[gthumb] Fixed file saving, bug 586858
- From: Michael J. Chudobiak <mjc src gnome org>
- To: svn-commits-list gnome org
- Subject: [gthumb] Fixed file saving, bug 586858
- Date: Wed, 24 Jun 2009 18:28:03 +0000 (UTC)
commit d47cc4e01586772b695cbbcb35d6d7f7723ba7a0
Author: Michael J. Chudobiak <mjc avtechpulse com>
Date: Wed Jun 24 14:27:07 2009 -0400
Fixed file saving, bug 586858
Properly guess mime type for files that don't exist yet, based on
their extension.
libgthumb/dlg-save-image.c | 20 +++++++++++---------
libgthumb/gfile-utils.c | 18 +++++++++++++-----
src/dlg-photo-importer.c | 4 ++--
3 files changed, 26 insertions(+), 16 deletions(-)
---
diff --git a/libgthumb/dlg-save-image.c b/libgthumb/dlg-save-image.c
index dc7e055..3d0f883 100644
--- a/libgthumb/dlg-save-image.c
+++ b/libgthumb/dlg-save-image.c
@@ -31,6 +31,7 @@
#include "dlg-save-image.h"
#include "glib-utils.h"
+#include "file-data.h"
#include "file-utils.h"
#include "gfile-utils.h"
#include "gtk-utils.h"
@@ -178,7 +179,6 @@ file_save_ok_cb (GtkDialog *file_sel,
GtkWidget *combo_box;
GdkPixbuf *pixbuf;
FileData *file = NULL;
- const char *mime_type = NULL;
const char *original_file;
int idx;
SaveImageData *data;
@@ -194,13 +194,12 @@ file_save_ok_cb (GtkDialog *file_sel,
idx = gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box));
if (idx < 0
|| file_options[idx].type == IMAGE_TYPE_AUTOMATIC)
- mime_type = gfile_get_mime_type (file->gfile, FALSE);
+ file_data_update_mime_type (file, FALSE);
else
- mime_type = file_options[idx].mime_type;
- file->mime_type = get_static_string (mime_type);
+ file->mime_type = get_static_string (file_options[idx].mime_type);
save_image (parent, file, original_file, pixbuf, data, file_sel);
- g_free (file);
+ file_data_unref (file);
}
@@ -294,11 +293,13 @@ dlg_save_image_as (GtkWindow *parent,
gtk_widget_show_all (vbox);
/**/
-
- if (uri != NULL)
- gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (file_sel), uri);
- else
+ if (uri != NULL) {
+ FileData *fd = file_data_new_from_path (uri);
+ gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (file_sel), fd->uri);
+ file_data_unref (fd);
+ } else {
gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (file_sel), get_home_uri ());
+ }
g_object_ref (pixbuf);
@@ -351,6 +352,7 @@ dlg_save_image (GtkWindow *parent,
data->done_data = done_data;
data->metadata = metadata;
+ file_data_update_mime_type (file, TRUE);
save_image (parent, file, file->utf8_path, pixbuf, data, NULL);
}
diff --git a/libgthumb/gfile-utils.c b/libgthumb/gfile-utils.c
index 9d3c8cf..a15fd26 100644
--- a/libgthumb/gfile-utils.c
+++ b/libgthumb/gfile-utils.c
@@ -278,13 +278,11 @@ gfile_get_mime_type (GFile *file,
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
G_FILE_QUERY_INFO_NONE,
NULL,
- &error);
+ NULL);
+
if (error) {
- char *utf8_path = g_file_get_parse_name (file);
- g_warning ("Error getting mime_type for %s: %s", utf8_path, error->message);
+ gfile_warning ("Error getting file info for mime type check", file, error);
g_error_free (error);
- g_free (utf8_path);
- return NULL;
}
if (info != NULL) {
@@ -325,6 +323,16 @@ gfile_get_mime_type (GFile *file,
result = get_static_string (value);
g_object_unref (info);
+ } else {
+ char *value;
+ char *path = g_file_get_parse_name (file);
+ value = g_content_type_guess (path, NULL, 0, NULL);
+ result = get_static_string (value);
+ g_free (value);
+ g_free (path);
+
+ if (result == NULL)
+ gfile_warning ("Could not determime content type", file, error);
}
return result;
diff --git a/src/dlg-photo-importer.c b/src/dlg-photo-importer.c
index c8ca4f4..87747da 100644
--- a/src/dlg-photo-importer.c
+++ b/src/dlg-photo-importer.c
@@ -509,8 +509,6 @@ is_relevant_mime_type (GFile *gfile,
char *name_ext;
int i;
- /* For some reason, this does not always succeed. I think the gphoto2
- backend has a mime type detection bug. */
mime_type = gfile_get_mime_type (gfile, FALSE);
if (mime_type != NULL) {
if (mime_type_is_image (mime_type))
@@ -523,6 +521,8 @@ is_relevant_mime_type (GFile *gfile,
return FALSE;
}
+ /* FIXME - I don't think the following code is needed anymore */
+
basename = g_file_get_basename (gfile);
name_ext = get_filename_extension (basename);
g_free (basename);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]