diff finch/gntrequest.c @ 23113:8c3444f04709

propagate from branch 'im.pidgin.pidgin' (head d7144f5dbbde09137aff1ceadfd419e25303bf7d) to branch 'im.pidgin.pidgin.next.minor' (head b6f1c6f279a87ac4b59426eea116c349eb31fe8c)
author Evan Schoenberg <evan.s@dreskin.net>
date Wed, 07 May 2008 12:14:28 +0000
parents 5c9d9df219af
children 5d681e194fb3 ff29208e03ef
line wrap: on
line diff
--- a/finch/gntrequest.c	Mon May 05 06:55:00 2008 +0000
+++ b/finch/gntrequest.c	Wed May 07 12:14:28 2008 +0000
@@ -98,11 +98,14 @@
  * 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, ...)
 {
-	GntWidget *box, *button;
+	GntWidget *box;
+	GntWidget *button = NULL;
 	va_list list;
 	const char *text;
 	gpointer callback;
@@ -122,6 +125,9 @@
 		g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(cb), data);
 	}
 
+	if (button)
+		g_object_set_data(G_OBJECT(button), "cancellation-function", GINT_TO_POINTER(TRUE));
+
 	va_end(list);
 	return box;
 }
@@ -300,7 +306,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 +375,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 +660,7 @@
 	}
 
 	g_object_set_data(G_OBJECT(window), "fields", allfields);
-	
+
 	return window;
 }