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)
92 _this.name.el.set_text(c.name);
93 _this.title.el.set_text(c.title);
94 _this.parent.el.set_text(c.parent);
95 _this.region.el.set_text(c.region);
96 _this.modOrder.el.set_text(c.modOrder);
97 _this.permname.el.set_text(c.permname);
99 if (c.path.length > 0) {
101 this.save_btn.el.set_label("Save");
103 this.save_btn.el.set_label("Create");
106 var ar = new Gee.ArrayList<string>();
107 _this.dbmodel.loadData(ar,"");
108 // load the modules... if relivant..
109 if (this.project.xtype == "Gtk") {
110 var p = (Project.Gtk)c.project;
111 var cg = p.compilegroups;
113 var iter = cg.map_iterator();
115 var key = iter.get_key();
116 if (key == "_default_") {
121 _this.dbmodel.loadData(ar, c.build_module);
127 //console.log('show all');
128 this.el.set_modal(true);
129 this.el.set_relative_to(btn);
131 this.el.set_position(Gtk.PositionType.RIGHT);
134 print("SHOWALL - POPIP\n");
136 this.name.el.grab_focus();
138 //this.success = c.success;
142 public class Xcls_Box2 : Object
145 private Xcls_PopoverProperty _this;
151 public Xcls_Box2(Xcls_PopoverProperty _owner )
154 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
158 // set gobject values
159 this.el.homogeneous = false;
160 var child_0 = new Xcls_HeaderBar3( _this );
162 this.el.pack_start ( child_0.el , false,true,0 );
163 var child_1 = new Xcls_Table4( _this );
165 this.el.pack_start ( child_1.el , false,false,4 );
166 var child_2 = new Xcls_HButtonBox13( _this );
168 this.el.pack_end ( child_2.el , false,true,0 );
171 // user defined functions
173 public class Xcls_HeaderBar3 : Object
175 public Gtk.HeaderBar el;
176 private Xcls_PopoverProperty _this;
182 public Xcls_HeaderBar3(Xcls_PopoverProperty _owner )
185 this.el = new Gtk.HeaderBar();
189 // set gobject values
190 this.el.title = "Modify / Create Property";
193 // user defined functions
196 public class Xcls_Table4 : Object
199 private Xcls_PopoverProperty _this;
205 public Xcls_Table4(Xcls_PopoverProperty _owner )
208 this.el = new Gtk.Table( 3, 2, true );
212 // set gobject values
213 this.el.margin_right = 4;
214 this.el.margin_left = 4;
215 this.el.row_spacing = 2;
216 var child_0 = new Xcls_Label5( _this );
218 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
219 var child_1 = new Xcls_build_module( _this );
221 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
222 var child_2 = new Xcls_Label9( _this );
224 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
225 var child_3 = new Xcls_title( _this );
227 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
228 var child_4 = new Xcls_Label11( _this );
230 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
231 var child_5 = new Xcls_parent( _this );
233 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
236 // user defined functions
238 public class Xcls_Label5 : Object
241 private Xcls_PopoverProperty _this;
247 public Xcls_Label5(Xcls_PopoverProperty _owner )
250 this.el = new Gtk.Label( "Special Flags" );
254 // set gobject values
255 this.el.justify = Gtk.Justification.RIGHT;
256 this.el.xalign = 0.900000f;
259 // user defined functions
262 public class Xcls_build_module : Object
264 public Gtk.ComboBox el;
265 private Xcls_PopoverProperty _this;
271 public Xcls_build_module(Xcls_PopoverProperty _owner )
274 _this.build_module = this;
275 this.el = new Gtk.ComboBox();
279 // set gobject values
280 var child_0 = new Xcls_dbcellrenderer( _this );
282 this.el.pack_start ( child_0.el , true );
283 var child_1 = new Xcls_dbmodel( _this );
285 this.el.set_model ( child_1.el );
289 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
292 // user defined functions
294 public class Xcls_dbcellrenderer : Object
296 public Gtk.CellRendererText el;
297 private Xcls_PopoverProperty _this;
303 public Xcls_dbcellrenderer(Xcls_PopoverProperty _owner )
306 _this.dbcellrenderer = this;
307 this.el = new Gtk.CellRendererText();
311 // set gobject values
314 // user defined functions
317 public class Xcls_dbmodel : Object
319 public Gtk.ListStore el;
320 private Xcls_PopoverProperty _this;
326 public Xcls_dbmodel(Xcls_PopoverProperty _owner )
329 _this.dbmodel = this;
330 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
334 // set gobject values
337 // user defined functions
338 public void loadData (Gee.ArrayList<string> data, string cur) {
343 /// el.append(out iter);
346 // el.set_value(iter, 0, "");
347 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
352 el.set_value(iter, 0, "");
353 el.set_value(iter, 1, "-- select a module --");
354 _this.build_module.el.set_active_iter(iter);
356 for (var i = 0; i < data.size;i++) {
361 el.set_value(iter, 0, data.get(i));
362 el.set_value(iter, 1, data.get(i));
364 if (data.get(i) == cur) {
365 _this.build_module.el.set_active_iter(iter);
369 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
375 public class Xcls_Label9 : Object
378 private Xcls_PopoverProperty _this;
384 public Xcls_Label9(Xcls_PopoverProperty _owner )
387 this.el = new Gtk.Label( "Title" );
391 // set gobject values
392 this.el.justify = Gtk.Justification.RIGHT;
393 this.el.xalign = 0.900000f;
394 this.el.visible = true;
397 // user defined functions
400 public class Xcls_title : Object
403 private Xcls_PopoverProperty _this;
409 public Xcls_title(Xcls_PopoverProperty _owner )
413 this.el = new Gtk.Entry();
417 // set gobject values
418 this.el.visible = true;
421 // user defined functions
424 public class Xcls_Label11 : Object
427 private Xcls_PopoverProperty _this;
433 public Xcls_Label11(Xcls_PopoverProperty _owner )
436 this.el = new Gtk.Label( "Name" );
440 // set gobject values
441 this.el.justify = Gtk.Justification.RIGHT;
442 this.el.xalign = 0.900000f;
443 this.el.tooltip_text = "center, north, south, east, west";
444 this.el.visible = true;
447 // user defined functions
450 public class Xcls_parent : Object
453 private Xcls_PopoverProperty _this;
459 public Xcls_parent(Xcls_PopoverProperty _owner )
463 this.el = new Gtk.Entry();
467 // set gobject values
468 this.el.visible = true;
471 // user defined functions
475 public class Xcls_HButtonBox13 : Object
477 public Gtk.HButtonBox el;
478 private Xcls_PopoverProperty _this;
484 public Xcls_HButtonBox13(Xcls_PopoverProperty _owner )
487 this.el = new Gtk.HButtonBox();
491 // set gobject values
492 this.el.margin_right = 4;
493 this.el.margin_left = 4;
494 this.el.margin_bottom = 4;
495 var child_0 = new Xcls_Button14( _this );
497 this.el.add ( child_0.el );
498 var child_1 = new Xcls_save_btn( _this );
500 this.el.add ( child_1.el );
503 // user defined functions
505 public class Xcls_Button14 : Object
507 public Gtk.Button el;
508 private Xcls_PopoverProperty _this;
514 public Xcls_Button14(Xcls_PopoverProperty _owner )
517 this.el = new Gtk.Button();
521 // set gobject values
522 this.el.label = "Cancel";
525 this.el.clicked.connect( () => {
532 // user defined functions
535 public class Xcls_save_btn : Object
537 public Gtk.Button el;
538 private Xcls_PopoverProperty _this;
544 public Xcls_save_btn(Xcls_PopoverProperty _owner )
547 _this.save_btn = this;
548 this.el = new Gtk.Button();
552 // set gobject values
553 this.el.label = "Save";
556 this.el.clicked.connect( ( ) => {
561 if (_this.name.el.get_text().length < 1) {
562 StandardErrorDialog.show(
564 "You have to set Component name "
569 // what does this do?
571 var isNew = _this.file.name.length > 0 ? false : true;
573 if (!isNew && this.file.name != _this.name.el.get_text()) {
574 Xcls_StandardErrorDialog.singleton().show(
576 "Sorry changing names does not work yet. "
585 // FIXME - this may be more complicated...
586 //for (var i in this.def) {
587 // this.file[i] = this.get(i).el.get_text();
592 _this.updateFileFromEntry();
593 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
594 Xcls_StandardErrorDialog.singleton().show(
596 "The name you used already exists "
607 var fn = _this.name.el.get_text();
608 var dir = _this.project.firstPath();
610 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
611 Xcls_StandardErrorDialog.singleton().show(
613 "That file already exists"
618 var f = JsRender.JsRender.factory(
619 _this.file.project.xtype,
621 dir + "/" + fn + ".bjs");
627 _this.updateFileFromEntry();
628 _this.file.loaded = true;
630 _this.file.project.addFile(_this.file);
639 _this.success(_this.project, _this.file);
644 // user defined functions