1
by donadigo
Initial commit; this is not original branch; all the euclide files are included + bazaar extension |
1 |
/*
|
2 |
* Copyright (c) 2011 Lucas Baudin <xapantu@gmail.com>
|
|
3 |
*
|
|
4 |
* This is a free software; you can redistribute it and/or
|
|
5 |
* modify it under the terms of the GNU General Public License as
|
|
6 |
* published by the Free Software Foundation; either version 2 of the
|
|
7 |
* License, or (at your option) any later version.
|
|
8 |
*
|
|
9 |
* This is distributed in the hope that it will be useful,
|
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
12 |
* General Public License for more details.
|
|
13 |
*
|
|
14 |
* You should have received a copy of the GNU General Public
|
|
15 |
* License along with this program; see the file COPYING. If not,
|
|
16 |
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
17 |
* Boston, MA 02111-1307, USA.
|
|
18 |
*`
|
|
19 |
*/
|
|
20 |
||
21 |
using Euclide; |
|
22 |
using Granite.Widgets; |
|
23 |
||
24 |
Settings euclide_settings; |
|
25 |
Scratch.Services.Interface plugins; |
|
26 |
||
27 |
public class Euclide.Plugin : Peas.Activatable, Object { |
|
28 |
||
29 |
Gtk.ActionGroup main_actions; |
|
30 |
Gtk.UIManager ui; |
|
31 |
Terminal terminal; |
|
32 |
RawTerminal raw_terminal; |
|
33 |
Gtk.Menu menu_binaries; |
|
34 |
ProgramList list; |
|
35 |
Gtk.Notebook notebook_terminal; |
|
36 |
Gtk.ToolButton toolbar_compile; |
|
37 |
Granite.Widgets.ToolArrow build_arrow; |
|
38 |
CMake.Parser cmake; |
|
39 |
Euclide.Bazaar.BazaarDialog bzr_dialog; |
|
40 |
GLib.List<CMake.Parser> projects; |
|
41 |
SearchBar search_bar; |
|
42 |
||
43 |
static string current_folder = GLib.Environment.get_home_dir (); |
|
44 |
static string project_path; |
|
45 |
static string executable; |
|
46 |
||
47 |
Scratch.MainWindow? window = null; |
|
48 |
Scratch.Widgets.Toolbar? toolbar = null; |
|
49 |
||
50 |
const string ui_string = """ |
|
51 |
<ui> |
|
52 |
<popup name="CompactMenu" accelerators="true"> |
|
53 |
<menuitem name="Open Project" action="Open Project"/> |
|
54 |
<menuitem name="Terminal" action="Terminal"/> |
|
55 |
<menuitem name="Build and test" action="Build and test"/> |
|
56 |
<menuitem name="Only Build" action="Only Build"/> |
|
57 |
<menuitem name="Clean" action="Clean"/> |
|
58 |
<menuitem name="Plugins" action="Plugins"/> |
|
59 |
<menu action="Add"> |
|
60 |
<menuitem name="AddLibrary" action="AddLibrary"/> |
|
61 |
<menuitem name="AddExecutable" action="AddExecutable"/> |
|
62 |
</menu> |
|
63 |
<menuitem name="Project Settings" action="Project Settings"/> |
|
64 |
<menuitem name="Settings" action="Settings"/> |
|
65 |
<menuitem name="About" action="About"/> |
|
66 |
</popup> |
|
67 |
<popup name="MenuItemTool" accelerators="false"> |
|
68 |
<menuitem name="Save" action="Save"/> |
|
69 |
<menuitem name="New" action="New"/> |
|
70 |
<menuitem name="Compile" action="Compile"/> |
|
71 |
<menuitem name="Build and test" action="Build and test"/> |
|
72 |
<menuitem name="Fetch" action="Fetch"/> |
|
73 |
<menuitem name="Save as" action="Save as"/> |
|
74 |
<menuitem name="About" action="About"/> |
|
75 |
</popup> |
|
76 |
<popup name="AppMenu" accelerators="true"> |
|
77 |
<separator /> |
|
78 |
<menuitem name="AddExecutable" action="AddExecutable"/> |
|
79 |
<menuitem name="AddLibrary" action="AddLibrary"/> |
|
80 |
<menuitem name="Open Project" action="Open Project"/> |
|
81 |
</popup> |
|
82 |
</ui> |
|
83 |
""";
|
|
84 |
||
85 |
void on_new_source_view (Scratch.Services.Document doc) { |
|
86 |
var view = doc.source_view; |
|
87 |
((Gtk.TextView)view).key_press_event.connect(Euclide.SourceView.on_insert_event); |
|
88 |
}
|
|
89 |
||
90 |
void hook_preferences_dialog (Object dialog) { |
|
91 |
var preferences_dialog = dialog as Scratch.Dialogs.Preferences; |
|
92 |
assert(preferences_dialog != null); |
|
93 |
this.projects.foreach ((project) => { |
|
94 |
var euclide_settings = new ProjectSettingsDialog(project); |
|
95 |
//preferences_dialog.main_static_notebook.append_page (euclide_settings, new Gtk.Label(project.project.name));
|
|
96 |
});
|
|
97 |
}
|
|
98 |
||
99 |
void on_new_window (Scratch.MainWindow window) { |
|
100 |
if (this.window != null) |
|
101 |
return; |
|
102 |
this.window = window; |
|
103 |
debug (""); |
|
104 |
window.add_accel_group (ui.get_accel_group ()); |
|
105 |
}
|
|
106 |
||
107 |
void action_new_project () { |
|
108 |
var dialog = new NewProjectDialog (this.window); |
|
109 |
string project = dialog.create (); |
|
110 |
if (project != null) { |
|
111 |
open_project (project); |
|
112 |
}
|
|
113 |
dialog.destroy (); |
|
114 |
}
|
|
115 |
||
116 |
void action_add_library () { |
|
117 |
var dialog = new EntryDialog (this.window); |
|
118 |
dialog.title = _("Add Library"); |
|
119 |
dialog.run (); |
|
120 |
cmake.add_target (dialog.value_entry, true /* is library */); |
|
121 |
||
122 |
list.open_project (cmake); |
|
123 |
update_executable_menu (); |
|
124 |
||
125 |
dialog.destroy (); |
|
126 |
}
|
|
127 |
||
128 |
void action_add_executable () { |
|
129 |
var dialog = new EntryDialog (this.window); |
|
130 |
dialog.title = _("Add Executable"); |
|
131 |
dialog.run (); |
|
132 |
cmake.add_target(dialog.value_entry); |
|
133 |
||
134 |
list.open_project(cmake); |
|
135 |
update_executable_menu(); |
|
136 |
||
137 |
dialog.destroy(); |
|
138 |
}
|
|
139 |
||
140 |
/*void welcome_activated(int index) {
|
|
141 |
switch(index)
|
|
142 |
{
|
|
143 |
case 0: /* create *
|
|
144 |
action_new_project();
|
|
145 |
break;
|
|
146 |
case 1: /* open project *
|
|
147 |
action_open_project();
|
|
148 |
break;
|
|
149 |
case 2:
|
|
150 |
action_open_file();
|
|
151 |
break;
|
|
152 |
default:
|
|
153 |
open_project(euclide_settings.get_string("recent-" + (index - 2).to_string()));
|
|
154 |
break;
|
|
155 |
}
|
|
156 |
}*/
|
|
157 |
||
158 |
void update_executable_menu () { |
|
159 |
Gtk.RadioMenuItem menuitem = null; |
|
160 |
foreach (var w in menu_binaries.get_children()) { |
|
161 |
w.destroy(); |
|
162 |
}
|
|
163 |
foreach (var bin in cmake.project.bin) { |
|
164 |
menuitem = new Gtk.RadioMenuItem.with_label((menuitem != null ? menuitem.get_group() : null), bin.name); |
|
165 |
menuitem.activate.connect( () => { executable = bin.filename; }); |
|
166 |
menu_binaries.append(menuitem); |
|
167 |
}
|
|
168 |
menu_binaries.show_all(); |
|
169 |
}
|
|
170 |
||
171 |
Gtk.VBox create_binary_choice () { |
|
172 |
var vbox = new Gtk.VBox(false, 0); |
|
173 |
Gtk.RadioButton? former_radio = null; |
|
174 |
this.projects.foreach ((project) => { |
|
175 |
foreach(var bin in project.project.bin) { |
|
176 |
former_radio = new Gtk.RadioButton(former_radio == null ? null : former_radio.get_group()); |
|
177 |
former_radio.label = bin.name; |
|
178 |
former_radio.toggled.connect( () => { executable = bin.filename; }); |
|
179 |
vbox.pack_start(former_radio); |
|
180 |
if(bin.filename == executable) |
|
181 |
former_radio.active = true; |
|
182 |
}
|
|
183 |
});
|
|
184 |
return vbox; |
|
185 |
}
|
|
186 |
||
187 |
void unlock_project_actions() |
|
188 |
{
|
|
189 |
main_actions.get_action("Project Settings").set_sensitive(true); |
|
190 |
main_actions.get_action("Add").set_sensitive(true); |
|
191 |
main_actions.get_action("AddLibrary").set_sensitive(true); |
|
192 |
main_actions.get_action("AddExecutable").set_sensitive(true); |
|
193 |
}
|
|
194 |
||
195 |
void lock_project_actions() |
|
196 |
{
|
|
197 |
main_actions.get_action("Project Settings").set_sensitive(false); |
|
198 |
main_actions.get_action("Add").set_sensitive(false); |
|
199 |
main_actions.get_action("AddLibrary").set_sensitive(false); |
|
200 |
main_actions.get_action("AddExecutable").set_sensitive(false); |
|
201 |
}
|
|
202 |
||
203 |
public void open_project(string filename) { |
|
204 |
unlock_project_actions(); |
|
205 |
unlock_build(); |
|
206 |
project_path = filename; |
|
207 |
cmake = new Euclide.CMake.Parser(project_path + "/CMakeLists.txt"); |
|
208 |
if(cmake.project.bin.size > 0) |
|
209 |
executable = cmake.project.bin[0].filename; |
|
210 |
cmake.project.project_path = project_path; |
|
211 |
projects.append(cmake); |
|
212 |
list.open_project(cmake, project_path); |
|
213 |
update_executable_menu(); |
|
214 |
list.no_show_all = false; |
|
215 |
list.visible = true; |
|
216 |
list.show_all(); |
|
217 |
}
|
|
218 |
||
219 |
public void action_fetch() { |
|
220 |
search_bar.grab_focus(); |
|
221 |
}
|
|
222 |
||
223 |
Threads.SimpleCommand simple_command; |
|
224 |
BuildActions.Build build_command; |
|
225 |
BuildActions.Check check_command; |
|
226 |
||
227 |
public void action_build() { |
|
228 |
show_terminal(); |
|
229 |
lock_build(); |
|
230 |
build_command = new BuildActions.Build(cmake, raw_terminal, terminal, list.progress); |
|
231 |
build_command.build_finished.connect( (exit) => { |
|
232 |
unlock_build(); |
|
233 |
if(exit == 0) |
|
234 |
{
|
|
235 |
raw_terminal.clear(); |
|
236 |
string[] arguments = cmake.arguments.split(" "); |
|
237 |
Gee.LinkedList<string> new_arguments = new Gee.LinkedList<string>(); |
|
238 |
new_arguments.add(executable); |
|
239 |
foreach(var arg in arguments) |
|
240 |
new_arguments.add(arg); |
|
241 |
try { |
|
242 |
raw_terminal.fork_command_full (Vte.PtyFlags.DEFAULT, project_path, new_arguments.to_array(), null, SpawnFlags.SEARCH_PATH, null, null); |
|
243 |
} catch (Error e) { |
|
244 |
warning (e.message); |
|
245 |
}
|
|
246 |
}
|
|
247 |
else
|
|
248 |
{
|
|
249 |
show_terminal(); |
|
250 |
}
|
|
251 |
});
|
|
252 |
build_command.run(); |
|
253 |
}
|
|
254 |
||
255 |
public void action_only_build() |
|
256 |
{
|
|
257 |
show_terminal(); |
|
258 |
lock_build(); |
|
259 |
build_command = new BuildActions.Build(cmake, raw_terminal, terminal, list.progress); |
|
260 |
build_command.build_finished.connect( (exit) => { |
|
261 |
unlock_build(); |
|
262 |
});
|
|
263 |
build_command.run(); |
|
264 |
}
|
|
265 |
||
266 |
void lock_build() |
|
267 |
{
|
|
268 |
notebook_terminal.page = 0; |
|
269 |
main_actions.get_action("Clean").set_sensitive(false); |
|
270 |
main_actions.get_action("Build and test").set_sensitive(false); |
|
271 |
main_actions.get_action("Compile").set_sensitive(false); |
|
272 |
main_actions.get_action("Only Build").set_sensitive(false); |
|
273 |
build_arrow.set_sensitive(false); |
|
274 |
toolbar_compile.set_sensitive(false); |
|
275 |
}
|
|
276 |
||
277 |
void unlock_build() |
|
278 |
{
|
|
279 |
main_actions.get_action("Clean").set_sensitive(true); |
|
280 |
main_actions.get_action("Build and test").set_sensitive(true); |
|
281 |
main_actions.get_action("Compile").set_sensitive(true); |
|
282 |
main_actions.get_action("Only Build").set_sensitive(true); |
|
283 |
build_arrow.set_sensitive (true); |
|
284 |
toolbar_compile.set_sensitive(true); |
|
285 |
}
|
|
286 |
||
287 |
void action_make_check() |
|
288 |
{
|
|
289 |
lock_build(); |
|
290 |
check_command = new BuildActions.Check(cmake, raw_terminal); |
|
291 |
show_terminal(); |
|
292 |
check_command.build_finished.connect( (exit) => { |
|
293 |
unlock_build(); |
|
294 |
});
|
|
295 |
check_command.run(); |
|
296 |
}
|
|
297 |
||
298 |
||
299 |
public void action_build_tests() |
|
300 |
{
|
|
301 |
lock_build(); |
|
302 |
build_command = new BuildActions.Build(cmake, raw_terminal, terminal, list.progress); |
|
303 |
show_terminal(); |
|
304 |
build_command.build_finished.connect( (exit) => { |
|
305 |
if(exit == 0) |
|
306 |
{
|
|
307 |
if(!euclide_settings.get_boolean ("make-ctest")) |
|
308 |
{
|
|
309 |
notebook_terminal.page = 1; |
|
310 |
raw_terminal.clear(); |
|
311 |
simple_command = new Threads.SimpleCommand(project_path + "/build/", "/usr/bin/ctest -V"); |
|
312 |
simple_command.output_changed.connect((text) => {raw_terminal.add_text(text); }); |
|
313 |
simple_command.done.connect( (exit) => { |
|
314 |
unlock_build(); |
|
315 |
});
|
|
316 |
simple_command.run(); |
|
317 |
}
|
|
318 |
else
|
|
319 |
action_make_check(); |
|
320 |
}
|
|
321 |
else
|
|
322 |
unlock_build(); |
|
323 |
});
|
|
324 |
build_command.run(); |
|
325 |
}
|
|
326 |
||
327 |
public void action_clean_project() |
|
328 |
{
|
|
329 |
lock_build(); |
|
330 |
simple_command = new Threads.SimpleCommand(project_path + "/build/", "/usr/bin/make clean"); |
|
331 |
simple_command.output_changed.connect((text) => {raw_terminal.add_text(text); }); |
|
332 |
simple_command.done.connect( () => {unlock_build(); }); |
|
333 |
simple_command.run(); |
|
334 |
}
|
|
335 |
||
336 |
public void action_terminal() { |
|
337 |
notebook_terminal.visible = !notebook_terminal.visible; |
|
338 |
notebook_terminal.no_show_all = !notebook_terminal.no_show_all; |
|
339 |
}
|
|
340 |
||
341 |
public void show_terminal () { |
|
342 |
terminal_grid.visible = true; |
|
343 |
terminal_grid.no_show_all = false; |
|
344 |
terminal_grid.show_all(); |
|
345 |
scrolled_raw_terminal.visible = true; |
|
346 |
scrolled_raw_terminal.no_show_all = false; |
|
347 |
scrolled_raw_terminal.show_all(); |
|
348 |
}
|
|
349 |
||
350 |
public void hide_terminal () { |
|
351 |
terminal_grid.visible = false; |
|
352 |
terminal_grid.no_show_all = true; |
|
353 |
scrolled_raw_terminal.visible = false; |
|
354 |
scrolled_raw_terminal.no_show_all = true; |
|
355 |
}
|
|
356 |
||
357 |
public void open_file(string file_path, int line = -1) |
|
358 |
{
|
|
359 |
var file = GLib.File.new_for_path (file_path); |
|
360 |
plugins.open_file (file).source_view.go_to_line (line); |
|
361 |
}
|
|
362 |
||
363 |
void action_open_project () { |
|
364 |
var file_chooser = new Gtk.FileChooserDialog (_("Open a file..."), |
|
365 |
this.window, Gtk.FileChooserAction.OPEN, |
|
366 |
Gtk.Stock.CANCEL, Gtk.ResponseType.CANCEL, |
|
367 |
Gtk.Stock.OPEN, Gtk.ResponseType.ACCEPT, null); |
|
368 |
file_chooser.set_current_folder (current_folder); |
|
369 |
file_chooser.add_filter (get_project_filter ()); |
|
370 |
||
371 |
int reponse = file_chooser.run (); |
|
372 |
if (reponse == Gtk.ResponseType.ACCEPT) { |
|
373 |
open_project (file_chooser.get_current_folder ()); |
|
374 |
}
|
|
375 |
current_folder = file_chooser.get_current_folder (); |
|
376 |
file_chooser.destroy (); |
|
377 |
show_terminal (); |
|
378 |
}
|
|
379 |
||
380 |
static const Gtk.ActionEntry[] main_entries = { |
|
381 |
{ "Terminal", null, |
|
382 |
/* label, accelerator */ N_("Terminal"), null, |
|
383 |
/* tooltip */ N_("Terminal"), |
|
384 |
action_terminal }, |
|
385 |
{ "Only Build", Gtk.Stock.EXECUTE, |
|
386 |
/* label, accelerator */ N_("Only Build"), "<Control><shift>b", |
|
387 |
/* tooltip */ N_("Only Build"), |
|
388 |
action_only_build }, |
|
389 |
{ "Compile", Gtk.Stock.MEDIA_PLAY, |
|
390 |
/* label, accelerator */ N_("Compile"), "<Control><shift>r", |
|
391 |
/* tooltip */ N_("Compile"), |
|
392 |
action_build }, |
|
393 |
{ "Build and test", Gtk.Stock.EXECUTE, |
|
394 |
/* label, accelerator */ N_("Build and test"), "<Control>u", |
|
395 |
/* tooltip */ N_("Build and test"), |
|
396 |
action_build_tests }, |
|
397 |
{ "Open Project", Gtk.Stock.OPEN, |
|
398 |
/* label, accelerator */ N_("Open Project"), "<Control><shift>o", |
|
399 |
/* tooltip */ N_("Open Project"), |
|
400 |
action_open_project }, |
|
401 |
{ "Clean", Gtk.Stock.CLEAR, |
|
402 |
/* label, accelerator */ N_("Clean"), "<Control><alt>c", |
|
403 |
/* tooltip */ N_("Clean"), |
|
404 |
action_clean_project }, |
|
405 |
{ "New Project", Gtk.Stock.NEW, |
|
406 |
/* label, accelerator */ N_("New Project"), "<Control><shift>n", |
|
407 |
/* tooltip */ N_("New Project"), |
|
408 |
action_new_project }, |
|
409 |
{ "Add", null, |
|
410 |
/* label, accelerator */ N_("Add"), null, |
|
411 |
/* tooltip */ N_("Add"), |
|
412 |
null }, |
|
413 |
{ "AddLibrary", Gtk.Stock.ADD, |
|
414 |
/* label, accelerator */ N_("Add a library"), null, |
|
415 |
/* tooltip */ N_("Add a library"), |
|
416 |
action_add_library }, |
|
417 |
{ "AddExecutable", Gtk.Stock.ADD, |
|
418 |
/* label, accelerator */ N_("Add an executable"), null, |
|
419 |
/* tooltip */ N_("Add an excutable"), |
|
420 |
action_add_executable }, |
|
421 |
{ "Project Settings", null, |
|
422 |
/* label, accelerator */ N_("Project Settings"), null, |
|
423 |
/* tooltip */ N_("Project Settings"), |
|
424 |
null }, |
|
425 |
{ "Settings", null, |
|
426 |
/* label, accelerator */ N_("Settings"), null, |
|
427 |
/* tooltip */ N_("Settings"), |
|
428 |
null }, |
|
429 |
{ "About", null, |
|
430 |
/* label, accelerator */ N_("About"), null, |
|
431 |
/* tooltip */ N_("About"), |
|
432 |
null }, |
|
433 |
{ "Save", null, |
|
434 |
/* label, accelerator */ N_("Save"), null, |
|
435 |
/* tooltip */ N_("Save"), |
|
436 |
null }, |
|
437 |
{ "New", null, |
|
438 |
/* label, accelerator */ N_("New"), null, |
|
439 |
/* tooltip */ N_("New"), |
|
440 |
null }, |
|
441 |
{ "Fetch", null, |
|
442 |
/* label, accelerator */ N_("Fetch"), null, |
|
443 |
/* tooltip */ N_("Fetch"), |
|
444 |
null }, |
|
445 |
{ "Save as", null, |
|
446 |
/* label, accelerator */ N_("Save as"), null, |
|
447 |
/* tooltip */ N_("Save as"), |
|
448 |
null }, |
|
449 |
{ "Plugins", null, |
|
450 |
/* label, accelerator */ N_("Plugins"), null, |
|
451 |
/* tooltip */ N_("Plugins"), |
|
452 |
null } |
|
453 |
};
|
|
454 |
||
455 |
Gtk.FileFilter get_project_filter() { |
|
456 |
var filter = new Gtk.FileFilter(); |
|
457 |
filter.set_filter_name(_("CMake Project")); |
|
458 |
filter.add_pattern("CMakeLists.txt"); |
|
459 |
return filter; |
|
460 |
}
|
|
461 |
||
462 |
public Object object { owned get; construct; } |
|
463 |
||
464 |
public void activate() |
|
465 |
{
|
|
466 |
||
467 |
/* Init stuff */
|
|
468 |
||
469 |
euclide_settings = new Settings("org.pantheon.euclide.settings"); |
|
470 |
main_actions = new Gtk.ActionGroup("MainActionGroup"); /* Actions and UIManager */ |
|
471 |
main_actions.set_translation_domain("euclide"); |
|
472 |
main_actions.add_actions(main_entries, this); |
|
473 |
||
474 |
build_arrow = new Granite.Widgets.ToolArrow(); |
|
475 |
build_arrow.no_show_all = false; |
|
476 |
build_arrow.visible = true; |
|
477 |
||
478 |
// Init internationalization support
|
|
479 |
Intl.setlocale (LocaleCategory.ALL, ""); |
|
480 |
string langpack_dir = Path.build_filename (Constants.INSTALL_PREFIX, "share", "locale"); |
|
481 |
Intl.bindtextdomain (Constants.GETTEXT_PACKAGE, langpack_dir); |
|
482 |
Intl.bind_textdomain_codeset (Constants.GETTEXT_PACKAGE, "UTF-8"); |
|
483 |
Intl.textdomain (Constants.GETTEXT_PACKAGE); |
|
484 |
||
485 |
// Init projects var
|
|
486 |
this.projects = new GLib.List<CMake.Parser> (); |
|
487 |
||
488 |
ui = new Gtk.UIManager(); |
|
489 |
try { |
|
490 |
ui.add_ui_from_string(ui_string, -1); |
|
491 |
}
|
|
492 |
catch(Error e) { |
|
493 |
error("Couldn't load the UI"); |
|
494 |
}
|
|
495 |
ui.insert_action_group(main_actions, 0); |
|
496 |
ui.ensure_update(); |
|
497 |
list = new ProgramList(); |
|
498 |
list.open_file.connect( (s) => {open_file(s);}); |
|
499 |
notebook_terminal = new Gtk.Notebook(); |
|
500 |
||
501 |
terminal = new Terminal(); |
|
502 |
terminal.open_file.connect(open_file); |
|
503 |
||
504 |
raw_terminal = new RawTerminal(); |
|
505 |
raw_terminal.child_exited.connect( () => { raw_terminal.add_text("[Exited]\n"); }); |
|
506 |
||
507 |
toolbar_compile = (Gtk.ToolButton)new Gtk.MenuToolButton.from_stock(Gtk.Stock.EXECUTE); |
|
508 |
menu_binaries = new Gtk.Menu (); |
|
509 |
menu_binaries.show_all (); |
|
510 |
((Gtk.MenuToolButton)toolbar_compile).set_menu(menu_binaries); |
|
511 |
toolbar_compile.clicked.connect (() => { action_build(); }); |
|
512 |
||
513 |
plugins = (Scratch.Services.Interface) object; |
|
514 |
plugins.hook_notebook_sidebar.connect (on_notebook_sidebar); |
|
515 |
plugins.hook_main_menu.connect (on_main_menu); |
|
516 |
plugins.hook_notebook_bottom.connect (on_notebook_bottom); |
|
517 |
plugins.hook_toolbar.connect (on_toolbar); |
|
518 |
plugins.hook_window.connect (on_new_window); |
|
519 |
plugins.hook_document.connect (on_new_source_view); |
|
520 |
plugins.hook_preferences_dialog.connect (hook_preferences_dialog); |
|
521 |
||
522 |
lock_build (); |
|
523 |
lock_project_actions (); |
|
524 |
||
525 |
//on_set_arg();
|
|
526 |
||
527 |
/* Templates! */
|
|
528 |
var template_manager = plugins.template_manager; |
|
529 |
template_manager.template_loaded.connect ((t, f) => { |
|
530 |
debug (f.get_path ()); |
|
531 |
// Open loaded template
|
|
532 |
if (!f.query_exists ()) |
|
533 |
return; |
|
534 |
||
535 |
open_project (f.get_path ()); |
|
536 |
current_folder = f.get_path (); |
|
537 |
show_terminal (); |
|
538 |
});
|
|
539 |
||
540 |
}
|
|
541 |
||
542 |
void on_notebook_sidebar (Gtk.Notebook sidebar) { |
|
543 |
sidebar.append_page (list, new Gtk.Label (_("Project"))); |
|
544 |
}
|
|
545 |
||
546 |
Gtk.Grid terminal_grid; |
|
547 |
Gtk.ScrolledWindow scrolled_raw_terminal; |
|
548 |
||
549 |
void on_notebook_bottom (Gtk.Notebook bottombar) { |
|
550 |
terminal_grid = new Gtk.Grid (); |
|
551 |
raw_terminal.vexpand = true; |
|
552 |
raw_terminal.hexpand = true; |
|
553 |
var sb = new Gtk.Scrollbar (Gtk.Orientation.VERTICAL, raw_terminal.vadjustment); |
|
554 |
terminal_grid.attach (raw_terminal, 0, 0, 1, 1); |
|
555 |
terminal_grid.attach (sb, 1, 0, 1, 1); |
|
556 |
bottombar.append_page (terminal_grid, new Gtk.Label (_("Compilation"))); |
|
557 |
||
558 |
scrolled_raw_terminal = new Gtk.ScrolledWindow (null, null); |
|
559 |
scrolled_raw_terminal.add (terminal); |
|
560 |
bottombar.append_page (scrolled_raw_terminal, new Gtk.Label (_("Output"))); |
|
561 |
||
562 |
hide_terminal (); |
|
563 |
}
|
|
564 |
||
565 |
void on_main_menu (Gtk.Menu main_menu) { |
|
566 |
/*var sep = new Gtk.SeparatorMenuItem ();
|
|
567 |
main_menu.insert (sep, 5);
|
|
568 |
sep.show ();
|
|
569 |
var menu = ui.get_widget ("ui/AppMenu") as Gtk.Menu;
|
|
570 |
((Gtk.Container)menu).get_children ().foreach ((w) => {
|
|
571 |
w.unparent ();
|
|
572 |
main_menu.insert ((Gtk.MenuItem)w, 5);
|
|
573 |
});*/
|
|
574 |
main_menu.insert ((Gtk.MenuItem)main_actions.get_action ("AddExecutable").create_menu_item (), 5); |
|
575 |
main_menu.insert ((Gtk.MenuItem)main_actions.get_action ("AddLibrary").create_menu_item (), 5); |
|
576 |
main_menu.insert ((Gtk.MenuItem)main_actions.get_action ("Open Project").create_menu_item (), 5); |
|
577 |
}
|
|
578 |
||
579 |
/*** TOOLBAR SECTION ***/
|
|
580 |
void on_toolbar (Scratch.Widgets.Toolbar toolbar) { |
|
581 |
if (this.toolbar != null) |
|
582 |
return; |
|
583 |
this.toolbar = toolbar; |
|
584 |
build_arrow.clicked.connect (on_show_popover); |
|
585 |
toolbar.pack_start (build_arrow); |
|
586 |
toolbar.pack_start ((Gtk.ToolItem)main_actions.get_action ("Compile").create_tool_item ()); |
|
587 |
toolbar.pack_start ((Gtk.ToolItem)main_actions.get_action ("Only Build").create_tool_item ()); |
|
588 |
var bzr_btn = new Gtk.Button.from_icon_name("applications-versioncontrol", Gtk.IconSize.LARGE_TOOLBAR); |
|
589 |
bzr_btn.clicked.connect(() => { |
|
590 |
bzr_dialog = new Bazaar.BazaarDialog (); |
|
591 |
bzr_dialog.build_ui (current_folder); |
|
592 |
});
|
|
593 |
toolbar.pack_end (bzr_btn); |
|
594 |
toolbar.show_all (); |
|
595 |
}
|
|
596 |
||
597 |
public void deactivate() { |
|
598 |
}
|
|
599 |
||
600 |
public void update_state() { |
|
601 |
}
|
|
602 |
||
603 |
void on_show_popover() { |
|
604 |
build_arrow.set_state (true); |
|
605 |
var build_popover = new Granite.Widgets.PopOver(); |
|
606 |
build_popover.move_to_widget(build_arrow); |
|
607 |
var box = build_popover.get_content_area() as Gtk.Box; |
|
608 |
var label = new Gtk.Label(_("Binary to launch:")); |
|
609 |
label.halign = Gtk.Align.START; |
|
610 |
box.pack_start(label); |
|
611 |
box.pack_start(create_binary_choice()); |
|
612 |
var arguments = new Granite.Widgets.HintedEntry(_("Arguments...")); |
|
613 |
arguments.text = cmake.arguments; |
|
614 |
arguments.set_margin_top(10); |
|
615 |
box.pack_start(arguments); |
|
616 |
build_popover.show_all(); |
|
617 |
build_popover.present(); |
|
618 |
build_popover.run(); |
|
619 |
cmake.arguments = arguments.text; |
|
620 |
build_popover.destroy(); |
|
621 |
build_arrow.set_state (false); |
|
622 |
||
623 |
}
|
|
624 |
||
625 |
/*public void on_set_arg()
|
|
626 |
{
|
|
627 |
if (plugins.set_name.down() == "euclide" && plugins.argument != null)
|
|
628 |
open_project(plugins.argument);
|
|
629 |
}*/
|
|
630 |
||
631 |
}
|
|
632 |
||
633 |
[ModuleInit] |
|
634 |
public void peas_register_types (GLib.TypeModule module) { |
|
635 |
var objmodule = module as Peas.ObjectModule; |
|
636 |
objmodule.register_extension_type (typeof (Peas.Activatable), |
|
637 |
typeof (Euclide.Plugin)); |
|
638 |
}
|