diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 98076fc8b..643c4d6b2 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,10 @@ +2006-04-23 Alex Roitman + * src/Utils.py: Make set_titles call ManagedWindow.set_titles + with warning. + * src/ManagedWindow.py: move set_titles here. + * src/plugins/FilterEditor.py: Use new set_window method. + * src/Editors/_Edit*.py: new set_window method. + 2006-04-23 Don Allingham * src/ColumnOrder.py: use ManagedWindow * src/DataViews/_MediaView.py: ColumnOrder update diff --git a/gramps2/src/Editors/_EditAddress.py b/gramps2/src/Editors/_EditAddress.py index dddad6682..867162627 100644 --- a/gramps2/src/Editors/_EditAddress.py +++ b/gramps2/src/Editors/_EditAddress.py @@ -70,9 +70,9 @@ class EditAddress(EditSecondary): def _local_init(self): self.top = gtk.glade.XML(const.gladeFile, "addr_edit","gramps") - self.define_top_level(self.top.get_widget("addr_edit"), - self.top.get_widget("title"), - _('Address Editor')) + self.set_window(self.top.get_widget("addr_edit"), + self.top.get_widget("title"), + _('Address Editor')) def _setup_fields(self): self.addr_start = MonitoredDate( diff --git a/gramps2/src/Editors/_EditAttribute.py b/gramps2/src/Editors/_EditAttribute.py index 91807ffb1..f2764e6e1 100644 --- a/gramps2/src/Editors/_EditAttribute.py +++ b/gramps2/src/Editors/_EditAttribute.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2000-2005 Donald N. Allingham +# Copyright (C) 2000-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 @@ -79,9 +79,9 @@ class EditAttribute(EditSecondary): def _local_init(self): self.top = gtk.glade.XML(const.gladeFile, "attr_edit","gramps") - self.define_top_level(self.top.get_widget("attr_edit"), - self.top.get_widget('title'), - _('Attribute Editor')) + self.set_window(self.top.get_widget("attr_edit"), + self.top.get_widget('title'), + _('Attribute Editor')) def _connect_signals(self): self.define_cancel_button(self.top.get_widget('cancel')) diff --git a/gramps2/src/Editors/_EditChildRef.py b/gramps2/src/Editors/_EditChildRef.py index 5c21efda5..e942c4946 100644 --- a/gramps2/src/Editors/_EditChildRef.py +++ b/gramps2/src/Editors/_EditChildRef.py @@ -72,9 +72,9 @@ class EditChildRef(EditSecondary): def _local_init(self): self.top = gtk.glade.XML(const.gladeFile, "cref_edit","gramps") - self.define_top_level(self.top.get_widget("cref_edit"), - self.top.get_widget("title"), - _('Child Reference Editor')) + self.set_window(self.top.get_widget("cref_edit"), + self.top.get_widget("title"), + _('Child Reference Editor')) def _setup_fields(self): diff --git a/gramps2/src/Editors/_EditEventRef.py b/gramps2/src/Editors/_EditEventRef.py index 819d16797..b76e09b11 100644 --- a/gramps2/src/Editors/_EditEventRef.py +++ b/gramps2/src/Editors/_EditEventRef.py @@ -73,9 +73,9 @@ class EditEventRef(EditReference): def _local_init(self): self.top = gtk.glade.XML(const.gladeFile, "event_eref_edit","gramps") - self.define_top_level(self.top.get_widget('event_eref_edit'), - self.top.get_widget('eer_title'), - _('Event Reference Editor')) + self.set_window(self.top.get_widget('event_eref_edit'), + self.top.get_widget('eer_title'), + _('Event Reference Editor')) self.define_warn_box(self.top.get_widget("eer_warning")) self.define_expander(self.top.get_widget("eer_expander")) diff --git a/gramps2/src/Editors/_EditFamily.py b/gramps2/src/Editors/_EditFamily.py index 5f19abcd1..bf072cb90 100644 --- a/gramps2/src/Editors/_EditFamily.py +++ b/gramps2/src/Editors/_EditFamily.py @@ -376,8 +376,8 @@ class EditFamily(EditPrimary): self.top = gtk.glade.XML(const.gladeFile,"family_editor","gramps") - self.define_top_level(self.top.get_widget("family_editor"), - None,_('Family Editor')) + self.set_window(self.top.get_widget("family_editor"), + None,_('Family Editor')) self.fbirth = self.top.get_widget('fbirth') self.fdeath = self.top.get_widget('fdeath') diff --git a/gramps2/src/Editors/_EditLdsOrd.py b/gramps2/src/Editors/_EditLdsOrd.py index f971e02d1..a48262e83 100644 --- a/gramps2/src/Editors/_EditLdsOrd.py +++ b/gramps2/src/Editors/_EditLdsOrd.py @@ -121,9 +121,9 @@ class EditLdsOrd(EditSecondary): def _local_init(self): self.top = gtk.glade.XML(const.gladeFile, "lds_person_edit","gramps") - self.define_top_level(self.top.get_widget("lds_person_edit"), - self.top.get_widget('title'), - _('LDS Ordinance Editor')) + self.set_window(self.top.get_widget("lds_person_edit"), + self.top.get_widget('title'), + _('LDS Ordinance Editor')) def _connect_signals(self): self.parents_select.connect('clicked',self.select_parents_clicked) @@ -302,9 +302,9 @@ class EditFamilyLdsOrd(EditSecondary): def _local_init(self): self.top = gtk.glade.XML(const.gladeFile, "lds_person_edit","gramps") - self.define_top_level(self.top.get_widget("lds_person_edit"), - self.top.get_widget('title'), - _('LDS Ordinance Editor')) + self.set_window(self.top.get_widget("lds_person_edit"), + self.top.get_widget('title'), + _('LDS Ordinance Editor')) def _connect_signals(self): self.define_cancel_button(self.top.get_widget('cancel')) diff --git a/gramps2/src/Editors/_EditLocation.py b/gramps2/src/Editors/_EditLocation.py index ca1c07448..0ba7c4f7e 100644 --- a/gramps2/src/Editors/_EditLocation.py +++ b/gramps2/src/Editors/_EditLocation.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2000-2004 Donald N. Allingham +# Copyright (C) 2000-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 @@ -53,9 +53,9 @@ class EditLocation(EditSecondary): def _local_init(self): self.top = gtk.glade.XML(const.gladeFile, "loc_edit","gramps") - self.define_top_level(self.top.get_widget("loc_edit"), - self.top.get_widget('title'), - _('Location Editor')) + self.set_window(self.top.get_widget("loc_edit"), + self.top.get_widget('title'), + _('Location Editor')) def _setup_fields(self): self.city = MonitoredEntry( diff --git a/gramps2/src/Editors/_EditMedia.py b/gramps2/src/Editors/_EditMedia.py index d15fdf1ab..f9d9b0412 100644 --- a/gramps2/src/Editors/_EditMedia.py +++ b/gramps2/src/Editors/_EditMedia.py @@ -72,9 +72,9 @@ class EditMedia(EditPrimary): assert(self.obj) self.glade = gtk.glade.XML(const.gladeFile, "change_global","gramps") - self.define_top_level(self.glade.get_widget('change_global'), - self.glade.get_widget('title'), - _('Media Properties Editor')) + self.set_window(self.glade.get_widget('change_global'), + self.glade.get_widget('title'), + _('Media Properties Editor')) def _connect_signals(self): self.define_cancel_button(self.glade.get_widget('button91')) diff --git a/gramps2/src/Editors/_EditMediaRef.py b/gramps2/src/Editors/_EditMediaRef.py index 1bbd73344..52699d811 100644 --- a/gramps2/src/Editors/_EditMediaRef.py +++ b/gramps2/src/Editors/_EditMediaRef.py @@ -67,9 +67,9 @@ class EditMediaRef(EditReference): self.top = gtk.glade.XML(const.gladeFile, "change_description","gramps") - self.define_top_level(self.top.get_widget('change_description'), - self.top.get_widget('title'), - _('Media Reference Editor')) + self.set_window(self.top.get_widget('change_description'), + self.top.get_widget('title'), + _('Media Reference Editor')) self.define_warn_box(self.top.get_widget("warn_box")) def _setup_fields(self): diff --git a/gramps2/src/Editors/_EditName.py b/gramps2/src/Editors/_EditName.py index 8a419cd7b..c391259e7 100644 --- a/gramps2/src/Editors/_EditName.py +++ b/gramps2/src/Editors/_EditName.py @@ -63,9 +63,9 @@ class EditName(EditSecondary): def _local_init(self): self.top = gtk.glade.XML(const.gladeFile, "name_edit","gramps") - self.define_top_level(self.top.get_widget("name_edit"), - self.top.get_widget("title"), - _("Name Editor")) + self.set_window(self.top.get_widget("name_edit"), + self.top.get_widget("title"), + _("Name Editor")) self.original_group_as = self.obj.get_group_as() self.general_label = self.top.get_widget("general_tab") diff --git a/gramps2/src/Editors/_EditPerson.py b/gramps2/src/Editors/_EditPerson.py index 53d7d3993..4c9fc1960 100644 --- a/gramps2/src/Editors/_EditPerson.py +++ b/gramps2/src/Editors/_EditPerson.py @@ -115,8 +115,8 @@ class EditPerson(EditPrimary): self.load_obj = None self.top = gtk.glade.XML(const.person_glade, "edit_person", "gramps") - self.define_top_level(self.top.get_widget("edit_person"), None, - _('Edit Person')) + self.set_window(self.top.get_widget("edit_person"), None, + _('Edit Person')) self.obj_photo = self.top.get_widget("personPix") self.eventbox = self.top.get_widget("eventbox1") diff --git a/gramps2/src/Editors/_EditPersonRef.py b/gramps2/src/Editors/_EditPersonRef.py index 1324948d9..f716a4d23 100644 --- a/gramps2/src/Editors/_EditPersonRef.py +++ b/gramps2/src/Editors/_EditPersonRef.py @@ -71,9 +71,9 @@ class EditPersonRef(EditSecondary): def _local_init(self): self.top = gtk.glade.XML(const.gladeFile, "pref_edit","gramps") - self.define_top_level(self.top.get_widget("pref_edit"), - self.top.get_widget("title"), - _('Person Reference Editor')) + self.set_window(self.top.get_widget("pref_edit"), + self.top.get_widget("title"), + _('Person Reference Editor')) self.person_label = self.top.get_widget('person') def _setup_fields(self): diff --git a/gramps2/src/Editors/_EditPlace.py b/gramps2/src/Editors/_EditPlace.py index 272b1b2e3..094a904d5 100644 --- a/gramps2/src/Editors/_EditPlace.py +++ b/gramps2/src/Editors/_EditPlace.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2000-2005 Donald N. Allingham +# Copyright (C) 2000-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 @@ -70,9 +70,9 @@ class EditPlace(EditPrimary): def _local_init(self): self.top = gtk.glade.XML(const.gladeFile,"place_editor","gramps") - self.define_top_level(self.top.get_widget("place_editor"), - self.top.get_widget('title'), - _('Place Editor')) + self.set_window(self.top.get_widget("place_editor"), + self.top.get_widget('title'), + _('Place Editor')) def _connect_signals(self): self.define_ok_button(self.top.get_widget('ok'),self.save) diff --git a/gramps2/src/Editors/_EditPrimary.py b/gramps2/src/Editors/_EditPrimary.py index 104288377..b7c3c3ff2 100644 --- a/gramps2/src/Editors/_EditPrimary.py +++ b/gramps2/src/Editors/_EditPrimary.py @@ -27,8 +27,6 @@ import DateHandler import NameDisplay import Config import GrampsDisplay -import Utils - from QuestionDialog import SaveDialog class EditPrimary(ManagedWindow.ManagedWindow): @@ -103,11 +101,6 @@ class EditPrimary(ManagedWindow.ManagedWindow): button.connect('clicked',function) button.set_sensitive(not self.db.readonly) - def define_top_level(self,window,title,text): - self.window = window - self.window.connect('delete-event',self.delete_event) - Utils.set_titles(window,title,text) - def define_cancel_button(self,button): button.connect('clicked',self.delete_event) diff --git a/gramps2/src/Editors/_EditReference.py b/gramps2/src/Editors/_EditReference.py index 2ef01b00c..d3b22a6f4 100644 --- a/gramps2/src/Editors/_EditReference.py +++ b/gramps2/src/Editors/_EditReference.py @@ -46,7 +46,6 @@ import gtk.glade # #------------------------------------------------------------------------- import const -import Utils import RelLib import ManagedWindow @@ -128,11 +127,6 @@ class EditReference(ManagedWindow.ManagedWindow): button.connect('clicked',function) button.set_sensitive(not self.db.readonly) - def define_top_level(self,window,title,text): - self.window = window - self.window.connect('delete-event',self.close_window) - Utils.set_titles(window,title,text) - def define_cancel_button(self,button): button.connect('clicked',self.close_window) diff --git a/gramps2/src/Editors/_EditRepoRef.py b/gramps2/src/Editors/_EditRepoRef.py index d15665b0e..6d6b704f3 100644 --- a/gramps2/src/Editors/_EditRepoRef.py +++ b/gramps2/src/Editors/_EditRepoRef.py @@ -68,9 +68,9 @@ class EditRepoRef(EditReference): self.top = gtk.glade.XML(const.gladeFile, "repository_ref_edit","gramps") - self.define_top_level(self.top.get_widget('repository_ref_edit'), - self.top.get_widget('repo_title'), - _('Repository Reference Editor')) + self.set_window(self.top.get_widget('repository_ref_edit'), + self.top.get_widget('repo_title'), + _('Repository Reference Editor')) self.define_warn_box(self.top.get_widget("warn_box")) self.define_expander(self.top.get_widget("src_expander")) diff --git a/gramps2/src/Editors/_EditRepository.py b/gramps2/src/Editors/_EditRepository.py index bdd394415..c041b1976 100644 --- a/gramps2/src/Editors/_EditRepository.py +++ b/gramps2/src/Editors/_EditRepository.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2000-2005 Donald N. Allingham +# Copyright (C) 2000-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 @@ -60,9 +60,9 @@ class EditRepository(EditPrimary): def _local_init(self): self.glade = gtk.glade.XML(const.gladeFile,"repository_editor","gramps") - self.define_top_level(self.glade.get_widget("repository_editor"), - self.glade.get_widget('repository_title'), - _('Repository Editor')) + self.set_window(self.glade.get_widget("repository_editor"), + self.glade.get_widget('repository_title'), + _('Repository Editor')) def _setup_fields(self): diff --git a/gramps2/src/Editors/_EditSecondary.py b/gramps2/src/Editors/_EditSecondary.py index 37d6d6d16..7be1d38ae 100644 --- a/gramps2/src/Editors/_EditSecondary.py +++ b/gramps2/src/Editors/_EditSecondary.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2000-2005 Donald N. Allingham +# Copyright (C) 2000-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 @@ -25,7 +25,6 @@ from gettext import gettext as _ import ManagedWindow import Config import GrampsDisplay -import Utils class EditSecondary(ManagedWindow.ManagedWindow): @@ -88,11 +87,6 @@ class EditSecondary(ManagedWindow.ManagedWindow): button.connect('clicked',function) button.set_sensitive(not self.db.readonly) - def define_top_level(self,window,title,text): - self.window = window - self.window.connect('delete-event',self.delete_event) - Utils.set_titles(window,title,text) - def define_cancel_button(self,button): button.connect('clicked',self.delete_event) diff --git a/gramps2/src/Editors/_EditSource.py b/gramps2/src/Editors/_EditSource.py index f6c99aad9..972064ff1 100644 --- a/gramps2/src/Editors/_EditSource.py +++ b/gramps2/src/Editors/_EditSource.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2000-2005 Donald N. Allingham +# Copyright (C) 2000-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 @@ -74,10 +74,9 @@ class EditSource(EditPrimary): assert(self.obj) self.glade = gtk.glade.XML(const.gladeFile,"source_editor","gramps") - self.define_top_level(self.glade.get_widget("source_editor"), - self.glade.get_widget('title'), - _('Source Editor')) - + self.set_window(self.glade.get_widget("source_editor"), + self.glade.get_widget('title'), + _('Source Editor')) def _connect_signals(self): self.define_ok_button(self.glade.get_widget('ok'),self.save) diff --git a/gramps2/src/Editors/_EditSourceRef.py b/gramps2/src/Editors/_EditSourceRef.py index 05f7a1694..9ba7ec6bc 100644 --- a/gramps2/src/Editors/_EditSourceRef.py +++ b/gramps2/src/Editors/_EditSourceRef.py @@ -68,9 +68,9 @@ class EditSourceRef(EditReference): self.top = gtk.glade.XML(const.gladeFile, "source_ref_edit","gramps") - self.define_top_level(self.top.get_widget('source_ref_edit'), - self.top.get_widget('source_title'), - _('Source Reference Editor')) + self.set_window(self.top.get_widget('source_ref_edit'), + self.top.get_widget('source_title'), + _('Source Reference Editor')) self.define_warn_box(self.top.get_widget("warn_box")) self.define_expander(self.top.get_widget("src_expander")) diff --git a/gramps2/src/Editors/_EditUrl.py b/gramps2/src/Editors/_EditUrl.py index 3760aecf8..558ae3bd6 100644 --- a/gramps2/src/Editors/_EditUrl.py +++ b/gramps2/src/Editors/_EditUrl.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2000-2005 Donald N. Allingham +# Copyright (C) 2000-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 @@ -61,9 +61,9 @@ class EditUrl(EditSecondary): def _local_init(self): self.top = gtk.glade.XML(const.gladeFile, "url_edit","gramps") - self.define_top_level(self.top.get_widget("url_edit"), - self.top.get_widget("title"), - _('Internet Address Editor')) + self.set_window(self.top.get_widget("url_edit"), + self.top.get_widget("title"), + _('Internet Address Editor')) def _connect_signals(self): self.define_cancel_button(self.top.get_widget('button125')) diff --git a/gramps2/src/ManagedWindow.py b/gramps2/src/ManagedWindow.py index 1efde2772..5835b7a56 100644 --- a/gramps2/src/ManagedWindow.py +++ b/gramps2/src/ManagedWindow.py @@ -20,10 +20,28 @@ # $Id: DisplayState.py 6085 2006-03-05 23:39:20Z dallingham $ -import Errors -import gtk +#------------------------------------------------------------------------- +# +# Standard python modules +# +#------------------------------------------------------------------------- from cStringIO import StringIO +#------------------------------------------------------------------------- +# +# GNOME/GTK +# +#------------------------------------------------------------------------- +import gtk + +#------------------------------------------------------------------------- +# +# Gramps modules +# +#------------------------------------------------------------------------- +import const +import Errors + #------------------------------------------------------------------------- # # Window manager @@ -317,8 +335,10 @@ class ManagedWindow: # On the top level: we use gramps top window self.parent_window = self.uistate.window - def set_window(self, window): + def set_window(self,window,title,text,msg=None): + set_titles(window,title,text,msg) self.window = window + self.window.connect('delete-event',self.delete_event) def build_menu_names(self,obj): return ('Undefined Menu','Undefined Submenu') @@ -327,7 +347,7 @@ class ManagedWindow: return id(self) def show(self): - assert(self.window) + assert self.window, "ManagedWindow: self.window does not exist!" self.window.set_transient_for(self.parent_window) self.window.show() @@ -343,5 +363,20 @@ class ManagedWindow: """ Present window (unroll/unminimize/bring to top). """ - assert(self.window) + assert self.window, "ManagedWindow: self.window does not exist!" self.window.present() + +#------------------------------------------------------------------------- +# +# Helper functions +# +#------------------------------------------------------------------------- +def set_titles(window,title,t,msg=None): + if title: + title.set_text('%s' % t) + title.set_use_markup(True) + if msg: + window.set_title('%s - GRAMPS' % msg) + else: + window.set_title('%s - GRAMPS' % t) + window.set_icon_from_file(const.icon) diff --git a/gramps2/src/Utils.py b/gramps2/src/Utils.py index 4fbd4bd73..d115274a0 100644 --- a/gramps2/src/Utils.py +++ b/gramps2/src/Utils.py @@ -496,15 +496,10 @@ def set_title_label(xmlobj,t): title_label.set_text('%s' % t) title_label.set_use_markup(True) +from ManagedWindow import set_titles as _set_titles +from warnings import warn def set_titles(window,title,t,msg=None): - if title: - title.set_text('%s' % t) - title.set_use_markup(True) - if msg: - window.set_title('%s - GRAMPS' % msg) - else: - window.set_title('%s - GRAMPS' % t) - window.set_icon_from_file(const.icon) + warn('The Utils.set_titles is deprecated. Use ManagedWindow methods') def gfloat(val): """Converts to floating number, taking care of possible locale differences. diff --git a/gramps2/src/plugins/FilterEditor.py b/gramps2/src/plugins/FilterEditor.py index aca84795c..09002d914 100644 --- a/gramps2/src/plugins/FilterEditor.py +++ b/gramps2/src/plugins/FilterEditor.py @@ -334,9 +334,9 @@ class FilterEditor(ManagedWindow.ManagedWindow): self.delete = self.editor.get_widget('delete') self.test = self.editor.get_widget('test') - self.define_top_level(self.editor.get_widget('filter_list'), - self.editor.get_widget('title'), - _('User defined filters')) + self.set_window(self.editor.get_widget('filter_list'), + self.editor.get_widget('title'), + _('User defined filters')) self.editor.signal_autoconnect({ 'on_add_clicked' : self.add_new_filter, @@ -362,9 +362,8 @@ class FilterEditor(ManagedWindow.ManagedWindow): """Display the relevant portion of GRAMPS manual""" GrampsDisplay.help('tools-util-cfe') - def define_top_level(self,window,title,text): - self.window = window - self.window.connect('delete-event',self.on_delete_event) + def set_window(self,window,title,text): + ManagedWindow.ManagedWindow.set_window(self,window) Utils.set_titles(window,title,text) def on_delete_event(self,obj,b):