1 static Xcls_PopoverFileDetails _PopoverFileDetails;
3 public class Xcls_PopoverFileDetails : Object
6 private Xcls_PopoverFileDetails _this;
8 public static Xcls_PopoverFileDetails singleton()
10 if (_PopoverFileDetails == null) {
11 _PopoverFileDetails= new Xcls_PopoverFileDetails();
13 return _PopoverFileDetails;
15 public Xcls_name name;
16 public Xcls_title title;
17 public Xcls_region region;
18 public Xcls_parent parent;
19 public Xcls_permname permname;
20 public Xcls_modOrder modOrder;
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_PopoverFileDetails()
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_VBox2( _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_VBox2 : Object
152 private Xcls_PopoverFileDetails _this;
158 public Xcls_VBox2(Xcls_PopoverFileDetails _owner )
161 this.el = new Gtk.VBox( false, 0 );
165 // set gobject values
166 var child_0 = new Xcls_HeaderBar3( _this );
168 this.el.pack_start ( child_0.el , false,true,0 );
169 var child_1 = new Xcls_Table4( _this );
171 this.el.pack_start ( child_1.el , false,false,4 );
172 var child_2 = new Xcls_HButtonBox21( _this );
174 this.el.pack_end ( child_2.el , false,true,0 );
177 // user defined functions
179 public class Xcls_HeaderBar3 : Object
181 public Gtk.HeaderBar el;
182 private Xcls_PopoverFileDetails _this;
188 public Xcls_HeaderBar3(Xcls_PopoverFileDetails _owner )
191 this.el = new Gtk.HeaderBar();
195 // set gobject values
196 this.el.title = "Add / Edit File";
199 // user defined functions
201 public class Xcls_Table4 : Object
204 private Xcls_PopoverFileDetails _this;
210 public Xcls_Table4(Xcls_PopoverFileDetails _owner )
213 this.el = new Gtk.Table( 3, 2, true );
217 // set gobject values
218 this.el.margin_right = 4;
219 this.el.margin_left = 4;
220 this.el.row_spacing = 2;
221 var child_0 = new Xcls_Label5( _this );
223 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
224 var child_1 = new Xcls_name( _this );
226 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
227 var child_2 = new Xcls_Label7( _this );
229 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
230 var child_3 = new Xcls_title( _this );
232 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
233 var child_4 = new Xcls_Label9( _this );
235 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
236 var child_5 = new Xcls_region( _this );
238 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
239 var child_6 = new Xcls_Label11( _this );
241 this.el.attach_defaults ( child_6.el , 0,1,3,4 );
242 var child_7 = new Xcls_parent( _this );
244 this.el.attach_defaults ( child_7.el , 1,2,3,4 );
245 var child_8 = new Xcls_Label13( _this );
247 this.el.attach_defaults ( child_8.el , 0,1,4,5 );
248 var child_9 = new Xcls_permname( _this );
250 this.el.attach_defaults ( child_9.el , 1,2,4,5 );
251 var child_10 = new Xcls_Label15( _this );
253 this.el.attach_defaults ( child_10.el , 0,1,5,6 );
254 var child_11 = new Xcls_modOrder( _this );
256 this.el.attach_defaults ( child_11.el , 1,2,5,6 );
257 var child_12 = new Xcls_Label17( _this );
259 this.el.attach_defaults ( child_12.el , 0,1,6,7 );
260 var child_13 = new Xcls_build_module( _this );
262 this.el.attach_defaults ( child_13.el , 1,2,6,7 );
265 // user defined functions
267 public class Xcls_Label5 : Object
270 private Xcls_PopoverFileDetails _this;
276 public Xcls_Label5(Xcls_PopoverFileDetails _owner )
279 this.el = new Gtk.Label( "Component Name" );
283 // set gobject values
284 this.el.justify = Gtk.Justification.RIGHT;
285 this.el.xalign = 0.900000f;
288 // user defined functions
290 public class Xcls_name : Object
293 private Xcls_PopoverFileDetails _this;
299 public Xcls_name(Xcls_PopoverFileDetails _owner )
303 this.el = new Gtk.Entry();
307 // set gobject values
308 this.el.visible = true;
311 // user defined functions
313 public class Xcls_Label7 : Object
316 private Xcls_PopoverFileDetails _this;
322 public Xcls_Label7(Xcls_PopoverFileDetails _owner )
325 this.el = new Gtk.Label( "Title" );
329 // set gobject values
330 this.el.justify = Gtk.Justification.RIGHT;
331 this.el.xalign = 0.900000f;
332 this.el.visible = true;
335 // user defined functions
337 public class Xcls_title : Object
340 private Xcls_PopoverFileDetails _this;
346 public Xcls_title(Xcls_PopoverFileDetails _owner )
350 this.el = new Gtk.Entry();
354 // set gobject values
355 this.el.visible = true;
358 // user defined functions
360 public class Xcls_Label9 : Object
363 private Xcls_PopoverFileDetails _this;
369 public Xcls_Label9(Xcls_PopoverFileDetails _owner )
372 this.el = new Gtk.Label( "Region" );
376 // set gobject values
377 this.el.justify = Gtk.Justification.RIGHT;
378 this.el.xalign = 0.900000f;
379 this.el.tooltip_text = "center, north, south, east, west";
380 this.el.visible = true;
383 // user defined functions
385 public class Xcls_region : Object
388 private Xcls_PopoverFileDetails _this;
394 public Xcls_region(Xcls_PopoverFileDetails _owner )
398 this.el = new Gtk.Entry();
402 // set gobject values
403 this.el.visible = true;
406 // user defined functions
408 public class Xcls_Label11 : Object
411 private Xcls_PopoverFileDetails _this;
417 public Xcls_Label11(Xcls_PopoverFileDetails _owner )
420 this.el = new Gtk.Label( "Parent Name" );
424 // set gobject values
425 this.el.justify = Gtk.Justification.RIGHT;
426 this.el.xalign = 0.900000f;
427 this.el.visible = true;
430 // user defined functions
432 public class Xcls_parent : Object
435 private Xcls_PopoverFileDetails _this;
441 public Xcls_parent(Xcls_PopoverFileDetails _owner )
445 this.el = new Gtk.Entry();
449 // set gobject values
450 this.el.visible = true;
453 // user defined functions
455 public class Xcls_Label13 : Object
458 private Xcls_PopoverFileDetails _this;
464 public Xcls_Label13(Xcls_PopoverFileDetails _owner )
467 this.el = new Gtk.Label( "Permission Name" );
471 // set gobject values
472 this.el.justify = Gtk.Justification.RIGHT;
473 this.el.xalign = 0.900000f;
474 this.el.visible = true;
477 // user defined functions
479 public class Xcls_permname : Object
482 private Xcls_PopoverFileDetails _this;
488 public Xcls_permname(Xcls_PopoverFileDetails _owner )
491 _this.permname = this;
492 this.el = new Gtk.Entry();
496 // set gobject values
497 this.el.visible = true;
500 // user defined functions
502 public class Xcls_Label15 : Object
505 private Xcls_PopoverFileDetails _this;
511 public Xcls_Label15(Xcls_PopoverFileDetails _owner )
514 this.el = new Gtk.Label( "Order (for tabs)" );
518 // set gobject values
519 this.el.justify = Gtk.Justification.RIGHT;
520 this.el.xalign = 0.900000f;
521 this.el.visible = true;
524 // user defined functions
526 public class Xcls_modOrder : Object
529 private Xcls_PopoverFileDetails _this;
535 public Xcls_modOrder(Xcls_PopoverFileDetails _owner )
538 _this.modOrder = this;
539 this.el = new Gtk.Entry();
543 // set gobject values
544 this.el.visible = true;
547 // user defined functions
549 public class Xcls_Label17 : Object
552 private Xcls_PopoverFileDetails _this;
558 public Xcls_Label17(Xcls_PopoverFileDetails _owner )
561 this.el = new Gtk.Label( "Module to build (Vala only)" );
565 // set gobject values
566 this.el.justify = Gtk.Justification.RIGHT;
567 this.el.xalign = 0.900000f;
568 this.el.visible = true;
571 // user defined functions
573 public class Xcls_build_module : Object
575 public Gtk.ComboBox el;
576 private Xcls_PopoverFileDetails _this;
582 public Xcls_build_module(Xcls_PopoverFileDetails _owner )
585 _this.build_module = this;
586 this.el = new Gtk.ComboBox();
590 // set gobject values
591 var child_0 = new Xcls_dbcellrenderer( _this );
593 this.el.pack_start ( child_0.el , true );
594 var child_1 = new Xcls_dbmodel( _this );
596 this.el.set_model ( child_1.el );
600 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
603 // user defined functions
605 public class Xcls_dbcellrenderer : Object
607 public Gtk.CellRendererText el;
608 private Xcls_PopoverFileDetails _this;
614 public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
617 _this.dbcellrenderer = this;
618 this.el = new Gtk.CellRendererText();
622 // set gobject values
625 // user defined functions
627 public class Xcls_dbmodel : Object
629 public Gtk.ListStore el;
630 private Xcls_PopoverFileDetails _this;
636 public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
639 _this.dbmodel = this;
640 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
644 // set gobject values
647 // user defined functions
648 public void loadData (Gee.ArrayList<string> data, string cur) {
653 /// el.append(out iter);
656 // el.set_value(iter, 0, "");
657 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
662 el.set_value(iter, 0, "");
663 el.set_value(iter, 1, "-- select a module --");
664 _this.build_module.el.set_active_iter(iter);
666 for (var i = 0; i < data.size;i++) {
671 el.set_value(iter, 0, data.get(i));
672 el.set_value(iter, 1, data.get(i));
674 if (data.get(i) == cur) {
675 _this.build_module.el.set_active_iter(iter);
679 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
683 public class Xcls_HButtonBox21 : Object
685 public Gtk.HButtonBox el;
686 private Xcls_PopoverFileDetails _this;
692 public Xcls_HButtonBox21(Xcls_PopoverFileDetails _owner )
695 this.el = new Gtk.HButtonBox();
699 // set gobject values
700 this.el.margin_right = 4;
701 this.el.margin_left = 4;
702 this.el.margin_bottom = 4;
703 var child_0 = new Xcls_Button22( _this );
705 this.el.add ( child_0.el );
706 var child_1 = new Xcls_save_btn( _this );
708 this.el.add ( child_1.el );
711 // user defined functions
713 public class Xcls_Button22 : Object
715 public Gtk.Button el;
716 private Xcls_PopoverFileDetails _this;
722 public Xcls_Button22(Xcls_PopoverFileDetails _owner )
725 this.el = new Gtk.Button();
729 // set gobject values
730 this.el.label = "Cancel";
733 this.el.clicked.connect( () => {
740 // user defined functions
742 public class Xcls_save_btn : Object
744 public Gtk.Button el;
745 private Xcls_PopoverFileDetails _this;
751 public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
754 _this.save_btn = this;
755 this.el = new Gtk.Button();
759 // set gobject values
760 this.el.label = "Save";
763 this.el.clicked.connect( ( ) => {
768 if (_this.name.el.get_text().length < 1) {
769 StandardErrorDialog.show(
771 "You have to set Component name "
776 // what does this do?
778 var isNew = _this.file.name.length > 0 ? false : true;
780 if (!isNew && this.file.name != _this.name.el.get_text()) {
781 Xcls_StandardErrorDialog.singleton().show(
783 "Sorry changing names does not work yet. "
792 // FIXME - this may be more complicated...
793 //for (var i in this.def) {
794 // this.file[i] = this.get(i).el.get_text();
799 _this.updateFileFromEntry();
800 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
801 Xcls_StandardErrorDialog.singleton().show(
803 "The name you used already exists "
814 var fn = _this.name.el.get_text();
815 var dir = _this.project.firstPath();
817 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
818 Xcls_StandardErrorDialog.singleton().show(
820 "That file already exists"
825 var f = JsRender.JsRender.factory(
826 _this.file.project.xtype,
828 dir + "/" + fn + ".bjs");
834 _this.updateFileFromEntry();
836 _this.file.project.addFile(_this.file);
845 _this.success(_this.project, _this.file);
850 // user defined functions