phosh-media-player/src/extension.vala
Vasiliy Doylov b09f92cb35
All checks were successful
PostmarketOS Build / Prepare (push) Successful in 13s
PostmarketOS Build / Build for aarch64 (push) Successful in 2m35s
PostmarketOS Build / Build for x86_64 (push) Successful in 57s
extension: fix module query
Signed-off-by: Vasiliy Doylov <nekocwd@mainlining.org>
2025-07-12 12:33:54 +03:00

52 lines
1.8 KiB
Vala

/*
* Copyright (C) 2025 Vasiliy Doylov <nekocwd@mainlining.org>
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Author: Vasiliy Doylov <nekocwd@mainlining.org>
*/
namespace MediaPlayer {
static Gtk.CssProvider css = null;
[CCode (cname = "g_io_phosh_plugin_media_player_load")]
public static void stub (GLib.TypeModule module) {
if (typeof (Player) == 0) {
module.use (); // We don't want to unuse it. Just beleve me
init (module);
}
IOExtensionPoint.implement ("phosh-quick-setting-widget",
typeof (QuickSetting),
"media-player",
10);
IOExtensionPoint.implement ("phosh-lockscreen-widget",
typeof (LockScreen),
"media-player",
10);
if (css == null) {
css = new Gtk.CssProvider ();
css.load_from_resource ("/mobi/phosh/plugins/media-player/style.css");
Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), css, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
}
}
/*
* Weird hack.
* Move this attribute to stub and see what will happen
* We don't need to register type on all loads.
* In `stub` we're checking if any our types was registred if no, call module init
*/
[ModuleInit]
public static void init (GLib.TypeModule module) {
}
[CCode (cname = "g_io_phosh_plugin_media_player_unload")]
public static void unload (GLib.TypeModule module) {
// TODO: Remove our CSS here
}
[CCode (cname = "g_io_phosh_plugin_media_player_query", array_null_terminated = true, array_length = false)]
public static string[] query () {
return { "phosh-quick-setting-widget", "phosh-lockscreen-widget" };
}
}