changeset 13836047b0ac in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset;node=13836047b0ac
description:
Remove fast tabbing
The focus_chain is deprecated in GTK+3 so we can no more implement
easily the
fast tabbing. Instead we remove focusable property on buttons that are
not
needed because they have shortcuts.
issue8181
review261071002
diffstat:
CHANGELOG | 2 +
doc/usage.rst | 3 -
tryton/common/focus.py | 38 +++++-----------
tryton/config.py | 1 -
tryton/gui/main.py | 1 -
tryton/gui/window/view_form/view/form_gtk/binary.py | 5 --
tryton/gui/window/view_form/view/form_gtk/calendar_.py | 7 ---
tryton/gui/window/view_form/view/form_gtk/char.py | 9 ----
tryton/gui/window/view_form/view/form_gtk/dictionary.py | 3 +-
tryton/gui/window/view_form/view/form_gtk/many2many.py | 6 +-
tryton/gui/window/view_form/view/form_gtk/many2one.py | 5 --
tryton/gui/window/view_form/view/form_gtk/one2many.py | 34 ++++-----------
tryton/gui/window/view_form/view/form_gtk/reference.py | 8 ---
tryton/gui/window/view_form/view/form_gtk/selection.py | 6 --
tryton/gui/window/view_form/view/form_gtk/textbox.py | 4 -
tryton/gui/window/view_form/view/form_gtk/timedelta.py | 5 --
tryton/gui/window/view_form/view/form_gtk/url.py | 6 --
tryton/gui/window/view_form/view/screen_container.py | 1 -
18 files changed, 26 insertions(+), 118 deletions(-)
diffs (533 lines):
diff -r 841e8f907d37 -r 13836047b0ac CHANGELOG
--- a/CHANGELOG Fri Mar 22 11:20:53 2019 +0100
+++ b/CHANGELOG Fri Mar 22 11:26:31 2019 +0100
@@ -1,3 +1,5 @@
+* Remove Fast Tabbing option
+* Remove usage of focus_chain
* Add shortcuts for switch and remove on One2Many
* Rename roundup.url configuration to bug.url
* Remove send error to bug tracker
diff -r 841e8f907d37 -r 13836047b0ac doc/usage.rst
--- a/doc/usage.rst Fri Mar 22 11:20:53 2019 +0100
+++ b/doc/usage.rst Fri Mar 22 11:26:31 2019 +0100
@@ -185,9 +185,6 @@
* Save Tree Expanded State:
Check box to enable saving of expanded and selected nodes in trees/lists.
- * Fast Tabbing:
- Check box to enable fast tabbing navigation by skipping readonly entries.
-
* Spell Checking:
Check box to enable spell checking in fields.
diff -r 841e8f907d37 -r 13836047b0ac tryton/common/focus.py
--- a/tryton/common/focus.py Fri Mar 22 11:20:53 2019 +0100
+++ b/tryton/common/focus.py Fri Mar 22 11:26:31 2019 +0100
@@ -43,13 +43,12 @@
return (y1 > y2) - (y1 < y2)
-def get_focus_chain(widget):
- focus_chain = widget.get_focus_chain()
- # If the focus_chain is not defined on the widget then we will simply
- # search into all its children widgets
- return (focus_chain
- if focus_chain is not None
- else sorted(widget.get_children(), key=cmp_to_key(tab_compare)))
+def get_focus_children(widget):
+ if hasattr(widget, 'get_children'):
+ result = sorted(widget.get_children(), key=cmp_to_key(tab_compare))
+ return result
+ else:
+ return []
def find_focusable_child(widget):
@@ -57,9 +56,7 @@
return None
if widget.get_can_focus():
return widget
- if not hasattr(widget, 'get_children'):
- return None
- for child in get_focus_chain(widget):
+ for child in get_focus_children(widget):
focusable = find_focusable_child(child)
if focusable:
return focusable
@@ -68,29 +65,18 @@
def next_focus_widget(widget):
if not widget.props.parent:
return None
- focus_chain = widget.props.parent.get_focus_chain()
- if focus_chain is not None:
- idx = focus_chain.index(widget)
- focus_widget = None
- for widget in focus_chain[idx:] + focus_chain[:idx]:
- focus_widget = find_focusable_child(widget)
- if focus_widget:
- return focus_widget
- if not focus_widget:
- return next_focus_widget(widget.props.parent)
+ focus_widget = find_focusable_child(widget.props.parent)
+ if focus_widget:
+ return focus_widget
else:
- focus_widget = find_focusable_child(widget.props.parent)
- if focus_widget:
- return focus_widget
- else:
- return next_focus_widget(widget.props.parent)
+ return next_focus_widget(widget.props.parent)
def find_first_focus_widget(ancestor, widgets):
"Return the widget from widgets which should have first the focus"
if len(widgets) == 1:
return widgets[0]
- for child in get_focus_chain(ancestor):
+ for child in get_focus_children(ancestor):
common = [w for w in widgets if w.is_ancestor(child)]
if common:
return find_first_focus_widget(child, common)
diff -r 841e8f907d37 -r 13836047b0ac tryton/config.py
--- a/tryton/config.py Fri Mar 22 11:20:53 2019 +0100
+++ b/tryton/config.py Fri Mar 22 11:26:31 2019 +0100
@@ -48,7 +48,6 @@
'client.toolbar': 'default',
'client.save_width_height': True,
'client.save_tree_state': True,
- 'client.fast_tabbing': True,
'client.spellcheck': False,
'client.lang': locale.getdefaultlocale()[0],
'client.language_direction': 'ltr',
diff -r 841e8f907d37 -r 13836047b0ac tryton/gui/main.py
--- a/tryton/gui/main.py Fri Mar 22 11:20:53 2019 +0100
+++ b/tryton/gui/main.py Fri Mar 22 11:26:31 2019 +0100
@@ -77,7 +77,6 @@
('mode-pda', 'client.modepda'),
('save-width-height', 'client.save_width_height'),
('save-tree-state', 'client.save_tree_state'),
- ('fast-tabbing', 'client.fast_tabbing'),
('spell-checking', 'client.spellcheck'),
('check-version', 'client.check_version'),
]:
diff -r 841e8f907d37 -r 13836047b0ac
tryton/gui/window/view_form/view/form_gtk/binary.py
--- a/tryton/gui/window/view_form/view/form_gtk/binary.py Fri Mar 22
11:20:53 2019 +0100
+++ b/tryton/gui/window/view_form/view/form_gtk/binary.py Fri Mar 22
11:26:31 2019 +0100
@@ -10,7 +10,6 @@
from tryton.common import common
from tryton.common import file_selection, Tooltips, file_open, file_write
from tryton.common.entry_position import reset_position
-from tryton.config import CONFIG
from .widget import Widget
_ = gettext.gettext
@@ -178,10 +177,6 @@
self.but_clear.set_sensitive(not value)
if self.wid_text:
self.wid_text.set_editable(not value)
- if value and CONFIG['client.fast_tabbing']:
- self.widget.set_focus_chain([])
- else:
- self.widget.unset_focus_chain()
def sig_key_press(self, widget, event, *args):
editable = self.wid_text and self.wid_text.get_editable()
diff -r 841e8f907d37 -r 13836047b0ac
tryton/gui/window/view_form/view/form_gtk/calendar_.py
--- a/tryton/gui/window/view_form/view/form_gtk/calendar_.py Fri Mar 22
11:20:53 2019 +0100
+++ b/tryton/gui/window/view_form/view/form_gtk/calendar_.py Fri Mar 22
11:26:31 2019 +0100
@@ -9,7 +9,6 @@
from tryton import common
from tryton.common.datetime_ import (Date as DateEntry, Time as TimeEntry,
DateTime as DateTimeEntry, add_operators)
-from tryton.config import CONFIG
_ = gettext.gettext
@@ -39,10 +38,6 @@
def _readonly_set(self, value):
self._set_editable(not value)
- if value and CONFIG['client.fast_tabbing']:
- self.widget.set_focus_chain([])
- else:
- self.widget.unset_focus_chain()
@classmethod
def cast(cls, value):
@@ -87,7 +82,6 @@
class Time(Date):
def __init__(self, view, attrs):
super(Time, self).__init__(view, attrs, _entry=TimeEntry)
- self.entry.set_focus_chain([self.entry.get_child()])
self.entry.connect('time-changed', self.changed)
def _set_editable(self, value):
@@ -132,7 +126,6 @@
for child in self.entry.get_children():
add_operators(child)
if isinstance(child, Gtk.ComboBox):
- child.set_focus_chain([child.get_child()])
child = child.get_child()
child.set_property('activates_default', True)
child.connect('key_press_event', self.sig_key_press)
diff -r 841e8f907d37 -r 13836047b0ac
tryton/gui/window/view_form/view/form_gtk/char.py
--- a/tryton/gui/window/view_form/view/form_gtk/char.py Fri Mar 22 11:20:53
2019 +0100
+++ b/tryton/gui/window/view_form/view/form_gtk/char.py Fri Mar 22 11:26:31
2019 +0100
@@ -8,7 +8,6 @@
from tryton.common import Tooltips, IconFactory
from tryton.common.entry_position import reset_position
from tryton.common.selection import PopdownMixin, selection_shortcuts
-from tryton.config import CONFIG
_ = gettext.gettext
@@ -155,10 +154,6 @@
else:
entry_editable = self.entry
entry_editable.set_editable(not value)
- if value and CONFIG['client.fast_tabbing']:
- self.widget.set_focus_chain([])
- else:
- self.widget.unset_focus_chain()
class Password(Char):
@@ -177,10 +172,6 @@
super(Char, self)._readonly_set(value)
self.entry.set_editable(not value)
self.visibility_checkbox.props.visible = not value
- if value and CONFIG['client.fast_tabbing']:
- self.widget.set_focus_chain([])
- else:
- self.widget.unset_focus_chain()
def toggle_visibility(self, button):
self.entry.props.visibility = not self.entry.props.visibility
diff -r 841e8f907d37 -r 13836047b0ac
tryton/gui/window/view_form/view/form_gtk/dictionary.py
--- a/tryton/gui/window/view_form/view/form_gtk/dictionary.py Fri Mar 22
11:20:53 2019 +0100
+++ b/tryton/gui/window/view_form/view/form_gtk/dictionary.py Fri Mar 22
11:26:31 2019 +0100
@@ -327,13 +327,12 @@
else:
self.wid_completion = None
- self.but_add = Gtk.Button()
+ self.but_add = Gtk.Button(can_focus=False)
self.but_add.connect('clicked', self._sig_add)
self.but_add.add(
IconFactory.get_image('tryton-add', Gtk.IconSize.SMALL_TOOLBAR))
self.but_add.set_relief(Gtk.ReliefStyle.NONE)
hbox.pack_start(self.but_add, expand=False, fill=False, padding=0)
- hbox.set_focus_chain([self.wid_text])
vbox.pack_start(hbox, expand=True, fill=True, padding=0)
self.tooltips = Tooltips()
diff -r 841e8f907d37 -r 13836047b0ac
tryton/gui/window/view_form/view/form_gtk/many2many.py
--- a/tryton/gui/window/view_form/view/form_gtk/many2many.py Fri Mar 22
11:20:53 2019 +0100
+++ b/tryton/gui/window/view_form/view/form_gtk/many2many.py Fri Mar 22
11:26:31 2019 +0100
@@ -63,7 +63,7 @@
else:
self.wid_completion = None
- self.but_add = Gtk.Button()
+ self.but_add = Gtk.Button(can_focus=False)
tooltips.set_tip(self.but_add, _('Add existing record'))
self.but_add.connect('clicked', self._sig_add)
self.but_add.add(common.IconFactory.get_image(
@@ -71,7 +71,7 @@
self.but_add.set_relief(Gtk.ReliefStyle.NONE)
hbox.pack_start(self.but_add, expand=False, fill=False, padding=0)
- self.but_remove = Gtk.Button()
+ self.but_remove = Gtk.Button(can_focus=False)
tooltips.set_tip(self.but_remove, _('Remove selected record <Del>'))
self.but_remove.connect('clicked', self._sig_remove)
self.but_remove.add(common.IconFactory.get_image(
@@ -79,8 +79,6 @@
self.but_remove.set_relief(Gtk.ReliefStyle.NONE)
hbox.pack_start(self.but_remove, expand=False, fill=False, padding=0)
- hbox.set_focus_chain([self.wid_text])
-
tooltips.enable()
frame = Gtk.Frame()
diff -r 841e8f907d37 -r 13836047b0ac
tryton/gui/window/view_form/view/form_gtk/many2one.py
--- a/tryton/gui/window/view_form/view/form_gtk/many2one.py Fri Mar 22
11:20:53 2019 +0100
+++ b/tryton/gui/window/view_form/view/form_gtk/many2one.py Fri Mar 22
11:26:31 2019 +0100
@@ -13,7 +13,6 @@
from tryton.common.completion import get_completion, update_completion
from tryton.common.entry_position import reset_position
from tryton.common.domain_parser import quote
-from tryton.config import CONFIG
_ = gettext.gettext
@@ -54,10 +53,6 @@
def _readonly_set(self, value):
self._readonly = value
self._set_button_sensitive()
- if value and CONFIG['client.fast_tabbing']:
- self.widget.set_focus_chain([])
- else:
- self.widget.unset_focus_chain()
def _set_button_sensitive(self):
self.wid_text.set_editable(not self._readonly)
diff -r 841e8f907d37 -r 13836047b0ac
tryton/gui/window/view_form/view/form_gtk/one2many.py
--- a/tryton/gui/window/view_form/view/form_gtk/one2many.py Fri Mar 22
11:20:53 2019 +0100
+++ b/tryton/gui/window/view_form/view/form_gtk/one2many.py Fri Mar 22
11:26:31 2019 +0100
@@ -45,7 +45,7 @@
tooltips = common.Tooltips()
- but_switch = Gtk.Button()
+ but_switch = Gtk.Button(can_focus=False)
tooltips.set_tip(but_switch, _('Switch <F4>'))
but_switch.connect('clicked', self.switch_view)
but_switch.add(common.IconFactory.get_image(
@@ -53,7 +53,7 @@
but_switch.set_relief(Gtk.ReliefStyle.NONE)
hbox.pack_start(but_switch, expand=False, fill=False, padding=0)
- self.but_pre = Gtk.Button()
+ self.but_pre = Gtk.Button(can_focus=False)
tooltips.set_tip(self.but_pre, _('Previous'))
self.but_pre.connect('clicked', self._sig_previous)
self.but_pre.add(common.IconFactory.get_image(
@@ -64,7 +64,7 @@
self.label = Gtk.Label(label='(0,0)')
hbox.pack_start(self.label, expand=False, fill=False, padding=0)
- self.but_next = Gtk.Button()
+ self.but_next = Gtk.Button(can_focus=False)
tooltips.set_tip(self.but_next, _('Next'))
self.but_next.connect('clicked', self._sig_next)
self.but_next.add(common.IconFactory.get_image(
@@ -96,7 +96,7 @@
self.wid_text.set_completion(self.wid_completion)
self.wid_text.connect('changed', self._update_completion)
- self.but_add = Gtk.Button()
+ self.but_add = Gtk.Button(can_focus=False)
tooltips.set_tip(self.but_add, _('Add existing record'))
self.but_add.connect('clicked', self._sig_add)
self.but_add.add(common.IconFactory.get_image(
@@ -104,7 +104,7 @@
self.but_add.set_relief(Gtk.ReliefStyle.NONE)
hbox.pack_start(self.but_add, expand=False, fill=False, padding=0)
- self.but_remove = Gtk.Button()
+ self.but_remove = Gtk.Button(can_focus=False)
tooltips.set_tip(self.but_remove,
_('Remove selected record <CTRL> + <Del>'))
self.but_remove.connect('clicked', self._sig_remove, True)
@@ -117,7 +117,7 @@
hbox.pack_start(
Gtk.VSeparator(), expand=False, fill=True, padding=0)
- self.but_new = Gtk.Button()
+ self.but_new = Gtk.Button(can_focus=False)
tooltips.set_tip(self.but_new, _('Create a new record'))
self.but_new.connect('clicked', self._sig_new)
self.but_new.add(common.IconFactory.get_image(
@@ -125,7 +125,7 @@
self.but_new.set_relief(Gtk.ReliefStyle.NONE)
hbox.pack_start(self.but_new, expand=False, fill=False, padding=0)
- self.but_open = Gtk.Button()
+ self.but_open = Gtk.Button(can_focus=False)
tooltips.set_tip(self.but_open, _('Edit selected record'))
self.but_open.connect('clicked', self._sig_edit)
self.but_open.add(common.IconFactory.get_image(
@@ -133,7 +133,7 @@
self.but_open.set_relief(Gtk.ReliefStyle.NONE)
hbox.pack_start(self.but_open, expand=False, fill=False, padding=0)
- self.but_del = Gtk.Button()
+ self.but_del = Gtk.Button(can_focus=False)
tooltips.set_tip(self.but_del, _('Delete selected record <Del>'))
self.but_del.connect('clicked', self._sig_remove, False)
self.but_del.add(common.IconFactory.get_image(
@@ -141,7 +141,7 @@
self.but_del.set_relief(Gtk.ReliefStyle.NONE)
hbox.pack_start(self.but_del, expand=False, fill=False, padding=0)
- self.but_undel = Gtk.Button()
+ self.but_undel = Gtk.Button(can_focus=False)
tooltips.set_tip(self.but_undel, _('Undelete selected record <Ins>'))
self.but_undel.connect('clicked', self._sig_undelete)
self.but_undel.add(common.IconFactory.get_image(
@@ -149,11 +149,6 @@
self.but_undel.set_relief(Gtk.ReliefStyle.NONE)
hbox.pack_start(self.but_undel, expand=False, fill=False, padding=0)
- if attrs.get('add_remove'):
- hbox.set_focus_chain([self.wid_text])
- else:
- hbox.set_focus_chain([])
-
tooltips.enable()
frame = Gtk.Frame()
@@ -309,17 +304,6 @@
self.wid_text.set_sensitive(self.but_add.get_sensitive())
self.wid_text.set_editable(self.but_add.get_sensitive())
- # New button must be added to focus chain to allow keyboard only
- # creation when there is no existing record on form view.
- focus_chain = self.title_box.get_focus_chain() or []
- if o2m_size == 0 and self.screen.current_view.view_type == 'form':
- if self.but_new not in focus_chain:
- focus_chain.append(self.but_new)
- else:
- if self.but_new in focus_chain:
- focus_chain.remove(self.but_new)
- self.title_box.set_focus_chain(focus_chain)
-
def _validate(self):
self.view.set_value()
record = self.screen.current_record
diff -r 841e8f907d37 -r 13836047b0ac
tryton/gui/window/view_form/view/form_gtk/reference.py
--- a/tryton/gui/window/view_form/view/form_gtk/reference.py Fri Mar 22
11:20:53 2019 +0100
+++ b/tryton/gui/window/view_form/view/form_gtk/reference.py Fri Mar 22
11:26:31 2019 +0100
@@ -7,7 +7,6 @@
from .many2one import Many2One
from tryton.common.selection import SelectionMixin, PopdownMixin, \
selection_shortcuts
-from tryton.config import CONFIG
_ = gettext.gettext
@@ -28,7 +27,6 @@
'scroll-event',
lambda c, e: c.stop_emission_by_name('scroll-event'))
selection_shortcuts(self.widget_combo)
- self.widget_combo.set_focus_chain([child])
self.widget.pack_start(
self.widget_combo, expand=False, fill=True, padding=0)
@@ -36,8 +34,6 @@
self.init_selection()
self.set_popdown(self.selection, self.widget_combo)
- self.widget.set_focus_chain([self.widget_combo, self.wid_text])
-
def get_model(self):
active = self.widget_combo.get_active()
if active < 0:
@@ -62,10 +58,6 @@
self.widget_combo.set_button_sensitivity(
Gtk.SensitivityType.OFF if self._readonly
else Gtk.SensitivityType.AUTO)
- if self._readonly and CONFIG['client.fast_tabbing']:
- self.widget.set_focus_chain([])
- else:
- self.widget.unset_focus_chain()
@property
def modified(self):
diff -r 841e8f907d37 -r 13836047b0ac
tryton/gui/window/view_form/view/form_gtk/selection.py
--- a/tryton/gui/window/view_form/view/form_gtk/selection.py Fri Mar 22
11:20:53 2019 +0100
+++ b/tryton/gui/window/view_form/view/form_gtk/selection.py Fri Mar 22
11:26:31 2019 +0100
@@ -5,7 +5,6 @@
from .widget import Widget
from tryton.common.selection import SelectionMixin, selection_shortcuts, \
PopdownMixin
-from tryton.config import CONFIG
class Selection(Widget, SelectionMixin, PopdownMixin):
@@ -29,7 +28,6 @@
'scroll-event',
lambda c, e: c.stop_emission_by_name('scroll-event'))
self.widget.pack_start(self.entry, expand=True, fill=True, padding=0)
- self.widget.set_focus_chain([child])
self.selection = attrs.get('selection', [])[:]
self.attrs = attrs
@@ -52,10 +50,6 @@
self.entry.get_child().set_editable(not value)
self.entry.set_button_sensitivity(
Gtk.SensitivityType.OFF if value else Gtk.SensitivityType.AUTO)
- if value and CONFIG['client.fast_tabbing']:
- self.widget.set_focus_chain([])
- else:
- self.widget.unset_focus_chain()
def get_value(self):
if not self.entry.get_child(): # entry is destroyed
diff -r 841e8f907d37 -r 13836047b0ac
tryton/gui/window/view_form/view/form_gtk/textbox.py
--- a/tryton/gui/window/view_form/view/form_gtk/textbox.py Fri Mar 22
11:20:53 2019 +0100
+++ b/tryton/gui/window/view_form/view/form_gtk/textbox.py Fri Mar 22
11:26:31 2019 +0100
@@ -87,10 +87,6 @@
self.textview.set_editable(not value)
if self.button:
self.button.set_sensitive(not value)
- if value and CONFIG['client.fast_tabbing']:
- self.widget.set_focus_chain([])
- else:
- self.widget.unset_focus_chain()
@property
def modified(self):
diff -r 841e8f907d37 -r 13836047b0ac
tryton/gui/window/view_form/view/form_gtk/timedelta.py
--- a/tryton/gui/window/view_form/view/form_gtk/timedelta.py Fri Mar 22
11:20:53 2019 +0100
+++ b/tryton/gui/window/view_form/view/form_gtk/timedelta.py Fri Mar 22
11:26:31 2019 +0100
@@ -2,7 +2,6 @@
# this repository contains the full copyright notices and license terms.
from gi.repository import Gtk
-from tryton.config import CONFIG
from tryton.common.entry_position import reset_position
from .widget import Widget
@@ -48,7 +47,3 @@
def _readonly_set(self, value):
super(TimeDelta, self)._readonly_set(value)
self.entry.set_editable(not value)
- if value and CONFIG['client.fast_tabbing']:
- self.widget.set_focus_chain([])
- else:
- self.widget.unset_focus_chain()
diff -r 841e8f907d37 -r 13836047b0ac
tryton/gui/window/view_form/view/form_gtk/url.py
--- a/tryton/gui/window/view_form/view/form_gtk/url.py Fri Mar 22 11:20:53
2019 +0100
+++ b/tryton/gui/window/view_form/view/form_gtk/url.py Fri Mar 22 11:26:31
2019 +0100
@@ -6,7 +6,6 @@
from .char import Char
import tryton.common as common
-from tryton.config import CONFIG
class URL(Char):
@@ -23,7 +22,6 @@
self.button.connect('clicked', self.button_clicked)
self.widget.pack_start(
self.button, expand=False, fill=False, padding=0)
- self.widget.set_focus_chain([self.entry])
def display(self):
super(URL, self).display()
@@ -53,10 +51,6 @@
self.entry.hide()
else:
self.entry.show()
- if value and CONFIG['client.fast_tabbing']:
- self.widget.set_focus_chain([self.button])
- else:
- self.widget.set_focus_chain([self.entry])
self.button.set_sensitive(True)
def button_clicked(self, widget):
diff -r 841e8f907d37 -r 13836047b0ac
tryton/gui/window/view_form/view/screen_container.py
--- a/tryton/gui/window/view_form/view/screen_container.py Fri Mar 22
11:20:53 2019 +0100
+++ b/tryton/gui/window/view_form/view/screen_container.py Fri Mar 22
11:26:31 2019 +0100
@@ -299,7 +299,6 @@
hbox.pack_start(but_next, expand=False, fill=False, padding=0)
hbox.show_all()
- hbox.set_focus_chain([self.search_entry])
self.filter_vbox.pack_start(hbox, expand=False, fill=False, padding=0)
hseparator = Gtk.HSeparator()