From 1b83b3b0758d29d94a1e404f551939ea1885ad76 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Thu, 10 Nov 2011 17:49:27 -0500 Subject: make sure to cancel an idle callback when the object dies --- libdbusmenu-gtk/client.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 38b6a75..533764a 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -505,7 +505,6 @@ menu_item_stop_activating(DbusmenuMenuitem * mi) guint id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(parent), data_idle_close_id)); if (id > 0) { - g_source_remove(id); g_object_set_data(G_OBJECT(parent), data_idle_close_id, GINT_TO_POINTER(0)); should_close = TRUE; @@ -574,6 +573,14 @@ close_in_idle (DbusmenuMenuitem * mi) return FALSE; } +static void +cancel_idle_close_id (gpointer data) +{ + guint id = GPOINTER_TO_INT(data); + if (id > 0) + g_source_remove(id); +} + static void submenu_notify_visible_cb (GtkWidget * menu, GParamSpec * pspec, DbusmenuMenuitem * mi) { @@ -591,8 +598,8 @@ submenu_notify_visible_cb (GtkWidget * menu, GParamSpec * pspec, DbusmenuMenuite data_idle_close_id)); if (id == 0) { id = g_idle_add((GSourceFunc)close_in_idle, mi); - g_object_set_data(G_OBJECT(mi), data_idle_close_id, - GINT_TO_POINTER(id)); + g_object_set_data_full(G_OBJECT(mi), data_idle_close_id, + GINT_TO_POINTER(id), cancel_idle_close_id); } } } -- cgit v1.2.3 From 0f7fdf8d2c567a641083646a43e6ebec1faf9078 Mon Sep 17 00:00:00 2001 From: György Balló Date: Mon, 21 Nov 2011 03:52:39 +0100 Subject: Use different directory for headers of gtk3 library --- libdbusmenu-gtk/Makefile.am | 2 +- libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index b4564d1..7860433 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -33,7 +33,7 @@ glib_enum_headers = $(srcdir)/genericmenuitem.h # Include Directory ##################### -libdbusmenu_gtkincludedir=$(includedir)/libdbusmenu-0.4/libdbusmenu-gtk$(VER)/ +libdbusmenu_gtkincludedir=$(includedir)/libdbusmenu$(VER)-0.4/libdbusmenu-gtk/ libdbusmenu_gtkinclude_HEADERS = \ dbusmenu-gtk.h \ diff --git a/libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc.in b/libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc.in index c297db3..c320a57 100644 --- a/libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc.in +++ b/libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc.in @@ -4,7 +4,7 @@ libdir=@libdir@ bindir=@bindir@ includedir=@includedir@ -Cflags: -I${includedir}/libdbusmenu-0.4 +Cflags: -I${includedir}/libdbusmenu3-0.4 Requires: dbusmenu-glib-0.4 gdk-pixbuf-2.0 gtk+-3.0 Libs: -L${libdir} -ldbusmenu-gtk3 -- cgit v1.2.3 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(-) (limited to 'libdbusmenu-gtk') 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 From 82f99f0a30316807d0c261308bc207e74eacbd33 Mon Sep 17 00:00:00 2001 From: György Balló Date: Thu, 5 Jan 2012 20:39:42 +0100 Subject: Separate libdbusmenu-glib and libdbusmenu-gtk include directories --- libdbusmenu-glib/Makefile.am | 2 +- libdbusmenu-glib/dbusmenu-glib-0.4.pc.in | 2 +- libdbusmenu-gtk/Makefile.am | 2 +- libdbusmenu-gtk/dbusmenu-gtk-0.4.pc.in | 2 +- libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc.in | 2 +- tests/Makefile.am | 2 +- tests/dbusmenu-jsonloader-0.4.pc.in | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index 7d4ea5d..5a04900 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -15,7 +15,7 @@ include $(top_srcdir)/Makefile.am.enum lib_LTLIBRARIES = \ libdbusmenu-glib.la -libdbusmenu_glibincludedir=$(includedir)/libdbusmenu-0.4/libdbusmenu-glib/ +libdbusmenu_glibincludedir=$(includedir)/libdbusmenu-glib-0.4/libdbusmenu-glib/ EXPORTED_OBJECTS = \ diff --git a/libdbusmenu-glib/dbusmenu-glib-0.4.pc.in b/libdbusmenu-glib/dbusmenu-glib-0.4.pc.in index 31a1eac..fd71acf 100644 --- a/libdbusmenu-glib/dbusmenu-glib-0.4.pc.in +++ b/libdbusmenu-glib/dbusmenu-glib-0.4.pc.in @@ -4,7 +4,7 @@ libdir=@libdir@ bindir=@bindir@ includedir=@includedir@ -Cflags: -I${includedir}/libdbusmenu-0.4 +Cflags: -I${includedir}/libdbusmenu-glib-0.4 Requires: Libs: -L${libdir} -ldbusmenu-glib diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index 7860433..2b3075f 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -33,7 +33,7 @@ glib_enum_headers = $(srcdir)/genericmenuitem.h # Include Directory ##################### -libdbusmenu_gtkincludedir=$(includedir)/libdbusmenu$(VER)-0.4/libdbusmenu-gtk/ +libdbusmenu_gtkincludedir=$(includedir)/libdbusmenu-gtk$(VER)-0.4/libdbusmenu-gtk/ libdbusmenu_gtkinclude_HEADERS = \ dbusmenu-gtk.h \ diff --git a/libdbusmenu-gtk/dbusmenu-gtk-0.4.pc.in b/libdbusmenu-gtk/dbusmenu-gtk-0.4.pc.in index 9a1b460..cae4c10 100644 --- a/libdbusmenu-gtk/dbusmenu-gtk-0.4.pc.in +++ b/libdbusmenu-gtk/dbusmenu-gtk-0.4.pc.in @@ -4,7 +4,7 @@ libdir=@libdir@ bindir=@bindir@ includedir=@includedir@ -Cflags: -I${includedir}/libdbusmenu-0.4 +Cflags: -I${includedir}/libdbusmenu-gtk-0.4 Requires: dbusmenu-glib-0.4 gdk-pixbuf-2.0 gtk+-2.0 Libs: -L${libdir} -ldbusmenu-gtk diff --git a/libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc.in b/libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc.in index c320a57..ba4c1aa 100644 --- a/libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc.in +++ b/libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc.in @@ -4,7 +4,7 @@ libdir=@libdir@ bindir=@bindir@ includedir=@includedir@ -Cflags: -I${includedir}/libdbusmenu3-0.4 +Cflags: -I${includedir}/libdbusmenu-gtk3-0.4 Requires: dbusmenu-glib-0.4 gdk-pixbuf-2.0 gtk+-3.0 Libs: -L${libdir} -ldbusmenu-gtk3 diff --git a/tests/Makefile.am b/tests/Makefile.am index a4e8682..5110b8e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -86,7 +86,7 @@ TESTS_ENVIRONMENT = env GI_TYPELIB_PATH=$(top_builddir)/libdbusmenu-glib:$(top_b lib_LTLIBRARIES = libdbusmenu-jsonloader.la -libdbusmenu_jsonloaderincludedir=$(includedir)/libdbusmenu-0.4/libdbusmenu-jsonloader/ +libdbusmenu_jsonloaderincludedir=$(includedir)/libdbusmenu-glib-0.4/libdbusmenu-jsonloader/ libdbusmenu_jsonloaderinclude_HEADERS = \ json-loader.h diff --git a/tests/dbusmenu-jsonloader-0.4.pc.in b/tests/dbusmenu-jsonloader-0.4.pc.in index 62bfeb2..1920d02 100644 --- a/tests/dbusmenu-jsonloader-0.4.pc.in +++ b/tests/dbusmenu-jsonloader-0.4.pc.in @@ -4,7 +4,7 @@ libdir=@libdir@ bindir=@bindir@ includedir=@includedir@ -Cflags: -I${includedir}/libdbusmenu-0.1 +Cflags: -I${includedir}/libdbusmenu-glib-0.4 Requires: dbusmenu-glib-0.4 json-glib-1.0 Libs: -L${libdir} -ldbusmenu-jsonloader -- cgit v1.2.3 From 248e0c0f0ce3883579caa56369e7e92340ae9c64 Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Thu, 12 Jan 2012 11:35:50 +0100 Subject: in gtk3, use stock signals instead of Ubuntu-specific ones --- libdbusmenu-gtk/Makefile.am | 2 +- libdbusmenu-gtk/parser.c | 35 +++++++++++++++++++++++------------ 2 files changed, 24 insertions(+), 13 deletions(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index b4564d1..9e0967f 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -76,7 +76,7 @@ libdbusmenu_gtk3includedir = $(libdbusmenu_gtkincludedir) libdbusmenu_gtk3include_HEADERS = $(libdbusmenu_gtkinclude_HEADERS) libdbusmenu_gtk3_la_SOURCES = $(libdbusmenu_gtk_la_SOURCES) libdbusmenu_gtk3_la_LDFLAGS = $(libdbusmenu_gtk_la_LDFLAGS) -libdbusmenu_gtk3_la_CFLAGS = $(libdbusmenu_gtk_la_CFLAGS) +libdbusmenu_gtk3_la_CFLAGS = $(libdbusmenu_gtk_la_CFLAGS) -DWITH_GTK3 libdbusmenu_gtk3_la_LIBADD = $(libdbusmenu_gtk_la_LIBADD) pkgconfig_DATA = dbusmenu-gtk$(VER)-0.4.pc diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 92932c5..5f50dc6 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -66,10 +66,13 @@ static void image_notify_cb (GtkWidget * widget, static void action_notify_cb (GtkAction * action, GParamSpec * pspec, gpointer data); -static void child_added_cb (GtkContainer * menu, +static void item_inserted_cb (GtkContainer * menu, GtkWidget * widget, +#ifdef WITH_GTK3 + gint position, +#endif gpointer data); -static void child_removed_cb (GtkContainer * menu, +static void item_removed_cb (GtkContainer * menu, GtkWidget * widget, gpointer data); static void theme_changed_cb (GtkIconTheme * theme, @@ -184,9 +187,9 @@ parse_data_free (gpointer data) if (pdata != NULL && pdata->shell != NULL) { g_signal_handlers_disconnect_matched(pdata->shell, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, - 0, 0, NULL, G_CALLBACK(child_added_cb), NULL); + 0, 0, NULL, G_CALLBACK(item_inserted_cb), NULL); g_signal_handlers_disconnect_matched(pdata->shell, (GSignalMatchType)G_SIGNAL_MATCH_FUNC, - 0, 0, NULL, G_CALLBACK(child_removed_cb), NULL); + 0, 0, NULL, G_CALLBACK(item_removed_cb), NULL); g_object_remove_weak_pointer(G_OBJECT(pdata->shell), (gpointer*)&pdata->shell); } @@ -290,12 +293,16 @@ watch_submenu(DbusmenuMenuitem * mi, GtkWidget * menu) pdata->shell = menu; g_signal_connect (G_OBJECT (menu), - "child-added", - G_CALLBACK (child_added_cb), +#ifdef WITH_GTK3 + "insert", +#else + "child-added" +#endif + G_CALLBACK (item_inserted_cb), mi); g_signal_connect (G_OBJECT (menu), - "child-removed", - G_CALLBACK (child_removed_cb), + "remove", + G_CALLBACK (item_removed_cb), mi); g_object_add_weak_pointer(G_OBJECT (menu), (gpointer*)&pdata->shell); @@ -1137,7 +1144,12 @@ widget_add_cb (GtkWidget *widget, /* A child item was added to a menu we're watching. Let's try to integrate it. */ static void -child_added_cb (GtkContainer *menu, GtkWidget *widget, gpointer data) +item_inserted_cb (GtkContainer *menu, + GtkWidget *widget, +#ifdef WITH_GTK3 + gint position, +#endif + gpointer data) { DbusmenuMenuitem *menuitem = (DbusmenuMenuitem *)data; @@ -1152,9 +1164,9 @@ child_added_cb (GtkContainer *menu, GtkWidget *widget, gpointer data) parse_menu_structure_helper(widget, &recurse); } -/* A child item was added to a menu we're watching. Let's try to integrate it. */ +/* A child item was removed from a menu we're watching. */ static void -child_removed_cb (GtkContainer *menu, GtkWidget *widget, gpointer data) +item_removed_cb (GtkContainer *menu, GtkWidget *widget, gpointer data) { gpointer pmi = g_object_get_data(G_OBJECT(widget), CACHED_MENUITEM); if (pmi == NULL) { @@ -1216,4 +1228,3 @@ should_show_image (GtkImage *image) return FALSE; } - -- cgit v1.2.3 From 145fba945cdc582ccdf5dc483acb7f170325549b Mon Sep 17 00:00:00 2001 From: Mikkel Kamstrup Erlandsen Date: Mon, 16 Jan 2012 12:57:11 +0100 Subject: Fix build with gtk3 by ifdeffing the GtkBox/HBox construction in genericmenuitem.c --- libdbusmenu-gtk/genericmenuitem.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index ef77a2e..098de67 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -241,7 +241,12 @@ set_label (GtkMenuItem * menu_item, const gchar * in_label) /* We need to put the child into a new box and make the box the child of the menu item. Basically we're inserting a box in the middle. */ + #ifdef HAVE_GTK3 + GtkWidget * hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, + get_toggle_space(GTK_WIDGET(menu_item))); + #else GtkWidget * hbox = gtk_hbox_new(FALSE, get_toggle_space(GTK_WIDGET(menu_item))); + #endif g_object_ref(child); gtk_container_remove(GTK_CONTAINER(menu_item), child); gtk_box_pack_start(GTK_BOX(hbox), child, FALSE, FALSE, 0); @@ -457,7 +462,12 @@ genericmenuitem_set_image (Genericmenuitem * menu_item, GtkWidget * image) /* We need to put the child into a new box and make the box the child of the menu item. Basically we're inserting a box in the middle. */ + #ifdef HAVE_GTK3 + GtkWidget * hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, + get_toggle_space(GTK_WIDGET(menu_item))); + #else GtkWidget * hbox = gtk_hbox_new(FALSE, get_toggle_space(GTK_WIDGET(menu_item))); + #endif g_object_ref(child); gtk_container_remove(GTK_CONTAINER(menu_item), child); gtk_box_pack_end(GTK_BOX(hbox), child, TRUE, TRUE, 0); -- cgit v1.2.3 From 9a01ce5b74bd5d2012a59e9d55a49531da1c4d14 Mon Sep 17 00:00:00 2001 From: Aurélien Gâteau Date: Mon, 23 Jan 2012 14:38:36 +0100 Subject: Change icon-data to contains raw png bytes, without base64 encoding Reasons: - base64 encoding is not necessary because dbusmenu properties can use any dbus-supported types. - faster: no need to base64 decode/encode images - more efficient: base64-encoded data is 1/3 bigger than raw data --- libdbusmenu-glib/menuitem.c | 51 +++++++++++++++++++++++++++++++++++++++++++++ libdbusmenu-glib/menuitem.h | 2 ++ libdbusmenu-gtk/menuitem.c | 14 ++++--------- 3 files changed, 57 insertions(+), 10 deletions(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index c9c7736..30ae277 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1126,6 +1126,32 @@ dbusmenu_menuitem_property_set_int (DbusmenuMenuitem * mi, const gchar * propert return dbusmenu_menuitem_property_set_variant(mi, property, variant); } +/** + * dbusmenu_menuitem_property_set_byte_array: + * @mi: The #DbusmenuMenuitem to set the property on. + * @property: Name of the property to set. + * @value: The byte array. + * @nelements: The number of elements in the byte array. + * + * Takes a byte array @value and sets it on @property as a + * property on @mi. If a property already exists by that name, + * then the value is set to the new value. If not, the property + * is added. If the value is changed or the property was previously + * unset then the signal #DbusmenuMenuitem::prop-changed will be + * emitted by this function. + * + * Return value: A boolean representing if the property value was set. + */ +gboolean +dbusmenu_menuitem_property_set_byte_array (DbusmenuMenuitem * mi, const gchar * property, const guchar * value, gsize nelements) +{ + GVariant * variant = NULL; + if (value != NULL) { + variant = g_variant_new_fixed_array(G_VARIANT_TYPE_BYTE, value, nelements, sizeof(guchar)); + } + return dbusmenu_menuitem_property_set_variant(mi, property, variant); +} + /** * dbusmenu_menuitem_property_set_variant: * @mi: The #DbusmenuMenuitem to set the property on. @@ -1360,6 +1386,31 @@ dbusmenu_menuitem_property_get_int (DbusmenuMenuitem * mi, const gchar * propert return 0; } +/** + * dbusmenu_menuitem_property_get_byte_array: + * @mi: The #DbusmenuMenuitem to look for the property on. + * @property: The property to grab. + * @nelements: A pointer to the location to store the number of items (out) + * + * Look up a property on @mi and return the value of it if + * it exits. #NULL will be returned if the property doesn't + * exist. + * + * Return value: (array length=nelements)(element-type guint8)(transfer none): A byte array with the + * value of the property that shouldn't be free'd. Or #NULL if the property + * is not set or is not a byte array. + */ +const guchar * +dbusmenu_menuitem_property_get_byte_array (DbusmenuMenuitem * mi, const gchar * property, gsize * nelements) +{ + GVariant * variant = dbusmenu_menuitem_property_get_variant(mi, property); + if (variant == NULL) { + *nelements = 0; + return NULL; + } + if (!g_variant_type_equal(g_variant_get_type(variant), G_VARIANT_TYPE("ay"))) return NULL; + return g_variant_get_fixed_array(variant, nelements, sizeof(guchar)); +} /** * dbusmenu_menuitem_property_exist: diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index 985e1a3..64dc87c 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -485,10 +485,12 @@ gboolean dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * pr gboolean dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * property, GVariant * value); gboolean dbusmenu_menuitem_property_set_bool (DbusmenuMenuitem * mi, const gchar * property, const gboolean value); gboolean dbusmenu_menuitem_property_set_int (DbusmenuMenuitem * mi, const gchar * property, const gint value); +gboolean dbusmenu_menuitem_property_set_byte_array (DbusmenuMenuitem * mi, const gchar * property, const guchar * value, gsize nelements); const gchar * dbusmenu_menuitem_property_get (DbusmenuMenuitem * mi, const gchar * property); GVariant * dbusmenu_menuitem_property_get_variant (DbusmenuMenuitem * mi, const gchar * property); gboolean dbusmenu_menuitem_property_get_bool (DbusmenuMenuitem * mi, const gchar * property); gint dbusmenu_menuitem_property_get_int (DbusmenuMenuitem * mi, const gchar * property); +const guchar * dbusmenu_menuitem_property_get_byte_array (DbusmenuMenuitem * mi, const gchar * property, gsize * nelements); gboolean dbusmenu_menuitem_property_exist (DbusmenuMenuitem * mi, const gchar * property); GList * dbusmenu_menuitem_properties_list (DbusmenuMenuitem * mi) G_GNUC_WARN_UNUSED_RESULT; GHashTable * dbusmenu_menuitem_properties_copy (DbusmenuMenuitem * mi); diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c index 0f511bc..19ea1a0 100644 --- a/libdbusmenu-gtk/menuitem.c +++ b/libdbusmenu-gtk/menuitem.c @@ -66,11 +66,9 @@ dbusmenu_menuitem_property_set_image (DbusmenuMenuitem * menuitem, const gchar * return FALSE; } - gchar * prop_str = g_base64_encode((guchar *)png_data, png_data_len); gboolean propreturn = FALSE; - propreturn = dbusmenu_menuitem_property_set(menuitem, property, prop_str); + propreturn = dbusmenu_menuitem_property_set_byte_array(menuitem, property, (guchar *)png_data, png_data_len); - g_free(prop_str); g_free(png_data); return propreturn; @@ -94,20 +92,17 @@ dbusmenu_menuitem_property_get_image (DbusmenuMenuitem * menuitem, const gchar * g_return_val_if_fail(DBUSMENU_IS_MENUITEM(menuitem), NULL); g_return_val_if_fail(property != NULL && property[0] != '\0', NULL); - const gchar * value = dbusmenu_menuitem_property_get(menuitem, property); + gsize length = 0; + const guchar * icondata = dbusmenu_menuitem_property_get_byte_array(menuitem, property, &length); /* There is no icon */ - if (value == NULL || value[0] == '\0') { + if (length == 0) { return NULL; } - - gsize length = 0; - guchar * icondata = g_base64_decode(value, &length); GInputStream * input = g_memory_input_stream_new_from_data(icondata, length, NULL); if (input == NULL) { g_warning("Cound not create input stream from icon property data"); - g_free(icondata); return NULL; } @@ -120,7 +115,6 @@ dbusmenu_menuitem_property_get_image (DbusmenuMenuitem * menuitem, const gchar * } g_object_unref(input); - g_free(icondata); return icon; } -- cgit v1.2.3 From d0065933d25307a95644e3ab984de0f4f848d6ad Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 26 Jan 2012 13:33:24 -0600 Subject: Remove custom WITH_GTK3 and use the HAVE_GTK3 --- libdbusmenu-gtk/Makefile.am | 2 +- libdbusmenu-gtk/parser.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index 9e0967f..b4564d1 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -76,7 +76,7 @@ libdbusmenu_gtk3includedir = $(libdbusmenu_gtkincludedir) libdbusmenu_gtk3include_HEADERS = $(libdbusmenu_gtkinclude_HEADERS) libdbusmenu_gtk3_la_SOURCES = $(libdbusmenu_gtk_la_SOURCES) libdbusmenu_gtk3_la_LDFLAGS = $(libdbusmenu_gtk_la_LDFLAGS) -libdbusmenu_gtk3_la_CFLAGS = $(libdbusmenu_gtk_la_CFLAGS) -DWITH_GTK3 +libdbusmenu_gtk3_la_CFLAGS = $(libdbusmenu_gtk_la_CFLAGS) libdbusmenu_gtk3_la_LIBADD = $(libdbusmenu_gtk_la_LIBADD) pkgconfig_DATA = dbusmenu-gtk$(VER)-0.4.pc diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 5f50dc6..d222f10 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -68,7 +68,7 @@ static void action_notify_cb (GtkAction * action, gpointer data); static void item_inserted_cb (GtkContainer * menu, GtkWidget * widget, -#ifdef WITH_GTK3 +#ifdef HAVE_GTK3 gint position, #endif gpointer data); @@ -293,7 +293,7 @@ watch_submenu(DbusmenuMenuitem * mi, GtkWidget * menu) pdata->shell = menu; g_signal_connect (G_OBJECT (menu), -#ifdef WITH_GTK3 +#ifdef HAVE_GTK3 "insert", #else "child-added" @@ -1146,7 +1146,7 @@ widget_add_cb (GtkWidget *widget, static void item_inserted_cb (GtkContainer *menu, GtkWidget *widget, -#ifdef WITH_GTK3 +#ifdef HAVE_GTK3 gint position, #endif gpointer data) -- cgit v1.2.3 From 4eae3efbe5c3aa84035b2ade9ceedd68b7b3e895 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 26 Jan 2012 13:36:57 -0600 Subject: Move the no-error on deprications into the Makefiles so it's always after the -Wall --- configure.ac | 2 -- libdbusmenu-glib/Makefile.am | 4 +++- libdbusmenu-gtk/Makefile.am | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) (limited to 'libdbusmenu-gtk') diff --git a/configure.ac b/configure.ac index 13efd3c..fd69595 100644 --- a/configure.ac +++ b/configure.ac @@ -23,8 +23,6 @@ m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) AC_PATH_PROG([GLIB_MKENUMS], [glib-mkenums]) -CFLAGS="$CFLAGS -Wno-error=deprecated-declarations" - ########################### # GTK Doc ########################### diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index 591bf30..83b2e7b 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -62,7 +62,9 @@ libdbusmenu_glib_la_LDFLAGS = \ -export-symbols-regex "^[^_].*" libdbusmenu_glib_la_CFLAGS = \ - $(DBUSMENUGLIB_CFLAGS) -Wall -Werror -DG_DISABLE_DEPRECATED -DG_LOG_DOMAIN="\"LIBDBUSMENU-GLIB\"" + $(DBUSMENUGLIB_CFLAGS) \ + -Wall -Werror -Wno-error=deprecated-declarations \ + -DG_LOG_DOMAIN="\"LIBDBUSMENU-GLIB\"" libdbusmenu_glib_la_LIBADD = \ $(DBUSMENUGLIB_LIBS) diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index b4564d1..9f297f5 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -62,7 +62,10 @@ libdbusmenu_gtk_la_LDFLAGS = \ -export-symbols-regex "^[^_].*" libdbusmenu_gtk_la_CFLAGS = \ - $(DBUSMENUGTK_CFLAGS) -I$(top_srcdir) -Wall -Werror -DG_DISABLE_DEPRECATED -DG_LOG_DOMAIN="\"LIBDBUSMENU-GTK\"" + $(DBUSMENUGTK_CFLAGS) \ + -I$(top_srcdir) \ + -Wall -Werror -Wno-error=deprecated-declarations \ + -DG_LOG_DOMAIN="\"LIBDBUSMENU-GTK\"" libdbusmenu_gtk_la_LIBADD = \ ../libdbusmenu-glib/libdbusmenu-glib.la \ -- cgit v1.2.3 From 9b2524f59c26df873495b308b2ea7ca2fda602f6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 26 Jan 2012 13:52:38 -0600 Subject: Fix function calls here --- libdbusmenu-gtk/client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 7390fb1..14c71ab 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -894,8 +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))); + 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), NULL)); refresh_shortcut(client, item); /* Oh, we're a child, let's deal with that */ -- cgit v1.2.3 From b68c281a6b3761af902a4d4e8a35cf450c298ec0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 26 Jan 2012 13:53:21 -0600 Subject: Missing comma --- libdbusmenu-gtk/parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index d222f10..2abeccd 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -296,7 +296,7 @@ watch_submenu(DbusmenuMenuitem * mi, GtkWidget * menu) #ifdef HAVE_GTK3 "insert", #else - "child-added" + "child-added", #endif G_CALLBACK (item_inserted_cb), mi); -- cgit v1.2.3 From a68451b70e621c1c9b59f4d6be78c3e327356eed Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 26 Jan 2012 13:56:13 -0600 Subject: Include config.h to get the HAVE_GTK3 define --- libdbusmenu-gtk/parser.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 2abeccd..0ecfa1e 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -29,6 +29,7 @@ License version 3 and version 2.1 along with this program. If not, see #include "parser.h" #include "menuitem.h" #include "client.h" +#include "config.h" #define CACHED_MENUITEM "dbusmenu-gtk-parser-cached-item" #define PARSER_DATA "dbusmenu-gtk-parser-data" -- cgit v1.2.3 From d27208df523d669e2bf86ab0506634d0ae86e558 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 26 Jan 2012 19:53:42 -0600 Subject: Only setting the accessible object name if it has been set --- libdbusmenu-gtk/client.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 14c71ab..9888cbe 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -894,10 +894,13 @@ 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), NULL)); refresh_shortcut(client, item); + const gchar * a11y_desc = dbusmenu_menuitem_property_get(item, DBUSMENU_MENUITEM_PROP_ACCESSIBLE_DESC); + if (a11y_desc != NULL) { + atk_object_set_name(gtk_widget_get_accessible(GTK_WIDGET(gmi)), a11y_desc); + } + /* Oh, we're a child, let's deal with that */ if (parent != NULL) { new_child(parent, item, dbusmenu_menuitem_get_position(item, parent), DBUSMENU_GTKCLIENT(client)); -- cgit v1.2.3