[nautilus-actions] Introduce NactStorage new class
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Subject: [nautilus-actions] Introduce NactStorage new class
- Date: Fri, 5 Jun 2009 08:33:01 -0400 (EDT)
commit d9137b239da609b180890399504d29bd12c26101
Author: Pierre Wieser <pwieser trychlos org>
Date: Mon Jun 1 13:13:15 2009 +0200
Introduce NactStorage new class
Rationale: Introducing a new object hierarchy, where a base class will take care
of all I/O stuff, even if it is only GConf-based for now.
As a small advantage, the new class names will also be a bit shorter.
---
ChangeLog | 9 +-
src/common/Makefile.am | 5 +
src/common/nact-gconf-keys.h | 37 +++++
src/common/nact-gconf.c | 343 +++++++++++++++++++++++++++++++++++++++++
src/common/nact-gconf.h | 53 +++++++
src/common/nact-storage.c | 274 ++++++++++++++++++++++++++++++++
src/common/nact-storage.h | 102 ++++++++++++
src/plugin/nautilus-actions.c | 2 +-
8 files changed, 823 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index dad9343..32d4751 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,13 +3,20 @@
* configure.ac: Have a more funny package string.
* src/plugin/nautilus-module.c: Syslog at module initialization.
-
+
* src/plugin/nautilus-actions.c:
* src/plugin/nautilus-actions.h:
Move NautilusActions object data members to a private area.
Add forward declarations of, remove prefix from, static functions.
Do nothing on get_background_items callback.
+ * nact-gconf.c:
+ * nact-gconf.h:
+ * nact-gconf-keys.h:
+ * nact-storage.c:
+ * nact-storage.h:
+ New files, prepare for a new object hierarchy (with shorter names).
+
2009-05-29 Pierre Wieser <pwieser trychlos org>
Move all sources directories under src/
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index 0a1aa4a..4402149 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -35,6 +35,11 @@ AM_CPPFLAGS += \
$(NULL)
libnact_la_SOURCES = \
+ nact-gconf.c \
+ nact-gconf.h \
+ nact-gconf-keys.h \
+ nact-storage.c \
+ nact-storage.h \
nautilus-actions-config.c \
nautilus-actions-config.h \
nautilus-actions-config-gconf.c \
diff --git a/src/common/nact-gconf-keys.h b/src/common/nact-gconf-keys.h
new file mode 100644
index 0000000..5acdc9a
--- /dev/null
+++ b/src/common/nact-gconf-keys.h
@@ -0,0 +1,37 @@
+/*
+ * Nautilus Actions
+ * A Nautilus extension which offers configurable context menu actions.
+ *
+ * Copyright (C) 2005 The GNOME Foundation
+ * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+ * Copyright (C) 2009 Pierre Wieser and others (see AUTHORS)
+ *
+ * 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 Library; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Frederic Ruaudel <grumz grumz net>
+ * Rodrigo Moya <rodrigo gnome-db org>
+ * Pierre Wieser <pwieser trychlos org>
+ * ... and many others (see AUTHORS)
+ */
+
+#ifndef __NACT_GCONF_KEYS_H__
+#define __NACT_GCONF_KEYS_H__
+
+/* GConf general information */
+#define NACT_GCONF_CONFIG NAUTILUS_ACTIONS_CONFIG_GCONF_BASEDIR "/configurations"
+
+#endif /* __NACT_GCONF_KEYS_H__ */
diff --git a/src/common/nact-gconf.c b/src/common/nact-gconf.c
new file mode 100644
index 0000000..d56f469
--- /dev/null
+++ b/src/common/nact-gconf.c
@@ -0,0 +1,343 @@
+/*
+ * Nautilus Actions
+ * A Nautilus extension which offers configurable context menu actions.
+ *
+ * Copyright (C) 2005 The GNOME Foundation
+ * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+ * Copyright (C) 2009 Pierre Wieser and others (see AUTHORS)
+ *
+ * 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 Library; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Frederic Ruaudel <grumz grumz net>
+ * Rodrigo Moya <rodrigo gnome-db org>
+ * Pierre Wieser <pwieser trychlos org>
+ * ... and many others (see AUTHORS)
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <gconf/gconf.h>
+#include <gconf/gconf-client.h>
+#include <string.h>
+#include "nact-gconf.h"
+#include "nact-gconf-keys.h"
+
+static GConfClient *st_gconf = NULL;
+
+static void initialize( void );
+static gchar *get_object_path( NactStorage *object );
+static gchar *path_to_key( const gchar *path );
+static GSList *load_subdirs( const gchar *path );
+static void free_subdirs( GSList *list );
+static GSList *load_keys_values( const gchar *path );
+static void free_keys_values( GSList *list );
+static GSList *duplicate_list( GSList *list );
+
+/*
+ * we have to initialize this early in the process as nautilus-actions
+ * will try to load actions before even any NactAction has been created
+ */
+static void
+initialize( void )
+{
+ static const gchar *thisfn = "nact_gconf_initialize";
+ g_debug( "%s", thisfn );
+
+ st_gconf = gconf_client_get_default();
+}
+
+gchar *
+get_object_path( NactStorage *object )
+{
+ g_assert( NACT_IS_STORAGE( object ));
+
+ gchar *id = nact_storage_get_id( object );
+ gchar *path = g_strdup_printf( "%s/%s", NACT_GCONF_CONFIG, id );
+ g_free( id );
+
+ return( path );
+}
+
+/*
+ * Returns a list of the keys which appear as subdirectories
+ *
+ * The returned list contains allocated strings. Each string is the
+ * relative path of a subdirectory. You should g_free() each string
+ * in the list, then g_slist_free() the list itself.
+ */
+static gchar *
+path_to_key( const gchar *path )
+{
+ gchar **split = g_strsplit( path, "/", -1 );
+ guint count = g_strv_length( split );
+ gchar *key = g_strdup( split[count-1] );
+ g_strfreev( split );
+
+ return( key );
+}
+
+GSList *
+load_subdirs( const gchar *path )
+{
+ static const gchar *thisfn = "nact_gconf_load_subdirs";
+ g_debug( "%s: path=%s", thisfn, path );
+
+ if( !st_gconf ){
+ initialize();
+ }
+
+ GError *error = NULL;
+ GSList *list_path = gconf_client_all_dirs( st_gconf, path, &error );
+ if( error ){
+ g_error( "%s: %s", thisfn, error->message );
+ g_error_free( error );
+ return(( GSList * ) NULL );
+ }
+
+ GSList *list_keys = NULL;
+ GSList *item;
+ for( item = list_path ; item != NULL ; item = item->next ){
+ gchar *key = path_to_key(( gchar * ) item->data );
+ list_keys = g_slist_prepend( list_keys, key );
+ }
+
+ free_subdirs( list_path );
+
+ return( list_keys );
+}
+
+/**
+ * Return the list of uuids.
+ *
+ * The list of UUIDs is returned as a GSList of newly allocation strings.
+ * This list should be freed by calling nact_gconf_free_uuids.
+ */
+GSList *
+nact_gconf_load_uuids( void )
+{
+ static const gchar *thisfn = "nact_gconf_load_uuids";
+ g_debug( "%s", thisfn );
+
+ return( load_subdirs( NACT_GCONF_CONFIG ));
+}
+
+static void
+free_subdirs( GSList *list )
+{
+ static const gchar *thisfn = "nact_gconf_free_subdirs";
+ g_debug( "%s: list=%p", thisfn, list );
+
+ GSList *key;
+ for( key = list ; key != NULL ; key = key->next ){
+ g_free(( gchar * ) key->data );
+ }
+
+ g_slist_free( list );
+}
+
+/**
+ * Free a previously allocated list of UUIDs.
+ *
+ * @list: list of UUIDs to be freed.
+ */
+void
+nact_gconf_free_uuids( GSList *list )
+{
+ static const gchar *thisfn = "nact_gconf_free_uuids";
+ g_debug( "%s: list=%p", thisfn, list );
+
+ free_subdirs( list );
+}
+
+/*
+ * Load all the key=value pairs of this key
+ *
+ * The list is not recursive, it contains only the immediate children of
+ * path. To free the returned list, gconf_entry_free() each list element,
+ * then g_slist_free() the list itself.
+ */
+static GSList *
+load_keys_values( const gchar *path )
+{
+ static const gchar *thisfn = "nact_gconf_load_keys_values";
+
+ if( !st_gconf ){
+ initialize();
+ }
+
+ GError *error = NULL;
+ GSList *list_path = gconf_client_all_entries( st_gconf, path, &error );
+ if( error ){
+ g_error( "%s: %s", thisfn, error->message );
+ g_error_free( error );
+ return(( GSList * ) NULL );
+ }
+
+ GSList *list_keys = NULL;
+ GSList *item;
+ for( item = list_path ; item != NULL ; item = item->next ){
+ GConfEntry *entry = ( GConfEntry * ) item->data;
+ gchar *key = path_to_key( gconf_entry_get_key( entry ));
+ GConfEntry *entry_new = gconf_entry_new( key, gconf_entry_get_value( entry ));
+ g_free( key );
+ list_keys = g_slist_prepend( list_keys, entry_new );
+ }
+
+ free_keys_values( list_path );
+
+ return( list_keys );
+}
+
+static void
+free_keys_values( GSList *list )
+{
+ GSList *item;
+ for( item = list ; item != NULL ; item = item->next ){
+ GConfEntry *entry = ( GConfEntry * ) item->data;
+ gconf_entry_unref( entry );
+ }
+ g_slist_free( list );
+}
+
+/*
+ * load the action properties from GConf repository and setup action
+ * instance accordingly
+ */
+gboolean
+nact_gconf_load_action_properties( NactStorage *action )
+{
+ g_object_set( G_OBJECT( action ), "origin", ORIG_GCONF, NULL );
+
+ gchar *path = get_object_path( action );
+
+ g_object_set( G_OBJECT( action ), "gconf-path", path, NULL );
+
+ GSList *list = load_keys_values( path );
+
+ g_free( path );
+
+ if( !list ){
+ return( FALSE );
+ }
+
+ GSList *item;
+ for( item = list ; item != NULL ; item = item->next ){
+ GConfEntry *entry = ( GConfEntry * ) item->data;
+ const char *key = gconf_entry_get_key( entry );
+ GConfValue *value = gconf_entry_get_value( entry );
+ switch( value->type ){
+ case GCONF_VALUE_STRING:
+ g_object_set( G_OBJECT( action ), key, gconf_value_get_string( value ), NULL );
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+ }
+ }
+
+ free_keys_values( list );
+
+ return( TRUE );
+}
+
+GSList *
+nact_gconf_load_profile_names( NactStorage *action )
+{
+ gchar *path = get_object_path( action );
+
+ GSList *list = load_subdirs( path );
+
+ g_free( path );
+
+ return( list );
+}
+
+static GSList *
+duplicate_list( GSList *list )
+{
+ GSList *newlist = NULL;
+ GSList *item;
+ for( item = list ; item != NULL ; item = item->next ){
+ gchar *value = g_strdup(( gchar * ) item->data );
+ g_debug( "duplicate '%s'", value );
+ newlist = g_slist_prepend( newlist, value );
+ }
+ return( newlist );
+}
+
+gboolean
+nact_gconf_load_profile_properties( NactStorage *profile )
+{
+ g_object_set( G_OBJECT( profile ), "origin", ORIG_GCONF, NULL );
+
+ NactStorage *action;
+ g_object_get( G_OBJECT( profile ), "action", &action, NULL );
+ gchar *path_action = get_object_path( action );
+
+ gchar *profile_name;
+ g_object_get( G_OBJECT( profile ), "name", &profile_name, NULL );
+ gchar *profile_path = g_strdup_printf( "%s/%s", path_action, profile_name );
+ g_free( profile_name );
+ g_free( path_action );
+
+ g_object_set( G_OBJECT( profile ), "gconf-path", profile_path, NULL );
+
+ GSList *list = load_keys_values( profile_path );
+
+ g_free( profile_path );
+
+ if( !list ){
+ return( FALSE );
+ }
+
+ GSList *item;
+ for( item = list ; item != NULL ; item = item->next ){
+
+ GConfEntry *entry = ( GConfEntry * ) item->data;
+
+ const char *key = gconf_entry_get_key( entry );
+ GConfValue *value = gconf_entry_get_value( entry );
+
+ switch( value->type ){
+
+ case GCONF_VALUE_STRING:
+ g_object_set( G_OBJECT( profile ), key, gconf_value_get_string( value ), NULL );
+ break;
+
+ case GCONF_VALUE_BOOL:
+ g_object_set( G_OBJECT( profile ), key, gconf_value_get_bool( value ), NULL );
+ break;
+
+ case GCONF_VALUE_LIST:
+ g_object_set( G_OBJECT( profile ), key, duplicate_list( gconf_value_get_list( value )), NULL );
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ free_keys_values( list );
+
+ return( TRUE );
+}
+
+void
+nact_gconf_free_profile_names( GSList *list )
+{
+}
diff --git a/src/common/nact-gconf.h b/src/common/nact-gconf.h
new file mode 100644
index 0000000..c143ac2
--- /dev/null
+++ b/src/common/nact-gconf.h
@@ -0,0 +1,53 @@
+/*
+ * Nautilus Actions
+ * A Nautilus extension which offers configurable context menu actions.
+ *
+ * Copyright (C) 2005 The GNOME Foundation
+ * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+ * Copyright (C) 2009 Pierre Wieser and others (see AUTHORS)
+ *
+ * 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 Library; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Frederic Ruaudel <grumz grumz net>
+ * Rodrigo Moya <rodrigo gnome-db org>
+ * Pierre Wieser <pwieser trychlos org>
+ * ... and many others (see AUTHORS)
+ */
+
+#ifndef __NACT_GCONF_H__
+#define __NACT_GCONF_H__
+
+/*
+ * read/write api for the GCong storage subsystem
+ */
+
+#include <glib.h>
+#include "nact-storage.h"
+
+G_BEGIN_DECLS
+
+GSList *nact_gconf_load_uuids( void );
+gboolean nact_gconf_load_action_properties( NactStorage *action );
+void nact_gconf_free_uuids( GSList *list );
+
+GSList *nact_gconf_load_profile_names( NactStorage *action );
+gboolean nact_gconf_load_profile_properties( NactStorage *profile );
+void nact_gconf_free_profile_names( GSList *list );
+
+G_END_DECLS
+
+#endif /* __NACT_GCONF_H__ */
diff --git a/src/common/nact-storage.c b/src/common/nact-storage.c
new file mode 100644
index 0000000..218bab8
--- /dev/null
+++ b/src/common/nact-storage.c
@@ -0,0 +1,274 @@
+/*
+ * Nautilus Actions
+ * A Nautilus extension which offers configurable context menu actions.
+ *
+ * Copyright (C) 2005 The GNOME Foundation
+ * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+ * Copyright (C) 2009 Pierre Wieser and others (see AUTHORS)
+ *
+ * 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 Library; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Frederic Ruaudel <grumz grumz net>
+ * Rodrigo Moya <rodrigo gnome-db org>
+ * Pierre Wieser <pwieser trychlos org>
+ * ... and many others (see AUTHORS)
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "nact-gconf.h"
+#include "nact-storage.h"
+
+static GObjectClass *st_parent_class = NULL;
+
+static GType register_type( void );
+static void class_init( NactStorageClass *klass );
+static void instance_init( GTypeInstance *instance, gpointer klass );
+static void instance_get_property( GObject *object, guint property_id, GValue *value, GParamSpec *spec );
+static void instance_set_property( GObject *object, guint property_id, const GValue *value, GParamSpec *spec );
+static void instance_dispose( GObject *object );
+static void instance_finalize( GObject *object );
+static void do_dump( const NactStorage *object );
+
+struct NactStoragePrivate {
+ gboolean dispose_has_run;
+ int origin;
+};
+
+struct NactStorageClassPrivate {
+};
+
+enum {
+ PROP_ORIGIN = 1
+};
+
+GType
+nact_storage_get_type( void )
+{
+ static GType object_type = 0;
+
+ if( !object_type ){
+ object_type = register_type();
+ }
+
+ return( object_type );
+}
+
+static GType
+register_type( void )
+{
+ static GTypeInfo info = {
+ sizeof( NactStorageClass ),
+ ( GBaseInitFunc ) NULL,
+ ( GBaseFinalizeFunc ) NULL,
+ ( GClassInitFunc ) class_init,
+ NULL,
+ NULL,
+ sizeof( NactStorage ),
+ 0,
+ ( GInstanceInitFunc ) instance_init
+ };
+
+ return( g_type_register_static( G_TYPE_OBJECT, "NactStorage", &info, 0 ));
+}
+
+static void
+class_init( NactStorageClass *klass )
+{
+ static const gchar *thisfn = "nact_storage_class_init";
+ g_debug( "%s: klass=%p", thisfn, klass );
+
+ GObjectClass *object_class = G_OBJECT_CLASS( klass );
+ object_class->dispose = instance_dispose;
+ object_class->finalize = instance_finalize;
+ object_class->set_property = instance_set_property;
+ object_class->get_property = instance_get_property;
+
+ st_parent_class = g_type_class_peek_parent( klass );
+
+ GParamSpec *spec;
+ spec = g_param_spec_int(
+ "origin",
+ "origin",
+ "Internal identifiant of the storage subsystem", 0, ORIGIN_LAST, 0,
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
+ g_object_class_install_property( object_class, PROP_ORIGIN, spec );
+
+ klass->private = g_new0( NactStorageClassPrivate, 1 );
+
+ klass->do_dump = do_dump;
+}
+
+static void
+instance_init( GTypeInstance *instance, gpointer klass )
+{
+ g_assert( NACT_IS_STORAGE( instance ));
+ NactStorage *self = NACT_STORAGE( instance );
+
+ self->private = g_new0( NactStoragePrivate, 1 );
+
+ self->private->dispose_has_run = FALSE;
+ self->private->origin = 0;
+}
+
+static void
+instance_get_property( GObject *object, guint property_id, GValue *value, GParamSpec *spec )
+{
+ g_assert( NACT_IS_STORAGE( object ));
+ NactStorage *self = NACT_STORAGE( object );
+
+ switch( property_id ){
+ case PROP_ORIGIN:
+ g_value_set_int( value, self->private->origin );
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
+ break;
+ }
+}
+
+static void
+instance_set_property( GObject *object, guint property_id, const GValue *value, GParamSpec *spec )
+{
+ g_assert( NACT_IS_STORAGE( object ));
+ NactStorage *self = NACT_STORAGE( object );
+
+ switch( property_id ){
+ case PROP_ORIGIN:
+ self->private->origin = g_value_get_int( value );
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
+ break;
+ }
+}
+
+static void
+instance_dispose( GObject *object )
+{
+ g_assert( NACT_IS_STORAGE( object ));
+ NactStorage *self = NACT_STORAGE( object );
+
+ if( !self->private->dispose_has_run ){
+
+ self->private->dispose_has_run = TRUE;
+
+ /* chain up to the parent class */
+ G_OBJECT_CLASS( st_parent_class )->dispose( object );
+ }
+}
+
+static void
+instance_finalize( GObject *object )
+{
+ g_assert( NACT_IS_STORAGE( object ));
+ /*NactStorage *self = ( NactStorage * ) object;*/
+
+ /* chain call to parent class */
+ if( st_parent_class->finalize ){
+ G_OBJECT_CLASS( st_parent_class )->finalize( object );
+ }
+}
+
+/**
+ * Returns the id of the object as a newly allocated string.
+ *
+ * This is a pure virtual function, which has to be implemented by
+ * the derived class.
+ *
+ * @object: object whose id is to be returned.
+ *
+ * The returned string has to be g_free by the caller.
+ */
+gchar *
+nact_storage_get_id( const NactStorage *object )
+{
+ g_assert( NACT_IS_STORAGE( object ));
+ return( NACT_STORAGE_GET_CLASS( object )->get_id( object ));
+}
+
+static void
+do_dump( const NactStorage *object )
+{
+ static const char *thisfn = "nact_storage_do_dump";
+
+ g_assert( NACT_IS_STORAGE( object ));
+
+ g_debug( "%s: origin=%d", thisfn, object->private->origin );
+}
+
+/**
+ * Dump the content of the object via g_debug output.
+ *
+ * This is a virtual function which may be implemented by the derived
+ * class ; the derived class may also call its parent class to get a
+ * dump of parent object.
+ *
+ * @object: object to be dumped.
+ */
+void
+nact_storage_dump( const NactStorage *object )
+{
+ g_assert( NACT_IS_STORAGE( object ));
+ NACT_STORAGE_GET_CLASS( object )->do_dump( object );
+}
+
+GSList *
+nact_storage_load_action_ids( void )
+{
+ static const gchar *thisfn = "nact_storage_load_action_ids";
+ g_debug( "%s", thisfn );
+ return( nact_gconf_load_uuids());
+}
+
+gboolean
+nact_storage_load_action_properties( NactStorage *action )
+{
+ g_assert( NACT_IS_STORAGE( action ));
+ return( nact_gconf_load_action_properties( action ));
+}
+
+void
+nact_storage_free_action_ids( GSList *list )
+{
+ static const gchar *thisfn = "nact_storage_free_action_ids";
+ g_debug( "%s: list=%p", thisfn, list );
+ nact_gconf_free_uuids( list );
+}
+
+GSList *
+nact_storage_load_profile_ids( NactStorage *action )
+{
+ g_assert( NACT_IS_STORAGE( action ));
+ return( nact_gconf_load_profile_names( action ));
+}
+
+gboolean
+nact_storage_load_profile_properties( NactStorage *profile )
+{
+ g_assert( NACT_IS_STORAGE( profile ));
+ return( nact_gconf_load_profile_properties( profile ));
+}
+
+void
+nact_storage_free_profile_ids( GSList *list )
+{
+ return( nact_gconf_free_profile_names( list ));
+}
diff --git a/src/common/nact-storage.h b/src/common/nact-storage.h
new file mode 100644
index 0000000..4c50ca5
--- /dev/null
+++ b/src/common/nact-storage.h
@@ -0,0 +1,102 @@
+/*
+ * Nautilus Actions
+ * A Nautilus extension which offers configurable context menu actions.
+ *
+ * Copyright (C) 2005 The GNOME Foundation
+ * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+ * Copyright (C) 2009 Pierre Wieser and others (see AUTHORS)
+ *
+ * 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 Library; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Frederic Ruaudel <grumz grumz net>
+ * Rodrigo Moya <rodrigo gnome-db org>
+ * Pierre Wieser <pwieser trychlos org>
+ * ... and many others (see AUTHORS)
+ */
+
+#ifndef __NACT_STORAGE_H__
+#define __NACT_STORAGE_H__
+
+/*
+ * NactStorage class definition.
+ *
+ * This is the NactAction base class.
+ *
+ * It takes care of storage subsystems management.
+ *
+ * For now, Gconf storage subsystem is implemented by calling directly
+ * ad-hoc functions of nact-gconf.c source.
+ *
+ * In a near or far future, storage subsystems may be extended by
+ * creating extension libraries, this class loading the modules at
+ * startup time (e.g. on the model of provider interfaces in Nautilus).
+ */
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/* identifiers for various storage subsystems */
+enum {
+ ORIG_GCONF = 1,
+ ORIGIN_LAST
+};
+
+#define NACT_STORAGE_TYPE ( nact_storage_get_type())
+#define NACT_STORAGE( object ) ( G_TYPE_CHECK_INSTANCE_CAST( object, NACT_STORAGE_TYPE, NactStorage ))
+#define NACT_STORAGE_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( klass, NACT_STORAGE_TYPE, NactStorageClass ))
+#define NACT_IS_STORAGE( object ) ( G_TYPE_CHECK_INSTANCE_TYPE( object, NACT_STORAGE_TYPE ))
+#define NACT_IS_STORAGE_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE(( klass ), NACT_STORAGE_TYPE ))
+#define NACT_STORAGE_GET_CLASS( object ) ( G_TYPE_INSTANCE_GET_CLASS(( object ), NACT_STORAGE_TYPE, NactStorageClass ))
+
+typedef struct NactStoragePrivate NactStoragePrivate;
+
+typedef struct {
+ GObject parent;
+ NactStoragePrivate *private;
+}
+ NactStorage;
+
+typedef struct NactStorageClassPrivate NactStorageClassPrivate;
+
+typedef struct {
+ GObjectClass parent;
+ NactStorageClassPrivate *private;
+
+ /* virtual public functions */
+ void ( *do_dump )( const NactStorage *object );
+ gchar * ( *get_id )( const NactStorage *object );
+}
+ NactStorageClass;
+
+GType nact_storage_get_type( void );
+
+gchar *nact_storage_get_id( const NactStorage *object );
+
+void nact_storage_dump( const NactStorage *object );
+
+GSList *nact_storage_load_action_ids( void );
+gboolean nact_storage_load_action_properties( NactStorage *action );
+void nact_storage_free_action_ids( GSList *list );
+
+GSList *nact_storage_load_profile_ids( NactStorage *action );
+gboolean nact_storage_load_profile_properties( NactStorage *profile );
+void nact_storage_free_profile_ids( GSList *list );
+
+G_END_DECLS
+
+#endif /* __NACT_STORAGE_H__ */
diff --git a/src/plugin/nautilus-actions.c b/src/plugin/nautilus-actions.c
index 4383c50..9f383c2 100644
--- a/src/plugin/nautilus-actions.c
+++ b/src/plugin/nautilus-actions.c
@@ -380,7 +380,7 @@ get_background_items( NautilusMenuProvider *provider, GtkWidget *window, Nautilu
g_debug( "%s: provider=%p, window=%p, current_folder=%p (%s)", thisfn, provider, window, current_folder, uri );
g_free( uri );
#endif
- return(( GSList * ) NULL );
+ return(( GList * ) NULL );
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]