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 // does node have this property...
74 this.save_btn.el.set_label("Save");
76 this.save_btn.el.set_label("Create");
80 //console.log('show all');
81 this.el.set_modal(true);
82 this.el.set_relative_to(btn);
84 this.el.set_position(Gtk.PositionType.TOP);
87 print("SHOWALL - POPIP\n");
89 this.kname.el.grab_focus();
91 //this.success = c.success;
94 public void updateNodeFromValues () {
96 /* _this.file.title = _this.title.el.get_text();
97 _this.file.region = _this.region.el.get_text();
98 _this.file.parent = _this.parent.el.get_text();
99 _this.file.permname = _this.permname.el.get_text();
100 _this.file.modOrder = _this.modOrder.el.get_text();
102 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
103 _this.file.renameTo(_this.name.el.get_text());
105 // store the module...
106 _this.file.build_module = "";
108 if (_this.build_module.el.get_active_iter (out iter)) {
110 this.dbmodel.el.get_value (iter, 0, out vfname);
111 if (((string)vfname).length > 0) {
112 _this.file.build_module = (string)vfname;
122 public class Xcls_Box2 : Object
125 private Xcls_PopoverProperty _this;
131 public Xcls_Box2(Xcls_PopoverProperty _owner )
134 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
138 // set gobject values
139 this.el.homogeneous = false;
140 var child_0 = new Xcls_HeaderBar3( _this );
142 this.el.pack_start ( child_0.el , false,true,0 );
143 var child_1 = new Xcls_Table4( _this );
145 this.el.pack_start ( child_1.el , false,false,4 );
146 var child_2 = new Xcls_HButtonBox13( _this );
148 this.el.pack_end ( child_2.el , false,true,0 );
151 // user defined functions
153 public class Xcls_HeaderBar3 : Object
155 public Gtk.HeaderBar el;
156 private Xcls_PopoverProperty _this;
162 public Xcls_HeaderBar3(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_build_module( _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_build_module : Object
244 public Gtk.ComboBox el;
245 private Xcls_PopoverProperty _this;
251 public Xcls_build_module(Xcls_PopoverProperty _owner )
254 _this.build_module = this;
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 (Gee.ArrayList<string> data, string cur) {
323 /// el.append(out iter);
326 // el.set_value(iter, 0, "");
327 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
332 el.set_value(iter, 0, "");
333 el.set_value(iter, 1, "-- select a module --");
334 _this.build_module.el.set_active_iter(iter);
336 for (var i = 0; i < data.size;i++) {
341 el.set_value(iter, 0, data.get(i));
342 el.set_value(iter, 1, data.get(i));
344 if (data.get(i) == cur) {
345 _this.build_module.el.set_active_iter(iter);
349 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
355 public class Xcls_Label9 : Object
358 private Xcls_PopoverProperty _this;
364 public Xcls_Label9(Xcls_PopoverProperty _owner )
367 this.el = new Gtk.Label( "Type" );
371 // set gobject values
372 this.el.justify = Gtk.Justification.RIGHT;
373 this.el.xalign = 0.900000f;
374 this.el.visible = true;
377 // user defined functions
380 public class Xcls_ktype : Object
383 private Xcls_PopoverProperty _this;
389 public Xcls_ktype(Xcls_PopoverProperty _owner )
393 this.el = new Gtk.Entry();
397 // set gobject values
398 this.el.visible = true;
401 // user defined functions
404 public class Xcls_Label11 : Object
407 private Xcls_PopoverProperty _this;
413 public Xcls_Label11(Xcls_PopoverProperty _owner )
416 this.el = new Gtk.Label( "Name" );
420 // set gobject values
421 this.el.justify = Gtk.Justification.RIGHT;
422 this.el.xalign = 0.900000f;
423 this.el.tooltip_text = "center, north, south, east, west";
424 this.el.visible = true;
427 // user defined functions
430 public class Xcls_kname : Object
433 private Xcls_PopoverProperty _this;
439 public Xcls_kname(Xcls_PopoverProperty _owner )
443 this.el = new Gtk.Entry();
447 // set gobject values
448 this.el.visible = true;
451 // user defined functions
455 public class Xcls_HButtonBox13 : Object
457 public Gtk.HButtonBox el;
458 private Xcls_PopoverProperty _this;
464 public Xcls_HButtonBox13(Xcls_PopoverProperty _owner )
467 this.el = new Gtk.HButtonBox();
471 // set gobject values
472 this.el.margin_right = 4;
473 this.el.margin_left = 4;
474 this.el.margin_bottom = 4;
475 var child_0 = new Xcls_Button14( _this );
477 this.el.add ( child_0.el );
478 var child_1 = new Xcls_save_btn( _this );
480 this.el.add ( child_1.el );
483 // user defined functions
485 public class Xcls_Button14 : Object
487 public Gtk.Button el;
488 private Xcls_PopoverProperty _this;
494 public Xcls_Button14(Xcls_PopoverProperty _owner )
497 this.el = new Gtk.Button();
501 // set gobject values
502 this.el.label = "Cancel";
505 this.el.clicked.connect( () => {
512 // user defined functions
515 public class Xcls_save_btn : Object
517 public Gtk.Button el;
518 private Xcls_PopoverProperty _this;
524 public Xcls_save_btn(Xcls_PopoverProperty _owner )
527 _this.save_btn = this;
528 this.el = new Gtk.Button();
532 // set gobject values
533 this.el.label = "Save";
536 this.el.clicked.connect( ( ) => {
541 if (_this.name.el.get_text().length < 1) {
542 StandardErrorDialog.show(
544 "You have to set Component name "
549 // what does this do?
551 var isNew = _this.file.name.length > 0 ? false : true;
556 // FIXME - this may be more complicated...
557 //for (var i in this.def) {
558 // this.file[i] = this.get(i).el.get_text();
563 _this.updateFileFromEntry();
564 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
565 Xcls_StandardErrorDialog.singleton().show(
567 "The name you used already exists "
578 var fn = _this.name.el.get_text();
579 var dir = _this.project.firstPath();
581 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
582 Xcls_StandardErrorDialog.singleton().show(
584 "That file already exists"
589 var f = JsRender.JsRender.factory(
590 _this.file.project.xtype,
592 dir + "/" + fn + ".bjs");
598 _this.updateFileFromEntry();
599 _this.file.loaded = true;
601 _this.file.project.addFile(_this.file);
610 _this.success(_this.project, _this.file);
616 // user defined functions