Skip to content

Commit

Permalink
osx: disable mmkeys through a config entry and expose it in the advan…
Browse files Browse the repository at this point in the history
…ced prefs plugin. See #1817
  • Loading branch information
lazka committed Feb 18, 2016
1 parent f1e7733 commit c2d560b
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 24 deletions.
2 changes: 0 additions & 2 deletions osx_bundle/misc/bundle/launcher.sh
Expand Up @@ -45,8 +45,6 @@ fi
export PYTHON="$bundle_contents/MacOS/python"
export PYTHONHOME="$bundle_res"

# temporary disable multimedia keys
export QUODLIBET_NO_MMKEYS=yes
# temporary disable tooltips
export QUODLIBET_NO_HINTS=yes

Expand Down
3 changes: 0 additions & 3 deletions quodlibet/docs/development/faq.rst
Expand Up @@ -122,9 +122,6 @@ QUODLIBET_DEBUG
QUODLIBET_NO_TRANS
When in the environment disables translations

QUODLIBET_NO_MMKEYS
When in the environment disables multimedia keys support

QUODLIBET_BACKEND
Can be set to the audio backend, overriding the value present in the main
config file. Useful for quickly testing a different audio backend.
Expand Down
6 changes: 3 additions & 3 deletions quodlibet/quodlibet.py
Expand Up @@ -174,9 +174,9 @@ def show_backend_error(window):
except ImportError:
DBusHandler = lambda player, library: None

mmkeys_handler = MMKeysHandler(app.name, window, player)
if "QUODLIBET_NO_MMKEYS" not in os.environ:
mmkeys_handler.start()
mmkeys_handler = MMKeysHandler(app)
mmkeys_handler.start()

current_path = os.path.join(quodlibet.get_user_dir(), "current")
fsiface = FSInterface(current_path, player)
remote = Remote(app, cmd_registry)
Expand Down
3 changes: 3 additions & 0 deletions quodlibet/quodlibet/config.py
Expand Up @@ -120,6 +120,9 @@
# If set to "true" allow directly deleting files, even on systems that
# support sending them to the trash.
"bypass_trash": "false",

# our implementation is buggy and disabled by default
"osx_mmkeys": "false",
},
"rename": {
"spaces": "false",
Expand Down
6 changes: 6 additions & 0 deletions quodlibet/quodlibet/ext/events/advanced_preferences.py
Expand Up @@ -135,6 +135,12 @@ def changed(entry, name, section="settings"):
("Size of the album cover images in the album list browser "
"(restart required)")))

rows.append(
boolean_config(
"settings", "osx_mmkeys",
"OS X Multimedia Keys:",
"Enable experimental mmkeys support (restart required)"))

for (row, (label, entry, button)) in enumerate(rows):
label.set_alignment(1.0, 0.5)
table.attach(label, 0, 1, row, row + 1,
Expand Down
23 changes: 13 additions & 10 deletions quodlibet/quodlibet/mmkeys/__init__.py
Expand Up @@ -5,6 +5,8 @@
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation

from quodlibet import config

from ._base import MMKeysAction, MMKeysImportError


Expand All @@ -31,12 +33,13 @@ def iter_backends():
else:
yield PyHookBackend

try:
from .osx import OSXBackend
except MMKeysImportError:
pass
else:
yield OSXBackend
if config.getboolean("settings", "osx_mmkeys"):
try:
from .osx import OSXBackend
except MMKeysImportError:
pass
else:
yield OSXBackend


def find_active_backend():
Expand All @@ -52,11 +55,11 @@ class MMKeysHandler(object):
events to actions on the player backend.
"""

def __init__(self, app_name, window, player):
def __init__(self, app):
self._backend = None
self._window = window
self._player = player
self._app_name = app_name
self._window = app.window
self._player = app.player
self._app_name = app.name

def start(self):
kind = find_active_backend()
Expand Down
15 changes: 9 additions & 6 deletions quodlibet/tests/test_mmkeys.py
@@ -1,17 +1,20 @@
# -*- coding: utf-8 -*-
from tests import TestCase
from tests import TestCase, init_fake_app, destroy_fake_app

from gi.repository import Gtk

from quodlibet.player.nullbe import NullPlayer
from quodlibet import app
from quodlibet.mmkeys import MMKeysHandler, iter_backends


class TMmKeys(TestCase):

def setUp(self):
init_fake_app()

def tearDown(self):
destroy_fake_app()

def test_handler(self):
win = Gtk.Window()
handler = MMKeysHandler("Foo", win, NullPlayer())
handler = MMKeysHandler(app)
handler.quit()

def test_backends(self):
Expand Down

0 comments on commit c2d560b

Please sign in to comment.