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);
109 _this.ftdbmodel.loadData("bjs"); // fixme - need to determine type..
112 if (c.path.length > 0) {
114 this.save_btn.el.set_label("Save");
116 this.save_btn.el.set_label("Create");
119 var ar = new Gee.ArrayList<string>();
120 _this.dbmodel.loadData(ar,"");
121 // load the modules... if relivant..
122 if (this.project.xtype == "Gtk") {
123 var p = (Project.Gtk)c.project;
124 var cg = p.compilegroups;
126 var iter = cg.map_iterator();
128 var key = iter.get_key();
129 if (key == "_default_") {
134 _this.dbmodel.loadData(ar, c.build_module);
140 //console.log('show all');
141 this.el.set_modal(true);
142 this.el.set_relative_to(btn);
144 this.el.set_position(Gtk.PositionType.RIGHT);
147 print("SHOWALL - POPIP\n");
149 this.name.el.grab_focus();
151 //this.success = c.success;
155 public class Xcls_Box2 : Object
158 private Xcls_PopoverFileDetails _this;
164 public Xcls_Box2(Xcls_PopoverFileDetails _owner )
167 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
171 // set gobject values
172 this.el.homogeneous = false;
173 var child_0 = new Xcls_HeaderBar3( _this );
175 this.el.pack_start ( child_0.el , false,true,0 );
176 var child_1 = new Xcls_Table4( _this );
178 this.el.pack_start ( child_1.el , false,false,4 );
179 var child_2 = new Xcls_HButtonBox25( _this );
181 this.el.pack_end ( child_2.el , false,true,0 );
184 // user defined functions
186 public class Xcls_HeaderBar3 : Object
188 public Gtk.HeaderBar el;
189 private Xcls_PopoverFileDetails _this;
195 public Xcls_HeaderBar3(Xcls_PopoverFileDetails _owner )
198 this.el = new Gtk.HeaderBar();
202 // set gobject values
203 this.el.title = "Add / Edit File";
206 // user defined functions
209 public class Xcls_Table4 : Object
212 private Xcls_PopoverFileDetails _this;
218 public Xcls_Table4(Xcls_PopoverFileDetails _owner )
221 this.el = new Gtk.Table( 7, 2, true );
225 // set gobject values
226 this.el.margin_right = 4;
227 this.el.margin_left = 4;
228 this.el.row_spacing = 2;
229 var child_0 = new Xcls_Label5( _this );
231 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
232 var child_1 = new Xcls_filetype( _this );
234 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
235 var child_2 = new Xcls_Label9( _this );
237 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
238 var child_3 = new Xcls_name( _this );
240 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
241 var child_4 = new Xcls_Label11( _this );
243 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
244 var child_5 = new Xcls_title( _this );
246 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
247 var child_6 = new Xcls_Label13( _this );
249 this.el.attach_defaults ( child_6.el , 0,1,3,4 );
250 var child_7 = new Xcls_region( _this );
252 this.el.attach_defaults ( child_7.el , 1,2,3,4 );
253 var child_8 = new Xcls_Label15( _this );
255 this.el.attach_defaults ( child_8.el , 0,1,4,5 );
256 var child_9 = new Xcls_parent( _this );
258 this.el.attach_defaults ( child_9.el , 1,2,4,5 );
259 var child_10 = new Xcls_Label17( _this );
261 this.el.attach_defaults ( child_10.el , 0,1,5,6 );
262 var child_11 = new Xcls_permname( _this );
264 this.el.attach_defaults ( child_11.el , 1,2,5,6 );
265 var child_12 = new Xcls_Label19( _this );
267 this.el.attach_defaults ( child_12.el , 0,1,6,7 );
268 var child_13 = new Xcls_modOrder( _this );
270 this.el.attach_defaults ( child_13.el , 1,2,6,7 );
271 var child_14 = new Xcls_Label21( _this );
273 this.el.attach_defaults ( child_14.el , 0,1,7,8 );
274 var child_15 = new Xcls_build_module( _this );
276 this.el.attach_defaults ( child_15.el , 1,2,7,8 );
279 // user defined functions
281 public class Xcls_Label5 : Object
284 private Xcls_PopoverFileDetails _this;
290 public Xcls_Label5(Xcls_PopoverFileDetails _owner )
293 this.el = new Gtk.Label( "File type" );
297 // set gobject values
298 this.el.justify = Gtk.Justification.RIGHT;
299 this.el.xalign = 0.900000f;
302 // user defined functions
305 public class Xcls_filetype : Object
307 public Gtk.ComboBox el;
308 private Xcls_PopoverFileDetails _this;
314 public Xcls_filetype(Xcls_PopoverFileDetails _owner )
317 _this.filetype = this;
318 this.el = new Gtk.ComboBox();
322 // set gobject values
323 var child_0 = new Xcls_ftdbcellrenderer( _this );
325 this.el.pack_start ( child_0.el , true );
326 var child_1 = new Xcls_ftdbmodel( _this );
328 this.el.set_model ( child_1.el );
332 this.el.add_attribute(_this.ftdbcellrenderer.el , "markup", 1 );
335 // user defined functions
337 public class Xcls_ftdbcellrenderer : Object
339 public Gtk.CellRendererText el;
340 private Xcls_PopoverFileDetails _this;
346 public Xcls_ftdbcellrenderer(Xcls_PopoverFileDetails _owner )
349 _this.ftdbcellrenderer = this;
350 this.el = new Gtk.CellRendererText();
354 // set gobject values
357 // user defined functions
360 public class Xcls_ftdbmodel : Object
362 public Gtk.ListStore el;
363 private Xcls_PopoverFileDetails _this;
369 public Xcls_ftdbmodel(Xcls_PopoverFileDetails _owner )
372 _this.ftdbmodel = this;
373 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
377 // set gobject values
380 // user defined functions
381 public void loadData (string cur) {
386 /// el.append(out iter);
389 // el.set_value(iter, 0, "");
390 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
395 el.set_value(iter, 0, "bjs");
396 el.set_value(iter, 1, "User Interface File (bjs)");
397 _this.filetype.el.set_active_iter(iter);
401 el.set_value(iter, 0, "vala");
402 el.set_value(iter, 1, "Vala");
404 _this.filetype.el.set_active_iter(iter);
411 el.set_value(iter, 0, "js");
412 el.set_value(iter, 1, "Javascript");
415 _this.filetype.el.set_active_iter(iter);
420 el.set_value(iter, 0, "css");
421 el.set_value(iter, 1, "CSS");
424 _this.filetype.el.set_active_iter(iter);
431 public class Xcls_Label9 : Object
434 private Xcls_PopoverFileDetails _this;
440 public Xcls_Label9(Xcls_PopoverFileDetails _owner )
443 this.el = new Gtk.Label( "Component Name" );
447 // set gobject values
448 this.el.justify = Gtk.Justification.RIGHT;
449 this.el.xalign = 0.900000f;
452 // user defined functions
455 public class Xcls_name : Object
458 private Xcls_PopoverFileDetails _this;
464 public Xcls_name(Xcls_PopoverFileDetails _owner )
468 this.el = new Gtk.Entry();
472 // set gobject values
473 this.el.visible = true;
476 // user defined functions
479 public class Xcls_Label11 : Object
482 private Xcls_PopoverFileDetails _this;
488 public Xcls_Label11(Xcls_PopoverFileDetails _owner )
491 this.el = new Gtk.Label( "Title" );
495 // set gobject values
496 this.el.justify = Gtk.Justification.RIGHT;
497 this.el.xalign = 0.900000f;
498 this.el.visible = true;
501 // user defined functions
504 public class Xcls_title : Object
507 private Xcls_PopoverFileDetails _this;
513 public Xcls_title(Xcls_PopoverFileDetails _owner )
517 this.el = new Gtk.Entry();
521 // set gobject values
522 this.el.visible = true;
525 // user defined functions
528 public class Xcls_Label13 : Object
531 private Xcls_PopoverFileDetails _this;
537 public Xcls_Label13(Xcls_PopoverFileDetails _owner )
540 this.el = new Gtk.Label( "Region" );
544 // set gobject values
545 this.el.justify = Gtk.Justification.RIGHT;
546 this.el.xalign = 0.900000f;
547 this.el.tooltip_text = "center, north, south, east, west";
548 this.el.visible = true;
551 // user defined functions
554 public class Xcls_region : Object
557 private Xcls_PopoverFileDetails _this;
563 public Xcls_region(Xcls_PopoverFileDetails _owner )
567 this.el = new Gtk.Entry();
571 // set gobject values
572 this.el.visible = true;
575 // user defined functions
578 public class Xcls_Label15 : Object
581 private Xcls_PopoverFileDetails _this;
587 public Xcls_Label15(Xcls_PopoverFileDetails _owner )
590 this.el = new Gtk.Label( "Parent Name" );
594 // set gobject values
595 this.el.justify = Gtk.Justification.RIGHT;
596 this.el.xalign = 0.900000f;
597 this.el.visible = true;
600 // user defined functions
603 public class Xcls_parent : Object
606 private Xcls_PopoverFileDetails _this;
612 public Xcls_parent(Xcls_PopoverFileDetails _owner )
616 this.el = new Gtk.Entry();
620 // set gobject values
621 this.el.visible = true;
624 // user defined functions
627 public class Xcls_Label17 : Object
630 private Xcls_PopoverFileDetails _this;
636 public Xcls_Label17(Xcls_PopoverFileDetails _owner )
639 this.el = new Gtk.Label( "Permission Name" );
643 // set gobject values
644 this.el.justify = Gtk.Justification.RIGHT;
645 this.el.xalign = 0.900000f;
646 this.el.visible = true;
649 // user defined functions
652 public class Xcls_permname : Object
655 private Xcls_PopoverFileDetails _this;
661 public Xcls_permname(Xcls_PopoverFileDetails _owner )
664 _this.permname = this;
665 this.el = new Gtk.Entry();
669 // set gobject values
670 this.el.visible = true;
673 // user defined functions
676 public class Xcls_Label19 : Object
679 private Xcls_PopoverFileDetails _this;
685 public Xcls_Label19(Xcls_PopoverFileDetails _owner )
688 this.el = new Gtk.Label( "Order (for tabs)" );
692 // set gobject values
693 this.el.justify = Gtk.Justification.RIGHT;
694 this.el.xalign = 0.900000f;
695 this.el.visible = true;
698 // user defined functions
701 public class Xcls_modOrder : Object
704 private Xcls_PopoverFileDetails _this;
710 public Xcls_modOrder(Xcls_PopoverFileDetails _owner )
713 _this.modOrder = this;
714 this.el = new Gtk.Entry();
718 // set gobject values
719 this.el.visible = true;
722 // user defined functions
725 public class Xcls_Label21 : Object
728 private Xcls_PopoverFileDetails _this;
734 public Xcls_Label21(Xcls_PopoverFileDetails _owner )
737 this.el = new Gtk.Label( "Module to build (Vala only)" );
741 // set gobject values
742 this.el.justify = Gtk.Justification.RIGHT;
743 this.el.xalign = 0.900000f;
744 this.el.visible = true;
747 // user defined functions
750 public class Xcls_build_module : Object
752 public Gtk.ComboBox el;
753 private Xcls_PopoverFileDetails _this;
759 public Xcls_build_module(Xcls_PopoverFileDetails _owner )
762 _this.build_module = this;
763 this.el = new Gtk.ComboBox();
767 // set gobject values
768 var child_0 = new Xcls_dbcellrenderer( _this );
770 this.el.pack_start ( child_0.el , true );
771 var child_1 = new Xcls_dbmodel( _this );
773 this.el.set_model ( child_1.el );
777 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
780 // user defined functions
782 public class Xcls_dbcellrenderer : Object
784 public Gtk.CellRendererText el;
785 private Xcls_PopoverFileDetails _this;
791 public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
794 _this.dbcellrenderer = this;
795 this.el = new Gtk.CellRendererText();
799 // set gobject values
802 // user defined functions
805 public class Xcls_dbmodel : Object
807 public Gtk.ListStore el;
808 private Xcls_PopoverFileDetails _this;
814 public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
817 _this.dbmodel = this;
818 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
822 // set gobject values
825 // user defined functions
826 public void loadData (Gee.ArrayList<string> data, string cur) {
831 /// el.append(out iter);
834 // el.set_value(iter, 0, "");
835 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
840 el.set_value(iter, 0, "");
841 el.set_value(iter, 1, "-- select a module --");
842 _this.build_module.el.set_active_iter(iter);
844 for (var i = 0; i < data.size;i++) {
849 el.set_value(iter, 0, data.get(i));
850 el.set_value(iter, 1, data.get(i));
852 if (data.get(i) == cur) {
853 _this.build_module.el.set_active_iter(iter);
857 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
864 public class Xcls_HButtonBox25 : Object
866 public Gtk.HButtonBox el;
867 private Xcls_PopoverFileDetails _this;
873 public Xcls_HButtonBox25(Xcls_PopoverFileDetails _owner )
876 this.el = new Gtk.HButtonBox();
880 // set gobject values
881 this.el.margin_right = 4;
882 this.el.margin_left = 4;
883 this.el.margin_bottom = 4;
884 var child_0 = new Xcls_Button26( _this );
886 this.el.add ( child_0.el );
887 var child_1 = new Xcls_save_btn( _this );
889 this.el.add ( child_1.el );
892 // user defined functions
894 public class Xcls_Button26 : Object
896 public Gtk.Button el;
897 private Xcls_PopoverFileDetails _this;
903 public Xcls_Button26(Xcls_PopoverFileDetails _owner )
906 this.el = new Gtk.Button();
910 // set gobject values
911 this.el.label = "Cancel";
914 this.el.clicked.connect( () => {
921 // user defined functions
924 public class Xcls_save_btn : Object
926 public Gtk.Button el;
927 private Xcls_PopoverFileDetails _this;
933 public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
936 _this.save_btn = this;
937 this.el = new Gtk.Button();
941 // set gobject values
942 this.el.label = "Save";
945 this.el.clicked.connect( ( ) => {
950 if (_this.name.el.get_text().length < 1) {
951 StandardErrorDialog.show(
953 "You have to set Component name "
958 // what does this do?
960 var isNew = _this.file.name.length > 0 ? false : true;
962 if (!isNew && this.file.name != _this.name.el.get_text()) {
963 Xcls_StandardErrorDialog.singleton().show(
965 "Sorry changing names does not work yet. "
974 // FIXME - this may be more complicated...
975 //for (var i in this.def) {
976 // this.file[i] = this.get(i).el.get_text();
981 _this.updateFileFromEntry();
982 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
983 Xcls_StandardErrorDialog.singleton().show(
985 "The name you used already exists "
996 var fn = _this.name.el.get_text();
997 var dir = _this.project.firstPath();
999 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
1000 Xcls_StandardErrorDialog.singleton().show(
1001 _this.mainwindow.el,
1002 "That file already exists"
1007 var f = JsRender.JsRender.factory(
1008 _this.file.project.xtype,
1010 dir + "/" + fn + ".bjs");
1016 _this.updateFileFromEntry();
1017 _this.file.loaded = true;
1019 _this.file.project.addFile(_this.file);
1028 _this.success(_this.project, _this.file);
1033 // user defined functions