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