Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/libpurple/accountopt.c b/libpurple/accountopt.c
- --- a/libpurple/accountopt.c
- +++ b/libpurple/accountopt.c
- @@ -50,10 +50,17 @@
- } default_value;
- - gboolean masked; /**< Whether the value entered should be
- - * obscured from view (for passwords and
- - * similar options)
- - */
- + union
- + {
- + struct
- + {
- + gboolean masked; /**< Whether the value entered should
- + * be obscured from view (for
- + * passwords and similar options)
- + */
- + GList *hints; /**< List of hinted values */
- + } string;
- + } params;
- };
- /**
- @@ -177,6 +184,7 @@
- if (option->type == PURPLE_PREF_STRING)
- {
- g_free(option->default_value.string);
- + g_list_free_full(option->params.string.hints, &g_free);
- }
- else if (option->type == PURPLE_PREF_STRING_LIST)
- {
- @@ -221,14 +229,23 @@
- }
- void
- -purple_account_option_set_masked(PurpleAccountOption *option, gboolean masked)
- +purple_account_option_string_set_masked(PurpleAccountOption *option, gboolean masked)
- {
- g_return_if_fail(option != NULL);
- g_return_if_fail(option->type == PURPLE_PREF_STRING);
- - option->masked = masked;
- + option->params.string.masked = masked;
- }
- +void
- +purple_account_option_string_set_hints(PurpleAccountOption *option, GList *hints)
- +{
- + g_return_if_fail(option != NULL);
- + g_return_if_fail(option->type == PURPLE_PREF_STRING);
- +
- + g_list_free_full(option->params.string.hints, &g_free);
- + option->params.string.hints = hints;
- +}
- void
- purple_account_option_set_list(PurpleAccountOption *option, GList *values)
- @@ -332,12 +349,21 @@
- }
- gboolean
- -purple_account_option_get_masked(const PurpleAccountOption *option)
- +purple_account_option_string_get_masked(const PurpleAccountOption *option)
- {
- g_return_val_if_fail(option != NULL, FALSE);
- g_return_val_if_fail(option->type == PURPLE_PREF_STRING, FALSE);
- - return option->masked;
- + return option->params.string.masked;
- +}
- +
- +const GList *
- +purple_account_option_string_get_hints(const PurpleAccountOption *option)
- +{
- + g_return_val_if_fail(option != NULL, FALSE);
- + g_return_val_if_fail(option->type == PURPLE_PREF_STRING, FALSE);
- +
- + return option->params.string.hints;
- }
- GList *
- diff --git a/libpurple/accountopt.h b/libpurple/accountopt.h
- --- a/libpurple/accountopt.h
- +++ b/libpurple/accountopt.h
- @@ -158,7 +158,19 @@
- * @param masked The masking.
- */
- void
- -purple_account_option_set_masked(PurpleAccountOption *option, gboolean masked);
- +purple_account_option_string_set_masked(PurpleAccountOption *option, gboolean masked);
- +
- +/**
- + * Sets the hint list for an account option.
- + *
- + * The list passed will be owned by the account option, and the
- + * strings inside will be freed automatically.
- + *
- + * @param option The account option.
- + * @param hints The list of hints, stored as strings.
- + */
- +void purple_account_option_string_set_hints(PurpleAccountOption *option,
- + GList *hints);
- /**
- * Sets the list values for an account option.
- @@ -261,7 +273,16 @@
- * @return %TRUE if the option's value should be obscured.
- */
- gboolean
- -purple_account_option_get_masked(const PurpleAccountOption *option);
- +purple_account_option_string_get_masked(const PurpleAccountOption *option);
- +
- +/**
- + * Returns the list of hints for an account option.
- + *
- + * @param option The account option.
- + *
- + * @constreturn A list of hints, stored as strings.
- + */
- +const GList * purple_account_option_string_get_hints(const PurpleAccountOption *option);
- /**
- * Returns the list values for an account option.
- diff --git a/libpurple/protocols/gg/gg.c b/libpurple/protocols/gg/gg.c
- --- a/libpurple/protocols/gg/gg.c
- +++ b/libpurple/protocols/gg/gg.c
- @@ -2136,12 +2136,19 @@
- {
- PurpleAccountOption *option;
- GList *encryption_options = NULL;
- + GList *server_hints = NULL;
- purple_debug_info("gg", "Loading Gadu-Gadu protocol plugin with "
- "libgadu %s...\n", gg_libgadu_version());
- + server_hints = g_list_append(server_hints, g_strdup("hint1"));
- + server_hints = g_list_append(server_hints, g_strdup("hint2"));
- + server_hints = g_list_append(server_hints, g_strdup("hint3"));
- + server_hints = g_list_append(server_hints, g_strdup("hint4"));
- +
- option = purple_account_option_string_new(_("GG server"),
- "gg_server", "");
- + purple_account_option_string_set_hints(option, server_hints);
- prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
- option);
- diff --git a/pidgin/gtkaccount.c b/pidgin/gtkaccount.c
- --- a/pidgin/gtkaccount.c
- +++ b/pidgin/gtkaccount.c
- @@ -812,6 +812,7 @@
- const char *str_value;
- gboolean bool_value;
- ProtocolOptEntry *opt_entry;
- + const GList *str_hints;
- if (dialog->protocol_frame != NULL) {
- gtk_notebook_remove_page (GTK_NOTEBOOK(dialog->notebook), 1);
- @@ -912,8 +913,25 @@
- purple_account_option_get_default_string(option));
- }
- - opt_entry->widget = entry = gtk_entry_new();
- - if (purple_account_option_get_masked(option))
- + str_hints = purple_account_option_string_get_hints(option);
- + if (str_hints)
- + {
- + const GList *hint_it = str_hints;
- + entry = gtk_combo_box_entry_new_text();
- + while (hint_it)
- + {
- + const gchar *hint = hint_it->data;
- + hint_it = g_list_next(hint_it);
- + gtk_combo_box_append_text(GTK_COMBO_BOX(entry), hint);
- + }
- + }
- + else
- + entry = gtk_entry_new();
- +
- + opt_entry->widget = entry;
- + if (purple_account_option_string_get_masked(option) && str_hints)
- + g_warn_if_reached();
- + else if (purple_account_option_string_get_masked(option))
- {
- gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
- #if !GTK_CHECK_VERSION(2,16,0)
- @@ -922,7 +940,9 @@
- #endif /* Less than GTK+ 2.16 */
- }
- - if (str_value != NULL)
- + if (str_value != NULL && str_hints)
- + gtk_entry_set_text(GTK_ENTRY(GTK_BIN(entry)->child), str_value);
- + else
- gtk_entry_set_text(GTK_ENTRY(entry), str_value);
- title = g_strdup_printf("_%s:",
- @@ -1453,7 +1473,10 @@
- switch (opt_entry->type) {
- case PURPLE_PREF_STRING:
- - value = gtk_entry_get_text(GTK_ENTRY(opt_entry->widget));
- + if (GTK_IS_COMBO_BOX(opt_entry->widget))
- + value = gtk_combo_box_get_active_text(GTK_COMBO_BOX(opt_entry->widget));
- + else
- + value = gtk_entry_get_text(GTK_ENTRY(opt_entry->widget));
- purple_account_set_string(account, opt_entry->setting, value);
- break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement