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_title title;
19 public Xcls_parent parent;
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;
30 public Xcls_PopoverProperty()
33 this.el = new Gtk.Popover( null );
38 this.mainwindow = null;
41 this.el.border_width = 0;
43 this.el.position = Gtk.PositionType.RIGHT;
44 var child_0 = new Xcls_Box2( _this );
46 this.el.add ( child_0.el );
49 this.el.closed.connect( () => {
57 // user defined functions
58 public void updateFileFromEntry () {
60 _this.file.title = _this.title.el.get_text();
61 _this.file.region = _this.region.el.get_text();
62 _this.file.parent = _this.parent.el.get_text();
63 _this.file.permname = _this.permname.el.get_text();
64 _this.file.modOrder = _this.modOrder.el.get_text();
66 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
67 _this.file.renameTo(_this.name.el.get_text());
69 // store the module...
70 _this.file.build_module = "";
72 if (_this.build_module.el.get_active_iter (out iter)) {
74 this.dbmodel.el.get_value (iter, 0, out vfname);
75 if (((string)vfname).length > 0) {
76 _this.file.build_module = (string)vfname;
85 public void show (Gtk.Widget btn, JsRender.Node node, string key)
88 string kname = "", kflag = "", ktype = "";
90 node.normalize_key( key, out kname, out kflag, out ktype)
93 _this.kname.el.set_text(kname);
94 _this.ktype.el.set_text(ktype);
96 // does node have this property...
100 this.save_btn.el.set_label("Save");
102 this.save_btn.el.set_label("Create");
106 //console.log('show all');
107 this.el.set_modal(true);
108 this.el.set_relative_to(btn);
110 this.el.set_position(Gtk.PositionType.TOP);
113 print("SHOWALL - POPIP\n");
115 this.name.el.grab_focus();
117 //this.success = c.success;
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_HeaderBar3( _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_HeaderBar3 : Object
154 public Gtk.HeaderBar el;
155 private Xcls_PopoverProperty _this;
161 public Xcls_HeaderBar3(Xcls_PopoverProperty _owner )
164 this.el = new Gtk.HeaderBar();
168 // set gobject values
169 this.el.title = "Modify / Create Property";
172 // user defined functions
175 public class Xcls_Table4 : Object
178 private Xcls_PopoverProperty _this;
184 public Xcls_Table4(Xcls_PopoverProperty _owner )
187 this.el = new Gtk.Table( 3, 2, true );
191 // set gobject values
192 this.el.margin_right = 4;
193 this.el.margin_left = 4;
194 this.el.row_spacing = 2;
195 var child_0 = new Xcls_Label5( _this );
197 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
198 var child_1 = new Xcls_build_module( _this );
200 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
201 var child_2 = new Xcls_Label9( _this );
203 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
204 var child_3 = new Xcls_title( _this );
206 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
207 var child_4 = new Xcls_Label11( _this );
209 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
210 var child_5 = new Xcls_parent( _this );
212 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
215 // user defined functions
217 public class Xcls_Label5 : Object
220 private Xcls_PopoverProperty _this;
226 public Xcls_Label5(Xcls_PopoverProperty _owner )
229 this.el = new Gtk.Label( "Special Flags" );
233 // set gobject values
234 this.el.justify = Gtk.Justification.RIGHT;
235 this.el.xalign = 0.900000f;
238 // user defined functions
241 public class Xcls_build_module : Object
243 public Gtk.ComboBox el;
244 private Xcls_PopoverProperty _this;
250 public Xcls_build_module(Xcls_PopoverProperty _owner )
253 _this.build_module = this;
254 this.el = new Gtk.ComboBox();
258 // set gobject values
259 var child_0 = new Xcls_dbcellrenderer( _this );
261 this.el.pack_start ( child_0.el , true );
262 var child_1 = new Xcls_dbmodel( _this );
264 this.el.set_model ( child_1.el );
268 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
271 // user defined functions
273 public class Xcls_dbcellrenderer : Object
275 public Gtk.CellRendererText el;
276 private Xcls_PopoverProperty _this;
282 public Xcls_dbcellrenderer(Xcls_PopoverProperty _owner )
285 _this.dbcellrenderer = this;
286 this.el = new Gtk.CellRendererText();
290 // set gobject values
293 // user defined functions
296 public class Xcls_dbmodel : Object
298 public Gtk.ListStore el;
299 private Xcls_PopoverProperty _this;
305 public Xcls_dbmodel(Xcls_PopoverProperty _owner )
308 _this.dbmodel = this;
309 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
313 // set gobject values
316 // user defined functions
317 public void loadData (Gee.ArrayList<string> data, string cur) {
322 /// el.append(out iter);
325 // el.set_value(iter, 0, "");
326 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
331 el.set_value(iter, 0, "");
332 el.set_value(iter, 1, "-- select a module --");
333 _this.build_module.el.set_active_iter(iter);
335 for (var i = 0; i < data.size;i++) {
340 el.set_value(iter, 0, data.get(i));
341 el.set_value(iter, 1, data.get(i));
343 if (data.get(i) == cur) {
344 _this.build_module.el.set_active_iter(iter);
348 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
354 public class Xcls_Label9 : Object
357 private Xcls_PopoverProperty _this;
363 public Xcls_Label9(Xcls_PopoverProperty _owner )
366 this.el = new Gtk.Label( "Title" );
370 // set gobject values
371 this.el.justify = Gtk.Justification.RIGHT;
372 this.el.xalign = 0.900000f;
373 this.el.visible = true;
376 // user defined functions
379 public class Xcls_title : Object
382 private Xcls_PopoverProperty _this;
388 public Xcls_title(Xcls_PopoverProperty _owner )
392 this.el = new Gtk.Entry();
396 // set gobject values
397 this.el.visible = true;
400 // user defined functions
403 public class Xcls_Label11 : Object
406 private Xcls_PopoverProperty _this;
412 public Xcls_Label11(Xcls_PopoverProperty _owner )
415 this.el = new Gtk.Label( "Name" );
419 // set gobject values
420 this.el.justify = Gtk.Justification.RIGHT;
421 this.el.xalign = 0.900000f;
422 this.el.tooltip_text = "center, north, south, east, west";
423 this.el.visible = true;
426 // user defined functions
429 public class Xcls_parent : Object
432 private Xcls_PopoverProperty _this;
438 public Xcls_parent(Xcls_PopoverProperty _owner )
442 this.el = new Gtk.Entry();
446 // set gobject values
447 this.el.visible = true;
450 // user defined functions
454 public class Xcls_HButtonBox13 : Object
456 public Gtk.HButtonBox el;
457 private Xcls_PopoverProperty _this;
463 public Xcls_HButtonBox13(Xcls_PopoverProperty _owner )
466 this.el = new Gtk.HButtonBox();
470 // set gobject values
471 this.el.margin_right = 4;
472 this.el.margin_left = 4;
473 this.el.margin_bottom = 4;
474 var child_0 = new Xcls_Button14( _this );
476 this.el.add ( child_0.el );
477 var child_1 = new Xcls_save_btn( _this );
479 this.el.add ( child_1.el );
482 // user defined functions
484 public class Xcls_Button14 : Object
486 public Gtk.Button el;
487 private Xcls_PopoverProperty _this;
493 public Xcls_Button14(Xcls_PopoverProperty _owner )
496 this.el = new Gtk.Button();
500 // set gobject values
501 this.el.label = "Cancel";
504 this.el.clicked.connect( () => {
511 // user defined functions
514 public class Xcls_save_btn : Object
516 public Gtk.Button el;
517 private Xcls_PopoverProperty _this;
523 public Xcls_save_btn(Xcls_PopoverProperty _owner )
526 _this.save_btn = this;
527 this.el = new Gtk.Button();
531 // set gobject values
532 this.el.label = "Save";
535 this.el.clicked.connect( ( ) => {
540 if (_this.name.el.get_text().length < 1) {
541 StandardErrorDialog.show(
543 "You have to set Component name "
548 // what does this do?
550 var isNew = _this.file.name.length > 0 ? false : true;
552 if (!isNew && this.file.name != _this.name.el.get_text()) {
553 Xcls_StandardErrorDialog.singleton().show(
555 "Sorry changing names does not work yet. "
564 // FIXME - this may be more complicated...
565 //for (var i in this.def) {
566 // this.file[i] = this.get(i).el.get_text();
571 _this.updateFileFromEntry();
572 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
573 Xcls_StandardErrorDialog.singleton().show(
575 "The name you used already exists "
586 var fn = _this.name.el.get_text();
587 var dir = _this.project.firstPath();
589 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
590 Xcls_StandardErrorDialog.singleton().show(
592 "That file already exists"
597 var f = JsRender.JsRender.factory(
598 _this.file.project.xtype,
600 dir + "/" + fn + ".bjs");
606 _this.updateFileFromEntry();
607 _this.file.loaded = true;
609 _this.file.project.addFile(_this.file);
618 _this.success(_this.project, _this.file);
623 // user defined functions