Skip to content

Commit

Permalink
refactor statusIconInit in scal3/ui_gtk/starcal.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Feb 29, 2024
1 parent 17c24a7 commit 68e0be9
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions scal3/ui_gtk/starcal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1160,33 +1160,37 @@ def updateStatusIconClock(self, checkStatusIconMode=True):
# def weekCalShow(self, obj=None, data=None):
# openWindow(ui.weekCalWin)

def useAppIndicator(self) -> bool:
if not ui.useAppIndicator:
return False
try:
import scal3.ui_gtk.starcal_appindicator # noqa: F401
except (ImportError, ValueError):
return False
return True

def statusIconInit(self):
if self.statusIconMode != 2:
self.sicon = None
return

useAppIndicator = ui.useAppIndicator
if useAppIndicator:
try:
import scal3.ui_gtk.starcal_appindicator # noqa: F401
except (ImportError, ValueError):
useAppIndicator = False
if useAppIndicator:
if self.useAppIndicator():
from scal3.ui_gtk.starcal_appindicator import (
IndicatorStatusIconWrapper,
)

self.sicon = IndicatorStatusIconWrapper(self)
else:
self.sicon = gtk.StatusIcon()
self.sicon.set_title(core.APP_DESC)
self.sicon.set_visible(True) # is needed?
self.sicon.connect(
"button-press-event",
self.onStatusIconPress,
)
self.sicon.connect("activate", self.onStatusIconClick)
self.sicon.connect("popup-menu", self.statusIconPopup)
return

self.sicon = gtk.StatusIcon()
self.sicon.set_title(core.APP_DESC)
self.sicon.set_visible(True) # is needed?
self.sicon.connect(
"button-press-event",
self.onStatusIconPress,
)
self.sicon.connect("activate", self.onStatusIconClick)
self.sicon.connect("popup-menu", self.statusIconPopup)

def getMainWinMenuItem(self):
item = gtk.MenuItem(label=_("Main Window"))
Expand Down

0 comments on commit 68e0be9

Please sign in to comment.