ui: add option to specify use of explict tray icon files and their size
This commit is contained in:
parent
f83c927a1e
commit
adae5a2e2b
|
@ -121,8 +121,11 @@ for the step-by-step procedure for manual installation.
|
||||||
- If some icons appear broken in the application, make sure you've properly
|
- If some icons appear broken in the application, make sure you've properly
|
||||||
configured the Gtk theme and icon theme in your control panel.
|
configured the Gtk theme and icon theme in your control panel.
|
||||||
|
|
||||||
- There are several implementations of the system tray. Some of these have problems
|
- Solaar normally uses icon names for its icons, which in some system tray implementatations
|
||||||
that can result in missing or wrong-sized icons.
|
results in missing or wrong-sized icons.
|
||||||
|
The `--tray-icon-size` option forces Solaar to use icon files of appropriate size
|
||||||
|
for tray icons instead, which produces better results in some system tray implementatations.
|
||||||
|
To use icon files close to 32 pixels in size use `--tray-icon-size=32`.
|
||||||
|
|
||||||
- The icon in the system tray can show up as 'black on black' in dark
|
- The icon in the system tray can show up as 'black on black' in dark
|
||||||
themes or as non-symbolic when the theme uses symbolic icons. This is due to problems
|
themes or as non-symbolic when the theme uses symbolic icons. This is due to problems
|
||||||
|
|
|
@ -81,6 +81,7 @@ def _parse_arguments():
|
||||||
choices=('regular', 'symbolic', 'solaar'),
|
choices=('regular', 'symbolic', 'solaar'),
|
||||||
help='prefer regular battery / symbolic battery / solaar icons'
|
help='prefer regular battery / symbolic battery / solaar icons'
|
||||||
)
|
)
|
||||||
|
arg_parser.add_argument('--tray-icon-size', type=int, help='explicit size for tray icons')
|
||||||
arg_parser.add_argument('-V', '--version', action='version', version='%(prog)s ' + __version__)
|
arg_parser.add_argument('-V', '--version', action='version', version='%(prog)s ' + __version__)
|
||||||
arg_parser.add_argument('--help-actions', action='store_true', help='print help for the optional actions')
|
arg_parser.add_argument('--help-actions', action='store_true', help='print help for the optional actions')
|
||||||
arg_parser.add_argument('action', nargs=argparse.REMAINDER, choices=_cli.actions, help='optional actions to perform')
|
arg_parser.add_argument('action', nargs=argparse.REMAINDER, choices=_cli.actions, help='optional actions to perform')
|
||||||
|
@ -96,6 +97,8 @@ def _parse_arguments():
|
||||||
|
|
||||||
global battery_icons_style
|
global battery_icons_style
|
||||||
battery_icons_style = args.battery_icons if args.battery_icons is not None else 'regular'
|
battery_icons_style = args.battery_icons if args.battery_icons is not None else 'regular'
|
||||||
|
global tray_icon_size
|
||||||
|
tray_icon_size = args.tray_icon_size
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
if args.debug > 0:
|
if args.debug > 0:
|
||||||
|
|
|
@ -42,7 +42,7 @@ del getLogger
|
||||||
# constants
|
# constants
|
||||||
#
|
#
|
||||||
|
|
||||||
_TRAY_ICON_SIZE = 64 # pixels - make large as downscaling is done but not always upscaling
|
_TRAY_ICON_SIZE = 48
|
||||||
_MENU_ICON_SIZE = Gtk.IconSize.LARGE_TOOLBAR
|
_MENU_ICON_SIZE = Gtk.IconSize.LARGE_TOOLBAR
|
||||||
_RECEIVER_SEPARATOR = ('~', None, None, None)
|
_RECEIVER_SEPARATOR = ('~', None, None, None)
|
||||||
|
|
||||||
|
@ -174,9 +174,11 @@ try:
|
||||||
# https://bugs.launchpad.net/ubuntu/+source/libappindicator/+bug/1363277
|
# https://bugs.launchpad.net/ubuntu/+source/libappindicator/+bug/1363277
|
||||||
# Defense against bug that shows up in XFCE 4.16 where icons are not upscaled
|
# Defense against bug that shows up in XFCE 4.16 where icons are not upscaled
|
||||||
def _icon_file(icon_name):
|
def _icon_file(icon_name):
|
||||||
if False and not os.path.isfile(icon_name):
|
if gtk.tray_icon_size is None and not os.path.isfile(icon_name):
|
||||||
return icon_name
|
return icon_name
|
||||||
icon_info = Gtk.IconTheme.get_default().lookup_icon(icon_name, _TRAY_ICON_SIZE, Gtk.IconLookupFlags.FORCE_SVG)
|
icon_info = Gtk.IconTheme.get_default().lookup_icon(
|
||||||
|
icon_name, gtk.tray_icon_size or _TRAY_ICON_SIZE, Gtk.IconLookupFlags.FORCE_SVG
|
||||||
|
)
|
||||||
return icon_info.get_filename() if icon_info else icon_name
|
return icon_info.get_filename() if icon_info else icon_name
|
||||||
|
|
||||||
def _create(menu):
|
def _create(menu):
|
||||||
|
|
Loading…
Reference in New Issue