[chirp_devel] [PATCH] Normalized dialog box affirmative buttons to follow gnome human interface guidelines and added alternative button order for other platforms. Fixes #8271
# HG changeset patch # User Kosta A. ve7kcy@gmail.com # Date 1600853926 25200 # Wed Sep 23 02:38:46 2020 -0700 # Node ID 42b1e50fcf7a40ab591074fba9f3808805590f2f # Parent 1a49ad2e84e305b56a3bdeb823266e1219f34e02 Normalized dialog box affirmative buttons to follow gnome human interface guidelines and added alternative button order for other platforms. Fixes #8271.
diff --git a/chirp/ui/bandplans.py b/chirp/ui/bandplans.py --- a/chirp/ui/bandplans.py +++ b/chirp/ui/bandplans.py @@ -47,7 +47,7 @@ # Check for duplicates. duplicates = [x for x in plan.BANDS if x == band] if len(duplicates) > 1: - LOG.warn("Bandplan %s has duplicates %s" % + LOG.debug("Bandplan %s has duplicates %s" % (name, duplicates)) # Add repeater inputs. rpt_input = band.inverse() diff --git a/chirp/ui/clone.py b/chirp/ui/clone.py --- a/chirp/ui/clone.py +++ b/chirp/ui/clone.py @@ -44,13 +44,16 @@
class CloneSettingsDialog(gtk.Dialog): - def __make_field(self, label, widget): - l = gtk.Label(label) - self.__table.attach(l, 0, 1, self.__row, self.__row+1) - self.__table.attach(widget, 1, 2, self.__row, self.__row+1) + def __make_field(self, text, widget): + label = gtk.Label(text) + label.set_alignment(1.0, 0.5) + self.__table.attach(label, 0, 1, self.__row, self.__row+1, + xpadding=6, ypadding=3) + self.__table.attach(widget, 1, 2, self.__row, self.__row+1, + xpadding=6, ypadding=3) self.__row += 1
- l.show() + label.show() widget.show()
def __make_port(self, port): @@ -123,17 +126,15 @@
def __make_ui(self, settings): self.__table = gtk.Table(3, 2) - self.__table.set_row_spacings(3) - self.__table.set_col_spacings(10) self.__row = 0
self.__port = self.__make_port(settings and settings.port or None) self.__modl = self.__make_model() self.__vend = self.__make_vendor(self.__modl)
- self.__make_field(_("Port"), self.__port) - self.__make_field(_("Vendor"), self.__vend) - self.__make_field(_("Model"), self.__modl) + self.__make_field(_("Serial Port:"), self.__port) + self.__make_field(_("Vendor:"), self.__vend) + self.__make_field(_("Model:"), self.__modl)
if settings and settings.radio_class: common.combo_select(self.__vend, settings.radio_class.VENDOR) @@ -144,21 +145,21 @@ self.__modl.set_sensitive(False)
self.__table.show() - self.vbox.pack_start(self.__table, 1, 1, 1) + self.vbox.pack_start(self.__table, False, True, 2)
def __init__(self, settings=None, parent=None, title=_("Radio")): buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK) gtk.Dialog.__init__(self, title, parent=parent, + buttons=buttons, flags=gtk.DIALOG_MODAL) + self.set_default_response(gtk.RESPONSE_OK) + self.set_alternative_button_order([gtk.RESPONSE_OK, + gtk.RESPONSE_CANCEL]) + self.__make_ui(settings) - self.__cancel_button = self.add_button(gtk.STOCK_CANCEL, - gtk.RESPONSE_CANCEL) - self.__okay_button = self.add_button(gtk.STOCK_OK, - gtk.RESPONSE_OK) - self.__okay_button.grab_default() - self.__okay_button.grab_focus() +
def run(self): r = gtk.Dialog.run(self) diff --git a/chirp/ui/editorset.py b/chirp/ui/editorset.py --- a/chirp/ui/editorset.py +++ b/chirp/ui/editorset.py @@ -276,7 +276,7 @@ choices = [x.VARIANT for x in devices]
d = inputdialog.ChoiceDialog(choices) - text = _("The {vendor} {model} has multiple independent sub-devices") + text = _("The {vendor} {model} has multiple independent sub-devices.") d.label.set_text(text.format(vendor=radio.VENDOR, model=radio.MODEL) + os.linesep + _("Choose one to import from:")) r = d.run() diff --git a/chirp/ui/importdialog.py b/chirp/ui/importdialog.py --- a/chirp/ui/importdialog.py +++ b/chirp/ui/importdialog.py @@ -396,19 +396,19 @@ all.connect("clicked", self.__select_all, True) all.set_size_request(50, 25) all.show() - hbox.pack_start(all, 0, 0, 0) + hbox.pack_start(all, False, False, 1)
none = gtk.Button(_("None")) none.connect("clicked", self.__select_all, False) none.set_size_request(50, 25) none.show() - hbox.pack_start(none, 0, 0, 0) + hbox.pack_start(none, False, False, 1)
inv = gtk.Button(_("Inverse")) inv.connect("clicked", self.__select_all, None) inv.set_size_request(50, 25) inv.show() - hbox.pack_start(inv, 0, 0, 0) + hbox.pack_start(inv, False, False, 1)
frame = gtk.Frame(_("Select")) frame.show() @@ -424,49 +424,49 @@ incr.connect("clicked", self.__incrnew, 100) incr.set_size_request(50, 25) incr.show() - hbox.pack_start(incr, 0, 0, 0) + hbox.pack_start(incr, False, False, 1)
incr = gtk.Button("+10") incr.connect("clicked", self.__incrnew, 10) incr.set_size_request(50, 25) incr.show() - hbox.pack_start(incr, 0, 0, 0) + hbox.pack_start(incr, False, False, 1)
incr = gtk.Button("+1") incr.connect("clicked", self.__incrnew, 1) incr.set_size_request(50, 25) incr.show() - hbox.pack_start(incr, 0, 0, 0) + hbox.pack_start(incr, False, False, 1)
decr = gtk.Button("-1") decr.connect("clicked", self.__incrnew, -1) decr.set_size_request(50, 25) decr.show() - hbox.pack_start(decr, 0, 0, 0) + hbox.pack_start(decr, False, False, 1)
decr = gtk.Button("-10") decr.connect("clicked", self.__incrnew, -10) decr.set_size_request(50, 25) decr.show() - hbox.pack_start(decr, 0, 0, 0) + hbox.pack_start(decr, False, False, 1)
decr = gtk.Button("-100") decr.connect("clicked", self.__incrnew, -100) decr.set_size_request(50, 25) decr.show() - hbox.pack_start(decr, 0, 0, 0) + hbox.pack_start(decr, False, False, 1)
auto = gtk.Button(_("Auto")) auto.connect("clicked", self.__autonew) auto.set_size_request(50, 25) auto.show() - hbox.pack_start(auto, 0, 0, 0) + hbox.pack_start(auto, False, False, 1)
revr = gtk.Button(_("Reverse")) revr.connect("clicked", self.__revrnew) revr.set_size_request(50, 25) revr.show() - hbox.pack_start(revr, 0, 0, 0) + hbox.pack_start(revr, False, False, 1)
frame = gtk.Frame(_("Adjust New Location")) frame.show() @@ -482,7 +482,7 @@ confirm.connect("toggled", __set_confirm) confirm.show()
- hbox.pack_start(confirm, 0, 0, 0) + hbox.pack_start(confirm, False, False, 1)
frame = gtk.Frame(_("Options")) frame.add(hbox) @@ -494,16 +494,16 @@ def make_controls(self): hbox = gtk.HBox(False, 2)
- hbox.pack_start(self.make_select(), 0, 0, 0) - hbox.pack_start(self.make_adjust(), 0, 0, 0) + hbox.pack_start(self.make_select(), False, False, 1) + hbox.pack_start(self.make_adjust(), False, False, 1) # hbox.pack_start(self.make_options(), 0, 0, 0) hbox.show()
return hbox
def build_ui(self): - self.vbox.pack_start(self.make_view(), 1, 1, 1) - self.vbox.pack_start(self.make_controls(), 0, 0, 0) + self.vbox.pack_start(self.make_view(), True, True, 1) + self.vbox.pack_start(self.make_controls(), False, False, 0)
def record_use_of(self, number): lo, hi = self.dst_radio.get_features().memory_bounds @@ -578,12 +578,17 @@ ACTION = _("Import")
def __init__(self, src_radio, dst_radio, parent=None): + buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, + gtk.STOCK_OK, gtk.RESPONSE_OK) gtk.Dialog.__init__(self, - buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK, - gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL), title=self.TITLE, + buttons=buttons, parent=parent)
+ self.set_default_response(gtk.RESPONSE_OK) + self.set_alternative_button_order([gtk.RESPONSE_OK, + gtk.RESPONSE_CANCEL]) + self.col_import = 0 self.col_nloc = 1 self.col_oloc = 2 diff --git a/chirp/ui/inputdialog.py b/chirp/ui/inputdialog.py --- a/chirp/ui/inputdialog.py +++ b/chirp/ui/inputdialog.py @@ -22,69 +22,91 @@ LOG = logging.getLogger(__name__)
-class TextInputDialog(gtk.Dialog): - def respond_ok(self, _): - self.response(gtk.RESPONSE_OK) +class ChoiceDialog(gtk.Dialog):
- def __init__(self, **args): - buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, - gtk.STOCK_OK, gtk.RESPONSE_OK) - gtk.Dialog.__init__(self, buttons=buttons, **args) + def _make_ui(self, choices): + self._table = gtk.Table(1, 2)
self.label = gtk.Label() - self.label.set_size_request(300, 100) - # pylint: disable-msg=E1101 - self.vbox.pack_start(self.label, 1, 1, 0) - - self.text = gtk.Entry() - self.text.connect("activate", self.respond_ok, None) - # pylint: disable-msg=E1101 - self.vbox.pack_start(self.text, 1, 1, 0) - + self.label.set_alignment(0.0, 0.5) + self.label.set_size_request(384, -1) self.label.show() - self.text.show() - - -class ChoiceDialog(gtk.Dialog): - editable = False - - def __init__(self, choices, **args): - buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, - gtk.STOCK_OK, gtk.RESPONSE_OK) - gtk.Dialog.__init__(self, buttons=buttons, **args) - - self.label = gtk.Label() - self.label.set_size_request(300, 100) - # pylint: disable-msg=E1101 - self.vbox.pack_start(self.label, 1, 1, 0) - self.label.show() + self._table.attach(self.label, 0, 1, 0, 1, xpadding=6, ypadding=3)
try: default = choices[0] except IndexError: default = None
- self.choice = make_choice(sorted(choices), self.editable, default) - # pylint: disable-msg=E1101 - self.vbox.pack_start(self.choice, 1, 1, 0) + self.choice = make_choice(sorted(choices), False, default) self.choice.show() + self._table.attach(self.choice, 0, 1, 1, 2, xpadding=6, ypadding=3) + + self._table.show() + self.vbox.pack_start(self._table, True, True, 2) + + def __init__(self, choices, **args): + buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, + gtk.STOCK_OK, gtk.RESPONSE_OK) + gtk.Dialog.__init__(self, buttons=buttons, **args)
self.set_default_response(gtk.RESPONSE_OK) + self.set_alternative_button_order([gtk.RESPONSE_OK, + gtk.RESPONSE_CANCEL]) + + self._make_ui(choices)
-class EditableChoiceDialog(ChoiceDialog): - editable = True +class FieldDialog(gtk.Dialog): + + def _make_ui(self): + self._table = gtk.Table(1, 2) + self._table.show() + self._row = 0 + + self.vbox.pack_start(self._table, True, True, 2) + + def __init__(self, **args): + buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, + gtk.STOCK_OK, gtk.RESPONSE_OK) + gtk.Dialog.__init__(self, buttons=buttons, **args) + self.set_default_response(gtk.RESPONSE_OK) + self.set_alternative_button_order([gtk.RESPONSE_OK, + gtk.RESPONSE_CANCEL]) + + self._fields = {} + + self._make_ui()
- def __init__(self, choices, **args): - ChoiceDialog.__init__(self, choices, **args) + def response(self, _): + LOG.debug("Blocking response") + return + + def add_field(self, name, widget, validator=None): + label = gtk.Label(name + ":") + label.set_alignment(1.0, 0.5) + label.show()
- self.choice.child.set_activates_default(True) + widget.set_size_request(160, -1) + widget.show() + + self._table.attach(label, 0, 1, self._row, self._row+1, + xpadding=6, ypadding=3) + self._table.attach(widget, 1, 2, self._row, self._row+1, + xpadding=6, ypadding=3) + self._row += 1 + + self._fields[name] = widget + + def get_field(self, name): + return self._fields.get(name, None)
class ExceptionDialog(gtk.MessageDialog): def __init__(self, exception, **args): gtk.MessageDialog.__init__(self, buttons=gtk.BUTTONS_OK, type=gtk.MESSAGE_ERROR, **args) + self.set_default_response(gtk.RESPONSE_OK) self.set_property("text", _("An error has occurred")) self.format_secondary_text(str(exception))
@@ -94,64 +116,3 @@ LOG.error("--- Exception Dialog: %s ---" % exception) LOG.error(traceback.format_exc(limit=100)) LOG.error("----------------------------") - - -class FieldDialog(gtk.Dialog): - def __init__(self, **kwargs): - if "buttons" not in kwargs.keys(): - kwargs["buttons"] = (gtk.STOCK_OK, gtk.RESPONSE_OK, - gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL) - - self.__fields = {} - self.set_default_response(gtk.RESPONSE_OK) - - gtk.Dialog.__init__(self, **kwargs) - - def response(self, _): - LOG.debug("Blocking response") - return - - def add_field(self, label, widget, validator=None): - box = gtk.HBox(True, 2) - - lab = gtk.Label(label) - lab.show() - - widget.set_size_request(150, -1) - widget.show() - - box.pack_start(lab, 0, 0, 0) - box.pack_start(widget, 0, 0, 0) - box.show() - - # pylint: disable-msg=E1101 - self.vbox.pack_start(box, 0, 0, 0) - - self.__fields[label] = widget - - def get_field(self, label): - return self.__fields.get(label, None) - - -class OverwriteDialog(gtk.MessageDialog): - def __init__(self, filename): - gtk.Dialog.__init__(self, - buttons=(_("Overwrite"), gtk.RESPONSE_OK, - gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) - - self.set_property("text", _("File Exists")) - - text = \ - _("The file {name} already exists. " - "Do you want to overwrite it?").format(name=filename) - - self.format_secondary_text(text) - -if __name__ == "__main__": - # pylint: disable-msg=C0103 - d = FieldDialog(buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK)) - d.add_field("Foo", gtk.Entry()) - d.add_field("Bar", make_choice(["A", "B"])) - d.run() - gtk.main() - d.destroy() diff --git a/chirp/ui/mainapp.py b/chirp/ui/mainapp.py --- a/chirp/ui/mainapp.py +++ b/chirp/ui/mainapp.py @@ -161,9 +161,12 @@ esets.append(self.tabs.get_nth_page(i))
d = gtk.Dialog(title="Diff Radios", - buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK, - gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL), + buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, + gtk.STOCK_OK, gtk.RESPONSE_OK), parent=self) + d.set_default_response(gtk.RESPONSE_OK) + d.set_alternative_button_order([gtk.RESPONSE_OK, + gtk.RESPONSE_CANCEL])
label = gtk.Label("") label.set_markup("<b>-1</b> for either Mem # does a full-file hex " + @@ -296,8 +299,11 @@ choice = miscwidgets.make_choice(sorted(radiolist.keys()), False, sorted(radiolist.keys())[0]) d = gtk.Dialog(title="Detection Failed", - buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK, - gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) + buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, + gtk.STOCK_OK, gtk.RESPONSE_OK)) + d.set_default_response(gtk.RESPONSE_OK) + d.set_alternative_button_order([gtk.RESPONSE_OK, + gtk.RESPONSE_CANCEL]) d.vbox.pack_start(lab, 0, 0, 0) d.vbox.pack_start(choice, 0, 0, 0) d.vbox.set_spacing(5) @@ -481,10 +487,22 @@ return
if os.path.exists(fname): - dlg = inputdialog.OverwriteDialog(fname) - owrite = dlg.run() + dlg = miscwidgets.YesNoDialog( + title=_("Save As"), + parent=self, + buttons=(gtk.STOCK_NO, gtk.RESPONSE_NO, + gtk.STOCK_YES, gtk.RESPONSE_YES)) + dlg.set_default_response(gtk.RESPONSE_NO) + dlg.set_alternative_button_order([gtk.RESPONSE_YES, + gtk.RESPONSE_NO]) + dlg.set_text( + _("{name} already exists." + os.linesep + + "Do you want to replace it?").format(name=fname)) + + res = dlg.run() dlg.destroy() - if owrite == gtk.RESPONSE_OK: + + if res == gtk.RESPONSE_OK: break else: break @@ -812,10 +830,16 @@
if eset.is_modified(): dlg = miscwidgets.YesNoDialog( - title=_("Save Changes?"), parent=self, - buttons=(gtk.STOCK_YES, gtk.RESPONSE_YES, + title=_("Save Changes"), + parent=self, + buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_NO, gtk.RESPONSE_NO, - gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) + gtk.STOCK_YES, gtk.RESPONSE_YES)) + dlg.set_default_response(gtk.RESPONSE_YES) + dlg.set_alternative_button_order([gtk.RESPONSE_YES, + gtk.RESPONSE_NO, + gtk.RESPONSE_CANCEL]) + dlg.set_text(_("File is modified, save changes before closing?")) res = dlg.run() dlg.destroy() @@ -1407,18 +1431,30 @@ else: defname = "radio"
- filen = platform.get_platform().gui_save_file(default_name=defname, + fname = platform.get_platform().gui_save_file(default_name=defname, types=types) - if not filen: + if not fname: return
- if os.path.exists(filen): - dlg = inputdialog.OverwriteDialog(filen) - owrite = dlg.run() + if os.path.exists(fname): + dlg = miscwidgets.YesNoDialog( + title=_("Export"), + parent=self, + buttons=(gtk.STOCK_NO, gtk.RESPONSE_NO, + gtk.STOCK_YES, gtk.RESPONSE_YES)) + dlg.set_default_response(gtk.RESPONSE_NO) + dlg.set_alternative_button_order([gtk.RESPONSE_YES, + gtk.RESPONSE_NO]) + dlg.set_text( + _("{name} already exists." + os.linesep + + "Do you want to replace it?").format(name=fname)) + + res = dlg.run() dlg.destroy() - if owrite != gtk.RESPONSE_OK: + + if res != gtk.RESPONSE_OK: return - os.remove(filen) + os.remove(fname)
count = eset.do_export(filen) reporting.report_model_usage(eset.rthread.radio, "export", count > 0) @@ -1472,28 +1508,43 @@ radio_name = "%s %s %s" % (eset.rthread.radio.VENDOR, eset.rthread.radio.MODEL, eset.rthread.radio.VARIANT) - d = gtk.Dialog(title=_("Select Columns"), + d = gtk.Dialog(title=_("Choose Columns"), parent=self, - buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK, - gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) - - vbox = gtk.VBox() - vbox.show() - sw = gtk.ScrolledWindow() - sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) - sw.add_with_viewport(vbox) - sw.show() - d.vbox.pack_start(sw, 1, 1, 1) + buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, + gtk.STOCK_OK, gtk.RESPONSE_OK)) + d.set_default_response(gtk.RESPONSE_OK) + d.set_alternative_button_order([gtk.RESPONSE_OK, + gtk.RESPONSE_CANCEL]) d.set_size_request(-1, 300) d.set_resizable(False)
- labelstr = _("Visible columns for {radio}").format(radio=radio_name) - label = gtk.Label(labelstr) + text = _("Select the columns you want to display for {radio}.").format(radio=radio_name) + label = gtk.Label(text) + label.set_line_wrap(True) + label.set_size_request(240, -1) label.show() - vbox.pack_start(label) + d.vbox.pack_start(label, False, False, 2) + + model = gtk.ListStore(bool, str) + view = gtk.TreeView(model) + view.set_headers_visible(False) + view.show()
- fields = [] - memedit = eset.get_current_editor() # .editors["memedit"] + def _toggle(rend, path, model, *ignore): + if path is not None: + itr = model.get_iter(path) + model[itr][0] = not model[itr][0] + + rend = gtk.CellRendererToggle() + rend.connect("toggled", _toggle, model) + col = gtk.TreeViewColumn(None, rend, active=0) + view.append_column(col) + + rend = gtk.CellRendererText() + col = gtk.TreeViewColumn(None, rend, text=1) + view.append_column(col) + + memedit = eset.get_current_editor() unsupported = memedit.get_unsupported_columns() for colspec in memedit.cols: if colspec[0].startswith("_"): @@ -1502,20 +1553,22 @@ continue label = colspec[0] visible = memedit.get_column_visible(memedit.col(label)) - widget = gtk.CheckButton(label) - widget.set_active(visible) - fields.append(widget) - vbox.pack_start(widget, 1, 1, 1) - widget.show() + model.append([visible, label]) + + sw = gtk.ScrolledWindow() + sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) + sw.add_with_viewport(view) + sw.show() + d.vbox.pack_start(sw, True, True, 2)
res = d.run() selected_columns = [] if res == gtk.RESPONSE_OK: - for widget in fields: - colnum = memedit.col(widget.get_label()) - memedit.set_column_visible(colnum, widget.get_active()) - if widget.get_active(): - selected_columns.append(widget.get_label()) + for row in model: + colnum = memedit.col(row[1]) + memedit.set_column_visible(colnum, row[0]) + if row[0]: + selected_columns.append(row[1])
d.destroy()
@@ -1598,7 +1651,7 @@ d.label.set_text(_("Choose a language or Auto to use the " "operating system default. You will need to " "restart the application before the change " - "will take effect")) + "will take effect.")) d.label.set_line_wrap(True) r = d.run() if r == gtk.RESPONSE_OK: diff --git a/chirp/ui/memdetail.py b/chirp/ui/memdetail.py --- a/chirp/ui/memdetail.py +++ b/chirp/ui/memdetail.py @@ -176,7 +176,7 @@
def _add(self, tab, row, name, editor, text, colindex=0): label = gtk.Label(text + ":") - label.set_alignment(0.0, 0.5) + label.set_alignment(1.0, 0.5) label.show() tab.attach(label, colindex, colindex + 1, row, row + 1, xoptions=gtk.FILL, yoptions=0, xpadding=6, ypadding=3) @@ -292,8 +292,12 @@ title="Memory Properties", flags=gtk.DIALOG_MODAL, parent=parent, - buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK, - gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) + buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, + gtk.STOCK_OK, gtk.RESPONSE_OK)) + self.set_default_response(gtk.RESPONSE_OK) + self.set_alternative_button_order([gtk.RESPONSE_OK, + gtk.RESPONSE_CANCEL]) + self.set_size_request(-1, 500) self._tips = gtk.Tooltips()
diff --git a/chirp/ui/memedit.py b/chirp/ui/memedit.py --- a/chirp/ui/memedit.py +++ b/chirp/ui/memedit.py @@ -60,6 +60,8 @@ self.set_property("text", _("Invalid value for this field")) self.format_secondary_text(str(exception))
+ self.set_default_response(gtk.RESPONSE_OK) +
def iter_prev(store, iter): row = store.get_path(iter)[0] @@ -1477,20 +1479,28 @@ loc, filled = store.get(iter, self.col(_("Loc")), self.col("_filled")) if filled and not always: - d = miscwidgets.YesNoDialog(title=_("Overwrite?"), - buttons=(gtk.STOCK_YES, 1, - gtk.STOCK_NO, 2, - gtk.STOCK_CANCEL, 3, - "All", 4)) + d = miscwidgets.YesNoDialog( + title=_("Overwrite"), + parent=None, + buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, + gtk.STOCK_NO, gtk.RESPONSE_NO, + _("Yes to All"), gtk.RESPONSE_ACCEPT, + gtk.STOCK_YES, gtk.RESPONSE_YES)) + d.set_default_response(gtk.RESPONSE_YES) + d.set_alternative_button_order([gtk.RESPONSE_YES, + gtk.RESPONSE_ACCEPT, + gtk.RESPONSE_NO, + gtk.RESPONSE_CANCEL]) + d.set_text( _("Overwrite location {number}?").format(number=loc)) r = d.run() d.destroy() - if r == 4: + if r == gtk.RESPONSE_ACCEPT: always = True - elif r == 3: + elif r == gtk.RESPONSE_CANCEL: break - elif r == 2: + elif r == gtk.RESPONSE_NO: iter = store.iter_next(iter) continue
@@ -1508,16 +1518,22 @@ errs = [x for x in msgs if isinstance(x, chirp_common.ValidationError)] if errs: - d = miscwidgets.YesNoDialog(title=_("Incompatible Memory"), - buttons=(gtk.STOCK_OK, 1, - gtk.STOCK_CANCEL, 2)) + d = miscwidgets.YesNoDialog( + title=_("Incompatible Memory"), + parent=None, + buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, + gtk.STOCK_OK, gtk.RESPONSE_OK)) + d.set_default_response(gtk.RESPONSE_OK) + d.set_alternative_button_order([gtk.RESPONSE_OK, + gtk.RESPONSE_CANCEL]) + d.set_text( _("Pasted memory {number} is not compatible with " "this radio because:").format(number=src_number) + os.linesep + os.linesep.join(msgs)) r = d.run() d.destroy() - if r == 2: + if r == gtk.RESPONSE_CANCEL: break else: iter = store.iter_next(iter) diff --git a/chirp/ui/miscwidgets.py b/chirp/ui/miscwidgets.py --- a/chirp/ui/miscwidgets.py +++ b/chirp/ui/miscwidgets.py @@ -603,13 +603,24 @@
class YesNoDialog(gtk.Dialog): def __init__(self, title="", parent=None, buttons=None): - gtk.Dialog.__init__(self, title=title, parent=parent, buttons=buttons) + gtk.Dialog.__init__(self, + title=title, + parent=parent, + buttons=buttons) + + self._table = gtk.Table(1, 2)
self._label = gtk.Label("") + self._label.set_alignment(0.0, 0.5) + self._label.set_line_wrap(True) + self._label.set_size_request(384, -1) self._label.show() + self._table.attach(self._label, 0, 1, 0, 1, + xpadding=6, ypadding=3)
+ self._table.show() # pylint: disable-msg=E1101 - self.vbox.pack_start(self._label, 1, 1, 1) + self.vbox.pack_start(self._table, True, True, 2)
def set_text(self, text): self._label.set_text(text) diff --git a/chirp/ui/settingsedit.py b/chirp/ui/settingsedit.py --- a/chirp/ui/settingsedit.py +++ b/chirp/ui/settingsedit.py @@ -135,7 +135,7 @@
# Label label = gtk.Label(element.get_shortname() + ":") - label.set_alignment(0.0, 0.5) + label.set_alignment(1.0, 0.5) label.show()
table.attach(label, 0, 1, row, row + 1, diff --git a/chirp/ui/shiftdialog.py b/chirp/ui/shiftdialog.py --- a/chirp/ui/shiftdialog.py +++ b/chirp/ui/shiftdialog.py @@ -30,6 +30,8 @@ title=_("Shift"), buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_OK))
+ self.set_default_response(gtk.RESPONSE_OK) + self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
self.rthread = rthread
# HG changeset patch # User Kosta A. ve7kcy@gmail.com # Date 1600853926 25200 # Wed Sep 23 02:38:46 2020 -0700 # Node ID 42b1e50fcf7a40ab591074fba9f3808805590f2f # Parent 1a49ad2e84e305b56a3bdeb823266e1219f34e02 Normalized dialog box affirmative buttons to follow gnome human interface guidelines and added alternative button order for other platforms.
There are a ton of other changes in here, unrelated to this stated goal. Can you please separate out the button ordering change from everything else? Otherwise it's nearly impossible for me to hand-check all of the places that minor tweaks have been made. Since we run on a range of platforms and GTK versions, it's not uncommon for a small seemingly-harmless change to break rendering on a specific GTK version, so validating all of these changes is very difficult.
--Dan
participants (2)
-
Dan Smith
-
Kosta A.