Notification toasts setting

This commit is contained in:
bleakgrey 2018-05-30 15:58:27 +03:00
parent 8f98f467ab
commit 99cd873134
4 changed files with 27 additions and 2 deletions

View File

@ -6,6 +6,11 @@
<summary>Current Account</summary>
<description>Do not edit or it shall set your house on fire</description>
</key>
<key name="notifications" type="b">
<default>true</default>
<summary>Display desktop notifications</summary>
<description></description>
</key>
<key name="always-online" type="b">
<default>false</default>
<summary>Always monitor new notifications</summary>

View File

@ -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);

View File

@ -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);
}

View File

@ -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; }