[gnome-music] playlistview: Fix right-click popover position
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] playlistview: Fix right-click popover position
- Date: Fri, 18 Jan 2019 09:57:14 +0000 (UTC)
commit 78b0e9680ed6e9b478e5f6b656e1f984d28d9f09
Author: Harry Xie <harryjordan9208 gmail com>
Date: Mon Jan 14 20:12:54 2019 -0500
playlistview: Fix right-click popover position
Issue #214 points out that right-click popover in the playlist view
sometimes appears at odd positions. This is because the rectangle the
popover points to is too tall. When the window is small, there isn't
enough space at the bottom, so the popover chooses to appear on the
side of the rectangle, which is far away from the user's mouse.
To fix this, change the way the rectangle is created by taking into
account the position of the mouse cursor inside the row. Add half the
height of a cell to the vertical position of the popover to make sure
it is always displayed at the center of the cell.
Closes: #214
gnomemusic/views/playlistview.py | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/gnomemusic/views/playlistview.py b/gnomemusic/views/playlistview.py
index eb9433c6..093cb320 100644
--- a/gnomemusic/views/playlistview.py
+++ b/gnomemusic/views/playlistview.py
@@ -362,12 +362,13 @@ class PlaylistView(BaseView):
@log
def _on_view_right_clicked(self, gesture, n_press, x, y):
- (path, _, _, _) = self._view.get_path_at_pos(x, y)
+ (path, column, cell_x, cell_y) = self._view.get_path_at_pos(x, y)
self._view.get_selection().select_path(path)
+ row_height = self._view.get_cell_area(path, None).height
- rect = self._view.get_visible_rect()
- rect.x = x - rect.width / 2.0
- rect.y = y - rect.height + 5
+ rect = Gdk.Rectangle()
+ rect.x = x
+ rect.y = y - cell_y + 0.5 * row_height
self._song_popover.set_relative_to(self._view)
self._song_popover.set_pointing_to(rect)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]