changeset 22823:750813c2db46

The required fields are not really required if the action is cancelled.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Mon, 05 May 2008 16:01:02 +0000
parents f09acca60066
children 29235834c692 66914f306712 5d833ca5a265 ab7e9aa328f6
files finch/gntrequest.c
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/finch/gntrequest.c	Mon May 05 14:56:36 2008 +0000
+++ b/finch/gntrequest.c	Mon May 05 16:01:02 2008 +0000
@@ -98,6 +98,8 @@
  * cb: the callback
  * data: data for the callback
  * (text, primary-callback) pairs, ended by a NULL
+ *
+ * The cancellation callback should be the last callback sent.
  */
 static GntWidget *
 setup_button_box(GntWidget *win, gpointer userdata, gpointer cb, gpointer data, ...)
@@ -122,6 +124,8 @@
 		g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(cb), data);
 	}
 
+	g_object_set_data(G_OBJECT(button), "cancellation-function", GINT_TO_POINTER(TRUE));
+
 	va_end(list);
 	return box;
 }
@@ -300,7 +304,7 @@
 	{
 		PurpleRequestFieldGroup *group = list->data;
 		GList *fields = purple_request_field_group_get_fields(group);
-		
+
 		for (; fields ; fields = fields->next)
 		{
 			PurpleRequestField *field = fields->data;
@@ -369,7 +373,8 @@
 
 	purple_notify_close_with_handle(button);
 
-	if (!purple_request_fields_all_required_filled(fields)) {
+	if (!g_object_get_data(G_OBJECT(button), "cancellation-function") &&
+			!purple_request_fields_all_required_filled(fields)) {
 		purple_notify_error(button, _("Error"),
 				_("You must fill all the required fields."),
 				_("The required fields are underlined."));
@@ -653,7 +658,7 @@
 	}
 
 	g_object_set_data(G_OBJECT(window), "fields", allfields);
-	
+
 	return window;
 }