Commit e3c78dc5 authored by Jens Georg's avatar Jens Georg

Use GSettings default for export dialog

Signed-off-by: Jens Georg's avatarJens Georg <mail@jensge.org>
parent 8b95f0de
......@@ -315,9 +315,40 @@
</key>
</schema>
<enum id="org.yorba.shotwell.ScaleConstraint">
<value value="0" nick="ORIGINAL" />
<value value="1" nick="DIMENSIONS" />
<value value="2" nick="WIDTH" />
<value value="3" nick="HEIGHT" />
<value value="4" nick="FILL_VIEWPORT" />
</enum>
<enum id="org.yorba.shotwell.ExportFormatMode">
<value value="0" nick="UNMODIFIED" />
<value value="1" nick="CURRENT" />
<value value="2" nick="SPECIFIED" />
<value value="3" nick="LAS" />
</enum>
<enum id="org.yorba.shotwell.PhotoFileFormat">
<value value="0" nick="JFIF" />
<value value="1" nick="RAW" />
<value value="2" nick="PNG" />
<value value="3" nick="TIFF" />
<value value="4" nick="BMP" />
<value value="5" nick="UNKNOWN" />
</enum>
<enum id="org.yorba.shotwell.JpegQuality">
<value value="50" nick="LOW" />
<value value="75" nick="MEDIUM" />
<value value="90" nick="HIGH" />
<value value="100" nick="MAXIMUM" />
</enum>
<schema id="org.yorba.shotwell.preferences.export" path="/org/yorba/shotwell/preferences/export/">
<key name="constraint" type="i">
<default>0</default>
<key name="constraint" enum="org.yorba.shotwell.ScaleConstraint">
<default>'ORIGINAL'</default>
<summary>Setting in export dialog: how to trim images</summary>
<description>Setting in export dialog: how to trim images</description>
</key>
......@@ -328,32 +359,26 @@
<description>Setting in export dialog: option to export metadata</description>
</key>
<key name="export-format-mode" type="i">
<default>0</default>
<key name="export-format-mode" enum="org.yorba.shotwell.ExportFormatMode">
<default>'CURRENT'</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>
<key name="photo-file-format" enum="org.yorba.shotwell.PhotoFileFormat">
<default>'JFIF'</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>
<key name="quality" enum="org.yorba.shotwell.JpegQuality">
<default>'HIGH'</default>
<summary>JPEG quality option</summary>
<description>Setting in export dialog: jpeg quality option</description>
</key>
<key name="scale" type="i">
<default>0</default>
<default>1200</default>
<summary>maximal size of image</summary>
<description>Setting in export dialog: maximal size of image</description>
</key>
......
......@@ -174,14 +174,12 @@ public class ExportDialog : Gtk.Dialog {
//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
}
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;
......@@ -353,8 +351,6 @@ public class ExportDialog : Gtk.Dialog {
//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
......
......@@ -48,7 +48,6 @@ public enum ConfigurableProperty {
EXPORT_CONSTRAINT,
EXPORT_EXPORT_FORMAT_MODE,
EXPORT_EXPORT_METADATA,
EXPORT_IS_SET,
EXPORT_PHOTO_FILE_FORMAT,
EXPORT_QUALITY,
EXPORT_SCALE,
......@@ -180,9 +179,6 @@ public enum ConfigurableProperty {
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";
......@@ -320,6 +316,9 @@ public interface ConfigurationEngine : GLib.Object {
public abstract int get_int_property(ConfigurableProperty p) throws ConfigurationError;
public abstract void set_int_property(ConfigurableProperty p, int val) throws ConfigurationError;
public abstract int get_enum_property(ConfigurableProperty p) throws ConfigurationError;
public abstract void set_enum_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;
......@@ -909,7 +908,7 @@ public abstract class ConfigurationFacade : Object {
//
public virtual ScaleConstraint get_export_constraint() {
try {
return (ScaleConstraint) get_engine().get_int_property(ConfigurableProperty.EXPORT_CONSTRAINT);
return (ScaleConstraint) get_engine().get_enum_property(ConfigurableProperty.EXPORT_CONSTRAINT);
} catch (ConfigurationError err) {
on_configuration_error(err);
......@@ -919,7 +918,7 @@ public abstract class ConfigurationFacade : Object {
public virtual void set_export_constraint(ScaleConstraint constraint) {
try {
get_engine().set_int_property(ConfigurableProperty.EXPORT_CONSTRAINT, ( (int) constraint));
get_engine().set_enum_property(ConfigurableProperty.EXPORT_CONSTRAINT, ( (int) constraint));
} catch (ConfigurationError err) {
on_configuration_error(err);
return;
......@@ -928,7 +927,7 @@ public abstract class ConfigurationFacade : Object {
public virtual ExportFormatMode get_export_export_format_mode() {
try {
return (ExportFormatMode) get_engine().get_int_property(ConfigurableProperty.EXPORT_EXPORT_FORMAT_MODE);
return (ExportFormatMode) get_engine().get_enum_property(ConfigurableProperty.EXPORT_EXPORT_FORMAT_MODE);
} catch (ConfigurationError err) {
on_configuration_error(err);
......@@ -938,7 +937,7 @@ public abstract class ConfigurationFacade : Object {
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 ));
get_engine().set_enum_property(ConfigurableProperty.EXPORT_EXPORT_FORMAT_MODE, ( (int) export_format_mode ));
} catch (ConfigurationError err) {
on_configuration_error(err);
return;
......@@ -964,28 +963,9 @@ public abstract class ConfigurationFacade : Object {
}
}
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) );
return PhotoFileFormat.unserialize( get_engine().get_enum_property(ConfigurableProperty.EXPORT_PHOTO_FILE_FORMAT) );
} catch (ConfigurationError err) {
on_configuration_error(err);
......@@ -995,7 +975,7 @@ public abstract class ConfigurationFacade : Object {
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());
get_engine().set_enum_property(ConfigurableProperty.EXPORT_PHOTO_FILE_FORMAT, photo_file_format.serialize());
} catch (ConfigurationError err) {
on_configuration_error(err);
return;
......@@ -1004,7 +984,7 @@ public abstract class ConfigurationFacade : Object {
public virtual Jpeg.Quality get_export_quality() {
try {
return (Jpeg.Quality) get_engine().get_int_property(ConfigurableProperty.EXPORT_QUALITY);
return (Jpeg.Quality) get_engine().get_enum_property(ConfigurableProperty.EXPORT_QUALITY);
} catch (ConfigurationError err) {
on_configuration_error(err);
......@@ -1014,7 +994,7 @@ public abstract class ConfigurationFacade : Object {
public virtual void set_export_quality(Jpeg.Quality quality) {
try {
get_engine().set_int_property(ConfigurableProperty.EXPORT_QUALITY, ( (int) quality ));
get_engine().set_enum_property(ConfigurableProperty.EXPORT_QUALITY, ( (int) quality ));
} catch (ConfigurationError err) {
on_configuration_error(err);
return;
......
......@@ -57,7 +57,6 @@ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object {
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;
......@@ -130,7 +129,6 @@ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object {
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";
......@@ -202,6 +200,20 @@ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object {
schema_object.set_boolean(key, value);
}
private void set_gs_enum (string schema, string key, int value) throws ConfigurationError {
check_key_valid (schema, key);
var schema_object = new Settings (schema);
schema_object.set_enum (key, value);
}
private int get_gs_enum (string schema, string key) throws ConfigurationError {
check_key_valid (schema, key);
var schema_object = new Settings (schema);
return schema_object.get_enum (key);
}
private int get_gs_int(string schema, string key) throws ConfigurationError {
check_key_valid(schema, key);
......@@ -293,6 +305,15 @@ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object {
return "GSettings";
}
public int get_enum_property (ConfigurableProperty p) throws ConfigurationError{
return get_gs_enum (schema_names[p], key_names[p]);
}
public void set_enum_property (ConfigurableProperty p, int val) throws ConfigurationError {
set_gs_enum (schema_names[p], key_names[p], val);
property_changed (p);
}
public int get_int_property(ConfigurableProperty p) throws ConfigurationError {
return get_gs_int(schema_names[p], key_names[p]);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment