1 static Xcls_PopoverFileDetails _PopoverFileDetails;
3 public class Xcls_PopoverFileDetails : Object
6 private Xcls_PopoverFileDetails _this;
8 public static Xcls_PopoverFileDetails singleton()
10 if (_PopoverFileDetails == null) {
11 _PopoverFileDetails= new Xcls_PopoverFileDetails();
13 return _PopoverFileDetails;
15 public Xcls_filetype filetype;
16 public Xcls_ftdbcellrenderer ftdbcellrenderer;
17 public Xcls_ftdbmodel ftdbmodel;
18 public Xcls_name name;
19 public Xcls_title title;
20 public Xcls_region region;
21 public Xcls_parent parent;
22 public Xcls_permname permname;
23 public Xcls_modOrder modOrder;
24 public Xcls_build_module build_module;
25 public Xcls_dbcellrenderer dbcellrenderer;
26 public Xcls_dbmodel dbmodel;
27 public Xcls_save_btn save_btn;
30 public signal void success (Project.Project pr, JsRender.JsRender file);
32 public Project.Project project;
33 public JsRender.JsRender file;
34 public Xcls_MainWindow mainwindow;
37 public Xcls_PopoverFileDetails()
40 this.el = new Gtk.Popover( null );
45 this.mainwindow = null;
48 this.el.border_width = 0;
50 this.el.position = Gtk.PositionType.RIGHT;
51 var child_0 = new Xcls_Box2( _this );
53 this.el.add ( child_0.el );
56 this.el.closed.connect( () => {
64 // user defined functions
65 public void updateFileFromEntry () {
67 _this.file.title = _this.title.el.get_text();
68 _this.file.region = _this.region.el.get_text();
69 _this.file.parent = _this.parent.el.get_text();
70 _this.file.permname = _this.permname.el.get_text();
71 _this.file.modOrder = _this.modOrder.el.get_text();
73 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
74 _this.file.renameTo(_this.name.el.get_text());
76 // store the module...
77 _this.file.build_module = "";
79 if (_this.build_module.el.get_active_iter (out iter)) {
81 this.dbmodel.el.get_value (iter, 0, out vfname);
82 if (((string)vfname).length > 0) {
83 _this.file.build_module = (string)vfname;
92 public void show (JsRender.JsRender c, Gtk.Widget btn)
94 this.project = c.project;
102 _this.name.el.set_text(c.name);
103 _this.title.el.set_text(c.title);
104 _this.parent.el.set_text(c.parent);
105 _this.region.el.set_text(c.region);
106 _this.modOrder.el.set_text(c.modOrder);
107 _this.permname.el.set_text(c.permname);
111 _this.ftdbmodel.loadData("bjs"); // fixme - need to determine type..
112 _this.filetype.el.hide();
113 _this.filetypelbl.el.hide();
116 if (c.path.length > 0) {
118 this.save_btn.el.set_label("Save");
120 this.save_btn.el.set_label("Create");
123 var ar = new Gee.ArrayList<string>();
124 _this.dbmodel.loadData(ar,"");
125 // load the modules... if relivant..
126 if (this.project.xtype == "Gtk") {
127 var p = (Project.Gtk)c.project;
128 var cg = p.compilegroups;
130 var iter = cg.map_iterator();
132 var key = iter.get_key();
133 if (key == "_default_") {
138 _this.dbmodel.loadData(ar, c.build_module);
144 //console.log('show all');
145 this.el.set_modal(true);
146 this.el.set_relative_to(btn);
148 this.el.set_position(Gtk.PositionType.RIGHT);
151 print("SHOWALL - POPIP\n");
153 this.name.el.grab_focus();
155 //this.success = c.success;
159 public class Xcls_Box2 : Object
162 private Xcls_PopoverFileDetails _this;
168 public Xcls_Box2(Xcls_PopoverFileDetails _owner )
171 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
175 // set gobject values
176 this.el.homogeneous = false;
177 var child_0 = new Xcls_HeaderBar3( _this );
179 this.el.pack_start ( child_0.el , false,true,0 );
180 var child_1 = new Xcls_Table4( _this );
182 this.el.pack_start ( child_1.el , false,false,4 );
183 var child_2 = new Xcls_HButtonBox25( _this );
185 this.el.pack_end ( child_2.el , false,true,0 );
188 // user defined functions
190 public class Xcls_HeaderBar3 : Object
192 public Gtk.HeaderBar el;
193 private Xcls_PopoverFileDetails _this;
199 public Xcls_HeaderBar3(Xcls_PopoverFileDetails _owner )
202 this.el = new Gtk.HeaderBar();
206 // set gobject values
207 this.el.title = "Add / Edit File";
210 // user defined functions
213 public class Xcls_Table4 : Object
216 private Xcls_PopoverFileDetails _this;
222 public Xcls_Table4(Xcls_PopoverFileDetails _owner )
225 this.el = new Gtk.Table( 7, 2, true );
229 // set gobject values
230 this.el.margin_right = 4;
231 this.el.margin_left = 4;
232 this.el.row_spacing = 2;
233 var child_0 = new Xcls_Label5( _this );
235 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
236 var child_1 = new Xcls_filetype( _this );
238 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
239 var child_2 = new Xcls_Label9( _this );
241 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
242 var child_3 = new Xcls_name( _this );
244 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
245 var child_4 = new Xcls_Label11( _this );
247 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
248 var child_5 = new Xcls_title( _this );
250 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
251 var child_6 = new Xcls_Label13( _this );
253 this.el.attach_defaults ( child_6.el , 0,1,3,4 );
254 var child_7 = new Xcls_region( _this );
256 this.el.attach_defaults ( child_7.el , 1,2,3,4 );
257 var child_8 = new Xcls_Label15( _this );
259 this.el.attach_defaults ( child_8.el , 0,1,4,5 );
260 var child_9 = new Xcls_parent( _this );
262 this.el.attach_defaults ( child_9.el , 1,2,4,5 );
263 var child_10 = new Xcls_Label17( _this );
265 this.el.attach_defaults ( child_10.el , 0,1,5,6 );
266 var child_11 = new Xcls_permname( _this );
268 this.el.attach_defaults ( child_11.el , 1,2,5,6 );
269 var child_12 = new Xcls_Label19( _this );
271 this.el.attach_defaults ( child_12.el , 0,1,6,7 );
272 var child_13 = new Xcls_modOrder( _this );
274 this.el.attach_defaults ( child_13.el , 1,2,6,7 );
275 var child_14 = new Xcls_Label21( _this );
277 this.el.attach_defaults ( child_14.el , 0,1,7,8 );
278 var child_15 = new Xcls_build_module( _this );
280 this.el.attach_defaults ( child_15.el , 1,2,7,8 );
283 // user defined functions
285 public class Xcls_Label5 : Object
288 private Xcls_PopoverFileDetails _this;
294 public Xcls_Label5(Xcls_PopoverFileDetails _owner )
297 this.el = new Gtk.Label( "File type" );
301 // set gobject values
302 this.el.justify = Gtk.Justification.RIGHT;
303 this.el.xalign = 0.900000f;
306 // user defined functions
309 public class Xcls_filetype : Object
311 public Gtk.ComboBox el;
312 private Xcls_PopoverFileDetails _this;
318 public Xcls_filetype(Xcls_PopoverFileDetails _owner )
321 _this.filetype = this;
322 this.el = new Gtk.ComboBox();
326 // set gobject values
327 var child_0 = new Xcls_ftdbcellrenderer( _this );
329 this.el.pack_start ( child_0.el , true );
330 var child_1 = new Xcls_ftdbmodel( _this );
332 this.el.set_model ( child_1.el );
336 this.el.add_attribute(_this.ftdbcellrenderer.el , "markup", 1 );
339 // user defined functions
341 public class Xcls_ftdbcellrenderer : Object
343 public Gtk.CellRendererText el;
344 private Xcls_PopoverFileDetails _this;
350 public Xcls_ftdbcellrenderer(Xcls_PopoverFileDetails _owner )
353 _this.ftdbcellrenderer = this;
354 this.el = new Gtk.CellRendererText();
358 // set gobject values
361 // user defined functions
364 public class Xcls_ftdbmodel : Object
366 public Gtk.ListStore el;
367 private Xcls_PopoverFileDetails _this;
373 public Xcls_ftdbmodel(Xcls_PopoverFileDetails _owner )
376 _this.ftdbmodel = this;
377 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
381 // set gobject values
384 // user defined functions
385 public void loadData (string cur) {
390 /// el.append(out iter);
393 // el.set_value(iter, 0, "");
394 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
399 el.set_value(iter, 0, "bjs");
400 el.set_value(iter, 1, "User Interface File (bjs)");
401 _this.filetype.el.set_active_iter(iter);
405 el.set_value(iter, 0, "vala");
406 el.set_value(iter, 1, "Vala");
408 _this.filetype.el.set_active_iter(iter);
415 el.set_value(iter, 0, "js");
416 el.set_value(iter, 1, "Javascript");
419 _this.filetype.el.set_active_iter(iter);
424 el.set_value(iter, 0, "css");
425 el.set_value(iter, 1, "CSS");
428 _this.filetype.el.set_active_iter(iter);
435 public class Xcls_Label9 : Object
438 private Xcls_PopoverFileDetails _this;
444 public Xcls_Label9(Xcls_PopoverFileDetails _owner )
447 this.el = new Gtk.Label( "Component Name" );
451 // set gobject values
452 this.el.justify = Gtk.Justification.RIGHT;
453 this.el.xalign = 0.900000f;
456 // user defined functions
459 public class Xcls_name : Object
462 private Xcls_PopoverFileDetails _this;
468 public Xcls_name(Xcls_PopoverFileDetails _owner )
472 this.el = new Gtk.Entry();
476 // set gobject values
477 this.el.visible = true;
480 // user defined functions
483 public class Xcls_Label11 : Object
486 private Xcls_PopoverFileDetails _this;
492 public Xcls_Label11(Xcls_PopoverFileDetails _owner )
495 this.el = new Gtk.Label( "Title" );
499 // set gobject values
500 this.el.justify = Gtk.Justification.RIGHT;
501 this.el.xalign = 0.900000f;
502 this.el.visible = true;
505 // user defined functions
508 public class Xcls_title : Object
511 private Xcls_PopoverFileDetails _this;
517 public Xcls_title(Xcls_PopoverFileDetails _owner )
521 this.el = new Gtk.Entry();
525 // set gobject values
526 this.el.visible = true;
529 // user defined functions
532 public class Xcls_Label13 : Object
535 private Xcls_PopoverFileDetails _this;
541 public Xcls_Label13(Xcls_PopoverFileDetails _owner )
544 this.el = new Gtk.Label( "Region" );
548 // set gobject values
549 this.el.justify = Gtk.Justification.RIGHT;
550 this.el.xalign = 0.900000f;
551 this.el.tooltip_text = "center, north, south, east, west";
552 this.el.visible = true;
555 // user defined functions
558 public class Xcls_region : Object
561 private Xcls_PopoverFileDetails _this;
567 public Xcls_region(Xcls_PopoverFileDetails _owner )
571 this.el = new Gtk.Entry();
575 // set gobject values
576 this.el.visible = true;
579 // user defined functions
582 public class Xcls_Label15 : Object
585 private Xcls_PopoverFileDetails _this;
591 public Xcls_Label15(Xcls_PopoverFileDetails _owner )
594 this.el = new Gtk.Label( "Parent Name" );
598 // set gobject values
599 this.el.justify = Gtk.Justification.RIGHT;
600 this.el.xalign = 0.900000f;
601 this.el.visible = true;
604 // user defined functions
607 public class Xcls_parent : Object
610 private Xcls_PopoverFileDetails _this;
616 public Xcls_parent(Xcls_PopoverFileDetails _owner )
620 this.el = new Gtk.Entry();
624 // set gobject values
625 this.el.visible = true;
628 // user defined functions
631 public class Xcls_Label17 : Object
634 private Xcls_PopoverFileDetails _this;
640 public Xcls_Label17(Xcls_PopoverFileDetails _owner )
643 this.el = new Gtk.Label( "Permission Name" );
647 // set gobject values
648 this.el.justify = Gtk.Justification.RIGHT;
649 this.el.xalign = 0.900000f;
650 this.el.visible = true;
653 // user defined functions
656 public class Xcls_permname : Object
659 private Xcls_PopoverFileDetails _this;
665 public Xcls_permname(Xcls_PopoverFileDetails _owner )
668 _this.permname = this;
669 this.el = new Gtk.Entry();
673 // set gobject values
674 this.el.visible = true;
677 // user defined functions
680 public class Xcls_Label19 : Object
683 private Xcls_PopoverFileDetails _this;
689 public Xcls_Label19(Xcls_PopoverFileDetails _owner )
692 this.el = new Gtk.Label( "Order (for tabs)" );
696 // set gobject values
697 this.el.justify = Gtk.Justification.RIGHT;
698 this.el.xalign = 0.900000f;
699 this.el.visible = true;
702 // user defined functions
705 public class Xcls_modOrder : Object
708 private Xcls_PopoverFileDetails _this;
714 public Xcls_modOrder(Xcls_PopoverFileDetails _owner )
717 _this.modOrder = this;
718 this.el = new Gtk.Entry();
722 // set gobject values
723 this.el.visible = true;
726 // user defined functions
729 public class Xcls_Label21 : Object
732 private Xcls_PopoverFileDetails _this;
738 public Xcls_Label21(Xcls_PopoverFileDetails _owner )
741 this.el = new Gtk.Label( "Module to build (Vala only)" );
745 // set gobject values
746 this.el.justify = Gtk.Justification.RIGHT;
747 this.el.xalign = 0.900000f;
748 this.el.visible = true;
751 // user defined functions
754 public class Xcls_build_module : Object
756 public Gtk.ComboBox el;
757 private Xcls_PopoverFileDetails _this;
763 public Xcls_build_module(Xcls_PopoverFileDetails _owner )
766 _this.build_module = this;
767 this.el = new Gtk.ComboBox();
771 // set gobject values
772 var child_0 = new Xcls_dbcellrenderer( _this );
774 this.el.pack_start ( child_0.el , true );
775 var child_1 = new Xcls_dbmodel( _this );
777 this.el.set_model ( child_1.el );
781 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
784 // user defined functions
786 public class Xcls_dbcellrenderer : Object
788 public Gtk.CellRendererText el;
789 private Xcls_PopoverFileDetails _this;
795 public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
798 _this.dbcellrenderer = this;
799 this.el = new Gtk.CellRendererText();
803 // set gobject values
806 // user defined functions
809 public class Xcls_dbmodel : Object
811 public Gtk.ListStore el;
812 private Xcls_PopoverFileDetails _this;
818 public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
821 _this.dbmodel = this;
822 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
826 // set gobject values
829 // user defined functions
830 public void loadData (Gee.ArrayList<string> data, string cur) {
835 /// el.append(out iter);
838 // el.set_value(iter, 0, "");
839 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
844 el.set_value(iter, 0, "");
845 el.set_value(iter, 1, "-- select a module --");
846 _this.build_module.el.set_active_iter(iter);
848 for (var i = 0; i < data.size;i++) {
853 el.set_value(iter, 0, data.get(i));
854 el.set_value(iter, 1, data.get(i));
856 if (data.get(i) == cur) {
857 _this.build_module.el.set_active_iter(iter);
861 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
868 public class Xcls_HButtonBox25 : Object
870 public Gtk.HButtonBox el;
871 private Xcls_PopoverFileDetails _this;
877 public Xcls_HButtonBox25(Xcls_PopoverFileDetails _owner )
880 this.el = new Gtk.HButtonBox();
884 // set gobject values
885 this.el.margin_right = 4;
886 this.el.margin_left = 4;
887 this.el.margin_bottom = 4;
888 var child_0 = new Xcls_Button26( _this );
890 this.el.add ( child_0.el );
891 var child_1 = new Xcls_save_btn( _this );
893 this.el.add ( child_1.el );
896 // user defined functions
898 public class Xcls_Button26 : Object
900 public Gtk.Button el;
901 private Xcls_PopoverFileDetails _this;
907 public Xcls_Button26(Xcls_PopoverFileDetails _owner )
910 this.el = new Gtk.Button();
914 // set gobject values
915 this.el.label = "Cancel";
918 this.el.clicked.connect( () => {
925 // user defined functions
928 public class Xcls_save_btn : Object
930 public Gtk.Button el;
931 private Xcls_PopoverFileDetails _this;
937 public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
940 _this.save_btn = this;
941 this.el = new Gtk.Button();
945 // set gobject values
946 this.el.label = "Save";
949 this.el.clicked.connect( ( ) => {
954 if (_this.name.el.get_text().length < 1) {
955 StandardErrorDialog.show(
957 "You have to set Component name "
962 // what does this do?
964 var isNew = _this.file.name.length > 0 ? false : true;
966 if (!isNew && this.file.name != _this.name.el.get_text()) {
967 Xcls_StandardErrorDialog.singleton().show(
969 "Sorry changing names does not work yet. "
978 // FIXME - this may be more complicated...
979 //for (var i in this.def) {
980 // this.file[i] = this.get(i).el.get_text();
985 _this.updateFileFromEntry();
986 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
987 Xcls_StandardErrorDialog.singleton().show(
989 "The name you used already exists "
1000 var fn = _this.name.el.get_text();
1001 var dir = _this.project.firstPath();
1003 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
1004 Xcls_StandardErrorDialog.singleton().show(
1005 _this.mainwindow.el,
1006 "That file already exists"
1011 var f = JsRender.JsRender.factory(
1012 _this.file.project.xtype,
1014 dir + "/" + fn + ".bjs");
1020 _this.updateFileFromEntry();
1021 _this.file.loaded = true;
1023 _this.file.project.addFile(_this.file);
1032 _this.success(_this.project, _this.file);
1037 // user defined functions