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_grid grid;
16 public Xcls_filetypelbl filetypelbl;
17 public Xcls_filetype filetype;
18 public Xcls_ftdbcellrenderer ftdbcellrenderer;
19 public Xcls_ftdbmodel ftdbmodel;
20 public Xcls_name name;
21 public Xcls_title title;
22 public Xcls_region region;
23 public Xcls_parent parent;
24 public Xcls_permname permname;
25 public Xcls_modOrder modOrder;
26 public Xcls_build_module build_module;
27 public Xcls_dbcellrenderer dbcellrenderer;
28 public Xcls_dbmodel dbmodel;
29 public Xcls_save_btn save_btn;
32 public signal void success (Project.Project pr, JsRender.JsRender file);
34 public Project.Project project;
35 public JsRender.JsRender file;
36 public Xcls_MainWindow mainwindow;
39 public Xcls_PopoverFileDetails()
42 this.el = new Gtk.Popover( null );
47 this.mainwindow = null;
50 this.el.border_width = 0;
52 this.el.position = Gtk.PositionType.RIGHT;
53 var child_0 = new Xcls_Box2( _this );
55 this.el.add ( child_0.el );
58 this.el.closed.connect( () => {
66 // user defined functions
67 public void updateFileFromEntry () {
69 _this.file.title = _this.title.el.get_text();
70 _this.file.region = _this.region.el.get_text();
71 _this.file.parent = _this.parent.el.get_text();
72 _this.file.permname = _this.permname.el.get_text();
73 _this.file.modOrder = _this.modOrder.el.get_text();
75 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
76 _this.file.renameTo(_this.name.el.get_text());
78 // store the module...
79 _this.file.build_module = "";
81 if (_this.build_module.el.get_active_iter (out iter)) {
83 this.dbmodel.el.get_value (iter, 0, out vfname);
84 if (((string)vfname).length > 0) {
85 _this.file.build_module = (string)vfname;
94 public void show (JsRender.JsRender c, Gtk.Widget btn)
96 this.project = c.project;
104 _this.name.el.set_text(c.name);
105 _this.title.el.set_text(c.title);
106 _this.parent.el.set_text(c.parent);
107 _this.region.el.set_text(c.region);
108 _this.modOrder.el.set_text(c.modOrder);
109 _this.permname.el.set_text(c.permname);
114 _this.filetype.el.hide();
115 _this.filetypelbl.el.hide();
118 if (c.path.length > 0) {
119 this.save_btn.el.set_label("Save");
121 this.save_btn.el.set_label("Create");
122 _this.ftdbmodel.loadData("bjs"); // fixme - need to determine type..
123 _this.filetype.el.show();
124 _this.filetypelbl.el.show();
127 var ar = new Gee.ArrayList<string>();
128 _this.dbmodel.loadData(ar,"");
129 // load the modules... if relivant..
130 if (this.project.xtype == "Gtk") {
131 var p = (Project.Gtk)c.project;
132 var cg = p.compilegroups;
134 var iter = cg.map_iterator();
136 var key = iter.get_key();
137 if (key == "_default_") {
142 _this.dbmodel.loadData(ar, c.build_module);
148 //console.log('show all');
149 this.el.set_modal(true);
150 this.el.set_relative_to(btn);
152 this.el.set_position(Gtk.PositionType.RIGHT);
155 print("SHOWALL - POPIP\n");
157 this.name.el.grab_focus();
159 //this.success = c.success;
163 public class Xcls_Box2 : Object
166 private Xcls_PopoverFileDetails _this;
172 public Xcls_Box2(Xcls_PopoverFileDetails _owner )
175 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
179 // set gobject values
180 this.el.homogeneous = false;
181 var child_0 = new Xcls_HeaderBar3( _this );
183 this.el.pack_start ( child_0.el , false,true,0 );
184 var child_1 = new Xcls_grid( _this );
186 this.el.pack_start ( child_1.el , false,false,4 );
187 var child_2 = new Xcls_HButtonBox25( _this );
189 this.el.pack_end ( child_2.el , false,true,0 );
192 // user defined functions
194 public class Xcls_HeaderBar3 : Object
196 public Gtk.HeaderBar el;
197 private Xcls_PopoverFileDetails _this;
203 public Xcls_HeaderBar3(Xcls_PopoverFileDetails _owner )
206 this.el = new Gtk.HeaderBar();
210 // set gobject values
211 this.el.title = "Add / Edit File";
214 // user defined functions
217 public class Xcls_grid : Object
220 private Xcls_PopoverFileDetails _this;
226 public Xcls_grid(Xcls_PopoverFileDetails _owner )
230 this.el = new Gtk.Grid();
234 // set gobject values
235 this.el.margin_right = 4;
236 this.el.margin_left = 4;
237 this.el.row_spacing = 2;
238 var child_0 = new Xcls_filetypelbl( _this );
240 this.el.attach ( child_0.el , 0,0,1,1 );
241 var child_1 = new Xcls_filetype( _this );
243 this.el.attach ( child_1.el , 1,0,1,1 );
244 var child_2 = new Xcls_Label9( _this );
246 this.el.attach ( child_2.el , 0,1,1,1 );
247 var child_3 = new Xcls_name( _this );
249 this.el.attach ( child_3.el , 1,1,1,1 );
250 var child_4 = new Xcls_Label11( _this );
252 this.el.attach ( child_4.el , 0,2,1,1 );
253 var child_5 = new Xcls_title( _this );
255 this.el.attach ( child_5.el , 1,2,1,1 );
256 var child_6 = new Xcls_Label13( _this );
258 this.el.attach ( child_6.el , 0,3,1,1 );
259 var child_7 = new Xcls_region( _this );
261 this.el.attach ( child_7.el , 1,3,1,1 );
262 var child_8 = new Xcls_Label15( _this );
264 this.el.attach ( child_8.el , 0,4,1,1 );
265 var child_9 = new Xcls_parent( _this );
267 this.el.attach ( child_9.el , 1,4,1,1 );
268 var child_10 = new Xcls_Label17( _this );
270 this.el.attach ( child_10.el , 0,5,1,1 );
271 var child_11 = new Xcls_permname( _this );
273 this.el.attach ( child_11.el , 1,5,1,1 );
274 var child_12 = new Xcls_Label19( _this );
276 this.el.attach ( child_12.el , 0,6,1,1 );
277 var child_13 = new Xcls_modOrder( _this );
279 this.el.attach ( child_13.el , 1,6,1,1 );
280 var child_14 = new Xcls_Label21( _this );
282 this.el.attach ( child_14.el , 0,7,1,1 );
283 var child_15 = new Xcls_build_module( _this );
285 this.el.attach ( child_15.el , 1,7,1,1 );
288 // user defined functions
290 public class Xcls_filetypelbl : Object
293 private Xcls_PopoverFileDetails _this;
299 public Xcls_filetypelbl(Xcls_PopoverFileDetails _owner )
302 _this.filetypelbl = this;
303 this.el = new Gtk.Label( "File type" );
307 // set gobject values
308 this.el.justify = Gtk.Justification.RIGHT;
309 this.el.xalign = 0.900000f;
312 // user defined functions
315 public class Xcls_filetype : Object
317 public Gtk.ComboBox el;
318 private Xcls_PopoverFileDetails _this;
324 public Xcls_filetype(Xcls_PopoverFileDetails _owner )
327 _this.filetype = this;
328 this.el = new Gtk.ComboBox();
332 // set gobject values
333 var child_0 = new Xcls_ftdbcellrenderer( _this );
335 this.el.pack_start ( child_0.el , true );
336 var child_1 = new Xcls_ftdbmodel( _this );
338 this.el.set_model ( child_1.el );
342 this.el.add_attribute(_this.ftdbcellrenderer.el , "markup", 1 );
345 this.el.changed.connect( () => {
348 if (this.el.get_active_iter(out iter)) {
350 _this.ftdbmodel.el.get_value (iter, 0, out vfname);
351 is_bjs = ((string)vfname) == "bjs";
354 for (var i = 2; i < 8;i++) {
355 var el = _this.grid.el.get_child_at(0,i);
361 el = _this.grid.el.get_child_at(1,i);
375 // user defined functions
377 public class Xcls_ftdbcellrenderer : Object
379 public Gtk.CellRendererText el;
380 private Xcls_PopoverFileDetails _this;
386 public Xcls_ftdbcellrenderer(Xcls_PopoverFileDetails _owner )
389 _this.ftdbcellrenderer = this;
390 this.el = new Gtk.CellRendererText();
394 // set gobject values
397 // user defined functions
400 public class Xcls_ftdbmodel : Object
402 public Gtk.ListStore el;
403 private Xcls_PopoverFileDetails _this;
409 public Xcls_ftdbmodel(Xcls_PopoverFileDetails _owner )
412 _this.ftdbmodel = this;
413 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
417 // set gobject values
420 // user defined functions
421 public void loadData (string cur) {
426 /// el.append(out iter);
429 // el.set_value(iter, 0, "");
430 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
435 el.set_value(iter, 0, "bjs");
436 el.set_value(iter, 1, "User Interface File (bjs)");
437 _this.filetype.el.set_active_iter(iter);
441 el.set_value(iter, 0, "vala");
442 el.set_value(iter, 1, "Vala");
444 _this.filetype.el.set_active_iter(iter);
451 el.set_value(iter, 0, "js");
452 el.set_value(iter, 1, "Javascript");
455 _this.filetype.el.set_active_iter(iter);
460 el.set_value(iter, 0, "css");
461 el.set_value(iter, 1, "CSS");
464 _this.filetype.el.set_active_iter(iter);
471 public class Xcls_Label9 : Object
474 private Xcls_PopoverFileDetails _this;
480 public Xcls_Label9(Xcls_PopoverFileDetails _owner )
483 this.el = new Gtk.Label( "Component Name" );
487 // set gobject values
488 this.el.justify = Gtk.Justification.RIGHT;
489 this.el.xalign = 0.900000f;
492 // user defined functions
495 public class Xcls_name : Object
498 private Xcls_PopoverFileDetails _this;
504 public Xcls_name(Xcls_PopoverFileDetails _owner )
508 this.el = new Gtk.Entry();
512 // set gobject values
513 this.el.visible = true;
516 // user defined functions
519 public class Xcls_Label11 : Object
522 private Xcls_PopoverFileDetails _this;
528 public Xcls_Label11(Xcls_PopoverFileDetails _owner )
531 this.el = new Gtk.Label( "Title" );
535 // set gobject values
536 this.el.justify = Gtk.Justification.RIGHT;
537 this.el.xalign = 0.900000f;
538 this.el.visible = true;
541 // user defined functions
544 public class Xcls_title : Object
547 private Xcls_PopoverFileDetails _this;
553 public Xcls_title(Xcls_PopoverFileDetails _owner )
557 this.el = new Gtk.Entry();
561 // set gobject values
562 this.el.visible = true;
565 // user defined functions
568 public class Xcls_Label13 : Object
571 private Xcls_PopoverFileDetails _this;
577 public Xcls_Label13(Xcls_PopoverFileDetails _owner )
580 this.el = new Gtk.Label( "Region" );
584 // set gobject values
585 this.el.justify = Gtk.Justification.RIGHT;
586 this.el.xalign = 0.900000f;
587 this.el.tooltip_text = "center, north, south, east, west";
588 this.el.visible = true;
591 // user defined functions
594 public class Xcls_region : Object
597 private Xcls_PopoverFileDetails _this;
603 public Xcls_region(Xcls_PopoverFileDetails _owner )
607 this.el = new Gtk.Entry();
611 // set gobject values
612 this.el.visible = true;
615 // user defined functions
618 public class Xcls_Label15 : Object
621 private Xcls_PopoverFileDetails _this;
627 public Xcls_Label15(Xcls_PopoverFileDetails _owner )
630 this.el = new Gtk.Label( "Parent Name" );
634 // set gobject values
635 this.el.justify = Gtk.Justification.RIGHT;
636 this.el.xalign = 0.900000f;
637 this.el.visible = true;
640 // user defined functions
643 public class Xcls_parent : Object
646 private Xcls_PopoverFileDetails _this;
652 public Xcls_parent(Xcls_PopoverFileDetails _owner )
656 this.el = new Gtk.Entry();
660 // set gobject values
661 this.el.visible = true;
664 // user defined functions
667 public class Xcls_Label17 : Object
670 private Xcls_PopoverFileDetails _this;
676 public Xcls_Label17(Xcls_PopoverFileDetails _owner )
679 this.el = new Gtk.Label( "Permission Name" );
683 // set gobject values
684 this.el.justify = Gtk.Justification.RIGHT;
685 this.el.xalign = 0.900000f;
686 this.el.visible = true;
689 // user defined functions
692 public class Xcls_permname : Object
695 private Xcls_PopoverFileDetails _this;
701 public Xcls_permname(Xcls_PopoverFileDetails _owner )
704 _this.permname = this;
705 this.el = new Gtk.Entry();
709 // set gobject values
710 this.el.visible = true;
713 // user defined functions
716 public class Xcls_Label19 : Object
719 private Xcls_PopoverFileDetails _this;
725 public Xcls_Label19(Xcls_PopoverFileDetails _owner )
728 this.el = new Gtk.Label( "Order (for tabs)" );
732 // set gobject values
733 this.el.justify = Gtk.Justification.RIGHT;
734 this.el.xalign = 0.900000f;
735 this.el.visible = true;
738 // user defined functions
741 public class Xcls_modOrder : Object
744 private Xcls_PopoverFileDetails _this;
750 public Xcls_modOrder(Xcls_PopoverFileDetails _owner )
753 _this.modOrder = this;
754 this.el = new Gtk.Entry();
758 // set gobject values
759 this.el.visible = true;
762 // user defined functions
765 public class Xcls_Label21 : Object
768 private Xcls_PopoverFileDetails _this;
774 public Xcls_Label21(Xcls_PopoverFileDetails _owner )
777 this.el = new Gtk.Label( "Module to build (Vala only)" );
781 // set gobject values
782 this.el.justify = Gtk.Justification.RIGHT;
783 this.el.xalign = 0.900000f;
784 this.el.visible = true;
787 // user defined functions
790 public class Xcls_build_module : Object
792 public Gtk.ComboBox el;
793 private Xcls_PopoverFileDetails _this;
799 public Xcls_build_module(Xcls_PopoverFileDetails _owner )
802 _this.build_module = this;
803 this.el = new Gtk.ComboBox();
807 // set gobject values
808 var child_0 = new Xcls_dbcellrenderer( _this );
810 this.el.pack_start ( child_0.el , true );
811 var child_1 = new Xcls_dbmodel( _this );
813 this.el.set_model ( child_1.el );
817 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
820 // user defined functions
822 public class Xcls_dbcellrenderer : Object
824 public Gtk.CellRendererText el;
825 private Xcls_PopoverFileDetails _this;
831 public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
834 _this.dbcellrenderer = this;
835 this.el = new Gtk.CellRendererText();
839 // set gobject values
842 // user defined functions
845 public class Xcls_dbmodel : Object
847 public Gtk.ListStore el;
848 private Xcls_PopoverFileDetails _this;
854 public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
857 _this.dbmodel = this;
858 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
862 // set gobject values
865 // user defined functions
866 public void loadData (Gee.ArrayList<string> data, string cur) {
871 /// el.append(out iter);
874 // el.set_value(iter, 0, "");
875 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
880 el.set_value(iter, 0, "");
881 el.set_value(iter, 1, "-- select a module --");
882 _this.build_module.el.set_active_iter(iter);
884 for (var i = 0; i < data.size;i++) {
889 el.set_value(iter, 0, data.get(i));
890 el.set_value(iter, 1, data.get(i));
892 if (data.get(i) == cur) {
893 _this.build_module.el.set_active_iter(iter);
897 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
904 public class Xcls_HButtonBox25 : Object
906 public Gtk.HButtonBox el;
907 private Xcls_PopoverFileDetails _this;
913 public Xcls_HButtonBox25(Xcls_PopoverFileDetails _owner )
916 this.el = new Gtk.HButtonBox();
920 // set gobject values
921 this.el.margin_right = 4;
922 this.el.margin_left = 4;
923 this.el.margin_bottom = 4;
924 var child_0 = new Xcls_Button26( _this );
926 this.el.add ( child_0.el );
927 var child_1 = new Xcls_save_btn( _this );
929 this.el.add ( child_1.el );
932 // user defined functions
934 public class Xcls_Button26 : Object
936 public Gtk.Button el;
937 private Xcls_PopoverFileDetails _this;
943 public Xcls_Button26(Xcls_PopoverFileDetails _owner )
946 this.el = new Gtk.Button();
950 // set gobject values
951 this.el.label = "Cancel";
954 this.el.clicked.connect( () => {
961 // user defined functions
964 public class Xcls_save_btn : Object
966 public Gtk.Button el;
967 private Xcls_PopoverFileDetails _this;
973 public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
976 _this.save_btn = this;
977 this.el = new Gtk.Button();
981 // set gobject values
982 this.el.label = "Save";
985 this.el.clicked.connect( ( ) => {
990 if (_this.name.el.get_text().length < 1) {
991 StandardErrorDialog.show(
993 "You have to set Component name "
998 // what does this do?
1000 var isNew = _this.file.name.length > 0 ? false : true;
1002 if (!isNew && this.file.name != _this.name.el.get_text()) {
1003 Xcls_StandardErrorDialog.singleton().show(
1005 "Sorry changing names does not work yet. "
1014 // FIXME - this may be more complicated...
1015 //for (var i in this.def) {
1016 // this.file[i] = this.get(i).el.get_text();
1021 _this.updateFileFromEntry();
1022 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
1023 Xcls_StandardErrorDialog.singleton().show(
1024 _this.mainwindow.el,
1025 "The name you used already exists "
1036 var fn = _this.name.el.get_text();
1037 var dir = _this.project.firstPath();
1039 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
1040 Xcls_StandardErrorDialog.singleton().show(
1041 _this.mainwindow.el,
1042 "That file already exists"
1047 var f = JsRender.JsRender.factory(
1048 _this.file.project.xtype,
1050 dir + "/" + fn + ".bjs");
1056 _this.updateFileFromEntry();
1057 _this.file.loaded = true;
1059 _this.file.project.addFile(_this.file);
1068 _this.success(_this.project, _this.file);
1073 // user defined functions