[nautilus-actions: 8/30] Merge common/na-object* stuff into private/ directory



commit 8f847cb36e391d0613b5683d588ddcda189d063a
Author: Pierre Wieser <pwieser trychlos org>
Date:   Wed Nov 18 22:56:39 2009 +0100

    Merge common/na-object* stuff into private/ directory

 ChangeLog                                         |   57 +++++
 TODO                                              |    2 +
 nautilus-actions/Makefile.am                      |    2 +-
 nautilus-actions/common/Makefile.am               |   13 --
 nautilus-actions/common/na-object-action-fn.h     |   56 -----
 nautilus-actions/common/na-object-action.c        |  106 ----------
 nautilus-actions/common/na-object-api.h           |   81 -------
 nautilus-actions/common/na-object-fn.h            |   62 ------
 nautilus-actions/common/na-object-id-fn.h         |   59 ------
 nautilus-actions/common/na-object-id.c            |  205 ------------------
 nautilus-actions/common/na-object-item-fn.h       |   62 ------
 nautilus-actions/common/na-object-item.c          |  233 ---------------------
 nautilus-actions/common/na-object-menu-fn.h       |   51 -----
 nautilus-actions/common/na-object-menu.c          |   37 ----
 nautilus-actions/common/na-object-profile-fn.h    |   53 -----
 nautilus-actions/common/na-object-profile.c       |   92 --------
 nautilus-actions/common/na-object.c               |  168 ---------------
 nautilus-actions/common/na-xml-writer.c           |    3 +-
 nautilus-actions/nact/nact-assistant-export-ask.c |    3 +-
 nautilus-actions/nact/nact-assistant-export.c     |    2 +-
 nautilus-actions/nact/nact-assistant-import-ask.c |    3 +-
 nautilus-actions/nact/nact-assistant-import.c     |    7 +-
 nautilus-actions/nact/nact-clipboard.c            |    7 +-
 nautilus-actions/nact/nact-iaction-tab.c          |    2 +-
 nautilus-actions/nact/nact-iactions-list.c        |    2 +-
 nautilus-actions/nact/nact-iadvanced-tab.c        |    3 +-
 nautilus-actions/nact/nact-ibackground-tab.c      |    3 +-
 nautilus-actions/nact/nact-icommand-tab.c         |    3 +-
 nautilus-actions/nact/nact-iconditions-tab.c      |    3 +-
 nautilus-actions/nact/nact-main-menubar.c         |   42 ++++-
 nautilus-actions/nact/nact-main-menubar.h         |   11 +-
 nautilus-actions/nact/nact-main-window.c          |    7 +-
 nautilus-actions/nact/nact-tree-model.c           |    8 +-
 nautilus-actions/nact/nact-window.c               |    3 +-
 nautilus-actions/nact/nact-xml-reader.c           |    9 +-
 nautilus-actions/private/Makefile.am              |    1 +
 nautilus-actions/private/na-object-action-fn.h    |    4 +
 nautilus-actions/private/na-object-action.c       |   67 ++++++
 nautilus-actions/private/na-object-api.h          |   13 ++
 nautilus-actions/private/na-object-fn.h           |    4 +
 nautilus-actions/private/na-object-id-fn.h        |    8 +-
 nautilus-actions/private/na-object-id.c           |  150 +++++++++++++
 nautilus-actions/private/na-object-item-fn.h      |    9 +
 nautilus-actions/private/na-object-item.c         |  193 +++++++++++++++++
 nautilus-actions/private/na-object-profile-fn.h   |    3 +
 nautilus-actions/private/na-object-profile.c      |   52 +++++-
 nautilus-actions/private/na-object.c              |  120 +++++++++++
 nautilus-actions/utils/nautilus-actions-new.c     |    9 +-
 po/POTFILES.in                                    |    4 +-
 49 files changed, 776 insertions(+), 1321 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3e11669..2b1def0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,62 @@
 2009-11-18 Pierre Wieser <pwieser trychlos org>
 
+	Merge common/na-object-* stuff to private/ subdirectory.
+
+	* nautilus-actions/common/na-object-action-fn.h:
+	* nautilus-actions/common/na-object-action.c:
+	* nautilus-actions/common/na-object-api.h:
+	* nautilus-actions/common/na-object-fn.h:
+	* nautilus-actions/common/na-object-id-fn.h:
+	* nautilus-actions/common/na-object-id.c:
+	* nautilus-actions/common/na-object-item-fn.h:
+	* nautilus-actions/common/na-object-item.c:
+	* nautilus-actions/common/na-object-menu-fn.h:
+	* nautilus-actions/common/na-object-menu.c:
+	* nautilus-actions/common/na-object-profile-fn.h:
+	* nautilus-actions/common/na-object-profile.c:
+	* nautilus-actions/common/na-object.c:
+	Merged into private/ directory, thus deleted from common/ one.
+
+	* nautilus-actions/Makefile.am:
+	* nautilus-actions/common/Makefile.am:
+	* nautilus-actions/common/na-xml-writer.c:
+	* nautilus-actions/nact/nact-assistant-export-ask.c:
+	* nautilus-actions/nact/nact-assistant-export.c:
+	* nautilus-actions/nact/nact-assistant-import-ask.c:
+	* nautilus-actions/nact/nact-assistant-import.c:
+	* nautilus-actions/nact/nact-clipboard.c:
+	* nautilus-actions/nact/nact-iaction-tab.c:
+	* nautilus-actions/nact/nact-iactions-list.c:
+	* nautilus-actions/nact/nact-iadvanced-tab.c:
+	* nautilus-actions/nact/nact-ibackground-tab.c:
+	* nautilus-actions/nact/nact-icommand-tab.c:
+	* nautilus-actions/nact/nact-iconditions-tab.c:
+	* nautilus-actions/nact/nact-main-menubar.c:
+	* nautilus-actions/nact/nact-main-menubar.h:
+	* nautilus-actions/nact/nact-main-window.c:
+	* nautilus-actions/nact/nact-tree-model.c:
+	* nautilus-actions/nact/nact-window.c:
+	* nautilus-actions/nact/nact-xml-reader.c:
+	* nautilus-actions/private/Makefile.am:
+	* nautilus-actions/private/na-object-action-fn.h:
+	* nautilus-actions/private/na-object-action.c:
+	* nautilus-actions/private/na-object-api.h:
+	* nautilus-actions/private/na-object-fn.h:
+	* nautilus-actions/private/na-object-id-fn.h:
+	* nautilus-actions/private/na-object-id.c:
+	* nautilus-actions/private/na-object-item-fn.h:
+	* nautilus-actions/private/na-object-item.c:
+	* nautilus-actions/private/na-object-profile-fn.h:
+	* nautilus-actions/private/na-object-profile.c:
+	* nautilus-actions/private/na-object.c:
+	* nautilus-actions/utils/nautilus-actions-new.c:
+	* po/POTFILES.in: Updated accordingly.
+
+	* nautilus-actions/nact/nact-main-menubar.c:
+	* nautilus-actions/nact/nact-main-menubar.h
+	(nact_main_menubar_is_pasted_object_relabeled): New function
+	to avoid moving also NAPivot class to private directory.
+
 	Move runtime/na-object-* stuff to private/ subdirectory.
 
 	* nautilus-actions/runtime/na-gnome-vfs-uri.c:
diff --git a/TODO b/TODO
index ac81f42..4eacefb 100644
--- a/TODO
+++ b/TODO
@@ -78,3 +78,5 @@
   along with their methods
 
 - export: add a overwrite page: what to do if file already exists ?
+
+- na_object_id_get_topmost_parent: should it return a NAObjectItem ?
diff --git a/nautilus-actions/Makefile.am b/nautilus-actions/Makefile.am
index a68ec41..dc1ec32 100644
--- a/nautilus-actions/Makefile.am
+++ b/nautilus-actions/Makefile.am
@@ -28,8 +28,8 @@
 
 SUBDIRS = \
 	api							\
-	private						\
 	common						\
+	private						\
 	runtime						\
 	nact						\
 	plugin						\
diff --git a/nautilus-actions/common/Makefile.am b/nautilus-actions/common/Makefile.am
index 84ceac0..110fa9c 100644
--- a/nautilus-actions/common/Makefile.am
+++ b/nautilus-actions/common/Makefile.am
@@ -39,19 +39,6 @@ AM_CPPFLAGS += \
 libna_common_la_SOURCES = \
 	na-iprefs.c									\
 	na-iprefs.h									\
-	na-object.c									\
-	na-object-api.h								\
-	na-object-fn.h								\
-	na-object-id.c								\
-	na-object-id-fn.h							\
-	na-object-item.c							\
-	na-object-item-fn.h							\
-	na-object-action.c							\
-	na-object-action-fn.h						\
-	na-object-menu.c							\
-	na-object-menu-fn.h							\
-	na-object-profile.c							\
-	na-object-profile-fn.h						\
 	na-utils.c									\
 	na-utils.h									\
 	na-xml-names.h								\
diff --git a/nautilus-actions/common/na-xml-writer.c b/nautilus-actions/common/na-xml-writer.c
index f3f09d9..644a6e9 100644
--- a/nautilus-actions/common/na-xml-writer.c
+++ b/nautilus-actions/common/na-xml-writer.c
@@ -36,7 +36,8 @@
 #include <libxml/tree.h>
 
 #include <common/na-iprefs.h>
-#include <common/na-object-api.h>
+
+#include <private/na-object-api.h>
 
 #include <runtime/na-gconf-provider-keys.h>
 
diff --git a/nautilus-actions/nact/nact-assistant-export-ask.c b/nautilus-actions/nact/nact-assistant-export-ask.c
index 2a156ce..16d7c59 100644
--- a/nautilus-actions/nact/nact-assistant-export-ask.c
+++ b/nautilus-actions/nact/nact-assistant-export-ask.c
@@ -35,7 +35,8 @@
 #include <glib/gi18n.h>
 
 #include <common/na-iprefs.h>
-#include <common/na-object-api.h>
+
+#include <private/na-object-api.h>
 
 #include <runtime/na-pivot.h>
 
diff --git a/nautilus-actions/nact/nact-assistant-export.c b/nautilus-actions/nact/nact-assistant-export.c
index b70a5ef..9500c14 100644
--- a/nautilus-actions/nact/nact-assistant-export.c
+++ b/nautilus-actions/nact/nact-assistant-export.c
@@ -36,12 +36,12 @@
 #include <gtk/gtk.h>
 #include <string.h>
 
-#include <common/na-object-api.h>
 #include <common/na-iprefs.h>
 #include <common/na-utils.h>
 #include <common/na-xml-names.h>
 #include <common/na-xml-writer.h>
 
+#include <private/na-object-api.h>
 #include <private/na-iduplicable.h>
 
 #include <runtime/na-pivot.h>
diff --git a/nautilus-actions/nact/nact-assistant-import-ask.c b/nautilus-actions/nact/nact-assistant-import-ask.c
index 804960a..d4d4b54 100644
--- a/nautilus-actions/nact/nact-assistant-import-ask.c
+++ b/nautilus-actions/nact/nact-assistant-import-ask.c
@@ -35,7 +35,8 @@
 #include <glib/gi18n.h>
 
 #include <common/na-iprefs.h>
-#include <common/na-object-api.h>
+
+#include <private/na-object-api.h>
 
 #include <runtime/na-pivot.h>
 
diff --git a/nautilus-actions/nact/nact-assistant-import.c b/nautilus-actions/nact/nact-assistant-import.c
index 9ebd181..79b832a 100644
--- a/nautilus-actions/nact/nact-assistant-import.c
+++ b/nautilus-actions/nact/nact-assistant-import.c
@@ -37,12 +37,13 @@
 #include <gtk/gtk.h>
 #include <string.h>
 
-#include <runtime/na-pivot.h>
-
-#include <common/na-object-api.h>
 #include <common/na-iprefs.h>
 #include <common/na-utils.h>
 
+#include <private/na-object-api.h>
+
+#include <runtime/na-pivot.h>
+
 #include "nact-application.h"
 #include "nact-iactions-list.h"
 #include "nact-assistant-import.h"
diff --git a/nautilus-actions/nact/nact-clipboard.c b/nautilus-actions/nact/nact-clipboard.c
index cfaae31..38a03fb 100644
--- a/nautilus-actions/nact/nact-clipboard.c
+++ b/nautilus-actions/nact/nact-clipboard.c
@@ -35,14 +35,15 @@
 #include <gtk/gtk.h>
 #include <string.h>
 
-#include <runtime/na-pivot.h>
-
 #include <common/na-iprefs.h>
-#include <common/na-object-api.h>
 #include <common/na-xml-names.h>
 #include <common/na-xml-writer.h>
 #include <common/na-utils.h>
 
+#include <private/na-object-api.h>
+
+#include <runtime/na-pivot.h>
+
 #include "nact-application.h"
 #include "nact-assistant-export-ask.h"
 #include "nact-tree-model.h"
diff --git a/nautilus-actions/nact/nact-iaction-tab.c b/nautilus-actions/nact/nact-iaction-tab.c
index e8ddc55..e4c8571 100644
--- a/nautilus-actions/nact/nact-iaction-tab.c
+++ b/nautilus-actions/nact/nact-iaction-tab.c
@@ -35,7 +35,7 @@
 #include <glib/gi18n.h>
 #include <string.h>
 
-#include <common/na-object-api.h>
+#include <private/na-object-api.h>
 
 #include "base-window.h"
 #include "nact-application.h"
diff --git a/nautilus-actions/nact/nact-iactions-list.c b/nautilus-actions/nact/nact-iactions-list.c
index 67d04a7..3d142a6 100644
--- a/nautilus-actions/nact/nact-iactions-list.c
+++ b/nautilus-actions/nact/nact-iactions-list.c
@@ -35,9 +35,9 @@
 #include <gdk/gdkkeysyms.h>
 #include <string.h>
 
-#include <common/na-object-api.h>
 #include <common/na-iprefs.h>
 
+#include <private/na-object-api.h>
 #include <private/na-iduplicable.h>
 
 #include "nact-application.h"
diff --git a/nautilus-actions/nact/nact-iadvanced-tab.c b/nautilus-actions/nact/nact-iadvanced-tab.c
index 655c8c2..58b1760 100644
--- a/nautilus-actions/nact/nact-iadvanced-tab.c
+++ b/nautilus-actions/nact/nact-iadvanced-tab.c
@@ -36,9 +36,10 @@
 #include <glib/gi18n.h>
 #include <string.h>
 
-#include <common/na-object-api.h>
 #include <common/na-utils.h>
 
+#include <private/na-object-api.h>
+
 #include "base-window.h"
 #include "base-iprefs.h"
 #include "nact-main-tab.h"
diff --git a/nautilus-actions/nact/nact-ibackground-tab.c b/nautilus-actions/nact/nact-ibackground-tab.c
index 8e260f6..2e90cb6 100644
--- a/nautilus-actions/nact/nact-ibackground-tab.c
+++ b/nautilus-actions/nact/nact-ibackground-tab.c
@@ -37,9 +37,10 @@
 #include <string.h>
 
 #include <common/na-iprefs.h>
-#include <common/na-object-api.h>
 #include <common/na-utils.h>
 
+#include <private/na-object-api.h>
+
 #include <runtime/na-pivot.h>
 
 #include "base-iprefs.h"
diff --git a/nautilus-actions/nact/nact-icommand-tab.c b/nautilus-actions/nact/nact-icommand-tab.c
index a96be28..0a9a247 100644
--- a/nautilus-actions/nact/nact-icommand-tab.c
+++ b/nautilus-actions/nact/nact-icommand-tab.c
@@ -35,10 +35,11 @@
 #include <glib/gi18n.h>
 #include <string.h>
 
-#include <common/na-object-api.h>
 #include <common/na-iprefs.h>
 #include <common/na-utils.h>
 
+#include <private/na-object-api.h>
+
 #include "base-window.h"
 #include "base-iprefs.h"
 #include "nact-application.h"
diff --git a/nautilus-actions/nact/nact-iconditions-tab.c b/nautilus-actions/nact/nact-iconditions-tab.c
index 53fd204..36803ff 100644
--- a/nautilus-actions/nact/nact-iconditions-tab.c
+++ b/nautilus-actions/nact/nact-iconditions-tab.c
@@ -35,9 +35,10 @@
 #include <glib/gi18n.h>
 #include <string.h>
 
-#include <common/na-object-api.h>
 #include <common/na-utils.h>
 
+#include <private/na-object-api.h>
+
 #include "base-iprefs.h"
 #include "nact-main-window.h"
 #include "nact-main-tab.h"
diff --git a/nautilus-actions/nact/nact-main-menubar.c b/nautilus-actions/nact/nact-main-menubar.c
index 2bf9cf9..d914d3e 100644
--- a/nautilus-actions/nact/nact-main-menubar.c
+++ b/nautilus-actions/nact/nact-main-menubar.c
@@ -34,12 +34,13 @@
 
 #include <glib/gi18n.h>
 
+#include <common/na-iprefs.h>
+
+#include <private/na-object-api.h>
+
 #include <runtime/na-iabout.h>
 #include <runtime/na-ipivot-consumer.h>
 
-#include <common/na-object-api.h>
-#include <common/na-iprefs.h>
-
 #include "nact-application.h"
 #include "nact-assistant-export.h"
 #include "nact-assistant-import.h"
@@ -428,6 +429,33 @@ nact_main_menubar_dispose( NactMainWindow *window )
 }
 
 /**
+ * Whether the specified object should be relabeled when pasted ?
+ * @object: the considered #NAObject-derived object.
+ * @pivot: the #NAPivot instance.
+ *
+ * Returns: %TRUE if the object should be relabeled, %FALSE else.
+ */
+gboolean
+nact_main_menubar_is_pasted_object_relabeled( NAObject *object, NAPivot *pivot )
+{
+	static const gchar *thisfn = "nact_main_menubar_is_pasted_object_relabeled";
+	gboolean relabel;
+
+	if( NA_IS_OBJECT_MENU( object )){
+		relabel = na_iprefs_read_bool( NA_IPREFS( pivot ), IPREFS_RELABEL_MENUS, FALSE );
+	} else if( NA_IS_OBJECT_ACTION( object )){
+		relabel = na_iprefs_read_bool( NA_IPREFS( pivot ), IPREFS_RELABEL_ACTIONS, FALSE );
+	} else if( NA_IS_OBJECT_PROFILE( object )){
+		relabel = na_iprefs_read_bool( NA_IPREFS( pivot ), IPREFS_RELABEL_PROFILES, FALSE );
+	} else {
+		g_warning( "%s: unknown object type at %p", thisfn, ( void * ) object );
+		g_return_val_if_reached( FALSE );
+	}
+
+	return( relabel );
+}
+
+/**
  * nact_main_menubar_open_popup:
  * @window: this #NactMainWindow window.
  * @event: the mouse event.
@@ -985,6 +1013,7 @@ prepare_for_paste( NactMainWindow *window )
 	GList *items, *it;
 	NactClipboard *clipboard;
 	NAObjectAction *action;
+	gboolean relabel;
 	gboolean renumber;
 	NactApplication *application;
 	NAPivot *pivot;
@@ -1007,7 +1036,8 @@ prepare_for_paste( NactMainWindow *window )
 			}
 		}
 
-		na_object_prepare_for_paste( it->data, pivot, renumber, action );
+		relabel = nact_main_menubar_is_pasted_object_relabeled( NA_OBJECT( it->data ), pivot );
+		na_object_prepare_for_paste( it->data, relabel, renumber, action );
 	}
 
 	g_debug( "%s: action=%p (%s)",
@@ -1034,6 +1064,7 @@ on_duplicate_activated( GtkAction *gtk_action, NactMainWindow *window )
 	GList *items, *it;
 	GList *dup;
 	NAObject *obj;
+	gboolean relabel;
 
 	g_debug( "%s: gtk_action=%p, window=%p", thisfn, ( void * ) gtk_action, ( void * ) window );
 	g_return_if_fail( GTK_IS_ACTION( gtk_action ));
@@ -1054,7 +1085,8 @@ on_duplicate_activated( GtkAction *gtk_action, NactMainWindow *window )
 			action = NA_OBJECT_ACTION( na_object_get_parent( NA_OBJECT_PROFILE( obj )));
 		}
 
-		na_object_prepare_for_paste( obj, pivot, TRUE, action );
+		relabel = nact_main_menubar_is_pasted_object_relabeled( obj, pivot );
+		na_object_prepare_for_paste( obj, relabel, TRUE, action );
 		na_object_set_origin( obj, NULL );
 		na_object_check_status( obj );
 		dup = g_list_prepend( NULL, obj );
diff --git a/nautilus-actions/nact/nact-main-menubar.h b/nautilus-actions/nact/nact-main-menubar.h
index e26a698..0719aef 100644
--- a/nautilus-actions/nact/nact-main-menubar.h
+++ b/nautilus-actions/nact/nact-main-menubar.h
@@ -37,13 +37,18 @@
  * @include: nact/nact-main-menubar.h
  */
 
+#include <private/na-object-class.h>
+
+#include <runtime/na-pivot.h>
+
 #include "nact-main-window.h"
 
 G_BEGIN_DECLS
 
-void  nact_main_menubar_runtime_init( NactMainWindow *window );
-void  nact_main_menubar_dispose( NactMainWindow *window );
-void  nact_main_menubar_open_popup( NactMainWindow *window, GdkEventButton *event );
+void     nact_main_menubar_runtime_init( NactMainWindow *window );
+void     nact_main_menubar_dispose( NactMainWindow *window );
+gboolean nact_main_menubar_is_pasted_object_relabeled( NAObject *object, NAPivot *pivot );
+void     nact_main_menubar_open_popup( NactMainWindow *window, GdkEventButton *event );
 
 G_END_DECLS
 
diff --git a/nautilus-actions/nact/nact-main-window.c b/nautilus-actions/nact/nact-main-window.c
index 360cd86..7f8a56f 100644
--- a/nautilus-actions/nact/nact-main-window.c
+++ b/nautilus-actions/nact/nact-main-window.c
@@ -37,13 +37,14 @@
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
+#include <common/na-iprefs.h>
+
+#include <private/na-object-api.h>
+
 #include <runtime/na-pivot.h>
 #include <runtime/na-iabout.h>
 #include <runtime/na-ipivot-consumer.h>
 
-#include <common/na-object-api.h>
-#include <common/na-iprefs.h>
-
 #include "base-iprefs.h"
 #include "nact-application.h"
 #include "nact-iactions-list.h"
diff --git a/nautilus-actions/nact/nact-tree-model.c b/nautilus-actions/nact/nact-tree-model.c
index 1472955..9d53d9b 100644
--- a/nautilus-actions/nact/nact-tree-model.c
+++ b/nautilus-actions/nact/nact-tree-model.c
@@ -34,14 +34,16 @@
 
 #include <string.h>
 
-#include <common/na-object-api.h>
 #include <common/na-iprefs.h>
 #include <common/na-utils.h>
 #include <common/na-xml-writer.h>
 
+#include <private/na-object-api.h>
+
 #include "egg-tree-multi-dnd.h"
 #include "nact-application.h"
 #include "nact-iactions-list.h"
+#include "nact-main-menubar.h"
 #include "nact-main-statusbar.h"
 #include "nact-main-window.h"
 #include "nact-clipboard.h"
@@ -1449,6 +1451,7 @@ drop_inside( NactTreeModel *model, GtkTreePath *dest, GtkSelectionData  *selecti
 	GList *object_list, *it;
 	GtkTreeIter iter;
 	GList *deletable;
+	gboolean relabel;
 
 	application = NACT_APPLICATION( base_window_get_application( model->private->window ));
 	pivot = nact_application_get_pivot( application );
@@ -1491,7 +1494,8 @@ drop_inside( NactTreeModel *model, GtkTreePath *dest, GtkSelectionData  *selecti
 						g_list_free( deletable );
 					}
 
-					na_object_prepare_for_paste( inserted, pivot, copy_data, parent );
+					relabel = nact_main_menubar_is_pasted_object_relabeled( inserted, pivot );
+					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 ));
 				}
