Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
ximper-shell-notification-center
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ximper Linux
ximper-shell-notification-center
Commits
aab565d7
Commit
aab565d7
authored
Jun 19, 2022
by
Erik Reider
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replaced state cacher with gsettings
parent
8425afbf
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
42 additions
and
94 deletions
+42
-94
postinstall.py
build-aux/meson/postinstall.py
+13
-0
meson.build
data/meson.build
+10
-0
org.erikreider.swaync.gschema.xml
data/org.erikreider.swaync.gschema.xml
+10
-0
meson.build
meson.build
+3
-0
cacher.vala
src/cacher/cacher.vala
+0
-79
main.vala
src/main.vala
+4
-0
meson.build
src/meson.build
+0
-1
notiDaemon.vala
src/notiDaemon/notiDaemon.vala
+2
-6
swayncDaemon.vala
src/swayncDaemon/swayncDaemon.vala
+0
-8
No files found.
build-aux/meson/postinstall.py
0 → 100755
View file @
aab565d7
#!/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'
)])
data/meson.build
0 → 100644
View file @
aab565d7
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
data/org.erikreider.swaync.gschema.xml
0 → 100644
View file @
aab565d7
<?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>
meson.build
View file @
aab565d7
...
...
@@ -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')
...
...
src/cacher/cacher.vala
deleted
100644 → 0
View file @
8425afbf
namespace
SwayNotificationCenter
{
public
class
Cacher
{
private
static
Cacher
_instance
;
/** Get the static singleton */
public
static
unowned
Cacher
instance
{
get
{
if
(
_instance
==
null
)
_instance
=
new
Cacher
();
return
_instance
;
}
}
private
const
string
CACHE_FILE_STATE
=
"swaync-state.cache"
;
private
const
FileCreateFlags
FILE_FLAGS
=
FileCreateFlags
.
PRIVATE
|
FileCreateFlags
.
REPLACE_DESTINATION
;
private
string
get_cache_path
()
{
string
path
=
Path
.
build_filename
(
Environment
.
get_user_cache_dir
(),
CACHE_FILE_STATE
);
File
file
=
File
.
new_for_path
(
path
);
if
(!
file
.
query_exists
())
{
try
{
file
.
create
(
FILE_FLAGS
);
}
catch
(
Error
e
)
{
stderr
.
printf
(
"Error: %s\n"
,
e
.
message
);
}
}
return
path
;
}
public
bool
cache_state
(
StateCache
state
)
{
string
path
=
get_cache_path
();
Json
.
Node
json
=
Json
.
gobject_serialize
(
state
);
string
data
=
Json
.
to_string
(
json
,
true
);
try
{
File
file
=
File
.
new_for_path
(
path
);
return
file
.
replace_contents
(
data
.
data
,
null
,
false
,
FILE_FLAGS
,
null
);
}
catch
(
Error
e
)
{
stderr
.
printf
(
"Cache state write error: %s\n"
,
e
.
message
);
return
false
;
}
}
public
StateCache
get_state_cache
()
{
string
path
=
get_cache_path
();
StateCache
s
=
null
;
try
{
Json
.
Parser
parser
=
new
Json
.
Parser
();
parser
.
load_from_file
(
path
);
Json
.
Node
?
node
=
parser
.
get_root
();
if
(
node
==
null
)
{
throw
new
Json
.
ParserError
.
PARSE
(
"Node is null!"
);
}
StateCache
model
=
Json
.
gobject_deserialize
(
typeof
(
StateCache
),
node
)
as
StateCache
;
if
(
model
==
null
)
{
throw
new
Json
.
ParserError
.
UNKNOWN
(
"Json model is null!"
);
}
s
=
model
;
}
catch
(
Error
e
)
{
stderr
.
printf
(
e
.
message
+
"\n"
);
}
return
s
??
new
StateCache
();
}
}
public
class
StateCache
:
Object
{
public
bool
dnd_state
{
get
;
set
;
default
=
false
;
}
}
}
src/main.vala
View file @
aab565d7
...
...
@@ -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
];
...
...
src/meson.build
View file @
aab565d7
...
...
@@ -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,
...
...
src/notiDaemon/notiDaemon.vala
View file @
aab565d7
...
...
@@ -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
);
...
...
src/swayncDaemon/swayncDaemon.vala
View file @
aab565d7
...
...
@@ -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"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment