/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-03 21:28:25 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20250603212825-d99acf3s4b1qktk3
spellingĀ error

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
 
  }
38
28
 
39
29
  public static unowned LO.Settings? get_instance () {
40
30
    return instance.once (() => {
46
36
 
47
37
  public void load_settings (string config_path) {
48
38
    key_file = new GLib.KeyFile ();
49
 
    this.config_path = config_path;
 
39
  this.config_path = config_path;
50
40
    parse_key_file ();
51
41
  }
52
42
 
53
43
  public void load_setting_from_xdg () {
54
44
    key_file = new GLib.KeyFile ();
55
45
    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
 
    }
62
46
  }
63
47
 
64
48
  private void parse_key_file ()
68
52
    } catch (GLib.FileError e) {
69
53
      string message = @"ERROR: $(e.message)\n";
70
54
      stderr.printf (message);
71
 
      GLib.Process.exit (41);
72
55
    } catch (GLib.KeyFileError e) {
73
56
      string message = @"ERROR: $(e.message)\n";
74
57
      stderr.printf (message);
75
 
      GLib.Process.exit (42);
76
58
    }
77
59
 
78
60
    try {
79
61
      if( key_file.has_key (CONFIG_INI_NAMESPACE_MAIN, "DarkTheme") ) {
80
62
        this.dark_theme = key_file.get_boolean (CONFIG_INI_NAMESPACE_MAIN, "DarkTheme");
81
 
      } else {
82
 
        this.dark_theme = true;
83
63
      }
84
64
    } catch (GLib.KeyFileError e) {
85
65
      string message = @"ERROR: $(e.message)\n";
86
66
      stderr.printf (message);
87
 
      GLib.Process.exit (43);
88
67
    }
89
68
  }
90
69
}