Enable opening from sidebar in a new window
This commit is contained in:
parent
9e45ba249e
commit
3bc07e00d9
24
fastiv.c
24
fastiv.c
|
@ -270,12 +270,25 @@ on_item_activated(G_GNUC_UNUSED FastivBrowser *browser, const char *path,
|
||||||
open(path);
|
open(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
|
static void
|
||||||
on_open_location(G_GNUC_UNUSED GtkPlacesSidebar *sidebar, GFile *location,
|
on_open_location(G_GNUC_UNUSED GtkPlacesSidebar *sidebar, GFile *location,
|
||||||
G_GNUC_UNUSED GtkPlacesOpenFlags flags, G_GNUC_UNUSED gpointer user_data)
|
G_GNUC_UNUSED GtkPlacesOpenFlags flags, G_GNUC_UNUSED gpointer user_data)
|
||||||
{
|
{
|
||||||
gchar *path = g_file_get_path(location);
|
gchar *path = g_file_get_path(location);
|
||||||
if (path) {
|
if (path) {
|
||||||
|
if (flags & GTK_PLACES_OPEN_NEW_WINDOW)
|
||||||
|
spawn_path(path);
|
||||||
|
else
|
||||||
load_directory(path);
|
load_directory(path);
|
||||||
g_free(path);
|
g_free(path);
|
||||||
}
|
}
|
||||||
|
@ -302,15 +315,10 @@ on_key_press(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event,
|
||||||
case GDK_KEY_o:
|
case GDK_KEY_o:
|
||||||
on_open();
|
on_open();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
case GDK_KEY_n: {
|
case GDK_KEY_n:
|
||||||
char *argv[] = {PROJECT_NAME, g.directory, NULL};
|
spawn_path(g.directory);
|
||||||
GError *error = NULL;
|
|
||||||
g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL,
|
|
||||||
NULL, &error);
|
|
||||||
g_clear_error(&error);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
switch (event->keyval) {
|
switch (event->keyval) {
|
||||||
|
@ -506,6 +514,8 @@ main(int argc, char *argv[])
|
||||||
GTK_PLACES_SIDEBAR(g.browser_sidebar), FALSE);
|
GTK_PLACES_SIDEBAR(g.browser_sidebar), FALSE);
|
||||||
gtk_places_sidebar_set_show_trash(
|
gtk_places_sidebar_set_show_trash(
|
||||||
GTK_PLACES_SIDEBAR(g.browser_sidebar), FALSE);
|
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_signal_connect(g.browser_sidebar, "open-location",
|
||||||
G_CALLBACK(on_open_location), NULL);
|
G_CALLBACK(on_open_location), NULL);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue