[nautilus-actions] Refactoring: Update NactIBackgroundTab interface



commit cf72905f8d785887532d611226e655a3287165fa
Author: Pierre Wieser <pwieser trychlos org>
Date:   Wed Feb 17 13:59:48 2010 +0100

    Refactoring: Update NactIBackgroundTab interface

 ChangeLog                       |    8 ++++++++
 src/api/na-object-api.h         |    2 ++
 src/api/na-object-profile.h     |    2 ++
 src/core/na-object-profile.c    |   25 +++++++++++++++++++++++++
 src/nact/nact-iaction-tab.c     |    1 -
 src/nact/nact-iadvanced-tab.c   |    8 +++-----
 src/nact/nact-ibackground-tab.c |   36 ++++++++++++++++++------------------
 7 files changed, 58 insertions(+), 24 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3f78b07..f524cd8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,14 @@
 2009-02-17 Pierre Wieser <pwieser trychlos org>
 
 	* src/api/na-object-api.h:
+	* src/api/na-object-profile.h:
+	* src/core/na-object-profile.c:
+	* src/nact/nact-iaction-tab.c:
+	* src/nact/nact-iadvanced-tab.c:
+	* src/nact/nact-ibackground-tab.c: Update NactIBackgroundTab
+	interface.
+
+	* src/api/na-object-api.h:
 	* src/api/na-object-item.h:
 	* src/nact/nact-gtk-utils.c:
 	* src/nact/nact-gtk-utils.h:
diff --git a/src/api/na-object-api.h b/src/api/na-object-api.h
index abaaab4..d5ec136 100644
--- a/src/api/na-object-api.h
+++ b/src/api/na-object-api.h
@@ -153,6 +153,8 @@ G_BEGIN_DECLS
 #define na_object_set_schemes( obj, schemes )			na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_SCHEMES, ( const void * )( schemes ))
 #define na_object_set_folders( obj, folders )			na_idata_factory_set( NA_IDATA_FACTORY( obj ), NADF_DATA_FOLDERS, ( const void * )( folders ))
 
+#define na_object_replace_folder( obj, old, new )		na_object_profile_replace_folder( NA_OBJECT_PROFILE( obj ), ( const gchar * )( old ), ( const gchar * )( new ))
+
 G_END_DECLS
 
 #endif /* __NAUTILUS_ACTIONS_API_NA_OBJECT_API_H__ */
diff --git a/src/api/na-object-profile.h b/src/api/na-object-profile.h
index d491ae2..c7a9e75 100644
--- a/src/api/na-object-profile.h
+++ b/src/api/na-object-profile.h
@@ -71,6 +71,8 @@ GType            na_object_profile_get_type( void );
 
 NAObjectProfile *na_object_profile_new( void );
 
+void             na_object_profile_replace_folder( NAObjectProfile *profile, const gchar *old, const gchar *new );
+
 gboolean         na_object_profile_is_candidate                ( const NAObjectProfile *profile, gint target, GList *files );
 gboolean         na_object_profile_is_candidate_for_tracked    ( const NAObjectProfile *profile, GList *tracked );
 
diff --git a/src/core/na-object-profile.c b/src/core/na-object-profile.c
index f31c073..5fc8d88 100644
--- a/src/core/na-object-profile.c
+++ b/src/core/na-object-profile.c
@@ -332,6 +332,31 @@ na_object_profile_new( void )
 }
 
 /**
+ * na_object_profile_replace_folder:
+ * @profile: the #NAObjectProfile to be updated.
+ * @old: the old uri.
+ * @new: the new uri.
+ *
+ * Replaces the @old URI by the @new one.
+ */
+void
+na_object_profile_replace_folder( NAObjectProfile *profile, const gchar *old, const gchar *new )
+{
+	GSList *folders;
+
+	g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
+
+	if( !profile->private->dispose_has_run ){
+
+		folders = na_object_get_folders( profile );
+		folders = na_core_utils_slist_remove_string( folders, old );
+		folders = g_slist_append( folders, ( gpointer ) g_strdup( new ));
+		na_object_set_folders( profile, folders );
+		na_core_utils_slist_free( folders );
+	}
+}
+
+/**
  * na_object_profile_is_candidate:
  * @profile: the #NAObjectProfile to be checked.
  * @target: the current target.
diff --git a/src/nact/nact-iaction-tab.c b/src/nact/nact-iaction-tab.c
index 98f0398..7b62669 100644
--- a/src/nact/nact-iaction-tab.c
+++ b/src/nact/nact-iaction-tab.c
@@ -35,7 +35,6 @@
 #include <glib/gi18n.h>
 #include <string.h>
 
-#include <api/na-core-utils.h>
 #include <api/na-object-api.h>
 
 #include <core/na-io-provider.h>
diff --git a/src/nact/nact-iadvanced-tab.c b/src/nact/nact-iadvanced-tab.c
index 97c831e..c18ffa5 100644
--- a/src/nact/nact-iadvanced-tab.c
+++ b/src/nact/nact-iadvanced-tab.c
@@ -34,8 +34,6 @@
 
 #include <api/na-object-api.h>
 
-#include <runtime/na-utils.h>
-
 #include "base-window.h"
 #include "nact-main-tab.h"
 #include "nact-schemes-list.h"
@@ -258,7 +256,7 @@ nact_iadvanced_tab_dispose( NactIAdvancedTab *instance )
 
 /**
  * Returns selected schemes as a list of strings.
- * The caller should call na_utils_free_string_list after use.
+ * The caller should call na_core_utils_slist_free() after use.
  */
 GSList *
 nact_iadvanced_tab_get_schemes( NactIAdvancedTab *instance )
@@ -302,7 +300,7 @@ on_tab_updatable_selection_changed( NactIAdvancedTab *instance, gint count_selec
 		enable_tab = tab_set_sensitive( instance );
 
 		if( profile ){
-			schemes = na_object_profile_get_schemes( profile );
+			schemes = na_object_get_schemes( profile );
 		}
 
 		nact_schemes_list_setup_values(
@@ -341,7 +339,7 @@ tab_set_sensitive( NactIAdvancedTab *instance )
 			TAB_UPDATABLE_PROP_EDITED_PROFILE, &profile,
 			NULL );
 
-	enable_tab = ( profile != NULL && na_object_action_is_target_selection( NA_OBJECT_ACTION( item )));
+	enable_tab = ( profile != NULL && na_object_is_target_selection( NA_OBJECT_ACTION( item )));
 	nact_main_tab_enable_page( NACT_MAIN_WINDOW( instance ), TAB_ADVANCED, enable_tab );
 
 	return( enable_tab );
diff --git a/src/nact/nact-ibackground-tab.c b/src/nact/nact-ibackground-tab.c
index fd4bafe..1ee662a 100644
--- a/src/nact/nact-ibackground-tab.c
+++ b/src/nact/nact-ibackground-tab.c
@@ -36,15 +36,15 @@
 #include <glib/gi18n.h>
 #include <string.h>
 
+#include <api/na-core-utils.h>
 #include <api/na-object-api.h>
 
-#include <runtime/na-iprefs.h>
-#include <runtime/na-pivot.h>
-#include <runtime/na-utils.h>
+#include <core/na-iprefs.h>
 
 #include "base-iprefs.h"
 #include "base-window.h"
 #include "nact-gtk-utils.h"
+#include "nact-iprefs.h"
 #include "nact-application.h"
 #include "nact-main-tab.h"
 #include "nact-ibackground-tab.h"
@@ -369,7 +369,7 @@ tab_set_sensitive( NactIBackgroundTab *instance )
 			NULL );
 
 	enable_tab = ( profile != NULL &&
-			( na_object_action_is_target_background( action ) || na_object_action_is_target_toolbar( action )));
+			( na_object_is_target_background( action ) || na_object_is_target_toolbar( action )));
 
 	nact_main_tab_enable_page( NACT_MAIN_WINDOW( instance ), TAB_BACKGROUND, enable_tab );
 
@@ -528,10 +528,10 @@ add_uri_to_folders( NactIBackgroundTab *instance, const gchar *uri )
 			TAB_UPDATABLE_PROP_EDITED_PROFILE, &edited,
 			NULL );
 
-	folders = na_object_profile_get_folders( edited );
+	folders = na_object_get_folders( edited );
 	folders = g_slist_prepend( folders, ( gpointer ) g_strdup( uri ));
-	na_object_profile_set_folders( edited, folders );
-	na_utils_free_string_list( folders );
+	na_object_set_folders( edited, folders );
+	na_core_utils_slist_free( folders );
 
 	g_signal_emit_by_name( G_OBJECT( instance ), TAB_UPDATABLE_SIGNAL_ITEM_UPDATED, edited, FALSE );
 }
@@ -553,7 +553,7 @@ on_add_folder_clicked( GtkButton *button, NactIBackgroundTab *instance )
 	GtkWidget *dialog;
 	GtkWindow *toplevel;
 	NactApplication *application;
-	NAPivot *pivot;
+	NAUpdater *updater;
 	gchar *uri;
 	GtkTreeView *listview;
 
@@ -572,11 +572,11 @@ on_add_folder_clicked( GtkButton *button, NactIBackgroundTab *instance )
 			NULL );
 
 	application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( instance )));
-	pivot = nact_application_get_pivot( application );
+	updater = nact_application_get_updater( application );
 
 	base_iprefs_position_named_window( BASE_WINDOW( instance ), GTK_WINDOW( dialog ), IPREFS_BACKGROUND_DIALOG );
 
-	uri = na_iprefs_read_string( NA_IPREFS( pivot ), IPREFS_BACKGROUND_URI, "x-nautilus-desktop:///" );
+	uri = na_iprefs_read_string( NA_IPREFS( updater ), IPREFS_BACKGROUND_URI, "x-nautilus-desktop:///" );
 	if( uri && strlen( uri )){
 		gtk_file_chooser_set_uri( GTK_FILE_CHOOSER( dialog ), uri );
 	}
@@ -584,7 +584,7 @@ on_add_folder_clicked( GtkButton *button, NactIBackgroundTab *instance )
 
 	if( gtk_dialog_run( GTK_DIALOG( dialog )) == GTK_RESPONSE_ACCEPT ){
 		uri = gtk_file_chooser_get_uri( GTK_FILE_CHOOSER( dialog ));
-		na_iprefs_write_string( NA_IPREFS( pivot ), IPREFS_BACKGROUND_URI, uri );
+		nact_iprefs_write_string( BASE_WINDOW( instance ), IPREFS_BACKGROUND_URI, uri );
 		add_row( instance, listview, uri );
 		add_uri_to_folders( instance, uri );
 		g_free( uri );
@@ -636,11 +636,11 @@ remove_uri_from_folders( NactIBackgroundTab *instance, const gchar *uri )
 			TAB_UPDATABLE_PROP_EDITED_PROFILE, &edited,
 			NULL );
 
-	folders = na_object_profile_get_folders( edited );
-	folders = na_utils_remove_from_string_list( folders, uri );
-	na_object_profile_set_folders( edited, folders );
+	folders = na_object_get_folders( edited );
+	folders = na_core_utils_slist_remove_string( folders, uri );
+	na_object_set_folders( edited, folders );
 
-	na_utils_free_string_list( folders );
+	na_core_utils_slist_free( folders );
 
 	g_signal_emit_by_name( G_OBJECT( instance ), TAB_UPDATABLE_SIGNAL_ITEM_UPDATED, edited, FALSE );
 }
@@ -671,11 +671,11 @@ setup_folders( NactIBackgroundTab *instance )
 			NULL );
 
 	if( edited ){
-		folders = na_object_profile_get_folders( edited );
+		folders = na_object_get_folders( edited );
 		for( is = folders ; is ; is = is->next ){
 			add_row( instance, listview, ( const gchar * ) is->data );
 		}
-		na_utils_free_string_list( folders );
+		na_core_utils_slist_free( folders );
 	}
 }
 
@@ -710,7 +710,7 @@ treeview_cell_edited( NactIBackgroundTab *instance, const gchar *path_string, co
 			TAB_UPDATABLE_PROP_EDITED_PROFILE, &edited,
 			NULL );
 
-	na_object_profile_replace_folder_uri( edited, previous_text, text );
+	na_object_profile_replace_folder( edited, previous_text, text );
 
 	if( old_text ){
 		*old_text = g_strdup( previous_text );



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