ayatana-commits team mailing list archive
-
ayatana-commits team
-
Mailing list archive
-
Message #02842
[Merge] lp:~ted/dbusmenu/no-warning-for-prop into lp:dbusmenu
Ted Gould has proposed merging lp:~ted/dbusmenu/no-warning-for-prop into lp:dbusmenu.
Requested reviews:
DBus Menu Team (dbusmenu-team)
For more details, see:
https://code.launchpad.net/~ted/dbusmenu/no-warning-for-prop/+merge/47476
Seems not all GTK+ packages are keeping with this patch. Let's make it not awful if something happens to it.
--
https://code.launchpad.net/~ted/dbusmenu/no-warning-for-prop/+merge/47476
Your team ayatana-commits is subscribed to branch lp:dbusmenu.
=== modified file 'libdbusmenu-gtk/client.c'
--- libdbusmenu-gtk/client.c 2011-01-18 21:59:36 +0000
+++ libdbusmenu-gtk/client.c 2011-01-25 23:06:37 +0000
@@ -42,6 +42,7 @@
};
#define DBUSMENU_GTKCLIENT_GET_PRIVATE(o) (DBUSMENU_GTKCLIENT(o)->priv)
+#define USE_FALLBACK_PROP "use-fallback"
/* Prototypes */
static void dbusmenu_gtkclient_class_init (DbusmenuGtkClientClass *klass);
@@ -737,6 +738,28 @@
return TRUE;
}
+/* A little helper so we don't generate a bunch of warnings
+ about being able to set use-fallback */
+static void
+set_use_fallback (GtkWidget * widget)
+{
+ static gboolean checked = FALSE;
+ static gboolean available = FALSE;
+
+ if (!checked) {
+ available = (g_object_class_find_property(G_OBJECT_CLASS(GTK_IMAGE_GET_CLASS(widget)), USE_FALLBACK_PROP) != NULL);
+ if (!available) {
+ g_warning("The '" USE_FALLBACK_PROP "' is not available on GtkImage so icons may not show correctly.");
+ }
+ }
+
+ if (available) {
+ g_object_set(G_OBJECT(widget), USE_FALLBACK_PROP, TRUE, NULL);
+ }
+
+ return;
+}
+
/* This handler looks at property changes for items that are
image menu items. */
static void
@@ -789,7 +812,7 @@
gtkimage = NULL;
} else if (g_strcmp0(iconname, DBUSMENU_MENUITEM_ICON_NAME_BLANK) == 0) {
gtkimage = gtk_image_new();
- g_object_set(G_OBJECT(gtkimage), "use-fallback", TRUE, NULL);
+ set_use_fallback(gtkimage);
} else {
/* Look to see if we want to have an icon with the 'ltr' or
'rtl' depending on what we're doing. */
@@ -808,7 +831,7 @@
can just convert it to this name. */
if (gtkimage == NULL) {
gtkimage = gtk_image_new_from_icon_name(finaliconname, GTK_ICON_SIZE_MENU);
- g_object_set(G_OBJECT(gtkimage), "use-fallback", TRUE, NULL);
+ set_use_fallback(gtkimage);
} else {
gtk_image_set_from_icon_name(GTK_IMAGE(gtkimage), finaliconname, GTK_ICON_SIZE_MENU);
}
Follow ups