From 068ff60c2b6aab28caaf68522918d12a361d8caa Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Thu, 26 Feb 2004 03:34:19 +0000 Subject: [PATCH] More windows updates and small fixes svn: r2914 --- gramps2/src/EditPlace.py | 91 +++++++++++++++++++++++++++++++------- gramps2/src/LocEdit.py | 43 +++++++++++++++--- gramps2/src/MediaView.py | 3 +- gramps2/src/PlaceView.py | 9 ++-- gramps2/src/SourceView.py | 10 ++--- gramps2/src/UrlEdit.py | 2 +- gramps2/src/dialog.glade | 3 ++ gramps2/src/gramps_main.py | 6 +-- gramps2/src/places.glade | 5 ++- 9 files changed, 133 insertions(+), 39 deletions(-) diff --git a/gramps2/src/EditPlace.py b/gramps2/src/EditPlace.py index 751b6346f..7e414dd88 100644 --- a/gramps2/src/EditPlace.py +++ b/gramps2/src/EditPlace.py @@ -65,15 +65,24 @@ pycode_tgts = [('url', 0, 0)] class EditPlace: def __init__(self,parent,place,func=None,parent_window=None): + self.parent = parent + if place.get_id(): + if self.parent.child_windows.has_key(place.get_id()): + self.parent.child_windows[place.get_id()].present(None) + return + else: + self.win_key = place.get_id() + else: + self.win_key = self self.place = place self.db = parent.db - self.parent = parent + self.child_windows = {} self.callback = func self.path = parent.db.get_save_path() self.not_loaded = 1 self.ref_not_loaded = 1 self.lists_changed = 0 - self.gallery_ok = 0 + self.gallery_ok = 0 if place: self.srcreflist = place.get_source_references() else: @@ -180,7 +189,10 @@ class EditPlace: "on_delete_loc_clicked" : self.on_delete_loc_clicked, "on_update_loc_clicked" : self.on_update_loc_clicked, "on_web_go_clicked" : self.on_web_go_clicked, - "on_help_clicked" : self.on_help_clicked, + "on_help_clicked" : self.on_help_clicked, + "on_delete_event" : self.on_delete_event, + "on_cancel_clicked" : self.close, + "on_apply_clicked" : self.on_place_apply_clicked, }) self.sourcetab = Sources.SourceTab(self.srcreflist,self, @@ -207,16 +219,56 @@ class EditPlace: self.display_references() if parent_window: self.top.set_transient_for(parent_window) - self.val = self.top.run() - if self.val == gtk.RESPONSE_OK: - self.on_place_apply_clicked() + self.add_itself_to_menu() + self.top.show() + + def on_delete_event(self,obj,b): self.glry.close(self.gallery_ok) + self.close_child_windows() + self.remove_itself_from_menu() + + def close(self,obj): + self.glry.close(self.gallery_ok) + self.close_child_windows() + self.remove_itself_from_menu() self.top.destroy() + def close_child_windows(self): + for child_window in self.child_windows.values(): + child_window.close(None) + self.child_windows = {} + + def add_itself_to_menu(self): + self.parent.child_windows[self.win_key] = self + if not self.place.get_title(): + label = _("New Place") + else: + label = self.place.get_title() + if not label.strip(): + label = _("New Place") + label = "%s: %s" % (_('Place'),label) + self.parent_menu_item = gtk.MenuItem(label) + self.parent_menu_item.set_submenu(gtk.Menu()) + self.parent_menu_item.show() + self.parent.winsmenu.append(self.parent_menu_item) + self.winsmenu = self.parent_menu_item.get_submenu() + self.menu_item = gtk.MenuItem(_('Place Editor')) + self.menu_item.connect("activate",self.present) + self.menu_item.show() + self.winsmenu.append(self.menu_item) + + def remove_itself_from_menu(self): + del self.parent.child_windows[self.win_key] + self.menu_item.destroy() + self.winsmenu.destroy() + self.parent_menu_item.destroy() + + def present(self,obj): + self.top.present() + def on_help_clicked(self,obj): """Display the relevant portion of GRAMPS manual""" gnome.help_display('gramps-manual','gramps-edit-complete') - self.val = self.top.run() def build_columns(self,tree,list): cnum = 0 @@ -288,12 +340,12 @@ class EditPlace: setf(text) Utils.modified() - def on_place_apply_clicked(self): + def on_place_apply_clicked(self,obj): note = unicode(self.note_buffer.get_text(self.note_buffer.get_start_iter(), self.note_buffer.get_end_iter(),gtk.FALSE)) format = self.preform.get_active() - mloc = self.place.get_main_location() + mloc = self.place.get_main_location() self.set(self.city,mloc.get_city,mloc.set_city) self.set(self.parish,mloc.get_parish,mloc.set_parish) @@ -320,12 +372,14 @@ class EditPlace: self.place.set_note_format(format) Utils.modified() - self.gallery_ok = 1 + self.gallery_ok = 1 self.update_lists() if self.callback: self.callback(self.place) + self.close(obj) + def on_switch_page(self,obj,a,page): if page == 4 and self.not_loaded: self.not_loaded = 0 @@ -428,12 +482,15 @@ class EditPlace: msg = "" for key in self.db.get_person_keys(): p = self.db.get_person(key) - for event in [p.get_birth(), p.get_death()] + p.get_event_list(): - if event.get_place_id() == self.place: + for event_id in [p.get_birth_id(), p.get_death_id()] + p.get_event_list(): + event = self.db.find_event_from_id(event_id) + if event and event.get_place_id() == self.place: pevent.append((p,event)) - for f in self.db.get_family_id_map().values(): - for event in f.get_event_list(): - if event.get_place_id() == self.place: + for family_id in self.db.get_family_keys(): + f = self.db.find_family_from_id(family_id) + for event_id in f.get_event_list(): + event = self.db.find_event_from_id(event_id) + if event and event.get_place_id() == self.place: fevent.append((f,event)) any = 0 @@ -457,8 +514,8 @@ class EditPlace: mother = e[0].get_mother_id() if father and mother: fname = _("%(father)s and %(mother)s") % { - "father" : GrampsCfg.nameof(father), - "mother" : GrampsCfg.nameof(mother) } + "father" : GrampsCfg.nameof(father), + "mother" : GrampsCfg.nameof(mother) } elif father: fname = "%s" % GrampsCfg.nameof(father) else: diff --git a/gramps2/src/LocEdit.py b/gramps2/src/LocEdit.py index 13021d398..747aba92c 100644 --- a/gramps2/src/LocEdit.py +++ b/gramps2/src/LocEdit.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 @@ -49,6 +49,14 @@ class LocationEditor: def __init__(self,parent,location,parent_window=None): self.parent = parent + if location: + if self.parent.child_windows.has_key(location): + self.parent.child_windows[location].present(None) + return + else: + self.win_key = location + else: + self.win_key = self self.location = location self.top = gtk.glade.XML(const.dialogFile, "loc_edit","gramps") self.window = self.top.get_widget("loc_edit") @@ -75,21 +83,43 @@ class LocationEditor: self.window.set_data("o",self) self.top.signal_autoconnect({ "on_help_loc_clicked" : self.on_help_clicked, + "on_ok_loc_clicked" : self.on_location_edit_ok_clicked, + "on_cancel_loc_clicked" : self.close, + "on_loc_delete_event" : self.on_delete_event, }) if parent_window: self.window.set_transient_for(parent_window) - self.val = self.window.run() - if self.val == gtk.RESPONSE_OK: - self.on_location_edit_ok_clicked() + self.add_itself_to_menu() + self.window.show() + + def on_delete_event(self,obj,b): + self.close_child_windows() + self.remove_itself_from_menu() + + def close(self,obj): + self.remove_itself_from_menu() self.window.destroy() + + def add_itself_to_menu(self): + self.parent.child_windows[self.win_key] = self + self.parent_menu_item = gtk.MenuItem(_('Location Editor')) + self.parent_menu_item.connect("activate",self.present) + self.parent_menu_item.show() + self.parent.winsmenu.append(self.parent_menu_item) + + def remove_itself_from_menu(self): + del self.parent.child_windows[self.win_key] + self.parent_menu_item.destroy() + + def present(self,obj): + self.window.present() def on_help_clicked(self,obj): """Display the relevant portion of GRAMPS manual""" gnome.help_display('gramps-manual','gramps-edit-complete') - self.val = self.window.run() - def on_location_edit_ok_clicked(self): + def on_location_edit_ok_clicked(self,obj): self.location = self.location city = unicode(self.city.get_text()) @@ -107,6 +137,7 @@ class LocationEditor: self.update_location(city,parish,county,state,phone,postal,country) self.parent.redraw_location_list() + self.close(obj) def update_location(self,city,parish,county,state,phone,postal,country): if self.location.get_city() != city: diff --git a/gramps2/src/MediaView.py b/gramps2/src/MediaView.py index d549e44e9..81efa9d2f 100644 --- a/gramps2/src/MediaView.py +++ b/gramps2/src/MediaView.py @@ -64,7 +64,8 @@ from gettext import gettext as _ # #------------------------------------------------------------------------- class MediaView: - def __init__(self,db,glade,update): + def __init__(self,parent,db,glade,update): + self.parent = parent self.db = db self.list = glade.get_widget("media_list") self.mid = glade.get_widget("mid") diff --git a/gramps2/src/PlaceView.py b/gramps2/src/PlaceView.py index f300e865b..cab39de39 100644 --- a/gramps2/src/PlaceView.py +++ b/gramps2/src/PlaceView.py @@ -52,7 +52,8 @@ from gettext import gettext as _ #------------------------------------------------------------------------- class PlaceView: - def __init__(self,db,glade,update): + def __init__(self,parent,db,glade,update): + self.parent = parent self.db = db self.glade = glade self.list = glade.get_widget("place_list") @@ -164,7 +165,7 @@ class PlaceView: mlist = [] self.selection.selected_foreach(self.blist,mlist) if mlist: - EditPlace.EditPlace(self,mlist[0],self.update_display,self.topWindow) + EditPlace.EditPlace(self.parent,mlist[0],self.update_display,self.topWindow) return 1 elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3: self.build_context_menu(event) @@ -214,7 +215,7 @@ class PlaceView: self.update(0) def on_add_place_clicked(self,obj): - EditPlace.EditPlace(self,RelLib.Place(),self.new_place_after_edit) + EditPlace.EditPlace(self.parent,RelLib.Place(),self.new_place_after_edit) def on_delete_clicked(self,obj): mlist = [] @@ -263,7 +264,7 @@ class PlaceView: self.selection.selected_foreach(self.blist,mlist) for place in mlist: - EditPlace.EditPlace(self, place, self.update_display) + EditPlace.EditPlace(self.parent, place, self.update_display) def blist(self,store,path,iter,list): id = self.db.get_place_id(store.get_value(iter,1)) diff --git a/gramps2/src/SourceView.py b/gramps2/src/SourceView.py index 25eb74669..21bcaaf25 100644 --- a/gramps2/src/SourceView.py +++ b/gramps2/src/SourceView.py @@ -59,7 +59,8 @@ from gettext import gettext as _ # #------------------------------------------------------------------------- class SourceView: - def __init__(self,db,glade,update): + def __init__(self,parent,db,glade,update): + self.parent = parent self.glade = glade self.db = db self.update = update @@ -129,7 +130,7 @@ class SourceView: store,iter = self.selection.get_selected() id = store.get_value(iter,1) source = self.db.get_source(id) - EditSource.EditSource(source,self.db,self.topWindow,self.update_display) + EditSource.EditSource(source,self.db,self.parent,self.topWindow,self.update_display) return 1 elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3: self.build_context_menu(event) @@ -169,7 +170,7 @@ class SourceView: menu.popup(None,None,None,event.button,event.time) def on_add_clicked(self,obj): - EditSource.EditSource(RelLib.Source(),self.db,self.topWindow,self.new_after_edit) + EditSource.EditSource(RelLib.Source(),self.db,self.parent,self.topWindow,self.new_after_edit) def on_delete_clicked(self,obj): @@ -244,7 +245,7 @@ class SourceView: if iter: id = list_store.get_value(iter,1) source = self.db.get_source(id) - EditSource.EditSource(source, self.db, self.topWindow, self.update_display) + EditSource.EditSource(source, self.db, self.parent, self.topWindow, self.update_display) def new_after_edit(self,source): self.db.add_source(source) @@ -253,4 +254,3 @@ class SourceView: def update_display(self,place): self.db.build_source_display(place.get_id()) self.update(0) - diff --git a/gramps2/src/UrlEdit.py b/gramps2/src/UrlEdit.py index 6122a29f6..5112e6857 100644 --- a/gramps2/src/UrlEdit.py +++ b/gramps2/src/UrlEdit.py @@ -105,7 +105,7 @@ class UrlEditor: self.parent.winsmenu.append(self.parent_menu_item) def remove_itself_from_menu(self): - self.parent.child_windows[self.win_key] + del self.parent.child_windows[self.win_key] self.parent_menu_item.destroy() def present(self,obj): diff --git a/gramps2/src/dialog.glade b/gramps2/src/dialog.glade index d78fbb75b..2dbe282cc 100644 --- a/gramps2/src/dialog.glade +++ b/gramps2/src/dialog.glade @@ -1630,6 +1630,7 @@ False gramps.png False + @@ -1651,6 +1652,7 @@ True GTK_RELIEF_NORMAL -6 + @@ -1664,6 +1666,7 @@ True GTK_RELIEF_NORMAL -5 + diff --git a/gramps2/src/gramps_main.py b/gramps2/src/gramps_main.py index 820dbe96e..ee4d65c9c 100755 --- a/gramps2/src/gramps_main.py +++ b/gramps2/src/gramps_main.py @@ -254,9 +254,9 @@ class Gramps: self.change_active_person, self.load_person ) - self.place_view = PlaceView.PlaceView(self.db,self.gtop,self.update_display) - self.source_view = SourceView.SourceView(self.db,self.gtop,self.update_display) - self.media_view = MediaView.MediaView(self.db,self.gtop,self.update_display) + self.place_view = PlaceView.PlaceView(self,self.db,self.gtop,self.update_display) + self.source_view = SourceView.SourceView(self,self.db,self.gtop,self.update_display) + self.media_view = MediaView.MediaView(self,self.db,self.gtop,self.update_display) self.add_button = self.gtop.get_widget('addbtn') self.add_item = self.gtop.get_widget('add_item') diff --git a/gramps2/src/places.glade b/gramps2/src/places.glade index 3d2435663..bf5220f5c 100644 --- a/gramps2/src/places.glade +++ b/gramps2/src/places.glade @@ -17,6 +17,7 @@ False gramps.png False + @@ -38,7 +39,7 @@ True GTK_RELIEF_NORMAL -6 - + @@ -52,7 +53,7 @@ True GTK_RELIEF_NORMAL -5 - +