[seahorse/refactor: 33/37] Remove SeahorseView and merge functionality into SeahorseViewer
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seahorse/refactor: 33/37] Remove SeahorseView and merge functionality into SeahorseViewer
- Date: Thu, 20 Oct 2011 08:39:12 +0000 (UTC)
commit b7deadc93845be59ce25d87523777c8d2a438cd9
Author: Stef Walter <stefw collabora co uk>
Date: Tue Oct 18 10:39:42 2011 +0200
Remove SeahorseView and merge functionality into SeahorseViewer
* Now that SeahorseViewer is in the common directory, there's no
need to have the SeahorseView interface, and it's just confusing.
gkr/seahorse-gkr-item-commands.c | 24 +++----
gkr/seahorse-gkr-keyring-commands.c | 73 +++++++++-----------
libseahorse/Makefile.am | 1 -
libseahorse/seahorse-commands.c | 50 +++++++-------
libseahorse/seahorse-commands.h | 4 +-
libseahorse/seahorse-view.c | 127 -----------------------------------
libseahorse/seahorse-view.h | 99 ---------------------------
libseahorse/seahorse-viewer.c | 62 +++++------------
libseahorse/seahorse-viewer.h | 13 ++--
pgp/seahorse-keyserver-results.c | 2 +-
pgp/seahorse-pgp-commands.c | 62 +++++++----------
pkcs11/seahorse-pkcs11-commands.c | 38 ++++-------
pkcs11/seahorse-pkcs11-commands.h | 1 +
ssh/seahorse-ssh-commands.c | 55 ++++++---------
14 files changed, 157 insertions(+), 454 deletions(-)
---
diff --git a/gkr/seahorse-gkr-item-commands.c b/gkr/seahorse-gkr-item-commands.c
index b35df30..84889e3 100644
--- a/gkr/seahorse-gkr-item-commands.c
+++ b/gkr/seahorse-gkr-item-commands.c
@@ -117,21 +117,15 @@ seahorse_gkr_item_commands_delete_objects (SeahorseCommands* commands,
return ret;
}
-static GObject*
-seahorse_gkr_item_commands_constructor (GType type, guint n_props, GObjectConstructParam *props)
+static void
+seahorse_gkr_item_commands_constructed (GObject *obj)
{
- GObject *obj = G_OBJECT_CLASS (seahorse_gkr_item_commands_parent_class)->constructor (type, n_props, props);
- SeahorseCommands *base = NULL;
- SeahorseView *view;
-
- if (obj) {
- base = SEAHORSE_COMMANDS (obj);
- view = seahorse_commands_get_view (base);
- g_return_val_if_fail (view, NULL);
- seahorse_view_register_commands (view, &commands_predicate, base);
- }
-
- return obj;
+ SeahorseCommands *commands = SEAHORSE_COMMANDS (obj);
+
+ G_OBJECT_CLASS (seahorse_gkr_item_commands_parent_class)->constructed (obj);
+
+ seahorse_viewer_register_commands (seahorse_commands_get_viewer (commands),
+ &commands_predicate, commands);
}
static void
@@ -148,7 +142,7 @@ seahorse_gkr_item_commands_class_init (SeahorseGkrItemCommandsClass *klass)
seahorse_gkr_item_commands_parent_class = g_type_class_peek_parent (klass);
- gobject_class->constructor = seahorse_gkr_item_commands_constructor;
+ gobject_class->constructed = seahorse_gkr_item_commands_constructed;
cmd_class->show_properties = seahorse_gkr_item_commands_show_properties;
cmd_class->delete_objects = seahorse_gkr_item_commands_delete_objects;
diff --git a/gkr/seahorse-gkr-keyring-commands.c b/gkr/seahorse-gkr-keyring-commands.c
index 30be44b..1cf11eb 100644
--- a/gkr/seahorse-gkr-keyring-commands.c
+++ b/gkr/seahorse-gkr-keyring-commands.c
@@ -56,7 +56,7 @@ static const char* UI_KEYRING = ""\
static SeahorsePredicate keyring_predicate = { 0, };
-static void on_view_selection_changed (SeahorseView *view, gpointer user_data);
+static void on_viewer_selection_changed (SeahorseViewer *viewer, gpointer user_data);
/* -----------------------------------------------------------------------------
* INTERNAL
@@ -68,13 +68,13 @@ on_refresh_all_keyrings_complete (GObject *source,
gpointer user_data)
{
SeahorseCommands *self = SEAHORSE_COMMANDS (user_data);
- SeahorseView *view;
+ SeahorseViewer *viewer;
g_return_if_fail (SEAHORSE_IS_COMMANDS (self));
- view = seahorse_commands_get_view (self);
- if (view != NULL)
- on_view_selection_changed (view, self);
+ viewer = seahorse_commands_get_viewer (self);
+ if (viewer != NULL)
+ on_viewer_selection_changed (viewer, self);
g_object_unref (self);
}
@@ -134,14 +134,14 @@ on_keyring_unlock_done (GnomeKeyringResult result, gpointer user_data)
static void
on_keyring_unlock (GtkAction *action, SeahorseGkrKeyringCommands *self)
{
- SeahorseView *view;
+ SeahorseViewer *viewer;
GList *keys, *l;
g_return_if_fail (SEAHORSE_IS_GKR_KEYRING_COMMANDS (self));
g_return_if_fail (GTK_IS_ACTION (action));
- view = seahorse_commands_get_view (SEAHORSE_COMMANDS (self));
- keys = seahorse_view_get_selected_matching (view, &keyring_predicate);
+ viewer = seahorse_commands_get_viewer (SEAHORSE_COMMANDS (self));
+ keys = seahorse_viewer_get_selected_matching (viewer, &keyring_predicate);
for (l = keys; l; l = g_list_next (l)) {
g_return_if_fail (SEAHORSE_IS_GKR_KEYRING (l->data));
@@ -171,14 +171,14 @@ on_keyring_lock_done (GnomeKeyringResult result, gpointer user_data)
static void
on_keyring_lock (GtkAction *action, SeahorseGkrKeyringCommands *self)
{
- SeahorseView *view;
+ SeahorseViewer *viewer;
GList *keyrings, *l;
g_return_if_fail (SEAHORSE_IS_GKR_KEYRING_COMMANDS (self));
g_return_if_fail (GTK_IS_ACTION (action));
- view = seahorse_commands_get_view (SEAHORSE_COMMANDS (self));
- keyrings = seahorse_view_get_selected_matching (view, &keyring_predicate);
+ viewer = seahorse_commands_get_viewer (SEAHORSE_COMMANDS (self));
+ keyrings = seahorse_viewer_get_selected_matching (viewer, &keyring_predicate);
for (l = keyrings; l; l = g_list_next (l)) {
g_return_if_fail (SEAHORSE_IS_GKR_KEYRING (l->data));
@@ -208,14 +208,14 @@ on_set_default_keyring_done (GnomeKeyringResult result, gpointer user_data)
static void
on_keyring_default (GtkAction *action, SeahorseGkrKeyringCommands *self)
{
- SeahorseView *view;
+ SeahorseViewer *viewer;
GList *keys;
g_return_if_fail (SEAHORSE_IS_GKR_KEYRING_COMMANDS (self));
g_return_if_fail (GTK_IS_ACTION (action));
- view = seahorse_commands_get_view (SEAHORSE_COMMANDS (self));
- keys = seahorse_view_get_selected_matching (view, &keyring_predicate);
+ viewer = seahorse_commands_get_viewer (SEAHORSE_COMMANDS (self));
+ keys = seahorse_viewer_get_selected_matching (viewer, &keyring_predicate);
if (keys) {
gnome_keyring_set_default_keyring (seahorse_gkr_keyring_get_name (keys->data),
@@ -245,14 +245,14 @@ on_change_password_done (GnomeKeyringResult result, gpointer user_data)
static void
on_keyring_password (GtkAction *action, SeahorseGkrKeyringCommands *self)
{
- SeahorseView *view;
+ SeahorseViewer *viewer;
GList *keys, *l;
g_return_if_fail (SEAHORSE_IS_GKR_KEYRING_COMMANDS (self));
g_return_if_fail (GTK_IS_ACTION (action));
- view = seahorse_commands_get_view (SEAHORSE_COMMANDS (self));
- keys = seahorse_view_get_selected_matching (view, &keyring_predicate);
+ viewer = seahorse_commands_get_viewer (SEAHORSE_COMMANDS (self));
+ keys = seahorse_viewer_get_selected_matching (viewer, &keyring_predicate);
for (l = keys; l; l = g_list_next (l)) {
g_return_if_fail (SEAHORSE_IS_GKR_KEYRING (l->data));
@@ -275,7 +275,8 @@ static const GtkActionEntry ENTRIES_KEYRING[] = {
};
static void
-on_view_selection_changed (SeahorseView *view, gpointer user_data)
+on_viewer_selection_changed (SeahorseViewer *viewer,
+ gpointer user_data)
{
SeahorseGkrKeyringCommands *self = user_data;
GnomeKeyringInfo *info;
@@ -283,11 +284,8 @@ on_view_selection_changed (SeahorseView *view, gpointer user_data)
gboolean unlocked = FALSE;
gboolean can_default = FALSE;
GList *keys, *l;
-
- g_return_if_fail (SEAHORSE_IS_VIEW (view));
- g_return_if_fail (SEAHORSE_IS_GKR_KEYRING_COMMANDS (self));
-
- keys = seahorse_view_get_selected_matching (view, &keyring_predicate);
+
+ keys = seahorse_viewer_get_selected_matching (viewer, &keyring_predicate);
for (l = keys; l; l = g_list_next (l)) {
info = seahorse_gkr_keyring_get_info (l->data);
if (info != NULL) {
@@ -373,32 +371,29 @@ seahorse_gkr_keyring_commands_delete_objects (SeahorseCommands* commands,
return ret;
}
-static GObject*
-seahorse_gkr_keyring_commands_constructor (GType type, guint n_props, GObjectConstructParam *props)
+static void
+seahorse_gkr_keyring_commands_constructed (GObject* obj)
{
- SeahorseGkrKeyringCommands *self = SEAHORSE_GKR_KEYRING_COMMANDS (G_OBJECT_CLASS (seahorse_gkr_keyring_commands_parent_class)->constructor (type, n_props, props));
+ SeahorseGkrKeyringCommands *self = SEAHORSE_GKR_KEYRING_COMMANDS (obj);
GtkActionGroup *actions;
- SeahorseView *view;
-
- g_return_val_if_fail (SEAHORSE_IS_GKR_KEYRING_COMMANDS (self), NULL);
-
- view = seahorse_commands_get_view (SEAHORSE_COMMANDS (self));
- g_return_val_if_fail (view, NULL);
- seahorse_view_register_commands (view, &keyring_predicate, SEAHORSE_COMMANDS (self));
+ SeahorseViewer *viewer;
+
+ G_OBJECT_CLASS (seahorse_gkr_keyring_commands_parent_class)->constructed (obj);
+
+ viewer = seahorse_commands_get_viewer (SEAHORSE_COMMANDS (self));
+ seahorse_viewer_register_commands (viewer, &keyring_predicate, SEAHORSE_COMMANDS (self));
actions = gtk_action_group_new ("gkr-keyring");
gtk_action_group_set_translation_domain (actions, GETTEXT_PACKAGE);
gtk_action_group_add_actions (actions, ENTRIES_KEYRING, G_N_ELEMENTS (ENTRIES_KEYRING), self);
- seahorse_view_register_ui (view, &keyring_predicate, UI_KEYRING, actions);
+ seahorse_viewer_register_ui (viewer, &keyring_predicate, UI_KEYRING, actions);
self->pv->action_lock = g_object_ref (gtk_action_group_get_action (actions, "keyring-lock"));
self->pv->action_unlock = g_object_ref (gtk_action_group_get_action (actions, "keyring-unlock"));
self->pv->action_default = g_object_ref (gtk_action_group_get_action (actions, "keyring-default"));
g_object_unref (actions);
-
- /* Watch and wait for selection changes and diddle lock/unlock */
- g_signal_connect (view, "selection-changed", G_CALLBACK (on_view_selection_changed), self);
- return G_OBJECT (self);
+ /* Watch and wait for selection changes and diddle lock/unlock */
+ g_signal_connect (viewer, "selection-changed", G_CALLBACK (on_viewer_selection_changed), self);
}
static void
@@ -433,7 +428,7 @@ seahorse_gkr_keyring_commands_class_init (SeahorseGkrKeyringCommandsClass *klass
seahorse_gkr_keyring_commands_parent_class = g_type_class_peek_parent (klass);
- gobject_class->constructor = seahorse_gkr_keyring_commands_constructor;
+ gobject_class->constructed = seahorse_gkr_keyring_commands_constructed;
gobject_class->finalize = seahorse_gkr_keyring_commands_finalize;
cmd_class->show_properties = seahorse_gkr_keyring_commands_show_properties;
diff --git a/libseahorse/Makefile.am b/libseahorse/Makefile.am
index b9ae7e1..bc42164 100644
--- a/libseahorse/Makefile.am
+++ b/libseahorse/Makefile.am
@@ -54,7 +54,6 @@ libseahorse_la_SOURCES = \
seahorse-types.c seahorse-types.h \
seahorse-util.c seahorse-util.h \
seahorse-validity.c seahorse-validity.h \
- seahorse-view.c seahorse-view.h \
seahorse-viewer.c seahorse-viewer.h \
seahorse-widget.c seahorse-widget.h \
$(MARSHAL_SRCS) \
diff --git a/libseahorse/seahorse-commands.c b/libseahorse/seahorse-commands.c
index 4d7f3cb..7a4a23c 100644
--- a/libseahorse/seahorse-commands.c
+++ b/libseahorse/seahorse-commands.c
@@ -26,14 +26,14 @@
enum {
PROP_0,
- PROP_VIEW,
+ PROP_VIEWER,
PROP_KTYPE,
PROP_COMMAND_ACTIONS,
PROP_UI_DEFINITION
};
struct _SeahorseCommandsPrivate {
- SeahorseView* view;
+ SeahorseViewer* viewer;
};
G_DEFINE_TYPE (SeahorseCommands, seahorse_commands, G_TYPE_OBJECT);
@@ -72,11 +72,12 @@ static void
seahorse_commands_dispose (GObject *obj)
{
SeahorseCommands *self = SEAHORSE_COMMANDS (obj);
-
- if (self->pv->view)
- g_object_remove_weak_pointer (G_OBJECT (self->pv->view), (gpointer*)&self->pv->view);
- self->pv->view = NULL;
-
+
+ if (self->pv->viewer)
+ g_object_remove_weak_pointer (G_OBJECT (self->pv->viewer),
+ (gpointer*)&self->pv->viewer);
+ self->pv->viewer = NULL;
+
G_OBJECT_CLASS (seahorse_commands_parent_class)->dispose (obj);
}
@@ -85,8 +86,8 @@ seahorse_commands_finalize (GObject *obj)
{
SeahorseCommands *self = SEAHORSE_COMMANDS (obj);
- g_assert (!self->pv->view);
-
+ g_assert (!self->pv->viewer);
+
G_OBJECT_CLASS (seahorse_commands_parent_class)->finalize (obj);
}
@@ -97,11 +98,12 @@ seahorse_commands_set_property (GObject *obj, guint prop_id, const GValue *value
SeahorseCommands *self = SEAHORSE_COMMANDS (obj);
switch (prop_id) {
- case PROP_VIEW:
- g_return_if_fail (!self->pv->view);
- self->pv->view = g_value_get_object (value);
- g_return_if_fail (self->pv->view);
- g_object_add_weak_pointer (G_OBJECT (self->pv->view), (gpointer*)&self->pv->view);
+ case PROP_VIEWER:
+ g_return_if_fail (!self->pv->viewer);
+ self->pv->viewer = g_value_get_object (value);
+ g_return_if_fail (self->pv->viewer);
+ g_object_add_weak_pointer (G_OBJECT (self->pv->viewer),
+ (gpointer*)&self->pv->viewer);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
@@ -116,8 +118,8 @@ seahorse_commands_get_property (GObject *obj, guint prop_id, GValue *value,
SeahorseCommands *self = SEAHORSE_COMMANDS (obj);
switch (prop_id) {
- case PROP_VIEW:
- g_value_set_object (value, seahorse_commands_get_view (self));
+ case PROP_VIEWER:
+ g_value_set_object (value, seahorse_commands_get_viewer (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
@@ -141,8 +143,8 @@ seahorse_commands_class_init (SeahorseCommandsClass *klass)
SEAHORSE_COMMANDS_CLASS (klass)->show_properties = seahorse_commands_real_show_properties;
SEAHORSE_COMMANDS_CLASS (klass)->delete_objects = seahorse_commands_real_delete_objects;
- g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_VIEW,
- g_param_spec_object ("view", "view", "view", SEAHORSE_TYPE_VIEW,
+ g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_VIEWER,
+ g_param_spec_object ("viewer", "viewer", "Viewer", SEAHORSE_TYPE_VIEWER,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_KTYPE,
@@ -179,11 +181,11 @@ seahorse_commands_delete_objects (SeahorseCommands *self,
return SEAHORSE_COMMANDS_GET_CLASS (self)->delete_objects (self, objects);
}
-SeahorseView*
-seahorse_commands_get_view (SeahorseCommands* self)
+SeahorseViewer *
+seahorse_commands_get_viewer (SeahorseCommands* self)
{
g_return_val_if_fail (SEAHORSE_IS_COMMANDS (self), NULL);
- return self->pv->view;
+ return self->pv->viewer;
}
GtkActionGroup*
@@ -210,7 +212,7 @@ seahorse_commands_get_ui_definition (SeahorseCommands* self)
GtkWindow*
seahorse_commands_get_window (SeahorseCommands* self)
{
- SeahorseView *view = seahorse_commands_get_view (self);
- g_return_val_if_fail (view, NULL);
- return seahorse_view_get_window (view);
+ SeahorseViewer *viewer = seahorse_commands_get_viewer (self);
+ g_return_val_if_fail (viewer != NULL, NULL);
+ return seahorse_viewer_get_window (viewer);
}
diff --git a/libseahorse/seahorse-commands.h b/libseahorse/seahorse-commands.h
index 5d795dc..7cae090 100644
--- a/libseahorse/seahorse-commands.h
+++ b/libseahorse/seahorse-commands.h
@@ -27,7 +27,7 @@
#include <glib-object.h>
#include "seahorse-object.h"
-#include "seahorse-view.h"
+#include "seahorse-viewer.h"
#define SEAHORSE_TYPE_COMMANDS (seahorse_commands_get_type ())
#define SEAHORSE_COMMANDS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_TYPE_COMMANDS, SeahorseCommands))
@@ -64,7 +64,7 @@ void seahorse_commands_show_properties (SeahorseComman
gboolean seahorse_commands_delete_objects (SeahorseCommands *self,
GList *objects);
-SeahorseView * seahorse_commands_get_view (SeahorseCommands *self);
+SeahorseViewer * seahorse_commands_get_viewer (SeahorseCommands *self);
GtkWindow * seahorse_commands_get_window (SeahorseCommands *self);
diff --git a/libseahorse/seahorse-viewer.c b/libseahorse/seahorse-viewer.c
index d413323..c0deada 100644
--- a/libseahorse/seahorse-viewer.c
+++ b/libseahorse/seahorse-viewer.c
@@ -29,7 +29,6 @@
#include "seahorse-progress.h"
#include "seahorse-registry.h"
#include "seahorse-util.h"
-#include "seahorse-view.h"
#include "seahorse-viewer.h"
#include <glib/gi18n-lib.h>
@@ -59,9 +58,7 @@ struct _SeahorseViewerPrivate {
GList *all_commands;
};
-static void seahorse_viewer_implement_view (SeahorseViewIface *iface);
-G_DEFINE_TYPE_EXTENDED (SeahorseViewer, seahorse_viewer, SEAHORSE_TYPE_WIDGET, 0,
- G_IMPLEMENT_INTERFACE (SEAHORSE_TYPE_VIEW, seahorse_viewer_implement_view));
+G_DEFINE_TYPE (SeahorseViewer, seahorse_viewer, SEAHORSE_TYPE_WIDGET);
#define SEAHORSE_VIEWER_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), SEAHORSE_TYPE_VIEWER, SeahorseViewerPrivate))
@@ -495,7 +492,7 @@ include_basic_actions (SeahorseViewer* self)
}
static void
-on_selection_changed (SeahorseView* view, SeahorseViewer* self)
+seahorse_viewer_real_selection_changed (SeahorseViewer *self)
{
SeahorseViewerPrivate *pv = SEAHORSE_VIEWER_GET_PRIVATE (self);
ViewerPredicate *predicate;
@@ -503,10 +500,10 @@ on_selection_changed (SeahorseView* view, SeahorseViewer* self)
guint i;
g_return_if_fail (SEAHORSE_IS_VIEWER (self));
- g_return_if_fail (SEAHORSE_IS_VIEW (view));
/* Enable if anything is selected */
- gtk_action_group_set_sensitive (pv->object_actions, seahorse_view_get_selected (view) != NULL);
+ gtk_action_group_set_sensitive (pv->object_actions,
+ seahorse_viewer_get_selected (self) != NULL);
objects = seahorse_viewer_get_selected_objects (self);
@@ -554,22 +551,17 @@ on_add_widget (GtkUIManager* ui, GtkWidget* widget, SeahorseViewer* self)
g_warning ("no place holder found for: %s", name);
}
-
-/* -----------------------------------------------------------------------------
- * OBJECT
- */
-
-static GList*
-seahorse_viewer_get_selected_matching (SeahorseView *base,
+GList *
+seahorse_viewer_get_selected_matching (SeahorseViewer *self,
SeahorsePredicate *pred)
{
GList *all_objects;
GList *objects;
- g_return_val_if_fail (SEAHORSE_IS_VIEW (base), NULL);
- g_return_val_if_fail (pred, NULL);
+ g_return_val_if_fail (SEAHORSE_IS_VIEWER (self), NULL);
+ g_return_val_if_fail (pred != NULL, NULL);
- all_objects = seahorse_view_get_selected_objects (base);
+ all_objects = seahorse_viewer_get_selected_objects (self);
objects = filter_matching_objects (pred, &all_objects);
g_list_free (all_objects);
@@ -609,9 +601,6 @@ seahorse_viewer_constructor (GType type, guint n_props, GObjectConstructParam *p
include_basic_actions (self);
- g_signal_connect (SEAHORSE_VIEW (self), "selection-changed",
- G_CALLBACK (on_selection_changed), self);
-
/* Setup the commands */
types = seahorse_registry_object_types (seahorse_registry_get (), "commands", NULL, NULL);
for (l = types; l; l = g_list_next (l)) {
@@ -700,7 +689,7 @@ seahorse_viewer_get_property (GObject *obj, guint prop_id, GValue *value,
g_value_set_object (value, seahorse_viewer_get_selected (self));
break;
case PROP_WINDOW:
- g_value_set_object (value, seahorse_view_get_window (SEAHORSE_VIEW (self)));
+ g_value_set_object (value, seahorse_viewer_get_window (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
@@ -738,31 +727,24 @@ seahorse_viewer_class_init (SeahorseViewerClass *klass)
gobject_class->set_property = seahorse_viewer_set_property;
gobject_class->get_property = seahorse_viewer_get_property;
+ klass->selection_changed = seahorse_viewer_real_selection_changed;
+
g_object_class_install_property (gobject_class, PROP_SELECTED,
g_param_spec_object ("selected", "Selected", "Selected Object",
- SEAHORSE_TYPE_OBJECT, G_PARAM_READWRITE));
+ SEAHORSE_TYPE_OBJECT, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_WINDOW,
g_param_spec_object ("window", "Window", "Window of View",
GTK_TYPE_WIDGET, G_PARAM_READABLE));
+ g_signal_new ("selection-changed", SEAHORSE_TYPE_VIEWER,
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (SeahorseViewerClass, selection_changed),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+
exportable_predicate.flags = SEAHORSE_FLAG_EXPORTABLE;
deletable_predicate.flags = SEAHORSE_FLAG_DELETABLE;
}
-static void
-seahorse_viewer_implement_view (SeahorseViewIface *iface)
-{
- iface->get_selected_objects = (gpointer)seahorse_viewer_get_selected_objects;
- iface->set_selected_objects = (gpointer)seahorse_viewer_set_selected_objects;
- iface->get_selected = (gpointer)seahorse_viewer_get_selected;
- iface->set_selected = (gpointer)seahorse_viewer_set_selected;
- iface->get_selected_matching = (gpointer)seahorse_viewer_get_selected_matching;
- iface->get_window = (gpointer)seahorse_viewer_get_window;
- iface->register_ui = (gpointer)seahorse_viewer_register_ui;
- iface->register_commands = (gpointer)seahorse_viewer_register_commands;
-}
-
/* -----------------------------------------------------------------------------
* PUBLIC
*/
@@ -804,16 +786,6 @@ seahorse_viewer_set_selected_objects (SeahorseViewer* self, GList* objects)
SEAHORSE_VIEWER_GET_CLASS (self)->set_selected_objects (self, objects);
}
-GObject *
-seahorse_viewer_get_selected_object_and_uid (SeahorseViewer *self,
- guint *uid)
-{
- g_return_val_if_fail (SEAHORSE_IS_VIEWER (self), NULL);
- g_return_val_if_fail (SEAHORSE_VIEWER_GET_CLASS (self)->get_selected_object_and_uid, NULL);
-
- return SEAHORSE_VIEWER_GET_CLASS (self)->get_selected_object_and_uid (self, uid);
-}
-
void
seahorse_viewer_show_context_menu (SeahorseViewer* self, guint button, guint time)
{
diff --git a/libseahorse/seahorse-viewer.h b/libseahorse/seahorse-viewer.h
index 4eb75cb..e582941 100644
--- a/libseahorse/seahorse-viewer.h
+++ b/libseahorse/seahorse-viewer.h
@@ -24,8 +24,7 @@
#include <glib-object.h>
-#include "seahorse-object.h"
-#include "seahorse-view.h"
+#include "seahorse-predicate.h"
#include "seahorse-widget.h"
#define SEAHORSE_TYPE_VIEWER (seahorse_viewer_get_type ())
@@ -35,6 +34,7 @@
#define SEAHORSE_IS_VIEWER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAHORSE_TYPE_VIEWER))
#define SEAHORSE_VIEWER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAHORSE_TYPE_VIEWER, SeahorseViewerClass))
+typedef struct _SeahorseCommands SeahorseCommands;
typedef struct _SeahorseViewer SeahorseViewer;
typedef struct _SeahorseViewerClass SeahorseViewerClass;
typedef struct _SeahorseViewerPrivate SeahorseViewerPrivate;
@@ -53,9 +53,6 @@ struct _SeahorseViewerClass {
void (*set_selected_objects) (SeahorseViewer *self,
GList *objects);
- GObject * (*get_selected_object_and_uid) (SeahorseViewer* self,
- guint *uid);
-
GObject * (*get_selected) (SeahorseViewer* self);
void (*set_selected) (SeahorseViewer* self,
@@ -63,7 +60,7 @@ struct _SeahorseViewerClass {
/* signals --------------------------------------------------------- */
- void (*signal) (SeahorseViewer *viewer);
+ void (*selection_changed) (SeahorseViewer *viewer);
};
GType seahorse_viewer_get_type (void);
@@ -78,8 +75,8 @@ GList* seahorse_viewer_get_selected_objects (SeahorseVie
void seahorse_viewer_set_selected_objects (SeahorseViewer* self,
GList* objects);
-GObject * seahorse_viewer_get_selected_object_and_uid (SeahorseViewer *self,
- guint *uid);
+GList * seahorse_viewer_get_selected_matching (SeahorseViewer *self,
+ SeahorsePredicate *pred);
void seahorse_viewer_show_context_menu (SeahorseViewer* self,
guint button,
diff --git a/pgp/seahorse-keyserver-results.c b/pgp/seahorse-keyserver-results.c
index a9800ff..3df5aa1 100644
--- a/pgp/seahorse-keyserver-results.c
+++ b/pgp/seahorse-keyserver-results.c
@@ -77,7 +77,7 @@ fire_selection_changed (SeahorseKeyserverResults* self)
seahorse_viewer_set_numbered_status (SEAHORSE_VIEWER (self), ngettext ("Selected %d key", "Selected %d keys", rows), rows);
if (self->pv->import_actions)
gtk_action_group_set_sensitive (self->pv->import_actions, rows > 0);
- g_signal_emit_by_name (G_OBJECT (SEAHORSE_VIEW (self)), "selection-changed");
+ g_signal_emit_by_name (self, "selection-changed");
return FALSE;
}
diff --git a/pgp/seahorse-pgp-commands.c b/pgp/seahorse-pgp-commands.c
index a94b512..111bacc 100644
--- a/pgp/seahorse-pgp-commands.c
+++ b/pgp/seahorse-pgp-commands.c
@@ -85,24 +85,21 @@ static SeahorsePredicate commands_uid_predicate = { 0 };
static void
on_key_sign (GtkAction* action, SeahorsePgpCommands* self)
{
- SeahorseView *view;
+ SeahorseViewer *viewer;
GtkWindow *window;
GList *keys;
- g_return_if_fail (SEAHORSE_IS_PGP_COMMANDS (self));
- g_return_if_fail (GTK_IS_ACTION (action));
-
- view = seahorse_commands_get_view (SEAHORSE_COMMANDS (self));
- keys = seahorse_view_get_selected_matching (view, &actions_key_predicate);
+ viewer = seahorse_commands_get_viewer (SEAHORSE_COMMANDS (self));
+ keys = seahorse_viewer_get_selected_matching (viewer, &actions_key_predicate);
if (keys == NULL) {
- keys = seahorse_view_get_selected_matching (view, &actions_uid_predicate);
+ keys = seahorse_viewer_get_selected_matching (viewer, &actions_uid_predicate);
if (keys == NULL)
return;
}
/* Indicate what we're actually going to operate on */
- seahorse_view_set_selected (view, keys->data);
+ seahorse_viewer_set_selected (viewer, keys->data);
window = seahorse_commands_get_window (SEAHORSE_COMMANDS (self));
@@ -126,11 +123,11 @@ on_remote_sync (GtkAction* action,
gpointer user_data)
{
SeahorseCommands *commands = SEAHORSE_COMMANDS (user_data);
- SeahorseView *view = seahorse_commands_get_view (commands);
+ SeahorseViewer *viewer = seahorse_commands_get_viewer (commands);
SeahorseGpgmeKeyring *keyring;
GList* objects;
- objects = seahorse_view_get_selected_objects (view);
+ objects = seahorse_viewer_get_selected_objects (viewer);
if (objects == NULL) {
keyring = seahorse_pgp_backend_get_default_keyring (NULL);
objects = gcr_collection_get_objects (GCR_COLLECTION (keyring));
@@ -261,32 +258,25 @@ seahorse_pgp_commands_delete_objects (SeahorseCommands* base, GList* objects)
return TRUE;
}
-static GObject*
-seahorse_pgp_commands_constructor (GType type, guint n_props, GObjectConstructParam *props)
+static void
+seahorse_pgp_commands_constructed (GObject* obj)
{
- GObject *obj = G_OBJECT_CLASS (seahorse_pgp_commands_parent_class)->constructor (type, n_props, props);
- SeahorsePgpCommands *self = NULL;
- SeahorseCommands *base;
- SeahorseView *view;
-
- if (obj) {
- self = SEAHORSE_PGP_COMMANDS (obj);
- base = SEAHORSE_COMMANDS (self);
-
- view = seahorse_commands_get_view (base);
- g_return_val_if_fail (view, NULL);
-
- self->pv->command_actions = gtk_action_group_new ("pgp");
- gtk_action_group_set_translation_domain (self->pv->command_actions, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (self->pv->command_actions, COMMAND_ENTRIES,
- G_N_ELEMENTS (COMMAND_ENTRIES), self);
-
- seahorse_view_register_commands (view, &commands_key_predicate, base);
- seahorse_view_register_commands (view, &commands_uid_predicate, base);
- seahorse_view_register_ui (view, &actions_key_predicate, UI_DEFINITION, self->pv->command_actions);
- }
-
- return obj;
+ SeahorsePgpCommands *self = SEAHORSE_PGP_COMMANDS (obj);
+ SeahorseCommands *commands = SEAHORSE_COMMANDS (obj);
+ SeahorseViewer *viewer;
+
+ G_OBJECT_CLASS (seahorse_pgp_commands_parent_class)->constructed (obj);
+
+ viewer = seahorse_commands_get_viewer (commands);
+
+ self->pv->command_actions = gtk_action_group_new ("pgp");
+ gtk_action_group_set_translation_domain (self->pv->command_actions, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (self->pv->command_actions, COMMAND_ENTRIES,
+ G_N_ELEMENTS (COMMAND_ENTRIES), self);
+
+ seahorse_viewer_register_commands (viewer, &commands_key_predicate, commands);
+ seahorse_viewer_register_commands (viewer, &commands_uid_predicate, commands);
+ seahorse_viewer_register_ui (viewer, &actions_key_predicate, UI_DEFINITION, self->pv->command_actions);
}
static void
@@ -348,7 +338,7 @@ seahorse_pgp_commands_class_init (SeahorsePgpCommandsClass *klass)
seahorse_pgp_commands_parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (klass, sizeof (SeahorsePgpCommandsPrivate));
- gobject_class->constructor = seahorse_pgp_commands_constructor;
+ gobject_class->constructed = seahorse_pgp_commands_constructed;
gobject_class->dispose = seahorse_pgp_commands_dispose;
gobject_class->finalize = seahorse_pgp_commands_finalize;
gobject_class->set_property = seahorse_pgp_commands_set_property;
diff --git a/pkcs11/seahorse-pkcs11-commands.c b/pkcs11/seahorse-pkcs11-commands.c
index 4202e8b..8495c81 100644
--- a/pkcs11/seahorse-pkcs11-commands.c
+++ b/pkcs11/seahorse-pkcs11-commands.c
@@ -148,35 +148,25 @@ seahorse_pkcs11_commands_delete_objects (SeahorseCommands *cmds, GList *objects)
return ret;
}
-static GObject*
-seahorse_pkcs11_commands_constructor (GType type, guint n_props, GObjectConstructParam *props)
+static void
+seahorse_pkcs11_commands_constructed (GObject* obj)
{
- GObject *obj = G_OBJECT_CLASS (seahorse_pkcs11_commands_parent_class)->constructor (type, n_props, props);
- SeahorsePkcs11CommandsPrivate *pv;
- SeahorsePkcs11Commands *self = NULL;
- SeahorseCommands *base;
- SeahorseView *view;
-
- if (obj) {
- pv = SEAHORSE_PKCS11_COMMANDS_GET_PRIVATE (obj);
- self = SEAHORSE_PKCS11_COMMANDS (obj);
- base = SEAHORSE_COMMANDS (self);
-
- view = seahorse_commands_get_view (base);
- g_return_val_if_fail (view, NULL);
-
- seahorse_view_register_commands (view, &commands_predicate, base);
- seahorse_view_register_ui (view, &commands_predicate, "", pv->action_group);
- }
-
- return obj;
+ SeahorsePkcs11Commands *self = SEAHORSE_PKCS11_COMMANDS (obj);
+ SeahorseCommands *commands = SEAHORSE_COMMANDS (self);
+ SeahorseViewer *viewer;
+
+ G_OBJECT_CLASS (seahorse_pkcs11_commands_parent_class)->constructed (obj);
+
+ viewer = seahorse_commands_get_viewer (commands);
+ seahorse_viewer_register_commands (viewer, &commands_predicate, commands);
+ seahorse_viewer_register_ui (viewer, &commands_predicate, "", self->pv->action_group);
}
static void
seahorse_pkcs11_commands_init (SeahorsePkcs11Commands *self)
{
- SeahorsePkcs11CommandsPrivate *pv = SEAHORSE_PKCS11_COMMANDS_GET_PRIVATE (self);
- pv->action_group = gtk_action_group_new ("pkcs11");
+ self->pv = SEAHORSE_PKCS11_COMMANDS_GET_PRIVATE (self);
+ self->pv->action_group = gtk_action_group_new ("pkcs11");
}
static void
@@ -234,7 +224,7 @@ seahorse_pkcs11_commands_class_init (SeahorsePkcs11CommandsClass *klass)
seahorse_pkcs11_commands_parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (klass, sizeof (SeahorsePkcs11CommandsPrivate));
- gobject_class->constructor = seahorse_pkcs11_commands_constructor;
+ gobject_class->constructed = seahorse_pkcs11_commands_constructed;
gobject_class->dispose = seahorse_pkcs11_commands_dispose;
gobject_class->finalize = seahorse_pkcs11_commands_finalize;
gobject_class->set_property = seahorse_pkcs11_commands_set_property;
diff --git a/pkcs11/seahorse-pkcs11-commands.h b/pkcs11/seahorse-pkcs11-commands.h
index 790e1b8..f4d67f3 100644
--- a/pkcs11/seahorse-pkcs11-commands.h
+++ b/pkcs11/seahorse-pkcs11-commands.h
@@ -39,6 +39,7 @@ typedef struct _SeahorsePkcs11CommandsPrivate SeahorsePkcs11CommandsPrivate;
struct _SeahorsePkcs11Commands {
SeahorseCommands parent;
+ SeahorsePkcs11CommandsPrivate *pv;
};
struct _SeahorsePkcs11CommandsClass {
diff --git a/ssh/seahorse-ssh-commands.c b/ssh/seahorse-ssh-commands.c
index eb24ea5..fcd7018 100644
--- a/ssh/seahorse-ssh-commands.c
+++ b/ssh/seahorse-ssh-commands.c
@@ -64,20 +64,17 @@ static SeahorsePredicate commands_predicate = { 0, };
static void
on_ssh_upload (GtkAction* action, SeahorseSshCommands* self)
{
- SeahorseView *view;
+ SeahorseViewer *viewer;
GList* ssh_keys;
- g_return_if_fail (SEAHORSE_IS_SSH_COMMANDS (self));
- g_return_if_fail (GTK_IS_ACTION (action));
-
- view = seahorse_commands_get_view (SEAHORSE_COMMANDS (self));
- ssh_keys = seahorse_view_get_selected_matching (view, &commands_predicate);
+ viewer = seahorse_commands_get_viewer (SEAHORSE_COMMANDS (self));
+ ssh_keys = seahorse_viewer_get_selected_matching (viewer, &commands_predicate);
if (ssh_keys == NULL)
return;
/* Indicate what we're actually going to operate on */
- seahorse_view_set_selected_objects (view, ssh_keys);
-
+ seahorse_viewer_set_selected_objects (viewer, ssh_keys);
+
seahorse_ssh_upload_prompt (ssh_keys, seahorse_commands_get_window (SEAHORSE_COMMANDS (self)));
g_list_free (ssh_keys);
}
@@ -135,31 +132,23 @@ seahorse_ssh_commands_delete_objects (SeahorseCommands* base, GList* objects)
return TRUE;
}
-static GObject*
-seahorse_ssh_commands_constructor (GType type, guint n_props, GObjectConstructParam *props)
+static void
+seahorse_ssh_commands_constructed (GObject* obj)
{
- GObject *obj = G_OBJECT_CLASS (seahorse_ssh_commands_parent_class)->constructor (type, n_props, props);
- SeahorseSshCommands *self = NULL;
- SeahorseCommands *base;
- SeahorseView *view;
-
- if (obj) {
- self = SEAHORSE_SSH_COMMANDS (obj);
- base = SEAHORSE_COMMANDS (obj);
-
- view = seahorse_commands_get_view (SEAHORSE_COMMANDS (self));
- g_return_val_if_fail (view, NULL);
-
- self->pv->command_actions = gtk_action_group_new ("ssh");
- gtk_action_group_set_translation_domain (self->pv->command_actions, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (self->pv->command_actions, COMMAND_ENTRIES,
- G_N_ELEMENTS (COMMAND_ENTRIES), self);
-
- seahorse_view_register_commands (view, &commands_predicate, base);
- seahorse_view_register_ui (view, &commands_predicate, UI_DEFINITION, self->pv->command_actions);
- }
-
- return obj;
+ SeahorseSshCommands *self = SEAHORSE_SSH_COMMANDS (obj);
+ SeahorseCommands *commands = SEAHORSE_COMMANDS (obj);
+ SeahorseViewer *viewer;
+
+ G_OBJECT_CLASS (seahorse_ssh_commands_parent_class)->constructed (obj);
+
+ viewer = seahorse_commands_get_viewer (commands);
+ self->pv->command_actions = gtk_action_group_new ("ssh");
+ gtk_action_group_set_translation_domain (self->pv->command_actions, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (self->pv->command_actions, COMMAND_ENTRIES,
+ G_N_ELEMENTS (COMMAND_ENTRIES), self);
+
+ seahorse_viewer_register_commands (viewer, &commands_predicate, commands);
+ seahorse_viewer_register_ui (viewer, &commands_predicate, UI_DEFINITION, self->pv->command_actions);
}
static void
@@ -221,7 +210,7 @@ seahorse_ssh_commands_class_init (SeahorseSshCommandsClass *klass)
seahorse_ssh_commands_parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (klass, sizeof (SeahorseSshCommandsPrivate));
- gobject_class->constructor = seahorse_ssh_commands_constructor;
+ gobject_class->constructed = seahorse_ssh_commands_constructed;
gobject_class->dispose = seahorse_ssh_commands_dispose;
gobject_class->finalize = seahorse_ssh_commands_finalize;
gobject_class->set_property = seahorse_ssh_commands_set_property;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]