split the about window into its own module
This commit is contained in:
parent
49ecd252ed
commit
5e68094e87
|
|
@ -5,3 +5,4 @@
|
||||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__version__ = '0.8.7.1'
|
__version__ = '0.8.7.1'
|
||||||
|
NAME = 'Solaar'
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,7 @@
|
||||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
|
||||||
NAME = 'Solaar'
|
from solaar import __version__, NAME
|
||||||
from solaar import __version__
|
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
from gi.repository import Gtk
|
||||||
|
|
||||||
|
from solaar import __version__, NAME
|
||||||
|
|
||||||
|
|
||||||
|
def show_window(action):
|
||||||
|
about = Gtk.AboutDialog()
|
||||||
|
|
||||||
|
about.set_icon_name(NAME.lower())
|
||||||
|
about.set_program_name(NAME)
|
||||||
|
about.set_logo_icon_name(NAME.lower())
|
||||||
|
about.set_version(__version__)
|
||||||
|
about.set_comments('Shows status of devices connected\nto a Logitech Unifying Receiver.')
|
||||||
|
|
||||||
|
about.set_copyright(b'\xC2\xA9'.decode('utf-8') + ' 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('Testing', (
|
||||||
|
'Douglas Wagner',
|
||||||
|
'Julien Gascard',
|
||||||
|
'Peter Wu http://www.lekensteyn.nl/logitech-unifying.html',
|
||||||
|
))
|
||||||
|
about.add_credit_section('Technical specifications\nprovided by', (
|
||||||
|
'Julien Danjou http://julien.danjou.info/blog/2012/logitech-unifying-upower',
|
||||||
|
'Nestor Lopez Casado https://drive.google.com/folderview?id=0BxbRzx7vEV7eWmgwazJ3NUFfQ28'
|
||||||
|
))
|
||||||
|
except TypeError:
|
||||||
|
# gtk3 < 3.6 has incorrect gi bindings
|
||||||
|
import logging
|
||||||
|
logging.exception("failed to fully create the about dialog")
|
||||||
|
except:
|
||||||
|
# is the Gtk3 version too old?
|
||||||
|
import logging
|
||||||
|
logging.exception("failed to fully create the about dialog")
|
||||||
|
|
||||||
|
about.set_website('http://pwr.github.io/Solaar/')
|
||||||
|
about.set_website_label(NAME)
|
||||||
|
|
||||||
|
about.run()
|
||||||
|
about.destroy()
|
||||||
|
|
@ -6,13 +6,6 @@ from __future__ import absolute_import, division, print_function, unicode_litera
|
||||||
|
|
||||||
from gi.repository import Gtk, Gdk
|
from gi.repository import Gtk, Gdk
|
||||||
|
|
||||||
from . import notify, pair_window
|
|
||||||
from ..ui import error_dialog
|
|
||||||
|
|
||||||
|
|
||||||
_NAME = 'Solaar'
|
|
||||||
from solaar import __version__
|
|
||||||
|
|
||||||
|
|
||||||
def make(name, label, function, *args):
|
def make(name, label, function, *args):
|
||||||
action = Gtk.Action(name, label, label, None)
|
action = Gtk.Action(name, label, label, None)
|
||||||
|
|
@ -32,58 +25,24 @@ def make_toggle(name, label, function, *args):
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
def _toggle_notifications(action):
|
# def _toggle_notifications(action):
|
||||||
if action.get_active():
|
# if action.get_active():
|
||||||
notify.init('Solaar')
|
# notify.init('Solaar')
|
||||||
else:
|
# else:
|
||||||
notify.uninit()
|
# notify.uninit()
|
||||||
action.set_sensitive(notify.available)
|
# action.set_sensitive(notify.available)
|
||||||
toggle_notifications = make_toggle('notifications', 'Notifications', _toggle_notifications)
|
# toggle_notifications = make_toggle('notifications', 'Notifications', _toggle_notifications)
|
||||||
|
|
||||||
|
|
||||||
def _show_about_window(action):
|
from .about import show_window as _show_about_window
|
||||||
about = Gtk.AboutDialog()
|
from solaar import NAME
|
||||||
|
about = make('help-about', 'About ' + NAME, _show_about_window)
|
||||||
about.set_icon_name(_NAME.lower())
|
|
||||||
about.set_program_name(_NAME)
|
|
||||||
about.set_logo_icon_name(_NAME.lower())
|
|
||||||
about.set_version(__version__)
|
|
||||||
about.set_comments('Shows status of devices connected\nto a Logitech Unifying Receiver.')
|
|
||||||
|
|
||||||
about.set_copyright(b'\xC2\xA9'.decode('utf-8') + ' 2012 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('Testing', (
|
|
||||||
'Douglas Wagner',
|
|
||||||
'Julien Gascard',
|
|
||||||
'Peter Wu http://www.lekensteyn.nl/logitech-unifying.html',
|
|
||||||
))
|
|
||||||
about.add_credit_section('Technical specifications\nprovided by', (
|
|
||||||
'Julien Danjou http://julien.danjou.info/blog/2012/logitech-unifying-upower',
|
|
||||||
'Nestor Lopez Casado https://drive.google.com/folderview?id=0BxbRzx7vEV7eWmgwazJ3NUFfQ28'
|
|
||||||
))
|
|
||||||
except TypeError:
|
|
||||||
# gtk3 < 3.6 has incorrect gi bindings
|
|
||||||
import logging
|
|
||||||
logging.exception("failed to fully create the about dialog")
|
|
||||||
except:
|
|
||||||
# is the Gtk3 version too old?
|
|
||||||
import logging
|
|
||||||
logging.exception("failed to fully create the about dialog")
|
|
||||||
|
|
||||||
about.set_website('http://pwr.github.io/Solaar/')
|
|
||||||
about.set_website_label('Solaar')
|
|
||||||
|
|
||||||
about.run()
|
|
||||||
about.destroy()
|
|
||||||
about = make('help-about', 'About ' + _NAME, _show_about_window)
|
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from . import pair_window
|
||||||
def _pair_device(action, frame):
|
def _pair_device(action, frame):
|
||||||
window = frame.get_toplevel()
|
window = frame.get_toplevel()
|
||||||
|
|
||||||
|
|
@ -99,6 +58,7 @@ def pair(frame):
|
||||||
return make('list-add', 'Pair new device', _pair_device, frame)
|
return make('list-add', 'Pair new device', _pair_device, frame)
|
||||||
|
|
||||||
|
|
||||||
|
from ..ui import error_dialog
|
||||||
def _unpair_device(action, frame):
|
def _unpair_device(action, frame):
|
||||||
window = frame.get_toplevel()
|
window = frame.get_toplevel()
|
||||||
# window.present()
|
# window.present()
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera
|
||||||
|
|
||||||
from gi.repository import Gtk, Gdk, GLib
|
from gi.repository import Gtk, Gdk, GLib
|
||||||
|
|
||||||
|
from solaar import NAME
|
||||||
from logitech.unifying_receiver import status as _status
|
from logitech.unifying_receiver import status as _status
|
||||||
from . import config_panel as _config_panel
|
from . import config_panel as _config_panel
|
||||||
from . import action as _action, icons as _icons
|
from . import action as _action, icons as _icons
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,9 @@ try:
|
||||||
from gi.repository import Notify
|
from gi.repository import Notify
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from solaar import NAME
|
||||||
from . import icons as _icons
|
from . import icons as _icons
|
||||||
|
|
||||||
|
|
||||||
_NAMESPACE = 'Solaar'
|
|
||||||
# assumed to be working since the import succeeded
|
# assumed to be working since the import succeeded
|
||||||
available = True
|
available = True
|
||||||
|
|
||||||
|
|
@ -28,7 +27,7 @@ try:
|
||||||
if not Notify.is_initted():
|
if not Notify.is_initted():
|
||||||
logging.info("starting desktop notifications")
|
logging.info("starting desktop notifications")
|
||||||
try:
|
try:
|
||||||
return Notify.init(_NAMESPACE)
|
return Notify.init(NAME)
|
||||||
except:
|
except:
|
||||||
logging.exception("initializing desktop notifications")
|
logging.exception("initializing desktop notifications")
|
||||||
available = False
|
available = False
|
||||||
|
|
@ -42,13 +41,33 @@ try:
|
||||||
Notify.uninit()
|
Notify.uninit()
|
||||||
|
|
||||||
|
|
||||||
def toggle(action):
|
# def toggle(action):
|
||||||
if action.get_active():
|
# if action.get_active():
|
||||||
init()
|
# init()
|
||||||
else:
|
# else:
|
||||||
uninit()
|
# uninit()
|
||||||
action.set_sensitive(available)
|
# action.set_sensitive(available)
|
||||||
return action.get_active()
|
# return action.get_active()
|
||||||
|
|
||||||
|
|
||||||
|
def alert(reason):
|
||||||
|
assert reason
|
||||||
|
|
||||||
|
if available and Notify.is_initted():
|
||||||
|
n = _notifications.get(NAME)
|
||||||
|
if n is None:
|
||||||
|
n = _notifications[NAME] = Notify.Notification()
|
||||||
|
|
||||||
|
# we need to use the filename here because the notifications daemon
|
||||||
|
# is an external application that does not know about our icon sets
|
||||||
|
n.update(NAME, reason, _icons.icon_file(NAME.lower()))
|
||||||
|
n.set_urgency(Notify.Urgency.NORMAL)
|
||||||
|
|
||||||
|
try:
|
||||||
|
# logging.debug("showing %s", n)
|
||||||
|
n.show()
|
||||||
|
except Exception:
|
||||||
|
logging.exception("showing %s", n)
|
||||||
|
|
||||||
|
|
||||||
def show(dev, reason=None):
|
def show(dev, reason=None):
|
||||||
|
|
@ -80,5 +99,6 @@ except ImportError:
|
||||||
available = False
|
available = False
|
||||||
init = lambda: False
|
init = lambda: False
|
||||||
uninit = lambda: None
|
uninit = lambda: None
|
||||||
toggle = lambda action: False
|
# toggle = lambda action: False
|
||||||
|
alert = lambda reason: None
|
||||||
show = lambda dev, reason=None: None
|
show = lambda dev, reason=None: None
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ from gi.repository import Gtk, GdkPixbuf
|
||||||
from . import (action as _action,
|
from . import (action as _action,
|
||||||
icons as _icons,
|
icons as _icons,
|
||||||
main_window as _main_window)
|
main_window as _main_window)
|
||||||
|
from solaar import NAME
|
||||||
from logitech.unifying_receiver import status as _status
|
from logitech.unifying_receiver import status as _status
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
@ -18,16 +19,15 @@ from logitech.unifying_receiver import status as _status
|
||||||
_NO_DEVICES = [None] * 6
|
_NO_DEVICES = [None] * 6
|
||||||
|
|
||||||
def create(window):
|
def create(window):
|
||||||
name = window.get_title()
|
|
||||||
|
|
||||||
icon = Gtk.StatusIcon()
|
icon = Gtk.StatusIcon()
|
||||||
icon.set_title(name)
|
icon.set_title(NAME)
|
||||||
icon.set_name(name)
|
icon.set_name(NAME)
|
||||||
icon.set_from_icon_name(_icons.APP_ICON[0])
|
icon.set_from_icon_name(_icons.APP_ICON[0])
|
||||||
icon._devices = list(_NO_DEVICES)
|
icon._devices = list(_NO_DEVICES)
|
||||||
|
|
||||||
icon.set_tooltip_text(name)
|
|
||||||
icon.connect('activate', _main_window.toggle, window)
|
icon.connect('activate', _main_window.toggle, window)
|
||||||
|
icon.set_tooltip_text(NAME)
|
||||||
|
|
||||||
menu = Gtk.Menu()
|
menu = Gtk.Menu()
|
||||||
|
|
||||||
|
|
@ -89,7 +89,7 @@ def update(icon, device):
|
||||||
return
|
return
|
||||||
|
|
||||||
def _lines(r, devices):
|
def _lines(r, devices):
|
||||||
yield '<b>Solaar</b>: %s' % r.status
|
yield '<b>%s</b>: %s' % (NAME, r.status)
|
||||||
yield ''
|
yield ''
|
||||||
|
|
||||||
for dev in devices:
|
for dev in devices:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue