[gnome-builder/wip/chergert/headerbar] omnibar: get relative path to project



commit 0c9b0dc05bb4124f367cb22c2b431ba053f1639a
Author: Christian Hergert <chergert redhat com>
Date:   Thu Jun 23 15:00:50 2016 -0700

    omnibar: get relative path to project
    
    But also handle non-native (remote) file-systems and absolute paths when
    necessary.

 libide/workbench/ide-omni-bar.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/libide/workbench/ide-omni-bar.c b/libide/workbench/ide-omni-bar.c
index 240b6ce..0a9bcb1 100644
--- a/libide/workbench/ide-omni-bar.c
+++ b/libide/workbench/ide-omni-bar.c
@@ -132,15 +132,22 @@ ide_omni_bar_context_set (GtkWidget  *widget,
     {
       IdeConfigurationManager *configs;
       g_autofree gchar *path = NULL;
+      g_autoptr(GFile) home = NULL;
       GFile *workdir;
       IdeVcs *vcs;
 
       configs = ide_context_get_configuration_manager (context);
       vcs = ide_context_get_vcs (context);
       workdir = ide_vcs_get_working_directory (vcs);
+      home = g_file_new_for_path (g_get_home_dir ());
+
+      if (g_file_has_prefix (workdir, home))
+        path = g_file_get_relative_path (home, workdir);
+      else if (g_file_is_native (workdir))
+        path = g_file_get_path (workdir);
+      else
+        path = g_file_get_uri (workdir);
 
-      /* TODO: Convert to relative path (or remote uri) */
-      path = g_file_get_path (workdir);
       gtk_label_set_label (self->popover_project_label, path);
 
       g_signal_connect_object (vcs,


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