seahorse r2656 - in trunk: common libseahorse pgp src ssh
- From: nnielsen svn gnome org
- To: svn-commits-list gnome org
- Subject: seahorse r2656 - in trunk: common libseahorse pgp src ssh
- Date: Sat, 13 Dec 2008 21:05:46 +0000 (UTC)
Author: nnielsen
Date: Sat Dec 13 21:05:46 2008
New Revision: 2656
URL: http://svn.gnome.org/viewvc/seahorse?rev=2656&view=rev
Log:
* common/seahorse-registry.c:
* common/seahorse-registry.h:
* libseahorse/Makefile.am:
* libseahorse/seahorse-generator.c: (removed)
* libseahorse/seahorse-generator.h: (removed)
* libseahorse/seahorse-generator.vala: (removed)
* libseahorse/seahorse-source.c:
* pgp/libseahorse-pgp-c.vapi: (removed)
* pgp/Makefile.am:
* pgp/seahorse-pgp-dialogs.h:
* pgp/seahorse-pgp-generate.c:
* pgp/seahorse-pgp-generator.c: (removed)
* pgp/seahorse-pgp-generator.h: (removed)
* pgp/seahorse-pgp-generator.vala: (removed)
* pgp/seahorse-pgp-module.c:
* src/Makefile.am:
* src/seahorse-generate-select.c:
* src/seahorse-generate-select.h:
* src/seahorse-generate-select.vala: (removed)
* ssh/libseahorse-ssh-c.vapi: (removed)
* ssh/Makefile.am:
* ssh/seahorse-ssh.c:
* ssh/seahorse-ssh.h:
* ssh/seahorse-ssh.vala: (removed)
* ssh/seahorse-ssh-dialogs.h:
* ssh/seahorse-ssh-generate.c:
* ssh/seahorse-ssh-generator.c: (removed)
* ssh/seahorse-ssh-generator.h: (removed)
* ssh/seahorse-ssh-generator.vala: (removed)
* ssh/seahorse-ssh-module.c: Simplified how the generate actions work,
and removed some vala code.
Removed:
trunk/libseahorse/seahorse-generator.c
trunk/libseahorse/seahorse-generator.h
trunk/libseahorse/seahorse-generator.vala
trunk/libseahorse/vala-build.stamp
trunk/pgp/libseahorse-pgp-c.vapi
trunk/pgp/seahorse-pgp-generator.c
trunk/pgp/seahorse-pgp-generator.h
trunk/pgp/seahorse-pgp-generator.vala
trunk/pgp/vala-build.stamp
trunk/src/seahorse-generate-select.vala
trunk/ssh/libseahorse-ssh-c.vapi
trunk/ssh/seahorse-ssh-generator.c
trunk/ssh/seahorse-ssh-generator.h
trunk/ssh/seahorse-ssh-generator.vala
trunk/ssh/seahorse-ssh.vala
trunk/ssh/vala-build.stamp
Modified:
trunk/common/seahorse-registry.c
trunk/common/seahorse-registry.h
trunk/libseahorse/Makefile.am
trunk/libseahorse/seahorse-source.c
trunk/libseahorse/seahorse-xxx.c
trunk/pgp/Makefile.am
trunk/pgp/seahorse-pgp-dialogs.h
trunk/pgp/seahorse-pgp-generate.c
trunk/pgp/seahorse-pgp-module.c
trunk/src/Makefile.am
trunk/src/seahorse-generate-select.c
trunk/src/seahorse-generate-select.h
trunk/src/seahorse-viewer.c
trunk/src/vala-build.stamp
trunk/ssh/Makefile.am
trunk/ssh/seahorse-ssh-dialogs.h
trunk/ssh/seahorse-ssh-generate.c
trunk/ssh/seahorse-ssh-module.c
trunk/ssh/seahorse-ssh.c
trunk/ssh/seahorse-ssh.h
Modified: trunk/common/seahorse-registry.c
==============================================================================
--- trunk/common/seahorse-registry.c (original)
+++ trunk/common/seahorse-registry.c Sat Dec 13 21:05:46 2008
@@ -25,7 +25,8 @@
typedef struct _SeahorseRegistryPrivate SeahorseRegistryPrivate;
struct _SeahorseRegistryPrivate {
- GHashTable *categories;
+ GHashTable *types;
+ GHashTable *objects;
};
#define SEAHORSE_REGISTRY_GET_PRIVATE(o) \
@@ -57,37 +58,36 @@
}
static void
-register_type_for_category (SeahorseRegistry *registry, const gchar *category, GType type)
+register_value_for_category (GHashTable *table, const gchar *category,
+ gpointer value, GDestroyNotify destroy_func)
{
- SeahorseRegistryPrivate *pv = SEAHORSE_REGISTRY_GET_PRIVATE (registry);
GHashTable *set;
- g_return_if_fail (SEAHORSE_IS_REGISTRY (registry));
+ g_return_if_fail (table);
g_return_if_fail (category);
g_return_if_fail (category[0]);
- set = g_hash_table_lookup (pv->categories, category);
+ set = g_hash_table_lookup (table, category);
if (!set) {
- set = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, NULL);
- g_hash_table_replace (pv->categories, g_strdup (category), set);
+ set = g_hash_table_new_full (g_direct_hash, g_direct_equal, destroy_func, NULL);
+ g_hash_table_replace (table, g_strdup (category), set);
}
- g_hash_table_replace (set, GUINT_TO_POINTER (type), NO_VALUE);
+ g_hash_table_replace (set, value, NO_VALUE);
}
static GList*
-lookup_types (SeahorseRegistry *registry, const gchar *category, va_list cats)
+lookup_category_values (GHashTable *table, const gchar *category, va_list cats)
{
- SeahorseRegistryPrivate *pv = SEAHORSE_REGISTRY_GET_PRIVATE (registry);
GList *l, *type, *types = NULL;
GHashTable *set;
-
- g_return_val_if_fail (SEAHORSE_IS_REGISTRY (registry), NULL);
+
+ g_return_val_if_fail (table, NULL);
g_return_val_if_fail (category, NULL);
g_return_val_if_fail (category[0], NULL);
/* Get the first category */
- set = g_hash_table_lookup (pv->categories, category);
+ set = g_hash_table_lookup (table, category);
if (!set)
return NULL;
@@ -95,7 +95,7 @@
g_hash_table_foreach (set, keys_to_list, &types);
/*
- * Go through the other categories and remove any in results
+ * Go through the other types and remove any in results
* which we don't find.
*/
for (;;) {
@@ -105,7 +105,7 @@
g_return_val_if_fail (category[0], NULL);
/* Lookup this category */
- set = g_hash_table_lookup (pv->categories, category);
+ set = g_hash_table_lookup (table, category);
/* No category, no matches */
if (!set) {
@@ -126,6 +126,27 @@
return types;
}
+static gpointer
+lookup_category_value (GHashTable *table, const gchar *category, va_list cats)
+{
+ gpointer value = NULL;
+ GList *values;
+
+ values = lookup_category_values (table, category, cats);
+ if (values)
+ value = values->data;
+ g_list_free (values);
+ return value;
+}
+
+static gint
+object_has_type (gconstpointer object, gconstpointer type)
+{
+ if (G_OBJECT_TYPE (object) == GPOINTER_TO_UINT (type))
+ return 0;
+ return -1;
+}
+
/* -----------------------------------------------------------------------------
* OBJECT
*/
@@ -134,15 +155,17 @@
seahorse_registry_init (SeahorseRegistry *obj)
{
SeahorseRegistryPrivate *pv = SEAHORSE_REGISTRY_GET_PRIVATE (obj);
- pv->categories = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, (GDestroyNotify)g_hash_table_destroy);
+ pv->types = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, (GDestroyNotify)g_hash_table_destroy);
+ pv->objects = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, (GDestroyNotify)g_hash_table_destroy);
}
static void
seahorse_registry_dispose (GObject *obj)
{
SeahorseRegistryPrivate *pv = SEAHORSE_REGISTRY_GET_PRIVATE (obj);
- g_hash_table_remove_all (pv->categories);
+ g_hash_table_remove_all (pv->types);
G_OBJECT_CLASS (seahorse_registry_parent_class)->dispose (obj);
}
@@ -150,7 +173,7 @@
seahorse_registry_finalize (GObject *obj)
{
SeahorseRegistryPrivate *pv = SEAHORSE_REGISTRY_GET_PRIVATE (obj);
- g_hash_table_destroy (pv->categories);
+ g_hash_table_destroy (pv->types);
G_OBJECT_CLASS (seahorse_registry_parent_class)->finalize (obj);
}
@@ -186,6 +209,7 @@
seahorse_registry_register_type (SeahorseRegistry *registry, GType type,
const gchar *category, ...)
{
+ SeahorseRegistryPrivate *pv;
va_list cats;
if (!registry)
@@ -195,44 +219,70 @@
g_return_if_fail (type);
g_return_if_fail (category);
- register_type_for_category (registry, category, type);
+ pv = SEAHORSE_REGISTRY_GET_PRIVATE (registry);
+ register_value_for_category (pv->types, category, GUINT_TO_POINTER (type), NULL);
+
+ va_start (cats, category);
+ for (;;) {
+ category = va_arg (cats, const gchar*);
+ if (!category)
+ break;
+ register_value_for_category (pv->types, category, GUINT_TO_POINTER (type), NULL);
+ }
+ va_end (cats);
+}
+
+void
+seahorse_registry_register_object (SeahorseRegistry *registry, GObject *object,
+ const gchar *category, ...)
+{
+ SeahorseRegistryPrivate *pv;
+ va_list cats;
+
+ if (!registry)
+ registry = seahorse_registry_get ();
+
+ g_return_if_fail (SEAHORSE_IS_REGISTRY (registry));
+ g_return_if_fail (G_IS_OBJECT (object));
+ g_return_if_fail (category);
+
+ pv = SEAHORSE_REGISTRY_GET_PRIVATE (registry);
+ register_value_for_category (pv->objects, category, g_object_ref (object), g_object_unref);
va_start (cats, category);
for (;;) {
category = va_arg (cats, const gchar*);
if (!category)
break;
- register_type_for_category (registry, category, type);
+ register_value_for_category (pv->objects, category, g_object_ref (object), g_object_unref);
}
va_end (cats);
}
GType
-seahorse_registry_find_type (SeahorseRegistry *registry, const gchar *category, ...)
+seahorse_registry_object_type (SeahorseRegistry *registry, const gchar *category, ...)
{
+ SeahorseRegistryPrivate *pv;
va_list cats;
- GList *types;
GType type;
if (!registry)
registry = seahorse_registry_get ();
g_return_val_if_fail (SEAHORSE_IS_REGISTRY (registry), 0);
+ pv = SEAHORSE_REGISTRY_GET_PRIVATE (registry);
va_start (cats, category);
- types = lookup_types (registry, category, cats);
+ type = GPOINTER_TO_UINT (lookup_category_value (pv->types, category, cats));
va_end (cats);
- type = 0;
- if (types)
- type = GPOINTER_TO_UINT (types->data);
- g_list_free (types);
return type;
}
GList*
-seahorse_registry_find_types (SeahorseRegistry *registry, const gchar *category, ...)
+seahorse_registry_object_types (SeahorseRegistry *registry, const gchar *category, ...)
{
+ SeahorseRegistryPrivate *pv;
va_list cats;
GList *types;
@@ -240,10 +290,71 @@
registry = seahorse_registry_get ();
g_return_val_if_fail (SEAHORSE_IS_REGISTRY (registry), NULL);
+ pv = SEAHORSE_REGISTRY_GET_PRIVATE (registry);
va_start (cats, category);
- types = lookup_types (registry, category, cats);
+ types = lookup_category_values (pv->types, category, cats);
va_end (cats);
return types;
}
+
+GObject*
+seahorse_registry_object_instance (SeahorseRegistry *registry, const gchar *category, ...)
+{
+ SeahorseRegistryPrivate *pv;
+ va_list cats;
+ GObject *object;
+ GType type;
+
+ if (!registry)
+ registry = seahorse_registry_get ();
+
+ g_return_val_if_fail (SEAHORSE_IS_REGISTRY (registry), 0);
+ pv = SEAHORSE_REGISTRY_GET_PRIVATE (registry);
+
+ va_start (cats, category);
+ object = lookup_category_value (pv->objects, category, cats);
+ type = GPOINTER_TO_UINT (lookup_category_value (pv->types, category, cats));
+ va_end (cats);
+
+ if (object)
+ return g_object_ref (object);
+
+ if (!type)
+ return NULL;
+
+ return g_object_new (type, NULL);
+}
+
+GList*
+seahorse_registry_object_instances (SeahorseRegistry *registry, const gchar *category, ...)
+{
+ SeahorseRegistryPrivate *pv;
+ va_list cats;
+ GList *objects;
+ GList *types, *l;
+
+ if (!registry)
+ registry = seahorse_registry_get ();
+
+ g_return_val_if_fail (SEAHORSE_IS_REGISTRY (registry), 0);
+ pv = SEAHORSE_REGISTRY_GET_PRIVATE (registry);
+
+ va_start (cats, category);
+ objects = lookup_category_values (pv->objects, category, cats);
+ types = lookup_category_values (pv->types, category, cats);
+ va_end (cats);
+
+ for (l = objects; l; l = g_list_next (l))
+ g_object_ref (l->data);
+
+ /* Instantiate other types if nothing of that type exists */
+ for (l = types; l; l = g_list_next (l)) {
+ if (!g_list_find_custom (objects, l->data, object_has_type))
+ objects = g_list_prepend (objects, g_object_new (GPOINTER_TO_UINT (l->data), NULL));
+ }
+
+ g_list_free (types);
+ return objects;
+}
Modified: trunk/common/seahorse-registry.h
==============================================================================
--- trunk/common/seahorse-registry.h (original)
+++ trunk/common/seahorse-registry.h Sat Dec 13 21:05:46 2008
@@ -45,21 +45,33 @@
};
/* member functions */
-GType seahorse_registry_get_type (void) G_GNUC_CONST;
+GType seahorse_registry_get_type (void) G_GNUC_CONST;
-SeahorseRegistry* seahorse_registry_get (void);
+SeahorseRegistry* seahorse_registry_get (void);
-void seahorse_registry_register_type (SeahorseRegistry *registry,
- GType type, const gchar *category,
- ...) G_GNUC_NULL_TERMINATED;
+void seahorse_registry_register_type (SeahorseRegistry *registry,
+ GType type, const gchar *category,
+ ...) G_GNUC_NULL_TERMINATED;
-GType seahorse_registry_find_type (SeahorseRegistry *registry,
- const gchar *category,
- ...) G_GNUC_NULL_TERMINATED;
+void seahorse_registry_register_object (SeahorseRegistry *registry,
+ GObject *object, const gchar *category,
+ ...) G_GNUC_NULL_TERMINATED;
-GList* seahorse_registry_find_types (SeahorseRegistry *registry,
- const gchar *category,
- ...) G_GNUC_NULL_TERMINATED;
+GType seahorse_registry_object_type (SeahorseRegistry *registry,
+ const gchar *category,
+ ...) G_GNUC_NULL_TERMINATED;
+
+GList* seahorse_registry_object_types (SeahorseRegistry *registry,
+ const gchar *category,
+ ...) G_GNUC_NULL_TERMINATED;
+
+GObject* seahorse_registry_object_instance (SeahorseRegistry *registry,
+ const gchar *category,
+ ...) G_GNUC_NULL_TERMINATED;
+
+GList* seahorse_registry_object_instances (SeahorseRegistry *registry,
+ const gchar *category,
+ ...) G_GNUC_NULL_TERMINATED;
G_END_DECLS
Modified: trunk/libseahorse/Makefile.am
==============================================================================
--- trunk/libseahorse/Makefile.am (original)
+++ trunk/libseahorse/Makefile.am Sat Dec 13 21:05:46 2008
@@ -16,7 +16,6 @@
-DLIBCRYPTUI_API_SUBJECT_TO_CHANGE
VALA_SRCS = \
- seahorse-generator.vala \
seahorse-servers.vala
VALA_PKGS = \
@@ -28,16 +27,11 @@
SUFFIXES = .vala .c .h
-vala-build.stamp: $(VALA_SRCS)
- $(VALAC) -C -X "$(INCLUDES)" --library libseahorse $(VALA_PKGS) $^ --basedir ./
- date +'%s' > $@
-
MARSHAL_SRCS = \
seahorse-marshal.c seahorse-marshal.h
BUILT_SOURCES = \
- $(MARSHAL_SRCS) \
- vala-build.stamp
+ $(MARSHAL_SRCS)
noinst_LTLIBRARIES = libseahorse.la
@@ -103,7 +97,6 @@
seahorse-notify.glade
EXTRA_DIST = $(glade_DATA) \
- vala-build.stamp \
$(VALA_SRCS) \
libseahorse-c.vapi \
libseahorse.vapi \
@@ -111,5 +104,7 @@
seahorse-marshal.list
vala-clean:
- rm -f vala-build.stamp $(VALA_CFILES) $(VALA_HFILES)
+ rm -f $(VALA_CFILES) $(VALA_HFILES)
+vala-build: $(VALA_SRCS)
+ $(VALAC) -C -X "$(INCLUDES)" --library libseahorse $(VALA_PKGS) $^ --basedir ./
Modified: trunk/libseahorse/seahorse-source.c
==============================================================================
--- trunk/libseahorse/seahorse-source.c (original)
+++ trunk/libseahorse/seahorse-source.c Sat Dec 13 21:05:46 2008
@@ -379,7 +379,7 @@
g_return_val_if_fail (id != NULL, 0);
- type = seahorse_registry_find_type (NULL, "source", g_quark_to_string (ktype), "local", NULL);
+ type = seahorse_registry_object_type (NULL, "source", g_quark_to_string (ktype), "local", NULL);
g_return_val_if_fail (type, 0);
klass = SEAHORSE_SOURCE_CLASS (g_type_class_peek (type));
Modified: trunk/libseahorse/seahorse-xxx.c
==============================================================================
--- trunk/libseahorse/seahorse-xxx.c (original)
+++ trunk/libseahorse/seahorse-xxx.c Sat Dec 13 21:05:46 2008
@@ -63,7 +63,7 @@
static void
seahorse_xxx_init (SeahorseXxx *self)
{
- self->pv = G_TYPE_INSTANCE_GET_PRIVATE ((o), SEAHORSE_TYPE_XXX, SeahorseXxxPrivate);
+ self->pv = G_TYPE_INSTANCE_GET_PRIVATE (self, SEAHORSE_TYPE_XXX, SeahorseXxxPrivate);
}
Modified: trunk/pgp/Makefile.am
==============================================================================
--- trunk/pgp/Makefile.am (original)
+++ trunk/pgp/Makefile.am Sat Dec 13 21:05:46 2008
@@ -17,27 +17,6 @@
-DLIBCRYPTUI_API_SUBJECT_TO_CHANGE \
-DGETTEXT_PACKAGE=\""seahorse\""
-VALA_SRCS = \
- seahorse-pgp-generator.vala
-
-VALA_VAPIS = \
- libseahorse-pgp-c.vapi \
- $(top_srcdir)/config.vapi \
- $(top_srcdir)/libseahorse/libseahorse-c.vapi \
- $(top_srcdir)/libseahorse/libseahorse.vapi
-
-VALA_CFILES = $(VALA_SRCS:.vala=.c)
-VALA_HFILES = $(VALA_SRCS:.vala=.h)
-
-SUFFIXES = .vala .c .h
-
-vala-build.stamp: $(VALA_SRCS) $(VALA_VAPIS)
- $(VALAC) -C $(VALA_PKGS) $(VALA_VAPIS) $(VALA_SRCS)
- date +'%s' > $@
-
-BUILT_SOURCES = \
- vala-build.stamp
-
noinst_LTLIBRARIES = libseahorse-pgp.la
if WITH_LDAP
@@ -109,12 +88,5 @@
seahorse-signer.glade
EXTRA_DIST = \
- $(glade_DATA) \
- libseahorse-pgp-c.vapi \
- vala-build.stamp \
- $(VALA_CFILES) $(VALA_HFILES) \
- $(VALA_SRCS)
-
-vala-clean:
- rm -f vala-build.stamp $(VALA_CFILES) $(VALA_HFILES)
+ $(glade_DATA)
Modified: trunk/pgp/seahorse-pgp-dialogs.h
==============================================================================
--- trunk/pgp/seahorse-pgp-dialogs.h (original)
+++ trunk/pgp/seahorse-pgp-dialogs.h Sat Dec 13 21:05:46 2008
@@ -48,6 +48,8 @@
void seahorse_pgp_key_properties_show (SeahorsePgpKey *pkey,
GtkWindow *parent);
+void seahorse_pgp_generate_register (void);
+
void seahorse_pgp_generate_show (SeahorsePGPSource *sksrc,
GtkWindow *parent);
Modified: trunk/pgp/seahorse-pgp-generate.c
==============================================================================
--- trunk/pgp/seahorse-pgp-generate.c (original)
+++ trunk/pgp/seahorse-pgp-generate.c Sat Dec 13 21:05:46 2008
@@ -33,12 +33,56 @@
#include "seahorse-progress.h"
#include "seahorse-gtkstock.h"
#include "seahorse-passphrase.h"
+#include "seahorse-gtkstock.h"
+#include "seahorse-pgp.h"
#include "seahorse-pgp-dialogs.h"
#include "seahorse-pgp-key.h"
#include "seahorse-pgp-key-op.h"
#include "seahorse-pgp-source.h"
+#include "common/seahorse-registry.h"
+
+/* --------------------------------------------------------------------------
+ * ACTIONS
+ */
+
+static void
+on_pgp_generate_key (GtkAction *action, gpointer unused)
+{
+ SeahorseSource* sksrc;
+
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ sksrc = seahorse_context_find_source (seahorse_context_for_app (), SEAHORSE_PGP_TYPE, SEAHORSE_LOCATION_LOCAL);
+ g_return_if_fail (sksrc != NULL);
+
+ seahorse_pgp_generate_show (SEAHORSE_PGP_SOURCE (sksrc), NULL);
+}
+
+static const GtkActionEntry ACTION_ENTRIES[] = {
+ { "pgp-generate-key", SEAHORSE_PGP_STOCK_ICON, N_ ("PGP Key"), "",
+ N_("Used to encrypt email and files"), G_CALLBACK (on_pgp_generate_key) }
+};
+
+void
+seahorse_pgp_generate_register (void)
+{
+ GtkActionGroup *actions;
+
+ actions = gtk_action_group_new ("pgp-generate");
+
+ gtk_action_group_set_translation_domain (actions, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (actions, ACTION_ENTRIES, G_N_ELEMENTS (ACTION_ENTRIES), NULL);
+
+ /* Register this as a generator */
+ seahorse_registry_register_object (NULL, actions, SEAHORSE_PGP_TYPE_STR, "generator", NULL);
+}
+
+/* --------------------------------------------------------------------------
+ * DIALOGS
+ */
+
typedef struct _AlgorithmDesc {
const gchar* desc;
guint type;
Modified: trunk/pgp/seahorse-pgp-module.c
==============================================================================
--- trunk/pgp/seahorse-pgp-module.c (original)
+++ trunk/pgp/seahorse-pgp-module.c Sat Dec 13 21:05:46 2008
@@ -24,8 +24,8 @@
#include "seahorse-pgp-module.h"
#include "seahorse-pgp-commands.h"
-#include "seahorse-pgp-generator.h"
#include "seahorse-pgp-source.h"
+#include "seahorse-pgp-dialogs.h"
#ifdef WITH_LDAP
#include "seahorse-ldap-source.h"
@@ -47,11 +47,12 @@
g_type_class_unref (g_type_class_ref (SEAHORSE_TYPE_PGP_SOURCE));
g_type_class_unref (g_type_class_ref (SEAHORSE_TYPE_PGP_COMMANDS));
- g_type_class_unref (g_type_class_ref (SEAHORSE_PGP_TYPE_GENERATOR));
#ifdef WITH_LDAP
g_type_class_unref (g_type_class_ref (SEAHORSE_TYPE_LDAP_SOURCE));
#endif
#ifdef WITH_HKP
g_type_class_unref (g_type_class_ref (SEAHORSE_TYPE_HKP_SOURCE));
#endif
+
+ seahorse_pgp_generate_register ();
}
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Sat Dec 13 21:05:46 2008
@@ -17,7 +17,6 @@
-DGETTEXT_PACKAGE=\""seahorse\""
VALA_SRCS = \
- seahorse-generate-select.vala \
seahorse-key-manager.vala \
seahorse-keyserver-results.vala
@@ -68,6 +67,7 @@
seahorse_SOURCES = main.c \
seahorse-preferences.c seahorse-preferences.h \
eggtreemultidnd.c eggtreemultidnd.h \
+ seahorse-generate-select.c seahorse-generate-select.h \
seahorse-key-manager-store.c seahorse-key-manager-store.h \
seahorse-viewer.c seahorse-viewer.h \
seahorse-windows.h \
Modified: trunk/src/seahorse-generate-select.c
==============================================================================
--- trunk/src/seahorse-generate-select.c (original)
+++ trunk/src/seahorse-generate-select.c Sat Dec 13 21:05:46 2008
@@ -19,319 +19,194 @@
* 02111-1307, USA.
*/
-#include "seahorse-generate-select.h"
-#include <seahorse-generator.h>
-#include <common/seahorse-registry.h>
-#include <stdlib.h>
-#include <string.h>
+#include "config.h"
+#include "seahorse-generate-select.h"
-#define SEAHORSE_GENERATE_SELECT_TYPE_COLUMN (seahorse_generate_select_column_get_type ())
+#include "common/seahorse-object-list.h"
+#include "common/seahorse-registry.h"
typedef enum {
- SEAHORSE_GENERATE_SELECT_COLUMN_ICON,
- SEAHORSE_GENERATE_SELECT_COLUMN_TEXT,
- SEAHORSE_GENERATE_SELECT_COLUMN_ACTION,
- SEAHORSE_GENERATE_SELECT_COLUMN_N_COLUMNS
-} SeahorseGenerateSelectColumn;
-
-
+ COLUMN_ICON,
+ COLUMN_TEXT,
+ COLUMN_ACTION,
+ COLUMN_N_COLUMNS
+} Column;
struct _SeahorseGenerateSelectPrivate {
- GtkListStore* _store;
- GtkTreeView* _view;
- GtkDialog* _dialog;
- SeahorseGenerator** _generators;
- gint _generators_length1;
+ GtkListStore* store;
+ GtkTreeView* view;
+ GtkDialog* dialog;
+ GList *action_groups;
};
-#define SEAHORSE_GENERATE_SELECT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SEAHORSE_TYPE_GENERATE_SELECT, SeahorseGenerateSelectPrivate))
-enum {
- SEAHORSE_GENERATE_SELECT_DUMMY_PROPERTY
-};
-GType seahorse_generate_select_column_get_type (void);
-static SeahorseGenerateSelect* seahorse_generate_select_new (void);
-static void seahorse_generate_select_fire_selected_action (SeahorseGenerateSelect* self);
-static void seahorse_generate_select_on_row_activated (SeahorseGenerateSelect* self, GtkTreeView* view, GtkTreePath* path, GtkTreeViewColumn* col);
-static void seahorse_generate_select_on_response (SeahorseGenerateSelect* self, GtkDialog* dialog, gint response);
-static void _seahorse_generate_select_on_row_activated_gtk_tree_view_row_activated (GtkTreeView* _sender, GtkTreePath* path, GtkTreeViewColumn* column, gpointer self);
-static void _seahorse_generate_select_on_response_gtk_dialog_response (GtkDialog* _sender, gint response_id, gpointer self);
-static GObject * seahorse_generate_select_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
-static gpointer seahorse_generate_select_parent_class = NULL;
-static void seahorse_generate_select_finalize (GObject * obj);
-static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
-
-static const char* SEAHORSE_GENERATE_SELECT_TEMPLATE = "<span size=\"larger\" weight=\"bold\">%s</span>\n%s";
-
-
-
-GType seahorse_generate_select_column_get_type (void) {
- static GType seahorse_generate_select_column_type_id = 0;
- if (G_UNLIKELY (seahorse_generate_select_column_type_id == 0)) {
- static const GEnumValue values[] = {{SEAHORSE_GENERATE_SELECT_COLUMN_ICON, "SEAHORSE_GENERATE_SELECT_COLUMN_ICON", "icon"}, {SEAHORSE_GENERATE_SELECT_COLUMN_TEXT, "SEAHORSE_GENERATE_SELECT_COLUMN_TEXT", "text"}, {SEAHORSE_GENERATE_SELECT_COLUMN_ACTION, "SEAHORSE_GENERATE_SELECT_COLUMN_ACTION", "action"}, {SEAHORSE_GENERATE_SELECT_COLUMN_N_COLUMNS, "SEAHORSE_GENERATE_SELECT_COLUMN_N_COLUMNS", "n-columns"}, {0, NULL, NULL}};
- seahorse_generate_select_column_type_id = g_enum_register_static ("SeahorseGenerateSelectColumn", values);
- }
- return seahorse_generate_select_column_type_id;
-}
-
-
-static SeahorseGenerateSelect* seahorse_generate_select_new (void) {
- GParameter * __params;
- GParameter * __params_it;
- SeahorseGenerateSelect * self;
- __params = g_new0 (GParameter, 1);
- __params_it = __params;
- __params_it->name = "name";
- g_value_init (&__params_it->value, G_TYPE_STRING);
- g_value_set_string (&__params_it->value, "generate-select");
- __params_it++;
- self = g_object_newv (SEAHORSE_TYPE_GENERATE_SELECT, __params_it - __params, __params);
- while (__params_it > __params) {
- --__params_it;
- g_value_unset (&__params_it->value);
- }
- g_free (__params);
- return self;
-}
+G_DEFINE_TYPE (SeahorseGenerateSelect, seahorse_generate_select, SEAHORSE_TYPE_WIDGET);
+static const char* TEMPLATE = "<span size=\"larger\" weight=\"bold\">%s</span>\n%s";
-void seahorse_generate_select_show (GtkWindow* parent) {
- SeahorseGenerateSelect* sel;
- g_return_if_fail (parent == NULL || GTK_IS_WINDOW (parent));
- sel = g_object_ref_sink (seahorse_generate_select_new ());
- g_object_ref (G_OBJECT (sel));
- /* Destorys itself with destroy */
- if (parent != NULL) {
- gtk_window_set_transient_for (GTK_WINDOW (sel->priv->_dialog), parent);
- }
- (sel == NULL ? NULL : (sel = (g_object_unref (sel), NULL)));
-}
+/* -----------------------------------------------------------------------------
+ * INTERNAL
+ */
+static gboolean
+fire_selected_action (SeahorseGenerateSelect* self)
+{
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ GtkAction *action;
+
+ selection = gtk_tree_view_get_selection (self->pv->view);
+ if (!gtk_tree_selection_get_selected (selection, &model, &iter))
+ return FALSE;
-static void seahorse_generate_select_fire_selected_action (SeahorseGenerateSelect* self) {
- GtkTreeIter iter = {0};
- GtkTreeModel* model;
- GtkTreeModel* _tmp3;
- GtkTreeModel* _tmp2;
- gboolean _tmp1;
- GtkTreeModel* _tmp0;
- GtkAction* action;
- g_return_if_fail (SEAHORSE_IS_GENERATE_SELECT (self));
- model = NULL;
- _tmp3 = NULL;
- _tmp2 = NULL;
- _tmp0 = NULL;
- if (!(_tmp1 = gtk_tree_selection_get_selected (gtk_tree_view_get_selection (self->priv->_view), &_tmp0, &iter), model = (_tmp2 = (_tmp3 = _tmp0, (_tmp3 == NULL ? NULL : g_object_ref (_tmp3))), (model == NULL ? NULL : (model = (g_object_unref (model), NULL))), _tmp2), _tmp1)) {
- (model == NULL ? NULL : (model = (g_object_unref (model), NULL)));
- return;
- }
- action = NULL;
- gtk_tree_model_get (model, &iter, SEAHORSE_GENERATE_SELECT_COLUMN_ACTION, &action, -1, -1);
+ gtk_tree_model_get (GTK_TREE_MODEL (self->pv->store), &iter,
+ COLUMN_ACTION, &action, -1);
g_assert (action != NULL);
+
gtk_action_activate (action);
- (model == NULL ? NULL : (model = (g_object_unref (model), NULL)));
- (action == NULL ? NULL : (action = (g_object_unref (action), NULL)));
+ return TRUE;
}
-
-static void seahorse_generate_select_on_row_activated (SeahorseGenerateSelect* self, GtkTreeView* view, GtkTreePath* path, GtkTreeViewColumn* col) {
+static void
+on_row_activated (GtkTreeView* view, GtkTreePath* path, GtkTreeViewColumn* col, SeahorseGenerateSelect* self)
+{
g_return_if_fail (SEAHORSE_IS_GENERATE_SELECT (self));
g_return_if_fail (GTK_IS_TREE_VIEW (view));
g_return_if_fail (path != NULL);
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (col));
- seahorse_generate_select_fire_selected_action (self);
- seahorse_widget_destroy (SEAHORSE_WIDGET (self));
+
+ if (fire_selected_action (self))
+ seahorse_widget_destroy (SEAHORSE_WIDGET (self));
}
-
-static void seahorse_generate_select_on_response (SeahorseGenerateSelect* self, GtkDialog* dialog, gint response) {
+static void
+on_response (GtkDialog* dialog, gint response, SeahorseGenerateSelect* self)
+{
g_return_if_fail (SEAHORSE_IS_GENERATE_SELECT (self));
g_return_if_fail (GTK_IS_DIALOG (dialog));
- if (response == GTK_RESPONSE_OK) {
- seahorse_generate_select_fire_selected_action (self);
- }
- seahorse_widget_destroy (SEAHORSE_WIDGET (self));
-}
+
+ if (response == GTK_RESPONSE_OK)
+ fire_selected_action (self);
-
-static void _seahorse_generate_select_on_row_activated_gtk_tree_view_row_activated (GtkTreeView* _sender, GtkTreePath* path, GtkTreeViewColumn* column, gpointer self) {
- seahorse_generate_select_on_row_activated (self, _sender, path, column);
+ seahorse_widget_destroy (SEAHORSE_WIDGET (self));
}
-
-static void _seahorse_generate_select_on_response_gtk_dialog_response (GtkDialog* _sender, gint response_id, gpointer self) {
- seahorse_generate_select_on_response (self, _sender, response_id);
-}
+/* -----------------------------------------------------------------------------
+ * OBJECT
+ */
-static GObject * seahorse_generate_select_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
- GObject * obj;
- SeahorseGenerateSelectClass * klass;
- GObjectClass * parent_class;
- SeahorseGenerateSelect * self;
- klass = SEAHORSE_GENERATE_SELECT_CLASS (g_type_class_peek (SEAHORSE_TYPE_GENERATE_SELECT));
- parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
- obj = parent_class->constructor (type, n_construct_properties, construct_properties);
- self = SEAHORSE_GENERATE_SELECT (obj);
- {
- GtkListStore* _tmp0;
- GList* types;
- SeahorseGenerator** _tmp2;
- gint _tmp1;
- gint i;
- GtkTreeView* _tmp13;
- GtkTreeView* _tmp12;
- GtkCellRendererPixbuf* pixcell;
- guint _tmp14;
- GtkCellRendererText* _tmp15;
- GtkTreeIter iter = {0};
- GtkDialog* _tmp17;
- GtkDialog* _tmp16;
- _tmp0 = NULL;
- self->priv->_store = (_tmp0 = gtk_list_store_new (((gint) (SEAHORSE_GENERATE_SELECT_COLUMN_N_COLUMNS)), G_TYPE_STRING, G_TYPE_STRING, GTK_TYPE_ACTION, NULL), (self->priv->_store == NULL ? NULL : (self->priv->_store = (g_object_unref (self->priv->_store), NULL))), _tmp0);
- types = seahorse_registry_find_types (seahorse_registry_get (), "generator", NULL, NULL);
- _tmp2 = NULL;
- self->priv->_generators = (_tmp2 = g_new0 (SeahorseGenerator*, (_tmp1 = g_list_length (types)) + 1), (self->priv->_generators = (_vala_array_free (self->priv->_generators, self->priv->_generators_length1, ((GDestroyNotify) (g_object_unref))), NULL)), self->priv->_generators_length1 = _tmp1, _tmp2);
- i = 0;
- {
- GList* typ_collection;
- GList* typ_it;
- typ_collection = types;
- for (typ_it = typ_collection; typ_it != NULL; typ_it = typ_it->next) {
- GType typ;
- typ = GPOINTER_TO_INT (typ_it->data);
- {
- SeahorseGenerator* generator;
- gint _tmp5;
- SeahorseGenerator* _tmp4;
- SeahorseGenerator* _tmp3;
- GtkActionGroup* _tmp6;
- GtkActionGroup* group;
- generator = SEAHORSE_GENERATOR (g_object_new (typ, NULL, NULL));
- _tmp4 = NULL;
- _tmp3 = NULL;
- _tmp5 = i++;
- self->priv->_generators[_tmp5] = (_tmp4 = (_tmp3 = generator, (_tmp3 == NULL ? NULL : g_object_ref (_tmp3))), (self->priv->_generators[_tmp5] == NULL ? NULL : (self->priv->_generators[_tmp5] = (g_object_unref (self->priv->_generators[_tmp5]), NULL))), _tmp4);
- /* Add each action to our store */
- _tmp6 = NULL;
- group = (_tmp6 = seahorse_generator_get_actions (generator), (_tmp6 == NULL ? NULL : g_object_ref (_tmp6)));
- if (group != NULL) {
- GList* actions;
- actions = gtk_action_group_list_actions (group);
- {
- GList* action_collection;
- GList* action_it;
- action_collection = actions;
- for (action_it = action_collection; action_it != NULL; action_it = action_it->next) {
- GtkAction* _tmp11;
- GtkAction* action;
- _tmp11 = NULL;
- action = (_tmp11 = ((GtkAction*) (action_it->data)), (_tmp11 == NULL ? NULL : g_object_ref (_tmp11)));
- {
- char* _tmp8;
- char* _tmp7;
- char* text;
- const char* _tmp10;
- char* _tmp9;
- char* icon;
- GtkTreeIter iter = {0};
- _tmp8 = NULL;
- _tmp7 = NULL;
- text = g_strdup_printf (SEAHORSE_GENERATE_SELECT_TEMPLATE, (g_object_get (G_OBJECT (action), "label", &_tmp7, NULL), _tmp7), (g_object_get (G_OBJECT (action), "tooltip", &_tmp8, NULL), _tmp8));
- _tmp10 = NULL;
- _tmp9 = NULL;
- icon = (_tmp10 = (g_object_get (G_OBJECT (action), "stock-id", &_tmp9, NULL), _tmp9), (_tmp10 == NULL ? NULL : g_strdup (_tmp10)));
- gtk_list_store_append (self->priv->_store, &iter);
- gtk_list_store_set (self->priv->_store, &iter, SEAHORSE_GENERATE_SELECT_COLUMN_TEXT, text, SEAHORSE_GENERATE_SELECT_COLUMN_ICON, icon, SEAHORSE_GENERATE_SELECT_COLUMN_ACTION, action, -1, -1);
- (action == NULL ? NULL : (action = (g_object_unref (action), NULL)));
- text = (g_free (text), NULL);
- icon = (g_free (icon), NULL);
- }
- }
- }
- }
- (generator == NULL ? NULL : (generator = (g_object_unref (generator), NULL)));
- (group == NULL ? NULL : (group = (g_object_unref (group), NULL)));
- }
- }
+static GObject*
+seahorse_generate_select_constructor (GType type, guint n_props, GObjectConstructParam *props)
+{
+ SeahorseGenerateSelect *self = SEAHORSE_GENERATE_SELECT (G_OBJECT_CLASS (seahorse_generate_select_parent_class)->constructor(type, n_props, props));
+ gchar *text, *icon;
+ gchar *label, *tooltip;
+ GtkCellRenderer *pixcell;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ GList *l;
+
+ g_return_val_if_fail (self, NULL);
+
+ self->pv->store = gtk_list_store_new (COLUMN_N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, GTK_TYPE_ACTION);
+
+ self->pv->action_groups = seahorse_registry_object_instances (NULL, "generator", NULL);
+ for (l = self->pv->action_groups; l; l = g_list_next (l)) {
+ GList *k, *actions = gtk_action_group_list_actions (l->data);
+ for (k = actions; k; k = g_list_next (k)) {
+
+ g_object_get (k->data, "label", &label, "tooltip", &tooltip, "stock-id", &icon, NULL);
+ text = g_strdup_printf (TEMPLATE, label, tooltip);
+
+ gtk_list_store_append (self->pv->store, &iter);
+ gtk_list_store_set (self->pv->store, &iter,
+ COLUMN_TEXT, text,
+ COLUMN_ICON, icon,
+ COLUMN_ACTION, k->data,
+ -1);
+
+ g_free (text);
+ g_free (label);
+ g_free (icon);
+ g_free (tooltip);
}
- /* Hook it into the view */
- _tmp13 = NULL;
- _tmp12 = NULL;
- self->priv->_view = (_tmp13 = (_tmp12 = GTK_TREE_VIEW (seahorse_widget_get_widget (SEAHORSE_WIDGET (self), "keytype-tree")), (_tmp12 == NULL ? NULL : g_object_ref (_tmp12))), (self->priv->_view == NULL ? NULL : (self->priv->_view = (g_object_unref (self->priv->_view), NULL))), _tmp13);
- pixcell = g_object_ref_sink (((GtkCellRendererPixbuf*) (gtk_cell_renderer_pixbuf_new ())));
- g_object_set (pixcell, "stock-size", ((guint) (GTK_ICON_SIZE_DIALOG)), NULL);
- gtk_tree_view_insert_column_with_attributes (self->priv->_view, -1, "", GTK_CELL_RENDERER (pixcell), "stock-id", SEAHORSE_GENERATE_SELECT_COLUMN_ICON, NULL, NULL);
- _tmp15 = NULL;
- gtk_tree_view_insert_column_with_attributes (self->priv->_view, -1, "", GTK_CELL_RENDERER ((_tmp15 = g_object_ref_sink (((GtkCellRendererText*) (gtk_cell_renderer_text_new ()))))), "markup", SEAHORSE_GENERATE_SELECT_COLUMN_TEXT, NULL, NULL);
- (_tmp15 == NULL ? NULL : (_tmp15 = (g_object_unref (_tmp15), NULL)));
- gtk_tree_view_set_model (self->priv->_view, GTK_TREE_MODEL (self->priv->_store));
- /* Setup selection, select first item */
- gtk_tree_selection_set_mode (gtk_tree_view_get_selection (self->priv->_view), GTK_SELECTION_BROWSE);
- gtk_tree_model_get_iter_first (GTK_TREE_MODEL (self->priv->_store), &iter);
- gtk_tree_selection_select_iter (gtk_tree_view_get_selection (self->priv->_view), &iter);
- g_signal_connect_object (self->priv->_view, "row-activated", ((GCallback) (_seahorse_generate_select_on_row_activated_gtk_tree_view_row_activated)), self, 0);
- _tmp17 = NULL;
- _tmp16 = NULL;
- self->priv->_dialog = (_tmp17 = (_tmp16 = GTK_DIALOG (seahorse_widget_get_toplevel (SEAHORSE_WIDGET (self))), (_tmp16 == NULL ? NULL : g_object_ref (_tmp16))), (self->priv->_dialog == NULL ? NULL : (self->priv->_dialog = (g_object_unref (self->priv->_dialog), NULL))), _tmp17);
- g_signal_connect_object (self->priv->_dialog, "response", ((GCallback) (_seahorse_generate_select_on_response_gtk_dialog_response)), self, 0);
- (types == NULL ? NULL : (types = (g_list_free (types), NULL)));
- (pixcell == NULL ? NULL : (pixcell = (g_object_unref (pixcell), NULL)));
+
+ g_list_free (actions);
}
- return obj;
-}
-
-
-static void seahorse_generate_select_class_init (SeahorseGenerateSelectClass * klass) {
- seahorse_generate_select_parent_class = g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (SeahorseGenerateSelectPrivate));
- G_OBJECT_CLASS (klass)->constructor = seahorse_generate_select_constructor;
- G_OBJECT_CLASS (klass)->finalize = seahorse_generate_select_finalize;
-}
-
-
-static void seahorse_generate_select_instance_init (SeahorseGenerateSelect * self) {
- self->priv = SEAHORSE_GENERATE_SELECT_GET_PRIVATE (self);
-}
+
+ /* Hook it into the view */
+ self->pv->view = GTK_TREE_VIEW (seahorse_widget_get_widget (SEAHORSE_WIDGET (self), "keytype-tree"));
+ g_return_val_if_fail (self->pv->view, NULL);
+
+ pixcell = gtk_cell_renderer_pixbuf_new ();
+ g_object_set (pixcell, "stock-size", GTK_ICON_SIZE_DIALOG, NULL);
+ gtk_tree_view_insert_column_with_attributes (self->pv->view, -1, "", pixcell, "stock-id", COLUMN_ICON, NULL);
+ gtk_tree_view_insert_column_with_attributes (self->pv->view, -1, "", gtk_cell_renderer_text_new (), "markup", COLUMN_TEXT, NULL);
+ gtk_tree_view_set_model (self->pv->view, GTK_TREE_MODEL (self->pv->store));
+
+ /* Setup selection, select first item */
+ selection = gtk_tree_view_get_selection (self->pv->view);
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
+
+ gtk_tree_model_get_iter_first (GTK_TREE_MODEL (self->pv->store), &iter);
+ gtk_tree_selection_select_iter (selection, &iter);
+
+ g_signal_connect (self->pv->view, "row-activated", G_CALLBACK (on_row_activated), self);
+
+ self->pv->dialog = GTK_DIALOG (seahorse_widget_get_toplevel (SEAHORSE_WIDGET (self)));
+ g_signal_connect (self->pv->dialog, "response", G_CALLBACK (on_response), self);
+
+ return G_OBJECT (self);
+}
+
+static void
+seahorse_generate_select_init (SeahorseGenerateSelect *self)
+{
+ self->pv = G_TYPE_INSTANCE_GET_PRIVATE (self, SEAHORSE_TYPE_GENERATE_SELECT, SeahorseGenerateSelectPrivate);
+}
+
+static void
+seahorse_generate_select_finalize (GObject *obj)
+{
+ SeahorseGenerateSelect *self = SEAHORSE_GENERATE_SELECT (obj);
+
+ if (self->pv->store != NULL)
+ g_object_unref (self->pv->store);
+ self->pv->store = NULL;
+ seahorse_object_list_free (self->pv->action_groups);
+ self->pv->action_groups = NULL;
-static void seahorse_generate_select_finalize (GObject * obj) {
- SeahorseGenerateSelect * self;
- self = SEAHORSE_GENERATE_SELECT (obj);
- (self->priv->_store == NULL ? NULL : (self->priv->_store = (g_object_unref (self->priv->_store), NULL)));
- (self->priv->_view == NULL ? NULL : (self->priv->_view = (g_object_unref (self->priv->_view), NULL)));
- (self->priv->_dialog == NULL ? NULL : (self->priv->_dialog = (g_object_unref (self->priv->_dialog), NULL)));
- self->priv->_generators = (_vala_array_free (self->priv->_generators, self->priv->_generators_length1, ((GDestroyNotify) (g_object_unref))), NULL);
G_OBJECT_CLASS (seahorse_generate_select_parent_class)->finalize (obj);
}
+static void
+seahorse_generate_select_class_init (SeahorseGenerateSelectClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+ seahorse_generate_select_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (SeahorseGenerateSelectPrivate));
-GType seahorse_generate_select_get_type (void) {
- static GType seahorse_generate_select_type_id = 0;
- if (seahorse_generate_select_type_id == 0) {
- static const GTypeInfo g_define_type_info = { sizeof (SeahorseGenerateSelectClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) seahorse_generate_select_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SeahorseGenerateSelect), 0, (GInstanceInitFunc) seahorse_generate_select_instance_init };
- seahorse_generate_select_type_id = g_type_register_static (SEAHORSE_TYPE_WIDGET, "SeahorseGenerateSelect", &g_define_type_info, 0);
- }
- return seahorse_generate_select_type_id;
-}
-
+ gobject_class->constructor = seahorse_generate_select_constructor;
+ gobject_class->finalize = seahorse_generate_select_finalize;
-static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
- if (array != NULL && destroy_func != NULL) {
- int i;
- if (array_length >= 0)
- for (i = 0; i < array_length; i = i + 1) {
- if (((gpointer*) (array))[i] != NULL)
- destroy_func (((gpointer*) (array))[i]);
- }
- else
- for (i = 0; ((gpointer*) (array))[i] != NULL; i = i + 1) {
- destroy_func (((gpointer*) (array))[i]);
- }
- }
- g_free (array);
}
+/* -----------------------------------------------------------------------------
+ * PUBLIC
+ */
-
-
+void
+seahorse_generate_select_show (GtkWindow* parent)
+{
+ SeahorseGenerateSelect* sel;
+
+ g_return_if_fail (parent == NULL || GTK_IS_WINDOW (parent));
+
+ sel = g_object_ref_sink (g_object_new (SEAHORSE_TYPE_GENERATE_SELECT, "name", "generate-select", NULL));
+ if (parent != NULL)
+ gtk_window_set_transient_for (GTK_WINDOW (sel->pv->dialog), parent);
+}
Modified: trunk/src/seahorse-generate-select.h
==============================================================================
--- trunk/src/seahorse-generate-select.h (original)
+++ trunk/src/seahorse-generate-select.h Sat Dec 13 21:05:46 2008
@@ -24,18 +24,15 @@
#include <glib.h>
#include <glib-object.h>
-#include <seahorse-widget.h>
-#include <gtk/gtk.h>
-G_BEGIN_DECLS
+#include "seahorse-widget.h"
-
-#define SEAHORSE_TYPE_GENERATE_SELECT (seahorse_generate_select_get_type ())
-#define SEAHORSE_GENERATE_SELECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_TYPE_GENERATE_SELECT, SeahorseGenerateSelect))
-#define SEAHORSE_GENERATE_SELECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SEAHORSE_TYPE_GENERATE_SELECT, SeahorseGenerateSelectClass))
-#define SEAHORSE_IS_GENERATE_SELECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAHORSE_TYPE_GENERATE_SELECT))
-#define SEAHORSE_IS_GENERATE_SELECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAHORSE_TYPE_GENERATE_SELECT))
-#define SEAHORSE_GENERATE_SELECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAHORSE_TYPE_GENERATE_SELECT, SeahorseGenerateSelectClass))
+#define SEAHORSE_TYPE_GENERATE_SELECT (seahorse_generate_select_get_type ())
+#define SEAHORSE_GENERATE_SELECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_TYPE_GENERATE_SELECT, SeahorseGenerateSelect))
+#define SEAHORSE_GENERATE_SELECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SEAHORSE_TYPE_GENERATE_SELECT, SeahorseGenerateSelectClass))
+#define SEAHORSE_IS_GENERATE_SELECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAHORSE_TYPE_GENERATE_SELECT))
+#define SEAHORSE_IS_GENERATE_SELECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAHORSE_TYPE_GENERATE_SELECT))
+#define SEAHORSE_GENERATE_SELECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAHORSE_TYPE_GENERATE_SELECT, SeahorseGenerateSelectClass))
typedef struct _SeahorseGenerateSelect SeahorseGenerateSelect;
typedef struct _SeahorseGenerateSelectClass SeahorseGenerateSelectClass;
@@ -43,14 +40,13 @@
struct _SeahorseGenerateSelect {
SeahorseWidget parent_instance;
- SeahorseGenerateSelectPrivate * priv;
+ SeahorseGenerateSelectPrivate *pv;
};
struct _SeahorseGenerateSelectClass {
SeahorseWidgetClass parent_class;
};
-
void seahorse_generate_select_show (GtkWindow* parent);
GType seahorse_generate_select_get_type (void);
Modified: trunk/src/seahorse-viewer.c
==============================================================================
--- trunk/src/seahorse-viewer.c (original)
+++ trunk/src/seahorse-viewer.c Sat Dec 13 21:05:46 2008
@@ -556,7 +556,7 @@
G_CALLBACK (on_selection_changed), self);
/* Setup the commands */
- types = seahorse_registry_find_types (seahorse_registry_get (), "commands", NULL, NULL);
+ types = seahorse_registry_object_types (seahorse_registry_get (), "commands", NULL, NULL);
for (l = types; l; l = g_list_next (l)) {
GType typ = GPOINTER_TO_INT (l->data);
SeahorseCommands *commands;
Modified: trunk/src/vala-build.stamp
==============================================================================
--- trunk/src/vala-build.stamp (original)
+++ trunk/src/vala-build.stamp Sat Dec 13 21:05:46 2008
@@ -1 +1 @@
-1228007245
+1229196882
Modified: trunk/ssh/Makefile.am
==============================================================================
--- trunk/ssh/Makefile.am (original)
+++ trunk/ssh/Makefile.am Sat Dec 13 21:05:46 2008
@@ -16,32 +16,11 @@
-DGETTEXT_PACKAGE=\""seahorse\""
AM_LDFLAGS = @NETLIBS@
-
-VALA_SRCS = \
- seahorse-ssh.vala \
- seahorse-ssh-generator.vala
-
-VALA_VAPIS = \
- libseahorse-ssh-c.vapi \
- $(top_srcdir)/config.vapi \
- $(top_srcdir)/libseahorse/libseahorse-c.vapi \
- $(top_srcdir)/libseahorse/libseahorse.vapi
-
-VALA_CFILES = $(VALA_SRCS:.vala=.c)
-VALA_HFILES = $(VALA_SRCS:.vala=.h)
-
-SUFFIXES = .vala .c .h
-
-vala-build.stamp: $(VALA_SRCS) $(VALA_VAPIS)
- $(VALAC) -C $(VALA_PKGS) $(VALA_VAPIS) $(VALA_SRCS)
- date +'%s' > $@
-
-BUILT_SOURCES = \
- vala-build.stamp
noinst_LTLIBRARIES = libseahorse-ssh.la
libseahorse_ssh_la_SOURCES = \
+ seahorse-ssh.h seahorse-ssh.c \
seahorse-ssh-module.c seahorse-ssh-module.h \
seahorse-algo.c seahorse-algo.h \
seahorse-ssh-commands.c seahorse-ssh-commands.h \
@@ -52,8 +31,7 @@
seahorse-ssh-key-properties.c \
seahorse-ssh-source.c seahorse-ssh-source.h \
seahorse-ssh-operation.c seahorse-ssh-operation.h \
- seahorse-ssh-upload.c \
- $(VALA_CFILES) $(VALA_HFILES)
+ seahorse-ssh-upload.c
libseahorse_ssh_la_LIBADD = \
$(top_builddir)/libseahorse/libseahorse.la \
@@ -73,12 +51,5 @@
seahorse-ssh-upload.glade
EXTRA_DIST = \
- $(glade_DATA) \
- libseahorse-ssh-c.vapi \
- vala-build.stamp \
- $(VALA_CFILES) $(VALA_HFILES) \
- $(VALA_SRCS)
-
-vala-clean:
- rm -f vala-build.stamp $(VALA_CFILES) $(VALA_HFILES)
+ $(glade_DATA)
Modified: trunk/ssh/seahorse-ssh-dialogs.h
==============================================================================
--- trunk/ssh/seahorse-ssh-dialogs.h (original)
+++ trunk/ssh/seahorse-ssh-dialogs.h Sat Dec 13 21:05:46 2008
@@ -15,4 +15,6 @@
void seahorse_ssh_generate_show (SeahorseSSHSource *sksrc,
GtkWindow *parent);
+void seahorse_ssh_generate_register (void);
+
#endif /*SEAHORSESSHDIALOGS_H_*/
Modified: trunk/ssh/seahorse-ssh-generate.c
==============================================================================
--- trunk/ssh/seahorse-ssh-generate.c (original)
+++ trunk/ssh/seahorse-ssh-generate.c Sat Dec 13 21:05:46 2008
@@ -28,6 +28,7 @@
#include "seahorse-ssh-dialogs.h"
#include "seahorse-ssh-source.h"
#include "seahorse-ssh-key.h"
+#include "seahorse-ssh.h"
#include "seahorse-ssh-operation.h"
#include "seahorse-widget.h"
@@ -35,6 +36,48 @@
#include "seahorse-progress.h"
#include "seahorse-gtkstock.h"
+#include "common/seahorse-registry.h"
+
+/* --------------------------------------------------------------------------
+ * ACTIONS
+ */
+
+static void
+on_ssh_generate_key (GtkAction *action, gpointer unused)
+{
+ SeahorseSource* sksrc;
+
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ sksrc = seahorse_context_find_source (seahorse_context_for_app (), SEAHORSE_SSH_TYPE, SEAHORSE_LOCATION_LOCAL);
+ g_return_if_fail (sksrc != NULL);
+
+ seahorse_ssh_generate_show (SEAHORSE_SSH_SOURCE (sksrc), NULL);
+}
+
+static const GtkActionEntry ACTION_ENTRIES[] = {
+ { "ssh-generate-key", SEAHORSE_SSH_STOCK_ICON, N_ ("Secure Shell Key"), "",
+ N_("Used to access other computers (eg: via a terminal)"), G_CALLBACK (on_ssh_generate_key) }
+};
+
+void
+seahorse_ssh_generate_register (void)
+{
+ GtkActionGroup *actions;
+
+ actions = gtk_action_group_new ("ssh-generate");
+
+ gtk_action_group_set_translation_domain (actions, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (actions, ACTION_ENTRIES, G_N_ELEMENTS (ACTION_ENTRIES), NULL);
+
+ /* Register this as a generator */
+ seahorse_registry_register_object (NULL, actions, SEAHORSE_SSH_TYPE_STR, "generator", NULL);
+}
+
+/* --------------------------------------------------------------------
+ * DIALOGS
+ */
+
#define DSA_SIZE 1024
#define DEFAULT_RSA_SIZE 2048
Modified: trunk/ssh/seahorse-ssh-module.c
==============================================================================
--- trunk/ssh/seahorse-ssh-module.c (original)
+++ trunk/ssh/seahorse-ssh-module.c Sat Dec 13 21:05:46 2008
@@ -24,7 +24,7 @@
#include "seahorse-ssh-module.h"
#include "seahorse-ssh-commands.h"
-#include "seahorse-ssh-generator.h"
+#include "seahorse-ssh-dialogs.h"
#include "seahorse-ssh-source.h"
#include "seahorse-context.h"
@@ -40,5 +40,6 @@
g_type_class_unref (g_type_class_ref (SEAHORSE_TYPE_SSH_SOURCE));
g_type_class_unref (g_type_class_ref (SEAHORSE_TYPE_SSH_COMMANDS));
- g_type_class_unref (g_type_class_ref (SEAHORSE_SSH_TYPE_GENERATOR));
+
+ seahorse_ssh_generate_register ();
}
Modified: trunk/ssh/seahorse-ssh.c
==============================================================================
--- trunk/ssh/seahorse-ssh.c (original)
+++ trunk/ssh/seahorse-ssh.c Sat Dec 13 21:05:46 2008
@@ -20,6 +20,7 @@
*/
#include "seahorse-ssh.h"
+
#include <stdlib.h>
#include <string.h>
Modified: trunk/ssh/seahorse-ssh.h
==============================================================================
--- trunk/ssh/seahorse-ssh.h (original)
+++ trunk/ssh/seahorse-ssh.h Sat Dec 13 21:05:46 2008
@@ -25,15 +25,10 @@
#include <glib.h>
#include <glib-object.h>
-G_BEGIN_DECLS
-
-
#define SEAHORSE_SSH_TYPE_STR "openssh"
#define SEAHORSE_SSH_TYPE g_quark_from_string ("openssh")
#define SEAHORSE_SSH_STOCK_ICON "seahorse-key-ssh"
-G_END_DECLS
-
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]