diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1e37bda1..902c4601 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,7 +28,7 @@ variables: FEDORA_DEPS: meson vala desktop-file-utils enchant2-devel folks-devel gcr-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 libsecret-devel libunwind-devel libxml2-devel libytnef-devel sqlite-devel webkitgtk4-devel @@ -39,10 +39,10 @@ variables: meson build-essential valac desktop-file-utils gettext iso-codes itstool libappstream-glib-dev libenchant-2-dev libfolks-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 - libjson-glib-dev libmessaging-menu-dev libpeas-dev libsecret-1-dev - libsqlite3-dev libunwind-dev libwebkit2gtk-4.0-dev libxml2-dev - libytnef0-dev + libgoa-1.0-dev libgspell-1-dev libgsound-dev libgtk-3-dev + libhandy-0.0-dev libjson-glib-dev libmessaging-menu-dev + libpeas-dev libsecret-1-dev libsqlite3-dev libunwind-dev + libwebkit2gtk-4.0-dev libxml2-dev libytnef0-dev UBUNTU_TEST_DEPS: locales xauth xvfb fedora: diff --git a/INSTALL b/INSTALL index 67270544..05dfbb4a 100644 --- a/INSTALL +++ b/INSTALL @@ -41,11 +41,11 @@ Install them by running this command: sudo dnf install meson vala desktop-file-utils enchant2-devel \ folks-devel gcr-devel glib2-devel gmime30-devel \ - gnome-online-accounts-devel gspell-devel gtk3-devel \ - iso-codes-devel json-glib-devel libappstream-glib-devel \ - libgee-devel libhandy-devel libpeas-devel libsecret-devel \ - libunwind-devel libxml2-devel libytnef-devel sqlite-devel \ - webkitgtk4-devel + gnome-online-accounts-devel gspell-devel gsound-devel \ + gtk3-devel iso-codes-devel json-glib-devel \ + libappstream-glib-devel libgee-devel libhandy-devel \ + libpeas-devel libsecret-devel libunwind-devel libxml2-devel \ + libytnef-devel sqlite-devel webkitgtk4-devel Installing dependencies on Ubuntu/Debian ---------------------------------------- @@ -56,9 +56,9 @@ Install them by running this command: desktop-file-utils iso-codes gettext itstool \ libappstream-glib-dev libenchant-2-dev libfolks-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 \ - libhandy-0.0-dev libpeas-dev libsecret-1-dev libsqlite3-dev \ - libunwind-dev libwebkit2gtk-4.0-dev libxml2-dev \ + libgoa-1.0-dev libgspell-1-dev libgsound-dev libgtk-3-dev \ + libjson-glib-dev libhandy-0.0-dev libpeas-dev libsecret-1-dev \ + libsqlite3-dev libunwind-dev libwebkit2gtk-4.0-dev libxml2-dev \ libytnef0-dev And for Ubuntu Messaging Menu integration: diff --git a/meson.build b/meson.build index 84fe0710..6a5bb77d 100644 --- a/meson.build +++ b/meson.build @@ -79,6 +79,7 @@ gdk = dependency('gdk-3.0', version: '>=' + target_gtk) gee = dependency('gee-0.8', version: '>= 0.8.5') gio = dependency('gio-2.0', version: '>=' + target_glib) goa = dependency('goa-1.0') +gsound = dependency('gsound') gspell = dependency('gspell-1') gthread = dependency('gthread-2.0', version: '>=' + target_glib) iso_codes = dependency('iso-codes') diff --git a/src/client/plugin/meson.build b/src/client/plugin/meson.build index a4198c6a..ca3300d5 100644 --- a/src/client/plugin/meson.build +++ b/src/client/plugin/meson.build @@ -26,3 +26,4 @@ subdir('desktop-notifications') subdir('folder-highlight') subdir('messaging-menu') subdir('notification-badge') +subdir('sent-sound') diff --git a/src/client/plugin/sent-sound/meson.build b/src/client/plugin/sent-sound/meson.build new file mode 100644 index 00000000..305c445d --- /dev/null +++ b/src/client/plugin/sent-sound/meson.build @@ -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 +) diff --git a/src/client/plugin/sent-sound/sent-sound.plugin.in b/src/client/plugin/sent-sound/sent-sound.plugin.in new file mode 100644 index 00000000..d692d2e5 --- /dev/null +++ b/src/client/plugin/sent-sound/sent-sound.plugin.in @@ -0,0 +1,4 @@ +[Plugin] +Module=sent-sound +Name=Sent Sound +Description=Plays the desktop sent-mail sound when an email is sent diff --git a/src/client/plugin/sent-sound/sent-sound.vala b/src/client/plugin/sent-sound/sent-sound.vala new file mode 100644 index 00000000..a986b348 --- /dev/null +++ b/src/client/plugin/sent-sound/sent-sound.vala @@ -0,0 +1,55 @@ +/* + * Copyright © 2020 Michael Gratton . + * + * 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); + } + } + +}