revamp the new file dialog - show hide setting in correct config - mostly
authorAlan <alan@roojs.com>
Thu, 4 Jan 2024 12:03:29 +0000 (20:03 +0800)
committerAlan <alan@roojs.com>
Thu, 4 Jan 2024 12:03:29 +0000 (20:03 +0800)
src/Builder4/PopoverFileDetails.bjs
src/Builder4/PopoverFileDetails.vala

index a698a48..6206dbf 100644 (file)
@@ -48,6 +48,7 @@
         {
          "$ xns" : "Gtk",
          "bool hexpand" : true,
+         "bool in_showhide" : false,
          "id" : "filetype",
          "items" : [
           {
           "notify[\"selected\"]" : [
            "() => {",
            "",
-           " ",
-           "  ",
-           "    // directory is only available for non-bjs ",
-           "    this.showhide( );",
+           " \t_this.onFileTypeChange();",
            "",
            " }"
           ]
           "\t\t}",
           "\t}",
           "}"
-         ],
-         "| void showhide" : [
-          "()   {",
-          "\t ",
-          "",
-          "\t_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();",
-          "\t",
-          "\t_this.title_lbl.el.hide();",
-          "\t_this.title.el.hide();",
-          "\t",
-          "\t_this.region_lbl.el.hide();",
-          "\t_this.region.el.hide();",
-          "\t",
-          "\t_this.parent_lbl.el.hide();",
-          "\t_this.parent.el.hide();",
-          "\t",
-          "\t_this.permname_lbl.el.hide();",
-          "\t_this.permname.el.hide();",
-          "\t",
-          "\t_this.modOrder_lbl.el.hide();",
-          "\t_this.modOrder.el.hide();",
-          "\t",
-          "\t_this.build_module_lbl.el.hide();",
-          "\t_this.build_module.el.hide();",
-          "\t",
-          "\t_this.gen_lbl.el.hide();",
-          "\t_this.gen.el.hide();",
-          "\t",
-          "  ",
-          "\tvar sel = this.getValue();",
-          "",
-          "\tGLib.debug(\"showhide is new ? %s / sel = '%s'\" , _this.is_new ? \"YES\" :\"NO\", sel); ",
-          "\t",
-          "    if (_this.is_new) {",
-          "\t\tif (sel == \"\" &&  _this.project.xtype == \"Gtk\") {",
-          "\t\t\treturn;",
-          "\t\t}",
-          "\t\t ",
-          "\t  ",
-          "        _this.dir_dropdown_lbl.el.show();",
-          "\t    _this.dir_dropdown.el.show();",
-          "\t    ",
-          "        _this.name_lbl.el.show();",
-          "    \t_this.name.el.show();",
-          "",
-          "\t    ",
-          "\t    ",
-          "    }   else {",
-          "        _this.path.el.set_text(_this.file.relpath);",
-          "    }",
-          "    ",
-          "\t",
-          "\t",
-          "\t",
-          "\tswitch(_this.project.xtype) {",
-          "\t\tcase \"Roo\":",
-          "\t\t \t",
-          "\t\t\tif (sel == \"bjs\") {",
-          "\t\t\t\t_this.title_lbl.el.show();",
-          "\t\t\t\t_this.title.el.show();",
-          "\t\t\t\t",
-          "\t\t\t\t_this.region_lbl.el.show();",
-          "\t\t\t\t_this.region.el.show();",
-          "\t\t\t\t",
-          "\t\t\t\t_this.parent_lbl.el.show();",
-          "\t\t\t\t_this.parent.el.show();",
-          "\t\t\t\t",
-          "\t\t\t\t_this.permname_lbl.el.show();",
-          "\t\t\t\t_this.permname.el.show();",
-          "\t\t\t\t",
-          "\t\t\t\t_this.modOrder_lbl.el.show();",
-          "\t\t\t\t_this.modOrder.el.show();",
-          "\t\t\t",
-          "\t\t\t}",
-          "\t\t\t_this.build_module_model.load(null);",
-          "\t\t ",
-          "\t\t\t",
-          "\t\t\tbreak;",
-          "\t\tdefault: // vala..",
-          "\t\t",
-          "\t \t\t_this.build_module_lbl.el.show();",
-          "\t\t\t_this.build_module.el.show();",
-          "\t",
-          "\t\t\t ",
-          "\t\t\t",
-          "\t\t\tif (sel == \"bjs\" || sel == \"vala\") {",
-          "\t\t\t\t _this.project.loadDirsToStringList(_this.dir_model.el, \"/src\");",
-          "\t\t\t\t _this.dir_dropdown.el.selected = Gtk.INVALID_LIST_POSITION;",
-          "\t\t        _this.name_lbl.el.label = \"Component Name (Filename with-out extension)\";\t\t\t\t ",
-          "\t\t        ",
-          "\t\t        if (sel == \"bjs\") {",
-          "\t\t\t        _this.gen_lbl.el.show();",
-          "\t\t\t        _this.gen.el.show();",
-          "\t\t        }",
-          "\t\t        ",
-          "\t\t        ",
-          "\t\t        ",
-          "\t\t\t} else {",
-          "\t\t        _this.project.loadDirsToStringList(_this.dir_model.el, \"\");",
-          "\t\t        _this.dir_dropdown.el.selected = Gtk.INVALID_LIST_POSITION;",
-          "\t\t        _this.name_lbl.el.label = \"File Name (with extension)\";",
-          "\t        }",
-          "\t\t\tbreak;",
-          "\t}",
-          " ",
-          "    // load up the directories",
-          "    //??? why can we not create bjs files in other directories??",
-          "\t//if (!is_bjs && _this.file.path.length < 1) {",
-          "\t",
-          " ",
-          "\t\t",
-          "\t\t",
-          "\t//}",
-          "   ",
-          "    ",
-          "}",
-          ""
          ]
         },
         {
            "xtype" : "StringList"
           }
          ],
