调整mpd stop状态时的读取; 隐藏窗口的标题栏;
parent
4ae5a975be
commit
6b1fa4daae
|
@ -103,7 +103,9 @@ class Application(Gtk.Application):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
try:
|
||||||
app = Application()
|
app = Application()
|
||||||
app.run(sys.argv)
|
app.run(sys.argv)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ class SonistWindow(Gtk.Window):
|
||||||
self.set_default_style()
|
self.set_default_style()
|
||||||
|
|
||||||
self.connect("destroy", lambda win: app.remove_window(win))
|
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('offline', lambda o: self.reset_player())
|
||||||
self.mpd.connect('online', lambda o: self.sync_state(None, None, True))
|
self.mpd.connect('online', lambda o: self.sync_state(None, None, True))
|
||||||
|
@ -45,6 +46,7 @@ class SonistWindow(Gtk.Window):
|
||||||
self.mpd.connect('volume_changed', lambda o, vol: self.update_volume(vol))
|
self.mpd.connect('volume_changed', lambda o, vol: self.update_volume(vol))
|
||||||
self.mpd.connect('playing', lambda o, stat, song: self.update_playtime(stat))
|
self.mpd.connect('playing', lambda o, stat, song: self.update_playtime(stat))
|
||||||
|
|
||||||
|
self.set_decorated(False)
|
||||||
self.set_name('SonistWindow')
|
self.set_name('SonistWindow')
|
||||||
self.set_title('Sonist')
|
self.set_title('Sonist')
|
||||||
self.set_default_size(320, 384)
|
self.set_default_size(320, 384)
|
||||||
|
@ -151,7 +153,12 @@ class SonistWindow(Gtk.Window):
|
||||||
self.style_context.add_provider_for_screen(self.screen, provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
|
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):
|
def get_mpd_stat(self):
|
||||||
try:
|
try:
|
||||||
|
@ -285,7 +292,10 @@ class SonistWindow(Gtk.Window):
|
||||||
song_num = int(self.mpd.stats().get('songs') or 0)
|
song_num = int(self.mpd.stats().get('songs') or 0)
|
||||||
playlist = [it['file'] for it in self.mpd.playlistinfo()]
|
playlist = [it['file'] for it in self.mpd.playlistinfo()]
|
||||||
|
|
||||||
self.ctrl_box.disabled = song_num == 0
|
|
||||||
|
if song_num == 0:
|
||||||
|
self.ctrl_box.disabled = True
|
||||||
|
return
|
||||||
|
|
||||||
# 这里只做添加, 不做删除, 重建播放列表在设置里
|
# 这里只做添加, 不做删除, 重建播放列表在设置里
|
||||||
if song_num > 0 and len(playlist) < song_num:
|
if song_num > 0 and len(playlist) < song_num:
|
||||||
|
@ -307,10 +317,6 @@ class SonistWindow(Gtk.Window):
|
||||||
self.ctrl_box.toggle_mode_btn(mode = 'random')
|
self.ctrl_box.toggle_mode_btn(mode = 'random')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if state != 'stop':
|
|
||||||
|
|
||||||
song = song or self.mpd.currentsong()
|
song = song or self.mpd.currentsong()
|
||||||
|
|
||||||
if song.get('id'):
|
if song.get('id'):
|
||||||
|
|
Loading…
Reference in New Issue