src/Builder4/ValaCompileErrors.bjs
[app.Builder.js] / src / Builder4 / ValaCompileErrors.vala
1 static Xcls_ValaCompileErrors  _ValaCompileErrors;
2
3 public class Xcls_ValaCompileErrors : Object
4 {
5     public Gtk.Popover el;
6     private Xcls_ValaCompileErrors  _this;
7
8     public static Xcls_ValaCompileErrors singleton()
9     {
10         if (_ValaCompileErrors == null) {
11             _ValaCompileErrors= new Xcls_ValaCompileErrors();
12         }
13         return _ValaCompileErrors;
14     }
15     public Xcls_compile_view compile_view;
16     public Xcls_save_btn save_btn;
17     public Xcls_compile_tree compile_tree;
18     public Xcls_compile_result_store compile_result_store;
19     public Xcls_renderer renderer;
20
21         // my vars (def)
22     public Xcls_MainWindow window;
23     public bool active;
24     public JsRender.JsRender? file;
25     public Json.Object notices;
26
27     // ctor
28     public Xcls_ValaCompileErrors()
29     {
30         _this = this;
31         this.el = new Gtk.Popover( null );
32
33         // my vars (dec)
34         this.active = false;
35
36         // set gobject values
37         this.el.width_request = 900;
38         this.el.height_request = 800;
39         this.el.modal = false;
40         this.el.position = Gtk.PositionType.TOP;
41         var child_0 = new Xcls_compile_view( _this );
42         child_0.ref();
43         this.el.add (  child_0.el  );
44
45         //listeners
46         this.el.closed.connect( () => {
47             if (this.active) {
48                 this.el.show();
49                 return;
50             }
51            
52         });
53     }
54
55     // user defined functions
56     public void show (Json.Object tree, Gtk.Widget onbtn) {
57     
58             
59             this.file = null;
60             this.notices = tree;
61             this.active = true;
62              //print("looking for %s\n", id);
63             // loop through parent childnre
64               
65             
66             var store = this.compile_result_store.el;    
67             
68             store.clear();
69          
70             
71             tree.foreach_member((obj, file, node) => {
72                 // id line "display text", file
73                 
74                 var title = GLib.Path.get_basename(GLib.Path.get_dirname( file)) + "/" +  GLib.Path.get_basename( file) ;
75                 Gtk.TreeIter iter;
76                 print("Add file %s", title);
77                 store.append(out iter, null);
78                 var lines = tree.get_object_member(file);
79                 title += " (" + lines.get_size().to_string() + ")";
80                 store.set(iter, 0, file, 1, 0, 2, title, 3, file,-1);
81                 
82                 lines.foreach_member((obja, line, nodea) => {
83                     var msg  = "";
84                     var ar = lines.get_array_member(line);
85                     for (var i = 0 ; i < ar.get_length(); i++) {
86                             msg += (msg.length > 0) ? "\n" : "";
87                             msg += ar.get_string_element(i);
88                 }
89                     Gtk.TreeIter citer;  
90                     print("Add line %s", line);
91                     store.append(out citer, iter);
92                     store.set(citer, 
93                         0, file + ":" + line, 
94                         1, int.parse(line), 
95                         2, GLib.Markup.escape_text(line + ": " + msg), 
96                         3, file,-1);
97                 
98                 });
99                 
100                 
101             
102             });
103             
104         int w,h;
105         this.window.el.get_size(out w, out h);
106         
107         // left tree = 250, editor area = 500?
108         
109         var new_w = int.min(250, w-100);
110         if (new_w > (w-100)) {
111             new_w = w-100;
112         }
113         this.el.set_size_request( int.max(100, new_w), int.max(100, h-120));
114     
115         
116     
117         if (this.el.relative_to == null) {
118             this.el.set_relative_to(onbtn);
119         }
120         this.el.show_all();
121         this.save_btn.el.hide();       
122         while(Gtk.events_pending()) { 
123                 Gtk.main_iteration();
124         }       
125         this.hpane.el.set_position( 0);
126     }
127     public class Xcls_compile_view : Object
128     {
129         public Gtk.VBox el;
130         private Xcls_ValaCompileErrors  _this;
131
132
133             // my vars (def)
134
135         // ctor
136         public Xcls_compile_view(Xcls_ValaCompileErrors _owner )
137         {
138             _this = _owner;
139             _this.compile_view = this;
140             this.el = new Gtk.VBox( false, 0 );
141
142             // my vars (dec)
143
144             // set gobject values
145             var child_0 = new Xcls_HBox3( _this );
146             child_0.ref();
147             this.el.pack_start (  child_0.el , false,false,0 );
148             var child_1 = new Xcls_ScrolledWindow7( _this );
149             child_1.ref();
150             this.el.add (  child_1.el  );
151         }
152
153         // user defined functions
154     }
155     public class Xcls_HBox3 : Object
156     {
157         public Gtk.HBox el;
158         private Xcls_ValaCompileErrors  _this;
159
160
161             // my vars (def)
162
163         // ctor
164         public Xcls_HBox3(Xcls_ValaCompileErrors _owner )
165         {
166             _this = _owner;
167             this.el = new Gtk.HBox( true, 0 );
168
169             // my vars (dec)
170
171             // set gobject values
172             var child_0 = new Xcls_Button4( _this );
173             child_0.ref();
174             this.el.pack_start (  child_0.el , true,true,0 );
175             var child_1 = new Xcls_Button5( _this );
176             child_1.ref();
177             this.el.pack_start (  child_1.el , true,true,0 );
178             var child_2 = new Xcls_save_btn( _this );
179             child_2.ref();
180             this.el.pack_start (  child_2.el , true,true,0 );
181         }
182
183         // user defined functions
184     }
185     public class Xcls_Button4 : Object
186     {
187         public Gtk.Button el;
188         private Xcls_ValaCompileErrors  _this;
189
190
191             // my vars (def)
192
193         // ctor
194         public Xcls_Button4(Xcls_ValaCompileErrors _owner )
195         {
196             _this = _owner;
197             this.el = new Gtk.Button();
198
199             // my vars (dec)
200
201             // set gobject values
202             this.el.label = "Compile and Run";
203         }
204
205         // user defined functions
206     }
207
208     public class Xcls_Button5 : Object
209     {
210         public Gtk.Button el;
211         private Xcls_ValaCompileErrors  _this;
212
213
214             // my vars (def)
215
216         // ctor
217         public Xcls_Button5(Xcls_ValaCompileErrors _owner )
218         {
219             _this = _owner;
220             this.el = new Gtk.Button();
221
222             // my vars (dec)
223
224             // set gobject values
225             this.el.label = "Edit";
226
227             //listeners
228             this.el.clicked.connect( () => {
229                 // is the file managed by the builder?
230                 
231                 var f = _this.sourceview.curfname;
232                 
233                 Regex regex = new Regex("\\.vala$");
234             
235                 var bjsf = regex.replace(f,f.length , 0 , ".bjs");
236                 
237                 var p = _this.window.project;
238                 
239                 
240                 
241                 var jsr = p.getByPath(bjsf);
242                 if (jsr != null) {
243                     _this.window.windowstate.fileViewOpen(jsr);
244                     
245                     return;
246                 
247                 }
248             
249             
250             });
251         }
252
253         // user defined functions
254     }
255
256     public class Xcls_save_btn : Object
257     {
258         public Gtk.Button el;
259         private Xcls_ValaCompileErrors  _this;
260
261
262             // my vars (def)
263
264         // ctor
265         public Xcls_save_btn(Xcls_ValaCompileErrors _owner )
266         {
267             _this = _owner;
268             _this.save_btn = this;
269             this.el = new Gtk.Button();
270
271             // my vars (dec)
272
273             // set gobject values
274             this.el.label = "Save";
275             this.el.visible = false;
276         }
277
278         // user defined functions
279     }
280
281
282     public class Xcls_ScrolledWindow7 : Object
283     {
284         public Gtk.ScrolledWindow el;
285         private Xcls_ValaCompileErrors  _this;
286
287
288             // my vars (def)
289
290         // ctor
291         public Xcls_ScrolledWindow7(Xcls_ValaCompileErrors _owner )
292         {
293             _this = _owner;
294             this.el = new Gtk.ScrolledWindow( null, null );
295
296             // my vars (dec)
297
298             // set gobject values
299             var child_0 = new Xcls_compile_tree( _this );
300             child_0.ref();
301             this.el.add (  child_0.el  );
302
303             // init method
304
305             {
306              this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
307              
308             
309             }
310         }
311
312         // user defined functions
313     }
314     public class Xcls_compile_tree : Object
315     {
316         public Gtk.TreeView el;
317         private Xcls_ValaCompileErrors  _this;
318
319
320             // my vars (def)
321
322         // ctor
323         public Xcls_compile_tree(Xcls_ValaCompileErrors _owner )
324         {
325             _this = _owner;
326             _this.compile_tree = this;
327             this.el = new Gtk.TreeView();
328
329             // my vars (dec)
330
331             // set gobject values
332             var child_0 = new Xcls_compile_result_store( _this );
333             child_0.ref();
334             this.el.set_model (  child_0.el  );
335             var child_1 = new Xcls_column( _this );
336             child_1.ref();
337             this.el.append_column (  child_1.el  );
338
339             // init method
340
341             {
342              var description = new Pango.FontDescription();
343                 description.set_size(8000);
344                 this.el.modify_font(description);
345             
346             }
347
348             //listeners
349             this.el.cursor_changed.connect( () => {
350                 var sel = this.el.get_selection();
351             
352                 if (sel.count_selected_rows() < 1) {
353             
354                     print("selected rows < 1\n");
355                     //??this.mo 
356                     return  ;
357                 }
358                     
359                     //console.log('changed');
360                  
361                  Gtk.TreeIter iter;
362                  Gtk.TreeModel mod;
363                 sel.get_selected(out mod, out iter);
364                 /*
365                  store.set(citer, 
366                         0, file + ":" + line, 
367                         1, int.parse(line), 
368                         2, GLib.Markup.escape_text(line + ": " + msg), 
369                         3, file,-1);
370                 
371                 });
372                 */
373                 
374                 
375                 
376                 // var val = "";
377                 GLib.Value value;
378                 _this.compile_result_store.el.get_value(iter, 3, out value);
379                 var fname = (string)value;
380                 GLib.Value lvalue;
381                 _this.compile_result_store.el.get_value(iter, 1, out lvalue);
382                 var line = (int) lvalue;
383                 
384                 
385                 
386              
387                 
388                 
389                 print ("loadfile %s : %d", fname,line);
390                 
391                 _this.sourceview.loadFile(fname, line);
392                 
393                 
394                         
395                         
396             });
397         }
398
399         // user defined functions
400     }
401     public class Xcls_compile_result_store : Object
402     {
403         public Gtk.TreeStore el;
404         private Xcls_ValaCompileErrors  _this;
405
406
407             // my vars (def)
408
409         // ctor
410         public Xcls_compile_result_store(Xcls_ValaCompileErrors _owner )
411         {
412             _this = _owner;
413             _this.compile_result_store = this;
414             this.el = new Gtk.TreeStore( 4,   typeof(string), typeof(int), typeof(string), typeof(string)  );
415
416             // my vars (dec)
417
418             // set gobject values
419         }
420
421         // user defined functions
422     }
423
424     public class Xcls_column : Object
425     {
426         public Gtk.TreeViewColumn el;
427         private Xcls_ValaCompileErrors  _this;
428
429
430             // my vars (def)
431
432         // ctor
433         public Xcls_column(Xcls_ValaCompileErrors _owner )
434         {
435             _this = _owner;
436             this.el = new Gtk.TreeViewColumn();
437
438             // my vars (dec)
439
440             // set gobject values
441             this.el.title = "Compile output";
442             var child_0 = new Xcls_renderer( _this );
443             child_0.ref();
444             this.el.pack_start (  child_0.el , true );
445
446             // init method
447
448             {
449               this.el.add_attribute(_this.renderer.el , "markup", 2 );
450              
451             }
452         }
453
454         // user defined functions
455     }
456     public class Xcls_renderer : Object
457     {
458         public Gtk.CellRendererText el;
459         private Xcls_ValaCompileErrors  _this;
460
461
462             // my vars (def)
463
464         // ctor
465         public Xcls_renderer(Xcls_ValaCompileErrors _owner )
466         {
467             _this = _owner;
468             _this.renderer = this;
469             this.el = new Gtk.CellRendererText();
470
471             // my vars (dec)
472
473             // set gobject values
474         }
475
476         // user defined functions
477     }
478
479
480
481
482
483 }