From 39d4b10daeee829c8568491fd5268a15ecff4bf9 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 11 Apr 2012 17:40:03 -0500 Subject: apply Evan Nemerson's patch to make the Vala binidngs use pkg-config names, not GIR names, so that valac can automatically pick up the relevant libraries and flags. --- libdbusmenu-gtk/Makefile.am | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index b52098f..a255a69 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -160,14 +160,14 @@ if HAVE_VALA if HAVE_INTROSPECTION vapidir = $(datadir)/vala/vapi -vapi_DATA = DbusmenuGtk$(VER)-0.4.vapi +vapi_DATA = dbusmenu-gtk$(VER)-0.4.vapi -DbusmenuGtk$(VER)-0.4.vapi: DbusmenuGtk$(VER)-0.4.tmp.gir Makefile.am - $(VALA_API_GEN) --library=DbusmenuGtk$(VER)-0.4 \ +dbusmenu-gtk$(VER)-0.4.vapi: DbusmenuGtk$(VER)-0.4.tmp.gir Makefile.am + $(VALA_API_GEN) --library=dbusmenu-gtk$(VER)-0.4 \ --pkg gdk-pixbuf-2.0 \ --pkg $(GTKVALA) \ --pkg atk \ - --pkg Dbusmenu-0.4 \ + --pkg dbusmenu-glib-0.4 \ --vapidir=$(top_builddir)/libdbusmenu-glib \ $< -- cgit v1.2.3 From fca9a5705ac81654b8fe848fb166af94618382b0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 23 Apr 2012 12:48:49 -0500 Subject: Static is probably better to ensure we don't get out of the binary --- libdbusmenu-gtk/genericmenuitem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 33d888d..a06485d 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -242,7 +242,7 @@ has_mnemonic (const gchar * string, gboolean previous_underscore) } /* Sanitize the label by removing "__" meaning "_" */ -G_INLINE_FUNC gchar * +static gchar * sanitize_label (const gchar * in_label) { static GRegex * underscore_regex = NULL; -- cgit v1.2.3 From 92ce49aa3f1ecd493c33eca1c31233b9d1ca3c58 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 24 May 2012 10:10:28 +0200 Subject: don't include build-time filenames in comments of the enum header files If we do, the header files may be different on each build. This is especially harmful when building multiple times for multiple architectures and expecting the files to be identical. See: http://bugs.debian.org/674200 --- libdbusmenu-gtk/genericmenuitem-enum-types.h.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/genericmenuitem-enum-types.h.in b/libdbusmenu-gtk/genericmenuitem-enum-types.h.in index 5758438..afd9132 100644 --- a/libdbusmenu-gtk/genericmenuitem-enum-types.h.in +++ b/libdbusmenu-gtk/genericmenuitem-enum-types.h.in @@ -43,7 +43,7 @@ G_END_DECLS /*** END file-tail ***/ /*** BEGIN file-production ***/ -/* Enumerations from file: "@filename@" */ +/* Enumerations from file: "@basename@" */ #include "@basename@" /*** END file-production ***/ -- cgit v1.2.3 From 75bdca54d5e6838aece55c84db3fd3249a624dfb Mon Sep 17 00:00:00 2001 From: Albert Astals Date: Mon, 4 Jun 2012 13:18:43 +0200 Subject: Replace & with & since we are using set_markup in the label --- libdbusmenu-gtk/genericmenuitem.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 75bdbbd..ab57e86 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -262,6 +262,27 @@ sanitize_label (const gchar * in_label) NULL); /* error */ } +/* Replace '&' with '&' in the label */ +static gchar * +replace_amps (const gchar * in_label) +{ + static GRegex * amp_regex = NULL; + + g_return_val_if_fail(in_label != NULL, NULL); + + if (amp_regex == NULL) { + amp_regex = g_regex_new("&", 0, 0, NULL); + } + + return g_regex_replace_literal(amp_regex, + in_label, + -1, /* length */ + 0, /* start */ + "&", /* replacement */ + 0, /* flags */ + NULL); /* error */ +} + /* Set the label on the item */ static void set_label (GtkMenuItem * menu_item, const gchar * in_label) @@ -338,11 +359,15 @@ set_label (GtkMenuItem * menu_item, const gchar * in_label) gtk_accel_label_set_accel_widget(GTK_ACCEL_LABEL(labelw), GTK_WIDGET(menu_item)); if (has_mnemonic(in_label, FALSE)) { + gchar * amp_replaced = replace_amps (local_label); gtk_label_set_use_underline(GTK_LABEL(labelw), TRUE); - gtk_label_set_markup_with_mnemonic(labelw, local_label); + gtk_label_set_markup_with_mnemonic(labelw, amp_replaced); + g_free(amp_replaced); } else { gchar * sanitized = sanitize_label(local_label); - gtk_label_set_markup(labelw, sanitized); + gchar * amp_replaced = replace_amps (sanitized); + gtk_label_set_markup(labelw, amp_replaced); + g_free(amp_replaced); g_free(sanitized); } -- cgit v1.2.3 From 9c77e28fb5485650e033a6cfb868785ea8f1dbad Mon Sep 17 00:00:00 2001 From: Albert Astals Date: Mon, 4 Jun 2012 15:29:56 +0200 Subject: Use g_markup_escape_text instead of manually trying to fix the text --- libdbusmenu-gtk/genericmenuitem.c | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index ab57e86..ae6d4c0 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -262,27 +262,6 @@ sanitize_label (const gchar * in_label) NULL); /* error */ } -/* Replace '&' with '&' in the label */ -static gchar * -replace_amps (const gchar * in_label) -{ - static GRegex * amp_regex = NULL; - - g_return_val_if_fail(in_label != NULL, NULL); - - if (amp_regex == NULL) { - amp_regex = g_regex_new("&", 0, 0, NULL); - } - - return g_regex_replace_literal(amp_regex, - in_label, - -1, /* length */ - 0, /* start */ - "&", /* replacement */ - 0, /* flags */ - NULL); /* error */ -} - /* Set the label on the item */ static void set_label (GtkMenuItem * menu_item, const gchar * in_label) @@ -300,7 +279,7 @@ set_label (GtkMenuItem * menu_item, const gchar * in_label) gchar * local_label = NULL; switch (GENERICMENUITEM(menu_item)->priv->disposition) { case GENERICMENUITEM_DISPOSITION_NORMAL: - local_label = g_strdup(in_label); + local_label = g_markup_escape_text(in_label, -1); break; case GENERICMENUITEM_DISPOSITION_INFORMATIONAL: case GENERICMENUITEM_DISPOSITION_WARNING: @@ -359,15 +338,11 @@ set_label (GtkMenuItem * menu_item, const gchar * in_label) gtk_accel_label_set_accel_widget(GTK_ACCEL_LABEL(labelw), GTK_WIDGET(menu_item)); if (has_mnemonic(in_label, FALSE)) { - gchar * amp_replaced = replace_amps (local_label); gtk_label_set_use_underline(GTK_LABEL(labelw), TRUE); - gtk_label_set_markup_with_mnemonic(labelw, amp_replaced); - g_free(amp_replaced); + gtk_label_set_markup_with_mnemonic(labelw, local_label); } else { gchar * sanitized = sanitize_label(local_label); - gchar * amp_replaced = replace_amps (sanitized); - gtk_label_set_markup(labelw, amp_replaced); - g_free(amp_replaced); + gtk_label_set_markup(labelw, sanitized); g_free(sanitized); } -- cgit v1.2.3 From f1649bd94ffa9d4a32c7f1c9c989054d3dc56901 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Mon, 10 Sep 2012 11:30:56 -0400 Subject: pay attention to GtkSettings's gtk-menu-images value as it changes on the client end --- libdbusmenu-gtk/parser.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 2f7277c..419c15f 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -60,6 +60,9 @@ typedef struct _ParserData gulong widget_accel_handler_id; gulong widget_toggle_handler_id; gulong widget_visible_handler_id; + gulong widget_screen_changed_handler_id; + + gulong settings_notify_handler_id; } ParserData; @@ -116,6 +119,12 @@ static void widget_notify_cb (GtkWidget * widget, static void widget_add_cb (GtkWidget * widget, GtkWidget * child, gpointer data); +static void widget_screen_changed_cb (GtkWidget * widget, + GdkScreen * old_screen, + gpointer data); +static void settings_notify_cb (GtkSettings * settings, + GParamSpec * pspec, + gpointer data); static gboolean should_show_image (GtkImage * image); static void menuitem_notify_cb (GtkWidget * widget, GParamSpec * pspec, @@ -130,6 +139,7 @@ static const char * interned_str_active = NULL; static const char * interned_str_always_show_image = NULL; static const char * interned_str_file = NULL; static const char * interned_str_gicon = NULL; +static const char * interned_str_gtk_menu_images = NULL; static const char * interned_str_icon_name = NULL; static const char * interned_str_icon_set = NULL; static const char * interned_str_image = NULL; @@ -155,6 +165,7 @@ ensure_interned_strings_loaded (void) interned_str_always_show_image = g_intern_static_string ("always-show-image"); interned_str_file = g_intern_static_string ("file"); interned_str_gicon = g_intern_static_string ("gicon"); + interned_str_gtk_menu_images = g_intern_static_string ("gtk-menu-images"); interned_str_icon_name = g_intern_static_string ("icon-name"); interned_str_icon_set = g_intern_static_string ("icon-set"); interned_str_image = g_intern_static_string ("image"); @@ -291,6 +302,9 @@ parser_data_free (ParserData * pdata) dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_accel_handler_id); dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_toggle_handler_id); dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_visible_handler_id); + dbusmenu_gtk_clear_signal_handler (o, &pdata->widget_screen_changed_handler_id); + dbusmenu_gtk_clear_signal_handler (gtk_widget_get_settings (GTK_WIDGET (o)), + &pdata->settings_notify_handler_id); g_object_remove_weak_pointer(o, (gpointer*)&pdata->widget); /* since the DbusmenuMenuitem is being destroyed, uncache it from the GtkWidget */ @@ -746,6 +760,10 @@ construct_dbusmenu_for_widget (GtkWidget * widget) pdata->widget_add_handler_id = g_signal_connect (widget, "add", G_CALLBACK (widget_add_cb), mi); + pdata->widget_screen_changed_handler_id = g_signal_connect (widget, "screen-changed", + G_CALLBACK (widget_screen_changed_cb), mi); + widget_screen_changed_cb (widget, NULL, mi); + return mi; } @@ -1282,6 +1300,51 @@ widget_add_cb (GtkWidget *widget, handle_first_label (data); } +/* Pass NULL for pspec to update all settings at once */ +static void +widget_screen_changed_cb (GtkWidget * widget, GdkScreen * old_screen, gpointer data) +{ + DbusmenuMenuitem * mi = DBUSMENU_MENUITEM(data); + g_return_if_fail (mi != NULL); + + ParserData *pdata = (ParserData *)g_object_get_data(G_OBJECT(mi), PARSER_DATA); + + if (old_screen != NULL) + dbusmenu_gtk_clear_signal_handler (gtk_settings_get_for_screen (old_screen), + &pdata->settings_notify_handler_id); + pdata->settings_notify_handler_id = g_signal_connect (gtk_widget_get_settings (widget), "notify", + G_CALLBACK (settings_notify_cb), mi); + + /* And update widget now that we have a new GtkSettings */ + settings_notify_cb (gtk_widget_get_settings (widget), NULL, mi); +} + +/* Pass NULL for pspec to update all settings at once */ +static void +settings_notify_cb (GtkSettings * settings, GParamSpec * pspec, gpointer data) +{ + GValue prop_value = {0}; + DbusmenuMenuitem * mi = DBUSMENU_MENUITEM(data); + g_return_if_fail (mi != NULL); + + ensure_interned_strings_loaded (); + + if (pspec != NULL) + { + g_value_init (&prop_value, pspec->value_type); + g_object_get_property (G_OBJECT (settings), pspec->name, &prop_value); + } + + if (pspec == NULL || pspec->name == interned_str_gtk_menu_images) + { + ParserData *pdata = (ParserData *)g_object_get_data(G_OBJECT(mi), PARSER_DATA); + update_icon (mi, pdata, GTK_IMAGE(pdata->image)); + } + + if (pspec != NULL) + g_value_unset (&prop_value); +} + /* A child item was added to a menu we're watching. Let's try to integrate it. */ static void item_inserted_cb (GtkContainer *menu, -- cgit v1.2.3