1 static Xcls_PopoverProperty _PopoverProperty;
3 public class Xcls_PopoverProperty : Object
6 private Xcls_PopoverProperty _this;
8 public static Xcls_PopoverProperty singleton()
10 if (_PopoverProperty == null) {
11 _PopoverProperty= new Xcls_PopoverProperty();
13 return _PopoverProperty;
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_PopoverProperty()
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_Box2( _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_Box2 : Object
152 private Xcls_PopoverProperty _this;
158 public Xcls_Box2(Xcls_PopoverProperty _owner )
161 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
165 // set gobject values
166 this.el.homogeneous = false;
167 var child_0 = new Xcls_HeaderBar3( _this );
169 this.el.pack_start ( child_0.el , false,true,0 );
170 var child_1 = new Xcls_Table4( _this );
172 this.el.pack_start ( child_1.el , false,false,4 );
173 var child_2 = new Xcls_HButtonBox21( _this );
175 this.el.pack_end ( child_2.el , false,true,0 );
178 // user defined functions
180 public class Xcls_HeaderBar3 : Object
182 public Gtk.HeaderBar el;
183 private Xcls_PopoverProperty _this;
189 public Xcls_HeaderBar3(Xcls_PopoverProperty _owner )
192 this.el = new Gtk.HeaderBar();
196 // set gobject values
197 this.el.title = "Modify / Create Property";
200 // user defined functions
203 public class Xcls_Table4 : Object
206 private Xcls_PopoverProperty _this;
212 public Xcls_Table4(Xcls_PopoverProperty _owner )
215 this.el = new Gtk.Table( 3, 2, true );
219 // set gobject values
220 this.el.margin_right = 4;
221 this.el.margin_left = 4;
222 this.el.row_spacing = 2;
223 var child_0 = new Xcls_Label5( _this );
225 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
226 var child_1 = new Xcls_name( _this );
228 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
229 var child_2 = new Xcls_Label7( _this );
231 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
232 var child_3 = new Xcls_title( _this );
234 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
235 var child_4 = new Xcls_Label9( _this );
237 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
238 var child_5 = new Xcls_region( _this );
240 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
241 var child_6 = new Xcls_Label11( _this );
243 this.el.attach_defaults ( child_6.el , 0,1,3,4 );
244 var child_7 = new Xcls_parent( _this );
246 this.el.attach_defaults ( child_7.el , 1,2,3,4 );
247 var child_8 = new Xcls_Label13( _this );
249 this.el.attach_defaults ( child_8.el , 0,1,4,5 );
250 var child_9 = new Xcls_permname( _this );
252 this.el.attach_defaults ( child_9.el , 1,2,4,5 );
253 var child_10 = new Xcls_Label15( _this );
255 this.el.attach_defaults ( child_10.el , 0,1,5,6 );
256 var child_11 = new Xcls_modOrder( _this );
258 this.el.attach_defaults ( child_11.el , 1,2,5,6 );
259 var child_12 = new Xcls_Label17( _this );
261 this.el.attach_defaults ( child_12.el , 0,1,6,7 );
262 var child_13 = new Xcls_build_module( _this );
264 this.el.attach_defaults ( child_13.el , 1,2,6,7 );
267 // user defined functions
269 public class Xcls_Label5 : Object
272 private Xcls_PopoverProperty _this;
278 public Xcls_Label5(Xcls_PopoverProperty _owner )
281 this.el = new Gtk.Label( "Component Name" );
285 // set gobject values
286 this.el.justify = Gtk.Justification.RIGHT;
287 this.el.xalign = 0.900000f;
290 // user defined functions
293 public class Xcls_name : Object
296 private Xcls_PopoverProperty _this;
302 public Xcls_name(Xcls_PopoverProperty _owner )
306 this.el = new Gtk.Entry();
310 // set gobject values
311 this.el.visible = true;
314 // user defined functions
317 public class Xcls_Label7 : Object
320 private Xcls_PopoverProperty _this;
326 public Xcls_Label7(Xcls_PopoverProperty _owner )
329 this.el = new Gtk.Label( "Title" );
333 // set gobject values
334 this.el.justify = Gtk.Justification.RIGHT;
335 this.el.xalign = 0.900000f;
336 this.el.visible = true;
339 // user defined functions
342 public class Xcls_title : Object
345 private Xcls_PopoverProperty _this;
351 public Xcls_title(Xcls_PopoverProperty _owner )
355 this.el = new Gtk.Entry();
359 // set gobject values
360 this.el.visible = true;
363 // user defined functions
366 public class Xcls_Label9 : Object
369 private Xcls_PopoverProperty _this;
375 public Xcls_Label9(Xcls_PopoverProperty _owner )
378 this.el = new Gtk.Label( "Region" );
382 // set gobject values
383 this.el.justify = Gtk.Justification.RIGHT;
384 this.el.xalign = 0.900000f;
385 this.el.tooltip_text = "center, north, south, east, west";
386 this.el.visible = true;
389 // user defined functions
392 public class Xcls_region : Object
395 private Xcls_PopoverProperty _this;
401 public Xcls_region(Xcls_PopoverProperty _owner )
405 this.el = new Gtk.Entry();
409 // set gobject values
410 this.el.visible = true;
413 // user defined functions
416 public class Xcls_Label11 : Object
419 private Xcls_PopoverProperty _this;
425 public Xcls_Label11(Xcls_PopoverProperty _owner )
428 this.el = new Gtk.Label( "Parent Name" );
432 // set gobject values
433 this.el.justify = Gtk.Justification.RIGHT;
434 this.el.xalign = 0.900000f;
435 this.el.visible = true;
438 // user defined functions
441 public class Xcls_parent : Object
444 private Xcls_PopoverProperty _this;
450 public Xcls_parent(Xcls_PopoverProperty _owner )
454 this.el = new Gtk.Entry();
458 // set gobject values
459 this.el.visible = true;
462 // user defined functions
465 public class Xcls_Label13 : Object
468 private Xcls_PopoverProperty _this;
474 public Xcls_Label13(Xcls_PopoverProperty _owner )
477 this.el = new Gtk.Label( "Permission Name" );
481 // set gobject values
482 this.el.justify = Gtk.Justification.RIGHT;
483 this.el.xalign = 0.900000f;
484 this.el.visible = true;
487 // user defined functions
490 public class Xcls_permname : Object
493 private Xcls_PopoverProperty _this;
499 public Xcls_permname(Xcls_PopoverProperty _owner )
502 _this.permname = this;
503 this.el = new Gtk.Entry();
507 // set gobject values
508 this.el.visible = true;
511 // user defined functions
514 public class Xcls_Label15 : Object
517 private Xcls_PopoverProperty _this;
523 public Xcls_Label15(Xcls_PopoverProperty _owner )
526 this.el = new Gtk.Label( "Order (for tabs)" );
530 // set gobject values
531 this.el.justify = Gtk.Justification.RIGHT;
532 this.el.xalign = 0.900000f;
533 this.el.visible = true;
536 // user defined functions
539 public class Xcls_modOrder : Object
542 private Xcls_PopoverProperty _this;
548 public Xcls_modOrder(Xcls_PopoverProperty _owner )
551 _this.modOrder = this;
552 this.el = new Gtk.Entry();
556 // set gobject values
557 this.el.visible = true;
560 // user defined functions
563 public class Xcls_Label17 : Object
566 private Xcls_PopoverProperty _this;
572 public Xcls_Label17(Xcls_PopoverProperty _owner )
575 this.el = new Gtk.Label( "Module to build (Vala only)" );
579 // set gobject values
580 this.el.justify = Gtk.Justification.RIGHT;
581 this.el.xalign = 0.900000f;
582 this.el.visible = true;
585 // user defined functions
588 public class Xcls_build_module : Object
590 public Gtk.ComboBox el;
591 private Xcls_PopoverProperty _this;
597 public Xcls_build_module(Xcls_PopoverProperty _owner )
600 _this.build_module = this;
601 this.el = new Gtk.ComboBox();
605 // set gobject values
606 var child_0 = new Xcls_dbcellrenderer( _this );
608 this.el.pack_start ( child_0.el , true );
609 var child_1 = new Xcls_dbmodel( _this );
611 this.el.set_model ( child_1.el );
615 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
618 // user defined functions
620 public class Xcls_dbcellrenderer : Object
622 public Gtk.CellRendererText el;
623 private Xcls_PopoverProperty _this;
629 public Xcls_dbcellrenderer(Xcls_PopoverProperty _owner )
632 _this.dbcellrenderer = this;
633 this.el = new Gtk.CellRendererText();
637 // set gobject values
640 // user defined functions
643 public class Xcls_dbmodel : Object
645 public Gtk.ListStore el;
646 private Xcls_PopoverProperty _this;
652 public Xcls_dbmodel(Xcls_PopoverProperty _owner )
655 _this.dbmodel = this;
656 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
660 // set gobject values
663 // user defined functions
664 public void loadData (Gee.ArrayList<string> data, string cur) {
669 /// el.append(out iter);
672 // el.set_value(iter, 0, "");
673 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
678 el.set_value(iter, 0, "");
679 el.set_value(iter, 1, "-- select a module --");
680 _this.build_module.el.set_active_iter(iter);
682 for (var i = 0; i < data.size;i++) {
687 el.set_value(iter, 0, data.get(i));
688 el.set_value(iter, 1, data.get(i));
690 if (data.get(i) == cur) {
691 _this.build_module.el.set_active_iter(iter);
695 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
702 public class Xcls_HButtonBox21 : Object
704 public Gtk.HButtonBox el;
705 private Xcls_PopoverProperty _this;
711 public Xcls_HButtonBox21(Xcls_PopoverProperty _owner )
714 this.el = new Gtk.HButtonBox();
718 // set gobject values
719 this.el.margin_right = 4;
720 this.el.margin_left = 4;
721 this.el.margin_bottom = 4;
722 var child_0 = new Xcls_Button22( _this );
724 this.el.add ( child_0.el );
725 var child_1 = new Xcls_save_btn( _this );
727 this.el.add ( child_1.el );
730 // user defined functions
732 public class Xcls_Button22 : Object
734 public Gtk.Button el;
735 private Xcls_PopoverProperty _this;
741 public Xcls_Button22(Xcls_PopoverProperty _owner )
744 this.el = new Gtk.Button();
748 // set gobject values
749 this.el.label = "Cancel";
752 this.el.clicked.connect( () => {
759 // user defined functions
762 public class Xcls_save_btn : Object
764 public Gtk.Button el;
765 private Xcls_PopoverProperty _this;
771 public Xcls_save_btn(Xcls_PopoverProperty _owner )
774 _this.save_btn = this;
775 this.el = new Gtk.Button();
779 // set gobject values
780 this.el.label = "Save";
783 this.el.clicked.connect( ( ) => {
788 if (_this.name.el.get_text().length < 1) {
789 StandardErrorDialog.show(
791 "You have to set Component name "
796 // what does this do?
798 var isNew = _this.file.name.length > 0 ? false : true;
800 if (!isNew && this.file.name != _this.name.el.get_text()) {
801 Xcls_StandardErrorDialog.singleton().show(
803 "Sorry changing names does not work yet. "
812 // FIXME - this may be more complicated...
813 //for (var i in this.def) {
814 // this.file[i] = this.get(i).el.get_text();
819 _this.updateFileFromEntry();
820 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
821 Xcls_StandardErrorDialog.singleton().show(
823 "The name you used already exists "
834 var fn = _this.name.el.get_text();
835 var dir = _this.project.firstPath();
837 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
838 Xcls_StandardErrorDialog.singleton().show(
840 "That file already exists"
845 var f = JsRender.JsRender.factory(
846 _this.file.project.xtype,
848 dir + "/" + fn + ".bjs");
854 _this.updateFileFromEntry();
855 _this.file.loaded = true;
857 _this.file.project.addFile(_this.file);
866 _this.success(_this.project, _this.file);
871 // user defined functions