aboutsummaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/data/settings_dialog.ui30
-rw-r--r--main/src/ui/notifications.vala12
-rw-r--r--main/src/ui/settings_dialog.vala10
3 files changed, 46 insertions, 6 deletions
diff --git a/main/data/settings_dialog.ui b/main/data/settings_dialog.ui
index 42448cc1..9d18bdc7 100644
--- a/main/data/settings_dialog.ui
+++ b/main/data/settings_dialog.ui
@@ -18,8 +18,8 @@
<property name="row-spacing">10</property>
<property name="visible">True</property>
<child>
- <object class="GtkCheckButton" id="marker_checkbutton">
- <property name="label" translatable="yes">Send typing notifications and message marker</property>
+ <object class="GtkCheckButton" id="typing_checkbutton">
+ <property name="label" translatable="yes">Send typing notifications</property>
<property name="visible">True</property>
</object>
<packing>
@@ -30,13 +30,37 @@
</packing>
</child>
<child>
+ <object class="GtkCheckButton" id="marker_checkbutton">
+ <property name="label" translatable="yes">Send message marker</property>
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="notification_checkbutton">
+ <property name="label" translatable="yes">Notify when a new message arrives</property>
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkCheckButton" id="emoji_checkbutton">
<property name="label" translatable="yes">Convert smileys to emojis</property>
<property name="visible">True</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">1</property>
+ <property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
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; });
}
}