[nautilus-actions] Refactoring: update src/utils/



commit 596eac5eb281e734d994f67c3d058f0834e15081
Author: Pierre Wieser <pwieser trychlos org>
Date:   Mon Feb 15 20:12:24 2010 +0100

    Refactoring: update src/utils/

 ChangeLog                            |    4 +
 src/utils/Makefile.am                |   15 +----
 src/utils/nautilus-actions-new.c     |  101 +++++++++++++++++----------------
 src/utils/nautilus-actions-run.c     |   19 +++---
 src/utils/nautilus-actions-schemas.c |   19 ++++---
 5 files changed, 81 insertions(+), 77 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index cfb944e..6dffb65 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-02-15 Pierre Wieser <pwieser trychlos org>
+
+	Update src/utils.
+
 2009-02-15 Deji Akingunola <dakingun gmail com>
 
 	* src/test/Makefile.am: Fix typo.
diff --git a/src/utils/Makefile.am b/src/utils/Makefile.am
index 71a1249..6193b2d 100644
--- a/src/utils/Makefile.am
+++ b/src/utils/Makefile.am
@@ -34,7 +34,6 @@ bin_PROGRAMS = \
 
 AM_CPPFLAGS += \
 	-I $(top_srcdir)											\
-	-I $(top_srcdir)/nautilus-actions							\
 	-DGNOMELOCALEDIR=\""$(datadir)/locale"\"					\
 	-DG_LOG_DOMAIN=\"${NA_LOGDOMAIN_UTILS}\"					\
 	$(NAUTILUS_ACTIONS_CFLAGS)									\
@@ -47,9 +46,7 @@ nautilus_actions_new_SOURCES = \
 	$(NULL)
 
 nautilus_actions_new_LDADD = \
-	-L$(top_builddir)/nautilus-actions/api		-lna-api		\
-	-L$(top_builddir)/nautilus-actions/private	-lna-private	\
-	-L$(top_builddir)/nautilus-actions/runtime	-lna-runtime	\
+	$(top_builddir)/src/core/libna-core.la						\
 	$(NAUTILUS_ACTIONS_LIBS)									\
 	$(NULL)
 
@@ -57,7 +54,7 @@ BUILT_SOURCES = \
 	nautilus-actions-run-bindings.h								\
 	$(NULL)
 
-nautilus-actions-run-bindings.h: $(top_srcdir)/nautilus-actions/tracker/na-tracker-dbus.xml
+nautilus-actions-run-bindings.h: $(top_srcdir)/src/plugin-tracker/na-tracker-dbus.xml
 	dbus-binding-tool --mode=glib-client $< > $@
 
 nautilus_actions_run_SOURCES = \
@@ -67,9 +64,7 @@ nautilus_actions_run_SOURCES = \
 	$(NULL)
 
 nautilus_actions_run_LDADD = \
-	-L$(top_builddir)/nautilus-actions/api		-lna-api		\
-	-L$(top_builddir)/nautilus-actions/private	-lna-private	\
-	-L$(top_builddir)/nautilus-actions/runtime	-lna-runtime	\
+	$(top_builddir)/src/core/libna-core.la						\
 	$(NAUTILUS_ACTIONS_LIBS)									\
 	$(NULL)
 
@@ -80,9 +75,7 @@ nautilus_actions_schemas_SOURCES = \
 	$(NULL)
 
 nautilus_actions_schemas_LDADD = \
-	-L$(top_builddir)/nautilus-actions/api		-lna-api		\
-	-L$(top_builddir)/nautilus-actions/private	-lna-private	\
-	-L$(top_builddir)/nautilus-actions/runtime	-lna-runtime	\
+	$(top_builddir)/src/core/libna-core.la						\
 	$(NAUTILUS_ACTIONS_LIBS)									\
 	$(NULL)
 
diff --git a/src/utils/nautilus-actions-new.c b/src/utils/nautilus-actions-new.c
index d0e30f0..fb04f02 100644
--- a/src/utils/nautilus-actions-new.c
+++ b/src/utils/nautilus-actions-new.c
@@ -36,17 +36,18 @@
 #include <glib/gi18n.h>
 #include <stdlib.h>
 
+#include <api/na-core-utils.h>
 #include <api/na-iio-provider.h>
 #include <api/na-object-api.h>
 
-#include <io-provider-gconf/nagp-keys.h>
+#include <io-gconf/nagp-keys.h>
 
-#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>
+#include <core/na-io-provider.h>
+#include <core/na-updater.h>
+#if 0
+#include <core/na-xml-names.h>
+#include <core/na-xml-writer.h>
+#endif
 
 #include "console-utils.h"
 
@@ -169,7 +170,7 @@ main( int argc, char** argv )
 	}
 
 	if( version ){
-		na_utils_print_version();
+		na_core_utils_print_version();
 		exit( status );
 	}
 
@@ -204,6 +205,7 @@ main( int argc, char** argv )
 			g_print( _( "Action '%s' succesfully written to GConf configuration.\n" ), label );
 		}
 
+#if 0
 	} else {
 		gchar *output_fname = na_xml_writer_export( action, output_dir, IPREFS_EXPORT_FORMAT_GCONF_ENTRY, &msg );
 		if( output_fname ){
@@ -211,13 +213,14 @@ main( int argc, char** argv )
 			g_print( _( "Action '%s' succesfully written to %s, and ready to be imported in NACT.\n" ), label, output_fname );
 			g_free( output_fname );
 		}
+#endif
 	}
 
 	if( msg ){
 		for( im = msg ; im ; im = im->next ){
 			g_printerr( "%s\n", ( gchar * ) im->data );
 		}
-		na_utils_free_string_list( msg );
+		na_core_utils_slist_free( msg );
 		status = EXIT_FAILURE;
 	}
 
