[nautilus-actions: 16/30] nautilus-actions-new uses new module architecture



commit 488c52f180597ddf921434b681b59c0ced527e33
Author: Pierre Wieser <pwieser trychlos org>
Date:   Thu Nov 19 23:28:32 2009 +0100

    nautilus-actions-new uses new module architecture
    
    Uses a NAPivot instance and get an available provider from it,
    instead of directly instantiating a NAGConfProvider object.

 ChangeLog                                     |   15 ++++++++--
 TODO                                          |    2 -
 nautilus-actions/runtime/na-pivot.c           |   37 +++++++++++++++++++++++++
 nautilus-actions/runtime/na-pivot.h           |    2 +
 nautilus-actions/utils/nautilus-actions-new.c |   17 +++++++----
 5 files changed, 62 insertions(+), 11 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5facc1b..ec1d0ba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -26,19 +26,28 @@
 	(na_gconf_utils_get_subdirs, na_gconf_utils_free_subdirs,
 	na_gconf_utils_have_entry:): Move functions to NagpIOProvider class.
 
-	* nautilus-actions/runtime/na-module.c:
-	Fix dynamic loading of the modules.
-
 	* nautilus-actions/runtime/na-gconf-utils.c:
 	* nautilus-actions/runtime/na-gconf-utils.h
 	(na_gconf_utils_have_subdir): Removed function.
 
+	* nautilus-actions/runtime/na-module.c:
+	Fix dynamic loading of the modules.
+
+	* nautilus-actions/runtime/na-pivot.c:
+	* nautilus-actions/runtime/na-pivot.h
+	(na_pivot_get_provider, na_pivot_release_provider):
+	New functions.
+
 	* nautilus-actions/nact/nact-xml-reader.c:
 	* nautilus-actions/runtime/Makefile.am:
 	* nautilus-actions/runtime/na-pivot.c:
 	* nautilus-actions/runtime/na-xml-writer.c:
 	Updated accordingly.
 
+	* nautilus-actions/utils/nautilus-actions-new.c:
+	Use NAPivot to find an adequate provider instead of directly
+	instantiating a NAGConfProvider object.
+
 2009-11-18 Pierre Wieser <pwieser trychlos org>
 
 	Move runtime/na-gconf-monitor.{c,h} to api/.
diff --git a/TODO b/TODO
index cc622de..4eacefb 100644
--- a/TODO
+++ b/TODO
@@ -80,5 +80,3 @@
 - export: add a overwrite page: what to do if file already exists ?
 
 - na_object_id_get_topmost_parent: should it return a NAObjectItem ?
-
-- nautilus-actions-new: write to GConf
diff --git a/nautilus-actions/runtime/na-pivot.c b/nautilus-actions/runtime/na-pivot.c
index 5987293..e8db861 100644
--- a/nautilus-actions/runtime/na-pivot.c
+++ b/nautilus-actions/runtime/na-pivot.c
@@ -398,6 +398,43 @@ na_pivot_get_providers( const NAPivot *pivot, GType type )
 }
 
 /**
+ * na_pivot_get_provider:
+ * @pivot: this #NAPivot instance.
+ * @type: the type of searched interface.
+ *
+ * Returns: the first available provider for this interface.
+ *
+ * The returned #GObject should be released by calling na_pivot_release_provider().
+ */
+GObject *
+na_pivot_get_provider( const NAPivot *pivot, GType type )
+{
+	GList *providers;
+	GObject *provider;
+
+	provider = NULL;
+	providers = na_pivot_get_providers( pivot, type );
+	if( providers ){
+		provider = g_object_ref( G_OBJECT( providers->data ));
+		na_pivot_free_providers( providers );
+	}
+
+	return( provider );
+}
+
+/**
+ * na_pivot_release_provider:
+ * @provider: a provider.
+ *
+ * Release the given provider.
+ */
+void
+na_pivot_release_provider( const GObject *provider )
+{
+	g_object_unref(( gpointer ) provider );
+}
+
+/**
  * na_pivot_free_providers:
  * @providers: a list of providers.
  *
diff --git a/nautilus-actions/runtime/na-pivot.h b/nautilus-actions/runtime/na-pivot.h
index 845776e..b5e299d 100644
--- a/nautilus-actions/runtime/na-pivot.h
+++ b/nautilus-actions/runtime/na-pivot.h
@@ -112,6 +112,8 @@ void      na_pivot_check_status( const NAPivot *pivot );
 void      na_pivot_dump( const NAPivot *pivot );
 
 GList    *na_pivot_get_providers( const NAPivot *pivot, GType type );
+GObject  *na_pivot_get_provider( const NAPivot *pivot, GType type );
+void      na_pivot_release_provider( const GObject *provider );
 void      na_pivot_free_providers( GList *providers );
 
 GList    *na_pivot_get_items( const NAPivot *pivot );
diff --git a/nautilus-actions/utils/nautilus-actions-new.c b/nautilus-actions/utils/nautilus-actions-new.c
index f2b2e9e..8262c9a 100644
--- a/nautilus-actions/utils/nautilus-actions-new.c
+++ b/nautilus-actions/utils/nautilus-actions-new.c
@@ -43,6 +43,7 @@
 
 #include <runtime/na-io-provider.h>
 #include <runtime/na-iprefs.h>
+#include <runtime/na-pivot.h>
 #include <runtime/na-utils.h>
 #include <runtime/na-xml-names.h>
 #include <runtime/na-xml-writer.h>
@@ -369,17 +370,21 @@ get_action_from_cmdline( void )
 static gboolean
 write_to_gconf( NAObjectAction *action, GSList **msg )
 {
-	/*NAGConfProvider *gconf;
+	NAPivot *pivot;
+	GObject *provider;
 	guint ret;
 
-	gconf = na_gconf_provider_new( NULL );
+	pivot = na_pivot_new( NULL );
+	provider = na_pivot_get_provider( pivot, NA_IIO_PROVIDER_TYPE );
 
-	na_object_set_provider( action, NA_IIO_PROVIDER( gconf ));
+	na_object_set_provider( action, NA_IIO_PROVIDER( provider ));
 
-	ret = na_io_provider_write_item( NULL, NA_OBJECT_ITEM( action ), msg );
+	ret = na_io_provider_write_item( pivot, NA_OBJECT_ITEM( action ), msg );
 
-	return( ret == NA_IIO_PROVIDER_WRITE_OK );*/
-	return( TRUE );
+	na_pivot_release_provider( provider );
+	g_object_unref( pivot );
+
+	return( ret == NA_IIO_PROVIDER_WRITE_OK );
 }
 
 /*



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]