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