From 98ffd7c6b0a2c26b76df726ea8968c2304dc9375 Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Sun, 7 May 2023 14:50:39 -0500 Subject: [PATCH] added labels, added window preservation logic --- src/core/containers/base_container.py | 6 + src/core/window.py | 37 +++-- src/utils/settings/settings.py | 22 +-- user_config/usr/share/pulstar/settings.json | 153 ++++++++++++++----- user_config/usr/share/pulstar/stylesheet.css | 7 +- 5 files changed, 161 insertions(+), 64 deletions(-) diff --git a/src/core/containers/base_container.py b/src/core/containers/base_container.py index 761b321..b93e324 100644 --- a/src/core/containers/base_container.py +++ b/src/core/containers/base_container.py @@ -47,18 +47,24 @@ class BaseContainer(Gtk.Box): scroll = SinkInputList(self.pulse) box = scroll.get_box() + label2 = Gtk.Label("Playback") + label2.set_xalign(0.0) for sink_input in self.sink_inputs: box.add( AudioSink(self.pulse, sink_input) ) + self.add(label2) self.add(scroll) self._set_pulse_event_listener() def _load_pulse_data(self): try: + label1 = Gtk.Label("Output Devices") pulse = pulsectl.Pulse() self.pulse_events = pulsectl.Pulse('event-printer') si, sink_inputs, modules, clients, sink_list = pulse.server_info(), pulse.sink_input_list(), pulse.module_list(), pulse.client_list(), pulse.sink_list() + self.add(label1) + label1.set_xalign(0.0) logger.debug(f"\n\nServer Info\n{si}\n\nSink Inputs:") for sink in sink_list: self.add( AudioSink(pulse, sink) ) diff --git a/src/core/window.py b/src/core/window.py index d31f2eb..bcc05ea 100644 --- a/src/core/window.py +++ b/src/core/window.py @@ -26,6 +26,7 @@ class Window(Gtk.ApplicationWindow): def __init__(self, args, unknownargs): super(Window, self).__init__() + settings.set_main_window(self) self._controller = None @@ -33,27 +34,21 @@ class Window(Gtk.ApplicationWindow): self._setup_styling() self._setup_signals() self._subscribe_to_events() - - settings.set_main_window(self) self._load_widgets(args, unknownargs) - self.show() - - # NOTE: Need to set size after show b/c get_allocation methods are initially incorrect if done beforehand... self._set_size_constraints() + self.show() def _setup_styling(self): - self.set_default_size(settings.get_main_window_width(), - settings.get_main_window_height()) self.set_title(f"{app_name}") self.set_icon_from_file( settings.get_window_icon() ) self.set_gravity(5) # 5 = CENTER self.set_position(1) # 1 = CENTER, 4 = CENTER_ALWAYS def _setup_signals(self): - self.connect("delete-event", self._tear_down) GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT, self._tear_down) + self.connect("delete-event", self._tear_down) def _subscribe_to_events(self): event_system.subscribe("tear_down", self._tear_down) @@ -62,7 +57,6 @@ class Window(Gtk.ApplicationWindow): if settings.is_debug(): self.set_interactive_debugging(True) - self._controller = Controller(args, unknownargs) if not self._controller: raise ControllerStartException("Controller exited and doesn't exist...") @@ -70,10 +64,16 @@ class Window(Gtk.ApplicationWindow): self.add( self._controller.get_base_container() ) def _set_size_constraints(self): - self.set_default_size(settings.get_main_window_width(), - settings.get_main_window_height()) - self.set_size_request(settings.get_main_window_min_width(), - settings.get_main_window_min_height()) + _window_x = settings.get_main_window_x() + _window_y = settings.get_main_window_y() + _min_width = settings.get_main_window_min_width() + _min_height = settings.get_main_window_min_height() + _width = settings.get_main_window_width() + _height = settings.get_main_window_height() + + self.move(_window_x, _window_y - 28) + self.set_size_request(_min_width, _min_height) + self.set_default_size(_width, _height) def _set_window_data(self) -> None: screen = self.get_screen() @@ -98,7 +98,16 @@ class Window(Gtk.ApplicationWindow): cr.set_operator(cairo.OPERATOR_OVER) - def _tear_down(self, widget=None, eve=None): + def _tear_down(self, widget = None, eve = None): + size = self.get_default_size() + pos = self.get_position() + + settings.set_main_window_width(size.width) + settings.set_main_window_height(size.height) + settings.set_main_window_x(pos.root_x) + settings.set_main_window_y(pos.root_y) + settings.save_settings() + settings.clear_pid() time.sleep(event_sleep_time) Gtk.main_quit() diff --git a/src/utils/settings/settings.py b/src/utils/settings/settings.py index d7bd8c8..574c9b0 100644 --- a/src/utils/settings/settings.py +++ b/src/utils/settings/settings.py @@ -84,11 +84,6 @@ class Settings(StartCheckMixin, Singleton): self._main_window = None - self._main_window_w = 800 - self._main_window_h = 600 - self._main_window_mw = 720 - self._main_window_mh = 480 - self._builder = None self.PAINT_BG_COLOR = (0, 0, 0, 0.54) @@ -126,10 +121,12 @@ class Settings(StartCheckMixin, Singleton): return monitors def get_main_window(self) -> any: return self._main_window - def get_main_window_width(self) -> any: return self._main_window_w - def get_main_window_height(self) -> any: return self._main_window_h - def get_main_window_min_width(self) -> any: return self._main_window_mw - def get_main_window_min_height(self) -> any: return self._main_window_mh + def get_main_window_x(self) -> any: return self._settings["config"]["window_x"] + def get_main_window_y(self) -> any: return self._settings["config"]["window_y"] + def get_main_window_width(self) -> any: return self._settings["config"]["window_width"] + def get_main_window_height(self) -> any: return self._settings["config"]["window_height"] + def get_main_window_min_width(self) -> any: return self._settings["config"]["window_min_width"] + def get_main_window_min_height(self) -> any: return self._settings["config"]["window_min_height"] def get_builder(self) -> any: return self._builder def get_paint_bg_color(self) -> any: return self.PAINT_BG_COLOR def get_ui_widgets_path(self) -> str: return self._UI_WIDEGTS_PATH @@ -161,6 +158,13 @@ class Settings(StartCheckMixin, Singleton): def get_ch_log_lvl(self) -> str: return self._settings["debugging"]["ch_log_lvl"] def get_fh_log_lvl(self) -> str: return self._settings["debugging"]["fh_log_lvl"] + def set_main_window_x(self, x = 0): self._settings["config"]["window_x"] = x + def set_main_window_y(self, y = 0): self._settings["config"]["window_y"] = y + def set_main_window_width(self, width = 800): self._settings["config"]["window_width"] = width + def set_main_window_height(self, height = 600): self._settings["config"]["window_height"] = height + def set_main_window_min_width(self, width = 720): self._settings["config"]["window_min_width"] = width + def set_main_window_min_height(self, height = 480): self._settings["config"]["window_min_height"] = height + def set_trace_debug(self, trace_debug): self._trace_debug = trace_debug diff --git a/user_config/usr/share/pulstar/settings.json b/user_config/usr/share/pulstar/settings.json index 9b0686d..2c40824 100644 --- a/user_config/usr/share/pulstar/settings.json +++ b/user_config/usr/share/pulstar/settings.json @@ -1,41 +1,118 @@ { - "config": { - "base_of_home": "", - "hide_hidden_files": "true", - "thumbnailer_path": "ffmpegthumbnailer", - "go_past_home": "true", - "lock_folder": "false", - "locked_folders": "venv::::flasks", - "mplayer_options": "-quiet -really-quiet -xy 1600 -geometry 50%:50%", - "music_app": "/opt/deadbeef/bin/deadbeef", - "media_app": "mpv", - "image_app": "mirage", - "office_app": "libreoffice", - "pdf_app": "evince", - "text_app": "leafpad", - "file_manager_app": "solarfm", - "terminal_app": "terminator", - "remux_folder_max_disk_usage": "8589934592", - "make_transparent": 0 + "config":{ + "base_of_home":"", + "hide_hidden_files":"true", + "thumbnailer_path":"ffmpegthumbnailer", + "go_past_home":"true", + "lock_folder":"false", + "locked_folders":"venv::::flasks", + "mplayer_options":"-quiet -really-quiet -xy 1600 -geometry 50%:50%", + "music_app":"/opt/deadbeef/bin/deadbeef", + "media_app":"mpv", + "image_app":"mirage", + "office_app":"libreoffice", + "pdf_app":"evince", + "text_app":"leafpad", + "file_manager_app":"solarfm", + "terminal_app":"terminator", + "remux_folder_max_disk_usage":"8589934592", + "make_transparent":0, + "window_x":720, + "window_y":720, + "window_min_width":720, + "window_min_height":480, + "window_width":800, + "window_height":600 }, - "filters": { - "meshs": [".blend", ".dae", ".fbx", ".gltf", ".obj", ".stl"], - "code": [".cpp", ".css", ".c", ".go", ".html", ".htm", ".java", ".js", ".json", ".lua", ".md", ".py", ".rs", ".toml", ".xml", ".pom"], - "videos": [".mkv", ".mp4", ".webm", ".avi", ".mov", ".m4v", ".mpg", ".mpeg", ".wmv", ".flv"], - "office": [".doc", ".docx", ".xls", ".xlsx", ".xlt", ".xltx", ".xlm", ".ppt", ".pptx", ".pps", ".ppsx", ".odt", ".rtf"], - "images": [".png", ".jpg", ".jpeg", ".gif", ".ico", ".tga", ".webp"], - "text": [".txt", ".text", ".sh", ".cfg", ".conf", ".log"], - "music": [".psf", ".mp3", ".ogg", ".flac", ".m4a"], - "pdf": [".pdf"] - - }, - "theming":{ - "success_color":"#88cc27", - "warning_color":"#ffa800", - "error_color":"#ff0000" - }, - "debugging": { - "ch_log_lvl": 20, - "fh_log_lvl": 20 - } + "filters":{ + "meshs":[ + ".blend", + ".dae", + ".fbx", + ".gltf", + ".obj", + ".stl" + ], + "code":[ + ".cpp", + ".css", + ".c", + ".go", + ".html", + ".htm", + ".java", + ".js", + ".json", + ".lua", + ".md", + ".py", + ".rs", + ".toml", + ".xml", + ".pom" + ], + "videos":[ + ".mkv", + ".mp4", + ".webm", + ".avi", + ".mov", + ".m4v", + ".mpg", + ".mpeg", + ".wmv", + ".flv" + ], + "office":[ + ".doc", + ".docx", + ".xls", + ".xlsx", + ".xlt", + ".xltx", + ".xlm", + ".ppt", + ".pptx", + ".pps", + ".ppsx", + ".odt", + ".rtf" + ], + "images":[ + ".png", + ".jpg", + ".jpeg", + ".gif", + ".ico", + ".tga", + ".webp" + ], + "text":[ + ".txt", + ".text", + ".sh", + ".cfg", + ".conf", + ".log" + ], + "music":[ + ".psf", + ".mp3", + ".ogg", + ".flac", + ".m4a" + ], + "pdf":[ + ".pdf" + ] + }, + "theming":{ + "success_color":"#88cc27", + "warning_color":"#ffa800", + "error_color":"#ff0000" + }, + "debugging":{ + "ch_log_lvl":20, + "fh_log_lvl":20 + } } diff --git a/user_config/usr/share/pulstar/stylesheet.css b/user_config/usr/share/pulstar/stylesheet.css index a9e501f..43c0aca 100644 --- a/user_config/usr/share/pulstar/stylesheet.css +++ b/user_config/usr/share/pulstar/stylesheet.css @@ -1,7 +1,8 @@ -/* * { - background: rgba(0, 0, 0, 0.14); +* { + /* background: rgba(0, 0, 0, 0.14); */ color: rgba(255, 255, 255, 1); -} */ + border: 2px solid rgba(0, 0, 0, 0.0); +} .sink-list-container { /* Neon Blue 00e8ff border */