RepoStatusPopover.bjs
[gitlive] / RepoStatusPopover.vala
1 static RepoStatusPopover  _RepoStatusPopover;
2
3 public class RepoStatusPopover : Object
4 {
5     public Gtk.Popover el;
6     private RepoStatusPopover  _this;
7
8     public static RepoStatusPopover singleton()
9     {
10         if (_RepoStatusPopover == null) {
11             _RepoStatusPopover= new RepoStatusPopover();
12         }
13         return _RepoStatusPopover;
14     }
15     public Xcls_label_status label_status;
16     public Xcls_label_diff label_diff;
17     public Xcls_status_view status_view;
18     public Xcls_diff_view diff_view;
19
20         // my vars (def)
21     public GitRepo repo;
22
23     // ctor
24     public RepoStatusPopover()
25     {
26         _this = this;
27         this.el = new Gtk.Popover( null );
28
29         // my vars (dec)
30
31         // set gobject values
32         this.el.border_width = 0;
33         this.el.modal = true;
34         this.el.position = Gtk.PositionType.RIGHT;
35         var child_0 = new Xcls_Box2( _this );
36         child_0.ref();
37         this.el.add (  child_0.el  );
38     }
39
40     // user defined functions
41     public void show (Gtk.Widget btn, Gdk.Rectangle rect, GitRepo repo) {
42         _this.repo = repo;
43         // get the active project.
44          var lm = Gtk.SourceLanguageManager.get_default();
45                     
46     //    ((Gtk.SourceBuffer)(_this.view.el.get_buffer())) .set_language(
47       //      lm.get_language("html")
48      //   );
49       
50         //print (project.fn);
51         //project.runhtml = project.runhtml || '';
52         _this.diff_view.el.get_buffer().set_text(repo.git_diff);
53         _this.status_view.el.get_buffer().set_text(repo.git_status);
54            
55                 //console.log('show all');
56         this.el.set_modal(true);
57         this.el.set_relative_to(btn);
58         this.el.set_pointing_to(rect);
59       
60         //this.el.set_position(Gtk.PositionType.RIGHT);
61     
62         // window + header?
63          GLib.debug("SHOWALL - POPIP\n");
64         this.el.show_all();
65         //this.el.set_size_request(800,500);
66     //  this.diff_view.el.grab_focus();
67         
68         //this.el.show_all();
69     }
70     public class Xcls_Box2 : Object
71     {
72         public Gtk.Box el;
73         private RepoStatusPopover  _this;
74
75
76             // my vars (def)
77
78         // ctor
79         public Xcls_Box2(RepoStatusPopover _owner )
80         {
81             _this = _owner;
82             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
83
84             // my vars (dec)
85
86             // set gobject values
87             this.el.homogeneous = false;
88             this.el.border_width = 5;
89             var child_0 = new Xcls_Notebook3( _this );
90             child_0.ref();
91             this.el.pack_start (  child_0.el , true,true,0 );
92             var child_1 = new Xcls_Box12( _this );
93             child_1.ref();
94             this.el.pack_end (  child_1.el , false,false,0 );
95         }
96
97         // user defined functions
98     }
99     public class Xcls_Notebook3 : Object
100     {
101         public Gtk.Notebook el;
102         private RepoStatusPopover  _this;
103
104
105             // my vars (def)
106
107         // ctor
108         public Xcls_Notebook3(RepoStatusPopover _owner )
109         {
110             _this = _owner;
111             this.el = new Gtk.Notebook();
112
113             // my vars (dec)
114
115             // set gobject values
116             var child_0 = new Xcls_label_status( _this );
117             child_0.ref();
118             var child_1 = new Xcls_label_diff( _this );
119             child_1.ref();
120             var child_2 = new Xcls_Box6( _this );
121             child_2.ref();
122             this.el.append_page (  child_2.el , _this.label_status.el );
123             var child_3 = new Xcls_Box9( _this );
124             child_3.ref();
125             this.el.append_page (  child_3.el , _this.label_diff.el );
126         }
127
128         // user defined functions
129     }
130     public class Xcls_label_status : Object
131     {
132         public Gtk.Label el;
133         private RepoStatusPopover  _this;
134
135
136             // my vars (def)
137
138         // ctor
139         public Xcls_label_status(RepoStatusPopover _owner )
140         {
141             _this = _owner;
142             _this.label_status = this;
143             this.el = new Gtk.Label( "Status" );
144
145             // my vars (dec)
146
147             // set gobject values
148         }
149
150         // user defined functions
151     }
152
153     public class Xcls_label_diff : Object
154     {
155         public Gtk.Label el;
156         private RepoStatusPopover  _this;
157
158
159             // my vars (def)
160
161         // ctor
162         public Xcls_label_diff(RepoStatusPopover _owner )
163         {
164             _this = _owner;
165             _this.label_diff = this;
166             this.el = new Gtk.Label( "Diff" );
167
168             // my vars (dec)
169
170             // set gobject values
171         }
172
173         // user defined functions
174     }
175
176     public class Xcls_Box6 : Object
177     {
178         public Gtk.Box el;
179         private RepoStatusPopover  _this;
180
181
182             // my vars (def)
183
184         // ctor
185         public Xcls_Box6(RepoStatusPopover _owner )
186         {
187             _this = _owner;
188             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
189
190             // my vars (dec)
191
192             // set gobject values
193             this.el.homogeneous = false;
194             var child_0 = new Xcls_ScrolledWindow7( _this );
195             child_0.ref();
196             this.el.pack_start (  child_0.el , true,true,0 );
197         }
198
199         // user defined functions
200     }
201     public class Xcls_ScrolledWindow7 : Object
202     {
203         public Gtk.ScrolledWindow el;
204         private RepoStatusPopover  _this;
205
206
207             // my vars (def)
208
209         // ctor
210         public Xcls_ScrolledWindow7(RepoStatusPopover _owner )
211         {
212             _this = _owner;
213             this.el = new Gtk.ScrolledWindow( null, null );
214
215             // my vars (dec)
216
217             // set gobject values
218             var child_0 = new Xcls_status_view( _this );
219             child_0.ref();
220             this.el.add (  child_0.el  );
221         }
222
223         // user defined functions
224     }
225     public class Xcls_status_view : Object
226     {
227         public Gtk.SourceView el;
228         private RepoStatusPopover  _this;
229
230
231             // my vars (def)
232
233         // ctor
234         public Xcls_status_view(RepoStatusPopover _owner )
235         {
236             _this = _owner;
237             _this.status_view = this;
238             this.el = new Gtk.SourceView();
239
240             // my vars (dec)
241
242             // init method
243
244             var description =   Pango.FontDescription.from_string("monospace");
245                 description.set_size(9000);
246                 this.el.override_font(description);
247         }
248
249         // user defined functions
250     }
251
252
253
254     public class Xcls_Box9 : Object
255     {
256         public Gtk.Box el;
257         private RepoStatusPopover  _this;
258
259
260             // my vars (def)
261
262         // ctor
263         public Xcls_Box9(RepoStatusPopover _owner )
264         {
265             _this = _owner;
266             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
267
268             // my vars (dec)
269
270             // set gobject values
271             this.el.homogeneous = false;
272             var child_0 = new Xcls_ScrolledWindow10( _this );
273             child_0.ref();
274             this.el.pack_start (  child_0.el , true,true,0 );
275         }
276
277         // user defined functions
278     }
279     public class Xcls_ScrolledWindow10 : Object
280     {
281         public Gtk.ScrolledWindow el;
282         private RepoStatusPopover  _this;
283
284
285             // my vars (def)
286
287         // ctor
288         public Xcls_ScrolledWindow10(RepoStatusPopover _owner )
289         {
290             _this = _owner;
291             this.el = new Gtk.ScrolledWindow( null, null );
292
293             // my vars (dec)
294
295             // set gobject values
296             this.el.height_request = 400;
297             var child_0 = new Xcls_diff_view( _this );
298             child_0.ref();
299             this.el.add (  child_0.el  );
300         }
301
302         // user defined functions
303     }
304     public class Xcls_diff_view : Object
305     {
306         public Gtk.SourceView el;
307         private RepoStatusPopover  _this;
308
309
310             // my vars (def)
311
312         // ctor
313         public Xcls_diff_view(RepoStatusPopover _owner )
314         {
315             _this = _owner;
316             _this.diff_view = this;
317             this.el = new Gtk.SourceView();
318
319             // my vars (dec)
320
321             // init method
322
323             var description =   Pango.FontDescription.from_string("monospace");
324                 description.set_size(9000);
325                 this.el.override_font(description);
326         }
327
328         // user defined functions
329     }
330
331
332
333
334     public class Xcls_Box12 : Object
335     {
336         public Gtk.Box el;
337         private RepoStatusPopover  _this;
338
339
340             // my vars (def)
341
342         // ctor
343         public Xcls_Box12(RepoStatusPopover _owner )
344         {
345             _this = _owner;
346             this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
347
348             // my vars (dec)
349
350             // set gobject values
351             this.el.homogeneous = true;
352             this.el.expand = false;
353             this.el.vexpand = false;
354             var child_0 = new Xcls_Toolbar13( _this );
355             child_0.ref();
356             this.el.add (  child_0.el  );
357         }
358
359         // user defined functions
360     }
361     public class Xcls_Toolbar13 : Object
362     {
363         public Gtk.Toolbar el;
364         private RepoStatusPopover  _this;
365
366
367             // my vars (def)
368
369         // ctor
370         public Xcls_Toolbar13(RepoStatusPopover _owner )
371         {
372             _this = _owner;
373             this.el = new Gtk.Toolbar();
374
375             // my vars (dec)
376
377             // set gobject values
378             this.el.toolbar_style = Gtk.ToolbarStyle.BOTH_HORIZ;
379             var child_0 = new Xcls_ToolButton14( _this );
380             child_0.ref();
381             this.el.add (  child_0.el  );
382             var child_1 = new Xcls_ToolButton15( _this );
383             child_1.ref();
384             this.el.add (  child_1.el  );
385             var child_2 = new Xcls_ToolButton16( _this );
386             child_2.ref();
387             this.el.add (  child_2.el  );
388             var child_3 = new Xcls_ToolButton17( _this );
389             child_3.ref();
390             this.el.add (  child_3.el  );
391             var child_4 = new Xcls_ToolButton18( _this );
392             child_4.ref();
393             this.el.add (  child_4.el  );
394             var child_5 = new Xcls_ToolButton19( _this );
395             child_5.ref();
396             this.el.add (  child_5.el  );
397             var child_6 = new Xcls_ToolButton20( _this );
398             child_6.ref();
399             this.el.add (  child_6.el  );
400         }
401
402         // user defined functions
403     }
404     public class Xcls_ToolButton14 : Object
405     {
406         public Gtk.ToolButton el;
407         private RepoStatusPopover  _this;
408
409
410             // my vars (def)
411
412         // ctor
413         public Xcls_ToolButton14(RepoStatusPopover _owner )
414         {
415             _this = _owner;
416             this.el = new Gtk.ToolButton(new Gtk.Image.from_icon_name ("gtk-undo", Gtk.IconSize.SMALL_TOOLBAR), null);;
417
418             // my vars (dec)
419
420             // set gobject values
421             this.el.label = "Stash Changes";
422             this.el.is_important = true;
423
424             //listeners
425             this.el.button_press_event.connect( () => {
426               
427                
428                GitMonitor.gitmonitor.stop();
429                _this.repo.git({ "stash" , "--all" });
430                _this.repo.loadStatus();
431                GitMonitor.gitmonitor.start();
432                 _this.diff_view.el.get_buffer().set_text(_this.repo.git_diff);
433                 _this.status_view.el.get_buffer().set_text(_this.repo.git_status);
434                 Clones.singleton().reposStore.load();
435               
436                _this.el.hide();
437                 return false;
438             });
439         }
440
441         // user defined functions
442     }
443
444     public class Xcls_ToolButton15 : Object
445     {
446         public Gtk.ToolButton el;
447         private RepoStatusPopover  _this;
448
449
450             // my vars (def)
451
452         // ctor
453         public Xcls_ToolButton15(RepoStatusPopover _owner )
454         {
455             _this = _owner;
456             this.el = new Gtk.ToolButton(new Gtk.Image.from_icon_name ("gtk-save", Gtk.IconSize.SMALL_TOOLBAR), null);;
457
458             // my vars (dec)
459
460             // set gobject values
461             this.el.label = "Commit Changes";
462             this.el.is_important = true;
463
464             //listeners
465             this.el.button_press_event.connect( () => {
466                _this.repo.git({ "commit" , "-a" ,"-m", "Uncommited changes synced" });
467                _this.repo.push();
468                _this.repo.loadStatus();
469                
470                 _this.diff_view.el.get_buffer().set_text(_this.repo.git_diff);
471                 _this.status_view.el.get_buffer().set_text(_this.repo.git_status);
472                 
473                _this.el.hide();
474                Clones.singleton().reposStore.load();
475                
476                 return false;
477             });
478         }
479
480         // user defined functions
481     }
482
483     public class Xcls_ToolButton16 : Object
484     {
485         public Gtk.ToolButton el;
486         private RepoStatusPopover  _this;
487
488
489             // my vars (def)
490
491         // ctor
492         public Xcls_ToolButton16(RepoStatusPopover _owner )
493         {
494             _this = _owner;
495             this.el = new Gtk.ToolButton(new Gtk.Image.from_icon_name ("gtk-add", Gtk.IconSize.SMALL_TOOLBAR), null);;
496
497             // my vars (dec)
498
499             // set gobject values
500             this.el.label = "Create Branch / Start ticket";
501             this.el.is_important = true;
502
503             //listeners
504             this.el.button_press_event.connect( () => {
505                var oldq = new Gee.ArrayList<GitMonitorQueue>();  
506             
507                 Clones.singleton().el.response(-1);
508                 NewBranch.singleton().show(_this.repo, oldq);
509             
510                 return false;
511             });
512         }
513
514         // user defined functions
515     }
516
517     public class Xcls_ToolButton17 : Object
518     {
519         public Gtk.ToolButton el;
520         private RepoStatusPopover  _this;
521
522
523             // my vars (def)
524
525         // ctor
526         public Xcls_ToolButton17(RepoStatusPopover _owner )
527         {
528             _this = _owner;
529             this.el = new Gtk.ToolButton(new Gtk.Image.from_icon_name ("gtk-revert-to-saved", Gtk.IconSize.SMALL_TOOLBAR), null);;
530
531             // my vars (dec)
532
533             // set gobject values
534             this.el.label = "Reset / clear changes";
535             this.el.is_important = true;
536
537             //listeners
538             this.el.button_press_event.connect( () => {
539               
540                
541                GitMonitor.gitmonitor.stop();
542                _this.repo.git({ "reset" , "--hard" });
543                _this.repo.loadStatus();
544                GitMonitor.gitmonitor.start();
545                 _this.diff_view.el.get_buffer().set_text(_this.repo.git_diff);
546                 _this.status_view.el.get_buffer().set_text(_this.repo.git_status);
547                 Clones.singleton().reposStore.load();
548               
549                _this.el.hide();
550                 return false;
551             });
552         }
553
554         // user defined functions
555     }
556
557     public class Xcls_ToolButton18 : Object
558     {
559         public Gtk.ToolButton el;
560         private RepoStatusPopover  _this;
561
562
563             // my vars (def)
564
565         // ctor
566         public Xcls_ToolButton18(RepoStatusPopover _owner )
567         {
568             _this = _owner;
569             this.el = new Gtk.ToolButton(new Gtk.Image.from_icon_name ("gtk-goto-bottom", Gtk.IconSize.SMALL_TOOLBAR), null);;
570
571             // my vars (dec)
572
573             // set gobject values
574             this.el.label = "Pull updates";
575
576             //listeners
577             this.el.button_press_event.connect( () => {
578               
579                
580                GitMonitor.gitmonitor.stop();
581                _this.repo.git({ "pull" , "--all" });
582                _this.repo.loadStatus();
583                GitMonitor.gitmonitor.start();
584                 _this.diff_view.el.get_buffer().set_text(_this.repo.git_diff);
585                 _this.status_view.el.get_buffer().set_text(_this.repo.git_status);
586                 Clones.singleton().reposStore.load();
587               
588                _this.el.hide();
589                 return false;
590             });
591         }
592
593         // user defined functions
594     }
595
596     public class Xcls_ToolButton19 : Object
597     {
598         public Gtk.ToolButton el;
599         private RepoStatusPopover  _this;
600
601
602             // my vars (def)
603
604         // ctor
605         public Xcls_ToolButton19(RepoStatusPopover _owner )
606         {
607             _this = _owner;
608             this.el = new Gtk.ToolButton(new Gtk.Image.from_icon_name ("gtk-goto-top", Gtk.IconSize.SMALL_TOOLBAR), null);;
609
610             // my vars (dec)
611
612             // set gobject values
613             this.el.label = "Merge branch/  ticket";
614
615             //listeners
616             this.el.button_press_event.connect( () => {
617             
618                _this.el.hide();
619                Clones.singleton().el.response(-1);
620                if (_this.repo.activeTicket != null) {
621                    MergeBranch.singleton().show(_this.repo.activeTicket, null);   
622                }
623                 return false;
624             });
625         }
626
627         // user defined functions
628     }
629
630     public class Xcls_ToolButton20 : Object
631     {
632         public Gtk.ToolButton el;
633         private RepoStatusPopover  _this;
634
635
636             // my vars (def)
637
638         // ctor
639         public Xcls_ToolButton20(RepoStatusPopover _owner )
640         {
641             _this = _owner;
642             this.el = new Gtk.ToolButton(new Gtk.Image.from_icon_name ("gtk-new", Gtk.IconSize.SMALL_TOOLBAR), null);;
643
644             // my vars (dec)
645
646             // set gobject values
647             this.el.label = "Create Ticket";
648
649             //listeners
650             this.el.button_press_event.connect( () => {
651               
652             
653             
654                   Clones.singleton().el.response(-1);
655               
656                _this.el.hide();
657                Ticket.singleton().show( _this.repo);
658                
659                 return false;
660             });
661         }
662
663         // user defined functions
664     }
665
666
667
668
669 }