aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2012-08-22 01:28:40 -0500
committerCharles Kerr <charles.kerr@canonical.com>2012-08-22 01:28:40 -0500
commit6468eba432ae085f71d9d256bed206391c280538 (patch)
tree3eb67c4cd60e746e3339f295ddf9a62acf468538
parentc69973f9c525f8c3c8681374111f2c0f839005d3 (diff)
parent58a88cde17abc8dfaf9a047229d564f54e947677 (diff)
downloadayatana-indicator-session-6468eba432ae085f71d9d256bed206391c280538.tar.gz
ayatana-indicator-session-6468eba432ae085f71d9d256bed206391c280538.tar.bz2
ayatana-indicator-session-6468eba432ae085f71d9d256bed206391c280538.zip
merge lp:~charlesk/indicator-session/lp-1024395 to fix user menu icon sizes.
-rw-r--r--src/indicator-session.c11
-rw-r--r--src/user-widget.c56
2 files changed, 36 insertions, 31 deletions
diff --git a/src/indicator-session.c b/src/indicator-session.c
index 53ff87e..3038948 100644
--- a/src/indicator-session.c
+++ b/src/indicator-session.c
@@ -36,7 +36,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <libindicator/indicator.h>
#include <libindicator/indicator-object.h>
#include <libindicator/indicator-service-manager.h>
-#include <libindicator/indicator-image-helper.h>
#include "shared-names.h"
#include "user-widget.h"
@@ -117,6 +116,8 @@ indicator_session_class_init (IndicatorSessionClass *klass)
static void
indicator_session_init (IndicatorSession *self)
{
+ const gchar * icon_name;
+
self->settings = g_settings_new ("com.canonical.indicator.session");
/* Now let's fire these guys up. */
@@ -131,9 +132,8 @@ indicator_session_init (IndicatorSession *self)
self->entry.name_hint = PACKAGE;
self->entry.accessible_desc = _("Session Menu");
self->entry.label = GTK_LABEL (gtk_label_new ("User Name"));
- self->entry.image = greeter_mode
- ? indicator_image_helper (GREETER_ICON_DEFAULT)
- : indicator_image_helper (ICON_DEFAULT);
+ icon_name = greeter_mode ? GREETER_ICON_DEFAULT : ICON_DEFAULT;
+ self->entry.image = GTK_IMAGE (gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON));
self->entry.menu = GTK_MENU (dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME,
INDICATOR_SESSION_DBUS_OBJECT));
g_settings_bind (self->settings, "show-real-name-on-panel",
@@ -341,7 +341,8 @@ receive_signal (GDBusProxy * proxy,
}
else if (!g_strcmp0(signal_name, "RestartRequired"))
{
- indicator_image_helper_update (self->entry.image, greeter_mode ? GREETER_ICON_RESTART : ICON_RESTART);
+ const gchar * icon_name = greeter_mode ? GREETER_ICON_RESTART : ICON_RESTART;
+ gtk_image_set_from_icon_name (GTK_IMAGE(self->entry.image), icon_name, GTK_ICON_SIZE_MENU);
self->entry.accessible_desc = _("Device Menu (reboot required)");
g_signal_emit (G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE_ID, 0, &self->entry);
}
diff --git a/src/user-widget.c b/src/user-widget.c
index b0d2dd4..79b87b0 100644
--- a/src/user-widget.c
+++ b/src/user-widget.c
@@ -89,9 +89,8 @@ user_widget_init (UserWidget *self)
// Create the UI elements.
priv->user_image = gtk_image_new ();
gtk_misc_set_alignment(GTK_MISC(priv->user_image), 0.0, 0.0);
- gtk_misc_set_padding (GTK_MISC(priv->user_image),0, 4.0);
- priv->user_name = gtk_label_new ("");
+ priv->user_name = gtk_label_new (NULL);
priv->container = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
@@ -180,40 +179,43 @@ user_widget_primitive_draw_cb_gtk_3 (GtkWidget *widget,
****
***/
-static const int ICON_SIZE = 24;
-
static void
update_icon (UserWidget * self, DbusmenuMenuitem * mi)
{
- GdkPixbuf * pixbuf = NULL;
+ gboolean updated = FALSE;
+ GtkImage * image = GTK_IMAGE(self->priv->user_image);
- /* first, try the menuitem's icon property */
+ /* first try the menuitem's icon property */
const gchar * icon_name = dbusmenu_menuitem_property_get (mi, USER_ITEM_PROP_ICON);
- if (icon_name)
+ if (icon_name != NULL)
{
- GError* error = NULL;
- pixbuf = gdk_pixbuf_new_from_file_at_size (icon_name, ICON_SIZE, ICON_SIZE, &error);
- if (error != NULL)
+ int width = 18; /* arbitrary default values */
+ int height = 18;
+ GError * err = NULL;
+ GdkPixbuf * pixbuf = NULL;
+
+ /* load the image */
+ gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, &height);
+ pixbuf = gdk_pixbuf_new_from_file_at_size (icon_name, width, height, &err);
+ if (err == NULL)
{
- g_warning ("Couldn't load the image \"%s\": %s", icon_name, error->message);
- g_clear_error (&error);
+ gtk_image_set_from_pixbuf (image, pixbuf);
+ g_object_unref (pixbuf);
+ updated = TRUE;
+ }
+ else
+ {
+ g_warning ("Couldn't load the image \"%s\": %s", icon_name, err->message);
+ g_clear_error (&err);
}
}
- /* as a fallback, try to use the default user icon */
- if (pixbuf == NULL)
- {
- pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
- USER_ITEM_ICON_DEFAULT,
- ICON_SIZE,
- GTK_ICON_LOOKUP_FORCE_SIZE,
- NULL);
- }
-
- if (pixbuf != NULL)
+ /* as a fallback, use the default user icon */
+ if (!updated)
{
- gtk_image_set_from_pixbuf (GTK_IMAGE(self->priv->user_image), pixbuf);
- g_object_unref (pixbuf);
+ gtk_image_set_from_icon_name (image,
+ USER_ITEM_ICON_DEFAULT,
+ GTK_ICON_SIZE_MENU);
}
}
@@ -277,7 +279,9 @@ user_widget_set_twin_item (UserWidget * self, DbusmenuMenuitem * mi)
/**
* user_widget_new:
- * @returns: a new #UserWidget.
+ * @item: the #DbusmenuMenuitem this widget will render.
+ *
+ * Returns: (transfer full): a new #UserWidget.
**/
GtkWidget*
user_widget_new (DbusmenuMenuitem *item)