Added archive dialoug; go to trash context option
This commit is contained in:
parent
aa74b30c12
commit
a418df2ce7
|
@ -11,7 +11,7 @@ SolarFM is a Gtk+ Python file manager.
|
||||||
<li>Add prompt guards for actions.</li>
|
<li>Add prompt guards for actions.</li>
|
||||||
<li>Add path bar search dropdown.</li>
|
<li>Add path bar search dropdown.</li>
|
||||||
<li>Add "execute" and "execute in terminal" context options.</li>
|
<li>Add "execute" and "execute in terminal" context options.</li>
|
||||||
<li>Add "go to trash", "clear trash", "restore from trash" options.</li>
|
<li>Add "clear trash", "restore from trash" options.</li>
|
||||||
<li>Add drive size free and consumed info to bottom bar.</li>
|
<li>Add drive size free and consumed info to bottom bar.</li>
|
||||||
<li>Add simpleish plugin system to run bash/python scripts.</li>
|
<li>Add simpleish plugin system to run bash/python scripts.</li>
|
||||||
<li>Add DnD context awareness for over folder drop.</li>
|
<li>Add DnD context awareness for over folder drop.</li>
|
||||||
|
|
|
@ -18,8 +18,8 @@ def threaded(fn):
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
class Controller(Controller_Data, ShowHideMixin, KeyboardSignalsMixin, WidgetFileActionMixin, \
|
class Controller(Controller_Data, ShowHideMixin, KeyboardSignalsMixin, \
|
||||||
PaneMixin, WindowMixin):
|
WidgetFileActionMixin, PaneMixin, WindowMixin):
|
||||||
def __init__(self, args, unknownargs, _settings):
|
def __init__(self, args, unknownargs, _settings):
|
||||||
sys.excepthook = self.my_except_hook
|
sys.excepthook = self.my_except_hook
|
||||||
self.settings = _settings
|
self.settings = _settings
|
||||||
|
@ -109,10 +109,18 @@ class Controller(Controller_Data, ShowHideMixin, KeyboardSignalsMixin, WidgetFil
|
||||||
self.to_rename_files = self.selected_files
|
self.to_rename_files = self.selected_files
|
||||||
self.rename_files()
|
self.rename_files()
|
||||||
|
|
||||||
def execute(self, option, start_dir=os.getenv("HOME")):
|
def set_arc_buffer_text(self, widget=None, eve=None):
|
||||||
DEVNULL = open(os.devnull, 'w')
|
id = widget.get_active_id()
|
||||||
command = option.split()
|
self.arc_command_buffer.set_text(self.arc_commands[int(id)])
|
||||||
subprocess.Popen(command, cwd=start_dir, start_new_session=True, stdout=DEVNULL, stderr=DEVNULL)
|
|
||||||
|
def execute(self, _command, start_dir=os.getenv("HOME"), use_os_system=None):
|
||||||
|
if use_os_system:
|
||||||
|
os.system(_command)
|
||||||
|
else:
|
||||||
|
DEVNULL = open(os.devnull, 'w')
|
||||||
|
command = _command.split()
|
||||||
|
subprocess.Popen(command, cwd=start_dir, shell=False, start_new_session=True, stdout=DEVNULL, stderr=DEVNULL)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def do_action_from_menu_controls(self, imagemenuitem, eventbutton):
|
def do_action_from_menu_controls(self, imagemenuitem, eventbutton):
|
||||||
|
@ -138,11 +146,13 @@ class Controller(Controller_Data, ShowHideMixin, KeyboardSignalsMixin, WidgetFil
|
||||||
self.copy_files()
|
self.copy_files()
|
||||||
if action == "paste":
|
if action == "paste":
|
||||||
self.paste_files()
|
self.paste_files()
|
||||||
|
if action == "archive":
|
||||||
|
self.show_archiver_dialogue()
|
||||||
if action == "delete":
|
if action == "delete":
|
||||||
# self.delete_files()
|
# self.delete_files()
|
||||||
self.trash_files()
|
self.trash_files()
|
||||||
if action == "trash":
|
if action == "go_to_trash":
|
||||||
self.trash_files()
|
self.builder.get_object("path_entry").set_text(self.trash_files_path)
|
||||||
|
|
||||||
self.ctrlDown = False
|
self.ctrlDown = False
|
||||||
|
|
||||||
|
|
|
@ -1,35 +1,69 @@
|
||||||
# Python imports
|
# Python imports
|
||||||
|
|
||||||
# Gtk imports
|
# Gtk imports
|
||||||
|
from gi.repository import GLib
|
||||||
|
|
||||||
# Application imports
|
# Application imports
|
||||||
from shellfm import WindowController
|
from shellfm import WindowController
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Controller_Data:
|
class Controller_Data:
|
||||||
def has_method(self, o, name):
|
def has_method(self, o, name):
|
||||||
return callable(getattr(o, name, None))
|
return callable(getattr(o, name, None))
|
||||||
|
|
||||||
def setup_controller_data(self):
|
def setup_controller_data(self):
|
||||||
self.window_controller = WindowController()
|
self.window_controller = WindowController()
|
||||||
self.state = self.window_controller.load_state()
|
self.state = self.window_controller.load_state()
|
||||||
|
|
||||||
self.builder = self.settings.builder
|
self.builder = self.settings.builder
|
||||||
self.logger = self.settings.logger
|
self.logger = self.settings.logger
|
||||||
|
|
||||||
self.window = self.settings.getMainWindow()
|
self.window = self.settings.getMainWindow()
|
||||||
self.window1 = self.builder.get_object("window_1")
|
self.window1 = self.builder.get_object("window_1")
|
||||||
self.window2 = self.builder.get_object("window_2")
|
self.window2 = self.builder.get_object("window_2")
|
||||||
self.window3 = self.builder.get_object("window_3")
|
self.window3 = self.builder.get_object("window_3")
|
||||||
self.window4 = self.builder.get_object("window_4")
|
self.window4 = self.builder.get_object("window_4")
|
||||||
self.message_widget = self.builder.get_object("message_widget")
|
self.message_widget = self.builder.get_object("message_widget")
|
||||||
self.message_view = self.builder.get_object("message_view")
|
self.message_view = self.builder.get_object("message_view")
|
||||||
self.message_buffer = self.builder.get_object("message_buffer")
|
self.message_buffer = self.builder.get_object("message_buffer")
|
||||||
|
self.arc_command_buffer = self.builder.get_object("arc_command_buffer")
|
||||||
|
|
||||||
self.bottom_size_label = self.builder.get_object("bottom_size_label")
|
self.bottom_size_label = self.builder.get_object("bottom_size_label")
|
||||||
self.bottom_file_count_label = self.builder.get_object("bottom_file_count_label")
|
self.bottom_file_count_label = self.builder.get_object("bottom_file_count_label")
|
||||||
self.bottom_path_label = self.builder.get_object("bottom_path_label")
|
self.bottom_path_label = self.builder.get_object("bottom_path_label")
|
||||||
|
|
||||||
|
self.trash_files_path = GLib.get_user_data_dir() + "/Trash/files"
|
||||||
|
self.trash_info_path = GLib.get_user_data_dir() + "/Trash/info"
|
||||||
|
|
||||||
|
|
||||||
|
# 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.notebooks = [self.window1, self.window2, self.window3, self.window4]
|
||||||
self.selected_files = []
|
self.selected_files = []
|
||||||
self.to_rename_files = []
|
self.to_rename_files = []
|
||||||
|
|
|
@ -19,16 +19,33 @@ class ShowHideMixin:
|
||||||
self.hide_about_page()
|
self.hide_about_page()
|
||||||
|
|
||||||
def hide_about_page(self, widget=None, eve=None):
|
def hide_about_page(self, widget=None, eve=None):
|
||||||
about_page = self.builder.get_object("about_page").hide()
|
self.builder.get_object("about_page").hide()
|
||||||
|
|
||||||
|
def show_archiver_dialogue(self, widget=None, eve=None):
|
||||||
|
archiver_dialogue = self.builder.get_object("archiver_dialogue")
|
||||||
|
archiver_dialogue.set_action(Gtk.FileChooserAction.SAVE)
|
||||||
|
archiver_dialogue.set_select_multiple(True)
|
||||||
|
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):
|
def show_appchooser_menu(self, widget=None, eve=None):
|
||||||
appchooser_menu = self.builder.get_object("appchooser_menu")
|
appchooser_menu = self.builder.get_object("appchooser_menu")
|
||||||
appchooser_widget = self.builder.get_object("appchooser_widget")
|
appchooser_widget = self.builder.get_object("appchooser_widget")
|
||||||
|
response = appchooser_menu.run()
|
||||||
|
|
||||||
resp = appchooser_menu.run()
|
if response == Gtk.ResponseType.CANCEL:
|
||||||
if resp == Gtk.ResponseType.CANCEL:
|
|
||||||
self.hide_appchooser_menu()
|
self.hide_appchooser_menu()
|
||||||
if resp == Gtk.ResponseType.OK:
|
if response == Gtk.ResponseType.OK:
|
||||||
self.open_with_files(appchooser_widget)
|
self.open_with_files(appchooser_widget)
|
||||||
self.hide_appchooser_menu()
|
self.hide_appchooser_menu()
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,20 @@ class WidgetFileActionMixin:
|
||||||
self.hide_new_file_menu()
|
self.hide_new_file_menu()
|
||||||
self.to_rename_files.clear()
|
self.to_rename_files.clear()
|
||||||
|
|
||||||
|
def archive_files(self, archiver_dialogue):
|
||||||
|
wid, tid = self.window_controller.get_active_data()
|
||||||
|
iconview = self.builder.get_object(f"{wid}|{tid}|iconview")
|
||||||
|
store = iconview.get_model()
|
||||||
|
paths = self.format_to_uris(store, wid, tid, self.selected_files, True)
|
||||||
|
|
||||||
|
save_target = archiver_dialogue.get_filename();
|
||||||
|
start_itr, end_itr = self.arc_command_buffer.get_bounds()
|
||||||
|
command = self.arc_command_buffer.get_text(start_itr, end_itr, False)
|
||||||
|
|
||||||
|
command = command.replace("%o", save_target)
|
||||||
|
command = command.replace("%N", ' '.join(paths))
|
||||||
|
final_command = f"terminator -e '{command}'"
|
||||||
|
self.execute(final_command, start_dir=None, use_os_system=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -452,6 +452,170 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
|
||||||
<action-widget response="-5">appchooser_select_btn</action-widget>
|
<action-widget response="-5">appchooser_select_btn</action-widget>
|
||||||
</action-widgets>
|
</action-widgets>
|
||||||
</object>
|
</object>
|
||||||
|
<object class="GtkTextBuffer" id="arc_command_buffer">
|
||||||
|
<property name="text" translatable="yes">$(which 7za || echo 7zr) a %o %N</property>
|
||||||
|
</object>
|
||||||
|
<object class="GtkFileChooserDialog" id="archiver_dialogue">
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="modal">True</property>
|
||||||
|
<property name="window-position">center</property>
|
||||||
|
<property name="type-hint">dialog</property>
|
||||||
|
<property name="gravity">center</property>
|
||||||
|
<property name="do-overwrite-confirmation">True</property>
|
||||||
|
<property name="select-multiple">True</property>
|
||||||
|
<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" id="button2">
|
||||||
|
<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>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">True</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="button3">
|
||||||
|
<property name="label">gtk-ok</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
<property name="receives-default">True</property>
|
||||||
|
<property name="use-stock">True</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">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>
|
||||||
|
<property name="homogeneous">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="label" translatable="yes">Compress Commands:</property>
|
||||||
|
<property name="xalign">0.20000000298023224</property>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="gravity" value="west"/>
|
||||||
|
</attributes>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="label" translatable="yes">Archive Format:</property>
|
||||||
|
<property name="xalign">1</property>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="gravity" value="east"/>
|
||||||
|
</attributes>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkComboBoxText">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="active">0</property>
|
||||||
|
<property name="active-id">0</property>
|
||||||
|
<items>
|
||||||
|
<item id="0" translatable="yes">7Zip (*.7z)</item>
|
||||||
|
<item id="1" translatable="yes">Zip (*.zip *.ZIP)</item>
|
||||||
|
<item id="2" translatable="yes">RAR (*.rar *.RAR)</item>
|
||||||
|
<item id="3" translatable="yes">Tar (*.tar)</item>
|
||||||
|
<item id="4" translatable="yes">Tar bzip2 (*.tar.bz2)</item>
|
||||||
|
<item id="5" translatable="yes">Tar Gzip (*.tar.gz *.tgz)</item>
|
||||||
|
<item id="6" translatable="yes">Tar xz (*.tar.xz *.txz)</item>
|
||||||
|
<item id="7" translatable="yes">Gzip (*.gz)</item>
|
||||||
|
<item id="8" translatable="yes">XZ (*.xz)</item>
|
||||||
|
</items>
|
||||||
|
<signal name="changed" handler="set_arc_buffer_text" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">3</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="GtkTextView" id="arc_command">
|
||||||
|
<property name="height-request">72</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
<property name="buffer">arc_command_buffer</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">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<action-widgets>
|
||||||
|
<action-widget response="-6">button2</action-widget>
|
||||||
|
<action-widget response="-5">button3</action-widget>
|
||||||
|
</action-widgets>
|
||||||
|
</object>
|
||||||
|
<object class="GtkImage" id="archive_img">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="stock">gtk-save-as</property>
|
||||||
|
</object>
|
||||||
<object class="GtkImage" id="createImage">
|
<object class="GtkImage" id="createImage">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
|
@ -1645,6 +1809,24 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
|
||||||
<property name="position">4</property>
|
<property name="position">4</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton">
|
||||||
|
<property name="label">gtk-paste</property>
|
||||||
|
<property name="name">paste</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
<property name="receives-default">True</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Paste...</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">5</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton">
|
<object class="GtkButton">
|
||||||
<property name="label" translatable="yes">Go To Trash</property>
|
<property name="label" translatable="yes">Go To Trash</property>
|
||||||
|
@ -1661,25 +1843,25 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
<property name="pack-type">end</property>
|
<property name="pack-type">end</property>
|
||||||
<property name="position">5</property>
|
<property name="position">6</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton">
|
<object class="GtkButton">
|
||||||
<property name="label">gtk-paste</property>
|
<property name="label" translatable="yes">Archive</property>
|
||||||
<property name="name">paste</property>
|
<property name="name">archive</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">True</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="receives-default">True</property>
|
<property name="receives-default">True</property>
|
||||||
<property name="tooltip-text" translatable="yes">Paste...</property>
|
<property name="tooltip-text" translatable="yes">Archive...</property>
|
||||||
<property name="use-stock">True</property>
|
<property name="image">archive_img</property>
|
||||||
<property name="always-show-image">True</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="do_action_from_menu_controls" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
<property name="position">6</property>
|
<property name="position">7</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
Loading…
Reference in New Issue