dbgenerate.js
[app.Builder.js] / Builder / DialogSaveTemplate.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 console = imports.console;
12 XObject = imports.XObject.XObject;
13 DialogSaveTemplate=new XObject({
14     xtype: Gtk.Dialog,
15     listeners : {
16         delete_event : function (self, event) {
17             this.el.hide();
18             return true;
19         },
20         response : function (self, response_id) {
21         
22             if (!response_id) {
23                 this.el.hide();
24                  return;
25             }
26             var name = this.get('name').el.get_text();
27             if (!name.length) {
28                 this.get('/StandardErrorDialog').show(
29                     "You must give the template a name. "
30                 );
31                 return;
32             }
33             
34            if (!name.match(/^[A-Z ]+$/i) || !name.match(/[A-Z]/i)) {
35                 this.get('/StandardErrorDialog').show(
36                     "Template Nane must contain only letters and spaces. "
37                 );
38                  return;
39             }
40             this.get('/Window.LeftTree').getPaleteProvider().saveTemplate(name, this.data);
41             // now we save it..
42                 this.el.hide();
43             
44         }
45     },
46     default_height : 200,
47     default_width : 400,
48     modal : true,
49     show : function(data) {
50         this.data = data;
51         this.get('name').el.set_text('');
52         this.el.show_all();
53     },
54     items : [
55         {
56             xtype: Gtk.HBox,
57             pack : function(p,e) {
58                                 p.el.get_content_area().add(e.el)
59                             },
60             items : [
61                 {
62                     xtype: Gtk.Label,
63                     label : "Name",
64                     pack : "add"
65                 },
66                 {
67                     xtype: Gtk.Entry,
68                     id : "name",
69                     pack : "add"
70                 }
71             ]
72         },
73         {
74             xtype: Gtk.Button,
75             label : "Cancel",
76             pack : "add_action_widget,0"
77         },
78         {
79             xtype: Gtk.Button,
80             label : "OK",
81             pack : "add_action_widget,1"
82         }
83     ]
84 });
85 DialogSaveTemplate.init();
86 XObject.cache['/DialogSaveTemplate'] = DialogSaveTemplate;