changeset 29290:03705a4f3dc0

gtkrequest: Handle a multiline text field being set as required properly. The GtkTextView wasn't having setup_entry_field() called on it, which listens for the changed signal if the field is required. The result was that it was impossible to submit such a form because Pidgin never thought it was sufficiently filled in.
author Paul Aurich <paul@darkrain42.org>
date Sat, 23 Jan 2010 03:56:35 +0000
parents d9c97c2b29fd
children a25090259b4c
files ChangeLog pidgin/gtkrequest.c
diffstat 2 files changed, 25 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Jan 22 17:36:42 2010 +0000
+++ b/ChangeLog	Sat Jan 23 03:56:35 2010 +0000
@@ -31,6 +31,8 @@
 	Pidgin:
 	* Correctly size conversation and status box entries when the
 	  interior-focus style property is diabled. (Gabriel Schulhof)
+	* Correctly handle a multiline text field being required in a
+	  request form.  (Thanks to Florian Zeitz for finding this problem)
 
 version 2.6.5 (01/08/2010):
 	libpurple:
--- a/pidgin/gtkrequest.c	Fri Jan 22 17:36:42 2010 +0000
+++ b/pidgin/gtkrequest.c	Sat Jan 23 03:56:35 2010 +0000
@@ -719,9 +719,23 @@
 {
 	PurpleRequestFieldGroup *group;
 	PidginRequestData *req_data;
-	const char *text = gtk_entry_get_text(GTK_ENTRY(entry));
+	const char *text = NULL;
+
+	if (purple_request_field_string_is_multiline(field))
+	{
+		GtkTextIter start_iter, end_iter;
+
+		gtk_text_buffer_get_start_iter(GTK_TEXT_BUFFER(entry), &start_iter);
+		gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(entry), &end_iter);
 
-	purple_request_field_string_set_value(field, (*text == '\0' ? NULL : text));
+		text = gtk_text_buffer_get_text(GTK_TEXT_BUFFER(entry), &start_iter, &end_iter, FALSE);
+	}
+	else
+	{
+		text = gtk_entry_get_text(GTK_ENTRY(entry));
+	}
+
+	purple_request_field_string_set_value(field, (*text == '\0') ? NULL : text);
 
 	group = purple_request_field_get_group(field);
 	req_data = (PidginRequestData *)group->fields_list->ui_data;
@@ -824,6 +838,13 @@
 
 		g_signal_connect(G_OBJECT(textview), "focus-out-event",
 						 G_CALLBACK(field_string_focus_out_cb), field);
+
+	    if (purple_request_field_is_required(field))
+	    {
+			GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
+			g_signal_connect(G_OBJECT(buffer), "changed",
+							 G_CALLBACK(req_entry_field_changed_cb), field);
+	    }
 	}
 	else
 	{