diff src/buddy_chat.c @ 2205:cff4fbe01c7b

[gaim-migrate @ 2215] eric@blue:~/gaim/app/src/protocols $ cat gtk for i in icq irc jabber msn napster oscar toc yahoo zephyr do echo -n $i: grep -i g\[td\]k $i/*.c | wc -l done eric@blue:~/gaim/app/src/protocols $ ./gtk icq: 13 irc: 0 jabber: 59 msn: 0 napster: 106 oscar: 13 toc: 25 yahoo: 15 zephyr: 2 committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Fri, 31 Aug 2001 20:36:11 +0000
parents e8e2a72a37b7
children 9b3262a2f7c4
line wrap: on
line diff
--- a/src/buddy_chat.c	Fri Aug 31 18:09:27 2001 +0000
+++ b/src/buddy_chat.c	Fri Aug 31 20:36:11 2001 +0000
@@ -41,11 +41,11 @@
 
 GtkWidget *joinchat;
 static struct gaim_connection *joinchatgc;
-static GtkWidget *entry;
 static GtkWidget *invite;
 static GtkWidget *inviteentry;
 static GtkWidget *invitemess;
 static GtkWidget *jc_vbox = NULL;
+static GList *chatentries = NULL;
 extern int state_lock;
 
 GList *chats = NULL;
@@ -53,16 +53,6 @@
 GtkWidget *chat_notebook = NULL;
 
 
-static void destroy_prev_jc()
-{
-	if (!jc_vbox)
-		return;
-
-	while (GTK_BOX(jc_vbox)->children)
-		gtk_container_remove(GTK_CONTAINER(jc_vbox),
-				     ((GtkBoxChild *)GTK_BOX(jc_vbox)->children->data)->widget);
-}
-
 static void destroy_join_chat()
 {
 	if (joinchat)
@@ -81,47 +71,94 @@
 void do_join_chat()
 {
 	if (joinchat) {
-		if (joinchatgc->prpl->draw_join_chat)
-			serv_join_chat(joinchatgc, 0, NULL);
-		else
-			serv_join_chat(joinchatgc, 0, gtk_entry_get_text(GTK_ENTRY(entry)));
+		GList *data = NULL;
+		GList *tmp = chatentries;
+		int *ival;
+		char *sval;
+		while (tmp) {
+			if (gtk_object_get_user_data(tmp->data)) {
+				ival = g_new0(int, 1);
+				*ival = gtk_spin_button_get_value_as_int(tmp->data);
+				data = g_list_append(data, ival);
+			} else {
+				sval = g_strdup(gtk_entry_get_text(tmp->data));
+				data = g_list_append(data, sval);
+			}
+			tmp = tmp->next;
+		}
+		serv_join_chat(joinchatgc, data);
+
+		tmp = data;
+		while (tmp) {
+			g_free(tmp->data);
+			tmp = tmp->next;
+		}
+		g_list_free(data);
+
 		gtk_widget_destroy(joinchat);
+		if (chatentries)
+			g_list_free(chatentries);
+		chatentries = NULL;
 	}
 	joinchat = NULL;
 }
 
-static void default_draw_join_chat(struct gaim_connection *gc, GtkWidget *fbox) {
-	GtkWidget *label;
-	GtkWidget *rowbox;
-
-	if (!joinchat || !fbox)
-		return;
-	
-	rowbox = gtk_hbox_new(FALSE, 5);
-	gtk_box_pack_start(GTK_BOX(fbox), rowbox, TRUE, TRUE, 0);
-	gtk_widget_show(rowbox);
-
-	label = gtk_label_new(_("Join what group:"));
-	gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0);
-	gtk_widget_show(label);
-
-	entry = gtk_entry_new();
-	gtk_box_pack_start(GTK_BOX(rowbox), entry, TRUE, TRUE, 0);
-	gtk_widget_grab_focus(entry);
-	gtk_signal_connect(GTK_OBJECT(entry), "activate", GTK_SIGNAL_FUNC(do_join_chat), NULL);
-	gtk_widget_show(entry);
-}
-
 static void rebuild_jc()
 {
+	GList *list, *tmp;
+	struct proto_chat_entry *pce;
+
 	if (!joinchatgc)
 		return;
 
-	destroy_prev_jc();
-	if (joinchatgc->prpl->draw_join_chat)
-		(*joinchatgc->prpl->draw_join_chat)(joinchatgc, jc_vbox);
-	else
-		default_draw_join_chat(joinchatgc, jc_vbox);
+	while (GTK_BOX(jc_vbox)->children)
+		gtk_container_remove(GTK_CONTAINER(jc_vbox),
+				     ((GtkBoxChild *)GTK_BOX(jc_vbox)->children->data)->widget);
+	if (chatentries)
+		g_list_free(chatentries);
+	chatentries = NULL;
+
+	tmp = list = (*joinchatgc->prpl->chat_info)(joinchatgc);
+	while (list) {
+		GtkWidget *label;
+		GtkWidget *rowbox;
+		pce = list->data;
+
+		rowbox = gtk_hbox_new(FALSE, 5);
+		gtk_box_pack_start(GTK_BOX(jc_vbox), rowbox, TRUE, TRUE, 0);
+		gtk_widget_show(rowbox);
+
+		label = gtk_label_new(pce->label);
+		gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0);
+		gtk_widget_show(label);
+
+		if (pce->is_int) {
+			GtkObject *adjust;
+			GtkWidget *spin;
+			adjust = gtk_adjustment_new(pce->min, pce->min, pce->max, 1, 10, 10);
+			spin = gtk_spin_button_new(GTK_ADJUSTMENT(adjust), 1, 0);
+			gtk_object_set_user_data(GTK_OBJECT(spin), (void *)1);
+			chatentries = g_list_append(chatentries, spin);
+			gtk_widget_set_usize(spin, 50, -1);
+			gtk_box_pack_start(GTK_BOX(rowbox), spin, FALSE, FALSE, 0);
+			gtk_widget_show(spin);
+		} else {
+			GtkWidget *entry;
+			entry = gtk_entry_new();
+			chatentries = g_list_append(chatentries, entry);
+			gtk_box_pack_start(GTK_BOX(rowbox), entry, TRUE, TRUE, 0);
+			if (pce->def)
+				gtk_entry_set_text(GTK_ENTRY(entry), pce->def);
+			gtk_widget_grab_focus(entry);
+			gtk_signal_connect(GTK_OBJECT(entry), "activate",
+					   GTK_SIGNAL_FUNC(do_join_chat), NULL);
+			gtk_widget_show(entry);
+		}
+
+		g_free(pce);
+		list = list->next;
+	}
+	g_list_free(tmp);
 }
 
 static void joinchat_choose(GtkWidget *w, struct gaim_connection *g)