parent
3329e3ed8f
commit
5b314fd899
2
build.sh
2
build.sh
|
@ -4,7 +4,7 @@ if [ -d unpack ]; then
|
||||||
sudo rm -rf unpack
|
sudo rm -rf unpack
|
||||||
fi
|
fi
|
||||||
|
|
||||||
version="1.0.1"
|
version="1.0.2"
|
||||||
|
|
||||||
mkdir -p unpack/DEBIAN
|
mkdir -p unpack/DEBIAN
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Package: sonist
|
Package: sonist
|
||||||
Version: 1.0.1
|
Version: 1.0.2
|
||||||
Section: X11
|
Section: X11
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Author: Yutent
|
Author: Yutent
|
||||||
|
|
|
@ -21,7 +21,7 @@ class AboutWindow(Gtk.AboutDialog):
|
||||||
self.set_logo(GdkPixbuf.Pixbuf.new_from_file(image_dict['sonist']))
|
self.set_logo(GdkPixbuf.Pixbuf.new_from_file(image_dict['sonist']))
|
||||||
|
|
||||||
self.set_license_type(Gtk.License.MIT_X11)
|
self.set_license_type(Gtk.License.MIT_X11)
|
||||||
self.set_version('1.0.1')
|
self.set_version('1.0.2')
|
||||||
self.set_website('https://github.com/app-cat/sonist-gtk')
|
self.set_website('https://github.com/app-cat/sonist-gtk')
|
||||||
self.set_website_label('官网')
|
self.set_website_label('官网')
|
||||||
self.set_authors([
|
self.set_authors([
|
||||||
|
|
|
@ -67,12 +67,12 @@ class CommandError(Exception):
|
||||||
self.command = None
|
self.command = None
|
||||||
self.msg = None
|
self.msg = None
|
||||||
|
|
||||||
match = ERROR_PATTERN.match(error)
|
matches = ERROR_PATTERN.match(error)
|
||||||
if match:
|
if matches:
|
||||||
self.errno = FailureResponseCode(int(match.group("errno")))
|
self.errno = FailureResponseCode(int(matches.group("errno")))
|
||||||
self.offset = int(match.group("offset"))
|
self.offset = int(matches.group("offset"))
|
||||||
self.command = match.group("command")
|
self.command = matches.group("command")
|
||||||
self.msg = match.group("msg")
|
self.msg = matches.group("msg")
|
||||||
|
|
||||||
|
|
||||||
class CommandListError(Exception):
|
class CommandListError(Exception):
|
||||||
|
|
|
@ -18,6 +18,9 @@ home_dir = os.getenv('HOME')
|
||||||
|
|
||||||
|
|
||||||
def get_music_dir():
|
def get_music_dir():
|
||||||
|
mpd_config = f'{home_dir}/.mpd/mpd.conf'
|
||||||
|
|
||||||
|
if os.path.isfile(mpd_config):
|
||||||
with open(f'{home_dir}/.mpd/mpd.conf', 'r') as f:
|
with open(f'{home_dir}/.mpd/mpd.conf', 'r') as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
|
|
||||||
|
|
|
@ -48,11 +48,10 @@ class OptionMenu(Gtk.Menu):
|
||||||
|
|
||||||
|
|
||||||
def on_menu_select(self, item):
|
def on_menu_select(self, item):
|
||||||
match(item.name):
|
if item.name == '首选项':
|
||||||
case '首选项':
|
|
||||||
self.app.preferences.show()
|
self.app.preferences.show()
|
||||||
|
|
||||||
case '窗口置顶':
|
elif item.name == '窗口置顶':
|
||||||
self.on_top = not self.on_top
|
self.on_top = not self.on_top
|
||||||
self.app.window.set_keep_above(self.on_top)
|
self.app.window.set_keep_above(self.on_top)
|
||||||
if self.on_top:
|
if self.on_top:
|
||||||
|
@ -60,10 +59,10 @@ class OptionMenu(Gtk.Menu):
|
||||||
else:
|
else:
|
||||||
item.deselect()
|
item.deselect()
|
||||||
|
|
||||||
case '退出应用':
|
elif item.name == '退出应用':
|
||||||
self.app.quit_all()
|
self.app.quit_all()
|
||||||
|
|
||||||
case '关于播放器':
|
elif item.name == '关于播放器':
|
||||||
self.app.about.present()
|
self.app.about.present()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,6 @@ class SonistWindow(Gtk.Window):
|
||||||
#ImageButton:hover {{
|
#ImageButton:hover {{
|
||||||
background-color: rgba(255,255,255,.1);
|
background-color: rgba(255,255,255,.1);
|
||||||
outline: transparent;
|
outline: transparent;
|
||||||
box-shadow:none;
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
#Slider {{
|
#Slider {{
|
||||||
|
@ -188,11 +187,10 @@ class SonistWindow(Gtk.Window):
|
||||||
|
|
||||||
|
|
||||||
def ctrl_clicked(self, box, btn):
|
def ctrl_clicked(self, box, btn):
|
||||||
match(btn):
|
if btn == 'play_btn':
|
||||||
case 'play_btn':
|
|
||||||
self.toggle_play()
|
self.toggle_play()
|
||||||
|
|
||||||
case 'mode_btn':
|
elif btn == 'mode_btn':
|
||||||
# repeat all
|
# repeat all
|
||||||
if self.ctrl_box.curr_mode == 0:
|
if self.ctrl_box.curr_mode == 0:
|
||||||
self.mpd.repeat(1)
|
self.mpd.repeat(1)
|
||||||
|
@ -209,13 +207,13 @@ class SonistWindow(Gtk.Window):
|
||||||
self.mpd.random(0)
|
self.mpd.random(0)
|
||||||
self.mpd.single(1)
|
self.mpd.single(1)
|
||||||
|
|
||||||
case 'prev_btn':
|
elif btn == 'prev_btn':
|
||||||
self.prev_song()
|
self.prev_song()
|
||||||
|
|
||||||
case 'next_btn':
|
elif btn == 'next_btn':
|
||||||
self.next_song()
|
self.next_song()
|
||||||
|
|
||||||
case 'vol_btn':
|
elif btn == 'vol_btn':
|
||||||
self.toggle_play()
|
self.toggle_play()
|
||||||
|
|
||||||
|
|
||||||
|
@ -254,9 +252,6 @@ class SonistWindow(Gtk.Window):
|
||||||
|
|
||||||
if is_play:
|
if is_play:
|
||||||
self.handler.reset(image_dict['handler_a'])
|
self.handler.reset(image_dict['handler_a'])
|
||||||
# song = self.mpd.currentsong()
|
|
||||||
# 更新歌曲信息
|
|
||||||
# self.title_box.update(f"{song.get('artist')} - {song.get('title')}")
|
|
||||||
else:
|
else:
|
||||||
self.handler.reset(image_dict['handler'])
|
self.handler.reset(image_dict['handler'])
|
||||||
|
|
||||||
|
@ -286,13 +281,14 @@ class SonistWindow(Gtk.Window):
|
||||||
|
|
||||||
# 首次启动时, 更新数据库
|
# 首次启动时, 更新数据库
|
||||||
if first:
|
if first:
|
||||||
if self.app.config_data['auto_scan']:
|
|
||||||
self.mpd.update()
|
self.mpd.update()
|
||||||
song_num = int(self.mpd.stats().get('songs'))
|
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 len(playlist) < song_num:
|
if song_num > 0 and len(playlist) < song_num:
|
||||||
songs = self.mpd.listall()
|
songs = self.mpd.listall()
|
||||||
for it in songs:
|
for it in songs:
|
||||||
if it['file'] in playlist:
|
if it['file'] in playlist:
|
||||||
|
@ -316,10 +312,12 @@ class SonistWindow(Gtk.Window):
|
||||||
if state != 'stop':
|
if state != 'stop':
|
||||||
|
|
||||||
song = song or self.mpd.currentsong()
|
song = song or self.mpd.currentsong()
|
||||||
|
|
||||||
|
if song.get('id'):
|
||||||
# 更新歌曲信息
|
# 更新歌曲信息
|
||||||
self.title_box.update(f"{song.get('artist')} - {song.get('title')}")
|
self.title_box.update(f"{song.get('artist')} - {song.get('title')}")
|
||||||
|
|
||||||
title = song['file']
|
title = song.get('title')
|
||||||
title_hex = base64.b64encode(title.encode()).hex()
|
title_hex = base64.b64encode(title.encode()).hex()
|
||||||
|
|
||||||
filepath = f"{self.app.album_cache_dir}/{title_hex}.png"
|
filepath = f"{self.app.album_cache_dir}/{title_hex}.png"
|
||||||
|
|
Loading…
Reference in New Issue