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