diff --git a/fs/share/xpra/icons/warning.png b/fs/share/xpra/images/warning.png similarity index 100% rename from fs/share/xpra/icons/warning.png rename to fs/share/xpra/images/warning.png diff --git a/packaging/debian/xpra/xpra-common.files b/packaging/debian/xpra/xpra-common.files index c5fd9d04df..d344a26681 100644 --- a/packaging/debian/xpra/xpra-common.files +++ b/packaging/debian/xpra/xpra-common.files @@ -2,6 +2,7 @@ usr/bin/xpra usr/share/xpra/README.md usr/share/xpra/COPYING usr/share/xpra/icons/ +usr/share/xpra/images/ usr/share/xpra/*.wav usr/share/man/man1/xpra.1* usr/share/metainfo/xpra.appdata.xml diff --git a/packaging/rpm/xpra.spec b/packaging/rpm/xpra.spec index 316ab83668..78c086f101 100644 --- a/packaging/rpm/xpra.spec +++ b/packaging/rpm/xpra.spec @@ -548,6 +548,7 @@ rm -rf $RPM_BUILD_ROOT %{_datadir}/xpra/README.md %{_datadir}/xpra/COPYING %{_datadir}/xpra/icons +%{_datadir}/xpra/images %{_datadir}/xpra/*.wav %{_datadir}/man/man1/xpra*.1* %{_datadir}/man/man1/run_scaled.1* diff --git a/setup.py b/setup.py index 8643b30bd3..da88ca60bb 100755 --- a/setup.py +++ b/setup.py @@ -2031,6 +2031,7 @@ def noop(*_args, **_kwargs): # pylint: disable=function-redefined if WIN32: ICONS += glob.glob("fs/share/xpra/icons/*.ico") add_data_files(f"{share_xpra}/icons", ICONS) + add_data_files(f"{share_xpra}/images", glob.glob("fs/share/xpra/images/*.png")) add_data_files(f"{share_xpra}/css", glob.glob("fs/share/xpra/css/*")) #******************************************************************************* diff --git a/xpra/gtk/configure/gstreamer.py b/xpra/gtk/configure/gstreamer.py index dc1332bc7c..d27ca2f22b 100644 --- a/xpra/gtk/configure/gstreamer.py +++ b/xpra/gtk/configure/gstreamer.py @@ -8,7 +8,7 @@ from xpra.gtk.dialogs.base_gui_window import BaseGUIWindow from xpra.gtk.widget import label -from xpra.platform.paths import get_icon +from xpra.platform.paths import get_image from xpra.log import Logger gi.require_version('Gtk', '3.0') @@ -31,7 +31,7 @@ class ConfigureGUI(BaseGUIWindow): def __init__(self, parent:Gtk.Window|None=None): self.warning_shown = False - self.warning_pixbuf = get_icon("warning.png") + self.warning_pixbuf = get_image("warning.png") size = (800, 554) if self.warning_pixbuf: size = self.warning_pixbuf.get_width(), self.warning_pixbuf.get_height() @@ -58,9 +58,9 @@ def populate(self): def populate_with_warning(self): layout = Gtk.Layout() self.vbox.add(layout) - pixbuf = get_icon("warning.png") - image = Gtk.Image.new_from_pixbuf(pixbuf) - layout.put(image, 0, 0) + if self.warning_pixbuf: + image = Gtk.Image.new_from_pixbuf(self.warning_pixbuf) + layout.put(image, 0, 0) for i, text in enumerate(( "This tool can cause your system to crash,", "it may even damage hardware in rare cases.", diff --git a/xpra/platform/darwin/paths.py b/xpra/platform/darwin/paths.py index 319f161b1f..eea1d7b9b6 100644 --- a/xpra/platform/darwin/paths.py +++ b/xpra/platform/darwin/paths.py @@ -62,6 +62,12 @@ def do_get_app_dir() -> str: debug("get_app_dir()=%s", rsc) return rsc #hope for the best.. +def do_get_image_dir() -> str: + from xpra.platform.paths import get_resources_dir + i = os.path.join(get_resources_dir(), "share", "xpra", "images") + debug("get_image_dir()=%s", i) + return i + def do_get_icon_dir() -> str: from xpra.platform.paths import get_resources_dir i = os.path.join(get_resources_dir(), "share", "xpra", "icons") diff --git a/xpra/platform/paths.py b/xpra/platform/paths.py index 76a3a2ade2..27b2869d7c 100755 --- a/xpra/platform/paths.py +++ b/xpra/platform/paths.py @@ -202,18 +202,22 @@ def do_get_resources_dir() -> str: return get_app_dir() #may be overridden in platform code: + +def get_image(name:str): + filename = os.path.join(get_image_dir(), name) + from xpra.gtk.pixbuf import get_icon_from_file + return get_icon_from_file(filename) + +def get_image_dir() -> str: + return env_or_delegate("XPRA_IMAGE_DIR", do_get_image_dir) +def do_get_image_dir() -> str: + raise NotImplementedError() + + def get_icon_dir() -> str: return env_or_delegate("XPRA_ICON_DIR", do_get_icon_dir) def do_get_icon_dir() -> str: - adir = get_app_dir() - idir = os.path.join(adir, "icons") - if valid_dir(idir): - return idir - for prefix in (sys.exec_prefix, "/usr", "/usr/local"): - idir = os.path.join(prefix, "icons") - if os.path.exists(idir): - return idir - return adir #better than nothing :( + raise NotImplementedError() def get_icon(name:str): filename = get_icon_filename(name) @@ -297,7 +301,9 @@ def do_get_python_execfile_command() -> list[str]: platform_import(globals(), "paths", True, "do_get_resources_dir", "do_get_app_dir", - "do_get_icon_dir") + "do_get_icon_dir", + "do_get_image_dir", + ) platform_import(globals(), "paths", False, "do_get_sshpass_command", "do_get_xpra_command", @@ -355,6 +361,7 @@ def get_info(): "ssh-known-hosts" : get_ssh_known_hosts_files(), "resources" : get_resources_dir(), "icons" : get_icon_dir(), + "images" : get_image_dir(), "home" : os.path.expanduser("~"), "xpra_command" : get_xpra_command(), "nodock_command" : get_nodock_command(), diff --git a/xpra/platform/posix/paths.py b/xpra/platform/posix/paths.py index e8068ec1cf..8d0b393f31 100644 --- a/xpra/platform/posix/paths.py +++ b/xpra/platform/posix/paths.py @@ -59,6 +59,10 @@ def do_get_app_dir(): from xpra.platform.paths import get_resources_dir return get_resources_dir() +def do_get_image_dir(): + from xpra.platform.paths import get_app_dir + return os.path.join(get_app_dir(), "images") + def do_get_icon_dir(): from xpra.platform.paths import get_app_dir return os.path.join(get_app_dir(), "icons") diff --git a/xpra/platform/win32/paths.py b/xpra/platform/win32/paths.py index 5ae79de753..cfb5419cd7 100644 --- a/xpra/platform/win32/paths.py +++ b/xpra/platform/win32/paths.py @@ -67,6 +67,10 @@ def do_get_resources_dir() -> str: return share_xpra return app_dir +def do_get_image_dir() -> str: + from xpra.platform.paths import get_resources_dir + return os.path.join(get_resources_dir(), "images") + def do_get_icon_dir() -> str: from xpra.platform.paths import get_resources_dir return os.path.join(get_resources_dir(), "icons")