Builder/Provider/Palete/Gtk.js
authorAlan Knowles <alan@akbkhome.com>
Mon, 10 May 2010 10:58:21 +0000 (18:58 +0800)
committerAlan Knowles <alan@akbkhome.com>
Mon, 10 May 2010 10:58:21 +0000 (18:58 +0800)
Builder/Provider/Palete/Gtk.js

index e69de29..e6b62cc 100644 (file)
@@ -0,0 +1,128 @@
+//<Script type="text/javascript">
+Gio = imports.gi.Gio;
+
+console = imports.console;
+XObject = imports.XObject.XObject;
+
+Base = imports.Builder.Provider.Palete.Base.Base;
+
+//----------------------- our roo verison
+
+
+
+Gtk = XObject.define(
+    function(cfg) {
+        
+       
+        // various loader methods..
+        
+        this.map = [];
+        // no parent...
+        
+       
+    },
+    Base,
+    {
+    
+     
+        load: function ( o ) {
+           //  Seed.print(__script_path__ +'/RooUsage.txt');
+             var file = Gio.file_new_for_path(__script_path__ +'/../GtkUsage.txt');
+                                        
+            var _this = this;                        
+             
+                                        
+            file.read_async(0, null, function(source,result) {
+                var stream = source.read_finish(result)
+                var dstream = new Gio.DataInputStream.c_new(stream);
+              
+                var data =  dstream.read_until("")
+                data  = data.split(/\n/g);
+                var state = 0;
+                var cfg = [];
+                var left = [];
+                var right = [];
+                
+                data.forEach( function(d) {
+                    if (!d.length || d.match(/^\s+$/) || d.match(/^\//)) { //empty
+                        return;
+                    }
+                    if (d.match(/^left:/)) { 
+                        state = 1;
+                        if (left.length ){
+                            
+                            cfg.push({
+                                left : left,
+                                right: right
+                            });
+                            }
+                        left = [];
+                        right = [];
+                        return;
+                    }
+                    if (d.match(/^right:/)) { 
+                        state = 2;
+                        return;
+                    }
+                    if (state == 1) {
+                        left.push(d.replace(/\s+/g, ''));
+                        return;
+                    }
+                    right.push(d.replace(/\s+/g, ''));
+                    //Seed.quit();
+                   
+                }); 
+                if (left.length ){
+                            
+                    cfg.push({
+                        left : left,
+                        right: right
+                    });
+                }
+                _this.map = cfg;
+                if (o && o.success) o.success.apply(o.scope || _this, [_this]);
+                //console.dump(cfg);
+            });
+        }
+        
+         
+        
+        
+    }
+);
+
+    // static load @ starttime.
+XObject.extend(Roo, {
+        proplist:  [],
+         
+        load : function()
+        {
+             
+            return;
+            if (this.proplist) {
+                return;
+            }
+            
+            var file = Gio.file_new_for_path(__script_path__ +'/../rooprops.json');
+            var _this = this;
+            file.read_async(0, null, function(source,result) {
+                var stream = source.read_finish(result)
+                var dstream = new Gio.DataInputStream.c_new(stream);
+                var data =  dstream.read_until("");       
+                _this.proplist = JSON.parse(data).data;
+
+            });
+        },
+        guessName : function(ar)
+        {
+            
+           
+                                
+                                 
+        }
+        
+    }
+);
+
+Gtk.load();