Sample/RooProjectProperties.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 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         //   print (str);
55            //    this.get('view').el.get_buffer().get_text(project.runjs, project.runjs.length);
56            // ok pressed..
57            this.el.hide();
58         }
59     },
60     items : [
61         {
62             xtype: Gtk.VBox,
63             pack : function(p,e) {
64                         p.el.get_content_area().add(e.el);
65                         e.border_width  =5;
66                     },
67             items : [
68                 {
69                     xtype: Gtk.Label,
70                     pack : "pack_start,false,false,0",
71                     label : "HTML To insert at end of <HEAD>"
72                 },
73                 {
74                     xtype: Gtk.ScrolledWindow,
75                     pack : "pack_end,true,true,0",
76                     items : [
77                         {
78                             xtype: GtkSource.View,
79                             pack : "add",
80                             id : "view"
81                         }
82                     ]
83                 }
84             ]
85         },
86         {
87             xtype: Gtk.Button,
88             pack : "add_action_widget,1",
89             label : "OK"
90         },
91         {
92             xtype: Gtk.Button,
93             pack : "add_action_widget,0",
94             label : "Cancel"
95         }
96     ]
97 });
98 RooProjectProperties.init();
99 XObject.cache['/RooProjectProperties'] = RooProjectProperties;