aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/conversation_content_view
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/ui/conversation_content_view')
-rw-r--r--main/src/ui/conversation_content_view/file_default_widget.vala16
-rw-r--r--main/src/ui/conversation_content_view/file_widget.vala5
2 files changed, 20 insertions, 1 deletions
diff --git a/main/src/ui/conversation_content_view/file_default_widget.vala b/main/src/ui/conversation_content_view/file_default_widget.vala
index 28b7d477..638dab15 100644
--- a/main/src/ui/conversation_content_view/file_default_widget.vala
+++ b/main/src/ui/conversation_content_view/file_default_widget.vala
@@ -19,6 +19,7 @@ public class FileDefaultWidget : EventBox {
public ModelButton file_open_button;
public ModelButton file_save_button;
+ public ModelButton cancel_button;
private FileTransfer.State state;
@@ -27,6 +28,7 @@ public class FileDefaultWidget : EventBox {
this.leave_notify_event.connect(on_pointer_left_event);
file_open_button = new ModelButton() { text=_("Open"), visible=true };
file_save_button = new ModelButton() { text=_("Save as…"), visible=true };
+ cancel_button = new ModelButton() { text=_("Cancel"), visible=true };
}
public void update_file_info(string? mime_type, FileTransfer.State state, long size) {
@@ -59,6 +61,18 @@ public class FileDefaultWidget : EventBox {
mime_label.label = _("Downloading %s…").printf(get_size_string(size));
spinner.active = true;
image_stack.set_visible_child_name("spinner");
+
+ // Create a menu
+ Gtk.PopoverMenu popover_menu = new Gtk.PopoverMenu();
+ Box file_menu_box = new Box(Orientation.VERTICAL, 0) { margin=10, visible=true };
+ file_menu_box.add(cancel_button);
+ popover_menu.add(file_menu_box);
+ file_menu.popover = popover_menu;
+ file_menu.button_release_event.connect(() => {
+ popover_menu.visible = true;
+ return true;
+ });
+ popover_menu.closed.connect(on_pointer_left);
break;
case FileTransfer.State.NOT_STARTED:
if (mime_description != null) {
@@ -84,7 +98,7 @@ public class FileDefaultWidget : EventBox {
if (state == FileTransfer.State.NOT_STARTED) {
image_stack.set_visible_child_name("download_image");
}
- if (state == FileTransfer.State.COMPLETE) {
+ if (state == FileTransfer.State.COMPLETE || state == FileTransfer.State.IN_PROGRESS) {
file_menu.opacity = 1;
}
return false;
diff --git a/main/src/ui/conversation_content_view/file_widget.vala b/main/src/ui/conversation_content_view/file_widget.vala
index 0040db3c..b63195dc 100644
--- a/main/src/ui/conversation_content_view/file_widget.vala
+++ b/main/src/ui/conversation_content_view/file_widget.vala
@@ -131,6 +131,7 @@ public class FileDefaultWidgetController : Object {
widget.button_release_event.connect(on_clicked);
widget.file_open_button.clicked.connect(open_file);
widget.file_save_button.clicked.connect(save_file);
+ widget.cancel_button.clicked.connect(cancel_download);
}
public void set_file_transfer(FileTransfer file_transfer, StreamInteractor stream_interactor) {
@@ -186,6 +187,10 @@ public class FileDefaultWidgetController : Object {
}
}
+ private void cancel_download() {
+ file_transfer.cancellable.cancel();
+ }
+
private bool on_clicked(EventButton event_button) {
switch (state) {
case FileTransfer.State.COMPLETE: