parent
ef701c2c43
commit
712d321bf3
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk, Gdk
|
||||
|
||||
from .image_button import ImageButton
|
||||
from .option_menu import OptionMenu
|
||||
|
||||
from assets import image_dict
|
||||
|
||||
class Topbar(Gtk.EventBox):
|
||||
|
||||
def __init__(self, app, win):
|
||||
Gtk.EventBox.__init__(self)
|
||||
|
||||
self.window = win
|
||||
|
||||
self.set_size_request(320, 26)
|
||||
|
||||
box = Gtk.Fixed()
|
||||
|
||||
menu_btn = ImageButton(image_dict['menu'])
|
||||
popup_menu = OptionMenu(app)
|
||||
menu_btn.connect('clicked', lambda btn: popup_menu.show(btn))
|
||||
box.put(menu_btn, 276, 6)
|
||||
|
||||
self.connect("button-press-event", self.on_drag)
|
||||
self.add(box)
|
||||
|
||||
|
||||
def on_drag(self, widget, event):
|
||||
if event.button == Gdk.BUTTON_PRIMARY:
|
||||
self.window.begin_move_drag(
|
||||
event.button,
|
||||
int(event.x_root),
|
||||
int(event.y_root),
|
||||
event.time)
|
|
@ -9,12 +9,12 @@ from utils import blur_image, pic_to_pixbuf, base64_to_pixbuf, idle
|
|||
|
||||
from assets import image_dict
|
||||
|
||||
from ui.topbar import Topbar
|
||||
from ui.image import ScaleImage
|
||||
from ui.image_button import ImageButton
|
||||
from ui.title_text import TitleText
|
||||
from ui.ctrl_box import CtrlBox
|
||||
from ui.timebar import Timebar
|
||||
from ui.option_menu import OptionMenu
|
||||
from ui.disk_box import DiskBox
|
||||
|
||||
|
||||
|
@ -50,7 +50,6 @@ class SonistWindow(Gtk.Window):
|
|||
|
||||
|
||||
self.connect("destroy", lambda win: app.remove_window(win))
|
||||
# self.connect("button-press-event", self.on_drag_start)
|
||||
|
||||
self.mpd.connect('offline', lambda o: self.reset_player())
|
||||
self.mpd.connect('online', lambda o: self.sync_state(None, None, True))
|
||||
|
@ -61,11 +60,9 @@ class SonistWindow(Gtk.Window):
|
|||
|
||||
layout = Gtk.Layout()
|
||||
|
||||
# 菜单按钮
|
||||
menu_btn = ImageButton(image_dict['menu'])
|
||||
popup_menu = OptionMenu(app)
|
||||
menu_btn.connect('clicked', lambda btn: popup_menu.show(btn))
|
||||
layout.put(menu_btn, 276, 6)
|
||||
# 内嵌的标题栏
|
||||
bar = Topbar(app, self)
|
||||
layout.put(bar, 0, 0)
|
||||
|
||||
# 唱片
|
||||
disk = DiskBox()
|
||||
|
@ -140,13 +137,6 @@ class SonistWindow(Gtk.Window):
|
|||
self.style_context.add_provider_for_screen(self.screen, provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
|
||||
|
||||
|
||||
def on_drag_start(self, widget, event):
|
||||
self.begin_move_drag(
|
||||
event.button,
|
||||
int(event.x_root),
|
||||
int(event.y_root),
|
||||
event.time)
|
||||
|
||||
def get_mpd_stat(self):
|
||||
try:
|
||||
self.stat = self.mpd.status()
|
||||
|
|
Loading…
Reference in New Issue