[nautilus-actions: 20/45] Introduce two new, lighter, export formats



commit 56b756208500b76d37b7434b5911191132336152
Author: Pierre Wieser <pwieser trychlos org>
Date:   Sun Jul 26 18:54:00 2009 +0200

    Introduce two new, lighter, export formats

 ChangeLog                            |    7 +
 src/common/na-gconf-keys.h           |    1 +
 src/common/na-gconf.c                |    2 +-
 src/nact/Makefile.am                 |    1 +
 src/nact/nact-assist-export.c        |  135 +++++++++++++++---
 src/nact/nact-gconf-keys.h           |   73 ++++++++--
 src/nact/nact-gconf-reader.c         |   52 ++++----
 src/nact/nact-gconf-writer.c         |  267 +++++++++++++++++++++++++++++-----
 src/nact/nact-gconf-writer.h         |    2 +-
 src/nact/nact-import-export-format.h |   57 +++++++
 src/nact/nact-main-window.c          |   10 +-
 src/nact/nautilus-actions-config.ui  |  207 +++++++++++++++++++++++++-
 12 files changed, 699 insertions(+), 115 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e5b3ac5..1e44834 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,7 @@
 	* src/nact/nact-main-window.c:
 	Fix selection when removing last action, or entering with
 	no action at all.
+	Sets the modification indicator to be application-wide.
 
 	* src/nact/base-application-class.h:
 	* src/nact/base-window-class.h: New files.
@@ -27,6 +28,12 @@
 	Reload the GtkBuilder XML file each time we run the assistant
 	(see http://bugzilla.gnome.org/show_bug.cgi?id=589746).
 
+	* src/nact/nact-import-export-format.h: New file.
+
+	* src/nact/nact-assist-export.c:
+	* src/nact/nact-gconf-writer.c:
+	Introduce two new export formats.
+
 2009-07-25 Pierre Wieser <pwieser trychlos org>
 
 	* src/common/na-action-class.h:
diff --git a/src/common/na-gconf-keys.h b/src/common/na-gconf-keys.h
index a1dbc4f..fdb26e9 100644
--- a/src/common/na-gconf-keys.h
+++ b/src/common/na-gconf-keys.h
@@ -34,6 +34,7 @@
 /* GConf general information
  */
 #define NA_GCONF_CONFIG_PATH			NAUTILUS_ACTIONS_CONFIG_GCONF_BASEDIR "/configurations"
+#define NA_GCONF_SCHEMA_PREFIX			"/schemas"
 
 /* GConf key names
  */
diff --git a/src/common/na-gconf.c b/src/common/na-gconf.c
index f8d8dd3..b9b428f 100644
--- a/src/common/na-gconf.c
+++ b/src/common/na-gconf.c
@@ -490,7 +490,7 @@ iio_provider_delete_action( const NAIIOProvider *provider, const NAAction *actio
 	gchar *uuid = na_action_get_uuid( action );
 
 	GError *error = NULL;
-	gchar *path = g_strdup_printf( "/schemas%s/%s", NA_GCONF_CONFIG_PATH, uuid );
+	gchar *path = g_strdup_printf( "%s%s/%s", NA_GCONF_SCHEMA_PREFIX, NA_GCONF_CONFIG_PATH, uuid );
 	gconf_client_recursive_unset( self->private->gconf, path, 0, &error );
 	if( error ){
 		g_debug( "%s: error=%s for path=%s", thisfn, error->message, path );
diff --git a/src/nact/Makefile.am b/src/nact/Makefile.am
index 3029abb..c342312 100644
--- a/src/nact/Makefile.am
+++ b/src/nact/Makefile.am
@@ -71,6 +71,7 @@ nautilus_actions_config_SOURCES = \
 	nact-iconditions-tab.h								\
 	nact-imenubar.c										\
 	nact-imenubar.h										\
+	nact-import-export-format.h							\
 	nact-iprefs.c										\
 	nact-iprefs.h										\
 	nact-main.c											\
diff --git a/src/nact/nact-assist-export.c b/src/nact/nact-assist-export.c
index 60e0e31..fdc8008 100644
--- a/src/nact/nact-assist-export.c
+++ b/src/nact/nact-assist-export.c
@@ -45,6 +45,7 @@
 #include "nact-gconf-writer.h"
 #include "nact-iactions-list.h"
 #include "nact-iprefs.h"
+#include "nact-import-export-format.h"
 
 /* Export Assistant
  *
@@ -53,14 +54,16 @@
  *   0   Intro    Introduction
  *   1   Content  Selection of the actions
  *   2   Content  Selection of the target folder
- *   3   Confirm  Summary of the operations to be done
- *   4   Summary  Export is done: summary of the done operations
+ *   3   Content  Selection of the export format
+ *   4   Confirm  Summary of the operations to be done
+ *   5   Summary  Export is done: summary of the done operations
  */
 
 enum {
 	ASSIST_PAGE_INTRO = 0,
 	ASSIST_PAGE_ACTIONS_SELECTION,
 	ASSIST_PAGE_FOLDER_SELECTION,
+	ASSIST_PAGE_FORMAT_SELECTION,
 	ASSIST_PAGE_CONFIRM,
 	ASSIST_PAGE_DONE
 };
@@ -79,24 +82,7 @@ struct NactAssistExportPrivate {
 	GSList         *fnames;
 	gint            errors;
 	gchar          *reason;
-};
-
-/* export formats
- *
- * EXPORT_FORMAT_GCONFSCHEMAFILE_V1: a schema with owner, short and long
- * descriptions ; each action has its own schema addressed by the uuid
- * (historical format)
- *
- * EXPORT_FORMAT_GCONFSCHEMAFILE_V2: the lightest schema still compatible
- * with gconftool-2 --install-schema-file (no owner, no short nor long
- * descriptions) - introduced in v 1.11
- *
- * EXPORT_FORMAT_GCONFENTRY: not a schema, but a dump of the GConf entry
- */
-enum {
-	EXPORT_FORMAT_GCONFSCHEMAFILE_V1 = 1,
-	EXPORT_FORMAT_GCONFSCHEMAFILE_V2,
-	EXPORT_FORMAT_GCONFENTRY
+	gint            format;
 };
 
 static GObjectClass *st_parent_class = NULL;
@@ -115,25 +101,38 @@ static gchar            *do_get_dialog_name( BaseWindow *dialog );
 static GSList           *get_actions( NactWindow *window );
 static void              on_initial_load_dialog( BaseWindow *dialog );
 static void              on_runtime_init_dialog( BaseWindow *dialog );
+static void              on_all_widgets_showed( BaseWindow *dialog );
 static void              on_apply( NactAssistant *window, GtkAssistant *assistant );
 static void              on_prepare( NactAssistant *window, GtkAssistant *assistant, GtkWidget *page );
 
 static void              assist_initial_load_intro( NactAssistExport *window, GtkAssistant *assistant );
 static void              assist_runtime_init_intro( NactAssistExport *window, GtkAssistant *assistant );
+
 static void              assist_initial_load_actions_list( NactAssistExport *window, GtkAssistant *assistant );
 static void              assist_runtime_init_actions_list( NactAssistExport *window, GtkAssistant *assistant );
 static void              on_actions_list_selection_changed( GtkTreeSelection *selection, gpointer user_data );
+
 static void              assist_initial_load_target_folder( NactAssistExport *window, GtkAssistant *assistant );
 static void              assist_runtime_init_target_folder( NactAssistExport *window, GtkAssistant *assistant );
 static GtkFileChooser   *get_folder_chooser( NactAssistExport *window );
 static void              on_folder_selection_changed( GtkFileChooser *chooser, gpointer user_data );
 static gboolean          is_writable_dir( const gchar *uri );
+
+static void              assist_initial_load_format( NactAssistExport *window, GtkAssistant *assistant );
+static void              assist_runtime_init_format( NactAssistExport *window, GtkAssistant *assistant );
+static void              on_format_toggled( GtkToggleButton *button, gpointer user_data );
+static GtkWidget        *get_gconfschemav1_button( NactWindow *window );
+static GtkWidget        *get_gconfschemav2_button( NactWindow *window );
+static GtkWidget        *get_gconfdump_button( NactWindow *window );
+
 static void              assist_initial_load_confirm( NactAssistExport *window, GtkAssistant *assistant );
 static void              assist_runtime_init_confirm( NactAssistExport *window, GtkAssistant *assistant );
 static void              assist_prepare_confirm( NactAssistExport *window, GtkAssistant *assistant, GtkWidget *page );
+
 static void              assist_initial_load_exportdone( NactAssistExport *window, GtkAssistant *assistant );
 static void              assist_runtime_init_exportdone( NactAssistExport *window, GtkAssistant *assistant );
 static void              assist_prepare_exportdone( NactAssistExport *window, GtkAssistant *assistant, GtkWidget *page );
+
 static void              do_export( NactAssistExport *window );
 
 #ifdef NACT_MAINTAINER_MODE
@@ -203,6 +202,7 @@ class_init( NactAssistExportClass *klass )
 	base_class->get_toplevel_name = do_get_dialog_name;
 	base_class->initial_load_toplevel = on_initial_load_dialog;
 	base_class->runtime_init_toplevel = on_runtime_init_dialog;
+	base_class->all_widgets_showed = on_all_widgets_showed;
 
 	NactWindowClass *nact_class = NACT_WINDOW_CLASS( klass );
 	nact_class->get_iprefs_window_id = do_get_iprefs_window_id;
@@ -337,6 +337,7 @@ on_initial_load_dialog( BaseWindow *dialog )
 	assist_initial_load_intro( window, assistant );
 	assist_initial_load_actions_list( window, assistant );
 	assist_initial_load_target_folder( window, assistant );
+	assist_initial_load_format( window, assistant );
 	assist_initial_load_confirm( window, assistant );
 	assist_initial_load_exportdone( window, assistant );
 }
@@ -360,10 +361,16 @@ on_runtime_init_dialog( BaseWindow *dialog )
 	assist_runtime_init_intro( window, assistant );
 	assist_runtime_init_actions_list( window, assistant );
 	assist_runtime_init_target_folder( window, assistant );
+	assist_runtime_init_format( window, assistant );
 	assist_runtime_init_confirm( window, assistant );
 	assist_runtime_init_exportdone( window, assistant );
 }
 
+static void
+on_all_widgets_showed( BaseWindow *dialog )
+{
+}
+
 /*
  * As of 1.11, nact_gconf_writer doesn't return any error message.
  * An error is simply indicated by returning a null filename.
@@ -563,6 +570,64 @@ is_writable_dir( const gchar *uri )
 }
 
 static void
+assist_initial_load_format( NactAssistExport *window, GtkAssistant *assistant )
+{
+}
+
+static void
+assist_runtime_init_format( NactAssistExport *window, GtkAssistant *assistant )
+{
+	GtkWidget *button = get_gconfschemav1_button( NACT_WINDOW( window ));
+	nact_window_signal_connect( NACT_WINDOW( window ), G_OBJECT( button ), "toggled", G_CALLBACK( on_format_toggled ));
+
+	button = get_gconfschemav2_button( NACT_WINDOW( window ));
+	nact_window_signal_connect( NACT_WINDOW( window ), G_OBJECT( button ), "toggled", G_CALLBACK( on_format_toggled ));
+
+	button = get_gconfdump_button( NACT_WINDOW( window ));
+	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), TRUE );
+	window->private->format = FORMAT_GCONFENTRY;
+	nact_window_signal_connect( NACT_WINDOW( window ), G_OBJECT( button ), "toggled", G_CALLBACK( on_format_toggled ));
+
+	GtkWidget *content = gtk_assistant_get_nth_page( assistant, ASSIST_PAGE_FORMAT_SELECTION );
+	gtk_assistant_set_page_complete( assistant, content, TRUE );
+}
+
+static void
+on_format_toggled( GtkToggleButton *button, gpointer user_data )
+{
+	g_assert( NACT_IS_WINDOW( user_data ));
+	NactWindow *window = NACT_WINDOW( user_data );
+
+	if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( get_gconfschemav1_button( window )))){
+		NACT_ASSIST_EXPORT( window )->private->format = FORMAT_GCONFSCHEMAFILE_V1;
+
+	} else if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( get_gconfschemav2_button( window )))){
+		NACT_ASSIST_EXPORT( window )->private->format = FORMAT_GCONFSCHEMAFILE_V2;
+
+	} else if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( get_gconfdump_button( window )))){
+		NACT_ASSIST_EXPORT( window )->private->format = FORMAT_GCONFENTRY;
+	}
+}
+
+static GtkWidget *
+get_gconfschemav1_button( NactWindow *window )
+{
+	return( base_window_get_widget( BASE_WINDOW( window ), "ExportSchemaV1Button" ));
+}
+
+static GtkWidget *
+get_gconfschemav2_button( NactWindow *window )
+{
+	return( base_window_get_widget( BASE_WINDOW( window ), "ExportSchemaV2Button" ));
+}
+
+static GtkWidget *
+get_gconfdump_button( NactWindow *window )
+{
+	return( base_window_get_widget( BASE_WINDOW( window ), "ExportGConfDumpButton" ));
+}
+
+static void
 assist_initial_load_confirm( NactAssistExport *window, GtkAssistant *assistant )
 {
 }
@@ -600,6 +665,34 @@ assist_prepare_confirm( NactAssistExport *window, GtkAssistant *assistant, GtkWi
 	g_free( text );
 	text = tmp;
 
+	gchar *label1 = NULL;
+	gchar *label2 = NULL;
+	switch( window->private->format ){
+		case FORMAT_GCONFSCHEMAFILE_V1:
+			label1 = g_strdup( gtk_button_get_label( GTK_BUTTON( get_gconfschemav1_button( NACT_WINDOW( window )))));
+			label2 = g_strdup( gtk_label_get_text( GTK_LABEL( base_window_get_widget( BASE_WINDOW( window ), "ExportSchemaV1Label"))));
+			break;
+
+		case FORMAT_GCONFSCHEMAFILE_V2:
+			label1 = g_strdup( gtk_button_get_label( GTK_BUTTON( get_gconfschemav2_button( NACT_WINDOW( window )))));
+			label2 = g_strdup( gtk_label_get_text( GTK_LABEL( base_window_get_widget( BASE_WINDOW( window ), "ExportSchemaV2Label"))));
+			break;
+
+		case FORMAT_GCONFENTRY:
+			label1 = g_strdup( gtk_button_get_label( GTK_BUTTON( get_gconfdump_button( NACT_WINDOW( window )))));
+			label2 = g_strdup( gtk_label_get_text( GTK_LABEL( base_window_get_widget( BASE_WINDOW( window ), "ExportGConfDumpLabel"))));
+			break;
+
+		default:
+			break;
+	}
+
+	tmp = g_strdup_printf( _( "%s\n\n<b>%s</b>\n\n%s" ), text, label1, label2 );
+	g_free( label2 );
+	g_free( label1 );
+	g_free( text );
+	text = tmp;
+
 	gtk_label_set_markup( GTK_LABEL( page ), text );
 	g_free( text );
 
@@ -681,7 +774,7 @@ do_export( NactAssistExport *window )
 
 	for( ia = actions ; ia ; ia = ia->next ){
 		NAAction *action = NA_ACTION( ia->data );
-		gchar *fname = nact_gconf_writer_export( action, window->private->uri, &msg );
+		gchar *fname = nact_gconf_writer_export( action, window->private->uri, window->private->format, &msg );
 
 		if( fname && strlen( fname )){
 			window->private->fnames = g_slist_prepend( window->private->fnames, fname );
diff --git a/src/nact/nact-gconf-keys.h b/src/nact/nact-gconf-keys.h
index af74b86..c39f89d 100644
--- a/src/nact/nact-gconf-keys.h
+++ b/src/nact/nact-gconf-keys.h
@@ -35,14 +35,18 @@
 
 G_BEGIN_DECLS
 
-/* XML element names (GConf style)
+/* XML element names (GConf schema)
+ * used in FORMAT_GCONFSCHEMAFILE_V1 and FORMAT_GCONFSCHEMAFILE_V2
  */
-#define NACT_GCONF_XML_ROOT						"gconfschemafile"
-#define NACT_GCONF_XML_SCHEMA_LIST				"schemalist"
-#define NACT_GCONF_XML_SCHEMA_ENTRY				"schema"
-#define NACT_GCONF_XML_SCHEMA_APPLYTO			"applyto"
-#define NACT_GCONF_XML_SCHEMA_LOCALE			"locale"
-#define NACT_GCONF_XML_SCHEMA_DFT				"default"
+#define NACT_GCONF_SCHEMA_ROOT				"gconfschemafile"
+#define NACT_GCONF_SCHEMA_LIST				"schemalist"
+#define NACT_GCONF_SCHEMA_ENTRY				"schema"
+#define NACT_GCONF_SCHEMA_KEY				"key"
+#define NACT_GCONF_SCHEMA_APPLYTO			"applyto"
+#define NACT_GCONF_SCHEMA_TYPE				"type"
+#define NACT_GCONF_SCHEMA_LIST_TYPE			"list_type"
+#define NACT_GCONF_SCHEMA_LOCALE			"locale"
+#define NACT_GCONF_SCHEMA_DEFAULT			"default"
 
 /* Previous used keys
  *
@@ -53,15 +57,56 @@ G_BEGIN_DECLS
  * Starting with 1.11, export only contains required keys (applyto,
  * default and locale) ; import of course accept all previous keys
  * without warning
+ *
+ * only used in FORMAT_GCONFSCHEMAFILE_V1
+ */
+#define NACT_GCONF_SCHEMA_OWNER				"owner"
+#define NACT_GCONF_SCHEMA_SHORT				"short"
+#define NACT_GCONF_SCHEMA_LONG				"long"
+
+/* XML element names (GConf dump)
+ * used in FORMAT_GCONFENTRY
  */
-#define NACT_GCONF_XML_SCHEMA_KEY				"key"
-#define NACT_GCONF_XML_SCHEMA_OWNER				"owner"
-#define NACT_GCONF_XML_SCHEMA_TYPE				"type"
-#define NACT_GCONF_XML_SCHEMA_LIST_TYPE			"list_type"
-#define NACT_GCONF_XML_SCHEMA_SHORT				"short"
-#define NACT_GCONF_XML_SCHEMA_LONG				"long"
+#define NACT_GCONF_DUMP_ROOT				"gconfentryfile"
+#define NACT_GCONF_DUMP_ENTRYLIST			"entrylist"
+#define NACT_GCONF_DUMP_ENTRYLIST_BASE		"base"
+#define NACT_GCONF_DUMP_ENTRY				"entry"
+#define NACT_GCONF_DUMP_KEY					"key"
+#define NACT_GCONF_DUMP_VALUE				"value"
+#define NACT_GCONF_DUMP_STRING				"string"
+#define NACT_GCONF_DUMP_LIST				"list"
+#define NACT_GCONF_DUMP_LIST_TYPE			"type"
 
-#define NACT_GCONF_SCHEMA_PREFIX				"/schemas"
+/* GConf schema descriptions
+ */
+#define ACTION_LABEL_DESC_SHORT		_("The label of the menu item")
+#define ACTION_LABEL_DESC_LONG		_("The label of the menu item that will appear in the Nautilus popup menu when the selection matches the appearance condition settings")
+#define ACTION_TOOLTIP_DESC_SHORT	_("The tooltip of the menu item")
+#define ACTION_TOOLTIP_DESC_LONG	_("The tooltip of the menu item that will appear in the Nautilus statusbar when the user points to the Nautilus popup menu item with his/her mouse")
+#define ACTION_ICON_DESC_SHORT		_("The icon of the menu item")
+#define ACTION_ICON_DESC_LONG		_("The icon of the menu item that will appear next to the label in the Nautilus popup menu when the selection matches the appearance conditions settings")
+#define ACTION_PROFILE_NAME_DESC_SHORT	_("A description name of the profile")
+#define ACTION_PROFILE_NAME_DESC_LONG	_("The field is here to give the user a human readable name for a profile in the Nact interface. If not set there will be a default auto generated string set by default")
+#define ACTION_PATH_DESC_SHORT		_("The path of the command")
+#define ACTION_PATH_DESC_LONG		_("The path of the command to start when the user select the menu item in the Nautilus popup menu")
+#define ACTION_PARAMETERS_DESC_SHORT _("The parameters of the command")
+#define ACTION_PARAMETERS_DESC_LONG	_("The parameters of the command to start when the user selects the menu item in the Nautilus popup menu.\n\nThe parameters can contain some special tokens which are replaced by Nautilus information before starting the command:\n\n%d: base folder of the selected file(s)\n%f: the name of the selected file or the first one if many are selected\n%m: space-separated list of the basenames of the selected file(s)/folder(s)\n%M: space-separated list of the selected file(s)/folder(s), with their full paths\n%u: GnomeVFS URI\n%s: scheme of the GnomeVFS URI\n%h: hostname of the GnomeVFS URI\n%U: username of the GnomeVFS URI\n%%: a percent sign")
+#define ACTION_BASENAMES_DESC_SHORT	_("The list of pattern to match the selected file(s)/folder(s)")
+#define ACTION_BASENAMES_DESC_LONG	_("A list of strings with joker '*' or '?' to match the name of the selected file(s)/folder(s). Each selected items must match at least one of the filename patterns for the action to appear")
+#define ACTION_MATCHCASE_DESC_SHORT _("'true' if the filename patterns have to be case sensitive, 'false' otherwise")
+#define ACTION_MATCHCASE_DESC_LONG	_("If you need to match a filename in a case-sensitive manner, set this key to 'true'. If you also want, for example '*.jpg' to match 'photo.JPG', set 'false'")
+#define ACTION_MIMETYPES_DESC_SHORT	_("The list of patterns to match the mimetypes of the selected file(s)")
+#define ACTION_MIMETYPES_DESC_LONG	_("A list of strings with joker '*' or '?' to match the mimetypes of the selected file(s). Each selected items must match at least one of the mimetype patterns for the action to appear")
+#define ACTION_ISFILE_DESC_SHORT	_("'true' if the selection can have files, 'false' otherwise")
+#define ACTION_ISFILE_DESC_LONG		_("This setting is tied in with the 'isdir' setting. The valid combinations are:\n\nisfile=TRUE and isdir=FALSE: the selection may hold only files\nisfile=FALSE and isdir=TRUE: the selection may hold only folders\nisfile=TRUE and isdir=TRUE: the selection may hold both files and folders\nisfile=FALSE and isdir=FALSE: this is an invalid combination (your configuration will never appear)")
+#define ACTION_ISDIR_DESC_SHORT		_("'true' if the selection can have folders, 'false' otherwise")
+#define ACTION_ISDIR_DESC_LONG		_("This setting is tied in with the 'isfile' setting. The valid combinations are:\n\nisfile=TRUE and isdir=FALSE: the selection may hold only files\nisfile=FALSE and isdir=TRUE: the selection may hold only folders\nisfile=TRUE and isdir=TRUE: the selection may hold both files and folders\nisfile=FALSE and isdir=FALSE: this is an invalid combination (your configuration will never appear)")
+#define ACTION_MULTIPLE_DESC_SHORT	_("'true' if the selection can have several items, 'false' otherwise")
+#define ACTION_MULTIPLE_DESC_LONG	_("If you need one or more files or folders to be selected, set this key to 'true'. If you want just one file or folder, set 'false'")
+#define ACTION_SCHEMES_DESC_SHORT	_("The list of GnomeVFS schemes where the selected files should be located")
+#define ACTION_SCHEMES_DESC_LONG	_("Defines the list of valid GnomeVFS schemes to be matched against the selected items. The GnomeVFS scheme is the protocol used to access the files. The keyword to use is the one used in the GnomeVFS URI.\n\nExamples of GnomeVFS URI include: \nfile:///tmp/foo.txt\nsftp:///root test example net/tmp/foo.txt\n\nThe most common schemes are:\n\n'file': local files\n'sftp': files accessed via SSH\n'ftp': files accessed via FTP\n'smb': files accessed via Samba (Windows share)\n'dav': files accessed via WebDav\n\nAll GnomeVFS schemes used by Nautilus can be used here.")
+#define ACTION_VERSION_DESC_SHORT	_("The version of the configuration format")
+#define ACTION_VERSION_DESC_LONG	_("The version of the configuration format that will be used to manage backward compatibility")
 
 G_END_DECLS
 
diff --git a/src/nact/nact-gconf-reader.c b/src/nact/nact-gconf-reader.c
index caf237c..ec8967c 100644
--- a/src/nact/nact-gconf-reader.c
+++ b/src/nact/nact-gconf-reader.c
@@ -278,10 +278,10 @@ nact_gconf_reader_import( NactWindow *window, const gchar *uri, GSList **msg )
 	} else {
 		xmlNode *root_node = xmlDocGetRootElement( doc );
 
-		if( strxcmp( root_node->name, NACT_GCONF_XML_ROOT )){
+		if( strxcmp( root_node->name, NACT_GCONF_SCHEMA_ROOT )){
 			add_message( reader,
 					ERR_ROOT_ELEMENT,
-					NACT_GCONF_XML_ROOT, ( const char * ) root_node->name, root_node->line );
+					NACT_GCONF_SCHEMA_ROOT, ( const char * ) root_node->name, root_node->line );
 
 		} else {
 			for( iter = root_node->children ; iter ; iter = iter->next ){
@@ -290,10 +290,10 @@ nact_gconf_reader_import( NactWindow *window, const gchar *uri, GSList **msg )
 					continue;
 				}
 
-				if( strxcmp( iter->name, NACT_GCONF_XML_SCHEMA_LIST )){
+				if( strxcmp( iter->name, NACT_GCONF_SCHEMA_LIST )){
 					add_message( reader,
 							ERR_WAITED_IGNORED_NODE,
-							NACT_GCONF_XML_SCHEMA_LIST, ( const char * ) iter->name, iter->line );
+							NACT_GCONF_SCHEMA_LIST, ( const char * ) iter->name, iter->line );
 					continue;
 				}
 
@@ -344,10 +344,10 @@ gconf_reader_parse_schemalist( NactGConfReader *reader, xmlNode *schema )
 			continue;
 		}
 
-		if( strxcmp( iter->name, NACT_GCONF_XML_SCHEMA_ENTRY )){
+		if( strxcmp( iter->name, NACT_GCONF_SCHEMA_ENTRY )){
 			add_message( reader,
 					ERR_WAITED_IGNORED_NODE,
-					NACT_GCONF_XML_SCHEMA_ENTRY, ( const char * ) iter->name, iter->line );
+					NACT_GCONF_SCHEMA_ENTRY, ( const char * ) iter->name, iter->line );
 			continue;
 		}
 
@@ -415,23 +415,23 @@ gconf_reader_parse_schema( NactGConfReader *reader, xmlNode *schema )
 			continue;
 		}
 
