/cpw/tomkiewicz/masterpassword: 13be8e0a1bd0: Add keyring settin...

Tomasz Wasilczyk tomkiewicz at cpw.pidgin.im
Sat May 11 13:07:06 EDT 2013


Changeset: 13be8e0a1bd030db31bc6b12575c0201acb8d286
Author:	 Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date:	 2013-05-11 19:06 +0200
Branch:	 soc.2008.masterpassword
URL: https://hg.pidgin.im/cpw/tomkiewicz/masterpassword/rev/13be8e0a1bd0

Description:

Add keyring settings to finch

diffstat:

 finch/gntprefs.c |  43 ++++++++++++++++++++++++++++++++++++++++++-
 finch/gntprefs.h |   5 +++++
 finch/gntui.c    |   1 +
 3 files changed, 48 insertions(+), 1 deletions(-)

diffs (97 lines):

diff --git a/finch/gntprefs.c b/finch/gntprefs.c
--- a/finch/gntprefs.c
+++ b/finch/gntprefs.c
@@ -1,7 +1,6 @@
 /**
  * @file gntprefs.c GNT Preferences API
  * @ingroup finch
- * @todo: add support for master password changing.
  */
 
 /* finch
@@ -42,6 +41,7 @@ static struct {
 	GList *freestrings;  /* strings to be freed when the pref-window is closed */
 	gboolean showing;
 	GntWidget *window;
+	GntWidget *keyring_window;
 } pref_request;
 
 void finch_prefs_init()
@@ -253,6 +253,10 @@ void finch_prefs_show_all()
 		return;
 	}
 
+	if (pref_request.keyring_window != NULL)
+		purple_request_close(PURPLE_REQUEST_FIELDS,
+			pref_request.keyring_window);
+
 	fields = purple_request_fields_new();
 
 	add_pref_group(fields, _("Buddy List"), blist);
@@ -268,3 +272,40 @@ void finch_prefs_show_all()
 			NULL);
 }
 
+static void
+finch_prefs_keyring_save(void *data, PurpleRequestFields *fields)
+{
+	pref_request.keyring_window = NULL;
+
+	purple_keyring_apply_settings(NULL, fields);
+}
+
+static void
+finch_prefs_keyring_cancel(void)
+{
+	pref_request.keyring_window = NULL;
+}
+
+void finch_prefs_show_keyring(void)
+{
+	PurpleRequestFields *fields;
+
+	if (pref_request.keyring_window != NULL) {
+		gnt_window_present(pref_request.keyring_window);
+		return;
+	}
+
+	fields = purple_keyring_read_settings();
+	if (fields == NULL) {
+		purple_notify_info(NULL, _("Keyring settings"),
+			_("Selected keyring doesn't allow any configuration"),
+			NULL);
+		return;
+	}
+
+	pref_request.keyring_window = purple_request_fields(NULL,
+		_("Keyring settings"), NULL, NULL, fields,
+		_("Save"), G_CALLBACK(finch_prefs_keyring_save),
+		_("Cancel"), G_CALLBACK(finch_prefs_keyring_cancel),
+		NULL, NULL, NULL, NULL);
+}
diff --git a/finch/gntprefs.h b/finch/gntprefs.h
--- a/finch/gntprefs.h
+++ b/finch/gntprefs.h
@@ -42,6 +42,11 @@ void finch_prefs_init(void);
 void finch_prefs_show_all(void);
 
 /**
+ * Show the preferences dialog for the selected keyring.
+ */
+void finch_prefs_show_keyring(void);
+
+/**
  * You don't need to know about this.
  */
 void finch_prefs_update_old(void);
diff --git a/finch/gntui.c b/finch/gntui.c
--- a/finch/gntui.c
+++ b/finch/gntui.c
@@ -106,6 +106,7 @@ void gnt_ui_init()
 	gnt_register_action(_("Room List"), finch_roomlist_show_all);
 	gnt_register_action(_("Sounds"), finch_sounds_show_all);
 	gnt_register_action(_("Preferences"), finch_prefs_show_all);
+	gnt_register_action(_("Keyring settings"), finch_prefs_show_keyring);
 	gnt_register_action(_("Statuses"), finch_savedstatus_show_all);
 
 #ifdef STANDALONE



More information about the Commits mailing list