From 4b940b71351bd1392eced23d4e8d3a2ee9626cb3 Mon Sep 17 00:00:00 2001 From: DYefremov Date: Sun, 15 Aug 2021 14:37:21 +0300 Subject: [PATCH] gui rework --- app/ui/control.glade | 2760 +++++++------- app/ui/control.py | 3 +- app/ui/{main_window.glade => main.glade} | 3325 ++++++++--------- app/ui/{main_app_window.py => main.py} | 127 +- ...tellites_dialog.glade => satellites.glade} | 628 ++-- .../{satellites_dialog.py => satellites.py} | 53 +- app/ui/uicommons.py | 11 + start.py | 2 +- 8 files changed, 3297 insertions(+), 3612 deletions(-) rename app/ui/{main_window.glade => main.glade} (65%) rename app/ui/{main_app_window.py => main.py} (97%) rename app/ui/{satellites_dialog.glade => satellites.glade} (83%) rename app/ui/{satellites_dialog.py => satellites.py} (95%) diff --git a/app/ui/control.glade b/app/ui/control.glade index ce824e55..7a31018d 100644 --- a/app/ui/control.glade +++ b/app/ui/control.glade @@ -1,5 +1,5 @@ - @@ -385,79 +272,33 @@ Author: Dmitriy Yefremov - + + True False - True - center-on-parent - True - applications-utilities - True - True - center - - - + 1 + 1 + 1 + 1 + 0 + in + + True False - Satellites edit tool - True + 5 + 5 + 5 + 5 + vertical + 5 - + True False - 2 - - - True - True - True - left_header_menu - - - True - False - find-location-symbolic - - - - - False - True - 0 - - - - - True - False - - - False - True - 1 - - - - - True - True - True - Save - - - - True - False - gtk-save - - - - - False - True - 3 - - + 15 + 15 + 5 + 5 True @@ -476,220 +317,231 @@ Author: Dmitriy Yefremov False True - 4 + 0 + + + + + False + True + 0 + + + + + True + True + in + + + True + True + satellites_tree_store + 0 + True + True + + + + + + multiple + + + + + True + 250 + Satellite + True + 0.5 + + + end + + + 0 + + + + + + + True + 20 + Freq + True + 0.5 + + + + 1 + + + + + + + True + 20 + Rate + True + 0.5 + + + + 2 + + + + + + + True + 20 + Pol + True + 0.5 + + + + 3 + + + + + + + True + 20 + FEC + True + 0.5 + + + + 4 + + + + + + + True + 20 + System + True + 0.5 + + + + 5 + + + + + + + True + 20 + Mod + True + 0.5 + + + + 6 + + + + + + + False + True + Pls mode + True + + + + 7 + + + + + + + False + True + Pls code + True + + + + 8 + + + + + + + False + True + Is ID + True + + + + 9 + + + + + + + False + True + Flags + + + + 10 + + + + + + + False + True + Pos: + + + + 11 + + + + + + + + + True + True + 1 + + + + - - - 480 - 250 - True - True - 1 - 1 - 1 - 1 - in - 320 - 240 - - - True - True - satellites_tree_store - 0 - True - True - - - - - - multiple - - - - - True - 250 - Satellite - True - 0.5 - - - end - - - 0 - - - - - - - True - 20 - Freq - True - 0.5 - - - - 1 - - - - - - - True - 20 - Rate - True - 0.5 - - - - 2 - - - - - - - True - 20 - Pol - True - 0.5 - - - - 3 - - - - - - - True - 20 - FEC - True - 0.5 - - - - 4 - - - - - - - True - 20 - System - True - 0.5 - - - - 5 - - - - - - - True - 20 - Mod - True - 0.5 - - - - 6 - - - - - - - False - True - Pls mode - True - - - - 7 - - - - - - - False - True - Pls code - True - - - - 8 - - - - - - - False - True - Is ID - True - - - - 9 - - - - - - - False - True - Flags - - - - 10 - - - - - - - False - True - Pos: - - - - 11 - - - - - - - + + diff --git a/app/ui/satellites_dialog.py b/app/ui/satellites.py similarity index 95% rename from app/ui/satellites_dialog.py rename to app/ui/satellites.py index 066fb9b3..fd5079eb 100644 --- a/app/ui/satellites_dialog.py +++ b/app/ui/satellites.py @@ -14,24 +14,20 @@ from .main_helper import move_items, scroll_to, append_text_to_tview, get_base_m from .search import SearchProvider from .uicommons import Gtk, Gdk, UI_RESOURCES_PATH, MOVE_KEYS, KeyboardKey, MOD_MASK -_UI_PATH = UI_RESOURCES_PATH + "satellites_dialog.glade" +_UI_PATH = UI_RESOURCES_PATH + "satellites.glade" -def show_satellites_dialog(transient, options): - SatellitesDialog(transient, options).show() - - -class SatellitesDialog: +class SatellitesTool(Gtk.Box): _aggr = [None for x in range(9)] # aggregate - def __init__(self, transient, settings): + def __init__(self, app, settings, *args, **kwargs): + super().__init__(*args, **kwargs) + + self._app = app self._data_path = settings.data_local_path + "satellites.xml" self._settings = settings - handlers = {"on_open": self.on_open, - "on_remove": self.on_remove, - "on_save": self.on_save, - "on_save_as": self.on_save_as, + handlers = {"on_remove": self.on_remove, "on_update": self.on_update, "on_up": self.on_up, "on_down": self.on_down, @@ -40,45 +36,26 @@ class SatellitesDialog: "on_transponder_add": self.on_transponder_add, "on_edit": self.on_edit, "on_key_release": self.on_key_release, - "on_row_activated": self.on_row_activated, - "on_resize": self.on_resize, - "on_quit": self.on_quit} + "on_row_activated": self.on_row_activated} builder = get_builder(_UI_PATH, handlers, use_str=True, - objects=("satellites_editor_window", "satellites_tree_store", "popup_menu", + objects=("satellite_tool_frame", "satellites_tree_store", "popup_menu", "left_header_menu", "popup_menu_add_image", "popup_menu_add_image_2")) - self._window = builder.get_object("satellites_editor_window") - self._window.set_transient_for(transient) self._sat_view = builder.get_object("satellites_editor_tree_view") - # Setting the last size of the dialog window if it was saved - window_size = self._settings.get("sat_editor_window_size") - if window_size: - self._window.resize(*window_size) - self._stores = {3: builder.get_object("pol_store"), 4: builder.get_object("fec_store"), 5: builder.get_object("system_store"), 6: builder.get_object("mod_store")} + self.pack_start(builder.get_object("satellite_tool_frame"), True, True, 0) + self.show() self.load_satellites_list(self._sat_view.get_model()) def load_satellites_list(self, model): gen = self.on_satellites_list_load(model) GLib.idle_add(lambda: next(gen, False), priority=GLib.PRIORITY_LOW) - def show(self): - self._window.show() - - def on_resize(self, window): - """ Stores new size properties for dialog window after resize """ - if self._settings: - self._settings.add("sat_editor_window_size", window.get_size()) - - @run_idle - def on_quit(self, *args): - self._window.destroy() - @run_idle def on_open(self, model): response = get_chooser_dialog(self._window, self._settings, "satellites.xml", ("*.xml",)) @@ -170,7 +147,7 @@ class SatellitesDialog: def on_satellite(self, satellite=None, edited_itr=None): """ Create or edit satellite""" - sat_dialog = SatelliteDialog(self._window, satellite) + sat_dialog = SatelliteDialog(self._app.get_active_window(), satellite) sat = sat_dialog.run() sat_dialog.destroy() @@ -194,7 +171,7 @@ class SatellitesDialog: show_dialog(DialogType.ERROR, self._window, "No satellite is selected!") return - dialog = TransponderDialog(self._window, transponder) + dialog = TransponderDialog(self._app.get_active_window(), transponder) tr = dialog.run() dialog.destroy() @@ -285,7 +262,7 @@ class SatellitesDialog: @run_idle def on_update(self, item): - SatellitesUpdateDialog(self._window, self._settings, self._sat_view.get_model()).show() + SatellitesUpdateDialog(self._app.get_active_window(), self._settings, self._sat_view.get_model()).show() @staticmethod def parse_data(model, path, itr, sats): @@ -454,7 +431,7 @@ class UpdateDialog: self._parser = None self._size_name = "{}_window_size".format("_".join(re.findall("[A-Z][^A-Z]*", self.__class__.__name__))).lower() - builder = get_builder(UI_RESOURCES_PATH + "satellites_dialog.glade", handlers, + builder = get_builder(UI_RESOURCES_PATH + "satellites.glade", handlers, objects=("satellites_update_window", "update_source_store", "update_sat_list_store", "update_sat_list_model_filter", "update_sat_list_model_sort", "side_store", "pos_adjustment", "pos_adjustment2", "satellites_update_popup_menu", diff --git a/app/ui/uicommons.py b/app/ui/uicommons.py index b476fcee..8fb2b515 100644 --- a/app/ui/uicommons.py +++ b/app/ui/uicommons.py @@ -90,6 +90,17 @@ def show_notification(message, timeout=10000, urgency=1): notify.show() +class Page(Enum): + """ Main stack widget page. """ + INFO = "info" + SERVICES = "services" + SATELLITE = "satellite" + PICONS = "picons" + PLAYBACK = "playback" + FTP = "ftp" + CONTROL = "control" + + class KeyboardKey(Enum): """ The raw(hardware) codes of the keyboard keys. """ E = 26 diff --git a/start.py b/start.py index e2ca1ee8..0abb8974 100755 --- a/start.py +++ b/start.py @@ -23,7 +23,7 @@ def update_icon(): if __name__ == "__main__": - from app.ui.main_app_window import start_app + from app.ui.main import start_app update_icon() start_app()