[nautilus/gnome-3-26] notebook: Fix tab lookup by coordinates
- From: Ernestas Kulik <ernestask src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/gnome-3-26] notebook: Fix tab lookup by coordinates
- Date: Mon, 30 Apr 2018 13:56:41 +0000 (UTC)
commit 38b2969847f5dd627c8c608f3eca513520a93cda
Author: Ernestas Kulik <ernestask gnome org>
Date: Sat Apr 14 16:14:19 2018 +0300
notebook: Fix tab lookup by coordinates
The current code only checks one coordinate, depending on the tab
orientation.
Fixes https://gitlab.gnome.org/GNOME/nautilus/issues/342
(cherry picked from commit 7ca2197ae3f0df527e27cf58188b1f83216e3cdb)
src/nautilus-notebook.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
---
diff --git a/src/nautilus-notebook.c b/src/nautilus-notebook.c
index f2b3fbdf1..6e1db521b 100644
--- a/src/nautilus-notebook.c
+++ b/src/nautilus-notebook.c
@@ -88,14 +88,11 @@ find_tab_num_at_pos (NautilusNotebook *notebook,
gint abs_x,
gint abs_y)
{
- GtkPositionType tab_pos;
int page_num = 0;
GtkNotebook *nb = GTK_NOTEBOOK (notebook);
GtkWidget *page;
GtkAllocation allocation;
- tab_pos = gtk_notebook_get_tab_pos (GTK_NOTEBOOK (notebook));
-
while ((page = gtk_notebook_get_nth_page (nb, page_num)))
{
GtkWidget *tab;
@@ -118,15 +115,7 @@ find_tab_num_at_pos (NautilusNotebook *notebook,
max_x = x_root + allocation.x + allocation.width;
max_y = y_root + allocation.y + allocation.height;
- if (((tab_pos == GTK_POS_TOP)
- || (tab_pos == GTK_POS_BOTTOM))
- && (abs_x <= max_x))
- {
- return page_num;
- }
- else if (((tab_pos == GTK_POS_LEFT)
- || (tab_pos == GTK_POS_RIGHT))
- && (abs_y <= max_y))
+ if (abs_x <= max_x && abs_y <= max_y)
{
return page_num;
}
@@ -154,7 +143,7 @@ button_press_cb (NautilusNotebook *notebook,
/* consume event, so that we don't pop up the context menu when
* the mouse if not over a tab label
*/
- return TRUE;
+ return GDK_EVENT_STOP;
}
/* switch to the page the mouse is over, but don't consume the event */
@@ -165,11 +154,16 @@ button_press_cb (NautilusNotebook *notebook,
{
GtkWidget *slot;
+ if (tab_clicked == -1)
+ {
+ return GDK_EVENT_PROPAGATE;
+ }
+
slot = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), tab_clicked);
g_signal_emit (notebook, signals[TAB_CLOSE_REQUEST], 0, slot);
}
- return FALSE;
+ return GDK_EVENT_PROPAGATE;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]