~versable/estudio/estudio

« back to all changes in this revision

Viewing changes to src/UI/Dialogs/Project_Preferences.vala

  • Committer: Chris Timberlake
  • Date: 2013-09-13 08:15:44 UTC
  • Revision ID: git-v1:a81e8a287bd7e509bb70f1845e2d7dd56a57a660
Moved Repo

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *    Copyright (c) 2013 Christopher Timberlake 
3
 
 *    <Chris@TimberlakeTechnologies.com> -or- <www.ChristopherTimberlake.com>
4
 
 *
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:
11
 
 
12
 
 *    The above copyright notice and this permission notice shall be included in
13
 
 *    all copies or substantial portions of the Software.
14
 
 
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
21
 
 *    THE SOFTWARE.
22
 
 */
23
 
 
24
 
using Gtk;
25
 
namespace eStudio {
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;
31
 
            
32
 
            var light_window_notebook = new Granite.Widgets.StaticNotebook ();
33
 
            
34
 
            var grid = new Gtk.Grid ();
35
 
            grid.attach (light_window_notebook, 0, 2, 2, 1);
36
 
            
37
 
            var builder = new Gtk.Builder();
38
 
            try {
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);
42
 
            }
43
 
            
44
 
            var general = builder.get_object("GeneralBox") as Gtk.Box;
45
 
 
46
 
            Gtk.Entry project_name = builder.get_object("project_name") as Gtk.Entry;
47
 
            project_name.set_text(ProjectManager.Get_Setting("main", "project_name"));
48
 
    
49
 
            Gtk.Entry author_name = builder.get_object("author_name") as Gtk.Entry;
50
 
            author_name.set_text(ProjectManager.Get_Setting("main","project_author"));
51
 
            
52
 
            Gtk.Entry author_email = builder.get_object("author_email") as Gtk.Entry;
53
 
            author_email.set_text(ProjectManager.Get_Setting("main", "author_email"));
54
 
            
55
 
            Gtk.Entry copyright_years = builder.get_object("copyright_years") as Gtk.Entry;
56
 
            copyright_years.set_text(ProjectManager.Get_Setting("main", "copyright_years"));
57
 
            
58
 
            Gtk.Entry default_license = builder.get_object("default_license") as Gtk.Entry;
59
 
            default_license.set_text(ProjectManager.Get_Setting("main", "project_license"));
60
 
 
61
 
 
62
 
            
63
 
            light_window_notebook.append_page (general, new Gtk.Label ("Project Info"));
64
 
 
65
 
            var button_box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
66
 
 
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 (() => {
71
 
            
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 ();
77
 
            
78
 
                this.SavePreferences(pname_str, aname_str, aemail_str, cyears_str, dlicense_str);
79
 
                
80
 
            });
81
 
    
82
 
            //Set Sizing
83
 
            light_window_notebook.set_size_request(400, 350);
84
 
 
85
 
            grid.margin = 12;
86
 
            grid.margin_top = 10;
87
 
            grid.margin_bottom = 10;
88
 
            
89
 
            button_box.margin_bottom = 10;
90
 
            
91
 
            light_window.add (grid);
92
 
            button_box.pack_start (help_button);
93
 
            light_window.add (button_box);
94
 
        }
95
 
        
96
 
        public void show_all(){
97
 
            light_window.show_all ();
98
 
        }
99
 
 
100
 
        public void SavePreferences(string pname, string aname, string aemail, string cyears, string dlicense){
101
 
 
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);
107
 
        }
108
 
    }
109
 
}