diff options
author | Carlos Soriano <csoriano@gnome.org> | 2015-09-08 11:05:36 +0200 |
---|---|---|
committer | Carlos Soriano <csoriano@gnome.org> | 2015-09-08 11:13:16 +0200 |
commit | 7bc43d8623d493c771ba89e6a93eea59de478a0a (patch) | |
tree | 85beeb972de90cf5c7c55492d02fe95b5cffb84e | |
parent | 7d96b11f195594c62d347c94e373f8d455c027f6 (diff) | |
download | nautilus-7bc43d8623d493c771ba89e6a93eea59de478a0a.tar.gz |
list-view: use button position for rename popover
We were always pointing to the middle of the row, which is not
very nice if the user is has his point of vision to another
place.
So use the last mouse event if available for positioning the
rename popover in the x direction.
https://bugzilla.gnome.org/show_bug.cgi?id=754620
-rw-r--r-- | src/nautilus-list-view.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c index 8ee776919..369090c8c 100644 --- a/src/nautilus-list-view.c +++ b/src/nautilus-list-view.c @@ -86,6 +86,9 @@ struct NautilusListViewDetails { GtkTreePath *hover_path; + gint last_event_button_x; + gint last_event_button_y; + guint drag_button; int drag_x; int drag_y; @@ -645,6 +648,8 @@ button_press_callback (GtkWidget *widget, GdkEventButton *event, gpointer callba tree_view = GTK_TREE_VIEW (widget); tree_view_class = GTK_WIDGET_GET_CLASS (tree_view); selection = gtk_tree_view_get_selection (tree_view); + view->details->last_event_button_x = event->x; + view->details->last_event_button_y = event->y; /* Don't handle extra mouse buttons here */ if (event->button > 5) { @@ -1043,6 +1048,9 @@ key_press_callback (GtkWidget *widget, GdkEventKey *event, gpointer callback_dat view = NAUTILUS_FILES_VIEW (callback_data); handled = FALSE; + NAUTILUS_LIST_VIEW (view)->details->last_event_button_x = -1; + NAUTILUS_LIST_VIEW (view)->details->last_event_button_y = -1; + switch (event->keyval) { case GDK_KEY_F10: if (event->state & GDK_CONTROL_MASK) { @@ -3313,11 +3321,15 @@ nautilus_list_view_compute_rename_popover_relative_to (NautilusFilesView *view) rect->x, rect->y, &rect->x, &rect->y); - rect->x = CLAMP (gtk_widget_get_allocated_width (GTK_WIDGET (tree_view)) * 0.5 - - RENAME_POPOVER_RELATIVE_TO_RECTANGLE_WIDTH * 0.5, - 0, - gtk_widget_get_allocated_width (GTK_WIDGET (tree_view)) - - RENAME_POPOVER_RELATIVE_TO_RECTANGLE_WIDTH); + if (list_view->details->last_event_button_x > 0) { + rect->x = list_view->details->last_event_button_x; + } else { + rect->x = CLAMP (gtk_widget_get_allocated_width (GTK_WIDGET (tree_view)) * 0.5 - + RENAME_POPOVER_RELATIVE_TO_RECTANGLE_WIDTH * 0.5, + 0, + gtk_widget_get_allocated_width (GTK_WIDGET (tree_view)) - + RENAME_POPOVER_RELATIVE_TO_RECTANGLE_WIDTH); + } rect->width = RENAME_POPOVER_RELATIVE_TO_RECTANGLE_WIDTH; g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free); |