diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2021-11-21 21:52:52 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2021-11-21 21:53:07 +0100 |
commit | a8796512d2778375a4f14592188ac9d1603d8a1c (patch) | |
tree | 3c6f2d9a7ad55d1f174022080f6593c0473e2969 | |
parent | 8b1a14decbd065e43c30a7dede4b0350116b4242 (diff) | |
download | fiv-a8796512d2778375a4f14592188ac9d1603d8a1c.tar.gz fiv-a8796512d2778375a4f14592188ac9d1603d8a1c.tar.xz fiv-a8796512d2778375a4f14592188ac9d1603d8a1c.zip |
Improve the window title situation
-rw-r--r-- | fastiv.c | 31 |
1 files changed, 22 insertions, 9 deletions
@@ -108,6 +108,21 @@ show_error_dialog(GError *error) } static void +switch_to_browser(void) +{ + gtk_window_set_title(GTK_WINDOW(g.window), g.directory); + gtk_stack_set_visible_child(GTK_STACK(g.stack), g.browser_paned); + gtk_widget_grab_focus(g.browser_scroller); +} + +static void +switch_to_view(const char *path) +{ + gtk_window_set_title(GTK_WINDOW(g.window), path); + gtk_stack_set_visible_child(GTK_STACK(g.stack), g.view_scroller); +} + +static void load_directory(const gchar *dirname) { if (dirname) { @@ -150,10 +165,8 @@ load_directory(const gchar *dirname) // XXX: When something outside the filtered entries is open, the index is // kept at -1, and browsing doesn't work. How to behave here? // Should we add it to the pointer array as an exception? - if (dirname) { - gtk_stack_set_visible_child(GTK_STACK(g.stack), g.browser_paned); - gtk_widget_grab_focus(g.browser_scroller); - } + if (dirname) + switch_to_browser(); } static void @@ -201,8 +214,7 @@ open(const gchar *path) } g_free(dirname); - gtk_window_set_title(GTK_WINDOW(g.window), path); - gtk_stack_set_visible_child(GTK_STACK(g.stack), g.view_scroller); + switch_to_view(path); } static GtkWidget * @@ -449,7 +461,7 @@ on_key_press_view(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event, case GDK_KEY_Tab: case GDK_KEY_Return: - gtk_stack_set_visible_child(GTK_STACK(g.stack), g.browser_paned); + switch_to_browser(); return TRUE; } } @@ -463,7 +475,7 @@ on_button_press_view(G_GNUC_UNUSED GtkWidget *widget, GdkEventButton *event) return FALSE; switch (event->button) { case 8: // back - gtk_stack_set_visible_child(GTK_STACK(g.stack), g.browser_paned); + switch_to_browser(); return TRUE; case GDK_BUTTON_PRIMARY: if (event->type == GDK_2BUTTON_PRESS) { @@ -483,7 +495,8 @@ on_button_press_browser(G_GNUC_UNUSED GtkWidget *widget, GdkEventButton *event) return FALSE; switch (event->button) { case 9: // forward - gtk_stack_set_visible_child(GTK_STACK(g.stack), g.view_scroller); + // FIXME: This is inconsistent, normally there is an absolute path. + switch_to_view(g.basename); return TRUE; default: return FALSE; |