[gnome-builder] editor: allow multiple file selection



commit 45e7422546536ac14f16b99fdf40743c2905c8e7
Author: Christian Hergert <chergert redhat com>
Date:   Fri Jun 30 01:08:44 2017 -0700

    editor: allow multiple file selection

 libide/editor/ide-editor-perspective-actions.c |   30 +++++++++++++----------
 1 files changed, 17 insertions(+), 13 deletions(-)
---
diff --git a/libide/editor/ide-editor-perspective-actions.c b/libide/editor/ide-editor-perspective-actions.c
index 969ee8e..91d55f7 100644
--- a/libide/editor/ide-editor-perspective-actions.c
+++ b/libide/editor/ide-editor-perspective-actions.c
@@ -73,24 +73,28 @@ ide_editor_perspective_actions_open_file (GSimpleAction *action,
                                          _("Open"),
                                          _("Cancel"));
   gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (chooser), FALSE);
+  gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (chooser), TRUE);
 
   ret = gtk_native_dialog_run (GTK_NATIVE_DIALOG (chooser));
 
   if (ret == GTK_RESPONSE_ACCEPT)
     {
-      g_autoptr(GFile) file = NULL;
-
-      file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (chooser));
-
-      if (file != NULL)
-        {
-          ide_workbench_open_files_async (workbench,
-                                          &file,
-                                          1,
-                                          "editor",
-                                          IDE_WORKBENCH_OPEN_FLAGS_NONE,
-                                          NULL, NULL, NULL);
-        }
+      g_autoptr(GPtrArray) ar = NULL;
+      GSList *files;
+
+      ar = g_ptr_array_new_with_free_func (g_object_unref);
+      files = gtk_file_chooser_get_files (GTK_FILE_CHOOSER (chooser));
+      for (const GSList *iter = files; iter; iter = iter->next)
+        g_ptr_array_add (ar, iter->data);
+      g_slist_free (files);
+
+      if (ar->len > 0)
+        ide_workbench_open_files_async (workbench,
+                                        (GFile **)ar->pdata,
+                                        ar->len,
+                                        "editor",
+                                        IDE_WORKBENCH_OPEN_FLAGS_NONE,
+                                        NULL, NULL, NULL);
     }
 
   gtk_native_dialog_destroy (GTK_NATIVE_DIALOG (chooser));


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