Commit 29c1e170 authored by sumpfralle's avatar sumpfralle

changed the directory of the UI components

improved handling of non-existing font directory


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@847 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 6ff33000
...@@ -19,5 +19,5 @@ index 3046304..9f66f6d 100755 ...@@ -19,5 +19,5 @@ index 3046304..9f66f6d 100755
- "release_info.txt"]), - "release_info.txt"]),
+ "Changelog"]), + "Changelog"]),
("share/pycam/ui", [ ("share/pycam/ui", [
os.path.join("share", "gtk-interface", "pycam-project.ui"), os.path.join("share", "ui", "pycam-project.ui"),
os.path.join("share", "gtk-interface", "menubar.xml"), os.path.join("share", "ui", "menubar.xml"),
# -*- mode: python -*- # -*- mode: python -*-
BASE_DIR = os.path.realpath(os.path.join(os.path.dirname(locals()["spec"]), BASE_DIR = os.path.realpath(os.path.join(os.path.dirname(locals()["spec"]),
os.path.pardir)) os.path.pardir))
UI_DATA_DIR = os.path.join(BASE_DIR, "share", "ui")
data = [("pycam-project.ui", os.path.join(BASE_DIR, "share", "gtk-interface", "pycam-project.ui"), "DATA"), data = [("pycam-project.ui", os.path.join(UI_DATA_DIR, "pycam-project.ui"), "DATA"),
("menubar.xml", os.path.join(BASE_DIR, "share", "gtk-interface", "menubar.xml"), "DATA"), ("menubar.xml", os.path.join(UI_DATA_DIR, "menubar.xml"), "DATA"),
("logo_gui.png", os.path.join(BASE_DIR, "share", "gtk-interface", "logo_gui.png"), "DATA"), ("logo_gui.png", os.path.join(UI_DATA_DIR, "logo_gui.png"), "DATA"),
] ]
# look for the location of "libpixbufloader-png.dll" (for Windows standalone executable)
start_dirs = (os.path.join(os.environ["PROGRAMFILES"], "Common files", "Gtk"), start_dirs = (os.path.join(os.environ["PROGRAMFILES"], "Common files", "Gtk"),
os.path.join(os.environ["COMMONPROGRAMFILES"], "Gtk")) os.path.join(os.environ["COMMONPROGRAMFILES"], "Gtk"))
def find_gtk_pixbuf_dir(dirs): def find_gtk_pixbuf_dir(dirs):
...@@ -20,6 +22,7 @@ if gtk_loaders_dir is None: ...@@ -20,6 +22,7 @@ if gtk_loaders_dir is None:
print >>sys.stderr, "Failed to locate Gtk installation (looking for libpixbufloader-png.dll)" print >>sys.stderr, "Failed to locate Gtk installation (looking for libpixbufloader-png.dll)"
sys.exit(1) sys.exit(1)
# configure the pixbufloader (for the Windows standalone executable)
config_dir = gtk_loaders_dir config_dir = gtk_loaders_dir
config_relative = os.path.join("etc", "gtk-2.0", "gdk-pixbuf.loaders") config_relative = os.path.join("etc", "gtk-2.0", "gdk-pixbuf.loaders")
while not os.path.isfile(os.path.join(config_dir, config_relative)): while not os.path.isfile(os.path.join(config_dir, config_relative)):
......
...@@ -9,5 +9,6 @@ How to build a standalone exe file (on Windows only): ...@@ -9,5 +9,6 @@ How to build a standalone exe file (on Windows only):
5) "python PYINSTALLER_PATH\Build.py pyinstaller\pycam.spec" 5) "python PYINSTALLER_PATH\Build.py pyinstaller\pycam.spec"
6) test and upload the binary file "pycam-VERSION_standalone.exe" 6) test and upload the binary file "pycam-VERSION_standalone.exe"
Known issues: currently none Known issues:
* multiprocessing does not work with standalone executable
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
- standalone binary (Windows): no specific architecture - standalone binary (Windows): no specific architecture
5) announcements 5) announcements
- run "python setup.py register" (for the PyPI package index)
- create a project news items at sourceforge - create a project news items at sourceforge
- create a new release at http://freshmeat.net - create a new release at http://freshmeat.net
- post the new release at http://www.cnczone.com/forums/showthread.php?t=63716 - post the new release at http://www.cnczone.com/forums/showthread.php?t=63716
......
[bdist_wininst] [bdist_wininst]
install_script = pycam_win32_postinstall.py install_script = pycam_win32_postinstall.py
bitmap = share/gtk-interface/logo_gui_vertical.bmp bitmap = share/ui/logo_gui_vertical.bmp
[bdist_rpm] [bdist_rpm]
packager = Lars Kruse <devel@sumpfralle.de> packager = Lars Kruse <devel@sumpfralle.de>
......
...@@ -86,9 +86,9 @@ Basically you will need Python, GTK and OpenGL. ...@@ -86,9 +86,9 @@ Basically you will need Python, GTK and OpenGL.
"Changelog", "Changelog",
"release_info.txt"]), "release_info.txt"]),
("share/pycam/ui", [ ("share/pycam/ui", [
os.path.join("share", "gtk-interface", "pycam-project.ui"), os.path.join("share", "ui", "pycam-project.ui"),
os.path.join("share", "gtk-interface", "menubar.xml"), os.path.join("share", "ui", "menubar.xml"),
os.path.join("share", "gtk-interface", "logo_gui.png"), os.path.join("share", "ui", "logo_gui.png"),
]), ]),
("share/pycam", [os.path.join("share", "pycam.ico")]), ("share/pycam", [os.path.join("share", "pycam.ico")]),
("share/pycam/samples", glob.glob(os.path.join("samples", "*"))), ("share/pycam/samples", glob.glob(os.path.join("samples", "*"))),
......
...@@ -57,11 +57,11 @@ import os ...@@ -57,11 +57,11 @@ import os
import sys import sys
DATA_DIR_ENVIRON_KEY = "PYCAM_DATA_DIR" DATA_DIR_ENVIRON_KEY = "PYCAM_DATA_DIR"
DATA_BASE_DIRS = [os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, DATA_BASE_DIRS = [os.path.realpath(os.path.join(os.path.dirname(__file__),
os.pardir, "share", "gtk-interface"), os.pardir, os.pardir, os.pardir, "share")),
os.path.join(sys.prefix, "share", "pycam", "ui")] os.path.join(sys.prefix, "share", "pycam")]
# TODO: improve this definition of the fonts' location UI_SUBDIR = "ui"
FONT_DIRS = [os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, "share", "fonts")] FONTS_SUBDIR = "fonts"
# necessary for "pyinstaller" # necessary for "pyinstaller"
if "_MEIPASS2" in os.environ: if "_MEIPASS2" in os.environ:
DATA_BASE_DIRS.insert(0, os.environ["_MEIPASS2"]) DATA_BASE_DIRS.insert(0, os.environ["_MEIPASS2"])
...@@ -69,8 +69,8 @@ if "_MEIPASS2" in os.environ: ...@@ -69,8 +69,8 @@ if "_MEIPASS2" in os.environ:
if DATA_DIR_ENVIRON_KEY in os.environ: 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.environ[DATA_DIR_ENVIRON_KEY])
GTKBUILD_FILE = "pycam-project.ui" GTKBUILD_FILE = os.path.join(UI_SUBDIR, "pycam-project.ui")
GTKMENU_FILE = "menubar.xml" GTKMENU_FILE = os.path.join(UI_SUBDIR, "menubar.xml")
HELP_WIKI_URL = "http://sourceforge.net/apps/mediawiki/pycam/index.php?title=%s" HELP_WIKI_URL = "http://sourceforge.net/apps/mediawiki/pycam/index.php?title=%s"
...@@ -126,16 +126,19 @@ GTK_COLOR_MAX = 65535.0 ...@@ -126,16 +126,19 @@ GTK_COLOR_MAX = 65535.0
log = pycam.Utils.log.get_logger() log = pycam.Utils.log.get_logger()
def get_data_file_location(filename): def get_data_file_location(filename, silent=False):
for base_dir in DATA_BASE_DIRS: for base_dir in DATA_BASE_DIRS:
test_path = os.path.join(base_dir, filename) test_path = os.path.join(base_dir, filename)
if os.path.exists(test_path): if os.path.exists(test_path):
return test_path return test_path
else: else:
lines = [] if not silent:
lines.append("Failed to locate a resource file (%s) in %s!" % (filename, DATA_BASE_DIRS)) lines = []
lines.append("You can extend the search path by setting the environment variable '%s'." % str(DATA_DIR_ENVIRON_KEY)) lines.append("Failed to locate a resource file (%s) in %s!" \
log.error(os.linesep.join(lines)) % (filename, DATA_BASE_DIRS))
lines.append("You can extend the search path by setting the " \
+ "environment variable '%s'." % str(DATA_DIR_ENVIRON_KEY))
log.error(os.linesep.join(lines))
return None return None
def report_exception(): def report_exception():
...@@ -161,13 +164,17 @@ def get_filters_from_list(filter_list, file_filter=True): ...@@ -161,13 +164,17 @@ def get_filters_from_list(filter_list, file_filter=True):
return result return result
def get_font_files(): def get_font_files():
font_dir = get_data_file_location(FONTS_SUBDIR, silent=True)
if font_dir is None:
log.warn("Failed to locate the fonts directory '%s' below '%s'." \
% (FONTS_SUBDIR, DATA_BASE_DIRS))
return []
result = [] result = []
for font_dir in FONT_DIRS: files = os.listdir(font_dir)
files = os.listdir(font_dir) for fname in files:
for fname in files: filename = os.path.join(font_dir, fname)
filename = os.path.join(font_dir, fname) if filename.lower().endswith(".cxf") and os.path.isfile(filename):
if filename.lower().endswith(".cxf") and os.path.isfile(filename): result.append(filename)
result.append(filename)
result.sort() result.sort()
return result return result
...@@ -1608,15 +1615,21 @@ class ProjectGui: ...@@ -1608,15 +1615,21 @@ class ProjectGui:
self.update_font_dialog_preview) self.update_font_dialog_preview)
font_selector.show() font_selector.show()
self.font_selector = font_selector self.font_selector = font_selector
if self._font_dialog_window_position: if self._fonts:
self.font_dialog_window.move( # show the dialog only if fonts are available
*self._font_dialog_window_position) if self._font_dialog_window_position:
self.font_dialog_window.show() self.font_dialog_window.move(
*self._font_dialog_window_position)
self.font_dialog_window.show()
self._font_dialog_window_visible = True
else:
log.error("No fonts were found on your system. " \
+ "Please check the Log Window for details.")
else: else:
self._font_dialog_window_position = \ self._font_dialog_window_position = \
self.font_dialog_window.get_position() self.font_dialog_window.get_position()
self.font_dialog_window.hide() self.font_dialog_window.hide()
self._font_dialog_window_visible = state self._font_dialog_window_visible = False
# don't close the window - just hide it (for "delete-event") # don't close the window - just hide it (for "delete-event")
return True return True
...@@ -1647,7 +1660,8 @@ class ProjectGui: ...@@ -1647,7 +1660,8 @@ class ProjectGui:
@gui_activity_guard @gui_activity_guard
def update_font_dialog_preview(self, widget=None, event=None): def update_font_dialog_preview(self, widget=None, event=None):
if self._fonts is None: if not self._fonts:
# not initialized or empty
return return
font_name = self.font_selector.get_active_text() font_name = self.font_selector.get_active_text()
font = self._fonts[font_name] font = self._fonts[font_name]
......
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