/pidgin/main: c3ee96290bfd: Account Options: hinted string optio...
Tomasz Wasilczyk
tomkiewicz at cpw.pidgin.im
Tue Aug 14 16:04:56 EDT 2012
Changeset: c3ee96290bfd71415bfaf2e0cc8dae8221995423
Author: Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date: 2012-08-14 22:05 +0200
Branch: default
URL: http://hg.pidgin.im/pidgin/main/rev/c3ee96290bfd
Description:
Account Options: hinted string options; fix perl plugins compilation
diffstat:
libpurple/accountopt.c | 42 ++++++++++++++++++++++-----
libpurple/accountopt.h | 25 +++++++++++++++-
libpurple/plugins/perl/common/AccountOpts.xs | 4 +-
pidgin/gtkaccount.c | 31 ++++++++++++++++++--
pidgin/plugins/perl/common/Makefile.PL.in | 2 +-
5 files changed, 87 insertions(+), 17 deletions(-)
diffs (220 lines):
diff --git a/libpurple/accountopt.c b/libpurple/accountopt.c
--- a/libpurple/accountopt.c
+++ b/libpurple/accountopt.c
@@ -50,10 +50,17 @@ struct _PurpleAccountOption
} 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)
+ */
+ GSList *hints; /**< List of hinted values */
+ } string;
+ } params;
};
/**
@@ -177,6 +184,7 @@ purple_account_option_destroy(PurpleAcco
if (option->type == PURPLE_PREF_STRING)
{
g_free(option->default_value.string);
+ g_slist_free_full(option->params.string.hints, &g_free);
}
else if (option->type == PURPLE_PREF_STRING_LIST)
{
@@ -221,14 +229,23 @@ purple_account_option_set_default_string
}
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, GSList *hints)
+{
+ g_return_if_fail(option != NULL);
+ g_return_if_fail(option->type == PURPLE_PREF_STRING);
+
+ g_slist_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 @@ purple_account_option_get_default_list_v
}
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 GSList *
+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 @@ void purple_account_option_set_default_s
* @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,
+ GSList *hints);
/**
* Sets the list values for an account option.
@@ -261,7 +273,16 @@ const char *purple_account_option_get_de
* @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 GSList * purple_account_option_string_get_hints(const PurpleAccountOption *option);
/**
* Returns the list values for an account option.
diff --git a/libpurple/plugins/perl/common/AccountOpts.xs b/libpurple/plugins/perl/common/AccountOpts.xs
--- a/libpurple/plugins/perl/common/AccountOpts.xs
+++ b/libpurple/plugins/perl/common/AccountOpts.xs
@@ -102,7 +102,7 @@ purple_account_option_get_type(option)
Purple::Account::Option option
gboolean
-purple_account_option_get_masked(option)
+purple_account_option_string_get_masked(option)
Purple::Account::Option option
int
@@ -138,7 +138,7 @@ PPCODE:
purple_account_option_set_list(option, t_GL);
void
-purple_account_option_set_masked(option, masked)
+purple_account_option_string_set_masked(option, masked)
Purple::Account::Option option
gboolean masked
diff --git a/pidgin/gtkaccount.c b/pidgin/gtkaccount.c
--- a/pidgin/gtkaccount.c
+++ b/pidgin/gtkaccount.c
@@ -812,6 +812,7 @@ add_protocol_options(AccountPrefsDialog
const char *str_value;
gboolean bool_value;
ProtocolOptEntry *opt_entry;
+ const GSList *str_hints;
if (dialog->protocol_frame != NULL) {
gtk_notebook_remove_page (GTK_NOTEBOOK(dialog->notebook), 1);
@@ -912,8 +913,25 @@ add_protocol_options(AccountPrefsDialog
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 GSList *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 @@ add_protocol_options(AccountPrefsDialog
#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 @@ ok_account_prefs_cb(GtkWidget *w, Accoun
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;
diff --git a/pidgin/plugins/perl/common/Makefile.PL.in b/pidgin/plugins/perl/common/Makefile.PL.in
--- a/pidgin/plugins/perl/common/Makefile.PL.in
+++ b/pidgin/plugins/perl/common/Makefile.PL.in
@@ -10,7 +10,7 @@ WriteMakefile(
'AUTHOR' => 'Pidgin <http://pidgin.im/>') : ()),
'DEFINE' => '@DEBUG_CFLAGS@',
'dynamic_lib' => { 'OTHERLDFLAGS' => '@LDFLAGS@' },
- 'INC' => '-I. -I at srcdir@ -I at top_srcdir@ -I at top_srcdir@/libpurple -I at top_srcdir@/pidgin @GTK_CFLAGS@',
+ 'INC' => '-I. -I at srcdir@ -I at top_srcdir@ -I at top_srcdir@/libpurple -I at top_srcdir@/pidgin @GTK_CFLAGS@ @WEBKIT_CFLAGS@',
'OBJECT' => '$(O_FILES)', # link all the C files too
'TYPEMAPS' => ["@top_srcdir@/libpurple/plugins/perl/common/typemap"],
# 'OPTIMIZE' => '-g', # For debugging.
More information about the Commits
mailing list