Merge lp:~attente/libindicator/gicon-serialization into lp:libindicator/13.10

Proposed by William Hua
Status: Merged
Approved by: Lars Karlitski
Approved revision: 493
Merged at revision: 489
Proposed branch: lp:~attente/libindicator/gicon-serialization
Merge into: lp:libindicator/13.10
Diff against target: 216 lines (+76/-44)
4 files modified
configure.ac (+1/-1)
debian/control (+1/-1)
libindicator/indicator-image-helper.c (+53/-31)
libindicator/indicator-ng.c (+21/-11)
To merge this branch: bzr merge lp:~attente/libindicator/gicon-serialization
Reviewer Review Type Date Requested Status
Lars Karlitski (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Ted Gould (community) Needs Information
Review via email: mp+160148@code.launchpad.net

Commit message

Use GIcon's serialization/deserialization interface for indicator icons so that we can load icons as PNG data transmitted over the bus.

Description of the change

Use GIcon's serialization/deserialization interface for indicator icons so that we can load icons as PNG data transmitted over the bus.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:487
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~attente/libindicator/gicon-serialization/+merge/160148/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/libindicator-ci/9/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/libindicator-raring-amd64-ci/9/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/libindicator-raring-armhf-ci/9/console

Click here to trigger a rebuild:
http://s-jenkins:8080/job/libindicator-ci/9/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Lars Karlitski (larsu) wrote :

Thanks for the patch!

* We need to wait for the new glib before this can land (that's what Jenkins is complaining about).

* Why did you add a changelog entry? Daily releases are created automatically.

* The error checking logic in indicator-image-helper.c is weird. Don't check whether the error is set, but instead check the return value of the function (by convention, @error will be set when functions return NULL or FALSE). Also, use "else" :P

* In indicator_ng_update_entry, you removed the const from 'label' and 'accessible_desc' and freed those strings at the end of the function. That's wrong. They are filled with pointers to the serialized GVariant-data (that's what the '&' in the format string means).

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:489
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~attente/libindicator/gicon-serialization/+merge/160148/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/libindicator-ci/10/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/libindicator-raring-amd64-ci/10/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/libindicator-raring-armhf-ci/10/console

Click here to trigger a rebuild:
http://s-jenkins:8080/job/libindicator-ci/10/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:490
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~attente/libindicator/gicon-serialization/+merge/160148/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/libindicator-ci/11/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/libindicator-raring-amd64-ci/11/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/libindicator-raring-armhf-ci/11/console

Click here to trigger a rebuild:
http://s-jenkins:8080/job/libindicator-ci/11/rebuild

review: Needs Fixing (continuous-integration)
487. By Mathieu Trudel-Lapierre

Merge changelog changes from /13.04 branch for saucy.

Approved by PS Jenkins bot, Łukasz Zemczak.

488. By PS Jenkins bot

Releasing 12.10.2daily13.05.02-0ubuntu1 to ubuntu.

Approved by PS Jenkins bot.

Revision history for this message
Ted Gould (ted) wrote :

I'm a little confused on why we want this. It seems like sending PNGs over the bus is a bad idea because if we do that it'll be impossible to match the theme/resolution on the other side of the bus. I think for this to land we also need a way to communicate that information to the indicator service. This patch should really include that information mechanism as well.

review: Needs Information
Revision history for this message
Lars Karlitski (larsu) wrote :

This is for images that are not in the theme (for example user avatars or favicons).

This patch basically replaces g_icon_from_string() with g_icon_deserialize(), a new function in Gio which is a bit saner: it doesn't require GdkPixbuf on the other side of the bus. This will be handy for Unity 8, because Qt already has png decoding functionality, it should really not have to link against gdkpixbuf.

Revision history for this message
Ted Gould (ted) wrote :

On Sat, 2013-05-18 at 02:58 +0000, Lars Uebernickel wrote:

> This is for images that are not in the theme (for example user avatars
> or favicons).
>
> This patch basically replaces g_icon_from_string() with
> g_icon_deserialize(), a new function in Gio which is a bit saner: it
> doesn't require GdkPixbuf on the other side of the bus. This will be
> handy for Unity 8, because Qt already has png decoding functionality,
> it should really not have to link against gdkpixbuf.

But we don't allow icons that aren't in the theme on the panel. So I
don't see why we need it at all in libindicator. Sure it might be
needed for messaging menu and other things that use avatars, but
libindicator doesn't need that feature.

Revision history for this message
William Hua (attente) wrote :

The new keyboard indicator will probably need this support (see: https://wiki.ubuntu.com/LanguageAndText#Icon). But yes, you're correct that the indicator service will need to infer the theming information from the panel service to render the icons properly. I'm not sure if there's a better way than exposing that information through a DBus method though.

Revision history for this message
Lars Karlitski (larsu) wrote :

> But we don't allow icons that aren't in the theme on the panel. So I
> don't see why we need it at all in libindicator. Sure it might be
> needed for messaging menu and other things that use avatars, but
> libindicator doesn't need that feature.

Yes it does, IndicatorNg turns the indicator menu models into GtkMenus, and needs to convert icons into GtkImages in the process.

We probaby don't need it for indicator-image-helper (except maybe for the case Will is describing), but I think we should keep it for completeness sake. It would be confusing if we allowed custom icons in the menus but not in the panel itself.

Revision history for this message
Ted Gould (ted) wrote :

On Sat, 2013-05-18 at 05:24 +0000, William Hua wrote:

> The new keyboard indicator will probably need this support (see:
> https:��wiki.ubuntu.com�LanguageAndText#Icon). But yes, you're correct
> that the indicator service will need to infer the theming information
> from the panel service to render the icons properly. I'm not sure if
> there's a better way than exposing that information through a DBus
> method though.

Hmm, I don't see where it needs that. It has instructions for the
visual designers on the data in the icons, but I still don't see why
they shouldn't be in the theme. For instance, the background color
would be different depending on the theme. Computer generated icons are
never a good experience.

I think that what would make sense, as a temporary solution, is to have
indicator-keyboard generate fallback icons in the hicolor theme as part
of it's build. That way it can know they exist, but then allow a proper
theme to be generated as well.

Revision history for this message
Ted Gould (ted) wrote :

On Sat, 2013-05-18 at 13:00 +0000, Lars Uebernickel wrote:

> > But we don't allow icons that aren't in the theme on the panel. So I
> > don't see why we need it at all in libindicator. Sure it might be
> > needed for messaging menu and other things that use avatars, but
> > libindicator doesn't need that feature.
>
>
> Yes it does, IndicatorNg turns the indicator menu models into
> GtkMenus, and needs to convert icons into GtkImages in the process.

I'm not sure what you're saying here. Sure, they need to be bitmaps to
be on the screen at some point. But we still don't want them to be not
from the theme. It's not that it's not technically possible, it's a
non-feature and something that creates a worse user experience.

> We probaby don't need it for indicator-image-helper (except maybe for
> the case Will is describing), but I think we should keep it for
> completeness sake. It would be confusing if we allowed custom icons in
> the menus but not in the panel itself.

Hmm, not sure why it's confusing. :-) And frankly, it's what we
already do. This branch changes that. Let's not change it. The rule
in my mind is simply: icons, always theme names; user data, we take it
as high of resolution as we can get it and do as best we can. Things
like avatars are user data. User data never appears on the panel.

Revision history for this message
Lars Karlitski (larsu) wrote :

> > Yes it does, IndicatorNg turns the indicator menu models into
> > GtkMenus, and needs to convert icons into GtkImages in the process.
>
> I'm not sure what you're saying here. Sure, they need to be bitmaps to
> be on the screen at some point. But we still don't want them to be not
> from the theme. It's not that it's not technically possible, it's a
> non-feature and something that creates a worse user experience.

What I'm saying is that libindicator is responsible to turn any icon in any of the menus into a GtkImage now (through IndicatorNg). Themed icons will stay themed icons. File icons will stay file icons. The only change is that for bitmapped icons, we send a well-known format instead of something that relies on GdkPixbuf.

Bitmapped icons in the panel are a different topic, totally unrelated to this patch. Services can insert them now if they want to, but none of them does.

> > We probaby don't need it for indicator-image-helper (except maybe for
> > the case Will is describing), but I think we should keep it for
> > completeness sake. It would be confusing if we allowed custom icons in
> > the menus but not in the panel itself.
>
> Hmm, not sure why it's confusing. :-) And frankly, it's what we
> already do. This branch changes that. Let's not change it. The rule
> in my mind is simply: icons, always theme names; user data, we take it
> as high of resolution as we can get it and do as best we can. Things
> like avatars are user data. User data never appears on the panel.

Oh, now I understand where this misunderstanding is coming from. IndiciatorNg uses GIcon for every type of icon (themed, file, bitmapped). This patch doesn't change that, it simply changes the code to the new GIcon serialization API.

It would be confusing because the panel would support only a subset of the GIcon types that the menus support.

490. By William Hua

Remove changelog entry.

491. By William Hua

Don't free label and accessible_desc.

492. By William Hua

Clean up error checking.

493. By William Hua

Code clean-up.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Allan LeSage (allanlesage) wrote :

Updated to saucy; Jenkins now approves :) .

