Uncommited changes synced
authorAlan Knowles <alan@roojs.com>
Wed, 30 Jan 2019 08:18:04 +0000 (16:18 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 30 Jan 2019 08:18:04 +0000 (16:18 +0800)
1  2 
MergeBranch.bjs
MergeBranch.vala
NewBranch.bjs
RooTicket.vala

diff --cc MergeBranch.bjs
    {
     "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}"
++    "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\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,
--   "# GitRepo repo" : "",
     "$ deletable" : true,
++   "# GitRepo repo" : "",
     "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\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\t\n    this.ticket = ticket;\n    this.repo = repo;\n    \n\t\n\tTimeout.add_seconds(1, () => {\n\t    _this.diff_view.el.get_buffer().set_text(\n\t    \trepo != null ? repo.previewMerge() : GitRepo.previewMerges(ticket.id)\n    \t);\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}",
++   "|   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\t\n    this.ticket = ticket;\n    this.repo = repo;\n    \n\t\n\tTimeout.add_seconds(1, () => {\n\t\n        _this.prmodel.loadProjects(ticket.project_id);\n\t\n\t    _this.diff_view.el.get_buffer().set_text(\n\t    \trepo != null ? repo.previewMerge() : GitRepo.previewMerges(ticket.id)\n    \t);\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(ticket.project_id);\n\t \t_this.actionmodel.loadActions();\n\t \t_this.mergebtn.updateState();\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",
         "uint column_spacing" : 2,
         "n_columns" : 2,
         "$ xns" : "Gtk",
--       "n_rows" : 2,
++       "n_rows" : 4,
         "bool vexpand" : false,
         "int margin" : 2,
         "items" : [
          {
           "label" : "Do what?",
           "$ visible" : true,
--         "xalign" : 0.90000000000000002,
++         "Gtk.Align halign" : "Gtk.Align.END",
++         "int margin_right" : 3,
           "* pack" : "attach_defaults,0,1,0,1",
           "xtype" : "Label",
--         "$ justify" : "Gtk.Justification.RIGHT",
--         "x_options" : 4,
           "$ xns" : "Gtk"
          },
          {
           "listeners" : {
--          "changed" : "() => {\n\tif (this.loading) {\n\t\treturn;\n\t}\n  \t_this.name.updateText();\n\t//GLib.debug (//\"Selection: %s, %s\\n\", (string) val1, (string) val2);\n}"
++          "changed" : "() => {\n\tif (this.loading) {\n\t\treturn;\n\t}\n  \t_this.name.updateText();\n  \t_this.mergebtn.updateState();\n\t//GLib.debug (//\"Selection: %s, %s\\n\", (string) val1, (string) val2);\n}"
           },
           "id" : "actionsel",
           "* init" : "this.el.add_attribute(_this.actioncellrenderer.el , \"markup\", 1 );",
++         "bool hexpand" : true,
           "* pack" : "attach_defaults,1,2,0,1",
           "xtype" : "ComboBox",
           "# bool loading" : false,
           "items" : [
            {
             "id" : "actioncellrenderer",
--           "* pack" : "pack_start,true",
             "xtype" : "CellRendererText",
++           "* pack" : "pack_start,true",
             "$ xns" : "Gtk"
            },
            {
             "id" : "actionmodel",
--           "* pack" : "set_model",
             "xtype" : "ListStore",
++           "* pack" : "set_model",
             "$ columns" : "typeof(string),typeof(string)",
             "n_columns" : 2,
             "$ xns" : "Gtk",
            }
           ]
          },
++        {
++         "label" : "Project",
++         "$ visible" : true,
++         "Gtk.Align halign" : "Gtk.Align.END",
++         "int margin_right" : 3,
++         "* pack" : "attach_defaults,0,1,1,2",
++         "xtype" : "Label",
++         "x_options" : 4,
++         "$ xns" : "Gtk"
++        },
++        {
++         "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()",
++         "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);",
++         "bool hexpand" : true,
++         "* pack" : "attach_defaults,1,2,1,2",
++         "xtype" : "ComboBox",
++         "# bool loading" : false,
++         "$ xns" : "Gtk",
++         "items" : [
++          {
++           "id" : "prcellrenderer",
++           "xtype" : "CellRendererText",
++           "* pack" : "pack_start,true",
++           "$ xns" : "Gtk"
++          },
++          {
++           "| 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",
++           "$ columns" : "typeof(string),typeof(string)",
++           "n_columns" : 2,
++           "$ xns" : "Gtk"
++          }
++         ]
++        },
          {
           "label" : "Select Ticket",
           "$ visible" : true,
++         "Gtk.Align halign" : "Gtk.Align.END",
           "xalign" : 0.90000000000000002,
--         "* pack" : "attach_defaults,0,1,1,2",
++         "int margin_right" : 3,
++         "* pack" : "attach_defaults,0,1,2,3",
           "xtype" : "Label",
           "$ justify" : "Gtk.Justification.RIGHT",
           "x_options" : 4,
           },
           "id" : "ticketsel",
           "* init" : "this.el.add_attribute(_this.dbcellrenderer.el , \"markup\", 1 );",
--         "* pack" : "attach_defaults,1,2,1,2",
++         "bool hexpand" : true,
++         "* pack" : "attach_defaults,1,2,2,3",
           "xtype" : "ComboBox",
           "# bool loading" : true,
           "$ xns" : "Gtk",
           "items" : [
            {
             "id" : "dbcellrenderer",
--           "xtype" : "CellRendererText",
             "* pack" : "pack_start,true",
++           "xtype" : "CellRendererText",
             "$ xns" : "Gtk"
            },
            {
             "id" : "dbmodel",
--           "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",
++           "xtype" : "ListStore",
++           "| void loadTickets" : "  (string project_id) {\n\n    RooTicket.singleton().loadTickets(project_id,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,
             "$ xns" : "Gtk"
            }
           ]
          },
++        {
++         "* pack" : "attach_defaults,0,2,3,4",
++         "xtype" : "Box",
++         "$ xns" : "Gtk",
++         "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
++         "items" : [
++          {
++           "listeners" : {
++            "toggled" : "() => {\n\tvar project_id = _this.projectsel.selectedProjectId();\n\t_this.dbmodel.loadTickets(project_id);\t\n}"
++           },
++           "id" : "btn_not_me",
++           "string label" : "Show tickets not assigned to me",
++           "* pack" : "add",
++           "xtype" : "CheckButton",
++           "$ xns" : "Gtk"
++          },
++          {
++           "listeners" : {
++            "toggled" : "() => {\n \tvar project_id = _this.projectsel.selectedProjectId();\n\t_this.dbmodel.loadTickets(project_id);\t\n\t \n}"
++           },
++           "id" : "btn_closed",
++           "xtype" : "CheckButton",
++           "string label" : "Show closed Tickets",
++           "* pack" : "add",
++           "$ xns" : "Gtk"
++          },
++          {
++           "listeners" : {
++            "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",
++           "bool hexpand" : true,
++           "* pack" : "add",
++           "xtype" : "Label",
++           "string label" : "<a href=\"refresh\">Refresh Ticket list</a>",
++           "$ xns" : "Gtk"
++          }
++         ]
++        },
          {
           "label" : "Use this commit message",
--         "xalign" : 0.90000000000000002,
--         "* pack" : "attach_defaults,0,1,2,3",
++         "Gtk.Align halign" : "Gtk.Align.END",
++         "int margin_right" : 3,
++         "* pack" : "attach_defaults,0,1,4,5",
           "xtype" : "Label",
--         "$ justify" : "Gtk.Justification.RIGHT",
           "x_options" : 4,
           "$ xns" : "Gtk"
          },
           "$ visible" : true,
           "| void updateText" : "() {\n\tvar ticket_id = _this.ticketsel.selectedTicketId();\n\t\n\tRooTicket ticket = null;\n\tif (ticket_id.length > 0){\n\t\tticket = RooTicket.singleton().getById(ticket_id);\n\t}\n\t\n\tvar name = RooTicket.singleton().usernameLocal();\n\tvar action = _this.actionsel.selectedAction();\n\tthis.el.set_editable(true); \n \tswitch (action) {\n \t\tcase \"CLOSE\": // merge changes and close..\n\t \t\tthis.el.set_text(\"Fix #%s - %s\".printf(ticket_id, ticket != null ? ticket.summary : \"\"));\n\t \t\tbreak;\n\t \tcase \"LEAVE\": // partial fix\t\n\t \t\tthis.el.set_text(\"Partial Fix #%s - %s\".printf(ticket_id,   ticket != null ? ticket.summary : \"\"));\n\t \t\tbreak;\n \t\tcase \"MASTER\": // merge master\n \t\tcase \"EXIT\": // just switch back... \t\t\n \t\t\tthis.el.set_editable(false);\n\t \t\tthis.el.set_text(\"\"); // not relivant.. \t\t\t\n\t\t\tbreak;\n \t\tdefault:\n \t\t\n \t\t\tbreak; /// don't fix the text value.\n\t}\n   \n}\n",
           "xtype" : "Entry",
--         "* pack" : "attach_defaults,1,2,2,3",
++         "* pack" : "attach_defaults,1,2,4,5",
           "$ xns" : "Gtk"
          }
         ]
         "items" : [
          {
           "id" : "label_diff",
--         "* pack" : false,
           "xtype" : "Label",
++         "* pack" : false,
           "string label" : "Projected Commit Diff",
           "$ xns" : "Gtk"
          },
          {
           "id" : "label_ticket",
--         "string label" : "Ticket Details",
           "* pack" : false,
++         "string label" : "Ticket Details",
           "xtype" : "Label",
           "$ xns" : "Gtk"
          },
           "items" : [
            {
             "int height_request" : 400,
--           "* pack" : "pack_start,true,true,0",
             "xtype" : "ScrolledWindow",
++           "* pack" : "pack_start,true,true,0",
             "$ xns" : "Gtk",
             "items" : [
              {
             "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"
              }
      },
      {
       "label" : "Cancel",
--     "xtype" : "Button",
       "* pack" : "add_action_widget,0",
++     "xtype" : "Button",
       "Gtk.ReliefStyle relief" : "Gtk.ReliefStyle.NONE",
       "$ xns" : "Gtk"
      },
      {
       "label" : "Do Merge",
++     "| void updateState" : "() {\n\tif (_this.actionsel.selectedAction() == \"\") {\n\t\t// need to select an action..\n\t\tthis.el.set_sensitive(false);\n\t\treturn;\n\t\n\t\n\t}\n\t\tthis.el.set_sensitive(true);\n\t\treturn;\n}\n",
++     "id" : "mergebtn",
       "* init" : "{\n   this.el.get_style_context().add_class(\"suggested-action\");\n}\n",
       "xtype" : "Button",
       "* pack" : "add_action_widget,1",
@@@ -16,9 -16,9 +16,14 @@@ public class MergeBranch : Objec
      public Xcls_actionsel actionsel;
      public Xcls_actioncellrenderer actioncellrenderer;
      public Xcls_actionmodel actionmodel;
++    public Xcls_projectsel projectsel;
++    public Xcls_prcellrenderer prcellrenderer;
++    public Xcls_prmodel prmodel;
      public Xcls_ticketsel ticketsel;
      public Xcls_dbcellrenderer dbcellrenderer;
      public Xcls_dbmodel dbmodel;
++    public Xcls_btn_not_me btn_not_me;
++    public Xcls_btn_closed btn_closed;
      public Xcls_name name;
      public Xcls_label_diff label_diff;
      public Xcls_label_ticket label_ticket;
@@@ -26,6 -26,6 +31,7 @@@
      public Xcls_scrolled_window scrolled_window;
      public Xcls_view view;
      public Xcls_spinner spinner;
++    public Xcls_mergebtn mergebtn;
  
          // my vars (def)
      public GitRepo repo;
          var child_0 = new Xcls_Box2( _this );
          child_0.ref();
          this.el.get_content_area().add (  child_0.el  );
--        var child_1 = new Xcls_Button24( _this );
++        var child_1 = new Xcls_Button32( _this );
          child_1.ref();
          this.el.add_action_widget (  child_1.el , 0 );
--        var child_2 = new Xcls_Button25( _this );
++        var child_2 = new Xcls_mergebtn( _this );
          child_2.ref();
          this.el.add_action_widget (  child_2.el , 1 );
  
@@@ -73,6 -73,6 +79,9 @@@
                GitMonitor.gitmonitor.start();
                        return;
                }
++              
++              
++              
                 /*
                // have they selected a ticket..
                // make that the current active ticket?
          
        
        Timeout.add_seconds(1, () => {
++      
++            _this.prmodel.loadProjects(ticket.project_id);
++      
            _this.diff_view.el.get_buffer().set_text(
                repo != null ? repo.previewMerge() : GitRepo.previewMerges(ticket.id)
                );              
                // if we are not working on a ticket, then we should be able to pick one?
--              _this.dbmodel.loadTickets();
++              _this.dbmodel.loadTickets(ticket.project_id);
                _this.actionmodel.loadActions();
++              _this.mergebtn.updateState();
                _this.view.loadTicket(ticket.id);
                _this.spinner.el.stop();
                _this.spinner.el.hide();        
              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_Notebook14( _this );
++            var child_1 = new Xcls_Notebook22( _this );
              child_1.ref();
              this.el.add (  child_1.el  );
              var child_2 = new Xcls_spinner( _this );
          {
              _this = _owner;
              _this.table = this;
--            this.el = new Gtk.Table( 2, 2, false );
++            this.el = new Gtk.Table( 4, 2, false );
  
              // my vars (dec)
  
              var child_2 = new Xcls_Label8( _this );
              child_2.ref();
              this.el.attach_defaults (  child_2.el , 0,1,1,2 );
--            var child_3 = new Xcls_ticketsel( _this );
++            var child_3 = new Xcls_projectsel( _this );
              child_3.ref();
              this.el.attach_defaults (  child_3.el , 1,2,1,2 );
              var child_4 = new Xcls_Label12( _this );
              child_4.ref();
              this.el.attach_defaults (  child_4.el , 0,1,2,3 );
--            var child_5 = new Xcls_name( _this );
++            var child_5 = new Xcls_ticketsel( _this );
              child_5.ref();
              this.el.attach_defaults (  child_5.el , 1,2,2,3 );
++            var child_6 = new Xcls_Box16( _this );
++            child_6.ref();
++            this.el.attach_defaults (  child_6.el , 0,2,3,4 );
++            var child_7 = new Xcls_Label20( _this );
++            child_7.ref();
++            this.el.attach_defaults (  child_7.el , 0,1,4,5 );
++            var child_8 = new Xcls_name( _this );
++            child_8.ref();
++            this.el.attach_defaults (  child_8.el , 1,2,4,5 );
          }
  
          // user defined functions
              // my vars (dec)
  
              // set gobject values
--            this.el.justify = Gtk.Justification.RIGHT;
--            this.el.xalign = 0.900000f;
++            this.el.margin_right = 3;
++            this.el.halign = Gtk.Align.END;
              this.el.visible = true;
          }
  
              this.loading = false;
  
              // set gobject values
++            this.el.hexpand = true;
              var child_0 = new Xcls_actioncellrenderer( _this );
              child_0.ref();
              this.el.pack_start (  child_0.el , true );
                        return;
                }
                        _this.name.updateText();
++                      _this.mergebtn.updateState();
                //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
              });
          }
  
          // ctor
          public Xcls_Label8(MergeBranch _owner )
++        {
++            _this = _owner;
++            this.el = new Gtk.Label( "Project" );
++
++            // my vars (dec)
++
++            // set gobject values
++            this.el.margin_right = 3;
++            this.el.halign = Gtk.Align.END;
++            this.el.visible = true;
++        }
++
++        // user defined functions
++    }
++
++    public class Xcls_projectsel : Object
++    {
++        public Gtk.ComboBox el;
++        private MergeBranch  _this;
++
++
++            // my vars (def)
++        public bool loading;
++
++        // ctor
++        public Xcls_projectsel(MergeBranch _owner )
++        {
++            _this = _owner;
++            _this.projectsel = this;
++            this.el = new Gtk.ComboBox.with_entry();
++
++            // my vars (dec)
++            this.loading = false;
++
++            // set gobject values
++            this.el.hexpand = true;
++            var child_0 = new Xcls_prcellrenderer( _this );
++            child_0.ref();
++            this.el.pack_start (  child_0.el , true );
++            var child_1 = new Xcls_prmodel( _this );
++            child_1.ref();
++            this.el.set_model (  child_1.el  );
++
++            // init method
++
++            this.el.set_entry_text_column(1);
++
++            //listeners
++            this.el.changed.connect( () => {
++              if (this.loading) {
++                      return;
++              }
++              var project_id = this.selectedProjectId();
++              _this.dbmodel.loadTickets(project_id);
++              
++              
++              /*if (this.loading) {
++                      return;
++              }
++              var ticket_id = this.selectedTicketId();
++              
++              var name = RooTicket.singleton().usernameLocal();
++              
++              if (ticket_id == "" || ticket_id == null) {
++              
++                      var dt = new  DateTime.now_local();
++                      _this.name.el.set_text("wip_%s_%s".printf(name,dt.format("%Y_%b_%d")));
++                      return;
++              }
++              
++              
++              var ticket = RooTicket.singleton().getById(ticket_id);
++               
++              _this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName()));
++              
++              //GLib.debug (//"Selection: %s, %s\n", (string) val1, (string) val2);
++              */
++            });
++        }
++
++        // user defined functions
++        public string selectedProjectId () {
++              Gtk.TreeIter iter;
++              Value val1;
++         
++         
++              this.el.get_active_iter (out iter);
++              _this.prmodel.el.get_value (iter, 0, out val1);
++         
++        
++              return  (string) val1;
++              
++              
++              
++              
++        }
++    }
++    public class Xcls_prcellrenderer : Object
++    {
++        public Gtk.CellRendererText el;
++        private MergeBranch  _this;
++
++
++            // my vars (def)
++
++        // ctor
++        public Xcls_prcellrenderer(MergeBranch _owner )
++        {
++            _this = _owner;
++            _this.prcellrenderer = this;
++            this.el = new Gtk.CellRendererText();
++
++            // my vars (dec)
++
++            // set gobject values
++        }
++
++        // user defined functions
++    }
++
++    public class Xcls_prmodel : Object
++    {
++        public Gtk.ListStore el;
++        private MergeBranch  _this;
++
++
++            // my vars (def)
++
++        // ctor
++        public Xcls_prmodel(MergeBranch _owner )
++        {
++            _this = _owner;
++            _this.prmodel = this;
++            this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
++
++            // my vars (dec)
++
++            // set gobject values
++        }
++
++        // user defined functions
++        public void loadProjects (string id) {
++        
++        
++            
++            _this.projectsel.loading = true;
++        
++            this.el.clear();                                    
++            Gtk.TreeIter iter;
++            var el = this.el;
++            
++            el.append(out iter);
++        
++            
++            el.set_value(iter, 0, "");
++            el.set_value(iter, 1, "-- select a project --");
++            if (id == "") {
++                  _this.projectsel.el.set_active_iter(iter);
++            }
++          
++            foreach(var project in RooProject.projects()) {
++            
++                el.append(out iter);
++                
++                el.set_value(iter, 0, project.id);
++                el.set_value(iter, 1,  project.name );
++                if (id == project.id) {
++                         _this.projectsel.el.set_active_iter(iter);
++                  }   
++                
++            }
++            
++            _this.projectsel.loading = false;
++             //this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);          
++                                             
++        }
++    }
++
++
++    public class Xcls_Label12 : Object
++    {
++        public Gtk.Label el;
++        private MergeBranch  _this;
++
++
++            // my vars (def)
++
++        // ctor
++        public Xcls_Label12(MergeBranch _owner )
          {
              _this = _owner;
              this.el = new Gtk.Label( "Select Ticket" );
              // my vars (dec)
  
              // set gobject values
++            this.el.margin_right = 3;
++            this.el.halign = Gtk.Align.END;
              this.el.justify = Gtk.Justification.RIGHT;
              this.el.xalign = 0.900000f;
              this.el.visible = true;
              this.loading = true;
  
              // set gobject values
++            this.el.hexpand = true;
              var child_0 = new Xcls_dbcellrenderer( _this );
              child_0.ref();
              this.el.pack_start (  child_0.el , true );
          }
  
          // user defined functions
--        public void loadTickets () {
++        public void loadTickets (string project_id) {
          
--            RooTicket.singleton().loadTickets("",RooTicket.Who.ME, RooTicket.Status.ACTIVE);
++            RooTicket.singleton().loadTickets(project_id,RooTicket.Who.ME, RooTicket.Status.ACTIVE);
              
              _this.ticketsel.loading = true;
          
      }
  
  
--    public class Xcls_Label12 : Object
++    public class Xcls_Box16 : Object
++    {
++        public Gtk.Box el;
++        private MergeBranch  _this;
++
++
++            // my vars (def)
++
++        // ctor
++        public Xcls_Box16(MergeBranch _owner )
++        {
++            _this = _owner;
++            this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
++
++            // my vars (dec)
++
++            // set gobject values
++            var child_0 = new Xcls_btn_not_me( _this );
++            child_0.ref();
++            this.el.add (  child_0.el  );
++            var child_1 = new Xcls_btn_closed( _this );
++            child_1.ref();
++            this.el.add (  child_1.el  );
++            var child_2 = new Xcls_Label19( _this );
++            child_2.ref();
++            this.el.add (  child_2.el  );
++        }
++
++        // user defined functions
++    }
++    public class Xcls_btn_not_me : Object
++    {
++        public Gtk.CheckButton el;
++        private MergeBranch  _this;
++
++
++            // my vars (def)
++
++        // ctor
++        public Xcls_btn_not_me(MergeBranch _owner )
++        {
++            _this = _owner;
++            _this.btn_not_me = this;
++            this.el = new Gtk.CheckButton();
++
++            // my vars (dec)
++
++            // set gobject values
++            this.el.label = "Show tickets not assigned to me";
++
++            //listeners
++            this.el.toggled.connect( () => {
++              var project_id = _this.projectsel.selectedProjectId();
++              _this.dbmodel.loadTickets(project_id);  
++            });
++        }
++
++        // user defined functions
++    }
++
++    public class Xcls_btn_closed : Object
++    {
++        public Gtk.CheckButton el;
++        private MergeBranch  _this;
++
++
++            // my vars (def)
++
++        // ctor
++        public Xcls_btn_closed(MergeBranch _owner )
++        {
++            _this = _owner;
++            _this.btn_closed = this;
++            this.el = new Gtk.CheckButton();
++
++            // my vars (dec)
++
++            // set gobject values
++            this.el.label = "Show closed Tickets";
++
++            //listeners
++            this.el.toggled.connect( () => {
++              var project_id = _this.projectsel.selectedProjectId();
++              _this.dbmodel.loadTickets(project_id);  
++               
++            });
++        }
++
++        // user defined functions
++    }
++
++    public class Xcls_Label19 : Object
      {
          public Gtk.Label el;
          private MergeBranch  _this;
              // my vars (def)
  
          // ctor
--        public Xcls_Label12(MergeBranch _owner )
++        public Xcls_Label19(MergeBranch _owner )
++        {
++            _this = _owner;
++            this.el = new Gtk.Label( "<a href=\"refresh\">Refresh Ticket list</a>" );
++
++            // my vars (dec)
++
++            // set gobject values
++            this.el.halign = Gtk.Align.END;
++            this.el.hexpand = true;
++            this.el.use_markup = true;
++
++            //listeners
++            this.el.activate_link.connect( (uri) => {
++              if (uri == "refresh") {
++                      RooProject.reload();
++                      var curproj = RooProject.getProjectByRepo(_this.repo);
++                       _this.prmodel.loadProjects(curproj == null ? "": curproj.id);
++            
++                      _this.dbmodel.loadTickets(curproj == null ? "": curproj.id);            
++              }
++              return true;
++            });
++        }
++
++        // user defined functions
++    }
++
++
++    public class Xcls_Label20 : Object
++    {
++        public Gtk.Label el;
++        private MergeBranch  _this;
++
++
++            // my vars (def)
++
++        // ctor
++        public Xcls_Label20(MergeBranch _owner )
          {
              _this = _owner;
              this.el = new Gtk.Label( "Use this commit message" );
              // my vars (dec)
  
              // set gobject values
--            this.el.justify = Gtk.Justification.RIGHT;
--            this.el.xalign = 0.900000f;
++            this.el.margin_right = 3;
++            this.el.halign = Gtk.Align.END;
          }
  
          // user defined functions
      }
  
  
--    public class Xcls_Notebook14 : Object
++    public class Xcls_Notebook22 : Object
      {
          public Gtk.Notebook el;
          private MergeBranch  _this;
              // my vars (def)
  
          // ctor
--        public Xcls_Notebook14(MergeBranch _owner )
++        public Xcls_Notebook22(MergeBranch _owner )
          {
              _this = _owner;
              this.el = new Gtk.Notebook();
              child_0.ref();
              var child_1 = new Xcls_label_ticket( _this );
              child_1.ref();
--            var child_2 = new Xcls_Box17( _this );
++            var child_2 = new Xcls_Box25( _this );
              child_2.ref();
              this.el.append_page (  child_2.el , _this.label_diff.el );
--            var child_3 = new Xcls_Box20( _this );
++            var child_3 = new Xcls_Box28( _this );
              child_3.ref();
              this.el.append_page (  child_3.el , _this.label_ticket.el );
          }
          // user defined functions
      }
  
--    public class Xcls_Box17 : Object
++    public class Xcls_Box25 : Object
      {
          public Gtk.Box el;
          private MergeBranch  _this;
              // my vars (def)
  
          // ctor
--        public Xcls_Box17(MergeBranch _owner )
++        public Xcls_Box25(MergeBranch _owner )
          {
              _this = _owner;
              this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
  
              // set gobject values
              this.el.homogeneous = false;
--            var child_0 = new Xcls_ScrolledWindow18( _this );
++            var child_0 = new Xcls_ScrolledWindow26( _this );
              child_0.ref();
              this.el.pack_start (  child_0.el , true,true,0 );
          }
  
          // user defined functions
      }
--    public class Xcls_ScrolledWindow18 : Object
++    public class Xcls_ScrolledWindow26 : Object
      {
          public Gtk.ScrolledWindow el;
          private MergeBranch  _this;
              // my vars (def)
  
          // ctor
--        public Xcls_ScrolledWindow18(MergeBranch _owner )
++        public Xcls_ScrolledWindow26(MergeBranch _owner )
          {
              _this = _owner;
              this.el = new Gtk.ScrolledWindow( null, null );
  
  
  
--    public class Xcls_Box20 : Object
++    public class Xcls_Box28 : Object
      {
          public Gtk.Box el;
          private MergeBranch  _this;
              // my vars (def)
  
          // ctor
--        public Xcls_Box20(MergeBranch _owner )
++        public Xcls_Box28(MergeBranch _owner )
          {
              _this = _owner;
              this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
      }
  
  
--    public class Xcls_Button24 : Object
++    public class Xcls_Button32 : Object
      {
          public Gtk.Button el;
          private MergeBranch  _this;
              // my vars (def)
  
          // ctor
--        public Xcls_Button24(MergeBranch _owner )
++        public Xcls_Button32(MergeBranch _owner )
          {
              _this = _owner;
              this.el = new Gtk.Button();
          // user defined functions
      }
  
--    public class Xcls_Button25 : Object
++    public class Xcls_mergebtn : Object
      {
          public Gtk.Button el;
          private MergeBranch  _this;
              // my vars (def)
  
          // ctor
--        public Xcls_Button25(MergeBranch _owner )
++        public Xcls_mergebtn(MergeBranch _owner )
          {
              _this = _owner;
++            _this.mergebtn = this;
              this.el = new Gtk.Button();
  
              // my vars (dec)
          }
  
          // user defined functions
++        public void updateState () {
++              if (_this.actionsel.selectedAction() == "") {
++                      // need to select an action..
++                      this.el.set_sensitive(false);
++                      return;
++              
++              
++              }
++                      this.el.set_sensitive(true);
++                      return;
++        }
      }
  
  }
diff --cc NewBranch.bjs
@@@ -66,8 -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()",
--         "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",
++         "id" : "projectsel",
           "* init" : "this.el.set_entry_text_column(1);",
           "* pack" : "attach_defaults,0,1,1,2",
           "xtype" : "ComboBox",
@@@ -76,8 -76,8 +76,8 @@@
           "items" : [
            {
             "id" : "prcellrenderer",
--           "xtype" : "CellRendererText",
             "* pack" : "pack_start,true",
++           "xtype" : "CellRendererText",
             "$ xns" : "Gtk"
            },
            {
           "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" : "(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,
            "clicked" : "() => {\n    _this.el.response(-1);\n\tTicket.singleton().show(_this.repo);\n\n}"
           },
           "bool expand" : false,
--         "xtype" : "Button",
           "* pack" : "attach_defaults,4,5,1,2",
++         "xtype" : "Button",
           "string label" : "New Ticket",
           "$ xns" : "Gtk"
          },
              "toggled" : "() => {\n\tvar project_id = _this.projectsel.selectedProjectId();\n\t_this.dbmodel.loadTickets(project_id);\t\n}"
             },
             "id" : "btn_not_me",
--           "string label" : "Show tickets not assigned to me",
             "* pack" : "add",
++           "string label" : "Show tickets not assigned to me",
             "xtype" : "CheckButton",
             "$ xns" : "Gtk"
            },
              "toggled" : "() => {\n \tvar project_id = _this.projectsel.selectedProjectId();\n\t_this.dbmodel.loadTickets(project_id);\t\n\t \n}"
             },
             "id" : "btn_closed",
--           "xtype" : "CheckButton",
             "string label" : "Show closed Tickets",
++           "xtype" : "CheckButton",
             "* pack" : "add",
             "$ xns" : "Gtk"
            },
         "items" : [
          {
           "id" : "view",
--         "xtype" : "WebView",
           "* pack" : "add",
++         "xtype" : "WebView",
           "$ 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 --cc RooTicket.vala
@@@ -69,6 -69,6 +69,7 @@@ public class RooTicket : Objec
        public string  id; // not really important that they are numbers..
        public string summary;
        public string description;
++      public string project_id;       
        public string project_id_name;
  
  
                add.id = t.get_string_member("id");
                add.summary = t.get_string_member("summary");
                add.description = t.get_string_member("description");
++              add.project_id = t.get_string_member("project_id");                                                             
                add.project_id_name = t.get_string_member("project_id_name");                                           
                this.tickets.add(add);
                GLib.debug("ADD ticket  %s : %s : %s", add.id, add.summary, add.project_id_name);
                t.id = "-1";
                t.summary = "";
                t.description = "";
++              t.project_id = "";              
                t.project_id_name = "";
                RooTicket.singleton().tickets.add(t);
                return t;