More pylint improvements

This commit is contained in:
Nick Hall
2016-06-01 23:52:59 +01:00
parent 5f1b719810
commit 32ff947a87
37 changed files with 460 additions and 318 deletions

View File

@ -21,22 +21,16 @@ AgeOnDateGramplet computes the age for everyone thought to be alive
on a particular date. on a particular date.
""" """
#------------------------------------------------------------------------
#
# Python modules
#
#------------------------------------------------------------------------
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# Gramps modules # Gramps modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
from gramps.gen.datehandler import parser from gramps.gen.datehandler import parser
from gramps.gui.plug.quick import run_quick_report_by_name from gramps.gui.plug.quick import run_quick_report_by_name
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #

View File

@ -28,7 +28,6 @@ This Gramplet shows textual distributions of age breakdowns of various types.
# Python modules # Python modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from collections import defaultdict from collections import defaultdict
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -36,11 +35,10 @@ from collections import defaultdict
# Gramps modules # Gramps modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gen.lib import ChildRefType
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext _ = glocale.translation.gettext
from gramps.gen.lib import ChildRefType
class AgeStatsGramplet(Gramplet): class AgeStatsGramplet(Gramplet):
@ -150,7 +148,7 @@ class AgeStatsGramplet(Gramplet):
bref = f.get_birth_ref() bref = f.get_birth_ref()
if bref: if bref:
bevent = self.dbstate.db.get_event_from_handle(bref.ref) bevent = self.dbstate.db.get_event_from_handle(bref.ref)
bdate = bevent.get_date_object() bdate = bevent.get_date_object()
if bdate and birth_date and birth_date.get_year() != 0: if bdate and birth_date and birth_date.get_year() != 0:
diff = birth_date.get_year() - bdate.get_year() diff = birth_date.get_year() - bdate.get_year()
if diff >= 0 and diff < self.max_father_diff: if diff >= 0 and diff < self.max_father_diff:
@ -165,7 +163,7 @@ class AgeStatsGramplet(Gramplet):
bref = m.get_birth_ref() bref = m.get_birth_ref()
if bref: if bref:
bevent = self.dbstate.db.get_event_from_handle(bref.ref) bevent = self.dbstate.db.get_event_from_handle(bref.ref)
bdate = bevent.get_date_object() bdate = bevent.get_date_object()
if bdate and birth_date and birth_date.get_year() != 0: if bdate and birth_date and birth_date.get_year() != 0:
diff = birth_date.get_year() - bdate.get_year() diff = birth_date.get_year() - bdate.get_year()
if diff >= 0 and diff < self.max_mother_diff: if diff >= 0 and diff < self.max_mother_diff:
@ -185,7 +183,7 @@ class AgeStatsGramplet(Gramplet):
self.gui.buffer.apply_tag_by_name("fixed", start, end) self.gui.buffer.apply_tag_by_name("fixed", start, end)
self.append_text("", scroll_to="begin") self.append_text("", scroll_to="begin")
def ticks(self, width, start = 0, stop = 100, fill = " "): def ticks(self, width, start=0, stop=100, fill=" "):
""" Returns the tickmark numbers for a graph axis """ """ Returns the tickmark numbers for a graph axis """
count = int(width / 10.0) count = int(width / 10.0)
retval = "%-3d" % start retval = "%-3d" % start
@ -205,7 +203,7 @@ class AgeStatsGramplet(Gramplet):
retval += "%3d" % int(stop) retval += "%3d" % int(stop)
return retval return retval
def format(self, text, width, align = "left", borders = "||", fill = " "): def format(self, text, width, align="left", borders="||", fill=" "):
""" Returns a formatted string for nice, fixed-font display """ """ Returns a formatted string for nice, fixed-font display """
if align == "center": if align == "center":
text = text.center(width, fill) text = text.center(width, fill)
@ -269,34 +267,39 @@ class AgeStatsGramplet(Gramplet):
max_bin = float(max(bin)) max_bin = float(max(bin))
if max_bin != 0: if max_bin != 0:
i = 0 i = 0
self.append_text("--------" + self.append_text(
self.format("", graph_width-4, fill = "-", borders="++") + "--------" +
self.format("", graph_width-4, fill="-", borders="++") +
"-----\n") "-----\n")
self.append_text(column.center(8) + self.append_text(
column.center(8) +
self.format(title, graph_width-4, align="center") + self.format(title, graph_width-4, align="center") +
" % " + "\n") " % " + "\n")
self.append_text("--------" + self.append_text(
self.format("", graph_width-4, fill = "-", borders="++") + "--------" +
self.format("", graph_width-4, fill="-", borders="++") +
"-----\n") "-----\n")
for bin in bin: for bin in bin:
self.append_text((" %3d-%3d" % (i * 5, (i+1)* 5,))) self.append_text((" %3d-%3d" % (i * 5, (i+1)* 5,)))
selected = self.make_handles_set(i * 5, (i+1) *5, handles) selected = self.make_handles_set(i * 5, (i+1) *5, handles)
self.link(self.format("X" * int(bin/max_bin * (graph_width-4)), self.link(self.format("X" * int(bin/max_bin * (graph_width-4)),
graph_width-4), graph_width-4),
'PersonList', 'PersonList',
selected, selected,
tooltip=_("Double-click to see %d people") % tooltip=_("Double-click to see %d people") %
len(selected)) len(selected))
procent = (float(len(selected)) / procent = (float(len(selected)) /
(float(sum(hash.values())))*100) (float(sum(hash.values())))*100)
self.append_text(glocale.format("%#5.2f", procent)) self.append_text(glocale.format("%#5.2f", procent))
self.append_text("\n") self.append_text("\n")
i += 1 i += 1
self.append_text("--------" + self.append_text(
self.format("", graph_width-4, fill = "-", borders="++") + "--------" +
self.format("", graph_width-4, fill="-", borders="++") +
"-----\n") "-----\n")
self.append_text(" % " + self.append_text(
self.ticks(graph_width-4, start = 0, " % " +
stop = int(max_bin/(float(sum(hash.values())))*100)) + self.ticks(graph_width-4, start=0,
stop=int(max_bin/(float(sum(hash.values())))*100)) +
"\n\n") "\n\n")
self.append_text(self.compute_stats(hash)) self.append_text(self.compute_stats(hash))

View File

@ -45,7 +45,9 @@ from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext _ = glocale.translation.gettext
class Ancestor(Gramplet): class Ancestor(Gramplet):
"""
Gramplet to display ancestors of the active person.
"""
def init(self): def init(self):
self.gui.WIDGET = self.build_gui() self.gui.WIDGET = self.build_gui()
self.gui.get_container_widget().remove(self.gui.textview) self.gui.get_container_widget().remove(self.gui.textview)
@ -120,6 +122,9 @@ class Ancestor(Gramplet):
self.set_has_data(False) self.set_has_data(False)
def add_to_tree(self, depth, parent_id, person_handle): def add_to_tree(self, depth, parent_id, person_handle):
"""
Add a person to the tree.
"""
if depth > config.get('behavior.generation-depth'): if depth > config.get('behavior.generation-depth'):
return return

View File

@ -17,12 +17,23 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
from gramps.gui.listmodel import ListModel, NOSORT #-------------------------------------------------------------------------
#
# Gtk modules
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gui.listmodel import ListModel
from gramps.gui.plug.quick import run_quick_report_by_name from gramps.gui.plug.quick import run_quick_report_by_name
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext _ = glocale.translation.gettext
from gi.repository import Gtk
class Attributes(Gramplet): class Attributes(Gramplet):
""" """

View File

@ -18,13 +18,24 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
from gramps.gui.listmodel import ListModel, NOSORT #-------------------------------------------------------------------------
#
# Gtk modules
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gui.listmodel import ListModel
from gramps.gen.utils.db import navigation_label from gramps.gen.utils.db import navigation_label
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gui.utils import edit_object from gramps.gui.utils import edit_object
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext _ = glocale.translation.gettext
from gi.repository import Gtk
class Backlinks(Gramplet): class Backlinks(Gramplet):
""" """

View File

@ -16,16 +16,24 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#------------------------------------------------------------------------
#
# Gtk modules
#
#------------------------------------------------------------------------
from gi.repository import Gtk
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# Gramps modules # Gramps modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
from gramps.gui.plug.quick import run_quick_report_by_name from gramps.gui.plug.quick import run_quick_report_by_name
from gramps.gen.lib import Date from gramps.gen.lib import Date
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -33,25 +41,29 @@ from gramps.gen.lib import Date
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class CalendarGramplet(Gramplet): class CalendarGramplet(Gramplet):
"""
Gramplet showing a calendar of events.
"""
def init(self): def init(self):
from gi.repository import Gtk
self.set_tooltip(_("Double-click a day for details")) self.set_tooltip(_("Double-click a day for details"))
self.gui.calendar = Gtk.Calendar() self.gui.calendar = Gtk.Calendar()
self.gui.calendar.connect('day-selected-double-click', self.double_click) self.gui.calendar.connect('day-selected-double-click',
self.double_click)
self.gui.calendar.set_display_options( self.gui.calendar.set_display_options(
Gtk.CalendarDisplayOptions.SHOW_HEADING) Gtk.CalendarDisplayOptions.SHOW_HEADING)
self.gui.get_container_widget().remove(self.gui.textview) self.gui.get_container_widget().remove(self.gui.textview)
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
vbox.pack_start(self.gui.calendar, False, False, 0) vbox.pack_start(self.gui.calendar, False, False, 0)
self.gui.get_container_widget().add(vbox) self.gui.get_container_widget().add(vbox)
vbox.show_all() vbox.show_all()
#self.gui.calendar.show()
def post_init(self): def post_init(self):
self.disconnect("active-changed") self.disconnect("active-changed")
def double_click(self, obj): def double_click(self, obj):
# bring up events on this day """
Bring up events on this day.
"""
year, month, day = self.gui.calendar.get_date() year, month, day = self.gui.calendar.get_date()
date = Date() date = Date()
date.set_yr_mon_day(year, month + 1, day) date.set_yr_mon_day(year, month + 1, day)

View File

@ -17,18 +17,29 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
#-------------------------------------------------------------------------
#
# Gtk modules
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gui.editors import EditPerson from gramps.gui.editors import EditPerson
from gramps.gui.listmodel import ListModel, NOSORT from gramps.gui.listmodel import ListModel, NOSORT
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gen.plug.report.utils import find_spouse from gramps.gen.plug.report.utils import find_spouse
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.display.name import displayer as name_displayer from gramps.gen.display.name import displayer as name_displayer
from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback
from gramps.gen.datehandler import get_date from gramps.gen.datehandler import get_date
from gramps.gen.display.place import displayer as place_displayer from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.errors import WindowActiveError from gramps.gen.errors import WindowActiveError
from gi.repository import Gtk from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
class Children(Gramplet): class Children(Gramplet):
""" """

View File

@ -18,14 +18,25 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
#-------------------------------------------------------------------------
#
# Gtk modules
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gui.editors import EditSource, EditCitation from gramps.gui.editors import EditSource, EditCitation
from gramps.gui.listmodel import ListModel, NOSORT from gramps.gui.listmodel import ListModel, NOSORT
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gui.dbguielement import DbGUIElement from gramps.gui.dbguielement import DbGUIElement
from gramps.gen.errors import WindowActiveError
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext _ = glocale.translation.gettext
from gramps.gen.errors import WindowActiveError
from gi.repository import Gtk
class Citations(Gramplet, DbGUIElement): class Citations(Gramplet, DbGUIElement):

View File

@ -20,21 +20,12 @@
"""Descendant Gramplet""" """Descendant Gramplet"""
#------------------------------------------------------------------------
#
# Python modules
#
#------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# GTK modules # GTK modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gi.repository import Gtk from gi.repository import Gtk
from gi.repository import Gdk
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -49,9 +40,13 @@ from gramps.gen.display.name import displayer as name_displayer
from gramps.gen.datehandler import get_date from gramps.gen.datehandler import get_date
from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback
from gramps.gui.utils import model_to_text, text_to_clipboard from gramps.gui.utils import model_to_text, text_to_clipboard
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
class Descendant(Gramplet): class Descendant(Gramplet):
"""
Gramplet to display descendants of the active person.
"""
def init(self): def init(self):
self.gui.WIDGET = self.build_gui() self.gui.WIDGET = self.build_gui()
self.gui.get_container_widget().remove(self.gui.textview) self.gui.get_container_widget().remove(self.gui.textview)
@ -112,7 +107,8 @@ class Descendant(Gramplet):
menu = Gtk.Menu() menu = Gtk.Menu()
menu.set_title(_('Descendent Menu')) menu.set_title(_('Descendent Menu'))
entries = [ entries = [
(_("Edit"), lambda obj: self.cb_double_click(treeview), sensitivity), (_("Edit"), lambda obj: self.cb_double_click(treeview),
sensitivity),
(None, None, 0), (None, None, 0),
(_("Copy all"), lambda obj: self.on_copy_all(treeview), 1), (_("Copy all"), lambda obj: self.on_copy_all(treeview), 1),
] ]
@ -127,6 +123,9 @@ class Descendant(Gramplet):
self.menu.popup(None, None, None, None, event.button, event.time) self.menu.popup(None, None, None, None, event.button, event.time)
def on_copy_all(self, treeview): def on_copy_all(self, treeview):
"""
Copy tree to clipboard.
"""
model = treeview.get_model() model = treeview.get_model()
text = model_to_text(model, [0, 1], level=1) text = model_to_text(model, [0, 1], level=1)
text_to_clipboard(text) text_to_clipboard(text)
@ -155,6 +154,9 @@ class Descendant(Gramplet):
self.set_has_data(False) self.set_has_data(False)
def add_to_tree(self, parent_id, person_handle): def add_to_tree(self, parent_id, person_handle):
"""
Add a person to the tree.
"""
person = self.dbstate.db.get_person_from_handle(person_handle) person = self.dbstate.db.get_person_from_handle(person_handle)
name = name_displayer.display(person) name = name_displayer.display(person)

View File

@ -30,8 +30,6 @@ Provide a python evaluation window
#------------------------------------------------------------------------ #------------------------------------------------------------------------
import sys import sys
from io import StringIO from io import StringIO
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
import traceback import traceback
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -47,6 +45,8 @@ from gi.repository import Gtk
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -102,7 +102,7 @@ class PythonEvaluation(Gramplet):
def apply_clicked(self, obj): def apply_clicked(self, obj):
text = str(self.ebuf.get_text(self.ebuf.get_start_iter(), text = str(self.ebuf.get_text(self.ebuf.get_start_iter(),
self.ebuf.get_end_iter(),False)) self.ebuf.get_end_iter(), False))
outtext = StringIO() outtext = StringIO()
errtext = StringIO() errtext = StringIO()

View File

@ -17,23 +17,32 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
#-------------------------------------------------------------------------
#
# Gtk modules
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gui.editors import EditEvent from gramps.gui.editors import EditEvent
from gramps.gen.lib import EventRoleType
from gramps.gui.listmodel import ListModel, NOSORT from gramps.gui.listmodel import ListModel, NOSORT
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gen.plug.report.utils import find_spouse from gramps.gen.plug.report.utils import find_spouse
from gramps.gui.dbguielement import DbGUIElement from gramps.gui.dbguielement import DbGUIElement
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.display.name import displayer as name_displayer
from gramps.gen.display.place import displayer as place_displayer from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.datehandler import get_date from gramps.gen.datehandler import get_date
from gramps.gen.utils.db import (get_participant_from_event, from gramps.gen.utils.db import (get_participant_from_event,
get_birth_or_fallback, get_birth_or_fallback,
get_marriage_or_fallback) get_marriage_or_fallback)
from gramps.gen.errors import WindowActiveError from gramps.gen.errors import WindowActiveError
from gi.repository import Gtk
from gramps.gen.config import config from gramps.gen.config import config
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
age_precision = config.get('preferences.age-display-precision') age_precision = config.get('preferences.age-display-precision')

View File

@ -19,35 +19,18 @@
## Based on the normal fanchart ## Based on the normal fanchart
#-------------------------------------------------------------------------
#
# Python modules
#
#-------------------------------------------------------------------------
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Pango
from gi.repository import Gtk
import math
from gi.repository import Gdk
try:
import cairo
except ImportError:
pass
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Gramps modules # Gramps modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.plug import Gramplet
from gramps.gui.widgets.fanchartdesc import (FanChartDescWidget,
FanChartDescGrampsGUI,
ANGLE_WEIGHT)
from gramps.gui.widgets.fanchart import FORM_HALFCIRCLE, BACKGROUND_SCHEME1
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext _ = glocale.translation.gettext
from gramps.gen.plug import Gramplet
from gramps.gen.errors import WindowActiveError
from gramps.gui.editors import EditPerson
from gramps.gui.widgets.fanchartdesc import (FanChartDescWidget, FanChartDescGrampsGUI,
ANGLE_WEIGHT)
from gramps.gui.widgets.fanchart import FORM_HALFCIRCLE, BACKGROUND_SCHEME1
class FanChartDescGramplet(FanChartDescGrampsGUI, Gramplet): class FanChartDescGramplet(FanChartDescGrampsGUI, Gramplet):
""" """
@ -67,7 +50,8 @@ class FanChartDescGramplet(FanChartDescGrampsGUI, Gramplet):
self.alpha_filter = 0.2 self.alpha_filter = 0.2
self.form = FORM_HALFCIRCLE self.form = FORM_HALFCIRCLE
self.angle_algo = ANGLE_WEIGHT self.angle_algo = ANGLE_WEIGHT
self.set_fan(FanChartDescWidget(self.dbstate, self.uistate, self.on_popup)) self.set_fan(FanChartDescWidget(self.dbstate, self.uistate,
self.on_popup))
# Replace the standard textview with the fan chart widget: # Replace the standard textview with the fan chart widget:
self.gui.get_container_widget().remove(self.gui.textview) self.gui.get_container_widget().remove(self.gui.textview)
self.gui.get_container_widget().add(self.fan) self.gui.get_container_widget().add(self.fan)
@ -75,7 +59,9 @@ class FanChartDescGramplet(FanChartDescGrampsGUI, Gramplet):
self.fan.show() self.fan.show()
def init(self): def init(self):
self.set_tooltip(_("Click to expand/contract person\nRight-click for options\nClick and drag in open area to rotate")) self.set_tooltip(_("Click to expand/contract person\n"
"Right-click for options\n"
"Click and drag in open area to rotate"))
def active_changed(self, handle): def active_changed(self, handle):
""" """

View File

@ -25,34 +25,16 @@
## Found by redwood: ## Found by redwood:
## http://www.gramps-project.org/bugs/view.php?id=2611 ## http://www.gramps-project.org/bugs/view.php?id=2611
#-------------------------------------------------------------------------
#
# Python modules
#
#-------------------------------------------------------------------------
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Pango
from gi.repository import Gtk
import math
from gi.repository import Gdk
try:
import cairo
except ImportError:
pass
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Gramps modules # Gramps modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.plug import Gramplet
from gramps.gui.widgets.fanchart import (FanChartWidget, FanChartGrampsGUI,
FORM_HALFCIRCLE, BACKGROUND_SCHEME1)
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext _ = glocale.translation.gettext
from gramps.gen.plug import Gramplet
from gramps.gen.errors import WindowActiveError
from gramps.gui.editors import EditPerson
from gramps.gui.widgets.fanchart import (FanChartWidget, FanChartGrampsGUI,
FORM_HALFCIRCLE, BACKGROUND_SCHEME1)
class FanChartGramplet(FanChartGrampsGUI, Gramplet): class FanChartGramplet(FanChartGrampsGUI, Gramplet):
""" """
@ -80,7 +62,8 @@ class FanChartGramplet(FanChartGrampsGUI, Gramplet):
self.fan.show() self.fan.show()
def init(self): def init(self):
self.set_tooltip(_("Click to expand/contract person\nRight-click for options\nClick and drag in open area to rotate")) self.set_tooltip(_("Click to expand/contract person\nRight-click for "
"options\nClick and drag in open area to rotate"))
def active_changed(self, handle): def active_changed(self, handle):
""" """

View File

@ -28,9 +28,9 @@
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gen.const import URL_MANUAL_PAGE
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext _ = glocale.translation.sgettext
from gramps.gen.const import URL_MANUAL_PAGE
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -48,132 +48,132 @@ class FAQGramplet(Gramplet):
calls gui/display.py's display_url method. So no URL_WIKISTRING calls gui/display.py's display_url method. So no URL_WIKISTRING
is needed in this code. is needed in this code.
""" """
faq_dict = { 'bold_start' : '<b>' , faq_dict = {'bold_start': '<b>',
'bold_end' : '</b>' , 'bold_end': '</b>',
'gramps_wiki_html_start' : "<a wiki='" , 'gramps_wiki_html_start': "<a wiki='",
'gramps_manual_html_start' : 'gramps_manual_html_start':
"<a wiki='" + URL_MANUAL_PAGE + "_-_" , "<a wiki='" + URL_MANUAL_PAGE + "_-_",
'gramps_FAQ_html_start' : 'gramps_FAQ_html_start':
"<a wiki='" + URL_MANUAL_PAGE + "_-_FAQ" , "<a wiki='" + URL_MANUAL_PAGE + "_-_FAQ",
'html_middle' : "'>" , 'html_middle': "'>",
'html_end' : '</a>' } 'html_end': '</a>'}
self.render_text( self.render_text(
_("%(bold_start)s%(gramps_FAQ_html_start)s%(html_middle)s" _("%(bold_start)s%(gramps_FAQ_html_start)s%(html_middle)s"
"Frequently Asked Questions" "Frequently Asked Questions"
"%(html_end)s%(bold_end)s" "%(html_end)s%(bold_end)s"
"\n(needs a connection to the internet)\n") % faq_dict ) "\n(needs a connection to the internet)\n") % faq_dict)
self.render_text("\n<b>%s</b>\n\n" % _("Editing Spouses")) self.render_text("\n<b>%s</b>\n\n" % _("Editing Spouses"))
faq_dict.update( faq_dict.update(
{ 'faq_section' : "#How_do_I_change_the_order_of_spouses.3F'>" }) {'faq_section': "#How_do_I_change_the_order_of_spouses.3F'>"})
self.render_text( self.render_text(
_(" 1. %(gramps_FAQ_html_start)s%(faq_section)s" _(" 1. %(gramps_FAQ_html_start)s%(faq_section)s"
"How do I change the order of spouses?" "How do I change the order of spouses?"
"%(html_end)s\n") % faq_dict ) "%(html_end)s\n") % faq_dict)
faq_dict.update( faq_dict.update(
{ 'faq_section' : "#How_do_I_add_an_additional_spouse.3F'>" }) {'faq_section': "#How_do_I_add_an_additional_spouse.3F'>"})
self.render_text( self.render_text(
_(" 2. %(gramps_FAQ_html_start)s%(faq_section)s" _(" 2. %(gramps_FAQ_html_start)s%(faq_section)s"
"How do I add an additional spouse?" "How do I add an additional spouse?"
"%(html_end)s\n") % faq_dict ) "%(html_end)s\n") % faq_dict)
faq_dict.update( faq_dict.update(
{ 'faq_section' : "#How_do_I_remove_a_spouse.3F'>" }) {'faq_section': "#How_do_I_remove_a_spouse.3F'>"})
self.render_text( self.render_text(
_(" 3. %(gramps_FAQ_html_start)s%(faq_section)s" _(" 3. %(gramps_FAQ_html_start)s%(faq_section)s"
"How do I remove a spouse?" "How do I remove a spouse?"
"%(html_end)s\n") % faq_dict ) "%(html_end)s\n") % faq_dict)
self.render_text("\n<b>%s</b>\n\n" % _("Backups and Updates")) self.render_text("\n<b>%s</b>\n\n" % _("Backups and Updates"))
faq_dict.update( faq_dict.update(
{ 'faq_section' : "#How_do_I_keep_backups.3F'>" }) {'faq_section': "#How_do_I_keep_backups.3F'>"})
self.render_text( self.render_text(
_(" 4. %(gramps_FAQ_html_start)s%(faq_section)s" _(" 4. %(gramps_FAQ_html_start)s%(faq_section)s"
"How do I make backups safely?" "How do I make backups safely?"
"%(html_end)s\n") % faq_dict ) "%(html_end)s\n") % faq_dict)
faq_dict.update( faq_dict.update(
{ 'faq_section' : "#How_do_I_upgrade_GRAMPS.3F'>" }) {'faq_section': "#How_do_I_upgrade_GRAMPS.3F'>"})
self.render_text( self.render_text(
_(" 5. %(gramps_FAQ_html_start)s%(faq_section)s" _(" 5. %(gramps_FAQ_html_start)s%(faq_section)s"
"Is it necessary to update Gramps " "Is it necessary to update Gramps "
"every time an update is released?" "every time an update is released?"
"%(html_end)s\n") % faq_dict ) "%(html_end)s\n") % faq_dict)
self.render_text("\n<b>%s</b>\n\n" % _("Data Entry")) self.render_text("\n<b>%s</b>\n\n" % _("Data Entry"))
faq_dict.update( { 'section' : faq_dict.update({'section':
"Entering_and_Editing_Data:_Detailed_-_part_1" "Entering_and_Editing_Data:_Detailed_-_part_1"
"#Editing_Information_About_Relationships'>" }) "#Editing_Information_About_Relationships'>"})
self.render_text( self.render_text(
_(" 6. %(gramps_manual_html_start)s%(section)s" _(" 6. %(gramps_manual_html_start)s%(section)s"
"How should information about marriages be entered?" "How should information about marriages be entered?"
"%(html_end)s\n") % faq_dict ) "%(html_end)s\n") % faq_dict)
faq_dict.update( { 'faq_section' : faq_dict.update({'faq_section':
"#What_is_the_difference_" "#What_is_the_difference_"
"between_a_residence_and_an_address.3F'>" }) "between_a_residence_and_an_address.3F'>"})
self.render_text( self.render_text(
_(" 7. %(gramps_FAQ_html_start)s%(faq_section)s" _(" 7. %(gramps_FAQ_html_start)s%(faq_section)s"
"What's the difference between a residence and an address?" "What's the difference between a residence and an address?"
"%(html_end)s\n") % faq_dict ) "%(html_end)s\n") % faq_dict)
self.render_text("\n<b>%s</b>\n\n" % _("Media Files")) self.render_text("\n<b>%s</b>\n\n" % _("Media Files"))
faq_dict.update( faq_dict.update(
{ 'faq_section' : "#How_do_you_add_photos_to_an_item.3F'>" }) {'faq_section': "#How_do_you_add_photos_to_an_item.3F'>"})
self.render_text( self.render_text(
_(" 8. %(gramps_FAQ_html_start)s%(faq_section)s" _(" 8. %(gramps_FAQ_html_start)s%(faq_section)s"
"How do you add a photo of a person/source/event?" "How do you add a photo of a person/source/event?"
"%(html_end)s\n") % faq_dict ) "%(html_end)s\n") % faq_dict)
faq_dict.update( faq_dict.update(
{ 'faq_section' : "#How_do_you_find_unused_media.3F'>" }) {'faq_section': "#How_do_you_find_unused_media.3F'>"})
self.render_text( self.render_text(
_(" 9. %(gramps_FAQ_html_start)s%(faq_section)s" _(" 9. %(gramps_FAQ_html_start)s%(faq_section)s"
"How do you find unused media objects?" "How do you find unused media objects?"
"%(html_end)s\n") % faq_dict ) "%(html_end)s\n") % faq_dict)
self.render_text("\n<b>%s</b>\n\n" % _("Miscellaneous")) self.render_text("\n<b>%s</b>\n\n" % _("Miscellaneous"))
faq_dict.update( { 'faq_section' : faq_dict.update({'faq_section':
"#How_can_I_publish_web_sites_" "#How_can_I_publish_web_sites_"
"generated_by_GRAMPS.3F'>" }) "generated_by_GRAMPS.3F'>"})
self.render_text( self.render_text(
_(" 10. %(gramps_FAQ_html_start)s%(faq_section)s" _(" 10. %(gramps_FAQ_html_start)s%(faq_section)s"
"How can I make a website with Gramps and my tree?" "How can I make a website with Gramps and my tree?"
"%(html_end)s\n") % faq_dict ) "%(html_end)s\n") % faq_dict)
faq_dict.update( { 'web_html_start' : faq_dict.update({'web_html_start':
"<a href='http://sourceforge.net/mailarchive" "<a href='http://sourceforge.net/mailarchive"
"/message.php?msg_id=21487967'>" }) "/message.php?msg_id=21487967'>"})
self.render_text( self.render_text(
_(" 11. %(web_html_start)s" _(" 11. %(web_html_start)s"
"How do I record one's occupation?" "How do I record one's occupation?"
"%(html_end)s\n") % faq_dict ) "%(html_end)s\n") % faq_dict)
faq_dict.update( faq_dict.update(
{ 'faq_section' : "#What_do_I_do_if_I_have_found_a_bug.3F'>" }) {'faq_section': "#What_do_I_do_if_I_have_found_a_bug.3F'>"})
self.render_text( self.render_text(
_(" 12. %(gramps_FAQ_html_start)s%(faq_section)s" _(" 12. %(gramps_FAQ_html_start)s%(faq_section)s"
"What do I do if I have found a bug?" "What do I do if I have found a bug?"
"%(html_end)s\n") % faq_dict ) "%(html_end)s\n") % faq_dict)
faq_dict.update( { 'section' : "Portal:Using_GRAMPS'>" }) faq_dict.update({'section': "Portal:Using_GRAMPS'>"})
self.render_text( self.render_text(
_(" 13. %(gramps_wiki_html_start)s%(section)s" _(" 13. %(gramps_wiki_html_start)s%(section)s"
"Is there a manual for Gramps?" "Is there a manual for Gramps?"
"%(html_end)s\n") % faq_dict ) "%(html_end)s\n") % faq_dict)
faq_dict.update( { 'section' : "Category:Tutorials'>" }) faq_dict.update({'section': "Category:Tutorials'>"})
self.render_text( self.render_text(
_(" 14. %(gramps_wiki_html_start)s%(section)s" _(" 14. %(gramps_wiki_html_start)s%(section)s"
"Are there tutorials available?" "Are there tutorials available?"
"%(html_end)s\n") % faq_dict ) "%(html_end)s\n") % faq_dict)
faq_dict.update( { 'section' : "Category:How_do_I...'>" }) faq_dict.update({'section': "Category:How_do_I...'>"})
self.render_text( self.render_text(
_(" 15. %(gramps_wiki_html_start)s%(section)s" _(" 15. %(gramps_wiki_html_start)s%(section)s"
"How do I ...?" "How do I ...?"
"%(html_end)s\n") % faq_dict ) "%(html_end)s\n") % faq_dict)
faq_dict.update( { 'section' : "How_you_can_help'>" }) faq_dict.update({'section': "How_you_can_help'>"})
self.render_text( self.render_text(
_(" 16. %(gramps_wiki_html_start)s%(section)s" _(" 16. %(gramps_wiki_html_start)s%(section)s"
"How can I help with Gramps?" "How can I help with Gramps?"
"%(html_end)s\n") % faq_dict ) "%(html_end)s\n") % faq_dict)
self.append_text("", scroll_to='begin') self.append_text("", scroll_to='begin')
def post_init(self): def post_init(self):

View File

@ -19,17 +19,20 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
"""
Module providing a gramplet interface to the sidebar filters.
"""
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Gramps modules # Gramps modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gui.filters.sidebar import (PersonSidebarFilter, FamilySidebarFilter, from gramps.gui.filters.sidebar import (
EventSidebarFilter, SourceSidebarFilter, PersonSidebarFilter, FamilySidebarFilter, EventSidebarFilter,
CitationSidebarFilter, SourceSidebarFilter, CitationSidebarFilter, PlaceSidebarFilter,
PlaceSidebarFilter, MediaSidebarFilter, MediaSidebarFilter, RepoSidebarFilter, NoteSidebarFilter)
RepoSidebarFilter, NoteSidebarFilter)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #

View File

@ -18,11 +18,22 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
#------------------------------------------------------------------------
#
# Gtk
#
#------------------------------------------------------------------------
from gi.repository import Gtk
#------------------------------------------------------------------------
#
# Gramps modules
#
#------------------------------------------------------------------------
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gui.widgets import Photo from gramps.gui.widgets import Photo
from gramps.gen.utils.thumbnails import get_thumbnail_image from gramps.gen.utils.thumbnails import get_thumbnail_image
from gramps.gen.utils.file import media_path_full from gramps.gen.utils.file import media_path_full
from gi.repository import Gtk
class Gallery(Gramplet): class Gallery(Gramplet):
""" """
@ -67,9 +78,8 @@ class Gallery(Gramplet):
else: else:
photo = Photo(self.uistate.screen_height() < 1000) photo = Photo(self.uistate.screen_height() < 1000)
photo.set_pixbuf(full_path, photo.set_pixbuf(full_path,
get_thumbnail_image(full_path, get_thumbnail_image(full_path, mime_type,
mime_type, media_ref.get_rectangle()))
media_ref.get_rectangle()))
self.image_list.append(photo) self.image_list.append(photo)
self.top.pack_start(photo, False, False, 0) self.top.pack_start(photo, False, False, 0)
count += 1 count += 1

View File

@ -18,12 +18,23 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
# #
from collections import defaultdict
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#-------------------------------------------------------------------------
#
# Python modules
#
#-------------------------------------------------------------------------
from collections import defaultdict
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gen.config import config from gramps.gen.config import config
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
_YIELD_INTERVAL = 350 _YIELD_INTERVAL = 350
@ -66,12 +77,12 @@ class GivenNameCloudGramplet(Gramplet):
allnames = [person.get_primary_name()] + person.get_alternate_names() allnames = [person.get_primary_name()] + person.get_alternate_names()
allnames = set(name.get_first_name().strip() for name in allnames) allnames = set(name.get_first_name().strip() for name in allnames)
for givenname in allnames: for givenname in allnames:
anyNBSP = givenname.split('\u00A0') nbsp = givenname.split('\u00A0')
if len(anyNBSP) > 1: # there was an NBSP, a non-breaking space if len(nbsp) > 1: # there was an NBSP, a non-breaking space
first_two = anyNBSP[0] + '\u00A0' + anyNBSP[1].split()[0] first_two = nbsp[0] + '\u00A0' + nbsp[1].split()[0]
givensubnames[first_two] += 1 givensubnames[first_two] += 1
representative_handle[first_two] = person.handle representative_handle[first_two] = person.handle
givenname = ' '.join(anyNBSP[1].split()[1:]) givenname = ' '.join(nbsp[1].split()[1:])
for givensubname in givenname.split(): for givensubname in givenname.split():
givensubnames[givensubname] += 1 givensubnames[givensubname] += 1
representative_handle[givensubname] = person.handle representative_handle[givensubname] = person.handle
@ -84,7 +95,8 @@ class GivenNameCloudGramplet(Gramplet):
total = cnt = 0 total = cnt = 0
for givensubname in givensubnames: for givensubname in givensubnames:
givensubname_sort.append( (givensubnames[givensubname], givensubname) ) givensubname_sort.append((givensubnames[givensubname],
givensubname))
total += givensubnames[givensubname] total += givensubnames[givensubname]
cnt += 1 cnt += 1
if not cnt % _YIELD_INTERVAL: if not cnt % _YIELD_INTERVAL:
@ -96,8 +108,8 @@ class GivenNameCloudGramplet(Gramplet):
cloud_values = [] cloud_values = []
for count, givensubname in givensubname_sort: for count, givensubname in givensubname_sort:
cloud_names.append( (count, givensubname) ) cloud_names.append((count, givensubname))
cloud_values.append( count ) cloud_values.append(count)
cloud_names.sort(key=lambda k: k[1]) cloud_names.sort(key=lambda k: k[1])
counts = sorted(set(cloud_values), reverse=True) counts = sorted(set(cloud_values), reverse=True)

View File

@ -24,14 +24,6 @@
Show uncollected objects in a window. Show uncollected objects in a window.
""" """
#------------------------------------------------------------------------
#
# standard python modules
#
#------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# GNOME/GTK modules # GNOME/GTK modules
@ -49,6 +41,8 @@ import gc
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gui.dialog import InfoDialog from gramps.gui.dialog import InfoDialog
from gramps.gui.utils import is_right_click from gramps.gui.utils import is_right_click
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -108,7 +102,7 @@ class Leak(Gramplet):
apply_button = Gtk.Button(label=_("Refresh")) apply_button = Gtk.Button(label=_("Refresh"))
apply_button.connect('clicked', self.apply_clicked) apply_button.connect('clicked', self.apply_clicked)
bbox.pack_start(apply_button, False, False, 6) bbox.pack_start(apply_button, False, False, 6)
self.top.pack_start(bbox, False, False, 6) self.top.pack_start(bbox, False, False, 6)
self.top.show_all() self.top.show_all()
@ -137,7 +131,7 @@ class Leak(Gramplet):
except ReferenceError: except ReferenceError:
pass pass
InfoDialog(_('Referrers of %d') % count, text, InfoDialog(_('Referrers of %d') % count, text,
parent=self.uistate.window) parent=self.uistate.window)
def refers_to(self): def refers_to(self):
model, iter = self.selection.get_selected() model, iter = self.selection.get_selected()
@ -151,7 +145,7 @@ class Leak(Gramplet):
except ReferenceError: except ReferenceError:
pass pass
InfoDialog(_('%d refers to') % count, text, InfoDialog(_('%d refers to') % count, text,
parent=self.uistate.window) parent=self.uistate.window)
def display(self): def display(self):
try: try:

View File

@ -19,7 +19,7 @@
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Python modules # Gtk modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gi.repository import Gtk from gi.repository import Gtk
@ -162,7 +162,9 @@ class Locations(Gramplet, DbGUIElement):
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class EnclosedBy(Locations): class EnclosedBy(Locations):
"""
Gramplet showing the locations enclosed by the active place.
"""
def display_place(self, place, node, visited): def display_place(self, place, node, visited):
""" """
Display the location hierarchy for the active place. Display the location hierarchy for the active place.
@ -194,7 +196,9 @@ class EnclosedBy(Locations):
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class Encloses(Locations): class Encloses(Locations):
"""
Gramplet showing the locations which the active place encloses.
"""
def display_place(self, place, node, visited): def display_place(self, place, node, visited):
""" """
Display the location hierarchy for the active place. Display the location hierarchy for the active place.

View File

@ -17,10 +17,21 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
#-------------------------------------------------------------------------
#
# Gtk modules
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gui.widgets import Photo from gramps.gui.widgets import Photo
from gramps.gen.utils.file import media_path_full from gramps.gen.utils.file import media_path_full
from gi.repository import Gtk
class MediaPreview(Gramplet): class MediaPreview(Gramplet):
""" """
@ -72,7 +83,6 @@ class MediaPreview(Gramplet):
""" """
Load the primary image if it exists. Load the primary image if it exists.
""" """
self.full_path = media_path_full(self.dbstate.db, self.full_path = media_path_full(self.dbstate.db, media.get_path())
media.get_path())
mime_type = media.get_mime_type() mime_type = media.get_mime_type()
self.photo.set_image(self.full_path, mime_type) self.photo.set_image(self.full_path, mime_type)

View File

@ -18,13 +18,24 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
#------------------------------------------------------------------------
#
# Gtk
#
#------------------------------------------------------------------------
from gi.repository import Gtk
#------------------------------------------------------------------------
#
# Gramps modules
#
#------------------------------------------------------------------------
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gui.widgets.styledtexteditor import StyledTextEditor from gramps.gui.widgets.styledtexteditor import StyledTextEditor
from gramps.gui.widgets import SimpleButton from gramps.gui.widgets import SimpleButton
from gramps.gen.lib import StyledText from gramps.gen.lib import StyledText
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext _ = glocale.translation.gettext
from gi.repository import Gtk
class Notes(Gramplet): class Notes(Gramplet):
""" """
@ -53,7 +64,8 @@ class Notes(Gramplet):
hbox.pack_end(self.page, False, False, 10) hbox.pack_end(self.page, False, False, 10)
scrolledwindow = Gtk.ScrolledWindow() scrolledwindow = Gtk.ScrolledWindow()
scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC,
Gtk.PolicyType.AUTOMATIC)
self.texteditor = StyledTextEditor() self.texteditor = StyledTextEditor()
self.texteditor.set_editable(False) self.texteditor.set_editable(False)
self.texteditor.set_wrap_mode(Gtk.WrapMode.WORD) self.texteditor.set_wrap_mode(Gtk.WrapMode.WORD)
@ -96,8 +108,9 @@ class Notes(Gramplet):
note_handle = self.note_list[self.current] note_handle = self.note_list[self.current]
note = self.dbstate.db.get_note_from_handle(note_handle) note = self.dbstate.db.get_note_from_handle(note_handle)
self.texteditor.set_text(note.get_styledtext()) self.texteditor.set_text(note.get_styledtext())
self.page.set_text(_('%(current)d of %(total)d') % {'current': self.current + 1, self.page.set_text(_('%(current)d of %(total)d') %
'total': len(self.note_list)}) {'current': self.current + 1,
'total': len(self.note_list)})
def left_clicked(self, button): def left_clicked(self, button):
""" """

View File

@ -29,14 +29,16 @@ from html import escape
# Gramps modules # Gramps modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
ngettext = glocale.translation.ngettext # else "nearby" comments are ignored
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gen.display.name import displayer as name_displayer from gramps.gen.display.name import displayer as name_displayer
from gramps.gen.datehandler import get_date from gramps.gen.datehandler import get_date
from gramps.gen.lib import EventType from gramps.gen.lib import EventType
from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback
from gramps.gen.plug.menu import (NumberOption, BooleanOption,
EnumeratedListOption)
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
ngettext = glocale.translation.ngettext # else "nearby" comments are ignored
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -53,7 +55,6 @@ class PedigreeGramplet(Gramplet):
self.box_mode = "UTF" self.box_mode = "UTF"
def build_options(self): def build_options(self):
from gramps.gen.plug.menu import NumberOption, BooleanOption, EnumeratedListOption
self.add_option(NumberOption(_("Max generations"), self.add_option(NumberOption(_("Max generations"),
self.max_generations, 1, 100)) self.max_generations, 1, 100))
self.add_option(BooleanOption(_("Show dates"), bool(self.show_dates))) self.add_option(BooleanOption(_("Show dates"), bool(self.show_dates)))
@ -117,9 +118,9 @@ class PedigreeGramplet(Gramplet):
if self.box_mode == "UTF": if self.box_mode == "UTF":
retval += "-" retval += "-"
retval = retval.replace("\\", "\u2514") retval = retval.replace("\\", "\u2514")
retval = retval.replace("-", "\u2500") retval = retval.replace("-", "\u2500")
retval = retval.replace("|", "\u2502") retval = retval.replace("|", "\u2502")
retval = retval.replace("/", "\u250c") retval = retval.replace("/", "\u250c")
elif self.box_mode == "ASCII": elif self.box_mode == "ASCII":
retval += "--" retval += "--"
return retval return retval
@ -259,7 +260,7 @@ class PedigreeGramplet(Gramplet):
if g == 0: if g == 0:
self.link(_("Generation 1"), 'PersonList', handles, self.link(_("Generation 1"), 'PersonList', handles,
tooltip=_("Double-click to see people in generation")) tooltip=_("Double-click to see people in generation"))
percent = glocale.format( '%.2f', 100) + percent_sign percent = glocale.format('%.2f', 100) + percent_sign
self.append_text(_(" has 1 of 1 individual (%(percent)s complete)\n") % {'percent': percent}) self.append_text(_(" has 1 of 1 individual (%(percent)s complete)\n") % {'percent': percent})
else: else:
all.extend(handles) all.extend(handles)
@ -269,19 +270,19 @@ class PedigreeGramplet(Gramplet):
self.append_text( self.append_text(
# translators: leave all/any {...} untranslated # translators: leave all/any {...} untranslated
ngettext(" has {count_person} of {max_count_person} " ngettext(" has {count_person} of {max_count_person} "
"individuals ({percent} complete)\n", "individuals ({percent} complete)\n",
" has {count_person} of {max_count_person} " " has {count_person} of {max_count_person} "
"individuals ({percent} complete)\n", 2**(g-1) "individuals ({percent} complete)\n", 2**(g-1)
).format(count_person=count, ).format(count_person=count,
max_count_person=2**(g-1), max_count_person=2**(g-1),
percent=percent) ) percent=percent))
self.link(_("All generations"), 'PersonList', all, self.link(_("All generations"), 'PersonList', all,
tooltip=_("Double-click to see all generations")) tooltip=_("Double-click to see all generations"))
self.append_text( self.append_text(
# translators: leave all/any {...} untranslated # translators: leave all/any {...} untranslated
ngettext(" have {number_of} individual\n", ngettext(" have {number_of} individual\n",
" have {number_of} individuals\n", len(all) " have {number_of} individuals\n", len(all)
).format(number_of=len(all)) ) ).format(number_of=len(all)))
# Set to a fixed font # Set to a fixed font
if self.box_mode == "UTF": if self.box_mode == "UTF":
start, end = self.gui.buffer.get_bounds() start, end = self.gui.buffer.get_bounds()

View File

@ -18,17 +18,28 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
#-------------------------------------------------------------------------
#
# Gtk modules
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
from gi.repository import Pango
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.lib import EventType, EventRoleType from gramps.gen.lib import EventType, EventRoleType
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gui.widgets import Photo from gramps.gui.widgets import Photo
from gramps.gen.display.name import displayer as name_displayer from gramps.gen.display.name import displayer as name_displayer
from gramps.gen.display.place import displayer as place_displayer from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.datehandler import get_date from gramps.gen.datehandler import get_date
from gramps.gen.utils.file import media_path_full from gramps.gen.utils.file import media_path_full
from gi.repository import Gtk from gramps.gen.const import GRAMPS_LOCALE as glocale
from gi.repository import Pango _ = glocale.translation.gettext
class PersonDetails(Gramplet): class PersonDetails(Gramplet):
""" """
@ -175,7 +186,7 @@ class PersonDetails(Gramplet):
nlist = active_person.get_alternate_names() nlist = active_person.get_alternate_names()
if len(nlist) > 0: if len(nlist) > 0:
for altname in nlist: for altname in nlist:
name_type = str( altname.get_type() ) name_type = str(altname.get_type())
text = name_displayer.display_name(altname) text = name_displayer.display_name(altname)
self.add_row(name_type, text) self.add_row(name_type, text)
self.display_separator() self.display_separator()
@ -249,7 +260,7 @@ class PersonDetails(Gramplet):
retval = _('%(date)s - %(place)s.') % {'date' : date, retval = _('%(date)s - %(place)s.') % {'date' : date,
'place' : place} 'place' : place}
else: else:
retval = _('%(date)s.') % dict(date = date) retval = _('%(date)s.') % dict(date=date)
return retval return retval
def load_person_image(self, person): def load_person_image(self, person):

View File

@ -17,16 +17,27 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
#-------------------------------------------------------------------------
#
# Gtk modules
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.lib import EventType, EventRoleType from gramps.gen.lib import EventType, EventRoleType
from gramps.gui.editors import EditEvent from gramps.gui.editors import EditEvent
from gramps.gui.listmodel import ListModel, NOSORT from gramps.gui.listmodel import ListModel, NOSORT
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.datehandler import get_date from gramps.gen.datehandler import get_date
from gramps.gen.display.place import displayer as place_displayer from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.errors import WindowActiveError from gramps.gen.errors import WindowActiveError
from gi.repository import Gtk from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
class PersonResidence(Gramplet): class PersonResidence(Gramplet):
""" """

View File

@ -17,15 +17,26 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
#-------------------------------------------------------------------------
#
# Gtk modules
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
from gi.repository import Pango
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gui.widgets import Photo from gramps.gui.widgets import Photo
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.utils.place import conv_lat_lon from gramps.gen.utils.place import conv_lat_lon
from gramps.gen.utils.file import media_path_full from gramps.gen.utils.file import media_path_full
from gramps.gen.display.place import displayer as place_displayer from gramps.gen.display.place import displayer as place_displayer
from gi.repository import Gtk from gramps.gen.const import GRAMPS_LOCALE as glocale
from gi.repository import Pango _ = glocale.translation.gettext
class PlaceDetails(Gramplet): class PlaceDetails(Gramplet):
""" """

View File

@ -30,14 +30,15 @@
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gui.plug.quick import (run_quick_report_by_name,
get_quick_report_list)
from gramps.gen.plug import (
CATEGORY_QR_PERSON, CATEGORY_QR_FAMILY, CATEGORY_QR_EVENT,
CATEGORY_QR_SOURCE, CATEGORY_QR_NOTE, CATEGORY_QR_PLACE,
CATEGORY_QR_MEDIA, CATEGORY_QR_REPOSITORY, CATEGORY_QR_CITATION,
CATEGORY_QR_SOURCE_OR_CITATION)
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext _ = glocale.translation.sgettext
from gramps.gui.plug.quick import run_quick_report_by_name, get_quick_report_list
from gramps.gen.plug import (CATEGORY_QR_PERSON, CATEGORY_QR_FAMILY,
CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE, CATEGORY_QR_NOTE,
CATEGORY_QR_MISC, CATEGORY_QR_PLACE, CATEGORY_QR_MEDIA,
CATEGORY_QR_REPOSITORY, CATEGORY_QR_CITATION,
CATEGORY_QR_SOURCE_OR_CITATION)
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -112,7 +113,7 @@ class QuickViewGramplet(Gramplet):
("Repository", _("Repository")), ("Repository", _("Repository")),
("Source", _("Source")), ("Source", _("Source")),
("Citation", _("Citation")), ("Citation", _("Citation")),
]: ]:
type_list.add_item(item[0], item[1]) type_list.add_item(item[0], item[1])
# Add particular lists: # Add particular lists:
qv_list = get_quick_report_list(CATEGORY_QR_PERSON) qv_list = get_quick_report_list(CATEGORY_QR_PERSON)

View File

@ -20,14 +20,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
#------------------------------------------------------------------------
#
# Standard Python modules
#
#------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# Gramps modules # Gramps modules
@ -35,10 +27,12 @@ _ = glocale.translation.sgettext
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from gramps.plugins.lib.librecords import find_records, CALLNAME_DONTUSE from gramps.plugins.lib.librecords import find_records, CALLNAME_DONTUSE
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# The Gramplet # RecordsGramplet
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class RecordsGramplet(Gramplet): class RecordsGramplet(Gramplet):

View File

@ -22,9 +22,9 @@
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gen.display.name import displayer as name_displayer
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext _ = glocale.translation.sgettext
from gramps.gen.display.name import displayer as name_displayer
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #

View File

@ -17,12 +17,23 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
#-------------------------------------------------------------------------
#
# Gtk
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
from gi.repository import Pango
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.lib import UrlType from gramps.gen.lib import UrlType
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext _ = glocale.translation.gettext
from gi.repository import Gtk
from gi.repository import Pango
class RepositoryDetails(Gramplet): class RepositoryDetails(Gramplet):
""" """

View File

@ -32,10 +32,10 @@ import time
from gramps.gen.lib import Person, Family from gramps.gen.lib import Person, Family
from gramps.gen.db import PERSON_KEY, FAMILY_KEY, TXNDEL from gramps.gen.db import PERSON_KEY, FAMILY_KEY, TXNDEL
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
from gramps.gen.display.name import displayer as name_displayer from gramps.gen.display.name import displayer as name_displayer
from gramps.gen.utils.db import family_name from gramps.gen.utils.db import family_name
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -80,7 +80,7 @@ class LogGramplet(Gramplet):
continue continue
self.last_log = (ltype, action, handle) self.last_log = (ltype, action, handle)
self.timestamp() self.timestamp()
self.append_text("%s: " % _(action) ) self.append_text("%s: " % _(action))
if action == 'Deleted': if action == 'Deleted':
transaction = self.dbstate.db.transaction transaction = self.dbstate.db.transaction
if ltype == 'Person': if ltype == 'Person':
@ -105,7 +105,7 @@ class LogGramplet(Gramplet):
and hndl == handle): and hndl == handle):
family = Family() family = Family()
family.unserialize(old_data) family.unserialize(old_data)
name = family_name(family, self.dbstate.db,name) name = family_name(family, self.dbstate.db, name)
break break
self.append_text(name) self.append_text(name)
else: else:

View File

@ -29,11 +29,11 @@ import posixpath
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
from gramps.gen.utils.file import media_path_full from gramps.gen.utils.file import media_path_full
from gramps.gen.datehandler import get_date from gramps.gen.datehandler import get_date
from gramps.gen.lib import Person from gramps.gen.lib import Person
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -90,9 +90,9 @@ class StatsGramplet(Gramplet):
except OSError: except OSError:
notfound.append(media.get_path()) notfound.append(media.get_path())
males = sum([v[0] for v in database.genderStats.stats.values()]) # male, female, unknown males = sum([v[0] for v in database.genderStats.stats.values()])
females = sum([v[1] for v in database.genderStats.stats.values()]) # male, female, unknown females = sum([v[1] for v in database.genderStats.stats.values()])
unknown = sum([v[2] for v in database.genderStats.stats.values()]) # male, female, unknown unknown = sum([v[2] for v in database.genderStats.stats.values()])
self.clear_text() self.clear_text()
self.append_text(_("Individuals") + "\n") self.append_text(_("Individuals") + "\n")

View File

@ -16,6 +16,11 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#------------------------------------------------------------------------
#
# Python modules
#
#------------------------------------------------------------------------
from collections import defaultdict from collections import defaultdict
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -24,9 +29,9 @@ from collections import defaultdict
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gen.config import config
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext _ = glocale.translation.sgettext
from gramps.gen.config import config
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -91,7 +96,7 @@ class SurnameCloudGramplet(Gramplet):
representative_handle = {} representative_handle = {}
cnt = 0 cnt = 0
namelist =[] namelist = []
for person in self.dbstate.db.iter_people(): for person in self.dbstate.db.iter_people():
allnames = [person.get_primary_name()] + person.get_alternate_names() allnames = [person.get_primary_name()] + person.get_alternate_names()
allnames = set([name.get_group_name().strip() for name in allnames]) allnames = set([name.get_group_name().strip() for name in allnames])
@ -111,7 +116,7 @@ class SurnameCloudGramplet(Gramplet):
surname_sort = [] surname_sort = []
total = cnt = 0 total = cnt = 0
for surname in surnames: for surname in surnames:
surname_sort.append( (surnames[surname], surname) ) surname_sort.append((surnames[surname], surname))
total += surnames[surname] total += surnames[surname]
cnt += 1 cnt += 1
if not cnt % _YIELD_INTERVAL: if not cnt % _YIELD_INTERVAL:
@ -121,10 +126,10 @@ class SurnameCloudGramplet(Gramplet):
cloud_names = [] cloud_names = []
cloud_values = [] cloud_values = []
for (count, surname) in surname_sort: for (count, surname) in surname_sort:
cloud_names.append( (count, surname) ) cloud_names.append((count, surname))
cloud_values.append( count ) cloud_values.append(count)
cloud_names.sort(key=lambda k:k[1]) cloud_names.sort(key=lambda k: k[1])
line = 0 line = 0
### All done! ### All done!
# Now, find out how many we can display without going over top_size: # Now, find out how many we can display without going over top_size:

View File

@ -17,6 +17,18 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
#-------------------------------------------------------------------------
#
# Gtk modules
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gui.widgets.styledtexteditor import StyledTextEditor from gramps.gui.widgets.styledtexteditor import StyledTextEditor
from gramps.gui.widgets import SimpleButton from gramps.gui.widgets import SimpleButton
@ -24,7 +36,6 @@ from gramps.gen.lib import StyledText, Note, NoteType
from gramps.gen.db import DbTxn from gramps.gen.db import DbTxn
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext _ = glocale.translation.gettext
from gi.repository import Gtk
class ToDo(Gramplet): class ToDo(Gramplet):
""" """
@ -122,8 +133,8 @@ class ToDo(Gramplet):
note = self.dbstate.db.get_note_from_handle(note_handle) note = self.dbstate.db.get_note_from_handle(note_handle)
self.texteditor.set_text(note.get_styledtext()) self.texteditor.set_text(note.get_styledtext())
self.page.set_text(_('%(current)d of %(total)d') % self.page.set_text(_('%(current)d of %(total)d') %
{'current': self.current + 1, {'current': self.current + 1,
'total': len(self.note_list)}) 'total': len(self.note_list)})
def left_clicked(self, button): def left_clicked(self, button):
""" """

View File

@ -18,14 +18,24 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
#-------------------------------------------------------------------------
#
# Gtk modules
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gui.widgets.styledtexteditor import StyledTextEditor from gramps.gui.widgets.styledtexteditor import StyledTextEditor
from gramps.gui.widgets import SimpleButton from gramps.gui.widgets import SimpleButton
from gramps.gen.lib import StyledText, Note, NoteType from gramps.gen.lib import StyledText, Note, NoteType
from gramps.gen.filters import GenericFilterFactory, rules from gramps.gen.filters import GenericFilterFactory, rules
from gramps.gen.utils.db import navigation_label from gramps.gen.utils.db import navigation_label
from gramps.gen.db import DbTxn
from gi.repository import Gtk
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext _ = glocale.translation.gettext
@ -139,8 +149,8 @@ class ToDoGramplet(Gramplet):
self.title.set_text(_("Unattached")) self.title.set_text(_("Unattached"))
self.texteditor.set_text(note.get_styledtext()) self.texteditor.set_text(note.get_styledtext())
self.page.set_text(_('%(current)d of %(total)d') % self.page.set_text(_('%(current)d of %(total)d') %
{'current': self.current + 1, {'current': self.current + 1,
'total': len(self.note_list)}) 'total': len(self.note_list)})
def left_clicked(self, button): def left_clicked(self, button):
""" """

View File

@ -21,7 +21,6 @@
# Python modules # Python modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from collections import defaultdict from collections import defaultdict
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -30,16 +29,15 @@ from collections import defaultdict
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gen.config import config
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext _ = glocale.translation.sgettext
from gramps.gen.config import config
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# Constants # Constants
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
_YIELD_INTERVAL = 350 _YIELD_INTERVAL = 350
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -89,7 +87,7 @@ class TopSurnamesGramplet(Gramplet):
cnt = 0 cnt = 0
for surname in surnames: for surname in surnames:
surname_sort.append( (surnames[surname], surname) ) surname_sort.append((surnames[surname], surname))
total += surnames[surname] total += surnames[surname]
cnt += 1 cnt += 1
if not cnt % _YIELD_INTERVAL: if not cnt % _YIELD_INTERVAL:

View File

@ -18,10 +18,9 @@
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# modules # Gtk modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from gi.repository import Gtk from gi.repository import Gtk
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -32,17 +31,15 @@ from gi.repository import Gtk
from gramps.gen.const import URL_WIKISTRING, URL_MANUAL_PAGE, URL_HOMEPAGE from gramps.gen.const import URL_WIKISTRING, URL_MANUAL_PAGE, URL_HOMEPAGE
from gramps.gen.plug import Gramplet from gramps.gen.plug import Gramplet
from gramps.gui.widgets.styledtexteditor import StyledTextEditor from gramps.gui.widgets.styledtexteditor import StyledTextEditor
from gramps.gui.widgets import SimpleButton
from gramps.gen.lib import StyledText, StyledTextTag, StyledTextTagType from gramps.gen.lib import StyledText, StyledTextTag, StyledTextTagType
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext _ = glocale.translation.sgettext
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# functions # Functions
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
def st(text): def st(text):
""" Return text as styled text """ Return text as styled text
""" """
@ -51,15 +48,13 @@ def st(text):
def boldst(text): def boldst(text):
""" Return text as bold styled text """ Return text as bold styled text
""" """
tags = [StyledTextTag(StyledTextTagType.BOLD, True, tags = [StyledTextTag(StyledTextTagType.BOLD, True, [(0, len(text))])]
[(0, len(text))])]
return StyledText(text, tags) return StyledText(text, tags)
def linkst(text, url): def linkst(text, url):
""" Return text as link styled text """ Return text as link styled text
""" """
tags = [StyledTextTag(StyledTextTagType.LINK, url, tags = [StyledTextTag(StyledTextTagType.LINK, url, [(0, len(text))])]
[(0, len(text))])]
return StyledText(text, tags) return StyledText(text, tags)
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -85,60 +80,63 @@ class WelcomeGramplet(Gramplet):
top = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) top = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
scrolledwindow = Gtk.ScrolledWindow() scrolledwindow = Gtk.ScrolledWindow()
scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC,
Gtk.PolicyType.AUTOMATIC)
self.texteditor = StyledTextEditor() self.texteditor = StyledTextEditor()
self.texteditor.set_editable(False) self.texteditor.set_editable(False)
self.texteditor.set_wrap_mode(Gtk.WrapMode.WORD) self.texteditor.set_wrap_mode(Gtk.WrapMode.WORD)
scrolledwindow.add(self.texteditor) scrolledwindow.add(self.texteditor)
self.set_text() self.display_text()
top.pack_start(scrolledwindow, True, True, 0) top.pack_start(scrolledwindow, True, True, 0)
top.show_all() top.show_all()
return top return top
def set_text(self): def display_text(self):
""" """
Display the welcome text. Display the welcome text.
""" """
welcome = boldst(_('Intro')) + '\n\n' welcome = boldst(_('Intro')) + '\n\n'
welcome += _( welcome += _(
'Gramps is a software package designed for genealogical research.' 'Gramps is a software package designed for genealogical research.'
' Although similar to other genealogical programs, Gramps offers ' ' Although similar to other genealogical programs, Gramps offers '
'some unique and powerful features.\n\n') 'some unique and powerful features.\n\n')
welcome += boldst(_('Links')) + '\n\n' welcome += boldst(_('Links')) + '\n\n'
welcome += linkst(_('Home Page'), URL_HOMEPAGE) + '\n' welcome += linkst(_('Home Page'), URL_HOMEPAGE) + '\n'
welcome += linkst(_('Start with Genealogy and Gramps'), welcome += linkst(_('Start with Genealogy and Gramps'),
'%(gramps_wiki_url)sStart_with_Genealogy' % '%(gramps_wiki_url)sStart_with_Genealogy' %
{'gramps_wiki_url': URL_WIKISTRING} ) + '\n' {'gramps_wiki_url': URL_WIKISTRING}) + '\n'
welcome += linkst(_('Gramps online manual'), welcome += linkst(_('Gramps online manual'),
URL_WIKISTRING + URL_MANUAL_PAGE + _('locale_suffix|')) + '\n' URL_WIKISTRING + URL_MANUAL_PAGE +
_('locale_suffix|')) + '\n'
welcome += linkst(_('Ask questions on gramps-users mailing list'), welcome += linkst(_('Ask questions on gramps-users mailing list'),
'%(gramps_home_url)scontact/' % '%(gramps_home_url)scontact/' %
{'gramps_home_url': URL_HOMEPAGE} ) + '\n\n' {'gramps_home_url': URL_HOMEPAGE}) + '\n\n'
welcome += boldst(_('Who makes Gramps?')) + '\n\n' + _( welcome += boldst(_('Who makes Gramps?')) + '\n\n' + _(
'Gramps is created by genealogists for genealogists, organized in the' 'Gramps is created by genealogists for genealogists, organized in'
' Gramps Project.' ' the Gramps Project.'
' Gramps is an Open Source Software package, which means you are ' ' Gramps is an Open Source Software package, which means you are '
'free to make copies and distribute it to anyone you like. It\'s ' 'free to make copies and distribute it to anyone you like. It\'s '
'developed and maintained by a worldwide team of volunteers whose' 'developed and maintained by a worldwide team of volunteers whose'
' goal is to make Gramps powerful, yet easy to use.\n\n') ' goal is to make Gramps powerful, yet easy to use.\n\n')
welcome += boldst(_('Getting Started')) + '\n\n' + _( welcome += boldst(_('Getting Started')) + '\n\n' + _(
'The first thing you must do is to create a new Family Tree. To ' 'The first thing you must do is to create a new Family Tree. To '
'create a new Family Tree (sometimes called \'database\') select ' 'create a new Family Tree (sometimes called \'database\') select '
'"Family Trees" from the menu, pick "Manage Family Trees", press ' '"Family Trees" from the menu, pick "Manage Family Trees", press '
'"New" and name your Family Tree. For more details, please read the ' '"New" and name your Family Tree. For more details, please read '
'information at the links above\n\n') 'the information at the links above\n\n')
welcome += boldst(_('Dashboard View')) + '\n\n' + _( welcome += boldst(_('Dashboard View')) + '\n\n' + _(
'You are currently reading from the "Dashboard" view, where you can' 'You are currently reading from the "Dashboard" view, where you can'
' add your own gramplets. You can also add gramplets to any view by' ' add your own gramplets. You can also add gramplets to any view by'
' adding a sidebar and/or bottombar, and right-clicking to the right' ' adding a sidebar and/or bottombar, and right-clicking to the'
' of the tab.\n\n' ' right of the tab.\n\n'
'You can click the configuration icon in the toolbar to add additional' 'You can click the configuration icon in the toolbar to add'
' columns, while right-click on the background allows to add gramplets.' ' additional columns, while right-click on the background allows to'
' You can also drag the Properties button to reposition the gramplet ' ' add gramplets. You can also drag the Properties button to'
' on this page, and detach the gramplet to float above Gramps.' ' reposition the gramplet on this page, and detach the gramplet to'
' float above Gramps.'
) )
self.texteditor.set_text(welcome) self.texteditor.set_text(welcome)

View File

@ -227,7 +227,7 @@ class WhatNextGramplet(Gramplet):
spouses = [] spouses = []
spouses_queue = [] spouses_queue = []
while (ancestors or families): while ancestors or families:
# (Other) families of parents # (Other) families of parents
for ancestor_group in ancestors_queue.pop(0): for ancestor_group in ancestors_queue.pop(0):
new_family_group = [] new_family_group = []
@ -416,9 +416,7 @@ class WhatNextGramplet(Gramplet):
if not name2: if not name2:
name2 = _("(person with unknown name)") name2 = _("(person with unknown name)")
name = _("%(name1)s and %(name2)s") % { name = _("%(name1)s and %(name2)s") % {'name1': name1, 'name2': name2}
'name1': name1,
'name2': name2}
has_marriage = False has_marriage = False
@ -463,9 +461,7 @@ class WhatNextGramplet(Gramplet):
if not name2: if not name2:
name2 = _("(person with unknown name)") name2 = _("(person with unknown name)")
name = _("%(name1)s and %(name2)s") % { name = _("%(name1)s and %(name2)s") % {'name1': name1, 'name2': name2}
'name1': name1,
'name2': name2}
if self.__family_complete_handle is not None and \ if self.__family_complete_handle is not None and \
self.__family_complete_handle not in family.get_tag_list(): self.__family_complete_handle not in family.get_tag_list():
@ -494,8 +490,8 @@ class WhatNextGramplet(Gramplet):
if missingbits: if missingbits:
return [_("%(type)s: %(list)s") % { return [_("%(type)s: %(list)s") % {
'type': event.get_type(), 'type': event.get_type(),
'list': _(", ").join(missingbits)}] 'list': _(", ").join(missingbits)}]
else: else:
return [] return []