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