* src/DbState.py: Remove modeule.
* src/DisplayState.py: Rename from DbState, kepp only DisplayState class. * src/GrampsDbBase.py: Add DbState class. * src/MapView.py: Swap zoom_in and zoom_out to reflect reality; add place list with the ScrollableWindow, request size for the place list. * src/ViewManager.py: Use DisplayState.DisplayState. * src/gramps_main.py: Use GrampsDbBase.DbState; add docstring; svn: r5055
This commit is contained in:
parent
9d62401d7b
commit
3338178102
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
||||
2005-08-11 Alex Roitman <shura@gramps-project.org>
|
||||
* src/DbState.py: Remove modeule.
|
||||
* src/DisplayState.py: Rename from DbState, kepp only DisplayState
|
||||
class.
|
||||
* src/GrampsDbBase.py: Add DbState class.
|
||||
* src/MapView.py: Swap zoom_in and zoom_out to reflect reality;
|
||||
add place list with the ScrollableWindow, request size for the
|
||||
place list.
|
||||
* src/ViewManager.py: Use DisplayState.DisplayState.
|
||||
* src/gramps_main.py: Use GrampsDbBase.DbState; add docstring;
|
||||
|
||||
2005-08-11 Don Allingham <don@gramps-project.org>
|
||||
* various: added new views
|
||||
* src/DbState.py: handle self.index == -1
|
||||
|
@ -118,41 +118,6 @@ class History(GrampsDBCallback.GrampsDBCallback):
|
||||
if not self.at_end():
|
||||
self.history = self.history[0:self.index+1]
|
||||
|
||||
class DbState(GrampsDBCallback.GrampsDBCallback):
|
||||
|
||||
__signals__ = {
|
||||
'database-changed' : (GrampsDbBase.GrampsDbBase,),
|
||||
'active-changed' : (str,),
|
||||
'no-database' : None,
|
||||
}
|
||||
|
||||
def __init__(self):
|
||||
GrampsDBCallback.GrampsDBCallback.__init__(self)
|
||||
self.db = GrampsDbBase.GrampsDbBase()
|
||||
self.active = None
|
||||
|
||||
def change_active_person(self,person):
|
||||
self.active = person
|
||||
if person:
|
||||
try:
|
||||
self.emit('active-changed',(person.handle,))
|
||||
except:
|
||||
self.emit('active-changed',("",))
|
||||
|
||||
def change_active_handle(self,handle):
|
||||
self.change_active_person(self.db.get_person_from_handle(handle))
|
||||
|
||||
def get_active_person(self):
|
||||
return self.active
|
||||
|
||||
def change_database(self,db):
|
||||
self.db = db
|
||||
self.emit('database-changed',(self.db,))
|
||||
|
||||
def no_database(self):
|
||||
self.db = GrampsDbBase.GrampsDbBase()
|
||||
self.emit('no-database')
|
||||
|
||||
class DisplayState(GrampsDBCallback.GrampsDBCallback):
|
||||
|
||||
__signals__ = {
|
@ -1496,3 +1496,38 @@ class Transaction:
|
||||
if self.last and self.first:
|
||||
return self.last - self.first + 1
|
||||
return 0
|
||||
|
||||
class DbState(GrampsDBCallback.GrampsDBCallback):
|
||||
|
||||
__signals__ = {
|
||||
'database-changed' : (GrampsDbBase,),
|
||||
'active-changed' : (str,),
|
||||
'no-database' : None,
|
||||
}
|
||||
|
||||
def __init__(self):
|
||||
GrampsDBCallback.GrampsDBCallback.__init__(self)
|
||||
self.db = GrampsDbBase()
|
||||
self.active = None
|
||||
|
||||
def change_active_person(self,person):
|
||||
self.active = person
|
||||
if person:
|
||||
try:
|
||||
self.emit('active-changed',(person.handle,))
|
||||
except:
|
||||
self.emit('active-changed',("",))
|
||||
|
||||
def change_active_handle(self,handle):
|
||||
self.change_active_person(self.db.get_person_from_handle(handle))
|
||||
|
||||
def get_active_person(self):
|
||||
return self.active
|
||||
|
||||
def change_database(self,db):
|
||||
self.db = db
|
||||
self.emit('database-changed',(self.db,))
|
||||
|
||||
def no_database(self):
|
||||
self.db = GrampsDbBase()
|
||||
self.emit('no-database')
|
||||
|
@ -26,6 +26,7 @@
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
import gc
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -35,7 +36,6 @@ from gettext import gettext as _
|
||||
import gobject
|
||||
import gtk
|
||||
import gtk.gdk
|
||||
import gc
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -45,7 +45,6 @@ import gc
|
||||
import RelLib
|
||||
import PageView
|
||||
|
||||
|
||||
data = (("_Center", 0,0),
|
||||
("_North",0,80),
|
||||
("_South",0,-80),
|
||||
@ -94,8 +93,12 @@ class GuideMap(gtk.DrawingArea):
|
||||
if self.backbuf and self.gc:
|
||||
self.window.draw_pixbuf( self.gc, self.backbuf, 0,0, 0,0, -1,-1)
|
||||
if self.current_area:
|
||||
r = self.map_to_screen(self.current_area[0],self.current_area[1],self.current_area[2],self.current_area[3])
|
||||
self.window.draw_rectangle( self.gc, False, r[0],r[1], r[2],r[3])
|
||||
r = self.map_to_screen(self.current_area[0],
|
||||
self.current_area[1],
|
||||
self.current_area[2],
|
||||
self.current_area[3])
|
||||
self.window.draw_rectangle( self.gc, False,
|
||||
r[0],r[1],r[2],r[3])
|
||||
|
||||
# Scale backbuffer
|
||||
def size_allocate_cb(self,widget,allocation):
|
||||
@ -109,7 +112,10 @@ class GuideMap(gtk.DrawingArea):
|
||||
new_size = (allocation.width,allocation.height)
|
||||
if new_size is not self.old_size:
|
||||
self.old_size = new_size
|
||||
self.backbuf = self.map_pixbuf.scale_simple(self.old_size[0],self.old_size[1],gtk.gdk.INTERP_BILINEAR)
|
||||
self.backbuf = self.map_pixbuf.scale_simple(
|
||||
self.old_size[0],
|
||||
self.old_size[1],
|
||||
gtk.gdk.INTERP_BILINEAR)
|
||||
gc.collect()
|
||||
|
||||
def map_to_screen( self, x,y,w,h):
|
||||
@ -122,7 +128,8 @@ class GuideMap(gtk.DrawingArea):
|
||||
|
||||
# Zoomable map image
|
||||
class ZoomMap( gtk.DrawingArea):
|
||||
def __init__(self, map_pixbuf, place_marker_pixbuf, hightlight_marker_pixbuf):
|
||||
def __init__(self, map_pixbuf, place_marker_pixbuf,
|
||||
hightlight_marker_pixbuf):
|
||||
gtk.DrawingArea.__init__(self)
|
||||
self.map_pixbuf = map_pixbuf
|
||||
self.place_marker_pixbuf = place_marker_pixbuf
|
||||
@ -152,9 +159,17 @@ class ZoomMap( gtk.DrawingArea):
|
||||
self.size_allocate_cb( self,self.get_allocation())
|
||||
if self.backbuf and self.gc:
|
||||
self.window.draw_pixbuf( self.gc, self.backbuf, 0,0, 0,0, -1,-1)
|
||||
px = int((float(self.zoom_pos[1]) + 180.0) / 360.0 * self.backbuf.get_width())
|
||||
py = int((90-float(self.zoom_pos[0])) / 180.0 * self.backbuf.get_height())
|
||||
self.window.draw_pixbuf( self.gc, self.hightlight_marker_pixbuf, 0,0, px-self.hightlight_marker_pixbuf.get_width()/2,py-self.hightlight_marker_pixbuf.get_height()/2, -1,-1)
|
||||
px = int((float(self.zoom_pos[1]) + 180.0) / 360.0
|
||||
* self.backbuf.get_width())
|
||||
py = int((90-float(self.zoom_pos[0])) / 180.0
|
||||
* self.backbuf.get_height())
|
||||
self.window.draw_pixbuf(
|
||||
self.gc,
|
||||
self.hightlight_marker_pixbuf,
|
||||
0,0,
|
||||
px-self.hightlight_marker_pixbuf.get_width()/2,
|
||||
py-self.hightlight_marker_pixbuf.get_height()/2,
|
||||
-1,-1)
|
||||
self.window.draw_rectangle( self.gc, False, px-3,py-3, 6,6)
|
||||
|
||||
# Scale backbuffer
|
||||
@ -171,8 +186,10 @@ class ZoomMap( gtk.DrawingArea):
|
||||
pw = int(self.old_size[0]*self.magnifer)
|
||||
ph = int(self.old_size[1]*self.magnifer)
|
||||
|
||||
px = int((float(self.zoom_pos[1]) + 180.0) / 360.0 * self.map_pixbuf.get_width())
|
||||
py = int((90-float(self.zoom_pos[0])) / 180.0 * self.map_pixbuf.get_height())
|
||||
px = int((float(self.zoom_pos[1]) + 180.0) / 360.0
|
||||
* self.map_pixbuf.get_width())
|
||||
py = int((90-float(self.zoom_pos[0])) / 180.0
|
||||
* self.map_pixbuf.get_height())
|
||||
|
||||
px = max( pw/2, px)
|
||||
py = max( ph/2, py)
|
||||
@ -180,10 +197,13 @@ class ZoomMap( gtk.DrawingArea):
|
||||
px = min( px, self.map_pixbuf.get_width()-pw/2)
|
||||
py = min( py, self.map_pixbuf.get_height()-ph/2)
|
||||
|
||||
zoomebuf = self.map_pixbuf.subpixbuf( int(px-pw/2), int(py-ph/2), pw,ph)
|
||||
zoomebuf = self.map_pixbuf.subpixbuf( int(px-pw/2),
|
||||
int(py-ph/2), pw,ph)
|
||||
print ( px-pw/2, py-ph/2, pw,ph)
|
||||
|
||||
self.backbuf = zoomebuf.scale_simple(self.old_size[0],self.old_size[1],gtk.gdk.INTERP_BILINEAR)
|
||||
self.backbuf = zoomebuf.scale_simple(self.old_size[0],
|
||||
self.old_size[1],
|
||||
gtk.gdk.INTERP_BILINEAR)
|
||||
gc.collect()
|
||||
if self.guide:
|
||||
mx = 360.0 / self.map_pixbuf.get_width() * (px-pw/2.0) - 180.0
|
||||
@ -199,12 +219,12 @@ class ZoomMap( gtk.DrawingArea):
|
||||
self.backbuf = None
|
||||
self.queue_draw()
|
||||
|
||||
def zoom_in(self):
|
||||
def zoom_out(self):
|
||||
self.magnifer = min( 10, self.magnifer * 1.5)
|
||||
self.backbuf = None
|
||||
self.queue_draw()
|
||||
|
||||
def zoom_out(self):
|
||||
def zoom_in(self):
|
||||
self.magnifer = max( 0.1, self.magnifer * 0.75)
|
||||
self.backbuf = None
|
||||
self.queue_draw()
|
||||
@ -266,10 +286,14 @@ class MapView(PageView.PageView):
|
||||
|
||||
def define_actions(self):
|
||||
print "MapView.define_actions"
|
||||
self.add_action('ZoomIn', gtk.STOCK_ZOOM_IN, "Zoom _In", callback=self.zoom_in_cb)
|
||||
self.add_action('ZoomOut', gtk.STOCK_ZOOM_OUT, "Zoom _Out", callback=self.zoom_out_cb)
|
||||
self.add_action('ZoomNormal',gtk.STOCK_ZOOM_100,"_Normal Size", callback=self.zoom_100_cb)
|
||||
self.add_action('ZoomFit', gtk.STOCK_ZOOM_FIT, "Best _Fit", callback=self.zoom_fit_cb)
|
||||
self.add_action('ZoomIn',gtk.STOCK_ZOOM_IN,
|
||||
"Zoom _In",callback=self.zoom_in_cb)
|
||||
self.add_action('ZoomOut',gtk.STOCK_ZOOM_OUT,
|
||||
"Zoom _Out",callback=self.zoom_out_cb)
|
||||
self.add_action('ZoomNormal',gtk.STOCK_ZOOM_100,
|
||||
"_Normal Size", callback=self.zoom_100_cb)
|
||||
self.add_action('ZoomFit',gtk.STOCK_ZOOM_FIT,
|
||||
"Best _Fit",callback=self.zoom_fit_cb)
|
||||
|
||||
def get_stock(self):
|
||||
"""
|
||||
@ -293,10 +317,11 @@ class MapView(PageView.PageView):
|
||||
|
||||
# On the right side
|
||||
vbox = gtk.VBox( False, 4)
|
||||
hbox.pack_start( vbox, False, True, 0)
|
||||
hbox.pack_start( vbox, False, False, 0)
|
||||
|
||||
# The small guide map
|
||||
self.guide_map = GuideMap( gtk.gdk.pixbuf_new_from_file("land_shallow_topo_350.jpg"))
|
||||
self.guide_map = GuideMap(
|
||||
gtk.gdk.pixbuf_new_from_file("land_shallow_topo_350.jpg"))
|
||||
self.guide_map.set_size_request(128,64)
|
||||
vbox.pack_start( self.guide_map, False, True, 0)
|
||||
|
||||
@ -304,8 +329,11 @@ class MapView(PageView.PageView):
|
||||
|
||||
# And the place list
|
||||
self.place_list_view = MapPlacesList( data)
|
||||
vbox.pack_start( self.place_list_view,True,True,0)
|
||||
|
||||
self.place_list_view.set_size_request(128,-1)
|
||||
vport = gtk.ScrolledWindow()
|
||||
vbox.pack_start(vport,True,True,0)
|
||||
vport.add( self.place_list_view)
|
||||
|
||||
self.place_list_view.connect("cursor-changed", self.entry_select_cb)
|
||||
|
||||
return hbox
|
||||
@ -340,7 +368,8 @@ class MapView(PageView.PageView):
|
||||
(model,sel) = s.get_selected_rows()
|
||||
for path in sel:
|
||||
iter = model.get_iter(path)
|
||||
self.zoom_map.scroll_to(model.get_value(iter,1), model.get_value(iter,2))
|
||||
self.zoom_map.scroll_to(model.get_value(iter,1),
|
||||
model.get_value(iter,2))
|
||||
break
|
||||
|
||||
def zoom_in_cb(self,obj):
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2005 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
|
||||
@ -18,12 +18,13 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
from gettext import gettext as _
|
||||
from bsddb import db
|
||||
import os
|
||||
@ -44,7 +45,7 @@ except:
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import DbState
|
||||
import DisplayState
|
||||
import DbPrompter
|
||||
import const
|
||||
import PluginMgr
|
||||
@ -176,7 +177,7 @@ class ViewManager:
|
||||
vbox.pack_end(self.statusbar,False)
|
||||
|
||||
self.notebook.connect('switch-page',self.change_page)
|
||||
self.uistate = DbState.DisplayState(self.window, self.statusbar,
|
||||
self.uistate = DisplayState.DisplayState(self.window, self.statusbar,
|
||||
self.uimanager, self.state)
|
||||
|
||||
person_nav = Navigation.PersonNavigation(self.uistate)
|
||||
@ -797,4 +798,3 @@ def format_maker(formats):
|
||||
box.add(type_selector)
|
||||
box.show_all()
|
||||
return (box,type_selector)
|
||||
|
||||
|
@ -36,7 +36,7 @@ import const
|
||||
import Errors
|
||||
import PluginMgr
|
||||
import TipOfDay
|
||||
import DbState
|
||||
import GrampsDbBase
|
||||
|
||||
from GrampsMime import mime_type_is_defined
|
||||
from QuestionDialog import ErrorDialog
|
||||
@ -44,19 +44,20 @@ from QuestionDialog import ErrorDialog
|
||||
import gnome
|
||||
|
||||
|
||||
iconpaths = [".","/usr/share/gramps"]
|
||||
iconpaths = [".",const.rootDir]
|
||||
|
||||
def register_stock_icons ():
|
||||
import os
|
||||
items = [
|
||||
('people48.png',('gramps-person', 'Person', gtk.gdk.CONTROL_MASK, 0, '')),
|
||||
('family48.png',('gramps-family', 'Family', gtk.gdk.CONTROL_MASK, 0, '')),
|
||||
('ped24.png',('gramps-pedigree', 'Pedigree', gtk.gdk.CONTROL_MASK, 0, '')),
|
||||
('repos.png',('gramps-repository', 'Repositories', gtk.gdk.CONTROL_MASK, 0, '')),
|
||||
('sources.png',('gramps-source', 'Sources', gtk.gdk.CONTROL_MASK, 0, '')),
|
||||
('events.png',('gramps-event', 'Events', gtk.gdk.CONTROL_MASK, 0, '')),
|
||||
('place.png',('gramps-place', 'Places', gtk.gdk.CONTROL_MASK, 0, '')),
|
||||
('place.png',('gramps-map', 'Map', gtk.gdk.CONTROL_MASK, 0, '')),
|
||||
('people48.png',('gramps-person','Person',gtk.gdk.CONTROL_MASK,0,'')),
|
||||
('family48.png',('gramps-family','Family',gtk.gdk.CONTROL_MASK,0,'')),
|
||||
('ped24.png',('gramps-pedigree','Pedigree',gtk.gdk.CONTROL_MASK,0,'')),
|
||||
('repos.png',('gramps-repository','Repositories',
|
||||
gtk.gdk.CONTROL_MASK,0,'')),
|
||||
('sources.png',('gramps-source','Sources',gtk.gdk.CONTROL_MASK,0,'')),
|
||||
('events.png',('gramps-event','Events',gtk.gdk.CONTROL_MASK,0,'')),
|
||||
('place.png',('gramps-place','Places',gtk.gdk.CONTROL_MASK,0,'')),
|
||||
('place.png',('gramps-map','Map',gtk.gdk.CONTROL_MASK,0,'')),
|
||||
]
|
||||
|
||||
# Register our stock items
|
||||
@ -86,6 +87,12 @@ def register_stock_icons ():
|
||||
print 'failed to load GTK logo for toolbar'
|
||||
|
||||
class Gramps:
|
||||
"""
|
||||
Main class corresponding to a running gramps process.
|
||||
|
||||
There can be only one instance of this class per gramps application
|
||||
process. It may spawn several windows and control several databases.
|
||||
"""
|
||||
|
||||
def __init__(self,args):
|
||||
|
||||
@ -107,9 +114,10 @@ class Gramps:
|
||||
ErrorDialog(_("Configuration error"),str(msg))
|
||||
return
|
||||
except Errors.GConfSchemaError, val:
|
||||
ErrorDialog(_("Configuration error"),
|
||||
str(val) + _("\n\nPossibly the installation of GRAMPS was incomplete."
|
||||
" Make sure the GConf schema of GRAMPS is properly installed."))
|
||||
ErrorDialog(_("Configuration error"),str(val) +
|
||||
_("\n\nPossibly the installation of GRAMPS "
|
||||
"was incomplete. Make sure the GConf schema "
|
||||
"of GRAMPS is properly installed."))
|
||||
gtk.main_quit()
|
||||
return
|
||||
except:
|
||||
@ -118,9 +126,11 @@ class Gramps:
|
||||
|
||||
if not mime_type_is_defined(const.app_gramps):
|
||||
ErrorDialog(_("Configuration error"),
|
||||
_("A definition for the MIME-type %s could not be found"
|
||||
"\n\nPossibly the installation of GRAMPS was incomplete."
|
||||
" Make sure the MIME-types of GRAMPS are properly installed.") % const.app_gramps)
|
||||
_("A definition for the MIME-type %s could not "
|
||||
"be found \n\nPossibly the installation of GRAMPS "
|
||||
"was incomplete. Make sure the MIME-types "
|
||||
"of GRAMPS are properly installed.")
|
||||
% const.app_gramps)
|
||||
gtk.main_quit()
|
||||
return
|
||||
|
||||
@ -150,7 +160,7 @@ class Gramps:
|
||||
|
||||
register_stock_icons()
|
||||
|
||||
state = DbState.DbState()
|
||||
state = GrampsDbBase.DbState()
|
||||
|
||||
a = ViewManager.ViewManager(state)
|
||||
a.register_view(PersonView.PersonView)
|
||||
|
Loading…
Reference in New Issue
Block a user