[gnome-builder] file: wait for settings to settle before completing



commit 62650983c57a64d6679eebdbb32f95b8965201cb
Author: Christian Hergert <christian hergert me>
Date:   Wed May 6 13:40:34 2015 -0700

    file: wait for settings to settle before completing
    
    I still want a way to access this synchronously, but to shim this into
    the old API, we might as well settle before returning.

 libide/ide-file.c |   35 ++++++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)
---
diff --git a/libide/ide-file.c b/libide/ide-file.c
index 00cbb54..3a70b19 100644
--- a/libide/ide-file.c
+++ b/libide/ide-file.c
@@ -280,6 +280,29 @@ ide_file_set_path (IdeFile     *self,
   self->path = g_strdup (path);
 }
 
+static void
+ide_file__file_settings_settled_cb (IdeFileSettings *file_settings,
+                                    GParamSpec      *pspec,
+                                    GTask           *task)
+{
+  IDE_ENTRY;
+
+  g_assert (IDE_IS_FILE_SETTINGS (file_settings));
+  g_assert (G_IS_TASK (task));
+
+  if (ide_file_settings_get_settled (file_settings))
+    {
+      g_signal_handlers_disconnect_by_func (file_settings,
+                                            G_CALLBACK (ide_file__file_settings_settled_cb),
+                                            task);
+      g_task_return_pointer (task, file_settings, g_object_unref);
+      g_object_unref (task);
+      IDE_EXIT;
+    }
+
+  IDE_EXIT;
+}
+
 void
 ide_file_load_settings_async (IdeFile              *self,
                               GCancellable         *cancellable,
@@ -297,7 +320,17 @@ ide_file_load_settings_async (IdeFile              *self,
   task = g_task_new (self, cancellable, callback, user_data);
 
   file_settings = ide_file_settings_new (self);
-  g_task_return_pointer (task, file_settings, g_object_unref);
+
+  if (ide_file_settings_get_settled (file_settings))
+    {
+      g_task_return_pointer (task, file_settings, g_object_unref);
+      IDE_EXIT;
+    }
+
+  g_signal_connect (file_settings,
+                    "notify::settled",
+                    G_CALLBACK (ide_file__file_settings_settled_cb),
+                    g_object_ref (task));
 
   IDE_EXIT;
 }


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