Skip to content

Commit

Permalink
Always show Show/Hide on right clicking the tray, fixes #53
Browse files Browse the repository at this point in the history
  • Loading branch information
C0rn3j committed Oct 10, 2024
1 parent f3eb99b commit d1f9ec7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 23 deletions.
27 changes: 14 additions & 13 deletions scc/gui/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""SC-Controller - App.
"""SC Controller - App.
Main application window
"""
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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())


Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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()
Expand Down
15 changes: 9 additions & 6 deletions scc/gui/global_settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env python3
"""
SC-Controller - Global Settings
"""SC Controller - Global Settings.
Currently setups only one thing...
"""
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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")
Expand Down
8 changes: 4 additions & 4 deletions scc/gui/statusicon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit d1f9ec7

Please sign in to comment.