[seahorse: 1/4] Port to GSettings instead of GConf
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seahorse: 1/4] Port to GSettings instead of GConf
- Date: Tue, 2 Aug 2011 08:47:08 +0000 (UTC)
commit 140bfe64528ae740b7d372a5d8c23439de2ac864
Author: Stef Walter <stefw collabora co uk>
Date: Wed Jul 27 15:08:51 2011 +0200
Port to GSettings instead of GConf
* Depends on recent change in gnome-keyring schemas.
* Some minor fixes and cleanup along with the gsettings port.
https://bugzilla.gnome.org/show_bug.cgi?id=622401
.gitignore | 1 +
configure.ac | 6 +-
data/Makefile.am | 32 +--
data/org.gnome.seahorse.convert | 6 +
data/org.gnome.seahorse.gschema.xml | 29 ++
data/org.gnome.seahorse.manager.convert | 6 +
data/org.gnome.seahorse.manager.gschema.xml | 29 ++
data/org.gnome.seahorse.window.gschema.xml | 14 +
data/seahorse.schemas.in | 211 -------------
libseahorse/Makefile.am | 2 -
libseahorse/seahorse-add-keyserver.xml | 3 +-
libseahorse/seahorse-check-button-control.c | 63 ----
libseahorse/seahorse-check-button-control.h | 34 --
libseahorse/seahorse-combo-keys.c | 1 -
libseahorse/seahorse-context.c | 291 +++++++++---------
libseahorse/seahorse-context.h | 4 +
libseahorse/seahorse-dns-sd.c | 64 ++---
libseahorse/seahorse-dns-sd.h | 6 +-
libseahorse/seahorse-gconf.c | 439 ---------------------------
libseahorse/seahorse-gconf.h | 85 -----
libseahorse/seahorse-keyserver-control.c | 178 +++++------
libseahorse/seahorse-keyserver-control.h | 11 +-
libseahorse/seahorse-prefs.c | 218 ++++++--------
libseahorse/seahorse-servers.c | 63 ++--
libseahorse/seahorse-servers.h | 5 +-
libseahorse/seahorse-set.c | 25 +-
libseahorse/seahorse-util.c | 1 -
libseahorse/seahorse-widget.c | 129 +++-----
libseahorse/seahorse-widget.h | 1 +
pgp/seahorse-gpgme-sign.c | 3 +-
pgp/seahorse-hkp-source.c | 116 +++++---
pgp/seahorse-pgp-key-properties.c | 1 -
pgp/seahorse-pgp-keysets.c | 18 +-
pgp/seahorse-signer.c | 12 +-
pkcs11/seahorse-pkcs11-module.c | 13 +-
src/seahorse-key-manager-store.c | 179 ++++++------
src/seahorse-key-manager-store.h | 3 +-
src/seahorse-key-manager.c | 69 ++---
src/seahorse-keyserver-results.c | 12 +-
src/seahorse-keyserver-search.c | 429 +++++++++++++-------------
src/seahorse-keyserver-sync.c | 113 ++++----
src/seahorse-preferences.c | 2 -
42 files changed, 1067 insertions(+), 1860 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 1a811a8..2c1fa72 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,7 @@
~*
tmp-*
*~
+*.valid
/configure.lineno
/Makefile
diff --git a/configure.ac b/configure.ac
index f387c42..908e2a7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7,6 +7,8 @@ dnl MAIN SEAHORSE VERSION (update after release)
AC_INIT(seahorse, 3.1.5)
+GCR_REQUIRED=3.1.5
+
dnl ****************************************************************************
AC_CONFIG_SRCDIR(src/seahorse-main.c)
@@ -42,6 +44,8 @@ AC_SUBST(GTK_LIBS)
PKG_CHECK_MODULES(SEAHORSE, gmodule-2.0 gio-2.0 gconf-2.0 gthread-2.0 gtk+-3.0 >= $GTK_REQUIRED)
+GLIB_GSETTINGS
+
AC_MSG_CHECKING([for some Win32 platform])
case "$host" in
*-*-cygwin*|*-*-mingw*)
@@ -382,7 +386,7 @@ if test "$enable_pkcs11" = "no"; then
echo "disabling pkcs11 support"
enable_pkcs11="no"
else
- PKG_CHECK_MODULES(GCR, gcr-3 >= 3.0.0, gcr_is_present="yes", gcr_is_present="no")
+ PKG_CHECK_MODULES(GCR, gcr-3 >= $GCR_REQUIRED, gcr_is_present="yes", gcr_is_present="no")
if test "$gcr_is_present" = "no"; then
echo "disabling pkcs11 support"
fi
diff --git a/data/Makefile.am b/data/Makefile.am
index aaaada5..2ac0da6 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,24 +1,20 @@
SUBDIRS = icons
- INTLTOOL_SCHEMAS_RULE@
-schemasdir = $(GCONF_SCHEMA_FILE_DIR)
-schemas_in_files = seahorse.schemas.in
-schemas_DATA = $(schemas_in_files:.schemas.in=.schemas)
+gsettings_SCHEMAS = \
+ org.gnome.seahorse.gschema.xml \
+ org.gnome.seahorse.manager.gschema.xml \
+ org.gnome.seahorse.window.gschema.xml
-if GCONF_SCHEMAS_INSTALL
-install-data-local:
- @GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) gconftool-2 \
- --makefile-install-rule $(schemas_DATA) || \
- (echo ;\
- echo "*****************************************************"; \
- echo "Installation of schemas failed, install them manually"; \
- echo "*****************************************************";)
- @true
-else
-install-data-local:
-endif
+ GSETTINGS_RULES@
-EXTRA_DIST = $(schemas_in_files)
+convert_DATA = \
+ org.gnome.seahorse.convert \
+ org.gnome.seahorse.manager.convert
-CLEANFILES = $(schemas_DATA)
+convertdir = \
+ $(datarootdir)/GConf/gsettings
+
+EXTRA_DIST = \
+ $(convert_DATA) \
+ $(gsettings_SCHEMAS)
\ No newline at end of file
diff --git a/data/org.gnome.seahorse.convert b/data/org.gnome.seahorse.convert
new file mode 100644
index 0000000..9a2e3f7
--- /dev/null
+++ b/data/org.gnome.seahorse.convert
@@ -0,0 +1,6 @@
+[org.gnome.seahorse]
+server-auto-retrieve = /desktop/pgp/keyservers/auto_retrieve
+server-auto-publish = /desktop/pgp/keyservers/auto_sync
+server-publish-to = /desktop/pgp/keyservers/publish_to
+last-search-text = /desktop/pgp/keyservers/search_text
+last-search-servers = /desktop/pgp/keyservers/search_keyservers
\ No newline at end of file
diff --git a/data/org.gnome.seahorse.gschema.xml b/data/org.gnome.seahorse.gschema.xml
new file mode 100644
index 0000000..67ff15d
--- /dev/null
+++ b/data/org.gnome.seahorse.gschema.xml
@@ -0,0 +1,29 @@
+<schemalist>
+ <schema id="org.gnome.seahorse" path="/apps/seahorse/">
+ <key name="server-auto-retrieve" type="b">
+ <default>false</default>
+ <summary>Auto retrieve keys</summary>
+ <description>Whether or not keys should be automatically retrieved from key servers.</description>
+ </key>
+ <key name="server-auto-publish" type="b">
+ <default>false</default>
+ <summary>Auto publish keys</summary>
+ <description>Whether or not modified keys should be automatically published.</description>
+ </key>
+ <key name="server-publish-to" type="s">
+ <default>''</default>
+ <summary>Publish keys to this key server</summary>
+ <description>The key server to publish PGP keys to. Or empty to suppress publishing of PGP keys.</description>
+ </key>
+ <key name="last-search-text" type="s">
+ <default>''</default>
+ <summary>Last key server search pattern</summary>
+ <description>The last search pattern searched for against a key server.</description>
+ </key>
+ <key name="last-search-servers" type="as">
+ <default>[]</default>
+ <summary>Last key servers used</summary>
+ <description>The last key server a search was performed against or empty for all key servers.</description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/data/org.gnome.seahorse.manager.convert b/data/org.gnome.seahorse.manager.convert
new file mode 100644
index 0000000..c914854
--- /dev/null
+++ b/data/org.gnome.seahorse.manager.convert
@@ -0,0 +1,6 @@
+[org.gnome.crypto.pgp]
+show-validity = /apps/seahorse/listing/show_validity
+show-expiry = /apps/seahorse/listing/show_expires
+show-trust = /apps/seahorse/listing/show_trust
+show-type = /apps/seahorse/listing/show_type
+sort-by = /apps/seahorse/listing/sort_by
\ No newline at end of file
diff --git a/data/org.gnome.seahorse.manager.gschema.xml b/data/org.gnome.seahorse.manager.gschema.xml
new file mode 100644
index 0000000..76d5c50
--- /dev/null
+++ b/data/org.gnome.seahorse.manager.gschema.xml
@@ -0,0 +1,29 @@
+<schemalist>
+ <schema id="org.gnome.seahorse.manager" path="/apps/seahorse/listing/">
+ <key name="show-validity" type="b">
+ <default>false</default>
+ <summary>Show validity column</summary>
+ <description>Controls the visibility of the expires column for the key manager.</description>
+ </key>
+ <key name="show-expiry" type="b">
+ <default>false</default>
+ <summary>Show expiry column</summary>
+ <description>Controls the visibility of the expiry column for the key manager.</description>
+ </key>
+ <key name="show-trust" type="b">
+ <default>false</default>
+ <summary>Show trust column</summary>
+ <description>Controls the visibility of the trust column for the key manager.</description>
+ </key>
+ <key name="show-type" type="b">
+ <default>false</default>
+ <summary>Show type column</summary>
+ <description>Controls the visibility of the type column for the key manager.</description>
+ </key>
+ <key name="sort-by" type="s">
+ <default>'name'</default>
+ <summary>The column to sort the seahorse keys by</summary>
+ <description>Specify the column to sort the seahorse key manager main window by. Columns are: 'name', 'id', 'validity', 'expires', 'trust', and 'type'. Put a '-' in front of the column name to sort in descending order.</description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/data/org.gnome.seahorse.window.gschema.xml b/data/org.gnome.seahorse.window.gschema.xml
new file mode 100644
index 0000000..9263a25
--- /dev/null
+++ b/data/org.gnome.seahorse.window.gschema.xml
@@ -0,0 +1,14 @@
+<schemalist>
+ <schema id="org.gnome.seahorse.window">
+ <key name="width" type="i">
+ <default>-1</default>
+ <summary>Width of the window</summary>
+ <description>Width (in pixels) of the window.</description>
+ </key>
+ <key name="height" type="i">
+ <default>-1</default>
+ <summary>Height of the window</summary>
+ <description>Height (in pixels) of the window.</description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/libseahorse/Makefile.am b/libseahorse/Makefile.am
index e3e2b15..d3c2206 100644
--- a/libseahorse/Makefile.am
+++ b/libseahorse/Makefile.am
@@ -28,13 +28,11 @@ KEYSERVER_SRCS =
endif
libseahorse_la_SOURCES = \
- seahorse-check-button-control.c seahorse-check-button-control.h \
seahorse-combo-keys.c seahorse-combo-keys.h \
seahorse-commands.c seahorse-commands.h \
seahorse-context.c seahorse-context.h \
seahorse-debug.c seahorse-debug.h \
seahorse-dns-sd.c seahorse-dns-sd.h \
- seahorse-gconf.c seahorse-gconf.h \
seahorse-gtkstock.c seahorse-gtkstock.h \
seahorse-object.c seahorse-object.h \
seahorse-object-model.c seahorse-object-model.h \
diff --git a/libseahorse/seahorse-add-keyserver.xml b/libseahorse/seahorse-add-keyserver.xml
index 4a26ab8..d53f9d7 100644
--- a/libseahorse/seahorse-add-keyserver.xml
+++ b/libseahorse/seahorse-add-keyserver.xml
@@ -46,7 +46,7 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="keyserver-type">
+ <object class="GtkComboBoxText" id="keyserver-type">
<property name="visible">True</property>
<property name="model">model1</property>
<signal name="changed" handler="on_prefs_add_keyserver_uri_changed"/>
@@ -157,7 +157,6 @@
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
- <signal name="clicked" handler="on_widget_closed"/>
</object>
<packing>
<property name="expand">False</property>
diff --git a/libseahorse/seahorse-combo-keys.c b/libseahorse/seahorse-combo-keys.c
index fb269a4..35c34ff 100644
--- a/libseahorse/seahorse-combo-keys.c
+++ b/libseahorse/seahorse-combo-keys.c
@@ -23,7 +23,6 @@
#include "seahorse-combo-keys.h"
-#include "seahorse-gconf.h"
#include "seahorse-object.h"
enum {
diff --git a/libseahorse/seahorse-context.c b/libseahorse/seahorse-context.c
index 353857a..7c802ae 100644
--- a/libseahorse/seahorse-context.c
+++ b/libseahorse/seahorse-context.c
@@ -28,7 +28,6 @@
#include "seahorse-context.h"
#include "seahorse-dns-sd.h"
-#include "seahorse-gconf.h"
#include "seahorse-marshal.h"
#include "seahorse-servers.h"
#include "seahorse-transfer-operation.h"
@@ -86,22 +85,80 @@ struct _SeahorseContextPrivate {
SeahorseMultiOperation *refresh_ops; /* Operations for refreshes going on */
SeahorseServiceDiscovery *discovery; /* Adds sources from DNS-SD */
gboolean in_destruction; /* In destroy signal */
+ GSettings *seahorse_settings;
+ GSettings *crypto_pgp_settings;
};
static void seahorse_context_dispose (GObject *gobject);
static void seahorse_context_finalize (GObject *gobject);
-/* Forward declarations */
-static void refresh_keyservers (GConfClient *client, guint id,
- GConfEntry *entry, SeahorseContext *sctx);
+#ifdef WITH_KEYSERVER
+
+static void
+on_settings_keyservers_changed (GSettings *settings, gchar *key, gpointer user_data)
+{
+#ifdef WITH_PGP
+ SeahorseContext *self = SEAHORSE_CONTEXT (user_data);
+ SeahorseServerSource *source;
+ gchar **keyservers;
+ GHashTable *check;
+ const gchar *uri;
+ GHashTableIter iter;
+ guint i;
+
+ if (!self->pv->auto_sources)
+ return;
+
+ /* Make a light copy of the auto_source table */
+ check = g_hash_table_new (g_str_hash, g_str_equal);
+ g_hash_table_iter_init (&iter, self->pv->auto_sources);
+ while (g_hash_table_iter_next (&iter, (gpointer*)&uri, (gpointer*)&source))
+ g_hash_table_replace (check, (gpointer)uri, source);
+
+ /* Load and strip names from keyserver list */
+ keyservers = seahorse_servers_get_uris ();
+
+ for (i = 0; keyservers[i] != NULL; i++) {
+ uri = keyservers[i];
+
+ /* If we don't have a keysource then add it */
+ if (!g_hash_table_lookup (self->pv->auto_sources, uri)) {
+ source = seahorse_server_source_new (uri);
+ if (source != NULL) {
+ seahorse_context_take_source (self, SEAHORSE_SOURCE (source));
+ g_hash_table_replace (self->pv->auto_sources, g_strdup (uri), source);
+ }
+ }
+
+ /* Mark this one as present */
+ g_hash_table_remove (check, uri);
+ }
+
+ /* Now remove any extras */
+ g_hash_table_iter_init (&iter, check);
+ while (g_hash_table_iter_next (&iter, (gpointer*)&uri, (gpointer*)&source)) {
+ g_hash_table_remove (self->pv->auto_sources, uri);
+ seahorse_context_remove_source (self, SEAHORSE_SOURCE (source));
+ }
+
+ g_hash_table_destroy (check);
+ g_strfreev (keyservers);
+#endif /* WITH_PGP */
+}
+
+#endif /* WITH_KEYSERVER */
static void
seahorse_context_constructed (GObject *obj)
{
SeahorseContext *self = SEAHORSE_CONTEXT (obj);
+ g_return_if_fail (app_context == NULL);
+
G_OBJECT_CLASS(seahorse_context_parent_class)->constructed (obj);
+ app_context = self;
+
/* DNS-SD discovery */
self->pv->discovery = seahorse_service_discovery_new ();
@@ -109,12 +166,21 @@ seahorse_context_constructed (GObject *obj)
self->pv->auto_sources = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
- /* Listen for new gconf remote key sources automatically */
- self->pv->notify_id = seahorse_gconf_notify (KEYSERVER_KEY,
- (GConfClientNotifyFunc)refresh_keyservers, self);
+ self->pv->seahorse_settings = g_settings_new ("org.gnome.seahorse");
+
+#ifdef WITH_PGP
+ /* This is installed by gnome-keyring */
+ self->pv->crypto_pgp_settings = g_settings_new ("org.gnome.crypto.pgp");
+
+#ifdef WITH_KEYSERVER
+ g_signal_connect (self->pv->crypto_pgp_settings, "changed::keyservers",
+ G_CALLBACK (on_settings_keyservers_changed), self);
- refresh_keyservers (NULL, 0, NULL, self);
+ /* Initial loading */
+ on_settings_keyservers_changed (self->pv->crypto_pgp_settings, "keyservers", self);
+#endif
+#endif
}
/**
* klass: The class to initialise
@@ -213,11 +279,15 @@ seahorse_context_dispose (GObject *gobject)
}
g_slist_free (objects);
- /* Gconf notification */
- if (sctx->pv->notify_id)
- seahorse_gconf_unnotify (sctx->pv->notify_id);
- sctx->pv->notify_id = 0;
-
+#ifdef WITH_KEYSERVER
+ if (sctx->pv->crypto_pgp_settings) {
+ g_signal_handlers_disconnect_by_func (sctx->pv->crypto_pgp_settings,
+ on_settings_keyservers_changed, sctx);
+ g_clear_object (&sctx->pv->crypto_pgp_settings);
+ }
+#endif
+ g_clear_object (&sctx->pv->seahorse_settings);
+
/* Auto sources */
if (sctx->pv->auto_sources)
g_hash_table_destroy (sctx->pv->auto_sources);
@@ -298,7 +368,8 @@ void
seahorse_context_create (void)
{
g_return_if_fail (app_context == NULL);
- app_context = g_object_new (SEAHORSE_TYPE_CONTEXT, NULL);
+ g_object_new (SEAHORSE_TYPE_CONTEXT, NULL);
+ g_return_if_fail (app_context != NULL);
}
/**
@@ -1011,31 +1082,30 @@ seahorse_context_remove_object (SeahorseContext *sctx, SeahorseObject *sobj)
* seahorse_context_get_default_key:
* @sctx: Current #SeahorseContext
*
- * Returns: the secret key that's the default key
+ * Returns: the PGP secret key that's the default key
*
* Deprecated: No replacement
*/
SeahorseObject*
-seahorse_context_get_default_key (SeahorseContext *sctx)
+seahorse_context_get_default_key (SeahorseContext *self)
{
- SeahorseObject *sobj = NULL;
- gchar *id;
-
- if (!sctx)
- sctx = seahorse_context_instance ();
- g_return_val_if_fail (SEAHORSE_IS_CONTEXT (sctx), NULL);
+ SeahorseObject *key = NULL;
+ gchar *keyid;
- /* TODO: All of this needs to take multiple key types into account */
-
- id = seahorse_gconf_get_string (SEAHORSE_DEFAULT_KEY);
- if (id != NULL && id[0]) {
- GQuark keyid = g_quark_from_string (id);
- sobj = seahorse_context_find_object (sctx, keyid, SEAHORSE_LOCATION_LOCAL);
- }
-
- g_free (id);
-
- return sobj;
+ if (self == NULL)
+ self = seahorse_context_instance ();
+ g_return_val_if_fail (SEAHORSE_IS_CONTEXT (self), NULL);
+
+ if (self->pv->crypto_pgp_settings) {
+ keyid = g_settings_get_string (self->pv->crypto_pgp_settings, "default-key");
+ if (keyid != NULL && keyid[0]) {
+ key = seahorse_context_find_object (self, g_quark_from_string (keyid),
+ SEAHORSE_LOCATION_LOCAL);
+ }
+ g_free (keyid);
+ }
+
+ return key;
}
/**
@@ -1110,22 +1180,25 @@ seahorse_context_search_remote (SeahorseContext *sctx, const gchar *search)
SeahorseSource *ks;
SeahorseMultiOperation *mop = NULL;
SeahorseOperation *op = NULL;
- GSList *l, *names;
+ gchar **names;
GHashTable *servers = NULL;
gchar *uri;
-
+ GSList *l;
+ guint i;
+
if (!sctx)
sctx = seahorse_context_instance ();
g_return_val_if_fail (SEAHORSE_IS_CONTEXT (sctx), NULL);
-
- /* Get a list of all selected key servers */
- names = seahorse_gconf_get_string_list (LASTSERVERS_KEY);
- if (names) {
- servers = g_hash_table_new (g_str_hash, g_str_equal);
- for (l = names; l; l = g_slist_next (l))
- g_hash_table_insert (servers, l->data, GINT_TO_POINTER (TRUE));
- }
-
+
+ /* Get a list of all selected key servers */
+ names = g_settings_get_strv (sctx->pv->seahorse_settings, "last-search-servers");
+ if (names != NULL) {
+ servers = g_hash_table_new (g_str_hash, g_str_equal);
+ for (i = 0; names[i] != NULL; i++)
+ g_hash_table_insert (servers, names[i], GINT_TO_POINTER (TRUE));
+ g_strfreev (names);
+ }
+
for (l = sctx->pv->sources; l; l = g_slist_next (l)) {
ks = SEAHORSE_SOURCE (l->data);
@@ -1153,104 +1226,9 @@ seahorse_context_search_remote (SeahorseContext *sctx, const gchar *search)
seahorse_multi_operation_take (mop, op);
}
- seahorse_util_string_slist_free (names);
return mop ? SEAHORSE_OPERATION (mop) : op;
}
-#ifdef WITH_KEYSERVER
-#ifdef WITH_PGP
-/* For copying the keys */
-/**
-* uri: the uri of the source
-* sksrc: the source to add or replace
-* ht: the hash table to modify
-*
-* Adds the @sksrc to the hash table @ht
-*
-**/
-static void
-auto_source_to_hash (const gchar *uri, SeahorseSource *sksrc, GHashTable *ht)
-
-{
- g_hash_table_replace (ht, (gpointer)uri, sksrc);
-}
-
-/**
-* uri: The uri of this source
-* sksrc: The source to remove
-* sctx: The Context to remove data from
-*
-*
-*
-**/
-static void
-auto_source_remove (const gchar* uri, SeahorseSource *sksrc, SeahorseContext *sctx)
-{
- seahorse_context_remove_source (sctx, sksrc);
- g_hash_table_remove (sctx->pv->auto_sources, uri);
-}
-#endif
-#endif
-
-/**
-* client: ignored
-* id: ignored
-* entry: used for validation only
-* sctx: The context to work with
-*
-* Refreshes the sources generated from the keyservers
-*
-**/
-static void
-refresh_keyservers (GConfClient *client, guint id, GConfEntry *entry,
- SeahorseContext *sctx)
-{
-#ifdef WITH_KEYSERVER
-#ifdef WITH_PGP
- SeahorseServerSource *ssrc;
- GSList *keyservers, *l;
- GHashTable *check;
- const gchar *uri;
-
- if (!sctx->pv->auto_sources)
- return;
-
- if (entry && !g_str_equal (KEYSERVER_KEY, gconf_entry_get_key (entry)))
- return;
-
- /* Make a light copy of the auto_source table */
- check = g_hash_table_new (g_str_hash, g_str_equal);
- g_hash_table_foreach (sctx->pv->auto_sources, (GHFunc)auto_source_to_hash, check);
-
-
- /* Load and strip names from keyserver list */
- keyservers = seahorse_servers_get_uris ();
-
- for (l = keyservers; l; l = g_slist_next (l)) {
- uri = (const gchar*)(l->data);
-
- /* If we don't have a keysource then add it */
- if (!g_hash_table_lookup (sctx->pv->auto_sources, uri)) {
- ssrc = seahorse_server_source_new (uri);
- if (ssrc != NULL) {
- seahorse_context_take_source (sctx, SEAHORSE_SOURCE (ssrc));
- g_hash_table_replace (sctx->pv->auto_sources, g_strdup (uri), ssrc);
- }
- }
-
- /* Mark this one as present */
- g_hash_table_remove (check, uri);
- }
-
- /* Now remove any extras */
- g_hash_table_foreach (check, (GHFunc)auto_source_remove, sctx);
-
- g_hash_table_destroy (check);
- seahorse_util_string_slist_free (keyservers);
-#endif /* WITH_PGP */
-#endif /* WITH_KEYSERVER */
-}
-
/**
* seahorse_context_transfer_objects:
* @sctx: The #SeahorseContext (can be NULL)
@@ -1486,13 +1464,14 @@ seahorse_context_discover_objects (SeahorseContext *sctx, GQuark ktype,
g_object_unref (op);
}
- /* Start a discover process on all todiscover */
- if (seahorse_gconf_get_boolean (AUTORETRIEVE_KEY) && todiscover) {
- op = seahorse_context_retrieve_objects (sctx, ktype, todiscover, NULL);
-
- /* Running operations ref themselves */
- g_object_unref (op);
- }
+ /* Start a discover process on all todiscover */
+ if (todiscover != NULL &&
+ g_settings_get_boolean (sctx->pv->seahorse_settings, "server-auto-retrieve")) {
+
+ op = seahorse_context_retrieve_objects (sctx, ktype, todiscover, NULL);
+ /* Running operations ref themselves */
+ g_object_unref (op);
+ }
/* Add unknown objects for all these */
sksrc = seahorse_context_find_source (sctx, ktype, SEAHORSE_LOCATION_MISSING);
@@ -1531,3 +1510,23 @@ seahorse_context_canonize_id (GQuark ktype, const gchar *id)
return (canonize) (id);
}
+
+GSettings *
+seahorse_context_settings (SeahorseContext *self)
+{
+ if (self == NULL)
+ self = seahorse_context_instance ();
+ g_return_val_if_fail (SEAHORSE_IS_CONTEXT (self), NULL);
+
+ return self->pv->seahorse_settings;
+}
+
+GSettings *
+seahorse_context_pgp_settings (SeahorseContext *self)
+{
+ if (self == NULL)
+ self = seahorse_context_instance ();
+ g_return_val_if_fail (SEAHORSE_IS_CONTEXT (self), NULL);
+
+ return self->pv->crypto_pgp_settings;
+}
diff --git a/libseahorse/seahorse-context.h b/libseahorse/seahorse-context.h
index 76a3f07..be3ebee 100644
--- a/libseahorse/seahorse-context.h
+++ b/libseahorse/seahorse-context.h
@@ -193,4 +193,8 @@ typedef GQuark (*SeahorseCanonizeFunc) (const gchar *id);
GQuark seahorse_context_canonize_id (GQuark ktype, const gchar *id);
+GSettings * seahorse_context_settings (SeahorseContext *self);
+
+GSettings * seahorse_context_pgp_settings (SeahorseContext *self);
+
#endif /* __SEAHORSE_CONTEXT_H__ */
diff --git a/libseahorse/seahorse-dns-sd.c b/libseahorse/seahorse-dns-sd.c
index a3b36a7..cd9b29b 100644
--- a/libseahorse/seahorse-dns-sd.c
+++ b/libseahorse/seahorse-dns-sd.c
@@ -269,21 +269,6 @@ client_callback (AvahiClient *client, AvahiClientState state, void *data)
#endif /* WITH_SHARING */
-/**
-* key: Will be prepeded to the list
-* value: ignored
-* arg: A GSList, the key will be prepended
-*
-*
-*
-**/
-static void
-service_key_list (const gchar* key, const gchar* value, GSList **arg)
-{
- *arg = g_slist_prepend (*arg, g_strdup (key));
-}
-
-
/* -----------------------------------------------------------------------------
* OBJECT
*/
@@ -307,7 +292,7 @@ seahorse_service_discovery_init (SeahorseServiceDiscovery *ssd)
ssd->priv->client = avahi_client_new (seahorse_util_dns_sd_get_poll (),
0, client_callback, ssd, &aerr);
if (!ssd->priv->client) {
- g_warning ("DNS-SD initialization failed: %s", avahi_strerror (aerr));
+ g_message ("DNS-SD initialization failed: %s", avahi_strerror (aerr));
return;
}
@@ -315,7 +300,7 @@ seahorse_service_discovery_init (SeahorseServiceDiscovery *ssd)
AVAHI_PROTO_UNSPEC, HKP_SERVICE_TYPE, NULL, 0,
browse_callback, ssd);
if (!ssd->priv->browser) {
- g_warning ("Browsing for DNS-SD services failed: %s",
+ g_message ("Browsing for DNS-SD services failed: %s",
avahi_strerror (avahi_client_errno (ssd->priv->client)));
return;
}
@@ -415,17 +400,21 @@ seahorse_service_discovery_new ()
*
*
*
- * Returns: A #GSList containing the services in @ssd
+ * Returns: the services in @ssd
*/
-GSList*
+gchar **
seahorse_service_discovery_list (SeahorseServiceDiscovery *ssd)
{
- GSList *list = NULL;
- GSList **arg = &list;
-
- g_return_val_if_fail (SEAHORSE_IS_SERVICE_DISCOVERY (ssd), NULL);
- g_hash_table_foreach (ssd->services, (GHFunc)service_key_list, arg);
- return *arg;
+ GHashTableIter iter;
+ GPtrArray *result = g_ptr_array_new ();
+ gpointer key;
+
+ g_return_val_if_fail (SEAHORSE_IS_SERVICE_DISCOVERY (ssd), NULL);
+ g_hash_table_iter_init (&iter, ssd->services);
+ while (g_hash_table_iter_next (&iter, &key, NULL))
+ g_ptr_array_add (result, g_strdup (key));
+
+ return (gchar **)g_ptr_array_free (result, FALSE);
}
/**
@@ -451,19 +440,20 @@ seahorse_service_discovery_get_uri (SeahorseServiceDiscovery *ssd, const gchar *
*
* The returned uris in the list are copied and must be freed with g_free.
*
- * Returns: A #GSList of uris for the services
+ * Returns: uris for the services
*/
-GSList*
-seahorse_service_discovery_get_uris (SeahorseServiceDiscovery *ssd, GSList *services)
+gchar **
+seahorse_service_discovery_get_uris (SeahorseServiceDiscovery *ssd, const gchar **services)
{
- GSList *uris = NULL;
- const gchar *uri;
-
- while (services) {
- uri = (const gchar*)g_hash_table_lookup (ssd->services, services->data);
- uris = g_slist_append (uris, uri ? g_strdup (uri) : NULL);
- services = g_slist_next (services);
- }
+ GPtrArray *result = g_ptr_array_new ();
+ const gchar *uri;
+ guint i;
+
+ for (i = 0; services && services[i] != NULL; i++) {
+ uri = g_hash_table_lookup (ssd->services, services[i]);
+ g_ptr_array_add (result, g_strdup (uri));
+ }
- return uris;
+ g_ptr_array_add (result, NULL);
+ return (gchar **)g_ptr_array_free (result, FALSE);
}
diff --git a/libseahorse/seahorse-dns-sd.h b/libseahorse/seahorse-dns-sd.h
index 73f3e92..67b0bbb 100644
--- a/libseahorse/seahorse-dns-sd.h
+++ b/libseahorse/seahorse-dns-sd.h
@@ -72,12 +72,12 @@ GType seahorse_service_discovery_get_type (void);
SeahorseServiceDiscovery* seahorse_service_discovery_new ();
-GSList* seahorse_service_discovery_list (SeahorseServiceDiscovery *ssd);
+gchar ** seahorse_service_discovery_list (SeahorseServiceDiscovery *ssd);
const gchar* seahorse_service_discovery_get_uri (SeahorseServiceDiscovery *ssd,
const gchar *service);
-GSList* seahorse_service_discovery_get_uris (SeahorseServiceDiscovery *ssd,
- GSList *services);
+gchar ** seahorse_service_discovery_get_uris (SeahorseServiceDiscovery *ssd,
+ const gchar **services);
#endif /* __SEAHORSE_KEY_H__ */
diff --git a/libseahorse/seahorse-keyserver-control.c b/libseahorse/seahorse-keyserver-control.c
index ec2a6a8..5e742a4 100644
--- a/libseahorse/seahorse-keyserver-control.c
+++ b/libseahorse/seahorse-keyserver-control.c
@@ -22,7 +22,6 @@
#include <config.h>
#include "seahorse-context.h"
-#include "seahorse-gconf.h"
#include "seahorse-keyserver-control.h"
#include "seahorse-servers.h"
#include "seahorse-util.h"
@@ -30,9 +29,9 @@
#define UPDATING "updating"
enum {
- PROP_0,
- PROP_GCONF_KEY,
- PROP_NONE_OPTION
+ PROP_0,
+ PROP_SETTINGS_KEY,
+ PROP_NONE_OPTION
};
enum {
@@ -47,13 +46,10 @@ enum {
};
/* Forward declaration */
-static void populate_combo (SeahorseKeyserverControl *combo, gboolean gconf);
+static void populate_combo (SeahorseKeyserverControl *combo, gboolean with_key);
static void seahorse_keyserver_control_class_init (SeahorseKeyserverControlClass *klass);
static void seahorse_keyserver_control_init (SeahorseKeyserverControl *skc);
-static GObject *seahorse_keyserver_control_constructor (GType type, guint n_construct_properties,
- GObjectConstructParam *construct_params);
-static void seahorse_keyserver_control_finalize (GObject *gobject);
static void seahorse_keyserver_control_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec);
static void seahorse_keyserver_control_get_property (GObject *object, guint prop_id,
@@ -62,13 +58,74 @@ static void seahorse_keyserver_control_get_property (GObject *object, guin
G_DEFINE_TYPE(SeahorseKeyserverControl, seahorse_keyserver_control, GTK_TYPE_COMBO_BOX)
static void
+on_keyserver_changed (GtkComboBox *widget, SeahorseKeyserverControl *self)
+{
+ gchar *text;
+
+ /* If currently updating (see populate_combo) ignore */
+ if (g_object_get_data (G_OBJECT (self), UPDATING) != NULL)
+ return;
+
+ if (self->settings_key) {
+ text = seahorse_keyserver_control_selected (self);
+ g_settings_set_string (seahorse_context_settings (NULL),
+ self->settings_key, text ? text : "");
+ g_free (text);
+ }
+}
+
+static void
+on_settings_keyserver_changed (GSettings *settings, const gchar *key, gpointer user_data)
+{
+ SeahorseKeyserverControl *self = SEAHORSE_KEYSERVER_CONTROL (user_data);
+ populate_combo (self, FALSE);
+}
+
+static void
+on_settings_key_changed (GSettings *settings, const gchar *key, gpointer user_data)
+{
+ SeahorseKeyserverControl *self = SEAHORSE_KEYSERVER_CONTROL (user_data);
+ populate_combo (self, TRUE);
+}
+
+static void
+seahorse_keyserver_control_constructed (GObject *object)
+{
+ SeahorseKeyserverControl *self = SEAHORSE_KEYSERVER_CONTROL (object);
+ gchar *detailed;
+
+ G_OBJECT_CLASS (seahorse_keyserver_control_parent_class)->constructed (object);
+
+ populate_combo (self, TRUE);
+ g_signal_connect_object (self, "changed", G_CALLBACK (on_keyserver_changed), self, 0);
+ g_signal_connect_object (seahorse_context_pgp_settings (NULL), "changed::keyserver",
+ G_CALLBACK (on_settings_keyserver_changed), self, 0);
+ if (self->settings_key) {
+ detailed = g_strdup_printf ("changed::%s", self->settings_key);
+ g_signal_connect_object (seahorse_context_settings (NULL), detailed,
+ G_CALLBACK (on_settings_key_changed), self, 0);
+ g_free (detailed);
+ }
+}
+
+static void
+seahorse_keyserver_control_finalize (GObject *gobject)
+{
+ SeahorseKeyserverControl *skc = SEAHORSE_KEYSERVER_CONTROL (gobject);
+
+ g_free (skc->settings_key);
+
+ G_OBJECT_CLASS (seahorse_keyserver_control_parent_class)->finalize (gobject);
+}
+
+static void
seahorse_keyserver_control_class_init (SeahorseKeyserverControlClass *klass)
{
GObjectClass *gobject_class;
gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->constructor = seahorse_keyserver_control_constructor;
+
+ gobject_class->constructed = seahorse_keyserver_control_constructed;
gobject_class->set_property = seahorse_keyserver_control_set_property;
gobject_class->get_property = seahorse_keyserver_control_get_property;
gobject_class->finalize = seahorse_keyserver_control_finalize;
@@ -77,38 +134,12 @@ seahorse_keyserver_control_class_init (SeahorseKeyserverControlClass *klass)
g_param_spec_string ("none-option", "No key option", "Puts in an option for 'no key server'",
NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (gobject_class, PROP_GCONF_KEY,
- g_param_spec_string ("gconf-key", "GConf key", "GConf key to read/write selection",
+ g_object_class_install_property (gobject_class, PROP_SETTINGS_KEY,
+ g_param_spec_string ("settings-key", "Settings key", "Settings key to read/write selection",
NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
}
-static void
-keyserver_changed (GtkComboBox *widget, SeahorseKeyserverControl *skc)
-{
- /* If currently updating (see populate_combo) ignore */
- if (g_object_get_data (G_OBJECT (skc), UPDATING) != NULL)
- return;
-
- if (skc->gconf_key) {
- gchar *t = seahorse_keyserver_control_selected (skc);
- seahorse_gconf_set_string (skc->gconf_key, t ? t : "");
- g_free (t);
- }
-}
-
-static void
-gconf_notify (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- SeahorseKeyserverControl *skc = SEAHORSE_KEYSERVER_CONTROL (data);
- const gchar *key = gconf_entry_get_key (entry);
-
- if (g_str_equal (KEYSERVER_KEY, key))
- populate_combo (skc, FALSE);
- else if (skc->gconf_key && g_str_equal (skc->gconf_key, key))
- populate_combo (skc, TRUE);
-}
-
static gint
compare_func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data)
{
@@ -157,26 +188,6 @@ seahorse_keyserver_control_init (SeahorseKeyserverControl *skc)
NULL, NULL);
}
-static GObject *
-seahorse_keyserver_control_constructor (GType type, guint n_construct_properties,
- GObjectConstructParam *construct_params)
-{
- GObject *object;
- SeahorseKeyserverControl *skc;
-
- object = G_OBJECT_CLASS (seahorse_keyserver_control_parent_class)->constructor
- (type, n_construct_properties, construct_params);
- skc = SEAHORSE_KEYSERVER_CONTROL (object);
-
- populate_combo (skc, TRUE);
- g_signal_connect (skc, "changed", G_CALLBACK (keyserver_changed), skc);
- skc->notify_id_list = seahorse_gconf_notify (KEYSERVER_KEY, gconf_notify, skc);
- if (skc->gconf_key)
- skc->notify_id = seahorse_gconf_notify (skc->gconf_key, gconf_notify, skc);
-
- return object;
-}
-
static void
seahorse_keyserver_control_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
@@ -184,8 +195,8 @@ seahorse_keyserver_control_set_property (GObject *object, guint prop_id,
SeahorseKeyserverControl *control = SEAHORSE_KEYSERVER_CONTROL (object);
switch (prop_id) {
- case PROP_GCONF_KEY:
- control->gconf_key = g_value_dup_string (value);
+ case PROP_SETTINGS_KEY:
+ control->settings_key = g_value_dup_string (value);
break;
case PROP_NONE_OPTION:
@@ -208,8 +219,8 @@ seahorse_keyserver_control_get_property (GObject *object, guint prop_id,
g_value_set_string (value, control->none_option);
break;
- case PROP_GCONF_KEY:
- g_value_set_string (value, control->gconf_key);
+ case PROP_SETTINGS_KEY:
+ g_value_set_string (value, control->settings_key);
break;
default:
@@ -218,39 +229,20 @@ seahorse_keyserver_control_get_property (GObject *object, guint prop_id,
}
static void
-seahorse_keyserver_control_finalize (GObject *gobject)
-{
- SeahorseKeyserverControl *skc = SEAHORSE_KEYSERVER_CONTROL (gobject);
-
- if (skc->notify_id >= 0) {
- seahorse_gconf_unnotify (skc->notify_id);
- skc->notify_id = 0;
- }
-
- if (skc->notify_id_list >= 0) {
- seahorse_gconf_unnotify (skc->notify_id_list);
- skc->notify_id_list = 0;
- }
-
- g_free (skc->gconf_key);
-
- G_OBJECT_CLASS (seahorse_keyserver_control_parent_class)->finalize (gobject);
-}
-
-static void
-populate_combo (SeahorseKeyserverControl *skc, gboolean gconf)
+populate_combo (SeahorseKeyserverControl *skc, gboolean with_key)
{
GtkComboBox *combo = GTK_COMBO_BOX (skc);
- GSList *l, *ks;
+ gchar **keyservers;
gchar *chosen = NULL;
gint chosen_info = OPTION_KEYSERVER;
GtkListStore *store;
GtkTreeIter iter, none_iter, chosen_iter;
gboolean chosen_iter_set = FALSE;
+ guint i;
/* Get the appropriate selection */
- if (gconf && skc->gconf_key)
- chosen = seahorse_gconf_get_string (skc->gconf_key);
+ if (with_key && skc->settings_key)
+ chosen = g_settings_get_string (seahorse_context_settings (NULL), skc->settings_key);
else {
if (gtk_combo_box_get_active_iter (combo, &iter)) {
gtk_tree_model_get (gtk_combo_box_get_model (combo), &iter,
@@ -281,10 +273,10 @@ populate_combo (SeahorseKeyserverControl *skc, gboolean gconf)
-1);
}
- ks = seahorse_servers_get_uris ();
+ keyservers = seahorse_servers_get_uris ();
- for (l = ks; l != NULL; l = g_slist_next (l)) {
- const gchar *keyserver = (const gchar *) l->data;
+ for (i = 0; keyservers[i] != NULL; i++) {
+ const gchar *keyserver = keyservers[i];
g_assert (keyserver != NULL);
gtk_list_store_insert_with_values (store, &iter, 0,
@@ -296,7 +288,7 @@ populate_combo (SeahorseKeyserverControl *skc, gboolean gconf)
chosen_iter_set = TRUE;
}
}
- seahorse_util_string_slist_free (ks);
+ g_strfreev (keyservers);
g_free (chosen);
/* Turn on sorting after populating the store, since that's faster */
@@ -318,11 +310,11 @@ populate_combo (SeahorseKeyserverControl *skc, gboolean gconf)
g_object_set_data (G_OBJECT (skc), UPDATING, NULL);
}
-SeahorseKeyserverControl*
-seahorse_keyserver_control_new (const gchar *gconf_key, const gchar *none_option)
+SeahorseKeyserverControl*
+seahorse_keyserver_control_new (const gchar *settings_key, const gchar *none_option)
{
return g_object_new (SEAHORSE_TYPE_KEYSERVER_CONTROL,
- "gconf-key", gconf_key, "none-option", none_option, NULL);
+ "settings-key", settings_key, "none-option", none_option, NULL);
}
gchar *
diff --git a/libseahorse/seahorse-keyserver-control.h b/libseahorse/seahorse-keyserver-control.h
index cf2b378..20661a0 100644
--- a/libseahorse/seahorse-keyserver-control.h
+++ b/libseahorse/seahorse-keyserver-control.h
@@ -50,22 +50,17 @@ typedef struct _SeahorseKeyserverControlClass SeahorseKeyserverControlClass;
struct _SeahorseKeyserverControl {
GtkComboBox parent_instance;
-
+
/* <public> */
- gchar *gconf_key;
+ gchar *settings_key;
gchar *none_option;
-
- /* <private> */
- guint notify_id;
- guint notify_id_list;
- gboolean changed;
};
struct _SeahorseKeyserverControlClass {
GtkComboBoxClass parent_class;
};
-SeahorseKeyserverControl* seahorse_keyserver_control_new (const gchar *gconf_key,
+SeahorseKeyserverControl* seahorse_keyserver_control_new (const gchar *settings_key,
const gchar *none_option);
gchar* seahorse_keyserver_control_selected (SeahorseKeyserverControl *skc);
diff --git a/libseahorse/seahorse-prefs.c b/libseahorse/seahorse-prefs.c
index af610b4..92273bd 100644
--- a/libseahorse/seahorse-prefs.c
+++ b/libseahorse/seahorse-prefs.c
@@ -22,9 +22,7 @@
#include <glib/gi18n.h>
-#include "seahorse-check-button-control.h"
#include "seahorse-combo-keys.h"
-#include "seahorse-gconf.h"
#include "seahorse-gtkstock.h"
#include "seahorse-keyserver-control.h"
#include "seahorse-prefs.h"
@@ -100,21 +98,23 @@ on_prefs_keyserver_remove_clicked (GtkWidget *button, SeahorseWidget *swidget)
static void
save_keyservers (GtkTreeModel *model)
{
- GSList *ks = NULL;
- GtkTreeIter iter;
- gchar *v;
-
- if (gtk_tree_model_get_iter_first (model, &iter)) {
-
- do {
- gtk_tree_model_get (model, &iter, KEYSERVER_COLUMN, &v, -1);
- g_return_if_fail (v != NULL);
- ks = g_slist_append (ks, v);
- } while (gtk_tree_model_iter_next (model, &iter));
- }
-
- seahorse_gconf_set_string_list (KEYSERVER_KEY, ks);
- seahorse_util_string_slist_free (ks);
+ GPtrArray *values;
+ GtkTreeIter iter;
+ gchar *keyserver;
+
+ values = g_ptr_array_new_with_free_func (g_free);
+ if (gtk_tree_model_get_iter_first (model, &iter)) {
+ do {
+ gtk_tree_model_get (model, &iter, KEYSERVER_COLUMN, &keyserver, -1);
+ g_return_if_fail (keyserver != NULL);
+ g_ptr_array_add (values, keyserver);
+ } while (gtk_tree_model_iter_next (model, &iter));
+ }
+
+ g_ptr_array_add (values, NULL);
+ g_settings_set_strv (seahorse_context_pgp_settings (NULL), "keyservers",
+ (const gchar* const*)values->pdata);
+ g_ptr_array_free (values, TRUE);
}
/* Called when values in a row changes */
@@ -143,7 +143,7 @@ keyserver_row_deleted (GtkTreeModel *model, GtkTreePath *arg1,
/* Fill in the list with values in ks */
static void
-populate_keyservers (SeahorseWidget *swidget, GSList *ks)
+populate_keyservers (SeahorseWidget *swidget, gchar **keyservers)
{
GtkTreeView *treeview;
GtkTreeStore *store;
@@ -152,8 +152,9 @@ populate_keyservers (SeahorseWidget *swidget, GSList *ks)
GtkTreeViewColumn *column;
GtkTreeIter iter;
gboolean cont;
- gchar *v;
-
+ gchar *value;
+ guint i = 0;
+
treeview = GTK_TREE_VIEW (seahorse_widget_get_widget (swidget, "keyservers"));
model = gtk_tree_view_get_model (treeview);
store = GTK_TREE_STORE (model);
@@ -174,62 +175,45 @@ populate_keyservers (SeahorseWidget *swidget, GSList *ks)
gtk_tree_view_append_column (treeview, column);
}
- /* Mark this so we can ignore events */
- g_object_set_data (G_OBJECT (model), UPDATING_MODEL, GINT_TO_POINTER (1));
-
- /* We try and be inteligent about updating so we don't throw
- * away selections and stuff like that */
-
- if (gtk_tree_model_get_iter_first (model, &iter)) {
- do {
- gtk_tree_model_get (model, &iter, KEYSERVER_COLUMN, &v, -1);
-
- if (ks && v && g_utf8_collate (ks->data, v) == 0) {
- ks = ks->next;
- cont = gtk_tree_model_iter_next (model, &iter);
- } else {
- cont = gtk_tree_store_remove (store, &iter);
- }
-
- g_free (v);
- }
- while (cont);
- }
-
- /* Any remaining extra rows */
- for ( ; ks; ks = ks->next) {
- gtk_tree_store_append (store, &iter, NULL);
- gtk_tree_store_set (store, &iter, KEYSERVER_COLUMN, (gchar*)ks->data, -1);
- }
-
- /* Done updating */
- g_object_set_data (G_OBJECT (model), UPDATING_MODEL, NULL);
+ /* Mark this so we can ignore events */
+ g_object_set_data (G_OBJECT (model), UPDATING_MODEL, GINT_TO_POINTER (1));
+
+ /* We try and be inteligent about updating so we don't throw
+ * away selections and stuff like that */
+
+ if (gtk_tree_model_get_iter_first (model, &iter)) {
+ do {
+ gtk_tree_model_get (model, &iter, KEYSERVER_COLUMN, &value, -1);
+ if (keyservers[i] != NULL && value != NULL &&
+ g_utf8_collate (keyservers[i], value) == 0) {
+ cont = gtk_tree_model_iter_next (model, &iter);
+ i++;
+ } else {
+ cont = gtk_tree_store_remove (store, &iter);
+ }
+ g_free (value);
+ } while (cont);
+ }
+
+ /* Any remaining extra rows */
+ for ( ; keyservers[i] != NULL; i++) {
+ gtk_tree_store_append (store, &iter, NULL);
+ gtk_tree_store_set (store, &iter, KEYSERVER_COLUMN, keyservers[i], -1);
+ }
+
+ /* Done updating */
+ g_object_set_data (G_OBJECT (model), UPDATING_MODEL, NULL);
}
-/* Callback for changes on keyserver key */
static void
-gconf_notify (GConfClient *client, guint id, GConfEntry *entry, SeahorseWidget *swidget)
+on_settings_keyserver_changed (GSettings *settings, const gchar *key, gpointer user_data)
{
- GSList *l, *ks;
- GConfValue *value;
+ SeahorseWidget *swidget = SEAHORSE_WIDGET (user_data);
+ gchar **keyservers;
- if (g_str_equal (KEYSERVER_KEY, gconf_entry_get_key (entry))) {
- value = gconf_entry_get_value (entry);
- g_return_if_fail (gconf_value_get_list_type (value) == GCONF_VALUE_STRING);
-
- /* Change list of GConfValue to list of strings */
- for (ks = NULL, l = gconf_value_get_list (value); l; l = l->next)
- ks = g_slist_append (ks, (gchar*)gconf_value_get_string (l->data));
- populate_keyservers (swidget, ks);
- g_slist_free (l); /* We don't own string values */
- }
-}
-
-/* Remove gconf notification */
-static void
-gconf_unnotify (GtkWidget *widget, guint notify_id)
-{
- seahorse_gconf_unnotify (notify_id);
+ keyservers = g_settings_get_strv (settings, key);
+ populate_keyservers (swidget, keyservers);
+ g_strfreev (keyservers);
}
static gchar*
@@ -250,7 +234,6 @@ calculate_keyserver_uri (SeahorseWidget *swidget)
active = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
if (active >= 0) {
types = g_object_get_data (G_OBJECT (swidget), "keyserver-types");
- g_return_val_if_fail (types != NULL, NULL);
scheme = (const gchar*)g_slist_nth_data (types, active);
if (scheme && !scheme[0])
scheme = NULL;
@@ -309,7 +292,6 @@ on_prefs_add_keyserver_uri_changed (GtkWidget *button, SeahorseWidget *swidget)
active = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
if (active > -1) {
types = g_object_get_data (G_OBJECT (swidget), "keyserver-types");
- g_return_if_fail (types != NULL);
widget = GTK_WIDGET (seahorse_widget_get_widget (swidget, "port-block"));
g_return_if_fail (widget != NULL);
@@ -385,53 +367,49 @@ on_prefs_keyserver_add_clicked (GtkButton *button, SeahorseWidget *sw)
static void
setup_keyservers (SeahorseWidget *swidget)
{
- GtkTreeView *treeview;
- SeahorseKeyserverControl *skc;
- GtkTreeModel *model;
- GtkTreeSelection *selection;
- GtkWidget *w;
- GSList *ks;
- guint notify_id;
-
- ks = seahorse_servers_get_uris ();
- populate_keyservers (swidget, ks);
- seahorse_util_string_slist_free (ks);
-
- treeview = GTK_TREE_VIEW (seahorse_widget_get_widget (swidget, "keyservers"));
- model = gtk_tree_view_get_model (treeview);
- g_signal_connect (model, "row-changed", G_CALLBACK (keyserver_row_changed), swidget);
- g_signal_connect (model, "row-deleted", G_CALLBACK (keyserver_row_deleted), swidget);
-
- selection = gtk_tree_view_get_selection (treeview);
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
- g_signal_connect (selection, "changed", G_CALLBACK (keyserver_sel_changed), swidget);
-
- gtk_builder_connect_signals (swidget->gtkbuilder, swidget);
-
- notify_id = seahorse_gconf_notify (KEYSERVER_KEY, (GConfClientNotifyFunc)gconf_notify,
- swidget);
- g_signal_connect (seahorse_widget_get_toplevel (swidget), "destroy",
- G_CALLBACK (gconf_unnotify), GINT_TO_POINTER (notify_id));
-
- w = GTK_WIDGET (seahorse_widget_get_widget (swidget, "keyserver-publish"));
- g_return_if_fail (w != NULL);
-
- skc = seahorse_keyserver_control_new (PUBLISH_TO_KEY, _("None: Don't publish keys"));
- gtk_container_add (GTK_CONTAINER (w), GTK_WIDGET (skc));
- gtk_widget_show_all (w);
-
- w = GTK_WIDGET (seahorse_widget_get_widget (swidget, "keyserver-publish-to-label"));
- gtk_label_set_mnemonic_widget (GTK_LABEL (w), GTK_WIDGET (skc));
-
- w = GTK_WIDGET (seahorse_widget_get_widget (swidget, "auto_retrieve"));
- g_return_if_fail (w != NULL);
-
- seahorse_check_button_gconf_attach (GTK_CHECK_BUTTON(w), AUTORETRIEVE_KEY);
-
- w = GTK_WIDGET (seahorse_widget_get_widget (swidget, "auto_sync"));
- g_return_if_fail (w != NULL);
-
- seahorse_check_button_gconf_attach (GTK_CHECK_BUTTON(w), AUTOSYNC_KEY);
+ GtkTreeView *treeview;
+ SeahorseKeyserverControl *skc;
+ GtkTreeModel *model;
+ GtkTreeSelection *selection;
+ GtkWidget *widget;
+ gchar **keyservers;
+
+ keyservers = seahorse_servers_get_uris ();
+ populate_keyservers (swidget, keyservers);
+ g_strfreev (keyservers);
+
+ treeview = GTK_TREE_VIEW (seahorse_widget_get_widget (swidget, "keyservers"));
+ model = gtk_tree_view_get_model (treeview);
+ g_signal_connect (model, "row-changed", G_CALLBACK (keyserver_row_changed), swidget);
+ g_signal_connect (model, "row-deleted", G_CALLBACK (keyserver_row_deleted), swidget);
+
+ selection = gtk_tree_view_get_selection (treeview);
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
+ g_signal_connect (selection, "changed", G_CALLBACK (keyserver_sel_changed), swidget);
+
+ gtk_builder_connect_signals (swidget->gtkbuilder, swidget);
+ g_signal_connect_object (seahorse_context_pgp_settings (NULL), "changed::keyserver",
+ G_CALLBACK (on_settings_keyserver_changed), swidget, 0);
+
+ widget = seahorse_widget_get_widget (swidget, "keyserver-publish");
+ g_return_if_fail (widget != NULL);
+
+ skc = seahorse_keyserver_control_new ("server-publish-to", _("None: Don't publish keys"));
+ gtk_container_add (GTK_CONTAINER (widget), GTK_WIDGET (skc));
+ gtk_widget_show_all (widget);
+
+ widget = seahorse_widget_get_widget (swidget, "keyserver-publish-to-label");
+ gtk_label_set_mnemonic_widget (GTK_LABEL (widget), GTK_WIDGET (skc));
+
+ widget = seahorse_widget_get_widget (swidget, "auto_retrieve");
+ g_return_if_fail (widget != NULL);
+ g_settings_bind (seahorse_context_settings (NULL), "server-auto-retrieve",
+ widget, "active", G_SETTINGS_BIND_DEFAULT);
+
+ widget = seahorse_widget_get_widget (swidget, "auto_sync");
+ g_return_if_fail (widget != NULL);
+ g_settings_bind (seahorse_context_settings (NULL), "server-auto-publish",
+ widget, "active", G_SETTINGS_BIND_DEFAULT);
}
#endif /* WITH_KEYSERVER */
diff --git a/libseahorse/seahorse-servers.c b/libseahorse/seahorse-servers.c
index d0c31c4..e736d55 100644
--- a/libseahorse/seahorse-servers.c
+++ b/libseahorse/seahorse-servers.c
@@ -19,8 +19,8 @@
* Boston, MA 02111-1307, USA.
*/
+#include "seahorse-context.h"
#include "seahorse-servers.h"
-#include "seahorse-gconf.h"
#include "common/seahorse-cleanup.h"
@@ -97,45 +97,46 @@ seahorse_servers_register_type (const char* type, const char* description,
}
-GSList*
-seahorse_servers_get_uris (void)
+gchar **
+seahorse_servers_get_uris (void)
{
- GSList* servers, *l;
- gchar *name, *value;
-
- servers = seahorse_gconf_get_string_list (KEYSERVER_KEY);
-
+ gchar **servers;
+ gchar *name;
+ guint i;
+
+ servers = g_settings_get_strv (seahorse_context_pgp_settings (NULL), "keyservers");
+
/* The values are 'uri name', remove the name part */
- for (l = servers; l; l = g_slist_next (l)) {
- value = l->data;
- g_strstrip (value);
- name = strchr (value, ' ');
- if (name)
- *name = 0;
+ for (i = 0; servers[i] != NULL; i++) {
+ g_strstrip (servers[i]);
+ name = strchr (servers[i], ' ');
+ if (name != NULL)
+ *name = '\0';
}
-
+
return servers;
}
-GSList*
-seahorse_servers_get_names (void)
+gchar **
+seahorse_servers_get_names (void)
{
- GSList* servers, *l;
- gchar *name, *value;
-
- servers = seahorse_gconf_get_string_list (KEYSERVER_KEY);
-
- /* The values are 'uri name', remove the name part */
- for (l = servers; l; l = g_slist_next (l)) {
- value = l->data;
- g_strstrip (value);
- name = strchr (value, ' ');
- if (name) {
- memset (value, ' ', name - value);
- g_strstrip (value);
+ gchar **servers;
+ gchar *name;
+ guint i;
+
+ servers = g_settings_get_strv (seahorse_context_pgp_settings (NULL),
+ "keyservers");
+
+ /* The values are 'uri name', remove the value part */
+ for (i = 0; servers[i] != NULL; i++) {
+ g_strstrip (servers[i]);
+ name = strchr (servers[i], ' ');
+ if (name != NULL) {
+ memset (servers[i], ' ', name - servers[i]);
+ g_strstrip (servers[i]);
}
}
-
+
return servers;
}
diff --git a/libseahorse/seahorse-servers.h b/libseahorse/seahorse-servers.h
index e620252..867cc75 100644
--- a/libseahorse/seahorse-servers.h
+++ b/libseahorse/seahorse-servers.h
@@ -23,14 +23,15 @@
#define __SEAHORSE_SERVERS_H__
#include <glib.h>
+#include <gio/gio.h>
GSList* seahorse_servers_get_types (void);
-GSList* seahorse_servers_get_names (void);
+gchar ** seahorse_servers_get_names (void);
char* seahorse_servers_get_description (const char* type);
-GSList* seahorse_servers_get_uris (void);
+gchar ** seahorse_servers_get_uris (void);
gboolean seahorse_servers_is_valid_uri (const char* uri);
diff --git a/libseahorse/seahorse-set.c b/libseahorse/seahorse-set.c
index c714744..9ce8078 100644
--- a/libseahorse/seahorse-set.c
+++ b/libseahorse/seahorse-set.c
@@ -21,7 +21,6 @@
#include "seahorse-set.h"
#include "seahorse-marshal.h"
-#include "seahorse-gconf.h"
enum {
PROP_0,
@@ -50,7 +49,7 @@ G_DEFINE_TYPE (SeahorseSet, seahorse_set, G_TYPE_OBJECT);
*/
static gboolean
-remove_update (SeahorseObject *sobj, SeahorseSet *skset)
+remove_update (SeahorseObject *sobj, gpointer unused, SeahorseSet *skset)
{
g_signal_emit (skset, signals[REMOVED], 0, sobj);
g_signal_emit (skset, signals[SET_CHANGED], 0);
@@ -61,7 +60,7 @@ static void
remove_object (SeahorseObject *sobj, SeahorseSet *skset)
{
g_hash_table_remove (skset->pv->objects, sobj);
- remove_update (sobj, skset);
+ remove_update (sobj, NULL, skset);
}
static gboolean
@@ -150,16 +149,16 @@ objects_to_hash (SeahorseObject *sobj, gpointer *c, GHashTable *ht)
static void
seahorse_set_dispose (GObject *gobject)
{
- SeahorseSet *skset = SEAHORSE_SET (gobject);
-
- /* Release all our pointers and stuff */
- g_hash_table_foreach_remove (skset->pv->objects, (GHRFunc)remove_update, skset);
- skset->pv->pred = NULL;
-
- g_signal_handlers_disconnect_by_func (SCTX_APP (), object_added, skset);
- g_signal_handlers_disconnect_by_func (SCTX_APP (), object_removed, skset);
- g_signal_handlers_disconnect_by_func (SCTX_APP (), object_changed, skset);
-
+ SeahorseSet *skset = SEAHORSE_SET (gobject);
+
+ g_signal_handlers_disconnect_by_func (SCTX_APP (), object_added, skset);
+ g_signal_handlers_disconnect_by_func (SCTX_APP (), object_removed, skset);
+ g_signal_handlers_disconnect_by_func (SCTX_APP (), object_changed, skset);
+
+ /* Release all our pointers and stuff */
+ g_hash_table_foreach_remove (skset->pv->objects, (GHRFunc)remove_update, skset);
+ skset->pv->pred = NULL;
+
G_OBJECT_CLASS (seahorse_set_parent_class)->dispose (gobject);
}
diff --git a/libseahorse/seahorse-util.c b/libseahorse/seahorse-util.c
index 5bfb323..c886c8f 100644
--- a/libseahorse/seahorse-util.c
+++ b/libseahorse/seahorse-util.c
@@ -22,7 +22,6 @@
#include "config.h"
-#include "seahorse-gconf.h"
#include "seahorse-object.h"
#include "seahorse-util.h"
diff --git a/libseahorse/seahorse-widget.c b/libseahorse/seahorse-widget.c
index 8b40614..5838fb6 100644
--- a/libseahorse/seahorse-widget.c
+++ b/libseahorse/seahorse-widget.c
@@ -27,7 +27,6 @@
#include <glib/gi18n.h>
#include "seahorse-widget.h"
-#include "seahorse-gconf.h"
#include "seahorse-gtkstock.h"
/**
@@ -66,10 +65,6 @@ static void object_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
-
-static GObject* seahorse_widget_constructor (GType type,
- guint n_props,
- GObjectConstructParam* props);
/* signal functions */
G_MODULE_EXPORT void on_widget_closed (GtkWidget *widget,
@@ -116,6 +111,31 @@ seahorse_widget_get_type (void)
return widget_type;
}
+static void
+seahorse_widget_constructed (GObject *object)
+{
+ SeahorseWidget *self = SEAHORSE_WIDGET (object);
+ GtkWindow *window;
+ gint width, height;
+ gchar *path;
+
+ G_OBJECT_CLASS (parent_class)->constructed (object);
+
+ /* Load window size for windows that aren't dialogs */
+ window = GTK_WINDOW (seahorse_widget_get_toplevel (self));
+ if (!GTK_IS_DIALOG (window)) {
+ path = g_strdup_printf ("/apps/seahorse/windows/%s/", self->name);
+ self->settings = g_settings_new_with_path ("org.gnome.seahorse.window", path);
+ g_free (path);
+
+ width = g_settings_get_int (self->settings, "width");
+ height = g_settings_get_int (self->settings, "height");
+
+ if (width > 0 && height > 0)
+ gtk_window_resize (window, width, height);
+ }
+}
+
/**
* klass: the #SeahorseWidgetClass
*
@@ -129,8 +149,8 @@ class_init (SeahorseWidgetClass *klass)
parent_class = g_type_class_peek_parent (klass);
gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->constructor = seahorse_widget_constructor;
+
+ gobject_class->constructed = seahorse_widget_constructed;
gobject_class->dispose = object_dispose;
gobject_class->finalize = object_finalize;
gobject_class->set_property = object_set_property;
@@ -171,47 +191,6 @@ object_init (SeahorseWidget *swidget)
G_CALLBACK (context_destroyed), swidget);
}
-/**
-* type: the #GType to construct
-* n_props: number of properties
-* props: properties
-*
-*
-*
-* Returns the initialised object
-**/
-static GObject*
-seahorse_widget_constructor (GType type, guint n_props, GObjectConstructParam* props)
-{
- SeahorseWidget *swidget;
- GObject *obj;
-
- GtkWindow *window;
- gint width, height;
- gchar *widthkey, *heightkey;
-
- obj = G_OBJECT_CLASS (parent_class)->constructor (type, n_props, props);
- swidget = SEAHORSE_WIDGET (obj);
-
- /* Load window size for windows that aren't dialogs */
- window = GTK_WINDOW (seahorse_widget_get_toplevel (swidget));
- if (!GTK_IS_DIALOG (window)) {
- widthkey = g_strdup_printf ("%s%s%s", WINDOW_SIZE, swidget->name, "_width");
- width = seahorse_gconf_get_integer (widthkey);
-
- heightkey = g_strdup_printf ("%s%s%s", WINDOW_SIZE, swidget->name, "_height");
- height = seahorse_gconf_get_integer (heightkey);
-
- if (width > 0 && height > 0)
- gtk_window_resize (window, width, height);
-
- g_free (widthkey);
- g_free (heightkey);
- }
-
- return obj;
-}
-
static void
object_dispose (GObject *object)
{
@@ -250,12 +229,14 @@ object_finalize (GObject *gobject)
}
g_signal_handlers_disconnect_by_func (SCTX_APP (), context_destroyed, swidget);
+
if (seahorse_widget_get_widget (swidget, swidget->name))
gtk_widget_destroy (GTK_WIDGET (seahorse_widget_get_widget (swidget, swidget->name)));
g_object_unref (swidget->gtkbuilder);
swidget->gtkbuilder = NULL;
-
+
+ g_clear_object (&swidget->settings);
g_free (swidget->name);
G_OBJECT_CLASS (parent_class)->finalize (gobject);
@@ -589,40 +570,32 @@ seahorse_widget_set_sensitive (SeahorseWidget *swidget, const char *identifier,
/**
* seahorse_widget_destroy:
- * @swidget: #SeahorseWidget to destroy
+ * @self: #SeahorseWidget to destroy
*
* Unrefs @swidget.
**/
void
-seahorse_widget_destroy (SeahorseWidget *swidget)
+seahorse_widget_destroy (SeahorseWidget *self)
{
- GtkWidget *widget;
- gchar *widthkey, *heightkey;
- gint width, height;
+ GtkWidget *widget;
+ gint width, height;
- g_return_if_fail (swidget != NULL && SEAHORSE_IS_WIDGET (swidget));
- widget = seahorse_widget_get_toplevel (swidget);
-
- /* Don't save window size for dialogs */
- if (!GTK_IS_DIALOG (widget)) {
+ g_return_if_fail (self != NULL && SEAHORSE_IS_WIDGET (self));
+ widget = seahorse_widget_get_toplevel (self);
- /* Save window size */
- gtk_window_get_size (GTK_WINDOW (widget), &width, &height);
-
- widthkey = g_strdup_printf ("%s%s%s", WINDOW_SIZE, swidget->name, "_width");
- seahorse_gconf_set_integer (widthkey, width);
-
- heightkey = g_strdup_printf ("%s%s%s", WINDOW_SIZE, swidget->name, "_height");
- seahorse_gconf_set_integer (heightkey, height);
-
- g_free (widthkey);
- g_free (heightkey);
- }
-
- /* Destroy Widget */
- if (!swidget->destroying) {
- swidget->destroying = TRUE;
- gtk_widget_destroy (seahorse_widget_get_toplevel (swidget));
- g_object_unref (swidget);
- }
+ /* Save window size */
+ if (self->settings) {
+
+ gtk_window_get_size (GTK_WINDOW (widget), &width, &height);
+
+ g_settings_set_int (self->settings, "width", width);
+ g_settings_set_int (self->settings, "height", height);
+ }
+
+ /* Destroy Widget */
+ if (!self->destroying) {
+ self->destroying = TRUE;
+ gtk_widget_destroy (seahorse_widget_get_toplevel (self));
+ g_object_unref (self);
+ }
}
diff --git a/libseahorse/seahorse-widget.h b/libseahorse/seahorse-widget.h
index 76dd225..9acc8b9 100644
--- a/libseahorse/seahorse-widget.h
+++ b/libseahorse/seahorse-widget.h
@@ -67,6 +67,7 @@ struct _SeahorseWidget {
/*< private >*/
gboolean destroying;
gboolean in_destruction;
+ GSettings *settings;
};
struct _SeahorseWidgetClass {
diff --git a/pgp/seahorse-gpgme-sign.c b/pgp/seahorse-gpgme-sign.c
index aa1291b..749c0c9 100644
--- a/pgp/seahorse-gpgme-sign.c
+++ b/pgp/seahorse-gpgme-sign.c
@@ -23,7 +23,6 @@
#include "config.h"
#include "seahorse-combo-keys.h"
-#include "seahorse-gconf.h"
#include "seahorse-gtkstock.h"
#include "seahorse-object-widget.h"
#include "seahorse-set.h"
@@ -197,7 +196,7 @@ sign_internal (SeahorseObject *to_sign, GtkWindow *parent)
/* Signature area */
w = GTK_WIDGET (seahorse_widget_get_widget (swidget, "signer-frame"));
g_return_if_fail (w != NULL);
- g_signal_connect (skset, "set-changed", G_CALLBACK (keyset_changed), w);
+ g_signal_connect_object (skset, "set-changed", G_CALLBACK (keyset_changed), w, 0);
keyset_changed (skset, w);
/* Signer box */
diff --git a/pgp/seahorse-hkp-source.c b/pgp/seahorse-hkp-source.c
index eb10b1e..e411905 100644
--- a/pgp/seahorse-hkp-source.c
+++ b/pgp/seahorse-hkp-source.c
@@ -32,7 +32,6 @@
#include "seahorse-pgp-subkey.h"
#include "seahorse-pgp-uid.h"
-#include "seahorse-gconf.h"
#include "seahorse-operation.h"
#include "seahorse-servers.h"
#include "seahorse-util.h"
@@ -146,6 +145,74 @@ END_DECLARE_OPERATION
IMPLEMENT_OPERATION (HKP, hkp)
+static gboolean
+check_for_http_proxy_schema__with_love_to_ryan ()
+{
+ const gchar * const* schemas;
+ guint i;
+
+ /*
+ * This isn't very efficient, but it's the only way to use this schema
+ * without our GSettings killing our process if the schema doesn't exist.
+ *
+ * Groan.
+ */
+
+ schemas = g_settings_list_schemas ();
+ for (i = 0; schemas[i] != NULL; i++) {
+ if (g_str_equal (schemas[i], "org.gnome.system.proxy.http"))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static SoupSession *
+create_proxy_session (void)
+{
+ SoupSession *session = NULL;
+ SoupURI *uri;
+ GSettings *settings;
+ gchar *host;
+ gchar *user;
+ gchar *password;
+
+ if (!check_for_http_proxy_schema__with_love_to_ryan ())
+ return NULL;
+
+ settings = g_settings_new ("org.gnome.system.proxy.http");
+ if (g_settings_get_boolean (settings, "enabled")) {
+ host = g_settings_get_string (settings, "host");
+ if (host) {
+ uri = soup_uri_new (NULL);
+ if (!uri) {
+ g_warning ("creation of SoupURI from '%s' failed", host);
+ } else {
+ soup_uri_set_scheme (uri, SOUP_URI_SCHEME_HTTP);
+ soup_uri_set_host (uri, host);
+ }
+ g_free (host);
+ soup_uri_set_port (uri, g_settings_get_int (settings, "port"));
+
+ if (g_settings_get_boolean (settings, "use-authentication")) {
+ user = g_settings_get_string (settings, "authentication-user");
+ soup_uri_set_user (uri, user);
+ g_free (user);
+
+ password = g_settings_get_string (settings, "authentication-password");
+ soup_uri_set_password (uri, password);
+ g_free (password);
+ }
+
+ session = soup_session_async_new_with_options (SOUP_SESSION_PROXY_URI, uri, NULL);
+ soup_uri_free (uri);
+ }
+ }
+
+ g_object_unref (settings);
+ return session;
+}
+
/**
* hop: A SeahorseHKPOperation to init
*
@@ -155,48 +222,15 @@ IMPLEMENT_OPERATION (HKP, hkp)
static void
seahorse_hkp_operation_init (SeahorseHKPOperation *hop)
{
- SoupURI *uri;
- gchar *host;
#if WITH_DEBUG
- SoupLogger *logger;
+ SoupLogger *logger;
#endif
-
- if (seahorse_gconf_get_boolean (GCONF_USE_HTTP_PROXY)) {
-
- host = seahorse_gconf_get_string (GCONF_HTTP_PROXY_HOST);
- if (host) {
- uri = soup_uri_new (NULL);
-
- if (!uri) {
- g_warning ("creation of SoupURI from '%s' failed", host);
-
- } else {
- soup_uri_set_scheme (uri, SOUP_URI_SCHEME_HTTP);
- soup_uri_set_host (uri, host);
- g_free (host);
- soup_uri_set_port (uri, seahorse_gconf_get_integer (GCONF_PROXY_PORT));
-
- if (seahorse_gconf_get_boolean (GCONF_USE_AUTH)) {
- char *user, *pass;
-
- user = seahorse_gconf_get_string (GCONF_AUTH_USER);
- soup_uri_set_user (uri, user);
- g_free (user);
- pass = seahorse_gconf_get_string (GCONF_AUTH_PASS);
- soup_uri_set_password (uri, pass);
- g_free (pass);
- }
-
- hop->session = soup_session_async_new_with_options (SOUP_SESSION_PROXY_URI, uri, NULL);
- soup_uri_free (uri);
- }
- }
- }
-
- /* Without a proxy */
- if (!hop->session)
- hop->session = soup_session_async_new ();
+ hop->session = create_proxy_session ();
+
+ /* Without a proxy */
+ if (hop->session == NULL)
+ hop->session = soup_session_async_new ();
#if WITH_DEBUG
if (seahorse_debugging) {
diff --git a/pgp/seahorse-pgp-key-properties.c b/pgp/seahorse-pgp-key-properties.c
index 5de3b68..b41cb8e 100644
--- a/pgp/seahorse-pgp-key-properties.c
+++ b/pgp/seahorse-pgp-key-properties.c
@@ -29,7 +29,6 @@
#include <glib/gi18n.h>
-#include "seahorse-gconf.h"
#include "seahorse-gtkstock.h"
#include "seahorse-object.h"
#include "seahorse-object-model.h"
diff --git a/pgp/seahorse-pgp-keysets.c b/pgp/seahorse-pgp-keysets.c
index 0999b29..9dda768 100644
--- a/pgp/seahorse-pgp-keysets.c
+++ b/pgp/seahorse-pgp-keysets.c
@@ -21,7 +21,6 @@
#include "config.h"
-#include "seahorse-gconf.h"
#include "seahorse-object.h"
#include "seahorse-pgp-module.h"
@@ -32,11 +31,12 @@
*/
static void
-pgp_signers_gconf_notify (GConfClient *client, guint id, GConfEntry *entry,
- SeahorseSet *skset)
+on_settings_default_key_changed (GSettings *settings, const gchar *key, gpointer user_data)
{
- /* Default key changed, refresh */
- seahorse_set_refresh (skset);
+ SeahorseSet *skset = SEAHORSE_SET (user_data);
+
+ /* Default key changed, refresh */
+ seahorse_set_refresh (skset);
}
static gboolean
@@ -71,9 +71,9 @@ seahorse_keyset_pgp_signers_new ()
skset = seahorse_set_new_full (pred);
g_object_set_data_full (G_OBJECT (skset), "pgp-signers-predicate", pred, g_free);
-
- seahorse_gconf_notify_lazy (SEAHORSE_DEFAULT_KEY,
- (GConfClientNotifyFunc)pgp_signers_gconf_notify,
- skset, skset);
+
+ g_signal_connect_object (seahorse_context_pgp_settings (NULL), "changed::default-key",
+ G_CALLBACK (on_settings_default_key_changed), skset, 0);
+
return skset;
}
diff --git a/pgp/seahorse-signer.c b/pgp/seahorse-signer.c
index 1b575ee..8103925 100755
--- a/pgp/seahorse-signer.c
+++ b/pgp/seahorse-signer.c
@@ -30,7 +30,6 @@
#include "seahorse-widget.h"
#include "seahorse-validity.h"
#include "seahorse-combo-keys.h"
-#include "seahorse-gconf.h"
#include "seahorse-util.h"
#include "pgp/seahorse-pgp-key.h"
@@ -47,6 +46,7 @@ seahorse_signer_get (GtkWindow *parent)
gint response;
gboolean done = FALSE;
gboolean ok = FALSE;
+ GSettings *settings;
gchar *id;
guint nkeys;
@@ -81,9 +81,11 @@ seahorse_signer_get (GtkWindow *parent)
g_return_val_if_fail (combo != NULL, NULL);
seahorse_combo_keys_attach (GTK_COMBO_BOX (combo), skset, NULL);
g_object_unref (skset);
-
+
+ settings = seahorse_context_pgp_settings (NULL);
+
/* Select the last key used */
- id = seahorse_gconf_get_string (SEAHORSE_LASTSIGNER_KEY);
+ id = g_settings_get_string (settings, "last-signer");
seahorse_combo_keys_set_active_id (GTK_COMBO_BOX (combo), g_quark_from_string (id));
g_free (id);
@@ -108,8 +110,8 @@ seahorse_signer_get (GtkWindow *parent)
g_return_val_if_fail (SEAHORSE_IS_PGP_KEY (object), NULL);
/* Save this as the last key signed with */
- seahorse_gconf_set_string (SEAHORSE_LASTSIGNER_KEY, object == NULL ?
- "" : g_quark_to_string (seahorse_object_get_id (object)));
+ g_settings_set_string (settings, "last-signer",
+ object == NULL ? "" : g_quark_to_string (seahorse_object_get_id (object)));
}
seahorse_widget_destroy (swidget);
diff --git a/pkcs11/seahorse-pkcs11-module.c b/pkcs11/seahorse-pkcs11-module.c
index 105c5f7..75e1071 100644
--- a/pkcs11/seahorse-pkcs11-module.c
+++ b/pkcs11/seahorse-pkcs11-module.c
@@ -26,7 +26,6 @@
#include "seahorse-pkcs11-commands.h"
#include "seahorse-pkcs11-source.h"
-#include "seahorse-gconf.h"
#include "seahorse-util.h"
#include <gck/gck.h>
@@ -34,19 +33,18 @@
void
seahorse_pkcs11_module_init (void)
{
+ /* TODO: Use modules from p11-kit via gck */
+#if 0
SeahorseSource *source;
GckModule *module;
- GSList *l, *module_paths;
GList *slots, *s;
GError *err = NULL;
-
- /* Load each module in turn, and each slot for each module */
- module_paths = seahorse_gconf_get_string_list ("/system/pkcs11/modules");
+
for (l = module_paths; l; l = g_slist_next (l)) {
module = gck_module_initialize (l->data, &err);
if (!module) {
- g_warning ("couldn't initialize %s pkcs11 module: %s",
+ g_warning ("couldn't initialize %s pkcs11 module: %s",
(gchar*)l->data, err ? err->message : NULL);
g_clear_error (&err);
continue;
@@ -62,8 +60,7 @@ seahorse_pkcs11_module_init (void)
gck_list_unref_free (slots);
g_object_unref (module);
}
-
- seahorse_util_string_slist_free (module_paths);
+#endif
/* Let these register themselves */
g_type_class_unref (g_type_class_ref (SEAHORSE_TYPE_PKCS11_SOURCE));
diff --git a/src/seahorse-key-manager-store.c b/src/seahorse-key-manager-store.c
index ee92703..5e64a76 100644
--- a/src/seahorse-key-manager-store.c
+++ b/src/seahorse-key-manager-store.c
@@ -28,7 +28,6 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
-#include "seahorse-gconf.h"
#include "seahorse-key-manager-store.h"
#include "seahorse-preferences.h"
#include "seahorse-util.h"
@@ -42,9 +41,10 @@
#define KEY_MANAGER_SORT_KEY "/apps/seahorse/listing/sort_by"
enum {
- PROP_0,
- PROP_MODE,
- PROP_FILTER
+ PROP_0,
+ PROP_MODE,
+ PROP_FILTER,
+ PROP_SETTINGS
};
enum {
@@ -91,10 +91,11 @@ static GtkTargetEntry store_targets[] = {
{ "XdndDirectSave0", 0, DRAG_INFO_XDS }
};
-struct _SeahorseKeyManagerStorePriv {
- GtkTreeModelFilter *filter;
- GtkTreeModelSort *sort;
-
+struct _SeahorseKeyManagerStorePriv {
+ GtkTreeModelFilter *filter;
+ GtkTreeModelSort *sort;
+ GSettings *settings;
+
SeahorseKeyManagerStoreMode filter_mode;
gchar* filter_text;
guint filter_stag;
@@ -317,69 +318,64 @@ set_sort_to (SeahorseKeyManagerStore *skstore, const gchar *name)
static void
sort_changed (GtkTreeSortable *sort, gpointer user_data)
{
- gint id;
- GtkSortType ord;
- SeahorseKeyManagerStore *skstore;
- const gchar* t;
- gchar* x;
-
- skstore = SEAHORSE_KEY_MANAGER_STORE (user_data);
- g_return_if_fail (skstore->priv->sort);
-
- /* We have a sort so save it */
- if (gtk_tree_sortable_get_sort_column_id (sort, &id, &ord)) {
- if (id >= 0 && id < N_COLS) {
- t = column_info[id].data;
- if (t != NULL) {
- x = g_strconcat (ord == GTK_SORT_DESCENDING ? "-" : "", t, NULL);
- seahorse_gconf_set_string (KEY_MANAGER_SORT_KEY, x);
- g_free (x);
- }
- }
- }
-
- /* No sort so save blank */
- else {
- seahorse_gconf_set_string (KEY_MANAGER_SORT_KEY, "");
- }
+ SeahorseKeyManagerStore *self = SEAHORSE_KEY_MANAGER_STORE (user_data);
+ GtkSortType ord;
+ gchar* value;
+ gint column_id;
+
+ g_return_if_fail (self->priv->sort);
+ if (!self->priv->settings)
+ return;
+
+ /* We have a sort so save it */
+ if (gtk_tree_sortable_get_sort_column_id (sort, &column_id, &ord)) {
+ if (column_id >= 0 && column_id < N_COLS) {
+ if (column_info[column_id].data != NULL) {
+ value = g_strconcat (ord == GTK_SORT_DESCENDING ? "-" : "",
+ column_info[column_id].data, NULL);
+ g_settings_set_string (self->priv->settings, "sort-by", value);
+ g_free (value);
+ }
+ }
+
+ /* No sort so save blank */
+ } else if (self->priv->settings) {
+ g_settings_set_string (self->priv->settings, "sort-by", "");
+ }
}
static void
-gconf_notification (GConfClient *gclient, guint id, GConfEntry *entry, GtkTreeView *view)
+on_manager_settings_changed (GSettings *settings, const gchar *key, gpointer user_data)
{
- SeahorseKeyManagerStore *skstore;
- GtkTreeViewColumn *col = NULL;
- GList *columns, *l;
- GConfValue *value;
- const gchar *key;
- const gchar *t;
+ SeahorseKeyManagerStore *self;
+ GtkTreeViewColumn *col = NULL;
+ GtkTreeView *view = GTK_TREE_VIEW (user_data);
+ const gchar *col_key = NULL;
+ GList *columns, *l;
+ gchar *sort_by;
+
+ if (g_str_equal (key, "sort-by")) {
+ self = key_store_from_model (gtk_tree_view_get_model (view));
+ g_return_if_fail (SEAHORSE_IS_KEY_MANAGER_STORE (self));
+ sort_by = g_settings_get_string (settings, key);
+ set_sort_to (self, sort_by);
+ g_free (sort_by);
+ return;
+ }
- key = gconf_entry_get_key (entry);
+ columns = gtk_tree_view_get_columns (view);
+ for (l = columns; l; l = g_list_next (l)) {
+ col_key = g_object_get_data (G_OBJECT (l->data), "settings-key");
+ if (col_key && g_str_equal (col_key, key)) {
+ col = GTK_TREE_VIEW_COLUMN (l->data);
+ break;
+ }
+ }
- g_assert (key != NULL);
- g_assert (GTK_IS_TREE_VIEW (view));
-
- if (g_str_equal (key, KEY_MANAGER_SORT_KEY)) {
- skstore = key_store_from_model (gtk_tree_view_get_model (view));
- g_return_if_fail (SEAHORSE_IS_KEY_MANAGER_STORE (skstore));
- set_sort_to (skstore, gconf_value_get_string (gconf_entry_get_value (entry)));
- }
-
- columns = gtk_tree_view_get_columns (view);
- for (l = columns; l; l = g_list_next (l)) {
- t = (const gchar*)g_object_get_data (G_OBJECT (l->data), "gconf-key");
- if (t && g_str_equal (t, key)) {
- col = GTK_TREE_VIEW_COLUMN (l->data);
- break;
- }
- }
-
- if (col != NULL) {
- value = gconf_entry_get_value (entry);
- gtk_tree_view_column_set_visible (col, gconf_value_get_bool (value));
- }
-
- g_list_free (columns);
+ if (col != NULL)
+ gtk_tree_view_column_set_visible (col, g_settings_get_boolean (settings, key));
+
+ g_list_free (columns);
}
static GtkTreeViewColumn*
@@ -729,7 +725,11 @@ seahorse_key_manager_store_get_property (GObject *gobject, guint prop_id,
case PROP_MODE:
g_value_set_uint (value, skstore->priv->filter_mode);
break;
-
+
+ case PROP_SETTINGS:
+ g_value_set_object (value, skstore->priv->settings);
+ break;
+
/* The filter text. Note that we act as if we don't have any
* filter text when not in filtering mode */
case PROP_FILTER:
@@ -758,7 +758,11 @@ seahorse_key_manager_store_set_property (GObject *gobject, guint prop_id,
refilter_later (skstore);
}
break;
-
+
+ case PROP_SETTINGS:
+ skstore->priv->settings = g_value_dup_object (value);
+ break;
+
/* The filter text */
case PROP_FILTER:
t = g_value_get_string (value);
@@ -826,6 +830,10 @@ seahorse_key_manager_store_class_init (SeahorseKeyManagerStoreClass *klass)
g_object_class_install_property (gobject_class, PROP_FILTER,
g_param_spec_string ("filter", "Key Store Filter", "Key store filter for when in filtered mode",
"", G_PARAM_READWRITE));
+
+ g_object_class_install_property (gobject_class, PROP_SETTINGS,
+ g_param_spec_object ("settings", "Settings", "Manager Settings",
+ G_TYPE_SETTINGS, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
}
/* -----------------------------------------------------------------------------
@@ -833,16 +841,16 @@ seahorse_key_manager_store_class_init (SeahorseKeyManagerStoreClass *klass)
*/
SeahorseKeyManagerStore*
-seahorse_key_manager_store_new (SeahorseSet *skset, GtkTreeView *view)
+seahorse_key_manager_store_new (SeahorseSet *skset, GtkTreeView *view, GSettings *settings)
{
SeahorseKeyManagerStore *skstore;
GtkTreeViewColumn *col;
SeahorseObjectPredicate *pred;
GtkCellRenderer *renderer;
- gchar *sort;
+ gchar *sort_by;
gint last;
-
- skstore = g_object_new (SEAHORSE_TYPE_KEY_MANAGER_STORE, "set", skset, NULL);
+
+ skstore = g_object_new (SEAHORSE_TYPE_KEY_MANAGER_STORE, "set", skset, "settings", settings, NULL);
last = seahorse_set_model_set_columns (SEAHORSE_SET_MODEL (skstore), column_info, N_COLS);
g_return_val_if_fail (last == N_COLS - 1, NULL);
@@ -884,42 +892,41 @@ seahorse_key_manager_store_new (SeahorseSet *skset, GtkTreeView *view)
/* Public keys show validity */
if (pred->usage == SEAHORSE_USAGE_PUBLIC_KEY) {
col = append_text_column (skstore, view, _("Validity"), COL_VALIDITY_STR);
- g_object_set_data (G_OBJECT (col), "gconf-key", SHOW_VALIDITY_KEY);
- gtk_tree_view_column_set_visible (col, seahorse_gconf_get_boolean (SHOW_VALIDITY_KEY));
+ g_object_set_data (G_OBJECT (col), "settings-key", "show-validity");
+ gtk_tree_view_column_set_visible (col, g_settings_get_boolean (settings, "show-validity"));
gtk_tree_view_column_set_sort_column_id (col, COL_VALIDITY);
}
/* Trust column */
col = append_text_column (skstore, view, _("Trust"), COL_TRUST_STR);
- g_object_set_data (G_OBJECT (col), "gconf-key", SHOW_TRUST_KEY);
- gtk_tree_view_column_set_visible (col, seahorse_gconf_get_boolean (SHOW_TRUST_KEY));
+ g_object_set_data (G_OBJECT (col), "settings-key", "show-trust");
+ gtk_tree_view_column_set_visible (col, g_settings_get_boolean (settings, "show-trust"));
gtk_tree_view_column_set_sort_column_id (col, COL_TRUST);
-
+
/* The key type column */
col = append_text_column (skstore, view, _("Type"), COL_TYPE);
- g_object_set_data (G_OBJECT (col), "gconf-key", SHOW_TYPE_KEY);
- gtk_tree_view_column_set_visible (col, seahorse_gconf_get_boolean (SHOW_TYPE_KEY));
+ g_object_set_data (G_OBJECT (col), "settings-key", "show-type");
+ gtk_tree_view_column_set_visible (col, g_settings_get_boolean (settings, "show-type"));
gtk_tree_view_column_set_sort_column_id (col, COL_TYPE);
/* Expiry date column */
col = append_text_column (skstore, view, _("Expiration Date"), COL_EXPIRES_STR);
- g_object_set_data (G_OBJECT (col), "gconf-key", SHOW_EXPIRES_KEY);
- gtk_tree_view_column_set_visible (col, seahorse_gconf_get_boolean (SHOW_EXPIRES_KEY));
+ g_object_set_data (G_OBJECT (col), "settings-key", "show-expiry");
+ gtk_tree_view_column_set_visible (col, g_settings_get_boolean (settings, "show-expiry"));
gtk_tree_view_column_set_sort_column_id (col, COL_EXPIRES);
/* Also watch for sort-changed on the store */
g_signal_connect (skstore->priv->sort, "sort-column-changed", G_CALLBACK (sort_changed), skstore);
/* Update sort order in case the sorted column was added */
- if ((sort = seahorse_gconf_get_string (KEY_MANAGER_SORT_KEY)) != NULL) {
- set_sort_to (skstore, sort);
- g_free (sort);
+ if ((sort_by = g_settings_get_string (settings, "sort-by")) != NULL) {
+ set_sort_to (skstore, sort_by);
+ g_free (sort_by);
}
gtk_tree_view_set_enable_search (view, FALSE);
-
- seahorse_gconf_notify_lazy (LISTING_SCHEMAS, (GConfClientNotifyFunc)gconf_notification,
- view, GTK_WIDGET (view));
+
+ g_signal_connect_object (settings, "changed", G_CALLBACK (on_manager_settings_changed), view, 0);
/* Tree drag */
egg_tree_multi_drag_add_drag_support (view);
diff --git a/src/seahorse-key-manager-store.h b/src/seahorse-key-manager-store.h
index 363666b..1dfc859 100644
--- a/src/seahorse-key-manager-store.h
+++ b/src/seahorse-key-manager-store.h
@@ -57,7 +57,8 @@ struct _SeahorseKeyManagerStoreClass {
};
SeahorseKeyManagerStore* seahorse_key_manager_store_new (SeahorseSet *skset,
- GtkTreeView *view);
+ GtkTreeView *view,
+ GSettings *settings);
SeahorseObject* seahorse_key_manager_store_get_object_from_path (GtkTreeView *view,
GtkTreePath *path);
diff --git a/src/seahorse-key-manager.c b/src/seahorse-key-manager.c
index 7304047..59297bb 100644
--- a/src/seahorse-key-manager.c
+++ b/src/seahorse-key-manager.c
@@ -28,7 +28,6 @@
#include "seahorse-windows.h"
#include "seahorse-keyserver-results.h"
-#include "seahorse-gconf.h"
#include "seahorse-operation.h"
#include "seahorse-progress.h"
#include "seahorse-util.h"
@@ -57,6 +56,7 @@ struct _SeahorseKeyManagerPrivate {
GQuark track_selected_id;
guint track_selected_tab;
TabInfo* tabs;
+ GSettings *settings;
};
enum {
@@ -357,7 +357,7 @@ initialize_tab (SeahorseKeyManager* self, const char* tabwidget, guint tabid, co
gtk_widget_realize (GTK_WIDGET (view));
/* Add new key store and associate it */
- self->pv->tabs[tabid].store = seahorse_key_manager_store_new (objects, view);
+ self->pv->tabs[tabid].store = seahorse_key_manager_store_new (objects, view, self->pv->settings);
}
static gboolean
@@ -660,7 +660,7 @@ on_view_type_activate (GtkToggleAction* action, SeahorseKeyManager* self)
{
g_return_if_fail (SEAHORSE_IS_KEY_MANAGER (self));
g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));
- seahorse_gconf_set_boolean (SHOW_TYPE_KEY, gtk_toggle_action_get_active (action));
+ g_settings_set_boolean (self->pv->settings, "show-type", gtk_toggle_action_get_active (action));
}
@@ -669,7 +669,7 @@ on_view_expires_activate (GtkToggleAction* action, SeahorseKeyManager* self)
{
g_return_if_fail (SEAHORSE_IS_KEY_MANAGER (self));
g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));
- seahorse_gconf_set_boolean (SHOW_EXPIRES_KEY, gtk_toggle_action_get_active (action));
+ g_settings_set_boolean (self->pv->settings, "show-expiry", gtk_toggle_action_get_active (action));
}
@@ -678,7 +678,7 @@ on_view_validity_activate (GtkToggleAction* action, SeahorseKeyManager* self)
{
g_return_if_fail (SEAHORSE_IS_KEY_MANAGER (self));
g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));
- seahorse_gconf_set_boolean (SHOW_VALIDITY_KEY, gtk_toggle_action_get_active (action));
+ g_settings_set_boolean (self->pv->settings, "show-validity", gtk_toggle_action_get_active (action));
}
static void
@@ -686,38 +686,31 @@ on_view_trust_activate (GtkToggleAction* action, SeahorseKeyManager* self)
{
g_return_if_fail (SEAHORSE_IS_KEY_MANAGER (self));
g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));
- seahorse_gconf_set_boolean (SHOW_TRUST_KEY, gtk_toggle_action_get_active (action));
+ g_settings_set_boolean (self->pv->settings, "show-trust", gtk_toggle_action_get_active (action));
}
-static void
-on_gconf_notify (GConfClient* client, guint cnxn_id, GConfEntry* entry, SeahorseKeyManager* self)
+static void
+on_manager_settings_changed (GSettings *settings, const gchar *key, gpointer user_data)
{
+ SeahorseKeyManager *self = SEAHORSE_KEY_MANAGER (user_data);
GtkToggleAction* action;
- const gchar* key;
- const char* name;
+ const gchar* name;
- g_return_if_fail (SEAHORSE_IS_KEY_MANAGER (self));
- g_return_if_fail (GCONF_IS_CLIENT (client));
- g_return_if_fail (entry != NULL);
-
- key = entry->key;
- g_return_if_fail (key);
-
- if (g_str_equal (key, SHOW_TRUST_KEY))
+ if (g_str_equal (key, "show-trust"))
name = "view-trust";
- else if (g_str_equal (key, SHOW_TYPE_KEY))
+ else if (g_str_equal (key, "show-type"))
name = "view-type";
- else if (g_str_equal (key, SHOW_EXPIRES_KEY))
+ else if (g_str_equal (key, "show-expiry"))
name = "view-expires";
- else if (g_str_equal (key, SHOW_VALIDITY_KEY))
+ else if (g_str_equal (key, "show-validity"))
name = "view-validity";
else
return;
-
+
action = GTK_TOGGLE_ACTION (gtk_action_group_get_action (self->pv->view_actions, name));
g_return_if_fail (action != NULL);
-
- gtk_toggle_action_set_active (action, gconf_value_get_bool (entry->value));
+
+ gtk_toggle_action_set_active (action, g_settings_get_boolean (settings, key));
}
static void
@@ -845,16 +838,16 @@ seahorse_key_manager_set_selected (SeahorseViewer* base, SeahorseObject* value)
g_object_notify (G_OBJECT (self), "selected");
}
-static GObject*
-seahorse_key_manager_constructor (GType type, guint n_props, GObjectConstructParam *props)
+static void
+seahorse_key_manager_constructed (GObject *object)
{
- SeahorseKeyManager *self = SEAHORSE_KEY_MANAGER (G_OBJECT_CLASS (seahorse_key_manager_parent_class)->constructor(type, n_props, props));
+ SeahorseKeyManager *self = SEAHORSE_KEY_MANAGER (object);
GtkActionGroup* actions;
GtkToggleAction* action;
GtkTargetList* targets;
GtkWidget* widget;
- g_return_val_if_fail (self, NULL);
+ G_OBJECT_CLASS (seahorse_key_manager_parent_class)->constructed (object);
self->pv->tabs = g_new0 (TabInfo, TAB_NUM_TABS);
@@ -877,18 +870,18 @@ seahorse_key_manager_constructor (GType type, guint n_props, GObjectConstructPar
gtk_action_group_set_translation_domain (self->pv->view_actions, GETTEXT_PACKAGE);
gtk_action_group_add_toggle_actions (self->pv->view_actions, VIEW_ENTRIES, G_N_ELEMENTS (VIEW_ENTRIES), self);
action = GTK_TOGGLE_ACTION (gtk_action_group_get_action (self->pv->view_actions, "view-type"));
- gtk_toggle_action_set_active (action, seahorse_gconf_get_boolean (SHOW_TYPE_KEY));
+ gtk_toggle_action_set_active (action, g_settings_get_boolean (self->pv->settings, "show-type"));
action = GTK_TOGGLE_ACTION (gtk_action_group_get_action (self->pv->view_actions, "view-expires"));
- gtk_toggle_action_set_active (action, seahorse_gconf_get_boolean (SHOW_EXPIRES_KEY));
+ gtk_toggle_action_set_active (action, g_settings_get_boolean (self->pv->settings, "show-expiry"));
action = GTK_TOGGLE_ACTION (gtk_action_group_get_action (self->pv->view_actions, "view-trust"));
- gtk_toggle_action_set_active (action, seahorse_gconf_get_boolean (SHOW_TRUST_KEY));
+ gtk_toggle_action_set_active (action, g_settings_get_boolean (self->pv->settings, "show-trust"));
action = GTK_TOGGLE_ACTION (gtk_action_group_get_action (self->pv->view_actions, "view-validity"));
- gtk_toggle_action_set_active (action, seahorse_gconf_get_boolean (SHOW_VALIDITY_KEY));
+ gtk_toggle_action_set_active (action, g_settings_get_boolean (self->pv->settings, "show-validity"));
seahorse_viewer_include_actions (SEAHORSE_VIEWER (self), self->pv->view_actions);
/* Notify us when gconf stuff changes under this key */
- seahorse_gconf_notify_lazy (LISTING_SCHEMAS, (GConfClientNotifyFunc)on_gconf_notify, self, self);
-
+ g_signal_connect_object (self->pv->settings, "changed", G_CALLBACK (on_manager_settings_changed), self, 0);
+
/* close event */
g_signal_connect_object (seahorse_widget_get_toplevel (SEAHORSE_WIDGET (self)),
"delete-event", G_CALLBACK (on_delete_event), self, 0);
@@ -999,15 +992,13 @@ seahorse_key_manager_constructor (GType type, guint n_props, GObjectConstructPar
g_timeout_add_seconds (1, (GSourceFunc)on_first_timer, self);
g_signal_connect (seahorse_context_instance (), "refreshing", G_CALLBACK (on_refreshing), self);
-
- return G_OBJECT (self);
}
static void
seahorse_key_manager_init (SeahorseKeyManager *self)
{
self->pv = G_TYPE_INSTANCE_GET_PRIVATE (self, SEAHORSE_TYPE_KEY_MANAGER, SeahorseKeyManagerPrivate);
-
+ self->pv->settings = g_settings_new ("org.gnome.seahorse.manager");
}
static void
@@ -1033,6 +1024,8 @@ seahorse_key_manager_finalize (GObject *obj)
self->pv->tabs = NULL;
}
+ g_clear_object (&self->pv->settings);
+
G_OBJECT_CLASS (seahorse_key_manager_parent_class)->finalize (obj);
}
@@ -1076,7 +1069,7 @@ seahorse_key_manager_class_init (SeahorseKeyManagerClass *klass)
seahorse_key_manager_parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (klass, sizeof (SeahorseKeyManagerPrivate));
- gobject_class->constructor = seahorse_key_manager_constructor;
+ gobject_class->constructed = seahorse_key_manager_constructed;
gobject_class->finalize = seahorse_key_manager_finalize;
gobject_class->set_property = seahorse_key_manager_set_property;
gobject_class->get_property = seahorse_key_manager_get_property;
diff --git a/src/seahorse-keyserver-results.c b/src/seahorse-keyserver-results.c
index 8fd1384..cd0b084 100644
--- a/src/seahorse-keyserver-results.c
+++ b/src/seahorse-keyserver-results.c
@@ -45,6 +45,7 @@ struct _SeahorseKeyserverResultsPrivate {
SeahorseKeyManagerStore *store;
SeahorseSet *objects;
SeahorseObjectPredicate pred;
+ GSettings *settings;
};
G_DEFINE_TYPE (SeahorseKeyserverResults, seahorse_keyserver_results, SEAHORSE_TYPE_VIEWER);
@@ -106,7 +107,8 @@ fire_selection_changed (SeahorseKeyserverResults* self)
selection = gtk_tree_view_get_selection (self->pv->view);
rows = gtk_tree_selection_count_selected_rows (selection);
seahorse_viewer_set_numbered_status (SEAHORSE_VIEWER (self), ngettext ("Selected %d key", "Selected %d keys", rows), rows);
- gtk_action_group_set_sensitive (self->pv->object_actions, rows > 0);
+ if (self->pv->object_actions)
+ gtk_action_group_set_sensitive (self->pv->object_actions, rows > 0);
g_signal_emit_by_name (G_OBJECT (SEAHORSE_VIEW (self)), "selection-changed");
return FALSE;
}
@@ -365,7 +367,8 @@ seahorse_keyserver_results_constructor (GType type, guint n_props, GObjectConstr
/* Our set all nicely filtered */
self->pv->objects = seahorse_set_new_full (&self->pv->pred);
- self->pv->store = seahorse_key_manager_store_new (self->pv->objects, self->pv->view);
+ self->pv->store = seahorse_key_manager_store_new (self->pv->objects, self->pv->view,
+ self->pv->settings);
on_view_selection_changed (selection, self);
return G_OBJECT (self);
@@ -381,6 +384,7 @@ static void
seahorse_keyserver_results_init (SeahorseKeyserverResults *self)
{
self->pv = G_TYPE_INSTANCE_GET_PRIVATE (self, SEAHORSE_TYPE_KEYSERVER_RESULTS, SeahorseKeyserverResultsPrivate);
+ self->pv->settings = g_settings_new ("org.gnome.seahorse.manager");
}
/**
@@ -412,7 +416,9 @@ seahorse_keyserver_results_finalize (GObject *obj)
if (self->pv->view)
gtk_tree_view_set_model (self->pv->view, NULL);
self->pv->view = NULL;
-
+
+ g_clear_object (&self->pv->settings);
+
G_OBJECT_CLASS (seahorse_keyserver_results_parent_class)->finalize (obj);
}
diff --git a/src/seahorse-keyserver-search.c b/src/seahorse-keyserver-search.c
index c2dd20d..e92ddf4 100644
--- a/src/seahorse-keyserver-search.c
+++ b/src/seahorse-keyserver-search.c
@@ -23,7 +23,6 @@
#include "seahorse-context.h"
#include "seahorse-dns-sd.h"
-#include "seahorse-gconf.h"
#include "seahorse-keyserver-results.h"
#include "seahorse-preferences.h"
#include "seahorse-servers.h"
@@ -43,9 +42,9 @@
* @all: TRUE if all keyservers are selected
**/
typedef struct _KeyserverSelection {
- GSList *names;
- GSList *uris;
- gboolean all;
+ GPtrArray *names;
+ GPtrArray *uris;
+ gboolean all;
} KeyserverSelection;
@@ -61,18 +60,22 @@ typedef struct _KeyserverSelection {
static void
get_checks (GtkWidget *widget, KeyserverSelection *selection)
{
- if (GTK_IS_CHECK_BUTTON (widget)) {
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
- /* Pull in the selected name and uri */
- selection->names = g_slist_prepend (selection->names,
- g_strdup (gtk_button_get_label (GTK_BUTTON (widget))));
- selection->uris = g_slist_prepend (selection->uris,
- g_strdup (g_object_get_data (G_OBJECT (widget), "keyserver-uri")));
- } else {
- /* Note that not all checks are selected */
- selection->all = FALSE;
- }
- }
+ const gchar *value;
+
+ if (!GTK_IS_CHECK_BUTTON (widget))
+ return;
+
+ /* Pull in the selected name and uri */
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
+ value = gtk_button_get_label (GTK_BUTTON (widget));
+ g_ptr_array_add (selection->names, g_strdup (value));
+ value = g_object_get_data (G_OBJECT (widget), "keyserver-uri");
+ g_ptr_array_add (selection->uris, g_strdup (value));
+
+ /* Note that not all checks are selected */
+ } else {
+ selection->all = FALSE;
+ }
}
/**
@@ -86,23 +89,28 @@ get_checks (GtkWidget *widget, KeyserverSelection *selection)
static KeyserverSelection*
get_keyserver_selection (SeahorseWidget *swidget)
{
- KeyserverSelection *selection;
- GtkWidget *w;
-
- selection = g_new0(KeyserverSelection, 1);
- selection->all = TRUE;
-
- /* Key servers */
- w = GTK_WIDGET (seahorse_widget_get_widget (swidget, "key-server-list"));
- g_return_val_if_fail (w != NULL, selection);
- gtk_container_foreach (GTK_CONTAINER (w), (GtkCallback)get_checks, selection);
+ KeyserverSelection *selection;
+ GtkWidget *widget;
- /* Shared Key */
- w = GTK_WIDGET (seahorse_widget_get_widget (swidget, "shared-keys-list"));
- g_return_val_if_fail (w != NULL, selection);
- gtk_container_foreach (GTK_CONTAINER (w), (GtkCallback)get_checks, selection);
-
- return selection;
+ selection = g_new0 (KeyserverSelection, 1);
+ selection->all = TRUE;
+ selection->uris = g_ptr_array_new_with_free_func (g_free);
+ selection->names = g_ptr_array_new_with_free_func (g_free);
+
+ /* Key servers */
+ widget = seahorse_widget_get_widget (swidget, "key-server-list");
+ g_return_val_if_fail (widget != NULL, selection);
+ gtk_container_foreach (GTK_CONTAINER (widget), (GtkCallback)get_checks, selection);
+
+ /* Shared Key */
+ widget = seahorse_widget_get_widget (swidget, "shared-keys-list");
+ g_return_val_if_fail (widget != NULL, selection);
+ gtk_container_foreach (GTK_CONTAINER (widget), (GtkCallback)get_checks, selection);
+
+ g_ptr_array_add (selection->uris, NULL);
+ g_ptr_array_add (selection->names, NULL);
+
+ return selection;
}
/**
@@ -114,11 +122,11 @@ get_keyserver_selection (SeahorseWidget *swidget)
static void
free_keyserver_selection (KeyserverSelection *selection)
{
- if (selection) {
- seahorse_util_string_slist_free (selection->uris);
- seahorse_util_string_slist_free (selection->names);
- g_free (selection);
- }
+ if (selection) {
+ g_ptr_array_free (selection->uris, TRUE);
+ g_ptr_array_free (selection->names, TRUE);
+ g_free (selection);
+ }
}
/**
@@ -195,26 +203,26 @@ on_keyserver_search_control_changed (GtkWidget *widget, SeahorseWidget *swidget)
/* Initial Selection -------------------------------------------------------- */
-/**
- * widget: a toggle button
- * names: a list of names
- *
- * If the label of the toggle button is in the list of names it will be
- * set active
- *
- **/
static void
-select_checks (GtkWidget *widget, GSList *names)
+foreach_child_select_checks (GtkWidget *widget, gpointer user_data)
{
- if (GTK_IS_CHECK_BUTTON (widget)) {
-
- gchar *t = g_utf8_casefold (gtk_button_get_label (GTK_BUTTON (widget)), -1);
- gboolean checked = !names ||
- g_slist_find_custom (names, t, (GCompareFunc)g_utf8_collate);
- g_free (t);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), checked);
- }
+ gchar **names = user_data;
+ gboolean checked;
+ gchar *name;
+ guint i;
+
+ if (GTK_IS_CHECK_BUTTON (widget)) {
+ name = g_utf8_casefold (gtk_button_get_label (GTK_BUTTON (widget)), -1);
+ checked = names ? FALSE : TRUE;
+ for (i = 0; names && names[i] != NULL; i++) {
+ if (g_utf8_collate (names[i], name) == 0) {
+ checked = TRUE;
+ break;
+ }
+ }
+ g_free (name);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), checked);
+ }
}
/**
@@ -226,30 +234,32 @@ select_checks (GtkWidget *widget, GSList *names)
static void
select_inital_keyservers (SeahorseWidget *swidget)
{
- GSList *l, *names;
- GtkWidget *w;
-
- names = seahorse_gconf_get_string_list (LASTSERVERS_KEY);
-
- /* Close the expander if all servers are selected */
- w = GTK_WIDGET (seahorse_widget_get_widget (swidget, "search-where"));
- g_return_if_fail (w != NULL);
- gtk_expander_set_expanded (GTK_EXPANDER (w), names != NULL);
-
- /* We do case insensitive matches */
- for (l = names; l; l = g_slist_next (l)) {
- gchar *t = g_utf8_casefold (l->data, -1);
- g_free (l->data);
- l->data = t;
- }
-
- w = GTK_WIDGET (seahorse_widget_get_widget (swidget, "key-server-list"));
- g_return_if_fail (w != NULL);
- gtk_container_foreach (GTK_CONTAINER (w), (GtkCallback)select_checks, names);
-
- w = GTK_WIDGET (seahorse_widget_get_widget (swidget, "shared-keys-list"));
- g_return_if_fail (w != NULL);
- gtk_container_foreach (GTK_CONTAINER (w), (GtkCallback)select_checks, names);
+ gchar **names;
+ GtkWidget *widget;
+ gchar *name;
+ guint i;
+
+ names = g_settings_get_strv (seahorse_context_settings (NULL), "last-search-servers");
+
+ /* Close the expander if all servers are selected */
+ widget = seahorse_widget_get_widget (swidget, "search-where");
+ g_return_if_fail (widget != NULL);
+ gtk_expander_set_expanded (GTK_EXPANDER (widget), names != NULL);
+
+ /* We do case insensitive matches */
+ for (i = 0; names[i] != NULL; i++) {
+ name = g_utf8_casefold (names[i], -1);
+ g_free (names[i]);
+ names[i] = name;
+ }
+
+ widget = seahorse_widget_get_widget (swidget, "key-server-list");
+ g_return_if_fail (widget != NULL);
+ gtk_container_foreach (GTK_CONTAINER (widget), foreach_child_select_checks, names);
+
+ widget = seahorse_widget_get_widget (swidget, "shared-keys-list");
+ g_return_if_fail (widget != NULL);
+ gtk_container_foreach (GTK_CONTAINER (widget), foreach_child_select_checks, names);
}
/* Populating Lists --------------------------------------------------------- */
@@ -285,72 +295,63 @@ remove_checks (GtkWidget *widget, GHashTable *unchecked)
* of already existing check boxes is not changed.
**/
static void
-populate_keyserver_list (SeahorseWidget *swidget, GtkWidget *box, GSList *uris,
- GSList *names)
+populate_keyserver_list (SeahorseWidget *swidget, GtkWidget *box, gchar **uris,
+ gchar **names)
{
- GtkContainer *cont = GTK_CONTAINER (box);
- GHashTable *unchecked;
- gboolean any = FALSE;
- GtkWidget *check;
- GSList *l, *n;
-
- /* Remove all checks, and note which ones were unchecked */
- unchecked = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- gtk_container_foreach (cont, (GtkCallback)remove_checks, unchecked);
-
- /* Now add the new ones back */
- for (l = uris, n = names; l && n; l = g_slist_next (l), n = g_slist_next (n)) {
- any = TRUE;
-
- /* A new checkbox with this the name as the label */
- check = gtk_check_button_new_with_label ((const gchar*)n->data);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check),
- g_hash_table_lookup (unchecked, (gchar*)n->data) == NULL);
- g_signal_connect (check, "toggled", G_CALLBACK (on_keyserver_search_control_changed), swidget);
- gtk_widget_show (check);
-
- /* Save URI and set it as the tooltip */
- g_object_set_data_full (G_OBJECT (check), "keyserver-uri", g_strdup ((gchar*)l->data), g_free);
- gtk_widget_set_tooltip_text (check, (gchar*)l->data);
-
- gtk_container_add (cont, check);
- }
-
- g_hash_table_destroy (unchecked);
-
- /* Only display the container if we had some checks */
- if (any)
- gtk_widget_show (box);
- else
- gtk_widget_hide (box);
+ GtkContainer *cont = GTK_CONTAINER (box);
+ GHashTable *unchecked;
+ gboolean any = FALSE;
+ GtkWidget *check;
+ guint i;
+
+ /* Remove all checks, and note which ones were unchecked */
+ unchecked = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ gtk_container_foreach (cont, (GtkCallback)remove_checks, unchecked);
+
+ /* Now add the new ones back */
+ for (i = 0; uris && uris[i] && names && names[i]; i++) {
+ any = TRUE;
+
+ /* A new checkbox with this the name as the label */
+ check = gtk_check_button_new_with_label (names[i]);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check),
+ g_hash_table_lookup (unchecked, names[i]) == NULL);
+ g_signal_connect (check, "toggled", G_CALLBACK (on_keyserver_search_control_changed), swidget);
+ gtk_widget_show (check);
+
+ /* Save URI and set it as the tooltip */
+ g_object_set_data_full (G_OBJECT (check), "keyserver-uri", g_strdup (uris[i]), g_free);
+ gtk_widget_set_tooltip_text (check, uris[i]);
+
+ gtk_container_add (cont, check);
+ }
+
+ g_hash_table_destroy (unchecked);
+
+ /* Only display the container if we had some checks */
+ if (any)
+ gtk_widget_show (box);
+ else
+ gtk_widget_hide (box);
}
-/**
-* client: ignored
-* id: ignored
-* entry: used only for initial test
-* swidget: the main SeahorseWidget
-*
-* refreshes the "key-server-list". It reads the data from GConf
-**/
static void
-refresh_keyservers (GConfClient *client, guint id, GConfEntry *entry, SeahorseWidget *swidget)
+on_settings_keyservers_changed (GSettings *settings, const gchar *key, gpointer user_data)
{
- GSList *keyservers, *names;
- GtkWidget *w;
+ SeahorseWidget *swidget = SEAHORSE_WIDGET (user_data);
+ GtkWidget *widget;
+ gchar **keyservers;
+ gchar **names;
- if (entry && !g_str_equal (KEYSERVER_KEY, gconf_entry_get_key (entry)))
- return;
+ widget = seahorse_widget_get_widget (swidget, "key-server-list");
+ g_return_if_fail (widget != NULL);
- w = GTK_WIDGET (seahorse_widget_get_widget (swidget, "key-server-list"));
- g_return_if_fail (w != NULL);
+ keyservers = seahorse_servers_get_uris ();
+ names = seahorse_servers_get_names ();
+ populate_keyserver_list (swidget, widget, keyservers, names);
- keyservers = seahorse_servers_get_uris ();
- names = seahorse_servers_get_names ();
- populate_keyserver_list (swidget, w, keyservers, names);
-
- seahorse_util_string_slist_free (keyservers);
- seahorse_util_string_slist_free (names);
+ g_strfreev (keyservers);
+ g_strfreev (names);
}
/**
@@ -364,18 +365,19 @@ refresh_keyservers (GConfClient *client, guint id, GConfEntry *entry, SeahorseWi
static void
refresh_shared_keys (SeahorseServiceDiscovery *ssd, const gchar *name, SeahorseWidget *swidget)
{
- GSList *keyservers, *names;
- GtkWidget *w;
-
- w = GTK_WIDGET (seahorse_widget_get_widget (swidget, "shared-keys-list"));
- g_return_if_fail (w != NULL);
+ gchar **keyservers;
+ gchar **names;
+ GtkWidget *widget;
- names = seahorse_service_discovery_list (ssd);
- keyservers = seahorse_service_discovery_get_uris (ssd, names);
- populate_keyserver_list (swidget, w, keyservers, names);
+ widget = seahorse_widget_get_widget (swidget, "shared-keys-list");
+ g_return_if_fail (widget != NULL);
- seahorse_util_string_slist_free (keyservers);
- seahorse_util_string_slist_free (names);
+ names = seahorse_service_discovery_list (ssd);
+ keyservers = seahorse_service_discovery_get_uris (ssd, (const gchar **)names);
+ populate_keyserver_list (swidget, widget, keyservers, names);
+
+ g_strfreev (keyservers);
+ g_strfreev (names);
}
/* -------------------------------------------------------------------------- */
@@ -393,36 +395,36 @@ refresh_shared_keys (SeahorseServiceDiscovery *ssd, const gchar *name, SeahorseW
G_MODULE_EXPORT void
on_keyserver_search_ok_clicked (GtkButton *button, SeahorseWidget *swidget)
{
- SeahorseOperation *op;
- KeyserverSelection *selection;
- const gchar *search;
- GtkWidget *w;
-
- w = GTK_WIDGET (seahorse_widget_get_widget (swidget, "search-text"));
- g_return_if_fail (w != NULL);
-
- /* Get search text and save it for next time */
- search = gtk_entry_get_text (GTK_ENTRY (w));
- g_return_if_fail (search != NULL && search[0] != 0);
- seahorse_gconf_set_string (LASTSEARCH_KEY, search);
-
- /* The keyservers to search, and save for next time */
- selection = get_keyserver_selection (swidget);
- g_return_if_fail (selection->uris != NULL);
- seahorse_gconf_set_string_list (LASTSERVERS_KEY,
- selection->all ? NULL : selection->names);
-
- op = seahorse_context_search_remote (SCTX_APP(), search);
- if (op == NULL)
- return;
-
- /* Open the new result window */
- seahorse_keyserver_results_show (op,
- GTK_WINDOW (seahorse_widget_get_widget (swidget, swidget->name)),
- search);
-
- free_keyserver_selection (selection);
- seahorse_widget_destroy (swidget);
+ SeahorseOperation *op;
+ KeyserverSelection *selection;
+ const gchar *search;
+ GtkWidget *widget;
+
+ widget = seahorse_widget_get_widget (swidget, "search-text");
+ g_return_if_fail (widget != NULL);
+
+ /* Get search text and save it for next time */
+ search = gtk_entry_get_text (GTK_ENTRY (widget));
+ g_return_if_fail (search != NULL && search[0] != 0);
+ g_settings_set_string (seahorse_context_settings (NULL), "last-search-text", search);
+
+ /* The keyservers to search, and save for next time */
+ selection = get_keyserver_selection (swidget);
+ g_return_if_fail (selection->uris != NULL);
+ g_settings_set_strv (seahorse_context_settings (NULL), "last-search-servers",
+ selection->all ? NULL : (const gchar * const*)selection->names->pdata);
+
+ op = seahorse_context_search_remote (SCTX_APP(), search);
+ if (op == NULL)
+ return;
+
+ /* Open the new result window */
+ seahorse_keyserver_results_show (op,
+ GTK_WINDOW (seahorse_widget_get_widget (swidget, swidget->name)),
+ search);
+
+ free_keyserver_selection (selection);
+ seahorse_widget_destroy (swidget);
}
/**
@@ -451,47 +453,44 @@ cleanup_signals (GtkWidget *widget, SeahorseWidget *swidget)
GtkWindow*
seahorse_keyserver_search_show (GtkWindow *parent)
{
- SeahorseServiceDiscovery *ssd;
+ SeahorseServiceDiscovery *ssd;
SeahorseWidget *swidget;
- GtkWindow *win;
- GtkWidget *w;
- gchar *search;
-
+ GtkWindow *window;
+ GtkWidget *widget;
+ GSettings *settings;
+ gchar *search;
+
swidget = seahorse_widget_new ("keyserver-search", parent);
g_return_val_if_fail (swidget != NULL, NULL);
-
- win = GTK_WINDOW (seahorse_widget_get_widget (swidget, swidget->name));
- w = GTK_WIDGET (seahorse_widget_get_widget (swidget, "search-text"));
- g_return_val_if_fail (w != NULL, win);
+ window = GTK_WINDOW (seahorse_widget_get_widget (swidget, swidget->name));
- search = seahorse_gconf_get_string (LASTSEARCH_KEY);
- if (search != NULL) {
- gtk_entry_set_text (GTK_ENTRY (w), search);
- gtk_editable_select_region (GTK_EDITABLE (w), 0, -1);
- g_free (search);
- }
-
- /*CHECK: unknown key:
- glade_xml_signal_connect_data (swidget->xml, "configure_clicked",
- G_CALLBACK (configure_clicked), swidget);
- */
-
- /* The key servers to list */
- refresh_keyservers (NULL, 0, NULL, swidget);
- w = GTK_WIDGET (seahorse_widget_get_widget (swidget, swidget->name));
- seahorse_gconf_notify_lazy (KEYSERVER_KEY, (GConfClientNotifyFunc)refresh_keyservers,
- swidget, GTK_WIDGET (win));
-
- /* Any shared keys to list */
- ssd = seahorse_context_get_discovery (SCTX_APP ());
- refresh_shared_keys (ssd, NULL, swidget);
- g_signal_connect (ssd, "added", G_CALLBACK (refresh_shared_keys), swidget);
- g_signal_connect (ssd, "removed", G_CALLBACK (refresh_shared_keys), swidget);
- g_signal_connect (win, "destroy", G_CALLBACK (cleanup_signals), swidget);
-
- select_inital_keyservers (swidget);
- on_keyserver_search_control_changed (NULL, swidget);
-
- return win;
+ widget = seahorse_widget_get_widget (swidget, "search-text");
+ g_return_val_if_fail (widget != NULL, window);
+
+ search = g_settings_get_string (seahorse_context_settings (NULL),
+ "last-search-text");
+ if (search != NULL) {
+ gtk_entry_set_text (GTK_ENTRY (widget), search);
+ gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1);
+ g_free (search);
+ }
+
+ /* The key servers to list */
+ settings = seahorse_context_pgp_settings (NULL);
+ on_settings_keyservers_changed (settings, "keyservers", swidget);
+ g_signal_connect_object (settings, "changed::keyservers",
+ G_CALLBACK (on_settings_keyservers_changed), swidget, 0);
+
+ /* Any shared keys to list */
+ ssd = seahorse_context_get_discovery (NULL);
+ refresh_shared_keys (ssd, NULL, swidget);
+ g_signal_connect (ssd, "added", G_CALLBACK (refresh_shared_keys), swidget);
+ g_signal_connect (ssd, "removed", G_CALLBACK (refresh_shared_keys), swidget);
+ g_signal_connect (window, "destroy", G_CALLBACK (cleanup_signals), swidget);
+
+ select_inital_keyservers (swidget);
+ on_keyserver_search_control_changed (NULL, swidget);
+
+ return window;
}
diff --git a/src/seahorse-keyserver-sync.c b/src/seahorse-keyserver-sync.c
index 300c89c..f2a2ac1 100644
--- a/src/seahorse-keyserver-sync.c
+++ b/src/seahorse-keyserver-sync.c
@@ -24,7 +24,6 @@
#include <glib/gi18n.h>
#include "seahorse-context.h"
-#include "seahorse-gconf.h"
#include "seahorse-keyserver-sync.h"
#include "seahorse-object.h"
#include "seahorse-progress.h"
@@ -38,14 +37,18 @@
static void
sync_import_complete (SeahorseOperation *op, SeahorseSource *sksrc)
{
- GError *err = NULL;
-
- if (!seahorse_operation_is_successful (op)) {
- seahorse_operation_copy_error (op, &err);
- seahorse_util_handle_error (err, _("Couldn't publish keys to server"),
- seahorse_gconf_get_string (PUBLISH_TO_KEY));
- g_clear_error (&err);
- }
+ GError *error = NULL;
+ gchar *publish_to;
+
+ if (!seahorse_operation_is_successful (op)) {
+ seahorse_operation_copy_error (op, &error);
+ publish_to = g_settings_get_string (seahorse_context_settings (NULL),
+ "server-publish-to");
+ seahorse_util_handle_error (error, _("Couldn't publish keys to server"),
+ publish_to);
+ g_free (publish_to);
+ g_clear_error (&error);
+ }
}
static void
@@ -88,44 +91,34 @@ on_sync_configure_clicked (GtkButton *button, SeahorseWidget *swidget)
static void
update_message (SeahorseWidget *swidget)
{
- GtkWidget *w, *w2, *sync_button;
- gchar *t;
-
- w = GTK_WIDGET (seahorse_widget_get_widget (swidget, "publish-message"));
- w2 = GTK_WIDGET (seahorse_widget_get_widget (swidget, "sync-message"));
- sync_button = GTK_WIDGET (seahorse_widget_get_widget (swidget, "sync-button"));
-
- t = seahorse_gconf_get_string (PUBLISH_TO_KEY);
- if (t && t[0]) {
- gtk_widget_show (w);
- gtk_widget_hide (w2);
-
- gtk_widget_set_sensitive (sync_button, TRUE);
- } else {
- gtk_widget_hide (w);
- gtk_widget_show (w2);
-
- gtk_widget_set_sensitive (sync_button, FALSE);
- }
- g_free (t);
+ GtkWidget *widget;
+ GtkWidget *widget2;
+ GtkWidget *sync_button;
+ gchar *text;
+
+ widget = seahorse_widget_get_widget (swidget, "publish-message");
+ widget2 = seahorse_widget_get_widget (swidget, "sync-message");
+ sync_button = seahorse_widget_get_widget (swidget, "sync-button");
+
+ text = g_settings_get_string (seahorse_context_settings (NULL),
+ "server-publish-to");
+ if (text && text[0]) {
+ gtk_widget_show (widget);
+ gtk_widget_hide (widget2);
+ gtk_widget_set_sensitive (sync_button, TRUE);
+ } else {
+ gtk_widget_hide (widget);
+ gtk_widget_show (widget2);
+ gtk_widget_set_sensitive (sync_button, FALSE);
+ }
+ g_free (text);
}
static void
-gconf_notify (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
+on_settings_publish_to_changed (GSettings *settings, const gchar *key, gpointer user_data)
{
- SeahorseWidget *swidget;
-
- if (g_str_equal (PUBLISH_TO_KEY, gconf_entry_get_key (entry))) {
- swidget = SEAHORSE_WIDGET (data);
- update_message (swidget);
- }
-}
-
-static void
-unhook_notification (GtkWidget *widget, gpointer data)
-{
- guint notify_id = GPOINTER_TO_INT (data);
- seahorse_gconf_unnotify (notify_id);
+ SeahorseWidget *swidget = SEAHORSE_WIDGET (user_data);
+ update_message (swidget);
}
/**
@@ -142,7 +135,7 @@ seahorse_keyserver_sync_show (GList *keys, GtkWindow *parent)
SeahorseWidget *swidget;
GtkWindow *win;
GtkWidget *w;
- guint n, notify_id;
+ guint n;
gchar *t;
swidget = seahorse_widget_new_allow_multiple ("keyserver-sync", parent);
@@ -159,12 +152,11 @@ seahorse_keyserver_sync_show (GList *keys, GtkWindow *parent)
g_return_val_if_fail (swidget != NULL, win);
gtk_label_set_markup (GTK_LABEL (w), t);
g_free (t);
-
+
/* The right help message */
update_message (swidget);
- notify_id = seahorse_gconf_notify (PUBLISH_TO_KEY, gconf_notify, swidget);
- g_signal_connect (win, "destroy", G_CALLBACK (unhook_notification),
- GINT_TO_POINTER (notify_id));
+ g_signal_connect_object (seahorse_context_settings (NULL), "changed::server-publish-to",
+ G_CALLBACK (on_settings_publish_to_changed), swidget, 0);
keys = g_list_copy (keys);
g_return_val_if_fail (!keys || SEAHORSE_IS_OBJECT (keys->data), win);
@@ -182,10 +174,11 @@ seahorse_keyserver_sync (GList *keys)
SeahorseMultiOperation *mop;
SeahorseOperation *op;
gchar *keyserver;
- GSList *ks, *l;
+ gchar **keyservers;
GList *k;
GSList *keyids = NULL;
-
+ guint i;
+
if (!keys)
return;
@@ -199,11 +192,9 @@ seahorse_keyserver_sync (GList *keys)
mop = seahorse_multi_operation_new ();
/* And now synchronizing keys from the servers */
- ks = seahorse_servers_get_uris ();
-
- for (l = ks; l; l = g_slist_next (l)) {
-
- sksrc = seahorse_context_remote_source (SCTX_APP (), (const gchar*)(l->data));
+ keyservers = seahorse_servers_get_uris ();
+ for (i = 0; keyservers[i] != NULL; i++) {
+ sksrc = seahorse_context_remote_source (SCTX_APP (), keyservers[i]);
/* This can happen if the URI scheme is not supported */
if (sksrc == NULL)
@@ -220,13 +211,13 @@ seahorse_keyserver_sync (GList *keys)
seahorse_operation_watch (op, (SeahorseDoneFunc) sync_export_complete, sksrc, NULL, NULL);
}
}
-
- seahorse_util_string_slist_free (ks);
-
- /* Publishing keys online */
- keyserver = seahorse_gconf_get_string (PUBLISH_TO_KEY);
+
+ g_strfreev (keyservers);
+
+ /* Publishing keys online */
+ keyserver = g_settings_get_string (seahorse_context_settings (NULL),
+ "server-publish-to");
if (keyserver && keyserver[0]) {
-
sksrc = seahorse_context_remote_source (SCTX_APP (), keyserver);
/* This can happen if the URI scheme is not supported */
diff --git a/src/seahorse-preferences.c b/src/seahorse-preferences.c
index a2b3676..0379a180 100644
--- a/src/seahorse-preferences.c
+++ b/src/seahorse-preferences.c
@@ -21,10 +21,8 @@
*/
#include "seahorse-prefs.h"
-#include "seahorse-gconf.h"
#include "seahorse-preferences.h"
#include "seahorse-widget.h"
-#include "seahorse-check-button-control.h"
/**
* seahorse_preferences_show:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]