From 4530bd5cb962c15dbb17d8cd41e3b78b50e12bfe Mon Sep 17 00:00:00 2001 From: Gary Burton Date: Sat, 7 Feb 2009 22:54:16 +0000 Subject: [PATCH] Refactoring. ManagedWindow now controls window sizing svn: r11905 --- src/Editors/_EditAddress.py | 5 +++-- src/Editors/_EditAttribute.py | 6 +++--- src/Editors/_EditEvent.py | 12 ++++-------- src/Editors/_EditEventRef.py | 6 +++--- src/Editors/_EditFamily.py | 13 +++---------- src/Editors/_EditLdsOrd.py | 6 +++--- src/Editors/_EditLocation.py | 6 +++--- src/Editors/_EditMedia.py | 10 +++------- src/Editors/_EditMediaRef.py | 9 ++++----- src/Editors/_EditName.py | 6 +++--- src/Editors/_EditNote.py | 12 +++--------- src/Editors/_EditPerson.py | 9 +++------ src/Editors/_EditPersonRef.py | 6 +++--- src/Editors/_EditPlace.py | 10 +++------- src/Editors/_EditPrimary.py | 6 ++++-- src/Editors/_EditReference.py | 17 +---------------- src/Editors/_EditRepoRef.py | 6 +++--- src/Editors/_EditRepository.py | 11 +++-------- src/Editors/_EditSecondary.py | 17 +---------------- src/Editors/_EditSource.py | 11 +++-------- src/Editors/_EditSourceRef.py | 6 +++--- src/Editors/_EditUrl.py | 6 +++--- src/ManagedWindow.py | 23 ++++++++++++++++++++++- 23 files changed, 87 insertions(+), 132 deletions(-) diff --git a/src/Editors/_EditAddress.py b/src/Editors/_EditAddress.py index 33d111577..e780e3a4b 100644 --- a/src/Editors/_EditAddress.py +++ b/src/Editors/_EditAddress.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham +# 2009 Gary Burton # # 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 @@ -63,8 +64,6 @@ class EditAddress(EditSecondary): Displays a dialog that allows the user to edit an address. """ - WIDTH_KEY = Config.ADDRESS_WIDTH - HEIGHT_KEY = Config.ADDRESS_HEIGHT def __init__(self, dbstate, uistate, track, addr, callback): """ @@ -76,6 +75,8 @@ class EditAddress(EditSecondary): EditSecondary.__init__(self, dbstate, uistate, track, addr, callback) def _local_init(self): + self.width_key = Config.ADDRESS_WIDTH + self.height_key = Config.ADDRESS_HEIGHT self.top = glade.XML(const.GLADE_FILE, "addr_edit","gramps") self.set_window(self.top.get_widget("addr_edit"), self.top.get_widget("title"), diff --git a/src/Editors/_EditAttribute.py b/src/Editors/_EditAttribute.py index b1c8e4e84..b8eb73d31 100644 --- a/src/Editors/_EditAttribute.py +++ b/src/Editors/_EditAttribute.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham +# 2009 Gary Burton # # 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 @@ -63,9 +64,6 @@ class EditAttribute(EditSecondary): Displays a dialog that allows the user to edit an attribute. """ - WIDTH_KEY = Config.ATTRIBUTE_WIDTH - HEIGHT_KEY = Config.ATTRIBUTE_HEIGHT - def __init__(self, state, uistate, track, attrib, title, data_list, callback): """ Displays the dialog box. @@ -79,6 +77,8 @@ class EditAttribute(EditSecondary): EditSecondary.__init__(self, state, uistate, track, attrib, callback) def _local_init(self): + self.width_key = Config.ATTRIBUTE_WIDTH + self.height_key = Config.ATTRIBUTE_HEIGHT self.top = glade.XML(const.GLADE_FILE, "attr_edit","gramps") self.set_window(self.top.get_widget("attr_edit"), self.top.get_widget('title'), diff --git a/src/Editors/_EditEvent.py b/src/Editors/_EditEvent.py index 8cd57058f..c61b1d8e7 100644 --- a/src/Editors/_EditEvent.py +++ b/src/Editors/_EditEvent.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham +# 2009 Gary Burton # # 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 @@ -95,6 +96,9 @@ class EditEvent(EditPrimary): self.dbstate.db.get_family_event_types() def _local_init(self): + self.width_key = Config.EVENT_WIDTH + self.height_key = Config.EVENT_HEIGHT + self.top = glade.XML(const.GLADE_FILE, "event_edit","gramps") self.set_window(self.top.get_widget("event_edit"), None, self.get_menu_title()) @@ -103,10 +107,6 @@ class EditEvent(EditPrimary): self.share_btn = self.top.get_widget('select_place') self.add_del_btn = self.top.get_widget('add_del_place') - width = Config.get(Config.EVENT_WIDTH) - height = Config.get(Config.EVENT_HEIGHT) - self.window.resize(width, height) - def _connect_signals(self): self.top.get_widget('button111').connect('clicked', self.close) self.top.get_widget('button126').connect('clicked', self.help_clicked) @@ -186,10 +186,6 @@ class EditEvent(EditPrimary): def _cleanup_on_exit(self): self.backref_tab.close() - (width, height) = self.window.get_size() - Config.set(Config.EVENT_WIDTH, width) - Config.set(Config.EVENT_HEIGHT, height) - Config.sync() def build_menu_names(self, event): return (_('Edit Event'), self.get_menu_title()) diff --git a/src/Editors/_EditEventRef.py b/src/Editors/_EditEventRef.py index 43280d69a..22e51f971 100644 --- a/src/Editors/_EditEventRef.py +++ b/src/Editors/_EditEventRef.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham +# 2009 Gary Burton # # 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 @@ -65,15 +66,14 @@ from ObjectEntries import PlaceEntry #------------------------------------------------------------------------- class EditEventRef(EditReference): - WIDTH_KEY = Config.EVENT_REF_WIDTH - HEIGHT_KEY = Config.EVENT_REF_HEIGHT - def __init__(self, state, uistate, track, event, event_ref, update): EditReference.__init__(self, state, uistate, track, event, event_ref, update) self._init_event() def _local_init(self): + self.width_key = Config.EVENT_REF_WIDTH + self.height_key = Config.EVENT_REF_HEIGHT self.top = glade.XML(const.GLADE_FILE, "event_eref_edit","gramps") self.set_window(self.top.get_widget('event_eref_edit'), diff --git a/src/Editors/_EditFamily.py b/src/Editors/_EditFamily.py index 73ba1721e..1efd275f6 100644 --- a/src/Editors/_EditFamily.py +++ b/src/Editors/_EditFamily.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham +# 2009 Gary Burton # # 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 @@ -510,6 +511,8 @@ class EditFamily(EditPrimary): return (_('Edit Family'), self.get_menu_title()) def build_interface(self): + self.width_key = Config.FAMILY_WIDTH + self.height_key = Config.FAMILY_HEIGHT self.top = glade.XML(const.GLADE_FILE, "family_editor", "gramps") @@ -521,10 +524,6 @@ class EditFamily(EditPrimary): # FIXME: remove if we can use show() self.window.show_all = self.window.show - # restore window size - width = Config.get(Config.FAMILY_WIDTH) - height = Config.get(Config.FAMILY_HEIGHT) - self.window.set_default_size(width, height) self.fbirth = self.top.get_widget('fbirth') self.fdeath = self.top.get_widget('fdeath') @@ -1028,12 +1027,6 @@ class EditFamily(EditPrimary): self._do_close() - def _cleanup_on_exit(self): - (width, height) = self.window.get_size() - Config.set(Config.FAMILY_WIDTH, width) - Config.set(Config.FAMILY_HEIGHT, height) - Config.sync() - def no_name(self): """ Default surname guess. diff --git a/src/Editors/_EditLdsOrd.py b/src/Editors/_EditLdsOrd.py index 22f4beb1e..e58c1cff6 100644 --- a/src/Editors/_EditLdsOrd.py +++ b/src/Editors/_EditLdsOrd.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham +# 2009 Gary Burton # # 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 @@ -131,9 +132,6 @@ class EditLdsOrd(EditSecondary): Displays a dialog that allows the user to edit an attribute. """ - WIDTH_KEY = Config.LDS_WIDTH - HEIGHT_KEY = Config.LDS_HEIGHT - def __init__(self, state, uistate, track, attrib, callback): """ Displays the dialog box. @@ -146,6 +144,8 @@ class EditLdsOrd(EditSecondary): EditSecondary.__init__(self, state, uistate, track, attrib, callback) def _local_init(self): + self.width_key = Config.LDS_WIDTH + self.height_key = Config.LDS_HEIGHT self.top = glade.XML(const.GLADE_FILE, "lds_person_edit","gramps") self.set_window(self.top.get_widget("lds_person_edit"), self.top.get_widget('title'), diff --git a/src/Editors/_EditLocation.py b/src/Editors/_EditLocation.py index 382e5904f..af14eecda 100644 --- a/src/Editors/_EditLocation.py +++ b/src/Editors/_EditLocation.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham +# 2009 Gary Burton # # 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 @@ -46,14 +47,13 @@ from gettext import gettext as _ #------------------------------------------------------------------------- class EditLocation(EditSecondary): - WIDTH_KEY = Config.LOCATION_WIDTH - HEIGHT_KEY = Config.LOCATION_HEIGHT - def __init__(self,dbstate,uistate,track,location,callback): EditSecondary.__init__(self, dbstate, uistate, track, location, callback) def _local_init(self): + self.width_key = Config.LOCATION_WIDTH + self.height_key = Config.LOCATION_HEIGHT self.top = glade.XML(const.GLADE_FILE, "loc_edit","gramps") self.set_window(self.top.get_widget("loc_edit"), None, _('Location Editor')) diff --git a/src/Editors/_EditMedia.py b/src/Editors/_EditMedia.py index 51f6bd128..81bfa07be 100644 --- a/src/Editors/_EditMedia.py +++ b/src/Editors/_EditMedia.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham +# 2009 Gary Burton # # 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 @@ -88,14 +89,13 @@ class EditMedia(EditPrimary): def _local_init(self): assert(self.obj) + self.width_key = Config.MEDIA_WIDTH + self.height_key = Config.MEDIA_HEIGHT self.glade = glade.XML(const.GLADE_FILE, "change_global","gramps") self.set_window(self.glade.get_widget('change_global'), None, self.get_menu_title()) - width = Config.get(Config.MEDIA_WIDTH) - height = Config.get(Config.MEDIA_HEIGHT) - self.window.resize(width, height) def _connect_signals(self): self.define_cancel_button(self.glade.get_widget('button91')) @@ -277,10 +277,6 @@ class EditMedia(EditPrimary): def _cleanup_on_exit(self): self.backref_list.close() - (width, height) = self.window.get_size() - Config.set(Config.MEDIA_WIDTH, width) - Config.set(Config.MEDIA_HEIGHT, height) - Config.sync() def data_has_changed(self): """ diff --git a/src/Editors/_EditMediaRef.py b/src/Editors/_EditMediaRef.py index dd280f2d3..d6a9de7ff 100644 --- a/src/Editors/_EditMediaRef.py +++ b/src/Editors/_EditMediaRef.py @@ -2,7 +2,8 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham -# Copyright (C) 2008-2009 Stephane Charette +# 2008-2009 Stephane Charette +# 2009 Gary Burton # # 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 @@ -61,9 +62,6 @@ from AddMedia import AddMediaObject #------------------------------------------------------------------------- class EditMediaRef(EditReference): - WIDTH_KEY = Config.MEDIA_REF_WIDTH - HEIGHT_KEY = Config.MEDIA_REF_HEIGHT - def __init__(self, state, uistate, track, media, media_ref, update): EditReference.__init__(self, state, uistate, track, media, media_ref, update) @@ -73,7 +71,8 @@ class EditMediaRef(EditReference): self._update_addmedia) def _local_init(self): - + self.width_key = Config.MEDIA_REF_WIDTH + self.height_key = Config.MEDIA_REF_HEIGHT self.top = glade.XML(const.GLADE_FILE, "change_description","gramps") diff --git a/src/Editors/_EditName.py b/src/Editors/_EditName.py index 6b4577d80..c23c53752 100644 --- a/src/Editors/_EditName.py +++ b/src/Editors/_EditName.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham +# 2009 Gary Burton # # 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 @@ -100,15 +101,14 @@ class GeneralNameTab(GrampsTab): #------------------------------------------------------------------------- class EditName(EditSecondary): - WIDTH_KEY = Config.NAME_WIDTH - HEIGHT_KEY = Config.NAME_HEIGHT - def __init__(self, dbstate, uistate, track, name, callback): EditSecondary.__init__(self, dbstate, uistate, track, name, callback) def _local_init(self): + self.width_key = Config.NAME_WIDTH + self.height_key = Config.NAME_HEIGHT self.top = glade.XML(const.GLADE_FILE, "name_edit","gramps") self.set_window(self.top.get_widget("name_edit"), diff --git a/src/Editors/_EditNote.py b/src/Editors/_EditNote.py index 3b6589dcb..9425c622a 100644 --- a/src/Editors/_EditNote.py +++ b/src/Editors/_EditNote.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham +# 2009 Gary Burton # # 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 @@ -163,13 +164,12 @@ class EditNote(EditPrimary): and overridden here. """ + self.width_key = Config.NOTE_WIDTH + self.height_key = Config.NOTE_HEIGHT self.top = glade.XML(GLADE_FILE, "edit_note", "gramps") win = self.top.get_widget("edit_note") self.set_window(win, None, self.get_menu_title()) - width = Config.get(Config.NOTE_WIDTH) - height = Config.get(Config.NOTE_HEIGHT) - self.window.set_default_size(width, height) vboxnote = self.top.get_widget('vbox131') notebook = self.top.get_widget('note_notebook') @@ -361,12 +361,6 @@ class EditNote(EditPrimary): self.callback(self.obj.get_handle()) self.close() - def _cleanup_on_exit(self): - (width, height) = self.window.get_size() - Config.set(Config.NOTE_WIDTH, width) - Config.set(Config.NOTE_HEIGHT, height) - Config.sync() - class DeleteNoteQuery: def __init__(self, dbstate, uistate, note, the_lists): self.note = note diff --git a/src/Editors/_EditPerson.py b/src/Editors/_EditPerson.py index 329f5ffef..2733a42c7 100644 --- a/src/Editors/_EditPerson.py +++ b/src/Editors/_EditPerson.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham +# 2009 Gary Burton # # 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 @@ -127,6 +128,8 @@ class EditPerson(EditPrimary): This is called by the base class of EditPrimary, and overridden here. """ + self.width_key = Config.PERSON_WIDTH + self.height_key = Config.PERSON_HEIGHT self.pname = self.obj.get_primary_name() self.should_guess_gender = (not self.obj.get_gramps_id() and self.obj.get_gender () == @@ -138,9 +141,6 @@ class EditPerson(EditPrimary): self.set_window(self.top.get_widget("edit_person"), None, self.get_menu_title()) - width = Config.get(Config.PERSON_WIDTH) - height = Config.get(Config.PERSON_HEIGHT) - self.window.set_default_size(width, height) self.obj_photo = self.top.get_widget("personPix") self.eventbox = self.top.get_widget("eventbox1") @@ -849,9 +849,6 @@ class EditPerson(EditPrimary): return child_ref_list def _cleanup_on_exit(self): - (width, height) = self.window.get_size() - Config.set(Config.PERSON_WIDTH, width) - Config.set(Config.PERSON_HEIGHT, height) Config.set(Config.PREFIX_SUFFIX, self.prefix_suffix.active_key) Config.set(Config.PATRO_TITLE, self.patro_title.active_key) Config.sync() diff --git a/src/Editors/_EditPersonRef.py b/src/Editors/_EditPersonRef.py index 15c908895..e2025c646 100644 --- a/src/Editors/_EditPersonRef.py +++ b/src/Editors/_EditPersonRef.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham +# 2009 Gary Burton # # 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 @@ -63,9 +64,6 @@ class EditPersonRef(EditSecondary): Displays a dialog that allows the user to edit an address. """ - WIDTH_KEY = Config.PERSON_REF_WIDTH - HEIGHT_KEY = Config.PERSON_REF_HEIGHT - def __init__(self, dbstate, uistate, track, addr, callback): """ Displays the dialog box. @@ -76,6 +74,8 @@ class EditPersonRef(EditSecondary): EditSecondary.__init__(self, dbstate, uistate, track, addr, callback) def _local_init(self): + self.width_key = Config.PERSON_REF_WIDTH + self.height_key = Config.PERSON_REF_HEIGHT self.top = glade.XML(const.GLADE_FILE, "pref_edit","gramps") self.set_window(self.top.get_widget("pref_edit"), self.top.get_widget("title"), diff --git a/src/Editors/_EditPlace.py b/src/Editors/_EditPlace.py index 5fc575e7e..12744cf1a 100644 --- a/src/Editors/_EditPlace.py +++ b/src/Editors/_EditPlace.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham +# 2009 Gary Burton # # 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 @@ -113,13 +114,12 @@ class EditPlace(EditPrimary): return gen.lib.Place() def _local_init(self): + self.width_key = Config.PLACE_WIDTH + self.height_key = Config.PLACE_HEIGHT self.top = glade.XML(const.GLADE_FILE, "place_editor","gramps") self.set_window(self.top.get_widget("place_editor"), None, self.get_menu_title()) - width = Config.get(Config.PLACE_WIDTH) - height = Config.get(Config.PLACE_HEIGHT) - self.window.resize(width, height) tblmloc = self.top.get_widget('table19') notebook = self.top.get_widget('notebook3') #recreate start page as GrampsTab @@ -257,10 +257,6 @@ class EditPlace(EditPrimary): def _cleanup_on_exit(self): self.backref_list.close() - (width, height) = self.window.get_size() - Config.set(Config.PLACE_WIDTH, width) - Config.set(Config.PLACE_HEIGHT, height) - Config.sync() def save(self, *obj): self.ok_button.set_sensitive(False) diff --git a/src/Editors/_EditPrimary.py b/src/Editors/_EditPrimary.py index e27e5eeea..1527e0d83 100644 --- a/src/Editors/_EditPrimary.py +++ b/src/Editors/_EditPrimary.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham +# 2009 Gary Burton # # 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 @@ -60,7 +61,7 @@ class EditPrimary(ManagedWindow.ManagedWindow): ManagedWindow.ManagedWindow.__init__(self, uistate, track, obj) self._local_init() - + self._set_size() self._create_tabbed_pages() self._setup_fields() self._connect_signals() @@ -153,6 +154,7 @@ class EditPrimary(ManagedWindow.ManagedWindow): for key in self.signal_keys: self.db.disconnect(key) self._cleanup_on_exit() + self._save_size() ManagedWindow.ManagedWindow.close(self) def close(self, *obj): @@ -285,4 +287,4 @@ class EditPrimary(ManagedWindow.ManagedWindow): if self.get_from_gramps_id(idval): return (True, idval) return (False, 0) - \ No newline at end of file + diff --git a/src/Editors/_EditReference.py b/src/Editors/_EditReference.py index c978aa90c..3a48b5d4a 100644 --- a/src/Editors/_EditReference.py +++ b/src/Editors/_EditReference.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham +# 2009 Gary Burton # # 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 @@ -86,9 +87,6 @@ class RefTab(GrampsTab): #------------------------------------------------------------------------- class EditReference(ManagedWindow.ManagedWindow): - WIDTH_KEY = None - HEIGHT_KEY = None - def __init__(self, state, uistate, track, source, source_ref, update): self.db = state.db self.dbstate = state @@ -110,12 +108,6 @@ class EditReference(ManagedWindow.ManagedWindow): self.show() self._post_init() - def _set_size(self): - if self.WIDTH_KEY: - width = Config.get(self.WIDTH_KEY) - height = Config.get(self.HEIGHT_KEY) - self.window.resize(width, height) - def _local_init(self): """ Derived class should do any pre-window initalization in this task. @@ -212,10 +204,3 @@ class EditReference(ManagedWindow.ManagedWindow): self.db.disconnect(key) self._save_size() ManagedWindow.ManagedWindow.close(self) - - def _save_size(self): - if self.HEIGHT_KEY: - (width, height) = self.window.get_size() - Config.set(self.WIDTH_KEY, width) - Config.set(self.HEIGHT_KEY, height) - Config.sync() diff --git a/src/Editors/_EditRepoRef.py b/src/Editors/_EditRepoRef.py index 2e2cd7601..24996c95d 100644 --- a/src/Editors/_EditRepoRef.py +++ b/src/Editors/_EditRepoRef.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham +# 2009 Gary Burton # # 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,15 +56,14 @@ from _EditReference import RefTab, EditReference #------------------------------------------------------------------------- class EditRepoRef(EditReference): - WIDTH_KEY = Config.REPO_REF_WIDTH - HEIGHT_KEY = Config.REPO_REF_HEIGHT - def __init__(self, state, uistate, track, source, source_ref, update): EditReference.__init__(self, state, uistate, track, source, source_ref, update) def _local_init(self): + self.width_key = Config.REPO_REF_WIDTH + self.height_key = Config.REPO_REF_HEIGHT self.top = glade.XML(const.GLADE_FILE, "repository_ref_edit","gramps") diff --git a/src/Editors/_EditRepository.py b/src/Editors/_EditRepository.py index 15484d53d..adb203335 100644 --- a/src/Editors/_EditRepository.py +++ b/src/Editors/_EditRepository.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham +# 2009 Gary Burton # # 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 @@ -72,15 +73,13 @@ class EditRepository(EditPrimary): return title def _local_init(self): + self.width_key = Config.REPO_WIDTH + self.height_key = Config.REPO_HEIGHT self.glade = glade.XML(const.GLADE_FILE, "repository_editor","gramps") self.set_window(self.glade.get_widget("repository_editor"), None, self.get_menu_title()) - width = Config.get(Config.REPO_WIDTH) - height = Config.get(Config.REPO_HEIGHT) - self.window.resize(width, height) - def build_menu_names(self, source): return (_('Edit Repository'), self.get_menu_title()) @@ -176,10 +175,6 @@ class EditRepository(EditPrimary): def _cleanup_on_exit(self): self.backref_tab.close() - (width, height) = self.window.get_size() - Config.set(Config.REPO_WIDTH, width) - Config.set(Config.REPO_HEIGHT, height) - Config.sync() class DelRepositoryQuery: def __init__(self, dbstate, uistate, repository, sources): diff --git a/src/Editors/_EditSecondary.py b/src/Editors/_EditSecondary.py index c3305bf97..eb9f8123a 100644 --- a/src/Editors/_EditSecondary.py +++ b/src/Editors/_EditSecondary.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham +# 2009 Gary Burton # # 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 @@ -26,9 +27,6 @@ import Config class EditSecondary(ManagedWindow.ManagedWindow): - WIDTH_KEY = None - HEIGHT_KEY = None - def __init__(self, state, uistate, track, obj, callback=None): """Create an edit window. Associates a person with the window.""" @@ -50,12 +48,6 @@ class EditSecondary(ManagedWindow.ManagedWindow): self.show() self._post_init() - def _set_size(self): - if self.WIDTH_KEY: - width = Config.get(self.WIDTH_KEY) - height = Config.get(self.HEIGHT_KEY) - self.window.resize(width, height) - def _local_init(self): """ Derived class should do any pre-window initalization in this task. @@ -134,10 +126,3 @@ class EditSecondary(ManagedWindow.ManagedWindow): self._cleanup_on_exit() self._save_size() ManagedWindow.ManagedWindow.close(self) - - def _save_size(self): - if self.HEIGHT_KEY: - (width, height) = self.window.get_size() - Config.set(self.WIDTH_KEY, width) - Config.set(self.HEIGHT_KEY, height) - Config.sync() diff --git a/src/Editors/_EditSource.py b/src/Editors/_EditSource.py index 834a037a3..8472b60f3 100644 --- a/src/Editors/_EditSource.py +++ b/src/Editors/_EditSource.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham +# 2009 Gary Burton # # 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 @@ -78,15 +79,13 @@ class EditSource(EditPrimary): return title def _local_init(self): - + self.width_key = Config.SOURCE_WIDTH + self.height_key = Config.SOURCE_HEIGHT assert(self.obj) self.glade = glade.XML(const.GLADE_FILE, "source_editor","gramps") self.set_window(self.glade.get_widget("source_editor"), None, self.get_menu_title()) - width = Config.get(Config.SOURCE_WIDTH) - height = Config.get(Config.SOURCE_HEIGHT) - self.window.resize(width, height) def _connect_signals(self): self.define_ok_button(self.glade.get_widget('ok'),self.save) @@ -193,10 +192,6 @@ class EditSource(EditPrimary): def _cleanup_on_exit(self): self.backref_tab.close() - (width, height) = self.window.get_size() - Config.set(Config.SOURCE_WIDTH, width) - Config.set(Config.SOURCE_HEIGHT, height) - Config.sync() class DelSrcQuery: def __init__(self, dbstate, uistate, source, the_lists): diff --git a/src/Editors/_EditSourceRef.py b/src/Editors/_EditSourceRef.py index 8a1c78f61..a01723d16 100644 --- a/src/Editors/_EditSourceRef.py +++ b/src/Editors/_EditSourceRef.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham +# 2009 Gary Burton # # 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 @@ -56,15 +57,14 @@ from _EditReference import RefTab, EditReference #------------------------------------------------------------------------- class EditSourceRef(EditReference): - WIDTH_KEY = Config.SOURCE_REF_WIDTH - HEIGHT_KEY = Config.SOURCE_REF_HEIGHT - def __init__(self, state, uistate, track, source, source_ref, update): EditReference.__init__(self, state, uistate, track, source, source_ref, update) def _local_init(self): + self.width_key = Config.EVENT_REF_WIDTH + self.height_key = Config.EVENT_REF_HEIGHT self.top = glade.XML(const.GLADE_FILE, "source_ref_edit","gramps") diff --git a/src/Editors/_EditUrl.py b/src/Editors/_EditUrl.py index 54583ebae..a73952994 100644 --- a/src/Editors/_EditUrl.py +++ b/src/Editors/_EditUrl.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham +# 2009 Gary Burton # # 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 @@ -51,15 +52,14 @@ from widgets import MonitoredEntry, PrivacyButton, MonitoredDataType #------------------------------------------------------------------------- class EditUrl(EditSecondary): - WIDTH_KEY = Config.URL_WIDTH - HEIGHT_KEY = Config.URL_HEIGHT - def __init__(self, dbstate, uistate, track, name, url, callback): EditSecondary.__init__(self, dbstate, uistate, track, url, callback) def _local_init(self): + self.width_key = Config.URL_WIDTH + self.height_key = Config.URL_HEIGHT self.top = glade.XML(const.GLADE_FILE, "url_edit", "gramps") self.jump = self.top.get_widget('jump') diff --git a/src/ManagedWindow.py b/src/ManagedWindow.py index 9349e0411..8a023303c 100644 --- a/src/ManagedWindow.py +++ b/src/ManagedWindow.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham +# 2009 Gary Burton # # 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,6 +48,7 @@ from gtk import glade #------------------------------------------------------------------------- import const import Errors +import Config #------------------------------------------------------------------------- # @@ -292,7 +294,6 @@ class ManagedWindow: menu, keeping track of child windows, closing them on close/delete event, and presenting itself when selected or attempted to create again. """ - def __init__(self, uistate, track, obj): """ Create child windows and add itself to menu, if not there already. @@ -331,6 +332,8 @@ class ManagedWindow: menu_label, submenu_label = self.build_menu_names(obj) self._gladeobj = None self.isWindow = None + self.width_key = None + self.height_key = None if uistate.gwm.get_item_from_id(window_key): uistate.gwm.get_item_from_id(window_key).present() @@ -478,6 +481,24 @@ class ManagedWindow: "ManagedWindow: self.window does not exist!" self.window.present() + def _set_size(self): + """ + Set the dimensions of the window + """ + if self.width_key is not None: + width = Config.get(self.width_key) + height = Config.get(self.height_key) + self.window.resize(width, height) + + def _save_size(self): + """ + Save the dimensions of the window to the config file + """ + if self.width_key is not None: + (width, height) = self.window.get_size() + Config.set(self.width_key, width) + Config.set(self.height_key, height) + Config.sync() #------------------------------------------------------------------------- # # Helper functions