Fix #8048 - context provider start work - fix meson build flag - project settings...
[roobuilder] / src / Project / Gtk.vala
index f0d1dd2..42afbc9 100644 (file)
@@ -39,13 +39,16 @@ namespace Project
            public Gee.HashMap<string,Gee.ArrayList<string>> child_list_cache;   // what child can on on what node
                public Gee.HashMap<string,Gee.ArrayList<string>> child_list_cache_props; // what child can go on what node (with properties included)
                
-            public string compile_flags = ""; // generic to all.       
+           public string compile_flags = ""; // generic to all.        
+           public bool generate_meson = false; 
+            
                public Gee.ArrayList<string> packages; // list of vapi's that are used by this project. 
                 
                //pblic Gee.ArrayList<string> hidden; // list of dirs to be hidden from display...
                
                public GtkValaSettings? active_cg = null;
                public Gee.HashMap<string,GtkValaSettings> compilegroups;
+               public Meson meson;
                
                
                public Palete.Gtk gpalete {
@@ -72,6 +75,7 @@ namespace Project
                        this.packages = new Gee.ArrayList<string>();
                        //this.hidden = new Gee.ArrayList<string>();
                        this.compilegroups = new  Gee.HashMap<string,GtkValaSettings>();
+                       this.meson = new Meson(this);
                
                }
                
@@ -96,7 +100,15 @@ namespace Project
                        if (obj.has_member("compiler_flags")) {
                                this.compile_flags = obj.get_string_member("compile_flags");
                        }
-                       
+                       if (obj.has_member("version")) {
+                               this.version = obj.get_string_member("version");
+                       }
+                       if (obj.has_member("licence")) {
+                               this.licence = obj.get_string_member("licence");
+                       }
+                       if (obj.has_member("generate_meson")) {
+                               this.generate_meson = obj.get_boolean_member("generate_meson");
+                       }
                         if (!obj.has_member("compilegroups") || obj.get_member("compilegroups").get_node_type () != Json.NodeType.ARRAY) {
                                // make _default_ ?
                                 return;
@@ -128,6 +140,9 @@ namespace Project
                        obj.set_array_member("compilegroups", ar);
                        
                        obj.set_string_member("compile_flags", this.compile_flags);
+                       obj.set_string_member("version", this.version);
+                       obj.set_string_member("licence", this.licence);
+                       obj.set_boolean_member("generate_meson",this.generate_meson);
                        var par = new Json.Array();
                        foreach(var p in this.packages) {
                                par.add_string_element(p);
@@ -145,6 +160,16 @@ namespace Project
                        this.gir_cache = null;
                }
                
+               public override void onSave()
+               {
+                       if (this.generate_meson) {
+                               this.meson.save();
+                       }
+                       var vl = this.language_servers.get("vala");
+                       if (vl != null) {
+                               vl.initialize_server(); // hopefully better than exit?
+                       }
+               }
         
                /**
                 *  perhaps we should select the default in the window somewhere...
@@ -201,9 +226,41 @@ namespace Project
                {
                        return this.pathsMatching("vapi", false);
                }
+               
+               
+                
+               public override Palete.LanguageClient getLanguageServer(string lang)
+               {
+                       if (this.language_servers.has_key(lang)) {
+                               return this.language_servers.get(lang);
+                       }
+                       switch( lang ) {
+                               case "vala":
+                                       var ls = new Palete.LanguageClientVala(this);
+                                       ls.log.connect((act, msg) => {
+                                               //GLib.debug("log %s: %s", act.to_string(), msg);
+                                               BuilderApplication.showSpinnerLspLog(act,msg);
+                                       });
+                                       this.language_servers.set(lang, ls);
+                                       break;
+                               default :
+                                        return this.language_servers.get("dummy");
+                                        
+                               }
+                               return this.language_servers.get(lang);
+               
+               }
+                
+                
                 
+                
+                
+                
+                // ------------------  new project stufff
                public override void initialize()
                {
+                       this.generate_meson = true; // default to true on new projects.
+                       
                        string[] dirs = {
                                "src",
                                "src/ui"
@@ -241,7 +298,7 @@ namespace Project
                        this.makeMain();
                        this.makeApplication();
                        this.makeWindow();
-                       
+                       this.makeGitIgnore();
 
                        var cg =  new GtkValaSettings(this, this.name);
                        this.compilegroups.set(this.name, cg);
@@ -357,14 +414,18 @@ namespace Project
 }
 """);
        }
-       
+       void makeGitIgnore()
+       {
+                       this.writeFile(".gitignore", """
+build/
+""");
+       }
                        
                
- public override void   initDatabase()
-    {
-         // nOOP
-    }
               public override void   initDatabase()
+               {
+                    // nOOP
+               }
        }