Added delete guard; reordered glade import/setup
This commit is contained in:
parent
f2dfd94a5f
commit
844121a5c6
@ -50,6 +50,7 @@ class Controller(Controller_Data, ShowHideMixin, KeyboardSignalsMixin, \
|
|||||||
time.sleep(event_sleep_time)
|
time.sleep(event_sleep_time)
|
||||||
Gtk.main_quit()
|
Gtk.main_quit()
|
||||||
|
|
||||||
|
|
||||||
@threaded
|
@threaded
|
||||||
def gui_event_observer(self):
|
def gui_event_observer(self):
|
||||||
while event_system.monitor_events:
|
while event_system.monitor_events:
|
||||||
@ -103,8 +104,6 @@ class Controller(Controller_Data, ShowHideMixin, KeyboardSignalsMixin, \
|
|||||||
save_location_prompt.destroy()
|
save_location_prompt.destroy()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def do_edit_files(self, widget=None, eve=None):
|
def do_edit_files(self, widget=None, eve=None):
|
||||||
self.to_rename_files = self.selected_files
|
self.to_rename_files = self.selected_files
|
||||||
self.rename_files()
|
self.rename_files()
|
||||||
@ -113,6 +112,7 @@ class Controller(Controller_Data, ShowHideMixin, KeyboardSignalsMixin, \
|
|||||||
id = widget.get_active_id()
|
id = widget.get_active_id()
|
||||||
self.arc_command_buffer.set_text(self.arc_commands[int(id)])
|
self.arc_command_buffer.set_text(self.arc_commands[int(id)])
|
||||||
|
|
||||||
|
|
||||||
def execute(self, _command, start_dir=os.getenv("HOME"), use_os_system=None):
|
def execute(self, _command, start_dir=os.getenv("HOME"), use_os_system=None):
|
||||||
if use_os_system:
|
if use_os_system:
|
||||||
os.system(_command)
|
os.system(_command)
|
||||||
@ -121,8 +121,6 @@ class Controller(Controller_Data, ShowHideMixin, KeyboardSignalsMixin, \
|
|||||||
command = _command.split()
|
command = _command.split()
|
||||||
subprocess.Popen(command, cwd=start_dir, shell=False, start_new_session=True, stdout=DEVNULL, stderr=DEVNULL)
|
subprocess.Popen(command, cwd=start_dir, shell=False, start_new_session=True, stdout=DEVNULL, stderr=DEVNULL)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def do_action_from_menu_controls(self, widget, eventbutton):
|
def do_action_from_menu_controls(self, widget, eventbutton):
|
||||||
action = widget.get_name()
|
action = widget.get_name()
|
||||||
self.ctrlDown = True
|
self.ctrlDown = True
|
||||||
@ -130,7 +128,6 @@ class Controller(Controller_Data, ShowHideMixin, KeyboardSignalsMixin, \
|
|||||||
self.hide_new_file_menu()
|
self.hide_new_file_menu()
|
||||||
self.hide_edit_file_menu()
|
self.hide_edit_file_menu()
|
||||||
|
|
||||||
|
|
||||||
if action == "execute":
|
if action == "execute":
|
||||||
self.execute_files()
|
self.execute_files()
|
||||||
if action == "execute_in_terminal":
|
if action == "execute_in_terminal":
|
||||||
@ -154,7 +151,8 @@ class Controller(Controller_Data, ShowHideMixin, KeyboardSignalsMixin, \
|
|||||||
if action == "archive":
|
if action == "archive":
|
||||||
self.show_archiver_dialogue()
|
self.show_archiver_dialogue()
|
||||||
if action == "delete":
|
if action == "delete":
|
||||||
# self.delete_files()
|
self.delete_files()
|
||||||
|
if action == "trash":
|
||||||
self.trash_files()
|
self.trash_files()
|
||||||
if action == "go_to_trash":
|
if action == "go_to_trash":
|
||||||
self.builder.get_object("path_entry").set_text(self.trash_files_path)
|
self.builder.get_object("path_entry").set_text(self.trash_files_path)
|
||||||
@ -162,8 +160,6 @@ class Controller(Controller_Data, ShowHideMixin, KeyboardSignalsMixin, \
|
|||||||
self.ctrlDown = False
|
self.ctrlDown = False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def generate_windows(self, data = None):
|
def generate_windows(self, data = None):
|
||||||
if data:
|
if data:
|
||||||
for j, value in enumerate(data):
|
for j, value in enumerate(data):
|
||||||
|
@ -30,6 +30,7 @@ class Controller_Data:
|
|||||||
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.arc_command_buffer = self.builder.get_object("arc_command_buffer")
|
||||||
|
|
||||||
|
self.warning_alert = self.builder.get_object("warning_alert")
|
||||||
self.exists_alert = self.builder.get_object("exists_alert")
|
self.exists_alert = self.builder.get_object("exists_alert")
|
||||||
self.exists_from_label = self.builder.get_object("exists_from_label")
|
self.exists_from_label = self.builder.get_object("exists_from_label")
|
||||||
self.exists_to_label = self.builder.get_object("exists_to_label")
|
self.exists_to_label = self.builder.get_object("exists_to_label")
|
||||||
|
@ -4,8 +4,7 @@
|
|||||||
import gi
|
import gi
|
||||||
gi.require_version('Gtk', '3.0')
|
gi.require_version('Gtk', '3.0')
|
||||||
gi.require_version('Gdk', '3.0')
|
gi.require_version('Gdk', '3.0')
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk, Gdk
|
||||||
from gi.repository import Gdk
|
|
||||||
|
|
||||||
# Application imports
|
# Application imports
|
||||||
|
|
||||||
@ -67,8 +66,10 @@ class KeyboardSignalsMixin:
|
|||||||
if self.ctrlDown and keyname == "n":
|
if self.ctrlDown and keyname == "n":
|
||||||
self.show_new_file_menu()
|
self.show_new_file_menu()
|
||||||
|
|
||||||
if keyname == "delete":
|
if self.ctrlDown and self.shiftDown and keyname == "t":
|
||||||
self.trash_files()
|
self.trash_files()
|
||||||
|
if keyname == "delete":
|
||||||
|
self.delete_files()
|
||||||
if keyname == "f2":
|
if keyname == "f2":
|
||||||
self.do_edit_files()
|
self.do_edit_files()
|
||||||
if keyname == "f4":
|
if keyname == "f4":
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
# Gtk imports
|
# Gtk imports
|
||||||
import gi
|
import gi
|
||||||
gi.require_version('Gtk', '3.0')
|
gi.require_version('Gtk', '3.0')
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk, Gio
|
||||||
from gi.repository import Gio
|
|
||||||
|
|
||||||
# Application imports
|
# Application imports
|
||||||
|
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
# Lib imports
|
# Lib imports
|
||||||
from gi.repository import GObject, Gio
|
import gi
|
||||||
|
gi.require_version('Gtk', '3.0')
|
||||||
|
from gi.repository import Gtk, GObject, Gio
|
||||||
|
|
||||||
# Application imports
|
# Application imports
|
||||||
|
|
||||||
@ -89,6 +91,7 @@ class WidgetFileActionMixin:
|
|||||||
command = f"sh -c '{path}'" if not in_terminal else f"{view.terminal_app} -e '{path}'"
|
command = f"sh -c '{path}'" if not in_terminal else f"{view.terminal_app} -e '{path}'"
|
||||||
self.execute(command, current_dir)
|
self.execute(command, current_dir)
|
||||||
|
|
||||||
|
|
||||||
def open_files(self):
|
def open_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, True)
|
uris = self.format_to_uris(store, wid, tid, self.selected_files, True)
|
||||||
@ -96,7 +99,6 @@ class WidgetFileActionMixin:
|
|||||||
for file in uris:
|
for file in uris:
|
||||||
view.open_file_locally(file)
|
view.open_file_locally(file)
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
uris = self.format_to_uris(store, wid, tid, self.selected_files)
|
uris = self.format_to_uris(store, wid, tid, self.selected_files)
|
||||||
@ -197,10 +199,13 @@ class WidgetFileActionMixin:
|
|||||||
|
|
||||||
# NOTE: While not fully race condition proof, we happy path it first
|
# NOTE: While not fully race condition proof, we happy path it first
|
||||||
# and then handle anything after as a conflict for renaming before
|
# and then handle anything after as a conflict for renaming before
|
||||||
# copy, move, or edit.
|
# copy, move, or edit. This is literally the oppopsite of what Gtk says to do.
|
||||||
|
# But, they can't even delete directories properly. So... f**k them.
|
||||||
def handle_file(self, paths, action, _target_path=None):
|
def handle_file(self, paths, action, _target_path=None):
|
||||||
paths = self.preprocess_paths(paths)
|
paths = self.preprocess_paths(paths)
|
||||||
target = None
|
target = None
|
||||||
|
response = None
|
||||||
|
self.warning_alert.format_secondary_text(f"Do you really want to {action} the {len(paths)} file(s)?")
|
||||||
|
|
||||||
for path in paths:
|
for path in paths:
|
||||||
try:
|
try:
|
||||||
@ -209,17 +214,6 @@ class WidgetFileActionMixin:
|
|||||||
if action == "trash":
|
if action == "trash":
|
||||||
file.trash(cancellable=None)
|
file.trash(cancellable=None)
|
||||||
|
|
||||||
if action == "delete":
|
|
||||||
# TODO: Add proper confirmation prompt befor doing either
|
|
||||||
type = file.query_file_type(flags=Gio.FileQueryInfoFlags.NONE)
|
|
||||||
|
|
||||||
if type == Gio.FileType.DIRECTORY:
|
|
||||||
wid, tid = self.window_controller.get_active_data()
|
|
||||||
view = self.get_fm_window(wid).get_view_by_id(tid)
|
|
||||||
view.delete_file( file.get_path() )
|
|
||||||
else:
|
|
||||||
file.delete(cancellable=None)
|
|
||||||
|
|
||||||
if (action == "create_file" or action == "create_dir") and not file.query_exists():
|
if (action == "create_file" or action == "create_dir") and not file.query_exists():
|
||||||
if action == "create_file":
|
if action == "create_file":
|
||||||
file.create(flags=Gio.FileCreateFlags.NONE, cancellable=None)
|
file.create(flags=Gio.FileCreateFlags.NONE, cancellable=None)
|
||||||
@ -261,14 +255,28 @@ class WidgetFileActionMixin:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# NOTE: Past here, we need to handle detected conflicts.
|
# NOTE: Past here, we need to handle detected conflicts.
|
||||||
# Maybe create a collection of file and target pares
|
# Maybe create a collection of file and target pares
|
||||||
# that then get passed to a handler who calls show_exists_page?
|
# that then get passed to a handler who calls show_exists_page?
|
||||||
# type = None
|
|
||||||
# gio_flag = None
|
if action == "delete":
|
||||||
# self.exists_alert.hide()
|
if not response:
|
||||||
# if not state:
|
response = self.warning_alert.run()
|
||||||
# raise GObject.GError("Failed to perform requested dir/file action!")
|
self.warning_alert.hide()
|
||||||
|
if response == Gtk.ResponseType.YES:
|
||||||
|
type = file.query_file_type(flags=Gio.FileQueryInfoFlags.NONE)
|
||||||
|
|
||||||
|
if type == Gio.FileType.DIRECTORY:
|
||||||
|
wid, tid = self.window_controller.get_active_data()
|
||||||
|
view = self.get_fm_window(wid).get_view_by_id(tid)
|
||||||
|
view.delete_file( file.get_path() )
|
||||||
|
else:
|
||||||
|
file.delete(cancellable=None)
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
except GObject.GError as e:
|
except GObject.GError as e:
|
||||||
raise OSError(e)
|
raise OSError(e)
|
||||||
|
|
||||||
|
@ -46,14 +46,9 @@ class WidgetMixin:
|
|||||||
|
|
||||||
# NOTE: Might need to keep an eye on this throwing invalid iters when too
|
# NOTE: Might need to keep an eye on this throwing invalid iters when too
|
||||||
# many updates are happening to a folder. Example: /tmp
|
# many updates are happening to a folder. Example: /tmp
|
||||||
# Will sink for now. (Aka ignore forever)
|
|
||||||
def update_store(self, item):
|
def update_store(self, item):
|
||||||
i, store, icon, view, fpath = item
|
i, store, icon, view, fpath = item
|
||||||
itr = None
|
itr = store.get_iter(i)
|
||||||
try:
|
|
||||||
itr = store.get_iter(i)
|
|
||||||
except Exception as e:
|
|
||||||
return
|
|
||||||
|
|
||||||
if not icon:
|
if not icon:
|
||||||
icon = self.get_system_thumbnail(fpath, view.SYS_ICON_WH[0])
|
icon = self.get_system_thumbnail(fpath, view.SYS_ICON_WH[0])
|
||||||
|
@ -93,6 +93,13 @@ class WindowMixin(TabMixin):
|
|||||||
|
|
||||||
def grid_icon_double_left_click(self, iconview, item, data=None):
|
def grid_icon_double_left_click(self, iconview, item, data=None):
|
||||||
try:
|
try:
|
||||||
|
if self.ctrlDown and self.shiftDown:
|
||||||
|
self.execute_files(in_terminal=True)
|
||||||
|
return
|
||||||
|
elif self.ctrlDown:
|
||||||
|
self.execute_files()
|
||||||
|
return
|
||||||
|
|
||||||
wid, tid = self.window_controller.get_active_data()
|
wid, tid = self.window_controller.get_active_data()
|
||||||
notebook = self.builder.get_object(f"window_{wid}")
|
notebook = self.builder.get_object(f"window_{wid}")
|
||||||
path_entry = self.builder.get_object(f"path_entry")
|
path_entry = self.builder.get_object(f"path_entry")
|
||||||
|
@ -21,14 +21,14 @@ class Settings:
|
|||||||
self.USER_HOME = path.expanduser('~')
|
self.USER_HOME = path.expanduser('~')
|
||||||
self.CONFIG_PATH = self.USER_HOME + "/.config/solarfm"
|
self.CONFIG_PATH = self.USER_HOME + "/.config/solarfm"
|
||||||
|
|
||||||
self.windows_glade = self.CONFIG_PATH + "/Main_Window.glade"
|
|
||||||
self.popups_glade = self.CONFIG_PATH + "/Menu_Popups.glade"
|
|
||||||
self.cssFile = self.CONFIG_PATH + '/stylesheet.css'
|
self.cssFile = self.CONFIG_PATH + '/stylesheet.css'
|
||||||
|
self.popups_glade = self.CONFIG_PATH + "/Menu_Popups.glade"
|
||||||
|
self.windows_glade = self.CONFIG_PATH + "/Main_Window.glade"
|
||||||
|
|
||||||
self.logger = Logger().get_logger()
|
self.logger = Logger().get_logger()
|
||||||
self.builder = gtk.Builder()
|
self.builder = gtk.Builder()
|
||||||
self.builder.add_from_file(self.windows_glade)
|
|
||||||
self.builder.add_from_file(self.popups_glade)
|
self.builder.add_from_file(self.popups_glade)
|
||||||
|
self.builder.add_from_file(self.windows_glade)
|
||||||
|
|
||||||
self.DEFAULT_ICONS = self.CONFIG_PATH + "/icons"
|
self.DEFAULT_ICONS = self.CONFIG_PATH + "/icons"
|
||||||
self.window_icon = self.DEFAULT_ICONS + "/solarfm.png"
|
self.window_icon = self.DEFAULT_ICONS + "/solarfm.png"
|
||||||
|
Loading…
Reference in New Issue
Block a user