fix branching and ticket selection
[gitlive] / MergeBranch.vala
1 static MergeBranch  _MergeBranch;
2
3 public class MergeBranch : Object
4 {
5     public Gtk.Dialog el;
6     private MergeBranch  _this;
7
8     public static MergeBranch singleton()
9     {
10         if (_MergeBranch == null) {
11             _MergeBranch= new MergeBranch();
12         }
13         return _MergeBranch;
14     }
15     public Xcls_table table;
16     public Xcls_actionsel actionsel;
17     public Xcls_actioncellrenderer actioncellrenderer;
18     public Xcls_actionmodel actionmodel;
19     public Xcls_projectsel projectsel;
20     public Xcls_prcellrenderer prcellrenderer;
21     public Xcls_prmodel prmodel;
22     public Xcls_ticketsel ticketsel;
23     public Xcls_dbcellrenderer dbcellrenderer;
24     public Xcls_dbmodel dbmodel;
25     public Xcls_btn_not_me btn_not_me;
26     public Xcls_btn_closed btn_closed;
27     public Xcls_name name;
28     public Xcls_label_diff label_diff;
29     public Xcls_label_ticket label_ticket;
30     public Xcls_diff_view diff_view;
31     public Xcls_scrolled_window scrolled_window;
32     public Xcls_view view;
33     public Xcls_spinner spinner;
34     public Xcls_mergebtn mergebtn;
35
36         // my vars (def)
37     public GitRepo repo;
38     public RooTicket? ticket;
39     public bool running;
40
41     // ctor
42     public MergeBranch()
43     {
44         _this = this;
45         this.el = new Gtk.Dialog();
46
47         // my vars (dec)
48         this.ticket = null;
49         this.running = false;
50
51         // set gobject values
52         this.el.title = "Merge Branch";
53         this.el.default_height = 200;
54         this.el.default_width = 500;
55         this.el.deletable = true;
56         this.el.modal = true;
57         var child_0 = new Xcls_Box2( _this );
58         child_0.ref();
59         this.el.get_content_area().add (  child_0.el  );
60         var child_1 = new Xcls_Button32( _this );
61         child_1.ref();
62         this.el.add_action_widget (  child_1.el , 0 );
63         var child_2 = new Xcls_mergebtn( _this );
64         child_2.ref();
65         this.el.add_action_widget (  child_2.el , 1 );
66
67         //listeners
68         this.el.delete_event.connect( (self, event) => {
69             this.el.hide();
70             return true; 
71             //test  
72         });
73         this.el.response.connect( (self, response_id) =>  { 
74           
75                 GLib.debug("got %d", (int) response_id);
76                 if (response_id < 1) {
77                     _this.el.hide();    
78                     this.running = false; 
79                 GitMonitor.gitmonitor.start();
80                         return;
81                 }
82                 
83                 
84                 
85                  /*
86                 // have they selected a ticket..
87                 // make that the current active ticket?
88                 // we really need to store locally what ticket is being worked on..
89                 // in theory we could be working on multiple project and not merging..
90                 // -- each repo would have their active ticket (only one per repo)
91                 // -- so we could just store that in there
92                 // -- initial load can check the contents of the ticket files on first scan.
93                 var ticket_id = _this.ticketsel.selectedTicketId();
94                 
95             if (this.repo != null) {
96                 var bn = _this.name.el.get_text();
97                 if (ticket_id != "" ) {
98                                 this.repo.setActiveTicket( RooTicket.singleton().getById(ticket_id), bn);
99                         } else {
100                                 this.repo.createBranchNamed(bn);
101                         }
102             }
103                 */
104                 
105                 if (this.repo != null) {
106                         repo.doMerge(
107                                 _this.actionsel.selectedAction(), 
108                                 _this.ticketsel.selectedTicketId(),
109                                 _this.name.el.get_text()
110                         );
111                 
112                 } else {
113                         GitRepo.doMerges(
114                                 _this.actionsel.selectedAction(), 
115                                 _this.ticketsel.selectedTicketId(),
116                                 _this.name.el.get_text()
117                         );
118                 }
119                 this.running = false; 
120         
121                  
122                 _this.el.hide();        
123                 GitMonitor.gitmonitor.start();
124         
125                  
126         });
127     }
128
129     // user defined functions
130     public   void show (  RooTicket ticket, GitRepo? repo ) 
131     {
132          // this.el.set_gravity(Gdk.Gravity.NORTH);
133         if (this.running) {
134                 return;
135         }
136         GitMonitor.gitmonitor.stop();
137         
138         _this.el.show_all();
139         
140         _this.table.el.hide();
141         _this.scrolled_window.el.hide();
142         _this.spinner.el.show();
143         _this.spinner.el.start();       
144         this.el.set_keep_above(true);    
145         this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
146                 GLib.debug("Loading tickets"); 
147      
148         
149         this.ticket = ticket;
150         this.repo = repo;
151         
152         
153         Timeout.add_seconds(1, () => {
154         
155             _this.prmodel.loadProjects(ticket.project_id);
156         
157             _this.diff_view.el.get_buffer().set_text(
158                 repo != null ? repo.previewMerge() : GitRepo.previewMerges(ticket.id)
159                 );              
160                 // if we are not working on a ticket, then we should be able to pick one?
161                 _this.dbmodel.loadTickets(ticket.project_id);
162                 _this.actionmodel.loadActions();
163                 _this.mergebtn.updateState();
164                 _this.view.loadTicket(ticket.id);
165                 _this.spinner.el.stop();
166                 _this.spinner.el.hide();        
167     
168                 this.table.el.show();
169                 return false;
170         });
171         
172         this.el.run();
173          
174     }
175     public class Xcls_Box2 : Object
176     {
177         public Gtk.Box el;
178         private MergeBranch  _this;
179
180
181             // my vars (def)
182
183         // ctor
184         public Xcls_Box2(MergeBranch _owner )
185         {
186             _this = _owner;
187             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
188
189             // my vars (dec)
190
191             // set gobject values
192             var child_0 = new Xcls_table( _this );
193             child_0.ref();
194             this.el.pack_start (  child_0.el , false,false,0 );
195             var child_1 = new Xcls_Notebook22( _this );
196             child_1.ref();
197             this.el.add (  child_1.el  );
198             var child_2 = new Xcls_spinner( _this );
199             child_2.ref();
200             this.el.add (  child_2.el  );
201         }
202
203         // user defined functions
204     }
205     public class Xcls_table : Object
206     {
207         public Gtk.Table el;
208         private MergeBranch  _this;
209
210
211             // my vars (def)
212
213         // ctor
214         public Xcls_table(MergeBranch _owner )
215         {
216             _this = _owner;
217             _this.table = this;
218             this.el = new Gtk.Table( 4, 2, false );
219
220             // my vars (dec)
221
222             // set gobject values
223             this.el.margin = 2;
224             this.el.column_spacing = 2;
225             this.el.vexpand = false;
226             var child_0 = new Xcls_Label4( _this );
227             child_0.ref();
228             this.el.attach_defaults (  child_0.el , 0,1,0,1 );
229             var child_1 = new Xcls_actionsel( _this );
230             child_1.ref();
231             this.el.attach_defaults (  child_1.el , 1,2,0,1 );
232             var child_2 = new Xcls_Label8( _this );
233             child_2.ref();
234             this.el.attach_defaults (  child_2.el , 0,1,1,2 );
235             var child_3 = new Xcls_projectsel( _this );
236             child_3.ref();
237             this.el.attach_defaults (  child_3.el , 1,2,1,2 );
238             var child_4 = new Xcls_Label12( _this );
239             child_4.ref();
240             this.el.attach_defaults (  child_4.el , 0,1,2,3 );
241             var child_5 = new Xcls_ticketsel( _this );
242             child_5.ref();
243             this.el.attach_defaults (  child_5.el , 1,2,2,3 );
244             var child_6 = new Xcls_Box16( _this );
245             child_6.ref();
246             this.el.attach_defaults (  child_6.el , 0,2,3,4 );
247             var child_7 = new Xcls_Label20( _this );
248             child_7.ref();
249             this.el.attach_defaults (  child_7.el , 0,1,4,5 );
250             var child_8 = new Xcls_name( _this );
251             child_8.ref();
252             this.el.attach_defaults (  child_8.el , 1,2,4,5 );
253         }
254
255         // user defined functions
256     }
257     public class Xcls_Label4 : Object
258     {
259         public Gtk.Label el;
260         private MergeBranch  _this;
261
262
263             // my vars (def)
264
265         // ctor
266         public Xcls_Label4(MergeBranch _owner )
267         {
268             _this = _owner;
269             this.el = new Gtk.Label( "Do what?" );
270
271             // my vars (dec)
272
273             // set gobject values
274             this.el.margin_right = 3;
275             this.el.halign = Gtk.Align.END;
276             this.el.visible = true;
277         }
278
279         // user defined functions
280     }
281
282     public class Xcls_actionsel : Object
283     {
284         public Gtk.ComboBox el;
285         private MergeBranch  _this;
286
287
288             // my vars (def)
289         public bool loading;
290
291         // ctor
292         public Xcls_actionsel(MergeBranch _owner )
293         {
294             _this = _owner;
295             _this.actionsel = this;
296             this.el = new Gtk.ComboBox();
297
298             // my vars (dec)
299             this.loading = false;
300
301             // set gobject values
302             this.el.hexpand = true;
303             var child_0 = new Xcls_actioncellrenderer( _this );
304             child_0.ref();
305             this.el.pack_start (  child_0.el , true );
306             var child_1 = new Xcls_actionmodel( _this );
307             child_1.ref();
308             this.el.set_model (  child_1.el  );
309
310             // init method
311
312             this.el.add_attribute(_this.actioncellrenderer.el , "markup", 1 );
313
314             //listeners
315             this.el.changed.connect( () => {
316                 if (this.loading) {
317                         return;
318                 }
319                 _this.name.updateText();
320                 _this.mergebtn.updateState();
321                 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
322             });
323         }
324
325         // user defined functions
326         public string selectedAction () {
327                 Gtk.TreeIter iter;
328                 Value val1;
329          
330                 this.el.get_active_iter (out iter);
331                 _this.actionmodel.el.get_value (iter, 0, out val1);
332         
333                 return  (string) val1;
334         }
335     }
336     public class Xcls_actioncellrenderer : Object
337     {
338         public Gtk.CellRendererText el;
339         private MergeBranch  _this;
340
341
342             // my vars (def)
343
344         // ctor
345         public Xcls_actioncellrenderer(MergeBranch _owner )
346         {
347             _this = _owner;
348             _this.actioncellrenderer = this;
349             this.el = new Gtk.CellRendererText();
350
351             // my vars (dec)
352
353             // set gobject values
354         }
355
356         // user defined functions
357     }
358
359     public class Xcls_actionmodel : Object
360     {
361         public Gtk.ListStore el;
362         private MergeBranch  _this;
363
364
365             // my vars (def)
366
367         // ctor
368         public Xcls_actionmodel(MergeBranch _owner )
369         {
370             _this = _owner;
371             _this.actionmodel = this;
372             this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
373
374             // my vars (dec)
375
376             // set gobject values
377         }
378
379         // user defined functions
380         public void loadActions () {
381         
382          
383             
384             _this.actionsel.loading = true;
385         
386             this.el.clear();                                    
387             Gtk.TreeIter iter;
388             var el = this.el;
389             
390             el.append(out iter);
391         
392             
393             el.set_value(iter, 0, "");
394             el.set_value(iter, 1, "-- select action  --");
395             
396             _this.actionsel.el.set_active_iter(iter);
397         
398             el.append(out iter);    
399             el.set_value(iter, 0, "CLOSE");
400             el.set_value(iter, 1, "Merge changes to master - and CLOSE ticket");
401                 
402                 
403             el.append(out iter);    
404             el.set_value(iter, 0, "LEAVE");
405             el.set_value(iter, 1, "Merge changes to master - and LEAVE ticket open");
406         
407             el.append(out iter);    
408             el.set_value(iter, 0, "MASTER");
409             el.set_value(iter, 1, "Merge changes FROM master into this branch");    
410             
411             el.append(out iter);    
412             el.set_value(iter, 0, "EXIT");
413             el.set_value(iter, 1, "Switch back to MASTER branch - no merge");    
414             
415             
416             
417             _this.actionsel.loading = false;
418              //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);          
419                                              
420         }
421     }
422
423
424     public class Xcls_Label8 : Object
425     {
426         public Gtk.Label el;
427         private MergeBranch  _this;
428
429
430             // my vars (def)
431
432         // ctor
433         public Xcls_Label8(MergeBranch _owner )
434         {
435             _this = _owner;
436             this.el = new Gtk.Label( "Project" );
437
438             // my vars (dec)
439
440             // set gobject values
441             this.el.margin_right = 3;
442             this.el.halign = Gtk.Align.END;
443             this.el.visible = true;
444         }
445
446         // user defined functions
447     }
448
449     public class Xcls_projectsel : Object
450     {
451         public Gtk.ComboBox el;
452         private MergeBranch  _this;
453
454
455             // my vars (def)
456         public bool loading;
457
458         // ctor
459         public Xcls_projectsel(MergeBranch _owner )
460         {
461             _this = _owner;
462             _this.projectsel = this;
463             this.el = new Gtk.ComboBox.with_entry();
464
465             // my vars (dec)
466             this.loading = false;
467
468             // set gobject values
469             this.el.hexpand = true;
470             var child_0 = new Xcls_prcellrenderer( _this );
471             child_0.ref();
472             this.el.pack_start (  child_0.el , true );
473             var child_1 = new Xcls_prmodel( _this );
474             child_1.ref();
475             this.el.set_model (  child_1.el  );
476
477             // init method
478
479             this.el.set_entry_text_column(1);
480             this.el.get_child().set_sensitive(false);
481
482             //listeners
483             this.el.changed.connect( () => {
484                 if (this.loading) {
485                         return;
486                 }
487                 var project_id = this.selectedProjectId();
488                 _this.dbmodel.loadTickets(project_id);
489                 
490                 
491                 /*if (this.loading) {
492                         return;
493                 }
494                 var ticket_id = this.selectedTicketId();
495                 
496                 var name = RooTicket.singleton().usernameLocal();
497                 
498                 if (ticket_id == "" || ticket_id == null) {
499                 
500                         var dt = new  DateTime.now_local();
501                         _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
502                         return;
503                 }
504                 
505                 
506                 var ticket = RooTicket.singleton().getById(ticket_id);
507                
508                 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
509                 
510                 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
511                 */
512             });
513         }
514
515         // user defined functions
516         public string selectedProjectId () {
517                 Gtk.TreeIter iter;
518                 Value val1;
519          
520          
521                 this.el.get_active_iter (out iter);
522                 _this.prmodel.el.get_value (iter, 0, out val1);
523          
524         
525                 return  (string) val1;
526                 
527                 
528                 
529                 
530         }
531     }
532     public class Xcls_prcellrenderer : Object
533     {
534         public Gtk.CellRendererText el;
535         private MergeBranch  _this;
536
537
538             // my vars (def)
539
540         // ctor
541         public Xcls_prcellrenderer(MergeBranch _owner )
542         {
543             _this = _owner;
544             _this.prcellrenderer = this;
545             this.el = new Gtk.CellRendererText();
546
547             // my vars (dec)
548
549             // set gobject values
550         }
551
552         // user defined functions
553     }
554
555     public class Xcls_prmodel : Object
556     {
557         public Gtk.ListStore el;
558         private MergeBranch  _this;
559
560
561             // my vars (def)
562
563         // ctor
564         public Xcls_prmodel(MergeBranch _owner )
565         {
566             _this = _owner;
567             _this.prmodel = this;
568             this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
569
570             // my vars (dec)
571
572             // set gobject values
573         }
574
575         // user defined functions
576         public void loadProjects (string id) {
577         
578         
579             
580             _this.projectsel.loading = true;
581         
582             this.el.clear();                                    
583             Gtk.TreeIter iter;
584             var el = this.el;
585             
586             el.append(out iter);
587         
588             
589             el.set_value(iter, 0, "");
590             el.set_value(iter, 1, "-- select a project --");
591             if (id == "") {
592                     _this.projectsel.el.set_active_iter(iter);
593             }
594           
595             foreach(var project in RooProject.projects()) {
596             
597                 el.append(out iter);
598                 
599                 el.set_value(iter, 0, project.id);
600                 el.set_value(iter, 1,  project.name );
601                 if (id == project.id) {
602                            _this.projectsel.el.set_active_iter(iter);
603                     }   
604                 
605             }
606             
607             _this.projectsel.loading = false;
608              //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);          
609                                              
610         }
611     }
612
613
614     public class Xcls_Label12 : Object
615     {
616         public Gtk.Label el;
617         private MergeBranch  _this;
618
619
620             // my vars (def)
621
622         // ctor
623         public Xcls_Label12(MergeBranch _owner )
624         {
625             _this = _owner;
626             this.el = new Gtk.Label( "Select Ticket" );
627
628             // my vars (dec)
629
630             // set gobject values
631             this.el.margin_right = 3;
632             this.el.halign = Gtk.Align.END;
633             this.el.justify = Gtk.Justification.RIGHT;
634             this.el.xalign = 0.900000f;
635             this.el.visible = true;
636         }
637
638         // user defined functions
639     }
640
641     public class Xcls_ticketsel : Object
642     {
643         public Gtk.ComboBox el;
644         private MergeBranch  _this;
645
646
647             // my vars (def)
648         public bool loading;
649
650         // ctor
651         public Xcls_ticketsel(MergeBranch _owner )
652         {
653             _this = _owner;
654             _this.ticketsel = this;
655             this.el = new Gtk.ComboBox.with_entry();
656
657             // my vars (dec)
658             this.loading = false;
659
660             // set gobject values
661             var child_0 = new Xcls_dbcellrenderer( _this );
662             child_0.ref();
663             this.el.pack_start (  child_0.el , true );
664             var child_1 = new Xcls_dbmodel( _this );
665             child_1.ref();
666             this.el.set_model (  child_1.el  );
667
668             // init method
669
670             //this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
671             this.el.set_entry_text_column(1);
672             this.el.get_child().set_sensitive(false);
673
674             //listeners
675             this.el.changed.connect( () => {
676                 if (this.loading) {
677                         return;
678                 }
679                   
680                 _this.view.loadTicket(this.selectedTicketId());
681                  _this.name.updateText();
682                 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
683             });
684         }
685
686         // user defined functions
687         public string selectedTicketId () {
688         Gtk.TreeIter iter;
689                 Value val1;
690          
691          
692                 if (!this.el.get_active_iter (out iter)) {
693                         return "";
694                 }
695                  
696                 _this.dbmodel.el.get_value (iter, 0, out val1);
697          
698         
699                 return  (string) val1;
700                 
701                 
702                 
703                 
704         }
705     }
706     public class Xcls_dbcellrenderer : Object
707     {
708         public Gtk.CellRendererText el;
709         private MergeBranch  _this;
710
711
712             // my vars (def)
713
714         // ctor
715         public Xcls_dbcellrenderer(MergeBranch _owner )
716         {
717             _this = _owner;
718             _this.dbcellrenderer = this;
719             this.el = new Gtk.CellRendererText();
720
721             // my vars (dec)
722
723             // set gobject values
724         }
725
726         // user defined functions
727     }
728
729     public class Xcls_dbmodel : Object
730     {
731         public Gtk.ListStore el;
732         private MergeBranch  _this;
733
734
735             // my vars (def)
736
737         // ctor
738         public Xcls_dbmodel(MergeBranch _owner )
739         {
740             _this = _owner;
741             _this.dbmodel = this;
742             this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
743
744             // my vars (dec)
745
746             // set gobject values
747         }
748
749         // user defined functions
750         public void loadTickets (string project_id  ) {
751         
752         
753             
754             // fixme .. get project id from selection..
755             
756              RooTicket.singleton().loadTickets(
757                                 project_id,
758                                 _this.btn_not_me.el.active ? RooTicket.Who.ANYBODY :  RooTicket.Who.ME,
759                                  _this.btn_closed.el.active ? RooTicket.Status.ALL :  RooTicket.Status.ACTIVE
760                          );
761                 
762             _this.ticketsel.loading = true;
763         
764             this.el.clear();                                    
765             Gtk.TreeIter iter;
766             var el = this.el;
767             
768             el.append(out iter);
769         
770             
771             el.set_value(iter, 0, "");
772             el.set_value(iter, 1, "-- select a ticket --");
773             
774             _this.ticketsel.el.set_active_iter(iter);
775             
776             if (_this.ticket != null &&  _this.ticket.id == "-1") {
777                         el.append(out iter);
778                         el.set_value(iter, 0, "-1");
779                         el.set_value(iter, 1, "Temporary Branch - No ticket specified/relivant");
780                 _this.ticketsel.el.set_active_iter(iter);       
781              }
782             
783             
784             
785             var tickets = RooTicket.singleton().tickets;
786             foreach(var ticket in tickets) {
787             
788                 el.append(out iter);
789                 
790                 el.set_value(iter, 0, ticket.id);
791                 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
792                 
793                 if (_this.ticket != null && _this.ticket.id == ticket.id) {
794                             _this.ticketsel.el.set_active_iter(iter);
795                 }
796                 
797             }
798             
799             _this.ticketsel.loading = false;
800              //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);          
801                                              
802         }
803     }
804
805
806     public class Xcls_Box16 : Object
807     {
808         public Gtk.Box el;
809         private MergeBranch  _this;
810
811
812             // my vars (def)
813
814         // ctor
815         public Xcls_Box16(MergeBranch _owner )
816         {
817             _this = _owner;
818             this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
819
820             // my vars (dec)
821
822             // set gobject values
823             var child_0 = new Xcls_btn_not_me( _this );
824             child_0.ref();
825             this.el.add (  child_0.el  );
826             var child_1 = new Xcls_btn_closed( _this );
827             child_1.ref();
828             this.el.add (  child_1.el  );
829             var child_2 = new Xcls_Label19( _this );
830             child_2.ref();
831             this.el.add (  child_2.el  );
832         }
833
834         // user defined functions
835     }
836     public class Xcls_btn_not_me : Object
837     {
838         public Gtk.CheckButton el;
839         private MergeBranch  _this;
840
841
842             // my vars (def)
843
844         // ctor
845         public Xcls_btn_not_me(MergeBranch _owner )
846         {
847             _this = _owner;
848             _this.btn_not_me = this;
849             this.el = new Gtk.CheckButton();
850
851             // my vars (dec)
852
853             // set gobject values
854             this.el.label = "Show tickets not assigned to me";
855
856             //listeners
857             this.el.toggled.connect( () => {
858                 var project_id = _this.projectsel.selectedProjectId();
859                 _this.dbmodel.loadTickets(project_id);  
860             });
861         }
862
863         // user defined functions
864     }
865
866     public class Xcls_btn_closed : Object
867     {
868         public Gtk.CheckButton el;
869         private MergeBranch  _this;
870
871
872             // my vars (def)
873
874         // ctor
875         public Xcls_btn_closed(MergeBranch _owner )
876         {
877             _this = _owner;
878             _this.btn_closed = this;
879             this.el = new Gtk.CheckButton();
880
881             // my vars (dec)
882
883             // set gobject values
884             this.el.label = "Show closed Tickets";
885
886             //listeners
887             this.el.toggled.connect( () => {
888                 var project_id = _this.projectsel.selectedProjectId();
889                 _this.dbmodel.loadTickets(project_id);  
890                  
891             });
892         }
893
894         // user defined functions
895     }
896
897     public class Xcls_Label19 : Object
898     {
899         public Gtk.Label el;
900         private MergeBranch  _this;
901
902
903             // my vars (def)
904
905         // ctor
906         public Xcls_Label19(MergeBranch _owner )
907         {
908             _this = _owner;
909             this.el = new Gtk.Label( "<a href=\"refresh\">Refresh Ticket list</a>" );
910
911             // my vars (dec)
912
913             // set gobject values
914             this.el.halign = Gtk.Align.END;
915             this.el.hexpand = true;
916             this.el.use_markup = true;
917
918             //listeners
919             this.el.activate_link.connect( (uri) => {
920                 if (uri == "refresh") {
921                         RooProject.reload();
922                         var curproj = RooProject.getProjectByRepo(_this.repo);
923                          _this.prmodel.loadProjects(curproj == null ? "": curproj.id);
924             
925                         _this.dbmodel.loadTickets(curproj == null ? "": curproj.id);            
926                 }
927                 return true;
928             });
929         }
930
931         // user defined functions
932     }
933
934
935     public class Xcls_Label20 : Object
936     {
937         public Gtk.Label el;
938         private MergeBranch  _this;
939
940
941             // my vars (def)
942
943         // ctor
944         public Xcls_Label20(MergeBranch _owner )
945         {
946             _this = _owner;
947             this.el = new Gtk.Label( "Use this commit message" );
948
949             // my vars (dec)
950
951             // set gobject values
952             this.el.margin_right = 3;
953             this.el.halign = Gtk.Align.END;
954         }
955
956         // user defined functions
957     }
958
959     public class Xcls_name : Object
960     {
961         public Gtk.Entry el;
962         private MergeBranch  _this;
963
964
965             // my vars (def)
966
967         // ctor
968         public Xcls_name(MergeBranch _owner )
969         {
970             _this = _owner;
971             _this.name = this;
972             this.el = new Gtk.Entry();
973
974             // my vars (dec)
975
976             // set gobject values
977             this.el.visible = true;
978         }
979
980         // user defined functions
981         public void updateText () {
982                 var ticket_id = _this.ticketsel.selectedTicketId();
983                  
984                 RooTicket ticket = null;
985                 if (ticket_id.length > 0){
986                         ticket = RooTicket.singleton().getById(ticket_id);
987                 }
988                 
989                 var name = RooTicket.singleton().usernameLocal();
990                 var action = _this.actionsel.selectedAction();
991                 this.el.set_editable(true); 
992                 switch (action) {
993                         case "CLOSE": // merge changes and close..
994                                 this.el.set_text("Fix #%s - %s".printf(ticket_id, ticket != null ? ticket.summary : ""));
995                                 break;
996                         case "LEAVE": // partial fix    
997                                 this.el.set_text("Partial Fix #%s - %s".printf(ticket_id,   ticket != null ? ticket.summary : ""));
998                                 break;
999                         case "MASTER": // merge master
1000                         case "EXIT": // just switch back...             
1001                                 this.el.set_editable(false);
1002                                 this.el.set_text(""); // not relivant..                         
1003                                 break;
1004                         default:
1005                         
1006                                 break; /// don't fix the text value.
1007                 }
1008            
1009         }
1010     }
1011
1012
1013     public class Xcls_Notebook22 : Object
1014     {
1015         public Gtk.Notebook el;
1016         private MergeBranch  _this;
1017
1018
1019             // my vars (def)
1020
1021         // ctor
1022         public Xcls_Notebook22(MergeBranch _owner )
1023         {
1024             _this = _owner;
1025             this.el = new Gtk.Notebook();
1026
1027             // my vars (dec)
1028
1029             // set gobject values
1030             this.el.vexpand = true;
1031             var child_0 = new Xcls_label_diff( _this );
1032             child_0.ref();
1033             var child_1 = new Xcls_label_ticket( _this );
1034             child_1.ref();
1035             var child_2 = new Xcls_Box25( _this );
1036             child_2.ref();
1037             this.el.append_page (  child_2.el , _this.label_diff.el );
1038             var child_3 = new Xcls_Box28( _this );
1039             child_3.ref();
1040             this.el.append_page (  child_3.el , _this.label_ticket.el );
1041         }
1042
1043         // user defined functions
1044     }
1045     public class Xcls_label_diff : Object
1046     {
1047         public Gtk.Label el;
1048         private MergeBranch  _this;
1049
1050
1051             // my vars (def)
1052
1053         // ctor
1054         public Xcls_label_diff(MergeBranch _owner )
1055         {
1056             _this = _owner;
1057             _this.label_diff = this;
1058             this.el = new Gtk.Label( "Projected Commit Diff" );
1059
1060             // my vars (dec)
1061
1062             // set gobject values
1063         }
1064
1065         // user defined functions
1066     }
1067
1068     public class Xcls_label_ticket : Object
1069     {
1070         public Gtk.Label el;
1071         private MergeBranch  _this;
1072
1073
1074             // my vars (def)
1075
1076         // ctor
1077         public Xcls_label_ticket(MergeBranch _owner )
1078         {
1079             _this = _owner;
1080             _this.label_ticket = this;
1081             this.el = new Gtk.Label( "Ticket Details" );
1082
1083             // my vars (dec)
1084
1085             // set gobject values
1086         }
1087
1088         // user defined functions
1089     }
1090
1091     public class Xcls_Box25 : Object
1092     {
1093         public Gtk.Box el;
1094         private MergeBranch  _this;
1095
1096
1097             // my vars (def)
1098
1099         // ctor
1100         public Xcls_Box25(MergeBranch _owner )
1101         {
1102             _this = _owner;
1103             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1104
1105             // my vars (dec)
1106
1107             // set gobject values
1108             this.el.homogeneous = false;
1109             var child_0 = new Xcls_ScrolledWindow26( _this );
1110             child_0.ref();
1111             this.el.pack_start (  child_0.el , true,true,0 );
1112         }
1113
1114         // user defined functions
1115     }
1116     public class Xcls_ScrolledWindow26 : Object
1117     {
1118         public Gtk.ScrolledWindow el;
1119         private MergeBranch  _this;
1120
1121
1122             // my vars (def)
1123
1124         // ctor
1125         public Xcls_ScrolledWindow26(MergeBranch _owner )
1126         {
1127             _this = _owner;
1128             this.el = new Gtk.ScrolledWindow( null, null );
1129
1130             // my vars (dec)
1131
1132             // set gobject values
1133             this.el.height_request = 400;
1134             var child_0 = new Xcls_diff_view( _this );
1135             child_0.ref();
1136             this.el.add (  child_0.el  );
1137         }
1138
1139         // user defined functions
1140     }
1141     public class Xcls_diff_view : Object
1142     {
1143         public Gtk.SourceView el;
1144         private MergeBranch  _this;
1145
1146
1147             // my vars (def)
1148
1149         // ctor
1150         public Xcls_diff_view(MergeBranch _owner )
1151         {
1152             _this = _owner;
1153             _this.diff_view = this;
1154             this.el = new Gtk.SourceView();
1155
1156             // my vars (dec)
1157
1158             // init method
1159
1160             var description =   Pango.FontDescription.from_string("monospace");
1161                 description.set_size(9000);
1162                 this.el.override_font(description);
1163                  var lm = Gtk.SourceLanguageManager.get_default();
1164                                 
1165                 ((Gtk.SourceBuffer)(this.el.get_buffer())).set_language(
1166                     lm.get_language("diff")
1167                 );
1168         }
1169
1170         // user defined functions
1171     }
1172
1173
1174
1175     public class Xcls_Box28 : Object
1176     {
1177         public Gtk.Box el;
1178         private MergeBranch  _this;
1179
1180
1181             // my vars (def)
1182
1183         // ctor
1184         public Xcls_Box28(MergeBranch _owner )
1185         {
1186             _this = _owner;
1187             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1188
1189             // my vars (dec)
1190
1191             // set gobject values
1192             this.el.homogeneous = false;
1193             var child_0 = new Xcls_scrolled_window( _this );
1194             child_0.ref();
1195             this.el.add (  child_0.el  );
1196         }
1197
1198         // user defined functions
1199     }
1200     public class Xcls_scrolled_window : Object
1201     {
1202         public Gtk.ScrolledWindow el;
1203         private MergeBranch  _this;
1204
1205
1206             // my vars (def)
1207
1208         // ctor
1209         public Xcls_scrolled_window(MergeBranch _owner )
1210         {
1211             _this = _owner;
1212             _this.scrolled_window = this;
1213             this.el = new Gtk.ScrolledWindow( null, null );
1214
1215             // my vars (dec)
1216
1217             // set gobject values
1218             this.el.height_request = 500;
1219             this.el.vexpand = true;
1220             var child_0 = new Xcls_view( _this );
1221             child_0.ref();
1222             this.el.add (  child_0.el  );
1223
1224             // init method
1225
1226             {
1227                 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1228             }
1229         }
1230
1231         // user defined functions
1232     }
1233     public class Xcls_view : Object
1234     {
1235         public WebKit.WebView el;
1236         private MergeBranch  _this;
1237
1238
1239             // my vars (def)
1240
1241         // ctor
1242         public Xcls_view(MergeBranch _owner )
1243         {
1244             _this = _owner;
1245             _this.view = this;
1246             this.el = new WebKit.WebView();
1247
1248             // my vars (dec)
1249
1250             // set gobject values
1251         }
1252
1253         // user defined functions
1254         public void loadTicket (string tid) {
1255                 int h,w;
1256                 _this.el.get_size(out w, out h);
1257                 
1258                 if (tid == "") {
1259                         _this.scrolled_window.el.hide();
1260                         _this.el.resize(w, 150);
1261                 } else {
1262                         _this.scrolled_window.el.show();
1263                         _this.el.resize(w, 800);
1264                 }
1265                 
1266                 var rs =  RooTicket.singleton();                
1267                 var uri = new WebKit.URIRequest("https://roojs.com/admin.php/MTrack/View/" + tid);
1268                 var hd = uri.get_http_headers();
1269                 var authCode = Base64.encode ("%s:%s".printf(rs.username, rs.password).data);
1270                 hd.append("Authorization", "Basic %s".printf(authCode));
1271                 
1272                  this.el.load_request(uri);
1273         }
1274     }
1275
1276
1277
1278
1279     public class Xcls_spinner : Object
1280     {
1281         public Gtk.Spinner el;
1282         private MergeBranch  _this;
1283
1284
1285             // my vars (def)
1286
1287         // ctor
1288         public Xcls_spinner(MergeBranch _owner )
1289         {
1290             _this = _owner;
1291             _this.spinner = this;
1292             this.el = new Gtk.Spinner();
1293
1294             // my vars (dec)
1295
1296             // set gobject values
1297             this.el.hexpand = true;
1298             this.el.vexpand = true;
1299         }
1300
1301         // user defined functions
1302     }
1303
1304
1305     public class Xcls_Button32 : Object
1306     {
1307         public Gtk.Button el;
1308         private MergeBranch  _this;
1309
1310
1311             // my vars (def)
1312
1313         // ctor
1314         public Xcls_Button32(MergeBranch _owner )
1315         {
1316             _this = _owner;
1317             this.el = new Gtk.Button();
1318
1319             // my vars (dec)
1320
1321             // set gobject values
1322             this.el.relief = Gtk.ReliefStyle.NONE;
1323             this.el.label = "Cancel";
1324         }
1325
1326         // user defined functions
1327     }
1328
1329     public class Xcls_mergebtn : Object
1330     {
1331         public Gtk.Button el;
1332         private MergeBranch  _this;
1333
1334
1335             // my vars (def)
1336
1337         // ctor
1338         public Xcls_mergebtn(MergeBranch _owner )
1339         {
1340             _this = _owner;
1341             _this.mergebtn = this;
1342             this.el = new Gtk.Button();
1343
1344             // my vars (dec)
1345
1346             // set gobject values
1347             this.el.label = "Do Merge";
1348
1349             // init method
1350
1351             {
1352                this.el.get_style_context().add_class("suggested-action");
1353             }
1354         }
1355
1356         // user defined functions
1357         public void updateState () {
1358                 if (_this.actionsel.selectedAction() == "") {
1359                         // need to select an action..
1360                         this.el.set_sensitive(false);
1361                         return;
1362                 
1363                 
1364                 }
1365                         this.el.set_sensitive(true);
1366                         return;
1367         }
1368     }
1369
1370 }