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_name name;
19 public Xcls_title title;
20 public Xcls_parent parent;
21 public Xcls_build_module build_module;
22 public Xcls_dbcellrenderer dbcellrenderer;
23 public Xcls_dbmodel dbmodel;
24 public Xcls_save_btn save_btn;
27 public signal void success (Project.Project pr, JsRender.JsRender file);
29 public Project.Project project;
30 public JsRender.JsRender file;
31 public Xcls_MainWindow mainwindow;
34 public Xcls_PopoverProperty()
37 this.el = new Gtk.Popover( null );
42 this.mainwindow = null;
45 this.el.border_width = 0;
47 this.el.position = Gtk.PositionType.RIGHT;
48 var child_0 = new Xcls_Box2( _this );
50 this.el.add ( child_0.el );
53 this.el.closed.connect( () => {
61 // user defined functions
62 public void updateFileFromEntry () {
64 _this.file.title = _this.title.el.get_text();
65 _this.file.region = _this.region.el.get_text();
66 _this.file.parent = _this.parent.el.get_text();
67 _this.file.permname = _this.permname.el.get_text();
68 _this.file.modOrder = _this.modOrder.el.get_text();
70 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
71 _this.file.renameTo(_this.name.el.get_text());
73 // store the module...
74 _this.file.build_module = "";
76 if (_this.build_module.el.get_active_iter (out iter)) {
78 this.dbmodel.el.get_value (iter, 0, out vfname);
79 if (((string)vfname).length > 0) {
80 _this.file.build_module = (string)vfname;
89 public void show (JsRender.JsRender c, Gtk.Widget btn)
91 this.project = c.project;
99 _this.name.el.set_text(c.name);
100 _this.title.el.set_text(c.title);
101 _this.parent.el.set_text(c.parent);
102 _this.region.el.set_text(c.region);
103 _this.modOrder.el.set_text(c.modOrder);
104 _this.permname.el.set_text(c.permname);
106 if (c.path.length > 0) {
108 this.save_btn.el.set_label("Save");
110 this.save_btn.el.set_label("Create");
113 var ar = new Gee.ArrayList<string>();
114 _this.dbmodel.loadData(ar,"");
115 // load the modules... if relivant..
116 if (this.project.xtype == "Gtk") {
117 var p = (Project.Gtk)c.project;
118 var cg = p.compilegroups;
120 var iter = cg.map_iterator();
122 var key = iter.get_key();
123 if (key == "_default_") {
128 _this.dbmodel.loadData(ar, c.build_module);
134 //console.log('show all');
135 this.el.set_modal(true);
136 this.el.set_relative_to(btn);
138 this.el.set_position(Gtk.PositionType.RIGHT);
141 print("SHOWALL - POPIP\n");
143 this.name.el.grab_focus();
145 //this.success = c.success;
149 public class Xcls_Box2 : Object
152 private Xcls_PopoverProperty _this;
158 public Xcls_Box2(Xcls_PopoverProperty _owner )
161 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
165 // set gobject values
166 this.el.homogeneous = false;
167 var child_0 = new Xcls_HeaderBar3( _this );
169 this.el.pack_start ( child_0.el , false,true,0 );
170 var child_1 = new Xcls_Table4( _this );
172 this.el.pack_start ( child_1.el , false,false,4 );
173 var child_2 = new Xcls_HButtonBox17( _this );
175 this.el.pack_end ( child_2.el , false,true,0 );
178 // user defined functions
180 public class Xcls_HeaderBar3 : Object
182 public Gtk.HeaderBar el;
183 private Xcls_PopoverProperty _this;
189 public Xcls_HeaderBar3(Xcls_PopoverProperty _owner )
192 this.el = new Gtk.HeaderBar();
196 // set gobject values
197 this.el.title = "Modify / Create Property";
200 // user defined functions
203 public class Xcls_Table4 : Object
206 private Xcls_PopoverProperty _this;
212 public Xcls_Table4(Xcls_PopoverProperty _owner )
215 this.el = new Gtk.Table( 3, 2, true );
219 // set gobject values
220 this.el.margin_right = 4;
221 this.el.margin_left = 4;
222 this.el.row_spacing = 2;
223 var child_0 = new Xcls_Label5( _this );
225 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
226 var child_1 = new Xcls_build_module( _this );
228 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
229 var child_2 = new Xcls_name( _this );
231 this.el.attach_defaults ( child_2.el , 1,2,0,1 );
232 var child_3 = new Xcls_Label10( _this );
234 this.el.attach_defaults ( child_3.el , 0,1,1,2 );
235 var child_4 = new Xcls_title( _this );
237 this.el.attach_defaults ( child_4.el , 1,2,1,2 );
238 var child_5 = new Xcls_Label12( _this );
240 this.el.attach_defaults ( child_5.el , 0,1,2,3 );
241 var child_6 = new Xcls_parent( _this );
243 this.el.attach_defaults ( child_6.el , 1,2,2,3 );
244 var child_7 = new Xcls_build_module( _this );
246 this.el.attach_defaults ( child_7.el , 1,2,6,7 );
249 // user defined functions
251 public class Xcls_Label5 : Object
254 private Xcls_PopoverProperty _this;
260 public Xcls_Label5(Xcls_PopoverProperty _owner )
263 this.el = new Gtk.Label( "Special Flags" );
267 // set gobject values
268 this.el.justify = Gtk.Justification.RIGHT;
269 this.el.xalign = 0.900000f;
272 // user defined functions
275 public class Xcls_build_module : Object
277 public Gtk.ComboBox el;
278 private Xcls_PopoverProperty _this;
284 public Xcls_build_module(Xcls_PopoverProperty _owner )
287 _this.build_module = this;
288 this.el = new Gtk.ComboBox();
292 // set gobject values
293 var child_0 = new Xcls_dbcellrenderer( _this );
295 this.el.pack_start ( child_0.el , true );
296 var child_1 = new Xcls_dbmodel( _this );
298 this.el.set_model ( child_1.el );
302 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
305 // user defined functions
307 public class Xcls_dbcellrenderer : Object
309 public Gtk.CellRendererText el;
310 private Xcls_PopoverProperty _this;
316 public Xcls_dbcellrenderer(Xcls_PopoverProperty _owner )
319 _this.dbcellrenderer = this;
320 this.el = new Gtk.CellRendererText();
324 // set gobject values
327 // user defined functions
330 public class Xcls_dbmodel : Object
332 public Gtk.ListStore el;
333 private Xcls_PopoverProperty _this;
339 public Xcls_dbmodel(Xcls_PopoverProperty _owner )
342 _this.dbmodel = this;
343 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
347 // set gobject values
350 // user defined functions
351 public void loadData (Gee.ArrayList<string> data, string cur) {
356 /// el.append(out iter);
359 // el.set_value(iter, 0, "");
360 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
365 el.set_value(iter, 0, "");
366 el.set_value(iter, 1, "-- select a module --");
367 _this.build_module.el.set_active_iter(iter);
369 for (var i = 0; i < data.size;i++) {
374 el.set_value(iter, 0, data.get(i));
375 el.set_value(iter, 1, data.get(i));
377 if (data.get(i) == cur) {
378 _this.build_module.el.set_active_iter(iter);
382 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
388 public class Xcls_name : Object
391 private Xcls_PopoverProperty _this;
397 public Xcls_name(Xcls_PopoverProperty _owner )
401 this.el = new Gtk.Entry();
405 // set gobject values
406 this.el.visible = true;
409 // user defined functions
412 public class Xcls_Label10 : Object
415 private Xcls_PopoverProperty _this;
421 public Xcls_Label10(Xcls_PopoverProperty _owner )
424 this.el = new Gtk.Label( "Title" );
428 // set gobject values
429 this.el.justify = Gtk.Justification.RIGHT;
430 this.el.xalign = 0.900000f;
431 this.el.visible = true;
434 // user defined functions
437 public class Xcls_title : Object
440 private Xcls_PopoverProperty _this;
446 public Xcls_title(Xcls_PopoverProperty _owner )
450 this.el = new Gtk.Entry();
454 // set gobject values
455 this.el.visible = true;
458 // user defined functions
461 public class Xcls_Label12 : Object
464 private Xcls_PopoverProperty _this;
470 public Xcls_Label12(Xcls_PopoverProperty _owner )
473 this.el = new Gtk.Label( "Name" );
477 // set gobject values
478 this.el.justify = Gtk.Justification.RIGHT;
479 this.el.xalign = 0.900000f;
480 this.el.tooltip_text = "center, north, south, east, west";
481 this.el.visible = true;
484 // user defined functions
487 public class Xcls_parent : Object
490 private Xcls_PopoverProperty _this;
496 public Xcls_parent(Xcls_PopoverProperty _owner )
500 this.el = new Gtk.Entry();
504 // set gobject values
505 this.el.visible = true;
508 // user defined functions
511 public class Xcls_build_module : Object
513 public Gtk.ComboBox el;
514 private Xcls_PopoverProperty _this;
520 public Xcls_build_module(Xcls_PopoverProperty _owner )
523 _this.build_module = this;
524 this.el = new Gtk.ComboBox();
528 // set gobject values
529 var child_0 = new Xcls_dbcellrenderer( _this );
531 this.el.pack_start ( child_0.el , true );
532 var child_1 = new Xcls_dbmodel( _this );
534 this.el.set_model ( child_1.el );
538 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
541 // user defined functions
543 public class Xcls_dbcellrenderer : Object
545 public Gtk.CellRendererText el;
546 private Xcls_PopoverProperty _this;
552 public Xcls_dbcellrenderer(Xcls_PopoverProperty _owner )
555 _this.dbcellrenderer = this;
556 this.el = new Gtk.CellRendererText();
560 // set gobject values
563 // user defined functions
566 public class Xcls_dbmodel : Object
568 public Gtk.ListStore el;
569 private Xcls_PopoverProperty _this;
575 public Xcls_dbmodel(Xcls_PopoverProperty _owner )
578 _this.dbmodel = this;
579 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
583 // set gobject values
586 // user defined functions
587 public void loadData (Gee.ArrayList<string> data, string cur) {
592 /// el.append(out iter);
595 // el.set_value(iter, 0, "");
596 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
601 el.set_value(iter, 0, "");
602 el.set_value(iter, 1, "-- select a module --");
603 _this.build_module.el.set_active_iter(iter);
605 for (var i = 0; i < data.size;i++) {
610 el.set_value(iter, 0, data.get(i));
611 el.set_value(iter, 1, data.get(i));
613 if (data.get(i) == cur) {
614 _this.build_module.el.set_active_iter(iter);
618 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
625 public class Xcls_HButtonBox17 : Object
627 public Gtk.HButtonBox el;
628 private Xcls_PopoverProperty _this;
634 public Xcls_HButtonBox17(Xcls_PopoverProperty _owner )
637 this.el = new Gtk.HButtonBox();
641 // set gobject values
642 this.el.margin_right = 4;
643 this.el.margin_left = 4;
644 this.el.margin_bottom = 4;
645 var child_0 = new Xcls_Button18( _this );
647 this.el.add ( child_0.el );
648 var child_1 = new Xcls_save_btn( _this );
650 this.el.add ( child_1.el );
653 // user defined functions
655 public class Xcls_Button18 : Object
657 public Gtk.Button el;
658 private Xcls_PopoverProperty _this;
664 public Xcls_Button18(Xcls_PopoverProperty _owner )
667 this.el = new Gtk.Button();
671 // set gobject values
672 this.el.label = "Cancel";
675 this.el.clicked.connect( () => {
682 // user defined functions
685 public class Xcls_save_btn : Object
687 public Gtk.Button el;
688 private Xcls_PopoverProperty _this;
694 public Xcls_save_btn(Xcls_PopoverProperty _owner )
697 _this.save_btn = this;
698 this.el = new Gtk.Button();
702 // set gobject values
703 this.el.label = "Save";
706 this.el.clicked.connect( ( ) => {
711 if (_this.name.el.get_text().length < 1) {
712 StandardErrorDialog.show(
714 "You have to set Component name "
719 // what does this do?
721 var isNew = _this.file.name.length > 0 ? false : true;
723 if (!isNew && this.file.name != _this.name.el.get_text()) {
724 Xcls_StandardErrorDialog.singleton().show(
726 "Sorry changing names does not work yet. "
735 // FIXME - this may be more complicated...
736 //for (var i in this.def) {
737 // this.file[i] = this.get(i).el.get_text();
742 _this.updateFileFromEntry();
743 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
744 Xcls_StandardErrorDialog.singleton().show(
746 "The name you used already exists "
757 var fn = _this.name.el.get_text();
758 var dir = _this.project.firstPath();
760 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
761 Xcls_StandardErrorDialog.singleton().show(
763 "That file already exists"
768 var f = JsRender.JsRender.factory(
769 _this.file.project.xtype,
771 dir + "/" + fn + ".bjs");
777 _this.updateFileFromEntry();
778 _this.file.loaded = true;
780 _this.file.project.addFile(_this.file);
789 _this.success(_this.project, _this.file);
794 // user defined functions