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