diff --git a/po/POTFILES.skip b/po/POTFILES.skip index bea6075e4..4c6deb06e 100644 --- a/po/POTFILES.skip +++ b/po/POTFILES.skip @@ -257,6 +257,7 @@ src/gui/views/treemodels/repomodel.py src/gui/views/treemodels/sourcemodel.py # gui/widgets - the GUI widgets package +src/gui/widgets/locationbox.py src/gui/widgets/menutoolbuttonaction.py src/gui/widgets/styledtextbuffer.py src/gui/widgets/undoablestyledbuffer.py diff --git a/src/gui/widgets/Makefile.am b/src/gui/widgets/Makefile.am index af450ad6c..3db8afbd2 100644 --- a/src/gui/widgets/Makefile.am +++ b/src/gui/widgets/Makefile.am @@ -12,6 +12,7 @@ pkgdata_PYTHON = \ grampletpane.py \ labels.py \ linkbox.py \ + locationbox.py \ menutoolbuttonaction.py \ monitoredwidgets.py \ multitreeview.py \ diff --git a/src/gui/widgets/__init__.py b/src/gui/widgets/__init__.py index c17218c5a..2eda61869 100644 --- a/src/gui/widgets/__init__.py +++ b/src/gui/widgets/__init__.py @@ -27,6 +27,7 @@ from buttons import * from expandcollapsearrow import * from labels import * from linkbox import * +from locationbox import * from monitoredwidgets import * from shortlistcomboentry import * from springseparator import * diff --git a/src/gui/widgets/locationbox.py b/src/gui/widgets/locationbox.py new file mode 100644 index 000000000..bf3c15c13 --- /dev/null +++ b/src/gui/widgets/locationbox.py @@ -0,0 +1,87 @@ +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2011 Nick Hall +# +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# $Id$ +# + +#------------------------------------------------------------------------- +# +# GTK/Gnome modules +# +#------------------------------------------------------------------------- +import gtk + +#------------------------------------------------------------------------- +# +# LocationBox class +# +#------------------------------------------------------------------------- +class LocationBox(gtk.VBox): + """ + Displays a location. + """ + def __init__(self): + gtk.VBox.__init__(self) + + self.__street = self.__create_label() + self.__locality = self.__create_label() + self.__city = self.__create_label() + self.__county = self.__create_label() + self.__state = self.__create_label() + self.__country = self.__create_label() + self.__postal_code = self.__create_label() + + def set_location(self, location): + """ + Set the location to be displayed. + """ + if location is not None: + self.__set_line(self.__street, location.get_street()) + self.__set_line(self.__locality, location.get_locality()) + self.__set_line(self.__city, location.get_city()) + self.__set_line(self.__county, location.get_county()) + self.__set_line(self.__state, location.get_state()) + self.__set_line(self.__country, location.get_country()) + self.__set_line(self.__postal_code, location.get_postal_code()) + else: + self.__set_line(self.__street, '') + self.__set_line(self.__locality, '') + self.__set_line(self.__city, '') + self.__set_line(self.__county, '') + self.__set_line(self.__state, '') + self.__set_line(self.__country, '') + self.__set_line(self.__postal_code, '') + + def __create_label(self): + """ + Create a label to display a single line of the location. + """ + label = gtk.Label() + label.set_alignment(0, 0) + self.pack_start(label, False, False) + return label + + def __set_line(self, label, value): + """ + Display a single line of the location. + """ + if value: + label.set_text(value) + label.show() + else: + label.hide()