diff src/gtkblist.c @ 9754:4a8bf81b82ae

[gaim-migrate @ 10621] " This will default the room/server fields to the proper values when an add chat is requested from a conversation window. It wasn't quite as trivial as the reporter suggested..." --Nathan (noif) Fredrickson committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Sun, 15 Aug 2004 19:34:20 +0000
parents 60705fd4f411
children 41f302d41839
line wrap: on
line diff
--- a/src/gtkblist.c	Sun Aug 15 17:05:51 2004 +0000
+++ b/src/gtkblist.c	Sun Aug 15 19:34:20 2004 +0000
@@ -75,6 +75,7 @@
 typedef struct
 {
     GaimAccount *account;
+    const char *default_chat_name;
 
     GtkWidget *window;
 	GtkWidget *account_menu;
@@ -949,14 +950,14 @@
 	if(gtk_tree_selection_get_selected(sel, NULL, &iter)){
 		gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1);
 		if (GAIM_BLIST_NODE_IS_BUDDY(node))
-			gaim_blist_request_add_chat(NULL, (GaimGroup*)node->parent->parent, NULL);
+			gaim_blist_request_add_chat(NULL, (GaimGroup*)node->parent->parent, NULL, NULL);
 		if (GAIM_BLIST_NODE_IS_CONTACT(node) || GAIM_BLIST_NODE_IS_CHAT(node))
-			gaim_blist_request_add_chat(NULL, (GaimGroup*)node->parent, NULL);
+			gaim_blist_request_add_chat(NULL, (GaimGroup*)node->parent, NULL, NULL);
 		else if (GAIM_BLIST_NODE_IS_GROUP(node))
-			gaim_blist_request_add_chat(NULL, (GaimGroup*)node, NULL);
+			gaim_blist_request_add_chat(NULL, (GaimGroup*)node, NULL, NULL);
 	}
 	else {
-		gaim_blist_request_add_chat(NULL, NULL, NULL);
+		gaim_blist_request_add_chat(NULL, NULL, NULL, NULL);
 	}
 }
 
@@ -4143,6 +4144,7 @@
 {
 	GaimConnection *gc;
 	GList *list, *tmp;
+	GHashTable *defaults = NULL;
 	struct proto_chat_entry *pce;
 	gboolean focus = TRUE;
 
@@ -4161,6 +4163,10 @@
 
 	list = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info(gc);
 
+	if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults != NULL)
+		defaults = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc,
+					data->default_chat_name);
+
 	for (tmp = list; tmp; tmp = tmp->next)
 	{
 		GtkWidget *label;
@@ -4194,11 +4200,15 @@
 		else
 		{
 			GtkWidget *entry = gtk_entry_new();
+			char *value;
 
 			g_object_set_data(G_OBJECT(entry), "identifier", pce->identifier);
 			data->entries = g_list_append(data->entries, entry);
 
-			if (pce->def)
+			value = g_hash_table_lookup(defaults, pce->identifier);
+			if (value != NULL)
+				gtk_entry_set_text(GTK_ENTRY(entry), value);
+			else if (pce->def)
 				gtk_entry_set_text(GTK_ENTRY(entry), pce->def);
 
 			if (focus)
@@ -4222,6 +4232,7 @@
 	}
 
 	g_list_free(list);
+	g_hash_table_destroy(defaults);
 
 	gtk_widget_show_all(data->entries_box);
 }
@@ -4252,7 +4263,7 @@
 
 void
 gaim_gtk_blist_request_add_chat(GaimAccount *account, GaimGroup *group,
-								const char *alias)
+								const char *alias, const char *name)
 {
 	GaimGtkAddChatData *data;
 	GaimGtkBuddyList *gtkblist;
@@ -4271,6 +4282,8 @@
 
 	gtkblist = GAIM_GTK_BLIST(gaim_get_blist());
 
+	data->default_chat_name = name;
+
 	if (account != NULL)
 	{
 		data->account = account;