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_dbcellrenderer dbcellrenderer;
17 public Xcls_dbmodel dbmodel;
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 if (c.path.length > 0) {
111 this.save_btn.el.set_label("Save");
113 this.save_btn.el.set_label("Create");
116 var ar = new Gee.ArrayList<string>();
117 _this.dbmodel.loadData(ar,"");
118 // load the modules... if relivant..
119 if (this.project.xtype == "Gtk") {
120 var p = (Project.Gtk)c.project;
121 var cg = p.compilegroups;
123 var iter = cg.map_iterator();
125 var key = iter.get_key();
126 if (key == "_default_") {
131 _this.dbmodel.loadData(ar, c.build_module);
137 //console.log('show all');
138 this.el.set_modal(true);
139 this.el.set_relative_to(btn);
141 this.el.set_position(Gtk.PositionType.RIGHT);
144 print("SHOWALL - POPIP\n");
146 this.name.el.grab_focus();
148 //this.success = c.success;
152 public class Xcls_Box2 : Object
155 private Xcls_PopoverFileDetails _this;
161 public Xcls_Box2(Xcls_PopoverFileDetails _owner )
164 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
168 // set gobject values
169 this.el.homogeneous = false;
170 var child_0 = new Xcls_HeaderBar3( _this );
172 this.el.pack_start ( child_0.el , false,true,0 );
173 var child_1 = new Xcls_Table4( _this );
175 this.el.pack_start ( child_1.el , false,false,4 );
176 var child_2 = new Xcls_HButtonBox25( _this );
178 this.el.pack_end ( child_2.el , false,true,0 );
181 // user defined functions
183 public class Xcls_HeaderBar3 : Object
185 public Gtk.HeaderBar el;
186 private Xcls_PopoverFileDetails _this;
192 public Xcls_HeaderBar3(Xcls_PopoverFileDetails _owner )
195 this.el = new Gtk.HeaderBar();
199 // set gobject values
200 this.el.title = "Add / Edit File";
203 // user defined functions
206 public class Xcls_Table4 : Object
209 private Xcls_PopoverFileDetails _this;
215 public Xcls_Table4(Xcls_PopoverFileDetails _owner )
218 this.el = new Gtk.Table( 7, 2, true );
222 // set gobject values
223 this.el.margin_right = 4;
224 this.el.margin_left = 4;
225 this.el.row_spacing = 2;
226 var child_0 = new Xcls_Label5( _this );
228 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
229 var child_1 = new Xcls_filetype( _this );
231 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
232 var child_2 = new Xcls_Label9( _this );
234 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
235 var child_3 = new Xcls_name( _this );
237 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
238 var child_4 = new Xcls_Label11( _this );
240 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
241 var child_5 = new Xcls_title( _this );
243 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
244 var child_6 = new Xcls_Label13( _this );
246 this.el.attach_defaults ( child_6.el , 0,1,3,4 );
247 var child_7 = new Xcls_region( _this );
249 this.el.attach_defaults ( child_7.el , 1,2,3,4 );
250 var child_8 = new Xcls_Label15( _this );
252 this.el.attach_defaults ( child_8.el , 0,1,4,5 );
253 var child_9 = new Xcls_parent( _this );
255 this.el.attach_defaults ( child_9.el , 1,2,4,5 );
256 var child_10 = new Xcls_Label17( _this );
258 this.el.attach_defaults ( child_10.el , 0,1,5,6 );
259 var child_11 = new Xcls_permname( _this );
261 this.el.attach_defaults ( child_11.el , 1,2,5,6 );
262 var child_12 = new Xcls_Label19( _this );
264 this.el.attach_defaults ( child_12.el , 0,1,6,7 );
265 var child_13 = new Xcls_modOrder( _this );
267 this.el.attach_defaults ( child_13.el , 1,2,6,7 );
268 var child_14 = new Xcls_Label21( _this );
270 this.el.attach_defaults ( child_14.el , 0,1,7,8 );
271 var child_15 = new Xcls_build_module( _this );
273 this.el.attach_defaults ( child_15.el , 1,2,7.8 );
276 // user defined functions
278 public class Xcls_Label5 : Object
281 private Xcls_PopoverFileDetails _this;
287 public Xcls_Label5(Xcls_PopoverFileDetails _owner )
290 this.el = new Gtk.Label( "File type" );
294 // set gobject values
295 this.el.justify = Gtk.Justification.RIGHT;
296 this.el.xalign = 0.900000f;
299 // user defined functions
302 public class Xcls_filetype : Object
304 public Gtk.ComboBox el;
305 private Xcls_PopoverFileDetails _this;
311 public Xcls_filetype(Xcls_PopoverFileDetails _owner )
314 _this.filetype = this;
315 this.el = new Gtk.ComboBox();
319 // set gobject values
320 var child_0 = new Xcls_dbcellrenderer( _this );
322 this.el.pack_start ( child_0.el , true );
323 var child_1 = new Xcls_dbmodel( _this );
325 this.el.set_model ( child_1.el );
329 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
332 // user defined functions
334 public class Xcls_dbcellrenderer : Object
336 public Gtk.CellRendererText el;
337 private Xcls_PopoverFileDetails _this;
343 public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
346 _this.dbcellrenderer = this;
347 this.el = new Gtk.CellRendererText();
351 // set gobject values
354 // user defined functions
357 public class Xcls_dbmodel : Object
359 public Gtk.ListStore el;
360 private Xcls_PopoverFileDetails _this;
366 public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
369 _this.dbmodel = this;
370 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
374 // set gobject values
377 // user defined functions
378 public void loadData (Gee.ArrayList<string> data, string cur) {
383 /// el.append(out iter);
386 // el.set_value(iter, 0, "");
387 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
392 el.set_value(iter, 0, "bjs");
393 el.set_value(iter, 1, "User Interface File (bjs)");
394 _this.build_module.el.set_active_iter(iter);
398 el.set_value(iter, 0, "vala");
399 el.set_value(iter, 1, "Vala");
406 el.set_value(iter, 0, "js");
407 el.set_value(iter, 1, "Javascript");
413 el.set_value(iter, 0, "css");
414 el.set_value(iter, 1, "CSS");
421 public class Xcls_Label9 : Object
424 private Xcls_PopoverFileDetails _this;
430 public Xcls_Label9(Xcls_PopoverFileDetails _owner )
433 this.el = new Gtk.Label( "Component Name" );
437 // set gobject values
438 this.el.justify = Gtk.Justification.RIGHT;
439 this.el.xalign = 0.900000f;
442 // user defined functions
445 public class Xcls_name : Object
448 private Xcls_PopoverFileDetails _this;
454 public Xcls_name(Xcls_PopoverFileDetails _owner )
458 this.el = new Gtk.Entry();
462 // set gobject values
463 this.el.visible = true;
466 // user defined functions
469 public class Xcls_Label11 : Object
472 private Xcls_PopoverFileDetails _this;
478 public Xcls_Label11(Xcls_PopoverFileDetails _owner )
481 this.el = new Gtk.Label( "Title" );
485 // set gobject values
486 this.el.justify = Gtk.Justification.RIGHT;
487 this.el.xalign = 0.900000f;
488 this.el.visible = true;
491 // user defined functions
494 public class Xcls_title : Object
497 private Xcls_PopoverFileDetails _this;
503 public Xcls_title(Xcls_PopoverFileDetails _owner )
507 this.el = new Gtk.Entry();
511 // set gobject values
512 this.el.visible = true;
515 // user defined functions
518 public class Xcls_Label13 : Object
521 private Xcls_PopoverFileDetails _this;
527 public Xcls_Label13(Xcls_PopoverFileDetails _owner )
530 this.el = new Gtk.Label( "Region" );
534 // set gobject values
535 this.el.justify = Gtk.Justification.RIGHT;
536 this.el.xalign = 0.900000f;
537 this.el.tooltip_text = "center, north, south, east, west";
538 this.el.visible = true;
541 // user defined functions
544 public class Xcls_region : Object
547 private Xcls_PopoverFileDetails _this;
553 public Xcls_region(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_Label15 : Object
571 private Xcls_PopoverFileDetails _this;
577 public Xcls_Label15(Xcls_PopoverFileDetails _owner )
580 this.el = new Gtk.Label( "Parent Name" );
584 // set gobject values
585 this.el.justify = Gtk.Justification.RIGHT;
586 this.el.xalign = 0.900000f;
587 this.el.visible = true;
590 // user defined functions
593 public class Xcls_parent : Object
596 private Xcls_PopoverFileDetails _this;
602 public Xcls_parent(Xcls_PopoverFileDetails _owner )
606 this.el = new Gtk.Entry();
610 // set gobject values
611 this.el.visible = true;
614 // user defined functions
617 public class Xcls_Label17 : Object
620 private Xcls_PopoverFileDetails _this;
626 public Xcls_Label17(Xcls_PopoverFileDetails _owner )
629 this.el = new Gtk.Label( "Permission Name" );
633 // set gobject values
634 this.el.justify = Gtk.Justification.RIGHT;
635 this.el.xalign = 0.900000f;
636 this.el.visible = true;
639 // user defined functions
642 public class Xcls_permname : Object
645 private Xcls_PopoverFileDetails _this;
651 public Xcls_permname(Xcls_PopoverFileDetails _owner )
654 _this.permname = this;
655 this.el = new Gtk.Entry();
659 // set gobject values
660 this.el.visible = true;
663 // user defined functions
666 public class Xcls_Label19 : Object
669 private Xcls_PopoverFileDetails _this;
675 public Xcls_Label19(Xcls_PopoverFileDetails _owner )
678 this.el = new Gtk.Label( "Order (for tabs)" );
682 // set gobject values
683 this.el.justify = Gtk.Justification.RIGHT;
684 this.el.xalign = 0.900000f;
685 this.el.visible = true;
688 // user defined functions
691 public class Xcls_modOrder : Object
694 private Xcls_PopoverFileDetails _this;
700 public Xcls_modOrder(Xcls_PopoverFileDetails _owner )
703 _this.modOrder = this;
704 this.el = new Gtk.Entry();
708 // set gobject values
709 this.el.visible = true;
712 // user defined functions
715 public class Xcls_Label21 : Object
718 private Xcls_PopoverFileDetails _this;
724 public Xcls_Label21(Xcls_PopoverFileDetails _owner )
727 this.el = new Gtk.Label( "Module to build (Vala only)" );
731 // set gobject values
732 this.el.justify = Gtk.Justification.RIGHT;
733 this.el.xalign = 0.900000f;
734 this.el.visible = true;
737 // user defined functions
740 public class Xcls_build_module : Object
742 public Gtk.ComboBox el;
743 private Xcls_PopoverFileDetails _this;
749 public Xcls_build_module(Xcls_PopoverFileDetails _owner )
752 _this.build_module = this;
753 this.el = new Gtk.ComboBox();
757 // set gobject values
758 var child_0 = new Xcls_dbcellrenderer( _this );
760 this.el.pack_start ( child_0.el , true );
761 var child_1 = new Xcls_dbmodel( _this );
763 this.el.set_model ( child_1.el );
767 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
770 // user defined functions
772 public class Xcls_dbcellrenderer : Object
774 public Gtk.CellRendererText el;
775 private Xcls_PopoverFileDetails _this;
781 public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
784 _this.dbcellrenderer = this;
785 this.el = new Gtk.CellRendererText();
789 // set gobject values
792 // user defined functions
795 public class Xcls_dbmodel : Object
797 public Gtk.ListStore el;
798 private Xcls_PopoverFileDetails _this;
804 public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
807 _this.dbmodel = this;
808 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
812 // set gobject values
815 // user defined functions
816 public void loadData (Gee.ArrayList<string> data, string cur) {
821 /// el.append(out iter);
824 // el.set_value(iter, 0, "");
825 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
830 el.set_value(iter, 0, "");
831 el.set_value(iter, 1, "-- select a module --");
832 _this.build_module.el.set_active_iter(iter);
834 for (var i = 0; i < data.size;i++) {
839 el.set_value(iter, 0, data.get(i));
840 el.set_value(iter, 1, data.get(i));
842 if (data.get(i) == cur) {
843 _this.build_module.el.set_active_iter(iter);
847 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
854 public class Xcls_HButtonBox25 : Object
856 public Gtk.HButtonBox el;
857 private Xcls_PopoverFileDetails _this;
863 public Xcls_HButtonBox25(Xcls_PopoverFileDetails _owner )
866 this.el = new Gtk.HButtonBox();
870 // set gobject values
871 this.el.margin_right = 4;
872 this.el.margin_left = 4;
873 this.el.margin_bottom = 4;
874 var child_0 = new Xcls_Button26( _this );
876 this.el.add ( child_0.el );
877 var child_1 = new Xcls_save_btn( _this );
879 this.el.add ( child_1.el );
882 // user defined functions
884 public class Xcls_Button26 : Object
886 public Gtk.Button el;
887 private Xcls_PopoverFileDetails _this;
893 public Xcls_Button26(Xcls_PopoverFileDetails _owner )
896 this.el = new Gtk.Button();
900 // set gobject values
901 this.el.label = "Cancel";
904 this.el.clicked.connect( () => {
911 // user defined functions
914 public class Xcls_save_btn : Object
916 public Gtk.Button el;
917 private Xcls_PopoverFileDetails _this;
923 public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
926 _this.save_btn = this;
927 this.el = new Gtk.Button();
931 // set gobject values
932 this.el.label = "Save";
935 this.el.clicked.connect( ( ) => {
940 if (_this.name.el.get_text().length < 1) {
941 StandardErrorDialog.show(
943 "You have to set Component name "
948 // what does this do?
950 var isNew = _this.file.name.length > 0 ? false : true;
952 if (!isNew && this.file.name != _this.name.el.get_text()) {
953 Xcls_StandardErrorDialog.singleton().show(
955 "Sorry changing names does not work yet. "
964 // FIXME - this may be more complicated...
965 //for (var i in this.def) {
966 // this.file[i] = this.get(i).el.get_text();
971 _this.updateFileFromEntry();
972 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
973 Xcls_StandardErrorDialog.singleton().show(
975 "The name you used already exists "
986 var fn = _this.name.el.get_text();
987 var dir = _this.project.firstPath();
989 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
990 Xcls_StandardErrorDialog.singleton().show(
992 "That file already exists"
997 var f = JsRender.JsRender.factory(
998 _this.file.project.xtype,
1000 dir + "/" + fn + ".bjs");
1006 _this.updateFileFromEntry();
1007 _this.file.loaded = true;
1009 _this.file.project.addFile(_this.file);
1018 _this.success(_this.project, _this.file);
1023 // user defined functions