Bringing to latest changes #3
|
@ -1,5 +1,3 @@
|
|||
# SolarFM
|
||||
|
||||
# SolarFM
|
||||
SolarFM is a Gtk+ Python file manager.
|
||||
|
||||
|
@ -14,6 +12,8 @@ sudo apt-get install python3.8 wget python3-setproctitle python3-gi ffmpegthumbn
|
|||
# TODO
|
||||
<ul>
|
||||
<li>Add simpleish plugin system to run bash/python scripts.</li>
|
||||
<li>Add simpleish search plugin to do recursive search and show.</li>
|
||||
<li>Add simpleish bulk-renamer.</li>
|
||||
</ul>
|
||||
|
||||
# Images
|
||||
|
|
|
@ -21,7 +21,7 @@ class Main:
|
|||
self._event_system = event_system
|
||||
self._socket_id = socket_id
|
||||
self._gtk_plug = Gtk.Plug.new(self._socket_id)
|
||||
button = Gtk.Button(label="Click Me!")
|
||||
button = Gtk.Button(label=label=self._plugin_name)
|
||||
self._message = None
|
||||
self._time_out = 5
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
# Python imports
|
||||
import os, sys, threading, subprocess, time
|
||||
|
||||
# Gtk imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
|
||||
|
||||
def threaded(fn):
|
||||
def wrapper(*args, **kwargs):
|
||||
threading.Thread(target=fn, args=args, kwargs=kwargs, daemon=False).start()
|
||||
return wrapper
|
||||
|
||||
|
||||
class Main:
|
||||
def __init__(self, socket_id, event_system):
|
||||
self.SCRIPT_PTH = os.path.dirname(os.path.realpath(__file__))
|
||||
self._plugin_name = "Youtube Download"
|
||||
self._event_system = event_system
|
||||
self._socket_id = socket_id
|
||||
self._gtk_plug = Gtk.Plug.new(self._socket_id)
|
||||
button = Gtk.Button(label=self._plugin_name)
|
||||
self._message = None
|
||||
self._time_out = 5
|
||||
|
||||
button.connect("button-release-event", self._do_download)
|
||||
self._gtk_plug.add(button)
|
||||
self._gtk_plug.show_all()
|
||||
|
||||
|
||||
@threaded
|
||||
def _do_download(self, widget=None, eve=None):
|
||||
self._event_system.push_gui_event([self._plugin_name, "get_current_state", ()])
|
||||
self._run_timeout()
|
||||
|
||||
if self._message:
|
||||
wid, tid, view, iconview, store = self._message
|
||||
subprocess.Popen([f'{self.SCRIPT_PTH}/download.sh' , view.get_current_directory()])
|
||||
self._message = None
|
||||
|
||||
|
||||
def set_message(self, data):
|
||||
self._message = data
|
||||
|
||||
def get_plugin_name(self):
|
||||
return self._plugin_name
|
||||
|
||||
def get_socket_id(self):
|
||||
return self._socket_id
|
||||
|
||||
def _run_timeout(self):
|
||||
timeout = 0
|
||||
while not self._message and timeout < self._time_out:
|
||||
time.sleep(1)
|
||||
timeout += 1
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
|
||||
# . CONFIG.sh
|
||||
|
||||
# set -o xtrace ## To debug scripts
|
||||
# set -o errexit ## To exit on error
|
||||
# set -o errunset ## To exit if a variable is referenced but not set
|
||||
|
||||
|
||||
function main() {
|
||||
cd "$(dirname "")"
|
||||
echo "Working Dir: " $(pwd)
|
||||
|
||||
LINK=`xclip -selection clipboard -o`
|
||||
yt-dlp --write-sub --embed-sub --sub-langs en -o "${1}/%(title)s.%(ext)s" "${LINK}"
|
||||
}
|
||||
main "$@";
|
|
@ -19,7 +19,7 @@ class Main(Builtins):
|
|||
event_system.create_ipc_server()
|
||||
|
||||
time.sleep(0.2)
|
||||
if not trace_debug:
|
||||
if not trace_debug and not debug:
|
||||
if not event_system.is_ipc_alive:
|
||||
if unknownargs:
|
||||
for arg in unknownargs:
|
||||
|
|
|
@ -25,9 +25,13 @@ class Controller(UIMixin, KeyboardSignalsMixin, IPCSignalsMixin, ExceptionHookMi
|
|||
def __init__(self, args, unknownargs, _settings):
|
||||
self.setup_controller_data(_settings)
|
||||
self.window.show()
|
||||
|
||||
self.generate_windows(self.state)
|
||||
self.plugins.launch_plugins()
|
||||
|
||||
if debug:
|
||||
self.window.set_interactive_debugging(True)
|
||||
|
||||
if not trace_debug:
|
||||
self.gui_event_observer()
|
||||
|
||||
|
@ -73,7 +77,7 @@ class Controller(UIMixin, KeyboardSignalsMixin, IPCSignalsMixin, ExceptionHookMi
|
|||
|
||||
|
||||
def save_load_session(self, action="save_session"):
|
||||
wid, tid = self.window_controller.get_active_data()
|
||||
wid, tid = self.window_controller.get_active_wid_and_tid()
|
||||
view = self.get_fm_window(wid).get_view_by_id(tid)
|
||||
save_load_dialog = self.builder.get_object("save_load_dialog")
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ from gi.repository import GLib
|
|||
|
||||
# Application imports
|
||||
from trasher.xdgtrash import XDGTrash
|
||||
from shellfm import WindowController
|
||||
from shellfm.windows.controller import WindowController
|
||||
from plugins import Plugins
|
||||
|
||||
|
||||
|
@ -118,7 +118,7 @@ class Controller_Data:
|
|||
Returns:
|
||||
wid, tid, view, iconview, store
|
||||
'''
|
||||
wid, tid = self.window_controller.get_active_data()
|
||||
wid, tid = self.window_controller.get_active_wid_and_tid()
|
||||
view = self.get_fm_window(wid).get_view_by_id(tid)
|
||||
iconview = self.builder.get_object(f"{wid}|{tid}|iconview")
|
||||
store = iconview.get_model()
|
||||
|
|
|
@ -56,7 +56,7 @@ class ShowHideMixin:
|
|||
|
||||
|
||||
def show_archiver_dialogue(self, widget=None, eve=None):
|
||||
wid, tid = self.window_controller.get_active_data()
|
||||
wid, tid = self.window_controller.get_active_wid_and_tid()
|
||||
view = self.get_fm_window(wid).get_view_by_id(tid)
|
||||
archiver_dialogue = self.builder.get_object("archiver_dialogue")
|
||||
archiver_dialogue.set_action(Gtk.FileChooserAction.SAVE)
|
||||
|
|
|
@ -61,5 +61,5 @@ class PaneMixin:
|
|||
|
||||
def _save_state(self, state, pane_index):
|
||||
window = self.window_controller.get_window_by_index(pane_index - 1)
|
||||
window.isHidden = state
|
||||
window.set_is_hidden(state)
|
||||
self.window_controller.save_state()
|
||||
|
|
|
@ -30,7 +30,7 @@ class TabMixin(WidgetMixin):
|
|||
# scroll, store = self.create_grid_treeview_widget(view, wid)
|
||||
index = notebook.append_page(scroll, tab)
|
||||
|
||||
self.window_controller.set_active_data(wid, view.get_tab_id())
|
||||
self.window_controller.set__wid_and_tid(wid, view.get_id())
|
||||
path_entry.set_text(view.get_current_directory())
|
||||
notebook.show_all()
|
||||
notebook.set_current_page(index)
|
||||
|
@ -47,7 +47,7 @@ class TabMixin(WidgetMixin):
|
|||
|
||||
def close_tab(self, button, eve=None):
|
||||
notebook = button.get_parent().get_parent()
|
||||
tid = self.get_tab_id_from_tab_box(button.get_parent())
|
||||
tid = self.get_id_from_tab_box(button.get_parent())
|
||||
wid = int(notebook.get_name()[-1])
|
||||
scroll = self.builder.get_object(f"{wid}|{tid}")
|
||||
page = notebook.page_num(scroll)
|
||||
|
@ -65,12 +65,12 @@ class TabMixin(WidgetMixin):
|
|||
window = self.get_fm_window(wid)
|
||||
view = None
|
||||
|
||||
for i, view in enumerate(window.views):
|
||||
if view.id == tid:
|
||||
for i, view in enumerate(window.get_all_views()):
|
||||
if view.get_id() == tid:
|
||||
_view = window.get_view_by_id(tid)
|
||||
watcher = _view.get_dir_watcher()
|
||||
watcher.cancel()
|
||||
window.views.insert(new_index, window.views.pop(i))
|
||||
window.get_all_views().insert(new_index, window.get_all_views().pop(i))
|
||||
|
||||
view = window.get_view_by_id(tid)
|
||||
self.set_file_watcher(view)
|
||||
|
@ -79,11 +79,11 @@ class TabMixin(WidgetMixin):
|
|||
def on_tab_switch_update(self, notebook, content=None, index=None):
|
||||
self.selected_files.clear()
|
||||
wid, tid = content.get_children()[0].get_name().split("|")
|
||||
self.window_controller.set_active_data(wid, tid)
|
||||
self.window_controller.set__wid_and_tid(wid, tid)
|
||||
self.set_path_text(wid, tid)
|
||||
self.set_window_title()
|
||||
|
||||
def get_tab_id_from_tab_box(self, tab_box):
|
||||
def get_id_from_tab_box(self, tab_box):
|
||||
tid = tab_box.get_children()[2]
|
||||
return tid.get_text()
|
||||
|
||||
|
@ -114,7 +114,7 @@ class TabMixin(WidgetMixin):
|
|||
|
||||
def do_action_from_bar_controls(self, widget, eve=None):
|
||||
action = widget.get_name()
|
||||
wid, tid = self.window_controller.get_active_data()
|
||||
wid, tid = self.window_controller.get_active_wid_and_tid()
|
||||
notebook = self.builder.get_object(f"window_{wid}")
|
||||
store, tab_label = self.get_store_and_label_from_notebook(notebook, f"{wid}|{tid}")
|
||||
view = self.get_fm_window(wid).get_view_by_id(tid)
|
||||
|
@ -138,11 +138,11 @@ class TabMixin(WidgetMixin):
|
|||
if isinstance(focused_obj, Gtk.Entry):
|
||||
button_box = self.path_menu.get_children()[0].get_children()[0].get_children()[0]
|
||||
query = widget.get_text().replace(dir, "")
|
||||
files = view.files + view.hidden
|
||||
files = view.get_files() + view.get_hidden()
|
||||
|
||||
self.clear_children(button_box)
|
||||
show_path_menu = False
|
||||
for file in files:
|
||||
for file, hash in files:
|
||||
if os.path.isdir(f"{dir}{file}"):
|
||||
if query.lower() in file.lower():
|
||||
button = Gtk.Button(label=file)
|
||||
|
@ -183,7 +183,7 @@ class TabMixin(WidgetMixin):
|
|||
self.path_menu.popdown()
|
||||
|
||||
def keyboard_close_tab(self):
|
||||
wid, tid = self.window_controller.get_active_data()
|
||||
wid, tid = self.window_controller.get_active_wid_and_tid()
|
||||
notebook = self.builder.get_object(f"window_{wid}")
|
||||
scroll = self.builder.get_object(f"{wid}|{tid}")
|
||||
page = notebook.page_num(scroll)
|
||||
|
@ -198,8 +198,8 @@ class TabMixin(WidgetMixin):
|
|||
|
||||
# File control events
|
||||
def show_hide_hidden_files(self):
|
||||
wid, tid = self.window_controller.get_active_data()
|
||||
wid, tid = self.window_controller.get_active_wid_and_tid()
|
||||
view = self.get_fm_window(wid).get_view_by_id(tid)
|
||||
view.hide_hidden = not view.hide_hidden
|
||||
view.set_is_hidden(not view.is_hidden())
|
||||
view.load_directory()
|
||||
self.builder.get_object("refresh_view").released()
|
||||
|
|
|
@ -52,7 +52,7 @@ class WidgetFileActionMixin:
|
|||
.monitor_directory(Gio.FileMonitorFlags.WATCH_MOVES, Gio.Cancellable())
|
||||
|
||||
wid = view.get_wid()
|
||||
tid = view.get_tab_id()
|
||||
tid = view.get_id()
|
||||
dir_watcher.connect("changed", self.dir_watch_updates, (f"{wid}|{tid}",))
|
||||
view.set_dir_watcher(dir_watcher)
|
||||
|
||||
|
@ -174,7 +174,7 @@ class WidgetFileActionMixin:
|
|||
self.to_copy_files = uris
|
||||
|
||||
def paste_files(self):
|
||||
wid, tid = self.window_controller.get_active_data()
|
||||
wid, tid = self.window_controller.get_active_wid_and_tid()
|
||||
view = self.get_fm_window(wid).get_view_by_id(tid)
|
||||
target = f"{view.get_current_directory()}"
|
||||
|
||||
|
@ -227,7 +227,7 @@ class WidgetFileActionMixin:
|
|||
file_name = fname_field.get_text().strip()
|
||||
type = self.builder.get_object("context_menu_type_toggle").get_state()
|
||||
|
||||
wid, tid = self.window_controller.get_active_data()
|
||||
wid, tid = self.window_controller.get_active_wid_and_tid()
|
||||
view = self.get_fm_window(wid).get_view_by_id(tid)
|
||||
target = f"{view.get_current_directory()}"
|
||||
|
||||
|
@ -294,7 +294,7 @@ class WidgetFileActionMixin:
|
|||
type = _file.query_file_type(flags=Gio.FileQueryInfoFlags.NONE)
|
||||
|
||||
if type == Gio.FileType.DIRECTORY:
|
||||
wid, tid = self.window_controller.get_active_data()
|
||||
wid, tid = self.window_controller.get_active_wid_and_tid()
|
||||
view = self.get_fm_window(wid).get_view_by_id(tid)
|
||||
view.delete_file( _file.get_path() )
|
||||
else:
|
||||
|
@ -321,7 +321,7 @@ class WidgetFileActionMixin:
|
|||
|
||||
type = file.query_file_type(flags=Gio.FileQueryInfoFlags.NONE)
|
||||
if type == Gio.FileType.DIRECTORY:
|
||||
wid, tid = self.window_controller.get_active_data()
|
||||
wid, tid = self.window_controller.get_active_wid_and_tid()
|
||||
view = self.get_fm_window(wid).get_view_by_id(tid)
|
||||
fPath = file.get_path()
|
||||
tPath = target.get_path()
|
||||
|
|
|
@ -100,7 +100,7 @@ class WidgetMixin:
|
|||
label.set_label(f"{view.get_end_of_path()}")
|
||||
label.set_width_chars(len(view.get_end_of_path()))
|
||||
label.set_xalign(0.0)
|
||||
tid.set_label(f"{view.id}")
|
||||
tid.set_label(f"{view.get_id()}")
|
||||
|
||||
close.add(icon)
|
||||
tab.add(label)
|
||||
|
@ -148,10 +148,10 @@ class WidgetMixin:
|
|||
|
||||
grid.show_all()
|
||||
scroll.add(grid)
|
||||
grid.set_name(f"{wid}|{view.id}")
|
||||
scroll.set_name(f"{wid}|{view.id}")
|
||||
self.builder.expose_object(f"{wid}|{view.id}|iconview", grid)
|
||||
self.builder.expose_object(f"{wid}|{view.id}", scroll)
|
||||
grid.set_name(f"{wid}|{view.get_id()}")
|
||||
scroll.set_name(f"{wid}|{view.get_id()}")
|
||||
self.builder.expose_object(f"{wid}|{view.get_id()}|iconview", grid)
|
||||
self.builder.expose_object(f"{wid}|{view.get_id()}", scroll)
|
||||
return scroll, store
|
||||
|
||||
def create_grid_treeview_widget(self, view, wid):
|
||||
|
@ -197,10 +197,10 @@ class WidgetMixin:
|
|||
|
||||
grid.show_all()
|
||||
scroll.add(grid)
|
||||
grid.set_name(f"{wid}|{view.id}")
|
||||
scroll.set_name(f"{wid}|{view.id}")
|
||||
grid.set_name(f"{wid}|{view.get_id()}")
|
||||
scroll.set_name(f"{wid}|{view.get_id()}")
|
||||
grid.columns_autosize()
|
||||
self.builder.expose_object(f"{wid}|{view.id}", scroll)
|
||||
self.builder.expose_object(f"{wid}|{view.get_id()}", scroll)
|
||||
return scroll, store
|
||||
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ class WindowMixin(TabMixin):
|
|||
|
||||
|
||||
formatted_size = self.sizeof_fmt(combined_size)
|
||||
if view.hide_hidden:
|
||||
if view.get_hidden():
|
||||
self.bottom_path_label.set_label(f" {len(uris)} / {view.get_files_count()} ({formatted_size})")
|
||||
else:
|
||||
self.bottom_path_label.set_label(f" {len(uris)} / {view.get_not_hidden_count()} ({formatted_size})")
|
||||
|
@ -121,7 +121,7 @@ class WindowMixin(TabMixin):
|
|||
return
|
||||
|
||||
# If nothing selected
|
||||
if view.hide_hidden:
|
||||
if view.get_hidden():
|
||||
if view.get_hidden_count() > 0:
|
||||
self.bottom_file_count_label.set_label(f"{view.get_not_hidden_count()} visible ({view.get_hidden_count()} hidden)")
|
||||
else:
|
||||
|
@ -132,7 +132,7 @@ class WindowMixin(TabMixin):
|
|||
|
||||
|
||||
def set_window_title(self):
|
||||
wid, tid = self.window_controller.get_active_data()
|
||||
wid, tid = self.window_controller.get_active_wid_and_tid()
|
||||
notebook = self.builder.get_object(f"window_{wid}")
|
||||
view = self.get_fm_window(wid).get_view_by_id(tid)
|
||||
dir = view.get_current_directory()
|
||||
|
@ -164,7 +164,7 @@ class WindowMixin(TabMixin):
|
|||
try:
|
||||
self.path_menu.popdown()
|
||||
wid, tid = iconview.get_name().split("|")
|
||||
self.window_controller.set_active_data(wid, tid)
|
||||
self.window_controller.set__wid_and_tid(wid, tid)
|
||||
self.set_path_text(wid, tid)
|
||||
self.set_window_title()
|
||||
|
||||
|
@ -221,7 +221,7 @@ class WindowMixin(TabMixin):
|
|||
data.set_text(uris_text, -1)
|
||||
|
||||
def grid_on_drag_motion(self, iconview, drag_context, x, y, data):
|
||||
current = '|'.join(self.window_controller.get_active_data())
|
||||
current = '|'.join(self.window_controller.get_active_wid_and_tid())
|
||||
target = iconview.get_name()
|
||||
wid, tid = target.split("|")
|
||||
store = iconview.get_model()
|
||||
|
@ -232,12 +232,12 @@ class WindowMixin(TabMixin):
|
|||
self.override_drop_dest = uri if isdir(uri) else None
|
||||
|
||||
if target not in current:
|
||||
self.window_controller.set_active_data(wid, tid)
|
||||
self.window_controller.set__wid_and_tid(wid, tid)
|
||||
|
||||
|
||||
def grid_on_drag_data_received(self, widget, drag_context, x, y, data, info, time):
|
||||
if info == 80:
|
||||
wid, tid = self.window_controller.get_active_data()
|
||||
wid, tid = self.window_controller.get_active_wid_and_tid()
|
||||
notebook = self.builder.get_object(f"window_{wid}")
|
||||
store, tab_label = self.get_store_and_label_from_notebook(notebook, f"{wid}|{tid}")
|
||||
view = self.get_fm_window(wid).get_view_by_id(tid)
|
||||
|
|
|
@ -11,7 +11,7 @@ class IPCSignalsMixin:
|
|||
print(message)
|
||||
|
||||
def handle_file_from_ipc(self, path):
|
||||
wid, tid = self.window_controller.get_active_data()
|
||||
wid, tid = self.window_controller.get_active_wid_and_tid()
|
||||
notebook = self.builder.get_object(f"window_{wid}")
|
||||
if notebook.is_visible():
|
||||
self.create_tab(wid, path)
|
||||
|
|
|
@ -114,7 +114,7 @@ class KeyboardSignalsMixin:
|
|||
if keyname == "f2":
|
||||
self.rename_files()
|
||||
if keyname == "f4":
|
||||
wid, tid = self.window_controller.get_active_data()
|
||||
wid, tid = self.window_controller.get_active_wid_and_tid()
|
||||
view = self.get_fm_window(wid).get_view_by_id(tid)
|
||||
dir = view.get_current_directory()
|
||||
view.execute(f"{view.terminal_app}", dir)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Python imports
|
||||
import os, importlib
|
||||
import os, sys, importlib, traceback
|
||||
from os.path import join, isdir
|
||||
|
||||
# Lib imports
|
||||
|
@ -47,15 +47,20 @@ class Plugins:
|
|||
# @threaded
|
||||
def load_plugins(self, file=None):
|
||||
print(f"Loading plugins...")
|
||||
parent_path = os.getcwd()
|
||||
|
||||
for file in os.listdir(self._plugins_path):
|
||||
try:
|
||||
path = join(self._plugins_path, file)
|
||||
if isdir(path):
|
||||
os.chdir(path)
|
||||
|
||||
gtk_socket = Gtk.Socket().new()
|
||||
self._plugin_list_socket.add(gtk_socket)
|
||||
# NOTE: Must get ID after adding socket to window. Else issues....
|
||||
gtk_socket_id = gtk_socket.get_id()
|
||||
|
||||
sys.path.insert(0, path)
|
||||
spec = importlib.util.spec_from_file_location(file, join(path, "__main__.py"))
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
|
@ -72,7 +77,9 @@ class Plugins:
|
|||
gtk_socket.show_all()
|
||||
except Exception as e:
|
||||
print("Malformed plugin! Not loading!")
|
||||
print(repr(e))
|
||||
traceback.print_exc()
|
||||
|
||||
os.chdir(parent_path)
|
||||
|
||||
|
||||
def reload_plugins(self, file=None):
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
from .windows import WindowController
|
|
@ -1,66 +0,0 @@
|
|||
# Python imports
|
||||
from random import randint
|
||||
|
||||
|
||||
# Lib imports
|
||||
|
||||
|
||||
# Application imports
|
||||
from .view import View
|
||||
|
||||
|
||||
class Window:
|
||||
def __init__(self):
|
||||
self.id_length = 10
|
||||
self.id = ""
|
||||
self.name = ""
|
||||
self.nickname = ""
|
||||
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))
|
||||
|
||||
def get_window_id(self):
|
||||
return self.id
|
||||
|
||||
def create_view(self):
|
||||
view = View()
|
||||
self.views.append(view)
|
||||
return view
|
||||
|
||||
def pop_view(self):
|
||||
self.views.pop()
|
||||
|
||||
def delete_view_by_id(self, vid):
|
||||
for view in self.views:
|
||||
if view.id == vid:
|
||||
self.views.remove(view)
|
||||
break
|
||||
|
||||
|
||||
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):
|
||||
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)
|
|
@ -1,196 +0,0 @@
|
|||
# Python imports
|
||||
import threading, subprocess, time, json
|
||||
from os import path
|
||||
|
||||
# Lib imports
|
||||
|
||||
# Application imports
|
||||
from . import Window
|
||||
|
||||
|
||||
def threaded(fn):
|
||||
def wrapper(*args, **kwargs):
|
||||
threading.Thread(target=fn, args=args, kwargs=kwargs, daemon=True).start()
|
||||
return wrapper
|
||||
|
||||
|
||||
class WindowController:
|
||||
def __init__(self):
|
||||
USER_HOME = path.expanduser('~')
|
||||
CONFIG_PATH = USER_HOME + "/.config/solarfm"
|
||||
self.session_file = CONFIG_PATH + "/session.json"
|
||||
|
||||
self._event_sleep_time = 1
|
||||
self.active_window_id = ""
|
||||
self.active_tab_id = ""
|
||||
self.windows = []
|
||||
|
||||
if not trace_debug:
|
||||
self.fm_event_observer()
|
||||
|
||||
@threaded
|
||||
def fm_event_observer(self):
|
||||
while True:
|
||||
time.sleep(event_sleep_time)
|
||||
event = event_system.consume_module_event()
|
||||
if event:
|
||||
print(event)
|
||||
|
||||
def set_active_data(self, wid, tid):
|
||||
self.active_window_id = str(wid)
|
||||
self.active_tab_id = str(tid)
|
||||
|
||||
def get_active_data(self):
|
||||
return self.active_window_id, self.active_tab_id
|
||||
|
||||
def create_window(self):
|
||||
window = Window()
|
||||
window.name = "window_" + window.id
|
||||
window.nickname = "window_" + str(len(self.windows) + 1)
|
||||
|
||||
self.windows.append(window)
|
||||
return window
|
||||
|
||||
|
||||
def add_view_for_window(self, win_id):
|
||||
for window in self.windows:
|
||||
if window.id == win_id:
|
||||
return window.create_view()
|
||||
|
||||
def add_view_for_window_by_name(self, name):
|
||||
for window in self.windows:
|
||||
if window.name == name:
|
||||
return window.create_view()
|
||||
|
||||
def add_view_for_window_by_nickname(self, nickname):
|
||||
for window in self.windows:
|
||||
if window.nickname == nickname:
|
||||
return window.create_view()
|
||||
|
||||
def pop_window(self):
|
||||
self.windows.pop()
|
||||
|
||||
def delete_window_by_id(self, win_id):
|
||||
for window in self.windows:
|
||||
if window.id == win_id:
|
||||
self.windows.remove(window)
|
||||
break
|
||||
|
||||
def delete_window_by_name(self, name):
|
||||
for window in self.windows:
|
||||
if window.name == name:
|
||||
self.windows.remove(window)
|
||||
break
|
||||
|
||||
def delete_window_by_nickname(self, nickname):
|
||||
for window in self.windows:
|
||||
if window.nickname == nickname:
|
||||
self.windows.remove(window)
|
||||
break
|
||||
|
||||
def get_window_by_id(self, win_id):
|
||||
for window in self.windows:
|
||||
if window.id == win_id:
|
||||
return window
|
||||
|
||||
raise(f"No Window by ID {win_id} found!")
|
||||
|
||||
def get_window_by_name(self, name):
|
||||
for window in self.windows:
|
||||
if window.name == name:
|
||||
return window
|
||||
|
||||
raise(f"No Window by Name {name} found!")
|
||||
|
||||
def get_window_by_nickname(self, nickname):
|
||||
for window in self.windows:
|
||||
if window.nickname == nickname:
|
||||
return window
|
||||
|
||||
raise(f"No Window by Nickname {nickname} found!")
|
||||
|
||||
def get_window_by_index(self, index):
|
||||
return self.windows[index]
|
||||
|
||||
def get_all_windows(self):
|
||||
return self.windows
|
||||
|
||||
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):
|
||||
print("\n[ ---- Windows ---- ]\n")
|
||||
for window in self.windows:
|
||||
print(f"\nID: {window.id}")
|
||||
print(f"Name: {window.name}")
|
||||
print(f"Nickname: {window.nickname}")
|
||||
print(f"Is Hidden: {window.isHidden}")
|
||||
print(f"View Count: {window.get_views_count()}")
|
||||
print("\n-------------------------\n")
|
||||
|
||||
|
||||
|
||||
def list_files_from_views_of_window(self, win_id):
|
||||
for window in self.windows:
|
||||
if window.id == win_id:
|
||||
window.list_files_from_views()
|
||||
break
|
||||
|
||||
def get_views_count(self, win_id):
|
||||
for window in self.windows:
|
||||
if window.id == win_id:
|
||||
return window.get_views_count()
|
||||
|
||||
def get_views_from_window(self, win_id):
|
||||
for window in self.windows:
|
||||
if window.id == win_id:
|
||||
return window.get_all_views()
|
||||
|
||||
|
||||
|
||||
|
||||
def unload_views_and_windows(self):
|
||||
for window in self.windows:
|
||||
window.views.clear()
|
||||
|
||||
self.windows.clear()
|
||||
|
||||
def save_state(self, session_file = None):
|
||||
if not session_file:
|
||||
session_file = self.session_file
|
||||
|
||||
if len(self.windows) > 0:
|
||||
windows = []
|
||||
for window in self.windows:
|
||||
views = []
|
||||
for view in window.views:
|
||||
views.append(view.get_current_directory())
|
||||
|
||||
windows.append(
|
||||
[
|
||||
{
|
||||
'window':{
|
||||
"ID": window.id,
|
||||
"Name": window.name,
|
||||
"Nickname": window.nickname,
|
||||
"isHidden": f"{window.isHidden}",
|
||||
'views': views
|
||||
}
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
with open(session_file, 'w') as outfile:
|
||||
json.dump(windows, outfile, separators=(',', ':'), indent=4)
|
||||
else:
|
||||
raise Exception("Window dara corrupted! Can not save session!")
|
||||
|
||||
def load_state(self, session_file = None):
|
||||
if not session_file:
|
||||
session_file = self.session_file
|
||||
|
||||
if path.isfile(session_file):
|
||||
with open(session_file) as infile:
|
||||
return json.load(infile)
|
|
@ -1,2 +0,0 @@
|
|||
from .Window import Window
|
||||
from .WindowController import WindowController
|
|
@ -0,0 +1,185 @@
|
|||
# Python imports
|
||||
import threading, subprocess, time, json
|
||||
from os import path
|
||||
|
||||
# Lib imports
|
||||
|
||||
# Application imports
|
||||
from .window import Window
|
||||
|
||||
|
||||
def threaded(fn):
|
||||
def wrapper(*args, **kwargs):
|
||||
threading.Thread(target=fn, args=args, kwargs=kwargs, daemon=True).start()
|
||||
return wrapper
|
||||
|
||||
|
||||
class WindowController:
|
||||
def __init__(self):
|
||||
USER_HOME = path.expanduser('~')
|
||||
CONFIG_PATH = USER_HOME + "/.config/solarfm"
|
||||
self._session_file = CONFIG_PATH + "/session.json"
|
||||
|
||||
self._event_sleep_time = 1
|
||||
self._active_window_id = ""
|
||||
self._active_tab_id = ""
|
||||
self._windows = []
|
||||
|
||||
|
||||
def set__wid_and_tid(self, wid, tid):
|
||||
self._active_window_id = str(wid)
|
||||
self._active_tab_id = str(tid)
|
||||
|
||||
def get_active_wid_and_tid(self):
|
||||
return self._active_window_id, self._active_tab_id
|
||||
|
||||
def create_window(self):
|
||||
window = Window()
|
||||
window.set_nickname(f"window_{str(len(self._windows) + 1)}")
|
||||
self._windows.append(window)
|
||||
return window
|
||||
|
||||
|
||||
def add_view_for_window(self, win_id):
|
||||
for window in self._windows:
|
||||
if window.get_id() == win_id:
|
||||
return window.create_view()
|
||||
|
||||
def add_view_for_window_by_name(self, name):
|
||||
for window in self._windows:
|
||||
if window.get_name() == name:
|
||||
return window.create_view()
|
||||
|
||||
def add_view_for_window_by_nickname(self, nickname):
|
||||
for window in self._windows:
|
||||
if window.get_nickname() == nickname:
|
||||
return window.create_view()
|
||||
|
||||
def pop_window(self):
|
||||
self._windows.pop()
|
||||
|
||||
def delete_window_by_id(self, win_id):
|
||||
for window in self._windows:
|
||||
if window.get_id() == win_id:
|
||||
self._windows.remove(window)
|
||||
break
|
||||
|
||||
def delete_window_by_name(self, name):
|
||||
for window in self._windows:
|
||||
if window.get_name() == name:
|
||||
self._windows.remove(window)
|
||||
break
|
||||
|
||||
def delete_window_by_nickname(self, nickname):
|
||||
for window in self._windows:
|
||||
if window.get_nickname() == nickname:
|
||||
self._windows.remove(window)
|
||||
break
|
||||
|
||||
def get_window_by_id(self, win_id):
|
||||
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):
|
||||
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):
|
||||
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):
|
||||
return self._windows[index]
|
||||
|
||||
def get_all_windows(self):
|
||||
return self._windows
|
||||
|
||||
|
||||
def set_window_nickname(self, win_id = None, nickname = ""):
|
||||
for window in self._windows:
|
||||
if window.get_id() == win_id:
|
||||
window.set_nickname(nickname)
|
||||
|
||||
def list_windows(self):
|
||||
print("\n[ ---- Windows ---- ]\n")
|
||||
for window in self._windows:
|
||||
print(f"\nID: {window.get_id()}")
|
||||
print(f"Name: {window.get_name()}")
|
||||
print(f"Nickname: {window.get_nickname()}")
|
||||
print(f"Is Hidden: {window.is_hidden()}")
|
||||
print(f"View Count: {window.get_views_count()}")
|
||||
print("\n-------------------------\n")
|
||||
|
||||
|
||||
|
||||
def list_files_from_views_of_window(self, win_id):
|
||||
for window in self._windows:
|
||||
if window.get_id() == win_id:
|
||||
window.list_files_from_views()
|
||||
break
|
||||
|
||||
def get_views_count(self, win_id):
|
||||
for window in self._windows:
|
||||
if window.get_id() == win_id:
|
||||
return window.get_views_count()
|
||||
|
||||
def get_views_from_window(self, win_id):
|
||||
for window in self._windows:
|
||||
if window.get_id() == win_id:
|
||||
return window.get_all_views()
|
||||
|
||||
|
||||
|
||||
|
||||
def unload_views_and_windows(self):
|
||||
for window in self._windows:
|
||||
window.get_all_views().clear()
|
||||
|
||||
self._windows.clear()
|
||||
|
||||
def save_state(self, session_file = None):
|
||||
if not session_file:
|
||||
session_file = self._session_file
|
||||
|
||||
if len(self._windows) > 0:
|
||||
windows = []
|
||||
for window in self._windows:
|
||||
views = []
|
||||
for view in window.get_all_views():
|
||||
views.append(view.get_current_directory())
|
||||
|
||||
windows.append(
|
||||
[
|
||||
{
|
||||
'window':{
|
||||
"ID": window.get_id(),
|
||||
"Name": window.get_name(),
|
||||
"Nickname": window.get_nickname(),
|
||||
"isHidden": f"{window.is_hidden()}",
|
||||
'views': views
|
||||
}
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
with open(session_file, 'w') as outfile:
|
||||
json.dump(windows, outfile, separators=(',', ':'), indent=4)
|
||||
else:
|
||||
raise Exception("Window data corrupted! Can not save session!")
|
||||
|
||||
def load_state(self, session_file = None):
|
||||
if not session_file:
|
||||
session_file = self._session_file
|
||||
|
||||
if path.isfile(session_file):
|
||||
with open(session_file) as infile:
|
||||
return json.load(infile)
|
|
@ -1,5 +0,0 @@
|
|||
from .utils import *
|
||||
from .icons import *
|
||||
|
||||
from .Path import Path
|
||||
from .View import View
|
|
@ -1,4 +0,0 @@
|
|||
from .mixins import DesktopIconMixin
|
||||
from .mixins import VideoIconMixin
|
||||
|
||||
from .Icon import Icon
|
|
@ -1,4 +0,0 @@
|
|||
from . import xdg
|
||||
|
||||
from .VideoIconMixin import VideoIconMixin
|
||||
from .DesktopIconMixin import DesktopIconMixin
|
|
@ -1,3 +0,0 @@
|
|||
from .Settings import Settings
|
||||
from .Launcher import Launcher
|
||||
from .FileHandler import FileHandler
|
|
@ -3,10 +3,13 @@ import os, subprocess, threading, hashlib
|
|||
from os.path import isfile
|
||||
|
||||
# Gtk imports
|
||||
import gi
|
||||
gi.require_version('GdkPixbuf', '2.0')
|
||||
from gi.repository import GdkPixbuf
|
||||
|
||||
# Application imports
|
||||
from .mixins import *
|
||||
from .mixins.desktopiconmixin import DesktopIconMixin
|
||||
from .mixins.videoiconmixin import VideoIconMixin
|
||||
|
||||
|
||||
def threaded(fn):
|
|
@ -1,6 +1,5 @@
|
|||
# Python imports
|
||||
import hashlib
|
||||
import os
|
||||
import os, hashlib, re
|
||||
from os import listdir
|
||||
from os.path import isdir, isfile, join
|
||||
|
||||
|
@ -11,64 +10,43 @@ from random import randint
|
|||
|
||||
|
||||
# Application imports
|
||||
from .utils import Settings, Launcher, FileHandler
|
||||
from .icons import Icon
|
||||
from . import Path
|
||||
from .utils.settings import Settings
|
||||
from .utils.launcher import Launcher
|
||||
from .utils.filehandler import FileHandler
|
||||
|
||||
from .icons.icon import Icon
|
||||
from .path import Path
|
||||
|
||||
|
||||
class View(Settings, FileHandler, Launcher, Icon, Path):
|
||||
def __init__(self):
|
||||
self. logger = None
|
||||
self.id_length = 10
|
||||
self.logger = None
|
||||
self._id_length = 10
|
||||
|
||||
self.id = ""
|
||||
self.wid = 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._id = ""
|
||||
self._wid = 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.generate_id()
|
||||
self._generate_id()
|
||||
self.set_to_home()
|
||||
|
||||
|
||||
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))
|
||||
|
||||
def get_tab_id(self):
|
||||
return self.id
|
||||
|
||||
def set_wid(self, _wid):
|
||||
self.wid = _wid
|
||||
|
||||
def get_wid(self):
|
||||
return self.wid
|
||||
|
||||
def set_dir_watcher(self, watcher):
|
||||
self.dir_watcher = watcher
|
||||
|
||||
def get_dir_watcher(self):
|
||||
return self.dir_watcher
|
||||
|
||||
def load_directory(self):
|
||||
path = self.get_path()
|
||||
self.dirs = []
|
||||
self.vids = []
|
||||
self.images = []
|
||||
self.desktop = []
|
||||
self.ungrouped = []
|
||||
self.hidden = []
|
||||
self.files = []
|
||||
self._dirs = []
|
||||
self._vids = []
|
||||
self._images = []
|
||||
self._desktop = []
|
||||
self._ungrouped = []
|
||||
self._hidden = []
|
||||
self._files = []
|
||||
|
||||
if not isdir(path):
|
||||
self.set_to_home()
|
||||
|
@ -76,40 +54,31 @@ class View(Settings, FileHandler, Launcher, Icon, Path):
|
|||
|
||||
for f in listdir(path):
|
||||
file = join(path, f)
|
||||
if self.hide_hidden:
|
||||
if self._hide_hidden:
|
||||
if f.startswith('.'):
|
||||
self.hidden.append(f)
|
||||
self._hidden.append(f)
|
||||
continue
|
||||
|
||||
if isfile(file):
|
||||
lowerName = file.lower()
|
||||
if lowerName.endswith(self.fvideos):
|
||||
self.vids.append(f)
|
||||
self._vids.append(f)
|
||||
elif lowerName.endswith(self.fimages):
|
||||
self.images.append(f)
|
||||
self._images.append(f)
|
||||
elif lowerName.endswith((".desktop",)):
|
||||
self.desktop.append(f)
|
||||
self._desktop.append(f)
|
||||
else:
|
||||
self.ungrouped.append(f)
|
||||
self._ungrouped.append(f)
|
||||
else:
|
||||
self.dirs.append(f)
|
||||
self._dirs.append(f)
|
||||
|
||||
self.dirs.sort()
|
||||
self.vids.sort()
|
||||
self.images.sort()
|
||||
self.desktop.sort()
|
||||
self.ungrouped.sort()
|
||||
self._dirs.sort(key=self._natural_keys)
|
||||
self._vids.sort(key=self._natural_keys)
|
||||
self._images.sort(key=self._natural_keys)
|
||||
self._desktop.sort(key=self._natural_keys)
|
||||
self._ungrouped.sort(key=self._natural_keys)
|
||||
|
||||
self.files = self.dirs + self.vids + self.images + self.desktop + self.ungrouped
|
||||
|
||||
def hash_text(self, text):
|
||||
return hashlib.sha256(str.encode(text)).hexdigest()[:18]
|
||||
|
||||
def hash_set(self, arry):
|
||||
data = []
|
||||
for arr in arry:
|
||||
data.append([arr, self.hash_text(arr)])
|
||||
return data
|
||||
self._files = self._dirs + self._vids + self._images + self._desktop + self._ungrouped
|
||||
|
||||
def is_folder_locked(self, hash):
|
||||
if self.lock_folder:
|
||||
|
@ -129,18 +98,18 @@ class View(Settings, FileHandler, Launcher, Icon, Path):
|
|||
|
||||
|
||||
def get_not_hidden_count(self):
|
||||
return len(self.files) + \
|
||||
len(self.dirs) + \
|
||||
len(self.vids) + \
|
||||
len(self.images) + \
|
||||
len(self.desktop) + \
|
||||
len(self.ungrouped)
|
||||
return len(self._files) + \
|
||||
len(self._dirs) + \
|
||||
len(self._vids) + \
|
||||
len(self._images) + \
|
||||
len(self._desktop) + \
|
||||
len(self._ungrouped)
|
||||
|
||||
def get_hidden_count(self):
|
||||
return len(self.hidden)
|
||||
return len(self._hidden)
|
||||
|
||||
def get_files_count(self):
|
||||
return len(self.files)
|
||||
return len(self._files)
|
||||
|
||||
def get_path_part_from_hash(self, hash):
|
||||
files = self.get_files()
|
||||
|
@ -154,13 +123,13 @@ class View(Settings, FileHandler, Launcher, Icon, Path):
|
|||
return file
|
||||
|
||||
def get_files_formatted(self):
|
||||
files = self.hash_set(self.files),
|
||||
dirs = self.hash_set(self.dirs),
|
||||
files = self._hash_set(self._files),
|
||||
dirs = self._hash_set(self._dirs),
|
||||
videos = self.get_videos(),
|
||||
images = self.hash_set(self.images),
|
||||
desktops = self.hash_set(self.desktop),
|
||||
ungrouped = self.hash_set(self.ungrouped)
|
||||
hidden = self.hash_set(self.hidden)
|
||||
images = self._hash_set(self._images),
|
||||
desktops = self._hash_set(self._desktop),
|
||||
ungrouped = self._hash_set(self._ungrouped)
|
||||
hidden = self._hash_set(self._hidden)
|
||||
|
||||
return {
|
||||
'path_head': self.get_path(),
|
||||
|
@ -178,7 +147,7 @@ class View(Settings, FileHandler, Launcher, Icon, Path):
|
|||
def get_pixbuf_icon_str_combo(self):
|
||||
data = []
|
||||
dir = self.get_current_directory()
|
||||
for file in self.files:
|
||||
for file in self._files:
|
||||
icon = self.create_icon(dir, file).get_pixbuf()
|
||||
data.append([icon, file])
|
||||
|
||||
|
@ -188,7 +157,7 @@ class View(Settings, FileHandler, Launcher, Icon, Path):
|
|||
def get_gtk_icon_str_combo(self):
|
||||
data = []
|
||||
dir = self.get_current_directory()
|
||||
for file in self.files:
|
||||
for file in self._files:
|
||||
icon = self.create_icon(dir, file)
|
||||
data.append([icon, file[0]])
|
||||
|
||||
|
@ -207,23 +176,69 @@ class View(Settings, FileHandler, Launcher, Icon, Path):
|
|||
size = len(parts)
|
||||
return parts[size - 1]
|
||||
|
||||
|
||||
|
||||
def is_hiding_hidden(self):
|
||||
return self._hide_hidden
|
||||
|
||||
def get_dot_dots(self):
|
||||
return self.hash_set(['.', '..'])
|
||||
return self._hash_set(['.', '..'])
|
||||
|
||||
def get_files(self):
|
||||
return self.hash_set(self.files)
|
||||
return self._hash_set(self._files)
|
||||
|
||||
def get_dirs(self):
|
||||
return self.hash_set(self.dirs)
|
||||
return self._hash_set(self._dirs)
|
||||
|
||||
def get_videos(self):
|
||||
return self.hash_set(self.vids)
|
||||
return self._hash_set(self._vids)
|
||||
|
||||
def get_images(self):
|
||||
return self.hash_set(self.images)
|
||||
return self._hash_set(self._images)
|
||||
|
||||
def get_desktops(self):
|
||||
return self.hash_set(self.desktop)
|
||||
return self._hash_set(self._desktop)
|
||||
|
||||
def get_ungrouped(self):
|
||||
return self.hash_set(self.ungrouped)
|
||||
return self._hash_set(self._ungrouped)
|
||||
|
||||
def get_hidden(self):
|
||||
return self._hash_set(self._hidden)
|
||||
|
||||
def get_id(self):
|
||||
return self._id
|
||||
|
||||
def set_wid(self, _wid):
|
||||
self._wid = _wid
|
||||
|
||||
def get_wid(self):
|
||||
return self._wid
|
||||
|
||||
def set_dir_watcher(self, watcher):
|
||||
self._dir_watcher = watcher
|
||||
|
||||
def get_dir_watcher(self):
|
||||
return self._dir_watcher
|
||||
|
||||
def _atoi(self, text):
|
||||
return int(text) if text.isdigit() else text
|
||||
|
||||
def _natural_keys(self, text):
|
||||
return [ self._atoi(c) for c in re.split('(\d+)',text) ]
|
||||
|
||||
def _hash_text(self, text):
|
||||
return hashlib.sha256(str.encode(text)).hexdigest()[:18]
|
||||
|
||||
def _hash_set(self, arry):
|
||||
data = []
|
||||
for arr in arry:
|
||||
data.append([arr, self._hash_text(arr)])
|
||||
return data
|
||||
|
||||
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))
|
|
@ -0,0 +1,89 @@
|
|||
# Python imports
|
||||
from random import randint
|
||||
|
||||
|
||||
# Lib imports
|
||||
|
||||
|
||||
# Application imports
|
||||
from .views.view import View
|
||||
|
||||
|
||||
class Window:
|
||||
def __init__(self):
|
||||
self._id_length = 10
|
||||
self._id = ""
|
||||
self._name = ""
|
||||
self._nickname = ""
|
||||
self._isHidden = False
|
||||
self._views = []
|
||||
|
||||
self._generate_id()
|
||||
self._set_name()
|
||||
|
||||
|
||||
def create_view(self):
|
||||
view = View()
|
||||
self._views.append(view)
|
||||
return view
|
||||
|
||||
def pop_view(self):
|
||||
self._views.pop()
|
||||
|
||||
def delete_view_by_id(self, vid):
|
||||
for view in self._views:
|
||||
if view.get_id() == vid:
|
||||
self._views.remove(view)
|
||||
break
|
||||
|
||||
|
||||
def get_view_by_id(self, vid):
|
||||
for view in self._views:
|
||||
if view.get_id() == vid:
|
||||
return view
|
||||
|
||||
def get_view_by_index(self, index):
|
||||
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.get_files())
|
||||
|
||||
|
||||
def get_id(self):
|
||||
return self._id
|
||||
|
||||
def get_name(self):
|
||||
return self._name
|
||||
|
||||
def get_nickname(self):
|
||||
return self._nickname
|
||||
|
||||
def is_hidden(self):
|
||||
return self._isHidden
|
||||
|
||||
|
||||
|
||||
|
||||
def set_nickname(self, nickname):
|
||||
self._nickname = f"{nickname}"
|
||||
|
||||
def set_is_hidden(self, state):
|
||||
self._isHidden = f"{state}"
|
||||
|
||||
def _set_name(self):
|
||||
self._name = "window_" + self.get_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))
|
|
@ -643,6 +643,21 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
|
|||
<object class="GtkButtonBox">
|
||||
<property name="can-focus">False</property>
|
||||
<property name="layout-style">end</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="button9">
|
||||
<property name="label">gtk-cancel</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="use-stock">True</property>
|
||||
<property name="always-show-image">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button10">
|
||||
<property name="label" translatable="yes">Create</property>
|
||||
|
@ -657,21 +672,6 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
|
|||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button9">
|
||||
<property name="label">gtk-cancel</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="use-stock">True</property>
|
||||
<property name="always-show-image">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
@ -783,8 +783,8 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
|
|||
</object>
|
||||
</child>
|
||||
<action-widgets>
|
||||
<action-widget response="-10">button10</action-widget>
|
||||
<action-widget response="-6">button9</action-widget>
|
||||
<action-widget response="-10">button10</action-widget>
|
||||
</action-widgets>
|
||||
</object>
|
||||
<object class="GtkImage" id="exec_in_term_img">
|
||||
|
@ -1246,14 +1246,13 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
|
|||
<property name="can-focus">False</property>
|
||||
<property name="layout-style">end</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="button1">
|
||||
<property name="label" translatable="yes">Skip</property>
|
||||
<property name="name">skip_renames</property>
|
||||
<object class="GtkButton" id="button2">
|
||||
<property name="label">gtk-cancel</property>
|
||||
<property name="name">cancel_renames</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="image">skip_img</property>
|
||||
<property name="always-show-image">True</property>
|
||||
<property name="use-stock">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
|
@ -1262,13 +1261,14 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button2">
|
||||
<property name="label">gtk-cancel</property>
|
||||
<property name="name">cancel_renames</property>
|
||||
<object class="GtkButton" id="button1">
|
||||
<property name="label" translatable="yes">Skip</property>
|
||||
<property name="name">skip_renames</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="use-stock">True</property>
|
||||
<property name="image">skip_img</property>
|
||||
<property name="always-show-image">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
|
@ -1366,8 +1366,8 @@ SolarFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspe
|
|||
</object>
|
||||
</child>
|
||||
<action-widgets>
|
||||
<action-widget response="-7">button1</action-widget>
|
||||
<action-widget response="-6">button2</action-widget>
|
||||
<action-widget response="-7">button1</action-widget>
|
||||
</action-widgets>
|
||||
</object>
|
||||
<object class="GtkImage" id="tggl_notebook_1_img">
|
||||
|
|
Loading…
Reference in New Issue