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 type, string key)
60 string kname = "", kflag = "", ktype = "";
62 node.normalize_key( key, out kname, out kflag, out ktype);
65 if (this.type == "listener") {
66 this.header.el.title = "Modify Event Listener";
68 this.header.el.title = "Modify Property";
73 _this.kname.el.set_text(kname);
74 _this.ktype.el.set_text(ktype);
76 _this.dbmodel.loadData(kflag);
77 // does node have this property...
81 this.save_btn.el.set_label("Save");
83 this.save_btn.el.set_label("Create");
87 //console.log('show all');
88 this.el.set_modal(true);
89 this.el.set_relative_to(btn);
91 this.el.set_position(Gtk.PositionType.TOP);
94 print("SHOWALL - POPIP\n");
96 this.kname.el.grab_focus();
98 //this.success = c.success;
101 public void updateNodeFromValues () {
103 /* _this.file.title = _this.title.el.get_text();
104 _this.file.region = _this.region.el.get_text();
105 _this.file.parent = _this.parent.el.get_text();
106 _this.file.permname = _this.permname.el.get_text();
107 _this.file.modOrder = _this.modOrder.el.get_text();
109 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
110 _this.file.renameTo(_this.name.el.get_text());
112 // store the module...
113 _this.file.build_module = "";
115 if (_this.build_module.el.get_active_iter (out iter)) {
117 this.dbmodel.el.get_value (iter, 0, out vfname);
118 if (((string)vfname).length > 0) {
119 _this.file.build_module = (string)vfname;
129 public class Xcls_Box2 : Object
132 private Xcls_PopoverProperty _this;
138 public Xcls_Box2(Xcls_PopoverProperty _owner )
141 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
145 // set gobject values
146 this.el.homogeneous = false;
147 var child_0 = new Xcls_header( _this );
149 this.el.pack_start ( child_0.el , false,true,0 );
150 var child_1 = new Xcls_Table4( _this );
152 this.el.pack_start ( child_1.el , false,false,4 );
153 var child_2 = new Xcls_HButtonBox13( _this );
155 this.el.pack_end ( child_2.el , false,true,0 );
158 // user defined functions
160 public class Xcls_header : Object
162 public Gtk.HeaderBar el;
163 private Xcls_PopoverProperty _this;
169 public Xcls_header(Xcls_PopoverProperty _owner )
173 this.el = new Gtk.HeaderBar();
177 // set gobject values
178 this.el.title = "Modify / Create Property";
181 // user defined functions
184 public class Xcls_Table4 : Object
187 private Xcls_PopoverProperty _this;
193 public Xcls_Table4(Xcls_PopoverProperty _owner )
196 this.el = new Gtk.Table( 3, 2, true );
200 // set gobject values
201 this.el.margin_right = 4;
202 this.el.margin_left = 4;
203 this.el.row_spacing = 2;
204 var child_0 = new Xcls_Label5( _this );
206 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
207 var child_1 = new Xcls_kflag( _this );
209 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
210 var child_2 = new Xcls_Label9( _this );
212 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
213 var child_3 = new Xcls_ktype( _this );
215 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
216 var child_4 = new Xcls_Label11( _this );
218 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
219 var child_5 = new Xcls_kname( _this );
221 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
224 // user defined functions
226 public class Xcls_Label5 : Object
229 private Xcls_PopoverProperty _this;
235 public Xcls_Label5(Xcls_PopoverProperty _owner )
238 this.el = new Gtk.Label( "Special Flags" );
242 // set gobject values
243 this.el.justify = Gtk.Justification.RIGHT;
244 this.el.xalign = 0.900000f;
247 // user defined functions
250 public class Xcls_kflag : Object
252 public Gtk.ComboBox el;
253 private Xcls_PopoverProperty _this;
259 public Xcls_kflag(Xcls_PopoverProperty _owner )
263 this.el = new Gtk.ComboBox();
267 // set gobject values
268 var child_0 = new Xcls_dbcellrenderer( _this );
270 this.el.pack_start ( child_0.el , true );
271 var child_1 = new Xcls_dbmodel( _this );
273 this.el.set_model ( child_1.el );
277 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
280 // user defined functions
282 public class Xcls_dbcellrenderer : Object
284 public Gtk.CellRendererText el;
285 private Xcls_PopoverProperty _this;
291 public Xcls_dbcellrenderer(Xcls_PopoverProperty _owner )
294 _this.dbcellrenderer = this;
295 this.el = new Gtk.CellRendererText();
299 // set gobject values
302 // user defined functions
305 public class Xcls_dbmodel : Object
307 public Gtk.ListStore el;
308 private Xcls_PopoverProperty _this;
314 public Xcls_dbmodel(Xcls_PopoverProperty _owner )
317 _this.dbmodel = this;
318 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
322 // set gobject values
325 // user defined functions
326 public void loadData (string kflag) {
334 // user defined property '#'
335 // user defined method '|'
336 // special property '*' => prop |args|ctor|init
340 /// el.append(out iter);
343 // el.set_value(iter, 0, "");
344 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
347 el.set(iter, 0, "", 1, "Normal Property", -1);
349 if (_this.mainwindow.windowstate.file.xtype == "Gtk") {
351 el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1);
355 el.set(iter, 0, "#", 1, "(#) User defined property", -1);
358 el.set(iter, 0, "|", 1, "(|) User defined method", -1);
361 el.set(iter, 0, "*", 1, "(*) Special property (eg. prop | args | ctor | init )", -1);
365 el.set(iter, 0, "@", 1, "(@) Vala Signal", -1);
371 el.set(iter, 0, "$", 1, "($) Raw Property (not escaped)", -1);
374 el.set(iter, 0, "|", 1, "(|) User defined method", -1);
377 el.set(iter, 0, "*", 1, "(*) Special property (eg. prop )", -1);
381 el.foreach((tm, tp, titer) => {
383 el.get_value(titer, 0, out val);
385 print("check %s against %s\n", (string)val, kflag);
386 if (((string)val) == kflag) {
387 _this.kflag.el.set_active_iter(titer);
399 public class Xcls_Label9 : Object
402 private Xcls_PopoverProperty _this;
408 public Xcls_Label9(Xcls_PopoverProperty _owner )
411 this.el = new Gtk.Label( "Type" );
415 // set gobject values
416 this.el.justify = Gtk.Justification.RIGHT;
417 this.el.xalign = 0.900000f;
418 this.el.visible = true;
421 // user defined functions
424 public class Xcls_ktype : Object
427 private Xcls_PopoverProperty _this;
433 public Xcls_ktype(Xcls_PopoverProperty _owner )
437 this.el = new Gtk.Entry();
441 // set gobject values
442 this.el.visible = true;
445 // user defined functions
448 public class Xcls_Label11 : Object
451 private Xcls_PopoverProperty _this;
457 public Xcls_Label11(Xcls_PopoverProperty _owner )
460 this.el = new Gtk.Label( "Name" );
464 // set gobject values
465 this.el.justify = Gtk.Justification.RIGHT;
466 this.el.xalign = 0.900000f;
467 this.el.tooltip_text = "center, north, south, east, west";
468 this.el.visible = true;
471 // user defined functions
474 public class Xcls_kname : Object
477 private Xcls_PopoverProperty _this;
483 public Xcls_kname(Xcls_PopoverProperty _owner )
487 this.el = new Gtk.Entry();
491 // set gobject values
492 this.el.visible = true;
495 // user defined functions
499 public class Xcls_HButtonBox13 : Object
501 public Gtk.HButtonBox el;
502 private Xcls_PopoverProperty _this;
508 public Xcls_HButtonBox13(Xcls_PopoverProperty _owner )
511 this.el = new Gtk.HButtonBox();
515 // set gobject values
516 this.el.margin_right = 4;
517 this.el.margin_left = 4;
518 this.el.margin_bottom = 4;
519 var child_0 = new Xcls_Button14( _this );
521 this.el.add ( child_0.el );
522 var child_1 = new Xcls_save_btn( _this );
524 this.el.add ( child_1.el );
527 // user defined functions
529 public class Xcls_Button14 : Object
531 public Gtk.Button el;
532 private Xcls_PopoverProperty _this;
538 public Xcls_Button14(Xcls_PopoverProperty _owner )
541 this.el = new Gtk.Button();
545 // set gobject values
546 this.el.label = "Cancel";
549 this.el.clicked.connect( () => {
556 // user defined functions
559 public class Xcls_save_btn : Object
561 public Gtk.Button el;
562 private Xcls_PopoverProperty _this;
568 public Xcls_save_btn(Xcls_PopoverProperty _owner )
571 _this.save_btn = this;
572 this.el = new Gtk.Button();
576 // set gobject values
577 this.el.label = "Save";
580 this.el.clicked.connect( ( ) => {
585 if (_this.name.el.get_text().length < 1) {
586 StandardErrorDialog.show(
588 "You have to set Component name "
593 // what does this do?
595 var isNew = _this.file.name.length > 0 ? false : true;
600 // FIXME - this may be more complicated...
601 //for (var i in this.def) {
602 // this.file[i] = this.get(i).el.get_text();
607 _this.updateFileFromEntry();
608 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
609 Xcls_StandardErrorDialog.singleton().show(
611 "The name you used already exists "
622 var fn = _this.name.el.get_text();
623 var dir = _this.project.firstPath();
625 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
626 Xcls_StandardErrorDialog.singleton().show(
628 "That file already exists"
633 var f = JsRender.JsRender.factory(
634 _this.file.project.xtype,
636 dir + "/" + fn + ".bjs");
642 _this.updateFileFromEntry();
643 _this.file.loaded = true;
645 _this.file.project.addFile(_this.file);
654 _this.success(_this.project, _this.file);
660 // user defined functions