[gnome-text-editor] buffermonitor: disable during failures



commit a6de9d43f86840fac2b68059ea664d65071c1f05
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jan 10 17:26:01 2022 -0800

    buffermonitor: disable during failures

 src/editor-buffer-monitor-private.h |  2 ++
 src/editor-buffer-monitor.c         | 22 +++++++++++++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)
---
diff --git a/src/editor-buffer-monitor-private.h b/src/editor-buffer-monitor-private.h
index 6c7b193..239c26c 100644
--- a/src/editor-buffer-monitor-private.h
+++ b/src/editor-buffer-monitor-private.h
@@ -40,5 +40,7 @@ void                 editor_buffer_monitor_set_file    (EditorBufferMonitor *sel
 void                 editor_buffer_monitor_reset       (EditorBufferMonitor *self);
 void                 editor_buffer_monitor_pause       (EditorBufferMonitor *self);
 void                 editor_buffer_monitor_unpause     (EditorBufferMonitor *self);
+void                 editor_buffer_monitor_set_failed  (EditorBufferMonitor *self,
+                                                        gboolean             failed);
 
 G_END_DECLS
diff --git a/src/editor-buffer-monitor.c b/src/editor-buffer-monitor.c
index c0cf116..89391d1 100644
--- a/src/editor-buffer-monitor.c
+++ b/src/editor-buffer-monitor.c
@@ -33,6 +33,7 @@ struct _EditorBufferMonitor
   int pause_count;
   guint changed_source;
   guint changed : 1;
+  guint failed : 1;
 };
 
 G_DEFINE_TYPE (EditorBufferMonitor, editor_buffer_monitor, G_TYPE_OBJECT)
@@ -201,7 +202,7 @@ notify_timeout_cb (gpointer user_data)
 
   self->changed_source = 0;
 
-  if (!self->changed)
+  if (!self->changed && !self->failed)
     g_file_query_info_async (self->file,
                              G_FILE_ATTRIBUTE_ETAG_VALUE,
                              G_FILE_QUERY_INFO_NONE,
@@ -360,3 +361,22 @@ editor_buffer_monitor_set_etag (EditorBufferMonitor *self,
       g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_ETAG]);
     }
 }
+
+void
+editor_buffer_monitor_set_failed (EditorBufferMonitor *self,
+                                  gboolean             failed)
+{
+  g_return_if_fail (EDITOR_IS_BUFFER_MONITOR (self));
+
+  failed = !!failed;
+
+  if (failed == self->failed)
+    return;
+
+  self->failed = failed;
+
+  if (self->failed)
+    editor_buffer_monitor_pause (self);
+  else
+    editor_buffer_monitor_unpause (self);
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]