changeset 14148:5b9daf111b42

[gaim-migrate @ 16793] Handle the plugin-pref windows better. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Wed, 16 Aug 2006 17:10:36 +0000
parents 6a19a83ed49f
children d994f64248ef
files console/gntplugin.c
diffstat 1 files changed, 30 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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)