[gnome-panel] libgnome-panel: avoid creating default label in image menu item
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] libgnome-panel: avoid creating default label in image menu item
- Date: Thu, 26 Dec 2019 13:25:56 +0000 (UTC)
commit 5ba1dbb0c952c181d2958372b3d84852f7572aac
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Thu Dec 26 15:19:19 2019 +0200
libgnome-panel: avoid creating default label in image menu item
gtk_menu_item_get_label will create and set label as its child if
it does not already have one.
libgnome-panel/gp-image-menu-item.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/libgnome-panel/gp-image-menu-item.c b/libgnome-panel/gp-image-menu-item.c
index 3bb0b6dbc..db03fd44d 100644
--- a/libgnome-panel/gp-image-menu-item.c
+++ b/libgnome-panel/gp-image-menu-item.c
@@ -40,7 +40,7 @@ static void
update_css_class (GpImageMenuItem *self)
{
GtkStyleContext *context;
- const char *label;
+ GtkWidget *child;
context = gtk_widget_get_style_context (GTK_WIDGET (self));
@@ -50,10 +50,20 @@ update_css_class (GpImageMenuItem *self)
return;
}
- label = gtk_menu_item_get_label (GTK_MENU_ITEM (self));
+ child = gtk_bin_get_child (GTK_BIN (self));
- if (label != NULL && *label != '\0')
- return;
+ if (child != NULL && GTK_IS_LABEL (child))
+ {
+ const char *text;
+
+ text = gtk_label_get_text (GTK_LABEL (child));
+ if (text != NULL && *text != '\0')
+ return;
+ }
+ else if (child != NULL)
+ {
+ return;
+ }
gtk_style_context_add_class (context, "image-only");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]