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