Cosmetic improvements to details gramplets
svn: r17333
This commit is contained in:
parent
5d2ae80184
commit
e4348092c3
@ -257,7 +257,6 @@ 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
|
||||
|
@ -12,7 +12,6 @@ pkgdata_PYTHON = \
|
||||
grampletpane.py \
|
||||
labels.py \
|
||||
linkbox.py \
|
||||
locationbox.py \
|
||||
menutoolbuttonaction.py \
|
||||
monitoredwidgets.py \
|
||||
multitreeview.py \
|
||||
|
@ -27,7 +27,6 @@ from buttons import *
|
||||
from expandcollapsearrow import *
|
||||
from labels import *
|
||||
from linkbox import *
|
||||
from locationbox import *
|
||||
from photo import *
|
||||
from monitoredwidgets import *
|
||||
from shortlistcomboentry import *
|
||||
|
@ -1,87 +0,0 @@
|
||||
# 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()
|
@ -75,6 +75,13 @@ class PersonDetails(Gramplet):
|
||||
xpadding=10)
|
||||
self.table.attach(value, 1, 2, rows, rows + 1)
|
||||
|
||||
def clear_table(self):
|
||||
"""
|
||||
Remove all the rows from the table.
|
||||
"""
|
||||
map(self.table.remove, self.table.get_children())
|
||||
self.table.resize(1, 2)
|
||||
|
||||
def db_changed(self):
|
||||
self.dbstate.db.connect('person-update', self.update)
|
||||
self.update()
|
||||
@ -106,7 +113,7 @@ class PersonDetails(Gramplet):
|
||||
self.load_person_image(active_person)
|
||||
self.name.set_text(name_displayer.display(active_person))
|
||||
|
||||
map(self.table.remove, self.table.get_children())
|
||||
self.clear_table()
|
||||
self.display_parents(active_person)
|
||||
self.display_separator()
|
||||
self.display_type(active_person, EventType(EventType.BIRTH))
|
||||
@ -115,6 +122,7 @@ class PersonDetails(Gramplet):
|
||||
self.display_type(active_person, EventType(EventType.BURIAL))
|
||||
self.display_separator()
|
||||
self.display_attribute(active_person, _('Occupation'))
|
||||
self.display_attribute(active_person, _('Title'))
|
||||
self.display_attribute(active_person, _('Religion'))
|
||||
|
||||
def display_empty(self):
|
||||
@ -123,7 +131,7 @@ class PersonDetails(Gramplet):
|
||||
"""
|
||||
self.photo.set_image(None)
|
||||
self.name.set_text(_('No active person'))
|
||||
map(self.table.remove, self.table.get_children())
|
||||
self.clear_table()
|
||||
|
||||
def display_separator(self):
|
||||
"""
|
||||
|
@ -20,7 +20,7 @@
|
||||
#
|
||||
|
||||
from gen.plug import Gramplet
|
||||
from gui.widgets import LocationBox, Photo
|
||||
from gui.widgets import Photo
|
||||
from gen.ggettext import gettext as _
|
||||
from PlaceUtils import conv_lat_lon
|
||||
import Utils
|
||||
@ -47,32 +47,36 @@ class PlaceDetails(Gramplet):
|
||||
self.title.set_alignment(0, 0)
|
||||
self.title.modify_font(pango.FontDescription('sans bold 12'))
|
||||
vbox.pack_start(self.title, fill=True, expand=False, padding=7)
|
||||
table = gtk.Table(4, 2)
|
||||
self.location = LocationBox()
|
||||
label = gtk.Label(_('Location') + ':')
|
||||
label.set_alignment(1, 0)
|
||||
table.attach(label, 0, 1, 0, 1, xoptions=gtk.FILL, xpadding=10)
|
||||
table.attach(self.location, 1, 2, 0, 1, xoptions=gtk.FILL)
|
||||
table.attach(gtk.Label(), 0, 1, 1, 2, xoptions=gtk.FILL)
|
||||
self.latitude = self.make_row(table, 2, _('Latitude'))
|
||||
self.longitude = self.make_row(table, 3, _('Longitude'))
|
||||
vbox.pack_start(table, fill=True, expand=False)
|
||||
self.table = gtk.Table(1, 2)
|
||||
vbox.pack_start(self.table, fill=True, expand=False)
|
||||
self.top.pack_start(self.photo, fill=True, expand=False, padding=5)
|
||||
self.top.pack_start(vbox, fill=True, expand=False, padding=10)
|
||||
self.top.show_all()
|
||||
return self.top
|
||||
|
||||
def make_row(self, table, row, title):
|
||||
def add_row(self, title, value):
|
||||
"""
|
||||
Make a row in a table.
|
||||
Add a row to the table.
|
||||
"""
|
||||
label = gtk.Label(title + ':')
|
||||
label.set_alignment(1, 0)
|
||||
widget = gtk.Label()
|
||||
widget.set_alignment(0, 0)
|
||||
table.attach(label, 0, 1, row, row + 1, xoptions=gtk.FILL, xpadding=10)
|
||||
table.attach(widget, 1, 2, row, row + 1)
|
||||
return (label, widget)
|
||||
label.show()
|
||||
value = gtk.Label(value)
|
||||
value.set_alignment(0, 0)
|
||||
value.show()
|
||||
rows = self.table.get_property('n-rows')
|
||||
rows += 1
|
||||
self.table.resize(rows, 2)
|
||||
self.table.attach(label, 0, 1, rows, rows + 1, xoptions=gtk.FILL,
|
||||
xpadding=10)
|
||||
self.table.attach(value, 1, 2, rows, rows + 1)
|
||||
|
||||
def clear_table(self):
|
||||
"""
|
||||
Remove all the rows from the table.
|
||||
"""
|
||||
map(self.table.remove, self.table.get_children())
|
||||
self.table.resize(1, 2)
|
||||
|
||||
def db_changed(self):
|
||||
self.dbstate.db.connect('place-update', self.update)
|
||||
@ -102,16 +106,24 @@ class PlaceDetails(Gramplet):
|
||||
"""
|
||||
self.load_place_image(place)
|
||||
self.title.set_text(place.get_title())
|
||||
self.location.set_location(place.get_main_location())
|
||||
|
||||
self.clear_table()
|
||||
self.display_location(place.get_main_location())
|
||||
self.display_separator()
|
||||
lat, lon = conv_lat_lon(place.get_latitude(),
|
||||
place.get_longitude(),
|
||||
format='DEG')
|
||||
self.latitude[1].set_text('')
|
||||
self.longitude[1].set_text('')
|
||||
if lat:
|
||||
self.latitude[1].set_text(lat)
|
||||
self.add_row(_('Latitude'), lat)
|
||||
if lon:
|
||||
self.longitude[1].set_text(lon)
|
||||
self.add_row(_('Longitude'), lat)
|
||||
|
||||
def display_location(self, location):
|
||||
"""
|
||||
Display a location.
|
||||
"""
|
||||
lines = [line for line in location.get_text_data_list()[:-1] if line]
|
||||
self.add_row(_('Location'), '\n'.join(lines))
|
||||
|
||||
def display_empty(self):
|
||||
"""
|
||||
@ -119,9 +131,19 @@ class PlaceDetails(Gramplet):
|
||||
"""
|
||||
self.photo.set_image(None)
|
||||
self.title.set_text('')
|
||||
self.location.set_location(None)
|
||||
self.latitude[1].set_text('')
|
||||
self.longitude[1].set_text('')
|
||||
self.clear_table()
|
||||
|
||||
def display_separator(self):
|
||||
"""
|
||||
Display an empty row to separate groupd of entries.
|
||||
"""
|
||||
label = gtk.Label('')
|
||||
label.modify_font(pango.FontDescription('sans 4'))
|
||||
label.show()
|
||||
rows = self.table.get_property('n-rows')
|
||||
rows += 1
|
||||
self.table.resize(rows, 2)
|
||||
self.table.attach(label, 0, 1, rows, rows + 1, xoptions=gtk.FILL)
|
||||
|
||||
def load_place_image(self, place):
|
||||
"""
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
from gen.lib import UrlType
|
||||
from gen.plug import Gramplet
|
||||
from gui.widgets import LocationBox
|
||||
from gen.ggettext import gettext as _
|
||||
import gtk
|
||||
import pango
|
||||
@ -45,31 +44,35 @@ class RepositoryDetails(Gramplet):
|
||||
self.name.set_alignment(0, 0)
|
||||
self.name.modify_font(pango.FontDescription('sans bold 12'))
|
||||
vbox.pack_start(self.name, fill=True, expand=False, padding=7)
|
||||
table = gtk.Table(4, 2)
|
||||
self.address = LocationBox()
|
||||
label = gtk.Label(_('Address') + ':')
|
||||
label.set_alignment(1, 0)
|
||||
table.attach(label, 0, 1, 0, 1, xoptions=gtk.FILL, xpadding=10)
|
||||
table.attach(self.address, 1, 2, 0, 1, xoptions=gtk.FILL)
|
||||
self.phone = self.make_row(table, 1, _('Phone'))
|
||||
self.email = self.make_row(table, 2, _('Email'))
|
||||
self.web = self.make_row(table, 3, _('Web'))
|
||||
vbox.pack_start(table, fill=True, expand=False)
|
||||
self.table = gtk.Table(1, 2)
|
||||
vbox.pack_start(self.table, fill=True, expand=False)
|
||||
self.top.pack_start(vbox, fill=True, expand=False, padding=10)
|
||||
self.top.show_all()
|
||||
return self.top
|
||||
|
||||
def make_row(self, table, row, title):
|
||||
def add_row(self, title, value):
|
||||
"""
|
||||
Make a row in a table.
|
||||
Add a row to the table.
|
||||
"""
|
||||
label = gtk.Label(title + ':')
|
||||
label.set_alignment(1, 0)
|
||||
widget = gtk.Label()
|
||||
widget.set_alignment(0, 0)
|
||||
table.attach(label, 0, 1, row, row + 1, xoptions=gtk.FILL, xpadding=10)
|
||||
table.attach(widget, 1, 2, row, row + 1)
|
||||
return (label, widget)
|
||||
label.show()
|
||||
value = gtk.Label(value)
|
||||
value.set_alignment(0, 0)
|
||||
value.show()
|
||||
rows = self.table.get_property('n-rows')
|
||||
rows += 1
|
||||
self.table.resize(rows, 2)
|
||||
self.table.attach(label, 0, 1, rows, rows + 1, xoptions=gtk.FILL,
|
||||
xpadding=10)
|
||||
self.table.attach(value, 1, 2, rows, rows + 1)
|
||||
|
||||
def clear_table(self):
|
||||
"""
|
||||
Remove all the rows from the table.
|
||||
"""
|
||||
map(self.table.remove, self.table.get_children())
|
||||
self.table.resize(1, 2)
|
||||
|
||||
def db_changed(self):
|
||||
self.dbstate.db.connect('repository-update', self.update)
|
||||
@ -98,28 +101,49 @@ class RepositoryDetails(Gramplet):
|
||||
Display details of the active repository.
|
||||
"""
|
||||
self.name.set_text(repo.get_name())
|
||||
|
||||
self.clear_table()
|
||||
address_list = repo.get_address_list()
|
||||
if len(address_list) > 0:
|
||||
self.address.set_location(address_list[0])
|
||||
self.phone[1].set_text(address_list[0].get_phone())
|
||||
else:
|
||||
self.address.set_location(None)
|
||||
self.phone[1].set_text('')
|
||||
self.display_address(address_list[0])
|
||||
self.display_separator()
|
||||
phone = address_list[0].get_phone()
|
||||
if phone:
|
||||
self.add_row(_('Phone'), phone)
|
||||
|
||||
self.email[1].set_text('')
|
||||
self.web[1].set_text('')
|
||||
self.display_url(repo, UrlType(UrlType.EMAIL))
|
||||
self.display_url(repo, UrlType(UrlType.WEB_HOME))
|
||||
|
||||
def display_address(self, address):
|
||||
"""
|
||||
Display an address.
|
||||
"""
|
||||
lines = [line for line in address.get_text_data_list()[:-1] if line]
|
||||
self.add_row(_('Address'), '\n'.join(lines))
|
||||
|
||||
def display_url(self, repo, url_type):
|
||||
"""
|
||||
Display an url of the given url type.
|
||||
"""
|
||||
for url in repo.get_url_list():
|
||||
if int(url.get_type()) == UrlType.EMAIL:
|
||||
self.email[1].set_text(url.get_path())
|
||||
if int(url.get_type()) == UrlType.WEB_HOME:
|
||||
self.web[1].set_text(url.get_path())
|
||||
if url.get_type() == url_type:
|
||||
self.add_row(str(url_type), url.get_path())
|
||||
|
||||
def display_empty(self):
|
||||
"""
|
||||
Display empty details when no repository is selected.
|
||||
"""
|
||||
self.name.set_text('')
|
||||
self.address.set_location(None)
|
||||
self.phone[1].set_text('')
|
||||
self.email[1].set_text('')
|
||||
self.web[1].set_text('')
|
||||
self.clear_table()
|
||||
|
||||
def display_separator(self):
|
||||
"""
|
||||
Display an empty row to separate groupd of entries.
|
||||
"""
|
||||
label = gtk.Label('')
|
||||
label.modify_font(pango.FontDescription('sans 4'))
|
||||
label.show()
|
||||
rows = self.table.get_property('n-rows')
|
||||
rows += 1
|
||||
self.table.resize(rows, 2)
|
||||
self.table.attach(label, 0, 1, rows, rows + 1, xoptions=gtk.FILL)
|
||||
|
Loading…
Reference in New Issue
Block a user