Cleanedup controller data

This commit is contained in:
itdominator 2022-12-06 18:41:52 -06:00
parent a9ab9e95d8
commit 6d4279c871
6 changed files with 29 additions and 40 deletions

View File

@ -25,11 +25,11 @@ class State:
wid: int = None wid: int = None
tid: int = None tid: int = None
tab: type = None tab: type = None
icon_grid: gi.overrides.Gtk.IconView = None icon_grid: gi.overrides.Gtk.IconView = None
store: gi.overrides.Gtk.ListStore = None store: gi.overrides.Gtk.ListStore = None
selected_files: [] = None selected_files: [] = None
to_copy_files: [] = None to_copy_files: [] = None
to_cut_files: [] = None to_cut_files: [] = None
message_dialog: type = None message_dialog: type = None
@ -50,23 +50,12 @@ class Controller_Data:
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_popup_widget = self.builder.get_object("message_popup_widget")
self.message_text_view = self.builder.get_object("message_text_view")
self.message_buffer = self.builder.get_object("message_buffer")
self.arc_command_buffer = self.builder.get_object("arc_command_buffer")
self.exists_file_rename_bttn = self.builder.get_object("exists_file_rename_bttn")
self.warning_alert = self.builder.get_object("warning_alert")
self.path_entry = self.builder.get_object("path_entry")
self.path_entry = self.builder.get_object("path_entry")
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 = f"{GLib.get_user_data_dir()}/Trash/files"
self.trash_info_path = f"{GLib.get_user_data_dir()}/Trash/info"
self.icon_theme = settings.get_icon_theme()
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_copy_files = [] self.to_copy_files = []
@ -81,15 +70,10 @@ class Controller_Data:
self.is_pane4_hidden = False self.is_pane4_hidden = False
self.override_drop_dest = None self.override_drop_dest = None
self.ctrl_down = False self.ctrl_down = False
self.shift_down = False self.shift_down = False
self.alt_down = False self.alt_down = False
self.success_color = settings.get_success_color()
self.warning_color = settings.get_warning_color()
self.error_color = settings.get_error_color()
# sys.excepthook = self.custom_except_hook # sys.excepthook = self.custom_except_hook
self.window.connect("delete-event", self.tear_down) self.window.connect("delete-event", self.tear_down)
GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT, self.tear_down) GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT, self.tear_down)

View File

@ -344,7 +344,7 @@ class FileActionSignalsMixin:
except GObject.GError as e: except GObject.GError as e:
raise OSError(e) raise OSError(e)
self.exists_file_rename_bttn.set_sensitive(False) self.builder.get_object("exists_file_rename_bttn").set_sensitive(False)
def rename_proc(self, gio_file): def rename_proc(self, gio_file):
full_path = gio_file.get_path() full_path = gio_file.get_path()

View File

@ -59,7 +59,7 @@ class GridMixin:
gio_file = Gio.File.new_for_path(filename) gio_file = Gio.File.new_for_path(filename)
info = gio_file.query_info('standard::icon' , 0, None) info = gio_file.query_info('standard::icon' , 0, None)
icon = info.get_icon().get_names()[0] icon = info.get_icon().get_names()[0]
icon_path = self.icon_theme.lookup_icon(icon , size , 0).get_filename() icon_path = settings.get_icon_theme().lookup_icon(icon , size , 0).get_filename()
return GdkPixbuf.Pixbuf.new_from_file(icon_path) return GdkPixbuf.Pixbuf.new_from_file(icon_path)
except Exception: except Exception:

View File

@ -94,7 +94,7 @@ class WindowMixin(TabMixin):
formatted_mount_size = sizeof_fmt( int(mount_file.get_attribute_as_string("filesystem::size")) ) formatted_mount_size = sizeof_fmt( int(mount_file.get_attribute_as_string("filesystem::size")) )
# NOTE: Hides empty trash and other desired buttons based on context. # NOTE: Hides empty trash and other desired buttons based on context.
if self.trash_files_path == current_directory: if settings.get_trash_files_path() == current_directory:
event_system.emit("show_trash_buttons") event_system.emit("show_trash_buttons")
else: else:
event_system.emit("hide_trash_buttons") event_system.emit("hide_trash_buttons")
@ -202,7 +202,7 @@ class WindowMixin(TabMixin):
except WindowException as e: except WindowException as e:
print(repr(e)) print(repr(e))
self.display_message(self.error_color, f"{repr(e)}") self.display_message(settings.get_error_color(), f"{repr(e)}")
def grid_icon_double_click(self, icons_grid, item, data=None): def grid_icon_double_click(self, icons_grid, item, data=None):
try: try:
@ -231,7 +231,7 @@ class WindowMixin(TabMixin):
self.open_files() self.open_files()
except WindowException as e: except WindowException as e:
traceback.print_exc() traceback.print_exc()
self.display_message(self.error_color, f"{repr(e)}") self.display_message(settings.get_error_color(), f"{repr(e)}")

