1 static Xcls_ValaCompileErrors _ValaCompileErrors;
3 public class Xcls_ValaCompileErrors : Object
6 private Xcls_ValaCompileErrors _this;
8 public static Xcls_ValaCompileErrors singleton()
10 if (_ValaCompileErrors == null) {
11 _ValaCompileErrors= new Xcls_ValaCompileErrors();
13 return _ValaCompileErrors;
15 public Xcls_compile_view compile_view;
16 public Xcls_save_btn save_btn;
17 public Xcls_hpane hpane;
18 public Xcls_compile_tree compile_tree;
19 public Xcls_compile_result_store compile_result_store;
20 public Xcls_renderer renderer;
21 public Xcls_sourceview sourceview;
24 public Xcls_MainWindow window;
26 public Json.Object notices;
29 public Xcls_ValaCompileErrors()
32 this.el = new Gtk.Popover( null );
38 this.el.width_request = 900;
39 this.el.height_request = 800;
40 this.el.modal = false;
41 this.el.position = Gtk.PositionType.TOP;
42 var child_0 = new Xcls_compile_view( _this );
44 this.el.add ( child_0.el );
47 this.el.closed.connect( () => {
56 // user defined functions
57 public void show (Json.Object tree, Gtk.Widget onbtn) {
61 //print("looking for %s\n", id);
62 // loop through parent childnre
65 var store = this.compile_result_store.el;
70 tree.foreach_member((obj, file, node) => {
71 // id line "display text", file
73 var title = GLib.Path.get_basename(GLib.Path.get_dirname( file)) + "/" + GLib.Path.get_basename( file) ;
75 print("Add file %s", title);
76 store.append(out iter, null);
77 var lines = tree.get_object_member(file);
78 title += " (" + lines.get_size().to_string() + ")";
79 store.set(iter, 0, file, 1, 0, 2, title, 3, file,-1);
81 lines.foreach_member((obja, line, nodea) => {
83 var ar = lines.get_array_member(line);
84 for (var i = 0 ; i < ar.get_length(); i++) {
85 msg += (msg.length > 0) ? "\n" : "";
86 msg += ar.get_string_element(i);
89 print("Add line %s", line);
90 store.append(out citer, iter);
94 2, GLib.Markup.escape_text(line + ": " + msg),
104 this.window.el.get_size(out w, out h);
106 // left tree = 250, editor area = 500?
108 var new_w = int.min(750, w-100);
109 if (new_w > (w-100)) {
112 this.el.set_size_request( int.max(100, new_w), int.max(100, h-120));
115 this.hpane.el.set_position(250);
116 if (this.el.relative_to == null) {
117 this.el.set_relative_to(onbtn);
120 this.save_btn.el.hide();
123 public class Xcls_compile_view : Object
126 private Xcls_ValaCompileErrors _this;
132 public Xcls_compile_view(Xcls_ValaCompileErrors _owner )
135 _this.compile_view = this;
136 this.el = new Gtk.VBox( false, 0 );
140 // set gobject values
141 var child_0 = new Xcls_HBox3( _this );
143 this.el.pack_start ( child_0.el , false,false,0 );
144 var child_1 = new Xcls_hpane( _this );
146 this.el.pack_start ( child_1.el , true,true,0 );
149 // user defined functions
151 public class Xcls_HBox3 : Object
154 private Xcls_ValaCompileErrors _this;
160 public Xcls_HBox3(Xcls_ValaCompileErrors _owner )
163 this.el = new Gtk.HBox( true, 0 );
167 // set gobject values
168 var child_0 = new Xcls_Button4( _this );
170 this.el.pack_start ( child_0.el , true,true,0 );
171 var child_1 = new Xcls_Button5( _this );
173 this.el.pack_start ( child_1.el , true,true,0 );
174 var child_2 = new Xcls_save_btn( _this );
176 this.el.pack_start ( child_2.el , true,true,0 );
179 // user defined functions
181 public class Xcls_Button4 : Object
183 public Gtk.Button el;
184 private Xcls_ValaCompileErrors _this;
190 public Xcls_Button4(Xcls_ValaCompileErrors _owner )
193 this.el = new Gtk.Button();
197 // set gobject values
198 this.el.label = "Compile and Run";
201 // user defined functions
203 public class Xcls_Button5 : Object
205 public Gtk.Button el;
206 private Xcls_ValaCompileErrors _this;
212 public Xcls_Button5(Xcls_ValaCompileErrors _owner )
215 this.el = new Gtk.Button();
219 // set gobject values
220 this.el.label = "Edit";
223 this.el.clicked.connect( () => {
224 // is the file managed by the builder?
226 var f = _this.sourceview.curfname;
228 Regex regex = new Regex("\\.vala$");
230 var bjsf = regex.replace(f,f.length , 0 , ".bjs");
232 var p = _this.window.project;
236 var jsr = p.getByPath(bjsf);
238 _this.window.windowstate.fileViewOpen(jsr);
248 // user defined functions
250 public class Xcls_save_btn : Object
252 public Gtk.Button el;
253 private Xcls_ValaCompileErrors _this;
259 public Xcls_save_btn(Xcls_ValaCompileErrors _owner )
262 _this.save_btn = this;
263 this.el = new Gtk.Button();
267 // set gobject values
268 this.el.label = "Save";
269 this.el.visible = false;
272 // user defined functions
274 public class Xcls_hpane : Object
276 public Gtk.HPaned el;
277 private Xcls_ValaCompileErrors _this;
283 public Xcls_hpane(Xcls_ValaCompileErrors _owner )
287 this.el = new Gtk.HPaned();
291 // set gobject values
292 var child_0 = new Xcls_ScrolledWindow8( _this );
294 this.el.add ( child_0.el );
295 var child_1 = new Xcls_ScrolledWindow13( _this );
297 this.el.add ( child_1.el );
300 // user defined functions
302 public class Xcls_ScrolledWindow8 : Object
304 public Gtk.ScrolledWindow el;
305 private Xcls_ValaCompileErrors _this;
311 public Xcls_ScrolledWindow8(Xcls_ValaCompileErrors _owner )
314 this.el = new Gtk.ScrolledWindow( null, null );
318 // set gobject values
319 var child_0 = new Xcls_compile_tree( _this );
321 this.el.add ( child_0.el );
326 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
332 // user defined functions
334 public class Xcls_compile_tree : Object
336 public Gtk.TreeView el;
337 private Xcls_ValaCompileErrors _this;
343 public Xcls_compile_tree(Xcls_ValaCompileErrors _owner )
346 _this.compile_tree = this;
347 this.el = new Gtk.TreeView();
351 // set gobject values
352 var child_0 = new Xcls_compile_result_store( _this );
354 this.el.set_model ( child_0.el );
355 var child_1 = new Xcls_column( _this );
357 this.el.append_column ( child_1.el );
362 var description = new Pango.FontDescription();
363 description.set_size(8000);
364 this.el.modify_font(description);
369 this.el.cursor_changed.connect( () => {
370 var sel = this.el.get_selection();
372 if (sel.count_selected_rows() < 1) {
374 print("selected rows < 1\n");
379 //console.log('changed');
383 sel.get_selected(out mod, out iter);
386 0, file + ":" + line,
388 2, GLib.Markup.escape_text(line + ": " + msg),
398 _this.compile_result_store.el.get_value(iter, 3, out value);
399 var fname = (string)value;
401 _this.compile_result_store.el.get_value(iter, 1, out lvalue);
402 var line = (int) lvalue;
404 print ("loadfile %s : %d", fname,line);
406 _this.sourceview.loadFile(fname, line);
414 // user defined functions
416 public class Xcls_compile_result_store : Object
418 public Gtk.TreeStore el;
419 private Xcls_ValaCompileErrors _this;
425 public Xcls_compile_result_store(Xcls_ValaCompileErrors _owner )
428 _this.compile_result_store = this;
429 this.el = new Gtk.TreeStore( 4, typeof(string), typeof(int), typeof(string), typeof(string) );
433 // set gobject values
436 // user defined functions
438 public class Xcls_column : Object
440 public Gtk.TreeViewColumn el;
441 private Xcls_ValaCompileErrors _this;
447 public Xcls_column(Xcls_ValaCompileErrors _owner )
450 this.el = new Gtk.TreeViewColumn();
454 // set gobject values
455 this.el.title = "Compile output";
456 var child_0 = new Xcls_renderer( _this );
458 this.el.pack_start ( child_0.el , true );
463 this.el.add_attribute(_this.renderer.el , "markup", 2 );
468 // user defined functions
470 public class Xcls_renderer : Object
472 public Gtk.CellRendererText el;
473 private Xcls_ValaCompileErrors _this;
479 public Xcls_renderer(Xcls_ValaCompileErrors _owner )
482 _this.renderer = this;
483 this.el = new Gtk.CellRendererText();
487 // set gobject values
490 // user defined functions
492 public class Xcls_ScrolledWindow13 : Object
494 public Gtk.ScrolledWindow el;
495 private Xcls_ValaCompileErrors _this;
501 public Xcls_ScrolledWindow13(Xcls_ValaCompileErrors _owner )
504 this.el = new Gtk.ScrolledWindow( null, null );
508 // set gobject values
509 var child_0 = new Xcls_sourceview( _this );
511 this.el.add ( child_0.el );
514 // user defined functions
516 public class Xcls_sourceview : Object
518 public Gtk.SourceView el;
519 private Xcls_ValaCompileErrors _this;
523 public string curfname;
526 public Xcls_sourceview(Xcls_ValaCompileErrors _owner )
529 _this.sourceview = this;
530 this.el = new Gtk.SourceView();
534 // set gobject values
535 this.el.editable = false;
536 this.el.show_line_marks = true;
537 this.el.show_line_numbers = true;
543 var description = Pango.FontDescription.from_string("monospace");
544 description.set_size(8000);
545 this.el.override_font(description);
547 var attrs = new Gtk.SourceMarkAttributes();
548 var pink = new Gdk.RGBA();
549 pink.parse ( "pink");
550 attrs.set_background ( pink);
551 attrs.set_icon_name ( "process-stop");
552 attrs.query_tooltip_text.connect(( mark) => {
553 //print("tooltip query? %s\n", mark.name);
557 this.el.set_mark_attributes ("error", attrs, 1);
562 // user defined functions
563 public void loadFile (string fname, int line ) {
564 var buf = ((Gtk.SourceBuffer)(this.el.get_buffer()));
566 if (this.curfname != fname) {
567 this.curfname = fname;
571 buf.get_bounds (out start, out end);
573 buf.remove_source_marks (start, end, null);
578 FileUtils.get_contents(fname, out str);
580 buf.set_text(str, str.length);
581 var lm = Gtk.SourceLanguageManager.get_default();
584 buf.set_language(lm.get_language("vala"));
587 this.el.grab_focus();
591 var lines = _this.notices.get_object_member(fname);
594 lines.foreach_member((obj, line, node) => {
597 // print("get inter\n");
598 var eline = int.parse(line) -1 ;
601 buf.get_iter_at_line( out iter, eline);
602 //print("mark line\n");
603 var msg = "Line: %d".printf(eline+1);
604 var ar = lines.get_array_member(line);
605 for (var i = 0 ; i < ar.get_length(); i++) {
606 msg += (msg.length > 0) ? "\n" : "";
607 msg += ar.get_string_element(i);
611 buf.create_source_mark(msg, "error", iter);
614 // jump to the line...
616 buf.get_iter_at_line (out liter, line);
617 print("Scroll to \n");
618 this.el.scroll_to_iter (liter, 0.0f, false, 0.0f, 0.5f);
619 print("End Scroll to \n");