some debugging when setting icon theme paths

This commit is contained in:
Daniel Pavel 2013-06-01 15:08:23 +02:00
parent 83a29328c7
commit 7317fad754
2 changed files with 18 additions and 6 deletions

View File

@ -5,12 +5,17 @@
from __future__ import absolute_import, division, print_function, unicode_literals
import logging
_DEBUG = logging.DEBUG
_log = logging.getLogger('solaar.ui')
def _look_for_application_icons():
import os.path as _path
import os as _os
import sys as _sys
# print ("path[0] = %s" % _sys.path[0])
_log.debug("sys.path[0] = %s", _sys.path[0])
prefix_share = _path.normpath(_path.join(_path.realpath(_sys.path[0]), '..'))
src_share = _path.normpath(_path.join(_path.realpath(_sys.path[0]), '..', 'share'))
local_share = _os.environ.get('XDG_DATA_HOME', _path.expanduser('~/.local/share'))
@ -19,11 +24,12 @@ def _look_for_application_icons():
share_solaar = [prefix_share] + list(_path.join(x, 'solaar') for x in [src_share, local_share] + data_dirs.split(':'))
for location in share_solaar:
# print ("checking %s" % location)
if _log.isEnabledFor(_DEBUG):
_log.debug("looking for icons in %s", location)
solaar_png = _path.join(location, 'icons', 'solaar-mask.png')
if _path.exists(solaar_png):
_os.environ['XDG_DATA_DIRS'] = location + ':' + data_dirs
# print ('XDG_DATA_DIRS=%s' % _os.environ['XDG_DATA_DIRS'])
_log.info("XDG_DATA_DIRS = %s", _os.environ['XDG_DATA_DIRS'])
break
del _os
@ -43,7 +49,6 @@ def error_dialog(title, text):
m.run()
m.destroy()
#
#
#
@ -54,3 +59,4 @@ from . import notify, main_window
from . import icons
Gtk.Window.set_default_icon_from_file(icons.icon_file(main_window.NAME.lower()))
# Gtk.Window.set_default_icon_name(main_window.NAME.lower())

View File

@ -4,6 +4,10 @@
from __future__ import absolute_import, division, print_function, unicode_literals
import logging
_DEBUG = logging.DEBUG
_log = logging.getLogger('solaar.ui.icons')
from gi.repository import Gtk
#
@ -20,9 +24,11 @@ Gtk.IconSize.LARGE = Gtk.icon_size_register('large', _LARGE_SIZE, _LARGE_SIZE)
# print ("dnd", int(Gtk.IconSize.DND), Gtk.icon_size_lookup(Gtk.IconSize.DND))
# print ("dialog", int(Gtk.IconSize.DIALOG), Gtk.icon_size_lookup(Gtk.IconSize.DIALOG))
APP_ICON = { 1: 'solaar', 2: 'solaar-mask', 0: 'solaar-init', -1: 'solaar-fail' }
_default_theme = Gtk.IconTheme.get_default()
_log.debug("icon theme paths: %s", _default_theme.get_search_path())
#
#
#
@ -30,7 +36,7 @@ APP_ICON = { 1: 'solaar', 2: 'solaar-mask', 0: 'solaar-init', -1: 'solaar-fail'
def battery(level=None, charging=False):
if level is None or level < 0:
return 'battery_unknown'
return 'battery_%03d' % (10 * ((level + 5) // 10))
return 'battery_%03d' % (20 * ((level + 10) // 20))
def lux(level=None):