69 lines
2.4 KiB
Vala
69 lines
2.4 KiB
Vala
/*
|
|
* pdf-presenter - advanced pdf presentation util
|
|
*
|
|
* Copyright (C) 2012 Sebastian Reichel <sre@ring0.de>
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
* THE SOFTWARE.
|
|
*/
|
|
|
|
class Config {
|
|
private KeyFile keyfile;
|
|
private string path;
|
|
|
|
public string control_monitor;
|
|
public bool control_fullscreen;
|
|
public string presentation_monitor;
|
|
|
|
public signal void configuration_changed();
|
|
|
|
public Config() {
|
|
path = Environment.get_user_config_dir() + "/pdf-presenter.cfg";
|
|
keyfile = new KeyFile();
|
|
load();
|
|
}
|
|
|
|
public void load() {
|
|
try {
|
|
keyfile.load_from_file (path, KeyFileFlags.NONE);
|
|
|
|
/* monitors section */
|
|
control_monitor = keyfile.get_string ("monitors", "control");
|
|
presentation_monitor = keyfile.get_string ("monitors", "presentation");
|
|
control_fullscreen = keyfile.get_boolean ("monitors", "control_fullscreen");
|
|
} catch(Error e) {
|
|
stderr.printf("could not load settings: %s\n", e.message);
|
|
}
|
|
}
|
|
|
|
public void save() {
|
|
/* monitors section */
|
|
keyfile.set_string("monitors", "control", control_monitor);
|
|
keyfile.set_string("monitors", "presentation", presentation_monitor);
|
|
keyfile.set_boolean("monitors", "control_fullscreen", control_fullscreen);
|
|
|
|
try {
|
|
string data = keyfile.to_data();
|
|
var file = File.new_for_path(path);
|
|
file.replace_contents(data, data.length, null, false, FileCreateFlags.NONE, null);
|
|
} catch(Error e) {
|
|
stderr.printf("could not save settings: %s\n", e.message);
|
|
}
|
|
}
|
|
}
|