+         "listeners" : {
+          "notify[\"selected\"]" : [
+           "() => {",
+           "",
+           "\t _this.onDirChanged();",
+           "\t",
+           "\t",
+           "\t",
+           " } "
+          ]
+         },
          "xtype" : "DropDown",
          "| string getValue" : [
           "() {",
           "\treturn _this.dir_model.el.get_string(this.el.selected);",
           "}"
+         ],
+         "| void setValue" : [
+          "(string cur) {",
+          "\tvar el  = _this.dir_model.el;",
+          "\tfor(var i= 0; i < el.get_n_items();i++)  {",
+          "\t\tif (el.get_string(i) == cur) {",
+          "\t\t\tthis.el.selected = i;",
+          "\t\t\tbreak;",
+          "\t\t}",
+          "\t}",
+          "}"
          ]
         },
         {
          "\t}",
          "\t// what does this do?",
          "\t",
-         "\tvar isNew = _this.file.name.length  > 0 ? false : true;",
+         " ",
          "\t/*",
          "\tif (!isNew && this.file.name != _this.name.el.get_text()) {",
          "\t    Xcls_StandardErrorDialog.singleton().show(",
          "\t//    this.file[i] =  this.get(i).el.get_text();",
          "\t//}",
          "",
-         "\tif (!isNew) {",
+         "\tif (!_this.is_new) {",
          "\t  //  try {",
          "\t  ",
          "\t  \tvar old_target = _this.file.build_module;",
          "\t    _this.file.save();",
          "\t    _this.el.hide();",
          "\t    return;",
-         "\t}",
+         "\t}  ",
          "\t",
          "\t// ---------------- NEW FILES...",
          "\tvar ftype = _this.filetype.getValue();",
          "\t_this.file.loaded = true;",
          "\t_this.file.save();",
          "     _this.file.project.addFile(_this.file);",
-         "\t\t ",
+         "     var sel = _this.filetype.getValue();",
+         "\t if (_this.file.project.xtype == \"Gtk\" && ",
+         "\t \t_this.file.build_module.length > 0 &&",
+         "\t \t( sel == \"bjs\" || sel == \"vala\")) {",
+         "\t ",
+         "\t\tvar pr = (Project.Gtk) _this.file.project;",
+         "\t\tif (pr.compilegroups.has_key(_this.file.build_module)) {",
+         "\t\t\tvar cg = pr.compilegroups.get(_this.file.build_module);",
+         "\t\t\tif (!cg.sources.contains(_this.file.relpath)) {",
+         "\t\t\t\tcg.sources.add(_this.file.relpath);",
+         "\t\t\t}",
+         "\t\t}",
+         "\t",
+         "\t}",
          "\t ",
          " ",
          "\t// what about .js ?",
    "string title" : "Add / Edit File",
    "uint border_width" : 0,
    "xtype" : "Window",
+   "| void hideAll" : [
+    "() {",
+    "",
+    "\t// exiting only",
+    "\tthis.path_lbl.el.hide();",
+    "    this.path.el.hide();",
+    "     ",
+    "    // new ",
+    "    this.name_lbl.el.hide();",
+    "    this.name.el.hide();",
+    "    //new ",
+    "    this.dir_dropdown_lbl.el.hide();",
+    "    this.dir_dropdown.el.hide();",
+    "\t// roo",
+    "\tthis.title_lbl.el.hide();",
+    "\tthis.title.el.hide();",
+    "\t",
+    "\tthis.region_lbl.el.hide();",
+    "\tthis.region.el.hide();",
+    "\t",
+    "\tthis.parent_lbl.el.hide();",
+    "\tthis.parent.el.hide();",
+    "\t",
+    "\tthis.permname_lbl.el.hide();",
+    "\tthis.permname.el.hide();",
+    "\t",
+    "\tthis.modOrder_lbl.el.hide();",
+    "\tthis.modOrder.el.hide();",
+    "\t",
+    "\tthis.build_module_lbl.el.hide();",
+    "\tthis.build_module.el.hide();",
+    "\t",
+    "\tthis.gen_lbl.el.hide();",
+    "\tthis.gen.el.hide();",
+    "\t\tthis.filetype_lbl.el.hide();",
+    "\t\tthis.filetype.el.hide();",
+    "}\t"
+   ],
+   "| void onDirChanged" : [
+    "() {",
+    "if (this.dir_dropdown.el.selected == Gtk.INVALID_LIST_POSITION) {",
+    "\t\tthis.build_module_lbl.el.hide();",
+    "\t\tthis.build_module.el.hide();",
+    "\t\tthis.name_lbl.el.hide();",
+    "\t\tthis.name.el.hide();",
+    "\t\t ",
+    "    \tthis.gen_lbl.el.hide();",
+    "\t\tthis.gen.el.hide();",
+    "    ",
+    "\t\treturn;",
+    "\t\t",
+    "\t",
+    "\t}",
+    "\t// directory selected",
+    "\tvar sel = this.filetype.getValue();",
+    "\t",
+    "\tif (this.file.project.xtype==\"Gtk\" && (sel == \"bjs\" || sel == \"vala\")) {",
+    "\t\tthis.build_module_lbl.el.show();",
+    "\t\tthis.build_module.el.show();",
+    "\t}",
+    "\tthis.name_lbl.el.show();",
+    "\tthis.name.el.show();",
+    "\t",
+    "\tif (sel == \"bjs\") {",
+    "        _this.gen_lbl.el.show();",
+    "        _this.gen.el.show();",
+    "    }",
+    "    ",
+    "    if (this.file.project.xtype == \"Roo\" && sel == \"bjs\") {",
+    "    \tthis.title_lbl.el.show();",
+    "\t\tthis.title.el.show();",
+    "\t\t",
+    "\t\tthis.region_lbl.el.show();",
+    "\t\tthis.region.el.show();",
+    "\t\t",
+    "\t\tthis.parent_lbl.el.show();",
+    "\t\tthis.parent.el.show();",
+    "\t\t",
+    "\t\tthis.permname_lbl.el.show();",
+    "\t\tthis.permname.el.show();",
+    "\t\t",
+    "\t\tthis.modOrder_lbl.el.show();",
+    "\t\tthis.modOrder.el.show();",
+    "\t}",
+    "    ",
+    "        ",
+    "}"
+   ],
+   "| void onFileTypeChange" : [
+    "() {",
+    "\tif (this.filetype.el.selected == Gtk.INVALID_LIST_POSITION) {",
+    "\t\tthis.dir_dropdown.el.hide();",
+    "\t\tthis.dir_dropdown_lbl.el.hide();",
+    "\t\tthis.build_module_lbl.el.hide();",
+    "\t\tthis.build_module.el.hide();",
+    "\t\tthis.name_lbl.el.hide();",
+    "\t\tthis.name.el.hide();",
+    "\t ",
+    "    \tthis.gen_lbl.el.hide();",
+    "\t\tthis.gen.el.hide();",
+    "    ",
+    "    ",
+    "    \tthis.title_lbl.el.hide();",
+    "\t\tthis.title.el.hide();",
+    "\t\t",
+    "\t\tthis.region_lbl.el.hide();",
+    "\t\tthis.region.el.hide();",
+    "\t\t",
+    "\t\tthis.parent_lbl.el.hide();",
+    "\t\tthis.parent.el.hide();",
+    "\t\t",
+    "\t\tthis.permname_lbl.el.hide();",
+    "\t\tthis.permname.el.hide();",
+    "\t\t",
+    "\t\tthis.modOrder_lbl.el.hide();",
+    "\t\tthis.modOrder.el.hide();",
+    " ",
+    "\t\treturn;",
+    "\t\t ",
+    "\t}",
+    "\t",
+    "\tthis.dir_dropdown.el.show();",
+    "\tthis.dir_dropdown_lbl.el.show();",
+    "\tvar sel = this.filetype.getValue();",
+    "\t",
+    "\tvar old_sel = _this.dir_dropdown.el.selected != Gtk.INVALID_LIST_POSITION;",
+    "\tvar olddir = this.dir_dropdown.getValue();",
+    "\tGLib.debug(\"old dir = %s\", olddir);",
+    "\tif (this.file.project.xtype==\"Gtk\" && (sel == \"bjs\" || sel == \"vala\")) {",
+    "\t\t_this.project.loadDirsToStringList(_this.dir_model.el, \"/src\");",
+    "\t\tif (old_sel && olddir.has_prefix(\"/src\")) {",
+    "\t\t \tthis.dir_dropdown.setValue(olddir);",
+    " \t\t} else {",
+    "\t \t     _this.dir_dropdown.el.selected = Gtk.INVALID_LIST_POSITION;",
+    " \t    }",
+    "         ",
+    "\t} else {",
+    "",
+    "        _this.project.loadDirsToStringList(_this.dir_model.el, \"\");",
+    "\t\tif (old_sel) {",
+    "\t\t\tthis.dir_dropdown.setValue(olddir);",
+    "\t\t} else {",
+    "\t\t     _this.dir_dropdown.el.selected = Gtk.INVALID_LIST_POSITION;",
+    "\t     }",
+    "       ",
+    "    }",
+    "",
+    " ",
+    "    // is this confusing?  - should we just strip out / add if necessary..",
+    "    if (sel == \"bjs\" || sel == \"vala\" || sel == \"js\" || sel == \"css\" || sel == \"php\") {",
+    "        _this.name_lbl.el.label = \"Component Name (Filename with-out extension)\";\t\t\t\t ",
+    "    } else {",
+    "\t    _this.name_lbl.el.label = \"File Name (with extension)\";",
+    "    }",
+    " ",
+    "}"
+   ],
    "| void show" : [
     "(JsRender.JsRender  c, Gtk.Window pwin, bool new_window) ",
     "{",
     "    this.el.set_transient_for(pwin);",
     "    ",
     "    // window + header?",
-    "     ",
+    "     this.hideAll();",
     "    this.el.show();",
     "   // this.name.el.grab_focus();",
     "    ",
     "    ",
     "    if (!this.is_new) {",
-    "\t    this.save_btn.el.set_label(\"Save\");",
-    "\t\tthis.filetype_lbl.el.hide();",
-    "\t\tthis.filetype.el.hide();",
-    "\t\tthis.filetype.showhide(); // as we only work on bjs files currently",
+    "\t   this.showEditFile();",
     "    } else {",
-    "    ",
-    "\t\t//_this.project.loadDirsToStringList(this.dir_model.el, \"\");",
-    "\t\t//_this.dir_dropdown.el.selected = Gtk.INVALID_LIST_POSITION;",
-    "    ",
-    "        this.save_btn.el.set_label(\"Create\");",
-    "\t    this.filetype.el.show();",
-    "\t    this.filetype_lbl.el.show();",
-    "\t    this.filetype_model.load();",
-    "\t\tthis.filetype.el.selected = Gtk.INVALID_LIST_POSITION;",
-    "\t    this.filetype.showhide();",
+    "    \tthis.showNewFile();",
+    "\t\t ",
+    "      ",
     "\t    ",
     "    }",
     "    ",
     "    ",
     "}"
    ],
+   "| void showEditFile" : [
+    "() {",
+    " \tthis.save_btn.el.set_label(\"Save\");",
+    "\tthis.filetype_lbl.el.hide();",
+    "\tthis.filetype.el.hide();",
+    "\t\t ",
+    "\tvar sel = this.filetype.getValue();",
+    "\tswitch(_this.project.xtype) {",
+    "\t\tcase \"Roo\":\t ",
+    "\t\t\t if (sel == \"bjs\") {",
+    "\t\t\t\t_this.title_lbl.el.show();",
+    "\t\t\t\t_this.title.el.show();",
+    "\t\t\t\t",
+    "\t\t\t\t_this.region_lbl.el.show();",
+    "\t\t\t\t_this.region.el.show();",
+    "\t\t\t\t",
+    "\t\t\t\t_this.parent_lbl.el.show();",
+    "\t\t\t\t_this.parent.el.show();",
+    "\t\t\t\t",
+    "\t\t\t\t_this.permname_lbl.el.show();",
+    "\t\t\t\t_this.permname.el.show();",
+    "\t\t\t\t",
+    "\t\t\t\t_this.modOrder_lbl.el.show();",
+    "\t\t\t\t_this.modOrder.el.show();",
+    "\t\t\t",
+    "\t\t\t}",
+    "\t\t\tbreak;",
+    "\t\tdefault:",
+    "\t\t\t_this.build_module_lbl.el.show();",
+    "\t\t\t_this.build_module.el.show();\t",
+    "\t\t\t",
+    "\t\t\tif (sel == \"bjs\") {",
+    "\t\t\t",
+    "\t\t\t\t _this.gen_lbl.el.show();",
+    "\t\t\t\t_this.gen.el.show();",
+    "\t\t\t}",
+    "\t\t\tbreak;",
+    "\t}",
+    "\tthis.path.el.show();",
+    "\tthis.path_lbl.el.show();",
+    "\tthis.path.el.set_text(_this.file.relpath);",
+    "}"
+   ],
+   "| void showNewFile" : [
+    "() {",
+    " \tthis.save_btn.el.set_label(\"Create\");",
+    " \tthis.hideAll();",
+    " \tthis.filetype.el.show();",
+    "    this.filetype_lbl.el.show();",
+    "    this.filetype_model.load();",
+    "\tthis.filetype.el.selected = Gtk.INVALID_LIST_POSITION;",
+    " ",
+    "\t    ",
+    "}"
+   ],
    "| void updateFileFromEntry" : [
     "() {",
     "",
     "        }",
     "        ",
     "        _this.file.build_module = _this.build_module.getValue();",
-    "        ",
+    "\t\t",
     "        ",
     "        ",
     "",
index 7181e95..01684da 100644 (file)
         }
 
         // user defined functions
+        public void onDirChanged () {
+        if (this.dir_dropdown.el.selected == Gtk.INVALID_LIST_POSITION) {
+                       this.build_module_lbl.el.hide();
+                       this.build_module.el.hide();
+                       this.name_lbl.el.hide();
+                       this.name.el.hide();
+                        
+               this.gen_lbl.el.hide();
+                       this.gen.el.hide();
+            
+                       return;
+                       
+               
+               }
+               // directory selected
+               var sel = this.filetype.getValue();
+               
+               if (this.file.project.xtype=="Gtk" && (sel == "bjs" || sel == "vala")) {
+                       this.build_module_lbl.el.show();
+                       this.build_module.el.show();
+               }
+               this.name_lbl.el.show();
+               this.name.el.show();
+               
+               if (sel == "bjs") {
+                _this.gen_lbl.el.show();
+                _this.gen.el.show();
+            }
+            
+            if (this.file.project.xtype == "Roo" && sel == "bjs") {
+               this.title_lbl.el.show();
+                       this.title.el.show();
+                       
+                       this.region_lbl.el.show();
+                       this.region.el.show();
+                       
+                       this.parent_lbl.el.show();
+                       this.parent.el.show();
+                       
+                       this.permname_lbl.el.show();
+                       this.permname.el.show();
+                       
+                       this.modOrder_lbl.el.show();
+                       this.modOrder.el.show();
+               }
+            
+                
+        }
+        public void showEditFile () {
+               this.save_btn.el.set_label("Save");
+               this.filetype_lbl.el.hide();
+               this.filetype.el.hide();
+                        
+               var sel = this.filetype.getValue();
+               switch(_this.project.xtype) {
+                       case "Roo":      
+                                if (sel == "bjs") {
+                                       _this.title_lbl.el.show();
+                                       _this.title.el.show();
+                                       
+                                       _this.region_lbl.el.show();
+                                       _this.region.el.show();
+                                       
+                                       _this.parent_lbl.el.show();
+                                       _this.parent.el.show();
+                                       
+                                       _this.permname_lbl.el.show();
+                                       _this.permname.el.show();
+                                       
+                                       _this.modOrder_lbl.el.show();
+                                       _this.modOrder.el.show();
+                               
+                               }
+                               break;
+                       default:
+                               _this.build_module_lbl.el.show();
+                               _this.build_module.el.show();   
+                               
+                               if (sel == "bjs") {
+                               
+                                        _this.gen_lbl.el.show();
+                                       _this.gen.el.show();
+                               }
+                               break;
+               }
+               this.path.el.show();
+               this.path_lbl.el.show();
+               this.path.el.set_text(_this.file.relpath);
+        }
         public void show (JsRender.JsRender  c, Gtk.Window pwin, bool new_window) 
         {
             
             this.el.set_transient_for(pwin);
             
             // window + header?
-             
+             this.hideAll();
             this.el.show();
            // this.name.el.grab_focus();
             
             
             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.showEditFile();
             } 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_model.load();
-                       this.filetype.el.selected = Gtk.INVALID_LIST_POSITION;
-                   this.filetype.showhide();
+               this.showNewFile();
+                        
+              
                    
             }
             
                 }
                 
                 _this.file.build_module = _this.build_module.getValue();
