summaryrefslogtreecommitdiff
path: root/pidgin/gtkrequest.c
diff options
context:
space:
mode:
authorGary Kramlich <grim@reaperworld.com>2020-04-09 08:47:36 +0000
committerGary Kramlich <grim@reaperworld.com>2020-04-09 08:47:36 +0000
commitf6dc1787c484ac7638ed3d065259b25dc69e6d12 (patch)
treef507fbef6420fe8906e3a19668c51f9bc3146496 /pidgin/gtkrequest.c
parentd283fc516d4219aee8b82edc75cd7baf10781da9 (diff)
parent3b33db913afd34961221f5b5c1869b5f2c16b9f6 (diff)
downloadpidgin-f6dc1787c484ac7638ed3d065259b25dc69e6d12.tar.gz
Merged in default (pull request #652)
Use structs instead of adjacent name-value GList elements Approved-by: Elliott Sales de Andrade Approved-by: Gary Kramlich
Diffstat (limited to 'pidgin/gtkrequest.c')
-rw-r--r--pidgin/gtkrequest.c52
1 files changed, 17 insertions, 35 deletions
diff --git a/pidgin/gtkrequest.c b/pidgin/gtkrequest.c
index 8e2c17371b..197eadbf86 100644
--- a/pidgin/gtkrequest.c
+++ b/pidgin/gtkrequest.c
@@ -1221,8 +1221,7 @@ create_choice_field(PurpleRequestField *field,
{
GtkWidget *widget;
GList *elements = purple_request_field_choice_get_elements(field);
- int num_labels = g_list_length(elements) / 2;
- GList *l;
+ guint num_labels = g_list_length(elements);
gpointer *values = g_new(gpointer, num_labels);
gpointer default_value;
gboolean default_found = FALSE;
@@ -1235,23 +1234,16 @@ create_choice_field(PurpleRequestField *field,
widget = gtk_combo_box_text_new();
i = 0;
- l = elements;
- while (l != NULL)
+ for (GList *l = elements; l != NULL; l = g_list_next(l))
{
- const char *text;
- gpointer *value;
-
- text = l->data;
- l = g_list_next(l);
- value = l->data;
- l = g_list_next(l);
+ PurpleKeyValuePair *choice = l->data;
- gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), text);
- if (value == default_value) {
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), choice->key);
+ if (choice->value == default_value) {
default_index = i;
default_found = TRUE;
}
- values[i++] = value;
+ values[i++] = choice->value;
}
gtk_combo_box_set_active(GTK_COMBO_BOX(widget), default_index);
@@ -1277,29 +1269,22 @@ create_choice_field(PurpleRequestField *field,
gtk_widget_set_tooltip_text(widget, purple_request_field_get_tooltip(field));
i = 0;
- l = elements;
- while (l != NULL)
+ for (GList *l = elements; l != NULL; l = g_list_next(l))
{
- const char *text;
- gpointer *value;
-
- text = l->data;
- l = g_list_next(l);
- value = l->data;
- l = g_list_next(l);
+ PurpleKeyValuePair *choice = l->data;
radio = gtk_radio_button_new_with_label_from_widget(
- GTK_RADIO_BUTTON(first_radio), text);
+ GTK_RADIO_BUTTON(first_radio), choice->key);
g_object_set_data(G_OBJECT(radio), "box", box);
if (first_radio == NULL)
first_radio = radio;
- if (value == default_value) {
+ if (choice->value == default_value) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio), TRUE);
default_found = TRUE;
}
- values[i++] = value;
+ values[i++] = choice->value;
gtk_box_pack_start(GTK_BOX(box), radio, TRUE, TRUE, 0);
gtk_widget_show(radio);
@@ -1884,8 +1869,8 @@ pidgin_request_fields(const char *title, const char *primary,
char *label_text;
char *primary_esc, *secondary_esc;
const gboolean compact = purple_request_cpar_is_compact(cpar);
- GSList *extra_actions, *it;
- size_t extra_actions_count, i;
+ GSList *extra_actions;
+ size_t i;
const gchar **tab_names;
guint tab_count;
gboolean ok_btn = (ok_text != NULL);
@@ -1898,7 +1883,6 @@ pidgin_request_fields(const char *title, const char *primary,
purple_request_fields_set_ui_data(fields, data);
extra_actions = purple_request_cpar_get_extra_actions(cpar);
- extra_actions_count = g_slist_length(extra_actions) / 2;
data->cb_count = 2;
data->cbs = g_new0(GCallback, 2);
@@ -1929,14 +1913,12 @@ pidgin_request_fields(const char *title, const char *primary,
pidgin_request_add_help(GTK_DIALOG(win), cpar);
- it = extra_actions;
- for (i = 0; i < extra_actions_count; i++, it = it->next->next) {
- const gchar *label = it->data;
- PurpleRequestFieldsCb *cb = it->next->data;
+ for (GSList *it = extra_actions; it != NULL; it = it->next) {
+ PurpleKeyValuePair *extra_action = it->data;
- button = pidgin_dialog_add_button(GTK_DIALOG(win), label,
+ button = pidgin_dialog_add_button(GTK_DIALOG(win), extra_action->key,
G_CALLBACK(multifield_extra_cb), data);
- g_object_set_data(G_OBJECT(button), "extra-cb", cb);
+ g_object_set_data(G_OBJECT(button), "extra-cb", extra_action->value);
}
/* Cancel button */