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