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( () => {
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);
65 _this.mainwindow.windowstate.leftprops.updateIter(iter, ktype, newtext, ov);
69 var ov = _this.node.props.get(oldval);
70 _this.node.props.set(newtext, ov);
71 _this.node.props.unset(oldval);
72 _this.updateIter(iter, ktype, newtext, ov);
81 // user defined functions
82 public void show (Gtk.Widget btn, JsRender.Node node, string key_type, string key)
85 string kname = "", kflag = "", ktype = "";
87 node.normalize_key( key, out kname, out kflag, out ktype);
90 if (key_type == "listener") {
91 this.header.el.title = "Modify Event Listener";
93 this.header.el.title = "Modify Property";
96 this.key_type = key_type;
97 this.old_keyname = key;
100 _this.kname.el.set_text(kname);
101 _this.ktype.el.set_text(ktype);
103 _this.dbmodel.loadData(kflag);
104 // does node have this property...
107 if (key.length > 0) {
108 this.save_btn.el.set_label("Save");
110 this.save_btn.el.set_label("Create");
114 //console.log('show all');
115 this.el.set_modal(true);
116 this.el.set_relative_to(btn);
118 this.el.set_position(Gtk.PositionType.TOP);
121 print("SHOWALL - POPIP\n");
123 this.kname.el.grab_focus();
125 //this.success = c.success;
128 public void updateNodeFromValues () {
130 /* _this.file.title = _this.title.el.get_text();
131 _this.file.region = _this.region.el.get_text();
132 _this.file.parent = _this.parent.el.get_text();
133 _this.file.permname = _this.permname.el.get_text();
134 _this.file.modOrder = _this.modOrder.el.get_text();
136 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
137 _this.file.renameTo(_this.name.el.get_text());
139 // store the module...
140 _this.file.build_module = "";
142 if (_this.build_module.el.get_active_iter (out iter)) {
144 this.dbmodel.el.get_value (iter, 0, out vfname);
145 if (((string)vfname).length > 0) {
146 _this.file.build_module = (string)vfname;
156 public class Xcls_Box2 : Object
159 private Xcls_PopoverProperty _this;
165 public Xcls_Box2(Xcls_PopoverProperty _owner )
168 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
172 // set gobject values
173 this.el.homogeneous = false;
174 var child_0 = new Xcls_header( _this );
176 this.el.pack_start ( child_0.el , false,true,0 );
177 var child_1 = new Xcls_Table4( _this );
179 this.el.pack_start ( child_1.el , false,false,4 );
180 var child_2 = new Xcls_HButtonBox13( _this );
182 this.el.pack_end ( child_2.el , false,true,0 );
185 // user defined functions
187 public class Xcls_header : Object
189 public Gtk.HeaderBar el;
190 private Xcls_PopoverProperty _this;
196 public Xcls_header(Xcls_PopoverProperty _owner )
200 this.el = new Gtk.HeaderBar();
204 // set gobject values
205 this.el.title = "Modify / Create Property";
208 // user defined functions
211 public class Xcls_Table4 : Object
214 private Xcls_PopoverProperty _this;
220 public Xcls_Table4(Xcls_PopoverProperty _owner )
223 this.el = new Gtk.Table( 3, 2, true );
227 // set gobject values
228 this.el.margin_right = 4;
229 this.el.margin_left = 4;
230 this.el.row_spacing = 2;
231 var child_0 = new Xcls_Label5( _this );
233 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
234 var child_1 = new Xcls_kflag( _this );
236 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
237 var child_2 = new Xcls_Label9( _this );
239 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
240 var child_3 = new Xcls_ktype( _this );
242 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
243 var child_4 = new Xcls_Label11( _this );
245 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
246 var child_5 = new Xcls_kname( _this );
248 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
251 // user defined functions
253 public class Xcls_Label5 : Object
256 private Xcls_PopoverProperty _this;
262 public Xcls_Label5(Xcls_PopoverProperty _owner )
265 this.el = new Gtk.Label( "Special Flags" );
269 // set gobject values
270 this.el.justify = Gtk.Justification.RIGHT;
271 this.el.xalign = 0.900000f;
274 // user defined functions
277 public class Xcls_kflag : Object
279 public Gtk.ComboBox el;
280 private Xcls_PopoverProperty _this;
286 public Xcls_kflag(Xcls_PopoverProperty _owner )
290 this.el = new Gtk.ComboBox();
294 // set gobject values
295 var child_0 = new Xcls_dbcellrenderer( _this );
297 this.el.pack_start ( child_0.el , true );
298 var child_1 = new Xcls_dbmodel( _this );
300 this.el.set_model ( child_1.el );
304 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
307 // user defined functions
309 public class Xcls_dbcellrenderer : Object
311 public Gtk.CellRendererText el;
312 private Xcls_PopoverProperty _this;
318 public Xcls_dbcellrenderer(Xcls_PopoverProperty _owner )
321 _this.dbcellrenderer = this;
322 this.el = new Gtk.CellRendererText();
326 // set gobject values
329 // user defined functions
332 public class Xcls_dbmodel : Object
334 public Gtk.ListStore el;
335 private Xcls_PopoverProperty _this;
341 public Xcls_dbmodel(Xcls_PopoverProperty _owner )
344 _this.dbmodel = this;
345 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
349 // set gobject values
352 // user defined functions
353 public void loadData (string kflag) {
361 // user defined property '#'
362 // user defined method '|'
363 // special property '*' => prop |args|ctor|init
367 /// el.append(out iter);
370 // el.set_value(iter, 0, "");
371 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
374 el.set(iter, 0, "", 1, "Normal Property", -1);
376 if (_this.mainwindow.windowstate.file.xtype == "Gtk") {
378 el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1);
382 el.set(iter, 0, "#", 1, "(#) User defined property", -1);
385 el.set(iter, 0, "|", 1, "(|) User defined method", -1);
388 el.set(iter, 0, "*", 1, "(*) Special property (eg. prop | args | ctor | init )", -1);
392 el.set(iter, 0, "@", 1, "(@) Vala Signal", -1);
398 el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1);
401 el.set(iter, 0, "|", 1, "(|) User defined method", -1);
404 el.set(iter, 0, "*", 1, "(*) Special property (eg. prop )", -1);
408 el.foreach((tm, tp, titer) => {
410 el.get_value(titer, 0, out val);
412 print("check %s against %s\n", (string)val, kflag);
413 if (((string)val) == kflag) {
414 _this.kflag.el.set_active_iter(titer);
426 public class Xcls_Label9 : Object
429 private Xcls_PopoverProperty _this;
435 public Xcls_Label9(Xcls_PopoverProperty _owner )
438 this.el = new Gtk.Label( "Type" );
442 // set gobject values
443 this.el.justify = Gtk.Justification.RIGHT;
444 this.el.xalign = 0.900000f;
445 this.el.visible = true;
448 // user defined functions
451 public class Xcls_ktype : Object
454 private Xcls_PopoverProperty _this;
460 public Xcls_ktype(Xcls_PopoverProperty _owner )
464 this.el = new Gtk.Entry();
468 // set gobject values
469 this.el.visible = true;
472 // user defined functions
475 public class Xcls_Label11 : Object
478 private Xcls_PopoverProperty _this;
484 public Xcls_Label11(Xcls_PopoverProperty _owner )
487 this.el = new Gtk.Label( "Name" );
491 // set gobject values
492 this.el.justify = Gtk.Justification.RIGHT;
493 this.el.xalign = 0.900000f;
494 this.el.tooltip_text = "center, north, south, east, west";
495 this.el.visible = true;
498 // user defined functions
501 public class Xcls_kname : Object
504 private Xcls_PopoverProperty _this;
510 public Xcls_kname(Xcls_PopoverProperty _owner )
514 this.el = new Gtk.Entry();
518 // set gobject values
519 this.el.visible = true;
522 // user defined functions
526 public class Xcls_HButtonBox13 : Object
528 public Gtk.HButtonBox el;
529 private Xcls_PopoverProperty _this;
535 public Xcls_HButtonBox13(Xcls_PopoverProperty _owner )
538 this.el = new Gtk.HButtonBox();
542 // set gobject values
543 this.el.margin_right = 4;
544 this.el.margin_left = 4;
545 this.el.margin_bottom = 4;
546 var child_0 = new Xcls_Button14( _this );
548 this.el.add ( child_0.el );
549 var child_1 = new Xcls_save_btn( _this );
551 this.el.add ( child_1.el );
554 // user defined functions
556 public class Xcls_Button14 : Object
558 public Gtk.Button el;
559 private Xcls_PopoverProperty _this;
565 public Xcls_Button14(Xcls_PopoverProperty _owner )
568 this.el = new Gtk.Button();
572 // set gobject values
573 this.el.label = "Cancel";
576 this.el.clicked.connect( () => {
583 // user defined functions
586 public class Xcls_save_btn : Object
588 public Gtk.Button el;
589 private Xcls_PopoverProperty _this;
595 public Xcls_save_btn(Xcls_PopoverProperty _owner )
598 _this.save_btn = this;
599 this.el = new Gtk.Button();
603 // set gobject values
604 this.el.label = "Save";
607 this.el.clicked.connect( ( ) => {
612 if (_this.name.el.get_text().length < 1) {
613 StandardErrorDialog.show(
615 "You have to set Component name "
620 // what does this do?
622 var isNew = _this.file.name.length > 0 ? false : true;
627 // FIXME - this may be more complicated...
628 //for (var i in this.def) {
629 // this.file[i] = this.get(i).el.get_text();
634 _this.updateFileFromEntry();
635 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
636 Xcls_StandardErrorDialog.singleton().show(
638 "The name you used already exists "
649 var fn = _this.name.el.get_text();
650 var dir = _this.project.firstPath();
652 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
653 Xcls_StandardErrorDialog.singleton().show(
655 "That file already exists"
660 var f = JsRender.JsRender.factory(
661 _this.file.project.xtype,
663 dir + "/" + fn + ".bjs");
669 _this.updateFileFromEntry();
670 _this.file.loaded = true;
672 _this.file.project.addFile(_this.file);
681 _this.success(_this.project, _this.file);
687 // user defined functions