[shotwell] Persist export dialog settings



commit 8b95f0de193e63fc7e87d1121d3ef8b26dceb86c
Author: Jens Georg <mail jensge org>
Date:   Tue Oct 4 22:33:14 2016 +0200

    Persist export dialog settings
    
    Based on original patch by Jonas Bushart.
    
    Signed-off-by: Jens Georg <mail jensge org>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=716259

 misc/org.yorba.shotwell.gschema.xml     |   45 +++++++++
 src/Dialogs.vala                        |   22 ++++
 src/config/ConfigurationInterfaces.vala |  164 +++++++++++++++++++++++++++++++
 src/config/GSettingsEngine.vala         |   15 +++
 4 files changed, 246 insertions(+), 0 deletions(-)
---
diff --git a/misc/org.yorba.shotwell.gschema.xml b/misc/org.yorba.shotwell.gschema.xml
index 963a31e..d39c3a2 100644
--- a/misc/org.yorba.shotwell.gschema.xml
+++ b/misc/org.yorba.shotwell.gschema.xml
@@ -14,6 +14,7 @@
     <child name="window" schema="org.yorba.shotwell.preferences.window" />
     <child name="files" schema="org.yorba.shotwell.preferences.files" />
     <child name="editing" schema="org.yorba.shotwell.preferences.editing" />
+    <child name="export" schema="org.yorba.shotwell.preferences.export" />
 </schema>
 
 <schema id="org.yorba.shotwell.preferences.ui" path="/org/yorba/shotwell/preferences/ui/">
@@ -314,6 +315,50 @@
     </key>
 </schema>
 
+<schema id="org.yorba.shotwell.preferences.export" path="/org/yorba/shotwell/preferences/export/">
+    <key name="constraint" type="i">
+        <default>0</default>
+        <summary>Setting in export dialog: how to trim images</summary>
+        <description>Setting in export dialog: how to trim images</description>
+    </key>
+
+    <key name="export-metadata" type="b">
+        <default>true</default>
+        <summary>export metadata</summary>
+        <description>Setting in export dialog: option to export metadata</description>
+    </key>
+
+    <key name="export-format-mode" type="i">
+        <default>0</default>
+        <summary>format setting, special value</summary>
+        <description>Setting in export dialog: format setting, special value</description>
+    </key>
+
+    <key name="is-set" type="b">
+        <default>false</default>
+        <summary>are these datas set by Shotwell</summary>
+        <description>Will be set to true the first time data is saved in the export schema. This helps 
Shotwell to use this data only if they are set by Shotwell</description>
+    </key>
+
+    <key name="photo-file-format" type="i">
+        <default>0</default>
+        <summary>format setting, type value</summary>
+        <description>Setting in export dialog: format setting, type value</description>
+    </key>
+
+    <key name="quality" type="i">
+        <default>0</default>
+        <summary>jpeg quality option</summary>
+        <description>Setting in export dialog: jpeg quality option</description>
+    </key>
+
+    <key name="scale" type="i">
+        <default>0</default>
+        <summary>maximal size of image</summary>
+        <description>Setting in export dialog: maximal size of image</description>
+    </key>
+</schema>
+
 <schema id="org.yorba.shotwell.sharing" path="/org/yorba/shotwell/sharing/">
     <key name="last-used-service" type="s">
         <default>""</default>
