aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/ui')
-rw-r--r--main/src/ui/add_conversation/add_conference_dialog.vala2
-rw-r--r--main/src/ui/add_conversation/conference_list.vala1
-rw-r--r--main/src/ui/add_conversation/list_row.vala57
-rw-r--r--main/src/ui/application.vala33
-rw-r--r--main/src/ui/chat_input/chat_input_controller.vala10
-rw-r--r--main/src/ui/chat_input/chat_text_view.vala133
-rw-r--r--main/src/ui/conversation_content_view/message_widget.vala105
-rw-r--r--main/src/ui/conversation_details.vala32
-rw-r--r--main/src/ui/main_window.vala2
-rw-r--r--main/src/ui/main_window_controller.vala2
-rw-r--r--main/src/ui/notifier_freedesktop.vala7
-rw-r--r--main/src/ui/notifier_gnotifications.vala1
-rw-r--r--main/src/ui/settings_dialog.vala30
-rw-r--r--main/src/ui/util/helper.vala25
14 files changed, 343 insertions, 97 deletions
diff --git a/main/src/ui/add_conversation/add_conference_dialog.vala b/main/src/ui/add_conversation/add_conference_dialog.vala
index 551f6713..eac55ffc 100644
--- a/main/src/ui/add_conversation/add_conference_dialog.vala
+++ b/main/src/ui/add_conversation/add_conference_dialog.vala
@@ -165,7 +165,7 @@ public class AddConferenceDialog : Gtk.Dialog {
details_fragment.clear();
ListRow? row = conference_list_box.get_selected_row() != null ? conference_list_box.get_selected_row().get_child() as ListRow : null;
- ConferenceListRow? conference_row = conference_list_box.get_selected_row() != null ? conference_list_box.get_selected_row() as ConferenceListRow : null;
+ ConferenceListRow? conference_row = conference_list_box.get_selected_row() != null ? conference_list_box.get_selected_row().get_child() as ConferenceListRow : null;
if (conference_row != null) {
details_fragment.account = conference_row.account;
details_fragment.jid = conference_row.bookmark.jid.to_string();
diff --git a/main/src/ui/add_conversation/conference_list.vala b/main/src/ui/add_conversation/conference_list.vala
index 0b630ae4..bf6191fa 100644
--- a/main/src/ui/add_conversation/conference_list.vala
+++ b/main/src/ui/add_conversation/conference_list.vala
@@ -103,6 +103,7 @@ internal class ConferenceListRow : ListRow {
this.account = account;
this.bookmark = bookmark;
+ status_dot.visible = false;
name_label.label = bookmark.name != null && bookmark.name != "" ? bookmark.name : bookmark.jid.to_string();
if (stream_interactor.get_accounts().size > 1) {
via_label.label = "via " + account.bare_jid.to_string();
diff --git a/main/src/ui/add_conversation/list_row.vala b/main/src/ui/add_conversation/list_row.vala
index c5e344d0..c489aa13 100644
--- a/main/src/ui/add_conversation/list_row.vala
+++ b/main/src/ui/add_conversation/list_row.vala
@@ -8,28 +8,54 @@ namespace Dino.Ui {
public class ListRow : Widget {
- public Grid outer_grid;
+ public Box outer_box;
public AvatarPicture picture;
public Label name_label;
+ public Image status_dot;
public Label via_label;
- public Jid? jid;
- public Account? account;
+ public StreamInteractor stream_interactor;
+ public Jid jid;
+ public Account account;
+
+ private ulong[] handler_ids = new ulong[0];
construct {
Builder builder = new Builder.from_resource("/im/dino/Dino/add_conversation/list_row.ui");
- outer_grid = (Grid) builder.get_object("outer_grid");
+ outer_box = (Box) builder.get_object("outer_box");
picture = (AvatarPicture) builder.get_object("picture");
name_label = (Label) builder.get_object("name_label");
+ status_dot = (Image) builder.get_object("status_dot");
via_label = (Label) builder.get_object("via_label");
+
this.layout_manager = new BinLayout();
- outer_grid.set_parent(this);
+ outer_box.set_parent(this);
}
- public ListRow() {}
+ private void set_status_dot(StreamInteractor stream_interactor){
+ status_dot.visible = stream_interactor.connection_manager.get_state(account) == ConnectionManager.ConnectionState.CONNECTED;
+
+ Gee.List<Jid>? full_jids = stream_interactor.get_module(PresenceManager.IDENTITY).get_full_jids(jid, account);
+ if (full_jids != null) {
+ var statuses = new ArrayList<string>();
+ foreach (var full_jid in full_jids) {
+ statuses.add(stream_interactor.get_module(PresenceManager.IDENTITY).get_last_show(full_jid, account));
+ }
+
+ if (statuses.contains(Xmpp.Presence.Stanza.SHOW_DND)) status_dot.set_from_icon_name("dino-status-dnd");
+ else if (statuses.contains(Xmpp.Presence.Stanza.SHOW_CHAT)) status_dot.set_from_icon_name("dino-status-chat");
+ else if (statuses.contains(Xmpp.Presence.Stanza.SHOW_ONLINE)) status_dot.set_from_icon_name("dino-status-online");
+ else if (statuses.contains(Xmpp.Presence.Stanza.SHOW_AWAY)) status_dot.set_from_icon_name("dino-status-away");
+ else if (statuses.contains(Xmpp.Presence.Stanza.SHOW_XA)) status_dot.set_from_icon_name("dino-status-away");
+ else status_dot.set_from_icon_name("dino-status-offline");
+ } else {
+ status_dot.set_from_icon_name("dino-status-offline");
+ }
+ }
public ListRow.from_jid(StreamInteractor stream_interactor, Jid jid, Account account, bool show_account) {
+ this.stream_interactor = stream_interactor;
this.jid = jid;
this.account = account;
@@ -46,10 +72,27 @@ public class ListRow : Widget {
}
name_label.label = display_name;
picture.model = new ViewModel.CompatAvatarPictureModel(stream_interactor).set_conversation(conv);
+
+ handler_ids += stream_interactor.get_module(PresenceManager.IDENTITY).show_received.connect((jid, account) => {
+ if (account.equals(this.account) && jid.equals_bare(this.jid)) {
+ set_status_dot(stream_interactor);
+ }
+ });
+ handler_ids += stream_interactor.get_module(PresenceManager.IDENTITY).received_offline_presence.connect((jid, account) => {
+ if (account.equals(this.account) && jid.equals_bare(this.jid)) {
+ set_status_dot(stream_interactor);
+ }
+ });
+
+ set_status_dot(stream_interactor);
}
public override void dispose() {
- outer_grid.unparent();
+ outer_box.unparent();
+
+ foreach (var handler_id in handler_ids) {
+ stream_interactor.get_module(PresenceManager.IDENTITY).disconnect(handler_id);
+ }
}
}
diff --git a/main/src/ui/application.vala b/main/src/ui/application.vala
index 1c96e9ce..d213ef09 100644
--- a/main/src/ui/application.vala
+++ b/main/src/ui/application.vala
@@ -113,13 +113,17 @@ public class Dino.Ui.Application : Adw.Application, Dino.Application {
}
private void create_actions() {
- SimpleAction accounts_action = new SimpleAction("accounts", null);
- accounts_action.activate.connect(show_accounts_window);
- add_action(accounts_action);
-
- SimpleAction settings_action = new SimpleAction("settings", null);
- settings_action.activate.connect(show_settings_window);
- add_action(settings_action);
+ SimpleAction preferences_action = new SimpleAction("preferences", null);
+ preferences_action.activate.connect(show_preferences_window);
+ add_action(preferences_action);
+
+ SimpleAction preferences_account_action = new SimpleAction("preferences-account", VariantType.INT32);
+ preferences_account_action.activate.connect((variant) => {
+ Account? account = db.get_account_by_id(variant.get_int32());
+ if (account == null) return;
+ show_preferences_account_window(account);
+ });
+ add_action(preferences_account_action);
SimpleAction about_action = new SimpleAction("about", null);
about_action.activate.connect(show_about_window);
@@ -252,17 +256,16 @@ public class Dino.Ui.Application : Adw.Application, Dino.Application {
return Environment.get_variable("GTK_CSD") != "0";
}
- private void show_accounts_window() {
- ManageAccounts.Dialog dialog = new ManageAccounts.Dialog(stream_interactor, db);
- dialog.set_transient_for(get_active_window());
- dialog.account_enabled.connect(add_connection);
- dialog.account_disabled.connect(remove_connection);
+ private void show_preferences_window() {
+ Ui.PreferencesWindow dialog = new Ui.PreferencesWindow() { transient_for = window };
+ dialog.model.populate(db, stream_interactor);
dialog.present();
}
- private void show_settings_window() {
- SettingsDialog dialog = new SettingsDialog();
- dialog.set_transient_for(get_active_window());
+ private void show_preferences_account_window(Account account) {
+ Ui.PreferencesWindow dialog = new Ui.PreferencesWindow() { transient_for = window };
+ dialog.model.populate(db, stream_interactor);
+ dialog.accounts_page.account_chosen(account);
dialog.present();
}
diff --git a/main/src/ui/chat_input/chat_input_controller.vala b/main/src/ui/chat_input/chat_input_controller.vala
index d1c42d35..07499aa4 100644
--- a/main/src/ui/chat_input/chat_input_controller.vala
+++ b/main/src/ui/chat_input/chat_input_controller.vala
@@ -1,7 +1,9 @@
using Gee;
using Gdk;
using Gtk;
+using Xmpp;
+using Xmpp;
using Dino.Entities;
namespace Dino.Ui {
@@ -135,6 +137,7 @@ public class ChatInputController : Object {
string text = chat_input.chat_text_view.text_view.buffer.text;
ContentItem? quoted_content_item_bak = quoted_content_item;
+ var markups = chat_input.chat_text_view.get_markups();
// Reset input state. Has do be done before parsing commands, because those directly return.
chat_input.chat_text_view.text_view.buffer.text = "";
@@ -193,11 +196,8 @@ public class ChatInputController : Object {
break;
}
}
- Message out_message = stream_interactor.get_module(MessageProcessor.IDENTITY).create_out_message(text, conversation);
- if (quoted_content_item_bak != null) {
- stream_interactor.get_module(Replies.IDENTITY).set_message_is_reply_to(out_message, quoted_content_item_bak);
- }
- stream_interactor.get_module(MessageProcessor.IDENTITY).send_message(out_message, conversation);
+
+ Dino.send_message(conversation, text, quoted_content_item_bak != null ? quoted_content_item_bak.id : 0, null, markups);
}
private void on_text_input_changed() {
diff --git a/main/src/ui/chat_input/chat_text_view.vala b/main/src/ui/chat_input/chat_text_view.vala
index 72ebc845..c7429318 100644
--- a/main/src/ui/chat_input/chat_text_view.vala
+++ b/main/src/ui/chat_input/chat_text_view.vala
@@ -40,6 +40,10 @@ public class ChatTextView : Box {
private uint wait_queue_resize;
private SmileyConverter smiley_converter;
+ private TextTag italic_tag;
+ private TextTag bold_tag;
+ private TextTag strikethrough_tag;
+
construct {
valign = Align.CENTER;
scrolled_window.set_child(text_view);
@@ -49,6 +53,15 @@ public class ChatTextView : Box {
text_input_key_events.key_pressed.connect(on_text_input_key_press);
text_view.add_controller(text_input_key_events);
+ italic_tag = text_view.buffer.create_tag("italic");
+ italic_tag.style = Pango.Style.ITALIC;
+
+ bold_tag = text_view.buffer.create_tag("bold");
+ bold_tag.weight = Pango.Weight.BOLD;
+
+ strikethrough_tag = text_view.buffer.create_tag("strikethrough");
+ strikethrough_tag.strikethrough = true;
+
smiley_converter = new SmileyConverter(text_view);
scrolled_window.vadjustment.changed.connect(on_upper_notify);
@@ -60,6 +73,37 @@ public class ChatTextView : Box {
});
}
+ public void set_text(Message message) {
+ // Get a copy of the markup spans, such that we can modify them
+ var markups = new ArrayList<Xep.MessageMarkup.Span>();
+ foreach (var markup in message.get_markups()) {
+ markups.add(new Xep.MessageMarkup.Span() { types=markup.types, start_char=markup.start_char, end_char=markup.end_char });
+ }
+
+ text_view.buffer.text = Util.remove_fallbacks_adjust_markups(message.body, message.quoted_item_id > 0, message.get_fallbacks(), markups);
+
+ foreach (var markup in markups) {
+ foreach (var ty in markup.types) {
+ TextTag tag = null;
+ switch (ty) {
+ case Xep.MessageMarkup.SpanType.EMPHASIS:
+ tag = italic_tag;
+ break;
+ case Xep.MessageMarkup.SpanType.STRONG_EMPHASIS:
+ tag = bold_tag;
+ break;
+ case Xep.MessageMarkup.SpanType.DELETED:
+ tag = strikethrough_tag;
+ break;
+ }
+ TextIter start_selection, end_selection;
+ text_view.buffer.get_iter_at_offset(out start_selection, markup.start_char);
+ text_view.buffer.get_iter_at_offset(out end_selection, markup.end_char);
+ text_view.buffer.apply_tag(tag, start_selection, end_selection);
+ }
+ }
+ }
+
public override void dispose() {
base.dispose();
if (wait_queue_resize != 0) {
@@ -95,6 +139,7 @@ public class ChatTextView : Box {
}
private bool on_text_input_key_press(EventControllerKey controller, uint keyval, uint keycode, Gdk.ModifierType state) {
+ // Enter pressed -> Send message (except if it was Shift+Enter)
if (keyval in new uint[]{ Key.Return, Key.KP_Enter }) {
// Allow the text view to process the event. Needed for IME.
if (text_view.im_context_filter_keypress(controller.get_current_event())) {
@@ -102,17 +147,103 @@ public class ChatTextView : Box {
}
if ((state & ModifierType.SHIFT_MASK) > 0) {
- text_view.buffer.insert_at_cursor("\n", 1);
+ // Let the default handler normally insert a newline if shift was hold
+ return false;
} else if (text_view.buffer.text.strip() != "") {
send_text();
}
return true;
}
+
if (keyval == Key.Escape) {
cancel_input();
}
+
+ // Style text section bold (CTRL + b) or italic (CTRL + i)
+ if ((state & ModifierType.CONTROL_MASK) > 0) {
+ if (keyval in new uint[]{ Key.i, Key.b }) {
+ TextIter start_selection, end_selection;
+ text_view.buffer.get_selection_bounds(out start_selection, out end_selection);
+
+ TextTag tag = null;
+ bool already_formatted = false;
+ var markup_types = get_markup_types_from_iter(start_selection);
+ if (keyval == Key.i) {
+ tag = italic_tag;
+ already_formatted = markup_types.contains(Xep.MessageMarkup.SpanType.EMPHASIS);
+ } else if (keyval == Key.b) {
+ tag = bold_tag;
+ already_formatted = markup_types.contains(Xep.MessageMarkup.SpanType.STRONG_EMPHASIS);
+ } else if (keyval == Key.s) {
+ tag = strikethrough_tag;
+ already_formatted = markup_types.contains(Xep.MessageMarkup.SpanType.DELETED);
+ }
+ if (tag != null) {
+ if (already_formatted) {
+ text_view.buffer.remove_tag(tag, start_selection, end_selection);
+ } else {
+ text_view.buffer.apply_tag(tag, start_selection, end_selection);
+ }
+ }
+ }
+ }
+
return false;
}
+
+ public Gee.List<Xep.MessageMarkup.Span> get_markups() {
+ var markups = new HashMap<Xep.MessageMarkup.SpanType, Xep.MessageMarkup.SpanType>();
+ markups[Xep.MessageMarkup.SpanType.EMPHASIS] = Xep.MessageMarkup.SpanType.EMPHASIS;
+ markups[Xep.MessageMarkup.SpanType.STRONG_EMPHASIS] = Xep.MessageMarkup.SpanType.STRONG_EMPHASIS;
+ markups[Xep.MessageMarkup.SpanType.DELETED] = Xep.MessageMarkup.SpanType.DELETED;
+
+ var ended_groups = new ArrayList<Xep.MessageMarkup.Span>();
+ Xep.MessageMarkup.Span current_span = null;
+
+ TextIter iter;
+ text_view.buffer.get_start_iter(out iter);
+ int i = 0;
+ do {
+ var char_markups = get_markup_types_from_iter(iter);
+
+ // Not the same set of markups as last character -> end all spans
+ if (current_span != null && (!char_markups.contains_all(current_span.types) || !current_span.types.contains_all(char_markups))) {
+ ended_groups.add(current_span);
+ current_span = null;
+ }
+
+ if (char_markups.size > 0) {
+ if (current_span == null) {
+ current_span = new Xep.MessageMarkup.Span() { types=char_markups, start_char=i, end_char=i + 1 };
+ } else {
+ current_span.end_char = i + 1;
+ }
+ }
+
+ i++;
+ } while (iter.forward_char());
+
+ if (current_span != null) {
+ ended_groups.add(current_span);
+ }
+
+ return ended_groups;
+ }
+
+ private Gee.List<Xep.MessageMarkup.SpanType> get_markup_types_from_iter(TextIter iter) {
+ var ret = new ArrayList<Xep.MessageMarkup.SpanType>();
+
+ foreach (TextTag tag in iter.get_tags()) {
+ if (tag.style == Pango.Style.ITALIC) {
+ ret.add(Xep.MessageMarkup.SpanType.EMPHASIS);
+ } else if (tag.weight == Pango.Weight.BOLD) {
+ ret.add(Xep.MessageMarkup.SpanType.STRONG_EMPHASIS);
+ } else if (tag.strikethrough) {
+ ret.add(Xep.MessageMarkup.SpanType.DELETED);
+ }
+ }
+ return ret;
+ }
}
}
diff --git a/main/src/ui/conversation_content_view/message_widget.vala b/main/src/ui/conversation_content_view/message_widget.vala
index 11b38286..376ef4bd 100644
--- a/main/src/ui/conversation_content_view/message_widget.vala
+++ b/main/src/ui/conversation_content_view/message_widget.vala
@@ -26,8 +26,8 @@ public class MessageMetaItem : ContentMetaItem {
AdditionalInfo additional_info = AdditionalInfo.NONE;
ulong realize_id = -1;
- ulong style_updated_id = -1;
ulong marked_notify_handler_id = -1;
+ uint pending_timeout_id = -1;
public Label label = new Label("") { use_markup=true, xalign=0, selectable=true, wrap=true, wrap_mode=Pango.WrapMode.WORD_CHAR, hexpand=true, vexpand=true };
@@ -64,6 +64,7 @@ public class MessageMetaItem : ContentMetaItem {
if (message.marked in Message.MARKED_RECEIVED) {
binding.unbind();
this.disconnect(marked_notify_handler_id);
+ marked_notify_handler_id = -1;
}
});
}
@@ -71,20 +72,72 @@ public class MessageMetaItem : ContentMetaItem {
update_label();
}
- private string generate_markup_text(ContentItem item) {
+ private void generate_markup_text(ContentItem item, Label label) {
MessageItem message_item = item as MessageItem;
Conversation conversation = message_item.conversation;
Message message = message_item.message;
- bool theme_dependent = false;
+ // Get a copy of the markup spans, such that we can modify them
+ var markups = new ArrayList<Xep.MessageMarkup.Span>();
+ foreach (var markup in message.get_markups()) {
+ markups.add(new Xep.MessageMarkup.Span() { types=markup.types, start_char=markup.start_char, end_char=markup.end_char });
+ }
+
+ string markup_text = message.body;
+
+ var attrs = new AttrList();
+ label.set_attributes(attrs);
- string markup_text = Dino.message_body_without_reply_fallback(message);
+ if (markup_text == null) return; // TODO remove
+ // Only process messages up to a certain size
if (markup_text.length > 10000) {
markup_text = markup_text.substring(0, 10000) + " [" + _("Message too long") + "]";
}
- if (message.body.has_prefix("/me ")) {
- markup_text = markup_text.substring(4);
+
+ bool theme_dependent = false;
+
+ markup_text = Util.remove_fallbacks_adjust_markups(markup_text, message.quoted_item_id > 0, message.get_fallbacks(), markups);
+
+ var bold_attr = Pango.attr_weight_new(Pango.Weight.BOLD);
+ var italic_attr = Pango.attr_style_new(Pango.Style.ITALIC);
+ var strikethrough_attr = Pango.attr_strikethrough_new(true);
+
+ // Prefix message with name instead of /me
+ if (markup_text.has_prefix("/me ")) {
+ string display_name = Util.get_participant_display_name(stream_interactor, conversation, message.from);
+ markup_text = display_name + " " + markup_text.substring(4);
+
+ foreach (Xep.MessageMarkup.Span span in markups) {
+ int length = display_name.char_count() - 4 + 1;
+ span.start_char += length;
+ span.end_char += length;
+ }
+
+ bold_attr.end_index = display_name.length;
+ italic_attr.end_index = display_name.length;
+ attrs.insert(bold_attr.copy());
+ attrs.insert(italic_attr.copy());
+ }
+
+ foreach (var markup in markups) {
+ foreach (var ty in markup.types) {
+ Attribute attr = null;
+ switch (ty) {
+ case Xep.MessageMarkup.SpanType.EMPHASIS:
+ attr = Pango.attr_style_new(Pango.Style.ITALIC);
+ break;
+ case Xep.MessageMarkup.SpanType.STRONG_EMPHASIS:
+ attr = Pango.attr_weight_new(Pango.Weight.BOLD);
+ break;
+ case Xep.MessageMarkup.SpanType.DELETED:
+ attr = Pango.attr_strikethrough_new(true);
+ break;
+ }
+ attr.start_index = markup_text.index_of_nth_char(markup.start_char);
+ attr.end_index = markup_text.index_of_nth_char(markup.end_char);
+ attrs.insert(attr.copy());
+ }
}
if (conversation.type_ == Conversation.Type.GROUPCHAT) {
@@ -93,11 +146,6 @@ public class MessageMetaItem : ContentMetaItem {
markup_text = Util.parse_add_markup_theme(markup_text, null, true, true, true, Util.is_dark_theme(this.label), ref theme_dependent);
}
- if (message.body.has_prefix("/me ")) {
- string display_name = Util.get_participant_display_name(stream_interactor, conversation, message.from);
- markup_text = @"<i><b>$(Markup.escape_text(display_name))</b> " + markup_text + "</i>";
- }
-
int only_emoji_count = Util.get_only_emoji_count(markup_text);
if (only_emoji_count != -1) {
string size_str = only_emoji_count < 5 ? "xx-large" : "large";
@@ -121,8 +169,10 @@ public class MessageMetaItem : ContentMetaItem {
additional_info = AdditionalInfo.PENDING;
} else {
int time_diff = (- (int) message.time.difference(new DateTime.now_utc()) / 1000);
- Timeout.add(10000 - time_diff, () => {
+ if (pending_timeout_id != -1) Source.remove(pending_timeout_id);
+ pending_timeout_id = Timeout.add(10000 - time_diff, () => {
update_label();
+ pending_timeout_id = -1;
return false;
});
}
@@ -136,16 +186,14 @@ public class MessageMetaItem : ContentMetaItem {
if (theme_dependent && realize_id == -1) {
realize_id = label.realize.connect(update_label);
-// style_updated_id = label.style_updated.connect(update_label);
} else if (!theme_dependent && realize_id != -1) {
label.disconnect(realize_id);
- label.disconnect(style_updated_id);
}
- return markup_text;
+ label.label = markup_text;
}
public void update_label() {
- label.label = generate_markup_text(content_item);
+ generate_markup_text(content_item, label);
}
public override Object? get_widget(Plugins.ConversationItemWidgetInterface outer, Plugins.WidgetType type) {
@@ -209,16 +257,15 @@ public class MessageMetaItem : ContentMetaItem {
outer.set_widget(label, Plugins.WidgetType.GTK4, 2);
});
edit_mode.send.connect(() => {
- if (((MessageItem) content_item).message.body != edit_mode.chat_text_view.text_view.buffer.text) {
- on_edit_send(edit_mode.chat_text_view.text_view.buffer.text);
- } else {
-// edit_cancelled();
- }
+ string text = edit_mode.chat_text_view.text_view.buffer.text;
+ var markups = edit_mode.chat_text_view.get_markups();
+ Dino.send_message(message_item.conversation, text, message_item.message.quoted_item_id, message_item.message, markups);
+
in_edit_mode = false;
outer.set_widget(label, Plugins.WidgetType.GTK4, 2);
});
- edit_mode.chat_text_view.text_view.buffer.text = message.body;
+ edit_mode.chat_text_view.set_text(message);
outer.set_widget(edit_mode, Plugins.WidgetType.GTK4, 2);
edit_mode.chat_text_view.text_view.grab_focus();
@@ -227,11 +274,6 @@ public class MessageMetaItem : ContentMetaItem {
}
}
- private void on_edit_send(string text) {
- stream_interactor.get_module(MessageCorrection.IDENTITY).send_correction(message_item.conversation, message_item.message, text);
- this.in_edit_mode = false;
- }
-
private void on_received_correction(ContentItem content_item) {
if (this.content_item.id == content_item.id) {
this.content_item = content_item;
@@ -251,6 +293,15 @@ public class MessageMetaItem : ContentMetaItem {
public override void dispose() {
stream_interactor.get_module(MessageCorrection.IDENTITY).received_correction.disconnect(on_received_correction);
this.notify["in-edit-mode"].disconnect(on_in_edit_mode_changed);
+ if (marked_notify_handler_id != -1) {
+ this.disconnect(marked_notify_handler_id);
+ }
+ if (realize_id != -1) {
+ label.disconnect(realize_id);
+ }
+ if (pending_timeout_id != -1) {
+ Source.remove(pending_timeout_id);
+ }
if (label != null) {
label.unparent();
label.dispose();
diff --git a/main/src/ui/conversation_details.vala b/main/src/ui/conversation_details.vala
index 1c82f105..4c6a0481 100644
--- a/main/src/ui/conversation_details.vala
+++ b/main/src/ui/conversation_details.vala
@@ -10,6 +10,7 @@ namespace Dino.Ui.ConversationDetails {
model.conversation = conversation;
model.display_name = stream_interactor.get_module(ContactModels.IDENTITY).get_display_name_model(conversation);
model.blocked = stream_interactor.get_module(BlockingManager.IDENTITY).is_blocked(model.conversation.account, model.conversation.counterpart);
+ model.domain_blocked = stream_interactor.get_module(BlockingManager.IDENTITY).is_blocked(model.conversation.account, model.conversation.counterpart.domain_jid);
if (conversation.type_ == Conversation.Type.GROUPCHAT) {
stream_interactor.get_module(MucManager.IDENTITY).get_config_form.begin(conversation.account, conversation.counterpart, (_, res) => {
@@ -24,6 +25,14 @@ namespace Dino.Ui.ConversationDetails {
view_model.avatar = new ViewModel.CompatAvatarPictureModel(stream_interactor).set_conversation(model.conversation);
view_model.show_blocked = model.conversation.type_ == Conversation.Type.CHAT && stream_interactor.get_module(BlockingManager.IDENTITY).is_supported(model.conversation.account);
+ if (model.domain_blocked) {
+ view_model.blocked = DOMAIN;
+ } else if (model.blocked) {
+ view_model.blocked = USER;
+ } else {
+ view_model.blocked = UNBLOCK;
+ }
+
model.display_name.bind_property("display-name", view_model, "name", BindingFlags.SYNC_CREATE);
model.conversation.bind_property("notify-setting", view_model, "notification", BindingFlags.SYNC_CREATE, (_, from, ref to) => {
switch (model.conversation.get_notification_setting(stream_interactor)) {
@@ -57,7 +66,6 @@ namespace Dino.Ui.ConversationDetails {
to = ty == Conversation.Type.GROUPCHAT ? ViewModel.ConversationDetails.NotificationOptions.ON_HIGHLIGHT_OFF : ViewModel.ConversationDetails.NotificationOptions.ON_OFF;
return true;
});
- model.bind_property("blocked", view_model, "blocked", BindingFlags.SYNC_CREATE);
model.bind_property("data-form", view_model, "room-configuration-rows", BindingFlags.SYNC_CREATE, (_, from, ref to) => {
var data_form = (DataForms.DataForm) from;
if (data_form == null) return true;
@@ -77,13 +85,21 @@ namespace Dino.Ui.ConversationDetails {
view_model.pin_changed.connect(() => {
model.conversation.pinned = model.conversation.pinned == 1 ? 0 : 1;
});
- view_model.block_changed.connect(() => {
- if (view_model.blocked) {
- stream_interactor.get_module(BlockingManager.IDENTITY).unblock(model.conversation.account, model.conversation.counterpart);
- } else {
- stream_interactor.get_module(BlockingManager.IDENTITY).block(model.conversation.account, model.conversation.counterpart);
+ view_model.block_changed.connect((action) => {
+ switch (action) {
+ case USER:
+ stream_interactor.get_module(BlockingManager.IDENTITY).block(model.conversation.account, model.conversation.counterpart);
+ stream_interactor.get_module(BlockingManager.IDENTITY).unblock(model.conversation.account, model.conversation.counterpart.domain_jid);
+ break;
+ case DOMAIN:
+ stream_interactor.get_module(BlockingManager.IDENTITY).block(model.conversation.account, model.conversation.counterpart.domain_jid);
+ break;
+ case UNBLOCK:
+ stream_interactor.get_module(BlockingManager.IDENTITY).unblock(model.conversation.account, model.conversation.counterpart);
+ stream_interactor.get_module(BlockingManager.IDENTITY).unblock(model.conversation.account, model.conversation.counterpart.domain_jid);
+ break;
}
- view_model.blocked = !view_model.blocked;
+ view_model.blocked = action;
});
view_model.notification_changed.connect((setting) => {
switch (setting) {
@@ -189,4 +205,4 @@ namespace Dino.Ui.ConversationDetails {
break;
}
}
-} \ No newline at end of file
+}
diff --git a/main/src/ui/main_window.vala b/main/src/ui/main_window.vala
index dd54052e..ce71d413 100644
--- a/main/src/ui/main_window.vala
+++ b/main/src/ui/main_window.vala
@@ -20,7 +20,7 @@ public class MainWindow : Adw.ApplicationWindow {
public ConversationTitlebar conversation_titlebar;
public Widget conversation_list_titlebar;
public Box box = new Box(Orientation.VERTICAL, 0) { orientation=Orientation.VERTICAL };
- public Adw.Leaflet leaflet;
+ private Adw.Leaflet leaflet;
public Box left_box;
public Box right_box;
public Adw.Flap search_flap;
diff --git a/main/src/ui/main_window_controller.vala b/main/src/ui/main_window_controller.vala
index 7a3ebcb2..2e270663 100644
--- a/main/src/ui/main_window_controller.vala
+++ b/main/src/ui/main_window_controller.vala
@@ -69,7 +69,7 @@ public class MainWindowController : Object {
dialog.set_transient_for(app.get_active_window());
dialog.present();
});
- window.accounts_placeholder.primary_button.clicked.connect(() => { app.activate_action("accounts", null); });
+ window.accounts_placeholder.primary_button.clicked.connect(() => { app.activate_action("preferences", null); });
window.conversation_selector.conversation_selected.connect((conversation) => select_conversation(conversation));
// ConversationListModel list_model = new ConversationListModel(stream_interactor);
diff --git a/main/src/ui/notifier_freedesktop.vala b/main/src/ui/notifier_freedesktop.vala
index a1df5990..0d263dba 100644
--- a/main/src/ui/notifier_freedesktop.vala
+++ b/main/src/ui/notifier_freedesktop.vala
@@ -201,8 +201,13 @@ public class Dino.Ui.FreeDesktopNotifier : NotificationProvider, Object {
HashTable<string, Variant> hash_table = new HashTable<string, Variant>(null, null);
hash_table["desktop-entry"] = new Variant.string(Dino.Application.get_default().get_application_id());
hash_table["category"] = new Variant.string("im.error");
+ string[] actions = new string[] {"default", "Open preferences"};
try {
- yield dbus_notifications.notify("Dino", 0, "im.dino.Dino", summary, body, new string[]{}, hash_table, -1);
+ uint32 notification_id = yield dbus_notifications.notify("Dino", 0, "im.dino.Dino", summary, body, actions, hash_table, -1);
+
+ add_action_listener(notification_id, "default", () => {
+ GLib.Application.get_default().activate_action("preferences-account", new Variant.int32(account.id));
+ });
} catch (Error e) {
warning("Failed showing connection error notification: %s", e.message);
}
diff --git a/main/src/ui/notifier_gnotifications.vala b/main/src/ui/notifier_gnotifications.vala
index 4d36620d..462cdf70 100644
--- a/main/src/ui/notifier_gnotifications.vala
+++ b/main/src/ui/notifier_gnotifications.vala
@@ -102,6 +102,7 @@ namespace Dino.Ui {
public async void notify_connection_error(Account account, ConnectionManager.ConnectionError error) {
Notification notification = new Notification(_("Could not connect to %s").printf(account.bare_jid.domainpart));
+ notification.set_default_action_and_target_value("app.preferences-account", new Variant.int32(account.id));
switch (error.source) {
case ConnectionManager.ConnectionError.Source.SASL:
notification.set_body("Wrong password");
diff --git a/main/src/ui/settings_dialog.vala b/main/src/ui/settings_dialog.vala
deleted file mode 100644
index 3635879c..00000000
--- a/main/src/ui/settings_dialog.vala
+++ /dev/null
@@ -1,30 +0,0 @@
-using Gtk;
-
-namespace Dino.Ui {
-
-[GtkTemplate (ui = "/im/dino/Dino/settings_dialog.ui")]
-class SettingsDialog : Adw.PreferencesWindow {
-
- [GtkChild] private unowned Switch typing_switch;
- [GtkChild] private unowned Switch marker_switch;
- [GtkChild] private unowned Switch notification_switch;
- [GtkChild] private unowned Switch emoji_switch;
-
- Dino.Entities.Settings settings = Dino.Application.get_default().settings;
-
- public SettingsDialog() {
- Object();
-
- typing_switch.active = settings.send_typing;
- marker_switch.active = settings.send_marker;
- notification_switch.active = settings.notifications;
- emoji_switch.active = settings.convert_utf8_smileys;
-
- typing_switch.notify["active"].connect(() => { settings.send_typing = typing_switch.active; } );
- marker_switch.notify["active"].connect(() => { settings.send_marker = marker_switch.active; } );
- notification_switch.notify["active"].connect(() => { settings.notifications = notification_switch.active; } );
- emoji_switch.notify["active"].connect(() => { settings.convert_utf8_smileys = emoji_switch.active; });
- }
-}
-
-}
diff --git a/main/src/ui/util/helper.vala b/main/src/ui/util/helper.vala
index 63288fc2..45b96b94 100644
--- a/main/src/ui/util/helper.vala
+++ b/main/src/ui/util/helper.vala
@@ -297,6 +297,31 @@ public static string parse_add_markup_theme(string s_, string? highlight_word, b
return s;
}
+ // Modifies `markups`.
+ public string remove_fallbacks_adjust_markups(string text, bool contains_quote, Gee.List<Xep.FallbackIndication.Fallback> fallbacks, Gee.List<Xep.MessageMarkup.Span> markups) {
+ string processed_text = text;
+
+ foreach (var fallback in fallbacks) {
+ if (fallback.ns_uri == Xep.Replies.NS_URI && contains_quote) {
+ foreach (var fallback_location in fallback.locations) {
+ processed_text = processed_text[0:processed_text.index_of_nth_char(fallback_location.from_char)] +
+ processed_text[processed_text.index_of_nth_char(fallback_location.to_char):processed_text.length];
+
+ int length = fallback_location.to_char - fallback_location.from_char;
+ foreach (Xep.MessageMarkup.Span span in markups) {
+ if (span.start_char > fallback_location.to_char) {
+ span.start_char -= length;
+ }
+ if (span.end_char > fallback_location.to_char) {
+ span.end_char -= length;
+ }
+ }
+ }
+ }
+ }
+ return processed_text;
+ }
+
/**
* This is a heuristic to count emojis in a string {@link http://example.com/}
*