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