-		if( strxcmp( iter->name, NACT_GCONF_XML_SCHEMA_KEY ) &&
-			strxcmp( iter->name, NACT_GCONF_XML_SCHEMA_APPLYTO ) &&
-			strxcmp( iter->name, NACT_GCONF_XML_SCHEMA_OWNER ) &&
-			strxcmp( iter->name, NACT_GCONF_XML_SCHEMA_TYPE ) &&
-			strxcmp( iter->name, NACT_GCONF_XML_SCHEMA_LIST_TYPE ) &&
-			strxcmp( iter->name, NACT_GCONF_XML_SCHEMA_LOCALE ) &&
-			strxcmp( iter->name, NACT_GCONF_XML_SCHEMA_DFT )){
+		if( strxcmp( iter->name, NACT_GCONF_SCHEMA_KEY ) &&
+			strxcmp( iter->name, NACT_GCONF_SCHEMA_APPLYTO ) &&
+			strxcmp( iter->name, NACT_GCONF_SCHEMA_OWNER ) &&
+			strxcmp( iter->name, NACT_GCONF_SCHEMA_TYPE ) &&
+			strxcmp( iter->name, NACT_GCONF_SCHEMA_LIST_TYPE ) &&
+			strxcmp( iter->name, NACT_GCONF_SCHEMA_LOCALE ) &&
+			strxcmp( iter->name, NACT_GCONF_SCHEMA_DEFAULT )){
 
 				add_message( reader, ERR_UNEXPECTED_NODE, ( const char * ) iter->name, iter->line );
 				ret = FALSE;
 				continue;
 		}
 
-		if( !strxcmp( iter->name, NACT_GCONF_XML_SCHEMA_KEY ) ||
-			!strxcmp( iter->name, NACT_GCONF_XML_SCHEMA_OWNER ) ||
-			!strxcmp( iter->name, NACT_GCONF_XML_SCHEMA_TYPE ) ||
-			!strxcmp( iter->name, NACT_GCONF_XML_SCHEMA_LIST_TYPE )){
+		if( !strxcmp( iter->name, NACT_GCONF_SCHEMA_KEY ) ||
+			!strxcmp( iter->name, NACT_GCONF_SCHEMA_OWNER ) ||
+			!strxcmp( iter->name, NACT_GCONF_SCHEMA_TYPE ) ||
+			!strxcmp( iter->name, NACT_GCONF_SCHEMA_LIST_TYPE )){
 
 				pre_v1_11 = TRUE;
 				continue;
@@ -456,7 +456,7 @@ gconf_reader_parse_schema( NactGConfReader *reader, xmlNode *schema )
 			continue;
 		}
 
-		if( !strxcmp( iter->name, NACT_GCONF_XML_SCHEMA_APPLYTO )){
+		if( !strxcmp( iter->name, NACT_GCONF_SCHEMA_APPLYTO )){
 
 			if( applyto ){
 				add_message( reader, ERR_UNEXPECTED_NODE, ( const char * ) iter->name, iter->line );
@@ -470,7 +470,7 @@ gconf_reader_parse_schema( NactGConfReader *reader, xmlNode *schema )
 
 	if( !applyto ){
 		g_assert( ret );
-		add_message( reader, ERR_NODE_NOT_FOUND, NACT_GCONF_XML_SCHEMA_APPLYTO );
+		add_message( reader, ERR_NODE_NOT_FOUND, NACT_GCONF_SCHEMA_APPLYTO );
 		ret = FALSE;
 	}
 
@@ -490,7 +490,7 @@ gconf_reader_parse_schema( NactGConfReader *reader, xmlNode *schema )
 			continue;
 		}
 
-		if( !strxcmp( iter->name, NACT_GCONF_XML_SCHEMA_LOCALE )){
+		if( !strxcmp( iter->name, NACT_GCONF_SCHEMA_LOCALE )){
 
 			if( locale_found ){
 				add_message( reader, ERR_UNEXPECTED_NODE, ( const char * ) iter->name, iter->line );
@@ -503,7 +503,7 @@ gconf_reader_parse_schema( NactGConfReader *reader, xmlNode *schema )
 				}
 			}
 
-		} else if( !strxcmp( iter->name, NACT_GCONF_XML_SCHEMA_DFT )){
+		} else if( !strxcmp( iter->name, NACT_GCONF_SCHEMA_DEFAULT )){
 
 			if( default_found ){
 				add_message( reader, ERR_UNEXPECTED_NODE, ( const char * ) iter->name, iter->line );
@@ -654,17 +654,17 @@ gconf_reader_parse_locale( NactGConfReader *reader, xmlNode *locale )
 			continue;
 		}
 
-		if( strxcmp( iter->name, NACT_GCONF_XML_SCHEMA_SHORT ) &&
-			strxcmp( iter->name, NACT_GCONF_XML_SCHEMA_LONG ) &&
-			strxcmp( iter->name, NACT_GCONF_XML_SCHEMA_DFT )){
+		if( strxcmp( iter->name, NACT_GCONF_SCHEMA_SHORT ) &&
+			strxcmp( iter->name, NACT_GCONF_SCHEMA_LONG ) &&
+			strxcmp( iter->name, NACT_GCONF_SCHEMA_DEFAULT )){
 
 				add_message( reader, ERR_UNEXPECTED_NODE, ( const char * ) iter->name, iter->line );
 				ret = FALSE;
 				continue;
 		}
 
-		if( !strxcmp( iter->name, NACT_GCONF_XML_SCHEMA_SHORT ) ||
-			!strxcmp( iter->name, NACT_GCONF_XML_SCHEMA_LONG )){
+		if( !strxcmp( iter->name, NACT_GCONF_SCHEMA_SHORT ) ||
+			!strxcmp( iter->name, NACT_GCONF_SCHEMA_LONG )){
 				continue;
 		}
 
diff --git a/src/nact/nact-gconf-writer.c b/src/nact/nact-gconf-writer.c
index 9ffd256..258f173 100644
--- a/src/nact/nact-gconf-writer.c
+++ b/src/nact/nact-gconf-writer.c
@@ -32,6 +32,7 @@
 #include <config.h>
 #endif
 
+#include <glib/gi18n.h>
 #include <libxml/tree.h>
 
 #include <common/na-gconf-keys.h>
@@ -39,6 +40,7 @@
 
 #include "nact-gconf-keys.h"
 #include "nact-gconf-writer.h"
+#include "nact-import-export-format.h"
 
 /* private class data
  */
@@ -71,16 +73,29 @@ static void             instance_dispose( GObject *object );
 static void             instance_finalize( GObject *object );
 
 static NactGConfWriter *gconf_writer_new( const gchar *uuid );
-static xmlDocPtr        create_xml( NactGConfWriter *writer, NAAction *action );
+static xmlDocPtr        create_xml_schema( NactGConfWriter *writer, gint format, NAAction *action );
 static void             create_schema_entry(
 										NactGConfWriter *writer,
+										gint format,
 										const gchar *profile_name,
 										const gchar *key,
 										const gchar *value,
 										xmlDocPtr doc,
 										xmlNodePtr list_node,
 										const gchar *type,
-										gboolean is_l10n_value );
+										gboolean is_l10n_value,
+										const gchar *short_desc,
+										const gchar *long_desc );
+static xmlDocPtr        create_xml_dump( NactGConfWriter *writer, gint format, NAAction *action );
+static void             create_dump_entry(
+										NactGConfWriter *writer,
+										gint format,
+										const gchar *profile_name,
+										const gchar *key,
+										const gchar *value,
+										xmlDocPtr doc,
+										xmlNodePtr list_node,
+										const gchar *type );
 
 GType
 nact_gconf_writer_get_type( void )
@@ -231,55 +246,73 @@ gconf_writer_new( const gchar *uuid )
  * Returns the written filename.
  */
 gchar *
-nact_gconf_writer_export( NAAction *action, const gchar *folder, gchar **msg )
+nact_gconf_writer_export( NAAction *action, const gchar *folder, gint format, gchar **msg )
 {
 	gchar *uuid = na_action_get_uuid( action );
 	NactGConfWriter *writer = gconf_writer_new( uuid );
 	g_free( uuid );
 
-	xmlDocPtr doc = create_xml( writer, action );
+	xmlDocPtr doc = NULL;
+	gchar *filename = NULL;
 
-	/* generate the filename name and save the xml document into it */
-	gchar *filename = g_strdup_printf( "%s/action-%s.xml", folder, writer->private->uuid );
+	switch( format ){
+		case FORMAT_GCONFSCHEMAFILE_V1:
+			doc = create_xml_schema( writer, format, action );
+			filename = g_strdup_printf( "%s/config_%s.schemas", folder, writer->private->uuid );
+			break;
+
+		case FORMAT_GCONFSCHEMAFILE_V2:
+			doc = create_xml_schema( writer, format, action );
+			filename = g_strdup_printf( "%s/config-%s.schema", folder, writer->private->uuid );
+			break;
+
+		case FORMAT_GCONFENTRY:
+			doc = create_xml_dump( writer, format, action );
+			filename = g_strdup_printf( "%s/action-%s.xml", folder, writer->private->uuid );
+			break;
+	}
+
+	g_assert( doc );
+	g_assert( filename );
 
 	if( xmlSaveFormatFileEnc( filename, doc, "UTF-8", 1 ) == -1 ){
 		g_free( filename );
 		filename = NULL;
 	}
+
 	xmlFreeDoc (doc);
 	xmlCleanupParser();
-
 	g_object_unref( writer );
 
 	return( filename );
 }
 
 static xmlDocPtr
-create_xml( NactGConfWriter *writer, NAAction *action )
+create_xml_schema( NactGConfWriter *writer, gint format, NAAction *action )
 {
 	xmlDocPtr doc = xmlNewDoc( BAD_CAST( "1.0" ));
-	xmlNodePtr root_node = xmlNewNode( NULL, BAD_CAST( NACT_GCONF_XML_ROOT ));
+	xmlNodePtr root_node = xmlNewNode( NULL, BAD_CAST( NACT_GCONF_SCHEMA_ROOT ));
 	xmlDocSetRootElement( doc, root_node );
-	xmlNodePtr list_node = xmlNewChild( root_node, NULL, BAD_CAST( NACT_GCONF_XML_SCHEMA_LIST ), NULL );
+	xmlNodePtr list_node = xmlNewChild( root_node, NULL, BAD_CAST( NACT_GCONF_SCHEMA_LIST ), NULL );
 
 	/* version */
 	gchar *version = na_action_get_version( action );
-	create_schema_entry( writer, NULL, ACTION_VERSION_ENTRY, version, doc, list_node, "string", FALSE );
+	create_schema_entry( writer, format, NULL, ACTION_VERSION_ENTRY, version, doc, list_node, "string", FALSE, ACTION_VERSION_DESC_SHORT, ACTION_VERSION_DESC_LONG );
 	g_free( version );
 
 	/* label */
 	gchar *label = na_action_get_label( action );
-	create_schema_entry( writer, NULL, ACTION_LABEL_ENTRY, label, doc, list_node, "string", TRUE );
+	create_schema_entry( writer, format, NULL, ACTION_LABEL_ENTRY, label, doc, list_node, "string", TRUE, ACTION_LABEL_DESC_SHORT, ACTION_LABEL_DESC_LONG );
 	g_free( label );
 
 	/* tooltip */
 	gchar *tooltip = na_action_get_tooltip( action );
-	create_schema_entry( writer, NULL, ACTION_TOOLTIP_ENTRY, tooltip, doc, list_node, "string", TRUE );
+	create_schema_entry( writer, format, NULL, ACTION_TOOLTIP_ENTRY, tooltip, doc, list_node, "string", TRUE, ACTION_TOOLTIP_DESC_SHORT, ACTION_TOOLTIP_DESC_LONG );
 	g_free( tooltip );
 
 	/* icon name */
 	gchar *icon = na_action_get_icon( action );
-	create_schema_entry( writer, NULL, ACTION_ICON_ENTRY, icon, doc, list_node, "string", FALSE );
+	create_schema_entry( writer, format, NULL, ACTION_ICON_ENTRY, icon, doc, list_node, "string", FALSE, ACTION_ICON_DESC_SHORT, ACTION_ICON_DESC_LONG );
 	g_free( icon );
 
 	GSList *profiles = na_action_get_profiles( action );
@@ -292,61 +325,61 @@ create_xml( NactGConfWriter *writer, NAAction *action )
 
 		/* profile label */
 		gchar *profile_label = na_action_profile_get_label( profile );
-		create_schema_entry( writer, profile_dir, ACTION_PROFILE_LABEL_ENTRY, profile_label, doc, list_node, "string", TRUE );
+		create_schema_entry( writer, format, profile_dir, ACTION_PROFILE_LABEL_ENTRY, profile_label, doc, list_node, "string", TRUE, ACTION_PROFILE_NAME_DESC_SHORT, ACTION_PROFILE_NAME_DESC_LONG );
 		g_free( profile_label );
 
 		/* path */
 		gchar *path = na_action_profile_get_path( profile );
-		create_schema_entry( writer, profile_dir, ACTION_PATH_ENTRY, path, doc, list_node, "string", FALSE );
+		create_schema_entry( writer, format, profile_dir, ACTION_PATH_ENTRY, path, doc, list_node, "string", FALSE, ACTION_PATH_DESC_SHORT, ACTION_PATH_DESC_LONG );
 		g_free( path );
 
 		/* parameters */
 		gchar *parameters = na_action_profile_get_parameters( profile );
-		create_schema_entry( writer, profile_dir, ACTION_PARAMETERS_ENTRY, parameters, doc, list_node, "string", FALSE );
+		create_schema_entry( writer, format, profile_dir, ACTION_PARAMETERS_ENTRY, parameters, doc, list_node, "string", FALSE, ACTION_PARAMETERS_DESC_SHORT, ACTION_PARAMETERS_DESC_LONG );
 		g_free( parameters );
 
 		/* basenames */
 		GSList *basenames = na_action_profile_get_basenames( profile );
 		gchar *text = na_utils_gslist_to_schema( basenames );
-		create_schema_entry( writer, profile_dir, ACTION_BASENAMES_ENTRY, text, doc, list_node, "list", FALSE );
+		create_schema_entry( writer, format, profile_dir, ACTION_BASENAMES_ENTRY, text, doc, list_node, "list", FALSE, ACTION_BASENAMES_DESC_SHORT, ACTION_BASENAMES_DESC_LONG );
 		g_free( text );
 		na_utils_free_string_list( basenames );
 
 		/* match_case */
 		gboolean match = na_action_profile_get_matchcase( profile );
 		text = na_utils_boolean_to_schema( match );
-		create_schema_entry( writer, profile_dir, ACTION_MATCHCASE_ENTRY, text, doc, list_node, "bool", FALSE );
+		create_schema_entry( writer, format, profile_dir, ACTION_MATCHCASE_ENTRY, text, doc, list_node, "bool", FALSE, ACTION_MATCHCASE_DESC_SHORT, ACTION_MATCHCASE_DESC_LONG );
 		g_free( text );
 
 		/* mimetypes */
 		GSList *mimetypes = na_action_profile_get_mimetypes( profile );
 		text = na_utils_gslist_to_schema( mimetypes );
-		create_schema_entry( writer, profile_dir, ACTION_MIMETYPES_ENTRY, text, doc, list_node, "list", FALSE );
+		create_schema_entry( writer, format, profile_dir, ACTION_MIMETYPES_ENTRY, text, doc, list_node, "list", FALSE, ACTION_MIMETYPES_DESC_SHORT, ACTION_MIMETYPES_DESC_LONG );
 		g_free( text );
 		na_utils_free_string_list( mimetypes );
 
 		/* is_file */
 		gboolean isfile = na_action_profile_get_is_file( profile );
 		text = na_utils_boolean_to_schema( isfile );
-		create_schema_entry( writer, profile_dir, ACTION_ISFILE_ENTRY, text, doc, list_node, "bool", FALSE );
+		create_schema_entry( writer, format, profile_dir, ACTION_ISFILE_ENTRY, text, doc, list_node, "bool", FALSE, ACTION_ISFILE_DESC_SHORT, ACTION_ISFILE_DESC_LONG );
 		g_free( text );
 
 		/* is_dir */
 		gboolean isdir = na_action_profile_get_is_dir( profile );
 		text = na_utils_boolean_to_schema( isdir );
-		create_schema_entry( writer, profile_dir, ACTION_ISDIR_ENTRY, text, doc, list_node, "bool", FALSE );
+		create_schema_entry( writer, format, profile_dir, ACTION_ISDIR_ENTRY, text, doc, list_node, "bool", FALSE, ACTION_ISDIR_DESC_SHORT, ACTION_ISDIR_DESC_LONG );
 		g_free( text );
 
 		/* accept-multiple-files */
 		gboolean mutiple = na_action_profile_get_multiple( profile );
 		text = na_utils_boolean_to_schema( mutiple );
-		create_schema_entry( writer, profile_dir, ACTION_MULTIPLE_ENTRY, text, doc, list_node, "bool", FALSE );
+		create_schema_entry( writer, format, profile_dir, ACTION_MULTIPLE_ENTRY, text, doc, list_node, "bool", FALSE, ACTION_MULTIPLE_DESC_SHORT, ACTION_MULTIPLE_DESC_LONG );
 		g_free( text );
 
 		/* schemes */
 		GSList *schemes = na_action_profile_get_schemes( profile );
 		text = na_utils_gslist_to_schema( schemes );
-		create_schema_entry( writer, profile_dir, ACTION_SCHEMES_ENTRY, text, doc, list_node, "list", FALSE );
+		create_schema_entry( writer, format, profile_dir, ACTION_SCHEMES_ENTRY, text, doc, list_node, "list", FALSE, ACTION_SCHEMES_DESC_SHORT, ACTION_SCHEMES_DESC_LONG );
 		g_free( text );
 		na_utils_free_string_list( schemes );
 
@@ -358,8 +391,10 @@ create_xml( NactGConfWriter *writer, NAAction *action )
 
 static void
 create_schema_entry( NactGConfWriter *writer,
+		gint format,
 		const gchar *profile_name, const gchar *key, const gchar *value,
-		xmlDocPtr doc, xmlNodePtr list_node, const gchar *type, gboolean is_l10n_value )
+		xmlDocPtr doc, xmlNodePtr list_node, const gchar *type, gboolean is_l10n_value,
+		const gchar *short_desc, const gchar *long_desc )
 {
 	gchar *path = NULL;
 	if( profile_name ){
@@ -368,34 +403,188 @@ create_schema_entry( NactGConfWriter *writer,
 		path = g_build_path( "/", NA_GCONF_CONFIG_PATH, writer->private->uuid, key, NULL );
 	}
 
-	xmlNodePtr schema_node = xmlNewChild( list_node, NULL, BAD_CAST( NACT_GCONF_XML_SCHEMA_ENTRY ), NULL );
+	xmlNodePtr schema_node = xmlNewChild( list_node, NULL, BAD_CAST( NACT_GCONF_SCHEMA_ENTRY ), NULL );
 
-	/*xmlChar *content = BAD_CAST( g_build_path( "/", NACT_GCONF_SCHEMA_PREFIX, path, NULL ));
-	xmlNewChild( schema_node, NULL, BAD_CAST( NACT_GCONF_XML_SCHEMA_KEY ), content );
-	xmlFree( content );*/
+	xmlChar *content = BAD_CAST( g_build_path( "/", NA_GCONF_SCHEMA_PREFIX, path, NULL ));
+	xmlNewChild( schema_node, NULL, BAD_CAST( NACT_GCONF_SCHEMA_KEY ), content );
+	xmlFree( content );
 
-	xmlNewChild( schema_node, NULL, BAD_CAST( NACT_GCONF_XML_SCHEMA_APPLYTO ), BAD_CAST( path ));
+	xmlNewChild( schema_node, NULL, BAD_CAST( NACT_GCONF_SCHEMA_APPLYTO ), BAD_CAST( path ));
 
-	/*xmlNewChild( schema_node, NULL, BAD_CAST( NACT_GCONF_XML_SCHEMA_TYPE ), BAD_CAST( type ));*/
-
-	/*if( !g_ascii_strcasecmp( type, "list" )){
-		xmlNewChild( schema_node, NULL, BAD_CAST( NACT_GCONF_XML_SCHEMA_LIST_TYPE ), BAD_CAST( "string" ));
-	}*/
+	xmlNewChild( schema_node, NULL, BAD_CAST( NACT_GCONF_SCHEMA_TYPE ), BAD_CAST( type ));
+	if( !g_ascii_strcasecmp( type, "list" )){
+		xmlNewChild( schema_node, NULL, BAD_CAST( NACT_GCONF_SCHEMA_LIST_TYPE ), BAD_CAST( "string" ));
+	}
 
-	/* if the default value must be localized, put it in the <locale> element
+	/* always creates a 'locale' node,
+	 * maybe with the default value if this later is localized
 	 */
 	xmlNodePtr value_root_node = schema_node;
+	xmlNodePtr locale_node = xmlNewChild( schema_node, NULL, BAD_CAST( NACT_GCONF_SCHEMA_LOCALE ), NULL );
+	xmlNewProp( locale_node, BAD_CAST( "name" ), BAD_CAST( "C" ));
 	if( is_l10n_value ){
-		xmlNodePtr locale_node = xmlNewChild( schema_node, NULL, BAD_CAST( NACT_GCONF_XML_SCHEMA_LOCALE ), NULL );
-		xmlNewProp( locale_node, BAD_CAST( "name" ), BAD_CAST( "C" ));
 		value_root_node = locale_node;
 	}
 
 	/* encode special chars <, >, &, ...
 	 */
 	xmlChar *encoded_content = xmlEncodeSpecialChars( doc, BAD_CAST( value ));
-	xmlNewChild( value_root_node, NULL, BAD_CAST( NACT_GCONF_XML_SCHEMA_DFT ), encoded_content );
+	xmlNewChild( value_root_node, NULL, BAD_CAST( NACT_GCONF_SCHEMA_DEFAULT ), encoded_content );
 	xmlFree( encoded_content );
 
+	/* fill up the historical format if asked for
+	 * add owner and short and long descriptions
+	 */
+	if( format == FORMAT_GCONFSCHEMAFILE_V1 ){
+		xmlNewChild( schema_node, NULL, BAD_CAST( NACT_GCONF_SCHEMA_OWNER ), BAD_CAST( PACKAGE_TARNAME ));
+
+		xmlNewChild( locale_node, NULL, BAD_CAST( NACT_GCONF_SCHEMA_SHORT ), BAD_CAST( short_desc ));
+
+		xmlNewChild( locale_node, NULL, BAD_CAST( NACT_GCONF_SCHEMA_SHORT ), BAD_CAST( long_desc ));
+	}
+
+	g_free( path );
+}
+
+static xmlDocPtr
+create_xml_dump( NactGConfWriter *writer, gint format, NAAction *action )
+{
+	xmlDocPtr doc = xmlNewDoc( BAD_CAST( "1.0" ));
+	xmlNodePtr root_node = xmlNewNode( NULL, BAD_CAST( NACT_GCONF_DUMP_ROOT ));
+	xmlDocSetRootElement( doc, root_node );
+
+	gchar *path = g_build_path( "/", NA_GCONF_CONFIG_PATH, writer->private->uuid, NULL );
+	xmlNodePtr list_node = xmlNewChild( root_node, NULL, BAD_CAST( NACT_GCONF_DUMP_ENTRYLIST ), NULL );
+	xmlNewProp( list_node, BAD_CAST( NACT_GCONF_DUMP_ENTRYLIST_BASE ), BAD_CAST( path ));
 	g_free( path );
+
+	/* version */
+	gchar *version = na_action_get_version( action );
+	create_dump_entry( writer, format, NULL, ACTION_VERSION_ENTRY, version, doc, list_node, "string" );
+	g_free( version );
+
+	/* label */
+	gchar *label = na_action_get_label( action );
+	create_dump_entry( writer, format, NULL, ACTION_LABEL_ENTRY, label, doc, list_node, "string" );
+	g_free( label );
+
+	/* tooltip */
+	gchar *tooltip = na_action_get_tooltip( action );
+	create_dump_entry( writer, format, NULL, ACTION_TOOLTIP_ENTRY, tooltip, doc, list_node, "string" );
+	g_free( tooltip );
+
+	/* icon name */
+	gchar *icon = na_action_get_icon( action );
+	create_dump_entry( writer, format, NULL, ACTION_ICON_ENTRY, icon, doc, list_node, "string" );
+	g_free( icon );
+
+	GSList *profiles = na_action_get_profiles( action );
+	GSList *ip;
+
+	for( ip = profiles ; ip ; ip = ip->next ){
+
+		NAActionProfile *profile = NA_ACTION_PROFILE( ip->data );
+		gchar *profile_dir = na_action_profile_get_name( profile );
+
+		/* profile label */
+		gchar *profile_label = na_action_profile_get_label( profile );
+		create_dump_entry( writer, format, profile_dir, ACTION_PROFILE_LABEL_ENTRY, profile_label, doc, list_node, "string" );
+		g_free( profile_label );
+
+		/* path */
+		gchar *path = na_action_profile_get_path( profile );
+		create_dump_entry( writer, format, profile_dir, ACTION_PATH_ENTRY, path, doc, list_node, "string" );
+		g_free( path );
+
+		/* parameters */
+		gchar *parameters = na_action_profile_get_parameters( profile );
+		create_dump_entry( writer, format, profile_dir, ACTION_PARAMETERS_ENTRY, parameters, doc, list_node, "string" );
+		g_free( parameters );
+
+		/* basenames */
+		GSList *basenames = na_action_profile_get_basenames( profile );
+		gchar *text = na_utils_gslist_to_schema( basenames );
+		create_dump_entry( writer, format, profile_dir, ACTION_BASENAMES_ENTRY, text, doc, list_node, "list" );
+		g_free( text );
+		na_utils_free_string_list( basenames );
+
+		/* match_case */
+		gboolean match = na_action_profile_get_matchcase( profile );
+		text = na_utils_boolean_to_schema( match );
+		create_dump_entry( writer, format, profile_dir, ACTION_MATCHCASE_ENTRY, text, doc, list_node, "bool" );
+		g_free( text );
+
+		/* mimetypes */
+		GSList *mimetypes = na_action_profile_get_mimetypes( profile );
+		text = na_utils_gslist_to_schema( mimetypes );
+		create_dump_entry( writer, format, profile_dir, ACTION_MIMETYPES_ENTRY, text, doc, list_node, "list" );
+		g_free( text );
+		na_utils_free_string_list( mimetypes );
+
+		/* is_file */
+		gboolean isfile = na_action_profile_get_is_file( profile );
+		text = na_utils_boolean_to_schema( isfile );
+		create_dump_entry( writer, format, profile_dir, ACTION_ISFILE_ENTRY, text, doc, list_node, "bool" );
+		g_free( text );
+
+		/* is_dir */
+		gboolean isdir = na_action_profile_get_is_dir( profile );
+		text = na_utils_boolean_to_schema( isdir );
+		create_dump_entry( writer, format, profile_dir, ACTION_ISDIR_ENTRY, text, doc, list_node, "bool" );
+		g_free( text );
+
+		/* accept-multiple-files */
+		gboolean mutiple = na_action_profile_get_multiple( profile );
+		text = na_utils_boolean_to_schema( mutiple );
+		create_dump_entry( writer, format, profile_dir, ACTION_MULTIPLE_ENTRY, text, doc, list_node, "bool" );
+		g_free( text );
+
+		/* schemes */
+		GSList *schemes = na_action_profile_get_schemes( profile );
+		text = na_utils_gslist_to_schema( schemes );
+		create_dump_entry( writer, format, profile_dir, ACTION_SCHEMES_ENTRY, text, doc, list_node, "list" );
+		g_free( text );
+		na_utils_free_string_list( schemes );
+
+		g_free( profile_dir );
+	}
+
+	return( doc );
+}
+
+static void
+create_dump_entry( NactGConfWriter *writer,
+		gint format,
+		const gchar *profile_name, const gchar *key, const gchar *value,
+		xmlDocPtr doc, xmlNodePtr list_node, const gchar *type )
+{
+	xmlNodePtr entry_node = xmlNewChild( list_node, NULL, BAD_CAST( NACT_GCONF_DUMP_ENTRY ), NULL );
+
+	gchar *entry = NULL;
+	if( profile_name ){
+		entry = g_strdup_printf( "%s/%s", profile_name, key );
+	} else {
+		entry = g_strdup( key );
+	}
+	xmlNewChild( entry_node, NULL, BAD_CAST( NACT_GCONF_DUMP_KEY ), BAD_CAST( entry ));
+	g_free( entry );
+
+	xmlNodePtr value_node = xmlNewChild( entry_node, NULL, BAD_CAST( NACT_GCONF_DUMP_VALUE ), NULL );
+
+	if( !g_ascii_strcasecmp( type, "list" )){
+		xmlNodePtr value_list_node = xmlNewChild( value_node, NULL, BAD_CAST( NACT_GCONF_DUMP_LIST ), NULL );
+		xmlNewProp( value_list_node, BAD_CAST( NACT_GCONF_DUMP_LIST_TYPE ), BAD_CAST( NACT_GCONF_DUMP_STRING ));
+		xmlNodePtr value_list_value_node = xmlNewChild( value_list_node, NULL, BAD_CAST( NACT_GCONF_DUMP_VALUE ), NULL );
+		GSList *list = na_utils_schema_to_gslist( value );
+		GSList *is;
+		for( is = list ; is ; is = is->next ){
+			xmlChar *encoded_content = xmlEncodeSpecialChars( doc, BAD_CAST(( gchar * ) is->data ));
+			xmlNewChild( value_list_value_node, NULL, BAD_CAST( NACT_GCONF_DUMP_STRING ), encoded_content );
+			xmlFree( encoded_content );
+		}
+	} else {
+		xmlChar *encoded_content = xmlEncodeSpecialChars( doc, BAD_CAST( value ));
+		xmlNewChild( value_node, NULL, BAD_CAST( NACT_GCONF_DUMP_STRING ), encoded_content );
+		xmlFree( encoded_content );
+	}
 }
diff --git a/src/nact/nact-gconf-writer.h b/src/nact/nact-gconf-writer.h
index 26e10bf..a740c0c 100644
--- a/src/nact/nact-gconf-writer.h
+++ b/src/nact/nact-gconf-writer.h
@@ -70,7 +70,7 @@ typedef struct {
 
 GType  nact_gconf_writer_get_type( void );
 
-gchar *nact_gconf_writer_export( NAAction *action, const gchar *folder, gchar **msg );
+gchar *nact_gconf_writer_export( NAAction *action, const gchar *folder, gint format, gchar **msg );
 
 G_END_DECLS
 
diff --git a/src/nact/nact-import-export-format.h b/src/nact/nact-import-export-format.h
new file mode 100644
index 0000000..384ad06
--- /dev/null
+++ b/src/nact/nact-import-export-format.h
@@ -0,0 +1,57 @@
+/*
+ * Nautilus Actions
+ * A Nautilus extension which offers configurable context menu actions.
+ *
+ * Copyright (C) 2005 The GNOME Foundation
+ * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+ * Copyright (C) 2009 Pierre Wieser and others (see AUTHORS)
+ *
+ * This Program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this Library; see the file COPYING.  If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ *   Frederic Ruaudel <grumz grumz net>
+ *   Rodrigo Moya <rodrigo gnome-db org>
+ *   Pierre Wieser <pwieser trychlos org>
+ *   ... and many others (see AUTHORS)
+ */
+
+#ifndef __NACT_IMPORT_EXPORT_FORMAT_H__
+#define __NACT_IMPORT_EXPORT_FORMAT_H__
+
+G_BEGIN_DECLS
+
+/* import/export formats
+ *
+ * FORMAT_GCONFSCHEMAFILE_V1: a schema with owner, short and long
+ * descriptions ; each action has its own schema addressed by the uuid
+ * (historical format up to v1.10.x serie)
+ *
+ * FORMAT_GCONFSCHEMAFILE_V2: the lightest schema still compatible
+ * with gconftool-2 --install-schema-file (no owner, no short nor long
+ * descriptions) - introduced in v 1.11
+ *
+ * FORMAT_GCONFENTRY: not a schema, but a dump of the GConf entry
+ * introduced in v 1.11
+ */
+enum {
+	FORMAT_GCONFSCHEMAFILE_V1 = 1,
+	FORMAT_GCONFSCHEMAFILE_V2,
+	FORMAT_GCONFENTRY
+};
+
+G_END_DECLS
+
+#endif /* __NACT_IMPORT_EXPORT_FORMAT_H__ */
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index 718852f..59128f7 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -592,12 +592,12 @@ setup_dialog_title( NactWindow *window )
 		g_free( label );
 		g_free( title );
 		title = tmp;
+	}
 
-		if( is_modified_action( NACT_WINDOW( window ), NACT_MAIN_WINDOW( window )->private->edited_action )){
-			gchar *tmp = g_strdup_printf( "*%s", title );
-			g_free( title );
-			title = tmp;
-		}
+	if( count_modified_actions( window )){
+		gchar *tmp = g_strdup_printf( "*%s", title );
+		g_free( title );
+		title = tmp;
 	}
 
 	GtkWindow *toplevel = base_window_get_toplevel_dialog( BASE_WINDOW( window ));
diff --git a/src/nact/nautilus-actions-config.ui b/src/nact/nautilus-actions-config.ui
index 4a64292..1823955 100644
--- a/src/nact/nautilus-actions-config.ui
+++ b/src/nact/nautilus-actions-config.ui
@@ -886,9 +886,9 @@
       <object class="GtkFileChooserWidget" id="filechooserwidget1">
         <property name="visible">True</property>
         <property name="orientation">vertical</property>
-        <property name="local_only">False</property>
-        <property name="preview_widget_active">False</property>
         <property name="select_multiple">True</property>
+        <property name="preview_widget_active">False</property>
+        <property name="local_only">False</property>
         <property name="use_preview_label">False</property>
       </object>
     </child>
@@ -972,10 +972,10 @@ to extend a selection.</property>
           <object class="GtkFileChooserWidget" id="ExportFolderChooser">
             <property name="visible">True</property>
             <property name="orientation">vertical</property>
-            <property name="local_only">False</property>
             <property name="preview_widget_active">False</property>
-            <property name="use_preview_label">False</property>
+            <property name="local_only">False</property>
             <property name="action">select-folder</property>
+            <property name="use_preview_label">False</property>
           </object>
           <packing>
             <property name="position">0</property>
@@ -987,6 +987,197 @@ to extend a selection.</property>
       </packing>
     </child>
     <child>
+      <object class="GtkVBox" id="vbox1">
+        <property name="visible">True</property>
+        <property name="border_width">10</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">10</property>
+        <child>
+          <object class="GtkVBox" id="vbox2">
+            <property name="visible">True</property>
+            <property name="orientation">vertical</property>
+            <child>
+              <object class="GtkRadioButton" id="ExportSchemaV1Button">
+                <property name="label" translatable="yes">Export as a GConf schema file with full key descriptions.</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="active">True</property>
+                <property name="draw_indicator">True</property>
+              </object>
+              <packing>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkHBox" id="hbox4">
+                <property name="visible">True</property>
+                <child>
+                  <object class="GtkRadioButton" id="ExportHide1">
+                    <property name="sensitive">False</property>
+                    <property name="can_focus">False</property>
+                    <property name="receives_default">False</property>
+                    <property name="focus_on_click">False</property>
+                    <property name="draw_indicator">False</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="padding">2</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="ExportSchemaV1Label">
+                    <property name="visible">True</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">This used to be the historical export format.
+The exported file may later be imported via :
+- Import assistant of the Nautilus Actions Configuration Tool,
+- or via the gconftool-2 --import-schema-file command-line tool.</property>
+                  </object>
+                  <packing>
+                    <property name="padding">4</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkVBox" id="vbox3">
+            <property name="visible">True</property>
+            <property name="orientation">vertical</property>
+            <child>
+              <object class="GtkRadioButton" id="ExportSchemaV2Button">
+                <property name="label" translatable="yes">Export as a light GConf schema file.</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="xalign">0</property>
+                <property name="active">True</property>
+                <property name="draw_indicator">True</property>
+                <property name="group">ExportSchemaV1Button</property>
+              </object>
+              <packing>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkHBox" id="hbox5">
+                <property name="visible">True</property>
+                <child>
+                  <object class="GtkRadioButton" id="ExportHide2">
+                    <property name="sensitive">False</property>
+                    <property name="can_focus">False</property>
+                    <property name="receives_default">False</property>
+                    <property name="focus_on_click">False</property>
+                    <property name="draw_indicator">False</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="padding">2</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="ExportSchemaV2Label">
+                    <property name="visible">True</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">The exported file may later be imported via :
+- Import assistant of the Nautilus Actions Configuration Tool,
+- or via the gconftool-2 --import-schema-file command-line tool.</property>
+                  </object>
+                  <packing>
+                    <property name="padding">4</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkVBox" id="vbox4">
+            <property name="visible">True</property>
+            <property name="orientation">vertical</property>
+            <child>
+              <object class="GtkRadioButton" id="ExportGConfDumpButton">
+                <property name="label" translatable="yes">Export as a GConf dump file.</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="xalign">0</property>
+                <property name="active">True</property>
+                <property name="draw_indicator">True</property>
+                <property name="group">ExportSchemaV1Button</property>
+              </object>
+              <packing>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkHBox" id="hbox6">
+                <property name="visible">True</property>
+                <child>
+                  <object class="GtkRadioButton" id="ExportHide3">
+                    <property name="sensitive">False</property>
+                    <property name="can_focus">False</property>
+                    <property name="receives_default">False</property>
+                    <property name="focus_on_click">False</property>
+                    <property name="draw_indicator">False</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="padding">2</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="ExportGConfDumpLabel">
+                    <property name="visible">True</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">This is the preferred format for newly exported actions.
+The exported file may later be imported via :
+- Import assistant of the Nautilus Actions Configuration Tool,
+- or via the gconftool-2 --load command-line tool.</property>
+                  </object>
+                  <packing>
+                    <property name="padding">4</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="position">3</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="title">Select the export format</property>
+      </packing>
+    </child>
+    <child>
       <object class="GtkLabel" id="label3">
         <property name="visible">True</property>
         <property name="use_markup">True</property>
@@ -1211,16 +1402,16 @@ file(s)/folder(s)</property>
   </object>
   <object class="GtkSizeGroup" id="CommandLabelSizeGroup">
     <widgets>
-      <widget name="ProfileLabelLabel"/>
-      <widget name="CommandPathLabel"/>
-      <widget name="CommandParametersLabel"/>
       <widget name="CommandExamplePreLabel"/>
+      <widget name="CommandParametersLabel"/>
+      <widget name="CommandPathLabel"/>
+      <widget name="ProfileLabelLabel"/>
     </widgets>
   </object>
   <object class="GtkSizeGroup" id="CommandButtonSizeGroup">
     <widgets>
-      <widget name="CommandPathButton"/>
       <widget name="CommandLegendButton"/>
+      <widget name="CommandPathButton"/>
     </widgets>
   </object>
 </interface>



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