How to use the solaar.NAME function in solaar

To help you get started, we’ve selected a few solaar examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pwr-Solaar / Solaar / app / ui / __init__.py View on Github external
#
#

from __future__ import absolute_import, division, print_function, unicode_literals

from gi.repository import GObject, Gtk
GObject.threads_init()

_LARGE_SIZE = 64
Gtk.IconSize.LARGE = Gtk.icon_size_register('large', _LARGE_SIZE, _LARGE_SIZE)
# Gtk.IconSize.XLARGE = Gtk.icon_size_register('x-large', _LARGE_SIZE * 2, _LARGE_SIZE * 2)

from . import notify, status_icon, main_window, pair_window, action

from solaar import NAME
APP_ICON = { 1: NAME, 2: NAME + '-mask', 0: NAME + '-init', -1: NAME + '-fail' }


def get_battery_icon(level):
	if level < 0:
		return 'battery_unknown'
	return 'battery_%03d' % (10 * ((level + 5) // 10))


_ICON_SETS = {}

def device_icon_set(name, kind=None):
	icon_set = _ICON_SETS.get(name)
	if icon_set is None:
		icon_set = Gtk.IconSet.new()
		_ICON_SETS[name] = icon_set
github pwr-Solaar / Solaar / lib / solaar / ui / window.py View on Github external
def init():
	Gtk.Window.set_default_icon_name(NAME.lower())
	Gtk.Window.set_default_icon_from_file(_icons.icon_file(NAME.lower()))

	global _model, _tree, _details, _info, _empty, _window
	_model = Gtk.TreeStore(*_COLUMN_TYPES)
	_tree = _create_tree(_model)
	_details = _create_details_panel()
	_info = _create_info_panel()
	_empty = _create_empty_panel()
	_window = _create()
github pwr-Solaar / Solaar / lib / solaar / cli / __init__.py View on Github external
_sys.exit(2)
		action = args.action
	assert action in actions

	try:
		c = list(_receivers(hidraw_path))
		if not c:
			raise Exception('Logitech receiver not found')

		from importlib import import_module
		m = import_module('.' + action, package=__name__)
		m.run(c, args, _find_receiver, _find_device)
	except AssertionError as e:
		from traceback import extract_tb
		tb_last = extract_tb(_sys.exc_info()[2])[-1]
		_sys.exit('%s: assertion failed: %s line %d' % (NAME.lower(), tb_last[0], tb_last[1]))
	except Exception as e:
		_sys.exit('%s: error: %s' % (NAME.lower(), e))
github pwr-Solaar / Solaar / lib / solaar / i18n.py View on Github external
from glob import glob as _glob

	for location in prefix_share, src_share:
		mo_files = _glob(_path.join(location, 'locale', '*', 'LC_MESSAGES', lc_domain + '.mo'))
		if mo_files:
			return _path.join(location, 'locale')

	# del _path


import locale
locale.setlocale(locale.LC_ALL, '')
language, encoding = locale.getlocale()
del locale

_LOCALE_DOMAIN = _NAME.lower()
path = _find_locale_path(_LOCALE_DOMAIN)

import gettext as _gettext

_gettext.bindtextdomain(_LOCALE_DOMAIN, path)
_gettext.textdomain(_LOCALE_DOMAIN)
_gettext.install(_LOCALE_DOMAIN)

try:
	unicode
	_ = lambda x: _gettext.gettext(x).decode('UTF-8')
	ngettext = lambda *x: _gettext.ngettext(*x).decode('UTF-8')
except:
	_ = _gettext.gettext
	ngettext = _gettext.ngettext
github pwr-Solaar / Solaar / lib / solaar / ui / about.py View on Github external
def _create():
	about = Gtk.AboutDialog()

	about.set_program_name(NAME)
	about.set_version(__version__)
	about.set_comments(_("Shows status of devices connected\nthrough wireless Logitech receivers."))

	about.set_logo_icon_name(NAME.lower())

	about.set_copyright('© 2012-2013 Daniel Pavel')
	about.set_license_type(Gtk.License.GPL_2_0)

	about.set_authors(('Daniel Pavel http://github.com/pwr',))
	try:
		about.add_credit_section(_("GUI design"), ('Julien Gascard', 'Daniel Pavel'))
		about.add_credit_section(_("Testing"), (
						'Douglas Wagner',
						'Julien Gascard',
						'Peter Wu http://www.lekensteyn.nl/logitech-unifying.html',
						))
		about.add_credit_section(_("Logitech documentation"), (
						'Julien Danjou http://julien.danjou.info/blog/2012/logitech-unifying-upower',
						'Nestor Lopez Casado http://drive.google.com/folderview?id=0BxbRzx7vEV7eWmgwazJ3NUFfQ28',
						))
github pwr-Solaar / Solaar / lib / solaar / ui / tray.py View on Github external
def _create(menu):
		icon = Gtk.StatusIcon.new_from_icon_name(_icons.TRAY_INIT)
		icon.set_name(NAME)
		icon.set_title(NAME)
		icon.set_tooltip_text(NAME)
		icon.connect('activate', _window_toggle)
		icon.connect('scroll-event', _scroll)
		icon.connect('popup-menu',
						lambda icon, button, time: menu.popup(None, None, icon.position_menu, icon, button, time))

		return icon
github pwr-Solaar / Solaar / lib / solaar / ui / tray.py View on Github external
def _create(menu):
		icon = Gtk.StatusIcon.new_from_icon_name(_icons.TRAY_INIT)
		icon.set_name(NAME)
		icon.set_title(NAME)
		icon.set_tooltip_text(NAME)
		icon.connect('activate', _window_toggle)
		icon.connect('scroll-event', _scroll)
		icon.connect('popup-menu',
						lambda icon, button, time: menu.popup(None, None, icon.position_menu, icon, button, time))

		return icon
github pwr-Solaar / Solaar / lib / solaar / ui / tray.py View on Github external
def _create(menu):
		theme_paths = Gtk.IconTheme.get_default().get_search_path()

		ind = AppIndicator3.Indicator.new_with_path(
						'indicator-solaar',
						_icons.TRAY_INIT,
						AppIndicator3.IndicatorCategory.HARDWARE,
						':'.join(theme_paths))
		ind.set_title(NAME)
		ind.set_status(AppIndicator3.IndicatorStatus.ACTIVE)
		ind.set_attention_icon_full(_icons.TRAY_ATTENTION, '')
		# ind.set_label(NAME, NAME)

		ind.set_menu(menu)
		ind.connect('scroll-event', _scroll)

		return ind
github pwr-Solaar / Solaar / lib / solaar / ui / about.py View on Github external
def _create():
	about = Gtk.AboutDialog()

	about.set_program_name(NAME)
	about.set_version(__version__)
	about.set_comments(_("Shows status of devices connected\nthrough wireless Logitech receivers."))

	about.set_logo_icon_name(NAME.lower())

	about.set_copyright('© 2012-2013 Daniel Pavel')
	about.set_license_type(Gtk.License.GPL_2_0)

	about.set_authors(('Daniel Pavel http://github.com/pwr',))
	try:
		about.add_credit_section(_("GUI design"), ('Julien Gascard', 'Daniel Pavel'))
		about.add_credit_section(_("Testing"), (
						'Douglas Wagner',
						'Julien Gascard',
						'Peter Wu http://www.lekensteyn.nl/logitech-unifying.html',
						))
github pwr-Solaar / Solaar / lib / solaar / ui / tray.py View on Github external
def _create(menu):
		icon = Gtk.StatusIcon.new_from_icon_name(_icons.TRAY_INIT)
		icon.set_name(NAME)
		icon.set_title(NAME)
		icon.set_tooltip_text(NAME)
		icon.connect('activate', _window_toggle)
		icon.connect('scroll-event', _scroll)
		icon.connect('popup-menu',
						lambda icon, button, time: menu.popup(None, None, icon.position_menu, icon, button, time))

		return icon