From d1f9ec7e00b46f55b2202a1825e19625fb79fe41 Mon Sep 17 00:00:00 2001 From: Martin Rys Date: Fri, 11 Oct 2024 01:32:27 +0200 Subject: [PATCH] Always show Show/Hide on right clicking the tray, fixes #53 --- scc/gui/app.py | 27 ++++++++++++++------------- scc/gui/global_settings.py | 15 +++++++++------ scc/gui/statusicon.py | 8 ++++---- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/scc/gui/app.py b/scc/gui/app.py index 3f0a551a..b8060690 100644 --- a/scc/gui/app.py +++ b/scc/gui/app.py @@ -1,4 +1,4 @@ -"""SC-Controller - App. +"""SC Controller - App. Main application window """ @@ -40,8 +40,8 @@ class App(Gtk.Application, UserDataManager, BindingEditor): """Main application / window.""" - HILIGHT_COLOR = "#FF00FF00" # ARGB - OBSERVE_COLOR = "#FF60A0FF" # ARGB + HILIGHT_COLOR = "#FF00FF00" # ARGB + OBSERVE_COLOR = "#FF60A0FF" # ARGB CONFIG = "scc.config.json" RELEASE_URL = "https://github.com/C0rn3j/sc-controller/releases/tag/v%s" OSD_MODE_PROF_NAME = ".scc-osd.profile_editor" @@ -276,14 +276,15 @@ def apply_ui_layout(self, layout): btLGRIP.get_parent().reorder_child(btDPAD, 5) - def setup_statusicon(self): + def setup_statusicon(self) -> None: menu = self.builder.get_object("mnuTray") self.statusicon = get_status_icon(self.imagepath, menu) - self.statusicon.connect('clicked', self.on_statusicon_clicked) - if not self.statusicon.is_clickable(): - self.builder.get_object("mnuShowWindowTray").set_visible(True) - GLib.idle_add(self.statusicon.set, "scc-%s" % (self.status,), _("SC Controller")) - + self.statusicon.connect("clicked", self.on_statusicon_clicked) +# if not self.statusicon.is_clickable(): +# self.builder.get_object("mnuShowWindowTray").set_visible(True) + # Workaround - always add it to the menu, see https://github.com/C0rn3j/sc-controller/issues/53 + self.builder.get_object("mnuShowWindowTray").set_visible(True) + GLib.idle_add(self.statusicon.set, f"scc-{self.status}", _("SC Controller")) def destroy_statusicon(self): self.statusicon.destroy() @@ -454,8 +455,8 @@ def save_config(self): self.enable_test_mode() - def on_statusicon_clicked(self, *a): - """ Handler for user clicking on tray icon button """ + def on_statusicon_clicked(self, *a) -> None: + """Handler for user clicking on tray icon button.""" self.window.set_visible(not self.window.get_visible()) @@ -865,7 +866,7 @@ def on_mnuExit_activate(self, *a): self.quit() - def on_mnuAbout_activate(self, *a): + def on_mnuAbout_activate(self, *a) -> None: from scc.gui.aboutdialog import AboutDialog AboutDialog(self).show(self.window) @@ -1354,7 +1355,7 @@ def on_mnuEmulationEnabled_toggled(self, cb): self.dm.stop() - def do_startup(self, *a): + def do_startup(self, *a) -> None: Gtk.Application.do_startup(self, *a) self.load_profile_list() self.setup_widgets() diff --git a/scc/gui/global_settings.py b/scc/gui/global_settings.py index ed424360..6296ff3f 100644 --- a/scc/gui/global_settings.py +++ b/scc/gui/global_settings.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python3 -""" -SC-Controller - Global Settings +"""SC Controller - Global Settings. Currently setups only one thing... """ @@ -29,7 +27,12 @@ from scc.osd.osk_actions import OSKCursorAction import scc.osd.osk_actions -import re, sys, os, json, logging, traceback +import re +import sys +import os +import json +import logging +import traceback log = logging.getLogger("GS") class GlobalSettings(Editor, UserDataManager, ComboSetter): @@ -304,8 +307,8 @@ def cb(*a): self._timer = GLib.timeout_add_seconds(3, cb) - def save_config(self): - """ Transfers settings from UI back to config """ + def save_config(self) -> None: + """Transfers settings from UI back to config.""" # Store hard stuff tvItems = self.builder.get_object("tvItems") cbShowOSD = self.builder.get_object("cbShowOSD") diff --git a/scc/gui/statusicon.py b/scc/gui/statusicon.py index eaf6091d..1029ea02 100644 --- a/scc/gui/statusicon.py +++ b/scc/gui/statusicon.py @@ -110,8 +110,8 @@ def show(self): self.__hidden = False self._set_visible(self.__visible) - def is_clickable(self): - """ Basically, returns False is appindicator is used """ + def is_clickable(self) -> bool: + """Basically, returns False is appindicator is used.""" return True def _is_forced(self): @@ -279,7 +279,7 @@ def _set_visible(self, active): self._tray.set_status(self._status_active if active else self._status_passive) - def is_clickable(self): + def is_clickable(self) -> bool: return False def destroy(self): @@ -362,7 +362,7 @@ def _load_fallback(self): # Update fallback icon self.set(self._icon, self._text) - def is_clickable(self): + def is_clickable(self) -> bool: if self._status_gtk: return self._status_gtk.is_clickable() if self._status_fb: