Fix #7959 - new project flow - use void func to callback after each step, tidy up...
[roobuilder] / src / Builder4 / PopoverFileDetails.vala
index 49b9736..7181e95 100644 (file)
             return _PopoverFileDetails;
         }
         public Xcls_grid grid;
-        public Xcls_dir_dropdown_lbl dir_dropdown_lbl;
-        public Xcls_dir_dropdown dir_dropdown;
-        public Xcls_dir_model dir_model;
         public Xcls_filetype_lbl filetype_lbl;
         public Xcls_filetype filetype;
         public Xcls_filetype_model filetype_model;
+        public Xcls_dir_dropdown_lbl dir_dropdown_lbl;
+        public Xcls_dir_dropdown dir_dropdown;
+        public Xcls_dir_model dir_model;
+        public Xcls_name_lbl name_lbl;
         public Xcls_name name;
         public Xcls_title_lbl title_lbl;
         public Xcls_title title;
@@ -40,6 +41,7 @@
         public Xcls_save_btn save_btn;
 
             // my vars (def)
+        public bool is_new;
         public bool new_window;
         public signal void success (Project.Project pr, JsRender.JsRender file);
         public JsRender.JsRender file;
@@ -55,6 +57,7 @@
             this.el = new Gtk.Window();
 
             // my vars (dec)
+            this.is_new = true;
             this.new_window = true;
             this.file = null;
             this.border_width = 0;
@@ -78,7 +81,7 @@
         }
 
         // user defined functions
-        public void show (JsRender.JsRender c, Gtk.Window pwin, bool new_window) 
+        public void show (JsRender.JsRender  c, Gtk.Window pwin, bool new_window) 
         {
             
             this.project = c.project;
@@ -89,7 +92,7 @@
                 //this.init();
              //} 
              
-             
+              this.is_new = c.name == "";
         
             _this.name.el.set_text(c.name);
             _this.title.el.set_text(c.title);
          
            _this.gen.el.active = c.gen_extended;
            
-               _this.path_lbl.el.show();
-            _this.path.el.show();
-            _this.dir_dropdown_lbl.el.hide();
-            _this.dir_dropdown.el.hide();
-            if (c.name == "") {
-               _this.path_lbl.el.hide();
-                   _this.path.el.hide();
-                   this.filetype_model.load();
-                _this.dir_dropdown_lbl.el.show();
-                   _this.dir_dropdown.el.show();
-                   
-            }   else {
-                _this.path.el.set_text(c.relpath);
-            }
-            
+        
             
             if (this.project.xtype == "Gtk") {
                var p = (Project.Gtk) this.project;
                    this.build_module_model.load(p.compilegroups);
                    // it will select first if available...
                    // only for new files.
-                   if (c.name != "") {
+                   if (!this.is_new) {
                            this.build_module.setValue(c.build_module);
                    }
             }
             this.el.set_transient_for(pwin);
             
             // window + header?
-             print("SHOWALL - POPIP\n");
+             
             this.el.show();
-            this.name.el.grab_focus();
+           // this.name.el.grab_focus();
             
-            _this.project.loadDirsToStringList(this.dir_model.el);
             
-            if (c.path.length > 0) {
+            if (!this.is_new) {
                    this.save_btn.el.set_label("Save");
-                       _this.filetype_lbl.el.hide();
-                       _this.filetype.el.hide();
-                       _this.filetype.showhide(); // as we only work on bjs files currently
+                       this.filetype_lbl.el.hide();
+                       this.filetype.el.hide();
+                       this.filetype.showhide(); // as we only work on bjs files currently
             } else {
+            
+                       //_this.project.loadDirsToStringList(this.dir_model.el, "");
+                       //_this.dir_dropdown.el.selected = Gtk.INVALID_LIST_POSITION;
+            
                 this.save_btn.el.set_label("Create");
-                   _this.filetype.el.show();
-                   _this.filetype_lbl.el.show();
-                   _this.filetype.showhide();
+                   this.filetype.el.show();
+                   this.filetype_lbl.el.show();
+                   this.filetype_model.load();
+                       this.filetype.el.selected = Gtk.INVALID_LIST_POSITION;
+                   this.filetype.showhide();
+                   
             }
             
             
                 this.el.hexpand = true;
                 this.el.margin_bottom = 4;
                 this.el.margin_top = 4;
-                var child_1 = new Xcls_grid( _this );
-                this.el.append ( child_1.el  );
+                new Xcls_grid( _this );
+                this.el.append ( _this.grid.el  );
             }
 
             // user defined functions
                 this.el.hexpand = true;
                 this.el.column_spacing = 4;
                 this.el.row_spacing = 2;
-                var child_1 = new Xcls_dir_dropdown_lbl( _this );
-                this.el.attach( child_1.el, 0, 0, 1, 1 );
-                var child_2 = new Xcls_dir_dropdown( _this );
-                this.el.attach( child_2.el, 1, 0, 1, 1 );
-                var child_3 = new Xcls_filetype_lbl( _this );
-                this.el.attach( child_3.el, 0, 1, 1, 1 );
-                var child_4 = new Xcls_filetype( _this );
-                this.el.attach( child_4.el, 1, 1, 1, 1 );
-                var child_5 = new Xcls_Label10( _this );
-                child_5.ref();
-                this.el.attach( child_5.el, 0, 2, 1, 1 );
-                var child_6 = new Xcls_name( _this );
-                this.el.attach( child_6.el, 1, 2, 1, 1 );
-                var child_7 = new Xcls_title_lbl( _this );
-                this.el.attach( child_7.el, 0, 3, 1, 1 );
-                var child_8 = new Xcls_title( _this );
-                this.el.attach ( child_8.el , 1,2,1,1 );
-                var child_9 = new Xcls_region_lbl( _this );
-                this.el.attach( child_9.el, 0, 4, 1, 1 );
-                var child_10 = new Xcls_region( _this );
-                this.el.attach( child_10.el, 1, 4, 1, 1 );
-                var child_11 = new Xcls_parent_lbl( _this );
-                this.el.attach( child_11.el, 0, 5, 1, 1 );
-                var child_12 = new Xcls_parent( _this );
-                this.el.attach( child_12.el, 1, 5, 1, 1 );
-                var child_13 = new Xcls_permname_lbl( _this );
-                this.el.attach( child_13.el, 0, 6, 1, 1 );
-                var child_14 = new Xcls_permname( _this );
-                this.el.attach( child_14.el, 1, 6, 1, 1 );
-                var child_15 = new Xcls_modOrder_lbl( _this );
-                this.el.attach( child_15.el, 0, 7, 1, 1 );
-                var child_16 = new Xcls_modOrder( _this );
-                this.el.attach( child_16.el, 1, 7, 1, 1 );
-                var child_17 = new Xcls_build_module_lbl( _this );
-                this.el.attach( child_17.el, 0, 8, 1, 1 );
-                var child_18 = new Xcls_build_module( _this );
-                this.el.attach( child_18.el, 1, 8, 1, 1 );
-                var child_19 = new Xcls_path_lbl( _this );
-                this.el.attach( child_19.el, 0, 9, 1, 1 );
-                var child_20 = new Xcls_path( _this );
-                this.el.attach( child_20.el, 1, 9, 1, 1 );
-                var child_21 = new Xcls_gen_lbl( _this );
-                this.el.attach( child_21.el, 0, 10, 1, 1 );
-                var child_22 = new Xcls_gen( _this );
-                this.el.attach( child_22.el, 1, 10, 1, 1 );
+                new Xcls_filetype_lbl( _this );
+                this.el.attach( _this.filetype_lbl.el, 0, 0, 1, 1 );
+                new Xcls_filetype( _this );
+                this.el.attach( _this.filetype.el, 1, 0, 1, 1 );
+                new Xcls_dir_dropdown_lbl( _this );
+                this.el.attach( _this.dir_dropdown_lbl.el, 0, 1, 1, 1 );
+                new Xcls_dir_dropdown( _this );
+                this.el.attach( _this.dir_dropdown.el, 1, 1, 1, 1 );
+                new Xcls_name_lbl( _this );
+                this.el.attach( _this.name_lbl.el, 0, 2, 1, 1 );
+                new Xcls_name( _this );
+                this.el.attach( _this.name.el, 1, 2, 1, 1 );
+                new Xcls_title_lbl( _this );
+                this.el.attach( _this.title_lbl.el, 0, 3, 1, 1 );
+                new Xcls_title( _this );
+                this.el.attach ( _this.title.el , 1,2,1,1 );
+                new Xcls_region_lbl( _this );
+                this.el.attach( _this.region_lbl.el, 0, 4, 1, 1 );
+                new Xcls_region( _this );
+                this.el.attach( _this.region.el, 1, 4, 1, 1 );
+                new Xcls_parent_lbl( _this );
+                this.el.attach( _this.parent_lbl.el, 0, 5, 1, 1 );
+                new Xcls_parent( _this );
+                this.el.attach( _this.parent.el, 1, 5, 1, 1 );
+                new Xcls_permname_lbl( _this );
+                this.el.attach( _this.permname_lbl.el, 0, 6, 1, 1 );
+                new Xcls_permname( _this );
+                this.el.attach( _this.permname.el, 1, 6, 1, 1 );
+                new Xcls_modOrder_lbl( _this );
+                this.el.attach( _this.modOrder_lbl.el, 0, 7, 1, 1 );
+                new Xcls_modOrder( _this );
+                this.el.attach( _this.modOrder.el, 1, 7, 1, 1 );
+                new Xcls_build_module_lbl( _this );
+                this.el.attach( _this.build_module_lbl.el, 0, 8, 1, 1 );
+                new Xcls_build_module( _this );
+                this.el.attach( _this.build_module.el, 1, 8, 1, 1 );
+                new Xcls_path_lbl( _this );
+                this.el.attach( _this.path_lbl.el, 0, 9, 1, 1 );
+                new Xcls_path( _this );
+                this.el.attach( _this.path.el, 1, 9, 1, 1 );
+                new Xcls_gen_lbl( _this );
+                this.el.attach( _this.gen_lbl.el, 0, 10, 1, 1 );
+                new Xcls_gen( _this );
+                this.el.attach( _this.gen.el, 1, 10, 1, 1 );
             }
 
             // user defined functions
-            public void showAllRows () {
-               for (var i = 2; i < 10;i++) {
-                       var el = _this.grid.el.get_child_at(0,i);
-                       el.show();
-                       el = _this.grid.el.get_child_at(1,i);
-                       el.show();
-                }
-            }
-            public void hideRow (int row) 
+            public void xhideRow (int row) 
             {
                var el = _this.grid.el.get_child_at(0,row);
             
                el.hide();
             
             }
-        }
-        public class Xcls_dir_dropdown_lbl : Object
-        {
-            public Gtk.Label el;
-            private Xcls_PopoverFileDetails  _this;
-
-
-                // my vars (def)
-
-            // ctor
-            public Xcls_dir_dropdown_lbl(Xcls_PopoverFileDetails _owner )
-            {
-                _this = _owner;
-                _this.dir_dropdown_lbl = this;
-                this.el = new Gtk.Label( "Create File in this Directory" );
-
-                // my vars (dec)
-
-                // set gobject values
-                this.el.justify = Gtk.Justification.RIGHT;
-                this.el.xalign = 0.900000f;
-                this.el.visible = true;
-            }
-
-            // user defined functions
-        }
-
-        public class Xcls_dir_dropdown : Object
-        {
-            public Gtk.DropDown el;
-            private Xcls_PopoverFileDetails  _this;
-
-
-                // my vars (def)
-            public int colspan;
-
-            // ctor
-            public Xcls_dir_dropdown(Xcls_PopoverFileDetails _owner )
-            {
-                _this = _owner;
-                _this.dir_dropdown = this;
-                var child_1 = new Xcls_dir_model( _this );
-                this.el = new Gtk.DropDown( child_1.el, null );
-
-                // my vars (dec)
-                this.colspan = 1;
-
-                // set gobject values
-            }
-
-            // user defined functions
-            public string getValue () {
-               return _this.dir_model.el.get_string(this.el.selected);
-            }
-        }
-        public class Xcls_dir_model : Object
-        {
-            public Gtk.StringList el;
-            private Xcls_PopoverFileDetails  _this;
-
-
-                // my vars (def)
-
-            // ctor
-            public Xcls_dir_model(Xcls_PopoverFileDetails _owner )
-            {
-                _this = _owner;
-                _this.dir_model = this;
-                this.el = new Gtk.StringList( {} );
-
-                // my vars (dec)
-
-                // set gobject values
+            public void xshowAllRows () {
+               for (var i = 2; i < 10;i++) {
+                       var el = _this.grid.el.get_child_at(0,i);
+                       el.show();
+                       el = _this.grid.el.get_child_at(1,i);
+                       el.show();
+                }
             }
-
-            // user defined functions
         }
-
-
         public class Xcls_filetype_lbl : Object
         {
             public Gtk.Label el;
             {
                 _this = _owner;
                 _this.filetype = this;
-                var child_1 = new Xcls_filetype_model( _this );
-                this.el = new Gtk.DropDown( child_1.el, null );
+                new Xcls_filetype_model( _this );
+                this.el = new Gtk.DropDown( _this.filetype_model.el, null );
 
                 // my vars (dec)
 
 
             // user defined functions
             public string getValue () {
+               
+               if (!_this.is_new) {
+                       return _this.file.xtype != "Plainfile" ? "bjs" :  _this.file.file_ext;
+               }
+               
                if (this.el.selected == Gtk.INVALID_LIST_POSITION) {
                        return "";
                }
                return _this.filetype_model.el.get_string(this.el.selected).split(" ")[0];
             }
             public void showhide ()   {
+                
             
-            
-               
+               _this.path_lbl.el.hide();
+                _this.path.el.hide();
+                
+                
+                _this.name_lbl.el.hide();
+                _this.name.el.hide();
+                
+                _this.dir_dropdown_lbl.el.hide();
+                _this.dir_dropdown.el.hide();
                
                _this.title_lbl.el.hide();
                _this.title.el.hide();
                
                _this.gen_lbl.el.hide();
                _this.gen.el.hide();
-             
+               
+              
                var sel = this.getValue();
+            
+               GLib.debug("showhide is new ? %s / sel = '%s'" , _this.is_new ? "YES" :"NO", sel); 
+               
+                if (_this.is_new) {
+                       if (sel == "" &&  _this.project.xtype == "Gtk") {
+                               return;
+                       }
+                        
+                 
+                    _this.dir_dropdown_lbl.el.show();
+                   _this.dir_dropdown.el.show();
+                   
+                    _this.name_lbl.el.show();
+                       _this.name.el.show();
+            
+                   
+                   
+                }   else {
+                    _this.path.el.set_text(_this.file.relpath);
+                }
+                
+               
+               
                
                switch(_this.project.xtype) {
                        case "Roo":
                                _this.build_module_lbl.el.show();
                                _this.build_module.el.show();
                
-                               _this.gen_lbl.el.show();
-                               _this.gen.el.show();
-                           
+                                
+                               
+                               if (sel == "bjs" || sel == "vala") {
+                                        _this.project.loadDirsToStringList(_this.dir_model.el, "/src");
+                                        _this.dir_dropdown.el.selected = Gtk.INVALID_LIST_POSITION;
+                               _this.name_lbl.el.label = "Component Name (Filename with-out extension)";                                
+                               
+                               if (sel == "bjs") {
+                                       _this.gen_lbl.el.show();
+                                       _this.gen.el.show();
+                               }
+                               
+                               
+                               
+                               } else {
+                               _this.project.loadDirsToStringList(_this.dir_model.el, "");
+                               _this.dir_dropdown.el.selected = Gtk.INVALID_LIST_POSITION;
+                               _this.name_lbl.el.label = "File Name (with extension)";
+                       }
                                break;
                }
              
         }
 
 
-        public class Xcls_Label10 : Object
+        public class Xcls_dir_dropdown_lbl : Object
+        {
+            public Gtk.Label el;
+            private Xcls_PopoverFileDetails  _this;
+
+
+                // my vars (def)
+
+            // ctor
+            public Xcls_dir_dropdown_lbl(Xcls_PopoverFileDetails _owner )
+            {
+                _this = _owner;
+                _this.dir_dropdown_lbl = this;
+                this.el = new Gtk.Label( "Create File in this Directory" );
+
+                // my vars (dec)
+
+                // set gobject values
+                this.el.justify = Gtk.Justification.RIGHT;
+                this.el.xalign = 0.900000f;
+                this.el.visible = true;
+            }
+
+            // user defined functions
+        }
+
+        public class Xcls_dir_dropdown : Object
+        {
+            public Gtk.DropDown el;
+            private Xcls_PopoverFileDetails  _this;
+
+
+                // my vars (def)
+            public int colspan;
+
+            // ctor
+            public Xcls_dir_dropdown(Xcls_PopoverFileDetails _owner )
+            {
+                _this = _owner;
+                _this.dir_dropdown = this;
+                new Xcls_dir_model( _this );
+                this.el = new Gtk.DropDown( _this.dir_model.el, null );
+
+                // my vars (dec)
+                this.colspan = 1;
+
+                // set gobject values
+            }
+
+            // user defined functions
+            public string getValue () {
+               return _this.dir_model.el.get_string(this.el.selected);
+            }
+        }
+        public class Xcls_dir_model : Object
+        {
+            public Gtk.StringList el;
+            private Xcls_PopoverFileDetails  _this;
+
+
+                // my vars (def)
+
+            // ctor
+            public Xcls_dir_model(Xcls_PopoverFileDetails _owner )
+            {
+                _this = _owner;
+                _this.dir_model = this;
+                this.el = new Gtk.StringList( {} );
+
+                // my vars (dec)
+
+                // set gobject values
+            }
+
+            // user defined functions
+        }
+
+
+        public class Xcls_name_lbl : Object
         {
             public Gtk.Label el;
             private Xcls_PopoverFileDetails  _this;
                 // my vars (def)
 
             // ctor
-            public Xcls_Label10(Xcls_PopoverFileDetails _owner )
+            public Xcls_name_lbl(Xcls_PopoverFileDetails _owner )
             {
                 _this = _owner;
+                _this.name_lbl = this;
                 this.el = new Gtk.Label( "Component Name (File name without extension)" );
 
                 // my vars (dec)
             {
                 _this = _owner;
                 _this.build_module = this;
-                var child_1 = new Xcls_build_module_model( _this );
-                this.el = new Gtk.DropDown( child_1.el, null );
+                new Xcls_build_module_model( _this );
+                this.el = new Gtk.DropDown( _this.build_module_model.el, null );
 
                 // my vars (dec)
 
             {
                 _this = _owner;
                 _this.gen_lbl = this;
-                this.el = new Gtk.Label( "Generate as Extended (experimental)" );
+                this.el = new Gtk.Label( "Generate as Extended (no working)" );
 
                 // my vars (dec)
                 this.colspan = 1;
                 var child_1 = new Xcls_Button30( _this );
                 child_1.ref();
                 this.el.pack_start ( child_1.el  );
-                var child_2 = new Xcls_save_btn( _this );
-                this.el.pack_end ( child_2.el  );
+                new Xcls_save_btn( _this );
+                this.el.pack_end ( _this.save_btn.el  );
             }
 
             // user defined functions