Added rename functionality

This commit is contained in:
itdominator 2021-11-26 16:50:58 -06:00
parent bff7053139
commit 7119e49ab7
3 changed files with 474 additions and 148 deletions

View File

@ -8,6 +8,7 @@
<property name="window-position">center-on-parent</property>
<property name="icon">pyfm.png</property>
<property name="type-hint">dialog</property>
<property name="gravity">center</property>
<property name="program-name">PyFM</property>
<property name="version">0.0.1</property>
<property name="copyright" translatable="yes">Copyright (C) 2021 GPL2</property>
@ -387,6 +388,303 @@ PyFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspecti
<property name="can-focus">False</property>
<property name="stock">gtk-new</property>
</object>
<object class="GtkDialog" id="new_file_menu">
<property name="can-focus">False</property>
<property name="window-position">center</property>
<property name="type-hint">splashscreen</property>
<property name="gravity">center</property>
<signal name="focus-out-event" handler="hide_new_file_menu" swapped="no"/>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="layout-style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkEntry" id="context_menu_fname">
<property name="width-request">500</property>
<property name="height-request">26</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="primary-icon-stock">gtk-edit</property>
<property name="placeholder-text" translatable="yes">New File/Dir Name...</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="menuButtonBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-bottom">20</property>
<property name="orientation">vertical</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-top">15</property>
<property name="label" translatable="yes">Folder</property>
<attributes>
<attribute name="size" value="12000"/>
</attributes>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-top">15</property>
<property name="label" translatable="yes">File</property>
<attributes>
<attribute name="size" value="12000"/>
</attributes>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="context_menu_type_toggle">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="tooltip-text" translatable="yes">File/Folder</property>
<property name="active">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Create</property>
<property name="name">create</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Create File/Folder...</property>
<property name="image">createImage</property>
<property name="always-show-image">True</property>
<signal name="button-release-event" handler="do_action_from_menu_controls" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkImage" id="rename_img">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="stock">gtk-edit</property>
<property name="icon_size">3</property>
</object>
<object class="GtkImage" id="rename_img2">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="stock">gtk-edit</property>
</object>
<object class="GtkImage" id="skip_img">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="stock">gtk-media-forward</property>
</object>
<object class="GtkDialog" id="edit_file_menu">
<property name="can-focus">False</property>
<property name="modal">True</property>
<property name="window-position">center</property>
<property name="type-hint">splashscreen</property>
<property name="gravity">center</property>
<signal name="focus-out-event" handler="hide_edit_file_menu" swapped="no"/>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="layout-style">end</property>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Skip</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">skip_img</property>
<property name="always-show-image">True</property>
<signal name="button-release-event" handler="hide_edit_file_menu_skip" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="use-stock">True</property>
<signal name="button-release-event" handler="hide_edit_file_menu_cancel" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Rename:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="file_to_rename_label">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="new_rename_fname">
<property name="width-request">500</property>
<property name="height-request">26</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="primary-icon-stock">gtk-edit</property>
<property name="placeholder-text" translatable="yes">To:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Rename</property>
<property name="name">rename</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">rename_img</property>
<property name="always-show-image">True</property>
<signal name="button-release-event" handler="hide_edit_file_menu" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkImage" id="tggl_notebook_1_img">
<property name="visible">True</property>
<property name="can-focus">False</property>
@ -961,11 +1259,6 @@ PyFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspecti
</object>
</child>
</object>
<object class="GtkImage" id="trashImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixbuf">icons/trash.png</property>
</object>
<object class="GtkImage" id="trash_img">
<property name="visible">True</property>
<property name="can-focus">False</property>
@ -973,9 +1266,12 @@ PyFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspecti
</object>
<object class="GtkDialog" id="context_menu">
<property name="can-focus">False</property>
<property name="resizable">False</property>
<property name="window-position">mouse</property>
<property name="type-hint">splashscreen</property>
<property name="gravity">south</property>
<property name="decorated">False</property>
<property name="deletable">False</property>
<property name="gravity">static</property>
<signal name="focus-out-event" handler="hide_context_menu" swapped="no"/>
<child internal-child="vbox">
<object class="GtkBox">
@ -1001,112 +1297,9 @@ PyFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspecti
</child>
<child>
<object class="GtkBox">
<property name="width-request">500</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkEntry" id="context_menu_fname">
<property name="width-request">500</property>
<property name="height-request">26</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="primary-icon-stock">gtk-edit</property>
<property name="placeholder-text" translatable="yes">New File/Dir Name...</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="menuButtonBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-bottom">20</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-top">15</property>
<property name="label" translatable="yes">Folder</property>
<attributes>
<attribute name="size" value="12000"/>
</attributes>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-top">15</property>
<property name="label" translatable="yes">File</property>
<attributes>
<attribute name="size" value="12000"/>
</attributes>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="context_menu_type_toggle">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="tooltip-text" translatable="yes">File/Folder</property>
<property name="active">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Create</property>
<property name="name">create</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Create File/Folder...</property>
<property name="image">createImage</property>
<property name="always-show-image">True</property>
<signal name="button-release-event" handler="do_action_from_menu_controls" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="iconsButtonBox">
<property name="visible">True</property>
@ -1128,19 +1321,18 @@ PyFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspecti
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label">gtk-cut</property>
<property name="name">cut</property>
<property name="label">gtk-open</property>
<property name="name">open</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Cut...</property>
<property name="tooltip-text" translatable="yes">Open...</property>
<property name="use-stock">True</property>
<property name="always-show-image">True</property>
<signal name="button-release-event" handler="do_action_from_menu_controls" swapped="no"/>
</object>
<packing>
@ -1151,15 +1343,15 @@ PyFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspecti
</child>
<child>
<object class="GtkButton">
<property name="label">gtk-copy</property>
<property name="name">copy</property>
<property name="label" translatable="yes">Rename</property>
<property name="name">rename</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Copy...</property>
<property name="use-stock">True</property>
<property name="tooltip-text" translatable="yes">Rename...</property>
<property name="image">rename_img2</property>
<property name="always-show-image">True</property>
<signal name="button-release-event" handler="do_action_from_menu_controls" swapped="no"/>
<signal name="button-release-event" handler="show_edit_file_menu" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
@ -1183,9 +1375,45 @@ PyFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspecti
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack-type">end</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label">gtk-cut</property>
<property name="name">cut</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Cut...</property>
<property name="use-stock">True</property>
<property name="always-show-image">True</property>
<signal name="button-release-event" handler="do_action_from_menu_controls" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label">gtk-copy</property>
<property name="name">copy</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Copy...</property>
<property name="use-stock">True</property>
<property name="always-show-image">True</property>
<signal name="button-release-event" handler="do_action_from_menu_controls" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label">gtk-paste</property>
@ -1201,7 +1429,7 @@ PyFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspecti
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
<property name="position">5</property>
</packing>
</child>
</object>

View File

@ -36,6 +36,7 @@ class Signals(WidgetFileActionMixin, PaneMixin, WindowMixin):
self.window4 = self.builder.get_object("window_4")
self.notebooks = [self.window1, self.window2, self.window3, self.window4]
self.selected_files = []
self.to_rename_files = []
self.to_copy_files = []
self.to_cut_files = []
@ -45,6 +46,8 @@ class Signals(WidgetFileActionMixin, PaneMixin, WindowMixin):
self.is_pane3_hidden = False
self.is_pane4_hidden = False
self.skip_edit = False
self.cancel_edit = False
self.ctrlDown = False
self.shiftDown = False
self.altDown = False
@ -68,9 +71,9 @@ class Signals(WidgetFileActionMixin, PaneMixin, WindowMixin):
def tear_down(self, widget=None, eve=None):
self.window_controller.save_state()
event_system.monitor_events = False
event_system.send_ipc_message("close server")
self.window_controller.save_state()
time.sleep(event_sleep_time)
Gtk.main_quit()
@ -98,14 +101,25 @@ class Signals(WidgetFileActionMixin, PaneMixin, WindowMixin):
view.load_directory()
self.load_store(view, store)
def has_method(self, o, name):
return callable(getattr(o, name, None))
def do_action_from_menu_controls(self, imagemenuitem, eventbutton):
action = imagemenuitem.get_name()
self.ctrlDown = True
self.hide_context_menu()
self.hide_new_file_menu()
self.hide_edit_file_menu()
if action == "create":
self.create_file()
self.hide_new_file_menu()
if action == "open":
self.open_files()
if action == "rename":
self.to_rename_files = self.selected_files
self.rename_files()
if action == "cut":
self.to_copy_files.clear()
self.cut_files()
@ -160,10 +174,14 @@ class Signals(WidgetFileActionMixin, PaneMixin, WindowMixin):
self.builder.get_object("path_entry").grab_focus()
if self.ctrlDown and keyname == "t":
self.builder.get_object("create_tab").released()
if self.ctrlDown and keyname == "o":
self.open_files()
if self.ctrlDown and keyname == "w":
self.keyboard_close_tab()
if self.ctrlDown and keyname == "h":
self.show_hide_hidden_files()
if (self.ctrlDown and keyname == "e"):
self.edit_files()
if self.ctrlDown and keyname == "c":
self.to_cut_files.clear()
self.copy_files()
@ -172,11 +190,14 @@ class Signals(WidgetFileActionMixin, PaneMixin, WindowMixin):
self.cut_files()
if self.ctrlDown and keyname == "v":
self.paste_files()
if self.ctrlDown and keyname == "o":
self.open_files()
if self.ctrlDown and keyname == "n":
self.show_new_file_menu()
if keyname == "delete":
self.trash_files()
if keyname == "f2":
self.to_rename_files = self.selected_files
self.rename_files()
if keyname == "f4":
wid, tid = self.window_controller.get_active_data()
view = self.get_fm_window(wid).get_view_by_id(tid)
@ -190,6 +211,8 @@ class Signals(WidgetFileActionMixin, PaneMixin, WindowMixin):
subprocess.Popen(command, cwd=start_dir, start_new_session=True, stdout=DEVNULL, stderr=DEVNULL)
def show_about_page(self, widget, eve):
about_page = self.builder.get_object("about_page")
response = about_page.run()
@ -199,13 +222,35 @@ class Signals(WidgetFileActionMixin, PaneMixin, WindowMixin):
def hide_about_page(self, widget=None, eve=None):
about_page = self.builder.get_object("about_page").hide()
def show_context_menu(self, widget=None, eve=None):
self.builder.get_object("context_menu").run()
def hide_context_menu(self, widget=None, eve=None):
self.builder.get_object("context_menu").hide()
def show_edit_file_menu(self, widget=None, eve=None):
self.builder.get_object("edit_file_menu").run()
def hide_edit_file_menu(self, widget=None, eve=None):
self.builder.get_object("edit_file_menu").hide()
def show_new_file_menu(self, widget=None, eve=None):
self.builder.get_object("new_file_menu").run()
def hide_new_file_menu(self, widget=None, eve=None):
self.builder.get_object("new_file_menu").hide()
def hide_edit_file_menu_skip(self, widget=None, eve=None):
self.skip_edit = True
self.builder.get_object("edit_file_menu").hide()
def hide_edit_file_menu_cancel(self, widget=None, eve=None):
self.cancel_edit = True
self.builder.get_object("edit_file_menu").hide()
def generate_windows(self, data = None):
if data:

