Merge lp:~larsu/ido/update-icon into lp:ido/14.04

Proposed by Lars Karlitski
Status: Merged
Approved by: Charles Kerr
Approved revision: 182
Merged at revision: 181
Proposed branch: lp:~larsu/ido/update-icon
Merge into: lp:ido/14.04
Diff against target: 113 lines (+52/-31)
1 file modified
src/idobasicmenuitem.c (+52/-31)
To merge this branch: bzr merge lp:~larsu/ido/update-icon
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+214313@code.launchpad.net

Commit message

idobasicmenuitem: update icon when the theme changes

Description of the change

idobasicmenuitem: update icon when the theme changes

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~larsu/ido/update-icon updated
182. By Lars Karlitski

idobasicmenuitem: don't export update_image()

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :

Looks good.

Omitting top approval only to wait for Jenkins

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/idobasicmenuitem.c'
--- src/idobasicmenuitem.c 2014-03-28 10:27:12 +0000
+++ src/idobasicmenuitem.c 2014-04-04 17:37:51 +0000
@@ -136,6 +136,50 @@
136 G_OBJECT_CLASS (ido_basic_menu_item_parent_class)->finalize (object);136 G_OBJECT_CLASS (ido_basic_menu_item_parent_class)->finalize (object);
137}137}
138138
139static void
140ido_basic_menu_item_update_image (IdoBasicMenuItem *self)
141{
142 IdoBasicMenuItemPrivate * p = self->priv;
143
144 gtk_image_clear (GTK_IMAGE (p->image));
145
146 if (p->icon == NULL)
147 {
148 gtk_widget_set_visible (p->image, FALSE);
149 }
150 else
151 {
152 GtkIconInfo *info;
153 const gchar *filename;
154
155 info = gtk_icon_theme_lookup_by_gicon (gtk_icon_theme_get_default (), p->icon, 16, 0);
156 filename = gtk_icon_info_get_filename (info);
157
158 if (filename)
159 {
160 GdkPixbuf *pixbuf;
161
162 pixbuf = gdk_pixbuf_new_from_file_at_scale (filename, -1, 16, TRUE, NULL);
163 gtk_image_set_from_pixbuf (GTK_IMAGE (p->image), pixbuf);
164
165 g_object_unref (pixbuf);
166 }
167
168 gtk_widget_set_visible (p->image, filename != NULL);
169
170 g_object_unref (info);
171 }
172}
173
174static void
175ido_basic_menu_item_style_updated (GtkWidget *widget)
176{
177 GTK_WIDGET_CLASS (ido_basic_menu_item_parent_class)->style_updated (widget);
178
179 ido_basic_menu_item_update_image (IDO_BASIC_MENU_ITEM (widget));
180 gtk_widget_queue_draw (widget);
181}
182
139/***183/***
140**** Instantiation184**** Instantiation
141***/185***/
@@ -145,6 +189,7 @@
145{189{
146 GParamFlags prop_flags;190 GParamFlags prop_flags;
147 GObjectClass * gobject_class = G_OBJECT_CLASS (klass);191 GObjectClass * gobject_class = G_OBJECT_CLASS (klass);
192 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
148193
149 g_type_class_add_private (klass, sizeof (IdoBasicMenuItemPrivate));194 g_type_class_add_private (klass, sizeof (IdoBasicMenuItemPrivate));
150195
@@ -153,6 +198,8 @@
153 gobject_class->dispose = my_dispose;198 gobject_class->dispose = my_dispose;
154 gobject_class->finalize = my_finalize;199 gobject_class->finalize = my_finalize;
155200
201 widget_class->style_updated = ido_basic_menu_item_style_updated;
202
156 prop_flags = G_PARAM_CONSTRUCT203 prop_flags = G_PARAM_CONSTRUCT
157 | G_PARAM_READWRITE204 | G_PARAM_READWRITE
158 | G_PARAM_STATIC_STRINGS;205 | G_PARAM_STATIC_STRINGS;
@@ -244,37 +291,11 @@
244291
245 if (p->icon != icon)292 if (p->icon != icon)
246 {293 {
247 g_clear_object (&p->icon);294 if (p->icon)
248 gtk_image_clear (GTK_IMAGE(p->image));295 g_object_unref (p->icon);
249296
250 if (icon == NULL)297 p->icon = icon ? g_object_ref (icon) : NULL;
251 {298 ido_basic_menu_item_update_image (self);
252 gtk_widget_set_visible (p->image, FALSE);
253 }
254 else
255 {
256 GtkIconInfo *info;
257 const gchar *filename;
258
259 p->icon = g_object_ref (icon);
260
261 info = gtk_icon_theme_lookup_by_gicon (gtk_icon_theme_get_default (), p->icon, 16, 0);
262 filename = gtk_icon_info_get_filename (info);
263
264 if (filename)
265 {
266 GdkPixbuf *pixbuf;
267
268 pixbuf = gdk_pixbuf_new_from_file_at_scale (filename, -1, 16, TRUE, NULL);
269 gtk_image_set_from_pixbuf (GTK_IMAGE(p->image), pixbuf);
270
271 g_object_unref (pixbuf);
272 }
273
274 gtk_widget_set_visible (p->image, filename != NULL);
275
276 g_object_unref (info);
277 }
278 }299 }
279}300}
280301

Subscribers

People subscribed via source and target branches