Clone.bjs
authorAlan Knowles <alan@roojs.com>
Fri, 14 Dec 2018 07:38:46 +0000 (15:38 +0800)
committerAlan Knowles <alan@roojs.com>
Fri, 14 Dec 2018 07:38:46 +0000 (15:38 +0800)
Clone.vala

Clone.bjs
Clone.vala

index b5ee53a..833a2fb 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",
        "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    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.name == repo.shortname) {\n    \t\t\thas_repo = true;\n    \t}\n    \tif (has_repo) {\n    \t\tcontinue;\n\t\t}\n        el.append(out iter);\n        \n        el.set_value(iter, 0, repo.name);\n        el.set_value(iter, 1,  \"%s : %s\".printf(repo.shortname, repo.description) );\n       \n        \n    }\n    \n    _this.reposel.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,  \"%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)",
@@ -57,8 +56,8 @@
         "button_press_event" : "() => {\n       _this.el.hide();\n        return false;\n}"
        },
        "label" : "Checkout",
-       "* pack" : "add",
        "xtype" : "Button",
+       "* pack" : "add",
        "$ xns" : "Gtk"
       }
      ]
index 7a3a53c..087a88e 100644 (file)
@@ -14,10 +14,9 @@ public class Clone : Object
     }
     public Xcls_reposel reposel;
     public Xcls_prcellrenderer prcellrenderer;
-    public Xcls_prmodel prmodel;
+    public Xcls_repomodel repomodel;
 
         // my vars (def)
-    public GitRepo repo;
 
     // ctor
     public Clone()
@@ -33,16 +32,16 @@ public class Clone : Object
         this.el.position = Gtk.PositionType.RIGHT;
         var child_0 = new Xcls_Box2( _this );
         child_0.ref();
-        this.el.pack_end (  child_0.el , false,false,0 );
+        this.el.add (  child_0.el  );
     }
 
     // user defined functions
-    public void show (Gtk.Widget btn, GitRepo repo) {
+    public void show (Gtk.Widget btn) {
      
                //console.log('show all');
        this.el.set_modal(true);
        this.el.set_relative_to(btn);
-      
+       this.repomodel.loadRepos();
        //this.el.set_position(Gtk.PositionType.RIGHT);
     
        // window + header?
@@ -71,7 +70,7 @@ public class Clone : Object
             this.el.vexpand = false;
             var child_0 = new Xcls_reposel( _this );
             child_0.ref();
-            this.el.attach_defaults (  child_0.el , 0,1,1,2 );
+            this.el.add (  child_0.el  );
             var child_1 = new Xcls_Button6( _this );
             child_1.ref();
             this.el.add (  child_1.el  );
@@ -103,7 +102,7 @@ public class Clone : Object
             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 );
+            var child_1 = new Xcls_repomodel( _this );
             child_1.ref();
             this.el.set_model (  child_1.el  );
 
@@ -152,7 +151,7 @@ public class Clone : Object
         // user defined functions
     }
 
-    public class Xcls_prmodel : Object
+    public class Xcls_repomodel : Object
     {
         public Gtk.ListStore el;
         private Clone  _this;
@@ -161,10 +160,10 @@ public class Clone : Object
             // my vars (def)
 
         // ctor
-        public Xcls_prmodel(Clone _owner )
+        public Xcls_repomodel(Clone _owner )
         {
             _this = _owner;
-            _this.prmodel = this;
+            _this.repomodel = this;
             this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
 
             // my vars (dec)
@@ -173,7 +172,7 @@ public class Clone : Object
         }
 
         // user defined functions
-        public void loadProjects (string id) {
+        public void loadRepos () {
         
             var rt = RooTicket.singleton();
             var gr = GitRepo.singleton();
@@ -195,16 +194,17 @@ public class Clone : Object
             foreach(var newrepo in rt.repos) {
                var has_repo = false;
                foreach(var repo in gr.cache.values) {
-                       if (newrepo.name == repo.shortname) {
+                       if (newrepo.shortname == repo.name) {
                                has_repo = true;
+                       }
                }
                if (has_repo) {
                        continue;
                        }
                 el.append(out iter);
                 
-                el.set_value(iter, 0, repo.name);
-                el.set_value(iter, 1,  "%s : %s".printf(repo.shortname, repo.description) );
+                el.set_value(iter, 0, newrepo.shortname);
+                el.set_value(iter, 1,  "%s : %s".printf(newrepo.shortname, newrepo.description) );
                
                 
             }