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 JsRender.Node node;
30 public Xcls_PopoverProperty()
33 this.el = new Gtk.Popover( null );
37 this.mainwindow = null;
40 this.el.border_width = 0;
42 this.el.position = Gtk.PositionType.RIGHT;
43 var child_0 = new Xcls_Box2( _this );
45 this.el.add ( child_0.el );
48 this.el.closed.connect( () => {
56 // user defined functions
57 public void show (Gtk.Widget btn, JsRender.Node node, string key)
60 string kname = "", kflag = "", ktype = "";
62 node.normalize_key( key, out kname, out kflag, out ktype);
65 _this.kname.el.set_text(kname);
66 _this.ktype.el.set_text(ktype);
68 _this.dbmodel.loadData(kflag);
69 // does node have this property...
73 this.save_btn.el.set_label("Save");
75 this.save_btn.el.set_label("Create");
79 //console.log('show all');
80 this.el.set_modal(true);
81 this.el.set_relative_to(btn);
83 this.el.set_position(Gtk.PositionType.TOP);
86 print("SHOWALL - POPIP\n");
88 this.kname.el.grab_focus();
90 //this.success = c.success;
93 public void updateNodeFromValues () {
95 /* _this.file.title = _this.title.el.get_text();
96 _this.file.region = _this.region.el.get_text();
97 _this.file.parent = _this.parent.el.get_text();
98 _this.file.permname = _this.permname.el.get_text();
99 _this.file.modOrder = _this.modOrder.el.get_text();
101 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
102 _this.file.renameTo(_this.name.el.get_text());
104 // store the module...
105 _this.file.build_module = "";
107 if (_this.build_module.el.get_active_iter (out iter)) {
109 this.dbmodel.el.get_value (iter, 0, out vfname);
110 if (((string)vfname).length > 0) {
111 _this.file.build_module = (string)vfname;
121 public class Xcls_Box2 : Object
124 private Xcls_PopoverProperty _this;
130 public Xcls_Box2(Xcls_PopoverProperty _owner )
133 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
137 // set gobject values
138 this.el.homogeneous = false;
139 var child_0 = new Xcls_header( _this );
141 this.el.pack_start ( child_0.el , false,true,0 );
142 var child_1 = new Xcls_Table4( _this );
144 this.el.pack_start ( child_1.el , false,false,4 );
145 var child_2 = new Xcls_HButtonBox13( _this );
147 this.el.pack_end ( child_2.el , false,true,0 );
150 // user defined functions
152 public class Xcls_header : Object
154 public Gtk.HeaderBar el;
155 private Xcls_PopoverProperty _this;
161 public Xcls_header(Xcls_PopoverProperty _owner )
165 this.el = new Gtk.HeaderBar();
169 // set gobject values
170 this.el.title = "Modify / Create Property";
173 // user defined functions
176 public class Xcls_Table4 : Object
179 private Xcls_PopoverProperty _this;
185 public Xcls_Table4(Xcls_PopoverProperty _owner )
188 this.el = new Gtk.Table( 3, 2, true );
192 // set gobject values
193 this.el.margin_right = 4;
194 this.el.margin_left = 4;
195 this.el.row_spacing = 2;
196 var child_0 = new Xcls_Label5( _this );
198 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
199 var child_1 = new Xcls_kflag( _this );
201 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
202 var child_2 = new Xcls_Label9( _this );
204 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
205 var child_3 = new Xcls_ktype( _this );
207 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
208 var child_4 = new Xcls_Label11( _this );
210 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
211 var child_5 = new Xcls_kname( _this );
213 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
216 // user defined functions
218 public class Xcls_Label5 : Object
221 private Xcls_PopoverProperty _this;
227 public Xcls_Label5(Xcls_PopoverProperty _owner )
230 this.el = new Gtk.Label( "Special Flags" );
234 // set gobject values
235 this.el.justify = Gtk.Justification.RIGHT;
236 this.el.xalign = 0.900000f;
239 // user defined functions
242 public class Xcls_kflag : Object
244 public Gtk.ComboBox el;
245 private Xcls_PopoverProperty _this;
251 public Xcls_kflag(Xcls_PopoverProperty _owner )
255 this.el = new Gtk.ComboBox();
259 // set gobject values
260 var child_0 = new Xcls_dbcellrenderer( _this );
262 this.el.pack_start ( child_0.el , true );
263 var child_1 = new Xcls_dbmodel( _this );
265 this.el.set_model ( child_1.el );
269 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
272 // user defined functions
274 public class Xcls_dbcellrenderer : Object
276 public Gtk.CellRendererText el;
277 private Xcls_PopoverProperty _this;
283 public Xcls_dbcellrenderer(Xcls_PopoverProperty _owner )
286 _this.dbcellrenderer = this;
287 this.el = new Gtk.CellRendererText();
291 // set gobject values
294 // user defined functions
297 public class Xcls_dbmodel : Object
299 public Gtk.ListStore el;
300 private Xcls_PopoverProperty _this;
306 public Xcls_dbmodel(Xcls_PopoverProperty _owner )
309 _this.dbmodel = this;
310 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
314 // set gobject values
317 // user defined functions
318 public void loadData (string kflag) {
326 // user defined property '#'
327 // user defined method '|'
328 // special property '*' => prop |args|ctor|init
332 /// el.append(out iter);
335 // el.set_value(iter, 0, "");
336 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
339 el.set(iter, 0, "", 1, "Normal Property", -1);
341 if (_this.mainwindow.windowstate.file.xtype == "Gtk") {
343 el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1);
347 el.set(iter, 0, "#", 1, "(#) User defined property", -1);
350 el.set(iter, 0, "|", 1, "(|) User defined method", -1);
353 el.set(iter, 0, "*", 1, "(*) Special property (eg. prop | args | ctor | init )", -1);
357 el.set(iter, 0, "@", 1, "(@) Vala Signal", -1);
363 el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1);
366 el.set(iter, 0, "|", 1, "(|) User defined method", -1);
369 el.set(iter, 0, "*", 1, "(*) Special property (eg. prop )", -1);
373 el.foreach((tm, tp, titer) => {
375 el.get_value(titer, 0, out val);
377 print("check %s against %s\n", (string)val, kflag);
378 if (((string)val) == kflag) {
379 _this.kflag.el.set_active_iter(titer);
391 public class Xcls_Label9 : Object
394 private Xcls_PopoverProperty _this;
400 public Xcls_Label9(Xcls_PopoverProperty _owner )
403 this.el = new Gtk.Label( "Type" );
407 // set gobject values
408 this.el.justify = Gtk.Justification.RIGHT;
409 this.el.xalign = 0.900000f;
410 this.el.visible = true;
413 // user defined functions
416 public class Xcls_ktype : Object
419 private Xcls_PopoverProperty _this;
425 public Xcls_ktype(Xcls_PopoverProperty _owner )
429 this.el = new Gtk.Entry();
433 // set gobject values
434 this.el.visible = true;
437 // user defined functions
440 public class Xcls_Label11 : Object
443 private Xcls_PopoverProperty _this;
449 public Xcls_Label11(Xcls_PopoverProperty _owner )
452 this.el = new Gtk.Label( "Name" );
456 // set gobject values
457 this.el.justify = Gtk.Justification.RIGHT;
458 this.el.xalign = 0.900000f;
459 this.el.tooltip_text = "center, north, south, east, west";
460 this.el.visible = true;
463 // user defined functions
466 public class Xcls_kname : Object
469 private Xcls_PopoverProperty _this;
475 public Xcls_kname(Xcls_PopoverProperty _owner )
479 this.el = new Gtk.Entry();
483 // set gobject values
484 this.el.visible = true;
487 // user defined functions
491 public class Xcls_HButtonBox13 : Object
493 public Gtk.HButtonBox el;
494 private Xcls_PopoverProperty _this;
500 public Xcls_HButtonBox13(Xcls_PopoverProperty _owner )
503 this.el = new Gtk.HButtonBox();
507 // set gobject values
508 this.el.margin_right = 4;
509 this.el.margin_left = 4;
510 this.el.margin_bottom = 4;
511 var child_0 = new Xcls_Button14( _this );
513 this.el.add ( child_0.el );
514 var child_1 = new Xcls_save_btn( _this );
516 this.el.add ( child_1.el );
519 // user defined functions
521 public class Xcls_Button14 : Object
523 public Gtk.Button el;
524 private Xcls_PopoverProperty _this;
530 public Xcls_Button14(Xcls_PopoverProperty _owner )
533 this.el = new Gtk.Button();
537 // set gobject values
538 this.el.label = "Cancel";
541 this.el.clicked.connect( () => {
548 // user defined functions
551 public class Xcls_save_btn : Object
553 public Gtk.Button el;
554 private Xcls_PopoverProperty _this;
560 public Xcls_save_btn(Xcls_PopoverProperty _owner )
563 _this.save_btn = this;
564 this.el = new Gtk.Button();
568 // set gobject values
569 this.el.label = "Save";
572 this.el.clicked.connect( ( ) => {
577 if (_this.name.el.get_text().length < 1) {
578 StandardErrorDialog.show(
580 "You have to set Component name "
585 // what does this do?
587 var isNew = _this.file.name.length > 0 ? false : true;
592 // FIXME - this may be more complicated...
593 //for (var i in this.def) {
594 // this.file[i] = this.get(i).el.get_text();
599 _this.updateFileFromEntry();
600 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
601 Xcls_StandardErrorDialog.singleton().show(
603 "The name you used already exists "
614 var fn = _this.name.el.get_text();
615 var dir = _this.project.firstPath();
617 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
618 Xcls_StandardErrorDialog.singleton().show(
620 "That file already exists"
625 var f = JsRender.JsRender.factory(
626 _this.file.project.xtype,
628 dir + "/" + fn + ".bjs");
634 _this.updateFileFromEntry();
635 _this.file.loaded = true;
637 _this.file.project.addFile(_this.file);
646 _this.success(_this.project, _this.file);
652 // user defined functions