View File

@ -1,4 +1,5 @@
# Python imports
import os
# Lib imports
from gi.repository import GObject, Gio
@ -42,13 +43,17 @@ class WidgetFileActionMixin:
self.load_store(view, store)
tab_label.set_label(view.get_end_of_path())
def create_file(self):
file_name = self.builder.get_object("context_menu_fname").get_text().strip()
type = self.builder.get_object("context_menu_type_toggle").get_state()
wid, tid = self.window_controller.get_active_data()
view = self.get_fm_window(wid).get_view_by_id(tid)
target = f"{view.get_current_directory()}"
def create_file(self):
fname_field = self.builder.get_object("context_menu_fname")
file_name = fname_field.get_text().strip()
type = self.builder.get_object("context_menu_type_toggle").get_state()
wid, tid = self.window_controller.get_active_data()
view = self.get_fm_window(wid).get_view_by_id(tid)
target = f"{view.get_current_directory()}"
if file_name != "":
file_name = "file://" + target + "/" + file_name
@ -57,11 +62,7 @@ class WidgetFileActionMixin:
else: # Create Folder
self.handle_file([file_name], "create_dir")
def update_file(self):
pass
def menu_bar_copy(self, widget, eve):
self.copy_file()
fname_field.set_text("")
def open_files(self):
wid, tid = self.window_controller.get_active_data()
@ -73,12 +74,50 @@ class WidgetFileActionMixin:
for file in uris:
view.open_file_locally(file)
def copy_files(self):
wid, tid = self.window_controller.get_active_data()
iconview = self.builder.get_object(f"{wid}|{tid}|iconview")
store = iconview.get_model()
uris = self.format_to_uris(store, wid, tid, self.selected_files)
self.to_copy_files = uris
def edit_files(self):
pass
def rename_files(self):
rename_label = self.builder.get_object("file_to_rename_label")
rename_input = self.builder.get_object("new_rename_fname")
wid, tid = self.window_controller.get_active_data()
view = self.get_fm_window(wid).get_view_by_id(tid)
iconview = self.builder.get_object(f"{wid}|{tid}|iconview")
store = iconview.get_model()
uris = self.format_to_uris(store, wid, tid, self.to_rename_files, True)
# The rename button hides the rename dialog box which lets this loop continue.
# Weirdly, the show at the end is needed to flow through all the list properly
# than auto chosing the first rename entry you do.
for uri in uris:
entry = uri.split("/")[-1]
rename_label.set_label(entry)
rename_input.set_text(entry)
if self.skip_edit:
self.skip_edit = False
self.show_edit_file_menu()
self.show_edit_file_menu()
if self.skip_edit:
continue
if self.cancel_edit:
break
rname_to = rename_input.get_text().strip()
target = f"file://{view.get_current_directory()}/{rname_to}"
self.handle_file([f"file://{uri}"], "edit", target)
self.show_edit_file_menu()
self.skip_edit = False
self.cancel_edit = False
self.hide_new_file_menu()
self.to_rename_files.clear()
def cut_files(self):
wid, tid = self.window_controller.get_active_data()
@ -87,6 +126,13 @@ class WidgetFileActionMixin:
uris = self.format_to_uris(store, wid, tid, self.selected_files)
self.to_cut_files = uris
def copy_files(self):
wid, tid = self.window_controller.get_active_data()
iconview = self.builder.get_object(f"{wid}|{tid}|iconview")
store = iconview.get_model()
uris = self.format_to_uris(store, wid, tid, self.selected_files)
self.to_copy_files = uris
def paste_files(self):
wid, tid = self.window_controller.get_active_data()
view = self.get_fm_window(wid).get_view_by_id(tid)
@ -98,6 +144,8 @@ class WidgetFileActionMixin:
self.handle_file(self.to_cut_files, "move", target)
def move_file(self, view, files, target):
self.handle_file([files], "move", target)
@ -118,10 +166,12 @@ class WidgetFileActionMixin:
self.handle_file(uris, "trash")
# NOTE: Gio moves files by generating the target file path with name in it
# We can't just give a base target directory and run with it.
# Also, the display name is UTF-8 safe and meant for displaying in GUIs
def handle_file(self, paths, action, base_dir=None):
def handle_file(self, paths, action, _target_path=None):
paths = self.preprocess_paths(paths)
target = None
@ -137,13 +187,16 @@ class WidgetFileActionMixin:
break
if base_dir:
info = f.query_info("standard::display-name", 0, cancellable=None)
_target = f"file://{base_dir}/{info.get_display_name()}"
target = Gio.File.new_for_uri(_target)
if _target_path:
if os.path.isdir(_target_path):
info = f.query_info("standard::display-name", 0, cancellable=None)
_target = f"file://{base_dir}/{info.get_display_name()}"
target = Gio.File.new_for_uri(_target_path)
else:
target = Gio.File.new_for_uri(_target_path)
# See if dragging to same directory then break
if action != "trash" and action != "delete" and \
if action not in ["trash", "delete", "edit"] and \
(f.get_parent().get_path() == target.get_parent().get_path()):
break
@ -153,7 +206,7 @@ class WidgetFileActionMixin:
f.trash(cancellable=None)
if action == "copy":
f.copy(target, flags=Gio.FileCopyFlags.BACKUP, cancellable=None)
if action == "move":
if action == "move" or action == "edit":
f.move(target, flags=Gio.FileCopyFlags.BACKUP, cancellable=None)
except GObject.GError as e:
raise OSError(e.message)