Fix #5662 - Gitlive - create a tracking branch
[gitlive] / MergeBranch.vala
index a0aa781..900c667 100644 (file)
@@ -12,6 +12,7 @@ public class MergeBranch : Object
         }
         return _MergeBranch;
     }
+    public Xcls_table table;
     public Xcls_actionsel actionsel;
     public Xcls_actioncellrenderer actioncellrenderer;
     public Xcls_actionmodel actionmodel;
@@ -19,8 +20,15 @@ public class MergeBranch : Object
     public Xcls_dbcellrenderer dbcellrenderer;
     public Xcls_dbmodel dbmodel;
     public Xcls_name name;
+    public Xcls_label_diff label_diff;
+    public Xcls_label_ticket label_ticket;
+    public Xcls_diff_view diff_view;
+    public Xcls_scrolled_window scrolled_window;
+    public Xcls_view view;
+    public Xcls_spinner spinner;
 
         // my vars (def)
+    public GitRepo repo;
     public RooTicket? ticket;
     public bool running;
 
@@ -40,13 +48,13 @@ public class MergeBranch : Object
         this.el.default_width = 500;
         this.el.deletable = true;
         this.el.modal = true;
-        var child_0 = new Xcls_VBox2( _this );
+        var child_0 = new Xcls_Box2( _this );
         child_0.ref();
         this.el.get_content_area().add (  child_0.el  );
-        var child_1 = new Xcls_Button14( _this );
+        var child_1 = new Xcls_Button24( _this );
         child_1.ref();
         this.el.add_action_widget (  child_1.el , 0 );
-        var child_2 = new Xcls_Button15( _this );
+        var child_2 = new Xcls_Button25( _this );
         child_2.ref();
         this.el.add_action_widget (  child_2.el , 1 );
 
@@ -59,7 +67,7 @@ public class MergeBranch : Object
         this.el.response.connect( (self, response_id) =>  { 
           
                GLib.debug("got %d", (int) response_id);
-               if (response_id == 0) {
+               if (response_id < 1) {
                    _this.el.hide();    
                    this.running = false; 
                GitMonitor.gitmonitor.start();
@@ -85,12 +93,20 @@ public class MergeBranch : Object
             }
                */
                
-               GitRepo.doMerges(
-                       _this.actionsel.selectedAction(), 
-                       _this.ticketsel.selectedTicketId(),
-                       _this.name.el.get_text()
-               );
+               if (this.repo != null) {
+                       repo.doMerge(
+                               _this.actionsel.selectedAction(), 
+                               _this.ticketsel.selectedTicketId(),
+                               _this.name.el.get_text()
+                       );
                
+               } else {
+                       GitRepo.doMerges(
+                               _this.actionsel.selectedAction(), 
+                               _this.ticketsel.selectedTicketId(),
+                               _this.name.el.get_text()
+                       );
+               }
                this.running = false; 
         
                 
@@ -99,15 +115,10 @@ public class MergeBranch : Object
         
                 
         });
-        this.el.show.connect( (self)  => {
-         
-        
-          //test
-        });
     }
 
     // user defined functions
-    public   void show (  RooTicket ticket ) 
+    public   void show (  RooTicket ticket, GitRepo? repo ) 
     {
          // this.el.set_gravity(Gdk.Gravity.NORTH);
         if (this.running) {
@@ -115,43 +126,70 @@ public class MergeBranch : Object
        }
        GitMonitor.gitmonitor.stop();
        
-        this.ticket = ticket;
-        
+       _this.el.show_all();
+       
+       _this.table.el.hide();
+       _this.scrolled_window.el.hide();
+       _this.spinner.el.show();
+       _this.spinner.el.start();       
+       this.el.set_keep_above(true);    
        this.el.move((Gdk.Screen.width() / 2)- 250 ,0);
                GLib.debug("Loading tickets"); 
+     
+       
+        this.ticket = ticket;
+        this.repo = repo;
+        
+       
+       Timeout.add_seconds(1, () => {
+           _this.diff_view.el.get_buffer().set_text(
+               repo != null ? repo.previewMerge() : GitRepo.previewMerges(ticket.id)
+               );              
+               // if we are not working on a ticket, then we should be able to pick one?
+               _this.dbmodel.loadTickets();
+               _this.actionmodel.loadActions();
+               _this.view.loadTicket(ticket.id);
+               _this.spinner.el.stop();
+               _this.spinner.el.hide();        
     
-    
-        this.el.show_all();
-       _this.dbmodel.loadTickets();
-       _this.actionmodel.loadActions();
-    
-    
+               this.table.el.show();
+               return false;
+       });
+       
+       this.el.run();
+        
     }
