Fix #8102 - glade view include gtksource
[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                         if (value < 6 || value > 50) {
28                                 return;
29                         }
30                         this._editor_font_size = (int) value;
31                         if (this.css != null) {
32                                 this.css.load_from_string(
33                                         ".code-editor { font: %dpx monospace; }".printf((int) value)
34                                 );
35                         }
36                         this.save();
37
38                         this.editor_font_size_updated();
39                 }
40                 
41         }
42         public bool editor_font_size_inchange = false;
43         public signal void editor_font_size_updated();
44         
45         
46         // things we look after..
47         Gtk.CssProvider? css = null;
48         bool loaded = false;
49         
50         
51         public  Settings ()
52         {
53                 
54                 this.css = new  Gtk.CssProvider();
55                 this.editor_font_size = 10;
56                 Gtk.StyleContext.add_provider_for_display(
57                         Gdk.Display.get_default(),
58                         this.css,
59                         Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
60                 );
61                 
62                 if (this.load()) {
63                         return;
64                 }
65                 this.loadOld();
66                 this.save();
67                         
68         }
69
70         public void save()
71         {
72                 if (!this.loaded) {
73                         return;
74                 }
75         }
76         
77         public bool load()
78         {
79                 this.loaded = true;
80                 return true;
81         }
82         public  void loadOld() {
83                 this.loaded = true;
84         }
85
86 }
87