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