StatusIcon.vala
[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.add (  child_1.el  );
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             this.el.vexpand = true;
342             var child_0 = new Xcls_label_status( _this );
343             child_0.ref();
344             var child_1 = new Xcls_label_diff( _this );
345             child_1.ref();
346             var child_2 = new Xcls_Box12( _this );
347             child_2.ref();
348             this.el.append_page (  child_2.el , _this.label_status.el );
349             var child_3 = new Xcls_Box15( _this );
350             child_3.ref();
351             this.el.append_page (  child_3.el , _this.label_diff.el );
352         }
353
354         // user defined functions
355     }
356     public class Xcls_label_status : Object
357     {
358         public Gtk.Label el;
359         private RepoStatusPopover  _this;
360
361
362             // my vars (def)
363
364         // ctor
365         public Xcls_label_status(RepoStatusPopover _owner )
366         {
367             _this = _owner;
368             _this.label_status = this;
369             this.el = new Gtk.Label( "Status" );
370
371             // my vars (dec)
372
373             // set gobject values
374         }
375
376         // user defined functions
377     }
378
379     public class Xcls_label_diff : Object
380     {
381         public Gtk.Label el;
382         private RepoStatusPopover  _this;
383
384
385             // my vars (def)
386
387         // ctor
388         public Xcls_label_diff(RepoStatusPopover _owner )
389         {
390             _this = _owner;
391             _this.label_diff = this;
392             this.el = new Gtk.Label( "Diff" );
393
394             // my vars (dec)
395
396             // set gobject values
397         }
398
399         // user defined functions
400     }
401
402     public class Xcls_Box12 : Object
403     {
404         public Gtk.Box el;
405         private RepoStatusPopover  _this;
406
407
408             // my vars (def)
409
410         // ctor
411         public Xcls_Box12(RepoStatusPopover _owner )
412         {
413             _this = _owner;
414             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
415
416             // my vars (dec)
417
418             // set gobject values
419             this.el.homogeneous = false;
420             var child_0 = new Xcls_ScrolledWindow13( _this );
421             child_0.ref();
422             this.el.pack_start (  child_0.el , true,true,0 );
423         }
424
425         // user defined functions
426     }
427     public class Xcls_ScrolledWindow13 : Object
428     {
429         public Gtk.ScrolledWindow el;
430         private RepoStatusPopover  _this;
431
432
433             // my vars (def)
434
435         // ctor
436         public Xcls_ScrolledWindow13(RepoStatusPopover _owner )
437         {
438             _this = _owner;
439             this.el = new Gtk.ScrolledWindow( null, null );
440
441             // my vars (dec)
442
443             // set gobject values
444             var child_0 = new Xcls_status_view( _this );
445             child_0.ref();
446             this.el.add (  child_0.el  );
447         }
448
449         // user defined functions
450     }
451     public class Xcls_status_view : Object
452     {
453         public Gtk.SourceView el;
454         private RepoStatusPopover  _this;
455
456
457             // my vars (def)
458
459         // ctor
460         public Xcls_status_view(RepoStatusPopover _owner )
461         {
462             _this = _owner;
463             _this.status_view = this;
464             this.el = new Gtk.SourceView();
465
466             // my vars (dec)
467
468             // init method
469
470             var description =   Pango.FontDescription.from_string("monospace");
471                 description.set_size(9000);
472                 this.el.override_font(description);
473         }
474
475         // user defined functions
476     }
477
478
479
480     public class Xcls_Box15 : Object
481     {
482         public Gtk.Box el;
483         private RepoStatusPopover  _this;
484
485
486             // my vars (def)
487
488         // ctor
489         public Xcls_Box15(RepoStatusPopover _owner )
490         {
491             _this = _owner;
492             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
493
494             // my vars (dec)
495
496             // set gobject values
497             this.el.homogeneous = false;
498             var child_0 = new Xcls_ScrolledWindow16( _this );
499             child_0.ref();
500             this.el.pack_start (  child_0.el , true,true,0 );
501         }
502
503         // user defined functions
504     }
505     public class Xcls_ScrolledWindow16 : Object
506     {
507         public Gtk.ScrolledWindow el;
508         private RepoStatusPopover  _this;
509
510
511             // my vars (def)
512
513         // ctor
514         public Xcls_ScrolledWindow16(RepoStatusPopover _owner )
515         {
516             _this = _owner;
517             this.el = new Gtk.ScrolledWindow( null, null );
518
519             // my vars (dec)
520
521             // set gobject values
522             this.el.height_request = 400;
523             var child_0 = new Xcls_diff_view( _this );
524             child_0.ref();
525             this.el.add (  child_0.el  );
526         }
527
528         // user defined functions
529     }
530     public class Xcls_diff_view : Object
531     {
532         public Gtk.SourceView el;
533         private RepoStatusPopover  _this;
534
535
536             // my vars (def)
537
538         // ctor
539         public Xcls_diff_view(RepoStatusPopover _owner )
540         {
541             _this = _owner;
542             _this.diff_view = this;
543             this.el = new Gtk.SourceView();
544
545             // my vars (dec)
546
547             // init method
548
549             var description =   Pango.FontDescription.from_string("monospace");
550                 description.set_size(9000);
551                 this.el.override_font(description);
552         }
553
554         // user defined functions
555     }
556
557
558
559
560     public class Xcls_Box18 : Object
561     {
562         public Gtk.Box el;
563         private RepoStatusPopover  _this;
564
565
566             // my vars (def)
567
568         // ctor
569         public Xcls_Box18(RepoStatusPopover _owner )
570         {
571             _this = _owner;
572             this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
573
574             // my vars (dec)
575
576             // set gobject values
577             this.el.homogeneous = true;
578             this.el.expand = false;
579             this.el.vexpand = false;
580             var child_0 = new Xcls_Toolbar19( _this );
581             child_0.ref();
582             this.el.add (  child_0.el  );
583         }
584
585         // user defined functions
586     }
587     public class Xcls_Toolbar19 : Object
588     {
589         public Gtk.Toolbar el;
590         private RepoStatusPopover  _this;
591
592
593             // my vars (def)
594
595         // ctor
596         public Xcls_Toolbar19(RepoStatusPopover _owner )
597         {
598             _this = _owner;
599             this.el = new Gtk.Toolbar();
600
601             // my vars (dec)
602
603             // set gobject values
604             this.el.toolbar_style = Gtk.ToolbarStyle.BOTH_HORIZ;
605             var child_0 = new Xcls_ToolButton20( _this );
606             child_0.ref();
607             this.el.add (  child_0.el  );
608             var child_1 = new Xcls_ToolButton21( _this );
609             child_1.ref();
610             this.el.add (  child_1.el  );
611             var child_2 = new Xcls_ToolButton22( _this );
612             child_2.ref();
613             this.el.add (  child_2.el  );
614         }
615
616         // user defined functions
617     }
618     public class Xcls_ToolButton20 : Object
619     {
620         public Gtk.ToolButton el;
621         private RepoStatusPopover  _this;
622
623
624             // my vars (def)
625
626         // ctor
627         public Xcls_ToolButton20(RepoStatusPopover _owner )
628         {
629             _this = _owner;
630             this.el = new Gtk.ToolButton(new Gtk.Image.from_icon_name ("gtk-add", Gtk.IconSize.SMALL_TOOLBAR), null);;
631
632             // my vars (dec)
633
634             // set gobject values
635             this.el.label = "Create Branch / Start ticket";
636             this.el.is_important = true;
637
638             //listeners
639             this.el.button_press_event.connect( () => {
640                var oldq = new Gee.ArrayList<GitMonitorQueue>();  
641             
642                 Clones.singleton().el.response(-1);
643                 NewBranch.singleton().show(_this.repo, oldq);
644             
645                 return false;
646             });
647         }
648
649         // user defined functions
650     }
651
652     public class Xcls_ToolButton21 : Object
653     {
654         public Gtk.ToolButton el;
655         private RepoStatusPopover  _this;
656
657
658             // my vars (def)
659
660         // ctor
661         public Xcls_ToolButton21(RepoStatusPopover _owner )
662         {
663             _this = _owner;
664             this.el = new Gtk.ToolButton(new Gtk.Image.from_icon_name ("gtk-goto-top", Gtk.IconSize.SMALL_TOOLBAR), null);;
665
666             // my vars (dec)
667
668             // set gobject values
669             this.el.label = "Merge branch/  ticket";
670             this.el.is_important = true;
671
672             //listeners
673             this.el.button_press_event.connect( () => {
674             
675                _this.el.hide();
676                Clones.singleton().el.response(-1);
677                if (_this.repo.activeTicket != null) {
678                    MergeBranch.singleton().show(_this.repo.activeTicket, null);   
679                }
680                 return false;
681             });
682         }
683
684         // user defined functions
685     }
686
687     public class Xcls_ToolButton22 : Object
688     {
689         public Gtk.ToolButton el;
690         private RepoStatusPopover  _this;
691
692
693             // my vars (def)
694
695         // ctor
696         public Xcls_ToolButton22(RepoStatusPopover _owner )
697         {
698             _this = _owner;
699             this.el = new Gtk.ToolButton(new Gtk.Image.from_icon_name ("gtk-new", Gtk.IconSize.SMALL_TOOLBAR), null);;
700
701             // my vars (dec)
702
703             // set gobject values
704             this.el.label = "Create Ticket";
705             this.el.is_important = true;
706
707             //listeners
708             this.el.button_press_event.connect( () => {
709               
710             
711             
712                   Clones.singleton().el.response(-1);
713               
714                _this.el.hide();
715                Ticket.singleton().show( _this.repo);
716                
717                 return false;
718             });
719         }
720
721         // user defined functions
722     }
723
724
725
726
727 }