/pidgin/main: b7926ff76ed6: Request API: implement purple_reques...
Tomasz Wasilczyk
twasilczyk at pidgin.im
Tue Sep 17 06:17:24 EDT 2013
Changeset: b7926ff76ed61f8ac94f3707761edab3e82a5d30
Author: Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date: 2013-09-17 12:17 +0200
Branch: default
URL: https://hg.pidgin.im/pidgin/main/rev/b7926ff76ed6
Description:
Request API: implement purple_request_wait
diffstat:
finch/gntrequest.c | 3 ++-
libpurple/request.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
libpurple/request.h | 38 +++++++++++++++++++++++++++++++++++---
pidgin/gtkrequest.c | 5 ++++-
4 files changed, 85 insertions(+), 6 deletions(-)
diffs (190 lines):
diff --git a/finch/gntrequest.c b/finch/gntrequest.c
--- a/finch/gntrequest.c
+++ b/finch/gntrequest.c
@@ -814,10 +814,11 @@ static PurpleRequestUiOps uiops =
finch_request_input,
finch_request_choice,
finch_request_action,
+ NULL,
finch_request_fields,
finch_request_file,
+ finch_request_folder,
finch_close_request,
- finch_request_folder,
NULL,
NULL,
NULL,
diff --git a/libpurple/request.c b/libpurple/request.c
--- a/libpurple/request.c
+++ b/libpurple/request.c
@@ -289,7 +289,7 @@ PurpleRequestIconType
purple_request_cpar_get_icon(PurpleRequestCommonParameters *cpar)
{
if (cpar == NULL)
- return PURPLE_REQUEST_ICON_REQUEST;
+ return PURPLE_REQUEST_ICON_DEFAULT;
return cpar->icon_type;
}
@@ -2011,6 +2011,49 @@ purple_request_action_varg(void *handle,
}
void *
+purple_request_wait(void *handle, const char *title, const char *primary,
+ const char *secondary, GCallback cancel_cb,
+ PurpleRequestCommonParameters *cpar, void *user_data)
+{
+ PurpleRequestUiOps *ops;
+
+ if (title == NULL)
+ title = _("Please wait");
+ if (primary == NULL)
+ primary = _("Please wait...");
+
+ ops = purple_request_get_ui_ops();
+
+ if (ops != NULL && ops->request_wait != NULL) {
+ PurpleRequestInfo *info;
+ gchar **tmp;
+
+ tmp = purple_request_strip_html(cpar, &primary, &secondary);
+
+ info = g_new0(PurpleRequestInfo, 1);
+ info->type = PURPLE_REQUEST_WAIT;
+ info->handle = handle;
+ info->ui_handle = ops->request_wait(title, primary, secondary,
+ cancel_cb, cpar, user_data);
+
+ handles = g_list_append(handles, info);
+
+ g_strfreev(tmp);
+ purple_request_cpar_unref(cpar);
+ return info->ui_handle;
+ }
+
+ if (cpar == NULL)
+ cpar = purple_request_cpar_new();
+ if (purple_request_cpar_get_icon(cpar) == PURPLE_REQUEST_ICON_DEFAULT)
+ purple_request_cpar_set_icon(cpar, PURPLE_REQUEST_ICON_WAIT);
+
+ return purple_request_action(handle, title, primary, secondary,
+ PURPLE_DEFAULT_ACTION_NONE, cpar, user_data,
+ cancel_cb ? 1 : 0, _("Cancel"), cancel_cb);
+}
+
+void *
purple_request_fields(void *handle, const char *title, const char *primary,
const char *secondary, PurpleRequestFields *fields, const char *ok_text,
GCallback ok_cb, const char *cancel_text, GCallback cancel_cb,
diff --git a/libpurple/request.h b/libpurple/request.h
--- a/libpurple/request.h
+++ b/libpurple/request.h
@@ -64,6 +64,7 @@ typedef enum
PURPLE_REQUEST_INPUT = 0, /**< Text input request. */
PURPLE_REQUEST_CHOICE, /**< Multiple-choice request. */
PURPLE_REQUEST_ACTION, /**< Action request. */
+ PURPLE_REQUEST_WAIT, /**< Please wait dialog. */
PURPLE_REQUEST_FIELDS, /**< Multiple fields request. */
PURPLE_REQUEST_FILE, /**< File open or save request. */
PURPLE_REQUEST_FOLDER /**< Folder selection request. */
@@ -95,8 +96,10 @@ typedef enum
typedef enum
{
- PURPLE_REQUEST_ICON_REQUEST = 0,
+ PURPLE_REQUEST_ICON_DEFAULT = 0,
+ PURPLE_REQUEST_ICON_REQUEST,
PURPLE_REQUEST_ICON_DIALOG,
+ PURPLE_REQUEST_ICON_WAIT,
PURPLE_REQUEST_ICON_INFO,
PURPLE_REQUEST_ICON_WARNING,
PURPLE_REQUEST_ICON_ERROR
@@ -130,6 +133,11 @@ typedef struct
PurpleRequestCommonParameters *cpar, void *user_data,
size_t action_count, va_list actions);
+ /** @see purple_request_wait(). */
+ void *(*request_wait)(const char *title, const char *primary,
+ const char *secondary, GCallback cancel_cb,
+ PurpleRequestCommonParameters *cpar, void *user_data);
+
/** @see purple_request_fields(). */
void *(*request_fields)(const char *title, const char *primary,
const char *secondary, PurpleRequestFields *fields,
@@ -142,13 +150,13 @@ typedef struct
gboolean savedialog, GCallback ok_cb, GCallback cancel_cb,
PurpleRequestCommonParameters *cpar, void *user_data);
- void (*close_request)(PurpleRequestType type, void *ui_handle);
-
/** @see purple_request_folder(). */
void *(*request_folder)(const char *title, const char *dirname,
GCallback ok_cb, GCallback cancel_cb,
PurpleRequestCommonParameters *cpar, void *user_data);
+ void (*close_request)(PurpleRequestType type, void *ui_handle);
+
void (*_purple_reserved1)(void);
void (*_purple_reserved2)(void);
void (*_purple_reserved3)(void);
@@ -1722,6 +1730,30 @@ purple_request_action_varg(void *handle,
size_t action_count, va_list actions);
/**
+ * Displays a "please wait" dialog.
+ *
+ * @param handle The plugin or connection handle. For some things this
+ * is <em>extremely</em> important. See the comments on
+ * purple_request_input().
+ * @param title The title of the message, or @c NULL if it should have
+ * default title.
+ * @param primary The main point of the message, or @c NULL if you're
+ * feeling enigmatic.
+ * @param secondary Secondary information, or @c NULL if there is none.
+ * @param cancel_cb The callback for the @c Cancel button, which may be
+ * @c NULL.
+ * @param cpar The #PurpleRequestCommonParameters object, which gets
+ * unref'ed after this call.
+ * @param user_data The data to pass to the callback.
+ *
+ * @return A UI-specific handle.
+ */
+void *
+purple_request_wait(void *handle, const char *title, const char *primary,
+ const char *secondary, GCallback cancel_cb,
+ PurpleRequestCommonParameters *cpar, void *user_data);
+
+/**
* Displays groups of fields for the user to fill in.
*
* @param handle The plugin or connection handle. For some things this
diff --git a/pidgin/gtkrequest.c b/pidgin/gtkrequest.c
--- a/pidgin/gtkrequest.c
+++ b/pidgin/gtkrequest.c
@@ -410,11 +410,13 @@ pidgin_request_dialog_icon(PurpleRequest
icon_type = purple_request_cpar_get_icon(cpar);
switch (icon_type)
{
+ case PURPLE_REQUEST_ICON_DEFAULT:
case PURPLE_REQUEST_ICON_REQUEST:
icon_stock = PIDGIN_STOCK_DIALOG_QUESTION;
break;
case PURPLE_REQUEST_ICON_DIALOG:
case PURPLE_REQUEST_ICON_INFO:
+ case PURPLE_REQUEST_ICON_WAIT: /* TODO: we need another icon */
icon_stock = PIDGIN_STOCK_DIALOG_INFO;
break;
case PURPLE_REQUEST_ICON_WARNING:
@@ -1971,10 +1973,11 @@ static PurpleRequestUiOps ops =
pidgin_request_input,
pidgin_request_choice,
pidgin_request_action,
+ NULL,
pidgin_request_fields,
pidgin_request_file,
+ pidgin_request_folder,
pidgin_close_request,
- pidgin_request_folder,
NULL,
NULL,
NULL,
More information about the Commits
mailing list