src/JsRender/PlainFile.vala
[app.Builder.js] / src / JsRender / PlainFile.vala
1
2 /**
3  * 
4  *  this is the code represents a File when using the Gtk view..
5  *   
6  *  It ues NodeToGtk
7  * 
8  * 
9  */
10
11 namespace JsRender {
12
13
14  
15     int plid = 1;
16
17   
18     public  class PlainFile : JsRender
19     {
20                 string contents;
21
22         public PlainFile(Project.Project project, string path) {
23         
24             base( project, path);
25             this.xtype = "PlainFile";
26             
27             var f = File.new_for_path (path) ;
28             var info = f.query_info ("standard::*", 0);
29             var ct = info.get_content_type();
30             this.content_type = ct;
31        
32             this.language = "";
33              
34             // fixme...
35
36             
37             this.contents = "";
38             
39             // super?!?!
40             this.id = "file-plain-%d".printf(plid++);
41             //console.dump(this);
42             // various loader methods..
43
44             // Class = list of arguments ... and which property to use as a value.
45        
46
47             
48             
49         }
50           
51
52         /*
53         setNSID : function(id)
54         {
55             
56             this.items[0]['*class'] = id;
57             
58             
59         },
60         getType: function() {
61             return 'Gtk';
62         },
63         */
64
65         public   override void   removeFiles() {
66                 if (FileUtils.test(this.path, FileTest.EXISTS)) {
67                         GLib.FileUtils.remove(this.path);
68                 }
69                  
70         }
71     
72         public   override void  loadItems() throws GLib.Error // : function(cb, sync) == original was async.
73         {
74            
75                GLib.FileUtils.get_contents(this.path, out this.contents);
76                this.loaded = true;
77         }
78      
79         
80                 
81         public override string toSourcePreview()
82         {
83                          return "";
84                 }
85                 public override void setSource(string str) {
86                         this.contents = str;
87                 }
88         public override string toSource()
89         {
90                         return this.contents;
91             
92              
93             
94         }
95                 
96         public override void save() {
97                 if (!this.loaded) {
98                         return;
99                 }
100             this.writeFile(this.path, this.contents);
101             
102         }
103             // ignore these calls.
104         public override void saveHTML ( string html ) {}
105             
106                     
107         /** 
108          *  saveJS
109          * 
110          * save as a javascript file.
111          * why is this not save...???
112          * 
113          */ 
114          
115    
116         string getHelpUrl(string cls)
117         {
118             return ""; 
119         }
120         public override void  findTransStrings(Node? node )
121                 {
122                         // not yet..
123                 }
124         
125         
126           
127
128                 
129
130         }
131 }
132
133
134