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( () => {
57 var lp = _this.mainwindow.windowstate.left_props;
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);
66 //lp.updateIter(iter, ktype, newtext, ov);
70 var ov = _this.node.props.get(oldval);
71 _this.node.props.set(newtext, ov);
72 _this.node.props.unset(oldval);
73 _this.updateIter(iter, ktype, newtext, ov);
82 // user defined functions
83 public void show (Gtk.Widget btn, JsRender.Node node, string key_type, string key)
86 string kname = "", kflag = "", ktype = "";
88 node.normalize_key( key, out kname, out kflag, out ktype);
91 if (key_type == "listener") {
92 this.header.el.title = "Modify Event Listener";
94 this.header.el.title = "Modify Property";
97 this.key_type = key_type;
98 this.old_keyname = key;
101 _this.kname.el.set_text(kname);
102 _this.ktype.el.set_text(ktype);
104 _this.dbmodel.loadData(kflag);
105 // does node have this property...
108 if (key.length > 0) {
109 this.save_btn.el.set_label("Save");
111 this.save_btn.el.set_label("Create");
115 //console.log('show all');
116 this.el.set_modal(true);
117 this.el.set_relative_to(btn);
119 this.el.set_position(Gtk.PositionType.TOP);
122 print("SHOWALL - POPIP\n");
124 this.kname.el.grab_focus();
126 //this.success = c.success;
129 public void updateNodeFromValues () {
131 /* _this.file.title = _this.title.el.get_text();
132 _this.file.region = _this.region.el.get_text();
133 _this.file.parent = _this.parent.el.get_text();
134 _this.file.permname = _this.permname.el.get_text();
135 _this.file.modOrder = _this.modOrder.el.get_text();
137 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
138 _this.file.renameTo(_this.name.el.get_text());
140 // store the module...
141 _this.file.build_module = "";
143 if (_this.build_module.el.get_active_iter (out iter)) {
145 this.dbmodel.el.get_value (iter, 0, out vfname);
146 if (((string)vfname).length > 0) {
147 _this.file.build_module = (string)vfname;
157 public class Xcls_Box2 : Object
160 private Xcls_PopoverProperty _this;
166 public Xcls_Box2(Xcls_PopoverProperty _owner )
169 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
173 // set gobject values
174 this.el.homogeneous = false;
175 var child_0 = new Xcls_header( _this );
177 this.el.pack_start ( child_0.el , false,true,0 );
178 var child_1 = new Xcls_Table4( _this );
180 this.el.pack_start ( child_1.el , false,false,4 );
181 var child_2 = new Xcls_HButtonBox13( _this );
183 this.el.pack_end ( child_2.el , false,true,0 );
186 // user defined functions
188 public class Xcls_header : Object
190 public Gtk.HeaderBar el;
191 private Xcls_PopoverProperty _this;
197 public Xcls_header(Xcls_PopoverProperty _owner )
201 this.el = new Gtk.HeaderBar();
205 // set gobject values
206 this.el.title = "Modify / Create Property";
209 // user defined functions
212 public class Xcls_Table4 : Object
215 private Xcls_PopoverProperty _this;
221 public Xcls_Table4(Xcls_PopoverProperty _owner )
224 this.el = new Gtk.Table( 3, 2, true );
228 // set gobject values
229 this.el.margin_right = 4;
230 this.el.margin_left = 4;
231 this.el.row_spacing = 2;
232 var child_0 = new Xcls_Label5( _this );
234 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
235 var child_1 = new Xcls_kflag( _this );
237 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
238 var child_2 = new Xcls_Label9( _this );
240 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
241 var child_3 = new Xcls_ktype( _this );
243 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
244 var child_4 = new Xcls_Label11( _this );
246 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
247 var child_5 = new Xcls_kname( _this );
249 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
252 // user defined functions
254 public class Xcls_Label5 : Object
257 private Xcls_PopoverProperty _this;
263 public Xcls_Label5(Xcls_PopoverProperty _owner )
266 this.el = new Gtk.Label( "Special Flags" );
270 // set gobject values
271 this.el.justify = Gtk.Justification.RIGHT;
272 this.el.xalign = 0.900000f;
275 // user defined functions
278 public class Xcls_kflag : Object
280 public Gtk.ComboBox el;
281 private Xcls_PopoverProperty _this;
287 public Xcls_kflag(Xcls_PopoverProperty _owner )
291 this.el = new Gtk.ComboBox();
295 // set gobject values
296 var child_0 = new Xcls_dbcellrenderer( _this );
298 this.el.pack_start ( child_0.el , true );
299 var child_1 = new Xcls_dbmodel( _this );
301 this.el.set_model ( child_1.el );
305 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
308 // user defined functions
310 public class Xcls_dbcellrenderer : Object
312 public Gtk.CellRendererText el;
313 private Xcls_PopoverProperty _this;
319 public Xcls_dbcellrenderer(Xcls_PopoverProperty _owner )
322 _this.dbcellrenderer = this;
323 this.el = new Gtk.CellRendererText();
327 // set gobject values
330 // user defined functions
333 public class Xcls_dbmodel : Object
335 public Gtk.ListStore el;
336 private Xcls_PopoverProperty _this;
342 public Xcls_dbmodel(Xcls_PopoverProperty _owner )
345 _this.dbmodel = this;
346 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
350 // set gobject values
353 // user defined functions
354 public void loadData (string kflag) {
362 // user defined property '#'
363 // user defined method '|'
364 // special property '*' => prop |args|ctor|init
368 /// el.append(out iter);
371 // el.set_value(iter, 0, "");
372 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
375 el.set(iter, 0, "", 1, "Normal Property", -1);
377 if (_this.mainwindow.windowstate.file.xtype == "Gtk") {
379 el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1);
383 el.set(iter, 0, "#", 1, "(#) User defined property", -1);
386 el.set(iter, 0, "|", 1, "(|) User defined method", -1);
389 el.set(iter, 0, "*", 1, "(*) Special property (eg. prop | args | ctor | init )", -1);
393 el.set(iter, 0, "@", 1, "(@) Vala Signal", -1);
399 el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1);
402 el.set(iter, 0, "|", 1, "(|) User defined method", -1);
405 el.set(iter, 0, "*", 1, "(*) Special property (eg. prop )", -1);
409 el.foreach((tm, tp, titer) => {
411 el.get_value(titer, 0, out val);
413 print("check %s against %s\n", (string)val, kflag);
414 if (((string)val) == kflag) {
415 _this.kflag.el.set_active_iter(titer);
427 public class Xcls_Label9 : Object
430 private Xcls_PopoverProperty _this;
436 public Xcls_Label9(Xcls_PopoverProperty _owner )
439 this.el = new Gtk.Label( "Type" );
443 // set gobject values
444 this.el.justify = Gtk.Justification.RIGHT;
445 this.el.xalign = 0.900000f;
446 this.el.visible = true;
449 // user defined functions
452 public class Xcls_ktype : Object
455 private Xcls_PopoverProperty _this;
461 public Xcls_ktype(Xcls_PopoverProperty _owner )
465 this.el = new Gtk.Entry();
469 // set gobject values
470 this.el.visible = true;
473 // user defined functions
476 public class Xcls_Label11 : Object
479 private Xcls_PopoverProperty _this;
485 public Xcls_Label11(Xcls_PopoverProperty _owner )
488 this.el = new Gtk.Label( "Name" );
492 // set gobject values
493 this.el.justify = Gtk.Justification.RIGHT;
494 this.el.xalign = 0.900000f;
495 this.el.tooltip_text = "center, north, south, east, west";
496 this.el.visible = true;
499 // user defined functions
502 public class Xcls_kname : Object
505 private Xcls_PopoverProperty _this;
511 public Xcls_kname(Xcls_PopoverProperty _owner )
515 this.el = new Gtk.Entry();
519 // set gobject values
520 this.el.visible = true;
523 // user defined functions
527 public class Xcls_HButtonBox13 : Object
529 public Gtk.HButtonBox el;
530 private Xcls_PopoverProperty _this;
536 public Xcls_HButtonBox13(Xcls_PopoverProperty _owner )
539 this.el = new Gtk.HButtonBox();
543 // set gobject values
544 this.el.margin_right = 4;
545 this.el.margin_left = 4;
546 this.el.margin_bottom = 4;
547 var child_0 = new Xcls_Button14( _this );
549 this.el.add ( child_0.el );
550 var child_1 = new Xcls_save_btn( _this );
552 this.el.add ( child_1.el );
555 // user defined functions
557 public class Xcls_Button14 : Object
559 public Gtk.Button el;
560 private Xcls_PopoverProperty _this;
566 public Xcls_Button14(Xcls_PopoverProperty _owner )
569 this.el = new Gtk.Button();
573 // set gobject values
574 this.el.label = "Cancel";
577 this.el.clicked.connect( () => {
584 // user defined functions
587 public class Xcls_save_btn : Object
589 public Gtk.Button el;
590 private Xcls_PopoverProperty _this;
596 public Xcls_save_btn(Xcls_PopoverProperty _owner )
599 _this.save_btn = this;
600 this.el = new Gtk.Button();
604 // set gobject values
605 this.el.label = "Save";
608 this.el.clicked.connect( ( ) => {
613 if (_this.name.el.get_text().length < 1) {
614 StandardErrorDialog.show(
616 "You have to set Component name "
621 // what does this do?
623 var isNew = _this.file.name.length > 0 ? false : true;
628 // FIXME - this may be more complicated...
629 //for (var i in this.def) {
630 // this.file[i] = this.get(i).el.get_text();
635 _this.updateFileFromEntry();
636 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
637 Xcls_StandardErrorDialog.singleton().show(
639 "The name you used already exists "
650 var fn = _this.name.el.get_text();
651 var dir = _this.project.firstPath();
653 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
654 Xcls_StandardErrorDialog.singleton().show(
656 "That file already exists"
661 var f = JsRender.JsRender.factory(
662 _this.file.project.xtype,
664 dir + "/" + fn + ".bjs");
670 _this.updateFileFromEntry();
671 _this.file.loaded = true;
673 _this.file.project.addFile(_this.file);
682 _this.success(_this.project, _this.file);
688 // user defined functions