Test.GtkWriter.vala.c
[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     listeners : {
15         delete_event : (self, event) => {
16             this.el.hide();
17              return true;
18         },
19         response : (self, response_id)  => {
20            //print(response_id);
21            if (response_id< 1 ) {
22               this.el.hide();
23             
24               return;
25            }
26            
27            var buf =    view.el.get_buffer();
28            Gtk.TextIter s;
29              Gtk.TextIter e;
30             buf.get_start_iter(out s);
31             buf.get_end_iter(out e);
32             var str = buf.get_text(s,e,true);
33             // ideally we should syntax check it.. but it's html!?
34             
35            //var project = this.get('/Window.LeftTree').getActiveFile().project;
36            
37            
38            _this.project.runhtml = str;
39            _this.project.save();
40            
41           // imports.Builder.Provider.ProjectManager.ProjectManager.saveConfig();
42         //   print (str);
43            //    this.get('view').el.get_buffer().get_text(project.runjs, project.runjs.length);
44            // ok pressed..
45            this.el.hide();
46         }
47     },
48     default_width : 500,
49     modal : true,
50     'void:show' : (Project.Project project) {
51         _this.project = project;
52         // get the active project.
53         
54         //print (project.fn);
55         //project.runhtml = project.runhtml || '';
56         _this.view.el.get_buffer().set_text(project.runhtml);
57         
58         this.el.show_all();
59     },
60     items : [
61         {
62             xtype: Gtk.VBox,
63             border_width : 5,
64             pack : get_content_area().add,
65             items : [
66                 {
67                     xtype: Gtk.Label,
68                     pack : "pack_start,false,false,0",
69                     label : "HTML To insert at end of <HEAD>"
70                 },
71                 {
72                     xtype: Gtk.ScrolledWindow,
73                     pack : "pack_end,true,true,0",
74                     items : [
75                         {
76                             xtype: GtkSource.View,
77                             pack : "add",
78                             id : "view"
79                         }
80                     ]
81                 }
82             ]
83         },
84         {
85             xtype: Gtk.Button,
86             pack : "add_action_widget,1",
87             label : "OK"
88         },
89         {
90             xtype: Gtk.Button,
91             pack : "add_action_widget,0",
92             label : "Cancel"
93         }
94     ]
95 });
96 RooProjectProperties.init();
97 XObject.cache['/RooProjectProperties'] = RooProjectProperties;