Automount from location input

This commit is contained in:
Přemysl Eric Janouch 2022-01-05 06:40:08 +01:00
parent 244779bd8c
commit 6142bf9c53
Signed by: p
GPG Key ID: A0420B94F92B9493
1 changed files with 25 additions and 1 deletions

26
fiv.c
View File

@ -566,11 +566,35 @@ on_item_activated(G_GNUC_UNUSED FivBrowser *browser, GFile *location,
g_free(uri);
}
static void open_any_file(GFile *file, gboolean force_browser);
static void
on_mounted_enclosing(GObject *source_object, GAsyncResult *res,
G_GNUC_UNUSED gpointer user_data)
{
GFile *file = G_FILE(source_object);
GError *error = NULL;
if (!g_file_mount_enclosing_volume_finish(file, res, &error))
show_error_dialog(error);
else
open_any_file(file, FALSE);
}
static void
open_any_file(GFile *file, gboolean force_browser)
{
gchar *uri = g_file_get_uri(file);
GFileType type = g_file_query_file_type(file, G_FILE_QUERY_INFO_NONE, NULL);
if (type == G_FILE_TYPE_UNKNOWN &&
G_FILE_GET_IFACE(file)->mount_enclosing_volume) {
// TODO(p): At least provide some kind of indication.
GMountOperation *op = gtk_mount_operation_new(GTK_WINDOW(g.window));
g_file_mount_enclosing_volume(file, G_MOUNT_MOUNT_NONE, op, NULL,
on_mounted_enclosing, NULL);
g_object_unref(op);
return;
}
gchar *uri = g_file_get_uri(file);
if (type == G_FILE_TYPE_UNKNOWN) {
errno = ENOENT;
show_error_dialog(g_error_new(G_FILE_ERROR,