[gnome-builder/wip/gtk4-port] libide/vcs: add property to denote when branch model is busy



commit 33ee119e4a7b72dca17f49f55c6a929dd2a8557e
Author: Christian Hergert <chergert redhat com>
Date:   Tue May 31 16:48:53 2022 -0700

    libide/vcs: add property to denote when branch model is busy

 src/libide/vcs/ide-vcs-clone-request.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/src/libide/vcs/ide-vcs-clone-request.c b/src/libide/vcs/ide-vcs-clone-request.c
index 558ebe767..a71741b38 100644
--- a/src/libide/vcs/ide-vcs-clone-request.c
+++ b/src/libide/vcs/ide-vcs-clone-request.c
@@ -43,6 +43,8 @@ struct _IdeVcsCloneRequest
   char         *branch_name;
   char         *module_name;
   char         *uri;
+
+  guint         fetching_branches;
 };
 
 enum {
@@ -51,6 +53,7 @@ enum {
   PROP_AUTHOR_NAME,
   PROP_CAN_SELECT_BRANCH,
   PROP_BRANCH_MODEL,
+  PROP_BRANCH_MODEL_BUSY,
   PROP_BRANCH_NAME,
   PROP_DIRECTORY,
   PROP_MODULE_NAME,
@@ -136,6 +139,10 @@ ide_vcs_clone_request_get_property (GObject    *object,
       g_value_set_object (value, ide_vcs_clone_request_get_branch_model (self));
       break;
 
+    case PROP_BRANCH_MODEL_BUSY:
+      g_value_set_boolean (value, self->fetching_branches);
+      break;
+
     case PROP_BRANCH_NAME:
       g_value_set_string (value, ide_vcs_clone_request_get_branch_name (self));
       break;
@@ -236,14 +243,18 @@ ide_vcs_clone_request_class_init (IdeVcsCloneRequestClass *klass)
     g_param_spec_object ("branch-model", NULL, NULL, G_TYPE_LIST_MODEL,
                          (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
 
-  properties [PROP_CAN_SELECT_BRANCH] =
-    g_param_spec_boolean ("can-select-branch", NULL, NULL, FALSE,
+  properties [PROP_BRANCH_MODEL_BUSY] =
+    g_param_spec_boolean ("branch-model-busy", NULL, NULL, FALSE,
                           (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
 
   properties [PROP_BRANCH_NAME] =
     g_param_spec_string ("branch-name", NULL, NULL, NULL,
                          (G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
 
+  properties [PROP_CAN_SELECT_BRANCH] =
+    g_param_spec_boolean ("can-select-branch", NULL, NULL, FALSE,
+                          (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
   properties [PROP_DIRECTORY] =
     g_param_spec_object ("directory", NULL, NULL, G_TYPE_FILE,
                          (G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
@@ -466,6 +477,9 @@ ide_vcs_clone_request_populate_branches_cb (GObject *object,
   if (g_set_object (&self->branch_model, branches))
     g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_BRANCH_MODEL]);
 
+  self->fetching_branches--;
+  g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_BRANCH_MODEL_BUSY]);
+
   IDE_EXIT;
 }
 
@@ -498,11 +512,15 @@ ide_vcs_clone_request_populate_branches (IdeVcsCloneRequest *self)
   g_clear_object (&self->cancellable);
   self->cancellable = g_cancellable_new ();
 
+  self->fetching_branches++;
+
   ide_vcs_cloner_list_branches_async (self->cloner,
                                       uri,
                                       self->cancellable,
                                       ide_vcs_clone_request_populate_branches_cb,
                                       g_object_ref (self));
 
+  g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_BRANCH_MODEL_BUSY]);
+
   IDE_EXIT;
 }


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