[seahorse] Migrate to GtkApplication
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seahorse] Migrate to GtkApplication
- Date: Mon, 2 Jul 2012 05:12:13 +0000 (UTC)
commit 7e7d7794147d126d1fae447f4776bb64e591e923
Author: Stef Walter <stefw gnome org>
Date: Mon Jul 2 06:58:17 2012 +0200
Migrate to GtkApplication
* Use GtkApplication to startup seahorse, parse arguments
* Seahorse is now a single instance application
* SeahorseApplication replaces SeahorseContext and is
derived from GtkApplication
* Depends on GTK+ 3.4 or later
https://bugzilla.gnome.org/show_bug.cgi?id=677234
configure.ac | 2 +-
libseahorse/Makefile.am | 2 +-
libseahorse/seahorse-application.c | 203 +++++++++++++++++++++++++
libseahorse/seahorse-application.h | 51 +++++++
libseahorse/seahorse-context.c | 236 ------------------------------
libseahorse/seahorse-context.h | 85 -----------
libseahorse/seahorse-keyserver-control.c | 10 +-
libseahorse/seahorse-place.c | 1 -
libseahorse/seahorse-prefs.c | 9 +-
libseahorse/seahorse-servers.c | 6 +-
libseahorse/seahorse-widget.c | 35 ++---
libseahorse/seahorse-widget.h | 2 +-
pgp/seahorse-keyserver-search.c | 10 +-
pgp/seahorse-keyserver-sync.c | 8 +-
pgp/seahorse-pgp-backend.c | 12 +-
pgp/seahorse-pgp-keysets.c | 4 +-
pgp/seahorse-signer.c | 2 +-
src/seahorse-key-manager.c | 43 ++----
src/seahorse-key-manager.h | 2 +-
src/seahorse-main.c | 84 +++--------
20 files changed, 330 insertions(+), 477 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 762780e..b8adda7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,7 +5,7 @@ AC_INIT([seahorse], [3.5.4],
GCK_REQUIRED=3.3.4
GCR_REQUIRED=3.3.4
-GTK_REQUIRED=2.90.0
+GTK_REQUIRED=3.4.0
GNUPG_ACCEPTED="1.2 1.4 2.0"
GPGME_REQUIRED=1.0.0
LIBSECRET_REQUIRED=0.4
diff --git a/libseahorse/Makefile.am b/libseahorse/Makefile.am
index 806f89c..06e8629 100644
--- a/libseahorse/Makefile.am
+++ b/libseahorse/Makefile.am
@@ -30,12 +30,12 @@ endif
libseahorse_la_SOURCES = \
seahorse-action.c seahorse-action.h \
seahorse-actions.c seahorse-actions.h \
+ seahorse-application.c seahorse-application.h \
seahorse-backend.c seahorse-backend.h \
seahorse-bind.c seahorse-bind.h \
seahorse-catalog.c seahorse-catalog.h \
seahorse-cleanup.c seahorse-cleanup.h \
seahorse-collection.c seahorse-collection.h \
- seahorse-context.c seahorse-context.h \
seahorse-debug.c seahorse-debug.h \
seahorse-delete-dialog.c seahorse-delete-dialog.h \
seahorse-deletable.c seahorse-deletable.h \
diff --git a/libseahorse/seahorse-application.c b/libseahorse/seahorse-application.c
new file mode 100644
index 0000000..ef73bb9
--- /dev/null
+++ b/libseahorse/seahorse-application.c
@@ -0,0 +1,203 @@
+/*
+ * Seahorse
+ *
+ * Copyright (C) 2003 Jacob Perkins
+ * Copyright (C) 2005, 2006 Stefan Walter
+ * Copyright (C) 2011 Collabora Ltd.
+ * Copyright (C) 2012 Stefan Walter
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include "seahorse-application.h"
+#include "seahorse-icons.h"
+
+#include "gkr/seahorse-gkr.h"
+#include "pgp/seahorse-pgp.h"
+#include "ssh/seahorse-ssh.h"
+#include "pkcs11/seahorse-pkcs11.h"
+
+#include <gtk/gtk.h>
+
+#include <glib/gi18n.h>
+
+struct _SeahorseApplication {
+ GtkApplication parent;
+ GSettings *seahorse_settings;
+ GSettings *crypto_pgp_settings;
+};
+
+struct _SeahorseApplicationClass {
+ GtkApplicationClass parent_class;
+};
+
+G_DEFINE_TYPE (SeahorseApplication, seahorse_application, GTK_TYPE_APPLICATION);
+
+static SeahorseApplication *the_application = NULL;
+
+static void
+seahorse_application_constructed (GObject *obj)
+{
+ SeahorseApplication *self = SEAHORSE_APPLICATION (obj);
+
+ g_return_if_fail (the_application == NULL);
+
+ G_OBJECT_CLASS (seahorse_application_parent_class)->constructed (obj);
+
+ the_application = self;
+
+ self->seahorse_settings = g_settings_new ("org.gnome.seahorse");
+
+#ifdef WITH_PGP
+ /* This is installed by gnome-keyring */
+ self->crypto_pgp_settings = g_settings_new ("org.gnome.crypto.pgp");
+#endif
+}
+
+static void
+seahorse_application_finalize (GObject *gobject)
+{
+ SeahorseApplication *self = SEAHORSE_APPLICATION (gobject);
+ the_application = NULL;
+
+#ifdef WITH_PGP
+ g_clear_object (&self->crypto_pgp_settings);
+#endif
+ g_clear_object (&self->seahorse_settings);
+
+ G_OBJECT_CLASS (seahorse_application_parent_class)->finalize (gobject);
+}
+
+static void
+seahorse_application_startup (GApplication *application)
+{
+ /* Insert Icons into Stock */
+ seahorse_icons_init ();
+
+ /* Initialize the various components */
+#ifdef WITH_PGP
+ seahorse_pgp_backend_initialize ();
+#endif
+#ifdef WITH_SSH
+ seahorse_ssh_backend_initialize ();
+#endif
+#ifdef WITH_PKCS11
+ seahorse_pkcs11_backend_initialize ();
+#endif
+ seahorse_gkr_backend_initialize ();
+
+ G_APPLICATION_CLASS (seahorse_application_parent_class)->startup (application);
+}
+
+static gboolean
+seahorse_application_local_command_line (GApplication *application,
+ gchar ***arguments,
+ gint *exit_status)
+{
+ gboolean show_version = FALSE;
+ GOptionContext *context;
+ GError *error = NULL;
+ int argc;
+
+ GOptionEntry options[] = {
+ { "version", 'v', 0, G_OPTION_ARG_NONE, &show_version, N_("Version of this application"), NULL },
+ { NULL, 0, 0, 0, NULL, NULL, NULL }
+ };
+
+ argc = g_strv_length (*arguments);
+
+ context = g_option_context_new (N_("- System Settings"));
+ g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
+ g_option_context_set_translation_domain(context, GETTEXT_PACKAGE);
+ g_option_context_add_group (context, gtk_get_option_group (TRUE));
+ g_option_context_set_help_enabled (context, FALSE);
+ g_option_context_set_ignore_unknown_options (context, TRUE);
+
+ if (g_option_context_parse (context, &argc, arguments, &error) == FALSE) {
+ g_printerr ("seahorse: %s\n", error->message);
+ g_option_context_free (context);
+ g_error_free (error);
+ *exit_status = 1;
+ return TRUE;
+ }
+
+ g_option_context_free (context);
+
+ if (show_version) {
+ g_print ("%s\n", PACKAGE_STRING);
+#ifdef WITH_PGP
+ g_print ("GNUPG: %s (%d.%d.%d)\n", GNUPG, GPG_MAJOR, GPG_MINOR, GPG_MICRO);
+#endif
+ *exit_status = 0;
+ return TRUE;
+ }
+
+ return G_APPLICATION_CLASS (seahorse_application_parent_class)->local_command_line (application, arguments, exit_status);
+}
+
+static void
+seahorse_application_class_init (SeahorseApplicationClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GApplicationClass *application_class = G_APPLICATION_CLASS (klass);
+
+ gobject_class->constructed = seahorse_application_constructed;
+ gobject_class->finalize = seahorse_application_finalize;
+
+ application_class->startup = seahorse_application_startup;
+ application_class->local_command_line = seahorse_application_local_command_line;
+}
+
+static void
+seahorse_application_init (SeahorseApplication *self)
+{
+
+}
+
+GtkApplication *
+seahorse_application_new (void)
+{
+ return g_object_new (SEAHORSE_TYPE_APPLICATION,
+ "application-id", "org.gnome.seahorse",
+ NULL);
+}
+
+GtkApplication *
+seahorse_application_get (void)
+{
+ g_return_val_if_fail (the_application != NULL, NULL);
+ return GTK_APPLICATION (the_application);
+}
+
+GSettings *
+seahorse_application_settings (SeahorseApplication *self)
+{
+ if (self == NULL)
+ self = the_application;
+ g_return_val_if_fail (SEAHORSE_IS_APPLICATION (self), NULL);
+ return self->seahorse_settings;
+}
+
+GSettings *
+seahorse_application_pgp_settings (SeahorseApplication *self)
+{
+ if (self == NULL)
+ self = the_application;
+ g_return_val_if_fail (SEAHORSE_IS_APPLICATION (self), NULL);
+ return self->crypto_pgp_settings;
+}
diff --git a/libseahorse/seahorse-application.h b/libseahorse/seahorse-application.h
new file mode 100644
index 0000000..38bc9d6
--- /dev/null
+++ b/libseahorse/seahorse-application.h
@@ -0,0 +1,51 @@
+/*
+ * Seahorse
+ *
+ * Copyright (C) 2003 Jacob Perkins
+ * Copyright (C) 2004-2005 Stefan Walter
+ * Copyright (C) 2011 Collabora Ltd.
+ * Copyright (C) 2012 Stefan Walter
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __SEAHORSE_APPLICATION_H__
+#define __SEAHORSE_APPLICATION_H__
+
+#include <gio/gio.h>
+#include <gtk/gtk.h>
+
+#define SEAHORSE_TYPE_APPLICATION (seahorse_application_get_type ())
+#define SEAHORSE_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_TYPE_APPLICATION, SeahorseApplication))
+#define SEAHORSE_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SEAHORSE_TYPE_APPLICATION, SeahorseApplicationClass))
+#define SEAHORSE_IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAHORSE_TYPE_APPLICATION))
+#define SEAHORSE_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAHORSE_TYPE_APPLICATION))
+#define SEAHORSE_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAHORSE_TYPE_APPLICATION, SeahorseApplicationClass))
+
+typedef struct _SeahorseApplication SeahorseApplication;
+typedef struct _SeahorseApplicationClass SeahorseApplicationClass;
+
+GType seahorse_application_get_type (void);
+
+GtkApplication * seahorse_application_new (void);
+
+GtkApplication * seahorse_application_get (void);
+
+GSettings * seahorse_application_settings (SeahorseApplication *self);
+
+GSettings * seahorse_application_pgp_settings (SeahorseApplication *self);
+
+#endif /* __SEAHORSE_APPLICATION_H__ */
diff --git a/libseahorse/seahorse-keyserver-control.c b/libseahorse/seahorse-keyserver-control.c
index 5e742a4..52528e6 100644
--- a/libseahorse/seahorse-keyserver-control.c
+++ b/libseahorse/seahorse-keyserver-control.c
@@ -21,7 +21,7 @@
#include <config.h>
-#include "seahorse-context.h"
+#include "seahorse-application.h"
#include "seahorse-keyserver-control.h"
#include "seahorse-servers.h"
#include "seahorse-util.h"
@@ -68,7 +68,7 @@ on_keyserver_changed (GtkComboBox *widget, SeahorseKeyserverControl *self)
if (self->settings_key) {
text = seahorse_keyserver_control_selected (self);
- g_settings_set_string (seahorse_context_settings (NULL),
+ g_settings_set_string (seahorse_application_settings (NULL),
self->settings_key, text ? text : "");
g_free (text);
}
@@ -98,11 +98,11 @@ seahorse_keyserver_control_constructed (GObject *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_signal_connect_object (seahorse_application_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_signal_connect_object (seahorse_application_settings (NULL), detailed,
G_CALLBACK (on_settings_key_changed), self, 0);
g_free (detailed);
}
@@ -242,7 +242,7 @@ populate_combo (SeahorseKeyserverControl *skc, gboolean with_key)
/* Get the appropriate selection */
if (with_key && skc->settings_key)
- chosen = g_settings_get_string (seahorse_context_settings (NULL), skc->settings_key);
+ chosen = g_settings_get_string (seahorse_application_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,
diff --git a/libseahorse/seahorse-place.c b/libseahorse/seahorse-place.c
index a50a536..d2f87e7 100644
--- a/libseahorse/seahorse-place.c
+++ b/libseahorse/seahorse-place.c
@@ -22,7 +22,6 @@
#include "config.h"
-#include "seahorse-context.h"
#include "seahorse-marshal.h"
#include "seahorse-object.h"
#include "seahorse-registry.h"
diff --git a/libseahorse/seahorse-prefs.c b/libseahorse/seahorse-prefs.c
index cb42ba7..14a5a57 100644
--- a/libseahorse/seahorse-prefs.c
+++ b/libseahorse/seahorse-prefs.c
@@ -22,6 +22,7 @@
#include <glib/gi18n.h>
+#include "seahorse-application.h"
#include "seahorse-icons.h"
#include "seahorse-keyserver-control.h"
#include "seahorse-prefs.h"
@@ -119,7 +120,7 @@ save_keyservers (GtkTreeModel *model)
}
g_ptr_array_add (values, NULL);
- g_settings_set_strv (seahorse_context_pgp_settings (NULL), "keyservers",
+ g_settings_set_strv (seahorse_application_pgp_settings (NULL), "keyservers",
(const gchar* const*)values->pdata);
g_ptr_array_free (values, TRUE);
}
@@ -394,7 +395,7 @@ setup_keyservers (SeahorseWidget *swidget)
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_signal_connect_object (seahorse_application_pgp_settings (NULL), "changed::keyserver",
G_CALLBACK (on_settings_keyserver_changed), swidget, 0);
widget = seahorse_widget_get_widget (swidget, "keyserver-publish");
@@ -409,12 +410,12 @@ setup_keyservers (SeahorseWidget *swidget)
widget = seahorse_widget_get_widget (swidget, "auto_retrieve");
g_return_if_fail (widget != NULL);
- g_settings_bind (seahorse_context_settings (NULL), "server-auto-retrieve",
+ g_settings_bind (seahorse_application_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",
+ g_settings_bind (seahorse_application_settings (NULL), "server-auto-publish",
widget, "active", G_SETTINGS_BIND_DEFAULT);
}
diff --git a/libseahorse/seahorse-servers.c b/libseahorse/seahorse-servers.c
index 667b6d4..3ef4912 100644
--- a/libseahorse/seahorse-servers.c
+++ b/libseahorse/seahorse-servers.c
@@ -19,8 +19,8 @@
* Boston, MA 02111-1307, USA.
*/
+#include "seahorse-application.h"
#include "seahorse-cleanup.h"
-#include "seahorse-context.h"
#include "seahorse-servers.h"
#include <string.h>
@@ -103,7 +103,7 @@ seahorse_servers_get_uris (void)
gchar *name;
guint i;
- servers = g_settings_get_strv (seahorse_context_pgp_settings (NULL), "keyservers");
+ servers = g_settings_get_strv (seahorse_application_pgp_settings (NULL), "keyservers");
/* The values are 'uri name', remove the name part */
for (i = 0; servers[i] != NULL; i++) {
@@ -123,7 +123,7 @@ seahorse_servers_get_names (void)
gchar *name;
guint i;
- servers = g_settings_get_strv (seahorse_context_pgp_settings (NULL),
+ servers = g_settings_get_strv (seahorse_application_pgp_settings (NULL),
"keyservers");
/* The values are 'uri name', remove the value part */
diff --git a/libseahorse/seahorse-widget.c b/libseahorse/seahorse-widget.c
index 1fc8e22..80951d6 100644
--- a/libseahorse/seahorse-widget.c
+++ b/libseahorse/seahorse-widget.c
@@ -77,9 +77,6 @@ G_MODULE_EXPORT gboolean on_widget_delete_event (GtkWidget *widget,
GdkEvent *event,
SeahorseWidget *swidget);
-static void context_destroyed (SeahorseContext *sctx,
- SeahorseWidget *swidget);
-
static GObjectClass *parent_class = NULL;
/* Hash of widgets with name as key */
@@ -134,6 +131,13 @@ seahorse_widget_constructed (GObject *object)
if (width > 0 && height > 0)
gtk_window_resize (window, width, height);
}
+
+ if(!widgets)
+ widgets = g_hash_table_new ((GHashFunc)g_str_hash, (GCompareFunc)g_str_equal);
+ g_hash_table_insert (widgets, g_strdup (self->name), self);
+
+ gtk_application_add_window (seahorse_application_get (),
+ GTK_WINDOW (seahorse_widget_get_widget (self, self->name)));
}
/**
@@ -178,19 +182,6 @@ class_init (SeahorseWidgetClass *klass)
}
/**
-* sctx: ignored
-* swidget: The swidget being destroyed
-*
-* Destroy widget when context is destroyed
-*
-**/
-static void
-context_destroyed (SeahorseContext *sctx, SeahorseWidget *swidget)
-{
- seahorse_widget_destroy (swidget);
-}
-
-/**
* swidget: The #SeahorseWidget being initialised
*
* Connects the destroy-signal
@@ -199,8 +190,7 @@ context_destroyed (SeahorseContext *sctx, SeahorseWidget *swidget)
static void
object_init (SeahorseWidget *swidget)
{
- g_signal_connect_after (SCTX_APP(), "destroy",
- G_CALLBACK (context_destroyed), swidget);
+
}
static void
@@ -240,7 +230,8 @@ object_finalize (GObject *gobject)
}
}
- g_signal_handlers_disconnect_by_func (SCTX_APP (), context_destroyed, swidget);
+ gtk_application_remove_window (seahorse_application_get (),
+ GTK_WINDOW (seahorse_widget_get_widget (swidget, swidget->name)));
if (seahorse_widget_get_widget (swidget, swidget->name))
gtk_widget_destroy (GTK_WIDGET (seahorse_widget_get_widget (swidget, swidget->name)));
@@ -250,7 +241,7 @@ object_finalize (GObject *gobject)
g_clear_object (&swidget->settings);
g_free (swidget->name);
-
+
G_OBJECT_CLASS (parent_class)->finalize (gobject);
}
@@ -393,10 +384,6 @@ seahorse_widget_new (const gchar *name, GtkWindow *parent)
/* If widget doesn't already exist, create & insert into hash */
swidget = g_object_new (SEAHORSE_TYPE_WIDGET, "name", name, NULL);
- if(!widgets)
- widgets = g_hash_table_new ((GHashFunc)g_str_hash, (GCompareFunc)g_str_equal);
- g_hash_table_insert (widgets, g_strdup (name), swidget);
-
if (parent != NULL) {
window = GTK_WINDOW (seahorse_widget_get_widget (swidget, swidget->name));
gtk_window_set_transient_for (window, parent);
diff --git a/libseahorse/seahorse-widget.h b/libseahorse/seahorse-widget.h
index 8e599f4..af76068 100644
--- a/libseahorse/seahorse-widget.h
+++ b/libseahorse/seahorse-widget.h
@@ -26,7 +26,7 @@
#include <glib.h>
#include <gtk/gtk.h>
-#include "seahorse-context.h"
+#include "seahorse-application.h"
#define SEAHORSE_TYPE_WIDGET (seahorse_widget_get_type ())
#define SEAHORSE_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_TYPE_WIDGET, SeahorseWidget))
diff --git a/pgp/seahorse-keyserver-search.c b/pgp/seahorse-keyserver-search.c
index a3f08d3..16b1a75 100644
--- a/pgp/seahorse-keyserver-search.c
+++ b/pgp/seahorse-keyserver-search.c
@@ -250,7 +250,7 @@ select_inital_keyservers (SeahorseWidget *swidget)
gchar *name;
guint i;
- names = g_settings_get_strv (seahorse_context_settings (NULL), "last-search-servers");
+ names = g_settings_get_strv (seahorse_application_settings (NULL), "last-search-servers");
/* Close the expander if all servers are selected */
widget = seahorse_widget_get_widget (swidget, "search-where");
@@ -418,12 +418,12 @@ on_keyserver_search_ok_clicked (GtkButton *button, SeahorseWidget *swidget)
/* 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);
+ g_settings_set_string (seahorse_application_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",
+ g_settings_set_strv (seahorse_application_settings (NULL), "last-search-servers",
selection->all ? NULL : (const gchar * const*)selection->uris->pdata);
/* Open the new result window */
@@ -474,7 +474,7 @@ seahorse_keyserver_search_show (GtkWindow *parent)
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),
+ search = g_settings_get_string (seahorse_application_settings (NULL),
"last-search-text");
if (search != NULL) {
gtk_entry_set_text (GTK_ENTRY (widget), search);
@@ -483,7 +483,7 @@ seahorse_keyserver_search_show (GtkWindow *parent)
}
/* The key servers to list */
- settings = seahorse_context_pgp_settings (NULL);
+ settings = seahorse_application_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);
diff --git a/pgp/seahorse-keyserver-sync.c b/pgp/seahorse-keyserver-sync.c
index 1019b94..0609db9 100644
--- a/pgp/seahorse-keyserver-sync.c
+++ b/pgp/seahorse-keyserver-sync.c
@@ -51,7 +51,7 @@ on_transfer_upload_complete (GObject *object,
gchar *publish_to;
if (!seahorse_pgp_backend_transfer_finish (SEAHORSE_PGP_BACKEND (object), result, &error)) {
- publish_to = g_settings_get_string (seahorse_context_settings (NULL),
+ publish_to = g_settings_get_string (seahorse_application_settings (NULL),
"server-publish-to");
seahorse_util_handle_error (&error, NULL,
_("Couldn't publish keys to server"), publish_to);
@@ -112,7 +112,7 @@ update_message (SeahorseWidget *swidget)
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),
+ text = g_settings_get_string (seahorse_application_settings (NULL),
"server-publish-to");
if (text && text[0]) {
gtk_widget_show (widget);
@@ -167,7 +167,7 @@ seahorse_keyserver_sync_show (GList *keys, GtkWindow *parent)
/* The right help message */
update_message (swidget);
- g_signal_connect_object (seahorse_context_settings (NULL), "changed::server-publish-to",
+ g_signal_connect_object (seahorse_application_settings (NULL), "changed::server-publish-to",
G_CALLBACK (on_settings_publish_to_changed), swidget, 0);
keys = g_list_copy (keys);
@@ -222,7 +222,7 @@ seahorse_keyserver_sync (GList *keys)
g_strfreev (keyservers);
/* Publishing keys online */
- keyserver = g_settings_get_string (seahorse_context_settings (NULL),
+ keyserver = g_settings_get_string (seahorse_application_settings (NULL),
"server-publish-to");
if (keyserver && keyserver[0]) {
source = seahorse_pgp_backend_lookup_remote (NULL, keyserver);
diff --git a/pgp/seahorse-pgp-backend.c b/pgp/seahorse-pgp-backend.c
index 2ea226b..448824e 100644
--- a/pgp/seahorse-pgp-backend.c
+++ b/pgp/seahorse-pgp-backend.c
@@ -148,11 +148,11 @@ seahorse_pgp_backend_constructed (GObject *obj)
self->unknown = seahorse_unknown_source_new ();
#ifdef WITH_KEYSERVER
- g_signal_connect (seahorse_context_pgp_settings (NULL), "changed::keyservers",
+ g_signal_connect (seahorse_application_pgp_settings (NULL), "changed::keyservers",
G_CALLBACK (on_settings_keyservers_changed), self);
/* Initial loading */
- on_settings_keyservers_changed (seahorse_context_pgp_settings (NULL), "keyservers", self);
+ on_settings_keyservers_changed (seahorse_application_pgp_settings (NULL), "keyservers", self);
#endif
}
@@ -189,7 +189,7 @@ seahorse_pgp_backend_finalize (GObject *obj)
SeahorsePgpBackend *self = SEAHORSE_PGP_BACKEND (obj);
#ifdef WITH_KEYSERVER
- g_signal_handlers_disconnect_by_func (seahorse_context_pgp_settings (NULL),
+ g_signal_handlers_disconnect_by_func (seahorse_application_pgp_settings (NULL),
on_settings_keyservers_changed, self);
#endif
@@ -304,7 +304,7 @@ seahorse_pgp_backend_get_default_key (SeahorsePgpBackend *self)
self = self ? self : seahorse_pgp_backend_get ();
g_return_val_if_fail (SEAHORSE_IS_PGP_BACKEND (self), NULL);
- settings = seahorse_context_pgp_settings (NULL);
+ settings = seahorse_application_pgp_settings (NULL);
if (settings != NULL) {
value = g_settings_get_string (settings, "default-key");
if (value != NULL && value[0]) {
@@ -424,7 +424,7 @@ seahorse_pgp_backend_search_remote_async (SeahorsePgpBackend *self,
g_return_if_fail (SEAHORSE_IS_PGP_BACKEND (self));
/* Get a list of all selected key servers */
- names = g_settings_get_strv (seahorse_context_settings (NULL), "last-search-servers");
+ names = g_settings_get_strv (seahorse_application_settings (NULL), "last-search-servers");
if (names != NULL && names[0] != NULL) {
servers = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
for (i = 0; names[i] != NULL; i++)
@@ -704,7 +704,7 @@ seahorse_pgp_backend_discover_keys (SeahorsePgpBackend *self,
keyids = (const gchar **)todiscover->pdata;
/* Start a discover process on all todiscover */
- if (g_settings_get_boolean (seahorse_context_settings (NULL), "server-auto-retrieve"))
+ if (g_settings_get_boolean (seahorse_application_settings (NULL), "server-auto-retrieve"))
seahorse_pgp_backend_retrieve_async (self, keyids, SEAHORSE_PLACE (self->keyring),
cancellable, NULL, NULL);
diff --git a/pgp/seahorse-pgp-keysets.c b/pgp/seahorse-pgp-keysets.c
index ef8703d..e9224ba 100644
--- a/pgp/seahorse-pgp-keysets.c
+++ b/pgp/seahorse-pgp-keysets.c
@@ -21,7 +21,7 @@
#include "config.h"
-#include "seahorse-context.h"
+#include "seahorse-application.h"
#include "seahorse-collection.h"
#include "seahorse-object.h"
#include "seahorse-predicate.h"
@@ -79,7 +79,7 @@ seahorse_keyset_pgp_signers_new (void)
collection = seahorse_collection_new_for_predicate (GCR_COLLECTION (keyring),
predicate, g_free);
- g_signal_connect_object (seahorse_context_pgp_settings (NULL), "changed::default-key",
+ g_signal_connect_object (seahorse_application_pgp_settings (NULL), "changed::default-key",
G_CALLBACK (on_settings_default_key_changed), collection, 0);
return GCR_COLLECTION (collection);
diff --git a/pgp/seahorse-signer.c b/pgp/seahorse-signer.c
index 2da3641..0abd45e 100755
--- a/pgp/seahorse-signer.c
+++ b/pgp/seahorse-signer.c
@@ -81,7 +81,7 @@ seahorse_signer_get (GtkWindow *parent)
seahorse_combo_keys_attach (GTK_COMBO_BOX (combo), collection, NULL);
g_object_unref (collection);
- settings = seahorse_context_pgp_settings (NULL);
+ settings = seahorse_application_pgp_settings (NULL);
/* Select the last key used */
id = g_settings_get_string (settings, "last-signer");
diff --git a/src/seahorse-key-manager.c b/src/seahorse-key-manager.c
index a84431d..7495109 100644
--- a/src/seahorse-key-manager.c
+++ b/src/seahorse-key-manager.c
@@ -412,30 +412,13 @@ on_key_import_clipboard (GtkAction* action, SeahorseKeyManager* self)
gtk_clipboard_request_text (board, (GtkClipboardTextReceivedFunc)on_clipboard_received, self);
}
-static gboolean
-quit_app_later (gpointer unused)
-{
- seahorse_context_destroy (seahorse_context_instance ());
- return FALSE;
-}
-
-
static void
-on_app_quit (GtkAction* action, SeahorseKeyManager* self)
+on_app_quit (GtkAction* action,
+ SeahorseKeyManager* self)
{
g_return_if_fail (SEAHORSE_IS_KEY_MANAGER (self));
g_return_if_fail (GTK_IS_ACTION (action));
- g_idle_add (quit_app_later, NULL);
-}
-
-/* When this window closes we quit seahorse */
-static gboolean
-on_delete_event (GtkWidget* widget, GdkEvent* event, SeahorseKeyManager* self)
-{
- g_return_val_if_fail (SEAHORSE_IS_KEY_MANAGER (self), FALSE);
- g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- g_idle_add (quit_app_later, NULL);
- return TRUE;
+ g_application_quit (G_APPLICATION (seahorse_application_get ()));
}
static const gchar *
@@ -712,10 +695,6 @@ seahorse_key_manager_constructed (GObject *object)
G_CALLBACK (on_item_filter_changed), self, 0);
on_item_filter_changed (self->pv->settings, "item-filter", self);
- /* close event */
- g_signal_connect_object (seahorse_widget_get_toplevel (SEAHORSE_WIDGET (self)),
- "delete-event", G_CALLBACK (on_delete_event), self, 0);
-
/* first time signals */
g_signal_connect_object (seahorse_widget_get_widget (SEAHORSE_WIDGET (self), "import-button"),
"clicked", G_CALLBACK (on_keymanager_import_button), self, 0);
@@ -847,16 +826,14 @@ seahorse_key_manager_class_init (SeahorseKeyManagerClass *klass)
catalog_class->get_focused_place = seahorse_key_manager_get_focused_place;
}
-SeahorseWidget *
+void
seahorse_key_manager_show (void)
{
- SeahorseKeyManager *self;
+ SeahorseWidget *self;
- self = g_object_new (SEAHORSE_TYPE_KEY_MANAGER,
- "name", "key-manager",
- NULL);
-
- g_object_ref_sink (self);
-
- return SEAHORSE_WIDGET (self);
+ self = seahorse_widget_find ("key-manager");
+ if (self != NULL)
+ gtk_window_present (GTK_WINDOW (seahorse_widget_get_widget (self, self->name)));
+ else
+ g_object_new (SEAHORSE_TYPE_KEY_MANAGER, "name", "key-manager", NULL);
}
diff --git a/src/seahorse-key-manager.h b/src/seahorse-key-manager.h
index fb5d3c3..4f82636 100644
--- a/src/seahorse-key-manager.h
+++ b/src/seahorse-key-manager.h
@@ -54,7 +54,7 @@ struct _SeahorseKeyManagerClass {
GType seahorse_key_manager_get_type (void) G_GNUC_CONST;
-SeahorseWidget * seahorse_key_manager_show (void);
+void seahorse_key_manager_show (void);
G_END_DECLS
diff --git a/src/seahorse-main.c b/src/seahorse-main.c
index cbf2655..de470fb 100644
--- a/src/seahorse-main.c
+++ b/src/seahorse-main.c
@@ -22,90 +22,46 @@
#include "config.h"
+#include "seahorse-application.h"
#include "seahorse-cleanup.h"
-#include "seahorse-context.h"
-#include "seahorse-icons.h"
#include "seahorse-registry.h"
#include "seahorse-util.h"
#include "seahorse-key-manager.h"
-#include "gkr/seahorse-gkr.h"
-#include "pgp/seahorse-pgp.h"
-#include "ssh/seahorse-ssh.h"
-#include "pkcs11/seahorse-pkcs11.h"
+#include <glib/gi18n.h>
#include <locale.h>
#include <stdlib.h>
-
-#include <glib/gi18n.h>
-static gboolean show_version = FALSE;
+static void
+on_application_activate (GApplication *application,
+ gpointer user_data)
+{
+ seahorse_key_manager_show ();
+}
/* Initializes context and preferences, then loads key manager */
int
main (int argc, char **argv)
{
- SeahorseWidget *swidget;
- SeahorseContext *context;
-
- static GOptionEntry options[] = {
- { "version", 'v', 0, G_OPTION_ARG_NONE, &show_version, N_("Version of this application"), NULL },
- { NULL, 0, 0, 0, NULL, NULL, NULL }
- };
- GError *error = NULL;
- int ret = 0;
+ GtkApplication *application;
+ int status;
#ifdef ENABLE_NLS
- bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
- textdomain (GETTEXT_PACKAGE);
-#endif
-
- if (!gtk_init_with_args (&argc, &argv, _("Passwords and Keys"), options, GETTEXT_PACKAGE, &error)) {
- g_printerr ("seahorse: %s\n", error->message);
- g_error_free (error);
- exit (1);
- }
-
- if (show_version) {
- g_print ("%s\n", PACKAGE_STRING);
-#ifdef WITH_PGP
- g_print ("GNUPG: %s (%d.%d.%d)\n", GNUPG, GPG_MAJOR, GPG_MINOR, GPG_MICRO);
+ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
#endif
- exit (1);
- }
-
- /* Insert Icons into Stock */
- seahorse_icons_init ();
-
- /* Make the default SeahorseContext */
- seahorse_context_create ();
- context = seahorse_context_instance ();
-
- /* Initialize the various components */
-#ifdef WITH_PGP
- seahorse_pgp_backend_initialize ();
-#endif
-#ifdef WITH_SSH
- seahorse_ssh_backend_initialize ();
-#endif
-#ifdef WITH_PKCS11
- seahorse_pkcs11_backend_initialize ();
-#endif
- seahorse_gkr_backend_initialize ();
-
- swidget = seahorse_key_manager_show ();
-
- g_object_ref (context);
- g_signal_connect_after (context, "destroy", gtk_main_quit, NULL);
- gtk_main ();
+ g_type_init ();
- seahorse_cleanup_perform ();
+ application = seahorse_application_new ();
+ g_signal_connect (application, "activate", G_CALLBACK (on_application_activate), NULL);
+ status = g_application_run (G_APPLICATION (application), argc, argv);
- g_object_unref (swidget);
- g_object_unref (context);
+ seahorse_cleanup_perform ();
+ g_object_unref (application);
- return ret;
+ return status;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]