-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
plugin: add a plugin to toggle the menubar's visibility
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 Christoph Reiter | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License version 2 as | ||
# published by the Free Software Foundation | ||
|
||
from gi.repository import Gdk | ||
|
||
from quodlibet import _ | ||
from quodlibet import app | ||
from quodlibet.plugins.events import EventPlugin | ||
from quodlibet.qltk import Icons | ||
|
||
|
||
class ToggleMenuBarPlugin(EventPlugin): | ||
PLUGIN_ID = "ToggleMenuBar" | ||
PLUGIN_NAME = _("Toggle Menu Bar") | ||
PLUGIN_DESC = _("Toggle the menu bar by pressing the Alt key.") | ||
PLUGIN_ICON = Icons.EDIT | ||
|
||
def enabled(self): | ||
window = app.window | ||
|
||
# Maybe this should be made directly accessible | ||
menubar = window.get_children()[0].get_children()[0] | ||
|
||
# Menu bar visibility toggle | ||
def toggle_menubar(widget, event): | ||
if event.state == Gdk.ModifierType.MOD1_MASK: | ||
menubar.set_visible(not menubar.get_visible()) | ||
|
||
self._handler = window.connect('key_release_event', toggle_menubar) | ||
|
||
def disabled(self): | ||
window = app.window | ||
window.disconnect(self._handler) | ||
del self._handler |