From 364faf67be9ba0f04915f4cb00d0633f8fde0148 Mon Sep 17 00:00:00 2001 From: Martin Wagner Date: Sun, 2 May 2021 14:42:01 +0200 Subject: [PATCH] added force mode to "back_to_current_album_button" --- bin/mpdevil | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/bin/mpdevil b/bin/mpdevil index 5da0ad5..95e4e3e 100755 --- a/bin/mpdevil +++ b/bin/mpdevil @@ -2501,7 +2501,8 @@ class Browser(Gtk.Paned): self._album_window=AlbumWindow(self._client, self._settings, self._artist_window) # connect - self.back_to_current_album_button.connect("clicked", self._back_to_current_album) + self.back_to_current_album_button.connect("clicked", self._on_back_to_current_album_button_clicked) + self.back_to_current_album_button.connect("button-press-event", self._on_back_to_current_album_button_press_event) self.search_button.connect("toggled", self._on_search_toggled) self._artist_window.connect("artists_changed", self._on_artists_changed) self._settings.connect("notify::mini-player", self._on_mini_player) @@ -2526,7 +2527,7 @@ class Browser(Gtk.Paned): self.pack1(box1, False, False) self.pack2(self._stack, True, False) - def _back_to_current_album(self, *args): + def _back_to_current_album(self, force=False): song=ClientHelper.song_to_first_str_dict(self._client.currentsong()) if song != {}: self.search_button.set_active(False) @@ -2535,16 +2536,23 @@ class Browser(Gtk.Paned): if artist is None: artist=song.get("artist", "") # deactivate genre filter to show all artists (if needed) - if song.get("genre", "") != self._genre_select.get_selected_genre(): + if song.get("genre", "") != self._genre_select.get_selected_genre() or force: self._genre_select.deactivate() # select artist - if self._artist_window.get_selected_artist() is None: # all artists selected + if self._artist_window.get_selected_artist() is None and not force: # all artists selected self.search_button.set_active(False) self._artist_window.highlight_selected() else: # one artist selected self._artist_window.select(artist) self._album_window.scroll_to_current_album() + def _on_back_to_current_album_button_clicked(self, *args): + self._back_to_current_album() + + def _on_back_to_current_album_button_press_event(self, widget, event): + if event.button == 1 and event.type == Gdk.EventType._2BUTTON_PRESS: + self._back_to_current_album(force=True) + def _on_search_toggled(self, widget): if widget.get_active(): self._stack.set_visible_child_name("search")