View File

@ -79,7 +79,7 @@ class MessagePopupWidget(Gtk.Popover):
data = f"Exec Type: {exec_type} <--> Value: {value}\n\n{trace}\n\n\n\n" data = f"Exec Type: {exec_type} <--> Value: {value}\n\n{trace}\n\n\n\n"
start_itr = self._message_buffer.get_start_iter() start_itr = self._message_buffer.get_start_iter()
self._message_buffer.place_cursor(start_itr) self._message_buffer.place_cursor(start_itr)
self.display_message(self.error_color, data) self.display_message(settings.get_error_color(), data)
def display_message(self, type, text, seconds=None): def display_message(self, type, text, seconds=None):
self._message_buffer.insert_at_cursor(text) self._message_buffer.insert_at_cursor(text)
@ -90,7 +90,6 @@ class MessagePopupWidget(Gtk.Popover):
@threaded @threaded
def hide_message_timeout(self, seconds=3): def hide_message_timeout(self, seconds=3):
time.sleep(seconds) time.sleep(seconds)
# GLib.idle_add(self.message_popup_widget.popdown)
GLib.idle_add(event_system.emit, ("hide_messages_popup")) GLib.idle_add(event_system.emit, ("hide_messages_popup"))
def save_debug_alerts(self, widget=None, eve=None): def save_debug_alerts(self, widget=None, eve=None):

View File

@ -8,6 +8,7 @@ import gi, cairo
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
from gi.repository import GLib
from gi.repository import Gdk from gi.repository import Gdk
# Application imports # Application imports
@ -34,6 +35,8 @@ class Settings:
self._CONTEXT_MENU = f"{self._CONFIG_PATH}/contexct_menu.json" self._CONTEXT_MENU = f"{self._CONFIG_PATH}/contexct_menu.json"
self._PID_FILE = f"{self._CONFIG_PATH}/{app_name.lower()}.pid" self._PID_FILE = f"{self._CONFIG_PATH}/{app_name.lower()}.pid"
self._ICON_THEME = Gtk.IconTheme.get_default() self._ICON_THEME = Gtk.IconTheme.get_default()
self._TRASH_FILES_PATH = f"{GLib.get_user_data_dir()}/Trash/files"
self._TRASH_INFO_PATH = f"{GLib.get_user_data_dir()}/Trash/info"
if not os.path.exists(self._CONFIG_PATH): if not os.path.exists(self._CONFIG_PATH):
os.mkdir(self._CONFIG_PATH) os.mkdir(self._CONFIG_PATH)
@ -149,27 +152,30 @@ class Settings:
return monitors return monitors
def get_context_menu_data(self) -> Gtk.Builder: return self._context_menu_data
def get_main_window(self) -> Gtk.ApplicationWindow: return self._main_window def get_main_window(self) -> Gtk.ApplicationWindow: return self._main_window
def get_builder(self) -> Gtk.Builder: return self._builder def get_builder(self) -> Gtk.Builder: return self._builder
def get_ui_widgets_path(self) -> Gtk.Builder: return self._UI_WIDEGTS_PATH def get_context_menu_data(self) -> str: return self._context_menu_data
def get_ui_widgets_path(self) -> str: return self._UI_WIDEGTS_PATH
def get_trash_files_path(self) -> str: return self._TRASH_FILES_PATH
def get_trash_info_path(self) -> str: return self._TRASH_INFO_PATH
def get_plugins_path(self) -> str: return self._PLUGINS_PATH
def get_logger(self) -> Logger: return self._logger def get_logger(self) -> Logger: return self._logger
def get_keybindings(self) -> Keybindings: return self._keybindings def get_keybindings(self) -> Keybindings: return self._keybindings
def get_plugins_path(self) -> str: return self._PLUGINS_PATH
def get_icon_theme(self) -> str: return self._ICON_THEME def get_icon_theme(self) -> str: return self._ICON_THEME
def get_success_color(self) -> str: return self._success_color def get_success_color(self) -> str: return self._success_color
def get_warning_color(self) -> str: return self._warning_color def get_warning_color(self) -> str: return self._warning_color
def get_error_color(self) -> str: return self._error_color def get_error_color(self) -> str: return self._error_color
def is_trace_debug(self) -> str: return self._trace_debug def is_trace_debug(self) -> bool: return self._trace_debug
def is_debug(self) -> str: return self._debug def is_debug(self) -> bool: return self._debug
def is_dirty_start(self) -> bool: return self._dirty_start def is_dirty_start(self) -> bool: return self._dirty_start
def clear_pid(self): self._clean_pid() def clear_pid(self): self._clean_pid()
def set_trace_debug(self, trace_debug): def set_trace_debug(self, trace_debug: bool):
self._trace_debug = trace_debug self._trace_debug = trace_debug
def set_debug(self, debug): def set_debug(self, debug: bool):
self._debug = debug self._debug = debug