/pidgin/main: 78b2942f06db: Finch-OTR: implement missing PurpleR...

Tomasz Wasilczyk twasilczyk at pidgin.im
Sat Apr 26 16:08:09 EDT 2014


Changeset: 78b2942f06db366f9a2231b768dbf14cddfe658d
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-04-26 22:07 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/78b2942f06db

Description:

Finch-OTR: implement missing PurpleRequestCommonParameters features

diffstat:

 finch/gntrequest.c    |  44 ++++++++++++++++++++++++++++++++++++++++++++
 finch/libgnt/gntbox.c |   6 ++++++
 finch/libgnt/gntbox.h |  11 +++++++++++
 3 files changed, 61 insertions(+), 0 deletions(-)

diffs (105 lines):

diff --git a/finch/gntrequest.c b/finch/gntrequest.c
--- a/finch/gntrequest.c
+++ b/finch/gntrequest.c
@@ -590,6 +590,24 @@ create_certificate_field(PurpleRequestFi
 	return w;
 }
 
+static void
+multifield_extra_cb(GntWidget *button, PurpleRequestFields *allfields)
+{
+	PurpleRequestFieldsCb cb;
+	gpointer cb_data;
+	gpointer handle;
+
+	handle = g_object_get_data(G_OBJECT(button), "ui-handle");
+	cb = g_object_get_data(G_OBJECT(button), "extra-cb");
+	cb_data = g_object_get_data(G_OBJECT(button), "extra-cb-data");
+
+	if (cb != NULL)
+		cb(cb_data, allfields);
+
+	action_performed(button, handle);
+	purple_request_close(PURPLE_REQUEST_FIELDS, handle);
+}
+
 static void *
 finch_request_fields(const char *title, const char *primary,
 		const char *secondary, PurpleRequestFields *allfields,
@@ -601,6 +619,9 @@ finch_request_fields(const char *title, 
 	GntWidget *window, *box;
 	GList *grlist;
 	GntWidget *username = NULL, *accountlist = NULL;
+	PurpleRequestHelpCb help_cb;
+	gpointer help_data;
+	GSList *extra_actions, *it;
 
 	window = setup_request_window(title, primary, secondary, PURPLE_REQUEST_FIELDS);
 
@@ -688,6 +709,29 @@ finch_request_fields(const char *title, 
 
 	box = setup_button_box(window, userdata, request_fields_cb, allfields,
 			ok, ok_cb, cancel, cancel_cb, NULL);
+
+	extra_actions = purple_request_cpar_get_extra_actions(cpar);
+	for (it = extra_actions; it; it = it->next->next) {
+		const gchar *label = it->data;
+		PurpleRequestFieldsCb *cb = it->next->data;
+
+		GntWidget *button = gnt_button_new(label);
+		gnt_box_add_widget_in_front(GNT_BOX(box), button);
+		g_object_set_data(G_OBJECT(button), "ui-handle", window);
+		g_object_set_data(G_OBJECT(button), "extra-cb", cb);
+		g_object_set_data(G_OBJECT(button), "extra-cb-data", userdata);
+		g_signal_connect(G_OBJECT(button), "activate",
+			G_CALLBACK(multifield_extra_cb), allfields);
+	}
+
+	help_cb = purple_request_cpar_get_help_cb(cpar, &help_data);
+	if (help_cb) {
+		GntWidget *button = gnt_button_new(_("Help"));
+		gnt_box_add_widget_in_front(GNT_BOX(box), button);
+		g_signal_connect_swapped(G_OBJECT(button), "activate",
+			G_CALLBACK(help_cb), help_data);
+	}
+
 	gnt_box_add_widget(GNT_BOX(window), box);
 
 	setup_default_callback(window, cancel_cb, userdata);
diff --git a/finch/libgnt/gntbox.c b/finch/libgnt/gntbox.c
--- a/finch/libgnt/gntbox.c
+++ b/finch/libgnt/gntbox.c
@@ -677,6 +677,12 @@ void gnt_box_add_widget(GntBox *b, GntWi
 	widget->parent = GNT_WIDGET(b);
 }
 
+void gnt_box_add_widget_in_front(GntBox *b, GntWidget *widget)
+{
+	b->list = g_list_prepend(b->list, widget);
+	widget->parent = GNT_WIDGET(b);
+}
+
 void gnt_box_set_title(GntBox *b, const char *title)
 {
 	char *prev = b->title;
diff --git a/finch/libgnt/gntbox.h b/finch/libgnt/gntbox.h
--- a/finch/libgnt/gntbox.h
+++ b/finch/libgnt/gntbox.h
@@ -125,6 +125,17 @@ GntWidget * gnt_box_new(gboolean homo, g
 void gnt_box_add_widget(GntBox *box, GntWidget *widget);
 
 /**
+ * gnt_box_add_widget_in_front:
+ * @box:     The box
+ * @widget:  The widget to add
+ *
+ * Add a widget in the box at its front.
+ *
+ * Since: 2.8.0
+ */
+void gnt_box_add_widget_in_front(GntBox *b, GntWidget *widget);
+
+/**
  * gnt_box_set_title:
  * @box:    The box
  * @title:	 The title to set



More information about the Commits mailing list