src/Builder4/ValaProjectSettings.bjs
[app.Builder.js] / src / Builder4 / ValaProjectSettings.vala
index 61f4cf8..28c3e6a 100644 (file)
@@ -26,6 +26,7 @@ public class ValaProjectSettings : Object
     public Xcls_targets_tree targets_tree;
     public Xcls_targets_tree_store targets_tree_store;
     public Xcls_targets_render targets_render;
+    public Xcls_set_vbox set_vbox;
     public Xcls_build_pack_target build_pack_target;
     public Xcls_build_compile_flags build_compile_flags;
     public Xcls_files_tree_store files_tree_store;
@@ -60,7 +61,7 @@ public class ValaProjectSettings : Object
         
         this.project=  project;
     
-        this.compile_flags.el.text = "";
+        this.compile_flags.el.text = _this.project.compilegroups.get("_default_").compile_flags;
         
         this.default_directory_tree_store.load();    
         this.default_packages_tree_store.load();            
@@ -68,6 +69,9 @@ public class ValaProjectSettings : Object
         this.files_tree_store.load();
     
     }
+    public void save ()  {
+        this.project.writeConfig();
+    }
     public class Xcls_Notebook2 : Object 
     {
         public Gtk.Notebook el;
@@ -221,11 +225,13 @@ public class ValaProjectSettings : Object
             // my vars (dec)
 
             // set gobject values
+            this.el.placeholder_text = "eg. -g --valasrc $BASEDIR ";
 
             // listeners 
             this.el.changed.connect( () => {
                 
-            
+               _this.project.compilegroups.get("_default_").compile_flags = this.el.text;
+               _this.project.writeConfig();
             //    _this.project.save();
             
             });
@@ -334,7 +340,7 @@ public class ValaProjectSettings : Object
         public void load () {
          
             var def = _this.project.compilegroups.get("_default_");
-             var items  = def.packages;
+            var items  = def.packages;
             
             this.el.clear();
             var pal = (Palete.Gtk) Palete.factory("Gtk");
@@ -379,7 +385,8 @@ public class ValaProjectSettings : Object
 
             // init method 
 
-            this.el.add_attribute(_this.packages_render.el , "text", 0 );        }
+            this.el.add_attribute(_this.packages_render.el , "text", 0 );
+        }
 
         // user defined functions 
     }
@@ -433,7 +440,8 @@ public class ValaProjectSettings : Object
 
             {
              this.el.add_attribute(_this.packages_render_use.el , "active", 1 );
-             }        }
+             }
+        }
 
         // user defined functions 
     }
@@ -655,7 +663,8 @@ public class ValaProjectSettings : Object
 
             // init method 
 
-            this.el.add_attribute(_this.directory_render.el , "text", 0 );        }
+            this.el.add_attribute(_this.directory_render.el , "text", 0 );
+        }
 
         // user defined functions 
     }
@@ -925,7 +934,8 @@ public class ValaProjectSettings : Object
             {  
             this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
             
-            }        }
+            }
+        }
 
         // user defined functions 
     }
@@ -1128,10 +1138,12 @@ public class ValaProjectSettings : Object
                      Gtk.TreeModel mod;
                     Gtk.TreeIter iter;
                     if (!this.el.get_selection().get_selected(out mod, out iter)) {
-                           print("nothing selected\n");
+                        print("nothing selected\n");
+                        // should disable the right hand side..
+                        _this.set_vbox.el.hide();
                         return;
                     }
-            
+                    _this.set_vbox.el.show();
                         
                    // add the directory..
                    
@@ -1142,10 +1154,13 @@ public class ValaProjectSettings : Object
                    
                    this.cursor = fn;
                    var cg = _this.project.compilegroups.get(fn);
+                   
                    _this.build_pack_target.el.set_text(cg.target_bin);
                    _this.build_compile_flags.el.set_text(cg.compile_flags);
+                   _this.set_vbox.cgroup = cg;
+                   //_this.files_tree_store.updatesel(cg);
                    // load the srouces
-            
+                   
             
               });
         }
@@ -1197,7 +1212,7 @@ public class ValaProjectSettings : Object
                 //this.el.set_value(citer, 1,   items.get(i) );
             };
             this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);
-            
+            _this.set_vbox.el.hide();
         }
     }
     public class Xcls_TreeViewColumn35 : Object 
@@ -1227,7 +1242,8 @@ public class ValaProjectSettings : Object
 
             {
                  this.el.add_attribute(_this.targets_render.el , "text", 0 );
-             }        }
+             }
+        }
 
         // user defined functions 
     }
@@ -1266,7 +1282,7 @@ public class ValaProjectSettings : Object
                     cg.name = newtext;
                     _this.project.compilegroups.unset(oldval);
                     _this.project.compilegroups.set(newtext, cg);
-                _this.targets_tree_store.load();
+                   _this.targets_tree_store.load();
               });
         }
 
@@ -1279,14 +1295,17 @@ public class ValaProjectSettings : Object
 
 
             // my vars (def)
+        public Project.GtkValaSettings cgroup;
 
         // ctor 
         public Xcls_set_vbox(ValaProjectSettings _owner )
         {
             _this = _owner;
+            _this.set_vbox = this;
             this.el = new Gtk.VBox( false, 0 );
 
             // my vars (dec)
+            this.cgroup = null;
 
             // set gobject values
             var child_0 = new Xcls_Label38( _this );
@@ -1453,6 +1472,7 @@ public class ValaProjectSettings : Object
             // set gobject values
             var child_0 = new Xcls_files_tree( _this );
             child_0.ref();
+            this.el.add (  child_0.el  );
         }
 
         // user defined functions 
