aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-gtk
diff options
context:
space:
mode:
Diffstat (limited to 'libdbusmenu-gtk')
-rw-r--r--libdbusmenu-gtk/client.c22
-rw-r--r--libdbusmenu-gtk/genericmenuitem.c22
2 files changed, 38 insertions, 6 deletions
diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c
index 4a8637a..dd94663 100644
--- a/libdbusmenu-gtk/client.c
+++ b/libdbusmenu-gtk/client.c
@@ -511,13 +511,31 @@ 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,
+ 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. */
+ 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 {
diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c
index f927556..8f40d93 100644
--- a/libdbusmenu-gtk/genericmenuitem.c
+++ b/libdbusmenu-gtk/genericmenuitem.c
@@ -143,6 +143,17 @@ set_label_helper (GtkWidget * widget, gpointer data)
return;
}
+/* A quick little function to grab the padding from the
+ style. It should be considered for caching when
+ optimizing. */
+static gint
+get_hpadding (GtkWidget * widget)
+{
+ gint padding = 0;
+ gtk_widget_style_get(widget, "horizontal-padding", &padding, NULL);
+ return padding;
+}
+
/* Set the label on the item */
static void
set_label (GtkMenuItem * menu_item, const gchar * label)
@@ -166,7 +177,7 @@ set_label (GtkMenuItem * menu_item, const gchar * label)
GtkWidget * hbox = gtk_hbox_new(FALSE, 0);
g_object_ref(child);
gtk_container_remove(GTK_CONTAINER(menu_item), child);
- gtk_box_pack_start(GTK_BOX(hbox), child, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox), child, FALSE, FALSE, get_hpadding(GTK_WIDGET(menu_item)));
gtk_container_add(GTK_CONTAINER(menu_item), hbox);
gtk_widget_show(hbox);
g_object_unref(child);
@@ -190,7 +201,7 @@ set_label (GtkMenuItem * menu_item, const gchar * label)
if (child == NULL) {
gtk_container_add(GTK_CONTAINER(menu_item), GTK_WIDGET(labelw));
} else {
- gtk_box_pack_end(GTK_BOX(child), GTK_WIDGET(labelw), TRUE, TRUE, 0);
+ gtk_box_pack_end(GTK_BOX(child), GTK_WIDGET(labelw), TRUE, TRUE, get_hpadding(GTK_WIDGET(menu_item)));
}
} else {
/* Oh, just an update. No biggie. */
@@ -383,7 +394,7 @@ genericmenuitem_set_image (Genericmenuitem * menu_item, GtkWidget * image)
GtkWidget * hbox = gtk_hbox_new(FALSE, 0);
g_object_ref(child);
gtk_container_remove(GTK_CONTAINER(menu_item), child);
- gtk_box_pack_end(GTK_BOX(hbox), child, TRUE, TRUE, 0);
+ gtk_box_pack_end(GTK_BOX(hbox), child, TRUE, TRUE, get_hpadding(GTK_WIDGET(menu_item)));
gtk_container_add(GTK_CONTAINER(menu_item), hbox);
gtk_widget_show(hbox);
g_object_unref(child);
@@ -393,6 +404,9 @@ genericmenuitem_set_image (Genericmenuitem * menu_item, GtkWidget * image)
}
}
+ if (image == (GtkWidget *)imagew)
+ return;
+
/* No we can see if we need to ethier replace and image or
just put ourselves into the structures */
if (imagew != NULL) {
@@ -405,7 +419,7 @@ genericmenuitem_set_image (Genericmenuitem * menu_item, GtkWidget * image)
if (child == NULL) {
gtk_container_add(GTK_CONTAINER(menu_item), GTK_WIDGET(image));
} else {
- gtk_box_pack_start(GTK_BOX(child), GTK_WIDGET(image), FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(child), GTK_WIDGET(image), FALSE, FALSE, get_hpadding(GTK_WIDGET(menu_item)));
}
gtk_widget_show(image);