resources/RooUsage.txt
[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             // if the file does not exist...
28             if (GLib.FileUtils.test(path, GLib.FileTest.EXISTS)) {
29                         var f = File.new_for_path (path) ;
30                         var info = f.query_info ("standard::*", 0);
31                         var ct = info.get_content_type();
32                     this.content_type = ct;
33             } else {
34                         this.content_type = "text/plain"; // hopefully..
35 //                      var ar = path.split(".");
36   //                    var ext = ar[ar.length -1]; // hopefully not fail...
37                         
38   //                    switch(ext) { 
39         //                      case "vala";
40                         this.loaded = true;
41                         
42             
43             }
44        
45             this.language = "";
46              
47             // fixme...
48
49             
50             this.contents = "";
51             
52             // super?!?!
53             this.id = "file-plain-%d".printf(plid++);
54             //console.dump(this);
55             // various loader methods..
56
57             // Class = list of arguments ... and which property to use as a value.
58        
59
60             
61             
62         }
63           
64
65         /*
66         setNSID : function(id)
67         {
68             
69             this.items[0]['*class'] = id;
70             
71             
72         },
73         getType: function() {
74             return 'Gtk';
75         },
76         */
77
78         public   override void   removeFiles() {
79                 if (FileUtils.test(this.path, FileTest.EXISTS)) {
80                         GLib.FileUtils.remove(this.path);
81                 }
82                  
83         }
84     
85         public   override void  loadItems() throws GLib.Error // : function(cb, sync) == original was async.
86         {
87                         if (this.loaded) {
88                                 return;
89                         }
90                 GLib.FileUtils.get_contents(this.path, out this.contents);
91                 this.loaded = true;
92         }
93      
94         
95                 
96         public override string toSourcePreview()
97         {
98                          return "";
99                 }
100                 public override void setSource(string str) {
101                         this.contents = str;
102                 }
103         public override string toSource()
104         {
105                         return this.contents;
106             
107              
108             
109         }
110                  public override string toSourceCode()
111         {
112                         return this.contents;
113             
114              
115             
116         }
117         public override void save() {
118                 if (!this.loaded) {
119                         print("Ignoring Save  - as file was never loaded?\n");
120                         return;
121                 }
122                 try { 
123                     this.writeFile(this.path, this.contents);
124             } catch (GLib.Error e) {
125                     // error ???
126                 }
127             
128         }
129             // ignore these calls.
130         public override void saveHTML ( string html ) {}
131             
132                     
133         /** 
134          *  saveJS
135          * 
136          * save as a javascript file.
137          * why is this not save...???
138          * 
139          */ 
140          
141    
142         string getHelpUrl(string cls)
143         {
144             return ""; 
145         }
146         public override void  findTransStrings(Node? node )
147                 {
148                         // not yet..
149                 }
150         
151         
152           
153
154                 
155
156         }
157 }
158
159
160