Builder/Provider/RooUsage.txt
[app.Builder.js] / Builder3 / RooProjectProperties.js
1 Gtk = imports.gi.Gtk;
2 Gdk = imports.gi.Gdk;
3 Pango = imports.gi.Pango;
4 GLib = imports.gi.GLib;
5 Gio = imports.gi.Gio;
6 GObject = imports.gi.GObject;
7 GtkSource = imports.gi.GtkSource;
8 WebKit = imports.gi.WebKit;
9 Vte = imports.gi.Vte;
10 //Gdl = imports.gi.Gdl;
11 console = imports.console;
12 XObject = imports.XObject.XObject;
13 RooProjectProperties=new XObject({
14     xtype: Gtk.Dialog,
15     modal : true,
16     show : function() {
17         // get the active project.
18         var file = this.get('/Window.LeftTree').getActiveFile();
19         if (!file) {
20             this.get('/StandardErrorDialog').show("No file is currently active");
21             return;
22         }
23         var project = this.get('/Window.LeftTree').getActiveFile().project;
24         //print (project.fn);
25         project.runhtml = project.runhtml || '';
26         this.get('view').el.get_buffer().set_text(project.runhtml, project.runhtml.length);
27         
28         this.el.show_all();
29     },
30     default_width : 500,
31     listeners : {
32         delete_event : function (self, event) {
33             this.el.hide()
34             return true;
35         },
36         response : function (self, response_id) {
37            print(response_id);
38            if (!response_id) {
39               this.el.hide();
40             
41               return;
42            }
43            var buf =    this.get('view').el.get_buffer()
44            
45             var e = {};
46             var s = {};                             
47             buf.get_start_iter(s);
48             buf.get_end_iter(e);
49             
50             var str = buf.get_text(s.iter,e.iter,false);
51             print(str);
52             // ideally we should syntax check it.. but it's html!?
53             
54            var project = this.get('/Window.LeftTree').getActiveFile().project;
55            
56            
57            project.runhtml = str;
58            
59            imports.Builder.Provider.ProjectManager.ProjectManager.saveConfig();
60         //   print (str);
61            //    this.get('view').el.get_buffer().get_text(project.runjs, project.runjs.length);
62            // ok pressed..
63            this.el.hide();
64         }
65     },
66     items : [
67         {
68             xtype: Gtk.VBox,
69             pack : function(p,e) {
70                         p.el.get_content_area().add(e.el);
71                         e.border_width  =5;
72                     },
73             items : [
74                 {
75                     xtype: Gtk.Label,
76                     pack : "pack_start,false,false,0",
77                     label : "HTML To insert at end of <HEAD>"
78                 },
79                 {
80                     xtype: Gtk.ScrolledWindow,
81                     pack : "pack_end,true,true,0",
82                     items : [
83                         {
84                             xtype: GtkSource.View,
85                             pack : "add",
86                             id : "view"
87                         }
88                     ]
89                 }
90             ]
91         },
92         {
93             xtype: Gtk.Button,
94             pack : "add_action_widget,1",
95             label : "OK"
96         },
97         {
98             xtype: Gtk.Button,
99             pack : "add_action_widget,0",
100             label : "Cancel"
101         }
102     ]
103 });
104 RooProjectProperties.init();
105 XObject.cache['/RooProjectProperties'] = RooProjectProperties;