diff --git a/gnucash/gschemas/org.gnucash.GnuCash.deprecated.gschema.xml.in b/gnucash/gschemas/org.gnucash.GnuCash.deprecated.gschema.xml.in
index 7e626fd750..19bbcb794b 100644
--- a/gnucash/gschemas/org.gnucash.GnuCash.deprecated.gschema.xml.in
+++ b/gnucash/gschemas/org.gnucash.GnuCash.deprecated.gschema.xml.in
@@ -5,6 +5,12 @@
+
+ false
+ -Obsolete-
+ This setting is obsolete and will be removed in the next major @PROJECT_NAME@ release series.
+
+
0
The version of these settings
@@ -419,6 +425,26 @@ For example setting this to 2.0 will display reports at twice their typical size
+
+
+ (-1,-1,-1,-1)
+ Last window position and size
+ This setting describes the size and position of the window when it was last closed.
+ The numbers are the X and Y coordinates of the top left corner of the window
+ followed by the width and height of the window.
+
+
+
+
+
+ (-1,-1,-1,-1)
+ Last window position and size
+ This setting describes the size and position of the window when it was last closed.
+ The numbers are the X and Y coordinates of the top left corner of the window
+ followed by the width and height of the window.
+
+
+
(-1,-1,-1,-1)
diff --git a/gnucash/gschemas/org.gnucash.GnuCash.gschema.xml.in b/gnucash/gschemas/org.gnucash.GnuCash.gschema.xml.in
index 385ece7193..c772b7c78d 100644
--- a/gnucash/gschemas/org.gnucash.GnuCash.gschema.xml.in
+++ b/gnucash/gschemas/org.gnucash.GnuCash.gschema.xml.in
@@ -230,6 +230,7 @@
Set book option on new files to use split "action" field for "Num" field on registers/reports
If selected, the default book option for new files is set so that the 'Num' cell on registers shows/updates the split 'action' field and the transaction 'num' field is shown on the second line in double line mode (and is not visible in single line mode). Otherwise, the default book option for new files is set so that the 'Num' cell on registers shows/updates the transaction 'num' field.
+
diff --git a/gnucash/gschemas/pref_transformations.xml b/gnucash/gschemas/pref_transformations.xml
index cd1dcbbe86..66f4a0191a 100644
--- a/gnucash/gschemas/pref_transformations.xml
+++ b/gnucash/gschemas/pref_transformations.xml
@@ -29,12 +29,42 @@
Within a release node the following rules are currently supported:
+ : does nothing other than informing GnuCash devs this
+ preference will eventually be removed with no
+ replacement. The preference should not be used anymore
+ in GnuCash code directly.
+ It takes two arguments (old-path and old-key) that
+ together define the preference
+ : informs GnuCash a preference has moved or has been
+ renamed. The old preference should be treated as
+ deprecated and should not be used anymore in GnuCash
+ code directly.
+ It takes four arguments (old-path, old-key and
+ new-path, new-key). The first two define the deprecated
+ preference the last two the replacement preference.
+ : informs GnuCash this preference is ready to be removed
+ in the next major release and will be unset in this
+ major release series. This intermediary step is to
+ clean up the settings database over time.
+ It takes two arguments (old-path and old-key) that
+ together define the preference
+ Example
+ =======
+
+
+
+
+
- This will migrate the preference at old-path:old-key to new-path:new-key.
+
+
+
Note
@@ -1342,3 +1372,16 @@
new-key="end-period"/>
+
+
+
+
+
+
+
+
+
+
diff --git a/libgnucash/app-utils/gnc-gsettings.cpp b/libgnucash/app-utils/gnc-gsettings.cpp
index 35fdf56460..17b25114be 100644
--- a/libgnucash/app-utils/gnc-gsettings.cpp
+++ b/libgnucash/app-utils/gnc-gsettings.cpp
@@ -655,15 +655,51 @@ gnc_gsettings_get_user_value (const gchar *schema,
}
}
+using opt_str_vec = boost::optional;
+
+static void
+deprecate_one_key (const opt_str_vec &oldpath, const opt_str_vec &oldkey)
+{
+ if (!oldpath || !oldkey )
+ {
+ DEBUG ("Skipping node - missing attribute (old-path or old-key)");
+ return;
+ }
+
+ PINFO ("'%s:%s' has been marked deprecated", oldpath->c_str(), oldkey->c_str());
+ /* This does nothing really, but is a reminder for future maintainers
+ * to mark this pref as obsolete in the next major release. */
+}
+
static void
-migrate_one_key (const std::string &oldpath, const std::string &oldkey,
- const std::string &newpath, const std::string &newkey)
+migrate_one_key (const opt_str_vec &oldpath, const opt_str_vec &oldkey,
+ const opt_str_vec &newpath, const opt_str_vec &newkey)
{
- PINFO ("Migrating '%s:%s' to '%s:%s'", oldpath.c_str(), oldkey.c_str(),
- newpath.c_str(), newkey.c_str());
- auto user_value = gnc_gsettings_get_user_value (oldpath.data(), oldkey.data());
+ if (!oldpath || !oldkey || !newpath || !newkey)
+ {
+ DEBUG ("Skipping node - missing attribute (old-path, old-key, new-path or new-key)");
+ return;
+ }
+
+ PINFO ("Migrating '%s:%s' to '%s:%s'", oldpath->c_str(), oldkey->c_str(),
+ newpath->c_str(), newkey->c_str());
+
+ auto user_value = gnc_gsettings_get_user_value (oldpath->c_str(), oldkey->c_str());
if (user_value)
- gnc_gsettings_set_value (newpath.data(), newkey.data(), user_value);
+ gnc_gsettings_set_value (newpath->c_str(), newkey->c_str(), user_value);
+}
+
+static void
+obsolete_one_key (const opt_str_vec &oldpath, const opt_str_vec &oldkey)
+{
+ if (!oldpath || !oldkey )
+ {
+ DEBUG ("Skipping node - missing attribute (old-path or old-key)");
+ return;
+ }
+
+ PINFO ("Resetting obsolete '%s:%s'", oldpath->c_str(), oldkey->c_str());
+ gnc_gsettings_reset (oldpath->c_str(), oldkey->c_str());
}
static void
@@ -675,19 +711,17 @@ parse_one_release_node (bpt::ptree &pt)
{
if (node.first == "")
return;
- if (node.first == "migrate")
- {
- auto oldpath = node.second.get_optional (".old-path");
- auto oldkey = node.second.get_optional (".old-key");
- auto newpath = node.second.get_optional (".new-path");
- auto newkey = node.second.get_optional (".new-key");
- if (!oldpath || !oldkey || !newpath || !newkey)
- {
- DEBUG ("Skipping migration node - missing attribute (old-path, old-key, new-path or new-key)");
- return;
- }
- migrate_one_key (*oldpath, *oldkey, *newpath, *newkey);
- }
+ else if (node.first == "deprecate")
+ deprecate_one_key (node.second.get_optional (".old-path"),
+ node.second.get_optional (".old-key"));
+ else if (node.first == "migrate")
+ migrate_one_key (node.second.get_optional (".old-path"),
+ node.second.get_optional (".old-key"),
+ node.second.get_optional (".new-path"),
+ node.second.get_optional (".new-key"));
+ else if (node.first == "obsolete")
+ obsolete_one_key (node.second.get_optional (".old-path"),
+ node.second.get_optional (".old-key"));
else
{
DEBUG ("Skipping unknown node <%s>", node.first.c_str());