Merger.bjs
[gitlive] / Merger.bjs
1 {
2     "id": "file-gtk-3",
3     "name": "Merger",
4     "parent": "",
5     "title": false,
6     "path": "/home/alan/gitlive/gitlive/Merger.bjs",
7     "items": [
8         {
9             "listeners": {
10                 "destroy_event": "function (self, event) {\n     this.el.hide();\n                return false;\n}",
11                 "response": "function (self, id) {\n  // hide\n     //if (id < 1) {\n        this.el.hide();\n        return;\n    //}\n    if (typeof(this.get('bug').getValue()) != 'object') {\n        print(\"ERROR\");\n        return;\n    }\n \n    this.el.hide();\n        \n    //var val = this.get('bug').getValue();\n     //   Seed.print(val);\n}"
12             },
13             "border_width": 3,
14             "default_height": 700,
15             "default_width": 800,
16             "id": "Merger",
17             "title": "Merger",
18             "xtype": "Dialog",
19             "|deletable": true,
20             "|show": "function(c) {\n    \n    if (!this.el) {\n        this.init();\n    }\n    var _this = this;\n     \n      //this.el.set_title(\"Merger - ??? \");\n//   this.el.set_title(\"Merger - \" + this.repo.repopath);\n\n\n\n     /// load up branches\n     this.get('/workingCombo').load(Merger.repo.branches);\n     \n     this.get('/releaseCombo').load(Merger.repo.branches);\n\n    this.el.show_all();\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",
21             "|xns": "Gtk",
22             "items": [
23                 {
24                     "xtype": "VBox",
25                     "|pack": " function(p,e) {\n        p.el.get_content_area().pack_start(e.el,true,true,0)\n    }\n",
26                     "|xns": "Gtk",
27                     "items": [
28                         {
29                             "pack": "pack_start,false,true",
30                             "xtype": "HBox",
31                             "|xns": "Gtk",
32                             "items": [
33                                 {
34                                     "label": "Working Branch",
35                                     "xtype": "Label",
36                                     "|xns": "Gtk"
37                                 },
38                                 {
39                                     "listeners": {
40                                         "changed": "function (self) {\n   this.get('/historyTreeStore').loadTree();\n}"
41                                     },
42                                     "id": "workingCombo",
43                                     "xtype": "ComboBox",
44                                     "|init": "function() {\n    this.el = new Gtk.ComboBox.with_entry();\n    \n    \n    this.model  = new XObject(this.model);\n    this.model.init();\n    this.el.set_model(this.model.el);\n    this.el.set_entry_text_column (0);\n     XObject.prototype.init.call(this);\n    \n}\n",
45                                     "|load": "function(tr)\n{\n    //this.insert(citer,iter,0);\n    this.model.el.clear();\n    \n    var master = false;\n    var working = false;\n    \n    for(var i =0 ; i < tr.length; i++) {\n        var ret = {  };\n        this.model.el.append(ret);\n        //print(JSON.stringify(ret,null,4));\n        if (tr[i].name == 'master') {\n            master = i;\n        }\n        if (tr[i].name == 'working') {\n            working = i;\n        }          \n        this.model.el.set_value(ret.iter, 0, '' + tr[i].name );\n        this.model.el.set_value(ret.iter, 1, '' + tr[i].rev  );\n \n        \n    }     \n    if (master !== false) {\n        this.el.set_active(master);\n    }\n    if (working !== false) {\n        this.el.set_active(working);\n    }\n    \n}",
46                                     "|xns": "Gtk",
47                                     "items": [
48                                         {
49                                             "*prop": "model",
50                                             "xtype": "ListStore",
51                                             "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.set_column_types ( 3, [\n           GObject.TYPE_STRING, // file  \n          GObject.TYPE_STRING, // added\n          GObject.TYPE_STRING, // removed\n      ] );\n}\n",
52                                             "|xns": "Gtk"
53                                         }
54                                     ]
55                                 },
56                                 {
57                                     "label": "Release Branch",
58                                     "xtype": "Label",
59                                     "|xns": "Gtk"
60                                 },
61                                 {
62                                     "listeners": {
63                                         "changed": "function (self) {\n   this.get('/historyTreeStore').loadTree();\n}"
64                                     },
65                                     "id": "releaseCombo",
66                                     "xtype": "ComboBox",
67                                     "|init": "function() {\n    this.el = new Gtk.ComboBox.with_entry();\n    \n    \n    this.model  = new XObject(this.model);\n    this.model.init();\n    this.el.set_model(this.model.el);\n    this.el.set_entry_text_column (0);\n     XObject.prototype.init.call(this);\n    \n}\n",
68                                     "|load": "function(tr)\n{\n    //this.insert(citer,iter,0);\n    this.model.el.clear();\n    \n    var master = false;\n    var release = false;\n    \n    for(var i =0 ; i < tr.length; i++) {\n        var ret = {  };\n        this.model.el.append(ret);\n        //print(JSON.stringify(ret,null,4));\n        if (tr[i].name == 'master') {\n            master = i;\n        }\n        if (tr[i].name == 'release') {\n            release = i;\n        }          \n        this.model.el.set_value(ret.iter, 0, '' + tr[i].name );\n        this.model.el.set_value(ret.iter, 1, '' + tr[i].rev  );\n \n        \n    }     \n    if (master !== false) {\n        this.el.set_active(master);\n    }\n    if (release !== false) {\n        this.el.set_active(release);\n    }\n    \n}",
69                                     "|xns": "Gtk",
70                                     "items": [
71                                         {
72                                             "*prop": "model",
73                                             "xtype": "ListStore",
74                                             "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.set_column_types ( 3, [\n           GObject.TYPE_STRING, // file  \n          GObject.TYPE_STRING, // added\n          GObject.TYPE_STRING, // removed\n      ] );\n}\n",
75                                             "|xns": "Gtk"
76                                         }
77                                     ]
78                                 }
79                             ]
80                         },
81                         {
82                             "pack": "pack_end,true,true,0",
83                             "position": 400,
84                             "xtype": "VPaned",
85                             "|xns": "Gtk",
86                             "items": [
87                                 {
88                                     "pack": "add",
89                                     "position": 200,
90                                     "xtype": "HPaned",
91                                     "|xns": "Gtk",
92                                     "items": [
93                                         {
94                                             "xtype": "ScrolledWindow",
95                                             "|init": "function() {\n    XObject.prototype.init.call(this);\n     this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n}\n",
96                                             "|xns": "Gtk",
97                                             "items": [
98                                                 {
99                                                     "listeners": {
100                                                         "cursor_changed": "function (self) {\n\n    if (this.el.get_selection().count_selected_rows() < 1) {\n        //nothing?\n        return;\n    }\n    var model = this.get('/historyTreeStore');\n    var ret = {};        \n     var s = this.el.get_selection();\n    s.get_selected(ret);\n    \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    var Repo = imports.Scm.Git.Repo.Repo;\n    \n    \n   \n    if (model.release === false) {\n        return;\n    }\n    model.rev = value;\n   \n    var files = Merger.repo.changedFiles('/',   'rev', model.release + '..' + value);\n    this.get('/changedFilesStore').load(files);\n    return true;\n\n}"
101                                                     },
102                                                     "pack": "add",
103                                                     "xtype": "TreeView",
104                                                     "|init": "function() {\n    XObject.prototype.init.call(this);\n        var description = new Pango.FontDescription.c_new();\n   description.set_size(8000);\n     this.el.modify_font(description);\n\n     this.selection = this.el.get_selection();\n      this.selection.set_mode( Gtk.SelectionMode.SINGLE);\n    var _this = this;\n    /*\n 780                                                                     \n 781                                                                         // is this really needed??\n 782                                                                         this.selection.signal['changed'].connect(function() {\n 783                                                                                 _this.get('/LeftTree.view').listeners.cursor_changed.apply(\n 784                                                                                     _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']\n 785                                                                                 );\n 786                                                                         });\n 787                                                                         \n */\n }\n",
105                                                     "|xns": "Gtk",
106                                                     "items": [
107                                                         {
108                                                             "id": "historyTreeStore",
109                                                             "pack": "set_model",
110                                                             "release": false,
111                                                             "xtype": "TreeStore",
112                                                             "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.set_column_types ( 3, [\n       GObject.TYPE_STRING, // title \n      GObject.TYPE_STRING, // rev \n  ] );\n}\n",
113                                                             "|load": "function(tr,iter)\n{\n    //this.insert(citer,iter,0);\n    if (!iter) {\n        this.el.clear();\n    }\n    \n    for(var i =0 ; i < tr.length; i++) {\n        var ret = {  };\n        if (iter) {\n            this.el.insert(ret ,iter,-1);\n        } else {\n            this.el.append(ret);\n        }\n        //print(JSON.stringify(ret,null,4));\n         \n          \n        this.el.set_value(ret.iter, 0, ''  +  tr[i].text );\n        this.el.set_value(ret.iter, 1, '' + tr[i].rev  );\n \n        if (tr[i].children && tr[i].children.length) {\n            this.load(tr[i].children, ret.iter);\n        }\n    }     \n}",
114                                                             "|loadTree": "function() {\n\n       this.working = false;\n   \n   var wid = this.get('/workingCombo').el.get_active();\n   var rid = this.get('/releaseCombo').el.get_active();\n   if (wid < 0 || rid < 0 || rid == wid) {\n    return;\n   }\n   \n   var w = Merger.repo.branches[wid];\n   var r = Merger.repo.branches[rid];\n   \n\n\n    var rev = r.name + '..' + w.name;\n    this.release = r.name;\n\n    var hist = Merger.repo.dayTree('/', false, 'rev', rev);\n    this.load(hist);\n        \n       \n}\n",
115                                                             "|xns": "Gtk"
116                                                         },
117                                                         {
118                                                             "pack": "append_column",
119                                                             "title": "Changes",
120                                                             "xtype": "TreeViewColumn",
121                                                             "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 0 );\n\n}\n",
122                                                             "|xns": "Gtk",
123                                                             "items": [
124                                                                 {
125                                                                     "pack": "pack_start",
126                                                                     "xtype": "CellRendererText",
127                                                                     "|xns": "Gtk"
128                                                                 }
129                                                             ]
130                                                         }
131                                                     ]
132                                                 }
133                                             ]
134                                         },
135                                         {
136                                             "xtype": "ScrolledWindow",
137                                             "|init": "function() {\n    XObject.prototype.init.call(this);\n      this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n}\n",
138                                             "|xns": "Gtk",
139                                             "items": [
140                                                 {
141                                                     "listeners": {
142                                                         "cursor_changed": "function (self) {\n  // SEE SELECTION.CHANGED\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}"
143                                                     },
144                                                     "id": "changedFilesView",
145                                                     "pack": "add",
146                                                     "xtype": "TreeView",
147                                                     "|init": "function() {\n    XObject.prototype.init.call(this);\n        var description = new Pango.FontDescription.c_new();\n   description.set_size(8000);\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  this.selection.signal['changed'].connect(function() {\n     _this.listeners.cursor_changed.apply(\n          _this, [ _this, '']\n       );\n             });\n  }\n",
148                                                     "|xns": "Gtk",
149                                                     "items": [
150                                                         {
151                                                             "id": "changedFilesStore",
152                                                             "pack": "set_model",
153                                                             "xtype": "ListStore",
154                                                             "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.set_column_types ( 3, [\n       GObject.TYPE_STRING, // file  \n      GObject.TYPE_STRING, // added\n      GObject.TYPE_STRING, // removed\n  ] );\n}\n",
155                                                             "|load": "function(tr)\n{\n    //this.insert(citer,iter,0);\n    this.el.clear();\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         \n          \n        this.el.set_value(ret.iter, 0, ''  +  tr[i].filename );\n        this.el.set_value(ret.iter, 1, '' + tr[i].added  );\n        this.el.set_value(ret.iter, 2, '' + tr[i].removed  );\n \n        \n    }     \n}",
156                                                             "|xns": "Gtk"
157                                                         },
158                                                         {
159                                                             "resizable": true,
160                                                             "min_width": 200,
161                                                             "pack": "append_column",
162                                                             "title": "Filename",
163                                                             "xtype": "TreeViewColumn",
164                                                             "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 0 );\n\n}\n",
165                                                             "|xns": "Gtk",
166                                                             "items": [
167                                                                 {
168                                                                     "pack": "pack_start",
169                                                                     "xtype": "CellRendererText",
170                                                                     "|xns": "Gtk"
171                                                                 }
172                                                             ]
173                                                         },
174                                                         {
175                                                             "min_width": 50,
176                                                             "pack": "append_column",
177                                                             "title": "Added",
178                                                             "xtype": "TreeViewColumn",
179                                                             "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 1 );\n\n}\n",
180                                                             "|xns": "Gtk",
181                                                             "items": [
182                                                                 {
183                                                                     "pack": "pack_start",
184                                                                     "xtype": "CellRendererText",
185                                                                     "|xns": "Gtk"
186                                                                 }
187                                                             ]
188                                                         },
189                                                         {
190                                                             "min_width": 50,
191                                                             "pack": "append_column",
192                                                             "title": "Removed",
193                                                             "xtype": "TreeViewColumn",
194                                                             "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 2 );\n\n}\n",
195                                                             "|xns": "Gtk",
196                                                             "items": [
197                                                                 {
198                                                                     "pack": "pack_start",
199                                                                     "xtype": "CellRendererText",
200                                                                     "|xns": "Gtk"
201                                                                 }
202                                                             ]
203                                                         }
204                                                     ]
205                                                 },
206                                                 {
207                                                     "|xns": "Gtk",
208                                                     "xtype": "TreeView",
209                                                     "pack": false,
210                                                     "items": [
211                                                         {
212                                                             "|xns": "Gtk",
213                                                             "xtype": "ListStore",
214                                                             "pack": false
215                                                         }
216                                                     ]
217                                                 }
218                                             ]
219                                         }
220                                     ]
221                                 },
222                                 {
223                                     "xtype": "VBox",
224                                     "|xns": "Gtk",
225                                     "items": [
226                                         {
227                                             "pack": "pack_start,false,false,0",
228                                             "xtype": "HBox",
229                                             "|xns": "Gtk",
230                                             "items": [
231                                                 {
232                                                     "label": "Commit diff (no merge)",
233                                                     "xtype": "Button",
234                                                     "|xns": "Gtk"
235                                                 },
236                                                 {
237                                                     "label": "Commit diff (merge after)",
238                                                     "xtype": "Button",
239                                                     "|xns": "Gtk"
240                                                 }
241                                             ]
242                                         },
243                                         {
244                                             "pack": "pack_end,true,true,0",
245                                             "xtype": "ScrolledWindow",
246                                             "|init": "function() {\n    XObject.prototype.init.call(this);\n      this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n}\n",
247                                             "|xns": "Gtk",
248                                             "items": [
249                                                 {
250                                                     "id": "patchview",
251                                                     "pack": "add",
252                                                     "xtype": "WebView",
253                                                     "|showDiff": "function(files) {\n    \n    \n    \n     var model = this.get('/historyTreeStore');\n    \n    if (model.release === false) {\n        return;\n    }\n    \n    var diff = Merger.repo.diff(files, model.release, model.rev);\n    \n   // remove..\n    var s  = \"document.body.textContent='';var pre  = document.createElement('pre'); document.body.appendChild(pre);\";\n    s += \"pre.textContent =  \" +\n             JSON.stringify(Merger.repo.lastCmd + \"\\n\") + '+  ' + \n           JSON.stringify(diff) + \";\";\n    print(s);\n        \n    this.el.execute_script(s);\n        \n        \n    \n    \n    \n}\n",
254                                                     "|xns": "WebKit"
255                                                 }
256                                             ]
257                                         }
258                                     ]
259                                 }
260                             ]
261                         }
262                     ]
263                 },
264                 {
265                     "label": "Cancel",
266                     "pack": "add_action_widget,0",
267                     "xtype": "Button",
268                     "|xns": "Gtk",
269                     "listeners": {}
270                 },
271                 {
272                     "id": "ok_button",
273                     "label": "OK",
274                     "pack": "add_action_widget,1",
275                     "xtype": "Button",
276                     "|xns": "Gtk"
277                 }
278             ]
279         }
280     ],
281     "permname": "",
282     "modOrder": ""
283 }