Show non editable widget as insensitive

Since changeset 37b76806c878, there is no visual hint for the editable property
of a widget. So we will change the normal fg/base/bg for their insensitive
values.

issue5855
review28741002
This commit is contained in:
Cédric Krier committed 2016-09-19 22:34:29 +02:00
1 parent 0c31ae95ea
commit fdce24fc3b
12 files changed
+37

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
* Show non editable widget as insensitive
* Move info-bar at the bottom
* Manage readonly on fields translation dialog
* Restore tab default order when no manual change
+15
View File
@@ -0,0 +1,15 @@
# 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 gtk
def set_widget_style(widget, editable):
style = widget.__class__().get_style()
if editable:
widget.modify_fg(gtk.STATE_NORMAL, style.fg[gtk.STATE_NORMAL])
widget.modify_base(gtk.STATE_NORMAL, style.base[gtk.STATE_NORMAL])
widget.modify_bg(gtk.STATE_NORMAL, style.bg[gtk.STATE_NORMAL])
else:
widget.modify_fg(gtk.STATE_NORMAL, style.fg[gtk.STATE_INSENSITIVE])
widget.modify_base(gtk.STATE_NORMAL, style.base[gtk.STATE_INSENSITIVE])
widget.modify_bg(gtk.STATE_NORMAL, style.bg[gtk.STATE_INSENSITIVE])
@@ -7,6 +7,7 @@ import tempfile
from tryton.common import common
from tryton.common import file_selection, Tooltips, file_open, slugify
from tryton.common.entry_position import reset_position
from tryton.common.widget_style import set_widget_style
from tryton.config import CONFIG
from .widget import Widget
@@ -169,6 +170,7 @@ class Binary(BinaryMixin, Widget):
self.but_clear.show()
if self.wid_text:
self.wid_text.set_editable(not value)
set_widget_style(self.wid_text, not value)
if value and CONFIG['client.fast_tabbing']:
self.widget.set_focus_chain([])
else:
@@ -8,6 +8,7 @@ import gobject
from .widget import Widget
from tryton.common.datetime_ import (Date as DateEntry, Time as TimeEntry,
DateTime as DateTimeEntry, add_operators)
from tryton.common.widget_style import set_widget_style
from tryton.config import CONFIG
_ = gettext.gettext
@@ -34,6 +35,7 @@ class Date(Widget):
def _set_editable(self, value):
self.entry.set_editable(value)
set_widget_style(self.entry, value)
self.entry.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, value)
def _readonly_set(self, value):
@@ -130,6 +132,7 @@ class DateTime(Date):
for child in self.entry.get_children():
if isinstance(child, gtk.Entry):
child.set_editable(value)
set_widget_style(child, value)
child.set_icon_sensitive(gtk.ENTRY_ICON_SECONDARY, value)
elif isinstance(child, gtk.ComboBoxEntry):
child.set_sensitive(value)
@@ -8,6 +8,7 @@ from .widget import Widget, TranslateMixin
from tryton.common import Tooltips
from tryton.common.entry_position import reset_position
from tryton.common.selection import PopdownMixin, selection_shortcuts
from tryton.common.widget_style import set_widget_style
from tryton.config import CONFIG
_ = gettext.gettext
@@ -141,6 +142,7 @@ class Char(Widget, TranslateMixin, PopdownMixin):
self.entry.set_button_sensitivity(sensitivity[value])
else:
self.entry.set_editable(not value)
set_widget_style(self.entry, not value)
if value and CONFIG['client.fast_tabbing']:
self.widget.set_focus_chain([])
else:
@@ -20,6 +20,7 @@ from tryton.common.completion import get_completion, update_completion
from tryton.common.datetime_ import Date, DateTime
from tryton.common.domain_parser import quote
from tryton.common.entry_position import reset_position
from tryton.common.widget_style import set_widget_style
_ = gettext.gettext
@@ -53,6 +54,7 @@ class DictEntry(object):
def set_readonly(self, readonly):
self.widget.set_editable(not readonly)
set_widget_style(self.widget, not readonly)
class DictBooleanEntry(DictEntry):
@@ -13,6 +13,7 @@ from tryton.common.popup_menu import populate
from tryton.common.completion import get_completion, update_completion
from tryton.common.entry_position import reset_position
from tryton.common.domain_parser import quote
from tryton.common.widget_style import set_widget_style
from tryton.config import CONFIG
_ = gettext.gettext
@@ -61,6 +62,7 @@ class Many2One(Widget):
def _set_button_sensitive(self):
self.wid_text.set_editable(not self._readonly)
set_widget_style(self.wid_text, not self._readonly)
self.wid_text.set_icon_sensitive(
gtk.ENTRY_ICON_PRIMARY, self.read_access)
self.wid_text.set_icon_sensitive(
@@ -6,6 +6,7 @@ import gobject
from .widget import Widget
from tryton.common.selection import SelectionMixin
from tryton.common.treeviewcontrol import TreeViewControl
from tryton.common.widget_style import set_widget_style
class MultiSelection(Widget, SelectionMixin):
@@ -41,6 +42,7 @@ class MultiSelection(Widget, SelectionMixin):
def _readonly_set(self, readonly):
super(MultiSelection, self)._readonly_set(readonly)
set_widget_style(self.tree, not readonly)
selection = self.tree.get_selection()
selection.set_select_function(lambda info: not readonly)
@@ -6,6 +6,7 @@ import gettext
from .many2one import Many2One
from tryton.common.selection import SelectionMixin, PopdownMixin, \
selection_shortcuts
from tryton.common.widget_style import set_widget_style
from tryton.config import CONFIG
_ = gettext.gettext
@@ -50,6 +51,7 @@ class Reference(Many2One, SelectionMixin, PopdownMixin):
def _set_button_sensitive(self):
super(Reference, self)._set_button_sensitive()
self.widget_combo.child.set_editable(not self._readonly)
set_widget_style(self.widget_combo.child, not self._readonly)
self.widget_combo.set_button_sensitivity(
gtk.SENSITIVITY_OFF if self._readonly else gtk.SENSITIVITY_AUTO)
if self._readonly and CONFIG['client.fast_tabbing']:
@@ -6,6 +6,7 @@ import gobject
from .widget import Widget
from tryton.common.selection import SelectionMixin, selection_shortcuts, \
PopdownMixin
from tryton.common.widget_style import set_widget_style
from tryton.config import CONFIG
@@ -53,6 +54,7 @@ class Selection(Widget, SelectionMixin, PopdownMixin):
def _readonly_set(self, value):
super(Selection, self)._readonly_set(value)
self.entry.child.set_editable(not value)
set_widget_style(self.entry.child, not value)
self.entry.set_button_sensitivity(
gtk.SENSITIVITY_OFF if value else gtk.SENSITIVITY_AUTO)
if value and CONFIG['client.fast_tabbing']:
@@ -2,6 +2,7 @@
# this repository contains the full copyright notices and license terms.
import gtk
from .widget import Widget, TranslateMixin
from tryton.common.widget_style import set_widget_style
from tryton.config import CONFIG
try:
@@ -85,6 +86,7 @@ class TextBox(Widget, TranslateMixin):
def _readonly_set(self, value):
super(TextBox, self)._readonly_set(value)
self.textview.set_editable(not value)
set_widget_style(self.textview, not value)
if self.button:
self.button.set_sensitive(not value)
if value and CONFIG['client.fast_tabbing']:
@@ -4,6 +4,7 @@ import gtk
from tryton.config import CONFIG
from tryton.common.entry_position import reset_position
from tryton.common.widget_style import set_widget_style
from .widget import Widget
@@ -48,6 +49,7 @@ class TimeDelta(Widget):
def _readonly_set(self, value):
super(TimeDelta, self)._readonly_set(value)
self.entry.set_editable(not value)
set_widget_style(self.entry, not value)
if value and CONFIG['client.fast_tabbing']:
self.widget.set_focus_chain([])
else: