RepoStatusPopover.bjs
[gitlive] / RepoStatusPopover.vala
1 static Xcls_RooProjectSettings  _RooProjectSettings;
2
3 public class Xcls_RooProjectSettings : Object
4 {
5     public Gtk.Popover el;
6     private Xcls_RooProjectSettings  _this;
7
8     public static Xcls_RooProjectSettings singleton()
9     {
10         if (_RooProjectSettings == null) {
11             _RooProjectSettings= new Xcls_RooProjectSettings();
12         }
13         return _RooProjectSettings;
14     }
15     public Xcls_label_status label_status;
16     public Xcls_label_diff label_diff;
17     public Xcls_view view;
18     public Xcls_view view;
19
20         // my vars (def)
21     public signal void buttonPressed (string btn);
22     public Project.Project project;
23
24     // ctor
25     public Xcls_RooProjectSettings()
26     {
27         _this = this;
28         this.el = new Gtk.Popover( null );
29
30         // my vars (dec)
31
32         // set gobject values
33         this.el.border_width = 0;
34         this.el.modal = true;
35         this.el.position = Gtk.PositionType.RIGHT;
36         var child_0 = new Xcls_Box2( _this );
37         child_0.ref();
38         this.el.add (  child_0.el  );
39     }
40
41     // user defined functions
42     public void show (Gtk.Widget btn, Project.Project project) {
43         _this.project = project;
44         _this.path.el.label = project.firstPath();
45         // get the active project.
46          var lm = Gtk.SourceLanguageManager.get_default();
47                     
48         ((Gtk.SourceBuffer)(_this.view.el.get_buffer())) .set_language(
49             lm.get_language("html")
50         );
51       
52         //print (project.fn);
53         //project.runhtml = project.runhtml || '';
54         _this.view.el.get_buffer().set_text(project.runhtml);
55         
56           
57           
58         _this.rootURL.el.set_text( _this.project.rootURL );
59         
60         _this.html_gen_model.loadData(_this.project.html_gen);
61     
62         _this.base_template_model.loadData();
63         
64          var js = _this.project;
65         _this.database_DBTYPE.el.set_text(     js.get_string_member("DBTYPE") );
66         _this.database_DBNAME.el.set_text(    js.get_string_member("DBNAME") );
67         _this.database_DBUSERNAME.el.set_text(    js.get_string_member("DBUSERNAME") );
68         _this.database_DBPASSWORD.el.set_text(    js.get_string_member("DBPASSWORD") );
69         
70                 //console.log('show all');
71         this.el.set_modal(true);
72         this.el.set_relative_to(btn);
73     
74         this.el.set_position(Gtk.PositionType.RIGHT);
75     
76         // window + header?
77          print("SHOWALL - POPIP\n");
78         this.el.show_all();
79         this.el.set_size_request(800,500);
80         this.view.el.grab_focus();
81         
82         
83         //this.el.show_all();
84     }
85     public void save () {
86        var buf =    _this.view.el.get_buffer();
87        Gtk.TextIter s;
88          Gtk.TextIter e;
89         buf.get_start_iter(out s);
90         buf.get_end_iter(out e);
91         _this.project.runhtml = buf.get_text(s,e,true);
92           
93         _this.project.rootURL = _this.rootURL.el.get_text();
94         
95         
96         Gtk.TreeIter iter;
97         Value html_gen_val;
98         _this.html_gen.el.get_active_iter(out iter);
99         _this.html_gen_model.el.get_value (iter, 0, out html_gen_val);
100         
101         _this.project.html_gen = (string)html_gen_val;
102         
103         // set by event changed...
104         //_this.project.base_template = _this.base_template.el.get_text();    
105         
106         var js = _this.project.json_project_data;
107         js.set_string_member("DBTYPE", _this.database_DBTYPE.el.get_text());
108        js.set_string_member("DBNAME", _this.database_DBNAME.el.get_text());
109         js.set_string_member("DBUSERNAME", _this.database_DBUSERNAME.el.get_text());
110         js.set_string_member("DBPASSWORD", _this.database_DBPASSWORD.el.get_text());
111     //    _this.project.set_string_member("DBHOST", _this.DBTYPE.el.get_text());    
112         
113         // need to re-init the database 
114         
115         _this.project.initRooDatabase();
116          
117         
118     }
119     public class Xcls_Box2 : Object
120     {
121         public Gtk.Box el;
122         private Xcls_RooProjectSettings  _this;
123
124
125             // my vars (def)
126
127         // ctor
128         public Xcls_Box2(Xcls_RooProjectSettings _owner )
129         {
130             _this = _owner;
131             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
132
133             // my vars (dec)
134
135             // set gobject values
136             this.el.homogeneous = false;
137             this.el.border_width = 5;
138             var child_0 = new Xcls_Notebook3( _this );
139             child_0.ref();
140             this.el.pack_start (  child_0.el , true,true,0 );
141             var child_1 = new Xcls_Box12( _this );
142             child_1.ref();
143             this.el.pack_end (  child_1.el , false,false,0 );
144         }
145
146         // user defined functions
147     }
148     public class Xcls_Notebook3 : Object
149     {
150         public Gtk.Notebook el;
151         private Xcls_RooProjectSettings  _this;
152
153
154             // my vars (def)
155
156         // ctor
157         public Xcls_Notebook3(Xcls_RooProjectSettings _owner )
158         {
159             _this = _owner;
160             this.el = new Gtk.Notebook();
161
162             // my vars (dec)
163
164             // set gobject values
165             var child_0 = new Xcls_label_status( _this );
166             child_0.ref();
167             var child_1 = new Xcls_label_diff( _this );
168             child_1.ref();
169             var child_2 = new Xcls_Box6( _this );
170             child_2.ref();
171             this.el.append_page (  child_2.el , _this.label_status.el );
172             var child_3 = new Xcls_Box9( _this );
173             child_3.ref();
174             this.el.append_page (  child_3.el , _this.label_diff.el );
175         }
176
177         // user defined functions
178     }
179     public class Xcls_label_status : Object
180     {
181         public Gtk.Label el;
182         private Xcls_RooProjectSettings  _this;
183
184
185             // my vars (def)
186
187         // ctor
188         public Xcls_label_status(Xcls_RooProjectSettings _owner )
189         {
190             _this = _owner;
191             _this.label_status = this;
192             this.el = new Gtk.Label( "Status" );
193
194             // my vars (dec)
195
196             // set gobject values
197         }
198
199         // user defined functions
200     }
201
202     public class Xcls_label_diff : Object
203     {
204         public Gtk.Label el;
205         private Xcls_RooProjectSettings  _this;
206
207
208             // my vars (def)
209
210         // ctor
211         public Xcls_label_diff(Xcls_RooProjectSettings _owner )
212         {
213             _this = _owner;
214             _this.label_diff = this;
215             this.el = new Gtk.Label( "Diff" );
216
217             // my vars (dec)
218
219             // set gobject values
220         }
221
222         // user defined functions
223     }
224
225     public class Xcls_Box6 : Object
226     {
227         public Gtk.Box el;
228         private Xcls_RooProjectSettings  _this;
229
230
231             // my vars (def)
232
233         // ctor
234         public Xcls_Box6(Xcls_RooProjectSettings _owner )
235         {
236             _this = _owner;
237             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
238
239             // my vars (dec)
240
241             // set gobject values
242             this.el.homogeneous = false;
243             var child_0 = new Xcls_ScrolledWindow7( _this );
244             child_0.ref();
245             this.el.pack_start (  child_0.el , true,true,0 );
246         }
247
248         // user defined functions
249     }
250     public class Xcls_ScrolledWindow7 : Object
251     {
252         public Gtk.ScrolledWindow el;
253         private Xcls_RooProjectSettings  _this;
254
255
256             // my vars (def)
257
258         // ctor
259         public Xcls_ScrolledWindow7(Xcls_RooProjectSettings _owner )
260         {
261             _this = _owner;
262             this.el = new Gtk.ScrolledWindow( null, null );
263
264             // my vars (dec)
265
266             // set gobject values
267             var child_0 = new Xcls_view( _this );
268             child_0.ref();
269             this.el.add (  child_0.el  );
270         }
271
272         // user defined functions
273     }
274     public class Xcls_view : Object
275     {
276         public Gtk.SourceView el;
277         private Xcls_RooProjectSettings  _this;
278
279
280             // my vars (def)
281
282         // ctor
283         public Xcls_view(Xcls_RooProjectSettings _owner )
284         {
285             _this = _owner;
286             _this.view = this;
287             this.el = new Gtk.SourceView();
288
289             // my vars (dec)
290
291             // init method
292
293             var description =   Pango.FontDescription.from_string("monospace");
294                 description.set_size(9000);
295                 this.el.override_font(description);
296
297             //listeners
298             this.el.key_release_event.connect( ( event) =>{
299                 if (event.keyval != 115) {
300                     return false;
301                      
302                 }
303                 if   ( (event.state & Gdk.ModifierType.CONTROL_MASK ) < 1 ) {
304                     return false;
305                 }
306                  var buf =    this.el.get_buffer();
307                 Gtk.TextIter s;
308                 Gtk.TextIter e;
309                 buf.get_start_iter(out s);
310                 buf.get_end_iter(out e);
311                 _this.project.runhtml = buf.get_text(s,e,true);
312                 
313                       
314                 _this.buttonPressed("save");
315                  
316                 return false;
317                      
318             });
319         }
320
321         // user defined functions
322     }
323
324
325
326     public class Xcls_Box9 : Object
327     {
328         public Gtk.Box el;
329         private Xcls_RooProjectSettings  _this;
330
331
332             // my vars (def)
333
334         // ctor
335         public Xcls_Box9(Xcls_RooProjectSettings _owner )
336         {
337             _this = _owner;
338             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
339
340             // my vars (dec)
341
342             // set gobject values
343             this.el.homogeneous = false;
344             var child_0 = new Xcls_ScrolledWindow10( _this );
345             child_0.ref();
346             this.el.pack_start (  child_0.el , true,true,0 );
347         }
348
349         // user defined functions
350     }
351     public class Xcls_ScrolledWindow10 : Object
352     {
353         public Gtk.ScrolledWindow el;
354         private Xcls_RooProjectSettings  _this;
355
356
357             // my vars (def)
358
359         // ctor
360         public Xcls_ScrolledWindow10(Xcls_RooProjectSettings _owner )
361         {
362             _this = _owner;
363             this.el = new Gtk.ScrolledWindow( null, null );
364
365             // my vars (dec)
366
367             // set gobject values
368             var child_0 = new Xcls_view( _this );
369             child_0.ref();
370             this.el.add (  child_0.el  );
371         }
372
373         // user defined functions
374     }
375     public class Xcls_view : Object
376     {
377         public Gtk.SourceView el;
378         private Xcls_RooProjectSettings  _this;
379
380
381             // my vars (def)
382
383         // ctor
384         public Xcls_view(Xcls_RooProjectSettings _owner )
385         {
386             _this = _owner;
387             _this.view = this;
388             this.el = new Gtk.SourceView();
389
390             // my vars (dec)
391
392             // init method
393
394             var description =   Pango.FontDescription.from_string("monospace");
395                 description.set_size(9000);
396                 this.el.override_font(description);
397
398             //listeners
399             this.el.key_release_event.connect( ( event) =>{
400                 if (event.keyval != 115) {
401                     return false;
402                      
403                 }
404                 if   ( (event.state & Gdk.ModifierType.CONTROL_MASK ) < 1 ) {
405                     return false;
406                 }
407                  var buf =    this.el.get_buffer();
408                 Gtk.TextIter s;
409                 Gtk.TextIter e;
410                 buf.get_start_iter(out s);
411                 buf.get_end_iter(out e);
412                 _this.project.runhtml = buf.get_text(s,e,true);
413                 
414                       
415                 _this.buttonPressed("save");
416                  
417                 return false;
418                      
419             });
420         }
421
422         // user defined functions
423     }
424
425
426
427
428     public class Xcls_Box12 : Object
429     {
430         public Gtk.Box el;
431         private Xcls_RooProjectSettings  _this;
432
433
434             // my vars (def)
435
436         // ctor
437         public Xcls_Box12(Xcls_RooProjectSettings _owner )
438         {
439             _this = _owner;
440             this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
441
442             // my vars (dec)
443
444             // set gobject values
445             this.el.homogeneous = true;
446             this.el.expand = false;
447             this.el.vexpand = false;
448             var child_0 = new Xcls_Button13( _this );
449             child_0.ref();
450             this.el.add (  child_0.el  );
451             var child_1 = new Xcls_Button14( _this );
452             child_1.ref();
453             this.el.add (  child_1.el  );
454         }
455
456         // user defined functions
457     }
458     public class Xcls_Button13 : Object
459     {
460         public Gtk.Button el;
461         private Xcls_RooProjectSettings  _this;
462
463
464             // my vars (def)
465
466         // ctor
467         public Xcls_Button13(Xcls_RooProjectSettings _owner )
468         {
469             _this = _owner;
470             this.el = new Gtk.Button();
471
472             // my vars (dec)
473
474             // set gobject values
475             this.el.label = "Stash Changes";
476
477             //listeners
478             this.el.button_press_event.connect( () => {
479                 _this.save();
480                       
481                 _this.buttonPressed("apply");
482                     return false;
483             });
484         }
485
486         // user defined functions
487     }
488
489     public class Xcls_Button14 : Object
490     {
491         public Gtk.Button el;
492         private Xcls_RooProjectSettings  _this;
493
494
495             // my vars (def)
496
497         // ctor
498         public Xcls_Button14(Xcls_RooProjectSettings _owner )
499         {
500             _this = _owner;
501             this.el = new Gtk.Button();
502
503             // my vars (dec)
504
505             // set gobject values
506             this.el.label = "Save";
507
508             //listeners
509             this.el.button_press_event.connect( () => {
510                    _this.save();
511                       
512                 _this.buttonPressed("save");
513                     return false;
514             });
515         }
516
517         // user defined functions
518     }
519
520
521
522 }