Skip to content

Commit

Permalink
Replaced state cacher with gsettings
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikReider committed Jun 19, 2022
1 parent 8425afb commit aab565d
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 94 deletions.
13 changes: 13 additions & 0 deletions build-aux/meson/postinstall.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env python3

from os import environ, path
from subprocess import call

prefix = environ.get('MESON_INSTALL_PREFIX', '/usr/local')
datadir = path.join(prefix, 'share')
destdir = environ.get('DESTDIR', '')

# Package managers set this so we don't need to run
if not destdir:
print('Compiling GSettings schemas...')
call(['glib-compile-schemas', path.join(datadir, 'glib-2.0', 'schemas')])
10 changes: 10 additions & 0 deletions data/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
install_data('org.erikreider.swaync.gschema.xml',
install_dir: join_paths(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
10 changes: 10 additions & 0 deletions data/org.erikreider.swaync.gschema.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain="swaync">
<schema id="org.erikreider.swaync" path="/org/erikreider/swaync/">
<key name="dnd-state" type="b">
<default>false</default>
<summary>The current do not disturb state</summary>
<description>Whether notifications should be silent or not</description>
</key>
</schema>
</schemalist>
3 changes: 3 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ project('sway-notificaton-center', ['c', 'vala'],
add_project_arguments(['--enable-gobject-tracing'], language: 'vala')
add_project_arguments(['--enable-checking'], language: 'vala')

i18n = import('i18n')

subdir('data')
subdir('src')

datadir = get_option('datadir')
Expand Down
79 changes: 0 additions & 79 deletions src/cacher/cacher.vala

This file was deleted.

4 changes: 4 additions & 0 deletions src/main.vala
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ namespace SwayNotificationCenter {
static string ? style_path;
static string ? config_path;

static Settings self_settings;

public void main (string[] args) {
Gtk.init (ref args);
Hdy.init ();
Functions.init ();

self_settings = new Settings ("org.erikreider.swaync");

if (args.length > 0) {
for (uint i = 1; i < args.length; i++) {
string arg = args[i];
Expand Down
1 change: 0 additions & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ app_sources = [
'notification/notification.vala',
'controlCenter/controlCenter.vala',
'controlCenter/topAction/topAction.vala',
'cacher/cacher.vala',
'blankWindow/blankWindow.vala',
'functions.vala',
constants,
Expand Down
8 changes: 2 additions & 6 deletions src/notiDaemon/notiDaemon.vala
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ namespace SwayNotificationCenter {
public NotiDaemon (SwayncDaemon swaync_daemon) {
this.notify["dnd"].connect (() => on_dnd_toggle (dnd));

// Init from state cache
swaync_daemon.cache_state.bind_property ("dnd-state",
this,
"dnd",
BindingFlags.BIDIRECTIONAL
| BindingFlags.SYNC_CREATE);
// Init dnd from gsettings
self_settings.bind ("dnd-state", this, "dnd", SettingsBindFlags.DEFAULT);

this.noti_window = new NotificationWindow ();
this.control_center = new ControlCenter (swaync_daemon, this);
Expand Down
8 changes: 0 additions & 8 deletions src/swayncDaemon/swayncDaemon.vala
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,12 @@ namespace SwayNotificationCenter {

[DBus (name = "org.erikreider.swaync.cc")]
public class SwayncDaemon : Object {
public StateCache cache_state;

public NotiDaemon noti_daemon;

private Array<BlankWindow> blank_windows = new Array<BlankWindow> ();
private unowned Gdk.Display ? display = Gdk.Display.get_default ();

public SwayncDaemon () {
this.cache_state = Cacher.instance.get_state_cache ();
this.cache_state.notify.connect ((x, r) => {
debug ("State changed: %s\n", r.name);
Cacher.instance.cache_state (cache_state);
});

// Init noti_daemon
this.noti_daemon = new NotiDaemon (this);
Bus.own_name (BusType.SESSION, "org.freedesktop.Notifications",
Expand Down

0 comments on commit aab565d

Please sign in to comment.