[gnome-builder/wip/gtk4-port: 1260/1774] plugins/vcsui: handle clone request from GNOME project




commit 680410580d2135d0b1b50908a89d9efdaeddc9d5
Author: Christian Hergert <chergert redhat com>
Date:   Tue May 31 23:49:20 2022 -0700

    plugins/vcsui: handle clone request from GNOME project

 src/libide/greeter/ide-greeter-workspace.c    | 34 +--------------------------
 src/plugins/vcsui/gbp-vcsui-workspace-addin.c | 30 +++++++++++++++++++++++
 2 files changed, 31 insertions(+), 33 deletions(-)
---
diff --git a/src/libide/greeter/ide-greeter-workspace.c b/src/libide/greeter/ide-greeter-workspace.c
index e1ae0245b..724bcf7e3 100644
--- a/src/libide/greeter/ide-greeter-workspace.c
+++ b/src/libide/greeter/ide-greeter-workspace.c
@@ -405,42 +405,10 @@ ide_greeter_workspace_real_open_project (IdeGreeterWorkspace *self,
         {
           g_autoptr(GFile) directory = g_file_new_for_path (checkout);
           ide_project_info_set_directory (project_info, directory);
+          IDE_RETURN (FALSE);
         }
     }
 
-  return FALSE;
-
-#if 0
-  /*
-   * to switch to the clone dialog. However, we can use the VCS Uri to
-   * determine what the check-out directory would be, and if so, we can
-   * just open that directory.
-   */
-  if (!ide_project_info_get_file (project_info) &&
-      !ide_project_info_get_directory (project_info) &&
-      (vcs_uri = ide_project_info_get_vcs_uri (project_info)))
-    {
-      g_autoptr(IdeVcsUri) uri = ide_vcs_uri_new (vcs_uri);
-      g_autofree gchar *suggested = NULL;
-      g_autofree gchar *checkout = NULL;
-
-      if (uri != NULL &&
-          (suggested = ide_vcs_uri_get_clone_name (uri)) &&
-          (checkout = g_build_filename (ide_get_projects_dir (), suggested, NULL)) &&
-          g_file_test (checkout, G_FILE_TEST_IS_DIR))
-        {
-          g_autoptr(GFile) directory = g_file_new_for_path (checkout);
-          ide_project_info_set_directory (project_info, directory);
-        }
-      else
-        {
-          ide_clone_page_set_uri (self->clone_page, vcs_uri);
-          ide_greeter_workspace_set_page_name (self, "clone");
-          return;
-        }
-    }
-#endif
-
   IDE_RETURN (FALSE);
 }
 
diff --git a/src/plugins/vcsui/gbp-vcsui-workspace-addin.c b/src/plugins/vcsui/gbp-vcsui-workspace-addin.c
index 318419841..c9930fe0a 100644
--- a/src/plugins/vcsui/gbp-vcsui-workspace-addin.c
+++ b/src/plugins/vcsui/gbp-vcsui-workspace-addin.c
@@ -42,6 +42,31 @@ struct _GbpVcsuiWorkspaceAddin
   IdeBindingGroup     *vcs_bindings;
 };
 
+static gboolean
+greeter_open_project_cb (GbpVcsuiWorkspaceAddin *self,
+                         IdeProjectInfo         *project_info,
+                         IdeGreeterWorkspace    *greeter)
+{
+  const char *vcs_uri;
+
+  IDE_ENTRY;
+
+  g_assert (GBP_IS_VCSUI_WORKSPACE_ADDIN (self));
+  g_assert (IDE_IS_PROJECT_INFO (project_info));
+  g_assert (IDE_IS_GREETER_WORKSPACE (greeter));
+
+  if (!ide_project_info_get_file (project_info) &&
+      !ide_project_info_get_directory (project_info) &&
+      (vcs_uri = ide_project_info_get_vcs_uri (project_info)))
+    {
+      gbp_vcsui_clone_page_set_uri (self->clone, vcs_uri);
+      ide_greeter_workspace_set_page_name (greeter, "clone");
+      IDE_RETURN (TRUE);
+    }
+
+  IDE_RETURN (FALSE);
+}
+
 static void
 gbp_vcsui_workspace_addin_load (IdeWorkspaceAddin *addin,
                                 IdeWorkspace      *workspace)
@@ -54,6 +79,11 @@ gbp_vcsui_workspace_addin_load (IdeWorkspaceAddin *addin,
 
   if (IDE_IS_GREETER_WORKSPACE (workspace))
     {
+      g_signal_connect_object (workspace,
+                               "open-project",
+                               G_CALLBACK (greeter_open_project_cb),
+                               self,
+                               G_CONNECT_AFTER | G_CONNECT_SWAPPED);
       self->clone = g_object_new (GBP_TYPE_VCSUI_CLONE_PAGE,
                                   NULL);
       ide_greeter_workspace_add_page (IDE_GREETER_WORKSPACE (workspace),


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