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;
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( () => {
55 // user defined functions
56 public void show (Json.Object tree, Gtk.Widget onbtn) {
60 //print("looking for %s\n", id);
61 // loop through parent childnre
64 var store = this.compile_result_store.el;
69 tree.foreach_member((obj, file, node) => {
70 // id line "display text", file
72 var title = GLib.Path.get_basename(GLib.Path.get_dirname( file)) + "/" + GLib.Path.get_basename( file) ;
74 print("Add file %s", title);
75 store.append(out iter, null);
76 var lines = tree.get_object_member(file);
77 title += " (" + lines.get_size().to_string() + ")";
78 store.set(iter, 0, file, 1, 0, 2, title, 3, file,-1);
80 lines.foreach_member((obja, line, nodea) => {
82 var ar = lines.get_array_member(line);
83 for (var i = 0 ; i < ar.get_length(); i++) {
84 msg += (msg.length > 0) ? "\n" : "";
85 msg += ar.get_string_element(i);
88 print("Add line %s", line);
89 store.append(out citer, iter);
93 2, GLib.Markup.escape_text(line + ": " + msg),
103 this.window.el.get_size(out w, out h);
105 // left tree = 250, editor area = 500?
107 var new_w = int.min(750, w-100);
108 if (new_w > (w-100)) {
111 this.el.set_size_request( int.max(100, new_w), int.max(100, h-120));
114 this.hpane.el.set_position(250);
115 if (this.el.relative_to == null) {
116 this.el.set_relative_to(onbtn);
119 this.save_btn.el.hide();
122 public class Xcls_compile_view : Object
125 private Xcls_ValaCompileErrors _this;
131 public Xcls_compile_view(Xcls_ValaCompileErrors _owner )
134 _this.compile_view = this;
135 this.el = new Gtk.VBox( false, 0 );
139 // set gobject values
140 var child_0 = new Xcls_HBox3( _this );
142 this.el.pack_start ( child_0.el , false,false,0 );
143 var child_1 = new Xcls_hpane( _this );
145 this.el.pack_start ( child_1.el , true,true,0 );
148 // user defined functions
150 public class Xcls_HBox3 : Object
153 private Xcls_ValaCompileErrors _this;
159 public Xcls_HBox3(Xcls_ValaCompileErrors _owner )
162 this.el = new Gtk.HBox( true, 0 );
166 // set gobject values
167 var child_0 = new Xcls_Button4( _this );
169 this.el.pack_start ( child_0.el , true,true,0 );
170 var child_1 = new Xcls_Button5( _this );
172 this.el.pack_start ( child_1.el , true,true,0 );
173 var child_2 = new Xcls_save_btn( _this );
175 this.el.pack_start ( child_2.el , true,true,0 );
178 // user defined functions
180 public class Xcls_Button4 : Object
182 public Gtk.Button el;
183 private Xcls_ValaCompileErrors _this;
189 public Xcls_Button4(Xcls_ValaCompileErrors _owner )
192 this.el = new Gtk.Button();
196 // set gobject values
197 this.el.label = "Compile and Run";
200 // user defined functions
202 public class Xcls_Button5 : Object
204 public Gtk.Button el;
205 private Xcls_ValaCompileErrors _this;
211 public Xcls_Button5(Xcls_ValaCompileErrors _owner )
214 this.el = new Gtk.Button();
218 // set gobject values
219 this.el.label = "Edit";
222 this.el.clicked.connect( () => {
223 // is the file managed by the builder?
225 var f = _this.sourceview.curfname;
227 Regex regex = new Regex("\\.vala$");
229 var bjsf = regex.replace(f,f.length , 0 , ".bjs");
231 var p = _this.window.project;
235 var jsr = p.getByPath(bjsf);
237 _this.window.windowstate.fileViewOpen(jsr);
247 // user defined functions
249 public class Xcls_save_btn : Object
251 public Gtk.Button el;
252 private Xcls_ValaCompileErrors _this;
258 public Xcls_save_btn(Xcls_ValaCompileErrors _owner )
261 _this.save_btn = this;
262 this.el = new Gtk.Button();
266 // set gobject values
267 this.el.label = "Save";
268 this.el.visible = false;
271 // user defined functions
273 public class Xcls_hpane : Object
275 public Gtk.HPaned el;
276 private Xcls_ValaCompileErrors _this;
282 public Xcls_hpane(Xcls_ValaCompileErrors _owner )
286 this.el = new Gtk.HPaned();
290 // set gobject values
291 var child_0 = new Xcls_ScrolledWindow8( _this );
293 this.el.add ( child_0.el );
294 var child_1 = new Xcls_ScrolledWindow13( _this );
296 this.el.add ( child_1.el );
299 // user defined functions
301 public class Xcls_ScrolledWindow8 : Object
303 public Gtk.ScrolledWindow el;
304 private Xcls_ValaCompileErrors _this;
310 public Xcls_ScrolledWindow8(Xcls_ValaCompileErrors _owner )
313 this.el = new Gtk.ScrolledWindow( null, null );
317 // set gobject values
318 var child_0 = new Xcls_compile_tree( _this );
320 this.el.add ( child_0.el );
325 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
331 // user defined functions
333 public class Xcls_compile_tree : Object
335 public Gtk.TreeView el;
336 private Xcls_ValaCompileErrors _this;
342 public Xcls_compile_tree(Xcls_ValaCompileErrors _owner )
345 _this.compile_tree = this;
346 this.el = new Gtk.TreeView();
350 // set gobject values
351 var child_0 = new Xcls_compile_result_store( _this );
353 this.el.set_model ( child_0.el );
354 var child_1 = new Xcls_column( _this );
356 this.el.append_column ( child_1.el );
361 var description = new Pango.FontDescription();
362 description.set_size(8000);
363 this.el.modify_font(description);
368 this.el.cursor_changed.connect( () => {
369 var sel = this.el.get_selection();
371 if (sel.count_selected_rows() < 1) {
373 print("selected rows < 1\n");
378 //console.log('changed');
382 sel.get_selected(out mod, out iter);
385 0, file + ":" + line,
387 2, GLib.Markup.escape_text(line + ": " + msg),
397 _this.compile_result_store.el.get_value(iter, 3, out value);
398 var fname = (string)value;
400 _this.compile_result_store.el.get_value(iter, 1, out lvalue);
401 var line = (int) lvalue;
403 print ("loadfile %s : %d", fname,line);
405 _this.sourceview.loadFile(fname, line);
413 // user defined functions
415 public class Xcls_compile_result_store : Object
417 public Gtk.TreeStore el;
418 private Xcls_ValaCompileErrors _this;
424 public Xcls_compile_result_store(Xcls_ValaCompileErrors _owner )
427 _this.compile_result_store = this;
428 this.el = new Gtk.TreeStore( 4, typeof(string), typeof(int), typeof(string), typeof(string) );
432 // set gobject values
435 // user defined functions
437 public class Xcls_column : Object
439 public Gtk.TreeViewColumn el;
440 private Xcls_ValaCompileErrors _this;
446 public Xcls_column(Xcls_ValaCompileErrors _owner )
449 this.el = new Gtk.TreeViewColumn();
453 // set gobject values
454 this.el.title = "Compile output";
455 var child_0 = new Xcls_renderer( _this );
457 this.el.pack_start ( child_0.el , true );
462 this.el.add_attribute(_this.renderer.el , "markup", 2 );
467 // user defined functions
469 public class Xcls_renderer : Object
471 public Gtk.CellRendererText el;
472 private Xcls_ValaCompileErrors _this;
478 public Xcls_renderer(Xcls_ValaCompileErrors _owner )
481 _this.renderer = this;
482 this.el = new Gtk.CellRendererText();
486 // set gobject values
489 // user defined functions
491 public class Xcls_ScrolledWindow13 : Object
493 public Gtk.ScrolledWindow el;
494 private Xcls_ValaCompileErrors _this;
500 public Xcls_ScrolledWindow13(Xcls_ValaCompileErrors _owner )
503 this.el = new Gtk.ScrolledWindow( null, null );
507 // set gobject values
508 var child_0 = new Xcls_sourceview( _this );
510 this.el.add ( child_0.el );
513 // user defined functions
515 public class Xcls_sourceview : Object
517 public Gtk.SourceView el;
518 private Xcls_ValaCompileErrors _this;
522 public string curfname;
525 public Xcls_sourceview(Xcls_ValaCompileErrors _owner )
528 _this.sourceview = this;
529 this.el = new Gtk.SourceView();
533 // set gobject values
534 this.el.editable = false;
535 this.el.show_line_marks = true;
536 this.el.show_line_numbers = true;
542 var description = Pango.FontDescription.from_string("monospace");
543 description.set_size(8000);
544 this.el.override_font(description);
546 var attrs = new Gtk.SourceMarkAttributes();
547 var pink = new Gdk.RGBA();
548 pink.parse ( "pink");
549 attrs.set_background ( pink);
550 attrs.set_icon_name ( "process-stop");
551 attrs.query_tooltip_text.connect(( mark) => {
552 //print("tooltip query? %s\n", mark.name);
556 this.el.set_mark_attributes ("error", attrs, 1);
561 // user defined functions
562 public void loadFile (string fname, int line ) {
563 var buf = ((Gtk.SourceBuffer)(this.el.get_buffer()));
565 if (this.curfname != fname) {
566 this.curfname = fname;
570 buf.get_bounds (out start, out end);
572 buf.remove_source_marks (start, end, null);
577 FileUtils.get_contents(fname, out str);
579 buf.set_text(str, str.length);
580 var lm = Gtk.SourceLanguageManager.get_default();
583 buf.set_language(lm.get_language("vala"));
586 this.el.grab_focus();
590 var lines = _this.notices.get_object_member(fname);
593 lines.foreach_member((obj, line, node) => {
596 // print("get inter\n");
597 var eline = int.parse(line) -1 ;
600 buf.get_iter_at_line( out iter, eline);
601 //print("mark line\n");
602 var msg = "Line: %d".printf(eline+1);
603 var ar = lines.get_array_member(line);
604 for (var i = 0 ; i < ar.get_length(); i++) {
605 msg += (msg.length > 0) ? "\n" : "";
606 msg += ar.get_string_element(i);
610 buf.create_source_mark(msg, "error", iter);
613 // jump to the line...
615 buf.get_iter_at_line (out liter, line);
616 print("Scroll to \n");
617 this.el.scroll_to_iter (liter, 0.0f, false, 0.0f, 0.5f);
618 print("End Scroll to \n");