From 144708e6667818d48e3bbd9403e447079e8a5c56 Mon Sep 17 00:00:00 2001 From: Luke Yelavich Date: Tue, 13 Dec 2011 10:56:56 +1100 Subject: Add a new property DBUSMENU_MENUITEM_PROP_ACCESSIBLE_DESC, to set an alternative label for a menu item. This alternative label is only used for assistive technologies such as Orca. It is particularly useful for menu items where an icon is used to present further information to the user, in which case this property can be used to give a textual description of the icon. --- configure.ac | 2 ++ libdbusmenu-glib/client.c | 3 ++- libdbusmenu-glib/defaults.c | 1 + libdbusmenu-glib/menuitem.h | 12 ++++++++++++ libdbusmenu-gtk/client.c | 6 ++++++ 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index ba5cd4b..ed6080e 100644 --- a/configure.ac +++ b/configure.ac @@ -73,6 +73,7 @@ AM_CONDITIONAL([USE_GTK3], [test "x$with_gtk" = "x3"]) AS_IF([test "x$enable_gtk" != "xno"],[ AS_IF([test "x$with_gtk" = x3], [PKG_CHECK_MODULES(DBUSMENUGTK, gtk+-3.0 >= $GTK3_REQUIRED_VERSION + atk glib-2.0 >= $GLIB_REQUIRED_VERSION, [have_gtk=yes] ) @@ -80,6 +81,7 @@ AS_IF([test "x$with_gtk" = x3], ], [test "x$with_gtk" = x2], [PKG_CHECK_MODULES(DBUSMENUGTK, gtk+-2.0 >= $GTK_REQUIRED_VERSION + atk glib-2.0 >= $GLIB_REQUIRED_VERSION, [have_gtk=yes] ) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 9129db5..a2330d1 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -331,7 +331,7 @@ dbusmenu_client_class_init (DbusmenuClientClass *klass) return; } -#define LAYOUT_PROPS_COUNT 5 +#define LAYOUT_PROPS_COUNT 6 static void dbusmenu_client_init (DbusmenuClient *self) @@ -359,6 +359,7 @@ dbusmenu_client_init (DbusmenuClient *self) layout_props[2] = DBUSMENU_MENUITEM_PROP_VISIBLE; layout_props[3] = DBUSMENU_MENUITEM_PROP_ENABLED; layout_props[4] = DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY; + layout_props[5] = DBUSMENU_MENUITEM_PROP_ACCESSIBLE_DESC; layout_props[LAYOUT_PROPS_COUNT] = NULL; priv->layout_props = g_variant_new_strv((const gchar * const *)layout_props, LAYOUT_PROPS_COUNT); g_variant_ref_sink(priv->layout_props); diff --git a/libdbusmenu-glib/defaults.c b/libdbusmenu-glib/defaults.c index a5caf0b..10a9115 100644 --- a/libdbusmenu-glib/defaults.c +++ b/libdbusmenu-glib/defaults.c @@ -88,6 +88,7 @@ dbusmenu_defaults_init (DbusmenuDefaults *self) dbusmenu_defaults_default_set(self, DBUSMENU_CLIENT_TYPES_DEFAULT, DBUSMENU_MENUITEM_PROP_SHORTCUT, G_VARIANT_TYPE("aas"), NULL); dbusmenu_defaults_default_set(self, DBUSMENU_CLIENT_TYPES_DEFAULT, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY, G_VARIANT_TYPE_STRING, NULL); dbusmenu_defaults_default_set(self, DBUSMENU_CLIENT_TYPES_DEFAULT, DBUSMENU_MENUITEM_PROP_DISPOSITION, G_VARIANT_TYPE_STRING, g_variant_new_string(DBUSMENU_MENUITEM_DISPOSITION_NORMAL)); + dbusmenu_defaults_default_set(self, DBUSMENU_CLIENT_TYPES_DEFAULT, DBUSMENU_MENUITEM_PROP_ACCESSIBLE_DESC,G_VARIANT_TYPE_STRING, NULL); /* Separator defaults */ dbusmenu_defaults_default_set(self, DBUSMENU_CLIENT_TYPES_SEPARATOR, DBUSMENU_MENUITEM_PROP_VISIBLE, G_VARIANT_TYPE_BOOLEAN, g_variant_new_boolean(TRUE)); diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index 985e1a3..ea455ac 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -153,6 +153,18 @@ G_BEGIN_DECLS * libdbusmenu-gtk library is used with the function dbusmenu_menuitem_property_set_image() */ #define DBUSMENU_MENUITEM_PROP_ICON_DATA "icon-data" +/** + * DBUSMENU_MENUITEM_PROP_ACCESSIBLE_DESC: + * + * #DbusmenuMenuitem property used to provide a textual description of any + * information that the icon may convey. The contents of this property are + * passed through to assistive technologies such as the Orca screen reader. + * The contents of this property will not be visible in the menu item. If + * this property is set, Orca will use this property instead of the label + * property. + * Type: #G_VARIANT_TYPE_STRING + */ +#define DBUSMENU_MENUITEM_PROP_ACCESSIBLE_DESC "accessible-desc" /** * DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE: * diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 533764a..7390fb1 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -32,6 +32,7 @@ License version 3 and version 2.1 along with this program. If not, see #include #include +#include #include "client.h" #include "menuitem.h" @@ -745,6 +746,9 @@ menu_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant * variant, Db process_submenu(mi, gmi, variant, gtkclient); } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_DISPOSITION)) { process_disposition(mi, gmi, variant, gtkclient); + } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_ACCESSIBLE_DESC)) { + atk_object_set_name(gtk_widget_get_accessible(GTK_WIDGET(gmi)), variant == NULL ? NULL : + g_variant_get_string(variant, NULL)); } return; @@ -890,6 +894,8 @@ dbusmenu_gtkclient_newitem_base (DbusmenuGtkClient * client, DbusmenuMenuitem * process_toggle_state(item, gmi, dbusmenu_menuitem_property_get_variant(item, DBUSMENU_MENUITEM_PROP_TOGGLE_STATE)); process_submenu(item, gmi, dbusmenu_menuitem_property_get_variant(item, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY), client); process_disposition(item, gmi, dbusmenu_menuitem_property_get_variant(item, DBUSMENU_MENUITEM_PROP_DISPOSITION), client); + atk_object_set_name(gtk_widget_Get_accessible(GTK_WIDGET)gmi)), + g_variant_get_string(dbusmenu_menuitem_property_get_variant(item, DBUSMENU_MENUITEM_PROP_ACCESSIBLE_DESC))); refresh_shortcut(client, item); /* Oh, we're a child, let's deal with that */ -- cgit v1.2.3