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 print ("loadfile %s : %d", fname,line);
306 _this.sourceview.loadFile(fname, line);
314 // user defined functions
316 public class Xcls_compile_result_store : Object
318 public Gtk.TreeStore el;
319 private Xcls_ValaCompileErrors _this;
325 public Xcls_compile_result_store(Xcls_ValaCompileErrors _owner )
328 _this.compile_result_store = this;
329 this.el = new Gtk.TreeStore( 4, typeof(string), typeof(int), typeof(string), typeof(string) );
333 // set gobject values
336 // user defined functions
338 public class Xcls_column : Object
340 public Gtk.TreeViewColumn el;
341 private Xcls_ValaCompileErrors _this;
347 public Xcls_column(Xcls_ValaCompileErrors _owner )
350 this.el = new Gtk.TreeViewColumn();
354 // set gobject values
355 this.el.title = "Compile output";
356 var child_0 = new Xcls_renderer( _this );
358 this.el.pack_start ( child_0.el , true );
363 this.el.add_attribute(_this.renderer.el , "markup", 2 );
368 // user defined functions
370 public class Xcls_renderer : Object
372 public Gtk.CellRendererText el;
373 private Xcls_ValaCompileErrors _this;
379 public Xcls_renderer(Xcls_ValaCompileErrors _owner )
382 _this.renderer = this;
383 this.el = new Gtk.CellRendererText();
387 // set gobject values
390 // user defined functions
392 public class Xcls_ScrolledWindow11 : Object
394 public Gtk.ScrolledWindow el;
395 private Xcls_ValaCompileErrors _this;
401 public Xcls_ScrolledWindow11(Xcls_ValaCompileErrors _owner )
404 this.el = new Gtk.ScrolledWindow( null, null );
408 // set gobject values
409 var child_0 = new Xcls_sourceview( _this );
411 this.el.add ( child_0.el );
414 // user defined functions
416 public class Xcls_sourceview : Object
418 public Gtk.SourceView el;
419 private Xcls_ValaCompileErrors _this;
423 public string curfname;
426 public Xcls_sourceview(Xcls_ValaCompileErrors _owner )
429 _this.sourceview = this;
430 this.el = new Gtk.SourceView();
434 // set gobject values
435 this.el.editable = false;
436 this.el.show_line_marks = true;
437 this.el.show_line_numbers = true;
443 var description = Pango.FontDescription.from_string("monospace");
444 description.set_size(8000);
445 this.el.override_font(description);
447 var attrs = new Gtk.SourceMarkAttributes();
448 var pink = new Gdk.RGBA();
449 pink.parse ( "pink");
450 attrs.set_background ( pink);
451 attrs.set_icon_name ( "process-stop");
452 attrs.query_tooltip_text.connect(( mark) => {
453 //print("tooltip query? %s\n", mark.name);
457 this.el.set_mark_attributes ("error", attrs, 1);
462 // user defined functions
463 public void loadFile (string fname, int line ) {
464 var buf = ((Gtk.SourceBuffer)(this.el.get_buffer()));
466 if (this.curfname != fname) {
467 this.curfname = fname;
471 buf.get_bounds (out start, out end);
473 buf.remove_source_marks (start, end, null);
478 FileUtils.get_contents(fname, out str);
480 buf.set_text(str, str.length);
481 var lm = Gtk.SourceLanguageManager.get_default();
484 buf.set_language(lm.get_language("vala"));
487 this.el.grab_focus();
491 var lines = _this.notices.get_object_member(fname);
494 lines.foreach_member((obj, line, node) => {
497 // print("get inter\n");
498 var eline = int.parse(line) -1 ;
501 buf.get_iter_at_line( out iter, eline);
502 //print("mark line\n");
503 var msg = "Line: %d".printf(eline+1);
504 var ar = lines.get_array_member(line);
505 for (var i = 0 ; i < ar.get_length(); i++) {
506 msg += (msg.length > 0) ? "\n" : "";
507 msg += ar.get_string_element(i);
511 buf.create_source_mark(msg, "error", iter);
514 // jump to the line...
516 buf.get_iter_at_line (out liter, line);
517 print("Scroll to \n");
518 this.el.scroll_to_iter (liter, 0.0f, false, 0.0f, 0.5f);
519 print("End Scroll to \n");