Index: src/gaim-xmms-remote.c =================================================================== RCS file: /cvsroot/guifications/gaim-xmms-remote/src/gaim-xmms-remote.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -p -r1.25 -r1.26 --- src/gaim-xmms-remote.c 6 Sep 2004 01:05:51 -0000 1.25 +++ src/gaim-xmms-remote.c 11 Oct 2004 14:14:22 -0000 1.26 @@ -47,10 +47,10 @@ #define GXR_STOCK_STOP "gxr-stop" #define GXR_STOCK_XMMS "gxr-xmms" -static GList *buttons; +static GList *buttons = NULL; static GtkIconFactory *icon_factory; -static guint button_type_cb_id, im_button_show_cb_id, chat_button_show_cb_id; static GaimCmdId gxr_cmd; +static guint button_type_cb_id; static void gxr_menu_play_cb(GtkMenuItem *item, gpointer data) { @@ -467,7 +467,7 @@ gxr_button_type_changed_cb(const char *n GaimConversation *conv; GaimGtkConversation *gtkconv; GtkWidget *button; - GList *l; + GList *l, *tmp = NULL; for(l = buttons; l != NULL; l = l->next) { button = GTK_WIDGET(l->data); @@ -483,7 +483,10 @@ gxr_button_type_changed_cb(const char *n gtk_size_group_add_widget(gtkconv->sg, button); gtk_widget_show(button); g_object_set_data(G_OBJECT(button), "conv", conv); + tmp = g_list_append(tmp, (gpointer)button); } + g_list_free(buttons); + buttons = tmp; } static void @@ -501,17 +504,34 @@ gxr_popup_cb(GtkWidget *w, GtkMenu *menu gtk_widget_show(item); } +void +gxr_disconnect_popup_cb(GaimConversation *conv) { + GaimGtkConversation *gtkconv; + gulong handle; + + if((gtkconv = GAIM_GTK_CONVERSATION(conv)) == NULL) + return; + + if((handle = (gulong)gaim_conversation_get_data(conv, "gxr-popup-handle")) == 0) + return; + + g_signal_handler_disconnect(G_OBJECT(gtkconv->entry), handle); +} + static void gxr_conv_created_cb(GaimConversation *conv, gpointer data) { GaimGtkConversation *gtkconv; + gulong handle; if((gtkconv = GAIM_GTK_CONVERSATION(conv)) == NULL) return; gxr_add_button(conv); - g_signal_connect(G_OBJECT(gtkconv->entry), "populate-popup", - G_CALLBACK(gxr_popup_cb), (gpointer)conv); + handle = g_signal_connect(G_OBJECT(gtkconv->entry), "populate-popup", + G_CALLBACK(gxr_popup_cb), (gpointer)conv); + + gaim_conversation_set_data(conv, "gxr-popup-handle", (gpointer)handle); } static void @@ -519,6 +539,7 @@ gxr_hook_popups() { GList *wins, *convs; GaimConvWindow *window; GaimConversation *conv; + gulong handle; for(wins = gaim_get_windows(); wins; wins = wins->next) { window = (GaimConvWindow *)wins->data; @@ -527,9 +548,10 @@ gxr_hook_popups() { convs = convs->next) { conv = (GaimConversation *)convs->data; - g_signal_connect(G_OBJECT(GAIM_GTK_CONVERSATION(conv)->entry), + handle = g_signal_connect(G_OBJECT(GAIM_GTK_CONVERSATION(conv)->entry), "populate-popup", G_CALLBACK(gxr_popup_cb), conv); + gaim_conversation_set_data(conv, "gxr-popup-handle", (gpointer)handle); } } } @@ -781,13 +803,11 @@ gxr_load(GaimPlugin *plugin) { "/gaim/gtk/conversations/button_type", gxr_button_type_changed_cb, NULL); - im_button_show_cb_id = gaim_prefs_connect_callback( - "/plugins/gtk/amc_grim/gaim-xmms-remote/im", - gxr_im_button_show_cb, NULL); + gaim_prefs_connect_callback("/plugins/gtk/amc_grim/gaim-xmms-remote/im", + gxr_im_button_show_cb, NULL); - chat_button_show_cb_id = gaim_prefs_connect_callback( - "/plugins/gtk/amc_grim/gaim-xmms-remote/chat", - gxr_chat_button_show_cb, NULL); + gaim_prefs_connect_callback("/plugins/gtk/amc_grim/gaim-xmms-remote/chat", + gxr_chat_button_show_cb, NULL); if(gaim_prefs_get_bool("/plugins/gtk/amc_grim/gaim-xmms-remote/im")) gxr_show_buttons(GAIM_CONV_IM); @@ -807,11 +827,17 @@ gxr_load(GaimPlugin *plugin) { } static gboolean -gxr_unload() { +gxr_unload(GaimPlugin *plugin) { gaim_prefs_disconnect_callback(button_type_cb_id); + /* remove our buttons */ + gxr_hide_buttons(GAIM_CONV_IM); + gxr_hide_buttons(GAIM_CONV_CHAT); + g_list_free(buttons); + /* remove our popup menu item */ + gaim_conversation_foreach(gxr_disconnect_popup_cb); /* remove our icons */ gtk_icon_factory_remove_default(icon_factory); @@ -821,7 +847,7 @@ gxr_unload() { return TRUE; } -static void +static void init_plugin(GaimPlugin *plugin) { gaim_prefs_add_none("/plugins/gtk/amc_grim"); gaim_prefs_add_none("/plugins/gtk/amc_grim/gaim-xmms-remote");