Settings: bind values to gsettings
Signed-off-by: Vasiliy Doylov <nekocwd@mainlining.org>
This commit is contained in:
parent
a87140e04e
commit
b81ab03924
6 changed files with 53 additions and 9 deletions
|
@ -21,6 +21,7 @@ resources = gnome.compile_resources(
|
|||
)
|
||||
|
||||
sources = files(
|
||||
'prefs/shared.vala',
|
||||
'color.vala',
|
||||
'entrypoints.vala',
|
||||
'extension.vala',
|
||||
|
|
|
@ -15,7 +15,11 @@ namespace MediaPlayer.Preferences {
|
|||
}
|
||||
|
||||
IOExtensionPoint.implement ("phosh-quick-setting-widget-prefs",
|
||||
typeof (Preferences),
|
||||
typeof (QuickSettings),
|
||||
"media-player-prefs",
|
||||
10);
|
||||
IOExtensionPoint.implement ("phosh-lockscreen-widget-prefs",
|
||||
typeof (LockScreen),
|
||||
"media-player-prefs",
|
||||
10);
|
||||
}
|
||||
|
@ -40,6 +44,7 @@ namespace MediaPlayer.Preferences {
|
|||
StrvBuilder builder = new StrvBuilder ();
|
||||
|
||||
builder.add ("phosh-quick-setting-widget-prefs");
|
||||
builder.add ("phosh-lockscreen-widget-prefs");
|
||||
return builder.end ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ shared_module(
|
|||
'prefs.vala',
|
||||
'extension.vala',
|
||||
prefs_resources,
|
||||
'shared.vala',
|
||||
],
|
||||
dependencies: [
|
||||
dependency('gtk4'),
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<schemalist>
|
||||
<schema id="mobi.phosh.plugins.mediaplayer.settings">
|
||||
<key name='margin-right' type='i'>
|
||||
<default>12</default>
|
||||
<key name='margin-end' type='i'>
|
||||
<default>0</default>
|
||||
</key>
|
||||
<key name='margin-left' type='i'>
|
||||
<default>12</default>
|
||||
<key name='margin-start' type='i'>
|
||||
<default>0</default>
|
||||
</key>
|
||||
<key name='margin-top' type='i'>
|
||||
<default>24</default>
|
||||
|
|
|
@ -1,7 +1,36 @@
|
|||
[GtkTemplate (ui = "/mobi/phosh/plugins/media-player/prefs.ui")]
|
||||
[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/");
|
||||
[GtkChild]
|
||||
private unowned Gtk.Adjustment adj_margin_top;
|
||||
[GtkChild]
|
||||
private unowned Gtk.Adjustment adj_margin_bottom;
|
||||
[GtkChild]
|
||||
private unowned Gtk.Adjustment adj_margin_start;
|
||||
[GtkChild]
|
||||
private unowned Gtk.Adjustment adj_margin_end;
|
||||
|
||||
|
||||
protected void bind_preferences(string key) {
|
||||
var settings = new Settings.with_path(Keys.SCHEMA_ID, Keys.SETTINGS_PATH);
|
||||
settings = settings.get_child(key);
|
||||
/*
|
||||
* Margins
|
||||
*/
|
||||
settings.bind(Keys.MARGIN_TOP, adj_margin_top, "value", SettingsBindFlags.DEFAULT);
|
||||
settings.bind(Keys.MARGIN_BOTTOM, adj_margin_bottom, "value", SettingsBindFlags.DEFAULT);
|
||||
settings.bind(Keys.MARGIN_START, adj_margin_start, "value", SettingsBindFlags.DEFAULT);
|
||||
settings.bind(Keys.MARGIN_END, adj_margin_end, "value", SettingsBindFlags.DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
public class MediaPlayer.Preferences.QuickSettings : Preferences {
|
||||
construct {
|
||||
bind_preferences("quick-settings");
|
||||
}
|
||||
}
|
||||
|
||||
public class MediaPlayer.Preferences.LockScreen : Preferences {
|
||||
construct {
|
||||
bind_preferences("lock-screen");
|
||||
}
|
||||
}
|
||||
|
|
8
src/prefs/shared.vala
Normal file
8
src/prefs/shared.vala
Normal file
|
@ -0,0 +1,8 @@
|
|||
namespace MediaPlayer.Preferences.Keys {
|
||||
public const string MARGIN_TOP = "margin-top";
|
||||
public const string MARGIN_BOTTOM = "margin-bottom";
|
||||
public const string MARGIN_START = "margin-start";
|
||||
public const string MARGIN_END = "margin-end";
|
||||
public const string SCHEMA_ID = "mobi.phosh.plugins.mediaplayer";
|
||||
public const string SETTINGS_PATH = "/mobi/phosh/plugins/media-player/";
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue