X-Git-Url: http://git.roojs.org/?p=gitlive;a=blobdiff_plain;f=Clones.vala;h=d4c267b98c2ceee3bd01f9ace9028116504561f5;hp=3a187ecb015e3c2aa317ba0ce5246ff7da1f962c;hb=c245640608475ef3270eb6a48c9af03b274d9996;hpb=9e641e366549656621a3e4fc4950b62c4b395650 diff --git a/Clones.vala b/Clones.vala index 3a187ecb..d4c267b9 100644 --- a/Clones.vala +++ b/Clones.vala @@ -12,6 +12,9 @@ public class Clones : Object } return _Clones; } + public Xcls_spinner spinner; + public Xcls_toolbar toolbar; + public Xcls_scrolled scrolled; public Xcls_reposView reposView; public Xcls_reposStore reposStore; public Xcls_tv_autocommit tv_autocommit; @@ -66,21 +69,50 @@ public class Clones : Object } // user defined functions - public void show () { - - - this.el.set_deletable(true); + public void loadAndShow () { + this.el.set_deletable(true); this.el.set_gravity(Gdk.Gravity.NORTH); - this.el.move((Gdk.Screen.width() / 2 ) -400 ,0); - + this.el.move((Gdk.Screen.width() / 2 ) - (int.min(1280,Gdk.Screen.width()) / 2) ,0); + this.el.set_keep_above(true); this.el.set_default_size( - int.min(1024,Gdk.Screen.width()), - int.max(500,Gdk.Screen.width() - 300) + int.min(1280,Gdk.Screen.width()), + int.max(500,Gdk.Screen.height() - 200) + ); + this.el.show_all(); + + this.toolbar.el.hide(); + this.scrolled.el.hide(); + this.spinner.el.show(); + this.spinner.el.start(); + + GitRepo.updateAllAsync("show_clones"); + + + + + + } + public void show () { + this.el.set_deletable(true); + this.el.set_gravity(Gdk.Gravity.NORTH); + this.el.move((Gdk.Screen.width() / 2 ) - (int.max(1280,Gdk.Screen.width()) / 2) ,0); + this.el.set_keep_above(true); + this.el.set_default_size( + int.max(1280,Gdk.Screen.width()), + int.max(500,Gdk.Screen.height() - 100) ); - this.el.show_all(); - _this.reposStore.load(); - this.el.set_keep_above(true); + this.spinner.el.stop(); + this.spinner.el.hide(); + this.toolbar.el.show(); + this.scrolled.el.show(); + + + + + this.reposStore.load(); + + GLib.debug("show clones = run?"); this.el.run(); // load clones.. // this.get('/reposStore').load(); @@ -115,249 +147,71 @@ public class Clones : Object // my vars (dec) // set gobject values - var child_0 = new Xcls_Box3( _this ); - child_0.ref(); - this.el.pack_start ( child_0.el , false,false,0 ); - var child_1 = new Xcls_ScrolledWindow9( _this ); - child_1.ref(); - this.el.pack_end ( child_1.el , true,true,0 ); - } - - // user defined functions - } - public class Xcls_Box3 : Object - { - public Gtk.Box el; - private Clones _this; - - - // my vars (def) - - // ctor - public Xcls_Box3(Clones _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); - - // my vars (dec) - - // set gobject values - this.el.homogeneous = true; - var child_0 = new Xcls_Button4( _this ); + var child_0 = new Xcls_spinner( _this ); child_0.ref(); this.el.add ( child_0.el ); - var child_1 = new Xcls_Button5( _this ); + var child_1 = new Xcls_toolbar( _this ); child_1.ref(); - this.el.add ( child_1.el ); - var child_2 = new Xcls_Button6( _this ); + this.el.pack_start ( child_1.el , false,false,0 ); + var child_2 = new Xcls_scrolled( _this ); child_2.ref(); - this.el.add ( child_2.el ); - var child_3 = new Xcls_Button7( _this ); - child_3.ref(); - this.el.add ( child_3.el ); - var child_4 = new Xcls_Button8( _this ); - child_4.ref(); - this.el.add ( child_4.el ); + this.el.pack_end ( child_2.el , true,true,0 ); } // user defined functions } - public class Xcls_Button4 : Object + public class Xcls_spinner : Object { - public Gtk.Button el; + public Gtk.Spinner el; private Clones _this; // my vars (def) // ctor - public Xcls_Button4(Clones _owner ) + public Xcls_spinner(Clones _owner ) { _this = _owner; - this.el = new Gtk.Button(); + _this.spinner = this; + this.el = new Gtk.Spinner(); // my vars (dec) // set gobject values - this.el.label = "Add Repository"; - - //listeners - this.el.clicked.connect( () => { - - /* var rv = this.get('/reposView'); - var rs = this.get('/reposStore'); - if (rv.el.get_selection().count_selected_rows() != 1) { - //nothing? - // error condition. - return; - } - var Remotes = imports.Remotes.Remotes; - - - var ret = {}; - var s = rv.el.get_selection(); - var path = ''; - s.selected_foreach(function(model,p,iter) { - - path = model.get_value(iter, 6).value.get_string(); - - }); - - var repo = false; - rs.repos.forEach(function(r) { - if (r.repopath == path) { - repo = r; - - } - - }); - Remotes.repo = repo; - Remotes.el.set_transient_for(Clones.el); - Clones.el.set_title("Manage Clones - " + repo.repopath); - Remotes.show(); - Clones.el.set_title("Manage Clones"); - - */ - - - - - - - }); - } - - // user defined functions - } - - public class Xcls_Button5 : Object - { - public Gtk.Button el; - private Clones _this; - - - // my vars (def) - - // ctor - public Xcls_Button5(Clones _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - - // set gobject values - this.el.label = "Branches"; - this.el.visible = false; - - //listeners - this.el.clicked.connect( () => { - // - - //NewBranch.singleton().show(); - - /* - var rv = this.get('/reposView'); - var rs = this.get('/reposStore'); - if (rv.el.get_selection().count_selected_rows() != 1) { - //nothing? - // error condition. - return; - } - var Branches = imports.Branches.Branches; - - - var ret = {}; - var s = rv.el.get_selection(); - var path = ''; - s.selected_foreach(function(model,p,iter) { - - path = model.get_value(iter, 6).value.get_string(); - - }); - - var repo = false; - rs.repos.forEach(function(r) { - if (r.repopath == path) { - repo = r; - - } - - }); - Branches.repo = repo; - Branches.el.set_transient_for(Clones.el); - Clones.el.set_title("Manage Clones - " + repo.repopath); - Branches.show(); - Clones.el.set_title("Manage Clones"); - - - - - - - - */ - - }); + this.el.hexpand = true; + this.el.vexpand = true; } // user defined functions } - public class Xcls_Button6 : Object + public class Xcls_toolbar : Object { - public Gtk.Button el; + public Gtk.Box el; private Clones _this; // my vars (def) // ctor - public Xcls_Button6(Clones _owner ) + public Xcls_toolbar(Clones _owner ) { _this = _owner; - this.el = new Gtk.Button(); + _this.toolbar = this; + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); // my vars (dec) // set gobject values - this.el.label = "Merge"; - - //listeners - this.el.clicked.connect( () => { - - var rv = _this.reposView; - var rs = _this.reposStore; - var s =rv.el.get_selection(); - if (s.count_selected_rows() != 1) { - return; - } - Gtk.TreeIter iter; - Gtk.TreeModel tm; - s.get_selected(out tm, out iter); - GLib.Value val; - tm.get_value(iter, 6, out val); - var git_working_dir = (string)val; - - var repo = GitRepo.singleton().get(git_working_dir); - - // if you hit merge.... in master.. - // ignore.. - if (repo.currentBranch.name == "master") { - return; - } - MergeBranch.singleton().show(repo.activeTicket, repo); - _this.reposStore.load(); - - - - }); + this.el.homogeneous = true; + var child_0 = new Xcls_Button5( _this ); + child_0.ref(); + this.el.add ( child_0.el ); } // user defined functions } - - public class Xcls_Button7 : Object + public class Xcls_Button5 : Object { public Gtk.Button el; private Clones _this; @@ -366,7 +220,7 @@ public class Clones : Object // my vars (def) // ctor - public Xcls_Button7(Clones _owner ) + public Xcls_Button5(Clones _owner ) { _this = _owner; this.el = new Gtk.Button(); @@ -374,49 +228,19 @@ public class Clones : Object // my vars (dec) // set gobject values - this.el.label = "Switch Branch"; - this.el.visible = false; - - //listeners - this.el.clicked.connect( () => { - - - - - - - }); - } - - // user defined functions - } - - public class Xcls_Button8 : Object - { - public Gtk.Button el; - private Clones _this; - - - // my vars (def) - - // ctor - public Xcls_Button8(Clones _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); + this.el.label = "Add Repository"; - // my vars (dec) + // init method - // set gobject values - this.el.label = "Pull"; + { + this.el.get_style_context().add_class("suggested-action"); + } //listeners this.el.clicked.connect( () => { + Clone.singleton().show(this.el); - - - }); } @@ -425,7 +249,7 @@ public class Clones : Object } - public class Xcls_ScrolledWindow9 : Object + public class Xcls_scrolled : Object { public Gtk.ScrolledWindow el; private Clones _this; @@ -434,9 +258,10 @@ public class Clones : Object // my vars (def) // ctor - public Xcls_ScrolledWindow9(Clones _owner ) + public Xcls_scrolled(Clones _owner ) { _this = _owner; + _this.scrolled = this; this.el = new Gtk.ScrolledWindow( null, null ); // my vars (dec) @@ -523,8 +348,8 @@ public class Clones : Object //listeners this.el.row_activated.connect( (path, col) => { - GLib.debug("row activated: %s", col.title); - if (col.title != "Current Branch") { + + if (col.title == "Auto Commit" || col.title == "Auto Push" || col.title == "Auto Branch") { return; } @@ -536,7 +361,7 @@ public class Clones : Object _this.reposStore.el.get_value(iter, 6, out val); var git_working_dir = (string)val; - var repo = GitRepo.singleton().get(git_working_dir); + var repo = GitRepo.singleton().get_sync(git_working_dir); Gdk.Rectangle rect; _this.reposView.el.get_cell_area(path, col, out rect); @@ -639,7 +464,7 @@ public class Clones : Object // } catch(e) { print(e);} this.el.set_value(iter, 0, repo.name ); - this.el.set_value( iter, 1, repo.currentBranch.name ); + this.el.set_value( iter, 1, repo.getCurrentBranch().name ); this.el.set_value( iter, 2, repo.branchesToString() ); // this.el.set_value(ret.iter, 2, '' + repo.branches.map( // function(e) { return e.name; @@ -650,21 +475,26 @@ public class Clones : Object this.el.set_value(iter, 5, repo.is_autopush() ); this.el.set_value(iter, 6, repo.git_working_dir ); // highlight color. - var cb = repo.currentBranch; + var cb = repo.getCurrentBranch(); //print(JSON.stringify(cb,null,4)); var col = "#ffffff"; if (cb.lastrev != cb.remoterev) { col = "#f2dede"; - this.el.set_value( iter, 1, repo.currentBranch.name +"\nRemote != Local" ); + this.el.set_value( iter, 1, repo.getCurrentBranch().name +"\n" + + (repo.ahead_or_behind == "B" ? "Local is BEHIND remote" : "Local is AHEAD of remote") + + ); } if (repo.has_local_changes) { col = "#d9edf7"; - this.el.set_value( iter, 1, repo.currentBranch.name +"\nHas uncommitted changes" ); + this.el.set_value( iter, 1, repo.getCurrentBranch().name +"\nHas uncommitted changes" ); } if ((cb.lastrev != cb.remoterev) && (repo.has_local_changes)) { col = "#fcf8e3"; - this.el.set_value( iter, 1, repo.currentBranch.name +"\nRemote != Local\nHas uncommitted changes" ); + this.el.set_value( iter, 1, repo.getCurrentBranch().name +"\n" + + (repo.ahead_or_behind == "B" ? "Local is BEHIND remote" : "Local is AHEAD of remote") + + "\nHas uncommitted changes" ); } this.el.set_value(iter, 7, col ); @@ -747,11 +577,9 @@ public class Clones : Object _this.reposStore.el.set_value(iter, 4, !bval); GLib.debug("got repopath? %s", repopath); - var repo = GitRepo.get(repopath); + var repo = GitRepo.get_sync(repopath); repo.set_autocommit(!bval); - - - + }); } @@ -826,7 +654,7 @@ public class Clones : Object var repopath = (string)rval; var bval = (bool)val; _this.reposStore.el.set_value(iter, 5, !bval); - var repo = GitRepo.get(repopath); + var repo = GitRepo.get_sync(repopath); repo.set_autopush(!bval); @@ -905,7 +733,7 @@ public class Clones : Object var repopath = (string)rval; var bval = (bool)val; _this.reposStore.el.set_value(iter, 8, !bval); - var repo = GitRepo.get(repopath); + var repo = GitRepo.get_sync(repopath); repo.set_auto_branch(!bval);