Clones.bjs
authorAlan Knowles <alan@roojs.com>
Tue, 30 Oct 2018 04:59:23 +0000 (12:59 +0800)
committerAlan Knowles <alan@roojs.com>
Tue, 30 Oct 2018 04:59:23 +0000 (12:59 +0800)
Clones.vala

Clones.bjs
Clones.vala

index 91593db..fa023d8 100644 (file)
@@ -13,7 +13,7 @@
     "response" : "(self, response_id) =>  { \n \n        this.el.hide();\n  \n}"
    },
    "default_width" : 600,
-   "| void show" : "() =>  {\n\n    \n    this.el.set_deletable(false);\n    this.el.show_all();\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    \n    this.el.set_deletable(false);\n    this.el.show_all();\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",
    "$ deletable" : true,
    "title" : "Manage Clones",
    "xtype" : "Dialog",
      "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
      "items" : [
       {
-       "* pack" : "pack_start,false,true",
-       "xtype" : "HBox",
+       "* pack" : "pack_start,false,false,0",
+       "xtype" : "Box",
        "$ xns" : "Gtk",
+       "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
        "items" : [
         {
          "listeners" : {
-          "clicked" : "() => {\n\n/*    var rv = this.get('/reposView');\n    var rs = this.get('/reposStore');\n    if (rv.el.get_selection().count_selected_rows() != 1) {\n        //nothing?\n        // error condition.\n        return;\n    }\n    var Remotes =     imports.Remotes.Remotes;\n    \n \n    var ret = {};       \n    var s = rv.el.get_selection();\n    var path = '';\n    s.selected_foreach(function(model,p,iter) {\n                                                    \n       path = model.get_value(iter, 6).value.get_string();\n     \n    }); \n\n    var repo = false;\n    rs.repos.forEach(function(r) {\n        if (r.repopath == path) {\n            repo = r;\n        \n        }\n    \n    });\n    Remotes.repo = repo;\n    Remotes.el.set_transient_for(Clones.el);\n    Clones.el.set_title(\"Manage Clones - \" + repo.repopath);\n    Remotes.show();\n    Clones.el.set_title(\"Manage Clones\");\n\n  */   \n    \n    \n    \n\n       \n    \n    \n}"
+          "clicked" : "() => {\n\n/*    var rv = this.get('/reposView');\n    var rs = this.get('/reposStore');\n    if (rv.el.get_selection().count_selected_rows() != 1) {\n        //nothing?\n        // error condition.\n        return;\n    }\n    var Remotes =     imports.Remotes.Remotes;\n    \n \n    var ret = {};       \n    var s = rv.el.get_selection();\n    var path = '';\n    s.selected_foreach(function(model,p,iter) {\n                                                    \n       path = model.get_value(iter, 6).value.get_string();\n     \n    }); \n\n    var repo = false;\n    rs.repos.forEach(function(r) {\n        if (r.repopath == path) {\n            repo = r;\n        \n        }\n    \n    });\n    Remotes.repo = repo;\n    Remotes.el.set_transient_for(Clones.el);\n    Clones.el.set_title(\"Manage Clones - \" + repo.repopath);\n    Remotes.show();\n    Clones.el.set_title(\"Manage Clones\");\n\n  */   \n    \n     \n\n       \n    \n    \n}"
          },
          "label" : "Remotes / Clones",
          "* pack" : "add",
@@ -54,7 +55,7 @@
         },
         {
          "listeners" : {
-          "clicked" : "() {\n/*\n    var rv = this.get('/reposView');\n    var rs = this.get('/reposStore');\n    if (rv.el.get_selection().count_selected_rows() != 1) {\n        //nothing?\n        // error condition.\n        return;\n    }\n    var Merger =     imports.Merger.Merger;\n    \n \n    var ret = {};       \n    var s = rv.el.get_selection();\n    var path = '';\n    s.selected_foreach(function(model,p,iter) {\n                                                    \n       path = model.get_value(iter, 6).value.get_string();\n     \n    }); \n\n    var repo = false;\n    rs.repos.forEach(function(r) {\n        if (r.repopath == path) {\n            repo = r;\n        \n        }\n    \n    });\n    Merger.repo = repo;\n    Merger.el.set_transient_for(Clones.el);\n    Clones.el.set_title(\"Manage Clones - \" + repo.repopath);\n    Merger.show();\n    Clones.el.set_title(\"Manage Clones\");\n\n    \n    \n\n    \n\n    \n    \n    \n    \n\n */      \n    \n    \n}"
+          "clicked" : "() =>  {\n/*\n    var rv = this.get('/reposView');\n    var rs = this.get('/reposStore');\n    if (rv.el.get_selection().count_selected_rows() != 1) {\n        //nothing?\n        // error condition.\n        return;\n    }\n    var Merger =     imports.Merger.Merger;\n    \n \n    var ret = {};       \n    var s = rv.el.get_selection();\n    var path = '';\n    s.selected_foreach(function(model,p,iter) {\n                                                    \n       path = model.get_value(iter, 6).value.get_string();\n     \n    }); \n\n    var repo = false;\n    rs.repos.forEach(function(r) {\n        if (r.repopath == path) {\n            repo = r;\n        \n        }\n    \n    });\n    Merger.repo = repo;\n    Merger.el.set_transient_for(Clones.el);\n    Clones.el.set_title(\"Manage Clones - \" + repo.repopath);\n    Merger.show();\n    Clones.el.set_title(\"Manage Clones\");\n\n    \n    \n\n     \n    \n\n */      \n    \n    \n}"
          },
          "label" : "Merge",
          "* pack" : "add",
        ]
       },
       {
-       "* init" : "() => {\n    XObject.prototype.init.call(this);\n      this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n}\n",
+       "* init" : "  {\n  \n   this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n}\n",
        "xtype" : "ScrolledWindow",
+       "* pack" : "pack_end,true,true,0",
+       "Gtk.ShadowType shadow_type" : "Gtk.ShadowType.IN",
        "$ xns" : "Gtk",
        "items" : [
         {
          "listeners" : {
-          "cursor_changed" : "function (self) {\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}"
+          "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",
-         "* init" : "function() {\n    XObject.prototype.init.call(this);\n        var description = new Pango.FontDescription.c_new();\n   description.set_size(10000);\n     this.el.modify_font(description);\n\n     this.selection = this.el.get_selection();\n      this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);\n    var _this = this;\n    \n    \n  this.selection.signal['changed'].connect(function() {\n     _this.listeners.cursor_changed.apply(\n          _this, [ _this, '']\n       );\n             });\n  }\n",
+         "* 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",
          "xtype" : "TreeView",
          "* pack" : "add",
          "$ xns" : "Gtk",
          "items" : [
           {
            "id" : "reposStore",
-           "* init" : "function() {\n    XObject.prototype.init.call(this);\n    this.el.set_column_types ( 8, [\n       GObject.TYPE_STRING, // repo  \n      GObject.TYPE_STRING, // current branch\n      GObject.TYPE_STRING, // all branch      \n      GObject.TYPE_STRING, // updated\n       GObject.TYPE_BOOLEAN, // auto-commit\n        GObject.TYPE_BOOLEAN, // auto-push\n           GObject.TYPE_STRING, // repopath\n           GObject.TYPE_STRING // color highighling \n  ] );\n}\n",
+           "columns" : "     typeof(string),  // 0 repo\n     typeof(string),  // 1 current branch\n     typeof(string),  // 2 all branch\n     typeof(string),  // 3 updated\n     typeof(bool),   // 4 auto commit\n     typeof(bool),   // 5 auto push\n     typeof(string)   // 7 repopath\n      typeof(string)   // 8 color highlighting?",
            "$ pathToRepo" : "function(path) {\n\n    var tr= this.repos;\n\n    \n    for(var i =0 ; i < tr.length; i++) {\n        if (tr[i].repopath == path) {\n            return tr[i];\n        }\n    } \n    return false; \n}\n",
            "xtype" : "ListStore",
            "* pack" : "set_model",
            "$ load" : "function()\n{\n    //this.insert(citer,iter,0);\n    print(\"getting list\");\n    this.repos = imports.Scm.Repo.Repo.list();\n    var tr= this.repos;\n    this.el.clear();\n    \n    for(var i =0 ; i < tr.length; i++) {\n        var ret = {  };\n       \n        this.el.append(ret);\n        \n        //print(JSON.stringify(ret,null,4));\n         tr[i].getBranches();\n         tr[i].getStatus();\n         var hi;\n         try {\n             //tr[i].debug=1;\n              hi = tr[i].history('/', 1, 'branch', tr[i].currentBranch.name );\n//             print(JSON.stringify(hi,null,4));\n         } catch(e) { print(e);}\n          \n        this.el.set_value(ret.iter, 0, '' +  tr[i].repopath.split('/').pop() );\n        this.el.set_value(ret.iter, 1, '' + tr[i].currentBranch.name   );\n        this.el.set_value(ret.iter, 2, '' + tr[i].branches.map(\n                        function(e) { return e.name; \n                    }).join(', ') \n         );\n        this.el.set_value(ret.iter, 3, '' +  (!hi  ? '??' : hi[0].changed_raw));        \n        this.el.set_value(ret.iter, 4, tr[i].autocommit() );                \n        this.el.set_value(ret.iter, 5, tr[i].autopush() );                        \n        this.el.set_value(ret.iter, 6,  tr[i].repopath );  \n        // highlight color.\n        var cb = tr[i].currentBranch;\n        //print(JSON.stringify(cb,null,4));\n        var col = '#ffffff';\n        if (cb.lastrev != cb.remoterev) {\n            col =  '#ff0000';\n        }\n        if (tr[i].hasLocalChanges) {\n            col =  '#0000ff';\n        }\n        if  ((cb.lastrev != cb.remoterev) && (tr[i].hasLocalChanges)) {\n            col =  '#ff00ff';\n        }\n        \n        this.el.set_value(ret.iter, 7, col  );      \n        \n    }     \n}"
           },
           {
-           "* init" : "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'active', 4 );\n    this.items[0].el.set_activatable(true);\n\n}\n",
+           "* init" : "\n//    this.items[0].el.set_activatable(true);\n this.el.add_attribute(_this.keyrender.el , \"active\", 4 );\n\n",
            "* pack" : "append_column",
            "title" : "Auto Commit",
            "xtype" : "TreeViewColumn",
            "items" : [
             {
              "listeners" : {
-              "toggled" : "function (self, path) {\n    var ret ={} ;\n    var store = this.get('/reposStore');\n    store.el.get_iter_from_string(ret, path);\n                                                                 \n    var value =   store.el.get_value(ret.iter,4).value.get_boolean();\n                                                                 \n    //print(JSON.stringify(value));\n    store.el.set_value(ret.iter,4, !value);\n    \n     var path =  store.el.get_value(ret.iter, 6).value.get_string();\n     var repo = imports.Scm.Repo.Repo.get(path);\n     repo.autocommit(!value);\n     \n    \n    \n}"
+              "toggled" : "  (self, path)  => {\n/*    var ret ={} ;\n    var store = this.get('/reposStore');\n    store.el.get_iter_from_string(ret, path);\n                                                                 \n    var value =   store.el.get_value(ret.iter,4).value.get_boolean();\n                                                                 \n    //print(JSON.stringify(value));\n    store.el.set_value(ret.iter,4, !value);\n    \n     var path =  store.el.get_value(ret.iter, 6).value.get_string();\n     var repo = imports.Scm.Repo.Repo.get(path);\n     repo.autocommit(!value);\n  */   \n    \n    \n}"
              },
-             "* pack" : "pack_start",
+             "* pack" : "pack_start,false",
              "xtype" : "CellRendererToggle",
              "$ xns" : "Gtk",
              "$ mode" : "Gtk.CellRendererMode.ACTIVATABLE"
index ae5552f..073cd95 100644 (file)
@@ -55,7 +55,7 @@ public class Clones : Object
     }
 
     // user defined functions
-    public void show () =>  {
+    public void show ()    {
     
         
         this.el.set_deletable(false);
@@ -94,28 +94,29 @@ public class Clones : Object
             // my vars (dec)
 
             // set gobject values
-            var child_0 = new Xcls_HBox3( _this );
+            var child_0 = new Xcls_Box3( _this );
             child_0.ref();
-            this.el.pack_start (  child_0.el , false,true );
+            this.el.pack_start (  child_0.el , false,false,0 );
             var child_1 = new Xcls_ScrolledWindow9( _this );
             child_1.ref();
+            this.el.pack_end (  child_1.el , true,true,0 );
         }
 
         // user defined functions
     }
-    public class Xcls_HBox3 : Object
+    public class Xcls_Box3 : Object
     {
-        public Gtk.HBox el;
+        public Gtk.Box el;
         private Clones  _this;
 
 
             // my vars (def)
 
         // ctor
-        public Xcls_HBox3(Clones _owner )
+        public Xcls_Box3(Clones _owner )
         {
             _this = _owner;
-            this.el = new Gtk.HBox( true, 0 );
+            this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
 
             // my vars (dec)
 
@@ -196,8 +197,7 @@ public class Clones : Object
             
               */   
                 
-                
-                
+                 
             
                    
                 
@@ -297,7 +297,7 @@ public class Clones : Object
             this.el.label = "Merge";
 
             //listeners
-            this.el.clicked.connect( () {
+            this.el.clicked.connect( () =>  {
             /*
                 var rv = this.get('/reposView');
                 var rs = this.get('/reposStore');
@@ -335,11 +335,7 @@ public class Clones : Object
                 
                 
             
-                
-            
-                
-                
-                
+                 
                 
             
              */      
@@ -435,6 +431,7 @@ public class Clones : Object
             // my vars (dec)
 
             // set gobject values
+            this.el.shadow_type = Gtk.ShadowType.IN;
             var child_0 = new Xcls_reposView( _this );
             child_0.ref();
             this.el.add (  child_0.el  );
@@ -443,9 +440,9 @@ public class Clones : Object
 
             // init method
 
-            () => {
-                XObject.prototype.init.call(this);
-                  this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+            {
+              
+               this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
             }
         }
 
@@ -493,28 +490,20 @@ public class Clones : Object
 
             // init method
 
-            function() {
-                XObject.prototype.init.call(this);
-                    var description = new Pango.FontDescription.c_new();
-               description.set_size(10000);
-                 this.el.modify_font(description);
+            {
+                var selection = this.el.get_selection();
+                selection.set_mode( Gtk.SelectionMode.SINGLE);
             
-                 this.selection = this.el.get_selection();
-                  this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);
-                var _this = this;
-                
-                
-              this.selection.signal['changed'].connect(function() {
-                 _this.listeners.cursor_changed.apply(
-                      _this, [ _this, '']
-                   );
-                         });
-              }
+            
+                var description = new Pango.FontDescription();
+                description.set_size(10000);
+                this.el.override_font(description);
+            }
 
             //listeners
-            this.el.cursor_changed.connect( function (self) {
+            this.el.cursor_changed.connect( ()  => {
               // SEE SELECTION.CHANGED
-              
+              /*
               
               return;
               
@@ -538,7 +527,7 @@ public class Clones : Object
                 // load the list in the right grid..
                  
                 return true;
-            
+            */
             });
         }
 
@@ -557,27 +546,18 @@ public class Clones : Object
         {
             _this = _owner;
             _this.reposStore = this;
-            this.el = new Gtk.ListStore( 0, null );
+            this.el = new Gtk.ListStore( 0,      typeof(string),  // 0 repo
+     typeof(string),  // 1 current branch
+     typeof(string),  // 2 all branch
+     typeof(string),  // 3 updated
+     typeof(bool),   // 4 auto commit
+     typeof(bool),   // 5 auto push
+     typeof(string)   // 7 repopath
+      typeof(string)   // 8 color highlighting? );
 
             // my vars (dec)
 
             // set gobject values
-
-            // init method
-
-            function() {
-                XObject.prototype.init.call(this);
-                this.el.set_column_types ( 8, [
-                   GObject.TYPE_STRING, // repo  
-                  GObject.TYPE_STRING, // current branch
-                  GObject.TYPE_STRING, // all branch      
-                  GObject.TYPE_STRING, // updated
-                   GObject.TYPE_BOOLEAN, // auto-commit
-                    GObject.TYPE_BOOLEAN, // auto-push
-                       GObject.TYPE_STRING, // repopath
-                       GObject.TYPE_STRING // color highighling 
-              ] );
-            }
         }
 
         // user defined functions
@@ -604,16 +584,12 @@ public class Clones : Object
             this.el.min_width = 50;
             var child_0 = new Xcls_CellRendererToggle13( _this );
             child_0.ref();
-            this.el.pack_start (  child_0.el  );
+            this.el.pack_start (  child_0.el , false );
 
             // init method
 
-            function() {
-                XObject.prototype.init.call(this);
-                this.el.add_attribute(this.items[0].el , 'active', 4 );
-                this.items[0].el.set_activatable(true);
-            
-            }
+            //    this.items[0].el.set_activatable(true);
+             this.el.add_attribute(_this.keyrender.el , "active", 4 );
         }
 
         // user defined functions
@@ -638,8 +614,8 @@ public class Clones : Object
             this.el.mode = Gtk.CellRendererMode.ACTIVATABLE;
 
             //listeners
-            this.el.toggled.connect( function (self, path) {
-                var ret ={} ;
+            this.el.toggled.connect( (self, path)  => {
+            /*    var ret ={} ;
                 var store = this.get('/reposStore');
                 store.el.get_iter_from_string(ret, path);
                                                                              
@@ -651,7 +627,7 @@ public class Clones : Object
                  var path =  store.el.get_value(ret.iter, 6).value.get_string();
                  var repo = imports.Scm.Repo.Repo.get(path);
                  repo.autocommit(!value);
-                 
+              */   
                 
                 
             });