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 string old_keyname;
25 public signal void success (Project.Project pr, JsRender.JsRender file);
27 public Xcls_MainWindow mainwindow;
28 public string key_type;
29 public JsRender.Node node;
32 public Xcls_PopoverProperty()
35 this.el = new Gtk.Popover( null );
39 this.mainwindow = null;
42 this.el.border_width = 0;
44 this.el.position = Gtk.PositionType.RIGHT;
45 var child_0 = new Xcls_Box2( _this );
47 this.el.add ( child_0.el );
50 this.el.closed.connect( () => {
58 newtext += this.ktype.el.get_text().length > 0 && newtext.length > 0 ? " " :"";
59 newtext += this.ktype.el.get_text() ;
60 newtext += this.kname.el.get_text().length > 0 && newtext.length > 0 ? " " :"";
61 newtext += this.kname.el.get_text();
64 var lp = _this.mainwindow.windowstate.left_props;
66 switch(this.key_type) {
68 var ov = _this.node.listeners.get(this.old_keyname);
69 _this.node.listeners.set(newtext, ov);
70 _this.node.listeners.unset(this.old_keyname);
73 lp.updateKey(this.old_keyname, this.key_type, newtext);
77 var ov = _this.node.props.get(this.old_keyname);
78 _this.node.props.set(newtext, ov);
79 _this.node.props.unset(this.old_keyname);
80 lp.updateKey(this.old_keyname, this.key_type, newtext);
89 // user defined functions
90 public void show (Gtk.Widget btn, JsRender.Node node, string key_type, string key)
93 string kname = "", kflag = "", ktype = "";
95 node.normalize_key( key, out kname, out kflag, out ktype);
98 if (key_type == "listener") {
99 this.header.el.title = "Modify Event Listener";
101 this.header.el.title = "Modify Property";
104 this.key_type = key_type;
105 this.old_keyname = key;
108 _this.kname.el.set_text(kname);
109 _this.ktype.el.set_text(ktype);
111 _this.dbmodel.loadData(kflag);
112 // does node have this property...
115 if (key.length > 0) {
116 this.save_btn.el.set_label("Save");
118 this.save_btn.el.set_label("Create");
122 //console.log('show all');
123 this.el.set_modal(true);
124 this.el.set_relative_to(btn);
126 this.el.set_position(Gtk.PositionType.TOP);
129 print("SHOWALL - POPIP\n");
131 this.kname.el.grab_focus();
133 //this.success = c.success;
136 public void updateNodeFromValues () {
138 /* _this.file.title = _this.title.el.get_text();
139 _this.file.region = _this.region.el.get_text();
140 _this.file.parent = _this.parent.el.get_text();
141 _this.file.permname = _this.permname.el.get_text();
142 _this.file.modOrder = _this.modOrder.el.get_text();
144 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
145 _this.file.renameTo(_this.name.el.get_text());
147 // store the module...
148 _this.file.build_module = "";
150 if (_this.build_module.el.get_active_iter (out iter)) {
152 this.dbmodel.el.get_value (iter, 0, out vfname);
153 if (((string)vfname).length > 0) {
154 _this.file.build_module = (string)vfname;
164 public class Xcls_Box2 : Object
167 private Xcls_PopoverProperty _this;
173 public Xcls_Box2(Xcls_PopoverProperty _owner )
176 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
180 // set gobject values
181 this.el.homogeneous = false;
182 var child_0 = new Xcls_header( _this );
184 this.el.pack_start ( child_0.el , false,true,0 );
185 var child_1 = new Xcls_Table4( _this );
187 this.el.pack_start ( child_1.el , false,false,4 );
188 var child_2 = new Xcls_HButtonBox13( _this );
190 this.el.pack_end ( child_2.el , false,true,0 );
193 // user defined functions
195 public class Xcls_header : Object
197 public Gtk.HeaderBar el;
198 private Xcls_PopoverProperty _this;
204 public Xcls_header(Xcls_PopoverProperty _owner )
208 this.el = new Gtk.HeaderBar();
212 // set gobject values
213 this.el.title = "Modify / Create Property";
216 // user defined functions
219 public class Xcls_Table4 : Object
222 private Xcls_PopoverProperty _this;
228 public Xcls_Table4(Xcls_PopoverProperty _owner )
231 this.el = new Gtk.Table( 3, 2, true );
235 // set gobject values
236 this.el.margin_right = 4;
237 this.el.margin_left = 4;
238 this.el.row_spacing = 2;
239 var child_0 = new Xcls_Label5( _this );
241 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
242 var child_1 = new Xcls_kflag( _this );
244 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
245 var child_2 = new Xcls_Label9( _this );
247 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
248 var child_3 = new Xcls_ktype( _this );
250 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
251 var child_4 = new Xcls_Label11( _this );
253 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
254 var child_5 = new Xcls_kname( _this );
256 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
259 // user defined functions
261 public class Xcls_Label5 : Object
264 private Xcls_PopoverProperty _this;
270 public Xcls_Label5(Xcls_PopoverProperty _owner )
273 this.el = new Gtk.Label( "Special Flags" );
277 // set gobject values
278 this.el.justify = Gtk.Justification.RIGHT;
279 this.el.xalign = 0.900000f;
282 // user defined functions
285 public class Xcls_kflag : Object
287 public Gtk.ComboBox el;
288 private Xcls_PopoverProperty _this;
294 public Xcls_kflag(Xcls_PopoverProperty _owner )
298 this.el = new Gtk.ComboBox();
302 // set gobject values
303 var child_0 = new Xcls_dbcellrenderer( _this );
305 this.el.pack_start ( child_0.el , true );
306 var child_1 = new Xcls_dbmodel( _this );
308 this.el.set_model ( child_1.el );
312 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
315 // user defined functions
317 public class Xcls_dbcellrenderer : Object
319 public Gtk.CellRendererText el;
320 private Xcls_PopoverProperty _this;
326 public Xcls_dbcellrenderer(Xcls_PopoverProperty _owner )
329 _this.dbcellrenderer = this;
330 this.el = new Gtk.CellRendererText();
334 // set gobject values
337 // user defined functions
340 public class Xcls_dbmodel : Object
342 public Gtk.ListStore el;
343 private Xcls_PopoverProperty _this;
349 public Xcls_dbmodel(Xcls_PopoverProperty _owner )
352 _this.dbmodel = this;
353 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
357 // set gobject values
360 // user defined functions
361 public void loadData (string kflag) {
369 // user defined property '#'
370 // user defined method '|'
371 // special property '*' => prop |args|ctor|init
375 /// el.append(out iter);
378 // el.set_value(iter, 0, "");
379 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
382 el.set(iter, 0, "", 1, "Normal Property", -1);
384 if (_this.mainwindow.windowstate.file.xtype == "Gtk") {
386 el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1);
390 el.set(iter, 0, "#", 1, "(#) User defined property", -1);
393 el.set(iter, 0, "|", 1, "(|) User defined method", -1);
396 el.set(iter, 0, "*", 1, "(*) Special property (eg. prop | args | ctor | init )", -1);
400 el.set(iter, 0, "@", 1, "(@) Vala Signal", -1);
406 el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1);
409 el.set(iter, 0, "|", 1, "(|) User defined method", -1);
412 el.set(iter, 0, "*", 1, "(*) Special property (eg. prop )", -1);
416 el.foreach((tm, tp, titer) => {
418 el.get_value(titer, 0, out val);
420 print("check %s against %s\n", (string)val, kflag);
421 if (((string)val) == kflag) {
422 _this.kflag.el.set_active_iter(titer);
434 public class Xcls_Label9 : Object
437 private Xcls_PopoverProperty _this;
443 public Xcls_Label9(Xcls_PopoverProperty _owner )
446 this.el = new Gtk.Label( "Type" );
450 // set gobject values
451 this.el.justify = Gtk.Justification.RIGHT;
452 this.el.xalign = 0.900000f;
453 this.el.visible = true;
456 // user defined functions
459 public class Xcls_ktype : Object
462 private Xcls_PopoverProperty _this;
468 public Xcls_ktype(Xcls_PopoverProperty _owner )
472 this.el = new Gtk.Entry();
476 // set gobject values
477 this.el.visible = true;
480 // user defined functions
483 public class Xcls_Label11 : Object
486 private Xcls_PopoverProperty _this;
492 public Xcls_Label11(Xcls_PopoverProperty _owner )
495 this.el = new Gtk.Label( "Name" );
499 // set gobject values
500 this.el.justify = Gtk.Justification.RIGHT;
501 this.el.xalign = 0.900000f;
502 this.el.tooltip_text = "center, north, south, east, west";
503 this.el.visible = true;
506 // user defined functions
509 public class Xcls_kname : Object
512 private Xcls_PopoverProperty _this;
518 public Xcls_kname(Xcls_PopoverProperty _owner )
522 this.el = new Gtk.Entry();
526 // set gobject values
527 this.el.visible = true;
530 // user defined functions
534 public class Xcls_HButtonBox13 : Object
536 public Gtk.HButtonBox el;
537 private Xcls_PopoverProperty _this;
543 public Xcls_HButtonBox13(Xcls_PopoverProperty _owner )
546 this.el = new Gtk.HButtonBox();
550 // set gobject values
551 this.el.margin_right = 4;
552 this.el.margin_left = 4;
553 this.el.margin_bottom = 4;
554 var child_0 = new Xcls_Button14( _this );
556 this.el.add ( child_0.el );
557 var child_1 = new Xcls_save_btn( _this );
559 this.el.add ( child_1.el );
562 // user defined functions
564 public class Xcls_Button14 : Object
566 public Gtk.Button el;
567 private Xcls_PopoverProperty _this;
573 public Xcls_Button14(Xcls_PopoverProperty _owner )
576 this.el = new Gtk.Button();
580 // set gobject values
581 this.el.label = "Cancel";
584 this.el.clicked.connect( () => {
591 // user defined functions
594 public class Xcls_save_btn : Object
596 public Gtk.Button el;
597 private Xcls_PopoverProperty _this;
603 public Xcls_save_btn(Xcls_PopoverProperty _owner )
606 _this.save_btn = this;
607 this.el = new Gtk.Button();
611 // set gobject values
612 this.el.label = "Save";
615 this.el.clicked.connect( ( ) => {
620 if (_this.name.el.get_text().length < 1) {
621 StandardErrorDialog.show(
623 "You have to set Component name "
628 // what does this do?
630 var isNew = _this.file.name.length > 0 ? false : true;
635 // FIXME - this may be more complicated...
636 //for (var i in this.def) {
637 // this.file[i] = this.get(i).el.get_text();
642 _this.updateFileFromEntry();
643 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
644 Xcls_StandardErrorDialog.singleton().show(
646 "The name you used already exists "
657 var fn = _this.name.el.get_text();
658 var dir = _this.project.firstPath();
660 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
661 Xcls_StandardErrorDialog.singleton().show(
663 "That file already exists"
668 var f = JsRender.JsRender.factory(
669 _this.file.project.xtype,
671 dir + "/" + fn + ".bjs");
677 _this.updateFileFromEntry();
678 _this.file.loaded = true;
680 _this.file.project.addFile(_this.file);
689 _this.success(_this.project, _this.file);
695 // user defined functions