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 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",
70 // should trigger a redraw on a the webkit if it's live...
75 case 3: // Gir overrides - used to handle the fact we are not querying valadoc yet....and gir does
76 // not map that well to vala...
77 this.fetchResourceFrom (
78 "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/Gir.overides",
81 (new Palete.GirObject()).loadOverides(true);
87 case 4: // The main gtk tree rules
88 this.fetchResourceFrom (
89 "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/GtkUsage.txt",
92 Palete factory("Gtk").load();
96 case 5: // The main roo tree rules
97 this.fetchResourceFrom (
98 "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/RooUsage.txt",
101 // next step triggers the
105 case 6: // The docs / types for Roojs - it's already in roojs if checked out..??
106 // we might be better just checking if roojs is set up configured.
108 this.fetchResourceFrom (
109 "http://git.roojs.org/?p=roojs1;a=blob_plain;f=docs/json/roodata.json",
113 Palete factory("Roo").classes. = null;
114 Palete factory("Roo").load();
115 this.updateProgress(0);
131 public void fetchResourceFrom(string src, string target, Soup.SessionCallback? callback)
135 print("downloading %s \nto : %s\n", src,res);
136 var session = new Soup.Session ();
137 session.user_agent = "App Builder ";
138 var message = new Soup.Message ("GET", src );
139 session.queue_message (message, (sess, mess) => {
141 FileUtils.set_contents(
142 Application.configDirectory() + "/resources/" + res,
143 (string) message.response_body.data