From 5634064d17bde22858701b8ddfe25698c630930e Mon Sep 17 00:00:00 2001 From: Trigg Date: Tue, 16 May 2023 10:35:09 +0100 Subject: [PATCH] - Re-add text popup timer in config - Add 1hz redraw when in text popup mode - Added condition to voice 1hz redraw --- discover_overlay/glade/settings.glade | 206 +++++++++++++++----------- discover_overlay/settings_window.py | 7 + discover_overlay/text_overlay.py | 8 +- discover_overlay/voice_overlay.py | 3 +- 4 files changed, 137 insertions(+), 87 deletions(-) diff --git a/discover_overlay/glade/settings.glade b/discover_overlay/glade/settings.glade index e96a84a..91913c6 100644 --- a/discover_overlay/glade/settings.glade +++ b/discover_overlay/glade/settings.glade @@ -110,6 +110,13 @@ 1 1 + + 30 + 5000 + 30 + 1 + 10 + @@ -1451,7 +1458,7 @@ - + text_grid True @@ -1517,30 +1524,6 @@ 1 - - - text_server_label - True - False - Server - 0 - - - 0 - 2 - - - - - text_server - True - False - - - 1 - 2 - - text_line_limit_label @@ -1551,7 +1534,7 @@ 0 - 11 + 12 @@ -1559,12 +1542,26 @@ text_line_limit True True + 10 text_line_limit_adj 10 1 + 12 + + + + + text_show_attachments_label + True + False + Show Attachments + 0 + + + 0 11 @@ -1579,15 +1576,15 @@ 1 - 10 + 11 - text_show_attachments_label + text_overlay_location_label True False - Show Attachments + Overlay Location 0 @@ -1606,21 +1603,7 @@ 1 - 9 - - - - - text_overlay_location_label - True - False - Overlay Location - 0 - - - 0 - 8 - 2 + 10 @@ -1632,6 +1615,19 @@ 1 + 9 + + + + + text_background_colour_label + True + False + Background Colour + 0 + + + 0 8 @@ -1646,6 +1642,19 @@ 1 + 8 + + + + + text_colour_label + True + False + Text Colour + 0 + + + 0 7 @@ -1660,35 +1669,9 @@ 1 - 6 - - - - - text_background_colour_label - True - False - Background Colour - 0 - - - 0 7 - - - text_colour_label - True - False - Text Colour - 0 - - - 0 - 6 - - text_font @@ -1702,7 +1685,7 @@ 1 - 5 + 6 @@ -1713,6 +1696,19 @@ Font 0 + + 0 + 6 + + + + + text_channel_label + True + False + Channel + 0 + 0 5 @@ -1726,20 +1722,7 @@ 1 - 4 - - - - - text_channel_label - True - False - Channel - 0 - - - 0 - 4 + 5 @@ -1753,9 +1736,62 @@ 1 + 4 + + + + + text_server_label + True + False + Server + 0 + + + 0 3 + + + text_server + True + False + + + 1 + 3 + + + + + text_popup_time_label + True + False + Popup time limit + 0 + + + 0 + 2 + + + + + text_popup_time + True + True + text_popup_time_adj + + + + 1 + 2 + + + + + diff --git a/discover_overlay/settings_window.py b/discover_overlay/settings_window.py index 9ec8e2c..800e5c2 100644 --- a/discover_overlay/settings_window.py +++ b/discover_overlay/settings_window.py @@ -403,6 +403,10 @@ class MainSettingsWindow(): self.widget['text_popup_style'].set_active( config.getboolean("text", "popup_style", fallback=False)) + self.widget['text_popup_time'].set_value( + config.getint("text","text_time", fallback=30) + ) + self.current_guild = config.get("text", "guild", fallback="0") self.current_channel = config.get("text", "channel", fallback="0") @@ -951,6 +955,9 @@ class MainSettingsWindow(): def text_popup_style_changed(self, button): self.config_set("text", "popup_style", "%s" % (button.get_active())) + def text_popup_time_changed(self, button): + self.config_set("text", "text_time", "%s" % (int(button.get_value()))) + def text_server_changed(self, button): if button.get_active() < 0: self.config_set("text", "guild", "0") diff --git a/discover_overlay/text_overlay.py b/discover_overlay/text_overlay.py index eb28ba6..d41b911 100644 --- a/discover_overlay/text_overlay.py +++ b/discover_overlay/text_overlay.py @@ -21,7 +21,7 @@ from .overlay import OverlayWindow gi.require_version("Gtk", "3.0") gi.require_version('PangoCairo', '1.0') # pylint: disable=wrong-import-position,wrong-import-order -from gi.repository import Pango, PangoCairo # nopep8 +from gi.repository import Pango, PangoCairo, GLib # nopep8 log = logging.getLogger(__name__) @@ -54,6 +54,12 @@ class TextOverlayWindow(OverlayWindow): self.warned_filetypes = [] self.set_title("Discover Text") self.redraw() + GLib.timeout_add_seconds(1, self.set_need_redraw) + + def set_need_redraw(self): + if self.popup_style: + self.needsredraw = True + return True def set_blank(self): self.content = [] diff --git a/discover_overlay/voice_overlay.py b/discover_overlay/voice_overlay.py index b89e622..35ef2f7 100644 --- a/discover_overlay/voice_overlay.py +++ b/discover_overlay/voice_overlay.py @@ -121,7 +121,8 @@ class VoiceOverlayWindow(OverlayWindow): GLib.timeout_add_seconds(1, self.set_need_redraw) def set_need_redraw(self): - self.needsredraw = True + if self.only_speaking: + self.needsredraw = True return True def set_icon_transparency(self, trans):