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