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_kflag kflag;
16 public Xcls_dbcellrenderer dbcellrenderer;
17 public Xcls_dbmodel dbmodel;
18 public Xcls_ktype ktype;
19 public Xcls_kname kname;
20 public Xcls_save_btn save_btn;
23 public signal void success (Project.Project pr, JsRender.JsRender file);
25 public Xcls_MainWindow mainwindow;
26 public JsRender.Node node;
29 public Xcls_PopoverProperty()
32 this.el = new Gtk.Popover( null );
36 this.mainwindow = null;
39 this.el.border_width = 0;
41 this.el.position = Gtk.PositionType.RIGHT;
42 var child_0 = new Xcls_Box2( _this );
44 this.el.add ( child_0.el );
47 this.el.closed.connect( () => {
55 // user defined functions
56 public void show (Gtk.Widget btn, JsRender.Node node, string key)
59 string kname = "", kflag = "", ktype = "";
61 node.normalize_key( key, out kname, out kflag, out ktype);
64 _this.kname.el.set_text(kname);
65 _this.ktype.el.set_text(ktype);
67 _this.dbmodel.loadData(kflag);
68 // does node have this property...
72 this.save_btn.el.set_label("Save");
74 this.save_btn.el.set_label("Create");
78 //console.log('show all');
79 this.el.set_modal(true);
80 this.el.set_relative_to(btn);
82 this.el.set_position(Gtk.PositionType.TOP);
85 print("SHOWALL - POPIP\n");
87 this.kname.el.grab_focus();
89 //this.success = c.success;
92 public void updateNodeFromValues () {
94 /* _this.file.title = _this.title.el.get_text();
95 _this.file.region = _this.region.el.get_text();
96 _this.file.parent = _this.parent.el.get_text();
97 _this.file.permname = _this.permname.el.get_text();
98 _this.file.modOrder = _this.modOrder.el.get_text();
100 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
101 _this.file.renameTo(_this.name.el.get_text());
103 // store the module...
104 _this.file.build_module = "";
106 if (_this.build_module.el.get_active_iter (out iter)) {
108 this.dbmodel.el.get_value (iter, 0, out vfname);
109 if (((string)vfname).length > 0) {
110 _this.file.build_module = (string)vfname;
120 public class Xcls_Box2 : Object
123 private Xcls_PopoverProperty _this;
129 public Xcls_Box2(Xcls_PopoverProperty _owner )
132 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
136 // set gobject values
137 this.el.homogeneous = false;
138 var child_0 = new Xcls_HeaderBar3( _this );
140 this.el.pack_start ( child_0.el , false,true,0 );
141 var child_1 = new Xcls_Table4( _this );
143 this.el.pack_start ( child_1.el , false,false,4 );
144 var child_2 = new Xcls_HButtonBox13( _this );
146 this.el.pack_end ( child_2.el , false,true,0 );
149 // user defined functions
151 public class Xcls_HeaderBar3 : Object
153 public Gtk.HeaderBar el;
154 private Xcls_PopoverProperty _this;
160 public Xcls_HeaderBar3(Xcls_PopoverProperty _owner )
163 this.el = new Gtk.HeaderBar();
167 // set gobject values
168 this.el.title = "Modify / Create Property";
171 // user defined functions
174 public class Xcls_Table4 : Object
177 private Xcls_PopoverProperty _this;
183 public Xcls_Table4(Xcls_PopoverProperty _owner )
186 this.el = new Gtk.Table( 3, 2, true );
190 // set gobject values
191 this.el.margin_right = 4;
192 this.el.margin_left = 4;
193 this.el.row_spacing = 2;
194 var child_0 = new Xcls_Label5( _this );
196 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
197 var child_1 = new Xcls_kflag( _this );
199 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
200 var child_2 = new Xcls_Label9( _this );
202 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
203 var child_3 = new Xcls_ktype( _this );
205 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
206 var child_4 = new Xcls_Label11( _this );
208 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
209 var child_5 = new Xcls_kname( _this );
211 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
214 // user defined functions
216 public class Xcls_Label5 : Object
219 private Xcls_PopoverProperty _this;
225 public Xcls_Label5(Xcls_PopoverProperty _owner )
228 this.el = new Gtk.Label( "Special Flags" );
232 // set gobject values
233 this.el.justify = Gtk.Justification.RIGHT;
234 this.el.xalign = 0.900000f;
237 // user defined functions
240 public class Xcls_kflag : Object
242 public Gtk.ComboBox el;
243 private Xcls_PopoverProperty _this;
249 public Xcls_kflag(Xcls_PopoverProperty _owner )
253 this.el = new Gtk.ComboBox();
257 // set gobject values
258 var child_0 = new Xcls_dbcellrenderer( _this );
260 this.el.pack_start ( child_0.el , true );
261 var child_1 = new Xcls_dbmodel( _this );
263 this.el.set_model ( child_1.el );
267 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
270 // user defined functions
272 public class Xcls_dbcellrenderer : Object
274 public Gtk.CellRendererText el;
275 private Xcls_PopoverProperty _this;
281 public Xcls_dbcellrenderer(Xcls_PopoverProperty _owner )
284 _this.dbcellrenderer = this;
285 this.el = new Gtk.CellRendererText();
289 // set gobject values
292 // user defined functions
295 public class Xcls_dbmodel : Object
297 public Gtk.ListStore el;
298 private Xcls_PopoverProperty _this;
304 public Xcls_dbmodel(Xcls_PopoverProperty _owner )
307 _this.dbmodel = this;
308 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
312 // set gobject values
315 // user defined functions
316 public void loadData (string kflag) {
324 // user defined property '#'
325 // user defined method '|'
326 // special property '*' => prop |args|ctor|init
330 /// el.append(out iter);
333 // el.set_value(iter, 0, "");
334 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
337 el.set(iter, 0, "", 1, "Normal Property", -1);
339 if (_this.mainwindow.windowstate.file.xtype == "Gtk") {
341 el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1);
345 el.set(iter, 0, "#", 1, "(#) User defined property", -1);
348 el.set(iter, 0, "|", 1, "(|) User defined method", -1);
351 el.set(iter, 0, "*", 1, "(*) Special property (eg. prop | args | ctor | init )", -1);
355 el.set(iter, 0, "@", 1, "(@) Vala Signal", -1);
361 el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1);
364 el.set(iter, 0, "|", 1, "(|) User defined method", -1);
367 el.set(iter, 0, "*", 1, "(*) Special property (eg. prop )", -1);
371 el.foreach((tm, tp, titer) => {
373 el.get_value(titer, 0, out val);
375 print("check %s against %s\n", (string)val, kflag);
376 if (((string)val) == kflag) {
377 _this.kflag.el.set_active_iter(titer);
389 public class Xcls_Label9 : Object
392 private Xcls_PopoverProperty _this;
398 public Xcls_Label9(Xcls_PopoverProperty _owner )
401 this.el = new Gtk.Label( "Type" );
405 // set gobject values
406 this.el.justify = Gtk.Justification.RIGHT;
407 this.el.xalign = 0.900000f;
408 this.el.visible = true;
411 // user defined functions
414 public class Xcls_ktype : Object
417 private Xcls_PopoverProperty _this;
423 public Xcls_ktype(Xcls_PopoverProperty _owner )
427 this.el = new Gtk.Entry();
431 // set gobject values
432 this.el.visible = true;
435 // user defined functions
438 public class Xcls_Label11 : Object
441 private Xcls_PopoverProperty _this;
447 public Xcls_Label11(Xcls_PopoverProperty _owner )
450 this.el = new Gtk.Label( "Name" );
454 // set gobject values
455 this.el.justify = Gtk.Justification.RIGHT;
456 this.el.xalign = 0.900000f;
457 this.el.tooltip_text = "center, north, south, east, west";
458 this.el.visible = true;
461 // user defined functions
464 public class Xcls_kname : Object
467 private Xcls_PopoverProperty _this;
473 public Xcls_kname(Xcls_PopoverProperty _owner )
477 this.el = new Gtk.Entry();
481 // set gobject values
482 this.el.visible = true;
485 // user defined functions
489 public class Xcls_HButtonBox13 : Object
491 public Gtk.HButtonBox el;
492 private Xcls_PopoverProperty _this;
498 public Xcls_HButtonBox13(Xcls_PopoverProperty _owner )
501 this.el = new Gtk.HButtonBox();
505 // set gobject values
506 this.el.margin_right = 4;
507 this.el.margin_left = 4;
508 this.el.margin_bottom = 4;
509 var child_0 = new Xcls_Button14( _this );
511 this.el.add ( child_0.el );
512 var child_1 = new Xcls_save_btn( _this );
514 this.el.add ( child_1.el );
517 // user defined functions
519 public class Xcls_Button14 : Object
521 public Gtk.Button el;
522 private Xcls_PopoverProperty _this;
528 public Xcls_Button14(Xcls_PopoverProperty _owner )
531 this.el = new Gtk.Button();
535 // set gobject values
536 this.el.label = "Cancel";
539 this.el.clicked.connect( () => {
546 // user defined functions
549 public class Xcls_save_btn : Object
551 public Gtk.Button el;
552 private Xcls_PopoverProperty _this;
558 public Xcls_save_btn(Xcls_PopoverProperty _owner )
561 _this.save_btn = this;
562 this.el = new Gtk.Button();
566 // set gobject values
567 this.el.label = "Save";
570 this.el.clicked.connect( ( ) => {
575 if (_this.name.el.get_text().length < 1) {
576 StandardErrorDialog.show(
578 "You have to set Component name "
583 // what does this do?
585 var isNew = _this.file.name.length > 0 ? false : true;
590 // FIXME - this may be more complicated...
591 //for (var i in this.def) {
592 // this.file[i] = this.get(i).el.get_text();
597 _this.updateFileFromEntry();
598 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
599 Xcls_StandardErrorDialog.singleton().show(
601 "The name you used already exists "
612 var fn = _this.name.el.get_text();
613 var dir = _this.project.firstPath();
615 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
616 Xcls_StandardErrorDialog.singleton().show(
618 "That file already exists"
623 var f = JsRender.JsRender.factory(
624 _this.file.project.xtype,
626 dir + "/" + fn + ".bjs");
632 _this.updateFileFromEntry();
633 _this.file.loaded = true;
635 _this.file.project.addFile(_this.file);
644 _this.success(_this.project, _this.file);
650 // user defined functions