aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-05-30 22:31:05 +0200
committerfiaxh <git@mx.ax.lt>2017-05-30 22:33:33 +0200
commit387433ebb9bab442502f812e0364111f37270bcb (patch)
tree5dba69992da0a402380d7bde27433c750f5be920 /main/src/ui
parent3a8df2069eba3a5a4174749fc46a6698c1877ec1 (diff)
downloaddino-387433ebb9bab442502f812e0364111f37270bcb.tar.gz
dino-387433ebb9bab442502f812e0364111f37270bcb.zip
Notifications + typing notifications + message marker settings per conversation
Diffstat (limited to 'main/src/ui')
-rw-r--r--main/src/ui/notifications.vala12
-rw-r--r--main/src/ui/settings_dialog.vala10
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; });
}
}