From b54bcbb8389c624969d6eb0b8b720957ad785e02 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Tue, 15 Jan 2019 17:28:20 +0800 Subject: [PATCH] Changed Clones.bjsGitBranch.valaGitRepo.vala --- Clones.bjs | 20 ++++++++++---------- GitBranch.vala | 8 ++++++-- GitRepo.vala | 3 ++- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Clones.bjs b/Clones.bjs index d1c1402f..24c654f9 100644 --- a/Clones.bjs +++ b/Clones.bjs @@ -73,8 +73,8 @@ "cursor_changed" : "() => {\n // SEE SELECTION.CHANGED\n /*\n \n return;\n \n if (this.el.get_selection().count_selected_rows() < 1) {\n //nothing? - clea it?\n return;\n }\n var ret = {}; \n var model = this.get('/changedFilesStore');\n\n var s = this.el.get_selection();\n var files = [];\n s.selected_foreach(function(model,p,iter) {\n \n files.push( model.get_value(iter, 0).value.get_string());\n \n });\n this.get('/patchview').showDiff(files); \n //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();\n //print(\"OUT?\" + value);// id..\n // load the list in the right grid..\n \n return true;\n*/\n}" }, "id" : "reposView", - "bool activate_on_single_click" : true, "* init" : " \n{\n var selection = this.el.get_selection();\n selection.set_mode( Gtk.SelectionMode.SINGLE);\n\n\n var description = new Pango.FontDescription();\n description.set_size(10000);\n this.el.override_font(description);\n \n}\n", + "bool activate_on_single_click" : true, "xtype" : "TreeView", "* pack" : "add", "int search_column" : 0, @@ -105,8 +105,8 @@ "toggled" : " (self, path) => {\n \n \tGtk.TreeIter iter;\n \t_this.reposStore.el.get_iter_from_string(out iter, path);\n \t\n \tGLib.Value val;\n \tGLib.Value rval;\n \t_this.reposStore.el.get_value(iter, 4, out val);\n \t_this.reposStore.el.get_value(iter, 6, out rval);\n \t\n \tvar repopath = (string)rval;\n \tvar bval = (bool)val;\n \t_this.reposStore.el.set_value(iter, 4, !bval);\n \tGLib.debug(\"got repopath? %s\", repopath);\n \t\n \tvar repo = GitRepo.get(repopath);\n \trepo.set_autocommit(!bval);\n \t\n \t\n \t\n \n}" }, "id" : "cr_autocommit", - "* pack" : "pack_start,false", "xtype" : "CellRendererToggle", + "* pack" : "pack_start,false", "$ xns" : "Gtk", "$ mode" : "Gtk.CellRendererMode.ACTIVATABLE" } @@ -126,8 +126,8 @@ "toggled" : " (self, path) => {\n \n \tGtk.TreeIter iter;\n \t_this.reposStore.el.get_iter_from_string(out iter, path);\n \t\n \tGLib.Value val;\n \tGLib.Value rval;\n \t_this.reposStore.el.get_value(iter, 5, out val);\n \t_this.reposStore.el.get_value(iter, 6, out rval);\n \t\n \tvar repopath = (string)rval;\n \tvar bval = (bool)val;\n \t_this.reposStore.el.set_value(iter, 5, !bval);\n \tvar repo = GitRepo.get(repopath);\n \trepo.set_autopush(!bval);\n \t\n \t\n \t\n \n}" }, "id" : "cr_autopush", - "* pack" : "pack_start,false", "xtype" : "CellRendererToggle", + "* pack" : "pack_start,false", "$ xns" : "Gtk", "$ mode" : "Gtk.CellRendererMode.ACTIVATABLE" } @@ -147,8 +147,8 @@ "toggled" : " (self, path) => {\n \n \tGtk.TreeIter iter;\n \t_this.reposStore.el.get_iter_from_string(out iter, path);\n \t\n \tGLib.Value val;\n \tGLib.Value rval;\n \t_this.reposStore.el.get_value(iter, 8, out val);\n \t_this.reposStore.el.get_value(iter, 6, out rval);\n \t\n \tvar repopath = (string)rval;\n \tvar bval = (bool)val;\n \t_this.reposStore.el.set_value(iter, 8, !bval);\n \tvar repo = GitRepo.get(repopath);\n \trepo.set_auto_branch(!bval);\n \t\n \t\n \t\n \n}" }, "id" : "cr_autobranch", - "xtype" : "CellRendererToggle", "* pack" : "pack_start,false", + "xtype" : "CellRendererToggle", "$ xns" : "Gtk", "$ mode" : "Gtk.CellRendererMode.ACTIVATABLE" } @@ -156,8 +156,8 @@ }, { "id" : "tv_repo", - "* init" : "\n this.el.add_attribute(_this.cr_repo.el , \"markup\", 0 );\n", "Gtk.SortType sort_order" : "Gtk.SortType.ASCENDING", + "* init" : "\n this.el.add_attribute(_this.cr_repo.el , \"markup\", 0 );\n", "title" : "Repo", "* pack" : "append_column", "xtype" : "TreeViewColumn", @@ -168,8 +168,8 @@ "items" : [ { "id" : "cr_repo", - "* pack" : "pack_start,false", "xtype" : "CellRendererText", + "* pack" : "pack_start,false", "$ xns" : "Gtk" } ] @@ -185,8 +185,8 @@ "items" : [ { "id" : "cr_active_ticket", - "xtype" : "CellRendererText", "* pack" : "pack_start,false", + "xtype" : "CellRendererText", "$ xns" : "Gtk" } ] @@ -202,8 +202,8 @@ "items" : [ { "id" : "cr_current_branch", - "* pack" : "pack_start,false", "xtype" : "CellRendererText", + "* pack" : "pack_start,false", "$ xns" : "Gtk" } ] @@ -219,8 +219,8 @@ "items" : [ { "id" : "cr_last_updated", - "* pack" : "pack_start,false", "xtype" : "CellRendererText", + "* pack" : "pack_start,false", "$ xns" : "Gtk" } ] @@ -237,8 +237,8 @@ "items" : [ { "id" : "cr_all_branches", - "* pack" : "pack_start,false", "xtype" : "CellRendererText", + "* pack" : "pack_start,false", "$ xns" : "Gtk" } ] diff --git a/GitBranch.vala b/GitBranch.vala index 84a83312..18aa32c1 100644 --- a/GitBranch.vala +++ b/GitBranch.vala @@ -35,6 +35,7 @@ public class GitBranch : Object public bool is_remote; public string remote = ""; public string remoterev = ""; + public string age = ""; public string toString() { @@ -44,7 +45,8 @@ public class GitBranch : Object "lastrev: " + lastrev + "\n" + "name: " + name + "\n" + "remote: " + remote + "\n" + - "remoterev: " + remoterev + "\n"; + "remoterev: " + remoterev + "\n" + + "age: " + age + "\n" ; } @@ -86,7 +88,7 @@ public class GitBranch : Object var bl = repo.git({ "for-each-ref", - "--format", "%(refname:short):remotes/%(upstream:short)", + "--format", "%(refname:short):remotes/%(upstream:short):remotes/%(authordate:relative)", "refs/heads" }).split("\n"); @@ -97,10 +99,12 @@ public class GitBranch : Object var lname= ar[0]; var rname = "remotes/" + ar[1]; + //print(rname); // we should always have a local version of it. if (branches.has_key(lname)) { branches.get(lname).remote = rname; + branches.get(lname).age = ar[2]; } if (!branches.has_key(rname) || !branches.has_key(lname) ) { diff --git a/GitRepo.vala b/GitRepo.vala index 08b38243..14391842 100644 --- a/GitRepo.vala +++ b/GitRepo.vala @@ -321,8 +321,9 @@ public class GitRepo : Object if (br.name == "") { continue; } + var col = /hours/.match(br.age) ? "#ff851b" : "#ffdc00"; // orange or yellow ret += ret.length > 0 ? "\n" : ""; - ret += br.name; + ret += br.name + " " + br.age + ""; } return ret; -- 2.39.2