/soc/2013/ankitkv/gobjectification: 088f823e196c: Merged default...

Ankit Vani a at nevitus.org
Thu Sep 12 14:59:34 EDT 2013


Changeset: 088f823e196c3bd3db5c38ef6332c0e5d837439c
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-09-13 00:28 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/088f823e196c

Description:

Merged default branch

diffstat:

 libpurple/request.c  |  30 ++++++++++++++++++++++++++++++
 libpurple/request.h  |  23 +++++++++++++++++++++++
 pidgin/gtkrequest.c  |  33 ++++++++++++++++++++++++++++++++-
 pidgin/pidginstock.c |   4 +++-
 pidgin/pidginstock.h |   1 +
 5 files changed, 89 insertions(+), 2 deletions(-)

diffs (224 lines):

diff --git a/libpurple/request.c b/libpurple/request.c
--- a/libpurple/request.c
+++ b/libpurple/request.c
@@ -162,11 +162,17 @@ struct _PurpleRequestCommonParameters
 
 	PurpleAccount *account;
 	PurpleConversation *conv;
+
 	PurpleRequestIconType icon_type;
 	gconstpointer icon_data;
 	gsize icon_size;
+
 	gboolean html;
+
 	gboolean compact;
+
+	PurpleRequestHelpCb help_cb;
+	gpointer help_data;
 };
 
 PurpleRequestCommonParameters *
@@ -336,6 +342,8 @@ void
 purple_request_cpar_set_compact(PurpleRequestCommonParameters *cpar,
 	gboolean compact)
 {
+	g_return_if_fail(cpar != NULL);
+
 	cpar->compact = compact;
 }
 
@@ -348,6 +356,28 @@ purple_request_cpar_is_compact(PurpleReq
 	return cpar->compact;
 }
 
+void
+purple_request_cpar_set_help_cb(PurpleRequestCommonParameters *cpar,
+	PurpleRequestHelpCb cb, gpointer user_data)
+{
+	g_return_if_fail(cpar != NULL);
+
+	cpar->help_cb = cb;
+	cpar->help_data = cb ? user_data : NULL;
+}
+
+PurpleRequestHelpCb
+purple_request_cpar_get_help_cb(PurpleRequestCommonParameters *cpar,
+	gpointer *user_data)
+{
+	if (cpar == NULL)
+		return NULL;
+
+	if (user_data != NULL)
+		*user_data = cpar->help_data;
+	return cpar->help_cb;
+}
+
 PurpleRequestFields *
 purple_request_fields_new(void)
 {
diff --git a/libpurple/request.h b/libpurple/request.h
--- a/libpurple/request.h
+++ b/libpurple/request.h
@@ -168,6 +168,7 @@ typedef void (*PurpleRequestActionCb)(vo
 typedef void (*PurpleRequestChoiceCb)(void *, gpointer);
 typedef void (*PurpleRequestFieldsCb)(void *, PurpleRequestFields *fields);
 typedef void (*PurpleRequestFileCb)(void *, const char *filename);
+typedef void (*PurpleRequestHelpCb)(gpointer);
 
 G_BEGIN_DECLS
 
@@ -356,6 +357,28 @@ purple_request_cpar_set_compact(PurpleRe
 gboolean
 purple_request_cpar_is_compact(PurpleRequestCommonParameters *cpar);
 
+/**
+ * Sets the callback for the Help button.
+ *
+ * @param cpar      The parameters set.
+ * @param cb        The callback.
+ * @param user_data The data to be passed to the callback.
+ */
+void
+purple_request_cpar_set_help_cb(PurpleRequestCommonParameters *cpar,
+	PurpleRequestHelpCb cb, gpointer user_data);
+
+/**
+ * Gets the callback for the Help button.
+ *
+ * @param cpar      The parameters set (may be @c NULL).
+ * @param user_data The pointer to the variable, where user data (to be passed
+ *                  to callback function) should be stored.
+ */
+PurpleRequestHelpCb
+purple_request_cpar_get_help_cb(PurpleRequestCommonParameters *cpar,
+	gpointer *user_data);
+
 /*@}*/
 
 /**************************************************************************/
diff --git a/pidgin/gtkrequest.c b/pidgin/gtkrequest.c
--- a/pidgin/gtkrequest.c
+++ b/pidgin/gtkrequest.c
@@ -323,8 +323,10 @@ text_to_stock(const char *text)
 	STOCK_ITEMIZE(N_("Add"),     GTK_STOCK_ADD);
 	STOCK_ITEMIZE(N_("Remove"),  GTK_STOCK_REMOVE);
 	STOCK_ITEMIZE(N_("Save"),    GTK_STOCK_SAVE);
-	STOCK_ITEMIZE(N_("Next"),    GTK_STOCK_GO_FORWARD);
+	STOCK_ITEMIZE(N_("Next"),    PIDGIN_STOCK_NEXT);
+	STOCK_ITEMIZE(N_("_Next"),   PIDGIN_STOCK_NEXT);
 	STOCK_ITEMIZE(N_("Back"),    GTK_STOCK_GO_BACK);
+	STOCK_ITEMIZE(N_("_Back"),   GTK_STOCK_GO_BACK);
 	STOCK_ITEMIZE(N_("Alias"),   PIDGIN_STOCK_ALIAS);
 
 	return text;
@@ -431,6 +433,23 @@ pidgin_request_dialog_icon(PurpleRequest
 		gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_HUGE));
 }
 
+static void
+pidgin_request_add_help(GtkDialog *dialog, PurpleRequestCommonParameters *cpar)
+{
+	GtkWidget *button;
+	PurpleRequestHelpCb help_cb;
+	gpointer help_data;
+
+	help_cb = purple_request_cpar_get_help_cb(cpar, &help_data);
+	if (help_cb == NULL)
+		return;
+
+	button = gtk_dialog_add_button(dialog, GTK_STOCK_HELP,
+		GTK_RESPONSE_HELP);
+	g_signal_connect(G_OBJECT(button), "clicked", (GCallback)help_cb,
+		help_data);
+}
+
 static void *
 pidgin_request_input(const char *title, const char *primary,
 					   const char *secondary, const char *default_value,
@@ -491,6 +510,8 @@ pidgin_request_input(const char *title, 
 	gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
 	gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
 
+	pidgin_request_add_help(GTK_DIALOG(dialog), cpar);
+
 	/* Vertical box */
 	vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER);
 
@@ -651,6 +672,8 @@ pidgin_request_choice(const char *title,
 
 	pidgin_widget_decorate_account(hbox, purple_request_cpar_get_account(cpar));
 
+	pidgin_request_add_help(GTK_DIALOG(dialog), cpar);
+
 	/* Vertical box */
 	vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER);
 	gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
@@ -776,6 +799,8 @@ pidgin_request_action(const char *title,
 	pidgin_widget_decorate_account(hbox,
 		purple_request_cpar_get_account(cpar));
 
+	pidgin_request_add_help(GTK_DIALOG(dialog), cpar);
+
 	/* Descriptive label */
 	primary_esc = pidgin_request_escape(cpar, primary);
 	secondary_esc = pidgin_request_escape(cpar, secondary);
@@ -1381,6 +1406,8 @@ pidgin_request_fields(const char *title,
 	gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
 	gtk_widget_show(img);
 
+	pidgin_request_add_help(GTK_DIALOG(win), cpar);
+
 	/* Cancel button */
 	button = pidgin_dialog_add_button(GTK_DIALOG(win), text_to_stock(cancel_text), G_CALLBACK(multifield_cancel_cb), data);
 	gtk_widget_set_can_default(button, TRUE);
@@ -1776,6 +1803,8 @@ pidgin_request_file(const char *title, c
 						NULL);
 	gtk_dialog_set_default_response(GTK_DIALOG(filesel), GTK_RESPONSE_ACCEPT);
 
+	pidgin_request_add_help(GTK_DIALOG(filesel), cpar);
+
 	if ((filename != NULL) && (*filename != '\0')) {
 		if (savedialog)
 			gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(filesel), filename);
@@ -1845,6 +1874,8 @@ pidgin_request_folder(const char *title,
 						NULL);
 	gtk_dialog_set_default_response(GTK_DIALOG(dirsel), GTK_RESPONSE_ACCEPT);
 
+	pidgin_request_add_help(GTK_DIALOG(dirsel), cpar);
+
 	if ((dirname != NULL) && (*dirname != '\0'))
 		gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dirsel), dirname);
 
diff --git a/pidgin/pidginstock.c b/pidgin/pidginstock.c
--- a/pidgin/pidginstock.c
+++ b/pidgin/pidginstock.c
@@ -76,6 +76,7 @@ static struct StockIcon
 	{ PIDGIN_STOCK_TYPED,           "pidgin",  "typed.png"                },
 	{ PIDGIN_STOCK_UPLOAD,          NULL,      GTK_STOCK_GO_UP            },
 	{ PIDGIN_STOCK_INFO,            NULL,      GTK_STOCK_INFO             },
+	{ PIDGIN_STOCK_NEXT,            NULL,      GTK_STOCK_GO_FORWARD       },
 };
 
 static const GtkStockItem stock_items[] =
@@ -90,7 +91,8 @@ static const GtkStockItem stock_items[] 
 	{ PIDGIN_STOCK_ADD,                 N_("_Add..."),     0, 0, PACKAGE },
 	{ PIDGIN_STOCK_OPEN_MAIL,           N_("_Open Mail"),  0, 0, PACKAGE },
 	{ PIDGIN_STOCK_PAUSE,               N_("_Pause"),      0, 0, PACKAGE },
-	{ PIDGIN_STOCK_EDIT,                N_("_Edit"),       0, 0, PACKAGE }
+	{ PIDGIN_STOCK_EDIT,                N_("_Edit"),       0, 0, PACKAGE },
+	{ PIDGIN_STOCK_NEXT,                N_("_Next"),       0, 0, PACKAGE },
 };
 
 typedef struct {
diff --git a/pidgin/pidginstock.h b/pidgin/pidginstock.h
--- a/pidgin/pidginstock.h
+++ b/pidgin/pidginstock.h
@@ -59,6 +59,7 @@
 #define PIDGIN_STOCK_TEXT_NORMAL     "pidgin-text-normal"
 #define PIDGIN_STOCK_TYPED           "pidgin-typed"
 #define PIDGIN_STOCK_UPLOAD          "pidgin-upload"
+#define PIDGIN_STOCK_NEXT            "pidgin-next"
 
 /* Status icons */
 #define PIDGIN_STOCK_STATUS_AVAILABLE  "pidgin-status-available"



More information about the Commits mailing list