-                
+                       
                 
                 
         
                                                             
+        }
+        public void onFileTypeChange () {
+               if (this.filetype.el.selected == Gtk.INVALID_LIST_POSITION) {
+                       this.dir_dropdown.el.hide();
+                       this.dir_dropdown_lbl.el.hide();
+                       this.build_module_lbl.el.hide();
+                       this.build_module.el.hide();
+                       this.name_lbl.el.hide();
+                       this.name.el.hide();
+                
+               this.gen_lbl.el.hide();
+                       this.gen.el.hide();
+            
+            
+               this.title_lbl.el.hide();
+                       this.title.el.hide();
+                       
+                       this.region_lbl.el.hide();
+                       this.region.el.hide();
+                       
+                       this.parent_lbl.el.hide();
+                       this.parent.el.hide();
+                       
+                       this.permname_lbl.el.hide();
+                       this.permname.el.hide();
+                       
+                       this.modOrder_lbl.el.hide();
+                       this.modOrder.el.hide();
+         
+                       return;
+                        
+               }
+               
+               this.dir_dropdown.el.show();
+               this.dir_dropdown_lbl.el.show();
+               var sel = this.filetype.getValue();
+               
+               var old_sel = _this.dir_dropdown.el.selected != Gtk.INVALID_LIST_POSITION;
+               var olddir = this.dir_dropdown.getValue();
+               GLib.debug("old dir = %s", olddir);
+               if (this.file.project.xtype=="Gtk" && (sel == "bjs" || sel == "vala")) {
+                       _this.project.loadDirsToStringList(_this.dir_model.el, "/src");
+                       if (old_sel && olddir.has_prefix("/src")) {
+                               this.dir_dropdown.setValue(olddir);
+                       } else {
+                            _this.dir_dropdown.el.selected = Gtk.INVALID_LIST_POSITION;
+                   }
+                 
+               } else {
+        
+                _this.project.loadDirsToStringList(_this.dir_model.el, "");
+                       if (old_sel) {
+                               this.dir_dropdown.setValue(olddir);
+                       } else {
+                            _this.dir_dropdown.el.selected = Gtk.INVALID_LIST_POSITION;
+                    }
+               
+            }
+        
+         
+            // is this confusing?  - should we just strip out / add if necessary..
+            if (sel == "bjs" || sel == "vala" || sel == "js" || sel == "css" || sel == "php") {
+                _this.name_lbl.el.label = "Component Name (Filename with-out extension)";                               
+            } else {
+                   _this.name_lbl.el.label = "File Name (with extension)";
+            }
+         
+        }
+        public void showNewFile () {
+               this.save_btn.el.set_label("Create");
+               this.hideAll();
+               this.filetype.el.show();
+            this.filetype_lbl.el.show();
+            this.filetype_model.load();
+               this.filetype.el.selected = Gtk.INVALID_LIST_POSITION;
+         
+                   
+        }
+        public void hideAll () {
+        
+               // exiting only
+               this.path_lbl.el.hide();
+            this.path.el.hide();
+             
+            // new 
+            this.name_lbl.el.hide();
+            this.name.el.hide();
+            //new 
+            this.dir_dropdown_lbl.el.hide();
+            this.dir_dropdown.el.hide();
+               // roo
+               this.title_lbl.el.hide();
+               this.title.el.hide();
+               
+               this.region_lbl.el.hide();
+               this.region.el.hide();
+               
+               this.parent_lbl.el.hide();
+               this.parent.el.hide();
+               
+               this.permname_lbl.el.hide();
+               this.permname.el.hide();
+               
+               this.modOrder_lbl.el.hide();
+               this.modOrder.el.hide();
+               
+               this.build_module_lbl.el.hide();
+               this.build_module.el.hide();
+               
+               this.gen_lbl.el.hide();
+               this.gen.el.hide();
+                       this.filetype_lbl.el.hide();
+                       this.filetype.el.hide();
         }
         public class Xcls_Box2 : Object
         {
 
 
                 // my vars (def)
+            public bool in_showhide;
 
             // ctor
             public Xcls_filetype(Xcls_PopoverFileDetails _owner )
                 this.el = new Gtk.DropDown( _this.filetype_model.el, null );
 
                 // my vars (dec)
+                this.in_showhide = false;
 
                 // set gobject values
                 this.el.hexpand = true;
                 //listeners
                 this.el.notify["selected"].connect( () => {
                 
-                 
-                  
-                    // directory is only available for non-bjs 
-                    this.showhide( );
+                       _this.onFileTypeChange();
                 
                  });
             }
                }
                
                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.region_lbl.el.hide();
