From: Alan Knowles Date: Mon, 24 Dec 2018 08:17:45 +0000 (+0800) Subject: Fix #5632 - cache project listing X-Git-Url: http://git.roojs.org/?p=gitlive;a=commitdiff_plain;h=7787e7058c952459a07f64edaa20d5e7778dc1fa Fix #5632 - cache project listing --- diff --git a/Clone.bjs b/Clone.bjs index e6e034f3..62cb51b3 100644 --- a/Clone.bjs +++ b/Clone.bjs @@ -42,7 +42,7 @@ }, { "id" : "repomodel", - "| void loadRepos" : " () {\n\n var rt = RooTicket.singleton();\n var gr = GitRepo.singleton();\n _this.reposel.loading = true;\n\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n el.append(out iter);\n\n \n el.set_value(iter, 0, \"\");\n el.set_value(iter, 1, \"-- select a repo --\");\n \n\t_this.reposel.el.set_active_iter(iter);\n \n var projects = rt.projects;\n foreach(var newrepo in rt.repos) {\n \tvar has_repo = false;\n \tforeach(var repo in gr.cache.values) {\n \t\tif (newrepo.shortname == repo.name) {\n \t\t\thas_repo = true;\n \t\t}\n \t}\n \tif (has_repo) {\n \t\tcontinue;\n\t\t}\n el.append(out iter);\n \n el.set_value(iter, 0, newrepo.shortname);\n el.set_value(iter, 1, newrepo.shortname); // \"%s : %s\".printf(newrepo.shortname, newrepo.description) );\n \n \n }\n \n _this.reposel.loading = false;\n //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); \n \n}\n", + "| void loadRepos" : " () {\n\n var rt = RooTicket.singleton();\n var gr = GitRepo.singleton();\n _this.reposel.loading = true;\n\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n el.append(out iter);\n\n \n el.set_value(iter, 0, \"\");\n el.set_value(iter, 1, \"-- select a repo --\");\n \n\t_this.reposel.el.set_active_iter(iter);\n \n foreach(var newrepo in RooRepo.repos()) {\n \tvar has_repo = false;\n \tforeach(var repo in gr.cache.values) {\n \t\tif (newrepo.shortname == repo.name) {\n \t\t\thas_repo = true;\n \t\t}\n \t}\n \tif (has_repo) {\n \t\tcontinue;\n\t\t}\n el.append(out iter);\n \n el.set_value(iter, 0, newrepo.shortname);\n el.set_value(iter, 1, newrepo.shortname); // \"%s : %s\".printf(newrepo.shortname, newrepo.description) );\n \n \n }\n \n _this.reposel.loading = false;\n //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); \n \n}\n", "* pack" : "set_model", "xtype" : "ListStore", "$ columns" : "typeof(string),typeof(string)", diff --git a/Clone.vala b/Clone.vala index afad6825..f44b22cd 100644 --- a/Clone.vala +++ b/Clone.vala @@ -189,9 +189,8 @@ public class Clone : Object el.set_value(iter, 1, "-- select a repo --"); _this.reposel.el.set_active_iter(iter); - - var projects = rt.projects; - foreach(var newrepo in rt.repos) { + + foreach(var newrepo in RooRepo.repos()) { var has_repo = false; foreach(var repo in gr.cache.values) { if (newrepo.shortname == repo.name) { diff --git a/Clones.bjs b/Clones.bjs index 78d1cb23..30e9f78a 100644 --- a/Clones.bjs +++ b/Clones.bjs @@ -13,8 +13,9 @@ "response" : "(self, response_id) => { \n \n this.el.hide();\n \n}" }, "boolean deletable" : true, + "| void loadAndShow" : "() {\n\t\n\t_this.el.show_all();\n\t\n\t_this.toolbar.el.hide();\n\t_this.scrolled.el.hide();\n\t_this.spinner.el.show();\n\t_this.spinner.el.start();\t\n\t\n\tGitRepo.updateAll(\"show_clones\");\n\tthis.el.set_deletable(true);\n this.el.set_gravity(Gdk.Gravity.NORTH);\n this.el.move((Gdk.Screen.width() / 2 ) -400 ,0);\n this.el.set_keep_above(true);\n this.el.set_default_size(\n\t\t\tint.min(1024,Gdk.Screen.width()),\n\t\t\tint.max(500,Gdk.Screen.height() - 300)\n\t);\n \n \n\t\n\t\n}\n\n", "default_width" : 1024, - "| void show" : "() {\n\n GLib.debug(\"show clones?\");\n this.el.set_deletable(true);\n this.el.set_gravity(Gdk.Gravity.NORTH);\n this.el.move((Gdk.Screen.width() / 2 ) -400 ,0);\n \n this.el.set_default_size(\n\t\t\tint.min(1024,Gdk.Screen.width()),\n\t\t\tint.max(500,Gdk.Screen.height() - 300)\n\t);\n \n this.el.show_all();\n _this.reposStore.load();\n this.el.set_keep_above(true);\n GLib.debug(\"show clones = run?\");\n this.el.run();\n // load clones..\n// this.get('/reposStore').load();\n \n //this.get('/ok_button').el.set_sensitive(false);\n \n // block until we return.\n// var run_ret = this.el.run();\n// if (run_ret < 1 ) {\n// return \"DONE\";\n// }\n// print(\"RUN RETURN : \" + run_ret);\n// return \"DONE\";\n //print(JSON.stringify(this.get('bug').getValue()));\n // return this.get('bug').getValue();\n //this.success = c.success;\n}\n", + "| void show" : "() {\n\n this.el.show_all();\n\t_this.spinner.el.stop();\n\t_this.spinner.el.hide();\t\n\t_this.toolbar.el.show();\n\t_this.scrolled.el.show();\t\n \n this.el.set_deletable(true);\n this.el.set_gravity(Gdk.Gravity.NORTH);\n this.el.move((Gdk.Screen.width() / 2 ) -400 ,0);\n this.el.set_keep_above(true);\n this.el.set_default_size(\n\t\t\tint.min(1024,Gdk.Screen.width()),\n\t\t\tint.max(500,Gdk.Screen.height() - 300)\n\t);\n \n\n _this.reposStore.load();\n \n GLib.debug(\"show clones = run?\");\n this.el.run();\n // load clones..\n// this.get('/reposStore').load();\n \n //this.get('/ok_button').el.set_sensitive(false);\n \n // block until we return.\n// var run_ret = this.el.run();\n// if (run_ret < 1 ) {\n// return \"DONE\";\n// }\n// print(\"RUN RETURN : \" + run_ret);\n// return \"DONE\";\n //print(JSON.stringify(this.get('bug').getValue()));\n // return this.get('bug').getValue();\n //this.success = c.success;\n}\n", "title" : "Manage Clones", "xtype" : "Dialog", "default_height" : 500, @@ -29,9 +30,18 @@ "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", "items" : [ { + "id" : "spinner", + "bool hexpand" : true, + "* pack" : "add", + "xtype" : "Spinner", + "$ xns" : "Gtk", + "bool vexpand" : true + }, + { + "id" : "toolbar", "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" : [ @@ -48,9 +58,10 @@ ] }, { + "id" : "scrolled", "* 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", @@ -62,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, @@ -94,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" } @@ -115,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" } @@ -136,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" } @@ -145,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", @@ -157,8 +168,8 @@ "items" : [ { "id" : "cr_repo", - "* pack" : "pack_start,false", "xtype" : "CellRendererText", + "* pack" : "pack_start,false", "$ xns" : "Gtk" } ] @@ -174,8 +185,8 @@ "items" : [ { "id" : "cr_active_ticket", - "xtype" : "CellRendererText", "* pack" : "pack_start,false", + "xtype" : "CellRendererText", "$ xns" : "Gtk" } ] @@ -191,8 +202,8 @@ "items" : [ { "id" : "cr_current_branch", - "* pack" : "pack_start,false", "xtype" : "CellRendererText", + "* pack" : "pack_start,false", "$ xns" : "Gtk" } ] @@ -208,8 +219,8 @@ "items" : [ { "id" : "cr_last_updated", - "* pack" : "pack_start,false", "xtype" : "CellRendererText", + "* pack" : "pack_start,false", "$ xns" : "Gtk" } ] @@ -226,8 +237,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 65976e96..b152f768 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,22 +69,50 @@ public class Clones : Object } // user defined functions + public void loadAndShow () { + + _this.el.show_all(); + + _this.toolbar.el.hide(); + _this.scrolled.el.hide(); + _this.spinner.el.show(); + _this.spinner.el.start(); + + GitRepo.updateAll("show_clones"); + this.el.set_deletable(true); + this.el.set_gravity(Gdk.Gravity.NORTH); + this.el.move((Gdk.Screen.width() / 2 ) -400 ,0); + this.el.set_keep_above(true); + this.el.set_default_size( + int.min(1024,Gdk.Screen.width()), + int.max(500,Gdk.Screen.height() - 300) + ); + + + + + } public void show () { - GLib.debug("show clones?"); + this.el.show_all(); + _this.spinner.el.stop(); + _this.spinner.el.hide(); + _this.toolbar.el.show(); + _this.scrolled.el.show(); + this.el.set_deletable(true); this.el.set_gravity(Gdk.Gravity.NORTH); this.el.move((Gdk.Screen.width() / 2 ) -400 ,0); - + this.el.set_keep_above(true); this.el.set_default_size( int.min(1024,Gdk.Screen.width()), int.max(500,Gdk.Screen.height() - 300) ); - this.el.show_all(); + _this.reposStore.load(); - this.el.set_keep_above(true); - GLib.debug("show clones = run?"); + + GLib.debug("show clones = run?"); this.el.run(); // load clones.. // this.get('/reposStore').load(); @@ -116,17 +147,45 @@ public class Clones : Object // my vars (dec) // set gobject values - var child_0 = new Xcls_Box3( _this ); + var child_0 = new Xcls_spinner( _this ); child_0.ref(); - this.el.pack_start ( child_0.el , false,false,0 ); - var child_1 = new Xcls_ScrolledWindow5( _this ); + this.el.add ( child_0.el ); + var child_1 = new Xcls_toolbar( _this ); child_1.ref(); - this.el.pack_end ( child_1.el , true,true,0 ); + this.el.pack_start ( child_1.el , false,false,0 ); + var child_2 = new Xcls_scrolled( _this ); + child_2.ref(); + this.el.pack_end ( child_2.el , true,true,0 ); } // user defined functions } - public class Xcls_Box3 : Object + public class Xcls_spinner : Object + { + public Gtk.Spinner el; + private Clones _this; + + + // my vars (def) + + // ctor + public Xcls_spinner(Clones _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_toolbar : Object { public Gtk.Box el; private Clones _this; @@ -135,23 +194,24 @@ public class Clones : Object // my vars (def) // ctor - public Xcls_Box3(Clones _owner ) + public Xcls_toolbar(Clones _owner ) { _this = _owner; + _this.toolbar = this; 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_Button5( _this ); child_0.ref(); this.el.add ( child_0.el ); } // user defined functions } - public class Xcls_Button4 : Object + public class Xcls_Button5 : Object { public Gtk.Button el; private Clones _this; @@ -160,7 +220,7 @@ public class Clones : Object // my vars (def) // ctor - public Xcls_Button4(Clones _owner ) + public Xcls_Button5(Clones _owner ) { _this = _owner; this.el = new Gtk.Button(); @@ -189,7 +249,7 @@ public class Clones : Object } - public class Xcls_ScrolledWindow5 : Object + public class Xcls_scrolled : Object { public Gtk.ScrolledWindow el; private Clones _this; @@ -198,9 +258,10 @@ public class Clones : Object // my vars (def) // ctor - public Xcls_ScrolledWindow5(Clones _owner ) + public Xcls_scrolled(Clones _owner ) { _this = _owner; + _this.scrolled = this; this.el = new Gtk.ScrolledWindow( null, null ); // my vars (dec) diff --git a/Makefile.am b/Makefile.am index 1395b0d5..aa78ad4e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,6 +30,8 @@ Gitlive_SOURCES = \ GitRepo.vala \ GitBranch.vala \ RooTicket.vala \ + RooProject.vala \ + RooRepo.vala \ c/xorg_idletime.c \ WindowLog.vala \ Clones.vala \ diff --git a/MergeBranch.bjs b/MergeBranch.bjs index d4aa0830..54496423 100644 --- a/MergeBranch.bjs +++ b/MergeBranch.bjs @@ -10,15 +10,14 @@ { "listeners" : { "delete_event" : "(self, event) => {\n this.el.hide();\n return true; \n //test \n}\n ", - "response" : " (self, response_id) => { \n \n\tGLib.debug(\"got %d\", (int) response_id);\n\tif (response_id < 1) {\n\t _this.el.hide();\t\n\t this.running = false; \n \tGitMonitor.gitmonitor.start();\n\t \treturn;\n\t}\n\t /*\n\t// have they selected a ticket..\n\t// make that the current active ticket?\n\t// we really need to store locally what ticket is being worked on..\n\t// in theory we could be working on multiple project and not merging..\n\t// -- each repo would have their active ticket (only one per repo)\n\t// -- so we could just store that in there\n\t// -- initial load can check the contents of the ticket files on first scan.\n\tvar ticket_id = _this.ticketsel.selectedTicketId();\n\t\n if (this.repo != null) {\n \tvar bn = _this.name.el.get_text();\n \tif (ticket_id != \"\" ) {\n\t\t\tthis.repo.setActiveTicket( RooTicket.singleton().getById(ticket_id), bn);\n\t\t} else {\n\t\t\tthis.repo.createBranchNamed(bn);\n\t\t}\n }\n\t*/\n\t\n\tif (this.repo != null) {\n\t\trepo.doMerge(\n\t\t\t_this.actionsel.selectedAction(), \n\t\t\t_this.ticketsel.selectedTicketId(),\n\t\t\t_this.name.el.get_text()\n\t\t);\n\t\n\t} else {\n\t\tGitRepo.doMerges(\n\t\t\t_this.actionsel.selectedAction(), \n\t\t\t_this.ticketsel.selectedTicketId(),\n\t\t\t_this.name.el.get_text()\n\t\t);\n\t}\n\tthis.running = false; \n\n\t \n\t_this.el.hide();\t\n \tGitMonitor.gitmonitor.start();\n\n\t \n}", - "show" : "(self) => {\n \n\n //test\n}" + "response" : " (self, response_id) => { \n \n\tGLib.debug(\"got %d\", (int) response_id);\n\tif (response_id < 1) {\n\t _this.el.hide();\t\n\t this.running = false; \n \tGitMonitor.gitmonitor.start();\n\t \treturn;\n\t}\n\t /*\n\t// have they selected a ticket..\n\t// make that the current active ticket?\n\t// we really need to store locally what ticket is being worked on..\n\t// in theory we could be working on multiple project and not merging..\n\t// -- each repo would have their active ticket (only one per repo)\n\t// -- so we could just store that in there\n\t// -- initial load can check the contents of the ticket files on first scan.\n\tvar ticket_id = _this.ticketsel.selectedTicketId();\n\t\n if (this.repo != null) {\n \tvar bn = _this.name.el.get_text();\n \tif (ticket_id != \"\" ) {\n\t\t\tthis.repo.setActiveTicket( RooTicket.singleton().getById(ticket_id), bn);\n\t\t} else {\n\t\t\tthis.repo.createBranchNamed(bn);\n\t\t}\n }\n\t*/\n\t\n\tif (this.repo != null) {\n\t\trepo.doMerge(\n\t\t\t_this.actionsel.selectedAction(), \n\t\t\t_this.ticketsel.selectedTicketId(),\n\t\t\t_this.name.el.get_text()\n\t\t);\n\t\n\t} else {\n\t\tGitRepo.doMerges(\n\t\t\t_this.actionsel.selectedAction(), \n\t\t\t_this.ticketsel.selectedTicketId(),\n\t\t\t_this.name.el.get_text()\n\t\t);\n\t}\n\tthis.running = false; \n\n\t \n\t_this.el.hide();\t\n \tGitMonitor.gitmonitor.start();\n\n\t \n}" }, "default_width" : 500, - "$ deletable" : true, "# GitRepo repo" : "", + "$ deletable" : true, "title" : "Merge Branch", "xtype" : "Dialog", - "| void show" : "( RooTicket ticket, GitRepo? repo ) \n{\n // this.el.set_gravity(Gdk.Gravity.NORTH);\n if (this.running) {\n \treturn;\n\t}\n\tGitMonitor.gitmonitor.stop();\n\t\n this.ticket = ticket;\n this.repo = repo;\n \n\tthis.el.move((Gdk.Screen.width() / 2)- 250 ,0);\n \tGLib.debug(\"Loading tickets\"); \n\n\n this.el.show_all();\n \t_this.dbmodel.loadTickets();\n \t_this.actionmodel.loadActions();\n\t_this.view.loadTicket(ticket.id);\n\n}", + "| void show" : "( RooTicket ticket, GitRepo? repo ) \n{\n // this.el.set_gravity(Gdk.Gravity.NORTH);\n if (this.running) {\n \treturn;\n\t}\n\tGitMonitor.gitmonitor.stop();\n\t\n\t_this.el.show_all();\n\t\n\t_this.table.el.hide();\n\t_this.scrolled_window.el.hide();\n\t_this.spinner.el.show();\n\t_this.spinner.el.start();\t\n\tthis.el.set_keep_above(true); \n\tthis.el.move((Gdk.Screen.width() / 2)- 250 ,0);\n \tGLib.debug(\"Loading tickets\"); \n\n\n\t\n\t\n this.ticket = ticket;\n this.repo = repo;\n \n\t\n\tTimeout.add_seconds(1, () => {\n\t\t\n\t\t// if we are not working on a ticket, then we should be able to pick one?\n\t \t_this.dbmodel.loadTickets();\n\t \t_this.actionmodel.loadActions();\n\t\t_this.view.loadTicket(ticket.id);\n\t\t_this.spinner.el.stop();\n\t\t_this.spinner.el.hide();\t\n\n\t\tthis.table.el.show();\n\t\treturn false;\n\t});\n\t\n\tthis.el.run();\n\t \n}", "default_height" : 200, "# RooTicket? ticket" : "null", "$ xns" : "Gtk", @@ -32,9 +31,10 @@ "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", "items" : [ { + "id" : "table", "bool homogeneous" : false, - "xtype" : "Table", "* pack" : "pack_start,false,false,0", + "xtype" : "Table", "uint column_spacing" : 2, "n_columns" : 2, "$ xns" : "Gtk", @@ -66,14 +66,14 @@ "items" : [ { "id" : "actioncellrenderer", - "xtype" : "CellRendererText", "* pack" : "pack_start,true", + "xtype" : "CellRendererText", "$ xns" : "Gtk" }, { "id" : "actionmodel", - "xtype" : "ListStore", "* pack" : "set_model", + "xtype" : "ListStore", "$ columns" : "typeof(string),typeof(string)", "n_columns" : 2, "$ xns" : "Gtk", @@ -105,14 +105,14 @@ "items" : [ { "id" : "dbcellrenderer", - "* pack" : "pack_start,true", "xtype" : "CellRendererText", + "* pack" : "pack_start,true", "$ xns" : "Gtk" }, { "id" : "dbmodel", - "* pack" : "set_model", "xtype" : "ListStore", + "* pack" : "set_model", "| void loadTickets" : " () {\n\n RooTicket.singleton().loadTickets(\"\",RooTicket.Who.ME, RooTicket.Status.ACTIVE);\n \n _this.ticketsel.loading = true;\n\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n el.append(out iter);\n el.set_value(iter, 0, \"\");\n el.set_value(iter, 1, \"-- select a ticket --\");\n \n _this.ticketsel.el.set_active_iter(iter);\n \n if (_this.ticket != null && _this.ticket.id == \"-1\") {\n\t\tel.append(out iter);\n\t\tel.set_value(iter, 0, \"-1\");\n\t\tel.set_value(iter, 1, \"Temporary Branch - No ticket specified/relivant\");\n _this.ticketsel.el.set_active_iter(iter);\t\n }\n \n \n \n \n var tickets = RooTicket.singleton().tickets;\n foreach(var ticket in tickets) {\n \n el.append(out iter);\n\n el.set_value(iter, 0, ticket.id);\n el.set_value(iter, 1, \"#%s [%s] %s\".printf( ticket.id, ticket.project_id_name , ticket.summary));\n\t\tif (_this.ticket != null && _this.ticket.id == ticket.id) {\n\t\t _this.ticketsel.el.set_active_iter(iter);\n\t }\n \n }\n \n _this.ticketsel.loading = false;\n //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); \n \n}\n", "$ columns" : "typeof(string),typeof(string)", "n_columns" : 2, @@ -150,26 +150,35 @@ "items" : [ { "id" : "view", - "* pack" : "add", "xtype" : "WebView", + "* pack" : "add", "$ xns" : "WebKit", "| void loadTicket" : "(string tid) {\n\tint h,w;\n\t_this.el.get_size(out w, out h);\n\t\n\tif (tid == \"\") {\n\t\t_this.scrolled_window.el.hide();\n\t\t_this.el.resize(w, 150);\n\t} else {\n\t\t_this.scrolled_window.el.show();\n\t\t_this.el.resize(w, 800);\n\t}\n\t\n\tvar rs = RooTicket.singleton();\t\t\n\tvar uri = new WebKit.URIRequest(\"https://roojs.com/admin.php/MTrack/View/\" + tid);\n\tvar hd = uri.get_http_headers();\n\tvar authCode = Base64.encode (\"%s:%s\".printf(rs.username, rs.password).data);\n\thd.append(\"Authorization\", \"Basic %s\".printf(authCode));\n\t\n\t this.el.load_request(uri);\n}\n" } ] + }, + { + "id" : "spinner", + "bool hexpand" : true, + "* pack" : "add", + "xtype" : "Spinner", + "$ xns" : "Gtk", + "bool vexpand" : true } ] }, { "label" : "Cancel", - "* pack" : "add_action_widget,0", "xtype" : "Button", + "* pack" : "add_action_widget,0", "Gtk.ReliefStyle relief" : "Gtk.ReliefStyle.NONE", "$ xns" : "Gtk" }, { "label" : "Do Merge", - "* pack" : "add_action_widget,1", + "* init" : "{\n this.el.get_style_context().add_class(\"suggested-action\");\n}\n", "xtype" : "Button", + "* pack" : "add_action_widget,1", "$ xns" : "Gtk" } ] diff --git a/MergeBranch.vala b/MergeBranch.vala index 56416954..5eec3387 100644 --- a/MergeBranch.vala +++ b/MergeBranch.vala @@ -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; @@ -21,6 +22,7 @@ public class MergeBranch : Object public Xcls_name name; public Xcls_scrolled_window scrolled_window; public Xcls_view view; + public Xcls_spinner spinner; // my vars (def) public GitRepo repo; @@ -46,10 +48,10 @@ public class MergeBranch : Object var child_0 = new Xcls_Box2( _this ); child_0.ref(); this.el.get_content_area().add ( child_0.el ); - var child_1 = new Xcls_Button16( _this ); + var child_1 = new Xcls_Button17( _this ); child_1.ref(); this.el.add_action_widget ( child_1.el , 0 ); - var child_2 = new Xcls_Button17( _this ); + var child_2 = new Xcls_Button18( _this ); child_2.ref(); this.el.add_action_widget ( child_2.el , 1 ); @@ -110,11 +112,6 @@ public class MergeBranch : Object }); - this.el.show.connect( (self) => { - - - //test - }); } // user defined functions @@ -126,18 +123,38 @@ public class MergeBranch : Object } GitMonitor.gitmonitor.stop(); - this.ticket = ticket; - this.repo = repo; - + _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.el.show_all(); - _this.dbmodel.loadTickets(); - _this.actionmodel.loadActions(); - _this.view.loadTicket(ticket.id); + + + this.ticket = ticket; + this.repo = repo; + + + Timeout.add_seconds(1, () => { + + // 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.table.el.show(); + return false; + }); + + this.el.run(); + } public class Xcls_Box2 : Object { @@ -156,17 +173,20 @@ public class MergeBranch : Object // 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_scrolled_window( _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; @@ -175,9 +195,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) @@ -705,8 +726,33 @@ public class MergeBranch : Object } + public class Xcls_spinner : Object + { + public Gtk.Spinner el; + private MergeBranch _this; - public class Xcls_Button16 : Object + + // 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_Button17 : Object { public Gtk.Button el; private MergeBranch _this; @@ -715,7 +761,7 @@ public class MergeBranch : Object // my vars (def) // ctor - public Xcls_Button16(MergeBranch _owner ) + public Xcls_Button17(MergeBranch _owner ) { _this = _owner; this.el = new Gtk.Button(); @@ -730,7 +776,7 @@ public class MergeBranch : Object // user defined functions } - public class Xcls_Button17 : Object + public class Xcls_Button18 : Object { public Gtk.Button el; private MergeBranch _this; @@ -739,7 +785,7 @@ public class MergeBranch : Object // my vars (def) // ctor - public Xcls_Button17(MergeBranch _owner ) + public Xcls_Button18(MergeBranch _owner ) { _this = _owner; this.el = new Gtk.Button(); @@ -748,6 +794,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 diff --git a/NewBranch.bjs b/NewBranch.bjs index a5b845f2..02621d83 100644 --- a/NewBranch.bjs +++ b/NewBranch.bjs @@ -17,7 +17,7 @@ "title" : "Create a working branch ", "xtype" : "Dialog", "# GitRepo? repo" : "null", - "| void show" : "( GitRepo repo, Gee.ArrayList queue, string tid = \"\" ) \n{\n // this.el.set_gravity(Gdk.Gravity.NORTH);\n if (this.running) { // should not happen!!\n \tGLib.error(\"new branch show called, when already being displayed?\");\n\t}\n\tthis.queue = queue;\n\t\n\tthis.running = true;\n\tGitMonitor.gitmonitor.stop();\n\t\n this.repo = repo;\n \n \n \n\tthis.el.move((Gdk.Screen.width() / 2)- 250 ,0);\n\tthis.el.set_default_size( 500,200); // not sure why it grows..\n GLib.debug(\"Loading tickets\"); \n \n\n this.el.show_all();\n this.el.set_keep_above(true);\n \n \n var curproj = RooTicket.singleton().getProjectByRepo(this.repo);\n _this.prmodel.loadProjects(curproj == null ? \"\" : curproj.id);\n \n \t_this.dbmodel.loadTickets(curproj == null ? \"\": curproj.id, tid);\n\n \tif (tid != \"\") {\n\t \tvar name = RooTicket.singleton().usernameLocal();\n \t\tvar ticket = RooTicket.singleton().getById(tid);\n\t\t_this.name.el.set_text(\"wip_%s_T%s_%s\".printf(name,ticket.id, ticket.summaryToBranchName()));\n\n\n\t}\n _this.view.loadTicket(tid);\n \tthis.el.run();\n\n}", + "| void show" : "( GitRepo repo, Gee.ArrayList queue, string tid = \"\" ) \n{\n // this.el.set_gravity(Gdk.Gravity.NORTH);\n if (this.running) { // should not happen!!\n \tGLib.error(\"new branch show called, when already being displayed?\");\n\t}\n\tthis.queue = queue;\n\t\n\tthis.running = true;\n\tGitMonitor.gitmonitor.stop();\n\t\n this.repo = repo;\n \n \n \n\tthis.el.move((Gdk.Screen.width() / 2)- 250 ,0);\n\tthis.el.set_default_size( 500,200); // not sure why it grows..\n GLib.debug(\"Loading tickets\"); \n \n\n this.el.show_all();\n this.el.set_keep_above(true);\n \n \n var curproj = RooProject.getProjectByRepo(this.repo);\n _this.prmodel.loadProjects(curproj == null ? \"\" : curproj.id);\n \n \t_this.dbmodel.loadTickets(curproj == null ? \"\": curproj.id, tid);\n\n \tif (tid != \"\") {\n\t \tvar name = RooTicket.singleton().usernameLocal();\n \t\tvar ticket = RooTicket.singleton().getById(tid);\n\t\t_this.name.el.set_text(\"wip_%s_T%s_%s\".printf(name,ticket.id, ticket.summaryToBranchName()));\n\n\n\t}\n _this.view.loadTicket(tid);\n \tthis.el.run();\n\n}", "default_height" : 500, "$ xns" : "Gtk", "# bool running" : false, @@ -66,8 +66,8 @@ "changed" : "() => {\n\tif (this.loading) {\n\t\treturn;\n\t}\n\tvar project_id = this.selectedProjectId();\n\t_this.dbmodel.loadTickets(project_id);\n\t\n\t\n\t/*if (this.loading) {\n\t\treturn;\n\t}\n\tvar ticket_id = this.selectedTicketId();\n\t\n\tvar name = RooTicket.singleton().usernameLocal();\n\t\n\tif (ticket_id == \"\" || ticket_id == null) {\n\t\n\t\tvar dt = new DateTime.now_local();\n\t\t_this.name.el.set_text(\"wip_%s_%s\".printf(name,dt.format(\"%Y_%b_%d\")));\n\t\treturn;\n\t}\n\t\n\t\n\tvar ticket = RooTicket.singleton().getById(ticket_id);\n \n\t_this.name.el.set_text(\"wip_%s_T%s_%s\".printf(name,ticket.id, ticket.summaryToBranchName()));\n\t\n\t//GLib.debug (//\"Selection: %s, %s\\n\", (string) val1, (string) val2);\n\t*/\n}" }, "* ctor" : "new Gtk.ComboBox.with_entry()", - "| string selectedProjectId" : "() {\n\tGtk.TreeIter iter;\n\tValue val1;\n \n \n\tthis.el.get_active_iter (out iter);\n\t_this.prmodel.el.get_value (iter, 0, out val1);\n \n\n\treturn (string) val1;\n\t\n\t\n\t\n\t\n}\n", "id" : "projectsel", + "| string selectedProjectId" : "() {\n\tGtk.TreeIter iter;\n\tValue val1;\n \n \n\tthis.el.get_active_iter (out iter);\n\t_this.prmodel.el.get_value (iter, 0, out val1);\n \n\n\treturn (string) val1;\n\t\n\t\n\t\n\t\n}\n", "* init" : "this.el.set_entry_text_column(1);", "* pack" : "attach_defaults,0,1,1,2", "xtype" : "ComboBox", @@ -76,12 +76,12 @@ "items" : [ { "id" : "prcellrenderer", - "* pack" : "pack_start,true", "xtype" : "CellRendererText", + "* pack" : "pack_start,true", "$ xns" : "Gtk" }, { - "| void loadProjects" : " (string id) {\n\n var rt = RooTicket.singleton();\n rt.loadProjects();\n \n _this.projectsel.loading = true;\n\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n el.append(out iter);\n\n \n el.set_value(iter, 0, \"\");\n el.set_value(iter, 1, \"-- select a project --\");\n if (id == \"\") {\n\t _this.projectsel.el.set_active_iter(iter);\n }\n var projects = rt.projects;\n foreach(var project in projects) {\n \n el.append(out iter);\n \n el.set_value(iter, 0, project.id);\n el.set_value(iter, 1, project.name );\n if (id == project.id) {\n\t \t _this.projectsel.el.set_active_iter(iter);\n\t } \n \n }\n \n _this.projectsel.loading = false;\n //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); \n \n}\n", + "| void loadProjects" : " (string id) {\n\n\n \n _this.projectsel.loading = true;\n\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n el.append(out iter);\n\n \n el.set_value(iter, 0, \"\");\n el.set_value(iter, 1, \"-- select a project --\");\n if (id == \"\") {\n\t _this.projectsel.el.set_active_iter(iter);\n }\n \n foreach(var project in RooProject.projects()) {\n \n el.append(out iter);\n \n el.set_value(iter, 0, project.id);\n el.set_value(iter, 1, project.name );\n if (id == project.id) {\n\t \t _this.projectsel.el.set_active_iter(iter);\n\t } \n \n }\n \n _this.projectsel.loading = false;\n //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); \n \n}\n", "id" : "prmodel", "* pack" : "set_model", "xtype" : "ListStore", @@ -106,14 +106,14 @@ "items" : [ { "id" : "dbcellrenderer", - "xtype" : "CellRendererText", "* pack" : "pack_start,true", + "xtype" : "CellRendererText", "$ xns" : "Gtk" }, { "id" : "dbmodel", - "xtype" : "ListStore", "* pack" : "set_model", + "xtype" : "ListStore", "| void loadTickets" : "(string project_id , string tid = \"\") {\n\n\n \n // fixme .. get project id from selection..\n \n RooTicket.singleton().loadTickets(\n \t\t\tproject_id,\n \t\t\t_this.btn_not_me.el.active ? RooTicket.Who.ANYBODY : RooTicket.Who.ME,\n \t\t\t _this.btn_closed.el.active ? RooTicket.Status.ALL : RooTicket.Status.ACTIVE\n\t\t );\n \n _this.ticketsel.loading = true;\n\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n el.append(out iter);\n\n \n el.set_value(iter, 0, \"\");\n el.set_value(iter, 1, \"-- select a ticket --\");\n \n _this.ticketsel.el.set_active_iter(iter);\n var tickets = RooTicket.singleton().tickets;\n foreach(var ticket in tickets) {\n \n el.append(out iter);\n \n el.set_value(iter, 0, ticket.id);\n el.set_value(iter, 1, \"#%s [%s] %s\".printf( ticket.id, ticket.project_id_name , ticket.summary));\n \n if (ticket.id == tid) {\n\t\t _this.ticketsel.el.set_active_iter(iter);\n }\n \n }\n \n _this.ticketsel.loading = false;\n //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); \n \n}\n", "$ columns" : "typeof(string),typeof(string)", "n_columns" : 2, @@ -126,8 +126,8 @@ "clicked" : "() => {\n _this.el.response(-1);\n\tTicket.singleton().show(_this.repo);\n\n}" }, "bool expand" : false, - "* pack" : "attach_defaults,4,5,1,2", "xtype" : "Button", + "* pack" : "attach_defaults,4,5,1,2", "string label" : "New Ticket", "$ xns" : "Gtk" }, @@ -169,8 +169,8 @@ "toggled" : "() => {\n\tvar project_id = _this.projectsel.selectedProjectId();\n\t_this.dbmodel.loadTickets(project_id);\t\n}" }, "id" : "btn_not_me", - "* pack" : "add", "string label" : "Show tickets not assigned to me", + "* pack" : "add", "xtype" : "CheckButton", "$ xns" : "Gtk" }, @@ -179,14 +179,14 @@ "toggled" : "() => {\n \tvar project_id = _this.projectsel.selectedProjectId();\n\t_this.dbmodel.loadTickets(project_id);\t\n\t \n}" }, "id" : "btn_closed", - "string label" : "Show closed Tickets", "xtype" : "CheckButton", + "string label" : "Show closed Tickets", "* pack" : "add", "$ xns" : "Gtk" }, { "listeners" : { - "activate_link" : "(uri) => {\n\tif (uri == \"refresh\") {\n\t\tvar curproj = RooTicket.singleton().getProjectByRepo(_this.repo);\n\t\t _this.prmodel.loadProjects(curproj == null ? \"\": curproj.id);\n\n\t\t_this.dbmodel.loadTickets(curproj == null ? \"\": curproj.id);\t\t\n\t}\n\treturn true;\n}" + "activate_link" : "(uri) => {\n\tif (uri == \"refresh\") {\n\t\tRooProject.reload();\n\t\tvar curproj = RooProject.getProjectByRepo(_this.repo);\n\t\t _this.prmodel.loadProjects(curproj == null ? \"\": curproj.id);\n\n\t\t_this.dbmodel.loadTickets(curproj == null ? \"\": curproj.id);\t\t\n\t}\n\treturn true;\n}" }, "bool use_markup" : true, "Gtk.Align halign" : "Gtk.Align.END", @@ -211,8 +211,8 @@ "items" : [ { "id" : "view", - "* pack" : "add", "xtype" : "WebView", + "* pack" : "add", "$ xns" : "WebKit", "| void loadTicket" : "(string tid) {\n\tint h,w;\n\t_this.el.get_size(out w, out h);\n\t\n\tif (tid == \"\") {\n\t\t_this.scrolled_window.el.hide();\n\t\t_this.el.resize(w, 150);\n\t} else {\n\t\t_this.scrolled_window.el.show();\n\t\t_this.el.resize(w, 800);\n\t}\n\t\n\tvar rs = RooTicket.singleton();\t\t\n\tvar uri = new WebKit.URIRequest(\"https://roojs.com/admin.php/MTrack/View/\" + tid);\n\tvar hd = uri.get_http_headers();\n\tvar authCode = Base64.encode (\"%s:%s\".printf(rs.username, rs.password).data);\n\thd.append(\"Authorization\", \"Basic %s\".printf(authCode));\n\t\n\t this.el.load_request(uri);\n}\n" } diff --git a/NewBranch.vala b/NewBranch.vala index 9183007d..6b2c3455 100644 --- a/NewBranch.vala +++ b/NewBranch.vala @@ -123,7 +123,7 @@ public class NewBranch : Object this.el.set_keep_above(true); - var curproj = RooTicket.singleton().getProjectByRepo(this.repo); + var curproj = RooProject.getProjectByRepo(this.repo); _this.prmodel.loadProjects(curproj == null ? "" : curproj.id); _this.dbmodel.loadTickets(curproj == null ? "": curproj.id, tid); @@ -394,8 +394,7 @@ public class NewBranch : Object // user defined functions public void loadProjects (string id) { - var rt = RooTicket.singleton(); - rt.loadProjects(); + _this.projectsel.loading = true; @@ -411,8 +410,8 @@ public class NewBranch : Object if (id == "") { _this.projectsel.el.set_active_iter(iter); } - var projects = rt.projects; - foreach(var project in projects) { + + foreach(var project in RooProject.projects()) { el.append(out iter); @@ -828,7 +827,8 @@ public class NewBranch : Object //listeners this.el.activate_link.connect( (uri) => { if (uri == "refresh") { - var curproj = RooTicket.singleton().getProjectByRepo(_this.repo); + RooProject.reload(); + var curproj = RooProject.getProjectByRepo(_this.repo); _this.prmodel.loadProjects(curproj == null ? "": curproj.id); _this.dbmodel.loadTickets(curproj == null ? "": curproj.id); diff --git a/RooProject.vala b/RooProject.vala new file mode 100644 index 00000000..23fcbfa2 --- /dev/null +++ b/RooProject.vala @@ -0,0 +1,159 @@ +/** +This a mostly a static class that manages an array of it'self... + +*/ + +static RooProject _RooProject; +public class RooProject : Object +{ + + public string id; // not really important that they are numbers.. + public string code; + public string name; + public string type; + + + // --- static from here on.... + + + + static Gee.ArrayList _projects; + static int loadcount = 0; + const string roourl = "https://roojs.com/admin.php/Roo"; + + + static RooProject singleton() + { + if (_RooProject == null) { + _RooProject = new RooProject(); + RooProject.loadcount = 0; + RooProject.loadProjects(); + + } + return _RooProject; + } + + + public static Gee.ArrayList projects() + { + RooProject.singleton(); + + return RooProject._projects; + } + + + public static RooProject? getProjectByRepo(GitRepo repo) + { + RooProject.singleton(); // init... + + // fixme -- needs to get from rep list.. + + var pid = ""; + foreach(var roo_repo in RooRepo.repos()) { + if (roo_repo.shortname == repo.name) { + pid = roo_repo.project_id; + break; + } + } + if (pid == "") { + GLib.debug("getProjectByRepo: repo has no project"); + return null; + } + // get project by id... + foreach(var roo_project in RooProject.projects()) { + if (roo_project.id == pid) { + GLib.debug("getProjectByRepo: project_id = %s", pid); + return roo_project; + } + } + GLib.debug("getProjectByRepo: can not find project"); + return null; + + } + + + public static RooProject addProject(Json.Object t) + { + RooProject.singleton(); // init... + + var add = new RooProject(); + add.id = t.get_string_member("id"); + add.name = t.get_string_member("name"); + add.type = t.get_string_member("type"); + add.code = t.get_string_member("code"); + RooProject._projects.add(add); + GLib.debug("ADD project %s : %s : %s", add.id, add.code, add.name); + return add; + } + + public static void reload() /// has to be called on singleton.. + { + RooProject.loadcount = 0; + RooProject.singleton(); + if (RooProject.loadcount == 0 ) { + RooProject.loadProjects(); + } + } + + static void loadProjects() // called from singleton... + { + RooProject._projects = new Gee.ArrayList(); + + RooProject.loadcount ++; + var table = new GLib.HashTable(str_hash, str_equal); + + table.insert("query[project_filter]","P,N,U"); + table.insert("limit","200"); + table.insert("sort","name"); + table.insert("dir","ASC"); + + var params = Soup.Form.encode_hash(table); + + var url = "%s/%s?%s" . printf(roourl, "core_project", params); + + GLib.debug("request %s", url); + + var session = new Soup.Session (); + session.timeout = 0; + var message = new Soup.Message ("GET", url); + + + RooTicket.setAuth(message); + + session.send_message (message); + + var data = (string) message.response_body.flatten().data; + //GLib.debug("got %s", data); + try { + var parser = new Json.Parser (); + parser.load_from_data (data, -1); + + var response = parser.get_root().get_object(); + var status = response.get_boolean_member("success"); + + if(!status){ + GLib.error(response.get_string_member("errorMsg")); + return; + } + var rd = response.get_array_member ("data"); + + // got a valid result... + + for(var i = 0; i < rd.get_length(); i++) { + RooProject.addProject(rd.get_object_element(i)); + } + + + } catch (Error e) { + GLib.error(e.message); + return; + } + + } + + + + + +} + diff --git a/RooRepo.vala b/RooRepo.vala new file mode 100644 index 00000000..eb474068 --- /dev/null +++ b/RooRepo.vala @@ -0,0 +1,116 @@ + + +static RooRepo _RooRepo ; + +public class RooRepo : Object +{ + + + public string id; // not really important that they are numbers.. + public string project_id; + public string description; + public string shortname; + + + // -- static below... + const string roourl = "https://roojs.com/admin.php/Roo"; + static Gee.ArrayList _repos; // only available for singletonn. + static int loadcount = 0; + + static RooRepo init() + { + if (_RooRepo == null) { + _RooRepo = new RooRepo(); + RooRepo.loadcount = 0; + RooRepo.load(); + } + return _RooRepo; + } + + + public static Gee.ArrayList repos() { + RooRepo.init(); + return RooRepo._repos; + } + + static RooRepo add(Json.Object t) + { + var add = new RooRepo(); + add.id = t.get_string_member("id"); + add.shortname = t.get_string_member("shortname"); + add.description = t.get_string_member("description"); + add.project_id = t.get_string_member("project_id"); + RooRepo._repos.add(add); + GLib.debug("ADD project %s : %s : %s", add.id, add.shortname, add.project_id); + return add; + } + + public static void reload() /// has to be called on singleton.. + { + RooRepo.loadcount = 0; + RooRepo.init(); + if (RooRepo.loadcount == 0 ) { + RooRepo.load(); + } + } + + static void load() // only called from above + { + + RooRepo._repos = new Gee.ArrayList(); + + + var table = new GLib.HashTable(str_hash, str_equal); + + + table.insert("limit","200"); + table.insert("sort","shortname"); + table.insert("dir","ASC"); + + var params = Soup.Form.encode_hash(table); + + var url = "%s/%s?%s" . printf(roourl, "mtrack_repos", params); + + GLib.debug("request %s", url); + + var session = new Soup.Session (); + session.timeout = 0; + var message = new Soup.Message ("GET", url); + + + RooTicket.setAuth(message); + + session.send_message (message); + + var data = (string) message.response_body.flatten().data; + //GLib.debug("got %s", data); + try { + var parser = new Json.Parser (); + parser.load_from_data (data, -1); + + var response = parser.get_root().get_object(); + var status = response.get_boolean_member("success"); + + if(!status){ + GLib.error(response.get_string_member("errorMsg")); + return; + } + var rd = response.get_array_member ("data"); + + // got a valid result... + + for(var i = 0; i < rd.get_length(); i++) { + RooRepo.add(rd.get_object_element(i)); + } + + + } catch (Error e) { + GLib.error(e.message); + return; + } + + } + + + +} diff --git a/RooTicket.vala b/RooTicket.vala index 3d854010..083762b1 100644 --- a/RooTicket.vala +++ b/RooTicket.vala @@ -4,18 +4,6 @@ code to fetch ticket info... */ -public class RooRepo : Object -{ - - - - public string id; // not really important that they are numbers.. - public string project_id; - public string description; - public string shortname; - - -} public class RooOption : Object { @@ -34,16 +22,6 @@ public class RooOption : Object } -public class RooProject : Object -{ - public string id; // not really important that they are numbers.. - public string code; - public string name; - public string type; - -} - - static RooTicket _RooTicket; @@ -67,15 +45,15 @@ public class RooTicket : Object if (_RooTicket == null) { _RooTicket = new RooTicket(); _RooTicket.tickets = new Gee.ArrayList(); - _RooTicket.projects = new Gee.ArrayList(); - _RooTicket.repos = new Gee.ArrayList(); - _RooTicket.loadRepos(); // initalize it.. + + + } return _RooTicket; } public Gee.ArrayList tickets; // only available for singletonn. - public Gee.ArrayList projects; // only available for singletonn. - public Gee.ArrayList repos; // only available for singletonn. + + public Gee.ArrayList milestones; public Gee.ArrayList priorities; @@ -141,63 +119,9 @@ public class RooTicket : Object GLib.debug("ADD ticket %s : %s : %s", add.id, add.summary, add.project_id_name); return add; } - public RooProject addProject(Json.Object t) - { - var add = new RooProject(); - add.id = t.get_string_member("id"); - add.name = t.get_string_member("name"); - add.type = t.get_string_member("type"); - add.code = t.get_string_member("code"); - this.projects.add(add); - GLib.debug("ADD project %s : %s : %s", add.id, add.code, add.name); - return add; - } - - public RooRepo addRepo(Json.Object t) - { - var add = new RooRepo(); - add.id = t.get_string_member("id"); - add.shortname = t.get_string_member("shortname"); - add.description = t.get_string_member("description"); - add.project_id = t.get_string_member("project_id"); - this.repos.add(add); - GLib.debug("ADD project %s : %s : %s", add.id, add.shortname, add.project_id); - return add; - } - - public RooProject? getProjectByRepo(GitRepo repo) - { - var rt = RooTicket.singleton(); - - if (rt.repos.size < 1) { - rt.loadRepos(); - } - if (rt.projects.size < 1) { - rt.loadProjects(); - } - - var pid = ""; - foreach(var roo_repo in rt.repos) { - if (roo_repo.shortname == repo.name) { - pid = roo_repo.project_id; - break; - } - } - if (pid == "") { - GLib.debug("getProjectByRepo: repo has no project"); - return null; - } - // get project by id... - foreach(var roo_project in rt.projects) { - if (roo_project.id == pid) { - GLib.debug("getProjectByRepo: project_id = %s", pid); - return roo_project; - } - } - GLib.debug("getProjectByRepo: can not find project"); - return null; - - } + + + public static RooTicket fakeTicket() @@ -335,117 +259,7 @@ public class RooTicket : Object } - - public void loadProjects() - { - RooTicket.singleton().projects = new Gee.ArrayList(); - - - var table = new GLib.HashTable(str_hash, str_equal); - - table.insert("query[project_filter]","P,N,U"); - table.insert("limit","200"); - table.insert("sort","name"); - table.insert("dir","ASC"); - - var params = Soup.Form.encode_hash(table); - - var url = "%s/%s?%s" . printf(roourl, "core_project", params); - - GLib.debug("request %s", url); - - var session = new Soup.Session (); - session.timeout = 0; - var message = new Soup.Message ("GET", url); - - - RooTicket.setAuth(message); - - session.send_message (message); - - var data = (string) message.response_body.flatten().data; - //GLib.debug("got %s", data); - try { - var parser = new Json.Parser (); - parser.load_from_data (data, -1); - - var response = parser.get_root().get_object(); - var status = response.get_boolean_member("success"); - - if(!status){ - GLib.error(response.get_string_member("errorMsg")); - return; - } - var rd = response.get_array_member ("data"); - - // got a valid result... - var _this = RooTicket.singleton(); - for(var i = 0; i < rd.get_length(); i++) { - _this.addProject(rd.get_object_element(i)); - } - - - } catch (Error e) { - GLib.error(e.message); - return; - } - - } - public void loadRepos() - { - RooTicket.singleton().repos = new Gee.ArrayList(); - - - var table = new GLib.HashTable(str_hash, str_equal); - - - table.insert("limit","200"); - table.insert("sort","shortname"); - table.insert("dir","ASC"); - - var params = Soup.Form.encode_hash(table); - - var url = "%s/%s?%s" . printf(roourl, "mtrack_repos", params); - - GLib.debug("request %s", url); - - var session = new Soup.Session (); - session.timeout = 0; - var message = new Soup.Message ("GET", url); - - - RooTicket.setAuth(message); - - session.send_message (message); - - var data = (string) message.response_body.flatten().data; - //GLib.debug("got %s", data); - try { - var parser = new Json.Parser (); - parser.load_from_data (data, -1); - - var response = parser.get_root().get_object(); - var status = response.get_boolean_member("success"); - - if(!status){ - GLib.error(response.get_string_member("errorMsg")); - return; - } - var rd = response.get_array_member ("data"); - - // got a valid result... - var _this = RooTicket.singleton(); - for(var i = 0; i < rd.get_length(); i++) { - _this.addRepo(rd.get_object_element(i)); - } - - - } catch (Error e) { - GLib.error(e.message); - return; - } - - } + public void loadProjectOptions(string pid) { var rt = RooTicket.singleton(); diff --git a/StatusIcon.vala b/StatusIcon.vala index 652f5f79..d6b34d18 100644 --- a/StatusIcon.vala +++ b/StatusIcon.vala @@ -460,7 +460,8 @@ public class StatusIconA : StatusIcon { this.accel_group = null; this.activate.connect( () => { - GitRepo.updateAll("show_clones"); + //GitRepo.updateAll("show_clones"); + Clones.singleton().loadAndShow(); // Clones.singleton().show(); }); diff --git a/Ticket.bjs b/Ticket.bjs index a451a071..cd95bbbe 100644 --- a/Ticket.bjs +++ b/Ticket.bjs @@ -17,18 +17,20 @@ "title" : "Create a Ticket", "xtype" : "Dialog", "# GitRepo? repo" : "null", - "| void show" : "( GitRepo? repo ) \n{\n // this.el.set_gravity(Gdk.Gravity.NORTH);\n if (this.running) { // should not happen!!\n \tGLib.error(\"new branch show called, when already being displayed?\");\n\t}\n \n\t\n\tthis.running = true;\n\t//GitMonitor.gitmonitor.stop();\n\t\n this.repo = repo;\n \n \n \n \n\tthis.el.move((Gdk.Screen.width() / 2)- 250 ,0);\n\tthis.el.set_default_size( 500,200); // not sure why it grows..\n GLib.debug(\"Loading tickets\"); \n \n\n this.el.show_all();\n this.el.set_keep_above(true);\n \n\n\tRooProject? curproj = null;\n if (this.repo != null) {\n\t curproj = RooTicket.singleton().getProjectByRepo(this.repo);\n }\n\t_this.prmodel.loadProjects(curproj == null ? \"\" : curproj.id);\n if (curproj != null) {\n \n\t\t\n\t\tvar rt = RooTicket.singleton();\n\t\trt.loadProjectOptions(curproj.id);\n\t\t\n\t\t_this.msmodel.loadMilestones();\n\t\t_this.primodel.loadPriorities();\n\t\t_this.sevmodel.loadSeverities();\n\t\t_this.clmodel.loadClassifications();\t\n\t\t_this.devmodel.loadDevelopers();\t\n\t\t\n }\n \t_this.summary.el.set_text(\"\");\n\t\t_this.description.el.buffer.text = \"\"; \n \n \n \tthis.el.run();\n\n}", + "| void show" : "( GitRepo? repo ) \n{\n // this.el.set_gravity(Gdk.Gravity.NORTH);\n if (this.running) { // should not happen!!\n \tGLib.error(\"new branch show called, when already being displayed?\");\n\t}\n \tthis.running = true;\n \n \t_this.el.show_all();\n\t\n\t_this.table.el.hide();\n\n\t_this.spinner.el.show();\n\t_this.spinner.el.start();\t\n\tthis.el.set_keep_above(true); \n\tthis.el.move((Gdk.Screen.width() / 2)- 250 ,0);\n\tthis.el.set_default_size( 500,200); // not sure why it grows..\n\t\n\tGLib.debug(\"Showing dialog?\"); \n Timeout.add_seconds(1, () => {\n\t\t\n\t\t\n\t\t\n\n\t\t//GitMonitor.gitmonitor.stop();\n\t\t\n\t\tthis.repo = repo;\n\t\t\n\t\t\n\t\t\n\t\t\n\t// GLib.debug(\"Loading tickets\"); \n\t\t \n\n\n\t\tRooProject? curproj = null;\n\t\tif (this.repo != null) {\n\t\t\tcurproj = RooProject.getProjectByRepo(this.repo);\n\t\t}\n\t\t_this.prmodel.loadProjects(curproj == null ? \"\" : curproj.id);\n\t\tif (curproj != null) {\n\t \n\t\t\t\n\t\t\tvar rt = RooTicket.singleton();\n\t\t\trt.loadProjectOptions(curproj.id);\n\t\t\t\n\t\t\t_this.msmodel.loadMilestones();\n\t\t\t_this.primodel.loadPriorities();\n\t\t\t_this.sevmodel.loadSeverities();\n\t\t\t_this.clmodel.loadClassifications();\t\n\t\t\t_this.devmodel.loadDevelopers();\t\n\t\t\t\n\t\t}\n\t\t_this.summary.el.set_text(\"\");\n\t\t_this.description.el.buffer.text = \"\"; \n\t\t_this.spinner.el.stop();\n\t\t_this.spinner.el.hide();\t\n\n\t\tthis.table.el.show();\n\t \n\n\t \n\n\t \n\t \t\n\t \treturn false;\n \t});\n \tthis.el.run();\n \t\n\n}", "default_height" : 200, "$ xns" : "Gtk", "# bool running" : false, "bool modal" : true, "items" : [ { - "xtype" : "VBox", + "xtype" : "Box", "$ pack" : "get_content_area().add", "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", "items" : [ { + "id" : "table", "bool homogeneous" : true, "bool expand" : false, "xtype" : "Table", @@ -77,7 +79,7 @@ "$ xns" : "Gtk" }, { - "| void loadProjects" : " (string id) {\n\n var rt = RooTicket.singleton();\n rt.loadProjects();\n \n _this.project_id.loading = true;\n\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n el.append(out iter);\n\n \n el.set_value(iter, 0, \"\");\n el.set_value(iter, 1, \"-- select a project --\");\n if (id == \"\") {\n\t _this.project_id.el.set_active_iter(iter);\n }\n var projects = rt.projects;\n foreach(var project in projects) {\n \n el.append(out iter);\n \n el.set_value(iter, 0, project.id);\n el.set_value(iter, 1, project.name );\n if (id == project.id) {\n\t \t _this.project_id.el.set_active_iter(iter);\n\t } \n \n }\n \n _this.project_id.loading = false;\n //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); \n \n}\n", + "| void loadProjects" : " (string id) {\n\n \n _this.project_id.loading = true;\n\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n el.append(out iter);\n\n \n el.set_value(iter, 0, \"\");\n el.set_value(iter, 1, \"-- select a project --\");\n if (id == \"\") {\n\t _this.project_id.el.set_active_iter(iter);\n }\n\n foreach(var project in RooProject.projects()) {\n \n el.append(out iter);\n \n el.set_value(iter, 0, project.id);\n el.set_value(iter, 1, project.name );\n if (id == project.id) {\n\t \t _this.project_id.el.set_active_iter(iter);\n\t } \n \n }\n \n _this.project_id.loading = false;\n //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); \n \n}\n", "id" : "prmodel", "* pack" : "set_model", "xtype" : "ListStore", @@ -268,6 +270,14 @@ "$ xns" : "Gtk" } ] + }, + { + "id" : "spinner", + "bool hexpand" : true, + "* pack" : "add", + "xtype" : "Spinner", + "$ xns" : "Gtk", + "bool vexpand" : true } ] } diff --git a/Ticket.vala b/Ticket.vala index 6c5b0288..12eb4684 100644 --- a/Ticket.vala +++ b/Ticket.vala @@ -12,6 +12,7 @@ public class Ticket : Object } return _Ticket; } + public Xcls_table table; public Xcls_project_id project_id; public Xcls_prcellrenderer prcellrenderer; public Xcls_prmodel prmodel; @@ -27,6 +28,7 @@ public class Ticket : Object public Xcls_clmodel clmodel; public Xcls_developer_id developer_id; public Xcls_devmodel devmodel; + public Xcls_spinner spinner; // my vars (def) public GitRepo? repo; @@ -48,7 +50,7 @@ public class Ticket : 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 ); @@ -97,75 +99,99 @@ public class Ticket : Object if (this.running) { // should not happen!! GLib.error("new branch show called, when already being displayed?"); } + this.running = true; + _this.el.show_all(); - this.running = true; - //GitMonitor.gitmonitor.stop(); - - this.repo = repo; - - - - + _this.table.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); this.el.set_default_size( 500,200); // not sure why it grows.. - GLib.debug("Loading tickets"); - - - this.el.show_all(); - this.el.set_keep_above(true); - + + GLib.debug("Showing dialog?"); + Timeout.add_seconds(1, () => { + + + - RooProject? curproj = null; - if (this.repo != null) { - curproj = RooTicket.singleton().getProjectByRepo(this.repo); - } - _this.prmodel.loadProjects(curproj == null ? "" : curproj.id); - if (curproj != null) { - + //GitMonitor.gitmonitor.stop(); - var rt = RooTicket.singleton(); - rt.loadProjectOptions(curproj.id); + this.repo = repo; - _this.msmodel.loadMilestones(); - _this.primodel.loadPriorities(); - _this.sevmodel.loadSeverities(); - _this.clmodel.loadClassifications(); - _this.devmodel.loadDevelopers(); - } - _this.summary.el.set_text(""); + + + // GLib.debug("Loading tickets"); + + + + RooProject? curproj = null; + if (this.repo != null) { + curproj = RooProject.getProjectByRepo(this.repo); + } + _this.prmodel.loadProjects(curproj == null ? "" : curproj.id); + if (curproj != null) { + + + var rt = RooTicket.singleton(); + rt.loadProjectOptions(curproj.id); + + _this.msmodel.loadMilestones(); + _this.primodel.loadPriorities(); + _this.sevmodel.loadSeverities(); + _this.clmodel.loadClassifications(); + _this.devmodel.loadDevelopers(); + + } + _this.summary.el.set_text(""); _this.description.el.buffer.text = ""; - - + _this.spinner.el.stop(); + _this.spinner.el.hide(); + + 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 Ticket _this; // my vars (def) // ctor - public Xcls_VBox2(Ticket _owner ) + public Xcls_Box2(Ticket _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_spinner( _this ); + child_1.ref(); + this.el.add ( child_1.el ); } // user defined functions } - public class Xcls_Table3 : Object + public class Xcls_table : Object { public Gtk.Table el; private Ticket _this; @@ -174,9 +200,10 @@ public class Ticket : Object // my vars (def) // ctor - public Xcls_Table3(Ticket _owner ) + public Xcls_table(Ticket _owner ) { _this = _owner; + _this.table = this; this.el = new Gtk.Table( 14, 4, true ); // my vars (dec) @@ -426,8 +453,6 @@ public class Ticket : Object // user defined functions public void loadProjects (string id) { - var rt = RooTicket.singleton(); - rt.loadProjects(); _this.project_id.loading = true; @@ -443,8 +468,8 @@ public class Ticket : Object if (id == "") { _this.project_id.el.set_active_iter(iter); } - var projects = rt.projects; - foreach(var project in projects) { + + foreach(var project in RooProject.projects()) { el.append(out iter); @@ -1252,5 +1277,30 @@ public class Ticket : Object } + public class Xcls_spinner : Object + { + public Gtk.Spinner el; + private Ticket _this; + + + // my vars (def) + + // ctor + public Xcls_spinner(Ticket _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 + } + } diff --git a/config1.builder b/config1.builder index 3e98e73e..8c01d09d 100644 --- a/config1.builder +++ b/config1.builder @@ -21,7 +21,9 @@ "..//gitlive/MergeBranch.vala", "..//gitlive/RepoStatusPopover.vala", "..//gitlive/Clone.vala", - "..//gitlive/Ticket.vala" + "..//gitlive/Ticket.vala", + "..//gitlive/RooProject.vala", + "..//gitlive/RooRepo.vala" ], "packages" : [ ]