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