changeset 20029:51aff4db29da

merge of '15e090cc3c5ac0e910b83a17267afbabea78ef86' and '6d38e424cdf835b16ceeb7b90f893db804540ff3'
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Fri, 14 Sep 2007 08:31:50 +0000
parents bef95e866af8 (current diff) a2b4eac83902 (diff)
children faf39a913c61 cd2b19529dff
files ChangeLog ChangeLog.API
diffstat 10 files changed, 134 insertions(+), 88 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Sep 14 08:10:00 2007 +0000
+++ b/ChangeLog	Fri Sep 14 08:31:50 2007 +0000
@@ -1,6 +1,6 @@
 Pidgin and Finch: The Pimpin' Penguin IM Clients That're Good for the Soul
 
-version 2.2.0 (09/13/2007):
+Version 2.2.0 (09/13/2007):
 	http://developer.pidgin.im/query?status=closed&milestone=2.2.0
 
 	Libpurple:
--- a/ChangeLog.API	Fri Sep 14 08:10:00 2007 +0000
+++ b/ChangeLog.API	Fri Sep 14 08:31:50 2007 +0000
@@ -37,6 +37,8 @@
 		* pidgin_conv_attach_to_conversation, to reattach the Pidgin UI to a
 		  conversation
 		* conversation-hiding and conversation-displayed signals.
+		* pidgin_text_combo_box_entry_new, pidgin_text_combo_box_entry_get_text
+		  and pidgin_text_combo_box_entry_set_text
 
 		Changed:
 		* pidgin_conversations_fill_menu now also adds a separator and a 'Show
--- a/pidgin/gtkblist.c	Fri Sep 14 08:10:00 2007 +0000
+++ b/pidgin/gtkblist.c	Fri Sep 14 08:31:50 2007 +0000
@@ -124,6 +124,7 @@
 #endif
 static PidginBuddyList *gtkblist = NULL;
 
+static GList *groups_tree(void);
 static gboolean pidgin_blist_refresh_timer(PurpleBuddyList *list);
 static void pidgin_blist_update_buddy(PurpleBuddyList *list, PurpleBlistNode *node, gboolean status_change);
 static void pidgin_blist_selection_changed(GtkTreeSelection *selection, gpointer data);
@@ -5357,15 +5358,17 @@
 static GList *
 groups_tree(void)
 {
-	GList *tmp = NULL;
+	static GList *list = NULL;
 	char *tmp2;
 	PurpleGroup *g;
 	PurpleBlistNode *gnode;
 
+	g_list_free(list);
+	list = NULL;
+
 	if (purple_get_blist()->root == NULL)
 	{
-		tmp2 = g_strdup(_("Buddies"));
-		tmp  = g_list_append(tmp, tmp2);
+		list  = g_list_append(list, (gpointer)_("Buddies"));
 	}
 	else
 	{
@@ -5377,12 +5380,12 @@
 			{
 				g    = (PurpleGroup *)gnode;
 				tmp2 = g->name;
-				tmp  = g_list_append(tmp, tmp2);
+				list  = g_list_append(list, tmp2);
 			}
 		}
 	}
 
-	return tmp;
+	return list;
 }
 
 static void
@@ -5411,7 +5414,7 @@
 	if (resp == GTK_RESPONSE_OK)
 	{
 		who = gtk_entry_get_text(GTK_ENTRY(data->entry));
-		grp = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(data->combo)->entry));
+		grp = pidgin_text_combo_box_entry_get_text(data->combo);
 		whoalias = gtk_entry_get_text(GTK_ENTRY(data->entry_for_alias));
 		if (*whoalias == '\0')
 			whoalias = NULL;
@@ -5577,19 +5580,15 @@
 	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
 	gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4);
 
-	data->combo = gtk_combo_new();
-	gtk_combo_set_popdown_strings(GTK_COMBO(data->combo), groups_tree());
+	data->combo = pidgin_text_combo_box_entry_new(group, groups_tree());
 	gtk_table_attach_defaults(GTK_TABLE(table), data->combo, 1, 2, 3, 4);
-	gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_COMBO(data->combo)->entry);
+	gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_BIN(data->combo)->child);
 	pidgin_set_accessible_label (data->combo, label);
 
 	g_signal_connect(G_OBJECT(data->window), "response",
 					 G_CALLBACK(add_buddy_cb), data);
 
 	gtk_widget_show_all(data->window);
-
-	if (group != NULL)
-		gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(data->combo)->entry), group);
 }
 
 static void
@@ -5628,7 +5627,7 @@
 							   gtk_entry_get_text(GTK_ENTRY(data->alias_entry)),
 							   components);
 
