/usr/share/pyshared/quodlibet/qltk/menubutton.py is in exfalso 3.0.2-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | # -*- coding: utf-8 -*-
# Copyright 2011 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 Gtk
from quodlibet import qltk
class MenuButton(Gtk.ToggleButton):
__menu = None
__menu_sig = None
def __init__(self, widget, arrow=False):
super(MenuButton, self).__init__()
bbox = Gtk.HBox(spacing=3)
bbox.pack_start(widget, True, True, 0)
if arrow:
bbox.pack_start(Gtk.Arrow(Gtk.ArrowType.DOWN, Gtk.ShadowType.IN),
True, True, 0)
self.add(bbox)
self.connect("toggled", self.__toggled_cb)
self.connect("button-press-event", self.__press_cb)
self.connect("destroy", self.__destroy)
def get_menu(self):
return self.__menu
def set_menu(self, menu):
if self.__menu:
self.__menu.disconnect(self.__menu_sig)
self.__menu = menu
self.__menu_sig = menu.connect("deactivate",
self.__menu_deactivate_cb, self)
def __destroy(self, *args):
if self.__menu:
self.__menu.disconnect(self.__menu_sig)
self.__menu = None
def __menu_deactivate_cb(self, menu, button):
button.set_active(False)
def __press_cb(self, widget, event):
if self.__menu and event.button == 1:
qltk.popup_menu_under_widget(
self.__menu, widget, event.button, event.time)
widget.set_active(True)
return False
def __toggled_cb(self, widget):
menu = self.__menu
if widget.get_active() and menu:
time = Gtk.get_current_event_time()
qltk.popup_menu_under_widget(menu, widget, 0, time)
elif menu:
menu.popdown()
|