Revision history for this message
Lars Karlitski (larsu) wrote :

Looks good to me now, thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2013-01-18 21:18:27 +0000
3+++ configure.ac 2013-05-19 16:50:32 +0000
4@@ -44,7 +44,7 @@
5
6 GTK_REQUIRED_VERSION=2.18
7 GTK3_REQUIRED_VERSION=3.6
8-GIO_UNIX_REQUIRED_VERSION=2.22
9+GIO_UNIX_REQUIRED_VERSION=2.37
10
11 AC_ARG_WITH([gtk],
12 [AS_HELP_STRING([--with-gtk],
13
14=== modified file 'debian/control'
15--- debian/control 2012-11-22 17:19:57 +0000
16+++ debian/control 2013-05-19 16:50:32 +0000
17@@ -12,7 +12,7 @@
18 gtk-doc-tools,
19 dbus-test-runner,
20 xvfb,
21- libglib2.0-dev (>= 2.22),
22+ libglib2.0-dev (>= 2.37),
23 libgtk2.0-dev (>= 2.18),
24 libgtk-3-dev (>= 2.91.3),
25 Standards-Version: 3.9.2
26
27=== modified file 'libindicator/indicator-image-helper.c'
28--- libindicator/indicator-image-helper.c 2013-01-25 10:11:59 +0000
29+++ libindicator/indicator-image-helper.c 2013-05-19 16:50:32 +0000
30@@ -63,42 +63,64 @@
31 icon_filename = gtk_icon_info_get_filename(icon_info);
32 }
33
34- /* show a broken image if we don't have a filename */
35+ if (icon_filename == NULL && !G_IS_BYTES_ICON (icon_names)) {
36+ /* show a broken image if we don't have a filename or image data */
37+ gtk_image_set_from_stock (image, GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_LARGE_TOOLBAR);
38+ return;
39+ }
40+
41+ /* Build a pixbuf */
42+ GdkPixbuf * pixbuf = NULL;
43+
44 if (icon_filename == NULL) {
45+ GError * error = NULL;
46+ GInputStream * stream = g_loadable_icon_load (G_LOADABLE_ICON (icon_names), icon_size, NULL, NULL, &error);
47+
48+ if (stream != NULL) {
49+ pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, &error);
50+ g_input_stream_close (stream, NULL, NULL);
51+ g_object_unref (stream);
52+
53+ if (pixbuf == NULL) {
54+ g_warning ("Unable to load icon from data: %s", error->message);
55+ g_error_free (error);
56+ }
57+ } else {
58+ g_warning ("Unable to load icon from data: %s", error->message);
59+ g_error_free (error);
60+ }
61+ } else {
62+ GError * error = NULL;
63+
64+ pixbuf = gdk_pixbuf_new_from_file (icon_filename, &error);
65+
66+ if (pixbuf == NULL) {
67+ g_warning ("Unable to load icon from file '%s': %s", icon_filename, error->message);
68+ g_error_free (error);
69+ }
70+ }
71+
72+ if (pixbuf != NULL) {
73+ /* Scale icon if all we get is something too big. */
74+ if (gdk_pixbuf_get_height(pixbuf) > icon_size) {
75+ gfloat scale = (gfloat)icon_size / (gfloat)gdk_pixbuf_get_height(pixbuf);
76+ gint width = round(gdk_pixbuf_get_width(pixbuf) * scale);
77+
78+ GdkPixbuf * scaled = gdk_pixbuf_scale_simple(pixbuf, width, icon_size, GDK_INTERP_BILINEAR);
79+ g_object_unref(G_OBJECT(pixbuf));
80+ pixbuf = scaled;
81+ }
82+
83+ /* Put the pixbuf on the image */
84+ gtk_image_set_from_pixbuf(image, pixbuf);
85+ g_object_unref(G_OBJECT(pixbuf));
86+ } else {
87 gtk_image_set_from_stock (image, GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_LARGE_TOOLBAR);
88- return;
89 }
90
91- /* Build a pixbuf */
92- GError * error = NULL;
93- GdkPixbuf * pixbuf = gdk_pixbuf_new_from_file(icon_filename, &error);
94-
95 if (icon_info != NULL) {
96- gtk_icon_info_free(icon_info);
97- }
98-
99- if (pixbuf == NULL) {
100- g_warning("Unable to load icon from file '%s' because: %s", icon_filename, error == NULL ? "I don't know" : error->message);
101- g_clear_error (&error);
102- gtk_image_clear(image);
103- return;
104- }
105-
106- /* Scale icon if all we get is something too big. */
107- if (gdk_pixbuf_get_height(pixbuf) > icon_size) {
108- gfloat scale = (gfloat)icon_size / (gfloat)gdk_pixbuf_get_height(pixbuf);
109- gint width = round(gdk_pixbuf_get_width(pixbuf) * scale);
110-
111- GdkPixbuf * scaled = gdk_pixbuf_scale_simple(pixbuf, width, icon_size, GDK_INTERP_BILINEAR);
112- g_object_unref(G_OBJECT(pixbuf));
113- pixbuf = scaled;
114- }
115-
116- /* Put the pixbuf on the image */
117- gtk_image_set_from_pixbuf(image, pixbuf);
118- g_object_unref(G_OBJECT(pixbuf));
119-
120- return;
121+ gtk_icon_info_free (icon_info);
122+ }
123 }
124
125 /* Handles the theme changed signal to refresh the icon to make
126
127=== modified file 'libindicator/indicator-ng.c'
128--- libindicator/indicator-ng.c 2013-03-21 18:06:22 +0000
129+++ libindicator/indicator-ng.c 2013-05-19 16:50:32 +0000
130@@ -179,13 +179,12 @@
131 }
132
133 static void
134-indicator_ng_set_icon_from_string (IndicatorNg *self,
135- const gchar *str)
136+indicator_ng_set_icon_from_variant (IndicatorNg *self,
137+ GVariant *variant)
138 {
139 GIcon *icon;
140- GError *error = NULL;
141
142- if (str == NULL || *str == '\0')
143+ if (variant == NULL)
144 {
145 if (self->entry.image)
146 {
147@@ -200,7 +199,7 @@
148
149 gtk_widget_show (GTK_WIDGET (self->entry.image));
150
151- icon = g_icon_new_for_string (str, &error);
152+ icon = g_icon_deserialize (variant);
153 if (icon)
154 {
155 indicator_image_helper_update_from_gicon (self->entry.image, icon);
156@@ -208,9 +207,10 @@
157 }
158 else
159 {
160- g_warning ("invalid icon string '%s': %s", str, error->message);
161+ gchar *text = g_variant_print (variant, TRUE);
162+ g_warning ("invalid icon variant '%s'", text);
163 gtk_image_set_from_stock (self->entry.image, GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_LARGE_TOOLBAR);
164- g_error_free (error);
165+ g_free (text);
166 }
167 }
168
169@@ -237,7 +237,7 @@
170 {
171 GVariant *state;
172 const gchar *label = NULL;
173- const gchar *iconstr = NULL;
174+ GVariant *icon = NULL;
175 const gchar *accessible_desc = NULL;
176 gboolean visible = TRUE;
177
178@@ -254,12 +254,20 @@
179 state = g_action_group_get_action_state (self->actions, self->header_action);
180 if (state && g_variant_is_of_type (state, G_VARIANT_TYPE ("(sssb)")))
181 {
182+ gchar *iconstr = NULL;
183+
184 g_variant_get (state, "(&s&s&sb)", &label, &iconstr, &accessible_desc, &visible);
185+
186+ if (iconstr)
187+ {
188+ icon = g_variant_ref_sink (g_variant_new_string (iconstr));
189+ g_free (iconstr);
190+ }
191 }
192 else if (state && g_variant_is_of_type (state, G_VARIANT_TYPE ("a{sv}")))
193 {
194 g_variant_lookup (state, "label", "&s", &label);
195- g_variant_lookup (state, "icon", "&s", &iconstr);
196+ g_variant_lookup (state, "icon", "*", &icon);
197 g_variant_lookup (state, "accessible-desc", "&s", &accessible_desc);
198 g_variant_lookup (state, "visible", "b", &visible);
199 }
200@@ -268,12 +276,14 @@
201
202 if (label)
203 indicator_ng_set_label (self, label);
204- if (iconstr)
205- indicator_ng_set_icon_from_string (self, iconstr);
206+ if (icon)
207+ indicator_ng_set_icon_from_variant (self, icon);
208 if (accessible_desc)
209 indicator_ng_set_accessible_desc (self, accessible_desc);
210 indicator_object_set_visible (INDICATOR_OBJECT (self), visible);
211
212+ if (icon)
213+ g_variant_unref (icon);
214 if (state)
215 g_variant_unref (state);
216 }

Subscribers

People subscribed via source and target branches