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