:Revert "fix line numbering issues with vala generator - hopefully fixes completion...
[roobuilder] / src / JsRender / Gtk.vala
index 432bf3c..57ce644 100644 (file)
@@ -17,10 +17,17 @@ namespace JsRender {
        public  class Gtk : JsRender
        {
           
+          
+          public Project.Gtk gproject { 
+                       get {
+                               return (Project.Gtk) this.project;
+                       }
+                       private set {}
+               }
 
            public Gtk(Project.Project project, string path) {
            
-               aconstruct( project, path);
+               base( project, path);
                this.xtype = "Gtk";
                this.language = "vala";
                
@@ -101,13 +108,17 @@ namespace JsRender {
                        var obj = node.get_object ();
                
                        this.name = obj.get_string_member("name");
-                       this.parent = obj.get_string_member("parent");
-                       this.title = obj.get_string_member("title");
                
                        if (obj.has_member("build_module")) { // should check type really..
                                this.build_module = obj.get_string_member("build_module");
                        }
+                       if (obj.has_member("gen_extended")) { // should check type really..
+                               this.gen_extended = obj.get_boolean_member("gen_extended");
+                       }
+                       
                         
+                       
                        // load items[0] ??? into tree...
                        var bjs_version_str = this.jsonHasOrEmpty(obj, "bjs-version");
                        bjs_version_str = bjs_version_str == "" ? "1" : bjs_version_str;
@@ -137,43 +148,24 @@ namespace JsRender {
                }
            public override void setSource(string str) {}
            
+           int last_source_version = -2;
+           string last_source;
            public override string toSourceCode() // no seed support currently.
            {
-                   return  NodeToVala.mungeFile(this);
+                   if (this.version == this.last_source_version) {
+                       return this.last_source;
+               }
+                   this.last_source =   NodeToVala.mungeFile(this);
+                   this.last_source_version = this.version;
+                   return this.last_source;
+                   
            }
            
            // this is only used by dumping code...
            public override string toSource() // no seed support currently.
            {
                 
-                       
-               /*
-               if (this.tree == null) {
-                   return "";
-               }
-               
-               // var data = JSON.parse(JSON.stringify(this.items[0]));
-               // we should base this on the objects in the tree really..
-               string[]  inc = { "Gtk", "Gdk", "Pango", "GLib", "Gio", "GObject", 
-                   "GtkSource", "WebKit", "Vte" }; //, "GtkClutter" , "Gdl"];
-               var src = "";
-                        
-               for (var i=0; i< inc.length; i++) {
-                               var e = inc[i];
-                   src += e+" = imports.gi." + e +";\n";
-               }
-               
-               src += "console = imports.console;\n"; // path?!!?
-               src += "XObject = imports.XObject.XObject;\n"; // path?!!?
-               
-               
-               src += this.name + "=new XObject("+ this.mungeToString("    ") + ");\n";
-               src += this.name + ".init();\n";
-               // register it in the cache
-               src += "XObject.cache['/" + this.name + "'] = " + this.name + ";\n";
-               return src;
-               */
-               return "";
+                        return  this.toSourceCode();
                
                
            }
@@ -183,6 +175,9 @@ namespace JsRender {
                // this.saveJS(); - disabled at present.. project settings will probably enable this later..
        
                this.saveVala();
+
+               this.getLanguageServer().document_save(this);
+               BuilderApplication.showSpinner("spinner", "document save send");                
            }
                // ignore these calls.
            public override void saveHTML ( string html ) {}
@@ -205,17 +200,52 @@ namespace JsRender {
                
            }
            */
-          void  saveVala()
+           
+           public override string targetName()
+           {
+               return GLib.Path.get_dirname(this.path) + "/" + this.name + ".vala";
+       }
+           
+           void  saveVala()
            {
                        if (this.tree == null) {
                                return;
                        }
-                       var fn = GLib.Path.get_dirname(this.path) + "/" + this.name + ".vala";
-                       print("WRITE :%s\n " , fn);
-                       this.writeFile(fn,  NodeToVala.mungeFile(this));
+                       var fn = this.targetName();
+                       GLib.debug("WRITE :%s\n " , fn);
+                       try {
+                               this.writeFile(fn,  NodeToVala.mungeFile(this));
+               } catch (GLib.Error e) {}
                
                
            }
+           
+           
+           public void updateCompileGroup(string old_target, string new_target) 
+           {
+               if (old_target == new_target) {
+                       return;
+               }
+               if (old_target != "") {
+                       if (this.gproject.compilegroups.has_key(old_target)) {
+                               var cg = this.gproject.compilegroups.get(old_target);
+                               if (cg.sources.contains(this.relpath)) {
+                                       cg.sources.remove(this.relpath);
+                                       }
+                               }
+                       }
+                if (new_target != "") {
+                       if (this.gproject.compilegroups.has_key(new_target)) {
+                               var cg = this.gproject.compilegroups.get(new_target);
+                               if (!cg.sources.contains(this.relpath)) {
+                                       cg.sources.add(this.relpath);
+                                       }
+                               }
+                       }
+           
+           
+           }
+           
                /*
            valaCompileCmd : function()
            {
@@ -240,12 +270,7 @@ namespace JsRender {
                
            },
            */
-           
-   
-           string getHelpUrl(string cls)
-           {
-               return "http://devel.akbkhome.com/seed/" + cls + ".html";
-           }
+            
            public override void  findTransStrings(Node? node )
                {
                        // not yet..
@@ -255,7 +280,10 @@ namespace JsRender {
                {
                        return  NodeToGlade.mungeFile(this);
                }
-         
+               public   override string language_id() 
+               {
+                       return "vala";
+               }