61 lines
1.4 KiB
Python
61 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
|
|
import gi
|
|
gi.require_version('Gtk', '3.0')
|
|
from gi.repository import Gtk, Gdk, GObject
|
|
|
|
from .image import ScaleImage
|
|
|
|
class OptionMenu(Gtk.Menu):
|
|
def __init__(self, app):
|
|
Gtk.Menu.__init__(self)
|
|
self.app = app
|
|
|
|
btn_icos = [
|
|
'./usr/share/sonist/setting.png',
|
|
'./usr/share/sonist/pin.png',
|
|
'./usr/share/sonist/switch.png',
|
|
'./usr/share/sonist/info.png'
|
|
]
|
|
btn_txts = [
|
|
'首选项',
|
|
'窗口置顶',
|
|
'退出应用',
|
|
'关于播放器'
|
|
]
|
|
|
|
|
|
for i in range(4):
|
|
item = Gtk.MenuItem()
|
|
box = Gtk.Box(spacing = 0)
|
|
label = Gtk.Label(label = btn_txts[i])
|
|
img = ScaleImage(btn_icos[i]).resize(16, 16)
|
|
|
|
box.set_size_request(92, 32)
|
|
box.pack_start(img, False, False, 0)
|
|
box.pack_start(label, False, False, 6)
|
|
item.name = btn_txts[i]
|
|
item.add(box)
|
|
item.connect('activate', self.on_menu_select)
|
|
self.append(item)
|
|
|
|
self.show_all()
|
|
|
|
|
|
def on_menu_select(self, item):
|
|
match(item.name):
|
|
case '首选项':
|
|
pass
|
|
case '窗口置顶':
|
|
pass
|
|
case '退出应用':
|
|
pass
|
|
case '关于播放器':
|
|
self.app.about.present()
|
|
pass
|
|
|
|
|
|
|
|
def show(self, widget):
|
|
# 在按钮下方显示菜单
|
|
self.popup_at_widget(widget, Gdk.Gravity.NORTH_WEST, Gdk.Gravity.NORTH_WEST, None) |