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