source: gtkfrontend/projectsview.vala @ 628f3dc614aeb64636b8b50cb2c7413053d2e490

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

Add 'program profile' option

  • Property mode set to 100644
Line 
1/* projectsview.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.GtkFrontend.ProjectsView : GLib.Object, I4uc.Core.ProjectsView
25{
26        private UIManager _ui_manager;
27        private ActionGroup _action_group;
28        private PagesPanel _side_panel;
29        private PagesPanel _bottom_panel;
30        private ProjectsPageView _page_view = new ProjectsPageView ();
31        private ProfileBuilderLogPage _build_log_page = new ProfileBuilderLogPage ();
32
33        public I4uc.Core.ProjectsPageView page_view { get { return _page_view; } }
34       
35        public I4uc.Core.ProfileBuilderLogPage build_log_page { get { return _build_log_page; } }
36       
37        public bool add_file_sensitive
38        {
39                set { _action_group.get_action ("AddFileProjectAction").sensitive = value; }
40                get { return _action_group.get_action ("AddFileProjectAction").sensitive; }
41        }
42       
43        public bool remove_file_from_project_sensitive
44        {
45                set { _action_group.get_action ("RemoveFileFromProjectProjectAction").sensitive = value; }
46                get { return _action_group.get_action ("RemoveFileFromProjectProjectAction").sensitive; }
47        }
48       
49        public bool remove_file_from_profile_sensitive
50        {
51                set { _action_group.get_action ("RemoveFileFromProfileProjectAction").sensitive = value; }
52                get { return _action_group.get_action ("RemoveFileFromProfileProjectAction").sensitive; }
53        }
54       
55        public bool add_profile_sensitive
56        {
57                set { _action_group.get_action ("AddProfileProjectAction").sensitive = value; }
58                get { return _action_group.get_action ("AddProfileProjectAction").sensitive; }
59        }
60       
61        public bool edit_profile_sensitive
62        {
63                set { _action_group.get_action ("EditProfileProjectAction").sensitive = value; }
64                get { return _action_group.get_action ("EditProfileProjectAction").sensitive; }
65        }
66       
67        public bool duplicate_profile_sensitive
68        {
69                set { _action_group.get_action ("DuplicateProfileProjectAction").sensitive = value; }
70                get { return _action_group.get_action ("DuplicateProfileProjectAction").sensitive; }
71        }
72       
73        public bool remove_profile_sensitive
74        {
75                set { _action_group.get_action ("RemoveProfileFromProjectProjectAction").sensitive = value; }
76                get { return _action_group.get_action ("RemoveProfileFromProjectProjectAction").sensitive; }
77        }
78       
79        public bool build_profile_sensitive
80        {
81                set { _action_group.get_action ("BuildProfileProjectAction").sensitive = value; }
82                get { return _action_group.get_action ("BuildProfileProjectAction").sensitive; }
83        }
84       
85        public bool program_profile_sensitive
86        {
87                set { _action_group.get_action ("ProgramProfileProjectAction").sensitive = value; }
88                get { return _action_group.get_action ("ProgramProfileProjectAction").sensitive; }
89        }
90       
91        public bool stop_sensitive
92        {
93                set { _action_group.get_action ("StopProjectAction").sensitive = value; }
94                get { return _action_group.get_action ("StopProjectAction").sensitive; }
95        }
96       
97        public bool clean_profile_sensitive
98        {
99                set { _action_group.get_action ("CleanProfileProjectAction").sensitive = value; }
100                get { return _action_group.get_action ("CleanProfileProjectAction").sensitive; }
101        }
102       
103        public bool close_sensitive
104        {
105                set { _action_group.get_action ("CloseProjectAction").sensitive = value; }
106                get { return _action_group.get_action ("CloseProjectAction").sensitive; }
107        }
108       
109        public ProjectsView (UIManager ui_manager, PagesPanel side_panel, PagesPanel bottom_panel)
110        {
111                _ui_manager = ui_manager;
112                _side_panel = side_panel;
113                _bottom_panel = bottom_panel;
114
115                _action_group = new ActionGroup ("I4ucProjectsActions");
116                _action_group.set_translation_domain (Config.GETTEXT_PACKAGE);
117                _action_group.add_actions (_action_entries, this);
118               
119                _ui_manager.insert_action_group (_action_group, -1);
120               
121                try
122                {
123                        _ui_manager.add_ui_from_string (_UI, -1);
124                }
125                catch (GLib.Error e)
126                {
127                        warning (e.message);
128                }
129               
130                var toolbar = (Toolbar)_ui_manager.get_widget ("/MainToolbar");
131                toolbar.set_style (ToolbarStyle.ICONS);
132               
133                _side_panel.insert_page (_page_view, 0);
134                _side_panel.show_page (_page_view);
135                _bottom_panel.add_page (_build_log_page);
136        }
137
138        public void show_error_message (string error_message)
139        {
140                var message = new MessageDialog (null, DialogFlags.MODAL, MessageType.ERROR, ButtonsType.NONE, error_message);
141                message.add_button (STOCK_OK, ResponseType.OK);
142                message.set_default_response (ResponseType.OK);
143                message.run ();
144                message.destroy ();
145        }
146
147        public int show_yes_no_message (string message, bool cancel)
148        {
149                var dialog = new MessageDialog (null, DialogFlags.MODAL, MessageType.WARNING, ButtonsType.NONE, message);
150                if (cancel)
151                        dialog.add_button (STOCK_CANCEL, ResponseType.CANCEL);
152                dialog.add_button (STOCK_NO, ResponseType.NO);
153                dialog.add_button (STOCK_YES, ResponseType.YES);
154                dialog.set_default_response (ResponseType.YES);
155                var response = dialog.run ();
156                dialog.destroy ();
157                return response;
158        }
159
160        public int show_new_dialog (out string project_uri, out string project_name, out Gee.List<string> authors)
161        {
162                var dialog = new NewProjectDialog ();
163                var response = dialog.run ();
164
165                project_uri = dialog.project_uri;
166                project_name = dialog.project_name;
167                authors = dialog.project_authors;
168
169                dialog.destroy ();
170                return response;
171        }
172
173        public I4uc.Core.AddFileDialogView create_add_file_dialog_view ()
174        {
175                return new AddFileDialogView ();
176        }
177
178        public I4uc.Core.AddProfileDialogView create_add_profile_dialog_view ()
179        {
180                return new AddProfileDialogView ();
181        }
182       
183        public void show_build_log_page ()
184        {
185                _bottom_panel.show_page (_build_log_page);
186        }
187       
188        public void add_recent (string uri)
189        {
190                RecentManager.get_default ().add_item (uri);
191        }
192
193        private void on_new ()
194        {
195                this.new_clicked ();
196        }
197       
198        private void on_add_file ()
199        {
200                this.add_file_clicked ();
201        }
202
203        private void on_remove_file_from_project ()
204        {
205                this.remove_file_from_project_clicked ();
206        }
207
208        private void on_remove_file_from_profile ()
209        {
210                this.remove_file_from_profile_clicked ();
211        }
212
213        private void on_add_profile ()
214        {
215                this.add_profile_clicked ();
216        }
217       
218        private void on_edit_profile ()
219        {
220                this.edit_profile_clicked ();
221        }
222       
223        private void on_duplicate_profile ()
224        {
225                this.duplicate_profile_clicked ();
226        }
227
228        private void on_remove_profile ()
229        {
230                this.remove_profile_clicked ();
231        }
232       
233        private void on_build_profile ()
234        {
235                this.build_profile_clicked ();
236        }
237       
238        private void on_program_profile ()
239        {
240                this.program_profile_clicked ();
241        }
242       
243        private void on_stop ()
244        {
245                this.stop_clicked ();
246        }
247
248        private void on_clean_profile ()
249        {
250                this.clean_profile_clicked ();
251        }
252       
253        private void on_close ()
254        {
255                this.close_clicked ();
256        }
257
258        private const ActionEntry[] _action_entries =
259        {
260                { "ProjectsMenuAction", null, N_("_Projects") },
261                { "NewProjectAction", STOCK_NEW, null, "<Control><Shift>n", N_("Create a new project"), on_new },
262                { "AddFileProjectAction", STOCK_ADD, N_("Add file"), null, N_("Add a file to current project"), on_add_file },
263                { "RemoveFileFromProjectProjectAction", STOCK_REMOVE, N_("Remove file from project"), null, N_("Remove a file from current project"), on_remove_file_from_project },
264                { "RemoveFileFromProfileProjectAction", STOCK_REMOVE, N_("Remove file from profile"), null, N_("Remove a file from current profile"), on_remove_file_from_profile },
265                { "AddProfileProjectAction", STOCK_ADD, N_("Add profile"), null, N_("Add a profile to current project"), on_add_profile },
266                { "EditProfileProjectAction", STOCK_EDIT, N_("Edit profile"), null, N_("Edit current profile"), on_edit_profile },
267                { "DuplicateProfileProjectAction", STOCK_COPY, N_("Duplicate profile"), "<Control>d", N_("Duplicate current profile"), on_duplicate_profile },
268                { "RemoveProfileFromProjectProjectAction", STOCK_REMOVE, N_("Remove profile from project"), null, N_("Remove a profile from current project"), on_remove_profile },
269                { "BuildProfileProjectAction", STOCK_EXECUTE, N_("Build profile"), "<Control><Shift>b", N_("Build current profile"), on_build_profile },
270                { "ProgramProfileProjectAction", STOCK_MEDIA_RECORD, N_("Program profile"), "<Control><Shift>p", N_("Program current profile"), on_program_profile },
271                { "StopProjectAction", STOCK_STOP, N_("Stop"), "", N_("Stop building current profile"), on_stop },
272                { "CleanProfileProjectAction", STOCK_CLEAR, N_("Clean profile"), null, N_("Clean current profile"), on_clean_profile },
273                { "CloseProjectAction", STOCK_CLOSE, null, null, N_("Close current project"), on_close }
274        };
275       
276        private const string _UI = """
277<ui>
278        <menubar name="MainMenu">
279                <placeholder name="MenuBarOps">
280                        <menu name="ProjectsMenu" action="ProjectsMenuAction">
281                                <menuitem action="NewProjectAction"/>
282                                <separator/>
283                                <menuitem action="AddFileProjectAction"/>
284                                <menuitem action="RemoveFileFromProjectProjectAction"/>
285                                <menuitem action="RemoveFileFromProfileProjectAction"/>
286                                <separator/>
287                                <menuitem action="AddProfileProjectAction"/>
288                                <menuitem action="EditProfileProjectAction"/>
289                                <menuitem action="DuplicateProfileProjectAction"/>
290                                <menuitem action="RemoveProfileFromProjectProjectAction"/>
291                                <separator/>
292                                <menuitem action="BuildProfileProjectAction"/>
293                                <menuitem action="StopProjectAction"/>
294                                <menuitem action="CleanProfileProjectAction"/>
295                                <menuitem action="ProgramProfileProjectAction"/>
296                                <separator/>
297                                <menuitem action="CloseProjectAction"/>
298                        </menu>
299                </placeholder>
300        </menubar>
301        <toolbar name="MainToolbar">
302                <placeholder name="ToolbarEndOps">
303                        <separator/>
304                                <toolitem action="BuildProfileProjectAction"/>
305                                <toolitem action="StopProjectAction"/>
306                                <toolitem action="ProgramProfileProjectAction"/>
307                        <separator/>
308                </placeholder>
309        </toolbar>
310</ui>""";
311}
Note: See TracBrowser for help on using the repository browser.