diff --git a/tryton/gui/window/view_form/view/form_gtk/binary.py b/tryton/gui/window/view_form/view/form_gtk/binary.py index 118ba09570..a48543950a 100644 --- a/tryton/gui/window/view_form/view/form_gtk/binary.py +++ b/tryton/gui/window/view_form/view/form_gtk/binary.py @@ -57,9 +57,12 @@ class Binary(WidgetInterface): if value: self.but_new.hide() self.but_remove.hide() + self.widget.set_focus_chain([]) else: self.but_new.show() self.but_remove.show() + self.widget.set_focus_chain([self.but_new, self.but_save_as, + self.but_remove]) def grab_focus(self): return self.wid_text.grab_focus() diff --git a/tryton/gui/window/view_form/view/form_gtk/calendar.py b/tryton/gui/window/view_form/view/form_gtk/calendar.py index 5ab4260e2b..156bda5277 100644 --- a/tryton/gui/window/view_form/view/form_gtk/calendar.py +++ b/tryton/gui/window/view_form/view/form_gtk/calendar.py @@ -50,8 +50,11 @@ class Calendar(WidgetInterface): def _readonly_set(self, value): self.entry.set_editable(not value) - self.entry.set_sensitive(not value) self.but_open.set_sensitive(not value) + if value: + self.widget.set_focus_chain([]) + else: + self.widget.set_focus_chain([self.entry]) def sig_key_press(self, widget, event): if event.keyval == gtk.keysyms.F2: @@ -177,8 +180,11 @@ class DateTime(WidgetInterface): def _readonly_set(self, value): self.entry.set_editable(not value) - self.entry.set_sensitive(not value) self.but_open.set_sensitive(not value) + if value: + self.widget.set_focus_chain([]) + else: + self.widget.set_focus_chain([self.entry]) def sig_key_press(self, widget, event): if event.keyval == gtk.keysyms.F2: diff --git a/tryton/gui/window/view_form/view/form_gtk/char.py b/tryton/gui/window/view_form/view/form_gtk/char.py index d6d42babef..6c27487dba 100644 --- a/tryton/gui/window/view_form/view/form_gtk/char.py +++ b/tryton/gui/window/view_form/view/form_gtk/char.py @@ -41,7 +41,10 @@ class Char(WidgetInterface): def _readonly_set(self, value): super(Char, self)._readonly_set(value) self.entry.set_editable(not value) - self.entry.set_sensitive(not value) + if value: + self.widget.set_focus_chain([]) + else: + self.widget.set_focus_chain([self.entry]) class Sha(Char): diff --git a/tryton/gui/window/view_form/view/form_gtk/float_time.py b/tryton/gui/window/view_form/view/form_gtk/float_time.py index 34c237621c..dc25c8f2c2 100644 --- a/tryton/gui/window/view_form/view/form_gtk/float_time.py +++ b/tryton/gui/window/view_form/view/form_gtk/float_time.py @@ -11,14 +11,22 @@ class FloatTime(WidgetInterface): super(FloatTime, self).__init__(window, parent, model=model, attrs=attrs) - self.widget = gtk.Entry() - self.widget.set_alignment(1.0) - self.widget.set_property('activates_default', True) + self.widget = gtk.HBox() + self.entry = gtk.Entry() + self.entry.set_alignment(1.0) + self.entry.set_property('activates_default', True) - self.widget.connect('populate-popup', self._populate_popup) - self.widget.connect('activate', self.sig_activate) - self.widget.connect('focus-in-event', lambda x, y: self._focus_in()) - self.widget.connect('focus-out-event', lambda x, y: self._focus_out()) + self.entry.connect('populate-popup', self._populate_popup) + self.entry.connect('activate', self.sig_activate) + self.entry.connect('focus-in-event', lambda x, y: self._focus_in()) + self.entry.connect('focus-out-event', lambda x, y: self._focus_out()) + self.widget.pack_start(self.entry) + + def _color_widget(self): + return self.entry + + def grab_focus(self): + return self.entry.grab_focus() def text_to_float(self, text): try: @@ -35,7 +43,7 @@ class FloatTime(WidgetInterface): return 0.0 def set_value(self, model, model_field): - value = self.widget.get_text() + value = self.entry.get_text() if not value: return model_field.set_client(model, 0.0) return model_field.set_client(model, self.text_to_float(value)) @@ -43,15 +51,19 @@ class FloatTime(WidgetInterface): def display(self, model, model_field): super(FloatTime, self).display(model, model_field) if not model_field: - self.widget.set_text('00:00') + self.entry.set_text('00:00') return False val = model_field.get(model) value = '%02d:%02d' % (math.floor(abs(val)), round(abs(val)%1+0.01, 2) * 60) if val < 0: value = '-' + value - self.widget.set_text(value) + self.entry.set_text(value) def _readonly_set(self, value): - self.widget.set_editable(not value) - self.widget.set_sensitive(not value) + super(FloatTime, self)._readonly_set(value) + self.entry.set_editable(not value) + if value: + self.widget.set_focus_chain([]) + else: + self.widget.set_focus_chain([self.entry]) diff --git a/tryton/gui/window/view_form/view/form_gtk/many2one.py b/tryton/gui/window/view_form/view/form_gtk/many2one.py index bbe4c3aafd..ec9716efff 100644 --- a/tryton/gui/window/view_form/view/form_gtk/many2one.py +++ b/tryton/gui/window/view_form/view/form_gtk/many2one.py @@ -279,6 +279,10 @@ class Many2One(WidgetInterface): self._readonly = value self.wid_text.set_editable(not value) self.but_new.set_sensitive(not value) + if value: + self.widget.set_focus_chain([]) + else: + self.widget.set_focus_chain([self.wid_text]) def _color_widget(self): return self.wid_text diff --git a/tryton/gui/window/view_form/view/form_gtk/reference.py b/tryton/gui/window/view_form/view/form_gtk/reference.py index a96aa43bdc..7d2914fba2 100644 --- a/tryton/gui/window/view_form/view/form_gtk/reference.py +++ b/tryton/gui/window/view_form/view/form_gtk/reference.py @@ -119,8 +119,11 @@ class Reference(WidgetInterface): self._readonly = value self.widget_combo.set_sensitive(not value) self.wid_text.set_editable(not value) - self.wid_text.set_sensitive(not value) self.but_new.set_sensitive(not value) + if value: + self.widget.set_focus_chain([]) + else: + self.widget.set_focus_chain([self.widget_combo, self.wid_text]) def _color_widget(self): return self.wid_text diff --git a/tryton/gui/window/view_form/view/form_gtk/textbox.py b/tryton/gui/window/view_form/view/form_gtk/textbox.py index 3bbd63202e..e2149edaa3 100644 --- a/tryton/gui/window/view_form/view/form_gtk/textbox.py +++ b/tryton/gui/window/view_form/view/form_gtk/textbox.py @@ -41,7 +41,10 @@ class TextBox(WidgetInterface): def _readonly_set(self, value): super(TextBox, self)._readonly_set(value) self.textview.set_editable(not value) - self.textview.set_sensitive(not value) + if value: + self.widget.set_focus_chain([]) + else: + self.widget.set_focus_chain([self.textview]) if HAS_GTKSPELL: spell = None try: