resources/RooUsage.txt
[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_compile_tree compile_tree;
17     public Xcls_compile_result_store compile_result_store;
18     public Xcls_renderer renderer;
19
20         // my vars (def)
21     public Xcls_MainWindow window;
22     public bool active;
23     public JsRender.JsRender? file;
24     public Json.Object notices;
25
26     // ctor
27     public Xcls_ValaCompileErrors()
28     {
29         _this = this;
30         this.el = new Gtk.Popover( null );
31
32         // my vars (dec)
33         this.active = false;
34
35         // set gobject values
36         this.el.width_request = 900;
37         this.el.height_request = 800;
38         this.el.hexpand = false;
39         this.el.modal = true;
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
46     // user defined functions
47     public void show (Json.Object tree, Gtk.Widget onbtn) {
48     
49             
50             this.file = null;
51             this.notices = tree;
52            
53              //print("looking for %s\n", id);
54             // loop through parent childnre
55               
56             
57             var store = this.compile_result_store.el;    
58             
59             store.clear();
60          
61             
62             tree.foreach_member((obj, file, node) => {
63                 // id line "display text", file
64                 
65                 var title = GLib.Path.get_basename(GLib.Path.get_dirname( file)) + "/" +  GLib.Path.get_basename( file) ;
66                 Gtk.TreeIter iter;
67                 print("Add file %s", title);
68                 store.append(out iter, null);
69                 var lines = tree.get_object_member(file);
70                 title += " (" + lines.get_size().to_string() + ")";
71                 store.set(iter, 0, file, 1, -1, 2, title, 3, file,-1);
72                 
73                 lines.foreach_member((obja, line, nodea) => {
74                     var msg  = "";
75                     var ar = lines.get_array_member(line);
76                     for (var i = 0 ; i < ar.get_length(); i++) {
77                             msg += (msg.length > 0) ? "\n" : "";
78                             msg += ar.get_string_element(i);
79                 }
80                     Gtk.TreeIter citer;  
81                     print("Add line %s", line);
82                     store.append(out citer, iter);
83                     store.set(citer, 
84                         0, file + ":" + line, 
85                         1, int.parse(line), 
86                         2, GLib.Markup.escape_text(line + ": " + msg), 
87                         3, file,-1);
88                 
89                 });
90                 
91                 
92             
93             });
94             
95         int w,h;
96         this.window.el.get_size(out w, out h);
97         
98         // left tree = 250, editor area = 500?
99         
100         var new_w = int.min(250, w-100);
101         if (new_w > (w-100)) {
102             new_w = w-100;
103         }
104         this.el.set_size_request( int.max(100, new_w), int.max(100, h-120));
105     
106         
107     
108         if (this.el.relative_to == null) {
109             this.el.set_relative_to(onbtn);
110         }
111         this.el.show_all();
112        
113         while(Gtk.events_pending()) { 
114                 Gtk.main_iteration();
115         }       
116      //   this.hpane.el.set_position( 0);
117     }
118     public class Xcls_compile_view : Object
119     {
120         public Gtk.Box el;
121         private Xcls_ValaCompileErrors  _this;
122
123
124             // my vars (def)
125
126         // ctor
127         public Xcls_compile_view(Xcls_ValaCompileErrors _owner )
128         {
129             _this = _owner;
130             _this.compile_view = this;
131             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
132
133             // my vars (dec)
134
135             // set gobject values
136             this.el.homogeneous = false;
137             this.el.hexpand = false;
138             var child_0 = new Xcls_Box3( _this );
139             child_0.ref();
140             this.el.pack_start (  child_0.el , false,false,0 );
141             var child_1 = new Xcls_ScrolledWindow5( _this );
142             child_1.ref();
143             this.el.pack_end (  child_1.el , true,true,0 );
144         }
145
146         // user defined functions
147     }
148     public class Xcls_Box3 : Object
149     {
150         public Gtk.Box el;
151         private Xcls_ValaCompileErrors  _this;
152
153
154             // my vars (def)
155
156         // ctor
157         public Xcls_Box3(Xcls_ValaCompileErrors _owner )
158         {
159             _this = _owner;
160             this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
161
162             // my vars (dec)
163
164             // set gobject values
165             var child_0 = new Xcls_Button4( _this );
166             child_0.ref();
167             this.el.pack_start (  child_0.el , true,true,0 );
168         }
169
170         // user defined functions
171     }
172     public class Xcls_Button4 : Object
173     {
174         public Gtk.Button el;
175         private Xcls_ValaCompileErrors  _this;
176
177
178             // my vars (def)
179
180         // ctor
181         public Xcls_Button4(Xcls_ValaCompileErrors _owner )
182         {
183             _this = _owner;
184             this.el = new Gtk.Button();
185
186             // my vars (dec)
187
188             // set gobject values
189             this.el.label = "Compile and Run ";
190         }
191
192         // user defined functions
193     }
194
195
196     public class Xcls_ScrolledWindow5 : Object
197     {
198         public Gtk.ScrolledWindow el;
199         private Xcls_ValaCompileErrors  _this;
200
201
202             // my vars (def)
203
204         // ctor
205         public Xcls_ScrolledWindow5(Xcls_ValaCompileErrors _owner )
206         {
207             _this = _owner;
208             this.el = new Gtk.ScrolledWindow( null, null );
209
210             // my vars (dec)
211
212             // set gobject values
213             var child_0 = new Xcls_compile_tree( _this );
214             child_0.ref();
215             this.el.add (  child_0.el  );
216
217             // init method
218
219             {
220              this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
221              
222             
223             }
224         }
225
226         // user defined functions
227     }
228     public class Xcls_compile_tree : Object
229     {
230         public Gtk.TreeView el;
231         private Xcls_ValaCompileErrors  _this;
232
233
234             // my vars (def)
235
236         // ctor
237         public Xcls_compile_tree(Xcls_ValaCompileErrors _owner )
238         {
239             _this = _owner;
240             _this.compile_tree = this;
241             this.el = new Gtk.TreeView();
242
243             // my vars (dec)
244
245             // set gobject values
246             var child_0 = new Xcls_compile_result_store( _this );
247             child_0.ref();
248             this.el.set_model (  child_0.el  );
249             var child_1 = new Xcls_column( _this );
250             child_1.ref();
251             this.el.append_column (  child_1.el  );
252
253             // init method
254
255             {
256              var description = new Pango.FontDescription();
257                 description.set_size(8000);
258                 this.el.override_font(description);
259             
260             }
261
262             //listeners
263             this.el.button_press_event.connect( ( ev)  => {
264              
265                 Gtk.TreeViewColumn col;
266                 int cell_x;
267                 int cell_y;
268                 Gtk.TreePath path;
269                 if (!this.el.get_path_at_pos((int)ev.x, (int) ev.y, out path, out col, out cell_x, out cell_y )) {
270                     print("nothing selected on click");
271                     
272                     return false; //not on a element.
273                 }
274                 
275                  
276                  // right click.
277                  if (ev.type != Gdk.EventType.2BUTTON_PRESS  || ev.button != 1  ) {    
278                     // show popup!.   
279                         
280                      
281                     return false;
282                 }
283                 Gtk.TreeIter iter;
284                  var mod = _this.compile_result_store.el;
285                 mod.get_iter (out iter, path);
286                 
287                   
288                 
289                 // var val = "";
290                 GLib.Value value;
291                 _this.compile_result_store.el.get_value(iter, 3, out value);
292                 var fname = (string)value;
293                 GLib.Value lvalue;
294                 _this.compile_result_store.el.get_value(iter, 1, out lvalue);
295                 var line = (int) lvalue;
296                 
297                 print("open %s @ %d\n", fname, line);
298                 
299                 
300                var  bjsf = "";
301                 try {             
302                    var  regex = new Regex("\\.vala$");
303                 
304                  
305                     bjsf = regex.replace(fname,fname.length , 0 , ".bjs");
306                  } catch (GLib.RegexError e) {
307                     return false;
308                 }   
309                 var p = _this.window.project;
310                     
311                     
312                     
313                 var jsr = p.getByPath(bjsf);
314                 if (jsr != null) {
315                     _this.window.windowstate.fileViewOpen(jsr, line);
316                     
317                     return false;
318                 
319                 }
320                 
321                 var pf = JsRender.JsRender.factory("PlainFile", p, fname);
322                 _this.window.windowstate.fileViewOpen(pf,line);
323                 
324                 // try hiding the left nav..
325              
326                 return false;
327                 
328               });
329         }
330
331         // user defined functions
332     }
333     public class Xcls_compile_result_store : Object
334     {
335         public Gtk.TreeStore el;
336         private Xcls_ValaCompileErrors  _this;
337
338
339             // my vars (def)
340
341         // ctor
342         public Xcls_compile_result_store(Xcls_ValaCompileErrors _owner )
343         {
344             _this = _owner;
345             _this.compile_result_store = this;
346             this.el = new Gtk.TreeStore( 4,   typeof(string), typeof(int), typeof(string), typeof(string)  );
347
348             // my vars (dec)
349
350             // set gobject values
351         }
352
353         // user defined functions
354     }
355
356     public class Xcls_column : Object
357     {
358         public Gtk.TreeViewColumn el;
359         private Xcls_ValaCompileErrors  _this;
360
361
362             // my vars (def)
363
364         // ctor
365         public Xcls_column(Xcls_ValaCompileErrors _owner )
366         {
367             _this = _owner;
368             this.el = new Gtk.TreeViewColumn();
369
370             // my vars (dec)
371
372             // set gobject values
373             this.el.title = "Compile output";
374             var child_0 = new Xcls_renderer( _this );
375             child_0.ref();
376             this.el.pack_start (  child_0.el , true );
377
378             // init method
379
380             {
381               this.el.add_attribute(_this.renderer.el , "markup", 2 );
382              
383             }
384         }
385
386         // user defined functions
387     }
388     public class Xcls_renderer : Object
389     {
390         public Gtk.CellRendererText el;
391         private Xcls_ValaCompileErrors  _this;
392
393
394             // my vars (def)
395
396         // ctor
397         public Xcls_renderer(Xcls_ValaCompileErrors _owner )
398         {
399             _this = _owner;
400             _this.renderer = this;
401             this.el = new Gtk.CellRendererText();
402
403             // my vars (dec)
404
405             // set gobject values
406         }
407
408         // user defined functions
409     }
410
411
412
413
414
415 }