Merge lp:~ted/libdbusmenu/ltr-rtl-icon-support into lp:libdbusmenu/0.5

Proposed by Ted Gould
Status: Merged
Merged at revision: not available
Proposed branch: lp:~ted/libdbusmenu/ltr-rtl-icon-support
Merge into: lp:libdbusmenu/0.5
Diff against target: 37 lines (+20/-2)
1 file modified
libdbusmenu-gtk/client.c (+20/-2)
To merge this branch: bzr merge lp:~ted/libdbusmenu/ltr-rtl-icon-support
Reviewer Review Type Date Requested Status
Cody Russell (community) Approve
Review via email: mp+17154@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote :

This makes it so that DBus menu will look to see if there is a text
direction specific icon for the icon we're given. If there is, we'll
use that one. Otherwise, we just use the name that we're given.

Revision history for this message
Cody Russell (bratsche) :
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 2010-01-07 16:53:27 +0000
3+++ libdbusmenu-gtk/client.c 2010-01-11 18:50:27 +0000
4@@ -511,13 +511,31 @@
5 icon either. */
6 gtkimage = NULL;
7 } else {
8+ /* Look to see if we want to have an icon with the 'ltr' or
9+ 'rtl' depending on what we're doing. */
10+ gchar * finaliconname = g_strdup_printf("%s-%s", iconname,
11+ gtk_widget_get_direction(GTK_WIDGET(gimi)) == GTK_TEXT_DIR_RTL ? "rtl" : "ltr");
12+ if (!gtk_icon_theme_has_icon(gtk_icon_theme_get_default(), finaliconname)) {
13+ /* If we don't have that icon, fall back to having one
14+ without the extra bits. */
15+ g_free(finaliconname);
16+ finaliconname = (gchar *)iconname; /* Dropping const not
17+ becaue we don't love it. */
18+ }
19+
20 /* If we don't have an image, we need to build
21 one so that we can set the name. Otherwise we
22 can just convert it to this name. */
23 if (gtkimage == NULL) {
24- gtkimage = gtk_image_new_from_icon_name(iconname, GTK_ICON_SIZE_MENU);
25+ gtkimage = gtk_image_new_from_icon_name(finaliconname, GTK_ICON_SIZE_MENU);
26 } else {
27- gtk_image_set_from_icon_name(GTK_IMAGE(gtkimage), iconname, GTK_ICON_SIZE_MENU);
28+ gtk_image_set_from_icon_name(GTK_IMAGE(gtkimage), finaliconname, GTK_ICON_SIZE_MENU);
29+ }
30+
31+ /* If we're using the name with extra bits, then we need
32+ to free that string. */
33+ if (finaliconname != iconname) {
34+ g_free(finaliconname);
35 }
36 }
37 } else {

Subscribers

People subscribed via source and target branches