2
* Copyright (c) 2013 Christopher Timberlake
3
* <Chris@TimberlakeTechnologies.com> -or- <www.ChristopherTimberlake.com>
5
* Permission is hereby granted, free of charge, to any person obtaining a copy
6
* of this software and associated documentation files (the "Software"), to deal
7
* in the Software without restriction, including without limitation the rights
8
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
* copies of the Software, and to permit persons to whom the Software is
10
* furnished to do so, subject to the following conditions:
12
* The above copyright notice and this permission notice shall be included in
13
* all copies or substantial portions of the Software.
15
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26
class ProjPref_Dialog {
27
public Granite.Widgets.LightWindow light_window;
28
public ProjPref_Dialog(){
29
light_window = new Granite.Widgets.LightWindow ("Project Preferences");
30
light_window.window_position = Gtk.WindowPosition.CENTER;
32
var light_window_notebook = new Granite.Widgets.StaticNotebook ();
34
var grid = new Gtk.Grid ();
35
grid.attach (light_window_notebook, 0, 2, 2, 1);
37
var builder = new Gtk.Builder();
39
builder.add_from_file(Environment.get_current_dir ()+"/assets/ui/projprefs/General.ui");
40
} catch(GLib.Error e){
41
message("Error loading UI File: %s\n", e.message);
44
var general = builder.get_object("GeneralBox") as Gtk.Box;
46
Gtk.Entry project_name = builder.get_object("project_name") as Gtk.Entry;
47
project_name.set_text(ProjectManager.Get_Setting("main", "project_name"));
49
Gtk.Entry author_name = builder.get_object("author_name") as Gtk.Entry;
50
author_name.set_text(ProjectManager.Get_Setting("main","project_author"));
52
Gtk.Entry author_email = builder.get_object("author_email") as Gtk.Entry;
53
author_email.set_text(ProjectManager.Get_Setting("main", "author_email"));
55
Gtk.Entry copyright_years = builder.get_object("copyright_years") as Gtk.Entry;
56
copyright_years.set_text(ProjectManager.Get_Setting("main", "copyright_years"));
58
Gtk.Entry default_license = builder.get_object("default_license") as Gtk.Entry;
59
default_license.set_text(ProjectManager.Get_Setting("main", "project_license"));
63
light_window_notebook.append_page (general, new Gtk.Label ("Project Info"));
65
var button_box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
67
var help_button = new Gtk.Button.with_label ("Save Preferences");
68
help_button.halign = Gtk.Align.CENTER;
69
help_button.yalign = 0;
70
help_button.clicked.connect (() => {
72
unowned string pname_str = project_name.get_text ();
73
unowned string aname_str = author_name.get_text ();
74
unowned string aemail_str = author_email.get_text ();
75
unowned string cyears_str = copyright_years.get_text ();
76
unowned string dlicense_str = default_license.get_text ();
78
this.SavePreferences(pname_str, aname_str, aemail_str, cyears_str, dlicense_str);
83
light_window_notebook.set_size_request(400, 350);
87
grid.margin_bottom = 10;
89
button_box.margin_bottom = 10;
91
light_window.add (grid);
92
button_box.pack_start (help_button);
93
light_window.add (button_box);
96
public void show_all(){
97
light_window.show_all ();
100
public void SavePreferences(string pname, string aname, string aemail, string cyears, string dlicense){
102
ProjectManager.Set_Setting("main", "project_name", pname);
103
ProjectManager.Set_Setting("main", "project_author", aname);
104
ProjectManager.Set_Setting("main", "author_email", aemail);
105
ProjectManager.Set_Setting("main", "copyright_years", cyears);
106
ProjectManager.Set_Setting("main", "project_license", dlicense);