Merge Stable Changesto Master #9

Merged
itdominator merged 30 commits from develop into master 2022-11-29 04:58:09 +00:00
5 changed files with 103 additions and 98 deletions
Showing only changes of commit ee123c4916 - Show all commits

View File

@ -117,7 +117,6 @@ class Controller_Data:
state.store = state.icon_grid.get_model()
state.warning_alert = self.warning_alert
selected_files = state.icon_grid.get_selected_items()
if selected_files:
state.selected_files = self.format_to_uris(state.store, state.wid, state.tid, selected_files, True)

View File

@ -16,100 +16,100 @@ def threaded(fn):
class WindowController:
def __init__(self):
USER_HOME = path.expanduser('~')
CONFIG_PATH = USER_HOME + "/.config/solarfm"
self._session_file = CONFIG_PATH + "/session.json"
USER_HOME: str = path.expanduser('~')
CONFIG_PATH: str = f"{USER_HOME}/.config/solarfm"
self._session_file: srr = f"{CONFIG_PATH}/session.json"
self._event_sleep_time = 1
self._active_window_id = ""
self._active_tab_id = ""
self._windows = []
self._event_sleep_time: int = 1
self._active_window_id: str = ""
self._active_tab_id: str = ""
self._windows: list = []
def set_wid_and_tid(self, wid, tid):
def set_wid_and_tid(self, wid: int, tid: int) -> None:
self._active_window_id = str(wid)
self._active_tab_id = str(tid)
def get_active_wid_and_tid(self):
def get_active_wid_and_tid(self) -> list:
return self._active_window_id, self._active_tab_id
def create_window(self):
def create_window(self) -> Window:
window = Window()
window.set_nickname(f"window_{str(len(self._windows) + 1)}")
self._windows.append(window)
return window
def add_tab_for_window(self, win_id):
def add_tab_for_window(self, win_id: str) -> None:
for window in self._windows:
if window.get_id() == win_id:
return window.create_tab()
def add_tab_for_window_by_name(self, name):
def add_tab_for_window_by_name(self, name: str) -> None:
for window in self._windows:
if window.get_name() == name:
return window.create_tab()
def add_tab_for_window_by_nickname(self, nickname):
def add_tab_for_window_by_nickname(self, nickname: str) -> None:
for window in self._windows:
if window.get_nickname() == nickname:
return window.create_tab()
def pop_window(self):
def pop_window(self) -> None:
self._windows.pop()
def delete_window_by_id(self, win_id):
def delete_window_by_id(self, win_id: str) -> None:
for window in self._windows:
if window.get_id() == win_id:
self._windows.remove(window)
break
def delete_window_by_name(self, name):
def delete_window_by_name(self, name: str) -> str:
for window in self._windows:
if window.get_name() == name:
self._windows.remove(window)
break
def delete_window_by_nickname(self, nickname):
def delete_window_by_nickname(self, nickname: str) -> str:
for window in self._windows:
if window.get_nickname() == nickname:
self._windows.remove(window)
break
def get_window_by_id(self, win_id):
def get_window_by_id(self, win_id: str) -> Window:
for window in self._windows:
if window.get_id() == win_id:
return window
raise(f"No Window by ID {win_id} found!")
def get_window_by_name(self, name):
def get_window_by_name(self, name: str) -> Window:
for window in self._windows:
if window.get_name() == name:
return window
raise(f"No Window by Name {name} found!")
def get_window_by_nickname(self, nickname):
def get_window_by_nickname(self, nickname: str) -> Window:
for window in self._windows:
if window.get_nickname() == nickname:
return window
raise(f"No Window by Nickname {nickname} found!")
def get_window_by_index(self, index):
def get_window_by_index(self, index: int) -> Window:
return self._windows[index]
def get_all_windows(self):
def get_all_windows(self) -> list:
return self._windows
def set_window_nickname(self, win_id = None, nickname = ""):
def set_window_nickname(self, win_id: str = None, nickname: str = "") -> None:
for window in self._windows:
if window.get_id() == win_id:
window.set_nickname(nickname)
def list_windows(self):
def list_windows(self) -> None:
print("\n[ ---- Windows ---- ]\n")
for window in self._windows:
print(f"\nID: {window.get_id()}")
@ -121,18 +121,18 @@ class WindowController:
def list_files_from_tabs_of_window(self, win_id):
def list_files_from_tabs_of_window(self, win_id: str) -> None:
for window in self._windows:
if window.get_id() == win_id:
window.list_files_from_tabs()
break
def get_tabs_count(self, win_id):
def get_tabs_count(self, win_id: str) -> int:
for window in self._windows:
if window.get_id() == win_id:
return window.get_tabs_count()
def get_tabs_from_window(self, win_id):
def get_tabs_from_window(self, win_id: str) -> list:
for window in self._windows:
if window.get_id() == win_id:
return window.get_all_tabs()
@ -140,13 +140,13 @@ class WindowController:
def unload_tabs_and_windows(self):
def unload_tabs_and_windows(self) -> None:
for window in self._windows:
window.get_all_tabs().clear()
self._windows.clear()
def save_state(self, session_file = None):
def save_state(self, session_file: str = None) -> None:
if not session_file:
session_file = self._session_file
@ -174,7 +174,7 @@ class WindowController:
else:
raise Exception("Window data corrupted! Can not save session!")
def get_state_from_file(self, session_file = None):
def get_state_from_file(self, session_file: str = None) -> dict:
if not session_file:
session_file = self._session_file

