Icons: Add our custom icons to the search path
But only when we're running in debug mode. Running while installed should use the icons from the default search path Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
d98eca8533
commit
ba5f21b0c0
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 6.4 KiB |
|
@ -10,7 +10,7 @@ trier = os.path.abspath("trier")
|
|||
ffmpeg = "ffmpeg -hide_banner -nostdin -f s16le -i /dev/zero -codec libvorbis -loglevel warning".split()
|
||||
|
||||
image = mutagen.flac.Picture()
|
||||
image.data = open("emmental.png", "rb").read()
|
||||
image.data = open("data/emmental.png", "rb").read()
|
||||
image.type = mutagen.id3.PictureType.COVER_FRONT
|
||||
image.mime = u"image/png"
|
||||
image.width = 512
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright 2021 (c) Anna Schumaker.
|
||||
from . import icons
|
||||
from . import window
|
||||
from gi.repository import Gtk
|
||||
|
||||
|
|
13
ui/icons.py
13
ui/icons.py
|
@ -1 +1,14 @@
|
|||
# Copyright 2021 (c) Anna Schumaker.
|
||||
from . import window
|
||||
from lib import version
|
||||
from gi.repository import Gtk
|
||||
import pathlib
|
||||
|
||||
IconPath = pathlib.Path("data/").absolute()
|
||||
|
||||
if version.DEBUG == True:
|
||||
Display = window.Window.get_display()
|
||||
Theme = Gtk.IconTheme.get_for_display(Display)
|
||||
|
||||
paths = Theme.get_search_path()
|
||||
Theme.set_search_path([ str(IconPath) ] + paths)
|
||||
|
|
|
@ -1 +1,20 @@
|
|||
# Copyright 2021 (c) Anna Schumaker.
|
||||
from . import icons
|
||||
from . import window
|
||||
from gi.repository import Gdk, Gtk
|
||||
import pathlib
|
||||
import unittest
|
||||
|
||||
Path = pathlib.Path("./data").absolute()
|
||||
|
||||
class TestUIIcons(unittest.TestCase):
|
||||
def test_icons(self):
|
||||
self.assertIsInstance(icons.Display, Gdk.Display)
|
||||
self.assertIsInstance(icons.Theme, Gtk.IconTheme)
|
||||
|
||||
self.assertEqual(icons.Display, window.Window.get_display())
|
||||
self.assertEqual(icons.Theme, Gtk.IconTheme.get_for_display(icons.Display))
|
||||
self.assertEqual(icons.IconPath, Path)
|
||||
|
||||
self.assertIn(str(Path), icons.Theme.get_search_path())
|
||||
self.assertTrue(icons.Theme.has_icon("emmental"))
|
||||
|
|
Loading…
Reference in New Issue