From 13ca9a89915c4a06806d5f46bf304e2952848bd2 Mon Sep 17 00:00:00 2001 From: Luke Yelavich Date: Fri, 17 Feb 2012 15:01:53 +1100 Subject: Do not set the accessible name to an empty string if the accessible_desc property = NULL. Yes this was recently changed so that dbusmenu conformed to Atk documentation, but the GTK menu item accessibility code does not yet conform to sed documentation. As a result, all dbusmenu menu items that do not have the accessible_desc property set end up getting an empty string for their accessible name. In the long term, GTK accessibility needs to be fixed. --- libdbusmenu-gtk/client.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 830356a..1883eea 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -741,10 +741,6 @@ process_a11y_desc (DbusmenuMenuitem * mi, GtkMenuItem * gmi, GVariant * variant, setname = g_variant_get_string(variant, NULL); } - if (setname == NULL) { - setname = ""; - } - atk_object_set_name(aobj, setname); return; } -- cgit v1.2.3 From 17fe62d6ba9a44a86a250695e6e60380e2bab9c1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 1 Mar 2012 12:22:01 -0600 Subject: Setting the default role to be a menu item --- libdbusmenu-gtk/genericmenuitem.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 435c808..5d13081 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -83,6 +83,10 @@ genericmenuitem_class_init (GenericmenuitemClass *klass) object_class->dispose = genericmenuitem_dispose; object_class->finalize = genericmenuitem_finalize; + GtkWidgetClass * widget_class = GTK_WIDGET_CLASS(klass); + + gtk_widget_class_set_accessible_role(widget_class, ATK_ROLE_MENU_ITEM); + GtkCheckMenuItemClass * check_class = GTK_CHECK_MENU_ITEM_CLASS (klass); parent_draw_indicator = check_class->draw_indicator; -- cgit v1.2.3 From cbd4cda4b581a98fbe305fd82018ee78d643edc8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 1 Mar 2012 12:31:49 -0600 Subject: Set the role of the menu item based on how it's being displayed --- libdbusmenu-gtk/genericmenuitem.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 5d13081..4c57319 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -351,18 +351,29 @@ genericmenuitem_set_check_type (Genericmenuitem * item, GenericmenuitemCheckType } item->priv->check_type = check_type; + AtkObject * aobj = gtk_widget_get_accessible(GTK_WIDGET(item)); switch (item->priv->check_type) { case GENERICMENUITEM_CHECK_TYPE_NONE: /* We don't need to do anything here as we're queuing the draw and then when it draws it'll avoid drawing the check on the item. */ + + if (aobj != NULL) { + atk_object_set_role(aobj, ATK_ROLE_MENU_ITEM); + } break; case GENERICMENUITEM_CHECK_TYPE_CHECKBOX: gtk_check_menu_item_set_draw_as_radio(GTK_CHECK_MENU_ITEM(item), FALSE); + if (aobj != NULL) { + atk_object_set_role(aobj, ATK_ROLE_CHECK_MENU_ITEM); + } break; case GENERICMENUITEM_CHECK_TYPE_RADIO: gtk_check_menu_item_set_draw_as_radio(GTK_CHECK_MENU_ITEM(item), TRUE); + if (aobj != NULL) { + atk_object_set_role(aobj, ATK_ROLE_RADIO_MENU_ITEM); + } break; default: g_warning("Generic Menuitem invalid check type: %d", check_type); -- cgit v1.2.3 From e0a68da43067e5955f38e62cb5fb1975119082fc Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 1 Mar 2012 16:25:25 -0600 Subject: Fixing for GTK2 --- libdbusmenu-gtk/genericmenuitem.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 4c57319..e9c8367 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -83,9 +83,11 @@ genericmenuitem_class_init (GenericmenuitemClass *klass) object_class->dispose = genericmenuitem_dispose; object_class->finalize = genericmenuitem_finalize; +#ifdef HAVE_GTK3 GtkWidgetClass * widget_class = GTK_WIDGET_CLASS(klass); gtk_widget_class_set_accessible_role(widget_class, ATK_ROLE_MENU_ITEM); +#endif GtkCheckMenuItemClass * check_class = GTK_CHECK_MENU_ITEM_CLASS (klass); @@ -113,6 +115,13 @@ genericmenuitem_init (Genericmenuitem *self) self->priv->disposition = GENERICMENUITEM_DISPOSITION_NORMAL; self->priv->label_text = NULL; +#ifndef HAVE_GTK3 + AtkObject * aobj = gtk_widget_get_accessible(GTK_WIDGET(self)); + if (aobj != NULL) { + atk_object_set_role(aobj, ATK_ROLE_MENU_ITEM); + } +#endif + return; } -- cgit v1.2.3 From fd68aaf57b7b616434d6593f4b0627ec00fb7d97 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 2 Mar 2012 14:01:34 -0600 Subject: Track the theme changed signal so we ensure that we can drop it eventually --- libdbusmenu-gtk/parser.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 019a304..bdfc3e2 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -44,6 +44,8 @@ typedef struct _ParserData GtkWidget *shell; GtkWidget *image; AtkObject *accessible; + + guint theme_changed_sig; } ParserData; typedef struct _RecurseContext @@ -212,6 +214,11 @@ parse_data_free (gpointer data) g_object_remove_weak_pointer(G_OBJECT(pdata->accessible), (gpointer*)&pdata->accessible); } + if (pdata != NULL && pdata->theme_changed_sig != 0) { + g_signal_handler_disconnect(gtk_icon_theme_get_default(), pdata->theme_changed_sig); + pdata->theme_changed_sig = 0; + } + g_free(pdata); return; @@ -572,7 +579,7 @@ construct_dbusmenu_for_widget (GtkWidget * widget) /* Watch for theme changes because if gicon changes, we want to send a different pixbuf. */ - g_signal_connect(G_OBJECT(gtk_icon_theme_get_default()), + pdata->theme_changed_sig = g_signal_connect(G_OBJECT(gtk_icon_theme_get_default()), "changed", G_CALLBACK(theme_changed_cb), widget); pdata->image = image; -- cgit v1.2.3 From 16848ad3b788226b2f247dea73895580eb5b2d71 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 2 Mar 2012 14:20:49 -0600 Subject: Changing 'update_icon' to take more variables so we can do more fun stuff with it soon! --- libdbusmenu-gtk/parser.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index bdfc3e2..b6595f5 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -61,6 +61,8 @@ static void accel_changed (GtkWidget * widget, static void checkbox_toggled (GtkWidget * widget, DbusmenuMenuitem * mi); static void update_icon (DbusmenuMenuitem * menuitem, + ParserData * pdata, + GtkImageMenuItem * gmenuitem, GtkImage * image); static GtkWidget * find_menu_label (GtkWidget * widget); static void label_notify_cb (GtkWidget * widget, @@ -575,7 +577,7 @@ construct_dbusmenu_for_widget (GtkWidget * widget) if (GTK_IS_IMAGE (image)) { - update_icon (mi, GTK_IMAGE (image)); + update_icon (mi, pdata, GTK_IMAGE_MENU_ITEM(widget), GTK_IMAGE (image)); /* Watch for theme changes because if gicon changes, we want to send a different pixbuf. */ @@ -744,7 +746,7 @@ checkbox_toggled (GtkWidget *widget, DbusmenuMenuitem *mi) } static void -update_icon (DbusmenuMenuitem *menuitem, GtkImage *image) +update_icon (DbusmenuMenuitem *menuitem, ParserData * pdata, GtkImageMenuItem * gmenuitem, GtkImage *image) { GdkPixbuf * pixbuf = NULL; const gchar * icon_name = NULL; @@ -953,7 +955,8 @@ image_notify_cb (GtkWidget *widget, pspec->name == g_intern_static_string ("stock") || pspec->name == g_intern_static_string ("storage-type")) { - update_icon (mi, GTK_IMAGE (widget)); + ParserData *pdata = (ParserData *)g_object_get_data(G_OBJECT(mi), PARSER_DATA); + update_icon (mi, pdata, NULL, GTK_IMAGE (widget)); } } @@ -1141,13 +1144,15 @@ widget_notify_cb (GtkWidget *widget, { GtkWidget *image = NULL; g_object_get(widget, "image", &image, NULL); - update_icon (child, GTK_IMAGE(image)); + ParserData *pdata = (ParserData *)g_object_get_data(G_OBJECT(child), PARSER_DATA); + update_icon (child, pdata, GTK_IMAGE_MENU_ITEM(widget), GTK_IMAGE(image)); } else if (pspec->name == g_intern_static_string ("image")) { GtkWidget *image; image = GTK_WIDGET (g_value_get_object (&prop_value)); - update_icon (child, GTK_IMAGE (image)); + ParserData *pdata = (ParserData *)g_object_get_data(G_OBJECT(child), PARSER_DATA); + update_icon (child, pdata, GTK_IMAGE_MENU_ITEM(widget), GTK_IMAGE (image)); } else if (pspec->name == g_intern_static_string ("parent")) { @@ -1266,7 +1271,8 @@ theme_changed_cb (GtkIconTheme *theme, gpointer data) gpointer pmi = g_object_get_data(G_OBJECT(data), CACHED_MENUITEM); if (pmi != NULL) { - update_icon(DBUSMENU_MENUITEM(pmi), GTK_IMAGE(image)); + ParserData *pdata = (ParserData *)g_object_get_data(G_OBJECT(pmi), PARSER_DATA); + update_icon(DBUSMENU_MENUITEM(pmi), pdata, NULL, GTK_IMAGE(image)); } /* Switch signal to new theme */ -- cgit v1.2.3 From 6f5a36c2abdad2fccc9848f34b3572c425abd39e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 2 Mar 2012 14:40:37 -0600 Subject: Moving the adding of signals to the update_icon function so that everyone gets them --- libdbusmenu-gtk/parser.c | 44 ++++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index b6595f5..1092485 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -578,18 +578,6 @@ construct_dbusmenu_for_widget (GtkWidget * widget) if (GTK_IS_IMAGE (image)) { update_icon (mi, pdata, GTK_IMAGE_MENU_ITEM(widget), GTK_IMAGE (image)); - - /* Watch for theme changes because if gicon changes, we want to send a - different pixbuf. */ - pdata->theme_changed_sig = g_signal_connect(G_OBJECT(gtk_icon_theme_get_default()), - "changed", G_CALLBACK(theme_changed_cb), widget); - - pdata->image = image; - g_signal_connect (G_OBJECT (image), - "notify", - G_CALLBACK (image_notify_cb), - mi); - g_object_add_weak_pointer(G_OBJECT (image), (gpointer*)&pdata->image); } } @@ -755,6 +743,38 @@ update_icon (DbusmenuMenuitem *menuitem, ParserData * pdata, GtkImageMenuItem * GtkIconInfo * info; gint width; + /* Check to see if we're changing the image. If so, we need to track + that little bugger */ + /* Why check for gmenuitem being NULL? Because there are some cases where + we can't get it easily, and those mean it's not changed just the icon + underneith, so we can ignore these larger impacts */ + if (image != GTK_IMAGE(pdata->image) && gmenuitem != NULL) { + if (pdata->theme_changed_sig != 0) { + g_signal_handler_disconnect(gtk_icon_theme_get_default(), pdata->theme_changed_sig); + pdata->theme_changed_sig = 0; + } + + pdata->theme_changed_sig = g_signal_connect(G_OBJECT(gtk_icon_theme_get_default()), + "changed", G_CALLBACK(theme_changed_cb), gmenuitem); + + if (pdata->image != NULL) { + g_signal_handlers_disconnect_by_func(pdata->image, G_CALLBACK(image_notify_cb), menuitem); + g_object_remove_weak_pointer(G_OBJECT(pdata->image), (gpointer*)&pdata->image); + } + + pdata->image = GTK_WIDGET(image); + + if (pdata->image != NULL) { + pdata->theme_changed_sig = g_signal_connect(G_OBJECT(gtk_icon_theme_get_default()), + "changed", G_CALLBACK(theme_changed_cb), gmenuitem); + g_signal_connect (G_OBJECT (pdata->image), + "notify", + G_CALLBACK (image_notify_cb), + menuitem); + g_object_add_weak_pointer(G_OBJECT (pdata->image), (gpointer*)&pdata->image); + } + } + if (image != NULL && should_show_image (image)) { switch (gtk_image_get_storage_type (image)) { case GTK_IMAGE_EMPTY: -- cgit v1.2.3 From e9c3459c80d3db095712b93992548ee03ae80b90 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 2 Mar 2012 15:26:08 -0600 Subject: Don't need to setup this signal twice --- libdbusmenu-gtk/parser.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 1092485..70ffcea 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -754,9 +754,6 @@ update_icon (DbusmenuMenuitem *menuitem, ParserData * pdata, GtkImageMenuItem * pdata->theme_changed_sig = 0; } - pdata->theme_changed_sig = g_signal_connect(G_OBJECT(gtk_icon_theme_get_default()), - "changed", G_CALLBACK(theme_changed_cb), gmenuitem); - if (pdata->image != NULL) { g_signal_handlers_disconnect_by_func(pdata->image, G_CALLBACK(image_notify_cb), menuitem); g_object_remove_weak_pointer(G_OBJECT(pdata->image), (gpointer*)&pdata->image); -- cgit v1.2.3 From 6d953d231b4d974d1c79e604e88b55c13499433d Mon Sep 17 00:00:00 2001 From: Luke Yelavich Date: Thu, 8 Mar 2012 16:15:06 +1100 Subject: Set the accessible name from the dbusmenu item label. THis is a work-around until GTK follows atk docs. --- libdbusmenu-gtk/client.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 1883eea..4c3f1c2 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -741,6 +741,14 @@ process_a11y_desc (DbusmenuMenuitem * mi, GtkMenuItem * gmi, GVariant * variant, setname = g_variant_get_string(variant, NULL); } + /* The atk docs advise to set the name of the atk object to an empty + * string, but GTK doesn't yet do the same, and setting the name to NULL + * causes tests to fail. + */ + if (setname == NULL) { + setname = dbusmenu_menuitem_property_get(mi, DBUSMENU_MENUITEM_PROP_LABEL); + } + atk_object_set_name(aobj, setname); return; } -- cgit v1.2.3 From 004ede5cfbcab69652857f0d25d7ddab5bfe0b23 Mon Sep 17 00:00:00 2001 From: Luke Yelavich Date: Fri, 9 Mar 2012 11:30:43 +1100 Subject: Remove the underscores used for mnewmonics, as orca speaks them, which is not what we want. --- libdbusmenu-gtk/client.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 4c3f1c2..95d6b8b 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -736,6 +736,7 @@ process_a11y_desc (DbusmenuMenuitem * mi, GtkMenuItem * gmi, GVariant * variant, } const gchar * setname = NULL; + const gchar * label = NULL; if (variant != NULL) { setname = g_variant_get_string(variant, NULL); @@ -746,7 +747,12 @@ process_a11y_desc (DbusmenuMenuitem * mi, GtkMenuItem * gmi, GVariant * variant, * causes tests to fail. */ if (setname == NULL) { - setname = dbusmenu_menuitem_property_get(mi, DBUSMENU_MENUITEM_PROP_LABEL); + /* We don't want the underscore for mnewmonics */ + label = dbusmenu_menuitem_property_get(mi, DBUSMENU_MENUITEM_PROP_LABEL); + + GRegex * regex = g_regex_new ("_", 0, 0, NULL); + setname = g_regex_replace_literal (regex, label, -1, 0, "", 0, NULL); + g_regex_unref(regex); } atk_object_set_name(aobj, setname); -- cgit v1.2.3 From 4bd8e21dee661f26f8e1b4522cd3f955b5080e29 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 9 Mar 2012 09:10:02 -0600 Subject: Missing a couple of cases of removing the signal handler and clearing the stored value --- libdbusmenu-gtk/parser.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 70ffcea..da1c8fa 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -229,7 +229,12 @@ parse_data_free (gpointer data) static void widget_freed (gpointer data, GObject * obj) { - g_signal_handlers_disconnect_by_func(gtk_icon_theme_get_default(), G_CALLBACK(theme_changed_cb), obj); + ParserData * pdata = (ParserData *)data; + + if (pdata->theme_changed_sig != 0) { + g_signal_handler_disconnect(gtk_icon_theme_get_default(), pdata->theme_changed_sig); + pdata->theme_changed_sig = 0; + } return; } @@ -242,9 +247,12 @@ dbusmenu_item_freed (gpointer data, GObject * obj) ParserData *pdata = (ParserData *)g_object_get_data(G_OBJECT(obj), PARSER_DATA); if (pdata != NULL && pdata->widget != NULL) { - g_signal_handlers_disconnect_by_func(gtk_icon_theme_get_default(), G_CALLBACK(theme_changed_cb), pdata->widget); + if (pdata->theme_changed_sig != 0) { + g_signal_handler_disconnect(gtk_icon_theme_get_default(), pdata->theme_changed_sig); + pdata->theme_changed_sig = 0; + } g_object_steal_data(G_OBJECT(pdata->widget), CACHED_MENUITEM); - g_object_weak_unref(G_OBJECT(pdata->widget), widget_freed, NULL); + g_object_weak_unref(G_OBJECT(pdata->widget), widget_freed, pdata); } } @@ -286,7 +294,7 @@ new_menuitem (GtkWidget * widget) g_object_set_data_full(G_OBJECT(item), PARSER_DATA, pdata, parse_data_free); g_object_weak_ref(G_OBJECT(item), dbusmenu_item_freed, NULL); - g_object_weak_ref(G_OBJECT(widget), widget_freed, NULL); + g_object_weak_ref(G_OBJECT(widget), widget_freed, pdata); pdata->widget = widget; g_object_add_weak_pointer(G_OBJECT (widget), (gpointer*)&pdata->widget); -- cgit v1.2.3 From 633cd3f92e926b587b07dbc910b513d1daacf0f5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 9 Mar 2012 11:07:52 -0600 Subject: Restructuring slightly to have two cases, allocating memory and not allocating --- libdbusmenu-gtk/client.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 95d6b8b..9cb1144 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -735,27 +735,29 @@ process_a11y_desc (DbusmenuMenuitem * mi, GtkMenuItem * gmi, GVariant * variant, return; } - const gchar * setname = NULL; - const gchar * label = NULL; if (variant != NULL) { - setname = g_variant_get_string(variant, NULL); - } - + const gchar * setname = NULL; + setname = g_variant_dup_string(variant, NULL); + atk_object_set_name(aobj, setname); + } else { /* The atk docs advise to set the name of the atk object to an empty * string, but GTK doesn't yet do the same, and setting the name to NULL * causes tests to fail. */ - if (setname == NULL) { + gchar * setname = NULL; + const gchar * label = NULL; /* We don't want the underscore for mnewmonics */ label = dbusmenu_menuitem_property_get(mi, DBUSMENU_MENUITEM_PROP_LABEL); GRegex * regex = g_regex_new ("_", 0, 0, NULL); setname = g_regex_replace_literal (regex, label, -1, 0, "", 0, NULL); g_regex_unref(regex); + + atk_object_set_name(aobj, setname); + g_free(setname); } - atk_object_set_name(aobj, setname); return; } -- cgit v1.2.3 From 0386a8f6273e5bca12af38402148ccb45194119d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Mar 2012 22:53:24 -0500 Subject: Handle the case of the label being NULL which can happen on custom items --- libdbusmenu-gtk/client.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 9cb1144..31b01d5 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -745,17 +745,20 @@ process_a11y_desc (DbusmenuMenuitem * mi, GtkMenuItem * gmi, GVariant * variant, * string, but GTK doesn't yet do the same, and setting the name to NULL * causes tests to fail. */ - gchar * setname = NULL; const gchar * label = NULL; - /* We don't want the underscore for mnewmonics */ label = dbusmenu_menuitem_property_get(mi, DBUSMENU_MENUITEM_PROP_LABEL); - GRegex * regex = g_regex_new ("_", 0, 0, NULL); - setname = g_regex_replace_literal (regex, label, -1, 0, "", 0, NULL); - g_regex_unref(regex); + if (label != NULL) { + gchar * setname = NULL; - atk_object_set_name(aobj, setname); - g_free(setname); + /* We don't want the underscore for mnewmonics */ + GRegex * regex = g_regex_new ("_", 0, 0, NULL); + setname = g_regex_replace_literal (regex, label, -1, 0, "", 0, NULL); + g_regex_unref(regex); + + atk_object_set_name(aobj, setname); + g_free(setname); + } } return; -- cgit v1.2.3 From 24647064d5447a63987713844d6e59ee7f980be7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Mar 2012 22:53:52 -0500 Subject: Fix string leak --- libdbusmenu-gtk/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 31b01d5..f507a56 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -738,7 +738,7 @@ process_a11y_desc (DbusmenuMenuitem * mi, GtkMenuItem * gmi, GVariant * variant, if (variant != NULL) { const gchar * setname = NULL; - setname = g_variant_dup_string(variant, NULL); + setname = g_variant_get_string(variant, NULL); atk_object_set_name(aobj, setname); } else { /* The atk docs advise to set the name of the atk object to an empty -- cgit v1.2.3 From be73acbfefefb4581f82b19421fe5fc39941901e Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 21 Mar 2012 07:20:21 -0500 Subject: Don't listen for "changed" events from the screen's default GtkIconTheme. Fixes lp bug #953509 The crash in #953509 was being caused by the last two lines of theme_changed_cb() (a) leaving a dangling handler id in priv.theme_changed_sig, and (b) not remembering the handler id of its own signal connection. However after testing I don't see any reason to keep any of the theme handling code at all. "But wait," you say. "How will our menu icons follow the theme changes?" It works in practice anyway because we always listen for property changes to our reference GtkImage, **and** we listen for property changes to its GtkImageMenuItem parent so that if the GtkImageMenuItem changes GtkImages we can stop listening to the old one and start listening to the new one. --- libdbusmenu-gtk/parser.c | 51 ------------------------------------------------ 1 file changed, 51 deletions(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index da1c8fa..b98f34b 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -45,7 +45,6 @@ typedef struct _ParserData GtkWidget *image; AtkObject *accessible; - guint theme_changed_sig; } ParserData; typedef struct _RecurseContext @@ -86,8 +85,6 @@ static void item_inserted_cb (GtkContainer * menu, static void item_removed_cb (GtkContainer * menu, GtkWidget * widget, gpointer data); -static void theme_changed_cb (GtkIconTheme * theme, - gpointer data); static void item_activated (DbusmenuMenuitem * item, guint timestamp, gpointer user_data); @@ -216,29 +213,11 @@ parse_data_free (gpointer data) g_object_remove_weak_pointer(G_OBJECT(pdata->accessible), (gpointer*)&pdata->accessible); } - if (pdata != NULL && pdata->theme_changed_sig != 0) { - g_signal_handler_disconnect(gtk_icon_theme_get_default(), pdata->theme_changed_sig); - pdata->theme_changed_sig = 0; - } - g_free(pdata); return; } -static void -widget_freed (gpointer data, GObject * obj) -{ - ParserData * pdata = (ParserData *)data; - - if (pdata->theme_changed_sig != 0) { - g_signal_handler_disconnect(gtk_icon_theme_get_default(), pdata->theme_changed_sig); - pdata->theme_changed_sig = 0; - } - - return; -} - /* Called when the dbusmenu item that we're keeping around is finalized */ static void @@ -247,12 +226,7 @@ dbusmenu_item_freed (gpointer data, GObject * obj) ParserData *pdata = (ParserData *)g_object_get_data(G_OBJECT(obj), PARSER_DATA); if (pdata != NULL && pdata->widget != NULL) { - if (pdata->theme_changed_sig != 0) { - g_signal_handler_disconnect(gtk_icon_theme_get_default(), pdata->theme_changed_sig); - pdata->theme_changed_sig = 0; - } g_object_steal_data(G_OBJECT(pdata->widget), CACHED_MENUITEM); - g_object_weak_unref(G_OBJECT(pdata->widget), widget_freed, pdata); } } @@ -294,7 +268,6 @@ new_menuitem (GtkWidget * widget) g_object_set_data_full(G_OBJECT(item), PARSER_DATA, pdata, parse_data_free); g_object_weak_ref(G_OBJECT(item), dbusmenu_item_freed, NULL); - g_object_weak_ref(G_OBJECT(widget), widget_freed, pdata); pdata->widget = widget; g_object_add_weak_pointer(G_OBJECT (widget), (gpointer*)&pdata->widget); @@ -757,10 +730,6 @@ update_icon (DbusmenuMenuitem *menuitem, ParserData * pdata, GtkImageMenuItem * we can't get it easily, and those mean it's not changed just the icon underneith, so we can ignore these larger impacts */ if (image != GTK_IMAGE(pdata->image) && gmenuitem != NULL) { - if (pdata->theme_changed_sig != 0) { - g_signal_handler_disconnect(gtk_icon_theme_get_default(), pdata->theme_changed_sig); - pdata->theme_changed_sig = 0; - } if (pdata->image != NULL) { g_signal_handlers_disconnect_by_func(pdata->image, G_CALLBACK(image_notify_cb), menuitem); @@ -770,8 +739,6 @@ update_icon (DbusmenuMenuitem *menuitem, ParserData * pdata, GtkImageMenuItem * pdata->image = GTK_WIDGET(image); if (pdata->image != NULL) { - pdata->theme_changed_sig = g_signal_connect(G_OBJECT(gtk_icon_theme_get_default()), - "changed", G_CALLBACK(theme_changed_cb), gmenuitem); g_signal_connect (G_OBJECT (pdata->image), "notify", G_CALLBACK (image_notify_cb), @@ -1287,24 +1254,6 @@ item_removed_cb (GtkContainer *menu, GtkWidget *widget, gpointer data) return; } -static void -theme_changed_cb (GtkIconTheme *theme, gpointer data) -{ - GtkWidget *image; - - image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (data)); - - gpointer pmi = g_object_get_data(G_OBJECT(data), CACHED_MENUITEM); - if (pmi != NULL) { - ParserData *pdata = (ParserData *)g_object_get_data(G_OBJECT(pmi), PARSER_DATA); - update_icon(DBUSMENU_MENUITEM(pmi), pdata, NULL, GTK_IMAGE(image)); - } - - /* Switch signal to new theme */ - g_signal_handlers_disconnect_by_func(theme, G_CALLBACK(theme_changed_cb), data); - g_signal_connect(gtk_icon_theme_get_default(), "changed", G_CALLBACK(theme_changed_cb), data); -} - static gboolean should_show_image (GtkImage *image) { -- cgit v1.2.3 From 1dedf32ffdfd3ac56fb2ed46ddfc1e7be44eaf80 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 27 Mar 2012 14:23:09 -0700 Subject: fold client's two DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED signal handlers together for clarity --- libdbusmenu-gtk/client.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index f507a56..60af93f 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -787,22 +787,13 @@ menu_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant * variant, Db process_disposition(mi, gmi, variant, gtkclient); } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_ACCESSIBLE_DESC)) { process_a11y_desc(mi, gmi, variant, gtkclient); + } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_SHORTCUT)) { + refresh_shortcut(gtkclient, mi); } return; } -/* Special handler for the shortcut changing as we need to have the - client for that one to get the accel group. */ -static void -menu_shortcut_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant * value, DbusmenuGtkClient * client) -{ - if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_SHORTCUT)) { - refresh_shortcut(client, mi); - } - return; -} - /* The new menuitem signal only happens if we don't have a type handler for the type of the item. This should be an error condition and we're printing out a message. */ @@ -918,7 +909,6 @@ dbusmenu_gtkclient_newitem_base (DbusmenuGtkClient * client, DbusmenuMenuitem * /* DbusmenuMenuitem signals */ g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(menu_prop_change_cb), client); - g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(menu_shortcut_change_cb), client); g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED, G_CALLBACK(delete_child), client); g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED, G_CALLBACK(move_child), client); -- cgit v1.2.3 From c54e02d80857bd08071e2311f456ef992a9d7a01 Mon Sep 17 00:00:00 2001 From: Allan LeSage Date: Tue, 27 Mar 2012 23:40:23 -0500 Subject: Added gcov coverage tooling. --- libdbusmenu-gtk/Makefile.am | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index fcebd04..b52098f 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -57,12 +57,14 @@ libdbusmenu_gtk_la_SOURCES = \ parser.c libdbusmenu_gtk_la_LDFLAGS = \ + $(COVERAGE_LDFLAGS) \ -version-info $(LIBDBUSMENU_CURRENT):$(LIBDBUSMENU_REVISION):$(LIBDBUSMENU_AGE) \ -no-undefined \ -export-symbols-regex "^[^_].*" libdbusmenu_gtk_la_CFLAGS = \ $(DBUSMENUGTK_CFLAGS) \ + $(COVERAGE_CFLAGS) \ -I$(top_srcdir) \ -Wall -Werror -Wno-error=deprecated-declarations \ -DG_LOG_DOMAIN="\"LIBDBUSMENU-GTK\"" @@ -117,7 +119,12 @@ DbusmenuGtk_0_4_gir_INCLUDES = \ GObject-2.0 \ $(GTKGIR) \ Dbusmenu-0.4 -DbusmenuGtk_0_4_gir_CFLAGS = $(DBUSMENUGTK_CFLAGS) -I$(top_srcdir) +DbusmenuGtk_0_4_gir_CFLAGS = \ + $(DBUSMENUGTK_CFLAGS) \ + $(COVERAGE_CFLAGS) \ + -I$(top_srcdir) +DbusmenuGtk_0_4_gir_LDFLAGS = \ + $(COVERAGE_LDFLAGS) DbusmenuGtk_0_4_gir_LIBS = libdbusmenu-gtk$(VER).la \ $(top_builddir)/libdbusmenu-glib/libdbusmenu-glib.la DbusmenuGtk_0_4_gir_FILES = $(addprefix $(srcdir)/, $(introspection_sources)) @@ -127,6 +134,7 @@ DbusmenuGtk_0_4_gir_EXPORT_PACKAGES = dbusmenu-gtk$(VER)-0.4 # We duplicate these for the same reason as libdbusmenu_gtk3includedir above DbusmenuGtk3_0_4_gir_INCLUDES = $(DbusmenuGtk_0_4_gir_INCLUDES) DbusmenuGtk3_0_4_gir_CFLAGS = $(DbusmenuGtk_0_4_gir_CFLAGS) +DbusmenuGtk3_0_4_gir_LDFLAGS = $(DbusmenuGtk_0_4_gir_LDFLAGS) DbusmenuGtk3_0_4_gir_LIBS = $(DbusmenuGtk_0_4_gir_LIBS) DbusmenuGtk3_0_4_gir_FILES = $(DbusmenuGtk_0_4_gir_FILES) DbusmenuGtk3_0_4_gir_NAMESPACE = $(DbusmenuGtk_0_4_gir_NAMESPACE) -- cgit v1.2.3