-               _this.region.el.hide();
-               
-               _this.parent_lbl.el.hide();
-               _this.parent.el.hide();
-               
-               _this.permname_lbl.el.hide();
-               _this.permname.el.hide();
-               
-               _this.modOrder_lbl.el.hide();
-               _this.modOrder.el.hide();
-               
-               _this.build_module_lbl.el.hide();
-               _this.build_module.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":
-                               
-                               if (sel == "bjs") {
-                                       _this.title_lbl.el.show();
-                                       _this.title.el.show();
-                                       
-                                       _this.region_lbl.el.show();
-                                       _this.region.el.show();
-                                       
-                                       _this.parent_lbl.el.show();
-                                       _this.parent.el.show();
-                                       
-                                       _this.permname_lbl.el.show();
-                                       _this.permname.el.show();
-                                       
-                                       _this.modOrder_lbl.el.show();
-                                       _this.modOrder.el.show();
-                               
-                               }
-                               _this.build_module_model.load(null);
-                        
-                               
-                               break;
-                       default: // vala..
-                       
-                               _this.build_module_lbl.el.show();
-                               _this.build_module.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;
-               }
-             
-                // load up the directories
-                //??? why can we not create bjs files in other directories??
-               //if (!is_bjs && _this.file.path.length < 1) {
-               
-             
-                       
-                       
-               //}
-               
-                
             }
             public void setValue (string cur) {
                var el  = _this.filetype_model.el;
                 this.colspan = 1;
 
                 // set gobject values
+
+                //listeners
+                this.el.notify["selected"].connect( () => {
+                
+                        _this.onDirChanged();
+                       
+                       
+                       
+                 });
             }
 
             // user defined functions
             public string getValue () {
                return _this.dir_model.el.get_string(this.el.selected);
             }
