aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-gtk/client.c
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-01-25 17:04:23 -0600
committerTed Gould <ted@gould.cx>2011-01-25 17:04:23 -0600
commitd5a160e04dfd351cefb70ac5f6955cb2913e2ad5 (patch)
tree343b0a85224813354895bd84a7b8bcd7bfb43f84 /libdbusmenu-gtk/client.c
parent7dc976ae7666254a7cd643542527636010a3ac0b (diff)
downloadlibdbusmenu-d5a160e04dfd351cefb70ac5f6955cb2913e2ad5.tar.gz
libdbusmenu-d5a160e04dfd351cefb70ac5f6955cb2913e2ad5.tar.bz2
libdbusmenu-d5a160e04dfd351cefb70ac5f6955cb2913e2ad5.zip
Adding a little helper to reduce the number of warnings if the property is missing.
Diffstat (limited to 'libdbusmenu-gtk/client.c')
-rw-r--r--libdbusmenu-gtk/client.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c
index 18a2cdd..ff2b3a7 100644
--- a/libdbusmenu-gtk/client.c
+++ b/libdbusmenu-gtk/client.c
@@ -42,6 +42,7 @@ struct _DbusmenuGtkClientPrivate {
};
#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 @@ new_item_seperator (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm
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 @@ image_property_handle (DbusmenuMenuitem * item, const gchar * property, GVariant
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 @@ image_property_handle (DbusmenuMenuitem * item, const gchar * property, GVariant
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);
}