aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/ui')
-rw-r--r--main/src/ui/chat_input/chat_input_controller.vala13
-rw-r--r--main/src/ui/conversation_content_view/conversation_view.vala18
-rw-r--r--main/src/ui/conversation_content_view/message_widget.vala24
-rw-r--r--main/src/ui/conversation_view_controller.vala2
4 files changed, 55 insertions, 2 deletions
diff --git a/main/src/ui/chat_input/chat_input_controller.vala b/main/src/ui/chat_input/chat_input_controller.vala
index c0878c36..4844ff6c 100644
--- a/main/src/ui/chat_input/chat_input_controller.vala
+++ b/main/src/ui/chat_input/chat_input_controller.vala
@@ -8,6 +8,8 @@ namespace Dino.Ui {
public class ChatInputController : Object {
+ public signal void activate_last_message_correction();
+
public new string? conversation_display_name { get; set; }
public string? conversation_topic { get; set; }
@@ -30,6 +32,7 @@ public class ChatInputController : Object {
reset_input_field_status();
chat_input.chat_text_view.text_view.buffer.changed.connect(on_text_input_changed);
+ chat_input.chat_text_view.text_view.key_press_event.connect(on_text_input_key_press);
chat_text_view_controller.send_text.connect(send_text);
chat_input.encryption_widget.encryption_changed.connect(on_encryption_changed);
@@ -145,6 +148,16 @@ public class ChatInputController : Object {
stream_interactor.get_module(ChatInteraction.IDENTITY).on_message_cleared(conversation);
}
}
+
+ private bool on_text_input_key_press(EventKey event) {
+ if (event.keyval == Gdk.Key.Up && chat_input.chat_text_view.text_view.buffer.text == "") {
+ activate_last_message_correction();
+ return true;
+ } else {
+ chat_input.chat_text_view.text_view.grab_focus();
+ }
+ return false;
+ }
}
}
diff --git a/main/src/ui/conversation_content_view/conversation_view.vala b/main/src/ui/conversation_content_view/conversation_view.vala
index 808c6cad..aadb5fdc 100644
--- a/main/src/ui/conversation_content_view/conversation_view.vala
+++ b/main/src/ui/conversation_content_view/conversation_view.vala
@@ -76,6 +76,24 @@ public class ConversationView : Box, Plugins.ConversationItemCollection, Plugins
return this;
}
+ public void activate_last_message_correction() {
+ Gee.BidirIterator<Plugins.MetaConversationItem> iter = content_items.bidir_iterator();
+ iter.last();
+ for (int i = 0; i < 10 && content_items.size > i; i++) {
+ Plugins.MetaConversationItem item = iter.get();
+ MessageMetaItem message_item = item as MessageMetaItem;
+ if (message_item != null) {
+ if ((conversation.type_ == Conversation.Type.CHAT && message_item.jid.equals_bare(conversation.account.bare_jid)) ||
+ (conversation.type_ == Conversation.Type.GROUPCHAT &&
+ message_item.jid.equals(stream_interactor.get_module(MucManager.IDENTITY).get_own_jid(conversation.counterpart, conversation.account)))) {
+ message_item.in_edit_mode = true;
+ break;
+ }
+ }
+ iter.previous();
+ }
+ }
+
private bool on_enter_notify_event(Gdk.EventCrossing event) {
mouse_inside = true;
update_highlight((int)event.x_root, (int)event.y_root);
diff --git a/main/src/ui/conversation_content_view/message_widget.vala b/main/src/ui/conversation_content_view/message_widget.vala
index 71094c71..aefab6e1 100644
--- a/main/src/ui/conversation_content_view/message_widget.vala
+++ b/main/src/ui/conversation_content_view/message_widget.vala
@@ -28,6 +28,16 @@ public class MessageMetaItem : ContentMetaItem {
stream_interactor.get_module(MessageCorrection.IDENTITY).received_correction.connect(on_received_correction);
+ this.notify["in-edit-mode"].connect(() => {
+ if (in_edit_mode == false) return;
+ bool allowed = stream_interactor.get_module(MessageCorrection.IDENTITY).is_own_correction_allowed(message_item.conversation, message_item.message);
+ if (allowed) {
+ message_item_widget.set_edit_mode();
+ } else {
+ this.in_edit_mode = false;
+ }
+ });
+
return message_item_widget;
}
@@ -106,7 +116,11 @@ public class MessageItemWidget : SizeRequestBin {
unset_edit_mode();
});
edit_mode.send.connect(() => {
- edit_sent(edit_mode.chat_text_view.text_view.buffer.text);
+ if (((MessageItem) content_item).message.body != edit_mode.chat_text_view.text_view.buffer.text) {
+ edit_sent(edit_mode.chat_text_view.text_view.buffer.text);
+ } else {
+ edit_cancelled();
+ }
unset_edit_mode();
});
}
@@ -122,6 +136,9 @@ public class MessageItemWidget : SizeRequestBin {
public void unset_edit_mode() {
this.remove(edit_mode);
this.add(label);
+ label.grab_focus();
+ label.selectable = false;
+ label.selectable = true;
}
public void update_label() {
@@ -200,11 +217,16 @@ public class MessageItemEditMode : Box {
});
emoji_button.set_popover(chooser);
+ chat_text_view.text_view.buffer.changed.connect_after(on_text_view_changed);
+
cancel_button.clicked.connect(() => cancelled());
send_button.clicked.connect(() => send());
chat_text_view.cancel_input.connect(() => cancelled());
chat_text_view.send_text.connect(() => send());
+ }
+ private void on_text_view_changed() {
+ send_button.sensitive = chat_text_view.text_view.buffer.text != "";
}
}
diff --git a/main/src/ui/conversation_view_controller.vala b/main/src/ui/conversation_view_controller.vala
index 2e03de8f..31c7e612 100644
--- a/main/src/ui/conversation_view_controller.vala
+++ b/main/src/ui/conversation_view_controller.vala
@@ -44,6 +44,7 @@ public class ConversationViewController : Object {
view.drag_data_received.connect(this.on_drag_data_received);
// forward key presses
+ chat_input_controller.activate_last_message_correction.connect(() => view.conversation_frame.activate_last_message_correction());
view.chat_input.key_press_event.connect(forward_key_press_to_chat_input);
view.conversation_frame.key_press_event.connect(forward_key_press_to_chat_input);
titlebar.key_press_event.connect(forward_key_press_to_chat_input);
@@ -160,7 +161,6 @@ public class ConversationViewController : Object {
return false;
}
if (view.chat_input.chat_text_view.text_view.key_press_event(event)) {
- view.chat_input.chat_text_view.text_view.grab_focus();
return true;
}
return false;