aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-gtk/parser.c
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2012-01-30 23:20:48 -0600
committerTed Gould <ted@gould.cx>2012-01-30 23:20:48 -0600
commit9332359a3cad3a5f23e7ff0c4bae14159818d026 (patch)
tree372281b1a4a4c9abe902f2726277df5ddda18027 /libdbusmenu-gtk/parser.c
parentf966667e6e1af74f06c65d8cfca78d0b861d5621 (diff)
parent8d7a4ec5cbf30119b0ec553174853556a480228a (diff)
downloadlibdbusmenu-9332359a3cad3a5f23e7ff0c4bae14159818d026.tar.gz
libdbusmenu-9332359a3cad3a5f23e7ff0c4bae14159818d026.tar.bz2
libdbusmenu-9332359a3cad3a5f23e7ff0c4bae14159818d026.zip
Import upstream version 0.5.90
Diffstat (limited to 'libdbusmenu-gtk/parser.c')
-rw-r--r--libdbusmenu-gtk/parser.c45
1 files changed, 31 insertions, 14 deletions
diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c
index e988c62..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);
@@ -1059,8 +1067,13 @@ widget_notify_cb (GtkWidget *widget,
DBUSMENU_MENUITEM_PROP_VISIBLE,
g_value_get_boolean (&prop_value));
}
- else if (pspec->name == g_intern_static_string ("image") ||
- pspec->name == g_intern_static_string ("always-show-image"))
+ else if (pspec->name == g_intern_static_string ("always-show-image"))
+ {
+ GtkWidget *image = NULL;
+ g_object_get(widget, "image", &image, NULL);
+ update_icon (child, GTK_IMAGE(image));
+ }
+ else if (pspec->name == g_intern_static_string ("image"))
{
GtkWidget *image;
image = GTK_WIDGET (g_value_get_object (&prop_value));
@@ -1132,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;
@@ -1147,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) {
@@ -1211,4 +1229,3 @@ should_show_image (GtkImage *image)
return FALSE;
}
-