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 (JsRender.JsRender c, Gtk.Widget btn)
87 this.project = c.project;
95 _this.name.el.set_text(c.name);
96 _this.title.el.set_text(c.title);
97 _this.parent.el.set_text(c.parent);
98 _this.region.el.set_text(c.region);
99 _this.modOrder.el.set_text(c.modOrder);
100 _this.permname.el.set_text(c.permname);
102 if (c.path.length > 0) {
104 this.save_btn.el.set_label("Save");
106 this.save_btn.el.set_label("Create");
109 var ar = new Gee.ArrayList<string>();
110 _this.dbmodel.loadData(ar,"");
111 // load the modules... if relivant..
112 if (this.project.xtype == "Gtk") {
113 var p = (Project.Gtk)c.project;
114 var cg = p.compilegroups;
116 var iter = cg.map_iterator();
118 var key = iter.get_key();
119 if (key == "_default_") {
124 _this.dbmodel.loadData(ar, c.build_module);
130 //console.log('show all');
131 this.el.set_modal(true);
132 this.el.set_relative_to(btn);
134 this.el.set_position(Gtk.PositionType.RIGHT);
137 print("SHOWALL - POPIP\n");
139 this.name.el.grab_focus();
141 //this.success = c.success;
145 public class Xcls_Box2 : Object
148 private Xcls_PopoverProperty _this;
154 public Xcls_Box2(Xcls_PopoverProperty _owner )
157 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
161 // set gobject values
162 this.el.homogeneous = false;
163 var child_0 = new Xcls_HeaderBar3( _this );
165 this.el.pack_start ( child_0.el , false,true,0 );
166 var child_1 = new Xcls_Table4( _this );
168 this.el.pack_start ( child_1.el , false,false,4 );
169 var child_2 = new Xcls_HButtonBox13( _this );
171 this.el.pack_end ( child_2.el , false,true,0 );
174 // user defined functions
176 public class Xcls_HeaderBar3 : Object
178 public Gtk.HeaderBar el;
179 private Xcls_PopoverProperty _this;
185 public Xcls_HeaderBar3(Xcls_PopoverProperty _owner )
188 this.el = new Gtk.HeaderBar();
192 // set gobject values
193 this.el.title = "Modify / Create Property";
196 // user defined functions
199 public class Xcls_Table4 : Object
202 private Xcls_PopoverProperty _this;
208 public Xcls_Table4(Xcls_PopoverProperty _owner )
211 this.el = new Gtk.Table( 3, 2, true );
215 // set gobject values
216 this.el.margin_right = 4;
217 this.el.margin_left = 4;
218 this.el.row_spacing = 2;
219 var child_0 = new Xcls_Label5( _this );
221 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
222 var child_1 = new Xcls_build_module( _this );
224 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
225 var child_2 = new Xcls_Label9( _this );
227 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
228 var child_3 = new Xcls_title( _this );
230 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
231 var child_4 = new Xcls_Label11( _this );
233 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
234 var child_5 = new Xcls_parent( _this );
236 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
239 // user defined functions
241 public class Xcls_Label5 : Object
244 private Xcls_PopoverProperty _this;
250 public Xcls_Label5(Xcls_PopoverProperty _owner )
253 this.el = new Gtk.Label( "Special Flags" );
257 // set gobject values
258 this.el.justify = Gtk.Justification.RIGHT;
259 this.el.xalign = 0.900000f;
262 // user defined functions
265 public class Xcls_build_module : Object
267 public Gtk.ComboBox el;
268 private Xcls_PopoverProperty _this;
274 public Xcls_build_module(Xcls_PopoverProperty _owner )
277 _this.build_module = this;
278 this.el = new Gtk.ComboBox();
282 // set gobject values
283 var child_0 = new Xcls_dbcellrenderer( _this );
285 this.el.pack_start ( child_0.el , true );
286 var child_1 = new Xcls_dbmodel( _this );
288 this.el.set_model ( child_1.el );
292 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
295 // user defined functions
297 public class Xcls_dbcellrenderer : Object
299 public Gtk.CellRendererText el;
300 private Xcls_PopoverProperty _this;
306 public Xcls_dbcellrenderer(Xcls_PopoverProperty _owner )
309 _this.dbcellrenderer = this;
310 this.el = new Gtk.CellRendererText();
314 // set gobject values
317 // user defined functions
320 public class Xcls_dbmodel : Object
322 public Gtk.ListStore el;
323 private Xcls_PopoverProperty _this;
329 public Xcls_dbmodel(Xcls_PopoverProperty _owner )
332 _this.dbmodel = this;
333 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
337 // set gobject values
340 // user defined functions
341 public void loadData (Gee.ArrayList<string> data, string cur) {
346 /// el.append(out iter);
349 // el.set_value(iter, 0, "");
350 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
355 el.set_value(iter, 0, "");
356 el.set_value(iter, 1, "-- select a module --");
357 _this.build_module.el.set_active_iter(iter);
359 for (var i = 0; i < data.size;i++) {
364 el.set_value(iter, 0, data.get(i));
365 el.set_value(iter, 1, data.get(i));
367 if (data.get(i) == cur) {
368 _this.build_module.el.set_active_iter(iter);
372 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
378 public class Xcls_Label9 : Object
381 private Xcls_PopoverProperty _this;
387 public Xcls_Label9(Xcls_PopoverProperty _owner )
390 this.el = new Gtk.Label( "Title" );
394 // set gobject values
395 this.el.justify = Gtk.Justification.RIGHT;
396 this.el.xalign = 0.900000f;
397 this.el.visible = true;
400 // user defined functions
403 public class Xcls_title : Object
406 private Xcls_PopoverProperty _this;
412 public Xcls_title(Xcls_PopoverProperty _owner )
416 this.el = new Gtk.Entry();
420 // set gobject values
421 this.el.visible = true;
424 // user defined functions
427 public class Xcls_Label11 : Object
430 private Xcls_PopoverProperty _this;
436 public Xcls_Label11(Xcls_PopoverProperty _owner )
439 this.el = new Gtk.Label( "Name" );
443 // set gobject values
444 this.el.justify = Gtk.Justification.RIGHT;
445 this.el.xalign = 0.900000f;
446 this.el.tooltip_text = "center, north, south, east, west";
447 this.el.visible = true;
450 // user defined functions
453 public class Xcls_parent : Object
456 private Xcls_PopoverProperty _this;
462 public Xcls_parent(Xcls_PopoverProperty _owner )
466 this.el = new Gtk.Entry();
470 // set gobject values
471 this.el.visible = true;
474 // user defined functions
478 public class Xcls_HButtonBox13 : Object
480 public Gtk.HButtonBox el;
481 private Xcls_PopoverProperty _this;
487 public Xcls_HButtonBox13(Xcls_PopoverProperty _owner )
490 this.el = new Gtk.HButtonBox();
494 // set gobject values
495 this.el.margin_right = 4;
496 this.el.margin_left = 4;
497 this.el.margin_bottom = 4;
498 var child_0 = new Xcls_Button14( _this );
500 this.el.add ( child_0.el );
501 var child_1 = new Xcls_save_btn( _this );
503 this.el.add ( child_1.el );
506 // user defined functions
508 public class Xcls_Button14 : Object
510 public Gtk.Button el;
511 private Xcls_PopoverProperty _this;
517 public Xcls_Button14(Xcls_PopoverProperty _owner )
520 this.el = new Gtk.Button();
524 // set gobject values
525 this.el.label = "Cancel";
528 this.el.clicked.connect( () => {
535 // user defined functions
538 public class Xcls_save_btn : Object
540 public Gtk.Button el;
541 private Xcls_PopoverProperty _this;
547 public Xcls_save_btn(Xcls_PopoverProperty _owner )
550 _this.save_btn = this;
551 this.el = new Gtk.Button();
555 // set gobject values
556 this.el.label = "Save";
559 this.el.clicked.connect( ( ) => {
564 if (_this.name.el.get_text().length < 1) {
565 StandardErrorDialog.show(
567 "You have to set Component name "
572 // what does this do?
574 var isNew = _this.file.name.length > 0 ? false : true;
576 if (!isNew && this.file.name != _this.name.el.get_text()) {
577 Xcls_StandardErrorDialog.singleton().show(
579 "Sorry changing names does not work yet. "
588 // FIXME - this may be more complicated...
589 //for (var i in this.def) {
590 // this.file[i] = this.get(i).el.get_text();
595 _this.updateFileFromEntry();
596 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
597 Xcls_StandardErrorDialog.singleton().show(
599 "The name you used already exists "
610 var fn = _this.name.el.get_text();
611 var dir = _this.project.firstPath();
613 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
614 Xcls_StandardErrorDialog.singleton().show(
616 "That file already exists"
621 var f = JsRender.JsRender.factory(
622 _this.file.project.xtype,
624 dir + "/" + fn + ".bjs");
630 _this.updateFileFromEntry();
631 _this.file.loaded = true;
633 _this.file.project.addFile(_this.file);
642 _this.success(_this.project, _this.file);
647 // user defined functions