/pidgin/main: 43e91cccb4da: GTK Request: better html support
Tomasz Wasilczyk
twasilczyk at pidgin.im
Tue Sep 17 12:20:08 EDT 2013
Changeset: 43e91cccb4da0f52a8113fad4226b94a4d63944b
Author: Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date: 2013-09-17 18:20 +0200
Branch: default
URL: https://hg.pidgin.im/pidgin/main/rev/43e91cccb4da
Description:
GTK Request: better html support
diffstat:
libpurple/request.c | 31 +++++++++++++++++++++++++++++++
pidgin/gtkrequest.c | 19 +++++++++++++------
2 files changed, 44 insertions(+), 6 deletions(-)
diffs (115 lines):
diff --git a/libpurple/request.c b/libpurple/request.c
--- a/libpurple/request.c
+++ b/libpurple/request.c
@@ -2099,6 +2099,31 @@ purple_request_wait(void *handle, const
cancel_cb ? 1 : 0, _("Cancel"), cancel_cb);
}
+static void
+purple_request_fields_strip_html(PurpleRequestFields *fields)
+{
+ GList *itg;
+
+ for (itg = fields->groups; itg != NULL; itg = g_list_next(itg)) {
+ PurpleRequestFieldGroup *group = itg->data;
+ GList *itf;
+
+ for (itf = group->fields; itf != NULL; itf = g_list_next(itf)) {
+ PurpleRequestField *field = itf->data;
+ gchar *new_label;
+
+ new_label = purple_request_strip_html_custom(
+ field->label);
+ if (g_strcmp0(new_label, field->label) == 0) {
+ g_free(new_label);
+ continue;
+ }
+ g_free(field->label);
+ field->label = new_label;
+ }
+ }
+}
+
void *
purple_request_fields(void *handle, const char *title, const char *primary,
const char *secondary, PurpleRequestFields *fields, const char *ok_text,
@@ -2120,6 +2145,12 @@ purple_request_fields(void *handle, cons
ops = purple_request_get_ui_ops();
+ if (purple_request_cpar_is_html(cpar) &&
+ !((ops->features & PURPLE_REQUEST_FEATURE_HTML)))
+ {
+ purple_request_fields_strip_html(fields);
+ }
+
if (ops != NULL && ops->request_fields != NULL) {
PurpleRequestInfo *info;
gchar **tmp;
diff --git a/pidgin/gtkrequest.c b/pidgin/gtkrequest.c
--- a/pidgin/gtkrequest.c
+++ b/pidgin/gtkrequest.c
@@ -1068,12 +1068,16 @@ create_int_field(PurpleRequestField *fie
}
static GtkWidget *
-create_bool_field(PurpleRequestField *field)
+create_bool_field(PurpleRequestField *field,
+ PurpleRequestCommonParameters *cpar)
{
GtkWidget *widget;
+ gchar *label;
- widget = gtk_check_button_new_with_label(
+ label = pidgin_request_escape(cpar,
purple_request_field_get_label(field));
+ widget = gtk_check_button_new_with_label(label);
+ g_free(label);
gtk_widget_set_tooltip_text(widget, purple_request_field_get_tooltip(field));
@@ -1630,7 +1634,7 @@ pidgin_request_fields(const char *title,
size_t col_offset = col_num * 2;
PurpleRequestFieldType type;
GtkWidget *widget = NULL;
- const char *field_label;
+ gchar *field_label;
label = NULL;
field = fl->data;
@@ -1641,14 +1645,16 @@ pidgin_request_fields(const char *title,
}
type = purple_request_field_get_type(field);
- field_label = purple_request_field_get_label(field);
+ field_label = pidgin_request_escape(cpar,
+ purple_request_field_get_label(field));
if (type != PURPLE_REQUEST_FIELD_BOOLEAN && field_label)
{
char *text = NULL;
if (field_label[strlen(field_label) - 1] != ':' &&
- field_label[strlen(field_label) - 1] != '?')
+ field_label[strlen(field_label) - 1] != '?' &&
+ type != PURPLE_REQUEST_FIELD_LABEL)
{
text = g_strdup_printf("%s:", field_label);
}
@@ -1684,6 +1690,7 @@ pidgin_request_fields(const char *title,
}
gtk_widget_show(label);
+ g_free(field_label);
}
widget = GTK_WIDGET(purple_request_field_get_ui_data(field));
@@ -1694,7 +1701,7 @@ pidgin_request_fields(const char *title,
else if (type == PURPLE_REQUEST_FIELD_INTEGER)
widget = create_int_field(field);
else if (type == PURPLE_REQUEST_FIELD_BOOLEAN)
- widget = create_bool_field(field);
+ widget = create_bool_field(field, cpar);
else if (type == PURPLE_REQUEST_FIELD_CHOICE)
widget = create_choice_field(field, cpar);
else if (type == PURPLE_REQUEST_FIELD_LIST)
More information about the Commits
mailing list