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( () => {
60 var lp = _this.mainwindow.windowstate.left_props;
62 switch(this.key_type) {
64 var ov = _this.node.listeners.get(this.old_keyname);
65 _this.node.listeners.set(newtext, ov);
66 _this.node.listeners.unset(this.old_keyname);
69 lp.updateKey(this.old_keyname, this.key_type, newtext);
73 var ov = _this.node.props.get(this.old_keyname);
74 _this.node.props.set(newtext, ov);
75 _this.node.props.unset(this.old_keyname);
76 lp.updateKey(this.old_keyname, this.key_type, newtext);
85 // user defined functions
86 public void show (Gtk.Widget btn, JsRender.Node node, string key_type, string key)
89 string kname = "", kflag = "", ktype = "";
91 node.normalize_key( key, out kname, out kflag, out ktype);
94 if (key_type == "listener") {
95 this.header.el.title = "Modify Event Listener";
97 this.header.el.title = "Modify Property";
100 this.key_type = key_type;
101 this.old_keyname = key;
104 _this.kname.el.set_text(kname);
105 _this.ktype.el.set_text(ktype);
107 _this.dbmodel.loadData(kflag);
108 // does node have this property...
111 if (key.length > 0) {
112 this.save_btn.el.set_label("Save");
114 this.save_btn.el.set_label("Create");
118 //console.log('show all');
119 this.el.set_modal(true);
120 this.el.set_relative_to(btn);
122 this.el.set_position(Gtk.PositionType.TOP);
125 print("SHOWALL - POPIP\n");
127 this.kname.el.grab_focus();
129 //this.success = c.success;
132 public void updateNodeFromValues () {
134 /* _this.file.title = _this.title.el.get_text();
135 _this.file.region = _this.region.el.get_text();
136 _this.file.parent = _this.parent.el.get_text();
137 _this.file.permname = _this.permname.el.get_text();
138 _this.file.modOrder = _this.modOrder.el.get_text();
140 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
141 _this.file.renameTo(_this.name.el.get_text());
143 // store the module...
144 _this.file.build_module = "";
146 if (_this.build_module.el.get_active_iter (out iter)) {
148 this.dbmodel.el.get_value (iter, 0, out vfname);
149 if (((string)vfname).length > 0) {
150 _this.file.build_module = (string)vfname;
160 public class Xcls_Box2 : Object
163 private Xcls_PopoverProperty _this;
169 public Xcls_Box2(Xcls_PopoverProperty _owner )
172 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
176 // set gobject values
177 this.el.homogeneous = false;
178 var child_0 = new Xcls_header( _this );
180 this.el.pack_start ( child_0.el , false,true,0 );
181 var child_1 = new Xcls_Table4( _this );
183 this.el.pack_start ( child_1.el , false,false,4 );
184 var child_2 = new Xcls_HButtonBox13( _this );
186 this.el.pack_end ( child_2.el , false,true,0 );
189 // user defined functions
191 public class Xcls_header : Object
193 public Gtk.HeaderBar el;
194 private Xcls_PopoverProperty _this;
200 public Xcls_header(Xcls_PopoverProperty _owner )
204 this.el = new Gtk.HeaderBar();
208 // set gobject values
209 this.el.title = "Modify / Create Property";
212 // user defined functions
215 public class Xcls_Table4 : Object
218 private Xcls_PopoverProperty _this;
224 public Xcls_Table4(Xcls_PopoverProperty _owner )
227 this.el = new Gtk.Table( 3, 2, true );
231 // set gobject values
232 this.el.margin_right = 4;
233 this.el.margin_left = 4;
234 this.el.row_spacing = 2;
235 var child_0 = new Xcls_Label5( _this );
237 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
238 var child_1 = new Xcls_kflag( _this );
240 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
241 var child_2 = new Xcls_Label9( _this );
243 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
244 var child_3 = new Xcls_ktype( _this );
246 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
247 var child_4 = new Xcls_Label11( _this );
249 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
250 var child_5 = new Xcls_kname( _this );
252 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
255 // user defined functions
257 public class Xcls_Label5 : Object
260 private Xcls_PopoverProperty _this;
266 public Xcls_Label5(Xcls_PopoverProperty _owner )
269 this.el = new Gtk.Label( "Special Flags" );
273 // set gobject values
274 this.el.justify = Gtk.Justification.RIGHT;
275 this.el.xalign = 0.900000f;
278 // user defined functions
281 public class Xcls_kflag : Object
283 public Gtk.ComboBox el;
284 private Xcls_PopoverProperty _this;
290 public Xcls_kflag(Xcls_PopoverProperty _owner )
294 this.el = new Gtk.ComboBox();
298 // set gobject values
299 var child_0 = new Xcls_dbcellrenderer( _this );
301 this.el.pack_start ( child_0.el , true );
302 var child_1 = new Xcls_dbmodel( _this );
304 this.el.set_model ( child_1.el );
308 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
311 // user defined functions
313 public class Xcls_dbcellrenderer : Object
315 public Gtk.CellRendererText el;
316 private Xcls_PopoverProperty _this;
322 public Xcls_dbcellrenderer(Xcls_PopoverProperty _owner )
325 _this.dbcellrenderer = this;
326 this.el = new Gtk.CellRendererText();
330 // set gobject values
333 // user defined functions
336 public class Xcls_dbmodel : Object
338 public Gtk.ListStore el;
339 private Xcls_PopoverProperty _this;
345 public Xcls_dbmodel(Xcls_PopoverProperty _owner )
348 _this.dbmodel = this;
349 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
353 // set gobject values
356 // user defined functions
357 public void loadData (string kflag) {
365 // user defined property '#'
366 // user defined method '|'
367 // special property '*' => prop |args|ctor|init
371 /// el.append(out iter);
374 // el.set_value(iter, 0, "");
375 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
378 el.set(iter, 0, "", 1, "Normal Property", -1);
380 if (_this.mainwindow.windowstate.file.xtype == "Gtk") {
382 el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1);
386 el.set(iter, 0, "#", 1, "(#) User defined property", -1);
389 el.set(iter, 0, "|", 1, "(|) User defined method", -1);
392 el.set(iter, 0, "*", 1, "(*) Special property (eg. prop | args | ctor | init )", -1);
396 el.set(iter, 0, "@", 1, "(@) Vala Signal", -1);
402 el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1);
405 el.set(iter, 0, "|", 1, "(|) User defined method", -1);
408 el.set(iter, 0, "*", 1, "(*) Special property (eg. prop )", -1);
412 el.foreach((tm, tp, titer) => {
414 el.get_value(titer, 0, out val);
416 print("check %s against %s\n", (string)val, kflag);
417 if (((string)val) == kflag) {
418 _this.kflag.el.set_active_iter(titer);
430 public class Xcls_Label9 : Object
433 private Xcls_PopoverProperty _this;
439 public Xcls_Label9(Xcls_PopoverProperty _owner )
442 this.el = new Gtk.Label( "Type" );
446 // set gobject values
447 this.el.justify = Gtk.Justification.RIGHT;
448 this.el.xalign = 0.900000f;
449 this.el.visible = true;
452 // user defined functions
455 public class Xcls_ktype : Object
458 private Xcls_PopoverProperty _this;
464 public Xcls_ktype(Xcls_PopoverProperty _owner )
468 this.el = new Gtk.Entry();
472 // set gobject values
473 this.el.visible = true;
476 // user defined functions
479 public class Xcls_Label11 : Object
482 private Xcls_PopoverProperty _this;
488 public Xcls_Label11(Xcls_PopoverProperty _owner )
491 this.el = new Gtk.Label( "Name" );
495 // set gobject values
496 this.el.justify = Gtk.Justification.RIGHT;
497 this.el.xalign = 0.900000f;
498 this.el.tooltip_text = "center, north, south, east, west";
499 this.el.visible = true;
502 // user defined functions
505 public class Xcls_kname : Object
508 private Xcls_PopoverProperty _this;
514 public Xcls_kname(Xcls_PopoverProperty _owner )
518 this.el = new Gtk.Entry();
522 // set gobject values
523 this.el.visible = true;
526 // user defined functions
530 public class Xcls_HButtonBox13 : Object
532 public Gtk.HButtonBox el;
533 private Xcls_PopoverProperty _this;
539 public Xcls_HButtonBox13(Xcls_PopoverProperty _owner )
542 this.el = new Gtk.HButtonBox();
546 // set gobject values
547 this.el.margin_right = 4;
548 this.el.margin_left = 4;
549 this.el.margin_bottom = 4;
550 var child_0 = new Xcls_Button14( _this );
552 this.el.add ( child_0.el );
553 var child_1 = new Xcls_save_btn( _this );
555 this.el.add ( child_1.el );
558 // user defined functions
560 public class Xcls_Button14 : Object
562 public Gtk.Button el;
563 private Xcls_PopoverProperty _this;
569 public Xcls_Button14(Xcls_PopoverProperty _owner )
572 this.el = new Gtk.Button();
576 // set gobject values
577 this.el.label = "Cancel";
580 this.el.clicked.connect( () => {
587 // user defined functions
590 public class Xcls_save_btn : Object
592 public Gtk.Button el;
593 private Xcls_PopoverProperty _this;
599 public Xcls_save_btn(Xcls_PopoverProperty _owner )
602 _this.save_btn = this;
603 this.el = new Gtk.Button();
607 // set gobject values
608 this.el.label = "Save";
611 this.el.clicked.connect( ( ) => {
616 if (_this.name.el.get_text().length < 1) {
617 StandardErrorDialog.show(
619 "You have to set Component name "
624 // what does this do?
626 var isNew = _this.file.name.length > 0 ? false : true;
631 // FIXME - this may be more complicated...
632 //for (var i in this.def) {
633 // this.file[i] = this.get(i).el.get_text();
638 _this.updateFileFromEntry();
639 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
640 Xcls_StandardErrorDialog.singleton().show(
642 "The name you used already exists "
653 var fn = _this.name.el.get_text();
654 var dir = _this.project.firstPath();
656 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
657 Xcls_StandardErrorDialog.singleton().show(
659 "That file already exists"
664 var f = JsRender.JsRender.factory(
665 _this.file.project.xtype,
667 dir + "/" + fn + ".bjs");
673 _this.updateFileFromEntry();
674 _this.file.loaded = true;
676 _this.file.project.addFile(_this.file);
685 _this.success(_this.project, _this.file);
691 // user defined functions