Add QuickSettings preferences
Signed-off-by: Vasiliy Doylov <nekocwd@mainlining.org>
This commit is contained in:
parent
902abc2265
commit
a87140e04e
9 changed files with 211 additions and 1 deletions
|
@ -18,8 +18,8 @@ gnome = import('gnome')
|
||||||
i18n = import('i18n')
|
i18n = import('i18n')
|
||||||
|
|
||||||
phosh_dep = dependency('phosh-plugins', version: '>= 0.45')
|
phosh_dep = dependency('phosh-plugins', version: '>= 0.45')
|
||||||
lockscreen_plugins_dir = phosh_dep.get_variable('lockscreen_plugins_dir')
|
|
||||||
quick_setting_plugins_dir = phosh_dep.get_variable('quick_setting_plugins_dir')
|
quick_setting_plugins_dir = phosh_dep.get_variable('quick_setting_plugins_dir')
|
||||||
|
quick_setting_prefs_dir = phosh_dep.get_variable('quick_setting_prefs_dir')
|
||||||
|
|
||||||
common_deps = [
|
common_deps = [
|
||||||
dependency('gee-0.8'),
|
dependency('gee-0.8'),
|
||||||
|
@ -60,3 +60,9 @@ add_project_arguments(project_c_args, language: 'c')
|
||||||
subdir('po')
|
subdir('po')
|
||||||
# The example plugin
|
# The example plugin
|
||||||
subdir('src')
|
subdir('src')
|
||||||
|
|
||||||
|
gnome.post_install(
|
||||||
|
glib_compile_schemas: true,
|
||||||
|
gtk_update_icon_cache: true,
|
||||||
|
update_desktop_database: true,
|
||||||
|
)
|
||||||
|
|
|
@ -5,3 +5,7 @@ Name=Beautiful media player widget
|
||||||
Types=quick-setting;lockscreen
|
Types=quick-setting;lockscreen
|
||||||
Comment=Yep, it was written in vala
|
Comment=Yep, it was written in vala
|
||||||
Plugin=@plugins_dir@/libphosh-plugin-@name@.so
|
Plugin=@plugins_dir@/libphosh-plugin-@name@.so
|
||||||
|
|
||||||
|
[Prefs]
|
||||||
|
Id=@name@-prefs
|
||||||
|
Plugin=@plugin_prefs_dir@/libphosh-plugin-prefs-@name@.so
|
||||||
|
|
|
@ -37,10 +37,12 @@ shared_module(
|
||||||
install: true,
|
install: true,
|
||||||
install_dir: quick_setting_plugins_dir,
|
install_dir: quick_setting_plugins_dir,
|
||||||
)
|
)
|
||||||
|
subdir('prefs')
|
||||||
|
|
||||||
pluginconf = configuration_data()
|
pluginconf = configuration_data()
|
||||||
pluginconf.set('name', meson.project_name())
|
pluginconf.set('name', meson.project_name())
|
||||||
pluginconf.set('plugins_dir', quick_setting_plugins_dir)
|
pluginconf.set('plugins_dir', quick_setting_plugins_dir)
|
||||||
|
pluginconf.set('plugin_prefs_dir', quick_setting_prefs_dir)
|
||||||
|
|
||||||
i18n.merge_file(
|
i18n.merge_file(
|
||||||
input: configure_file(
|
input: configure_file(
|
||||||
|
|
6
src/prefs/extension.gresources.xml
Normal file
6
src/prefs/extension.gresources.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<gresources>
|
||||||
|
<gresource prefix="/mobi/phosh/plugins/media-player/">
|
||||||
|
<file preprocess="xml-stripblanks">prefs.ui</file>
|
||||||
|
</gresource>
|
||||||
|
</gresources>
|
45
src/prefs/extension.vala
Normal file
45
src/prefs/extension.vala
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2025 Vasiliy Doylov <nekocwd@mainlining.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*
|
||||||
|
* Author: Vasiliy Doylov <nekocwd@mainlining.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace MediaPlayer.Preferences {
|
||||||
|
[CCode (cname = "g_io_module_load")]
|
||||||
|
public static void stub (IOModule module) {
|
||||||
|
module.use ();
|
||||||
|
if (typeof (Preferences) == 0) {
|
||||||
|
init (module);
|
||||||
|
}
|
||||||
|
|
||||||
|
IOExtensionPoint.implement ("phosh-quick-setting-widget-prefs",
|
||||||
|
typeof (Preferences),
|
||||||
|
"media-player-prefs",
|
||||||
|
10);
|
||||||
|
}
|
||||||
|
|
||||||
|
[ModuleInit]
|
||||||
|
[CCode (cname = "g_module_load_real")]
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
public static void init (IOModule module) {
|
||||||
|
}
|
||||||
|
|
||||||
|
[CCode (cname = "g_io_module_unload")]
|
||||||
|
public static void unload (IOModule module) {
|
||||||
|
}
|
||||||
|
|
||||||
|
[CCode (cname = "g_io_phosh_plugin_prefs_media_player_query")]
|
||||||
|
public static string[] query () {
|
||||||
|
StrvBuilder builder = new StrvBuilder ();
|
||||||
|
|
||||||
|
builder.add ("phosh-quick-setting-widget-prefs");
|
||||||
|
return builder.end ();
|
||||||
|
}
|
||||||
|
}
|
53
src/prefs/meson.build
Normal file
53
src/prefs/meson.build
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
prefs_blueprints = custom_target(
|
||||||
|
'prefs_blueprints',
|
||||||
|
input: files(
|
||||||
|
'prefs.blp',
|
||||||
|
),
|
||||||
|
output: '.',
|
||||||
|
command: [
|
||||||
|
find_program('blueprint-compiler'),
|
||||||
|
'batch-compile',
|
||||||
|
'@OUTPUT@',
|
||||||
|
'@CURRENT_SOURCE_DIR@',
|
||||||
|
'@INPUT@',
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
prefs_resources = gnome.compile_resources(
|
||||||
|
'media-player-prefs-resources',
|
||||||
|
'extension.gresources.xml',
|
||||||
|
c_name: 'phosh_plugin_media_player',
|
||||||
|
dependencies: prefs_blueprints,
|
||||||
|
)
|
||||||
|
|
||||||
|
shared_module(
|
||||||
|
'phosh-plugin-prefs-media-player',
|
||||||
|
sources: [
|
||||||
|
'prefs.vala',
|
||||||
|
'extension.vala',
|
||||||
|
prefs_resources,
|
||||||
|
],
|
||||||
|
dependencies: [
|
||||||
|
dependency('gtk4'),
|
||||||
|
dependency('libadwaita-1'),
|
||||||
|
dependency('gio-2.0'),
|
||||||
|
],
|
||||||
|
c_args: common_c_args,
|
||||||
|
install: true,
|
||||||
|
install_dir: quick_setting_prefs_dir,
|
||||||
|
)
|
||||||
|
|
||||||
|
install_data(
|
||||||
|
[
|
||||||
|
'mobi.phosh.plugins.mediaplayer.gschema.xml',
|
||||||
|
],
|
||||||
|
install_dir: get_option('datadir') / 'glib-2.0' / 'schemas',
|
||||||
|
)
|
||||||
|
compile_schemas = find_program('glib-compile-schemas', required: false)
|
||||||
|
if compile_schemas.found()
|
||||||
|
test(
|
||||||
|
'Validate schema file',
|
||||||
|
compile_schemas,
|
||||||
|
args: ['--strict', '--dry-run', meson.current_source_dir()],
|
||||||
|
)
|
||||||
|
endif
|
31
src/prefs/mobi.phosh.plugins.mediaplayer.gschema.xml
Normal file
31
src/prefs/mobi.phosh.plugins.mediaplayer.gschema.xml
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<schemalist>
|
||||||
|
<schema id="mobi.phosh.plugins.mediaplayer.settings">
|
||||||
|
<key name='margin-right' type='i'>
|
||||||
|
<default>12</default>
|
||||||
|
</key>
|
||||||
|
<key name='margin-left' type='i'>
|
||||||
|
<default>12</default>
|
||||||
|
</key>
|
||||||
|
<key name='margin-top' type='i'>
|
||||||
|
<default>24</default>
|
||||||
|
</key>
|
||||||
|
<key name='margin-bottom' type='i'>
|
||||||
|
<default>0</default>
|
||||||
|
</key>
|
||||||
|
</schema>
|
||||||
|
<schema
|
||||||
|
id="mobi.phosh.plugins.mediaplayer"
|
||||||
|
path="/mobi/phosh/plugins/media-player/"
|
||||||
|
>
|
||||||
|
<child
|
||||||
|
name="quick-settings"
|
||||||
|
schema="mobi.phosh.plugins.mediaplayer.settings"
|
||||||
|
/>
|
||||||
|
<child
|
||||||
|
name="lock-screen"
|
||||||
|
schema="mobi.phosh.plugins.mediaplayer.settings"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</schema>
|
||||||
|
|
||||||
|
</schemalist>
|
56
src/prefs/prefs.blp
Normal file
56
src/prefs/prefs.blp
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
using Gtk 4.0;
|
||||||
|
using Adw 1;
|
||||||
|
|
||||||
|
template $MediaPlayerPreferencesPreferences: Adw.PreferencesDialog {
|
||||||
|
title: _("Quick settings preferences");
|
||||||
|
|
||||||
|
Adw.PreferencesPage {
|
||||||
|
Adw.PreferencesGroup {
|
||||||
|
title: _("Margins");
|
||||||
|
|
||||||
|
Adw.SpinRow {
|
||||||
|
title: _("Top");
|
||||||
|
|
||||||
|
adjustment: Adjustment adj_margin_top {
|
||||||
|
lower: 0;
|
||||||
|
upper: 4096;
|
||||||
|
step-increment: 1;
|
||||||
|
page-increment: 10;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
Adw.SpinRow spin_margin_bottom {
|
||||||
|
title: _("Bottom");
|
||||||
|
|
||||||
|
adjustment: Adjustment adj_margin_bottom {
|
||||||
|
lower: 0;
|
||||||
|
upper: 4096;
|
||||||
|
step-increment: 1;
|
||||||
|
page-increment: 10;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
Adw.SpinRow spin_margin_start {
|
||||||
|
title: _("Start");
|
||||||
|
|
||||||
|
adjustment: Adjustment adj_margin_start {
|
||||||
|
lower: 0;
|
||||||
|
upper: 4096;
|
||||||
|
step-increment: 1;
|
||||||
|
page-increment: 10;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
Adw.SpinRow spin_margin_end {
|
||||||
|
title: _("End");
|
||||||
|
|
||||||
|
adjustment: Adjustment adj_margin_end {
|
||||||
|
lower: 0;
|
||||||
|
upper: 4096;
|
||||||
|
step-increment: 1;
|
||||||
|
page-increment: 10;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
7
src/prefs/prefs.vala
Normal file
7
src/prefs/prefs.vala
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
[GtkTemplate (ui = "/mobi/phosh/plugins/media-player/prefs.ui")]
|
||||||
|
public class MediaPlayer.Preferences.Preferences : Adw.PreferencesDialog {
|
||||||
|
construct {
|
||||||
|
message ("Constuct");
|
||||||
|
var settings = new Settings.with_path ("mobi.phosh.plugins.mediaplayer", "/mobi/phosh/plugins/media-player/");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue