Skip to content

Commit 04cd206

Browse files
authored
Dynamic web: Gender fill colour hex incomplete (#528)
* Dynamic web: Gender fill colour hex incomplete Fixes #012513 Add an option to select a light or a dark theme when the background gender option is selected. * Store the value corresponding to the chosen theme * Upgrade to version 0.0.93
1 parent ef58538 commit 04cd206

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

DynamicWeb/dynamicweb.gpr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
id = 'DynamicWeb',
1515
name = _("Dynamic Web Report"),
1616
description = _("Produces dynamic web pages for the database"),
17-
version = '0.0.92',
17+
version = '0.0.93',
1818
gramps_target_version = "5.1",
1919
status = STABLE,
2020
fname = 'dynamicweb.py',

DynamicWeb/dynamicweb.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# Copyright (C) 2011 Tim G L Lyons
2020
# Copyright (C) 2013 Benny Malengier
2121
# Copyright (C) 2016 Allen Crider
22+
# Copyright (C) 2022- Serge Noiraud
2223
#
2324
# This program embeds some ideas from "fanchart.py" included in Gramps
2425
# Copyrights for "fanchart.py":
@@ -2391,8 +2392,11 @@ def _export_script_configuration(self):
23912392
'unknown-alive',
23922393
'unknown-dead',
23932394
]:
2394-
sw.write("GRAMPS_PREFERENCES['%s'] = \"%s\";\n" %
2395-
(pref, config.get('colors.%s' % pref)))
2395+
if self.options['svg_theme'] == 0:
2396+
value = config.get('colors.%s' % pref)[0]
2397+
else:
2398+
value = config.get('colors.%s' % pref)[1]
2399+
sw.write("GRAMPS_PREFERENCES['%s'] = \"%s\";\n" % (pref, value))
23962400
sw.write("SVG_TREE_COLOR_SCHEME0 = [" + ", ".join(
23972401
[("\"#%02x%02x%02x\"" % (r, g, b)) for (r, g, b) in GENCOLOR[BACKGROUND_WHITE]])
23982402
+ "];\n")
@@ -4206,11 +4210,23 @@ def __add_trees_options(self, menu):
42064210
svg_tree_distrib_dsc.set_help(_("Choose the default SVG tree children distribution (for fan charts only)"))
42074211
addopt("svg_tree_distrib_dsc", svg_tree_distrib_dsc)
42084212

4209-
svg_tree_background = EnumeratedListOption(_("Background"), DEFAULT_SVG_TREE_BACKGROUND)
4213+
svg_tree_background = EnumeratedListOption(_("Background"),
4214+
DEFAULT_SVG_TREE_BACKGROUND)
42104215
for (i, opt) in enumerate(SVG_TREE_BACKGROUNDS):
42114216
svg_tree_background.add_item(i, opt)
4212-
svg_tree_background.set_help(_("Choose the background color scheme for the persons in the SVG tree graph"))
4217+
svg_tree_background.set_help(_("Choose the background color scheme for"
4218+
" the persons in the SVG tree graph"))
42134219
addopt("svg_tree_background", svg_tree_background)
4220+
svg_tree_background.connect("value-changed",
4221+
self.change_theme_visibility)
4222+
self.svg_tree_background = svg_tree_background
4223+
4224+
self.svg_theme = EnumeratedListOption(_("Theme"), 0)
4225+
for (i, opt) in enumerate([_("Light colors"), _("Dark colors")]):
4226+
self.svg_theme.add_item(i, opt)
4227+
# self.svg_theme.set_help(_("Choose the background color theme for"
4228+
# " the persons in the SVG tree graph"))
4229+
addopt("svg_theme", self.svg_theme)
42144230

42154231
svg_tree_color1 = ColorOption(_("Start gradient/Main color"), "#EF2929")
42164232
addopt("svg_tree_color1", svg_tree_color1)
@@ -4226,6 +4242,12 @@ def __add_trees_options(self, menu):
42264242
self.__svg_tree_color_dup = ColorOption(_("Color for duplicates"), "#888A85")
42274243
addopt("svg_tree_color_dup", self.__svg_tree_color_dup)
42284244

4245+
def change_theme_visibility(self):
4246+
background = self.svg_tree_background.get_value()
4247+
if background == SVG_TREE_BACKGROUND_GENDER:
4248+
self.svg_theme.set_available(True)
4249+
else:
4250+
self.svg_theme.set_available(False)
42294251

42304252
def __add_pages_options(self, menu):
42314253
category_name = _("Pages")

DynamicWeb/templates/dwr_default/data/dwr_svg.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Gramps - a GTK+/GNOME based genealogy program
22
//
33
// Copyright (C) 2014 Pierre Bélissent
4+
// Copyright (C) 2022 Serge Noiraud
45
// See also https://github.com/andrewseddon/raphael-zpd/blob/master/raphael-zpd.js for parts of code from Raphael-ZPD
56
//
67
// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
@@ -741,8 +742,8 @@ function SvgSetStyle(p, text, x_elt, lev)
741742
if (I(elt[SVGELT_IDX], 'gender') == 'M') g = 'male';
742743
if (I(elt[SVGELT_IDX], 'gender') == 'F') g = 'female';
743744
var d = 'alive';
744-
if (I(elt[SVGELT_IDX], 'death_date') != "") d = 'death';
745-
fill = GRAMPS_PREFERENCES['color-gender-' + g + '-' + d];
745+
if (I(elt[SVGELT_IDX], 'death_date') != "") d = 'dead';
746+
fill = GRAMPS_PREFERENCES[g + '-' + d];
746747
}
747748
if (typeof(lev) !== 'undefined' && Dwr.search.SvgBackground == SVG_TREE_BACKGROUND_GENERATION)
748749
{

0 commit comments

Comments
 (0)