diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2021-12-26 19:41:42 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2021-12-27 21:51:01 +0100 |
commit | 336053f24d40bc5c350cad285a8d5e146c09d321 (patch) | |
tree | c6128561d31f351ffe311ff5dbbe987efd5e0e13 /fiv-view.c | |
parent | 2f993502fc6584a5877b300a1353cabf58c4e0e9 (diff) | |
download | fiv-336053f24d40bc5c350cad285a8d5e146c09d321.tar.gz fiv-336053f24d40bc5c350cad285a8d5e146c09d321.tar.xz fiv-336053f24d40bc5c350cad285a8d5e146c09d321.zip |
Implement trivial wide thumbnail production
Also make libwebp a required dependency.
Diffstat (limited to 'fiv-view.c')
-rw-r--r-- | fiv-view.c | 40 |
1 files changed, 15 insertions, 25 deletions
@@ -797,18 +797,7 @@ save_as(FivView *self, cairo_surface_t *frame) "_Cancel", GTK_RESPONSE_CANCEL, "_Save", GTK_RESPONSE_ACCEPT, NULL); GtkFileChooser *chooser = GTK_FILE_CHOOSER(dialog); - - // TODO(p): Consider a hard dependency on libwebp, or clean this up. -#ifdef HAVE_LIBWEBP - // This is the best general format: supports lossless encoding, animations, - // alpha channel, and Exif and ICC profile metadata. - // PNG is another viable option, but sPNG can't do APNG, Wuffs can't save, - // and libpng is a pain in the arse. - GtkFileFilter *webp_filter = gtk_file_filter_new(); - gtk_file_filter_add_mime_type(webp_filter, "image/webp"); - gtk_file_filter_add_pattern(webp_filter, "*.webp"); - gtk_file_filter_set_name(webp_filter, "Lossless WebP (*.webp)"); - gtk_file_chooser_add_filter(chooser, webp_filter); + gtk_file_chooser_set_do_overwrite_confirmation(chooser, TRUE); // Note that GTK+'s save dialog is too stupid to automatically change // the extension when user changes the filter. Presumably, @@ -819,14 +808,21 @@ save_as(FivView *self, cairo_surface_t *frame) g_free(basename); gtk_file_chooser_set_current_name(chooser, name); g_free(name); -#endif // HAVE_LIBWEBP - - gtk_file_chooser_set_do_overwrite_confirmation(chooser, TRUE); gchar *dirname = g_path_get_dirname(self->path); gtk_file_chooser_set_current_folder(chooser, dirname); g_free(dirname); + // This is the best general format: supports lossless encoding, animations, + // alpha channel, and Exif and ICC profile metadata. + // PNG is another viable option, but sPNG can't do APNG, Wuffs can't save, + // and libpng is a pain in the arse. + GtkFileFilter *webp_filter = gtk_file_filter_new(); + gtk_file_filter_add_mime_type(webp_filter, "image/webp"); + gtk_file_filter_add_pattern(webp_filter, "*.webp"); + gtk_file_filter_set_name(webp_filter, "Lossless WebP (*.webp)"); + gtk_file_chooser_add_filter(chooser, webp_filter); + // The format is supported by Exiv2 and ExifTool. // This is mostly a developer tool. GtkFileFilter *exv_filter = gtk_file_filter_new(); @@ -835,22 +831,16 @@ save_as(FivView *self, cairo_surface_t *frame) gtk_file_filter_set_name(exv_filter, "Exiv2 metadata (*.exv)"); gtk_file_chooser_add_filter(chooser, exv_filter); + GError *error = NULL; switch (gtk_dialog_run(GTK_DIALOG(dialog))) { gchar *path; case GTK_RESPONSE_ACCEPT: path = gtk_file_chooser_get_filename(chooser); - - GError *error = NULL; -#ifdef HAVE_LIBWEBP - if (gtk_file_chooser_get_filter(chooser) == webp_filter) - fiv_io_save(self->page, frame, target, path, &error); - else -#endif // HAVE_LIBWEBP - fiv_io_save_metadata(self->page, path, &error); - if (error) + if (!(gtk_file_chooser_get_filter(chooser) == webp_filter + ? fiv_io_save(self->page, frame, target, path, &error) + : fiv_io_save_metadata(self->page, path, &error))) show_error_dialog(window, error); g_free(path); - // Fall-through. default: gtk_widget_destroy(dialog); |