-	group_name = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(data->group_combo)->entry));
+	group_name = pidgin_text_combo_box_entry_get_text(data->group_combo);
 
 	if ((group = purple_find_group(group_name)) == NULL)
 	{
@@ -5931,18 +5930,11 @@
 	gtk_size_group_add_widget(data->sg, label);
 	gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0);
 
-	data->group_combo = gtk_combo_new();
-	gtk_combo_set_popdown_strings(GTK_COMBO(data->group_combo), groups_tree());
+	data->group_combo = pidgin_text_combo_box_entry_new(group ? group->name : NULL, groups_tree());
+	gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_BIN(data->group_combo)->child);
+	pidgin_set_accessible_label (data->group_combo, label);
 	gtk_box_pack_end(GTK_BOX(rowbox), data->group_combo, TRUE, TRUE, 0);
 
-	if (group)
-	{
-		gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(data->group_combo)->entry),
-						   group->name);
-	}
-	gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_COMBO(data->group_combo)->entry);
-	pidgin_set_accessible_label (data->group_combo, label);
-
 	g_signal_connect(G_OBJECT(data->window), "response",
 					 G_CALLBACK(add_chat_resp_cb), data);
 
--- a/pidgin/gtkconv.c	Fri Sep 14 08:10:00 2007 +0000
+++ b/pidgin/gtkconv.c	Fri Sep 14 08:31:50 2007 +0000
@@ -707,7 +707,7 @@
 	gtkconv = PIDGIN_CONVERSATION(info->conv);
 
 	if (resp == GTK_RESPONSE_OK) {
-		buddy   = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry));
+		buddy   = pidgin_text_combo_box_entry_get_text(info->entry);
 		message = gtk_entry_get_text(GTK_ENTRY(info->message));
 
 		if (!g_ascii_strcasecmp(buddy, ""))
@@ -754,7 +754,7 @@
 								"chat."), NULL);
 		}
 		else
-			gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), buddy->name);
+			pidgin_text_combo_box_entry_set_text(info->entry, buddy->name);
 
 		gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t);
 	}
@@ -781,7 +781,7 @@
 			}
 			else
 			{
-				gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), username);
+				pidgin_text_combo_box_entry_set_text(info->entry, username);
 			}
 		}
 
@@ -879,19 +879,10 @@
 		gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);
 
 		/* Now the Buddy drop-down entry field. */
-		info->entry = gtk_combo_new();
-		gtk_combo_set_case_sensitive(GTK_COMBO(info->entry), FALSE);
-		gtk_entry_set_activates_default(
-				GTK_ENTRY(GTK_COMBO(info->entry)->entry), TRUE);
-
+		info->entry = pidgin_text_combo_box_entry_new(NULL, generate_invite_user_names(gc));
 		gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1);
 		gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->entry);
 
-		/* Fill in the names. */
-		gtk_combo_set_popdown_strings(GTK_COMBO(info->entry),
-									  generate_invite_user_names(gc));
-
-
 		/* Now the label for "Message" */
 		label = gtk_label_new(NULL);
 		gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Message:"));
@@ -933,7 +924,7 @@
 	gtk_widget_show_all(invite_dialog);
 
 	if (info != NULL)
-		gtk_widget_grab_focus(GTK_COMBO(info->entry)->entry);
+		gtk_widget_grab_focus(GTK_BIN(info->entry)->child);
 }
 
 static void
@@ -3653,8 +3644,7 @@
 	static GList *tmp = NULL;
 
 	g_list_free(tmp);
