mirror of
https://github.com/Rafostar/clapper.git
synced 2025-09-02 01:12:02 +02:00
Prepare for resource loading
Cleanup the Clapper install path detection code in a way to make gresources loading eventually possible for compiled builds
This commit is contained in:
55
src/misc.js
55
src/misc.js
@@ -10,8 +10,6 @@ var subsMimes = [
|
||||
'text/x-ssa',
|
||||
];
|
||||
|
||||
var clapperPath = null;
|
||||
|
||||
var settings = new Gio.Settings({
|
||||
schema_id: appId,
|
||||
});
|
||||
@@ -30,13 +28,41 @@ const subsKeys = Object.keys(subsTitles);
|
||||
|
||||
let inhibitCookie;
|
||||
|
||||
function getClapperPath()
|
||||
function getResourceUri(path)
|
||||
{
|
||||
return (clapperPath)
|
||||
? clapperPath
|
||||
: (pkg)
|
||||
? `${pkg.datadir}/${pkg.name}`
|
||||
: '.';
|
||||
/* TODO: support gresources */
|
||||
let res = `file://${pkg.pkgdatadir}/${path}`;
|
||||
|
||||
debug(`importing ${res}`);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
function getBuilderForName(name)
|
||||
{
|
||||
const uri = getResourceUri(`ui/${name}`);
|
||||
|
||||
if(uri.startsWith('resource'))
|
||||
return Gtk.Builder.new_from_resource(uri.substring(11));
|
||||
|
||||
return Gtk.Builder.new_from_file(uri.substring(7));
|
||||
}
|
||||
|
||||
function loadCustomCss()
|
||||
{
|
||||
const uri = getResourceUri(`css/styles.css`);
|
||||
const cssProvider = new Gtk.CssProvider();
|
||||
|
||||
if(uri.startsWith('resource'))
|
||||
cssProvider.load_from_resource(uri);
|
||||
else
|
||||
cssProvider.load_from_path(uri.substring(7));
|
||||
|
||||
Gtk.StyleContext.add_provider_for_display(
|
||||
Gdk.Display.get_default(),
|
||||
cssProvider,
|
||||
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
|
||||
);
|
||||
}
|
||||
|
||||
function getClapperThemeIconUri()
|
||||
@@ -101,19 +127,6 @@ function getSubsTitle(infoTitle)
|
||||
return (found) ? subsTitles[found] : null;
|
||||
}
|
||||
|
||||
function loadCustomCss()
|
||||
{
|
||||
const clapperPath = getClapperPath();
|
||||
const cssProvider = new Gtk.CssProvider();
|
||||
|
||||
cssProvider.load_from_path(`${clapperPath}/css/styles.css`);
|
||||
Gtk.StyleContext.add_provider_for_display(
|
||||
Gdk.Display.get_default(),
|
||||
cssProvider,
|
||||
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
|
||||
);
|
||||
}
|
||||
|
||||
function setAppInhibit(isInhibit, window)
|
||||
{
|
||||
let isInhibited = false;
|
||||
|
Reference in New Issue
Block a user