Skip to content

Commit

Permalink
plugin: add a plugin to toggle the menubar's visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitjes committed Feb 23, 2017
1 parent 86d0e94 commit 13d1404
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions quodlibet/quodlibet/ext/events/toggle_menu.py
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

0 comments on commit 13d1404

Please sign in to comment.