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