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( () => {
62 newtext += this.ktype.el.get_text().length > 0 && newtext.length > 0 ? " " :"";
63 newtext += this.ktype.el.get_text() ;
64 newtext += this.kname.el.get_text().length > 0 && newtext.length > 0 ? " " :"";
65 newtext += this.kname.el.get_text();
68 var lp = _this.mainwindow.windowstate.left_props;
70 switch(this.key_type) {
72 var ov = _this.node.listeners.get(this.old_keyname);
73 _this.node.listeners.set(newtext, ov);
74 _this.node.listeners.unset(this.old_keyname);
77 lp.updateKey(this.old_keyname, this.key_type, newtext);
81 var ov = _this.node.props.get(this.old_keyname);
82 _this.node.props.set(newtext, ov);
83 _this.node.props.unset(this.old_keyname);
84 lp.updateKey(this.old_keyname, this.key_type, newtext);
93 // user defined functions
94 public void show (Gtk.Widget btn, JsRender.Node node, string key_type, string key)
97 string kname = "", kflag = "", ktype = "";
99 node.normalize_key( key, out kname, out kflag, out ktype);
102 if (key_type == "listener") {
103 this.header.el.title = "Modify Event Listener";
105 this.header.el.title = "Modify Property";
108 this.key_type = key_type;
109 this.old_keyname = key;
112 _this.kname.el.set_text(kname);
113 _this.ktype.el.set_text(ktype);
115 _this.dbmodel.loadData(kflag);
116 // does node have this property...
119 if (key.length > 0) {
120 this.save_btn.el.set_label("Save");
122 this.save_btn.el.set_label("Create");
126 //console.log('show all');
127 this.el.set_modal(true);
128 this.el.set_relative_to(btn);
130 this.el.set_position(Gtk.PositionType.TOP);
133 print("SHOWALL - POPIP\n");
135 this.kname.el.grab_focus();
137 //this.success = c.success;
140 public void updateNodeFromValues () {
142 /* _this.file.title = _this.title.el.get_text();
143 _this.file.region = _this.region.el.get_text();
144 _this.file.parent = _this.parent.el.get_text();
145 _this.file.permname = _this.permname.el.get_text();
146 _this.file.modOrder = _this.modOrder.el.get_text();
148 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
149 _this.file.renameTo(_this.name.el.get_text());
151 // store the module...
152 _this.file.build_module = "";
154 if (_this.build_module.el.get_active_iter (out iter)) {
156 this.dbmodel.el.get_value (iter, 0, out vfname);
157 if (((string)vfname).length > 0) {
158 _this.file.build_module = (string)vfname;
168 public class Xcls_Box2 : Object
171 private Xcls_PopoverProperty _this;
177 public Xcls_Box2(Xcls_PopoverProperty _owner )
180 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
184 // set gobject values
185 this.el.homogeneous = false;
186 var child_0 = new Xcls_header( _this );
188 this.el.pack_start ( child_0.el , false,true,0 );
189 var child_1 = new Xcls_Table4( _this );
191 this.el.pack_start ( child_1.el , false,false,4 );
192 var child_2 = new Xcls_HButtonBox13( _this );
194 this.el.pack_end ( child_2.el , false,true,0 );
197 // user defined functions
199 public class Xcls_header : Object
201 public Gtk.HeaderBar el;
202 private Xcls_PopoverProperty _this;
208 public Xcls_header(Xcls_PopoverProperty _owner )
212 this.el = new Gtk.HeaderBar();
216 // set gobject values
217 this.el.title = "Modify / Create Property";
220 // user defined functions
223 public class Xcls_Table4 : Object
226 private Xcls_PopoverProperty _this;
232 public Xcls_Table4(Xcls_PopoverProperty _owner )
235 this.el = new Gtk.Table( 3, 2, true );
239 // set gobject values
240 this.el.margin_right = 4;
241 this.el.margin_left = 4;
242 this.el.row_spacing = 2;
243 var child_0 = new Xcls_Label5( _this );
245 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
246 var child_1 = new Xcls_kflag( _this );
248 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
249 var child_2 = new Xcls_Label9( _this );
251 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
252 var child_3 = new Xcls_ktype( _this );
254 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
255 var child_4 = new Xcls_Label11( _this );
257 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
258 var child_5 = new Xcls_kname( _this );
260 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
263 // user defined functions
265 public class Xcls_Label5 : Object
268 private Xcls_PopoverProperty _this;
274 public Xcls_Label5(Xcls_PopoverProperty _owner )
277 this.el = new Gtk.Label( "Special Flags" );
281 // set gobject values
282 this.el.justify = Gtk.Justification.RIGHT;
283 this.el.xalign = 0.900000f;
286 // user defined functions
289 public class Xcls_kflag : Object
291 public Gtk.ComboBox el;
292 private Xcls_PopoverProperty _this;
298 public Xcls_kflag(Xcls_PopoverProperty _owner )
302 this.el = new Gtk.ComboBox();
306 // set gobject values
307 var child_0 = new Xcls_dbcellrenderer( _this );
309 this.el.pack_start ( child_0.el , true );
310 var child_1 = new Xcls_dbmodel( _this );
312 this.el.set_model ( child_1.el );
316 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
319 // user defined functions
321 public class Xcls_dbcellrenderer : Object
323 public Gtk.CellRendererText el;
324 private Xcls_PopoverProperty _this;
330 public Xcls_dbcellrenderer(Xcls_PopoverProperty _owner )
333 _this.dbcellrenderer = this;
334 this.el = new Gtk.CellRendererText();
338 // set gobject values
341 // user defined functions
344 public class Xcls_dbmodel : Object
346 public Gtk.ListStore el;
347 private Xcls_PopoverProperty _this;
353 public Xcls_dbmodel(Xcls_PopoverProperty _owner )
356 _this.dbmodel = this;
357 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
361 // set gobject values
364 // user defined functions
365 public void loadData (string kflag) {
373 // user defined property '#'
374 // user defined method '|'
375 // special property '*' => prop |args|ctor|init
379 /// el.append(out iter);
382 // el.set_value(iter, 0, "");
383 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
386 el.set(iter, 0, "", 1, "Normal Property", -1);
388 if (_this.mainwindow.windowstate.file.xtype == "Gtk") {
390 el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1);
394 el.set(iter, 0, "#", 1, "(#) User defined property", -1);
397 el.set(iter, 0, "|", 1, "(|) User defined method", -1);
400 el.set(iter, 0, "*", 1, "(*) Special property (eg. prop | args | ctor | init )", -1);
404 el.set(iter, 0, "@", 1, "(@) Vala Signal", -1);
410 el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1);
413 el.set(iter, 0, "|", 1, "(|) User defined method", -1);
416 el.set(iter, 0, "*", 1, "(*) Special property (eg. prop )", -1);
420 el.foreach((tm, tp, titer) => {
422 el.get_value(titer, 0, out val);
424 print("check %s against %s\n", (string)val, kflag);
425 if (((string)val) == kflag) {
426 _this.kflag.el.set_active_iter(titer);
438 public class Xcls_Label9 : Object
441 private Xcls_PopoverProperty _this;
447 public Xcls_Label9(Xcls_PopoverProperty _owner )
450 this.el = new Gtk.Label( "Type" );
454 // set gobject values
455 this.el.justify = Gtk.Justification.RIGHT;
456 this.el.xalign = 0.900000f;
457 this.el.visible = true;
460 // user defined functions
463 public class Xcls_ktype : Object
466 private Xcls_PopoverProperty _this;
472 public Xcls_ktype(Xcls_PopoverProperty _owner )
476 this.el = new Gtk.Entry();
480 // set gobject values
481 this.el.visible = true;
484 // user defined functions
487 public class Xcls_Label11 : Object
490 private Xcls_PopoverProperty _this;
496 public Xcls_Label11(Xcls_PopoverProperty _owner )
499 this.el = new Gtk.Label( "Name" );
503 // set gobject values
504 this.el.justify = Gtk.Justification.RIGHT;
505 this.el.xalign = 0.900000f;
506 this.el.tooltip_text = "center, north, south, east, west";
507 this.el.visible = true;
510 // user defined functions
513 public class Xcls_kname : Object
516 private Xcls_PopoverProperty _this;
522 public Xcls_kname(Xcls_PopoverProperty _owner )
526 this.el = new Gtk.Entry();
530 // set gobject values
531 this.el.visible = true;
534 // user defined functions
538 public class Xcls_HButtonBox13 : Object
540 public Gtk.HButtonBox el;
541 private Xcls_PopoverProperty _this;
547 public Xcls_HButtonBox13(Xcls_PopoverProperty _owner )
550 this.el = new Gtk.HButtonBox();
554 // set gobject values
555 this.el.margin_right = 4;
556 this.el.margin_left = 4;
557 this.el.margin_bottom = 4;
558 var child_0 = new Xcls_Button14( _this );
560 this.el.add ( child_0.el );
561 var child_1 = new Xcls_save_btn( _this );
563 this.el.add ( child_1.el );
566 // user defined functions
568 public class Xcls_Button14 : Object
570 public Gtk.Button el;
571 private Xcls_PopoverProperty _this;
577 public Xcls_Button14(Xcls_PopoverProperty _owner )
580 this.el = new Gtk.Button();
584 // set gobject values
585 this.el.label = "Cancel";
588 this.el.clicked.connect( () => {
595 // user defined functions
598 public class Xcls_save_btn : Object
600 public Gtk.Button el;
601 private Xcls_PopoverProperty _this;
607 public Xcls_save_btn(Xcls_PopoverProperty _owner )
610 _this.save_btn = this;
611 this.el = new Gtk.Button();
615 // set gobject values
616 this.el.label = "Save";
619 this.el.clicked.connect( ( ) => {
624 if (_this.name.el.get_text().length < 1) {
625 StandardErrorDialog.show(
627 "You have to set Component name "
632 // what does this do?
634 var isNew = _this.file.name.length > 0 ? false : true;
639 // FIXME - this may be more complicated...
640 //for (var i in this.def) {
641 // this.file[i] = this.get(i).el.get_text();
646 _this.updateFileFromEntry();
647 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
648 Xcls_StandardErrorDialog.singleton().show(
650 "The name you used already exists "
661 var fn = _this.name.el.get_text();
662 var dir = _this.project.firstPath();
664 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
665 Xcls_StandardErrorDialog.singleton().show(
667 "That file already exists"
672 var f = JsRender.JsRender.factory(
673 _this.file.project.xtype,
675 dir + "/" + fn + ".bjs");
681 _this.updateFileFromEntry();
682 _this.file.loaded = true;
684 _this.file.project.addFile(_this.file);
693 _this.success(_this.project, _this.file);
699 // user defined functions