diff options
author | Luke Yelavich <luke.yelavich@canonical.com> | 2012-03-08 15:49:05 +1100 |
---|---|---|
committer | Luke Yelavich <luke.yelavich@canonical.com> | 2012-03-08 15:49:05 +1100 |
commit | 357e0a1e969d2613b81f833a2936bcc71fc2470c (patch) | |
tree | b08d95af4e3412974c382e96cdfab4b4178549cf | |
parent | 13ca9a89915c4a06806d5f46bf304e2952848bd2 (diff) | |
parent | 33290b94668dec767edc167826e32f953f2e15ef (diff) | |
download | libdbusmenu-357e0a1e969d2613b81f833a2936bcc71fc2470c.tar.gz libdbusmenu-357e0a1e969d2613b81f833a2936bcc71fc2470c.tar.bz2 libdbusmenu-357e0a1e969d2613b81f833a2936bcc71fc2470c.zip |
Merge from trunk.
-rw-r--r-- | configure.ac | 6 | ||||
-rw-r--r-- | libdbusmenu-glib/client.c | 86 | ||||
-rw-r--r-- | libdbusmenu-gtk/genericmenuitem.c | 54 | ||||
-rw-r--r-- | tests/Makefile.am | 4 | ||||
-rw-r--r-- | tests/test-gtk-submenu-server.c | 1 |
5 files changed, 87 insertions, 64 deletions
diff --git a/configure.ac b/configure.ac index aef35a0..274875f 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.5.91, ted@canonical.com) +AC_INIT(libdbusmenu, 0.5.92, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.5.91, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.5.92, [-Wno-portability]) AM_MAINTAINER_MODE @@ -165,7 +165,7 @@ AC_PATH_PROG([XSLT_PROC], [xsltproc]) ########################### LIBDBUSMENU_CURRENT=4 -LIBDBUSMENU_REVISION=8 +LIBDBUSMENU_REVISION=9 LIBDBUSMENU_AGE=0 AC_SUBST(LIBDBUSMENU_CURRENT) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index e64d923..01f063d 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -601,64 +601,66 @@ get_properties_callback (GObject *obj, GAsyncResult * res, gpointer user_data) listener->callback(NULL, error, listener->user_data); } g_error_free(error); - goto out; } /* Callback all the folks we can find */ - GVariant * parent = g_variant_get_child_value(params, 0); - GVariantIter iter; - g_variant_iter_init(&iter, parent); - GVariant * child; - while ((child = g_variant_iter_next_value(&iter)) != NULL) { - if (g_strcmp0(g_variant_get_type_string(child), "(ia{sv})") != 0) { - g_warning("Properties return signature is not '(ia{sv})' it is '%s'", g_variant_get_type_string(child)); - g_variant_unref(child); - continue; - } + if (error == NULL) { + GVariant * parent = g_variant_get_child_value(params, 0); + GVariantIter iter; + g_variant_iter_init(&iter, parent); + GVariant * child; + while ((child = g_variant_iter_next_value(&iter)) != NULL) { + if (g_strcmp0(g_variant_get_type_string(child), "(ia{sv})") != 0) { + g_warning("Properties return signature is not '(ia{sv})' it is '%s'", g_variant_get_type_string(child)); + g_variant_unref(child); + continue; + } - GVariant * idv = g_variant_get_child_value(child, 0); - gint id = g_variant_get_int32(idv); - g_variant_unref(idv); + GVariant * idv = g_variant_get_child_value(child, 0); + gint id = g_variant_get_int32(idv); + g_variant_unref(idv); + + GVariant * properties = g_variant_get_child_value(child, 1); - GVariant * properties = g_variant_get_child_value(child, 1); + properties_listener_t * listener = find_listener(listeners, 0, id); + if (listener == NULL) { + g_warning("Unable to find listener for ID %d", id); + g_variant_unref(properties); + g_variant_unref(child); + continue; + } - properties_listener_t * listener = find_listener(listeners, 0, id); - if (listener == NULL) { - g_warning("Unable to find listener for ID %d", id); + if (!listener->replied) { + listener->callback(properties, NULL, listener->user_data); + listener->replied = TRUE; + } else { + g_warning("Odd, we've already replied to the listener on ID %d", id); + } g_variant_unref(properties); g_variant_unref(child); - continue; } - - if (!listener->replied) { - listener->callback(properties, NULL, listener->user_data); - listener->replied = TRUE; - } else { - g_warning("Odd, we've already replied to the listener on ID %d", id); - } - g_variant_unref(properties); - g_variant_unref(child); + g_variant_unref(parent); + g_variant_unref(params); } - g_variant_unref(parent); - g_variant_unref(params); /* Provide errors for those who we can't */ - GError * localerror = NULL; - for (i = 0; i < listeners->len; i++) { - properties_listener_t * listener = &g_array_index(listeners, properties_listener_t, i); - if (!listener->replied) { - g_warning("Generating properties error for: %d", listener->id); - if (localerror == NULL) { - g_set_error_literal(&localerror, error_domain(), 0, "Error getting properties for ID"); + if (error == NULL && listeners->len > 0) { + GError * localerror = NULL; + for (i = 0; i < listeners->len; i++) { + properties_listener_t * listener = &g_array_index(listeners, properties_listener_t, i); + if (!listener->replied) { + g_warning("Generating properties error for: %d", listener->id); + if (localerror == NULL) { + g_set_error_literal(&localerror, error_domain(), 0, "Error getting properties for ID"); + } + listener->callback(NULL, localerror, listener->user_data); } - listener->callback(NULL, localerror, listener->user_data); } - } - if (localerror != NULL) { - g_error_free(localerror); + if (localerror != NULL) { + g_error_free(localerror); + } } -out: /* Clean up */ g_array_free(listeners, TRUE); g_object_unref(cbdata->client); diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 098de67..e9c8367 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -43,6 +43,7 @@ struct _GenericmenuitemPrivate { GenericmenuitemCheckType check_type; GenericmenuitemState state; GenericmenuitemDisposition disposition; + gchar * label_text; }; /* Private macro */ @@ -82,6 +83,12 @@ 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); parent_draw_indicator = check_class->draw_indicator; @@ -106,6 +113,14 @@ genericmenuitem_init (Genericmenuitem *self) self->priv->check_type = GENERICMENUITEM_CHECK_TYPE_NONE; self->priv->state = GENERICMENUITEM_STATE_UNCHECKED; 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; } @@ -123,6 +138,8 @@ genericmenuitem_dispose (GObject *object) static void genericmenuitem_finalize (GObject *object) { + Genericmenuitem * self = GENERICMENUITEM(object); + g_free(self->priv->label_text); G_OBJECT_CLASS (genericmenuitem_parent_class)->finalize (object); return; @@ -205,6 +222,12 @@ set_label (GtkMenuItem * menu_item, const gchar * in_label) { if (in_label == NULL) return; + Genericmenuitem * item = GENERICMENUITEM(menu_item); + if (in_label != item->priv->label_text) { + g_free(item->priv->label_text); + item->priv->label_text = g_strdup(in_label); + } + /* Build a label that might include the colors of the disposition so that it gets rendered in the menuitem. */ gchar * local_label = NULL; @@ -308,25 +331,9 @@ set_label (GtkMenuItem * menu_item, const gchar * in_label) static const gchar * get_label (GtkMenuItem * menu_item) { - GtkWidget * child = gtk_bin_get_child(GTK_BIN(menu_item)); - GtkLabel * labelw = NULL; + Genericmenuitem * item = GENERICMENUITEM(menu_item); - /* Try to find if we have a label already */ - if (child != NULL) { - if (GTK_IS_LABEL(child)) { - /* We've got a label, let's update it. */ - labelw = GTK_LABEL(child); - } else if (GTK_IS_BOX(child)) { - /* Look for the label in the box */ - gtk_container_foreach(GTK_CONTAINER(child), set_label_helper, &labelw); - } - } - - if (labelw != NULL) { - return gtk_label_get_label(labelw); - } - - return NULL; + return item->priv->label_text; } /* Make sure we don't toggle when there is an @@ -353,18 +360,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); diff --git a/tests/Makefile.am b/tests/Makefile.am index db2d469..6824c1c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -25,8 +25,10 @@ TESTS += \ test-gtk-label \ test-gtk-shortcut \ test-gtk-reorder \ - test-gtk-submenu \ test-gtk-parser-test +# Not working with GTK3 and a critical grab that is in +# the GTK3 code. +# test-gtk-submenu endif # The Python test only work on the system copy of diff --git a/tests/test-gtk-submenu-server.c b/tests/test-gtk-submenu-server.c index 9c4d7d4..1d38a44 100644 --- a/tests/test-gtk-submenu-server.c +++ b/tests/test-gtk-submenu-server.c @@ -64,6 +64,7 @@ on_bus (GDBusConnection * connection, const gchar * name, gpointer user_data) DbusmenuMenuitem * item; item = add_item(root, "Folder 1"); + dbusmenu_menuitem_property_set(item, "disposition", "alert"); add_item(item, "1.1"); add_item(item, "1.2"); add_item(item, "1.3"); |