[nautilus/antonioffix-menus-and-popovers: 18/26] files-view: Always pop up background menu in view
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/antonioffix-menus-and-popovers: 18/26] files-view: Always pop up background menu in view
- Date: Sat, 13 Jan 2018 23:27:34 +0000 (UTC)
commit a0790e64a0d82aa9be29bc0bf378c1019a8b4734
Author: António Fernandes <antoniof gnome org>
Date: Tue Jan 9 22:40:51 2018 +0000
files-view: Always pop up background menu in view
Background context menu pops up from the pointer's position, which
is good when using a poiting device to open it.
When using keyboard shortcuts to open the background context menu,
the pointer may be outside the view, so the background context menu
will pop up out of context.
Instead, when triggered from the keyboard, pop up from the starting
corner of the view.
src/nautilus-files-view.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index b03cd78f1..7d3719789 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -8142,7 +8142,7 @@ nautilus_files_view_pop_up_selection_context_menu (NautilusFilesView *view,
/**
* nautilus_files_view_pop_up_background_context_menu
*
- * Pop up a context menu appropriate to the view globally at the last right click location.
+ * Pop up a context menu appropriate to the location in view.
* @view: NautilusFilesView of interest.
*
**/
@@ -8151,6 +8151,7 @@ nautilus_files_view_pop_up_background_context_menu (NautilusFilesView *view,
GdkEventButton *event)
{
NautilusFilesViewPrivate *priv;
+ g_autofree GdkRectangle *rectangle = NULL;
g_assert (NAUTILUS_IS_FILES_VIEW (view));
@@ -8161,7 +8162,20 @@ nautilus_files_view_pop_up_background_context_menu (NautilusFilesView *view,
*/
update_context_menus_if_pending (view);
- nautilus_pop_up_context_menu (GTK_WIDGET (view), priv->background_menu, event, NULL);
+ if (!event)
+ {
+ /* It was triggered from the keyboard, so pop up from the starting
+ * corner of the view.
+ */
+ gboolean rtl;
+
+ rtl = gtk_widget_get_direction (GTK_WIDGET (view)) == GTK_TEXT_DIR_RTL;
+ rectangle = g_new0 (GdkRectangle, 1);
+ rectangle->x = rtl ? gtk_widget_get_allocated_width (view) : 0;
+ rectangle->y = 0;
+ }
+
+ nautilus_pop_up_context_menu (GTK_WIDGET (view), priv->background_menu, event, rectangle);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]