diff --git a/nautilus-actions/nact/nact-window.c b/nautilus-actions/nact/nact-window.c
index e1a2f7d..4dbc6ef 100644
--- a/nautilus-actions/nact/nact-window.c
+++ b/nautilus-actions/nact/nact-window.c
@@ -37,10 +37,11 @@
 
 #include <api/na-iio-provider.h>
 
-#include <common/na-object-api.h>
 #include <common/na-iprefs.h>
 #include <common/na-utils.h>
 
+#include <private/na-object-api.h>
+
 #include "nact-application.h"
 #include "nact-window.h"
 
diff --git a/nautilus-actions/nact/nact-xml-reader.c b/nautilus-actions/nact/nact-xml-reader.c
index 91f1bc6..f57ae4c 100644
--- a/nautilus-actions/nact/nact-xml-reader.c
+++ b/nautilus-actions/nact/nact-xml-reader.c
@@ -38,14 +38,15 @@
 #include <string.h>
 #include <uuid/uuid.h>
 
-#include <runtime/na-gconf-provider-keys.h>
-#include <runtime/na-gconf-utils.h>
-
 #include <common/na-iprefs.h>
-#include <common/na-object-api.h>
 #include <common/na-utils.h>
 #include <common/na-xml-names.h>
 
+#include <private/na-object-api.h>
+
+#include <runtime/na-gconf-provider-keys.h>
+#include <runtime/na-gconf-utils.h>
+
 #include "nact-application.h"
 #include "nact-main-window.h"
 #include "nact-assistant-import-ask.h"
diff --git a/nautilus-actions/private/Makefile.am b/nautilus-actions/private/Makefile.am
index a9c5bb8..1fa9a08 100644
--- a/nautilus-actions/private/Makefile.am
+++ b/nautilus-actions/private/Makefile.am
@@ -75,6 +75,7 @@ libna_private_la_SOURCES = \
 	$(NULL)
 
 libna_private_la_LIBADD = \
+	$(top_builddir)/nautilus-actions/common/libna-common.la		\
 	$(NULL)
 
 VERSION_INFO = 1:0:0
diff --git a/nautilus-actions/private/na-object-action-fn.h b/nautilus-actions/private/na-object-action-fn.h
index cc47bd5..e271c96 100644
--- a/nautilus-actions/private/na-object-action-fn.h
+++ b/nautilus-actions/private/na-object-action-fn.h
@@ -69,8 +69,10 @@ enum {
 };
 
 NAObjectAction *na_object_action_new( void );
+NAObjectAction *na_object_action_new_with_profile( void );
 
 gchar          *na_object_action_get_version( const NAObjectAction *action );
+gboolean        na_object_action_is_readonly( const NAObjectAction *action );
 gboolean        na_object_action_is_target_selection( const NAObjectAction *action );
 gboolean        na_object_action_is_target_background( const NAObjectAction *action );
 gboolean        na_object_action_is_target_toolbar( const NAObjectAction *action );
@@ -85,6 +87,8 @@ void            na_object_action_set_target_toolbar( NAObjectAction *action, gbo
 void            na_object_action_toolbar_set_same_label( NAObjectAction *action, gboolean same_label );
 void            na_object_action_toolbar_set_label( NAObjectAction *action, const gchar *label );
 
+void            na_object_action_reset_last_allocated( NAObjectAction *action );
+
 gchar          *na_object_action_get_new_profile_name( const NAObjectAction *action );
 void            na_object_action_attach_profile( NAObjectAction *action, NAObjectProfile *profile );
 gboolean        na_object_action_is_candidate( const NAObjectAction *action, gint target );
diff --git a/nautilus-actions/private/na-object-action.c b/nautilus-actions/private/na-object-action.c
index 9d9d0c2..24986b7 100644
--- a/nautilus-actions/private/na-object-action.c
+++ b/nautilus-actions/private/na-object-action.c
@@ -405,6 +405,30 @@ na_object_action_new( void )
 }
 
 /**
+ * na_object_action_new_with_profile:
+ *
+ * Allocates a new #NAObjectAction object along with a default profile.
+ *
+ * Returns: the newly allocated #NAObjectAction action.
+ */
+NAObjectAction *
+na_object_action_new_with_profile( void )
+{
+	NAObjectAction *action;
+	NAObjectProfile *profile;
+
+	action = na_object_action_new();
+
+	profile = na_object_profile_new();
+
+	/* i18n: name of the default profile when creating an action */
+	na_object_set_label( profile, _( "Default profile" ));
+	na_object_action_attach_profile( action, profile );
+
+	return( action );
+}
+
+/**
  * na_object_action_get_version:
  * @action: the #NAObjectAction object to be requested.
  *
@@ -431,6 +455,30 @@ na_object_action_get_version( const NAObjectAction *action )
 }
 
 /**
+ * na_object_action_is_readonly:
+ * @action: the #NAObjectAction object to be requested.
+ *
+ * Is the specified action only readable ?
+ * Or, in other words, may this action be edited and then saved to the
+ * original I/O storage subsystem ?
+ *
+ * Returns: %TRUE if the action is read-only, %FALSE else.
+ */
+gboolean
+na_object_action_is_readonly( const NAObjectAction *action )
+{
+	gboolean readonly = FALSE;
+
+	g_return_val_if_fail( NA_IS_OBJECT_ACTION( action ), FALSE );
+
+	if( !action->private->dispose_has_run ){
+		g_object_get( G_OBJECT( action ), NAACTION_PROP_READONLY, &readonly, NULL );
+	}
+
+	return( readonly );
+}
+
+/**
  * na_object_action_is_target_selection:
  * @action: the #NAObjectAction to be requested.
  *
@@ -692,6 +740,25 @@ na_object_action_toolbar_set_label( NAObjectAction *action, const gchar *label )
 }
 
 /**
+ * na_object_action_reset_last_allocated:
+ * @action: the #NAObjectAction object.
+ *
+ * Resets the last_allocated counter for computing new profile names.
+ *
+ * This should be called after having successfully saved the action.
+ */
+void
+na_object_action_reset_last_allocated( NAObjectAction *action )
+{
+	g_return_if_fail( NA_IS_OBJECT_ACTION( action ));
+
+	if( !action->private->dispose_has_run ){
+
+		action->private->last_allocated = 0;
+	}
+}
+
+/**
  * na_object_action_get_new_profile_name:
  * @action: the #NAObjectAction object which will receive a new profile.
  *
diff --git a/nautilus-actions/private/na-object-api.h b/nautilus-actions/private/na-object-api.h
index f1c7513..cf80adb 100644
--- a/nautilus-actions/private/na-object-api.h
+++ b/nautilus-actions/private/na-object-api.h
@@ -58,18 +58,23 @@ G_BEGIN_DECLS
 #define na_object_dump_norec( object )				na_object_object_dump_norec( NA_OBJECT( object ))
 #define na_object_dump_tree( tree )					na_object_object_dump_tree( tree )
 #define na_object_ref( object )						na_object_object_ref( NA_OBJECT( object ))
+#define na_object_reset_origin( object, origin )	na_object_object_reset_origin( NA_OBJECT( object ), ( NAObject * ) origin )
+#define na_object_reset_status( object )			na_object_object_reset_status( NA_OBJECT( object ) )
 #define na_object_unref( object )					na_object_object_unref( NA_OBJECT( object ))
 
 /* NAIDuplicable
  */
 #define na_object_check_status( object )			na_object_iduplicable_check_status( NA_OBJECT( object ))
 #define na_object_duplicate( object )				na_object_iduplicable_duplicate( NA_OBJECT( object ))
+#define na_object_get_origin( object )				na_object_iduplicable_get_origin( NA_OBJECT( object ))
+#define na_object_set_origin( object, origin )		na_object_iduplicable_set_origin( NA_OBJECT( object ), NA_OBJECT( origin ))
 #define na_object_are_equal( a, b )					na_object_iduplicable_are_equal( NA_OBJECT( a ), NA_OBJECT( b ))
 #define na_object_is_modified( object )				na_object_iduplicable_is_modified( NA_OBJECT( object ))
 #define na_object_is_valid( object )				na_object_iduplicable_is_valid( NA_OBJECT( object ))
 
 /* NAObjectId
  */
+#define na_object_check_status_up( object )			na_object_id_check_status_up( NA_OBJECT_ID( object ))
 #define na_object_get_id( object )					na_object_id_get_id( NA_OBJECT_ID( object ))
 #define na_object_get_label( object )				na_object_id_get_label( NA_OBJECT_ID( object ))
 #define na_object_get_parent( object )				na_object_id_get_parent( NA_OBJECT_ID( object ))
@@ -79,6 +84,10 @@ G_BEGIN_DECLS
 #define na_object_set_label( object, label )		na_object_id_set_label( NA_OBJECT_ID( object ), label )
 #define na_object_set_parent( object, parent )		na_object_id_set_parent( NA_OBJECT_ID( object ), ( NAObjectItem * ) parent )
 
+#define na_object_prepare_for_paste( object, pivot, renumber, action ) \
+													na_object_id_prepare_for_paste( NA_OBJECT_ID( object ), pivot, renumber, ( NAObjectAction * ) action )
+#define na_object_set_copy_of_label( object )		na_object_id_set_copy_of_label( NA_OBJECT_ID( object ))
+
 /* NAObjectItem
  */
 #define na_object_free_items_list( list )			na_object_item_free_items_list( list )
@@ -98,6 +107,10 @@ G_BEGIN_DECLS
 #define na_object_set_items_list( object, list )	na_object_item_set_items_list( NA_OBJECT_ITEM( object ), list )
 
 #define na_object_append_item( object, item )		na_object_item_append_item( NA_OBJECT_ITEM( object ), NA_OBJECT( item ))
+#define na_object_get_position( object, child )		na_object_item_get_position( NA_OBJECT_ITEM( object ), NA_OBJECT( child ))
+#define na_object_insert_at( object, child, pos )	na_object_item_insert_at( NA_OBJECT_ITEM( object ), NA_OBJECT( child ), pos )
+#define na_object_insert_item( object, item, before ) \
+													na_object_item_insert_item( NA_OBJECT_ITEM( object ), NA_OBJECT( item ), ( NAObject * ) before )
 #define na_object_remove_item( object, item )		na_object_item_remove_item( NA_OBJECT_ITEM( object ), NA_OBJECT( item ))
 
 G_END_DECLS
diff --git a/nautilus-actions/private/na-object-fn.h b/nautilus-actions/private/na-object-fn.h
index abd8540..3dec129 100644
--- a/nautilus-actions/private/na-object-fn.h
+++ b/nautilus-actions/private/na-object-fn.h
@@ -50,6 +50,8 @@ G_BEGIN_DECLS
  */
 void      na_object_iduplicable_check_status( const NAObject *object );
 NAObject *na_object_iduplicable_duplicate( const NAObject *object );
+NAObject *na_object_iduplicable_get_origin( const NAObject *object );
+void      na_object_iduplicable_set_origin( NAObject *object, const NAObject *origin );
 gboolean  na_object_iduplicable_are_equal( const NAObject *a, const NAObject *b );
 gboolean  na_object_iduplicable_is_modified( const NAObject *object );
 gboolean  na_object_iduplicable_is_valid( const NAObject *object );
@@ -60,6 +62,8 @@ void      na_object_object_dump( const NAObject *object );
 void      na_object_object_dump_norec( const NAObject *object );
 void      na_object_object_dump_tree( GList *tree );
 NAObject *na_object_object_ref( NAObject *object );
+void      na_object_object_reset_origin( NAObject *object, const NAObject *origin );
+void      na_object_object_reset_status( NAObject *object );
 void      na_object_object_unref( NAObject *object );
 
 GList    *na_object_most_derived_get_childs( const NAObject *object );
diff --git a/nautilus-actions/private/na-object-id-fn.h b/nautilus-actions/private/na-object-id-fn.h
index 003c326..7078f09 100644
--- a/nautilus-actions/private/na-object-id-fn.h
+++ b/nautilus-actions/private/na-object-id-fn.h
@@ -42,19 +42,25 @@
  * in na-object-api.h
  */
 
-#include "na-object-item-class.h"
+#include "na-object-action-class.h"
 
 G_BEGIN_DECLS
 
+gboolean      na_object_id_check_status_up( NAObjectId *object );
+
 gchar        *na_object_id_get_id( const NAObjectId *object );
 void          na_object_id_set_new_id( NAObjectId *object, const NAObjectId *new_parent );
 gchar        *na_object_id_get_label( const NAObjectId *object );
 NAObjectItem *na_object_id_get_parent( NAObjectId *object );
+NAObjectId   *na_object_id_get_topmost_parent( NAObjectId *object );
 
 void          na_object_id_set_id( NAObjectId *object, const gchar *id );
 void          na_object_id_set_label( NAObjectId *object, const gchar *label );
 void          na_object_id_set_parent( NAObjectId *object, NAObjectItem *parent );
 
+void          na_object_id_prepare_for_paste( NAObjectId *object, gboolean relabel, gboolean renumber, NAObjectAction *action );
+void          na_object_id_set_copy_of_label( NAObjectId *object );
+
 G_END_DECLS
 
 #endif /* __NAUTILUS_ACTIONS_NA_PRIVATE_OBJECT_ID_FN_H__ */
diff --git a/nautilus-actions/private/na-object-id.c b/nautilus-actions/private/na-object-id.c
index 8319a54..cc44892 100644
--- a/nautilus-actions/private/na-object-id.c
+++ b/nautilus-actions/private/na-object-id.c
@@ -276,6 +276,53 @@ instance_finalize( GObject *object )
 }
 
 /**
+ * na_object_id_check_status_up:
+ * @object: the object at the start of the hierarchy.
+ *
+ * Checks for modification and validity status of the @object, its
+ * parent, the parent of its parent, etc. up to the top of the hierarchy.
+ *
+ * Returns: %TRUE if at least one of the status has changed, %FALSE else.
+ *
+ * Checking the modification of any of the status should be more
+ * efficient that systematically force the display of the item.
+ */
+gboolean
+na_object_id_check_status_up( NAObjectId *object )
+{
+	gboolean changed;
+	gboolean was_modified, is_modified;
+	gboolean was_valid, is_valid;
+
+	g_return_val_if_fail( NA_OBJECT_ID( object ), FALSE );
+
+	changed = FALSE;
+
+	if( !object->private->dispose_has_run ){
+
+		was_modified = na_object_is_modified( object );
+		was_valid = na_object_is_valid( object );
+
+		na_iduplicable_check_status( NA_IDUPLICABLE( object ));
+
+		is_modified = na_object_is_modified( object );
+		is_valid = na_object_is_valid( object );
+
+		if( object->private->parent ){
+			na_object_id_check_status_up( NA_OBJECT_ID( object->private->parent ));
+		}
+
+		changed =
+			( was_modified && !is_modified ) ||
+			( !was_modified && is_modified ) ||
+			( was_valid && !is_valid ) ||
+			( !was_valid && is_valid );
+	}
+
+	return( changed );
+}
+
+/**
  * na_object_id_get_id:
  * @object: the #NAObjectId object whose internal identifiant is
  * requested.
@@ -343,6 +390,31 @@ na_object_id_get_parent( NAObjectId *object )
 }
 
 /**
+ * na_object_id_get_topmost_parent:
+ * @object: the #NAObject whose parent is searched.
+ *
+ * Returns: the topmost parent, maybe @object itself.
+ */
+NAObjectId *
+na_object_id_get_topmost_parent( NAObjectId *object )
+{
+	NAObjectId *parent;
+
+	g_return_val_if_fail( NA_IS_OBJECT_ID( object ), NULL );
+
+	parent = object;
+
+	if( !object->private->dispose_has_run ){
+
+		while( parent->private->parent ){
+			parent = NA_OBJECT_ID( parent->private->parent );
+		}
+	}
+
+	return( parent );
+}
+
+/**
  * na_object_id_set_id:
  * @object: the #NAObjectId object whose internal identifiant is to be
  * set.
@@ -426,6 +498,84 @@ na_object_id_set_parent( NAObjectId *object, NAObjectItem *parent )
 	}
 }
 
+/**
+ * na_object_id_prepare_for_paste:
+ * @object: the #NAObjectId object to be pasted.
+ * @relabel: whether this object should be relabeled when pasted.
+ * @relabel: whether this item should be renumbered ?
+ * @action: if @object is a #NAObjectProfile, the attached #NAObjectAction.
+ *
+ * Prepares @object to be pasted.
+ *
+ * If a #NAObjectProfile, then @object is attached to the specified
+ * #NAObjectAction @action. The identifier is always renumbered to be
+ * suitable with the already existing profiles.
+ *
+ * If a #NAObjectAction or a #NAObjectMenu, a new UUID is allocated if
+ * and only if @relabel is %TRUE.
+ *
+ * Actual relabeling takes place if @relabel is %TRUE, depending of the
+ * user preferences.
+ */
+void
+na_object_id_prepare_for_paste( NAObjectId *object, gboolean relabel, gboolean renumber, NAObjectAction *action )
+{
+	static const gchar *thisfn = "na_object_id_prepare_for_paste";
+	GList *subitems, *it;
+
+	g_debug( "%s: object=%p, relabel=%s, renumber=%s, action=%p",
+			thisfn, ( void * ) object, relabel ? "True":"False", renumber ? "True":"False", ( void * ) action );
+	g_return_if_fail( NA_IS_OBJECT_ID( object ));
+	g_return_if_fail( !action || NA_IS_OBJECT_ACTION( action ));
+
+	if( !object->private->dispose_has_run ){
+
+		if( NA_IS_OBJECT_PROFILE( object )){
+			na_object_set_parent( object, action );
+			na_object_set_new_id( object, action );
+			if( renumber && relabel ){
+				na_object_set_copy_of_label( object );
+			}
+
+		} else {
+			if( renumber ){
+				na_object_set_new_id( object, NULL );
+				if( relabel ){
+					na_object_set_copy_of_label( object );
+				}
+			}
+			if( NA_IS_OBJECT_MENU( object )){
+				subitems = na_object_get_items_list( object );
+				for( it = subitems ; it ; it = it->next ){
+					na_object_prepare_for_paste( it->data, relabel, renumber, NULL );
+				}
+			}
+		}
+	}
+}
+
+/**
+ * na_object_id_set_copy_of_label:
+ * @object: the #NAObjectId object whose label is to be changed.
+ *
+ * Sets the 'Copy of' label.
+ */
+void
+na_object_id_set_copy_of_label( NAObjectId *object )
+{
+	gchar *new_label;
+
+	g_return_if_fail( NA_IS_OBJECT_ID( object ));
+
+	if( !object->private->dispose_has_run ){
+
+		/* i18n: copied items have a label as 'Copy of original label' */
+		new_label = g_strdup_printf( _( "Copy of %s" ), object->private->label );
+		g_free( object->private->label );
+		object->private->label = new_label;
+	}
+}
+
 static void
 object_dump( const NAObject *object )
 {
diff --git a/nautilus-actions/private/na-object-item-fn.h b/nautilus-actions/private/na-object-item-fn.h
index 51fe6e1..cbe53e4 100644
--- a/nautilus-actions/private/na-object-item-fn.h
+++ b/nautilus-actions/private/na-object-item-fn.h
@@ -42,6 +42,9 @@
  * in na-object-api.h
  */
 
+#include <gdk/gdk.h>
+#include <gtk/gtk.h>
+
 #include <nautilus-actions/api/na-iio-provider.h>
 
 #include "na-object-item-class.h"
@@ -52,12 +55,16 @@ void           na_object_item_free_items_list( GList *items );
 
 gchar         *na_object_item_get_tooltip( const NAObjectItem *item );
 gchar         *na_object_item_get_icon( const NAObjectItem *item );
+GdkPixbuf     *na_object_item_get_pixbuf( const NAObjectItem *object, GtkWidget *widget );
+gint           na_object_item_get_position( const NAObjectItem *object, const NAObject *child );
 NAIIOProvider *na_object_item_get_provider( const NAObjectItem *item );
 gboolean       na_object_item_is_enabled( const NAObjectItem *item );
 NAObject      *na_object_item_get_item( const NAObjectItem *item, const gchar *id );
 GList         *na_object_item_get_items_list( const NAObjectItem *item );
 guint          na_object_item_get_items_count( const NAObjectItem *item );
 
+void           na_object_item_count_items( GList *items, gint *menus, gint *actions, gint *profiles, gboolean recurse );
+
 void           na_object_item_set_tooltip( NAObjectItem *item, const gchar *tooltip );
 void           na_object_item_set_icon( NAObjectItem *item, const gchar *icon_name );
 void           na_object_item_set_provider( NAObjectItem *item, const NAIIOProvider *provider );
@@ -65,6 +72,8 @@ void           na_object_item_set_enabled( NAObjectItem *item, gboolean enabled
 void           na_object_item_set_items_list( NAObjectItem *item, GList *items );
 
 void           na_object_item_append_item( NAObjectItem *object, const NAObject *item );
+void           na_object_item_insert_at( NAObjectItem *object, const NAObject *item, gint pos );
+void           na_object_item_insert_item( NAObjectItem *object, const NAObject *item, const NAObject *before );
 void           na_object_item_remove_item( NAObjectItem *object, const NAObject *item );
 
 GSList        *na_object_item_get_items_string_list( const NAObjectItem *item );
diff --git a/nautilus-actions/private/na-object-item.c b/nautilus-actions/private/na-object-item.c
index 2e27a74..a1c0e63 100644
--- a/nautilus-actions/private/na-object-item.c
+++ b/nautilus-actions/private/na-object-item.c
@@ -386,6 +386,84 @@ na_object_item_get_icon( const NAObjectItem *item )
 }
 
 /**
+ * na_object_item_get_pixbuf:
+ * @item: this #NAObjectItem.
+ * @widget: the widget for which the icon must be rendered.
+ *
+ * Returns the #GdkPixbuf image corresponding to the icon.
+ * The image has a size of %GTK_ICON_SIZE_MENU.
+ */
+GdkPixbuf *na_object_item_get_pixbuf( const NAObjectItem *item, GtkWidget *widget )
+{
+	static const gchar *thisfn = "na_object_item_get_pixbuf";
+	gchar *iconname;
+	GtkStockItem stock_item;
+	GdkPixbuf* icon = NULL;
+	gint width, height;
+	GError* error = NULL;
+
+	g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), NULL );
+
+	if( !item->private->dispose_has_run ){
+
+		iconname = na_object_item_get_icon( item );
+
+		/* TODO: use the same algorythm than Nautilus to find and
+		 * display an icon
+		 */
+		if( iconname ){
+			if( gtk_stock_lookup( iconname, &stock_item )){
+				icon = gtk_widget_render_icon( widget, iconname, GTK_ICON_SIZE_MENU, NULL );
+
+			} else if( g_file_test( iconname, G_FILE_TEST_EXISTS )
+				   && g_file_test( iconname, G_FILE_TEST_IS_REGULAR )){
+
+				gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, &height);
+				icon = gdk_pixbuf_new_from_file_at_size( iconname, width, height, &error );
+				if( error ){
+					g_warning( "%s: iconname=%s, error=%s", thisfn, iconname, error->message );
+					g_error_free( error );
+					error = NULL;
+					icon = NULL;
+				}
+			}
+		}
+
+		g_free( iconname );
+	}
+
+	return( icon );
+}
+
+/**
+ * na_object_item_get_position:
+ * @object: this #NAObjectItem object.
+ * @child: a #NAObject child.
+ *
+ * Returns: the position of @child in the subitems list of @object,
+ * starting from zero, or -1 if not found.
+ */
+gint
+na_object_item_get_position( const NAObjectItem *object, const NAObject *child )
+{
+	gint pos = -1;
+
+	g_return_val_if_fail( NA_IS_OBJECT_ITEM( object ), pos );
+	g_return_val_if_fail( !child || NA_IS_OBJECT( child ), pos );
+
+	if( !child ){
+		return( pos );
+	}
+
+	if( !object->private->dispose_has_run ){
+
+		pos = g_list_index( object->private->items, ( gconstpointer ) child );
+	}
+
+	return( pos );
+}
+
+/**
  * na_object_item_get_provider:
  * @item: the #NAObjectItem object to be requested.
  *
@@ -516,6 +594,47 @@ na_object_item_get_items_count( const NAObjectItem *item )
 }
 
 /**
+ * na_object_item_count_items:
+ * @items: a list if #NAObject to be counted.
+ * @menus: will be set to the count of menus.
+ * @actions: will be set to the count of actions.
+ * @profiles: will be set to the count of profiles.
+ * @recurse: whether to recursively count all items, or only those in
+ *  level zero of the list.
+ *
+ * Count the numbers of items if the provided list.
+ *
+ * As this function is recursive, the counters should be initialized by
+ * the caller before calling it.
+ */
+void
+na_object_item_count_items( GList *items, gint *menus, gint *actions, gint *profiles, gboolean recurse )
+{
+	GList *it;
+
+	/*g_debug( "na_object_item_count_items: items=%p (count=%d), menus=%d, actions=%d, profiles=%d",
+			( void * ) items, items ? g_list_length( items ) : 0, *menus, *actions, *profiles );*/
+
+	for( it = items ; it ; it = it->next ){
+
+		if( recurse ){
+			if( NA_IS_OBJECT_ITEM( it->data )){
+				na_object_item_count_items(
+						NA_OBJECT_ITEM( it->data )->private->items, menus, actions, profiles, recurse );
+			}
+		}
+
+		if( NA_IS_OBJECT_MENU( it->data )){
+			*menus += 1;
+		} else if( NA_IS_OBJECT_ACTION( it->data )){
+			*actions += 1;
+		} else if( NA_IS_OBJECT_PROFILE( it->data )){
+			*profiles += 1;
+		}
+	}
+}
+
+/**
  * na_object_item_set_tooltip:
  * @item: the #NAObjectItem object to be updated.
  * @tooltip: the tooltip to be set.
@@ -641,6 +760,80 @@ na_object_item_append_item( NAObjectItem *item, const NAObject *object )
 }
 
 /**
+ * na_object_item_insert_at:
+ * @item: the #NAObjectItem in which add the subitem.
+ * @object: a #NAObject to be inserted in the list of subitems.
+ * @pos: the position at which the @object child should be inserted.
+ *
+ * Inserts a new @object in the list of subitems of @item.
+ *
+ * Doesn't modify the reference count on @object.
+ */
+void
+na_object_item_insert_at( NAObjectItem *item, const NAObject *object, gint pos )
+{
+	GList *it;
+	gint i;
+
+	g_return_if_fail( NA_IS_OBJECT_ITEM( item ));
+	g_return_if_fail( NA_IS_OBJECT( object ));
+
+	if( !item->private->dispose_has_run ){
+
+		if( pos == -1 || pos >= g_list_length( item->private->items )){
+			na_object_append_item( item, object );
+
+		} else {
+			i = 0;
+			for( it = item->private->items ; it && i <= pos ; it = it->next ){
+				if( i == pos ){
+					item->private->items = g_list_insert_before( item->private->items, it, ( gpointer ) object );
+				}
+				i += 1;
+			}
+		}
+	}
+}
+
+/**
+ * na_object_item_insert_item:
+ * @item: the #NAObjectItem to which add the subitem.
+ * @object: a #NAObject to be inserted in the list of subitems.
+ * @before: the #NAObject before which the @object should be inserted.
+ *
+ * Inserts a new @object in the list of subitems of @item.
+ *
+ * Doesn't modify the reference count on @object.
+ */
+void
+na_object_item_insert_item( NAObjectItem *item, const NAObject *object, const NAObject *before )
+{
+	GList *before_list;
+
+	g_return_if_fail( NA_IS_OBJECT_ITEM( item ));
+	g_return_if_fail( NA_IS_OBJECT( object ));
+	g_return_if_fail( !before || NA_IS_OBJECT( before ));
+
+	if( !item->private->dispose_has_run ){
+
+		if( !g_list_find( item->private->items, ( gpointer ) object )){
+
+			before_list = NULL;
+
+			if( before ){
+				before_list = g_list_find( item->private->items, ( gconstpointer ) before );
+			}
+
+			if( before_list ){
+				item->private->items = g_list_insert_before( item->private->items, before_list, ( gpointer ) object );
+			} else {
+				item->private->items = g_list_prepend( item->private->items, ( gpointer ) object );
+			}
+		}
+	}
+}
+
+/**
  * na_object_item_remove_item:
  * @item: the #NAObjectItem from which the subitem must be removed.
  * @object: a #NAObject to be removed from the list of subitems.
diff --git a/nautilus-actions/private/na-object-profile-fn.h b/nautilus-actions/private/na-object-profile-fn.h
index 3212454..ce32d51 100644
--- a/nautilus-actions/private/na-object-profile-fn.h
+++ b/nautilus-actions/private/na-object-profile-fn.h
@@ -75,9 +75,12 @@ void             na_object_profile_set_isfile( NAObjectProfile *profile, gboolea
 void             na_object_profile_set_isdir( NAObjectProfile *profile, gboolean isdir );
 void             na_object_profile_set_isfiledir( NAObjectProfile *profile, gboolean isfile, gboolean isdir );
 void             na_object_profile_set_multiple( NAObjectProfile *profile, gboolean multiple );
+void             na_object_profile_set_scheme( NAObjectProfile *profile, const gchar *scheme, gboolean selected );
 void             na_object_profile_set_schemes( NAObjectProfile *profile, GSList *schemes );
 void             na_object_profile_set_folders( NAObjectProfile *profile, GSList *folders );
 
+void             na_object_profile_replace_folder_uri( NAObjectProfile *profile, const gchar *old, const gchar *new );
+
 gboolean         na_object_profile_is_candidate( const NAObjectProfile *profile, gint target, GList *files );
 gchar           *na_object_profile_parse_parameters( const NAObjectProfile *profile, gint target, GList *files );
 
diff --git a/nautilus-actions/private/na-object-profile.c b/nautilus-actions/private/na-object-profile.c
index 088391a..6c000ab 100644
--- a/nautilus-actions/private/na-object-profile.c
+++ b/nautilus-actions/private/na-object-profile.c
@@ -36,7 +36,7 @@
 
 #include <libnautilus-extension/nautilus-file-info.h>
 
-#include <runtime/na-utils.h>
+#include <common/na-utils.h>
 
 #include "na-iduplicable.h"
 #include "na-object-api.h"
@@ -904,6 +904,36 @@ na_object_profile_set_multiple( NAObjectProfile *profile, gboolean multiple )
 }
 
 /**
+ * na_object_profile_set_scheme:
+ * @profile: the #NAObjectProfile to be updated.
+ * @scheme: name of the scheme.
+ * @selected: whether this scheme is candidate to this profile.
+ *
+ * Sets the status of a scheme relative to this profile.
+ */
+void
+na_object_profile_set_scheme( NAObjectProfile *profile, const gchar *scheme, gboolean selected )
+{
+	/*static const gchar *thisfn = "na_object_profile_set_scheme";*/
+	gboolean exist;
+
+	g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
+
+	if( !profile->private->dispose_has_run ){
+
+		exist = na_utils_find_in_list( profile->private->schemes, scheme );
+		/*g_debug( "%s: scheme=%s exist=%s", thisfn, scheme, exist ? "True":"False" );*/
+
+		if( selected && !exist ){
+			profile->private->schemes = g_slist_prepend( profile->private->schemes, g_strdup( scheme ));
+		}
+		if( !selected && exist ){
+			profile->private->schemes = na_utils_remove_ascii_from_string_list( profile->private->schemes, scheme );
+		}
+	}
+}
+
+/**
  * na_object_profile_set_schemes:
  * @profile: the #NAObjectProfile to be updated.
  * @schemes: list of schemes which apply.
@@ -950,6 +980,26 @@ na_object_profile_set_folders( NAObjectProfile *profile, GSList *folders )
 }
 
 /**
+ * na_object_profile_replace_folder_uri:
+ * @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_uri( NAObjectProfile *profile, const gchar *old, const gchar *new )
+{
+	g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
+
+	if( !profile->private->dispose_has_run ){
+
+		profile->private->folders = na_utils_remove_from_string_list( profile->private->folders, old );
+		profile->private->folders = g_slist_append( profile->private->folders, ( gpointer ) g_strdup( new ));
+	}
+}
+
+/**
  * na_object_profile_is_candidate:
  * @profile: the #NAObjectProfile to be checked.
  * @target: the current target.
diff --git a/nautilus-actions/private/na-object.c b/nautilus-actions/private/na-object.c
index 8d76431..0ea6c93 100644
--- a/nautilus-actions/private/na-object.c
+++ b/nautilus-actions/private/na-object.c
@@ -323,6 +323,59 @@ na_object_iduplicable_duplicate( const NAObject *object )
 }
 
 /**
+ * na_object_iduplicable_get_origin:
+ * @object: the #NAObject object whose status is requested.
+ *
+ * Returns the original object which was at the origin of @object.
+ *
+ * Returns: a #NAObject, or NULL.
+ */
+NAObject *
+na_object_iduplicable_get_origin( const NAObject *object )
+{
+	NAObject *origin = NULL;
+
+	g_return_val_if_fail( NA_IS_OBJECT( object ), NULL );
+
+	if( !object->private->dispose_has_run ){
+		/* do not use NA_OBJECT macro as we may return a (valid) NULL value */
+		origin = ( NAObject * ) na_iduplicable_get_origin( NA_IDUPLICABLE( object ));
+	}
+
+	return( origin );
+}
+
+/**
+ * na_object_iduplicable_set_origin:
+ * @object: the #NAObject object whose origin is to be set.
+ * @origin: a #NAObject which will be set as the new origin of @object.
+ *
+ * Sets the new origin of @object, and of all its childs.
+ *
+ * Be warned: but recursively reinitializing the origin to NULL, this
+ * function may cause difficult to solve issues.
+ */
+void
+na_object_iduplicable_set_origin( NAObject *object, const NAObject *origin )
+{
+	GList *childs, *ic;
+
+	g_return_if_fail( NA_IS_OBJECT( object ));
+	g_return_if_fail( NA_IS_OBJECT( origin ) || !origin );
+
+	if( !object->private->dispose_has_run &&
+		( !origin || !origin->private->dispose_has_run )){
+
+			na_iduplicable_set_origin( NA_IDUPLICABLE( object ), NA_IDUPLICABLE( origin ));
+
+			childs = v_get_childs( object );
+			for( ic = childs ; ic ; ic = ic->next ){
+				na_object_iduplicable_set_origin( NA_OBJECT( ic->data ), origin );
+			}
+	}
+}
+
+/**
  * na_object_iduplicable_are_equal:
  * @a: a first #NAObject object.
  * @b: a second #NAObject object to be compared to the first one.
@@ -491,6 +544,73 @@ na_object_object_ref( NAObject *object )
 }
 
 /**
+ * na_object_object_reset_origin:
+ * @object: a #NAObject-derived object.
+ * @origin: must be a duplication of @object.
+ *
+ * Recursively reset origin of @object and its childs to @origin and
+ * its childs), so that @origin appear as the actual origin of @object.
+ *
+ * The origin of @origin itself is set to NULL.
+ *
+ * This only works if @origin has just been duplicated from @object,
+ * and thus we do not have to check if childs lists are equal.
+ */
+void
+na_object_object_reset_origin( NAObject *object, const NAObject *origin )
+{
+	GList *origin_childs, *iorig;
+	GList *object_childs, *iobj;
+	NAObject *orig_object;
+
+	g_return_if_fail( NA_IS_OBJECT( origin ));
+	g_return_if_fail( NA_IS_OBJECT( object ));
+
+	if( !object->private->dispose_has_run && !origin->private->dispose_has_run ){
+
+		origin_childs = v_get_childs( origin );
+		object_childs = v_get_childs( object );
+		for( iorig = origin_childs, iobj = object_childs ; iorig && iobj ; iorig = iorig->next, iobj = iobj->next ){
+			orig_object = na_object_get_origin( iorig->data );
+			g_return_if_fail( orig_object == iobj->data );
+			na_object_reset_origin( iobj->data, iorig->data );
+		}
+
+		orig_object = na_object_get_origin( origin );
+		g_return_if_fail( orig_object == object );
+		na_iduplicable_set_origin( NA_IDUPLICABLE( object ), NA_IDUPLICABLE( origin ));
+		na_iduplicable_set_origin( NA_IDUPLICABLE( origin ), NULL );
+	}
+}
+
+/**
+ * na_object_object_reset_status:
+ * @object: a #NAObject-derived object.
+ *
+ * Recursively reset status of @object and its childs.
+ *
+ * This is typically used when we want display a clean list of current
+ * items (e.g. in Export assistant).
+ */
+void
+na_object_object_reset_status( NAObject *object )
+{
+	GList *object_childs, *iobj;
+
+	g_return_if_fail( NA_IS_OBJECT( object ));
+
+	if( !object->private->dispose_has_run ){
+
+		object_childs = v_get_childs( object );
+		for( iobj = object_childs ; iobj ; iobj = iobj->next ){
+			na_iduplicable_reset_status( NA_IDUPLICABLE( iobj->data ));
+		}
+
+		na_iduplicable_reset_status( NA_IDUPLICABLE( object ));
+	}
+}
+
+/**
  * na_object_object_unref:
  * @object: a #NAObject-derived object.
  *
diff --git a/nautilus-actions/utils/nautilus-actions-new.c b/nautilus-actions/utils/nautilus-actions-new.c
index cb2484d..2666fcb 100644
--- a/nautilus-actions/utils/nautilus-actions-new.c
+++ b/nautilus-actions/utils/nautilus-actions-new.c
@@ -38,15 +38,16 @@
 
 #include <api/na-iio-provider.h>
 
-#include <runtime/na-io-provider.h>
-#include <runtime/na-gconf-provider.h>
-
 #include <common/na-iprefs.h>
-#include <common/na-object-api.h>
 #include <common/na-xml-names.h>
 #include <common/na-xml-writer.h>
 #include <common/na-utils.h>
 
+#include <private/na-object-api.h>
+
+#include <runtime/na-io-provider.h>
+#include <runtime/na-gconf-provider.h>
+
 #include "console-utils.h"
 
 static gchar     *label            = "";
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 27aa224..66f5e82 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,6 +1,4 @@
 data/nautilus-actions.schemas.in
-nautilus-actions/common/na-object-action.c
-nautilus-actions/common/na-object-id.c
 nautilus-actions/common/na-xml-names.h
 nautilus-actions/nact/base-application.c
 nautilus-actions/nact/base-assistant.c
@@ -24,7 +22,9 @@ nautilus-actions/nact/nact-window.c
 nautilus-actions/nact/nact-xml-reader.c
 nautilus-actions/nact/nautilus-actions-config-tool.ui
 nautilus-actions/plugin/nautilus-actions.c
+nautilus-actions/private/na-object-action.c
 nautilus-actions/private/na-object-action-fn.h
+nautilus-actions/private/na-object-id.c
 nautilus-actions/private/na-object-menu-fn.h
 nautilus-actions/private/na-object-profile-fn.h
 nautilus-actions/runtime/na-iabout.c



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