diff options
author | William Hua <william.hua@canonical.com> | 2013-04-22 11:50:51 -0400 |
---|---|---|
committer | William Hua <william.hua@canonical.com> | 2013-04-22 11:50:51 -0400 |
commit | 19ec64915aac1ecf55f5b5aaa26358578dd2ac34 (patch) | |
tree | 57d0081c6f6fa26e9c304e3bd2e362614cfed108 | |
parent | 5cac96c229ed038b2e21f6a7a2ff08746c488019 (diff) | |
download | libayatana-indicator-19ec64915aac1ecf55f5b5aaa26358578dd2ac34.tar.gz libayatana-indicator-19ec64915aac1ecf55f5b5aaa26358578dd2ac34.tar.bz2 libayatana-indicator-19ec64915aac1ecf55f5b5aaa26358578dd2ac34.zip |
[ William Hua ]
* debian/control:
- Bump GLib to 2.37.
* configure.ac:
- Bump GLib to 2.37.
* libindicator/indicator-image-helper.c:
- Support display of GBytesIcons.
* libindicator/indicator-ng.c:
- Change action state icon type to GVariant.
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | debian/changelog | 14 | ||||
-rw-r--r-- | debian/control | 2 | ||||
-rw-r--r-- | libindicator/indicator-image-helper.c | 57 | ||||
-rw-r--r-- | libindicator/indicator-ng.c | 39 |
5 files changed, 88 insertions, 26 deletions
diff --git a/configure.ac b/configure.ac index 48f759f..3dc40f1 100644 --- a/configure.ac +++ b/configure.ac @@ -44,7 +44,7 @@ AS_IF([test "x$enable_deprecations" = xno], GTK_REQUIRED_VERSION=2.18 GTK3_REQUIRED_VERSION=3.6 -GIO_UNIX_REQUIRED_VERSION=2.22 +GIO_UNIX_REQUIRED_VERSION=2.37 AC_ARG_WITH([gtk], [AS_HELP_STRING([--with-gtk], diff --git a/debian/changelog b/debian/changelog index 17f10ee..506f167 100644 --- a/debian/changelog +++ b/debian/changelog @@ -36,6 +36,20 @@ libindicator (12.10.2daily13.04.08-0ubuntu1) raring; urgency=low -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Mon, 08 Apr 2013 02:02:11 +0000 +libindicator (12.10.2daily13.02.25-0ubuntu2) raring; urgency=low + + [ William Hua ] + * debian/control: + - Bump GLib to 2.37. + * configure.ac: + - Bump GLib to 2.37. + * libindicator/indicator-image-helper.c: + - Support display of GBytesIcons. + * libindicator/indicator-ng.c: + - Change action state icon type to GVariant. + + -- William Hua <william.hua@canonical.com> Wed, 17 Apr 2013 17:14:31 -0400 + libindicator (12.10.2daily13.02.25-0ubuntu1) raring; urgency=low * Automatic snapshot from revision 479 diff --git a/debian/control b/debian/control index 582965d..698ceda 100644 --- a/debian/control +++ b/debian/control @@ -12,7 +12,7 @@ Build-Depends: debhelper (>= 9), gtk-doc-tools, dbus-test-runner, xvfb, - libglib2.0-dev (>= 2.22), + libglib2.0-dev (>= 2.37), libgtk2.0-dev (>= 2.18), libgtk-3-dev (>= 2.91.3), Standards-Version: 3.9.2 diff --git a/libindicator/indicator-image-helper.c b/libindicator/indicator-image-helper.c index 382d0c9..ab09050 100644 --- a/libindicator/indicator-image-helper.c +++ b/libindicator/indicator-image-helper.c @@ -63,25 +63,60 @@ refresh_image (GtkImage * image) icon_filename = gtk_icon_info_get_filename(icon_info); } - /* show a broken image if we don't have a filename */ - if (icon_filename == NULL) { + if (icon_filename == NULL && !G_IS_BYTES_ICON (icon_names)) { + /* show a broken image if we don't have a filename */ gtk_image_set_from_stock (image, GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_LARGE_TOOLBAR); return; } /* Build a pixbuf */ GError * error = NULL; - GdkPixbuf * pixbuf = gdk_pixbuf_new_from_file(icon_filename, &error); + GdkPixbuf * pixbuf = NULL; - if (icon_info != NULL) { - gtk_icon_info_free(icon_info); - } + if (icon_filename == NULL) { + GInputStream * stream = g_loadable_icon_load (G_LOADABLE_ICON (icon_names), icon_size, NULL, NULL, &error); - if (pixbuf == NULL) { - g_warning("Unable to load icon from file '%s' because: %s", icon_filename, error == NULL ? "I don't know" : error->message); - g_clear_error (&error); - gtk_image_clear(image); - return; + if (error == NULL) { + pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, &error); + } + + if (error != NULL) { + if (stream != NULL) { + g_input_stream_close (stream, NULL, NULL); + g_object_unref (stream); + } + + if (icon_info != NULL) { + g_object_unref (icon_info); + } + + g_warning ("Unable to load icon from data: %s", error->message); + g_clear_error (&error); + gtk_image_clear (image); + return; + } + + g_input_stream_close (stream, NULL, &error); + + if (error != NULL) { + g_warning ("Unable to close input stream: %s", error->message); + g_clear_error (&error); + } + + g_object_unref (stream); + } else { + pixbuf = gdk_pixbuf_new_from_file (icon_filename, &error); + + if (icon_info != NULL) { + g_object_unref (icon_info); + } + + if (pixbuf == NULL) { + g_warning ("Unable to load icon from file '%s' because: %s", icon_filename, error == NULL ? "I don't know" : error->message); + g_clear_error (&error); + gtk_image_clear (image); + return; + } } /* Scale icon if all we get is something too big. */ diff --git a/libindicator/indicator-ng.c b/libindicator/indicator-ng.c index 1e95785..966e93f 100644 --- a/libindicator/indicator-ng.c +++ b/libindicator/indicator-ng.c @@ -179,13 +179,12 @@ indicator_ng_set_accessible_desc (IndicatorNg *self, } static void -indicator_ng_set_icon_from_string (IndicatorNg *self, - const gchar *str) +indicator_ng_set_icon_from_variant (IndicatorNg *self, + GVariant *variant) { GIcon *icon; - GError *error = NULL; - if (str == NULL || *str == '\0') + if (variant == NULL) { if (self->entry.image) { @@ -200,7 +199,7 @@ indicator_ng_set_icon_from_string (IndicatorNg *self, gtk_widget_show (GTK_WIDGET (self->entry.image)); - icon = g_icon_new_for_string (str, &error); + icon = g_icon_deserialize (variant); if (icon) { indicator_image_helper_update_from_gicon (self->entry.image, icon); @@ -208,9 +207,10 @@ indicator_ng_set_icon_from_string (IndicatorNg *self, } else { - g_warning ("invalid icon string '%s': %s", str, error->message); + gchar *text = g_variant_print (variant, TRUE); + g_warning ("invalid icon variant '%s'", text); gtk_image_set_from_stock (self->entry.image, GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_LARGE_TOOLBAR); - g_error_free (error); + g_free (text); } } @@ -236,9 +236,9 @@ static void indicator_ng_update_entry (IndicatorNg *self) { GVariant *state; - const gchar *label = NULL; - const gchar *iconstr = NULL; - const gchar *accessible_desc = NULL; + gchar *label = NULL; + GVariant *icon = NULL; + gchar *accessible_desc = NULL; gboolean visible = TRUE; g_return_if_fail (self->menu != NULL); @@ -254,12 +254,20 @@ indicator_ng_update_entry (IndicatorNg *self) state = g_action_group_get_action_state (self->actions, self->header_action); if (state && g_variant_is_of_type (state, G_VARIANT_TYPE ("(sssb)"))) { + gchar *iconstr = NULL; + g_variant_get (state, "(&s&s&sb)", &label, &iconstr, &accessible_desc, &visible); + + if (iconstr) + { + icon = g_variant_ref_sink (g_variant_new_string (iconstr)); + g_free (iconstr); + } } else if (state && g_variant_is_of_type (state, G_VARIANT_TYPE ("a{sv}"))) { g_variant_lookup (state, "label", "&s", &label); - g_variant_lookup (state, "icon", "&s", &iconstr); + g_variant_lookup (state, "icon", "*", &icon); g_variant_lookup (state, "accessible-desc", "&s", &accessible_desc); g_variant_lookup (state, "visible", "b", &visible); } @@ -268,12 +276,17 @@ indicator_ng_update_entry (IndicatorNg *self) if (label) indicator_ng_set_label (self, label); - if (iconstr) - indicator_ng_set_icon_from_string (self, iconstr); + if (icon) + indicator_ng_set_icon_from_variant (self, icon); if (accessible_desc) indicator_ng_set_accessible_desc (self, accessible_desc); indicator_object_set_visible (INDICATOR_OBJECT (self), visible); + g_free (accessible_desc); + g_free (label); + + if (icon) + g_variant_unref (icon); if (state) g_variant_unref (state); } |