ShellFM/src/shellfm/windows/WindowController.py

70 lines
1.9 KiB
Python
Raw Normal View History

2021-03-18 05:29:58 +00:00
from . import Window
class WindowController:
def __init__(self):
self.windows = []
def get_window(self, win_id):
for window in self.windows:
if window.id == win_id:
return window
raise("No Window by ID {} found!".format(win_id))
def get_windows(self):
return self.windows
def add_window(self):
window = Window()
window.id = len(self.windows) + 1
window.name = "window_" + str(window.id)
self.windows.append(window)
def add_view_for_window(self, win_id):
for window in self.windows:
if window.id == win_id:
2021-04-24 11:39:09 +00:00
return window.create_view()
2021-03-18 05:29:58 +00:00
def pop_window(self):
self.windows.pop()
def delete_window_by_id(self, win_id):
i = 0
for window in self.windows:
if window.id == win_id:
self.window.remove(win_id)
break
i += 1
def set_window_nickname(self, win_id = None, nickname = ""):
for window in self.windows:
if window.id == win_id:
window.nickname = nickname
def list_windows(self):
for window in self.windows:
print("\n[ Window ]")
print("ID: " + str(window.id))
print("Name: " + window.name)
print("Nickname: " + window.nickname)
print("View Count: " + str( len(window.views) ))
def list_files_from_views_of_window(self, win_id):
2021-03-18 05:29:58 +00:00
for window in self.windows:
if window.id == win_id:
for view in window.views:
print(view.files)
break
def get_views_count(self, win_id):
for window in self.windows:
if window.id == win_id:
return len(window.views)
2021-03-18 05:29:58 +00:00
def return_views_from_window(self, win_id):
for window in self.windows:
if window.id == win_id:
return window.views