GEPS008: Moved constfunc module

svn: r19810
This commit is contained in:
Nick Hall 2012-06-09 20:56:43 +00:00
parent aabc6c05c2
commit 9595af1324
32 changed files with 70 additions and 72 deletions

View File

@ -14,7 +14,6 @@ gdirdir=$(prefix)/share/gramps
gdir_PYTHON = \ gdir_PYTHON = \
const.py\ const.py\
constfunc.py\
gramps.py\ gramps.py\
ImgManip.py\ ImgManip.py\
LdsUtils.py \ LdsUtils.py \

View File

@ -41,7 +41,7 @@ import locale
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import const import const
from constfunc import mac from gen.constfunc import mac
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Public Constants # Public Constants

View File

@ -53,7 +53,7 @@ from gen.locale import codeset
import gen.datehandler import gen.datehandler
from const import TEMP_DIR, USER_HOME, GRAMPS_UUID, IMAGE_DIR from const import TEMP_DIR, USER_HOME, GRAMPS_UUID, IMAGE_DIR
import constfunc from gen.constfunc import mac, win
from gen.ggettext import sgettext as _ from gen.ggettext import sgettext as _
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -134,7 +134,7 @@ def fix_encoding(value, errors='strict'):
return unicode(value) return unicode(value)
except: except:
try: try:
if constfunc.mac(): if mac():
codeset = locale.getlocale()[1] codeset = locale.getlocale()[1]
else: else:
codeset = locale.getpreferredencoding() codeset = locale.getpreferredencoding()
@ -279,7 +279,7 @@ def encodingdefs():
""" """
pass pass
if constfunc.win(): if win():
# python encoding is ascii, but C functions need to receive the # python encoding is ascii, but C functions need to receive the
# windows codeset, so convert over to it # windows codeset, so convert over to it
conv_utf8_tosrtkey = lambda x: locale.strxfrm(x.decode("utf-8").encode( conv_utf8_tosrtkey = lambda x: locale.strxfrm(x.decode("utf-8").encode(
@ -379,7 +379,7 @@ def get_unicode_path_from_file_chooser(path):
if not (isinstance(path, str)): if not (isinstance(path, str)):
return path return path
if constfunc.win(): if win():
# in windows filechooser returns officially utf-8, not filesystemencoding # in windows filechooser returns officially utf-8, not filesystemencoding
try: try:
return unicode(path) return unicode(path)
@ -406,7 +406,7 @@ def get_unicode_path_from_env_var(path):
if not (isinstance(path, str)): if not (isinstance(path, str)):
return path return path
if constfunc.win(): if win():
# In Windows path/filename returned from a environment variable is in filesystemencoding # In Windows path/filename returned from a environment variable is in filesystemencoding
try: try:
new_path = unicode(path, sys.getfilesystemencoding()) new_path = unicode(path, sys.getfilesystemencoding())
@ -475,7 +475,7 @@ def search_for(name):
name = name.split('"')[1] name = name.split('"')[1]
else: else:
name = name.split()[0] name = name.split()[0]
if constfunc.win(): if win():
for i in os.environ['PATH'].split(';'): for i in os.environ['PATH'].split(';'):
fname = os.path.join(i, name) fname = os.path.join(i, name)
if os.access(fname, os.X_OK) and not os.path.isdir(fname): if os.access(fname, os.X_OK) and not os.path.isdir(fname):

View File

@ -55,7 +55,7 @@ LOG = logging.getLogger(".clidbman")
import gen.db import gen.db
from gen.plug import BasePluginManager from gen.plug import BasePluginManager
from gen.config import config from gen.config import config
import constfunc from gen.constfunc import win
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# constants # constants
@ -436,7 +436,7 @@ def time_val(dirpath):
if os.path.isfile(meta): if os.path.isfile(meta):
tval = os.stat(meta)[9] tval = os.stat(meta)[9]
# This gives creation date in Windows, but correct date in Linux # This gives creation date in Windows, but correct date in Linux
if constfunc.win(): if win():
# Try to use last modified date instead in Windows # Try to use last modified date instead in Windows
# and check that it is later than the creation date. # and check that it is later than the creation date.
tval_mod = os.stat(meta)[8] tval_mod = os.stat(meta)[8]

View File

@ -23,6 +23,7 @@ pkgpythondir = $(datadir)/@PACKAGE@/gen
pkgpython_PYTHON = \ pkgpython_PYTHON = \
__init__.py \ __init__.py \
config.py \ config.py \
constfunc.py \
dbstate.py \ dbstate.py \
errors.py \ errors.py \
ggettext.py \ ggettext.py \

View File

@ -47,14 +47,14 @@ log = logging.getLogger(".gen.datehandler")
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from _dateparser import DateParser from _dateparser import DateParser
from _datedisplay import DateDisplay, DateDisplayEn from _datedisplay import DateDisplay, DateDisplayEn
import constfunc from gen.constfunc import win
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Constants # Constants
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
if not constfunc.win(): if not win():
LANG = locale.getlocale(locale.LC_TIME)[0] LANG = locale.getlocale(locale.LC_TIME)[0]
else: else:
LANG = locale.getdefaultlocale(locale.LC_TIME)[0] LANG = locale.getdefaultlocale(locale.LC_TIME)[0]

View File

@ -64,7 +64,7 @@ from gen.db.dbconst import *
from gen.utils.callback import Callback from gen.utils.callback import Callback
from gen.updatecallback import UpdateCallback from gen.updatecallback import UpdateCallback
from gen.errors import DbError from gen.errors import DbError
import constfunc from gen.constfunc import win
_LOG = logging.getLogger(DBLOGNAME) _LOG = logging.getLogger(DBLOGNAME)
LOG = logging.getLogger(".citation") LOG = logging.getLogger(".citation")
@ -2004,7 +2004,7 @@ def write_lock_file(name):
if not os.path.isdir(name): if not os.path.isdir(name):
os.mkdir(name) os.mkdir(name)
f = open(os.path.join(name, DBLOCKFN), "w") f = open(os.path.join(name, DBLOCKFN), "w")
if constfunc.win(): if win():
user = os.environ['USERNAME'] user = os.environ['USERNAME']
try: try:
host = os.environ['USERDOMAIN'] host = os.environ['USERDOMAIN']

View File

@ -21,7 +21,7 @@
# $Id$ # $Id$
import locale import locale
import constfunc from gen.constfunc import mac, win
""" """
Some OS environments do not support the locale.nl_langinfo() method Some OS environments do not support the locale.nl_langinfo() method
@ -132,7 +132,7 @@ try:
except: except:
import time import time
if constfunc.win() or constfunc.mac(): if win() or mac():
codeset = locale.getlocale()[1] codeset = locale.getlocale()[1]
else: else:
codeset = locale.getpreferredencoding() codeset = locale.getpreferredencoding()

View File

@ -47,7 +47,7 @@ import Utils
from gen.plug.docgen import BaseDoc from gen.plug.docgen import BaseDoc
from gen.plug.menu import NumberOption, TextOption, EnumeratedListOption, \ from gen.plug.menu import NumberOption, TextOption, EnumeratedListOption, \
BooleanOption BooleanOption
import constfunc from gen.constfunc import win
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -87,7 +87,7 @@ _RATIO = [ { 'name' : _("Minimal size"), 'value': "compress" },
_NOTELOC = [ { 'name' : _("Top"), 'value' : "t" }, _NOTELOC = [ { 'name' : _("Top"), 'value' : "t" },
{ 'name' : _("Bottom"), 'value' : "b" }] { 'name' : _("Bottom"), 'value' : "b" }]
if constfunc.win(): if win():
_DOT_FOUND = Utils.search_for("dot.exe") _DOT_FOUND = Utils.search_for("dot.exe")
if Utils.search_for("gswin32c.exe") == 1: if Utils.search_for("gswin32c.exe") == 1:

View File

@ -49,7 +49,7 @@ from subprocess import Popen, PIPE
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gen.mime import mime_type_is_defined from gen.mime import mime_type_is_defined
import TransUtils import TransUtils
import constfunc from gen.constfunc import win
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Load internationalization setup # Load internationalization setup
@ -88,7 +88,7 @@ if hasattr(os, "uname"):
else: else:
operating_system = sys.platform operating_system = sys.platform
if constfunc.win(): # Windows if win(): # Windows
TransUtils.setup_windows_gettext() TransUtils.setup_windows_gettext()
elif operating_system == 'FreeBSD': elif operating_system == 'FreeBSD':
try: try:
@ -289,7 +289,7 @@ def show_settings():
dotversion_str = 'Graphviz not in system PATH' dotversion_str = 'Graphviz not in system PATH'
try: try:
if constfunc.win(): if win():
gsversion_str = Popen(['gswin32c', '--version'], stdout=PIPE).communicate(input=None)[0] gsversion_str = Popen(['gswin32c', '--version'], stdout=PIPE).communicate(input=None)[0]
else: else:
gsversion_str = Popen(['gs', '--version'], stdout=PIPE).communicate(input=None)[0] gsversion_str = Popen(['gs', '--version'], stdout=PIPE).communicate(input=None)[0]

View File

@ -52,7 +52,7 @@ from gui.display import display_help
from gui.managedwindow import ManagedWindow from gui.managedwindow import ManagedWindow
from gen.ggettext import sgettext as _ from gen.ggettext import sgettext as _
from TransUtils import trans_objclass from TransUtils import trans_objclass
from constfunc import mac from gen.constfunc import mac
from gui.glade import Glade from gui.glade import Glade
from gui.ddtargets import DdTargets from gui.ddtargets import DdTargets
from gui.makefilter import make_filter from gui.makefilter import make_filter

View File

@ -47,8 +47,8 @@ from gui.user import User
import logging import logging
LOG = logging.getLogger(".DbManager") LOG = logging.getLogger(".DbManager")
import constfunc from gen.constfunc import win
if constfunc.win(): if win():
_RCS_FOUND = os.system("rcs -V >nul 2>nul") == 0 _RCS_FOUND = os.system("rcs -V >nul 2>nul") == 0
if _RCS_FOUND and "TZ" not in os.environ: if _RCS_FOUND and "TZ" not in os.environ:
# RCS requires the "TZ" variable be set. # RCS requires the "TZ" variable be set.

View File

@ -21,7 +21,7 @@
# $Id$ # $Id$
import const import const
import constfunc from gen.constfunc import is_quartz
from gen.config import config from gen.config import config
import locale import locale
import os import os
@ -93,7 +93,7 @@ def run_file(file):
Open a file or url with the default application. This should work Open a file or url with the default application. This should work
on GNOME, KDE, XFCE, ... as we use a freedesktop application on GNOME, KDE, XFCE, ... as we use a freedesktop application
""" """
if constfunc.is_quartz(): if is_quartz():
prog = find_binary('open') prog = find_binary('open')
else: else:
prog = find_binary('xdg-open') prog = find_binary('xdg-open')

View File

@ -58,7 +58,7 @@ from gen.errors import WindowActiveError
import gen.mime import gen.mime
from gui.ddtargets import DdTargets from gui.ddtargets import DdTargets
from buttontab import ButtonTab from buttontab import ButtonTab
import constfunc from gen.constfunc import win
import const import const
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -487,7 +487,7 @@ class GalleryTab(ButtonTab, DbGUIElement):
self.handle_extra_type(mytype, obj) self.handle_extra_type(mytype, obj)
except pickle.UnpicklingError: except pickle.UnpicklingError:
#modern file managers provide URI_LIST. For Windows split sel_data.data #modern file managers provide URI_LIST. For Windows split sel_data.data
if constfunc.win(): if win():
files = sel_data.data.split('\n') files = sel_data.data.split('\n')
else: else:
files = sel_data.get_uris() files = sel_data.get_uris()

View File

@ -58,7 +58,7 @@ import gobject
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gen.config import config from gen.config import config
import const import const
import constfunc from gen.constfunc import has_display, win
import Utils import Utils
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -75,7 +75,7 @@ def register_stock_icons ():
from gui.pluginmanager import base_reg_stock_icons from gui.pluginmanager import base_reg_stock_icons
#iconpath to the base image. The front of the list has highest priority #iconpath to the base image. The front of the list has highest priority
if constfunc.win(): if win():
iconpaths = [ iconpaths = [
(os.path.join(const.IMAGE_DIR, '48x48'), '.png'), (os.path.join(const.IMAGE_DIR, '48x48'), '.png'),
(const.IMAGE_DIR, '.png'), (const.IMAGE_DIR, '.png'),
@ -288,7 +288,7 @@ def __startgramps(errors, argparser):
try: try:
quit_now = False quit_now = False
exit_code = 0 exit_code = 0
if constfunc.has_display(): if has_display():
Gramps(argparser) Gramps(argparser)
else: else:
print("Gramps terminated because of no DISPLAY") print("Gramps terminated because of no DISPLAY")

View File

@ -44,7 +44,7 @@ import gtk
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import gen.utils import gen.utils
from gen.plug import BasePluginManager, PluginRegister from gen.plug import BasePluginManager, PluginRegister
from constfunc import win from gen.constfunc import win
from gen.config import config from gen.config import config
import const import const

View File

@ -32,7 +32,6 @@ Utility functions that depend on GUI components or for GUI components
import os import os
import sys import sys
from gen.ggettext import gettext as _ from gen.ggettext import gettext as _
import constfunc
# gtk is not included here, because this file is currently imported # gtk is not included here, because this file is currently imported
# by code that needs to run without the DISPLAY variable (eg, in # by code that needs to run without the DISPLAY variable (eg, in
# the cli only). # the cli only).
@ -49,7 +48,7 @@ import constfunc
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import gen.lib import gen.lib
import constfunc from gen.constfunc import has_display, is_quartz, mac, win
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -143,7 +142,7 @@ class ProgressMeter(object):
else: else:
self.__cancel_callback = self.handle_cancel self.__cancel_callback = self.handle_cancel
if constfunc.has_display(): if has_display():
self.__dialog = gtk.Dialog() self.__dialog = gtk.Dialog()
else: else:
self.__dialog = CLIDialog() self.__dialog = CLIDialog()
@ -334,13 +333,13 @@ def open_file_with_default_application( file_path ):
ErrorDialog(_("Error Opening File"), _("File does not exist")) ErrorDialog(_("Error Opening File"), _("File does not exist"))
return return
if constfunc.win(): if win():
try: try:
os.startfile(norm_path) os.startfile(norm_path)
except WindowsError, msg: except WindowsError, msg:
ErrorDialog(_("Error Opening File"), str(msg)) ErrorDialog(_("Error Opening File"), str(msg))
else: else:
if constfunc.mac(): if mac():
utility = '/usr/bin/open' utility = '/usr/bin/open'
else: else:
utility = 'xdg-open' utility = 'xdg-open'
@ -375,7 +374,7 @@ def is_right_click(event):
import gtk import gtk
if event.type == gtk.gdk.BUTTON_PRESS: if event.type == gtk.gdk.BUTTON_PRESS:
if constfunc.is_quartz(): if is_quartz():
if (event.button == 3 if (event.button == 3
or (event.button == 1 and event.state & gtk.gdk.CONTROL_MASK)): or (event.button == 1 and event.state & gtk.gdk.CONTROL_MASK)):
return True return True

View File

@ -79,7 +79,7 @@ from gui.pluginmanager import GuiPluginManager
from gen.relationship import get_relationship_calculator from gen.relationship import get_relationship_calculator
from gui.displaystate import DisplayState, RecentDocsMenu from gui.displaystate import DisplayState, RecentDocsMenu
import const import const
import constfunc from gen.constfunc import is_quartz
from gen.config import config from gen.config import config
from gen.errors import WindowActiveError from gen.errors import WindowActiveError
from gui.dialog import (ErrorDialog, WarningDialog, QuestionDialog2, from gui.dialog import (ErrorDialog, WarningDialog, QuestionDialog2,
@ -103,7 +103,7 @@ from gen.utils.configmanager import safe_eval
# Constants # Constants
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
if constfunc.is_quartz(): if is_quartz():
try: try:
import gtk_osxapplication as QuartzApp import gtk_osxapplication as QuartzApp
_GTKOSXAPPLICATION = True _GTKOSXAPPLICATION = True

View File

@ -49,7 +49,7 @@ import gtk
from gui.views.pageview import PageView from gui.views.pageview import PageView
from gen.ggettext import sgettext as _ from gen.ggettext import sgettext as _
from Utils import navigation_label from Utils import navigation_label
from constfunc import mod_key from gen.constfunc import mod_key
DISABLED = -1 DISABLED = -1
MRU_SIZE = 10 MRU_SIZE = 10

View File

@ -38,14 +38,14 @@ _LOG = logging.getLogger(".widgets.expandcollapsearrow")
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import gtk import gtk
import constfunc from gen.constfunc import has_display
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Constants # Constants
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
if constfunc.has_display(): if has_display():
HAND_CURSOR = gtk.gdk.Cursor(gtk.gdk.HAND2) HAND_CURSOR = gtk.gdk.Cursor(gtk.gdk.HAND2)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------

View File

@ -47,14 +47,14 @@ import pango
# Gramps modules # Gramps modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import constfunc from gen.constfunc import has_display, win
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Constants # Constants
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
if constfunc.has_display(): if has_display():
HAND_CURSOR = gtk.gdk.Cursor(gtk.gdk.HAND2) HAND_CURSOR = gtk.gdk.Cursor(gtk.gdk.HAND2)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -208,7 +208,7 @@ class GenderLabel(gtk.Label):
def __init__(self, text): def __init__(self, text):
gtk.Label.__init__(self, text) gtk.Label.__init__(self, text)
self.set_alignment(0, 0.5) self.set_alignment(0, 0.5)
if constfunc.win(): if win():
pangoFont = pango.FontDescription('Arial') pangoFont = pango.FontDescription('Arial')
self.modify_font(pangoFont) self.modify_font(pangoFont)
self.show() self.show()

View File

@ -60,7 +60,7 @@ from gui.widgets.springseparator import SpringSeparatorAction
from gui.spell import Spell from gui.spell import Spell
from gui.display import display_url from gui.display import display_url
from gen.config import config from gen.config import config
from constfunc import has_display from gen.constfunc import has_display
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #

View File

@ -43,7 +43,7 @@ LOG = logging.getLogger(".grampsqml")
# GRAMPS modules # GRAMPS modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import constfunc from gen.constfunc import has_display
from gen.config import config from gen.config import config
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -136,7 +136,7 @@ def startqml(errors, argparser):
quit_now = False quit_now = False
openGL = True openGL = True
exit_code = 0 exit_code = 0
if constfunc.has_display(): if has_display():
GrampsQML(argparser) GrampsQML(argparser)
else: else:
print("Gramps terminated because of no DISPLAY") print("Gramps terminated because of no DISPLAY")

View File

@ -62,7 +62,7 @@ import gtk
from gui.plug.export import WriterOptionBox from gui.plug.export import WriterOptionBox
from ExportXml import XmlWriter from ExportXml import XmlWriter
import Utils import Utils
import constfunc from gen.constfunc import win
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -217,7 +217,7 @@ class PackageWriter(object):
tarinfo = tarfile.TarInfo('data.gramps') tarinfo = tarfile.TarInfo('data.gramps')
tarinfo.size = len(g.getvalue()) tarinfo.size = len(g.getvalue())
tarinfo.mtime = time.time() tarinfo.mtime = time.time()
if not constfunc.win(): if not win():
tarinfo.uid = os.getuid() tarinfo.uid = os.getuid()
tarinfo.gid = os.getgid() tarinfo.gid = os.getgid()
g.seek(0) g.seek(0)

View File

@ -61,7 +61,7 @@ import gen.lib
from gen.updatecallback import UpdateCallback from gen.updatecallback import UpdateCallback
from gen.db.exceptions import DbWriteFailure from gen.db.exceptions import DbWriteFailure
import const import const
import constfunc from gen.constfunc import win
from gui.plug.export import WriterOptionBox from gui.plug.export import WriterOptionBox
import libgrampsxml import libgrampsxml
@ -1198,7 +1198,7 @@ class GrampsXmlWriter(UpdateCallback):
elif self.strip_photos == 2 and (len(path)>0 and os.path.isabs(path)): elif self.strip_photos == 2 and (len(path)>0 and os.path.isabs(path)):
drive, path = os.path.splitdrive(path) drive, path = os.path.splitdrive(path)
path = path[1:] path = path[1:]
if constfunc.win(): if win():
# Always export path with \ replaced with /. Otherwise import # Always export path with \ replaced with /. Otherwise import
# from Windows to Linux of gpkg's path to images does not work. # from Windows to Linux of gpkg's path to images does not work.
path = path.replace('\\','/') path = path.replace('\\','/')

View File

@ -52,7 +52,6 @@ from gui.views.navigationview import NavigationView
from libformatting import FormattingHelper from libformatting import FormattingHelper
from gen.errors import WindowActiveError from gen.errors import WindowActiveError
import const import const
import constfunc
from gui.managedwindow import ManagedWindow from gui.managedwindow import ManagedWindow
from gen.config import config from gen.config import config
from gui.editors import EditPlace, EditEvent, EditFamily, EditPerson from gui.editors import EditPlace, EditEvent, EditFamily, EditPerson

View File

@ -60,7 +60,7 @@ import gtk
from gui.views.navigationview import NavigationView from gui.views.navigationview import NavigationView
from gui.views.bookmarks import PersonBookmarks from gui.views.bookmarks import PersonBookmarks
import Utils import Utils
import constfunc from gen.constfunc import lin, mac, win
from gen.config import config from gen.config import config
from const import TEMP_DIR from const import TEMP_DIR
@ -71,11 +71,11 @@ from const import TEMP_DIR
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def get_identity(): def get_identity():
if constfunc.lin(): if lin():
platform = "X11" platform = "X11"
elif constfunc.win(): elif win():
platform = "Windows" platform = "Windows"
elif constfunc.mac(): elif mac():
platform = "Macintosh" platform = "Macintosh"
else: else:
platform = "Unknown" platform = "Unknown"

View File

@ -53,7 +53,7 @@ from gui.utils import open_file_with_default_application
from gui.views.listview import ListView from gui.views.listview import ListView
from gui.views.treemodels import MediaModel from gui.views.treemodels import MediaModel
import const import const
import constfunc from gen.constfunc import win
from gen.config import config from gen.config import config
import Utils import Utils
from gui.views.bookmarks import MediaBookmarks from gui.views.bookmarks import MediaBookmarks
@ -174,7 +174,7 @@ class MediaView(ListView):
if not sel_data: if not sel_data:
return return
#modern file managers provide URI_LIST. For Windows split sel_data.data #modern file managers provide URI_LIST. For Windows split sel_data.data
if constfunc.win(): if win():
files = sel_data.data.split('\n') files = sel_data.data.split('\n')
else: else:
files = sel_data.get_uris() files = sel_data.get_uris()

View File

@ -62,7 +62,7 @@ import cPickle as pickle
from gen.config import config from gen.config import config
from gui.views.bookmarks import PersonBookmarks from gui.views.bookmarks import PersonBookmarks
import const import const
import constfunc from gen.constfunc import is_quartz, win
from gui.dialog import RunDatabaseRepair, ErrorDialog from gui.dialog import RunDatabaseRepair, ErrorDialog
import gui.utils import gui.utils
@ -71,7 +71,7 @@ import gui.utils
# Constants # Constants
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
if constfunc.is_quartz(): if is_quartz():
CAIRO_AVAILABLE = False CAIRO_AVAILABLE = False
else: else:
try: try:
@ -176,7 +176,7 @@ class PersonBoxWidgetCairo(_PersonWidgetBase):
self.maxlines = maxlines self.maxlines = maxlines
self.hightlight = False self.hightlight = False
self.connect("expose_event", self.expose) self.connect("expose_event", self.expose)
if not constfunc.win(): if not win():
self.connect("realize", self.realize) self.connect("realize", self.realize)
self.text = "" self.text = ""
if self.person: if self.person:
@ -257,7 +257,7 @@ class PersonBoxWidgetCairo(_PersonWidgetBase):
witout text. witout text.
""" """
# pylint: disable-msg=E1101 # pylint: disable-msg=E1101
if constfunc.win(): if win():
self.context = self.window.cairo_create() self.context = self.window.cairo_create()
self.textlayout = self.context.create_layout() self.textlayout = self.context.create_layout()
self.textlayout.set_font_description(self.get_style().font_desc) self.textlayout.set_font_description(self.get_style().font_desc)

View File

@ -89,7 +89,7 @@ from gen.plug.report import utils as ReportUtils
from gen.plug.report import MenuReportOptions from gen.plug.report import MenuReportOptions
import Utils import Utils
import constfunc from gen.constfunc import win
from gui.thumbnails import get_thumbnail_path, run_thumbnailer from gui.thumbnails import get_thumbnail_path, run_thumbnailer
import ImgManip import ImgManip
import gen.mime import gen.mime
@ -5767,7 +5767,7 @@ class IndividualPage(BasePage):
newpath = copy_thumbnail(self.report, photo_handle, photo, region) newpath = copy_thumbnail(self.report, photo_handle, photo, region)
# TODO. Check if build_url_fname can be used. # TODO. Check if build_url_fname can be used.
newpath = "/".join(['..']*3 + [newpath]) newpath = "/".join(['..']*3 + [newpath])
if constfunc.win(): if win():
newpath = newpath.replace('\\',"/") newpath = newpath.replace('\\',"/")
thumbnailUrl = newpath thumbnailUrl = newpath
#snapshot += self.media_link(photo_handle, newpath, '', uplink = True) #snapshot += self.media_link(photo_handle, newpath, '', uplink = True)
@ -5775,7 +5775,7 @@ class IndividualPage(BasePage):
else: else:
(photoUrl, thumbnailUrl) = self.report.prepare_copy_media(photo) (photoUrl, thumbnailUrl) = self.report.prepare_copy_media(photo)
thumbnailUrl = "/".join(['..']*3 + [thumbnailUrl]) thumbnailUrl = "/".join(['..']*3 + [thumbnailUrl])
if constfunc.win(): if win():
thumbnailUrl = thumbnailUrl.replace('\\',"/") thumbnailUrl = thumbnailUrl.replace('\\',"/")
url = self.report.build_url_fname_html(person.handle, "ppl", True) url = self.report.build_url_fname_html(person.handle, "ppl", True)
boxbg += self.person_link(url, person, name_style = True, thumbnailUrl = thumbnailUrl) boxbg += self.person_link(url, person, name_style = True, thumbnailUrl = thumbnailUrl)
@ -7509,7 +7509,7 @@ class NavWebReport(Report):
if up: if up:
subdirs = ['..']*3 + subdirs subdirs = ['..']*3 + subdirs
nname = "/".join(subdirs + [fname]) nname = "/".join(subdirs + [fname])
if constfunc.win(): if win():
nname = nname.replace('\\',"/") nname = nname.replace('\\',"/")
return nname return nname
@ -7577,7 +7577,7 @@ class NavWebReport(Report):
if not fname: if not fname:
return "" return ""
if constfunc.win(): if win():
fname = fname.replace('\\',"/") fname = fname.replace('\\',"/")
subdirs = self.build_subdirs(subdir, fname, up) subdirs = self.build_subdirs(subdir, fname, up)
return "/".join(subdirs + [fname]) return "/".join(subdirs + [fname])
@ -7622,7 +7622,7 @@ class NavWebReport(Report):
tarinfo = tarfile.TarInfo(self.cur_fname) tarinfo = tarfile.TarInfo(self.cur_fname)
tarinfo.size = len(string_io.getvalue()) tarinfo.size = len(string_io.getvalue())
tarinfo.mtime = time.time() tarinfo.mtime = time.time()
if not constfunc.win(): if not win():
tarinfo.uid = os.getuid() tarinfo.uid = os.getuid()
tarinfo.gid = os.getgid() tarinfo.gid = os.getgid()
string_io.seek(0) string_io.seek(0)

View File

@ -51,7 +51,7 @@ log = logging.getLogger(".WebPage")
#------------------------------------------------------------------------ #------------------------------------------------------------------------
import gen.lib import gen.lib
import const import const
import constfunc from gen.constfunc import win
from gen.plug.report import Report from gen.plug.report import Report
from gen.plug.report import utils as ReportUtils from gen.plug.report import utils as ReportUtils
from gen.plug.report import MenuReportOptions from gen.plug.report import MenuReportOptions
@ -1006,7 +1006,7 @@ class WebCalReport(Report):
Imagine we run gramps on Windows (heaven forbits), we don't want to Imagine we run gramps on Windows (heaven forbits), we don't want to
see backslashes in the URL. see backslashes in the URL.
""" """
if (constfunc.win()): if win():
fname = fname.replace('\\',"/") fname = fname.replace('\\',"/")
subdirs = self.build_subdirs(subdir, fname) subdirs = self.build_subdirs(subdir, fname)
return (prefix or '') + "/".join(subdirs + [fname]) return (prefix or '') + "/".join(subdirs + [fname])