@@ -281,84 +284,84 @@ init_options( void )
 static NAObjectAction *
 get_action_from_cmdline( void )
 {
-	NAObjectAction *action = na_object_action_new_with_profile();
-	GList *profiles;
+	NAObjectAction *action;
 	NAObjectProfile *profile;
-	int i = 0;
-	GSList *basenames = NULL;
-	GSList *mimetypes = NULL;
-	GSList *schemes = NULL;
-	GSList *folders = NULL;
+	int i;
+	GSList *basenames;
+	GSList *mimetypes;
+	GSList *schemes;
+	GSList *folders;
 
-	profiles = na_object_get_items_list( action );
-	profile = NA_OBJECT_PROFILE( profiles->data );
+	action = na_object_action_new_with_profile();
+	profile = NA_OBJECT_PROFILE(( GList * ) na_object_get_items( action )->data );
 
 	na_object_set_label( action, label );
 	na_object_set_tooltip( action, tooltip );
 	na_object_set_icon( action, icon );
-	na_object_set_enabled( NA_OBJECT_ITEM( action ), enabled );
-	na_object_action_set_target_selection( action, target_selection );
-	na_object_action_set_target_background( action, target_folders );
-	na_object_action_set_target_toolbar( action, target_toolbar );
+	na_object_set_enabled( action, enabled );
+	na_object_set_target_selection( action, target_selection );
+	na_object_set_target_background( action, target_folders );
+	na_object_set_target_toolbar( action, target_toolbar );
 
 	if( target_toolbar ){
 		if( label_toolbar && g_utf8_strlen( label_toolbar, -1 )){
-			na_object_action_toolbar_set_same_label( action, FALSE );
-			na_object_action_toolbar_set_label( action, label_toolbar );
+			na_object_set_toolbar_same_label( action, FALSE );
+			na_object_set_toolbar_label( action, label_toolbar );
 		} else {
-			na_object_action_toolbar_set_same_label( action, TRUE );
-			na_object_action_toolbar_set_label( action, label );
+			na_object_set_toolbar_same_label( action, TRUE );
+			na_object_set_toolbar_label( action, label );
 		}
 	} else {
-		na_object_action_toolbar_set_label( action, "" );
+		na_object_set_toolbar_label( action, "" );
 	}
 
-	na_object_profile_set_path( profile, command );
-	na_object_profile_set_parameters( profile, parameters );
+	na_object_set_path( profile, command );
+	na_object_set_parameters( profile, parameters );
 
+	i = 0;
+	basenames = NULL;
 	while( basenames_array != NULL && basenames_array[i] != NULL ){
 		basenames = g_slist_append( basenames, g_strdup( basenames_array[i] ));
 		i++;
 	}
-	na_object_profile_set_basenames( profile, basenames );
-	g_slist_foreach( basenames, ( GFunc ) g_free, NULL );
-	g_slist_free( basenames );
+	na_object_set_basenames( profile, basenames );
+	na_core_utils_slist_free( basenames );
 
-	na_object_profile_set_matchcase( profile, matchcase );
+	na_object_set_matchcase( profile, matchcase );
 
 	i = 0;
+	mimetypes = NULL;
 	while( mimetypes_array != NULL && mimetypes_array[i] != NULL ){
 		mimetypes = g_slist_append( mimetypes, g_strdup( mimetypes_array[i] ));
 		i++;
 	}
-	na_object_profile_set_mimetypes( profile, mimetypes );
-	g_slist_foreach( mimetypes, ( GFunc ) g_free, NULL );
-	g_slist_free( mimetypes );
+	na_object_set_mimetypes( profile, mimetypes );
+	na_core_utils_slist_free( mimetypes );
 
 	if( !isfile && !isdir ){
 		isfile = TRUE;
 	}
-	na_object_profile_set_isfile( profile, isfile );
-	na_object_profile_set_isdir( profile, isdir );
-	na_object_profile_set_multiple( profile, accept_multiple );
+	na_object_set_isfile( profile, isfile );
+	na_object_set_isdir( profile, isdir );
+	na_object_set_multiple( profile, accept_multiple );
 
 	i = 0;
+	schemes = NULL;
 	while( schemes_array != NULL && schemes_array[i] != NULL ){
 		schemes = g_slist_append( schemes, g_strdup( schemes_array[i] ));
 		i++;
 	}
-	na_object_profile_set_schemes( profile, schemes );
-	g_slist_foreach( schemes, ( GFunc ) g_free, NULL );
-	g_slist_free( schemes );
+	na_object_set_schemes( profile, schemes );
+	na_core_utils_slist_free( schemes );
 
 	i = 0;
+	folders = NULL;
 	while( folders_array != NULL && folders_array[i] != NULL ){
 		folders = g_slist_append( folders, g_strdup( folders_array[i] ));
 		i++;
 	}
-	na_object_profile_set_folders( profile, folders );
-	g_slist_foreach( folders, ( GFunc ) g_free, NULL );
-	g_slist_free( folders );
+	na_object_set_folders( profile, folders );
+	na_core_utils_slist_free( folders );
 
 	return( action );
 }
@@ -370,14 +373,14 @@ get_action_from_cmdline( void )
 static gboolean
 write_to_gconf( NAObjectAction *action, GSList **msg )
 {
-	NAPivot *pivot;
+	NAUpdater *updater;
 	guint ret;
 
-	pivot = na_pivot_new( PIVOT_LOAD_NONE );
+	updater = na_updater_new( PIVOT_LOAD_NONE );
 
-	ret = na_pivot_write_item( pivot, NA_OBJECT_ITEM( action ), msg );
+	ret = na_updater_write_item( updater, NA_OBJECT_ITEM( action ), msg );
 
-	g_object_unref( pivot );
+	g_object_unref( updater );
 
 	return( ret == NA_IIO_PROVIDER_CODE_OK );
 }
diff --git a/src/utils/nautilus-actions-run.c b/src/utils/nautilus-actions-run.c
index 4cfb252..fb3b3f4 100644
--- a/src/utils/nautilus-actions-run.c
+++ b/src/utils/nautilus-actions-run.c
@@ -37,14 +37,14 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <api/na-dbus.h>
+#include <api/na-core-utils.h>
 #include <api/na-object-api.h>
 
