1
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
3
* Copyright (C) 2010 Red Hat, Inc
4
* Copyright (C) 2008 William Jon McCann <jmccann@redhat.com>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
#include "cc-info-panel.h"
29
#include <glib/gi18n.h>
31
#include <gio/gunixmounts.h>
33
#include <glibtop/fsusage.h>
34
#include <glibtop/mountlist.h>
35
#include <glibtop/mem.h>
36
#include <glibtop/sysinfo.h>
38
#define GNOME_SESSION_MANAGER_SCHEMA "org.gnome.desktop.session"
39
#define KEY_SESSION_NAME "session-name"
41
#define WID(b, w) (GtkWidget *) gtk_builder_get_object (b, w)
43
G_DEFINE_DYNAMIC_TYPE (CcInfoPanel, cc_info_panel, CC_TYPE_PANEL)
45
#define INFO_PANEL_PRIVATE(o) \
46
(G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_INFO_PANEL, CcInfoPanelPrivate))
49
/* Will be one of the other two below, or "Unknown" */
50
const char *hardware_string;
52
char *xorg_vesa_hardware;
56
struct _CcInfoPanelPrivate
60
char *gnome_distributor;
62
gboolean updates_available;
66
GList *primary_mounts;
68
GCancellable *cancellable;
70
GDBusConnection *session_bus;
72
GDBusProxy *pk_transaction_proxy;
73
GSettings *session_settings;
75
GraphicsData *graphics_data;
78
static void get_primary_disc_info_start (CcInfoPanel *self);
91
version_start_element_handler (GMarkupParseContext *ctx,
92
const char *element_name,
93
const char **attr_names,
94
const char **attr_values,
98
VersionData *data = user_data;
99
if (g_str_equal (element_name, "platform"))
100
data->current = &data->major;
101
else if (g_str_equal (element_name, "minor"))
102
data->current = &data->minor;
103
else if (g_str_equal (element_name, "micro"))
104
data->current = &data->micro;
105
else if (g_str_equal (element_name, "distributor"))
106
data->current = &data->distributor;
107
else if (g_str_equal (element_name, "date"))
108
data->current = &data->date;
110
data->current = NULL;
114
version_end_element_handler (GMarkupParseContext *ctx,
115
const char *element_name,
119
VersionData *data = user_data;
120
data->current = NULL;
124
version_text_handler (GMarkupParseContext *ctx,
130
VersionData *data = user_data;
131
if (data->current != NULL)
132
*data->current = g_strstrip (g_strdup (text));
136
load_gnome_version (char **version,
140
GMarkupParser version_parser = {
141
version_start_element_handler,
142
version_end_element_handler,
143
version_text_handler,
148
GMarkupParseContext *ctx;
157
if (!g_file_get_contents (DATADIR "/gnome/gnome-version.xml",
163
data = g_new0 (VersionData, 1);
164
ctx = g_markup_parse_context_new (&version_parser, 0, data, NULL);
166
if (!g_markup_parse_context_parse (ctx, contents, length, &error))
168
g_warning ("Invalid version file: '%s'", error->message);
173
*version = g_strdup_printf ("%s.%s.%s", data->major, data->minor, data->micro);
174
if (distributor != NULL)
175
*distributor = g_strdup (data->distributor);
177
*date = g_strdup (data->date);
182
g_markup_parse_context_free (ctx);
183
g_free (data->major);
184
g_free (data->minor);
185
g_free (data->micro);
186
g_free (data->distributor);
201
prettify_info (const char *info)
205
static const ReplaceStrings rs[] = {
207
{ "Intel[(]R[)]", "Intel<sup>\302\256</sup>"},
208
{ "Core[(]TM[)]", "Core<sup>\342\204\242</sup>"},
209
{ "Atom[(]TM[)]", "Atom<sup>\342\204\242</sup>"},
210
{ "Graphics Controller", "Graphics"},
213
pretty = g_markup_escape_text (info, -1);
215
for (i = 0; i < G_N_ELEMENTS (rs); i++)
223
re = g_regex_new (rs[i].regex, 0, 0, &error);
226
g_warning ("Error building regex: %s", error->message);
227
g_error_free (error);
231
new = g_regex_replace_literal (re,
243
g_warning ("Error replacing %s: %s", rs[i].regex, error->message);
244
g_error_free (error);
256
graphics_data_free (GraphicsData *gdata)
258
g_free (gdata->xorg_vesa_hardware);
259
g_free (gdata->glx_renderer);
260
g_slice_free (GraphicsData, gdata);
264
get_graphics_data_glx_renderer (void)
268
GMatchInfo *match_info;
273
info = g_string_new (NULL);
276
g_spawn_command_line_sync ("glxinfo -l", &output, NULL, NULL, &error);
279
g_warning ("Unable to get graphics info: %s", error->message);
280
g_error_free (error);
284
re = g_regex_new ("^OpenGL renderer string: (.+)$", G_REGEX_MULTILINE, 0, &error);
287
g_warning ("Error building regex: %s", error->message);
288
g_error_free (error);
292
g_regex_match (re, output, 0, &match_info);
293
while (g_match_info_matches (match_info))
297
device = g_match_info_fetch (match_info, 1);
298
g_string_append_printf (info, "%s ", device);
301
g_match_info_next (match_info, NULL);
303
g_match_info_free (match_info);
308
result = prettify_info (info->str);
309
g_string_free (info, TRUE);
315
get_graphics_data_xorg_vesa_hardware (void)
321
GError *error = NULL;
329
display = g_getenv ("DISPLAY");
333
re = g_regex_new ("^:([0-9]+)", 0, 0, NULL);
334
g_assert (re != NULL);
336
g_regex_match (re, display, 0, &match);
338
if (!g_match_info_matches (match))
341
g_match_info_free (match);
345
display_num = g_match_info_fetch (match, 1);
349
g_match_info_free (match);
353
log_path = g_strdup_printf ("/var/log/Xorg.%s.log", display_num);
354
g_free (display_num);
356
g_file_get_contents (log_path, &log_contents, &log_len, &error);
361
re = g_regex_new ("VESA VBE OEM Product: (.*)$", G_REGEX_MULTILINE, 0, NULL);
362
g_assert (re != NULL);
364
g_regex_match (re, log_contents, 0, &match);
365
if (g_match_info_matches (match))
369
tmp = g_match_info_fetch (match, 1);
370
pretty_tmp = prettify_info (tmp);
372
/* Translators: VESA is an techncial acronym, don't translate it. */
373
result = g_strdup_printf (_("VESA: %s"), pretty_tmp);
376
g_match_info_free (match);
382
static GraphicsData *
383
get_graphics_data (void)
385
GraphicsData *result;
387
result = g_slice_new0 (GraphicsData);
389
result->glx_renderer = get_graphics_data_glx_renderer ();
390
result->xorg_vesa_hardware = get_graphics_data_xorg_vesa_hardware ();
392
if (result->xorg_vesa_hardware != NULL)
393
result->hardware_string = result->xorg_vesa_hardware;
394
else if (result->glx_renderer != NULL)
395
result->hardware_string = result->glx_renderer;
397
result->hardware_string = _("Unknown");
403
get_current_is_fallback (CcInfoPanel *self)
408
gboolean is_fallback;
411
if (!(reply = g_dbus_connection_call_sync (self->priv->session_bus,
412
"org.gnome.SessionManager",
413
"/org/gnome/SessionManager",
414
"org.freedesktop.DBus.Properties",
416
g_variant_new ("(ss)", "org.gnome.SessionManager", "session-name"),
417
(GVariantType*)"(v)",
422
g_warning ("Failed to get fallback mode: %s", error->message);
423
g_clear_error (&error);
427
g_variant_get (reply, "(v)", &reply_str);
428
is_fallback = g_strcmp0 ("gnome-fallback", g_variant_get_string (reply_str, NULL)) == 0;
429
g_variant_unref (reply_str);
430
g_variant_unref (reply);
436
cc_info_panel_get_property (GObject *object,
444
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
449
cc_info_panel_set_property (GObject *object,
457
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
462
cc_info_panel_dispose (GObject *object)
464
CcInfoPanelPrivate *priv = CC_INFO_PANEL (object)->priv;
466
if (priv->builder != NULL)
468
g_object_unref (priv->builder);
469
priv->builder = NULL;
472
if (priv->pk_proxy != NULL)
474
g_object_unref (priv->pk_proxy);
475
priv->pk_proxy = NULL;
478
if (priv->pk_transaction_proxy != NULL)
480
g_object_unref (priv->pk_transaction_proxy);
481
priv->pk_transaction_proxy = NULL;
484
if (priv->graphics_data != NULL)
486
graphics_data_free (priv->graphics_data);
487
priv->graphics_data = NULL;
490
G_OBJECT_CLASS (cc_info_panel_parent_class)->dispose (object);
494
cc_info_panel_finalize (GObject *object)
496
CcInfoPanelPrivate *priv = CC_INFO_PANEL (object)->priv;
498
if (priv->cancellable != NULL)
500
g_cancellable_cancel (priv->cancellable);
501
priv->cancellable = NULL;
503
g_free (priv->gnome_version);
504
g_free (priv->gnome_date);
505
g_free (priv->gnome_distributor);
507
G_OBJECT_CLASS (cc_info_panel_parent_class)->finalize (object);
511
cc_info_panel_class_init (CcInfoPanelClass *klass)
513
GObjectClass *object_class = G_OBJECT_CLASS (klass);
515
g_type_class_add_private (klass, sizeof (CcInfoPanelPrivate));
517
object_class->get_property = cc_info_panel_get_property;
518
object_class->set_property = cc_info_panel_set_property;
519
object_class->dispose = cc_info_panel_dispose;
520
object_class->finalize = cc_info_panel_finalize;
524
cc_info_panel_class_finalize (CcInfoPanelClass *klass)
533
if (GLIB_SIZEOF_VOID_P == 8)
538
/* translators: This is the type of architecture, for example:
539
* "64-bit" or "32-bit" */
540
return g_strdup_printf (_("%d-bit"), bits);
543
#define KILOBYTE_FACTOR (G_GOFFSET_CONSTANT (1000))
544
#define MEGABYTE_FACTOR (KILOBYTE_FACTOR * KILOBYTE_FACTOR)
545
#define GIGABYTE_FACTOR (MEGABYTE_FACTOR * KILOBYTE_FACTOR)
546
#define TERABYTE_FACTOR (GIGABYTE_FACTOR * KILOBYTE_FACTOR)
547
#define PETABYTE_FACTOR (TERABYTE_FACTOR * KILOBYTE_FACTOR)
548
#define EXABYTE_FACTOR (PETABYTE_FACTOR * KILOBYTE_FACTOR)
551
format_size_for_display (goffset size)
553
if (size < (goffset) KILOBYTE_FACTOR)
554
return g_strdup_printf (g_dngettext(NULL, "%u byte", "%u bytes",(guint) size), (guint) size);
557
gdouble displayed_size;
559
if (size < (goffset) MEGABYTE_FACTOR)
561
displayed_size = (gdouble) size / (gdouble) KILOBYTE_FACTOR;
562
return g_strdup_printf (_("%.1f KB"), displayed_size);
564
else if (size < (goffset) GIGABYTE_FACTOR)
566
displayed_size = (gdouble) size / (gdouble) MEGABYTE_FACTOR;
567
return g_strdup_printf (_("%.1f MB"), displayed_size);
569
else if (size < (goffset) TERABYTE_FACTOR)
571
displayed_size = (gdouble) size / (gdouble) GIGABYTE_FACTOR;
572
return g_strdup_printf (_("%.1f GB"), displayed_size);
574
else if (size < (goffset) PETABYTE_FACTOR)
576
displayed_size = (gdouble) size / (gdouble) TERABYTE_FACTOR;
577
return g_strdup_printf (_("%.1f TB"), displayed_size);
579
else if (size < (goffset) EXABYTE_FACTOR)
581
displayed_size = (gdouble) size / (gdouble) PETABYTE_FACTOR;
582
return g_strdup_printf (_("%.1f PB"), displayed_size);
586
displayed_size = (gdouble) size / (gdouble) EXABYTE_FACTOR;
587
return g_strdup_printf (_("%.1f EB"), displayed_size);
593
query_done (GFile *file,
598
GError *error = NULL;
600
self->priv->cancellable = NULL;
601
info = g_file_query_filesystem_info_finish (file, res, &error);
605
path = g_file_get_path (file);
606
g_warning ("Failed to get filesystem free space for '%s': %s", path, error->message);
608
g_error_free (error);
612
self->priv->total_bytes += g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE);
613
g_object_unref (info);
615
/* And onto the next element */
616
get_primary_disc_info_start (self);
620
get_primary_disc_info_start (CcInfoPanel *self)
622
GUnixMountEntry *mount;
625
if (self->priv->primary_mounts == NULL)
630
size = format_size_for_display (self->priv->total_bytes);
631
widget = WID (self->priv->builder, "disk_label");
632
gtk_label_set_text (GTK_LABEL (widget), size);
638
mount = self->priv->primary_mounts->data;
639
self->priv->primary_mounts = g_list_remove (self->priv->primary_mounts, mount);
640
file = g_file_new_for_path (g_unix_mount_get_mount_path (mount));
641
g_unix_mount_free (mount);
643
self->priv->cancellable = g_cancellable_new ();
645
g_file_query_filesystem_info_async (file,
646
G_FILE_ATTRIBUTE_FILESYSTEM_FREE,
648
self->priv->cancellable,
649
(GAsyncReadyCallback) query_done,
651
g_object_unref (file);
655
get_primary_disc_info (CcInfoPanel *self)
660
points = g_unix_mount_points_get (NULL);
661
for (p = points; p != NULL; p = p->next)
663
GUnixMountEntry *mount = p->data;
664
const char *mount_path;
666
mount_path = g_unix_mount_get_mount_path (mount);
668
if (g_str_has_prefix (mount_path, "/media/")
669
|| g_str_has_prefix (mount_path, g_get_home_dir ()))
671
g_unix_mount_free (mount);
675
self->priv->primary_mounts = g_list_prepend (self->priv->primary_mounts, mount);
677
g_list_free (points);
679
get_primary_disc_info_start (self);
683
remove_duplicate_whitespace (const char *old)
690
re = g_regex_new ("[ \t\n\r]+", G_REGEX_MULTILINE, 0, &error);
693
g_warning ("Error building regex: %s", error->message);
694
g_error_free (error);
695
return g_strdup (old);
697
new = g_regex_replace (re,
707
g_warning ("Error replacing string: %s", error->message);
708
g_error_free (error);
709
return g_strdup (old);
717
get_cpu_info (const glibtop_sysinfo *info)
727
counts = g_hash_table_new (g_str_hash, g_str_equal);
729
/* count duplicates */
730
for (i = 0; i != info->ncpu; ++i)
732
const char * const keys[] = { "model name", "cpu" };
738
for (j = 0; model == NULL && j != G_N_ELEMENTS (keys); ++j)
740
model = g_hash_table_lookup (info->cpuinfo[i].values,
745
model = _("Unknown model");
747
count = g_hash_table_lookup (counts, model);
749
g_hash_table_insert (counts, model, GINT_TO_POINTER (1));
751
g_hash_table_replace (counts, model, GINT_TO_POINTER (GPOINTER_TO_INT (count) + 1));
754
cpu = g_string_new (NULL);
755
g_hash_table_iter_init (&iter, counts);
756
while (g_hash_table_iter_next (&iter, &key, &value))
761
count = GPOINTER_TO_INT (value);
762
stripped = remove_duplicate_whitespace ((const char *)key);
764
g_string_append_printf (cpu, "%s \303\227 %d ", stripped, count);
766
g_string_append_printf (cpu, "%s ", stripped);
770
g_hash_table_destroy (counts);
772
ret = prettify_info (cpu->str);
773
g_string_free (cpu, TRUE);
779
on_section_changed (GtkTreeSelection *selection,
782
CcInfoPanel *self = CC_INFO_PANEL (data);
789
if (!gtk_tree_selection_get_selected (selection, &model, &iter))
792
path = gtk_tree_model_get_path (model, &iter);
794
indices = gtk_tree_path_get_indices (path);
799
g_object_set (G_OBJECT (WID (self->priv->builder, "notebook")),
800
"page", index, NULL);
803
gtk_tree_path_free (path);
807
switch_fallback_get_mapping (GValue *value,
813
setting = g_variant_get_string (variant, NULL);
814
g_value_set_boolean (value, strcmp (setting, "gnome") != 0);
819
toggle_fallback_warning_label (CcInfoPanel *self,
825
widget = WID (self->priv->builder, "graphics_logout_warning_label");
827
if (self->priv->is_fallback)
828
text = _("The next login will attempt to use the standard experience.");
830
text = _("The next login will use the fallback mode intended for unsupported graphics hardware.");
832
gtk_label_set_text (GTK_LABEL (widget), text);
835
gtk_widget_show (widget);
837
gtk_widget_hide (widget);
841
switch_fallback_set_mapping (const GValue *value,
842
const GVariantType *expected_type,
845
CcInfoPanel *self = data;
848
is_set = g_value_get_boolean (value);
849
if (is_set != self->priv->is_fallback)
850
toggle_fallback_warning_label (self, TRUE);
852
toggle_fallback_warning_label (self, FALSE);
854
return g_variant_new_string (is_set ? "gnome-fallback" : "gnome");
858
info_panel_setup_graphics (CcInfoPanel *self)
864
widget = WID (self->priv->builder, "graphics_driver_label");
865
gtk_label_set_markup (GTK_LABEL (widget), self->priv->graphics_data->hardware_string);
867
self->priv->is_fallback = get_current_is_fallback (self);
868
if (self->priv->is_fallback)
870
/* translators: The hardware is not able to run GNOME 3's
871
* shell, so we use the GNOME "Fallback" session */
872
text = g_strdup (C_("Experience", "Fallback"));
876
/* translators: The hardware is able to run GNOME 3's
877
* shell, also called "Standard" experience */
878
text = g_strdup (C_("Experience", "Standard"));
880
widget = WID (self->priv->builder, "graphics_experience_label");
881
gtk_label_set_markup (GTK_LABEL (widget), text ? text : "");
884
widget = WID (self->priv->builder, "graphics_fallback_switch_box");
885
sw = GTK_SWITCH (gtk_switch_new ());
886
g_settings_bind_with_mapping (self->priv->session_settings, KEY_SESSION_NAME,
888
switch_fallback_get_mapping,
889
switch_fallback_set_mapping, self, NULL);
890
gtk_box_pack_start (GTK_BOX (widget), GTK_WIDGET (sw), FALSE, FALSE, 0);
891
gtk_widget_show_all (GTK_WIDGET (sw));
895
default_app_changed (GtkAppChooserButton *button,
900
GError *error = NULL;
902
info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (button));
903
content_type = gtk_app_chooser_get_content_type (GTK_APP_CHOOSER (button));
904
if (g_app_info_set_as_default_for_type (info, content_type, &error) == FALSE)
906
g_warning ("Failed to set '%s' as the default application for '%s': %s",
907
g_app_info_get_name (info), content_type, error->message);
908
g_error_free (error);
912
/* Set https support for the browser as well */
913
if (g_str_equal (content_type, "x-scheme-handler/https"))
915
if (g_app_info_set_as_default_for_type (info, "x-scheme-handler/https", &error) == FALSE)
917
g_warning ("Failed to set '%s' as the default application for '%s': %s",
918
g_app_info_get_name (info), "x-scheme-handler/https", error->message);
919
g_error_free (error);
923
g_free (content_type);
924
g_object_unref (info);
928
info_panel_setup_default_app (CcInfoPanel *self,
929
const char *content_type,
938
GError *error = NULL;
940
table = WID (self->priv->builder, "default_apps_table");
942
/* FIXME: We need to do this because GtkAppChooser doesn't
943
* give us the opportunity to select what app should be selected
945
* https://bugzilla.gnome.org/show_bug.cgi?id=642706 */
946
info = g_app_info_get_default_for_type (content_type, FALSE);
947
if (info != NULL && g_app_info_set_as_last_used_for_type (info, content_type, &error) == FALSE)
949
g_warning ("Failed to set '%s' as the default application for '%s': %s",
950
g_app_info_get_name (info), content_type, error->message);
951
g_error_free (error);
954
g_object_unref (info);
956
button = gtk_app_chooser_button_new (content_type);
957
gtk_table_attach (GTK_TABLE (table), button,
958
left_attach, right_attach,
959
top_attach, bottom_attach, GTK_FILL, 0, 0, 0);
960
g_signal_connect (G_OBJECT (button), "changed",
961
G_CALLBACK (default_app_changed), self);
962
gtk_widget_show (button);
966
info_panel_setup_default_apps (CcInfoPanel *self)
968
info_panel_setup_default_app (self, "x-scheme-handler/http",
971
info_panel_setup_default_app (self, "x-scheme-handler/mailto",
974
info_panel_setup_default_app (self, "text/calendar",
977
info_panel_setup_default_app (self, "audio/x-vorbis+ogg",
980
info_panel_setup_default_app (self, "video/x-ogm+ogg",
983
info_panel_setup_default_app (self, "image/jpeg",
988
info_panel_setup_selector (CcInfoPanel *self)
992
GtkTreeSelection *selection;
993
GtkTreeViewColumn *column;
994
GtkCellRenderer *renderer;
996
int section_name_column = 0;
998
view = GTK_TREE_VIEW (WID (self->priv->builder, "overview_treeview"));
999
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
1001
model = gtk_list_store_new (1, G_TYPE_STRING);
1002
gtk_tree_view_set_model (view, GTK_TREE_MODEL (model));
1003
g_object_unref (model);
1005
renderer = gtk_cell_renderer_text_new ();
1006
g_object_set (renderer,
1008
"ellipsize", PANGO_ELLIPSIZE_END,
1010
column = gtk_tree_view_column_new_with_attributes (_("Section"),
1012
"text", section_name_column,
1014
gtk_tree_view_append_column (view, column);
1017
gtk_list_store_append (model, &iter);
1018
gtk_list_store_set (model, &iter, section_name_column,
1021
gtk_tree_selection_select_iter (selection, &iter);
1023
gtk_list_store_append (model, &iter);
1024
gtk_list_store_set (model, &iter, section_name_column,
1025
_("Default Applications"),
1028
gtk_list_store_append (model, &iter);
1029
gtk_list_store_set (model, &iter, section_name_column,
1033
g_signal_connect (selection, "changed",
1034
G_CALLBACK (on_section_changed), self);
1035
on_section_changed (selection, self);
1037
gtk_widget_show_all (GTK_WIDGET (view));
1041
info_panel_setup_overview (CcInfoPanel *self)
1046
const glibtop_sysinfo *info;
1049
res = load_gnome_version (&self->priv->gnome_version,
1050
&self->priv->gnome_distributor,
1051
&self->priv->gnome_date);
1054
widget = WID (self->priv->builder, "version_label");
1055
text = g_strdup_printf (_("Version %s"), self->priv->gnome_version);
1056
gtk_label_set_text (GTK_LABEL (widget), text);
1060
glibtop_get_mem (&mem);
1061
text = g_format_size_for_display (mem.total);
1062
widget = WID (self->priv->builder, "memory_label");
1063
gtk_label_set_text (GTK_LABEL (widget), text ? text : "");
1066
info = glibtop_get_sysinfo ();
1068
widget = WID (self->priv->builder, "processor_label");
1069
text = get_cpu_info (info);
1070
gtk_label_set_markup (GTK_LABEL (widget), text ? text : "");
1073
widget = WID (self->priv->builder, "os_type_label");
1074
text = get_os_type ();
1075
gtk_label_set_text (GTK_LABEL (widget), text ? text : "");
1078
get_primary_disc_info (self);
1080
widget = WID (self->priv->builder, "graphics_label");
1081
gtk_label_set_markup (GTK_LABEL (widget), self->priv->graphics_data->hardware_string);
1083
widget = WID (self->priv->builder, "info_vbox");
1084
gtk_widget_reparent (widget, (GtkWidget *) self);
1088
refresh_update_button (CcInfoPanel *self)
1092
widget = WID (self->priv->builder, "updates_button");
1093
if (self->priv->updates_available)
1094
gtk_widget_show (widget);
1096
gtk_widget_hide (widget);
1100
on_pk_transaction_signal (GDBusProxy *proxy,
1103
GVariant *parameters,
1106
if (g_strcmp0 (signal_name, "Package") == 0)
1108
self->priv->updates_available = TRUE;
1110
else if (g_strcmp0 (signal_name, "Finished") == 0)
1112
refresh_update_button (self);
1114
else if (g_strcmp0 (signal_name, "Destroy") == 0)
1116
g_object_unref (self->priv->pk_transaction_proxy);
1117
self->priv->pk_transaction_proxy = NULL;
1122
on_pk_get_updates_ready (GObject *source,
1130
result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source), res, &error);
1133
g_warning ("Error getting PackageKit updates list: %s", error->message);
1134
g_error_free (error);
1140
on_pk_get_tid_ready (GObject *source,
1149
result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source), res, &error);
1152
g_warning ("Error getting PackageKit transaction ID: %s", error->message);
1153
g_error_free (error);
1157
g_variant_get (result, "(s)", &tid);
1159
self->priv->pk_transaction_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
1160
G_DBUS_PROXY_FLAGS_NONE,
1162
"org.freedesktop.PackageKit",
1164
"org.freedesktop.PackageKit.Transaction",
1168
g_variant_unref (result);
1170
if (self->priv->pk_transaction_proxy == NULL)
1172
g_warning ("Unable to get PackageKit transaction proxy object");
1176
g_signal_connect (self->priv->pk_transaction_proxy,
1178
G_CALLBACK (on_pk_transaction_signal),
1181
g_dbus_proxy_call (self->priv->pk_transaction_proxy,
1183
g_variant_new ("(s)", "none"),
1184
G_DBUS_CALL_FLAGS_NONE,
1187
(GAsyncReadyCallback) on_pk_get_updates_ready,
1192
refresh_updates (CcInfoPanel *self)
1194
self->priv->updates_available = FALSE;
1196
g_assert (self->priv->pk_proxy != NULL);
1197
g_dbus_proxy_call (self->priv->pk_proxy,
1200
G_DBUS_CALL_FLAGS_NONE,
1203
(GAsyncReadyCallback) on_pk_get_tid_ready,
1208
on_pk_signal (GDBusProxy *proxy,
1211
GVariant *parameters,
1214
if (g_strcmp0 (signal_name, "UpdatesChanged") == 0)
1216
refresh_updates (self);
1221
on_updates_button_clicked (GtkWidget *widget,
1226
g_spawn_command_line_async ("gpk-update-viewer", &error);
1229
g_warning ("unable to launch Software Updates: %s", error->message);
1230
g_error_free (error);
1235
cc_info_panel_init (CcInfoPanel *self)
1237
GError *error = NULL;
1240
self->priv = INFO_PANEL_PRIVATE (self);
1242
self->priv->builder = gtk_builder_new ();
1244
self->priv->session_settings = g_settings_new (GNOME_SESSION_MANAGER_SCHEMA);
1246
self->priv->session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
1248
g_assert (self->priv->session_bus);
1250
self->priv->pk_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
1251
G_DBUS_PROXY_FLAGS_NONE,
1253
"org.freedesktop.PackageKit",
1254
"/org/freedesktop/PackageKit",
1255
"org.freedesktop.PackageKit",
1258
if (self->priv->pk_proxy == NULL)
1259
g_warning ("Unable to get PackageKit proxy object");
1262
g_signal_connect (self->priv->pk_proxy,
1264
G_CALLBACK (on_pk_signal),
1266
refresh_updates (self);
1269
gtk_builder_add_from_file (self->priv->builder,
1270
GNOMECC_UI_DIR "/info.ui",
1275
g_warning ("Could not load interface file: %s", error->message);
1276
g_error_free (error);
1280
self->priv->graphics_data = get_graphics_data ();
1282
widget = WID (self->priv->builder, "updates_button");
1283
g_signal_connect (widget, "clicked", G_CALLBACK (on_updates_button_clicked), self);
1285
info_panel_setup_selector (self);
1286
info_panel_setup_overview (self);
1287
info_panel_setup_default_apps (self);
1288
info_panel_setup_graphics (self);
1292
cc_info_panel_register (GIOModule *module)
1294
cc_info_panel_register_type (G_TYPE_MODULE (module));
1295
g_io_extension_point_implement (CC_SHELL_PANEL_EXTENSION_POINT,