View File

@ -7,20 +7,20 @@ import os
class Path:
def get_home(self):
def get_home(self) -> str:
return os.path.expanduser("~") + self.subpath
def get_path(self):
def get_path(self) -> str:
return f"/{'/'.join(self.path)}" if self.path else f"/{''.join(self.path)}"
def get_path_list(self):
def get_path_list(self) -> list:
return self.path
def push_to_path(self, dir):
def push_to_path(self, dir: str):
self.path.append(dir)
self.load_directory()
def pop_from_path(self):
def pop_from_path(self) -> None:
try:
self.path.pop()
@ -32,9 +32,9 @@ class Path:
except Exception as e:
pass
def set_path(self, path):
def set_path(self, path: str) -> bool:
if path == self.get_path():
return
return False
if os.path.isdir(path):
self.path = list( filter(None, path.replace("\\", "/").split('/')) )
@ -43,7 +43,7 @@ class Path:
return False
def set_path_with_sub_path(self, sub_path):
def set_path_with_sub_path(self, sub_path: str) -> bool:
path = os.path.join(self.get_home(), sub_path)
if path == self.get_path():
return False
@ -55,7 +55,7 @@ class Path:
return False
def set_to_home(self):
def set_to_home(self) -> None:
home = os.path.expanduser("~") + self.subpath
path = list( filter(None, home.replace("\\", "/").split('/')) )
self.path = path

View File

