Ticket.bjs
[gitlive] / Clone.bjs
index d9baf37..e6e034f 100644 (file)
--- a/Clone.bjs
+++ b/Clone.bjs
@@ -8,8 +8,7 @@
  "build_module" : "gitlive",
  "items" : [
   {
-   "GitRepo repo" : "",
-   "| void show" : " (Gtk.Widget btn, GitRepo repo) {\n \n    \t//console.log('show all');\n\tthis.el.set_modal(true);\n\tthis.el.set_relative_to(btn);\n  \n\t//this.el.set_position(Gtk.PositionType.RIGHT);\n\n\t// window + header?\n\t GLib.debug(\"SHOWALL - POPIP\\n\");\n\tthis.el.show_all();\n;\n}\n",
+   "| void show" : " (Gtk.Widget btn) {\n \n    \t//console.log('show all');\n\tthis.el.set_modal(true);\n\tthis.el.set_relative_to(btn);\n  \tthis.repomodel.loadRepos();\n\t//this.el.set_position(Gtk.PositionType.RIGHT);\n\n\t// window + header?\n\t GLib.debug(\"SHOWALL - POPIP\\n\");\n\tthis.el.show_all();\n;\n}\n",
    "xtype" : "Popover",
    "Gtk.PositionType position" : "Gtk.PositionType.RIGHT",
    "$ xns" : "Gtk",
@@ -17,7 +16,7 @@
    "uint border_width" : 0,
    "items" : [
     {
-     "* pack" : "pack_end,false,false,0",
+     "* pack" : "add",
      "xtype" : "Box",
      "gboolean expand" : false,
      "$ xns" : "Gtk",
      "gboolean vexpand" : false,
      "items" : [
       {
-       "listeners" : {
-        "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 selectedRepo" : "() {\n\tGtk.TreeIter iter;\n\tValue val1;\n \n \n\tthis.el.get_active_iter (out iter);\n\t_this.repomodel.el.get_value (iter, 0, out val1);\n \n\n\treturn  (string) val1;\n\t\n\t\n\t\n\t\n}\n",
+       "id" : "reposel",
        "* init" : "this.el.set_entry_text_column(1);",
        "bool hexpand" : true,
-       "* pack" : "attach_defaults,0,1,1,2",
+       "* pack" : "add",
        "xtype" : "ComboBox",
        "# bool loading" : false,
        "$ xns" : "Gtk",
        "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",
-         "id" : "prmodel",
+         "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",
          "* pack" : "set_model",
          "xtype" : "ListStore",
          "$ columns" : "typeof(string),typeof(string)",
       },
       {
        "listeners" : {
-        "button_press_event" : "() => {\n       _this.el.hide();\n        return false;\n}"
+        "button_press_event" : "() => {\n      _this.el.hide();\n      Clones.singleton().el.hide();\n     var repo = _this.reposel.selectedRepo();\n        GitMonitor.gitmonitor.stop();\n        \n    \n        string[]  args = { \"git\" , \"--no-pager\" , \"clone\" };\n    \n        args +=  (\"http://git.roojs.com/\" + repo );\n \n    \n\n        string[]   env = {};\n        string  home = \"HOME=\" + Environment.get_home_dir() ;\n        env +=  home ;\n   \t\t//v.push(\"GITPATH=\" + this.repo );\n        //}\n          \n        var cfg = new SpawnConfig(Environment.get_home_dir() + \"/gitlive\" , args , env);\n        //cfg.debug = true;\n\n       // may throw error...\n        var sp = new Spawn(cfg);\n      \n      \t GLib.debug(\"Spawn: %s\", sp.output);\n\t\n        \n        \n        \n        \n        \n        GitMonitor.gitmonitor.start();\n\n         GitRepo.updateAll(\"show_clones\");\n      \n        return false;\n}"
        },
        "label" : "Checkout",
-       "* pack" : "add",
        "xtype" : "Button",
+       "* pack" : "add",
        "$ xns" : "Gtk"
       }
      ]