Reviewers: ,
Please review this at http://codereview.tryton.org/836002/ Affected files: M tryton/common/cellrenderercombo.py M tryton/common/selection.py M tryton/gui/window/view_form/view/form_gtk/dictionary.py M tryton/gui/window/view_form/view/form_gtk/selection.py Index: tryton/common/cellrenderercombo.py =================================================================== --- a/tryton/common/cellrenderercombo.py +++ b/tryton/common/cellrenderercombo.py @@ -4,6 +4,8 @@ import gobject import pango +from tryton.common.selection import selection_shortcuts + class CellRendererCombo(gtk.GenericCellRenderer): __gproperties__ = { @@ -113,6 +115,6 @@ style.text[gtk.STATE_NORMAL]) editable.modify_text(gtk.STATE_INSENSITIVE, style.text[gtk.STATE_INSENSITIVE]) - return editable + return selection_shortcuts(editable) gobject.type_register(CellRendererCombo) Index: tryton/common/selection.py =================================================================== --- a/tryton/common/selection.py +++ b/tryton/common/selection.py @@ -1,6 +1,7 @@ #This file is part of Tryton. The COPYRIGHT file at the top level of #this repository contains the full copyright notices and license terms. import operator +import gtk from tryton.common import RPCExecute, RPCException @@ -70,3 +71,13 @@ selection = [] self._last_domain = None self.selection = selection[:] + + +def selection_shortcuts(entry): + def key_press(widget, event): + if (event.type == gtk.gdk.KEY_PRESS + and event.state & gtk.gdk.CONTROL_MASK + and event.keyval == gtk.keysyms.space): + widget.popup() + entry.connect('key_press_event', key_press) + return entry Index: tryton/gui/window/view_form/view/form_gtk/dictionary.py =================================================================== --- a/tryton/gui/window/view_form/view/form_gtk/dictionary.py +++ b/tryton/gui/window/view_form/view/form_gtk/dictionary.py @@ -16,6 +16,7 @@ datetime_strftime, Tooltips from tryton.common.date_widget import DateEntry from tryton.common.placeholder_entry import PlaceholderEntry +from tryton.common.selection import selection_shortcuts from tryton.translate import date_format _ = gettext.gettext @@ -86,7 +87,7 @@ lambda w: self.parent_widget._focus_out()) widget.connect('notify::active', lambda w, e: self.parent_widget._focus_out()) - widget.child.connect('key_press_event', self.sig_key_press) + selection_shortcuts(widget) # setting completion and selection model = gtk.ListStore(gobject.TYPE_STRING) @@ -130,12 +131,6 @@ def set_readonly(self, readonly): self.widget.set_sensitive(not readonly) - def sig_key_press(self, widget, event): - if (event.type == gtk.gdk.KEY_PRESS - and event.state & gtk.gdk.CONTROL_MASK - and event.keyval == gtk.keysyms.space): - self.widget.popup() - class DictIntegerEntry(DictEntry): expand = False Index: tryton/gui/window/view_form/view/form_gtk/selection.py =================================================================== --- a/tryton/gui/window/view_form/view/form_gtk/selection.py +++ b/tryton/gui/window/view_form/view/form_gtk/selection.py @@ -4,7 +4,7 @@ import gobject import math from interface import WidgetInterface -from tryton.common.selection import SelectionMixin +from tryton.common.selection import SelectionMixin, selection_shortcuts class PopdownMixin(object): @@ -60,6 +60,7 @@ child.set_max_length(int(attrs.get('size', 0))) child.set_width_chars(10) + selection_shortcuts(self.entry) child.connect('key_press_event', self.sig_key_press) child.connect('activate', self.sig_activate) child.connect_after('focus-out-event', self.sig_activate) @@ -98,10 +99,6 @@ return value def sig_key_press(self, widget, event): - if event.type == gtk.gdk.KEY_PRESS \ - and event.state & gtk.gdk.CONTROL_MASK \ - and event.keyval == gtk.keysyms.space: - self.entry.popup() self.send_modified() def sig_activate(self, widget, event=None):
