src/Builder4/DialogPluginWebkit.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_webview webview;
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, string text) {// JsRender.Node node) {
53      
54         if (parent  != null) {
55             this.el.set_transient_for(parent);
56             this.el.modal = true;
57         }
58         
59         
60         
61         this.el.show_all();
62          var   ret = "";
63         while (true) {
64             var response_id = this.el.run();
65             if (response_id < 1) {
66                 this.el.hide();
67                  return "";
68             }
69             // keep showing...?
70             break;
71         }
72         
73         // now we save it..
74         this.el.hide();
75         
76         return ret;
77         
78         
79         
80     }
81     public class Xcls_VBox2 : Object 
82     {
83         public Gtk.VBox el;
84         private Xcls_DialogPluginWebkit  _this;
85
86
87             // my vars (def)
88
89         // ctor 
90         public Xcls_VBox2(Xcls_DialogPluginWebkit _owner )
91         {
92             _this = _owner;
93             this.el = new Gtk.VBox( true, 0 );
94
95             // my vars (dec)
96
97             // set gobject values
98             var child_0 = new Xcls_ScrolledWindow3( _this );
99             child_0.ref();
100             this.el.pack_end (  child_0.el , true,true,0 );
101         }
102
103         // user defined functions 
104     }
105     public class Xcls_ScrolledWindow3 : Object 
106     {
107         public Gtk.ScrolledWindow el;
108         private Xcls_DialogPluginWebkit  _this;
109
110
111             // my vars (def)
112
113         // ctor 
114         public Xcls_ScrolledWindow3(Xcls_DialogPluginWebkit _owner )
115         {
116             _this = _owner;
117             this.el = new Gtk.ScrolledWindow( null, null );
118
119             // my vars (dec)
120
121             // set gobject values
122             var child_0 = new Xcls_webview( _this );
123             child_0.ref();
124             this.el.add (  child_0.el  );
125
126             // init method 
127
128             this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
129         }
130
131         // user defined functions 
132     }
133     public class Xcls_webview : Object 
134     {
135         public WebKit.WebView el;
136         private Xcls_DialogPluginWebkit  _this;
137
138
139             // my vars (def)
140
141         // ctor 
142         public Xcls_webview(Xcls_DialogPluginWebkit _owner )
143         {
144             _this = _owner;
145             _this.webview = this;
146             this.el = new WebKit.WebView();
147
148             // my vars (dec)
149
150             // set gobject values
151
152             // init method 
153
154             {
155                 // this may not work!?
156                 var settings =  this.el.get_settings();
157                 
158                  
159                 //var fs= new FakeServer(this.el);
160                 //fs.ref();
161                 // this was an attempt to change the url perms.. did not work..
162                 // settings.enable_file_access_from_file_uris = true;
163                 // settings.enable_offline_web_application_cache - true;
164                 // settings.enable_universal_access_from_file_uris = true;
165                
166                  
167                 
168                 
169                 
170             
171                  // FIXME - base url of script..
172                  // we need it so some of the database features work.
173                 this.el.load_html( "Render not ready" , 
174                         //fixme - should be a config option!
175                         // or should we catch stuff and fix it up..
176                         "xhttp://localhost/app.Builder/"
177                 );
178                     
179                     
180                 
181                 
182             }
183         }
184
185         // user defined functions 
186     }
187     public class Xcls_Button5 : Object 
188     {
189         public Gtk.Button el;
190         private Xcls_DialogPluginWebkit  _this;
191
192
193             // my vars (def)
194
195         // ctor 
196         public Xcls_Button5(Xcls_DialogPluginWebkit _owner )
197         {
198             _this = _owner;
199             this.el = new Gtk.Button();
200
201             // my vars (dec)
202
203             // set gobject values
204             this.el.label = "Cancel";
205         }
206
207         // user defined functions 
208     }
209     public class Xcls_Button6 : Object 
210     {
211         public Gtk.Button el;
212         private Xcls_DialogPluginWebkit  _this;
213
214
215             // my vars (def)
216
217         // ctor 
218         public Xcls_Button6(Xcls_DialogPluginWebkit _owner )
219         {
220             _this = _owner;
221             this.el = new Gtk.Button();
222
223             // my vars (dec)
224
225             // set gobject values
226             this.el.label = "OK";
227         }
228
229         // user defined functions 
230     }
231 }