allow moving the miniplayer by dragging the cover

This commit is contained in:
Martin Wagner
2021-02-04 21:33:51 +01:00
parent 4e8ae30201
commit 7916112432

View File

@ -2309,7 +2309,7 @@ class AlbumWindow(FocusFrame):
artist=self._store[path][6] artist=self._store[path][6]
v=self._scroll_vadj.get_value() v=self._scroll_vadj.get_value()
h=self._scroll_hadj.get_value() h=self._scroll_hadj.get_value()
pop=AlbumPopover(self._client, self._settings, album, artist, year, widget, int(event.x-h), int(event.y-v)) pop=AlbumPopover(self._client, self._settings, album, artist, year, widget, event.x-h, event.y-v)
pop.popup() pop.popup()
self._button_event=(None, None) self._button_event=(None, None)
@ -2638,31 +2638,29 @@ class CoverEventBox(Gtk.EventBox):
# connect # connect
self._button_press_event=self.connect("button-press-event", self._on_button_press_event) self._button_press_event=self.connect("button-press-event", self._on_button_press_event)
self._settings.connect("notify::mini-player", self._on_mini_player)
def _on_button_press_event(self, widget, event): def _on_button_press_event(self, widget, event):
if self._client.connected(): if self._settings.get_property("mini-player"):
song=ClientHelper.song_to_first_str_dict(self._client.wrapped_call("currentsong")) if event.button == 1 and event.type == Gdk.EventType.BUTTON_PRESS:
if song != {}: window=self.get_toplevel()
try: window.begin_move_drag(1, event.x_root, event.y_root, Gdk.CURRENT_TIME)
artist=song[self._settings.get_artist_type()]
except:
artist=song.get("artist", "")
album=song.get("album", "")
album_year=song.get("date", "")
if event.button == 1 and event.type == Gdk.EventType.BUTTON_PRESS:
self._client.wrapped_call("album_to_playlist", album, artist, album_year)
elif event.button == 2 and event.type == Gdk.EventType.BUTTON_PRESS:
self._client.wrapped_call("album_to_playlist", album, artist, album_year, "append")
elif event.button == 3 and event.type == Gdk.EventType.BUTTON_PRESS:
pop=AlbumPopover(self._client, self._settings, album, artist, album_year, widget, int(event.x), int(event.y))
pop.popup()
def _on_mini_player(self, obj, typestring):
if obj.get_property("mini-player"):
self.handler_block(self._button_press_event)
else: else:
self.handler_unblock(self._button_press_event) if self._client.connected():
song=ClientHelper.song_to_first_str_dict(self._client.wrapped_call("currentsong"))
if song != {}:
try:
artist=song[self._settings.get_artist_type()]
except:
artist=song.get("artist", "")
album=song.get("album", "")
album_year=song.get("date", "")
if event.button == 1 and event.type == Gdk.EventType.BUTTON_PRESS:
self._client.wrapped_call("album_to_playlist", album, artist, album_year)
elif event.button == 2 and event.type == Gdk.EventType.BUTTON_PRESS:
self._client.wrapped_call("album_to_playlist", album, artist, album_year, "append")
elif event.button == 3 and event.type == Gdk.EventType.BUTTON_PRESS:
pop=AlbumPopover(self._client, self._settings, album, artist, album_year, widget, event.x, event.y)
pop.popup()
class MainCover(Gtk.Frame): class MainCover(Gtk.Frame):
def __init__(self, client, settings): def __init__(self, client, settings):