Deactivate switch view button when there is only 1 view

review400002
This commit is contained in:
Cédric Krier committed 2012-06-28 14:58:16 +02:00
1 parent 3022d432d4
commit d9bfcada63
5 files changed
+13 -2

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
* Deactivate switch view button when there is only 1 view
* Manage create/delete field access
* Add dynamic size limit on the One2Many, Many2Many and Char
* Search only on fields in XML view
+3 -1
View File
@@ -468,11 +468,13 @@ class Form(SignalEvent, TabContent):
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]:
+5 -1
View File
@@ -306,6 +306,10 @@ class Screen(SignalEvent):
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 @@ class Screen(SignalEvent):
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
@@ -170,6 +170,8 @@ class One2Many(WidgetInterface):
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
+2
View File
@@ -233,6 +233,8 @@ class WinForm(NoModal):
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)