diff options
author | Ted Gould <ted@gould.cx> | 2012-03-02 14:40:37 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2012-03-02 14:40:37 -0600 |
commit | 6f5a36c2abdad2fccc9848f34b3572c425abd39e (patch) | |
tree | 4c6547c7889f8d2cba5ac34d9ba11360cfa0aae9 | |
parent | 16848ad3b788226b2f247dea73895580eb5b2d71 (diff) | |
download | libdbusmenu-6f5a36c2abdad2fccc9848f34b3572c425abd39e.tar.gz libdbusmenu-6f5a36c2abdad2fccc9848f34b3572c425abd39e.tar.bz2 libdbusmenu-6f5a36c2abdad2fccc9848f34b3572c425abd39e.zip |
Moving the adding of signals to the update_icon function so that everyone gets them
-rw-r--r-- | libdbusmenu-gtk/parser.c | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index b6595f5..1092485 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -578,18 +578,6 @@ construct_dbusmenu_for_widget (GtkWidget * widget) if (GTK_IS_IMAGE (image)) { update_icon (mi, pdata, GTK_IMAGE_MENU_ITEM(widget), GTK_IMAGE (image)); - - /* Watch for theme changes because if gicon changes, we want to send a - different pixbuf. */ - pdata->theme_changed_sig = g_signal_connect(G_OBJECT(gtk_icon_theme_get_default()), - "changed", G_CALLBACK(theme_changed_cb), widget); - - pdata->image = image; - g_signal_connect (G_OBJECT (image), - "notify", - G_CALLBACK (image_notify_cb), - mi); - g_object_add_weak_pointer(G_OBJECT (image), (gpointer*)&pdata->image); } } @@ -755,6 +743,38 @@ update_icon (DbusmenuMenuitem *menuitem, ParserData * pdata, GtkImageMenuItem * GtkIconInfo * info; gint width; + /* Check to see if we're changing the image. If so, we need to track + that little bugger */ + /* Why check for gmenuitem being NULL? Because there are some cases where + we can't get it easily, and those mean it's not changed just the icon + underneith, so we can ignore these larger impacts */ + if (image != GTK_IMAGE(pdata->image) && gmenuitem != NULL) { + if (pdata->theme_changed_sig != 0) { + g_signal_handler_disconnect(gtk_icon_theme_get_default(), pdata->theme_changed_sig); + pdata->theme_changed_sig = 0; + } + + pdata->theme_changed_sig = g_signal_connect(G_OBJECT(gtk_icon_theme_get_default()), + "changed", G_CALLBACK(theme_changed_cb), gmenuitem); + + if (pdata->image != NULL) { + g_signal_handlers_disconnect_by_func(pdata->image, G_CALLBACK(image_notify_cb), menuitem); + g_object_remove_weak_pointer(G_OBJECT(pdata->image), (gpointer*)&pdata->image); + } + + pdata->image = GTK_WIDGET(image); + + if (pdata->image != NULL) { + pdata->theme_changed_sig = g_signal_connect(G_OBJECT(gtk_icon_theme_get_default()), + "changed", G_CALLBACK(theme_changed_cb), gmenuitem); + g_signal_connect (G_OBJECT (pdata->image), + "notify", + G_CALLBACK (image_notify_cb), + menuitem); + g_object_add_weak_pointer(G_OBJECT (pdata->image), (gpointer*)&pdata->image); + } + } + if (image != NULL && should_show_image (image)) { switch (gtk_image_get_storage_type (image)) { case GTK_IMAGE_EMPTY: |