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:
parent
0d9f926a43
commit
7c1e29aa60
@ -29,6 +29,7 @@
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from gen.ggettext import sgettext as _
|
from gen.ggettext import sgettext as _
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import re
|
import re
|
||||||
from gi.repository import GObject
|
from gi.repository import GObject
|
||||||
import time
|
import time
|
||||||
@ -146,14 +147,19 @@ class GeoGraphyView(OsmGps, NavigationView):
|
|||||||
self.place_list = []
|
self.place_list = []
|
||||||
self.places_found = []
|
self.places_found = []
|
||||||
self.select_fct = None
|
self.select_fct = None
|
||||||
self.geo_mainmap = cairo.ImageSurface.create_from_png(
|
self.geo_mainmap = None
|
||||||
os.path.join(ROOT_DIR, "images", "48x48",
|
path = os.path.join(ROOT_DIR, "images", "48x48",
|
||||||
('gramps-geo-mainmap' + '.png' )))
|
('gramps-geo-mainmap' + '.png' ))
|
||||||
self.geo_altmap = cairo.ImageSurface.create_from_png(
|
pathu = path.encode(sys.getfilesystemencoding())
|
||||||
os.path.join(ROOT_DIR, "images", "48x48",
|
self.geo_mainmap = cairo.ImageSurface.create_from_png(pathu)
|
||||||
('gramps-geo-altmap' + '.png' )))
|
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
|
if ( config.get('geography.map_service') in
|
||||||
( constants.OPENSTREETMAP, constants.OPENSTREETMAP_RENDERER )):
|
( constants.OPENSTREETMAP,
|
||||||
|
constants.OPENSTREETMAP_RENDERER
|
||||||
|
)):
|
||||||
default_image = self.geo_mainmap
|
default_image = self.geo_mainmap
|
||||||
else:
|
else:
|
||||||
default_image = self.geo_altmap
|
default_image = self.geo_altmap
|
||||||
@ -161,9 +167,10 @@ class GeoGraphyView(OsmGps, NavigationView):
|
|||||||
for ident in ( gen.lib.EventType.BIRTH,
|
for ident in ( gen.lib.EventType.BIRTH,
|
||||||
gen.lib.EventType.DEATH,
|
gen.lib.EventType.DEATH,
|
||||||
gen.lib.EventType.MARRIAGE ):
|
gen.lib.EventType.MARRIAGE ):
|
||||||
self.geo_othermap[ident] = cairo.ImageSurface.create_from_png(
|
path = os.path.join(ROOT_DIR, "images", "48x48",
|
||||||
os.path.join(ROOT_DIR, "images", "48x48",
|
(constants.ICONS.get(int(ident), default_image) + '.png' ))
|
||||||
(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):
|
def change_page(self):
|
||||||
"""
|
"""
|
||||||
|
@ -45,13 +45,14 @@ _LOG = logging.getLogger("maps.marker")
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
|
import cairo
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Gramps Modules
|
# Gramps Modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import cairo
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# set up logging
|
# set up logging
|
||||||
|
@ -46,9 +46,7 @@ _LOG = logging.getLogger("maps.messagelayer")
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from gi.repository import Gdk
|
from gi.repository import Gdk
|
||||||
#from gi.repository import Cairo
|
|
||||||
import cairo
|
import cairo
|
||||||
import pangocairo
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -128,19 +126,13 @@ class MessageLayer(GObject.GObject, osmgpsmap.MapLayer):
|
|||||||
0.9) # transparency
|
0.9) # transparency
|
||||||
coord_x = 100
|
coord_x = 100
|
||||||
coord_y = int(self.size) # Show the first line under the zoom button
|
coord_y = int(self.size) # Show the first line under the zoom button
|
||||||
#(d_width, d_height) = drawable.get_size()
|
d_width = gpsmap.get_allocation().width
|
||||||
pcr = pangocairo.CairoContext(ctx)
|
gpsmap.set_size_request(300,400)
|
||||||
ctx_layout = pcr.create_layout()
|
|
||||||
(d_width, d_height) = ctx_layout.get_size()
|
|
||||||
print d_width, d_height
|
|
||||||
d_width -= 100
|
d_width -= 100
|
||||||
for line in self.message:
|
for line in self.message:
|
||||||
line_to_print = line
|
line_to_print = line
|
||||||
(x_bearing, y_bearing, width, height, x_advance, y_advance) = ctx.text_extents(line_to_print)
|
(x_bearing, y_bearing, width, height, x_advance, y_advance) = ctx.text_extents(line_to_print)
|
||||||
#while ( width > d_width):
|
while ( width > d_width ):
|
||||||
# BUG here d_with is negative
|
|
||||||
while ( width > 1000):
|
|
||||||
print width, " > ", d_width
|
|
||||||
line_length = len(line_to_print)
|
line_length = len(line_to_print)
|
||||||
character_length = int(width/line_length) + 1
|
character_length = int(width/line_length) + 1
|
||||||
max_length = int(d_width / character_length) - 5
|
max_length = int(d_width / character_length) - 5
|
||||||
|
@ -49,10 +49,10 @@ if repository.enumerate_versions("OsmGpsMap"):
|
|||||||
# current osmgpsmap support GTK3
|
# current osmgpsmap support GTK3
|
||||||
from gi.repository import OsmGpsMap as osmgpsmap
|
from gi.repository import OsmGpsMap as osmgpsmap
|
||||||
OSMGPSMAP = True
|
OSMGPSMAP = True
|
||||||
if osmgpsmap._version < '1.0':
|
if osmgpsmap._version < '0.8':
|
||||||
OSMGPSMAP = False
|
OSMGPSMAP = False
|
||||||
_LOG.warning( _("WARNING: osmgpsmap module not loaded. "
|
_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)
|
osmgpsmap._version)
|
||||||
else:
|
else:
|
||||||
_LOG.info("OsmGpsMap loaded, version : " + osmgpsmap._version)
|
_LOG.info("OsmGpsMap loaded, version : " + osmgpsmap._version)
|
||||||
|
@ -40,6 +40,7 @@ from gi.repository import Gdk
|
|||||||
KEY_TAB = Gdk.KEY_Tab
|
KEY_TAB = Gdk.KEY_Tab
|
||||||
import socket
|
import socket
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
|
from gi.repository import GObject
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user