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.filetype.el.hide();
114 if (c.path.length > 0) {
116 this.save_btn.el.set_label("Save");
118 this.save_btn.el.set_label("Create");
121 var ar = new Gee.ArrayList<string>();
122 _this.dbmodel.loadData(ar,"");
123 // load the modules... if relivant..
124 if (this.project.xtype == "Gtk") {
125 var p = (Project.Gtk)c.project;
126 var cg = p.compilegroups;
128 var iter = cg.map_iterator();
130 var key = iter.get_key();
131 if (key == "_default_") {
136 _this.dbmodel.loadData(ar, c.build_module);
142 //console.log('show all');
143 this.el.set_modal(true);
144 this.el.set_relative_to(btn);
146 this.el.set_position(Gtk.PositionType.RIGHT);
149 print("SHOWALL - POPIP\n");
151 this.name.el.grab_focus();
153 //this.success = c.success;
157 public class Xcls_Box2 : Object
160 private Xcls_PopoverFileDetails _this;
166 public Xcls_Box2(Xcls_PopoverFileDetails _owner )
169 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
173 // set gobject values
174 this.el.homogeneous = false;
175 var child_0 = new Xcls_HeaderBar3( _this );
177 this.el.pack_start ( child_0.el , false,true,0 );
178 var child_1 = new Xcls_Table4( _this );
180 this.el.pack_start ( child_1.el , false,false,4 );
181 var child_2 = new Xcls_HButtonBox25( _this );
183 this.el.pack_end ( child_2.el , false,true,0 );
186 // user defined functions
188 public class Xcls_HeaderBar3 : Object
190 public Gtk.HeaderBar el;
191 private Xcls_PopoverFileDetails _this;
197 public Xcls_HeaderBar3(Xcls_PopoverFileDetails _owner )
200 this.el = new Gtk.HeaderBar();
204 // set gobject values
205 this.el.title = "Add / Edit File";
208 // user defined functions
211 public class Xcls_Table4 : Object
214 private Xcls_PopoverFileDetails _this;
220 public Xcls_Table4(Xcls_PopoverFileDetails _owner )
223 this.el = new Gtk.Table( 7, 2, true );
227 // set gobject values
228 this.el.margin_right = 4;
229 this.el.margin_left = 4;
230 this.el.row_spacing = 2;
231 var child_0 = new Xcls_Label5( _this );
233 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
234 var child_1 = new Xcls_filetype( _this );
236 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
237 var child_2 = new Xcls_Label9( _this );
239 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
240 var child_3 = new Xcls_name( _this );
242 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
243 var child_4 = new Xcls_Label11( _this );
245 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
246 var child_5 = new Xcls_title( _this );
248 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
249 var child_6 = new Xcls_Label13( _this );
251 this.el.attach_defaults ( child_6.el , 0,1,3,4 );
252 var child_7 = new Xcls_region( _this );
254 this.el.attach_defaults ( child_7.el , 1,2,3,4 );
255 var child_8 = new Xcls_Label15( _this );
257 this.el.attach_defaults ( child_8.el , 0,1,4,5 );
258 var child_9 = new Xcls_parent( _this );
260 this.el.attach_defaults ( child_9.el , 1,2,4,5 );
261 var child_10 = new Xcls_Label17( _this );
263 this.el.attach_defaults ( child_10.el , 0,1,5,6 );
264 var child_11 = new Xcls_permname( _this );
266 this.el.attach_defaults ( child_11.el , 1,2,5,6 );
267 var child_12 = new Xcls_Label19( _this );
269 this.el.attach_defaults ( child_12.el , 0,1,6,7 );
270 var child_13 = new Xcls_modOrder( _this );
272 this.el.attach_defaults ( child_13.el , 1,2,6,7 );
273 var child_14 = new Xcls_Label21( _this );
275 this.el.attach_defaults ( child_14.el , 0,1,7,8 );
276 var child_15 = new Xcls_build_module( _this );
278 this.el.attach_defaults ( child_15.el , 1,2,7,8 );
281 // user defined functions
283 public class Xcls_Label5 : Object
286 private Xcls_PopoverFileDetails _this;
292 public Xcls_Label5(Xcls_PopoverFileDetails _owner )
295 this.el = new Gtk.Label( "File type" );
299 // set gobject values
300 this.el.justify = Gtk.Justification.RIGHT;
301 this.el.xalign = 0.900000f;
304 // user defined functions
307 public class Xcls_filetype : Object
309 public Gtk.ComboBox el;
310 private Xcls_PopoverFileDetails _this;
316 public Xcls_filetype(Xcls_PopoverFileDetails _owner )
319 _this.filetype = this;
320 this.el = new Gtk.ComboBox();
324 // set gobject values
325 var child_0 = new Xcls_ftdbcellrenderer( _this );
327 this.el.pack_start ( child_0.el , true );
328 var child_1 = new Xcls_ftdbmodel( _this );
330 this.el.set_model ( child_1.el );
334 this.el.add_attribute(_this.ftdbcellrenderer.el , "markup", 1 );
337 // user defined functions
339 public class Xcls_ftdbcellrenderer : Object
341 public Gtk.CellRendererText el;
342 private Xcls_PopoverFileDetails _this;
348 public Xcls_ftdbcellrenderer(Xcls_PopoverFileDetails _owner )
351 _this.ftdbcellrenderer = this;
352 this.el = new Gtk.CellRendererText();
356 // set gobject values
359 // user defined functions
362 public class Xcls_ftdbmodel : Object
364 public Gtk.ListStore el;
365 private Xcls_PopoverFileDetails _this;
371 public Xcls_ftdbmodel(Xcls_PopoverFileDetails _owner )
374 _this.ftdbmodel = this;
375 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
379 // set gobject values
382 // user defined functions
383 public void loadData (string cur) {
388 /// el.append(out iter);
391 // el.set_value(iter, 0, "");
392 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
397 el.set_value(iter, 0, "bjs");
398 el.set_value(iter, 1, "User Interface File (bjs)");
399 _this.filetype.el.set_active_iter(iter);
403 el.set_value(iter, 0, "vala");
404 el.set_value(iter, 1, "Vala");
406 _this.filetype.el.set_active_iter(iter);
413 el.set_value(iter, 0, "js");
414 el.set_value(iter, 1, "Javascript");
417 _this.filetype.el.set_active_iter(iter);
422 el.set_value(iter, 0, "css");
423 el.set_value(iter, 1, "CSS");
426 _this.filetype.el.set_active_iter(iter);
433 public class Xcls_Label9 : Object
436 private Xcls_PopoverFileDetails _this;
442 public Xcls_Label9(Xcls_PopoverFileDetails _owner )
445 this.el = new Gtk.Label( "Component Name" );
449 // set gobject values
450 this.el.justify = Gtk.Justification.RIGHT;
451 this.el.xalign = 0.900000f;
454 // user defined functions
457 public class Xcls_name : Object
460 private Xcls_PopoverFileDetails _this;
466 public Xcls_name(Xcls_PopoverFileDetails _owner )
470 this.el = new Gtk.Entry();
474 // set gobject values
475 this.el.visible = true;
478 // user defined functions
481 public class Xcls_Label11 : Object
484 private Xcls_PopoverFileDetails _this;
490 public Xcls_Label11(Xcls_PopoverFileDetails _owner )
493 this.el = new Gtk.Label( "Title" );
497 // set gobject values
498 this.el.justify = Gtk.Justification.RIGHT;
499 this.el.xalign = 0.900000f;
500 this.el.visible = true;
503 // user defined functions
506 public class Xcls_title : Object
509 private Xcls_PopoverFileDetails _this;
515 public Xcls_title(Xcls_PopoverFileDetails _owner )
519 this.el = new Gtk.Entry();
523 // set gobject values
524 this.el.visible = true;
527 // user defined functions
530 public class Xcls_Label13 : Object
533 private Xcls_PopoverFileDetails _this;
539 public Xcls_Label13(Xcls_PopoverFileDetails _owner )
542 this.el = new Gtk.Label( "Region" );
546 // set gobject values
547 this.el.justify = Gtk.Justification.RIGHT;
548 this.el.xalign = 0.900000f;
549 this.el.tooltip_text = "center, north, south, east, west";
550 this.el.visible = true;
553 // user defined functions
556 public class Xcls_region : Object
559 private Xcls_PopoverFileDetails _this;
565 public Xcls_region(Xcls_PopoverFileDetails _owner )
569 this.el = new Gtk.Entry();
573 // set gobject values
574 this.el.visible = true;
577 // user defined functions
580 public class Xcls_Label15 : Object
583 private Xcls_PopoverFileDetails _this;
589 public Xcls_Label15(Xcls_PopoverFileDetails _owner )
592 this.el = new Gtk.Label( "Parent Name" );
596 // set gobject values
597 this.el.justify = Gtk.Justification.RIGHT;
598 this.el.xalign = 0.900000f;
599 this.el.visible = true;
602 // user defined functions
605 public class Xcls_parent : Object
608 private Xcls_PopoverFileDetails _this;
614 public Xcls_parent(Xcls_PopoverFileDetails _owner )
618 this.el = new Gtk.Entry();
622 // set gobject values
623 this.el.visible = true;
626 // user defined functions
629 public class Xcls_Label17 : Object
632 private Xcls_PopoverFileDetails _this;
638 public Xcls_Label17(Xcls_PopoverFileDetails _owner )
641 this.el = new Gtk.Label( "Permission Name" );
645 // set gobject values
646 this.el.justify = Gtk.Justification.RIGHT;
647 this.el.xalign = 0.900000f;
648 this.el.visible = true;
651 // user defined functions
654 public class Xcls_permname : Object
657 private Xcls_PopoverFileDetails _this;
663 public Xcls_permname(Xcls_PopoverFileDetails _owner )
666 _this.permname = this;
667 this.el = new Gtk.Entry();
671 // set gobject values
672 this.el.visible = true;
675 // user defined functions
678 public class Xcls_Label19 : Object
681 private Xcls_PopoverFileDetails _this;
687 public Xcls_Label19(Xcls_PopoverFileDetails _owner )
690 this.el = new Gtk.Label( "Order (for tabs)" );
694 // set gobject values
695 this.el.justify = Gtk.Justification.RIGHT;
696 this.el.xalign = 0.900000f;
697 this.el.visible = true;
700 // user defined functions
703 public class Xcls_modOrder : Object
706 private Xcls_PopoverFileDetails _this;
712 public Xcls_modOrder(Xcls_PopoverFileDetails _owner )
715 _this.modOrder = this;
716 this.el = new Gtk.Entry();
720 // set gobject values
721 this.el.visible = true;
724 // user defined functions
727 public class Xcls_Label21 : Object
730 private Xcls_PopoverFileDetails _this;
736 public Xcls_Label21(Xcls_PopoverFileDetails _owner )
739 this.el = new Gtk.Label( "Module to build (Vala only)" );
743 // set gobject values
744 this.el.justify = Gtk.Justification.RIGHT;
745 this.el.xalign = 0.900000f;
746 this.el.visible = true;
749 // user defined functions
752 public class Xcls_build_module : Object
754 public Gtk.ComboBox el;
755 private Xcls_PopoverFileDetails _this;
761 public Xcls_build_module(Xcls_PopoverFileDetails _owner )
764 _this.build_module = this;
765 this.el = new Gtk.ComboBox();
769 // set gobject values
770 var child_0 = new Xcls_dbcellrenderer( _this );
772 this.el.pack_start ( child_0.el , true );
773 var child_1 = new Xcls_dbmodel( _this );
775 this.el.set_model ( child_1.el );
779 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
782 // user defined functions
784 public class Xcls_dbcellrenderer : Object
786 public Gtk.CellRendererText el;
787 private Xcls_PopoverFileDetails _this;
793 public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
796 _this.dbcellrenderer = this;
797 this.el = new Gtk.CellRendererText();
801 // set gobject values
804 // user defined functions
807 public class Xcls_dbmodel : Object
809 public Gtk.ListStore el;
810 private Xcls_PopoverFileDetails _this;
816 public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
819 _this.dbmodel = this;
820 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
824 // set gobject values
827 // user defined functions
828 public void loadData (Gee.ArrayList<string> data, string cur) {
833 /// el.append(out iter);
836 // el.set_value(iter, 0, "");
837 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
842 el.set_value(iter, 0, "");
843 el.set_value(iter, 1, "-- select a module --");
844 _this.build_module.el.set_active_iter(iter);
846 for (var i = 0; i < data.size;i++) {
851 el.set_value(iter, 0, data.get(i));
852 el.set_value(iter, 1, data.get(i));
854 if (data.get(i) == cur) {
855 _this.build_module.el.set_active_iter(iter);
859 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
866 public class Xcls_HButtonBox25 : Object
868 public Gtk.HButtonBox el;
869 private Xcls_PopoverFileDetails _this;
875 public Xcls_HButtonBox25(Xcls_PopoverFileDetails _owner )
878 this.el = new Gtk.HButtonBox();
882 // set gobject values
883 this.el.margin_right = 4;
884 this.el.margin_left = 4;
885 this.el.margin_bottom = 4;
886 var child_0 = new Xcls_Button26( _this );
888 this.el.add ( child_0.el );
889 var child_1 = new Xcls_save_btn( _this );
891 this.el.add ( child_1.el );
894 // user defined functions
896 public class Xcls_Button26 : Object
898 public Gtk.Button el;
899 private Xcls_PopoverFileDetails _this;
905 public Xcls_Button26(Xcls_PopoverFileDetails _owner )
908 this.el = new Gtk.Button();
912 // set gobject values
913 this.el.label = "Cancel";
916 this.el.clicked.connect( () => {
923 // user defined functions
926 public class Xcls_save_btn : Object
928 public Gtk.Button el;
929 private Xcls_PopoverFileDetails _this;
935 public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
938 _this.save_btn = this;
939 this.el = new Gtk.Button();
943 // set gobject values
944 this.el.label = "Save";
947 this.el.clicked.connect( ( ) => {
952 if (_this.name.el.get_text().length < 1) {
953 StandardErrorDialog.show(
955 "You have to set Component name "
960 // what does this do?
962 var isNew = _this.file.name.length > 0 ? false : true;
964 if (!isNew && this.file.name != _this.name.el.get_text()) {
965 Xcls_StandardErrorDialog.singleton().show(
967 "Sorry changing names does not work yet. "
976 // FIXME - this may be more complicated...
977 //for (var i in this.def) {
978 // this.file[i] = this.get(i).el.get_text();
983 _this.updateFileFromEntry();
984 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
985 Xcls_StandardErrorDialog.singleton().show(
987 "The name you used already exists "
998 var fn = _this.name.el.get_text();
999 var dir = _this.project.firstPath();
1001 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
1002 Xcls_StandardErrorDialog.singleton().show(
1003 _this.mainwindow.el,
1004 "That file already exists"
1009 var f = JsRender.JsRender.factory(
1010 _this.file.project.xtype,
1012 dir + "/" + fn + ".bjs");
1018 _this.updateFileFromEntry();
1019 _this.file.loaded = true;
1021 _this.file.project.addFile(_this.file);
1030 _this.success(_this.project, _this.file);
1035 // user defined functions