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_hpane hpane;
17 public Xcls_compile_tree compile_tree;
18 public Xcls_compile_result_store compile_result_store;
19 public Xcls_renderer renderer;
20 public Xcls_sourceview sourceview;
23 public Xcls_MainWindow window;
24 public Json.Object notices;
27 public Xcls_ValaCompileErrors()
30 this.el = new Gtk.Popover( null );
35 this.el.width_request = 900;
36 this.el.height_request = 800;
38 this.el.position = Gtk.PositionType.TOP;
39 var child_0 = new Xcls_compile_view( _this );
41 this.el.add ( child_0.el );
44 // user defined functions
45 public void show (Json.Object tree, Gtk.Widget onbtn) {
48 //print("looking for %s\n", id);
49 // loop through parent childnre
52 var store = this.compile_result_store.el;
57 tree.foreach_member((obj, file, node) => {
58 // id line "display text", file
60 var title = GLib.Path.get_basename(GLib.Path.get_dirname( file)) + "/" + GLib.Path.get_basename( file) ;
62 print("Add file %s", title);
63 store.append(out iter, null);
64 var lines = tree.get_object_member(file);
65 title += " (" + lines.get_size().to_string() + ")";
66 store.set(iter, 0, file, 1, 0, 2, title, 3, file,-1);
68 lines.foreach_member((obja, line, nodea) => {
70 var ar = lines.get_array_member(line);
71 for (var i = 0 ; i < ar.get_length(); i++) {
72 msg += (msg.length > 0) ? "\n" : "";
73 msg += ar.get_string_element(i);
76 print("Add line %s", line);
77 store.append(out citer, iter);
81 2, GLib.Markup.escape_text(line + ": " + msg),
91 this.window.el.get_size(out w, out h);
92 this.el.set_size_request( int.max(100, w- 100), int.max(100, h-100));
95 this.hpane.el.set_position(250);
96 if (this.el.relative_to == null) {
97 this.el.set_relative_to(onbtn);
103 public class Xcls_compile_view : Object
106 private Xcls_ValaCompileErrors _this;
112 public Xcls_compile_view(Xcls_ValaCompileErrors _owner )
115 _this.compile_view = this;
116 this.el = new Gtk.VBox( false, 0 );
120 // set gobject values
121 var child_0 = new Xcls_HBox3( _this );
123 this.el.pack_start ( child_0.el , false,false,0 );
124 var child_1 = new Xcls_hpane( _this );
126 this.el.pack_start ( child_1.el , true,true,0 );
129 // user defined functions
131 public class Xcls_HBox3 : Object
134 private Xcls_ValaCompileErrors _this;
140 public Xcls_HBox3(Xcls_ValaCompileErrors _owner )
143 this.el = new Gtk.HBox( true, 0 );
147 // set gobject values
148 var child_0 = new Xcls_Button4( _this );
150 this.el.pack_start ( child_0.el , true,true,0 );
151 var child_1 = new Xcls_Button5( _this );
153 this.el.pack_start ( child_1.el , true,true,0 );
154 var child_2 = new Xcls_Button6( _this );
156 this.el.pack_start ( child_2.el , true,true,0 );
159 // user defined functions
161 public class Xcls_Button4 : Object
163 public Gtk.Button el;
164 private Xcls_ValaCompileErrors _this;
170 public Xcls_Button4(Xcls_ValaCompileErrors _owner )
173 this.el = new Gtk.Button();
177 // set gobject values
178 this.el.label = "Compile and Run";
181 // user defined functions
183 public class Xcls_Button5 : Object
185 public Gtk.Button el;
186 private Xcls_ValaCompileErrors _this;
192 public Xcls_Button5(Xcls_ValaCompileErrors _owner )
195 this.el = new Gtk.Button();
199 // set gobject values
200 this.el.label = "Edit";
203 this.el.clicked.connect( () => {
204 // is the file managed by the builder?
206 var f = _this.sourceview.curfname;
208 var p = _this.window.project;
210 var jsr = p.getByPath(f);
220 // user defined functions
222 public class Xcls_Button6 : Object
224 public Gtk.Button el;
225 private Xcls_ValaCompileErrors _this;
231 public Xcls_Button6(Xcls_ValaCompileErrors _owner )
234 this.el = new Gtk.Button();
238 // set gobject values
239 this.el.label = "Save";
240 this.el.visible = false;
243 // user defined functions
245 public class Xcls_hpane : Object
247 public Gtk.HPaned el;
248 private Xcls_ValaCompileErrors _this;
254 public Xcls_hpane(Xcls_ValaCompileErrors _owner )
258 this.el = new Gtk.HPaned();
262 // set gobject values
263 var child_0 = new Xcls_ScrolledWindow8( _this );
265 this.el.add ( child_0.el );
266 var child_1 = new Xcls_ScrolledWindow13( _this );
268 this.el.add ( child_1.el );
271 // user defined functions
273 public class Xcls_ScrolledWindow8 : Object
275 public Gtk.ScrolledWindow el;
276 private Xcls_ValaCompileErrors _this;
282 public Xcls_ScrolledWindow8(Xcls_ValaCompileErrors _owner )
285 this.el = new Gtk.ScrolledWindow( null, null );
289 // set gobject values
290 var child_0 = new Xcls_compile_tree( _this );
292 this.el.add ( child_0.el );
297 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
303 // user defined functions
305 public class Xcls_compile_tree : Object
307 public Gtk.TreeView el;
308 private Xcls_ValaCompileErrors _this;
314 public Xcls_compile_tree(Xcls_ValaCompileErrors _owner )
317 _this.compile_tree = this;
318 this.el = new Gtk.TreeView();
322 // set gobject values
323 var child_0 = new Xcls_compile_result_store( _this );
325 this.el.set_model ( child_0.el );
326 var child_1 = new Xcls_column( _this );
328 this.el.append_column ( child_1.el );
333 var description = new Pango.FontDescription();
334 description.set_size(8000);
335 this.el.modify_font(description);
340 this.el.cursor_changed.connect( () => {
341 var sel = this.el.get_selection();
343 if (sel.count_selected_rows() < 1) {
345 print("selected rows < 1\n");
350 //console.log('changed');
354 sel.get_selected(out mod, out iter);
357 0, file + ":" + line,
359 2, GLib.Markup.escape_text(line + ": " + msg),
369 _this.compile_result_store.el.get_value(iter, 3, out value);
370 var fname = (string)value;
372 _this.compile_result_store.el.get_value(iter, 1, out lvalue);
373 var line = (int) lvalue;
375 print ("loadfile %s : %d", fname,line);
377 _this.sourceview.loadFile(fname, line);
385 // user defined functions
387 public class Xcls_compile_result_store : Object
389 public Gtk.TreeStore el;
390 private Xcls_ValaCompileErrors _this;
396 public Xcls_compile_result_store(Xcls_ValaCompileErrors _owner )
399 _this.compile_result_store = this;
400 this.el = new Gtk.TreeStore( 4, typeof(string), typeof(int), typeof(string), typeof(string) );
404 // set gobject values
407 // user defined functions
409 public class Xcls_column : Object
411 public Gtk.TreeViewColumn el;
412 private Xcls_ValaCompileErrors _this;
418 public Xcls_column(Xcls_ValaCompileErrors _owner )
421 this.el = new Gtk.TreeViewColumn();
425 // set gobject values
426 this.el.title = "Compile output";
427 var child_0 = new Xcls_renderer( _this );
429 this.el.pack_start ( child_0.el , true );
434 this.el.add_attribute(_this.renderer.el , "markup", 2 );
439 // user defined functions
441 public class Xcls_renderer : Object
443 public Gtk.CellRendererText el;
444 private Xcls_ValaCompileErrors _this;
450 public Xcls_renderer(Xcls_ValaCompileErrors _owner )
453 _this.renderer = this;
454 this.el = new Gtk.CellRendererText();
458 // set gobject values
461 // user defined functions
463 public class Xcls_ScrolledWindow13 : Object
465 public Gtk.ScrolledWindow el;
466 private Xcls_ValaCompileErrors _this;
472 public Xcls_ScrolledWindow13(Xcls_ValaCompileErrors _owner )
475 this.el = new Gtk.ScrolledWindow( null, null );
479 // set gobject values
480 var child_0 = new Xcls_sourceview( _this );
482 this.el.add ( child_0.el );
485 // user defined functions
487 public class Xcls_sourceview : Object
489 public Gtk.SourceView el;
490 private Xcls_ValaCompileErrors _this;
494 public string curfname;
497 public Xcls_sourceview(Xcls_ValaCompileErrors _owner )
500 _this.sourceview = this;
501 this.el = new Gtk.SourceView();
505 // set gobject values
506 this.el.editable = false;
507 this.el.show_line_marks = true;
508 this.el.show_line_numbers = true;
514 var description = Pango.FontDescription.from_string("monospace");
515 description.set_size(8000);
516 this.el.override_font(description);
518 var attrs = new Gtk.SourceMarkAttributes();
519 var pink = new Gdk.RGBA();
520 pink.parse ( "pink");
521 attrs.set_background ( pink);
522 attrs.set_icon_name ( "process-stop");
523 attrs.query_tooltip_text.connect(( mark) => {
524 //print("tooltip query? %s\n", mark.name);
528 this.el.set_mark_attributes ("error", attrs, 1);
533 // user defined functions
534 public void loadFile (string fname, int line ) {
535 var buf = ((Gtk.SourceBuffer)(this.el.get_buffer()));
537 if (this.curfname != fname) {
538 this.curfname = fname;
542 buf.get_bounds (out start, out end);
544 buf.remove_source_marks (start, end, null);
549 FileUtils.get_contents(fname, out str);
551 buf.set_text(str, str.length);
552 var lm = Gtk.SourceLanguageManager.get_default();
555 buf.set_language(lm.get_language("vala"));
558 this.el.grab_focus();
562 var lines = _this.notices.get_object_member(fname);
565 lines.foreach_member((obj, line, node) => {
568 // print("get inter\n");
569 var eline = int.parse(line) -1 ;
572 buf.get_iter_at_line( out iter, eline);
573 //print("mark line\n");
574 var msg = "Line: %d".printf(eline+1);
575 var ar = lines.get_array_member(line);
576 for (var i = 0 ; i < ar.get_length(); i++) {
577 msg += (msg.length > 0) ? "\n" : "";
578 msg += ar.get_string_element(i);
582 buf.create_source_mark(msg, "error", iter);
585 // jump to the line...
587 buf.get_iter_at_line (out liter, line);
588 print("Scroll to \n");
589 this.el.scroll_to_iter (liter, 0.0f, false, 0.0f, 0.5f);
590 print("End Scroll to \n");