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_header header;
16 public Xcls_kflag kflag;
17 public Xcls_dbcellrenderer dbcellrenderer;
18 public Xcls_dbmodel dbmodel;
19 public Xcls_ktype ktype;
20 public Xcls_kname kname;
21 public Xcls_save_btn save_btn;
24 public signal void success (Project.Project pr, JsRender.JsRender file);
26 public Xcls_MainWindow mainwindow;
27 public string key_type;
28 public JsRender.Node node;
31 public Xcls_PopoverProperty()
34 this.el = new Gtk.Popover( null );
38 this.mainwindow = null;
41 this.el.border_width = 0;
43 this.el.position = Gtk.PositionType.RIGHT;
44 var child_0 = new Xcls_Box2( _this );
46 this.el.add ( child_0.el );
49 this.el.closed.connect( () => {
57 // user defined functions
58 public void show (Gtk.Widget btn, JsRender.Node node, string key_type, string key)
61 string kname = "", kflag = "", ktype = "";
63 node.normalize_key( key, out kname, out kflag, out ktype);
66 if (key_type == "listener") {
67 this.header.el.title = "Modify Event Listener";
69 this.header.el.title = "Modify Property";
72 this.key_type = key_type;
74 _this.kname.el.set_text(kname);
75 _this.ktype.el.set_text(ktype);
77 _this.dbmodel.loadData(kflag);
78 // does node have this property...
82 this.save_btn.el.set_label("Save");
84 this.save_btn.el.set_label("Create");
88 //console.log('show all');
89 this.el.set_modal(true);
90 this.el.set_relative_to(btn);
92 this.el.set_position(Gtk.PositionType.TOP);
95 print("SHOWALL - POPIP\n");
97 this.kname.el.grab_focus();
99 //this.success = c.success;
102 public void updateNodeFromValues () {
104 /* _this.file.title = _this.title.el.get_text();
105 _this.file.region = _this.region.el.get_text();
106 _this.file.parent = _this.parent.el.get_text();
107 _this.file.permname = _this.permname.el.get_text();
108 _this.file.modOrder = _this.modOrder.el.get_text();
110 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
111 _this.file.renameTo(_this.name.el.get_text());
113 // store the module...
114 _this.file.build_module = "";
116 if (_this.build_module.el.get_active_iter (out iter)) {
118 this.dbmodel.el.get_value (iter, 0, out vfname);
119 if (((string)vfname).length > 0) {
120 _this.file.build_module = (string)vfname;
130 public class Xcls_Box2 : Object
133 private Xcls_PopoverProperty _this;
139 public Xcls_Box2(Xcls_PopoverProperty _owner )
142 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
146 // set gobject values
147 this.el.homogeneous = false;
148 var child_0 = new Xcls_header( _this );
150 this.el.pack_start ( child_0.el , false,true,0 );
151 var child_1 = new Xcls_Table4( _this );
153 this.el.pack_start ( child_1.el , false,false,4 );
154 var child_2 = new Xcls_HButtonBox13( _this );
156 this.el.pack_end ( child_2.el , false,true,0 );
159 // user defined functions
161 public class Xcls_header : Object
163 public Gtk.HeaderBar el;
164 private Xcls_PopoverProperty _this;
170 public Xcls_header(Xcls_PopoverProperty _owner )
174 this.el = new Gtk.HeaderBar();
178 // set gobject values
179 this.el.title = "Modify / Create Property";
182 // user defined functions
185 public class Xcls_Table4 : Object
188 private Xcls_PopoverProperty _this;
194 public Xcls_Table4(Xcls_PopoverProperty _owner )
197 this.el = new Gtk.Table( 3, 2, true );
201 // set gobject values
202 this.el.margin_right = 4;
203 this.el.margin_left = 4;
204 this.el.row_spacing = 2;
205 var child_0 = new Xcls_Label5( _this );
207 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
208 var child_1 = new Xcls_kflag( _this );
210 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
211 var child_2 = new Xcls_Label9( _this );
213 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
214 var child_3 = new Xcls_ktype( _this );
216 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
217 var child_4 = new Xcls_Label11( _this );
219 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
220 var child_5 = new Xcls_kname( _this );
222 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
225 // user defined functions
227 public class Xcls_Label5 : Object
230 private Xcls_PopoverProperty _this;
236 public Xcls_Label5(Xcls_PopoverProperty _owner )
239 this.el = new Gtk.Label( "Special Flags" );
243 // set gobject values
244 this.el.justify = Gtk.Justification.RIGHT;
245 this.el.xalign = 0.900000f;
248 // user defined functions
251 public class Xcls_kflag : Object
253 public Gtk.ComboBox el;
254 private Xcls_PopoverProperty _this;
260 public Xcls_kflag(Xcls_PopoverProperty _owner )
264 this.el = new Gtk.ComboBox();
268 // set gobject values
269 var child_0 = new Xcls_dbcellrenderer( _this );
271 this.el.pack_start ( child_0.el , true );
272 var child_1 = new Xcls_dbmodel( _this );
274 this.el.set_model ( child_1.el );
278 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
281 // user defined functions
283 public class Xcls_dbcellrenderer : Object
285 public Gtk.CellRendererText el;
286 private Xcls_PopoverProperty _this;
292 public Xcls_dbcellrenderer(Xcls_PopoverProperty _owner )
295 _this.dbcellrenderer = this;
296 this.el = new Gtk.CellRendererText();
300 // set gobject values
303 // user defined functions
306 public class Xcls_dbmodel : Object
308 public Gtk.ListStore el;
309 private Xcls_PopoverProperty _this;
315 public Xcls_dbmodel(Xcls_PopoverProperty _owner )
318 _this.dbmodel = this;
319 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
323 // set gobject values
326 // user defined functions
327 public void loadData (string kflag) {
335 // user defined property '#'
336 // user defined method '|'
337 // special property '*' => prop |args|ctor|init
341 /// el.append(out iter);
344 // el.set_value(iter, 0, "");
345 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
348 el.set(iter, 0, "", 1, "Normal Property", -1);
350 if (_this.mainwindow.windowstate.file.xtype == "Gtk") {
352 el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1);
356 el.set(iter, 0, "#", 1, "(#) User defined property", -1);
359 el.set(iter, 0, "|", 1, "(|) User defined method", -1);
362 el.set(iter, 0, "*", 1, "(*) Special property (eg. prop | args | ctor | init )", -1);
366 el.set(iter, 0, "@", 1, "(@) Vala Signal", -1);
372 el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1);
375 el.set(iter, 0, "|", 1, "(|) User defined method", -1);
378 el.set(iter, 0, "*", 1, "(*) Special property (eg. prop )", -1);
382 el.foreach((tm, tp, titer) => {
384 el.get_value(titer, 0, out val);
386 print("check %s against %s\n", (string)val, kflag);
387 if (((string)val) == kflag) {
388 _this.kflag.el.set_active_iter(titer);
400 public class Xcls_Label9 : Object
403 private Xcls_PopoverProperty _this;
409 public Xcls_Label9(Xcls_PopoverProperty _owner )
412 this.el = new Gtk.Label( "Type" );
416 // set gobject values
417 this.el.justify = Gtk.Justification.RIGHT;
418 this.el.xalign = 0.900000f;
419 this.el.visible = true;
422 // user defined functions
425 public class Xcls_ktype : Object
428 private Xcls_PopoverProperty _this;
434 public Xcls_ktype(Xcls_PopoverProperty _owner )
438 this.el = new Gtk.Entry();
442 // set gobject values
443 this.el.visible = true;
446 // user defined functions
449 public class Xcls_Label11 : Object
452 private Xcls_PopoverProperty _this;
458 public Xcls_Label11(Xcls_PopoverProperty _owner )
461 this.el = new Gtk.Label( "Name" );
465 // set gobject values
466 this.el.justify = Gtk.Justification.RIGHT;
467 this.el.xalign = 0.900000f;
468 this.el.tooltip_text = "center, north, south, east, west";
469 this.el.visible = true;
472 // user defined functions
475 public class Xcls_kname : Object
478 private Xcls_PopoverProperty _this;
484 public Xcls_kname(Xcls_PopoverProperty _owner )
488 this.el = new Gtk.Entry();
492 // set gobject values
493 this.el.visible = true;
496 // user defined functions
500 public class Xcls_HButtonBox13 : Object
502 public Gtk.HButtonBox el;
503 private Xcls_PopoverProperty _this;
509 public Xcls_HButtonBox13(Xcls_PopoverProperty _owner )
512 this.el = new Gtk.HButtonBox();
516 // set gobject values
517 this.el.margin_right = 4;
518 this.el.margin_left = 4;
519 this.el.margin_bottom = 4;
520 var child_0 = new Xcls_Button14( _this );
522 this.el.add ( child_0.el );
523 var child_1 = new Xcls_save_btn( _this );
525 this.el.add ( child_1.el );
528 // user defined functions
530 public class Xcls_Button14 : Object
532 public Gtk.Button el;
533 private Xcls_PopoverProperty _this;
539 public Xcls_Button14(Xcls_PopoverProperty _owner )
542 this.el = new Gtk.Button();
546 // set gobject values
547 this.el.label = "Cancel";
550 this.el.clicked.connect( () => {
557 // user defined functions
560 public class Xcls_save_btn : Object
562 public Gtk.Button el;
563 private Xcls_PopoverProperty _this;
569 public Xcls_save_btn(Xcls_PopoverProperty _owner )
572 _this.save_btn = this;
573 this.el = new Gtk.Button();
577 // set gobject values
578 this.el.label = "Save";
581 this.el.clicked.connect( ( ) => {
586 if (_this.name.el.get_text().length < 1) {
587 StandardErrorDialog.show(
589 "You have to set Component name "
594 // what does this do?
596 var isNew = _this.file.name.length > 0 ? false : true;
601 // FIXME - this may be more complicated...
602 //for (var i in this.def) {
603 // this.file[i] = this.get(i).el.get_text();
608 _this.updateFileFromEntry();
609 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
610 Xcls_StandardErrorDialog.singleton().show(
612 "The name you used already exists "
623 var fn = _this.name.el.get_text();
624 var dir = _this.project.firstPath();
626 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
627 Xcls_StandardErrorDialog.singleton().show(
629 "That file already exists"
634 var f = JsRender.JsRender.factory(
635 _this.file.project.xtype,
637 dir + "/" + fn + ".bjs");
643 _this.updateFileFromEntry();
644 _this.file.loaded = true;
646 _this.file.project.addFile(_this.file);
655 _this.success(_this.project, _this.file);
661 // user defined functions