diff --git a/tryton/gui/window/view_form/view/form.py b/tryton/gui/window/view_form/view/form.py index af75da275d..c4ce32a09c 100644 --- a/tryton/gui/window/view_form/view/form.py +++ b/tryton/gui/window/view_form/view/form.py @@ -23,6 +23,7 @@ class ViewForm(ParserView): for button in self.buttons: if isinstance(button, gtk.Button): button.connect('clicked', self.button_clicked) + button.set_focus_on_click(False) # Force to display the first time it switches on a page # This avoids glitch in position of widgets @@ -43,6 +44,7 @@ class ViewForm(ParserView): vbox = gtk.VBox() vp = gtk.Viewport() vp.set_shadow_type(gtk.SHADOW_NONE) + vp.connect('leave-notify-event', self.leave) vp.add(self.widget) scroll = gtk.ScrolledWindow() scroll.add(vp) @@ -165,6 +167,9 @@ class ViewForm(ParserView): notebook.set_current_page(i) focus_widget.grab_focus() + def leave(self, widget, event): + self.set_value() + def button_clicked(self, widget): record_id = self.screen.save_current() record = self.screen.current_record 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 ae6f24c6ca..34c0b3a260 100644 --- a/tryton/gui/window/view_form/view/form_gtk/binary.py +++ b/tryton/gui/window/view_form/view/form_gtk/binary.py @@ -46,6 +46,7 @@ class Binary(WidgetInterface): self.but_new.set_image(img_new) self.but_new.set_relief(gtk.RELIEF_NONE) self.but_new.connect('clicked', self.sig_new) + self.but_new.connect('enter-notify-event', self.enter) self.tooltips.set_tip(self.but_new, _('Select a File...')) self.widget.pack_start(self.but_new, expand=False, fill=False) @@ -56,6 +57,7 @@ class Binary(WidgetInterface): self.but_open.set_image(img_open) self.but_open.set_relief(gtk.RELIEF_NONE) self.but_open.connect('clicked', self.sig_open) + self.but_open.connect('enter-notify-event', self.enter) self.tooltips.set_tip(self.but_open, _('Open...')) self.widget.pack_start(self.but_open, expand=False, fill=False) else: @@ -68,6 +70,7 @@ class Binary(WidgetInterface): self.but_save_as.set_image(img_save_as) self.but_save_as.set_relief(gtk.RELIEF_NONE) self.but_save_as.connect('clicked', self.sig_save_as) + self.but_save_as.connect('enter-notify-event', self.enter) self.tooltips.set_tip(self.but_save_as, _('Save As...')) self.widget.pack_start(self.but_save_as, expand=False, fill=False) @@ -77,6 +80,7 @@ class Binary(WidgetInterface): self.but_remove.set_image(img_remove) self.but_remove.set_relief(gtk.RELIEF_NONE) self.but_remove.connect('clicked', self.sig_remove) + self.but_remove.connect('enter-notify-event', self.enter) self.tooltips.set_tip(self.but_remove, _('Clear')) self.widget.pack_start(self.but_remove, expand=False, fill=False) diff --git a/tryton/gui/window/view_form/view/form_gtk/image.py b/tryton/gui/window/view_form/view/form_gtk/image.py index dc30c039b9..7c1f8a2053 100644 --- a/tryton/gui/window/view_form/view/form_gtk/image.py +++ b/tryton/gui/window/view_form/view/form_gtk/image.py @@ -48,6 +48,7 @@ class Image(WidgetInterface): self.but_add.set_image(img_add) self.but_add.set_relief(gtk.RELIEF_NONE) self.but_add.connect('clicked', self.sig_add) + self.but_add.connect('enter-notify-event', self.enter) self.tooltips.set_tip(self.but_add, _('Select an Image...')) hbox.pack_start(self.but_add, expand=False, fill=False) @@ -59,6 +60,7 @@ class Image(WidgetInterface): self.but_open.set_image(img_open) self.but_open.set_relief(gtk.RELIEF_NONE) self.but_open.connect('clicked', self.sig_open) + self.but_open.connect('enter-notify-event', self.enter) self.tooltips.set_tip(self.but_open, _('Open...')) hbox.pack_start(self.but_open, expand=False, fill=False) else: @@ -71,6 +73,7 @@ class Image(WidgetInterface): self.but_save_as.set_image(img_save_as) self.but_save_as.set_relief(gtk.RELIEF_NONE) self.but_save_as.connect('clicked', self.sig_save_as) + self.but_save_as.connect('enter-notify-event', self.enter) self.tooltips.set_tip(self.but_save_as, _('Save As...')) hbox.pack_start(self.but_save_as, expand=False, fill=False) @@ -81,6 +84,7 @@ class Image(WidgetInterface): self.but_remove.set_image(img_remove) self.but_remove.set_relief(gtk.RELIEF_NONE) self.but_remove.connect('clicked', self.sig_remove) + self.but_remove.connect('enter-notify-event', self.enter) self.tooltips.set_tip(self.but_remove, _('Clear')) hbox.pack_start(self.but_remove, expand=False, fill=False) diff --git a/tryton/gui/window/view_form/view/form_gtk/interface.py b/tryton/gui/window/view_form/view/form_gtk/interface.py index 33f1fae91d..b669d82d5a 100644 --- a/tryton/gui/window/view_form/view/form_gtk/interface.py +++ b/tryton/gui/window/view_form/view/form_gtk/interface.py @@ -164,6 +164,10 @@ class WidgetInterface(object): def cancel(self): pass + def enter(self, widget, event): + if self.view: + self.view.set_value() + class TranslateDialog(NoModal): @@ -295,6 +299,7 @@ class TranslateMixin: button.set_image(img) button.set_relief(gtk.RELIEF_NONE) button.connect('clicked', self.translate) + button.connect('enter-notify-event', self.enter) return button def translate(self, widget): diff --git a/tryton/gui/window/view_form/view/form_gtk/many2many.py b/tryton/gui/window/view_form/view/form_gtk/many2many.py index 7e860d8422..ff23133111 100644 --- a/tryton/gui/window/view_form/view/form_gtk/many2many.py +++ b/tryton/gui/window/view_form/view/form_gtk/many2many.py @@ -43,6 +43,7 @@ class Many2Many(WidgetInterface): self.but_add = gtk.Button() tooltips.set_tip(self.but_add, _('Add')) self.but_add.connect('clicked', self._sig_add) + self.but_add.connect('enter-notify-event', self.enter) img_add = gtk.Image() img_add.set_from_stock('tryton-list-add', gtk.ICON_SIZE_SMALL_TOOLBAR) @@ -54,6 +55,7 @@ class Many2Many(WidgetInterface): self.but_remove = gtk.Button() tooltips.set_tip(self.but_remove, _('Remove ')) self.but_remove.connect('clicked', self._sig_remove) + self.but_remove.connect('enter-notify-event', self.enter) img_remove = gtk.Image() img_remove.set_from_stock('tryton-list-remove', gtk.ICON_SIZE_SMALL_TOOLBAR) 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 9f4099379c..46679a60d9 100644 --- a/tryton/gui/window/view_form/view/form_gtk/many2one.py +++ b/tryton/gui/window/view_form/view/form_gtk/many2one.py @@ -44,6 +44,7 @@ class Many2One(WidgetInterface): self.but_open.set_image(img_find) self.but_open.set_relief(gtk.RELIEF_NONE) self.but_open.connect('clicked', self.sig_edit) + self.but_open.connect('enter-notify-event', self.enter) self.but_open.set_alignment(0.5, 0.5) self.but_new = gtk.Button() @@ -52,6 +53,7 @@ class Many2One(WidgetInterface): self.but_new.set_image(img_new) self.but_new.set_relief(gtk.RELIEF_NONE) self.but_new.connect('clicked', self.sig_new) + self.but_new.connect('enter-notify-event', self.enter) self.but_new.set_alignment(0.5, 0.5) self.widget.pack_end(self.but_new, expand=False, fill=False) diff --git a/tryton/gui/window/view_form/view/form_gtk/one2many.py b/tryton/gui/window/view_form/view/form_gtk/one2many.py index 9ebc7930aa..86d79bb12d 100644 --- a/tryton/gui/window/view_form/view/form_gtk/one2many.py +++ b/tryton/gui/window/view_form/view/form_gtk/one2many.py @@ -46,6 +46,7 @@ class One2Many(WidgetInterface): self.but_add = gtk.Button() tooltips.set_tip(self.but_add, _('Add')) self.but_add.connect('clicked', self._sig_add) + self.but_add.connect('enter-notify-event', self.enter) img_add = gtk.Image() img_add.set_from_stock('tryton-list-add', gtk.ICON_SIZE_SMALL_TOOLBAR) @@ -57,6 +58,7 @@ class One2Many(WidgetInterface): self.but_remove = gtk.Button() tooltips.set_tip(self.but_remove, _('Remove ')) self.but_remove.connect('clicked', self._sig_remove, True) + self.but_remove.connect('enter-notify-event', self.enter) img_remove = gtk.Image() img_remove.set_from_stock('tryton-list-remove', gtk.ICON_SIZE_SMALL_TOOLBAR) @@ -70,6 +72,7 @@ class One2Many(WidgetInterface): self.but_new = gtk.Button() tooltips.set_tip(self.but_new, _('Create a new record ')) self.but_new.connect('clicked', self._sig_new) + self.but_new.connect('enter-notify-event', self.enter) img_new = gtk.Image() img_new.set_from_stock('tryton-new', gtk.ICON_SIZE_SMALL_TOOLBAR) img_new.set_alignment(0.5, 0.5) @@ -80,6 +83,7 @@ class One2Many(WidgetInterface): self.but_open = gtk.Button() tooltips.set_tip(self.but_open, _('Edit selected record ')) self.but_open.connect('clicked', self._sig_edit) + self.but_open.connect('enter-notify-event', self.enter) img_open = gtk.Image() img_open.set_from_stock('tryton-open', gtk.ICON_SIZE_SMALL_TOOLBAR) img_open.set_alignment(0.5, 0.5) @@ -90,6 +94,7 @@ class One2Many(WidgetInterface): self.but_del = gtk.Button() tooltips.set_tip(self.but_del, _('Delete selected record ')) self.but_del.connect('clicked', self._sig_remove, False) + self.but_del.connect('enter-notify-event', self.enter) img_del = gtk.Image() img_del.set_from_stock('tryton-delete', gtk.ICON_SIZE_SMALL_TOOLBAR) img_del.set_alignment(0.5, 0.5) @@ -100,6 +105,7 @@ class One2Many(WidgetInterface): self.but_undel = gtk.Button() tooltips.set_tip(self.but_undel, _('Undelete selected record ')) self.but_undel.connect('clicked', self._sig_undelete) + self.but_undel.connect('enter-notify-event', self.enter) img_undel = gtk.Image() img_undel.set_from_stock('tryton-undo', gtk.ICON_SIZE_SMALL_TOOLBAR) img_undel.set_alignment(0.5, 0.5) @@ -112,6 +118,7 @@ class One2Many(WidgetInterface): self.but_pre = gtk.Button() tooltips.set_tip(self.but_pre, _('Previous')) self.but_pre.connect('clicked', self._sig_previous) + self.but_pre.connect('enter-notify-event', self.enter) img_pre = gtk.Image() img_pre.set_from_stock('tryton-go-previous', gtk.ICON_SIZE_SMALL_TOOLBAR) @@ -126,6 +133,7 @@ class One2Many(WidgetInterface): self.but_next = gtk.Button() tooltips.set_tip(self.but_next, _('Next')) self.but_next.connect('clicked', self._sig_next) + self.but_next.connect('enter-notify-event', self.enter) img_next = gtk.Image() img_next.set_from_stock('tryton-go-next', gtk.ICON_SIZE_SMALL_TOOLBAR) img_next.set_alignment(0.5, 0.5) @@ -138,6 +146,7 @@ class One2Many(WidgetInterface): but_switch = gtk.Button() tooltips.set_tip(but_switch, _('Switch')) but_switch.connect('clicked', self.switch_view) + but_switch.connect('enter-notify-event', self.enter) img_switch = gtk.Image() img_switch.set_from_stock('tryton-fullscreen', gtk.ICON_SIZE_SMALL_TOOLBAR) diff --git a/tryton/gui/window/view_form/view/form_gtk/richtextbox.py b/tryton/gui/window/view_form/view/form_gtk/richtextbox.py index 8325f6a5dd..d5b8506757 100644 --- a/tryton/gui/window/view_form/view/form_gtk/richtextbox.py +++ b/tryton/gui/window/view_form/view/form_gtk/richtextbox.py @@ -187,6 +187,7 @@ class RichTextBox(TextBox): self.tools['markup'].set_tooltip_text(_('Change the markup text view')) # Packing widgets tool_bar = gtk.Toolbar() + tool_bar.connect('enter-notify-event', self.enter) tool_bar.set_style(gtk.TOOLBAR_ICONS) for tag in tags: diff --git a/tryton/gui/window/view_form/view/form_gtk/selection.py b/tryton/gui/window/view_form/view/form_gtk/selection.py index 27dc2d4f2b..cd5720651c 100644 --- a/tryton/gui/window/view_form/view/form_gtk/selection.py +++ b/tryton/gui/window/view_form/view/form_gtk/selection.py @@ -14,6 +14,8 @@ class Selection(WidgetInterface): super(Selection, self).__init__(field_name, model_name, attrs=attrs) self.widget = gtk.HBox(spacing=3) + ev_box = gtk.EventBox() + ev_box.connect('enter-notify-event', self.enter) self.entry = gtk.ComboBoxEntry() child = self.entry.child child.set_property('activates_default', True) @@ -25,7 +27,8 @@ class Selection(WidgetInterface): child.connect_after('focus-out-event', self.sig_activate) child.connect('changed', self.send_modified) self.entry.connect('notify::active', lambda *a: self._focus_out()) - self.widget.pack_start(self.entry) + ev_box.add(self.entry) + self.widget.pack_start(ev_box) self.widget.set_focus_chain([child]) self._selection = {} diff --git a/tryton/gui/window/view_form/view/form_gtk/url.py b/tryton/gui/window/view_form/view/form_gtk/url.py index 4e4651a022..d28540618d 100644 --- a/tryton/gui/window/view_form/view/form_gtk/url.py +++ b/tryton/gui/window/view_form/view/form_gtk/url.py @@ -19,6 +19,7 @@ class URL(Char): self.button.set_image(img) self.button.set_relief(gtk.RELIEF_NONE) self.button.connect('clicked', self.button_clicked) + self.button.connect('enter-notify-event', self.enter) self.button.set_alignment(0.5, 0.5) self.widget.pack_start(self.button, expand=False, fill=False) self.widget.set_focus_chain([self.entry]) diff --git a/tryton/gui/window/win_form.py b/tryton/gui/window/win_form.py index 674e11d5ae..d78391245c 100644 --- a/tryton/gui/window/win_form.py +++ b/tryton/gui/window/win_form.py @@ -54,9 +54,11 @@ class WinForm(NoModal): icon_cancel = gtk.STOCK_CANCEL self.but_cancel = self.win.add_button(icon_cancel, gtk.RESPONSE_CANCEL) + self.but_cancel.set_focus_on_click(False) self.but_ok = self.win.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK) + self.but_ok.set_focus_on_click(False) if new and self.many: self.but_ok.add_accelerator('clicked', self.accel_group, gtk.keysyms.Return, @@ -65,6 +67,7 @@ class WinForm(NoModal): self.but_new = self.win.add_button(gtk.STOCK_NEW, gtk.RESPONSE_ACCEPT) + self.but_new.set_focus_on_click(False) self.but_new.add_accelerator('clicked', self.accel_group, gtk.keysyms.Return, gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE) @@ -376,6 +379,8 @@ class WinForm(NoModal): validate = False cancel_responses = (gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT) self.screen.current_view.set_value() + if not self.win.get_focus(): + return if (response_id not in cancel_responses and self.screen.current_record is not None): validate = self.screen.current_record.validate(