Fix #8025 - move css to resources
[roobuilder] / src / Settings.vala
1 /**
2
3 File to handle global settings
4 In theory this should be stored in GLib.Settings - but since that requires a load of infrastructure to create
5 we will stick to "~/.config/roobuilder.json" for now
6
7
8 we used to store it in '.Builder/Project.list' .. but that's going to change..
9
10
11 // this should be available via BuilderApplicaiton.settings
12
13
14 */
15
16 public class Settings : Object  {
17
18         // things that can be set..
19         
20         private int _editor_font_size = 10;
21         public double editor_font_size {
22                 get {
23                         return (double) this._editor_font_size;
24                 }
25                 set {
26                         GLib.debug("updated to %d", (int) value );
27                         this._editor_font_size = (int) value;
28                         if (this.css != null) {
29                                 this.css.load_from_string(
30                                         ".code-editor { font: %dpx monospace; }".printf((int) value)
31                                 );
32                         }
33                         this.save();
34
35                         this.editor_font_size_updated();
36                 }
37                 
38         }
39         public bool editor_font_size_inchange = false;
40         public signal void editor_font_size_updated();
41         
42         
43         // things we look after..
44         Gtk.CssProvider? css = null;
45         bool loaded = false;
46         
47         
48         public  Settings ()
49         {
50                 
51                 this.css = new  Gtk.CssProvider();
52                 this.editor_font_size = 10;
53                 Gtk.StyleContext.add_provider_for_display(
54                         Gdk.Display.get_default(),
55                         this.css,
56                         Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
57                 );
58                 
59                 if (this.load()) {
60                         return;
61                 }
62                 this.loadOld();
63                 this.save();
64                         
65         }
66
67         public void save()
68         {
69                 if (!this.loaded) {
70                         return;
71                 }
72         }
73         
74         public bool load()
75         {
76                 this.loaded = true;
77                 return true;
78         }
79         public  void loadOld() {
80                 this.loaded = true;
81         }
82
83 }
84