Externalized archiver to plugin
This commit is contained in:
@@ -128,8 +128,6 @@ class Controller(UIMixin, KeyboardSignalsMixin, IPCSignalsMixin, ExceptionHookMi
|
||||
self.copy_files()
|
||||
if action == "paste":
|
||||
self.paste_files()
|
||||
if action == "archive":
|
||||
self.show_archiver_dialogue()
|
||||
if action == "create":
|
||||
self.create_files()
|
||||
if action in ["save_session", "save_session_as", "load_session"]:
|
||||
|
@@ -64,32 +64,6 @@ class Controller_Data:
|
||||
self.trash_info_path = f"{GLib.get_user_data_dir()}/Trash/info"
|
||||
self.icon_theme = settings.get_icon_theme()
|
||||
|
||||
# In compress commands:
|
||||
# %n: First selected filename/dir to archive
|
||||
# %N: All selected filenames/dirs to archive, or (with %O) a single filename
|
||||
# %o: Resulting single archive file
|
||||
# %O: Resulting archive per source file/directory (use changes %N meaning)
|
||||
#
|
||||
# In extract commands:
|
||||
# %x: Archive file to extract
|
||||
# %g: Unique extraction target filename with optional subfolder
|
||||
# %G: Unique extraction target filename, never with subfolder
|
||||
#
|
||||
# In list commands:
|
||||
# %x: Archive to list
|
||||
#
|
||||
# Plus standard bash variables are accepted.
|
||||
self.arc_commands = [ '$(which 7za || echo 7zr) a %o %N',
|
||||
'zip -r %o %N',
|
||||
'rar a -r %o %N',
|
||||
'tar -cvf %o %N',
|
||||
'tar -cvjf %o %N',
|
||||
'tar -cvzf %o %N',
|
||||
'tar -cvJf %o %N',
|
||||
'gzip -c %N > %O',
|
||||
'xz -cz %N > %O'
|
||||
]
|
||||
|
||||
self.notebooks = [self.window1, self.window2, self.window3, self.window4]
|
||||
self.selected_files = []
|
||||
self.to_copy_files = []
|
||||
|
@@ -51,8 +51,3 @@ class ExceptionHookMixin:
|
||||
f.write(text)
|
||||
|
||||
save_location_prompt.destroy()
|
||||
|
||||
|
||||
def set_arc_buffer_text(self, widget=None, eve=None):
|
||||
sid = widget.get_active_id()
|
||||
self.arc_command_buffer.set_text(self.arc_commands[int(sid)])
|
||||
|
@@ -55,26 +55,6 @@ class ShowHideMixin:
|
||||
self.builder.get_object("about_page").hide()
|
||||
|
||||
|
||||
def show_archiver_dialogue(self, widget=None, eve=None):
|
||||
wid, tid = self.fm_controller.get_active_wid_and_tid()
|
||||
tab = self.get_fm_window(wid).get_tab_by_id(tid)
|
||||
archiver_dialogue = self.builder.get_object("archiver_dialogue")
|
||||
archiver_dialogue.set_action(Gtk.FileChooserAction.SAVE)
|
||||
archiver_dialogue.set_current_folder(tab.get_current_directory())
|
||||
archiver_dialogue.set_current_name("arc.7z")
|
||||
|
||||
response = archiver_dialogue.run()
|
||||
if response == Gtk.ResponseType.OK:
|
||||
self.archive_files(archiver_dialogue)
|
||||
if (response == Gtk.ResponseType.CANCEL) or (response == Gtk.ResponseType.DELETE_EVENT):
|
||||
pass
|
||||
|
||||
archiver_dialogue.hide()
|
||||
|
||||
def hide_archiver_dialogue(self, widget=None, eve=None):
|
||||
self.builder.get_object("archiver_dialogue").hide()
|
||||
|
||||
|
||||
def show_appchooser_menu(self, widget=None, eve=None):
|
||||
appchooser_menu = self.builder.get_object("appchooser_menu")
|
||||
appchooser_widget = self.builder.get_object("appchooser_widget")
|
||||
|
@@ -143,19 +143,6 @@ class WidgetFileActionMixin:
|
||||
command = f"{shlex.quote(path)}" if not in_terminal else f"{state.tab.terminal_app} -e {shlex.quote(path)}"
|
||||
state.tab.execute(shlex.split(command), start_dir=state.tab.get_current_directory())
|
||||
|
||||
def archive_files(self, archiver_dialogue):
|
||||
state = self.get_current_state()
|
||||
paths = [shlex.quote(p) for p in self.format_to_uris(state.store, state.wid, state.tid, self.selected_files, True)]
|
||||
|
||||
save_target = archiver_dialogue.get_filename();
|
||||
sItr, eItr = self.arc_command_buffer.get_bounds()
|
||||
pre_command = self.arc_command_buffer.get_text(sItr, eItr, False)
|
||||
pre_command = pre_command.replace("%o", shlex.quote(save_target))
|
||||
pre_command = pre_command.replace("%N", ' '.join(paths))
|
||||
command = f"{state.tab.terminal_app} -e {shlex.quote(pre_command)}"
|
||||
|
||||
state.tab.execute(shlex.split(command), start_dir=shlex.quote(state.tab.get_current_directory()))
|
||||
|
||||
def rename_files(self):
|
||||
rename_label = self.builder.get_object("file_to_rename_label")
|
||||
rename_input = self.builder.get_object("new_rename_fname")
|
||||
|
Reference in New Issue
Block a user