* src/plugins/EventCmp.py: Convert to db.

* src/plugins/eventcmp.glade: HIGify dialogs.


svn: r3145
This commit is contained in:
Alex Roitman 2004-05-09 03:44:59 +00:00
parent 1b8fa18cc7
commit 3b246d35be
3 changed files with 258 additions and 219 deletions

View File

@ -1,3 +1,7 @@
2004-05-08 Alex Roitman <shura@alex.neuro.umn.edu>
* src/plugins/EventCmp.py: Convert to db.
* src/plugins/eventcmp.glade: HIGify dialogs.
2004-05-07 Don Allingham <donaldallingham@users.sourceforge.net>
* src/DbPrompter.py: handle open dialog in a clean manner
* src/gramps.py: handle open dialog in a clean manner

View File

@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2003 Donald N. Allingham
# Copyright (C) 2000-2004 Donald N. Allingham
#
# 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
@ -44,7 +44,7 @@ import gtk.glade
#------------------------------------------------------------------------
import GenericFilter
import ListModel
import sort
import Sort
import Utils
import BaseDoc
import OpenSpreadSheet
@ -139,7 +139,7 @@ class EventComparison:
"destroy_passed_object" : Utils.destroy_passed_object
})
top =self.filterDialog.get_widget("filters")
top = self.filterDialog.get_widget("filters")
self.filters = self.filterDialog.get_widget("filter_list")
Utils.set_titles(top,self.filterDialog.get_widget('title'),
@ -165,12 +165,12 @@ class EventComparison:
def on_apply_clicked(self,obj):
cfilter = self.filter_menu.get_active().get_data("filter")
plist = cfilter.apply(self.db,self.db.get_person_id_map().values())
plist = cfilter.apply(self.db,self.db.get_person_keys())
if len(plist) == 0:
WarningDialog(_("No matches were found"))
else:
DisplayChart(plist)
DisplayChart(self.db,plist)
#------------------------------------------------------------------------
#
@ -203,7 +203,8 @@ def fix(line):
#
#-------------------------------------------------------------------------
class DisplayChart:
def __init__(self,people_list):
def __init__(self,database,people_list):
self.db = database
self.my_list = people_list
self.row_data = []
@ -222,7 +223,8 @@ class DisplayChart:
Utils.set_titles(self.top, self.topDialog.get_widget('title'),
_('Event Comparison'))
self.my_list.sort(sort.by_last_name)
self.sort = Sort.Sort(self.db)
self.my_list.sort(self.sort.by_last_name)
self.event_titles = self.make_event_titles()
self.build_row_data()
@ -242,33 +244,61 @@ class DisplayChart:
self.list.add(data)
def build_row_data(self):
for individual in self.my_list:
for individual_id in self.my_list:
individual = self.db.find_person_from_id(individual_id)
name = individual.get_primary_name().get_name()
birth = individual.get_birth()
death = individual.get_death()
birth_id = individual.get_birth_id()
bdate = ""
bplace = ""
if birth_id:
birth = self.db.find_event_from_id(birth_id)
bdate = birth.get_date()
bplace_id = birth.get_place_id()
if bplace_id:
bplace = self.db.find_place_from_id(bplace_id).get_title()
death_id = individual.get_death_id()
ddate = ""
dplace = ""
if death_id:
death = self.db.find_event_from_id(death_id)
ddate = death.get_date()
dplace_id = death.get_place_id()
if dplace_id:
dplace = self.db.find_place_from_id(dplace_id).get_title()
map = {}
elist = individual.get_event_list()[:]
for ievent in elist:
for ievent_id in elist:
if not ievent_id:
continue
ievent = self.db.find_event_from_id(ievent_id)
event_name = ievent.get_name()
if map.has_key(event_name):
map[event_name].append(ievent)
map[event_name].append(ievent_id)
else:
map[event_name] = [ievent]
map[event_name] = [ievent_id]
first = 1
done = 0
while done == 0:
added = 0
if first:
tlist = [name,"%s\n%s" % (birth.get_date(),birth.get_place_name()),
"%s\n%s" % (death.get_date(),death.get_place_name())]
tlist = [name,"%s\n%s" % (bdate,bplace),
"%s\n%s" % (ddate,dplace)]
else:
tlist = ["","",""]
for ename in self.event_titles[3:]:
if map.has_key(ename) and len(map[ename]) > 0:
event = map[ename][0]
event_id = map[ename][0]
del map[ename][0]
tlist.append("%s\n%s" % (event.get_date(), event.get_place_name()))
date = ""
place = ""
if event_id:
event = self.db.find_event_from_id(event_id)
date = event.get_date()
place_id = event.get_place_id()
if place_id:
place = self.db.find_place_from_id(place_id).get_title()
tlist.append("%s\n%s" % (date, place))
added = 1
else:
tlist.append("")
@ -285,9 +315,13 @@ class DisplayChart:
"""Creates the list of unique event types, along with the person's
name, birth, and death. This should be the column titles of the report"""
map = {}
for individual in self.my_list:
for individual_id in self.my_list:
individual = self.db.find_person_from_id(individual_id)
elist = individual.get_event_list()
for event in elist:
for event_id in elist:
if not event_id:
continue
event = self.db.find_event_from_id(event_id)
name = event.get_name()
if not name:
break
@ -296,14 +330,9 @@ class DisplayChart:
else:
map[name] = 1
unsort_list = []
for item in map.keys():
unsort_list.append((map[item],item))
unsort_list = [ (map[item],item) for item in map.keys() ]
unsort_list.sort(by_value)
sort_list = []
for item in unsort_list:
sort_list.append(item[1])
sort_list = [ item[1] for item in unsort_list ]
return [_("Person"),_("Birth"),_("Death")] + sort_list
@ -315,7 +344,7 @@ class DisplayChart:
"destroy_passed_object" : Utils.destroy_passed_object
})
self.save_form = self.form.get_widget("dialog1")
self.save_form.show()
self.save_form.show_all()
def on_html_toggled(self,obj):
active = self.form.get_widget("html").get_active()
@ -356,4 +385,3 @@ register_tool(
"development of custom filters that can be applied "
"to the database to find similar events")
)

