Commit 47aaa319 authored by sumpfralle's avatar sumpfralle

disabled RecentManager for Windows (due to a weird "no stock-icon found" error message)

fixed some more path issues
fixed path handling (local path to URI style) for RecentManager items


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@944 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent e1d5e5da
......@@ -51,6 +51,7 @@ import gobject
import webbrowser
import ConfigParser
import urllib
import urlparse
import string
import StringIO
import pickle
......@@ -73,12 +74,12 @@ UI_SUBDIR = "ui"
FONTS_SUBDIR = "fonts"
# necessary for "pyinstaller"
if "_MEIPASS2" in os.environ:
DATA_BASE_DIRS.insert(0, os.environ["_MEIPASS2"])
DATA_BASE_DIRS.insert(0, os.path.normpath(os.environ["_MEIPASS2"]))
# respect an override via an environment setting
if DATA_DIR_ENVIRON_KEY in os.environ:
DATA_BASE_DIRS.insert(0, os.environ[DATA_DIR_ENVIRON_KEY])
DATA_BASE_DIRS.insert(0, os.path.normpath(os.environ[DATA_DIR_ENVIRON_KEY]))
if FONT_DIR_ENVIRON_KEY in os.environ:
FONT_DIR_OVERRIDE = os.environ[FONT_DIR_ENVIRON_KEY]
FONT_DIR_OVERRIDE = os.path.normpath(os.environ[FONT_DIR_ENVIRON_KEY])
else:
FONT_DIR_OVERRIDE = None
FONT_DIR_FALLBACK = "/usr/share/qcad/fonts"
......@@ -286,12 +287,18 @@ class ProjectGui:
# increase the initial width of the window (due to hidden elements)
self.window.set_default_size(400, -1)
# initialize the RecentManager
if pycam.Utils.get_platform() == pycam.Utils.PLATFORM_WINDOWS:
# The pyinstaller binary for Windows fails mysteriously when trying
# to display the stock item.
# Error message: Gtk:ERROR:gtkrecentmanager.c:1942:get_icon_fallback: assertion failed: (retval != NULL)
self.recent_manager = None
else:
try:
self.recent_manager = gtk.RecentManager()
except AttributeError:
# GTK 2.12.1 seems to have problems with "RecentManager" on Windows.
# Sadly this is the version, that is shipped with the "appunti" GTK
# packages for Windows (April 2010).
# GTK 2.12.1 seems to have problems with "RecentManager" on
# Windows. Sadly this is the version, that is shipped with the
# "appunti" GTK packages for Windows (April 2010).
# see http://www.daa.com.au/pipermail/pygtk/2009-May/017052.html
self.recent_manager = None
# file loading
......@@ -1010,7 +1017,7 @@ class ProjectGui:
recent_files_menu.connect("item-activated",
self.load_recent_model_file)
else:
self.gui.get_object("OpenRecentModel").hide()
self.gui.get_object("OpenRecentModel").set_visible(False)
# load the menubar and connect functions to its items
self.menubar = uimanager.get_widget("/MenuBar")
window_box = self.gui.get_object("WindowBox")
......@@ -3717,8 +3724,14 @@ class ProjectGui:
if os.path.isfile(filename):
# skip this, if the recent manager is not available (e.g. GTK 2.12.1 on Windows)
if self.recent_manager:
self.recent_manager.add_item("file://%s" \
% str(os.path.abspath(filename)))
# Convert the local path to a URI filename style. This is
# specifically necessary under Windows (due to backslashs).
filename_url_local = urllib.pathname2url(
os.path.abspath(filename))
# join the "file:" scheme with the url
filename_url = urlparse.urlunparse(("file", None,
filename_url_local, None, None, None))
self.recent_manager.add_item(filename_url)
# store the directory of the last loaded file
self.last_dirname = os.path.dirname(os.path.abspath(filename))
......
......@@ -20,13 +20,21 @@ You should have received a copy of the GNU General Public License
along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
"""
__all__ = [ "iterators", "polynomials", "ProgressCounter", "threading"]
__all__ = ["iterators", "polynomials", "ProgressCounter", "threading",
"get_platform", "get_external_program_location", "PLATFORM_WINDOWS",
"PLATFORM_MACOS", "PLATFORM_LINUX", "PLATFORM_UNKNOWN"]
import sys
import os
# this is imported below on demand
#import win32com
#import win32api
PLATFORM_LINUX = 0
PLATFORM_WINDOWS = 1
PLATFORM_MACOS = 2
PLATFORM_UNKNOWN = 3
# setproctitle is (optionally) imported
try:
from setproctitle import setproctitle
......@@ -35,6 +43,17 @@ except ImportError:
setproctitle = lambda name: None
def get_platform():
if hasattr(sys, "getwindowsversion"):
return PLATFORM_WINDOWS
elif sys.platform == "darwin":
return PLATFORM_MACOS
elif sys.platform.startswith("linux"):
return PLATFORM_LINUX
else:
return PLATFORM_UNKNOWN
def get_external_program_location(key):
extensions = ["", ".exe"]
potential_names = ["%s%s" % (key, ext) for ext in extensions]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment