LAview.Desktop/src/Settings.vala

34 lines
1.1 KiB
Vala
Raw Normal View History

2015-12-27 19:06:08 +03:00
namespace LAview.Desktop {
public class AppSettings {
Settings settings;
2015-12-27 19:06:08 +03:00
2018-10-17 11:17:05 +03:00
string _pdf_save_path = "";
public string pdf_save_path {
get { return _pdf_save_path; }
set {
if (settings != null) settings.set_string ("pdf-save-path", value);
_pdf_save_path = value;
}
}
public AppSettings () throws Error {
2016-08-02 16:48:04 +03:00
string schema_file = AppDirs.settings_dir+"/gschemas.compiled";
if (!File.new_for_path (schema_file).query_exists ())
throw new IOError.NOT_FOUND ("File "+schema_file+" not found");
2015-12-27 19:06:08 +03:00
SettingsSchemaSource sss = new SettingsSchemaSource.from_directory (AppDirs.settings_dir, null, false);
2016-08-02 16:48:04 +03:00
string schema_name = "ws.backbone.laview.desktop-"+Config.VERSION_MAJOR.to_string();
SettingsSchema schema = sss.lookup (schema_name, false);
if (schema == null) {
2016-08-02 16:48:04 +03:00
throw new IOError.NOT_FOUND ("Schema "+schema_name+" not found in "+schema_file);
}
settings = new Settings.full (schema, null, null);
2015-12-27 19:06:08 +03:00
_pdf_save_path = settings.get_string("pdf-save-path");
settings.changed["pdf-save-path"].connect (() => {
_pdf_save_path = settings.get_string("pdf-save-path");
});
2015-12-27 19:06:08 +03:00
}
}
}