2006-04-23 Alex Roitman <shura@gramps-project.org>

* 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.
	



svn: r6425
This commit is contained in:
Alex Roitman 2006-04-23 22:18:01 +00:00
parent 3274d3dad9
commit cd4ee9ca0b
25 changed files with 117 additions and 101 deletions

View File

@ -1,3 +1,10 @@
2006-04-23 Alex Roitman <shura@gramps-project.org>
* 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 <don@gramps-project.org>
* src/ColumnOrder.py: use ManagedWindow
* src/DataViews/_MediaView.py: ColumnOrder update

View File

@ -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(

View File

@ -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'))

View File

@ -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):

View File

@ -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"))

View File

@ -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')

View File

@ -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'))

View File

@ -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(

View File

@ -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'))

View File

@ -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):

View File

@ -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")

View File

@ -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")

View File

@ -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):

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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"))

View File

@ -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):

View File

@ -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)

View File

@ -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)

View File

@ -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"))

View File

@ -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'))

View File

@ -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('<span weight="bold" size="larger">%s</span>' % 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)

View File

@ -496,15 +496,10 @@ def set_title_label(xmlobj,t):
title_label.set_text('<span weight="bold" size="larger">%s</span>' % 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('<span weight="bold" size="larger">%s</span>' % 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.

View File

@ -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):