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.filetype.loadData();
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 (Gee.ArrayList<string> data, 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");
409 el.set_value(iter, 0, "js");
410 el.set_value(iter, 1, "Javascript");
416 el.set_value(iter, 0, "css");
417 el.set_value(iter, 1, "CSS");
424 public class Xcls_Label9 : Object
427 private Xcls_PopoverFileDetails _this;
433 public Xcls_Label9(Xcls_PopoverFileDetails _owner )
436 this.el = new Gtk.Label( "Component Name" );
440 // set gobject values
441 this.el.justify = Gtk.Justification.RIGHT;
442 this.el.xalign = 0.900000f;
445 // user defined functions
448 public class Xcls_name : Object
451 private Xcls_PopoverFileDetails _this;
457 public Xcls_name(Xcls_PopoverFileDetails _owner )
461 this.el = new Gtk.Entry();
465 // set gobject values
466 this.el.visible = true;
469 // user defined functions
472 public class Xcls_Label11 : Object
475 private Xcls_PopoverFileDetails _this;
481 public Xcls_Label11(Xcls_PopoverFileDetails _owner )
484 this.el = new Gtk.Label( "Title" );
488 // set gobject values
489 this.el.justify = Gtk.Justification.RIGHT;
490 this.el.xalign = 0.900000f;
491 this.el.visible = true;
494 // user defined functions
497 public class Xcls_title : Object
500 private Xcls_PopoverFileDetails _this;
506 public Xcls_title(Xcls_PopoverFileDetails _owner )
510 this.el = new Gtk.Entry();
514 // set gobject values
515 this.el.visible = true;
518 // user defined functions
521 public class Xcls_Label13 : Object
524 private Xcls_PopoverFileDetails _this;
530 public Xcls_Label13(Xcls_PopoverFileDetails _owner )
533 this.el = new Gtk.Label( "Region" );
537 // set gobject values
538 this.el.justify = Gtk.Justification.RIGHT;
539 this.el.xalign = 0.900000f;
540 this.el.tooltip_text = "center, north, south, east, west";
541 this.el.visible = true;
544 // user defined functions
547 public class Xcls_region : Object
550 private Xcls_PopoverFileDetails _this;
556 public Xcls_region(Xcls_PopoverFileDetails _owner )
560 this.el = new Gtk.Entry();
564 // set gobject values
565 this.el.visible = true;
568 // user defined functions
571 public class Xcls_Label15 : Object
574 private Xcls_PopoverFileDetails _this;
580 public Xcls_Label15(Xcls_PopoverFileDetails _owner )
583 this.el = new Gtk.Label( "Parent Name" );
587 // set gobject values
588 this.el.justify = Gtk.Justification.RIGHT;
589 this.el.xalign = 0.900000f;
590 this.el.visible = true;
593 // user defined functions
596 public class Xcls_parent : Object
599 private Xcls_PopoverFileDetails _this;
605 public Xcls_parent(Xcls_PopoverFileDetails _owner )
609 this.el = new Gtk.Entry();
613 // set gobject values
614 this.el.visible = true;
617 // user defined functions
620 public class Xcls_Label17 : Object
623 private Xcls_PopoverFileDetails _this;
629 public Xcls_Label17(Xcls_PopoverFileDetails _owner )
632 this.el = new Gtk.Label( "Permission Name" );
636 // set gobject values
637 this.el.justify = Gtk.Justification.RIGHT;
638 this.el.xalign = 0.900000f;
639 this.el.visible = true;
642 // user defined functions
645 public class Xcls_permname : Object
648 private Xcls_PopoverFileDetails _this;
654 public Xcls_permname(Xcls_PopoverFileDetails _owner )
657 _this.permname = this;
658 this.el = new Gtk.Entry();
662 // set gobject values
663 this.el.visible = true;
666 // user defined functions
669 public class Xcls_Label19 : Object
672 private Xcls_PopoverFileDetails _this;
678 public Xcls_Label19(Xcls_PopoverFileDetails _owner )
681 this.el = new Gtk.Label( "Order (for tabs)" );
685 // set gobject values
686 this.el.justify = Gtk.Justification.RIGHT;
687 this.el.xalign = 0.900000f;
688 this.el.visible = true;
691 // user defined functions
694 public class Xcls_modOrder : Object
697 private Xcls_PopoverFileDetails _this;
703 public Xcls_modOrder(Xcls_PopoverFileDetails _owner )
706 _this.modOrder = this;
707 this.el = new Gtk.Entry();
711 // set gobject values
712 this.el.visible = true;
715 // user defined functions
718 public class Xcls_Label21 : Object
721 private Xcls_PopoverFileDetails _this;
727 public Xcls_Label21(Xcls_PopoverFileDetails _owner )
730 this.el = new Gtk.Label( "Module to build (Vala only)" );
734 // set gobject values
735 this.el.justify = Gtk.Justification.RIGHT;
736 this.el.xalign = 0.900000f;
737 this.el.visible = true;
740 // user defined functions
743 public class Xcls_build_module : Object
745 public Gtk.ComboBox el;
746 private Xcls_PopoverFileDetails _this;
752 public Xcls_build_module(Xcls_PopoverFileDetails _owner )
755 _this.build_module = this;
756 this.el = new Gtk.ComboBox();
760 // set gobject values
761 var child_0 = new Xcls_dbcellrenderer( _this );
763 this.el.pack_start ( child_0.el , true );
764 var child_1 = new Xcls_dbmodel( _this );
766 this.el.set_model ( child_1.el );
770 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
773 // user defined functions
775 public class Xcls_dbcellrenderer : Object
777 public Gtk.CellRendererText el;
778 private Xcls_PopoverFileDetails _this;
784 public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
787 _this.dbcellrenderer = this;
788 this.el = new Gtk.CellRendererText();
792 // set gobject values
795 // user defined functions
798 public class Xcls_dbmodel : Object
800 public Gtk.ListStore el;
801 private Xcls_PopoverFileDetails _this;
807 public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
810 _this.dbmodel = this;
811 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
815 // set gobject values
818 // user defined functions
819 public void loadData (Gee.ArrayList<string> data, string cur) {
824 /// el.append(out iter);
827 // el.set_value(iter, 0, "");
828 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
833 el.set_value(iter, 0, "");
834 el.set_value(iter, 1, "-- select a module --");
835 _this.build_module.el.set_active_iter(iter);
837 for (var i = 0; i < data.size;i++) {
842 el.set_value(iter, 0, data.get(i));
843 el.set_value(iter, 1, data.get(i));
845 if (data.get(i) == cur) {
846 _this.build_module.el.set_active_iter(iter);
850 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
857 public class Xcls_HButtonBox25 : Object
859 public Gtk.HButtonBox el;
860 private Xcls_PopoverFileDetails _this;
866 public Xcls_HButtonBox25(Xcls_PopoverFileDetails _owner )
869 this.el = new Gtk.HButtonBox();
873 // set gobject values
874 this.el.margin_right = 4;
875 this.el.margin_left = 4;
876 this.el.margin_bottom = 4;
877 var child_0 = new Xcls_Button26( _this );
879 this.el.add ( child_0.el );
880 var child_1 = new Xcls_save_btn( _this );
882 this.el.add ( child_1.el );
885 // user defined functions
887 public class Xcls_Button26 : Object
889 public Gtk.Button el;
890 private Xcls_PopoverFileDetails _this;
896 public Xcls_Button26(Xcls_PopoverFileDetails _owner )
899 this.el = new Gtk.Button();
903 // set gobject values
904 this.el.label = "Cancel";
907 this.el.clicked.connect( () => {
914 // user defined functions
917 public class Xcls_save_btn : Object
919 public Gtk.Button el;
920 private Xcls_PopoverFileDetails _this;
926 public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
929 _this.save_btn = this;
930 this.el = new Gtk.Button();
934 // set gobject values
935 this.el.label = "Save";
938 this.el.clicked.connect( ( ) => {
943 if (_this.name.el.get_text().length < 1) {
944 StandardErrorDialog.show(
946 "You have to set Component name "
951 // what does this do?
953 var isNew = _this.file.name.length > 0 ? false : true;
955 if (!isNew && this.file.name != _this.name.el.get_text()) {
956 Xcls_StandardErrorDialog.singleton().show(
958 "Sorry changing names does not work yet. "
967 // FIXME - this may be more complicated...
968 //for (var i in this.def) {
969 // this.file[i] = this.get(i).el.get_text();
974 _this.updateFileFromEntry();
975 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
976 Xcls_StandardErrorDialog.singleton().show(
978 "The name you used already exists "
989 var fn = _this.name.el.get_text();
990 var dir = _this.project.firstPath();
992 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
993 Xcls_StandardErrorDialog.singleton().show(
995 "That file already exists"
1000 var f = JsRender.JsRender.factory(
1001 _this.file.project.xtype,
1003 dir + "/" + fn + ".bjs");
1009 _this.updateFileFromEntry();
1010 _this.file.loaded = true;
1012 _this.file.project.addFile(_this.file);
1021 _this.success(_this.project, _this.file);
1026 // user defined functions