Plugin: Add new sent-sound plugin
Optional plugin to play the sent-mail sound from the desktop's system sound theme when an email is sent. Fixes #598
This commit is contained in:
parent
e7c7326a05
commit
a47e0fcede
7 changed files with 103 additions and 13 deletions
|
|
@ -28,7 +28,7 @@ variables:
|
||||||
FEDORA_DEPS:
|
FEDORA_DEPS:
|
||||||
meson vala desktop-file-utils enchant2-devel folks-devel gcr-devel
|
meson vala desktop-file-utils enchant2-devel folks-devel gcr-devel
|
||||||
glib2-devel gmime30-devel gnome-online-accounts-devel gspell-devel
|
glib2-devel gmime30-devel gnome-online-accounts-devel gspell-devel
|
||||||
gtk3-devel iso-codes-devel json-glib-devel itstool
|
gsound-devel gtk3-devel iso-codes-devel json-glib-devel itstool
|
||||||
libappstream-glib-devel libgee-devel libhandy-devel libpeas-devel
|
libappstream-glib-devel libgee-devel libhandy-devel libpeas-devel
|
||||||
libsecret-devel libunwind-devel libxml2-devel libytnef-devel
|
libsecret-devel libunwind-devel libxml2-devel libytnef-devel
|
||||||
sqlite-devel webkitgtk4-devel
|
sqlite-devel webkitgtk4-devel
|
||||||
|
|
@ -39,10 +39,10 @@ variables:
|
||||||
meson build-essential valac desktop-file-utils gettext iso-codes
|
meson build-essential valac desktop-file-utils gettext iso-codes
|
||||||
itstool libappstream-glib-dev libenchant-2-dev libfolks-dev
|
itstool libappstream-glib-dev libenchant-2-dev libfolks-dev
|
||||||
libgcr-3-dev libgee-0.8-dev libglib2.0-dev libgmime-3.0-dev
|
libgcr-3-dev libgee-0.8-dev libglib2.0-dev libgmime-3.0-dev
|
||||||
libgoa-1.0-dev libgspell-1-dev libgtk-3-dev libhandy-0.0-dev
|
libgoa-1.0-dev libgspell-1-dev libgsound-dev libgtk-3-dev
|
||||||
libjson-glib-dev libmessaging-menu-dev libpeas-dev libsecret-1-dev
|
libhandy-0.0-dev libjson-glib-dev libmessaging-menu-dev
|
||||||
libsqlite3-dev libunwind-dev libwebkit2gtk-4.0-dev libxml2-dev
|
libpeas-dev libsecret-1-dev libsqlite3-dev libunwind-dev
|
||||||
libytnef0-dev
|
libwebkit2gtk-4.0-dev libxml2-dev libytnef0-dev
|
||||||
UBUNTU_TEST_DEPS: locales xauth xvfb
|
UBUNTU_TEST_DEPS: locales xauth xvfb
|
||||||
|
|
||||||
fedora:
|
fedora:
|
||||||
|
|
|
||||||
16
INSTALL
16
INSTALL
|
|
@ -41,11 +41,11 @@ Install them by running this command:
|
||||||
|
|
||||||
sudo dnf install meson vala desktop-file-utils enchant2-devel \
|
sudo dnf install meson vala desktop-file-utils enchant2-devel \
|
||||||
folks-devel gcr-devel glib2-devel gmime30-devel \
|
folks-devel gcr-devel glib2-devel gmime30-devel \
|
||||||
gnome-online-accounts-devel gspell-devel gtk3-devel \
|
gnome-online-accounts-devel gspell-devel gsound-devel \
|
||||||
iso-codes-devel json-glib-devel libappstream-glib-devel \
|
gtk3-devel iso-codes-devel json-glib-devel \
|
||||||
libgee-devel libhandy-devel libpeas-devel libsecret-devel \
|
libappstream-glib-devel libgee-devel libhandy-devel \
|
||||||
libunwind-devel libxml2-devel libytnef-devel sqlite-devel \
|
libpeas-devel libsecret-devel libunwind-devel libxml2-devel \
|
||||||
webkitgtk4-devel
|
libytnef-devel sqlite-devel webkitgtk4-devel
|
||||||
|
|
||||||
Installing dependencies on Ubuntu/Debian
|
Installing dependencies on Ubuntu/Debian
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
@ -56,9 +56,9 @@ Install them by running this command:
|
||||||
desktop-file-utils iso-codes gettext itstool \
|
desktop-file-utils iso-codes gettext itstool \
|
||||||
libappstream-glib-dev libenchant-2-dev libfolks-dev \
|
libappstream-glib-dev libenchant-2-dev libfolks-dev \
|
||||||
libgcr-3-dev libgee-0.8-dev libglib2.0-dev libgmime-3.0-dev \
|
libgcr-3-dev libgee-0.8-dev libglib2.0-dev libgmime-3.0-dev \
|
||||||
libgoa-1.0-dev libgspell-1-dev libgtk-3-dev libjson-glib-dev \
|
libgoa-1.0-dev libgspell-1-dev libgsound-dev libgtk-3-dev \
|
||||||
libhandy-0.0-dev libpeas-dev libsecret-1-dev libsqlite3-dev \
|
libjson-glib-dev libhandy-0.0-dev libpeas-dev libsecret-1-dev \
|
||||||
libunwind-dev libwebkit2gtk-4.0-dev libxml2-dev \
|
libsqlite3-dev libunwind-dev libwebkit2gtk-4.0-dev libxml2-dev \
|
||||||
libytnef0-dev
|
libytnef0-dev
|
||||||
|
|
||||||
And for Ubuntu Messaging Menu integration:
|
And for Ubuntu Messaging Menu integration:
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@ gdk = dependency('gdk-3.0', version: '>=' + target_gtk)
|
||||||
gee = dependency('gee-0.8', version: '>= 0.8.5')
|
gee = dependency('gee-0.8', version: '>= 0.8.5')
|
||||||
gio = dependency('gio-2.0', version: '>=' + target_glib)
|
gio = dependency('gio-2.0', version: '>=' + target_glib)
|
||||||
goa = dependency('goa-1.0')
|
goa = dependency('goa-1.0')
|
||||||
|
gsound = dependency('gsound')
|
||||||
gspell = dependency('gspell-1')
|
gspell = dependency('gspell-1')
|
||||||
gthread = dependency('gthread-2.0', version: '>=' + target_glib)
|
gthread = dependency('gthread-2.0', version: '>=' + target_glib)
|
||||||
iso_codes = dependency('iso-codes')
|
iso_codes = dependency('iso-codes')
|
||||||
|
|
|
||||||
|
|
@ -26,3 +26,4 @@ subdir('desktop-notifications')
|
||||||
subdir('folder-highlight')
|
subdir('folder-highlight')
|
||||||
subdir('messaging-menu')
|
subdir('messaging-menu')
|
||||||
subdir('notification-badge')
|
subdir('notification-badge')
|
||||||
|
subdir('sent-sound')
|
||||||
|
|
|
||||||
29
src/client/plugin/sent-sound/meson.build
Normal file
29
src/client/plugin/sent-sound/meson.build
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
|
||||||
|
plugin_name = 'sent-sound'
|
||||||
|
|
||||||
|
send_sound_dependencies = plugin_dependencies
|
||||||
|
send_sound_dependencies += gsound
|
||||||
|
|
||||||
|
plugin_src = join_paths(plugin_name + '.vala')
|
||||||
|
plugin_data = join_paths(plugin_name + '.plugin')
|
||||||
|
plugin_dest = join_paths(plugins_dir, plugin_name)
|
||||||
|
|
||||||
|
shared_module(
|
||||||
|
plugin_name,
|
||||||
|
sources: plugin_src,
|
||||||
|
dependencies: send_sound_dependencies,
|
||||||
|
include_directories: config_h_dir,
|
||||||
|
vala_args: geary_vala_args,
|
||||||
|
c_args: plugin_c_args,
|
||||||
|
install: true,
|
||||||
|
install_dir: plugin_dest
|
||||||
|
)
|
||||||
|
|
||||||
|
i18n.merge_file(
|
||||||
|
input: plugin_data + '.in',
|
||||||
|
output: plugin_data,
|
||||||
|
type: 'desktop',
|
||||||
|
po_dir: po_dir,
|
||||||
|
install: true,
|
||||||
|
install_dir: plugin_dest
|
||||||
|
)
|
||||||
4
src/client/plugin/sent-sound/sent-sound.plugin.in
Normal file
4
src/client/plugin/sent-sound/sent-sound.plugin.in
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
[Plugin]
|
||||||
|
Module=sent-sound
|
||||||
|
Name=Sent Sound
|
||||||
|
Description=Plays the desktop sent-mail sound when an email is sent
|
||||||
55
src/client/plugin/sent-sound/sent-sound.vala
Normal file
55
src/client/plugin/sent-sound/sent-sound.vala
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2020 Michael Gratton <mike@vee.net>.
|
||||||
|
*
|
||||||
|
* This software is licensed under the GNU Lesser General Public License
|
||||||
|
* (version 2.1 or later). See the COPYING file in this distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
[ModuleInit]
|
||||||
|
public void peas_register_types(TypeModule module) {
|
||||||
|
Peas.ObjectModule obj = module as Peas.ObjectModule;
|
||||||
|
obj.register_extension_type(
|
||||||
|
typeof(Plugin.PluginBase),
|
||||||
|
typeof(Plugin.SentSound)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Plays the desktop sent-mail sound when an email is sent. */
|
||||||
|
public class Plugin.SentSound : PluginBase, NotificationExtension {
|
||||||
|
|
||||||
|
|
||||||
|
public NotificationContext notifications {
|
||||||
|
get; set construct;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private GSound.Context? context = null;
|
||||||
|
private EmailStore? store = null;
|
||||||
|
|
||||||
|
|
||||||
|
public override async void activate() throws GLib.Error {
|
||||||
|
this.context = new GSound.Context();
|
||||||
|
this.context.init();
|
||||||
|
|
||||||
|
this.store = yield this.notifications.get_email();
|
||||||
|
this.store.email_sent.connect(on_sent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async void deactivate(bool is_shutdown) throws GLib.Error {
|
||||||
|
this.store.email_sent.disconnect(on_sent);
|
||||||
|
this.store = null;
|
||||||
|
|
||||||
|
this.context = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void on_sent() {
|
||||||
|
try {
|
||||||
|
this.context.play_simple(
|
||||||
|
null, GSound.Attribute.EVENT_ID, "message-sent-email"
|
||||||
|
);
|
||||||
|
} catch (GLib.Error err) {
|
||||||
|
warning("Failed to play sent mail sound: %s", err.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue