From d443a3c2509889533ca812c163056bace396b586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 14 Jun 2023 20:35:58 +0200 Subject: New upstream version 0.32.1 --- src/config/Config.vala | 2 +- src/config/ConfigurationInterfaces.vala | 30 ++++++++++- src/config/GSettingsEngine.vala | 88 ++++++++++++++++++++++++++++++--- 3 files changed, 110 insertions(+), 10 deletions(-) (limited to 'src/config') diff --git a/src/config/Config.vala b/src/config/Config.vala index 0e2798a..3081ff0 100644 --- a/src/config/Config.vala +++ b/src/config/Config.vala @@ -26,7 +26,7 @@ public class Facade : ConfigurationFacade { public signal void colors_changed(); private Facade() { - base(new GSettingsConfigurationEngine()); + base(new GSettingsConfigurationEngine(Shotwell.ProfileManager.get_instance().id())); transparent_background_type_changed.connect(on_color_name_changed); transparent_background_color_changed.connect(on_color_name_changed); diff --git a/src/config/ConfigurationInterfaces.vala b/src/config/ConfigurationInterfaces.vala index a8d8192..12c7da1 100644 --- a/src/config/ConfigurationInterfaces.vala +++ b/src/config/ConfigurationInterfaces.vala @@ -39,6 +39,7 @@ public enum ConfigurableProperty { DISPLAY_EXTENDED_PROPERTIES, DISPLAY_SIDEBAR, DISPLAY_TOOLBAR, + DISPLAY_MAP_WIDGET, DISPLAY_SEARCH_BAR, DISPLAY_PHOTO_RATINGS, DISPLAY_PHOTO_TAGS, @@ -149,7 +150,10 @@ public enum ConfigurableProperty { case DISPLAY_TOOLBAR: return "DISPLAY_TOOLBAR"; - + + case DISPLAY_MAP_WIDGET: + return "DISPLAY_MAP_WIDGET"; + case DISPLAY_SEARCH_BAR: return "DISPLAY_SEARCH_BAR"; @@ -400,6 +404,9 @@ public abstract class ConfigurationFacade : Object { case ConfigurableProperty.IMPORT_DIR: import_directory_changed(); break; + default: + // We do not support notification for the rest of the properties + break; } } @@ -718,7 +725,6 @@ public abstract class ConfigurationFacade : Object { on_configuration_error(err); } } - // // display toolbar @@ -741,6 +747,26 @@ public abstract class ConfigurationFacade : Object { } } + // + // display map widget + // + public virtual bool get_display_map_widget() { + try { + return get_engine().get_bool_property(ConfigurableProperty.DISPLAY_MAP_WIDGET); + } catch (ConfigurationError err) { + on_configuration_error(err); + + return false; + } + } + public virtual void set_display_map_widget(bool display) { + try { + get_engine().set_bool_property(ConfigurableProperty.DISPLAY_MAP_WIDGET, display); + } catch (ConfigurationError err) { + on_configuration_error(err); + } + } + // // display search & filter toolbar // diff --git a/src/config/GSettingsEngine.vala b/src/config/GSettingsEngine.vala index d35eb93..d4d95c6 100644 --- a/src/config/GSettingsEngine.vala +++ b/src/config/GSettingsEngine.vala @@ -5,7 +5,7 @@ */ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object { - private const string ROOT_SCHEMA_NAME = "org.yorba.shotwell"; + private const string ROOT_SCHEMA_NAME = "org.gnome.shotwell"; private const string PREFS_SCHEMA_NAME = ROOT_SCHEMA_NAME + ".preferences"; private const string UI_PREFS_SCHEMA_NAME = PREFS_SCHEMA_NAME + ".ui"; private const string SLIDESHOW_PREFS_SCHEMA_NAME = PREFS_SCHEMA_NAME + ".slideshow"; @@ -25,8 +25,11 @@ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object { private string[] schema_names; private string[] key_names; private Gee.HashMap settings_cache = new Gee.HashMap(); - - public GSettingsConfigurationEngine() { + + private string profile = ""; + + public GSettingsConfigurationEngine(string? profile) { + this.profile = profile == null ? "" : profile; schema_names = new string[ConfigurableProperty.NUM_PROPERTIES]; schema_names[ConfigurableProperty.AUTO_IMPORT_FROM_LIBRARY] = FILES_PREFS_SCHEMA_NAME; @@ -47,6 +50,7 @@ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object { schema_names[ConfigurableProperty.DISPLAY_EXTENDED_PROPERTIES] = UI_PREFS_SCHEMA_NAME; schema_names[ConfigurableProperty.DISPLAY_SIDEBAR] = UI_PREFS_SCHEMA_NAME; schema_names[ConfigurableProperty.DISPLAY_TOOLBAR] = UI_PREFS_SCHEMA_NAME; + schema_names[ConfigurableProperty.DISPLAY_MAP_WIDGET] = UI_PREFS_SCHEMA_NAME; schema_names[ConfigurableProperty.DISPLAY_SEARCH_BAR] = UI_PREFS_SCHEMA_NAME; schema_names[ConfigurableProperty.DISPLAY_PHOTO_RATINGS] = UI_PREFS_SCHEMA_NAME; schema_names[ConfigurableProperty.DISPLAY_PHOTO_TAGS] = UI_PREFS_SCHEMA_NAME; @@ -120,6 +124,7 @@ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object { key_names[ConfigurableProperty.DISPLAY_EXTENDED_PROPERTIES] = "display-extended-properties"; key_names[ConfigurableProperty.DISPLAY_SIDEBAR] = "display-sidebar"; key_names[ConfigurableProperty.DISPLAY_TOOLBAR] = "display-toolbar"; + key_names[ConfigurableProperty.DISPLAY_MAP_WIDGET] = "display-map-widget"; key_names[ConfigurableProperty.DISPLAY_SEARCH_BAR] = "display-search-bar"; key_names[ConfigurableProperty.DISPLAY_PHOTO_RATINGS] = "display-photo-ratings"; key_names[ConfigurableProperty.DISPLAY_PHOTO_TAGS] = "display-photo-tags"; @@ -176,7 +181,14 @@ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object { private Settings get_settings(string schema) { if (!this.settings_cache.has_key(schema)) { - this.settings_cache[schema] = new Settings(schema); + if (schema.has_prefix (ROOT_SCHEMA_NAME)) { + var path = schema.replace(ROOT_SCHEMA_NAME, ""); + path = "/org/gnome/shotwell/%s%s/".printf(profile == "" ? "" : "profiles/" + profile, path.replace(".", "/")); + path = path.replace("//", "/"); + this.settings_cache[schema] = new Settings.with_path (schema, path); + } else { + this.settings_cache[schema] = new Settings(schema); + } } return this.settings_cache[schema]; @@ -229,7 +241,9 @@ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object { Settings schema_object = get_settings(schema); - return schema_object.get_int(key); + var v = schema_object.get_int(key); + + return v; } private void set_gs_int(string schema, string key, int value) throws ConfigurationError { @@ -292,7 +306,7 @@ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object { if (cleaned_id == null) cleaned_id = "default"; - cleaned_id = cleaned_id.replace("org.yorba.shotwell.", ""); + cleaned_id = cleaned_id.replace("org.gnome.shotwell.", ""); cleaned_id = cleaned_id.replace(".", "-"); return cleaned_id; @@ -304,7 +318,7 @@ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object { cleaned_id = "default"; cleaned_id = cleaned_id.replace(".", "-"); - return "org.yorba.shotwell.%s.%s".printf(domain, cleaned_id); + return "org.gnome.shotwell.%s.%s".printf(domain, cleaned_id); } private static string make_gsettings_key(string gconf_key) { @@ -513,4 +527,64 @@ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object { } } + /*! @brief Migrates settings data over from old-style /org/yorba/ paths to /org/gnome/ ones. + * Should only be called ONCE, during DB upgrading; otherwise, stale data may be copied + * over newer data by accident. + */ + public static void run_gsettings_migrator_v2() { + var source = SettingsSchemaSource.get_default(); + var schema = source.lookup("org.yorba.shotwell", true); + var settings = new Settings.full(schema, null, null); + + copy_schema(settings); + + Settings.sync(); + } + + static void copy_schema(Settings settings) { + SettingsSchema schema; + ((Object)settings).get("settings-schema", out schema, null); + var id = schema.get_id(); + var path = schema.get_path(); + + var new_id = id.replace("org.yorba.shotwell", "org.gnome.shotwell"); + var new_path = path.replace("/org/yorba/shotwell", "/org/gnome/shotwell"); + + var new_schema = SettingsSchemaSource.get_default().lookup(new_id, true); + + // If we cannot find this schema, we cannot migrate the keys anyway, so skip it + if (new_schema != null) { + var new_settings = new Settings.with_path(new_id, new_path); + new_settings.delay(); + + foreach (var k in schema.list_keys()) { + var key = schema.get_key(k); + var default_value = key.get_default_value(); + var val = settings.get_value(k); + if (val.equal(default_value)) { + debug("%s is default value, skipping", k); + continue; + } + + if (!new_schema.has_key(k)) { + debug("Cannot migrate %s as it does not exist", k); + continue; + } + + debug("Will migrate %s %s @ %s -> %s:%s %s", k, id, path, new_id, new_path, val.print(true)); + if (!new_settings.set_value(k, val)) { + debug(" Failed..."); + } + } + new_settings.apply(); + } + else { + debug("%s does not exist, skipping\n", new_id); + } + + foreach (var c in schema.list_children()) { + var child = settings.get_child(c); + copy_schema(child); + } + } } -- cgit v1.2.3