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 = 6;
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);
144 //this.success = c.success;
148 public class Xcls_VBox2 : Object
151 private Xcls_PopoverFileDetails _this;
157 public Xcls_VBox2(Xcls_PopoverFileDetails _owner )
160 this.el = new Gtk.VBox( false, 0 );
164 // set gobject values
165 var child_0 = new Xcls_Table3( _this );
167 this.el.pack_start ( child_0.el , false,false,0 );
168 var child_1 = new Xcls_HButtonBox20( _this );
170 this.el.pack_end ( child_1.el , false,true,5 );
173 // user defined functions
175 public class Xcls_Table3 : Object
178 private Xcls_PopoverFileDetails _this;
184 public Xcls_Table3(Xcls_PopoverFileDetails _owner )
187 this.el = new Gtk.Table( 3, 2, true );
191 // set gobject values
192 var child_0 = new Xcls_Label4( _this );
194 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
195 var child_1 = new Xcls_name( _this );
197 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
198 var child_2 = new Xcls_Label6( _this );
200 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
201 var child_3 = new Xcls_title( _this );
203 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
204 var child_4 = new Xcls_Label8( _this );
206 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
207 var child_5 = new Xcls_region( _this );
209 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
210 var child_6 = new Xcls_Label10( _this );
212 this.el.attach_defaults ( child_6.el , 0,1,3,4 );
213 var child_7 = new Xcls_parent( _this );
215 this.el.attach_defaults ( child_7.el , 1,2,3,4 );
216 var child_8 = new Xcls_Label12( _this );
218 this.el.attach_defaults ( child_8.el , 0,1,4,5 );
219 var child_9 = new Xcls_permname( _this );
221 this.el.attach_defaults ( child_9.el , 1,2,4,5 );
222 var child_10 = new Xcls_Label14( _this );
224 this.el.attach_defaults ( child_10.el , 0,1,5,6 );
225 var child_11 = new Xcls_modOrder( _this );
227 this.el.attach_defaults ( child_11.el , 1,2,5,6 );
228 var child_12 = new Xcls_Label16( _this );
230 this.el.attach_defaults ( child_12.el , 0,1,6,7 );
231 var child_13 = new Xcls_build_module( _this );
233 this.el.attach_defaults ( child_13.el , 1,2,6,7 );
236 // user defined functions
238 public class Xcls_Label4 : Object
241 private Xcls_PopoverFileDetails _this;
247 public Xcls_Label4(Xcls_PopoverFileDetails _owner )
250 this.el = new Gtk.Label( "Component Name" );
254 // set gobject values
255 this.el.justify = Gtk.Justification.RIGHT;
256 this.el.xalign = 0.900000f;
259 // user defined functions
261 public class Xcls_name : Object
264 private Xcls_PopoverFileDetails _this;
270 public Xcls_name(Xcls_PopoverFileDetails _owner )
274 this.el = new Gtk.Entry();
278 // set gobject values
279 this.el.visible = true;
282 // user defined functions
284 public class Xcls_Label6 : Object
287 private Xcls_PopoverFileDetails _this;
293 public Xcls_Label6(Xcls_PopoverFileDetails _owner )
296 this.el = new Gtk.Label( "Title" );
300 // set gobject values
301 this.el.justify = Gtk.Justification.RIGHT;
302 this.el.xalign = 0.900000f;
303 this.el.visible = true;
306 // user defined functions
308 public class Xcls_title : Object
311 private Xcls_PopoverFileDetails _this;
317 public Xcls_title(Xcls_PopoverFileDetails _owner )
321 this.el = new Gtk.Entry();
325 // set gobject values
326 this.el.visible = true;
329 // user defined functions
331 public class Xcls_Label8 : Object
334 private Xcls_PopoverFileDetails _this;
340 public Xcls_Label8(Xcls_PopoverFileDetails _owner )
343 this.el = new Gtk.Label( "Region" );
347 // set gobject values
348 this.el.justify = Gtk.Justification.RIGHT;
349 this.el.xalign = 0.900000f;
350 this.el.tooltip_text = "center, north, south, east, west";
351 this.el.visible = true;
354 // user defined functions
356 public class Xcls_region : Object
359 private Xcls_PopoverFileDetails _this;
365 public Xcls_region(Xcls_PopoverFileDetails _owner )
369 this.el = new Gtk.Entry();
373 // set gobject values
374 this.el.visible = true;
377 // user defined functions
379 public class Xcls_Label10 : Object
382 private Xcls_PopoverFileDetails _this;
388 public Xcls_Label10(Xcls_PopoverFileDetails _owner )
391 this.el = new Gtk.Label( "Parent Name" );
395 // set gobject values
396 this.el.justify = Gtk.Justification.RIGHT;
397 this.el.xalign = 0.900000f;
398 this.el.visible = true;
401 // user defined functions
403 public class Xcls_parent : Object
406 private Xcls_PopoverFileDetails _this;
412 public Xcls_parent(Xcls_PopoverFileDetails _owner )
416 this.el = new Gtk.Entry();
420 // set gobject values
421 this.el.visible = true;
424 // user defined functions
426 public class Xcls_Label12 : Object
429 private Xcls_PopoverFileDetails _this;
435 public Xcls_Label12(Xcls_PopoverFileDetails _owner )
438 this.el = new Gtk.Label( "Permission Name" );
442 // set gobject values
443 this.el.justify = Gtk.Justification.RIGHT;
444 this.el.xalign = 0.900000f;
445 this.el.visible = true;
448 // user defined functions
450 public class Xcls_permname : Object
453 private Xcls_PopoverFileDetails _this;
459 public Xcls_permname(Xcls_PopoverFileDetails _owner )
462 _this.permname = this;
463 this.el = new Gtk.Entry();
467 // set gobject values
468 this.el.visible = true;
471 // user defined functions
473 public class Xcls_Label14 : Object
476 private Xcls_PopoverFileDetails _this;
482 public Xcls_Label14(Xcls_PopoverFileDetails _owner )
485 this.el = new Gtk.Label( "Order (for tabs)" );
489 // set gobject values
490 this.el.justify = Gtk.Justification.RIGHT;
491 this.el.xalign = 0.900000f;
492 this.el.visible = true;
495 // user defined functions
497 public class Xcls_modOrder : Object
500 private Xcls_PopoverFileDetails _this;
506 public Xcls_modOrder(Xcls_PopoverFileDetails _owner )
509 _this.modOrder = this;
510 this.el = new Gtk.Entry();
514 // set gobject values
515 this.el.visible = true;
518 // user defined functions
520 public class Xcls_Label16 : Object
523 private Xcls_PopoverFileDetails _this;
529 public Xcls_Label16(Xcls_PopoverFileDetails _owner )
532 this.el = new Gtk.Label( "Module to build (Vala only)" );
536 // set gobject values
537 this.el.justify = Gtk.Justification.RIGHT;
538 this.el.xalign = 0.900000f;
539 this.el.visible = true;
542 // user defined functions
544 public class Xcls_build_module : Object
546 public Gtk.ComboBox el;
547 private Xcls_PopoverFileDetails _this;
553 public Xcls_build_module(Xcls_PopoverFileDetails _owner )
556 _this.build_module = this;
557 this.el = new Gtk.ComboBox();
561 // set gobject values
562 var child_0 = new Xcls_dbcellrenderer( _this );
564 this.el.pack_start ( child_0.el , true );
565 var child_1 = new Xcls_dbmodel( _this );
567 this.el.set_model ( child_1.el );
571 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
574 // user defined functions
576 public class Xcls_dbcellrenderer : Object
578 public Gtk.CellRendererText el;
579 private Xcls_PopoverFileDetails _this;
585 public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
588 _this.dbcellrenderer = this;
589 this.el = new Gtk.CellRendererText();
593 // set gobject values
596 // user defined functions
598 public class Xcls_dbmodel : Object
600 public Gtk.ListStore el;
601 private Xcls_PopoverFileDetails _this;
607 public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
610 _this.dbmodel = this;
611 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
615 // set gobject values
618 // user defined functions
619 public void loadData (Gee.ArrayList<string> data, string cur) {
624 /// el.append(out iter);
627 // el.set_value(iter, 0, "");
628 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
633 el.set_value(iter, 0, "");
634 el.set_value(iter, 1, "-- select a module --");
635 _this.build_module.el.set_active_iter(iter);
637 for (var i = 0; i < data.size;i++) {
642 el.set_value(iter, 0, data.get(i));
643 el.set_value(iter, 1, data.get(i));
645 if (data.get(i) == cur) {
646 _this.build_module.el.set_active_iter(iter);
650 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
654 public class Xcls_HButtonBox20 : Object
656 public Gtk.HButtonBox el;
657 private Xcls_PopoverFileDetails _this;
663 public Xcls_HButtonBox20(Xcls_PopoverFileDetails _owner )
666 this.el = new Gtk.HButtonBox();
670 // set gobject values
671 var child_0 = new Xcls_Button21( _this );
673 this.el.add ( child_0.el );
674 var child_1 = new Xcls_save_btn( _this );
676 this.el.add ( child_1.el );
679 // user defined functions
681 public class Xcls_Button21 : Object
683 public Gtk.Button el;
684 private Xcls_PopoverFileDetails _this;
690 public Xcls_Button21(Xcls_PopoverFileDetails _owner )
693 this.el = new Gtk.Button();
697 // set gobject values
698 this.el.label = "Cancel";
701 this.el.clicked.connect( () => {
708 // user defined functions
710 public class Xcls_save_btn : Object
712 public Gtk.Button el;
713 private Xcls_PopoverFileDetails _this;
719 public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
722 _this.save_btn = this;
723 this.el = new Gtk.Button();
727 // set gobject values
728 this.el.label = "Save";
731 this.el.clicked.connect( ( ) => {
736 if (_this.name.el.get_text().length < 1) {
737 StandardErrorDialog.show(
739 "You have to set Component name "
744 // what does this do?
746 var isNew = _this.file.name.length > 0 ? false : true;
748 if (!isNew && this.file.name != _this.name.el.get_text()) {
749 Xcls_StandardErrorDialog.singleton().show(
751 "Sorry changing names does not work yet. "
760 // FIXME - this may be more complicated...
761 //for (var i in this.def) {
762 // this.file[i] = this.get(i).el.get_text();
767 _this.updateFileFromEntry();
768 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
769 Xcls_StandardErrorDialog.singleton().show(
771 "The name you used already exists "
782 var fn = _this.name.el.get_text();
783 var dir = _this.project.firstPath();
785 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
786 Xcls_StandardErrorDialog.singleton().show(
788 "That file already exists"
793 var f = JsRender.JsRender.factory(
794 _this.file.project.xtype,
796 dir + "/" + fn + ".bjs");
802 _this.updateFileFromEntry();
804 _this.file.project.addFile(_this.file);
813 _this.success(_this.project, _this.file);
818 // user defined functions