1 static EditProject _EditProject;
3 public class EditProject : Object
6 private EditProject _this;
8 public static EditProject singleton()
10 if (_EditProject == null) {
11 _EditProject= new EditProject();
15 public Xcls_ok_btn ok_btn;
16 public Xcls_type_lbl type_lbl;
17 public Xcls_type_dd type_dd;
18 public Xcls_parent_lbl parent_lbl;
19 public Xcls_parent_dd parent_dd;
20 public Xcls_folder_lbl folder_lbl;
21 public Xcls_folder_dd folder_dd;
22 public Xcls_name_lbl name_lbl;
23 public Xcls_name_entry name_entry;
24 public Xcls_ptype_lbl ptype_lbl;
25 public Xcls_ptype_dd ptype_dd;
28 public Project.Callback doneObj;
29 public WindowState? windowstate;
30 public signal void canceled ();
31 public Project.Project result;
37 this.el = new Gtk.Window();
41 this.windowstate = null;
45 this.el.title = "New Project";
46 this.el.name = "EditProject";
47 this.el.default_width = 600;
48 this.el.deletable = true;
50 var child_1 = new Xcls_HeaderBar2( _this );
51 this.el.titlebar = child_1.el;
52 var child_2 = new Xcls_Box5( _this );
53 this.el.child = child_2.el;
56 // user defined functions
57 public void show (Project.Callback doneObj) {
58 this.doneObj= doneObj;
61 _this.type_dd.el.selected = Gtk.INVALID_LIST_POSITION;
62 _this.folder_dd.el.selected = Gtk.INVALID_LIST_POSITION;
63 _this.ptype_dd.el.selected = Gtk.INVALID_LIST_POSITION;
64 _this.parent_dd.extra_value = "";
65 //[ 'xtype' ].forEach(function(k) {
66 // _this.get(k).setValue(typeof(c[k]) == 'undefined' ? '' : c[k]);
73 public void hideAll () {
74 _this.parent_lbl.el.hide();
75 _this.parent_dd.el.hide();
77 _this.folder_lbl.el.hide();
78 _this.folder_dd.el.hide();
79 _this.name_lbl.el.hide();
80 _this.name_entry.el.hide();
81 _this.ptype_lbl.el.hide();
82 _this.ptype_dd.el.hide();
83 _this.ok_btn.el.hide();
86 public class Xcls_HeaderBar2 : Object
88 public Gtk.HeaderBar el;
89 private EditProject _this;
95 public Xcls_HeaderBar2(EditProject _owner )
98 this.el = new Gtk.HeaderBar();
102 // set gobject values
103 this.el.show_title_buttons = false;
104 var child_1 = new Xcls_Button3( _this );
106 this.el.pack_start ( child_1.el );
107 new Xcls_ok_btn( _this );
108 this.el.pack_end ( _this.ok_btn.el );
111 // user defined functions
113 public class Xcls_Button3 : Object
115 public Gtk.Button el;
116 private EditProject _this;
122 public Xcls_Button3(EditProject _owner )
125 this.el = new Gtk.Button();
129 // set gobject values
130 this.el.halign = Gtk.Align.END;
131 this.el.hexpand = false;
132 this.el.label = "Cancel";
135 this.el.clicked.connect( ( ) => {
144 // user defined functions
147 public class Xcls_ok_btn : Object
149 public Gtk.Button el;
150 private EditProject _this;
156 public Xcls_ok_btn(EditProject _owner )
160 this.el = new Gtk.Button();
164 // set gobject values
165 this.el.halign = Gtk.Align.START;
166 this.el.hexpand = false;
167 this.el.css_classes = { "suggested-action" };
168 this.el.label = "OK";
171 this.el.clicked.connect( ( ) => {
172 var err_dialog = Xcls_StandardErrorDialog.singleton();
175 if (_this.ptype_dd.getValue().length < 1) {
176 err_dialog.show(_this.el,"You have to set Project type");
179 var fn = _this.parent_dd.getValue();
180 var is_existing = false;
181 var is_new_folder = false;
182 switch (_this.type_dd.getValue()) {
183 case "Existing Folder":
184 if (_this.folder_dd.getValue().length < 1) {
185 err_dialog.show(_this.el,"You have to set Folder");
188 fn += "/" + _this.folder_dd.getValue();
193 if (_this.name_entry.getValue().length < 1) {
194 err_dialog.show(_this.el,"You have enter a Project Name");
197 fn += "/" + _this.name_entry.getValue();
199 if (FileUtils.test( fn ,FileTest.EXISTS)) {
200 err_dialog.show(_this.el,"That folder already exists");
203 var dir = File.new_for_path(fn);
205 dir.make_directory();
207 GLib.error("Failed to make directory %s", fn);
209 is_new_folder = true;
225 GLib.debug("add %s\n" , fn);
227 var project = Project.Project.factory(_this.ptype_dd.getValue(), fn);
229 project.initialize();
236 Project.Project.saveProjectList();
237 _this.result = project;
238 if (is_new_folder || is_existing) {
241 _this.windowstate.projectPopoverShow(
242 _this.el.transient_for, project, _this.doneObj
245 if (_this.doneObj != null) {
246 _this.doneObj.call(project);
252 GLib.debug("got error? %s" , e.message);
259 // user defined functions
263 public class Xcls_Box5 : Object
266 private EditProject _this;
273 public Xcls_Box5(EditProject _owner )
276 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
281 // set gobject values
282 this.el.homogeneous = false;
283 this.el.margin_end = 10;
284 this.el.margin_start = 10;
285 this.el.margin_bottom = 10;
286 this.el.margin_top = 10;
287 var child_1 = new Xcls_Grid6( _this );
289 this.el.append( child_1.el );
292 // user defined functions
294 public class Xcls_Grid6 : Object
297 private EditProject _this;
303 public Xcls_Grid6(EditProject _owner )
306 this.el = new Gtk.Grid();
310 // set gobject values
311 this.el.column_spacing = 4;
312 this.el.row_spacing = 4;
313 this.el.margin_bottom = 20;
314 new Xcls_type_lbl( _this );
315 this.el.attach( _this.type_lbl.el, 0, 0, 1, 1 );
316 new Xcls_type_dd( _this );
317 this.el.attach( _this.type_dd.el, 1, 0, 1, 1 );
318 new Xcls_parent_lbl( _this );
319 this.el.attach( _this.parent_lbl.el, 0, 1, 1, 1 );
320 new Xcls_parent_dd( _this );
321 this.el.attach( _this.parent_dd.el, 1, 1, 1, 1 );
322 new Xcls_folder_lbl( _this );
323 this.el.attach( _this.folder_lbl.el, 0, 2, 1, 1 );
324 new Xcls_folder_dd( _this );
325 this.el.attach( _this.folder_dd.el, 1, 2, 1, 1 );
326 new Xcls_name_lbl( _this );
327 this.el.attach( _this.name_lbl.el, 0, 3, 1, 1 );
328 new Xcls_name_entry( _this );
329 this.el.attach( _this.name_entry.el, 1, 3, 1, 1 );
330 new Xcls_ptype_lbl( _this );
331 this.el.attach( _this.ptype_lbl.el, 0, 4, 1, 1 );
332 new Xcls_ptype_dd( _this );
333 this.el.attach( _this.ptype_dd.el, 1, 4, 1, 1 );
336 // user defined functions
338 public class Xcls_type_lbl : Object
341 private EditProject _this;
347 public Xcls_type_lbl(EditProject _owner )
350 _this.type_lbl = this;
351 this.el = new Gtk.Label( "Create a Project from:" );
355 // set gobject values
356 this.el.halign = Gtk.Align.START;
359 // user defined functions
362 public class Xcls_type_dd : Object
364 public Gtk.DropDown el;
365 private EditProject _this;
371 public Xcls_type_dd(EditProject _owner )
374 _this.type_dd = this;
375 var child_1 = new Xcls_StringList9( _this );
377 this.el = new Gtk.DropDown( child_1.el, null );
381 // set gobject values
382 this.el.hexpand = true;
383 this.el.selected = Gtk.INVALID_LIST_POSITION;
392 this.el.notify["selected"].connect( ( ) => {
394 if (this.el.selected == Gtk.INVALID_LIST_POSITION) {
397 var m = (Gtk.StringList) this.el.model;
398 GLib.debug("selected item: %s", m.get_string(this.el.selected));
401 _this.parent_lbl.el.show();
402 _this.parent_dd.el.show();
403 _this.parent_dd.load();
407 switch (m.get_string(this.el.selected)) {
409 _this.name_lbl.el.show();
410 _this.name_entry.el.show();
412 case "Existing Folder":
413 _this.folder_lbl.el.show();
414 _this.folder_dd.el.show();
417 case "Checkout from git":
418 _this.name_lbl.el.show();
419 _this.name_entry.el.show();
437 // user defined functions
438 public string getValue () {
439 var m = (Gtk.StringList) this.el.model;
440 return m.get_string(this.el.selected);
444 public class Xcls_StringList9 : Object
446 public Gtk.StringList el;
447 private EditProject _this;
453 public Xcls_StringList9(EditProject _owner )
456 this.el = new Gtk.StringList( { "New Folder", "Existing Folder" /*, "Checkout from git" */ } );
460 // set gobject values
463 // user defined functions
467 public class Xcls_parent_lbl : Object
470 private EditProject _this;
476 public Xcls_parent_lbl(EditProject _owner )
479 _this.parent_lbl = this;
480 this.el = new Gtk.Label( "In Folder:" );
484 // set gobject values
485 this.el.halign = Gtk.Align.START;
488 // user defined functions
491 public class Xcls_parent_dd : Object
493 public Gtk.DropDown el;
494 private EditProject _this;
498 public string extra_value;
501 public Xcls_parent_dd(EditProject _owner )
504 _this.parent_dd = this;
505 var child_1 = new Xcls_StringList12( _this );
507 this.el = new Gtk.DropDown( child_1.el, null );
511 // set gobject values
512 this.el.hexpand = true;
515 this.el.notify["selected"].connect( ( ) => {
516 if (this.el.selected == Gtk.INVALID_LIST_POSITION) {
518 _this.parent_lbl.el.show();
519 _this.parent_dd.el.show();
526 if (this.getValue() == "Select Folder") {
527 var fd = new Gtk.FileDialog();
528 fd.title = "Select Folder";
531 fd.select_folder.begin(_this.el, null, (obj, res) => {
533 var f = fd.select_folder.end(res);
534 this.extra_value = f.get_path();
535 var sl = (Gtk.StringList) this.el.model;
537 sl.remove(sl.get_n_items()-1);
539 sl.append(this.extra_value);
540 sl.append("Select Folder");
541 this.el.selected = sl.get_n_items()-2;
542 } catch (GLib.Error e) {
551 _this.parent_lbl.el.show();
552 _this.parent_dd.el.show();
555 _this.ptype_lbl.el.show();
556 _this.ptype_dd.el.show();
557 // folder selected...
558 switch(_this.type_dd.getValue()) {
560 _this.name_lbl.el.show();
561 _this.name_entry.el.show();
562 _this.name_entry.el.text = "";
563 _this.ptype_lbl.el.show();
564 _this.ptype_dd.el.show();
567 case "Existing Folder":
568 _this.folder_lbl.el.show();
569 _this.folder_dd.el.show();
570 _this.folder_dd.load();
574 case "Checkout from git":
575 _this.name_lbl.el.show();
576 _this.name_entry.el.show();
577 _this.name_lbl.el.label= "not yet";
578 _this.name_entry.el.text = "this is not supported yet";
589 // user defined functions
590 public string getValue () {
591 var m = (Gtk.StringList) this.el.model;
592 return m.get_string(this.el.selected);
595 public void load () {
597 var sl = (Gtk.StringList) this.el.model;
598 var hd = GLib.Environment.get_home_dir();
599 while(sl.get_n_items() > 0) {
602 if (FileUtils.test(hd + "/gitlive" ,FileTest.IS_DIR)) {
603 sl.append(hd + "/gitlive");
605 if (FileUtils.test(hd + "/Projects" ,FileTest.IS_DIR)) {
606 sl.append(hd + "/Projects");
608 if (this.extra_value != "" && FileUtils.test(this.extra_value ,FileTest.IS_DIR)) {
609 sl.append(this.extra_value);
612 sl.append("Select Folder");
613 this.el.selected = Gtk.INVALID_LIST_POSITION;
617 public class Xcls_StringList12 : Object
619 public Gtk.StringList el;
620 private EditProject _this;
626 public Xcls_StringList12(EditProject _owner )
629 this.el = new Gtk.StringList( { "gitlive", "Projects", "Select" } );
633 // set gobject values
636 // user defined functions
640 public class Xcls_folder_lbl : Object
643 private EditProject _this;
649 public Xcls_folder_lbl(EditProject _owner )
652 _this.folder_lbl = this;
653 this.el = new Gtk.Label( "Add Folder" );
657 // set gobject values
658 this.el.halign = Gtk.Align.START;
661 // user defined functions
664 public class Xcls_folder_dd : Object
666 public Gtk.DropDown el;
667 private EditProject _this;
673 public Xcls_folder_dd(EditProject _owner )
676 _this.folder_dd = this;
677 var child_1 = new Xcls_StringList15( _this );
679 this.el = new Gtk.DropDown( child_1.el, null );
683 // set gobject values
684 this.el.hexpand = true;
687 this.el.notify["selected"].connect( () => {
688 var fn = this.getValue();
692 var p = _this.parent_dd.getValue();
693 if (!FileUtils.test(p + "/" + fn + "/.roobuilder.jcfg" , GLib.FileTest.EXISTS)) {
696 var ty = Project.Project.peekProjectType(p + "/" + fn + "/.roobuilder.jcfg" );
700 _this.ptype_dd.setValue(ty);
705 // user defined functions
706 public string getValue () {
707 var m = (Gtk.StringList) this.el.model;
708 return this.el.selected == Gtk.INVALID_LIST_POSITION ?
709 "" : m.get_string(this.el.selected);
712 public void load () {
713 var p = _this.parent_dd.getValue();
714 var f = File.new_for_path(p);
715 var sl = (Gtk.StringList) this.el.model;
716 while(sl.get_n_items() > 0) {
719 var gstr = new Gee.ArrayList<string>();
723 var file_enum = f.enumerate_children(
724 GLib.FileAttribute.STANDARD_DISPLAY_NAME,
725 GLib.FileQueryInfoFlags.NONE, null);
731 while ((next_file = file_enum.next_file(null)) != null) {
732 var fn = next_file.get_display_name();
734 if (fn[0] == '.') { // skip hidden
738 if (!FileUtils.test(p + "/" + fn, GLib.FileTest.IS_DIR)) {
741 if (null != Project.Project.getProjectByPath(p + "/" + fn)) {
747 } catch (GLib.Error e) {
751 return Posix.strcmp(a.down(), b.down());
754 foreach(var str in gstr) {
760 public class Xcls_StringList15 : Object
762 public Gtk.StringList el;
763 private EditProject _this;
769 public Xcls_StringList15(EditProject _owner )
772 this.el = new Gtk.StringList( { "gitlive", "Projects", "Select" } );
776 // set gobject values
779 // user defined functions
783 public class Xcls_name_lbl : Object
786 private EditProject _this;
792 public Xcls_name_lbl(EditProject _owner )
795 _this.name_lbl = this;
796 this.el = new Gtk.Label( "Named (New Folder Name)" );
800 // set gobject values
801 this.el.halign = Gtk.Align.START;
804 // user defined functions
807 public class Xcls_name_entry : Object
810 private EditProject _this;
816 public Xcls_name_entry(EditProject _owner )
819 _this.name_entry = this;
820 this.el = new Gtk.Entry();
824 // set gobject values
825 this.el.hexpand = true;
828 // user defined functions
829 public string getValue () {
834 public class Xcls_ptype_lbl : Object
837 private EditProject _this;
843 public Xcls_ptype_lbl(EditProject _owner )
846 _this.ptype_lbl = this;
847 this.el = new Gtk.Label( "Project type :" );
851 // set gobject values
852 this.el.halign = Gtk.Align.START;
855 // user defined functions
858 public class Xcls_ptype_dd : Object
860 public Gtk.DropDown el;
861 private EditProject _this;
867 public Xcls_ptype_dd(EditProject _owner )
870 _this.ptype_dd = this;
871 var child_1 = new Xcls_StringList20( _this );
873 this.el = new Gtk.DropDown( child_1.el, null );
877 // set gobject values
878 this.el.hexpand = true;
881 this.el.notify["selected"].connect( ( ) => {
883 _this.ok_btn.el.hide();
884 if (this.getValue() != "") {
885 _this.ok_btn.el.show();
891 // user defined functions
892 public string getValue () {
893 var m = (Gtk.StringList) this.el.model;
894 var str = this.el.selected == Gtk.INVALID_LIST_POSITION ?
895 "" : m.get_string(this.el.selected);
897 var ar = str.split(" ");
901 public void setValue (string val) {
902 var m = (Gtk.StringList) this.el.model;
903 for(var i = 0; i < m.get_n_items();i++) {
904 if (m.get_string(i) == val) {
905 this.el.selected = i;
909 this.el.selected = Gtk.INVALID_LIST_POSITION;
913 public class Xcls_StringList20 : Object
915 public Gtk.StringList el;
916 private EditProject _this;
922 public Xcls_StringList20(EditProject _owner )
925 this.el = new Gtk.StringList( {
926 "Gtk - A Gtk / Vala Desktop project",
927 "Roo - A Web Javascript Project using the Roo Library"
933 // set gobject values
936 // user defined functions