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