diff options
| author | fiaxh <git@lightrise.org> | 2025-11-14 21:29:00 -0600 |
|---|---|---|
| committer | fiaxh <git@lightrise.org> | 2025-11-14 21:32:41 -0600 |
| commit | d479ba81a66a835913697bacf3a0d912ef68346a (patch) | |
| tree | 9e2e0f81b81bf02bc199d80d428c67259e516dca /main/src | |
| parent | 52a0d3544ec054edff1e0a67c800a7c18d3c689f (diff) | |
Make FileOverlay a proper Dialog
Diffstat (limited to 'main/src')
| -rw-r--r-- | main/src/ui/conversation_view.vala | 36 | ||||
| -rw-r--r-- | main/src/ui/conversation_view_controller.vala | 21 | ||||
| -rw-r--r-- | main/src/ui/file_send_overlay.vala | 56 |
3 files changed, 20 insertions, 93 deletions
diff --git a/main/src/ui/conversation_view.vala b/main/src/ui/conversation_view.vala index 62d1ec9b..26043666 100644 --- a/main/src/ui/conversation_view.vala +++ b/main/src/ui/conversation_view.vala @@ -9,49 +9,13 @@ namespace Dino.Ui { [GtkTemplate (ui = "/im/dino/Dino/conversation_view.ui")] public class ConversationView : Widget { -// [GtkChild] public unowned ScrolledWindow conversation_scrolled; - [GtkChild] public unowned Overlay overlay; [GtkChild] public unowned Revealer goto_end_revealer; [GtkChild] public unowned Button goto_end_button; [GtkChild] public unowned ChatInput.View chat_input; [GtkChild] public unowned ConversationSummary.ConversationView conversation_frame; - [GtkChild] public unowned Revealer white_revealer; - [GtkChild] public unowned Revealer content_revealer; - - public ListView list_view = new ListView(null, null); - - public bool at_current_content = true; construct { this.layout_manager = new BinLayout(); - white_revealer.notify["child-revealed"].connect_after(on_child_revealed_changed); - -// conversation_scrolled.set_child(list_view); -// list_view.set_factory(get_item_factory()); - - } - - public void add_overlay_dialog(Widget widget) { - content_revealer.set_child(widget); - - content_revealer.visible = true; - content_revealer.reveal_child = true; - white_revealer.visible = true; - white_revealer.reveal_child = true; - } - - public void remove_overlay_dialog() { - white_revealer.reveal_child = false; - content_revealer.reveal_child = false; - chat_input.do_focus(); - } - - private void on_child_revealed_changed() { - if (!white_revealer.child_revealed) { - white_revealer.visible = false; - content_revealer.visible = false; - content_revealer.set_child(null); - } } } diff --git a/main/src/ui/conversation_view_controller.vala b/main/src/ui/conversation_view_controller.vala index 888879b0..ad2caa15 100644 --- a/main/src/ui/conversation_view_controller.vala +++ b/main/src/ui/conversation_view_controller.vala @@ -109,9 +109,6 @@ public class ConversationViewController : Object { if (this.conversation != null) { conversation.notify["encryption"].disconnect(update_file_upload_status); } - if (overlay_dialog != null) { - overlay_dialog.destroy(); - } this.conversation = conversation; @@ -154,7 +151,7 @@ public class ConversationViewController : Object { bool upload_available = yield stream_interactor.get_module(FileManager.IDENTITY).is_upload_available(conversation); chat_input_controller.set_file_upload_active(upload_available); - if (upload_available && overlay_dialog == null) { + if (upload_available) { if (drop_event_controller.widget == null) { view.add_controller(drop_event_controller); } @@ -218,8 +215,8 @@ public class ConversationViewController : Object { return; } - FileSendOverlay overlay = new FileSendOverlay(file, file_info); - overlay.send_file.connect(() => send_file(file)); + FileSendOverlay file_send_overlay = new FileSendOverlay(file, file_info); + file_send_overlay.send_file.connect(send_file); stream_interactor.get_module(FileManager.IDENTITY).get_file_size_limits.begin(conversation, (_, res) => { HashMap<int, long> limits = stream_interactor.get_module(FileManager.IDENTITY).get_file_size_limits.end(res); @@ -230,22 +227,18 @@ public class ConversationViewController : Object { } } if (!something_works && limits.has_key(0)) { - if (!something_works && file_info.get_size() > limits[0] && overlay != null) { - overlay.set_file_too_large(); + if (!something_works && file_info.get_size() > limits[0] && file_send_overlay != null) { + file_send_overlay.set_file_too_large(); } } }); - overlay.close.connect(() => { + file_send_overlay.closed.connect(() => { // We don't want drag'n'drop to be active while the overlay is active - view.remove_overlay_dialog(); - overlay_dialog = null; update_file_upload_status.begin(); - overlay = null; }); - view.add_overlay_dialog(overlay.get_widget()); - overlay_dialog = overlay.get_widget(); + file_send_overlay.present(view); update_file_upload_status.begin(); } diff --git a/main/src/ui/file_send_overlay.vala b/main/src/ui/file_send_overlay.vala index 45349c11..130dc492 100644 --- a/main/src/ui/file_send_overlay.vala +++ b/main/src/ui/file_send_overlay.vala @@ -6,53 +6,27 @@ using Dino.Entities; namespace Dino.Ui { -public class FileSendOverlay : Object { +[GtkTemplate (ui = "/im/dino/Dino/file_send_overlay.ui")] +public class FileSendOverlay : Adw.Dialog { - public signal void close(); - public signal void send_file(); + public signal void send_file(File file); - public Box main_box; - public unowned Button close_button; - public unowned Button send_button; - public unowned SizingBin file_widget_insert; - public unowned Label info_label; + [GtkChild] protected unowned Button send_button; + [GtkChild] protected unowned SizingBin file_widget_insert; + [GtkChild] protected unowned Label info_label; + private File file; private bool can_send = true; public FileSendOverlay(File file, FileInfo file_info) { - Builder builder = new Builder.from_resource("/im/dino/Dino/file_send_overlay.ui"); - main_box = (Box) builder.get_object("main_box"); - close_button = (Button) builder.get_object("close_button"); - send_button = (Button) builder.get_object("send_button"); - file_widget_insert = (SizingBin) builder.get_object("file_widget_insert"); - info_label = (Label) builder.get_object("info_label"); - - close_button.clicked.connect(() => { - close(); - }); - send_button.clicked.connect(() => { - send_file(); - close(); - }); - + this.file = file; load_file_widget.begin(file, file_info); + } - main_box.realize.connect(() => { - if (can_send) { - send_button.grab_focus(); - } else { - close_button.grab_focus(); - } - }); - - var key_events = new EventControllerKey(); - key_events.key_pressed.connect((keyval) => { - if (keyval == Gdk.Key.Escape) { - close(); - } - return false; - }); - this.main_box.add_controller(key_events); + [GtkCallback] + private void on_send_button_clicked() { + send_file(file); + close(); } private async void load_file_widget(File file, FileInfo file_info) { @@ -86,10 +60,6 @@ public class FileSendOverlay : Object { send_button.sensitive = false; can_send = false; } - - public Widget get_widget() { - return main_box; - } } } |
