[gtk+/wip/csoriano/pathbar-prototype: 2/3] pathbar



commit 37dea13ee78c0a27faaad5ea50a7d28644b8a206
Author: Carlos Soriano <csoriano gnome org>
Date:   Sat Nov 21 22:53:40 2015 +0100

    pathbar

 gtk/gtkfilespathbar.c |   68 +---------
 gtk/gtkpathbar.c      |  383 ++++++++++++++++++++++---------------------------
 gtk/gtkpathbar.h      |   26 ++--
 gtk/ui/gtkpathbar.ui  |  102 ++++++--------
 tests/testpathbar.c   |  266 ++++++++++++++++------------------
 5 files changed, 354 insertions(+), 491 deletions(-)
---
diff --git a/gtk/gtkfilespathbar.c b/gtk/gtkfilespathbar.c
index c496127..e1de808 100644
--- a/gtk/gtkfilespathbar.c
+++ b/gtk/gtkfilespathbar.c
@@ -48,8 +48,6 @@ struct _GtkFilesPathBarPrivate
   GtkWidget *path_bar;
 
   GFile *file;
-  gboolean edit_mode_enabled;
-  GBinding *edit_mode_enabled_binding;
 };
 
 G_DEFINE_TYPE_WITH_PRIVATE (GtkFilesPathBar, gtk_files_path_bar, GTK_TYPE_BIN)
@@ -62,7 +60,6 @@ enum {
 enum {
   PROP_0,
   PROP_FILE,
-  PROP_EDIT_MODE_ENABLED,
   LAST_PROP
 };
 
@@ -103,7 +100,6 @@ gtk_files_path_bar_finalize (GObject *object)
   GtkFilesPathBarPrivate *priv = gtk_files_path_bar_get_instance_private (self);
 
   g_clear_object (&priv->file);
-  g_clear_object (&priv->edit_mode_enabled_binding);
 
   G_OBJECT_CLASS (gtk_files_path_bar_parent_class)->finalize (object);
 }
