Tidy up roodata fetching, and updating
authorAlan <alan@roojs.com>
Wed, 6 Jul 2022 10:26:23 +0000 (18:26 +0800)
committerAlan <alan@roojs.com>
Wed, 6 Jul 2022 10:26:23 +0000 (18:26 +0800)
src/Builder4/MainWindow.bjs
src/Builder4/MainWindow.vala
src/Palete/Roo.vala
src/Resources.vala

index 97cdb77..864b039 100644 (file)
     ]
    },
    "xtype" : "Window",
-   "|             void setTitle" : [
-    " (string str) {",
-    "    this.headerbar.el.set_title(this.title + \" - \" + str);",
-    "} ",
-    ""
-   ],
-   "|             void show" : [
-    "() {",
-    "   ",
-    "    this.el.show_all();",
-    "",
-    "}"
-   ],
-   "|        void initChildren" : [
+   "| void initChildren" : [
     " () {",
     "    // this needs putting in a better place..",
     "    this.windowstate = new WindowState(this);",
     "        //w.windowstate.switchState(WindowState.State.FILES);",
     "}",
     ""
+   ],
+   "| void setTitle" : [
+    " (string str) {",
+    "    this.headerbar.el.set_title(this.title + \" - \" + str);",
+    "} ",
+    ""
+   ],
+   "| void show" : [
+    "() {",
+    "   ",
+    "    this.el.show_all();",
+    "",
+    "}"
    ]
   }
  ],
index 3e2a617..5d91d50 100644 (file)
@@ -35,10 +35,10 @@ public class Xcls_MainWindow : Object
     public Xcls_statusbar_compile_spinner statusbar_compile_spinner;
 
         // my vars (def)
-    public Project.Project project;
-    public string title;
     public int no_windows;
     public WindowState windowstate;
+    public string title;
+    public Project.Project project;
 
     // ctor
     public Xcls_MainWindow()
@@ -47,10 +47,10 @@ public class Xcls_MainWindow : Object
         this.el = new Gtk.Window( Gtk.WindowType.TOPLEVEL );
 
         // my vars (dec)
-        this.project = null;
-        this.title = "Roo Application Builder";
         this.no_windows = 1;
         this.windowstate = null;
+        this.title = "Roo Application Builder";
+        this.project = null;
 
         // set gobject values
         this.el.border_width = 0;
@@ -126,18 +126,7 @@ public class Xcls_MainWindow : Object
     }
 
     // user defined functions
-    public void openNewWindow () {
-       Xcls_MainWindow.singleton().no_windows++;
-        var w = new Xcls_MainWindow();
-        w.ref();
-    
-        w.el.show_all();
-        w.initChildren();
-        w.windowstate.showPopoverFiles(w.open_projects_btn.el, _this.project);
-            // should open the file dialog...
-            //w.windowstate.switchState(WindowState.State.FILES);
-    }
-    public        void initChildren () {
+    public void initChildren () {
         // this needs putting in a better place..
         this.windowstate = new WindowState(this);
          
@@ -149,14 +138,25 @@ public class Xcls_MainWindow : Object
     
     
     }
-    public             void show () {
+    public void show () {
        
         this.el.show_all();
     
     }
-    public             void setTitle (string str) {
+    public void setTitle (string str) {
         this.headerbar.el.set_title(this.title + " - " + str);
     }
+    public void openNewWindow () {
+       Xcls_MainWindow.singleton().no_windows++;
+        var w = new Xcls_MainWindow();
+        w.ref();
+    
+        w.el.show_all();
+        w.initChildren();
+        w.windowstate.showPopoverFiles(w.open_projects_btn.el, _this.project);
+            // should open the file dialog...
+            //w.windowstate.switchState(WindowState.State.FILES);
+    }
     public class Xcls_headerbar : Object
     {
         public Gtk.HeaderBar el;
@@ -1203,7 +1203,7 @@ public class Xcls_MainWindow : Object
             this.el = new Gtk.ImageMenuItem();
 
             // my vars (dec)
-            this.notices = new Json.Object() ;
+            this.notices = new Json.Object();
 
             // set gobject values
             this.el.always_show_image = true;
@@ -1487,14 +1487,14 @@ public class Xcls_MainWindow : Object
         }
 
         // user defined functions
-        public void stop () {
-         this.el.stop();
-          this.el.hide();
-        }
         public void start () {
           this.el.show();
           this.el.start();  
         }
+        public void stop () {
+         this.el.stop();
+          this.el.hide();
+        }
     }
 
 
index 978f6f5..3227b99 100644 (file)
@@ -23,7 +23,7 @@ namespace Palete {
     public class Roo : Palete {
                
                Gee.ArrayList<string> top_classes;
-               
+               public static Gee.HashMap<string,GirObject>? classes_cache = null;
                
         public Roo(Project.Project project)
         {
@@ -33,6 +33,7 @@ namespace Palete {
             aconstruct(project);
             this.name = "Roo";
                        this.top_classes =  new Gee.ArrayList<string>();
+                       this.load(); // ? initialize the roodata?
         }
 
                Gee.HashMap<string,GirObject> propsFromJSONArray(string type, Json.Array ar, GirObject cls)
@@ -76,6 +77,12 @@ namespace Palete {
                        if (this.classes != null) {
                                return;
                        }
+                       if (Roo.classes_cache != null) {
+                               this.classes = Roo.classes_cache;
+                               return;
+                       }
+                       
+                       
                        // this.loadUsageFile(BuilderApplication.configDirectory() + "/resources/RooUsage.txt");
                        this.classes = new Gee.HashMap<string,GirObject>();
                        var add_to =  new Gee.HashMap<string,Gee.ArrayList<string>>();
@@ -189,7 +196,7 @@ namespace Palete {
                                        cls.can_drop_onto = add_to.get(cls.name);
                                }
                        }
-                                
+                       Roo.classes_cache = classes;     
                }
                  
                        
index 1d8ea32..1c623cc 100644 (file)
@@ -162,13 +162,17 @@ public class Resources : Object
                string[] required =  {
                        "bootstrap.builder.html",
                        "bootstrap4.builder.html",
-                       "Gir.overides",
-                       "GtkUsage.txt",
+                        
                        "mailer.builder.html",
                        "roo.builder.html",
                        "roo.builder.js",
+                       
+                       
                        "roodata.json",
-                       "RooUsage.txt"
+                       
+                       //"RooUsage.txt" ?? not needed it's doen from roodata.
+                       "Gir.overides" //?? needed anymnore?
+                       
                };
 
                for (var i = 0; i <  required.length; i++ ) { 
@@ -259,7 +263,7 @@ public class Resources : Object
                                return;
                        }
                        
-                       
+                        
                        var tfn = BuilderApplication.configDirectory() + "/resources/" + item.target;
                        
                        
@@ -285,18 +289,10 @@ public class Resources : Object
                                        }
 
                                        break;
-                                       
-                               case "GtkUsage.txt":
-                               foreach(var p in Project.Project.allProjectsByName()) { 
-                                               if (p is Project.Gtk) {
-                                                       p.palete = new Palete.Gtk(p);
-                                                       //p.palete.load();
-                                               }
-                                       }
-
-                                       break;
+                                
                                        
                                case "roodata.json":
+                                       Palete.Roo.classes_cache = null; // clear the cache.
                                        foreach(var p in Project.Project.allProjectsByName()) { 
                                                if (p is Project.Roo) {
                                                        p.palete = new Palete.Roo(p);