Verified Commit 7f49111f authored by Marcin Mielniczuk's avatar Marcin Mielniczuk
Browse files

Show a notification if some of the paths are skipped during a drag&drop.

Related to #10544
parent 19e371c8
Pipeline #7717 canceled with stages
......@@ -29,6 +29,8 @@ import time
import uuid
import tempfile
from typing import cast
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import GLib
......@@ -51,6 +53,7 @@ from gajim import gtkgui_helpers
from gajim.conversation_textview import ConversationTextview
from gajim.gui.notification import Notification
from gajim.gui.dialogs import DialogButton
from gajim.gui.dialogs import ConfirmationDialog
from gajim.gui.dialogs import PastePreviewDialog
......@@ -967,16 +970,29 @@ class ChatControlBase(ChatCommandProcessor, CommandTools, EventHelper):
self.xml.drop_area.set_no_show_all(False)
self.xml.drop_area.show_all()
def drag_data_file_transfer(self, selection):
def drag_data_file_transfer(self, selection: Gtk.SelectionData) -> None:
# we may have more than one file dropped
uri_splitted = selection.get_uris()
skipped_uris = []
for uri in uri_splitted:
path = helpers.get_file_path_from_dnd_dropped_uri(uri)
if not os.path.isfile(path): # is it a file?
skipped_uris.append(path)
continue
self._start_filetransfer(path)
if skipped_uris:
event_type = _('Skipped files')
text = _("The following files were skipped:") + "\n" + "\n".join(skipped_uris)
cast(Notification, app.notification).popup(
event_type,
self.contact.jid,
self.account,
icon_name='dialog-warning',
title=event_type,
text=text)
def get_seclabel(self):
idx = self.xml.label_selector.get_active()
if idx == -1:
......
......@@ -352,7 +352,7 @@ def build_command(executable, parameter):
command = '%s "%s"' % (executable, parameter)
return command
def get_file_path_from_dnd_dropped_uri(uri):
def get_file_path_from_dnd_dropped_uri(uri: str) -> str:
path = urllib.parse.unquote(uri) # escape special chars
path = path.strip('\r\n\x00') # remove \r\n and NULL
# get the path to file
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment