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