-
-	tmp = g_list_append(NULL, "");
+	tmp = NULL;
 
 	if (gc != NULL) {
 		for(gnode = purple_get_blist()->root; gnode; gnode = gnode->next) {
--- a/pidgin/gtkutils.c	Fri Sep 14 08:10:00 2007 +0000
+++ b/pidgin/gtkutils.c	Fri Sep 14 08:31:50 2007 +0000
@@ -3215,3 +3215,56 @@
 }
 #endif
 
+static void
+combo_box_changed_cb(GtkComboBox *combo_box, GtkEntry *entry)
+{
+	char *text = gtk_combo_box_get_active_text(combo_box);
+	gtk_entry_set_text(entry, text ? text : "");
+	g_free(text);
+}
+
+static gboolean
+entry_key_pressed_cb(GtkWidget *entry, GdkEventKey *key, GtkComboBox *combo)
+{
+	if (key->keyval == GDK_Down || key->keyval == GDK_Up) {
+		gtk_combo_box_popup(combo);
+		return TRUE;
+	}
+	return FALSE;
+}
+
+GtkWidget *
+pidgin_text_combo_box_entry_new(const char *default_item, GList *items)
+{
+	GtkComboBox *ret = NULL;
+	GtkWidget *the_entry = NULL;
+
+	ret = GTK_COMBO_BOX(gtk_combo_box_new_text());
+	the_entry = gtk_entry_new();
+	gtk_container_add(GTK_CONTAINER(ret), the_entry);
+
+	if (default_item)
+		gtk_entry_set_text(GTK_ENTRY(the_entry), default_item);
+
+	for (; items != NULL ; items = items->next) {
+		char *text = items->data;
+		if (text && *text)
+			gtk_combo_box_append_text(ret, text);
+	}
+
+	g_signal_connect(G_OBJECT(ret), "changed", (GCallback)combo_box_changed_cb, the_entry);
+	g_signal_connect_after(G_OBJECT(the_entry), "key-press-event", G_CALLBACK(entry_key_pressed_cb), ret);
+
+	return GTK_WIDGET(ret);
+}
+
+const char *pidgin_text_combo_box_entry_get_text(GtkWidget *widget)
+{
+	return gtk_entry_get_text(GTK_ENTRY(GTK_BIN((widget))->child));
+}
+
+void pidgin_text_combo_box_entry_set_text(GtkWidget *widget, const char *text)
+{
+	gtk_entry_set_text(GTK_ENTRY(GTK_BIN((widget))->child), (text));
+}
+
--- a/pidgin/gtkutils.h	Fri Sep 14 08:10:00 2007 +0000
+++ b/pidgin/gtkutils.h	Fri Sep 14 08:31:50 2007 +0000
@@ -658,10 +658,37 @@
  * @param ...            list of integers terminated by -1
  *
  * @return               A newly created GtkTreePath.
- *
  */
 GtkTreePath *gtk_tree_path_new_from_indices (gint first_index, ...);
 #endif
 
+/**
+ * Create a simple text GtkComboBoxEntry equivalent
+ *
+ * @param default_item   Initial contents of GtkEntry
+ * @param items          GList containing strings to add to GtkComboBox
+ *
+ * @return               A newly created text GtkComboBox containing a GtkEntry
+ *                       child.
+ */
+GtkWidget *pidgin_text_combo_box_entry_new(const char *default_item, GList *items);
+
+/**
+ * Retrieve the text from the entry of the simple text GtkComboBoxEntry equivalent
+ *
+ * @param widget         The simple text GtkComboBoxEntry equivalent widget
+ *
+ * @return               The text in the widget's entry. It must not be freed
+ */
+const char *pidgin_text_combo_box_entry_get_text(GtkWidget *widget);
+
+/**
+ * Set the text in the entry of the simple text GtkComboBoxEntry equivalent
+ *
+ * @param widget         The simple text GtkComboBoxEntry equivalent widget
+ * @param text           The text to set
+ */
+void pidgin_text_combo_box_entry_set_text(GtkWidget *widget, const char *text);
+
 #endif /* _PIDGINUTILS_H_ */
 
--- a/pidgin/plugins/crazychat/cc_features.c	Fri Sep 14 08:10:00 2007 +0000
+++ b/pidgin/plugins/crazychat/cc_features.c	Fri Sep 14 08:31:50 2007 +0000
@@ -155,20 +155,16 @@
 	gtk_box_pack_start(GTK_BOX(ret.vbox), hbox, FALSE, FALSE, 0);
 	gtk_widget_show(hbox);
 
-	GtkWidget *model_combo = gtk_combo_new();
 	GList *glist = NULL;
-
 	glist = g_list_append(glist, "Dog");
 	glist = g_list_append(glist, "Shark");
-	gtk_combo_set_popdown_strings(GTK_COMBO(model_combo), glist);
+	instance->model = pidgin_text_combo_box_entry_new(NULL, glist);
 	g_list_free(glist);
 	//gtk_combo_box_set_column_span_column(GTK_COMBO(model_combo),
 	//		10);
-	gtk_box_pack_start(GTK_BOX(hbox), model_combo, TRUE, TRUE, 0);
-	gtk_widget_show(model_combo);
-	instance->model = model_combo;
+	gtk_box_pack_start(GTK_BOX(hbox), instance->model, TRUE, TRUE, 0);
+	gtk_widget_show(instance->model);
 
-	GtkWidget *head_material_combo = gtk_combo_new();
 	glist = NULL;
 	glist = g_list_append(glist, "Red");
 	glist = g_list_append(glist, "Dark Brown");
@@ -176,15 +172,13 @@
 	glist = g_list_append(glist, "White");
 	glist = g_list_append(glist, "Green");
 	glist = g_list_append(glist, "Black");
-	gtk_combo_set_popdown_strings(GTK_COMBO(head_material_combo), glist);
+	instance->head = pidgin_text_combo_box_entry_new(NULL, glist);
 	g_list_free(glist);
 	//gtk_combo_box_set_column_span_column(GTK_COMBO(head_material_combo),
 	//		10);
-	gtk_box_pack_start(GTK_BOX(hbox), head_material_combo, TRUE, TRUE, 0);
-	gtk_widget_show(head_material_combo);
-	instance->head = head_material_combo;
+	gtk_box_pack_start(GTK_BOX(hbox), instance->head, TRUE, TRUE, 0);
+	gtk_widget_show(instance->head);
 
-	GtkWidget *appendage_material_combo = gtk_combo_new();
 	glist = NULL;
 	glist = g_list_append(glist, "Red");
 	glist = g_list_append(glist, "Dark Brown");
@@ -192,20 +186,17 @@
 	glist = g_list_append(glist, "White");
 	glist = g_list_append(glist, "Green");
 	glist = g_list_append(glist, "Black");
-	gtk_combo_set_popdown_strings(GTK_COMBO(appendage_material_combo),
-			glist);
+	instance->appendage = pidgin_text_combo_box_entry_new(NULL, glist);
 	g_list_free(glist);
 	//gtk_combo_box_set_column_span_column(GTK_COMBO(appendage_material_combo), 10);
-	gtk_box_pack_start(GTK_BOX(hbox), appendage_material_combo,
+	gtk_box_pack_start(GTK_BOX(hbox), instance->appendage,
 			TRUE, TRUE, 0);
-	gtk_widget_show(appendage_material_combo);
-	instance->appendage = appendage_material_combo;
+	gtk_widget_show(instance->appendage);
 
 	hbox = gtk_hbox_new(TRUE, 0);
 	gtk_box_pack_start(GTK_BOX(ret.vbox), hbox, FALSE, FALSE, 0);
 	gtk_widget_show(hbox);
 	
-	GtkWidget *lids_material_combo = gtk_combo_new();
 	glist = NULL;
 	glist = g_list_append(glist, "Red");
 	glist = g_list_append(glist, "Dark Brown");
@@ -213,14 +204,12 @@
 	glist = g_list_append(glist, "White");
 	glist = g_list_append(glist, "Green");
 	glist = g_list_append(glist, "Black");
-	gtk_combo_set_popdown_strings(GTK_COMBO(lids_material_combo), glist);
+	instance->lid = pidgin_text_combo_box_entry_new(NULL, glist);
 	g_list_free(glist);
 	//gtk_combo_box_set_column_span_column(GTK_COMBO(lids_material_combo), 10);
-	gtk_box_pack_start(GTK_BOX(hbox), lids_material_combo, TRUE, TRUE, 0);
-	gtk_widget_show(lids_material_combo);
-	instance->lid = lids_material_combo;
+	gtk_box_pack_start(GTK_BOX(hbox), instance->lid, TRUE, TRUE, 0);
+	gtk_widget_show(instance->lid);
 
-	GtkWidget *left_iris_material_combo = gtk_combo_new();
 	glist = NULL;
 	glist = g_list_append(glist, "Red");
 	glist = g_list_append(glist, "Dark Brown");
@@ -228,17 +217,13 @@
 	glist = g_list_append(glist, "White");
 	glist = g_list_append(glist, "Green");
 	glist = g_list_append(glist, "Black");
-	gtk_combo_set_popdown_strings(GTK_COMBO(left_iris_material_combo),
-			glist);
+	instance->left_iris = pidgin_text_combo_box_entry_new(NULL, glist);
 	g_list_free(glist);
 	//gtk_combo_box_set_column_span_column(GTK_COMBO(left_iris_material_combo), 10);
-	gtk_box_pack_start(GTK_BOX(hbox), left_iris_material_combo,
-			TRUE, TRUE, 0);
-	gtk_widget_show(left_iris_material_combo);
-	instance->left_iris = left_iris_material_combo;
+	gtk_box_pack_start(GTK_BOX(hbox), instance->left_iris, TRUE, TRUE, 0);
+	gtk_widget_show(instance->left_iris);
 
 	/*
-	GtkWidget *right_iris_material_combo = gtk_combo_new();
 	glist = NULL;
 	glist = g_list_append(glist, "Red");
 	glist = g_list_append(glist, "Dark Brown");
@@ -246,14 +231,11 @@
 	glist = g_list_append(glist, "White");
 	glist = g_list_append(glist, "Green");
 	glist = g_list_append(glist, "Black");
-	gtk_combo_set_popdown_strings(GTK_COMBO(right_iris_material_combo),
-			glist);
+	instance->right_iris = pidgin_text_combo_box_entry_new(NULL, glist);
 	g_list_free(glist);
 	//gtk_combo_box_set_column_span_column(GTK_COMBO(right_iris_material_combo), 10);
-	gtk_box_pack_start(GTK_BOX(hbox), right_iris_material_combo,
-			TRUE, TRUE, 0);
-	gtk_widget_show(right_iris_material_combo);
-	instance->right_iris = right_iris_material_combo;
+	gtk_box_pack_start(GTK_BOX(hbox), instance->right_iris, TRUE, TRUE, 0);
+	gtk_widget_show(instance->right_iris);
 */
 	gtk_widget_add_events(ret.draw_area, GDK_BUTTON_PRESS_MASK);
 	g_signal_connect(G_OBJECT(ret.draw_area), "button_press_event",
--- a/pidgin/plugins/gevolution/add_buddy_dialog.c	Fri Sep 14 08:10:00 2007 +0000
+++ b/pidgin/plugins/gevolution/add_buddy_dialog.c	Fri Sep 14 08:31:50 2007 +0000
@@ -68,7 +68,7 @@
 	const char *group_name;
 
 	group_name =
-		gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(dialog->group_combo)->entry));
+		pidgin_text_combo_box_entry_get_text(dialog->group_combo);
 
 	gevo_new_person_dialog_show(dialog->book, NULL, dialog->account, dialog->username,
 								(*group_name ? group_name : NULL),
@@ -105,7 +105,7 @@
 					   -1);
 
 	group_name =
-		gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(dialog->group_combo)->entry));
+		pidgin_text_combo_box_entry_get_text(dialog->group_combo);
 
 	if (username == NULL || *username == '\0')
 	{
@@ -553,9 +553,8 @@
 	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
 	gtk_widget_show(label);
 
-	dialog->group_combo = gtk_combo_new();
-	gtk_combo_set_popdown_strings(GTK_COMBO(dialog->group_combo),
-								  gevo_get_groups());
+	dialog->group_combo =
+		pidgin_text_combo_box_entry_new(NULL, gevo_get_groups());
 	gtk_box_pack_start(GTK_BOX(hbox), dialog->group_combo, TRUE, TRUE, 0);
 	gtk_widget_show(dialog->group_combo);
 
--- a/pidgin/plugins/gevolution/gevo-util.c	Fri Sep 14 08:10:00 2007 +0000
+++ b/pidgin/plugins/gevolution/gevo-util.c	Fri Sep 14 08:31:50 2007 +0000
@@ -55,10 +55,13 @@
 GList *
 gevo_get_groups(void)
 {
-	GList *list = NULL;
+	static GList *list = NULL;
 	PurpleGroup *g;
 	PurpleBlistNode *gnode;
 
+	g_list_free(list);
+	list = NULL;
+
 	if (purple_get_blist()->root == NULL)
 	{
 		list  = g_list_append(list, (gpointer)_("Buddies"));
--- a/pidgin/plugins/gevolution/new_person_dialog.c	Fri Sep 14 08:10:00 2007 +0000
+++ b/pidgin/plugins/gevolution/new_person_dialog.c	Fri Sep 14 08:31:50 2007 +0000
@@ -195,10 +195,9 @@
 
 	if (!dialog->person_only)
 	{
-		GtkWidget *entry = GTK_COMBO(dialog->group_combo)->entry;
 		const char *group_name;
 
-		group_name = gtk_entry_get_text(GTK_ENTRY(entry));
+		group_name = pidgin_text_combo_box_entry_get_text(dialog->group_combo);
 
 		gevo_add_buddy(dialog->account, group_name, screenname, full_name);
 	}
@@ -297,9 +296,8 @@
 						 G_CALLBACK(screenname_changed_cb), dialog);
 
 		/* Group */
-		dialog->group_combo = gtk_combo_new();
-		gtk_combo_set_popdown_strings(GTK_COMBO(dialog->group_combo),
-									  gevo_get_groups());
+		dialog->group_combo = pidgin_text_combo_box_entry_new(NULL,
+			gevo_get_groups());
 		add_pref_box(sg, vbox, _("Group:"), dialog->group_combo);
 
 		/* Separator */