[gnome-builder/wip/project-selector: 33/66] app: prefer already open project to creating new one



commit 240a0737433da27bee7938288d0347789c1b26a8
Author: Christian Hergert <christian hergert me>
Date:   Thu Apr 2 20:47:46 2015 -0700

    app: prefer already open project to creating new one

 src/app/gb-application.c |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/src/app/gb-application.c b/src/app/gb-application.c
index 67328fe..442b512 100644
--- a/src/app/gb-application.c
+++ b/src/app/gb-application.c
@@ -409,10 +409,37 @@ gb_application_open_project (GbApplication *self,
   g_autoptr(GFile) directory = NULL;
   g_autoptr(GTask) task = NULL;
   g_autoptr(GPtrArray) ar = NULL;
+  GList *windows;
+  GList *iter;
 
   g_return_if_fail (GB_IS_APPLICATION (self));
   g_return_if_fail (G_IS_FILE (file));
 
+  windows = gtk_application_get_windows (GTK_APPLICATION (self));
+
+  for (iter = windows; iter; iter = iter->next)
+    {
+      if (GB_IS_WORKBENCH (iter->data))
+        {
+          IdeContext *context;
+
+          context = gb_workbench_get_context (iter->data);
+
+          if (context != NULL)
+            {
+              GFile *project_file;
+
+              project_file = ide_context_get_project_file (context);
+
+              if (g_file_equal (file, project_file))
+                {
+                  gtk_window_present (iter->data);
+                  return;
+                }
+            }
+        }
+    }
+
   task = g_task_new (self, NULL, NULL, NULL);
 
   if (additional_files)


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