mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-16 18:25:11 -06:00
Add infrastructure to handle preference schema migrations and use it to replace one preference
The preference schema migration collects all schema mutations that can occur when upgrading to a newer gnucash version. The old gconf to gsettings conversion is integrated in this system as well. Newer schema mutations will happen based on version number upgrades though. The preference that got replaced is "use-theme-colors". Based on discussion in bug 746163 (https://bugzilla.gnome.org/show_bug.cgi?id=746163) and gnucash-docs PR#105 (https://github.com/Gnucash/gnucash-docs/pull/105) this has been replaced with "use-gnucash-color-theme" with inverted meaning. The old option is kept around for one or two major release cycles to allow seamless conversion.
This commit is contained in:
parent
9dc66c0b7d
commit
de4d1e9859
@ -486,7 +486,7 @@ gnc_tree_model_split_reg_new (SplitRegisterType2 reg_type, SplitRegisterStyle2 s
|
||||
|
||||
/* Setup some config entries */
|
||||
model->use_accounting_labels = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_ACCOUNTING_LABELS);
|
||||
model->use_theme_colors = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL_REGISTER, GNC_PREF_USE_THEME_COLORS);
|
||||
model->use_gnc_color_theme = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL_REGISTER, GNC_PREF_USE_GNUCASH_COLOR_THEME);
|
||||
model->alt_colors_by_txn = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL_REGISTER, GNC_PREF_ALT_COLOR_BY_TRANS);
|
||||
model->read_only = FALSE;
|
||||
|
||||
@ -1450,7 +1450,7 @@ gnc_tree_model_split_reg_get_row_color (GncTreeModelSplitReg *model, gboolean is
|
||||
|
||||
gchar *cell_color = NULL;
|
||||
|
||||
if (!model->use_theme_colors)
|
||||
if (model->use_gnc_color_theme)
|
||||
{
|
||||
if (model->use_double_line)
|
||||
{
|
||||
|
@ -152,7 +152,7 @@ typedef struct
|
||||
gboolean use_accounting_labels; /**< whether to use accounting Labels */
|
||||
gboolean separator_changed; /**< whether the separator has changed */
|
||||
gboolean alt_colors_by_txn; /**< whether to use alternative colors by transaction */
|
||||
gboolean use_theme_colors; /**< whether to use theme colors */
|
||||
gboolean use_gnc_color_theme; /**< whether to use the gnucash built-in color theme */
|
||||
|
||||
gboolean read_only; /**< register is read only */
|
||||
|
||||
|
@ -568,8 +568,8 @@ gnc_tree_view_split_reg_refresh_from_prefs (GncTreeViewSplitReg *view)
|
||||
|
||||
model = gnc_tree_view_split_reg_get_model_from_view (view);
|
||||
|
||||
model->use_theme_colors = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL_REGISTER,
|
||||
GNC_PREF_USE_THEME_COLORS);
|
||||
model->use_gnc_color_theme = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL_REGISTER,
|
||||
GNC_PREF_USE_GNUCASH_COLOR_THEME);
|
||||
model->use_accounting_labels = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL,
|
||||
GNC_PREF_ACCOUNTING_LABELS);
|
||||
|
||||
|
@ -2245,14 +2245,14 @@ many months before the current month:</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="pref/general.register/use-theme-colors">
|
||||
<property name="label" translatable="yes">Don't _use GnuCash built-in colors</property>
|
||||
<object class="GtkCheckButton" id="pref/general.register/use-gnucash-color-theme">
|
||||
<property name="label" translatable="yes">_Use GnuCash built-in color theme</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="has_tooltip">True</property>
|
||||
<property name="tooltip_markup">GnuCash uses a yellow/green theme by default for register windows. Check this if you want to use the system color theme instead.</property>
|
||||
<property name="tooltip_text" translatable="yes">GnuCash uses a yellow/green theme by default for register windows. Check this if you want to use the system color theme instead.</property>
|
||||
<property name="tooltip_markup">GnuCash uses a yellow/green theme by default for register windows. Uncheck this if you want to use the system color theme instead.</property>
|
||||
<property name="tooltip_text" translatable="yes">GnuCash uses a yellow/green theme by default for register windows. Uncheck this if you want to use the system color theme instead.</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="margin_left">12</property>
|
||||
<property name="use_underline">True</property>
|
||||
|
@ -5,6 +5,11 @@
|
||||
</schema>
|
||||
|
||||
<schema id="org.gnucash.general" path="/org/gnucash/general/">
|
||||
<key name="prefs-version" type="i">
|
||||
<default>0</default>
|
||||
<summary>The version of these settings</summary>
|
||||
<description>This is used internally to determine whether some preferences may need conversion when switching to a newer version of GnuCash.</description>
|
||||
</key>
|
||||
<key name="save-window-geometry" type="b">
|
||||
<default>true</default>
|
||||
<summary>Save window sizes and locations</summary>
|
||||
@ -225,10 +230,15 @@
|
||||
</schema>
|
||||
|
||||
<schema id="org.gnucash.general.register" path="/org/gnucash/general/register/">
|
||||
<key name="use-gnucash-color-theme" type="b">
|
||||
<default>true</default>
|
||||
<summary>Color the register using a gnucash specific color theme</summary>
|
||||
<description>When enabled the register will use a GnuCash specific color theme (green/yellow). Otherwise it will use the system color theme. Regardless of this setting the user can always override the color theme via a gnucash specific css file to be stored in the gnucash used config directory. More information can be found in the gnucash FAQ.</description>
|
||||
</key>
|
||||
<key name="use-theme-colors" type="b">
|
||||
<default>false</default>
|
||||
<summary>Color the register as specified by the system theme</summary>
|
||||
<description>If active, the register will be colored as specified by the system theme. This can be overridden to provide custom colors by editing the gtkrc file in the users home directory. Otherwise the standard register colors will be used that GnuCash has always used.</description>
|
||||
<summary>Superseded by "use-gnucash-color-theme"</summary>
|
||||
<description>This option is temporarily kept around for backwards compatibility. It will be removed in a future version.</description>
|
||||
</key>
|
||||
<key name="enter-moves-to-end" type="b">
|
||||
<default>false</default>
|
||||
|
@ -613,9 +613,8 @@ inner_main (void *closure, int argc, char **argv)
|
||||
main_mod = scm_c_resolve_module("gnucash main");
|
||||
scm_set_current_module(main_mod);
|
||||
|
||||
/* GnuCash switched to gsettings to store its preferences in version 2.5.6
|
||||
* Migrate the user's preferences from gconf if needed */
|
||||
gnc_gsettings_migrate_from_gconf();
|
||||
/* Check whether the settings need a version update */
|
||||
gnc_gsettings_version_upgrade ();
|
||||
|
||||
load_gnucash_modules();
|
||||
|
||||
|
@ -1540,8 +1540,8 @@ gnucash_sheet_refresh_from_prefs (GnucashSheet *sheet)
|
||||
g_return_if_fail(sheet != NULL);
|
||||
g_return_if_fail(GNUCASH_IS_SHEET(sheet));
|
||||
|
||||
sheet->use_theme_colors = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL_REGISTER,
|
||||
GNC_PREF_USE_THEME_COLORS);
|
||||
sheet->use_gnc_color_theme = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL_REGISTER,
|
||||
GNC_PREF_USE_GNUCASH_COLOR_THEME);
|
||||
sheet->use_horizontal_lines = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL_REGISTER,
|
||||
GNC_PREF_DRAW_HOR_LINES);
|
||||
sheet->use_vertical_lines = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL_REGISTER,
|
||||
@ -2472,13 +2472,13 @@ gnucash_get_style_classes (GnucashSheet *sheet, GtkStyleContext *stylectxt,
|
||||
break;
|
||||
}
|
||||
|
||||
if (sheet->use_theme_colors)
|
||||
if (sheet->use_gnc_color_theme)
|
||||
full_class = g_strconcat ("register-", style_class, NULL);
|
||||
else
|
||||
{
|
||||
gtk_style_context_add_class (stylectxt, GTK_STYLE_CLASS_VIEW);
|
||||
full_class = g_strconcat (style_class, "-color", NULL);
|
||||
}
|
||||
else
|
||||
full_class = g_strconcat ("register-", style_class, NULL);
|
||||
|
||||
gtk_style_context_add_class (stylectxt, full_class);
|
||||
|
||||
|
@ -63,7 +63,7 @@ struct _GnucashSheet
|
||||
GtkWidget *item_editor;
|
||||
GtkWidget *entry;
|
||||
|
||||
gboolean use_theme_colors;
|
||||
gboolean use_gnc_color_theme;
|
||||
gboolean use_horizontal_lines;
|
||||
gboolean use_vertical_lines;
|
||||
|
||||
|
@ -694,7 +694,7 @@ xsltprocExternalEntityLoader(const char *URL, const char *ID,
|
||||
* from running again. So in normal circumstances the migration will
|
||||
* be executed only once.
|
||||
*/
|
||||
void gnc_gsettings_migrate_from_gconf (void)
|
||||
static void gnc_gsettings_migrate_from_gconf (void)
|
||||
{
|
||||
gchar *pkgdatadir, *stylesheet, *input, *output, *command;
|
||||
gchar *gconf_root, *gconf_apps, *gconf_gnucash;
|
||||
@ -707,13 +707,6 @@ void gnc_gsettings_migrate_from_gconf (void)
|
||||
|
||||
ENTER ();
|
||||
|
||||
/* Only attempt to migrate if no successful migration has been done before */
|
||||
if (gnc_gsettings_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_MIGRATE_PREFS_DONE))
|
||||
{
|
||||
LEAVE ("Preferences migration ran successfully before. Skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
base_dir = g_strdup (g_get_home_dir ());
|
||||
for (iter = base_dir; *iter != 0; iter++)
|
||||
{
|
||||
@ -831,3 +824,29 @@ void gnc_gsettings_migrate_from_gconf (void)
|
||||
g_free (base_dir);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void gnc_gsettings_version_upgrade (void)
|
||||
{
|
||||
/* Use versioning to ensure this routine will only sync once for each
|
||||
* superseded setting */
|
||||
int old_maj_min = gnc_gsettings_get_int (GNC_PREFS_GROUP_GENERAL, GNC_PREF_VERSION);
|
||||
int cur_maj_min = GNUCASH_MAJOR_VERSION * 100 + GNUCASH_MINOR_VERSION;
|
||||
|
||||
/* Migrate preferences from gconf to gsettings */
|
||||
if (!gnc_gsettings_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_MIGRATE_PREFS_DONE))
|
||||
gnc_gsettings_migrate_from_gconf ();
|
||||
|
||||
/* Convert settings to 2.8 compatibility level */
|
||||
if (old_maj_min < 208)
|
||||
{
|
||||
/* 'use-theme-colors' has been replaced with 'use-gnucash-color-theme'
|
||||
* which inverts the meaning of the setting */
|
||||
gboolean old_color_theme = gnc_gsettings_get_bool (GNC_PREFS_GROUP_GENERAL_REGISTER, GNC_PREF_USE_THEME_COLORS);
|
||||
gnc_gsettings_set_bool (GNC_PREFS_GROUP_GENERAL_REGISTER, GNC_PREF_USE_GNUCASH_COLOR_THEME, !old_color_theme);
|
||||
}
|
||||
|
||||
/* Only write current version if it's more recent than what was set */
|
||||
if (cur_maj_min > old_maj_min)
|
||||
gnc_gsettings_set_int (GNC_PREFS_GROUP_GENERAL, GNC_PREF_VERSION, cur_maj_min);
|
||||
}
|
||||
|
@ -595,10 +595,14 @@ void gnc_gsettings_reset_schema (const gchar *schema);
|
||||
*/
|
||||
void gnc_gsettings_load_backend (void);
|
||||
|
||||
|
||||
/* Attempt to migrate preferences from gconf files
|
||||
to gsettings if not already done so */
|
||||
void gnc_gsettings_migrate_from_gconf (void);
|
||||
/** Check whether we need to adjust the user settings
|
||||
* to a newer version.
|
||||
*
|
||||
* New version of GnuCash may come with changes in the
|
||||
* settings schema. This function will take the necessary
|
||||
* steps to convert old settings to new (when possible).
|
||||
*/
|
||||
void gnc_gsettings_version_upgrade (void);
|
||||
|
||||
#endif /* GNC_GSETTINGS_H */
|
||||
/** @} */
|
||||
|
@ -57,6 +57,7 @@
|
||||
#define GNC_PREFS_GROUP_ACCT_SUMMARY "window.pages.account-tree.summary"
|
||||
|
||||
/* Preference names used across multiple modules */
|
||||
#define GNC_PREF_VERSION "prefs-version"
|
||||
#define GNC_PREF_SAVE_GEOMETRY "save-window-geometry"
|
||||
#define GNC_PREF_LAST_PATH "last-path"
|
||||
#define GNC_PREF_USE_NEW "use-new-window"
|
||||
@ -74,7 +75,8 @@
|
||||
#define GNC_PREF_DRAW_HOR_LINES "draw-horizontal-lines"
|
||||
#define GNC_PREF_DRAW_VERT_LINES "draw-vertical-lines"
|
||||
#define GNC_PREF_ALT_COLOR_BY_TRANS "alternate-color-by-transaction"
|
||||
#define GNC_PREF_USE_THEME_COLORS "use-theme-colors"
|
||||
#define GNC_PREF_USE_THEME_COLORS "use-theme-colors" // Obsolete, to remove in a future major version (> 2.8)
|
||||
#define GNC_PREF_USE_GNUCASH_COLOR_THEME "use-gnucash-color-theme"
|
||||
#define GNC_PREF_TAB_TRANS_MEMORISED "tab-to-transfer-on-memorised"
|
||||
#define GNC_PREF_FUTURE_AFTER_BLANK "future-after-blank-transaction"
|
||||
/* Date preferences */
|
||||
|
Loading…
Reference in New Issue
Block a user