dbgenerate.js
[app.Builder.js] / Builder / 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 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            var s = new Gtk.TextIter();
45             var e = new Gtk.TextIter();
46             buf.get_start_iter(s);
47             buf.get_end_iter(e);
48             var str = buf.get_text(s,e,true);
49             // ideally we should syntax check it.. but it's html!?
50             
51            var project = this.get('/Window.LeftTree').getActiveFile().project;
52            
53            
54            project.runhtml = str;
55            
56            imports.Builder.Provider.ProjectManager.ProjectManager.saveConfig();
57         //   print (str);
58            //    this.get('view').el.get_buffer().get_text(project.runjs, project.runjs.length);
59            // ok pressed..
60            this.el.hide();
61         }
62     },
63     items : [
64         {
65             xtype: Gtk.VBox,
66             pack : function(p,e) {
67                         p.el.get_content_area().add(e.el);
68                         e.border_width  =5;
69                     },
70             items : [
71                 {
72                     xtype: Gtk.Label,
73                     pack : "pack_start,false,false,0",
74                     label : "HTML To insert at end of <HEAD>"
75                 },
76                 {
77                     xtype: Gtk.ScrolledWindow,
78                     pack : "pack_end,true,true,0",
79                     items : [
80                         {
81                             xtype: GtkSource.View,
82                             pack : "add",
83                             id : "view"
84                         }
85                     ]
86                 }
87             ]
88         },
89         {
90             xtype: Gtk.Button,
91             pack : "add_action_widget,1",
92             label : "OK"
93         },
94         {
95             xtype: Gtk.Button,
96             pack : "add_action_widget,0",
97             label : "Cancel"
98         }
99     ]
100 });
101 RooProjectProperties.init();
102 XObject.cache['/RooProjectProperties'] = RooProjectProperties;