diff -rupN ristretto/src/image.c ristretto-new/src/image.c --- ristretto/src/image.c 2010-09-01 00:07:27.708187819 +0200 +++ ristretto-new/src/image.c 2010-09-01 00:28:00.367186596 +0200 @@ -259,33 +259,14 @@ RsttoImage * rstto_image_new (GFile *file) { RsttoImage *image = g_object_new (RSTTO_TYPE_IMAGE, NULL); - gchar *file_path = g_file_get_path (file); - ExifEntry *exif_entry = NULL; g_object_ref (file); image->priv->file = file; - image->priv->exif_data = exif_data_new_from_file (file_path); + image->priv->exif_data = NULL; image->priv->thumbnail = NULL; image->priv->pixbuf = NULL; - - if (image->priv->exif_data) { - exif_entry = exif_data_get_entry (image->priv->exif_data, EXIF_TAG_ORIENTATION); - } - /* Check if the image has exif-data available */ - if (exif_entry && exif_entry->data != NULL) - { - /* Get the image-orientation from EXIF data */ - image->priv->orientation = exif_get_short (exif_entry->data, exif_data_get_byte_order (exif_entry->parent->parent)); - if (image->priv->orientation == 0) - /* Default orientation */ - image->priv->orientation = RSTTO_IMAGE_ORIENT_NONE; - } - else - { - /* Default orientation */ - image->priv->orientation = RSTTO_IMAGE_ORIENT_NONE; - } + image->priv->orientation = RSTTO_IMAGE_ORIENT_NOT_DETERMINED; return image; } @@ -552,6 +533,31 @@ rstto_image_get_size (RsttoImage *image) RsttoImageOrientation rstto_image_get_orientation (RsttoImage *image) { + if (image->priv->orientation == RSTTO_IMAGE_ORIENT_NOT_DETERMINED){ + gchar *file_path = g_file_get_path (image->priv->file); + ExifEntry *exif_entry = NULL; + + image->priv->exif_data = exif_data_new_from_file (file_path); + + if (image->priv->exif_data) { + exif_entry = exif_data_get_entry (image->priv->exif_data, EXIF_TAG_ORIENTATION); + } + /* Check if the image has exif-data available */ + if (exif_entry && exif_entry->data != NULL) + { + /* Get the image-orientation from EXIF data */ + image->priv->orientation = exif_get_short (exif_entry->data, exif_data_get_byte_order (exif_entry->parent->parent)); + if (image->priv->orientation == 0) + /* Default orientation */ + image->priv->orientation = RSTTO_IMAGE_ORIENT_NONE; + } + else + { + /* Default orientation */ + image->priv->orientation = RSTTO_IMAGE_ORIENT_NONE; + } + } + return image->priv->orientation; } diff -rupN ristretto/src/image.h ristretto-new/src/image.h --- ristretto/src/image.h 2010-09-01 00:07:27.708187819 +0200 +++ ristretto-new/src/image.h 2010-09-01 00:28:00.367186596 +0200 @@ -31,6 +31,7 @@ typedef enum RSTTO_IMAGE_ORIENT_90, RSTTO_IMAGE_ORIENT_TRANSVERSE, RSTTO_IMAGE_ORIENT_270, + RSTTO_IMAGE_ORIENT_NOT_DETERMINED, } RsttoImageOrientation; #define RSTTO_TYPE_IMAGE rstto_image_get_type() diff -rupN ristretto/src/main_window.c ristretto-new/src/main_window.c --- ristretto/src/main_window.c 2010-09-01 00:07:27.712188746 +0200 +++ ristretto-new/src/main_window.c 2010-09-01 00:28:19.815207217 +0200 @@ -56,6 +56,9 @@ #define ZOOM_FACTOR 1.2 #endif +#define RSTTO_RECENT_FILES_APP_NAME "ristretto" +#define RSTTO_RECENT_FILES_GROUP "Graphics" + struct _RsttoMainWindowPriv { struct { @@ -258,6 +261,10 @@ rstto_main_window_set_navigationbar_posi static void cb_rstto_main_window_vpaned_pos_changed (GtkWidget *widget, gpointer user_data); +gboolean +rstto_main_window_add_file_to_recent_files (GFile *file); + + static GtkWidgetClass *parent_class = NULL; static GtkActionEntry action_entries[] = @@ -1981,13 +1988,7 @@ cb_rstto_main_window_open_image (GtkWidg gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); } - else - { - uri = g_file_get_uri (_files_iter->data); - gtk_recent_manager_add_item (window->priv->recent_manager, uri); - g_free (uri); - uri = NULL; - } + _files_iter = g_slist_next (_files_iter); } } @@ -2004,15 +2005,6 @@ cb_rstto_main_window_open_image (GtkWidg gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); } - else - { - - uri = g_file_get_uri (files->data); - gtk_recent_manager_add_item (window->priv->recent_manager, uri); - g_free (uri); - uri = NULL; - - } } if (pos == -1) @@ -2047,7 +2039,6 @@ cb_rstto_main_window_open_folder (GtkWid GFileInfo *file_info = NULL; const gchar *filename = NULL; const gchar *content_type = NULL; - gchar *uri = NULL; gint pos = 0; GtkWidget *dialog; gchar *current_uri = rstto_settings_get_string_property (RSTTO_SETTINGS (window->priv->settings_manager), "current-uri"); @@ -2092,10 +2083,8 @@ cb_rstto_main_window_open_folder (GtkWid if (pos == -1) rstto_image_list_iter_set_position (window->priv->iter, 0); - uri = g_file_get_uri (file); - gtk_recent_manager_add_item (window->priv->recent_manager, uri); - g_free (uri); - uri = NULL; + g_idle_add_full(G_PRIORITY_LOW, (GSourceFunc) rstto_main_window_add_file_to_recent_files, + file, NULL); rstto_settings_set_string_property (RSTTO_SETTINGS (window->priv->settings_manager), "current-uri", @@ -2454,3 +2443,40 @@ cb_rstto_main_window_vpaned_pos_changed rstto_settings_set_uint_property (RSTTO_SETTINGS (window->priv->settings_manager), "thumbnailbar-size", gtk_paned_get_position (GTK_PANED(widget))); g_debug("%s", __FUNCTION__); } + +gboolean +rstto_main_window_add_file_to_recent_files (GFile *file) +{ + GFileInfo *file_info; + GtkRecentData *recent_data; + gchar* uri; + static gchar *groups[2] = { RSTTO_RECENT_FILES_GROUP , NULL }; + + if (file == NULL) return FALSE; + + uri = g_file_get_uri (file); + if(uri == NULL) return FALSE; + + file_info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, + 0, NULL, NULL); + if (file_info == NULL) return FALSE; + + recent_data = g_slice_new (GtkRecentData); + recent_data->display_name = NULL; + recent_data->description = NULL; //NULL + recent_data->mime_type = (gchar *) g_file_info_get_content_type (file_info); + recent_data->app_name = RSTTO_RECENT_FILES_APP_NAME; + recent_data->app_exec = g_strjoin(" ", g_get_prgname (), "%u", NULL); + recent_data->groups = groups; + recent_data->is_private = FALSE; + + gtk_recent_manager_add_full (gtk_recent_manager_get_default(), uri, recent_data); + + g_free (recent_data->app_exec); + g_free (uri); + g_object_unref (file_info); + + g_slice_free (GtkRecentData, recent_data); + + return FALSE; +} diff -rupN ristretto/src/main_window.h ristretto-new/src/main_window.h --- ristretto/src/main_window.h 2010-09-01 00:07:27.712188746 +0200 +++ ristretto-new/src/main_window.h 2010-09-01 00:28:19.815207217 +0200 @@ -69,6 +69,8 @@ GType rstto_main_window_get_type(); GtkWidget *rstto_main_window_new (RsttoImageList *, gboolean); +gboolean rstto_main_window_add_file_to_recent_files (GFile *); + G_END_DECLS #endif /* __RISTRETTO_MAIN_WINDOW_H__ */ diff -rupN ristretto/src/picture_viewer.c ristretto-new/src/picture_viewer.c --- ristretto/src/picture_viewer.c 2010-09-01 00:07:27.712188746 +0200 +++ ristretto-new/src/picture_viewer.c 2010-09-01 00:28:19.815207217 +0200 @@ -29,6 +29,7 @@ #include "image_list.h" #include "picture_viewer.h" #include "settings.h" +#include "main_window.h" typedef enum { @@ -1659,6 +1660,9 @@ rstto_picture_viewer_set_image (RsttoPic } rstto_image_load (viewer->priv->image, FALSE, g_value_get_uint (&max_size), FALSE, NULL); + + g_idle_add_full(G_PRIORITY_LOW, (GSourceFunc) rstto_main_window_add_file_to_recent_files, + rstto_image_get_file(viewer->priv->image), NULL); } else {