source: libi4uc/i4ucprojectssidepageview.vala @ 16031c0c0382e0dec3ff640ff27c96d69a9ff602

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

Add ProjectsSidePanel? and projects manager

  • 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 ProfilesList _profiles_list = new ProfilesList ();
30        private string _current_profile;
31        private string _current_file;
32
33        public string current_project
34        {
35                set { _projects_combo.current_project = value; }
36                get { return _projects_combo.current_project; }
37        }
38
39        public string current_profile { get { return _current_profile; } }
40        public string current_file { get { return _current_file; } }
41       
42        public ProjectsSidePageView ()
43        {
44                _notebook.tab_pos = PositionType.BOTTOM;
45
46                var files_scrolled_window = new ScrolledWindow (null, null);
47                files_scrolled_window.add_with_viewport (_files_list);
48                files_scrolled_window.set_policy (PolicyType.NEVER, PolicyType.AUTOMATIC);
49               
50                var profiles_scrolled_window = new ScrolledWindow (null, null);
51                profiles_scrolled_window.add_with_viewport (_profiles_list);
52                profiles_scrolled_window.set_policy (PolicyType.NEVER, PolicyType.AUTOMATIC);
53               
54                _notebook.append_page (files_scrolled_window, new Image.from_stock (STOCK_FILE, IconSize.MENU));
55                _notebook.append_page (profiles_scrolled_window, new Image.from_stock (STOCK_DIRECTORY, IconSize.MENU));
56
57                pack_start (_projects_combo, false, false, 2);
58                pack_start (_notebook, true, true, 2);
59                show_all ();
60
61                //connect signals
62                _projects_combo.project_changed.connect (() => this.project_changed ());
63                _profiles_list.item_changed.connect (on_item_changed);
64                _profiles_list.item_activated.connect (on_item_activated);
65                _files_list.file_changed.connect (on_file_changed);
66                _files_list.file_activated.connect (() => this.file_activated ());
67        }
68
69        public void add_project (string project_uri, string project_name)
70        {
71                _projects_combo.add_project (project_uri, project_name);
72        }
73
74        public void add_profile (string profile)
75        {
76                _profiles_list.add_profile (profile);
77        }
78
79        public void add_profile_file (string profile, string file)
80        {
81                _profiles_list.add_file (profile, file);
82        }
83
84        public void add_file (string file)
85        {
86                _files_list.add_file (file);
87        }
88
89        public void remove_project (string project_uri)
90        {
91                _projects_combo.remove_project (project_uri);
92        }
93
94        public void remove_profile (string profile)
95        {
96                _profiles_list.remove_profile (profile);
97        }
98
99        public void remove_profile_file (string profile, string file)
100        {
101                _profiles_list.remove_file (profile, file);
102        }
103
104        public void remove_file (string file)
105        {
106                _files_list.remove_file (file);
107        }
108
109        public void clear_profile (string profile)
110        {
111                _profiles_list.clear_profile (profile);
112        }
113
114        public void clear_profiles_list ()
115        {
116                _profiles_list.clear_list ();
117        }
118
119        public void clear_files_list ()
120        {
121                _files_list.clear_list ();
122        }
123
124        private void on_item_changed ()
125        {
126                if (_current_profile != _profiles_list.current_profile)
127                {
128                        _current_profile = _profiles_list.current_profile;
129                        this.profile_selected ();
130                }
131                if (_current_file != _profiles_list.current_file)
132                {
133                        _current_file = _profiles_list.current_file;
134                        this.file_selected ();
135                }
136        }
137
138        private void on_item_activated ()
139        {
140                if (_profiles_list.current_file != null)
141                        this.file_activated ();
142                else
143                        this.profile_activated ();
144        }
145
146        private void on_file_changed ()
147        {
148                if (_current_file == _files_list.current_file)
149                        return;
150                _current_file = _files_list.current_file;
151                this.file_selected ();
152        }
153}
Note: See TracBrowser for help on using the repository browser.