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