2009-02-01 22:12:57 +05:30
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
|
|
|
# Copyright (C) 2007-2009 Douglas S. Blank <doug.blank@gmail.com>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Python modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2009-10-26 01:59:45 +05:30
|
|
|
from gen.plug import Gramplet
|
2009-02-01 22:12:57 +05:30
|
|
|
from TransUtils import sgettext as _
|
|
|
|
from QuickReports import run_quick_report_by_name, get_quick_report_list
|
2009-10-24 19:23:20 +05:30
|
|
|
from gen.plug import (CATEGORY_QR_PERSON, CATEGORY_QR_FAMILY,
|
2009-02-01 22:12:57 +05:30
|
|
|
CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE,
|
2009-12-31 20:29:44 +05:30
|
|
|
CATEGORY_QR_MISC, CATEGORY_QR_PLACE, CATEGORY_QR_MEDIA,
|
2009-02-01 22:12:57 +05:30
|
|
|
CATEGORY_QR_REPOSITORY)
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Gramplet class
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
class QuickViewGramplet(Gramplet):
|
|
|
|
def active_changed(self, handle):
|
|
|
|
self.update()
|
|
|
|
|
|
|
|
def main(self):
|
|
|
|
qv_type = self.get_option(_("View Type"))
|
|
|
|
quick_type = qv_type.get_value()
|
|
|
|
qv_option = self.get_option(_("Quick Views"))
|
|
|
|
quick_view = qv_option.get_value()
|
|
|
|
if quick_type == CATEGORY_QR_PERSON:
|
2010-01-11 00:49:33 +05:30
|
|
|
active_handle = self.get_active('Person')
|
|
|
|
if active_handle:
|
2009-02-01 22:12:57 +05:30
|
|
|
run_quick_report_by_name(self.gui.dbstate,
|
|
|
|
self.gui.uistate,
|
|
|
|
quick_view,
|
2010-01-11 00:49:33 +05:30
|
|
|
active_handle,
|
2009-02-01 22:12:57 +05:30
|
|
|
container=self.gui.textview)
|
|
|
|
else:
|
|
|
|
active_list = []
|
2009-12-31 20:29:44 +05:30
|
|
|
for pages in self.gui.uistate.viewmanager.pages:
|
|
|
|
for item in pages:
|
|
|
|
if (item.get_title() == _("Families") and
|
|
|
|
quick_type == CATEGORY_QR_FAMILY):
|
|
|
|
active_list += item.selected_handles()
|
|
|
|
elif (item.get_title() == _("Events") and
|
|
|
|
quick_type == CATEGORY_QR_EVENT):
|
|
|
|
active_list += item.selected_handles()
|
|
|
|
elif (item.get_title() == _("Sources") and
|
|
|
|
quick_type == CATEGORY_QR_SOURCE):
|
|
|
|
active_list += item.selected_handles()
|
|
|
|
elif (item.get_title() == _("Places") and
|
|
|
|
quick_type == CATEGORY_QR_PLACE):
|
|
|
|
active_list += item.selected_handles()
|
|
|
|
elif (item.get_title() == _("Media") and
|
|
|
|
quick_type == CATEGORY_QR_MEDIA):
|
|
|
|
active_list += item.selected_handles()
|
|
|
|
elif (item.get_title() == _("Repositories") and
|
|
|
|
quick_type == CATEGORY_QR_REPOSITORY):
|
|
|
|
active_list += item.selected_handles()
|
|
|
|
if len(active_list) > 1:
|
|
|
|
for active in active_list:
|
|
|
|
run_quick_report_by_name(self.gui.dbstate,
|
|
|
|
self.gui.uistate,
|
|
|
|
quick_view,
|
|
|
|
active)
|
|
|
|
elif len(active_list) == 1:
|
|
|
|
run_quick_report_by_name(self.gui.dbstate,
|
|
|
|
self.gui.uistate,
|
|
|
|
quick_view,
|
|
|
|
active_list[0],
|
|
|
|
container=self.gui.textview)
|
2009-02-01 22:12:57 +05:30
|
|
|
|
|
|
|
def build_options(self):
|
|
|
|
from gen.plug.menu import EnumeratedListOption
|
|
|
|
# Add types:
|
|
|
|
type_list = EnumeratedListOption(_("View Type"), CATEGORY_QR_PERSON)
|
2009-06-08 00:34:11 +05:30
|
|
|
for item in [(CATEGORY_QR_PERSON, _("Person")),
|
2009-02-01 22:12:57 +05:30
|
|
|
#TODO: add these once they have active change signals
|
2009-12-31 20:29:44 +05:30
|
|
|
(CATEGORY_QR_EVENT, _("Event")),
|
|
|
|
(CATEGORY_QR_FAMILY, _("Family")),
|
|
|
|
(CATEGORY_QR_MEDIA, _("Media")),
|
|
|
|
(CATEGORY_QR_PLACE, _("Place")),
|
|
|
|
(CATEGORY_QR_REPOSITORY, _("Repository")),
|
|
|
|
(CATEGORY_QR_SOURCE, _("Source")),
|
2009-02-01 22:12:57 +05:30
|
|
|
]:
|
|
|
|
type_list.add_item(item[0], item[1])
|
|
|
|
# Add particular lists:
|
|
|
|
qv_list = get_quick_report_list(CATEGORY_QR_PERSON)
|
2009-11-07 19:01:36 +05:30
|
|
|
list_option = EnumeratedListOption(_("Quick Views"),
|
|
|
|
qv_list[0].id)
|
2009-10-24 19:23:20 +05:30
|
|
|
for pdata in qv_list:
|
|
|
|
list_option.add_item(pdata.id, pdata.name)
|
2009-02-01 22:12:57 +05:30
|
|
|
self.add_option(type_list)
|
|
|
|
self.add_option(list_option)
|
|
|
|
type_widget = self.get_option_widget(_("View Type"))
|
|
|
|
type_widget.value_changed = self.rebuild_option_list
|
|
|
|
|
|
|
|
def rebuild_option_list(self):
|
|
|
|
qv_option = self.get_option(_("View Type"))
|
|
|
|
list_option = self.get_option(_("Quick Views"))
|
|
|
|
list_option.clear()
|
|
|
|
qv_list = get_quick_report_list(qv_option.get_value())
|
2009-10-24 19:23:20 +05:30
|
|
|
for pdata in qv_list:
|
|
|
|
list_option.add_item(pdata.id, pdata.name)
|