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