Commit df786b9b authored by Kai Willadsen's avatar Kai Willadsen

Add scaffolding for GResource build + load support

Predictably, distutils makes this harder than you'd like. However, it's
not that bad and it makes a bunch of resource handling code much, much
nicer.
parent 91c3f4e2
......@@ -222,11 +222,17 @@ def check_requirements():
def setup_resources():
from gi.repository import Gio
from gi.repository import GLib
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import GtkSource
if not uninstalled:
resource_file = os.path.join(meld.conf.DATADIR, "meld.gresource")
resources = Gio.resource_load(resource_file)
Gio.resources_register(resources)
icon_dir = os.path.join(meld.conf.DATADIR, "icons")
Gtk.IconTheme.get_default().append_search_path(icon_dir)
......
......@@ -78,6 +78,11 @@ class build_data(distutils.cmd.Command):
('share/meld', ['data/gschemas.compiled']),
]
# FIXME: This is way too much hard coding, but I really hope
# it also doesn't last that long.
resource_source = "meld/resources/meld.gresource.xml"
resource_target = "org.gnome.meld.gresource"
def initialize_options(self):
pass
......@@ -85,10 +90,31 @@ class build_data(distutils.cmd.Command):
pass
def get_data_files(self):
data_files = []
build_path = os.path.join('build', 'data')
if not os.path.exists(build_path):
os.makedirs(build_path)
info("compiling gresources")
resource_dir = os.path.dirname(self.resource_source)
target = os.path.join(build_path, self.resource_target)
self.spawn([
"glib-compile-resources",
"--target={}".format(target),
"--sourcedir={}".format(resource_dir),
self.resource_source,
])
data_files.append(('share/meld', [target]))
if os.name == 'nt':
return self.frozen_gschemas
gschemas = self.frozen_gschemas
else:
return self.gschemas
gschemas = self.gschemas
data_files.extend(gschemas)
return data_files
def run(self):
data_files = self.distribution.data_files
......
......@@ -7,6 +7,7 @@ __package__ = "meld"
__version__ = "3.19.2"
APPLICATION_ID = "org.gnome.meld"
RESOURCE_BASE = '/org/gnome/meld'
# START; these paths are clobbered on install by meld.build_helpers
DATADIR = Path(sys.prefix) / "share" / "meld"
......@@ -46,6 +47,9 @@ def uninstalled():
LOCALEDIR = melddir / "build" / "mo"
DATADIR_IS_UNINSTALLED = True
resource_path = melddir / "meld" / "resources"
os.environ['G_RESOURCE_OVERLAYS'] = f'{RESOURCE_BASE}={resource_path}'
def ui_file(filename):
return os.path.join(DATADIR, "ui", filename)
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/meld">
</gresource>
</gresources>
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