← Back to team overview

ayatana-commits team mailing list archive

[Branch ~dbusmenu-team/dbusmenu/trunk] Rev 195: Consolidate warnings if there isn't a 'use-fallback' property.

 

Merge authors:
  Ted Gould (ted)
Related merge proposals:
  https://code.launchpad.net/~ted/dbusmenu/no-warning-for-prop/+merge/47476
  proposed by: Ted Gould (ted)
  review: Approve - Jay Taoko (jaytaoko)
------------------------------------------------------------
revno: 195 [merge]
committer: Ted Gould <ted@xxxxxxxx>
branch nick: trunk
timestamp: Wed 2011-01-26 23:41:02 -0600
message:
  Consolidate warnings if there isn't a 'use-fallback' property.
modified:
  libdbusmenu-gtk/client.c


--
lp:dbusmenu
https://code.launchpad.net/~dbusmenu-team/dbusmenu/trunk

Your team ayatana-commits is subscribed to branch lp:dbusmenu.
To unsubscribe from this branch go to https://code.launchpad.net/~dbusmenu-team/dbusmenu/trunk/+edit-subscription
=== modified file 'libdbusmenu-gtk/client.c'
--- libdbusmenu-gtk/client.c	2011-01-18 21:59:36 +0000
+++ libdbusmenu-gtk/client.c	2011-01-27 04:42:30 +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,29 @@
 	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.");
+		}
+		checked = TRUE;
+	}
+
+	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 +813,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 +832,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);
 			}