Geography : Some cleaning, ImageSurface needs an utf-8 path

messagelayer : get the real window size.
            osmgpsmap must be >= 0.8


svn: r20389
This commit is contained in:
Serge Noiraud 2012-09-14 20:29:48 +00:00
parent 0d9f926a43
commit 7c1e29aa60
5 changed files with 25 additions and 24 deletions

View File

@ -29,6 +29,7 @@
#-------------------------------------------------------------------------
from gen.ggettext import sgettext as _
import os
import sys
import re
from gi.repository import GObject
import time
@ -146,14 +147,19 @@ class GeoGraphyView(OsmGps, NavigationView):
self.place_list = []
self.places_found = []
self.select_fct = None
self.geo_mainmap = cairo.ImageSurface.create_from_png(
os.path.join(ROOT_DIR, "images", "48x48",
('gramps-geo-mainmap' + '.png' )))
self.geo_altmap = cairo.ImageSurface.create_from_png(
os.path.join(ROOT_DIR, "images", "48x48",
('gramps-geo-altmap' + '.png' )))
self.geo_mainmap = None
path = os.path.join(ROOT_DIR, "images", "48x48",
('gramps-geo-mainmap' + '.png' ))
pathu = path.encode(sys.getfilesystemencoding())
self.geo_mainmap = cairo.ImageSurface.create_from_png(pathu)
path = os.path.join(ROOT_DIR, "images", "48x48",
('gramps-geo-altmap' + '.png' ))
pathu = path.encode(sys.getfilesystemencoding())
self.geo_altmap = cairo.ImageSurface.create_from_png(pathu)
if ( config.get('geography.map_service') in
( constants.OPENSTREETMAP, constants.OPENSTREETMAP_RENDERER )):
( constants.OPENSTREETMAP,
constants.OPENSTREETMAP_RENDERER
)):
default_image = self.geo_mainmap
else:
default_image = self.geo_altmap
@ -161,9 +167,10 @@ class GeoGraphyView(OsmGps, NavigationView):
for ident in ( gen.lib.EventType.BIRTH,
gen.lib.EventType.DEATH,
gen.lib.EventType.MARRIAGE ):
self.geo_othermap[ident] = cairo.ImageSurface.create_from_png(
os.path.join(ROOT_DIR, "images", "48x48",
(constants.ICONS.get(int(ident), default_image) + '.png' )))
path = os.path.join(ROOT_DIR, "images", "48x48",
(constants.ICONS.get(int(ident), default_image) + '.png' ))
pathu = path.encode(sys.getfilesystemencoding())
self.geo_othermap[ident] = cairo.ImageSurface.create_from_png(pathu)
def change_page(self):
"""

View File

@ -45,13 +45,14 @@ _LOG = logging.getLogger("maps.marker")
#
#-------------------------------------------------------------------------
from gi.repository import Gtk
import cairo
#-------------------------------------------------------------------------
#
# Gramps Modules
#
#-------------------------------------------------------------------------
import cairo
#-------------------------------------------------------------------------
#
# set up logging

View File

@ -46,9 +46,7 @@ _LOG = logging.getLogger("maps.messagelayer")
#
#-------------------------------------------------------------------------
from gi.repository import Gdk
#from gi.repository import Cairo
import cairo
import pangocairo
#-------------------------------------------------------------------------
#
@ -128,19 +126,13 @@ class MessageLayer(GObject.GObject, osmgpsmap.MapLayer):
0.9) # transparency
coord_x = 100
coord_y = int(self.size) # Show the first line under the zoom button
#(d_width, d_height) = drawable.get_size()
pcr = pangocairo.CairoContext(ctx)
ctx_layout = pcr.create_layout()
(d_width, d_height) = ctx_layout.get_size()
print d_width, d_height
d_width = gpsmap.get_allocation().width
gpsmap.set_size_request(300,400)
d_width -= 100
for line in self.message:
line_to_print = line
(x_bearing, y_bearing, width, height, x_advance, y_advance) = ctx.text_extents(line_to_print)
#while ( width > d_width):
# BUG here d_with is negative
while ( width > 1000):
print width, " > ", d_width
while ( width > d_width ):
line_length = len(line_to_print)
character_length = int(width/line_length) + 1
max_length = int(d_width / character_length) - 5

View File

@ -49,10 +49,10 @@ if repository.enumerate_versions("OsmGpsMap"):
# current osmgpsmap support GTK3
from gi.repository import OsmGpsMap as osmgpsmap
OSMGPSMAP = True
if osmgpsmap._version < '1.0':
if osmgpsmap._version < '0.8':
OSMGPSMAP = False
_LOG.warning( _("WARNING: osmgpsmap module not loaded. "
"osmgpsmap must be >= 1.0. yours is %s") %
"osmgpsmap must be >= 0.8. yours is %s") %
osmgpsmap._version)
else:
_LOG.info("OsmGpsMap loaded, version : " + osmgpsmap._version)

View File

@ -40,6 +40,7 @@ from gi.repository import Gdk
KEY_TAB = Gdk.KEY_Tab
import socket
from gi.repository import Gtk
from gi.repository import GObject
#-------------------------------------------------------------------------
#