2
This file is part of LoggerOuter.
4
LoggerOuter is free software: you can redistribute it and/or modify it under the
5
terms of the GNU Lesser General Public License as published by the Free Software
6
Foundation, either version 3 of the License, or (at your option) any later
9
LoggerOuter is distributed in the hope that it will be useful, but WITHOUT
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
12
License for more details.
14
You should have received a copy of the GNU Lessel General Public License
15
along with LoggerOuter. If not, see <https://www.gnu.org/licenses/>.
18
public struct LO.Settings {
20
const string CONFIG_INI_NAMESPACE_MAIN = "Main";
23
GLib.KeyFile? key_file;
25
private static GLib.Once<LO.Settings?> instance;
27
public bool? dark_theme;
29
public static unowned LO.Settings? get_instance () {
30
return instance.once (() => {
31
return LO.Settings ();
35
private Settings () {}
37
public void load_settings (string config_path) {
38
key_file = new GLib.KeyFile ();
39
this.config_path = config_path;
43
public void load_setting_from_xdg () {
44
key_file = new GLib.KeyFile ();
45
this.config_path = LO_XDG_CONFIG_PATH;
48
private void parse_key_file ()
49
requires (key_file != null) {
51
key_file.load_from_file (this.config_path, GLib.KeyFileFlags.NONE);
52
} catch (GLib.FileError e) {
53
string message = @"ERROR: $(e.message)\n";
54
stderr.printf (message);
55
} catch (GLib.KeyFileError e) {
56
string message = @"ERROR: $(e.message)\n";
57
stderr.printf (message);
61
if( key_file.has_key (CONFIG_INI_NAMESPACE_MAIN, "DarkTheme") ) {
62
this.dark_theme = key_file.get_boolean (CONFIG_INI_NAMESPACE_MAIN, "DarkTheme");
64
} catch (GLib.KeyFileError e) {
65
string message = @"ERROR: $(e.message)\n";
66
stderr.printf (message);