changeset 9770:41f302d41839

[gaim-migrate @ 10638] (22:52:45) noif: LSchiere: one last addition to my chat-info-defaults patch... this removes the old defaulting mechanism which only jabber used and accomplishes the same thing through the new defaulting mechanism. It also changes the "Group" to "Room" for oscar chats to avoid having two fields labelled "Group". committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Tue, 17 Aug 2004 02:52:13 +0000
parents 6be50545eed7
children 9812dde4323e
files src/gtkblist.c src/protocols/jabber/chat.c src/protocols/oscar/oscar.c src/prpl.h
diffstat 4 files changed, 18 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkblist.c	Tue Aug 17 00:50:20 2004 +0000
+++ b/src/gtkblist.c	Tue Aug 17 02:52:13 2004 +0000
@@ -660,6 +660,7 @@
 {
 	GaimConnection *gc;
 	GList *list, *tmp;
+	GHashTable *defaults = NULL;
 	struct proto_chat_entry *pce;
 	gboolean focus = TRUE;
 
@@ -678,6 +679,9 @@
 
 	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, NULL);
+
 	for (tmp = list; tmp; tmp = tmp->next)
 	{
 		GtkWidget *label;
@@ -712,13 +716,15 @@
 		else
 		{
 			GtkWidget *entry = gtk_entry_new();
+			char *value;
 
 			gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
 			g_object_set_data(G_OBJECT(entry), "identifier", pce->identifier);
 			data->entries = g_list_append(data->entries, entry);
 
-			if (pce->def)
-				gtk_entry_set_text(GTK_ENTRY(entry), pce->def);
+			value = g_hash_table_lookup(defaults, pce->identifier);
+			if (value != NULL)
+				gtk_entry_set_text(GTK_ENTRY(entry), value);
 
 			if (focus)
 			{
@@ -4208,8 +4214,6 @@
 			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)
 			{
--- a/src/protocols/jabber/chat.c	Tue Aug 17 00:50:20 2004 +0000
+++ b/src/protocols/jabber/chat.c	Tue Aug 17 02:52:13 2004 +0000
@@ -36,7 +36,6 @@
 {
 	GList *m = NULL;
 	struct proto_chat_entry *pce;
-	JabberStream *js = gc->proto_data;
 
 	pce = g_new0(struct proto_chat_entry, 1);
 	pce->label = _("_Room:");
@@ -46,13 +45,11 @@
 	pce = g_new0(struct proto_chat_entry, 1);
 	pce->label = _("_Server:");
 	pce->identifier = "server";
-	pce->def = js->chat_servers ? js->chat_servers->data : "conference.jabber.org";
 	m = g_list_append(m, pce);
 
 	pce = g_new0(struct proto_chat_entry, 1);
 	pce->label = _("_Handle:");
 	pce->identifier = "handle";
-	pce->def = js->user->node;
 	m = g_list_append(m, pce);
 
 	pce = g_new0(struct proto_chat_entry, 1);
@@ -67,15 +64,23 @@
 GHashTable *jabber_chat_info_defaults(GaimConnection *gc, const char *chat_name)
 {
 	GHashTable *defaults;
+	JabberStream *js = gc->proto_data;
 
 	defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
 
+	g_hash_table_insert(defaults, "handle", g_strdup(js->user->node));
+
+	if (js->chat_servers)
+		g_hash_table_insert(defaults, "server", g_strdup(js->chat_servers->data));
+	else
+		g_hash_table_insert(defaults, "server", g_strdup("conference.jabber.org"));
+
 	if (chat_name != NULL) {
 		JabberID *jid = jabber_id_new(chat_name);
 		if(jid) {
 			g_hash_table_insert(defaults, "room", g_strdup(jid->node));
 			if(jid->domain)
-				g_hash_table_insert(defaults, "server", g_strdup(jid->domain));
+				g_hash_table_replace(defaults, "server", g_strdup(jid->domain));
 			jabber_id_free(jid);
 		}
 	}
--- a/src/protocols/oscar/oscar.c	Tue Aug 17 00:50:20 2004 +0000
+++ b/src/protocols/oscar/oscar.c	Tue Aug 17 02:52:13 2004 +0000
@@ -6209,7 +6209,7 @@
 	struct proto_chat_entry *pce;
 
 	pce = g_new0(struct proto_chat_entry, 1);
-	pce->label = _("_Group:");
+	pce->label = _("_Room:");
 	pce->identifier = "room";
 	m = g_list_append(m, pce);
 
--- a/src/prpl.h	Tue Aug 17 00:50:20 2004 +0000
+++ b/src/prpl.h	Tue Aug 17 02:52:13 2004 +0000
@@ -98,7 +98,6 @@
 struct proto_chat_entry {
 	char *label;
 	char *identifier;
-	char *def;
 	gboolean is_int;
 	int min;
 	int max;