[gnome-builder/wip/libide-merge] set read-only and mtime properties when loading a buffer
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/libide-merge] set read-only and mtime properties when loading a buffer
- Date: Mon, 23 Mar 2015 01:53:04 +0000 (UTC)
commit 3cd9ab908158d443f6135c7f46fed4f89ab3b7ea
Author: Christian Hergert <christian hergert me>
Date: Sun Mar 22 18:52:27 2015 -0700
set read-only and mtime properties when loading a buffer
libide/ide-buffer-manager.c | 21 ++++++++++++++++++++-
libide/ide-buffer.c | 8 ++++----
libide/ide-internal.h | 2 ++
3 files changed, 26 insertions(+), 5 deletions(-)
---
diff --git a/libide/ide-buffer-manager.c b/libide/ide-buffer-manager.c
index 0415110..186b761 100644
--- a/libide/ide-buffer-manager.c
+++ b/libide/ide-buffer-manager.c
@@ -545,6 +545,23 @@ ide_buffer_manager__load_file_query_info_cb (GObject *object,
IDE_EXIT;
}
+ if (g_file_info_has_attribute (file_info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE))
+ {
+ gboolean read_only;
+
+ read_only = !g_file_info_get_attribute_boolean (file_info,
+ G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE);
+ _ide_buffer_set_read_only (state->buffer, read_only);
+ }
+
+ if (g_file_info_has_attribute (file_info, G_FILE_ATTRIBUTE_TIME_MODIFIED))
+ {
+ GTimeVal tv;
+
+ g_file_info_get_modification_time (file_info, &tv);
+ _ide_buffer_set_mtime (state->buffer, &tv);
+ }
+
g_signal_emit (self, gSignals [LOAD_BUFFER], 0, state->buffer);
gtk_source_file_loader_load_async (state->loader,
@@ -592,7 +609,9 @@ ide_buffer_manager__load_file_read_cb (GObject *object,
state->loader = gtk_source_file_loader_new (GTK_SOURCE_BUFFER (state->buffer), source_file);
g_file_query_info_async (file,
- G_FILE_ATTRIBUTE_STANDARD_SIZE,
+ G_FILE_ATTRIBUTE_STANDARD_SIZE","
+ G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE","
+ G_FILE_ATTRIBUTE_TIME_MODIFIED,
G_FILE_QUERY_INFO_NONE,
G_PRIORITY_DEFAULT,
g_task_get_cancellable (task),
diff --git a/libide/ide-buffer.c b/libide/ide-buffer.c
index d359be5..8e46aa6 100644
--- a/libide/ide-buffer.c
+++ b/libide/ide-buffer.c
@@ -1452,9 +1452,9 @@ ide_buffer_get_read_only (IdeBuffer *self)
return priv->read_only;
}
-static void
-ide_buffer_set_read_only (IdeBuffer *self,
- gboolean read_only)
+void
+_ide_buffer_set_read_only (IdeBuffer *self,
+ gboolean read_only)
{
IdeBufferPrivate *priv = ide_buffer_get_instance_private (self);
@@ -1529,7 +1529,7 @@ ide_buffer__check_for_volume_cb (GObject *object,
read_only = !g_file_info_get_attribute_boolean (file_info,
G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE);
- ide_buffer_set_read_only (self, read_only);
+ _ide_buffer_set_read_only (self, read_only);
}
if (g_file_info_has_attribute (file_info, G_FILE_ATTRIBUTE_TIME_MODIFIED) && priv->mtime_set)
diff --git a/libide/ide-internal.h b/libide/ide-internal.h
index 6d91878..201d8a4 100644
--- a/libide/ide-internal.h
+++ b/libide/ide-internal.h
@@ -55,6 +55,8 @@ void _ide_buffer_set_loading (IdeBuffer *s
gboolean loading);
void _ide_buffer_set_mtime (IdeBuffer *self,
const GTimeVal *mtime);
+void _ide_buffer_set_read_only (IdeBuffer *buffer,
+ gboolean read_only);
void _ide_build_system_set_project_file (IdeBuildSystem *self,
GFile *project_file);
void _ide_diagnostic_add_range (IdeDiagnostic *self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]