Reviewers: ,
Please review this at http://codereview.tryton.org/400002/
Affected files:
M tryton/gui/window/form.py
M tryton/gui/window/view_form/screen/screen.py
M tryton/gui/window/view_form/view/form_gtk/one2many.py
M tryton/gui/window/win_form.py
Index: tryton/gui/window/form.py
===================================================================
--- a/tryton/gui/window/form.py
+++ b/tryton/gui/window/form.py
@@ -468,11 +468,13 @@
if signal_data[0]:
name = str(signal_data[0])
for button_id in
('print', 'action', 'relate', 'email', 'open', 'save',
- 'switch', 'attach'):
+ 'attach'):
button = self.buttons[button_id]
can_be_sensitive = getattr(button, '_can_be_sensitive', True)
button.props.sensitive = (bool(signal_data[0])
and can_be_sensitive)
+ button_switch = self.buttons['switch']
+ button_switch.props.sensitive = self.screen.number_of_views > 1
msg = name + ' / ' + str(signal_data[1])
if signal_data[1] < signal_data[2]:
Index: tryton/gui/window/view_form/screen/screen.py
===================================================================
--- a/tryton/gui/window/view_form/screen/screen.py
+++ b/tryton/gui/window/view_form/screen/screen.py
@@ -306,6 +306,10 @@
self.switch_view(view_type='form')
return True
+ @property
+ def number_of_views(self):
+ return len(self.views) + len(self.view_to_load)
+
def switch_view(self, view_type=None, default=True, context=None):
if not self.parent and self.modified():
return
@@ -320,7 +324,7 @@
self.current_view.display()
return
if not view_type or self.current_view.view_type != view_type:
- for i in xrange(len(self.views) + len(self.view_to_load)):
+ for i in xrange(self.number_of_views):
if len(self.view_to_load):
self.load_view_to_load()
self.__current_view = len(self.views) - 1
Index: tryton/gui/window/view_form/view/form_gtk/one2many.py
===================================================================
--- a/tryton/gui/window/view_form/view/form_gtk/one2many.py
+++ b/tryton/gui/window/view_form/view/form_gtk/one2many.py
@@ -169,6 +169,8 @@
if self.attrs.get('add_remove'):
self.wid_text.connect('key_press_event', self.on_keypress)
+ but_switch.props.sensitive = self.screen.number_of_views > 1
+
def _color_widget(self):
if hasattr(self.screen.current_view, 'widget_tree'):
return self.screen.current_view.widget_tree
Index: tryton/gui/window/win_form.py
===================================================================
--- a/tryton/gui/window/win_form.py
+++ b/tryton/gui/window/win_form.py
@@ -232,6 +232,8 @@
but_switch.set_relief(gtk.RELIEF_NONE)
hbox.pack_start(but_switch, expand=False, fill=False)
+ but_switch.props.sensitive = screen.number_of_views > 1
+
tooltips.enable()
alignment = gtk.Alignment(1.0)
--
[email protected] mailing list