Commit 511e2802 authored by Pierre Wieser's avatar Pierre Wieser

Move NAIIOProvider interface to api/

Introducing runtime/na-io-provider.{c,h} to handle internal API to NAIIOProvider interface.
parent 3c94be52
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.
......
......@@ -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 = \
......
......@@ -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.
......
......@@ -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
......
/*
* 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 )
{
}
......@@ -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__ */
......@@ -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}\" \
......
......@@ -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)
......
......@@ -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>
......
......@@ -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>
......
......@@ -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 );
......
......@@ -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 );
......
......@@ -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) \
......
......@@ -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 \
......
......@@ -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,