Clones.bjs
[gitlive] / Clones.bjs
1 {
2  "name" : "Clones",
3  "parent" : "",
4  "title" : "",
5  "path" : "/home/alan/gitlive/gitlive/Clones.bjs",
6  "permname" : "",
7  "modOrder" : "",
8  "build_module" : "",
9  "items" : [
10   {
11    "default_width" : 600,
12    "| void show" : "(Gtk.Widget icon)    {\n\n    Gdk.Rectangle area;\n    Gdk.Screen screen;\n    Gtk.Orientation ori;\n    \n    icon.get_geometry(out screen, out area, out ori);\n    \n\tthis.el.set_pointing_to(area);\n    \n    \t//console.log('show all');\n\tthis.el.set_modal(true);\n\n\n\tthis.el.set_position(Gtk.PositionType.BOTTOM);\n//\tthis.el.popup();\n\t// window + header?\n\tthis.el.show_all();\n\tthis.el.set_size_request(800,500);\n\n\t//this.view.el.grab_focus();\n}\n",
13    "$ deletable" : true,
14    "title" : "Manage Clones",
15    "xtype" : "Popover",
16    "default_height" : 500,
17    "$ modal" : true,
18    "$ xns" : "Gtk",
19    "border_width" : 3,
20    "items" : [
21     {
22      "xtype" : "Box",
23      "$ pack" : "add",
24      "$ xns" : "Gtk",
25      "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
26      "items" : [
27       {
28        "* pack" : "pack_start,false,false,0",
29        "xtype" : "Box",
30        "$ xns" : "Gtk",
31        "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
32        "items" : [
33         {
34          "listeners" : {
35           "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}"
36          },
37          "label" : "Remotes / Clones",
38          "* pack" : "add",
39          "xtype" : "Button",
40          "$ xns" : "Gtk"
41         },
42         {
43          "listeners" : {
44           "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 Branches =     imports.Branches.Branches;\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    Branches.repo = repo;\n    Branches.el.set_transient_for(Clones.el);\n    Clones.el.set_title(\"Manage Clones - \" + repo.repopath);\n    Branches.show();\n    Clones.el.set_title(\"Manage Clones\");\n\n     \n    \n    \n    \n\n       \n */   \n    \n}"
45          },
46          "label" : "Branches",
47          "* pack" : "add",
48          "xtype" : "Button",
49          "$ xns" : "Gtk"
50         },
51         {
52          "listeners" : {
53           "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}"
54          },
55          "label" : "Merge",
56          "* pack" : "add",
57          "xtype" : "Button",
58          "$ xns" : "Gtk"
59         },
60         {
61          "listeners" : {
62           "clicked" : "() => {\n    \n    \n \n       \n    \n    \n}"
63          },
64          "label" : "Switch Branch",
65          "* pack" : "add",
66          "xtype" : "Button",
67          "$ xns" : "Gtk"
68         },
69         {
70          "listeners" : {
71           "clicked" : "() => {\n    \n    \n \n       \n    \n    \n}"
72          },
73          "label" : "Pull",
74          "* pack" : "add",
75          "xtype" : "Button",
76          "$ xns" : "Gtk"
77         }
78        ]
79       },
80       {
81        "* init" : "  {\n  \n   this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n}\n",
82        "bool expand" : true,
83        "xtype" : "ScrolledWindow",
84        "* pack" : "add",
85        "Gtk.ShadowType shadow_type" : "Gtk.ShadowType.IN",
86        "$ xns" : "Gtk",
87        "items" : [
88         {
89          "listeners" : {
90           "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}"
91          },
92          "id" : "reposView",
93          "* 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",
94          "xtype" : "TreeView",
95          "* pack" : "add",
96          "$ xns" : "Gtk",
97          "items" : [
98           {
99            "id" : "reposStore",
100            "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?\n      ",
101            "$ 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",
102            "xtype" : "ListStore",
103            "* pack" : "set_model",
104            "$ xns" : "Gtk",
105            "$ 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}"
106           },
107           {
108            "id" : "tv_autocommit",
109            "* init" : "\n//    this.items[0].el.set_activatable(true);\n this.el.add_attribute(_this.cr_autocommit.el , \"active\", 4 );\n\n",
110            "* pack" : "append_column",
111            "title" : "Auto Commit",
112            "xtype" : "TreeViewColumn",
113            "min_width" : 50,
114            "$ xns" : "Gtk",
115            "items" : [
116             {
117              "listeners" : {
118               "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}"
119              },
120              "id" : "cr_autocommit",
121              "* pack" : "pack_start,false",
122              "xtype" : "CellRendererToggle",
123              "$ xns" : "Gtk",
124              "$ mode" : "Gtk.CellRendererMode.ACTIVATABLE"
125             }
126            ]
127           },
128           {
129            "id" : "tv_autopush",
130            "* init" : " \n    this.el.add_attribute(_this.cr_autopush.el , \"active\", 5 );\n//      this.items[0].el.set_activatable(true);\n\n",
131            "* pack" : "append_column",
132            "title" : "Auto Push",
133            "xtype" : "TreeViewColumn",
134            "min_width" : 50,
135            "$ xns" : "Gtk",
136            "items" : [
137             {
138              "listeners" : {
139               "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,5).value.get_boolean();\n                                                                 \n    //print(JSON.stringify(value));\n    store.el.set_value(ret.iter,5, !value);\n      var path =  store.el.get_value(ret.iter, 6).value.get_string();\n     var repo = imports.Scm.Repo.Repo.get(path);\n     repo.autopush(!value);\n    */\n}"
140              },
141              "id" : "cr_autopush",
142              "* pack" : "pack_start,false",
143              "xtype" : "CellRendererToggle",
144              "$ xns" : "Gtk",
145              "$ mode" : "Gtk.CellRendererMode.ACTIVATABLE"
146             }
147            ]
148           },
149           {
150            "id" : "tv_repo",
151            "* init" : "\n    this.el.add_attribute(_this.cr_repo.el , \"markup\", 0 );\n",
152            "title" : "Repo",
153            "* pack" : "append_column",
154            "xtype" : "TreeViewColumn",
155            "min_width" : 200,
156            "$ xns" : "Gtk",
157            "resizable" : true,
158            "items" : [
159             {
160              "id" : "cr_repo",
161              "* pack" : "pack_start,false",
162              "xtype" : "CellRendererText",
163              "$ xns" : "Gtk"
164             }
165            ]
166           },
167           {
168            "id" : "tv_current_branch",
169            "* init" : " \n    this.el.add_attribute(_this.cr_current_branch.el , \"markup\", 1 );\n     this.el.add_attribute(_this.cr_current_branch.el, \"cell-background\", 7 );\n \n",
170            "* pack" : "append_column",
171            "title" : "Current Branch",
172            "xtype" : "TreeViewColumn",
173            "min_width" : 50,
174            "$ xns" : "Gtk",
175            "items" : [
176             {
177              "id" : "cr_current_branch",
178              "* pack" : "pack_start,false",
179              "xtype" : "CellRendererText",
180              "$ xns" : "Gtk"
181             }
182            ]
183           },
184           {
185            "id" : "tv_last_updated",
186            "* init" : "\n    this.el.add_attribute(_this.cr_last_updated.el , \"markup\", 3 );\n",
187            "* pack" : "append_column",
188            "title" : "Last updated",
189            "xtype" : "TreeViewColumn",
190            "min_width" : 50,
191            "$ xns" : "Gtk",
192            "items" : [
193             {
194              "id" : "cr_last_updated",
195              "* pack" : "pack_start,false",
196              "xtype" : "CellRendererText",
197              "$ xns" : "Gtk"
198             }
199            ]
200           },
201           {
202            "id" : "tv_all_branches",
203            "* init" : "    this.el.add_attribute(_this.cr_all_branches.el , \"markup\", 2 );\n\n",
204            "title" : "All Branches",
205            "* pack" : "append_column",
206            "xtype" : "TreeViewColumn",
207            "min_width" : 50,
208            "$ xns" : "Gtk",
209            "resizable" : false,
210            "items" : [
211             {
212              "id" : "cr_all_branches",
213              "* pack" : "pack_start,false",
214              "xtype" : "CellRendererText",
215              "$ xns" : "Gtk"
216             }
217            ]
218           }
219          ]
220         }
221        ]
222       },
223       {
224        "label" : "Close",
225        "id" : "ok_button",
226        "* pack" : "add",
227        "xtype" : "Button",
228        "$ xns" : "Gtk"
229       }
230      ]
231     }
232    ]
233   }
234  ]
235 }