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