[nautilus-actions: 5/30] Move NAIIOProvider interface to api/
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions: 5/30] Move NAIIOProvider interface to api/
- Date: Sat, 21 Nov 2009 18:01:40 +0000 (UTC)
commit 511e280284db7e373e14cc5951097b7fc43b33bf
Author: Pierre Wieser <pwieser trychlos org>
Date: Wed Nov 18 00:51:26 2009 +0100
Move NAIIOProvider interface to api/
Introducing runtime/na-io-provider.{c,h} to handle internal API to NAIIOProvider interface.
ChangeLog | 32 ++
nautilus-actions/api/Makefile.am | 3 +
nautilus-actions/api/na-api.h | 2 +-
nautilus-actions/api/na-gconf-keys.h | 2 +-
nautilus-actions/api/na-iio-provider.c | 153 ++++++++++
.../{runtime => api}/na-iio-provider.h | 82 +++---
nautilus-actions/common/Makefile.am | 1 +
nautilus-actions/nact/Makefile.am | 4 +-
nautilus-actions/nact/nact-assistant-import.c | 1 -
nautilus-actions/nact/nact-main-window.c | 1 -
nautilus-actions/nact/nact-window.c | 28 +-
nautilus-actions/nact/nact-window.h | 2 +-
nautilus-actions/plugin/Makefile.am | 1 +
nautilus-actions/runtime/Makefile.am | 5 +-
nautilus-actions/runtime/na-gconf-provider.c | 150 +++++-----
.../{na-iio-provider.c => na-io-provider.c} | 307 ++++++-------------
nautilus-actions/runtime/na-io-provider.h | 57 ++++
nautilus-actions/runtime/na-module.c | 7 +-
nautilus-actions/runtime/na-module.h | 2 +-
nautilus-actions/runtime/na-object-item-fn.h | 3 +-
nautilus-actions/runtime/na-pivot.c | 51 +++-
nautilus-actions/runtime/na-pivot.h | 5 +-
nautilus-actions/test/Makefile.am | 4 +-
nautilus-actions/utils/Makefile.am | 7 +-
nautilus-actions/utils/nautilus-actions-new.c | 12 +-
25 files changed, 553 insertions(+), 369 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7ccd111..8b6a72d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,42 @@
2009-11-17 Pierre Wieser <pwieser trychlos org>
+ Move NAIIOProvider interface to api/.
+
+ * nautilus-actions/api/na-api.h:
+ * nautilus-actions/api/na-gconf-keys.h: Fix doc typo.
+
+ * nautilus-actions/nact/nact-assistant-import.c:
+ * nautilus-actions/nact/nact-main-window.c:
+ * nautilus-actions/nact/nact-window.c:
+ * nautilus-actions/nact/nact-window.h:
+ * nautilus-actions/runtime/na-gconf-provider.c:
+ * nautilus-actions/runtime/na-object-item-fn.h:
+ * nautilus-actions/runtime/na-pivot.c:
+ * nautilus-actions/runtime/na-pivot.h:
+ * nautilus-actions/utils/nautilus-actions-new.c: Updated accordingly,
+ modifying path to headers,
+ fixing calls to NAIIOProvider interface.
+
+ * nautilus-actions/runtime/na-module.c:
+ * nautilus-actions/runtime/na-module.h: Fix typo.
+
+ * nautilus-actions/api/Makefile.am:
+ * nautilus-actions/common/Makefile.am:
+ * nautilus-actions/nact/Makefile.am:
+ * nautilus-actions/plugin/Makefile.am:
+ * nautilus-actions/runtime/Makefile.am:
+ * nautilus-actions/test/Makefile.am:
+ * nautilus-actions/utils/Makefile.am: Updated accordingly,
+ adding -I $(top_srcdir),
+ adding -L$(top_builddir)/nautilus-actions/api -lna-api.
+
Dynamically loads Nautilus-Actions extensions.
* nautilus-actions/runtime/na-module.c:
* nautilus-actions/runtime/na-module.h: New files.
+ * nautilus-actions/runtime/na-pivot.c: Load modules.
+
* nautilus-actions/runtime/Makefile.am: Updated accordingly.
Make libna-runtime a dynamically loaded library.
diff --git a/nautilus-actions/api/Makefile.am b/nautilus-actions/api/Makefile.am
index 83f8e4c..7315414 100644
--- a/nautilus-actions/api/Makefile.am
+++ b/nautilus-actions/api/Makefile.am
@@ -29,6 +29,7 @@
pkglib_LTLIBRARIES=libna-api.la
AM_CPPFLAGS += \
+ -I $(top_srcdir) \
$(NAUTILUS_ACTIONS_CFLAGS) \
-DG_LOG_DOMAIN=\"${NA_LOGDOMAIN_API}\" \
$(NULL)
@@ -38,9 +39,11 @@ libna_api_includedir = $(pkgincludedir)/api
libna_api_include_HEADERS = \
na-api.h \
na-gconf-keys.h \
+ na-iio-provider.h \
$(NULL)
libna_api_la_SOURCES = \
+ na-iio-provider.c \
$(NULL)
libna_api_la_LIBADD = \
diff --git a/nautilus-actions/api/na-api.h b/nautilus-actions/api/na-api.h
index d881d58..5c6fb84 100644
--- a/nautilus-actions/api/na-api.h
+++ b/nautilus-actions/api/na-api.h
@@ -34,7 +34,7 @@
/**
* SECTION: na_api
* @short_description: #NAAPI interface definition.
- * @include: api/na-api.h
+ * @include: nautilus-actions/api/na-api.h
*
* These are common functions a Nautilus-Actions extension should
* implement in order to be dynamically registered and identified.
diff --git a/nautilus-actions/api/na-gconf-keys.h b/nautilus-actions/api/na-gconf-keys.h
index dd74c10..db04984 100644
--- a/nautilus-actions/api/na-gconf-keys.h
+++ b/nautilus-actions/api/na-gconf-keys.h
@@ -34,7 +34,7 @@
/**
* SECTION: na_gconf
* @short_description: GConf general information.
- * @include: nautilus-actions/na-gconf-keys.h
+ * @include: nautilus-actions/api/na-gconf-keys.h
*
* These keys are used both:
* - by GConf as a NAIIOProvider
diff --git a/nautilus-actions/api/na-iio-provider.c b/nautilus-actions/api/na-iio-provider.c
new file mode 100644
index 0000000..d566ba8
--- /dev/null
+++ b/nautilus-actions/api/na-iio-provider.c
@@ -0,0 +1,153 @@
+/*
+ * 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 "na-iio-provider.h"
+
+/* private interface data
+ */
+struct NAIIOProviderInterfacePrivate {
+ void *empty; /* so that gcc -pedantic is happy */
+};
+
+static gboolean st_initialized = FALSE;
+static gboolean st_finalized = FALSE;
+
+static GType register_type( void );
+static void interface_base_init( NAIIOProviderInterface *klass );
+static void interface_base_finalize( NAIIOProviderInterface *klass );
+
+static gboolean do_is_willing_to_write( const NAIIOProvider *instance );
+static gboolean do_is_writable( const NAIIOProvider *instance, const NAObjectItem *item );
+
+/**
+ * Registers the GType of this interface.
+ */
+GType
+na_iio_provider_get_type( void )
+{
+ static GType object_type = 0;
+
+ if( !object_type ){
+ object_type = register_type();
+ }
+
+ return( object_type );
+}
+
+static GType
+register_type( void )
+{
+ static const gchar *thisfn = "na_iio_provider_register_type";
+ GType type;
+
+ static const GTypeInfo info = {
+ sizeof( NAIIOProviderInterface ),
+ ( GBaseInitFunc ) interface_base_init,
+ ( GBaseFinalizeFunc ) interface_base_finalize,
+ NULL,
+ NULL,
+ NULL,
+ 0,
+ 0,
+ NULL
+ };
+
+ g_debug( "%s", thisfn );
+
+ type = g_type_register_static( G_TYPE_INTERFACE, "NAIIOProvider", &info, 0 );
+
+ g_type_interface_add_prerequisite( type, G_TYPE_OBJECT );
+
+ return( type );
+}
+
+static void
+interface_base_init( NAIIOProviderInterface *klass )
+{
+ static const gchar *thisfn = "na_iio_provider_interface_base_init";
+
+ if( !st_initialized ){
+ g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
+
+ klass->private = g_new0( NAIIOProviderInterfacePrivate, 1 );
+
+ klass->read_items = NULL;
+ klass->is_willing_to_write = do_is_willing_to_write;
+ klass->is_writable = do_is_writable;
+ klass->write_item = NULL;
+ klass->delete_item = NULL;
+
+ st_initialized = TRUE;
+ }
+}
+
+static void
+interface_base_finalize( NAIIOProviderInterface *klass )
+{
+ static const gchar *thisfn = "na_iio_provider_interface_base_finalize";
+
+ if( !st_finalized ){
+
+ st_finalized = TRUE;
+
+ g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
+
+ g_free( klass->private );
+ }
+}
+
+static gboolean
+do_is_willing_to_write( const NAIIOProvider *instance )
+{
+ return( FALSE );
+}
+
+static gboolean
+do_is_writable( const NAIIOProvider *instance, const NAObjectItem *item )
+{
+ return( FALSE );
+}
+
+/**
+ * na_iio_provider_config_changed:
+ * @instance: the calling NAIIOProvider.
+ *
+ * Advertises Nautilus-Actions that this #NAIIOProvider @instance has
+ * detected a modification in one of its configurations (menu or action).
+ */
+void
+na_iio_provider_config_changed( const NAIIOProvider *instance )
+{
+
+}
diff --git a/nautilus-actions/runtime/na-iio-provider.h b/nautilus-actions/api/na-iio-provider.h
similarity index 61%
rename from nautilus-actions/runtime/na-iio-provider.h
rename to nautilus-actions/api/na-iio-provider.h
index fc0907b..7ebf11a 100644
--- a/nautilus-actions/runtime/na-iio-provider.h
+++ b/nautilus-actions/api/na-iio-provider.h
@@ -28,23 +28,19 @@
* ... and many others (see AUTHORS)
*/
-#ifndef __NA_RUNTIME_IIO_PROVIDER_H__
-#define __NA_RUNTIME_IIO_PROVIDER_H__
+#ifndef __NAUTILUS_ACTIONS_NA_IIO_PROVIDER_H__
+#define __NAUTILUS_ACTIONS_NA_IIO_PROVIDER_H__
/**
* SECTION: na_iio_provider
* @short_description: #NAIIOProvider interface definition.
- * @include: runtime/na-iio-provider.h
+ * @include: nautilus-actions/api/na-iio-provider.h
*
- * This is the API all storage subsystems should implement in order to
- * provide I/O resources to NautilusActions.
- *
- * In a near or far future, provider 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).
+ * This is the API all I/O Providers should implement in order to
+ * provide I/O storage resources to Nautilus-Actions.
*/
-#include "na-pivot.h"
+#include <nautilus-actions/runtime/na-object-item-class.h>
G_BEGIN_DECLS
@@ -61,16 +57,23 @@ typedef struct {
GTypeInterface parent;
NAIIOProviderInterfacePrivate *private;
+ /*
+ * This is the API the provider has to implement.
+ */
+
/**
- * read_items_list:
+ * read_items:
* @instance: the #NAIIOProvider provider.
+ * @messages: a pointer to a #GSList which has been initialized to
+ * NULL before calling this function ; the provider may append error
+ * messages to this list, but shouldn't reinitialize it.
*
* Reads the whole items list from the specified I/O provider.
*
- * Returns: a unordered #GSList of menus, actions and
- * profiles as #NAObject-derived objects.
+ * Returns: a unordered flat #GList of NAObjectItem-derived objects
+ * (menus or actions) ; the actions embed their own profiles.
*/
- GList * ( *read_items_list ) ( const NAIIOProvider *instance );
+ GList * ( *read_items ) ( const NAIIOProvider *instance, GSList **messages );
/**
* is_willing_to_write:
@@ -78,8 +81,8 @@ typedef struct {
*
* Checks for global writability of the I/O provider.
*
- * Returns: %TRUE if we are able to update/write/delete a #NAAction
- * into this I/O provider, %FALSE else.
+ * Returns: %TRUE if we are able to update/write/delete a #NAObjectItem
+ * (menu or action) into this I/O provider, %FALSE else.
*
* Note that the I/O provider may return a positive writability
* flag when considering the whole I/O storage subsystem, while not
@@ -90,54 +93,59 @@ typedef struct {
/**
* is_writable:
* @instance: the #NAIIOProvider provider.
- * @item: a #NAObject action or menu.
+ * @item: a #NAObjectItem-derived menu or action.
*
* Checks for writability of this particular @item.
*
* Returns: %TRUE if we are able to update/write/delete the
* @item, %FALSE else.
*/
- gboolean ( *is_writable ) ( const NAIIOProvider *instance, const NAObject *item );
+ gboolean ( *is_writable ) ( const NAIIOProvider *instance, const NAObjectItem *item );
/**
- * write_tree_item:
+ * write_item:
* @instance: the #NAIIOProvider provider.
- * @item: a #NAObject to be written.
- * @message: warning/error messages detected in the operation.
+ * @item: a #NAObjectItem-derived menu or action.
+ * @messages: a pointer to a #GSList which has been initialized to
+ * NULL before calling this function ; the provider may append error
+ * messages to this list, but shouldn't reinitialize it.
*
- * Updates an existing @item or writes a new one.
+ * Writes a new @item.
*
- * Returns: %NA_IIO_PROVIDER_WRITE_OK if the update/write operation
+ * Returns: %NA_IIO_PROVIDER_WRITE_OK if the write operation
* was successfull, or another code depending of the detected error.
+ *
+ * Note: there is no update_item function ; it is the responsability
+ * of the provider to delete the previous version of an item before
+ * writing the new version.
*/
- guint ( *write_item ) ( const NAIIOProvider *instance, NAObject *item, gchar **message );
+ guint ( *write_item ) ( const NAIIOProvider *instance, const NAObjectItem *item, GSList **messages );
/**
- * delete_tree_item:
+ * delete_item:
* @instance: the #NAIIOProvider provider.
- * @item: a #NAObject to be deleted.
- * @message: warning/error messages detected in the operation.
+ * @item: a #NAObjectItem-derived menu or action.
+ * @messages: a pointer to a #GSList which has been initialized to
+ * NULL before calling this function ; the provider may append error
+ * messages to this list, but shouldn't reinitialize it.
*
* Deletes an existing @item from the I/O subsystem.
*
* Returns: %NA_IIO_PROVIDER_WRITE_OK if the delete operation was
* successfull, or another code depending of the detected error.
*/
- guint ( *delete_item ) ( const NAIIOProvider *instance, const NAObject *item, gchar **message );
+ guint ( *delete_item ) ( const NAIIOProvider *instance, const NAObjectItem *item, GSList **messages );
}
NAIIOProviderInterface;
-GType na_iio_provider_get_type( void );
-
-GList *na_iio_provider_get_items_tree( const NAPivot *pivot );
-guint na_iio_provider_write_item( const NAPivot *pivot, NAObject *item, gchar **message );
-guint na_iio_provider_delete_item( const NAPivot *pivot, const NAObject *item, gchar **message );
+GType na_iio_provider_get_type ( void );
-/* notification message to NAPivot
+/* This function is to be called by the I/O provider when it detects a
+ * modification of one of its objects in its underlying storage subsystem.
*/
-#define NA_IIO_PROVIDER_SIGNAL_ACTION_CHANGED "notify-consumer-of-action-change"
+void na_iio_provider_config_changed ( const NAIIOProvider *instance );
-/* return code of update/write/delete operations
+/* return code of write/delete operations
*/
enum {
NA_IIO_PROVIDER_WRITE_OK = 0,
@@ -150,4 +158,4 @@ enum {
G_END_DECLS
-#endif /* __NA_RUNTIME_IIO_PROVIDER_H__ */
+#endif /* __NAUTILUS_ACTIONS_NA_IIO_PROVIDER_H__ */
diff --git a/nautilus-actions/common/Makefile.am b/nautilus-actions/common/Makefile.am
index bcabf6a..84ceac0 100644
--- a/nautilus-actions/common/Makefile.am
+++ b/nautilus-actions/common/Makefile.am
@@ -29,6 +29,7 @@
noinst_LTLIBRARIES = libna-common.la
AM_CPPFLAGS += \
+ -I $(top_srcdir) \
-I $(top_srcdir)/nautilus-actions \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DG_LOG_DOMAIN=\"${NA_LOGDOMAIN_COMMON}\" \
diff --git a/nautilus-actions/nact/Makefile.am b/nautilus-actions/nact/Makefile.am
index a5b037f..21cb09f 100644
--- a/nautilus-actions/nact/Makefile.am
+++ b/nautilus-actions/nact/Makefile.am
@@ -31,6 +31,7 @@ bin_PROGRAMS = \
$(NULL)
AM_CPPFLAGS += \
+ -I $(top_srcdir) \
-I $(top_srcdir)/nautilus-actions \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DPKGDATADIR=\"$(pkgdatadir)\" \
@@ -113,7 +114,8 @@ nact-marshal.c: nact-marshal.list $(GLIB_GENMARSHAL)
nautilus_actions_config_tool_LDADD = \
$(top_builddir)/nautilus-actions/common/libna-common.la \
- -L$(top_builddir)/nautilus-actions/runtime -lna-runtime \
+ -L$(top_builddir)/nautilus-actions/api -lna-api \
+ -L$(top_builddir)/nautilus-actions/runtime -lna-runtime \
$(NAUTILUS_ACTIONS_LIBS) \
$(NULL)
diff --git a/nautilus-actions/nact/nact-assistant-import.c b/nautilus-actions/nact/nact-assistant-import.c
index 5d78b42..9ebd181 100644
--- a/nautilus-actions/nact/nact-assistant-import.c
+++ b/nautilus-actions/nact/nact-assistant-import.c
@@ -37,7 +37,6 @@
#include <gtk/gtk.h>
#include <string.h>
-#include <runtime/na-iio-provider.h>
#include <runtime/na-pivot.h>
#include <common/na-object-api.h>
diff --git a/nautilus-actions/nact/nact-main-window.c b/nautilus-actions/nact/nact-main-window.c
index c67ca6f..360cd86 100644
--- a/nautilus-actions/nact/nact-main-window.c
+++ b/nautilus-actions/nact/nact-main-window.c
@@ -39,7 +39,6 @@
#include <runtime/na-pivot.h>
#include <runtime/na-iabout.h>
-#include <runtime/na-iio-provider.h>
#include <runtime/na-ipivot-consumer.h>
#include <common/na-object-api.h>
diff --git a/nautilus-actions/nact/nact-window.c b/nautilus-actions/nact/nact-window.c
index 1da7d29..e1a2f7d 100644
--- a/nautilus-actions/nact/nact-window.c
+++ b/nautilus-actions/nact/nact-window.c
@@ -35,7 +35,7 @@
#include <glib.h>
#include <glib/gi18n.h>
-#include <runtime/na-iio-provider.h>
+#include <api/na-iio-provider.h>
#include <common/na-object-api.h>
#include <common/na-iprefs.h>
@@ -214,7 +214,7 @@ nact_window_save_item( NactWindow *window, NAObjectItem *item )
static const gchar *thisfn = "nact_window_save_item";
gboolean save_ok = FALSE;
NAPivot *pivot;
- gchar *msg = NULL;
+ GSList *messages = NULL;
guint ret;
g_debug( "%s: window=%p, item=%p (%s)", thisfn,
@@ -229,13 +229,15 @@ nact_window_save_item( NactWindow *window, NAObjectItem *item )
na_object_dump( item );
- ret = na_pivot_write_item( pivot, NA_OBJECT( item ), &msg );
+ ret = na_pivot_write_item( pivot, item, &messages );
- if( msg ){
+ if( messages ){
base_window_error_dlg(
BASE_WINDOW( window ),
- GTK_MESSAGE_WARNING, _( "An error has occured when trying to save the item" ), msg );
- g_free( msg );
+ GTK_MESSAGE_WARNING,
+ _( "An error has occured when trying to save the item" ),
+ ( const gchar * ) messages->data );
+ na_utils_free_string_list( messages );
}
save_ok = ( ret == NA_IIO_PROVIDER_WRITE_OK );
@@ -252,12 +254,12 @@ nact_window_save_item( NactWindow *window, NAObjectItem *item )
* Deleted an item from the I/O storage subsystem.
*/
gboolean
-nact_window_delete_item( NactWindow *window, NAObjectItem *item )
+nact_window_delete_item( NactWindow *window, const NAObjectItem *item )
{
static const gchar *thisfn = "nact_window_delete_item";
gboolean delete_ok = FALSE;
NAPivot *pivot;
- gchar *msg = NULL;
+ GSList *messages = NULL;
guint ret;
g_debug( "%s: window=%p, item=%p (%s)", thisfn,
@@ -272,13 +274,15 @@ nact_window_delete_item( NactWindow *window, NAObjectItem *item )
na_object_dump_norec( item );
- ret = na_pivot_delete_item( pivot, NA_OBJECT( item ), &msg );
+ ret = na_pivot_delete_item( pivot, item, &messages );
- if( msg ){
+ if( messages ){
base_window_error_dlg(
BASE_WINDOW( window ),
- GTK_MESSAGE_WARNING, _( "An error has occured when trying to delete the item" ), msg );
- g_free( msg );
+ GTK_MESSAGE_WARNING,
+ _( "An error has occured when trying to delete the item" ),
+ ( const gchar * ) messages->data );
+ na_utils_free_string_list( messages );
}
delete_ok = ( ret == NA_IIO_PROVIDER_WRITE_OK );
diff --git a/nautilus-actions/nact/nact-window.h b/nautilus-actions/nact/nact-window.h
index 91a4c6d..067ef8a 100644
--- a/nautilus-actions/nact/nact-window.h
+++ b/nautilus-actions/nact/nact-window.h
@@ -75,7 +75,7 @@ GType nact_window_get_type( void );
NAPivot *nact_window_get_pivot( NactWindow *window );
gboolean nact_window_save_item( NactWindow *window, NAObjectItem *item );
-gboolean nact_window_delete_item( NactWindow *window, NAObjectItem *item );
+gboolean nact_window_delete_item( NactWindow *window, const NAObjectItem *item );
void nact_window_count_level_zero_items( GList *items, guint *actions, guint *profiles, guint *menus );
diff --git a/nautilus-actions/plugin/Makefile.am b/nautilus-actions/plugin/Makefile.am
index dfa14fc..0253fa0 100644
--- a/nautilus-actions/plugin/Makefile.am
+++ b/nautilus-actions/plugin/Makefile.am
@@ -27,6 +27,7 @@
# ... and many others (see AUTHORS)
AM_CPPFLAGS += \
+ -I $(top_srcdir) \
-I $(top_srcdir)/nautilus-actions \
-DG_LOG_DOMAIN=\"${NA_LOGDOMAIN_PLUGIN}\" \
$(NAUTILUS_ACTIONS_CFLAGS) \
diff --git a/nautilus-actions/runtime/Makefile.am b/nautilus-actions/runtime/Makefile.am
index b97e7a7..a2f8e68 100644
--- a/nautilus-actions/runtime/Makefile.am
+++ b/nautilus-actions/runtime/Makefile.am
@@ -29,6 +29,7 @@
pkglib_LTLIBRARIES = libna-runtime.la
AM_CPPFLAGS += \
+ -I $(top_srcdir) \
-DPKGLIBDIR=\""$(pkglibdir)"\" \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DG_LOG_DOMAIN=\"${NA_LOGDOMAIN_RUNTIME}\" \
@@ -50,8 +51,8 @@ libna_runtime_la_SOURCES = \
na-iabout.h \
na-iduplicable.c \
na-iduplicable.h \
- na-iio-provider.c \
- na-iio-provider.h \
+ na-io-provider.c \
+ na-io-provider.h \
na-ipivot-consumer.c \
na-ipivot-consumer.h \
na-iprefs.c \
diff --git a/nautilus-actions/runtime/na-gconf-provider.c b/nautilus-actions/runtime/na-gconf-provider.c
index 4a5e69c..a0be710 100644
--- a/nautilus-actions/runtime/na-gconf-provider.c
+++ b/nautilus-actions/runtime/na-gconf-provider.c
@@ -39,7 +39,6 @@
#include "na-gconf-provider.h"
#include "na-gconf-provider-keys.h"
#include "na-gconf-utils.h"
-#include "na-iio-provider.h"
#include "na-utils.h"
/* private class data
@@ -70,7 +69,7 @@ static void install_monitors( NAGConfProvider *provider );
static void config_path_changed_cb( GConfClient *client, guint cnxn_id, GConfEntry *entry, NAGConfProvider *provider );
static NAPivotNotify *entry_to_notify( const GConfEntry *entry );
-static GList *iio_provider_read_items_list( const NAIIOProvider *provider );
+static GList *iio_provider_read_items( const NAIIOProvider *provider, GSList **messages );
static NAObjectItem *read_item( NAGConfProvider *provider, const gchar *path );
static void read_item_action( NAGConfProvider *provider, const gchar *path, NAObjectAction *action );
static void read_item_action_properties( NAGConfProvider *provider, GSList *entries, NAObjectAction *action );
@@ -83,20 +82,20 @@ static void read_object_item_properties( NAGConfProvider *provider, GS
static gboolean iio_provider_is_willing_to_write( const NAIIOProvider *provider );
-static gboolean iio_provider_is_writable( const NAIIOProvider *provider, const NAObject *item );
+static gboolean iio_provider_is_writable( const NAIIOProvider *provider, const NAObjectItem *item );
-static guint iio_provider_write_item( const NAIIOProvider *provider, NAObject *item, gchar **message );
-static gboolean write_item_action( NAGConfProvider *gconf, const NAObjectAction *action, gchar **message );
-static gboolean write_item_menu( NAGConfProvider *gconf, const NAObjectMenu *menu, gchar **message );
-static gboolean write_object_item( NAGConfProvider *gconf, const NAObjectItem *item, gchar **message );
+static guint iio_provider_write_item( const NAIIOProvider *provider, const NAObjectItem *item, GSList **messages );
+static gboolean write_item_action( NAGConfProvider *gconf, const NAObjectAction *action, GSList **messages );
+static gboolean write_item_menu( NAGConfProvider *gconf, const NAObjectMenu *menu, GSList **messages );
+static gboolean write_object_item( NAGConfProvider *gconf, const NAObjectItem *item, GSList **messages );
-static guint iio_provider_delete_item( const NAIIOProvider *provider, const NAObject *item, gchar **message );
+static guint iio_provider_delete_item( const NAIIOProvider *provider, const NAObjectItem *item, GSList **messages );
static gboolean key_is_writable( NAGConfProvider *gconf, const gchar *path );
-static gboolean write_str( NAGConfProvider *gconf, const gchar *uuid, const gchar *name, const gchar *key, gchar *value, gchar **message );
-static gboolean write_bool( NAGConfProvider *gconf, const gchar *uuid, const gchar *name, const gchar *key, gboolean value, gchar **message );
-static gboolean write_list( NAGConfProvider *gconf, const gchar *uuid, const gchar *name, const gchar *key, GSList *value, gchar **message );
+static gboolean write_str( NAGConfProvider *gconf, const gchar *uuid, const gchar *name, const gchar *key, gchar *value, GSList **messages );
+static gboolean write_bool( NAGConfProvider *gconf, const gchar *uuid, const gchar *name, const gchar *key, gboolean value, GSList **messages );
+static gboolean write_list( NAGConfProvider *gconf, const gchar *uuid, const gchar *name, const gchar *key, GSList *value, GSList **messages );
GType
na_gconf_provider_get_type( void )
@@ -167,7 +166,7 @@ iio_provider_iface_init( NAIIOProviderInterface *iface )
g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
- iface->read_items_list = iio_provider_read_items_list;
+ iface->read_items = iio_provider_read_items;
iface->is_willing_to_write = iio_provider_is_willing_to_write;
iface->is_writable = iio_provider_is_writable;
iface->write_item = iio_provider_write_item;
@@ -328,7 +327,8 @@ config_path_changed_cb( GConfClient *client, guint cnxn_id, GConfEntry *entry, N
if( !provider->private->dispose_has_run ){
npn = entry_to_notify( entry );
- g_signal_emit_by_name( provider->private->pivot, NA_IIO_PROVIDER_SIGNAL_ACTION_CHANGED, npn );
+ /*g_signal_emit_by_name( provider->private->pivot, NA_IIO_PROVIDER_SIGNAL_ACTION_CHANGED, npn );*/
+ na_iio_provider_config_changed( NA_IIO_PROVIDER( provider ));
}
}
@@ -428,15 +428,15 @@ entry_to_notify( const GConfEntry *entry )
* latest, version of these classes.
*/
static GList *
-iio_provider_read_items_list( const NAIIOProvider *provider )
+iio_provider_read_items( const NAIIOProvider *provider, GSList **messages )
{
- static const gchar *thisfn = "na_gconf_provider_iio_provider_read_items_list";
+ static const gchar *thisfn = "na_gconf_provider_iio_provider_read_items";
NAGConfProvider *self;
GList *items_list = NULL;
GSList *listpath, *ip;
NAObjectItem *item;
- g_debug( "%s: provider=%p", thisfn, ( void * ) provider );
+ g_debug( "%s: provider=%p, messages=%p", thisfn, ( void * ) provider, ( void * ) messages );
g_return_val_if_fail( NA_IS_IIO_PROVIDER( provider ), NULL );
g_return_val_if_fail( NA_IS_GCONF_PROVIDER( provider ), NULL );
@@ -814,7 +814,7 @@ iio_provider_is_willing_to_write( const NAIIOProvider *provider )
}
static gboolean
-iio_provider_is_writable( const NAIIOProvider *provider, const NAObject *item )
+iio_provider_is_writable( const NAIIOProvider *provider, const NAObjectItem *item )
{
NAGConfProvider *self;
gboolean willing_to = FALSE;
@@ -833,49 +833,43 @@ iio_provider_is_writable( const NAIIOProvider *provider, const NAObject *item )
}
static guint
-iio_provider_write_item( const NAIIOProvider *provider, NAObject *item, gchar **message )
+iio_provider_write_item( const NAIIOProvider *provider, const NAObjectItem *item, GSList **messages )
{
static const gchar *thisfn = "na_gconf_provider_iio_provider_write_item";
NAGConfProvider *self;
- g_debug( "%s: provider=%p, item=%p (%s), message=%p",
+ g_debug( "%s: provider=%p, item=%p (%s), messages=%p",
thisfn, ( void * ) provider,
- ( void * ) item, G_OBJECT_TYPE_NAME( item ), ( void * ) message );
+ ( void * ) item, G_OBJECT_TYPE_NAME( item ), ( void * ) messages );
g_return_val_if_fail( NA_IS_GCONF_PROVIDER( provider ), NA_IIO_PROVIDER_PROGRAM_ERROR );
g_return_val_if_fail( NA_IS_IIO_PROVIDER( provider ), NA_IIO_PROVIDER_PROGRAM_ERROR );
g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), NA_IIO_PROVIDER_PROGRAM_ERROR );
self = NA_GCONF_PROVIDER( provider );
- if( message ){
- *message = NULL;
- }
-
if( self->private->dispose_has_run ){
return( NA_IIO_PROVIDER_NOT_WILLING_TO_WRITE );
}
if( NA_IS_OBJECT_ACTION( item )){
- if( !write_item_action( self, NA_OBJECT_ACTION( item ), message )){
+ if( !write_item_action( self, NA_OBJECT_ACTION( item ), messages )){
return( NA_IIO_PROVIDER_WRITE_ERROR );
}
}
if( NA_IS_OBJECT_MENU( item )){
- if( !write_item_menu( self, NA_OBJECT_MENU( item ), message )){
+ if( !write_item_menu( self, NA_OBJECT_MENU( item ), messages )){
return( NA_IIO_PROVIDER_WRITE_ERROR );
}
}
gconf_client_suggest_sync( self->private->gconf, NULL );
- na_object_set_provider( item, provider );
-
return( NA_IIO_PROVIDER_WRITE_OK );
}
static gboolean
-write_item_action( NAGConfProvider *provider, const NAObjectAction *action, gchar **message )
+write_item_action( NAGConfProvider *provider, const NAObjectAction *action, GSList **messages )
{
gchar *uuid, *name;
gboolean ret;
@@ -885,14 +879,14 @@ write_item_action( NAGConfProvider *provider, const NAObjectAction *action, gcha
uuid = na_object_get_id( action );
ret =
- write_object_item( provider, NA_OBJECT_ITEM( action ), message ) &&
- write_str( provider, uuid, NULL, ACTION_VERSION_ENTRY, na_object_action_get_version( action ), message ) &&
- write_bool( provider, uuid, NULL, OBJECT_ITEM_TARGET_SELECTION_ENTRY, na_object_action_is_target_selection( action ), message ) &&
- write_bool( provider, uuid, NULL, OBJECT_ITEM_TARGET_BACKGROUND_ENTRY, na_object_action_is_target_background( action ), message ) &&
- write_bool( provider, uuid, NULL, OBJECT_ITEM_TARGET_TOOLBAR_ENTRY, na_object_action_is_target_toolbar( action ), message ) &&
- write_bool( provider, uuid, NULL, OBJECT_ITEM_TOOLBAR_SAME_LABEL_ENTRY, na_object_action_toolbar_use_same_label( action ), message ) &&
- write_str( provider, uuid, NULL, OBJECT_ITEM_TOOLBAR_LABEL_ENTRY, na_object_action_toolbar_get_label( action ), message ) &&
- write_str( provider, uuid, NULL, OBJECT_ITEM_TYPE_ENTRY, g_strdup( OBJECT_ITEM_TYPE_ACTION ), message );
+ write_object_item( provider, NA_OBJECT_ITEM( action ), messages ) &&
+ write_str( provider, uuid, NULL, ACTION_VERSION_ENTRY, na_object_action_get_version( action ), messages ) &&
+ write_bool( provider, uuid, NULL, OBJECT_ITEM_TARGET_SELECTION_ENTRY, na_object_action_is_target_selection( action ), messages ) &&
+ write_bool( provider, uuid, NULL, OBJECT_ITEM_TARGET_BACKGROUND_ENTRY, na_object_action_is_target_background( action ), messages ) &&
+ write_bool( provider, uuid, NULL, OBJECT_ITEM_TARGET_TOOLBAR_ENTRY, na_object_action_is_target_toolbar( action ), messages ) &&
+ write_bool( provider, uuid, NULL, OBJECT_ITEM_TOOLBAR_SAME_LABEL_ENTRY, na_object_action_toolbar_use_same_label( action ), messages ) &&
+ write_str( provider, uuid, NULL, OBJECT_ITEM_TOOLBAR_LABEL_ENTRY, na_object_action_toolbar_get_label( action ), messages ) &&
+ write_str( provider, uuid, NULL, OBJECT_ITEM_TYPE_ENTRY, g_strdup( OBJECT_ITEM_TYPE_ACTION ), messages );
profiles = na_object_get_items_list( action );
@@ -902,17 +896,17 @@ write_item_action( NAGConfProvider *provider, const NAObjectAction *action, gcha
name = na_object_get_id( profile );
ret =
- write_str( provider, uuid, name, ACTION_PROFILE_LABEL_ENTRY, na_object_get_label( profile ), message ) &&
- write_str( provider, uuid, name, ACTION_PATH_ENTRY, na_object_profile_get_path( profile ), message ) &&
- write_str( provider, uuid, name, ACTION_PARAMETERS_ENTRY, na_object_profile_get_parameters( profile ), message ) &&
- write_list( provider, uuid, name, ACTION_BASENAMES_ENTRY, na_object_profile_get_basenames( profile ), message ) &&
- write_bool( provider, uuid, name, ACTION_MATCHCASE_ENTRY, na_object_profile_get_matchcase( profile ), message ) &&
- write_list( provider, uuid, name, ACTION_MIMETYPES_ENTRY, na_object_profile_get_mimetypes( profile ), message ) &&
- write_bool( provider, uuid, name, ACTION_ISFILE_ENTRY, na_object_profile_get_is_file( profile ), message ) &&
- write_bool( provider, uuid, name, ACTION_ISDIR_ENTRY, na_object_profile_get_is_dir( profile ), message ) &&
- write_bool( provider, uuid, name, ACTION_MULTIPLE_ENTRY, na_object_profile_get_multiple( profile ), message ) &&
- write_list( provider, uuid, name, ACTION_SCHEMES_ENTRY, na_object_profile_get_schemes( profile ), message ) &&
- write_list( provider, uuid, name, ACTION_FOLDERS_ENTRY, na_object_profile_get_folders( profile ), message );
+ write_str( provider, uuid, name, ACTION_PROFILE_LABEL_ENTRY, na_object_get_label( profile ), messages ) &&
+ write_str( provider, uuid, name, ACTION_PATH_ENTRY, na_object_profile_get_path( profile ), messages ) &&
+ write_str( provider, uuid, name, ACTION_PARAMETERS_ENTRY, na_object_profile_get_parameters( profile ), messages ) &&
+ write_list( provider, uuid, name, ACTION_BASENAMES_ENTRY, na_object_profile_get_basenames( profile ), messages ) &&
+ write_bool( provider, uuid, name, ACTION_MATCHCASE_ENTRY, na_object_profile_get_matchcase( profile ), messages ) &&
+ write_list( provider, uuid, name, ACTION_MIMETYPES_ENTRY, na_object_profile_get_mimetypes( profile ), messages ) &&
+ write_bool( provider, uuid, name, ACTION_ISFILE_ENTRY, na_object_profile_get_is_file( profile ), messages ) &&
+ write_bool( provider, uuid, name, ACTION_ISDIR_ENTRY, na_object_profile_get_is_dir( profile ), messages ) &&
+ write_bool( provider, uuid, name, ACTION_MULTIPLE_ENTRY, na_object_profile_get_multiple( profile ), messages ) &&
+ write_list( provider, uuid, name, ACTION_SCHEMES_ENTRY, na_object_profile_get_schemes( profile ), messages ) &&
+ write_list( provider, uuid, name, ACTION_FOLDERS_ENTRY, na_object_profile_get_folders( profile ), messages );
g_free( name );
}
@@ -923,7 +917,7 @@ write_item_action( NAGConfProvider *provider, const NAObjectAction *action, gcha
}
static gboolean
-write_item_menu( NAGConfProvider *provider, const NAObjectMenu *menu, gchar **message )
+write_item_menu( NAGConfProvider *provider, const NAObjectMenu *menu, GSList **messages )
{
gboolean ret;
gchar *uuid;
@@ -931,8 +925,8 @@ write_item_menu( NAGConfProvider *provider, const NAObjectMenu *menu, gchar **me
uuid = na_object_get_id( menu );
ret =
- write_object_item( provider, NA_OBJECT_ITEM( menu ), message ) &&
- write_str( provider, uuid, NULL, OBJECT_ITEM_TYPE_ENTRY, g_strdup( OBJECT_ITEM_TYPE_MENU ), message );
+ write_object_item( provider, NA_OBJECT_ITEM( menu ), messages ) &&
+ write_str( provider, uuid, NULL, OBJECT_ITEM_TYPE_ENTRY, g_strdup( OBJECT_ITEM_TYPE_MENU ), messages );
g_free( uuid );
@@ -940,7 +934,7 @@ write_item_menu( NAGConfProvider *provider, const NAObjectMenu *menu, gchar **me
}
static gboolean
-write_object_item( NAGConfProvider *provider, const NAObjectItem *item, gchar **message )
+write_object_item( NAGConfProvider *provider, const NAObjectItem *item, GSList **messages )
{
gchar *uuid;
gboolean ret;
@@ -948,11 +942,11 @@ write_object_item( NAGConfProvider *provider, const NAObjectItem *item, gchar **
uuid = na_object_get_id( NA_OBJECT( item ));
ret =
- write_str( provider, uuid, NULL, OBJECT_ITEM_LABEL_ENTRY, na_object_get_label( NA_OBJECT( item )), message ) &&
- write_str( provider, uuid, NULL, OBJECT_ITEM_TOOLTIP_ENTRY, na_object_get_tooltip( item ), message ) &&
- write_str( provider, uuid, NULL, OBJECT_ITEM_ICON_ENTRY, na_object_get_icon( item ), message ) &&
- write_bool( provider, uuid, NULL, OBJECT_ITEM_ENABLED_ENTRY, na_object_is_enabled( item ), message ) &&
- write_list( provider, uuid, NULL, OBJECT_ITEM_LIST_ENTRY, na_object_item_rebuild_items_list( item ), message );
+ write_str( provider, uuid, NULL, OBJECT_ITEM_LABEL_ENTRY, na_object_get_label( NA_OBJECT( item )), messages ) &&
+ write_str( provider, uuid, NULL, OBJECT_ITEM_TOOLTIP_ENTRY, na_object_get_tooltip( item ), messages ) &&
+ write_str( provider, uuid, NULL, OBJECT_ITEM_ICON_ENTRY, na_object_get_icon( item ), messages ) &&
+ write_bool( provider, uuid, NULL, OBJECT_ITEM_ENABLED_ENTRY, na_object_is_enabled( item ), messages ) &&
+ write_list( provider, uuid, NULL, OBJECT_ITEM_LIST_ENTRY, na_object_item_rebuild_items_list( item ), messages );
g_free( uuid );
return( ret );
@@ -963,7 +957,7 @@ write_object_item( NAGConfProvider *provider, const NAObjectItem *item, gchar **
* cf. http://bugzilla.gnome.org/show_bug.cgi?id=325585
*/
static guint
-iio_provider_delete_item( const NAIIOProvider *provider, const NAObject *item, gchar **message )
+iio_provider_delete_item( const NAIIOProvider *provider, const NAObjectItem *item, GSList **messages )
{
static const gchar *thisfn = "na_gconf_provider_iio_provider_delete_item";
NAGConfProvider *self;
@@ -971,9 +965,9 @@ iio_provider_delete_item( const NAIIOProvider *provider, const NAObject *item, g
gchar *uuid, *path;
GError *error = NULL;
- g_debug( "%s: provider=%p, item=%p (%s), message=%p",
+ g_debug( "%s: provider=%p, item=%p (%s), messages=%p",
thisfn, ( void * ) provider,
- ( void * ) item, G_OBJECT_TYPE_NAME( item ), ( void * ) message );
+ ( void * ) item, G_OBJECT_TYPE_NAME( item ), ( void * ) messages );
g_return_val_if_fail( NA_IS_IIO_PROVIDER( provider ), NA_IIO_PROVIDER_PROGRAM_ERROR );
g_return_val_if_fail( NA_IS_GCONF_PROVIDER( provider ), NA_IIO_PROVIDER_PROGRAM_ERROR );
@@ -985,10 +979,6 @@ iio_provider_delete_item( const NAIIOProvider *provider, const NAObject *item, g
return( NA_IIO_PROVIDER_NOT_WILLING_TO_WRITE );
}
- if( message ){
- *message = NULL;
- }
-
ret = NA_IIO_PROVIDER_WRITE_OK;
uuid = na_object_get_id( NA_OBJECT( item ));
@@ -1005,7 +995,7 @@ iio_provider_delete_item( const NAIIOProvider *provider, const NAObject *item, g
path = g_strdup_printf( "%s/%s", NA_GCONF_CONFIG_PATH, uuid );
if( !gconf_client_recursive_unset( self->private->gconf, path, 0, &error )){
g_warning( "%s: path=%s, error=%s", thisfn, path, error->message );
- *message = g_strdup( error->message );
+ /* TODO: *message = g_strdup( error->message );*/
g_error_free( error );
ret = NA_IIO_PROVIDER_WRITE_ERROR;
@@ -1075,10 +1065,11 @@ key_is_writable( NAGConfProvider *gconf, const gchar *path )
}
static gboolean
-write_str( NAGConfProvider *provider, const gchar *uuid, const gchar *name, const gchar *key, gchar *value, gchar **message )
+write_str( NAGConfProvider *provider, const gchar *uuid, const gchar *name, const gchar *key, gchar *value, GSList **messages )
{
gchar *path;
gboolean ret;
+ gchar *msg;
if( name && strlen( name )){
path = g_strdup_printf( "%s/%s/%s/%s", NA_GCONF_CONFIG_PATH, uuid, name, key );
@@ -1086,7 +1077,12 @@ write_str( NAGConfProvider *provider, const gchar *uuid, const gchar *name, cons
path = g_strdup_printf( "%s/%s/%s", NA_GCONF_CONFIG_PATH, uuid, key );
}
- ret = na_gconf_utils_write_string( provider->private->gconf, path, value, message );
+ msg = NULL;
+ ret = na_gconf_utils_write_string( provider->private->gconf, path, value, &msg );
+ if( msg ){
+ *messages = g_slist_append( *messages, msg );
+ g_free( msg );
+ }
g_free( value );
g_free( path );
@@ -1095,10 +1091,11 @@ write_str( NAGConfProvider *provider, const gchar *uuid, const gchar *name, cons
}
static gboolean
-write_bool( NAGConfProvider *provider, const gchar *uuid, const gchar *name, const gchar *key, gboolean value, gchar **message )
+write_bool( NAGConfProvider *provider, const gchar *uuid, const gchar *name, const gchar *key, gboolean value, GSList **messages )
{
gboolean ret;
gchar *path;
+ gchar *msg;
if( name && strlen( name )){
path = g_strdup_printf( "%s/%s/%s/%s", NA_GCONF_CONFIG_PATH, uuid, name, key );
@@ -1106,7 +1103,12 @@ write_bool( NAGConfProvider *provider, const gchar *uuid, const gchar *name, con
path = g_strdup_printf( "%s/%s/%s", NA_GCONF_CONFIG_PATH, uuid, key );
}
- ret = na_gconf_utils_write_bool( provider->private->gconf, path, value, message );
+ msg = NULL;
+ ret = na_gconf_utils_write_bool( provider->private->gconf, path, value, &msg );
+ if( msg ){
+ *messages = g_slist_append( *messages, msg );
+ g_free( msg );
+ }
g_free( path );
@@ -1114,10 +1116,11 @@ write_bool( NAGConfProvider *provider, const gchar *uuid, const gchar *name, con
}
static gboolean
-write_list( NAGConfProvider *provider, const gchar *uuid, const gchar *name, const gchar *key, GSList *value, gchar **message )
+write_list( NAGConfProvider *provider, const gchar *uuid, const gchar *name, const gchar *key, GSList *value, GSList **messages )
{
gboolean ret;
gchar *path;
+ gchar *msg;
if( name && strlen( name )){
path = g_strdup_printf( "%s/%s/%s/%s", NA_GCONF_CONFIG_PATH, uuid, name, key );
@@ -1125,7 +1128,12 @@ write_list( NAGConfProvider *provider, const gchar *uuid, const gchar *name, con
path = g_strdup_printf( "%s/%s/%s", NA_GCONF_CONFIG_PATH, uuid, key );
}
- ret = na_gconf_utils_write_string_list( provider->private->gconf, path, value, message );
+ msg = NULL;
+ ret = na_gconf_utils_write_string_list( provider->private->gconf, path, value, &msg );
+ if( msg ){
+ *messages = g_slist_append( *messages, msg );
+ g_free( msg );
+ }
na_utils_free_string_list( value );
g_free( path );
diff --git a/nautilus-actions/runtime/na-iio-provider.c b/nautilus-actions/runtime/na-io-provider.c
similarity index 52%
rename from nautilus-actions/runtime/na-iio-provider.c
rename to nautilus-actions/runtime/na-io-provider.c
index aca2d65..5a57d61 100644
--- a/nautilus-actions/runtime/na-iio-provider.c
+++ b/nautilus-actions/runtime/na-io-provider.c
@@ -34,116 +34,26 @@
#include <string.h>
+#include <nautilus-actions/api/na-iio-provider.h>
+
#include "na-object-api.h"
-#include "na-iio-provider.h"
+#include "na-io-provider.h"
#include "na-iprefs.h"
#include "na-utils.h"
-/* private interface data
- */
-struct NAIIOProviderInterfacePrivate {
- void *empty; /* so that gcc -pedantic is happy */
-};
-
-static gboolean st_initialized = FALSE;
-static gboolean st_finalized = FALSE;
-
-static GType register_type( void );
-static void interface_base_init( NAIIOProviderInterface *klass );
-static void interface_base_finalize( NAIIOProviderInterface *klass );
-
static GList *build_hierarchy( GList **tree, GSList *level_zero, gboolean list_if_empty );
static gint search_item( const NAObject *obj, const gchar *uuid );
-static GList *get_merged_items_list( const NAPivot *pivot, GList *providers );
-
-static guint try_write_item( const NAIIOProvider *instance, NAObject *item, gchar **message );
+static GList *get_merged_items_list( const NAPivot *pivot, GList *providers, GSList **messages );
-static gboolean do_is_willing_to_write( const NAIIOProvider *instance );
-static gboolean do_is_writable( const NAIIOProvider *instance, const NAObject *item );
+static guint try_write_item( const NAIIOProvider *instance, NAObjectItem *item, GSList **messages );
static GList *sort_tree( const NAPivot *pivot, GList *tree, GCompareFunc fn );
/**
- * Registers the GType of this interface.
- */
-GType
-na_iio_provider_get_type( void )
-{
- static GType object_type = 0;
-
- if( !object_type ){
- object_type = register_type();
- }
-
- return( object_type );
-}
-
-static GType
-register_type( void )
-{
- static const gchar *thisfn = "na_iio_provider_register_type";
- GType type;
-
- static const GTypeInfo info = {
- sizeof( NAIIOProviderInterface ),
- ( GBaseInitFunc ) interface_base_init,
- ( GBaseFinalizeFunc ) interface_base_finalize,
- NULL,
- NULL,
- NULL,
- 0,
- 0,
- NULL
- };
-
- g_debug( "%s", thisfn );
-
- type = g_type_register_static( G_TYPE_INTERFACE, "NAIIOProvider", &info, 0 );
-
- g_type_interface_add_prerequisite( type, G_TYPE_OBJECT );
-
- return( type );
-}
-
-static void
-interface_base_init( NAIIOProviderInterface *klass )
-{
- static const gchar *thisfn = "na_iio_provider_interface_base_init";
-
- if( !st_initialized ){
- g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
-
- klass->private = g_new0( NAIIOProviderInterfacePrivate, 1 );
-
- klass->read_items_list = NULL;
- klass->is_willing_to_write = do_is_willing_to_write;
- klass->is_writable = do_is_writable;
- klass->write_item = NULL;
- klass->delete_item = NULL;
-
- st_initialized = TRUE;
- }
-}
-
-static void
-interface_base_finalize( NAIIOProviderInterface *klass )
-{
- static const gchar *thisfn = "na_iio_provider_interface_base_finalize";
-
- if( !st_finalized ){
-
- st_finalized = TRUE;
-
- g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
-
- g_free( klass->private );
- }
-}
-
-/**
- * na_iio_provider_get_items_tree:
+ * na_io_provider_read_items:
* @pivot: the #NAPivot object which owns the list of registered I/O
* storage providers.
+ * @messages: error messages.
*
* Loads the tree from I/O storage subsystems.
*
@@ -152,62 +62,60 @@ interface_base_finalize( NAIIOProviderInterface *klass )
* #NAAction actions and their #NAActionProfile profiles.
*/
GList *
-na_iio_provider_get_items_tree( const NAPivot *pivot )
+na_io_provider_read_items( const NAPivot *pivot, GSList **messages )
{
- static const gchar *thisfn = "na_iio_provider_get_items_tree";
+ static const gchar *thisfn = "na_io_provider_read_items";
GList *providers;
GList *merged, *hierarchy;
GSList *level_zero;
gint order_mode;
- g_debug( "%s: pivot=%p", thisfn, ( void * ) pivot );
+ g_debug( "%s: pivot=%p, messages=%p", thisfn, ( void * ) pivot, ( void * ) messages );
g_return_val_if_fail( NA_IS_PIVOT( pivot ), NULL );
g_return_val_if_fail( NA_IS_IPREFS( pivot ), NULL );
hierarchy = NULL;
+ *messages = NULL;
- if( st_initialized && !st_finalized ){
-
- providers = na_pivot_get_providers( pivot, NA_IIO_PROVIDER_TYPE );
- merged = get_merged_items_list( pivot, providers );
- na_pivot_free_providers( providers );
+ providers = na_pivot_get_providers( pivot, NA_IIO_PROVIDER_TYPE );
+ merged = get_merged_items_list( pivot, providers, messages );
+ na_pivot_free_providers( providers );
- level_zero = na_iprefs_get_level_zero_items( NA_IPREFS( pivot ));
- hierarchy = build_hierarchy( &merged, level_zero, TRUE );
+ level_zero = na_iprefs_get_level_zero_items( NA_IPREFS( pivot ));
+ hierarchy = build_hierarchy( &merged, level_zero, TRUE );
- /* items that stay left in the merged list are simply appended
- * to the built hierarchy, and level zero is updated accordingly
- */
- if( merged ){
- g_debug( "%s: %d items left appended to the hierarchy", thisfn, g_list_length( merged ));
- hierarchy = g_list_concat( hierarchy, merged );
- }
+ /* items that stay left in the merged list are simply appended
+ * to the built hierarchy, and level zero is updated accordingly
+ */
+ if( merged ){
+ g_debug( "%s: %d items left appended to the hierarchy", thisfn, g_list_length( merged ));
+ hierarchy = g_list_concat( hierarchy, merged );
+ }
- if( merged || !level_zero || !g_slist_length( level_zero )){
- g_debug( "%s: rewriting level-zero", thisfn );
- na_pivot_write_level_zero( pivot, hierarchy );
- }
+ if( merged || !level_zero || !g_slist_length( level_zero )){
+ g_debug( "%s: rewriting level-zero", thisfn );
+ na_pivot_write_level_zero( pivot, hierarchy );
+ }
- na_utils_free_string_list( level_zero );
+ na_utils_free_string_list( level_zero );
- g_debug( "%s: tree before alphabetical reordering (if any)", thisfn );
- na_object_dump_tree( hierarchy );
- g_debug( "%s: end of tree", thisfn );
+ g_debug( "%s: tree before alphabetical reordering (if any)", thisfn );
+ na_object_dump_tree( hierarchy );
+ g_debug( "%s: end of tree", thisfn );
- order_mode = na_iprefs_get_order_mode( NA_IPREFS( pivot ));
- switch( order_mode ){
- case IPREFS_ORDER_ALPHA_ASCENDING:
- hierarchy = sort_tree( pivot, hierarchy, ( GCompareFunc ) na_pivot_sort_alpha_asc );
- break;
+ order_mode = na_iprefs_get_order_mode( NA_IPREFS( pivot ));
+ switch( order_mode ){
+ case IPREFS_ORDER_ALPHA_ASCENDING:
+ hierarchy = sort_tree( pivot, hierarchy, ( GCompareFunc ) na_pivot_sort_alpha_asc );
+ break;
- case IPREFS_ORDER_ALPHA_DESCENDING:
- hierarchy = sort_tree( pivot, hierarchy, ( GCompareFunc ) na_pivot_sort_alpha_desc );
- break;
+ case IPREFS_ORDER_ALPHA_DESCENDING:
+ hierarchy = sort_tree( pivot, hierarchy, ( GCompareFunc ) na_pivot_sort_alpha_desc );
+ break;
- case IPREFS_ORDER_MANUAL:
- default:
- break;
- }
+ case IPREFS_ORDER_MANUAL:
+ default:
+ break;
}
return( hierarchy );
@@ -287,7 +195,7 @@ search_item( const NAObject *obj, const gchar *uuid )
* returns a concatened list of readen actions / menus
*/
static GList *
-get_merged_items_list( const NAPivot *pivot, GList *providers )
+get_merged_items_list( const NAPivot *pivot, GList *providers, GSList **messages )
{
GList *ip;
GList *merged = NULL;
@@ -297,9 +205,9 @@ get_merged_items_list( const NAPivot *pivot, GList *providers )
for( ip = providers ; ip ; ip = ip->next ){
instance = NA_IIO_PROVIDER( ip->data );
- if( NA_IIO_PROVIDER_GET_INTERFACE( instance )->read_items_list ){
+ if( NA_IIO_PROVIDER_GET_INTERFACE( instance )->read_items ){
- list = NA_IIO_PROVIDER_GET_INTERFACE( instance )->read_items_list( instance );
+ list = NA_IIO_PROVIDER_GET_INTERFACE( instance )->read_items( instance, messages );
for( item = list ; item ; item = item->next ){
@@ -315,82 +223,78 @@ get_merged_items_list( const NAPivot *pivot, GList *providers )
}
/**
- * na_iio_provider_write_item:
+ * na_io_provider_write_item:
* @pivot: the #NAPivot object which owns the list of registered I/O
* storage providers. if NULL, @action must already have registered
* its own provider.
- * @item: a #NAObject to be written by the storage subsystem.
- * @message: the I/O provider can allocate and store here an error
- * message.
+ * @item: a #NAObjectItem to be written by the storage subsystem.
+ * @messages: error messages.
*
* Writes an @item to a willing-to storage subsystem.
*
* Returns: the NAIIOProvider return code.
*/
guint
-na_iio_provider_write_item( const NAPivot *pivot, NAObject *item, gchar **message )
+na_io_provider_write_item( const NAPivot *pivot, NAObjectItem *item, GSList **messages )
{
- static const gchar *thisfn = "na_iio_provider_write_item";
+ static const gchar *thisfn = "na_io_provider_write_item";
guint ret;
NAIIOProvider *instance;
NAIIOProvider *bad_instance;
GList *providers, *ip;
- g_debug( "%s: pivot=%p (%s), item=%p (%s), message=%p", thisfn,
+ g_debug( "%s: pivot=%p (%s), item=%p (%s), messages=%p", thisfn,
( void * ) pivot, G_OBJECT_TYPE_NAME( pivot ),
( void * ) item, G_OBJECT_TYPE_NAME( item ),
- ( void * ) message );
+ ( void * ) messages );
g_return_val_if_fail(( NA_IS_PIVOT( pivot ) || !pivot ), NA_IIO_PROVIDER_PROGRAM_ERROR );
g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), NA_IIO_PROVIDER_PROGRAM_ERROR );
- ret = NA_IIO_PROVIDER_NOT_WILLING_TO_WRITE;
-
- if( st_initialized && !st_finalized ){
+ ret = NA_IIO_PROVIDER_NOT_WRITABLE;
+ bad_instance = NULL;
+ *messages = NULL;
- ret = NA_IIO_PROVIDER_NOT_WRITABLE;
- bad_instance = NULL;
-
- /* try to write to the original provider of the item
- */
- instance = NA_IIO_PROVIDER( na_object_get_provider( item ));
- if( instance ){
- ret = try_write_item( instance, item, message );
- if( ret == NA_IIO_PROVIDER_NOT_WILLING_TO_WRITE || ret == NA_IIO_PROVIDER_NOT_WRITABLE ){
- bad_instance = instance;
- instance = NULL;
- }
+ /* try to write to the original provider of the item
+ */
+ instance = NA_IIO_PROVIDER( na_object_get_provider( item ));
+ if( instance ){
+ ret = try_write_item( instance, item, messages );
+ if( ret == NA_IIO_PROVIDER_NOT_WILLING_TO_WRITE || ret == NA_IIO_PROVIDER_NOT_WRITABLE ){
+ bad_instance = instance;
+ instance = NULL;
}
+ }
- /* else, search for a provider which is willing to write the item
- */
- if( !instance && pivot ){
- providers = na_pivot_get_providers( pivot, NA_IIO_PROVIDER_TYPE );
- for( ip = providers ; ip ; ip = ip->next ){
-
- instance = NA_IIO_PROVIDER( ip->data );
- if( !bad_instance || bad_instance != instance ){
- ret = try_write_item( instance, item, message );
- if( ret == NA_IIO_PROVIDER_WRITE_OK ){
- break;
- }
+ /* else, search for a provider which is willing to write the item
+ */
+ if( !instance && pivot ){
+ providers = na_pivot_get_providers( pivot, NA_IIO_PROVIDER_TYPE );
+ for( ip = providers ; ip ; ip = ip->next ){
+
+ instance = NA_IIO_PROVIDER( ip->data );
+ if( !bad_instance || instance != bad_instance ){
+ ret = try_write_item( instance, item, messages );
+ if( ret == NA_IIO_PROVIDER_WRITE_OK ){
+ na_object_set_provider( item, instance );
+ break;
}
}
- na_pivot_free_providers( providers );
}
+ na_pivot_free_providers( providers );
}
return( ret );
}
static guint
-try_write_item( const NAIIOProvider *provider, NAObject *item, gchar **message )
+try_write_item( const NAIIOProvider *provider, NAObjectItem *item, GSList **messages )
{
- static const gchar *thisfn = "na_iio_provider_try_write_item";
+ static const gchar *thisfn = "na_io_provider_try_write_item";
guint ret;
- g_debug( "%s: provider=%p, item=%p, message=%p",
- thisfn, ( void * ) provider, ( void * ) item, ( void * ) message );
+ g_debug( "%s: provider=%p, item=%p, messages=%p",
+ thisfn, ( void * ) provider, ( void * ) item, ( void * ) messages );
if( !NA_IIO_PROVIDER_GET_INTERFACE( provider )->is_willing_to_write( provider )){
return( NA_IIO_PROVIDER_NOT_WILLING_TO_WRITE );
@@ -405,21 +309,20 @@ try_write_item( const NAIIOProvider *provider, NAObject *item, gchar **message )
return( NA_IIO_PROVIDER_NOT_WILLING_TO_WRITE );
}
- ret = NA_IIO_PROVIDER_GET_INTERFACE( provider )->delete_item( provider, item, message );
+ ret = NA_IIO_PROVIDER_GET_INTERFACE( provider )->delete_item( provider, item, messages );
if( ret != NA_IIO_PROVIDER_WRITE_OK ){
return( ret );
}
- return( NA_IIO_PROVIDER_GET_INTERFACE( provider )->write_item( provider, item, message ));
+ return( NA_IIO_PROVIDER_GET_INTERFACE( provider )->write_item( provider, item, messages ));
}
/**
- * na_iio_provider_delete_item:
+ * na_io_provider_delete_item:
* @pivot: the #NAPivot object which owns the list of registered I/O
* storage providers.
- * @item: the #NAObject item to be deleted.
- * @message: the I/O provider can allocate and store here an error
- * message.
+ * @item: the #NAObjectItem item to be deleted.
+ * @messages: error messages.
*
* Deletes an item (action or menu) from the storage subsystem.
*
@@ -429,51 +332,35 @@ try_write_item( const NAIIOProvider *provider, NAObject *item, gchar **message )
* doesn't have any attached provider. We so do nothing...
*/
guint
-na_iio_provider_delete_item( const NAPivot *pivot, const NAObject *item, gchar **message )
+na_io_provider_delete_item( const NAPivot *pivot, const NAObjectItem *item, GSList **messages )
{
- static const gchar *thisfn = "na_iio_provider_delete_item";
+ static const gchar *thisfn = "na_io_provider_delete_item";
guint ret;
NAIIOProvider *instance;
- g_debug( "%s: pivot=%p (%s), item=%p (%s), message=%p", thisfn,
+ g_debug( "%s: pivot=%p (%s), item=%p (%s), messages=%p", thisfn,
( void * ) pivot, G_OBJECT_TYPE_NAME( pivot ),
( void * ) item, G_OBJECT_TYPE_NAME( item ),
- ( void * ) message );
+ ( void * ) messages );
g_return_val_if_fail( NA_IS_PIVOT( pivot ), NA_IIO_PROVIDER_PROGRAM_ERROR );
g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), NA_IIO_PROVIDER_PROGRAM_ERROR );
- ret = NA_IIO_PROVIDER_NOT_WILLING_TO_WRITE;
-
- if( st_initialized && !st_finalized ){
+ *messages = NULL;
+ ret = NA_IIO_PROVIDER_NOT_WRITABLE;
+ instance = NA_IIO_PROVIDER( na_object_get_provider( item ));
- ret = NA_IIO_PROVIDER_NOT_WRITABLE;
- instance = NA_IIO_PROVIDER( na_object_get_provider( item ));
+ if( instance ){
+ g_return_val_if_fail( NA_IS_IIO_PROVIDER( instance ), NA_IIO_PROVIDER_PROGRAM_ERROR );
- if( instance ){
- g_return_val_if_fail( NA_IS_IIO_PROVIDER( instance ), NA_IIO_PROVIDER_PROGRAM_ERROR );
-
- if( NA_IIO_PROVIDER_GET_INTERFACE( instance )->delete_item ){
- ret = NA_IIO_PROVIDER_GET_INTERFACE( instance )->delete_item( instance, item, message );
- }
+ if( NA_IIO_PROVIDER_GET_INTERFACE( instance )->delete_item ){
+ ret = NA_IIO_PROVIDER_GET_INTERFACE( instance )->delete_item( instance, item, messages );
}
}
return( ret );
}
-static gboolean
-do_is_willing_to_write( const NAIIOProvider *instance )
-{
- return( FALSE );
-}
-
-static gboolean
-do_is_writable( const NAIIOProvider *instance, const NAObject *item )
-{
- return( FALSE );
-}
-
static GList *
sort_tree( const NAPivot *pivot, GList *tree, GCompareFunc fn )
{
diff --git a/nautilus-actions/runtime/na-io-provider.h b/nautilus-actions/runtime/na-io-provider.h
new file mode 100644
index 0000000..f3d5bae
--- /dev/null
+++ b/nautilus-actions/runtime/na-io-provider.h
@@ -0,0 +1,57 @@
+/*
+ * 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 __NA_RUNTIME_IO_PROVIDER_H__
+#define __NA_RUNTIME_IO_PROVIDER_H__
+
+/**
+ * SECTION: na_iio_provider
+ * @short_description: #NAIIOProvider internal API.
+ * @include: runtime/na-io-provider.h
+ *
+ * This is the API which is used by Nautilus-Actions to manage the actual
+ * NAIIOProvider interface.
+ */
+
+#include "na-pivot.h"
+
+G_BEGIN_DECLS
+
+GList *na_io_provider_read_items ( const NAPivot *pivot, GSList **messages );
+guint na_io_provider_write_item ( const NAPivot *pivot, NAObjectItem *item, GSList **messages );
+guint na_io_provider_delete_item( const NAPivot *pivot, const NAObjectItem *item, GSList **messages );
+
+/* notification message to NAPivot
+ */
+#define NA_IIO_PROVIDER_SIGNAL_ACTION_CHANGED "notify-consumer-of-action-change"
+
+G_END_DECLS
+
+#endif /* __NA_RUNTIME_IO_PROVIDER_H__ */
diff --git a/nautilus-actions/runtime/na-module.c b/nautilus-actions/runtime/na-module.c
index cbf3bc5..e6ecd21 100644
--- a/nautilus-actions/runtime/na-module.c
+++ b/nautilus-actions/runtime/na-module.c
@@ -261,7 +261,7 @@ module_unload( GTypeModule *gmodule )
}
/**
- * na_modules_load_modules:
+ * na_module_load_modules:
*
* Load availables dynamic libraries.
*
@@ -269,9 +269,9 @@ module_unload( GTypeModule *gmodule )
* loaded library.
*/
GList *
-na_modules_load_modules( void )
+na_module_load_modules( void )
{
- static const gchar *thisfn = "na_modules_load_modules";
+ static const gchar *thisfn = "na_module_load_modules";
const gchar *dirname = PKGLIBDIR;
GList *modules;
GDir *api_dir;
@@ -298,6 +298,7 @@ na_modules_load_modules( void )
module = module_new( fname );
if( module ){
modules = g_list_prepend( modules, module );
+ g_debug( "%s: module %s successfully loaded", thisfn, fname );
}
g_free( fname );
}
diff --git a/nautilus-actions/runtime/na-module.h b/nautilus-actions/runtime/na-module.h
index b352e8a..388d541 100644
--- a/nautilus-actions/runtime/na-module.h
+++ b/nautilus-actions/runtime/na-module.h
@@ -70,7 +70,7 @@ typedef struct {
GType na_module_get_type ( void );
-GList *na_modules_load_modules ( void );
+GList *na_module_load_modules ( void );
GList *na_module_get_extensions_for_type( GList *modules, GType type );
gchar *na_module_get_name ( NAModule *module, GType type );
void na_module_release_modules ( GList *modules );
diff --git a/nautilus-actions/runtime/na-object-item-fn.h b/nautilus-actions/runtime/na-object-item-fn.h
index 630da50..b10d58e 100644
--- a/nautilus-actions/runtime/na-object-item-fn.h
+++ b/nautilus-actions/runtime/na-object-item-fn.h
@@ -42,8 +42,9 @@
* in na-object-api.h
*/
+#include <nautilus-actions/api/na-iio-provider.h>
+
#include "na-object-item-class.h"
-#include "na-iio-provider.h"
G_BEGIN_DECLS
diff --git a/nautilus-actions/runtime/na-pivot.c b/nautilus-actions/runtime/na-pivot.c
index fdffd59..5bd9daf 100644
--- a/nautilus-actions/runtime/na-pivot.c
+++ b/nautilus-actions/runtime/na-pivot.c
@@ -36,10 +36,11 @@
#include <uuid/uuid.h>
#include "na-object-api.h"
-#include "na-iio-provider.h"
+#include "na-io-provider.h"
#include "na-gconf-monitor.h"
#include "na-gconf-provider.h"
#include "na-iprefs.h"
+#include "na-module.h"
#include "na-pivot.h"
#include "na-utils.h"
@@ -54,6 +55,10 @@ struct NAPivotClassPrivate {
struct NAPivotPrivate {
gboolean dispose_has_run;
+ /* dynamically loaded modules
+ */
+ GList *modules;
+
/* list of instances to be notified of repository updates
* these are called 'consumers' of NAPivot
*/
@@ -219,6 +224,7 @@ instance_init( GTypeInstance *instance, gpointer klass )
self->private = g_new0( NAPivotPrivate, 1 );
self->private->dispose_has_run = FALSE;
+ self->private->modules = NULL;
self->private->consumers = NULL;
self->private->providers = NULL;
self->private->tree = NULL;
@@ -239,6 +245,10 @@ instance_dispose( GObject *object )
self->private->dispose_has_run = TRUE;
+ /* release modules */
+ na_module_release_modules( self->private->modules );
+ self->private->modules = NULL;
+
/* release list of NAIPivotConsumers */
free_consumers( self->private->consumers );
self->private->consumers = NULL;
@@ -295,12 +305,15 @@ na_pivot_new( const NAIPivotConsumer *target )
{
static const gchar *thisfn = "na_pivot_new";
NAPivot *pivot;
+ GSList *messages, *im;
g_debug( "%s: target=%p", thisfn, ( void * ) target );
g_return_val_if_fail( NA_IS_IPIVOT_CONSUMER( target ) || !target, NULL );
pivot = g_object_new( NA_PIVOT_TYPE, NULL );
+ pivot->private->modules = na_module_load_modules();
+
register_io_providers( pivot );
if( target ){
@@ -309,7 +322,11 @@ na_pivot_new( const NAIPivotConsumer *target )
monitor_runtime_preferences( pivot );
- pivot->private->tree = na_iio_provider_get_items_tree( pivot );
+ pivot->private->tree = na_io_provider_read_items( pivot, &messages );
+ for( im = messages ; im ; im = im->next ){
+ g_warning( "%s: %s", thisfn, ( const gchar * ) im->data );
+ }
+ na_utils_free_string_list( messages );
return( pivot );
}
@@ -352,6 +369,7 @@ na_pivot_dump( const NAPivot *pivot )
if( !pivot->private->dispose_has_run ){
+ g_debug( "%s: modules=%p (%d elts)", thisfn, ( void * ) pivot->private->modules, g_list_length( pivot->private->modules ));
g_debug( "%s: consumers=%p (%d elts)", thisfn, ( void * ) pivot->private->consumers, g_list_length( pivot->private->consumers ));
g_debug( "%s: providers=%p (%d elts)", thisfn, ( void * ) pivot->private->providers, g_list_length( pivot->private->providers ));
g_debug( "%s: tree=%p (%d elts)", thisfn, ( void * ) pivot->private->tree, g_list_length( pivot->private->tree ));
@@ -446,13 +464,20 @@ na_pivot_get_items( const NAPivot *pivot )
void
na_pivot_reload_items( NAPivot *pivot )
{
+ static const gchar *thisfn = "na_pivot_reload_items";
+ GSList *messages, *im;
+
g_return_if_fail( NA_IS_PIVOT( pivot ));
if( !pivot->private->dispose_has_run ){
na_object_free_items_list( pivot->private->tree );
- pivot->private->tree = na_iio_provider_get_items_tree( pivot );
+ pivot->private->tree = na_io_provider_read_items( pivot, &messages );
+ for( im = messages ; im ; im = im->next ){
+ g_warning( "%s: %s", thisfn, ( const gchar * ) im->data );
+ }
+ na_utils_free_string_list( messages );
}
}
@@ -545,24 +570,24 @@ na_pivot_remove_item( NAPivot *pivot, NAObject *item )
* na_pivot_delete_item:
* @pivot: this #NAPivot instance.
* @item: the #NAObjectItem to be deleted from the storage subsystem.
- * @message: the I/O provider can allocate and store here an error
- * message.
+ * @messages: the I/O provider can allocate and store here its error
+ * messages.
*
* Deletes an action from the I/O storage subsystem.
*
* Returns: the #NAIIOProvider return code.
*/
guint
-na_pivot_delete_item( const NAPivot *pivot, const NAObject *item, gchar **message )
+na_pivot_delete_item( const NAPivot *pivot, const NAObjectItem *item, GSList **messages )
{
guint ret = NA_IIO_PROVIDER_NOT_WILLING_TO_WRITE;
g_return_val_if_fail( NA_IS_PIVOT( pivot ), NA_IIO_PROVIDER_PROGRAM_ERROR );
g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), NA_IIO_PROVIDER_PROGRAM_ERROR );
- g_return_val_if_fail( message, NA_IIO_PROVIDER_PROGRAM_ERROR );
+ g_return_val_if_fail( messages, NA_IIO_PROVIDER_PROGRAM_ERROR );
if( !pivot->private->dispose_has_run ){
- ret = na_iio_provider_delete_item( pivot, item, message );
+ ret = na_io_provider_delete_item( pivot, item, messages );
}
return( ret );
@@ -572,24 +597,24 @@ na_pivot_delete_item( const NAPivot *pivot, const NAObject *item, gchar **messag
* na_pivot_write_item:
* @pivot: this #NAPivot instance.
* @item: a #NAObjectItem to be written by the storage subsystem.
- * @message: the I/O provider can allocate and store here an error
- * message.
+ * @messages: the I/O provider can allocate and store here its error
+ * messages.
*
* Writes an item (an action or a menu).
*
* Returns: the #NAIIOProvider return code.
*/
guint
-na_pivot_write_item( const NAPivot *pivot, NAObject *item, gchar **message )
+na_pivot_write_item( const NAPivot *pivot, NAObjectItem *item, GSList **messages )
{
guint ret = NA_IIO_PROVIDER_NOT_WILLING_TO_WRITE;
g_return_val_if_fail( NA_IS_PIVOT( pivot ), NA_IIO_PROVIDER_PROGRAM_ERROR );
g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), NA_IIO_PROVIDER_PROGRAM_ERROR );
- g_return_val_if_fail( message, NA_IIO_PROVIDER_PROGRAM_ERROR );
+ g_return_val_if_fail( messages, NA_IIO_PROVIDER_PROGRAM_ERROR );
if( !pivot->private->dispose_has_run ){
- ret = na_iio_provider_write_item( pivot, item, message );
+ ret = na_io_provider_write_item( pivot, item, messages );
}
return( ret );
diff --git a/nautilus-actions/runtime/na-pivot.h b/nautilus-actions/runtime/na-pivot.h
index e7ea54a..e3da3e8 100644
--- a/nautilus-actions/runtime/na-pivot.h
+++ b/nautilus-actions/runtime/na-pivot.h
@@ -76,6 +76,7 @@
#include "na-object-class.h"
#include "na-object-id-class.h"
+#include "na-object-item-class.h"
#include "na-ipivot-consumer.h"
G_BEGIN_DECLS
@@ -119,8 +120,8 @@ void na_pivot_add_item( NAPivot *pivot, const NAObject *item );
NAObject *na_pivot_get_item( const NAPivot *pivot, const gchar *uuid );
void na_pivot_remove_item( NAPivot *pivot, NAObject *item );
-guint na_pivot_delete_item( const NAPivot *pivot, const NAObject *item, gchar **message );
-guint na_pivot_write_item( const NAPivot *pivot, NAObject *item, gchar **message );
+guint na_pivot_delete_item( const NAPivot *pivot, const NAObjectItem *item, GSList **messages );
+guint na_pivot_write_item( const NAPivot *pivot, NAObjectItem *item, GSList **messages );
void na_pivot_register_consumer( NAPivot *pivot, const NAIPivotConsumer *consumer );
diff --git a/nautilus-actions/test/Makefile.am b/nautilus-actions/test/Makefile.am
index d4ec998..fc89557 100644
--- a/nautilus-actions/test/Makefile.am
+++ b/nautilus-actions/test/Makefile.am
@@ -34,6 +34,7 @@ noinst_PROGRAMS = \
$(NULL)
AM_CPPFLAGS += \
+ -I $(top_srcdir) \
-I $(top_srcdir)/nautilus-actions \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DG_LOG_DOMAIN=\"${NA_LOGDOMAIN_TEST}\" \
@@ -59,7 +60,8 @@ test_parse_uris_SOURCES = \
$(NULL)
test_parse_uris_LDADD = \
- -L$(top_builddir)/nautilus-actions/runtime -lna-runtime \
+ -L$(top_builddir)/nautilus-actions/api -lna-api \
+ -L$(top_builddir)/nautilus-actions/runtime -lna-runtime \
$(NAUTILUS_ACTIONS_LIBS) \
$(NULL)
diff --git a/nautilus-actions/utils/Makefile.am b/nautilus-actions/utils/Makefile.am
index 26a6620..5acfd41 100644
--- a/nautilus-actions/utils/Makefile.am
+++ b/nautilus-actions/utils/Makefile.am
@@ -32,6 +32,7 @@ bin_PROGRAMS = \
$(NULL)
AM_CPPFLAGS += \
+ -I $(top_srcdir) \
-I $(top_srcdir)/nautilus-actions \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DG_LOG_DOMAIN=\"${NA_LOGDOMAIN_UTILS}\" \
@@ -46,7 +47,8 @@ nautilus_actions_new_SOURCES = \
nautilus_actions_new_LDADD = \
$(top_builddir)/nautilus-actions/common/libna-common.la \
- -L$(top_builddir)/nautilus-actions/runtime -lna-runtime \
+ -L$(top_builddir)/nautilus-actions/api -lna-api \
+ -L$(top_builddir)/nautilus-actions/runtime -lna-runtime \
$(NAUTILUS_ACTIONS_LIBS) \
$(NULL)
@@ -58,6 +60,7 @@ nautilus_actions_schemas_SOURCES = \
nautilus_actions_schemas_LDADD = \
$(top_builddir)/nautilus-actions/common/libna-common.la \
- -L$(top_builddir)/nautilus-actions/runtime -lna-runtime \
+ -L$(top_builddir)/nautilus-actions/api -lna-api \
+ -L$(top_builddir)/nautilus-actions/runtime -lna-runtime \
$(NAUTILUS_ACTIONS_LIBS) \
$(NULL)
diff --git a/nautilus-actions/utils/nautilus-actions-new.c b/nautilus-actions/utils/nautilus-actions-new.c
index 63c05a8..cb2484d 100644
--- a/nautilus-actions/utils/nautilus-actions-new.c
+++ b/nautilus-actions/utils/nautilus-actions-new.c
@@ -36,8 +36,10 @@
#include <glib/gi18n.h>
#include <stdlib.h>
+#include <api/na-iio-provider.h>
+
+#include <runtime/na-io-provider.h>
#include <runtime/na-gconf-provider.h>
-#include <runtime/na-iio-provider.h>
#include <common/na-iprefs.h>
#include <common/na-object-api.h>
@@ -369,18 +371,12 @@ write_to_gconf( NAObjectAction *action, GSList **msg )
{
NAGConfProvider *gconf;
guint ret;
- gchar *str;
gconf = na_gconf_provider_new( NULL );
na_object_set_provider( action, NA_IIO_PROVIDER( gconf ));
- str = NULL;
- ret = na_iio_provider_write_item( NULL, NA_OBJECT( action ), &str );
- if( str ){
- *msg = g_slist_append( *msg, str );
- g_free( str );
- }
+ ret = na_io_provider_write_item( NULL, NA_OBJECT_ITEM( action ), msg );
return( ret == NA_IIO_PROVIDER_WRITE_OK );
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]