@@ -122,9 +118,6 @@ gtk_files_path_bar_get_property (GObject    *object,
     case PROP_FILE:
       g_value_set_object (value, priv->file);
       break;
-    case PROP_EDIT_MODE_ENABLED:
-      g_value_set_boolean (value, priv->edit_mode_enabled);
-      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -143,9 +136,6 @@ gtk_files_path_bar_set_property (GObject      *object,
     case PROP_FILE:
       gtk_files_path_bar_set_file (self, g_value_get_object (value));
       break;
-    case PROP_EDIT_MODE_ENABLED:
-      gtk_files_path_bar_set_edit_mode_enabled (self, g_value_get_boolean (value));
-      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -196,13 +186,6 @@ gtk_files_path_bar_class_init (GtkFilesPathBarClass *klass)
                                G_TYPE_FILE,
                                G_PARAM_READWRITE);
 
-  files_path_bar_properties[PROP_EDIT_MODE_ENABLED] =
-          g_param_spec_boolean ("edit-mode-enabled",
-                                P_("Edit mode enabled"),
-                                P_("Show an entry to edit the path in text mode"),
-                                FALSE,
-                                G_PARAM_READWRITE);
-
   g_object_class_install_properties (object_class, LAST_PROP, files_path_bar_properties);
 
   gtk_widget_class_set_css_name (widget_class, "files-path-bar");
@@ -216,15 +199,13 @@ gtk_files_path_bar_init (GtkFilesPathBar *self)
   g_type_ensure (GTK_TYPE_FILES_PATH_BAR);
 
   priv->path_bar = gtk_path_bar_new ();
+  gtk_path_bar_set_inverted (GTK_PATH_BAR (priv->path_bar), TRUE);
   gtk_widget_show (priv->path_bar);
   g_signal_connect (GTK_PATH_BAR (priv->path_bar), "populate-popup",
                     G_CALLBACK (on_path_bar_populate_popup), self);
   g_signal_connect (GTK_PATH_BAR (priv->path_bar), "notify::selected-path",
                     G_CALLBACK (on_path_bar_selected_path), self);
   gtk_container_add (GTK_CONTAINER (self), priv->path_bar);
-
-  priv->edit_mode_enabled = FALSE;
-  g_object_bind_property (self, "edit-mode-enabled", priv->path_bar, "edit-mode-enabled", 
G_BINDING_SYNC_CREATE);
 }
 
 /**
@@ -287,53 +268,6 @@ gtk_files_path_bar_set_file (GtkFilesPathBar *self,
   g_free (path);
 }
 
-/**
- * gtk_files_path_bar_get_edit_mode_enabled:
- * @files_path_bar: a #GtkFilesPathBar
- *
- * Returns %TRUE if the path bar is in edit mode.
- *
- * Since: 3.20
- */
-gboolean
-gtk_files_path_bar_get_edit_mode_enabled (GtkFilesPathBar *self)
-{
-  GtkFilesPathBarPrivate *priv ;
-
-  g_return_val_if_fail (GTK_IS_FILES_PATH_BAR (self), FALSE);
-
-  priv = gtk_files_path_bar_get_instance_private (GTK_FILES_PATH_BAR (self));
-
-  return priv->edit_mode_enabled;
-}
-
-/**
- * gtk_files_path_bar_set_edit_mode_enabled:
- * @files_path_bar: a #GtkFilesPathBar
- * @enable: %TRUE to enable the edit mode.
- *
- * Sets the files path bar in a text edit mode that allows to edit the path as text.
- *
- * Since: 3.20
- */
-void
-gtk_files_path_bar_set_edit_mode_enabled (GtkFilesPathBar *self,
-                                    gboolean    enable)
-{
-  GtkFilesPathBarPrivate *priv ;
-
-  g_return_if_fail (GTK_IS_FILES_PATH_BAR (self));
-
-  priv = gtk_files_path_bar_get_instance_private (GTK_FILES_PATH_BAR (self));
-
-  if (priv->edit_mode_enabled != enable)
-    {
-      priv->edit_mode_enabled = enable;
-
-      g_object_notify (G_OBJECT (self), "edit-mode-enabled");
-    }
-}
-
 GtkWidget *
 gtk_files_path_bar_new (void)
 {
diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c
index 5d2e77c..4c5b065 100644
--- a/gtk/gtkpathbar.c
+++ b/gtk/gtkpathbar.c
@@ -59,8 +59,6 @@
 
 struct _GtkPathBarPrivate
 {
-  GtkWidget *main_stack;
-  GtkWidget *edit_entry;
   GtkWidget *path_bar_containers_stack;
   GtkWidget *path_bar_container_1;
   GtkWidget *path_bar_container_2;
@@ -75,12 +73,11 @@ struct _GtkPathBarPrivate
   gchar *root_path;
 
   gchar *path;
+  gchar *display_path;
   gchar *selected_path;
-  gboolean hide_direction;
-  gboolean edit_mode_enabled;
+  gboolean inverted;
 
   gboolean selecting_path;
-  gboolean setting_path;
 };
 
 G_DEFINE_TYPE_WITH_PRIVATE (GtkPathBar, gtk_path_bar, GTK_TYPE_BIN)
@@ -94,8 +91,7 @@ enum {
   PROP_0,
   PROP_PATH,
   PROP_SELECTED_PATH,
-  PROP_HIDE_DIRECTION,
-  PROP_EDIT_MODE_ENABLED,
+  PROP_INVERTED,
   LAST_PROP
 };
 
@@ -245,6 +241,7 @@ create_path_chunk (GtkPathBar  *self,
                    GIcon       *icon,
                    gboolean     add_separator)
 {
+  GtkPathBarPrivate *priv = gtk_path_bar_get_instance_private (GTK_PATH_BAR (self));
   GtkWidget *button;
   GtkWidget *separator;
   GtkWidget *path_chunk;
@@ -258,7 +255,13 @@ create_path_chunk (GtkPathBar  *self,
 
   path_chunk = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
   button = gtk_toggle_button_new ();
-  if (label)
+
+  if (icon)
+    {
+      image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_MENU);
+      gtk_button_set_image (GTK_BUTTON (button), image);
+    }
+  else if (label)
     {
       button_label = gtk_label_new (label);
       gtk_label_set_ellipsize (GTK_LABEL (button_label), PANGO_ELLIPSIZE_MIDDLE);
@@ -268,11 +271,9 @@ create_path_chunk (GtkPathBar  *self,
                                  MIN (strlen (label), 10));
       gtk_container_add (GTK_CONTAINER (button), button_label);
     }
-
-  if (icon)
+  else
     {
-      image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_MENU);
-      gtk_button_set_image (GTK_BUTTON (button), image);
+      g_assert_not_reached ();
     }
 
   style = gtk_widget_get_style_context (button);
@@ -282,18 +283,24 @@ create_path_chunk (GtkPathBar  *self,
                             G_CALLBACK (on_path_chunk_button_release_event), path_chunk);
   if (add_separator)
     {
-      separator = gtk_label_new ("/");
-      gtk_widget_set_sensitive (separator, FALSE);
     }
 
-  if (direction == GTK_TEXT_DIR_LTR)
+  if (direction == GTK_TEXT_DIR_LTR || (direction == GTK_TEXT_DIR_RTL && priv->inverted))
     {
       gtk_container_add (GTK_CONTAINER (path_chunk), button);
       if (add_separator)
-        gtk_container_add (GTK_CONTAINER (path_chunk), separator);
+        {
+          separator = gtk_label_new ("/");
+          gtk_widget_set_sensitive (separator, FALSE);
+          gtk_container_add (GTK_CONTAINER (path_chunk), separator);
+        }
     } else {
       if (add_separator)
-        gtk_container_add (GTK_CONTAINER (path_chunk), separator);
+        {
+          separator = gtk_label_new ("/");
+          gtk_widget_set_sensitive (separator, FALSE);
+          gtk_container_add (GTK_CONTAINER (path_chunk), separator);
+        }
       gtk_container_add (GTK_CONTAINER (path_chunk), button);
     }
 
@@ -319,8 +326,22 @@ create_path_chunk (GtkPathBar  *self,
   return path_chunk;
 }
 
+static gchar**
+get_splitted_path (const gchar* path)
+{
+  gchar *path_no_first_slash;
+  gchar **splitted_path;
+
+  path_no_first_slash = g_utf8_substring (path, 1, strlen (path));
+  splitted_path = g_strsplit (path_no_first_slash, "/", -1);
+
+  g_free (path_no_first_slash);
+
+  return splitted_path;
+}
+
 static gboolean
-check_path_format (const gchar *path)
+validate_path (const gchar *path)
 {
   gchar ** splitted_path = NULL;
   gboolean valid = FALSE;
@@ -360,33 +381,62 @@ out:
   return valid;
 }
 
-static void
-on_entry_activate (GtkPathBar *self)
+static gboolean
+validate_root_path (const gchar *path,
+                    const gchar *root_path)
 {
-  GtkPathBarPrivate *priv = gtk_path_bar_get_instance_private (self);
-  const gchar *text;
+  return validate_path (root_path) &&
+         (g_str_has_prefix (path, root_path) || g_strcmp0 (path, root_path) == 0);
+}
 
-  gtk_path_bar_set_edit_mode_enabled (self, FALSE);
-  text = gtk_entry_get_text (GTK_ENTRY (priv->edit_entry));
-  if (check_path_format (text))
-    gtk_path_bar_set_path (self, text);
-  else
-    gtk_entry_set_text (GTK_ENTRY (priv->edit_entry), priv->path);
+static gboolean
+validate_display_path (const gchar *path,
+                       const gchar *display_path)
+{
+  gchar ** splitted_path = NULL;
+  gchar ** splitted_display_path = NULL;
+  gboolean same_length;
+
+  if (!validate_path (display_path))
+    return FALSE;
 
+  splitted_display_path = g_strsplit (display_path, "/", -1);
+  splitted_path = g_strsplit (path, "/", -1);
+  same_length = g_strv_length (splitted_path) == g_strv_length (splitted_display_path);
+
+  g_strfreev (splitted_path);
+  g_strfreev (splitted_display_path);
+
+  return same_length;
 }
 
-static gchar**
-get_splitted_path (const gchar* path)
+static gchar*
+get_display_name (GtkPathBar  *self,
+                  const gchar *path)
 {
-  gchar *path_no_first_slash;
+  GtkPathBarPrivate *priv = gtk_path_bar_get_instance_private (self);
   gchar **splitted_path;
+  gchar **splitted_current_path;
+  gchar **splitted_display_path;
+  gchar *name;
 
-  path_no_first_slash = g_utf8_substring (path, 1, strlen (path));
-  splitted_path = g_strsplit (path_no_first_slash, "/", -1);
+  splitted_path = get_splitted_path (path);
+  if (priv->display_path)
+    {
+      splitted_display_path = get_splitted_path (priv->display_path);
+      name = g_strdup (splitted_display_path[g_strv_length (splitted_path) - 1]);
+      g_strfreev (splitted_display_path);
+    }
+  else
+    {
+      splitted_current_path = get_splitted_path (priv->path);
+      name = g_strdup (splitted_current_path[g_strv_length (splitted_path) - 1]);
+      g_strfreev (splitted_current_path);
+    }
 
-  g_free (path_no_first_slash);
+   g_strfreev (splitted_path);
 
-  return splitted_path;
+  return name;
 }
 
 static void
@@ -399,6 +449,7 @@ update_path_bar (GtkPathBar  *self)
   GtkWidget *path_bar;
   GtkWidget *root_chunk;
   gchar *unprefixed_path;
+  gchar *label;
 
   get_path_bar_widgets (GTK_PATH_BAR (self), &path_bar, &overflow_button, &path_box, FALSE);
 
@@ -410,8 +461,11 @@ update_path_bar (GtkPathBar  *self)
 
   if (priv->root_path)
     {
-      root_chunk = create_path_chunk (self, priv->root_path, priv->root_label,
+      label = get_display_name (self, priv->root_path);
+      root_chunk = create_path_chunk (self, priv->root_path, label,
                                       priv->root_icon, TRUE);
+      g_free (label);
+
       gtk_container_add (GTK_CONTAINER (path_box), root_chunk);
       /* Remove root path */
       unprefixed_path = g_utf8_substring (priv->path, strlen (priv->root_path),
@@ -450,8 +504,10 @@ update_path_bar (GtkPathBar  *self)
                * However,if only one item is present, add a separator at the end since
                * is visually more pleasant. The result will be in the form of "Home/" */
               add_separator = length == 1 || i != length - 1;
+              label = get_display_name (self, current_path->str);
               path_chunk = create_path_chunk (self, current_path->str, splitted_path[i],
                                               NULL, add_separator);
+              g_free (label);
               gtk_container_add (GTK_CONTAINER (path_box), path_chunk);
             }
 
@@ -465,8 +521,6 @@ update_path_bar (GtkPathBar  *self)
       gtk_container_add (GTK_CONTAINER (path_box), path_chunk);
     }
 
-  gtk_entry_set_text (GTK_ENTRY (priv->edit_entry), priv->path);
-
   gtk_stack_set_visible_child (GTK_STACK (priv->path_bar_containers_stack), path_bar);
 
   g_free (unprefixed_path);
@@ -575,11 +629,8 @@ gtk_path_bar_get_property (GObject    *object,
     case PROP_SELECTED_PATH:
       g_value_set_string (value, priv->selected_path);
       break;
-    case PROP_HIDE_DIRECTION:
-      g_value_set_int (value, priv->hide_direction);
-      break;
-    case PROP_EDIT_MODE_ENABLED:
-      g_value_set_boolean (value, priv->edit_mode_enabled);
+    case PROP_INVERTED:
+      g_value_set_boolean (value, priv->inverted);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -602,11 +653,8 @@ gtk_path_bar_set_property (GObject      *object,
     case PROP_SELECTED_PATH:
       gtk_path_bar_set_selected_path (self, g_value_get_string (value));
       break;
-    case PROP_HIDE_DIRECTION:
-      gtk_path_bar_set_hide_direction (self, g_value_get_int (value));
-      break;
-    case PROP_EDIT_MODE_ENABLED:
-      gtk_path_bar_set_edit_mode_enabled (self, g_value_get_boolean (value));
+    case PROP_INVERTED:
+      gtk_path_bar_set_inverted (self, g_value_get_boolean (value));
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -673,17 +721,10 @@ gtk_path_bar_class_init (GtkPathBarClass *klass)
                                NULL,
                                G_PARAM_READWRITE);
 
-  path_bar_properties[PROP_HIDE_DIRECTION] =
-          g_param_spec_int ("hide-direction",
-                            P_("Hide direction"),
-                            P_("From where the path bar will start hiding widgets when there is not enough 
space"),
-                            0, G_MAXINT, 0,
-                            G_PARAM_READWRITE);
-
-  path_bar_properties[PROP_EDIT_MODE_ENABLED] =
-          g_param_spec_boolean ("edit-mode-enabled",
-                                P_("Edit mode enabled"),
-                                P_("Show an entry to edit the path in text mode"),
+  path_bar_properties[PROP_INVERTED] =
+          g_param_spec_boolean ("inverted",
+                                P_("Direction of hiding children inverted"),
+                                P_("If false the container will start hiding widgets from the end when there 
is not enough space, and the oposite in case inverted is true."),
                                 FALSE,
                                 G_PARAM_READWRITE);
 
@@ -691,8 +732,6 @@ gtk_path_bar_class_init (GtkPathBarClass *klass)
 
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/ui/gtkpathbar.ui");
 
-  gtk_widget_class_bind_template_child_private (widget_class, GtkPathBar, main_stack);
-  gtk_widget_class_bind_template_child_private (widget_class, GtkPathBar, edit_entry);
   gtk_widget_class_bind_template_child_private (widget_class, GtkPathBar, path_bar_containers_stack);
   gtk_widget_class_bind_template_child_private (widget_class, GtkPathBar, path_bar_container_1);
   gtk_widget_class_bind_template_child_private (widget_class, GtkPathBar, path_bar_container_2);
@@ -702,7 +741,6 @@ gtk_path_bar_class_init (GtkPathBarClass *klass)
   gtk_widget_class_bind_template_child_private (widget_class, GtkPathBar, path_box_2);
 
   gtk_widget_class_bind_template_callback (widget_class, populate_overflow_popover);
-  gtk_widget_class_bind_template_callback (widget_class, on_entry_activate);
 
   gtk_widget_class_set_css_name (widget_class, "path-bar");
 }
@@ -716,8 +754,63 @@ gtk_path_bar_init (GtkPathBar *self)
   gtk_widget_init_template (GTK_WIDGET (self));
 
   priv->selecting_path = FALSE;
-  priv->setting_path = FALSE;
-  priv->hide_direction = GTK_DIR_RIGHT;
+  priv->inverted = FALSE;
+}
+
+
+void
+gtk_path_bar_set_path_extended (GtkPathBar  *self,
+                                const gchar *path,
+                                const gchar *display_path,
+                                const gchar *root_path,
+                                GIcon       *root_icon)
+{
+  GtkPathBarPrivate *priv;
+  gchar *old_path;
+
+  g_return_if_fail (GTK_IS_PATH_BAR (self));
+  g_return_if_fail (validate_path (path));
+  g_return_if_fail (!root_path || validate_root_path (path, root_path));
+  g_return_if_fail (!display_path || validate_display_path (path, display_path));
+
+  priv = gtk_path_bar_get_instance_private (GTK_PATH_BAR (self));
+
+  if (priv->root_icon)
+    {
+      g_object_unref (priv->root_icon);
+      priv->root_icon = NULL;
+    }
+  if (priv->root_path)
+    {
+      g_free (priv->root_path);
+      priv->root_path = NULL;
+    }
+  if (priv->display_path)
+    {
+      g_free (priv->display_path);
+      priv->display_path = NULL;
+    }
+
+  if (root_icon)
+    priv->root_icon = g_object_ref (root_icon);
+  if (root_path)
+    priv->root_path = g_strdup (root_path);
+  if (display_path)
+    priv->display_path = g_strdup (display_path);
+
+  old_path = priv->path;
+  priv->path = g_strdup (path);
+
+  update_path_bar (self);
+
+  if (old_path)
+    {
+      if (g_strcmp0 (old_path, path) != 0)
+        g_object_notify_by_pspec (G_OBJECT (self), path_bar_properties[PROP_PATH]);
+      g_free (old_path);
+    }
+
+  gtk_path_bar_set_selected_path (self, priv->path);
 }
 
 /**
@@ -759,32 +852,7 @@ void
 gtk_path_bar_set_path (GtkPathBar  *self,
                        const gchar *path)
 {
-  GtkPathBarPrivate *priv;
-
-  g_return_if_fail (GTK_IS_PATH_BAR (self));
-  g_return_if_fail (check_path_format (path));
-
-  priv = gtk_path_bar_get_instance_private (GTK_PATH_BAR (self));
-
-  if (g_strcmp0 (priv->path, path) == 0)
-    return;
-
-  if (priv->path)
-    g_free (priv->path);
-  priv->path = g_strdup (path);
-
-  priv->setting_path = TRUE;
-
-  /* Remove root */
-  gtk_path_bar_set_root (self, NULL, NULL, NULL);
-
-  /* Notify before updating visually the path, in this way we allow clients to
-   * set a root withouth flashing the path bar */
-  g_object_notify_by_pspec (G_OBJECT (self), path_bar_properties[PROP_PATH]);
-  update_path_bar (self);
-  gtk_path_bar_set_selected_path (self, priv->path);
-
-  priv->setting_path = FALSE;
+  gtk_path_bar_set_path_extended (self, path, NULL, NULL, NULL);
 }
 
 /**
@@ -850,87 +918,38 @@ gtk_path_bar_set_selected_path (GtkPathBar  *self,
 }
 
 /**
- * gtk_path_bar_get_hide_direction:
- * @path_bar: a #GtkPathBar
- *
- * Returns a #GtkTextDirection indicating the direction the path bar hides
- * overflow children.
- *
- * Since: 3.20
- */
-GtkDirectionType
-gtk_path_bar_get_hide_direction (GtkPathBar *self)
-{
-  GtkPathBarPrivate *priv ;
-
-  g_return_val_if_fail (GTK_IS_PATH_BAR (self), 0);
-
-  priv = gtk_path_bar_get_instance_private (GTK_PATH_BAR (self));
-
-  return gtk_hiding_box_get_hide_direction (GTK_HIDING_BOX (priv->path_box_1));
-}
-
-/**
- * gtk_path_bar_set_hide_direction:
+ * gtk_path_bar_get_inverted:
  * @path_bar: a #GtkPathBar
- * @direction: the #GtkTextDirection to start hiding overflow children.
  *
- * Sets the direction from wheter the path bar starts hiding overflow children.
- *
- * Since: 3.20
- */
-void
-gtk_path_bar_set_hide_direction (GtkPathBar       *self,
-                                 GtkDirectionType  hide_direction)
-{
-  GtkPathBarPrivate *priv ;
-
-  g_return_if_fail (GTK_IS_PATH_BAR (self));
-  g_return_if_fail (hide_direction == GTK_DIR_LEFT || hide_direction == GTK_DIR_RIGHT);
-
-  priv = gtk_path_bar_get_instance_private (GTK_PATH_BAR (self));
-
-  if (gtk_hiding_box_get_hide_direction (GTK_HIDING_BOX (priv->path_box_1)) != hide_direction)
-    {
-      gtk_hiding_box_set_hide_direction (GTK_HIDING_BOX (priv->path_box_1), hide_direction);
-      gtk_hiding_box_set_hide_direction (GTK_HIDING_BOX (priv->path_box_2), hide_direction);
-
-      g_object_notify (G_OBJECT (self), "hide-direction");
-    }
-}
-
-/**
- * gtk_path_bar_get_edit_mode_enabled:
- * @path_bar: a #GtkPathBar
- *
- * Returns %TRUE if the path bar is in edit mode.
+ * Returns a wheter the path bar hides children in the inverted direction.
  *
  * Since: 3.20
  */
 gboolean
-gtk_path_bar_get_edit_mode_enabled (GtkPathBar *self)
+gtk_path_bar_get_inverted (GtkPathBar *self)
 {
   GtkPathBarPrivate *priv ;
 
-  g_return_val_if_fail (GTK_IS_PATH_BAR (self), FALSE);
+  g_return_val_if_fail (GTK_IS_PATH_BAR (self), 0);
 
   priv = gtk_path_bar_get_instance_private (GTK_PATH_BAR (self));
 
-  return priv->edit_mode_enabled;
+  return gtk_hiding_box_get_inverted (GTK_HIDING_BOX (priv->path_box_1));
 }
 
 /**
- * gtk_path_bar_set_edit_mode_enabled:
+ * gtk_path_bar_set_inverted:
  * @path_bar: a #GtkPathBar
- * @enable: %TRUE to enable the edit mode.
+ * @inverted: Wheter the path bar will start hiding widgets in the oposite direction.
  *
- * Sets the path bar in a text edit mode that allows to edit the path as text.
+ * If %FALSE, the path bar will start hiding widgets from the end of it, and from
+ * the start in the oposite case.
  *
  * Since: 3.20
  */
 void
-gtk_path_bar_set_edit_mode_enabled (GtkPathBar *self,
-                                    gboolean    enable)
+gtk_path_bar_set_inverted (GtkPathBar *self,
+                           gboolean    inverted)
 {
   GtkPathBarPrivate *priv ;
 
@@ -938,68 +957,12 @@ gtk_path_bar_set_edit_mode_enabled (GtkPathBar *self,
 
   priv = gtk_path_bar_get_instance_private (GTK_PATH_BAR (self));
 
-  if (priv->edit_mode_enabled != enable)
+  if (gtk_hiding_box_get_inverted (GTK_HIDING_BOX (priv->path_box_1)) != inverted)
     {
-      priv->edit_mode_enabled = enable;
-      if (enable)
-        gtk_stack_set_visible_child (GTK_STACK (priv->main_stack), priv->edit_entry);
-      else
-        gtk_stack_set_visible_child (GTK_STACK (priv->main_stack), priv->path_bar_containers_stack);
-
-      g_object_notify (G_OBJECT (self), "edit-mode-enabled");
-    }
-}
-
-void
-gtk_path_bar_set_root (GtkPathBar  *self,
-                       GIcon       *icon,
-                       const gchar *label,
-                       const gchar *path)
-{
-  GtkPathBarPrivate *priv ;
-
-  g_return_if_fail (GTK_IS_PATH_BAR (self));
-  priv = gtk_path_bar_get_instance_private (GTK_PATH_BAR (self));
-
-  if (path)
-    {
-      g_return_if_fail (g_str_has_prefix (priv->path, path) ||
-                        g_strcmp0 (priv->path, path) == 0);
-      g_return_if_fail (label || icon);
-
-    }
+      gtk_hiding_box_set_inverted (GTK_HIDING_BOX (priv->path_box_1), inverted);
+      gtk_hiding_box_set_inverted (GTK_HIDING_BOX (priv->path_box_2), inverted);
 
-  if (priv->root_icon)
-    {
-      g_object_unref (priv->root_icon);
-      priv->root_icon = NULL;
-    }
-
-  if (priv->root_label)
-    {
-      g_free (priv->root_label);
-      priv->root_label = NULL;
-    }
-
-  if (priv->root_path)
-    {
-      g_free (priv->root_path);
-      priv->root_path = NULL;
-    }
-
-  if (icon)
-    priv->root_icon = g_object_ref (icon);
-
-  if (label)
-    priv->root_label = g_strdup (label);
-
-  if (path)
-    priv->root_path = g_strdup (path);
-
-  if (!priv->setting_path)
-    {
-      update_path_bar (self);
-      update_selected_path (self);
+      g_object_notify (G_OBJECT (self), "inverted");
     }
 }
 
diff --git a/gtk/gtkpathbar.h b/gtk/gtkpathbar.h
index 4ecd293..67f00eb 100644
--- a/gtk/gtkpathbar.h
+++ b/gtk/gtkpathbar.h
@@ -70,29 +70,23 @@ GDK_AVAILABLE_IN_3_20
 const gchar*          gtk_path_bar_get_path              (GtkPathBar       *path_bar);
 
 GDK_AVAILABLE_IN_3_20
+void                  gtk_path_bar_set_path_extended     (GtkPathBar       *self,
+                                                          const gchar      *path,
+                                                          const gchar      *display_path,
+                                                          const gchar      *root_path,
+                                                          GIcon            *root_icon);
+
+GDK_AVAILABLE_IN_3_20
 void                  gtk_path_bar_set_selected_path     (GtkPathBar       *path_bar,
                                                           const gchar      *path);
 GDK_AVAILABLE_IN_3_20
 const gchar*          gtk_path_bar_get_selected_path     (GtkPathBar       *path_bar);
 
 GDK_AVAILABLE_IN_3_20
-void                  gtk_path_bar_set_hide_direction    (GtkPathBar       *path_bar,
-                                                          GtkDirectionType  hide_direction);
+void                  gtk_path_bar_set_inverted          (GtkPathBar       *path_bar,
+                                                          gboolean          inverted);
 GDK_AVAILABLE_IN_3_20
-GtkDirectionType      gtk_path_bar_get_hide_direction    (GtkPathBar       *path_bar);
-
-GDK_AVAILABLE_IN_3_20
-gboolean              gtk_path_bar_get_edit_mode_enabled (GtkPathBar       *path_bar);
-
-GDK_AVAILABLE_IN_3_20
-void                  gtk_path_bar_set_edit_mode_enabled (GtkPathBar       *path_bar,
-                                                          gboolean          enable);
-
-GDK_AVAILABLE_IN_3_20
-void                  gtk_path_bar_set_root              (GtkPathBar       *self,
-                                                          GIcon            *icon,
-                                                          const gchar      *label,
-                                                          const gchar      *path);
+gboolean              gtk_path_bar_get_inverted          (GtkPathBar       *path_bar);
 
 G_END_DECLS
 
diff --git a/gtk/ui/gtkpathbar.ui b/gtk/ui/gtkpathbar.ui
index bfd682b..2ff77bc 100644
--- a/gtk/ui/gtkpathbar.ui
+++ b/gtk/ui/gtkpathbar.ui
@@ -26,83 +26,69 @@
   </object>
   <template class="GtkPathBar" parent="GtkBin">
     <child>
-      <object class="GtkStack" id="main_stack">
+      <object class="GtkStack" id="path_bar_containers_stack">
         <property name="visible">true</property>
-        <property name="visible-child">path_bar_containers_stack</property>
+        <property name="valign">GTK_ALIGN_START</property>
+        <property name="vexpand">false</property>
         <property name="transition-type">GTK_STACK_TRANSITION_TYPE_CROSSFADE</property>
+        <property name="transition-duration">150</property>
         <child>
-          <object class="GtkEntry" id="edit_entry">
+          <object class="GtkPathBarContainer" id="path_bar_container_1">
             <property name="visible">true</property>
-            <property name="hexpand">true</property>
-            <signal name="activate" handler="on_entry_activate" object="GtkPathBar" swapped="yes"/>
+            <child internal-child="overflow_button">
+              <object class="GtkMenuButton" id="overflow_button_1">
+                <property name="visible">true</property>
+                <property name="popover">overflow_popover_1</property>
+                <signal name="clicked" handler="populate_overflow_popover" object="GtkPathBar" 
swapped="yes"/>
+                <child>
+                  <object class="GtkImage">
+                    <property name="visible">true</property>
+                    <property name="icon_name">image-loading-symbolic</property>
+                    <property name="icon_size">1</property>
+                  </object>
+                </child>
+                <style>
+                  <class name="flat"/>
+                </style>
+              </object>
+            </child>
+            <child internal-child="path_box">
+              <object class="GtkHidingBox" id="path_box_1">
+                <property name="visible">true</property>
+              </object>
+            </child>
           </object>
         </child>
         <child>
-          <object class="GtkStack" id="path_bar_containers_stack">
+          <object class="GtkPathBarContainer" id="path_bar_container_2">
             <property name="visible">true</property>
-            <property name="valign">GTK_ALIGN_START</property>
-            <property name="vexpand">false</property>
-            <property name="transition-type">GTK_STACK_TRANSITION_TYPE_CROSSFADE</property>
-            <property name="transition-duration">150</property>
-            <child>
-              <object class="GtkPathBarContainer" id="path_bar_container_1">
+            <child internal-child="overflow_button">
+              <object class="GtkMenuButton" id="overflow_button_2">
                 <property name="visible">true</property>
-                <child internal-child="overflow_button">
-                  <object class="GtkMenuButton" id="overflow_button_1">
-                    <property name="visible">true</property>
-                    <property name="popover">overflow_popover_1</property>
-                    <signal name="clicked" handler="populate_overflow_popover" object="GtkPathBar" 
swapped="yes"/>
-                    <child>
-                      <object class="GtkImage">
-                        <property name="visible">true</property>
-                        <property name="icon_name">image-loading-symbolic</property>
-                        <property name="icon_size">1</property>
-                      </object>
-                    </child>
-                    <style>
-                      <class name="flat"/>
-                    </style>
-                  </object>
-                </child>
-                <child internal-child="path_box">
-                  <object class="GtkHidingBox" id="path_box_1">
+                <property name="popover">overflow_popover_2</property>
+                <signal name="clicked" handler="populate_overflow_popover" object="GtkPathBar" 
swapped="yes"/>
+                <child>
+                  <object class="GtkImage">
                     <property name="visible">true</property>
+                    <property name="icon_name">image-loading-symbolic</property>
+                    <property name="icon_size">1</property>
                   </object>
                 </child>
+                <style>
+                  <class name="flat"/>
+                </style>
               </object>
             </child>
-            <child>
-              <object class="GtkPathBarContainer" id="path_bar_container_2">
+            <child internal-child="path_box">
+              <object class="GtkHidingBox" id="path_box_2">
                 <property name="visible">true</property>
-                <child internal-child="overflow_button">
-                  <object class="GtkMenuButton" id="overflow_button_2">
-                    <property name="visible">true</property>
-                    <property name="popover">overflow_popover_2</property>
-                    <signal name="clicked" handler="populate_overflow_popover" object="GtkPathBar" 
swapped="yes"/>
-                    <child>
-                      <object class="GtkImage">
-                        <property name="visible">true</property>
-                        <property name="icon_name">image-loading-symbolic</property>
-                        <property name="icon_size">1</property>
-                      </object>
-                    </child>
-                    <style>
-                      <class name="flat"/>
-                    </style>
-                  </object>
-                </child>
-                <child internal-child="path_box">
-                  <object class="GtkHidingBox" id="path_box_2">
-                    <property name="visible">true</property>
-                  </object>
-                </child>
               </object>
             </child>
-            <style>
-              <class name="path-bar"/>
-            </style>
           </object>
         </child>
+        <style>
+          <class name="path-bar"/>
+        </style>
       </object>
     </child>
   </template>
diff --git a/tests/testpathbar.c b/tests/testpathbar.c
index 761f725..8bdb2ee 100644
--- a/tests/testpathbar.c
+++ b/tests/testpathbar.c
@@ -3,10 +3,15 @@
 #include <gtk/gtk.h>
 
 static GActionGroup *action_group;
-static GList *path_bars = NULL;
-static GList *files_path_bars = NULL;
+static GtkWidget *path_bar;
+static GtkWidget *path_bar_inverted;
+static GtkWidget *path_bar_slash;
+static GtkWidget *path_bar_custom_root_label;
+static GtkWidget *path_bar_custom_root_icon;
+static GtkWidget *files_path_bar;
 static const gchar* ORIGINAL_PATH = "/test/test 2/test 3/asda lkasdl/pppppppppppppppp/ alskd";
 static const gchar* ROOT_PATH = "/test/test 2/test 3";
+static const gchar* DISPLAY_PATH = "/test/test 2/This Is A Root/asda lkasdl/pppppppppppppppp/ alskd";
 
 static void
 action_menu_1 (GSimpleAction *action,
@@ -79,94 +84,139 @@ on_path_selected (GtkPathBar *path_bar,
   g_print ("Path selected: %s\n", gtk_path_bar_get_selected_path (path_bar));
 }
 
+static gchar*
+get_display_path_from_selected (const gchar *selected_path)
+{
+  gchar **splitted_path;
+  gchar **display_splitted_path;
+  gint i;
+  GString *display_path;
+  gchar *display_path_gchar;
+
+  splitted_path = g_strsplit (selected_path, "/", -1);
+  display_splitted_path = g_strsplit (DISPLAY_PATH, "/", -1);
+  display_path = g_string_new ("");
+  /* Skip the first empty split part */
+  for (i = 1; i < g_strv_length (splitted_path); i++)
+    {
+      g_string_append (display_path, "/");
+      g_string_append (display_path, display_splitted_path[i]);
+    }
+
+  display_path_gchar = display_path->str;
+
+  g_string_free (display_path, FALSE);
+  g_strfreev (splitted_path);
+  g_strfreev (display_splitted_path);
+
+  return display_path_gchar;
+}
+
 static void
 on_path_selected_set_path (GtkPathBar *path_bar,
                            GParamSpec *pspec,
                            gpointer   *user_data)
 {
   gchar *selected_path;
+  gchar *new_display_path;
 
   selected_path = g_strdup (gtk_path_bar_get_selected_path (path_bar));
-  g_print ("Path selected: %s, setting path to GtkPathBar\n", selected_path);
-  gtk_path_bar_set_path (path_bar, selected_path);
-  g_free (selected_path);
-}
-
-static void
-on_path_changed_set_root (GtkPathBar *path_bar,
-                          GParamSpec *pspec,
-                          gpointer   *user_data)
-{
-  gchar *new_path;
-
-  new_path = g_strdup (gtk_path_bar_get_path (path_bar));
-  if (g_str_has_prefix (new_path, ROOT_PATH))
+  new_display_path = get_display_path_from_selected (selected_path);
+  g_print ("Path selected: %s, setting path to GtkPathBar and new display path %s\n", selected_path, 
new_display_path);
+  if (path_bar == GTK_PATH_BAR (path_bar_custom_root_label))
     {
-      g_print ("Path changed: %s, setting root\n", new_path);
-      gtk_path_bar_set_root (path_bar, NULL, "NewRoot", ROOT_PATH);
+      gtk_path_bar_set_path_extended (GTK_PATH_BAR (path_bar_custom_root_label),
+                                      selected_path, new_display_path, ROOT_PATH, NULL);
     }
-  else if (g_strcmp0 (new_path, "/") == 0)
+  else if (path_bar == GTK_PATH_BAR (path_bar_custom_root_icon))
     {
-      g_print ("Path changed: %s, setting root to “/” \n", new_path);
-      gtk_path_bar_set_root (path_bar, NULL, "TopRoot", "/");
+      GIcon *icon;
+
+      icon = g_themed_icon_new ("drive-harddisk");
+      gtk_path_bar_set_path_extended (GTK_PATH_BAR (path_bar_custom_root_icon),
+                                      selected_path, new_display_path, ROOT_PATH, icon);
+      g_object_unref (icon);
     }
+  else
+    {
+      gtk_path_bar_set_path (path_bar, selected_path);
+    }
+
+  g_free (selected_path);
+  g_free (new_display_path);
 }
 
 static void
-on_reset_button_clicked (GtkButton *reset_button)
+on_file_changed (GtkFilesPathBar *path_bar,
+                 GParamSpec      *pspec,
+                 gpointer        *user_data)
 {
-  GList *l;
   GFile *file;
+  gchar *uri;
 
-  file = g_file_new_for_path (ORIGINAL_PATH);
-
-  for (l = files_path_bars; l != NULL; l = l->next)
-    gtk_files_path_bar_set_file (l->data, file);
+  file = gtk_files_path_bar_get_file (path_bar);
+  uri = g_file_get_uri (file);
+  g_print ("File selected: %s in GtkFilesPathBar\n", uri);
+  g_free (uri);
+}
 
-  for (l = path_bars; l != NULL; l = l->next)
-    gtk_path_bar_set_path (l->data, ORIGINAL_PATH);
 
-  g_object_unref (file);
+static void
+connect_path_bar (GtkPathBar *path_bar)
+{
+  g_signal_connect (GTK_PATH_BAR (path_bar), "populate-popup",
+                    G_CALLBACK (on_populate_popup), NULL);
+  g_signal_connect (GTK_PATH_BAR (path_bar), "notify::selected-path",
+                    G_CALLBACK (on_path_selected), NULL);
 }
 
 static void
-on_path_bar_edit_mode_button_clicked (GtkButton  *reset_button,
-                                      GtkPathBar *path_bar)
+connect_path_bar_set_path (GtkPathBar *path_bar)
 {
-  gtk_path_bar_set_edit_mode_enabled (path_bar,
-                                      !gtk_path_bar_get_edit_mode_enabled (path_bar));
+  g_signal_connect (GTK_PATH_BAR (path_bar), "populate-popup",
+                    G_CALLBACK (on_populate_popup), NULL);
+  g_signal_connect (GTK_PATH_BAR (path_bar), "notify::selected-path",
+                    G_CALLBACK (on_path_selected_set_path), NULL);
 }
 
 static void
-on_files_path_bar_edit_mode_button_clicked (GtkButton  *reset_button,
-                                            GtkFilesPathBar *path_bar)
+connect_files_path_bar (GtkFilesPathBar *files_path_bar)
 {
-  gtk_files_path_bar_set_edit_mode_enabled (path_bar,
-                                            !gtk_files_path_bar_get_edit_mode_enabled (path_bar));
+  g_signal_connect (GTK_FILES_PATH_BAR (files_path_bar), "populate-popup",
+                    G_CALLBACK (on_populate_popup), NULL);
+  g_signal_connect (GTK_FILES_PATH_BAR (files_path_bar), "notify::file",
+                    G_CALLBACK (on_file_changed), NULL);
 }
 
 static void
-on_file_changed (GtkFilesPathBar *path_bar,
-                 GParamSpec      *pspec,
-                 gpointer        *user_data)
+on_reset_button_clicked (GtkButton *reset_button)
 {
   GFile *file;
-  gchar *uri;
+  GIcon *icon;
 
-  file = gtk_files_path_bar_get_file (path_bar);
-  uri = g_file_get_uri (file);
-  g_print ("File selected: %s in GtkFilesPathBar\n", uri);
-  g_free (uri);
+  file = g_file_new_for_path (ORIGINAL_PATH);
+  icon = g_themed_icon_new ("drive-harddisk");
+
+  gtk_path_bar_set_path (GTK_PATH_BAR (path_bar), ORIGINAL_PATH);
+  gtk_path_bar_set_path (GTK_PATH_BAR (path_bar_inverted), ORIGINAL_PATH);
+  gtk_path_bar_set_path (GTK_PATH_BAR (path_bar_slash), "/");
+  gtk_path_bar_set_path_extended (GTK_PATH_BAR (path_bar_custom_root_label),
+                                  ORIGINAL_PATH, DISPLAY_PATH, ROOT_PATH, NULL);
+  gtk_path_bar_set_path_extended (GTK_PATH_BAR (path_bar_custom_root_icon),
+                                  ORIGINAL_PATH, DISPLAY_PATH, ROOT_PATH, icon);
+  gtk_files_path_bar_set_file (GTK_FILES_PATH_BAR (files_path_bar), file);
+
+
+  g_object_unref (icon);
+  g_object_unref (file);
 }
 
 int
 main (int argc, char *argv[])
 {
   GtkWidget *window;
-  GtkWidget *path_bar;
   GtkWidget *grid;
   GtkWidget *reset_button;
-  GtkWidget *edit_mode_button;
   GtkWidget *label;
   GFile *file;
   GIcon *icon;
@@ -198,120 +248,56 @@ main (int argc, char *argv[])
   path_bar = gtk_path_bar_new ();
   gtk_grid_attach (GTK_GRID (grid), path_bar, 0, 1, 1, 1);
   gtk_path_bar_set_path (GTK_PATH_BAR (path_bar), ORIGINAL_PATH);
-  g_signal_connect (GTK_PATH_BAR (path_bar), "populate-popup",
-                    G_CALLBACK (on_populate_popup), window);
-  g_signal_connect (GTK_PATH_BAR (path_bar), "notify::selected-path",
-                    G_CALLBACK (on_path_selected), window);
-  path_bars = g_list_append (path_bars, path_bar);
-
-  edit_mode_button = gtk_button_new_from_icon_name ("edit-symbolic", GTK_ICON_SIZE_MENU);
-  gtk_widget_set_hexpand (edit_mode_button, FALSE);
-  g_signal_connect (GTK_BUTTON (edit_mode_button), "clicked",
-                    G_CALLBACK (on_path_bar_edit_mode_button_clicked), path_bar);
-  gtk_grid_attach (GTK_GRID (grid), edit_mode_button, 1, 1, 1, 1);
+  connect_path_bar (GTK_PATH_BAR (path_bar));
 
   /* ----------------------------------------------------------------------- */
-  path_bar = gtk_path_bar_new ();
-  gtk_path_bar_set_hide_direction (GTK_PATH_BAR (path_bar), GTK_DIR_LEFT);
-  gtk_path_bar_set_path (GTK_PATH_BAR (path_bar), ORIGINAL_PATH);
-  g_signal_connect (GTK_PATH_BAR (path_bar), "populate-popup",
-                    G_CALLBACK (on_populate_popup), window);
-  g_signal_connect (GTK_PATH_BAR (path_bar), "notify::selected-path",
-                    G_CALLBACK (on_path_selected), window);
-  path_bars = g_list_append (path_bars, path_bar);
-  gtk_grid_attach (GTK_GRID (grid), path_bar, 0, 2, 1, 1);
-
-  edit_mode_button = gtk_button_new_from_icon_name ("edit-symbolic", GTK_ICON_SIZE_MENU);
-  gtk_widget_set_hexpand (edit_mode_button, FALSE);
-  g_signal_connect (GTK_BUTTON (edit_mode_button), "clicked",
-                    G_CALLBACK (on_path_bar_edit_mode_button_clicked), path_bar);
-  gtk_grid_attach (GTK_GRID (grid), edit_mode_button, 1, 2, 1, 1);
+  path_bar_inverted = gtk_path_bar_new ();
+  gtk_path_bar_set_inverted (GTK_PATH_BAR (path_bar_inverted), TRUE);
+  gtk_path_bar_set_path (GTK_PATH_BAR (path_bar_inverted), ORIGINAL_PATH);
+  connect_path_bar (GTK_PATH_BAR (path_bar_inverted));
+  gtk_grid_attach (GTK_GRID (grid), path_bar_inverted, 0, 2, 1, 1);
 
   label = gtk_label_new ("“/” a.k.a root, special case");
   gtk_grid_attach (GTK_GRID (grid), label, 0, 3, 2, 1);
 
   /* ----------------------------------------------------------------------- */
-  path_bar = gtk_path_bar_new ();
-  gtk_path_bar_set_hide_direction (GTK_PATH_BAR (path_bar), GTK_DIR_LEFT);
-  gtk_path_bar_set_path (GTK_PATH_BAR (path_bar), "/");
-  g_signal_connect (GTK_PATH_BAR (path_bar), "populate-popup",
-                    G_CALLBACK (on_populate_popup), window);
-  g_signal_connect (GTK_PATH_BAR (path_bar), "notify::selected-path",
-                    G_CALLBACK (on_path_selected_set_path), window);
-  path_bars = g_list_append (path_bars, path_bar);
-  gtk_grid_attach (GTK_GRID (grid), path_bar, 0, 4, 1, 1);
-
-  edit_mode_button = gtk_button_new_from_icon_name ("edit-symbolic", GTK_ICON_SIZE_MENU);
-  gtk_widget_set_hexpand (edit_mode_button, FALSE);
-  g_signal_connect (GTK_BUTTON (edit_mode_button), "clicked",
-                    G_CALLBACK (on_path_bar_edit_mode_button_clicked), path_bar);
-  gtk_grid_attach (GTK_GRID (grid), edit_mode_button, 1, 4, 1, 1);
+  path_bar_slash = gtk_path_bar_new ();
+  gtk_path_bar_set_inverted (GTK_PATH_BAR (path_bar_slash), TRUE);
+  gtk_path_bar_set_path (GTK_PATH_BAR (path_bar_slash), "/");
+  connect_path_bar_set_path (GTK_PATH_BAR (path_bar_slash));
+  gtk_grid_attach (GTK_GRID (grid), path_bar_slash, 0, 4, 1, 1);
 
   label = gtk_label_new ("GtkPathBar with special roots");
   gtk_grid_attach (GTK_GRID (grid), label, 0, 5, 2, 1);
 
   /* ----------------------------------------------------------------------- */
-  path_bar = gtk_path_bar_new ();
-  gtk_path_bar_set_hide_direction (GTK_PATH_BAR (path_bar), GTK_DIR_LEFT);
-  gtk_path_bar_set_path (GTK_PATH_BAR (path_bar), ORIGINAL_PATH);
-  gtk_path_bar_set_root (GTK_PATH_BAR (path_bar), NULL, "ThisIsARoot", "/test/test 2/test 3");
-  g_signal_connect (GTK_PATH_BAR (path_bar), "populate-popup",
-                    G_CALLBACK (on_populate_popup), window);
-  g_signal_connect (GTK_PATH_BAR (path_bar), "notify::selected-path",
-                    G_CALLBACK (on_path_selected_set_path), window);
-  g_signal_connect (GTK_PATH_BAR (path_bar), "notify::path",
-                    G_CALLBACK (on_path_changed_set_root), window);
-  path_bars = g_list_append (path_bars, path_bar);
-  gtk_grid_attach (GTK_GRID (grid), path_bar, 0, 6, 1, 1);
-
-  edit_mode_button = gtk_button_new_from_icon_name ("edit-symbolic", GTK_ICON_SIZE_MENU);
-  gtk_widget_set_hexpand (edit_mode_button, FALSE);
-  g_signal_connect (GTK_BUTTON (edit_mode_button), "clicked",
-                    G_CALLBACK (on_path_bar_edit_mode_button_clicked), path_bar);
-  gtk_grid_attach (GTK_GRID (grid), edit_mode_button, 1, 6, 1, 1);
+  path_bar_custom_root_label = gtk_path_bar_new ();
+  gtk_path_bar_set_inverted (GTK_PATH_BAR (path_bar_custom_root_label), TRUE);
+  gtk_path_bar_set_path_extended (GTK_PATH_BAR (path_bar_custom_root_label),
+                                  ORIGINAL_PATH, DISPLAY_PATH, ROOT_PATH, NULL);
+  connect_path_bar_set_path (GTK_PATH_BAR (path_bar_custom_root_label));
+  gtk_grid_attach (GTK_GRID (grid), path_bar_custom_root_label, 0, 6, 1, 1);
 
   /* ----------------------------------------------------------------------- */
-  path_bar = gtk_path_bar_new ();
-  gtk_path_bar_set_hide_direction (GTK_PATH_BAR (path_bar), GTK_DIR_LEFT);
-  gtk_path_bar_set_path (GTK_PATH_BAR (path_bar), ORIGINAL_PATH);
-  icon = g_themed_icon_new ("drives-harddisk-symbolic");
-  gtk_path_bar_set_root (GTK_PATH_BAR (path_bar), icon, NULL, "/test/test 2/test 3");
+  path_bar_custom_root_icon = gtk_path_bar_new ();
+  gtk_path_bar_set_inverted (GTK_PATH_BAR (path_bar_custom_root_icon), TRUE);
+  icon = g_themed_icon_new ("drive-harddisk");
+  gtk_path_bar_set_path_extended (GTK_PATH_BAR (path_bar_custom_root_icon),
+                                  ORIGINAL_PATH, DISPLAY_PATH, ROOT_PATH, icon);
   g_object_unref (icon);
-  g_signal_connect (GTK_PATH_BAR (path_bar), "populate-popup",
-                    G_CALLBACK (on_populate_popup), window);
-  g_signal_connect (GTK_PATH_BAR (path_bar), "notify::selected-path",
-                    G_CALLBACK (on_path_selected_set_path), window);
-  g_signal_connect (GTK_PATH_BAR (path_bar), "notify::path",
-                    G_CALLBACK (on_path_changed_set_root), window);
-  path_bars = g_list_append (path_bars, path_bar);
-  gtk_grid_attach (GTK_GRID (grid), path_bar, 0, 7, 1, 1);
-
-  edit_mode_button = gtk_button_new_from_icon_name ("edit-symbolic", GTK_ICON_SIZE_MENU);
-  gtk_widget_set_hexpand (edit_mode_button, FALSE);
-  g_signal_connect (GTK_BUTTON (edit_mode_button), "clicked",
-                    G_CALLBACK (on_path_bar_edit_mode_button_clicked), path_bar);
-  gtk_grid_attach (GTK_GRID (grid), edit_mode_button, 1, 7, 1, 1);
+  connect_path_bar_set_path (GTK_PATH_BAR (path_bar_custom_root_icon));
+  gtk_grid_attach (GTK_GRID (grid), path_bar_custom_root_icon, 0, 7, 1, 1);
 
   /* GtkFilesPathBar tests */
   label = gtk_label_new ("GtkFilesPathBar tests");
   gtk_grid_attach (GTK_GRID (grid), label, 0, 8, 2, 1);
 
   /* ----------------------------------------------------------------------- */
-  path_bar = gtk_files_path_bar_new ();
+  files_path_bar = gtk_files_path_bar_new ();
   file = g_file_new_for_path (ORIGINAL_PATH);
-  gtk_files_path_bar_set_file (GTK_FILES_PATH_BAR (path_bar), file);
-  g_signal_connect (GTK_FILES_PATH_BAR (path_bar), "populate-popup",
-                    G_CALLBACK (on_populate_popup), window);
-  g_signal_connect (GTK_FILES_PATH_BAR (path_bar), "notify::file",
-                    G_CALLBACK (on_file_changed), window);
-  files_path_bars = g_list_append (files_path_bars, path_bar);
-  gtk_grid_attach (GTK_GRID (grid), path_bar, 0, 9, 1, 1);
-
-  edit_mode_button = gtk_button_new_from_icon_name ("edit-symbolic", GTK_ICON_SIZE_MENU);
-  gtk_widget_set_hexpand (edit_mode_button, FALSE);
-  g_signal_connect (GTK_BUTTON (edit_mode_button), "clicked",
-                    G_CALLBACK (on_files_path_bar_edit_mode_button_clicked), path_bar);
-  gtk_grid_attach (GTK_GRID (grid), edit_mode_button, 1, 9, 1, 1);
+  gtk_files_path_bar_set_file (GTK_FILES_PATH_BAR (files_path_bar), file);
+  connect_files_path_bar (GTK_FILES_PATH_BAR (files_path_bar));
+  gtk_grid_attach (GTK_GRID (grid), files_path_bar, 0, 9, 1, 1);
 
   g_clear_object (&file);
 



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