Please review this at http://codereview.appspot.com/186257/show
Affected files:
M tryton/gui/window/view_form/view/form_gtk/interface.py
Index: tryton/gui/window/view_form/view/form_gtk/interface.py
===================================================================
--- a/tryton/gui/window/view_form/view/form_gtk/interface.py
+++ b/tryton/gui/window/view_form/view/form_gtk/interface.py
@@ -93,13 +93,7 @@
]
self.widget = None
self.position = 0
- self.bg_color_active = None
- self.bg_color_insensitive = None
- self.base_color_normal = None
- self.base_color_insensitive = None
- self.fg_color_normal = None
- self.fg_color_insensitive = None
- self.text_color_normal = None
+ self.colors = {}
self.visible = True
def destroy(self):
@@ -156,25 +150,21 @@
def color_set(self, name):
widget = self._color_widget()
- colormap = widget.get_colormap()
- style = widget.get_style()
- if self.bg_color_active is None:
- self.bg_color_active = style.bg[gtk.STATE_ACTIVE]
- if self.bg_color_insensitive is None:
- self.bg_color_insensitive = style.bg[gtk.STATE_INSENSITIVE]
- if self.base_color_normal is None:
- self.base_color_normal = style.base[gtk.STATE_NORMAL]
- if self.base_color_insensitive is None:
- self.base_color_insensitive = style.base[gtk.STATE_INSENSITIVE]
- if self.fg_color_normal is None:
- self.fg_color_normal = style.fg[gtk.STATE_NORMAL]
- if self.fg_color_insensitive is None:
- self.fg_color_insensitive = style.fg[gtk.STATE_INSENSITIVE]
- if self.text_color_normal is None:
- self.text_color_normal = style.text[gtk.STATE_NORMAL]
+ if not self.colors:
+ style = widget.get_style()
+ self.colors = {
+ 'bg_color_active': style.bg[gtk.STATE_ACTIVE],
+ 'bg_color_insensitive': style.bg[gtk.STATE_INSENSITIVE],
+ 'base_color_normal': style.base[gtk.STATE_NORMAL],
+ 'base_color_insensitive':
style.base[gtk.STATE_INSENSITIVE],
+ 'fg_color_normal': style.fg[gtk.STATE_NORMAL],
+ 'fg_color_insensitive': style.fg[gtk.STATE_INSENSITIVE],
+ 'text_color_normal': style.text[gtk.STATE_NORMAL],
+ }
if COLORS.get(name):
+ colormap = widget.get_colormap()
bg_color = colormap.alloc_color(COLORS.get(name, 'white'))
fg_color = gtk.gdk.color_parse("black")
widget.modify_bg(gtk.STATE_ACTIVE, bg_color)
@@ -183,17 +173,27 @@
widget.modify_text(gtk.STATE_NORMAL, fg_color)
widget.modify_text(gtk.STATE_INSENSITIVE, fg_color)
elif name == 'readonly':
- widget.modify_bg(gtk.STATE_ACTIVE, self.bg_color_insensitive)
- widget.modify_base(gtk.STATE_NORMAL,
self.base_color_insensitive)
- widget.modify_fg(gtk.STATE_NORMAL, self.fg_color_insensitive)
- widget.modify_text(gtk.STATE_NORMAL, self.text_color_normal)
- widget.modify_text(gtk.STATE_INSENSITIVE,
self.text_color_normal)
+ widget.modify_bg(gtk.STATE_ACTIVE,
+ self.colors['bg_color_insensitive'])
+ widget.modify_base(gtk.STATE_NORMAL,
+ self.colors['base_color_insensitive'])
+ widget.modify_fg(gtk.STATE_NORMAL,
+ self.colors['fg_color_insensitive'])
+ widget.modify_text(gtk.STATE_NORMAL,
+ self.colors['text_color_normal'])
+ widget.modify_text(gtk.STATE_INSENSITIVE,
+ self.colors['text_color_normal'])
else:
- widget.modify_bg(gtk.STATE_ACTIVE, self.bg_color_active)
- widget.modify_base(gtk.STATE_NORMAL, self.base_color_normal)
- widget.modify_fg(gtk.STATE_NORMAL, self.fg_color_normal)
- widget.modify_text(gtk.STATE_NORMAL, self.text_color_normal)
- widget.modify_text(gtk.STATE_INSENSITIVE,
self.text_color_normal)
+ widget.modify_bg(gtk.STATE_ACTIVE,
+ self.colors['bg_color_active'])
+ widget.modify_base(gtk.STATE_NORMAL,
+ self.colors['base_color_normal'])
+ widget.modify_fg(gtk.STATE_NORMAL,
+ self.colors['fg_color_normal'])
+ widget.modify_text(gtk.STATE_NORMAL,
+ self.colors['text_color_normal'])
+ widget.modify_text(gtk.STATE_INSENSITIVE,
+ self.colors['text_color_normal'])
def invisible_set(self, value):
widget = self._invisible_widget()
--
Cédric Krier
B2CK SPRL
Rue de Rotterdam, 4
4000 Liège
Belgium
Tel: +32 472 54 46 59
Email: [email protected]
Jabber: [email protected]
Website: http://www.b2ck.com/
twitter: http://twitter.com/cedrickrier
identi.ca: http://identi.ca/cedrickrier
pgpRc4thzuIYl.pgp
Description: PGP signature
