Add CTRL+Space shortcut to selection widget in tree view
Factorise selection shortcuts over all widgets. review836002
This commit is contained in:
1 parent
66ad5d169d
commit
4170da49bc
4 files changed
+18
-13
No files matched your search
@@ -4,6 +4,8 @@ import gtk
|
||||
import gobject
|
||||
import pango
|
||||
|
||||
from tryton.common.selection import selection_shortcuts
|
||||
|
||||
|
||||
class CellRendererCombo(gtk.GenericCellRenderer):
|
||||
__gproperties__ = {
|
||||
@@ -113,6 +115,6 @@ class CellRendererCombo(gtk.GenericCellRenderer):
|
||||
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)
|
||||
@@ -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 @@ class SelectionMixin(object):
|
||||
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
|
||||
@@ -16,6 +16,7 @@ from tryton.common import RPCExecute, RPCException, timezoned_date, \
|
||||
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 @@ class DictSelectionEntry(DictEntry):
|
||||
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 @@ class DictSelectionEntry(DictEntry):
|
||||
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
|
||||
|
||||
@@ -4,7 +4,7 @@ import gtk
|
||||
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 @@ class Selection(WidgetInterface, SelectionMixin, PopdownMixin):
|
||||
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 @@ class Selection(WidgetInterface, SelectionMixin, PopdownMixin):
|
||||
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):
|
||||
|
||||
Reference in new issue
Block a user