diff options
author | fiaxh <git@mx.ax.lt> | 2017-03-16 16:28:32 +0100 |
---|---|---|
committer | fiaxh <git@mx.ax.lt> | 2017-03-16 19:46:22 +0100 |
commit | 6f3eee1430b1e3bdb22b8c532f8b609015d01bfb (patch) | |
tree | 13453938a7583d2d304bd9425c43a21e13f0c476 /main/src | |
parent | af49a47cf6c5933a9bcc21f2b7bb20d85be37483 (diff) | |
download | dino-6f3eee1430b1e3bdb22b8c532f8b609015d01bfb.tar.gz dino-6f3eee1430b1e3bdb22b8c532f8b609015d01bfb.zip |
Improve when to send chat state notifications
Diffstat (limited to 'main/src')
-rw-r--r-- | main/src/ui/chat_input.vala | 19 | ||||
-rw-r--r-- | main/src/ui/unified_window.vala | 4 |
2 files changed, 10 insertions, 13 deletions
diff --git a/main/src/ui/chat_input.vala b/main/src/ui/chat_input.vala index 209869a8..2079d747 100644 --- a/main/src/ui/chat_input.vala +++ b/main/src/ui/chat_input.vala @@ -38,23 +38,21 @@ public class ChatInput : Box { this.stream_interactor = stream_interactor; scrolled.get_vscrollbar().get_preferred_height(out vscrollbar_min_height, null); scrolled.vadjustment.notify["upper"].connect_after(on_upper_notify); + text_input.key_press_event.connect(on_text_input_key_press); + text_input.buffer.changed.connect(on_text_input_changed); } public void initialize_for_conversation(Conversation conversation) { - if (this.conversation != null) { - if (text_input.buffer.text != "") { - entry_cache[this.conversation] = text_input.buffer.text; - } else { - entry_cache.unset(this.conversation); - } - } + if (this.conversation != null) entry_cache[this.conversation] = text_input.buffer.text; this.conversation = conversation; + + text_input.buffer.changed.disconnect(on_text_input_changed); text_input.buffer.text = ""; if (entry_cache.has_key(conversation)) { text_input.buffer.text = entry_cache[conversation]; } - text_input.key_press_event.connect(on_text_input_key_press); - text_input.key_release_event.connect(on_text_input_key_release); + text_input.buffer.changed.connect(on_text_input_changed); + text_input.grab_focus(); } @@ -117,13 +115,12 @@ public class ChatInput : Box { } } - private bool on_text_input_key_release(EventKey event) { + private void on_text_input_changed() { if (text_input.buffer.text != "") { ChatInteraction.get_instance(stream_interactor).on_message_entered(conversation); } else { ChatInteraction.get_instance(stream_interactor).on_message_cleared(conversation); } - return false; } } diff --git a/main/src/ui/unified_window.vala b/main/src/ui/unified_window.vala index 269799c2..0f33450d 100644 --- a/main/src/ui/unified_window.vala +++ b/main/src/ui/unified_window.vala @@ -68,12 +68,12 @@ public class UnifiedWindow : Window { } private bool on_focus_in_event() { - ChatInteraction.get_instance(stream_interactor).window_focus_in(conversation); + ChatInteraction.get_instance(stream_interactor).on_window_focus_in(conversation); return false; } private bool on_focus_out_event() { - ChatInteraction.get_instance(stream_interactor).window_focus_out(conversation); + ChatInteraction.get_instance(stream_interactor).on_window_focus_out(conversation); return false; } } |