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