# HG changeset patch # User Sadrul Habib Chowdhury # Date 1155748236 0 # Node ID 5b9daf111b42dbaf7ffcc8c0c6b135bd488b637b # Parent 6a19a83ed49f4f1c37d18237c1e737d48fbb856f [gaim-migrate @ 16793] Handle the plugin-pref windows better. committer: Tailor Script diff -r 6a19a83ed49f -r 5b9daf111b42 console/gntplugin.c --- a/console/gntplugin.c Wed Aug 16 16:53:20 2006 +0000 +++ b/console/gntplugin.c Wed Aug 16 17:10:36 2006 +0000 @@ -18,6 +18,8 @@ GntWidget *conf; } plugins; +static GHashTable *confwins; + static void decide_conf_button(GaimPlugin *plugin) { @@ -44,8 +46,15 @@ } else { + GntWidget *win; + if (!gaim_plugin_unload(plugin)) gaim_notify_error(NULL, "ERROR", "unloading plugin failed", NULL); + + if ((win = g_hash_table_lookup(confwins, plugin)) != NULL) + { + gnt_widget_destroy(win); + } } decide_conf_button(plugin); gg_plugins_save_loaded(); @@ -111,6 +120,18 @@ } static void +confwin_init() +{ + confwins = g_hash_table_new(g_direct_hash, g_direct_equal); +} + +static void +remove_confwin(GntWidget *window, gpointer plugin) +{ + g_hash_table_remove(confwins, plugin); +} + +static void configure_plugin_cb(GntWidget *button, gpointer null) { GaimPlugin *plugin; @@ -126,6 +147,9 @@ return; } + if (confwins && g_hash_table_lookup(confwins, plugin)) + return; + if (GAIM_IS_GNT_PLUGIN(plugin) && (callback = GAIM_GNT_PLUGIN_UI_INFO(plugin)) != NULL) { @@ -146,8 +170,13 @@ gnt_box_add_widget(GNT_BOX(box), button); g_signal_connect_swapped(G_OBJECT(button), "activate", G_CALLBACK(gnt_widget_destroy), window); + g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(remove_confwin), plugin); - gnt_widget_show(window); /* XXX: This window needs to be closed when the plugin is unloaded */ + gnt_widget_show(window); + + if (confwins == NULL) + confwin_init(); + g_hash_table_insert(confwins, plugin, window); } else if (plugin->info->prefs_info && plugin->info->prefs_info->get_plugin_pref_frame)