resources/RooUsage.txt
[app.Builder.js] / src / Builder4 / PopoverFileDetails.vala
index ced3a46..9bfab0a 100644 (file)
@@ -26,9 +26,9 @@ public class Xcls_PopoverFileDetails : Object
     public Xcls_build_module build_module;
     public Xcls_dbcellrenderer dbcellrenderer;
     public Xcls_dbmodel dbmodel;
-    public Xcls_build_module build_module;
-    public Xcls_dbcellrenderer dbcellrenderer;
-    public Xcls_dbmodel dbmodel;
+    public Xcls_dir dir;
+    public Xcls_dircellrenderer dircellrenderer;
+    public Xcls_dirmodel dirmodel;
     public Xcls_save_btn save_btn;
 
         // my vars (def)
@@ -117,14 +117,6 @@ public class Xcls_PopoverFileDetails : Object
         
         
         
-        if (c.path.length > 0) {
-                
-           this.save_btn.el.set_label("Save");
-        } else {
-            this.save_btn.el.set_label("Create");
-            
-          
-        }
         
          var ar = new Gee.ArrayList<string>();
          _this.dbmodel.loadData(ar,"");
@@ -161,11 +153,12 @@ public class Xcls_PopoverFileDetails : Object
         
         
         if (c.path.length > 0) {
+           this.save_btn.el.set_label("Save");
                _this.filetype.el.hide();
                _this.filetypelbl.el.hide();
-     
+               _this.filetype.showhide(true); // as we only work on bjs files currently
         } else {
-            
+            this.save_btn.el.set_label("Create");
             _this.ftdbmodel.loadData("bjs"); // fixme - need to determine type..
            _this.filetype.el.show();
            _this.filetypelbl.el.show();
@@ -200,12 +193,9 @@ public class Xcls_PopoverFileDetails : Object
             var child_1 = new Xcls_grid( _this );
             child_1.ref();
             this.el.pack_start (  child_1.el , false,false,4 );
-            var child_2 = new Xcls_Label29( _this );
+            var child_2 = new Xcls_HButtonBox29( _this );
             child_2.ref();
-            this.el.attach (  child_2.el , 0,7,1,1 );
-            var child_3 = new Xcls_HButtonBox30( _this );
-            child_3.ref();
-            this.el.pack_end (  child_3.el , false,true,0 );
+            this.el.pack_end (  child_2.el , false,true,0 );
         }
 
         // user defined functions
@@ -305,7 +295,7 @@ public class Xcls_PopoverFileDetails : Object
             var child_16 = new Xcls_Label25( _this );
             child_16.ref();
             this.el.attach (  child_16.el , 0,8 );
-            var child_17 = new Xcls_build_module( _this );
+            var child_17 = new Xcls_dir( _this );
             child_17.ref();
             this.el.attach (  child_17.el , 1,8 );
         }
@@ -376,28 +366,46 @@ public class Xcls_PopoverFileDetails : Object
                         is_bjs = ((string)vfname) == "bjs";
                }
                 
-               for (var i = 2; i < 8;i++) {
-                       var el = _this.grid.el.get_child_at(0,i);
-                       if (is_bjs) {
-                          el.show();
-                       } else {
-                               el.hide();
-                       }
-                        el = _this.grid.el.get_child_at(1,i);
-                       if (is_bjs) {
-                          el.show();
-                       } else {
-                               el.hide();
-                       }     
-                }
-                 
-                 
+              
+                // directory is only available for non-bjs 
+                this.showhide(is_bjs);
             
             
             });
         }
 
         // user defined functions
+        public void showhide (bool is_bjs) {
+               for (var i = 2; i < 9;i++) {
+                       var el = _this.grid.el.get_child_at(0,i);
+                       
+                       var showhide= is_bjs;
+                       if (i> 7) {
+                               showhide = !showhide;
+                       }
+                       
+                       if (showhide) {
+                          el.show();
+                       } else {
+                               el.hide();
+                       }
+                        el = _this.grid.el.get_child_at(1,i);
+                       if (showhide) {
+                          el.show();
+                       } else {
+                               el.hide();
+                       }     
+            }
+            // load up the directories
+            //??? why can we not create bjs files in other directories??
+               if (!is_bjs && _this.file.path.length < 1) {
+                       _this.dirmodel.loadData();
+                       
+                       
+               }
+           
+            
+        }
     }
     public class Xcls_ftdbcellrenderer : Object
     {
@@ -937,7 +945,7 @@ public class Xcls_PopoverFileDetails : Object
         public Xcls_Label25(Xcls_PopoverFileDetails _owner )
         {
             _this = _owner;
-            this.el = new Gtk.Label( "Module to build (Vala only)" );
+            this.el = new Gtk.Label( "Directory" );
 
             // my vars (dec)
 
@@ -950,7 +958,7 @@ public class Xcls_PopoverFileDetails : Object
         // user defined functions
     }
 
-    public class Xcls_build_module : Object
+    public class Xcls_dir : Object
     {
         public Gtk.ComboBox el;
         private Xcls_PopoverFileDetails  _this;
@@ -959,30 +967,30 @@ public class Xcls_PopoverFileDetails : Object
             // my vars (def)
 
         // ctor
-        public Xcls_build_module(Xcls_PopoverFileDetails _owner )
+        public Xcls_dir(Xcls_PopoverFileDetails _owner )
         {
             _this = _owner;
-            _this.build_module = this;
+            _this.dir = this;
             this.el = new Gtk.ComboBox();
 
             // my vars (dec)
 
             // set gobject values
-            var child_0 = new Xcls_dbcellrenderer( _this );
+            var child_0 = new Xcls_dircellrenderer( _this );
             child_0.ref();
             this.el.pack_start (  child_0.el , true );
-            var child_1 = new Xcls_dbmodel( _this );
+            var child_1 = new Xcls_dirmodel( _this );
             child_1.ref();
             this.el.set_model (  child_1.el  );
 
             // init method
 
-            this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
+            this.el.add_attribute(_this.dircellrenderer.el , "markup", 1 );
         }
 
         // user defined functions
     }
-    public class Xcls_dbcellrenderer : Object
+    public class Xcls_dircellrenderer : Object
     {
         public Gtk.CellRendererText el;
         private Xcls_PopoverFileDetails  _this;
@@ -991,10 +999,10 @@ public class Xcls_PopoverFileDetails : Object
             // my vars (def)
 
         // ctor
-        public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
+        public Xcls_dircellrenderer(Xcls_PopoverFileDetails _owner )
         {
             _this = _owner;
-            _this.dbcellrenderer = this;
+            _this.dircellrenderer = this;
             this.el = new Gtk.CellRendererText();
 
             // my vars (dec)
@@ -1005,7 +1013,7 @@ public class Xcls_PopoverFileDetails : Object
         // user defined functions
     }
 
-    public class Xcls_dbmodel : Object
+    public class Xcls_dirmodel : Object
     {
         public Gtk.ListStore el;
         private Xcls_PopoverFileDetails  _this;
@@ -1014,10 +1022,10 @@ public class Xcls_PopoverFileDetails : Object
             // my vars (def)
 
         // ctor
-        public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
+        public Xcls_dirmodel(Xcls_PopoverFileDetails _owner )
         {
             _this = _owner;
-            _this.dbmodel = this;
+            _this.dirmodel = this;
             this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
 
             // my vars (dec)
@@ -1026,8 +1034,17 @@ public class Xcls_PopoverFileDetails : Object
         }
 
         // user defined functions
-        public void loadData (Gee.ArrayList<string> data, string cur) {
+        public void loadData () {
+               
+               
+          
             this.el.clear();                                    
+            
+            if (!(_this.project is Project.Gtk)) {
+                       return;
+               }
+            var sd = ((Project.Gtk)_this.project).sourcedirs();
+            
             Gtk.TreeIter iter;
             var el = this.el;
             
@@ -1037,59 +1054,34 @@ public class Xcls_PopoverFileDetails : Object
            // el.set_value(iter, 0, "");
            // el.set_value(iter, 1, "aaa  - Just add Element - aaa");
         
-            el.append(out iter);
+        //    el.append(out iter);
         
             
-            el.set_value(iter, 0, "");
-            el.set_value(iter, 1, "-- select a module --");
-            _this.build_module.el.set_active_iter(iter);
+        //    el.set_value(iter, 0, "");
+          //  el.set_value(iter, 1, "-- select a directoyr --");
+            //_this.build_module.el.set_active_iter(iter);
             
-            for (var i = 0; i < data.size;i++) {
+            for (var i = 0; i < sd.length;i++) {
             
         
                 el.append(out iter);
                 
-                el.set_value(iter, 0, data.get(i));
-                el.set_value(iter, 1, data.get(i));
+                el.set_value(iter, 0, sd[i]);
+                el.set_value(iter, 1, sd[i]);
                 
-                if (data.get(i) == cur) {
-                    _this.build_module.el.set_active_iter(iter);
-                }
+                //if (data.get(i) == cur) {
+                //    _this.build_module.el.set_active_iter(iter);
+               // }
                 
             }
-             this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);          
+          //  this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);          
                                              
         }
     }
 
 
 
-    public class Xcls_Label29 : Object
-    {
-        public Gtk.Label el;
-        private Xcls_PopoverFileDetails  _this;
-
-
-            // my vars (def)
-
-        // ctor
-        public Xcls_Label29(Xcls_PopoverFileDetails _owner )
-        {
-            _this = _owner;
-            this.el = new Gtk.Label( "Module to build (Vala only)" );
-
-            // my vars (dec)
-
-            // set gobject values
-            this.el.justify = Gtk.Justification.RIGHT;
-            this.el.xalign = 0.900000f;
-            this.el.visible = true;
-        }
-
-        // user defined functions
-    }
-
-    public class Xcls_HButtonBox30 : Object
+    public class Xcls_HButtonBox29 : Object
     {
         public Gtk.HButtonBox el;
         private Xcls_PopoverFileDetails  _this;
@@ -1098,7 +1090,7 @@ public class Xcls_PopoverFileDetails : Object
             // my vars (def)
 
         // ctor
-        public Xcls_HButtonBox30(Xcls_PopoverFileDetails _owner )
+        public Xcls_HButtonBox29(Xcls_PopoverFileDetails _owner )
         {
             _this = _owner;
             this.el = new Gtk.HButtonBox();
@@ -1109,7 +1101,7 @@ public class Xcls_PopoverFileDetails : Object
             this.el.margin_right = 4;
             this.el.margin_left = 4;
             this.el.margin_bottom = 4;
-            var child_0 = new Xcls_Button31( _this );
+            var child_0 = new Xcls_Button30( _this );
             child_0.ref();
             this.el.add (  child_0.el  );
             var child_1 = new Xcls_save_btn( _this );
@@ -1119,7 +1111,7 @@ public class Xcls_PopoverFileDetails : Object
 
         // user defined functions
     }
-    public class Xcls_Button31 : Object
+    public class Xcls_Button30 : Object
     {
         public Gtk.Button el;
         private Xcls_PopoverFileDetails  _this;
@@ -1128,7 +1120,7 @@ public class Xcls_PopoverFileDetails : Object
             // my vars (def)
 
         // ctor
-        public Xcls_Button31(Xcls_PopoverFileDetails _owner )
+        public Xcls_Button30(Xcls_PopoverFileDetails _owner )
         {
             _this = _owner;
             this.el = new Gtk.Button();
@@ -1223,13 +1215,6 @@ public class Xcls_PopoverFileDetails : Object
                }
                
                // ---------------- NEW FILES...
-               
-               var fn = _this.name.el.get_text();
-               var dir = _this.project.firstPath();   // fixme.. should be based on a pulldown?
-               
-               var targetfile = dir + "/" + fn;
-               
-               // strip the file type off the end..
                Gtk.TreeIter iter;
             
                if (!_this.filetype.el.get_active_iter(out iter)) {
@@ -1239,10 +1224,37 @@ public class Xcls_PopoverFileDetails : Object
                        _this.mainwindow.el,
                        "You must select a file type. "
                    );
+                   return;
+                        
                }
+               
+               
+               var fn = _this.name.el.get_text();
+               
                Value ftypename;
                _this.ftdbmodel.el.get_value (iter, 0, out ftypename);
                var ext = ((string)ftypename);
+               var dir = _this.project.firstPath(); 
+               if (ext != "bjs") {
+                
+                       if (!_this.dir.el.get_active_iter(out iter)) {
+                               // should not happen...
+                               // so we are jut going to return without 
+                               StandardErrorDialog.show(
+                                   _this.mainwindow.el,
+                                   "You must select a directory "
+                               );
+                               return;
+                       }
+                       Value vdir;
+                       _this.dirmodel.el.get_value (iter, 0, out vdir);
+                       dir = (string)vdir;
+               }
+               
+               var targetfile = dir + "/" + fn;
+               
+               // strip the file type off the end..
+               
                
                 var rx = new GLib.Regex("\\." + ext + "$",GLib.RegexCompileFlags.CASELESS);
                 targetfile = rx.replace(targetfile, targetfile.length, 0, "");