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 this.kflag.get_active_iter(out citer);
61 this.dbmodel.el.get_value(citer, 0, gval);
63 newtext += (string)gval;
64 newtext += this.ktype.el.get_text().length > 0 && newtext.length > 0 ? " " :"";
65 newtext += this.ktype.el.get_text() ;
66 newtext += this.kname.el.get_text().length > 0 && newtext.length > 0 ? " " :"";
67 newtext += this.kname.el.get_text();
70 var lp = _this.mainwindow.windowstate.left_props;
72 switch(this.key_type) {
74 var ov = _this.node.listeners.get(this.old_keyname);
75 _this.node.listeners.set(newtext, ov);
76 _this.node.listeners.unset(this.old_keyname);
79 lp.updateKey(this.old_keyname, this.key_type, newtext);
83 var ov = _this.node.props.get(this.old_keyname);
84 _this.node.props.set(newtext, ov);
85 _this.node.props.unset(this.old_keyname);
86 lp.updateKey(this.old_keyname, this.key_type, newtext);
95 // user defined functions
96 public void show (Gtk.Widget btn, JsRender.Node node, string key_type, string key)
99 string kname = "", kflag = "", ktype = "";
100 if (key.length > 0) {
101 node.normalize_key( key, out kname, out kflag, out ktype);
104 if (key_type == "listener") {
105 this.header.el.title = "Modify Event Listener";
107 this.header.el.title = "Modify Property";
110 this.key_type = key_type;
111 this.old_keyname = key;
114 _this.kname.el.set_text(kname);
115 _this.ktype.el.set_text(ktype);
117 _this.dbmodel.loadData(kflag);
118 // does node have this property...
121 if (key.length > 0) {
122 this.save_btn.el.set_label("Save");
124 this.save_btn.el.set_label("Create");
128 //console.log('show all');
129 this.el.set_modal(true);
130 this.el.set_relative_to(btn);
132 this.el.set_position(Gtk.PositionType.TOP);
135 print("SHOWALL - POPIP\n");
137 this.kname.el.grab_focus();
139 //this.success = c.success;
142 public void updateNodeFromValues () {
144 /* _this.file.title = _this.title.el.get_text();
145 _this.file.region = _this.region.el.get_text();
146 _this.file.parent = _this.parent.el.get_text();
147 _this.file.permname = _this.permname.el.get_text();
148 _this.file.modOrder = _this.modOrder.el.get_text();
150 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
151 _this.file.renameTo(_this.name.el.get_text());
153 // store the module...
154 _this.file.build_module = "";
156 if (_this.build_module.el.get_active_iter (out iter)) {
158 this.dbmodel.el.get_value (iter, 0, out vfname);
159 if (((string)vfname).length > 0) {
160 _this.file.build_module = (string)vfname;
170 public class Xcls_Box2 : Object
173 private Xcls_PopoverProperty _this;
179 public Xcls_Box2(Xcls_PopoverProperty _owner )
182 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
186 // set gobject values
187 this.el.homogeneous = false;
188 var child_0 = new Xcls_header( _this );
190 this.el.pack_start ( child_0.el , false,true,0 );
191 var child_1 = new Xcls_Table4( _this );
193 this.el.pack_start ( child_1.el , false,false,4 );
194 var child_2 = new Xcls_HButtonBox13( _this );
196 this.el.pack_end ( child_2.el , false,true,0 );
199 // user defined functions
201 public class Xcls_header : Object
203 public Gtk.HeaderBar el;
204 private Xcls_PopoverProperty _this;
210 public Xcls_header(Xcls_PopoverProperty _owner )
214 this.el = new Gtk.HeaderBar();
218 // set gobject values
219 this.el.title = "Modify / Create Property";
222 // user defined functions
225 public class Xcls_Table4 : Object
228 private Xcls_PopoverProperty _this;
234 public Xcls_Table4(Xcls_PopoverProperty _owner )
237 this.el = new Gtk.Table( 3, 2, true );
241 // set gobject values
242 this.el.margin_right = 4;
243 this.el.margin_left = 4;
244 this.el.row_spacing = 2;
245 var child_0 = new Xcls_Label5( _this );
247 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
248 var child_1 = new Xcls_kflag( _this );
250 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
251 var child_2 = new Xcls_Label9( _this );
253 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
254 var child_3 = new Xcls_ktype( _this );
256 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
257 var child_4 = new Xcls_Label11( _this );
259 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
260 var child_5 = new Xcls_kname( _this );
262 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
265 // user defined functions
267 public class Xcls_Label5 : Object
270 private Xcls_PopoverProperty _this;
276 public Xcls_Label5(Xcls_PopoverProperty _owner )
279 this.el = new Gtk.Label( "Special Flags" );
283 // set gobject values
284 this.el.justify = Gtk.Justification.RIGHT;
285 this.el.xalign = 0.900000f;
288 // user defined functions
291 public class Xcls_kflag : Object
293 public Gtk.ComboBox el;
294 private Xcls_PopoverProperty _this;
300 public Xcls_kflag(Xcls_PopoverProperty _owner )
304 this.el = new Gtk.ComboBox();
308 // set gobject values
309 var child_0 = new Xcls_dbcellrenderer( _this );
311 this.el.pack_start ( child_0.el , true );
312 var child_1 = new Xcls_dbmodel( _this );
314 this.el.set_model ( child_1.el );
318 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
321 // user defined functions
323 public class Xcls_dbcellrenderer : Object
325 public Gtk.CellRendererText el;
326 private Xcls_PopoverProperty _this;
332 public Xcls_dbcellrenderer(Xcls_PopoverProperty _owner )
335 _this.dbcellrenderer = this;
336 this.el = new Gtk.CellRendererText();
340 // set gobject values
343 // user defined functions
346 public class Xcls_dbmodel : Object
348 public Gtk.ListStore el;
349 private Xcls_PopoverProperty _this;
355 public Xcls_dbmodel(Xcls_PopoverProperty _owner )
358 _this.dbmodel = this;
359 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
363 // set gobject values
366 // user defined functions
367 public void loadData (string kflag) {
375 // user defined property '#'
376 // user defined method '|'
377 // special property '*' => prop |args|ctor|init
381 /// el.append(out iter);
384 // el.set_value(iter, 0, "");
385 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
388 el.set(iter, 0, "", 1, "Normal Property", -1);
390 if (_this.mainwindow.windowstate.file.xtype == "Gtk") {
392 el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1);
396 el.set(iter, 0, "#", 1, "(#) User defined property", -1);
399 el.set(iter, 0, "|", 1, "(|) User defined method", -1);
402 el.set(iter, 0, "*", 1, "(*) Special property (eg. prop | args | ctor | init )", -1);
406 el.set(iter, 0, "@", 1, "(@) Vala Signal", -1);
412 el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1);
415 el.set(iter, 0, "|", 1, "(|) User defined method", -1);
418 el.set(iter, 0, "*", 1, "(*) Special property (eg. prop )", -1);
422 el.foreach((tm, tp, titer) => {
424 el.get_value(titer, 0, out val);
426 print("check %s against %s\n", (string)val, kflag);
427 if (((string)val) == kflag) {
428 _this.kflag.el.set_active_iter(titer);
440 public class Xcls_Label9 : Object
443 private Xcls_PopoverProperty _this;
449 public Xcls_Label9(Xcls_PopoverProperty _owner )
452 this.el = new Gtk.Label( "Type" );
456 // set gobject values
457 this.el.justify = Gtk.Justification.RIGHT;
458 this.el.xalign = 0.900000f;
459 this.el.visible = true;
462 // user defined functions
465 public class Xcls_ktype : Object
468 private Xcls_PopoverProperty _this;
474 public Xcls_ktype(Xcls_PopoverProperty _owner )
478 this.el = new Gtk.Entry();
482 // set gobject values
483 this.el.visible = true;
486 // user defined functions
489 public class Xcls_Label11 : Object
492 private Xcls_PopoverProperty _this;
498 public Xcls_Label11(Xcls_PopoverProperty _owner )
501 this.el = new Gtk.Label( "Name" );
505 // set gobject values
506 this.el.justify = Gtk.Justification.RIGHT;
507 this.el.xalign = 0.900000f;
508 this.el.tooltip_text = "center, north, south, east, west";
509 this.el.visible = true;
512 // user defined functions
515 public class Xcls_kname : Object
518 private Xcls_PopoverProperty _this;
524 public Xcls_kname(Xcls_PopoverProperty _owner )
528 this.el = new Gtk.Entry();
532 // set gobject values
533 this.el.visible = true;
536 // user defined functions
540 public class Xcls_HButtonBox13 : Object
542 public Gtk.HButtonBox el;
543 private Xcls_PopoverProperty _this;
549 public Xcls_HButtonBox13(Xcls_PopoverProperty _owner )
552 this.el = new Gtk.HButtonBox();
556 // set gobject values
557 this.el.margin_right = 4;
558 this.el.margin_left = 4;
559 this.el.margin_bottom = 4;
560 var child_0 = new Xcls_Button14( _this );
562 this.el.add ( child_0.el );
563 var child_1 = new Xcls_save_btn( _this );
565 this.el.add ( child_1.el );
568 // user defined functions
570 public class Xcls_Button14 : Object
572 public Gtk.Button el;
573 private Xcls_PopoverProperty _this;
579 public Xcls_Button14(Xcls_PopoverProperty _owner )
582 this.el = new Gtk.Button();
586 // set gobject values
587 this.el.label = "Cancel";
590 this.el.clicked.connect( () => {
597 // user defined functions
600 public class Xcls_save_btn : Object
602 public Gtk.Button el;
603 private Xcls_PopoverProperty _this;
609 public Xcls_save_btn(Xcls_PopoverProperty _owner )
612 _this.save_btn = this;
613 this.el = new Gtk.Button();
617 // set gobject values
618 this.el.label = "Save";
621 this.el.clicked.connect( ( ) => {
626 if (_this.name.el.get_text().length < 1) {
627 StandardErrorDialog.show(
629 "You have to set Component name "
634 // what does this do?
636 var isNew = _this.file.name.length > 0 ? false : true;
641 // FIXME - this may be more complicated...
642 //for (var i in this.def) {
643 // this.file[i] = this.get(i).el.get_text();
648 _this.updateFileFromEntry();
649 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
650 Xcls_StandardErrorDialog.singleton().show(
652 "The name you used already exists "
663 var fn = _this.name.el.get_text();
664 var dir = _this.project.firstPath();
666 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
667 Xcls_StandardErrorDialog.singleton().show(
669 "That file already exists"
674 var f = JsRender.JsRender.factory(
675 _this.file.project.xtype,
677 dir + "/" + fn + ".bjs");
683 _this.updateFileFromEntry();
684 _this.file.loaded = true;
686 _this.file.project.addFile(_this.file);
695 _this.success(_this.project, _this.file);
701 // user defined functions