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
- "release_info.txt"]),
+ "Changelog"]),
("share/pycam/ui", [
os.path.join("share", "gtk-interface", "pycam-project.ui"),
os.path.join("share", "gtk-interface", "menubar.xml"),
os.path.join("share", "ui", "pycam-project.ui"),
os.path.join("share", "ui", "menubar.xml"),
# -*- mode: python -*-
BASE_DIR = os.path.realpath(os.path.join(os.path.dirname(locals()["spec"]),
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"),
("menubar.xml", os.path.join(BASE_DIR, "share", "gtk-interface", "menubar.xml"), "DATA"),
("logo_gui.png", os.path.join(BASE_DIR, "share", "gtk-interface", "logo_gui.png"), "DATA"),
data = [("pycam-project.ui", os.path.join(UI_DATA_DIR, "pycam-project.ui"), "DATA"),
("menubar.xml", os.path.join(UI_DATA_DIR, "menubar.xml"), "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"),
os.path.join(os.environ["COMMONPROGRAMFILES"], "Gtk"))
def find_gtk_pixbuf_dir(dirs):
......@@ -20,6 +22,7 @@ if gtk_loaders_dir is None:
print >>sys.stderr, "Failed to locate Gtk installation (looking for libpixbufloader-png.dll)"
sys.exit(1)
# configure the pixbufloader (for the Windows standalone executable)
config_dir = gtk_loaders_dir
config_relative = os.path.join("etc", "gtk-2.0", "gdk-pixbuf.loaders")
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):
5) "python PYINSTALLER_PATH\Build.py pyinstaller\pycam.spec"
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 @@
- standalone binary (Windows): no specific architecture
5) announcements
- run "python setup.py register" (for the PyPI package index)
- create a project news items at sourceforge
- create a new release at http://freshmeat.net
- post the new release at http://www.cnczone.com/forums/showthread.php?t=63716
......
[bdist_wininst]
install_script = pycam_win32_postinstall.py
bitmap = share/gtk-interface/logo_gui_vertical.bmp
bitmap = share/ui/logo_gui_vertical.bmp
[bdist_rpm]
packager = Lars Kruse <devel@sumpfralle.de>
......
......@@ -86,9 +86,9 @@ Basically you will need Python, GTK and OpenGL.
"Changelog",
"release_info.txt"]),
("share/pycam/ui", [
os.path.join("share", "gtk-interface", "pycam-project.ui"),
os.path.join("share", "gtk-interface", "menubar.xml"),
os.path.join("share", "gtk-interface", "logo_gui.png"),
os.path.join("share", "ui", "pycam-project.ui"),
os.path.join("share", "ui", "menubar.xml"),
os.path.join("share", "ui", "logo_gui.png"),
]),
("share/pycam", [os.path.join("share", "pycam.ico")]),
("share/pycam/samples", glob.glob(os.path.join("samples", "*"))),
......
......@@ -57,11 +57,11 @@ import os
import sys
DATA_DIR_ENVIRON_KEY = "PYCAM_DATA_DIR"
DATA_BASE_DIRS = [os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
os.pardir, "share", "gtk-interface"),
os.path.join(sys.prefix, "share", "pycam", "ui")]
# TODO: improve this definition of the fonts' location
FONT_DIRS = [os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, "share", "fonts")]
DATA_BASE_DIRS = [os.path.realpath(os.path.join(os.path.dirname(__file__),
os.pardir, os.pardir, os.pardir, "share")),
os.path.join(sys.prefix, "share", "pycam")]
UI_SUBDIR = "ui"
FONTS_SUBDIR = "fonts"
# necessary for "pyinstaller"
if "_MEIPASS2" in os.environ:
DATA_BASE_DIRS.insert(0, os.environ["_MEIPASS2"])
......@@ -69,8 +69,8 @@ if "_MEIPASS2" in os.environ:
if DATA_DIR_ENVIRON_KEY in os.environ:
DATA_BASE_DIRS.insert(0, os.environ[DATA_DIR_ENVIRON_KEY])
GTKBUILD_FILE = "pycam-project.ui"
GTKMENU_FILE = "menubar.xml"
GTKBUILD_FILE = os.path.join(UI_SUBDIR, "pycam-project.ui")
GTKMENU_FILE = os.path.join(UI_SUBDIR, "menubar.xml")
HELP_WIKI_URL = "http://sourceforge.net/apps/mediawiki/pycam/index.php?title=%s"
......@@ -126,15 +126,18 @@ GTK_COLOR_MAX = 65535.0
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:
test_path = os.path.join(base_dir, filename)
if os.path.exists(test_path):
return test_path
else:
if not silent:
lines = []
lines.append("Failed to locate a resource file (%s) in %s!" % (filename, DATA_BASE_DIRS))
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!" \
% (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
......@@ -161,8 +164,12 @@ def get_filters_from_list(filter_list, file_filter=True):
return result
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 = []
for font_dir in FONT_DIRS:
files = os.listdir(font_dir)
for fname in files:
filename = os.path.join(font_dir, fname)
......@@ -1608,15 +1615,21 @@ class ProjectGui:
self.update_font_dialog_preview)
font_selector.show()
self.font_selector = font_selector
if self._fonts:
# show the dialog only if fonts are available
if self._font_dialog_window_position:
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:
self._font_dialog_window_position = \
self.font_dialog_window.get_position()
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")
return True
......@@ -1647,7 +1660,8 @@ class ProjectGui:
@gui_activity_guard
def update_font_dialog_preview(self, widget=None, event=None):
if self._fonts is None:
if not self._fonts:
# not initialized or empty
return
font_name = self.font_selector.get_active_text()
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