4 * Idea is to manage resourse used by the app.
6 * The original code downloaded all the resources before it renders the main window
8 * This is a bit annoying as although they do change quite a bit, it's not on every app start
10 * So the Resource fetching behaviour should be a button on the File view page
11 * That starts the refresh of the resources.
13 * I'm not quite sure how we should flow this - if we do them all at once.. might be a bit of a server
14 * overload... so sequentially may be best...
17 public class Resources : Object
20 public signal void updateProgress(uint cur_pos);
22 static Resources singleton_val;
26 public static Resources singleton()
28 if (singleton_val == null) {
29 singleton_val = new Resources();
39 "bootstrap.builder.html",
51 public void fetchStart()
53 if (this.fetch_pos > 0) { // only fetch one at a time...
60 public void fetchNext()
62 var cur = this.fetch_pos;
64 this.updateProgress(this.fetch_pos); // min=0;
67 if (cur > this.avail_files.length) {
68 this.updateProgress(0);
73 var target = this.avail_files[cur];
74 var src = "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/" + target;
75 if (target == "roodata.json") {
76 src = "http://git.roojs.org/?p=roojs1;a=blob_plain;f=docs/json/roodata.json";
79 this.fetchResourceFrom (
85 Palete.Gir.factory("Gtk").loadOverrides(true);
89 Palete.factory("Gtk").load();
93 Palete.factory("Roo").classes = null;
94 Palete.factory("Roo").load();
104 case 0: // html for rendering Bootstrap apps.
105 this.fetchResourceFrom (
106 "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/bootstrap.builder.html",
107 "bootstrap.builder.html",
112 case 1:// html for rendering Roo apps.
113 this.fetchResourceFrom (
114 "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/roo.builder.html",
120 case 2: // generic javascript
121 this.fetchResourceFrom (
122 "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/roo.builder.js",
125 // should trigger a redraw on a the webkit if it's live...
130 case 3: // Gir overrides - used to handle the fact we are not querying valadoc yet....and gir does
131 // not map that well to vala...
132 this.fetchResourceFrom (
133 "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/Gir.overides",
136 Palete.Gir.factory("Gtk").loadOverrides(true);
142 case 4: // The main gtk tree rules
143 this.fetchResourceFrom (
144 "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/GtkUsage.txt",
147 Palete.factory("Gtk").load();
151 case 5: // The main roo tree rules
152 this.fetchResourceFrom (
153 "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/RooUsage.txt",
156 // next step triggers the
160 case 6: // The docs / types for Roojs - it's already in roojs if checked out..??
161 // we might be better just checking if roojs is set up configured.
163 this.fetchResourceFrom (
164 "http://git.roojs.org/?p=roojs1;a=blob_plain;f=docs/json/roodata.json",
168 Palete.factory("Roo").classes = null;
169 Palete.factory("Roo").load();
170 this.updateProgress(0);
182 public void checkResources()
184 bool needsload = false;
186 "bootstrap.builder.html",
194 for (var i = 0; i < res.length; i++ ) {
197 BuilderApplication.configDirectory() + "/resources/" + res[i],
213 public void fetchResourceFrom(string src, string target, Soup.SessionCallback? callback)
217 print("downloading %s \nto : %s\n", src,target);
218 var session = new Soup.Session ();
219 session.user_agent = "App Builder ";
220 var message = new Soup.Message ("GET", src );
221 session.queue_message (message, (sess, mess) => {
223 FileUtils.set_contents(
224 BuilderApplication.configDirectory() + "/resources/" + target,
225 (string) message.response_body.data