[gnome-break-timer] Fix sound effects with some new dependencies
- From: Dylan McCall <dylanmccall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-break-timer] Fix sound effects with some new dependencies
- Date: Sat, 14 Nov 2020 08:11:31 +0000 (UTC)
commit bcf3f446c3bd362a0dd777e8721335a24771b550
Author: Dylan McCall <dylan dylanmccall ca>
Date: Sat Nov 14 00:10:59 2020 -0800
Fix sound effects with some new dependencies
With this change, we switch from Canberra to GSound, and bump our
runtime to GNOME 3.38.
meson.build | 3 ++-
org.gnome.BreakTimer.json | 61 ++++++++++++++++++++++++++++++++++--------
src/daemon/UIManager.vala | 31 +++++++++++----------
src/meson.build | 8 +++---
src/settings/BreakManager.vala | 6 ++++-
5 files changed, 76 insertions(+), 33 deletions(-)
---
diff --git a/meson.build b/meson.build
index d9adefb..05f6bc3 100644
--- a/meson.build
+++ b/meson.build
@@ -15,10 +15,11 @@ gio_dep = dependency('gio-2.0')
gio_unix_dep = dependency('gio-unix-2.0')
glib_dep = dependency('glib-2.0')
gobject_dep = dependency('gobject-2.0')
+gsound_dep = dependency('gsound')
gtk_dep = dependency('gtk+-3.0')
json_glib_dep = dependency('json-glib-1.0')
-libnotify_dep = dependency('libnotify')
libcanberra_dep = dependency('libcanberra')
+libnotify_dep = dependency('libnotify')
posix_dep = valac.find_library('posix')
m_dep = cc.find_library('m', required : false)
diff --git a/org.gnome.BreakTimer.json b/org.gnome.BreakTimer.json
index 91e9da6..8a494f2 100644
--- a/org.gnome.BreakTimer.json
+++ b/org.gnome.BreakTimer.json
@@ -1,7 +1,7 @@
{
"id" : "org.gnome.BreakTimer",
"runtime" : "org.gnome.Platform",
- "runtime-version" : "3.36",
+ "runtime-version" : "3.38",
"sdk" : "org.gnome.Sdk",
"command" : "gnome-break-timer-settings",
"finish-args" : [
@@ -10,18 +10,9 @@
"--socket=wayland",
"--socket=pulseaudio",
"--talk-name=org.gnome.Shell",
- "--filesystem=/usr/share/glib-2.0/schemas:ro",
- "--filesystem=xdg-run/dconf",
- "--filesystem=~/.config/dconf:rw",
- "--own-name=org.gnome.BreakTimer",
- "--talk-name=org.gnome.BreakTimer",
- "--own-name=org.gnome.BreakTimer.*",
- "--talk-name=org.gnome.BreakTimer.*",
"--talk-name=org.gnome.Mutter.IdleMonitor",
"--talk-name=org.gnome.ScreenSaver",
- "--talk-name=org.freedesktop.Notifications",
- "--talk-name=ca.desrt.dconf",
- "--env=DCONF_USER_CONFIG_DIR=.config/dconf"
+ "--talk-name=org.freedesktop.Notifications"
],
"build-options" : {
"cflags" : "-O2 -g",
@@ -31,6 +22,54 @@
}
},
"modules" : [
+ {
+ "name": "libcanberra",
+ "sources": [
+ {
+ "type": "archive",
+ "url": "http://0pointer.de/lennart/projects/libcanberra/libcanberra-0.30.tar.xz";,
+ "sha256": "c2b671e67e0c288a69fc33dc1b6f1b534d07882c2aceed37004bf48c601afa72"
+ }
+ ],
+ "config-opts": [
+ "--disable-alsa",
+ "--disable-null",
+ "--disable-oss"
+ ]
+ },
+ {
+ "name": "gsound",
+ "sources": [
+ {
+ "type": "git",
+ "url": "https://gitlab.gnome.org/GNOME/gsound.git";,
+ "branch": "master"
+ }
+ ]
+ },
+ {
+ "name": "intltool",
+ "sources": [
+ {
+ "type": "archive",
+ "url": "https://launchpad.net/intltool/trunk/0.51.0/+download/intltool-0.51.0.tar.gz";,
+ "sha256": "67c74d94196b153b774ab9f89b2fa6c6ba79352407037c8c14d5aeb334e959cd"
+ }
+ ],
+ "cleanup": [
+ "*"
+ ]
+ },
+ {
+ "name": "sound-theme-freedesktop",
+ "sources": [
+ {
+ "type": "archive",
+ "url": "http://people.freedesktop.org/~mccann/dist/sound-theme-freedesktop-0.8.tar.bz2";,
+ "sha256": "cb518b20eef05ec2e82dda1fa89a292c1760dc023aba91b8aa69bafac85e8a14"
+ }
+ ]
+ },
{
"name" : "gnome-break-timer",
"buildsystem" : "meson",
diff --git a/src/daemon/UIManager.vala b/src/daemon/UIManager.vala
index 578bda2..b2898ba 100644
--- a/src/daemon/UIManager.vala
+++ b/src/daemon/UIManager.vala
@@ -27,7 +27,7 @@ public class UIManager : SimpleFocusManager {
private weak Gtk.Application application;
private ISessionStatus session_status;
- private Canberra.Context? canberra;
+ private GSound.Context? gsound;
private Notify.Notification? notification;
private Notify.Notification? lock_notification;
@@ -38,15 +38,12 @@ public class UIManager : SimpleFocusManager {
this.application = application;
this.session_status = session_status;
- if (Canberra.Context.create (out this.canberra) != 0) {
- this.canberra = null;
- }
-
- if (this.canberra != null) {
- this.canberra.change_props(Canberra.PROP_APPLICATION_ID, Config.DAEMON_APPLICATION_ID);
- this.canberra.change_props(Canberra.PROP_APPLICATION_NAME, _("GNOME Break Timer"));
- this.canberra.change_props(Canberra.PROP_APPLICATION_ICON_NAME, Config.APPLICATION_ICON);
- this.canberra.open();
+ try {
+ this.gsound = new GSound.Context ();
+ this.gsound.init ();
+ } catch (GLib.Error error) {
+ GLib.warning ("Error initializing gsound: %s", error.message);
+ this.gsound = null;
}
this.session_status.unlocked.connect (this.hide_lock_notification_cb);
@@ -76,7 +73,7 @@ public class UIManager : SimpleFocusManager {
try {
notification.show ();
- } catch (Error error) {
+ } catch (GLib.Error error) {
GLib.warning ("Error showing notification: %s", error.message);
}
@@ -96,7 +93,7 @@ public class UIManager : SimpleFocusManager {
this.notification.set_hint ("transient", true);
this.notification.show ();
}
- } catch (Error error) {
+ } catch (GLib.Error error) {
// We ignore this error, because it's usually just noise
// GLib.warning ("Error closing notification: %s", error.message);
}
@@ -120,10 +117,12 @@ public class UIManager : SimpleFocusManager {
}
public void play_sound_from_id (string event_id) {
- if (this.canberra != null) {
- canberra.play (0,
- Canberra.PROP_EVENT_ID, event_id
- );
+ if (this.gsound != null) {
+ try {
+ this.gsound.play_simple (null, "event.id", event_id);
+ } catch (GLib.Error error) {
+ GLib.warning ("Error playing sound: %s", error.message);
+ }
}
}
diff --git a/src/meson.build b/src/meson.build
index b871826..c10bf75 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -18,7 +18,7 @@ subdir('common')
subdir('settings')
subdir('daemon')
-main_dependencies = [
+common_dependencies = [
cairo_dep,
config_lib_dep,
gee_dep,
@@ -26,7 +26,7 @@ main_dependencies = [
gio_unix_dep,
gtk_dep,
json_glib_dep,
- libcanberra_dep,
+ gsound_dep,
libnotify_dep,
m_dep,
posix_dep,
@@ -39,7 +39,7 @@ executable(
sources : [
settings_sources
],
- dependencies : main_dependencies,
+ dependencies : common_dependencies,
install: true,
install_dir: bindir
)
@@ -49,7 +49,7 @@ executable(
sources : [
daemon_sources
],
- dependencies : main_dependencies,
+ dependencies : common_dependencies,
install: true,
install_dir: bindir
)
diff --git a/src/settings/BreakManager.vala b/src/settings/BreakManager.vala
index 8352c60..ed3f073 100644
--- a/src/settings/BreakManager.vala
+++ b/src/settings/BreakManager.vala
@@ -41,6 +41,8 @@ public class BreakManager : Object {
this.breaks_ordered = new GLib.List<BreakType> ();
if (this.get_is_in_flatpak ()) {
+ // TODO: Does this work outside of a flatpak? We could remove the
+ // extra file we install in data/autostart, which would be nice.
try {
this.background_portal = Bus.get_proxy_sync (
BusType.SESSION,
@@ -85,7 +87,9 @@ public class BreakManager : Object {
try {
// We don't have a nice way to generate a window handle, but the
- // background portal isn't using it at the moment.
+ // background portal can probably do without.
+ // TODO: Handle response, and display an error if the result
+ // includes `autostart == false || background == false`.
this.background_portal.request_background("", options);
} catch (IOError error) {
GLib.warning ("Error connecting to xdg desktop portal: %s", error.message);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]