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_parent parent;
18 public Xcls_permname permname;
19 public Xcls_modOrder modOrder;
20 public Xcls_build_module build_module;
21 public Xcls_dbcellrenderer dbcellrenderer;
22 public Xcls_dbmodel dbmodel;
23 public Xcls_save_btn save_btn;
26 public signal void success (Project.Project pr, JsRender.JsRender file);
28 public Project.Project project;
29 public JsRender.JsRender file;
30 public Xcls_MainWindow mainwindow;
33 public Xcls_PopoverProperty()
36 this.el = new Gtk.Popover( null );
41 this.mainwindow = null;
44 this.el.border_width = 0;
46 this.el.position = Gtk.PositionType.RIGHT;
47 var child_0 = new Xcls_Box2( _this );
49 this.el.add ( child_0.el );
52 this.el.closed.connect( () => {
60 // user defined functions
61 public void updateFileFromEntry () {
63 _this.file.title = _this.title.el.get_text();
64 _this.file.region = _this.region.el.get_text();
65 _this.file.parent = _this.parent.el.get_text();
66 _this.file.permname = _this.permname.el.get_text();
67 _this.file.modOrder = _this.modOrder.el.get_text();
69 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
70 _this.file.renameTo(_this.name.el.get_text());
72 // store the module...
73 _this.file.build_module = "";
75 if (_this.build_module.el.get_active_iter (out iter)) {
77 this.dbmodel.el.get_value (iter, 0, out vfname);
78 if (((string)vfname).length > 0) {
79 _this.file.build_module = (string)vfname;
88 public void show (JsRender.JsRender c, Gtk.Widget btn)
90 this.project = c.project;
98 _this.name.el.set_text(c.name);
99 _this.title.el.set_text(c.title);
100 _this.parent.el.set_text(c.parent);
101 _this.region.el.set_text(c.region);
102 _this.modOrder.el.set_text(c.modOrder);
103 _this.permname.el.set_text(c.permname);
105 if (c.path.length > 0) {
107 this.save_btn.el.set_label("Save");
109 this.save_btn.el.set_label("Create");
112 var ar = new Gee.ArrayList<string>();
113 _this.dbmodel.loadData(ar,"");
114 // load the modules... if relivant..
115 if (this.project.xtype == "Gtk") {
116 var p = (Project.Gtk)c.project;
117 var cg = p.compilegroups;
119 var iter = cg.map_iterator();
121 var key = iter.get_key();
122 if (key == "_default_") {
127 _this.dbmodel.loadData(ar, c.build_module);
133 //console.log('show all');
134 this.el.set_modal(true);
135 this.el.set_relative_to(btn);
137 this.el.set_position(Gtk.PositionType.RIGHT);
140 print("SHOWALL - POPIP\n");
142 this.name.el.grab_focus();
144 //this.success = c.success;
148 public class Xcls_Box2 : Object
151 private Xcls_PopoverProperty _this;
157 public Xcls_Box2(Xcls_PopoverProperty _owner )
160 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
164 // set gobject values
165 this.el.homogeneous = false;
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_HButtonBox19( _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_PopoverProperty _this;
188 public Xcls_HeaderBar3(Xcls_PopoverProperty _owner )
191 this.el = new Gtk.HeaderBar();
195 // set gobject values
196 this.el.title = "Modify / Create Property";
199 // user defined functions
202 public class Xcls_Table4 : Object
205 private Xcls_PopoverProperty _this;
211 public Xcls_Table4(Xcls_PopoverProperty _owner )
214 this.el = new Gtk.Table( 3, 2, true );
218 // set gobject values
219 this.el.margin_right = 4;
220 this.el.margin_left = 4;
221 this.el.row_spacing = 2;
222 var child_0 = new Xcls_Label5( _this );
224 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
225 var child_1 = new Xcls_name( _this );
227 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
228 var child_2 = new Xcls_Label7( _this );
230 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
231 var child_3 = new Xcls_title( _this );
233 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
234 var child_4 = new Xcls_Label9( _this );
236 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
237 var child_5 = new Xcls_parent( _this );
239 this.el.attach_defaults ( child_5.el , 1,2,3,4 );
240 var child_6 = new Xcls_Label11( _this );
242 this.el.attach_defaults ( child_6.el , 0,1,4,5 );
243 var child_7 = new Xcls_permname( _this );
245 this.el.attach_defaults ( child_7.el , 1,2,4,5 );
246 var child_8 = new Xcls_Label13( _this );
248 this.el.attach_defaults ( child_8.el , 0,1,5,6 );
249 var child_9 = new Xcls_modOrder( _this );
251 this.el.attach_defaults ( child_9.el , 1,2,5,6 );
252 var child_10 = new Xcls_Label15( _this );
254 this.el.attach_defaults ( child_10.el , 0,1,6,7 );
255 var child_11 = new Xcls_build_module( _this );
257 this.el.attach_defaults ( child_11.el , 1,2,6,7 );
260 // user defined functions
262 public class Xcls_Label5 : Object
265 private Xcls_PopoverProperty _this;
271 public Xcls_Label5(Xcls_PopoverProperty _owner )
274 this.el = new Gtk.Label( "Special Flags" );
278 // set gobject values
279 this.el.justify = Gtk.Justification.RIGHT;
280 this.el.xalign = 0.900000f;
283 // user defined functions
286 public class Xcls_name : Object
289 private Xcls_PopoverProperty _this;
295 public Xcls_name(Xcls_PopoverProperty _owner )
299 this.el = new Gtk.Entry();
303 // set gobject values
304 this.el.visible = true;
307 // user defined functions
310 public class Xcls_Label7 : Object
313 private Xcls_PopoverProperty _this;
319 public Xcls_Label7(Xcls_PopoverProperty _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
335 public class Xcls_title : Object
338 private Xcls_PopoverProperty _this;
344 public Xcls_title(Xcls_PopoverProperty _owner )
348 this.el = new Gtk.Entry();
352 // set gobject values
353 this.el.visible = true;
356 // user defined functions
359 public class Xcls_Label9 : Object
362 private Xcls_PopoverProperty _this;
368 public Xcls_Label9(Xcls_PopoverProperty _owner )
371 this.el = new Gtk.Label( "Name" );
375 // set gobject values
376 this.el.justify = Gtk.Justification.RIGHT;
377 this.el.xalign = 0.900000f;
378 this.el.tooltip_text = "center, north, south, east, west";
379 this.el.visible = true;
382 // user defined functions
385 public class Xcls_parent : Object
388 private Xcls_PopoverProperty _this;
394 public Xcls_parent(Xcls_PopoverProperty _owner )
398 this.el = new Gtk.Entry();
402 // set gobject values
403 this.el.visible = true;
406 // user defined functions
409 public class Xcls_Label11 : Object
412 private Xcls_PopoverProperty _this;
418 public Xcls_Label11(Xcls_PopoverProperty _owner )
421 this.el = new Gtk.Label( "Permission Name" );
425 // set gobject values
426 this.el.justify = Gtk.Justification.RIGHT;
427 this.el.xalign = 0.900000f;
428 this.el.visible = true;
431 // user defined functions
434 public class Xcls_permname : Object
437 private Xcls_PopoverProperty _this;
443 public Xcls_permname(Xcls_PopoverProperty _owner )
446 _this.permname = this;
447 this.el = new Gtk.Entry();
451 // set gobject values
452 this.el.visible = true;
455 // user defined functions
458 public class Xcls_Label13 : Object
461 private Xcls_PopoverProperty _this;
467 public Xcls_Label13(Xcls_PopoverProperty _owner )
470 this.el = new Gtk.Label( "Order (for tabs)" );
474 // set gobject values
475 this.el.justify = Gtk.Justification.RIGHT;
476 this.el.xalign = 0.900000f;
477 this.el.visible = true;
480 // user defined functions
483 public class Xcls_modOrder : Object
486 private Xcls_PopoverProperty _this;
492 public Xcls_modOrder(Xcls_PopoverProperty _owner )
495 _this.modOrder = this;
496 this.el = new Gtk.Entry();
500 // set gobject values
501 this.el.visible = true;
504 // user defined functions
507 public class Xcls_Label15 : Object
510 private Xcls_PopoverProperty _this;
516 public Xcls_Label15(Xcls_PopoverProperty _owner )
519 this.el = new Gtk.Label( "Module to build (Vala only)" );
523 // set gobject values
524 this.el.justify = Gtk.Justification.RIGHT;
525 this.el.xalign = 0.900000f;
526 this.el.visible = true;
529 // user defined functions
532 public class Xcls_build_module : Object
534 public Gtk.ComboBox el;
535 private Xcls_PopoverProperty _this;
541 public Xcls_build_module(Xcls_PopoverProperty _owner )
544 _this.build_module = this;
545 this.el = new Gtk.ComboBox();
549 // set gobject values
550 var child_0 = new Xcls_dbcellrenderer( _this );
552 this.el.pack_start ( child_0.el , true );
553 var child_1 = new Xcls_dbmodel( _this );
555 this.el.set_model ( child_1.el );
559 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
562 // user defined functions
564 public class Xcls_dbcellrenderer : Object
566 public Gtk.CellRendererText el;
567 private Xcls_PopoverProperty _this;
573 public Xcls_dbcellrenderer(Xcls_PopoverProperty _owner )
576 _this.dbcellrenderer = this;
577 this.el = new Gtk.CellRendererText();
581 // set gobject values
584 // user defined functions
587 public class Xcls_dbmodel : Object
589 public Gtk.ListStore el;
590 private Xcls_PopoverProperty _this;
596 public Xcls_dbmodel(Xcls_PopoverProperty _owner )
599 _this.dbmodel = this;
600 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
604 // set gobject values
607 // user defined functions
608 public void loadData (Gee.ArrayList<string> data, string cur) {
613 /// el.append(out iter);
616 // el.set_value(iter, 0, "");
617 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
622 el.set_value(iter, 0, "");
623 el.set_value(iter, 1, "-- select a module --");
624 _this.build_module.el.set_active_iter(iter);
626 for (var i = 0; i < data.size;i++) {
631 el.set_value(iter, 0, data.get(i));
632 el.set_value(iter, 1, data.get(i));
634 if (data.get(i) == cur) {
635 _this.build_module.el.set_active_iter(iter);
639 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
646 public class Xcls_HButtonBox19 : Object
648 public Gtk.HButtonBox el;
649 private Xcls_PopoverProperty _this;
655 public Xcls_HButtonBox19(Xcls_PopoverProperty _owner )
658 this.el = new Gtk.HButtonBox();
662 // set gobject values
663 this.el.margin_right = 4;
664 this.el.margin_left = 4;
665 this.el.margin_bottom = 4;
666 var child_0 = new Xcls_Button20( _this );
668 this.el.add ( child_0.el );
669 var child_1 = new Xcls_save_btn( _this );
671 this.el.add ( child_1.el );
674 // user defined functions
676 public class Xcls_Button20 : Object
678 public Gtk.Button el;
679 private Xcls_PopoverProperty _this;
685 public Xcls_Button20(Xcls_PopoverProperty _owner )
688 this.el = new Gtk.Button();
692 // set gobject values
693 this.el.label = "Cancel";
696 this.el.clicked.connect( () => {
703 // user defined functions
706 public class Xcls_save_btn : Object
708 public Gtk.Button el;
709 private Xcls_PopoverProperty _this;
715 public Xcls_save_btn(Xcls_PopoverProperty _owner )
718 _this.save_btn = this;
719 this.el = new Gtk.Button();
723 // set gobject values
724 this.el.label = "Save";
727 this.el.clicked.connect( ( ) => {
732 if (_this.name.el.get_text().length < 1) {
733 StandardErrorDialog.show(
735 "You have to set Component name "
740 // what does this do?
742 var isNew = _this.file.name.length > 0 ? false : true;
744 if (!isNew && this.file.name != _this.name.el.get_text()) {
745 Xcls_StandardErrorDialog.singleton().show(
747 "Sorry changing names does not work yet. "
756 // FIXME - this may be more complicated...
757 //for (var i in this.def) {
758 // this.file[i] = this.get(i).el.get_text();
763 _this.updateFileFromEntry();
764 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
765 Xcls_StandardErrorDialog.singleton().show(
767 "The name you used already exists "
778 var fn = _this.name.el.get_text();
779 var dir = _this.project.firstPath();
781 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
782 Xcls_StandardErrorDialog.singleton().show(
784 "That file already exists"
789 var f = JsRender.JsRender.factory(
790 _this.file.project.xtype,
792 dir + "/" + fn + ".bjs");
798 _this.updateFileFromEntry();
799 _this.file.loaded = true;
801 _this.file.project.addFile(_this.file);
810 _this.success(_this.project, _this.file);
815 // user defined functions