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( 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),
92 this.hpane.el.set_position(250);
93 if (this.el.relative_to == null) {
94 this.el.set_relative_to(onbtn);
100 public class Xcls_compile_view : Object
103 private Xcls_ValaCompileErrors _this;
109 public Xcls_compile_view(Xcls_ValaCompileErrors _owner )
112 _this.compile_view = this;
113 this.el = new Gtk.VBox( false, 0 );
117 // set gobject values
118 var child_0 = new Xcls_HBox3( _this );
120 this.el.pack_start ( child_0.el , false,false,0 );
121 var child_1 = new Xcls_hpane( _this );
123 this.el.pack_start ( child_1.el , true,true,0 );
126 // user defined functions
128 public class Xcls_HBox3 : Object
131 private Xcls_ValaCompileErrors _this;
137 public Xcls_HBox3(Xcls_ValaCompileErrors _owner )
140 this.el = new Gtk.HBox( true, 0 );
144 // set gobject values
145 var child_0 = new Xcls_Button4( _this );
147 this.el.pack_start ( child_0.el , true,true,0 );
150 // user defined functions
152 public class Xcls_Button4 : Object
154 public Gtk.Button el;
155 private Xcls_ValaCompileErrors _this;
161 public Xcls_Button4(Xcls_ValaCompileErrors _owner )
164 this.el = new Gtk.Button();
168 // set gobject values
169 this.el.label = "Compile and Run";
172 // user defined functions
174 public class Xcls_hpane : Object
176 public Gtk.HPaned el;
177 private Xcls_ValaCompileErrors _this;
183 public Xcls_hpane(Xcls_ValaCompileErrors _owner )
187 this.el = new Gtk.HPaned();
191 // set gobject values
192 var child_0 = new Xcls_ScrolledWindow6( _this );
194 this.el.add ( child_0.el );
195 var child_1 = new Xcls_ScrolledWindow11( _this );
197 this.el.add ( child_1.el );
200 // user defined functions
202 public class Xcls_ScrolledWindow6 : Object
204 public Gtk.ScrolledWindow el;
205 private Xcls_ValaCompileErrors _this;
211 public Xcls_ScrolledWindow6(Xcls_ValaCompileErrors _owner )
214 this.el = new Gtk.ScrolledWindow( null, null );
218 // set gobject values
219 var child_0 = new Xcls_compile_tree( _this );
221 this.el.add ( child_0.el );
226 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
232 // user defined functions
234 public class Xcls_compile_tree : Object
236 public Gtk.TreeView el;
237 private Xcls_ValaCompileErrors _this;
243 public Xcls_compile_tree(Xcls_ValaCompileErrors _owner )
246 _this.compile_tree = this;
247 this.el = new Gtk.TreeView();
251 // set gobject values
252 var child_0 = new Xcls_compile_result_store( _this );
254 this.el.set_model ( child_0.el );
255 var child_1 = new Xcls_column( _this );
257 this.el.append_column ( child_1.el );
262 var description = new Pango.FontDescription();
263 description.set_size(8000);
264 this.el.modify_font(description);
269 this.el.cursor_changed.connect( () => {
270 var sel = this.el.get_selection();
272 if (sel.count_selected_rows() < 1) {
274 print("selected rows < 1\n");
279 //console.log('changed');
283 sel.get_selected(out mod, out iter);
286 0, file + ":" + line,
288 2, GLib.Markup.escape_text(line + ": " + msg),
298 _this.compile_result_store.el.get_value(iter, 3, out value);
299 var fname = (string)value;
301 _this.compile_result_store.el.get_value(iter, 1, out lvalue);
302 var line = (int) lvalue;
304 _this.sourceview.loadFile(fname, line);
312 // user defined functions
314 public class Xcls_compile_result_store : Object
316 public Gtk.TreeStore el;
317 private Xcls_ValaCompileErrors _this;
323 public Xcls_compile_result_store(Xcls_ValaCompileErrors _owner )
326 _this.compile_result_store = this;
327 this.el = new Gtk.TreeStore( 4, typeof(string), typeof(int), typeof(string), typeof(string) );
331 // set gobject values
334 // user defined functions
336 public class Xcls_column : Object
338 public Gtk.TreeViewColumn el;
339 private Xcls_ValaCompileErrors _this;
345 public Xcls_column(Xcls_ValaCompileErrors _owner )
348 this.el = new Gtk.TreeViewColumn();
352 // set gobject values
353 this.el.title = "Compile output";
354 var child_0 = new Xcls_renderer( _this );
356 this.el.pack_start ( child_0.el , true );
361 this.el.add_attribute(_this.renderer.el , "markup", 2 );
366 // user defined functions
368 public class Xcls_renderer : Object
370 public Gtk.CellRendererText el;
371 private Xcls_ValaCompileErrors _this;
377 public Xcls_renderer(Xcls_ValaCompileErrors _owner )
380 _this.renderer = this;
381 this.el = new Gtk.CellRendererText();
385 // set gobject values
388 // user defined functions
390 public class Xcls_ScrolledWindow11 : Object
392 public Gtk.ScrolledWindow el;
393 private Xcls_ValaCompileErrors _this;
399 public Xcls_ScrolledWindow11(Xcls_ValaCompileErrors _owner )
402 this.el = new Gtk.ScrolledWindow( null, null );
406 // set gobject values
407 var child_0 = new Xcls_sourceview( _this );
409 this.el.add ( child_0.el );
412 // user defined functions
414 public class Xcls_sourceview : Object
416 public Gtk.SourceView el;
417 private Xcls_ValaCompileErrors _this;
421 public string curfname;
424 public Xcls_sourceview(Xcls_ValaCompileErrors _owner )
427 _this.sourceview = this;
428 this.el = new Gtk.SourceView();
432 // set gobject values
433 this.el.editable = false;
434 this.el.show_line_marks = true;
435 this.el.show_line_numbers = true;
444 // user defined functions
445 public void loadFile (string fname, int line ) {
446 var buf = ((Gtk.SourceBuffer)(this.el.get_buffer()));
448 if (this.curfname != fname) {
449 this.curfname = fname;
453 buf.get_bounds (out start, out end);
455 buf.remove_source_marks (start, end, null);
460 FileUtils.get_contents(fname, out str);
462 buf.set_text(str, str.length);
463 var lm = Gtk.SourceLanguageManager.get_default();
466 buf.set_language(lm.get_language("vala"));
469 this.el.grab_focus();
473 var lines = _this.notices.get_object_member(fname);
476 lines.foreach_member((obj, line, node) => {
479 // print("get inter\n");
480 var eline = int.parse(line);
483 buf.get_iter_at_line( out iter, eline);
484 //print("mark line\n");
485 var msg = "Line: %d".printf(eline+1);
486 var ar = lines.get_array_member(line);
487 for (var i = 0 ; i < ar.get_length(); i++) {
488 msg += (msg.length > 0) ? "\n" : "";
489 msg += ar.get_string_element(i);
493 buf.create_source_mark(msg, "error", iter);
496 // jump to the line...
498 buf.get_iter_at_line (out liter, line);
499 this.el.scroll_to_iter (liter, 0.0f, true, 0.0f, 0.5f);