changeset 8352:77baefe979c6

[gaim-migrate @ 9076] this compiles, and I don't think it breaks anything, so here's /list support, again from our patient friend marv committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Fri, 27 Feb 2004 01:48:11 +0000
parents ffa642240fc1
children 8ae61bbc479f
files src/gtkroomlist.c src/gtkroomlist.h src/protocols/irc/cmds.c src/protocols/irc/irc.c src/roomlist.c src/roomlist.h
diffstat 6 files changed, 54 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkroomlist.c	Fri Feb 27 01:45:26 2004 +0000
+++ b/src/gtkroomlist.c	Fri Feb 27 01:48:11 2004 +0000
@@ -343,29 +343,28 @@
 	gtk_container_add(GTK_CONTAINER(vbox), vbox2);
 	gtk_widget_show(vbox2);
 
-	/* accounts dropdown list */
-	if (!account) {
-		account_hbox = gtk_hbox_new(FALSE, 0);
-		gtk_box_pack_start(GTK_BOX(vbox2), account_hbox, FALSE, FALSE, 0);
-		gtk_widget_show(account_hbox);
 
+	if (!account)
 		dialog->account = first_account;
-		label = gtk_label_new(NULL);
-		gtk_box_pack_start(GTK_BOX(account_hbox), label, TRUE, TRUE, 0);
-		gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Account:"));
-		gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
-		gtk_widget_show(label);
+	else
+		dialog->account = account;
+	/* accounts dropdown list */
+	account_hbox = gtk_hbox_new(FALSE, 0);
+	gtk_box_pack_start(GTK_BOX(vbox2), account_hbox, FALSE, FALSE, 0);
+	gtk_widget_show(account_hbox);
 
-		dialog->account_widget = gaim_gtk_account_option_menu_new(first_account, FALSE,
-				G_CALLBACK(dialog_select_account_cb), accounts_filter_func, dialog);
+	label = gtk_label_new(NULL);
+	gtk_box_pack_start(GTK_BOX(account_hbox), label, TRUE, TRUE, 0);
+	gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Account:"));
+	gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
+	gtk_widget_show(label);
 
-		gtk_box_pack_start(GTK_BOX(account_hbox), dialog->account_widget, TRUE, TRUE, 0);
-		gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(dialog->account_widget));
-		gtk_widget_show(dialog->account_widget);
+	dialog->account_widget = gaim_gtk_account_option_menu_new(dialog->account, FALSE,
+	                         G_CALLBACK(dialog_select_account_cb), accounts_filter_func, dialog);
 
-	} else {
-		dialog->account = account;
-	}
+	gtk_box_pack_start(GTK_BOX(account_hbox), dialog->account_widget, TRUE, TRUE, 0);
+	gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(dialog->account_widget));
+	gtk_widget_show(dialog->account_widget);
 
 	/* scrolled window */
 	dialog->sw = gtk_scrolled_window_new(NULL, NULL);
@@ -434,6 +433,17 @@
 	return gaim_gtk_roomlist_dialog_new_with_account(NULL);
 }
 
+static void gaim_gtk_roomlist_dialog_show_with_account(GaimAccount *account)
+{
+	GaimGtkRoomlistDialog *dialog;
+
+	dialog = gaim_gtk_roomlist_dialog_new_with_account(account);
+	if (!dialog)
+		return;
+
+	list_button_cb(GTK_BUTTON(dialog->list_button), dialog);
+}
+
 void gaim_gtk_roomlist_dialog_show(void)
 {
 	gaim_gtk_roomlist_dialog_new();
@@ -701,6 +711,7 @@
 }
 
 static GaimRoomlistUiOps ops = {
+	gaim_gtk_roomlist_dialog_show_with_account,
 	gaim_gtk_roomlist_new,
 	gaim_gtk_roomlist_set_fields,
 	gaim_gtk_roomlist_add_room,
--- a/src/gtkroomlist.h	Fri Feb 27 01:45:26 2004 +0000
+++ b/src/gtkroomlist.h	Fri Feb 27 01:48:11 2004 +0000
@@ -45,7 +45,8 @@
 GaimGtkRoomlistDialog *gaim_gtk_roomlist_dialog_new(void);
 
 /**
- * Create a new room list dialog with no account selector.
+ * Create a new room list dialog and fetch the list on
+ * the specified account.
  *
  * @param account The account to force.
  * @return The new dialog.
--- a/src/protocols/irc/cmds.c	Fri Feb 27 01:45:26 2004 +0000
+++ b/src/protocols/irc/cmds.c	Fri Feb 27 01:48:11 2004 +0000
@@ -206,11 +206,7 @@
 
 int irc_cmd_list(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
 {
-	char *buf;
-
-	buf = irc_format(irc, "v", "LIST");
-	irc_send(irc, buf);
-	g_free(buf);
+	gaim_roomlist_show_with_account(irc->account);
 
 	return 0;
 }
--- a/src/protocols/irc/irc.c	Fri Feb 27 01:45:26 2004 +0000
+++ b/src/protocols/irc/irc.c	Fri Feb 27 01:48:11 2004 +0000
@@ -488,6 +488,7 @@
 	struct irc_conn *irc;
 	GList *fields = NULL;
 	GaimRoomlistField *f;
+	char *buf;
 
 	irc = gc->proto_data;
 
@@ -507,7 +508,9 @@
 
 	gaim_roomlist_set_fields(irc->roomlist, fields);
 
-	irc_cmd_list(irc, "LIST", NULL, NULL);
+	buf = irc_format(irc, "v", "LIST");
+	irc_send(irc, buf);
+	g_free(buf);
 
 	return irc->roomlist;
 }
--- a/src/roomlist.c	Fri Feb 27 01:45:26 2004 +0000
+++ b/src/roomlist.c	Fri Feb 27 01:48:11 2004 +0000
@@ -39,6 +39,12 @@
 /**************************************************************************/
 /*@{*/
 
+void gaim_roomlist_show_with_account(GaimAccount *account)
+{
+	if (ops && ops->show_with_account)
+		ops->show_with_account(account);
+}
+
 GaimRoomlist *gaim_roomlist_new(GaimAccount *account)
 {
 	GaimRoomlist *list;
--- a/src/roomlist.h	Fri Feb 27 01:45:26 2004 +0000
+++ b/src/roomlist.h	Fri Feb 27 01:48:11 2004 +0000
@@ -94,6 +94,7 @@
  * The room list ops to be filled out by the UI.
  */
 struct _GaimRoomlistUiOps {
+	void (*show_with_account)(GaimAccount *account); /**< Force the ui to pop up a dialog and get the list */
 	void (*new)(GaimRoomlist *list); /**< A new list was created. */
 	void (*set_fields)(GaimRoomlist *list, GList *fields); /**< Sets the columns. */
 	void (*add_room)(GaimRoomlist *list, GaimRoomlistRoom *room); /**< Add a room to the list. */
@@ -112,6 +113,17 @@
 /*@{*/
 
 /**
+ * This is used to get the room list on an account, asking the UI
+ * to pop up a dialog with the specified account already selected,
+ * and pretend the user clicked the get list button.
+ * While we're pretending, predend I didn't say anything about dialogs
+ * or buttons, since this is the core.
+ *
+ * @param account The account to get the list on.
+ */
+void gaim_roomlist_show_with_account(GaimAccount *account);
+
+/**
  * Returns a newly created room list object.
  *
  * It has an inital reference count of 1.