diff --git a/app/ui/main_app_window.py b/app/ui/main_app_window.py
index 212e9f60..63faa368 100644
--- a/app/ui/main_app_window.py
+++ b/app/ui/main_app_window.py
@@ -938,8 +938,9 @@ class Application(Gtk.Application):
uris = data.get_uris()
if txt:
self.receive_selection(view=view, drop_info=view.get_dest_row_at_pos(x, y), data=txt)
- elif len(uris) == 1:
- self.on_assign_picon(view, uris[0])
+ elif len(uris) == 2:
+ from urllib.parse import unquote, urlparse
+ self.on_assign_picon(view, urlparse(unquote(uris[0])).path, urlparse(unquote(uris[1])).path + "/")
def on_bq_view_drag_data_received(self, view, drag_context, x, y, data, info, time):
model_name, model = get_model_data(view)
@@ -2600,22 +2601,12 @@ class Application(Gtk.Application):
update_picons_data(self._settings.picons_local_path, self._picons)
append_picons(self._picons, self._services_model)
- def on_assign_picon(self, view, path=None):
- assign_picon(self.get_target_view(view),
- self._services_view,
- self._fav_view,
- self._main_window,
- self._picons,
- self._settings,
- self._services,
- path)
+ def on_assign_picon(self, view, src_path=None, dst_path=None):
+ assign_picon(self.get_target_view(view), self._services_view, self._fav_view, self._main_window,
+ self._picons, self._settings, self._services, src_path, dst_path)
def on_remove_picon(self, view):
- remove_picon(self.get_target_view(view),
- self._services_view,
- self._fav_view,
- self._picons,
- self._settings)
+ remove_picon(self.get_target_view(view), self._services_view, self._fav_view, self._picons, self._settings)
def on_reference_picon(self, view):
""" Copying picon id to clipboard """
diff --git a/app/ui/main_helper.py b/app/ui/main_helper.py
index bcb83f8e..51167e33 100644
--- a/app/ui/main_helper.py
+++ b/app/ui/main_helper.py
@@ -367,16 +367,16 @@ def append_picons(picons, model):
GLib.idle_add(lambda: next(app, False), priority=GLib.PRIORITY_LOW)
-def assign_picon(target, srv_view, fav_view, transient, picons, settings, services, p_path=None):
+def assign_picon(target, srv_view, fav_view, transient, picons, settings, services, src_path=None, dst_path=None):
view = srv_view if target is ViewTarget.SERVICES else fav_view
model, paths = view.get_selection().get_selected_rows()
- if not p_path:
- p_path = get_chooser_dialog(transient, settings, "*.png files", ("*.png",))
- if p_path == Gtk.ResponseType.CANCEL:
+ if not src_path:
+ src_path = get_chooser_dialog(transient, settings, "*.png files", ("*.png",))
+ if src_path == Gtk.ResponseType.CANCEL:
return
- if not str(p_path).endswith(".png") or not os.path.isfile(p_path):
+ if not str(src_path).endswith(".png") or not os.path.isfile(src_path):
show_dialog(DialogType.ERROR, transient, text="No png file is selected!")
return
@@ -394,10 +394,10 @@ def assign_picon(target, srv_view, fav_view, transient, picons, settings, servic
picon_id = services.get(fav_id)[Column.SRV_PICON_ID]
if picon_id:
- picons_path = settings.picons_local_path
+ picons_path = dst_path or settings.picons_local_path
os.makedirs(os.path.dirname(picons_path), exist_ok=True)
picon_file = picons_path + picon_id
- shutil.copy(p_path, picon_file)
+ shutil.copy(src_path, picon_file)
picon = get_picon_pixbuf(picon_file)
picons[picon_id] = picon
model.set_value(itr, p_pos, picon)
@@ -411,7 +411,8 @@ def set_picon(fav_id, model, picon, fav_id_pos, picon_pos):
for row in model:
if row[fav_id_pos] == fav_id:
row[picon_pos] = picon
- break
+ return True
+ return True
def remove_picon(target, srv_view, fav_view, picons, settings):
diff --git a/app/ui/picons_manager.glade b/app/ui/picons_manager.glade
index 6fe59376..f41f2d55 100644
--- a/app/ui/picons_manager.glade
+++ b/app/ui/picons_manager.glade
@@ -32,30 +32,7 @@ Author: Dmitriy Yefremov
-
-
-
-
-