View File

@ -12,7 +12,12 @@
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="has_separator">True</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox2">
@ -25,19 +30,6 @@
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="button14">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="response_id">0</property>
<signal name="clicked" handler="on_save_clicked" object="dialog1"/>
</widget>
</child>
<child>
<widget class="GtkButton" id="button16">
<property name="visible">True</property>
@ -46,10 +38,25 @@
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="destroy_passed_object" object="dialog1"/>
</widget>
</child>
<child>
<widget class="GtkButton" id="button14">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="on_save_clicked" object="dialog1"/>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
@ -60,40 +67,107 @@
</child>
<child>
<widget class="GtkVBox" id="vbox3">
<widget class="GtkTable" id="table2">
<property name="visible">True</property>
<property name="n_rows">6</property>
<property name="n_columns">3</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<property name="row_spacing">0</property>
<property name="column_spacing">0</property>
<child>
<widget class="GtkLabel" id="labelTitle">
<property name="visible">True</property>
<property name="label" translatable="yes">Save data as a spreadsheet</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="label" translatable="yes">&lt;b&gt;File _name:&lt;/b&gt;</property>
<property name="use_underline">True</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="left_attach">0</property>
<property name="right_attach">3</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_padding">6</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkHSeparator" id="hseparator1">
<widget class="GtkRadioButton" id="openoffice">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_OpenOffice.org Spreadsheet</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">True</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">5</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="left_attach">1</property>
<property name="right_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_padding">6</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="html">
<property name="can_focus">True</property>
<property name="label" translatable="yes">_HTML</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<property name="group">openoffice</property>
<signal name="toggled" handler="on_html_toggled" object="dialog1"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">3</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_padding">6</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label11">
<property name="label" translatable="yes">HTML _Template:</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">5</property>
<property name="ypad">0</property>
<property name="mnemonic_widget">htmlfile</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_padding">6</property>
<property name="y_options"></property>
</packing>
</child>
@ -105,6 +179,7 @@
<property name="browse_dialog_title" translatable="yes">Save Data</property>
<property name="directory_entry">False</property>
<property name="modal">False</property>
<property name="use_filechooser">False</property>
<child internal-child="entry">
<widget class="GtkEntry" id="filename">
@ -121,89 +196,12 @@
</child>
</widget>
<packing>
<property name="padding">5</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame1">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="label_yalign">0.5</property>
<property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
<child>
<widget class="GtkVBox" id="vbox4">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkRadioButton" id="openoffice">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">OpenOffice Spreadsheet</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="active">True</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="html">
<property name="can_focus">True</property>
<property name="label" translatable="yes">HTML</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<property name="group">openoffice</property>
<signal name="toggled" handler="on_html_toggled" object="dialog1"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<placeholder/>
</child>
<child>
<widget class="GtkLabel" id="label11">
<property name="label" translatable="yes">Template</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">1</property>
<property name="yalign">0.5</property>
<property name="xpad">5</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="left_attach">1</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_padding">6</property>
<property name="y_options"></property>
</packing>
</child>
@ -215,6 +213,7 @@
<property name="browse_dialog_title" translatable="yes">Choose the HTML template</property>
<property name="directory_entry">False</property>
<property name="modal">False</property>
<property name="use_filechooser">False</property>
<child internal-child="entry">
<widget class="GtkEntry" id="htmlfile">
@ -231,44 +230,37 @@
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_padding">6</property>
<property name="y_options"></property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label1">
<widget class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="label" translatable="yes">Format</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="label" translatable="yes">&lt;b&gt;_Format:&lt;/b&gt;</property>
<property name="use_underline">True</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="left_attach">0</property>
<property name="right_attach">3</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_padding">6</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
</widget>
@ -292,6 +284,11 @@
<property name="default_height">400</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
@ -305,19 +302,6 @@
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="button19">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-save-as</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="response_id">0</property>
<signal name="clicked" handler="on_write_table" object="view"/>
</widget>
</child>
<child>
<widget class="GtkButton" id="button21">
<property name="visible">True</property>
@ -326,10 +310,25 @@
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="destroy_passed_object" object="view"/>
</widget>
</child>
<child>
<widget class="GtkButton" id="button19">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-save-as</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="on_write_table" object="view"/>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
@ -419,6 +418,11 @@
<property name="default_width">400</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
@ -432,19 +436,6 @@
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="button26">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-apply</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="response_id">0</property>
<signal name="clicked" handler="on_apply_clicked" object="filters"/>
</widget>
</child>
<child>
<widget class="GtkButton" id="button27">
<property name="visible">True</property>
@ -453,10 +444,25 @@
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-7</property>
<signal name="clicked" handler="destroy_passed_object" object="filters"/>
</widget>
</child>
<child>
<widget class="GtkButton" id="button26">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-apply</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="on_apply_clicked" object="filters"/>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
@ -532,6 +538,7 @@
<property name="label" translatable="yes">_Custom filter editor</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_editor_clicked" last_modification_time="Wed, 12 Mar 2003 00:28:59 GMT"/>
</widget>
<packing>