[nautilus-actions] Record last export format used as a preference
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Record last export format used as a preference
- Date: Sat, 17 Oct 2009 23:48:44 +0000 (UTC)
commit 3cd1beaa5422633a917efc7aaff27d028e5a35cb
Author: Pierre Wieser <pwieser trychlos org>
Date: Fri Oct 16 21:24:54 2009 +0200
Record last export format used as a preference
ChangeLog | 19 ++
src/common/na-iprefs.c | 84 +++++++++-
src/common/na-iprefs.h | 33 ++++-
src/common/na-xml-names.h | 26 +---
src/common/na-xml-writer.c | 36 ++--
src/nact/nact-assistant-export.c | 299 +++++++++++++++++++---------------
src/nact/nact-assistant-export.ui | 53 +-----
src/nact/nact-assistant-import.c | 8 +-
src/nact/nact-clipboard.c | 5 +-
src/utils/nautilus-actions-new.c | 3 +-
src/utils/nautilus-actions-schemas.c | 3 +-
11 files changed, 333 insertions(+), 236 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index aaa0b98..ccaeb9d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,24 @@
2009-10-16 Pierre Wieser <pwieser trychlos org>
+ Record last export format as a preference.
+
+ * src/common/na-iprefs.c:
+ * src/common/na-iprefs.h
+ (na_iprefs_get_export_format, na_iprefs_set_export_format):
+ New functions.
+
+ * src/common/na-xml-names.h:
+ Move export format constantes to src/common/na-iprefs.h.
+
+ * src/common/na-xml-writer.c:
+ * src/nact/nact-assistant-export.c:
+ * src/nact/nact-assistant-export.ui:
+ * src/nact/nact-assistant-import.c:
+ * src/nact/nact-clipboard.c:
+ * src/utils/nautilus-actions-new.c:
+ * src/utils/nautilus-actions-schemas.c:
+ Updated accordingly.
+
* src/nact/nact-iactions-list.c (nact_iactions_list_fill):
Only count items in edition mode.
diff --git a/src/common/na-iprefs.c b/src/common/na-iprefs.c
index a739044..06b900d 100644
--- a/src/common/na-iprefs.c
+++ b/src/common/na-iprefs.c
@@ -35,14 +35,25 @@
#include "na-iprefs.h"
-#define DEFAULT_IMPORT_MODE_INT IPREFS_IMPORT_NO_IMPORT
-#define DEFAULT_IMPORT_MODE_STR "NoImport"
+#define DEFAULT_IMPORT_MODE_INT IPREFS_IMPORT_NO_IMPORT
+#define DEFAULT_IMPORT_MODE_STR "NoImport"
static GConfEnumStringPair import_mode_table[] = {
- { IPREFS_IMPORT_NO_IMPORT, "NoImport" },
- { IPREFS_IMPORT_RENUMBER, "Renumber" },
- { IPREFS_IMPORT_OVERRIDE, "Override" },
- { IPREFS_IMPORT_ASK, "Ask" },
+ { IPREFS_IMPORT_NO_IMPORT, DEFAULT_IMPORT_MODE_STR },
+ { IPREFS_IMPORT_RENUMBER, "Renumber" },
+ { IPREFS_IMPORT_OVERRIDE, "Override" },
+ { IPREFS_IMPORT_ASK, "Ask" },
+ { 0, NULL }
+};
+
+#define DEFAULT_EXPORT_FORMAT_INT IPREFS_EXPORT_FORMAT_GCONF_ENTRY
+#define DEFAULT_EXPORT_FORMAT_STR "GConfEntry"
+
+static GConfEnumStringPair export_format_table[] = {
+ { IPREFS_EXPORT_FORMAT_GCONF_SCHEMA_V1, "GConfSchemaV1" },
+ { IPREFS_EXPORT_FORMAT_GCONF_SCHEMA_V2, "GConfSchemaV2" },
+ { IPREFS_EXPORT_FORMAT_GCONF_ENTRY, DEFAULT_EXPORT_FORMAT_STR },
+ { IPREFS_EXPORT_FORMAT_ASK, "Ask" },
{ 0, NULL }
};
@@ -86,6 +97,42 @@ na_iprefs_migrate_key( NAIPrefs *instance, const gchar *old_key, const gchar *ne
}
/**
+ * na_iprefs_get_export_format:
+ * @instance: this #NAIPrefs interface instance.
+ * @name: name of the export format key to be readen
+ *
+ * Returns: the export format currently set.
+ *
+ * Note: this function returns a suitable default value even if the key
+ * is not found in GConf preferences or no schema has been installed.
+ *
+ * Note: please take care of keeping the default value synchronized with
+ * those defined in schemas.
+ */
+gint
+na_iprefs_get_export_format( NAIPrefs *instance, const gchar *name )
+{
+ gint export_format = DEFAULT_EXPORT_FORMAT_INT;
+ gint format_int;
+ gchar *format_str;
+
+ g_return_val_if_fail( NA_IS_IPREFS( instance ), DEFAULT_EXPORT_FORMAT_INT );
+
+ format_str = na_iprefs_read_string(
+ instance,
+ name,
+ DEFAULT_EXPORT_FORMAT_STR );
+
+ if( gconf_string_to_enum( export_format_table, format_str, &format_int )){
+ export_format = format_int;
+ }
+
+ g_free( format_str );
+
+ return( export_format );
+}
+
+/**
* na_iprefs_get_import_mode:
* @instance: this #NAIPrefs interface instance.
* @name: name of the import key to be readen
@@ -122,11 +169,34 @@ na_iprefs_get_import_mode( NAIPrefs *instance, const gchar *name )
}
/**
+ * na_iprefs_set_export_format:
+ * @instance: this #NAIPrefs interface instance.
+ * @format: the new value to be written.
+ *
+ * Writes the current status of 'import/export format' to the GConf
+ * preference system.
+ */
+void
+na_iprefs_set_export_format( NAIPrefs *instance, const gchar *name, gint format )
+{
+ const gchar *format_str;
+
+ g_return_if_fail( NA_IS_IPREFS( instance ));
+
+ format_str = gconf_enum_to_string( export_format_table, format );
+
+ na_iprefs_write_string(
+ instance,
+ name,
+ format_str ? format_str : DEFAULT_EXPORT_FORMAT_STR );
+}
+
+/**
* na_iprefs_set_import_mode:
* @instance: this #NAIPrefs interface instance.
* @mode: the new value to be written.
*
- * Writes the current status of 'alphabetical order' to the GConf
+ * Writes the current status of 'import mode' to the GConf
* preference system.
*/
void
diff --git a/src/common/na-iprefs.h b/src/common/na-iprefs.h
index 5a92fc2..656c1a0 100644
--- a/src/common/na-iprefs.h
+++ b/src/common/na-iprefs.h
@@ -47,6 +47,7 @@ G_BEGIN_DECLS
/* GConf Preference keys managed by IPrefs interface
*/
+#define IPREFS_EXPORT_FORMAT "export-format"
#define IPREFS_IMPORT_ACTIONS_IMPORT_MODE "import-mode"
#define IPREFS_IMPORT_ASK_LAST_MODE "import-ask-user-last-mode"
@@ -59,14 +60,40 @@ enum {
IPREFS_IMPORT_ASK
};
+/* import/export formats
+ *
+ * FORMAT_GCONF_SCHEMA_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_GCONF_SCHEMA_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_GCONF_SCHEMA: exports a full schema, not an action
+ *
+ * FORMAT_GCONF_ENTRY: not a schema, but a dump of the GConf entry
+ * introduced in v 1.11
+ */
+enum {
+ IPREFS_EXPORT_FORMAT_GCONF_SCHEMA_V1 = 1,
+ IPREFS_EXPORT_FORMAT_GCONF_SCHEMA_V2,
+ IPREFS_EXPORT_FORMAT_GCONF_SCHEMA,
+ IPREFS_EXPORT_FORMAT_GCONF_ENTRY,
+ IPREFS_EXPORT_FORMAT_ASK
+};
+
#define IPREFS_RELABEL_MENUS "iprefs-relabel-menus"
#define IPREFS_RELABEL_ACTIONS "iprefs-relabel-actions"
#define IPREFS_RELABEL_PROFILES "iprefs-relabel-profiles"
-void na_iprefs_migrate_key( NAIPrefs *instance, const gchar *old_key, const gchar *new_key );
+void na_iprefs_migrate_key( NAIPrefs *instance, const gchar *old_key, const gchar *new_key );
+
+gint na_iprefs_get_export_format( NAIPrefs *instance, const gchar *pref );
+gint na_iprefs_get_import_mode( NAIPrefs *instance, const gchar *pref );
-gint na_iprefs_get_import_mode( NAIPrefs *instance, const gchar *pref );
-void na_iprefs_set_import_mode( NAIPrefs *instance, const gchar *pref, gint mode );
+void na_iprefs_set_export_format( NAIPrefs *instance, const gchar *pref, gint format );
+void na_iprefs_set_import_mode( NAIPrefs *instance, const gchar *pref, gint mode );
G_END_DECLS
diff --git a/src/common/na-xml-names.h b/src/common/na-xml-names.h
index c758fcf..5088e9d 100644
--- a/src/common/na-xml-names.h
+++ b/src/common/na-xml-names.h
@@ -35,28 +35,8 @@
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,
- FORMAT_GCONFSCHEMA
-};
-
/* XML element names (GConf schema)
- * used in FORMAT_GCONFSCHEMAFILE_V1 and FORMAT_GCONFSCHEMAFILE_V2
+ * used in FORMAT_GCONF_SCHEMA_V1 and FORMAT_GCONF_SCHEMA_V2
*/
#define NACT_GCONF_SCHEMA_ROOT "gconfschemafile"
#define NACT_GCONF_SCHEMA_LIST "schemalist"
@@ -77,14 +57,14 @@ enum {
* Starting with 1.11, we have introduced a lighter export schema
* (mainly without owner and short and long descriptions)
*
- * only used in FORMAT_GCONFSCHEMAFILE_V1
+ * only used in FORMAT_GCONF_SCHEMA_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
+ * used in FORMAT_GCONF_ENTRY
*/
#define NACT_GCONF_DUMP_ROOT "gconfentryfile"
#define NACT_GCONF_DUMP_ENTRYLIST "entrylist"
diff --git a/src/common/na-xml-writer.c b/src/common/na-xml-writer.c
index 8b174e4..971e8a0 100644
--- a/src/common/na-xml-writer.c
+++ b/src/common/na-xml-writer.c
@@ -35,7 +35,9 @@
#include <gio/gio.h>
#include <libxml/tree.h>
-#include <runtime/na-object-api.h>
+#include <common/na-iprefs.h>
+#include <common/na-object-api.h>
+
#include <runtime/na-gconf-provider-keys.h>
#include "na-utils.h"
@@ -282,7 +284,7 @@ xml_writer_new( const gchar *uuid )
* na_xml_writer_export:
* @action: the #NAObjectAction to be exported.
* Can be NULL when exporting schemas ; in this case, format must be
- * FORMAT_GCONFSCHEMA.
+ * FORMAT_GCONF_SCHEMA.
* @folder: the directoy where to write the output XML file.
* If NULL, the output will be directed to stdout.
* @format: the export format.
@@ -300,28 +302,28 @@ na_xml_writer_export( const NAObjectAction *action, const gchar *folder, gint fo
gchar *xml_buffer;
g_debug( "%s: action=%p, format=%u", thisfn, ( void * ) action, format );
- g_return_val_if_fail( action || format == FORMAT_GCONFSCHEMA, NULL );
+ g_return_val_if_fail( action || format == IPREFS_EXPORT_FORMAT_GCONF_SCHEMA, NULL );
switch( format ){
- case FORMAT_GCONFSCHEMAFILE_V1:
- case FORMAT_GCONFSCHEMAFILE_V2:
+ case IPREFS_EXPORT_FORMAT_GCONF_SCHEMA_V1:
+ case IPREFS_EXPORT_FORMAT_GCONF_SCHEMA_V2:
filename = na_xml_writer_get_output_fname( action, folder, format );
break;
/* this is the format used by nautilus-actions-new utility,
* and that's why this option takes care of a NULL folder
*/
- case FORMAT_GCONFENTRY:
+ case IPREFS_EXPORT_FORMAT_GCONF_ENTRY:
if( folder ){
filename = na_xml_writer_get_output_fname( action, folder, format );
}
break;
- /* this is the format used by nautilus-actions-install-schema
+ /* this is the format used by nautilus-actions-schemas
* utility, and that's why this option takes care of a NULL
* folder, or an output filename
*/
- case FORMAT_GCONFSCHEMA:
+ case IPREFS_EXPORT_FORMAT_GCONF_SCHEMA:
if( folder ){
filename = g_strdup( folder );
}
@@ -376,17 +378,17 @@ na_xml_writer_get_output_fname( const NAObjectAction *action, const gchar *folde
uuid = na_object_get_id( action );
switch( format ){
- case FORMAT_GCONFSCHEMAFILE_V1:
+ case IPREFS_EXPORT_FORMAT_GCONF_SCHEMA_V1:
canonical_fname = g_strdup_printf( "config_%s", uuid );
canonical_ext = g_strdup( "schemas" );
break;
- case FORMAT_GCONFSCHEMAFILE_V2:
+ case IPREFS_EXPORT_FORMAT_GCONF_SCHEMA_V2:
canonical_fname = g_strdup_printf( "config-%s", uuid );
canonical_ext = g_strdup( "schema" );
break;
- case FORMAT_GCONFENTRY:
+ case IPREFS_EXPORT_FORMAT_GCONF_ENTRY:
canonical_fname = g_strdup_printf( "action-%s", uuid );
canonical_ext = g_strdup( "xml" );
break;
@@ -436,23 +438,23 @@ na_xml_writer_get_xml_buffer( const NAObjectAction *action, gint format )
int textlen;
gchar *buffer;
- g_return_val_if_fail( action || format == FORMAT_GCONFSCHEMA, NULL );
+ g_return_val_if_fail( action || format == IPREFS_EXPORT_FORMAT_GCONF_SCHEMA, NULL );
uuid = action ? na_object_get_id( action ) : NULL;
writer = xml_writer_new( uuid );
g_free( uuid );
switch( format ){
- case FORMAT_GCONFSCHEMAFILE_V1:
- case FORMAT_GCONFSCHEMAFILE_V2:
+ case IPREFS_EXPORT_FORMAT_GCONF_SCHEMA_V1:
+ case IPREFS_EXPORT_FORMAT_GCONF_SCHEMA_V2:
doc = create_xml_schema( writer, format, action );
break;
- case FORMAT_GCONFENTRY:
+ case IPREFS_EXPORT_FORMAT_GCONF_ENTRY:
doc = create_xml_dump( writer, format, action );
break;
- case FORMAT_GCONFSCHEMA:
+ case IPREFS_EXPORT_FORMAT_GCONF_SCHEMA:
doc = create_gconf_schema( writer );
break;
}
@@ -688,7 +690,7 @@ create_schema_entry( NAXMLWriter *writer,
/* fill up the historical format if asked for
* add owner and short and long descriptions
*/
- if( format == FORMAT_GCONFSCHEMAFILE_V1 ){
+ if( format == IPREFS_EXPORT_FORMAT_GCONF_SCHEMA_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 ));
diff --git a/src/nact/nact-assistant-export.c b/src/nact/nact-assistant-export.c
index ea5875b..072f854 100644
--- a/src/nact/nact-assistant-export.c
+++ b/src/nact/nact-assistant-export.c
@@ -108,9 +108,6 @@ static gchar *window_get_ui_filename( BaseWindow *dialog );
static void on_initial_load_dialog( NactAssistantExport *dialog, gpointer user_data );
static void on_runtime_init_dialog( NactAssistantExport *dialog, gpointer user_data );
-static void assistant_apply( BaseAssistant *window, GtkAssistant *assistant );
-static void assistant_prepare( BaseAssistant *window, GtkAssistant *assistant, GtkWidget *page );
-
static void assist_initial_load_intro( NactAssistantExport *window, GtkAssistant *assistant );
static void assist_runtime_init_intro( NactAssistantExport *window, GtkAssistant *assistant );
@@ -126,17 +123,21 @@ static void on_folder_selection_changed( GtkFileChooser *chooser, gpo
static void assist_initial_load_format( NactAssistantExport *window, GtkAssistant *assistant );
static void assist_runtime_init_format( NactAssistantExport *window, GtkAssistant *assistant );
-static void on_format_toggled( GtkToggleButton *button, NactAssistantExport *window );
static GtkWidget *get_gconfschemav1_button( NactAssistantExport *window );
static GtkWidget *get_gconfschemav2_button( NactAssistantExport *window );
static GtkWidget *get_gconfdump_button( NactAssistantExport *window );
+static GtkWidget *get_ask_button( NactAssistantExport *window );
+static gint get_export_format( NactAssistantExport *window );
static void assist_initial_load_confirm( NactAssistantExport *window, GtkAssistant *assistant );
static void assist_runtime_init_confirm( NactAssistantExport *window, GtkAssistant *assistant );
-static void assist_prepare_confirm( NactAssistantExport *window, GtkAssistant *assistant, GtkWidget *page );
static void assist_initial_load_exportdone( NactAssistantExport *window, GtkAssistant *assistant );
static void assist_runtime_init_exportdone( NactAssistantExport *window, GtkAssistant *assistant );
+
+static void assistant_prepare( BaseAssistant *window, GtkAssistant *assistant, GtkWidget *page );
+static void assist_prepare_confirm( NactAssistantExport *window, GtkAssistant *assistant, GtkWidget *page );
+static void assistant_apply( BaseAssistant *window, GtkAssistant *assistant );
static void assist_prepare_exportdone( NactAssistantExport *window, GtkAssistant *assistant, GtkWidget *page );
#ifdef NA_MAINTAINER_MODE
@@ -380,86 +381,6 @@ on_runtime_init_dialog( NactAssistantExport *dialog, gpointer user_data )
assist_runtime_init_exportdone( dialog, assistant );
}
-/*
- * As of 1.11, nact_gconf_writer doesn't return any error message.
- * An error is simply indicated by returning a null filename.
- * So we provide a general error message.
- */
-static void
-assistant_apply( BaseAssistant *wnd, GtkAssistant *assistant )
-{
- static const gchar *thisfn = "nact_assistant_export_on_apply";
- NactAssistantExport *window;
- GList *actions, *ia;
- gchar *msg = NULL;
- gchar *reason = NULL;
- gchar *tmp, *fname;
- NAObjectAction *action;
-
- g_debug( "%s: window=%p, assistant=%p", thisfn, ( void * ) wnd, ( void * ) assistant );
- g_assert( NACT_IS_ASSISTANT_EXPORT( wnd ));
- window = NACT_ASSISTANT_EXPORT( wnd );
-
- actions = nact_iactions_list_get_selected_items( NACT_IACTIONS_LIST( window ));
-
- g_assert( window->private->uri && strlen( window->private->uri ));
-
- for( ia = actions ; ia ; ia = ia->next ){
- action = NA_OBJECT_ACTION( ia->data );
- fname = na_xml_writer_export( action, window->private->uri, window->private->format, &msg );
-
- if( fname && strlen( fname )){
- window->private->fnames = g_slist_prepend( window->private->fnames, fname );
- g_debug( "%s: fname=%s", thisfn, fname );
-
- } else {
- window->private->errors += 1;
- if( msg ){
- if( reason ){
- tmp = g_strdup_printf( "%s\n", reason );
- g_free( reason );
- reason = tmp;
- }
- tmp = g_strdup_printf( "%s%s", reason, msg );
- g_free( reason );
- reason = tmp;
- g_free( msg );
- }
- }
- }
-
- na_object_free_items_list( actions );
-
- if( window->private->errors ){
- if( !reason ){
- reason = g_strdup( _( "You may not have writing permissions on selected folder." ));
- }
- window->private->reason = reason;
- }
-}
-
-static void
-assistant_prepare( BaseAssistant *window, GtkAssistant *assistant, GtkWidget *page )
-{
- /*static const gchar *thisfn = "nact_assistant_export_on_prepare";
- g_debug( "%s: window=%p, assistant=%p, page=%p", thisfn, window, assistant, page );*/
-
- GtkAssistantPageType type = gtk_assistant_get_page_type( assistant, page );
-
- switch( type ){
- case GTK_ASSISTANT_PAGE_CONFIRM:
- assist_prepare_confirm( NACT_ASSISTANT_EXPORT( window ), assistant, page );
- break;
-
- case GTK_ASSISTANT_PAGE_SUMMARY:
- assist_prepare_exportdone( NACT_ASSISTANT_EXPORT( window ), assistant, page );
- break;
-
- default:
- break;
- }
-}
-
static void
assist_initial_load_intro( NactAssistantExport *window, GtkAssistant *assistant )
{
@@ -640,50 +561,41 @@ assist_initial_load_format( NactAssistantExport *window, GtkAssistant *assistant
static void
assist_runtime_init_format( NactAssistantExport *window, GtkAssistant *assistant )
{
- GtkWidget *button;
+ GtkToggleButton *button;
GtkWidget *content;
+ NactApplication *application;
+ NAPivot *pivot;
+ gint format;
- button = get_gconfschemav1_button( window );
- base_window_signal_connect(
- BASE_WINDOW( window ),
- G_OBJECT( button ),
- "toggled",
- G_CALLBACK( on_format_toggled ));
-
- button = get_gconfschemav2_button( window );
- base_window_signal_connect(
- BASE_WINDOW( window ),
- G_OBJECT( button ),
- "toggled",
- G_CALLBACK( on_format_toggled ));
-
- button = get_gconfdump_button( window );
- gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), TRUE );
- window->private->format = FORMAT_GCONFENTRY;
- base_window_signal_connect(
- BASE_WINDOW( window ),
- G_OBJECT( button ),
- "toggled",
- G_CALLBACK( on_format_toggled ));
-
- content = gtk_assistant_get_nth_page( assistant, ASSIST_PAGE_FORMAT_SELECTION );
- gtk_assistant_set_page_complete( assistant, content, TRUE );
-}
+ application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
+ pivot = nact_application_get_pivot( application );
+ format = na_iprefs_get_export_format( NA_IPREFS( pivot ), IPREFS_EXPORT_FORMAT );
-static void
-on_format_toggled( GtkToggleButton *button, NactAssistantExport *window )
-{
- g_assert( NACT_IS_ASSISTANT_EXPORT( window ));
+ switch( format ){
+ case IPREFS_EXPORT_FORMAT_GCONF_SCHEMA_V1:
+ button = GTK_TOGGLE_BUTTON( get_gconfschemav1_button( window ));
+ gtk_toggle_button_set_active( button, TRUE );
+ break;
- if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( get_gconfschemav1_button( window )))){
- NACT_ASSISTANT_EXPORT( window )->private->format = FORMAT_GCONFSCHEMAFILE_V1;
+ case IPREFS_EXPORT_FORMAT_GCONF_SCHEMA_V2:
+ button = GTK_TOGGLE_BUTTON( get_gconfschemav2_button( window ));
+ gtk_toggle_button_set_active( button, TRUE );
+ break;
- } else if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( get_gconfschemav2_button( window )))){
- NACT_ASSISTANT_EXPORT( window )->private->format = FORMAT_GCONFSCHEMAFILE_V2;
+ case IPREFS_EXPORT_FORMAT_ASK:
+ button = GTK_TOGGLE_BUTTON( get_ask_button( window ));
+ gtk_toggle_button_set_active( button, TRUE );
+ break;
- } else if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( get_gconfdump_button( window )))){
- NACT_ASSISTANT_EXPORT( window )->private->format = FORMAT_GCONFENTRY;
+ case IPREFS_EXPORT_FORMAT_GCONF_ENTRY:
+ default:
+ button = GTK_TOGGLE_BUTTON( get_gconfdump_button( window ));
+ gtk_toggle_button_set_active( button, TRUE );
+ break;
}
+
+ content = gtk_assistant_get_nth_page( assistant, ASSIST_PAGE_FORMAT_SELECTION );
+ gtk_assistant_set_page_complete( assistant, content, TRUE );
}
static GtkWidget *
@@ -704,6 +616,36 @@ get_gconfdump_button( NactAssistantExport *window )
return( base_window_get_widget( BASE_WINDOW( window ), "ExportGConfDumpButton" ));
}
+static GtkWidget *
+get_ask_button( NactAssistantExport *window )
+{
+ return( base_window_get_widget( BASE_WINDOW( window ), "ExportAskButton" ));
+}
+
+static gint
+get_export_format( NactAssistantExport *window )
+{
+ GtkToggleButton *gconf_schema_v1_button;
+ GtkToggleButton *gconf_schema_v2_button;
+ GtkToggleButton *ask_button;
+ gint format;
+
+ gconf_schema_v1_button = GTK_TOGGLE_BUTTON( get_gconfschemav1_button( window ));
+ gconf_schema_v2_button = GTK_TOGGLE_BUTTON( get_gconfschemav2_button( window ));
+ ask_button = GTK_TOGGLE_BUTTON( get_ask_button( window ));
+
+ format = IPREFS_EXPORT_FORMAT_GCONF_ENTRY;
+ if( gtk_toggle_button_get_active( gconf_schema_v1_button )){
+ format = IPREFS_EXPORT_FORMAT_GCONF_SCHEMA_V1;
+ } else if( gtk_toggle_button_get_active( gconf_schema_v2_button )){
+ format = IPREFS_EXPORT_FORMAT_GCONF_SCHEMA_V2;
+ } else if( gtk_toggle_button_get_active( ask_button )){
+ format = IPREFS_EXPORT_FORMAT_ASK;
+ }
+
+ return( format );
+}
+
static void
assist_initial_load_confirm( NactAssistantExport *window, GtkAssistant *assistant )
{
@@ -715,12 +657,50 @@ assist_runtime_init_confirm( NactAssistantExport *window, GtkAssistant *assistan
}
static void
+assist_initial_load_exportdone( NactAssistantExport *window, GtkAssistant *assistant )
+{
+}
+
+static void
+assist_runtime_init_exportdone( NactAssistantExport *window, GtkAssistant *assistant )
+{
+}
+
+static void
+assistant_prepare( BaseAssistant *window, GtkAssistant *assistant, GtkWidget *page )
+{
+ /*static const gchar *thisfn = "nact_assistant_export_on_prepare";
+ g_debug( "%s: window=%p, assistant=%p, page=%p", thisfn, window, assistant, page );*/
+
+ GtkAssistantPageType type = gtk_assistant_get_page_type( assistant, page );
+
+ switch( type ){
+ case GTK_ASSISTANT_PAGE_CONFIRM:
+ assist_prepare_confirm( NACT_ASSISTANT_EXPORT( window ), assistant, page );
+ break;
+
+ case GTK_ASSISTANT_PAGE_SUMMARY:
+ assist_prepare_exportdone( NACT_ASSISTANT_EXPORT( window ), assistant, page );
+ break;
+
+ default:
+ break;
+ }
+}
+
+static void
assist_prepare_confirm( NactAssistantExport *window, GtkAssistant *assistant, GtkWidget *page )
{
static const gchar *thisfn = "nact_assistant_export_prepare_confirm";
gchar *text, *tmp, *text2;
gchar *label1, *label2;
GList *actions, *ia;
+ NactApplication *application;
+ NAPivot *pivot;
+ gint format;
+
+ application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
+ pivot = nact_application_get_pivot( application );
g_debug( "%s: window=%p, assistant=%p, page=%p",
thisfn, ( void * ) window, ( void * ) assistant, ( void * ) page );
@@ -756,25 +736,34 @@ assist_prepare_confirm( NactAssistantExport *window, GtkAssistant *assistant, Gt
label1 = NULL;
label2 = NULL;
- switch( window->private->format ){
- case FORMAT_GCONFSCHEMAFILE_V1:
+ format = get_export_format( window );
+ switch( format ){
+ case IPREFS_EXPORT_FORMAT_GCONF_SCHEMA_V1:
label1 = g_strdup( gtk_button_get_label( GTK_BUTTON( get_gconfschemav1_button( window ))));
label2 = g_strdup( gtk_label_get_text( GTK_LABEL( base_window_get_widget( BASE_WINDOW( window ), "ExportSchemaV1Label"))));
break;
- case FORMAT_GCONFSCHEMAFILE_V2:
+ case IPREFS_EXPORT_FORMAT_GCONF_SCHEMA_V2:
label1 = g_strdup( gtk_button_get_label( GTK_BUTTON( get_gconfschemav2_button( window ))));
label2 = g_strdup( gtk_label_get_text( GTK_LABEL( base_window_get_widget( BASE_WINDOW( window ), "ExportSchemaV2Label"))));
break;
- case FORMAT_GCONFENTRY:
+ case IPREFS_EXPORT_FORMAT_GCONF_ENTRY:
label1 = g_strdup( gtk_button_get_label( GTK_BUTTON( get_gconfdump_button( window ))));
label2 = g_strdup( gtk_label_get_text( GTK_LABEL( base_window_get_widget( BASE_WINDOW( window ), "ExportGConfDumpLabel"))));
break;
+ case IPREFS_EXPORT_FORMAT_ASK:
+ label1 = g_strdup( gtk_button_get_label( GTK_BUTTON( get_ask_button( window ))));
+ label2 = g_strdup( gtk_label_get_text( GTK_LABEL( base_window_get_widget( BASE_WINDOW( window ), "ExportAskLabel"))));
+ break;
+
default:
+ g_return_if_reached();
break;
}
+ na_iprefs_set_export_format( NA_IPREFS( pivot ), IPREFS_EXPORT_FORMAT, format );
+ window->private->format = format;
tmp = g_strdup_printf( "%s\n\n<b>%s</b>\n\n%s", text, label1, label2 );
g_free( label2 );
@@ -788,14 +777,62 @@ assist_prepare_confirm( NactAssistantExport *window, GtkAssistant *assistant, Gt
gtk_assistant_set_page_complete( assistant, page, TRUE );
}
+/*
+ * As of 1.11, nact_gconf_writer doesn't return any error message.
+ * An error is simply indicated by returning a null filename.
+ * So we provide a general error message.
+ */
static void
-assist_initial_load_exportdone( NactAssistantExport *window, GtkAssistant *assistant )
+assistant_apply( BaseAssistant *wnd, GtkAssistant *assistant )
{
-}
+ static const gchar *thisfn = "nact_assistant_export_on_apply";
+ NactAssistantExport *window;
+ GList *actions, *ia;
+ gchar *msg = NULL;
+ gchar *reason = NULL;
+ gchar *tmp, *fname;
+ NAObjectAction *action;
-static void
-assist_runtime_init_exportdone( NactAssistantExport *window, GtkAssistant *assistant )
-{
+ g_debug( "%s: window=%p, assistant=%p", thisfn, ( void * ) wnd, ( void * ) assistant );
+ g_assert( NACT_IS_ASSISTANT_EXPORT( wnd ));
+ window = NACT_ASSISTANT_EXPORT( wnd );
+
+ actions = nact_iactions_list_get_selected_items( NACT_IACTIONS_LIST( window ));
+
+ g_assert( window->private->uri && strlen( window->private->uri ));
+
+ for( ia = actions ; ia ; ia = ia->next ){
+ action = NA_OBJECT_ACTION( ia->data );
+ fname = na_xml_writer_export( action, window->private->uri, window->private->format, &msg );
+
+ if( fname && strlen( fname )){
+ window->private->fnames = g_slist_prepend( window->private->fnames, fname );
+ g_debug( "%s: fname=%s", thisfn, fname );
+
+ } else {
+ window->private->errors += 1;
+ if( msg ){
+ if( reason ){
+ tmp = g_strdup_printf( "%s\n", reason );
+ g_free( reason );
+ reason = tmp;
+ }
+ tmp = g_strdup_printf( "%s%s", reason, msg );
+ g_free( reason );
+ reason = tmp;
+ g_free( msg );
+ }
+ }
+ }
+
+ na_object_free_items_list( actions );
+
+ if( window->private->errors ){
+ if( !reason ){
+ reason = g_strdup( _( "You may not have writing permissions on selected folder." ));
+ }
+ window->private->reason = reason;
+ }
}
static void
diff --git a/src/nact/nact-assistant-export.ui b/src/nact/nact-assistant-export.ui
index d69d92d..e77cad7 100644
--- a/src/nact/nact-assistant-export.ui
+++ b/src/nact/nact-assistant-export.ui
@@ -87,8 +87,8 @@ to extend a selection.</property>
<object class="GtkFileChooserWidget" id="ExportFolderChooser">
<property name="visible">True</property>
<property name="preview_widget_active">False</property>
- <property name="use_preview_label">False</property>
<property name="action">select-folder</property>
+ <property name="use_preview_label">False</property>
<property name="local_only">False</property>
</object>
<packing>
@@ -125,23 +125,10 @@ to extend a selection.</property>
<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="xpad">16</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,
@@ -149,7 +136,7 @@ The exported file may later be imported via :
</object>
<packing>
<property name="padding">4</property>
- <property name="position">1</property>
+ <property name="position">0</property>
</packing>
</child>
</object>
@@ -185,30 +172,17 @@ The exported file may later be imported via :
<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="xpad">16</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>
+ <property name="position">0</property>
</packing>
</child>
</object>
@@ -244,23 +218,10 @@ The exported file may later be imported via :
<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="xpad">16</property>
<property name="label" translatable="yes">This should be the preferred format for newly exported actions.
The exported file may later be imported via :
- Import assistant of the Nautilus Actions Configuration Tool,
@@ -268,7 +229,7 @@ The exported file may later be imported via :
</object>
<packing>
<property name="padding">4</property>
- <property name="position">1</property>
+ <property name="position">0</property>
</packing>
</child>
</object>
diff --git a/src/nact/nact-assistant-import.c b/src/nact/nact-assistant-import.c
index 04b03c8..28800f7 100644
--- a/src/nact/nact-assistant-import.c
+++ b/src/nact/nact-assistant-import.c
@@ -570,14 +570,12 @@ get_import_mode( NactAssistantImport *window )
override_button = GTK_TOGGLE_BUTTON( base_window_get_widget( BASE_WINDOW( window ), "OverrideButton" ));
ask_button = GTK_TOGGLE_BUTTON( base_window_get_widget( BASE_WINDOW( window ), "AskButton" ));
- if( gtk_toggle_button_get_active( no_import_button )){
- mode = IPREFS_IMPORT_NO_IMPORT;
- } else if( gtk_toggle_button_get_active( renumber_button )){
+ mode = IPREFS_IMPORT_NO_IMPORT;
+ if( gtk_toggle_button_get_active( renumber_button )){
mode = IPREFS_IMPORT_RENUMBER;
} else if( gtk_toggle_button_get_active( override_button )){
mode = IPREFS_IMPORT_OVERRIDE;
- } else {
- g_return_val_if_fail( gtk_toggle_button_get_active( ask_button ), 0 );
+ } else if( gtk_toggle_button_get_active( ask_button )){
mode = IPREFS_IMPORT_ASK;
}
diff --git a/src/nact/nact-clipboard.c b/src/nact/nact-clipboard.c
index 9df9541..9efdf96 100644
--- a/src/nact/nact-clipboard.c
+++ b/src/nact/nact-clipboard.c
@@ -35,6 +35,7 @@
#include <gtk/gtk.h>
#include <string.h>
+#include <common/na-iprefs.h>
#include <common/na-object-api.h>
#include <common/na-xml-names.h>
#include <common/na-xml-writer.h>
@@ -501,7 +502,7 @@ get_action_xml_buffer( const NAObject *object, GList **exported, NAObjectAction
if( *action ){
index = g_list_index( *exported, ( gconstpointer ) *action );
if( index == -1 ){
- buffer = na_xml_writer_get_xml_buffer( *action, FORMAT_GCONFENTRY );
+ buffer = na_xml_writer_get_xml_buffer( *action, IPREFS_EXPORT_FORMAT_GCONF_ENTRY );
*exported = g_list_prepend( *exported, ( gpointer ) *action );
}
}
@@ -545,7 +546,7 @@ export_rows( NactClipboard *clipboard, NactClipboardDndData *data )
buffer = get_action_xml_buffer( object, &exported, &action );
if( buffer ){
- fname = na_xml_writer_get_output_fname( NA_OBJECT_ACTION( action ), data->folder, FORMAT_GCONFENTRY );
+ fname = na_xml_writer_get_output_fname( NA_OBJECT_ACTION( action ), data->folder, IPREFS_EXPORT_FORMAT_GCONF_ENTRY );
na_xml_writer_output_xml( buffer, fname );
g_free( fname );
g_free( buffer );
diff --git a/src/utils/nautilus-actions-new.c b/src/utils/nautilus-actions-new.c
index ccb47a5..58d6121 100644
--- a/src/utils/nautilus-actions-new.c
+++ b/src/utils/nautilus-actions-new.c
@@ -39,6 +39,7 @@
#include <runtime/na-gconf-provider.h>
#include <runtime/na-iio-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>
@@ -136,7 +137,7 @@ main( int argc, char** argv )
}
} else {
- gchar *output_fname = na_xml_writer_export( action, output_dir, FORMAT_GCONFENTRY, &msg );
+ gchar *output_fname = na_xml_writer_export( action, output_dir, IPREFS_EXPORT_FORMAT_GCONF_ENTRY, &msg );
if( output_fname ){
/* i18n: Action <action_label> written to <output_filename>...*/
g_print( _( "Action '%s' succesfully written to %s, and ready to be imported in NACT.\n" ), label, output_fname );
diff --git a/src/utils/nautilus-actions-schemas.c b/src/utils/nautilus-actions-schemas.c
index 6ab904d..5066ddf 100644
--- a/src/utils/nautilus-actions-schemas.c
+++ b/src/utils/nautilus-actions-schemas.c
@@ -38,6 +38,7 @@
#include <glib/gi18n.h>
#include <stdlib.h>
+#include <common/na-iprefs.h>
#include <common/na-xml-names.h>
#include <common/na-xml-writer.h>
@@ -96,7 +97,7 @@ main( int argc, char** argv )
}
} else {*/
- na_xml_writer_export( NULL, NULL, FORMAT_GCONFSCHEMA, &msg );
+ na_xml_writer_export( NULL, NULL, IPREFS_EXPORT_FORMAT_GCONF_SCHEMA, &msg );
/*if( !msg ){
g_print( _( "Nautilus Actions schema succesfully written to %s.\n" ), output_fname );
g_free( output_fname );
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]