Palete/Gtk.js
[app.Builder.js] / Builder4 / 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         this.get('dbcon').el.set_text(project.dbcon || '');
27         print("project db: " + project.dbcon);
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            
45             var e = {};
46             var s = {};                             
47             buf.get_start_iter(s);
48             buf.get_end_iter(e);
49             
50             var str = buf.get_text(s.iter,e.iter,false);
51             //print(str);
52             // ideally we should syntax check it.. but it's html!?
53             
54            var project = this.get('/Window.LeftTree').getActiveFile().project;
55            
56            
57            project.runhtml = str;
58            
59            project.dbcon = this.get('dbcon').el.get_text();
60            
61            
62            imports.ProjectManager.ProjectManager.saveConfig();
63         //   print (str);
64            //    this.get('view').el.get_buffer().get_text(project.runjs, project.runjs.length);
65            // ok pressed..
66            this.el.hide();
67         }
68     },
69     items : [
70         {
71             xtype: Gtk.VBox,
72             pack : function(p,e) {
73                         p.el.get_content_area().add(e.el);
74                         e.border_width  =5;
75                     },
76             items : [
77                 {
78                     xtype: Gtk.HBox,
79                     pack : "pack_start,false,true,3",
80                     items : [
81                                 
82                         
83                        {
84                            xtype: Gtk.Label,
85                            pack : "pack_start,false,false,0",
86                            label : "Database Name"
87                        },
88                        {
89                             xtype: Gtk.Entry,
90                             id : "dbcon",
91                             pack : "add",
92                             visible : true
93                         },
94                     ]
95                 },
96         
97                {
98                    xtype: Gtk.Label,
99                    pack : "pack_start,false,false,0",
100                    label : "HTML To insert at end of <HEAD>"
101                },
102                {
103                    xtype: Gtk.ScrolledWindow,
104                    pack : "pack_end,true,true,0",
105                    items : [
106                        {
107                            xtype: GtkSource.View,
108                            pack : "add",
109                            id : "view"
110                        }
111                    ]
112                }
113                  
114                 
115                 
116                 
117                 
118             ]
119         },
120         
121         
122        
123         
124         {
125             xtype: Gtk.Button,
126             pack : "add_action_widget,1",
127             label : "OK"
128         },
129         {
130             xtype: Gtk.Button,
131             pack : "add_action_widget,0",
132             label : "Cancel"
133         }
134     ]
135 });
136 RooProjectProperties.init();
137 XObject.cache['/RooProjectProperties'] = RooProjectProperties;