[gthumb] Convert many fd->path references to fd->utf8_path.
- From: Michael J. Chudobiak <mjc src gnome org>
- To: svn-commits-list gnome org
- Subject: [gthumb] Convert many fd->path references to fd->utf8_path.
- Date: Fri, 29 May 2009 14:24:30 -0400 (EDT)
commit 5621030c783d657168b9e5597cb4e8f88d1a1499
Author: Michael J. Chudobiak <mjc avtechpulse com>
Date: Fri May 29 14:22:32 2009 -0400
Convert many fd->path references to fd->utf8_path.
Also, don't use cached thumbnails ever if the file mtime is less
than 5 seconds ago. Fixes problem when rotating images in quick
succession (i.e, with an interval less than 1 second).
---
libgthumb/file-data.c | 35 ++++++++++++++++++++++++++++++++++-
libgthumb/file-data.h | 5 ++++-
libgthumb/gth-file-list.c | 16 ++++++++--------
libgthumb/thumb-loader.c | 5 ++---
src/dlg-convert.c | 2 +-
src/gth-batch-op.c | 4 ++--
src/gth-browser-actions-callbacks.c | 4 ++--
src/gth-browser.c | 12 ++++++------
src/gth-fullscreen.c | 8 ++++----
src/gth-viewer.c | 10 +++-------
src/gth-window.c | 2 +-
src/gthumb-preloader.c | 8 ++++----
12 files changed, 71 insertions(+), 40 deletions(-)
diff --git a/libgthumb/file-data.c b/libgthumb/file-data.c
index 2214bbb..da2f0a2 100644
--- a/libgthumb/file-data.c
+++ b/libgthumb/file-data.c
@@ -366,7 +366,7 @@ file_data_list_find_path (GList *list,
for (scan = list; scan; scan = scan->next) {
FileData *data = scan->data;
- if (strcmp (data->path, path) == 0)
+ if (strcmp (data->utf8_path, path) == 0)
return scan;
}
@@ -375,6 +375,39 @@ file_data_list_find_path (GList *list,
gboolean
+file_data_same_path (FileData *fd1,
+ const char *path2)
+{
+ FileData *fd2;
+ gboolean result;
+
+ if ((fd1 == NULL) && (path2 == NULL))
+ return TRUE;
+ if ((fd1 == NULL) || (path2 == NULL))
+ return FALSE;
+
+ fd2 = file_data_new (path2);
+ result = !strcmp (fd1->utf8_path,fd2->utf8_path);
+
+ file_data_unref (fd2);
+ return result;
+}
+
+
+gboolean
+file_data_same (FileData *fd1,
+ FileData *fd2)
+{
+ if ((fd1 == NULL) && (fd2 == NULL))
+ return TRUE;
+ if ((fd1 == NULL) || (fd2 == NULL))
+ return FALSE;
+
+ return !strcmp (fd1->utf8_path,fd2->utf8_path);
+}
+
+
+gboolean
file_data_has_local_path (FileData *fd,
GtkWindow *window)
{
diff --git a/libgthumb/file-data.h b/libgthumb/file-data.h
index 87d72e1..11a92ec 100644
--- a/libgthumb/file-data.h
+++ b/libgthumb/file-data.h
@@ -88,5 +88,8 @@ GList* file_data_list_find_path (GList *list,
const char *path);
gboolean file_data_has_local_path (FileData *fd,
GtkWindow *window);
-
+gboolean file_data_same_path (FileData *fd1,
+ const char *path2);
+gboolean file_data_same (FileData *fd1,
+ FileData *fd2);
#endif /* FILE_DATA_H */
diff --git a/libgthumb/gth-file-list.c b/libgthumb/gth-file-list.c
index 8fb7bca..db3743c 100644
--- a/libgthumb/gth-file-list.c
+++ b/libgthumb/gth-file-list.c
@@ -601,7 +601,7 @@ set_unknown_pixbuf (GthFileList *file_list,
GdkPixbuf *pixbuf;
fd = gth_file_view_get_image_data (file_list->view, pos);
- if ((fd == NULL) || (fd->path == NULL))
+ if ((fd == NULL) || (fd->utf8_path == NULL))
return;
pixbuf = get_pixbuf_from_mime_type (file_list, fd->mime_type);
@@ -1155,7 +1155,7 @@ load_new_list (GthFileList *file_list)
GList *same_path_in_list;
GList *next = scan->next;
- same_path_in_list = file_data_list_find_path (file_list->list, new_fd->path);
+ same_path_in_list = file_data_list_find_path (file_list->list, new_fd->utf8_path);
if (same_path_in_list != NULL) {
FileData *old_fd = same_path_in_list->data;
@@ -1339,7 +1339,7 @@ gth_file_list_pos_from_path (GthFileList *file_list,
for (scan = list; scan; scan = scan->next) {
FileData *fd = scan->data;
- if (same_uri (fd->path, path)) {
+ if (file_data_same_path (fd, path)) {
retval = i;
break;
}
@@ -1370,7 +1370,7 @@ gth_file_list_filedata_from_path (GthFileList *file_list,
list = gth_file_view_get_list (file_list->view);
for (scan = list; scan; scan = scan->next) {
FileData *fd = scan->data;
- if (same_uri (fd->path, path)) {
+ if (file_data_same_path (fd, path)) {
result = file_data_ref (fd);
break;
}
@@ -1396,7 +1396,7 @@ gth_file_list_get_all (GthFileList *file_list)
list = NULL;
for (scan = file_list->list; scan; scan = scan->next) {
FileData *fd = scan->data;
- list = g_list_prepend (list, g_strdup (fd->path));
+ list = g_list_prepend (list, g_strdup (fd->utf8_path));
}
return g_list_reverse (list);
@@ -1413,7 +1413,7 @@ gth_file_list_get_all_from_view (GthFileList *file_list)
list = gth_file_view_get_list (file_list->view);
for (scan = list; scan; scan = scan->next) {
FileData *fd = scan->data;
- path_list = g_list_prepend (path_list, g_strdup (fd->path));
+ path_list = g_list_prepend (path_list, g_strdup (fd->utf8_path));
}
file_data_list_free (list);
@@ -1472,8 +1472,8 @@ gth_file_list_path_from_pos (GthFileList *file_list,
return NULL;
fd = gth_file_view_get_image_data (file_list->view, pos);
- if ((fd != NULL) && (fd->path != NULL))
- retval = g_strdup (fd->path);
+ if ((fd != NULL) && (fd->utf8_path != NULL))
+ retval = g_strdup (fd->utf8_path);
file_data_unref (fd);
return retval;
diff --git a/libgthumb/thumb-loader.c b/libgthumb/thumb-loader.c
index 05b96dc..8b6ed81 100644
--- a/libgthumb/thumb-loader.c
+++ b/libgthumb/thumb-loader.c
@@ -372,7 +372,7 @@ thumb_loader_start__step2 (ThumbLoader *tl)
return;
}
- if (tl->priv->use_cache) {
+ if ((tl->priv->use_cache && ((time (NULL) - tl->priv->file->mtime) > (time_t) 5))) {
cache_path = gnome_thumbnail_factory_lookup (tl->priv->thumb_factory,
tl->priv->file->uri,
tl->priv->file->mtime);
@@ -380,8 +380,7 @@ thumb_loader_start__step2 (ThumbLoader *tl)
if ((cache_path == NULL)
&& gnome_thumbnail_factory_has_valid_failed_thumbnail (tl->priv->thumb_factory,
tl->priv->file->uri,
- tl->priv->file->mtime)
- && ((time (NULL) - tl->priv->file->mtime) > (time_t) 5))
+ tl->priv->file->mtime))
{
/* Use the existing "failed" thumbnail, if it is over
5 seconds old. Otherwise, try to thumbnail it again.
diff --git a/src/dlg-convert.c b/src/dlg-convert.c
index 9c274e3..a7367e5 100644
--- a/src/dlg-convert.c
+++ b/src/dlg-convert.c
@@ -248,7 +248,7 @@ save_image_and_remove_original (DialogData *data)
if (error == NULL) {
data->saved_list = g_list_prepend (data->saved_list, g_strdup (fd_new->path));
- if (data->remove_original && ! same_uri (fd_old->path, fd_new->path)) {
+ if (data->remove_original && ! file_data_same (fd_old, fd_new)) {
file_unlink (fd_old->path);
data->deleted_list = g_list_prepend (data->deleted_list, g_strdup (fd_old->path));
}
diff --git a/src/gth-batch-op.c b/src/gth-batch-op.c
index 73785f5..effa0a2 100644
--- a/src/gth-batch-op.c
+++ b/src/gth-batch-op.c
@@ -465,8 +465,8 @@ pixbuf_op_done_cb (GthPixbufOp *pixop,
if (error == NULL) {
PD(bop)->saved_list = g_list_prepend (PD(bop)->saved_list, g_strdup (PD(bop)->new_path));
- if (! same_uri (fd_old->path, fd_new->path)) {
- comment_copy (fd_old->path, fd_new->path);
+ if (! file_data_same (fd_old, fd_new)) {
+ comment_copy (fd_old->utf8_path, fd_new->utf8_path);
if (PD(bop)->remove_original) {
file_unlink (fd_old->path);
PD(bop)->deleted_list = g_list_prepend (PD(bop)->deleted_list, g_strdup (fd_old->path));
diff --git a/src/gth-browser-actions-callbacks.c b/src/gth-browser-actions-callbacks.c
index b067ecd..27de172 100644
--- a/src/gth-browser-actions-callbacks.c
+++ b/src/gth-browser-actions-callbacks.c
@@ -949,7 +949,7 @@ folder_rename (GtkWindow *window,
gth_monitor_pause ();
- if (same_uri (old_fd->utf8_path, new_fd->utf8_path)) {
+ if (file_data_same (old_fd, new_fd)) {
_gtk_error_dialog_run (window,
_("Could not rename the folder \"%s\": %s"),
old_fd->utf8_name,
@@ -1205,7 +1205,7 @@ folder_copy__response_cb (GObject *object,
message = move ? _("Could not move the folder \"%s\": %s") : _("Could not copy the folder \"%s\": %s");
- if (same_uri (old_fd->utf8_path, new_fd->utf8_path)) {
+ if (file_data_same (old_fd, new_fd)) {
_gtk_error_dialog_run (GTK_WINDOW (window),
message,
old_fd->utf8_name,
diff --git a/src/gth-browser.c b/src/gth-browser.c
index 44712c0..db14d05 100644
--- a/src/gth-browser.c
+++ b/src/gth-browser.c
@@ -1970,7 +1970,7 @@ gth_file_list_cursor_changed_cb (GtkWidget *widget,
if (focused_image == NULL)
return;
- if ((priv->image == NULL) || ! same_uri (focused_image, priv->image->path))
+ if ((priv->image == NULL) || ! file_data_same_path (priv->image, focused_image))
view_image_at_pos (browser, pos);
g_free (focused_image);
@@ -5720,7 +5720,7 @@ gth_browser_notify_file_rename (GthBrowser *browser,
gth_file_list_delete (priv->file_list, new_name);
gth_file_list_rename (priv->file_list, old_name, new_name);
- if (priv->image != NULL && same_uri (old_name, priv->image->path))
+ if (priv->image != NULL && file_data_same_path (priv->image, old_name))
gth_browser_load_image_from_uri (browser, new_name);
}
@@ -7991,7 +7991,7 @@ view_focused_image (GthBrowser *browser)
if (focused == NULL)
return FALSE;
- not_focused = (priv->image == NULL) || ! same_uri (priv->image->path, focused);
+ not_focused = (priv->image == NULL) || ! file_data_same_path (priv->image, focused);
g_free (focused);
return not_focused;
@@ -8323,7 +8323,7 @@ gth_browser_load_image (GthBrowser *browser,
return;
}
- if ((priv->image != NULL) && same_uri (file->path, priv->image->path)) {
+ if ((priv->image != NULL) && file_data_same (file, priv->image)) {
gth_browser_reload_image (browser);
return;
}
@@ -8333,7 +8333,7 @@ gth_browser_load_image (GthBrowser *browser,
if (! priv->image_modified
&& (priv->image != NULL)
&& (file != NULL)
- && same_uri (file->path, priv->image->path)
+ && file_data_same (file, priv->image)
&& (priv->image->mtime == file->mtime))
return;
@@ -8553,7 +8553,7 @@ fullscreen_destroy_cb (GtkWidget *widget,
if ((current_image == NULL || browser->priv->image == NULL))
return FALSE;
- if (same_uri (browser->priv->image->path, current_image))
+ if (same_uri (browser->priv->image->utf8_path, current_image))
return FALSE;
pos = gth_file_list_pos_from_path (browser->priv->file_list, current_image);
diff --git a/src/gth-fullscreen.c b/src/gth-fullscreen.c
index a69e3e7..bae80a4 100644
--- a/src/gth-fullscreen.c
+++ b/src/gth-fullscreen.c
@@ -484,7 +484,7 @@ load_current_image (GthFullscreen *fullscreen)
if ((priv->image != NULL)
&& (priv->file != NULL)
- && same_uri (priv->file->path, current->path))
+ && file_data_same (priv->file, current))
image_viewer_set_pixbuf (IMAGE_VIEWER (priv->viewer), priv->image);
else {
@@ -767,7 +767,7 @@ pos_from_path (GList *list,
for (scan = list; scan; scan = scan->next) {
FileData *fd = scan->data;
- if (same_uri (fd->path, path))
+ if (file_data_same_path (fd, path))
return i;
i++;
}
@@ -1407,7 +1407,7 @@ monitor_update_cat_files_cb (GthMonitor *monitor,
{
if (fullscreen->priv->catalog_path == NULL)
return;
- if (! same_uri (fullscreen->priv->catalog_path, catalog_name))
+ if (! same_uri (fullscreen->priv->catalog_path, catalog_name)) /* FIXME */
return;
switch (event) {
@@ -1491,7 +1491,7 @@ monitor_file_renamed_cb (GthMonitor *monitor,
if (fullscreen->priv->file == NULL)
return;
- if (! same_uri (old_name, fullscreen->priv->file->path))
+ if (! file_data_same_path (fullscreen->priv->file, old_name))
return;
file_data_unref (fullscreen->priv->file);
diff --git a/src/gth-viewer.c b/src/gth-viewer.c
index eb1b9bd..ea135a8 100644
--- a/src/gth-viewer.c
+++ b/src/gth-viewer.c
@@ -798,7 +798,7 @@ save_pixbuf__image_saved_cb (FileData *file,
if (closing)
return;
- if ((viewer->priv->image != NULL) && ! same_uri (viewer->priv->image->path, file->path)) {
+ if ((viewer->priv->image != NULL) && ! file_data_same (viewer->priv->image, file)) {
/*FIXME: gtk_widget_show (gth_viewer_new (uri));*/
file_data_set_path (viewer->priv->image, file->path);
gth_viewer_load (viewer, viewer->priv->image);
@@ -1235,17 +1235,13 @@ monitor_file_renamed_cb (GthMonitor *monitor,
const char *new_name,
GthViewer *viewer)
{
- char *uri;
-
if (viewer->priv->image == NULL)
return;
- if (! same_uri (old_name, viewer->priv->image->path))
+ if (! file_data_same_path (viewer->priv->image, old_name))
return;
- uri = add_scheme_if_absent (new_name);
- file_data_set_path (viewer->priv->image, uri);
- g_free (uri);
+ file_data_set_path (viewer->priv->image, new_name);
gth_window_reload_current_image (GTH_WINDOW (viewer));
}
diff --git a/src/gth-window.c b/src/gth-window.c
index 96a08a1..c0b6924 100644
--- a/src/gth-window.c
+++ b/src/gth-window.c
@@ -330,7 +330,7 @@ gth_window_get_image_filename (GthWindow *window)
if (file == NULL)
return NULL;
else
- return file->path;
+ return file->utf8_path;
}
diff --git a/src/gthumb-preloader.c b/src/gthumb-preloader.c
index e567966..17abe94 100644
--- a/src/gthumb-preloader.c
+++ b/src/gthumb-preloader.c
@@ -384,13 +384,13 @@ gthumb_preloader_load__step2 (LoadData *load_data)
PreLoader *ploader = gploader->loader[i];
if ((ploader->file != NULL)
- && same_uri (ploader->file->path, file->path)
+ && file_data_same (ploader->file, file)
&& (file->mtime == ploader->file->mtime)
&& ploader->loaded)
{
loader_assigned[i] = TRUE;
file_assigned[j] = TRUE;
- if (same_uri (file->path, requested->path)) {
+ if (file_data_same (file, requested)) {
gploader->requested = i;
g_signal_emit (G_OBJECT (gploader), gthumb_preloader_signals[REQUESTED_DONE], 0);
debug (DEBUG_INFO, "[requested] preloaded");
@@ -423,7 +423,7 @@ gthumb_preloader_load__step2 (LoadData *load_data)
loader_assigned[k] = TRUE;
preloader_set_file (ploader, file);
- if (same_uri (file->path, requested->path)) {
+ if (file_data_same (file, requested)) {
gploader->requested = k;
debug (DEBUG_INFO, "[requested] %s", file->path);
}
@@ -507,7 +507,7 @@ gthumb_preloader_get_loader (GThumbPreloader *gploader,
PreLoader *ploader = gploader->loader[i];
if ((ploader->file != NULL)
- && same_uri (ploader->file->path, path)
+ && file_data_same_path (ploader->file, path)
&& (path_mtime == ploader->file->mtime)
&& ploader->loaded)
return ploader->loader;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]