[gtk+/wip/csoriano/pathbar-prototype] pathbar



commit 78898285b82c6fff5def8beabb43c16dd1e7dd06
Author: Carlos Soriano <csoriano gnome org>
Date:   Mon Nov 9 12:40:58 2015 +0100

    pathbar

 gtk/gtkpathbar.c                         |  392 +++++++++++-------------------
 gtk/theme/Adwaita/_common.scss           |    2 +-
 gtk/theme/Adwaita/gtk-contained-dark.css |   12 +-
 gtk/theme/Adwaita/gtk-contained.css      |   12 +-
 gtk/ui/gtkpathbar.ui                     |   17 ++-
 tests/testpathbar.c                      |   54 ++++-
 6 files changed, 223 insertions(+), 266 deletions(-)
---
diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c
index ba8a789..c92603e 100644
--- a/gtk/gtkpathbar.c
+++ b/gtk/gtkpathbar.c
@@ -38,6 +38,8 @@ struct _GtkPathBarPrivate
 {
   GtkWidget *path_box;
   GtkWidget *overflow_button;
+  GtkWidget *overflow_popover;
+  GtkWidget *overflow_container;
   GtkWidget *path_chunk_popover_container;
 
   gchar *path;
@@ -196,8 +198,10 @@ create_path_chunk (GtkPathBar    *self,
   button = gtk_toggle_button_new ();
   button_label = gtk_label_new (label);
   gtk_label_set_ellipsize (GTK_LABEL (button_label), PANGO_ELLIPSIZE_MIDDLE);
+  // FIXME: the GtkLabel requests more than the number of chars set here.
+  // For visual testing for now substract 2 chars.
   gtk_label_set_width_chars (GTK_LABEL (button_label),
-                             MIN (g_utf8_strlen (label, -1), 6));
+                             MIN (g_utf8_strlen (label, -1) - 2, 10));
   gtk_container_add (GTK_CONTAINER (button), button_label);
 
   g_signal_connect_swapped (button, "button-release-event",
@@ -236,19 +240,17 @@ create_path_chunk (GtkPathBar    *self,
 }
 
 static void
-popup_overflow_menu (GtkPathBar *self)
+populate_overflow_popover (GtkPathBar *self)
 {
   GtkPathBarPrivate *priv = gtk_path_bar_get_instance_private (GTK_PATH_BAR (self));
   GList *overflow_children;
   GList *l;
   PathChunkData *data;
   GtkWidget *path_chunk;
-  GtkWidget *overflow_box;
-  GtkWidget *popover;
+  g_print ("raising overflow menu\n");
 
-  overflow_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
-  popover = gtk_popover_new (priv->overflow_button);
-  gtk_container_add (GTK_CONTAINER (popover), overflow_box);
+  gtk_container_foreach (GTK_CONTAINER (priv->overflow_container),
+                         (GtkCallback) gtk_widget_destroy, NULL);
 
   overflow_children = gtk_hiding_box_get_overflow_children (GTK_HIDING_BOX (priv->path_box));
   for (l = overflow_children; l != NULL; l = l->next)
@@ -256,139 +258,12 @@ popup_overflow_menu (GtkPathBar *self)
       data = g_object_get_data (l->data, "data");
       path_chunk = create_path_chunk (self, (const GString*) data->path,
                                       (const gchar*) data->label, FALSE);
-      gtk_container_add (GTK_CONTAINER (overflow_box), path_chunk);
+      gtk_container_add (GTK_CONTAINER (priv->overflow_container), path_chunk);
     }
 
-  gtk_widget_show_all (popover);
-
   g_list_free (overflow_children);
 }
 
-void
-gtk_path_bar_set_path (GtkPathBar  *self,
-                       const gchar *path)
-{
-  GtkPathBarPrivate *priv;
-  gchar ** splitted_path;
-  GString *current_path = NULL;
-  GtkWidget *path_chunk;
-  PathChunkData *data;
-  GList *children;
-
-  g_return_if_fail (GTK_IS_PATH_BAR (self));
-
-  priv = gtk_path_bar_get_instance_private (GTK_PATH_BAR (self));
-
-  if (g_strcmp0 (priv->path, path) == 0)
-    return;
-
-  gtk_container_foreach (GTK_CONTAINER (priv->path_box), (GtkCallback) gtk_widget_destroy, NULL);
-
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->overflow_button), FALSE);
-
-  if (priv->path)
-    {
-      g_free (priv->path);
-      priv->path = NULL;
-    }
-
-  splitted_path = g_strsplit (path, "/", -1);
-  current_path = g_string_new ("");
-  for (guint i = 0; i < g_strv_length (splitted_path); i++)
-    {
-      if (g_strcmp0 (splitted_path[i], "") == 0)
-        continue;
-
-      g_string_append (current_path, "/");
-      g_string_append (current_path, splitted_path[i]);
-      path_chunk = create_path_chunk (self, current_path, splitted_path[i], TRUE);
-      gtk_container_add (GTK_CONTAINER (priv->path_box), path_chunk);
-      data = g_object_get_data (G_OBJECT (path_chunk), "data");
-    }
-
-  children = gtk_container_get_children (GTK_CONTAINER (priv->path_box));
-  if (children != NULL)
-    {
-      path_chunk = GTK_WIDGET (g_list_last (children)->data);
-      data = g_object_get_data (G_OBJECT (path_chunk), "data");
-      priv->selecting_path = TRUE;
-      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->button), TRUE);
-      priv->selecting_path = FALSE;
-      priv->path = g_strdup (data->path->str);
-    }
-
-  g_object_notify_by_pspec (G_OBJECT (self), path_bar_properties[PROP_PATH]);
-
-  g_strfreev (splitted_path);
-  g_string_free (current_path, TRUE);
-  g_list_free (children);
-}
-
-void
-gtk_path_bar_select_path (GtkPathBar  *self,
-                          const gchar *path)
-{
-  GtkPathBarPrivate *priv;
-  PathChunkData *data;
-  GList *children;
-  GList *l;
-
-  g_return_if_fail (GTK_IS_PATH_BAR (self));
-
-  priv = gtk_path_bar_get_instance_private (GTK_PATH_BAR (self));
-
-  g_return_if_fail (g_str_has_prefix (priv->path, path));
-
-  children = gtk_container_get_children (GTK_CONTAINER (priv->path_box));
-  for (l = children; l != NULL; l = l->next)
-    {
-      data = g_object_get_data (G_OBJECT (l->data), "data");
-      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->button),
-                                    g_strcmp0 (data->path->str, path) == 0);
-    }
-
-  g_list_free (children);
-}
-
-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)) != hide_direction)
-    {
-      gtk_hiding_box_set_hide_direction (GTK_HIDING_BOX (priv->path_box), hide_direction);
-
-      g_object_notify (G_OBJECT (self), "hide-direction");
-
-      gtk_widget_queue_resize (GTK_WIDGET (self));
-    }
-}
-
-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));
-}
-
-GtkWidget *
-gtk_path_bar_new (void)
-{
-  return g_object_new (GTK_TYPE_PATH_BAR, NULL);
-}
-
 static void
 gtk_path_bar_finalize (GObject *object)
 {
@@ -443,111 +318,6 @@ gtk_path_bar_set_property (GObject      *object,
     }
 }
 
-static void
-get_path_preferred_width (GtkWidget *self,
-                          gint      *min_width,
-                          gint      *nat_width)
-{
-  GtkPathBarPrivate *priv = gtk_path_bar_get_instance_private (GTK_PATH_BAR (self));
-  GList *children;
-  GList *l;
-  gint child_nat_width;
-  gint child_min_width;
-
-  children = gtk_container_get_children (GTK_CONTAINER (priv->path_box));
-  *min_width = 0;
-  *nat_width = 0;
-
-  for (l = children; l != NULL; l = l->next)
-    {
-      gtk_widget_get_preferred_width (l->data, &child_min_width, &child_nat_width);
-      *min_width += child_min_width;
-      *nat_width += child_nat_width;
-    }
-
-  g_list_free (children);
-}
-
-static void
-get_preferred_width (GtkWidget *self,
-                     gint      *min_width,
-                     gint      *nat_width)
-{
-  GtkPathBarPrivate *priv = gtk_path_bar_get_instance_private (GTK_PATH_BAR (self));
-  gint overflow_button_min_width;
-  gint overflow_button_nat_width;
-
-  *min_width = 0;
-  *nat_width = 0;
-
-  get_path_preferred_width (self, min_width, nat_width);
-  gtk_widget_get_preferred_width (priv->overflow_button, &overflow_button_min_width, 
&overflow_button_nat_width);
-
-  *min_width = MIN (overflow_button_min_width, *min_width);
-  *nat_width = MAX (overflow_button_nat_width, *nat_width);
-}
-
-static void
-get_preferred_width_for_height (GtkWidget *self,
-                                gint       height,
-                                gint      *min_width,
-                                gint      *nat_width)
-{
-  get_preferred_width (self, min_width, nat_width);
-}
-
-static void
-get_path_preferred_height (GtkWidget *self,
-                           gint      *min_height,
-                           gint      *nat_height)
-{
-  GtkPathBarPrivate *priv = gtk_path_bar_get_instance_private (GTK_PATH_BAR (self));
-  GList *children;
-  GList *l;
-  gint child_nat_height;
-  gint child_min_height;
-
-  children = gtk_container_get_children (GTK_CONTAINER (priv->path_box));
-  *min_height = 0;
-  *nat_height = 0;
-
-  for (l = children; l != NULL; l = l->next)
-    {
-      gtk_widget_get_preferred_height (l->data, &child_min_height, &child_nat_height);
-      *min_height = MAX (*min_height, child_min_height);
-      *nat_height = MAX (*nat_height, child_nat_height);
-    }
-
-  g_list_free (children);
-}
-
-static void
-get_preferred_height (GtkWidget *self,
-                      gint      *min_height,
-                      gint      *nat_height)
-{
-  GtkPathBarPrivate *priv = gtk_path_bar_get_instance_private (GTK_PATH_BAR (self));
-  gint overflow_button_min_height;
-  gint overflow_button_nat_height;
-  gint path_min_height;
-  gint path_nat_height;
-
-  get_path_preferred_height (self, &path_min_height, &path_nat_height);
-  gtk_widget_get_preferred_height (priv->overflow_button, &overflow_button_min_height, 
&overflow_button_nat_height);
-
-  *min_height = MAX (path_min_height, overflow_button_min_height);
-  *nat_height = MAX (path_nat_height, overflow_button_nat_height);
-}
-
-static void
-get_preferred_height_for_width (GtkWidget *self,
-                                gint       width,
-                                gint      *min_height,
-                                gint      *nat_height)
-{
-  get_preferred_height (self, min_height, nat_height);
-}
-
 static GtkSizeRequestMode
 get_request_mode (GtkWidget *self)
 {
@@ -561,7 +331,6 @@ size_allocate (GtkWidget     *self,
   GtkPathBarPrivate *priv = gtk_path_bar_get_instance_private (GTK_PATH_BAR (self));
   gint path_min_width;
   gint path_nat_width;
-  gint current_x_pos;
   gint overflow_button_min_width;
   GtkAllocation path_container_allocation;
   GtkAllocation overflow_button_allocation;
@@ -592,21 +361,19 @@ size_allocate (GtkWidget     *self,
   gtk_widget_get_preferred_width (priv->path_box, &path_min_width, &path_nat_width);
   gtk_widget_get_preferred_width (priv->overflow_button, &overflow_button_min_width, NULL);
   direction = gtk_widget_get_direction (self);
-  current_x_pos = allocation->x;
 
-  g_print ("overflow %d %d\n", overflow, overflow_button_min_width);
   if (overflow && direction == GTK_TEXT_DIR_LTR)
     {
       overflow_button_allocation.y = allocation->y;
       overflow_button_allocation.height = allocation->height;
       overflow_button_allocation.width = overflow_button_min_width;
-      overflow_button_allocation.x = current_x_pos;
+      overflow_button_allocation.x = allocation->x;
       gtk_widget_set_child_visible (priv->overflow_button, TRUE);
       gtk_widget_size_allocate (priv->overflow_button, &overflow_button_allocation);
-      current_x_pos += overflow_button_allocation.width;
     }
 
-  path_container_allocation.x = current_x_pos;
+  path_container_allocation.x = overflow ? allocation->x + overflow_button_min_width
+                                         : allocation->x;
   path_container_allocation.width = overflow ? allocation->width - overflow_button_min_width
                                              : allocation->width;
   path_container_allocation.y = allocation->y;
@@ -639,10 +406,6 @@ gtk_path_bar_class_init (GtkPathBarClass *klass)
   object_class->set_property = gtk_path_bar_set_property;
 
   widget_class->get_request_mode = get_request_mode;
-  //widget_class->get_preferred_width = get_preferred_width;
-  //widget_class->get_preferred_height = get_preferred_height;
-  //widget_class->get_preferred_width_for_height = get_preferred_width_for_height;
-  //widget_class->get_preferred_height_for_width = get_preferred_height_for_width;
   widget_class->size_allocate = size_allocate;
 
   /**
@@ -721,8 +484,10 @@ gtk_path_bar_class_init (GtkPathBarClass *klass)
 
   gtk_widget_class_bind_template_child_private (widget_class, GtkPathBar, overflow_button);
   gtk_widget_class_bind_template_child_private (widget_class, GtkPathBar, path_box);
+  gtk_widget_class_bind_template_child_private (widget_class, GtkPathBar, overflow_popover);
+  gtk_widget_class_bind_template_child_private (widget_class, GtkPathBar, overflow_container);
 
-  gtk_widget_class_bind_template_callback (widget_class, popup_overflow_menu);
+  gtk_widget_class_bind_template_callback (widget_class, populate_overflow_popover);
 
   gtk_widget_class_set_css_name (widget_class, "path-bar");
 }
@@ -738,3 +503,128 @@ gtk_path_bar_init (GtkPathBar *self)
   priv->selecting_path = FALSE;
   priv->hide_direction = GTK_DIR_RIGHT;
 }
+
+void
+gtk_path_bar_set_path (GtkPathBar  *self,
+                       const gchar *path)
+{
+  GtkPathBarPrivate *priv;
+  gchar ** splitted_path;
+  GString *current_path = NULL;
+  GtkWidget *path_chunk;
+  PathChunkData *data;
+  GList *children;
+
+  g_return_if_fail (GTK_IS_PATH_BAR (self));
+
+  priv = gtk_path_bar_get_instance_private (GTK_PATH_BAR (self));
+
+  if (g_strcmp0 (priv->path, path) == 0)
+    return;
+
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->overflow_button), FALSE);
+
+  gtk_container_foreach (GTK_CONTAINER (priv->path_box), (GtkCallback) gtk_widget_destroy, NULL);
+
+  if (priv->path)
+    {
+      g_free (priv->path);
+      priv->path = NULL;
+    }
+
+  splitted_path = g_strsplit (path, "/", -1);
+  current_path = g_string_new ("");
+  for (guint i = 0; i < g_strv_length (splitted_path); i++)
+    {
+      if (g_strcmp0 (splitted_path[i], "") == 0)
+        continue;
+
+      g_string_append (current_path, "/");
+      g_string_append (current_path, splitted_path[i]);
+      path_chunk = create_path_chunk (self, current_path, splitted_path[i], TRUE);
+      gtk_container_add (GTK_CONTAINER (priv->path_box), path_chunk);
+      data = g_object_get_data (G_OBJECT (path_chunk), "data");
+    }
+
+  children = gtk_container_get_children (GTK_CONTAINER (priv->path_box));
+  if (children != NULL)
+    {
+      path_chunk = GTK_WIDGET (g_list_last (children)->data);
+      data = g_object_get_data (G_OBJECT (path_chunk), "data");
+      priv->selecting_path = TRUE;
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->button), TRUE);
+      priv->selecting_path = FALSE;
+      priv->path = g_strdup (data->path->str);
+    }
+
+  g_object_notify_by_pspec (G_OBJECT (self), path_bar_properties[PROP_PATH]);
+
+  g_strfreev (splitted_path);
+  g_string_free (current_path, TRUE);
+  g_list_free (children);
+}
+
+void
+gtk_path_bar_select_path (GtkPathBar  *self,
+                          const gchar *path)
+{
+  GtkPathBarPrivate *priv;
+  PathChunkData *data;
+  GList *children;
+  GList *l;
+
+  g_return_if_fail (GTK_IS_PATH_BAR (self));
+
+  priv = gtk_path_bar_get_instance_private (GTK_PATH_BAR (self));
+
+  g_return_if_fail (g_str_has_prefix (priv->path, path));
+
+  children = gtk_container_get_children (GTK_CONTAINER (priv->path_box));
+  for (l = children; l != NULL; l = l->next)
+    {
+      data = g_object_get_data (G_OBJECT (l->data), "data");
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->button),
+                                    g_strcmp0 (data->path->str, path) == 0);
+    }
+
+  g_list_free (children);
+}
+
+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)) != hide_direction)
+    {
+      gtk_hiding_box_set_hide_direction (GTK_HIDING_BOX (priv->path_box), hide_direction);
+
+      g_object_notify (G_OBJECT (self), "hide-direction");
+
+      gtk_widget_queue_resize (GTK_WIDGET (self));
+    }
+}
+
+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));
+}
+
+GtkWidget *
+gtk_path_bar_new (void)
+{
+  return g_object_new (GTK_TYPE_PATH_BAR, NULL);
+}
diff --git a/gtk/theme/Adwaita/_common.scss b/gtk/theme/Adwaita/_common.scss
index 05258f2..38d4a52 100644
--- a/gtk/theme/Adwaita/_common.scss
+++ b/gtk/theme/Adwaita/_common.scss
@@ -1239,7 +1239,7 @@ headerbar {
  * Pathbars *
  ************/
 
-path-bar button.flat {
+path-bar button.flat, .path-bar-overflow-popover button.flat {
     background-image: none;
     border-radius: 0px;
     border-top-color: transparent;
diff --git a/gtk/theme/Adwaita/gtk-contained-dark.css b/gtk/theme/Adwaita/gtk-contained-dark.css
index 76755c8..ec3949b 100644
--- a/gtk/theme/Adwaita/gtk-contained-dark.css
+++ b/gtk/theme/Adwaita/gtk-contained-dark.css
@@ -1835,7 +1835,9 @@ headerbar {
  ************/
 path-bar button.flat, path-bar .sidebar-button.button, path-bar headerbar button.titlebutton, headerbar 
path-bar button.titlebutton,
 path-bar .titlebar button.titlebutton,
-.titlebar path-bar button.titlebutton {
+.titlebar path-bar button.titlebutton, .path-bar-overflow-popover button.flat, .path-bar-overflow-popover 
.sidebar-button.button, .path-bar-overflow-popover headerbar button.titlebutton, headerbar 
.path-bar-overflow-popover button.titlebutton,
+.path-bar-overflow-popover .titlebar button.titlebutton,
+.titlebar .path-bar-overflow-popover button.titlebutton {
   background-image: none;
   border-radius: 0px;
   border-top-color: transparent;
@@ -1846,11 +1848,15 @@ path-bar .titlebar button.titlebutton,
   padding: 3px 8px 4px; }
   path-bar button.flat:hover, path-bar .sidebar-button.button:hover, path-bar headerbar 
button.titlebutton:hover, headerbar path-bar button.titlebutton:hover,
   path-bar .titlebar button.titlebutton:hover,
-  .titlebar path-bar button.titlebutton:hover {
+  .titlebar path-bar button.titlebutton:hover, .path-bar-overflow-popover button.flat:hover, 
.path-bar-overflow-popover .sidebar-button.button:hover, .path-bar-overflow-popover headerbar 
button.titlebutton:hover, headerbar .path-bar-overflow-popover button.titlebutton:hover,
+  .path-bar-overflow-popover .titlebar button.titlebutton:hover,
+  .titlebar .path-bar-overflow-popover button.titlebutton:hover {
     border-bottom-color: #5986b5; }
   path-bar button.flat:checked, path-bar .sidebar-button.button:checked, path-bar headerbar 
button.titlebutton:checked, headerbar path-bar button.titlebutton:checked,
   path-bar .titlebar button.titlebutton:checked,
-  .titlebar path-bar button.titlebutton:checked {
+  .titlebar path-bar button.titlebutton:checked, .path-bar-overflow-popover button.flat:checked, 
.path-bar-overflow-popover .sidebar-button.button:checked, .path-bar-overflow-popover headerbar 
button.titlebutton:checked, headerbar .path-bar-overflow-popover button.titlebutton:checked,
+  .path-bar-overflow-popover .titlebar button.titlebutton:checked,
+  .titlebar .path-bar-overflow-popover button.titlebutton:checked {
     border-bottom-color: #215d9c; }
 
 /**************
diff --git a/gtk/theme/Adwaita/gtk-contained.css b/gtk/theme/Adwaita/gtk-contained.css
index b74259e..3ea3bf4 100644
--- a/gtk/theme/Adwaita/gtk-contained.css
+++ b/gtk/theme/Adwaita/gtk-contained.css
@@ -1835,7 +1835,9 @@ headerbar {
  ************/
 path-bar button.flat, path-bar .sidebar-button.button, path-bar headerbar button.titlebutton, headerbar 
path-bar button.titlebutton,
 path-bar .titlebar button.titlebutton,
-.titlebar path-bar button.titlebutton {
+.titlebar path-bar button.titlebutton, .path-bar-overflow-popover button.flat, .path-bar-overflow-popover 
.sidebar-button.button, .path-bar-overflow-popover headerbar button.titlebutton, headerbar 
.path-bar-overflow-popover button.titlebutton,
+.path-bar-overflow-popover .titlebar button.titlebutton,
+.titlebar .path-bar-overflow-popover button.titlebutton {
   background-image: none;
   border-radius: 0px;
   border-top-color: transparent;
@@ -1846,11 +1848,15 @@ path-bar .titlebar button.titlebutton,
   padding: 3px 8px 4px; }
   path-bar button.flat:hover, path-bar .sidebar-button.button:hover, path-bar headerbar 
button.titlebutton:hover, headerbar path-bar button.titlebutton:hover,
   path-bar .titlebar button.titlebutton:hover,
-  .titlebar path-bar button.titlebutton:hover {
+  .titlebar path-bar button.titlebutton:hover, .path-bar-overflow-popover button.flat:hover, 
.path-bar-overflow-popover .sidebar-button.button:hover, .path-bar-overflow-popover headerbar 
button.titlebutton:hover, headerbar .path-bar-overflow-popover button.titlebutton:hover,
+  .path-bar-overflow-popover .titlebar button.titlebutton:hover,
+  .titlebar .path-bar-overflow-popover button.titlebutton:hover {
     border-bottom-color: #77ace3; }
   path-bar button.flat:checked, path-bar .sidebar-button.button:checked, path-bar headerbar 
button.titlebutton:checked, headerbar path-bar button.titlebutton:checked,
   path-bar .titlebar button.titlebutton:checked,
-  .titlebar path-bar button.titlebutton:checked {
+  .titlebar path-bar button.titlebutton:checked, .path-bar-overflow-popover button.flat:checked, 
.path-bar-overflow-popover .sidebar-button.button:checked, .path-bar-overflow-popover headerbar 
button.titlebutton:checked, headerbar .path-bar-overflow-popover button.titlebutton:checked,
+  .path-bar-overflow-popover .titlebar button.titlebutton:checked,
+  .titlebar .path-bar-overflow-popover button.titlebutton:checked {
     border-bottom-color: #4a90d9; }
 
 /**************
diff --git a/gtk/ui/gtkpathbar.ui b/gtk/ui/gtkpathbar.ui
index 55728bd..c60a941 100644
--- a/gtk/ui/gtkpathbar.ui
+++ b/gtk/ui/gtkpathbar.ui
@@ -1,15 +1,28 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface domain="gtk30">
+  <object class="GtkPopover" id="overflow_popover">
+   <property name="width-request">200</property>
+   <child>
+     <object class="GtkBox" id="overflow_container">
+       <property name="visible">true</property>
+       <property name="orientation">GTK_ORIENTATION_VERTICAL</property>
+     </object>
+   </child>
+    <style>
+      <class name="path-bar-overflow-popover"/>
+    </style>
+  </object>
   <template class="GtkPathBar" parent="GtkBox">
     <property name="visible">true</property>
     <property name="orientation">horizontal</property>
     <property name="vexpand">false</property>
     <property name="valign">GTK_ALIGN_START</property>
     <child>
-      <object class="GtkToggleButton" id="overflow_button">
+      <object class="GtkMenuButton" id="overflow_button">
         <property name="visible">true</property>
         <property name="no-show-all">true</property>
-        <signal name="clicked" handler="popup_overflow_menu" object="GtkPathBar" swapped="yes"/>
+        <property name="popover">overflow_popover</property>
+        <signal name="clicked" handler="populate_overflow_popover" object="GtkPathBar" swapped="yes"/>
         <child>
           <object class="GtkImage">
             <property name="visible">true</property>
diff --git a/tests/testpathbar.c b/tests/testpathbar.c
index be25f80..4ddc3c2 100644
--- a/tests/testpathbar.c
+++ b/tests/testpathbar.c
@@ -3,6 +3,8 @@
 #include <gtk/gtk.h>
 
 static GActionGroup *action_group;
+static GList *path_bars = NULL;
+static const gchar* original_path = "/test/test 2/test 3/asda lkasdl//pppppppppppppppp/ alskd/";
 
 static void
 action_menu_1 (GSimpleAction *action,
@@ -75,12 +77,30 @@ on_path_selected (GtkPathBar  *path_bar,
   g_print ("Path selected: %s\n", path);
 }
 
+static void
+on_path_selected_set_path (GtkPathBar  *path_bar,
+                           const gchar *path)
+{
+  g_print ("Path selected: %s, setting path to GtkPathBar\n", path);
+  gtk_path_bar_set_path (path_bar, path);
+}
+
+static void
+on_reset_button_clicked (GtkButton *reset_button)
+{
+  GList *l;
+
+  for (l = path_bars; l != NULL; l = l->next)
+    gtk_path_bar_set_path (l->data, original_path);
+}
+
 int
 main (int argc, char *argv[])
 {
   GtkWidget *window;
   GtkWidget *path_bar;
   GtkWidget *box;
+  GtkWidget *reset_button;
 
   gtk_init (&argc, &argv);
 
@@ -103,20 +123,42 @@ main (int argc, char *argv[])
   g_type_ensure (GTK_TYPE_PATH_BAR);
   path_bar = gtk_path_bar_new ();
   gtk_container_add (GTK_CONTAINER (box), path_bar);
-  gtk_path_bar_set_path (GTK_PATH_BAR (path_bar), "/test/test 2/test 3/asda lkasdl//pppppppppppppppp/ 
alskd/");
+  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), "path-selected",
+                    G_CALLBACK (on_path_selected), window);
+  path_bars = g_list_append (path_bars, path_bar);
 
   path_bar = gtk_path_bar_new ();
   gtk_container_add (GTK_CONTAINER (box), path_bar);
   gtk_path_bar_set_hide_direction (GTK_PATH_BAR (path_bar), GTK_DIR_LEFT);
-  gtk_path_bar_set_path (GTK_PATH_BAR (path_bar), "/test/test 2/test 3/asda lkasdl//pppppppppppppppp/ 
alskd/");
-
-  gtk_container_add (GTK_CONTAINER (window), box);
-  gtk_widget_show_all (window);
-
+  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), "path-selected",
                     G_CALLBACK (on_path_selected), window);
+  path_bars = g_list_append (path_bars, path_bar);
+
+  path_bar = gtk_path_bar_new ();
+  gtk_container_add (GTK_CONTAINER (box), path_bar);
+  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), "path-selected",
+                    G_CALLBACK (on_path_selected_set_path), window);
+  path_bars = g_list_append (path_bars, path_bar);
+
+  reset_button = gtk_button_new_with_label ("Reset State");
+  gtk_widget_set_hexpand (reset_button, TRUE);
+  gtk_container_add (GTK_CONTAINER (box), reset_button);
+  g_signal_connect (GTK_BUTTON (reset_button), "clicked",
+                    G_CALLBACK (on_reset_button_clicked), window);
+
+  gtk_container_add (GTK_CONTAINER (window), box);
+  gtk_widget_show_all (window);
+
 
   gtk_main ();
 


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