[nautilus-actions] Globally rename preferences
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Globally rename preferences
- Date: Wed, 19 Jan 2011 21:53:05 +0000 (UTC)
commit c2a27576f50a6db65ff15779bf7b6e3860b32d7f
Author: Pierre Wieser <pwieser trychlos org>
Date: Fri Jan 14 01:21:30 2011 +0100
Globally rename preferences
ChangeLog | 50 ++
README-GCONF | 12 +-
src/api/na-iio-provider.h | 11 +-
src/core/na-export-format.h | 1 +
src/core/na-exporter.h | 2 +-
src/core/na-importer-ask.h | 10 +-
src/core/na-importer.c | 18 +-
src/core/na-io-provider.c | 1220 +++++++++++++++++++--------------
src/core/na-io-provider.h | 68 +-
src/core/na-iprefs.c | 147 ++++-
src/core/na-iprefs.h | 21 +-
src/core/na-module.c | 3 +-
src/core/na-pivot.c | 233 ++-----
src/core/na-pivot.h | 41 +-
src/core/na-settings.c | 101 +++-
src/core/na-settings.h | 15 +-
src/core/na-updater.c | 32 +-
src/nact/nact-add-capability-dialog.c | 4 +-
src/nact/nact-add-scheme-dialog.c | 4 +-
src/nact/nact-assistant-export.c | 29 +-
src/nact/nact-assistant-import.c | 55 +-
src/nact/nact-clipboard.c | 2 +-
src/nact/nact-export-ask.c | 8 +-
src/nact/nact-gtk-utils.c | 12 +-
src/nact/nact-iactions-list.c | 8 +-
src/nact/nact-icommand-tab.c | 26 +-
src/nact/nact-icon-chooser.c | 19 +-
src/nact/nact-ienvironment-tab.c | 17 +-
src/nact/nact-ifolders-tab.c | 13 +-
src/nact/nact-iprefs.c | 2 +-
src/nact/nact-iprefs.h | 12 -
src/nact/nact-main-menubar-edit.c | 15 +-
src/nact/nact-main-menubar-file.c | 12 +-
src/nact/nact-main-menubar.c | 2 +-
src/nact/nact-main-toolbar.c | 10 +-
src/nact/nact-main-window.c | 18 +-
src/nact/nact-preferences-editor.c | 61 +-
src/nact/nact-providers-list.c | 54 +-
src/nact/nact-schemes-list.c | 10 +-
src/nact/nact-sort-buttons.c | 5 +-
src/nact/nact-tree-model-dnd.c | 8 +-
src/nact/nact-tree-model.c | 2 +-
src/nact/nact-window.c | 8 +-
src/nact/nact-window.h | 2 +
src/plugin-menu/nautilus-actions.c | 19 +-
src/utils/na-gconf2key.sh.in | 11 +-
src/utils/nautilus-actions-new.c | 7 +-
47 files changed, 1386 insertions(+), 1054 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d0a2d38..47b36a6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -29,6 +29,56 @@
* src/utils/nautilus-actions-run.c:
* src/utils/nautilus-actions-schemas.c: Add locale.h include.
+ Global renaming of preferences.
+
+ * README-GCONF:
+ * src/api/na-iio-provider.h:
+ * src/core/na-export-format.h:
+ * src/core/na-exporter.h:
+ * src/core/na-importer-ask.h:
+ * src/core/na-importer.c:
+ * src/core/na-io-provider.c:
+ * src/core/na-io-provider.h:
+ * src/core/na-iprefs.c:
+ * src/core/na-iprefs.h:
+ * src/core/na-module.c:
+ * src/core/na-pivot.c:
+ * src/core/na-pivot.h:
+ * src/core/na-settings.c:
+ * src/core/na-settings.h:
+ * src/core/na-updater.c:
+ * src/nact/nact-add-capability-dialog.c:
+ * src/nact/nact-add-scheme-dialog.c:
+ * src/nact/nact-assistant-export.c:
+ * src/nact/nact-assistant-import.c:
+ * src/nact/nact-clipboard.c:
+ * src/nact/nact-export-ask.c:
+ * src/nact/nact-gtk-utils.c:
+ * src/nact/nact-iactions-list.c:
+ * src/nact/nact-icommand-tab.c:
+ * src/nact/nact-icon-chooser.c:
+ * src/nact/nact-ienvironment-tab.c:
+ * src/nact/nact-ifolders-tab.c:
+ * src/nact/nact-iprefs.c:
+ * src/nact/nact-iprefs.h:
+ * src/nact/nact-main-menubar-edit.c:
+ * src/nact/nact-main-menubar-file.c:
+ * src/nact/nact-main-menubar.c:
+ * src/nact/nact-main-toolbar.c:
+ * src/nact/nact-main-window.c:
+ * src/nact/nact-preferences-editor.c:
+ * src/nact/nact-providers-list.c:
+ * src/nact/nact-schemes-list.c:
+ * src/nact/nact-sort-buttons.c:
+ * src/nact/nact-tree-model-dnd.c:
+ * src/nact/nact-tree-model.c:
+ * src/nact/nact-window.c:
+ * src/nact/nact-window.h:
+ * src/plugin-menu/nautilus-actions.c:
+ * src/utils/na-gconf2key.sh.in:
+ * src/utils/nautilus-actions-new.c: Rename preferences.
+>>>>>>> Globally rename preferences
+
2011-01-13 Pierre Wieser <pwieser trychlos org>
* src/core/na-settings.c:
diff --git a/README-GCONF b/README-GCONF
index 4e3a2eb..258aaef 100644
--- a/README-GCONF
+++ b/README-GCONF
@@ -129,7 +129,7 @@ Deprecating GConf
na-gconf/locked
These keys are just ignored if they are not in the mandatory GConf pool, i.e.
- if they happends to be eventually editable by the user.
+ if they happens to be eventually editable by the user.
If these keys are actually in the system mandatory GConf pool, they are renamed
in the following way:
@@ -137,10 +137,10 @@ Deprecating GConf
GConf Group Key
----------------------------------------- ------ --------------------------------------
/apps/nautilus-actions/mandatory/all/locked
- [nact] io-providers-all-locked
- /apps/nautilus-actions/mandatory/na-desktop/locked
- [io-provider na-desktop] locked
- /apps/nautilus-actions/mandatory/na-gconf/locked
- [io-provider na-gconf] locked
+ [runtime] preferences-locked
+ [runtime] io-providers-locked
+
+ /apps/nautilus-actions/mandatory/na-desktop/locked <removed>
+ /apps/nautilus-actions/mandatory/na-gconf/locked <removed>
P. Wieser - Jan. 2011
diff --git a/src/api/na-iio-provider.h b/src/api/na-iio-provider.h
index de8022a..07cd6f0 100644
--- a/src/api/na-iio-provider.h
+++ b/src/api/na-iio-provider.h
@@ -45,12 +45,12 @@
* <itemizedlist>
* <listitem>
* <para>
- * load all items at startup;
+ * load items;
* </para>
* </listitem>
* <listitem>
* <para>
- * create, update or delete items via the management user interface;
+ * create, update or delete items;
* </para>
* </listitem>
* <listitem>
@@ -58,6 +58,13 @@
* inform &prodname; when an item has been modified on the
* underlying storage subsystem.
* </para>
+ * <para>
+ * The #NAIIOProvider interface does not define specific monitoring
+ * methods. Instead, it is waited that the I/O provider module
+ * automatically takes care of starting/stopping its own monitoring
+ * at load/unload time, calling the na_iio_provider_item_changed()
+ * function when appropriate.
+ * </para>
* </listitem>
* </itemizedlist>
*
diff --git a/src/core/na-export-format.h b/src/core/na-export-format.h
index a9a9e05..43e4f1e 100644
--- a/src/core/na-export-format.h
+++ b/src/core/na-export-format.h
@@ -64,6 +64,7 @@ typedef struct {
NAExportFormatClass;
#define IPREFS_EXPORT_FORMAT_ASK g_quark_from_static_string( "Ask" )
+#define IPREFS_EXPORT_NO_EXPORT 1
GType na_export_format_get_type( void );
diff --git a/src/core/na-exporter.h b/src/core/na-exporter.h
index 3a858b5..d4154ec 100644
--- a/src/core/na-exporter.h
+++ b/src/core/na-exporter.h
@@ -38,7 +38,7 @@
#include <api/na-object-api.h>
-#include <core/na-pivot.h>
+#include "na-pivot.h"
G_BEGIN_DECLS
diff --git a/src/core/na-importer-ask.h b/src/core/na-importer-ask.h
index 0222810..cb26b76 100644
--- a/src/core/na-importer-ask.h
+++ b/src/core/na-importer-ask.h
@@ -73,11 +73,11 @@ typedef struct {
NAImporterAskClass;
typedef struct {
- GtkWindow *parent;
- gchar *uri;
- guint count;
- gboolean keep_choice;
- NAPivot *pivot;
+ GtkWindow *parent;
+ gchar *uri;
+ guint count;
+ gboolean keep_choice;
+ const NAPivot *pivot;
}
NAImporterAskUserParms;
diff --git a/src/core/na-importer.c b/src/core/na-importer.c
index a6ca2ab..44240a4 100644
--- a/src/core/na-importer.c
+++ b/src/core/na-importer.c
@@ -72,17 +72,17 @@ static guint ask_user_for_mode( const NAObjectItem *importing, const NAO
* - a #NAObjectItem item if import was successfull, or %NULL
* - a list of error messages, or %NULL.
*
- * Returns: the last import operation code.
- */
-/*
- * Importing a list of URIs:
- * if asked mode is 'ask', then ask the user at least the first time
+ * If asked mode is 'ask', then ask the user at least the first time
* the 'keep my choice' is active or not, depending of the last time used
* then the 'keep my chose' is kept for other times
* so preferences are:
* - asked import mode (may be 'ask') -> import-mode
* - keep my choice -> import-keep-choice
* - last choosen import mode -> import-ask-user-last-mode
+ *
+ * Returns: the last import operation code.
+ *
+ * Since: 2.30
*/
guint
na_importer_import_from_list( const NAPivot *pivot, NAImporterParms *parms )
@@ -151,7 +151,8 @@ import_from_uri( const NAPivot *pivot, GList *modules, NAImporterParms *parms, c
ask_parms.parent = parms->parent;
ask_parms.uri = ( gchar * ) uri;
ask_parms.count = g_list_length( parms->results );
- ask_parms.keep_choice = na_iprefs_read_bool( NA_IPREFS( pivot ), IPREFS_IMPORT_KEEP_CHOICE, FALSE );
+ ask_parms.keep_choice = na_settings_get_boolean( na_pivot_get_settings( pivot ), NA_IPREFS_IMPORT_MODE_KEEP_LAST_CHOICE, NULL, NULL );
+ ask_parms.pivot = pivot;
memset( &provider_parms, '\0', sizeof( NAIImporterImportFromUriParms ));
provider_parms.version = 1;
@@ -223,15 +224,12 @@ static guint
ask_user_for_mode( const NAObjectItem *importing, const NAObjectItem *existing, NAImporterAskUserParms *parms )
{
guint mode;
- GConfClient *gconf;
if( parms->count == 0 || !parms->keep_choice ){
mode = na_importer_ask_user( importing, existing, parms );
} else {
- gconf = gconf_client_get_default();
- mode = na_iprefs_get_import_mode( gconf, IPREFS_IMPORT_ASK_LAST_MODE );
- g_object_unref( gconf );
+ mode = na_iprefs_get_import_mode( parms->pivot, NA_IPREFS_IMPORT_ASK_USER_LAST_MODE );
}
return( mode );
diff --git a/src/core/na-io-provider.c b/src/core/na-io-provider.c
index 57fa4ed..07e0fff 100644
--- a/src/core/na-io-provider.c
+++ b/src/core/na-io-provider.c
@@ -38,8 +38,8 @@
#include <api/na-iio-provider.h>
#include <api/na-object-api.h>
#include <api/na-core-utils.h>
-#include <api/na-gconf-utils.h>
+#include "na-iprefs.h"
#include "na-io-provider.h"
/* private class data
@@ -53,7 +53,6 @@ struct _NAIOProviderClassPrivate {
struct _NAIOProviderPrivate {
gboolean dispose_has_run;
gchar *id;
- gchar *name;
NAIIOProvider *provider;
gulong item_changed_handler;
};
@@ -78,20 +77,22 @@ static void instance_set_property( GObject *object, guint property_id, const G
static void instance_dispose( GObject *object );
static void instance_finalize( GObject *object );
-static void setup_io_providers( const NAPivot *pivot, GSList *priority );
-static GList *allocate_ordered_providers( GSList *priority );
-static GList *merge_available_io_providers( const NAPivot *pivot, GList *ordered_providers );
-static void io_provider_set_provider( NAIOProvider *provider, NAIIOProvider *instance, const NAPivot *pivot );
-static GList *add_io_providers_from_prefs( const NAPivot *pivot, GList *runtime_providers );
-
-static void dump( const NAIOProvider *provider );
-
-static GList *get_merged_items_list( const NAPivot *pivot, GList *providers, GSList **messages );
-static GList *build_hierarchy( GList **tree, GSList *level_zero, gboolean list_if_empty, NAObjectItem *parent );
-static gint search_item( const NAObject *obj, const gchar *id );
-static GList *sort_tree( const NAPivot *pivot, GList *tree, GCompareFunc fn );
-static GList *filter_unwanted_items( const NAPivot *pivot, GList *merged );
-static GList *filter_unwanted_items_rec( GList *merged, gboolean load_disabled, gboolean load_invalid );
+#if 0
+static void dump( const NAIOProvider *provider );
+static void dump_providers_list( GList *providers );
+#endif
+static NAIOProvider *io_provider_new( const NAPivot *pivot, NAIIOProvider *module, const gchar *id );
+static GList *io_providers_list_add_from_plugins( const NAPivot *pivot, GList *list );
+static GList *io_providers_list_add_from_prefs( const NAPivot *pivot, GList *objects_list );
+static GList *io_providers_list_add_object( const NAPivot *pivot, GList *list, NAIIOProvider *module, const gchar *id );
+static gboolean is_really_writable( const NAIOProvider *provider, const NAPivot *pivot );
+static GList *load_items_filter_unwanted_items( const NAPivot *pivot, GList *merged, guint loadable_set );
+static GList *load_items_filter_unwanted_items_rec( GList *merged, guint loadable_set );
+static GList *load_items_get_merged_list( const NAPivot *pivot, guint loadable_set, GSList **messages );
+static GList *load_items_hierarchy_build( GList **tree, GSList *level_zero, gboolean list_if_empty, NAObjectItem *parent );
+static GList *load_items_hierarchy_sort( const NAPivot *pivot, GList *tree, GCompareFunc fn );
+static gint peek_item_by_id_compare( const NAObject *obj, const gchar *id );
+static NAIOProvider *peek_provider_by_id( const GList *providers, const gchar *id );
GType
na_io_provider_get_type( void )
@@ -151,7 +152,7 @@ class_init( NAIOProviderClass *klass )
spec = g_param_spec_string(
IO_PROVIDER_PROP_ID,
"I/O Provider Id",
- "Internal identifiant of the I/O provider", "",
+ "Internal identifier of the I/O provider (e.g. 'na-gconf')", "",
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
g_object_class_install_property( object_class, IO_PROVIDER_PROP_ID_ID, spec );
@@ -175,7 +176,6 @@ instance_init( GTypeInstance *instance, gpointer klass )
self->private->dispose_has_run = FALSE;
self->private->id = NULL;
- self->private->name = NULL;
self->private->provider = NULL;
self->private->item_changed_handler = 0;
}
@@ -192,7 +192,7 @@ instance_constructed( GObject *object )
if( !self->private->dispose_has_run ){
- g_debug( "%s: object=%p", thisfn, ( void * ) object );
+ g_debug( "%s: object=%p, id=%s", thisfn, ( void * ) object, self->private->id );
/* chain up to the parent class */
if( G_OBJECT_CLASS( st_parent_class )->constructed ){
@@ -258,11 +258,9 @@ instance_dispose( GObject *object )
self->private->dispose_has_run = TRUE;
if( self->private->provider ){
-
if( g_signal_handler_is_connected( self->private->provider, self->private->item_changed_handler )){
g_signal_handler_disconnect( self->private->provider, self->private->item_changed_handler );
}
-
g_object_unref( self->private->provider );
}
@@ -285,7 +283,6 @@ instance_finalize( GObject *object )
g_debug( "%s: object=%p", thisfn, ( void * ) object );
g_free( self->private->id );
- g_free( self->private->name );
g_free( self->private );
@@ -296,330 +293,323 @@ instance_finalize( GObject *object )
}
/*
- * na_io_provider_terminate:
+ * na_io_provider_find_writable_io_provider:
+ * @pivot: the #NAPivot instance.
*
- * Called by on #NAPivot dispose(), free here resources allocated to
- * the I/O providers.
+ * Returns: the first willing and able to write I/O provider, or NULL.
+ *
+ * The returned provider is owned by NAIOProvider class, and should not
+ * be released by the caller.
*/
-void
-na_io_provider_terminate( void )
+NAIOProvider *
+na_io_provider_find_writable_io_provider( const NAPivot *pivot )
{
- g_list_foreach( st_io_providers, ( GFunc ) g_object_unref, NULL );
- g_list_free( st_io_providers );
- st_io_providers = NULL;
+ const GList *providers;
+ const GList *ip;
+ NAIOProvider *provider;
+
+ providers = na_io_provider_get_io_providers_list( pivot );
+ provider = NULL;
+
+ for( ip = providers ; ip && !provider ; ip = ip->next ){
+ if( is_really_writable( NA_IO_PROVIDER( ip->data ), pivot )){
+ provider = NA_IO_PROVIDER( ip->data );
+ }
+ }
+
+ return( provider );
}
/*
- * na_io_provider_get_providers_list:
+ * na_io_provider_get_io_providers_list:
* @pivot: the current #NAPivot instance.
*
- * Returns: the list of I/O providers for @pivot.
+ * Build (if not already done) the unordered list of currently avialable
+ * NAIOProvider objects.
+ *
+ * A NAIOProvider object may be created:
+ * - either because we have loaded a plugin which claims to implement the
+ * NAIIOProvider interface;
+ * - or because an i/o provider identifier has been found in preferences.
+ *
+ * The order of objects in this list is not relevant:
+ * - when loading items, items are ordered depending of menus items list
+ * and of level zero defined order;
+ * - when writing a new item, there is a 'writable-order' preference.
+ *
+ * Returns: the list of I/O providers.
*
* The returned list is owned by #NAIOProvider class, and should not be
* released by the caller.
*/
-GList *
-na_io_provider_get_providers_list( const NAPivot *pivot )
+const GList *
+na_io_provider_get_io_providers_list( const NAPivot *pivot )
{
- static const gchar *thisfn = "na_io_provider_get_providers_list";
- GSList *order;
-
g_return_val_if_fail( NA_IS_PIVOT( pivot ), NULL );
if( !st_io_providers ){
-
- order = na_iprefs_read_string_list( NA_IPREFS( pivot ), IO_PROVIDER_KEY_ORDER, NULL );
-
- if( g_slist_length( order ) > 0 ){
- g_debug( "%s: dumping providers order", thisfn );
-
- } else {
- g_debug( "%s: initializing empty list with default I/O provider", thisfn );
- order = g_slist_append( order, g_strdup( NA_DEFAULT_IO_PROVIDER ));
- }
-
- na_core_utils_slist_dump( thisfn, order );
-
- setup_io_providers( pivot, order );
- na_core_utils_slist_free( order );
+ st_io_providers = io_providers_list_add_from_plugins( pivot, NULL );
+ st_io_providers = io_providers_list_add_from_prefs( pivot, st_io_providers );
}
return( st_io_providers );
}
/*
- * @priority: the internal ids of IO providers in descending order of
- * priority for writing new elements, as a string list
+ * na_io_provider_unref_io_providers_list:
*
- * build the static list of I/O providers, depending of setup of NAPivot
- * doing required initializations
+ * Called by on #NAPivot dispose(), free here resources allocated to
+ * the I/O providers.
*/
-static void
-setup_io_providers( const NAPivot *pivot, GSList *priority )
+void
+na_io_provider_unref_io_providers_list( void )
{
- GList *ordered_providers;
- GList *merged_providers;
- GList *all_providers;
-
- g_return_if_fail( st_io_providers == NULL );
-
- /* allocate the ordered list */
- ordered_providers = allocate_ordered_providers( priority );
-
- /* merge with available I/O providers */
- merged_providers = merge_available_io_providers( pivot, ordered_providers );
-
- /* add providers found in prefs */
- all_providers = add_io_providers_from_prefs( pivot, merged_providers );
-
- st_io_providers = all_providers;
+ g_list_foreach( st_io_providers, ( GFunc ) g_object_unref, NULL );
+ g_list_free( st_io_providers );
+ st_io_providers = NULL;
}
-static GList *
-allocate_ordered_providers( GSList *priority )
+/*
+ * na_io_provider_get_id:
+ * @provider: this #NAIOProvider.
+ *
+ * Returns: the internal id of this #NAIIOProvider, as a newly
+ * allocated string which should be g_free() by the caller.
+ */
+gchar *
+na_io_provider_get_id( const NAIOProvider *provider )
{
- GSList *ip;
- NAIOProvider *provider;
- GList *providers;
+ gchar *id;
- providers = NULL;
+ g_return_val_if_fail( NA_IS_IO_PROVIDER( provider ), NULL );
- for( ip = priority ; ip ; ip = ip->next ){
+ id = NULL;
- provider = g_object_new( NA_IO_PROVIDER_TYPE, IO_PROVIDER_PROP_ID, ( const gchar * ) ip->data, NULL );
- providers = g_list_prepend( providers, provider );
+ if( !provider->private->dispose_has_run ){
+
+ id = g_strdup( provider->private->id );
}
- return( g_list_reverse( providers ));
+ return( id );
}
/*
- * merge the ordered list of I/O providers (which have only Id)
- * with those found available at runtime
+ * na_io_provider_get_name:
+ * @provider: this #NAIOProvider.
+ *
+ * Returns: the displayable name of this #NAIIOProvider, as a newly
+ * allocated string which should be g_free() by the caller.
+ *
+ * This function makes sure to never return %NULL. An empty string
+ * may be returned if the NAIIOProvider is not present at runtime,
+ * or does not implement the needed interface, or returns itself %NULL
+ * or an empty string.
*/
-static GList *
-merge_available_io_providers( const NAPivot *pivot, GList *ordered )
+gchar *
+na_io_provider_get_name( const NAIOProvider *provider )
{
- static const gchar *thisfn = "na_io_provider_merge_available_io_providers";
- GList *merged;
- GList *module_objects, *im;
- gchar *id;
- NAIOProvider *provider;
-
- merged = ordered;
-
- module_objects = na_pivot_get_providers( pivot, NA_IIO_PROVIDER_TYPE );
- for( im = module_objects ; im ; im = im->next ){
-
- id = NULL;
- if( NA_IIO_PROVIDER_GET_INTERFACE( NA_IIO_PROVIDER( im->data ))->get_id ){
- id = NA_IIO_PROVIDER_GET_INTERFACE( NA_IIO_PROVIDER( im->data ))->get_id( NA_IIO_PROVIDER( im->data ));
+ static const gchar *thisfn = "na_io_provider_get_name";
+ gchar *name;
- } else {
- g_warning( "%s: NAIIOProvider %p doesn't support get_id() interface", thisfn, ( void * ) im->data );
- }
+ name = g_strdup( "" );
- provider = NULL;
- if( id ){
- provider = na_io_provider_find_provider_by_id( merged, id );
+ g_return_val_if_fail( NA_IS_IO_PROVIDER( provider ), name );
- if( !provider ){
- g_debug( "%s: no provider already allocated in ordered list for id=%s", thisfn, id );
- provider = g_object_new( NA_IO_PROVIDER_TYPE, IO_PROVIDER_PROP_ID, id, NULL );
- merged = g_list_append( merged, provider );
+ if( !provider->private->dispose_has_run ){
- } else {
- g_debug( "%s: found NAIOProvider=%p (NAIIOProvider=%p) for id=%s",
- thisfn, ( void * ) provider, ( void * ) im->data, id );
+ if( NA_IIO_PROVIDER_GET_INTERFACE( provider->private->provider )->get_name ){
+ g_free( name );
+ name = NULL;
+ name = NA_IIO_PROVIDER_GET_INTERFACE( provider->private->provider )->get_name( provider->private->provider );
+ if( !name ){
+ g_warning( "%s: NAIIOProvider %s get_name() interface returns NULL", thisfn, provider->private->id );
+ name = g_strdup( "" );
}
- io_provider_set_provider( provider, NA_IIO_PROVIDER( im->data ), pivot );
-
- g_free( id );
+ } else {
+ g_warning( "%s: NAIIOProvider %s doesn't support get_name() interface", thisfn, provider->private->id );
}
}
- na_pivot_free_providers( module_objects );
-
- return( merged );
+ return( name );
}
-static void
-io_provider_set_provider( NAIOProvider *provider, NAIIOProvider *instance, const NAPivot *pivot )
+/*
+ * na_io_provider_is_available:
+ * @provider: the #NAIOProvider object.
+ *
+ * Returns: %TRUE if the corresponding #NAIIOProvider module is available
+ * at runtime, %FALSE else.
+ */
+gboolean
+na_io_provider_is_available( const NAIOProvider *provider )
{
- static const gchar *thisfn = "na_io_provider_set_provider";
+ gboolean is_available;
- g_return_if_fail( NA_IS_IO_PROVIDER( provider ));
- g_return_if_fail( NA_IS_IIO_PROVIDER( instance ));
+ g_return_val_if_fail( NA_IS_IO_PROVIDER( provider ), FALSE );
- provider->private->provider = g_object_ref( instance );
+ is_available = FALSE;
- if( NA_IIO_PROVIDER_GET_INTERFACE( instance )->get_name ){
- provider->private->name = NA_IIO_PROVIDER_GET_INTERFACE( instance )->get_name( instance );
- } else {
- g_warning( "%s: NAIIOProvider %p doesn't support get_name() interface", thisfn, ( void * ) instance );
+ if( !provider->private->dispose_has_run ){
+
+ is_available = ( provider->private->provider && NA_IS_IIO_PROVIDER( provider->private->provider ));
}
- provider->private->item_changed_handler =
- g_signal_connect(
- instance,
- IO_PROVIDER_SIGNAL_ITEM_CHANGED,
- ( GCallback ) na_pivot_item_changed_handler,
- ( gpointer ) pivot );
+ return( is_available );
}
-static GList *
-add_io_providers_from_prefs( const NAPivot *pivot, GList *runtime_providers )
+/*
+ * na_io_provider_is_conf_readable:
+ * @provider: this #NAIOProvider.
+ * @pivot: the #NAPivot application object.
+ *
+ * Returns: %TRUE is this I/O provider should be read at startup, and so
+ * may participate to the global list of menus and actions, %FALSE else.
+ *
+ * This is a configuration property, which defaults to %TRUE.
+ *
+ * Whether it is editable by the user or not depends on:
+ * - whether the whole configuration has been locked down by an admin;
+ * - whether this flag has been set as mandatory by an admin.
+ */
+gboolean
+na_io_provider_is_conf_readable( const NAIOProvider *provider, const NAPivot *pivot )
{
- GConfClient *gconf;
- gchar *path, *id;
- GSList *ids, *iid;
- GList *providers;
- NAIOProvider *provider;
+ gboolean readable;
+ gchar *group;
- providers = runtime_providers;
- path = gconf_concat_dir_and_key( IPREFS_GCONF_BASEDIR, IO_PROVIDER_KEY_ROOT );
- gconf = na_iprefs_get_gconf_client( NA_IPREFS( pivot ));
+ g_return_val_if_fail( NA_IS_IO_PROVIDER( provider ), FALSE );
+ g_return_val_if_fail( NA_IS_PIVOT( pivot ), FALSE );
- ids = na_gconf_utils_get_subdirs( gconf, path );
+ readable = FALSE;
- for( iid = ids ; iid ; iid = iid->next ){
- id = g_path_get_basename(( const gchar * ) iid->data );
- provider = na_io_provider_find_provider_by_id( providers, id );
-
- if( !provider ){
- provider = g_object_new( NA_IO_PROVIDER_TYPE, IO_PROVIDER_PROP_ID, id, NULL );
- providers = g_list_append( providers, provider );
- }
+ if( !provider->private->dispose_has_run ){
- g_free( id );
+ group = g_strdup_printf( "%s %s", NA_IPREFS_IO_PROVIDER_GROUP, provider->private->id );
+ readable = na_settings_get_boolean_ex(
+ na_pivot_get_settings( pivot ), group, NA_IPREFS_IO_PROVIDER_READABLE, NULL, NULL );
+ g_free( group );
}
- na_gconf_utils_free_subdirs( ids );
- g_free( path );
-
- return( providers );
+ return( readable );
}
/*
- * na_io_provider_reorder_providers_list:
- * @pivot: the #NAPivot instance of the application.
+ * na_io_provider_is_able_to_write:
+ * @provider: this #NAIOProvider.
*
- * Reorder our global list of #NAIOProviders,after the user has reordered
- * them in user preferences.
+ * Whether the NAIIOProvider is able to write is a runtime condition.
+ *
+ * Returns: %TRUE is this I/O provider is able to write.
*/
-void
-na_io_provider_reorder_providers_list( const NAPivot *pivot )
+gboolean
+na_io_provider_is_able_to_write( const NAIOProvider *provider )
{
- GSList *order, *io;
- GList *new_list;
- NAIOProvider *provider;
+ gboolean is_able_to;
- new_list = NULL;
- order = na_iprefs_read_string_list( NA_IPREFS( pivot ), IO_PROVIDER_KEY_ORDER, NULL );
+ g_return_val_if_fail( NA_IS_IO_PROVIDER( provider ), FALSE );
- for( io = order ; io ; io = io->next ){
- provider = na_io_provider_find_provider_by_id( st_io_providers, ( const gchar * ) io->data );
- if( provider ){
- st_io_providers = g_list_remove( st_io_providers, provider );
- new_list = g_list_prepend( new_list, provider );
- }
- }
+ is_able_to = FALSE;
- st_io_providers = g_list_reverse( new_list );
+ if( !provider->private->dispose_has_run ){
- na_core_utils_slist_free( order );
-}
+ if( provider->private->provider ){
-/*
- * na_io_provider_dump_providers_list:
- * @providers: the list of #NAIOProvider to be dumped.
- *
- * Dumps the list of #NAIOProvider to debug output stream.
- */
-void
-na_io_provider_dump_providers_list( GList *providers )
-{
- static const gchar *thisfn = "na_io_provider_dump_providers_list";
- GList *ip;
+ g_return_val_if_fail( NA_IS_IIO_PROVIDER( provider->private->provider ), FALSE );
- g_debug( "%s: providers=%p (count=%d)", thisfn, ( void * ) providers, g_list_length( providers ));
+ if( NA_IIO_PROVIDER_GET_INTERFACE( provider->private->provider )->is_able_to_write ){
- for( ip = providers ; ip ; ip = ip->next ){
- dump( NA_IO_PROVIDER( ip->data ));
+ is_able_to = NA_IIO_PROVIDER_GET_INTERFACE( provider->private->provider )->is_able_to_write( provider->private->provider );
+ }
+ }
}
-}
-static void
-dump( const NAIOProvider *provider )
-{
- static const gchar *thisfn = "na_io_provider_dump";
-
- g_debug( "%s: id=%s", thisfn, provider->private->id );
- g_debug( "%s: name=%s", thisfn, provider->private->name );
- g_debug( "%s: provider=%p", thisfn, ( void * ) provider->private->provider );
- g_debug( "%s: item_changed_handler=%lu", thisfn, provider->private->item_changed_handler );
+ return( is_able_to );
}
/*
- * na_io_provider_find_provider_by_id:
- * @providers: the current list of #NAIOProvider.
- * @id: the searched internal id.
+ * na_io_provider_is_conf_writable:
+ * @provider: this #NAIOProvider.
+ * @pivot: the #NAPivot application object.
*
- * Returns: the searched #NAIOProvider, or %NULL if not found.
+ * Returns: %TRUE is this I/O provider is candidate to be edited.
*
- * The returned object is owned by #NAIOProvider class, and should not
- * be g_object_unref() by the user.
+ * This is a configuration property, which defaults to %TRUE.
+ *
+ * Whether it is editable by the user or not depends on:
+ * - whether the whole configuration has been locked down by an admin;
+ * - whether this flag has been set as mandatory by an admin.
+ *
+ * This property does not say that an item can actually be written by this
+ * NAIIOProvider module. See also is_willing_to() and is_able_to().
*/
-NAIOProvider *
-na_io_provider_find_provider_by_id( GList *providers, const gchar *id )
+gboolean
+na_io_provider_is_conf_writable( const NAIOProvider *provider, const NAPivot *pivot )
{
- NAIOProvider *provider;
- GList *ip;
+ gboolean is_writable;
+ gchar *group;
- provider = NULL;
+ g_return_val_if_fail( NA_IS_IO_PROVIDER( provider ), FALSE );
+ g_return_val_if_fail( NA_IS_PIVOT( pivot ), FALSE );
- for( ip = providers ; ip && !provider ; ip = ip->next ){
+ is_writable = FALSE;
- if( !strcmp( NA_IO_PROVIDER( ip->data )->private->id, id )){
+ if( !provider->private->dispose_has_run ){
- provider = NA_IO_PROVIDER( ip->data );
- }
+ group = g_strdup_printf( "%s %s", NA_IPREFS_IO_PROVIDER_GROUP, provider->private->id );
+ is_writable = na_settings_get_boolean_ex(
+ na_pivot_get_settings( pivot ), group, NA_IPREFS_IO_PROVIDER_WRITABLE, NULL, NULL );
+ g_free( group );
}
- return( provider );
+ return( is_writable );
}
/*
- * na_io_provider_get_writable_provider:
- * @pivot: the #NAPivot instance.
+ * na_io_provider_is_willing_to_write:
+ * @provider: this #NAIOProvider.
*
- * Returns: the first willing and able to write I/O provider, or NULL.
+ * The 'willing_to_write' property is an intrinsic attribute of the NAIIOProvider
+ * module. It depends on:
+ * - whether it provides a 'willing_to_write' api which returns %TRUE (defaults
+ * to %FALSE)
+ * - whether it has the needed API (is_able_to_write, write_item, delete_item)
*
- * The returned provider should not be g_object_unref() by the caller.
+ * Returns: %TRUE is this I/O provider is willing to write.
*/
-NAIOProvider *
-na_io_provider_get_writable_provider( const NAPivot *pivot )
+gboolean
+na_io_provider_is_willing_to_write( const NAIOProvider *provider )
{
- NAIOProvider *provider;
- GList *providers, *ip;
+ gboolean is_willing_to;
- providers = na_io_provider_get_providers_list( pivot );
- provider = NULL;
+ g_return_val_if_fail( NA_IS_IO_PROVIDER( provider ), FALSE );
- for( ip = providers ; ip && !provider ; ip = ip->next ){
- if( na_io_provider_are_writings_authorized( NA_IO_PROVIDER( ip->data ), pivot )){
- provider = NA_IO_PROVIDER( ip->data );
+ is_willing_to = FALSE;
+
+ if( !provider->private->dispose_has_run &&
+ provider->private->provider ){
+
+ g_return_val_if_fail( NA_IS_IIO_PROVIDER( provider->private->provider ), FALSE );
+
+ if( NA_IIO_PROVIDER_GET_INTERFACE( provider->private->provider )->is_willing_to_write &&
+ NA_IIO_PROVIDER_GET_INTERFACE( provider->private->provider )->is_willing_to_write( provider->private->provider )){
+
+ is_willing_to =
+ NA_IIO_PROVIDER_GET_INTERFACE( provider->private->provider )->is_able_to_write &&
+ NA_IIO_PROVIDER_GET_INTERFACE( provider->private->provider )->write_item &&
+ NA_IIO_PROVIDER_GET_INTERFACE( provider->private->provider )->delete_item;
}
}
- return( provider );
+ return( is_willing_to );
}
/*
- * na_io_provider_read_items:
+ * na_io_provider_load_items:
* @pivot: the #NAPivot object which owns the list of registered I/O
* storage providers.
+ * @loadable_set: the set of loadable items
+ * (cf. NAPivotLoadableSet enumeration defined in core/na-pivot.h).
* @messages: error messages.
*
* Loads the tree from I/O storage subsystems.
@@ -627,51 +617,61 @@ na_io_provider_get_writable_provider( const NAPivot *pivot )
* Returns: a #GList of newly allocated objects as a hierarchical tree
* in display order. This tree contains #NAObjectMenu menus, along with
* #NAObjectAction actions and their #NAObjectProfile profiles.
+ *
+ * The returned list should be na_object_unref_items() by the caller.
*/
GList *
-na_io_provider_read_items( const NAPivot *pivot, GSList **messages )
+na_io_provider_load_items( const NAPivot *pivot, guint loadable_set, GSList **messages )
{
- static const gchar *thisfn = "na_io_provider_read_items";
- GList *providers;
- GList *merged, *hierarchy, *filtered;
+ static const gchar *thisfn = "na_io_provider_load_items";
+ GList *flat, *hierarchy, *filtered;
GSList *level_zero;
- gint order_mode;
+ guint order_mode;
- 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 );
- providers = na_io_provider_get_providers_list( pivot );
+ g_debug( "%s: pivot=%p, loadable_set=%d, messages=%p",
+ thisfn, ( void * ) pivot, loadable_set, ( void * ) messages );
+
+ /* get the global flat items list, as a merge of the list provided
+ * each available and readable i/o provider
+ */
+ flat = load_items_get_merged_list( pivot, loadable_set, messages );
+
+ /* build the items hierarchy
+ */
+ level_zero = na_settings_get_string_list(
+ na_pivot_get_settings( pivot ), NA_IPREFS_ITEMS_LEVEL_ZERO_ORDER, NULL, NULL );
- merged = get_merged_items_list( pivot, providers, messages );
- level_zero = na_iprefs_read_string_list( NA_IPREFS( pivot ), IPREFS_LEVEL_ZERO_ITEMS, NULL );
- hierarchy = build_hierarchy( &merged, level_zero, TRUE, NULL );
+ hierarchy = load_items_hierarchy_build( &flat, level_zero, TRUE, NULL );
- /* items that stay left in the merged list are simply appended
+ /* items that stay left in the global flat 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( flat ){
+ g_debug( "%s: %d items left appended to the hierarchy", thisfn, g_list_length( flat ));
+ hierarchy = g_list_concat( hierarchy, flat );
}
- if( merged || !level_zero || !g_slist_length( level_zero )){
+ if( flat || !level_zero || !g_slist_length( level_zero )){
g_debug( "%s: rewriting level-zero", thisfn );
- if( !na_pivot_write_level_zero( pivot, hierarchy, messages )){
+ if( !na_iprefs_write_level_zero( pivot, hierarchy, messages )){
g_warning( "%s: unable to update level-zero", thisfn );
}
}
na_core_utils_slist_free( level_zero );
- order_mode = na_iprefs_get_order_mode( NA_IPREFS( pivot ));
+ /* sort the hierarchy according to preferences
+ */
+ order_mode = na_iprefs_get_order_mode( pivot );
switch( order_mode ){
case IPREFS_ORDER_ALPHA_ASCENDING:
- hierarchy = sort_tree( pivot, hierarchy, ( GCompareFunc ) na_object_id_sort_alpha_asc );
+ hierarchy = load_items_hierarchy_sort( pivot, hierarchy, ( GCompareFunc ) na_object_id_sort_alpha_asc );
break;
case IPREFS_ORDER_ALPHA_DESCENDING:
- hierarchy = sort_tree( pivot, hierarchy, ( GCompareFunc ) na_object_id_sort_alpha_desc );
+ hierarchy = load_items_hierarchy_sort( pivot, hierarchy, ( GCompareFunc ) na_object_id_sort_alpha_desc );
break;
case IPREFS_ORDER_MANUAL:
@@ -681,7 +681,7 @@ na_io_provider_read_items( const NAPivot *pivot, GSList **messages )
/* check status here...
*/
- filtered = filter_unwanted_items( pivot, hierarchy );
+ filtered = load_items_filter_unwanted_items( pivot, hierarchy, loadable_set );
g_list_free( hierarchy );
g_debug( "%s: tree after filtering and reordering (if any)", thisfn );
@@ -691,37 +691,268 @@ na_io_provider_read_items( const NAPivot *pivot, GSList **messages )
return( filtered );
}
+#if 0
+static void
+dump( const NAIOProvider *provider )
+{
+ static const gchar *thisfn = "na_io_provider_dump";
+
+ g_debug( "%s: id=%s", thisfn, provider->private->id );
+ g_debug( "%s: provider=%p", thisfn, ( void * ) provider->private->provider );
+ g_debug( "%s: item_changed_handler=%lu", thisfn, provider->private->item_changed_handler );
+}
+
+static void
+dump_providers_list( GList *providers )
+{
+ static const gchar *thisfn = "na_io_provider_dump_providers_list";
+ GList *ip;
+
+ g_debug( "%s: providers=%p (count=%d)", thisfn, ( void * ) providers, g_list_length( providers ));
+
+ for( ip = providers ; ip ; ip = ip->next ){
+ dump( NA_IO_PROVIDER( ip->data ));
+ }
+}
+#endif
+
+/*
+ * allocate a new NAIOProvider object for the specified module and id
+ */
+static NAIOProvider *
+io_provider_new( const NAPivot *pivot, NAIIOProvider *module, const gchar *id )
+{
+ NAIOProvider *object;
+
+ object = g_object_new( NA_IO_PROVIDER_TYPE, IO_PROVIDER_PROP_ID, id, NULL );
+
+ if( module ){
+ object->private->provider = g_object_ref( module );
+ object->private->item_changed_handler =
+ g_signal_connect(
+ module, IO_PROVIDER_SIGNAL_ITEM_CHANGED,
+ ( GCallback ) na_pivot_on_item_changed_handler, ( gpointer ) pivot );
+ }
+
+ return( object );
+}
+
/*
- * returns a concatened list of readen actions / menus
+ * add to the list a NAIOProvider object for each loaded plugin which claim
+ * to implement the NAIIOProvider interface
*/
static GList *
-get_merged_items_list( const NAPivot *pivot, GList *providers, GSList **messages )
+io_providers_list_add_from_plugins( const NAPivot *pivot, GList *objects_list )
{
- GList *ip;
- GList *merged = NULL;
- GList *list, *item;
- NAIIOProvider *instance;
+ static const gchar *thisfn = "na_io_provider_io_providers_list_add_from_plugins";
+ GList *merged;
+ GList *modules_list, *im;
+ gchar *id;
+ NAIIOProvider *provider_module;
- for( ip = providers ; ip ; ip = ip->next ){
+ merged = objects_list;
+ modules_list = na_pivot_get_providers( pivot, NA_IIO_PROVIDER_TYPE );
- if( na_io_provider_is_user_readable_at_startup( NA_IO_PROVIDER( ip->data ), NA_IPREFS( pivot ))){
+ for( im = modules_list ; im ; im = im->next ){
- instance = NA_IO_PROVIDER( ip->data )->private->provider;
- if( instance ){
+ id = NULL;
+ provider_module = NA_IIO_PROVIDER( im->data );
+
+ if( NA_IIO_PROVIDER_GET_INTERFACE( provider_module )->get_id ){
+ id = NA_IIO_PROVIDER_GET_INTERFACE( provider_module )->get_id( provider_module );
+ if( !id || !strlen( id )){
+ g_warning( "%s: NAIIOProvider %p get_id() interface returns null or empty id", thisfn, ( void * ) im->data );
+ g_free( id );
+ id = NULL;
+ }
+ } else {
+ g_warning( "%s: NAIIOProvider %p doesn't support get_id() interface", thisfn, ( void * ) im->data );
+ }
- if( NA_IIO_PROVIDER_GET_INTERFACE( instance )->read_items ){
+ if( id ){
+ merged = io_providers_list_add_object( pivot, merged, provider_module, id );
+ g_free( id );
+ }
+ }
- list = NA_IIO_PROVIDER_GET_INTERFACE( instance )->read_items( instance, messages );
+ na_pivot_free_providers( modules_list );
- for( item = list ; item ; item = item->next ){
+ return( merged );
+}
+
+/*
+ * add to the list NAIOProvider objects for the identifiers we may find
+ * in preferences without having found the plugin itself
+ *
+ * preferences may come from the 'write-order' list, or from the io-providers
+ * status.
+ */
+static GList *
+io_providers_list_add_from_prefs( const NAPivot *pivot, GList *objects_list )
+{
+ GList *merged;
+ const gchar *id;
+ GSList *io_providers, *it;
- na_object_set_provider( item->data, NA_IO_PROVIDER( ip->data ));
- na_object_dump( item->data );
- }
+ merged = objects_list;
- merged = g_list_concat( merged, list );
- }
+ io_providers = na_iprefs_get_io_providers( pivot );
+ for( it = io_providers ; it ; it = it->next ){
+ id = ( const gchar * ) it->data;
+ merged = io_providers_list_add_object( pivot, merged, NULL, id );
+ }
+ na_core_utils_slist_free( io_providers );
+
+ return( merged );
+}
+
+/*
+ * add to the list a NAIOProvider object for the specified module and id
+ * if it does not have been already registered
+ */
+static GList *
+io_providers_list_add_object( const NAPivot *pivot, GList *list, NAIIOProvider *module, const gchar *id )
+{
+ GList *merged;
+ NAIOProvider *object;
+
+ merged = list;
+
+ if( !peek_provider_by_id( list, id ) ){
+ object = io_provider_new( pivot, module, id );
+ merged = g_list_prepend( merged, object );
+ }
+
+ return( merged );
+}
+
+/*
+ * is_really_writable:
+ * @provider: the #NAIOProvider provider.
+ * @pivot: the #NAPivot instance.
+ *
+ * Returns: %TRUE if the @provider will be able to write proposed items,
+ * %FALSE else.
+ *
+ * Note thay almost all checked conditions are themselves subject to race
+ * conditions. Unless that (!), the caller can be (almost) sure that writings
+ * will be possible when this function returns %TRUE.
+ */
+static gboolean
+is_really_writable( const NAIOProvider *provider, const NAPivot *pivot )
+{
+
+ return( na_io_provider_is_willing_to_write( provider ) &&
+ na_io_provider_is_able_to_write( provider ) &&
+ na_io_provider_is_conf_writable( provider, pivot ) &&
+ !na_pivot_is_configuration_locked_by_admin( pivot ));
+}
+
+static GList *
+load_items_filter_unwanted_items( const NAPivot *pivot, GList *hierarchy, guint loadable_set )
+{
+ GList *it;
+ GList *filtered;
+
+ for( it = hierarchy ; it ; it = it->next ){
+ na_object_check_status( it->data );
+ }
+
+ filtered = load_items_filter_unwanted_items_rec( hierarchy, loadable_set );
+
+ return( filtered );
+}
+
+/*
+ * build a dest tree from a source tree, removing filtered items
+ * an item is filtered if it is invalid (and not loading invalid ones)
+ * or disabled (and not loading disabled ones)
+ */
+static GList *
+load_items_filter_unwanted_items_rec( GList *hierarchy, guint loadable_set )
+{
+ static const gchar *thisfn = "na_io_provider_load_items_filter_unwanted_items_rec";
+ GList *subitems, *subitems_f;
+ GList *it, *itnext;
+ GList *filtered;
+ gboolean selected;
+ gchar *label;
+ gboolean load_invalid, load_disabled;
+
+ filtered = NULL;
+ load_invalid = loadable_set & PIVOT_LOAD_INVALID;
+ load_disabled = loadable_set & PIVOT_LOAD_DISABLED;
+
+ for( it = hierarchy ; it ; it = itnext ){
+
+ itnext = it->next;
+ selected = FALSE;
+
+ if( NA_IS_OBJECT_PROFILE( it->data )){
+ if( na_object_is_valid( it->data ) || load_invalid ){
+ filtered = g_list_append( filtered, it->data );
+ selected = TRUE;
+ }
+ }
+
+ if( NA_IS_OBJECT_ITEM( it->data )){
+ if(( na_object_is_enabled( it->data ) || load_disabled ) &&
+ ( na_object_is_valid( it->data ) || load_invalid )){
+
+ subitems = na_object_get_items( it->data );
+ subitems_f = load_items_filter_unwanted_items_rec( subitems, loadable_set );
+ na_object_set_items( it->data, subitems_f );
+ filtered = g_list_append( filtered, it->data );
+ selected = TRUE;
+ }
+ }
+
+ if( !selected ){
+ label = na_object_get_label( it->data );
+ g_debug( "%s: filtering %p (%s) '%s'", thisfn, ( void * ) it->data, G_OBJECT_TYPE_NAME( it->data ), label );
+ g_free( label );
+ na_object_unref( it->data );
+ }
+ }
+
+ return( filtered );
+}
+
+/*
+ * returns a concatened flat list of readen actions / menus
+ * we take care here of:
+ * - i/o providers which appear unavailable at runtime
+ * - i/o providers marked as unreadable
+ * - items (actions or menus) which do not satisfy the defined loadable set
+ */
+static GList *
+load_items_get_merged_list( const NAPivot *pivot, guint loadable_set, GSList **messages )
+{
+ const GList *providers;
+ const GList *ip;
+ GList *merged, *items, *it;
+ const NAIOProvider *provider_object;
+ const NAIIOProvider *provider_module;
+
+ merged = NULL;
+ providers = na_io_provider_get_io_providers_list( pivot );
+
+ for( ip = providers ; ip ; ip = ip->next ){
+ provider_object = NA_IO_PROVIDER( it->data );
+ provider_module = provider_object->private->provider;
+
+ if( provider_module &&
+ NA_IIO_PROVIDER_GET_INTERFACE( provider_module )->read_items &&
+ na_io_provider_is_conf_readable( provider_object, pivot )){
+
+ items = NA_IIO_PROVIDER_GET_INTERFACE( provider_module )->read_items( provider_module, messages );
+
+ for( it = items ; it ; it = it->next ){
+ na_object_set_provider( it->data, provider_object );
+ na_object_dump( it->data );
}
+
+ merged = g_list_concat( merged, items );
}
}
@@ -730,14 +961,14 @@ get_merged_items_list( const NAPivot *pivot, GList *providers, GSList **messages
/*
* recursively builds the hierarchy
- * note that we add a ref count to object installed in new hierarchy
- * so that eventual non-referenced objects will not cause memory leak
- * when releasing initial merged tree
+ *
+ * this is a recursive function which _moves_ items from input 'tree' to
+ * output list.
*/
static GList *
-build_hierarchy( GList **tree, GSList *level_zero, gboolean list_if_empty, NAObjectItem *parent )
+load_items_hierarchy_build( GList **tree, GSList *level_zero, gboolean list_if_empty, NAObjectItem *parent )
{
- static const gchar *thisfn = "na_io_provider_build_hierarchy";
+ static const gchar *thisfn = "na_io_provider_load_items_hierarchy_build";
GList *hierarchy, *it;
GSList *ilevel;
GSList *subitems_ids;
@@ -748,7 +979,7 @@ build_hierarchy( GList **tree, GSList *level_zero, gboolean list_if_empty, NAObj
if( g_slist_length( level_zero )){
for( ilevel = level_zero ; ilevel ; ilevel = ilevel->next ){
/*g_debug( "%s: id=%s", thisfn, ( gchar * ) ilevel->data );*/
- it = g_list_find_custom( *tree, ilevel->data, ( GCompareFunc ) search_item );
+ it = g_list_find_custom( *tree, ilevel->data, ( GCompareFunc ) peek_item_by_id_compare );
if( it ){
hierarchy = g_list_append( hierarchy, it->data );
na_object_set_parent( it->data, parent );
@@ -760,15 +991,15 @@ build_hierarchy( GList **tree, GSList *level_zero, gboolean list_if_empty, NAObj
if( NA_IS_OBJECT_MENU( it->data )){
subitems_ids = na_object_get_items_slist( it->data );
- subitems = build_hierarchy( tree, subitems_ids, FALSE, NA_OBJECT_ITEM( it->data ));
+ subitems = load_items_hierarchy_build( tree, subitems_ids, FALSE, NA_OBJECT_ITEM( it->data ));
na_object_set_items( it->data, subitems );
na_core_utils_slist_free( subitems_ids );
}
}
}
}
-
- /* if level-zero list is empty, we consider that all actions go to it
+ /* if level-zero list is empty,
+ * we consider that all items are at the same level
*/
else if( list_if_empty ){
for( it = *tree ; it ; it = it->next ){
@@ -782,11 +1013,32 @@ build_hierarchy( GList **tree, GSList *level_zero, gboolean list_if_empty, NAObj
return( hierarchy );
}
+static GList *
+load_items_hierarchy_sort( const NAPivot *pivot, GList *tree, GCompareFunc fn )
+{
+ GList *sorted;
+ GList *items, *it;
+
+ sorted = g_list_sort( tree, fn );
+
+ /* recursively sort each level of the tree
+ */
+ for( it = sorted ; it ; it = it->next ){
+ if( NA_IS_OBJECT_MENU( it->data )){
+ items = na_object_get_items( it->data );
+ items = load_items_hierarchy_sort( pivot, items, fn );
+ na_object_set_items( it->data, items );
+ }
+ }
+
+ return( sorted );
+}
+
/*
- * returns zero when obj has the required id
+ * returns zero when @obj has the required @id
*/
static gint
-search_item( const NAObject *obj, const gchar *id )
+peek_item_by_id_compare( const NAObject *obj, const gchar *id )
{
gchar *obj_id;
gint ret = 1;
@@ -800,147 +1052,203 @@ search_item( const NAObject *obj, const gchar *id )
return( ret );
}
-static GList *
-sort_tree( const NAPivot *pivot, GList *tree, GCompareFunc fn )
+static NAIOProvider *
+peek_provider_by_id( const GList *providers, const gchar *id )
{
- GList *sorted;
- GList *items, *it;
+ NAIOProvider *provider = NULL;
+ const GList *ip;
- sorted = g_list_sort( tree, fn );
-
- /* recursively sort each level of the tree
- */
- for( it = sorted ; it ; it = it->next ){
- if( NA_IS_OBJECT_MENU( it->data )){
- items = na_object_get_items( it->data );
- items = sort_tree( pivot, items, fn );
- na_object_set_items( it->data, items );
+ for( ip = providers ; ip && !provider ; ip = ip->next ){
+ if( !strcmp( NA_IO_PROVIDER( ip->data )->private->id, id )){
+ provider = NA_IO_PROVIDER( ip->data );
}
}
- return( sorted );
+ return( provider );
+}
+
+#if 0
+/*
+ * @priority: the internal ids of IO providers in descending order of
+ * priority for writing new elements, as a string list
+ *
+ * build the static list of I/O providers, depending of setup of NAPivot
+ * doing required initializations
+ */
+static void
+setup_io_providers( const NAPivot *pivot, GSList *priority )
+{
+ GList *ordered_providers;
+ GList *merged_providers;
+ GList *all_providers;
+
+ g_return_if_fail( st_io_providers == NULL );
+
+ /* allocate the ordered list */
+ ordered_providers = allocate_ordered_providers( priority );
+
+ /* merge with available I/O providers */
+ merged_providers = merge_available_io_providers( pivot, ordered_providers );
+
+ /* add providers found in prefs */
+ all_providers = add_io_providers_from_prefs( pivot, merged_providers );
+
+ st_io_providers = all_providers;
}
static GList *
-filter_unwanted_items( const NAPivot *pivot, GList *hierarchy )
+allocate_ordered_providers( GSList *priority )
{
- gboolean load_disabled;
- gboolean load_invalid;
- GList *it;
- GList *filtered;
+ GSList *ip;
+ NAIOProvider *provider;
+ GList *providers;
- load_disabled = na_pivot_is_disable_loadable( pivot );
- load_invalid = na_pivot_is_invalid_loadable( pivot );
+ providers = NULL;
- for( it = hierarchy ; it ; it = it->next ){
- na_object_check_status( it->data );
- }
+ for( ip = priority ; ip ; ip = ip->next ){
- filtered = filter_unwanted_items_rec( hierarchy, load_disabled, load_invalid );
+ provider = g_object_new( NA_IO_PROVIDER_TYPE, IO_PROVIDER_PROP_ID, ( const gchar * ) ip->data, NULL );
+ providers = g_list_prepend( providers, provider );
+ }
- return( filtered );
+ return( g_list_reverse( providers ));
}
/*
- * build a dest tree from a source tree, removing filtered items
- * an item is filtered if it is invalid (and not loading invalid ones)
- * or disabled (and not loading disabled ones)
+ * merge the ordered list of I/O providers (which have only Id)
+ * with those found available at runtime
*/
static GList *
-filter_unwanted_items_rec( GList *hierarchy, gboolean load_disabled, gboolean load_invalid )
+merge_available_io_providers( const NAPivot *pivot, GList *ordered )
{
- static const gchar *thisfn = "na_io_provider_filter_unwanted_items_rec";
- GList *subitems, *subitems_f;
- GList *it, *itnext;
- GList *filtered;
- gboolean selected;
- gchar *label;
+ static const gchar *thisfn = "na_io_provider_merge_available_io_providers";
+ GList *merged;
+ GList *module_objects, *im;
+ gchar *id;
+ NAIOProvider *provider;
- filtered = NULL;
- for( it = hierarchy ; it ; it = itnext ){
+ merged = ordered;
- itnext = it->next;
- selected = FALSE;
+ module_objects = na_pivot_get_providers( pivot, NA_IIO_PROVIDER_TYPE );
+ for( im = module_objects ; im ; im = im->next ){
- if( NA_IS_OBJECT_PROFILE( it->data )){
- if( na_object_is_valid( it->data ) || load_invalid ){
- filtered = g_list_append( filtered, it->data );
- selected = TRUE;
- }
+ id = NULL;
+ if( NA_IIO_PROVIDER_GET_INTERFACE( NA_IIO_PROVIDER( im->data ))->get_id ){
+ id = NA_IIO_PROVIDER_GET_INTERFACE( NA_IIO_PROVIDER( im->data ))->get_id( NA_IIO_PROVIDER( im->data ));
+
+ } else {
+ g_warning( "%s: NAIIOProvider %p doesn't support get_id() interface", thisfn, ( void * ) im->data );
}
- if( NA_IS_OBJECT_ITEM( it->data )){
- if(( na_object_is_enabled( it->data ) || load_disabled ) &&
- ( na_object_is_valid( it->data ) || load_invalid )){
+ provider = NULL;
+ if( id ){
+ provider = na_io_provider_find_provider_by_id( merged, id );
- subitems = na_object_get_items( it->data );
- subitems_f = filter_unwanted_items_rec( subitems, load_disabled, load_invalid );
- na_object_set_items( it->data, subitems_f );
- filtered = g_list_append( filtered, it->data );
- selected = TRUE;
+ if( !provider ){
+ g_debug( "%s: no provider already allocated in ordered list for id=%s", thisfn, id );
+ provider = g_object_new( NA_IO_PROVIDER_TYPE, IO_PROVIDER_PROP_ID, id, NULL );
+ merged = g_list_append( merged, provider );
+
+ } else {
+ g_debug( "%s: found NAIOProvider=%p (NAIIOProvider=%p) for id=%s",
+ thisfn, ( void * ) provider, ( void * ) im->data, id );
}
- }
- if( !selected ){
- label = na_object_get_label( it->data );
- g_debug( "%s: filtering %p (%s) '%s'", thisfn, ( void * ) it->data, G_OBJECT_TYPE_NAME( it->data ), label );
- g_free( label );
- na_object_unref( it->data );
+ io_provider_set_provider( provider, NA_IIO_PROVIDER( im->data ), pivot );
+
+ g_free( id );
}
}
- return( filtered );
+ na_pivot_free_providers( module_objects );
+
+ return( merged );
}
-/*
- * na_io_provider_get_id:
- * @provider: this #NAIOProvider.
- *
- * Returns: the internal id of this #NAIIOProvider, as a newly
- * allocated string which should be g_free() by the caller.
- */
-gchar *
-na_io_provider_get_id( const NAIOProvider *provider )
+static void
+io_provider_set_provider( NAIOProvider *provider, NAIIOProvider *instance, const NAPivot *pivot )
{
- gchar *id;
+ static const gchar *thisfn = "na_io_provider_set_provider";
- id = NULL;
- g_return_val_if_fail( NA_IS_IO_PROVIDER( provider ), id );
+ g_return_if_fail( NA_IS_IO_PROVIDER( provider ));
+ g_return_if_fail( NA_IS_IIO_PROVIDER( instance ));
- if( !provider->private->dispose_has_run ){
+ provider->private->provider = g_object_ref( instance );
- id = g_strdup( provider->private->id );
+ if( NA_IIO_PROVIDER_GET_INTERFACE( instance )->get_name ){
+ provider->private->name = NA_IIO_PROVIDER_GET_INTERFACE( instance )->get_name( instance );
+ } else {
+ g_warning( "%s: NAIIOProvider %p doesn't support get_name() interface", thisfn, ( void * ) instance );
}
- return( id );
+ provider->private->item_changed_handler =
+ g_signal_connect(
+ instance,
+ IO_PROVIDER_SIGNAL_ITEM_CHANGED,
+ ( GCallback ) na_pivot_item_changed_handler,
+ ( gpointer ) pivot );
+}
+
+static GList *
+add_io_providers_from_prefs( const NAPivot *pivot, GList *runtime_providers )
+{
+ gchar *path, *id;
+ GSList *ids, *iid;
+ GList *providers;
+ NAIOProvider *provider;
+
+ providers = runtime_providers;
+ path = gconf_concat_dir_and_key( IPREFS_GCONF_BASEDIR, IO_PROVIDER_KEY_ROOT );
+ gconf = na_iprefs_get_gconf_client( NA_IPREFS( pivot ));
+
+ ids = na_gconf_utils_get_subdirs( gconf, path );
+
+ for( iid = ids ; iid ; iid = iid->next ){
+ id = g_path_get_basename(( const gchar * ) iid->data );
+ provider = na_io_provider_find_provider_by_id( providers, id );
+
+ if( !provider ){
+ provider = g_object_new( NA_IO_PROVIDER_TYPE, IO_PROVIDER_PROP_ID, id, NULL );
+ providers = g_list_append( providers, provider );
+ }
+
+ g_free( id );
+ }
+
+ na_gconf_utils_free_subdirs( ids );
+ g_free( path );
+
+ return( providers );
}
/*
- * na_io_provider_get_name:
- * @provider: this #NAIOProvider.
- *
- * Returns: the displayable name of this #NAIIOProvider, as a newly
- * allocated string which should be g_free() by the caller.
+ * na_io_provider_reorder_providers_list:
+ * @pivot: the #NAPivot instance of the application.
*
- * May return %NULL is the NAIIOProvider is not present at runtime.
+ * Reorder our global list of #NAIOProviders,after the user has reordered
+ * them in user preferences.
*/
-gchar *
-na_io_provider_get_name( const NAIOProvider *provider )
+void
+na_io_provider_reorder_providers_list( const NAPivot *pivot )
{
- gchar *name;
-
- name = NULL;
- g_return_val_if_fail( NA_IS_IO_PROVIDER( provider ), name );
-
- if( !provider->private->dispose_has_run ){
+ GSList *order, *io;
+ GList *new_list;
+ NAIOProvider *provider;
- if( provider->private->name ){
+ new_list = NULL;
+ order = na_iprefs_read_string_list( NA_IPREFS( pivot ), IO_PROVIDER_KEY_ORDER, NULL );
- name = g_strdup( provider->private->name );
+ for( io = order ; io ; io = io->next ){
+ provider = na_io_provider_find_provider_by_id( st_io_providers, ( const gchar * ) io->data );
+ if( provider ){
+ st_io_providers = g_list_remove( st_io_providers, provider );
+ new_list = g_list_prepend( new_list, provider );
}
}
- return( name );
+ st_io_providers = g_list_reverse( new_list );
+
+ na_core_utils_slist_free( order );
}
/*
@@ -974,7 +1282,7 @@ na_io_provider_is_user_readable_at_startup( const NAIOProvider *provider, const
path = gconf_concat_dir_and_key( IPREFS_GCONF_BASEDIR, IO_PROVIDER_KEY_ROOT );
key = gconf_concat_dir_and_key( path, provider->private->id );
- entry = gconf_concat_dir_and_key( key, IO_PROVIDER_KEY_READABLE );
+ entry = gconf_concat_dir_and_key( key, NA_IPREFS_IO_PROVIDER_READABLE );
to_be_read = na_gconf_utils_read_bool( gconf, entry, FALSE, TRUE );
@@ -987,42 +1295,32 @@ na_io_provider_is_user_readable_at_startup( const NAIOProvider *provider, const
}
/*
- * na_io_provider_is_user_writable:
- * @provider: this #NAIOProvider.
- * @iprefs: an implementor of the #NAIPrefs interface.
+ * na_io_provider_find_provider_by_id:
+ * @providers: the current list of #NAIOProvider.
+ * @id: the searched internal id.
*
- * Returns: %TRUE is this I/O provider is writable.
+ * Returns: the searched #NAIOProvider, or %NULL if not found.
*
- * This is a user preference, and doesn't suppose that the NAIIOProvider
- * will actually be writable or not.
+ * The returned object is owned by #NAIOProvider class, and should not
+ * be g_object_unref() by the user.
*/
-gboolean
-na_io_provider_is_user_writable( const NAIOProvider *provider, const NAIPrefs *iprefs )
+NAIOProvider *
+na_io_provider_find_provider_by_id( GList *providers, const gchar *id )
{
- gboolean writable;
- GConfClient *gconf;
- gchar *path, *key, *entry;
-
- writable = FALSE;
- g_return_val_if_fail( NA_IS_IO_PROVIDER( provider ), FALSE );
- g_return_val_if_fail( NA_IS_IPREFS( iprefs ), FALSE );
-
- if( !provider->private->dispose_has_run ){
+ NAIOProvider *provider;
+ GList *ip;
- gconf = na_iprefs_get_gconf_client( iprefs );
+ provider = NULL;
- path = gconf_concat_dir_and_key( IPREFS_GCONF_BASEDIR, IO_PROVIDER_KEY_ROOT );
- key = gconf_concat_dir_and_key( path, provider->private->id );
- entry = gconf_concat_dir_and_key( key, IO_PROVIDER_KEY_WRITABLE );
+ for( ip = providers ; ip && !provider ; ip = ip->next ){
- writable = na_gconf_utils_read_bool( gconf, entry, FALSE, TRUE );
+ if( !strcmp( NA_IO_PROVIDER( ip->data )->private->id, id )){
- g_free( entry );
- g_free( key );
- g_free( path );
+ provider = NA_IO_PROVIDER( ip->data );
+ }
}
- return( writable );
+ return( provider );
}
/*
@@ -1058,91 +1356,6 @@ na_io_provider_is_locked_by_admin( const NAIOProvider *provider, const NAIPrefs
}
/*
- * na_io_provider_get_provider:
- * @provider: the #NAIOProvider object.
- *
- * Returns: the I/O interface instance, or NULL.
- *
- * The returned #NAIIOProvider instance is owned by the #NAIOProvider
- * object, and should not be g_object_unref() by the caller.
- */
-NAIIOProvider *
-na_io_provider_get_provider( const NAIOProvider *provider )
-{
- NAIIOProvider *instance;
-
- instance = NULL;
- g_return_val_if_fail( NA_IS_IO_PROVIDER( provider ), instance );
-
- if( !provider->private->dispose_has_run ){
-
- instance = provider->private->provider;
- }
-
- return( instance );
-}
-
-/*
- * na_io_provider_is_willing_to_write:
- * @provider: this #NAIOProvider.
- *
- * Returns: %TRUE is this I/O provider is willing to write.
- */
-gboolean
-na_io_provider_is_willing_to_write( const NAIOProvider *provider )
-{
- gboolean willing_to;
-
- willing_to = FALSE;
- g_return_val_if_fail( NA_IS_IO_PROVIDER( provider ), willing_to );
-
- if( !provider->private->dispose_has_run ){
-
- if( provider->private->provider ){
-
- g_return_val_if_fail( NA_IS_IIO_PROVIDER( provider->private->provider ), FALSE );
-
- if( NA_IIO_PROVIDER_GET_INTERFACE( provider->private->provider )->is_willing_to_write ){
-
- willing_to = NA_IIO_PROVIDER_GET_INTERFACE( provider->private->provider )->is_willing_to_write( provider->private->provider );
- }
- }
- }
-
- return( willing_to );
-}
-
-/*
- * na_io_provider_is_able_to_write:
- * @provider: this #NAIOProvider.
- *
- * Returns: %TRUE is this I/O provider is willing to write.
- */
-gboolean
-na_io_provider_is_able_to_write( const NAIOProvider *provider )
-{
- gboolean able_to;
-
- able_to = FALSE;
- g_return_val_if_fail( NA_IS_IO_PROVIDER( provider ), able_to );
-
- if( !provider->private->dispose_has_run ){
-
- if( provider->private->provider ){
-
- g_return_val_if_fail( NA_IS_IIO_PROVIDER( provider->private->provider ), FALSE );
-
- if( NA_IIO_PROVIDER_GET_INTERFACE( provider->private->provider )->is_able_to_write ){
-
- able_to = NA_IIO_PROVIDER_GET_INTERFACE( provider->private->provider )->is_able_to_write( provider->private->provider );
- }
- }
- }
-
- return( able_to );
-}
-
-/*
* na_io_provider_has_write_api:
* @provider: this #NAIOProvider.
*
@@ -1170,30 +1383,7 @@ na_io_provider_has_write_api( const NAIOProvider *provider )
return( has_api );
}
-
-/*
- * na_io_provider_are_writings_authorized:
- * @provider: the #NAIOProvider provider.
- * @pivot: the #NAPivot instance.
- *
- * Returns: %TRUE if the @provider will be able to write proposed items,
- * %FALSE else.
- *
- * Unless some external condition change between this call and the actual
- * writing, the caller can be sure that writings are really possible when
- * this function returns %TRUE.
- */
-gboolean
-na_io_provider_are_writings_authorized( const NAIOProvider *provider, const NAPivot *pivot )
-{
-
- return( na_io_provider_is_willing_to_write( provider ) &&
- na_io_provider_is_able_to_write( provider ) &&
- na_io_provider_has_write_api( provider ) &&
- na_io_provider_is_user_writable( provider , NA_IPREFS( pivot )) &&
- !na_io_provider_is_locked_by_admin( provider , NA_IPREFS( pivot )) &&
- !na_pivot_is_configuration_locked_by_admin( pivot ));
-}
+#endif
/*
* na_io_provider_write_item:
diff --git a/src/core/na-io-provider.h b/src/core/na-io-provider.h
index 3e10e52..453a6ba 100644
--- a/src/core/na-io-provider.h
+++ b/src/core/na-io-provider.h
@@ -31,20 +31,35 @@
#ifndef __CORE_NA_IO_PROVIDER_H__
#define __CORE_NA_IO_PROVIDER_H__
-/* @title: NAIIOProvider
- * @short_description: The #NAIOProvider Class Definition.
+/* @title: NAIOProvider
+ * @short_description: The NAIOProvider Class Definition
* @include: core/na-io-provider.h
*
* #NAIOProvider is the Nautilus-Actions class which is used to manage
* external I/O Providers which implement #NAIIOProvider interface. Each
- * #NAIOProvider objects encapsulates one #NAIIOProvider provider.
+ * #NAIOProvider objects may (or not) encapsulates one #NAIIOProvider
+ * provider.
*
* Internal Nautilus-Actions code should never directly call a
* #NAIIOProvider interface method, but rather should call the
* corresponding NAIOProvider class method.
+ *
+ * Two preferences are used for each i/o provider:
+ * 'readable': means that the i/o provider should be readen when building
+ * the items hierarchy
+ * 'writable': means that the i/o provider is candidate when writing a
+ * new item; this also means that existing items are deletable.
+ *
+ * To be actually writable, a i/o provider must:
+ * - be set as 'writable' from a configuration point of view
+ * this may or not be edited depending of this is a mandatory or user
+ * preference
+ * - be willing to write: this is an intrisinc i/o provider attribute
+ * - be able to write: his is a runtime i/o provider property
+ *
+ * and the whole configuration must not have been locked by an admin.
*/
-#include "na-iprefs.h"
#include "na-pivot.h"
G_BEGIN_DECLS
@@ -56,7 +71,8 @@ G_BEGIN_DECLS
#define NA_IS_IO_PROVIDER_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE(( klass ), NA_IO_PROVIDER_TYPE ))
#define NA_IO_PROVIDER_GET_CLASS( object ) ( G_TYPE_INSTANCE_GET_CLASS(( object ), NA_IO_PROVIDER_TYPE, NAIOProviderClass ))
-typedef struct _NAIOProviderPrivate NAIOProviderPrivate;
+typedef struct _NAIOProviderPrivate NAIOProviderPrivate;
+typedef struct _NAIOProviderClassPrivate NAIOProviderClassPrivate;
typedef struct {
/*< private >*/
@@ -65,8 +81,6 @@ typedef struct {
}
NAIOProvider;
-typedef struct _NAIOProviderClassPrivate NAIOProviderClassPrivate;
-
typedef struct {
/*< private >*/
GObjectClass parent;
@@ -74,42 +88,28 @@ typedef struct {
}
NAIOProviderClass;
-/* GConf preferences key
- */
-#define IO_PROVIDER_KEY_ROOT "io-providers"
-#define IO_PROVIDER_KEY_READABLE "read-at-startup"
-#define IO_PROVIDER_KEY_WRITABLE "writable"
-#define IO_PROVIDER_KEY_ORDER "io-providers-order"
-
/* signal sent from a NAIIOProvider
* via the na_iio_provider_item_changed() function
*/
#define IO_PROVIDER_SIGNAL_ITEM_CHANGED "io-provider-item-changed"
-GType na_io_provider_get_type ( void );
-
-void na_io_provider_terminate( void );
-
-GList *na_io_provider_get_providers_list( const NAPivot *pivot );
-void na_io_provider_reorder_providers_list( const NAPivot *pivot );
-void na_io_provider_dump_providers_list( GList *providers );
+GType na_io_provider_get_type ( void );
-NAIOProvider *na_io_provider_find_provider_by_id( GList *providers, const gchar *id );
-NAIOProvider *na_io_provider_get_writable_provider( const NAPivot *pivot );
+NAIOProvider *na_io_provider_find_writable_io_provider( const NAPivot *pivot );
+const GList *na_io_provider_get_io_providers_list ( const NAPivot *pivot );
+void na_io_provider_unref_io_providers_list ( void );
-GList *na_io_provider_read_items( const NAPivot *pivot, GSList **messages );
+gchar *na_io_provider_get_id ( const NAIOProvider *provider );
+gchar *na_io_provider_get_name ( const NAIOProvider *provider );
+gboolean na_io_provider_is_available ( const NAIOProvider *provider );
+gboolean na_io_provider_is_conf_readable ( const NAIOProvider *provider, const NAPivot *pivot );
+gboolean na_io_provider_is_able_to_write ( const NAIOProvider *provider );
+gboolean na_io_provider_is_conf_writable ( const NAIOProvider *provider, const NAPivot *pivot );
+gboolean na_io_provider_is_willing_to_write( const NAIOProvider *provider );
-gchar *na_io_provider_get_id ( const NAIOProvider *provider );
-gchar *na_io_provider_get_name ( const NAIOProvider *provider );
-gboolean na_io_provider_is_user_readable_at_startup( const NAIOProvider *provider, const NAIPrefs *iprefs );
-gboolean na_io_provider_is_user_writable ( const NAIOProvider *provider, const NAIPrefs *iprefs );
-gboolean na_io_provider_is_locked_by_admin ( const NAIOProvider *provider, const NAIPrefs *iprefs );
-NAIIOProvider *na_io_provider_get_provider ( const NAIOProvider *provider );
-gboolean na_io_provider_is_willing_to_write ( const NAIOProvider *provider );
-gboolean na_io_provider_is_able_to_write ( const NAIOProvider *provider );
-gboolean na_io_provider_has_write_api ( const NAIOProvider *provider );
+GList *na_io_provider_load_items( const NAPivot *pivot, guint loadable_set, GSList **messages );
-gboolean na_io_provider_are_writings_authorized ( const NAIOProvider *provider, const NAPivot *pivot );
+/* ... */
guint na_io_provider_write_item ( const NAIOProvider *provider, const NAObjectItem *item, GSList **messages );
guint na_io_provider_delete_item ( const NAIOProvider *provider, const NAObjectItem *item, GSList **messages );
diff --git a/src/core/na-iprefs.c b/src/core/na-iprefs.c
index 00df17a..3e38109 100644
--- a/src/core/na-iprefs.c
+++ b/src/core/na-iprefs.c
@@ -34,6 +34,7 @@
#include <string.h>
+#include <api/na-core-utils.h>
#include <api/na-iimporter.h>
#include "na-iprefs.h"
@@ -129,7 +130,7 @@ na_iprefs_set_import_mode( const NAPivot *pivot, const gchar *pref, guint mode )
*
* Returns: the order mode currently set.
*/
-gint
+guint
na_iprefs_get_order_mode( const NAPivot *pivot )
{
gchar *order_mode_str;
@@ -153,7 +154,7 @@ na_iprefs_get_order_mode( const NAPivot *pivot )
* preference system.
*/
void
-na_iprefs_set_order_mode( const NAPivot *pivot, gint mode )
+na_iprefs_set_order_mode( const NAPivot *pivot, guint mode )
{
const gchar *order_str;
NASettings *settings;
@@ -163,6 +164,146 @@ na_iprefs_set_order_mode( const NAPivot *pivot, gint mode )
na_settings_set_string( settings, NA_IPREFS_ITEMS_LIST_ORDER_MODE, order_str );
}
+/*
+ * na_iprefs_get_io_providers:
+ * @pivot: the #NAPivot application object.
+ *
+ * Searches in preferences system for all mentions of an i/o provider.
+ * This does not mean in any way that the i/o provider is active,
+ * available or so, but just that is mentioned here.
+ *
+ * I/o provider identifers returned in the list are not supposed
+ * to be unique, nor sorted.
+ *
+ * Returns: a list of i/o provider identifiers found in preferences
+ * system; this list should be na_core_utils_slist_free() by the caller.
+ *
+ * since: 3.1.0
+ */
+GSList *
+na_iprefs_get_io_providers( const NAPivot *pivot )
+{
+ GSList *providers;
+ NASettings *settings;
+ GSList *write_order, *groups;
+ GSList *it;
+ const gchar *name;
+ gchar *group_prefix;
+ guint prefix_len;
+
+ providers = NULL;
+ settings = na_pivot_get_settings( pivot );
+
+ write_order = na_settings_get_string_list( settings, NA_IPREFS_IO_PROVIDERS_WRITE_ORDER, NULL, NULL );
+ for( it = write_order ; it ; it = it->data ){
+ name = ( const gchar * ) it->data;
+ providers = g_slist_prepend( providers, g_strdup( name ));
+ }
+ na_core_utils_slist_free( write_order );
+
+ groups = na_settings_get_groups( settings );
+ group_prefix = g_strdup_printf( "%s ", NA_IPREFS_IO_PROVIDER_GROUP );
+ prefix_len = strlen( group_prefix );
+ for( it = groups ; it ; it = it->data ){
+ name = ( const gchar * ) it->data;
+ if( g_str_has_prefix( name, group_prefix )){
+ providers = g_slist_prepend( providers, g_strdup( name+prefix_len ));
+ }
+ }
+ g_free( group_prefix );
+ na_core_utils_slist_free( groups );
+
+ return( providers );
+}
+
+/*
+ * na_iprefs_is_level_zero_writable:
+ * @pivot: the #NAPivot application object.
+ *
+ * The level-zero order may not be writable if:
+ * - all the configuration has been locked down by an admin
+ * - the preferences has been locked down by an admin
+ * - the level-zero order is a mandatory preference
+ * - the user configuration file is not writable.
+ *
+ * All these conditions are subject to runtime modifications. The caller
+ * should not keep the result, but rather re-call this function each time
+ * it needs this status.
+ *
+ * Each condition is also subject to race conditions. So the returned
+ * status may not be more valid when the caller tries to actually write
+ * the level-zero preference.
+ *
+ * Returns: %TRUE if we are able to update the level-zero list of items,
+ * %FALSE else.
+ *
+ * As of 3.1.0, level-zero order is written as a user preference.
+ */
+gboolean
+na_iprefs_is_level_zero_writable( const NAPivot *pivot )
+{
+ g_return_val_if_fail( NA_IS_PIVOT( pivot ), FALSE );
+
+ if( na_pivot_is_configuration_locked_by_admin( pivot )){
+ return( FALSE );
+ }
+
+ return( TRUE );
+}
+
+/*
+ * na_iprefs_write_level_zero:
+ * @pivot: the #NAPivot application object.
+ * @items: the #GList of items whose first level is to be written.
+ * @messages: a pointer to a #GSList in which we will add happening
+ * error messages;
+ * the pointer may be %NULL;
+ * if not %NULL, the #GSList must have been initialized by the
+ * caller.
+ *
+ * Rewrite the level-zero items in GConf preferences.
+ *
+ * Returns: %TRUE if successfully written (i.e. writable, not locked,
+ * and so on), %FALSE else.
+ *
+ * @messages #GSList is only filled up in case of an error has occured.
+ * If there is no error (na_iprefs_write_level_zero() returns %TRUE), then
+ * the caller may safely assume that @messages is returned in the same
+ * state that it has been provided.
+ */
+gboolean
+na_iprefs_write_level_zero( const NAPivot *pivot, const GList *items, GSList **messages )
+{
+ static const gchar *thisfn = "na_iprefs_write_level_zero";
+ gboolean written;
+ const GList *it;
+ gchar *id;
+ GSList *content;
+
+ g_return_val_if_fail( NA_IS_PIVOT( pivot ), FALSE );
+
+ written = FALSE;
+
+ g_debug( "%s: pivot=%p", thisfn, ( void * ) pivot);
+
+ if( na_iprefs_is_level_zero_writable( pivot )){
+
+ content = NULL;
+ for( it = items ; it ; it = it->next ){
+ id = na_object_get_id( it->data );
+ content = g_slist_prepend( content, id );
+ }
+ content = g_slist_reverse( content );
+
+ na_settings_set_string_list( na_pivot_get_settings( pivot ), NA_IPREFS_ITEMS_LEVEL_ZERO_ORDER, content );
+ written = TRUE;
+
+ na_core_utils_slist_free( content );
+ }
+
+ return( written );
+}
+
static const gchar *
enum_map_string_from_id( const EnumMap *map, guint id )
{
@@ -183,7 +324,7 @@ enum_map_id_from_string( const EnumMap *map, const gchar *str )
const EnumMap *i = map;
while( i->id ){
- if( !strcmp( i->str == str )){
+ if( !strcmp( i->str, str )){
return( i->id );
}
i++;
diff --git a/src/core/na-iprefs.h b/src/core/na-iprefs.h
index 93400fd..44f7835 100644
--- a/src/core/na-iprefs.h
+++ b/src/core/na-iprefs.h
@@ -65,9 +65,11 @@
* user interface or by choosing the ad-hoc preference, the plugin
* doesn't provides one, and the 'About' item will not be displayed.
*
- * Starting with 3.1.0, NAIPrefs interface is deprecated.
- * Instead, this file implements all maps needed to transform an enum
- * used in the code to and from a string stored in preferences.
+ * Starting with 3.1.0, NAIPrefs interface is deprecated in this form.
+ * Instead, this module is used as an intermediate level between actual
+ * settings and the application; it so implements all maps needed to
+ * transform an enum used in the code to and from a string stored in
+ * preferences.
*/
#include "na-pivot.h"
@@ -82,11 +84,16 @@ enum {
IPREFS_ORDER_MANUAL
};
-guint na_iprefs_get_import_mode( const NAPivot *pivot, const gchar *pref );
-void na_iprefs_set_import_mode( const NAPivot *pivot, const gchar *pref, guint mode );
+guint na_iprefs_get_import_mode ( const NAPivot *pivot, const gchar *pref );
+void na_iprefs_set_import_mode ( const NAPivot *pivot, const gchar *pref, guint mode );
-guint na_iprefs_get_order_mode ( const NAPivot *pivot );
-void na_iprefs_set_order_mode ( const NAPivot *pivot, gint mode );
+guint na_iprefs_get_order_mode ( const NAPivot *pivot );
+void na_iprefs_set_order_mode ( const NAPivot *pivot, guint mode );
+
+GSList *na_iprefs_get_io_providers ( const NAPivot * );
+
+gboolean na_iprefs_is_level_zero_writable( const NAPivot *pivot );
+gboolean na_iprefs_write_level_zero ( const NAPivot *pivot, const GList *items, GSList **messages );
G_END_DECLS
diff --git a/src/core/na-module.c b/src/core/na-module.c
index 4566565..714f506 100644
--- a/src/core/na-module.c
+++ b/src/core/na-module.c
@@ -225,7 +225,8 @@ na_module_dump( const NAModule *module )
* Load availables dynamically loadable extension libraries (plugins).
*
* Returns: a #GList of #NAModule, each object representing a dynamically
- * loaded library.
+ * loaded library. The list should be na_module_release_modules() by the
+ * caller after use.
*/
GList *
na_module_load_modules( void )
diff --git a/src/core/na-pivot.c b/src/core/na-pivot.c
index b5c973e..5930f43 100644
--- a/src/core/na-pivot.c
+++ b/src/core/na-pivot.c
@@ -35,8 +35,6 @@
#include <string.h>
#include <api/na-core-utils.h>
-#include <api/na-gconf-monitor.h>
-#include <api/na-gconf-utils.h>
#include "na-io-provider.h"
#include "na-iprefs.h"
@@ -90,7 +88,7 @@ struct _NAPivotPrivate {
/* NAPivot properties
*/
enum {
- NAPIVOT_PROP_TREE_ID = 1,
+ PIVOT_PROP_TREE_ID = 1,
};
/* signals
@@ -113,8 +111,6 @@ static void instance_set_property( GObject *object, guint property_id,
static void instance_dispose( GObject *object );
static void instance_finalize( GObject *object );
-static void iprefs_iface_init( NAIPrefsInterface *iface );
-
static NAObjectItem *get_item_from_tree( const NAPivot *pivot, GList *tree, const gchar *id );
/* NAIPivotConsumer management */
@@ -154,18 +150,10 @@ register_type( void )
( GInstanceInitFunc ) instance_init
};
- static const GInterfaceInfo iprefs_iface_info = {
- ( GInterfaceInitFunc ) iprefs_iface_init,
- NULL,
- NULL
- };
-
g_debug( "%s", thisfn );
type = g_type_register_static( G_TYPE_OBJECT, "NAPivot", &info, 0 );
- g_type_add_interface_static( type, NA_IPREFS_TYPE, &iprefs_iface_info );
-
return( type );
}
@@ -188,11 +176,11 @@ class_init( NAPivotClass *klass )
object_class->finalize = instance_finalize;
spec = g_param_spec_pointer(
- NAPIVOT_PROP_TREE,
+ PIVOT_PROP_TREE,
"Items tree",
"Hierarchical tree of items",
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
- g_object_class_install_property( object_class, NAPIVOT_PROP_TREE_ID, spec );
+ g_object_class_install_property( object_class, PIVOT_PROP_TREE_ID, spec );
klass->private = g_new0( NAPivotClassPrivate, 1 );
@@ -278,7 +266,7 @@ instance_get_property( GObject *object, guint property_id, GValue *value, GParam
if( !self->private->dispose_has_run ){
switch( property_id ){
- case NAPIVOT_PROP_TREE_ID:
+ case PIVOT_PROP_TREE_ID:
g_value_set_pointer( value, self->private->tree );
break;
@@ -300,7 +288,7 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
if( !self->private->dispose_has_run ){
switch( property_id ){
- case NAPIVOT_PROP_TREE_ID:
+ case PIVOT_PROP_TREE_ID:
self->private->tree = g_value_get_pointer( value );
break;
@@ -339,8 +327,8 @@ instance_dispose( GObject *object )
na_object_unref_items( self->private->tree );
self->private->tree = NULL;
- /* release the I/O Provider objects */
- na_io_provider_terminate();
+ /* release the I/O Provider object list */
+ na_io_provider_unref_io_providers_list();
/* chain up to the parent class */
if( G_OBJECT_CLASS( st_parent_class )->dispose ){
@@ -368,18 +356,26 @@ instance_finalize( GObject *object )
}
}
-static void
-iprefs_iface_init( NAIPrefsInterface *iface )
-{
- static const gchar *thisfn = "na_pivot_iprefs_iface_init";
-
- g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
-}
-
/*
* na_pivot_new:
*
- * Returns: a newly allocated #NAPivot object.
+ * This object takes care of all items/actions/menus/providers/settings
+ * management which is required to correctly handle file manager context
+ * menus.
+ *
+ * When this object is instantiated, it automatically takes care of:
+ * - loading Nautilus-Actions dynamic modules;
+ * - initializing the preferences monitoring.
+ *
+ * Actual loading of items from i/o providers is delayed until a call
+ * to call to na_pivot_load_items() function, so that the caller is able
+ * to set its own needed #NAPivot properties (e.g. the loadable set of
+ * items).
+ *
+ * Only one #NAPivot object should be instantiated for a running application.
+ *
+ * Returns: a newly allocated #NAPivot object which should be g_object_unref()
+ * by the caller at the end of the application.
*/
NAPivot *
na_pivot_new( void )
@@ -569,11 +565,9 @@ na_pivot_load_items( NAPivot *pivot )
g_debug( "%s: pivot=%p", thisfn, ( void * ) pivot );
- na_object_unref_items( pivot->private->tree );
-
messages = NULL;
-
- pivot->private->tree = na_io_provider_read_items( pivot, &messages );
+ na_object_unref_items( pivot->private->tree );
+ pivot->private->tree = na_io_provider_load_items( pivot, pivot->private->loadable_set, &messages );
for( im = messages ; im ; im = im->next ){
g_warning( "%s: %s", thisfn, ( const gchar * ) im->data );
@@ -603,13 +597,12 @@ na_pivot_set_new_items( NAPivot *pivot, GList *items )
thisfn, ( void * ) pivot, ( void * ) items, items ? g_list_length( items ) : 0 );
na_object_unref_items( pivot->private->tree );
-
pivot->private->tree = items;
}
}
/*
- * na_pivot_item_changed_handler:
+ * na_pivot_on_item_changed_handler:
* @provider: the #NAIIOProvider which has emitted the signal.
* @id: the id of the changed #NAObjectItem-derived object.
* As of 2.30, it is always %NULL.
@@ -622,9 +615,9 @@ na_pivot_set_new_items( NAPivot *pivot, GList *items )
* serie, and then reload the whole list of actions
*/
void
-na_pivot_item_changed_handler( NAIIOProvider *provider, const gchar *id, NAPivot *pivot )
+na_pivot_on_item_changed_handler( NAIIOProvider *provider, const gchar *id, NAPivot *pivot )
{
- static const gchar *thisfn = "na_pivot_item_changed_handler";
+ static const gchar *thisfn = "na_pivot_on_item_changed_handler";
g_return_if_fail( NA_IS_IIO_PROVIDER( provider ));
g_return_if_fail( NA_IS_PIVOT( pivot ));
@@ -701,62 +694,6 @@ time_val_diff( const GTimeVal *recent, const GTimeVal *old )
}
/*
- * na_pivot_write_level_zero:
- * @pivot: this #NAPivot instance.
- * @items: the #GList of items whose first level is to be written.
- * @messages: a pointer to a #GSList in which we will add happening
- * error messages;
- * the pointer may be %NULL;
- * if not %NULL, the #GSList must have been initialized by the
- * caller.
- *
- * Rewrite the level-zero items in GConf preferences.
- *
- * Returns: %TRUE if successfully written (i.e. writable, not locked,
- * and so on), %FALSE else.
- *
- * @messages #GSList is only filled up in case of an error has occured.
- * If there is no error (na_pivot_write_level_zero() returns %TRUE), then
- * the caller may safely assume that @messages is returned in the same
- * state that it has been provided.
- */
-gboolean
-na_pivot_write_level_zero( const NAPivot *pivot, GList *items, GSList **messages )
-{
- static const gchar *thisfn = "na_pivot_write_level_zero";
- gboolean written;
- GList *it;
- gchar *id;
- GSList *content;
-
- g_return_val_if_fail( NA_IS_PIVOT( pivot ), FALSE );
-
- written = FALSE;
-
- if( !pivot->private->dispose_has_run ){
-
- g_debug( "%s: pivot=%p", thisfn, ( void * ) pivot);
-
- if( na_pivot_is_level_zero_writable( pivot )){
-
- content = NULL;
- for( it = items ; it ; it = it->next ){
-
- id = na_object_get_id( it->data );
- content = g_slist_prepend( content, id );
- }
- content = g_slist_reverse( content );
-
- written = na_iprefs_write_string_list( NA_IPREFS( pivot ), IPREFS_LEVEL_ZERO_ITEMS, content );
-
- na_core_utils_slist_free( content );
- }
- }
-
- return( written );
-}
-
-/*
* na_pivot_register_consumer:
* @pivot: this #NAPivot instance.
* @consumer: a #NAIPivotConsumer which wishes be notified of any
@@ -798,7 +735,7 @@ free_consumers( GList *consumers )
* Since: 3.1.0
*/
NASettings *
-na_pivot_get_settings( NAPivot *pivot )
+na_pivot_get_settings( const NAPivot *pivot )
{
NASettings *settings;
@@ -840,52 +777,6 @@ na_pivot_set_automatic_reload( NAPivot *pivot, gboolean reload )
}
/*
- * na_pivot_is_disable_loadable:
- * @pivot: this #NAPivot instance.
- *
- * Returns: %TRUE if disabled items should be loaded, %FALSE else.
- */
-gboolean
-na_pivot_is_disable_loadable( const NAPivot *pivot )
-{
- gboolean is_loadable;
-
- g_return_val_if_fail( NA_IS_PIVOT( pivot ), FALSE );
-
- is_loadable = FALSE;
-
- if( !pivot->private->dispose_has_run ){
-
- is_loadable = ( pivot->private->loadable_set & PIVOT_LOAD_DISABLED );
- }
-
- return( is_loadable );
-}
-
-/*
- * na_pivot_is_invalid_loadable:
- * @pivot: this #NAPivot instance.
- *
- * Returns: %TRUE if invalid items should be loaded, %FALSE else.
- */
-gboolean
-na_pivot_is_invalid_loadable( const NAPivot *pivot )
-{
- gboolean is_loadable;
-
- g_return_val_if_fail( NA_IS_PIVOT( pivot ), FALSE );
-
- is_loadable = FALSE;
-
- if( !pivot->private->dispose_has_run ){
-
- is_loadable = ( pivot->private->loadable_set & PIVOT_LOAD_INVALID );
- }
-
- return( is_loadable );
-}
-
-/*
* na_pivot_set_loadable:
* @pivot: this #NAPivot instance.
* @loadable: the population of items to be loaded.
@@ -904,40 +795,6 @@ na_pivot_set_loadable( NAPivot *pivot, guint loadable )
}
/*
- * na_pivot_is_level_zero_writable:
- * @pivot: this #NAPivot instance.
- *
- * Returns: %TRUE if we are able to update the level-zero list of items,
- * %FALSE else.
- */
-gboolean
-na_pivot_is_level_zero_writable( const NAPivot *pivot )
-{
- gboolean all_locked;
- gboolean gconf_locked;
- GConfClient *gconf;
- gchar *path;
-
- all_locked = FALSE;
- gconf_locked = FALSE;
-
- g_return_val_if_fail( NA_IS_PIVOT( pivot ), FALSE );
-
- if( !pivot->private->dispose_has_run ){
-
- all_locked = na_pivot_is_configuration_locked_by_admin( pivot );
-
- gconf = na_iprefs_get_gconf_client( NA_IPREFS( pivot ));
-
- path = gconf_concat_dir_and_key( IPREFS_GCONF_BASEDIR, "mandatory/io-gconf/locked" );
- gconf_locked = na_gconf_utils_read_bool( gconf, path, FALSE, FALSE );
- g_free( path );
- }
-
- return( !all_locked && !gconf_locked );
-}
-
-/*
* na_pivot_is_configuration_locked_by_admin:
* @pivot: this #NAPivot.
*
@@ -948,19 +805,15 @@ gboolean
na_pivot_is_configuration_locked_by_admin( const NAPivot *pivot )
{
gboolean locked;
- GConfClient *gconf;
- gchar *path;
- locked = FALSE;
- g_return_val_if_fail( NA_IS_PIVOT( pivot ), FALSE );
+ g_return_val_if_fail( NA_IS_PIVOT( pivot ), TRUE );
- if( !pivot->private->dispose_has_run ){
+ locked = TRUE;
- gconf = na_iprefs_get_gconf_client( NA_IPREFS( pivot ));
+ if( !pivot->private->dispose_has_run ){
- path = gconf_concat_dir_and_key( IPREFS_GCONF_BASEDIR, "mandatory/all/locked" );
- locked = na_gconf_utils_read_bool( gconf, path, FALSE, FALSE );
- g_free( path );
+ /* TODO: na_pivot_is_configuration_locked_by_admin */
+ locked = FALSE;
}
return( locked );
@@ -1010,19 +863,19 @@ on_preferences_change( GConfClient *client, guint cnxn_id, GConfEntry *entry, NA
key_entry = g_path_get_basename( key );
/*g_debug( "%s: key=%s", thisfn, key_entry );*/
- if( !g_ascii_strcasecmp( key_entry, IPREFS_CREATE_ROOT_MENU )){
+ if( !g_ascii_strcasecmp( key_entry, NA_IPREFS_ITEMS_CREATE_ROOT_MENU )){
create_root_menu_changed( pivot );
}
- if( !g_ascii_strcasecmp( key_entry, IPREFS_ADD_ABOUT_ITEM )){
+ if( !g_ascii_strcasecmp( key_entry, NA_IPREFS_ITEMS_ADD_ABOUT_ITEM )){
display_about_changed( pivot );
}
- if( !g_ascii_strcasecmp( key_entry, IPREFS_DISPLAY_ALPHABETICAL_ORDER )){
+ if( !g_ascii_strcasecmp( key_entry, NA_IPREFS_ITEMS_LIST_ORDER_MODE )){
display_order_changed( pivot );
}
- if( !g_ascii_strcasecmp( key_entry, IPREFS_AUTOSAVE_ON ) || !g_ascii_strcasecmp( key_entry, IPREFS_AUTOSAVE_PERIOD )){
+ if( !g_ascii_strcasecmp( key_entry, NA_IPREFS_MAIN_SAVE_AUTO ) || !g_ascii_strcasecmp( key_entry, NA_IPREFS_MAIN_SAVE_PERIOD )){
autosave_changed( pivot );
}
@@ -1063,7 +916,7 @@ create_root_menu_changed( NAPivot *pivot )
g_debug( "%s: pivot=%p", thisfn, ( void * ) pivot );
- should_create = na_iprefs_read_bool( NA_IPREFS( pivot ), IPREFS_CREATE_ROOT_MENU, FALSE );
+ should_create = na_iprefs_read_bool( NA_IPREFS( pivot ), NA_IPREFS_ITEMS_CREATE_ROOT_MENU, FALSE );
for( ic = pivot->private->consumers ; ic ; ic = ic->next ){
na_ipivot_consumer_notify_of_create_root_menu_changed( NA_IPIVOT_CONSUMER( ic->data ), should_create );
}
@@ -1083,7 +936,7 @@ display_about_changed( NAPivot *pivot )
g_debug( "%s: pivot=%p", thisfn, ( void * ) pivot );
- display_about = na_iprefs_read_bool( NA_IPREFS( pivot ), IPREFS_ADD_ABOUT_ITEM, TRUE );
+ display_about = na_iprefs_read_bool( NA_IPREFS( pivot ), NA_IPREFS_ITEMS_ADD_ABOUT_ITEM, TRUE );
for( ic = pivot->private->consumers ; ic ; ic = ic->next ){
na_ipivot_consumer_notify_of_display_about_changed( NA_IPIVOT_CONSUMER( ic->data ), display_about );
@@ -1105,8 +958,8 @@ autosave_changed( NAPivot *pivot )
g_debug( "%s: pivot=%p", thisfn, ( void * ) pivot );
- autosave_on = na_iprefs_read_bool( NA_IPREFS( pivot ), IPREFS_AUTOSAVE_ON, FALSE );
- autosave_period = na_iprefs_read_uint( NA_IPREFS( pivot ), IPREFS_AUTOSAVE_PERIOD, 5 );
+ autosave_on = na_iprefs_read_bool( NA_IPREFS( pivot ), NA_IPREFS_MAIN_SAVE_AUTO, FALSE );
+ autosave_period = na_iprefs_read_uint( NA_IPREFS( pivot ), NA_IPREFS_MAIN_SAVE_PERIOD, 5 );
for( ic = pivot->private->consumers ; ic ; ic = ic->next ){
na_ipivot_consumer_notify_of_autosave_changed( NA_IPIVOT_CONSUMER( ic->data ), autosave_on, autosave_period );
diff --git a/src/core/na-pivot.h b/src/core/na-pivot.h
index 690e1ca..aa43b4a 100644
--- a/src/core/na-pivot.h
+++ b/src/core/na-pivot.h
@@ -53,7 +53,11 @@
* This notification system is so a double-stage one :
*
* 1. When an I/O storage subsystem detects a change on an action, it
- * should emit the "na-iio-provider-notify-pivot" signal to
+ * should call the na_iio_provider_item_changed() function, which
+ * itself will emit the "io-provider-item-changed" signal.
+ *
+ * All these signals are catched by na_pivot_on_item_changed_handler()
+ *
* notify #NAPivot of this change. The user data associated with the
* message is the internal id of the #NAObjectItem-derived modified
* object.
@@ -112,23 +116,34 @@ GType na_pivot_get_type( void );
/* properties
*/
-#define NAPIVOT_PROP_TREE "na-pivot-prop-tree"
+#define PIVOT_PROP_TREE "pivot-prop-tree"
+
+/* signals
+ *
+ * NAPivot acts as a 'sumarrizing' proxy for signals emitted by the NAIIOProvider
+ * providers when they detect a modification of their underlying items storage
+ * subsystems.
+ * As several to many signals may be emitted when such a modification occurs,
+ * NAPivot summarizes all these signals in an only one 'items-changed' event.
+ */
+#define PIVOT_SIGNAL_ITEMS_CHANGED "pivot-items-changed"
/* Loadable population
* NACT management user interface defaults to PIVOT_LOAD_ALL
* N-A plugin set the loadable population to !PIVOT_LOAD_DISABLED & !PIVOT_LOAD_INVALID
*/
-enum {
+typedef enum {
PIVOT_LOAD_NONE = 0,
PIVOT_LOAD_DISABLED = 1 << 0,
PIVOT_LOAD_INVALID = 1 << 1,
PIVOT_LOAD_ALL = 0xff
-};
+}
+ NAPivotLoadableSet;
NAPivot *na_pivot_new ( void );
void na_pivot_dump( const NAPivot *pivot );
-/* Management of the NAIxxxxProvider interfaces
+/* Management of the plugins which claim to implement a Nautilus-Actions interface.
* As of 2.30, these are NAIIOProvider, NAIImporter, NAIExporter
*/
GList *na_pivot_get_providers ( const NAPivot *pivot, GType type );
@@ -141,9 +156,7 @@ GList *na_pivot_get_items ( const NAPivot *pivot );
void na_pivot_load_items ( NAPivot *pivot );
void na_pivot_set_new_items( NAPivot *pivot, GList *tree );
-void na_pivot_item_changed_handler( NAIIOProvider *provider, const gchar *id, NAPivot *pivot );
-
-gboolean na_pivot_write_level_zero( const NAPivot *pivot, GList *items, GSList **messages );
+void na_pivot_on_item_changed_handler( NAIIOProvider *provider, const gchar *id, NAPivot *pivot );
/* NAIPivotConsumer interface management
* to be deprecated
@@ -152,25 +165,15 @@ void na_pivot_register_consumer( NAPivot *pivot, const NAIPivotConsumer
/*
* Monitoring and preferences management
- *
- * NAPivot acts as a proxy for signals emitted by the NAIIOProvider providers
- * when they detect a modification of their underlying items storage subsystems.
- * As several to many signals may be emitted when such a modification occurs,
- * NAPivot summarizes all these signals in an only one 'items-changed' event.
*/
-#define PIVOT_SIGNAL_ITEMS_CHANGED "pivot-items-changed"
-NASettings *na_pivot_get_settings ( NAPivot *pivot );
+NASettings *na_pivot_get_settings ( const NAPivot *pivot );
/* NAPivot properties and configuration
*/
void na_pivot_set_automatic_reload ( NAPivot *pivot, gboolean reload );
-
-gboolean na_pivot_is_disable_loadable ( const NAPivot *pivot );
-gboolean na_pivot_is_invalid_loadable ( const NAPivot *pivot );
void na_pivot_set_loadable ( NAPivot *pivot, guint loadable );
-gboolean na_pivot_is_level_zero_writable ( const NAPivot *pivot );
gboolean na_pivot_is_configuration_locked_by_admin( const NAPivot *pivot );
G_END_DECLS
diff --git a/src/core/na-settings.c b/src/core/na-settings.c
index e5fe994..174a6be 100644
--- a/src/core/na-settings.c
+++ b/src/core/na-settings.c
@@ -111,6 +111,8 @@ typedef struct {
KeyDef;
static const KeyDef st_def_keys[] = {
+ { NA_IPREFS_ADMIN_PREFERENCES_LOCKED, GROUP_RUNTIME, NA_BOXED_TYPE_BOOLEAN, "false" },
+ { NA_IPREFS_ADMIN_IO_PROVIDERS_LOCKED, GROUP_RUNTIME, NA_BOXED_TYPE_BOOLEAN, "false" },
{ NA_IPREFS_ASSISTANT_ESC_CONFIRM, GROUP_NACT, NA_BOXED_TYPE_BOOLEAN, "true" },
{ NA_IPREFS_ASSISTANT_ESC_QUIT, GROUP_NACT, NA_BOXED_TYPE_BOOLEAN, "true" },
{ NA_IPREFS_CAPABILITY_ADD_CAPABILITY_WSP, GROUP_NACT, NA_BOXED_TYPE_UINT_LIST, "" },
@@ -187,9 +189,9 @@ static KeyValue *read_key_value_from_key_file( GKeyFile *key_file, const gchar *
static void release_consumer( Consumer *consumer );
static void release_key_file( KeyFile *key_file );
static void release_key_value( KeyValue *value );
-static void set_key_value( NASettings *settings, const gchar *group, const gchar *key, const gchar *string );
+static gboolean set_key_value( NASettings *settings, const gchar *group, const gchar *key, const gchar *string );
static gulong time_val_diff( const GTimeVal *recent, const GTimeVal *old );
-static void write_user_key_file( NASettings *settings );
+static gboolean write_user_key_file( NASettings *settings );
GType
na_settings_get_type( void )
@@ -657,16 +659,47 @@ na_settings_get_uint_list( NASettings *settings, const gchar *key, gboolean *fou
* This function should only be called for unambiguous keys; the resultat
* is otherwise undefined (and rather unpredictable).
*
+ * Returns: %TRUE is the writing has been successfull, %FALSE else.
+ *
* Since: 3.1.0
*/
-void
+gboolean
na_settings_set_boolean( NASettings *settings, const gchar *key, gboolean value )
{
gchar *string;
+ gboolean ok;
string = g_strdup_printf( "%s", value ? "true" : "false" );
- set_key_value( settings, NULL, key, string );
+ ok = set_key_value( settings, NULL, key, string );
g_free( string );
+
+ return( ok );
+}
+
+/**
+ * na_settings_set_boolean_ex:
+ * @settings: this #NASettings instance.
+ * @group: the group in the keyed file;
+ * @key: the key whose value is to be returned.
+ * @value: the boolean to be written.
+ *
+ * This function writes @value as a user preference.
+ *
+ * Returns: %TRUE is the writing has been successfull, %FALSE else.
+ *
+ * Since: 3.1.0
+ */
+gboolean
+na_settings_set_boolean_ex( NASettings *settings, const gchar *group, const gchar *key, gboolean value )
+{
+ gchar *string;
+ gboolean ok;
+
+ string = g_strdup_printf( "%s", value ? "true" : "false" );
+ ok = set_key_value( settings, group, key, string );
+ g_free( string );
+
+ return( ok );
}
/**
@@ -680,12 +713,14 @@ na_settings_set_boolean( NASettings *settings, const gchar *key, gboolean value
* This function should only be called for unambiguous keys; the resultat
* is otherwise undefined (and rather unpredictable).
*
+ * Returns: %TRUE is the writing has been successfull, %FALSE else.
+ *
* Since: 3.1.0
*/
-void
+gboolean
na_settings_set_string( NASettings *settings, const gchar *key, const gchar *value )
{
- set_key_value( settings, NULL, key, value );
+ return( set_key_value( settings, NULL, key, value ));
}
/**
@@ -699,20 +734,25 @@ na_settings_set_string( NASettings *settings, const gchar *key, const gchar *val
* This function should only be called for unambiguous keys; the resultat
* is otherwise undefined (and rather unpredictable).
*
+ * Returns: %TRUE is the writing has been successfull, %FALSE else.
+ *
* Since: 3.1.0
*/
-void
+gboolean
na_settings_set_string_list( NASettings *settings, const gchar *key, const GSList *value )
{
GString *string;
const GSList *it;
+ gboolean ok;
string = g_string_new( "" );
for( it = value ; it ; it = it->next ){
g_string_append_printf( string, "%s;", ( const gchar * ) it->data );
}
- set_key_value( settings, NULL, key, string->str );
+ ok = set_key_value( settings, NULL, key, string->str );
g_string_free( string, TRUE );
+
+ return( ok );
}
/**
@@ -726,16 +766,21 @@ na_settings_set_string_list( NASettings *settings, const gchar *key, const GSLis
* This function should only be called for unambiguous keys; the resultat
* is otherwise undefined (and rather unpredictable).
*
+ * Returns: %TRUE is the writing has been successfull, %FALSE else.
+ *
* Since: 3.1.0
*/
-void
+gboolean
na_settings_set_uint( NASettings *settings, const gchar *key, guint value )
{
gchar *string;
+ gboolean ok;
string = g_strdup_printf( "%u", value );
- set_key_value( settings, NULL, key, string );
+ ok = set_key_value( settings, NULL, key, string );
g_free( string );
+
+ return( ok );
}
/**
@@ -749,20 +794,25 @@ na_settings_set_uint( NASettings *settings, const gchar *key, guint value )
* This function should only be called for unambiguous keys; the resultat
* is otherwise undefined (and rather unpredictable).
*
+ * Returns: %TRUE is the writing has been successfull, %FALSE else.
+ *
* Since: 3.1.0
*/
-void
+gboolean
na_settings_set_uint_list( NASettings *settings, const gchar *key, const GList *value )
{
GString *string;
const GList *it;
+ gboolean ok;
string = g_string_new( "" );
for( it = value ; it ; it = it->next ){
g_string_append_printf( string, "%u;", GPOINTER_TO_UINT( it->data ));
}
- set_key_value( settings, NULL, key, string->str );
+ ok = set_key_value( settings, NULL, key, string->str );
g_string_free( string, TRUE );
+
+ return( ok );
}
/**
@@ -792,13 +842,13 @@ na_settings_get_groups( NASettings *settings )
array = g_key_file_get_groups( settings->private->mandatory->key_file, NULL );
if( array ){
- groups = na_core_utils_slist_from_array( array );
+ groups = na_core_utils_slist_from_array(( const gchar ** ) array );
g_strfreev( array );
}
array = g_key_file_get_groups( settings->private->user->key_file, NULL );
if( array ){
- groups = g_slist_concat( groups, na_core_utils_slist_from_array( array ));
+ groups = g_slist_concat( groups, na_core_utils_slist_from_array(( const gchar ** ) array ));
g_strfreev( array );
}
}
@@ -1059,7 +1109,7 @@ on_keyfile_changed_timeout( NASettings *settings )
group_prefix = NULL;
if( !strcmp( consumer->monitored_key, NA_IPREFS_IO_PROVIDERS_READ_STATUS )){
group_prefix = g_strdup_printf( "%s ", NA_IPREFS_IO_PROVIDER_GROUP );
- key = NA_SETTINGS_IO_PROVIDER_READABLE;
+ key = NA_IPREFS_IO_PROVIDER_READABLE;
} else {
key = consumer->monitored_key;
}
@@ -1245,13 +1295,16 @@ release_key_value( KeyValue *value )
g_free( value );
}
-static void
+static gboolean
set_key_value( NASettings *settings, const gchar *group, const gchar *key, const gchar *string )
{
KeyDef *key_def;
const gchar *wgroup;
+ gboolean ok;
- g_return_if_fail( NA_IS_SETTINGS( settings ));
+ g_return_val_if_fail( NA_IS_SETTINGS( settings ), FALSE );
+
+ ok = FALSE;
if( !settings->private->dispose_has_run ){
@@ -1264,9 +1317,11 @@ set_key_value( NASettings *settings, const gchar *group, const gchar *key, const
}
if( wgroup ){
g_key_file_set_string( settings->private->user->key_file, wgroup, key, string );
- write_user_key_file( settings );
+ ok = write_user_key_file( settings );
}
}
+
+ return( ok );
}
/*
@@ -1280,7 +1335,7 @@ time_val_diff( const GTimeVal *recent, const GTimeVal *old )
return( microsec );
}
-static void
+static gboolean
write_user_key_file( NASettings *settings )
{
static const gchar *thisfn = "na_settings_write_user_key_file";
@@ -1303,7 +1358,7 @@ write_user_key_file( NASettings *settings )
}
g_object_unref( file );
g_free( data );
- return;
+ return( FALSE );
}
g_output_stream_write( G_OUTPUT_STREAM( stream ), data, length, NULL, &error );
@@ -1313,7 +1368,7 @@ write_user_key_file( NASettings *settings )
g_object_unref( stream );
g_object_unref( file );
g_free( data );
- return;
+ return( FALSE );
}
g_output_stream_close( G_OUTPUT_STREAM( stream ), NULL, &error );
@@ -1323,10 +1378,12 @@ write_user_key_file( NASettings *settings )
g_object_unref( stream );
g_object_unref( file );
g_free( data );
- return;
+ return( FALSE );
}
g_object_unref( stream );
g_object_unref( file );
g_free( data );
+
+ return( TRUE );
}
diff --git a/src/core/na-settings.h b/src/core/na-settings.h
index 1c2ecef..e34a871 100644
--- a/src/core/na-settings.h
+++ b/src/core/na-settings.h
@@ -93,6 +93,8 @@ GType na_settings_get_type( void );
/* other keys, mainly user preferences
*/
+#define NA_IPREFS_ADMIN_PREFERENCES_LOCKED "preferences-locked"
+#define NA_IPREFS_ADMIN_IO_PROVIDERS_LOCKED "io-providers-locked"
#define NA_IPREFS_ASSISTANT_ESC_CONFIRM "assistant-esc-confirm"
#define NA_IPREFS_ASSISTANT_ESC_QUIT "assistant-esc-quit"
#define NA_IPREFS_CAPABILITY_ADD_CAPABILITY_WSP "capability-add-capability-wsp"
@@ -137,9 +139,9 @@ GType na_settings_get_type( void );
#define NA_IPREFS_SCHEME_ADD_SCHEME_WSP "scheme-add-scheme-wsp"
#define NA_IPREFS_SCHEME_DEFAULT_LIST "scheme-default-list"
+#define NA_IPREFS_IO_PROVIDER_GROUP "io-provider"
#define NA_IPREFS_IO_PROVIDER_READABLE "readable"
#define NA_IPREFS_IO_PROVIDER_WRITABLE "writable"
-#define NA_IPREFS_IO_PROVIDER_GROUP "io-provider"
#define NA_IPREFS_DEFAULT_EXPORT_FORMAT "Desktop1"
#define NA_IPREFS_DEFAULT_IMPORT_MODE "NoImport"
@@ -158,11 +160,12 @@ GSList *na_settings_get_string_list ( NASettings *settings, const gc
guint na_settings_get_uint ( NASettings *settings, const gchar *key, gboolean *found, gboolean *mandatory );
GList *na_settings_get_uint_list ( NASettings *settings, const gchar *key, gboolean *found, gboolean *mandatory );
-void na_settings_set_boolean ( NASettings *settings, const gchar *key, gboolean value );
-void na_settings_set_string ( NASettings *settings, const gchar *key, const gchar *value );
-void na_settings_set_string_list ( NASettings *settings, const gchar *key, const GSList *value );
-void na_settings_set_uint ( NASettings *settings, const gchar *key, guint value );
-void na_settings_set_uint_list ( NASettings *settings, const gchar *key, const GList *value );
+gboolean na_settings_set_boolean ( NASettings *settings, const gchar *key, gboolean value );
+gboolean na_settings_set_boolean_ex ( NASettings *settings, const gchar *group, const gchar *key, gboolean value );
+gboolean na_settings_set_string ( NASettings *settings, const gchar *key, const gchar *value );
+gboolean na_settings_set_string_list ( NASettings *settings, const gchar *key, const GSList *value );
+gboolean na_settings_set_uint ( NASettings *settings, const gchar *key, guint value );
+gboolean na_settings_set_uint_list ( NASettings *settings, const gchar *key, const GList *value );
/* na_iprefs_get_io_providers() */
GSList *na_settings_get_groups ( NASettings *settings );
diff --git a/src/core/na-updater.c b/src/core/na-updater.c
index 37d2f81..d8d4d79 100644
--- a/src/core/na-updater.c
+++ b/src/core/na-updater.c
@@ -205,9 +205,9 @@ na_updater_append_item( NAUpdater *updater, NAObjectItem *item )
if( !updater->private->dispose_has_run ){
- g_object_get( G_OBJECT( updater ), NAPIVOT_PROP_TREE, &tree, NULL );
+ g_object_get( G_OBJECT( updater ), PIVOT_PROP_TREE, &tree, NULL );
tree = g_list_append( tree, item );
- g_object_set( G_OBJECT( updater ), NAPIVOT_PROP_TREE, tree, NULL );
+ g_object_set( G_OBJECT( updater ), PIVOT_PROP_TREE, tree, NULL );
}
}
@@ -232,7 +232,7 @@ na_updater_insert_item( NAUpdater *updater, NAObjectItem *item, const gchar *par
if( !updater->private->dispose_has_run ){
parent = NULL;
- g_object_get( G_OBJECT( updater ), NAPIVOT_PROP_TREE, &tree, NULL );
+ g_object_get( G_OBJECT( updater ), PIVOT_PROP_TREE, &tree, NULL );
if( parent_id ){
parent = na_pivot_get_item( NA_PIVOT( updater ), parent_id );
@@ -243,7 +243,7 @@ na_updater_insert_item( NAUpdater *updater, NAObjectItem *item, const gchar *par
} else {
tree = g_list_append( tree, item );
- g_object_set( G_OBJECT( updater ), NAPIVOT_PROP_TREE, tree, NULL );
+ g_object_set( G_OBJECT( updater ), PIVOT_PROP_TREE, tree, NULL );
}
}
}
@@ -276,9 +276,9 @@ na_updater_remove_item( NAUpdater *updater, NAObject *item )
na_object_set_items( parent, tree );
} else {
- g_object_get( G_OBJECT( updater ), NAPIVOT_PROP_TREE, &tree, NULL );
+ g_object_get( G_OBJECT( updater ), PIVOT_PROP_TREE, &tree, NULL );
tree = g_list_remove( tree, ( gconstpointer ) item );
- g_object_set( G_OBJECT( updater ), NAPIVOT_PROP_TREE, tree, NULL );
+ g_object_set( G_OBJECT( updater ), PIVOT_PROP_TREE, tree, NULL );
}
}
}
@@ -338,12 +338,18 @@ na_updater_is_item_writable( const NAUpdater *updater, const NAObjectItem *item,
if( reason ){
*reason = NA_IIO_PROVIDER_STATUS_PROVIDER_NOT_WILLING_TO;
}
- } else if( na_io_provider_is_locked_by_admin( provider, NA_IPREFS( updater ))){
+ } else if( !na_io_provider_is_able_to_write( provider )){
writable = FALSE;
if( reason ){
- *reason = NA_IIO_PROVIDER_STATUS_PROVIDER_LOCKED_BY_ADMIN;
+ /* TODO: found a reason */
+ *reason = NA_IIO_PROVIDER_STATUS_PROVIDER_NOT_WILLING_TO;
}
- } else if( !na_io_provider_is_user_writable( provider, NA_IPREFS( updater ))){
+ /*} else if( na_io_provider_is_locked_by_admin( provider, NA_IPREFS( updater ))){
+ writable = FALSE;
+ if( reason ){
+ *reason = NA_IIO_PROVIDER_STATUS_PROVIDER_LOCKED_BY_ADMIN;
+ }*/
+ } else if( !na_io_provider_is_conf_writable( provider, NA_PIVOT( updater ))){
writable = FALSE;
if( reason ){
*reason = NA_IIO_PROVIDER_STATUS_PROVIDER_LOCKED_BY_USER;
@@ -353,17 +359,17 @@ na_updater_is_item_writable( const NAUpdater *updater, const NAObjectItem *item,
if( reason ){
*reason = NA_IIO_PROVIDER_STATUS_CONFIGURATION_LOCKED_BY_ADMIN;
}
- } else if( !na_io_provider_has_write_api( provider )){
+ /*} else if( !na_io_provider_has_write_api( provider )){
writable = FALSE;
if( reason ){
*reason = NA_IIO_PROVIDER_STATUS_NO_API;
- }
+ }*/
}
/* the get_writable_provider() api already takes above checks
*/
} else {
- provider = na_io_provider_get_writable_provider( NA_PIVOT( updater ));
+ provider = na_io_provider_find_writable_io_provider( NA_PIVOT( updater ));
if( !provider ){
writable = FALSE;
if( reason ){
@@ -404,7 +410,7 @@ na_updater_write_item( const NAUpdater *updater, NAObjectItem *item, GSList **me
NAIOProvider *provider = na_object_get_provider( item );
if( !provider ){
- provider = na_io_provider_get_writable_provider( NA_PIVOT( updater ));
+ provider = na_io_provider_find_writable_io_provider( NA_PIVOT( updater ));
if( !provider ){
ret = NA_IIO_PROVIDER_STATUS_NO_PROVIDER_FOUND;
diff --git a/src/nact/nact-add-capability-dialog.c b/src/nact/nact-add-capability-dialog.c
index e85a49e..78cc010 100644
--- a/src/nact/nact-add-capability-dialog.c
+++ b/src/nact/nact-add-capability-dialog.c
@@ -38,6 +38,8 @@
#include <api/na-core-utils.h>
+#include <core/na-settings.h>
+
#include "nact-add-capability-dialog.h"
/* private class data
@@ -302,7 +304,7 @@ nact_add_capability_dialog_run( BaseWindow *parent, GSList *capabilities )
static gchar *
base_get_iprefs_window_id( const BaseWindow *window )
{
- return( g_strdup( "capability-add-capability-wsp" ));
+ return( g_strdup( NA_IPREFS_CAPABILITY_ADD_CAPABILITY_WSP ));
}
static gchar *
diff --git a/src/nact/nact-add-scheme-dialog.c b/src/nact/nact-add-scheme-dialog.c
index f0a6f6b..1db83ff 100644
--- a/src/nact/nact-add-scheme-dialog.c
+++ b/src/nact/nact-add-scheme-dialog.c
@@ -36,6 +36,8 @@
#include <api/na-core-utils.h>
+#include <core/na-settings.h>
+
#include "nact-schemes-list.h"
#include "nact-add-scheme-dialog.h"
@@ -273,7 +275,7 @@ nact_add_scheme_dialog_run( BaseWindow *parent, GSList *schemes )
static gchar *
base_get_iprefs_window_id( const BaseWindow *window )
{
- return( g_strdup( "scheme-add-scheme-wsp" ));
+ return( g_strdup( NA_IPREFS_SCHEME_ADD_SCHEME_WSP ));
}
static gchar *
diff --git a/src/nact/nact-assistant-export.c b/src/nact/nact-assistant-export.c
index 124155e..ffa1c90 100644
--- a/src/nact/nact-assistant-export.c
+++ b/src/nact/nact-assistant-export.c
@@ -327,7 +327,7 @@ nact_assistant_export_run( BaseWindow *main_window )
static gchar *
window_get_iprefs_window_id( const BaseWindow *window )
{
- return( g_strdup( "export-assistant-wsp" ));
+ return( g_strdup( NA_IPREFS_EXPORT_ASSISTANT_WSP ));
}
static gchar *
@@ -349,6 +349,7 @@ on_initial_load_dialog( NactAssistantExport *dialog, gpointer user_data )
GtkAssistant *assistant;
NactApplication *application;
NAUpdater *updater;
+ NASettings *settings;
gboolean esc_quit, esc_confirm;
g_debug( "%s: dialog=%p, user_data=%p", thisfn, ( void * ) dialog, ( void * ) user_data );
@@ -365,9 +366,11 @@ on_initial_load_dialog( NactAssistantExport *dialog, gpointer user_data )
application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( dialog )));
updater = nact_application_get_updater( application );
- esc_quit = na_iprefs_read_bool( NA_IPREFS( updater ), IPREFS_ASSIST_ESC_QUIT, TRUE );
+ settings = na_pivot_get_settings( NA_PIVOT( updater ));
+
+ esc_quit = na_settings_get_boolean( settings, NA_IPREFS_ASSISTANT_ESC_QUIT, NULL, NULL );
base_assistant_set_cancel_on_esc( BASE_ASSISTANT( dialog ), esc_quit );
- esc_confirm = na_iprefs_read_bool( NA_IPREFS( updater ), IPREFS_ASSIST_ESC_CONFIRM, TRUE );
+ esc_confirm = na_settings_get_boolean( settings, NA_IPREFS_ASSISTANT_ESC_CONFIRM, NULL, NULL );
base_assistant_set_warn_on_esc( BASE_ASSISTANT( dialog ), esc_confirm );
}
@@ -504,6 +507,7 @@ assist_runtime_init_target_folder( NactAssistantExport *window, GtkAssistant *as
GtkFileChooser *chooser;
NactApplication *application;
NAUpdater *updater;
+ NASettings *settings;
gchar *uri;
GtkWidget *content;
@@ -512,8 +516,9 @@ assist_runtime_init_target_folder( NactAssistantExport *window, GtkAssistant *as
application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
updater = nact_application_get_updater( application );
+ settings = na_pivot_get_settings( NA_PIVOT( updater ));
- uri = na_iprefs_read_string( NA_IPREFS( updater ), IPREFS_EXPORT_ITEMS_FOLDER_URI, "file:///tmp" );
+ uri = na_settings_get_string( settings, NA_IPREFS_EXPORT_ASSISTANT_URI, NULL, NULL );
if( uri && strlen( uri )){
gtk_file_chooser_set_current_folder_uri( GTK_FILE_CHOOSER( chooser ), uri );
}
@@ -550,6 +555,9 @@ on_folder_selection_changed( GtkFileChooser *chooser, gpointer user_data )
gboolean enabled;
NactAssistantExport *assist;
GtkWidget *content;
+ NactApplication *application;
+ NAUpdater *updater;
+ NASettings *settings;
g_debug( "%s: chooser=%p, user_data=%p", thisfn, ( void * ) chooser, ( void * ) user_data );
g_assert( NACT_IS_ASSISTANT_EXPORT( user_data ));
@@ -566,7 +574,12 @@ on_folder_selection_changed( GtkFileChooser *chooser, gpointer user_data )
if( enabled ){
g_free( assist->private->uri );
assist->private->uri = g_strdup( uri );
- nact_iprefs_write_string( BASE_WINDOW( assist ), IPREFS_EXPORT_ITEMS_FOLDER_URI, uri );
+
+ application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( assist )));
+ updater = nact_application_get_updater( application );
+ settings = na_pivot_get_settings( NA_PIVOT( updater ));
+
+ na_settings_set_string( settings, NA_IPREFS_EXPORT_ASSISTANT_URI, uri );
}
g_free( uri );
@@ -597,7 +610,7 @@ assist_runtime_init_format( NactAssistantExport *window, GtkAssistant *assistant
GtkWidget *container;
GQuark format;
- format = nact_iprefs_get_export_format( BASE_WINDOW( window ), IPREFS_EXPORT_FORMAT );
+ format = nact_iprefs_get_export_format( BASE_WINDOW( window ), NA_IPREFS_EXPORT_PREFERRED_FORMAT );
container = base_window_get_widget( BASE_WINDOW( window ), "AssistantExportFormatVBox" );
nact_export_format_select( container, format );
@@ -697,7 +710,7 @@ assist_prepare_confirm( NactAssistantExport *window, GtkAssistant *assistant, Gt
format = get_export_format( window );
label11 = na_export_format_get_label( format );
label21 = na_export_format_get_description( format );
- nact_iprefs_set_export_format( BASE_WINDOW( window ), IPREFS_EXPORT_FORMAT, na_export_format_get_quark( format ));
+ nact_iprefs_set_export_format( BASE_WINDOW( window ), NA_IPREFS_EXPORT_PREFERRED_FORMAT, na_export_format_get_quark( format ));
label12 = na_core_utils_str_remove_char( label11, "_" );
label22 = na_core_utils_str_add_prefix( "\t", label21 );
g_string_append_printf( text, "\n\n<b>%s</b>\n\n%s", label12, label22 );
@@ -744,7 +757,7 @@ assistant_apply( BaseAssistant *wnd, GtkAssistant *assistant )
str->item = NA_OBJECT_ITEM( na_object_get_origin( NA_IDUPLICABLE( ia->data )));
- str->format = nact_iprefs_get_export_format( BASE_WINDOW( wnd ), IPREFS_EXPORT_FORMAT );
+ str->format = nact_iprefs_get_export_format( BASE_WINDOW( wnd ), NA_IPREFS_EXPORT_PREFERRED_FORMAT );
if( str->format == IPREFS_EXPORT_FORMAT_ASK ){
str->format = nact_export_ask_user( BASE_WINDOW( wnd ), str->item );
diff --git a/src/nact/nact-assistant-import.c b/src/nact/nact-assistant-import.c
index 9b6428d..48bcf7f 100644
--- a/src/nact/nact-assistant-import.c
+++ b/src/nact/nact-assistant-import.c
@@ -76,7 +76,6 @@ struct NactAssistantImportClassPrivate {
*/
struct NactAssistantImportPrivate {
gboolean dispose_has_run;
- GConfClient *gconf;
GList *results;
};
@@ -181,9 +180,11 @@ instance_init( GTypeInstance *instance, gpointer klass )
static const gchar *thisfn = "nact_assistant_import_instance_init";
NactAssistantImport *self;
+ g_return_if_fail( NACT_IS_ASSISTANT_IMPORT( instance ));
+
g_debug( "%s: instance=%p (%s), klass=%p",
thisfn, ( void * ) instance, G_OBJECT_TYPE_NAME( instance ), ( void * ) klass );
- g_return_if_fail( NACT_IS_ASSISTANT_IMPORT( instance ));
+
self = NACT_ASSISTANT_IMPORT( instance );
self->private = g_new0( NactAssistantImportPrivate, 1 );
@@ -202,8 +203,6 @@ instance_init( GTypeInstance *instance, gpointer klass )
BASE_WINDOW_SIGNAL_RUNTIME_INIT,
G_CALLBACK( on_runtime_init_dialog ));
- self->private->gconf = gconf_client_get_default();
-
self->private->dispose_has_run = FALSE;
}
@@ -213,16 +212,15 @@ instance_dispose( GObject *window )
static const gchar *thisfn = "nact_assistant_import_instance_dispose";
NactAssistantImport *self;
- g_debug( "%s: window=%p (%s)", thisfn, ( void * ) window, G_OBJECT_TYPE_NAME( window ));
g_return_if_fail( NACT_IS_ASSISTANT_IMPORT( window ));
+
self = NACT_ASSISTANT_IMPORT( window );
if( !self->private->dispose_has_run ){
+ g_debug( "%s: window=%p (%s)", thisfn, ( void * ) window, G_OBJECT_TYPE_NAME( window ));
self->private->dispose_has_run = TRUE;
- g_object_unref( self->private->gconf );
-
/* chain up to the parent class */
if( G_OBJECT_CLASS( st_parent_class )->dispose ){
G_OBJECT_CLASS( st_parent_class )->dispose( window );
@@ -236,8 +234,10 @@ instance_finalize( GObject *window )
static const gchar *thisfn = "nact_assistant_import_instance_finalize";
NactAssistantImport *self;
- g_debug( "%s: window=%p", thisfn, ( void * ) window );
g_return_if_fail( NACT_IS_ASSISTANT_IMPORT( window ));
+
+ g_debug( "%s: window=%p", thisfn, ( void * ) window );
+
self = NACT_ASSISTANT_IMPORT( window );
free_results( self->private->results );
@@ -276,7 +276,7 @@ nact_assistant_import_run( BaseWindow *main_window )
static gchar *
window_get_iprefs_window_id( const BaseWindow *window )
{
- return( g_strdup( "import-assistant-wsp" ));
+ return( g_strdup( NA_IPREFS_IMPORT_ASSISTANT_WSP ));
}
static gchar *
@@ -291,6 +291,7 @@ on_initial_load_dialog( NactAssistantImport *dialog, gpointer user_data )
static const gchar *thisfn = "nact_assistant_import_on_initial_load_dialog";
NactApplication *application;
NAUpdater *updater;
+ NASettings *settings;
gboolean esc_quit, esc_confirm;
g_debug( "%s: dialog=%p, user_data=%p", thisfn, ( void * ) dialog, ( void * ) user_data );
@@ -298,9 +299,11 @@ on_initial_load_dialog( NactAssistantImport *dialog, gpointer user_data )
application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( dialog )));
updater = nact_application_get_updater( application );
- esc_quit = na_iprefs_read_bool( NA_IPREFS( updater ), IPREFS_ASSIST_ESC_QUIT, TRUE );
+ settings = na_pivot_get_settings( NA_PIVOT( updater ));
+
+ esc_quit = na_settings_get_boolean( settings, NA_IPREFS_ASSISTANT_ESC_QUIT, NULL, NULL );
base_assistant_set_cancel_on_esc( BASE_ASSISTANT( dialog ), esc_quit );
- esc_confirm = na_iprefs_read_bool( NA_IPREFS( updater ), IPREFS_ASSIST_ESC_CONFIRM, TRUE );
+ esc_confirm = na_settings_get_boolean( settings, NA_IPREFS_ASSISTANT_ESC_CONFIRM, NULL, NULL );
base_assistant_set_warn_on_esc( BASE_ASSISTANT( dialog ), esc_confirm );
}
@@ -343,6 +346,7 @@ runtime_init_file_selector( NactAssistantImport *window, GtkAssistant *assistant
static const gchar *thisfn = "nact_assistant_import_runtime_init_file_selector";
NactApplication *application;
NAUpdater *updater;
+ NASettings *settings;
GtkWidget *page;
GtkWidget *chooser;
gchar *uri;
@@ -354,9 +358,10 @@ runtime_init_file_selector( NactAssistantImport *window, GtkAssistant *assistant
application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
updater = nact_application_get_updater( application );
+ settings = na_pivot_get_settings( NA_PIVOT( updater ));
chooser = base_window_get_widget( BASE_WINDOW( window ), "ImportFileChooser" );
- uri = na_iprefs_read_string( NA_IPREFS( updater ), IPREFS_IMPORT_ITEMS_FOLDER_URI, "file:///tmp" );
+ uri = na_settings_get_string( settings, NA_IPREFS_IMPORT_ASSISTANT_URI, NULL, NULL );
if( uri && strlen( uri )){
gtk_file_chooser_set_current_folder_uri( GTK_FILE_CHOOSER( chooser ), uri );
}
@@ -374,9 +379,9 @@ runtime_init_file_selector( NactAssistantImport *window, GtkAssistant *assistant
static void
on_file_selection_changed( GtkFileChooser *chooser, gpointer user_data )
{
- /*static const gchar *thisfn = "nact_assistant_import_on_file_selection_changed";
- g_debug( "%s: chooser=%p, user_data=%p", thisfn, chooser, user_data );*/
-
+ NactApplication *application;
+ NAUpdater *updater;
+ NASettings *settings;
GtkAssistant *assistant;
gint pos;
GSList *uris;
@@ -393,8 +398,12 @@ on_file_selection_changed( GtkFileChooser *chooser, gpointer user_data )
enabled = has_readable_files( uris );
if( enabled ){
+ application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( user_data )));
+ updater = nact_application_get_updater( application );
+ settings = na_pivot_get_settings( NA_PIVOT( updater ));
+
folder = gtk_file_chooser_get_current_folder_uri( GTK_FILE_CHOOSER( chooser ));
- nact_iprefs_write_string( BASE_WINDOW( user_data ), IPREFS_IMPORT_ITEMS_FOLDER_URI, folder );
+ na_settings_set_string( settings, NA_IPREFS_IMPORT_ASSISTANT_URI, folder );
g_free( folder );
}
@@ -468,10 +477,15 @@ runtime_init_duplicates( NactAssistantImport *window, GtkAssistant *assistant )
static const gchar *thisfn = "nact_assistant_import_runtime_init_duplicates";
GtkWidget *page;
guint mode;
+ NactApplication *application;
+ NAUpdater *updater;
g_debug( "%s: window=%p", thisfn, ( void * ) window );
- mode = na_iprefs_get_import_mode( window->private->gconf, IPREFS_IMPORT_ITEMS_IMPORT_MODE );
+ application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
+ updater = nact_application_get_updater( application );
+
+ mode = na_iprefs_get_import_mode( NA_PIVOT( updater ), NA_IPREFS_IMPORT_PREFERRED_MODE );
set_import_mode( window, mode );
page = gtk_assistant_get_nth_page( assistant, ASSIST_PAGE_DUPLICATES );
@@ -740,10 +754,15 @@ prepare_importdone( NactAssistantImport *window, GtkAssistant *assistant, GtkWid
GtkTextTag *title_tag;
GtkTextIter start, end;
gint title_len;
+ NactApplication *application;
+ NAUpdater *updater;
g_debug( "%s: window=%p, assistant=%p, page=%p",
thisfn, ( void * ) window, ( void * ) assistant, ( void * ) page );
+ application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
+ updater = nact_application_get_updater( application );
+
/* i18n: result of the import assistant */
text = g_strdup( _( "Selected files have been proceeded :" ));
title_len = g_utf8_strlen( text, -1 );
@@ -813,7 +832,7 @@ prepare_importdone( NactAssistantImport *window, GtkAssistant *assistant, GtkWid
g_object_unref( title_tag );
mode = get_import_mode( window );
- na_iprefs_set_import_mode( window->private->gconf, IPREFS_IMPORT_ITEMS_IMPORT_MODE, mode );
+ na_iprefs_set_import_mode( NA_PIVOT( updater ), NA_IPREFS_IMPORT_PREFERRED_MODE, mode );
gtk_assistant_set_page_complete( assistant, page, TRUE );
base_assistant_set_warn_on_cancel( BASE_ASSISTANT( window ), FALSE );
diff --git a/src/nact/nact-clipboard.c b/src/nact/nact-clipboard.c
index ce4b345..5e85b6d 100644
--- a/src/nact/nact-clipboard.c
+++ b/src/nact/nact-clipboard.c
@@ -603,7 +603,7 @@ export_row_object( NactClipboard *clipboard, NAObject *object, const gchar *dest
if( index == -1 ){
*exported = g_list_prepend( *exported, ( gpointer ) action );
- format = nact_iprefs_get_export_format( clipboard->private->window, IPREFS_EXPORT_FORMAT );
+ format = nact_iprefs_get_export_format( clipboard->private->window, NA_IPREFS_EXPORT_PREFERRED_FORMAT );
if( format == IPREFS_EXPORT_FORMAT_ASK ){
format = nact_export_ask_user( clipboard->private->window, NA_OBJECT_ITEM( action ));
diff --git a/src/nact/nact-export-ask.c b/src/nact/nact-export-ask.c
index 7dddb7b..1625106 100644
--- a/src/nact/nact-export-ask.c
+++ b/src/nact/nact-export-ask.c
@@ -256,14 +256,14 @@ nact_export_ask_user( BaseWindow *parent, NAObjectItem *item )
editor->private->parent = parent;
editor->private->item = item;
- editor->private->format = nact_iprefs_get_export_format( BASE_WINDOW( parent ), IPREFS_EXPORT_ASK_LAST_FORMAT );
+ editor->private->format = nact_iprefs_get_export_format( BASE_WINDOW( parent ), NA_IPREFS_EXPORT_ASK_USER_LAST_FORMAT );
if( base_window_run( BASE_WINDOW( editor ))){
if( editor->private->format ){
format = editor->private->format;
- nact_iprefs_set_export_format( BASE_WINDOW( parent ), IPREFS_EXPORT_ASK_LAST_FORMAT, format );
+ nact_iprefs_set_export_format( BASE_WINDOW( parent ), NA_IPREFS_EXPORT_ASK_USER_LAST_FORMAT, format );
}
}
@@ -275,7 +275,7 @@ nact_export_ask_user( BaseWindow *parent, NAObjectItem *item )
static gchar *
base_get_iprefs_window_id( const BaseWindow *window )
{
- return( g_strdup( "export-ask-user-wsp" ));
+ return( g_strdup( NA_IPREFS_EXPORT_ASK_USER_WSP ));
}
static gchar *
@@ -392,7 +392,7 @@ get_export_format( NactExportAsk *editor )
button = base_window_get_widget( BASE_WINDOW( editor ), "AskKeepChoiceButton" );
keep = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ));
if( keep ){
- nact_iprefs_set_export_format( BASE_WINDOW( editor ), IPREFS_EXPORT_FORMAT, format_quark );
+ nact_iprefs_set_export_format( BASE_WINDOW( editor ), NA_IPREFS_EXPORT_PREFERRED_FORMAT, format_quark );
}
return( format_quark );
diff --git a/src/nact/nact-gtk-utils.c b/src/nact/nact-gtk-utils.c
index 160ea6c..444d019 100644
--- a/src/nact/nact-gtk-utils.c
+++ b/src/nact/nact-gtk-utils.c
@@ -344,9 +344,11 @@ nact_gtk_utils_select_file_with_preview( BaseWindow *window,
const gchar *text;
gchar *filename, *uri;
GtkWidget *preview;
+ NASettings *settings;
application = NACT_APPLICATION( base_window_get_application( window ));
updater = nact_application_get_updater( application );
+ settings = na_pivot_get_settings( NA_PIVOT( updater ));
toplevel = base_window_get_toplevel( window );
dialog = gtk_file_chooser_dialog_new(
@@ -372,7 +374,7 @@ nact_gtk_utils_select_file_with_preview( BaseWindow *window,
gtk_file_chooser_set_filename( GTK_FILE_CHOOSER( dialog ), text );
} else {
- uri = na_iprefs_read_string( NA_IPREFS( updater ), entry_name, default_dir_uri );
+ uri = na_settings_get_string( settings, entry_name, NULL, NULL );
gtk_file_chooser_set_current_folder_uri( GTK_FILE_CHOOSER( dialog ), uri );
g_free( uri );
}
@@ -384,7 +386,7 @@ nact_gtk_utils_select_file_with_preview( BaseWindow *window,
}
uri = gtk_file_chooser_get_current_folder_uri( GTK_FILE_CHOOSER( dialog ));
- nact_iprefs_write_string( window, entry_name, uri );
+ na_settings_set_string( settings, entry_name, uri );
g_free( uri );
base_iprefs_save_named_window_position( window, GTK_WINDOW( dialog ), dialog_name );
@@ -423,9 +425,11 @@ nact_gtk_utils_select_dir( BaseWindow *window,
GtkWidget *dialog;
const gchar *text;
gchar *dir, *uri;
+ NASettings *settings;
application = NACT_APPLICATION( base_window_get_application( window ));
updater = nact_application_get_updater( application );
+ settings = na_pivot_get_settings( NA_PIVOT( updater ));
toplevel = base_window_get_toplevel( window );
dialog = gtk_file_chooser_dialog_new(
@@ -445,7 +449,7 @@ nact_gtk_utils_select_dir( BaseWindow *window,
gtk_file_chooser_set_filename( GTK_FILE_CHOOSER( dialog ), text );
} else {
- uri = na_iprefs_read_string( NA_IPREFS( updater ), entry_name, default_dir_uri );
+ uri = na_settings_get_string( settings, entry_name, NULL, NULL );
gtk_file_chooser_set_current_folder_uri( GTK_FILE_CHOOSER( dialog ), uri );
g_free( uri );
}
@@ -457,7 +461,7 @@ nact_gtk_utils_select_dir( BaseWindow *window,
}
uri = gtk_file_chooser_get_current_folder_uri( GTK_FILE_CHOOSER( dialog ));
- nact_iprefs_write_string( window, entry_name, uri );
+ na_settings_set_string( settings, entry_name, uri );
g_free( uri );
base_iprefs_save_named_window_position( window, GTK_WINDOW( dialog ), dialog_name );
diff --git a/src/nact/nact-iactions-list.c b/src/nact/nact-iactions-list.c
index 04ac116..9834877 100644
--- a/src/nact/nact-iactions-list.c
+++ b/src/nact/nact-iactions-list.c
@@ -36,6 +36,7 @@
#include "base-window.h"
#include "base-keysyms.h"
+#include "nact-application.h"
#include "nact-main-menubar.h"
#include "nact-main-tab.h"
#include "nact-marshal.h"
@@ -859,6 +860,8 @@ display_label( GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *m
IActionsListInstanceData *ialid;
NAObjectItem *item;
gboolean writable_item;
+ NactApplication *application;
+ NAUpdater *updater;
gtk_tree_model_get( model, iter, IACTIONS_LIST_NAOBJECT_COLUMN, &object, -1 );
g_object_unref( object );
@@ -875,7 +878,10 @@ display_label( GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *m
modified = na_object_is_modified( object );
valid = na_object_is_valid( object );
item = NA_IS_OBJECT_PROFILE( object ) ? na_object_get_parent( object ) : NA_OBJECT_ITEM( object );
- writable_item = nact_window_is_item_writable( NACT_WINDOW( instance ), item, NULL );
+
+ application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( instance )));
+ updater = nact_application_get_updater( application );
+ writable_item = na_updater_is_item_writable( updater, item, NULL );
if( modified ){
g_object_set( cell, "style", PANGO_STYLE_ITALIC, "style-set", TRUE, NULL );
diff --git a/src/nact/nact-icommand-tab.c b/src/nact/nact-icommand-tab.c
index f4d0fad..26a38b8 100644
--- a/src/nact/nact-icommand-tab.c
+++ b/src/nact/nact-icommand-tab.c
@@ -59,14 +59,6 @@ struct NactICommandTabInterfacePrivate {
void *empty; /* so that gcc -pedantic is happy */
};
-/* the Preferences key used to read/write size and position of auxiliary dialogs
- */
-#define IPREFS_LEGEND_WSP "command-legend-wsp"
-#define IPREFS_COMMAND_WSP "command-command-chooser-wsp"
-#define IPREFS_FOLDER_URI "command-command-chooser-last-folder-uri"
-#define IPREFS_WORKING_DIR_WSP "command-working-dir-chooser-wsp"
-#define IPREFS_WORKING_DIR_URI "command-working-dir-chooser-last-folder-uri"
-
/* a data set in the LegendDialog GObject
*/
#define ICOMMAND_TAB_LEGEND_VISIBLE "nact-icommand-tab-legend-dialog-visible"
@@ -193,9 +185,9 @@ nact_icommand_tab_initial_load_toplevel( NactICommandTab *instance )
g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
- nact_iprefs_migrate_key( BASE_WINDOW( instance ), "iconditions-legend-dialog", IPREFS_LEGEND_WSP );
- nact_iprefs_migrate_key( BASE_WINDOW( instance ), "iconditions-command-chooser", IPREFS_COMMAND_WSP );
- nact_iprefs_migrate_key( BASE_WINDOW( instance ), "iconditions-folder-uri", IPREFS_FOLDER_URI );
+ nact_iprefs_migrate_key( BASE_WINDOW( instance ), "iconditions-legend-dialog", NA_IPREFS_COMMAND_LEGEND_WSP );
+ nact_iprefs_migrate_key( BASE_WINDOW( instance ), "iconditions-command-chooser", NA_IPREFS_COMMAND_CHOOSER_WSP );
+ nact_iprefs_migrate_key( BASE_WINDOW( instance ), "iconditions-folder-uri", NA_IPREFS_COMMAND_CHOOSER_URI );
}
}
@@ -478,7 +470,7 @@ legend_dialog_hide( NactICommandTab *instance )
if( is_visible ){
g_return_if_fail( GTK_IS_WINDOW( legend_dialog ));
- base_iprefs_save_named_window_position( BASE_WINDOW( instance ), legend_dialog, IPREFS_LEGEND_WSP );
+ base_iprefs_save_named_window_position( BASE_WINDOW( instance ), legend_dialog, NA_IPREFS_COMMAND_LEGEND_WSP );
gtk_widget_hide( GTK_WIDGET( legend_dialog ));
/* set the legend button state consistent for when the dialog is
@@ -503,7 +495,7 @@ legend_dialog_show( NactICommandTab *instance )
toplevel = base_window_get_toplevel( BASE_WINDOW( instance ));
gtk_window_set_transient_for( GTK_WINDOW( legend_dialog ), toplevel );
- base_iprefs_position_named_window( BASE_WINDOW( instance ), legend_dialog, IPREFS_LEGEND_WSP );
+ base_iprefs_position_named_window( BASE_WINDOW( instance ), legend_dialog, NA_IPREFS_COMMAND_LEGEND_WSP );
gtk_widget_show( GTK_WIDGET( legend_dialog ));
g_object_set_data( G_OBJECT( legend_dialog ), ICOMMAND_TAB_LEGEND_VISIBLE, GINT_TO_POINTER( TRUE ));
@@ -572,8 +564,8 @@ on_path_browse( GtkButton *button, NactICommandTab *instance )
{
nact_gtk_utils_select_file(
BASE_WINDOW( instance ),
- _( "Choosing a command" ), IPREFS_COMMAND_WSP,
- get_path_entry( instance ), IPREFS_FOLDER_URI, "file:///bin" );
+ _( "Choosing a command" ), NA_IPREFS_COMMAND_CHOOSER_WSP,
+ get_path_entry( instance ), NA_IPREFS_COMMAND_CHOOSER_URI, "file:///bin" );
}
static void
@@ -613,8 +605,8 @@ on_wdir_browse( GtkButton *button, NactICommandTab *instance )
nact_gtk_utils_select_dir(
BASE_WINDOW( instance ),
- _( "Choosing a working directory" ), IPREFS_WORKING_DIR_WSP,
- wdir_entry, IPREFS_WORKING_DIR_URI, default_value );
+ _( "Choosing a working directory" ), NA_IPREFS_WORKING_DIR_WSP,
+ wdir_entry, NA_IPREFS_WORKING_DIR_URI, default_value );
g_free( default_value );
}
diff --git a/src/nact/nact-icon-chooser.c b/src/nact/nact-icon-chooser.c
index 2315e08..eb4e401 100644
--- a/src/nact/nact-icon-chooser.c
+++ b/src/nact/nact-icon-chooser.c
@@ -32,8 +32,7 @@
#include <config.h>
#endif
-#include <gdk/gdkkeysyms.h>
-
+#include "base-keysyms.h"
#include "base-iprefs.h"
#include "nact-application.h"
#include "nact-gtk-utils.h"
@@ -55,10 +54,6 @@ struct _NactIconChooserPrivate {
GtkWidget *path_preview;
};
-#define IPREFS_PANED_WIDTH "item-icon-chooser-paned-width"
-#define IPREFS_LAST_URI "item-icon-chooser-last-file-uri"
-#define IPREFS_WSP "item-icon-chooser-wsp"
-
#define VIEW_ICON_SIZE GTK_ICON_SIZE_DND
#define VIEW_ICON_DEFAULT_WIDTH 32 /* width of the GTK_ICON_SIZE_DND icon size */
#define PREVIEW_ICON_SIZE GTK_ICON_SIZE_DIALOG
@@ -247,7 +242,7 @@ instance_dispose( GObject *dialog )
paned = base_window_get_widget( BASE_WINDOW( self ), "IconPaned" );
pos = gtk_paned_get_position( GTK_PANED( paned ));
- base_iprefs_set_int( BASE_WINDOW( self ), IPREFS_PANED_WIDTH, pos );
+ base_iprefs_set_int( BASE_WINDOW( self ), NA_IPREFS_ICON_CHOOSER_PANED, pos );
/* chain up to the parent class */
if( G_OBJECT_CLASS( st_parent_class )->dispose ){
@@ -330,7 +325,7 @@ nact_icon_chooser_choose_icon( BaseWindow *parent, const gchar *icon_name )
static gchar *
base_get_iprefs_window_id( const BaseWindow *window )
{
- return( g_strdup( IPREFS_WSP ));
+ return( g_strdup( NA_IPREFS_ICON_CHOOSER_WSP ));
}
static gchar *
@@ -448,7 +443,7 @@ on_base_runtime_init_dialog( NactIconChooser *editor, gpointer user_data )
g_debug( "%s: editor=%p, user_data=%p", thisfn, ( void * ) editor, ( void * ) user_data );
- pos = base_iprefs_get_int( BASE_WINDOW( editor ), IPREFS_PANED_WIDTH );
+ pos = base_iprefs_get_int( BASE_WINDOW( editor ), NA_IPREFS_ICON_CHOOSER_PANED );
if( pos ){
paned = base_window_get_widget( BASE_WINDOW( editor ), "IconPaned" );
gtk_paned_set_position( GTK_PANED( paned ), pos );
@@ -528,7 +523,7 @@ fillup_icons_by_path( NactIconChooser *editor )
gtk_file_chooser_unselect_all( file_chooser );
- uri = na_settings_get_string( settings, IPREFS_LAST_URI, NULL, NULL );
+ uri = na_settings_get_string( settings, NA_IPREFS_ICON_CHOOSER_URI, NULL, NULL );
if( uri ){
gtk_file_chooser_set_uri( file_chooser, uri );
g_free( uri );
@@ -706,7 +701,7 @@ on_key_pressed_event( GtkWidget *widget, GdkEventKey *event, NactIconChooser *ed
if( !editor->private->dispose_has_run ){
/* inhibit Escape key */
- if( event->keyval == GDK_Escape ){
+ if( event->keyval == NACT_KEY_Escape ){
stop = TRUE;
}
}
@@ -836,7 +831,7 @@ on_path_selection_changed( GtkFileChooser *file_chooser, NactIconChooser *editor
application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( editor )));
updater = nact_application_get_updater( application );
settings = na_pivot_get_settings( NA_PIVOT( updater ));
- na_settings_set_string( settings, IPREFS_LAST_URI, uri );
+ na_settings_set_string( settings, NA_IPREFS_ICON_CHOOSER_URI, uri );
g_free( uri );
}
}
diff --git a/src/nact/nact-ienvironment-tab.c b/src/nact/nact-ienvironment-tab.c
index 2abcbf5..78052dc 100644
--- a/src/nact/nact-ienvironment-tab.c
+++ b/src/nact/nact-ienvironment-tab.c
@@ -40,6 +40,8 @@
#include <api/na-core-utils.h>
#include <api/na-object-api.h>
+#include <core/na-settings.h>
+
#include "nact-gtk-utils.h"
#include "nact-main-tab.h"
#include "nact-ienvironment-tab.h"
@@ -96,13 +98,6 @@ static EnvStruct st_envs[] = {
{ NULL }
};
-/* preferences
- */
-#define IPREFS_SHOW_IF_RUNNING_WSP "environment-show-if-running-wsp"
-#define IPREFS_SHOW_IF_RUNNING_URI "environment-show-if-running-last-folder-uri"
-#define IPREFS_TRY_EXEC_WSP "environment-try-exec-wsp"
-#define IPREFS_TRY_EXEC_URI "environment-try-exec-last-folder-uri"
-
static gboolean st_initialized = FALSE;
static gboolean st_finalized = FALSE;
static gboolean st_on_selection_change = FALSE;
@@ -756,8 +751,8 @@ on_try_exec_browse( GtkButton *button, NactIEnvironmentTab *instance )
nact_gtk_utils_select_file(
BASE_WINDOW( instance ),
- _( "Choosing an executable" ), IPREFS_TRY_EXEC_WSP,
- entry, IPREFS_TRY_EXEC_URI, "file:///bin" );
+ _( "Choosing an executable" ), NA_IPREFS_TRY_EXEC_WSP,
+ entry, NA_IPREFS_TRY_EXEC_URI, "file:///bin" );
}
static void
@@ -814,8 +809,8 @@ on_show_if_running_browse( GtkButton *button, NactIEnvironmentTab *instance )
nact_gtk_utils_select_file(
BASE_WINDOW( instance ),
- _( "Choosing an executable" ), IPREFS_SHOW_IF_RUNNING_WSP,
- entry, IPREFS_SHOW_IF_RUNNING_URI, "file:///bin" );
+ _( "Choosing an executable" ), NA_IPREFS_SHOW_IF_RUNNING_WSP,
+ entry, NA_IPREFS_SHOW_IF_RUNNING_URI, "file:///bin" );
}
static void
diff --git a/src/nact/nact-ifolders-tab.c b/src/nact/nact-ifolders-tab.c
index df4bf3d..87e5870 100644
--- a/src/nact/nact-ifolders-tab.c
+++ b/src/nact/nact-ifolders-tab.c
@@ -57,9 +57,6 @@ struct NactIFoldersTabInterfacePrivate {
#define ITAB_NAME "folders"
-#define IPREFS_FOLDERS_WSP "folder-chooser-wsp"
-#define IPREFS_FOLDERS_URI "folder-last-folder-uri"
-
static gboolean st_initialized = FALSE;
static gboolean st_finalized = FALSE;
@@ -275,6 +272,7 @@ on_browse_folder_clicked( GtkButton *button, BaseWindow *window )
GtkWidget *dialog;
NactApplication *application;
NAUpdater *updater;
+ NASettings *settings;
uri = NULL;
toplevel = base_window_get_toplevel( window );
@@ -291,10 +289,11 @@ on_browse_folder_clicked( GtkButton *button, BaseWindow *window )
application = NACT_APPLICATION( base_window_get_application( window ));
updater = nact_application_get_updater( application );
+ settings = na_pivot_get_settings( NA_PIVOT( updater ));
- base_iprefs_position_named_window( window, GTK_WINDOW( dialog ), IPREFS_FOLDERS_WSP );
+ base_iprefs_position_named_window( window, GTK_WINDOW( dialog ), NA_IPREFS_FOLDER_CHOOSER_WSP );
- uri = na_iprefs_read_string( NA_IPREFS( updater ), IPREFS_FOLDERS_URI, "file:///" );
+ uri = na_settings_get_string( settings, NA_IPREFS_FOLDER_CHOOSER_URI, NULL, NULL );
if( uri && g_utf8_strlen( uri, -1 )){
gtk_file_chooser_set_current_folder_uri( GTK_FILE_CHOOSER( dialog ), uri );
}
@@ -302,7 +301,7 @@ on_browse_folder_clicked( GtkButton *button, BaseWindow *window )
if( gtk_dialog_run( GTK_DIALOG( dialog )) == GTK_RESPONSE_ACCEPT ){
uri = gtk_file_chooser_get_current_folder_uri( GTK_FILE_CHOOSER( dialog ));
- nact_iprefs_write_string( window, IPREFS_FOLDERS_URI, uri );
+ na_settings_set_string( settings, NA_IPREFS_FOLDER_CHOOSER_URI, uri );
path = g_filename_from_uri( uri, NULL, NULL );
nact_match_list_insert_row( window, ITAB_NAME, path, FALSE, FALSE );
@@ -311,7 +310,7 @@ on_browse_folder_clicked( GtkButton *button, BaseWindow *window )
g_free( uri );
}
- base_iprefs_save_named_window_position( window, GTK_WINDOW( dialog ), IPREFS_FOLDERS_WSP );
+ base_iprefs_save_named_window_position( window, GTK_WINDOW( dialog ), NA_IPREFS_FOLDER_CHOOSER_WSP );
gtk_widget_destroy( dialog );
}
diff --git a/src/nact/nact-iprefs.c b/src/nact/nact-iprefs.c
index 0156338..6e6a258 100644
--- a/src/nact/nact-iprefs.c
+++ b/src/nact/nact-iprefs.c
@@ -147,7 +147,7 @@ nact_iprefs_get_export_format( const BaseWindow *window, const gchar *name )
NASettings *settings;
gchar *format_str;
- export_format = g_quark_from_static_string( IPREFS_EXPORT_FORMAT_DEFAULT );
+ export_format = g_quark_from_static_string( NA_IPREFS_DEFAULT_EXPORT_FORMAT );
g_return_val_if_fail( BASE_IS_WINDOW( window ), export_format );
diff --git a/src/nact/nact-iprefs.h b/src/nact/nact-iprefs.h
index af4b27f..a063cea 100644
--- a/src/nact/nact-iprefs.h
+++ b/src/nact/nact-iprefs.h
@@ -58,18 +58,6 @@ typedef struct {
}
NactIPrefsInterface;
-#define IPREFS_EXPORT_ITEMS_FOLDER_URI "export-last-folder-uri"
-#define IPREFS_EXPORT_FORMAT "export-preferred-format"
-#define IPREFS_EXPORT_ASK_LAST_FORMAT "export-ask-user-last-format"
-#define IPREFS_IMPORT_ITEMS_FOLDER_URI "import-last-folder-uri"
-#define IPREFS_ASSIST_ESC_QUIT "assistant-esc-quit"
-#define IPREFS_ASSIST_ESC_CONFIRM "assistant-esc-confirm"
-
-/* these are special export formats
- */
-#define IPREFS_EXPORT_NO_EXPORT 0
-#define IPREFS_EXPORT_FORMAT_DEFAULT "Desktop1"
-
GType nact_iprefs_get_type( void );
GQuark nact_iprefs_get_export_format( const BaseWindow *window, const gchar *pref );
diff --git a/src/nact/nact-main-menubar-edit.c b/src/nact/nact-main-menubar-edit.c
index e3497a3..a137ade 100644
--- a/src/nact/nact-main-menubar-edit.c
+++ b/src/nact/nact-main-menubar-edit.c
@@ -134,7 +134,7 @@ nact_main_menubar_edit_on_update_sensitivities( NactMainWindow *window, gpointer
if( paste_enabled ){
parent_item = ( NAObject * ) na_object_get_parent( selected_item );
paste_enabled &= parent_item
- ? nact_window_is_item_writable( NACT_WINDOW( window ), NA_OBJECT_ITEM( parent_item ), NULL )
+ ? na_updater_is_item_writable( mis->updater, NA_OBJECT_ITEM( parent_item ), NULL )
: mis->is_level_zero_writable;
}
} else {
@@ -161,7 +161,7 @@ nact_main_menubar_edit_on_update_sensitivities( NactMainWindow *window, gpointer
if( paste_into_enabled ){
selected_action = NA_OBJECT( mis->selected_items->data );
paste_into_enabled &= NA_IS_OBJECT_ACTION( selected_action );
- paste_into_enabled &= nact_window_is_item_writable( NACT_WINDOW( window ), NA_OBJECT_ITEM( selected_action ), NULL );
+ paste_into_enabled &= na_updater_is_item_writable( mis->updater, NA_OBJECT_ITEM( selected_action ), NULL );
}
} else {
paste_into_enabled &= mis->has_writable_providers;
@@ -171,7 +171,7 @@ nact_main_menubar_edit_on_update_sensitivities( NactMainWindow *window, gpointer
if( paste_into_enabled ){
parent_item = ( NAObject * ) na_object_get_parent( selected_item );
paste_into_enabled &= parent_item
- ? nact_window_is_item_writable( NACT_WINDOW( window ), NA_OBJECT_ITEM( parent_item ), NULL )
+ ? na_updater_is_item_writable( mis->updater, NA_OBJECT_ITEM( parent_item ), NULL )
: mis->is_level_zero_writable;
}
} else {
@@ -642,13 +642,16 @@ nact_main_menubar_edit_is_pasted_object_relabeled( NAObject *object, NAPivot *pi
{
static const gchar *thisfn = "nact_main_menubar_edit_is_pasted_object_relabeled";
gboolean relabel;
+ NASettings *settings;
+
+ settings = na_pivot_get_settings( pivot );
if( NA_IS_OBJECT_MENU( object )){
- relabel = na_iprefs_read_bool( NA_IPREFS( pivot ), IPREFS_RELABEL_MENUS, FALSE );
+ relabel = na_settings_get_boolean( settings, NA_IPREFS_RELABEL_DUPLICATE_MENU, NULL, NULL );
} else if( NA_IS_OBJECT_ACTION( object )){
- relabel = na_iprefs_read_bool( NA_IPREFS( pivot ), IPREFS_RELABEL_ACTIONS, FALSE );
+ relabel = na_settings_get_boolean( settings, NA_IPREFS_RELABEL_DUPLICATE_ACTION, NULL, NULL );
} else if( NA_IS_OBJECT_PROFILE( object )){
- relabel = na_iprefs_read_bool( NA_IPREFS( pivot ), IPREFS_RELABEL_PROFILES, FALSE );
+ relabel = na_settings_get_boolean( settings, NA_IPREFS_RELABEL_DUPLICATE_PROFILE, NULL, NULL );
} else {
g_warning( "%s: unknown object type at %p", thisfn, ( void * ) object );
g_return_val_if_reached( FALSE );
diff --git a/src/nact/nact-main-menubar-file.c b/src/nact/nact-main-menubar-file.c
index 9ae8d75..6cb3eda 100644
--- a/src/nact/nact-main-menubar-file.c
+++ b/src/nact/nact-main-menubar-file.c
@@ -38,6 +38,7 @@
#include <api/na-core-utils.h>
#include <core/na-io-provider.h>
+#include <core/na-iprefs.h>
#include "nact-application.h"
#include "nact-iactions-list.h"
@@ -76,12 +77,17 @@ nact_main_menubar_file_on_update_sensitivities( NactMainWindow *window, gpointer
gboolean is_first_parent_writable;
gboolean has_modified_items;
GList *is;
+ NactApplication *application;
+ NAUpdater *updater;
+
+ application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
+ updater = nact_application_get_updater( application );
first_parent = mis->selected_items && g_list_length( mis->selected_items )
? ( NAObject * ) na_object_get_parent( mis->selected_items->data )
: NULL;
is_first_parent_writable = first_parent
- ? nact_window_is_item_writable( NACT_WINDOW( window ), NA_OBJECT_ITEM( first_parent ), NULL )
+ ? na_updater_is_item_writable( mis->updater, NA_OBJECT_ITEM( first_parent ), NULL )
: mis->is_level_zero_writable;
has_modified_items = nact_main_window_has_modified_items( window );
@@ -129,7 +135,7 @@ nact_main_menubar_file_on_update_sensitivities( NactMainWindow *window, gpointer
nact_main_menubar_enable_item( window, "NewProfileItem",
new_profile_enabled &&
selected_action != NULL &&
- nact_window_is_item_writable( NACT_WINDOW( window ), NA_OBJECT_ITEM( selected_action ), NULL ));
+ na_updater_is_item_writable( mis->updater, NA_OBJECT_ITEM( selected_action ), NULL ));
/* save enabled if at least one item has been modified
* or level-zero has been resorted and is writable
@@ -310,7 +316,7 @@ nact_main_menubar_file_save_items( NactMainWindow *window )
items = nact_iactions_list_bis_get_items( NACT_IACTIONS_LIST( window ));
messages = NULL;
- if( !na_pivot_write_level_zero( NA_PIVOT( updater ), items, &messages )){
+ if( !na_iprefs_write_level_zero( NA_PIVOT( updater ), items, &messages )){
if( g_slist_length( messages )){
msg = na_core_utils_slist_join_at_end( messages, "\n" );
} else {
diff --git a/src/nact/nact-main-menubar.c b/src/nact/nact-main-menubar.c
index 6b7053c..26fd752 100644
--- a/src/nact/nact-main-menubar.c
+++ b/src/nact/nact-main-menubar.c
@@ -544,7 +544,7 @@ on_update_sensitivities( NactMainWindow *window, gpointer user_data )
application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
mis->updater = nact_application_get_updater( application );
- mis->is_level_zero_writable = na_pivot_is_level_zero_writable( NA_PIVOT( mis->updater ));
+ mis->is_level_zero_writable = na_iprefs_is_level_zero_writable( NA_PIVOT( mis->updater ));
mis->has_writable_providers = nact_window_has_writable_providers( NACT_WINDOW( window ));
g_debug( "%s: has_writable_providers=%s", thisfn, mis->has_writable_providers ? "True":"False" );
diff --git a/src/nact/nact-main-toolbar.c b/src/nact/nact-main-toolbar.c
index 48bd5af..d344022 100644
--- a/src/nact/nact-main-toolbar.c
+++ b/src/nact/nact-main-toolbar.c
@@ -48,10 +48,10 @@ typedef struct {
ToolbarProps;
static ToolbarProps toolbar_props[] = {
- { MAIN_TOOLBAR_FILE_ID , "main-file-toolbar" , TRUE, "ViewFileToolbarItem" , "/ui/FileToolbar" },
- { MAIN_TOOLBAR_EDIT_ID , "main-edit-toolbar" , FALSE, "ViewEditToolbarItem" , "/ui/EditToolbar" },
- { MAIN_TOOLBAR_TOOLS_ID, "main-tools-toolbar", FALSE, "ViewToolsToolbarItem", "/ui/ToolsToolbar" },
- { MAIN_TOOLBAR_HELP_ID , "main-help-toolbar" , TRUE, "ViewHelpToolbarItem" , "/ui/HelpToolbar" }
+ { MAIN_TOOLBAR_FILE_ID , NA_IPREFS_MAIN_TOOLBAR_FILE_DISPLAY, TRUE, "ViewFileToolbarItem" , "/ui/FileToolbar" },
+ { MAIN_TOOLBAR_EDIT_ID , NA_IPREFS_MAIN_TOOLBAR_EDIT_DISPLAY, FALSE, "ViewEditToolbarItem" , "/ui/EditToolbar" },
+ { MAIN_TOOLBAR_TOOLS_ID, NA_IPREFS_MAIN_TOOLBAR_TOOLS_DISPLAY, FALSE, "ViewToolsToolbarItem", "/ui/ToolsToolbar" },
+ { MAIN_TOOLBAR_HELP_ID , NA_IPREFS_MAIN_TOOLBAR_HELP_DISPLAY, TRUE, "ViewHelpToolbarItem" , "/ui/HelpToolbar" }
};
/* defines the relative position of the main toolbars
@@ -108,7 +108,7 @@ init_toolbar( NactMainWindow *window, GtkActionGroup *group, int toolbar_id )
updater = nact_application_get_updater( application );
props = get_toolbar_properties( toolbar_id );
if( props ){
- is_active = na_iprefs_read_bool( NA_IPREFS( updater ), props->prefs_key, props->displayed_per_default );
+ is_active = na_settings_get_boolean( na_pivot_get_settings( NA_PIVOT( updater )), props->prefs_key, NULL, NULL );
if( is_active ){
action = GTK_TOGGLE_ACTION( gtk_action_group_get_action( group, props->ui_item ));
gtk_toggle_action_set_active( action, TRUE );
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index 9a79e43..1ce80f6 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -136,9 +136,6 @@ enum {
LAST_SIGNAL
};
-#define IPREFS_MAIN_WSP "main-window-wsp"
-#define IPREFS_MAIN_PANED "main-paned-width"
-
static NactWindowClass *st_parent_class = NULL;
static gint st_signals[ LAST_SIGNAL ] = { 0 };
@@ -763,7 +760,7 @@ instance_dispose( GObject *window )
pane = base_window_get_widget( BASE_WINDOW( window ), "MainPaned" );
pos = gtk_paned_get_position( GTK_PANED( pane ));
- base_iprefs_set_int( BASE_WINDOW( window ), IPREFS_MAIN_PANED, pos );
+ base_iprefs_set_int( BASE_WINDOW( window ), NA_IPREFS_MAIN_PANED, pos );
for( it = self->private->deleted ; it ; it = it->next ){
g_debug( "nact_main_window_instance_dispose: deleted=%p (%s)", ( void * ) it->data, G_OBJECT_TYPE_NAME( it->data ));
@@ -1089,7 +1086,7 @@ base_get_toplevel_name( const BaseWindow *window )
static gchar *
base_get_iprefs_window_id( const BaseWindow *window )
{
- return( g_strdup( IPREFS_MAIN_WSP ));
+ return( g_strdup( NA_IPREFS_MAIN_WINDOW_WSP ));
}
static gboolean
@@ -1126,7 +1123,7 @@ on_base_initial_load_toplevel( NactMainWindow *window, gpointer user_data )
if( !window->private->dispose_has_run ){
- pos = base_iprefs_get_int( BASE_WINDOW( window ), IPREFS_MAIN_PANED );
+ pos = base_iprefs_get_int( BASE_WINDOW( window ), NA_IPREFS_MAIN_PANED );
if( pos ){
pane = base_window_get_widget( BASE_WINDOW( window ), "MainPaned" );
gtk_paned_set_position( GTK_PANED( pane ), pos );
@@ -1191,7 +1188,7 @@ on_base_runtime_init_toplevel( NactMainWindow *window, gpointer user_data )
nact_main_menubar_runtime_init( window );
- order_mode = na_iprefs_get_order_mode( NA_IPREFS( updater ));
+ order_mode = na_iprefs_get_order_mode( NA_PIVOT( updater ));
ipivot_consumer_on_display_order_changed( NA_IPIVOT_CONSUMER( window ), order_mode );
/* fill the IActionsList at last so that all signals are connected
@@ -1493,11 +1490,14 @@ install_autosave( NactMainWindow *window )
guint autosave_period;
NactApplication *application;
NAUpdater *updater;
+ NASettings *settings;
application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
updater = nact_application_get_updater( application );
- autosave_on = na_iprefs_read_bool( NA_IPREFS( updater ), IPREFS_AUTOSAVE_ON, FALSE );
- autosave_period = na_iprefs_read_uint( NA_IPREFS( updater ), IPREFS_AUTOSAVE_PERIOD, 5 );
+ settings = na_pivot_get_settings( NA_PIVOT( updater ));
+
+ autosave_on = na_settings_get_boolean( settings, NA_IPREFS_MAIN_SAVE_AUTO, NULL, NULL );
+ autosave_period = na_settings_get_uint( settings, NA_IPREFS_MAIN_SAVE_PERIOD, NULL, NULL );
nact_main_menubar_file_set_autosave( window, autosave_on, autosave_period );
}
diff --git a/src/nact/nact-preferences-editor.c b/src/nact/nact-preferences-editor.c
index 8db3539..0d26f89 100644
--- a/src/nact/nact-preferences-editor.c
+++ b/src/nact/nact-preferences-editor.c
@@ -53,7 +53,6 @@ struct NactPreferencesEditorClassPrivate {
*/
struct NactPreferencesEditorPrivate {
gboolean dispose_has_run;
- GConfClient *gconf;
};
static GObjectClass *st_parent_class = NULL;
@@ -174,8 +173,6 @@ instance_init( GTypeInstance *instance, gpointer klass )
BASE_WINDOW_SIGNAL_ALL_WIDGETS_SHOWED,
G_CALLBACK( on_base_all_widgets_showed));
- self->private->gconf = gconf_client_get_default();
-
self->private->dispose_has_run = FALSE;
}
@@ -193,8 +190,6 @@ instance_dispose( GObject *dialog )
self->private->dispose_has_run = TRUE;
- g_object_unref( self->private->gconf );
-
nact_schemes_list_dispose( BASE_WINDOW( self ));
nact_providers_list_dispose( BASE_WINDOW( self ));
@@ -259,7 +254,7 @@ nact_preferences_editor_run( BaseWindow *parent )
static gchar *
base_get_iprefs_window_id( const BaseWindow *window )
{
- return( g_strdup( "preferences-wsp" ));
+ return( g_strdup( NA_IPREFS_PREFERENCES_WSP ));
}
static gchar *
@@ -317,15 +312,17 @@ on_base_runtime_init_dialog( NactPreferencesEditor *editor, gpointer user_data )
gboolean auto_save_on;
guint auto_save_period;
GtkAdjustment *adjustment;
+ NASettings *settings;
g_debug( "%s: editor=%p, user_data=%p", thisfn, ( void * ) editor, ( void * ) user_data );
application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( editor )));
updater = nact_application_get_updater( application );
+ settings = na_pivot_get_settings( NA_PIVOT( updater ));
/* first tab: runtime preferences
*/
- order_mode = na_iprefs_get_order_mode( NA_IPREFS( updater ));
+ order_mode = na_iprefs_get_order_mode( NA_PIVOT( updater ));
switch( order_mode ){
case IPREFS_ORDER_ALPHA_ASCENDING:
button = base_window_get_widget( BASE_WINDOW( editor ), "OrderAlphaAscButton" );
@@ -343,25 +340,25 @@ on_base_runtime_init_dialog( NactPreferencesEditor *editor, gpointer user_data )
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), TRUE );
enable_order_mode_buttons( editor );
- create_root_menu = na_iprefs_read_bool( NA_IPREFS( updater ), IPREFS_CREATE_ROOT_MENU, FALSE );
+ create_root_menu = na_settings_get_boolean( settings, NA_IPREFS_ITEMS_CREATE_ROOT_MENU, NULL, NULL );
button = base_window_get_widget( BASE_WINDOW( editor ), "CreateRootMenuButton" );
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), create_root_menu );
- add_about_item = na_iprefs_read_bool( NA_IPREFS( updater ), IPREFS_ADD_ABOUT_ITEM, TRUE );
+ add_about_item = na_settings_get_boolean( settings, NA_IPREFS_ITEMS_ADD_ABOUT_ITEM, NULL, NULL );
button = base_window_get_widget( BASE_WINDOW( editor ), "AddAboutButton" );
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), add_about_item );
/* second tab: ui preferences
*/
- relabel = na_iprefs_read_bool( NA_IPREFS( updater ), IPREFS_RELABEL_MENUS, FALSE );
+ relabel = na_settings_get_boolean( settings, NA_IPREFS_RELABEL_DUPLICATE_MENU, NULL, NULL );
button = base_window_get_widget( BASE_WINDOW( editor ), "RelabelMenuButton" );
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), relabel );
- relabel = na_iprefs_read_bool( NA_IPREFS( updater ), IPREFS_RELABEL_ACTIONS, FALSE );
+ relabel = na_settings_get_boolean( settings, NA_IPREFS_RELABEL_DUPLICATE_ACTION, NULL, NULL );
button = base_window_get_widget( BASE_WINDOW( editor ), "RelabelActionButton" );
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), relabel );
- relabel = na_iprefs_read_bool( NA_IPREFS( updater ), IPREFS_RELABEL_PROFILES, FALSE );
+ relabel = na_settings_get_boolean( settings, NA_IPREFS_RELABEL_DUPLICATE_PROFILE, NULL, NULL );
button = base_window_get_widget( BASE_WINDOW( editor ), "RelabelProfileButton" );
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), relabel );
@@ -373,15 +370,15 @@ on_base_runtime_init_dialog( NactPreferencesEditor *editor, gpointer user_data )
"toggled",
G_CALLBACK( on_esc_quit_toggled ));
- esc_quit = na_iprefs_read_bool( NA_IPREFS( updater ), IPREFS_ASSIST_ESC_QUIT, TRUE );
+ esc_quit = na_settings_get_boolean( settings, NA_IPREFS_ASSISTANT_ESC_QUIT, NULL, NULL );
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), esc_quit );
esc_quit_activated( editor, esc_quit );
- esc_confirm = na_iprefs_read_bool( NA_IPREFS( updater ), IPREFS_ASSIST_ESC_CONFIRM, TRUE );
+ esc_confirm = na_settings_get_boolean( settings, NA_IPREFS_ASSISTANT_ESC_CONFIRM, NULL, NULL );
button = base_window_get_widget( BASE_WINDOW( editor ), "EscConfirmButton" );
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), esc_confirm );
- auto_save_on = na_iprefs_read_bool( NA_IPREFS( updater ), IPREFS_AUTOSAVE_ON, FALSE );
+ auto_save_on = na_settings_get_boolean( settings, NA_IPREFS_MAIN_SAVE_AUTO, NULL, NULL );
button = base_window_get_widget( BASE_WINDOW( editor ), "AutoSaveCheckButton" );
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), auto_save_on );
auto_save_activated( editor, auto_save_on );
@@ -392,14 +389,14 @@ on_base_runtime_init_dialog( NactPreferencesEditor *editor, gpointer user_data )
"toggled",
G_CALLBACK( on_auto_save_toggled ));
- auto_save_period = na_iprefs_read_uint( NA_IPREFS( updater ), IPREFS_AUTOSAVE_PERIOD, 5 );
+ auto_save_period = na_settings_get_uint( settings, NA_IPREFS_MAIN_SAVE_PERIOD, NULL, NULL );
button = base_window_get_widget( BASE_WINDOW( editor ), "AutoSavePeriodicitySpinButton" );
adjustment = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( button ));
gtk_adjustment_configure( adjustment, auto_save_period, 1, 999, 1, 10, 0 );
/* third tab: import tool
*/
- import_mode = na_iprefs_get_import_mode( editor->private->gconf, IPREFS_IMPORT_ITEMS_IMPORT_MODE );
+ import_mode = na_iprefs_get_import_mode( NA_PIVOT( updater ), NA_IPREFS_IMPORT_PREFERRED_MODE );
switch( import_mode ){
case IMPORTER_MODE_ASK:
button = base_window_get_widget( BASE_WINDOW( editor ), "PrefsAskButton" );
@@ -422,7 +419,7 @@ on_base_runtime_init_dialog( NactPreferencesEditor *editor, gpointer user_data )
/* fourth tab: export tool
*/
- export_format = nact_iprefs_get_export_format( BASE_WINDOW( editor ), IPREFS_EXPORT_FORMAT );
+ export_format = nact_iprefs_get_export_format( BASE_WINDOW( editor ), NA_IPREFS_EXPORT_PREFERRED_FORMAT );
container = base_window_get_widget( BASE_WINDOW( editor ), "PreferencesExportFormatVBox" );
nact_export_format_select( container, export_format );
@@ -532,7 +529,7 @@ enable_order_mode_buttons( NactPreferencesEditor *editor )
application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( editor )));
updater = nact_application_get_updater( application );
- writable = na_pivot_is_level_zero_writable( NA_PIVOT( updater ));
+ writable = na_iprefs_is_level_zero_writable( NA_PIVOT( updater ));
button = base_window_get_widget( BASE_WINDOW( editor ), "OrderAlphaAscButton" );
gtk_widget_set_sensitive( button, writable );
@@ -560,9 +557,11 @@ save_preferences( NactPreferencesEditor *editor )
gboolean auto_save_on;
guint auto_save_period;
GtkAdjustment *adjustment;
+ NASettings *settings;
application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( editor )));
updater = nact_application_get_updater( application );
+ settings = na_pivot_get_settings( NA_PIVOT( updater ));
/* first tab: runtime preferences
*/
@@ -581,46 +580,46 @@ save_preferences( NactPreferencesEditor *editor )
}
}
}
- na_iprefs_set_order_mode( NA_IPREFS( updater ), order_mode );
+ na_iprefs_set_order_mode( NA_PIVOT( updater ), order_mode );
button = base_window_get_widget( BASE_WINDOW( editor ), "CreateRootMenuButton" );
enabled = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ));
- nact_iprefs_write_bool( BASE_WINDOW( editor ), IPREFS_CREATE_ROOT_MENU, enabled );
+ na_settings_set_boolean( settings, NA_IPREFS_ITEMS_CREATE_ROOT_MENU, enabled );
button = base_window_get_widget( BASE_WINDOW( editor ), "AddAboutButton" );
enabled = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ));
- nact_iprefs_write_bool( BASE_WINDOW( editor ), IPREFS_ADD_ABOUT_ITEM, enabled );
+ na_settings_set_boolean( settings, NA_IPREFS_ITEMS_ADD_ABOUT_ITEM, enabled );
/* second tab: runtime preferences
*/
button = base_window_get_widget( BASE_WINDOW( editor ), "RelabelMenuButton" );
relabel = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ));
- nact_iprefs_write_bool( BASE_WINDOW( editor ), IPREFS_RELABEL_MENUS, relabel );
+ na_settings_set_boolean( settings, NA_IPREFS_RELABEL_DUPLICATE_MENU, relabel );
button = base_window_get_widget( BASE_WINDOW( editor ), "RelabelActionButton" );
relabel = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ));
- nact_iprefs_write_bool( BASE_WINDOW( editor ), IPREFS_RELABEL_ACTIONS, relabel );
+ na_settings_set_boolean( settings, NA_IPREFS_RELABEL_DUPLICATE_ACTION, relabel );
button = base_window_get_widget( BASE_WINDOW( editor ), "RelabelProfileButton" );
relabel = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ));
- nact_iprefs_write_bool( BASE_WINDOW( editor ), IPREFS_RELABEL_PROFILES, relabel );
+ na_settings_set_boolean( settings, NA_IPREFS_RELABEL_DUPLICATE_PROFILE, relabel );
button = base_window_get_widget( BASE_WINDOW( editor ), "EscCloseButton" );
esc_quit = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ));
- nact_iprefs_write_bool( BASE_WINDOW( editor ), IPREFS_ASSIST_ESC_QUIT, esc_quit );
+ na_settings_set_boolean( settings, NA_IPREFS_ASSISTANT_ESC_QUIT, esc_quit );
button = base_window_get_widget( BASE_WINDOW( editor ), "EscConfirmButton" );
esc_confirm = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ));
- nact_iprefs_write_bool( BASE_WINDOW( editor ), IPREFS_ASSIST_ESC_CONFIRM, esc_confirm );
+ na_settings_set_boolean( settings, NA_IPREFS_ASSISTANT_ESC_CONFIRM, esc_confirm );
button = base_window_get_widget( BASE_WINDOW( editor ), "AutoSaveCheckButton" );
auto_save_on = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ));
- nact_iprefs_write_bool( BASE_WINDOW( editor ), IPREFS_AUTOSAVE_ON, auto_save_on );
+ na_settings_set_boolean( settings, NA_IPREFS_MAIN_SAVE_AUTO, auto_save_on );
button = base_window_get_widget( BASE_WINDOW( editor ), "AutoSavePeriodicitySpinButton" );
adjustment = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( button ));
auto_save_period = ( guint ) gtk_adjustment_get_value( adjustment );
- nact_iprefs_write_uint( BASE_WINDOW( editor ), IPREFS_AUTOSAVE_PERIOD, auto_save_period );
+ na_settings_set_uint( settings, NA_IPREFS_MAIN_SAVE_PERIOD, auto_save_period );
/* third tab: import tool
*/
@@ -639,14 +638,14 @@ save_preferences( NactPreferencesEditor *editor )
}
}
}
- na_iprefs_set_import_mode( editor->private->gconf, IPREFS_IMPORT_ITEMS_IMPORT_MODE, import_mode );
+ na_iprefs_set_import_mode( NA_PIVOT( updater ), NA_IPREFS_IMPORT_PREFERRED_MODE, import_mode );
/* fourth tab: export tool
*/
container = base_window_get_widget( BASE_WINDOW( editor ), "PreferencesExportFormatVBox" );
export_format = nact_export_format_get_selected( container );
nact_iprefs_set_export_format(
- BASE_WINDOW( editor ), IPREFS_EXPORT_FORMAT, na_export_format_get_quark( export_format ));
+ BASE_WINDOW( editor ), NA_IPREFS_EXPORT_PREFERRED_FORMAT, na_export_format_get_quark( export_format ));
/* fifth tab: list of default schemes
*/
diff --git a/src/nact/nact-providers-list.c b/src/nact/nact-providers-list.c
index e384918..d64a4a8 100644
--- a/src/nact/nact-providers-list.c
+++ b/src/nact/nact-providers-list.c
@@ -32,8 +32,6 @@
#include <config.h>
#endif
-#include <gconf/gconf-client.h>
-#include <gdk/gdkkeysyms.h>
#include <glib/gi18n.h>
#include <api/na-core-utils.h>
@@ -58,13 +56,11 @@ enum {
PROVIDER_N_COLUMN
};
-/* some data needed when saving the list sore
+/* some data needed when saving the list store
*/
typedef struct {
- GList *providers;
- GConfClient *gconf;
- gchar *path;
- GSList *order;
+ NASettings *settings;
+ GSList *order;
}
ProvidersListSaveData;
@@ -184,7 +180,8 @@ init_view_setup_providers( GtkTreeView *treeview, BaseWindow *window )
NactApplication *application;
NAUpdater *updater;
GtkListStore *model;
- GList *providers, *iter;
+ const GList *providers;
+ const GList *iter;
GtkTreeIter row;
gchar *id, *libelle;
@@ -192,7 +189,7 @@ init_view_setup_providers( GtkTreeView *treeview, BaseWindow *window )
application = NACT_APPLICATION( base_window_get_application( window ));
updater = nact_application_get_updater( application );
- providers = na_io_provider_get_providers_list( NA_PIVOT( updater ));
+ providers = na_io_provider_get_io_providers_list( NA_PIVOT( updater ));
for( iter = providers ; iter ; iter = iter->next ){
@@ -204,7 +201,7 @@ init_view_setup_providers( GtkTreeView *treeview, BaseWindow *window )
if( !libelle || !g_utf8_strlen( libelle, -1 )){
g_free( libelle );
- if( na_io_provider_get_provider( NA_IO_PROVIDER( iter->data ))){
+ if( na_io_provider_is_available( NA_IO_PROVIDER( iter->data ))){
/* i18n: default name when the I/O providers doesn't provide one */
libelle = g_strdup_printf( "<%s: %s>", id, _( "no name" ));
@@ -216,8 +213,8 @@ init_view_setup_providers( GtkTreeView *treeview, BaseWindow *window )
}
gtk_list_store_set( model, &row,
- PROVIDER_READABLE_COLUMN, na_io_provider_is_user_readable_at_startup( NA_IO_PROVIDER( iter->data ), NA_IPREFS( updater )),
- PROVIDER_WRITABLE_COLUMN, na_io_provider_is_user_writable( NA_IO_PROVIDER( iter->data ), NA_IPREFS( updater )),
+ PROVIDER_READABLE_COLUMN, na_io_provider_is_conf_readable( NA_IO_PROVIDER( iter->data ), NA_PIVOT( updater )),
+ PROVIDER_WRITABLE_COLUMN, na_io_provider_is_conf_writable( NA_IO_PROVIDER( iter->data ), NA_PIVOT( updater )),
PROVIDER_LIBELLE_COLUMN, libelle,
PROVIDER_ID_COLUMN, id,
PROVIDER_PROVIDER_COLUMN, iter->data,
@@ -290,8 +287,7 @@ init_view_select_first_row( GtkTreeView *treeview )
* nact_providers_list_save:
* @window: the #BaseWindow which embeds this treeview.
*
- * Save the I/O provider status as a GConf preference,
- * and update the I/O providers list maintained by #NAIOProvider class.
+ * Save the I/O provider status as a user preference.
*/
void
nact_providers_list_save( BaseWindow *window )
@@ -299,21 +295,19 @@ nact_providers_list_save( BaseWindow *window )
static const gchar *thisfn = "nact_providers_list_save";
NactApplication *application;
NAUpdater *updater;
- GList *providers;
GtkTreeView *treeview;
GtkTreeModel *model;
ProvidersListSaveData *plsd;
+ NASettings *settings;
g_debug( "%s: window=%p", thisfn, ( void * ) window );
application = NACT_APPLICATION( base_window_get_application( window ));
updater = nact_application_get_updater( application );
- providers = na_io_provider_get_providers_list( NA_PIVOT( updater ));
+ settings = na_pivot_get_settings( NA_PIVOT( updater ));
plsd = g_new0( ProvidersListSaveData, 1 );
- plsd->providers = providers;
- plsd->gconf = na_iprefs_get_gconf_client( NA_IPREFS( updater ));
- plsd->path = gconf_concat_dir_and_key( IPREFS_GCONF_BASEDIR, IO_PROVIDER_KEY_ROOT );
+ plsd->settings = settings;
plsd->order = NULL;
treeview = GTK_TREE_VIEW( g_object_get_data( G_OBJECT( window ), PROVIDERS_LIST_TREEVIEW ));
@@ -321,11 +315,9 @@ nact_providers_list_save( BaseWindow *window )
gtk_tree_model_foreach( model, ( GtkTreeModelForeachFunc ) providers_list_save_iter, plsd );
plsd->order = g_slist_reverse( plsd->order );
- na_iprefs_write_string_list( NA_IPREFS( updater ), IO_PROVIDER_KEY_ORDER, plsd->order );
- na_io_provider_reorder_providers_list( NA_PIVOT( updater ));
+ na_settings_set_string_list( settings, NA_IPREFS_IO_PROVIDERS_WRITE_ORDER, plsd->order );
na_core_utils_slist_free( plsd->order );
- g_free( plsd->path );
g_free( plsd );
}
@@ -335,7 +327,7 @@ providers_list_save_iter( GtkTreeModel *model, GtkTreePath *path, GtkTreeIter* i
gchar *id;
gboolean readable, writable;
NAIOProvider *provider;
- gchar *key, *entry;
+ gchar *group;
gtk_tree_model_get( model, iter,
PROVIDER_ID_COLUMN, &id,
@@ -344,21 +336,15 @@ providers_list_save_iter( GtkTreeModel *model, GtkTreePath *path, GtkTreeIter* i
PROVIDER_PROVIDER_COLUMN, &provider,
-1 );
- key = gconf_concat_dir_and_key( plsd->path, id );
-
- entry = gconf_concat_dir_and_key( key, IO_PROVIDER_KEY_READABLE );
- na_gconf_utils_write_bool( plsd->gconf, entry, readable, NULL );
- g_free( entry );
-
- entry = gconf_concat_dir_and_key( key, IO_PROVIDER_KEY_WRITABLE );
- na_gconf_utils_write_bool( plsd->gconf, entry, writable, NULL );
- g_free( entry );
+ group = g_strdup_printf( "%s %s", NA_IPREFS_IO_PROVIDER_GROUP, id );
+ na_settings_set_boolean_ex( plsd->settings, group, NA_IPREFS_IO_PROVIDER_READABLE, readable );
+ na_settings_set_boolean_ex( plsd->settings, group, NA_IPREFS_IO_PROVIDER_WRITABLE, writable );
+ g_free( group );
plsd->order = g_slist_prepend( plsd->order, g_strdup( id ));
g_object_unref( provider );
g_free( id );
- g_free( key );
return( FALSE ); /* don't stop looping */
}
@@ -516,7 +502,7 @@ display_label( GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *m
g_object_set( cell, "style-set", FALSE, NULL );
g_object_set( cell, "foreground-set", FALSE, NULL );
- if( !na_io_provider_get_provider( provider )){
+ if( !na_io_provider_is_available( provider )){
g_object_set( cell, "style", PANGO_STYLE_ITALIC, "style-set", TRUE, NULL );
g_object_set( cell, "foreground", "grey", "foreground-set", TRUE, NULL );
diff --git a/src/nact/nact-schemes-list.c b/src/nact/nact-schemes-list.c
index e6fe73e..32f0c1a 100644
--- a/src/nact/nact-schemes-list.c
+++ b/src/nact/nact-schemes-list.c
@@ -240,10 +240,13 @@ init_view_get_default_list( SchemesListData *data )
GSList *list = NULL;
NactApplication *application;
NAUpdater *updater;
+ NASettings *settings;
application = NACT_APPLICATION( base_window_get_application( data->window ));
updater = nact_application_get_updater( application );
- list = na_iprefs_read_string_list( NA_IPREFS( updater ), "schemes", NULL );
+ settings = na_pivot_get_settings( NA_PIVOT( updater ));
+
+ list = na_settings_get_string_list( settings, NA_IPREFS_SCHEME_DEFAULT_LIST, NULL, NULL );
if( !list ){
list = init_view_get_default_default_list( data );
@@ -468,13 +471,16 @@ nact_schemes_list_save_defaults( BaseWindow *window )
GSList *schemes;
NactApplication *application;
NAUpdater *updater;
+ NASettings *settings;
treeview = GTK_TREE_VIEW( g_object_get_data( G_OBJECT( window ), SCHEMES_LIST_TREEVIEW ));
schemes = get_list_schemes( treeview );
application = NACT_APPLICATION( base_window_get_application( window ));
updater = nact_application_get_updater( application );
- na_iprefs_write_string_list( NA_IPREFS( updater ), "schemes", schemes );
+ settings = na_pivot_get_settings( NA_PIVOT( updater ));
+
+ na_settings_set_string_list( settings, NA_IPREFS_SCHEME_DEFAULT_LIST, schemes );
na_core_utils_slist_free( schemes );
}
diff --git a/src/nact/nact-sort-buttons.c b/src/nact/nact-sort-buttons.c
index fe3f266..76e2fcb 100644
--- a/src/nact/nact-sort-buttons.c
+++ b/src/nact/nact-sort-buttons.c
@@ -213,7 +213,7 @@ enable_buttons( NactMainWindow *window )
application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
updater = nact_application_get_updater( application );
- writable = na_pivot_is_level_zero_writable( NA_PIVOT( updater ));
+ writable = na_iprefs_is_level_zero_writable( NA_PIVOT( updater ));
i = 0;
while( st_toggle_group[i].btn_name ){
@@ -260,7 +260,8 @@ set_new_sort_order( NactMainWindow *window, guint order_mode )
application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
updater = nact_application_get_updater( application );
- na_iprefs_set_order_mode( NA_IPREFS( updater ), order_mode );
+
+ na_iprefs_set_order_mode( NA_PIVOT( updater ), order_mode );
}
}
diff --git a/src/nact/nact-tree-model-dnd.c b/src/nact/nact-tree-model-dnd.c
index d1f2ff4..4c9b3d1 100644
--- a/src/nact/nact-tree-model-dnd.c
+++ b/src/nact/nact-tree-model-dnd.c
@@ -32,7 +32,6 @@
#include <config.h>
#endif
-#include <gconf/gconf-client.h>
#include <glib/gi18n.h>
#include <libintl.h>
#include <string.h>
@@ -863,7 +862,6 @@ drop_uri_list( NactTreeModel *model, GtkTreePath *dest, GtkSelectionData *selec
NAUpdater *updater;
NactMainWindow *main_window;
NAImporterParms parms;
- GConfClient *gconf;
GList *it;
guint count;
GString *str;
@@ -897,9 +895,7 @@ drop_uri_list( NactTreeModel *model, GtkTreePath *dest, GtkSelectionData *selec
parms.parent = base_window_get_toplevel( BASE_WINDOW( main_window ));
parms.uris = g_slist_reverse( na_core_utils_slist_from_split( selection_data_data, "\r\n" ));
- gconf = gconf_client_get_default();
- parms.mode = na_iprefs_get_import_mode( gconf, IPREFS_IMPORT_ITEMS_IMPORT_MODE );
- g_object_unref( gconf );
+ parms.mode = na_iprefs_get_import_mode( NA_PIVOT( updater ), NA_IPREFS_IMPORT_PREFERRED_MODE );
parms.check_fn = ( NAIImporterCheckFn ) is_dropped_already_exists;
parms.check_fn_data = main_window;
@@ -1141,7 +1137,7 @@ is_parent_accept_new_childs( NactApplication *application, NactMainWindow *windo
*/
if( parent == NULL ){
- if( na_pivot_is_level_zero_writable( NA_PIVOT( updater ))){
+ if( na_iprefs_is_level_zero_writable( NA_PIVOT( updater ))){
accept_ok = TRUE;
} else {
diff --git a/src/nact/nact-tree-model.c b/src/nact/nact-tree-model.c
index 1b9230a..e817530 100644
--- a/src/nact/nact-tree-model.c
+++ b/src/nact/nact-tree-model.c
@@ -307,7 +307,7 @@ tree_model_new( BaseWindow *window, GtkTreeView *treeview )
*/
application = NACT_APPLICATION( base_window_get_application( window ));
updater = nact_application_get_updater( application );
- order_mode = na_iprefs_get_order_mode( NA_IPREFS( updater ));
+ order_mode = na_iprefs_get_order_mode( NA_PIVOT( updater ));
nact_tree_model_display_order_change( model, order_mode );
model->private->window = window;
diff --git a/src/nact/nact-window.c b/src/nact/nact-window.c
index 3795c9e..f3b89c1 100644
--- a/src/nact/nact-window.c
+++ b/src/nact/nact-window.c
@@ -196,7 +196,7 @@ nact_window_has_writable_providers( NactWindow *window )
application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
updater = nact_application_get_updater( application );
- provider = na_io_provider_get_writable_provider( NA_PIVOT( updater ));
+ provider = na_io_provider_find_writable_io_provider( NA_PIVOT( updater ));
if( provider ){
has_writables = TRUE;
@@ -206,6 +206,7 @@ nact_window_has_writable_providers( NactWindow *window )
return( has_writables );
}
+#if 0
/**
* nact_window_is_item_writable:
* @window: this #NactWindow object.
@@ -270,7 +271,7 @@ nact_window_is_item_writable( const NactWindow *window, const NAObjectItem *item
if( reason ){
*reason = NA_IIO_PROVIDER_STATUS_PROVIDER_LOCKED_BY_ADMIN;
}
- } else if( !na_io_provider_is_user_writable( provider, NA_IPREFS( updater ))){
+ } else if( !na_io_provider_is_conf_writable( provider, NA_IPREFS( updater ))){
writable = FALSE;
if( reason ){
*reason = NA_IIO_PROVIDER_STATUS_PROVIDER_LOCKED_BY_USER;
@@ -290,7 +291,7 @@ nact_window_is_item_writable( const NactWindow *window, const NAObjectItem *item
/* the get_writable_provider() api already takes above checks
*/
} else {
- provider = na_io_provider_get_writable_provider( NA_PIVOT( updater ));
+ provider = na_io_provider_find_writable_io_provider( NA_PIVOT( updater ));
if( !provider ){
writable = FALSE;
if( reason ){
@@ -303,6 +304,7 @@ nact_window_is_item_writable( const NactWindow *window, const NAObjectItem *item
return( writable );
}
+#endif
/**
* nact_window_save_item:
diff --git a/src/nact/nact-window.h b/src/nact/nact-window.h
index b09cdd4..3484900 100644
--- a/src/nact/nact-window.h
+++ b/src/nact/nact-window.h
@@ -73,7 +73,9 @@ GType nact_window_get_type( void );
gboolean nact_window_has_writable_providers( NactWindow *window );
+#if 0
gboolean nact_window_is_item_writable( const NactWindow *window, const NAObjectItem *item, guint *reason );
+#endif
gboolean nact_window_save_item ( NactWindow *window, NAObjectItem *item, gchar **msgerr );
gboolean nact_window_delete_item( NactWindow *window, const NAObjectItem *item, gchar **msgerr );
diff --git a/src/plugin-menu/nautilus-actions.c b/src/plugin-menu/nautilus-actions.c
index 70c7d39..948599b 100644
--- a/src/plugin-menu/nautilus-actions.c
+++ b/src/plugin-menu/nautilus-actions.c
@@ -237,34 +237,29 @@ instance_constructed( GObject *object )
/* monitor
* - the changes of the readability status of the i/o providers
- * - the changes of the read order of the i/o providers
* - the modification of the level-zero order
* - whether we create a root menu
* - whether we add an 'About Nautilus-Actions' item
* - the preferred order mode
*/
na_settings_register_key_callback( settings,
- NA_SETTINGS_RUNTIME_IO_PROVIDER_READ_STATUS,
+ NA_IPREFS_IO_PROVIDERS_READ_STATUS,
G_CALLBACK( on_runtime_preference_changed ), self );
na_settings_register_key_callback( settings,
- NA_SETTINGS_RUNTIME_IO_PROVIDERS_READ_ORDER,
+ NA_IPREFS_ITEMS_LEVEL_ZERO_ORDER,
G_CALLBACK( on_runtime_preference_changed ), self );
na_settings_register_key_callback( settings,
- NA_SETTINGS_RUNTIME_ITEMS_LEVEL_ZERO_ORDER,
+ NA_IPREFS_ITEMS_CREATE_ROOT_MENU,
G_CALLBACK( on_runtime_preference_changed ), self );
na_settings_register_key_callback( settings,
- NA_SETTINGS_RUNTIME_ITEMS_CREATE_ROOT_MENU,
+ NA_IPREFS_ITEMS_ADD_ABOUT_ITEM,
G_CALLBACK( on_runtime_preference_changed ), self );
na_settings_register_key_callback( settings,
- NA_SETTINGS_RUNTIME_ITEMS_ADD_ABOUT_ITEM,
- G_CALLBACK( on_runtime_preference_changed ), self );
-
- na_settings_register_key_callback( settings,
- NA_SETTINGS_RUNTIME_ITEMS_LIST_ORDER_MODE,
+ NA_IPREFS_ITEMS_LIST_ORDER_MODE,
G_CALLBACK( on_runtime_preference_changed ), self );
/* chain up to the parent class */
@@ -512,12 +507,12 @@ get_menus_items( NautilusActions *plugin, guint target, GList *selection )
settings = na_pivot_get_settings( plugin->private->pivot );
- items_create_root_menu = na_settings_get_boolean( settings, NA_SETTINGS_RUNTIME_ITEMS_CREATE_ROOT_MENU, NULL, NULL );
+ items_create_root_menu = na_settings_get_boolean( settings, NA_IPREFS_ITEMS_CREATE_ROOT_MENU, NULL, NULL );
if( items_create_root_menu ){
menus_list = create_root_menu( plugin, menus_list );
}
- items_add_about_item = na_settings_get_boolean( settings, NA_SETTINGS_RUNTIME_ITEMS_ADD_ABOUT_ITEM, NULL, NULL );
+ items_add_about_item = na_settings_get_boolean( settings, NA_IPREFS_ITEMS_ADD_ABOUT_ITEM, NULL, NULL );
if( items_add_about_item ){
menus_list = add_about_item( plugin, menus_list );
}
diff --git a/src/utils/na-gconf2key.sh.in b/src/utils/na-gconf2key.sh.in
index 89055c4..bdb9bbc 100644
--- a/src/utils/na-gconf2key.sh.in
+++ b/src/utils/na-gconf2key.sh.in
@@ -592,15 +592,18 @@ if [ $(id -u) -eq 0 ]; then
if [ "${bdir}" != "na-gconf" ]; then
value=$(gconftool-2 --get ${dir}/locked 2>/dev/null)
if [ "${value}" != "" ]; then
- [ "${bdir}" = "all" ] && group="nact" || group="io-provider ${bdir}"
- [ "${bdir}" = "all" ] && key="io-providers-all-locked" || key="locked"
- add_pref_provider "${group}" "${key}" "${value}"
+ if [ "${bdir}" = "all" ]; then
+ add_pref "runtime" "preferences-locked" str "${value}"
+ add_pref "runtime" "io-providers-locked" str "${value}"
+ elif [ "${value}" = "true" ]; then
+ add_pref_provider "io-provider ${bdir}" "readable" "false"
+ add_pref_provider "io-provider ${bdir}" "writable" "false"
+ fi
fi
fi
done
# as a security - while we are root -, we force the GConf i/o provider to be locked
cat <<! >${my_tmproot}.io-provider_na-gconf
-locked = true
readable = false
writable = false
!
diff --git a/src/utils/nautilus-actions-new.c b/src/utils/nautilus-actions-new.c
index ef32319..d80b936 100644
--- a/src/utils/nautilus-actions-new.c
+++ b/src/utils/nautilus-actions-new.c
@@ -511,14 +511,15 @@ static gboolean
output_to_gconf( NAObjectAction *action, GSList **msgs )
{
NAUpdater *updater;
- GList *providers;
+ const GList *providers;
NAIOProvider *provider;
guint ret;
gboolean code;
updater = na_updater_new();
- providers = na_io_provider_get_providers_list( NA_PIVOT( updater ));
- provider = na_io_provider_find_provider_by_id( providers, "na-gconf" );
+ providers = na_io_provider_get_io_providers_list( NA_PIVOT( updater ));
+ /*provider = na_io_provider_find_provider_by_id( providers, "na-gconf" );*/
+ provider = NULL;
if( provider ){
na_object_set_provider( action, provider );
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]