From 4a57234293ba44f39800a2f1d0a3b071dfd76d19 Mon Sep 17 00:00:00 2001 From: DYefremov Date: Thu, 21 Oct 2021 18:53:57 +0300 Subject: [PATCH] added logs display in the gui --- app/commons.py | 9 +- app/ui/app_menu.ui | 8 + app/ui/logs.glade | 125 ++ app/ui/logs.py | 66 + app/ui/main.glade | 3686 ++++++++++++++++++++++--------------------- app/ui/main.py | 39 +- app/ui/telnet.glade | 8 +- app/ui/telnet.py | 30 +- 8 files changed, 2130 insertions(+), 1841 deletions(-) create mode 100644 app/ui/logs.glade create mode 100644 app/ui/logs.py diff --git a/app/commons.py b/app/commons.py index 35624385..3860e907 100644 --- a/app/commons.py +++ b/app/commons.py @@ -7,13 +7,12 @@ from gi.repository import GLib _LOG_FILE = "demon-editor.log" _DATE_FORMAT = "%d-%m-%y %H:%M:%S" -_LOGGER_NAME = None + +LOGGER_NAME = "main_logger" def init_logger(): - global _LOGGER_NAME - _LOGGER_NAME = "main_logger" - logging.Logger(_LOGGER_NAME) + logging.Logger(LOGGER_NAME) logging.basicConfig(level=logging.INFO, format="%(asctime)s %(message)s", datefmt=_DATE_FORMAT, @@ -23,7 +22,7 @@ def init_logger(): def log(message, level=logging.ERROR, debug=False, fmt_message="{}"): """ The main logging function. """ - logger = logging.getLogger(_LOGGER_NAME) + logger = logging.getLogger(LOGGER_NAME) if debug: from traceback import format_exc logger.log(level, fmt_message.format(format_exc())) diff --git a/app/ui/app_menu.ui b/app/ui/app_menu.ui index 0f7d3ca6..1d1e44e0 100644 --- a/app/ui/app_menu.ui +++ b/app/ui/app_menu.ui @@ -147,6 +147,10 @@ Telnet app.on_telnet_show + + Logs + app.on_logs_show + @@ -333,6 +337,10 @@ Telnet app.on_telnet_show + + Logs + app.on_logs_show + diff --git a/app/ui/logs.glade b/app/ui/logs.glade new file mode 100644 index 00000000..ebc7f5fc --- /dev/null +++ b/app/ui/logs.glade @@ -0,0 +1,125 @@ + + + + + + + + + + + + True + False + 0.49000000953674316 + in + + + True + False + 5 + 5 + 5 + vertical + 5 + + + True + False + 5 + 5 + 2 + 5 + + + True + True + True + Clear + center + center + + + + True + False + gtk-clear + + + + + False + True + 0 + + + + + + + + False + True + 0 + + + + + True + True + in + + + True + True + False + 5 + 5 + 5 + 5 + + + + + True + True + 1 + + + + + + + True + False + Logs + + + + diff --git a/app/ui/logs.py b/app/ui/logs.py new file mode 100644 index 00000000..a1a252a6 --- /dev/null +++ b/app/ui/logs.py @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- +# +# The MIT License (MIT) +# +# Copyright (c) 2018-2021 Dmitriy Yefremov +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# +# Author: Dmitriy Yefremov +# + + +import logging + +from gi.repository import GLib + +from app.commons import LOGGER_NAME +from app.ui.dialogs import get_builder +from app.ui.main_helper import append_text_to_tview +from app.ui.uicommons import Gtk, UI_RESOURCES_PATH + + +class LogsClient(Gtk.Box): + """ Logger GUI client. """ + + class LogHandler(logging.Handler): + def __init__(self, view): + logging.Handler.__init__(self) + self._view = view + + def handle(self, rec): + GLib.idle_add(append_text_to_tview, f"{rec.msg}\n", self._view) + + def __init__(self, app, *args, **kwargs): + super().__init__(*args, **kwargs) + self._app = app + + handlers = {"on_clear": self.on_clear} + builder = get_builder(UI_RESOURCES_PATH + "logs.glade", handlers) + + self._log_view = builder.get_object("log_view") + self.pack_start(builder.get_object("log_frame"), True, True, 0) + + logger = logging.getLogger(LOGGER_NAME) + logger.addHandler(LogsClient.LogHandler(self._log_view)) + + self.show() + + def on_clear(self, button): + GLib.idle_add(self._log_view.get_buffer().set_text, "") diff --git a/app/ui/main.glade b/app/ui/main.glade index 493fe476..12be77fb 100644 --- a/app/ui/main.glade +++ b/app/ui/main.glade @@ -27,11 +27,11 @@ Author: Dmitriy Yefremov --> - + - + @@ -1202,10 +1202,13 @@ Author: Dmitriy Yefremov services_model_filter + 720 + 560 False DemonEditor center 720 + 560 demon-editor DemonEditor @@ -1219,387 +1222,64 @@ Author: Dmitriy Yefremov vertical 5 - + True - True + False + vertical True - - - - + + 480 True - False - True + True True - - + + + + True False - crossfade - + True + True + - + True False - center - vertical - - - + crossfade + - + True False - demon-editor - 6 - - - False - True - 0 - - - - - True - False - DemonEditor - - - - - - - False - True - 1 - - - - - True - False - 2.0.0 Alpha - - - - - - False - True - 2 - - - - - info - - - - - True - False - 5 - 0.49000000953674316 - in - - - True - False - 5 - 5 + center vertical + + + - + True False - 5 - 5 - 5 - 5 - 5 - - - True - False - False - False - True - Filter - - - - True - False - edit-find-replace-symbolic - - - - - False - True - 0 - - - - - True - False - False - True - Search - - - True - False - edit-find-symbolic - - - - - False - True - 2 - - - - - False - False - 5 - - - True - False - False - True - Parent lock On/Off Ctrl + L - app.on_locked - - - True - False - changes-prevent-symbolic - - - - - False - True - 0 - - - - - True - False - False - True - Hide/Skip On/Off Ctrl + H - app.on_hide - - - True - False - go-jump-symbolic - - - - - False - True - end - 1 - - - - - False - True - end - 6 - - + demon-editor + 6 False - False + True 0 - + True False - 5 - 5 - 5 - 10 - - - False - center - - - 50 - True - False - True - Only free - - - - True - False - emblem-readonly - - - - - False - False - 0 - - - - - True - True - edit-find-replace-symbolic - False - False - - - - False - True - 1 - - - - - 50 - True - False - False - True - filter_type_popover - - - True - False - Type - - - - - False - True - 2 - - - - - 50 - True - False - False - True - filter_satellite_popover - - - True - False - Pos - - - - - False - True - 3 - - - - - - False - False - 0 - - - - - False - center - - - True - True - edit-find-symbolic - False - False - - - False - True - 0 - - - - - True - False - False - True - - - True - False - down - - - - - False - False - 1 - - - - - True - False - False - True - - - True - False - up - - - - - False - False - 2 - - - - - - False - False - 1 - - + DemonEditor + + + + False @@ -1608,842 +1288,64 @@ Author: Dmitriy Yefremov - + True - True - in - - - True - True - services_model_sort - False - 3 - True - both - 20 - True - - - - - - - - - - - - - - - - multiple - - - - - False - CAS - - - - 0 - - - - - - - False - Type - - - - 1 - - - - - - - True - 50 - Service - True - True - 0.5 - 3 - - - 2 - - - 21 - 2 - - - - - end - 25 - - - 21 - 3 - - - - - 2 - - - 21 - 4 - - - - - 2 - - - 21 - 5 - - - - - - - True - 50 - Package - True - True - 0.5 - 6 - - - end - 15 - - - 21 - 6 - - - - - - - True - 25 - Type - True - True - 0.5 - 7 - - - 0.51999998092651367 - - - 21 - 7 - - - - - - - 25 - Picon - True - 0.5 - 9 - - - - 21 - 8 - - - - - - - False - fixed - Picon ID - 0.5 - - - - 9 - - - - - - - True - 25 - SID - True - True - 0.5 - 10 - - - 0.50999999046325684 - - - 21 - 10 - - - - - - - True - 25 - Freq - True - True - 0.5 - 11 - - - 0.50999999046325684 - - - 21 - 11 - - - - - - - True - 25 - Rate - True - True - 0.5 - 12 - - - 0.50999999046325684 - - - 21 - 12 - - - - - - - True - 25 - Pol - True - True - 0.5 - 13 - - - 0.50999999046325684 - - - 21 - 13 - - - - - - - True - 25 - FEC - True - True - 0.5 - 14 - - - 0.50999999046325684 - - - 21 - 14 - - - - - - - True - 25 - System - True - True - 0.5 - 15 - - - 0.50999999046325684 - - - 21 - 15 - - - - - - - True - 25 - Pos - True - True - 0.5 - 16 - - - 0.50999999046325684 - - - 21 - 16 - - - - - - - False - data_id - - - - 17 - - - - - - - False - fav_id - - - - 18 - - - - - - - False - transponder - - - - 19 - - - - - - - False - extra - - - - 20 - - - - - - - - - + False + 2.0.0 Alpha + + + - True + False True 2 - - - 26 - True - False - 5 - 5 - queue - 2 - - - True - False - emblem-readonly - - - False - True - 0 - - - - - True - False - CAS - 20 - 20 - 0 - - - False - True - 2 - 1 - - - - - True - False - vertical - - - False - True - 5 - 2 - - - - - True - False - tv-symbolic - - - False - True - 3 - - - - - True - False - TV - 0 - - - False - True - 4 - - - - - True - False - network-wireless-symbolic - - - False - True - 5 - - - - - True - False - Radio - 0 - - - False - True - 6 - - - - - True - False - system-run - - - False - True - 7 - - - - - True - False - Data - 0 - - - False - True - 8 - - - - - True - False - vertical - - - False - True - 5 - 9 - - - - - True - False - Loading data... - center - center - - - False - True - end - 10 - - - - - False - True - 3 - - + + info + - - - True - False - 2 - 2 - Services - - - - - services - Bouquets - 1 - - - - - True - False - 5 - 5 - 2 - vertical - - - - - - satellite - Satellites - 2 - - - - - True - False - 5 - 2 - vertical - - - - - - - picons - Picons - 3 - - - - - True - False - 5 - 2 - vertical - - - - - - - epg - EPG - 4 - - - - - True - False - 5 - 2 - vertical - - - - - - - timers - Timers - 5 - - - - - True - False - 5 - 5 - 2 - vertical - - - - - - - recordings - Recordings - 6 - - - - - True - False - 5 - 5 - 2 - vertical - - - - - - - ftp - FTP - 7 - - - - - True - False - 5 - 5 - 2 - - - - - - - control - Control - 8 - - - - - True - False - - - - - 350 - False - 5 - True - True - - - True - False - 0.49000000953674316 - in - - + True False 5 - 5 - vertical + 0.49000000953674316 + in - + True False 5 5 - 5 - 5 - 5 + vertical - + True False - False - True - Search + 5 + 5 + 5 + 5 + 5 - + True + False False - edit-find-symbolic - - - - - False - True - 0 - - - - - True - False - False - False - True - IPTV - none - - - - - - False - True - end - 1 - - - - - True - False - False - False - True - Export to m3u - - - - True - False - document-save-as-symbolic - - - - - False - True - end - 2 - - - - - True - False - False - False - True - Import m3u file - - - - True - False - insert-link-symbolic - - - - - False - True - end - 3 - - - - - - - - False - True - 0 - - - - - True - False - 5 - 5 - 5 - 5 - - - False - center - - - True - True - edit-find-symbolic - False - False + False + True + Filter + + + + True + False + edit-find-replace-symbolic + + False @@ -2452,275 +1354,46 @@ Author: Dmitriy Yefremov - + True - False False + False True + Search - + True False - down + edit-find-symbolic False - False - 1 - - - - - True - False - False - True - - - True - False - up - - - - - False - False + True 2 - - - - False - False - 0 - - - - - False - True - 1 - - - - - True - False - 2 - vertical - 2 - - - True - False - in - - True - True - fav_list_store - False - 2 - True - both - 9 - True - - - - - - - - - - - - - - - multiple - - - - - True - 25 - Num - True - 0.5 - - - - 0.49000000953674316 - 5 - 5 - - - 10 - 0 - 0 - - - - - - - True - 50 - Service - True - True - 0.5 - - - - 2 - - - 10 - 8 - - - - - 2 - - - 10 - 1 - - - - - end - 25 - - - 10 - 2 - - - - - 2 - - - 10 - 3 - - - - - 2 - - - 10 - 4 - - - - - - - True - 25 - Type - True - True - 0.5 - - - - 0.50999999046325684 - - - 10 - 5 - - - - - - - 25 - Pos - True - True - 0.5 - - - - 0.50999999046325684 - - - 10 - 6 - - - - - - - False - fav_id - - - - 7 - - - - - - - False - extra - - - - 9 - - - - - - - - - - - - True - True - 0 - - - - - False - slide-up - - - 200 - True + + False False - vertical - 2 + 5 - + True False - Alternatives - - - + False + True + Parent lock On/Off Ctrl + L + app.on_locked + + + True + False + changes-prevent-symbolic + + False @@ -2729,136 +1402,213 @@ Author: Dmitriy Yefremov - + True - True - in + False + False + True + Hide/Skip On/Off Ctrl + H + app.on_hide - + True - True - alt_list_store - False - True - both - True - - - - - - - - multiple - - - - - 25 - Num - 0.5 - - - 0.49000000953674316 - 5 - 5 - - - 0 - - - - - - - True - 50 - Service - True - 0.5 - - - 2 - - - 1 - - - - - 0.10000000149011612 - - - 2 - - - - - - - True - Type - True - 0.5 - - - 0.50999999046325684 - - - 3 - - - - - - - 25 - Pos - 0.5 - - - 0.50999999046325684 - - - 4 - - - - - - - False - ID - - - - 5 - - - - - - 6 - - - - - - 7 - - - - + False + go-jump-symbolic - True + False True + end 1 + + False + True + end + 6 + + + + + False + False + 0 + + + + + True + False + 5 + 5 + 5 + 10 + + + False + center + + + 50 + True + False + True + Only free + + + + True + False + emblem-readonly + + + + + False + False + 0 + + + + + True + True + edit-find-replace-symbolic + False + False + + + + False + True + 1 + + + + + 50 + True + False + False + True + filter_type_popover + + + True + False + Type + + + + + False + True + 2 + + + + + 50 + True + False + False + True + filter_satellite_popover + + + True + False + Pos + + + + + False + True + 3 + + + + + + False + False + 0 + + + + + False + center + + + True + True + edit-find-symbolic + False + False + + + False + True + 0 + + + + + True + False + False + True + + + True + False + down + + + + + False + False + 1 + + + + + True + False + False + True + + + True + False + up + + + + + False + False + 2 + + + + + + False + False + 1 + @@ -2867,98 +1617,689 @@ Author: Dmitriy Yefremov 1 - - - True - True - 2 - - - - - 24 - True - False - 5 - 5 - 2 - + True - False - document-properties - - - False - True - 0 - - - - - True - False - 0 - 4 - 4 - 0 - - - False - True - 1 - - - - - True - False - - - False - True - 2 - - - - - True - False - center + True + in - + True - False - True - end - 12 - 20 + True + services_model_sort + False + 3 + True + both + 20 + True + + + + + + + + + + + + + + + + multiple + + + + + False + CAS + + + + 0 + + + + + + + False + Type + + + + 1 + + + + + + + True + 50 + Service + True + True + 0.5 + 3 + + + 2 + + + 21 + 2 + + + + + end + 25 + + + 21 + 3 + + + + + 2 + + + 21 + 4 + + + + + 2 + + + 21 + 5 + + + + + + + True + 50 + Package + True + True + 0.5 + 6 + + + end + 15 + + + 21 + 6 + + + + + + + True + 25 + Type + True + True + 0.5 + 7 + + + 0.51999998092651367 + + + 21 + 7 + + + + + + + 25 + Picon + True + 0.5 + 9 + + + + 21 + 8 + + + + + + + False + fixed + Picon ID + 0.5 + + + + 9 + + + + + + + True + 25 + SID + True + True + 0.5 + 10 + + + 0.50999999046325684 + + + 21 + 10 + + + + + + + True + 25 + Freq + True + True + 0.5 + 11 + + + 0.50999999046325684 + + + 21 + 11 + + + + + + + True + 25 + Rate + True + True + 0.5 + 12 + + + 0.50999999046325684 + + + 21 + 12 + + + + + + + True + 25 + Pol + True + True + 0.5 + 13 + + + 0.50999999046325684 + + + 21 + 13 + + + + + + + True + 25 + FEC + True + True + 0.5 + 14 + + + 0.50999999046325684 + + + 21 + 14 + + + + + + + True + 25 + System + True + True + 0.5 + 15 + + + 0.50999999046325684 + + + 21 + 15 + + + + + + + True + 25 + Pos + True + True + 0.5 + 16 + + + 0.50999999046325684 + + + 21 + 16 + + + + + + + False + data_id + + + + 17 + + + + + + + False + fav_id + + + + 18 + + + + + + + False + transponder + + + + 19 + + + + + + + False + extra + + + + 20 + + + + + + + True True + 2 + + + + + 26 + True + False + 5 + 5 + queue + 2 + + + True + False + emblem-readonly + + + False + True + 0 + + + + + True + False + CAS + 20 + 20 + 0 + + + False + True + 2 + 1 + + + + + True + False + vertical + + + False + True + 5 + 2 + + + + + True + False + tv-symbolic + + + False + True + 3 + + + + + True + False + TV + 0 + + + False + True + 4 + + + + + True + False + network-wireless-symbolic + + + False + True + 5 + + + + + True + False + Radio + 0 + + + False + True + 6 + + + + + True + False + system-run + + + False + True + 7 + + + + + True + False + Data + 0 + + + False + True + 8 + + + + + True + False + vertical + + + False + True + 5 + 9 + + + + + True + False + Loading data... + center + center + + + False + True + end + 10 + + + + + False + True 3 - - False - True - 4 - + + + + True + False + 2 + 2 + Services + + + services + Bouquets + 1 + - - + + True False + 5 + 5 2 - 2 - Bouquet details + vertical + + + + + + satellite + Satellites + 2 + + + + + True + False + 5 + 2 + vertical + + + + + + + picons + Picons + 3 + + + + + True + False + 5 + 2 + vertical + + + + + + + epg + EPG + 4 + + + + + True + False + 5 + 2 + vertical + + + + + + + timers + Timers + 5 + + + + + True + False + 5 + 5 + 2 + vertical + + + + + + + recordings + Recordings + 6 + + + + + True + False + 5 + 5 + 2 + vertical + + + + + + + ftp + FTP + 7 + + + + + True + False + 5 + 5 + 2 + + + + + + + control + Control + 8 + @@ -2967,68 +2308,46 @@ Author: Dmitriy Yefremov - - True + + 350 False - 0.49000000953674316 - in + 5 + True + True - + True False - 5 - 5 - vertical + 0.49000000953674316 + in - + True False 5 5 - 5 - 5 - 5 + vertical - + True - False - False - False - True - New bouquet - - - - True - False - bookmark-new-symbolic - - - - - False - True - 0 - - - - - False False + 5 + 5 + 5 + 5 5 - + True False False True - Parent lock On/Off Ctrl + L - app.on_locked + Search - + True False - changes-prevent-symbolic + edit-find-symbolic @@ -3039,21 +2358,720 @@ Author: Dmitriy Yefremov - + True + False False False True - Hide/Skip On/Off Ctrl + H - app.on_hide + IPTV + none - + + + + + False + True + end + 1 + + + + + True + False + False + False + True + Export to m3u + + + True False - go-jump-symbolic + document-save-as-symbolic + + False + True + end + 2 + + + + + True + False + False + False + True + Import m3u file + + + + True + False + insert-link-symbolic + + + + + False + True + end + 3 + + + + + + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + + + False + center + + + True + True + edit-find-symbolic + False + False + + + False + True + 0 + + + + + True + False + False + True + + + True + False + down + + + + + False + False + 1 + + + + + True + False + False + True + + + True + False + up + + + + + False + False + 2 + + + + + + False + False + 0 + + + + + False + True + 1 + + + + + True + False + 2 + vertical + 2 + + + True + False + in + + + True + True + fav_list_store + False + 2 + True + both + 9 + True + + + + + + + + + + + + + + + multiple + + + + + True + 25 + Num + True + 0.5 + + + + 0.49000000953674316 + 5 + 5 + + + 10 + 0 + 0 + + + + + + + True + 50 + Service + True + True + 0.5 + + + + 2 + + + 10 + 8 + + + + + 2 + + + 10 + 1 + + + + + end + 25 + + + 10 + 2 + + + + + 2 + + + 10 + 3 + + + + + 2 + + + 10 + 4 + + + + + + + True + 25 + Type + True + True + 0.5 + + + + 0.50999999046325684 + + + 10 + 5 + + + + + + + 25 + Pos + True + True + 0.5 + + + + 0.50999999046325684 + + + 10 + 6 + + + + + + + False + fav_id + + + + 7 + + + + + + + False + extra + + + + 9 + + + + + + + + + + + + True + True + 0 + + + + + False + slide-up + + + 200 + True + False + vertical + 2 + + + True + False + Alternatives + + + + + + False + True + 0 + + + + + True + True + in + + + True + True + alt_list_store + False + True + both + True + + + + + + + + multiple + + + + + 25 + Num + 0.5 + + + 0.49000000953674316 + 5 + 5 + + + 0 + + + + + + + True + 50 + Service + True + 0.5 + + + 2 + + + 1 + + + + + 0.10000000149011612 + + + 2 + + + + + + + True + Type + True + 0.5 + + + 0.50999999046325684 + + + 3 + + + + + + + 25 + Pos + 0.5 + + + 0.50999999046325684 + + + 4 + + + + + + + False + ID + + + + 5 + + + + + + 6 + + + + + + 7 + + + + + + + + + True + True + 1 + + + + + + + False + True + 1 + + + + + True + True + 2 + + + + + 24 + True + False + 5 + 5 + 2 + + + True + False + document-properties + + + False + True + 0 + + + + + True + False + 0 + 4 + 4 + 0 + + + False + True + 1 + + + + + True + False + + + False + True + 2 + + + + + True + False + center + + + True + False + True + end + 12 + 20 + + + + + True + True + 3 + + + + + False + True + 4 + + + + + + + True + False + 2 + 2 + Bouquet details + + + + + True + False + + + + + True + False + 0.49000000953674316 + in + + + True + False + 5 + 5 + vertical + + + True + False + 5 + 5 + 5 + 5 + 5 + + + True + False + False + False + True + New bouquet + + + + True + False + bookmark-new-symbolic + + + + + False + True + 0 + + + + + False + False + 5 + + + True + False + False + True + Parent lock On/Off Ctrl + L + app.on_locked + + + True + False + changes-prevent-symbolic + + + + + False + True + 0 + + + + + True + False + False + True + Hide/Skip On/Off Ctrl + H + app.on_hide + + + True + False + go-jump-symbolic + + + + + False + True + end + 1 + + + False True @@ -3062,138 +3080,6 @@ Author: Dmitriy Yefremov - - False - True - end - 1 - - - - - False - True - 0 - - - - - True - False - 5 - 5 - 5 - - - - - - False - True - 1 - - - - - True - False - 2 - in - - - True - True - bouquets_tree_store - False - 0 - True - True - True - - - - - - - - - - - - - - multiple - - - - - True - 2 - autosize - Name - True - 0.5 - - - end - - - 0 - - - - - - 1 - - - - - 0 - - - 2 - - - - - - - False - True - autosize - Type - - - - 3 - - - - - - - - - True - True - 2 - - - - - 24 - True - False - 5 - 5 - 2 - - - True - False - document-properties - False True @@ -3201,13 +3087,15 @@ Author: Dmitriy Yefremov - + True False - 0 - 10 - 10 - 0 + 5 + 5 + 5 + + + False @@ -3216,25 +3104,153 @@ Author: Dmitriy Yefremov - + + True + False + 2 + in + + + True + True + bouquets_tree_store + False + 0 + True + True + True + + + + + + + + + + + + + + multiple + + + + + True + 2 + autosize + Name + True + 0.5 + + + end + + + 0 + + + + + + 1 + + + + + 0 + + + 2 + + + + + + + False + True + autosize + Type + + + + 3 + + + + + + + + + True + True + 2 + + + + + 24 + True + False + 5 + 5 + 2 + + + True + False + document-properties + + + False + True + 0 + + + + + True + False + 0 + 10 + 10 + 0 + + + False + True + 1 + + + + + + + + False + True + 3 + - - False - True - 3 - + + + + True + False + 2 + 2 + Bouquets + - - - - True - False - 2 - 2 - Bouquets - + + True + False + @@ -3249,9 +3265,52 @@ Author: Dmitriy Yefremov + + False + True + + + + + False + 5 + 5 + 5 + True + + + 150 + False + vertical + + + + + + + True + False + + + + + 150 + False + vertical + + + + + + + True + False + + + True - False + True @@ -3261,21 +3320,6 @@ Author: Dmitriy Yefremov 0 - - - False - vertical - - - - - - - True - True - 1 - - False diff --git a/app/ui/main.py b/app/ui/main.py index 5f6ec109..a4f3e417 100644 --- a/app/ui/main.py +++ b/app/ui/main.py @@ -51,6 +51,7 @@ from app.tools.media import Recorder from app.ui.control import ControlTool, EpgTool, TimerTool, RecordingsTool from app.ui.epg import EpgDialog from app.ui.ftp import FtpClientBox +from app.ui.logs import LogsClient from app.ui.playback import PlayerBox from app.ui.telnet import TelnetClient from app.ui.transmitter import LinksTransmitter @@ -194,7 +195,8 @@ class Application(Gtk.Application): "on_recordings_realize": self.on_recordings_realize, "on_control_realize": self.on_control_realize, "on_ftp_realize": self.on_ftp_realize, - "on_telnet_relize": self.on_telnet_relize, + "on_telnet_realize": self.on_telnet_realize, + "on_logs_realize": self.on_logs_realize, "on_visible_page": self.on_visible_page, "on_data_paned_realize": self.init_main_paned_position} @@ -386,8 +388,11 @@ class Application(Gtk.Application): self._stack_recordings_box = builder.get_object("recordings_box") self._stack_ftp_box = builder.get_object("ftp_box") self._stack_control_box = builder.get_object("control_box") - self._telnet_box = builder.get_object("telnet_box") self.connect("change-page", self.on_page_change) + # Extra tools. + self._telnet_box = builder.get_object("telnet_box") + self._logs_box = builder.get_object("logs_box") + self._bottom_paned = builder.get_object("bottom_paned") # Header bar. profile_box = builder.get_object("profile_combo_box") toolbar_box = builder.get_object("toolbar_main_box") @@ -464,6 +469,7 @@ class Application(Gtk.Application): self.set_action("on_about_app", self.on_about_app) self.set_action("on_close_app", self.on_close_app) self.set_state_action("on_telnet_show", self.on_telnet_show, False) + self.set_state_action("on_logs_show", self.on_logs_show, False) # Filter. filter_action = Gio.SimpleAction.new("filter", None) filter_action.connect("activate", lambda a, v: self.emit("filter-toggled", None)) @@ -544,6 +550,7 @@ class Application(Gtk.Application): self.set_accels_for_action("app.on_close_app", ["q"]) self.set_accels_for_action("app.on_edit", ["e"]) self.set_accels_for_action("app.on_telnet_show", ["t"]) + self.set_accels_for_action("app.on_logs_show", ["l"]) self.set_accels_for_action("win.filter", ["f"]) def do_activate(self): @@ -795,9 +802,11 @@ class Application(Gtk.Application): self._control_tool = ControlTool(self, self._http_api, self._settings) box.pack_start(self._control_tool, True, True, 0) - def on_telnet_relize(self, box): - telnet_tool = TelnetClient(self, self._settings) - box.pack_start(telnet_tool, True, True, 0) + def on_telnet_realize(self, box): + box.pack_start(TelnetClient(self), True, True, 0) + + def on_logs_realize(self, box): + box.pack_start(LogsClient(self), True, True, 0) def on_visible_page(self, stack, param): self._page = Page(stack.get_visible_child_name()) @@ -1209,6 +1218,9 @@ class Application(Gtk.Application): def on_fav_view_query_tooltip(self, view, x, y, keyboard_mode, tooltip): """ Sets detailed info about service in the tooltip [fav view]. """ + if not self._main_window.is_active(): + return False + result = view.get_dest_row_at_pos(x, y) if not result or not self._settings.show_bq_hints: return False @@ -1217,6 +1229,9 @@ class Application(Gtk.Application): def on_services_view_query_tooltip(self, view, x, y, keyboard_mode, tooltip): """ Sets short info about service in the tooltip [main services view]. """ + if not self._main_window.is_active(): + return False + result = view.get_dest_row_at_pos(x, y) if not result or not self._settings.show_srv_hints: return False @@ -2657,11 +2672,21 @@ class Application(Gtk.Application): """ Shows backup tool dialog """ BackupDialog(self._main_window, self._settings, self.open_data).show() - # ***************** Telnet ******************** # + # ***************** Extra tools ******************** # def on_telnet_show(self, action, value=False): action.set_state(value) - GLib.idle_add(self._telnet_box.set_visible, value) + self._telnet_box.set_visible(value) + self.update_tools_visibility() + + def on_logs_show(self, action, value=False): + action.set_state(value) + self._logs_box.set_visible(value) + self.update_tools_visibility() + + @run_idle + def update_tools_visibility(self): + self._bottom_paned.set_visible(self._telnet_box.get_visible() or self._logs_box.get_visible()) # ************************* Streams ***************************** # diff --git a/app/ui/telnet.glade b/app/ui/telnet.glade index 64845e88..8a9422ac 100644 --- a/app/ui/telnet.glade +++ b/app/ui/telnet.glade @@ -27,7 +27,7 @@ Author: Dmitriy Yefremov --> - + @@ -46,16 +46,10 @@ Author: Dmitriy Yefremov True False - 5 - 5 - 5 - 5 0.49000000953674316 in - 480 - 180 True False 5 diff --git a/app/ui/telnet.py b/app/ui/telnet.py index 647bf7be..05363dda 100644 --- a/app/ui/telnet.py +++ b/app/ui/telnet.py @@ -1,3 +1,31 @@ +# -*- coding: utf-8 -*- +# +# The MIT License (MIT) +# +# Copyright (c) 2018-2021 Dmitriy Yefremov +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# +# Author: Dmitriy Yefremov +# + + import re import selectors import socket @@ -44,7 +72,7 @@ class TelnetClient(Gtk.Box): _ALL_PATTERN = re.compile(r'(\x1b\[|\x9b)[0-?]*[@-~]') _NOT_SUPPORTED = {"mc", "mcedit", "vi", "nano"} - def __init__(self, app, settings, *args, **kwargs): + def __init__(self, app, *args, **kwargs): super().__init__(*args, **kwargs) self._app = app self._app.connect("profile-changed", self.on_profile_changed)