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",
45 "Editors/Edit.Roo.grid.Grid.js"
52 public void fetchStart()
54 if (this.fetch_pos > 0) { // only fetch one at a time...
61 public void fetchNext()
63 var cur = this.fetch_pos;
65 this.updateProgress(this.fetch_pos); // min=0;
68 if (cur > this.avail_files.length) {
69 this.updateProgress(0);
74 var target = this.avail_files[cur];
75 var src = "http://git.roojs.org/?p=app.Builder.js;a=blob_plain;f=resources/" + target;
76 if (target == "roodata.json") {
77 src = "http://git.roojs.org/?p=roojs1;a=blob_plain;f=docs/json/roodata.json";
80 this.fetchResourceFrom (
86 Palete.Gir.factory("Gtk").loadOverrides(true);
90 Palete.factory("Gtk").load();
94 Palete.factory("Roo").classes = null;
95 Palete.factory("Roo").load();
110 public void checkResources()
112 bool needsload = false;
113 string[] res = this.avail_files;
115 for (var i = 0; i < res.length; i++ ) {
118 BuilderApplication.configDirectory() + "/resources/" + res[i],
134 public void fetchResourceFrom(string src, string target, Soup.SessionCallback? callback)
138 print("downloading %s \nto : %s\n", src,target);
139 var session = new Soup.Session ();
140 session.user_agent = "App Builder ";
141 var message = new Soup.Message ("GET", src );
142 session.queue_message (message, (sess, mess) => {
145 var tfn = BuilderApplication.configDirectory() + "/resources/" + target;
146 // create parent directory if needed
147 if (!GLibFileUtils.test (GLib.Path.get_dirname(tfn), FileTest.IS_DIR)) {
148 var f = new GLib.File.new_for_path(GLib.Path.get_dirname(tfn));
149 f.make_directory_with_parents ();
153 // set data??? - if it's binary?
154 FileUtils.set_contents( tfn, (string) message.response_body.data );