aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2025-11-14 21:29:00 -0600
committerfiaxh <git@lightrise.org>2025-11-14 21:32:41 -0600
commitd479ba81a66a835913697bacf3a0d912ef68346a (patch)
tree9e2e0f81b81bf02bc199d80d428c67259e516dca
parent52a0d3544ec054edff1e0a67c800a7c18d3c689f (diff)
Make FileOverlay a proper Dialog
-rw-r--r--main/data/conversation_view.ui88
-rw-r--r--main/data/file_send_overlay.ui85
-rw-r--r--main/data/style.css12
-rw-r--r--main/src/ui/conversation_view.vala36
-rw-r--r--main/src/ui/conversation_view_controller.vala21
-rw-r--r--main/src/ui/file_send_overlay.vala56
6 files changed, 84 insertions, 214 deletions
diff --git a/main/data/conversation_view.ui b/main/data/conversation_view.ui
index 099758a3..7baac756 100644
--- a/main/data/conversation_view.ui
+++ b/main/data/conversation_view.ui
@@ -2,78 +2,50 @@
<interface>
<template class="DinoUiConversationView">
<child>
- <object class="GtkOverlay" id="overlay">
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
+ <style>
+ <class name="dino-conversation"/>
+ </style>
<child>
- <object class="GtkBox">
- <property name="orientation">vertical</property>
- <style>
- <class name="dino-conversation"/>
- </style>
+ <object class="GtkOverlay" id="conversation_overlay">
+ <property name="vexpand">True</property>
<child>
- <object class="GtkOverlay" id="conversation_overlay">
- <property name="vexpand">True</property>
+ <object class="DinoUiConversationSummaryConversationView" id="conversation_frame">
+ </object>
+ </child>
+ <child type="overlay">
+ <object class="GtkRevealer" id="goto_end_revealer">
+ <property name="halign">end</property>
+ <property name="valign">end</property>
+ <property name="transition-type">crossfade</property>
+ <property name="margin-end">30</property>
+ <property name="margin-bottom">30</property>
<child>
- <object class="DinoUiConversationSummaryConversationView" id="conversation_frame">
- </object>
- </child>
- <child type="overlay">
- <object class="GtkRevealer" id="goto_end_revealer">
+ <object class="GtkButton" id="goto_end_button">
+ <property name="width-request">30</property>
+ <property name="height-request">30</property>
+ <property name="vexpand">False</property>
<property name="halign">end</property>
<property name="valign">end</property>
- <property name="transition-type">crossfade</property>
- <property name="margin-end">30</property>
- <property name="margin-bottom">30</property>
+ <style>
+ <class name="circular"/>
+ <class name="opaque"/>
+ </style>
<child>
- <object class="GtkButton" id="goto_end_button">
- <property name="width-request">30</property>
- <property name="height-request">30</property>
- <property name="vexpand">False</property>
- <property name="halign">end</property>
- <property name="valign">end</property>
- <style>
- <class name="circular"/>
- <class name="opaque"/>
- </style>
- <child>
- <object class="GtkImage">
- <property name="icon-name">go-down-symbolic</property>
- <property name="icon-size">1</property>
- </object>
- </child>
+ <object class="GtkImage">
+ <property name="icon-name">go-down-symbolic</property>
+ <property name="icon-size">1</property>
</object>
</child>
</object>
</child>
</object>
</child>
- <child>
- <object class="DinoUiChatInputView" id="chat_input">
- </object>
- </child>
</object>
</child>
- <child type="overlay">
- <object class="GtkRevealer" id="white_revealer">
- <property name="transition-type">crossfade</property>
- <property name="transition-duration">200</property>
- <property name="reveal-child">False</property>
- <property name="visible">False</property>
- <child>
- <object class="GtkBox">
- <property name="opacity">0.7</property>
- <style>
- <class name="dino-white-overlay"/>
- </style>
- </object>
- </child>
- </object>
- </child>
- <child type="overlay">
- <object class="GtkRevealer" id="content_revealer">
- <property name="transition-type">crossfade</property>
- <property name="transition-duration">100</property>
- <property name="reveal-child">False</property>
- <property name="visible">False</property>
+ <child>
+ <object class="DinoUiChatInputView" id="chat_input">
</object>
</child>
</object>
diff --git a/main/data/file_send_overlay.ui b/main/data/file_send_overlay.ui
index 15ff35ef..77e5bd5e 100644
--- a/main/data/file_send_overlay.ui
+++ b/main/data/file_send_overlay.ui
@@ -1,73 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
- <object class="GtkBox" id="main_box">
- <property name="hexpand">0</property>
- <property name="vexpand">0</property>
- <property name="halign">center</property>
- <property name="valign">center</property>
- <style>
- <class name="background"/>
- <class name="dino-file-overlay"/>
- </style>
+ <template class="DinoUiFileSendOverlay">
+ <property name="title" translatable="1">Send a file</property>
+ <property name="content-width">400</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
- <property name="margin-end">20</property>
- <property name="margin-start">20</property>
+ <child>
+ <object class="AdwHeaderBar">
+ <style>
+ <class name="flat"/>
+ </style>
+ </object>
+ </child>
<child>
<object class="GtkBox">
- <property name="margin-top">10</property>
- <property name="margin-bottom">10</property>
+ <property name="margin-start">14</property>
+ <property name="margin-end">14</property>
+ <property name="margin-top">14</property>
+ <property name="margin-bottom">14</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="spacing">14</property>
+ <property name="orientation">vertical</property>
<child>
- <object class="GtkLabel">
- <property name="label" translatable="1">Send a file</property>
- <property name="hexpand">1</property>
- <attributes>
- <attribute name="weight" value="PANGO_WEIGHT_BOLD"></attribute>
- </attributes>
+ <object class="DinoUiSizingBin" id="file_widget_insert">
+ <property name="halign">center</property>
</object>
</child>
<child>
- <object class="GtkButton" id="close_button">
- <property name="focusable">1</property>
- <style>
- <class name="titlebutton"/>
- <class name="close"/>
- </style>
+ <object class="GtkBox">
+ <property name="halign">end</property>
+ <property name="spacing">5</property>
+ <child>
+ <object class="GtkLabel" id="info_label"/>
+ </child>
<child>
- <object class="GtkImage">
- <property name="icon-name">window-close-symbolic</property>
+ <object class="GtkButton" id="send_button">
+ <property name="label" translatable="1">Send</property>
+ <property name="focusable">1</property>
+ <signal name="clicked" handler="on_send_button_clicked" />
+ <style>
+ <class name="suggested-action"/>
+ </style>
</object>
</child>
</object>
</child>
</object>
</child>
- <child>
- <object class="DinoUiSizingBin" id="file_widget_insert">
- </object>
- </child>
- <child>
- <object class="GtkBox">
- <property name="margin-top">15</property>
- <property name="margin-bottom">15</property>
- <property name="spacing">5</property>
- <child>
- <object class="GtkLabel" id="info_label"/>
- </child>
- <child>
- <object class="GtkButton" id="send_button">
- <property name="label" translatable="1">Send</property>
- <property name="focusable">1</property>
- <style>
- <class name="suggested-action"/>
- </style>
- </object>
- </child>
- </object>
- </child>
</object>
</child>
- </object>
+ </template>
</interface> \ No newline at end of file
diff --git a/main/data/style.css b/main/data/style.css
index 5762d264..625534f2 100644
--- a/main/data/style.css
+++ b/main/data/style.css
@@ -233,18 +233,6 @@ window.dino-main .dino-sidebar frame.auto-complete list > row {
transition: none;
}
-/* File overlay */
-
-window.dino-main .dino-white-overlay {
- background: @theme_base_color;
-}
-
-window.dino-main .dino-file-overlay {
- border-radius: 5px;
- border: 1px solid alpha(black, 0.2);
- box-shadow: 0 2px 3px alpha(black, 0.1);
-}
-
/* Chat Input*/
/* These rules are direved from the libadwaita style for activateable entry rows */
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;
- }
}
}