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                                     "listeners": {
35                                         "changed": "function (self) {\n   this.get('/historyTreeStore').loadTree();\n}"
36                                     },
37                                     "id": "workingCombo",
38                                     "xtype": "ComboBox",
39                                     "|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",
40                                     "|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}",
41                                     "|xns": "Gtk",
42                                     "items": [
43                                         {
44                                             "*prop": "model",
45                                             "xtype": "ListStore",
46                                             "|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",
47                                             "|xns": "Gtk"
48                                         }
49                                     ]
50                                 },
51                                 {
52                                     "label": "Release Branch",
53                                     "xtype": "Label",
54                                     "|xns": "Gtk"
55                                 },
56                                 {
57                                     "listeners": {
58                                         "changed": "function (self) {\n   this.get('/historyTreeStore').loadTree();\n}"
59                                     },
60                                     "id": "releaseCombo",
61                                     "xtype": "ComboBox",
62                                     "|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",
63                                     "|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}",
64                                     "|xns": "Gtk",
65                                     "items": [
66                                         {
67                                             "*prop": "model",
68                                             "xtype": "ListStore",
69                                             "|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",
70                                             "|xns": "Gtk"
71                                         }
72                                     ]
73                                 }
74                             ]
75                         },
76                         {
77                             "pack": "pack_end,true,true,0",
78                             "position": 400,
79                             "xtype": "VPaned",
80                             "|xns": "Gtk",
81                             "items": [
82                                 {
83                                     "pack": "add",
84                                     "position": 200,
85                                     "xtype": "HPaned",
86                                     "|xns": "Gtk",
87                                     "items": [
88                                         {
89                                             "xtype": "ScrolledWindow",
90                                             "|init": "function() {\n    XObject.prototype.init.call(this);\n     this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n}\n",
91                                             "|xns": "Gtk",
92                                             "items": [
93                                                 {
94                                                     "listeners": {
95                                                         "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}"
96                                                     },
97                                                     "pack": "add",
98                                                     "xtype": "TreeView",
99                                                     "|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",
100                                                     "|xns": "Gtk",
101                                                     "items": [
102                                                         {
103                                                             "id": "historyTreeStore",
104                                                             "pack": "set_model",
105                                                             "release": false,
106                                                             "xtype": "TreeStore",
107                                                             "|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",
108                                                             "|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}",
109                                                             "|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",
110                                                             "|xns": "Gtk"
111                                                         },
112                                                         {
113                                                             "pack": "append_column",
114                                                             "xtype": "TreeViewColumn",
115                                                             "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 0 );\n\n}\n",
116                                                             "|xns": "Gtk",
117                                                             "items": [
118                                                                 {
119                                                                     "pack": "pack_start",
120                                                                     "xtype": "CellRendererText",
121                                                                     "|xns": "Gtk"
122                                                                 }
123                                                             ]
124                                                         }
125                                                     ]
126                                                 }
127                                             ]
128                                         },
129                                         {
130                                             "xtype": "ScrolledWindow",
131                                             "|init": "function() {\n    XObject.prototype.init.call(this);\n      this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n}\n",
132                                             "|xns": "Gtk",
133                                             "items": [
134                                                 {
135                                                     "listeners": {
136                                                         "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}"
137                                                     },
138                                                     "id": "changedFilesView",
139                                                     "pack": "add",
140                                                     "xtype": "TreeView",
141                                                     "|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",
142                                                     "|xns": "Gtk",
143                                                     "items": [
144                                                         {
145                                                             "id": "changedFilesStore",
146                                                             "pack": "set_model",
147                                                             "xtype": "ListStore",
148                                                             "|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",
149                                                             "|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}",
150                                                             "|xns": "Gtk"
151                                                         },
152                                                         {
153                                                             "resizable": true,
154                                                             "min_width": 200,
155                                                             "pack": "append_column",
156                                                             "title": "Filename",
157                                                             "xtype": "TreeViewColumn",
158                                                             "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 0 );\n\n}\n",
159                                                             "|xns": "Gtk",
160                                                             "items": [
161                                                                 {
162                                                                     "pack": "pack_start",
163                                                                     "xtype": "CellRendererText",
164                                                                     "|xns": "Gtk"
165                                                                 }
166                                                             ]
167                                                         },
168                                                         {
169                                                             "min_width": 50,
170                                                             "pack": "append_column",
171                                                             "title": "Added",
172                                                             "xtype": "TreeViewColumn",
173                                                             "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 1 );\n\n}\n",
174                                                             "|xns": "Gtk",
175                                                             "items": [
176                                                                 {
177                                                                     "pack": "pack_start",
178                                                                     "xtype": "CellRendererText",
179                                                                     "|xns": "Gtk"
180                                                                 }
181                                                             ]
182                                                         },
183                                                         {
184                                                             "min_width": 50,
185                                                             "pack": "append_column",
186                                                             "title": "Removed",
187                                                             "xtype": "TreeViewColumn",
188                                                             "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 2 );\n\n}\n",
189                                                             "|xns": "Gtk",
190                                                             "items": [
191                                                                 {
192                                                                     "pack": "pack_start",
193                                                                     "xtype": "CellRendererText",
194                                                                     "|xns": "Gtk"
195                                                                 }
196                                                             ]
197                                                         }
198                                                     ]
199                                                 },
200                                                 {
201                                                     "|xns": "Gtk",
202                                                     "xtype": "TreeView",
203                                                     "pack": false,
204                                                     "items": [
205                                                         {
206                                                             "|xns": "Gtk",
207                                                             "xtype": "ListStore",
208                                                             "pack": false
209                                                         }
210                                                     ]
211                                                 }
212                                             ]
213                                         }
214                                     ]
215                                 },
216                                 {
217                                     "xtype": "VBox",
218                                     "|xns": "Gtk",
219                                     "items": [
220                                         {
221                                             "pack": "pack_start,false,false,0",
222                                             "xtype": "HBox",
223                                             "|xns": "Gtk",
224                                             "items": [
225                                                 {
226                                                     "label": "Commit diff (no merge)",
227                                                     "xtype": "Button",
228                                                     "|xns": "Gtk"
229                                                 },
230                                                 {
231                                                     "label": "Commit diff (merge after)",
232                                                     "xtype": "Button",
233                                                     "|xns": "Gtk"
234                                                 }
235                                             ]
236                                         },
237                                         {
238                                             "pack": "pack_end,true,true,0",
239                                             "xtype": "ScrolledWindow",
240                                             "|init": "function() {\n    XObject.prototype.init.call(this);\n      this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n}\n",
241                                             "|xns": "Gtk",
242                                             "items": [
243                                                 {
244                                                     "id": "patchview",
245                                                     "pack": "add",
246                                                     "xtype": "WebView",
247                                                     "|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(repo.lastCmd + \"\\n\") + '+  ' + \n           JSON.stringify(diff) + \";\";\n    print(s);\n        \n    this.el.execute_script(s);\n        \n        \n    \n    \n    \n}\n",
248                                                     "|xns": "WebKit"
249                                                 }
250                                             ]
251                                         }
252                                     ]
253                                 }
254                             ]
255                         }
256                     ]
257                 },
258                 {
259                     "label": "Cancel",
260                     "pack": "add_action_widget,0",
261                     "xtype": "Button",
262                     "|xns": "Gtk",
263                     "listeners": {}
264                 },
265                 {
266                     "id": "ok_button",
267                     "label": "OK",
268                     "pack": "add_action_widget,1",
269                     "xtype": "Button",
270                     "|xns": "Gtk"
271                 }
272             ]
273         }
274     ],
275     "permname": "",
276     "modOrder": ""
277 }