diff options
Diffstat (limited to 'main/src/ui')
-rw-r--r-- | main/src/ui/notifications.vala | 12 | ||||
-rw-r--r-- | main/src/ui/settings_dialog.vala | 10 |
2 files changed, 19 insertions, 3 deletions
diff --git a/main/src/ui/notifications.vala b/main/src/ui/notifications.vala index e5eda271..32e8d7ad 100644 --- a/main/src/ui/notifications.vala +++ b/main/src/ui/notifications.vala @@ -31,6 +31,8 @@ public class Notifications : Object { } private void on_message_received(Entities.Message message, Conversation conversation) { + if (!should_notify_message(message, conversation)) return; + if (!notifications.has_key(conversation)) { notifications[conversation] = new Notify.Notification("", null, null); notifications[conversation].set_hint("transient", true); @@ -74,7 +76,7 @@ public class Notifications : Object { AddConversation.Chat.AddContactDialog dialog = new AddConversation.Chat.AddContactDialog(stream_interactor); dialog.jid = jid.bare_jid.to_string(); dialog.account = account; - dialog.show(); + dialog.present(); } try { notification.close(); @@ -90,6 +92,14 @@ public class Notifications : Object { notification.show(); } catch (Error error) { } } + + private bool should_notify_message(Entities.Message message, Conversation conversation) { + Conversation.NotifySetting notify = conversation.get_notification_setting(stream_interactor); + if (notify == Conversation.NotifySetting.OFF) return false; + string? nick = stream_interactor.get_module(MucManager.IDENTITY).get_nick(conversation.counterpart, conversation.account); + if (notify == Conversation.NotifySetting.HIGHLIGHT && nick != null && !message.body.contains(nick)) return false; + return true; + } } }
\ No newline at end of file diff --git a/main/src/ui/settings_dialog.vala b/main/src/ui/settings_dialog.vala index 2d3c1efa..44596217 100644 --- a/main/src/ui/settings_dialog.vala +++ b/main/src/ui/settings_dialog.vala @@ -5,7 +5,9 @@ namespace Dino.Ui { [GtkTemplate (ui = "/org/dino-im/settings_dialog.ui")] class SettingsDialog : Dialog { + [GtkChild] private CheckButton typing_checkbutton; [GtkChild] private CheckButton marker_checkbutton; + [GtkChild] private CheckButton notification_checkbutton; [GtkChild] private CheckButton emoji_checkbutton; Dino.Settings settings = Dino.Settings.instance(); @@ -13,10 +15,14 @@ class SettingsDialog : Dialog { public SettingsDialog() { Object(use_header_bar : 1); - marker_checkbutton.active = settings.send_read; + typing_checkbutton.active = settings.send_typing; + marker_checkbutton.active = settings.send_marker; + notification_checkbutton.active = settings.notifications; emoji_checkbutton.active = settings.convert_utf8_smileys; - marker_checkbutton.toggled.connect(() => { settings.send_read = marker_checkbutton.active; }); + typing_checkbutton.toggled.connect(() => { settings.send_typing = typing_checkbutton.active; } ); + marker_checkbutton.toggled.connect(() => { settings.send_marker = marker_checkbutton.active; } ); + notification_checkbutton.toggled.connect(() => { settings.notifications = notification_checkbutton.active; } ); emoji_checkbutton.toggled.connect(() => { settings.convert_utf8_smileys = emoji_checkbutton.active; }); } } |