From bb47e3f1278ee1e1a249ff072c840626f91d19ed Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Fri, 14 Dec 2018 15:27:44 +0800 Subject: [PATCH] Clones.bjs Clones.vala --- Clones.bjs | 62 +++----------- Clones.vala | 229 +--------------------------------------------------- 2 files changed, 15 insertions(+), 276 deletions(-) diff --git a/Clones.bjs b/Clones.bjs index b731ebb0..e87e4204 100644 --- a/Clones.bjs +++ b/Clones.bjs @@ -30,8 +30,8 @@ "items" : [ { "bool homogeneous" : true, - "* pack" : "pack_start,false,false,0", "xtype" : "Box", + "* pack" : "pack_start,false,false,0", "$ xns" : "Gtk", "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", "items" : [ @@ -40,54 +40,16 @@ "clicked" : "() => {\n\n/* var rv = this.get('/reposView');\n var rs = this.get('/reposStore');\n if (rv.el.get_selection().count_selected_rows() != 1) {\n //nothing?\n // error condition.\n return;\n }\n var Remotes = imports.Remotes.Remotes;\n \n \n var ret = {}; \n var s = rv.el.get_selection();\n var path = '';\n s.selected_foreach(function(model,p,iter) {\n \n path = model.get_value(iter, 6).value.get_string();\n \n }); \n\n var repo = false;\n rs.repos.forEach(function(r) {\n if (r.repopath == path) {\n repo = r;\n \n }\n \n });\n Remotes.repo = repo;\n Remotes.el.set_transient_for(Clones.el);\n Clones.el.set_title(\"Manage Clones - \" + repo.repopath);\n Remotes.show();\n Clones.el.set_title(\"Manage Clones\");\n\n */ \n \n \n\n \n \n \n}" }, "label" : "Add Repository", - "* pack" : "add", - "xtype" : "Button", - "$ xns" : "Gtk" - }, - { - "listeners" : { - "clicked" : "() => {\n// \n\n\t//NewBranch.singleton().show();\n\n/*\n var rv = this.get('/reposView');\n var rs = this.get('/reposStore');\n if (rv.el.get_selection().count_selected_rows() != 1) {\n //nothing?\n // error condition.\n return;\n }\n var Branches = imports.Branches.Branches;\n \n \n var ret = {}; \n var s = rv.el.get_selection();\n var path = '';\n s.selected_foreach(function(model,p,iter) {\n \n path = model.get_value(iter, 6).value.get_string();\n \n }); \n\n var repo = false;\n rs.repos.forEach(function(r) {\n if (r.repopath == path) {\n repo = r;\n \n }\n \n });\n Branches.repo = repo;\n Branches.el.set_transient_for(Clones.el);\n Clones.el.set_title(\"Manage Clones - \" + repo.repopath);\n Branches.show();\n Clones.el.set_title(\"Manage Clones\");\n\n \n \n \n \n\n \n */ \n \n}" - }, - "label" : "Branches", - "* pack" : "add", - "xtype" : "Button", - "$ xns" : "Gtk", - "bool visible" : false - }, - { - "listeners" : { - "clicked" : "() => {\n\n\tvar rv = _this.reposView;\n\tvar rs = _this.reposStore;\n\tvar s =rv.el.get_selection();\n\tif (s.count_selected_rows() != 1) {\n\t\treturn;\n\t}\n\tGtk.TreeIter iter;\n\tGtk.TreeModel tm;\n\ts.get_selected(out tm, out iter);\n\tGLib.Value val;\n tm.get_value(iter, 6, out val);\n var git_working_dir = (string)val;\n \n var repo = GitRepo.singleton().get(git_working_dir);\n \n // if you hit merge.... in master..\n // ignore..\n if (repo.currentBranch.name == \"master\") {\n \treturn;\n\t}\n\tMergeBranch.singleton().show(repo.activeTicket, repo);\n\t_this.reposStore.load();\n\t\n \n \n}\n\n" - }, - "label" : "Merge", - "* pack" : "add", - "xtype" : "Button", - "$ xns" : "Gtk" - }, - { - "listeners" : { - "clicked" : "() => {\n \n \n \n \n \n \n}" - }, - "label" : "Switch Branch", - "* pack" : "add", "xtype" : "Button", - "$ xns" : "Gtk", - "bool visible" : false - }, - { - "listeners" : { - "clicked" : "() => {\n\n\tvar rv = _this.reposView;\n\tvar rs = _this.reposStore;\n\tvar s =rv.el.get_selection();\n\tif (s.count_selected_rows() != 1) {\n\t\treturn;\n\t}\n\tGtk.TreeIter iter;\n\tGtk.TreeModel tm;\n\ts.get_selected(out tm, out iter);\n\tGLib.Value val;\n tm.get_value(iter, 6, out val);\n var git_working_dir = (string)val;\n \n var repo = GitRepo.singleton().get(git_working_dir);\n GitMonitor.gitmonitor.pause(); \n repo.pull();\n repo.loadStatus();\n _this.reposStore.load();\n GitMonitor.gitmonitor.start(); \n\n \n \n}\n\n" - }, - "label" : "Pull", "* pack" : "add", - "xtype" : "Button", "$ xns" : "Gtk" } ] }, { "* init" : " {\n \n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n}\n", - "bool hexpand" : true, "bool expand" : true, + "bool hexpand" : true, "xtype" : "ScrolledWindow", "* pack" : "pack_end,true,true,0", "Gtk.ShadowType shadow_type" : "Gtk.ShadowType.IN", @@ -99,8 +61,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, @@ -131,8 +93,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" } @@ -152,8 +114,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" } @@ -173,8 +135,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" } @@ -182,8 +144,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", @@ -194,8 +156,8 @@ "items" : [ { "id" : "cr_repo", - "* pack" : "pack_start,false", "xtype" : "CellRendererText", + "* pack" : "pack_start,false", "$ xns" : "Gtk" } ] @@ -211,8 +173,8 @@ "items" : [ { "id" : "cr_active_ticket", - "xtype" : "CellRendererText", "* pack" : "pack_start,false", + "xtype" : "CellRendererText", "$ xns" : "Gtk" } ] @@ -228,8 +190,8 @@ "items" : [ { "id" : "cr_current_branch", - "* pack" : "pack_start,false", "xtype" : "CellRendererText", + "* pack" : "pack_start,false", "$ xns" : "Gtk" } ] @@ -245,8 +207,8 @@ "items" : [ { "id" : "cr_last_updated", - "* pack" : "pack_start,false", "xtype" : "CellRendererText", + "* pack" : "pack_start,false", "$ xns" : "Gtk" } ] @@ -263,8 +225,8 @@ "items" : [ { "id" : "cr_all_branches", - "* pack" : "pack_start,false", "xtype" : "CellRendererText", + "* pack" : "pack_start,false", "$ xns" : "Gtk" } ] diff --git a/Clones.vala b/Clones.vala index c1a8a2b8..3af463fc 100644 --- a/Clones.vala +++ b/Clones.vala @@ -118,7 +118,7 @@ public class Clones : Object 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 ); + var child_1 = new Xcls_ScrolledWindow5( _this ); child_1.ref(); this.el.pack_end ( child_1.el , true,true,0 ); } @@ -146,18 +146,6 @@ public class Clones : Object var child_0 = new Xcls_Button4( _this ); child_0.ref(); this.el.add ( child_0.el ); - var child_1 = new Xcls_Button5( _this ); - child_1.ref(); - this.el.add ( child_1.el ); - var child_2 = new Xcls_Button6( _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 ); } // user defined functions @@ -224,217 +212,6 @@ public class Clones : Object - }); - } - - // 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"); - - - - - - - - */ - - }); - } - - // user defined functions - } - - public class Xcls_Button6 : Object - { - public Gtk.Button el; - private Clones _this; - - - // my vars (def) - - // ctor - public Xcls_Button6(Clones _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // 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(); - - - - }); - } - - // user defined functions - } - - public class Xcls_Button7 : Object - { - public Gtk.Button el; - private Clones _this; - - - // my vars (def) - - // ctor - public Xcls_Button7(Clones _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // 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(); - - // my vars (dec) - - // set gobject values - this.el.label = "Pull"; - - //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); - GitMonitor.gitmonitor.pause(); - repo.pull(); - repo.loadStatus(); - _this.reposStore.load(); - GitMonitor.gitmonitor.start(); - - - }); } @@ -442,7 +219,7 @@ public class Clones : Object } - public class Xcls_ScrolledWindow9 : Object + public class Xcls_ScrolledWindow5 : Object { public Gtk.ScrolledWindow el; private Clones _this; @@ -451,7 +228,7 @@ public class Clones : Object // my vars (def) // ctor - public Xcls_ScrolledWindow9(Clones _owner ) + public Xcls_ScrolledWindow5(Clones _owner ) { _this = _owner; this.el = new Gtk.ScrolledWindow( null, null ); -- 2.39.2