by
Changes to one file · Browse files at 691bd7e30f06 Showing diff from parent 104e7441e988 66c16fa056e0 Diff from another changeset...
|
|
@@ -550,6 +550,9 @@ ret += netloc + '/' + folder
return ret
+CONF_GLOBAL = 0
+CONF_REPO = 1
+
class ConfigDialog(gtk.Dialog):
def __init__(self, configrepo=False, focus=None):
""" Initialize the Dialog. """
@@ -607,6 +610,7 @@ if repo:
combo.append_text(_('%s repository settings') % hglib.toutf(name))
combo.connect('changed', self.fileselect)
+ self.confcombo = combo
hbox = gtk.HBox()
hbox.pack_start(combo, False, False)
@@ -687,12 +691,10 @@ descframe.add(scrolled)
self.descbuffer = desctext.get_buffer()
- self.configrepo = configrepo
-
# Force dialog into clean state in the beginning
self._btn_apply.set_sensitive(False)
self.dirty = False
- combo.set_active(configrepo and 1 or 0)
+ combo.set_active(configrepo and CONF_REPO or CONF_GLOBAL)
# focus 'general' page or specified field
if focus:
@@ -704,16 +706,23 @@ def fileselect(self, combo):
'select another hgrc file'
if self.dirty:
- ret = gdialog.Confirm(_('Unapplied changes'), [], self,
- _('Lose changes and switch files?.')).run()
- if ret != gtk.RESPONSE_YES:
- return
- self.configrepo = combo.get_active() and True or False
+ ret = gdialog.CustomPrompt(_('Confirm Switch'),
+ _('Switch after saving changes?'), self,
+ (_('&Save'), _('&Discard'), _('&Cancel')),
+ default=2, esc=2).run()
+ if ret == 2:
+ combo.handler_block_by_func(self.fileselect)
+ repo = combo.get_active() == CONF_GLOBAL
+ combo.set_active(repo and CONF_REPO or CONF_GLOBAL)
+ combo.handler_unblock_by_func(self.fileselect)
+ return
+ elif ret == 0:
+ self.apply_changes()
self.refresh()
def refresh(self):
# determine target config file
- if self.configrepo:
+ if self.confcombo.get_active() == CONF_REPO:
repo = hg.repository(ui.ui(), self.root)
name = hglib.get_reponame(repo)
self.rcpath = [os.sep.join([repo.root, '.hg', 'hgrc'])]
@@ -735,7 +744,7 @@
def edit_clicked(self, button):
# reload configs, in case they have been written since opened
- if self.configrepo:
+ if self.confcombo.get_active() == CONF_REPO:
repo = hg.repository(ui.ui(), self.root)
u = repo.ui
else:
@@ -752,7 +761,7 @@
def should_live(self, dialog=None, resp=None):
if resp == gtk.RESPONSE_APPLY:
- self._apply_clicked()
+ self.apply_changes()
self.emit_stop_by_name('response')
return True
elif resp == gtk.RESPONSE_CANCEL:
@@ -770,7 +779,7 @@ self.emit_stop_by_name('response')
return True
elif ret == 0:
- self._apply_clicked()
+ self.apply_changes()
return False
def cursor_changed(self, treeview):
@@ -1268,7 +1277,7 @@ # Try to create a file from rcpath
try:
f = open(fn, 'w')
- f.write(_('# Generated by tortoisehg-config\n'))
+ f.write('# Generated by TortoiseHg setting dialog\n')
f.close()
break
except (IOError, OSError):
@@ -1328,7 +1337,7 @@ self.history.get_value(cpath).remove(newvalue)
self.history.mrul(cpath).add(newvalue)
- def _apply_clicked(self, *args):
+ def apply_changes(self):
if self.readonly:
#dialog? Read only access, please install ...
return
|
Loading...