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_build_module build_module;
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 Project.Project project;
26 public JsRender.JsRender file;
27 public Xcls_MainWindow mainwindow;
28 public JsRender.Node node;
31 public Xcls_PopoverProperty()
34 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( () => {
58 // user defined functions
59 public void show (Gtk.Widget btn, JsRender.Node node, string key)
62 string kname = "", kflag = "", ktype = "";
64 node.normalize_key( key, out kname, out kflag, out ktype);
67 _this.kname.el.set_text(kname);
68 _this.ktype.el.set_text(ktype);
70 _this.dbmodel.loadData(kflag);
71 // does node have this property...
75 this.save_btn.el.set_label("Save");
77 this.save_btn.el.set_label("Create");
81 //console.log('show all');
82 this.el.set_modal(true);
83 this.el.set_relative_to(btn);
85 this.el.set_position(Gtk.PositionType.TOP);
88 print("SHOWALL - POPIP\n");
90 this.kname.el.grab_focus();
92 //this.success = c.success;
95 public void updateNodeFromValues () {
97 /* _this.file.title = _this.title.el.get_text();
98 _this.file.region = _this.region.el.get_text();
99 _this.file.parent = _this.parent.el.get_text();
100 _this.file.permname = _this.permname.el.get_text();
101 _this.file.modOrder = _this.modOrder.el.get_text();
103 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
104 _this.file.renameTo(_this.name.el.get_text());
106 // store the module...
107 _this.file.build_module = "";
109 if (_this.build_module.el.get_active_iter (out iter)) {
111 this.dbmodel.el.get_value (iter, 0, out vfname);
112 if (((string)vfname).length > 0) {
113 _this.file.build_module = (string)vfname;
123 public class Xcls_Box2 : Object
126 private Xcls_PopoverProperty _this;
132 public Xcls_Box2(Xcls_PopoverProperty _owner )
135 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
139 // set gobject values
140 this.el.homogeneous = false;
141 var child_0 = new Xcls_HeaderBar3( _this );
143 this.el.pack_start ( child_0.el , false,true,0 );
144 var child_1 = new Xcls_Table4( _this );
146 this.el.pack_start ( child_1.el , false,false,4 );
147 var child_2 = new Xcls_HButtonBox13( _this );
149 this.el.pack_end ( child_2.el , false,true,0 );
152 // user defined functions
154 public class Xcls_HeaderBar3 : Object
156 public Gtk.HeaderBar el;
157 private Xcls_PopoverProperty _this;
163 public Xcls_HeaderBar3(Xcls_PopoverProperty _owner )
166 this.el = new Gtk.HeaderBar();
170 // set gobject values
171 this.el.title = "Modify / Create Property";
174 // user defined functions
177 public class Xcls_Table4 : Object
180 private Xcls_PopoverProperty _this;
186 public Xcls_Table4(Xcls_PopoverProperty _owner )
189 this.el = new Gtk.Table( 3, 2, true );
193 // set gobject values
194 this.el.margin_right = 4;
195 this.el.margin_left = 4;
196 this.el.row_spacing = 2;
197 var child_0 = new Xcls_Label5( _this );
199 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
200 var child_1 = new Xcls_build_module( _this );
202 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
203 var child_2 = new Xcls_Label9( _this );
205 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
206 var child_3 = new Xcls_ktype( _this );
208 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
209 var child_4 = new Xcls_Label11( _this );
211 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
212 var child_5 = new Xcls_kname( _this );
214 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
217 // user defined functions
219 public class Xcls_Label5 : Object
222 private Xcls_PopoverProperty _this;
228 public Xcls_Label5(Xcls_PopoverProperty _owner )
231 this.el = new Gtk.Label( "Special Flags" );
235 // set gobject values
236 this.el.justify = Gtk.Justification.RIGHT;
237 this.el.xalign = 0.900000f;
240 // user defined functions
243 public class Xcls_build_module : Object
245 public Gtk.ComboBox el;
246 private Xcls_PopoverProperty _this;
252 public Xcls_build_module(Xcls_PopoverProperty _owner )
255 _this.build_module = this;
256 this.el = new Gtk.ComboBox();
260 // set gobject values
261 var child_0 = new Xcls_dbcellrenderer( _this );
263 this.el.pack_start ( child_0.el , true );
264 var child_1 = new Xcls_dbmodel( _this );
266 this.el.set_model ( child_1.el );
270 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
273 // user defined functions
275 public class Xcls_dbcellrenderer : Object
277 public Gtk.CellRendererText el;
278 private Xcls_PopoverProperty _this;
284 public Xcls_dbcellrenderer(Xcls_PopoverProperty _owner )
287 _this.dbcellrenderer = this;
288 this.el = new Gtk.CellRendererText();
292 // set gobject values
295 // user defined functions
298 public class Xcls_dbmodel : Object
300 public Gtk.ListStore el;
301 private Xcls_PopoverProperty _this;
307 public Xcls_dbmodel(Xcls_PopoverProperty _owner )
310 _this.dbmodel = this;
311 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
315 // set gobject values
318 // user defined functions
319 public void loadData (string kflag) {
327 // user defined property '#'
328 // user defined method '|'
329 // special property '*' => prop |args|ctor|init
333 /// el.append(out iter);
336 // el.set_value(iter, 0, "");
337 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
340 el.set(iter, 0, "", 1, "Normal Property", -1);
342 if (_this.file.xtype == "Gtk") {
344 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);
356 el.set(iter, 0, "@", 1, "Vala Signal", -1);
360 el.set(iter, 0, "$", 1, "Raw Property (not escaped)", -1);
363 el.set(iter, 0, "|", 1, "User defined method", -1);
366 el.set(iter, 0, "*", 1, "Special property (eg. prop )", -1);
377 public class Xcls_Label9 : Object
380 private Xcls_PopoverProperty _this;
386 public Xcls_Label9(Xcls_PopoverProperty _owner )
389 this.el = new Gtk.Label( "Type" );
393 // set gobject values
394 this.el.justify = Gtk.Justification.RIGHT;
395 this.el.xalign = 0.900000f;
396 this.el.visible = true;
399 // user defined functions
402 public class Xcls_ktype : Object
405 private Xcls_PopoverProperty _this;
411 public Xcls_ktype(Xcls_PopoverProperty _owner )
415 this.el = new Gtk.Entry();
419 // set gobject values
420 this.el.visible = true;
423 // user defined functions
426 public class Xcls_Label11 : Object
429 private Xcls_PopoverProperty _this;
435 public Xcls_Label11(Xcls_PopoverProperty _owner )
438 this.el = new Gtk.Label( "Name" );
442 // set gobject values
443 this.el.justify = Gtk.Justification.RIGHT;
444 this.el.xalign = 0.900000f;
445 this.el.tooltip_text = "center, north, south, east, west";
446 this.el.visible = true;
449 // user defined functions
452 public class Xcls_kname : Object
455 private Xcls_PopoverProperty _this;
461 public Xcls_kname(Xcls_PopoverProperty _owner )
465 this.el = new Gtk.Entry();
469 // set gobject values
470 this.el.visible = true;
473 // user defined functions
477 public class Xcls_HButtonBox13 : Object
479 public Gtk.HButtonBox el;
480 private Xcls_PopoverProperty _this;
486 public Xcls_HButtonBox13(Xcls_PopoverProperty _owner )
489 this.el = new Gtk.HButtonBox();
493 // set gobject values
494 this.el.margin_right = 4;
495 this.el.margin_left = 4;
496 this.el.margin_bottom = 4;
497 var child_0 = new Xcls_Button14( _this );
499 this.el.add ( child_0.el );
500 var child_1 = new Xcls_save_btn( _this );
502 this.el.add ( child_1.el );
505 // user defined functions
507 public class Xcls_Button14 : Object
509 public Gtk.Button el;
510 private Xcls_PopoverProperty _this;
516 public Xcls_Button14(Xcls_PopoverProperty _owner )
519 this.el = new Gtk.Button();
523 // set gobject values
524 this.el.label = "Cancel";
527 this.el.clicked.connect( () => {
534 // user defined functions
537 public class Xcls_save_btn : Object
539 public Gtk.Button el;
540 private Xcls_PopoverProperty _this;
546 public Xcls_save_btn(Xcls_PopoverProperty _owner )
549 _this.save_btn = this;
550 this.el = new Gtk.Button();
554 // set gobject values
555 this.el.label = "Save";
558 this.el.clicked.connect( ( ) => {
563 if (_this.name.el.get_text().length < 1) {
564 StandardErrorDialog.show(
566 "You have to set Component name "
571 // what does this do?
573 var isNew = _this.file.name.length > 0 ? false : true;
578 // FIXME - this may be more complicated...
579 //for (var i in this.def) {
580 // this.file[i] = this.get(i).el.get_text();
585 _this.updateFileFromEntry();
586 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
587 Xcls_StandardErrorDialog.singleton().show(
589 "The name you used already exists "
600 var fn = _this.name.el.get_text();
601 var dir = _this.project.firstPath();
603 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
604 Xcls_StandardErrorDialog.singleton().show(
606 "That file already exists"
611 var f = JsRender.JsRender.factory(
612 _this.file.project.xtype,
614 dir + "/" + fn + ".bjs");
620 _this.updateFileFromEntry();
621 _this.file.loaded = true;
623 _this.file.project.addFile(_this.file);
632 _this.success(_this.project, _this.file);
638 // user defined functions