[nautilus/antonioffix-menus-and-popovers: 8/14] 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: 8/14] files-view: Always pop up background menu in view
- Date: Sun, 28 Jan 2018 23:15:52 +0000 (UTC)
commit 1da9418b970ebde00b0ef58e34028f569112a39b
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 center
of the view.
src/nautilus-files-view.c | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index db930064d..97ef75fed 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -8137,7 +8137,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.
*
**/
@@ -8156,9 +8156,28 @@ nautilus_files_view_pop_up_background_context_menu (NautilusFilesView *view,
*/
update_context_menus_if_pending (view);
- nautilus_pop_up_context_menu_at_pointer (GTK_WIDGET (view),
- priv->background_menu,
- event);
+ if (event != NULL)
+ {
+ nautilus_pop_up_context_menu_at_pointer (GTK_WIDGET (view),
+ priv->background_menu,
+ event);
+ }
+ else
+ {
+ /* It was triggered from the keyboard, so pop up from the center of view.
+ */
+ g_autoptr (GtkWidget) gtk_menu = NULL;
+
+ gtk_menu = gtk_menu_new_from_model (G_MENU_MODEL (priv->background_menu));
+ gtk_menu_attach_to_widget (GTK_MENU (gtk_menu), GTK_WIDGET (view), NULL);
+
+ gtk_menu_popup_at_widget (GTK_MENU (gtk_menu),
+ GTK_WIDGET (view),
+ GDK_GRAVITY_CENTER,
+ GDK_GRAVITY_CENTER,
+ NULL);
+ g_object_ref_sink (gtk_menu);
+ }
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]