reverts and refactors
This commit is contained in:
parent
2c258d470b
commit
f2314500b7
|
@ -18,6 +18,11 @@ class Builtins(IPCServerMixin):
|
||||||
self._gui_events = []
|
self._gui_events = []
|
||||||
self._fm_events = []
|
self._fm_events = []
|
||||||
self.is_ipc_alive = False
|
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
|
# Makeshift fake "events" type system FIFO
|
||||||
def _pop_gui_event(self):
|
def _pop_gui_event(self):
|
||||||
|
|
|
@ -24,7 +24,7 @@ class Path:
|
||||||
self.load_directory()
|
self.load_directory()
|
||||||
|
|
||||||
def pop_from_path(self):
|
def pop_from_path(self):
|
||||||
if self.path:
|
if len(self.path) > 1:
|
||||||
self.path.pop()
|
self.path.pop()
|
||||||
|
|
||||||
if not self.go_past_home:
|
if not self.go_past_home:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Python imports
|
# Python imports
|
||||||
import sys, traceback, threading, signal, inspect, os, time
|
import sys, traceback, threading, inspect, os, time
|
||||||
|
|
||||||
# Lib imports
|
# Lib imports
|
||||||
import gi
|
import gi
|
||||||
|
@ -23,15 +23,10 @@ class Controller(WidgetFileActionMixin, PaneMixin, WindowMixin, ShowHideMixin, \
|
||||||
KeyboardSignalsMixin, Controller_Data):
|
KeyboardSignalsMixin, Controller_Data):
|
||||||
def __init__(self, args, unknownargs, _settings):
|
def __init__(self, args, unknownargs, _settings):
|
||||||
# sys.excepthook = self.custom_except_hook
|
# sys.excepthook = self.custom_except_hook
|
||||||
self.settings = _settings
|
self.setup_controller_data(_settings)
|
||||||
self.setup_controller_data()
|
|
||||||
|
|
||||||
self.window.show()
|
self.window.show()
|
||||||
self.generate_windows(self.state)
|
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:
|
if not trace_debug:
|
||||||
self.gui_event_observer()
|
self.gui_event_observer()
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# Python imports
|
# Python imports
|
||||||
|
import signal
|
||||||
|
|
||||||
# Lib imports
|
# Lib imports
|
||||||
from gi.repository import GLib
|
from gi.repository import GLib
|
||||||
|
@ -14,16 +15,17 @@ 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, _settings):
|
||||||
self.window_controller = WindowController()
|
|
||||||
self.trashman = XDGTrash()
|
self.trashman = XDGTrash()
|
||||||
|
self.window_controller = WindowController()
|
||||||
|
self.state = self.window_controller.load_state()
|
||||||
self.trashman.regenerate()
|
self.trashman.regenerate()
|
||||||
|
|
||||||
self.state = self.window_controller.load_state()
|
self.settings = _settings
|
||||||
self.builder = self.settings.builder
|
self.builder = self.settings.get_builder()
|
||||||
self.logger = self.settings.logger
|
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.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")
|
||||||
|
@ -99,3 +101,7 @@ class Controller_Data:
|
||||||
self.success = "#88cc27"
|
self.success = "#88cc27"
|
||||||
self.warning = "#ffa800"
|
self.warning = "#ffa800"
|
||||||
self.error = "#ff0000"
|
self.error = "#ff0000"
|
||||||
|
|
||||||
|
|
||||||
|
self.window.connect("delete-event", self.tear_down)
|
||||||
|
GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT, self.tear_down)
|
||||||
|
|
|
@ -19,7 +19,7 @@ class IPCServerMixin:
|
||||||
|
|
||||||
@threaded
|
@threaded
|
||||||
def create_ipc_server(self):
|
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
|
self.is_ipc_alive = True
|
||||||
while True:
|
while True:
|
||||||
conn = listener.accept()
|
conn = listener.accept()
|
||||||
|
@ -49,7 +49,7 @@ class IPCServerMixin:
|
||||||
|
|
||||||
# NOTE: Not perfect but insures we don't lockup the connection for too long.
|
# NOTE: Not perfect but insures we don't lockup the connection for too long.
|
||||||
end_time = time.time()
|
end_time = time.time()
|
||||||
if (end - start) > 15.0:
|
if (end - start) > self.ipc_timeout:
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
listener.close()
|
listener.close()
|
||||||
|
@ -57,7 +57,7 @@ class IPCServerMixin:
|
||||||
|
|
||||||
def send_ipc_message(self, message="Empty Data..."):
|
def send_ipc_message(self, message="Empty Data..."):
|
||||||
try:
|
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(message)
|
||||||
conn.send('close connection')
|
conn.send('close connection')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
@ -232,9 +232,6 @@ class WidgetFileActionMixin:
|
||||||
target = f"{view.get_current_directory()}"
|
target = f"{view.get_current_directory()}"
|
||||||
|
|
||||||
if file_name:
|
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
|
if type == True: # Create File
|
||||||
|
|
|
@ -82,7 +82,7 @@ class WindowMixin(TabMixin):
|
||||||
_wid, _tid, _view, iconview, store = self.get_current_state()
|
_wid, _tid, _view, iconview, store = self.get_current_state()
|
||||||
selected_files = iconview.get_selected_items()
|
selected_files = iconview.get_selected_items()
|
||||||
current_directory = view.get_current_directory()
|
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)
|
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_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")) )
|
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)
|
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:
|
||||||
|
try:
|
||||||
file_info = Gio.File.new_for_path(uri).query_info(attributes="standard::size",
|
file_info = Gio.File.new_for_path(uri).query_info(attributes="standard::size",
|
||||||
flags=Gio.FileQueryInfoFlags.NONE,
|
flags=Gio.FileQueryInfoFlags.NONE,
|
||||||
cancellable=None)
|
cancellable=None)
|
||||||
file_size = file_info.get_size()
|
file_size = file_info.get_size()
|
||||||
combined_size += file_size
|
combined_size += file_size
|
||||||
|
except Exception as e:
|
||||||
|
if debug:
|
||||||
|
print(repr(e))
|
||||||
|
|
||||||
|
|
||||||
formatted_size = self.sizeof_fmt(combined_size)
|
formatted_size = self.sizeof_fmt(combined_size)
|
||||||
if view.hide_hidden:
|
if view.hide_hidden:
|
||||||
|
|
|
@ -72,7 +72,9 @@ class Settings:
|
||||||
cr.paint()
|
cr.paint()
|
||||||
cr.set_operator(cairo.OPERATOR_OVER)
|
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):
|
def getMonitorData(self):
|
||||||
|
|
Loading…
Reference in New Issue