[nautilus-actions] Take preference name as argument when updating GConf
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Take preference name as argument when updating GConf
- Date: Thu, 15 Oct 2009 20:49:31 +0000 (UTC)
commit 02341c64c075918b872337e72c5435af33efad87
Author: pierre <pierre vfedora10 virtuals pwi>
Date: Thu Oct 15 15:31:42 2009 +0200
Take preference name as argument when updating GConf
ChangeLog | 8 ++++++++
src/common/na-iprefs.c | 9 +++++----
src/common/na-iprefs.h | 5 +++--
src/nact/nact-assistant-import.c | 4 ++--
src/nact/nact-preferences-editor.c | 6 ++----
src/nact/nact-tree-model.c | 2 +-
src/nact/nact-xml-reader.c | 23 +++++++++++++++++------
src/nact/nact-xml-reader.h | 8 --------
8 files changed, 38 insertions(+), 27 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1b57afb..9157a3b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,8 @@
* src/nact/nact-assistant-import.c:
* src/nact/nact-preferences-editor.c:
Define IPREFS_IMPORT_ASK new import mode.
+ na_iprefs_get_import_mode, na_iprefs_set_import_mode now take
+ the preference name as an argument.
* src/nact/nact-main-window.c
(nact_main_window_action_exists): Renamed as
@@ -25,6 +27,12 @@
* src/nact/nact-assistant-import-ask.h:
New AssistantImportAsk dialog box.
+ * src/nact/nact-xml-reader.c (manager_import_mode):
+ Now may ask the user to know what to do.
+
+ * src/nact/nact-xml-reader.h:
+ No more redefine import modes here !
+
2009-10-14 Pierre Wieser <pwieser trychlos org>
* configure.ac:
diff --git a/src/common/na-iprefs.c b/src/common/na-iprefs.c
index b7b3e6e..a739044 100644
--- a/src/common/na-iprefs.c
+++ b/src/common/na-iprefs.c
@@ -88,6 +88,7 @@ na_iprefs_migrate_key( NAIPrefs *instance, const gchar *old_key, const gchar *ne
/**
* na_iprefs_get_import_mode:
* @instance: this #NAIPrefs interface instance.
+ * @name: name of the import key to be readen
*
* Returns: the import mode currently set.
*
@@ -98,7 +99,7 @@ na_iprefs_migrate_key( NAIPrefs *instance, const gchar *old_key, const gchar *ne
* those defined in schemas.
*/
gint
-na_iprefs_get_import_mode( NAIPrefs *instance )
+na_iprefs_get_import_mode( NAIPrefs *instance, const gchar *name )
{
gint import_mode = DEFAULT_IMPORT_MODE_INT;
gint import_int;
@@ -108,7 +109,7 @@ na_iprefs_get_import_mode( NAIPrefs *instance )
import_str = na_iprefs_read_string(
instance,
- IPREFS_IMPORT_ACTIONS_IMPORT_MODE,
+ name,
DEFAULT_IMPORT_MODE_STR );
if( gconf_string_to_enum( import_mode_table, import_str, &import_int )){
@@ -129,7 +130,7 @@ na_iprefs_get_import_mode( NAIPrefs *instance )
* preference system.
*/
void
-na_iprefs_set_import_mode( NAIPrefs *instance, gint mode )
+na_iprefs_set_import_mode( NAIPrefs *instance, const gchar *name, gint mode )
{
const gchar *import_str;
@@ -139,7 +140,7 @@ na_iprefs_set_import_mode( NAIPrefs *instance, gint mode )
na_iprefs_write_string(
instance,
- IPREFS_IMPORT_ACTIONS_IMPORT_MODE,
+ name,
import_str ? import_str : DEFAULT_IMPORT_MODE_STR );
}
diff --git a/src/common/na-iprefs.h b/src/common/na-iprefs.h
index 4ae7031..5a92fc2 100644
--- a/src/common/na-iprefs.h
+++ b/src/common/na-iprefs.h
@@ -48,6 +48,7 @@ G_BEGIN_DECLS
/* GConf Preference keys managed by IPrefs interface
*/
#define IPREFS_IMPORT_ACTIONS_IMPORT_MODE "import-mode"
+#define IPREFS_IMPORT_ASK_LAST_MODE "import-ask-user-last-mode"
/* import mode
*/
@@ -64,8 +65,8 @@ enum {
void na_iprefs_migrate_key( NAIPrefs *instance, const gchar *old_key, const gchar *new_key );
-gint na_iprefs_get_import_mode( NAIPrefs *instance );
-void na_iprefs_set_import_mode( NAIPrefs *instance, gint mode );
+gint na_iprefs_get_import_mode( NAIPrefs *instance, const gchar *pref );
+void na_iprefs_set_import_mode( NAIPrefs *instance, const gchar *pref, gint mode );
G_END_DECLS
diff --git a/src/nact/nact-assistant-import.c b/src/nact/nact-assistant-import.c
index b9ef08a..e4d34e0 100644
--- a/src/nact/nact-assistant-import.c
+++ b/src/nact/nact-assistant-import.c
@@ -463,7 +463,7 @@ runtime_init_duplicates( NactAssistantImport *window, GtkAssistant *assistant )
application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
pivot = nact_application_get_pivot( application );
- mode = na_iprefs_get_import_mode( NA_IPREFS( pivot ));
+ mode = na_iprefs_get_import_mode( NA_IPREFS( pivot ), IPREFS_IMPORT_ACTIONS_IMPORT_MODE );
set_import_mode( window, mode );
page = gtk_assistant_get_nth_page( assistant, ASSIST_PAGE_DUPLICATES );
@@ -759,7 +759,7 @@ prepare_importdone( NactAssistantImport *window, GtkAssistant *assistant, GtkWid
g_free( text );
mode = get_import_mode( window );
- na_iprefs_set_import_mode( NA_IPREFS( pivot ), mode );
+ na_iprefs_set_import_mode( NA_IPREFS( pivot ), IPREFS_IMPORT_ACTIONS_IMPORT_MODE, mode );
gtk_assistant_set_page_complete( assistant, page, TRUE );
base_assistant_set_warn_on_cancel( BASE_ASSISTANT( window ), FALSE );
diff --git a/src/nact/nact-preferences-editor.c b/src/nact/nact-preferences-editor.c
index 5a0dc9e..f427d84 100644
--- a/src/nact/nact-preferences-editor.c
+++ b/src/nact/nact-preferences-editor.c
@@ -322,7 +322,7 @@ on_base_runtime_init_dialog( NactPreferencesEditor *editor, gpointer user_data )
/* third tab: tools preferences
*/
- import_mode = na_iprefs_get_import_mode( NA_IPREFS( pivot ));
+ import_mode = na_iprefs_get_import_mode( NA_IPREFS( pivot ), IPREFS_IMPORT_ACTIONS_IMPORT_MODE );
switch( import_mode ){
case IPREFS_IMPORT_ASK:
button = base_window_get_widget( BASE_WINDOW( editor ), "PrefsAskButton" );
@@ -451,7 +451,7 @@ save_preferences( NactPreferencesEditor *editor )
}
}
}
- na_iprefs_set_import_mode( NA_IPREFS( pivot ), import_mode );
+ na_iprefs_set_import_mode( NA_IPREFS( pivot ), IPREFS_IMPORT_ACTIONS_IMPORT_MODE, import_mode );
}
static gboolean
@@ -464,8 +464,6 @@ base_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window )
g_assert( NACT_IS_PREFERENCES_EDITOR( window ));
editor = NACT_PREFERENCES_EDITOR( window );
- /*gboolean is_modified = is_edited_modified( editor );*/
-
switch( code ){
case GTK_RESPONSE_NONE:
case GTK_RESPONSE_DELETE_EVENT:
diff --git a/src/nact/nact-tree-model.c b/src/nact/nact-tree-model.c
index b1c4f24..17f51af 100644
--- a/src/nact/nact-tree-model.c
+++ b/src/nact/nact-tree-model.c
@@ -1708,7 +1708,7 @@ drop_uri_list( NactTreeModel *model, GtkTreePath *dest, GtkSelectionData *selec
}
uri_list = g_slist_reverse( na_utils_lines_to_string_list(( const gchar * ) selection_data->data ));
- import_mode = na_iprefs_get_import_mode( NA_IPREFS( pivot ));
+ import_mode = na_iprefs_get_import_mode( NA_IPREFS( pivot ), IPREFS_IMPORT_ACTIONS_IMPORT_MODE );
for( is = uri_list ; is ; is = is->next ){
diff --git a/src/nact/nact-xml-reader.c b/src/nact/nact-xml-reader.c
index 40acbd8..d7afcfc 100644
--- a/src/nact/nact-xml-reader.c
+++ b/src/nact/nact-xml-reader.c
@@ -41,12 +41,14 @@
#include <runtime/na-gconf-provider-keys.h>
#include <runtime/na-gconf-utils.h>
+#include <common/na-iprefs.h>
#include <common/na-object-api.h>
#include <common/na-utils.h>
#include <common/na-xml-names.h>
#include "nact-application.h"
#include "nact-main-window.h"
+#include "nact-assistant-import-ask.h"
#include "nact-xml-reader.h"
/* private class data
@@ -64,6 +66,7 @@ struct NactXMLReaderPrivate {
gboolean dispose_has_run;
BaseWindow *window;
gint import_mode;
+ const gchar *uri;
NAObjectAction *action; /* the action that we will return, or NULL */
GSList *messages;
gboolean uuid_set; /* set at first uuid, then checked against */
@@ -317,6 +320,7 @@ nact_xml_reader_import( BaseWindow *window, const gchar *uri, gint import_mode,
reader = gconf_reader_new();
reader->private->window = window;
reader->private->import_mode = import_mode;
+ reader->private->uri = uri;
g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
@@ -1282,35 +1286,42 @@ free_reader_values( NactXMLReader *reader )
static gboolean
manage_import_mode( NactXMLReader *reader )
{
- gboolean exists;
+ NAObjectItem *exists;
gchar *uuid;
BaseApplication *appli;
NactMainWindow *main_window;
gboolean ret;
+ gint mode;
appli = base_window_get_application( BASE_WINDOW( reader->private->window ));
main_window = NACT_MAIN_WINDOW( base_application_get_main_window( appli ));
uuid = na_object_get_id( reader->private->action );
- exists = nact_main_window_action_exists( main_window, uuid );
+ exists = nact_main_window_get_item( main_window, uuid );
g_free( uuid );
if( !exists ){
return( TRUE );
}
- switch( reader->private->import_mode ){
- case RENUMBER_MODE:
+ if( reader->private->import_mode == IPREFS_IMPORT_ASK ){
+ mode = nact_assistant_import_ask_user( main_window, reader->private->uri, reader->private->action, exists );
+ } else {
+ mode = reader->private->import_mode;
+ }
+
+ switch( mode ){
+ case IPREFS_IMPORT_RENUMBER:
na_object_set_new_id( reader->private->action, NULL );
reader->private->relabel = TRUE;
ret = TRUE;
break;
- case OVERRIDE_MODE:
+ case IPREFS_IMPORT_OVERRIDE:
ret = TRUE;
break;
- case NO_IMPORT_MODE:
+ case IPREFS_IMPORT_NO_IMPORT:
default:
ret = FALSE;
}
diff --git a/src/nact/nact-xml-reader.h b/src/nact/nact-xml-reader.h
index 740b176..a72537b 100644
--- a/src/nact/nact-xml-reader.h
+++ b/src/nact/nact-xml-reader.h
@@ -68,14 +68,6 @@ typedef struct {
}
NactXMLReaderClass;
-/* import mode of an existing uuid
- */
-enum {
- NO_IMPORT_MODE = 1,
- RENUMBER_MODE,
- OVERRIDE_MODE
-};
-
GType nact_xml_reader_get_type( void );
NAObjectAction *nact_xml_reader_import( BaseWindow *window, const gchar *uri, gint mode, GSList **msg );
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]