Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.4rc1, 0.4rc2, and 0.4rc3

hggtk/clone: add recent dest paths to drop-down list

Changeset 66b4d5869034

Parent 8a6b2ec1828e

by Amino Acid

Changes to one file · Browse files at 66b4d5869034 Showing diff from parent 8a6b2ec1828e Diff from another changeset...

Change 1 of 3 Show Entire File hggtk/​clone.py Stacked
 
115
116
117
118
 
 
 
119
 
 
 
 
 
 
 
120
121
122
123
 
124
125
 
 
 
 
 
 
126
127
128
 
226
227
228
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
230
231
 
275
276
277
 
278
279
280
 
115
116
117
 
118
119
120
121
122
123
124
125
126
127
128
129
130
131
 
132
133
134
135
136
137
138
139
140
141
142
143
 
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
 
311
312
313
314
315
316
317
@@ -115,14 +115,29 @@
  lbl = gtk.Label("Destination Path:")   lbl.set_property("width-chars", ewidth)   lbl.set_alignment(0, 0.5) - self._dest_input = gtk.Entry() + self._destlist = gtk.ListStore(str) + self._destlistbox = gtk.ComboBoxEntry(self._destlist, 0) + self._dest_input = self._destlistbox.get_child()   self._dest_input.set_text(self._dest_path) + # replace the drop-down widget so we can modify it's properties + self._destlistbox.clear() + cell = gtk.CellRendererText() + cell.set_property('ellipsize', pango.ELLIPSIZE_MIDDLE) + self._destlistbox.pack_start(cell) + self._destlistbox.add_attribute(cell, 'text', 0) +   self._btn_dest_browse = gtk.Button("Browse...")   self._btn_dest_browse.connect('clicked', self._btn_dest_clicked)   destbox.pack_start(lbl, False, False) - destbox.pack_start(self._dest_input, True, True) + destbox.pack_start(self._destlistbox, True, True)   destbox.pack_end(self._btn_dest_browse, False, False, 5)   vbox.pack_start(destbox, False, False, 2) + + # add pre-defined dest paths to pull-down list + recentdest = self._settings.get('dest_paths', []) + paths = list(set(sympaths + recentdest)) + paths.sort() + for p in paths: self._destlist.append([p])     # revision input   revbox = gtk.HBox() @@ -226,6 +241,27 @@
  self._settings['src_paths'] = []   self._settings['src_paths'].append(src)   self._settings.write() + + def _add_dest_to_recent(self, dest): + if os.path.exists(dest): + dest = os.path.abspath(dest) + + destlist = [x[0] for x in self._destlist] + if dest in destlist: + return + + # update drop-down list + destlist.append(dest) + destlist.sort() + self._destlist.clear() + for p in destlist: + self._destlist.append([p]) + + # save path to recent list in history + if not 'dest_paths' in self._settings: + self._settings['dest_paths'] = [] + self._settings['dest_paths'].append(dest) + self._settings.write()     def _btn_clone_clicked(self, toolbutton, data=None):   # gather input data @@ -275,6 +311,7 @@
  return False     self._add_src_to_recent(src) + self._add_dest_to_recent(dest)    def run(cwd='', files=[], **opts):   dialog = CloneDialog(cwd, repos=files)