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