diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 7321fa975..81c0a1f4a 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,7 @@ +2004-05-08 Alex Roitman + * src/plugins/EventCmp.py: Convert to db. + * src/plugins/eventcmp.glade: HIGify dialogs. + 2004-05-07 Don Allingham * src/DbPrompter.py: handle open dialog in a clean manner * src/gramps.py: handle open dialog in a clean manner diff --git a/gramps2/src/plugins/EventCmp.py b/gramps2/src/plugins/EventCmp.py index fafa9c718..3f601e00e 100644 --- a/gramps2/src/plugins/EventCmp.py +++ b/gramps2/src/plugins/EventCmp.py @@ -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") ) - diff --git a/gramps2/src/plugins/eventcmp.glade b/gramps2/src/plugins/eventcmp.glade index 56f3bc99d..6629b544c 100644 --- a/gramps2/src/plugins/eventcmp.glade +++ b/gramps2/src/plugins/eventcmp.glade @@ -12,7 +12,12 @@ False True False - True + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + False @@ -25,19 +30,6 @@ True GTK_BUTTONBOX_END - - - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - 0 - - - - True @@ -46,10 +38,25 @@ gtk-cancel True GTK_RELIEF_NORMAL + True 0 + + + + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + True + 0 + + + 0 @@ -60,40 +67,107 @@ - + True + 6 + 3 False - 0 + 0 + 0 True - Save data as a spreadsheet - False - False + <b>File _name:</b> + True + True GTK_JUSTIFY_CENTER False False - 0.5 + 0 0.5 0 0 - 0 - False - False + 0 + 3 + 0 + 1 + 6 + fill + - + True + True + _OpenOffice.org Spreadsheet + True + GTK_RELIEF_NORMAL + True + True + False + True - 5 - True - True + 1 + 3 + 3 + 4 + 6 + fill + + + + + + + True + _HTML + True + GTK_RELIEF_NORMAL + True + False + False + True + openoffice + + + + 1 + 3 + 4 + 5 + 6 + fill + + + + + + + HTML _Template: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 5 + 0 + htmlfile + + + 1 + 2 + 5 + 6 + 6 + @@ -105,6 +179,7 @@ Save Data False False + False @@ -121,154 +196,71 @@ - 5 - False - False + 1 + 3 + 1 + 2 + 6 + - - True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN + + False + HtmlTemplate + 10 + Choose the HTML template + False + False + False - - + + True - False - 0 - - - - True - True - OpenOffice Spreadsheet - True - GTK_RELIEF_NORMAL - True - False - True - - - 0 - False - False - - - - - - True - HTML - True - GTK_RELIEF_NORMAL - False - False - True - openoffice - - - - 0 - False - False - - - - - - True - False - 0 - - - - - - - - Template - False - False - GTK_JUSTIFY_CENTER - False - False - 1 - 0.5 - 5 - 0 - - - 0 - True - True - - - - - - False - HtmlTemplate - 10 - Choose the HTML template - False - False - - - - True - True - True - True - 0 - - True - * - False - - - - - 0 - True - True - - - - - 0 - True - True - - + True + True + True + 0 + + True + * + False - - - - True - Format - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - label_item - - - 0 - True - True + 2 + 3 + 5 + 6 + 6 + + + + + + + True + <b>_Format:</b> + True + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 3 + 2 + 3 + 6 + fill + @@ -292,6 +284,11 @@ 400 True False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST False @@ -305,19 +302,6 @@ True GTK_BUTTONBOX_END - - - True - True - True - gtk-save-as - True - GTK_RELIEF_NORMAL - 0 - - - - True @@ -326,10 +310,25 @@ gtk-close True GTK_RELIEF_NORMAL + True 0 + + + + True + True + True + gtk-save-as + True + GTK_RELIEF_NORMAL + True + 0 + + + 0 @@ -419,6 +418,11 @@ 400 True False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST False @@ -432,19 +436,6 @@ True GTK_BUTTONBOX_END - - - True - True - True - gtk-apply - True - GTK_RELIEF_NORMAL - 0 - - - - True @@ -453,10 +444,25 @@ gtk-close True GTK_RELIEF_NORMAL + True -7 + + + + True + True + True + gtk-apply + True + GTK_RELIEF_NORMAL + True + 0 + + + 0 @@ -532,6 +538,7 @@ _Custom filter editor True GTK_RELIEF_NORMAL + True