/loggerouter/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/loggerouter/trunk

« back to all changes in this revision

Viewing changes to src/settings.vala

  • Committer: Gustav Hartvigsson
  • Date: 2025-06-16 20:00:58 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20250616200058-mon16rxwoqvhyudl
[README.txt] updated.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
  private static GLib.Once<LO.Settings?> instance;
26
26
 
27
27
  public bool? dark_theme;
 
28
  
 
29
  //TODO: Timer countdown setting.
 
30
 
 
31
  public string to_string () {
 
32
    var builder = new StringBuilder ();
 
33
    builder.append_printf ("key_file: %px\n", key_file);
 
34
    builder.append_printf ("config_path: %s", config_path);
 
35
    builder.append_printf ("dark_theme: %s", dark_theme.to_string ());
 
36
    return builder.str;
 
37
  }
28
38
 
29
39
  public static unowned LO.Settings? get_instance () {
30
40
    return instance.once (() => {
36
46
 
37
47
  public void load_settings (string config_path) {
38
48
    key_file = new GLib.KeyFile ();
39
 
  this.config_path = config_path;
 
49
    this.config_path = config_path;
40
50
    parse_key_file ();
41
51
  }
42
52
 
43
53
  public void load_setting_from_xdg () {
44
54
    key_file = new GLib.KeyFile ();
45
55
    this.config_path = LO_XDG_CONFIG_PATH;
 
56
    if (GLib.File.new_for_path (this.config_path).query_exists ()) {
 
57
      parse_key_file ();
 
58
    } else {
 
59
      stderr.printf ("Colud not find file: %s", this.config_path);
 
60
      this.dark_theme = false;
 
61
    }
46
62
  }
47
63
 
48
64
  private void parse_key_file ()
52
68
    } catch (GLib.FileError e) {
53
69
      string message = @"ERROR: $(e.message)\n";
54
70
      stderr.printf (message);
 
71
      GLib.Process.exit (41);
55
72
    } catch (GLib.KeyFileError e) {
56
73
      string message = @"ERROR: $(e.message)\n";
57
74
      stderr.printf (message);
 
75
      GLib.Process.exit (42);
58
76
    }
59
77
 
60
78
    try {
61
79
      if( key_file.has_key (CONFIG_INI_NAMESPACE_MAIN, "DarkTheme") ) {
62
80
        this.dark_theme = key_file.get_boolean (CONFIG_INI_NAMESPACE_MAIN, "DarkTheme");
 
81
      } else {
 
82
        this.dark_theme = true;
63
83
      }
64
84
    } catch (GLib.KeyFileError e) {
65
85
      string message = @"ERROR: $(e.message)\n";
66
86
      stderr.printf (message);
 
87
      GLib.Process.exit (43);
67
88
    }
68
89
  }
69
90
}