diff options
Diffstat (limited to 'libdbusmenu-gtk')
-rw-r--r-- | libdbusmenu-gtk/Makefile.am | 7 | ||||
-rw-r--r-- | libdbusmenu-gtk/Makefile.in | 9 | ||||
-rw-r--r-- | libdbusmenu-gtk/client.c | 22 | ||||
-rw-r--r-- | libdbusmenu-gtk/dbusmenu-gtk-0.4.pc.in | 2 | ||||
-rw-r--r-- | libdbusmenu-gtk/dbusmenu-gtk3-0.4.pc.in | 2 | ||||
-rw-r--r-- | libdbusmenu-gtk/genericmenuitem.c | 10 | ||||
-rw-r--r-- | libdbusmenu-gtk/menuitem.c | 14 | ||||
-rw-r--r-- | libdbusmenu-gtk/parser.c | 36 |
8 files changed, 70 insertions, 32 deletions
diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index b4564d1..b1ee91a 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-gtk$(VER)-0.4/libdbusmenu-gtk/ libdbusmenu_gtkinclude_HEADERS = \ dbusmenu-gtk.h \ @@ -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 \ diff --git a/libdbusmenu-gtk/Makefile.in b/libdbusmenu-gtk/Makefile.in index 8278b2c..a1d9df2 100644 --- a/libdbusmenu-gtk/Makefile.in +++ b/libdbusmenu-gtk/Makefile.in @@ -368,7 +368,7 @@ glib_enum_headers = $(srcdir)/genericmenuitem.h ##################### # Include Directory ##################### -libdbusmenu_gtkincludedir = $(includedir)/libdbusmenu-0.4/libdbusmenu-gtk$(VER)/ +libdbusmenu_gtkincludedir = $(includedir)/libdbusmenu-gtk$(VER)-0.4/libdbusmenu-gtk/ libdbusmenu_gtkinclude_HEADERS = \ dbusmenu-gtk.h \ client.h \ @@ -396,7 +396,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 \ @@ -1031,7 +1034,7 @@ stamp-enum-types: $(glib_enum_headers) $(glib_enum_h): stamp-enum-types @true -$(glib_enum_c): $(glib_enum_h) +$(glib_enum_c): $(builddir)/$(glib_enum_h) $(QUIET_GEN)mkdir -p `dirname $(builddir)/$(glib_enum_c)` $(QUIET_GEN)$(GLIB_MKENUMS) \ --template $(srcdir)/$(enum_tmpl_c) \ diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 38b6a75..9888cbe 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 <gtk/gtk.h> #include <glib.h> +#include <atk/atk.h> #include "client.h" #include "menuitem.h" @@ -505,7 +506,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; @@ -575,6 +575,14 @@ close_in_idle (DbusmenuMenuitem * mi) } 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) { if (gtk_widget_get_visible (menu)) { @@ -591,8 +599,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); } } } @@ -738,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; @@ -885,6 +896,11 @@ dbusmenu_gtkclient_newitem_base (DbusmenuGtkClient * client, DbusmenuMenuitem * process_disposition(item, gmi, dbusmenu_menuitem_property_get_variant(item, DBUSMENU_MENUITEM_PROP_DISPOSITION), client); 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)); 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 c297db3..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}/libdbusmenu-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/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); 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; } diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 92932c5..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" @@ -66,10 +67,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 HAVE_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 +188,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 +294,16 @@ watch_submenu(DbusmenuMenuitem * mi, GtkWidget * menu) pdata->shell = menu; g_signal_connect (G_OBJECT (menu), - "child-added", - G_CALLBACK (child_added_cb), +#ifdef HAVE_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 +1145,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 HAVE_GTK3 + gint position, +#endif + gpointer data) { DbusmenuMenuitem *menuitem = (DbusmenuMenuitem *)data; @@ -1152,9 +1165,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 +1229,3 @@ should_show_image (GtkImage *image) return FALSE; } - |