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