+            public void setValue (string cur) {
+               var el  = _this.dir_model.el;
+               for(var i= 0; i < el.get_n_items();i++)  {
+                       if (el.get_string(i) == cur) {
+                               this.el.selected = i;
+                               break;
+                       }
+               }
+            }
         }
         public class Xcls_dir_model : Object
         {
                        }
                        // what does this do?
                        
-                       var isNew = _this.file.name.length  > 0 ? false : true;
+                 
                        /*
                        if (!isNew && this.file.name != _this.name.el.get_text()) {
                            Xcls_StandardErrorDialog.singleton().show(
                        //    this.file[i] =  this.get(i).el.get_text();
                        //}
                 
-                       if (!isNew) {
+                       if (!_this.is_new) {
                          //  try {
                          
                                var old_target = _this.file.build_module;
                            _this.file.save();
                            _this.el.hide();
                            return;
-                       }
+                       }  
                        
                        // ---------------- NEW FILES...
                        var ftype = _this.filetype.getValue();
                        _this.file.loaded = true;
                        _this.file.save();
                      _this.file.project.addFile(_this.file);
-                                
+                     var sel = _this.filetype.getValue();
+                        if (_this.file.project.xtype == "Gtk" && 
+                               _this.file.build_module.length > 0 &&
+                               ( sel == "bjs" || sel == "vala")) {
+                        
+                               var pr = (Project.Gtk) _this.file.project;
+                               if (pr.compilegroups.has_key(_this.file.build_module)) {
+                                       var cg = pr.compilegroups.get(_this.file.build_module);
+                                       if (!cg.sources.contains(_this.file.relpath)) {
+                                               cg.sources.add(_this.file.relpath);
+                                       }
+                               }
+                       
+                       }
                         
                  
                        // what about .js ?