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