aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2022-07-26 00:30:34 +0200
committerPřemysl Eric Janouch <p@janouch.name>2022-07-26 00:31:43 +0200
commit6baf1a7bbd82993d517d389993636e4ac08ff3e0 (patch)
treec5eec6134107655e672113895f7722baba6d8aef
parent78636fdc189d97b25f73f4a65ff7dec466b66bf2 (diff)
downloadfiv-6baf1a7bbd82993d517d389993636e4ac08ff3e0.tar.gz
fiv-6baf1a7bbd82993d517d389993636e4ac08ff3e0.tar.xz
fiv-6baf1a7bbd82993d517d389993636e4ac08ff3e0.zip
Make the switch-to-browser button select last file
Before, it was only possible to achieve the same result using keyboard.
-rw-r--r--fiv.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/fiv.c b/fiv.c
index f58cc28..d694b17 100644
--- a/fiv.c
+++ b/fiv.c
@@ -602,7 +602,7 @@ set_window_title(const char *uri)
}
static void
-switch_to_browser(void)
+switch_to_browser_noselect(void)
{
set_window_title(g.directory);
gtk_stack_set_visible_child(GTK_STACK(g.stack), g.browser_paned);
@@ -610,6 +610,15 @@ switch_to_browser(void)
}
static void
+switch_to_browser(void)
+{
+ // XXX: This distinction is weird, it might make sense to make
+ // an end-user option for the behaviour.
+ switch_to_browser_noselect();
+ fiv_browser_select(FIV_BROWSER(g.browser), g.uri);
+}
+
+static void
switch_to_view(void)
{
g_return_if_fail(g.uri != NULL);
@@ -710,7 +719,7 @@ load_directory(const char *uri)
// kept at -1, and browsing doesn't work. How to behave here?
// Should we add it to the pointer array as an exception?
if (uri) {
- switch_to_browser();
+ switch_to_browser_noselect();
// TODO(p): Rather place it in history.
g_clear_pointer(&g.uri, g_free);
@@ -1161,7 +1170,7 @@ on_key_press(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event,
switch (event->keyval) {
case GDK_KEY_Left:
if (gtk_stack_get_visible_child(GTK_STACK(g.stack)) == g.view_box)
- switch_to_browser();
+ switch_to_browser_noselect();
else if (g.directory_back)
load_directory(g.directory_back->data);
return TRUE;
@@ -1252,7 +1261,6 @@ on_key_press_view(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event,
case GDK_KEY_Escape:
case GDK_KEY_Return:
switch_to_browser();
- fiv_browser_select(FIV_BROWSER(g.browser), g.uri);
return TRUE;
}
}
@@ -1315,7 +1323,7 @@ on_button_press_view(G_GNUC_UNUSED GtkWidget *widget, GdkEventButton *event)
switch (event->button) {
case 4: // back (GdkWin32, GdkQuartz)
case 8: // back
- switch_to_browser();
+ switch_to_browser_noselect();
return TRUE;
case GDK_BUTTON_PRIMARY:
if (event->type == GDK_2BUTTON_PRESS) {