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;
98 _this.kname.el.set_text(kname);
99 _this.ktype.el.set_text(ktype);
101 _this.dbmodel.loadData(kflag);
102 // does node have this property...
105 if (key.length > 0) {
106 this.save_btn.el.set_label("Save");
108 this.save_btn.el.set_label("Create");
112 //console.log('show all');
113 this.el.set_modal(true);
114 this.el.set_relative_to(btn);
116 this.el.set_position(Gtk.PositionType.TOP);
119 print("SHOWALL - POPIP\n");
121 this.kname.el.grab_focus();
123 //this.success = c.success;
126 public void updateNodeFromValues () {
128 /* _this.file.title = _this.title.el.get_text();
129 _this.file.region = _this.region.el.get_text();
130 _this.file.parent = _this.parent.el.get_text();
131 _this.file.permname = _this.permname.el.get_text();
132 _this.file.modOrder = _this.modOrder.el.get_text();
134 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
135 _this.file.renameTo(_this.name.el.get_text());
137 // store the module...
138 _this.file.build_module = "";
140 if (_this.build_module.el.get_active_iter (out iter)) {
142 this.dbmodel.el.get_value (iter, 0, out vfname);
143 if (((string)vfname).length > 0) {
144 _this.file.build_module = (string)vfname;
154 public class Xcls_Box2 : Object
157 private Xcls_PopoverProperty _this;
163 public Xcls_Box2(Xcls_PopoverProperty _owner )
166 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
170 // set gobject values
171 this.el.homogeneous = false;
172 var child_0 = new Xcls_header( _this );
174 this.el.pack_start ( child_0.el , false,true,0 );
175 var child_1 = new Xcls_Table4( _this );
177 this.el.pack_start ( child_1.el , false,false,4 );
178 var child_2 = new Xcls_HButtonBox13( _this );
180 this.el.pack_end ( child_2.el , false,true,0 );
183 // user defined functions
185 public class Xcls_header : Object
187 public Gtk.HeaderBar el;
188 private Xcls_PopoverProperty _this;
194 public Xcls_header(Xcls_PopoverProperty _owner )
198 this.el = new Gtk.HeaderBar();
202 // set gobject values
203 this.el.title = "Modify / Create Property";
206 // user defined functions
209 public class Xcls_Table4 : Object
212 private Xcls_PopoverProperty _this;
218 public Xcls_Table4(Xcls_PopoverProperty _owner )
221 this.el = new Gtk.Table( 3, 2, true );
225 // set gobject values
226 this.el.margin_right = 4;
227 this.el.margin_left = 4;
228 this.el.row_spacing = 2;
229 var child_0 = new Xcls_Label5( _this );
231 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
232 var child_1 = new Xcls_kflag( _this );
234 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
235 var child_2 = new Xcls_Label9( _this );
237 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
238 var child_3 = new Xcls_ktype( _this );
240 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
241 var child_4 = new Xcls_Label11( _this );
243 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
244 var child_5 = new Xcls_kname( _this );
246 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
249 // user defined functions
251 public class Xcls_Label5 : Object
254 private Xcls_PopoverProperty _this;
260 public Xcls_Label5(Xcls_PopoverProperty _owner )
263 this.el = new Gtk.Label( "Special Flags" );
267 // set gobject values
268 this.el.justify = Gtk.Justification.RIGHT;
269 this.el.xalign = 0.900000f;
272 // user defined functions
275 public class Xcls_kflag : Object
277 public Gtk.ComboBox el;
278 private Xcls_PopoverProperty _this;
284 public Xcls_kflag(Xcls_PopoverProperty _owner )
288 this.el = new Gtk.ComboBox();
292 // set gobject values
293 var child_0 = new Xcls_dbcellrenderer( _this );
295 this.el.pack_start ( child_0.el , true );
296 var child_1 = new Xcls_dbmodel( _this );
298 this.el.set_model ( child_1.el );
302 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
305 // user defined functions
307 public class Xcls_dbcellrenderer : Object
309 public Gtk.CellRendererText el;
310 private Xcls_PopoverProperty _this;
316 public Xcls_dbcellrenderer(Xcls_PopoverProperty _owner )
319 _this.dbcellrenderer = this;
320 this.el = new Gtk.CellRendererText();
324 // set gobject values
327 // user defined functions
330 public class Xcls_dbmodel : Object
332 public Gtk.ListStore el;
333 private Xcls_PopoverProperty _this;
339 public Xcls_dbmodel(Xcls_PopoverProperty _owner )
342 _this.dbmodel = this;
343 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
347 // set gobject values
350 // user defined functions
351 public void loadData (string kflag) {
359 // user defined property '#'
360 // user defined method '|'
361 // special property '*' => prop |args|ctor|init
365 /// el.append(out iter);
368 // el.set_value(iter, 0, "");
369 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
372 el.set(iter, 0, "", 1, "Normal Property", -1);
374 if (_this.mainwindow.windowstate.file.xtype == "Gtk") {
376 el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1);
380 el.set(iter, 0, "#", 1, "(#) User defined property", -1);
383 el.set(iter, 0, "|", 1, "(|) User defined method", -1);
386 el.set(iter, 0, "*", 1, "(*) Special property (eg. prop | args | ctor | init )", -1);
390 el.set(iter, 0, "@", 1, "(@) Vala Signal", -1);
396 el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1);
399 el.set(iter, 0, "|", 1, "(|) User defined method", -1);
402 el.set(iter, 0, "*", 1, "(*) Special property (eg. prop )", -1);
406 el.foreach((tm, tp, titer) => {
408 el.get_value(titer, 0, out val);
410 print("check %s against %s\n", (string)val, kflag);
411 if (((string)val) == kflag) {
412 _this.kflag.el.set_active_iter(titer);
424 public class Xcls_Label9 : Object
427 private Xcls_PopoverProperty _this;
433 public Xcls_Label9(Xcls_PopoverProperty _owner )
436 this.el = new Gtk.Label( "Type" );
440 // set gobject values
441 this.el.justify = Gtk.Justification.RIGHT;
442 this.el.xalign = 0.900000f;
443 this.el.visible = true;
446 // user defined functions
449 public class Xcls_ktype : Object
452 private Xcls_PopoverProperty _this;
458 public Xcls_ktype(Xcls_PopoverProperty _owner )
462 this.el = new Gtk.Entry();
466 // set gobject values
467 this.el.visible = true;
470 // user defined functions
473 public class Xcls_Label11 : Object
476 private Xcls_PopoverProperty _this;
482 public Xcls_Label11(Xcls_PopoverProperty _owner )
485 this.el = new Gtk.Label( "Name" );
489 // set gobject values
490 this.el.justify = Gtk.Justification.RIGHT;
491 this.el.xalign = 0.900000f;
492 this.el.tooltip_text = "center, north, south, east, west";
493 this.el.visible = true;
496 // user defined functions
499 public class Xcls_kname : Object
502 private Xcls_PopoverProperty _this;
508 public Xcls_kname(Xcls_PopoverProperty _owner )
512 this.el = new Gtk.Entry();
516 // set gobject values
517 this.el.visible = true;
520 // user defined functions
524 public class Xcls_HButtonBox13 : Object
526 public Gtk.HButtonBox el;
527 private Xcls_PopoverProperty _this;
533 public Xcls_HButtonBox13(Xcls_PopoverProperty _owner )
536 this.el = new Gtk.HButtonBox();
540 // set gobject values
541 this.el.margin_right = 4;
542 this.el.margin_left = 4;
543 this.el.margin_bottom = 4;
544 var child_0 = new Xcls_Button14( _this );
546 this.el.add ( child_0.el );
547 var child_1 = new Xcls_save_btn( _this );
549 this.el.add ( child_1.el );
552 // user defined functions
554 public class Xcls_Button14 : Object
556 public Gtk.Button el;
557 private Xcls_PopoverProperty _this;
563 public Xcls_Button14(Xcls_PopoverProperty _owner )
566 this.el = new Gtk.Button();
570 // set gobject values
571 this.el.label = "Cancel";
574 this.el.clicked.connect( () => {
581 // user defined functions
584 public class Xcls_save_btn : Object
586 public Gtk.Button el;
587 private Xcls_PopoverProperty _this;
593 public Xcls_save_btn(Xcls_PopoverProperty _owner )
596 _this.save_btn = this;
597 this.el = new Gtk.Button();
601 // set gobject values
602 this.el.label = "Save";
605 this.el.clicked.connect( ( ) => {
610 if (_this.name.el.get_text().length < 1) {
611 StandardErrorDialog.show(
613 "You have to set Component name "
618 // what does this do?
620 var isNew = _this.file.name.length > 0 ? false : true;
625 // FIXME - this may be more complicated...
626 //for (var i in this.def) {
627 // this.file[i] = this.get(i).el.get_text();
632 _this.updateFileFromEntry();
633 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
634 Xcls_StandardErrorDialog.singleton().show(
636 "The name you used already exists "
647 var fn = _this.name.el.get_text();
648 var dir = _this.project.firstPath();
650 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
651 Xcls_StandardErrorDialog.singleton().show(
653 "That file already exists"
658 var f = JsRender.JsRender.factory(
659 _this.file.project.xtype,
661 dir + "/" + fn + ".bjs");
667 _this.updateFileFromEntry();
668 _this.file.loaded = true;
670 _this.file.project.addFile(_this.file);
679 _this.success(_this.project, _this.file);
685 // user defined functions