Builder4/MainWindow.bjs
[app.Builder.js] / Builder4 / MainWindow.js
1 Gtk = imports.gi.Gtk;
2 Gdk = imports.gi.Gdk;
3 Pango = imports.gi.Pango;
4 GLib = imports.gi.GLib;
5 Gio = imports.gi.Gio;
6 GObject = imports.gi.GObject;
7 GtkSource = imports.gi.GtkSource;
8 WebKit = imports.gi.WebKit;
9 Vte = imports.gi.Vte;
10 console = imports.console;
11 XObject = imports.XObject.XObject;
12 MainWindow=new XObject({
13     xtype: Gtk.Window,
14     listeners : {
15         show : ( ) => {
16             // hide the file editing..
17            
18             //this.hideViewEditing();
19         },
20         delete_event : (   event) => {
21             return false;
22         }
23     },
24     border_width : 0,
25     default_height : 500,
26     default_width : 800,
27     destroy : "() => {\n   Gtk.main_quit();\n}",
28     id : "MainWindow",
29     init : this.state = "files";
30           
31         //this.el.show_all();,
32     type : Gtk.WindowType.TOPLEVEL,
33     'void:hideAddListener' : () {
34          _this.addpropsview.el.save_easing_state();
35         var el = _this.rooview.el;
36         el.save_easing_state();
37     
38         
39         el.set_scale(1.0f,1.0f);
40         _this.addpropsview.el.set_scale(0.0f,0.0f);
41         _this.state = "edit";
42     
43      
44         //_this.clutterfiles.loadProject(_this.project);
45     
46         el.restore_easing_state();
47          _this.addpropsview.el.restore_easing_state();  
48       },
49     'void:hideAddProp' : () {
50          _this.addpropsview.el.save_easing_state();
51         var el = _this.rooview.el;
52         el.save_easing_state();
53     
54         
55         el.set_scale(1.0f,1.0f);
56         _this.addpropsview.el.set_scale(0.0f,0.0f);
57         _this.state = "edit";
58     
59      
60         //_this.clutterfiles.loadProject(_this.project);
61     
62         el.restore_easing_state();
63          _this.addpropsview.el.restore_easing_state();  
64      },
65     'void:hideCodeEdit' : () {
66         //this.code_editor.saveContents();
67        
68          _this.codeeditview.el.save_easing_state();
69         var el = _this.rooview.el;
70         el.save_easing_state();
71     
72         
73         el.set_scale(1.0f,1.0f);
74         _this.codeeditview.el.set_scale(0.0f,0.0f);
75         _this.state = "edit";
76     
77      
78         //_this.clutterfiles.loadProject(_this.project);
79     
80         el.restore_easing_state();
81          _this.codeeditview.el.restore_easing_state();  
82      },
83     'void:hideObject' : () {
84           // return to editing state..
85            
86          
87     
88     
89          
90          _this.objectview.el.save_easing_state();
91         var el = _this.rooview.el;
92         el.save_easing_state();
93     
94         
95         el.set_scale(1.0f,1.0f);
96         _this.objectview.el.set_scale(0.0f,0.0f);
97         _this.state = "edit";
98     
99      
100         //_this.clutterfiles.loadProject(_this.project);
101     
102         el.restore_easing_state();
103          _this.objectview.el.restore_easing_state();  
104      
105     
106     },
107     'void:hideProjectEdit' : () {
108         // return to editing state..
109            
110           _this.projectbutton.el.show();
111          _this.projecteditbutton.el.show();
112          
113          
114         //this.rooview.el.hide();
115          //this.edit_project.el.show();
116             _this.projecteditview.el.save_easing_state();
117         var el = _this.rooview.el;
118         el.save_easing_state();
119     
120         
121         el.set_scale(1.0f,1.0f);
122            _this.projecteditview.el.set_scale(1.0f,0.0f);
123         _this.state = "edit";
124     
125      
126         //_this.clutterfiles.loadProject(_this.project);
127     
128         el.restore_easing_state();
129           _this.projecteditview.el.restore_easing_state();  
130       
131     },
132     'void:hideViewEditing' : ( )   {
133       
134         if (this.left_tree.getActiveFile() != null) {
135              if (this.left_tree.getActiveFile().xtype == "Roo" ) {
136                  this.window_rooview.createThumb();
137              } else {
138                   this.window_gladeview.createThumb();
139               }
140           }
141           _this.projecteditbutton.el.hide();
142          this.editpane.el.hide();
143         //this.rooview.el.hide();
144          this.left_projects.el.show();
145         
146         var el = _this.rooview.el;
147         el.save_easing_state();
148           el.set_easing_duration(1000);
149         // show project / file view..
150         //_this.mainpane.lastWidth = _this.leftpane.el.get_position();
151         //_this.mainpane.el.set_position(0);
152         // rotate y 180..
153         el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 360.0f);
154         el.set_scale(0.0f,0.0f);
155        
156             _this.state = "files";
157     
158         _this.left_projects.selectProject(_this.project);
159         //_this.clutterfiles.loadProject(_this.project);
160     
161         el.restore_easing_state();
162             
163         print("show view browsing");
164     },
165     'void:initChildren' : () {
166         // this needs putting in a better place..
167         
168         print("init children");
169         this.left_tree = new Xcls_WindowLeftTree();
170         this.left_tree.ref();
171         this.tree.el.pack_start(this.left_tree.el,true, true,0);
172         this.left_tree.el.show_all();
173        
174         this.left_tree.before_node_change.connect(() => {
175             if (this.state != "codeedit") {
176                 this.left_props.finish_editing();
177                 return true;
178             }
179             if (!this.code_editor.saveContents()) {
180                 return false;
181             }
182             return false;
183         
184         });
185         
186         this.left_tree.node_selected.connect((sel) => {
187             
188             print("node_selected called %s\n", (sel == null) ? "NULL" : "a value");
189             
190             if (sel == null) {
191                 this.left_props.el.hide();
192             } 
193             this.left_props.el.show();
194             this.left_props.load(this.left_tree.getActiveFile(), sel);
195             switch (this.state) {
196                 case "object": 
197                       
198                      if (sel == null) {
199                         this.rightpalete.clear();
200                         break;
201                     }
202                     this.rightpalete.load(_this.left_tree.getActiveFile().palete(), sel.fqn());
203                     break;
204                      
205                     
206                case "addprop":
207                     if (sel == null) {
208                         this.add_props.clear();
209                         break;
210                     }
211                     this.add_props.show(_this.left_tree.getActiveFile().palete(), "props", sel.fqn());
212                     break;
213                     
214                case "addlistener":
215                     if (sel == null) {
216                         this.add_props.clear();
217                         break;
218                     }
219                     this.add_props.show(_this.left_tree.getActiveFile().palete(), "signals", sel.fqn());
220                     break;
221     
222                case "codeedit":
223                    
224                     this.hideCodeEdit();
225                     break;
226                    
227                                     
228             }
229             return  ;
230               
231         });
232         
233          this.left_tree.changed.connect(() => {
234            this.window_rooview.requestRedraw();
235         });
236          
237         
238     
239         // left properties
240     
241         this.left_props =new Xcls_LeftProps();
242         this.left_props.ref();
243         this.props.el.pack_start(this.left_props.el,true, true,0);
244         this.left_props.el.show_all();
245         
246         this.left_props.show_editor.connect( (file, node, type,  key) => {
247             this.showCodeEdit(node, type,  key);
248         });
249         this.left_props.stop_editor.connect( () => {
250             if (this.state != "codeedit") {
251                 return true;
252             }
253         
254             var ret =  this.code_editor.saveContents();
255             if (!ret) {
256                 return false;
257             }
258             this.hideCodeEdit();
259             return ret;
260         });
261          this.left_props.changed.connect(() => {
262               if (this.left_tree.getActiveFile().xtype == "Roo" ) {
263                    this.window_rooview.requestRedraw();
264                } else {
265                   this.window_gladeview.loadFile(this.left_tree.getActiveFile());
266               }
267         });
268         
269     
270     
271     
272         // left projects..
273          this.left_projects = new Xcls_WindowLeftProjects();
274          this.left_projects.ref();
275          this.leftpane.el.pack_start(this.left_projects.el,true, true,0);
276          //this.left_projects.el.show_all();
277          this.left_projects.project_selected.connect((proj) => {
278             proj.scanDirs();
279             _this.clutterfiles.loadProject(proj);
280         
281          });
282         
283        
284         // project edit..
285         this.projectsettings  =new Xcls_ProjectSettings();
286         this.projectsettings.ref();  /// really?
287         ((Gtk.Container)(this.projecteditview.el.get_widget())).add(this.projectsettings.el);
288         this.projectsettings.el.show_all();
289     
290         var stage = _this.projecteditview.el.get_stage();
291         stage.set_background_color(  Clutter.Color.from_string("#000"));
292         
293          this.projectsettings.buttonPressed.connect((btn) => {
294              if (this.left_tree.getActiveFile().xtype == "Roo" ) {
295              
296                 if (btn == "save") {
297                      _this.window_rooview.view.renderJS(true);
298                 }
299                 if (btn == "apply") {
300                     _this.window_rooview.view.renderJS(true);
301                     return;
302                 }
303             } else {
304                 // do nothing for gtk..
305             }
306             this.hideProjectEdit();
307              
308          });
309         
310         
311         // objects (palate..)
312         this.rightpalete  = new Xcls_RightPalete();
313         this.rightpalete.ref();  /// really?
314         ((Gtk.Container)(this.objectview.el.get_widget())).add(this.rightpalete.el);
315         //this.projectsettings.el.show_all();
316     
317         stage = _this.objectview.el.get_stage();
318         stage.set_background_color(  Clutter.Color.from_string("#000"));
319         
320         /*this.projectsettings.buttonPressed.connect((btn) => {
321             if (btn == "save") {
322                  _this.window_rooview.view.renderJS(true);
323             }
324             if (btn == "apply") {
325                 _this.window_rooview.view.renderJS(true);
326                 return;
327             }
328             this.hideProjectEdit();
329              
330          });
331         */
332         
333         
334           
335         // Add properties
336         this.add_props  = new Xcls_WindowAddProp();
337         this.add_props.ref();  /// really?
338         ((Gtk.Container)(this.addpropsview.el.get_widget())).add(this.add_props.el);
339         //this.projectsettings.el.show_all();
340     
341         stage = _this.addpropsview.el.get_stage();
342         stage.set_background_color(  Clutter.Color.from_string("#000"));
343         
344         
345         _this.add_props.select.connect( (key,type,skel, etype) => {
346             this.left_props.addProp(etype, key, skel, type);
347         });
348         
349         // editor
350         
351         
352         this.code_editor  = new Xcls_Editor();
353         this.code_editor.ref();  /// really?
354         ((Gtk.Container)(this.codeeditview.el.get_widget())).add(this.code_editor.el);
355         //this.projectsettings.el.show_all();
356     
357         stage = _this.codeeditview.el.get_stage();
358         stage.set_background_color(  Clutter.Color.from_string("#000"));
359         // editor.save...
360     
361         
362         
363          
364         
365         
366         //  roo view
367         
368          this.window_rooview  =new Xcls_WindowRooView();
369         this.window_rooview.ref();
370         ((Gtk.Container)(this.rooview.el.get_widget())).add(this.window_rooview.el);
371         this.window_rooview.el.show_all();
372     
373         stage = _this.rooview.el.get_stage();
374         stage.set_background_color(  Clutter.Color.from_string("#000"));
375         
376           
377         //  glade view
378         
379         this.window_gladeview  =new Xcls_GladeView();
380         this.window_gladeview.ref();
381     
382         //((Gtk.Container)(this.rooview.el.get_widget())).add(this.window_gladeview.el);
383         ///this.window_gladeview.el.hide();
384     
385        
386         
387         // clutter files
388         
389         
390         this.clutterfiles = new Xcls_ClutterFiles();
391         this.clutterfiles.ref();
392         stage.add_child(this.clutterfiles.el);
393         this.clutterfiles.el.show_all();
394     
395     
396         this.clutterfiles.open.connect((file) => { 
397             _this.project = file.project;
398             _this.showViewEditing();
399             this.left_tree.model.loadFile(file);
400             var ctr= ((Gtk.Container)(this.rooview.el.get_widget()));
401             if (file.xtype == "Roo" ) { 
402                 ctr.foreach( (w) => { ctr.remove(w); });
403                 ctr.add(this.window_rooview.el);
404                 this.window_rooview.loadFile(file);
405                 
406                 this.window_rooview.el.show_all();
407             } else {
408                 ctr.foreach( (w) => { ctr.remove(w); });
409                 ctr.add(this.window_gladeview.el);
410                 this.window_gladeview.loadFile(file);
411                 this.window_gladeview.el.show_all();
412             }
413             print("OPEN : " + file.name);
414     
415         });
416     
417     
418     
419     
420     
421     
422         //w.el.show_all();
423         var tl = new Clutter.Timeline(6000);
424         tl.set_repeat_count(-1);
425         tl.start();
426         tl.ref();
427     
428         this.children_loaded = true;
429     
430     
431     
432     
433     },
434     'void:setTitle' : (string str) {
435         this.el.set_title(this.title + " - " + str);
436     },
437     'void:show' : () {
438         this.left_tree =new Xcls_WindowLeftTree();
439         _this.vbox.el.pack_start(this.left_tree.el,true, true,0);
440         this.el.show_all();
441     
442     },
443     'void:showAddListener' : () {
444     
445          
446          
447         var ae =      this.left_tree.getActiveElement();
448         if (ae == null) {
449             return;
450         }
451          
452         //this.rooview.el.hide();
453         this.add_props.el.show_all();
454         this.add_props.show(
455             Palete.factory(this.project.xtype), 
456             "signals",
457             ae.fqn()
458         );
459         //this.rightpalete.show(this.project);
460     
461         _this.addpropsview.el.save_easing_state();
462             
463         var el = _this.rooview.el;
464         el.save_easing_state();
465        
466         
467         el.set_scale(0.5f,0.5f);
468     
469         _this.addpropsview.el.set_scale(1.0f,1.0f);
470        
471        
472      
473         //_this.clutterfiles.loadProject(_this.project);
474     
475         el.restore_easing_state();
476         _this.addpropsview.el.restore_easing_state();
477         this.state = "addlistener";
478     },
479     'void:showAddProp' : () {
480     
481          
482          var ae =      this.left_tree.getActiveElement();
483         if (ae == null) {
484             return;
485         }
486          
487          
488          
489          
490         //this.rooview.el.hide();
491         this.add_props.el.show_all();
492         this.add_props.show(
493             Palete.factory(this.project.xtype), 
494             "props",
495             ae.fqn()
496         );
497     
498         _this.addpropsview.el.save_easing_state();
499             
500         var el = _this.rooview.el;
501         el.save_easing_state();
502        
503         
504         el.set_scale(0.5f,0.5f);
505     
506         _this.addpropsview.el.set_scale(1.0f,1.0f);
507        
508        
509      
510         //_this.clutterfiles.loadProject(_this.project);
511     
512         el.restore_easing_state();
513         _this.addpropsview.el.restore_easing_state();
514         this.state = "addprop";
515     },
516     'void:showCodeEdit' : (JsRender.Node node, string ptype, string key)
517     {
518         // this is a bit different,
519         // it's not called via a button - but triggered by the prop edit class signal.
520         // so it has to hide any other state..
521         
522         switch(this.state) {
523             case "object":
524                 this.hideObject();
525                 break;
526             case "addprop":
527                 this.hideAddProp();
528                 break;
529             case "addlistener":
530                 this.hideAddListener();
531                 break;
532         }
533      
534      
535          
536          
537         //this.rooview.el.hide();
538         this.code_editor.el.show_all();
539         this.code_editor.show(
540             node,
541             ptype,
542             key
543         );
544     
545         _this.codeeditview.el.save_easing_state();
546             
547         var el = _this.rooview.el;
548         el.save_easing_state();
549        
550         
551         el.set_scale(0.5f,0.5f);
552     
553         _this.codeeditview.el.set_scale(1.0f,1.0f);
554        
555        
556      
557         //_this.clutterfiles.loadProject(_this.project);
558     
559         el.restore_easing_state();
560         _this.codeeditview.el.restore_easing_state();
561         this.state = "codeedit";
562     },
563     'void:showObject' : () {
564     
565          
566         // what's the active node on the left hand side..
567         
568         var n = _this.left_tree.getActiveElement();
569         if (n == null) {
570             return;
571         }
572         
573          
574          
575          
576         //this.rooview.el.hide();
577         this.rightpalete.el.show_all();
578         this.rightpalete.load(_this.left_tree.getActiveFile().palete(), n.fqn());
579     
580         
581         //this.rightpalete.show(this.project);
582     
583         _this.objectview.el.save_easing_state();
584             
585         var el = _this.rooview.el;
586         el.save_easing_state();
587        
588         
589         el.set_scale(0.5f,0.5f);
590     
591         _this.objectview.el.set_scale(1.0f,1.0f);
592        
593        
594      
595         //_this.clutterfiles.loadProject(_this.project);
596     
597         el.restore_easing_state();
598         _this.objectview.el.restore_easing_state();
599         this.state = "object";
600     },
601     'void:showProjectEdit' : () {
602         // make the browser smaller, and show the edit dialog
603         
604         
605          _this.projectbutton.el.hide();
606          _this.projecteditbutton.el.hide();
607          
608          
609         //this.rooview.el.hide();
610         this.projectsettings.el.show_all();
611         this.projectsettings.show(this.project);
612         _this.projecteditview.el.save_easing_state();
613             
614         var el = _this.rooview.el;
615         el.save_easing_state();
616        
617         
618         el.set_scale(0.5f,0.5f);
619     
620         _this.projecteditview.el.set_scale(1.0f,1.0f);
621        
622         _this.state = "projectedit";
623          
624      
625         //_this.clutterfiles.loadProject(_this.project);
626     
627         el.restore_easing_state();
628         _this.projecteditview.el.restore_easing_state();
629       //  print("show view browsing");
630         
631     },
632     'void:showViewEditing' : ( )  {
633          this.editpane.el.show();
634       //   this.rooview.el.show();
635          this.left_projects.el.hide();
636         
637            _this.projecteditbutton.el.show();
638         
639         var el = _this.rooview.el;
640             el.save_easing_state();
641       
642         
643             el.set_rotation_angle(Clutter.RotateAxis.Y_AXIS, 0.0f);
644             el.set_scale(1.0f,1.0f);
645             _this.state = "edit";
646            // _this.mainpane.el.set_position(_this.leftpane.lastWidth);
647             _this.clutterfiles.el.hide();
648         
649         el.restore_easing_state();
650             
651         print("show view editing");
652     },
653     items : [
654         {
655             xtype: Gtk.VBox,
656             homogeneous : false,
657             id : "vbox",
658             pack : "add",
659             items : [
660                 {
661                     xtype: Gtk.HBox,
662                     homogeneous : true,
663                     id : "topbar",
664                     pack : "pack_start,false,true,0",
665                     height_request : 20,
666                     vexpand : false
667                 },
668                 {
669                     xtype: Gtk.HPaned,
670                     id : "mainpane",
671                     pack : "pack_end,true,true,0",
672                     position : 400,
673                     items : [
674                         {
675                             xtype: Gtk.VBox,
676                             id : "leftpane",
677                             pack : "add1",
678                             items : [
679                                 {
680                                     xtype: Gtk.VPaned,
681                                     id : "editpane",
682                                     pack : "pack_start,false,true,0",
683                                     items : [
684                                         {
685                                             xtype: Gtk.VBox,
686                                             id : "tree",
687                                             pack : "add1"
688                                         },
689                                         {
690                                             xtype: Gtk.VBox,
691                                             id : "props",
692                                             pack : "add2"
693                                         }
694                                     ]
695                                 }
696                             ]
697                         },
698                         {
699                             xtype: Gtk.VBox,
700                             pack : "add2",
701                             items : [
702                                 {
703                                     xtype: GtkClutter.Embed,
704                                     listeners : {
705                                         size_allocate : (  alloc) => {
706                                             if (!_this.children_loaded) {  return; }
707                                             //print("size_allocation %d,%d\n".printf(alloc.width, alloc.height));
708                                         
709                                         /*    _this.rooview.el.set_size(this.el.get_stage().width-50,
710                                                     this.el.get_stage().height);
711                                             _this.clutterfiles.set_size(this.el.get_stage().width-50,
712                                                    this.el.get_stage().height);
713                                         */
714                                            // this.el.set_size_request(alloc.width,alloc.height);
715                                            // this.el.get_stage().set_size(alloc.width,alloc.height);
716                                             _this.rooview.el.set_size(alloc.width-50,
717                                                     alloc.height);
718                                                     
719                                                      
720                                                     
721                                             _this.clutterfiles.set_size(alloc.width-50,
722                                                    alloc.height);
723                                             _this.projecteditview.el.set_size(alloc.width-50,
724                                                    alloc.height / 2.0f);
725                                                    
726                                             _this.objectview.el.set_size((alloc.width -50)/2.0f,
727                                                    alloc.height);
728                                                    
729                                             _this.addpropsview.el.set_size((alloc.width -50)/2.0f,
730                                                    alloc.height);
731                                             
732                                             _this.codeeditview.el.set_size((alloc.width -50)/2.0f,
733                                                    alloc.height);
734                                         }
735                                     },
736                                     id : "clutterembed",
737                                     pack : "pack_start,true,true,0",
738                                     init : var stage = this.el.get_stage();
739                                         stage.set_background_color(  Clutter.Color.from_string("#000"));,
740                                     items : [
741                                         {
742                                             xtype: GtkClutter.Actor,
743                                             id : "rooview",
744                                             pack : "get_stage().add_child",
745                                             init : {
746                                                
747                                                
748                                                 this.el.add_constraint(
749                                                     new Clutter.AlignConstraint(
750                                                         _this.clutterembed.el.get_stage(), 
751                                                         Clutter.AlignAxis.X_AXIS,
752                                                         1.0f
753                                                     )
754                                                 );
755                                                     
756                                                 //this.el.set_position(100,100);
757                                                 this.el.set_pivot_point(1.0f,1.0f);
758                                                 
759                                                 this.el.set_size(_this.clutterembed.el.get_stage().width-50,
760                                                         _this.clutterembed.el.get_stage().height);
761                                                         
762                                             }
763                                         },
764                                         {
765                                             xtype: GtkClutter.Actor,
766                                             id : "objectview",
767                                             pack : "get_stage().add_child",
768                                             init : {
769                                                
770                                                /*
771                                                 this.el.add_constraint(
772                                                     new Clutter.AlignConstraint(
773                                                         _this.clutterembed.el.get_stage(), 
774                                                         Clutter.AlignAxis.X_AXIS,
775                                                         0.0f
776                                                     )
777                                                 );
778                                                 */
779                                                 this.el.fixed_x = 50.0f;
780                                                 this.el.fixed_y = 0.0f;
781                                                 //this.el.set_position(100,100);
782                                                 this.el.set_pivot_point(0.0f,0.0f);
783                                                 this.el.set_scale(0.0f,1.0f);
784                                                 this.el.set_size((_this.clutterembed.el.get_stage().width-50)/2,
785                                                         _this.clutterembed.el.get_stage().height);
786                                                         
787                                             }
788                                         },
789                                         {
790                                             xtype: GtkClutter.Actor,
791                                             id : "codeeditview",
792                                             pack : "get_stage().add_child",
793                                             init : {
794                                                
795                                                /*
796                                                 this.el.add_constraint(
797                                                     new Clutter.AlignConstraint(
798                                                         _this.clutterembed.el.get_stage(), 
799                                                         Clutter.AlignAxis.X_AXIS,
800                                                         0.0f
801                                                     )
802                                                 );
803                                                 */
804                                                 this.el.fixed_x = 50.0f;
805                                                 this.el.fixed_y = 0.0f;
806                                                 //this.el.set_position(100,100);
807                                                 this.el.set_pivot_point(0.0f,0.0f);
808                                                 this.el.set_scale(0.0f,1.0f);
809                                                 this.el.set_size((_this.clutterembed.el.get_stage().width-50)/2,
810                                                         _this.clutterembed.el.get_stage().height);
811                                                         
812                                             }
813                                         },
814                                         {
815                                             xtype: GtkClutter.Actor,
816                                             id : "addpropsview",
817                                             pack : "get_stage().add_child",
818                                             init : {
819                                                
820                                                /*
821                                                 this.el.add_constraint(
822                                                     new Clutter.AlignConstraint(
823                                                         _this.clutterembed.el.get_stage(), 
824                                                         Clutter.AlignAxis.X_AXIS,
825                                                         0.0f
826                                                     )
827                                                 );
828                                                 */
829                                                 this.el.fixed_x = 50.0f;
830                                                 this.el.fixed_y = 0.0f;
831                                                 //this.el.set_position(100,100);
832                                                 this.el.set_pivot_point(0.0f,0.0f);
833                                                 this.el.set_scale(0.0f,1.0f);
834                                                 this.el.set_size((_this.clutterembed.el.get_stage().width-50)/2,
835                                                         _this.clutterembed.el.get_stage().height);
836                                                         
837                                             }
838                                         },
839                                         {
840                                             xtype: GtkClutter.Actor,
841                                             id : "projecteditview",
842                                             pack : "get_stage().add_child",
843                                             init : {
844                                                
845                                                
846                                                 this.el.add_constraint(
847                                                     new Clutter.AlignConstraint(
848                                                         _this.clutterembed.el.get_stage(), 
849                                                         Clutter.AlignAxis.X_AXIS,
850                                                         1.0f
851                                                     )
852                                                 );
853                                                     
854                                                 //this.el.set_position(100,100);
855                                                 this.el.set_pivot_point(0.0f,0.0f);
856                                                 this.el.set_scale(1.0f,0.0f);
857                                                 this.el.set_size(_this.clutterembed.el.get_stage().width-50,
858                                                         _this.clutterembed.el.get_stage().height /2);
859                                                         
860                                             }
861                                         },
862                                         {
863                                             xtype: Clutter.Actor,
864                                             id : "buttonlayout",
865                                             pack : "get_stage().add_child",
866                                             init : {
867                                                 
868                                                 this.el.add_constraint(
869                                                     new Clutter.AlignConstraint(
870                                                         _this.clutterembed.el.get_stage(), 
871                                                         Clutter.AlignAxis.X_AXIS,
872                                                         0.0f
873                                                     )
874                                                 );
875                                                  
876                                                 
877                                                 //this.el.set_position(100,100);
878                                                 this.el.set_pivot_point(0.5f,0.5f);
879                                                  this.el.set_size(50,
880                                                        _this.clutterembed.el.get_stage().height);
881                                                  
882                                             },
883                                             items : [
884                                                 {
885                                                     xtype: Clutter.Actor,
886                                                     listeners : {
887                                                         enter_event : (  event)  => {
888                                                             this.el.background_color = new Clutter.Color.from_string("#333");
889                                                                 return false;
890                                                         },
891                                                         leave_event : (  event)  => {
892                                                             this.el.background_color = new Clutter.Color.from_string("#000");
893                                                             return false;
894                                                         },
895                                                         button_press_event : ( ) => {
896                                                             switch (_this.state) {
897                                                                 case "edit":
898                                                                 
899                                                                     _this.hideViewEditing();
900                                                                     break;  
901                                                                 case "files":
902                                                                     _this.showViewEditing();
903                                                                     break; 
904                                                                     
905                                                                   case "addprop":
906                                                                     _this.hideAddProp();
907                                                                     _this.hideViewEditing();
908                                                                     break;
909                                                                 case "addlistener":
910                                                                     _this.hideAddListener();
911                                                                     _this.hideViewEditing();
912                                                                     break;
913                                                                      
914                                                                  case "object":
915                                                                     _this.hideObject();
916                                                                     _this.hideViewEditing();
917                                                                     break;    
918                                                                     
919                                                                 default:
920                                                                     break;
921                                                             }
922                                                             return false;    
923                                                         
924                                                         }
925                                                     },
926                                                     id : "projectbutton",
927                                                     pack : "add_child",
928                                                     init : this.el.set_size(50,50);,
929                                                     reactive : true,
930                                                     items : [
931                                                         {
932                                                             xtype: Clutter.Text,
933                                                             pack : "add_child",
934                                                             line_alignment : Pango.Alignment.CENTER,
935                                                             x_align : Clutter.ActorAlign.CENTER,
936                                                             x_expand : false,
937                                                             y_align : Clutter.ActorAlign.CENTER,
938                                                             y_expand : false
939                                                         }
940                                                     ]
941                                                 },
942                                                 {
943                                                     xtype: Clutter.Actor,
944                                                     listeners : {
945                                                         enter_event : (  event)  => {
946                                                             this.el.background_color = new Clutter.Color.from_string("#333");
947                                                                 return false;
948                                                         },
949                                                         leave_event : (  event)  => {
950                                                             this.el.background_color = new Clutter.Color.from_string("#000");
951                                                             return false;
952                                                         },
953                                                         button_press_event : ( ) => {
954                                                             switch (_this.state) {
955                                                                 case "edit":
956                                                                     _this.showProjectEdit();
957                                                                     break;  
958                                                                 case "files":
959                                                                     // _this.showViewEditing();
960                                                                     break; 
961                                                                 case "projectedit":
962                                                                     _this.hideProjectEdit();
963                                                                     break;
964                                                                     
965                                                                     
966                                                                       
967                                                                 case "addprop":
968                                                                     _this.hideAddProp();
969                                                                     _this.showProjectEdit();
970                                                                     break;
971                                                                 case "addlistener":
972                                                                     _this.hideAddListener();
973                                                                     _this.showProjectEdit();
974                                                                     break;
975                                                                      
976                                                                  case "object":
977                                                                     _this.hideObject();
978                                                                     _this.showProjectEdit();    
979                                                                     break;
980                                                                 default:
981                                                                     break;
982                                                             }
983                                                             return false;    
984                                                         
985                                                         
986                                                         }
987                                                     },
988                                                     id : "projecteditbutton",
989                                                     pack : "add_child",
990                                                     init : this.el.set_size(50,50);,
991                                                     reactive : true,
992                                                     items : [
993                                                         {
994                                                             xtype: Clutter.Text,
995                                                             line_alignment : Pango.Alignment.CENTER,
996                                                             pack : "add_child",
997                                                             x_align : Clutter.ActorAlign.CENTER,
998                                                             x_expand : false,
999                                                             y_align : Clutter.ActorAlign.CENTER,
1000                                                             y_expand : false
1001                                                         }
1002                                                     ]
1003                                                 },
1004                                                 {
1005                                                     xtype: Clutter.Actor,
1006                                                     listeners : {
1007                                                         enter_event : (  event)  => {
1008                                                             this.el.background_color = new Clutter.Color.from_string("#333");
1009                                                                 return false;
1010                                                         },
1011                                                         leave_event : (  event)  => {
1012                                                             this.el.background_color = new Clutter.Color.from_string("#000");
1013                                                             return false;
1014                                                         },
1015                                                         button_press_event : ( ) => {
1016                                                             
1017                                                             
1018                                                             
1019                                                             switch (_this.state) {
1020                                                         
1021                                                          
1022                                                                 case "addprop":
1023                                                                     _this.hideAddProp();
1024                                                                     _this.showObject();
1025                                                                     break;
1026                                                             case "addlistener":
1027                                                                     _this.hideAddListener();
1028                                                                     _this.showObject();
1029                                                                     break;
1030                                                         
1031                                                         // show            
1032                                                                 case "edit":
1033                                                                     _this.showObject();
1034                                                                     break;
1035                                                                     
1036                                                         // hide            
1037                                                                 case "object":
1038                                                                     _this.hideObject();
1039                                                                     break;
1040                                                                     break;
1041                                                                                 
1042                                                                 default:
1043                                                                     print("unhandled add objects from %s\n",_this.state);
1044                                                                     break;
1045                                                             }
1046                                                             return false;    
1047                                                         
1048                                                         
1049                                                         }
1050                                                     },
1051                                                     id : "objectshowbutton",
1052                                                     pack : "add_child",
1053                                                     init : this.el.set_size(50,50);,
1054                                                     reactive : true,
1055                                                     items : [
1056                                                         {
1057                                                             xtype: Clutter.Text,
1058                                                             pack : "add_child",
1059                                                             line_alignment : Pango.Alignment.CENTER,
1060                                                             x_align : Clutter.ActorAlign.CENTER,
1061                                                             x_expand : false,
1062                                                             y_align : Clutter.ActorAlign.CENTER,
1063                                                             y_expand : false
1064                                                         }
1065                                                     ]
1066                                                 },
1067                                                 {
1068                                                     xtype: Clutter.Actor,
1069                                                     listeners : {
1070                                                         enter_event : (  event)  => {
1071                                                             this.el.background_color = new Clutter.Color.from_string("#333");
1072                                                                 return false;
1073                                                         },
1074                                                         leave_event : (  event)  => {
1075                                                             this.el.background_color = new Clutter.Color.from_string("#000");
1076                                                             return false;
1077                                                         },
1078                                                         button_press_event : ( ) => {
1079                                                             
1080                                                             
1081                                                             
1082                                                             switch (_this.state) {
1083                                                                 case "edit":
1084                                                                     _this.showAddProp();
1085                                                                     break;
1086                                                                     
1087                                                                 case "object":
1088                                                                     _this.hideObject();
1089                                                                     _this.showAddProp();
1090                                                                     break;
1091                                                                
1092                                                                 case "addlistener":
1093                                                                     _this.hideAddListener();
1094                                                                     _this.showAddProp();            
1095                                                                     break;
1096                                                                     
1097                                                                     
1098                                                                 case "addprop":
1099                                                                     _this.hideAddProp();
1100                                                                     break;
1101                                                                     
1102                                                                 default:
1103                                                                     print("unhandled add property from %s\n",_this.state);
1104                                                                     break;
1105                                                                     
1106                                                             }
1107                                                             return false;    
1108                                                         
1109                                                         
1110                                                         }
1111                                                     },
1112                                                     id : "addpropbutton",
1113                                                     pack : "add_child",
1114                                                     init : this.el.set_size(50,50);,
1115                                                     reactive : true,
1116                                                     items : [
1117                                                         {
1118                                                             xtype: Clutter.Text,
1119                                                             pack : "add_child",
1120                                                             line_alignment : Pango.Alignment.CENTER,
1121                                                             x_align : Clutter.ActorAlign.CENTER,
1122                                                             x_expand : false,
1123                                                             y_align : Clutter.ActorAlign.CENTER,
1124                                                             y_expand : false
1125                                                         }
1126                                                     ]
1127                                                 },
1128                                                 {
1129                                                     xtype: Clutter.Actor,
1130                                                     listeners : {
1131                                                         enter_event : (  event)  => {
1132                                                             this.el.background_color = new Clutter.Color.from_string("#333");
1133                                                                 return false;
1134                                                         },
1135                                                         leave_event : (  event)  => {
1136                                                             this.el.background_color = new Clutter.Color.from_string("#000");
1137                                                             return false;
1138                                                         },
1139                                                         button_press_event : ( ) => {
1140                                                             
1141                                                             
1142                                                             
1143                                                             switch (_this.state) {
1144                                                                 case "edit":
1145                                                                     _this.showAddListener();
1146                                                                     break;
1147                                                                     
1148                                                                
1149                                                                 case "addlistener":
1150                                                                     _this.hideAddListener();
1151                                                                     break;
1152                                                         
1153                                                                     
1154                                                                 case "addprop":
1155                                                                     _this.hideAddProp();
1156                                                                     _this.showAddListener();
1157                                                                     break;
1158                                                                  case "object":
1159                                                                     _this.hideObject();
1160                                                                     _this.showAddListener();
1161                                                                     break;
1162                                                             
1163                                                                   default:
1164                                                                     print("unhandled add listener from %s\n",_this.state);
1165                                                         
1166                                                                     break;
1167                                                                     
1168                                                             }
1169                                                             return false;    
1170                                                         
1171                                                         
1172                                                         }
1173                                                     },
1174                                                     id : "addlistenerbutton",
1175                                                     pack : "add_child",
1176                                                     init : this.el.set_size(50,50);,
1177                                                     reactive : true,
1178                                                     items : [
1179                                                         {
1180                                                             xtype: Clutter.Text,
1181                                                             pack : "add_child",
1182                                                             line_alignment : Pango.Alignment.CENTER,
1183                                                             x_align : Clutter.ActorAlign.CENTER,
1184                                                             x_expand : false,
1185                                                             y_align : Clutter.ActorAlign.CENTER,
1186                                                             y_expand : false
1187                                                         }
1188                                                     ]
1189                                                 }
1190                                             ],
1191                                             layout_manager : {
1192                                                 xtype: Clutter.BoxLayout,
1193                                                 orientation : Clutter.Orientation.VERTICAL
1194                                             }
1195                                         }
1196                                     ]
1197                                 }
1198                             ]
1199                         }
1200                     ]
1201                 }
1202             ]
1203         }
1204     ]
1205 });
1206 MainWindow.init();
1207 XObject.cache['/MainWindow'] = MainWindow;