[gnome-builder] ls: open parent directory upon "Open With" with file



commit 4cf9861e9875c92756990b57c7b98332e802742d
Author: Christian Hergert <chergert redhat com>
Date:   Mon May 6 09:19:07 2019 -0700

    ls: open parent directory upon "Open With" with file

 src/plugins/ls/gbp-ls-workbench-addin.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/src/plugins/ls/gbp-ls-workbench-addin.c b/src/plugins/ls/gbp-ls-workbench-addin.c
index c25fbf849..50bb478d0 100644
--- a/src/plugins/ls/gbp-ls-workbench-addin.c
+++ b/src/plugins/ls/gbp-ls-workbench-addin.c
@@ -52,7 +52,9 @@ gbp_ls_workbench_addin_can_open (IdeWorkbenchAddin *addin,
       return TRUE;
     }
 
-  return FALSE;
+  /* We can open, but super low priority */
+  *priority = G_MAXINT;
+  return TRUE;
 }
 
 static void
@@ -87,6 +89,7 @@ gbp_ls_workbench_addin_open_async (IdeWorkbenchAddin     *addin,
 {
   GbpLsWorkbenchAddin *self = (GbpLsWorkbenchAddin *)addin;
   g_autoptr(IdeTask) task = NULL;
+  g_autoptr(GFile) parent = NULL;
   IdeWorkspace *workspace;
   IdeSurface *surface;
   GtkWidget *current_frame;
@@ -106,6 +109,10 @@ gbp_ls_workbench_addin_open_async (IdeWorkbenchAddin     *addin,
   if (!(surface = ide_workspace_get_surface_by_name (workspace, "editor")))
     surface = ide_workspace_get_surface_by_name (workspace, "terminal");
 
+  /* If this isn't a directory, get the parent */
+  if (!g_str_equal (content_type, "inode/directory"))
+    file = parent = g_file_get_parent (file);
+
   /* First try to find an existing view for the file */
   locate.file = file;
   ide_workbench_foreach_page (self->workbench, locate_view, &locate);


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