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_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.repo.git({ "commit" , "-a" ,"-m", "Uncommited changes synced" });
246                _this.repo.push();
247                _this.repo.loadStatus();
248                
249                 _this.diff_view.el.get_buffer().set_text(_this.repo.git_diff);
250                 _this.status_view.el.get_buffer().set_text(_this.repo.git_status);
251                 
252                _this.el.hide();
253                Clones.singleton().reposStore.load();
254                 
255             });
256         }
257
258         // user defined functions
259     }
260
261     public class Xcls_btn_reset : Object
262     {
263         public Gtk.ToolButton el;
264         private RepoStatusPopover  _this;
265
266
267             // my vars (def)
268
269         // ctor
270         public Xcls_btn_reset(RepoStatusPopover _owner )
271         {
272             _this = _owner;
273             _this.btn_reset = this;
274             this.el = new Gtk.ToolButton(new Gtk.Image.from_icon_name ("gtk-revert-to-saved", Gtk.IconSize.SMALL_TOOLBAR), null);;
275
276             // my vars (dec)
277
278             // set gobject values
279             this.el.label = "Reset / clear changes";
280             this.el.is_important = true;
281
282             //listeners
283             this.el.clicked.connect( () => {
284               
285                
286                GitMonitor.gitmonitor.stop();
287                _this.repo.git({ "reset" , "--hard" });
288                _this.repo.loadStatus();
289                GitMonitor.gitmonitor.start();
290                 _this.diff_view.el.get_buffer().set_text(_this.repo.git_diff);
291                 _this.status_view.el.get_buffer().set_text(_this.repo.git_status);
292                 Clones.singleton().reposStore.load();
293               
294                _this.el.hide();
295              
296             });
297         }
298
299         // user defined functions
300     }
301
302     public class Xcls_btn_pull : Object
303     {
304         public Gtk.ToolButton el;
305         private RepoStatusPopover  _this;
306
307
308             // my vars (def)
309
310         // ctor
311         public Xcls_btn_pull(RepoStatusPopover _owner )
312         {
313             _this = _owner;
314             _this.btn_pull = this;
315             this.el = new Gtk.ToolButton(new Gtk.Image.from_icon_name ("gtk-goto-bottom", Gtk.IconSize.SMALL_TOOLBAR), null);;
316
317             // my vars (dec)
318
319             // set gobject values
320             this.el.label = "Pull updates";
321             this.el.is_important = true;
322
323             //listeners
324             this.el.clicked.connect( () => {
325               
326                
327                GitMonitor.gitmonitor.stop();
328                _this.repo.git({ "pull" , "--all" });
329                _this.repo.loadStatus();
330                GitMonitor.gitmonitor.start();
331                 _this.diff_view.el.get_buffer().set_text(_this.repo.git_diff);
332                 _this.status_view.el.get_buffer().set_text(_this.repo.git_status);
333                 Clones.singleton().reposStore.load();
334               
335                _this.el.hide();
336                 
337             });
338         }
339
340         // user defined functions
341     }
342
343
344
345     public class Xcls_Notebook9 : Object
346     {
347         public Gtk.Notebook el;
348         private RepoStatusPopover  _this;
349
350
351             // my vars (def)
352
353         // ctor
354         public Xcls_Notebook9(RepoStatusPopover _owner )
355         {
356             _this = _owner;
357             this.el = new Gtk.Notebook();
358
359             // my vars (dec)
360
361             // set gobject values
362             this.el.vexpand = true;
363             var child_0 = new Xcls_label_status( _this );
364             child_0.ref();
365             var child_1 = new Xcls_label_diff( _this );
366             child_1.ref();
367             var child_2 = new Xcls_Box12( _this );
368             child_2.ref();
369             this.el.append_page (  child_2.el , _this.label_status.el );
370             var child_3 = new Xcls_Box15( _this );
371             child_3.ref();
372             this.el.append_page (  child_3.el , _this.label_diff.el );
373         }
374
375         // user defined functions
376     }
377     public class Xcls_label_status : Object
378     {
379         public Gtk.Label el;
380         private RepoStatusPopover  _this;
381
382
383             // my vars (def)
384
385         // ctor
386         public Xcls_label_status(RepoStatusPopover _owner )
387         {
388             _this = _owner;
389             _this.label_status = this;
390             this.el = new Gtk.Label( "Status" );
391
392             // my vars (dec)
393
394             // set gobject values
395         }
396
397         // user defined functions
398     }
399
400     public class Xcls_label_diff : Object
401     {
402         public Gtk.Label el;
403         private RepoStatusPopover  _this;
404
405
406             // my vars (def)
407
408         // ctor
409         public Xcls_label_diff(RepoStatusPopover _owner )
410         {
411             _this = _owner;
412             _this.label_diff = this;
413             this.el = new Gtk.Label( "Diff" );
414
415             // my vars (dec)
416
417             // set gobject values
418         }
419
420         // user defined functions
421     }
422
423     public class Xcls_Box12 : Object
424     {
425         public Gtk.Box el;
426         private RepoStatusPopover  _this;
427
428
429             // my vars (def)
430
431         // ctor
432         public Xcls_Box12(RepoStatusPopover _owner )
433         {
434             _this = _owner;
435             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
436
437             // my vars (dec)
438
439             // set gobject values
440             this.el.homogeneous = false;
441             var child_0 = new Xcls_ScrolledWindow13( _this );
442             child_0.ref();
443             this.el.pack_start (  child_0.el , true,true,0 );
444         }
445
446         // user defined functions
447     }
448     public class Xcls_ScrolledWindow13 : Object
449     {
450         public Gtk.ScrolledWindow el;
451         private RepoStatusPopover  _this;
452
453
454             // my vars (def)
455
456         // ctor
457         public Xcls_ScrolledWindow13(RepoStatusPopover _owner )
458         {
459             _this = _owner;
460             this.el = new Gtk.ScrolledWindow( null, null );
461
462             // my vars (dec)
463
464             // set gobject values
465             var child_0 = new Xcls_status_view( _this );
466             child_0.ref();
467             this.el.add (  child_0.el  );
468         }
469
470         // user defined functions
471     }
472     public class Xcls_status_view : Object
473     {
474         public Gtk.SourceView el;
475         private RepoStatusPopover  _this;
476
477
478             // my vars (def)
479
480         // ctor
481         public Xcls_status_view(RepoStatusPopover _owner )
482         {
483             _this = _owner;
484             _this.status_view = this;
485             this.el = new Gtk.SourceView();
486
487             // my vars (dec)
488
489             // init method
490
491             var description =   Pango.FontDescription.from_string("monospace");
492                 description.set_size(9000);
493                 this.el.override_font(description);
494         }
495
496         // user defined functions
497     }
498
499
500
501     public class Xcls_Box15 : Object
502     {
503         public Gtk.Box el;
504         private RepoStatusPopover  _this;
505
506
507             // my vars (def)
508
509         // ctor
510         public Xcls_Box15(RepoStatusPopover _owner )
511         {
512             _this = _owner;
513             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
514
515             // my vars (dec)
516
517             // set gobject values
518             this.el.homogeneous = false;
519             var child_0 = new Xcls_ScrolledWindow16( _this );
520             child_0.ref();
521             this.el.pack_start (  child_0.el , true,true,0 );
522         }
523
524         // user defined functions
525     }
526     public class Xcls_ScrolledWindow16 : Object
527     {
528         public Gtk.ScrolledWindow el;
529         private RepoStatusPopover  _this;
530
531
532             // my vars (def)
533
534         // ctor
535         public Xcls_ScrolledWindow16(RepoStatusPopover _owner )
536         {
537             _this = _owner;
538             this.el = new Gtk.ScrolledWindow( null, null );
539
540             // my vars (dec)
541
542             // set gobject values
543             this.el.height_request = 400;
544             var child_0 = new Xcls_diff_view( _this );
545             child_0.ref();
546             this.el.add (  child_0.el  );
547         }
548
549         // user defined functions
550     }
551     public class Xcls_diff_view : Object
552     {
553         public Gtk.SourceView el;
554         private RepoStatusPopover  _this;
555
556
557             // my vars (def)
558
559         // ctor
560         public Xcls_diff_view(RepoStatusPopover _owner )
561         {
562             _this = _owner;
563             _this.diff_view = this;
564             this.el = new Gtk.SourceView();
565
566             // my vars (dec)
567
568             // init method
569
570             var description =   Pango.FontDescription.from_string("monospace");
571                 description.set_size(9000);
572                 this.el.override_font(description);
573         }
574
575         // user defined functions
576     }
577
578
579
580
581     public class Xcls_Box18 : Object
582     {
583         public Gtk.Box el;
584         private RepoStatusPopover  _this;
585
586
587             // my vars (def)
588
589         // ctor
590         public Xcls_Box18(RepoStatusPopover _owner )
591         {
592             _this = _owner;
593             this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
594
595             // my vars (dec)
596
597             // set gobject values
598             this.el.homogeneous = true;
599             this.el.expand = false;
600             this.el.vexpand = false;
601             var child_0 = new Xcls_Toolbar19( _this );
602             child_0.ref();
603             this.el.add (  child_0.el  );
604         }
605
606         // user defined functions
607     }
608     public class Xcls_Toolbar19 : Object
609     {
610         public Gtk.Toolbar el;
611         private RepoStatusPopover  _this;
612
613
614             // my vars (def)
615
616         // ctor
617         public Xcls_Toolbar19(RepoStatusPopover _owner )
618         {
619             _this = _owner;
620             this.el = new Gtk.Toolbar();
621
622             // my vars (dec)
623
624             // set gobject values
625             this.el.toolbar_style = Gtk.ToolbarStyle.BOTH_HORIZ;
626             var child_0 = new Xcls_btn_create( _this );
627             child_0.ref();
628             this.el.add (  child_0.el  );
629             var child_1 = new Xcls_btn_merge( _this );
630             child_1.ref();
631             this.el.add (  child_1.el  );
632             var child_2 = new Xcls_ToolButton22( _this );
633             child_2.ref();
634             this.el.add (  child_2.el  );
635         }
636
637         // user defined functions
638     }
639     public class Xcls_btn_create : Object
640     {
641         public Gtk.ToolButton el;
642         private RepoStatusPopover  _this;
643
644
645             // my vars (def)
646
647         // ctor
648         public Xcls_btn_create(RepoStatusPopover _owner )
649         {
650             _this = _owner;
651             _this.btn_create = this;
652             this.el = new Gtk.ToolButton(new Gtk.Image.from_icon_name ("gtk-add", Gtk.IconSize.SMALL_TOOLBAR), null);;
653
654             // my vars (dec)
655
656             // set gobject values
657             this.el.label = "Create Branch / Start ticket";
658             this.el.is_important = true;
659
660             //listeners
661             this.el.clicked.connect( () => {
662                var oldq = new Gee.ArrayList<GitMonitorQueue>();  
663             
664                 Clones.singleton().el.response(-1);
665                 NewBranch.singleton().show(_this.repo, oldq);
666             
667                 
668             });
669         }
670
671         // user defined functions
672     }
673
674     public class Xcls_btn_merge : Object
675     {
676         public Gtk.ToolButton el;
677         private RepoStatusPopover  _this;
678
679
680             // my vars (def)
681
682         // ctor
683         public Xcls_btn_merge(RepoStatusPopover _owner )
684         {
685             _this = _owner;
686             _this.btn_merge = this;
687             this.el = new Gtk.ToolButton(new Gtk.Image.from_icon_name ("gtk-goto-top", Gtk.IconSize.SMALL_TOOLBAR), null);;
688
689             // my vars (dec)
690
691             // set gobject values
692             this.el.label = "Merge branch /  Complete ticket";
693             this.el.is_important = true;
694
695             //listeners
696             this.el.clicked.connect( () => {
697             
698                _this.el.hide();
699                Clones.singleton().el.response(-1);
700                if (_this.repo.activeTicket != null) {
701                    MergeBranch.singleton().show(_this.repo.activeTicket, null);   
702                }
703              
704             });
705         }
706
707         // user defined functions
708     }
709
710     public class Xcls_ToolButton22 : Object
711     {
712         public Gtk.ToolButton el;
713         private RepoStatusPopover  _this;
714
715
716             // my vars (def)
717
718         // ctor
719         public Xcls_ToolButton22(RepoStatusPopover _owner )
720         {
721             _this = _owner;
722             this.el = new Gtk.ToolButton(new Gtk.Image.from_icon_name ("gtk-new", Gtk.IconSize.SMALL_TOOLBAR), null);;
723
724             // my vars (dec)
725
726             // set gobject values
727             this.el.label = "Create Ticket";
728             this.el.is_important = true;
729
730             //listeners
731             this.el.clicked.connect( () => {
732               
733             
734             
735                   Clones.singleton().el.response(-1);
736               
737                _this.el.hide();
738                Ticket.singleton().show( _this.repo);
739                 
740             });
741         }
742
743         // user defined functions
744     }
745
746
747
748
749 }