From 49b9de1063f32d657b0c5fd32c86b2172b881a52 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Thu, 4 May 2006 18:30:36 +0000 Subject: [PATCH] 2006-05-04 Alex Roitman * src/SelectObject.py: Convert to managed window. * src/SelectEvent.py: Convert to managed window. * src/SelectSource.py: Convert to managed window. * src/DisplayTabs.py: Properly call selectors. svn: r6543 --- gramps2/ChangeLog | 6 ++++++ gramps2/src/DisplayTabs.py | 9 ++++++--- gramps2/src/SelectEvent.py | 29 ++++++++++++++++------------- gramps2/src/SelectObject.py | 27 ++++++++++++++++----------- gramps2/src/SelectPerson.py | 1 - gramps2/src/SelectSource.py | 28 +++++++++++++++------------- 6 files changed, 59 insertions(+), 41 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index ed4ad55f2..47398249b 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,9 @@ +2006-05-04 Alex Roitman + * src/SelectObject.py: Convert to managed window. + * src/SelectEvent.py: Convert to managed window. + * src/SelectSource.py: Convert to managed window. + * src/DisplayTabs.py: Properly call selectors. + 2006-05-03 Alex Roitman * src/DisplayTabs.py (NoteTab.build_interface): Add spacing to radiobuttons. diff --git a/gramps2/src/DisplayTabs.py b/gramps2/src/DisplayTabs.py index 33bf513f4..9057586b4 100644 --- a/gramps2/src/DisplayTabs.py +++ b/gramps2/src/DisplayTabs.py @@ -689,7 +689,8 @@ class EventEmbedList(EmbeddedList): def share_button_clicked(self, obj): import SelectEvent - sel = SelectEvent.SelectEvent(self.dbstate.db, "Event Select") + sel = SelectEvent.SelectEvent(self.dbstate,self.uistate,self.track, + _("Select event")) event = sel.run() if event: try: @@ -1663,7 +1664,8 @@ class GalleryTab(ButtonTab): """ import SelectObject - sel = SelectObject.SelectObject(self.dbstate.db, _("Select media")) + sel = SelectObject.SelectObject(self.dbstate,self.uistate,self.track, + _("Select media")) src = sel.run() if src: sref = RelLib.MediaRef() @@ -1750,7 +1752,8 @@ class SourceEmbedList(EmbeddedList): def share_button_clicked(self, obj): import SelectSource - sel = SelectSource.SelectSource(self.dbstate.db, "Source Select") + sel = SelectSource.SelectSource(self.dbstate,self.uistate,self.track, + _("Select source")) src = sel.run() if src: try: diff --git a/gramps2/src/SelectEvent.py b/gramps2/src/SelectEvent.py index bde960214..f0842c576 100644 --- a/gramps2/src/SelectEvent.py +++ b/gramps2/src/SelectEvent.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2003-2005 Donald N. Allingham +# Copyright (C) 2003-2006 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 @@ -47,33 +47,36 @@ import gtk.glade # #------------------------------------------------------------------------- import const -import Utils import ListModel import DateHandler +import ManagedWindow #------------------------------------------------------------------------- # # SelectEvent # #------------------------------------------------------------------------- -class SelectEvent: +class SelectEvent(ManagedWindow.ManagedWindow): """ Selects an event from the list of available events """ - def __init__(self, database, title, parent_window=None): + def __init__(self, dbstate, uistate, track, title): """ Create an Event Selector, allowing the user to select on of the events in the event list. """ - self.db = database + self.title = title + ManagedWindow.ManagedWindow.__init__(self, uistate, track, self) + + self.db = dbstate.db self.glade = gtk.glade.XML(const.gladeFile, "select_person", "gramps") - self.top = self.glade.get_widget('select_person') + window = self.glade.get_widget('select_person') title_label = self.glade.get_widget('title') self.elist = self.glade.get_widget('plist') - Utils.set_titles(self.top, title_label, title) + self.set_window(window, title_label, self.title) titles = [(_('Description'), 4, 250), (_('ID'), 1, 75), (_('Type'), 2, 75), (_('Date'), 3, 150), ('', 4, 0) ] @@ -82,10 +85,10 @@ class SelectEvent: self.model = ListModel.ListModel(self.elist, titles) self.redraw() - self.top.show() + self.show() - if parent_window: - self.top.set_transient_for(parent_window) + def build_menu_names(self,obj): + return (self.title, None) def redraw(self): """ @@ -110,7 +113,7 @@ class SelectEvent: Runs te dialog, returning None if the event was not selected, or the event that was selected. """ - val = self.top.run() + val = self.window.run() if val == gtk.RESPONSE_OK: store, node = self.model.get_selected() @@ -120,8 +123,8 @@ class SelectEvent: return_value = self.db.get_event_from_handle(handle) else: return_value = None - self.top.destroy() + self.close() return return_value else: - self.top.destroy() + self.close() return None diff --git a/gramps2/src/SelectObject.py b/gramps2/src/SelectObject.py index e352a11fa..89a255f0c 100644 --- a/gramps2/src/SelectObject.py +++ b/gramps2/src/SelectObject.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2003-2004 Donald N. Allingham +# Copyright (C) 2003-2006 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 @@ -55,27 +55,29 @@ import gtk.gdk # #------------------------------------------------------------------------- import const -import Utils import ListModel import ImgManip import Mime +import ManagedWindow #------------------------------------------------------------------------- # # SelectPerson # #------------------------------------------------------------------------- -class SelectObject: +class SelectObject(ManagedWindow.ManagedWindow): - def __init__(self,db,title): + def __init__(self, dbstate, uistate, track, title): + self.title = title + ManagedWindow.ManagedWindow.__init__(self, uistate, track, self) - self.db = db + self.db = dbstate.db self.glade = gtk.glade.XML(const.gladeFile,"select_person","gramps") - self.top = self.glade.get_widget('select_person') + window = self.glade.get_widget('select_person') title_label = self.glade.get_widget('object_title') self.object_tree = self.glade.get_widget('plist') - Utils.set_titles(self.top,title_label,title) + self.set_window(window,title_label,self.title) titles = [ (_('Preview'),0,50,ListModel.IMAGE), @@ -91,7 +93,10 @@ class SelectObject: self.selection = self.object_tree.get_selection() self.redraw() - self.top.show() + self.show() + + def build_menu_names(self,obj): + return (self.title, None) def redraw(self): self.object_model.clear() @@ -109,7 +114,7 @@ class SelectObject: self.object_model.connect_model() def run(self): - val = self.top.run() + val = self.window.run() if val == gtk.RESPONSE_OK: store,node = self.object_model.get_selected() @@ -119,10 +124,10 @@ class SelectObject: return_value = self.db.get_object_from_handle(handle) else: return_value = None - self.top.destroy() + self.close() gc.collect() return return_value else: - self.top.destroy() + self.close() gc.collect() return None diff --git a/gramps2/src/SelectPerson.py b/gramps2/src/SelectPerson.py index 43d0d4376..ea1a1682f 100644 --- a/gramps2/src/SelectPerson.py +++ b/gramps2/src/SelectPerson.py @@ -42,7 +42,6 @@ import pango # #------------------------------------------------------------------------- import const -import Utils import PeopleModel import ManagedWindow diff --git a/gramps2/src/SelectSource.py b/gramps2/src/SelectSource.py index e860cf13e..60a92cf5a 100644 --- a/gramps2/src/SelectSource.py +++ b/gramps2/src/SelectSource.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2003-2005 Donald N. Allingham +# Copyright (C) 2003-2006 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 @@ -42,25 +42,27 @@ import gtk.glade # #------------------------------------------------------------------------- import const -import Utils import ListModel +import ManagedWindow #------------------------------------------------------------------------- # # SelectEvent # #------------------------------------------------------------------------- -class SelectSource: +class SelectSource(ManagedWindow.ManagedWindow): - def __init__(self,db,title,parent_window=None): + def __init__(self, dbstate, uistate, track, title): + self.title = title + ManagedWindow.ManagedWindow.__init__(self, uistate, track, self) - self.db = db + self.db = dbstate.db self.glade = gtk.glade.XML(const.gladeFile,"select_person","gramps") - self.top = self.glade.get_widget('select_person') + window = self.glade.get_widget('select_person') title_label = self.glade.get_widget('title') self.elist = self.glade.get_widget('plist') - Utils.set_titles(self.top,title_label,title) + self.set_window(window,title_label,self.title) titles = [(_('Title'),4,350), (_('ID'),1,50), ('',0,0)] self.ncols = len(titles) @@ -68,10 +70,10 @@ class SelectSource: self.model = ListModel.ListModel(self.elist,titles) self.redraw() - self.top.show() + self.show() - if parent_window: - self.top.set_transient_for(parent_window) + def build_menu_names(self,obj): + return (self.title, None) def redraw(self): self.model.clear() @@ -85,7 +87,7 @@ class SelectSource: self.model.connect_model() def run(self): - val = self.top.run() + val = self.window.run() if val == gtk.RESPONSE_OK: store,node = self.model.get_selected() @@ -95,8 +97,8 @@ class SelectSource: return_value = self.db.get_source_from_handle(handle) else: return_value = None - self.top.destroy() + self.close() return return_value else: - self.top.destroy() + self.close() return None