summaryrefslogtreecommitdiff
path: root/src/config
diff options
context:
space:
mode:
Diffstat (limited to 'src/config')
-rw-r--r--src/config/Config.vala155
-rw-r--r--src/config/ConfigurationInterfaces.vala1641
-rw-r--r--src/config/GSettingsEngine.vala475
-rw-r--r--src/config/mk/config.mk29
4 files changed, 2300 insertions, 0 deletions
diff --git a/src/config/Config.vala b/src/config/Config.vala
new file mode 100644
index 0000000..2095107
--- /dev/null
+++ b/src/config/Config.vala
@@ -0,0 +1,155 @@
+/* Copyright 2011-2014 Yorba Foundation
+ *
+ * This software is licensed under the GNU Lesser General Public License
+ * (version 2.1 or later). See the COPYING file in this distribution.
+ */
+
+/* This file is the master unit file for the Config unit. It should be edited to include
+ * whatever code is deemed necessary.
+ *
+ * The init() and terminate() methods are mandatory.
+ *
+ * If the unit needs to be configured prior to initialization, add the proper parameters to
+ * the preconfigure() method, implement it, and ensure in init() that it's been called.
+ */
+
+namespace Config {
+
+public class Facade : ConfigurationFacade {
+ public const double SLIDESHOW_DELAY_MAX = 30.0;
+ public const double SLIDESHOW_DELAY_MIN = 1.0;
+ public const double SLIDESHOW_DELAY_DEFAULT = 3.0;
+ public const double SLIDESHOW_TRANSITION_DELAY_MAX = 1.0;
+ public const double SLIDESHOW_TRANSITION_DELAY_MIN = 0.1;
+ public const double SLIDESHOW_TRANSITION_DELAY_DEFAULT = 0.3;
+ public const int WIDTH_DEFAULT = 1024;
+ public const int HEIGHT_DEFAULT = 768;
+ public const int SIDEBAR_MIN_POSITION = 180;
+ public const int SIDEBAR_MAX_POSITION = 1000;
+ public const string DEFAULT_BG_COLOR = "#444";
+ public const int NO_VIDEO_INTERPRETER_STATE = -1;
+
+ private const double BLACK_THRESHOLD = 0.61;
+ private const string DARK_SELECTED_COLOR = "#0AD";
+ private const string LIGHT_SELECTED_COLOR = "#2DF";
+ private const string DARK_UNSELECTED_COLOR = "#000";
+ private const string LIGHT_UNSELECTED_COLOR = "#FFF";
+ private const string DARK_BORDER_COLOR = "#999";
+ private const string LIGHT_BORDER_COLOR = "#AAA";
+ private const string DARK_UNFOCUSED_SELECTED_COLOR = "#6fc4dd";
+ private const string LIGHT_UNFOCUSED_SELECTED_COLOR = "#99efff";
+
+ private string bg_color = null;
+ private string selected_color = null;
+ private string unselected_color = null;
+ private string unfocused_selected_color = null;
+ private string border_color = null;
+
+ private static Facade instance = null;
+
+ public signal void colors_changed();
+
+ private Facade() {
+ base(new GSettingsConfigurationEngine());
+
+ bg_color_name_changed.connect(on_color_name_changed);
+ }
+
+ public static Facade get_instance() {
+ if (instance == null)
+ instance = new Facade();
+
+ return instance;
+ }
+
+ private void on_color_name_changed() {
+ colors_changed();
+ }
+
+ private void set_text_colors(Gdk.RGBA bg_color) {
+ // since bg color is greyscale, we only need to compare the red value to the threshold,
+ // which determines whether the background is dark enough to need light text and selection
+ // colors or vice versa
+ if (bg_color.red > BLACK_THRESHOLD) {
+ selected_color = DARK_SELECTED_COLOR;
+ unselected_color = DARK_UNSELECTED_COLOR;
+ unfocused_selected_color = DARK_UNFOCUSED_SELECTED_COLOR;
+ border_color = DARK_BORDER_COLOR;
+ } else {
+ selected_color = LIGHT_SELECTED_COLOR;
+ unselected_color = LIGHT_UNSELECTED_COLOR;
+ unfocused_selected_color = LIGHT_UNFOCUSED_SELECTED_COLOR;
+ border_color = LIGHT_BORDER_COLOR;
+ }
+ }
+
+ private void get_colors() {
+ bg_color = base.get_bg_color_name();
+
+ if (!is_color_parsable(bg_color))
+ bg_color = DEFAULT_BG_COLOR;
+
+ set_text_colors(parse_color(bg_color));
+ }
+
+ public Gdk.RGBA get_bg_color() {
+ if (is_string_empty(bg_color))
+ get_colors();
+
+ return parse_color(bg_color);
+ }
+
+ public Gdk.RGBA get_selected_color(bool in_focus = true) {
+ if (in_focus) {
+ if (is_string_empty(selected_color))
+ get_colors();
+
+ return parse_color(selected_color);
+ } else {
+ if (is_string_empty(unfocused_selected_color))
+ get_colors();
+
+ return parse_color(unfocused_selected_color);
+ }
+ }
+
+ public Gdk.RGBA get_unselected_color() {
+ if (is_string_empty(unselected_color))
+ get_colors();
+
+ return parse_color(unselected_color);
+ }
+
+ public Gdk.RGBA get_border_color() {
+ if (is_string_empty(border_color))
+ get_colors();
+
+ return parse_color(border_color);
+ }
+
+ public void set_bg_color(Gdk.RGBA color) {
+ uint8 col_tmp = (uint8) (color.red * 255.0);
+
+ bg_color = "#%02X%02X%02X".printf(col_tmp, col_tmp, col_tmp);
+ set_bg_color_name(bg_color);
+
+ set_text_colors(color);
+ }
+
+ public void commit_bg_color() {
+ base.set_bg_color_name(bg_color);
+ }
+}
+
+// preconfigure may be deleted if not used.
+public void preconfigure() {
+}
+
+public void init() throws Error {
+}
+
+public void terminate() {
+}
+
+}
+
diff --git a/src/config/ConfigurationInterfaces.vala b/src/config/ConfigurationInterfaces.vala
new file mode 100644
index 0000000..42a591a
--- /dev/null
+++ b/src/config/ConfigurationInterfaces.vala
@@ -0,0 +1,1641 @@
+/* Copyright 2009-2014 Yorba Foundation
+ *
+ * This software is licensed under the GNU LGPL (version 2.1 or later).
+ * See the COPYING file in this distribution.
+ */
+
+public errordomain ConfigurationError {
+ PROPERTY_HAS_NO_VALUE,
+ /**
+ * the underlying configuration engine reported an error; the error is
+ * specific to the configuration engine in use (e.g., GSettings)
+ * and is usually meaningless to client code */
+ ENGINE_ERROR,
+}
+
+public enum FuzzyPropertyState {
+ ENABLED,
+ DISABLED,
+ UNKNOWN
+}
+
+public enum ConfigurableProperty {
+ AUTO_IMPORT_FROM_LIBRARY = 0,
+ BG_COLOR_NAME,
+ COMMIT_METADATA_TO_MASTERS,
+ DESKTOP_BACKGROUND_FILE,
+ DESKTOP_BACKGROUND_MODE,
+ SCREENSAVER_FILE,
+ SCREENSAVER_MODE,
+ DIRECTORY_PATTERN,
+ DIRECTORY_PATTERN_CUSTOM,
+ DIRECT_WINDOW_HEIGHT,
+ DIRECT_WINDOW_MAXIMIZE,
+ DIRECT_WINDOW_WIDTH,
+ DISPLAY_BASIC_PROPERTIES,
+ DISPLAY_EVENT_COMMENTS,
+ DISPLAY_EXTENDED_PROPERTIES,
+ DISPLAY_SIDEBAR,
+ DISPLAY_SEARCH_BAR,
+ DISPLAY_PHOTO_RATINGS,
+ DISPLAY_PHOTO_TAGS,
+ DISPLAY_PHOTO_TITLES,
+ DISPLAY_PHOTO_COMMENTS,
+ EVENT_PHOTOS_SORT_ASCENDING,
+ EVENT_PHOTOS_SORT_BY,
+ EVENTS_SORT_ASCENDING,
+ EXTERNAL_PHOTO_APP,
+ EXTERNAL_RAW_APP,
+ HIDE_PHOTOS_ALREADY_IMPORTED,
+ IMPORT_DIR,
+ KEEP_RELATIVITY,
+ LAST_CROP_HEIGHT,
+ LAST_CROP_MENU_CHOICE,
+ LAST_CROP_WIDTH,
+ LAST_USED_SERVICE,
+ LAST_USED_DATAIMPORTS_SERVICE,
+ LIBRARY_PHOTOS_SORT_ASCENDING,
+ LIBRARY_PHOTOS_SORT_BY,
+ LIBRARY_WINDOW_HEIGHT,
+ LIBRARY_WINDOW_MAXIMIZE,
+ LIBRARY_WINDOW_WIDTH,
+ MODIFY_ORIGINALS,
+ PHOTO_THUMBNAIL_SCALE,
+ PIN_TOOLBAR_STATE,
+ PRINTING_CONTENT_HEIGHT,
+ PRINTING_CONTENT_LAYOUT,
+ PRINTING_CONTENT_PPI,
+ PRINTING_CONTENT_UNITS,
+ PRINTING_CONTENT_WIDTH,
+ PRINTING_IMAGES_PER_PAGE,
+ PRINTING_MATCH_ASPECT_RATIO,
+ PRINTING_PRINT_TITLES,
+ PRINTING_SIZE_SELECTION,
+ PRINTING_TITLES_FONT,
+ RAW_DEVELOPER_DEFAULT,
+ SHOW_WELCOME_DIALOG,
+ SIDEBAR_POSITION,
+ SLIDESHOW_DELAY,
+ SLIDESHOW_TRANSITION_DELAY,
+ SLIDESHOW_TRANSITION_EFFECT_ID,
+ SLIDESHOW_SHOW_TITLE,
+ USE_24_HOUR_TIME,
+ USE_LOWERCASE_FILENAMES,
+ VIDEO_INTERPRETER_STATE_COOKIE,
+
+
+ NUM_PROPERTIES;
+
+ public string to_string() {
+ switch (this) {
+ case AUTO_IMPORT_FROM_LIBRARY:
+ return "AUTO_IMPORT_FROM_LIBRARY";
+
+ case BG_COLOR_NAME:
+ return "BG_COLOR_NAME";
+
+ case COMMIT_METADATA_TO_MASTERS:
+ return "COMMIT_METADATA_TO_MASTERS";
+
+ case DESKTOP_BACKGROUND_FILE:
+ return "DESKTOP_BACKGROUND_FILE";
+
+ case DESKTOP_BACKGROUND_MODE:
+ return "DESKTOP_BACKGROUND_MODE";
+
+ case SCREENSAVER_FILE:
+ return "SCREENSAVER_FILE";
+
+ case SCREENSAVER_MODE:
+ return "SCREENSAVER_MODE";
+
+ case DIRECTORY_PATTERN:
+ return "DIRECTORY_PATTERN";
+
+ case DIRECTORY_PATTERN_CUSTOM:
+ return "DIRECTORY_PATTERN_CUSTOM";
+
+ case DIRECT_WINDOW_HEIGHT:
+ return "DIRECT_WINDOW_HEIGHT";
+
+ case DIRECT_WINDOW_MAXIMIZE:
+ return "DIRECT_WINDOW_MAXIMIZE";
+
+ case DIRECT_WINDOW_WIDTH:
+ return "DIRECT_WINDOW_WIDTH";
+
+ case DISPLAY_BASIC_PROPERTIES:
+ return "DISPLAY_BASIC_PROPERTIES";
+
+ case DISPLAY_EXTENDED_PROPERTIES:
+ return "DISPLAY_EXTENDED_PROPERTIES";
+
+ case DISPLAY_SIDEBAR:
+ return "DISPLAY_SIDEBAR";
+
+ case DISPLAY_SEARCH_BAR:
+ return "DISPLAY_SEARCH_BAR";
+
+ case DISPLAY_PHOTO_RATINGS:
+ return "DISPLAY_PHOTO_RATINGS";
+
+ case DISPLAY_PHOTO_TAGS:
+ return "DISPLAY_PHOTO_TAGS";
+
+ case DISPLAY_PHOTO_TITLES:
+ return "DISPLAY_PHOTO_TITLES";
+
+ case DISPLAY_PHOTO_COMMENTS:
+ return "DISPLAY_PHOTO_COMMENTS";
+
+ case DISPLAY_EVENT_COMMENTS:
+ return "DISPLAY_EVENT_COMMENTS";
+
+ case EVENT_PHOTOS_SORT_ASCENDING:
+ return "EVENT_PHOTOS_SORT_ASCENDING";
+
+ case EVENT_PHOTOS_SORT_BY:
+ return "EVENT_PHOTOS_SORT_BY";
+
+ case EVENTS_SORT_ASCENDING:
+ return "EVENTS_SORT_ASCENDING";
+
+ case EXTERNAL_PHOTO_APP:
+ return "EXTERNAL_PHOTO_APP";
+
+ case EXTERNAL_RAW_APP:
+ return "EXTERNAL_RAW_APP";
+
+ case HIDE_PHOTOS_ALREADY_IMPORTED:
+ return "HIDE_PHOTOS_ALREADY_IMPORTED";
+
+ case IMPORT_DIR:
+ return "IMPORT_DIR";
+
+ case KEEP_RELATIVITY:
+ return "KEEP_RELATIVITY";
+
+ case LAST_CROP_HEIGHT:
+ return "LAST_CROP_HEIGHT";
+
+ case LAST_CROP_MENU_CHOICE:
+ return "LAST_CROP_MENU_CHOICE";
+
+ case LAST_CROP_WIDTH:
+ return "LAST_CROP_WIDTH";
+
+ case LAST_USED_SERVICE:
+ return "LAST_USED_SERVICE";
+
+ case LAST_USED_DATAIMPORTS_SERVICE:
+ return "LAST_USED_DATAIMPORTS_SERVICE";
+
+ case LIBRARY_PHOTOS_SORT_ASCENDING:
+ return "LIBRARY_PHOTOS_SORT_ASCENDING";
+
+ case LIBRARY_PHOTOS_SORT_BY:
+ return "LIBRARY_PHOTOS_SORT_BY";
+
+ case LIBRARY_WINDOW_HEIGHT:
+ return "LIBRARY_WINDOW_HEIGHT";
+
+ case LIBRARY_WINDOW_MAXIMIZE:
+ return "LIBRARY_WINDOW_MAXIMIZE";
+
+ case LIBRARY_WINDOW_WIDTH:
+ return "LIBRARY_WINDOW_WIDTH";
+
+ case MODIFY_ORIGINALS:
+ return "MODIFY_ORIGINALS";
+
+ case PHOTO_THUMBNAIL_SCALE:
+ return "PHOTO_THUMBNAIL_SCALE";
+
+ case PIN_TOOLBAR_STATE:
+ return "PIN_TOOLBAR_STATE";
+
+ case PRINTING_CONTENT_HEIGHT:
+ return "PRINTING_CONTENT_HEIGHT";
+
+ case PRINTING_CONTENT_LAYOUT:
+ return "PRINTING_CONTENT_LAYOUT";
+
+ case PRINTING_CONTENT_PPI:
+ return "PRINTING_CONTENT_PPI";
+
+ case PRINTING_CONTENT_UNITS:
+ return "PRINTING_CONTENT_UNITS";
+
+ case PRINTING_CONTENT_WIDTH:
+ return "PRINTING_CONTENT_WIDTH";
+
+ case PRINTING_IMAGES_PER_PAGE:
+ return "PRINTING_IMAGES_PER_PAGE";
+
+ case PRINTING_MATCH_ASPECT_RATIO:
+ return "PRINTING_MATCH_ASPECT_RATIO";
+
+ case PRINTING_PRINT_TITLES:
+ return "PRINTING_PRINT_TITLES";
+
+ case PRINTING_SIZE_SELECTION:
+ return "PRINTING_SIZE_SELECTION";
+
+ case PRINTING_TITLES_FONT:
+ return "PRINTING_TITLES_FONT";
+
+ case RAW_DEVELOPER_DEFAULT:
+ return "RAW_DEVELOPER_DEFAULT";
+
+ case SHOW_WELCOME_DIALOG:
+ return "SHOW_WELCOME_DIALOG";
+
+ case SIDEBAR_POSITION:
+ return "SIDEBAR_POSITION";
+
+ case SLIDESHOW_DELAY:
+ return "SLIDESHOW_DELAY";
+
+ case SLIDESHOW_TRANSITION_DELAY:
+ return "SLIDESHOW_TRANSITION_DELAY";
+
+ case SLIDESHOW_TRANSITION_EFFECT_ID:
+ return "SLIDESHOW_TRANSITION_EFFECT_ID";
+
+ case SLIDESHOW_SHOW_TITLE:
+ return "SLIDESHOW_SHOW_TITLE";
+
+ case USE_24_HOUR_TIME:
+ return "USE_24_HOUR_TIME";
+
+ case USE_LOWERCASE_FILENAMES:
+ return "USE_LOWERCASE_FILENAMES";
+
+ case VIDEO_INTERPRETER_STATE_COOKIE:
+ return "VIDEO_INTERPRETER_STATE_COOKIE";
+
+ default:
+ error("unknown ConfigurableProperty enumeration value");
+ }
+ }
+}
+
+public interface ConfigurationEngine : GLib.Object {
+ public signal void property_changed(ConfigurableProperty p);
+
+ public abstract string get_name();
+
+ public abstract int get_int_property(ConfigurableProperty p) throws ConfigurationError;
+ public abstract void set_int_property(ConfigurableProperty p, int val) throws ConfigurationError;
+
+ public abstract string get_string_property(ConfigurableProperty p) throws ConfigurationError;
+ public abstract void set_string_property(ConfigurableProperty p, string val) throws ConfigurationError;
+
+ public abstract bool get_bool_property(ConfigurableProperty p) throws ConfigurationError;
+ public abstract void set_bool_property(ConfigurableProperty p, bool val) throws ConfigurationError;
+
+ public abstract double get_double_property(ConfigurableProperty p) throws ConfigurationError;
+ public abstract void set_double_property(ConfigurableProperty p, double val) throws ConfigurationError;
+
+ public abstract bool get_plugin_bool(string domain, string id, string key, bool def);
+ public abstract void set_plugin_bool(string domain, string id, string key, bool val);
+ public abstract double get_plugin_double(string domain, string id, string key, double def);
+ public abstract void set_plugin_double(string domain, string id, string key, double val);
+ public abstract int get_plugin_int(string domain, string id, string key, int def);
+ public abstract void set_plugin_int(string domain, string id, string key, int val);
+ public abstract string? get_plugin_string(string domain, string id, string key, string? def);
+ public abstract void set_plugin_string(string domain, string id, string key, string? val);
+ public abstract void unset_plugin_key(string domain, string id, string key);
+
+ public abstract FuzzyPropertyState is_plugin_enabled(string id);
+ public abstract void set_plugin_enabled(string id, bool enabled);
+}
+
+public abstract class ConfigurationFacade : Object {
+ private ConfigurationEngine engine;
+
+ public signal void auto_import_from_library_changed();
+ public signal void bg_color_name_changed();
+ public signal void commit_metadata_to_masters_changed();
+ public signal void events_sort_ascending_changed();
+ public signal void external_app_changed();
+ public signal void import_directory_changed();
+
+ protected ConfigurationFacade(ConfigurationEngine engine) {
+ this.engine = engine;
+
+ engine.property_changed.connect(on_property_changed);
+ }
+
+ private void on_property_changed(ConfigurableProperty p) {
+ debug ("ConfigurationFacade: engine reports property '%s' changed.", p.to_string());
+
+ switch (p) {
+ case ConfigurableProperty.AUTO_IMPORT_FROM_LIBRARY:
+ auto_import_from_library_changed();
+ break;
+
+ case ConfigurableProperty.BG_COLOR_NAME:
+ bg_color_name_changed();
+ break;
+
+ case ConfigurableProperty.COMMIT_METADATA_TO_MASTERS:
+ commit_metadata_to_masters_changed();
+ break;
+
+ case ConfigurableProperty.EVENTS_SORT_ASCENDING:
+ events_sort_ascending_changed();
+ break;
+
+ case ConfigurableProperty.EXTERNAL_PHOTO_APP:
+ case ConfigurableProperty.EXTERNAL_RAW_APP:
+ external_app_changed();
+ break;
+
+ case ConfigurableProperty.IMPORT_DIR:
+ import_directory_changed();
+ break;
+ }
+ }
+
+ protected ConfigurationEngine get_engine() {
+ return engine;
+ }
+
+ protected void on_configuration_error(ConfigurationError err) {
+ if (err is ConfigurationError.PROPERTY_HAS_NO_VALUE) {
+ message("configuration engine '%s' reports PROPERTY_HAS_NO_VALUE error: %s",
+ engine.get_name(), err.message);
+ }
+ else if (err is ConfigurationError.ENGINE_ERROR) {
+ critical("configuration engine '%s' reports ENGINE_ERROR: %s",
+ engine.get_name(), err.message);
+ } else {
+ critical("configuration engine '%s' reports unknown error: %s",
+ engine.get_name(), err.message);
+ }
+ }
+
+ //
+ // auto import from library
+ //
+ public virtual bool get_auto_import_from_library() {
+ try {
+ return get_engine().get_bool_property(ConfigurableProperty.AUTO_IMPORT_FROM_LIBRARY);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return false;
+ }
+ }
+
+ public virtual void set_auto_import_from_library(bool auto_import) {
+ try {
+ get_engine().set_bool_property(ConfigurableProperty.AUTO_IMPORT_FROM_LIBRARY,
+ auto_import);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ return;
+ }
+ }
+
+ //
+ // bg color name
+ //
+ public virtual string get_bg_color_name() {
+ try {
+ return get_engine().get_string_property(ConfigurableProperty.BG_COLOR_NAME);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return "";
+ }
+ }
+
+ public virtual void set_bg_color_name(string color_name) {
+ try {
+ get_engine().set_string_property(ConfigurableProperty.BG_COLOR_NAME, color_name);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ return;
+ }
+ }
+
+ //
+ // commit metadata to masters
+ //
+ public virtual bool get_commit_metadata_to_masters() {
+ try {
+ return get_engine().get_bool_property(ConfigurableProperty.COMMIT_METADATA_TO_MASTERS);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return false;
+ }
+ }
+
+ public virtual void set_commit_metadata_to_masters(bool commit_metadata) {
+ try {
+ get_engine().set_bool_property(ConfigurableProperty.COMMIT_METADATA_TO_MASTERS,
+ commit_metadata);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ return;
+ }
+ }
+
+ //
+ // desktop background
+ //
+ public virtual string get_desktop_background() {
+ try {
+ return get_engine().get_string_property(ConfigurableProperty.DESKTOP_BACKGROUND_FILE);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return "";
+ }
+ }
+
+ public virtual void set_desktop_background(string filename) {
+ try {
+ get_engine().set_string_property(ConfigurableProperty.DESKTOP_BACKGROUND_FILE,
+ filename);
+ get_engine().set_string_property(ConfigurableProperty.DESKTOP_BACKGROUND_MODE,
+ "zoom");
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // screensaver background
+ //
+ public virtual string get_screensaver() {
+ try {
+ return get_engine().get_string_property(ConfigurableProperty.SCREENSAVER_FILE);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return "";
+ }
+ }
+
+ public virtual void set_screensaver(string filename) {
+ try {
+ get_engine().set_string_property(ConfigurableProperty.SCREENSAVER_FILE,
+ filename);
+ get_engine().set_string_property(ConfigurableProperty.SCREENSAVER_MODE,
+ "zoom");
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // directory pattern
+ //
+ public virtual string? get_directory_pattern() {
+ try {
+ string s = get_engine().get_string_property(ConfigurableProperty.DIRECTORY_PATTERN);
+ return (s == "") ? null : s;
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return "";
+ }
+ }
+
+ public virtual void set_directory_pattern(string? s) {
+ try {
+ if (s == null)
+ s = "";
+
+ get_engine().set_string_property(ConfigurableProperty.DIRECTORY_PATTERN, s);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // directory pattern custom
+ //
+ public virtual string get_directory_pattern_custom() {
+ try {
+ return get_engine().get_string_property(ConfigurableProperty.DIRECTORY_PATTERN_CUSTOM);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return "";
+ }
+ }
+
+ public virtual void set_directory_pattern_custom(string s) {
+ try {
+ get_engine().set_string_property(ConfigurableProperty.DIRECTORY_PATTERN_CUSTOM, s);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // direct window state
+ //
+ public virtual void get_direct_window_state(out bool maximize, out Dimensions dimensions) {
+ maximize = false;
+ dimensions = Dimensions(1024, 768);
+ try {
+ maximize = get_engine().get_bool_property(ConfigurableProperty.DIRECT_WINDOW_MAXIMIZE);
+ int w = get_engine().get_int_property(ConfigurableProperty.DIRECT_WINDOW_WIDTH);
+ int h = get_engine().get_int_property(ConfigurableProperty.DIRECT_WINDOW_HEIGHT);
+ dimensions = Dimensions(w, h);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ public virtual void set_direct_window_state(bool maximize, Dimensions dimensions) {
+ try {
+ get_engine().set_bool_property(ConfigurableProperty.DIRECT_WINDOW_MAXIMIZE, maximize);
+ get_engine().set_int_property(ConfigurableProperty.DIRECT_WINDOW_WIDTH,
+ dimensions.width);
+ get_engine().set_int_property(ConfigurableProperty.DIRECT_WINDOW_HEIGHT,
+ dimensions.height);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // display basic properties
+ //
+ public virtual bool get_display_basic_properties() {
+ try {
+ return get_engine().get_bool_property(ConfigurableProperty.DISPLAY_BASIC_PROPERTIES);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return true;
+ }
+ }
+
+ public virtual void set_display_basic_properties(bool display) {
+ try {
+ get_engine().set_bool_property(ConfigurableProperty.DISPLAY_BASIC_PROPERTIES, display);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // display extended properties
+ //
+ public virtual bool get_display_extended_properties() {
+ try {
+ return get_engine().get_bool_property(ConfigurableProperty.DISPLAY_EXTENDED_PROPERTIES);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return false;
+ }
+ }
+
+ public virtual void set_display_extended_properties(bool display) {
+ try {
+ get_engine().set_bool_property(ConfigurableProperty.DISPLAY_EXTENDED_PROPERTIES,
+ display);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // display sidebar
+ //
+ public virtual bool get_display_sidebar() {
+ try {
+ return get_engine().get_bool_property(ConfigurableProperty.DISPLAY_SIDEBAR);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return false;
+ }
+ }
+
+ public virtual void set_display_sidebar(bool display) {
+ try {
+ get_engine().set_bool_property(ConfigurableProperty.DISPLAY_SIDEBAR, display);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // display search & filter toolbar
+ //
+ public virtual bool get_display_search_bar() {
+ try {
+ return get_engine().get_bool_property(ConfigurableProperty.DISPLAY_SEARCH_BAR);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return false;
+ }
+ }
+
+ public virtual void set_display_search_bar(bool display) {
+ try {
+ get_engine().set_bool_property(ConfigurableProperty.DISPLAY_SEARCH_BAR, display);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // display photo ratings
+ //
+ public virtual bool get_display_photo_ratings() {
+ try {
+ return get_engine().get_bool_property(ConfigurableProperty.DISPLAY_PHOTO_RATINGS);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return true;
+ }
+ }
+
+ public virtual void set_display_photo_ratings(bool display) {
+ try {
+ get_engine().set_bool_property(ConfigurableProperty.DISPLAY_PHOTO_RATINGS, display);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // display photo tags
+ //
+ public virtual bool get_display_photo_tags() {
+ try {
+ return get_engine().get_bool_property(ConfigurableProperty.DISPLAY_PHOTO_TAGS);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return true;
+ }
+ }
+
+ public virtual void set_display_photo_tags(bool display) {
+ try {
+ get_engine().set_bool_property(ConfigurableProperty.DISPLAY_PHOTO_TAGS, display);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // display photo titles
+ //
+ public virtual bool get_display_photo_titles() {
+ try {
+ return get_engine().get_bool_property(ConfigurableProperty.DISPLAY_PHOTO_TITLES);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return false;
+ }
+ }
+
+ public virtual void set_display_photo_titles(bool display) {
+ try {
+ get_engine().set_bool_property(ConfigurableProperty.DISPLAY_PHOTO_TITLES, display);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // display photo comments
+ //
+ public virtual bool get_display_photo_comments() {
+ try {
+ return get_engine().get_bool_property(ConfigurableProperty.DISPLAY_PHOTO_COMMENTS);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return false;
+ }
+ }
+
+ public virtual void set_display_photo_comments(bool display) {
+ try {
+ get_engine().set_bool_property(ConfigurableProperty.DISPLAY_PHOTO_COMMENTS, display);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // display event comments
+ //
+ public virtual bool get_display_event_comments() {
+ try {
+ return get_engine().get_bool_property(ConfigurableProperty.DISPLAY_EVENT_COMMENTS);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return false;
+ }
+ }
+
+ public virtual void set_display_event_comments(bool display) {
+ try {
+ get_engine().set_bool_property(ConfigurableProperty.DISPLAY_EVENT_COMMENTS, display);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // event photos sort
+ //
+ public virtual void get_event_photos_sort(out bool sort_order, out int sort_by) {
+ sort_order = false;
+ sort_by = 2;
+ try {
+ sort_order = get_engine().get_bool_property(
+ ConfigurableProperty.EVENT_PHOTOS_SORT_ASCENDING);
+ sort_by = get_engine().get_int_property(ConfigurableProperty.EVENT_PHOTOS_SORT_BY);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ public virtual void set_event_photos_sort(bool sort_order, int sort_by) {
+ try {
+ get_engine().set_bool_property(ConfigurableProperty.EVENT_PHOTOS_SORT_ASCENDING,
+ sort_order);
+ get_engine().set_int_property(ConfigurableProperty.EVENT_PHOTOS_SORT_BY,
+ sort_by);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // events sort ascending
+ //
+ public virtual bool get_events_sort_ascending() {
+ try {
+ return get_engine().get_bool_property(ConfigurableProperty.EVENTS_SORT_ASCENDING);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return false;
+ }
+ }
+
+ public virtual void set_events_sort_ascending(bool sort) {
+ try {
+ get_engine().set_bool_property(ConfigurableProperty.EVENTS_SORT_ASCENDING, sort);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ return;
+ }
+ }
+
+ //
+ // external photo app
+ //
+ public virtual string get_external_photo_app() {
+ try {
+ return get_engine().get_string_property(ConfigurableProperty.EXTERNAL_PHOTO_APP);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return "";
+ }
+ }
+
+ public virtual void set_external_photo_app(string external_photo_app) {
+ try {
+ get_engine().set_string_property(ConfigurableProperty.EXTERNAL_PHOTO_APP,
+ external_photo_app);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ return;
+ }
+ }
+
+ //
+ // external raw app
+ //
+ public virtual string get_external_raw_app() {
+ try {
+ return get_engine().get_string_property(ConfigurableProperty.EXTERNAL_RAW_APP);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return "";
+ }
+ }
+
+ public virtual void set_external_raw_app(string external_raw_app) {
+ try {
+ get_engine().set_string_property(ConfigurableProperty.EXTERNAL_RAW_APP,
+ external_raw_app);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ return;
+ }
+ }
+
+ //
+ // Default RAW developer.
+ //
+ public virtual RawDeveloper get_default_raw_developer() {
+ try {
+ return RawDeveloper.from_string(get_engine().get_string_property(
+ ConfigurableProperty.RAW_DEVELOPER_DEFAULT));
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return RawDeveloper.CAMERA;
+ }
+ }
+
+ public virtual void set_default_raw_developer(RawDeveloper d) {
+ try {
+ get_engine().set_string_property(ConfigurableProperty.RAW_DEVELOPER_DEFAULT,
+ d.to_string());
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ return;
+ }
+ }
+
+ //
+ // hide photos already imported
+ //
+ public virtual bool get_hide_photos_already_imported() {
+ try {
+ return get_engine().get_bool_property(ConfigurableProperty.HIDE_PHOTOS_ALREADY_IMPORTED);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return true;
+ }
+ }
+
+ public virtual void set_hide_photos_already_imported(bool hide_imported) {
+ try {
+ get_engine().set_bool_property(ConfigurableProperty.HIDE_PHOTOS_ALREADY_IMPORTED, hide_imported);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // import dir
+ //
+ public virtual string get_import_dir() {
+ try {
+ return get_engine().get_string_property(ConfigurableProperty.IMPORT_DIR);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return "";
+ }
+ }
+
+ public virtual void set_import_dir(string import_dir) {
+ try {
+ get_engine().set_string_property(ConfigurableProperty.IMPORT_DIR, import_dir);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // keep relativity
+ //
+ public virtual bool get_keep_relativity() {
+ try {
+ return get_engine().get_bool_property(ConfigurableProperty.KEEP_RELATIVITY);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return true;
+ }
+ }
+
+ public virtual void set_keep_relativity(bool keep_relativity) {
+ try {
+ get_engine().set_bool_property(ConfigurableProperty.KEEP_RELATIVITY, keep_relativity);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // pin toolbar state
+ //
+ public virtual bool get_pin_toolbar_state() {
+ try {
+ return get_engine().get_bool_property(ConfigurableProperty.PIN_TOOLBAR_STATE);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ return false;
+ }
+ }
+
+ public virtual void set_pin_toolbar_state(bool state) {
+ try {
+ get_engine().set_bool_property(ConfigurableProperty.PIN_TOOLBAR_STATE, state);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // last crop height
+ //
+ public virtual int get_last_crop_height() {
+ try {
+ return get_engine().get_int_property(ConfigurableProperty.LAST_CROP_HEIGHT);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ return 1;
+ }
+ }
+
+ public virtual void set_last_crop_height(int choice) {
+ try {
+ get_engine().set_int_property(ConfigurableProperty.LAST_CROP_HEIGHT, choice);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // last crop menu choice
+ //
+ public virtual int get_last_crop_menu_choice() {
+ try {
+ return get_engine().get_int_property(ConfigurableProperty.LAST_CROP_MENU_CHOICE);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ // in the event we can't get a reasonable value from the configuration engine, we
+ // return the empty string since it won't match the name of any existing publishing
+ // service -- this will cause the publishing subsystem to select the first service
+ // loaded that supports the user's media type
+ return 0;
+ }
+ }
+
+ public virtual void set_last_crop_menu_choice(int choice) {
+ try {
+ get_engine().set_int_property(ConfigurableProperty.LAST_CROP_MENU_CHOICE, choice);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // last crop width
+ //
+ public virtual int get_last_crop_width() {
+ try {
+ return get_engine().get_int_property(ConfigurableProperty.LAST_CROP_WIDTH);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ return 1;
+ }
+ }
+
+ public virtual void set_last_crop_width(int choice) {
+ try {
+ get_engine().set_int_property(ConfigurableProperty.LAST_CROP_WIDTH, choice);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // last used service
+ //
+ public virtual string get_last_used_service() {
+ try {
+ return get_engine().get_string_property(ConfigurableProperty.LAST_USED_SERVICE);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ // in the event we can't get a reasonable value from the configuration engine, we
+ // return the empty string since it won't match the name of any existing publishing
+ // service -- this will cause the publishing subsystem to select the first service
+ // loaded that supports the user's media type
+ return "";
+ }
+ }
+
+ public virtual void set_last_used_service(string service_name) {
+ try {
+ get_engine().set_string_property(ConfigurableProperty.LAST_USED_SERVICE, service_name);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // last used import service
+ //
+ public virtual string get_last_used_dataimports_service() {
+ try {
+ return get_engine().get_string_property(ConfigurableProperty.LAST_USED_DATAIMPORTS_SERVICE);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ // in the event we can't get a reasonable value from the configuration engine, we
+ // return the empty string since it won't match the name of any existing import
+ // service -- this will cause the import subsystem to select the first service
+ // loaded
+ return "";
+ }
+ }
+
+ public virtual void set_last_used_dataimports_service(string service_name) {
+ try {
+ get_engine().set_string_property(ConfigurableProperty.LAST_USED_DATAIMPORTS_SERVICE, service_name);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // library photos sort
+ //
+ public virtual void get_library_photos_sort(out bool sort_order, out int sort_by) {
+ sort_order = false;
+ sort_by = 2;
+ try {
+ sort_order = get_engine().get_bool_property(
+ ConfigurableProperty.LIBRARY_PHOTOS_SORT_ASCENDING);
+ sort_by = get_engine().get_int_property(ConfigurableProperty.LIBRARY_PHOTOS_SORT_BY);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ public virtual void set_library_photos_sort(bool sort_order, int sort_by) {
+ try {
+ get_engine().set_bool_property(ConfigurableProperty.LIBRARY_PHOTOS_SORT_ASCENDING,
+ sort_order);
+ get_engine().set_int_property(ConfigurableProperty.LIBRARY_PHOTOS_SORT_BY,
+ sort_by);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // library window state
+ //
+ public virtual void get_library_window_state(out bool maximize, out Dimensions dimensions) {
+ maximize = false;
+ dimensions = Dimensions(1024, 768);
+ try {
+ maximize = get_engine().get_bool_property(ConfigurableProperty.LIBRARY_WINDOW_MAXIMIZE);
+ int w = get_engine().get_int_property(ConfigurableProperty.LIBRARY_WINDOW_WIDTH);
+ int h = get_engine().get_int_property(ConfigurableProperty.LIBRARY_WINDOW_HEIGHT);
+ dimensions = Dimensions(w, h);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ public virtual void set_library_window_state(bool maximize, Dimensions dimensions) {
+ try {
+ get_engine().set_bool_property(ConfigurableProperty.LIBRARY_WINDOW_MAXIMIZE, maximize);
+ get_engine().set_int_property(ConfigurableProperty.LIBRARY_WINDOW_WIDTH,
+ dimensions.width);
+ get_engine().set_int_property(ConfigurableProperty.LIBRARY_WINDOW_HEIGHT,
+ dimensions.height);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // modify originals
+ //
+ public virtual bool get_modify_originals() {
+ try {
+ return get_engine().get_bool_property(ConfigurableProperty.MODIFY_ORIGINALS);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ // if we can't get a reasonable value from the configuration engine, don't modify
+ // originals
+ return false;
+ }
+ }
+
+ public virtual void set_modify_originals(bool modify_originals) {
+ try {
+ get_engine().set_bool_property(ConfigurableProperty.MODIFY_ORIGINALS, modify_originals);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // photo thumbnail scale
+ //
+ public virtual int get_photo_thumbnail_scale() {
+ try {
+ return get_engine().get_int_property(ConfigurableProperty.PHOTO_THUMBNAIL_SCALE);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ return Thumbnail.DEFAULT_SCALE;
+ }
+ }
+
+ public virtual void set_photo_thumbnail_scale(int scale) {
+ try {
+ get_engine().set_int_property(ConfigurableProperty.PHOTO_THUMBNAIL_SCALE, scale);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // printing content height
+ //
+ public virtual double get_printing_content_height() {
+ try {
+ return get_engine().get_double_property(ConfigurableProperty.PRINTING_CONTENT_HEIGHT);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return 5.0;
+ }
+ }
+
+ public virtual void set_printing_content_height(double content_height) {
+ try {
+ get_engine().set_double_property(ConfigurableProperty.PRINTING_CONTENT_HEIGHT,
+ content_height);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // printing content layout
+ //
+ public virtual int get_printing_content_layout() {
+ try {
+ return get_engine().get_int_property(ConfigurableProperty.PRINTING_CONTENT_LAYOUT) - 1;
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return 0;
+ }
+ }
+
+ public virtual void set_printing_content_layout(int layout_code) {
+ try {
+ get_engine().set_int_property(ConfigurableProperty.PRINTING_CONTENT_LAYOUT,
+ layout_code + 1);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // printing content ppi
+ //
+ public virtual int get_printing_content_ppi() {
+ try {
+ return get_engine().get_int_property(ConfigurableProperty.PRINTING_CONTENT_PPI);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return 600;
+ }
+ }
+
+ public virtual void set_printing_content_ppi(int content_ppi) {
+ try {
+ get_engine().set_int_property(ConfigurableProperty.PRINTING_CONTENT_PPI, content_ppi);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // printing content units
+ //
+ public virtual int get_printing_content_units() {
+ try {
+ return get_engine().get_int_property(ConfigurableProperty.PRINTING_CONTENT_UNITS) - 1;
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return 0;
+ }
+ }
+
+ public virtual void set_printing_content_units(int units_code) {
+ try {
+ get_engine().set_int_property(ConfigurableProperty.PRINTING_CONTENT_UNITS,
+ units_code + 1);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // printing content width
+ //
+ public virtual double get_printing_content_width() {
+ try {
+ return get_engine().get_double_property(ConfigurableProperty.PRINTING_CONTENT_WIDTH);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return 7.0;
+ }
+ }
+
+ public virtual void set_printing_content_width(double content_width) {
+ try {
+ get_engine().set_double_property(ConfigurableProperty.PRINTING_CONTENT_WIDTH,
+ content_width);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // printing images per page
+ //
+ public virtual int get_printing_images_per_page() {
+ try {
+ return get_engine().get_int_property(ConfigurableProperty.PRINTING_IMAGES_PER_PAGE) - 1;
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return 0;
+ }
+ }
+
+ public virtual void set_printing_images_per_page(int images_per_page_code) {
+ try {
+ get_engine().set_int_property(ConfigurableProperty.PRINTING_IMAGES_PER_PAGE,
+ images_per_page_code + 1);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // printing match aspect ratio
+ //
+ public virtual bool get_printing_match_aspect_ratio() {
+ try {
+ return get_engine().get_bool_property(ConfigurableProperty.PRINTING_MATCH_ASPECT_RATIO);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return true;
+ }
+ }
+
+ public virtual void set_printing_match_aspect_ratio(bool match_aspect_ratio) {
+ try {
+ get_engine().set_bool_property(ConfigurableProperty.PRINTING_MATCH_ASPECT_RATIO,
+ match_aspect_ratio);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // printing print titles
+ //
+ public virtual bool get_printing_print_titles() {
+ try {
+ return get_engine().get_bool_property(ConfigurableProperty.PRINTING_PRINT_TITLES);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return false;
+ }
+ }
+
+ public virtual void set_printing_print_titles(bool print_titles) {
+ try {
+ get_engine().set_bool_property(ConfigurableProperty.PRINTING_PRINT_TITLES,
+ print_titles);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // printing size selection
+ //
+ public virtual int get_printing_size_selection() {
+ try {
+ return get_engine().get_int_property(ConfigurableProperty.PRINTING_SIZE_SELECTION) - 1;
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return 0;
+ }
+ }
+
+ public virtual void set_printing_size_selection(int size_code) {
+ try {
+ get_engine().set_int_property(ConfigurableProperty.PRINTING_SIZE_SELECTION,
+ size_code + 1);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // printing titles font
+ //
+ public virtual string get_printing_titles_font() {
+ try {
+ return get_engine().get_string_property(ConfigurableProperty.PRINTING_TITLES_FONT);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ // in the event we can't get a reasonable value from the configuration engine, just
+ // use the system default Sans Serif font
+ return "Sans Bold 12";
+ }
+ }
+
+ public virtual void set_printing_titles_font(string font_name) {
+ try {
+ get_engine().set_string_property(ConfigurableProperty.PRINTING_TITLES_FONT, font_name);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // show welcome dialog
+ //
+ public virtual bool get_show_welcome_dialog() {
+ try {
+ return get_engine().get_bool_property(ConfigurableProperty.SHOW_WELCOME_DIALOG);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return true;
+ }
+ }
+
+ public virtual void set_show_welcome_dialog(bool show) {
+ try {
+ get_engine().set_bool_property(ConfigurableProperty.SHOW_WELCOME_DIALOG,
+ show);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // sidebar position
+ //
+ public virtual int get_sidebar_position() {
+ try {
+ return get_engine().get_int_property(ConfigurableProperty.SIDEBAR_POSITION);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return 180;
+ }
+ }
+
+ public virtual void set_sidebar_position(int position) {
+ try {
+ get_engine().set_int_property(ConfigurableProperty.SIDEBAR_POSITION, position);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // slideshow delay
+ //
+ public virtual double get_slideshow_delay() {
+ try {
+ return get_engine().get_double_property(ConfigurableProperty.SLIDESHOW_DELAY);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return 3.0;
+ }
+ }
+
+ public virtual void set_slideshow_delay(double delay) {
+ try {
+ get_engine().set_double_property(ConfigurableProperty.SLIDESHOW_DELAY, delay);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // slideshow transition delay
+ //
+ public virtual double get_slideshow_transition_delay() {
+ try {
+ return get_engine().get_double_property(
+ ConfigurableProperty.SLIDESHOW_TRANSITION_DELAY);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return 0.3;
+ }
+ }
+
+ public virtual void set_slideshow_transition_delay(double delay) {
+ try {
+ get_engine().set_double_property(ConfigurableProperty.SLIDESHOW_TRANSITION_DELAY,
+ delay);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // slideshow transition effect id
+ //
+ public virtual string get_slideshow_transition_effect_id() {
+ try {
+ return get_engine().get_string_property(
+ ConfigurableProperty.SLIDESHOW_TRANSITION_EFFECT_ID);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ // in the event we can't get a reasonable value from the configuration engine, use
+ // the null transition effect
+ return TransitionEffectsManager.NULL_EFFECT_ID;
+ }
+ }
+
+ public virtual void set_slideshow_transition_effect_id(string id) {
+ try {
+ get_engine().set_string_property(ConfigurableProperty.SLIDESHOW_TRANSITION_EFFECT_ID,
+ id);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // Slideshow show title
+ //
+ public virtual bool get_slideshow_show_title() {
+ try {
+ return get_engine().get_bool_property(ConfigurableProperty.SLIDESHOW_SHOW_TITLE);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return false;
+ }
+ }
+
+ public virtual void set_slideshow_show_title(bool show_title) {
+ try {
+ get_engine().set_bool_property(ConfigurableProperty.SLIDESHOW_SHOW_TITLE, show_title);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // use 24 hour time
+ //
+ public virtual bool get_use_24_hour_time() {
+ try {
+ return get_engine().get_bool_property(ConfigurableProperty.USE_24_HOUR_TIME);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ // if we can't get a reasonable value from the configuration system, then use the
+ // operating system default for the user's country and region.
+ return is_string_empty(Time.local(0).format("%p"));
+ }
+ }
+
+ public virtual void set_use_24_hour_time(bool use_24_hour_time) {
+ try {
+ get_engine().set_bool_property(ConfigurableProperty.USE_24_HOUR_TIME, use_24_hour_time);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // use lowercase filenames
+ //
+ public virtual bool get_use_lowercase_filenames() {
+ try {
+ return get_engine().get_bool_property(ConfigurableProperty.USE_LOWERCASE_FILENAMES);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return false;
+ }
+ }
+
+ public virtual void set_use_lowercase_filenames(bool b) {
+ try {
+ get_engine().set_bool_property(ConfigurableProperty.USE_LOWERCASE_FILENAMES, b);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // video interpreter state cookie
+ //
+ public virtual int get_video_interpreter_state_cookie() {
+ try {
+ return get_engine().get_int_property(
+ ConfigurableProperty.VIDEO_INTERPRETER_STATE_COOKIE);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+
+ return -1;
+ }
+ }
+
+ public virtual void set_video_interpreter_state_cookie(int state_cookie) {
+ try {
+ get_engine().set_int_property(ConfigurableProperty.VIDEO_INTERPRETER_STATE_COOKIE,
+ state_cookie);
+ } catch (ConfigurationError err) {
+ on_configuration_error(err);
+ }
+ }
+
+ //
+ // allow plugins to get & set arbitrary properties
+ //
+ public virtual bool get_plugin_bool(string domain, string id, string key, bool def) {
+ return get_engine().get_plugin_bool(domain, id, key, def);
+ }
+
+ public virtual void set_plugin_bool(string domain, string id, string key, bool val) {
+ get_engine().set_plugin_bool(domain, id, key, val);
+ }
+
+ public virtual double get_plugin_double(string domain, string id, string key, double def) {
+ return get_engine().get_plugin_double(domain, id, key, def);
+ }
+
+ public virtual void set_plugin_double(string domain, string id, string key, double val) {
+ get_engine().set_plugin_double(domain, id, key, val);
+ }
+
+ public virtual int get_plugin_int(string domain, string id, string key, int def) {
+ return get_engine().get_plugin_int(domain, id, key, def);
+ }
+
+ public virtual void set_plugin_int(string domain, string id, string key, int val) {
+ get_engine().set_plugin_int(domain, id, key, val);
+ }
+
+ public virtual string? get_plugin_string(string domain, string id, string key, string? def) {
+ string? result = get_engine().get_plugin_string(domain, id, key, def);
+ return (result == "") ? null : result;
+ }
+
+ public virtual void set_plugin_string(string domain, string id, string key, string? val) {
+ if (val == null)
+ val = "";
+
+ get_engine().set_plugin_string(domain, id, key, val);
+ }
+
+ public virtual void unset_plugin_key(string domain, string id, string key) {
+ get_engine().unset_plugin_key(domain, id, key);
+ }
+
+ //
+ // enable & disable plugins
+ //
+ public virtual FuzzyPropertyState is_plugin_enabled(string id) {
+ return get_engine().is_plugin_enabled(id);
+ }
+
+ public virtual void set_plugin_enabled(string id, bool enabled) {
+ get_engine().set_plugin_enabled(id, enabled);
+ }
+}
diff --git a/src/config/GSettingsEngine.vala b/src/config/GSettingsEngine.vala
new file mode 100644
index 0000000..0b2e691
--- /dev/null
+++ b/src/config/GSettingsEngine.vala
@@ -0,0 +1,475 @@
+/* Copyright 2011-2014 Yorba Foundation
+ *
+ * This software is licensed under the GNU LGPL (version 2.1 or later).
+ * See the COPYING file in this distribution.
+ */
+
+public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object {
+ private const string ROOT_SCHEMA_NAME = "org.yorba.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";
+ private const string WINDOW_PREFS_SCHEMA_NAME = PREFS_SCHEMA_NAME + ".window";
+ private const string FILES_PREFS_SCHEMA_NAME = PREFS_SCHEMA_NAME + ".files";
+ private const string EDITING_PREFS_SCHEMA_NAME = PREFS_SCHEMA_NAME + ".editing";
+ private const string VIDEO_SCHEMA_NAME = ROOT_SCHEMA_NAME + ".video";
+ private const string PRINTING_SCHEMA_NAME = ROOT_SCHEMA_NAME + ".printing";
+ private const string SHARING_SCHEMA_NAME = ROOT_SCHEMA_NAME + ".sharing";
+ private const string IMPORTING_SCHEMA_NAME = ROOT_SCHEMA_NAME + ".dataimports";
+ private const string CROP_SCHEMA_NAME = ROOT_SCHEMA_NAME + ".crop-settings";
+ private const string SYSTEM_DESKTOP_SCHEMA_NAME = "org.gnome.desktop.background";
+ private const string SYSTEM_SCREENSAVER_SCHEMA_NAME = "org.gnome.desktop.screensaver";
+ private const string PLUGINS_ENABLE_DISABLE_SCHEMA_NAME = ROOT_SCHEMA_NAME +
+ ".plugins.enable-state";
+
+ private Gee.Set<string> known_schemas;
+ private string[] schema_names;
+ private string[] key_names;
+
+ public GSettingsConfigurationEngine() {
+ known_schemas = new Gee.HashSet<string>();
+
+ foreach (string current_schema in Settings.list_schemas())
+ known_schemas.add(current_schema);
+
+ schema_names = new string[ConfigurableProperty.NUM_PROPERTIES];
+
+ schema_names[ConfigurableProperty.AUTO_IMPORT_FROM_LIBRARY] = FILES_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.BG_COLOR_NAME] = UI_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.COMMIT_METADATA_TO_MASTERS] = FILES_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.DESKTOP_BACKGROUND_FILE] = SYSTEM_DESKTOP_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.DESKTOP_BACKGROUND_MODE] = SYSTEM_DESKTOP_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.SCREENSAVER_FILE] = SYSTEM_SCREENSAVER_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.SCREENSAVER_MODE] = SYSTEM_SCREENSAVER_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.DIRECTORY_PATTERN] = FILES_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.DIRECTORY_PATTERN_CUSTOM] = FILES_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.DIRECT_WINDOW_HEIGHT] = WINDOW_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.DIRECT_WINDOW_MAXIMIZE] = WINDOW_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.DIRECT_WINDOW_WIDTH] = WINDOW_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.DISPLAY_BASIC_PROPERTIES] = UI_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.DISPLAY_EXTENDED_PROPERTIES] = UI_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.DISPLAY_SIDEBAR] = 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;
+ schema_names[ConfigurableProperty.DISPLAY_PHOTO_TITLES] = UI_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.DISPLAY_PHOTO_COMMENTS] = UI_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.DISPLAY_EVENT_COMMENTS] = UI_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.EVENT_PHOTOS_SORT_ASCENDING] = UI_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.EVENT_PHOTOS_SORT_BY] = UI_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.EVENTS_SORT_ASCENDING] = UI_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.EXTERNAL_PHOTO_APP] = EDITING_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.EXTERNAL_RAW_APP] = EDITING_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.HIDE_PHOTOS_ALREADY_IMPORTED] = UI_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.IMPORT_DIR] = FILES_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.KEEP_RELATIVITY] = UI_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.LAST_CROP_HEIGHT] = CROP_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.LAST_CROP_MENU_CHOICE] = CROP_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.LAST_CROP_WIDTH] = CROP_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.LAST_USED_SERVICE] = SHARING_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.LAST_USED_DATAIMPORTS_SERVICE] = IMPORTING_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.LIBRARY_PHOTOS_SORT_ASCENDING] = UI_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.LIBRARY_PHOTOS_SORT_BY] = UI_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.LIBRARY_WINDOW_HEIGHT] = WINDOW_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.LIBRARY_WINDOW_MAXIMIZE] = WINDOW_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.LIBRARY_WINDOW_WIDTH] = WINDOW_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.MODIFY_ORIGINALS] = UI_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.PHOTO_THUMBNAIL_SCALE] = UI_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.PIN_TOOLBAR_STATE] = UI_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.PRINTING_CONTENT_HEIGHT] = PRINTING_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.PRINTING_CONTENT_LAYOUT] = PRINTING_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.PRINTING_CONTENT_PPI] = PRINTING_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.PRINTING_CONTENT_UNITS] = PRINTING_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.PRINTING_CONTENT_WIDTH] = PRINTING_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.PRINTING_IMAGES_PER_PAGE] = PRINTING_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.PRINTING_MATCH_ASPECT_RATIO] = PRINTING_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.PRINTING_PRINT_TITLES] = PRINTING_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.PRINTING_SIZE_SELECTION] = PRINTING_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.PRINTING_TITLES_FONT] = PRINTING_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.RAW_DEVELOPER_DEFAULT] = FILES_PREFS_SCHEMA_NAME;;
+ schema_names[ConfigurableProperty.SHOW_WELCOME_DIALOG] = UI_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.SIDEBAR_POSITION] = UI_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.SLIDESHOW_DELAY] = SLIDESHOW_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.SLIDESHOW_TRANSITION_DELAY] = SLIDESHOW_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.SLIDESHOW_TRANSITION_EFFECT_ID] = SLIDESHOW_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.SLIDESHOW_SHOW_TITLE] = SLIDESHOW_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.USE_24_HOUR_TIME] = UI_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.USE_LOWERCASE_FILENAMES] = FILES_PREFS_SCHEMA_NAME;
+ schema_names[ConfigurableProperty.VIDEO_INTERPRETER_STATE_COOKIE] = VIDEO_SCHEMA_NAME;
+
+ key_names = new string[ConfigurableProperty.NUM_PROPERTIES];
+
+ key_names[ConfigurableProperty.AUTO_IMPORT_FROM_LIBRARY] = "auto-import";
+ key_names[ConfigurableProperty.BG_COLOR_NAME] = "background-color";
+ key_names[ConfigurableProperty.COMMIT_METADATA_TO_MASTERS] = "commit-metadata";
+ key_names[ConfigurableProperty.DESKTOP_BACKGROUND_FILE] = "picture-uri";
+ key_names[ConfigurableProperty.DESKTOP_BACKGROUND_MODE] = "picture-options";
+ key_names[ConfigurableProperty.SCREENSAVER_FILE] = "picture-uri";
+ key_names[ConfigurableProperty.SCREENSAVER_MODE] = "picture-options";
+ key_names[ConfigurableProperty.DIRECTORY_PATTERN] = "directory-pattern";
+ key_names[ConfigurableProperty.DIRECTORY_PATTERN_CUSTOM] = "directory-pattern-custom";
+ key_names[ConfigurableProperty.DIRECT_WINDOW_HEIGHT] = "direct-height";
+ key_names[ConfigurableProperty.DIRECT_WINDOW_MAXIMIZE] = "direct-maximize";
+ key_names[ConfigurableProperty.DIRECT_WINDOW_WIDTH] = "direct-width";
+ key_names[ConfigurableProperty.DISPLAY_BASIC_PROPERTIES] = "display-basic-properties";
+ key_names[ConfigurableProperty.DISPLAY_EXTENDED_PROPERTIES] = "display-extended-properties";
+ key_names[ConfigurableProperty.DISPLAY_SIDEBAR] = "display-sidebar";
+ 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";
+ key_names[ConfigurableProperty.DISPLAY_PHOTO_TITLES] = "display-photo-titles";
+ key_names[ConfigurableProperty.DISPLAY_PHOTO_COMMENTS] = "display-photo-comments";
+ key_names[ConfigurableProperty.DISPLAY_EVENT_COMMENTS] = "display-event-comments";
+ key_names[ConfigurableProperty.EVENT_PHOTOS_SORT_ASCENDING] = "event-photos-sort-ascending";
+ key_names[ConfigurableProperty.EVENT_PHOTOS_SORT_BY] = "event-photos-sort-by";
+ key_names[ConfigurableProperty.EVENTS_SORT_ASCENDING] = "events-sort-ascending";
+ key_names[ConfigurableProperty.EXTERNAL_PHOTO_APP] = "external-photo-editor";
+ key_names[ConfigurableProperty.EXTERNAL_RAW_APP] = "external-raw-editor";
+ key_names[ConfigurableProperty.HIDE_PHOTOS_ALREADY_IMPORTED] = "hide-photos-already-imported";
+ key_names[ConfigurableProperty.IMPORT_DIR] = "import-dir";
+ key_names[ConfigurableProperty.KEEP_RELATIVITY] = "keep-relativity";
+ key_names[ConfigurableProperty.LAST_CROP_HEIGHT] = "last-crop-height";
+ key_names[ConfigurableProperty.LAST_CROP_MENU_CHOICE] = "last-crop-menu-choice";
+ key_names[ConfigurableProperty.LAST_CROP_WIDTH] = "last-crop-width";
+ key_names[ConfigurableProperty.LAST_USED_SERVICE] = "last-used-service";
+ key_names[ConfigurableProperty.LAST_USED_DATAIMPORTS_SERVICE] = "last-used-dataimports-service";
+ key_names[ConfigurableProperty.LIBRARY_PHOTOS_SORT_ASCENDING] = "library-photos-sort-ascending";
+ key_names[ConfigurableProperty.LIBRARY_PHOTOS_SORT_BY] = "library-photos-sort-by";
+ key_names[ConfigurableProperty.LIBRARY_WINDOW_HEIGHT] = "library-height";
+ key_names[ConfigurableProperty.LIBRARY_WINDOW_MAXIMIZE] = "library-maximize";
+ key_names[ConfigurableProperty.LIBRARY_WINDOW_WIDTH] = "library-width";
+ key_names[ConfigurableProperty.MODIFY_ORIGINALS] = "modify-originals";
+ key_names[ConfigurableProperty.PHOTO_THUMBNAIL_SCALE] = "photo-thumbnail-scale";
+ key_names[ConfigurableProperty.PIN_TOOLBAR_STATE] = "pin-toolbar-state";
+ key_names[ConfigurableProperty.PRINTING_CONTENT_HEIGHT] = "content-height";
+ key_names[ConfigurableProperty.PRINTING_CONTENT_LAYOUT] = "content-layout";
+ key_names[ConfigurableProperty.PRINTING_CONTENT_PPI] = "content-ppi";
+ key_names[ConfigurableProperty.PRINTING_CONTENT_UNITS] = "content-units";
+ key_names[ConfigurableProperty.PRINTING_CONTENT_WIDTH] = "content-width";
+ key_names[ConfigurableProperty.PRINTING_IMAGES_PER_PAGE] = "images-per-page";
+ key_names[ConfigurableProperty.PRINTING_MATCH_ASPECT_RATIO] = "match-aspect-ratio";
+ key_names[ConfigurableProperty.PRINTING_PRINT_TITLES] = "print-titles";
+ key_names[ConfigurableProperty.PRINTING_SIZE_SELECTION] = "size-selection";
+ key_names[ConfigurableProperty.PRINTING_TITLES_FONT] = "titles-font";
+ key_names[ConfigurableProperty.RAW_DEVELOPER_DEFAULT] = "raw-developer-default";
+ key_names[ConfigurableProperty.SHOW_WELCOME_DIALOG] = "show-welcome-dialog";
+ key_names[ConfigurableProperty.SIDEBAR_POSITION] = "sidebar-position";
+ key_names[ConfigurableProperty.SLIDESHOW_DELAY] = "delay";
+ key_names[ConfigurableProperty.SLIDESHOW_TRANSITION_DELAY] = "transition-delay";
+ key_names[ConfigurableProperty.SLIDESHOW_TRANSITION_EFFECT_ID] = "transition-effect-id";
+ key_names[ConfigurableProperty.SLIDESHOW_SHOW_TITLE] = "show-title";
+ key_names[ConfigurableProperty.USE_24_HOUR_TIME] = "use-24-hour-time";
+ key_names[ConfigurableProperty.USE_LOWERCASE_FILENAMES] = "use-lowercase-filenames";
+ key_names[ConfigurableProperty.VIDEO_INTERPRETER_STATE_COOKIE] = "interpreter-state-cookie";
+ }
+
+ private bool schema_has_key(Settings schema_object, string key) {
+ foreach (string current_key in schema_object.list_keys()) {
+ if (current_key == key)
+ return true;
+ }
+
+ return false;
+ }
+
+ private void check_key_valid(string schema, string key) throws ConfigurationError {
+ if (!known_schemas.contains(schema))
+ throw new ConfigurationError.ENGINE_ERROR("schema '%s' is not installed".printf(schema));
+
+ Settings schema_object = new Settings(schema);
+
+ if (!schema_has_key(schema_object, key))
+ throw new ConfigurationError.ENGINE_ERROR("schema '%s' does not define key '%s'".printf(
+ schema, key));
+ }
+
+ private bool get_gs_bool(string schema, string key) throws ConfigurationError {
+ check_key_valid(schema, key);
+
+ Settings schema_object = new Settings(schema);
+
+ return schema_object.get_boolean(key);
+ }
+
+ private void set_gs_bool(string schema, string key, bool value) throws ConfigurationError {
+ check_key_valid(schema, key);
+
+ Settings schema_object = new Settings(schema);
+
+ schema_object.set_boolean(key, value);
+ }
+
+ private int get_gs_int(string schema, string key) throws ConfigurationError {
+ check_key_valid(schema, key);
+
+ Settings schema_object = new Settings(schema);
+
+ return schema_object.get_int(key);
+ }
+
+ private void set_gs_int(string schema, string key, int value) throws ConfigurationError {
+ check_key_valid(schema, key);
+
+ Settings schema_object = new Settings(schema);
+
+ schema_object.set_int(key, value);
+ }
+
+ private double get_gs_double(string schema, string key) throws ConfigurationError {
+ check_key_valid(schema, key);
+
+ Settings schema_object = new Settings(schema);
+
+ return schema_object.get_double(key);
+ }
+
+ private void set_gs_double(string schema, string key, double value) throws ConfigurationError {
+ check_key_valid(schema, key);
+
+ Settings schema_object = new Settings(schema);
+
+ schema_object.set_double(key, value);
+ }
+
+ private string get_gs_string(string schema, string key) throws ConfigurationError {
+ check_key_valid(schema, key);
+
+ Settings schema_object = new Settings(schema);
+
+ return schema_object.get_string(key);
+ }
+
+ private void set_gs_string(string schema, string key, string value) throws ConfigurationError {
+ check_key_valid(schema, key);
+
+ Settings schema_object = new Settings(schema);
+
+ schema_object.set_string(key, value);
+ }
+
+ private void reset_gs_to_default(string schema, string key) throws ConfigurationError {
+ check_key_valid(schema, key);
+
+ Settings schema_object = new Settings(schema);
+
+ schema_object.reset(key);
+ }
+
+ private static string? clean_plugin_id(string id) {
+ string cleaned = id.replace("/", "-");
+ cleaned = cleaned.strip();
+
+ return !is_string_empty(cleaned) ? cleaned : null;
+ }
+
+ private static string get_plugin_enable_disable_name(string id) {
+ string? cleaned_id = clean_plugin_id(id);
+ if (cleaned_id == null)
+ cleaned_id = "default";
+
+ cleaned_id = cleaned_id.replace("org.yorba.shotwell.", "");
+ cleaned_id = cleaned_id.replace(".", "-");
+
+ return cleaned_id;
+ }
+
+ private static string make_plugin_schema_name(string domain, string id) {
+ string? cleaned_id = clean_plugin_id(id);
+ if (cleaned_id == null)
+ cleaned_id = "default";
+ cleaned_id = cleaned_id.replace(".", "-");
+
+ return "org.yorba.shotwell.%s.%s".printf(domain, cleaned_id);
+ }
+
+ private static string make_gsettings_key(string gconf_key) {
+ return gconf_key.replace("_", "-");
+ }
+
+ public string get_name() {
+ return "GSettings";
+ }
+
+ public int get_int_property(ConfigurableProperty p) throws ConfigurationError {
+ return get_gs_int(schema_names[p], key_names[p]);
+ }
+
+ public void set_int_property(ConfigurableProperty p, int val) throws ConfigurationError {
+ set_gs_int(schema_names[p], key_names[p], val);
+ property_changed(p);
+ }
+
+ public string get_string_property(ConfigurableProperty p) throws ConfigurationError {
+ string gs_result = get_gs_string(schema_names[p], key_names[p]);
+
+ // if we're getting the desktop background file, convert the file uri we get back from
+ // GSettings into a file path
+ string result = gs_result;
+ if (p == ConfigurableProperty.DESKTOP_BACKGROUND_FILE) {
+ result = gs_result.substring(7);
+ }
+
+ return result;
+ }
+
+ public void set_string_property(ConfigurableProperty p, string val) throws ConfigurationError {
+ // if we're setting the desktop background/screensaver file, convert the filename into a file URI
+ string converted_val = val;
+ if (p == ConfigurableProperty.DESKTOP_BACKGROUND_FILE
+ || p == ConfigurableProperty.SCREENSAVER_FILE) {
+ converted_val = "file://" + val;
+ }
+
+ set_gs_string(schema_names[p], key_names[p], converted_val);
+ property_changed(p);
+ }
+
+ public bool get_bool_property(ConfigurableProperty p) throws ConfigurationError {
+ return get_gs_bool(schema_names[p], key_names[p]);
+ }
+
+ public void set_bool_property(ConfigurableProperty p, bool val) throws ConfigurationError {
+ set_gs_bool(schema_names[p], key_names[p], val);
+ property_changed(p);
+ }
+
+ public double get_double_property(ConfigurableProperty p) throws ConfigurationError {
+ return get_gs_double(schema_names[p], key_names[p]);
+ }
+
+ public void set_double_property(ConfigurableProperty p, double val) throws ConfigurationError {
+ set_gs_double(schema_names[p], key_names[p], val);
+ property_changed(p);
+ }
+
+ public bool get_plugin_bool(string domain, string id, string key, bool def) {
+ string schema_name = make_plugin_schema_name(domain, id);
+
+ try {
+ return get_gs_bool(schema_name, make_gsettings_key(key));
+ } catch (ConfigurationError err) {
+ critical("GSettingsConfigurationEngine: error: %s", err.message);
+ return def;
+ }
+ }
+
+ public void set_plugin_bool(string domain, string id, string key, bool val) {
+ string schema_name = make_plugin_schema_name(domain, id);
+
+ try {
+ set_gs_bool(schema_name, make_gsettings_key(key), val);
+ } catch (ConfigurationError err) {
+ critical("GSettingsConfigurationEngine: error: %s", err.message);
+ }
+ }
+
+ public double get_plugin_double(string domain, string id, string key, double def) {
+ string schema_name = make_plugin_schema_name(domain, id);
+
+ try {
+ return get_gs_double(schema_name, make_gsettings_key(key));
+ } catch (ConfigurationError err) {
+ critical("GSettingsConfigurationEngine: error: %s", err.message);
+ return def;
+ }
+ }
+
+ public void set_plugin_double(string domain, string id, string key, double val) {
+ string schema_name = make_plugin_schema_name(domain, id);
+
+ try {
+ set_gs_double(schema_name, make_gsettings_key(key), val);
+ } catch (ConfigurationError err) {
+ critical("GSettingsConfigurationEngine: error: %s", err.message);
+ }
+ }
+
+ public int get_plugin_int(string domain, string id, string key, int def) {
+ string schema_name = make_plugin_schema_name(domain, id);
+
+ try {
+ return get_gs_int(schema_name, make_gsettings_key(key));
+ } catch (ConfigurationError err) {
+ critical("GSettingsConfigurationEngine: error: %s", err.message);
+ return def;
+ }
+ }
+
+ public void set_plugin_int(string domain, string id, string key, int val) {
+ string schema_name = make_plugin_schema_name(domain, id);
+
+ try {
+ set_gs_int(schema_name, make_gsettings_key(key), val);
+ } catch (ConfigurationError err) {
+ critical("GSettingsConfigurationEngine: error: %s", err.message);
+ }
+ }
+
+ public string? get_plugin_string(string domain, string id, string key, string? def) {
+ string schema_name = make_plugin_schema_name(domain, id);
+
+ try {
+ return get_gs_string(schema_name, make_gsettings_key(key));
+ } catch (ConfigurationError err) {
+ critical("GSettingsConfigurationEngine: error: %s", err.message);
+ return def;
+ }
+ }
+
+ public void set_plugin_string(string domain, string id, string key, string? val) {
+ string schema_name = make_plugin_schema_name(domain, id);
+
+ try {
+ set_gs_string(schema_name, make_gsettings_key(key), val);
+ } catch (ConfigurationError err) {
+ critical("GSettingsConfigurationEngine: error: %s", err.message);
+ }
+ }
+
+ public void unset_plugin_key(string domain, string id, string key) {
+ string schema_name = make_plugin_schema_name(domain, id);
+
+ try {
+ reset_gs_to_default(schema_name, make_gsettings_key(key));
+ } catch (ConfigurationError err) {
+ critical("GSettingsConfigurationEngine: error: %s", err.message);
+ }
+ }
+
+ public FuzzyPropertyState is_plugin_enabled(string id) {
+ string enable_disable_name = get_plugin_enable_disable_name(id);
+
+ try {
+ return (get_gs_bool(PLUGINS_ENABLE_DISABLE_SCHEMA_NAME, enable_disable_name)) ?
+ FuzzyPropertyState.ENABLED : FuzzyPropertyState.DISABLED;
+ } catch (ConfigurationError err) {
+ critical("GSettingsConfigurationEngine: error: %s", err.message);
+ return FuzzyPropertyState.UNKNOWN;
+ }
+ }
+
+ public void set_plugin_enabled(string id, bool enabled) {
+ string enable_disable_name = get_plugin_enable_disable_name(id);
+
+ try {
+ set_gs_bool(PLUGINS_ENABLE_DISABLE_SCHEMA_NAME, enable_disable_name, enabled);
+ } catch (ConfigurationError err) {
+ critical("GSettingsConfigurationEngine: error: %s", err.message);
+ }
+ }
+
+ /*! @brief Migrates settings data over from old-style /apps/ paths to /org/yorba/ 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() {
+ string cmd_line = "sh " + AppDirs.get_settings_migrator_bin().get_path();
+
+ try {
+ Process.spawn_command_line_sync(cmd_line);
+ } catch (Error err) {
+ message("Error running shotwell-settings-migrator: %s", err.message);
+ }
+ }
+
+}
diff --git a/src/config/mk/config.mk b/src/config/mk/config.mk
new file mode 100644
index 0000000..e06dedf
--- /dev/null
+++ b/src/config/mk/config.mk
@@ -0,0 +1,29 @@
+
+# UNIT_NAME is the Vala namespace. A file named UNIT_NAME.vala must be in this directory with
+# a init() and terminate() function declared in the namespace.
+UNIT_NAME := Config
+
+# UNIT_DIR should match the subdirectory the files are located in. Generally UNIT_NAME in all
+# lowercase. The name of this file should be UNIT_DIR.mk.
+UNIT_DIR := config
+
+# All Vala files in the unit should be listed here with no subdirectory prefix.
+#
+# NOTE: Do *not* include the unit's master file, i.e. UNIT_NAME.vala.
+UNIT_FILES := \
+ ConfigurationInterfaces.vala \
+ GSettingsEngine.vala
+
+# Any unit this unit relies upon (and should be initialized before it's initialized) should
+# be listed here using its Vala namespace.
+#
+# NOTE: All units are assumed to rely upon the unit-unit. Do not include that here.
+UNIT_USES :=
+
+# List any additional files that are used in the build process as a part of this unit that should
+# be packaged in the tarball. File names should be relative to the unit's home directory.
+UNIT_RC :=
+
+# unitize.mk must be called at the end of each UNIT_DIR.mk file.
+include unitize.mk
+