Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.8, 0.8.1, and 0.8.2

hglib: hookup CustomPrompt to GtkUI

fixes #187

Changeset 4c9d3c72252b

Parent 4181cd5c0c85

by Steve Borho

Changes to one file · Browse files at 4c9d3c72252b Showing diff from parent 4181cd5c0c85 Diff from another changeset...

Change 1 of 4 Show Entire File hggtk/​hglib.py Stacked
 
5
6
7
 
8
9
10
 
144
145
146
147
 
148
149
150
151
152
153
 
154
155
156
 
165
166
167
168
 
169
170
171
 
207
208
209
210
211
 
 
 
 
 
 
 
212
213
214
215
216
 
 
 
 
 
 
 
 
217
218
 
219
220
221
 
222
223
224
 
5
6
7
8
9
10
11
 
145
146
147
 
148
149
150
151
152
153
 
154
155
156
157
 
166
167
168
 
169
170
171
172
 
208
209
210
 
 
211
212
213
214
215
216
217
218
219
220
221
 
222
223
224
225
226
227
228
229
230
 
231
232
233
 
234
235
236
237
@@ -5,6 +5,7 @@
 import threading, thread2  import urllib2  import Queue +import gdialog  from mercurial import hg, ui, util, extensions, commands, hook  from mercurial.i18n import _  from dialog import entry_dialog @@ -144,13 +145,13 @@
  def flush(self):   pass   - def prompt(self, msg, pat=None, default="y"): + def prompt(self, msg, pat=None, choices=None, default="y"):   import re   if not calliffunc(self.interactive): return default   while True:   try:   # send request to main thread, await response - self.dialogq.put( (msg, True, default) ) + self.dialogq.put( (msg, True, choices, default) )   r = self.responseq.get(True)   if r is None:   raise EOFError @@ -165,7 +166,7 @@
    def getpass(self, prompt=None, default=None):   # send request to main thread, await response - self.dialogq.put( (prompt or _('password: '), False, default) ) + self.dialogq.put( (prompt or _('password: '), False, None, default) )   r = self.responseq.get(True)   if r is None:   raise util.Abort(_('response expected')) @@ -207,18 +208,30 @@
  def process_dialogs(self):   '''Polled every 10ms to serve dialogs for the background thread'''   try: - (prompt, visible, default) = self.dialogq.get_nowait() - self.dlg = entry_dialog(self.parent, prompt, visible, default, + (prompt, visible, choices, default) = self.dialogq.get_nowait() + if choices: + dlg = gdialog.CustomPrompt('Hg Prompt', prompt, + self.parent, choices, default) + dlg.connect('response', self.prompt_response) + else: + dlg = entry_dialog(self.parent, prompt, visible, default,   self.dialog_response)   except Queue.Empty:   pass   - def dialog_response(self, widget, response_id): + def prompt_response(self, dialog, response_id): + dialog.destroy() + if response_id == gtk.RESPONSE_DELETE_EVENT: + raise util.Abort('No response') + else: + self.responseq.put(chr(response_id)) + + def dialog_response(self, dialog, response_id):   if response_id == gtk.RESPONSE_OK: - text = self.dlg.entry.get_text() + text = dialog.entry.get_text()   else:   text = None - self.dlg.destroy() + dialog.destroy()   self.responseq.put(text)     def run(self):