Compare commits
No commits in common. "51dc56c9dfa26b560f367d2060a7147084cb7138" and "d590d1da46843059dfbc71ce2f8aa0d8dba62572" have entirely different histories.
51dc56c9df
...
d590d1da46
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);
|
||||
|
||||
GFile *file = g_file_new_for_uri(self->uri);
|
||||
GFileInfo *info =
|
||||
g_file_query_info(file, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
|
||||
G_FILE_QUERY_INFO_NONE, NULL, NULL);
|
||||
const gchar *path = g_file_peek_path(file);
|
||||
// TODO(p): Use g_file_info_get_display_name().
|
||||
gchar *basename = g_filename_display_basename(path ? path : self->uri);
|
||||
|
||||
// Note that GTK+'s save dialog is too stupid to automatically change
|
||||
// the extension when user changes the filter. Presumably,
|
||||
// gtk_file_chooser_set_extra_widget() can be used to circumvent this.
|
||||
const char *basename = info ? g_file_info_get_display_name(info) : "image";
|
||||
gchar *name = g_strconcat(basename, frame ? "-frame.webp" : ".webp", NULL);
|
||||
gchar *name =
|
||||
g_strdup_printf(frame ? "%s.frame.webp" : "%s.webp", basename);
|
||||
gtk_file_chooser_set_current_name(chooser, name);
|
||||
g_free(name);
|
||||
if (g_file_peek_path(file)) {
|
||||
GFile *parent = g_file_get_parent(file);
|
||||
(void) gtk_file_chooser_set_current_folder_file(chooser, parent, NULL);
|
||||
g_object_unref(parent);
|
||||
if (path) {
|
||||
gchar *dirname = g_path_get_dirname(path);
|
||||
gtk_file_chooser_set_current_folder(chooser, dirname);
|
||||
g_free(dirname);
|
||||
}
|
||||
g_free(basename);
|
||||
g_object_unref(file);
|
||||
g_clear_object(&info);
|
||||
|
||||
// This is the best general format: supports lossless encoding, animations,
|
||||
// alpha channel, and Exif and ICC profile metadata.
|
||||
|
29
fiv.c
29
fiv.c
@ -913,44 +913,27 @@ 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, gpointer user_data)
|
||||
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))
|
||||
goto retry;
|
||||
|
||||
if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_ALREADY_MOUNTED)) {
|
||||
if (!g_file_mount_enclosing_volume_finish(file, res, &error))
|
||||
show_error_dialog(error);
|
||||
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);
|
||||
else
|
||||
open_any_file(file, FALSE);
|
||||
}
|
||||
|
||||
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, (gpointer) (gintptr) force_browser);
|
||||
on_mounted_enclosing, NULL);
|
||||
g_object_unref(op);
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user