diff --git a/data/com.github.bleakgrey.tootle.gschema.xml b/data/com.github.bleakgrey.tootle.gschema.xml index 0dffa2b..e9be8ee 100644 --- a/data/com.github.bleakgrey.tootle.gschema.xml +++ b/data/com.github.bleakgrey.tootle.gschema.xml @@ -6,6 +6,11 @@ Current Account Do not edit or it shall set your house on fire + + true + Display desktop notifications + + false Always monitor new notifications diff --git a/src/Dialogs/SettingsDialog.vala b/src/Dialogs/SettingsDialog.vala index 23dd504..302ffcf 100644 --- a/src/Dialogs/SettingsDialog.vala +++ b/src/Dialogs/SettingsDialog.vala @@ -5,6 +5,8 @@ public class Tootle.SettingsDialog : Gtk.Dialog { private static SettingsDialog dialog; + private SettingsSwitch switch_notifications; + private SettingsSwitch switch_watcher; private Gtk.Grid grid; public SettingsDialog () { @@ -35,9 +37,18 @@ public class Tootle.SettingsDialog : Gtk.Dialog { // settings.schema.bind ("cache-size", cache_size, "value", SettingsBindFlags.DEFAULT); // grid.attach (cache_size, 1, i++); + switch_watcher = new SettingsSwitch ("always-online"); + switch_notifications = new SettingsSwitch ("notifications"); + switch_notifications.state_set.connect (state => { + switch_watcher.sensitive = state; + return false; + }); + grid.attach (new Granite.HeaderLabel (_("Notifications")), 0, i++, 2, 1); + grid.attach (new SettingsLabel (_("Display notifications:")), 0, i); + grid.attach (switch_notifications, 1, i++); grid.attach (new SettingsLabel (_("Always receive notifications:")), 0, i); - grid.attach (new SettingsSwitch ("always-online"), 1, i++); + grid.attach (switch_watcher, 1, i++); var content = get_content_area () as Gtk.Box; content.pack_start (grid, false, false, 0); diff --git a/src/InstanceAccount.vala b/src/InstanceAccount.vala index 1249f7d..4478575 100644 --- a/src/InstanceAccount.vala +++ b/src/InstanceAccount.vala @@ -79,12 +79,17 @@ public class Tootle.InstanceAccount : GLib.Object { body += Utils.escape_html (obj.status.content); notification.set_body (body); } - app.send_notification (app.application_id + ":" + obj.id.to_string (), notification); + + if (settings.notifications) + app.send_notification (app.application_id + ":" + obj.id.to_string (), notification); network.notification (ref obj); } private void status_added (ref Status status) { + if (accounts.formal.token != this.token) + return; + if (settings.live_updates) network.status_added (ref status, "home"); else @@ -92,6 +97,9 @@ public class Tootle.InstanceAccount : GLib.Object { } private void status_removed (int64 id) { + if (accounts.formal.token != this.token) + return; + if (settings.live_updates) network.status_removed (id); } diff --git a/src/SettingsManager.vala b/src/SettingsManager.vala index 78f2530..9a9f5bb 100644 --- a/src/SettingsManager.vala +++ b/src/SettingsManager.vala @@ -1,6 +1,7 @@ public class Tootle.SettingsManager : Granite.Services.Settings { public int current_account { get; set; } + public bool notifications { get; set; } public bool always_online { get; set; } public bool cache { get; set; } public int cache_size { get; set; }