Only consider first file if multiple ones are drag and droped

fixes #818
This commit is contained in:
fiaxh 2020-06-04 17:10:57 +02:00
parent e3724f96ed
commit d5e036596b
2 changed files with 18 additions and 7 deletions

View file

@ -140,7 +140,7 @@ public class ConversationViewController : Object {
private void update_file_upload_status() { private void update_file_upload_status() {
bool upload_available = stream_interactor.get_module(FileManager.IDENTITY).is_upload_available(conversation); bool upload_available = stream_interactor.get_module(FileManager.IDENTITY).is_upload_available(conversation);
chat_input_controller.set_file_upload_active(upload_available); chat_input_controller.set_file_upload_active(upload_available);
if (upload_available) { if (upload_available && overlay_dialog == null) {
Gtk.drag_dest_set(view, DestDefaults.ALL, target_list, Gdk.DragAction.COPY); Gtk.drag_dest_set(view, DestDefaults.ALL, target_list, Gdk.DragAction.COPY);
} else { } else {
Gtk.drag_dest_unset(view); Gtk.drag_dest_unset(view);
@ -184,11 +184,10 @@ public class ConversationViewController : Object {
switch (target_type) { switch (target_type) {
case Target.URI_LIST: case Target.URI_LIST:
string[] uris = selection_data.get_uris(); string[] uris = selection_data.get_uris();
for (int i = 0; i < uris.length; i++) { // For now we only process the first dragged file
try { if (uris.length >= 1) {
string file_path = Filename.from_uri(uris[i]); string file_path = Filename.from_uri(uris[0]);
open_send_file_overlay(File.new_for_path(file_path)); open_send_file_overlay(File.new_for_path(file_path));
} catch (Error err) {}
} }
break; break;
default: default:
@ -226,8 +225,16 @@ public class ConversationViewController : Object {
} }
} }
overlay.close.connect(() => {
// We don't want drag'n'drop to be active while the overlay is active
overlay_dialog = null;
update_file_upload_status();
});
view.add_overlay_dialog(overlay); view.add_overlay_dialog(overlay);
overlay_dialog = overlay; overlay_dialog = overlay;
update_file_upload_status();
} }
private void send_file(File file) { private void send_file(File file) {

View file

@ -20,9 +20,13 @@ public class FileSendOverlay : Gtk.EventBox {
private bool can_send = true; private bool can_send = true;
public FileSendOverlay(File file, FileInfo file_info) { public FileSendOverlay(File file, FileInfo file_info) {
close_button.clicked.connect(() => this.destroy()); close_button.clicked.connect(() => {
this.close();
this.destroy();
});
send_button.clicked.connect(() => { send_button.clicked.connect(() => {
send_file(); send_file();
this.close();
this.destroy(); this.destroy();
}); });