[nautilus-actions] Move a NASettings getter to NAUpdater



commit 8556f88196dab98a5ff9f341d20cb8819ef1fcab
Author: Pierre Wieser <pwieser trychlos org>
Date:   Thu Feb 3 01:32:24 2011 +0100

    Move a NASettings getter to NAUpdater
    
    - Remove nact_main_menubar_edit_is_pasted_object_relabeled() function.
    + Define na_updater_should_pasted_be_relabeled() function.

 ChangeLog                         |    9 +++++++++
 src/core/na-updater.c             |   35 +++++++++++++++++++++++++++++++++++
 src/core/na-updater.h             |    2 ++
 src/nact/nact-main-menubar-edit.c |   36 ++----------------------------------
 src/nact/nact-main-menubar-edit.h |    2 --
 src/nact/nact-tree-model-dnd.c    |    3 +--
 6 files changed, 49 insertions(+), 38 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ec376b8..bfc4bfc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2011-02-02 Pierre Wieser <pwieser trychlos org>
 
+	* src/core/na-updater.c:
+	* src/core/na-updater.h (na_updater_should_pasted_be_relabeled): New function.
+
+	* src/nact/nact-main-menubar-edit.c:
+	* src/nact/nact-main-menubar-edit.h
+	(nact_main_menubar_edit_is_pasted_object_relabeled): Removed function.
+
+	* src/nact/nact-tree-model-dnd.c (drop_inside): Updated accordingly.
+
 	* src/nact/base-application.c (class_init):
 	* src/nact/base-assistant.c (class_init):
 	* src/nact/base-window.c (class_init):
diff --git a/src/core/na-updater.c b/src/core/na-updater.c
index 686e831..4606647 100644
--- a/src/core/na-updater.c
+++ b/src/core/na-updater.c
@@ -459,6 +459,41 @@ na_updater_remove_item( NAUpdater *updater, NAObject *item )
 	}
 }
 
+/**
+ * na_updater_should_pasted_be_relabeled:
+ * @updater: this #NAUpdater instance.
+ * @object: the considered #NAObject-derived object.
+ *
+ * Whether the specified object should be relabeled when pasted ?
+ *
+ * Returns: %TRUE if the object should be relabeled, %FALSE else.
+ */
+gboolean
+na_updater_should_pasted_be_relabeled( const NAUpdater *updater, const NAObject *item )
+{
+	static const gchar *thisfn = "na_updater_should_pasted_be_relabeled";
+	gboolean relabel;
+	NASettings *settings;
+
+	settings = na_pivot_get_settings( NA_PIVOT( updater ));
+
+	if( NA_IS_OBJECT_MENU( item )){
+		relabel = na_settings_get_boolean( settings, NA_IPREFS_RELABEL_DUPLICATE_MENU, NULL, NULL );
+
+	} else if( NA_IS_OBJECT_ACTION( item )){
+		relabel = na_settings_get_boolean( settings, NA_IPREFS_RELABEL_DUPLICATE_ACTION, NULL, NULL );
+
+	} else if( NA_IS_OBJECT_PROFILE( item )){
+		relabel = na_settings_get_boolean( settings, NA_IPREFS_RELABEL_DUPLICATE_PROFILE, NULL, NULL );
+
+	} else {
+		g_warning( "%s: unknown item type at %p", thisfn, ( void * ) item );
+		g_return_val_if_reached( FALSE );
+	}
+
+	return( relabel );
+}
+
 /*
  * na_updater_load_items:
  * @updater: this #NAUpdater instance.
diff --git a/src/core/na-updater.h b/src/core/na-updater.h
index 795b143..afadf56 100644
--- a/src/core/na-updater.h
+++ b/src/core/na-updater.h
@@ -84,6 +84,8 @@ void       na_updater_append_item( NAUpdater *updater, NAObjectItem *item );
 void       na_updater_insert_item( NAUpdater *updater, NAObjectItem *item, const gchar *parent_id, gint pos );
 void       na_updater_remove_item( NAUpdater *updater, NAObject *item );
 
+gboolean   na_updater_should_pasted_be_relabeled( const NAUpdater *updater, const NAObject *item );
+
 /* read from / write to the physical storage subsystem
  */
 GList     *na_updater_load_items ( NAUpdater *updater );
diff --git a/src/nact/nact-main-menubar-edit.c b/src/nact/nact-main-menubar-edit.c
index d8bbe9d..4c7fe6b 100644
--- a/src/nact/nact-main-menubar-edit.c
+++ b/src/nact/nact-main-menubar-edit.c
@@ -352,7 +352,7 @@ prepare_for_paste( NactMainWindow *window )
 			}
 		}
 
-		relabel = nact_main_menubar_edit_is_pasted_object_relabeled( NA_OBJECT( it->data ), NA_PIVOT( updater ));
+		relabel = na_updater_should_pasted_be_relabeled( updater, NA_OBJECT( it->data ));
 		na_object_prepare_for_paste( it->data, relabel, renumber, action );
 		na_object_check_status( it->data );
 	}
@@ -406,7 +406,7 @@ nact_main_menubar_edit_on_duplicate( GtkAction *gtk_action, NactMainWindow *wind
 			action = NA_OBJECT_ACTION( na_object_get_parent( it->data ));
 		}
 
-		relabel = nact_main_menubar_edit_is_pasted_object_relabeled( obj, NA_PIVOT( updater ));
+		relabel = na_updater_should_pasted_be_relabeled( updater, obj );
 		na_object_prepare_for_paste( obj, relabel, TRUE, action );
 		na_object_set_origin( obj, NULL );
 		na_object_check_status( obj );
@@ -596,35 +596,3 @@ nact_main_menubar_edit_on_prefererences( GtkAction *gtk_action, NactMainWindow *
 {
 	nact_preferences_editor_run( BASE_WINDOW( window ));
 }
-
-/**
- * nact_main_menubar_edit_is_pasted_object_relabeled:
- * @object: the considered #NAObject-derived object.
- * @pivot: the #NAPivot instance.
- *
- * Whether the specified object should be relabeled when pasted ?
- *
- * Returns: %TRUE if the object should be relabeled, %FALSE else.
- */
-gboolean
-nact_main_menubar_edit_is_pasted_object_relabeled( NAObject *object, NAPivot *pivot )
-{
-	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_settings_get_boolean( settings, NA_IPREFS_RELABEL_DUPLICATE_MENU, NULL, NULL );
-	} else if( NA_IS_OBJECT_ACTION( object )){
-		relabel = na_settings_get_boolean( settings, NA_IPREFS_RELABEL_DUPLICATE_ACTION, NULL, NULL );
-	} else if( NA_IS_OBJECT_PROFILE( object )){
-		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 );
-	}
-
-	return( relabel );
-}
diff --git a/src/nact/nact-main-menubar-edit.h b/src/nact/nact-main-menubar-edit.h
index 3738b95..f267f21 100644
--- a/src/nact/nact-main-menubar-edit.h
+++ b/src/nact/nact-main-menubar-edit.h
@@ -52,8 +52,6 @@ void     nact_main_menubar_edit_on_delete       ( GtkAction *action, NactMainWin
 void     nact_main_menubar_edit_on_reload       ( GtkAction *action, NactMainWindow *window );
 void     nact_main_menubar_edit_on_prefererences( GtkAction *action, NactMainWindow *window );
 
-gboolean nact_main_menubar_edit_is_pasted_object_relabeled( NAObject *object, NAPivot *pivot );
-
 G_END_DECLS
 
 #endif /* __NACT_NACT_MENUBAR_EDIT_H__ */
diff --git a/src/nact/nact-tree-model-dnd.c b/src/nact/nact-tree-model-dnd.c
index d202a36..540d7cc 100644
--- a/src/nact/nact-tree-model-dnd.c
+++ b/src/nact/nact-tree-model-dnd.c
@@ -46,7 +46,6 @@
 #include "nact-application.h"
 #include "nact-clipboard.h"
 #include "nact-iactions-list.h"
-#include "nact-main-menubar-edit.h"
 #include "nact-main-statusbar.h"
 #include "nact-main-window.h"
 #include "nact-tree-model.h"
@@ -628,7 +627,7 @@ drop_inside( NactTreeModel *model, GtkTreePath *dest, GtkSelectionData  *selecti
 					g_list_free( deletable );
 				}
 
-				relabel = nact_main_menubar_edit_is_pasted_object_relabeled( inserted, NA_PIVOT( updater ));
+				relabel = na_updater_should_pasted_be_relabeled( updater, inserted );
 				na_object_prepare_for_paste( inserted, relabel, copy_data, parent );
 				object_list = g_list_prepend( object_list, inserted );
 				g_debug( "%s: dropped=%s", thisfn, na_object_get_label( inserted ));



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