tests/forkme.vala
[app.Builder.js] / src / Builder4 / PopoverFileDetails.vala
index 5eb887e..92a0bae 100644 (file)
@@ -21,10 +21,14 @@ public class Xcls_PopoverFileDetails : Object
     public Xcls_build_module build_module;
     public Xcls_dbcellrenderer dbcellrenderer;
     public Xcls_dbmodel dbmodel;
+    public Xcls_save_btn save_btn;
 
         // my vars (def)
+    public signal void success (Project.Project pr, JsRender.JsRender file);
+    public bool done;
     public Project.Project project;
     public JsRender.JsRender file;
+    public Xcls_MainWindow mainwindow;
 
     // ctor 
     public Xcls_PopoverFileDetails()
@@ -33,19 +37,60 @@ public class Xcls_PopoverFileDetails : Object
         this.el = new Gtk.Popover( null );
 
         // my vars (dec)
+        this.done = false;
         this.file = null;
+        this.mainwindow = null;
 
         // set gobject values
+        this.el.border_width = 0;
         this.el.modal = true;
+        this.el.position = Gtk.PositionType.RIGHT;
         var child_0 = new Xcls_VBox2( _this );
         child_0.ref();
-        this.el.get_content_area().add (  child_0.el  );
+        this.el.add (  child_0.el  );
+
+        // listeners 
+        this.el.closed.connect( () => {
+          if (!this.done) {
+            _this.el.show();
+          
+          }
+        });
     }
 
     // user defined functions 
-    public void show (JsRender.JsRender c) 
+    public   void updateFileFromEntry () {
+    
+            _this.file.title = _this.title.el.get_text();
+            _this.file.region = _this.region.el.get_text();            
+            _this.file.parent = _this.parent.el.get_text();                        
+            _this.file.permname = _this.permname.el.get_text();                                    
+            _this.file.modOrder = _this.modOrder.el.get_text();
+            
+            if (_this.file.name.length  > 0 && _this.file.name != _this.name.el.get_text()) {
+                _this.file.renameTo(_this.name.el.get_text());
+            }
+            // store the module...
+            _this.file.build_module = "";        
+             Gtk.TreeIter iter; 
+            if (_this.build_module.el.get_active_iter (out iter)) {
+                 Value vfname;
+                 this.dbmodel.el.get_value (iter, 0, out vfname);
+                 if (((string)vfname).length > 0) {
+                     _this.file.build_module = (string)vfname;
+                 }
+        
+            }
+            
+            
+    
+                                                        
+    }
+    public void show (JsRender.JsRender c, Gtk.Widget btn) 
     {
         this.project = c.project;
+        this.done = false;
+        
         
         //if (!this.el) {
             //this.init();
@@ -59,9 +104,10 @@ public class Xcls_PopoverFileDetails : Object
          _this.permname.el.set_text(c.permname);
         
         if (c.path.length > 0) {
-            this.el.set_title("Edit File Details - " + c.name);
+        
+            this.save_btn.el.set_label("Save");
         } else {
-            this.el.set_title("Create New File");
+            this.save_btn.el.set_label("Create");
         }
         
          var ar = new Gee.ArrayList<string>();
@@ -86,7 +132,15 @@ public class Xcls_PopoverFileDetails : Object
          
         _this.file = c;
         //console.log('show all');
+       this.el.set_modal(true);
+        this.el.set_relative_to(btn);
+    
+        this.el.set_position(Gtk.PositionType.RIGHT);
+        
+        // window + header?
+         print("SHOWALL - POPIP\n");
         this.el.show_all();
+        this.name.el.grab_focus();
         
         //this.success = c.success;
         
@@ -104,22 +158,47 @@ public class Xcls_PopoverFileDetails : Object
         public Xcls_VBox2(Xcls_PopoverFileDetails _owner )
         {
             _this = _owner;
-            this.el = new Gtk.VBox( true, 0 );
+            this.el = new Gtk.VBox( false, 0 );
 
             // my vars (dec)
 
             // set gobject values
-            var child_0 = new Xcls_Table3( _this );
+            var child_0 = new Xcls_HeaderBar3( _this );
             child_0.ref();
-            this.el.pack_start (  child_0.el , false,false,0 );
-            var child_1 = new Xcls_HButtonBox20( _this );
+            this.el.pack_start (  child_0.el , false,true,0 );
+            var child_1 = new Xcls_Table4( _this );
             child_1.ref();
-            this.el.pack_end (  child_1.el , false,false,5 );
+            this.el.pack_start (  child_1.el , false,false,4 );
+            var child_2 = new Xcls_HButtonBox21( _this );
+            child_2.ref();
+            this.el.pack_end (  child_2.el , false,true,0 );
         }
 
         // user defined functions 
     }
