src/Builder4/WindowState.vala
[app.Builder.js] / src / Builder4 / WindowState.vala
index 2e76de2..bb2c15b 100644 (file)
@@ -18,15 +18,15 @@ public class WindowState : Object
                CODE,
                CODEONLY,
                FILES,
-               PROJECT // project settings..
+               PROJECT, // project settings..
+               FILEPROJECT // project when in file mode
        }
 
        public State state = State.NONE;
 
        public bool children_loaded = false;
 
-       
-       
+        
        public Project.Project project;
        public JsRender.JsRender file;
        
@@ -94,7 +94,11 @@ public class WindowState : Object
                this.children_loaded = true;
                
                this.left_tree.node_selected.connect((sel) => {
-                       this.window_gladeview.sourceview.nodeSelected(sel);
+                       if (this.file.xtype == "Roo") { 
+                               this.window_rooview.sourceview.nodeSelected(sel);                       
+                       } else {
+                               this.window_gladeview.sourceview.nodeSelected(sel);
+                       }
                });
                this.valasource = new Palete.ValaSource();
                this.valasource.compiled.connect(this.valaCompiled);
@@ -102,6 +106,10 @@ public class WindowState : Object
                this.compile_results = new  Xcls_ValaCompileResults();
                this.compile_results.window = this.win;
                this.valasource.compile_output.connect(this.compile_results.addLine);
+               
+               this.win.statusbar_compilestatus_label.el.hide();
+               this.win.statusbar_run.el.hide();
+               this.win.search_results.el.hide();
        }
 
 
@@ -454,7 +462,7 @@ public class WindowState : Object
                        this.switchState (State.PREVIEW); 
                        // this triggers loadItems..
                        this.left_tree.model.loadFile(file);
