Needed single place where colors boxes are defined, have put it in config, with a color tab in
preferences svn: r20258
This commit is contained in:
parent
3aefa46059
commit
f9f9109072
@ -306,6 +306,22 @@ register('preferences.last-views', [])
|
|||||||
register('preferences.use-bsddb3', False)
|
register('preferences.use-bsddb3', False)
|
||||||
register('preferences.family-relation-type', 3) # UNKNOWN
|
register('preferences.family-relation-type', 3) # UNKNOWN
|
||||||
register('preferences.age-display-precision', 1)
|
register('preferences.age-display-precision', 1)
|
||||||
|
register('preferences.color-gender-male-alive', '#b8cee6')
|
||||||
|
register('preferences.color-gender-male-death', '#b8cee6')
|
||||||
|
register('preferences.color-gender-female-alive', '#feccf0')
|
||||||
|
register('preferences.color-gender-female-death', '#feccf0')
|
||||||
|
register('preferences.color-gender-unknown-alive', '#f3dbb6')
|
||||||
|
register('preferences.color-gender-unknown-death', '#f3dbb6')
|
||||||
|
#register('preferences.color-gender-other-alive', '#fcaf3e')
|
||||||
|
#register('preferences.color-gender-other-death', '#fcaf3e')
|
||||||
|
register('preferences.bordercolor-gender-male-alive', '#1f4986')
|
||||||
|
register('preferences.bordercolor-gender-male-death', '#000000')
|
||||||
|
register('preferences.bordercolor-gender-female-alive', '#861f69')
|
||||||
|
register('preferences.bordercolor-gender-female-death', '#000000')
|
||||||
|
register('preferences.bordercolor-gender-unknown-alive', '#8e5801')
|
||||||
|
register('preferences.bordercolor-gender-unknown-death', '#000000')
|
||||||
|
#register('preferences.bordercolor-gender-other-alive', '#f57900')
|
||||||
|
#register('preferences.bordercolor-gender-other-death', '#000000')
|
||||||
|
|
||||||
register('researcher.researcher-addr', '')
|
register('researcher.researcher-addr', '')
|
||||||
register('researcher.researcher-locality', '')
|
register('researcher.researcher-locality', '')
|
||||||
|
@ -38,8 +38,9 @@ from xml.sax.saxutils import escape
|
|||||||
# GTK/Gnome modules
|
# GTK/Gnome modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from gi.repository import Gtk
|
|
||||||
from gi.repository import GObject
|
from gi.repository import GObject
|
||||||
|
from gi.repository import Gdk
|
||||||
|
from gi.repository import Gtk
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -280,14 +281,14 @@ class ConfigureDialog(ManagedWindow):
|
|||||||
table.attach(radiobox, column, column+1, index, index+1, yoptions=0)
|
table.attach(radiobox, column, column+1, index, index+1, yoptions=0)
|
||||||
return radiobox
|
return radiobox
|
||||||
|
|
||||||
def add_text(self, table, label, index, config=None):
|
def add_text(self, table, label, index, config=None, line_wrap=True):
|
||||||
if not config:
|
if not config:
|
||||||
config = self.__config
|
config = self.__config
|
||||||
text = Gtk.Label()
|
text = Gtk.Label()
|
||||||
text.set_line_wrap(True)
|
text.set_line_wrap(line_wrap)
|
||||||
text.set_alignment(0.,0.)
|
text.set_alignment(0.,0.)
|
||||||
text.set_text(label)
|
text.set_text(label)
|
||||||
table.attach(text, 1, 9, index, index+1, yoptions=0)
|
table.attach(text, 1, 9, index, index+1, yoptions=Gtk.AttachOptions.SHRINK)
|
||||||
|
|
||||||
def add_path_box(self, table, label, index, entry, path, callback_label,
|
def add_path_box(self, table, label, index, entry, path, callback_label,
|
||||||
callback_sel, config=None):
|
callback_sel, config=None):
|
||||||
@ -345,7 +346,7 @@ class ConfigureDialog(ManagedWindow):
|
|||||||
table.attach(entry, col_attach+1, col_attach+2, index, index+1,
|
table.attach(entry, col_attach+1, col_attach+2, index, index+1,
|
||||||
yoptions=0)
|
yoptions=0)
|
||||||
|
|
||||||
def add_color(self, table, label, index, constant, config=None):
|
def add_color(self, table, label, index, constant, config=None, col=0):
|
||||||
if not config:
|
if not config:
|
||||||
config = self.__config
|
config = self.__config
|
||||||
lwidget = BasicLabel("%s: " % label)
|
lwidget = BasicLabel("%s: " % label)
|
||||||
@ -354,10 +355,10 @@ class ConfigureDialog(ManagedWindow):
|
|||||||
entry = Gtk.ColorButton(color=color)
|
entry = Gtk.ColorButton(color=color)
|
||||||
color_hex_label = BasicLabel(hexval)
|
color_hex_label = BasicLabel(hexval)
|
||||||
entry.connect('color-set', self.update_color, constant, color_hex_label)
|
entry.connect('color-set', self.update_color, constant, color_hex_label)
|
||||||
table.attach(lwidget, 0, 1, index, index+1, yoptions=0,
|
table.attach(lwidget, col, col+1, index, index+1, yoptions=0,
|
||||||
xoptions=Gtk.AttachOptions.FILL)
|
xoptions=Gtk.AttachOptions.FILL)
|
||||||
table.attach(entry, 1, 2, index, index+1, yoptions=0, xoptions=0)
|
table.attach(entry, col+1, col+2, index, index+1, yoptions=0, xoptions=0)
|
||||||
table.attach(color_hex_label, 2, 3, index, index+1, yoptions=0)
|
table.attach(color_hex_label, col+2, col+3, index, index+1, yoptions=0)
|
||||||
return entry
|
return entry
|
||||||
|
|
||||||
def add_combo(self, table, label, index, constant, opts, callback=None,
|
def add_combo(self, table, label, index, constant, opts, callback=None,
|
||||||
@ -441,8 +442,9 @@ class GrampsPreferences(ConfigureDialog):
|
|||||||
self.add_text_panel,
|
self.add_text_panel,
|
||||||
self.add_prefix_panel,
|
self.add_prefix_panel,
|
||||||
self.add_date_panel,
|
self.add_date_panel,
|
||||||
self.add_advanced_panel,
|
|
||||||
self.add_researcher_panel,
|
self.add_researcher_panel,
|
||||||
|
self.add_advanced_panel,
|
||||||
|
self.add_color_panel
|
||||||
)
|
)
|
||||||
ConfigureDialog.__init__(self, uistate, dbstate, page_funcs,
|
ConfigureDialog.__init__(self, uistate, dbstate, page_funcs,
|
||||||
GrampsPreferences, config,
|
GrampsPreferences, config,
|
||||||
@ -453,15 +455,17 @@ class GrampsPreferences(ConfigureDialog):
|
|||||||
table.set_border_width(12)
|
table.set_border_width(12)
|
||||||
table.set_col_spacings(6)
|
table.set_col_spacings(6)
|
||||||
table.set_row_spacings(6)
|
table.set_row_spacings(6)
|
||||||
self.add_entry(table, _('Name'), 0, 'researcher.researcher-name')
|
self.add_text(table, _('Enter your information so people can contact you when you'
|
||||||
self.add_entry(table, _('Address'), 1, 'researcher.researcher-addr')
|
' distribute your family tree'), 0, line_wrap=False)
|
||||||
self.add_entry(table, _('Locality'), 2, 'researcher.researcher-locality')
|
self.add_entry(table, _('Name'), 1, 'researcher.researcher-name')
|
||||||
self.add_entry(table, _('City'), 3, 'researcher.researcher-city')
|
self.add_entry(table, _('Address'), 2, 'researcher.researcher-addr')
|
||||||
self.add_entry(table, _('State/County'), 4, 'researcher.researcher-state')
|
self.add_entry(table, _('Locality'), 3, 'researcher.researcher-locality')
|
||||||
self.add_entry(table, _('Country'), 5, 'researcher.researcher-country')
|
self.add_entry(table, _('City'), 4, 'researcher.researcher-city')
|
||||||
self.add_entry(table, _('ZIP/Postal Code'), 6, 'researcher.researcher-postal')
|
self.add_entry(table, _('State/County'), 5, 'researcher.researcher-state')
|
||||||
self.add_entry(table, _('Phone'), 7, 'researcher.researcher-phone')
|
self.add_entry(table, _('Country'), 6, 'researcher.researcher-country')
|
||||||
self.add_entry(table, _('Email'), 8, 'researcher.researcher-email')
|
self.add_entry(table, _('ZIP/Postal Code'), 7, 'researcher.researcher-postal')
|
||||||
|
self.add_entry(table, _('Phone'), 8, 'researcher.researcher-phone')
|
||||||
|
self.add_entry(table, _('Email'), 9, 'researcher.researcher-email')
|
||||||
return _('Researcher'), table
|
return _('Researcher'), table
|
||||||
|
|
||||||
def add_prefix_panel(self, configdialog):
|
def add_prefix_panel(self, configdialog):
|
||||||
@ -492,6 +496,47 @@ class GrampsPreferences(ConfigureDialog):
|
|||||||
self.update_idformat_entry)
|
self.update_idformat_entry)
|
||||||
return _('ID Formats'), table
|
return _('ID Formats'), table
|
||||||
|
|
||||||
|
def add_color_panel(self, configdialog):
|
||||||
|
"""
|
||||||
|
Add the tab to set defaults colors for graph boxes
|
||||||
|
"""
|
||||||
|
table = Gtk.Table(17, 8)
|
||||||
|
self.add_text(table, _('Set the colors used for boxes in the graphical views'),
|
||||||
|
0, line_wrap=False)
|
||||||
|
self.add_color(table, _('Gender Male Alive'), 1,
|
||||||
|
'preferences.color-gender-male-alive')
|
||||||
|
self.add_color(table, _('Border Male Alive'), 2,
|
||||||
|
'preferences.bordercolor-gender-male-alive')
|
||||||
|
self.add_color(table, _('Gender Male Death'), 3,
|
||||||
|
'preferences.color-gender-male-death')
|
||||||
|
self.add_color(table, _('Border Male Death'), 4,
|
||||||
|
'preferences.bordercolor-gender-male-death')
|
||||||
|
self.add_color(table, _('Gender Female Alive'), 1,
|
||||||
|
'preferences.color-gender-female-alive', col=4)
|
||||||
|
self.add_color(table, _('Border Female Alive'), 2,
|
||||||
|
'preferences.bordercolor-gender-female-alive', col=4)
|
||||||
|
self.add_color(table, _('Gender Female Death'), 3,
|
||||||
|
'preferences.color-gender-female-death', col=4)
|
||||||
|
self.add_color(table, _('Border Female Death'), 4,
|
||||||
|
'preferences.bordercolor-gender-female-death', col=4)
|
||||||
|
## self.add_color(table, _('Gender Other Alive'), 5,
|
||||||
|
## 'preferences.color-gender-other-alive')
|
||||||
|
## self.add_color(table, _('Border Other Alive'), 6,
|
||||||
|
## 'preferences.bordercolor-gender-other-alive')
|
||||||
|
## self.add_color(table, _('Gender Other Death'), 7,
|
||||||
|
## 'preferences.color-gender-other-death')
|
||||||
|
## self.add_color(table, _('Border Other Death'), 8,
|
||||||
|
## 'preferences.bordercolor-gender-other-death')
|
||||||
|
self.add_color(table, _('Gender Unknown Alive'), 5,
|
||||||
|
'preferences.color-gender-unknown-alive', col=4)
|
||||||
|
self.add_color(table, _('Border Unknown Alive'), 6,
|
||||||
|
'preferences.bordercolor-gender-unknown-alive', col=4)
|
||||||
|
self.add_color(table, _('Gender Unknown Death'), 7,
|
||||||
|
'preferences.color-gender-unknown-death', col=4)
|
||||||
|
self.add_color(table, _('Border Unknown Death'), 8,
|
||||||
|
'preferences.bordercolor-gender-unknown-death', col=4)
|
||||||
|
return _('Colors'), table
|
||||||
|
|
||||||
def add_advanced_panel(self, configdialog):
|
def add_advanced_panel(self, configdialog):
|
||||||
table = Gtk.Table(4, 8)
|
table = Gtk.Table(4, 8)
|
||||||
table.set_border_width(12)
|
table.set_border_width(12)
|
||||||
|
@ -50,6 +50,7 @@ from gi.repository import PangoCairo
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import gen.lib
|
import gen.lib
|
||||||
from gen.constfunc import has_display, is_quartz, mac, win
|
from gen.constfunc import has_display, is_quartz, mac, win
|
||||||
|
from gen.config import config
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -410,6 +411,56 @@ def is_right_click(event):
|
|||||||
if event.button == 3:
|
if event.button == 3:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def color_graph_box(alive=False, gender=gen.lib.Person.MALE):
|
||||||
|
"""
|
||||||
|
Returns based on the config the color for graph boxes in hex
|
||||||
|
If gender is None, an empty box is assumed
|
||||||
|
Return type: tuple (hex color fill, hex color border)
|
||||||
|
"""
|
||||||
|
if gender == gen.lib.Person.MALE:
|
||||||
|
if alive:
|
||||||
|
return (config.get('preferences.color-gender-male-alive'),
|
||||||
|
config.get('preferences.bordercolor-gender-male-alive'))
|
||||||
|
else:
|
||||||
|
return (config.get('preferences.color-gender-male-death'),
|
||||||
|
config.get('preferences.bordercolor-gender-male-death'))
|
||||||
|
elif gender == gen.lib.Person.FEMALE:
|
||||||
|
if alive:
|
||||||
|
return (config.get('preferences.color-gender-female-alive'),
|
||||||
|
config.get('preferences.bordercolor-gender-female-alive'))
|
||||||
|
else:
|
||||||
|
return (config.get('preferences.color-gender-female-death'),
|
||||||
|
config.get('preferences.bordercolor-gender-female-death'))
|
||||||
|
elif gender == gen.lib.Person.UNKNOWN:
|
||||||
|
if alive:
|
||||||
|
return (config.get('preferences.color-gender-unknown-alive'),
|
||||||
|
config.get('preferences.bordercolor-gender-unknown-alive'))
|
||||||
|
else:
|
||||||
|
return (config.get('preferences.color-gender-unknown-death'),
|
||||||
|
config.get('preferences.bordercolor-gender-unknown-death'))
|
||||||
|
#empty box, no gender
|
||||||
|
return ('#d2d6ce', '#000000')
|
||||||
|
## print 'male alive', rgb_to_hex((185/256.0, 207/256.0, 231/256.0))
|
||||||
|
## print 'female alive', rgb_to_hex((255/256.0, 205/256.0, 241/256.0))
|
||||||
|
## print 'unknown alive', rgb_to_hex((244/256.0, 220/256.0, 183/256.0))
|
||||||
|
## print 'male death', rgb_to_hex((185/256.0, 207/256.0, 231/256.0))
|
||||||
|
## print 'female death', rgb_to_hex((255/256.0, 205/256.0, 241/256.0))
|
||||||
|
## print 'unknown death', rgb_to_hex((244/256.0, 220/256.0, 183/256.0))
|
||||||
|
##
|
||||||
|
## print 'border male alive', rgb_to_hex((32/256.0, 74/256.0, 135/256.0))
|
||||||
|
## print 'border female alive', rgb_to_hex((135/256.0, 32/256.0, 106/256.0))
|
||||||
|
## print 'border unknown alive', rgb_to_hex((143/256.0, 89/256.0, 2/256.0))
|
||||||
|
## print 'empty', rgb_to_hex((211/256.0, 215/256.0, 207/256.0))
|
||||||
|
|
||||||
|
def hex_to_rgb_float(value):
|
||||||
|
"""
|
||||||
|
Convert a hexademical value #FF00FF to rgb. Returns tuple of float between
|
||||||
|
0 and 1
|
||||||
|
"""
|
||||||
|
value = value.lstrip('#')
|
||||||
|
lenv = len(value)
|
||||||
|
return tuple(int(value[i:i+lenv/3], 16)/256.0 for i in range(0, lenv, lenv/3))
|
||||||
|
|
||||||
def hex_to_rgb(value):
|
def hex_to_rgb(value):
|
||||||
"""
|
"""
|
||||||
Convert a hexademical value #FF00FF to rgb. Returns tuple of integers
|
Convert a hexademical value #FF00FF to rgb. Returns tuple of integers
|
||||||
|
@ -192,27 +192,12 @@ class PersonBoxWidgetCairo(_PersonWidgetBase):
|
|||||||
if self.person:
|
if self.person:
|
||||||
self.text = self.format_helper.format_person(self.person,
|
self.text = self.format_helper.format_person(self.person,
|
||||||
self.maxlines, True)
|
self.maxlines, True)
|
||||||
if alive and self.person.get_gender() == gen.lib.Person.MALE:
|
gender = self.person.get_gender()
|
||||||
self.bgcolor = (185/256.0, 207/256.0, 231/256.0)
|
|
||||||
self.bordercolor = (32/256.0, 74/256.0, 135/256.0)
|
|
||||||
elif alive and self.person.get_gender() == gen.lib.Person.FEMALE:
|
|
||||||
self.bgcolor = (255/256.0, 205/256.0, 241/256.0)
|
|
||||||
self.bordercolor = (135/256.0, 32/256.0, 106/256.0)
|
|
||||||
elif alive:
|
|
||||||
self.bgcolor = (244/256.0, 220/256.0, 183/256.0)
|
|
||||||
self.bordercolor = (143/256.0, 89/256.0, 2/256.0)
|
|
||||||
elif self.person.get_gender() == gen.lib.Person.MALE:
|
|
||||||
self.bgcolor = (185/256.0, 207/256.0, 231/256.0)
|
|
||||||
self.bordercolor = (0, 0, 0)
|
|
||||||
elif self.person.get_gender() == gen.lib.Person.FEMALE:
|
|
||||||
self.bgcolor = (255/256.0, 205/256.0, 241/256.0)
|
|
||||||
self.bordercolor = (0, 0, 0)
|
|
||||||
else:
|
|
||||||
self.bgcolor = (244/256.0, 220/256.0, 183/256.0)
|
|
||||||
self.bordercolor = (0, 0, 0)
|
|
||||||
else:
|
else:
|
||||||
self.bgcolor = (211/256.0, 215/256.0, 207/256.0)
|
gender = None
|
||||||
self.bordercolor = (0, 0, 0)
|
self.bgcolor, self.bordercolor = gui.utils.color_graph_box(alive, gender)
|
||||||
|
self.bgcolor = gui.utils.hex_to_rgb_float(self.bgcolor)
|
||||||
|
self.bordercolor = gui.utils.hex_to_rgb_float(self.bordercolor)
|
||||||
|
|
||||||
self.img_surf = None
|
self.img_surf = None
|
||||||
if image:
|
if image:
|
||||||
|
Loading…
Reference in New Issue
Block a user