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