diff --git a/src/Dialogs.vala b/src/Dialogs.vala
index 1ae1d1a..351c693 100644
--- a/src/Dialogs.vala
+++ b/src/Dialogs.vala
@@ -172,6 +172,17 @@ public class ExportDialog : Gtk.Dialog {
         this.title = title;
         resizable = false;
 
+        //get information about the export settings out of our config backend
+        Config.Facade config = Config.Facade.get_instance();
+        if (config.get_export_is_set()) {
+            current_parameters.mode = config.get_export_export_format_mode(); //ExportFormatMode
+            current_parameters.specified_format = config.get_export_photo_file_format(); //PhotoFileFormat
+            current_parameters.quality = config.get_export_quality(); //quality
+            current_parameters.export_metadata = config.get_export_export_metadata(); //export metadata
+            current_constraint = config.get_export_constraint(); //constraint
+            current_scale = config.get_export_scale(); //scale
+        }
+
         quality_combo = new Gtk.ComboBoxText();
         int ctr = 0;
         foreach (Jpeg.Quality quality in QUALITY_ARRAY) {
@@ -339,6 +350,17 @@ public class ExportDialog : Gtk.Dialog {
                 if (current_parameters.specified_format == PhotoFileFormat.JFIF)
                     parameters.quality = current_parameters.quality = 
QUALITY_ARRAY[quality_combo.get_active()];
             }
+
+            //save current settings in config backend for reusing later
+            Config.Facade config = Config.Facade.get_instance();
+            config.set_export_is_set(true);
+
+            config.set_export_export_format_mode(current_parameters.mode); //ExportFormatMode
+            config.set_export_photo_file_format(current_parameters.specified_format); //PhotoFileFormat
+            config.set_export_quality(current_parameters.quality); //quality
+            config.set_export_export_metadata(current_parameters.export_metadata); //export metadata
+            config.set_export_constraint(current_constraint); //constraint
+            config.set_export_scale(current_scale); //scale
         } else {
             scale = 0;
             constraint = ScaleConstraint.ORIGINAL;
diff --git a/src/config/ConfigurationInterfaces.vala b/src/config/ConfigurationInterfaces.vala
index 9414f49..b60c19f 100644
--- a/src/config/ConfigurationInterfaces.vala
+++ b/src/config/ConfigurationInterfaces.vala
@@ -45,6 +45,13 @@ public enum ConfigurableProperty {
     EVENT_PHOTOS_SORT_ASCENDING,
     EVENT_PHOTOS_SORT_BY,
     EVENTS_SORT_ASCENDING,
+    EXPORT_CONSTRAINT,
+    EXPORT_EXPORT_FORMAT_MODE,
+    EXPORT_EXPORT_METADATA,
+    EXPORT_IS_SET,
+    EXPORT_PHOTO_FILE_FORMAT,
+    EXPORT_QUALITY,
+    EXPORT_SCALE,
     EXTERNAL_PHOTO_APP,
     EXTERNAL_RAW_APP,
     HIDE_PHOTOS_ALREADY_IMPORTED,
@@ -164,6 +171,27 @@ public enum ConfigurableProperty {
             case EVENTS_SORT_ASCENDING:
                 return "EVENTS_SORT_ASCENDING";
                 
+            case EXPORT_CONSTRAINT:
+                return "EXPORT_CONSTRAINT";
+
+            case EXPORT_EXPORT_FORMAT_MODE:
+                return "EXPORT_EXPORT_FORMAT_MODE";
+
+            case EXPORT_EXPORT_METADATA:
+                return "EXPORT_EXPORT_METADATA";
+
+            case EXPORT_IS_SET:
+                return "EXPORT_IS_SET";
+
+            case EXPORT_PHOTO_FILE_FORMAT:
+                return "EXPORT_PHOTO_FILE_FORMAT";
+
+            case EXPORT_QUALITY:
+                return "EXPORT_QUALITY";
+
+            case EXPORT_SCALE:
+                return "EXPORT_SCALE";
+
             case EXTERNAL_PHOTO_APP:
                 return "EXTERNAL_PHOTO_APP";
                 
@@ -877,6 +905,142 @@ public abstract class ConfigurationFacade : Object {
     }
 
     //
+    // export dialog settings
+    //
+    public virtual ScaleConstraint get_export_constraint() {
+        try {
+            return (ScaleConstraint) get_engine().get_int_property(ConfigurableProperty.EXPORT_CONSTRAINT);
+        } catch (ConfigurationError err) {
+            on_configuration_error(err);
+
+            return 0;
+        }
+    }
+
+    public virtual void set_export_constraint(ScaleConstraint constraint) {
+        try {
+            get_engine().set_int_property(ConfigurableProperty.EXPORT_CONSTRAINT, ( (int) constraint));
+        } catch (ConfigurationError err) {
+            on_configuration_error(err);
+            return;
+        }
+    }
+
+    public virtual ExportFormatMode get_export_export_format_mode() {
+        try {
+            return (ExportFormatMode) 
get_engine().get_int_property(ConfigurableProperty.EXPORT_EXPORT_FORMAT_MODE);
+        } catch (ConfigurationError err) {
+            on_configuration_error(err);
+
+            return 0;
+        }
+    }
+
+    public virtual void set_export_export_format_mode(ExportFormatMode export_format_mode) {
+        try {
+            get_engine().set_int_property(ConfigurableProperty.EXPORT_EXPORT_FORMAT_MODE, ( (int) 
export_format_mode ));
+        } catch (ConfigurationError err) {
+            on_configuration_error(err);
+            return;
+        }
+    }
+
+    public virtual bool get_export_export_metadata() {
+        try {
+            return get_engine().get_bool_property(ConfigurableProperty.EXPORT_EXPORT_METADATA);
+        } catch (ConfigurationError err) {
+            on_configuration_error(err);
+
+            return false;
+        }
+    }
+
+    public virtual void set_export_export_metadata(bool export_metadata) {
+        try {
+            get_engine().set_bool_property(ConfigurableProperty.EXPORT_EXPORT_METADATA, export_metadata);
+        } catch (ConfigurationError err) {
+            on_configuration_error(err);
+            return;
+        }
+    }
+
+    public virtual bool get_export_is_set() {
+        try {
+            return get_engine().get_bool_property(ConfigurableProperty.EXPORT_IS_SET);
+        } catch (ConfigurationError err) {
+            on_configuration_error(err);
+
+            return false;
+        }
+    }
+
+    public virtual void set_export_is_set(bool is_set) {
+        try {
+            get_engine().set_bool_property(ConfigurableProperty.EXPORT_IS_SET, is_set);
+        } catch (ConfigurationError err) {
+            on_configuration_error(err);
+            return;
+        }
+    }
+
+    public virtual PhotoFileFormat get_export_photo_file_format() {
+        try {
+            return PhotoFileFormat.unserialize( 
get_engine().get_int_property(ConfigurableProperty.EXPORT_PHOTO_FILE_FORMAT) );
+        } catch (ConfigurationError err) {
+            on_configuration_error(err);
+
+            return 0;
+        }
+    }
+
+    public virtual void set_export_photo_file_format(PhotoFileFormat photo_file_format) {
+        try {
+            get_engine().set_int_property(ConfigurableProperty.EXPORT_PHOTO_FILE_FORMAT, 
photo_file_format.serialize());
+        } catch (ConfigurationError err) {
+            on_configuration_error(err);
+            return;
+        }
+    }
+
+    public virtual Jpeg.Quality get_export_quality() {
+        try {
+            return (Jpeg.Quality) get_engine().get_int_property(ConfigurableProperty.EXPORT_QUALITY);
+        } catch (ConfigurationError err) {
+            on_configuration_error(err);
+
+            return 0;
+        }
+    }
+
+    public virtual void set_export_quality(Jpeg.Quality quality) {
+        try {
+            get_engine().set_int_property(ConfigurableProperty.EXPORT_QUALITY, ( (int) quality ));
+        } catch (ConfigurationError err) {
+            on_configuration_error(err);
+            return;
+        }
+    }
+
+    public virtual int get_export_scale() {
+        try {
+            return get_engine().get_int_property(ConfigurableProperty.EXPORT_SCALE);
+        } catch (ConfigurationError err) {
+            on_configuration_error(err);
+
+            return 0;
+        }
+    }
+
+    public virtual void set_export_scale(int scale) {
+        try {
+            get_engine().set_int_property(ConfigurableProperty.EXPORT_SCALE, scale);
+        } catch (ConfigurationError err) {
+            on_configuration_error(err);
+            return;
+        }
+    }
+
+    //
     // Default RAW developer.
     //
     public virtual RawDeveloper get_default_raw_developer() {
diff --git a/src/config/GSettingsEngine.vala b/src/config/GSettingsEngine.vala
index daee354..7e691c6 100644
--- a/src/config/GSettingsEngine.vala
+++ b/src/config/GSettingsEngine.vala
@@ -12,6 +12,7 @@ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object {
     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 EXPORT_PREFS_SCHEMA_NAME = PREFS_SCHEMA_NAME + ".export";
     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";
@@ -53,6 +54,13 @@ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object {
         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.EXPORT_CONSTRAINT] = EXPORT_PREFS_SCHEMA_NAME;
+        schema_names[ConfigurableProperty.EXPORT_EXPORT_FORMAT_MODE] =  EXPORT_PREFS_SCHEMA_NAME;
+        schema_names[ConfigurableProperty.EXPORT_EXPORT_METADATA] =  EXPORT_PREFS_SCHEMA_NAME;
+        schema_names[ConfigurableProperty.EXPORT_IS_SET] =  EXPORT_PREFS_SCHEMA_NAME;
+        schema_names[ConfigurableProperty.EXPORT_PHOTO_FILE_FORMAT] =  EXPORT_PREFS_SCHEMA_NAME;
+        schema_names[ConfigurableProperty.EXPORT_QUALITY] =  EXPORT_PREFS_SCHEMA_NAME;
+        schema_names[ConfigurableProperty.EXPORT_SCALE] =  EXPORT_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;
@@ -119,6 +127,13 @@ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object {
         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.EXPORT_CONSTRAINT] = "constraint";
+        key_names[ConfigurableProperty.EXPORT_EXPORT_FORMAT_MODE] =  "export-format-mode";
+        key_names[ConfigurableProperty.EXPORT_EXPORT_METADATA] =  "export-metadata";
+        key_names[ConfigurableProperty.EXPORT_IS_SET] =  "is-set";
+        key_names[ConfigurableProperty.EXPORT_PHOTO_FILE_FORMAT] =  "photo-file-format";
+        key_names[ConfigurableProperty.EXPORT_QUALITY] =  "quality";
+        key_names[ConfigurableProperty.EXPORT_SCALE] =  "scale";
         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";


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]