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
1=== modified file 'src/idobasicmenuitem.c'
2--- src/idobasicmenuitem.c 2014-03-28 10:27:12 +0000
3+++ src/idobasicmenuitem.c 2014-04-04 17:37:51 +0000
4@@ -136,6 +136,50 @@
5 G_OBJECT_CLASS (ido_basic_menu_item_parent_class)->finalize (object);
6 }
7
8+static void
9+ido_basic_menu_item_update_image (IdoBasicMenuItem *self)
10+{
11+ IdoBasicMenuItemPrivate * p = self->priv;
12+
13+ gtk_image_clear (GTK_IMAGE (p->image));
14+
15+ if (p->icon == NULL)
16+ {
17+ gtk_widget_set_visible (p->image, FALSE);
18+ }
19+ else
20+ {
21+ GtkIconInfo *info;
22+ const gchar *filename;
23+
24+ info = gtk_icon_theme_lookup_by_gicon (gtk_icon_theme_get_default (), p->icon, 16, 0);
25+ filename = gtk_icon_info_get_filename (info);
26+
27+ if (filename)
28+ {
29+ GdkPixbuf *pixbuf;
30+
31+ pixbuf = gdk_pixbuf_new_from_file_at_scale (filename, -1, 16, TRUE, NULL);
32+ gtk_image_set_from_pixbuf (GTK_IMAGE (p->image), pixbuf);
33+
34+ g_object_unref (pixbuf);
35+ }
36+
37+ gtk_widget_set_visible (p->image, filename != NULL);
38+
39+ g_object_unref (info);
40+ }
41+}
42+
43+static void
44+ido_basic_menu_item_style_updated (GtkWidget *widget)
45+{
46+ GTK_WIDGET_CLASS (ido_basic_menu_item_parent_class)->style_updated (widget);
47+
48+ ido_basic_menu_item_update_image (IDO_BASIC_MENU_ITEM (widget));
49+ gtk_widget_queue_draw (widget);
50+}
51+
52 /***
53 **** Instantiation
54 ***/
55@@ -145,6 +189,7 @@
56 {
57 GParamFlags prop_flags;
58 GObjectClass * gobject_class = G_OBJECT_CLASS (klass);
59+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
60
61 g_type_class_add_private (klass, sizeof (IdoBasicMenuItemPrivate));
62
63@@ -153,6 +198,8 @@
64 gobject_class->dispose = my_dispose;
65 gobject_class->finalize = my_finalize;
66
67+ widget_class->style_updated = ido_basic_menu_item_style_updated;
68+
69 prop_flags = G_PARAM_CONSTRUCT
70 | G_PARAM_READWRITE
71 | G_PARAM_STATIC_STRINGS;
72@@ -244,37 +291,11 @@
73
74 if (p->icon != icon)
75 {
76- g_clear_object (&p->icon);
77- gtk_image_clear (GTK_IMAGE(p->image));
78-
79- if (icon == NULL)
80- {
81- gtk_widget_set_visible (p->image, FALSE);
82- }
83- else
84- {
85- GtkIconInfo *info;
86- const gchar *filename;
87-
88- p->icon = g_object_ref (icon);
89-
90- info = gtk_icon_theme_lookup_by_gicon (gtk_icon_theme_get_default (), p->icon, 16, 0);
91- filename = gtk_icon_info_get_filename (info);
92-
93- if (filename)
94- {
95- GdkPixbuf *pixbuf;
96-
97- pixbuf = gdk_pixbuf_new_from_file_at_scale (filename, -1, 16, TRUE, NULL);
98- gtk_image_set_from_pixbuf (GTK_IMAGE(p->image), pixbuf);
99-
100- g_object_unref (pixbuf);
101- }
102-
103- gtk_widget_set_visible (p->image, filename != NULL);
104-
105- g_object_unref (info);
106- }
107+ if (p->icon)
108+ g_object_unref (p->icon);
109+
110+ p->icon = icon ? g_object_ref (icon) : NULL;
111+ ido_basic_menu_item_update_image (self);
112 }
113 }
114

Subscribers

People subscribed via source and target branches