src/Builder4/WindowRooView.bjs
authorAlan Knowles <alan@roojs.com>
Wed, 3 Jun 2015 03:45:05 +0000 (11:45 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 3 Jun 2015 03:45:05 +0000 (11:45 +0800)
src/Builder4/WindowRooView.vala

src/Builder4/WindowRooView.bjs
src/Builder4/WindowRooView.vala

index 0a3ab57..df44c63 100644 (file)
@@ -12,7 +12,7 @@
    "id" : "WindowRooView",
    "# Gtk.Widget lastObj" : "null",
    "| void createThumb" : "() {\n    \n    \n    if (this.file == null) {\n        return;\n    }\n    var filename = this.file.getIconFileName(false);\n    \n    var  win = this.el.get_parent_window();\n    var width = win.get_width();\n  //  var height = win.get_height();\n    try { \n        Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, this.el.position);\n        screenshot.save(filename,\"png\");\n    } catch(Error e) {\n        //noop\n    }\n\n    \n     \n    \n     \n}\n",
-   "| void loadFile" : "(JsRender.JsRender file) \n{\n        this.file = null;\n        \n        if (file.tree == null) {\n            return;\n        }\n        this.notebook.el.page = 0;// gtk preview \n   \n  \n        \n       this.file = file;     \n        this.sourceview.loadFile();\n        this.searchcontext = null;\n        \n\n        if (this.lastObj != null) {\n            this.container.el.remove(this.lastObj);\n        }\n        \n        // hide the compile view at present..\n          \n        \n        var w = this.width;\n        var h = this.height;\n        \n        print(\"ALLOC SET SIZES %d, %d\\n\", w,h); \n        \n        // set the container size min to 500/500 or 20 px less than max..\n        w = int.max (w-20, 500);\n        h = int.max (h-20, 500); \n        \n        print(\"SET SIZES %d, %d\\n\", w,h);       \n        _this.container.el.set_size_request(w,h);\n        \n        _this.view_layout.el.set_size(w,h); // should be baded on calc.. -- see update_scrolled.\n        var rgba = Gdk.RGBA ();\n        rgba.parse (\"#ccc\");\n        _this.view_layout.el.override_background_color(Gtk.StateFlags.NORMAL, rgba);\n        \n        \n\tvar x = new JsRender.NodeToGtk(file.tree);\n        var obj = x.munge() as Gtk.Widget;\n        this.lastObj = null;\n\tif (obj == null) {\n        \treturn;\n\t}\n\tthis.lastObj = obj;\n        \n        this.container.el.add(obj);\n        obj.show_all();\n        \n         \n        \n}\n ",
+   "| void loadFile" : "\n(JsRender.JsRender file)\n{\n    this.file = file;\n    this.view.renderJS(true);\n    this.notebook.el.page = 0;// gtk preview \n    this.sourceview.loadFile();   \n    \n}\n \n ",
    "int width" : 0,
    "bool hexpand" : true,
    "| int search" : "(string txt) {\n\tthis.notebook.el.page = 1;\n \tvar s = new Gtk.SourceSearchSettings();\n\tvar buf = (Gtk.SourceBuffer) this.sourceview.el.get_buffer();\n\tthis.searchcontext = new Gtk.SourceSearchContext(buf,s);\n\tthis.searchcontext.set_highlight(true);\n\ts.set_search_text(txt);\n\t\n\tGtk.TextIter beg, st,en;\n\t \n\tbuf.get_start_iter(out beg);\n\tthis.searchcontext.forward(beg, out st, out en);\n\tthis.last_search_end  = 0;\n\treturn this.searchcontext.get_occurrences_count();\n\n   \n}\n",
index a9f4243..c46eed1 100644 (file)
@@ -97,60 +97,13 @@ public class Xcls_WindowRooView : Object
         
          
     }
-    public void loadFile (JsRender.JsRender file) 
+    public void loadFile (JsRender.JsRender file)
     {
-            this.file = null;
-            
-            if (file.tree == null) {
-                return;
-            }
-            this.notebook.el.page = 0;// gtk preview 
-       
-      
-            
-           this.file = file;     
-            this.sourceview.loadFile();
-            this.searchcontext = null;
-            
-    
-            if (this.lastObj != null) {
-                this.container.el.remove(this.lastObj);
-            }
-            
-            // hide the compile view at present..
-              
-            
-            var w = this.width;
-            var h = this.height;
-            
-            print("ALLOC SET SIZES %d, %d\n", w,h); 
-            
-            // set the container size min to 500/500 or 20 px less than max..
-            w = int.max (w-20, 500);
-            h = int.max (h-20, 500); 
-            
-            print("SET SIZES %d, %d\n", w,h);       
-            _this.container.el.set_size_request(w,h);
-            
-            _this.view_layout.el.set_size(w,h); // should be baded on calc.. -- see update_scrolled.
-            var rgba = Gdk.RGBA ();
-            rgba.parse ("#ccc");
-            _this.view_layout.el.override_background_color(Gtk.StateFlags.NORMAL, rgba);
-            
-            
-       var x = new JsRender.NodeToGtk(file.tree);
-            var obj = x.munge() as Gtk.Widget;
-            this.lastObj = null;
-       if (obj == null) {
-               return;
-       }
-       this.lastObj = obj;
-            
-            this.container.el.add(obj);
-            obj.show_all();
-            
-             
-            
+        this.file = file;
+        this.view.renderJS(true);
+        this.notebook.el.page = 0;// gtk preview 
+        this.sourceview.loadFile();   
+        
     }
     public int search (string txt) {
        this.notebook.el.page = 1;