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( () => {
59 switch(this.key_type) {
61 var ov = _this.node.listeners.get(this.old_keyname);
62 _this.node.listeners.set(newtext, ov);
63 _this.node.listeners.unset(this.old_keyname);
65 _this.mainwindow.windowstate.leftprops.updateIter(iter, ktype, newtext, ov);
69 var ov = _this.node.props.get(oldval);
70 _this.node.props.set(newtext, ov);
71 _this.node.props.unset(oldval);
72 _this.updateIter(iter, ktype, newtext, ov);
81 // user defined functions
82 public void show (Gtk.Widget btn, JsRender.Node node, string key_type, string key)
85 string kname = "", kflag = "", ktype = "";
87 node.normalize_key( key, out kname, out kflag, out ktype);
90 if (key_type == "listener") {
91 this.header.el.title = "Modify Event Listener";
93 this.header.el.title = "Modify Property";
96 this.key_type = key_type;
97 this.old_keyname = key;
99 _this.kname.el.set_text(kname);
100 _this.ktype.el.set_text(ktype);
102 _this.dbmodel.loadData(kflag);
103 // does node have this property...
106 if (key.length > 0) {
107 this.save_btn.el.set_label("Save");
109 this.save_btn.el.set_label("Create");
113 //console.log('show all');
114 this.el.set_modal(true);
115 this.el.set_relative_to(btn);
117 this.el.set_position(Gtk.PositionType.TOP);
120 print("SHOWALL - POPIP\n");
122 this.kname.el.grab_focus();
124 //this.success = c.success;
127 public void updateNodeFromValues () {
129 /* _this.file.title = _this.title.el.get_text();
130 _this.file.region = _this.region.el.get_text();
131 _this.file.parent = _this.parent.el.get_text();
132 _this.file.permname = _this.permname.el.get_text();
133 _this.file.modOrder = _this.modOrder.el.get_text();
135 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
136 _this.file.renameTo(_this.name.el.get_text());
138 // store the module...
139 _this.file.build_module = "";
141 if (_this.build_module.el.get_active_iter (out iter)) {
143 this.dbmodel.el.get_value (iter, 0, out vfname);
144 if (((string)vfname).length > 0) {
145 _this.file.build_module = (string)vfname;
155 public class Xcls_Box2 : Object
158 private Xcls_PopoverProperty _this;
164 public Xcls_Box2(Xcls_PopoverProperty _owner )
167 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
171 // set gobject values
172 this.el.homogeneous = false;
173 var child_0 = new Xcls_header( _this );
175 this.el.pack_start ( child_0.el , false,true,0 );
176 var child_1 = new Xcls_Table4( _this );
178 this.el.pack_start ( child_1.el , false,false,4 );
179 var child_2 = new Xcls_HButtonBox13( _this );
181 this.el.pack_end ( child_2.el , false,true,0 );
184 // user defined functions
186 public class Xcls_header : Object
188 public Gtk.HeaderBar el;
189 private Xcls_PopoverProperty _this;
195 public Xcls_header(Xcls_PopoverProperty _owner )
199 this.el = new Gtk.HeaderBar();
203 // set gobject values
204 this.el.title = "Modify / Create Property";
207 // user defined functions
210 public class Xcls_Table4 : Object
213 private Xcls_PopoverProperty _this;
219 public Xcls_Table4(Xcls_PopoverProperty _owner )
222 this.el = new Gtk.Table( 3, 2, true );
226 // set gobject values
227 this.el.margin_right = 4;
228 this.el.margin_left = 4;
229 this.el.row_spacing = 2;
230 var child_0 = new Xcls_Label5( _this );
232 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
233 var child_1 = new Xcls_kflag( _this );
235 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
236 var child_2 = new Xcls_Label9( _this );
238 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
239 var child_3 = new Xcls_ktype( _this );
241 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
242 var child_4 = new Xcls_Label11( _this );
244 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
245 var child_5 = new Xcls_kname( _this );
247 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
250 // user defined functions
252 public class Xcls_Label5 : Object
255 private Xcls_PopoverProperty _this;
261 public Xcls_Label5(Xcls_PopoverProperty _owner )
264 this.el = new Gtk.Label( "Special Flags" );
268 // set gobject values
269 this.el.justify = Gtk.Justification.RIGHT;
270 this.el.xalign = 0.900000f;
273 // user defined functions
276 public class Xcls_kflag : Object
278 public Gtk.ComboBox el;
279 private Xcls_PopoverProperty _this;
285 public Xcls_kflag(Xcls_PopoverProperty _owner )
289 this.el = new Gtk.ComboBox();
293 // set gobject values
294 var child_0 = new Xcls_dbcellrenderer( _this );
296 this.el.pack_start ( child_0.el , true );
297 var child_1 = new Xcls_dbmodel( _this );
299 this.el.set_model ( child_1.el );
303 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
306 // user defined functions
308 public class Xcls_dbcellrenderer : Object
310 public Gtk.CellRendererText el;
311 private Xcls_PopoverProperty _this;
317 public Xcls_dbcellrenderer(Xcls_PopoverProperty _owner )
320 _this.dbcellrenderer = this;
321 this.el = new Gtk.CellRendererText();
325 // set gobject values
328 // user defined functions
331 public class Xcls_dbmodel : Object
333 public Gtk.ListStore el;
334 private Xcls_PopoverProperty _this;
340 public Xcls_dbmodel(Xcls_PopoverProperty _owner )
343 _this.dbmodel = this;
344 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
348 // set gobject values
351 // user defined functions
352 public void loadData (string kflag) {
360 // user defined property '#'
361 // user defined method '|'
362 // special property '*' => prop |args|ctor|init
366 /// el.append(out iter);
369 // el.set_value(iter, 0, "");
370 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
373 el.set(iter, 0, "", 1, "Normal Property", -1);
375 if (_this.mainwindow.windowstate.file.xtype == "Gtk") {
377 el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1);
381 el.set(iter, 0, "#", 1, "(#) User defined property", -1);
384 el.set(iter, 0, "|", 1, "(|) User defined method", -1);
387 el.set(iter, 0, "*", 1, "(*) Special property (eg. prop | args | ctor | init )", -1);
391 el.set(iter, 0, "@", 1, "(@) Vala Signal", -1);
397 el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1);
400 el.set(iter, 0, "|", 1, "(|) User defined method", -1);
403 el.set(iter, 0, "*", 1, "(*) Special property (eg. prop )", -1);
407 el.foreach((tm, tp, titer) => {
409 el.get_value(titer, 0, out val);
411 print("check %s against %s\n", (string)val, kflag);
412 if (((string)val) == kflag) {
413 _this.kflag.el.set_active_iter(titer);
425 public class Xcls_Label9 : Object
428 private Xcls_PopoverProperty _this;
434 public Xcls_Label9(Xcls_PopoverProperty _owner )
437 this.el = new Gtk.Label( "Type" );
441 // set gobject values
442 this.el.justify = Gtk.Justification.RIGHT;
443 this.el.xalign = 0.900000f;
444 this.el.visible = true;
447 // user defined functions
450 public class Xcls_ktype : Object
453 private Xcls_PopoverProperty _this;
459 public Xcls_ktype(Xcls_PopoverProperty _owner )
463 this.el = new Gtk.Entry();
467 // set gobject values
468 this.el.visible = true;
471 // user defined functions
474 public class Xcls_Label11 : Object
477 private Xcls_PopoverProperty _this;
483 public Xcls_Label11(Xcls_PopoverProperty _owner )
486 this.el = new Gtk.Label( "Name" );
490 // set gobject values
491 this.el.justify = Gtk.Justification.RIGHT;
492 this.el.xalign = 0.900000f;
493 this.el.tooltip_text = "center, north, south, east, west";
494 this.el.visible = true;
497 // user defined functions
500 public class Xcls_kname : Object
503 private Xcls_PopoverProperty _this;
509 public Xcls_kname(Xcls_PopoverProperty _owner )
513 this.el = new Gtk.Entry();
517 // set gobject values
518 this.el.visible = true;
521 // user defined functions
525 public class Xcls_HButtonBox13 : Object
527 public Gtk.HButtonBox el;
528 private Xcls_PopoverProperty _this;
534 public Xcls_HButtonBox13(Xcls_PopoverProperty _owner )
537 this.el = new Gtk.HButtonBox();
541 // set gobject values
542 this.el.margin_right = 4;
543 this.el.margin_left = 4;
544 this.el.margin_bottom = 4;
545 var child_0 = new Xcls_Button14( _this );
547 this.el.add ( child_0.el );
548 var child_1 = new Xcls_save_btn( _this );
550 this.el.add ( child_1.el );
553 // user defined functions
555 public class Xcls_Button14 : Object
557 public Gtk.Button el;
558 private Xcls_PopoverProperty _this;
564 public Xcls_Button14(Xcls_PopoverProperty _owner )
567 this.el = new Gtk.Button();
571 // set gobject values
572 this.el.label = "Cancel";
575 this.el.clicked.connect( () => {
582 // user defined functions
585 public class Xcls_save_btn : Object
587 public Gtk.Button el;
588 private Xcls_PopoverProperty _this;
594 public Xcls_save_btn(Xcls_PopoverProperty _owner )
597 _this.save_btn = this;
598 this.el = new Gtk.Button();
602 // set gobject values
603 this.el.label = "Save";
606 this.el.clicked.connect( ( ) => {
611 if (_this.name.el.get_text().length < 1) {
612 StandardErrorDialog.show(
614 "You have to set Component name "
619 // what does this do?
621 var isNew = _this.file.name.length > 0 ? false : true;
626 // FIXME - this may be more complicated...
627 //for (var i in this.def) {
628 // this.file[i] = this.get(i).el.get_text();
633 _this.updateFileFromEntry();
634 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
635 Xcls_StandardErrorDialog.singleton().show(
637 "The name you used already exists "
648 var fn = _this.name.el.get_text();
649 var dir = _this.project.firstPath();
651 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
652 Xcls_StandardErrorDialog.singleton().show(
654 "That file already exists"
659 var f = JsRender.JsRender.factory(
660 _this.file.project.xtype,
662 dir + "/" + fn + ".bjs");
668 _this.updateFileFromEntry();
669 _this.file.loaded = true;
671 _this.file.project.addFile(_this.file);
680 _this.success(_this.project, _this.file);
686 // user defined functions