4 * this is the code represents a File when using the Gtk view..
18 public class PlainFile : JsRender
22 public PlainFile(Project.Project project, string path) {
25 this.xtype = "PlainFile";
26 this.content_type = "text/plain";
28 // if the file does not exist...
29 if (GLib.FileUtils.test(path, GLib.FileTest.EXISTS)) {
30 var f = File.new_for_path (path) ;
32 var info = f.query_info ("standard::*", 0);
33 var ct = info.get_content_type();
34 this.content_type = ct;
35 } catch (GLib.Error e) {}
38 this.content_type = "text/plain"; // hopefully..
39 // var ar = path.split(".");
40 // var ext = ar[ar.length -1]; // hopefully not fail...
57 this.id = "file-plain-%d".printf(plid++);
59 // various loader methods..
61 // Class = list of arguments ... and which property to use as a value.
70 setNSID : function(id)
73 this.items[0]['*class'] = id;
82 public override void removeFiles() {
83 if (FileUtils.test(this.path, FileTest.EXISTS)) {
84 GLib.FileUtils.remove(this.path);
89 public override void loadItems() throws GLib.Error // : function(cb, sync) == original was async.
94 GLib.FileUtils.get_contents(this.path, out this.contents);
100 public override string toSourcePreview()
104 public override void setSource(string str) {
107 public override string toSource()
109 return this.contents;
114 public override string toSourceCode()
116 return this.contents;
121 public override void save() {
123 print("Ignoring Save - as file was never loaded?\n");
127 this.writeFile(this.path, this.contents);
128 } catch (GLib.Error e) {
133 // ignore these calls.
134 public override void saveHTML ( string html ) {}
140 * save as a javascript file.
141 * why is this not save...???
147 public override void findTransStrings(Node? node )
152 public override string toGlade()
154 return "Roo files do not convert to glade";
156 public override string targetName()
162 public override string language_id()
164 switch(this.file_ext) {
165 case "js": return "javascript";
166 case "vala": return "vala";
167 case "php": return "php";
168 case "css": return "css";
169 case "sql": return "sql";
170 default: return "???";