Fix #7959 - new project flow - use void func to callback after each step, tidy up...
[roobuilder] / src / Builder4 / PopoverFileDetails.bjs
index 158deed..a698a48 100644 (file)
@@ -10,6 +10,7 @@
    "@ void success" : "(Project.Project pr, JsRender.JsRender file)",
    "Xcls_MainWindow mainwindow" : "null",
    "bool done" : false,
+   "bool is_new" : true,
    "bool modal" : true,
    "id" : "PopoverFileDetails",
    "items" : [
        "int margin_end" : 4,
        "int margin_start" : 4,
        "items" : [
-        {
-         "$ justify" : "Gtk.Justification.RIGHT",
-         "$ visible" : true,
-         "$ xns" : "Gtk",
-         "id" : "dir_dropdown_lbl",
-         "label" : "Create File in this Directory",
-         "x_options" : 4,
-         "xalign" : 0.90000000000000002,
-         "xtype" : "Label"
-        },
-        {
-         "$ xns" : "Gtk",
-         "id" : "dir_dropdown",
-         "int colspan" : 1,
-         "items" : [
-          {
-           "$ xns" : "Gtk",
-           "* prop" : "model",
-           "id" : "dir_model",
-           "strings" : "{}",
-           "xtype" : "StringList"
-          }
-         ],
-         "xtype" : "DropDown",
-         "| string getValue" : [
-          "() {",
-          "\treturn _this.dir_model.el.get_string(this.el.selected);",
-          "}"
-         ]
-        },
         {
          "$ justify" : "Gtk.Justification.RIGHT",
          "$ xns" : "Gtk",
          "xtype" : "DropDown",
          "| string getValue" : [
           "() {",
+          "\t",
+          "\tif (!_this.is_new) {",
+          "\t\treturn _this.file.xtype != \"Plainfile\" ? \"bjs\" :  _this.file.file_ext;",
+          "\t}",
+          "\t",
           "\tif (this.el.selected == Gtk.INVALID_LIST_POSITION) {",
           "\t\treturn \"\";",
           "\t}",
          ],
          "| void showhide" : [
           "()   {",
+          "\t ",
           "",
-          "",
-          "\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.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_this.build_module_lbl.el.show();",
           "\t\t\t_this.build_module.el.show();",
           "\t",
-          "\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\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}",
           " ",
         },
         {
          "$ justify" : "Gtk.Justification.RIGHT",
+         "$ visible" : true,
          "$ xns" : "Gtk",
+         "id" : "dir_dropdown_lbl",
+         "label" : "Create File in this Directory",
+         "x_options" : 4,
+         "xalign" : 0.90000000000000002,
+         "xtype" : "Label"
+        },
+        {
+         "$ xns" : "Gtk",
+         "id" : "dir_dropdown",
+         "int colspan" : 1,
+         "items" : [
+          {
+           "$ xns" : "Gtk",
+           "* prop" : "model",
+           "id" : "dir_model",
+           "strings" : "{}",
+           "xtype" : "StringList"
+          }
+         ],
+         "xtype" : "DropDown",
+         "| string getValue" : [
+          "() {",
+          "\treturn _this.dir_model.el.get_string(this.el.selected);",
+          "}"
+         ]
+        },
+        {
+         "$ justify" : "Gtk.Justification.RIGHT",
+         "$ xns" : "Gtk",
+         "id" : "name_lbl",
          "label" : "Component Name (File name without extension)",
          "x_options" : 4,
          "xalign" : 0.90000000000000002,
          "$ xns" : "Gtk",
          "id" : "gen_lbl",
          "int colspan" : 1,
-         "label" : "Generate as Extended (experimental)",
+         "label" : "Generate as Extended (no working)",
          "x_options" : 4,
          "xalign" : 0.90000000000000002,
          "xtype" : "Label"
        ],
        "uint row_spacing" : 2,
        "xtype" : "Grid",
-       "| void hideRow" : [
+       "| void xhideRow" : [
         "(int row) ",
         "{",
         "\tvar el = _this.grid.el.get_child_at(0,row);",
         "",
         "}"
        ],
-       "| void showAllRows" : [
+       "| void xshowAllRows" : [
         "() {",
         "\tfor (var i = 2; i < 10;i++) {",
         "\t\tvar el = _this.grid.el.get_child_at(0,i);",
    "uint border_width" : 0,
    "xtype" : "Window",
    "| void show" : [
-    "(JsRender.JsRender c, Gtk.Window pwin, bool new_window) ",
+    "(JsRender.JsRender  c, Gtk.Window pwin, bool new_window) ",
     "{",
     "    ",
     "    this.project = c.project;",
     "        //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;",
     "   ",
-    "\t_this.path_lbl.el.show();",
-    "    _this.path.el.show();",
-    "    _this.dir_dropdown_lbl.el.hide();",
-    "    _this.dir_dropdown.el.hide();",
-    "    if (c.name == \"\") {",
-    "    \t_this.path_lbl.el.hide();",
-    "\t    _this.path.el.hide();",
-    "\t    this.filetype_model.load();",
-    "        _this.dir_dropdown_lbl.el.show();",
-    "\t    _this.dir_dropdown.el.show();",
-    "\t    ",
-    "    }   else {",
-    "        _this.path.el.set_text(c.relpath);",
-    "    }",
-    "    ",
+    "",
     "    ",
     "    if (this.project.xtype == \"Gtk\") {",
     "    \tvar p = (Project.Gtk) this.project;",
     "\t    this.build_module_model.load(p.compilegroups);",
     "\t    // it will select first if available...",
     "\t    // only for new files.",
-    "\t    if (c.name != \"\") {",
+    "\t    if (!this.is_new) {",
     "\t\t    this.build_module.setValue(c.build_module);",
     "\t    }",
     "    }",
     "    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) {",
     "\t    this.save_btn.el.set_label(\"Save\");",
-    "\t\t_this.filetype_lbl.el.hide();",
-    "\t\t_this.filetype.el.hide();",
-    "\t\t_this.filetype.showhide(); // as we only work on bjs files currently",
+    "\t\tthis.filetype_lbl.el.hide();",
+    "\t\tthis.filetype.el.hide();",
+    "\t\tthis.filetype.showhide(); // as we only work on bjs files currently",
     "    } 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.showhide();",
+    "\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();",
+    "\t    ",
     "    }",
     "    ",
     "    ",