845b3d1bd6fc18b43a4188a80b1538a593a36309
[app.Builder.js] / src / Builder4 / GtkView.vala
1 static Xcls_GtkView  _GtkView;
2
3 public class Xcls_GtkView : Object 
4 {
5     public Gtk.VPaned el;
6     private Xcls_GtkView  _this;
7
8     public static Xcls_GtkView singleton()
9     {
10         if (_GtkView == null) {
11             _GtkView= new Xcls_GtkView();
12         }
13         return _GtkView;
14     }
15     public Xcls_view_layout view_layout;
16     public Xcls_container container;
17     public Xcls_compile_view compile_view;
18     public Xcls_compile_result_store compile_result_store;
19
20         // my vars (def)
21     public Gtk.Widget lastObj;
22     public int width;
23     public Xcls_MainWindow main_window;
24     public JsRender.JsRender file;
25     public int height;
26
27     // ctor 
28     public Xcls_GtkView()
29     {
30         _this = this;
31         this.el = new Gtk.VPaned();
32
33         // my vars (dec)
34         this.lastObj = null;
35         this.width = 0;
36         this.file = null;
37         this.height = 0;
38
39         // set gobject values
40         var child_0 = new Xcls_ScrolledWindow2( _this );
41         child_0.ref();
42         this.el.pack1 (  child_0.el , true,true );
43         var child_1 = new Xcls_compile_view( _this );
44         child_1.ref();
45         this.el.pack2 (  child_1.el , true,true );
46
47         // listeners 
48         this.el.size_allocate.connect( (aloc) => {
49         
50             this.width = aloc.width;
51             this.height =aloc.height;
52             });
53     }
54
55     // user defined functions 
56     public void createThumb () {
57         
58         
59         if (this.file == null) {
60             return;
61         }
62         var filename = this.file.getIconFileName(false);
63         
64         var  win = this.el.get_parent_window();
65         var width = win.get_width();
66         var height = win.get_height();
67     
68         Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position?
69     
70         screenshot.save(filename,"png");
71         return;
72         
73         
74         
75         
76         
77          
78         
79         // should we hold until it's printed...
80         
81           
82     
83         
84         
85     
86     
87         
88          
89     }
90     public void loadFile (JsRender.JsRender file) 
91     {
92         
93            // this.el.set_position((int)(this.el.max_position * 0.7));
94             this.el.set_position(this.el.max_position );
95             this.file = null;
96             
97             if (file.tree == null) {
98                 return;
99             }
100             this.file = file;
101             if (this.lastObj != null) {
102                 this.container.el.remove(this.lastObj);
103             }
104             
105             // hide the compile view at present..
106               
107             
108             var w = this.width;
109             var h = this.height;
110             
111             print("ALLOC SET SIZES %d, %d\n", w,h); 
112             
113             // set the container size min to 500/500 or 20 px less than max..
114             w = int.max (w-20, 500);
115             h = int.max (h-20, 500); 
116             
117             print("SET SIZES %d, %d\n", w,h);       
118             _this.container.el.set_size_request(w,h);
119             
120             _this.view_layout.el.set_size(w,h); // should be baded on calc.. -- see update_scrolled.
121             var rgba = Gdk.RGBA ();
122             rgba.parse ("#ccc");
123             _this.view_layout.el.override_background_color(Gtk.StateFlags.NORMAL, rgba);
124             
125             
126         var x = new JsRender.NodeToGtk(file.tree);
127             var obj = x.munge() as Gtk.Widget;
128             this.lastObj = null;
129         if (obj == null) {
130                 return;
131         }
132         this.lastObj = obj;
133             
134             this.container.el.add(obj);
135             obj.show_all();
136             
137              
138             
139     }
140     public void compileNotice ( string  type,   string file,   int line,   string  message) {
141         // if type = "START"... then we reset the tree?
142         // the issue is that the compiler is continually going..
143         // so editing a file etc.. may change things.?
144         // probably not an issue.
145         if (type =="START") {
146             // reset the tree;
147             return;
148         }
149         var cs = _this.compile_result_store;
150         
151         var top = 0;
152         var title = "";
153         switch(type) {
154             case "ERR":
155                 title = "Errors";
156                 top =0;
157                 break;
158             
159             case "WARN":
160                 title = "Warnings";
161                 top =1;
162                 break;
163                 
164             case "DEPR":
165                 title = "Depricated";
166                 top=2;
167                 
168         }
169                 
170         
171          var tv = cs.nodeFindOrCreate(null, top.to_string(), title);
172          tv = cs.nodeFindOrCreate(tv, "%d:%s".print(top, file), file);
173           cs.nodeAppendOrCreate(tv, "%d:%s:%d".print(top, file,line), file,line, message);
174         
175     }
176     public class Xcls_ScrolledWindow2 : Object 
177     {
178         public Gtk.ScrolledWindow el;
179         private Xcls_GtkView  _this;
180
181
182             // my vars (def)
183
184         // ctor 
185         public Xcls_ScrolledWindow2(Xcls_GtkView _owner )
186         {
187             _this = _owner;
188             this.el = new Gtk.ScrolledWindow( null, null );
189
190             // my vars (dec)
191
192             // set gobject values
193             var child_0 = new Xcls_view_layout( _this );
194             child_0.ref();
195             this.el.add (  child_0.el  );
196         }
197
198         // user defined functions 
199     }
200     public class Xcls_view_layout : Object 
201     {
202         public Gtk.Layout el;
203         private Xcls_GtkView  _this;
204
205
206             // my vars (def)
207
208         // ctor 
209         public Xcls_view_layout(Xcls_GtkView _owner )
210         {
211             _this = _owner;
212             _this.view_layout = this;
213             this.el = new Gtk.Layout( null, null );
214
215             // my vars (dec)
216
217             // set gobject values
218             var child_0 = new Xcls_container( _this );
219             child_0.ref();
220             this.el.put (  child_0.el , 10,10 );
221         }
222
223         // user defined functions 
224     }
225     public class Xcls_container : Object 
226     {
227         public Gtk.HBox el;
228         private Xcls_GtkView  _this;
229
230
231             // my vars (def)
232
233         // ctor 
234         public Xcls_container(Xcls_GtkView _owner )
235         {
236             _this = _owner;
237             _this.container = this;
238             this.el = new Gtk.HBox( true, 0 );
239
240             // my vars (dec)
241
242             // set gobject values
243         }
244
245         // user defined functions 
246     }
247     public class Xcls_compile_view : Object 
248     {
249         public Gtk.VBox el;
250         private Xcls_GtkView  _this;
251
252
253             // my vars (def)
254
255         // ctor 
256         public Xcls_compile_view(Xcls_GtkView _owner )
257         {
258             _this = _owner;
259             _this.compile_view = this;
260             this.el = new Gtk.VBox( false, 0 );
261
262             // my vars (dec)
263
264             // set gobject values
265             var child_0 = new Xcls_HBox6( _this );
266             child_0.ref();
267             this.el.pack_start (  child_0.el , false,false,0 );
268             var child_1 = new Xcls_HBox8( _this );
269             child_1.ref();
270             this.el.pack_start (  child_1.el , true,true,0 );
271         }
272
273         // user defined functions 
274     }
275     public class Xcls_HBox6 : Object 
276     {
277         public Gtk.HBox el;
278         private Xcls_GtkView  _this;
279
280
281             // my vars (def)
282
283         // ctor 
284         public Xcls_HBox6(Xcls_GtkView _owner )
285         {
286             _this = _owner;
287             this.el = new Gtk.HBox( true, 0 );
288
289             // my vars (dec)
290
291             // set gobject values
292             var child_0 = new Xcls_Button7( _this );
293             child_0.ref();
294             this.el.pack_start (  child_0.el , true,true,0 );
295         }
296
297         // user defined functions 
298     }
299     public class Xcls_Button7 : Object 
300     {
301         public Gtk.Button el;
302         private Xcls_GtkView  _this;
303
304
305             // my vars (def)
306
307         // ctor 
308         public Xcls_Button7(Xcls_GtkView _owner )
309         {
310             _this = _owner;
311             this.el = new Gtk.Button();
312
313             // my vars (dec)
314
315             // set gobject values
316             this.el.label = "Full Compile";
317         }
318
319         // user defined functions 
320     }
321     public class Xcls_HBox8 : Object 
322     {
323         public Gtk.HBox el;
324         private Xcls_GtkView  _this;
325
326
327             // my vars (def)
328
329         // ctor 
330         public Xcls_HBox8(Xcls_GtkView _owner )
331         {
332             _this = _owner;
333             this.el = new Gtk.HBox( true, 0 );
334
335             // my vars (dec)
336
337             // set gobject values
338             var child_0 = new Xcls_TreeView9( _this );
339             child_0.ref();
340             this.el.add (  child_0.el  );
341             var child_1 = new Xcls_ScrolledWindow13( _this );
342             child_1.ref();
343             this.el.pack_start (  child_1.el , true,true,0 );
344         }
345
346         // user defined functions 
347     }
348     public class Xcls_TreeView9 : Object 
349     {
350         public Gtk.TreeView el;
351         private Xcls_GtkView  _this;
352
353
354             // my vars (def)
355
356         // ctor 
357         public Xcls_TreeView9(Xcls_GtkView _owner )
358         {
359             _this = _owner;
360             this.el = new Gtk.TreeView();
361
362             // my vars (dec)
363
364             // set gobject values
365             var child_0 = new Xcls_compile_result_store( _this );
366             child_0.ref();
367             this.el.set_model (  child_0.el  );
368             var child_1 = new Xcls_column( _this );
369             child_1.ref();
370         }
371
372         // user defined functions 
373     }
374     public class Xcls_compile_result_store : Object 
375     {
376         public Gtk.TreeStore el;
377         private Xcls_GtkView  _this;
378
379
380             // my vars (def)
381
382         // ctor 
383         public Xcls_compile_result_store(Xcls_GtkView _owner )
384         {
385             _this = _owner;
386             _this.compile_result_store = this;
387             this.el = new Gtk.TreeStore( 4,   typeof(string), typeof(int), typeof(string), typeof(string)  );
388
389             // my vars (dec)
390
391             // set gobject values
392         }
393
394         // user defined functions 
395         public Gtk.TreePath nodeFindOrCreate (Gtk.TreePath? par, string id, string title) {
396         
397             // loop through parent childnre
398             Gtk.TreeIter piter;
399             if (par != null) {
400                 this.el.get_iter(out piter, par);
401             }
402             Gtk.TreeIter iter;
403             if (this.el.iter_children(out iter, par == null ? null : piter)) {
404                 var loop = true;
405                 while (loop) {
406                     GLib.Value val;
407                     this.el.get_value(iter, 0, out val);
408                     var sval = (string)val;
409                     if (sval == id) {
410                         return this.el.get_path(iter);
411                     }
412                     loop = this.el.iter_next(iter);    
413                 }
414             }
415             // create the node...
416             
417             this.el.append(out iter,par == null ? null : piter);
418             this.el.set(iter, id, 0, title, "",-1);
419                
420             return new this.el.get_path(iter);
421         
422         }
423     }
424     public class Xcls_column : Object 
425     {
426         public Gtk.TreeViewColumn el;
427         private Xcls_GtkView  _this;
428
429
430             // my vars (def)
431
432         // ctor 
433         public Xcls_column(Xcls_GtkView _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_CellRendererText12( _this );
443             child_0.ref();
444             this.el.pack_start (  child_0.el , false );
445         }
446
447         // user defined functions 
448     }
449     public class Xcls_CellRendererText12 : Object 
450     {
451         public Gtk.CellRendererText el;
452         private Xcls_GtkView  _this;
453
454
455             // my vars (def)
456
457         // ctor 
458         public Xcls_CellRendererText12(Xcls_GtkView _owner )
459         {
460             _this = _owner;
461             this.el = new Gtk.CellRendererText();
462
463             // my vars (dec)
464
465             // set gobject values
466         }
467
468         // user defined functions 
469     }
470     public class Xcls_ScrolledWindow13 : Object 
471     {
472         public Gtk.ScrolledWindow el;
473         private Xcls_GtkView  _this;
474
475
476             // my vars (def)
477
478         // ctor 
479         public Xcls_ScrolledWindow13(Xcls_GtkView _owner )
480         {
481             _this = _owner;
482             this.el = new Gtk.ScrolledWindow( null, null );
483
484             // my vars (dec)
485
486             // set gobject values
487             var child_0 = new Xcls_View14( _this );
488             child_0.ref();
489             this.el.add (  child_0.el  );
490         }
491
492         // user defined functions 
493     }
494     public class Xcls_View14 : Object 
495     {
496         public Gtk.SourceView el;
497         private Xcls_GtkView  _this;
498
499
500             // my vars (def)
501
502         // ctor 
503         public Xcls_View14(Xcls_GtkView _owner )
504         {
505             _this = _owner;
506             this.el = new Gtk.SourceView();
507
508             // my vars (dec)
509
510             // set gobject values
511             this.el.editable = false;
512             this.el.show_line_marks = true;
513             this.el.show_line_numbers = true;
514         }
515
516         // user defined functions 
517     }
518 }