summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntónio Fernandes <antoniof@gnome.org>2023-01-15 17:21:19 +0000
committerAntónio Fernandes <antoniof@gnome.org>2023-01-16 01:49:56 +0000
commit9c93e2fd3ed6a8bb262cbe9cb8f60d9b005c699e (patch)
tree27e8f0e57ffea76fc4e4f38cfb15150613bb8a67
parentbcbfcbf70838fb25d7e9bbb887b7131ef9b67cdd (diff)
downloadnautilus-9c93e2fd3ed6a8bb262cbe9cb8f60d9b005c699e.tar.gz
name-cell: Don't open on hover expander icon.
GtkTreeExpander includes a built-in "expand on drag hover" feature. But our own "open on drag hover" feature competes (and often wins) over it, making it hard to reliably expand rows on hover without opening the folder. So, separate the content and the expander. Trigger "expand on drag hover" only if over the expander, and "open on drag hover" only if over the rest.
-rw-r--r--src/nautilus-list-base-private.h2
-rw-r--r--src/nautilus-list-base.c23
-rw-r--r--src/nautilus-list-view.c2
-rw-r--r--src/nautilus-name-cell.c8
-rw-r--r--src/nautilus-name-cell.h1
-rw-r--r--src/resources/ui/nautilus-name-cell.ui14
6 files changed, 40 insertions, 10 deletions
diff --git a/src/nautilus-list-base-private.h b/src/nautilus-list-base-private.h
index 1a92360f6..54f26c03e 100644
--- a/src/nautilus-list-base-private.h
+++ b/src/nautilus-list-base-private.h
@@ -29,6 +29,8 @@ void set_directory_sort_metadata (NautilusFile *f
void setup_cell_common (GtkListItem *listitem,
NautilusViewCell *cell);
void setup_cell_hover (NautilusViewCell *cell);
+void setup_cell_hover_inner_target (NautilusViewCell *cell,
+ GtkWidget *target);
void set_focus_item (NautilusListBase *self,
NautilusViewItem *item);
diff --git a/src/nautilus-list-base.c b/src/nautilus-list-base.c
index 03bc6d9b0..46d28e882 100644
--- a/src/nautilus-list-base.c
+++ b/src/nautilus-list-base.c
@@ -931,17 +931,32 @@ setup_cell_common (GtkListItem *listitem,
gtk_widget_add_controller (GTK_WIDGET (cell), GTK_EVENT_CONTROLLER (drop_target));
}
-
-void
-setup_cell_hover (NautilusViewCell *cell)
+static void
+real_setup_cell_hover (NautilusViewCell *cell,
+ GtkWidget *target)
{
GtkEventController *controller = gtk_drop_controller_motion_new ();
- gtk_widget_add_controller (GTK_WIDGET (cell), controller);
+ gtk_widget_add_controller (target, controller);
g_signal_connect (controller, "enter", G_CALLBACK (on_item_drag_hover_enter), cell);
g_signal_connect (controller, "leave", G_CALLBACK (on_item_drag_hover_leave), cell);
g_signal_connect (controller, "motion", G_CALLBACK (on_item_drag_hover_motion), cell);
}
+void
+setup_cell_hover_inner_target (NautilusViewCell *cell,
+ GtkWidget *target)
+{
+ g_return_if_fail (gtk_widget_is_ancestor (target, GTK_WIDGET (cell)));
+
+ real_setup_cell_hover (cell, target);
+}
+
+void
+setup_cell_hover (NautilusViewCell *cell)
+{
+ real_setup_cell_hover (cell, GTK_WIDGET (cell));
+}
+
static void
nautilus_list_base_scroll_to_item (NautilusListBase *self,
guint position)
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 32ab01b7a..97257bea4 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -1128,7 +1128,7 @@ setup_name_cell (GtkSignalListItemFactory *factory,
cell = nautilus_name_cell_new (NAUTILUS_LIST_BASE (self));
setup_cell_common (listitem, cell);
- setup_cell_hover (cell);
+ setup_cell_hover_inner_target (cell, nautilus_name_cell_get_content (NAUTILUS_NAME_CELL (cell)));
nautilus_name_cell_set_path (NAUTILUS_NAME_CELL (cell),
self->path_attribute_q,
diff --git a/src/nautilus-name-cell.c b/src/nautilus-name-cell.c
index f4d80bcbe..bdcfcc2c7 100644
--- a/src/nautilus-name-cell.c
+++ b/src/nautilus-name-cell.c
@@ -19,6 +19,7 @@ struct _NautilusNameCell
GFile *file_path_base_location;
GtkWidget *expander;
+ GtkWidget *content;
GtkWidget *fixed_height_box;
GtkWidget *spinner;
GtkWidget *icon;
@@ -355,6 +356,7 @@ nautilus_name_cell_class_init (NautilusNameCellClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/nautilus/ui/nautilus-name-cell.ui");
gtk_widget_class_bind_template_child (widget_class, NautilusNameCell, expander);
+ gtk_widget_class_bind_template_child (widget_class, NautilusNameCell, content);
gtk_widget_class_bind_template_child (widget_class, NautilusNameCell, fixed_height_box);
gtk_widget_class_bind_template_child (widget_class, NautilusNameCell, spinner);
gtk_widget_class_bind_template_child (widget_class, NautilusNameCell, icon);
@@ -393,3 +395,9 @@ nautilus_name_cell_get_expander (NautilusNameCell *self)
{
return GTK_TREE_EXPANDER (self->expander);
}
+
+GtkWidget *
+nautilus_name_cell_get_content (NautilusNameCell *self)
+{
+ return self->content;
+}
diff --git a/src/nautilus-name-cell.h b/src/nautilus-name-cell.h
index 11b84931e..5df6fdbe7 100644
--- a/src/nautilus-name-cell.h
+++ b/src/nautilus-name-cell.h
@@ -20,5 +20,6 @@ void nautilus_name_cell_set_path (NautilusNameCell *self,
GFile *base_location);
void nautilus_name_cell_show_snippet (NautilusNameCell *self);
GtkTreeExpander * nautilus_name_cell_get_expander (NautilusNameCell *self);
+GtkWidget * nautilus_name_cell_get_content (NautilusNameCell *self);
G_END_DECLS
diff --git a/src/resources/ui/nautilus-name-cell.ui b/src/resources/ui/nautilus-name-cell.ui
index 49089e0e1..96094b79c 100644
--- a/src/resources/ui/nautilus-name-cell.ui
+++ b/src/resources/ui/nautilus-name-cell.ui
@@ -6,10 +6,14 @@
<relation name="labelled-by">label</relation>
</accessibility>
<child>
- <object class="GtkTreeExpander" id="expander">
- <property name="indent-for-icon">False</property>
- <property name="child">
- <object class="GtkBox">
+ <object class="GtkBox">
+ <child>
+ <object class="GtkTreeExpander" id="expander">
+ <property name="indent-for-icon">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox" id="content">
<property name="spacing">6</property>
<property name="orientation">horizontal</property>
<property name="halign">fill</property>
@@ -118,7 +122,7 @@
</object>
</child>
</object>
- </property>
+ </child>
</object>
</child>
</template>