135c9b4129bd2056b6cb0e253013258fc5ca634a
[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 ts = _this.compile_result_store;
150         var top = 0;
151         switch(type) {
152             case "ERR":
153                 top = 0;
154                 break;
155             case "WARN":
156                 top =1;
157                 break;
158             case "DEPR":
159                 top =2;
160                 break;
161         }
162         
163         //var tn = ts.nodeFindOrCreate(null,top.to_string(), type);
164         //tn = ts.nodeFindOrCreate(tn, "%d:%s".printf(top, file), file);    
165         //ts.nodeFindOrAppend(tn, "%d:%s:%d".printf(top, file,line), message);   
166         // tree:
167         
168           // error_type
169              // filename
170                 // line - message
171                 
172          // sort (and 'id'?)
173          
174             // 0-2 : fname : line
175          // display
176           
177         
178     }
179     public class Xcls_ScrolledWindow2 : Object 
180     {
181         public Gtk.ScrolledWindow el;
182         private Xcls_GtkView  _this;
183
184
185             // my vars (def)
186
187         // ctor 
188         public Xcls_ScrolledWindow2(Xcls_GtkView _owner )
189         {
190             _this = _owner;
191             this.el = new Gtk.ScrolledWindow( null, null );
192
193             // my vars (dec)
194
195             // set gobject values
196             var child_0 = new Xcls_view_layout( _this );
197             child_0.ref();
198             this.el.add (  child_0.el  );
199         }
200
201         // user defined functions 
202     }
203     public class Xcls_view_layout : Object 
204     {
205         public Gtk.Layout el;
206         private Xcls_GtkView  _this;
207
208
209             // my vars (def)
210
211         // ctor 
212         public Xcls_view_layout(Xcls_GtkView _owner )
213         {
214             _this = _owner;
215             _this.view_layout = this;
216             this.el = new Gtk.Layout( null, null );
217
218             // my vars (dec)
219
220             // set gobject values
221             var child_0 = new Xcls_container( _this );
222             child_0.ref();
223             this.el.put (  child_0.el , 10,10 );
224         }
225
226         // user defined functions 
227     }
228     public class Xcls_container : Object 
229     {
230         public Gtk.HBox el;
231         private Xcls_GtkView  _this;
232
233
234             // my vars (def)
235
236         // ctor 
237         public Xcls_container(Xcls_GtkView _owner )
238         {
239             _this = _owner;
240             _this.container = this;
241             this.el = new Gtk.HBox( true, 0 );
242
243             // my vars (dec)
244
245             // set gobject values
246         }
247
248         // user defined functions 
249     }
250     public class Xcls_compile_view : Object 
251     {
252         public Gtk.VBox el;
253         private Xcls_GtkView  _this;
254
255
256             // my vars (def)
257
258         // ctor 
259         public Xcls_compile_view(Xcls_GtkView _owner )
260         {
261             _this = _owner;
262             _this.compile_view = this;
263             this.el = new Gtk.VBox( false, 0 );
264
265             // my vars (dec)
266
267             // set gobject values
268             var child_0 = new Xcls_HBox6( _this );
269             child_0.ref();
270             this.el.pack_start (  child_0.el , false,false,0 );
271             var child_1 = new Xcls_HBox8( _this );
272             child_1.ref();
273             this.el.pack_start (  child_1.el , true,true,0 );
274         }
275
276         // user defined functions 
277     }
278     public class Xcls_HBox6 : Object 
279     {
280         public Gtk.HBox el;
281         private Xcls_GtkView  _this;
282
283
284             // my vars (def)
285
286         // ctor 
287         public Xcls_HBox6(Xcls_GtkView _owner )
288         {
289             _this = _owner;
290             this.el = new Gtk.HBox( true, 0 );
291
292             // my vars (dec)
293
294             // set gobject values
295             var child_0 = new Xcls_Button7( _this );
296             child_0.ref();
297             this.el.pack_start (  child_0.el , true,true,0 );
298         }
299
300         // user defined functions 
301     }
302     public class Xcls_Button7 : Object 
303     {
304         public Gtk.Button el;
305         private Xcls_GtkView  _this;
306
307
308             // my vars (def)
309
310         // ctor 
311         public Xcls_Button7(Xcls_GtkView _owner )
312         {
313             _this = _owner;
314             this.el = new Gtk.Button();
315
316             // my vars (dec)
317
318             // set gobject values
319             this.el.label = "Full Compile";
320         }
321
322         // user defined functions 
323     }
324     public class Xcls_HBox8 : Object 
325     {
326         public Gtk.HBox el;
327         private Xcls_GtkView  _this;
328
329
330             // my vars (def)
331
332         // ctor 
333         public Xcls_HBox8(Xcls_GtkView _owner )
334         {
335             _this = _owner;
336             this.el = new Gtk.HBox( true, 0 );
337
338             // my vars (dec)
339
340             // set gobject values
341             var child_0 = new Xcls_TreeView9( _this );
342             child_0.ref();
343             this.el.add (  child_0.el  );
344             var child_1 = new Xcls_ScrolledWindow13( _this );
345             child_1.ref();
346             this.el.pack_start (  child_1.el , true,true,0 );
347         }
348
349         // user defined functions 
350     }
351     public class Xcls_TreeView9 : Object 
352     {
353         public Gtk.TreeView el;
354         private Xcls_GtkView  _this;
355
356
357             // my vars (def)
358
359         // ctor 
360         public Xcls_TreeView9(Xcls_GtkView _owner )
361         {
362             _this = _owner;
363             this.el = new Gtk.TreeView();
364
365             // my vars (dec)
366
367             // set gobject values
368             var child_0 = new Xcls_compile_result_store( _this );
369             child_0.ref();
370             this.el.set_model (  child_0.el  );
371             var child_1 = new Xcls_column( _this );
372             child_1.ref();
373         }
374
375         // user defined functions 
376     }
377     public class Xcls_compile_result_store : Object 
378     {
379         public Gtk.TreeStore el;
380         private Xcls_GtkView  _this;
381
382
383             // my vars (def)
384
385         // ctor 
386         public Xcls_compile_result_store(Xcls_GtkView _owner )
387         {
388             _this = _owner;
389             _this.compile_result_store = this;
390             this.el = new Gtk.TreeStore( 4,   typeof(string), typeof(int), typeof(string), typeof(string)  );
391
392             // my vars (dec)
393
394             // set gobject values
395         }
396
397         // user defined functions 
398     }
399     public class Xcls_column : Object 
400     {
401         public Gtk.TreeViewColumn el;
402         private Xcls_GtkView  _this;
403
404
405             // my vars (def)
406
407         // ctor 
408         public Xcls_column(Xcls_GtkView _owner )
409         {
410             _this = _owner;
411             this.el = new Gtk.TreeViewColumn();
412
413             // my vars (dec)
414
415             // set gobject values
416             this.el.title = "Compile output";
417             var child_0 = new Xcls_CellRendererText12( _this );
418             child_0.ref();
419             this.el.pack_start (  child_0.el , false );
420         }
421
422         // user defined functions 
423     }
424     public class Xcls_CellRendererText12 : Object 
425     {
426         public Gtk.CellRendererText el;
427         private Xcls_GtkView  _this;
428
429
430             // my vars (def)
431
432         // ctor 
433         public Xcls_CellRendererText12(Xcls_GtkView _owner )
434         {
435             _this = _owner;
436             this.el = new Gtk.CellRendererText();
437
438             // my vars (dec)
439
440             // set gobject values
441         }
442
443         // user defined functions 
444     }
445     public class Xcls_ScrolledWindow13 : Object 
446     {
447         public Gtk.ScrolledWindow el;
448         private Xcls_GtkView  _this;
449
450
451             // my vars (def)
452
453         // ctor 
454         public Xcls_ScrolledWindow13(Xcls_GtkView _owner )
455         {
456             _this = _owner;
457             this.el = new Gtk.ScrolledWindow( null, null );
458
459             // my vars (dec)
460
461             // set gobject values
462             var child_0 = new Xcls_View14( _this );
463             child_0.ref();
464             this.el.add (  child_0.el  );
465         }
466
467         // user defined functions 
468     }
469     public class Xcls_View14 : Object 
470     {
471         public Gtk.SourceView el;
472         private Xcls_GtkView  _this;
473
474
475             // my vars (def)
476
477         // ctor 
478         public Xcls_View14(Xcls_GtkView _owner )
479         {
480             _this = _owner;
481             this.el = new Gtk.SourceView();
482
483             // my vars (dec)
484
485             // set gobject values
486             this.el.editable = false;
487             this.el.show_line_marks = true;
488             this.el.show_line_numbers = true;
489         }
490
491         // user defined functions 
492     }
493 }