src/Project/Gtk.vala
[app.Builder.js] / src / Project / Gtk.vala
index 10d1549..1b719a2 100644 (file)
@@ -46,7 +46,7 @@ namespace Project {
                        
                        
                        var fn = this.firstPath() + "/config1.builder";
-                       print("load: " + fn );
+                       GLib.debug("load: " + fn );
                        
                        if (!FileUtils.test(fn, FileTest.EXISTS)) {
                                this.compilegroups.set("_default_", new GtkValaSettings("_default_") );
@@ -71,7 +71,7 @@ namespace Project {
                                }
                                this.compilegroups.set(vs.name,vs);
                        }
-                       print("%s\n",this.configToString ());
+                       GLib.debug("%s\n",this.configToString ());
                        
                }
                public string configToString()
@@ -95,7 +95,7 @@ namespace Project {
                public void writeConfig()
                {
                        var fn = this.firstPath() + "/config1.builder";
-                       print("write: " + fn );
+                       GLib.debug("write: " + fn );
 
                         
                        var f = GLib.File.new_for_path(fn);
@@ -106,20 +106,39 @@ namespace Project {
                        data_out.close(null);
                        
                        return ;
-                       
-                       
-
+                        
+               }
+               /**
+                *  perhaps we should select the default in the window somewhere...
+                */ 
+               public string firstBuildModule()
+               {
+                       var iter = this.compilegroups.map_iterator();
+                       while(iter.next()) {
+                                
+                                if (iter.get_value().name == "__default__") {
+                                        continue;
+                                }
+                                
+                                return iter.get_value().name;
+                       }
+                       return "";
                }
+               
+               
                public string relPath(string target)
                {
                        var basename = this.firstPath();
                        // eg. base = /home/xxx/fred/blogs
                        // target = /home/xxx/fred/jones
+                       
+                       // this does not work correctly...
                        var bb = basename;
                        var prefix = "";
                        while (true) {
                                if (    bb.length < target.length &&
                                        target.substring(0, bb.length) == bb) {
+                                       
                                        return prefix + target.substring(bb.length +1);
                                }
                                if (bb.length < 1) {
@@ -132,6 +151,17 @@ namespace Project {
                        }
         
                }
+               /**
+                * get a list of files for a folder..
+                * 
+                * - in the project manager this has to list all possible compilable 
+                *   files  - eg. exclue XXX.vala.c or XXX.c with the same name as 
+                *   a vala file (so to ignore the generated files)
+                * 
+                * - for the editor navigation - this should exclude all files that
+                *   are vala based on a bjs file..
+                *  
+                */
                 
                
                public Gee.ArrayList<string> files(string in_path)
@@ -142,20 +172,20 @@ namespace Project {
                        var dirname = this.resolve_path(
                                this.resolve_path_combine_path(this.firstPath(),in_path));
                        
-                       print("SCAN %s\n", dirname);
+                       GLib.debug("SCAN %s\n", dirname);
                                // scan the directory for files -- ending with vala || c
                        
 
                        var dir = File.new_for_path(dirname);
                        if (!dir.query_exists()) {
-                               print("SCAN %s - skip - does not exist\n", dirname);
+                               GLib.debug("SCAN %s - skip - does not exist\n", dirname);
                                return ret;
                        }
          
           
                        try {
                                var file_enum = dir.enumerate_children(
-                                       GLib.FileAttribute.STANDARD_DISPLAY_NAME, 
+                                       GLib.FileAttribute.STANDARD_DISPLAY_NAME, 
                                        GLib.FileQueryInfoFlags.NONE, 
                                        null
                                );
@@ -165,14 +195,15 @@ namespace Project {
                                while ((next_file = file_enum.next_file(null)) != null) {
                                        var fn = next_file.get_display_name();
                                        
-                                       print("SCAN %s - checking %s\n", dirname, fn);
+                                       GLib.debug("SCAN %s - checking %s\n", dirname, fn);
                                        if (Regex.match_simple("\\.vala$", fn)) {
                                                ret.add(in_path + "/" + fn);
                                                continue;
                                        }
                                        
-                                       
-                                       
+                                       if (Regex.match_simple("\\.vala\\.c$", fn)) {
+                                               continue;
+                                       }
                                        if (Regex.match_simple("\\.c$", fn)) {
                                                
                                                // if we have a vala file with the same name 
@@ -184,23 +215,31 @@ namespace Project {
                                        // any other valid types???
                                
                                }
+                               
+                       } catch(Error e) {
+                               GLib.warning("oops - something went wrong scanning the projects\n");
+                       }       
+                                
                                // add the cfiles to ret - if they do not have a vala...
-                               for (var i = 0; i < cfiles.size; i ++) {
-                                       
-                                       var vv = (new Regex("\\.c$")).replace(  
-                                                       cfiles.get(i), cfiles.get(i).length, 0, ".vala");
-                                                       
-                                       if (ret.index_of( vv) > -1) {
-                                               continue;
-                                       }
-                                       ret.add(cfiles.get(i));
+                       for (var i = 0; i < cfiles.size; i ++) {
+                               
+                               var fn = cfiles.get(i);
+                               vv = fn;
+                               try {
+                                       vv = (new Regex("\\.c$")).replace( fn, fn, 0, ".vala");
+                               } catch (Error e) {
+                                       continue;
                                }
+                                       
                                                
-                                      
-                       } catch(Error e) {
-                               print("oops - something went wrong scanning the projects\n");
+                               if (ret.index_of( vv) > -1) {
+                                       continue;
+                               }
+                               ret.add(fn);
                        }
-                       print("SCAN %s = returning %d", dirname, ret.size);
+                                               
+                        
+                       GLib.debug("SCAN %s = returning %d", dirname, ret.size);
                         
                        return ret;
                        
@@ -215,6 +254,7 @@ namespace Project {
                        {
                                ret += "/";
                        }
+                       //print("combined path = %s",  ret + second);
                        return ret + second;
                }
                public   string  resolve_path_times(string part, int times, string? clue = null)
@@ -278,11 +318,10 @@ namespace Project {
                        var sources = this.compilegroups.get("_default_").sources;
                        for(var i =0; i< sources.size; i++) {
                                
-                               var path = this.resolve_path(
-                               this.resolve_path_combine_path(this.firstPath(),sources.get(i)));
+                               var path = this.resolve_path( this.firstPath(), sources.get(i));
                                
                                if (Path.get_basename (path) == "vapi") {
-                                       print("Adding VAPIDIR: %s\n", path);
+                                       GLib.debug("Adding VAPIDIR: %s\n", path);
                                        ret += path;
                                }