-    public class Xcls_Table3 : Object 
+    public class Xcls_HeaderBar3 : Object 
+    {
+        public Gtk.HeaderBar el;
+        private Xcls_PopoverFileDetails  _this;
+
+
+            // my vars (def)
+
+        // ctor 
+        public Xcls_HeaderBar3(Xcls_PopoverFileDetails _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.HeaderBar();
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.title = "Add / Edit File";
+        }
+
+        // user defined functions 
+    }
+    public class Xcls_Table4 : Object 
     {
         public Gtk.Table el;
         private Xcls_PopoverFileDetails  _this;
@@ -128,7 +207,7 @@ public class Xcls_PopoverFileDetails : Object
             // my vars (def)
 
         // ctor 
-        public Xcls_Table3(Xcls_PopoverFileDetails _owner )
+        public Xcls_Table4(Xcls_PopoverFileDetails _owner )
         {
             _this = _owner;
             this.el = new Gtk.Table( 3, 2, true );
@@ -136,43 +215,46 @@ public class Xcls_PopoverFileDetails : Object
             // my vars (dec)
 
             // set gobject values
-            var child_0 = new Xcls_Label4( _this );
+            this.el.margin_right = 4;
+            this.el.margin_left = 4;
+            this.el.row_spacing = 2;
+            var child_0 = new Xcls_Label5( _this );
             child_0.ref();
             this.el.attach_defaults (  child_0.el , 0,1,0,1 );
             var child_1 = new Xcls_name( _this );
             child_1.ref();
             this.el.attach_defaults (  child_1.el , 1,2,0,1 );
-            var child_2 = new Xcls_Label6( _this );
+            var child_2 = new Xcls_Label7( _this );
             child_2.ref();
             this.el.attach_defaults (  child_2.el , 0,1,1,2 );
             var child_3 = new Xcls_title( _this );
             child_3.ref();
             this.el.attach_defaults (  child_3.el , 1,2,1,2 );
-            var child_4 = new Xcls_Label8( _this );
+            var child_4 = new Xcls_Label9( _this );
             child_4.ref();
             this.el.attach_defaults (  child_4.el , 0,1,2,3 );
             var child_5 = new Xcls_region( _this );
             child_5.ref();
             this.el.attach_defaults (  child_5.el , 1,2,2,3 );
-            var child_6 = new Xcls_Label10( _this );
+            var child_6 = new Xcls_Label11( _this );
             child_6.ref();
             this.el.attach_defaults (  child_6.el , 0,1,3,4 );
             var child_7 = new Xcls_parent( _this );
             child_7.ref();
             this.el.attach_defaults (  child_7.el , 1,2,3,4 );
-            var child_8 = new Xcls_Label12( _this );
+            var child_8 = new Xcls_Label13( _this );
             child_8.ref();
             this.el.attach_defaults (  child_8.el , 0,1,4,5 );
             var child_9 = new Xcls_permname( _this );
             child_9.ref();
             this.el.attach_defaults (  child_9.el , 1,2,4,5 );
-            var child_10 = new Xcls_Label14( _this );
+            var child_10 = new Xcls_Label15( _this );
             child_10.ref();
             this.el.attach_defaults (  child_10.el , 0,1,5,6 );
             var child_11 = new Xcls_modOrder( _this );
             child_11.ref();
             this.el.attach_defaults (  child_11.el , 1,2,5,6 );
-            var child_12 = new Xcls_Label16( _this );
+            var child_12 = new Xcls_Label17( _this );
             child_12.ref();
             this.el.attach_defaults (  child_12.el , 0,1,6,7 );
             var child_13 = new Xcls_build_module( _this );
@@ -182,7 +264,7 @@ public class Xcls_PopoverFileDetails : Object
 
         // user defined functions 
     }
-    public class Xcls_Label4 : Object 
+    public class Xcls_Label5 : Object 
     {
         public Gtk.Label el;
         private Xcls_PopoverFileDetails  _this;
@@ -191,7 +273,7 @@ public class Xcls_PopoverFileDetails : Object
             // my vars (def)
 
         // ctor 
-        public Xcls_Label4(Xcls_PopoverFileDetails _owner )
+        public Xcls_Label5(Xcls_PopoverFileDetails _owner )
         {
             _this = _owner;
             this.el = new Gtk.Label( "Component Name" );
@@ -228,7 +310,7 @@ public class Xcls_PopoverFileDetails : Object
 
         // user defined functions 
     }
-    public class Xcls_Label6 : Object 
+    public class Xcls_Label7 : Object 
     {
         public Gtk.Label el;
         private Xcls_PopoverFileDetails  _this;
@@ -237,7 +319,7 @@ public class Xcls_PopoverFileDetails : Object
             // my vars (def)
 
         // ctor 
-        public Xcls_Label6(Xcls_PopoverFileDetails _owner )
+        public Xcls_Label7(Xcls_PopoverFileDetails _owner )
         {
             _this = _owner;
             this.el = new Gtk.Label( "Title" );
@@ -275,7 +357,7 @@ public class Xcls_PopoverFileDetails : Object
 
         // user defined functions 
     }
-    public class Xcls_Label8 : Object 
+    public class Xcls_Label9 : Object 
     {
         public Gtk.Label el;
         private Xcls_PopoverFileDetails  _this;
@@ -284,7 +366,7 @@ public class Xcls_PopoverFileDetails : Object
             // my vars (def)
 
         // ctor 
-        public Xcls_Label8(Xcls_PopoverFileDetails _owner )
+        public Xcls_Label9(Xcls_PopoverFileDetails _owner )
         {
             _this = _owner;
             this.el = new Gtk.Label( "Region" );
@@ -323,7 +405,7 @@ public class Xcls_PopoverFileDetails : Object
 
         // user defined functions 
     }
-    public class Xcls_Label10 : Object 
+    public class Xcls_Label11 : Object 
     {
         public Gtk.Label el;
         private Xcls_PopoverFileDetails  _this;
@@ -332,7 +414,7 @@ public class Xcls_PopoverFileDetails : Object
             // my vars (def)
 
         // ctor 
-        public Xcls_Label10(Xcls_PopoverFileDetails _owner )
+        public Xcls_Label11(Xcls_PopoverFileDetails _owner )
         {
             _this = _owner;
             this.el = new Gtk.Label( "Parent Name" );
@@ -370,7 +452,7 @@ public class Xcls_PopoverFileDetails : Object
 
         // user defined functions 
     }
-    public class Xcls_Label12 : Object 
+    public class Xcls_Label13 : Object 
     {
         public Gtk.Label el;
         private Xcls_PopoverFileDetails  _this;
@@ -379,7 +461,7 @@ public class Xcls_PopoverFileDetails : Object
             // my vars (def)
 
         // ctor 
-        public Xcls_Label12(Xcls_PopoverFileDetails _owner )
+        public Xcls_Label13(Xcls_PopoverFileDetails _owner )
         {
             _this = _owner;
             this.el = new Gtk.Label( "Permission Name" );
@@ -417,7 +499,7 @@ public class Xcls_PopoverFileDetails : Object
 
         // user defined functions 
     }
-    public class Xcls_Label14 : Object 
+    public class Xcls_Label15 : Object 
     {
         public Gtk.Label el;
         private Xcls_PopoverFileDetails  _this;
@@ -426,7 +508,7 @@ public class Xcls_PopoverFileDetails : Object
             // my vars (def)
 
         // ctor 
-        public Xcls_Label14(Xcls_PopoverFileDetails _owner )
+        public Xcls_Label15(Xcls_PopoverFileDetails _owner )
         {
             _this = _owner;
             this.el = new Gtk.Label( "Order (for tabs)" );
@@ -464,7 +546,7 @@ public class Xcls_PopoverFileDetails : Object
 
         // user defined functions 
     }
-    public class Xcls_Label16 : Object 
+    public class Xcls_Label17 : Object 
     {
         public Gtk.Label el;
         private Xcls_PopoverFileDetails  _this;
@@ -473,7 +555,7 @@ public class Xcls_PopoverFileDetails : Object
             // my vars (def)
 
         // ctor 
-        public Xcls_Label16(Xcls_PopoverFileDetails _owner )
+        public Xcls_Label17(Xcls_PopoverFileDetails _owner )
         {
             _this = _owner;
             this.el = new Gtk.Label( "Module to build (Vala only)" );
@@ -598,7 +680,7 @@ public class Xcls_PopoverFileDetails : Object
                                              
         }
     }
-    public class Xcls_HButtonBox20 : Object 
+    public class Xcls_HButtonBox21 : Object 
     {
         public Gtk.HButtonBox el;
         private Xcls_PopoverFileDetails  _this;
@@ -607,7 +689,7 @@ public class Xcls_PopoverFileDetails : Object
             // my vars (def)
 
         // ctor 
-        public Xcls_HButtonBox20(Xcls_PopoverFileDetails _owner )
+        public Xcls_HButtonBox21(Xcls_PopoverFileDetails _owner )
         {
             _this = _owner;
             this.el = new Gtk.HButtonBox();
@@ -615,17 +697,20 @@ public class Xcls_PopoverFileDetails : Object
             // my vars (dec)
 
             // set gobject values
-            var child_0 = new Xcls_Button21( _this );
+            this.el.margin_right = 4;
+            this.el.margin_left = 4;
+            this.el.margin_bottom = 4;
+            var child_0 = new Xcls_Button22( _this );
             child_0.ref();
             this.el.add (  child_0.el  );
-            var child_1 = new Xcls_Button22( _this );
+            var child_1 = new Xcls_save_btn( _this );
             child_1.ref();
             this.el.add (  child_1.el  );
         }
 
         // user defined functions 
     }
-    public class Xcls_Button21 : Object 
+    public class Xcls_Button22 : Object 
     {
         public Gtk.Button el;
         private Xcls_PopoverFileDetails  _this;
@@ -634,7 +719,7 @@ public class Xcls_PopoverFileDetails : Object
             // my vars (def)
 
         // ctor 
-        public Xcls_Button21(Xcls_PopoverFileDetails _owner )
+        public Xcls_Button22(Xcls_PopoverFileDetails _owner )
         {
             _this = _owner;
             this.el = new Gtk.Button();
@@ -643,23 +728,30 @@ public class Xcls_PopoverFileDetails : Object
 
             // set gobject values
             this.el.label = "Cancel";
+
+            // listeners 
+            this.el.clicked.connect( () => { 
+            
+              _this.done = true;
+                _this.el.hide(); 
+            });
         }
 
         // user defined functions 
     }
-    public class Xcls_Button22 : Object 
+    public class Xcls_save_btn : Object 
     {
         public Gtk.Button el;
         private Xcls_PopoverFileDetails  _this;
 
 
             // my vars (def)
-        public signal void success (Project.Project pr, JsRender.JsRender file);
 
         // ctor 
-        public Xcls_Button22(Xcls_PopoverFileDetails _owner )
+        public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
         {
             _this = _owner;
+            _this.save_btn = this;
             this.el = new Gtk.Button();
 
             // my vars (dec)
@@ -668,14 +760,14 @@ public class Xcls_PopoverFileDetails : Object
             this.el.label = "Save";
 
             // listeners 
-            this.el.activate.connect( ( ) =>  { 
+            this.el.clicked.connect( ( ) =>  { 
               
                 
             
             
                     if (_this.name.el.get_text().length  < 1) {
                         StandardErrorDialog.show(
-                            this.el,
+                            _this.mainwindow.el,
                             "You have to set Component name "
                         );
                          
@@ -704,27 +796,27 @@ public class Xcls_PopoverFileDetails : Object
             
                     if (!isNew) {
                         try {
-                             this.updateFileFromEntry();
+                             _this.updateFileFromEntry();
                          } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
                               Xcls_StandardErrorDialog.singleton().show(
-                                this.el,
+                                _this.mainwindow.el,
                                 "The name you used already exists "
                             );
                             return;
                              
                          }
                                                                     
-                    
+                          _this.done = true;
                         _this.file.save();
-                        this.el.hide();
+                        _this.el.hide();
                         return;
                     }
-                    var fn = this.name.el.get_text();
+                    var fn = _this.name.el.get_text();
                     var dir = _this.project.firstPath();
                    
                     if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
                         Xcls_StandardErrorDialog.singleton().show(
-                            this.el,
+                            _this.mainwindow.el,
                             "That file already exists"
                         ); 
                         return;
@@ -739,15 +831,15 @@ public class Xcls_PopoverFileDetails : Object
                     
             
                     
-                    this.updateFileFromEntry();
+                    _this.updateFileFromEntry();
                     _this.file.save();
                     _this.file.project.addFile(_this.file);
                     
                 
                     // what about .js ?
-                   
-                    this.el.hide();
-                    
+                   _this.done = true;
+                    _this.el.hide();
+             
                     
                     
                     _this.success(_this.project, _this.file);