-#include <runtime/na-pivot.h>
-#include <runtime/na-utils.h>
+#include <core/na-dbus.h>
+#include <core/na-pivot.h>
 
-#include <tracker/na-tracker.h>
-#include <tracker/na-tracker-dbus.h>
+#include <plugin-tracker/na-tracker.h>
+#include <plugin-tracker/na-tracker-dbus.h>
 
 #include "console-utils.h"
 #include "nautilus-actions-run-bindings.h"
@@ -114,7 +114,7 @@ main( int argc, char** argv )
 	g_option_context_free( context );
 
 	if( version ){
-		na_utils_print_version();
+		na_core_utils_print_version();
 		exit( status );
 	}
 
@@ -213,7 +213,8 @@ get_action( const gchar *id )
 
 	action = NULL;
 
-	pivot = na_pivot_new( !PIVOT_LOAD_DISABLED & !PIVOT_LOAD_INVALID );
+	/*pivot = na_pivot_new( !PIVOT_LOAD_DISABLED & !PIVOT_LOAD_INVALID );*/
+	pivot = na_pivot_new( PIVOT_LOAD_ALL );
 
 	na_pivot_load_items( pivot );
 
@@ -354,7 +355,7 @@ get_profile_for_targets( NAObjectAction *action, GList *targets )
 	GList *profiles, *ip;
 
 	candidate = NULL;
-	profiles = na_object_get_items_list( action );
+	profiles = na_object_get_items( action );
 	for( ip = profiles ; ip && !candidate ; ip = ip->next ){
 
 		NAObjectProfile *profile = NA_OBJECT_PROFILE( ip->data );
@@ -373,7 +374,7 @@ execute_action( NAObjectAction *action, NAObjectProfile *profile, GList *targets
 	GString *cmd;
 	gchar *param, *path;
 
-	path = na_object_profile_get_path( profile );
+	path = na_object_get_path( profile );
 	cmd = g_string_new( path );
 
 	param = na_object_profile_parse_parameters_for_tracked( profile, targets );
diff --git a/src/utils/nautilus-actions-schemas.c b/src/utils/nautilus-actions-schemas.c
index cfabb86..1c7e573 100644
--- a/src/utils/nautilus-actions-schemas.c
+++ b/src/utils/nautilus-actions-schemas.c
@@ -38,10 +38,13 @@
 #include <glib/gi18n.h>
 #include <stdlib.h>
 
-#include <runtime/na-iprefs.h>
-#include <runtime/na-utils.h>
-#include <runtime/na-xml-names.h>
-#include <runtime/na-xml-writer.h>
+#include <api/na-core-utils.h>
+
+#include <core/na-iprefs.h>
+#if 0
+#include <core/na-xml-names.h>
+#include <core/na-xml-writer.h>
+#endif
 
 #include "console-utils.h"
 
@@ -100,7 +103,7 @@ main( int argc, char** argv )
 	}
 
 	if( version ){
-		na_utils_print_version();
+		na_core_utils_print_version();
 		exit( status );
 	}
 
@@ -114,9 +117,9 @@ main( int argc, char** argv )
 			g_print( _( "Nautilus Actions schema succesfully written to GConf.\n" ));
 		}
 
-	} else {*/
+	} else {
 		na_xml_writer_export( NULL, NULL, IPREFS_EXPORT_FORMAT_GCONF_SCHEMA, &msg );
-		/*if( !msg ){
+		if( !msg ){
 			g_print( _( "Nautilus Actions schema succesfully written to %s.\n" ), output_fname );
 			g_free( output_fname );
 		}*/
@@ -126,7 +129,7 @@ main( int argc, char** argv )
 		for( im = msg ; im ; im = im->next ){
 			g_printerr( "%s\n", ( gchar * ) im->data );
 		}
-		na_utils_free_string_list( msg );
+		na_core_utils_slist_free( msg );
 		status = EXIT_FAILURE;
 	}
 



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