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_name name;
16 public Xcls_title title;
17 public Xcls_region region;
18 public Xcls_parent parent;
19 public Xcls_permname permname;
20 public Xcls_modOrder modOrder;
21 public Xcls_build_module build_module;
22 public Xcls_dbcellrenderer dbcellrenderer;
23 public Xcls_dbmodel dbmodel;
24 public Xcls_save_btn save_btn;
27 public signal void success (Project.Project pr, JsRender.JsRender file);
29 public Project.Project project;
30 public JsRender.JsRender file;
31 public Xcls_MainWindow mainwindow;
34 public Xcls_PopoverFileDetails()
37 this.el = new Gtk.Popover( null );
42 this.mainwindow = null;
45 this.el.border_width = 0;
47 this.el.position = Gtk.PositionType.RIGHT;
48 var child_0 = new Xcls_VBox2( _this );
50 this.el.add ( child_0.el );
53 this.el.closed.connect( () => {
61 // user defined functions
62 public void updateFileFromEntry () {
64 _this.file.title = _this.title.el.get_text();
65 _this.file.region = _this.region.el.get_text();
66 _this.file.parent = _this.parent.el.get_text();
67 _this.file.permname = _this.permname.el.get_text();
68 _this.file.modOrder = _this.modOrder.el.get_text();
70 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
71 _this.file.renameTo(_this.name.el.get_text());
73 // store the module...
74 _this.file.build_module = "";
76 if (_this.build_module.el.get_active_iter (out iter)) {
78 this.dbmodel.el.get_value (iter, 0, out vfname);
79 if (((string)vfname).length > 0) {
80 _this.file.build_module = (string)vfname;
89 public void show (JsRender.JsRender c, Gtk.Widget btn)
91 this.project = c.project;
99 _this.name.el.set_text(c.name);
100 _this.title.el.set_text(c.title);
101 _this.parent.el.set_text(c.parent);
102 _this.region.el.set_text(c.region);
103 _this.modOrder.el.set_text(c.modOrder);
104 _this.permname.el.set_text(c.permname);
106 if (c.path.length > 0) {
108 this.save_btn.el.set_label("Save");
110 this.save_btn.el.set_label("Create");
113 var ar = new Gee.ArrayList<string>();
114 _this.dbmodel.loadData(ar,"");
115 // load the modules... if relivant..
116 if (this.project.xtype == "Gtk") {
117 var p = (Project.Gtk)c.project;
118 var cg = p.compilegroups;
120 var iter = cg.map_iterator();
122 var key = iter.get_key();
123 if (key == "_default_") {
128 _this.dbmodel.loadData(ar, c.build_module);
134 //console.log('show all');
135 this.el.set_modal(true);
136 this.el.set_relative_to(btn);
138 this.el.set_position(Gtk.PositionType.RIGHT);
141 print("SHOWALL - POPIP\n");
143 this.name.el.grab_focus();
145 //this.success = c.success;
149 public class Xcls_VBox2 : Object
152 private Xcls_PopoverFileDetails _this;
158 public Xcls_VBox2(Xcls_PopoverFileDetails _owner )
161 this.el = new Gtk.VBox( false, 0 );
165 // set gobject values
166 var child_0 = new Xcls_HeaderBar3( _this );
168 this.el.pack_start ( child_0.el , false,true,0 );
169 var child_1 = new Xcls_Table4( _this );
171 this.el.pack_start ( child_1.el , false,false,4 );
172 var child_2 = new Xcls_HButtonBox21( _this );
174 this.el.pack_end ( child_2.el , false,true,0 );
177 // user defined functions
179 public class Xcls_HeaderBar3 : Object
181 public Gtk.HeaderBar el;
182 private Xcls_PopoverFileDetails _this;
188 public Xcls_HeaderBar3(Xcls_PopoverFileDetails _owner )
191 this.el = new Gtk.HeaderBar();
195 // set gobject values
196 this.el.title = "Add / Edit File";
199 // user defined functions
201 public class Xcls_Table4 : Object
204 private Xcls_PopoverFileDetails _this;
210 public Xcls_Table4(Xcls_PopoverFileDetails _owner )
213 this.el = new Gtk.Table( 3, 2, true );
217 // set gobject values
218 var child_0 = new Xcls_Label5( _this );
220 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
221 var child_1 = new Xcls_name( _this );
223 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
224 var child_2 = new Xcls_Label7( _this );
226 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
227 var child_3 = new Xcls_title( _this );
229 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
230 var child_4 = new Xcls_Label9( _this );
232 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
233 var child_5 = new Xcls_region( _this );
235 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
236 var child_6 = new Xcls_Label11( _this );
238 this.el.attach_defaults ( child_6.el , 0,1,3,4 );
239 var child_7 = new Xcls_parent( _this );
241 this.el.attach_defaults ( child_7.el , 1,2,3,4 );
242 var child_8 = new Xcls_Label13( _this );
244 this.el.attach_defaults ( child_8.el , 0,1,4,5 );
245 var child_9 = new Xcls_permname( _this );
247 this.el.attach_defaults ( child_9.el , 1,2,4,5 );
248 var child_10 = new Xcls_Label15( _this );
250 this.el.attach_defaults ( child_10.el , 0,1,5,6 );
251 var child_11 = new Xcls_modOrder( _this );
253 this.el.attach_defaults ( child_11.el , 1,2,5,6 );
254 var child_12 = new Xcls_Label17( _this );
256 this.el.attach_defaults ( child_12.el , 0,1,6,7 );
257 var child_13 = new Xcls_build_module( _this );
259 this.el.attach_defaults ( child_13.el , 1,2,6,7 );
262 // user defined functions
264 public class Xcls_Label5 : Object
267 private Xcls_PopoverFileDetails _this;
273 public Xcls_Label5(Xcls_PopoverFileDetails _owner )
276 this.el = new Gtk.Label( "Component Name" );
280 // set gobject values
281 this.el.justify = Gtk.Justification.RIGHT;
282 this.el.xalign = 0.900000f;
285 // user defined functions
287 public class Xcls_name : Object
290 private Xcls_PopoverFileDetails _this;
296 public Xcls_name(Xcls_PopoverFileDetails _owner )
300 this.el = new Gtk.Entry();
304 // set gobject values
305 this.el.visible = true;
308 // user defined functions
310 public class Xcls_Label7 : Object
313 private Xcls_PopoverFileDetails _this;
319 public Xcls_Label7(Xcls_PopoverFileDetails _owner )
322 this.el = new Gtk.Label( "Title" );
326 // set gobject values
327 this.el.justify = Gtk.Justification.RIGHT;
328 this.el.xalign = 0.900000f;
329 this.el.visible = true;
332 // user defined functions
334 public class Xcls_title : Object
337 private Xcls_PopoverFileDetails _this;
343 public Xcls_title(Xcls_PopoverFileDetails _owner )
347 this.el = new Gtk.Entry();
351 // set gobject values
352 this.el.visible = true;
355 // user defined functions
357 public class Xcls_Label9 : Object
360 private Xcls_PopoverFileDetails _this;
366 public Xcls_Label9(Xcls_PopoverFileDetails _owner )
369 this.el = new Gtk.Label( "Region" );
373 // set gobject values
374 this.el.justify = Gtk.Justification.RIGHT;
375 this.el.xalign = 0.900000f;
376 this.el.tooltip_text = "center, north, south, east, west";
377 this.el.visible = true;
380 // user defined functions
382 public class Xcls_region : Object
385 private Xcls_PopoverFileDetails _this;
391 public Xcls_region(Xcls_PopoverFileDetails _owner )
395 this.el = new Gtk.Entry();
399 // set gobject values
400 this.el.visible = true;
403 // user defined functions
405 public class Xcls_Label11 : Object
408 private Xcls_PopoverFileDetails _this;
414 public Xcls_Label11(Xcls_PopoverFileDetails _owner )
417 this.el = new Gtk.Label( "Parent Name" );
421 // set gobject values
422 this.el.justify = Gtk.Justification.RIGHT;
423 this.el.xalign = 0.900000f;
424 this.el.visible = true;
427 // user defined functions
429 public class Xcls_parent : Object
432 private Xcls_PopoverFileDetails _this;
438 public Xcls_parent(Xcls_PopoverFileDetails _owner )
442 this.el = new Gtk.Entry();
446 // set gobject values
447 this.el.visible = true;
450 // user defined functions
452 public class Xcls_Label13 : Object
455 private Xcls_PopoverFileDetails _this;
461 public Xcls_Label13(Xcls_PopoverFileDetails _owner )
464 this.el = new Gtk.Label( "Permission Name" );
468 // set gobject values
469 this.el.justify = Gtk.Justification.RIGHT;
470 this.el.xalign = 0.900000f;
471 this.el.visible = true;
474 // user defined functions
476 public class Xcls_permname : Object
479 private Xcls_PopoverFileDetails _this;
485 public Xcls_permname(Xcls_PopoverFileDetails _owner )
488 _this.permname = this;
489 this.el = new Gtk.Entry();
493 // set gobject values
494 this.el.visible = true;
497 // user defined functions
499 public class Xcls_Label15 : Object
502 private Xcls_PopoverFileDetails _this;
508 public Xcls_Label15(Xcls_PopoverFileDetails _owner )
511 this.el = new Gtk.Label( "Order (for tabs)" );
515 // set gobject values
516 this.el.justify = Gtk.Justification.RIGHT;
517 this.el.xalign = 0.900000f;
518 this.el.visible = true;
521 // user defined functions
523 public class Xcls_modOrder : Object
526 private Xcls_PopoverFileDetails _this;
532 public Xcls_modOrder(Xcls_PopoverFileDetails _owner )
535 _this.modOrder = this;
536 this.el = new Gtk.Entry();
540 // set gobject values
541 this.el.visible = true;
544 // user defined functions
546 public class Xcls_Label17 : Object
549 private Xcls_PopoverFileDetails _this;
555 public Xcls_Label17(Xcls_PopoverFileDetails _owner )
558 this.el = new Gtk.Label( "Module to build (Vala only)" );
562 // set gobject values
563 this.el.justify = Gtk.Justification.RIGHT;
564 this.el.xalign = 0.900000f;
565 this.el.visible = true;
568 // user defined functions
570 public class Xcls_build_module : Object
572 public Gtk.ComboBox el;
573 private Xcls_PopoverFileDetails _this;
579 public Xcls_build_module(Xcls_PopoverFileDetails _owner )
582 _this.build_module = this;
583 this.el = new Gtk.ComboBox();
587 // set gobject values
588 var child_0 = new Xcls_dbcellrenderer( _this );
590 this.el.pack_start ( child_0.el , true );
591 var child_1 = new Xcls_dbmodel( _this );
593 this.el.set_model ( child_1.el );
597 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
600 // user defined functions
602 public class Xcls_dbcellrenderer : Object
604 public Gtk.CellRendererText el;
605 private Xcls_PopoverFileDetails _this;
611 public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
614 _this.dbcellrenderer = this;
615 this.el = new Gtk.CellRendererText();
619 // set gobject values
622 // user defined functions
624 public class Xcls_dbmodel : Object
626 public Gtk.ListStore el;
627 private Xcls_PopoverFileDetails _this;
633 public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
636 _this.dbmodel = this;
637 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
641 // set gobject values
644 // user defined functions
645 public void loadData (Gee.ArrayList<string> data, string cur) {
650 /// el.append(out iter);
653 // el.set_value(iter, 0, "");
654 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
659 el.set_value(iter, 0, "");
660 el.set_value(iter, 1, "-- select a module --");
661 _this.build_module.el.set_active_iter(iter);
663 for (var i = 0; i < data.size;i++) {
668 el.set_value(iter, 0, data.get(i));
669 el.set_value(iter, 1, data.get(i));
671 if (data.get(i) == cur) {
672 _this.build_module.el.set_active_iter(iter);
676 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
680 public class Xcls_HButtonBox21 : Object
682 public Gtk.HButtonBox el;
683 private Xcls_PopoverFileDetails _this;
689 public Xcls_HButtonBox21(Xcls_PopoverFileDetails _owner )
692 this.el = new Gtk.HButtonBox();
696 // set gobject values
697 var child_0 = new Xcls_Button22( _this );
699 this.el.add ( child_0.el );
700 var child_1 = new Xcls_save_btn( _this );
702 this.el.add ( child_1.el );
705 // user defined functions
707 public class Xcls_Button22 : Object
709 public Gtk.Button el;
710 private Xcls_PopoverFileDetails _this;
716 public Xcls_Button22(Xcls_PopoverFileDetails _owner )
719 this.el = new Gtk.Button();
723 // set gobject values
724 this.el.label = "Cancel";
727 this.el.clicked.connect( () => {
734 // user defined functions
736 public class Xcls_save_btn : Object
738 public Gtk.Button el;
739 private Xcls_PopoverFileDetails _this;
745 public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
748 _this.save_btn = this;
749 this.el = new Gtk.Button();
753 // set gobject values
754 this.el.label = "Save";
757 this.el.clicked.connect( ( ) => {
762 if (_this.name.el.get_text().length < 1) {
763 StandardErrorDialog.show(
765 "You have to set Component name "
770 // what does this do?
772 var isNew = _this.file.name.length > 0 ? false : true;
774 if (!isNew && this.file.name != _this.name.el.get_text()) {
775 Xcls_StandardErrorDialog.singleton().show(
777 "Sorry changing names does not work yet. "
786 // FIXME - this may be more complicated...
787 //for (var i in this.def) {
788 // this.file[i] = this.get(i).el.get_text();
793 _this.updateFileFromEntry();
794 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
795 Xcls_StandardErrorDialog.singleton().show(
797 "The name you used already exists "
808 var fn = _this.name.el.get_text();
809 var dir = _this.project.firstPath();
811 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
812 Xcls_StandardErrorDialog.singleton().show(
814 "That file already exists"
819 var f = JsRender.JsRender.factory(
820 _this.file.project.xtype,
822 dir + "/" + fn + ".bjs");
828 _this.updateFileFromEntry();
830 _this.file.project.addFile(_this.file);
839 _this.success(_this.project, _this.file);
844 // user defined functions