Preferences now available to both enable/disable sounds for new mail and notification bubbles for new mail.
This commit is contained in:
parent
877a21686c
commit
a184bb58aa
5 changed files with 117 additions and 0 deletions
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -49,6 +49,17 @@
|
|||
<summary>enable inline spell checking</summary>
|
||||
<description>True to spell check while typing.</description>
|
||||
</key>
|
||||
<key name="play-sounds" type="b">
|
||||
<default>true</default>
|
||||
<summary>enable notification sounds</summary>
|
||||
<description>True to play sounds for notifications and sending.</description>
|
||||
</key>
|
||||
<key name="show-notifications" type="b">
|
||||
<default>true</default>
|
||||
<summary>show notifications for new mail</summary>
|
||||
<description>True to show notification bubbles.</description>
|
||||
</key>
|
||||
|
||||
|
||||
</schema>
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -155,6 +155,72 @@
|
|||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Notifications</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="bold"/>
|
||||
</attributes>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">6</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="play_sounds">
|
||||
<property name="label" translatable="yes">Play notification sounds</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="margin_left">12</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">7</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="show_notifications">
|
||||
<property name="label" translatable="yes">Show notifications for new mail</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="margin_left">12</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">8</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue