aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-gtk
diff options
context:
space:
mode:
Diffstat (limited to 'libdbusmenu-gtk')
-rw-r--r--libdbusmenu-gtk/client.c1
-rw-r--r--libdbusmenu-gtk/genericmenuitem.c3
-rw-r--r--libdbusmenu-gtk/parser.c51
3 files changed, 22 insertions, 33 deletions
diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c
index 08d3223..7e1ea36 100644
--- a/libdbusmenu-gtk/client.c
+++ b/libdbusmenu-gtk/client.c
@@ -1279,6 +1279,7 @@ image_property_handle (DbusmenuMenuitem * item, const gchar * property, GVariant
gtk_widget_set_size_request(GTK_WIDGET(gtkimage), width, height);
#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_halign(GTK_WIDGET(gtkimage), GTK_ALIGN_START);
gtk_widget_set_valign(GTK_WIDGET(gtkimage), GTK_ALIGN_CENTER);
#else
gtk_misc_set_alignment(GTK_MISC(gtkimage), 0.0, 0.5);
diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c
index 8fa77ad..fbd0416 100644
--- a/libdbusmenu-gtk/genericmenuitem.c
+++ b/libdbusmenu-gtk/genericmenuitem.c
@@ -335,7 +335,8 @@ set_label (GtkMenuItem * menu_item, const gchar * in_label)
labelw = GTK_LABEL(gtk_accel_label_new(local_label));
gtk_label_set_use_markup(GTK_LABEL(labelw), TRUE);
#if GTK_CHECK_VERSION(3,0,0)
- gtk_widget_set_valign(GTK_WIDGET (labelw), GTK_ALIGN_CENTER);
+ gtk_widget_set_halign(GTK_WIDGET(labelw), GTK_ALIGN_START);
+ gtk_widget_set_valign(GTK_WIDGET(labelw), GTK_ALIGN_CENTER);
#else
gtk_misc_set_alignment(GTK_MISC(labelw), 0.0, 0.5);
#endif
diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c
index bd62b15..d47622f 100644
--- a/libdbusmenu-gtk/parser.c
+++ b/libdbusmenu-gtk/parser.c
@@ -82,8 +82,7 @@ static void checkbox_toggled (GtkWidget * widget,
static void update_icon (DbusmenuMenuitem * menuitem,
ParserData * pdata,
GtkImage * image);
-static GtkWidget * find_menu_child (GtkWidget * widget,
- GType child_type);
+static GtkWidget * find_menu_label (GtkWidget * widget);
static void label_notify_cb (GtkWidget * widget,
GParamSpec * pspec,
gpointer data);
@@ -649,7 +648,7 @@ construct_dbusmenu_for_widget (GtkWidget * widget)
gboolean visible = FALSE;
gboolean sensitive = FALSE;
- if (GTK_IS_SEPARATOR_MENU_ITEM (widget) || !find_menu_child (widget, GTK_TYPE_LABEL))
+ if (GTK_IS_SEPARATOR_MENU_ITEM (widget) || !find_menu_label (widget))
{
dbusmenu_menuitem_property_set (mi,
DBUSMENU_MENUITEM_PROP_TYPE,
@@ -660,8 +659,6 @@ construct_dbusmenu_for_widget (GtkWidget * widget)
}
else
{
- GtkWidget *image = NULL;
-
pdata->widget_accel_handler_id = g_signal_connect (widget, "accel-closures-changed",
G_CALLBACK (accel_changed), mi);
@@ -677,26 +674,20 @@ construct_dbusmenu_for_widget (GtkWidget * widget)
pdata->widget_toggle_handler_id = g_signal_connect (widget, "activate", G_CALLBACK (checkbox_toggled), mi);
}
- else if (GTK_IS_IMAGE_MENU_ITEM (widget))
+
+ if (GTK_IS_IMAGE_MENU_ITEM (widget))
{
+ GtkWidget *image;
image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (widget));
+ if (GTK_IS_IMAGE (image))
+ {
+ update_icon (mi, pdata, GTK_IMAGE (image));
+ }
}
- else
- {
- // GtkImageMenuItem is deprecated, so check regular GtkMenuItems
- // for an image child too
- image = find_menu_child (widget, GTK_TYPE_IMAGE);
- }
-
- if (GTK_IS_IMAGE (image))
- {
- update_icon (mi, pdata, GTK_IMAGE (image));
- }
-
- GtkWidget *label = find_menu_child (widget, GTK_TYPE_LABEL);
+ GtkWidget *label = find_menu_label (widget);
// Sometimes, an app will directly find and modify the label
// (like empathy), so watch the label especially for that.
@@ -957,11 +948,11 @@ update_icon (DbusmenuMenuitem *menuitem, ParserData * pdata, GtkImage *image)
}
static GtkWidget *
-find_menu_child (GtkWidget *widget, GType child_type)
+find_menu_label (GtkWidget *widget)
{
- GtkWidget *child = NULL;
+ GtkWidget *label = NULL;
- if (G_TYPE_CHECK_INSTANCE_TYPE (widget, child_type))
+ if (GTK_IS_LABEL (widget))
return widget;
if (GTK_IS_CONTAINER (widget))
@@ -973,16 +964,16 @@ find_menu_child (GtkWidget *widget, GType child_type)
for (l = children; l; l = l->next)
{
- child = find_menu_child (l->data, child_type);
+ label = find_menu_label (l->data);
- if (child)
+ if (label)
break;
}
g_list_free (children);
}
- return child;
+ return label;
}
static void
@@ -1134,7 +1125,7 @@ a11y_name_notify_cb (AtkObject * accessible, GParamSpec * pspec, gpointer data)
{
DbusmenuMenuitem * item = DBUSMENU_MENUITEM(data);
GtkWidget *widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
- GtkWidget *label = find_menu_child (widget, GTK_TYPE_LABEL);
+ GtkWidget *label = find_menu_label (widget);
const gchar *label_text = gtk_label_get_text (GTK_LABEL (label));
const gchar *name = atk_object_get_name (accessible);
@@ -1348,7 +1339,7 @@ widget_add_cb (GtkWidget *widget,
GtkWidget *child,
gpointer data)
{
- if (find_menu_child (widget, GTK_TYPE_LABEL) != NULL)
+ if (find_menu_label (child) != NULL)
handle_first_label (data);
}
@@ -1446,9 +1437,6 @@ should_show_image (GtkImage *image)
item = gtk_widget_get_ancestor (GTK_WIDGET (image),
GTK_TYPE_IMAGE_MENU_ITEM);
- if (!item)
- item = gtk_widget_get_ancestor (GTK_WIDGET (image),
- GTK_TYPE_MENU_ITEM);
if (item)
{
@@ -1462,8 +1450,7 @@ should_show_image (GtkImage *image)
if (gtk_menu_images)
return TRUE;
- if (GTK_IS_IMAGE_MENU_ITEM (item))
- return gtk_image_menu_item_get_always_show_image (GTK_IMAGE_MENU_ITEM (item));
+ return gtk_image_menu_item_get_always_show_image (GTK_IMAGE_MENU_ITEM (item));
}
return FALSE;