From a9e8173a206f81967c099c2985253939f7445978 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 11 Jan 2010 11:32:10 -0600 Subject: Adding in a check to see if there is a 'ltr' icon, and use it if so. --- libdbusmenu-gtk/client.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 4a8637a..319083c 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -511,13 +511,30 @@ image_property_handle (DbusmenuMenuitem * item, const gchar * property, const GV icon either. */ gtkimage = NULL; } else { + /* Look to see if we want to have an icon with the 'ltr' or + 'rtl' depending on what we're doing. */ + gchar * finaliconname = g_strdup_printf("%s-%s", iconname, "ltr"); + if (!gtk_icon_theme_has_icon(gtk_icon_theme_get_default(), finaliconname)) { + /* If we don't have that icon, fall back to having one + without the extra bits. */ + g_free(finaliconname); + finaliconname = (gchar *)iconname; /* Dropping const not + becaue we don't love it. */ + } + /* If we don't have an image, we need to build one so that we can set the name. Otherwise we can just convert it to this name. */ if (gtkimage == NULL) { - gtkimage = gtk_image_new_from_icon_name(iconname, GTK_ICON_SIZE_MENU); + gtkimage = gtk_image_new_from_icon_name(finaliconname, GTK_ICON_SIZE_MENU); } else { - gtk_image_set_from_icon_name(GTK_IMAGE(gtkimage), iconname, GTK_ICON_SIZE_MENU); + gtk_image_set_from_icon_name(GTK_IMAGE(gtkimage), finaliconname, GTK_ICON_SIZE_MENU); + } + + /* If we're using the name with extra bits, then we need + to free that string. */ + if (finaliconname != iconname) { + g_free(finaliconname); } } } else { -- cgit v1.2.3 From eb17be92dbd586aef4f185d2e0c5af2ff6485c1b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 11 Jan 2010 12:42:55 -0600 Subject: Building the icon name based on the text direction of the menuitem widget. --- libdbusmenu-gtk/client.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 319083c..dd94663 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -513,7 +513,8 @@ image_property_handle (DbusmenuMenuitem * item, const gchar * property, const GV } else { /* Look to see if we want to have an icon with the 'ltr' or 'rtl' depending on what we're doing. */ - gchar * finaliconname = g_strdup_printf("%s-%s", iconname, "ltr"); + gchar * finaliconname = g_strdup_printf("%s-%s", iconname, + gtk_widget_get_direction(GTK_WIDGET(gimi)) == GTK_TEXT_DIR_RTL ? "rtl" : "ltr"); if (!gtk_icon_theme_has_icon(gtk_icon_theme_get_default(), finaliconname)) { /* If we don't have that icon, fall back to having one without the extra bits. */ -- cgit v1.2.3