src/Builder4/DialogSaveModule.bjs
[app.Builder.js] / src / Builder4 / DialogPluginWebkit.vala
1 static Xcls_DialogPluginWebkit  _DialogPluginWebkit;
2
3 public class Xcls_DialogPluginWebkit : Object 
4 {
5     public Gtk.Dialog el;
6     private Xcls_DialogPluginWebkit  _this;
7
8     public static Xcls_DialogPluginWebkit singleton()
9     {
10         if (_DialogPluginWebkit == null) {
11             _DialogPluginWebkit= new Xcls_DialogPluginWebkit();
12         }
13         return _DialogPluginWebkit;
14     }
15     public Xcls_patchview patchview;
16
17         // my vars (def)
18
19     // ctor 
20     public Xcls_DialogPluginWebkit()
21     {
22         _this = this;
23         this.el = new Gtk.Dialog();
24
25         // my vars (dec)
26
27         // set gobject values
28         this.el.title = "Add / Edit Component";
29         this.el.default_height = 500;
30         this.el.default_width = 500;
31         this.el.deletable = true;
32         this.el.modal = true;
33         var child_0 = new Xcls_VBox2( _this );
34         child_0.ref();
35         this.el.get_content_area().add (  child_0.el  );
36         var child_1 = new Xcls_Button5( _this );
37         child_1.ref();
38         this.el.add_action_widget (  child_1.el , 0 );
39         var child_2 = new Xcls_Button6( _this );
40         child_2.ref();
41         this.el.add_action_widget (  child_2.el , 1 );
42
43         // listeners 
44         this.el.delete_event.connect( (self, event) => {
45             this.el.hide();
46             return true; 
47             //test  
48         });
49     }
50
51     // user defined functions 
52     public string show (Gtk.Window parent, JsRender.Node node) {
53      
54          
55         this.el.set_transient_for(parent);
56         this.el.modal = true;
57         
58         
59         
60         this.el.show_all();
61          var   ret = "";
62         while (true) {
63             var response_id = this.el.run();
64             if (response_id < 1) {
65                 this.el.hide();
66                  return "";
67             }
68             
69             name = _this.name.el.get_text();
70             if (name.length < 1) {
71                 StandardErrorDialog.singleton().show(
72                      _this.el,
73                     "You must give the template a name. "
74                 );
75                 continue;
76             }
77             if (!Regex.match_simple ("^[A-Za-z][A-Za-z0-9.]+$", name) )
78             {
79                 StandardErrorDialog.singleton().show(
80                      _this.el,
81                     "Template Name must contain only letters dots"
82                 );
83                 continue;
84             }
85             break;
86         }
87         var f = project.newFile(name);
88         f.tree =  _this.data.deepClone();
89         f.save();
90         
91         // now we save it..
92         this.el.hide();
93         
94         return name;
95         
96         
97         
98     }
99     public class Xcls_VBox2 : Object 
100     {
101         public Gtk.VBox el;
102         private Xcls_DialogPluginWebkit  _this;
103
104
105             // my vars (def)
106
107         // ctor 
108         public Xcls_VBox2(Xcls_DialogPluginWebkit _owner )
109         {
110             _this = _owner;
111             this.el = new Gtk.VBox( true, 0 );
112
113             // my vars (dec)
114
115             // set gobject values
116             var child_0 = new Xcls_ScrolledWindow3( _this );
117             child_0.ref();
118             this.el.pack_end (  child_0.el , true,true,0 );
119         }
120
121         // user defined functions 
122     }
123     public class Xcls_ScrolledWindow3 : Object 
124     {
125         public Gtk.ScrolledWindow el;
126         private Xcls_DialogPluginWebkit  _this;
127
128
129             // my vars (def)
130
131         // ctor 
132         public Xcls_ScrolledWindow3(Xcls_DialogPluginWebkit _owner )
133         {
134             _this = _owner;
135             this.el = new Gtk.ScrolledWindow( null, null );
136
137             // my vars (dec)
138
139             // set gobject values
140             var child_0 = new Xcls_patchview( _this );
141             child_0.ref();
142             this.el.add (  child_0.el  );
143
144             // init method 
145
146             this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
147         }
148
149         // user defined functions 
150     }
151     public class Xcls_patchview : Object 
152     {
153         public WebKit.WebView el;
154         private Xcls_DialogPluginWebkit  _this;
155
156
157             // my vars (def)
158
159         // ctor 
160         public Xcls_patchview(Xcls_DialogPluginWebkit _owner )
161         {
162             _this = _owner;
163             _this.patchview = this;
164             this.el = new WebKit.WebView();
165
166             // my vars (dec)
167
168             // set gobject values
169
170             // init method 
171
172             {
173                 // this may not work!?
174                 var settings =  this.el.get_settings();
175                 
176                  
177                 //var fs= new FakeServer(this.el);
178                 //fs.ref();
179                 // this was an attempt to change the url perms.. did not work..
180                 // settings.enable_file_access_from_file_uris = true;
181                 // settings.enable_offline_web_application_cache - true;
182                 // settings.enable_universal_access_from_file_uris = true;
183                
184                  
185                 
186                 
187                 
188             
189                  // FIXME - base url of script..
190                  // we need it so some of the database features work.
191                 this.el.load_html( "Render not ready" , 
192                         //fixme - should be a config option!
193                         // or should we catch stuff and fix it up..
194                         "xhttp://localhost/app.Builder/"
195                 );
196                     
197                     
198                 
199                 
200             }
201         }
202
203         // user defined functions 
204     }
205     public class Xcls_Button5 : Object 
206     {
207         public Gtk.Button el;
208         private Xcls_DialogPluginWebkit  _this;
209
210
211             // my vars (def)
212
213         // ctor 
214         public Xcls_Button5(Xcls_DialogPluginWebkit _owner )
215         {
216             _this = _owner;
217             this.el = new Gtk.Button();
218
219             // my vars (dec)
220
221             // set gobject values
222             this.el.label = "Cancel";
223         }
224
225         // user defined functions 
226     }
227     public class Xcls_Button6 : Object 
228     {
229         public Gtk.Button el;
230         private Xcls_DialogPluginWebkit  _this;
231
232
233             // my vars (def)
234
235         // ctor 
236         public Xcls_Button6(Xcls_DialogPluginWebkit _owner )
237         {
238             _this = _owner;
239             this.el = new Gtk.Button();
240
241             // my vars (dec)
242
243             // set gobject values
244             this.el.label = "OK";
245         }
246
247         // user defined functions 
248     }
249 }