summaryrefslogtreecommitdiff
path: root/src/nautilus-list-view.c
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2015-08-15 17:20:21 +0200
committerCarlos Soriano <csoriano@gnome.org>2015-08-16 14:53:54 +0200
commit328348c6f76bc72823c1a8464937b7f4208674d9 (patch)
treed901e2155586dd3d14d7e3d3f56f24b0fde2649c /src/nautilus-list-view.c
parentedaa65f4ee7d6219c0c6ca1cecdf84be2bc2a63d (diff)
downloadnautilus-328348c6f76bc72823c1a8464937b7f4208674d9.tar.gz
nautilus-view: use popover for renaming
Some users felt it quite disruptive to us a dialog, even if the attention has to be on the name entry. Also it's the way that GtkFileChooser implemented it and it actually feels less disruptive and desigerns agreed it works better. So continue to use a dialog for the new folder creation, but use a popover for renaming.
Diffstat (limited to 'src/nautilus-list-view.c')
-rw-r--r--src/nautilus-list-view.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 20a4882c4..35a7472f6 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -59,6 +59,12 @@
#define DEBUG_FLAG NAUTILUS_DEBUG_LIST_VIEW
#include <libnautilus-private/nautilus-debug.h>
+/* We use a rectangle to make the popover point to the right column. In an
+ * ideal world with GtkListBox we would just point to the GtkListBoxRow. In our case, we
+ * need to use a rectangle and we provide some width to not make the popover arrow pointy
+ * in the edges if the window is small */
+#define RENAME_POPOVER_RELATIVE_TO_RECTANGLE_WIDTH 40
+
struct NautilusListViewDetails {
GtkTreeView *tree_view;
NautilusListModel *model;
@@ -3240,6 +3246,41 @@ nautilus_list_view_get_id (NautilusView *view)
return NAUTILUS_LIST_VIEW_ID;
}
+static GdkRectangle*
+nautilus_list_view_compute_rename_popover_relative_to (NautilusView *view)
+{
+ GtkTreeSelection *selection;
+ GtkTreePath *path;
+ GdkRectangle *rect;
+ GtkTreeModel *model;
+ GtkTreeView *tree_view;
+ GList *list;
+ NautilusListView *list_view;
+
+ rect = g_malloc0 (sizeof(GdkRectangle));
+ list_view = NAUTILUS_LIST_VIEW (view);
+ tree_view = list_view->details->tree_view;
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (list_view->details->tree_view));
+ model = GTK_TREE_MODEL (list_view->details->model);
+ list = gtk_tree_selection_get_selected_rows (selection, &model);
+ path = list->data;
+ gtk_tree_view_get_cell_area (tree_view, path, NULL, rect);
+ gtk_tree_view_convert_bin_window_to_widget_coords (tree_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);
+ rect->width = RENAME_POPOVER_RELATIVE_TO_RECTANGLE_WIDTH;
+
+ g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free);
+
+ return rect;
+}
+
static void
nautilus_list_view_class_init (NautilusListViewClass *class)
{
@@ -3277,6 +3318,7 @@ nautilus_list_view_class_init (NautilusListViewClass *class)
nautilus_view_class->get_view_id = nautilus_list_view_get_id;
nautilus_view_class->get_first_visible_file = nautilus_list_view_get_first_visible_file;
nautilus_view_class->scroll_to_file = list_view_scroll_to_file;
+ nautilus_view_class->compute_rename_popover_relative_to = nautilus_list_view_compute_rename_popover_relative_to;
}
static void