diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2021-11-18 21:58:15 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2021-11-18 22:08:45 +0100 |
commit | 3bc07e00d9031c908031ef3fcfe325789c5e7594 (patch) | |
tree | bd40333cea53e1d3fd15fabb13e36a78eeb2549f /fastiv.c | |
parent | 9e45ba249efe9bee75e6a05d8aedbc0587603e55 (diff) | |
download | fiv-3bc07e00d9031c908031ef3fcfe325789c5e7594.tar.gz fiv-3bc07e00d9031c908031ef3fcfe325789c5e7594.tar.xz fiv-3bc07e00d9031c908031ef3fcfe325789c5e7594.zip |
Enable opening from sidebar in a new window
Diffstat (limited to 'fastiv.c')
-rw-r--r-- | fastiv.c | 26 |
1 files changed, 18 insertions, 8 deletions
@@ -271,12 +271,25 @@ on_item_activated(G_GNUC_UNUSED FastivBrowser *browser, const char *path, } static void +spawn_path(const char *path) +{ + char *argv[] = {PROJECT_NAME, (char *) path, NULL}; + GError *error = NULL; + g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, + NULL, &error); + g_clear_error(&error); +} + +static void on_open_location(G_GNUC_UNUSED GtkPlacesSidebar *sidebar, GFile *location, G_GNUC_UNUSED GtkPlacesOpenFlags flags, G_GNUC_UNUSED gpointer user_data) { gchar *path = g_file_get_path(location); if (path) { - load_directory(path); + if (flags & GTK_PLACES_OPEN_NEW_WINDOW) + spawn_path(path); + else + load_directory(path); g_free(path); } } @@ -302,15 +315,10 @@ on_key_press(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event, case GDK_KEY_o: on_open(); return TRUE; - case GDK_KEY_n: { - char *argv[] = {PROJECT_NAME, g.directory, NULL}; - GError *error = NULL; - g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, - NULL, &error); - g_clear_error(&error); + case GDK_KEY_n: + spawn_path(g.directory); return TRUE; } - } break; case 0: switch (event->keyval) { @@ -506,6 +514,8 @@ main(int argc, char *argv[]) GTK_PLACES_SIDEBAR(g.browser_sidebar), FALSE); gtk_places_sidebar_set_show_trash( GTK_PLACES_SIDEBAR(g.browser_sidebar), FALSE); + gtk_places_sidebar_set_open_flags(GTK_PLACES_SIDEBAR(g.browser_sidebar), + GTK_PLACES_OPEN_NORMAL | GTK_PLACES_OPEN_NEW_WINDOW); g_signal_connect(g.browser_sidebar, "open-location", G_CALLBACK(on_open_location), NULL); |