I think what I want to do is change the threshold that nautilus uses to decide whether the window is in “narrow” mode. If I can make it always think it is “narrow” then I think the F9 key will do what I want.
No, because it changes many other unrelated variables.
Here’s a patch to have it the collapse button show up all the time and the F9 action always active:
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 84569bca9..2db9e23eb 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -1106,7 +1106,6 @@ static void
nautilus_window_initialize_actions (NautilusWindow *window)
{
GApplication *app;
- GAction *action;
gchar detailed_action[80];
gchar accel[80];
gint i;
@@ -1141,10 +1140,6 @@ nautilus_window_initialize_actions (NautilusWindow *window)
nautilus_window_on_undo_changed (nautilus_file_undo_manager_get (), window);
#undef ACCELS
-
- action = g_action_map_lookup_action (G_ACTION_MAP (window), "toggle-sidebar");
- g_object_bind_property (window->split_view, "collapsed",
- action, "enabled", G_BINDING_SYNC_CREATE);
}
static gboolean
diff --git a/src/resources/ui/nautilus-window.ui b/src/resources/ui/nautilus-window.ui
index feffa930b..b4f1fd7bf 100644
--- a/src/resources/ui/nautilus-window.ui
+++ b/src/resources/ui/nautilus-window.ui
@@ -154,6 +154,7 @@
<object class="AdwToolbarView">
<child type="top">
<object class="NautilusToolbar" id="toolbar">
+ <property name="show-sidebar-button">true</property>
<property name="show-view-controls">true</property>
<property name="show-history-controls">true</property>
<property name="sidebar-button-active" bind-source="split_view" bind-property="show-sidebar" bind-flags="bidirectional|sync-create"/>
@@ -204,7 +205,6 @@
<setter object="split_view" property="collapsed">True</setter>
<setter object="split_view" property="enable-show-gesture">True</setter>
<setter object="split_view" property="enable-hide-gesture">True</setter>
- <setter object="toolbar" property="show-sidebar-button">True</setter>
<setter object="toolbar" property="show-view-controls">False</setter>
<setter object="toolbar" property="show-history-controls">False</setter>
<setter object="action_bar" property="revealed">True</setter>
If you don’t want the button to show up in normal width, then don’t apply the last two changes.