# HG changeset patch
# User Adrian Buehlmann <adr...@cadifra.com>
# Date 1253400844 -7200
# Node ID fd9f6fae7fa48c782fd01a449002b979c731200d
# Parent  ed045400e5a7534d1aa9d6b8c27f31cbf857dbde
update: use radio group for options

A combobox containing the option -C is just way too dangerous.
One inadvertant tiny turn on the mousewheel and you have -C
in the combobox. Forget checking it, and a click on "Update"
later your local changes are gone forever!

This is a perfect case for classic radio buttons, so let's use
them here instead of a combobox.

We have enough room for using radio buttons. Like this, the
user can read the texts of all three choices at once and all
the time.

Tweaking the texts while we're at it.

diff --git a/tortoisehg/hgtk/update.py b/tortoisehg/hgtk/update.py
--- a/tortoisehg/hgtk/update.py
+++ b/tortoisehg/hgtk/update.py
@@ -22,10 +22,6 @@ BRANCH_TIP = _('= Current Branch Tip =')
 MODE_NORMAL   = 'normal'
 MODE_UPDATING = 'updating'
 
-OPT_CHECK = 0
-OPT_CLEAN = 1
-OPT_MERGE = 2
-
 class UpdateDialog(gtk.Dialog):
     """ Dialog to update Mercurial repo """
     def __init__(self, rev=None):
@@ -92,12 +88,20 @@ class UpdateDialog(gtk.Dialog):
             combo.append_text(t)
 
         # options
-        self.optlist = gtk.combo_box_new_text()
-        self.optlist.append_text(_('Check local changes (--check)'))
-        self.optlist.append_text(_('Discard local changes (--clean)'))
-        self.optlist.append_text(_('Allow merge (default)'))
-        self.optlist.set_active(OPT_CHECK)
-        addrow(_('Option:'), self.optlist, expand=False)
+        self.opt_buttons = []
+        group = gtk.RadioButton(None, _('Allow merge with local changes 
(default)'))
+        addrow('', group, expand=False)
+        self.opt_buttons.append(group)
+
+        btn = gtk.RadioButton(group, _('Abort if local changes found 
(-c/--check)'))
+        addrow('', btn, expand=False)
+        self.opt_buttons.append(btn)
+        self.opt_check = btn
+
+        btn = gtk.RadioButton(group, _('Discard local changes, no backup 
(-C/--clean)'))
+        addrow('', btn, expand=False)
+        self.opt_buttons.append(btn)
+        self.opt_clean = btn
 
         # prepare to show
         self.updatebtn.grab_focus()
@@ -137,15 +141,18 @@ class UpdateDialog(gtk.Dialog):
         if mode == MODE_NORMAL:
             normal = True
             self.closebtn.grab_focus()
+            for btn in self.opt_buttons:
+                btn.set_sensitive(True)
         elif mode == MODE_UPDATING:
             normal = False
             self.cancelbtn.grab_focus()
+            for btn in self.opt_buttons:
+                btn.set_sensitive(False)
         else:
             raise _('unknown mode name: %s') % mode
         updating = not normal
 
         self.table.set_sensitive(normal)
-        self.optlist.set_sensitive(normal)
         self.updatebtn.set_property('visible', normal)
         self.closebtn.set_property('visible', normal)
         if cmd:
@@ -160,10 +167,9 @@ class UpdateDialog(gtk.Dialog):
         if rev != BRANCH_TIP:
             cmdline.append('--rev')
             cmdline.append(rev)
-        opt = self.optlist.get_active()
-        if opt == OPT_CHECK:
+        if self.opt_check.get_active():
             cmdline.append('--check')
-        elif opt == OPT_CLEAN:
+        elif self.opt_clean.get_active():
             cmdline.append('--clean')
 
         def cmd_done(returncode):

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Tortoisehg-develop mailing list
Tortoisehg-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tortoisehg-develop

Reply via email to