aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/chat_input
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/ui/chat_input')
-rw-r--r--main/src/ui/chat_input/chat_input_controller.vala15
-rw-r--r--main/src/ui/chat_input/view.vala17
2 files changed, 10 insertions, 22 deletions
diff --git a/main/src/ui/chat_input/chat_input_controller.vala b/main/src/ui/chat_input/chat_input_controller.vala
index 4844ff6c..fb7f88b1 100644
--- a/main/src/ui/chat_input/chat_input_controller.vala
+++ b/main/src/ui/chat_input/chat_input_controller.vala
@@ -9,6 +9,7 @@ namespace Dino.Ui {
public class ChatInputController : Object {
public signal void activate_last_message_correction();
+ public signal void file_picker_selected();
public new string? conversation_display_name { get; set; }
public string? conversation_topic { get; set; }
@@ -33,11 +34,12 @@ public class ChatInputController : Object {
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);
- stream_interactor.get_module(FileManager.IDENTITY).upload_available.connect(on_upload_available);
+ chat_input.file_button.clicked.connect(() => file_picker_selected());
}
public void set_conversation(Conversation conversation) {
@@ -51,6 +53,10 @@ public class ChatInputController : Object {
chat_text_view_controller.initialize_for_conversation(conversation);
}
+ public void set_file_upload_active(bool active) {
+ chat_input.set_file_upload_active(active);
+ }
+
private void on_encryption_changed(Plugins.EncryptionListEntry? encryption_entry) {
reset_input_field_status();
@@ -72,13 +78,6 @@ public class ChatInputController : Object {
set_input_field_status(new Plugins.InputFieldStatus("", Plugins.InputFieldStatus.MessageType.NONE, Plugins.InputFieldStatus.InputState.NORMAL));
}
- private void on_upload_available(Account account) {
- if (conversation != null && conversation.account.equals(account)) {
- chat_input.file_button.visible = true;
- chat_input.file_separator.visible = true;
- }
- }
-
private void send_text() {
// Don't do anything if we're in a NO_SEND state. Don't clear the chat input, don't send.
if (input_field_status.input_state == Plugins.InputFieldStatus.InputState.NO_SEND) {
diff --git a/main/src/ui/chat_input/view.vala b/main/src/ui/chat_input/view.vala
index 166ead2e..b99cd1c4 100644
--- a/main/src/ui/chat_input/view.vala
+++ b/main/src/ui/chat_input/view.vala
@@ -33,17 +33,9 @@ public class View : Box {
encryption_widget = new EncryptionButton(stream_interactor) { relief=ReliefStyle.NONE, margin_top=3, valign=Align.START, visible=true };
- file_button.clicked.connect(() => {
- PreviewFileChooserNative chooser = new PreviewFileChooserNative("Select file", get_toplevel() as Gtk.Window, FileChooserAction.OPEN, "Select", "Cancel");
- if (chooser.run() == Gtk.ResponseType.ACCEPT) {
- string uri = chooser.get_filename();
- stream_interactor.get_module(FileManager.IDENTITY).send_file.begin(uri, conversation);
- }
- });
file_button.get_style_context().add_class("dino-attach-button");
encryption_widget.get_style_context().add_class("dino-chatinput-button");
- encryption_widget.encryption_changed.connect(update_file_transfer_availability);
// Emoji button for emoji picker (recents don't work < 3.22.19, category icons don't work <3.23.2)
if (Gtk.get_major_version() >= 3 && Gtk.get_minor_version() >= 24) {
@@ -68,18 +60,15 @@ public class View : Box {
return this;
}
- private void update_file_transfer_availability() {
- bool upload_available = stream_interactor.get_module(FileManager.IDENTITY).is_upload_available(conversation);
- file_button.visible = upload_available;
- file_separator.visible = upload_available;
+ public void set_file_upload_active(bool active) {
+ file_button.visible = active;
+ file_separator.visible = active;
}
public void initialize_for_conversation(Conversation conversation) {
if (this.conversation != null) entry_cache[this.conversation] = chat_text_view.text_view.buffer.text;
this.conversation = conversation;
- update_file_transfer_availability();
-
chat_text_view.text_view.buffer.text = "";
if (entry_cache.has_key(conversation)) {
chat_text_view.text_view.buffer.text = entry_cache[conversation];