Merge lp:~ted/libdbusmenu/no-warning-for-prop into lp:libdbusmenu/0.5

Proposed by Ted Gould
Status: Merged
Merged at revision: 195
Proposed branch: lp:~ted/libdbusmenu/no-warning-for-prop
Merge into: lp:libdbusmenu/0.5
Diff against target: 59 lines (+26/-2)
1 file modified
libdbusmenu-gtk/client.c (+26/-2)
To merge this branch: bzr merge lp:~ted/libdbusmenu/no-warning-for-prop
Reviewer Review Type Date Requested Status
Jay Taoko (community) Approve
Review via email: mp+47476@code.launchpad.net

Description of the change

Seems not all GTK+ packages are keeping with this patch. Let's make it not awful if something happens to it.

To post a comment you must log in.
Revision history for this message
Jay Taoko (jaytaoko) wrote :

In function set_use_fallback(), the value of checked is never changed to TRUE. Looks like the check will be done every time the function is called.

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

On Thu, 2011-01-27 at 04:33 +0000, Jay Taoko wrote:
> In function set_use_fallback(), the value of checked is never changed to TRUE. Looks like the check will be done every time the function is called.

Oops! Fixed in r194.

194. By Ted Gould

Actually setting the 'checked' value

Revision history for this message
Jay Taoko (jaytaoko) wrote :

Approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libdbusmenu-gtk/client.c'
2--- libdbusmenu-gtk/client.c 2011-01-18 21:59:36 +0000
3+++ libdbusmenu-gtk/client.c 2011-01-27 04:44:08 +0000
4@@ -42,6 +42,7 @@
5 };
6
7 #define DBUSMENU_GTKCLIENT_GET_PRIVATE(o) (DBUSMENU_GTKCLIENT(o)->priv)
8+#define USE_FALLBACK_PROP "use-fallback"
9
10 /* Prototypes */
11 static void dbusmenu_gtkclient_class_init (DbusmenuGtkClientClass *klass);
12@@ -737,6 +738,29 @@
13 return TRUE;
14 }
15
16+/* A little helper so we don't generate a bunch of warnings
17+ about being able to set use-fallback */
18+static void
19+set_use_fallback (GtkWidget * widget)
20+{
21+ static gboolean checked = FALSE;
22+ static gboolean available = FALSE;
23+
24+ if (!checked) {
25+ available = (g_object_class_find_property(G_OBJECT_CLASS(GTK_IMAGE_GET_CLASS(widget)), USE_FALLBACK_PROP) != NULL);
26+ if (!available) {
27+ g_warning("The '" USE_FALLBACK_PROP "' is not available on GtkImage so icons may not show correctly.");
28+ }
29+ checked = TRUE;
30+ }
31+
32+ if (available) {
33+ g_object_set(G_OBJECT(widget), USE_FALLBACK_PROP, TRUE, NULL);
34+ }
35+
36+ return;
37+}
38+
39 /* This handler looks at property changes for items that are
40 image menu items. */
41 static void
42@@ -789,7 +813,7 @@
43 gtkimage = NULL;
44 } else if (g_strcmp0(iconname, DBUSMENU_MENUITEM_ICON_NAME_BLANK) == 0) {
45 gtkimage = gtk_image_new();
46- g_object_set(G_OBJECT(gtkimage), "use-fallback", TRUE, NULL);
47+ set_use_fallback(gtkimage);
48 } else {
49 /* Look to see if we want to have an icon with the 'ltr' or
50 'rtl' depending on what we're doing. */
51@@ -808,7 +832,7 @@
52 can just convert it to this name. */
53 if (gtkimage == NULL) {
54 gtkimage = gtk_image_new_from_icon_name(finaliconname, GTK_ICON_SIZE_MENU);
55- g_object_set(G_OBJECT(gtkimage), "use-fallback", TRUE, NULL);
56+ set_use_fallback(gtkimage);
57 } else {
58 gtk_image_set_from_icon_name(GTK_IMAGE(gtkimage), finaliconname, GTK_ICON_SIZE_MENU);
59 }

Subscribers

People subscribed via source and target branches