Allow Request API dialog with only one closing button

Tue, 07 Jan 2014 15:50:27 +0100

author
Tomasz Wasilczyk <twasilczyk@pidgin.im>
date
Tue, 07 Jan 2014 15:50:27 +0100
changeset 35142
d3f26f67a5ef
parent 35141
48e4e99bb831
child 35143
7847eb4b93b0

Allow Request API dialog with only one closing button

libpurple/request.c file | annotate | diff | comparison | revisions
pidgin/gtkrequest.c file | annotate | diff | comparison | revisions
--- a/libpurple/request.c	Sun Jan 05 02:12:32 2014 +0100
+++ b/libpurple/request.c	Tue Jan 07 15:50:27 2014 +0100
@@ -2375,13 +2375,13 @@
 {
 	PurpleRequestUiOps *ops;
 
-	if (G_UNLIKELY(fields == NULL || ok_text == NULL || ok_cb == NULL ||
+	if (G_UNLIKELY(fields == NULL ||
+		((ok_text == NULL) != (ok_cb == NULL)) ||
 		cancel_text == NULL))
 	{
 		purple_request_cpar_unref(cpar);
 		g_warn_if_fail(fields != NULL);
-		g_warn_if_fail(ok_text != NULL);
-		g_warn_if_fail(ok_cb != NULL);
+		g_warn_if_fail((ok_text == NULL) != (ok_cb == NULL));
 		g_warn_if_fail(cancel_text != NULL);
 		g_return_val_if_reached(NULL);
 	}
--- a/pidgin/gtkrequest.c	Sun Jan 05 02:12:32 2014 +0100
+++ b/pidgin/gtkrequest.c	Tue Jan 07 15:50:27 2014 +0100
@@ -1991,6 +1991,7 @@
 	size_t extra_actions_count, i;
 	const gchar **tab_names;
 	guint tab_count;
+	gboolean ok_btn = (ok_text != NULL);
 
 	data            = g_new0(PidginRequestData, 1);
 	data->type      = PURPLE_REQUEST_FIELDS;
@@ -2008,7 +2009,6 @@
 	data->cbs[0] = ok_cb;
 	data->cbs[1] = cancel_cb;
 
-
 #ifdef _WIN32
 	data->dialog = win = pidgin_create_dialog(PIDGIN_ALERT_TITLE, PIDGIN_HIG_BORDER, "multifield", TRUE) ;
 #else /* !_WIN32 */
@@ -2047,10 +2047,14 @@
 	gtk_widget_set_can_default(button, TRUE);
 
 	/* OK button */
-	button = pidgin_dialog_add_button(GTK_DIALOG(win), text_to_stock(ok_text), G_CALLBACK(multifield_ok_cb), data);
-	data->ok_button = button;
-	gtk_widget_set_can_default(button, TRUE);
-	gtk_window_set_default(GTK_WINDOW(win), button);
+	if (!ok_btn) {
+		gtk_window_set_default(GTK_WINDOW(win), button);
+	} else {
+		button = pidgin_dialog_add_button(GTK_DIALOG(win), text_to_stock(ok_text), G_CALLBACK(multifield_ok_cb), data);
+		data->ok_button = button;
+		gtk_widget_set_can_default(button, TRUE);
+		gtk_window_set_default(GTK_WINDOW(win), button);
+	}
 
 	pidgin_widget_decorate_account(hbox,
 		purple_request_cpar_get_account(cpar));

mercurial