[gtksourceview/wip/loader-saver] File: update modification time
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/loader-saver] File: update modification time
- Date: Sat, 28 Dec 2013 14:26:01 +0000 (UTC)
commit 3137b109c5b8aba6fedbd30e1e8809feb3a4f912
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Dec 28 15:25:34 2013 +0100
File: update modification time
gtksourceview/gtksourcefile.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/gtksourceview/gtksourcefile.c b/gtksourceview/gtksourcefile.c
index 0e3268d..0781953 100644
--- a/gtksourceview/gtksourcefile.c
+++ b/gtksourceview/gtksourcefile.c
@@ -58,6 +58,41 @@ struct _GtkSourceFilePrivate
G_DEFINE_TYPE_WITH_PRIVATE (GtkSourceFile, gtk_source_file, G_TYPE_OBJECT)
static void
+update_mtime_cb (GFile *location,
+ GAsyncResult *result,
+ GtkSourceFile *file)
+{
+ GFileInfo *info = g_file_query_info_finish (location, result, NULL);
+
+ if (info != NULL && g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED))
+ {
+ g_file_info_get_modification_time (info, &file->priv->mtime);
+
+ file->priv->mtime_set = TRUE;
+ }
+
+ g_object_unref (info);
+ g_object_unref (file);
+}
+
+static void
+update_mtime (GtkSourceFile *file)
+{
+ /* We don't use a GTask to update the mtime, so when the callback is
+ * called, the GtkSourceFile must still be alive.
+ */
+ g_object_ref (file);
+
+ g_file_query_info_async (file->priv->location,
+ G_FILE_ATTRIBUTE_TIME_MODIFIED,
+ G_FILE_QUERY_INFO_NONE,
+ G_PRIORITY_DEFAULT,
+ NULL,
+ (GAsyncReadyCallback) update_mtime_cb,
+ file);
+}
+
+static void
gtk_source_file_get_property (GObject *object,
guint prop_id,
GValue *value,
@@ -494,5 +529,10 @@ gtk_source_file_save_finish (GtkSourceFile *file,
g_clear_object (&file->priv->saver);
+ if (ok)
+ {
+ update_mtime (file);
+ }
+
return ok;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]