Fixing issues with certain file renames
This commit is contained in:
parent
01a2be4c69
commit
3017fa3308
|
@ -93,7 +93,7 @@ class WidgetFileActionMixin:
|
||||||
def open_with_files(self, appchooser_widget):
|
def open_with_files(self, appchooser_widget):
|
||||||
wid, tid, view, iconview, store = self.get_current_state()
|
wid, tid, view, iconview, store = self.get_current_state()
|
||||||
app_info = appchooser_widget.get_app_info()
|
app_info = appchooser_widget.get_app_info()
|
||||||
uris = self.format_to_uris(store, wid, tid, self.selected_files)
|
uris = self.format_to_uris(store, wid, tid, self.selected_files, True)
|
||||||
|
|
||||||
view.app_chooser_exec(app_info, uris)
|
view.app_chooser_exec(app_info, uris)
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ class WidgetFileActionMixin:
|
||||||
rename_label = self.builder.get_object("file_to_rename_label")
|
rename_label = self.builder.get_object("file_to_rename_label")
|
||||||
rename_input = self.builder.get_object("new_rename_fname")
|
rename_input = self.builder.get_object("new_rename_fname")
|
||||||
wid, tid, view, iconview, store = self.get_current_state()
|
wid, tid, view, iconview, store = self.get_current_state()
|
||||||
uris = self.format_to_uris(store, wid, tid, self.selected_files)
|
uris = self.format_to_uris(store, wid, tid, self.selected_files, True)
|
||||||
|
|
||||||
for uri in uris:
|
for uri in uris:
|
||||||
entry = uri.split("/")[-1]
|
entry = uri.split("/")[-1]
|
||||||
|
@ -140,7 +140,7 @@ class WidgetFileActionMixin:
|
||||||
break
|
break
|
||||||
|
|
||||||
rname_to = rename_input.get_text().strip()
|
rname_to = rename_input.get_text().strip()
|
||||||
target = f"file://{view.get_current_directory()}/{rname_to}"
|
target = f"{view.get_current_directory()}/{rname_to}"
|
||||||
self.handle_files([uri], "rename", target)
|
self.handle_files([uri], "rename", target)
|
||||||
|
|
||||||
|
|
||||||
|
@ -151,18 +151,18 @@ class WidgetFileActionMixin:
|
||||||
|
|
||||||
def cut_files(self):
|
def cut_files(self):
|
||||||
wid, tid, view, iconview, store = self.get_current_state()
|
wid, tid, view, iconview, store = self.get_current_state()
|
||||||
uris = self.format_to_uris(store, wid, tid, self.selected_files)
|
uris = self.format_to_uris(store, wid, tid, self.selected_files, True)
|
||||||
self.to_cut_files = uris
|
self.to_cut_files = uris
|
||||||
|
|
||||||
def copy_files(self):
|
def copy_files(self):
|
||||||
wid, tid, view, iconview, store = self.get_current_state()
|
wid, tid, view, iconview, store = self.get_current_state()
|
||||||
uris = self.format_to_uris(store, wid, tid, self.selected_files)
|
uris = self.format_to_uris(store, wid, tid, self.selected_files, True)
|
||||||
self.to_copy_files = uris
|
self.to_copy_files = uris
|
||||||
|
|
||||||
def paste_files(self):
|
def paste_files(self):
|
||||||
wid, tid = self.window_controller.get_active_data()
|
wid, tid = self.window_controller.get_active_data()
|
||||||
view = self.get_fm_window(wid).get_view_by_id(tid)
|
view = self.get_fm_window(wid).get_view_by_id(tid)
|
||||||
target = f"file://{view.get_current_directory()}"
|
target = f"{view.get_current_directory()}"
|
||||||
|
|
||||||
if len(self.to_copy_files) > 0:
|
if len(self.to_copy_files) > 0:
|
||||||
self.handle_files(self.to_copy_files, "copy", target)
|
self.handle_files(self.to_copy_files, "copy", target)
|
||||||
|
@ -171,12 +171,12 @@ class WidgetFileActionMixin:
|
||||||
|
|
||||||
def delete_files(self):
|
def delete_files(self):
|
||||||
wid, tid, view, iconview, store = self.get_current_state()
|
wid, tid, view, iconview, store = self.get_current_state()
|
||||||
uris = self.format_to_uris(store, wid, tid, self.selected_files)
|
uris = self.format_to_uris(store, wid, tid, self.selected_files, True)
|
||||||
response = None
|
response = None
|
||||||
|
|
||||||
self.warning_alert.format_secondary_text(f"Do you really want to delete the {len(uris)} file(s)?")
|
self.warning_alert.format_secondary_text(f"Do you really want to delete the {len(uris)} file(s)?")
|
||||||
for uri in uris:
|
for uri in uris:
|
||||||
file = Gio.File.new_for_uri(uri)
|
file = Gio.File.new_for_path(uri)
|
||||||
|
|
||||||
if not response:
|
if not response:
|
||||||
response = self.warning_alert.run()
|
response = self.warning_alert.run()
|
||||||
|
@ -194,9 +194,9 @@ class WidgetFileActionMixin:
|
||||||
|
|
||||||
def trash_files(self):
|
def trash_files(self):
|
||||||
wid, tid, view, iconview, store = self.get_current_state()
|
wid, tid, view, iconview, store = self.get_current_state()
|
||||||
uris = self.format_to_uris(store, wid, tid, self.selected_files)
|
uris = self.format_to_uris(store, wid, tid, self.selected_files, True)
|
||||||
for uri in uris:
|
for uri in uris:
|
||||||
file = Gio.File.new_for_uri(uri)
|
file = Gio.File.new_for_path(uri)
|
||||||
file.trash(cancellable=None)
|
file.trash(cancellable=None)
|
||||||
|
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ class WidgetFileActionMixin:
|
||||||
target = f"{view.get_current_directory()}"
|
target = f"{view.get_current_directory()}"
|
||||||
|
|
||||||
if file_name:
|
if file_name:
|
||||||
path = f"file://{target}/{file_name}"
|
path = f"{target}/{file_name}"
|
||||||
|
|
||||||
if type == True: # Create File
|
if type == True: # Create File
|
||||||
self.handle_files([path], "create_file")
|
self.handle_files([path], "create_file")
|
||||||
|
@ -236,17 +236,17 @@ class WidgetFileActionMixin:
|
||||||
|
|
||||||
for path in paths:
|
for path in paths:
|
||||||
try:
|
try:
|
||||||
file = Gio.File.new_for_uri(path)
|
file = Gio.File.new_for_path(path)
|
||||||
|
|
||||||
if _target_path:
|
if _target_path:
|
||||||
if os.path.isdir(_target_path.split("file://")[1]):
|
if os.path.isdir(_target_path):
|
||||||
info = file.query_info("standard::display-name", 0, cancellable=None)
|
info = file.query_info("standard::display-name", 0, cancellable=None)
|
||||||
_target = f"{_target_path}/{info.get_display_name()}"
|
_target = f"{_target_path}/{info.get_display_name()}"
|
||||||
_file = Gio.File.new_for_uri(_target)
|
_file = Gio.File.new_for_path(_target)
|
||||||
else:
|
else:
|
||||||
_file = Gio.File.new_for_uri(_target_path)
|
_file = Gio.File.new_for_path(_target_path)
|
||||||
else:
|
else:
|
||||||
_file = Gio.File.new_for_uri(path)
|
_file = Gio.File.new_for_path(path)
|
||||||
|
|
||||||
|
|
||||||
if _file.query_exists():
|
if _file.query_exists():
|
||||||
|
|
|
@ -129,8 +129,8 @@ class WidgetMixin:
|
||||||
grid.set_spacing(12)
|
grid.set_spacing(12)
|
||||||
grid.set_column_spacing(18)
|
grid.set_column_spacing(18)
|
||||||
|
|
||||||
grid.connect("button_release_event", self.grid_icon_single_left_click)
|
grid.connect("button_release_event", self.grid_icon_single_click)
|
||||||
grid.connect("item-activated", self.grid_icon_double_left_click)
|
grid.connect("item-activated", self.grid_icon_double_click)
|
||||||
grid.connect("selection-changed", self.grid_set_selected_items)
|
grid.connect("selection-changed", self.grid_set_selected_items)
|
||||||
grid.connect("drag-data-get", self.grid_on_drag_set)
|
grid.connect("drag-data-get", self.grid_on_drag_set)
|
||||||
grid.connect("drag-data-received", self.grid_on_drag_data_received)
|
grid.connect("drag-data-received", self.grid_on_drag_data_received)
|
||||||
|
@ -178,8 +178,8 @@ class WidgetMixin:
|
||||||
grid.set_headers_visible(False)
|
grid.set_headers_visible(False)
|
||||||
grid.set_enable_tree_lines(False)
|
grid.set_enable_tree_lines(False)
|
||||||
|
|
||||||
grid.connect("button_release_event", self.grid_icon_single_left_click)
|
grid.connect("button_release_event", self.grid_icon_single_click)
|
||||||
grid.connect("row-activated", self.grid_icon_double_left_click)
|
grid.connect("row-activated", self.grid_icon_double_click)
|
||||||
grid.connect("drag-data-get", self.grid_on_drag_set)
|
grid.connect("drag-data-get", self.grid_on_drag_set)
|
||||||
grid.connect("drag-data-received", self.grid_on_drag_data_received)
|
grid.connect("drag-data-received", self.grid_on_drag_data_received)
|
||||||
grid.connect("drag-motion", self.grid_on_drag_motion)
|
grid.connect("drag-motion", self.grid_on_drag_motion)
|
||||||
|
|
|
@ -90,13 +90,13 @@ class WindowMixin(TabMixin):
|
||||||
self.bottom_size_label.set_label(f"{formatted_mount_free} free / {formatted_mount_size}")
|
self.bottom_size_label.set_label(f"{formatted_mount_free} free / {formatted_mount_size}")
|
||||||
self.bottom_path_label.set_label(view.get_current_directory())
|
self.bottom_path_label.set_label(view.get_current_directory())
|
||||||
if len(selected_files) > 0:
|
if len(selected_files) > 0:
|
||||||
uris = self.format_to_uris(store, _wid, _tid, selected_files)
|
uris = self.format_to_uris(store, _wid, _tid, selected_files, True)
|
||||||
combined_size = 0
|
combined_size = 0
|
||||||
for uri in uris:
|
for uri in uris:
|
||||||
file = Gio.File.new_for_uri(uri).query_info(attributes="standard::size",
|
file_info = Gio.File.new_for_path(uri).query_info(attributes="standard::size",
|
||||||
flags=Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,
|
flags=Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,
|
||||||
cancellable=None)
|
cancellable=None)
|
||||||
file_size = file.get_size()
|
file_size = file_info.get_size()
|
||||||
combined_size += file_size
|
combined_size += file_size
|
||||||
|
|
||||||
formatted_size = self.sizeof_fmt(combined_size)
|
formatted_size = self.sizeof_fmt(combined_size)
|
||||||
|
@ -144,7 +144,7 @@ class WindowMixin(TabMixin):
|
||||||
def grid_set_selected_items(self, iconview):
|
def grid_set_selected_items(self, iconview):
|
||||||
self.selected_files = iconview.get_selected_items()
|
self.selected_files = iconview.get_selected_items()
|
||||||
|
|
||||||
def grid_icon_single_left_click(self, iconview, eve):
|
def grid_icon_single_click(self, iconview, eve):
|
||||||
try:
|
try:
|
||||||
self.path_menu.popdown()
|
self.path_menu.popdown()
|
||||||
wid, tid = iconview.get_name().split("|")
|
wid, tid = iconview.get_name().split("|")
|
||||||
|
@ -155,7 +155,7 @@ class WindowMixin(TabMixin):
|
||||||
|
|
||||||
if eve.type == Gdk.EventType.BUTTON_RELEASE and eve.button == 1: # l-click
|
if eve.type == Gdk.EventType.BUTTON_RELEASE and eve.button == 1: # l-click
|
||||||
if self.single_click_open: # FIXME: need to find a way to pass the model index
|
if self.single_click_open: # FIXME: need to find a way to pass the model index
|
||||||
self.grid_icon_double_left_click(iconview)
|
self.grid_icon_double_click(iconview)
|
||||||
elif eve.type == Gdk.EventType.BUTTON_RELEASE and eve.button == 3: # r-click
|
elif eve.type == Gdk.EventType.BUTTON_RELEASE and eve.button == 3: # r-click
|
||||||
self.show_context_menu()
|
self.show_context_menu()
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ class WindowMixin(TabMixin):
|
||||||
print(repr(e))
|
print(repr(e))
|
||||||
self.display_message(self.error, f"{repr(e)}")
|
self.display_message(self.error, f"{repr(e)}")
|
||||||
|
|
||||||
def grid_icon_double_left_click(self, iconview, item, data=None):
|
def grid_icon_double_click(self, iconview, item, data=None):
|
||||||
try:
|
try:
|
||||||
if self.ctrlDown and self.shiftDown:
|
if self.ctrlDown and self.shiftDown:
|
||||||
self.execute_files(in_terminal=True)
|
self.execute_files(in_terminal=True)
|
||||||
|
|
Loading…
Reference in New Issue