changeset 14024:7109e6397a31

[gaim-migrate @ 16622] Add commands /accounts, /buddylist, /debugwin and /plugins. It allows the user to close those windows, and pop them back up when necessary -- provided a conversation window is open -- which I am assuming would be the case most of the time. Until there's some better way of accessing these dialogs (eg. menus), this is the only way. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Thu, 03 Aug 2006 07:16:35 +0000
parents 07d645986c79
children e1fd2a8bd40b
files console/gntaccount.c console/gntblist.c console/gntblist.h console/gntconv.c console/gntdebug.h console/gntplugin.c
diffstat 6 files changed, 100 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/console/gntaccount.c	Wed Aug 02 23:52:45 2006 +0000
+++ b/console/gntaccount.c	Thu Aug 03 07:16:35 2006 +0000
@@ -548,6 +548,13 @@
 	gaim_account_set_enabled(account, GAIM_GNT_UI, gnt_tree_get_choice(GNT_TREE(widget), key));
 }
 
+static void
+reset_accounts_win(GntWidget *widget, gpointer null)
+{
+	accounts.window = NULL;
+	accounts.tree = NULL;
+}
+
 void gg_accounts_show_all()
 {
 	GList *iter;
@@ -597,6 +604,8 @@
 	g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(delete_account_cb), accounts.tree);
 	
 	gnt_box_add_widget(GNT_BOX(accounts.window), box);
+
+	g_signal_connect(G_OBJECT(accounts.window), "destroy", G_CALLBACK(reset_accounts_win), NULL);
 	
 	gnt_widget_show(accounts.window);
 }
@@ -641,7 +650,8 @@
 
 void gg_accounts_uninit()
 {
-	gnt_widget_destroy(accounts.window);
+	if (accounts.window)
+		gnt_widget_destroy(accounts.window);
 }
 
 /* The following uiops stuff are copied from gtkaccount.c */
--- a/console/gntblist.c	Wed Aug 02 23:52:45 2006 +0000
+++ b/console/gntblist.c	Thu Aug 03 07:16:35 2006 +0000
@@ -66,7 +66,7 @@
 {
 	GGBlist *ggblist = list->ui_data;
 
-	if (node->ui_data == NULL)
+	if (ggblist == NULL || node->ui_data == NULL)
 		return;
 
 	gnt_tree_remove(GNT_TREE(ggblist->tree), node);
@@ -85,6 +85,9 @@
 static void
 node_update(GaimBuddyList *list, GaimBlistNode *node)
 {
+	if (list->ui_data == NULL)
+		return;
+
 	if (node->ui_data != NULL)
 	{
 		gnt_tree_change_text(GNT_TREE(ggblist->tree), node,
@@ -744,6 +747,40 @@
 	gaim_prefs_set_int(PREF_ROOT "/position/y", y);
 }
 
+static void
+reset_blist_window(GntWidget *window, gpointer null)
+{
+	GaimBlistNode *node;
+	gaim_signals_disconnect_by_handle(gg_blist_get_handle());
+	gaim_get_blist()->ui_data = NULL;
+
+	node = gaim_blist_get_root();
+	while (node)
+	{
+		node->ui_data = NULL;
+		node = gaim_blist_node_next(node, TRUE);
+	}
+		
+	remove_peripherals(ggblist);
+	g_free(ggblist);
+	ggblist = NULL;
+}
+
+static void
+populate_buddylist()
+{
+	GaimBlistNode *node;
+	GaimBuddyList *list;
+
+	list = gaim_get_blist();
+	node = gaim_blist_get_root();
+	while (node)
+	{
+		node_update(list, node);
+		node = gaim_blist_node_next(node, TRUE);
+	}
+}
+
 void gg_blist_init()
 {
 	gaim_prefs_add_none(PREF_ROOT);
@@ -754,6 +791,16 @@
 	gaim_prefs_add_int(PREF_ROOT "/position/x", 0);
 	gaim_prefs_add_int(PREF_ROOT "/position/y", 0);
 
+	gg_blist_show();
+
+	return;
+}
+
+void gg_blist_show()
+{
+	if (ggblist)
+		return;
+
 	ggblist = g_new0(GGBlist, 1);
 
 	gaim_get_blist()->ui_data = ggblist;
@@ -805,11 +852,16 @@
 				ggblist, 0, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
 	g_signal_connect(G_OBJECT(ggblist->tree), "size_changed", G_CALLBACK(size_changed_cb), NULL);
 	g_signal_connect(G_OBJECT(ggblist->window), "position_set", G_CALLBACK(save_position_cb), NULL);
+	g_signal_connect(G_OBJECT(ggblist->window), "destroy", G_CALLBACK(reset_blist_window), NULL);
 
+	populate_buddylist();
 }
 
 void gg_blist_uninit()
 {
+	if (ggblist == NULL)
+		return;
+
 	gnt_widget_destroy(ggblist->window);
 	g_free(ggblist);
 	ggblist = NULL;
--- a/console/gntblist.h	Wed Aug 02 23:52:45 2006 +0000
+++ b/console/gntblist.h	Thu Aug 03 07:16:35 2006 +0000
@@ -6,6 +6,8 @@
 
 void gg_blist_uninit();
 
+void gg_blist_show();
+
 void gg_blist_get_position(int *x, int *y);
 
 void gg_blist_set_position(int x, int y);
--- a/console/gntconv.c	Wed Aug 02 23:52:45 2006 +0000
+++ b/console/gntconv.c	Thu Aug 03 07:16:35 2006 +0000
@@ -5,8 +5,11 @@
 #include <util.h>
 
 #include "gntgaim.h"
+#include "gntaccount.h"
 #include "gntblist.h"
 #include "gntconv.h"
+#include "gntdebug.h"
+#include "gntplugin.h"
 
 #include "gnt.h"
 #include "gntbox.h"
@@ -478,6 +481,13 @@
 	return GAIM_CMD_STATUS_OK;
 }
 
+static GaimCmdRet
+cmd_show_window(GaimConversation *conv, const char *cmd, char **args, char **error, gpointer data)
+{
+	void (*callback)() = data;
+	callback();
+	return GAIM_CMD_STATUS_OK;
+}
 
 void gg_conversation_init()
 {
@@ -507,6 +517,20 @@
 	gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT,
 	                  GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL,
 	                  help_command_cb, _("help &lt;command&gt;:  Help on a specific command."), NULL);
+
+	/* Now some commands to bring up some other windows */
+	gaim_cmd_register("plugins", "", GAIM_CMD_P_DEFAULT,
+	                  GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL,
+	                  cmd_show_window, _("plugins: Show the plugins window."), gg_plugins_show_all);
+	gaim_cmd_register("buddylist", "", GAIM_CMD_P_DEFAULT,
+	                  GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL,
+	                  cmd_show_window, _("buddylist: Show the buddylist."), gg_blist_show);
+	gaim_cmd_register("accounts", "", GAIM_CMD_P_DEFAULT,
+	                  GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL,
+	                  cmd_show_window, _("accounts: Show the accounts window."), gg_accounts_show_all);
+	gaim_cmd_register("debugwin", "", GAIM_CMD_P_DEFAULT,
+	                  GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL,
+	                  cmd_show_window, _("debugwin: Show the debug window."), gg_debug_window_show);
 }
 
 void gg_conversation_uninit()
--- a/console/gntdebug.h	Wed Aug 02 23:52:45 2006 +0000
+++ b/console/gntdebug.h	Thu Aug 03 07:16:35 2006 +0000
@@ -6,3 +6,4 @@
 
 void gg_debug_uninit();
 
+void gg_debug_window_show();
--- a/console/gntplugin.c	Wed Aug 02 23:52:45 2006 +0000
+++ b/console/gntplugin.c	Thu Aug 03 07:16:35 2006 +0000
@@ -70,6 +70,14 @@
 	gnt_text_view_scroll(GNT_TEXT_VIEW(plugins.aboot), 0);
 }
 
+static void
+reset_plugin_window(GntWidget *window, gpointer null)
+{
+	plugins.window = NULL;
+	plugins.tree = NULL;
+	plugins.aboot = NULL;
+}
+
 void gg_plugins_show_all()
 {
 	GntWidget *window, *tree, *box, *aboot;
@@ -118,6 +126,7 @@
 	gnt_tree_set_col_width(GNT_TREE(tree), 0, 30);
 	g_signal_connect(G_OBJECT(tree), "toggled", G_CALLBACK(plugin_toggled_cb), NULL);
 	g_signal_connect(G_OBJECT(tree), "selection_changed", G_CALLBACK(selection_changed), NULL);
+	g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(reset_plugin_window), NULL);
 
 	gnt_widget_show(window);
 }