- mark version newer than 0.4.1
[FaRetSys.git] / Preferences.cs
blobbb2a9d4ebbb01e19ec313b3e321e0cd7a534d0d2
1 using System;
2 using Gtk;
3 using Glade;
4 using Mono.Unix;
6 namespace Eithne
8 public class Preferences
10 [Widget] Window PreferencesWindow;
11 [Widget] Button CloseButton;
13 // Look and feel
14 [Widget] CheckButton RoundButton;
15 [Widget] CheckButton InnerPathButton;
16 [Widget] CheckButton GradientButton;
17 [Widget] CheckButton SmoothConnectionsButton;
18 [Widget] CheckButton AntialiasingButton;
19 [Widget] CheckButton ProgressButton;
20 [Widget] CheckButton ConnectionAnimationButton;
22 [Widget] CheckButton ChangeBackgroundButton;
23 [Widget] Label RedLabel;
24 [Widget] Label GreenLabel;
25 [Widget] Label BlueLabel;
26 [Widget] Label AlphaLabel;
27 [Widget] Scale RedSlider;
28 [Widget] Scale GreenSlider;
29 [Widget] Scale BlueSlider;
30 [Widget] Scale AlphaSlider;
32 // Engine
33 [Widget] SpinButton ThreadSpin;
34 [Widget] CheckButton BlockThreadButton;
36 public Preferences()
38 Glade.XML gxml = new Glade.XML("Preferences.glade", "PreferencesWindow");
39 gxml.BindFields(this);
41 PreferencesWindow.IconList = new Gdk.Pixbuf[2] {new Gdk.Pixbuf(null, "preferences-desktop-48.png"), new Gdk.Pixbuf(null, "preferences-desktop.png")};
43 PreferencesWindow.DeleteEvent += CloseWindow;
44 CloseButton.Clicked += CloseWindow;
46 RoundButton.Active = Config.Get("block/round", true);
47 RoundButton.Toggled += delegate(object o, EventArgs args) { Config.Set("block/round", RoundButton.Active); };
49 InnerPathButton.Active = Config.Get("block/innerpath", true);
50 InnerPathButton.Toggled += delegate(object o, EventArgs args) { Config.Set("block/innerpath", InnerPathButton.Active); };
52 GradientButton.Active = Config.Get("block/gradient", true);
53 GradientButton.Toggled += delegate(object o, EventArgs args) { Config.Set("block/gradient", GradientButton.Active); };
55 SmoothConnectionsButton.Active = Config.Get("block/smoothconnections", true);
56 SmoothConnectionsButton.Toggled += delegate(object o, EventArgs args) { Config.Set("block/smoothconnections", SmoothConnectionsButton.Active); };
58 AntialiasingButton.Active = Config.Get("schematic/antialias", true);
59 AntialiasingButton.Toggled += delegate(object o, EventArgs args) { Config.Set("schematic/antialias", AntialiasingButton.Active); };
61 ProgressButton.Active = Config.Get("block/progress", true);
62 ProgressButton.Toggled += delegate(object o, EventArgs args) { Config.Set("block/progress", ProgressButton.Active); };
64 ConnectionAnimationButton.Active = Config.Get("schematic/connectionanimation", true);
65 ConnectionAnimationButton.Toggled += delegate(object o, EventArgs args) { Config.Set("schematic/connectionanimation", ConnectionAnimationButton.Active); };
67 ThreadSpin.Value = Config.Get("engine/threads", 1);
68 ThreadSpin.ValueChanged += delegate(object o, EventArgs args) { Config.Set("engine/threads", ThreadSpin.ValueAsInt); };
70 BlockThreadButton.Active = Config.Get("engine/blockthreads", false);
71 BlockThreadButton.Toggled += delegate(object o, EventArgs args) { Config.Set("engine/blockthreads", BlockThreadButton.Active); };
73 ChangeBackgroundButton.Active = Config.Get("schematic/changebackground", false);
74 SetBackgroundControlsStatus(ChangeBackgroundButton.Active);
75 ChangeBackgroundButton.Toggled += delegate(object o, EventArgs args) { Config.Set("schematic/changebackground", ChangeBackgroundButton.Active); SetBackgroundControlsStatus(ChangeBackgroundButton.Active); };
77 RedSlider.Value = Config.Get("schematic/red", 128);
78 RedSlider.ValueChanged += delegate(object o, EventArgs args) { Config.Set("schematic/red", (int)RedSlider.Value); };
80 GreenSlider.Value = Config.Get("schematic/green", 128);
81 GreenSlider.ValueChanged += delegate(object o, EventArgs args) { Config.Set("schematic/green", (int)GreenSlider.Value); };
83 BlueSlider.Value = Config.Get("schematic/blue", 128);
84 BlueSlider.ValueChanged += delegate(object o, EventArgs args) { Config.Set("schematic/blue", (int)BlueSlider.Value); };
86 AlphaSlider.Value = Config.Get("schematic/alpha", 255);
87 AlphaSlider.ValueChanged += delegate(object o, EventArgs args) { Config.Set("schematic/alpha", (int)AlphaSlider.Value); };
90 PreferencesWindow.ShowAll();
93 private void CloseWindow(object o, EventArgs args)
95 PreferencesWindow.Destroy();
98 private void SetBackgroundControlsStatus(bool status)
100 RedLabel.Sensitive = status;
101 GreenLabel.Sensitive = status;
102 BlueLabel.Sensitive = status;
104 RedSlider.Sensitive = status;
105 GreenSlider.Sensitive = status;
106 BlueSlider.Sensitive = status;
108 if(MainWindow.HaveAlpha)
110 AlphaLabel.Sensitive = status;
111 AlphaSlider.Sensitive = status;
113 else
115 AlphaLabel.Sensitive = false;
116 AlphaSlider.Sensitive = false;