Fix custom CSS loading for remote app

This commit is contained in:
Rafostar
2020-12-15 23:26:24 +01:00
parent 234451f62a
commit b6c947efa6
3 changed files with 21 additions and 15 deletions

View File

@@ -1,4 +1,4 @@
const { Gio, GstAudio, GstPlayer, Gtk } = imports.gi;
const { Gio, GstAudio, GstPlayer, Gdk, Gtk } = imports.gi;
const Debug = imports.clapper_src.debug;
var appName = 'Clapper';
@@ -34,6 +34,19 @@ function getClapperVersion()
: '';
}
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 inhibitForState(state, window)
{
let isInhibited = false;

View File

@@ -16,25 +16,15 @@ var Widget = GObject.registerClass({
}
}, class ClapperWidget extends Gtk.Grid
{
_init(opts)
_init()
{
Debug.gstVersionCheck();
super._init();
let clapperPath = Misc.getClapperPath();
let defaults = {
cssPath: `${clapperPath}/css/styles.css`,
};
Object.assign(this, defaults, opts);
let cssProvider = new Gtk.CssProvider();
cssProvider.load_from_path(this.cssPath);
Gtk.StyleContext.add_provider_for_display(
Gdk.Display.get_default(),
cssProvider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
);
/* load CSS here to allow using this class
* separately as a pre-made GTK widget */
Misc.loadCustomCss();
this.windowSize = JSON.parse(settings.get_string('window-size'));
this.floatSize = JSON.parse(settings.get_string('float-size'));

View File

@@ -1,4 +1,5 @@
const { GObject, Gtk } = imports.gi;
const Misc = imports.clapper_src.misc;
const { PlayerRemote } = imports.clapper_src.playerRemote;
var WidgetRemote = GObject.registerClass(
@@ -8,6 +9,8 @@ class ClapperWidgetRemote extends Gtk.Grid
{
super._init();
Misc.loadCustomCss();
this.player = new PlayerRemote();
this.player.webclient.passMsgData = this.receiveWs.bind(this);
}