Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.0, 1.0.1, and 1.0.2

gtklib: add function to open file with configured visual editor

Changeset 50bdf438d512

Parent d6da12d2789a

by Yuki KODAMA

Changes to 3 files · Browse files at 50bdf438d512 Showing diff from parent d6da12d2789a Diff from another changeset...

 
12
13
14
 
 
 
15
16
17
 
152
153
154
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
156
157
 
12
13
14
15
16
17
18
19
20
 
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
@@ -12,6 +12,9 @@
 import gobject  import Queue  import urllib +import threading + +from mercurial import util    from tortoisehg.util.i18n import _  from tortoisehg.util import paths, hglib, thread2 @@ -152,6 +155,23 @@
  paths.append(path)   return paths   +def open_with_editor(ui, file, parent=None): + def doedit(): + util.system('%s "%s"' % (editor, file)) + editor = (ui.config('tortoisehg', 'editor') or + ui.config('gtools', 'editor') or + os.environ.get('HGEDITOR') or + ui.config('ui', 'editor') or + os.environ.get('EDITOR', 'vi')) + if os.path.basename(editor) in ('vi', 'vim', 'hgeditor'): + gdialog.Prompt(_('No visual editor configured'), + _('Please configure a visual editor.'), parent).run() + return False + thread = threading.Thread(target=doedit, name='edit') + thread.setDaemon(True) + thread.start() + return True +  class MessageDialog(gtk.Dialog):   button_map = {   gtk.BUTTONS_NONE: None,
 
8
9
10
11
12
13
14
 
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
 
176
177
178
 
8
9
10
 
11
12
13
 
158
159
160
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
162
163
164
@@ -8,7 +8,6 @@
 import os  import gtk  import re -import threading    from mercurial import hg, ui, match, util, error   @@ -159,20 +158,7 @@
  self.refresh()     def edit_clicked(self, button): - def doedit(): - util.system('%s "%s"' % (editor, self.ignorefile)) - editor = (self.repo.ui.config('tortoisehg', 'editor') or - self.repo.ui.config('gtools', 'editor') or - os.environ.get('HGEDITOR') or - self.repo.ui.config('ui', 'editor') or - os.environ.get('EDITOR', 'vi')) - if os.path.basename(editor) in ('vi', 'vim', 'hgeditor'): - gdialog.Prompt(_('No visual editor configured'), - _('Please configure a visual editor.'), self).run() - return - thread = threading.Thread(target=doedit, name='edit ignore') - thread.setDaemon(True) - thread.start() + gtklib.open_with_editor(self.repo.ui, self.ignorefile, self)     def unknown_search(self, model, column, key, iter):   'case insensitive filename search'
 
10
11
12
13
14
15
16
 
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
 
 
700
701
702
703
704
705
706
707
708
 
10
11
12
 
13
14
15
 
680
681
682
 
 
683
684
685
686
687
688
 
 
 
 
 
 
 
 
689
690
691
 
 
 
 
 
692
693
694
@@ -10,7 +10,6 @@
 import sys  import re  import urlparse -import threading    from mercurial import hg, ui, util, url, filemerge, error   @@ -681,28 +680,15 @@
  self.dirty = False     def edit_clicked(self, button): - def doedit(): - util.system("%s \"%s\"" % (editor, self.fn))   # reload configs, in case they have been written since opened   if self.configrepo:   repo = hg.repository(ui.ui(), self.root)   u = repo.ui   else:   u = ui.ui() - editor = (u.config('tortoisehg', 'editor') or - u.config('gtools', 'editor') or - os.environ.get('HGEDITOR') or - u.config('ui', 'editor') or - os.environ.get('EDITOR', 'vi')) - if os.path.basename(editor) in ('vi', 'vim', 'hgeditor'): - gdialog.Prompt(_('No visual editor configured'), - _('Please configure a visual editor.'), self).run() + # open config file with visual editor + if not gtklib.open_with_editor(u, self.fn, self):   self.focus_field('tortoisehg.editor') - return True - thread = threading.Thread(target=doedit, name='edit config') - thread.setDaemon(True) - thread.start() - return True     def delete_event(self, dlg, event):   return True