ShellFM/src/shellfm/windows/Window.py

67 lines
1.3 KiB
Python
Raw Normal View History

# Python imports
from random import randint
# Lib imports
# Application imports
2021-04-22 06:32:18 +00:00
from .view import View
2021-03-18 05:29:58 +00:00
class Window:
def __init__(self):
self.id_length = 10
self.id = ""
self.name = ""
self.nickname = ""
2021-09-04 03:57:00 +00:00
self.isHidden = False
self.views = []
self.generate_id()
def random_with_N_digits(self, n):
range_start = 10**(n-1)
range_end = (10**n)-1
return randint(range_start, range_end)
def generate_id(self):
self.id = str(self.random_with_N_digits(self.id_length))
2021-04-28 04:30:58 +00:00
def get_window_id(self):
return self.id
2021-03-18 05:29:58 +00:00
def create_view(self):
view = View()
self.views.append(view)
2021-04-24 11:39:09 +00:00
return view
2021-03-18 05:29:58 +00:00
def pop_view(self):
self.views.pop()
def delete_view_by_id(self, vid):
2021-04-24 11:39:09 +00:00
for view in self.views:
if view.id == vid:
self.views.remove(view)
2021-04-24 11:39:09 +00:00
break
2021-03-18 05:29:58 +00:00
2021-04-24 11:39:09 +00:00
def get_view_by_id(self, vid):
for view in self.views:
if view.id == vid:
return view
def get_view_by_index(self, index):
2021-03-18 05:29:58 +00:00
return self.views[index]
def get_views_count(self):
return len(self.views)
def get_all_views(self):
return self.views
def list_files_from_views(self):
for view in self.views:
print(view.files)