aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2022-08-05 03:25:31 +0200
committerPřemysl Eric Janouch <p@janouch.name>2022-08-05 04:15:42 +0200
commit51dc56c9dfa26b560f367d2060a7147084cb7138 (patch)
treeb687cb28024acc3480c421b02eb69b1d064e411d
parentbb669743b606b6972485eec3153a22a5106b0427 (diff)
downloadfiv-51dc56c9dfa26b560f367d2060a7147084cb7138.tar.gz
fiv-51dc56c9dfa26b560f367d2060a7147084cb7138.tar.xz
fiv-51dc56c9dfa26b560f367d2060a7147084cb7138.zip
Improve support for opening HTTP URIs
While all GVfs files implement the mountable interface, mounting may not actually achieve anything.
-rw-r--r--fiv.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/fiv.c b/fiv.c
index fe3577b..723780e 100644
--- a/fiv.c
+++ b/fiv.c
@@ -913,27 +913,44 @@ on_item_activated(G_GNUC_UNUSED FivBrowser *browser, GFile *location,
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)
+on_mounted_enclosing(
+ GObject *source_object, GAsyncResult *res, gpointer user_data)
{
GFile *file = G_FILE(source_object);
GError *error = NULL;
- if (!g_file_mount_enclosing_volume_finish(file, res, &error))
+ if (g_file_mount_enclosing_volume_finish(file, res, &error))
+ goto retry;
+
+ if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_ALREADY_MOUNTED)) {
show_error_dialog(error);
- else
- open_any_file(file, FALSE);
+ return;
+ }
+
+ // The "http" scheme doesn't behave nicely, make a leap of faith.
+ g_error_free(error);
+ if (g_file_query_file_type(file, G_FILE_QUERY_INFO_NONE, NULL) ==
+ G_FILE_TYPE_UNKNOWN) {
+ gchar *uri = g_file_get_uri(file);
+ open_image(uri);
+ g_free(uri);
+ return;
+ }
+
+retry:
+ open_any_file(file, (gboolean) (gintptr) user_data);
}
static void
open_any_file(GFile *file, gboolean force_browser)
{
+ // Various GVfs schemes may need mounting.
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);
+ on_mounted_enclosing, (gpointer) (gintptr) force_browser);
g_object_unref(op);
return;
}