/soc/2015/mmcc/main: 5d4a86d3ccca: I misunderstood text_to_stock...
Michael McConville
mmcconville at mykolab.com
Wed Jun 24 23:20:21 EDT 2015
Changeset: 5d4a86d3ccca73df3443833879fdd9aafb432b74
Author: Michael McConville <mmcconville at mykolab.com>
Date: 2015-06-24 23:20 -0400
Branch: default
URL: https://hg.pidgin.im/soc/2015/mmcc/main/rev/5d4a86d3ccca
Description:
I misunderstood text_to_stock() - this restores it and updates it to replace Stock Items
diffstat:
pidgin/gtkrequest.c | 72 ++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 55 insertions(+), 17 deletions(-)
diffs (155 lines):
diff --git a/pidgin/gtkrequest.c b/pidgin/gtkrequest.c
--- a/pidgin/gtkrequest.c
+++ b/pidgin/gtkrequest.c
@@ -320,6 +320,39 @@ destroy_multifield_cb(GtkWidget *dialog,
return FALSE;
}
+
+#define STOCK_ITEMIZE(r, l) \
+ if (!strcmp((r), text) || !strcmp(_(r), text)) \
+ return (l);
+
+static const char *
+text_to_stock(const char *text)
+{
+ STOCK_ITEMIZE(N_("Yes"), _("_Yes"));
+ STOCK_ITEMIZE(N_("_Yes"), _("_Yes"));
+ STOCK_ITEMIZE(N_("No"), _("_No"));
+ STOCK_ITEMIZE(N_("_No"), _("_No"));
+ STOCK_ITEMIZE(N_("OK"), _("_OK"));
+ STOCK_ITEMIZE(N_("_OK"), _("_OK"));
+ STOCK_ITEMIZE(N_("Cancel"), _("_Cancel"));
+ STOCK_ITEMIZE(N_("_Cancel"), _("_Cancel"));
+ STOCK_ITEMIZE(N_("Apply"), _("_Apply"));
+ STOCK_ITEMIZE(N_("Close"), _("_Close"));
+ STOCK_ITEMIZE(N_("Delete"), _("_Delete"));
+ STOCK_ITEMIZE(N_("Add"), _("_Add"));
+ STOCK_ITEMIZE(N_("Remove"), _("_Remove"));
+ STOCK_ITEMIZE(N_("Save"), _("_Save"));
+ STOCK_ITEMIZE(N_("Next"), PIDGIN_STOCK_NEXT);
+ STOCK_ITEMIZE(N_("_Next"), PIDGIN_STOCK_NEXT);
+ STOCK_ITEMIZE(N_("Back"), _("_Back"));
+ STOCK_ITEMIZE(N_("_Back"), _("_Back"));
+ STOCK_ITEMIZE(N_("Alias"), PIDGIN_STOCK_ALIAS);
+
+ return text;
+}
+
+#undef STOCK_ITEMIZE
+
static gchar *
pidgin_request_escape(PurpleRequestCommonParameters *cpar, const gchar *text)
{
@@ -479,8 +512,8 @@ static void *
pidgin_request_input(const char *title, const char *primary,
const char *secondary, const char *default_value,
gboolean multiline, gboolean masked, gchar *hint,
- GCallback ok_cb,
- GCallback cancel_cb,
+ const char *ok_text, GCallback ok_cb,
+ const char *cancel_text, GCallback cancel_cb,
PurpleRequestCommonParameters *cpar,
void *user_data)
{
@@ -508,7 +541,7 @@ pidgin_request_input(const char *title,
dialog = gtk_dialog_new_with_buttons(title ? title : PIDGIN_ALERT_TITLE,
NULL, 0,
_("_Cancel"), 1,
- _("_OK"), 0,
+ text_to_stock(ok_text), 0,
NULL);
data->dialog = dialog;
@@ -632,8 +665,8 @@ pidgin_request_input(const char *title,
static void *
pidgin_request_choice(const char *title, const char *primary,
- const char *secondary, gpointer default_value,
- GCallback ok_cb, GCallback cancel_cb,
+ const char *secondary, gpointer default_value, const char *ok_text,
+ GCallback ok_cb, const char *cancel_text, GCallback cancel_cb,
PurpleRequestCommonParameters *cpar, void *user_data, va_list args)
{
PidginRequestData *data;
@@ -666,10 +699,10 @@ pidgin_request_choice(const char *title,
#endif
gtk_dialog_add_button(GTK_DIALOG(dialog),
- _("_Cancel"), 0);
+ text_to_stock(cancel_text), 0);
gtk_dialog_add_button(GTK_DIALOG(dialog),
- _("_OK"), 1);
+ text_to_stock(ok_text), 1);
g_signal_connect(G_OBJECT(dialog), "response",
G_CALLBACK(choice_response_cb), data);
@@ -787,7 +820,7 @@ pidgin_request_action(const char *title,
for (i = 0; i < action_count; i++) {
gtk_dialog_add_button(GTK_DIALOG(dialog),
- buttons[2 * i], i);
+ text_to_stock(buttons[2 * i]), i);
data->cbs[i] = buttons[2 * i + 1];
}
@@ -925,7 +958,7 @@ pidgin_request_wait(const char *title, c
/* Cancel button */
button = pidgin_dialog_add_button(GTK_DIALOG(dialog),
- _("Cancel"), G_CALLBACK(wait_cancel_cb), data);
+ text_to_stock(_("Cancel")), G_CALLBACK(wait_cancel_cb), data);
gtk_widget_set_can_default(button, FALSE);
/* Vertical box */
@@ -1919,8 +1952,8 @@ create_datasheet_field(PurpleRequestFiel
static void *
pidgin_request_fields(const char *title, const char *primary,
- const char *secondary, PurpleRequestFields *fields,
- GCallback ok_cb, GCallback cancel_cb,
+ const char *secondary, PurpleRequestFields *fields, const char *ok_text,
+ GCallback ok_cb, const char *cancel_text, GCallback cancel_cb,
PurpleRequestCommonParameters *cpar, void *user_data)
{
PidginRequestData *data;
@@ -1944,6 +1977,7 @@ pidgin_request_fields(const char *title,
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;
@@ -1989,20 +2023,24 @@ pidgin_request_fields(const char *title,
PurpleRequestFieldsCb *cb = it->next->data;
button = pidgin_dialog_add_button(GTK_DIALOG(win),
- _(label), G_CALLBACK(multifield_extra_cb),
+ text_to_stock(label), G_CALLBACK(multifield_extra_cb),
data);
g_object_set_data(G_OBJECT(button), "extra-cb", cb);
}
/* Cancel button */
- button = pidgin_dialog_add_button(GTK_DIALOG(win), _("_Cancel"), G_CALLBACK(multifield_cancel_cb), data);
+ 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);
/* OK button */
- button = pidgin_dialog_add_button(GTK_DIALOG(win), _("_OK"), 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));
More information about the Commits
mailing list