[gtk+/wip/csoriano/pathbar-bin-view-window] gtkrevealer: support minimum size of child
- From: Carlos Soriano Sánchez <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/csoriano/pathbar-bin-view-window] gtkrevealer: support minimum size of child
- Date: Tue, 21 Jun 2016 17:04:34 +0000 (UTC)
commit 15b262408f8f85fea6edf925b6cb2d5a1ddc4080
Author: Carlos Soriano <csoriano gnome org>
Date: Wed Jun 15 18:22:32 2016 +0200
gtkrevealer: support minimum size of child
GtkRevealer always allocates the natural size of the child so the
bin_window can take care of the animation with the full allocation of
the child.
However when GtkRevealer allocates the child doesn't take into
account the minimum size of the child. On the other hand it does take
into account the minimum size of the child when reporting the preferred
size to the parent of the GtkRevealer.
This behaviour clips the child of the GtkRevealer if the parent
allocates less than the natural size.
To fix this inconsistency, the patch makes the child adapt the
allocation of the GtkRevealer as long as it's not under the minimum
size of the child.
Note that it no longer takes into account the animation type to report
the child size. I don't think that part is necessary.
https://bugzilla.gnome.org/show_bug.cgi?id=767722
gtk/Makefile.am | 2 +
gtk/gtkpathbar.c | 2 +
gtk/gtkpathbarbox.c | 138 +++++++++++++++++++
gtk/{gtkpathbarbox.h => gtkpathbarboxprivate.h} | 14 +-
gtk/gtkpathbarcontainer.c | 165 +++++++++++++++++------
gtk/gtkpathbarcontainer.h | 16 +++
gtk/gtkrevealer.c | 32 +++--
gtk/ui/gtkpathbar.ui | 4 +-
gtkpathbarbox.c | 106 ---------------
tests/testpathbar.c | 2 +
10 files changed, 308 insertions(+), 173 deletions(-)
---
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 895019d..fb0ef03 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -522,6 +522,7 @@ gtk_private_h_sources = \
gtkorientableprivate.h \
gtkpathbarcontainer.h \
gtkpango.h \
+ gtkpathbarboxprivate.h \
gtkplacessidebarprivate.h \
gtkplacesviewprivate.h \
gtkplacesviewrowprivate.h \
@@ -836,6 +837,7 @@ gtk_base_c_sources = \
gtkpapersize.c \
gtkpathbar.c \
gtkpathbarcontainer.c \
+ gtkpathbarbox.c \
gtkplacessidebar.c \
gtkplacesview.c \
gtkplacesviewrow.c \
diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c
index 56c2347..ec58bfb 100644
--- a/gtk/gtkpathbar.c
+++ b/gtk/gtkpathbar.c
@@ -32,6 +32,7 @@
#include "gtkpopover.h"
#include "gtkbuilder.h"
#include "gtkstylecontext.h"
+#include "gtkpathbarboxprivate.h"
#include "gtkintl.h"
#include "gtkmarshalers.h"
@@ -724,6 +725,7 @@ gtk_path_bar_init (GtkPathBar *self)
{
GtkPathBarPrivate *priv = gtk_path_bar_get_instance_private (self);
+ g_type_ensure (GTK_TYPE_PATH_BAR_BOX);
g_type_ensure (GTK_TYPE_PATH_BAR_CONTAINER);
gtk_widget_init_template (GTK_WIDGET (self));
diff --git a/gtk/gtkpathbarbox.c b/gtk/gtkpathbarbox.c
new file mode 100644
index 0000000..1ccff6f
--- /dev/null
+++ b/gtk/gtkpathbarbox.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2016 Carlos Soriano <csoriano gnome org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#include "glib.h"
+
+#include "gtkpathbarboxprivate.h"
+#include "gtkpathbarcontainer.h"
+#include "gtkwidgetprivate.h"
+#include "gtkintl.h"
+#include "gtksizerequest.h"
+#include "gtkbuildable.h"
+#include "gtkrevealer.h"
+
+G_DEFINE_TYPE (GtkPathBarBox, gtk_path_bar_box, GTK_TYPE_BOX)
+
+static void
+gtk_path_bar_box_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ GtkPathBarBox *self = GTK_PATH_BAR_BOX (widget);
+ GList *children;
+ GList *child;
+ GtkRequisition child_available_size;
+ GtkRequestedSize *sizes;
+ GtkAllocation child_allocation;
+ gint available_size;
+ gint n_visible_children = 0;
+ gint current_x = 0;
+ gint i;
+ GtkRequisition minimum_size;
+ GtkRequisition natural_size;
+
+ gtk_widget_get_preferred_size (widget, &minimum_size, &natural_size);
+
+ if (natural_size.width <= allocation->width)
+ {
+ GTK_WIDGET_CLASS (gtk_path_bar_box_parent_class)->size_allocate (widget, allocation);
+
+ return;
+ }
+
+ gtk_widget_set_allocation (widget, allocation);
+
+ available_size = allocation->width;
+ children = gtk_container_get_children (GTK_CONTAINER (self));
+ sizes = g_newa (GtkRequestedSize, g_list_length (children));
+
+ for (child = children, i = 0; child != NULL; child = g_list_next (child), i++)
+ {
+ if (!gtk_widget_get_visible (child->data))
+ continue;
+
+ gtk_widget_get_preferred_width_for_height (child->data,
+ allocation->height,
+ &sizes[i].minimum_size,
+ &sizes[i].natural_size);
+ sizes[i].data = child->data;
+ available_size -= sizes[i].minimum_size;
+ n_visible_children++;
+ }
+
+ g_print ("child sizing pathbar %d %d\n", sizes[2].minimum_size, sizes[2].natural_size);
+ gtk_distribute_natural_allocation (MAX (0, available_size),
+ n_visible_children, sizes);
+
+ g_print ("child sizing pathbar %d %d\n", sizes[2].minimum_size, sizes[2].natural_size);
+
+ for (child = children, i = 0; child != NULL; child = g_list_next (child), i++)
+ {
+ if (!gtk_widget_get_visible (child->data))
+ continue;
+
+ child_available_size.width = sizes[i].minimum_size;
+ child_available_size.height = allocation->height;
+
+ g_print ("child sizing 1 %d %d\n", child_available_size.width, sizes[i].minimum_size);
+ if (GTK_IS_PATH_BAR_CONTAINER (child->data))
+ {
+ gtk_path_bar_container_get_preferred_size_for_requisition (GTK_WIDGET (child->data),
+ &child_available_size,
+ &minimum_size,
+ &natural_size);
+
+ sizes[i].minimum_size = MIN (child_available_size.width, natural_size.width);
+ }
+ g_print ("child sizing after %d %d\n", child_available_size.width, sizes[i].minimum_size);
+
+ child_allocation.x = current_x;
+ child_allocation.y = 0;
+ child_allocation.width = sizes[i].minimum_size;
+ child_allocation.height = allocation->height;
+
+ gtk_widget_size_allocate (child->data, &child_allocation);
+
+ current_x += sizes[i].minimum_size;
+ }
+
+ g_print ("\n\n\n");
+}
+
+static void
+gtk_path_bar_box_init (GtkPathBarBox *self)
+{
+}
+
+static void
+gtk_path_bar_box_class_init (GtkPathBarBoxClass *class)
+{
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
+
+ widget_class->size_allocate = gtk_path_bar_box_size_allocate;
+}
+
+GtkWidget *
+gtk_path_bar_box_new (void)
+{
+ return g_object_new (GTK_TYPE_PATH_BAR_BOX, NULL);
+}
+
diff --git a/gtk/gtkpathbarbox.h b/gtk/gtkpathbarboxprivate.h
similarity index 88%
rename from gtk/gtkpathbarbox.h
rename to gtk/gtkpathbarboxprivate.h
index 4be460f..fe98aa7 100644
--- a/gtk/gtkpathbarbox.h
+++ b/gtk/gtkpathbarboxprivate.h
@@ -1,4 +1,4 @@
-/* gtkpathbarbox.h
+/* gtkpathbarboxprivate.h
*
* Copyright (C) 2016 Carlos Soriano <csoriano gnome org>
*
@@ -15,13 +15,14 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef __GTK_PATH_BAR_BOX_H__
-#define __GTK_PATH_BAR_BOX_H__
+#ifndef __GTK_PATH_BAR_BOX_PRIVATE_H__
+#define __GTK_PATH_BAR_BOX_PRIVATE_H__
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif
+#include "gtkwidget.h"
#include <gtk/gtkbox.h>
G_BEGIN_DECLS
@@ -35,11 +36,10 @@ G_BEGIN_DECLS
typedef struct _GtkPathBarBox GtkPathBarBox;
typedef struct _GtkPathBarBoxClass GtkPathBarBoxClass;
-typedef struct _GtkPathBarBoxPrivate GtkPathBarBoxPrivate;
struct _GtkPathBarBoxClass
{
- GtkBoxClass parent;
+ GtkBoxClass parent_class;
/* Padding for future expansion */
gpointer reserved[10];
@@ -50,12 +50,10 @@ struct _GtkPathBarBox
GtkBox parent_instance;
};
-GDK_AVAILABLE_IN_3_20
GType gtk_path_bar_box_get_type (void) G_GNUC_CONST;
-GDK_AVAILABLE_IN_3_20
GtkWidget *gtk_path_bar_box_new (void);
G_END_DECLS
-#endif /* GTK_PATH_BAR_BOX_H_ */
+#endif /* GTK_PATH_BAR_BOX_PRIVATE_H_ */
diff --git a/gtk/gtkpathbarcontainer.c b/gtk/gtkpathbarcontainer.c
index 4b835d5..24c77f7 100644
--- a/gtk/gtkpathbarcontainer.c
+++ b/gtk/gtkpathbarcontainer.c
@@ -33,7 +33,7 @@
//TODO remove
#include "gtkbutton.h"
-#define REVEALER_ANIMATION_TIME 250 //ms
+#define REVEALER_ANIMATION_TIME 2000 //ms
#define INVERT_ANIMATION_SPEED 1.2 //px/ms
#define INVERT_ANIMATION_MAX_TIME 750 //px/ms
@@ -128,6 +128,8 @@ gtk_path_bar_container_add (GtkPathBarContainer *self,
GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT);
gtk_container_add (GTK_CONTAINER (revealer), widget);
gtk_container_add (GTK_CONTAINER (priv->children_box), revealer);
+ gtk_revealer_set_transition_duration (GTK_REVEALER (revealer),
+ REVEALER_ANIMATION_TIME);
priv->children = g_list_append (priv->children, widget);
gtk_widget_show_all (revealer);
}
@@ -189,29 +191,28 @@ gtk_path_bar_container_remove (GtkPathBarContainer *self,
gtk_widget_queue_resize (GTK_WIDGET (self));
}
-static GtkAllocation*
-get_children_allocation (GtkPathBarContainer *self,
- gboolean inverted)
+static gboolean
+get_children_preferred_size_for_requisition (GtkPathBarContainer *self,
+ GtkRequisition *available_size,
+ gboolean inverted,
+ GtkRequisition *minimum_size,
+ GtkRequisition *natural_size)
{
GtkPathBarContainerPrivate *priv = gtk_path_bar_container_get_instance_private (self);
- GtkAllocation *children_allocation;
- GtkAllocation *allocation;
GtkWidget *child_widget;
GList *child;
- GtkRequestedSize *sizes_temp;
+ GtkRequestedSize child_width;
+ GtkRequestedSize child_height;
+ GtkAllocation revealer_allocation;
+ GtkWidget *widget;
gint i;
GList *children;
gint current_children_min_width = 0;
gint current_children_nat_width = 0;
+ gint current_children_min_height = 0;
+ gint current_children_nat_height = 0;
children = g_list_copy (priv->children);
- sizes_temp = g_newa (GtkRequestedSize, g_list_length (priv->children));
- allocation = g_new (GtkAllocation, 1);
- gtk_widget_get_allocation (GTK_WIDGET (self), allocation);
- children_allocation = g_new (GtkAllocation, 1);
- children_allocation->x = 0;
- children_allocation->y = 0;
- children_allocation->height = allocation->height;
if (inverted)
children = g_list_reverse (children);
@@ -221,32 +222,54 @@ get_children_allocation (GtkPathBarContainer *self,
{
child_widget = GTK_WIDGET (child->data);
+ gtk_widget_get_allocation (gtk_widget_get_parent (child_widget),
+ &revealer_allocation);
/* If we are in the middle of a revealer animation, get the revealer
* allocation */
- gtk_widget_get_preferred_width_for_height (gtk_widget_get_parent (child_widget),
- allocation->height,
- &sizes_temp[i].minimum_size,
- &sizes_temp[i].natural_size);
+ if (revealer_allocation.width > 1)
+ widget = gtk_widget_get_parent (child_widget);
+ else
+ widget = child_widget;
+
+ gtk_widget_get_preferred_width_for_height (widget,
+ available_size->height,
+ &child_width.minimum_size,
+ &child_width.natural_size);
- current_children_min_width += sizes_temp[i].minimum_size;
- current_children_nat_width += sizes_temp[i].natural_size;
- if (current_children_min_width > allocation->width)
+ gtk_widget_get_preferred_height_for_width (widget,
+ current_children_nat_width,
+ &child_height.minimum_size,
+ &child_height.natural_size);
+
+ current_children_min_height = MAX (current_children_min_height, child_height.minimum_size);
+ current_children_nat_height = MAX (current_children_nat_height, child_height.natural_size);
+
+ current_children_min_width += child_width.minimum_size;
+ current_children_nat_width += child_width.natural_size;
+ if (current_children_min_width > available_size->width)
{
- current_children_min_width -= sizes_temp[i].minimum_size;
- current_children_nat_width -= sizes_temp[i].natural_size;
+ current_children_min_width -= child_width.minimum_size;
+ current_children_nat_width -= child_width.natural_size;
break;
}
}
- if (current_children_nat_width > allocation->width)
- children_allocation->width = current_children_min_width;
- else
- children_allocation->width = current_children_nat_width;
+ if (minimum_size)
+ {
+ minimum_size->width = current_children_min_width;
+ minimum_size->height = current_children_min_height;
+ }
+ if (natural_size)
+ {
+ natural_size->width = current_children_nat_width;
+ natural_size->height = current_children_nat_height;
+ }
+
+g_print ("natural sizing %d\n", natural_size->width);
g_list_free (children);
- g_free (allocation);
- return children_allocation;
+ return current_children_nat_width > available_size->width;
}
static void
@@ -432,27 +455,43 @@ static gint
get_max_scroll (GtkPathBarContainer *self)
{
GtkPathBarContainerPrivate *priv = gtk_path_bar_container_get_instance_private (self);
- GtkAllocation *used_children_allocation;
+ GtkRequisition children_used_min_size;
+ GtkRequisition children_used_nat_size;
+ gboolean overflows;
+ GtkAllocation allocation;
+ GtkRequisition available_size;
gint children_width;
+ gint children_used_width;
gdouble max_scroll;
- used_children_allocation = get_children_allocation (self, TRUE);
+
+ gtk_widget_get_allocation (GTK_WIDGET (self), &allocation);
+ available_size.width = allocation.width;
+ available_size.height = allocation.height;
+ overflows = get_children_preferred_size_for_requisition (self, &available_size,
+ TRUE,
+ &children_used_min_size,
+ &children_used_nat_size);
+
+ children_used_width = overflows ? MAX (children_used_min_size.width, allocation.width) :
+ children_used_nat_size.width;
+
children_width = gtk_widget_get_allocated_width (priv->children_box);
if (priv->invert_animation)
{
if (priv->inverted)
{
- max_scroll = MAX (0, children_width - used_children_allocation->width);
+ max_scroll = MAX (0, children_width - children_used_width);
}
else
{
- max_scroll = children_width - used_children_allocation->width;
+ max_scroll = children_width - children_used_width;
}
}
else
{
- max_scroll = MAX (0, children_width - used_children_allocation->width);
+ max_scroll = MAX (0, children_width - children_used_width);
}
return max_scroll;
@@ -602,7 +641,6 @@ invert_animation_on_tick (GtkWidget *widget,
guint64 elapsed;
gint max_scroll;
double animation_speed;
- GtkAllocation *used_children_allocation;
GtkAllocation child_allocation;
GtkAllocation allocation;
@@ -612,7 +650,6 @@ invert_animation_on_tick (GtkWidget *widget,
gtk_widget_get_allocation (GTK_WIDGET (self), &allocation);
gtk_widget_get_allocation (priv->children_box, &child_allocation);
- used_children_allocation = get_children_allocation (self, TRUE);
max_scroll = get_max_scroll (self);
if (!max_scroll)
@@ -628,7 +665,7 @@ invert_animation_on_tick (GtkWidget *widget,
elapsed = gdk_frame_clock_get_frame_time (frame_clock) - priv->invert_animation_initial_time;
priv->invert_animation_progress = MIN (1, elapsed * animation_speed / (1000. * max_scroll));
- g_print ("################animation progres %d %d %d %f %f\n", gtk_widget_get_allocated_width (GTK_WIDGET
(self)), used_children_allocation->width, max_scroll, elapsed / 1000., priv->invert_animation_progress);
+ g_print ("################animation progres %d %d %f %f\n", gtk_widget_get_allocated_width (GTK_WIDGET
(self)), max_scroll, elapsed / 1000., priv->invert_animation_progress);
update_scrolling (self);
if (priv->invert_animation_progress >= 1)
@@ -676,8 +713,8 @@ start_invert_animation (GtkPathBarContainer *self)
static void
gtk_path_bar_container_get_preferred_width (GtkWidget *widget,
- gint *minimum_width,
- gint *natural_width)
+ gint *minimum_width,
+ gint *natural_width)
{
GtkPathBarContainer *self = GTK_PATH_BAR_CONTAINER (widget);
GtkPathBarContainerPrivate *priv = gtk_path_bar_container_get_instance_private (self);
@@ -796,9 +833,13 @@ gtk_path_bar_container_realize (GtkWidget *widget)
GtkPathBarContainer *self = GTK_PATH_BAR_CONTAINER (widget);
GtkPathBarContainerPrivate *priv = gtk_path_bar_container_get_instance_private (self);
GtkAllocation allocation;
- GtkAllocation *children_allocation;
GdkWindowAttr attributes = { 0 };
GdkWindowAttributesType attributes_mask;
+ GtkRequisition children_used_min_size;
+ GtkRequisition children_used_nat_size;
+ GtkRequisition available_size;
+ gboolean overflows;
+ gint children_used_width;
gtk_widget_set_realized (widget, TRUE);
@@ -819,11 +860,19 @@ gtk_path_bar_container_realize (GtkWidget *widget)
gtk_widget_set_window (widget, priv->view_window);
gtk_widget_register_window (widget, priv->view_window);
- children_allocation = get_children_allocation (self, priv->inverted);
+ available_size.width = allocation.width;
+ available_size.height = allocation.height;
+ overflows = get_children_preferred_size_for_requisition (self, &available_size,
+ priv->inverted,
+ &children_used_min_size,
+ &children_used_nat_size);
+
+ children_used_width = overflows ? MAX (children_used_min_size.width, allocation.width) :
+ children_used_nat_size.width;
attributes.x = 0;
attributes.y = 0;
- attributes.width = children_allocation->width;
- attributes.height = children_allocation->height;
+ attributes.width = children_used_width;
+ attributes.height = children_used_nat_size.height;
priv->bin_window = gdk_window_new (priv->view_window, &attributes,
attributes_mask);
@@ -851,6 +900,34 @@ gtk_path_bar_container_draw (GtkWidget *widget,
return GDK_EVENT_PROPAGATE;
}
+static gboolean
+real_get_preferred_size_for_requisition (GtkWidget *widget,
+ GtkRequisition *available_size,
+ GtkRequisition *minimum_size,
+ GtkRequisition *natural_size)
+{
+ GtkPathBarContainer *self = GTK_PATH_BAR_CONTAINER (widget);
+ GtkPathBarContainerPrivate *priv = gtk_path_bar_container_get_instance_private (self);
+
+ return get_children_preferred_size_for_requisition (self, available_size,
+ priv->inverted,
+ minimum_size,
+ natural_size);
+}
+
+gboolean
+gtk_path_bar_container_get_preferred_size_for_requisition (GtkWidget *widget,
+ GtkRequisition *available_size,
+ GtkRequisition *minimum_size,
+ GtkRequisition *natural_size)
+{
+
+ return real_get_preferred_size_for_requisition (widget,
+ available_size,
+ minimum_size,
+ natural_size);
+}
+
static void
gtk_path_bar_container_init (GtkPathBarContainer *self)
{
@@ -895,6 +972,8 @@ gtk_path_bar_container_class_init (GtkPathBarContainerClass *class)
container_class->add = gtk_path_bar_container_container_add;
container_class->remove = gtk_path_bar_container_container_remove;
+ class->get_preferred_size_for_requisition = real_get_preferred_size_for_requisition;
+
path_bar_container_properties[PROP_INVERTED] =
g_param_spec_int ("inverted",
_("Direction of hiding children inverted"),
diff --git a/gtk/gtkpathbarcontainer.h b/gtk/gtkpathbarcontainer.h
index e9381ea..2f34ed4 100644
--- a/gtk/gtkpathbarcontainer.h
+++ b/gtk/gtkpathbarcontainer.h
@@ -44,6 +44,16 @@ struct _GtkPathBarContainerClass
{
GtkBinClass parent;
+ /* Get the preferred size for a specific allocation, assuming the container
+ * manages overflow. The return value indicates whether the container children
+ * overflow and the container reports preferred size for the non overflowing
+ * children or the ones the container consider that are going to be visible
+ */
+ gboolean (* get_preferred_size_for_requisition) (GtkWidget *widget,
+ GtkRequisition *available_size,
+ GtkRequisition *minimum_size,
+ GtkRequisition *natural_size);
+
/* Padding for future expansion */
gpointer reserved[10];
};
@@ -93,6 +103,12 @@ GList* gtk_path_bar_container_get_children (GtkPathBarCont
GDK_AVAILABLE_IN_3_20
gint gtk_path_bar_container_get_unused_width (GtkPathBarContainer *self);
+GDK_AVAILABLE_IN_3_20
+gboolean gtk_path_bar_container_get_preferred_size_for_requisition (GtkWidget
*widget,
+ GtkRequisition
*available_size,
+ GtkRequisition
*minimum_size,
+ GtkRequisition
*natural_size);
+
G_END_DECLS
#endif /* GTK_PATH_BAR_CONTAINER_H_ */
diff --git a/gtk/gtkrevealer.c b/gtk/gtkrevealer.c
index b23f66a..3d7e4d8 100644
--- a/gtk/gtkrevealer.c
+++ b/gtk/gtkrevealer.c
@@ -308,9 +308,11 @@ gtk_revealer_get_child_allocation (GtkRevealer *revealer,
GtkAllocation *child_allocation)
{
GtkWidget *child;
- GtkRevealerTransitionType transition;
GtkBorder padding;
gint vertical_padding, horizontal_padding;
+ GtkRequisition minimum_size;
+ GtkRequisition natural_size;
+
g_return_if_fail (revealer != NULL);
g_return_if_fail (allocation != NULL);
@@ -327,19 +329,21 @@ gtk_revealer_get_child_allocation (GtkRevealer *revealer,
child = gtk_bin_get_child (GTK_BIN (revealer));
if (child != NULL && gtk_widget_get_visible (child))
- {
- transition = effective_transition (revealer);
- if (transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT ||
- transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT)
- gtk_widget_get_preferred_width_for_height (child, MAX (0, allocation->height - vertical_padding),
NULL,
- &child_allocation->width);
- else
- gtk_widget_get_preferred_height_for_width (child, MAX (0, allocation->width - horizontal_padding),
NULL,
- &child_allocation->height);
- }
+ gtk_widget_get_preferred_size (child, &minimum_size, &natural_size);
+
+ if (natural_size.width > allocation->width - horizontal_padding)
+ child_allocation->width = CLAMP (allocation->width - horizontal_padding,
+ minimum_size.width,
+ natural_size.width);
+ else
+ child_allocation->width = allocation->width - horizontal_padding;
- child_allocation->width = MAX (child_allocation->width, allocation->width - horizontal_padding);
- child_allocation->height = MAX (child_allocation->height, allocation->height - vertical_padding);
+ if (natural_size.height > allocation->height - vertical_padding)
+ child_allocation->height = CLAMP (allocation->height - vertical_padding,
+ minimum_size.height,
+ natural_size.height);
+ else
+ child_allocation->height = allocation->height - vertical_padding;
}
static void
diff --git a/gtk/ui/gtkpathbar.ui b/gtk/ui/gtkpathbar.ui
index 61fe219..679e772 100644
--- a/gtk/ui/gtkpathbar.ui
+++ b/gtk/ui/gtkpathbar.ui
@@ -5,7 +5,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkBox" id="path_bar_1">
+ <object class="GtkPathBarBox" id="path_bar_1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
@@ -91,7 +91,7 @@
</packing>
</child>
<child>
- <object class="GtkBox" id="path_bar_2">
+ <object class="GtkPathBarBox" id="path_bar_2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
diff --git a/tests/testpathbar.c b/tests/testpathbar.c
index 31c4922..87ab983 100644
--- a/tests/testpathbar.c
+++ b/tests/testpathbar.c
@@ -255,6 +255,7 @@ main (int argc, char *argv[])
gtk_path_bar_set_path (GTK_PATH_BAR (path_bar), ORIGINAL_PATH);
connect_path_bar (GTK_PATH_BAR (path_bar));
+#if 0
/* ----------------------------------------------------------------------- */
path_bar_inverted = gtk_path_bar_new ();
gtk_path_bar_set_inverted (GTK_PATH_BAR (path_bar_inverted), TRUE);
@@ -321,6 +322,7 @@ main (int argc, char *argv[])
G_CALLBACK (on_reset_button_clicked), window);
gtk_grid_attach (GTK_GRID (grid), reset_button, 0, 11, 2, 1);
+#endif
gtk_container_add (GTK_CONTAINER (window), grid);
gtk_widget_show_all (window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]