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 page load
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 delegate void updateProgress(uint cur_pos);
22 static Resources singleton_val;
23 static Resources singleton()
25 if (singleton_val != null) {
26 singleton_val = new Resources();
34 public void fetchStart()
36 if (this.fetch_pos > 0) { // only fetch one at a time...
43 public void fetchNext()
45 var cur = this.fetch_pos;
47 this.updateProgress(this.fetch_pos); // min=0;
49 case 0: // html for rendering Bootstrap apps.
50 this.fetchResourceFrom (
51 "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/bootstrap.builder.html",
52 "bootstrap.builder.html",
58 this.fetchResourceFrom (
59 "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/roo.builder.html",
65 case 2: // generic javascript
66 this.fetchResourceFrom (
67 "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/roo.builder.js",
74 case 3: // Gir overrides - used to handle the fact we are not querying valadoc yet....and gir does
75 // not map that well to vala...
76 this.fetchResourceFrom (
77 "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/Gir.overides",
80 (new Palete.GirObject()).loadOverides(true);
86 case 4: // The main gtk tree rules
87 this.fetchResourceFrom (
88 "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/GtkUsage.txt",
91 Palete factory("Gtk").load();
95 case 5: // The main roo tree rules
96 this.fetchResourceFrom (
97 "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/RooUsage.txt",
100 // next step triggers the
104 case 6: // The docs / types for Roojs - it's already in roojs if checked out..??
105 // we might be better just checking if roojs is set up configured.
107 this.fetchResourceFrom (
108 "http://git.roojs.org/?p=roojs1;a=blob_plain;f=docs/json/roodata.json",
112 Palete factory("Roo").classes. = null;
113 Palete factory("Roo").load();
114 this.updateProgress(0);
130 public void fetchResourceFrom(string src, string target, Soup.SessionCallback? callback)
134 print("downloading %s \nto : %s\n", src,res);
135 var session = new Soup.Session ();
136 session.user_agent = "App Builder ";
137 var message = new Soup.Message ("GET", src );
138 session.queue_message (message, (sess, mess) => {
140 FileUtils.set_contents(
141 Application.configDirectory() + "/resources/" + res,
142 (string) message.response_body.data