From 01e7beaf18d9aca3c2c2ad6f60c4b183aa177888 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Tue, 18 Dec 2018 13:00:33 +0800 Subject: [PATCH] Changed MergeBranch.bjsMergeBranch.vala --- MergeBranch.bjs | 44 +++++++++++++------ MergeBranch.vala | 109 +++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 127 insertions(+), 26 deletions(-) diff --git a/MergeBranch.bjs b/MergeBranch.bjs index 9375c8e5..905cd03a 100644 --- a/MergeBranch.bjs +++ b/MergeBranch.bjs @@ -14,11 +14,11 @@ "show" : "(self) => {\n \n\n //test\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\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 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}", "default_height" : 200, "# RooTicket? ticket" : "null", "$ xns" : "Gtk", @@ -26,18 +26,20 @@ "bool modal" : true, "items" : [ { - "xtype" : "VBox", + "xtype" : "Box", "$ pack" : "get_content_area().add", "$ xns" : "Gtk", + "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", "items" : [ { "bool homogeneous" : false, - "xtype" : "Table", "* pack" : "pack_start,false,false,0", + "xtype" : "Table", "uint column_spacing" : 2, "n_columns" : 2, "$ xns" : "Gtk", "n_rows" : 2, + "bool vexpand" : false, "int margin" : 2, "items" : [ { @@ -64,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", @@ -91,26 +93,26 @@ }, { "listeners" : { - "changed" : "() => {\n\tif (this.loading) {\n\t\treturn;\n\t}\n\t\n\t \n \t_this.name.updateText();\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}" + "changed" : "() => {\n\tif (this.loading) {\n\t\treturn;\n\t}\n\t_this.view.loadTicket(this.selectedTicketId());\n\t \n \t_this.name.updateText();\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}" }, "id" : "ticketsel", "* init" : "this.el.add_attribute(_this.dbcellrenderer.el , \"markup\", 1 );", "* pack" : "attach_defaults,1,2,1,2", "xtype" : "ComboBox", - "# bool loading" : false, + "# bool loading" : true, "$ xns" : "Gtk", "| string selectedTicketId" : "() {\nGtk.TreeIter iter;\n\tValue val1;\n \n \n\tthis.el.get_active_iter (out iter);\n\t_this.dbmodel.el.get_value (iter, 0, out val1);\n \n\n\treturn (string) val1;\n\t\n\t\n\t\n\t\n}\n", "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, @@ -136,20 +138,38 @@ "$ xns" : "Gtk" } ] + }, + { + "int height_request" : 500, + "id" : "scrolled_window", + "* init" : "{\n\tthis.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n}\n", + "* pack" : "add", + "xtype" : "ScrolledWindow", + "$ xns" : "Gtk", + "bool vexpand" : true, + "items" : [ + { + "id" : "view", + "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", - "* 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", "xtype" : "Button", + "* pack" : "add_action_widget,1", "$ xns" : "Gtk" } ] diff --git a/MergeBranch.vala b/MergeBranch.vala index 737dab4e..90a65b36 100644 --- a/MergeBranch.vala +++ b/MergeBranch.vala @@ -19,6 +19,8 @@ public class MergeBranch : Object public Xcls_dbcellrenderer dbcellrenderer; public Xcls_dbmodel dbmodel; public Xcls_name name; + public Xcls_scrolled_window scrolled_window; + public Xcls_view view; // my vars (def) public GitRepo repo; @@ -41,13 +43,13 @@ public class MergeBranch : 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 ); - var child_1 = new Xcls_Button14( _this ); + var child_1 = new Xcls_Button16( _this ); child_1.ref(); this.el.add_action_widget ( child_1.el , 0 ); - var child_2 = new Xcls_Button15( _this ); + var child_2 = new Xcls_Button17( _this ); child_2.ref(); this.el.add_action_widget ( child_2.el , 1 ); @@ -134,22 +136,22 @@ public class MergeBranch : Object this.el.show_all(); _this.dbmodel.loadTickets(); _this.actionmodel.loadActions(); - + _this.view.loadTicket(ticket.id); } - public class Xcls_VBox2 : Object + public class Xcls_Box2 : Object { - public Gtk.VBox el; + public Gtk.Box el; private MergeBranch _this; // my vars (def) // ctor - public Xcls_VBox2(MergeBranch _owner ) + public Xcls_Box2(MergeBranch _owner ) { _this = _owner; - this.el = new Gtk.VBox( true, 0 ); + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); // my vars (dec) @@ -157,6 +159,9 @@ public class MergeBranch : Object var child_0 = new Xcls_Table3( _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 ); } // user defined functions @@ -180,6 +185,7 @@ public class MergeBranch : Object // set gobject values this.el.margin = 2; this.el.column_spacing = 2; + this.el.vexpand = false; var child_0 = new Xcls_Label4( _this ); child_0.ref(); this.el.attach_defaults ( child_0.el , 0,1,0,1 ); @@ -409,7 +415,7 @@ public class MergeBranch : Object this.el = new Gtk.ComboBox(); // my vars (dec) - this.loading = false; + this.loading = true; // set gobject values var child_0 = new Xcls_dbcellrenderer( _this ); @@ -428,7 +434,7 @@ public class MergeBranch : Object if (this.loading) { return; } - + _this.view.loadTicket(this.selectedTicketId()); _this.name.updateText(); //_this.name.el.set_text("wip_%s_T%s_%s".printf(name,ticket.id, ticket.summaryToBranchName())); @@ -622,8 +628,83 @@ public class MergeBranch : Object } + public class Xcls_scrolled_window : Object + { + public Gtk.ScrolledWindow el; + private MergeBranch _this; + + + // my vars (def) + + // ctor + public Xcls_scrolled_window(MergeBranch _owner ) + { + _this = _owner; + _this.scrolled_window = this; + this.el = new Gtk.ScrolledWindow( null, null ); + + // my vars (dec) + + // set gobject values + this.el.height_request = 500; + this.el.vexpand = true; + var child_0 = new Xcls_view( _this ); + child_0.ref(); + this.el.add ( child_0.el ); + + // init method + + { + this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); + } + } + + // user defined functions + } + public class Xcls_view : Object + { + public WebKit.WebView el; + private MergeBranch _this; + + + // my vars (def) + + // ctor + public Xcls_view(MergeBranch _owner ) + { + _this = _owner; + _this.view = this; + this.el = new WebKit.WebView(); + + // my vars (dec) + } + + // user defined functions + public void loadTicket (string tid) { + int h,w; + _this.el.get_size(out w, out h); + + if (tid == "") { + _this.scrolled_window.el.hide(); + _this.el.resize(w, 150); + } else { + _this.scrolled_window.el.show(); + _this.el.resize(w, 800); + } + + var rs = RooTicket.singleton(); + var uri = new WebKit.URIRequest("https://roojs.com/admin.php/MTrack/View/" + tid); + var hd = uri.get_http_headers(); + var authCode = Base64.encode ("%s:%s".printf(rs.username, rs.password).data); + hd.append("Authorization", "Basic %s".printf(authCode)); + + this.el.load_request(uri); + } + } + + - public class Xcls_Button14 : Object + public class Xcls_Button16 : Object { public Gtk.Button el; private MergeBranch _this; @@ -632,7 +713,7 @@ public class MergeBranch : Object // my vars (def) // ctor - public Xcls_Button14(MergeBranch _owner ) + public Xcls_Button16(MergeBranch _owner ) { _this = _owner; this.el = new Gtk.Button(); @@ -647,7 +728,7 @@ public class MergeBranch : Object // user defined functions } - public class Xcls_Button15 : Object + public class Xcls_Button17 : Object { public Gtk.Button el; private MergeBranch _this; @@ -656,7 +737,7 @@ public class MergeBranch : Object // my vars (def) // ctor - public Xcls_Button15(MergeBranch _owner ) + public Xcls_Button17(MergeBranch _owner ) { _this = _owner; this.el = new Gtk.Button(); -- 2.39.2