source: libi4uc/i4ucprojectssidepageview.vala @ cf36b3a262f09427a72acf9406f81506ecf9016b

Revision cf36b3a262f09427a72acf9406f81506ecf9016b, 5.9 KB checked in by Matias De la Puente <mfpuente.ar@…>, 3 years ago (diff)

Projects: Select builder, device type and device in profiles

  • Property mode set to 100644
Line 
1/* i4ucprojectssidepageview.vala
2 *
3 * Copyright (C) 2010  Matias De la Puente
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 *
18 * Author:
19 *      Matias De la Puente <mfpuente.ar@gmail.com>
20 */
21using Gtk;
22using Gee;
23
24public class I4uc.ProjectsSidePageView : SidePage, ProjectsSidePageViewIface
25{
26        private Notebook _notebook = new Notebook ();
27        private ProjectsCombo _projects_combo = new ProjectsCombo ();
28        private FilesList _files_list = new FilesList ();
29        private ProfilesCheckList _profiles_check_list = new ProfilesCheckList ();
30        private ProfilesList _profiles_list = new ProfilesList ();
31        private BuildersList _builders_list = new BuildersList ();
32        private string _current_profile;
33        private string _current_file;
34
35        public string current_project
36        {
37                set { _projects_combo.current_project = value; }
38                get { return _projects_combo.current_project; }
39        }
40
41        public string current_profile { get { return _current_profile; } }
42        public string current_file { get { return _current_file; } }
43
44        public bool profiles_check_list_sensitive
45        {
46                set { _profiles_check_list.sensitive = value; }
47                get { return _profiles_check_list.sensitive; }
48        }
49
50        public BuildersListIface builders_list { get { return _builders_list; } }
51       
52        public bool builders_list_sensitive
53        {
54                set { _builders_list.sensitive = value; }
55                get { return _builders_list.sensitive; }
56        }
57
58        public ProjectsSidePageView ()
59        {
60                _notebook.tab_pos = PositionType.BOTTOM;
61
62                var files_scrolled_window = new ScrolledWindow (null, null);
63                files_scrolled_window.add_with_viewport (_files_list);
64                files_scrolled_window.set_policy (PolicyType.NEVER, PolicyType.AUTOMATIC);
65               
66                var profiles_scrolled_window = new ScrolledWindow (null, null);
67                profiles_scrolled_window.add_with_viewport (_profiles_list);
68                profiles_scrolled_window.set_policy (PolicyType.NEVER, PolicyType.AUTOMATIC);
69
70                var profiles_expander = new Expander (_("Profiles"));
71                profiles_expander.add (_profiles_check_list);
72
73                var builders_expander = new Expander (_("Builders"));
74                builders_expander.add (_builders_list);
75
76                var files_vbox = new VBox (false, 0);
77                files_vbox.pack_start (files_scrolled_window, true, true, 0);
78                files_vbox.pack_start (profiles_expander, false, false, 0);
79
80                var profiles_vbox = new VBox (false, 0);
81                profiles_vbox.pack_start (profiles_scrolled_window, true, true, 0);
82                profiles_vbox.pack_start (builders_expander, false, false, 0);
83
84                _notebook.append_page (files_vbox, new Image.from_stock (STOCK_FILE, IconSize.MENU));
85                _notebook.append_page (profiles_vbox, new Image.from_stock (STOCK_DIRECTORY, IconSize.MENU));
86
87                pack_start (_projects_combo, false, false, 2);
88                pack_start (_notebook, true, true, 2);
89                show_all ();
90
91                //connect signals
92                _projects_combo.project_changed.connect (() => this.project_changed ());
93                _profiles_list.item_changed.connect (on_item_changed);
94                _profiles_list.item_activated.connect (on_item_activated);
95                _profiles_check_list.check_changed.connect ((profile, active) => this.profile_check_changed (profile, active));
96                _files_list.file_changed.connect (on_file_changed);
97                _files_list.file_activated.connect (() => this.file_activated ());
98                _notebook.switch_page.connect (on_switch_page);
99        }
100
101        public void add_project (string project_uri, string project_name)
102        {
103                _projects_combo.add_project (project_uri, project_name);
104        }
105
106        public void add_profile (string profile)
107        {
108                _profiles_check_list.add_profile (profile, false);
109                _profiles_list.add_profile (profile);
110        }
111
112        public void add_profile_file (string profile, string file)
113        {
114                _profiles_list.add_file (profile, file);
115        }
116
117        public void add_file (string file)
118        {
119                _files_list.add_file (file);
120        }
121
122        public void check_profile (string profile, bool active)
123        {
124                _profiles_check_list.check_profile (profile, active);
125        }
126
127        public void uncheck_all_profiles ()
128        {
129                _profiles_check_list.uncheck_all_profiles ();
130        }
131
132        public void remove_project (string project_uri)
133        {
134                _projects_combo.remove_project (project_uri);
135        }
136
137        public void remove_profile (string profile)
138        {
139                _profiles_list.remove_profile (profile);
140        }
141
142        public void remove_profile_file (string profile, string file)
143        {
144                _profiles_list.remove_file (profile, file);
145        }
146
147        public void remove_file (string file)
148        {
149                _files_list.remove_file (file);
150        }
151
152        public void clear_profile (string profile)
153        {
154                _profiles_list.clear_profile (profile);
155        }
156
157        public void clear_profiles_list ()
158        {
159                _profiles_check_list.clear_list ();
160                _profiles_list.clear_list ();
161        }
162
163        public void clear_files_list ()
164        {
165                _files_list.clear_list ();
166        }
167
168        private void on_item_changed ()
169        {
170                if (_current_profile != _profiles_list.current_profile)
171                {
172                        _current_profile = _profiles_list.current_profile;
173                        this.profile_selected ();
174                }
175                if (_current_file != _profiles_list.current_file)
176                {
177                        _current_file = _profiles_list.current_file;
178                        this.file_selected ();
179                }
180        }
181
182        private void on_item_activated ()
183        {
184                if (_profiles_list.current_file != null)
185                        this.file_activated ();
186                else
187                        this.profile_activated ();
188        }
189
190        private void on_file_changed ()
191        {
192                if (_current_file == _files_list.current_file)
193                        return;
194                _current_file = _files_list.current_file;
195                this.file_selected ();
196        }
197
198        private void on_switch_page (NotebookPage page, uint page_num)
199        {
200                switch (page_num)
201                {
202                        case 0:
203                                if (_current_profile != null)
204                                {
205                                        _current_profile = null;
206                                        this.profile_selected ();
207                                }
208                                on_file_changed ();
209                                break;
210                        case 1:
211                                on_item_changed ();
212                                break;
213                }
214        }
215}
Note: See TracBrowser for help on using the repository browser.