61e267aa433ed0925f351d2ebc220c973759bb79
[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
481             //listeners
482             this.el.changed.connect( () => {
483                 if (this.loading) {
484                         return;
485                 }
486                 var project_id = this.selectedProjectId();
487                 _this.dbmodel.loadTickets(project_id);
488                 
489                 
490                 /*if (this.loading) {
491                         return;
492                 }
493                 var ticket_id = this.selectedTicketId();
494                 
495                 var name = RooTicket.singleton().usernameLocal();
496                 
497                 if (ticket_id == "" || ticket_id == null) {
498                 
499                         var dt = new  DateTime.now_local();
500                         _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
501                         return;
502                 }
503                 
504                 
505                 var ticket = RooTicket.singleton().getById(ticket_id);
506                
507                 _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
508                 
509                 //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
510                 */
511             });
512         }
513
514         // user defined functions
515         public string selectedProjectId () {
516                 Gtk.TreeIter iter;
517                 Value val1;
518          
519          
520                 this.el.get_active_iter (out iter);
521                 _this.prmodel.el.get_value (iter, 0, out val1);
522          
523         
524                 return  (string) val1;
525                 
526                 
527                 
528                 
529         }
530     }
531     public class Xcls_prcellrenderer : Object
532     {
533         public Gtk.CellRendererText el;
534         private MergeBranch  _this;
535
536
537             // my vars (def)
538
539         // ctor
540         public Xcls_prcellrenderer(MergeBranch _owner )
541         {
542             _this = _owner;
543             _this.prcellrenderer = this;
544             this.el = new Gtk.CellRendererText();
545
546             // my vars (dec)
547
548             // set gobject values
549         }
550
551         // user defined functions
552     }
553
554     public class Xcls_prmodel : Object
555     {
556         public Gtk.ListStore el;
557         private MergeBranch  _this;
558
559
560             // my vars (def)
561
562         // ctor
563         public Xcls_prmodel(MergeBranch _owner )
564         {
565             _this = _owner;
566             _this.prmodel = this;
567             this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
568
569             // my vars (dec)
570
571             // set gobject values
572         }
573
574         // user defined functions
575         public void loadProjects (string id) {
576         
577         
578             
579             _this.projectsel.loading = true;
580         
581             this.el.clear();                                    
582             Gtk.TreeIter iter;
583             var el = this.el;
584             
585             el.append(out iter);
586         
587             
588             el.set_value(iter, 0, "");
589             el.set_value(iter, 1, "-- select a project --");
590             if (id == "") {
591                     _this.projectsel.el.set_active_iter(iter);
592             }
593           
594             foreach(var project in RooProject.projects()) {
595             
596                 el.append(out iter);
597                 
598                 el.set_value(iter, 0, project.id);
599                 el.set_value(iter, 1,  project.name );
600                 if (id == project.id) {
601                            _this.projectsel.el.set_active_iter(iter);
602                     }   
603                 
604             }
605             
606             _this.projectsel.loading = false;
607              //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);          
608                                              
609         }
610     }
611
612
613     public class Xcls_Label12 : Object
614     {
615         public Gtk.Label el;
616         private MergeBranch  _this;
617
618
619             // my vars (def)
620
621         // ctor
622         public Xcls_Label12(MergeBranch _owner )
623         {
624             _this = _owner;
625             this.el = new Gtk.Label( "Select Ticket" );
626
627             // my vars (dec)
628
629             // set gobject values
630             this.el.margin_right = 3;
631             this.el.halign = Gtk.Align.END;
632             this.el.justify = Gtk.Justification.RIGHT;
633             this.el.xalign = 0.900000f;
634             this.el.visible = true;
635         }
636
637         // user defined functions
638     }
639
640     public class Xcls_ticketsel : Object
641     {
642         public Gtk.ComboBox el;
643         private MergeBranch  _this;
644
645
646             // my vars (def)
647         public bool loading;
648
649         // ctor
650         public Xcls_ticketsel(MergeBranch _owner )
651         {
652             _this = _owner;
653             _this.ticketsel = this;
654             this.el = new Gtk.ComboBox();
655
656             // my vars (dec)
657             this.loading = true;
658
659             // set gobject values
660             this.el.hexpand = true;
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
672             //listeners
673             this.el.changed.connect( () => {
674                 if (this.loading) {
675                         return;
676                 }
677                 _this.view.loadTicket(this.selectedTicketId());
678                  
679                 _this.name.updateText();
680                 //_this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
681                 
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                 this.el.get_active_iter (out iter);
693                 _this.dbmodel.el.get_value (iter, 0, out val1);
694          
695         
696                 return  (string) val1;
697                 
698                 
699                 
700                 
701         }
702     }
703     public class Xcls_dbcellrenderer : Object
704     {
705         public Gtk.CellRendererText el;
706         private MergeBranch  _this;
707
708
709             // my vars (def)
710
711         // ctor
712         public Xcls_dbcellrenderer(MergeBranch _owner )
713         {
714             _this = _owner;
715             _this.dbcellrenderer = this;
716             this.el = new Gtk.CellRendererText();
717
718             // my vars (dec)
719
720             // set gobject values
721         }
722
723         // user defined functions
724     }
725
726     public class Xcls_dbmodel : Object
727     {
728         public Gtk.ListStore el;
729         private MergeBranch  _this;
730
731
732             // my vars (def)
733
734         // ctor
735         public Xcls_dbmodel(MergeBranch _owner )
736         {
737             _this = _owner;
738             _this.dbmodel = this;
739             this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
740
741             // my vars (dec)
742
743             // set gobject values
744         }
745
746         // user defined functions
747         public void loadTickets (string project_id) {
748         
749             RooTicket.singleton().loadTickets(project_id,RooTicket.Who.ME, RooTicket.Status.ACTIVE);
750             
751             _this.ticketsel.loading = true;
752         
753             this.el.clear();                                    
754             Gtk.TreeIter iter;
755             var el = this.el;
756             
757             el.append(out iter);
758             el.set_value(iter, 0, "");
759             el.set_value(iter, 1, "-- select a ticket --");
760             
761             _this.ticketsel.el.set_active_iter(iter);
762             
763             if (_this.ticket != null &&  _this.ticket.id == "-1") {
764                         el.append(out iter);
765                         el.set_value(iter, 0, "-1");
766                         el.set_value(iter, 1, "Temporary Branch - No ticket specified/relivant");
767                 _this.ticketsel.el.set_active_iter(iter);       
768             }
769             
770             
771             
772             
773             var tickets = RooTicket.singleton().tickets;
774             foreach(var ticket in tickets) {
775             
776                 el.append(out iter);
777         
778                 el.set_value(iter, 0, ticket.id);
779                 el.set_value(iter, 1, "#%s [%s] %s".printf( ticket.id, ticket.project_id_name , ticket.summary));
780                         if (_this.ticket != null && _this.ticket.id == ticket.id) {
781                             _this.ticketsel.el.set_active_iter(iter);
782                     }
783                 
784             }
785             
786             _this.ticketsel.loading = false;
787              //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);          
788                                              
789         }
790     }
791
792
793     public class Xcls_Box16 : Object
794     {
795         public Gtk.Box el;
796         private MergeBranch  _this;
797
798
799             // my vars (def)
800
801         // ctor
802         public Xcls_Box16(MergeBranch _owner )
803         {
804             _this = _owner;
805             this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
806
807             // my vars (dec)
808
809             // set gobject values
810             var child_0 = new Xcls_btn_not_me( _this );
811             child_0.ref();
812             this.el.add (  child_0.el  );
813             var child_1 = new Xcls_btn_closed( _this );
814             child_1.ref();
815             this.el.add (  child_1.el  );
816             var child_2 = new Xcls_Label19( _this );
817             child_2.ref();
818             this.el.add (  child_2.el  );
819         }
820
821         // user defined functions
822     }
823     public class Xcls_btn_not_me : Object
824     {
825         public Gtk.CheckButton el;
826         private MergeBranch  _this;
827
828
829             // my vars (def)
830
831         // ctor
832         public Xcls_btn_not_me(MergeBranch _owner )
833         {
834             _this = _owner;
835             _this.btn_not_me = this;
836             this.el = new Gtk.CheckButton();
837
838             // my vars (dec)
839
840             // set gobject values
841             this.el.label = "Show tickets not assigned to me";
842
843             //listeners
844             this.el.toggled.connect( () => {
845                 var project_id = _this.projectsel.selectedProjectId();
846                 _this.dbmodel.loadTickets(project_id);  
847             });
848         }
849
850         // user defined functions
851     }
852
853     public class Xcls_btn_closed : Object
854     {
855         public Gtk.CheckButton el;
856         private MergeBranch  _this;
857
858
859             // my vars (def)
860
861         // ctor
862         public Xcls_btn_closed(MergeBranch _owner )
863         {
864             _this = _owner;
865             _this.btn_closed = this;
866             this.el = new Gtk.CheckButton();
867
868             // my vars (dec)
869
870             // set gobject values
871             this.el.label = "Show closed Tickets";
872
873             //listeners
874             this.el.toggled.connect( () => {
875                 var project_id = _this.projectsel.selectedProjectId();
876                 _this.dbmodel.loadTickets(project_id);  
877                  
878             });
879         }
880
881         // user defined functions
882     }
883
884     public class Xcls_Label19 : Object
885     {
886         public Gtk.Label el;
887         private MergeBranch  _this;
888
889
890             // my vars (def)
891
892         // ctor
893         public Xcls_Label19(MergeBranch _owner )
894         {
895             _this = _owner;
896             this.el = new Gtk.Label( "<a href=\"refresh\">Refresh Ticket list</a>" );
897
898             // my vars (dec)
899
900             // set gobject values
901             this.el.halign = Gtk.Align.END;
902             this.el.hexpand = true;
903             this.el.use_markup = true;
904
905             //listeners
906             this.el.activate_link.connect( (uri) => {
907                 if (uri == "refresh") {
908                         RooProject.reload();
909                         var curproj = RooProject.getProjectByRepo(_this.repo);
910                          _this.prmodel.loadProjects(curproj == null ? "": curproj.id);
911             
912                         _this.dbmodel.loadTickets(curproj == null ? "": curproj.id);            
913                 }
914                 return true;
915             });
916         }
917
918         // user defined functions
919     }
920
921
922     public class Xcls_Label20 : Object
923     {
924         public Gtk.Label el;
925         private MergeBranch  _this;
926
927
928             // my vars (def)
929
930         // ctor
931         public Xcls_Label20(MergeBranch _owner )
932         {
933             _this = _owner;
934             this.el = new Gtk.Label( "Use this commit message" );
935
936             // my vars (dec)
937
938             // set gobject values
939             this.el.margin_right = 3;
940             this.el.halign = Gtk.Align.END;
941         }
942
943         // user defined functions
944     }
945
946     public class Xcls_name : Object
947     {
948         public Gtk.Entry el;
949         private MergeBranch  _this;
950
951
952             // my vars (def)
953
954         // ctor
955         public Xcls_name(MergeBranch _owner )
956         {
957             _this = _owner;
958             _this.name = this;
959             this.el = new Gtk.Entry();
960
961             // my vars (dec)
962
963             // set gobject values
964             this.el.visible = true;
965         }
966
967         // user defined functions
968         public void updateText () {
969                 var ticket_id = _this.ticketsel.selectedTicketId();
970                 
971                 RooTicket ticket = null;
972                 if (ticket_id.length > 0){
973                         ticket = RooTicket.singleton().getById(ticket_id);
974                 }
975                 
976                 var name = RooTicket.singleton().usernameLocal();
977                 var action = _this.actionsel.selectedAction();
978                 this.el.set_editable(true); 
979                 switch (action) {
980                         case "CLOSE": // merge changes and close..
981                                 this.el.set_text("Fix #%s - %s".printf(ticket_id, ticket != null ? ticket.summary : ""));
982                                 break;
983                         case "LEAVE": // partial fix    
984                                 this.el.set_text("Partial Fix #%s - %s".printf(ticket_id,   ticket != null ? ticket.summary : ""));
985                                 break;
986                         case "MASTER": // merge master
987                         case "EXIT": // just switch back...             
988                                 this.el.set_editable(false);
989                                 this.el.set_text(""); // not relivant..                         
990                                 break;
991                         default:
992                         
993                                 break; /// don't fix the text value.
994                 }
995            
996         }
997     }
998
999
1000     public class Xcls_Notebook22 : Object
1001     {
1002         public Gtk.Notebook el;
1003         private MergeBranch  _this;
1004
1005
1006             // my vars (def)
1007
1008         // ctor
1009         public Xcls_Notebook22(MergeBranch _owner )
1010         {
1011             _this = _owner;
1012             this.el = new Gtk.Notebook();
1013
1014             // my vars (dec)
1015
1016             // set gobject values
1017             this.el.vexpand = true;
1018             var child_0 = new Xcls_label_diff( _this );
1019             child_0.ref();
1020             var child_1 = new Xcls_label_ticket( _this );
1021             child_1.ref();
1022             var child_2 = new Xcls_Box25( _this );
1023             child_2.ref();
1024             this.el.append_page (  child_2.el , _this.label_diff.el );
1025             var child_3 = new Xcls_Box28( _this );
1026             child_3.ref();
1027             this.el.append_page (  child_3.el , _this.label_ticket.el );
1028         }
1029
1030         // user defined functions
1031     }
1032     public class Xcls_label_diff : Object
1033     {
1034         public Gtk.Label el;
1035         private MergeBranch  _this;
1036
1037
1038             // my vars (def)
1039
1040         // ctor
1041         public Xcls_label_diff(MergeBranch _owner )
1042         {
1043             _this = _owner;
1044             _this.label_diff = this;
1045             this.el = new Gtk.Label( "Projected Commit Diff" );
1046
1047             // my vars (dec)
1048
1049             // set gobject values
1050         }
1051
1052         // user defined functions
1053     }
1054
1055     public class Xcls_label_ticket : Object
1056     {
1057         public Gtk.Label el;
1058         private MergeBranch  _this;
1059
1060
1061             // my vars (def)
1062
1063         // ctor
1064         public Xcls_label_ticket(MergeBranch _owner )
1065         {
1066             _this = _owner;
1067             _this.label_ticket = this;
1068             this.el = new Gtk.Label( "Ticket Details" );
1069
1070             // my vars (dec)
1071
1072             // set gobject values
1073         }
1074
1075         // user defined functions
1076     }
1077
1078     public class Xcls_Box25 : Object
1079     {
1080         public Gtk.Box el;
1081         private MergeBranch  _this;
1082
1083
1084             // my vars (def)
1085
1086         // ctor
1087         public Xcls_Box25(MergeBranch _owner )
1088         {
1089             _this = _owner;
1090             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1091
1092             // my vars (dec)
1093
1094             // set gobject values
1095             this.el.homogeneous = false;
1096             var child_0 = new Xcls_ScrolledWindow26( _this );
1097             child_0.ref();
1098             this.el.pack_start (  child_0.el , true,true,0 );
1099         }
1100
1101         // user defined functions
1102     }
1103     public class Xcls_ScrolledWindow26 : Object
1104     {
1105         public Gtk.ScrolledWindow el;
1106         private MergeBranch  _this;
1107
1108
1109             // my vars (def)
1110
1111         // ctor
1112         public Xcls_ScrolledWindow26(MergeBranch _owner )
1113         {
1114             _this = _owner;
1115             this.el = new Gtk.ScrolledWindow( null, null );
1116
1117             // my vars (dec)
1118
1119             // set gobject values
1120             this.el.height_request = 400;
1121             var child_0 = new Xcls_diff_view( _this );
1122             child_0.ref();
1123             this.el.add (  child_0.el  );
1124         }
1125
1126         // user defined functions
1127     }
1128     public class Xcls_diff_view : Object
1129     {
1130         public Gtk.SourceView el;
1131         private MergeBranch  _this;
1132
1133
1134             // my vars (def)
1135
1136         // ctor
1137         public Xcls_diff_view(MergeBranch _owner )
1138         {
1139             _this = _owner;
1140             _this.diff_view = this;
1141             this.el = new Gtk.SourceView();
1142
1143             // my vars (dec)
1144
1145             // init method
1146
1147             var description =   Pango.FontDescription.from_string("monospace");
1148                 description.set_size(9000);
1149                 this.el.override_font(description);
1150                  var lm = Gtk.SourceLanguageManager.get_default();
1151                                 
1152                 ((Gtk.SourceBuffer)(this.el.get_buffer())).set_language(
1153                     lm.get_language("diff")
1154                 );
1155         }
1156
1157         // user defined functions
1158     }
1159
1160
1161
1162     public class Xcls_Box28 : Object
1163     {
1164         public Gtk.Box el;
1165         private MergeBranch  _this;
1166
1167
1168             // my vars (def)
1169
1170         // ctor
1171         public Xcls_Box28(MergeBranch _owner )
1172         {
1173             _this = _owner;
1174             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1175
1176             // my vars (dec)
1177
1178             // set gobject values
1179             this.el.homogeneous = false;
1180             var child_0 = new Xcls_scrolled_window( _this );
1181             child_0.ref();
1182             this.el.add (  child_0.el  );
1183         }
1184
1185         // user defined functions
1186     }
1187     public class Xcls_scrolled_window : Object
1188     {
1189         public Gtk.ScrolledWindow el;
1190         private MergeBranch  _this;
1191
1192
1193             // my vars (def)
1194
1195         // ctor
1196         public Xcls_scrolled_window(MergeBranch _owner )
1197         {
1198             _this = _owner;
1199             _this.scrolled_window = this;
1200             this.el = new Gtk.ScrolledWindow( null, null );
1201
1202             // my vars (dec)
1203
1204             // set gobject values
1205             this.el.height_request = 500;
1206             this.el.vexpand = true;
1207             var child_0 = new Xcls_view( _this );
1208             child_0.ref();
1209             this.el.add (  child_0.el  );
1210
1211             // init method
1212
1213             {
1214                 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1215             }
1216         }
1217
1218         // user defined functions
1219     }
1220     public class Xcls_view : Object
1221     {
1222         public WebKit.WebView el;
1223         private MergeBranch  _this;
1224
1225
1226             // my vars (def)
1227
1228         // ctor
1229         public Xcls_view(MergeBranch _owner )
1230         {
1231             _this = _owner;
1232             _this.view = this;
1233             this.el = new WebKit.WebView();
1234
1235             // my vars (dec)
1236
1237             // set gobject values
1238         }
1239
1240         // user defined functions
1241         public void loadTicket (string tid) {
1242                 int h,w;
1243                 _this.el.get_size(out w, out h);
1244                 
1245                 if (tid == "") {
1246                         _this.scrolled_window.el.hide();
1247                         _this.el.resize(w, 150);
1248                 } else {
1249                         _this.scrolled_window.el.show();
1250                         _this.el.resize(w, 800);
1251                 }
1252                 
1253                 var rs =  RooTicket.singleton();                
1254                 var uri = new WebKit.URIRequest("https://roojs.com/admin.php/MTrack/View/" + tid);
1255                 var hd = uri.get_http_headers();
1256                 var authCode = Base64.encode ("%s:%s".printf(rs.username, rs.password).data);
1257                 hd.append("Authorization", "Basic %s".printf(authCode));
1258                 
1259                  this.el.load_request(uri);
1260         }
1261     }
1262
1263
1264
1265
1266     public class Xcls_spinner : Object
1267     {
1268         public Gtk.Spinner el;
1269         private MergeBranch  _this;
1270
1271
1272             // my vars (def)
1273
1274         // ctor
1275         public Xcls_spinner(MergeBranch _owner )
1276         {
1277             _this = _owner;
1278             _this.spinner = this;
1279             this.el = new Gtk.Spinner();
1280
1281             // my vars (dec)
1282
1283             // set gobject values
1284             this.el.hexpand = true;
1285             this.el.vexpand = true;
1286         }
1287
1288         // user defined functions
1289     }
1290
1291
1292     public class Xcls_Button32 : Object
1293     {
1294         public Gtk.Button el;
1295         private MergeBranch  _this;
1296
1297
1298             // my vars (def)
1299
1300         // ctor
1301         public Xcls_Button32(MergeBranch _owner )
1302         {
1303             _this = _owner;
1304             this.el = new Gtk.Button();
1305
1306             // my vars (dec)
1307
1308             // set gobject values
1309             this.el.relief = Gtk.ReliefStyle.NONE;
1310             this.el.label = "Cancel";
1311         }
1312
1313         // user defined functions
1314     }
1315
1316     public class Xcls_mergebtn : Object
1317     {
1318         public Gtk.Button el;
1319         private MergeBranch  _this;
1320
1321
1322             // my vars (def)
1323
1324         // ctor
1325         public Xcls_mergebtn(MergeBranch _owner )
1326         {
1327             _this = _owner;
1328             _this.mergebtn = this;
1329             this.el = new Gtk.Button();
1330
1331             // my vars (dec)
1332
1333             // set gobject values
1334             this.el.label = "Do Merge";
1335
1336             // init method
1337
1338             {
1339                this.el.get_style_context().add_class("suggested-action");
1340             }
1341         }
1342
1343         // user defined functions
1344         public void updateState () {
1345                 if (_this.actionsel.selectedAction() == "") {
1346                         // need to select an action..
1347                         this.el.set_sensitive(false);
1348                         return;
1349                 
1350                 
1351                 }
1352                         this.el.set_sensitive(true);
1353                         return;
1354         }
1355     }
1356
1357 }