static char * get_basename_wo_ext_func (GthFileData *file_data) { char *basename; char *basename_wo_ext; basename = g_file_get_basename (file_data->file); basename_wo_ext = _g_uri_remove_extension (basename); g_free (basename); return basename_wo_ext; }
static void catalog_ready_cb (GObject *object, GError *error, gpointer user_data) { DialogData *data = user_data; if (error != NULL) { _gtk_error_dialog_from_gerror_show (GTK_WINDOW(data->browser), _("Could not load the catalog"), error); gtk_widget_destroy (data->dialog); return; } data->catalog = g_object_ref (object); if (gth_catalog_get_name (data->catalog) != NULL) { gtk_entry_set_text (GTK_ENTRY (GET_WIDGET ("name_entry")), gth_catalog_get_name (data->catalog)); } else if (! gth_datetime_valid_date (gth_catalog_get_date (data->catalog))) { char *basename; char *name; char *utf8_name; basename = g_file_get_basename (data->file_data->file); name = _g_uri_remove_extension (basename); utf8_name = g_filename_to_utf8 (name, -1, NULL, NULL, NULL); gtk_entry_set_text (GTK_ENTRY (GET_WIDGET ("name_entry")), utf8_name); g_free (utf8_name); g_free (name); g_free (basename); } gth_time_selector_set_value (GTH_TIME_SELECTOR (data->time_selector), gth_catalog_get_date (data->catalog)); gth_hook_invoke ("dlg-catalog-properties", data->builder, data->file_data, data->catalog); gtk_widget_show (data->dialog); g_object_unref (object); }
static void set_current_destination_file (GthPixbufListTask *self) { GthFileData *file_data; char *display_name; GFile *parent; GFile *destination; file_data = self->priv->current->data; if (self->priv->mime_type != NULL) { char *no_ext; GthPixbufSaver *saver; no_ext = _g_uri_remove_extension (g_file_info_get_display_name (file_data->info)); saver = gth_main_get_pixbuf_saver (self->priv->mime_type); g_return_if_fail (saver != NULL); display_name = g_strconcat (no_ext, ".", gth_pixbuf_saver_get_default_ext (saver), NULL); gth_file_data_set_mime_type (file_data, self->priv->mime_type); g_object_unref (saver); g_free (no_ext); } else display_name = g_strdup (g_file_info_get_display_name (file_data->info)); if (self->priv->destination_folder != NULL) parent = g_object_ref (self->priv->destination_folder); else parent = g_file_get_parent (file_data->file); destination = g_file_get_child_for_display_name (parent, display_name, NULL); gth_file_data_set_file (file_data, destination); g_object_unref (destination); g_object_unref (parent); g_free (display_name); }
static GthImage * dcraw_pixbuf_animation_new_from_file (GInputStream *istream, GthFileData *file_data, int requested_size, int *original_width, int *original_height, gpointer user_data, GCancellable *cancellable, GError **error) { GthImage *image = NULL; GdkPixbuf *pixbuf; gboolean is_thumbnail; gboolean is_raw; gboolean is_hdr; char *local_file; char *local_file_md5; char *cache_file; char *cache_file_esc; char *local_file_esc; char *command = NULL; if (file_data == NULL) { if (error != NULL) *error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_INVALID_FILENAME, "Could not load file"); return NULL; } is_thumbnail = requested_size > 0; is_raw = _g_mime_type_is_raw (gth_file_data_get_mime_type (file_data)); is_hdr = _g_mime_type_is_hdr (gth_file_data_get_mime_type (file_data)); /* The output filename, and its persistence, depend on the input file * type, and whether or not a thumbnail has been requested. */ local_file = g_file_get_path (file_data->file); local_file_md5 = gnome_desktop_thumbnail_md5 (local_file); if (is_raw && !is_thumbnail) /* Full-sized converted RAW file */ cache_file = get_cache_full_path (local_file_md5, "conv.pnm"); else if (is_raw && is_thumbnail) /* RAW: thumbnails generated in pnm format. The converted file is later removed. */ cache_file = get_cache_full_path (local_file_md5, "conv-thumb.pnm"); else if (is_hdr && is_thumbnail) /* HDR: thumbnails generated in tiff format. The converted file is later removed. */ cache_file = get_cache_full_path (local_file_md5, "conv-thumb.tiff"); else /* Full-sized converted HDR files */ cache_file = get_cache_full_path (local_file_md5, "conv.tiff"); g_free (local_file_md5); if (cache_file == NULL) { g_free (local_file); return NULL; } local_file_esc = g_shell_quote (local_file); cache_file_esc = g_shell_quote (cache_file); /* Do nothing if an up-to-date converted file is already in the cache */ if (! g_file_test (cache_file, G_FILE_TEST_EXISTS) || (gth_file_data_get_mtime (file_data) > get_file_mtime (cache_file))) { if (is_raw) { if (is_thumbnail) { char *first_part; char *jpg_thumbnail; char *tiff_thumbnail; char *ppm_thumbnail; char *thumb_command; thumb_command = g_strdup_printf ("dcraw -e %s", local_file_esc); g_spawn_command_line_sync (thumb_command, NULL, NULL, NULL, NULL); g_free (thumb_command); first_part = _g_uri_remove_extension (local_file); jpg_thumbnail = g_strdup_printf ("%s.thumb.jpg", first_part); tiff_thumbnail = g_strdup_printf ("%s.thumb.tiff", first_part); ppm_thumbnail = g_strdup_printf ("%s.thumb.ppm", first_part); if (g_file_test (jpg_thumbnail, G_FILE_TEST_EXISTS)) { g_free (cache_file); cache_file = g_strdup (jpg_thumbnail); } else if (g_file_test (tiff_thumbnail, G_FILE_TEST_EXISTS)) { g_free (cache_file); cache_file = g_strdup (tiff_thumbnail); } else if (g_file_test (ppm_thumbnail, G_FILE_TEST_EXISTS)) { g_free (cache_file); cache_file = g_strdup (ppm_thumbnail); } else { /* No embedded thumbnail. Read the whole file. */ /* Add -h option to speed up thumbnail generation. */ command = g_strdup_printf ("dcraw -w -c -h %s > %s", local_file_esc, cache_file_esc); } g_free (first_part); g_free (jpg_thumbnail); g_free (tiff_thumbnail); g_free (ppm_thumbnail); } else { /* -w option = camera-specified white balance */ command = g_strdup_printf ("dcraw -w -c %s > %s", local_file_esc, cache_file_esc); } } if (is_hdr) { /* HDR files. We can use the pfssize tool to speed up thumbnail generation considerably, so we treat thumbnailing as a special case. */ char *resize_command; if (is_thumbnail) resize_command = g_strdup_printf (" | pfssize --maxx %d --maxy %d", requested_size, requested_size); else resize_command = g_strdup_printf (" "); command = g_strconcat ( "pfsin ", local_file_esc, resize_command, " | pfsclamp --rgb | pfstmo_drago03 | pfsout ", cache_file_esc, NULL ); g_free (resize_command); } if (command != NULL) { if (system (command) == -1) { g_free (command); g_free (cache_file_esc); g_free (local_file_esc); g_free (cache_file); g_free (local_file); return NULL; } g_free (command); } } pixbuf = gdk_pixbuf_new_from_file (cache_file, NULL); /* Thumbnail files are already cached, so delete the conversion cache copies */ if (is_thumbnail) { GFile *file; file = g_file_new_for_path (cache_file); g_file_delete (file, NULL, NULL); g_object_unref (file); } if (pixbuf != NULL) { image = gth_image_new_for_pixbuf (pixbuf); g_object_unref (pixbuf); } g_free (cache_file_esc); g_free (local_file_esc); g_free (cache_file); g_free (local_file); return image; }