From 82bb28d04f9ac48818cf556131cc908396d69b26 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Tue, 5 Jun 2007 09:23:09 +0000 Subject: [PATCH] Adapted patch from Arjan van de Ven (arjan@linux.intel.com) to avoid the 2007-06-05 Bastien Nocera * shell/ev-metadata-manager.c: (ev_metadata_arm_timeout), (ev_metadata_manager_init), (ev_metadata_manager_shutdown), (ev_metadata_manager_set_last), (ev_metadata_manager_set), (ev_metadata_manager_save): Adapted patch from Arjan van de Ven (arjan@linux.intel.com) to avoid the timeout running all the time, saves on power (Closes: #443851) svn path=/trunk/; revision=2484 --- ChangeLog | 9 +++++++ shell/ev-metadata-manager.c | 47 +++++++++++++++++++++++++++++-------- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index d94e61b4..5d7808e5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-06-05 Bastien Nocera + + * shell/ev-metadata-manager.c: (ev_metadata_arm_timeout), + (ev_metadata_manager_init), (ev_metadata_manager_shutdown), + (ev_metadata_manager_set_last), (ev_metadata_manager_set), + (ev_metadata_manager_save): Adapted patch from Arjan van de + Ven (arjan@linux.intel.com) to avoid the timeout running all the + time, saves on power (Closes: #443851) + 2007-06-02 Carlos Garcia Campos * configure.ac: diff --git a/shell/ev-metadata-manager.c b/shell/ev-metadata-manager.c index 0dba983e..402beb70 100644 --- a/shell/ev-metadata-manager.c +++ b/shell/ev-metadata-manager.c @@ -93,6 +93,24 @@ item_free (gpointer data) g_free (item); } +/** + * ev_metadata_arm_timeout + * + * Setup a timeout for saving the metadata to disk. + */ +static void +ev_metadata_arm_timeout(void) +{ + if (ev_metadata_manager->timeout_id) + return; + ev_metadata_manager->timeout_id = + g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE, + 2000, /* 2 sec */ + (GSourceFunc)ev_metadata_manager_save, + NULL, + NULL); +} + /** * ev_metadata_manager_init: * @@ -116,13 +134,6 @@ ev_metadata_manager_init (void) g_str_equal, g_free, item_free); - - ev_metadata_manager->timeout_id = - g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE, - 2000, /* 2 sec */ - (GSourceFunc)ev_metadata_manager_save, - NULL, - NULL); } /* This function must be called before exiting ev */ @@ -132,7 +143,8 @@ ev_metadata_manager_shutdown (void) if (ev_metadata_manager == NULL) return; - g_source_remove (ev_metadata_manager->timeout_id); + if (ev_metadata_manager->timeout_id) + g_source_remove (ev_metadata_manager->timeout_id); ev_metadata_manager_save (NULL); @@ -392,6 +404,7 @@ ev_metadata_manager_set_last (const gchar *key, item->atime = time (NULL); ev_metadata_manager->modified = TRUE; + ev_metadata_arm_timeout (); return; } @@ -527,6 +540,7 @@ ev_metadata_manager_set (const gchar *uri, item->atime = time (NULL); ev_metadata_manager->modified = TRUE; + ev_metadata_arm_timeout (); } static void @@ -647,8 +661,10 @@ ev_metadata_manager_save (gpointer data) xmlNodePtr root; gchar *file_name; + ev_metadata_manager->timeout_id = 0; + if (!ev_metadata_manager->modified) - return TRUE; + return FALSE; resize_items (); @@ -674,9 +690,20 @@ ev_metadata_manager_save (gpointer data) ev_metadata_manager->modified = FALSE; - return TRUE; + return FALSE; } +void ev_metadata_arm_timeout(void) +{ + if (ev_metadata_manager->timeout_id) + return; + ev_metadata_manager->timeout_id = + g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE, + 2000, /* 2 sec */ + (GSourceFunc)ev_metadata_manager_save, + NULL, + NULL); +} void ev_metadata_manager_set_int (const gchar *uri, const gchar *key, int value) { -- 2.43.5