Skip to content

Commit

Permalink
#3964 split images from icons
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Oct 11, 2023
1 parent c91d48a commit 70747b8
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 15 deletions.
File renamed without changes
1 change: 1 addition & 0 deletions packaging/debian/xpra/xpra-common.files
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions packaging/rpm/xpra.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/*"))

#*******************************************************************************
Expand Down
10 changes: 5 additions & 5 deletions xpra/gtk/configure/gstreamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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()
Expand All @@ -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.",
Expand Down
6 changes: 6 additions & 0 deletions xpra/platform/darwin/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
27 changes: 17 additions & 10 deletions xpra/platform/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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(),
Expand Down
4 changes: 4 additions & 0 deletions xpra/platform/posix/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 4 additions & 0 deletions xpra/platform/win32/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 70747b8

Please sign in to comment.