+2007-06-05 Bastien Nocera <hadess@hadess.net>
+
+ * 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 <carlosgc@gnome.org>
* configure.ac:
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:
*
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 */
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);
item->atime = time (NULL);
ev_metadata_manager->modified = TRUE;
+ ev_metadata_arm_timeout ();
return;
}
item->atime = time (NULL);
ev_metadata_manager->modified = TRUE;
+ ev_metadata_arm_timeout ();
}
static void
xmlNodePtr root;
gchar *file_name;
+ ev_metadata_manager->timeout_id = 0;
+
if (!ev_metadata_manager->modified)
- return TRUE;
+ return FALSE;
resize_items ();
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)
{