diff --git a/src/client/geary-config.vala b/src/client/geary-config.vala
index b31a8b2b..f452bc47 100644
--- a/src/client/geary-config.vala
+++ b/src/client/geary-config.vala
@@ -66,6 +66,22 @@ public class Configuration {
spell_check_changed();
}
}
+
+ private const string PLAY_SOUNDS_NAME = "play-sounds";
+ public bool play_sounds {
+ get { return settings.get_boolean(PLAY_SOUNDS_NAME); }
+ set {
+ settings.set_boolean(PLAY_SOUNDS_NAME, value);
+ }
+ }
+
+ private const string SHOW_NOTIFICATIONS_NAME = "show-notifications";
+ public bool show_notifications {
+ get { return settings.get_boolean(SHOW_NOTIFICATIONS_NAME); }
+ set {
+ settings.set_boolean(SHOW_NOTIFICATIONS_NAME, value);
+ }
+ }
private const string CLOCK_FORMAT_NAME = "clock-format";
private const string TIME_FORMAT_NAME = "time-format";
diff --git a/src/client/org.yorba.geary.gschema.xml b/src/client/org.yorba.geary.gschema.xml
index 3cea7738..18f9565a 100644
--- a/src/client/org.yorba.geary.gschema.xml
+++ b/src/client/org.yorba.geary.gschema.xml
@@ -49,6 +49,17 @@
enable inline spell checking
True to spell check while typing.
+
+ true
+ enable notification sounds
+ True to play sounds for notifications and sending.
+
+
+ true
+ show notifications for new mail
+ True to show notification bubbles.
+
+
diff --git a/src/client/ui/notification-bubble.vala b/src/client/ui/notification-bubble.vala
index 20b9e53d..0c5b729e 100644
--- a/src/client/ui/notification-bubble.vala
+++ b/src/client/ui/notification-bubble.vala
@@ -43,6 +43,9 @@ public class NotificationBubble : GLib.Object {
}
public void notify_new_mail(int count) throws GLib.Error {
+ if (!GearyApplication.instance.config.show_notifications)
+ return;
+
notification.set_category("email.arrived");
prepare_notification(ngettext("%d new message", "%d new messages", count).printf(count),
@@ -52,6 +55,9 @@ public class NotificationBubble : GLib.Object {
public async void notify_one_message_async(Geary.Email email, GLib.Cancellable? cancellable) throws GLib.Error {
assert(email.fields.fulfills(REQUIRED_FIELDS));
+
+ if (!GearyApplication.instance.config.show_notifications)
+ return;
// possible to receive email with no originator
Geary.RFC822.MailboxAddress? primary = email.get_primary_originator();
@@ -101,6 +107,8 @@ public class NotificationBubble : GLib.Object {
}
public static void play_sound(string sound) {
+ if (!GearyApplication.instance.config.play_sounds)
+ return;
init_sound();
sound_context.play(0, Canberra.PROP_EVENT_ID, sound);
}
diff --git a/src/client/ui/preferences-dialog.vala b/src/client/ui/preferences-dialog.vala
index 691b02bc..6b1af04e 100644
--- a/src/client/ui/preferences-dialog.vala
+++ b/src/client/ui/preferences-dialog.vala
@@ -9,6 +9,8 @@ public class PreferencesDialog : Object {
private Gtk.CheckButton autoselect;
private Gtk.CheckButton display_preview;
private Gtk.CheckButton spell_check;
+ private Gtk.CheckButton play_sounds;
+ private Gtk.CheckButton show_notifications;
private Gtk.Button close_button;
private Configuration config;
@@ -21,17 +23,23 @@ public class PreferencesDialog : Object {
autoselect = builder.get_object("autoselect") as Gtk.CheckButton;
display_preview = builder.get_object("display_preview") as Gtk.CheckButton;
spell_check = builder.get_object("spell_check") as Gtk.CheckButton;
+ play_sounds = builder.get_object("play_sounds") as Gtk.CheckButton;
+ show_notifications = builder.get_object("show_notifications") as Gtk.CheckButton;
close_button = builder.get_object("close_button") as Gtk.Button;
// Populate the dialog with our current settings.
autoselect.active = config.autoselect;
display_preview.active = config.display_preview;
spell_check.active = config.spell_check;
+ play_sounds.active = config.play_sounds;
+ show_notifications.active = config.show_notifications;
// Connect to element signals.
autoselect.toggled.connect(on_autoselect_toggled);
display_preview.toggled.connect(on_display_preview_toggled);
spell_check.toggled.connect(on_spell_check_toggled);
+ play_sounds.toggled.connect(on_play_sounds_toggled);
+ show_notifications.toggled.connect(on_show_notifications_toggled);
GearyApplication.instance.exiting.connect(on_exit);
}
@@ -59,5 +67,13 @@ public class PreferencesDialog : Object {
private void on_spell_check_toggled() {
config.spell_check = spell_check.active;
}
+
+ private void on_play_sounds_toggled() {
+ config.play_sounds = play_sounds.active;
+ }
+
+ private void on_show_notifications_toggled() {
+ config.show_notifications = show_notifications.active;
+ }
}
diff --git a/ui/preferences.glade b/ui/preferences.glade
index 9c0127fe..16ebf7da 100644
--- a/ui/preferences.glade
+++ b/ui/preferences.glade
@@ -155,6 +155,72 @@
1
+
+
+
+ 0
+ 6
+ 1
+ 1
+
+
+
+
+
+ 0
+ 7
+ 1
+ 1
+
+
+
+
+
+ 0
+ 8
+ 1
+ 1
+
+
False