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 signal void success (Project.Project pr, JsRender.JsRender file);
26 public Xcls_MainWindow mainwindow;
27 public string key_type;
28 public JsRender.Node node;
31 public Xcls_PopoverProperty()
34 this.el = new Gtk.Popover( null );
38 this.mainwindow = null;
41 this.el.border_width = 0;
43 this.el.position = Gtk.PositionType.RIGHT;
44 var child_0 = new Xcls_Box2( _this );
46 this.el.add ( child_0.el );
49 this.el.closed.connect( () => {
57 print("ktype: %s\n",ktype);
58 switch(this.key_type) {
60 var ov = _this.node.listeners.get(oldval);
61 _this.node.listeners.set(newtext, ov);
62 _this.node.listeners.unset(oldval);
64 _this.updateIter(iter, ktype, newtext, ov);
68 var ov = _this.node.props.get(oldval);
69 _this.node.props.set(newtext, ov);
70 _this.node.props.unset(oldval);
71 _this.updateIter(iter, ktype, newtext, ov);
80 // user defined functions
81 public void show (Gtk.Widget btn, JsRender.Node node, string key_type, string key)
84 string kname = "", kflag = "", ktype = "";
86 node.normalize_key( key, out kname, out kflag, out ktype);
89 if (key_type == "listener") {
90 this.header.el.title = "Modify Event Listener";
92 this.header.el.title = "Modify Property";
95 this.key_type = key_type;
97 _this.kname.el.set_text(kname);
98 _this.ktype.el.set_text(ktype);
100 _this.dbmodel.loadData(kflag);
101 // does node have this property...
104 if (key.length > 0) {
105 this.save_btn.el.set_label("Save");
107 this.save_btn.el.set_label("Create");
111 //console.log('show all');
112 this.el.set_modal(true);
113 this.el.set_relative_to(btn);
115 this.el.set_position(Gtk.PositionType.TOP);
118 print("SHOWALL - POPIP\n");
120 this.kname.el.grab_focus();
122 //this.success = c.success;
125 public void updateNodeFromValues () {
127 /* _this.file.title = _this.title.el.get_text();
128 _this.file.region = _this.region.el.get_text();
129 _this.file.parent = _this.parent.el.get_text();
130 _this.file.permname = _this.permname.el.get_text();
131 _this.file.modOrder = _this.modOrder.el.get_text();
133 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
134 _this.file.renameTo(_this.name.el.get_text());
136 // store the module...
137 _this.file.build_module = "";
139 if (_this.build_module.el.get_active_iter (out iter)) {
141 this.dbmodel.el.get_value (iter, 0, out vfname);
142 if (((string)vfname).length > 0) {
143 _this.file.build_module = (string)vfname;
153 public class Xcls_Box2 : Object
156 private Xcls_PopoverProperty _this;
162 public Xcls_Box2(Xcls_PopoverProperty _owner )
165 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
169 // set gobject values
170 this.el.homogeneous = false;
171 var child_0 = new Xcls_header( _this );
173 this.el.pack_start ( child_0.el , false,true,0 );
174 var child_1 = new Xcls_Table4( _this );
176 this.el.pack_start ( child_1.el , false,false,4 );
177 var child_2 = new Xcls_HButtonBox13( _this );
179 this.el.pack_end ( child_2.el , false,true,0 );
182 // user defined functions
184 public class Xcls_header : Object
186 public Gtk.HeaderBar el;
187 private Xcls_PopoverProperty _this;
193 public Xcls_header(Xcls_PopoverProperty _owner )
197 this.el = new Gtk.HeaderBar();
201 // set gobject values
202 this.el.title = "Modify / Create Property";
205 // user defined functions
208 public class Xcls_Table4 : Object
211 private Xcls_PopoverProperty _this;
217 public Xcls_Table4(Xcls_PopoverProperty _owner )
220 this.el = new Gtk.Table( 3, 2, true );
224 // set gobject values
225 this.el.margin_right = 4;
226 this.el.margin_left = 4;
227 this.el.row_spacing = 2;
228 var child_0 = new Xcls_Label5( _this );
230 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
231 var child_1 = new Xcls_kflag( _this );
233 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
234 var child_2 = new Xcls_Label9( _this );
236 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
237 var child_3 = new Xcls_ktype( _this );
239 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
240 var child_4 = new Xcls_Label11( _this );
242 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
243 var child_5 = new Xcls_kname( _this );
245 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
248 // user defined functions
250 public class Xcls_Label5 : Object
253 private Xcls_PopoverProperty _this;
259 public Xcls_Label5(Xcls_PopoverProperty _owner )
262 this.el = new Gtk.Label( "Special Flags" );
266 // set gobject values
267 this.el.justify = Gtk.Justification.RIGHT;
268 this.el.xalign = 0.900000f;
271 // user defined functions
274 public class Xcls_kflag : Object
276 public Gtk.ComboBox el;
277 private Xcls_PopoverProperty _this;
283 public Xcls_kflag(Xcls_PopoverProperty _owner )
287 this.el = new Gtk.ComboBox();
291 // set gobject values
292 var child_0 = new Xcls_dbcellrenderer( _this );
294 this.el.pack_start ( child_0.el , true );
295 var child_1 = new Xcls_dbmodel( _this );
297 this.el.set_model ( child_1.el );
301 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
304 // user defined functions
306 public class Xcls_dbcellrenderer : Object
308 public Gtk.CellRendererText el;
309 private Xcls_PopoverProperty _this;
315 public Xcls_dbcellrenderer(Xcls_PopoverProperty _owner )
318 _this.dbcellrenderer = this;
319 this.el = new Gtk.CellRendererText();
323 // set gobject values
326 // user defined functions
329 public class Xcls_dbmodel : Object
331 public Gtk.ListStore el;
332 private Xcls_PopoverProperty _this;
338 public Xcls_dbmodel(Xcls_PopoverProperty _owner )
341 _this.dbmodel = this;
342 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
346 // set gobject values
349 // user defined functions
350 public void loadData (string kflag) {
358 // user defined property '#'
359 // user defined method '|'
360 // special property '*' => prop |args|ctor|init
364 /// el.append(out iter);
367 // el.set_value(iter, 0, "");
368 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
371 el.set(iter, 0, "", 1, "Normal Property", -1);
373 if (_this.mainwindow.windowstate.file.xtype == "Gtk") {
375 el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1);
379 el.set(iter, 0, "#", 1, "(#) User defined property", -1);
382 el.set(iter, 0, "|", 1, "(|) User defined method", -1);
385 el.set(iter, 0, "*", 1, "(*) Special property (eg. prop | args | ctor | init )", -1);
389 el.set(iter, 0, "@", 1, "(@) Vala Signal", -1);
395 el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1);
398 el.set(iter, 0, "|", 1, "(|) User defined method", -1);
401 el.set(iter, 0, "*", 1, "(*) Special property (eg. prop )", -1);
405 el.foreach((tm, tp, titer) => {
407 el.get_value(titer, 0, out val);
409 print("check %s against %s\n", (string)val, kflag);
410 if (((string)val) == kflag) {
411 _this.kflag.el.set_active_iter(titer);
423 public class Xcls_Label9 : Object
426 private Xcls_PopoverProperty _this;
432 public Xcls_Label9(Xcls_PopoverProperty _owner )
435 this.el = new Gtk.Label( "Type" );
439 // set gobject values
440 this.el.justify = Gtk.Justification.RIGHT;
441 this.el.xalign = 0.900000f;
442 this.el.visible = true;
445 // user defined functions
448 public class Xcls_ktype : Object
451 private Xcls_PopoverProperty _this;
457 public Xcls_ktype(Xcls_PopoverProperty _owner )
461 this.el = new Gtk.Entry();
465 // set gobject values
466 this.el.visible = true;
469 // user defined functions
472 public class Xcls_Label11 : Object
475 private Xcls_PopoverProperty _this;
481 public Xcls_Label11(Xcls_PopoverProperty _owner )
484 this.el = new Gtk.Label( "Name" );
488 // set gobject values
489 this.el.justify = Gtk.Justification.RIGHT;
490 this.el.xalign = 0.900000f;
491 this.el.tooltip_text = "center, north, south, east, west";
492 this.el.visible = true;
495 // user defined functions
498 public class Xcls_kname : Object
501 private Xcls_PopoverProperty _this;
507 public Xcls_kname(Xcls_PopoverProperty _owner )
511 this.el = new Gtk.Entry();
515 // set gobject values
516 this.el.visible = true;
519 // user defined functions
523 public class Xcls_HButtonBox13 : Object
525 public Gtk.HButtonBox el;
526 private Xcls_PopoverProperty _this;
532 public Xcls_HButtonBox13(Xcls_PopoverProperty _owner )
535 this.el = new Gtk.HButtonBox();
539 // set gobject values
540 this.el.margin_right = 4;
541 this.el.margin_left = 4;
542 this.el.margin_bottom = 4;
543 var child_0 = new Xcls_Button14( _this );
545 this.el.add ( child_0.el );
546 var child_1 = new Xcls_save_btn( _this );
548 this.el.add ( child_1.el );
551 // user defined functions
553 public class Xcls_Button14 : Object
555 public Gtk.Button el;
556 private Xcls_PopoverProperty _this;
562 public Xcls_Button14(Xcls_PopoverProperty _owner )
565 this.el = new Gtk.Button();
569 // set gobject values
570 this.el.label = "Cancel";
573 this.el.clicked.connect( () => {
580 // user defined functions
583 public class Xcls_save_btn : Object
585 public Gtk.Button el;
586 private Xcls_PopoverProperty _this;
592 public Xcls_save_btn(Xcls_PopoverProperty _owner )
595 _this.save_btn = this;
596 this.el = new Gtk.Button();
600 // set gobject values
601 this.el.label = "Save";
604 this.el.clicked.connect( ( ) => {
609 if (_this.name.el.get_text().length < 1) {
610 StandardErrorDialog.show(
612 "You have to set Component name "
617 // what does this do?
619 var isNew = _this.file.name.length > 0 ? false : true;
624 // FIXME - this may be more complicated...
625 //for (var i in this.def) {
626 // this.file[i] = this.get(i).el.get_text();
631 _this.updateFileFromEntry();
632 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
633 Xcls_StandardErrorDialog.singleton().show(
635 "The name you used already exists "
646 var fn = _this.name.el.get_text();
647 var dir = _this.project.firstPath();
649 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
650 Xcls_StandardErrorDialog.singleton().show(
652 "That file already exists"
657 var f = JsRender.JsRender.factory(
658 _this.file.project.xtype,
660 dir + "/" + fn + ".bjs");
666 _this.updateFileFromEntry();
667 _this.file.loaded = true;
669 _this.file.project.addFile(_this.file);
678 _this.success(_this.project, _this.file);
684 // user defined functions