@@ -1500,7 +1520,8 @@ public class ValaProjectSettings : Object
         {
             _this = _owner;
             _this.files_tree_store = this;
-            this.el = new Gtk.ListStore( 2,     typeof(string),  // 0 file name
+            this.el = new Gtk.ListStore( 4,     typeof(string),  // 0 file name
+        typeof(string),  // 0 basename
      typeof(string), // type (dir orfile)
      typeof(bool)  // is checked.
       );
@@ -1513,12 +1534,15 @@ public class ValaProjectSettings : Object
         // user defined functions 
         public void load () {
          
-          this.el.clear();
+              this.el.clear();
           
             
              var def = _this.project.compilegroups.get("_default_");
              var items  = def.sources;
              
+             
+             
+             
          
             Gtk.TreeIter citer;
         
@@ -1526,25 +1550,52 @@ public class ValaProjectSettings : Object
                  this.el.append(out citer);   
                  
                 this.el.set_value(citer, 0,   items.get(i) ); // title 
-                this.el.set_value(citer, 1,   "dir"); // type         
-                this.el.set_value(citer, 2,   false ); // checked 
-                /*
-                var files = def.files(items.get(i));
+                this.el.set_value(citer, 1,   "<span foreground=\"green\" font_weight=\"bold\">" + 
+                            GLib.Markup.escape_text(items.get(i)) + "</span>"
+                    ); // title 
+                print("ADD item %s", items.get(i));
+                this.el.set_value(citer, 2,   "dir"); // type         
+                this.el.set_value(citer, 3,   false ); // checked 
+        
+                var files = _this.project.files(items.get(i));
                 
                  for(var j =0 ; j < files.size; j++) {
                     this.el.append(out citer);   
-                 
+                         print("ADD item %s", files.get(j));
                     this.el.set_value(citer, 0,   files.get(j) ); // title 
-                    this.el.set_value(citer, 1,   "file"); // type         
-                    this.el.set_value(citer, 2,   false ); // checked 
+                    this.el.set_value(citer, 1,   GLib.Markup.escape_text( Path.get_basename (files.get(j))) ); // title             
+                    this.el.set_value(citer, 2,   "file"); // type         
+                    this.el.set_value(citer, 3,   false ); // checked 
         
                 }
-                */
+                
                 
                 //this.el.set_value(citer, 1,   items.get(i) );
             }
             this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);
             
+        }
+        public void update () {
+        
+        
+            Gtk.TreeIter citer;
+        
+            for(var i =0 ; i < this.el.iter_n_children(null); i++) {
+                this.el.iter_nth_child(citer,null,i);
+        
+                GLib.Value val;
+                this.el.get_value(iter,0, out val);
+                var fn = (string) val;
+                
+                var active = false;
+                if (_this.set_vbox.cgroup.sources.contains(fn)) {
+                    active = true;
+                }
+                
+                this.el.set_value(citer, 3,   active ); // checked 
+            }
+        
+        
         }
     }
     public class Xcls_TreeViewColumn46 : Object 
@@ -1572,8 +1623,11 @@ public class ValaProjectSettings : Object
 
             // init method 
 
-            /* this.el.add_attribute(_this.files_render.el , "markup", 2 );
-            // this.el.add_attribute(_this.files_render.el , "text", 1 ); */        }
+            this.el.add_attribute(_this.files_render.el , "markup", 1 ); // basnemae
+             
+            /*  this.el.add_attribute(_this.files_render.el , "markup", 2 );
+            */
+        }
 
         // user defined functions 
     }
@@ -1625,11 +1679,10 @@ public class ValaProjectSettings : Object
 
             // init method 
 
-            /*
-            
-             this.el.add_attribute(_this.packages_render_use.el , "active", 1 );
-             
-             */        }
+            {
+             this.el.add_attribute(_this.files_render_use.el , "active", 3 );
+             }
+        }
 
         // user defined functions 
     }
@@ -1655,24 +1708,40 @@ public class ValaProjectSettings : Object
 
             // listeners 
             this.el.toggled.connect( (  path_string) =>  { 
-                var m = _this.default_packages_tree_store.el;
+            
+            
+            
+                var m = _this.files_tree_store.el;
                Gtk.TreeIter iter;
                Gtk.TreePath path = new Gtk.TreePath.from_string (path_string);
                m.get_iter (out iter, path);
                GLib.Value val;
-               m.get_value(iter, 1, out val);
-               m.set_value(iter, 1,  ((bool) val) ? false :true); 
-                 GLib.Value fval;  
+               m.get_value(iter, 3, out val);
+               m.set_value(iter, 3,  ((bool) val) ? false :true); 
+               
+               // type.
+               GLib.Value ftval;  
+               m.get_value(iter, 2, out ftval);
+               var ftype = (string)ftval;   
+               
+               // full name...  
+               GLib.Value fval;     
                m.get_value(iter, 0, out fval);
                var fn = (string)fval;
                 
-                var def = _this.project.compilegroups.get("_default_");
-                var items  = def.packages;
+                
+                var cg =   _this.set_vbox.cgroup;
+                // what's the sleected target?
+                // update the list..
+                // if ftype is a dir == then toggle all the bellow.
+                // if ftype is a file .. see if all the files in that directory are check and check the dir.
+            
+                 
                 if ((bool)val) {
                     // renive
-                    items.remove(fn);
+                    cg.sources.remove(fn);
                 } else {
-                    items.add(fn);
+                    cg.sources.add(fn);
                 }
                 
             });