@ -21,24 +21,24 @@ from .path import Path
class Tab(Settings, FileHandler, Launcher, Icon, Path):
def __init__(self):
self.logger = None
self._id_length = 10
self._id_length: int = 10
self._id = ""
self._wid = None
self._id: str = ""
self._wid: str = None
self._dir_watcher = None
self._hide_hidden = self.HIDE_HIDDEN_FILES
self._files = []
self._dirs = []
self._vids = []
self._images = []
self._desktop = []
self._ungrouped = []
self._hidden = []
self._hide_hidden: bool = self.HIDE_HIDDEN_FILES
self._files: list = []
self._dirs: list = []
self._vids: list = []
self._images: list = []
self._desktop: list = []
self._ungrouped: list = []
self._hidden: list = []
self._generate_id()
self.set_to_home()
def load_directory(self):
def load_directory(self) -> None:
path = self.get_path()
self._dirs = []
self._vids = []
@ -97,7 +97,7 @@ class Tab(Settings, FileHandler, Launcher, Icon, Path):
return False
def get_not_hidden_count(self):
def get_not_hidden_count(self) -> int:
return len(self._files) + \
len(self._dirs) + \
len(self._vids) + \
@ -105,13 +105,13 @@ class Tab(Settings, FileHandler, Launcher, Icon, Path):
len(self._desktop) + \
len(self._ungrouped)
def get_hidden_count(self):
def get_hidden_count(self) -> int:
return len(self._hidden)
def get_files_count(self):
def get_files_count(self) -> int:
return len(self._files)
def get_path_part_from_hash(self, hash):
def get_path_part_from_hash(self, hash: str) -> str:
files = self.get_files()
file = None
@ -122,7 +122,7 @@ class Tab(Settings, FileHandler, Launcher, Icon, Path):
return file
def get_files_formatted(self):
def get_files_formatted(self) -> dict:
files = self._hash_set(self._files),
dirs = self._hash_set(self._dirs),
videos = self.get_videos(),
@ -154,7 +154,7 @@ class Tab(Settings, FileHandler, Launcher, Icon, Path):
return data
def get_gtk_icon_str_combo(self):
def get_gtk_icon_str_combo(self) -> list:
data = []
dir = self.get_current_directory()
for file in self._files:
@ -163,57 +163,57 @@ class Tab(Settings, FileHandler, Launcher, Icon, Path):
return data
def get_current_directory(self):
def get_current_directory(self) -> str:
return self.get_path()
def get_current_sub_path(self):
def get_current_sub_path(self) -> str:
path = self.get_path()
home = f"{self.get_home()}/"
return path.replace(home, "")
def get_end_of_path(self):
def get_end_of_path(self) -> str:
parts = self.get_current_directory().split("/")
size = len(parts)
return parts[size - 1]
def set_hiding_hidden(self, state):
def set_hiding_hidden(self, state: bool) -> None:
self._hide_hidden = state
def is_hiding_hidden(self):
def is_hiding_hidden(self) -> bool:
return self._hide_hidden
def get_dot_dots(self):
def get_dot_dots(self) -> list:
return self._hash_set(['.', '..'])
def get_files(self):
def get_files(self) -> list:
return self._hash_set(self._files)
def get_dirs(self):
def get_dirs(self) -> list:
return self._hash_set(self._dirs)
def get_videos(self):
def get_videos(self) -> list:
return self._hash_set(self._vids)
def get_images(self):
def get_images(self) -> list:
return self._hash_set(self._images)
def get_desktops(self):
def get_desktops(self) -> list:
return self._hash_set(self._desktop)
def get_ungrouped(self):
def get_ungrouped(self) -> list:
return self._hash_set(self._ungrouped)
def get_hidden(self):
def get_hidden(self) -> list:
return self._hash_set(self._hidden)
def get_id(self):
def get_id(self) -> str:
return self._id
def set_wid(self, _wid):
def set_wid(self, _wid: str) -> None:
self._wid = _wid
def get_wid(self):
def get_wid(self) -> str:
return self._wid
def set_dir_watcher(self, watcher):
@ -228,19 +228,19 @@ class Tab(Settings, FileHandler, Launcher, Icon, Path):
def _natural_keys(self, text):
return [ self._atoi(c) for c in re.split('(\d+)',text) ]
def _hash_text(self, text):
def _hash_text(self, text) -> str:
return hashlib.sha256(str.encode(text)).hexdigest()[:18]
def _hash_set(self, arry):
def _hash_set(self, arry: list) -> list:
data = []
for arr in arry:
data.append([arr, self._hash_text(arr)])
return data
def _random_with_N_digits(self, n):
def _random_with_N_digits(self, n: int) -> int:
range_start = 10**(n-1)
range_end = (10**n)-1
return randint(range_start, range_end)
def _generate_id(self):
def _generate_id(self) -> str:
self._id = str(self._random_with_N_digits(self._id_length))

View File

@ -11,62 +11,68 @@ from .tabs.tab import Tab
class Window:
def __init__(self):
self._id_length = 10
self._id = ""
self._name = ""
self._nickname = ""
self._isHidden = False
self._tabs = []
self._id_length: int = 10
self._id: str = ""
self._name: str = ""
self._nickname:str = ""
self._isHidden: bool = False
self._active_tab: int = 0
self._tabs: list = []
self._generate_id()
self._set_name()
def create_tab(self):
def create_tab(self) -> Tab:
tab = Tab()
self._tabs.append(tab)
return tab
def pop_tab(self):
def pop_tab(self) -> None:
self._tabs.pop()
def delete_tab_by_id(self, tid):
def delete_tab_by_id(self, tid: str):
for tab in self._tabs:
if tab.get_id() == tid:
self._tabs.remove(tab)
break
def get_tab_by_id(self, tid):
def get_tab_by_id(self, tid: str) -> Tab:
for tab in self._tabs:
if tab.get_id() == tid:
return tab
def get_tab_by_index(self, index):
def get_tab_by_index(self, index) -> Tab:
return self._tabs[index]
def get_tabs_count(self):
def get_tabs_count(self) -> int:
return len(self._tabs)
def get_all_tabs(self):
def get_all_tabs(self) -> list:
return self._tabs
def get_id(self):
def get_id(self) -> str:
return self._id
def get_name(self):
def get_name(self) -> str:
return self._name
def get_nickname(self):
def get_nickname(self) -> str:
return self._nickname
def is_hidden(self):
def is_hidden(self) -> bool:
return self._isHidden
def list_files_from_tabs(self):
def list_files_from_tabs(self) -> None:
for tab in self._tabs:
print(tab.get_files())
def set_active_tab(self, index: int):
self._active_tab = index
def get_active_tab(self) -> Tab:
return self._tabs[self._active_tab]
def set_nickname(self, nickname):
self._nickname = f"{nickname}"