[nautilus-actions] Use the same gconf2desktop.sh script to migrate preferences
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Use the same gconf2desktop.sh script to migrate preferences
- Date: Wed, 19 Jan 2011 21:48:31 +0000 (UTC)
commit 2ef6f1ce6d6c816485a50a318e4068c04cc2aa84
Author: Pierre Wieser <pwieser trychlos org>
Date: Thu Jan 6 20:53:01 2011 +0100
Use the same gconf2desktop.sh script to migrate preferences
ChangeLog | 8 +
README-GCONF | 53 +++++-
src/utils/nautilus-actions-gconf2desktop.sh.in | 260 +++++++++++++++++++++++-
3 files changed, 311 insertions(+), 10 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 6d88d3b..ca2a094 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -101,6 +101,14 @@
* src/nact/nautilus-actions-config-tool.ui:
Apply patch provided by Christian Kirbach. Fix #638548.
+ Use the same script to migrate items and preferences.
+
+ * README-GCONF: Document migrated and renamed preferences.
+
+ * src/utils/nautilus-actions-gconf2desktop.sh.in:
+ Rewrite migrated preferences as keyed files.
+ At last, remove the whole Nautilus-Actions tree from GConf.
+
2011-01-05 Pierre Wieser <pwieser trychlos org>
* src/utils/console-utils.c (console_cmdline_get_description):
diff --git a/README-GCONF b/README-GCONF
index 68fba13..4bb5947 100644
--- a/README-GCONF
+++ b/README-GCONF
@@ -54,6 +54,57 @@ Deprecating GConf
2. User preferences stored in GConf
-----------------------------------
- User preferences are automatically migrated from GConf to the target system.
+ Mandatory and user preferences are automatically migrated from GConf to the
+ target system.
+
+ They are renamed and reorganized:
+
+ GConf Group Key
+ ----------------------------------------- ------ --------------------------------------
+ add-capability-dialog = [720,263,384,246] [nact] capability-add-capability-dialog-size
+ add-scheme-dialog = [720,263,352,271] [nact] scheme-add-scheme-dialog-size
+ assistant-esc-confirm = true [nact] assistant-esc-confirm
+ assistant-esc-quit = true [nact] assistant-esc-quit
+ auto-save-on = false [nact] main-save-auto
+ auto-save-period = 5 [nact] main-save-period
+ export-assistant = [377,33,699,675] [nact] assistant-dialog-size
+ export-folder-uri = file:///home/pierre.. [nact] export-last-folder-uri
+ export-format = Ask [nact] export-preferred-format
+ icommand-command-chooser [nact] command-command-chooser-dialog-size
+ icommand-folder-uri [nact] command-command-last-folder-uri
+ icommand-legend-dialog = [673,94,474,480] [nact] command-legend-dialog-size
+ icommand-working-dir-dialog [nact] command-working-dir-chooser-dialog-size
+ icommand-working-dir-uri = file:///home.. [nact] command-working-dir-chooser-last-folder-uri
+ icons-chooser = [425,124,839,539] [nact] item-icon-chooser-dialog-size
+ icons-path = file:///usr/share/icons/hi.. [nact] item-icon-browse-last-path
+ ienvironment-show-if-running-dialog = [.. [nact] environment-show-if-running-dialog-size
+ ienvironment-show-if-running-uri = file.. [nact] environment-show-if-running-last-folder-uri
+ ienvironment-try-exec-dialog = [327,70,.. [nact] environment-try-exec-dialog-size
+ ienvironment-try-exec-uri = file:///bin [nact] environment-show-if-running-last-folder-uri
+ ifolders-chooser = [418,86,632,573] [nact] folder-chooser-dialog-size
+ ifolders-path = /home/pierre/data/Pictures [nact] folder-last-path
+ import-ask-user [nact] import-ask-user-dialog-size
+ import-ask-user-last-mode [nact] import-ask-user-last-mode
+ import-assistant [nact] import-assistant-dialog-size
+ import-folder-uri [nact] import-last-folder-uri
+ import-keep-choice [nact] import-mode-keep-last-choice
+ import-mode = NoImport [nact] import-preferred-mode
+ io-providers-order = [..] [runtime] io-providers-order
+ iprefs-add-about-item = true [runtime] items-add-about-item
+ iprefs-alphabetical-order = ManualOrder [runtime] items-list-order
+ iprefs-create-root-menu = false [runtime] items-create-root-menu
+ iprefs-level-zero = [my-first-na-menu,a1-mandatory2-action3,a-gconf-action]
+ [runtime] items-level-zero-order
+ iprefs-relabel-actions = false [nact] relabel-when-duplicate-action
+ iprefs-relabel-menus = false [nact] relabel-when-duplicate-menu
+ iprefs-relabel-profiles = false [nact] relabel-when-duplicate-profile
+ main-edit-toolbar = true [nact] main-toolbar-edit-display
+ main-file-toolbar = true [nact] main-toolbar-file-display
+ main-help-toolbar = true [nact] main-toolbar-help-display
+ main-paned = 211 [nact] main-pane-width
+ main-window = [319,95,901,533] [nact] main-window-size
+ preferences-editor = [548,218,497,392] [nact] preferences-dialog-size
+ schemes = [dav|WebDAV files,file|Local files,ftp|FTP files,sftp|SSH files,smb|Windows files]
+ [nact] scheme-default-list
P. Wieser - Jan. 2011
diff --git a/src/utils/nautilus-actions-gconf2desktop.sh.in b/src/utils/nautilus-actions-gconf2desktop.sh.in
index fa68a3f..70f4094 100644
--- a/src/utils/nautilus-actions-gconf2desktop.sh.in
+++ b/src/utils/nautilus-actions-gconf2desktop.sh.in
@@ -93,10 +93,13 @@ function msg_help
{
msg_version
echo "
- This program is meant to safely migrate menus and actions from GConf to
- .desktop files.
- Users menus and actions are automatically migrated when Nautilus-Actions
- menu plugin is loaded by Nautilus file-manager.
+ This program is meant to safely migrate items, menus and actions, and
+ preferences from GConf to .desktop files.
+ Users items and preferences are automatically migrated when Nautilus-Actions
+ menu plugin is loaded by Nautilus file-manager, or when one of the utilities
+ is run by the user.
+ A system administrator should nonetheless run himself this script in order
+ to migrate mandatory items and preferences he may have previsouly set.
Usage: ${my_cmd} [options]
--[no]help print this message, and exit [${opt_help_def}]
@@ -203,7 +206,10 @@ opt_delete=
opt_delete_def="no"
# path of the branch which contains the configurations
-na_configurations="/apps/nautilus-actions/configurations"
+na_package="/apps/@PACKAGE@"
+na_configurations="${na_package}/configurations"
+na_preferences="${na_package}/preferences"
+na_providers="${na_package}/providers"
# loop over command line arguments
pos=0
@@ -361,6 +367,26 @@ if [ ${errs} -gt 0 ]; then
exit
fi
+function add_pref
+{
+ typeset _group="${1}"
+ typeset _key="${2}"
+ typeset _type="${3}"
+ typeset _value="${4}"
+
+ typeset _newvalue="${4}"
+ if [ "${_type}" = "list" ]; then
+ _newvalue="$(echo "${_value}" | sed -e 's/^\[//' -e 's/]$//' -e 's/,/;/g');"
+ fi
+ echo "${_key} = ${_newvalue}" >> ${my_tmproot}.${_group}
+}
+
+function create_first_level
+{
+ typeset _newvalue="$(echo "$1" | sed -e 's/^\[//' -e 's/]$//' -e 's/,/;/g');"
+ echo "ItemsList = ${_newvalue}" >> ${my_tmproot}.zero
+}
+
# ---------------------------------------------------------------------
# MAIN CODE
@@ -373,6 +399,8 @@ command "mkdir -p ${opt_dir} || exit 1"
let count=0
# list objects in configurations/ subdir
+# each object, action or menu, is then exported in .a .desktop format
+# to be written to its .desktop file
for dir in $(gconftool-2 --all-dirs ${na_configurations}); do
id=$(basename ${dir})
let count+=1
@@ -389,21 +417,235 @@ for dir in $(gconftool-2 --all-dirs ${na_configurations}); do
fi
done
+# we are using this same script to migrate preferences to .conf files
+# mandatory preferences go to SYSCONFDIR/nautilus-actions.conf
+# while user preferences go to HOME/.config/nautilus-actions.conf
+# Note also that the GConf I/O provider is disabled both for reading
+# and writing
+[ $(id -u) -eq 0 ] && destdir= SYSCONFDIR@ || destdir=${HOME}/.config
+command "mkdir -p ${destdir}"
+destconf=${destdir}/@PACKAGE conf
+rm -f ${my_tmproot}.nact
+rm -f ${my_tmproot}.runtime
+rm -f ${my_tmproot}.zero
+nbprefs=0
+have_level_zero=0
+
+gconftool-2 --all-entries ${na_preferences} | while read key x value; do
+ case ${key} in
+ add-capability-dialog)
+ let nbprefs+=1
+ add_pref "nact" "capability-add-capability-dialog-size" list "${value}"
+ ;;
+ add-scheme-dialog)
+ let nbprefs+=1
+ add_pref "nact" "scheme-add-scheme-dialog-size" list "${value}"
+ ;;
+ assistant-esc-confirm)
+ let nbprefs+=1
+ add_pref "nact" "${key}" str "${value}"
+ ;;
+ assistant-esc-quit)
+ let nbprefs+=1
+ add_pref "nact" "${key}" str "${value}"
+ ;;
+ auto-save-on)
+ let nbprefs+=1
+ add_pref "nact" "main-save-auto" str "${value}"
+ ;;
+ auto-save-period)
+ let nbprefs+=1
+ add_pref "nact" "main-save-period" str "${value}"
+ ;;
+ export-assistant)
+ let nbprefs+=1
+ add_pref "nact" "assistant-dialog-size" list "${value}"
+ ;;
+ export-folder-uri)
+ let nbprefs+=1
+ add_pref "nact" "export-last-folder-uri" str "${value}"
+ ;;
+ export-format)
+ let nbprefs+=1
+ add_pref "nact" "export-preferred-format" str "${value}"
+ ;;
+ icommand-command-chooser)
+ let nbprefs+=1
+ add_pref "nact" "command-command-chooser-dialog-size" list "${value}"
+ ;;
+ icommand-folder-uri)
+ let nbprefs+=1
+ add_pref "nact" "command-command-chooser-last-folder-uri" list "${value}"
+ ;;
+ icommand-legend-dialog)
+ let nbprefs+=1
+ add_pref "nact" "command-legend-dialog-size" list "${value}"
+ ;;
+ icommand-working-dir-dialog)
+ let nbprefs+=1
+ add_pref "nact" "command-working-dir-chooser-dialog-size" list "${value}"
+ ;;
+ icommand-working-dir-uri)
+ let nbprefs+=1
+ add_pref "nact" "command-working-dir-chooser-last-folder-uri" str "${value}"
+ ;;
+ icons-chooser)
+ let nbprefs+=1
+ add_pref "nact" "item-icon-chooser-dialog-size" list "${value}"
+ ;;
+ icons-path)
+ let nbprefs+=1
+ add_pref "nact" "item-icon-browse-last-path" str "${value}"
+ ;;
+ ienvironment-show-if-running-dialog)
+ let nbprefs+=1
+ add_pref "nact" "environment-show-if-running-dialog-size" list "${value}"
+ ;;
+ ienvironment-show-if-running-uri)
+ let nbprefs+=1
+ add_pref "nact" "environment-show-if-running-last-folder-uri" str "${value}"
+ ;;
+ ienvironment-try-exec-dialog)
+ let nbprefs+=1
+ add_pref "nact" "environment-try-exec-dialog-size" list "${value}"
+ ;;
+ ienvironment-try-exec-uri)
+ let nbprefs+=1
+ add_pref "nact" "environment-show-if-running-last-folder-uri" str "${value}"
+ ;;
+ ifolders-chooser)
+ let nbprefs+=1
+ add_pref "nact" "folder-chooser-dialog-size" list "${value}"
+ ;;
+ ifolders-path)
+ let nbprefs+=1
+ add_pref "nact" "folder-last-path" str "${value}"
+ ;;
+ import-ask-user)
+ let nbprefs+=1
+ add_pref "nact" "import-ask-user-dialog-size" list "${value}"
+ ;;
+ import-ask-user-last-mode)
+ let nbprefs+=1
+ add_pref "nact" "${key}" str "${value}"
+ ;;
+ import-assistant)
+ let nbprefs+=1
+ add_pref "nact" "import-assistant-dialog-size" list "${value}"
+ ;;
+ import-folder-uri)
+ let nbprefs+=1
+ add_pref "nact" "import-last-folder-uri" str "${value}"
+ ;;
+ import-keep-choice)
+ let nbprefs+=1
+ add_pref "nact" "import-mode-keep-last-choice" list "${value}"
+ ;;
+ import-mode)
+ let nbprefs+=1
+ add_pref "nact" "import-preferred-mode" str "${value}"
+ ;;
+ io-providers-order)
+ let nbprefs+=1
+ add_pref "runtime" "io-providers-order" list "${value}"
+ ;;
+ iprefs-add-about-item)
+ let nbprefs+=1
+ add_pref "runtime" "items-add-about-item" str "${value}"
+ ;;
+ iprefs-alphabetical-order)
+ let nbprefs+=1
+ add_pref "runtime" "items-list-order" str "${value}"
+ ;;
+ iprefs-create-root-menu)
+ let nbprefs+=1
+ add_pref "runtime" "items-create-root-menu" str "${value}"
+ ;;
+ iprefs-level-zero)
+ # for now, keep the level zero order as a runtime preference
+ #let have_level_zero+=1
+ #create_first_level "${value}"
+ let nbprefs+=1
+ add_pref "runtime" "items-level-zero-order" list "${value}"
+ ;;
+ iprefs-relabel-actions)
+ let nbprefs+=1
+ add_pref "nact" "relabel-when-duplicate-action" str "${value}"
+ ;;
+ iprefs-relabel-menus)
+ let nbprefs+=1
+ add_pref "nact" "relabel-when-duplicate-menu" str "${value}"
+ ;;
+ iprefs-relabel-profiles)
+ let nbprefs+=1
+ add_pref "nact" "relabel-when-duplicate-profile" str "${value}"
+ ;;
+ main-edit-toolbar)
+ let nbprefs+=1
+ add_pref "nact" "main-toolbar-edit-display" str "${value}"
+ ;;
+ main-file-toolbar)
+ let nbprefs+=1
+ add_pref "nact" "main-toolbar-file-display" str "${value}"
+ ;;
+ main-help-toolbar)
+ let nbprefs+=1
+ add_pref "nact" "main-toolbar-help-display" str "${value}"
+ ;;
+ main-tools-toolbar)
+ let nbprefs+=1
+ add_pref "nact" "main-toolbar-tools-display" str "${value}"
+ ;;
+ main-paned)
+ let nbprefs+=1
+ add_pref "nact" "main-pane-width" str "${value}"
+ ;;
+ main-window)
+ let nbprefs+=1
+ add_pref "nact" "main-window-size" list "${value}"
+ ;;
+ preferences-editor)
+ let nbprefs+=1
+ add_pref "nact" "preferences-dialog-size" list "${value}"
+ ;;
+ schemes)
+ let nbprefs+=1
+ add_pref "nact" "scheme-default-list" list "${value}"
+ ;;
+ esac
+done
+if [ ${nbprefs} -gt 0 ]; then
+ cat <<! >${destconf}
+[nact]
+$(cat ${my_tmproot}.nact)
+
+[runtime]
+$(cat ${my_tmproot}.runtime)
+!
+fi
+
+#if [ ${have_level_zero} -gt 0 ]; then
+# cat <<! >${opt_dir}/level-zero.directory
+#[Desktop Entry]
+#$(cat ${my_tmproot}.zero)
+#!
+#fi
+
# force sync
killall gconfd-2
-# at the end, we delete the branch
+# at the end, we delete all package branch from GConf
if [ "${opt_delete}" = "yes" -a ${count} -gt 0 ]; then
if [ $(id -u) -eq 0 ]; then
- # rather a bad hack to find where mandatory items are stored by GConf
+ # rather a bad hack to find where mandatory keys are stored by GConf
# nautilus-actions-delete directly removes our branch from the XML tree!
xml=$(find /etc -name gconf.xml.mandatory)/%gconf-tree.xml
- path='/gconf/dir[ name="apps"]/dir[ name="nautilus-actions"]/dir[ name="configurations"]'
+ path='/gconf/dir[ name="apps"]/dir[ name="@PACKAGE@"]'
command "$(dirname ${opt_print})/nautilus-actions-delete --path '${path}' --xml ${xml} > ${xml}2"
command "mv ${xml}2 ${xml}"
else
# this does not work for mandatory items
- command "gconftool-2 --recursive-unset ${na_configurations}"
+ command "gconftool-2 --recursive-unset ${na_package}"
fi
fi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]