reverts and refactors

This commit is contained in:
itdominator 2022-01-24 10:24:55 -06:00
parent 2c258d470b
commit f2314500b7
8 changed files with 39 additions and 29 deletions

View File

@ -18,6 +18,11 @@ class Builtins(IPCServerMixin):
self._gui_events = []
self._fm_events = []
self.is_ipc_alive = False
self.ipc_authkey = b'solarfm-ipc'
self.ipc_address = '127.0.0.1'
self.ipc_port = 4848
self.ipc_timeout = 15.0
# Makeshift fake "events" type system FIFO
def _pop_gui_event(self):

View File

@ -24,14 +24,14 @@ class Path:
self.load_directory()
def pop_from_path(self):
if self.path:
if len(self.path) > 1:
self.path.pop()
if not self.go_past_home:
if self.get_home() not in self.get_path():
self.set_to_home()
self.load_directory()
self.load_directory()
def set_path(self, path):
if path == self.get_path():

View File

@ -1,5 +1,5 @@
# Python imports
import sys, traceback, threading, signal, inspect, os, time
import sys, traceback, threading, inspect, os, time
# Lib imports
import gi
@ -23,15 +23,10 @@ class Controller(WidgetFileActionMixin, PaneMixin, WindowMixin, ShowHideMixin, \
KeyboardSignalsMixin, Controller_Data):
def __init__(self, args, unknownargs, _settings):
# sys.excepthook = self.custom_except_hook
self.settings = _settings
self.setup_controller_data()
self.setup_controller_data(_settings)
self.window.show()
self.generate_windows(self.state)
self.window.connect("delete-event", self.tear_down)
GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT, self.tear_down)
if not trace_debug:
self.gui_event_observer()

View File

@ -1,4 +1,5 @@
# Python imports
import signal
# Lib imports
from gi.repository import GLib
@ -14,16 +15,17 @@ class Controller_Data:
def has_method(self, o, name):
return callable(getattr(o, name, None))
def setup_controller_data(self):
self.window_controller = WindowController()
def setup_controller_data(self, _settings):
self.trashman = XDGTrash()
self.window_controller = WindowController()
self.state = self.window_controller.load_state()
self.trashman.regenerate()
self.state = self.window_controller.load_state()
self.builder = self.settings.builder
self.logger = self.settings.logger
self.settings = _settings
self.builder = self.settings.get_builder()
self.logger = self.settings.get_logger()
self.window = self.settings.getMainWindow()
self.window = self.settings.get_main_window()
self.window1 = self.builder.get_object("window_1")
self.window2 = self.builder.get_object("window_2")
self.window3 = self.builder.get_object("window_3")
@ -99,3 +101,7 @@ class Controller_Data:
self.success = "#88cc27"
self.warning = "#ffa800"
self.error = "#ff0000"
self.window.connect("delete-event", self.tear_down)
GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT, self.tear_down)

View File

@ -19,7 +19,7 @@ class IPCServerMixin:
@threaded
def create_ipc_server(self):
listener = Listener(('127.0.0.1', 4848), authkey=b'solarfm-ipc')
listener = Listener((self.ipc_address, self.ipc_port), authkey=self.ipc_authkey)
self.is_ipc_alive = True
while True:
conn = listener.accept()
@ -49,7 +49,7 @@ class IPCServerMixin:
# NOTE: Not perfect but insures we don't lockup the connection for too long.
end_time = time.time()
if (end - start) > 15.0:
if (end - start) > self.ipc_timeout:
conn.close()
listener.close()
@ -57,7 +57,7 @@ class IPCServerMixin:
def send_ipc_message(self, message="Empty Data..."):
try:
conn = Client(('127.0.0.1', 4848), authkey=b'solarfm-ipc')
conn = Client((self.ipc_address, self.ipc_port), authkey=self.ipc_authkey)
conn.send(message)
conn.send('close connection')
except Exception as e:

View File

@ -232,10 +232,7 @@ class WidgetFileActionMixin:
target = f"{view.get_current_directory()}"
if file_name:
if len(target) == 1:
path = f"{target}{file_name}"
else:
path = f"{target}/{file_name}"
path = f"{target}/{file_name}"
if type == True: # Create File
self.handle_files([path], "create_file")

View File

@ -82,7 +82,7 @@ class WindowMixin(TabMixin):
_wid, _tid, _view, iconview, store = self.get_current_state()
selected_files = iconview.get_selected_items()
current_directory = view.get_current_directory()
path_file = Gio.File.new_for_path( current_directory)
path_file = Gio.File.new_for_path(current_directory)
mount_file = path_file.query_filesystem_info(attributes="filesystem::*", cancellable=None)
formatted_mount_free = self.sizeof_fmt( int(mount_file.get_attribute_as_string("filesystem::free")) )
formatted_mount_size = self.sizeof_fmt( int(mount_file.get_attribute_as_string("filesystem::size")) )
@ -101,11 +101,16 @@ class WindowMixin(TabMixin):
uris = self.format_to_uris(store, _wid, _tid, selected_files, True)
combined_size = 0
for uri in uris:
file_info = Gio.File.new_for_path(uri).query_info(attributes="standard::size",
flags=Gio.FileQueryInfoFlags.NONE,
cancellable=None)
file_size = file_info.get_size()
combined_size += file_size
try:
file_info = Gio.File.new_for_path(uri).query_info(attributes="standard::size",
flags=Gio.FileQueryInfoFlags.NONE,
cancellable=None)
file_size = file_info.get_size()
combined_size += file_size
except Exception as e:
if debug:
print(repr(e))
formatted_size = self.sizeof_fmt(combined_size)
if view.hide_hidden:

View File

@ -72,7 +72,9 @@ class Settings:
cr.paint()
cr.set_operator(cairo.OPERATOR_OVER)
def getMainWindow(self): return self.main_window
def get_builder(self): return self.builder
def get_logger(self): return self.logger
def get_main_window(self): return self.main_window
def getMonitorData(self):