{ "build_module" : "builder", "gen_extended" : false, "items" : [ { "# WindowState? windowstate" : "null", "$ Project.Callback doneObj" : "null", "$ deletable" : true, "$ xns" : "Gtk", "@ void canceled" : "()", "Project.Project result" : "null", "bool modal" : true, "default_width" : 600, "items" : [ { "$ xns" : "Gtk", "* prop" : "titlebar", "* title" : "New Project", "bool show_title_buttons" : false, "items" : [ { "$ Gtk.Align halign" : "Gtk.Align.END", "$ xns" : "Gtk", "* pack" : "pack_start", "bool hexpand" : false, "label" : "Cancel", "listeners" : { "clicked" : [ "( ) => {", " ", " _this.el.hide();", "\t_this.canceled();", " ", "", "}", "" ] }, "xtype" : "Button" }, { "$ Gtk.Align halign" : "Gtk.Align.START", "$ css_classes" : "{ \"suggested-action\" }", "$ xns" : "Gtk", "* pack" : "pack_end", "bool hexpand" : false, "id" : "ok_btn", "label" : "OK", "listeners" : { "clicked" : [ "( ) => {", " var err_dialog = Xcls_StandardErrorDialog.singleton();", " ", " ", " \tif (_this.ptype_dd.getValue().length < 1) {", " err_dialog.show(_this.el,\"You have to set Project type\"); ", " return;", " }", " var fn = _this.parent_dd.getValue();", " var is_existing = false;", " var is_new_folder = false;", " switch (_this.type_dd.getValue()) {", "\t \tcase \"Existing Folder\":", "\t\t \tif (_this.folder_dd.getValue().length < 1) {", "\t\t\t\terr_dialog.show(_this.el,\"You have to set Folder\"); ", "\t\t\t\treturn;", "\t\t\t}", "\t\t\tfn += \"/\" + _this.folder_dd.getValue();", "\t\t\tis_existing = true;", "\t\t\tbreak;", "\t \t", "\t \tcase \"New Folder\":", "\t\t \tif (_this.name_entry.getValue().length < 1) {", "\t\t\t\terr_dialog.show(_this.el,\"You have enter a Project Name\"); ", "\t\t\t\treturn;", "\t\t\t}", "\t\t\tfn += \"/\" + _this.name_entry.getValue();\t ", "\t\t\t", "\t\t\tif (FileUtils.test( fn ,FileTest.EXISTS)) {", "\t\t\t\terr_dialog.show(_this.el,\"That folder already exists\"); ", "\t\t\t\treturn;\t\t\t", "\t\t\t}", "\t\t\tvar dir = File.new_for_path(fn);", "\t\t\ttry {", "\t\t\t\tdir.make_directory();\t", "\t\t\t} catch (Error e) {", "\t\t\t\tGLib.error(\"Failed to make directory %s\", fn);", "\t\t\t} ", "\t\t\tis_new_folder = true;", "\t\t\tbreak;", "\t\t\t", "\t \tdefault:", "\t \t\treturn;", " \t\t", " }", " ", " ", " ", " ", " _this.el.hide();", " ", " ", "", " ", " GLib.debug(\"add %s\\n\" , fn);", " try {", "\t\tvar project = Project.Project.factory(_this.ptype_dd.getValue(), fn);", "\t\tif (is_new_folder) {\t", "\t\t\tproject.initialize();", "\t\t\t", "\t\t} else {", "\t\t\tproject.load();", "\t\t}", "\t\t", "\t\tproject.save();", "\t\t Project.Project.saveProjectList();", " \t\t_this.result = project;", "\t\tif (is_new_folder || is_existing) {", "\t\t\t ", "\t\t", "\t \t _this.windowstate.projectPopoverShow(", "\t \t \t_this.el.transient_for, project, _this.doneObj ", " \t \t);", " \t } else {", " \t \tif (_this.doneObj != null) {", "\t\t \t _this.doneObj.call(project);", "\t \t }", " \t }", "\t\t", "\t\treturn;", "\t} catch (Error e) {", "\t\tGLib.debug(\"got error? %s\" , e.message);", "\t}", "\t ", "", "}", "" ] }, "xtype" : "Button" } ], "xtype" : "HeaderBar" }, { "$ homogeneous" : false, "$ xns" : "Gtk", "* prop" : "child", "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", "bool expand" : true, "int margin_bottom" : 10, "int margin_end" : 10, "int margin_start" : 10, "int margin_top" : 10, "items" : [ { "$ xns" : "Gtk", "* columns" : 2, "int column_spacing" : 4, "int margin_bottom" : 20, "int row_spacing" : 4, "items" : [ { "$ Gtk.Align halign" : "Gtk.Align.START", "$ xns" : "Gtk", "id" : "type_lbl", "string label" : "Create a Project from:", "xtype" : "Label" }, { "$ uint selected" : "Gtk.INVALID_LIST_POSITION", "$ xns" : "Gtk", "* init" : [ "{", "", "}", "" ], "bool hexpand" : true, "id" : "type_dd", "items" : [ { "$ xns" : "Gtk", "* prop" : "model", "strings" : "{ \"New Folder\", \"Existing Folder\" /*, \"Checkout from git\" */ }", "xtype" : "StringList" } ], "listeners" : { "notify[\"selected\"]" : [ "( ) => {", "\t ", "\tif (this.el.selected == Gtk.INVALID_LIST_POSITION) {", "\t\treturn;", "\t}", "\tvar m = (Gtk.StringList) this.el.model;", "\tGLib.debug(\"selected item: %s\", m.get_string(this.el.selected));", "\t", "\t_this.hideAll();", "\t_this.parent_lbl.el.show();", "\t_this.parent_dd.el.show();", "\t_this.parent_dd.load();", "\t/*", "\t\t\t break;", " \t", " \tswitch (m.get_string(this.el.selected)) {", "\t\tcase \"New Folder\":", "\t\t _this.name_lbl.el.show(); ", " \t\t_this.name_entry.el.show(); ", "\t\t\t break;", "\t\tcase \"Existing Folder\":", "\t\t\t_this.folder_lbl.el.show();", "\t\t\t _this.folder_dd.el.show(); \t", "\t\t\t break;", "\t\t\t ", "\t\tcase \"Checkout from git\":", "\t\t _this.name_lbl.el.show(); ", "\t\t\t_this.name_entry.el.show(); ", "\t\t\tbreak; ", "\t\tdefault:", "\t\t\t_this.hideAll();", "\t\t\tbreak;", "", "\t}\t", "\t", "\t*/", "\t ", " ", " ", " ", " ", "\t\t", "} ", "" ] }, "xtype" : "DropDown", "| string getValue" : [ "() {", "\tvar m = (Gtk.StringList) this.el.model;", "\treturn m.get_string(this.el.selected);", "\t", "}" ] }, { "$ Gtk.Align halign" : "Gtk.Align.START", "$ xns" : "Gtk", "id" : "parent_lbl", "string label" : "In Folder:", "xtype" : "Label" }, { "$ xns" : "Gtk", "bool hexpand" : true, "id" : "parent_dd", "items" : [ { "$ xns" : "Gtk", "* prop" : "model", "strings" : "{ \"gitlive\", \"Projects\", \"Select\" }", "xtype" : "StringList" } ], "listeners" : { "notify[\"selected\"]" : [ "( ) => {", "\tif (this.el.selected == Gtk.INVALID_LIST_POSITION) {", "\t\t_this.hideAll();", "\t\t_this.parent_lbl.el.show();", " \t_this.parent_dd.el.show(); ", " \t", "\t\treturn;", "\t}", "\t", "\t", "\t", "\tif (this.getValue() == \"Select Folder\") {", "\t\tvar fd = new Gtk.FileDialog();", "\t\tfd.title = \"Select Folder\";", "\t\tfd.modal = true;", "\t\t", "\t\tfd.select_folder.begin(_this.el, null, (obj, res) => {", "\t\t\ttry {", "\t\t \tvar f = fd.select_folder.end(res);", "\t\t\t\tthis.extra_value = f.get_path();", "\t\t\t\tvar sl = (Gtk.StringList) this.el.model;\t", "\t\t\t\t", "\t\t\t\tsl.remove(sl.get_n_items()-1);", "\t\t\t\t", "\t\t\t\tsl.append(this.extra_value);", "\t\t\t\tsl.append(\"Select Folder\");", "\t\t\t\tthis.el.selected = sl.get_n_items()-2;", "\t\t\t} catch (GLib.Error e) {", "\t\t\t\t// do nothing?", "\t\t\t}", "\t\t\t", "\t\t});", "\t\treturn;", "", "\t}", "\t_this.hideAll();", "\t_this.parent_lbl.el.show();", " \t_this.parent_dd.el.show(); ", " \t", "\t", " _this.ptype_lbl.el.show(); ", " _this.ptype_dd.el.show(); ", "\t// folder selected...", "\tswitch(_this.type_dd.getValue()) {", "\t\tcase \"New Folder\":", "\t\t _this.name_lbl.el.show(); ", " \t _this.name_entry.el.show(); ", " \t _this.name_entry.el.text = \"\";", "\t\t _this.ptype_lbl.el.show(); ", "\t\t _this.ptype_dd.el.show(); ", " \t break;", " \t ", "\t\tcase \"Existing Folder\":", "\t\t\t_this.folder_lbl.el.show();", "\t\t \t_this.folder_dd.el.show();", "\t\t \t_this.folder_dd.load();", "\t\t ", "\t\t \tbreak;", "\t\t \t", "\t\tcase \"Checkout from git\":", "\t\t _this.name_lbl.el.show(); ", " \t _this.name_entry.el.show(); ", " \t _this.name_lbl.el.label= \"not yet\";", " \t _this.name_entry.el.text = \"this is not supported yet\";", "\t\t\tbreak;", "\t\tdefault:", "\t\t\tbreak;", "\t}", " ", "\t", "", "}", "" ] }, "string extra_value" : "", "xtype" : "DropDown", "| string getValue" : [ "() {", "\tvar m = (Gtk.StringList) this.el.model;", "\treturn m.get_string(this.el.selected);", "\t", "}" ], "| void load" : [ "() {", "", "\tvar sl = (Gtk.StringList) this.el.model;\t", "\tvar hd = GLib.Environment.get_home_dir();", "\twhile(sl.get_n_items() > 0) {", "\t\tsl.remove(0);", "\t}", "\tif (FileUtils.test(hd + \"/gitlive\" ,FileTest.IS_DIR)) {", "\t\tsl.append(hd + \"/gitlive\");", "\t}", "\tif (FileUtils.test(hd + \"/Projects\" ,FileTest.IS_DIR)) {", "\t\tsl.append(hd + \"/Projects\");", "\t}", "\tif (this.extra_value != \"\" && FileUtils.test(this.extra_value ,FileTest.IS_DIR)) {", "\t\tsl.append(this.extra_value);", "\t}", "\t", "\tsl.append(\"Select Folder\");", "\tthis.el.selected = Gtk.INVALID_LIST_POSITION;", "\t", "}" ] }, { "$ Gtk.Align halign" : "Gtk.Align.START", "$ xns" : "Gtk", "id" : "folder_lbl", "string label" : "Add Folder", "xtype" : "Label" }, { "$ xns" : "Gtk", "bool hexpand" : true, "id" : "folder_dd", "items" : [ { "$ xns" : "Gtk", "* prop" : "model", "strings" : "{ \"gitlive\", \"Projects\", \"Select\" }", "xtype" : "StringList" } ], "listeners" : { "notify[\"selected\"]" : [ "() => {", "\tvar fn = this.getValue();", "\tif (fn == \"\") {", "\t\treturn;", "\t}", "\tvar p = _this.parent_dd.getValue();", "\tif (!FileUtils.test(p + \"/\" + fn + \"/.roobuilder.jcfg\" , GLib.FileTest.EXISTS)) {", "\t\treturn;", "\t}", "\tvar ty = Project.Project.peekProjectType(p + \"/\" + fn + \"/.roobuilder.jcfg\" );", "\tif (ty == \"\") {", "\t\treturn;", "\t}", "\t_this.ptype_dd.setValue(ty);", "\t ", " }", " ", " " ] }, "xtype" : "DropDown", "| string getValue" : [ "() {", "\tvar m = (Gtk.StringList) this.el.model;", "\treturn this.el.selected == Gtk.INVALID_LIST_POSITION ?", "\t\t\t \"\" : m.get_string(this.el.selected);", "\t", "}" ], "| void load" : [ "() {", "\tvar p = _this.parent_dd.getValue();", "\tvar f = File.new_for_path(p);", "\tvar sl = (Gtk.StringList) this.el.model;\t", "\twhile(sl.get_n_items() > 0) {", "\t\tsl.remove(0);", "\t}", "\tvar gstr = new Gee.ArrayList();", "\t", "\t", "\ttry {", "\t\tvar file_enum = f.enumerate_children(", "\t\t\tGLib.FileAttribute.STANDARD_DISPLAY_NAME, ", "\t\t\tGLib.FileQueryInfoFlags.NONE, null);", "\t ", " \t", "\t\t", "\t\tFileInfo next_file; ", "\t\t ", "\t\twhile ((next_file = file_enum.next_file(null)) != null) {", "\t\t\tvar fn = next_file.get_display_name();", "\t\t ", "\t\t\tif (fn[0] == '.') { // skip hidden", "\t\t\t\tcontinue;", "\t\t\t}", "\t\t\t ", "\t\t\tif (!FileUtils.test(p + \"/\" + fn, GLib.FileTest.IS_DIR)) {", "\t\t\t\tcontinue;", "\t\t\t}", "\t\t\tif (null != Project.Project.getProjectByPath(p + \"/\" + fn)) {", "\t\t\t\tcontinue;", "\t\t\t}", "\t\t", "\t\t\tgstr.add(fn);", "\t\t}", "\t} catch (GLib.Error e) {", "\t\t// do nothing.. ", "\t}", "\tgstr.sort((a,b) => {", "\t\treturn Posix.strcmp(a.down(), b.down());", "\t});", "", "\tforeach(var str in gstr) {", "\t\tsl.append(str);", "\t}", "\t ", "}" ] }, { "$ Gtk.Align halign" : "Gtk.Align.START", "$ xns" : "Gtk", "id" : "name_lbl", "string label" : "Named (New Folder Name)", "xtype" : "Label" }, { "$ xns" : "Gtk", "bool hexpand" : true, "id" : "name_entry", "xtype" : "Entry", "| string getValue" : [ "() {", "\treturn this.el.text;", "}" ] }, { "$ Gtk.Align halign" : "Gtk.Align.START", "$ xns" : "Gtk", "id" : "ptype_lbl", "label" : "Project type :", "xtype" : "Label" }, { "$ xns" : "Gtk", "bool hexpand" : true, "id" : "ptype_dd", "items" : [ { "$ xns" : "Gtk", "* prop" : "model", "strings" : [ "{ ", "\t\"Gtk - A Gtk / Vala Desktop project\", ", "\t\"Roo - A Web Javascript Project using the Roo Library\"", "\t/*, \"Flutter\" */ ", "}" ], "xtype" : "StringList" } ], "listeners" : { "notify[\"selected\"]" : [ "( ) => {", "", "\t_this.ok_btn.el.hide();\t", "\tif (this.getValue() != \"\") {", "\t _this.ok_btn.el.show();", "\t}", "", "}", "" ] }, "xtype" : "DropDown", "| string getValue" : [ "() {", "\tvar m = (Gtk.StringList) this.el.model;", "\tvar str = this.el.selected == Gtk.INVALID_LIST_POSITION ?", "\t\t\t \"\" : m.get_string(this.el.selected);", "\t\t\t ", " \tvar ar = str.split(\" \");", " \treturn ar[0];", "\t", "}" ], "| void setValue" : [ "(string val) {", "\tvar m = (Gtk.StringList) this.el.model;", "\tfor(var i = 0; i < m.get_n_items();i++) {", "\t\tif (m.get_string(i) == val) {", "\t\t\tthis.el.selected = i;", "\t\t\tbreak;", "\t\t}", "\t}", "\tthis.el.selected = Gtk.INVALID_LIST_POSITION;", "", "}" ] } ], "xtype" : "Grid" } ], "xtype" : "Box" } ], "name" : "EditProject", "string title" : "New Project", "xtype" : "Window", "| void hideAll" : [ "() {", " \t_this.parent_lbl.el.hide();", " _this.parent_dd.el.hide(); ", " \t", " \t_this.folder_lbl.el.hide();", " _this.folder_dd.el.hide(); ", " _this.name_lbl.el.hide(); ", " _this.name_entry.el.hide(); ", " _this.ptype_lbl.el.hide(); ", " _this.ptype_dd.el.hide(); ", " _this.ok_btn.el.hide(); ", " ", "}" ], "| void show" : [ "(Project.Callback doneObj) {", " this.doneObj= doneObj;", " _this.hideAll(); ", " // hide stuff..", " _this.type_dd.el.selected = Gtk.INVALID_LIST_POSITION;", " _this.folder_dd.el.selected = Gtk.INVALID_LIST_POSITION;", " _this.ptype_dd.el.selected = Gtk.INVALID_LIST_POSITION;", " _this.parent_dd.extra_value = \"\";", " //[ 'xtype' ].forEach(function(k) {", " // _this.get(k).setValue(typeof(c[k]) == 'undefined' ? '' : c[k]);", " //});", "\t// shouild set path..", " ", " this.el.show();", " ", "}" ] } ], "name" : "EditProject" }