forked from bobcao3/SESDE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Preference.vala
53 lines (38 loc) · 1.08 KB
/
Preference.vala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using DConf;
using Gtk;
namespace Preference {
class PreferenceMan {
public bool dark_theme = false;
private DConf.Client dcl = new DConf.Client ();
private Gtk.Settings gtkst = Gtk.Settings.get_default ();
public void dark_theme_toggle () {
this.dark_theme = !this.dark_theme;
gtkst.gtk_application_prefer_dark_theme = this.dark_theme;
dcl.write_fast ("./dconf.conf", this.dark_theme);
}
public PreferenceMan () {
dcl.watch_sync ("./dconf.conf");
Variant? dark_var = dcl.read("SESDE.Dark");
if (dark_var.get_boolean ()) {
dark_theme_toggle ();
}
}
}
class PreferenceWin : Gtk.Window {
private Preference.PreferenceMan prman = new Preference.PreferenceMan ();
public void appear () {
this.show_all ();
}
public void vanish () {
this.hide ();
}
public PreferenceWin () {
Button dark_toggle = new Button ();
dark_toggle.set_label ("Toggle Dark Theme");
dark_toggle.clicked.connect(this.prman.dark_theme_toggle);
this.deletable = false;
this.title = "SESDE Preferences";
this.add (dark_toggle);
}
}
}