/pidgin/main: b23d9c0b64d5: Request API: help button support
Tomasz Wasilczyk
twasilczyk at pidgin.im
Thu Sep 12 10:47:15 EDT 2013
Changeset: b23d9c0b64d575b21dec21335a48ea5d18a15646
Author: Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date: 2013-09-12 16:47 +0200
Branch: default
URL: https://hg.pidgin.im/pidgin/main/rev/b23d9c0b64d5
Description:
Request API: help button support
diffstat:
libpurple/request.c | 30 ++++++++++++++++++++++++++++++
libpurple/request.h | 23 +++++++++++++++++++++++
pidgin/gtkrequest.c | 12 ++++++++++++
3 files changed, 65 insertions(+), 0 deletions(-)
diffs (121 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
@@ -1381,6 +1381,18 @@ pidgin_request_fields(const char *title,
gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
gtk_widget_show(img);
+ /* Help button */
+ if (purple_request_cpar_get_help_cb(cpar, NULL) != NULL) {
+ PurpleRequestHelpCb help_cb;
+ gpointer help_data;
+
+ help_cb = purple_request_cpar_get_help_cb(cpar, &help_data);
+ g_assert(help_cb != NULL);
+
+ button = gtk_dialog_add_button(GTK_DIALOG(win), GTK_STOCK_HELP, GTK_RESPONSE_HELP);
+ g_signal_connect(G_OBJECT(button), "clicked", (GCallback)help_cb, help_data);
+ }
+
/* 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);
More information about the Commits
mailing list