Compare commits
2 Commits
d590d1da46
...
51dc56c9df
Author | SHA1 | Date | |
---|---|---|---|
51dc56c9df | |||
bb669743b6 |
20
fiv-view.c
20
fiv-view.c
@ -1095,24 +1095,24 @@ save_as(FivView *self, cairo_surface_t *frame)
|
|||||||
gtk_file_chooser_set_do_overwrite_confirmation(chooser, TRUE);
|
gtk_file_chooser_set_do_overwrite_confirmation(chooser, TRUE);
|
||||||
|
|
||||||
GFile *file = g_file_new_for_uri(self->uri);
|
GFile *file = g_file_new_for_uri(self->uri);
|
||||||
const gchar *path = g_file_peek_path(file);
|
GFileInfo *info =
|
||||||
// TODO(p): Use g_file_info_get_display_name().
|
g_file_query_info(file, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
|
||||||
gchar *basename = g_filename_display_basename(path ? path : self->uri);
|
G_FILE_QUERY_INFO_NONE, NULL, NULL);
|
||||||
|
|
||||||
// Note that GTK+'s save dialog is too stupid to automatically change
|
// Note that GTK+'s save dialog is too stupid to automatically change
|
||||||
// the extension when user changes the filter. Presumably,
|
// the extension when user changes the filter. Presumably,
|
||||||
// gtk_file_chooser_set_extra_widget() can be used to circumvent this.
|
// gtk_file_chooser_set_extra_widget() can be used to circumvent this.
|
||||||
gchar *name =
|
const char *basename = info ? g_file_info_get_display_name(info) : "image";
|
||||||
g_strdup_printf(frame ? "%s.frame.webp" : "%s.webp", basename);
|
gchar *name = g_strconcat(basename, frame ? "-frame.webp" : ".webp", NULL);
|
||||||
gtk_file_chooser_set_current_name(chooser, name);
|
gtk_file_chooser_set_current_name(chooser, name);
|
||||||
g_free(name);
|
g_free(name);
|
||||||
if (path) {
|
if (g_file_peek_path(file)) {
|
||||||
gchar *dirname = g_path_get_dirname(path);
|
GFile *parent = g_file_get_parent(file);
|
||||||
gtk_file_chooser_set_current_folder(chooser, dirname);
|
(void) gtk_file_chooser_set_current_folder_file(chooser, parent, NULL);
|
||||||
g_free(dirname);
|
g_object_unref(parent);
|
||||||
}
|
}
|
||||||
g_free(basename);
|
|
||||||
g_object_unref(file);
|
g_object_unref(file);
|
||||||
|
g_clear_object(&info);
|
||||||
|
|
||||||
// This is the best general format: supports lossless encoding, animations,
|
// This is the best general format: supports lossless encoding, animations,
|
||||||
// alpha channel, and Exif and ICC profile metadata.
|
// alpha channel, and Exif and ICC profile metadata.
|
||||||
|
29
fiv.c
29
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 open_any_file(GFile *file, gboolean force_browser);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_mounted_enclosing(GObject *source_object, GAsyncResult *res,
|
on_mounted_enclosing(
|
||||||
G_GNUC_UNUSED gpointer user_data)
|
GObject *source_object, GAsyncResult *res, gpointer user_data)
|
||||||
{
|
{
|
||||||
GFile *file = G_FILE(source_object);
|
GFile *file = G_FILE(source_object);
|
||||||
GError *error = NULL;
|
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);
|
show_error_dialog(error);
|
||||||
else
|
return;
|
||||||
open_any_file(file, FALSE);
|
}
|
||||||
|
|
||||||
|
// 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
|
static void
|
||||||
open_any_file(GFile *file, gboolean force_browser)
|
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);
|
GFileType type = g_file_query_file_type(file, G_FILE_QUERY_INFO_NONE, NULL);
|
||||||
if (type == G_FILE_TYPE_UNKNOWN &&
|
if (type == G_FILE_TYPE_UNKNOWN &&
|
||||||
G_FILE_GET_IFACE(file)->mount_enclosing_volume) {
|
G_FILE_GET_IFACE(file)->mount_enclosing_volume) {
|
||||||
// TODO(p): At least provide some kind of indication.
|
// TODO(p): At least provide some kind of indication.
|
||||||
GMountOperation *op = gtk_mount_operation_new(GTK_WINDOW(g.window));
|
GMountOperation *op = gtk_mount_operation_new(GTK_WINDOW(g.window));
|
||||||
g_file_mount_enclosing_volume(file, G_MOUNT_MOUNT_NONE, op, NULL,
|
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);
|
g_object_unref(op);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user