changeset 9841:1ae82c0c24ee

[gaim-migrate @ 10718] "adds a masked string type to plugin prefs" from Gary Kramlich committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 23 Aug 2004 22:06:19 +0000
parents e8caffe42e38
children 595a2fb511b9
files plugins/pluginpref_example.c src/gtkpluginpref.c src/pluginpref.c src/pluginpref.h
diffstat 4 files changed, 40 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/pluginpref_example.c	Mon Aug 23 21:59:27 2004 +0000
+++ b/plugins/pluginpref_example.c	Mon Aug 23 22:06:19 2004 +0000
@@ -80,6 +80,12 @@
 	gaim_plugin_pref_frame_add(frame, ppref);
 
 	ppref = gaim_plugin_pref_new_with_name_and_label(
+								"/plugins/core/pluginpref_example/masked_string",
+								"masked string");
+	gaim_plugin_pref_set_masked(ppref, TRUE);
+	gaim_plugin_pref_frame_add(frame, ppref);
+
+	ppref = gaim_plugin_pref_new_with_name_and_label(
 							"/plugins/core/pluginpref_example/max_string",
 							"string pref\n(max length of 16)");
 	gaim_plugin_pref_set_max_length(ppref, 16);
@@ -144,6 +150,7 @@
 							"string");
 	gaim_prefs_add_string("/plugins/core/pluginpref_example/max_string",
 							"max length string");
+	gaim_prefs_add_string("/plugins/core/pluginpref_example/masked_string", "masked");
 	gaim_prefs_add_string("/plugins/core/pluginpref_example/string_choice", "red");
 }
 
--- a/src/gtkpluginpref.c	Mon Aug 23 21:59:27 2004 +0000
+++ b/src/gtkpluginpref.c	Mon Aug 23 22:06:19 2004 +0000
@@ -78,6 +78,8 @@
 			gtk_entry_set_text(GTK_ENTRY(entry), gaim_prefs_get_string(pref_name));
 			gtk_entry_set_max_length(GTK_ENTRY(entry),
 									 gaim_plugin_pref_get_max_length(pref));
+			gtk_entry_set_visibility(GTK_ENTRY(entry),
+									 !gaim_plugin_pref_get_masked(pref));
 			g_signal_connect(G_OBJECT(entry), "changed",
 							 G_CALLBACK(entry_cb),
 							 (gpointer)pref_name);
--- a/src/pluginpref.c	Mon Aug 23 21:59:27 2004 +0000
+++ b/src/pluginpref.c	Mon Aug 23 22:06:19 2004 +0000
@@ -44,6 +44,7 @@
 	int max;
 	GList *choices;
 	unsigned int max_length;
+	gboolean masked;
 };
 
 GaimPluginPrefFrame *
@@ -278,3 +279,17 @@
 
 	return pref->max_length;
 }
+
+void
+gaim_plugin_pref_set_masked(GaimPluginPref *pref, gboolean masked) {
+	g_return_if_fail(pref);
+
+	pref->masked = masked;
+}
+
+gboolean
+gaim_plugin_pref_get_masked(GaimPluginPref *pref) {
+	g_return_val_if_fail(pref, FALSE);
+
+	return pref->masked;
+}
--- a/src/pluginpref.h	Mon Aug 23 21:59:27 2004 +0000
+++ b/src/pluginpref.h	Mon Aug 23 22:06:19 2004 +0000
@@ -215,6 +215,22 @@
  */
 unsigned int gaim_plugin_pref_get_max_length(GaimPluginPref *pref);
 
+/**
+ * Sets the masking of a string plugin pref
+ *
+ * @param pref   The plugin pref
+ * @param masked The value to set
+ */
+void gaim_plugin_pref_set_masked(GaimPluginPref *pref, gboolean mask);
+
+/**
+ * Gets the masking of a string plugin pref
+ *
+ * @param pref The plugin pref
+ * @return The masking
+ */
+gboolean gaim_plugin_pref_get_masked(GaimPluginPref *pref);
+
 /*@}*/
 
 #ifdef __cplusplus