resources/RooUsage.txt
[app.Builder.js] / src / Builder4 / GladeView.vala
1 static Xcls_GladeView  _GladeView;
2
3 public class Xcls_GladeView : Object 
4 {
5     public Glade.DesignView el;
6     private Xcls_GladeView  _this;
7
8     public static Xcls_GladeView singleton()
9     {
10         if (_GladeView == null) {
11             _GladeView= new Xcls_GladeView();
12         }
13         return _GladeView;
14     }
15
16         // my vars (def)
17     public JsRender.JsRender file;
18
19     // ctor 
20     public Xcls_GladeView()
21     {
22         _this = this;
23         this.el = new Glade.DesignView(new Glade.Project());
24
25         // my vars (dec)
26         this.file = null;
27
28         // set gobject values
29     }
30
31     // user defined functions 
32     public void createThumb () {
33         
34         
35         if (this.file == null) {
36             return;
37         }
38         var filename = this.file.getIconFileName(false);
39         
40         var  win = this.el.get_parent_window();
41         var width = win.get_width();
42         var height = win.get_height();
43     
44         Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position?
45     
46         screenshot.save(filename,"png");
47         return;
48         
49         
50         
51         
52         
53          
54         
55         // should we hold until it's printed...
56         
57           
58     
59         
60         
61     
62     
63         
64          
65     }
66     public void loadFile (JsRender.JsRender file)
67     {
68         
69     
70         this.file = file;
71         
72     
73             // clear existing elements from project?
74             
75             var  p = this.el.get_project();
76             var    li = p.get_objects().copy();
77             // should remove all..
78             for (var i =0;    i < li.length(); i++) {   
79                 p.remove_object(li.nth_data(i)); 
80             }
81     
82             if (file.tree == null) {
83                 return;
84             }
85     
86     //        print("%s\n",tf.tree.toJsonString());
87         var x = new JsRender.NodeToGlade(file.tree,  "");
88     
89          
90         FileIOStream iostream;
91         var  f = File.new_tmp ("tpl-XXXXXX.glade", out iostream);
92         var ostream = iostream.output_stream;
93         var dostream = new DataOutputStream (ostream);
94         dostream.put_string (x.munge());
95         this.el.show();
96          print("LOADING %s\n",f.get_path ());
97             p.load_from_file(f.get_path ());
98             
99      
100     
101     }
102 }