-    public class Xcls_VBox2 : Object
+    public class Xcls_Box2 : Object
     {
-        public Gtk.VBox el;
+        public Gtk.Box el;
         private MergeBranch  _this;
 
 
             // my vars (def)
 
         // ctor
-        public Xcls_VBox2(MergeBranch _owner )
+        public Xcls_Box2(MergeBranch _owner )
         {
             _this = _owner;
-            this.el = new Gtk.VBox( true, 0 );
+            this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
 
             // my vars (dec)
 
             // set gobject values
-            var child_0 = new Xcls_Table3( _this );
+            var child_0 = new Xcls_table( _this );
             child_0.ref();
             this.el.pack_start (  child_0.el , false,false,0 );
+            var child_1 = new Xcls_Notebook14( _this );
+            child_1.ref();
+            this.el.add (  child_1.el  );
+            var child_2 = new Xcls_spinner( _this );
+            child_2.ref();
+            this.el.add (  child_2.el  );
         }
 
         // user defined functions
     }
-    public class Xcls_Table3 : Object
+    public class Xcls_table : Object
     {
         public Gtk.Table el;
         private MergeBranch  _this;
@@ -160,9 +198,10 @@ public class MergeBranch : Object
             // my vars (def)
 
         // ctor
-        public Xcls_Table3(MergeBranch _owner )
+        public Xcls_table(MergeBranch _owner )
         {
             _this = _owner;
+            _this.table = this;
             this.el = new Gtk.Table( 2, 2, false );
 
             // my vars (dec)
@@ -170,6 +209,7 @@ public class MergeBranch : Object
             // set gobject values
             this.el.margin = 2;
             this.el.column_spacing = 2;
+            this.el.vexpand = false;
             var child_0 = new Xcls_Label4( _this );
             child_0.ref();
             this.el.attach_defaults (  child_0.el , 0,1,0,1 );
@@ -399,7 +439,7 @@ public class MergeBranch : Object
             this.el = new Gtk.ComboBox();
 
             // my vars (dec)
-            this.loading = false;
+            this.loading = true;
 
             // set gobject values
             var child_0 = new Xcls_dbcellrenderer( _this );
@@ -418,7 +458,7 @@ public class MergeBranch : Object
                if (this.loading) {
                        return;
                }
-               
+               _this.view.loadTicket(this.selectedTicketId());
                 
                _this.name.updateText();
                //_this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
@@ -490,7 +530,7 @@ public class MergeBranch : Object
         // user defined functions
         public void loadTickets () {
         
-            RooTicket.singleton().loadTickets();
+            RooTicket.singleton().loadTickets("",RooTicket.Who.ME, RooTicket.Status.ACTIVE);
             
             _this.ticketsel.loading = true;
         
@@ -612,8 +652,299 @@ public class MergeBranch : Object
     }
 
 
+    public class Xcls_Notebook14 : Object
+    {
+        public Gtk.Notebook el;
+        private MergeBranch  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_Notebook14(MergeBranch _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.Notebook();
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.vexpand = true;
+            var child_0 = new Xcls_label_diff( _this );
+            child_0.ref();
+            var child_1 = new Xcls_label_ticket( _this );
+            child_1.ref();
+            var child_2 = new Xcls_Box17( _this );
+            child_2.ref();
+            this.el.append_page (  child_2.el , _this.label_diff.el );
+            var child_3 = new Xcls_Box20( _this );
+            child_3.ref();
+            this.el.append_page (  child_3.el , _this.label_ticket.el );
+        }
+
+        // user defined functions
+    }
+    public class Xcls_label_diff : Object
+    {
+        public Gtk.Label el;
+        private MergeBranch  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_label_diff(MergeBranch _owner )
+        {
+            _this = _owner;
+            _this.label_diff = this;
+            this.el = new Gtk.Label( "Projected Commit Diff" );
+
+            // my vars (dec)
+
+            // set gobject values
+        }
+
+        // user defined functions
+    }
+
+    public class Xcls_label_ticket : Object
+    {
+        public Gtk.Label el;
+        private MergeBranch  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_label_ticket(MergeBranch _owner )
+        {
+            _this = _owner;
+            _this.label_ticket = this;
+            this.el = new Gtk.Label( "Ticket Details" );
+
+            // my vars (dec)
+
+            // set gobject values
+        }
+
+        // user defined functions
+    }
+
+    public class Xcls_Box17 : Object
+    {
+        public Gtk.Box el;
+        private MergeBranch  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_Box17(MergeBranch _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.homogeneous = false;
+            var child_0 = new Xcls_ScrolledWindow18( _this );
+            child_0.ref();
+            this.el.pack_start (  child_0.el , true,true,0 );
+        }
 
-    public class Xcls_Button14 : Object
+        // user defined functions
+    }
+    public class Xcls_ScrolledWindow18 : Object
+    {
+        public Gtk.ScrolledWindow el;
+        private MergeBranch  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_ScrolledWindow18(MergeBranch _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.ScrolledWindow( null, null );
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.height_request = 400;
+            var child_0 = new Xcls_diff_view( _this );
+            child_0.ref();
+            this.el.add (  child_0.el  );
+        }
+
+        // user defined functions
+    }
+    public class Xcls_diff_view : Object
+    {
+        public Gtk.SourceView el;
+        private MergeBranch  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_diff_view(MergeBranch _owner )
+        {
+            _this = _owner;
+            _this.diff_view = this;
+            this.el = new Gtk.SourceView();
+
+            // my vars (dec)
+
+            // init method
+
+            var description =   Pango.FontDescription.from_string("monospace");
+                description.set_size(9000);
+                this.el.override_font(description);
+                 var lm = Gtk.SourceLanguageManager.get_default();
+                                
+                ((Gtk.SourceBuffer)(this.el.get_buffer())).set_language(
+                    lm.get_language("diff")
+                );
+        }
+
+        // user defined functions
+    }
+
+
+
+    public class Xcls_Box20 : Object
+    {
+        public Gtk.Box el;
+        private MergeBranch  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_Box20(MergeBranch _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.homogeneous = false;
+            var child_0 = new Xcls_scrolled_window( _this );
+            child_0.ref();
+            this.el.add (  child_0.el  );
+        }
+
+        // user defined functions
+    }
+    public class Xcls_scrolled_window : Object
+    {
+        public Gtk.ScrolledWindow el;
+        private MergeBranch  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_scrolled_window(MergeBranch _owner )
+        {
+            _this = _owner;
+            _this.scrolled_window = this;
+            this.el = new Gtk.ScrolledWindow( null, null );
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.height_request = 500;
+            this.el.vexpand = true;
+            var child_0 = new Xcls_view( _this );
+            child_0.ref();
+            this.el.add (  child_0.el  );
+
+            // init method
+
+            {
+               this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
+            }
+        }
+
+        // user defined functions
+    }
+    public class Xcls_view : Object
+    {
+        public WebKit.WebView el;
+        private MergeBranch  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_view(MergeBranch _owner )
+        {
+            _this = _owner;
+            _this.view = this;
+            this.el = new WebKit.WebView();
+
+            // my vars (dec)
+
+            // set gobject values
+        }
+
+        // user defined functions
+        public void loadTicket (string tid) {
+               int h,w;
+               _this.el.get_size(out w, out h);
+               
+               if (tid == "") {
+                       _this.scrolled_window.el.hide();
+                       _this.el.resize(w, 150);
+               } else {
+                       _this.scrolled_window.el.show();
+                       _this.el.resize(w, 800);
+               }
+               
+               var rs =  RooTicket.singleton();                
+               var uri = new WebKit.URIRequest("https://roojs.com/admin.php/MTrack/View/" + tid);
+               var hd = uri.get_http_headers();
+               var authCode = Base64.encode ("%s:%s".printf(rs.username, rs.password).data);
+               hd.append("Authorization", "Basic %s".printf(authCode));
+               
+                this.el.load_request(uri);
+        }
+    }
+
+
+
+
+    public class Xcls_spinner : Object
+    {
+        public Gtk.Spinner el;
+        private MergeBranch  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_spinner(MergeBranch _owner )
+        {
+            _this = _owner;
+            _this.spinner = this;
+            this.el = new Gtk.Spinner();
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.hexpand = true;
+            this.el.vexpand = true;
+        }
+
+        // user defined functions
+    }
+
+
+    public class Xcls_Button24 : Object
     {
         public Gtk.Button el;
         private MergeBranch  _this;
@@ -622,7 +953,7 @@ public class MergeBranch : Object
             // my vars (def)
 
         // ctor
-        public Xcls_Button14(MergeBranch _owner )
+        public Xcls_Button24(MergeBranch _owner )
         {
             _this = _owner;
             this.el = new Gtk.Button();
@@ -637,7 +968,7 @@ public class MergeBranch : Object
         // user defined functions
     }
 
-    public class Xcls_Button15 : Object
+    public class Xcls_Button25 : Object
     {
         public Gtk.Button el;
         private MergeBranch  _this;
@@ -646,7 +977,7 @@ public class MergeBranch : Object
             // my vars (def)
 
         // ctor
-        public Xcls_Button15(MergeBranch _owner )
+        public Xcls_Button25(MergeBranch _owner )
         {
             _this = _owner;
             this.el = new Gtk.Button();
@@ -655,6 +986,12 @@ public class MergeBranch : Object
 
             // set gobject values
             this.el.label = "Do Merge";
+
+            // init method
+
+            {
+               this.el.get_style_context().add_class("suggested-action");
+            }
         }
 
         // user defined functions