From 96f3ba0735966b6ffe0a90d5e54fa70dff7b8020 Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Sat, 27 Nov 2021 22:03:00 -0600 Subject: [PATCH] Added initial status bottom bar info --- .../PyFM/new/pyfm/resources/Main_Window.glade | 51 ++++++++++++++++++- .../new/pyfm/shellfm/windows/view/View.py | 15 ++++++ .../pyfm/signal_classes/Controller_Data.py | 4 ++ .../signal_classes/DBusControllerMixin.py | 12 ++++- .../mixins/WidgetFileActionMixin.py | 1 + .../pyfm/signal_classes/mixins/WindowMixin.py | 18 ++++++- 6 files changed, 97 insertions(+), 4 deletions(-) diff --git a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/resources/Main_Window.glade b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/resources/Main_Window.glade index ae0636f..5965ef4 100644 --- a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/resources/Main_Window.glade +++ b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/resources/Main_Window.glade @@ -1333,7 +1333,56 @@ PyFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspecti - + + True + False + 10 + 10 + 10 + 10 + 6 + 6 + 15 + top + + + True + False + + + False + True + 0 + + + + + True + False + + + False + True + 1 + + + + + True + False + + + False + True + 2 + + + + + False + True + 3 + diff --git a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/shellfm/windows/view/View.py b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/shellfm/windows/view/View.py index 719c423..a4f1d73 100644 --- a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/shellfm/windows/view/View.py +++ b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/shellfm/windows/view/View.py @@ -31,6 +31,7 @@ class View(Settings, FileHandler, Launcher, Icon, Path): self.images = [] self.desktop = [] self.ungrouped = [] + self.hidden = [] self.generate_id() self.set_to_home() @@ -66,6 +67,7 @@ class View(Settings, FileHandler, Launcher, Icon, Path): self.images = [] self.desktop = [] self.ungrouped = [] + self.hidden = [] self.files = [] if not isdir(path): @@ -76,6 +78,7 @@ class View(Settings, FileHandler, Launcher, Icon, Path): file = join(path, f) if self.hide_hidden: if f.startswith('.'): + self.hidden.append(f) continue if isfile(file): @@ -125,7 +128,19 @@ class View(Settings, FileHandler, Launcher, Icon, Path): return False + 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) + def get_hidden_count(self): + return len(self.hidden) + + def get_files_count(self): + return len(self.files) def get_path_part_from_hash(self, hash): files = self.get_files() diff --git a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/Controller_Data.py b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/Controller_Data.py index 9a1c644..529a11a 100644 --- a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/Controller_Data.py +++ b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/Controller_Data.py @@ -25,6 +25,10 @@ class Controller_Data: self.message_widget = self.builder.get_object("message_widget") self.message_label = self.builder.get_object("message_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_path_label = self.builder.get_object("bottom_path_label") + self.notebooks = [self.window1, self.window2, self.window3, self.window4] self.selected_files = [] self.to_rename_files = [] diff --git a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/DBusControllerMixin.py b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/DBusControllerMixin.py index ae0813f..2f8f955 100644 --- a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/DBusControllerMixin.py +++ b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/DBusControllerMixin.py @@ -1,5 +1,5 @@ # Python imports -import threading, socket +import threading, socket, time from multiprocessing.connection import Listener, Client # Gtk imports @@ -20,7 +20,9 @@ class DBusControllerMixin: listener = Listener(('127.0.0.1', 4848), authkey=b'pyfm-ipc') self.is_ipc_alive = True while event_system.keep_ipc_alive: - conn = listener.accept() + conn = listener.accept() + start_time = time.time() + print(f"New Connection: {listener.last_accepted}") while True: msg = conn.recv() @@ -43,6 +45,12 @@ class DBusControllerMixin: conn.close() event_system.keep_ipc_alive = False break + + # NOTE: Not perfect but insures we don't lockup the connection for too long. + end_time = time.time() + if (end - start) > 15.0: + conn.close() + listener.close() diff --git a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/mixins/WidgetFileActionMixin.py b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/mixins/WidgetFileActionMixin.py index f8545d2..f7768fb 100644 --- a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/mixins/WidgetFileActionMixin.py +++ b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/mixins/WidgetFileActionMixin.py @@ -42,6 +42,7 @@ class WidgetFileActionMixin: view.load_directory() self.load_store(view, store) tab_label.set_label(view.get_end_of_path()) + self.set_bottom_labels(view) diff --git a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/mixins/WindowMixin.py b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/mixins/WindowMixin.py index 2f20ef1..f76fe3f 100644 --- a/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/mixins/WindowMixin.py +++ b/src/versions/pyfm-0.0.1/PyFM/new/pyfm/signal_classes/mixins/WindowMixin.py @@ -39,11 +39,25 @@ class WindowMixin(TabMixin): return uris + + def set_bottom_labels(self, view): + self.bottom_size_label.set_label("TBD") + if view.hide_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: + self.bottom_file_count_label.set_label(f"{view.get_files_count()} items") + else: + self.bottom_file_count_label.set_label(f"{view.get_files_count()} items") + self.bottom_path_label.set_label(view.get_current_directory()) + + def set_window_title(self): wid, tid = self.window_controller.get_active_data() view = self.get_fm_window(wid).get_view_by_id(tid) dir = view.get_current_directory() self.window.set_title("PyFM ~ " + dir) + self.set_bottom_labels(view) def set_path_text(self, wid, tid): path_entry = self.builder.get_object("path_entry") @@ -68,6 +82,7 @@ class WindowMixin(TabMixin): except Exception as e: print(repr(e)) + self.display_message(self.error, f"{repr(e)}") def grid_icon_double_left_click(self, iconview, item, data=None): try: @@ -95,8 +110,9 @@ class WindowMixin(TabMixin): tab_label.set_label(view.get_end_of_path()) path_entry.set_text(view.get_current_directory()) self.set_file_watcher(view) + self.set_bottom_labels(view) except Exception as e: - print(repr(e)) + self.display_message(self.error, f"{repr(e)}")