Merge lp:~charlesk/indicator-session/lp-1024395 into lp:indicator-session/12.10

Proposed by Charles Kerr
Status: Merged
Approved by: Charles Kerr
Approved revision: 349
Merged at revision: 348
Proposed branch: lp:~charlesk/indicator-session/lp-1024395
Merge into: lp:indicator-session/12.10
Diff against target: 141 lines (+42/-37)
2 files modified
src/indicator-session.c (+6/-5)
src/user-widget.c (+36/-32)
To merge this branch: bzr merge lp:~charlesk/indicator-session/lp-1024395
Reviewer Review Type Date Requested Status
Lars Karlitski (community) Approve
jenkins (community) continuous-integration Approve
Review via email: mp+120683@code.launchpad.net
To post a comment you must log in.
Revision history for this message
jenkins (martin-mrazik+qa) wrote :
review: Approve (continuous-integration)
Revision history for this message
Lars Karlitski (larsu) wrote :

> - static const int ICON_SIZE = 24;

\o/

Why do you sometimes use GTK_ICON_SIZE_BUTTON and sometimes _MENU? That reminds me, I wanted to find out why _MENU is so small...

review: Approve
Revision history for this message
Charles Kerr (charlesk) wrote :

I'm using GTK_ICON_SIZE_BUTTON for the IndicatorObjectEntry's icon (ie, the one that gets shown in the bar) and GTK_ICON_SIZE_MENU for the menuitems.

many of the IndicatorObjectEntry's icons use indicator-image-helper's hardcoded 22 pixels. I went with GTK_ICON_SIZE_BUTTON because its default pixel value of 20 was the closest to that number so that there would be some consistency between IOE icon sizes.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/indicator-session.c'
2--- src/indicator-session.c 2012-06-18 17:35:05 +0000
3+++ src/indicator-session.c 2012-08-22 00:39:19 +0000
4@@ -36,7 +36,6 @@
5 #include <libindicator/indicator.h>
6 #include <libindicator/indicator-object.h>
7 #include <libindicator/indicator-service-manager.h>
8-#include <libindicator/indicator-image-helper.h>
9
10 #include "shared-names.h"
11 #include "user-widget.h"
12@@ -117,6 +116,8 @@
13 static void
14 indicator_session_init (IndicatorSession *self)
15 {
16+ const gchar * icon_name;
17+
18 self->settings = g_settings_new ("com.canonical.indicator.session");
19
20 /* Now let's fire these guys up. */
21@@ -131,9 +132,8 @@
22 self->entry.name_hint = PACKAGE;
23 self->entry.accessible_desc = _("Session Menu");
24 self->entry.label = GTK_LABEL (gtk_label_new ("User Name"));
25- self->entry.image = greeter_mode
26- ? indicator_image_helper (GREETER_ICON_DEFAULT)
27- : indicator_image_helper (ICON_DEFAULT);
28+ icon_name = greeter_mode ? GREETER_ICON_DEFAULT : ICON_DEFAULT;
29+ self->entry.image = GTK_IMAGE (gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON));
30 self->entry.menu = GTK_MENU (dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME,
31 INDICATOR_SESSION_DBUS_OBJECT));
32 g_settings_bind (self->settings, "show-real-name-on-panel",
33@@ -341,7 +341,8 @@
34 }
35 else if (!g_strcmp0(signal_name, "RestartRequired"))
36 {
37- indicator_image_helper_update (self->entry.image, greeter_mode ? GREETER_ICON_RESTART : ICON_RESTART);
38+ const gchar * icon_name = greeter_mode ? GREETER_ICON_RESTART : ICON_RESTART;
39+ gtk_image_set_from_icon_name (GTK_IMAGE(self->entry.image), icon_name, GTK_ICON_SIZE_MENU);
40 self->entry.accessible_desc = _("Device Menu (reboot required)");
41 g_signal_emit (G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE_ID, 0, &self->entry);
42 }
43
44=== modified file 'src/user-widget.c'
45--- src/user-widget.c 2012-07-05 15:46:44 +0000
46+++ src/user-widget.c 2012-08-22 00:39:19 +0000
47@@ -89,9 +89,8 @@
48 // Create the UI elements.
49 priv->user_image = gtk_image_new ();
50 gtk_misc_set_alignment(GTK_MISC(priv->user_image), 0.0, 0.0);
51- gtk_misc_set_padding (GTK_MISC(priv->user_image),0, 4.0);
52
53- priv->user_name = gtk_label_new ("");
54+ priv->user_name = gtk_label_new (NULL);
55
56 priv->container = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
57
58@@ -180,40 +179,43 @@
59 ****
60 ***/
61
62-static const int ICON_SIZE = 24;
63-
64 static void
65 update_icon (UserWidget * self, DbusmenuMenuitem * mi)
66 {
67- GdkPixbuf * pixbuf = NULL;
68+ gboolean updated = FALSE;
69+ GtkImage * image = GTK_IMAGE(self->priv->user_image);
70
71- /* first, try the menuitem's icon property */
72+ /* first try the menuitem's icon property */
73 const gchar * icon_name = dbusmenu_menuitem_property_get (mi, USER_ITEM_PROP_ICON);
74- if (icon_name)
75- {
76- GError* error = NULL;
77- pixbuf = gdk_pixbuf_new_from_file_at_size (icon_name, ICON_SIZE, ICON_SIZE, &error);
78- if (error != NULL)
79- {
80- g_warning ("Couldn't load the image \"%s\": %s", icon_name, error->message);
81- g_clear_error (&error);
82- }
83- }
84-
85- /* as a fallback, try to use the default user icon */
86- if (pixbuf == NULL)
87- {
88- pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
89- USER_ITEM_ICON_DEFAULT,
90- ICON_SIZE,
91- GTK_ICON_LOOKUP_FORCE_SIZE,
92- NULL);
93- }
94-
95- if (pixbuf != NULL)
96- {
97- gtk_image_set_from_pixbuf (GTK_IMAGE(self->priv->user_image), pixbuf);
98- g_object_unref (pixbuf);
99+ if (icon_name != NULL)
100+ {
101+ int width = 18; /* arbitrary default values */
102+ int height = 18;
103+ GError * err = NULL;
104+ GdkPixbuf * pixbuf = NULL;
105+
106+ /* load the image */
107+ gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, &height);
108+ pixbuf = gdk_pixbuf_new_from_file_at_size (icon_name, width, height, &err);
109+ if (err == NULL)
110+ {
111+ gtk_image_set_from_pixbuf (image, pixbuf);
112+ g_object_unref (pixbuf);
113+ updated = TRUE;
114+ }
115+ else
116+ {
117+ g_warning ("Couldn't load the image \"%s\": %s", icon_name, err->message);
118+ g_clear_error (&err);
119+ }
120+ }
121+
122+ /* as a fallback, use the default user icon */
123+ if (!updated)
124+ {
125+ gtk_image_set_from_icon_name (image,
126+ USER_ITEM_ICON_DEFAULT,
127+ GTK_ICON_SIZE_MENU);
128 }
129 }
130
131@@ -277,7 +279,9 @@
132
133 /**
134 * user_widget_new:
135- * @returns: a new #UserWidget.
136+ * @item: the #DbusmenuMenuitem this widget will render.
137+ *
138+ * Returns: (transfer full): a new #UserWidget.
139 **/
140 GtkWidget*
141 user_widget_new (DbusmenuMenuitem *item)

Subscribers

People subscribed via source and target branches