-                       if (file.project.xtype == "Gtk" ) {
+                       if (file.project.xtype == "Gtk" && line> -1 ) {
                                this.window_gladeview.scroll_to_line(line);
                        }
 
@@ -501,6 +509,7 @@ public class WindowState : Object
        public void webkitViewInit()
        {
                this.window_rooview  =new Xcls_WindowRooView();
+               this.window_rooview.main_window = this.win;
                this.window_rooview.ref();
                ((Gtk.Container)(this.win.rooview.el.get_widget())).add(this.window_rooview.el);
                this.window_rooview.el.show_all();
@@ -596,7 +605,8 @@ public class WindowState : Object
                                this.win.objectview.el.set_scale(0.0f,0.0f);
                                 break;
 
-                  case State.PROJECT:
+                       case State.FILEPROJECT:
+                       case State.PROJECT:
                                if (this.win.project.xtype == "Gtk") {
                                        this.vala_projectsettings.save();
                                } 
@@ -748,21 +758,36 @@ public class WindowState : Object
                                this.win.rooview.el.set_pivot_point(1.0f,0.5f);
                                break;
 
-                  case State.PROJECT:
 
-                          if (this.win.project.xtype == "Roo") {
+
+
+                       case State.PROJECT:
+                               this.win.rooview.el.set_pivot_point(1.0f,1.0f); // bottom right..
+                               
+                               if (this.win.project.xtype == "Roo") {
                                        this.projectsettings.el.show_all();
                                        this.projectsettings.show(this.win.project);
                                } else {
                                        this.vala_projectsettings.el.show_all();
                                        this.vala_projectsettings.show((Project.Gtk)this.win.project);
                                }
-
-                               this.win.rooview.el.set_pivot_point(1.0f,1.0f); // bottom right..
-                               
                                this.win.projecteditview.el.set_scale(1.0f,1.0f);
+                                
+                               break;
                                
-                          
+                       case State.FILEPROJECT:
+                               var pr = this.left_projects.getSelectedProject();
+                               if (pr.xtype == "Roo") {
+                                       this.projectsettings.el.show_all();
+                                       this.projectsettings.show(this.win.project);
+                               } else {
+                                       this.vala_projectsettings.el.show_all();
+                                       this.vala_projectsettings.show((Project.Gtk)this.win.project);
+                               }
+                               this.win.projecteditview.el.set_scale(1.0f,1.0f);
+                                
                                break;
                                
                   case State.FILES:  // can only get here from PREVIEW (or code-only) state.. in theory..
@@ -803,7 +828,10 @@ public class WindowState : Object
                this.easingRestoreAll();
                
                // run the animation.. - then load files...
-               
+               GLib.Timeout.add(500,  ()  =>{
+                        this.resizeCanvasElements();
+                        return false;
+               });
                        
        }
        
@@ -923,9 +951,13 @@ public class WindowState : Object
        {
                // basically hide everything, then show the relivant..
 
-                this.win.backbutton.el.hide();
-       
-               this.win.projectbutton.el.hide(); // show file nav...
+               // top bar btns
+               this.win.openbtn.el.hide();
+               this.win.openbackbtn.el.hide();
+               
+               this.win.backbutton.el.hide();
+               
+
                this.win.editfilebutton.el.hide();
                this.win.projecteditbutton.el.hide();
                 
@@ -939,27 +971,42 @@ public class WindowState : Object
                this.win.addprojectbutton.el.hide();
                this.win.addfilebutton.el.hide();
                this.win.delprojectbutton.el.hide();
-                 
                
+               this.win.search_entry.el.hide();
+               this.win.search_results.el.hide();
                switch (this.state) {
                        
                        case State.PREVIEW:  // this is the default state when working...
                           
-                               this.win.projectbutton.el.show(); // show file nav...
+                               
                                this.win.editfilebutton.el.show();
                                this.win.projecteditbutton.el.show();
                                 
+                                
                                
                                this.win.objectshowbutton.el.show(); // add objects
                                this.win.addpropbutton.el.show();  
                                this.win.addlistenerbutton.el.show(); 
+                               this.win.search_entry.el.show();
+                               
+                               this.win.openbtn.el.show();
+                               
                                break;
                        
                        case State.CODEONLY: 
-                               this.win.projectbutton.el.show();
+                               this.win.openbtn.el.show();
+       
+                               this.win.search_entry.el.show();
                                break;
                   
                        case State.CODE: 
+                               this.win.search_entry.el.show();
+                               this.win.backbutton.el.show();
+                               this.win.objectshowbutton.el.show(); // add objects ?? can you do this from here?
+                               this.win.addpropbutton.el.show();  
+                               this.win.addlistenerbutton.el.show(); 
+                               break;
+                               // continue thru..
                        case State.PROP:
                        case State.LISTENER:
                        case State.OBJECT:
@@ -973,20 +1020,28 @@ public class WindowState : Object
                        case State.PROJECT: 
                                // anything else?
                                this.win.backbutton.el.show();
+                               
                                break;
                        
        
                        case State.FILES:
                                if (this.left_projects.getSelectedProject() != null ) {
                                        if (this.left_tree.getActiveFile() != null) {
-                                               this.win.backbutton.el.show();
+                                        
+                                               this.win.openbackbtn.el.show();
                                        }
                                        this.win.addfilebutton.el.show();
-                               }
+                                       this.win.search_entry.el.show();
+                                       this.win.projecteditbutton.el.show(); 
+                               } 
+                               
                                         
                                this.win.addprojectbutton.el.show();
                                this.win.delprojectbutton.el.show();
                                
+                               
+                               
+                               
                                break;
                }
                
@@ -1002,8 +1057,12 @@ public class WindowState : Object
                        
                        var buf = this.code_editor.buffer;
                        buf.check_running = false;
+                       var has_errors = false;
                                      
                        if (obj.has_member("ERR-TOTAL")) {
+                               if (obj.get_int_member("ERR-TOTAL")> 0) {
+                                       has_errors = true;
+                               }
                                 this.win.statusbar_errors.setNotices( obj.get_object_member("ERR") , (int) obj.get_int_member("ERR-TOTAL"));
                        } else {
                                 this.win.statusbar_errors.setNotices( new Json.Object() , 0);
@@ -1028,7 +1087,14 @@ public class WindowState : Object
                        buf.highlightErrorsJson("WARN", obj);
                        buf.highlightErrorsJson("DEPR", obj);
                        
+                       this.win.statusbar_compilestatus_label.el.hide();
+                       this.win.statusbar_run.el.hide();
+                       
                        if (this.file.xtype == "Gtk") {
+                               this.win.statusbar_compilestatus_label.el.show();
+                               if (!has_errors) { 
+                                       this.win.statusbar_run.el.show();
+                               }
                                var gbuf =   this.window_gladeview.sourceview;
                                gbuf.highlightErrorsJson("ERR", obj);
                                gbuf.highlightErrorsJson("WARN", obj);