Feature Fanchart: allow to set font type used in graph
svn: r20322
This commit is contained in:
parent
9321422b48
commit
1b09094916
@ -362,11 +362,13 @@ class ConfigureDialog(ManagedWindow):
|
||||
return entry
|
||||
|
||||
def add_combo(self, table, label, index, constant, opts, callback=None,
|
||||
config=None):
|
||||
config=None, valueactive=False):
|
||||
"""
|
||||
A drop-down list allowing selection from a number of fixed options.
|
||||
:param opts: A list of options. Each option is a tuple containing an
|
||||
integer code and a textual description.
|
||||
If valueactive = True, the constant stores the value, not the position
|
||||
in the list
|
||||
"""
|
||||
if not config:
|
||||
config = self.__config
|
||||
@ -379,8 +381,17 @@ class ConfigureDialog(ManagedWindow):
|
||||
combo = Gtk.ComboBox(model=store)
|
||||
cell = Gtk.CellRendererText()
|
||||
combo.pack_start(cell, True)
|
||||
combo.add_attribute(cell, 'text', 1)
|
||||
combo.set_active(config.get(constant))
|
||||
combo.add_attribute(cell, 'text', 1)
|
||||
if valueactive:
|
||||
val = config.get(constant)
|
||||
pos = 0
|
||||
for nr, item in enumerate(opts):
|
||||
if item[-1] == val:
|
||||
pos = nr
|
||||
break
|
||||
combo.set_active(pos)
|
||||
else:
|
||||
combo.set_active(config.get(constant))
|
||||
combo.connect('changed', callback, constant)
|
||||
table.attach(lwidget, 1, 2, index, index+1, yoptions=0,
|
||||
xoptions=Gtk.AttachOptions.FILL)
|
||||
|
@ -128,7 +128,7 @@ class FanChartWidget(Gtk.DrawingArea):
|
||||
self.goto = None
|
||||
self.on_popup = callback_popup
|
||||
self.last_x, self.last_y = None, None
|
||||
self.fontdescr = "Times New Roman" #"sans"
|
||||
self.fontdescr = "Sans"
|
||||
self.fontsize = 8
|
||||
self.connect("button_release_event", self.on_mouse_up)
|
||||
self.connect("motion_notify_event", self.on_mouse_move)
|
||||
@ -169,16 +169,17 @@ class FanChartWidget(Gtk.DrawingArea):
|
||||
self.center_xy = [0, 0] # distance from center (x, y)
|
||||
self.center = 50 # pixel radius of center
|
||||
#default values
|
||||
self.reset(9, self.BACKGROUND_SCHEME1, True, True)
|
||||
self.reset(9, self.BACKGROUND_SCHEME1, True, True, 'Sans')
|
||||
self.set_size_request(120, 120)
|
||||
|
||||
def reset(self, maxgen, background, childring, radialtext):
|
||||
def reset(self, maxgen, background, childring, radialtext, fontdescr):
|
||||
"""
|
||||
Reset all of the data on where/how slices appear, and if they are expanded.
|
||||
"""
|
||||
self.radialtext = radialtext
|
||||
self.childring = childring
|
||||
self.background = background
|
||||
self.fontdescr = fontdescr
|
||||
if self.background == self.BACKGROUND_GENDER:
|
||||
self.colors = None
|
||||
else:
|
||||
@ -859,7 +860,7 @@ class FanChartWidget(Gtk.DrawingArea):
|
||||
class FanChartGrampsGUI(object):
|
||||
""" class for functions fanchart GUI elements will need in Gramps
|
||||
"""
|
||||
def __init__(self, maxgen, background, childring, radialtext,
|
||||
def __init__(self, maxgen, background, childring, radialtext, font,
|
||||
on_childmenu_changed):
|
||||
"""
|
||||
Common part of GUI that shows Fan Chart, needs to know what to do if
|
||||
@ -874,6 +875,7 @@ class FanChartGrampsGUI(object):
|
||||
self.background = background
|
||||
self.childring = childring
|
||||
self.radialtext = radialtext
|
||||
self.fonttype = font
|
||||
|
||||
def have_parents(self, person):
|
||||
"""on_childmenu_changed
|
||||
@ -928,7 +930,7 @@ class FanChartGrampsGUI(object):
|
||||
data.
|
||||
"""
|
||||
self.fan.reset(self.maxgen, self.background, self.childring,
|
||||
self.radialtext)
|
||||
self.radialtext, self.fonttype)
|
||||
person = self.dbstate.db.get_person_from_handle(self.get_active('Person'))
|
||||
if not person:
|
||||
name = None
|
||||
|
@ -63,7 +63,7 @@ class FanChartGramplet(FanChartGrampsGUI, Gramplet):
|
||||
|
||||
def __init__(self, gui, nav_group=0):
|
||||
Gramplet.__init__(self, gui, nav_group)
|
||||
FanChartGrampsGUI.__init__(self, 6, 0, True, True,
|
||||
FanChartGrampsGUI.__init__(self, 6, 0, True, True, 'Sans',
|
||||
self.on_childmenu_changed)
|
||||
self.set_fan(FanChartWidget(self.dbstate, self.on_popup))
|
||||
# Replace the standard textview with the fan chart widget:
|
||||
|
@ -48,6 +48,7 @@ from gui.views.navigationview import NavigationView
|
||||
from gen.errors import WindowActiveError
|
||||
from gui.views.bookmarks import PersonBookmarks
|
||||
from gui.editors import EditPerson
|
||||
from gui.utils import SystemFonts
|
||||
|
||||
# the print settings to remember between print sessions
|
||||
PRINT_SETTINGS = None
|
||||
@ -62,6 +63,7 @@ class FanChartView(FanChartGrampsGUI, NavigationView):
|
||||
('interface.fanview-background', 0),
|
||||
('interface.fanview-childrenring', True),
|
||||
('interface.fanview-radialtext', True),
|
||||
('interface.fanview-font', 'Sans'),
|
||||
)
|
||||
def __init__(self, pdata, dbstate, uistate, nav_group=0):
|
||||
self.dbstate = dbstate
|
||||
@ -76,12 +78,14 @@ class FanChartView(FanChartGrampsGUI, NavigationView):
|
||||
self._config.get('interface.fanview-background'),
|
||||
self._config.get('interface.fanview-childrenring'),
|
||||
self._config.get('interface.fanview-radialtext'),
|
||||
self._config.get('interface.fanview-font'),
|
||||
self.on_childmenu_changed)
|
||||
|
||||
dbstate.connect('active-changed', self.active_changed)
|
||||
dbstate.connect('database-changed', self.change_db)
|
||||
|
||||
self.additional_uis.append(self.additional_ui())
|
||||
self.allfonts = [x for x in enumerate(SystemFonts().get_system_fonts())]
|
||||
|
||||
def navigation_type(self):
|
||||
return 'Person'
|
||||
@ -263,6 +267,10 @@ class FanChartView(FanChartGrampsGUI, NavigationView):
|
||||
configdialog.add_checkbox(table,
|
||||
_('Allow radial text at generation 6'),
|
||||
3, 'interface.fanview-radialtext')
|
||||
configdialog.add_combo(table,
|
||||
_('Text Font'),
|
||||
4, 'interface.fanview-font',
|
||||
self.allfonts, callback=self.cb_update_font, valueactive=True)
|
||||
|
||||
return _('Layout'), table
|
||||
|
||||
@ -308,6 +316,12 @@ class FanChartView(FanChartGrampsGUI, NavigationView):
|
||||
self.radialtext = False
|
||||
self.update()
|
||||
|
||||
def cb_update_font(self, obj, constant):
|
||||
entry = obj.get_active()
|
||||
self._config.set(constant, self.allfonts[entry][1])
|
||||
self.fonttype = self.allfonts[entry][1]
|
||||
self.update()
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# CairoPrintSave class
|
||||
|
Loading…
Reference in New Issue
Block a user