summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2016-05-11 17:19:52 +0200
committerCarlos Soriano <csoriano@gnome.org>2016-05-30 17:52:46 +0200
commit852c89aa5e73abdcaea37b9e44a8917b5b41411f (patch)
tree934ad35ce1d332a2b97da3fa61aa5f14984a3ea7
parentacf2652f88e063d640e2995d019ed9a4759e50f1 (diff)
downloadgtk+-wip/csoriano/pathbar-prototype.tar.gz
experiment with revealerswip/csoriano/pathbar-prototype
-rw-r--r--gtk/Makefile.am2
-rw-r--r--gtk/gtk.h1
-rw-r--r--gtk/gtkbox.c5
-rw-r--r--gtk/gtkgrid.c8
-rw-r--r--gtk/gtkhidingbox.c378
-rw-r--r--gtk/gtkhidingbox.h (renamed from gtk/gtkhidingboxprivate.h)6
-rw-r--r--gtk/gtkpathbar.c2
-rw-r--r--gtk/gtkpathbarcontainer.c2
-rw-r--r--gtk/gtkrevealer.c1
-rw-r--r--gtk/theme/Adwaita/_common.scss14
-rw-r--r--gtk/theme/Adwaita/gtk-contained-dark.css11
-rw-r--r--gtk/theme/Adwaita/gtk-contained.css11
-rw-r--r--tests/Makefile.am5
-rw-r--r--tests/testhidingbox.c88
14 files changed, 411 insertions, 123 deletions
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index d91fbbd08d..e230d1c8fe 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -489,7 +489,7 @@ gtk_private_h_sources = \
gtkgestureswipeprivate.h \
gtkgesturezoomprivate.h \
gtkheaderbarprivate.h \
- gtkhidingboxprivate.h \
+ gtkhidingbox.h \
gtkhslaprivate.h \
gtkiconcache.h \
gtkiconhelperprivate.h \
diff --git a/gtk/gtk.h b/gtk/gtk.h
index 5e336e7c69..3fb9c675ce 100644
--- a/gtk/gtk.h
+++ b/gtk/gtk.h
@@ -121,6 +121,7 @@
#include <gtk/gtkglarea.h>
#include <gtk/gtkgrid.h>
#include <gtk/gtkheaderbar.h>
+#include <gtk/gtkhidingbox.h>
#include <gtk/gtkicontheme.h>
#include <gtk/gtkiconview.h>
#include <gtk/gtkimage.h>
diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c
index 93206cf403..bcf82205ab 100644
--- a/gtk/gtkbox.c
+++ b/gtk/gtkbox.c
@@ -479,7 +479,12 @@ count_expand_children (GtkBox *box,
{
*visible_children += 1;
if (child->expand || gtk_widget_compute_expand (child->widget, private->orientation))
+ {
+
+ if (GTK_IS_REVEALER (child->widget))
+ g_print ("########################## IT IS\n");
*expand_children += 1;
+ }
}
}
}
diff --git a/gtk/gtkgrid.c b/gtk/gtkgrid.c
index 5fed33fe2d..a7e2c50e31 100644
--- a/gtk/gtkgrid.c
+++ b/gtk/gtkgrid.c
@@ -29,6 +29,7 @@
#include "gtkcontainerprivate.h"
#include "gtkcsscustomgadgetprivate.h"
#include "gtkprivate.h"
+#include "gtkrevealer.h"
#include "gtkintl.h"
@@ -1000,7 +1001,12 @@ gtk_grid_request_compute_expand (GtkGridRequest *request,
line = &lines->lines[attach->pos - lines->min];
line->empty = FALSE;
if (gtk_widget_compute_expand (child->widget, orientation))
+ {
+
+ if (GTK_IS_REVEALER (child->widget))
+ g_print ("########################## IT IS\n");
line->expand = TRUE;
+ }
}
for (list = priv->children; list; list = list->next)
@@ -1030,6 +1036,8 @@ gtk_grid_request_compute_expand (GtkGridRequest *request,
if (!has_expand && gtk_widget_compute_expand (child->widget, orientation))
{
+ if (GTK_IS_REVEALER (child->widget))
+ g_print ("########################## IT IS\n");
for (i = 0; i < attach->span; i++)
{
if (attach->pos + i >= max || attach->pos + 1 < min)
diff --git a/gtk/gtkhidingbox.c b/gtk/gtkhidingbox.c
index ac45efd4a7..0a49402379 100644
--- a/gtk/gtkhidingbox.c
+++ b/gtk/gtkhidingbox.c
@@ -24,15 +24,23 @@
#include "config.h"
-#include "gtkhidingboxprivate.h"
+#include "gtkhidingbox.h"
#include "gtkwidgetprivate.h"
#include "gtkintl.h"
#include "gtksizerequest.h"
#include "gtkbuildable.h"
#include "gtkrevealer.h"
+#include "gtkadjustment.h"
+#include "gtkscrolledwindow.h"
+#include "gtkbox.h"
+
+//TODO remove
+#include "gtkbutton.h"
#include "glib.h"
+#define INVERT_ANIMATION_TIME 500 //ms
+
typedef enum {
ANIMATION_PHASE_NONE,
ANIMATION_PHASE_OUT,
@@ -53,15 +61,32 @@ struct _GtkHidingBoxPrivate
gint current_width;
gint current_height;
guint needs_update :1;
+
+ gboolean invert_animation;
+
+ GtkWidget *scrolled_window;
+ GtkWidget *box;
+ GtkAdjustment *hadjustment;
+
+ guint tick_id;
+ guint64 initial_time;
};
static void
+gtk_hiding_box_buildable_init (GtkBuildableIface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (GtkHidingBox, gtk_hiding_box, GTK_TYPE_CONTAINER,
+ G_ADD_PRIVATE (GtkHidingBox)
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_hiding_box_buildable_init))
+
+
+static void
gtk_hiding_box_buildable_add_child (GtkBuildable *buildable,
GtkBuilder *builder,
GObject *child,
const gchar *type)
{
- GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (box);
+ GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (buildable);
if (!type)
{
@@ -80,10 +105,6 @@ gtk_hiding_box_buildable_init (GtkBuildableIface *iface)
iface->add_child = gtk_hiding_box_buildable_add_child;
}
-G_DEFINE_TYPE_WITH_CODE (GtkHidingBox, gtk_hiding_box, GTK_TYPE_CONTAINER,
- G_ADD_PRIVATE (GtkHidingBox)
- G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_hiding_box_buildable_init))
-
enum {
PROP_0,
PROP_SPACING,
@@ -145,39 +166,62 @@ gtk_hiding_box_add (GtkContainer *container,
GtkHidingBox *box = GTK_HIDING_BOX (container);
GtkWidget *revealer;
GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (box);
+ GtkStyleContext *style_context;
revealer = gtk_revealer_new ();
+ style_context = gtk_widget_get_style_context (revealer);
+ gtk_style_context_add_class (style_context, "pathbar-initial-opacity");
+ gtk_revealer_set_transition_type (GTK_REVEALER (revealer),
+ GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT);
gtk_container_add (GTK_CONTAINER (revealer), widget);
- gtk_revealer_set_reveal_child (GTK_REVEALER (revealer), FALSE);
- priv->children = g_list_append (priv->children, revealer);
- gtk_widget_set_parent (revealer, GTK_WIDGET (box));
+ g_print ("box fine? %s \n", G_OBJECT_TYPE_NAME (priv->box));
+ gtk_container_add (GTK_CONTAINER (priv->box), revealer);
+ priv->children = g_list_append (priv->children, widget);
+ gtk_widget_show (revealer);
+
+ g_print ("add\n");
}
static void
-really_remove_child (GtkContainer *container,
+really_remove_child (GtkHidingBox *self,
GtkWidget *widget)
{
GList *child;
- GtkHidingBox *box = GTK_HIDING_BOX (container);
- GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (box);
+ GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (self);
- for (child = priv->children; child != NULL; child = child->next)
+ g_print ("really remove child %p %s\n", widget, gtk_button_get_label (GTK_BUTTON (widget)));
+ for (child = priv->widgets_to_remove; child != NULL; child = child->next)
{
- if (child->data == widget)
+ GtkWidget *revealer;
+
+ revealer = gtk_widget_get_parent (child->data);
+ g_print ("aver %p\n", child->data);
+ if (child->data == widget && !gtk_revealer_get_child_revealed (GTK_REVEALER (revealer)))
{
- gboolean was_visible = gtk_widget_get_visible (widget) &&
- gtk_widget_get_child_visible (widget);
+ g_print ("############################## INSIDE\n");
+ gboolean was_visible = gtk_widget_get_visible (widget);
- gtk_widget_unparent (widget);
- priv->children = g_list_delete_link (priv->children, child);
+ priv->widgets_to_remove = g_list_remove (priv->widgets_to_remove,
+ child->data);
+ gtk_container_remove (GTK_CONTAINER (priv->box), revealer);
if (was_visible)
- gtk_widget_queue_resize (GTK_WIDGET (container));
+ gtk_widget_queue_resize (GTK_WIDGET (self));
break;
}
}
+}
+
+static void
+unrevealed_really_remove_child (GObject *widget,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ GtkHidingBox *self = GTK_HIDING_BOX (user_data);
+ g_print ("unrevelaed really remove child %p %s\n", widget, G_OBJECT_TYPE_NAME (widget));
+ really_remove_child (self, gtk_bin_get_child (GTK_BIN (widget)));
}
static void
@@ -187,8 +231,16 @@ gtk_hiding_box_remove (GtkContainer *container,
GList *child;
GtkHidingBox *box = GTK_HIDING_BOX (container);
GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (box);
+ GtkWidget *to_remove;
+
+ g_print ("remove %p %s\n", widget, G_OBJECT_TYPE_NAME (widget));
+ if (GTK_IS_REVEALER (widget) && gtk_widget_get_parent (widget) == priv->box)
+ to_remove = gtk_bin_get_child (widget);
+ else
+ to_remove = widget;
- priv->widgets_to_remove = g_list_append (priv->widgets_to_remove, gtk_widget_get_parent (widget));
+ priv->widgets_to_remove = g_list_append (priv->widgets_to_remove, to_remove);
+ priv->children = g_list_remove (priv->children, to_remove);
priv->needs_update = TRUE;
gtk_widget_queue_resize (GTK_WIDGET (container));
}
@@ -201,16 +253,18 @@ gtk_hiding_box_forall (GtkContainer *container,
{
GtkHidingBox *box = GTK_HIDING_BOX (container);
GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (box);
- GtkWidget *child;
- GList *children;
+ GList *child;
- children = priv->children;
- while (children)
- {
- child = children->data;
- children = children->next;
- (* callback) (child, callback_data);
- }
+ for (child = priv->children; child != NULL; child = child->next)
+ (* callback) (child->data, callback_data);
+
+ if (include_internals)
+ {
+ (* callback) (priv->scrolled_window, callback_data);
+
+ for (child = priv->widgets_to_remove; child != NULL; child = child->next)
+ (* callback) (child->data, callback_data);
+ }
}
static void
@@ -259,11 +313,6 @@ update_children_visibility (GtkHidingBox *box,
for (i = 0, child = children; child != NULL; i++, child = child->next)
{
child_widget = GTK_WIDGET (child->data);
- if (!gtk_widget_get_visible (child_widget) || !allocate_more_children)
- {
- priv->widgets_to_hide = g_list_append (priv->widgets_to_hide, child_widget);
- continue;
- }
gtk_widget_get_preferred_width_for_height (child_widget,
allocation->height,
@@ -284,17 +333,21 @@ update_children_visibility (GtkHidingBox *box,
*children_size += sizes_temp[i].minimum_size + priv->spacing;
sizes_temp[i].data = child_widget;
- if (*children_size > allocation->width)
+ if (!allocate_more_children || *children_size > allocation->width)
{
allocate_more_children = FALSE;
- priv->widgets_to_hide = g_list_append (priv->widgets_to_hide, child_widget);
+ if (gtk_revealer_get_child_revealed (GTK_REVEALER (gtk_widget_get_parent (child_widget))))
+ priv->widgets_to_hide = g_list_append (priv->widgets_to_hide, child_widget);
+
continue;
}
if (gtk_widget_get_hexpand (child_widget))
(n_visible_children_expanding)++;
(n_visible_children)++;
- priv->widgets_to_show = g_list_append (priv->widgets_to_show, child_widget);
+
+ if (!g_list_find (priv->widgets_to_remove, child_widget))
+ priv->widgets_to_show = g_list_append (priv->widgets_to_show, child_widget);
}
for (i = 0; i < n_visible_children; i++)
@@ -400,26 +453,102 @@ needs_update (GtkHidingBox *box,
}
static void
+opacity_on (GObject *widget,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (GTK_HIDING_BOX (user_data));
+
+ g_print ("############opacity on!!!!!\n");
+ g_signal_handlers_disconnect_by_func (widget, opacity_on, user_data);
+ priv->widgets_to_show = g_list_remove (priv->widgets_to_show,
+ gtk_bin_get_child (GTK_BIN (widget)));
+}
+
+static void
+opacity_off (GObject *widget,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (GTK_HIDING_BOX (user_data));
+
+ g_print ("############opacity off!!!!!\n");
+ g_signal_handlers_disconnect_by_func (widget, opacity_off, user_data);
+ priv->widgets_to_hide = g_list_remove (priv->widgets_to_hide,
+ gtk_bin_get_child (GTK_BIN (widget)));
+}
+
+static void
idle_update_revealers (GtkHidingBox *box)
{
GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (box);
- GList *children;
GList *l;
- for (l = priv->widgets_to_show; l != NULL; l = l->next)
+ for (l = priv->widgets_to_hide; l != NULL; l = l->next)
{
- gtk_revealer_set_reveal_child (GTK_REVEALER (l->data), TRUE);
+ GtkRevealer *revealer;
+
+ g_print ("update revealer hide %s\n", gtk_button_get_label (GTK_BUTTON (l->data)));
+ revealer = GTK_REVEALER (gtk_widget_get_parent (l->data));
+ if (gtk_revealer_get_reveal_child (revealer))
+ {
+ GtkStyleContext *style_context;
+
+ style_context = gtk_widget_get_style_context (GTK_WIDGET (revealer));
+ gtk_style_context_remove_class (style_context, "pathbar-initial-opacity");
+ gtk_style_context_remove_class (style_context, "pathbar-opacity-on");
+ gtk_style_context_add_class (style_context, "pathbar-opacity-off");
+ g_signal_connect (revealer, "notify::child-revealed", (GCallback) opacity_off, box);
+ gtk_revealer_set_reveal_child (revealer, FALSE);
+ }
}
- for (l = priv->widgets_to_hide; l != NULL; l = l->next)
+ for (l = priv->widgets_to_remove; l != NULL; l = l->next)
{
- gtk_revealer_set_reveal_child (GTK_REVEALER (l->data), FALSE);
+ GtkRevealer *revealer;
+
+ g_print ("update revealer remove %s\n", gtk_button_get_label (GTK_BUTTON (l->data)));
+ revealer = GTK_REVEALER (gtk_widget_get_parent (l->data));
+ if (gtk_revealer_get_child_revealed (revealer))
+ {
+ GtkStyleContext *style_context;
+
+ style_context = gtk_widget_get_style_context (GTK_WIDGET (revealer));
+ gtk_style_context_remove_class (style_context, "pathbar-initial-opacity");
+ gtk_style_context_remove_class (style_context, "pathbar-opacity-on");
+ gtk_style_context_add_class (style_context, "pathbar-opacity-off");
+ g_signal_connect (revealer, "notify::child-revealed",
+ (GCallback) unrevealed_really_remove_child, box);
+ gtk_revealer_set_reveal_child (revealer, FALSE);
+ }
+ else
+ {
+ g_print ("widget to remove NOT revealed %p\n", l->data);
+ really_remove_child (box, l->data);
+ }
}
- for (l = priv->widgets_to_remove; l != NULL; l = l->next)
+ if (priv->widgets_to_remove || priv->widgets_to_hide)
+ return;
+
+ for (l = priv->widgets_to_show; l != NULL; l = l->next)
{
- gtk_revealer_set_reveal_child (GTK_REVEALER (l->data), FALSE);
+ GtkRevealer *revealer;
+
+ revealer = GTK_REVEALER (gtk_widget_get_parent (l->data));
+ if (!gtk_revealer_get_reveal_child (revealer))
+ {
+ GtkStyleContext *style_context;
+
+ style_context = gtk_widget_get_style_context (GTK_WIDGET (revealer));
+ gtk_style_context_remove_class (style_context, "pathbar-opacity-off");
+ gtk_style_context_remove_class (style_context, "pathbar-initial-opacity");
+ gtk_style_context_add_class (style_context, "pathbar-opacity-on");
+ gtk_revealer_set_reveal_child (revealer, TRUE);
+ g_signal_connect (revealer, "notify::child-revealed", (GCallback) opacity_on, box);
+ }
}
+
}
static void
@@ -428,92 +557,105 @@ gtk_hiding_box_size_allocate (GtkWidget *widget,
{
GtkHidingBox *box = GTK_HIDING_BOX (widget);
GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (box);
- GtkTextDirection direction;
GtkAllocation child_allocation;
GtkRequestedSize *sizes;
- gint extra_space = 0;
- gint x = 0;
- gint i;
- GList *child;
- GtkWidget *child_widget;
- gint spacing = priv->spacing;
- gint n_visible_children = 0;
gint n_visible_children_expanding = 0;
gint children_size = 0;
gtk_widget_set_allocation (widget, allocation);
+
sizes = g_newa (GtkRequestedSize, g_list_length (priv->children));
+ update_children_visibility (box, allocation, sizes, FALSE, &children_size,
+ &n_visible_children_expanding);
- /*
- if (needs_update (box, allocation))
- {
- clear_animation_state (box);
- g_list_free (priv->widgets_shown);
- priv->widgets_shown = NULL;
+ idle_update_revealers (box);
- update_children_visibility (box, allocation, sizes, TRUE, &children_size,
- &n_visible_children_expanding);
- if (priv->animation_phase != ANIMATION_PHASE_NONE)
- {
- priv->animation_phase = ANIMATION_PHASE_NONE;
- }
- }
- else
- */
- {
+ child_allocation.x = allocation->x;
+ child_allocation.y = allocation->y;
+ child_allocation.width = allocation->width;
+ child_allocation.height = allocation->height;
+ gtk_widget_size_allocate (priv->scrolled_window, &child_allocation);
- update_children_visibility (box, allocation, sizes, FALSE, &children_size,
- &n_visible_children_expanding);
+ _gtk_widget_set_simple_clip (widget, NULL);
+}
- idle_update_revealers (box);
- }
+static void
+finish_invert_animation (GtkHidingBox *self)
+{
+ GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (self);
+ priv->invert_animation = FALSE;
+}
- /* If there is no visible child, simply return. */
- if (n_visible_children == 0)
- return;
- direction = gtk_widget_get_direction (widget);
+static void
+invert_animation_on_tick (GtkWidget *widget,
+ GdkFrameClock *frame_clock,
+ gpointer user_data)
+{
+ GtkHidingBox *self = GTK_HIDING_BOX (user_data);
+ GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (self);
+ guint64 elapsed;
+ gfloat progress;
+ gdouble adjustment_value;
- /* Bring children up to allocation width first */
- extra_space = allocation->width - (n_visible_children - 1) * spacing - children_size;
- extra_space = gtk_distribute_natural_allocation (MAX (0, extra_space), n_visible_children, sizes);
+ if (!priv->initial_time)
+ priv->initial_time = gdk_frame_clock_get_frame_time (frame_clock);
- /* Distribute extra space on the expanding children */
- if (n_visible_children > 1)
- extra_space = extra_space / MAX (1, n_visible_children_expanding);
+ elapsed = gdk_frame_clock_get_frame_time (frame_clock) - priv->initial_time;
+ progress = elapsed / INVERT_ANIMATION_TIME;
- x = allocation->x;
- for (i = 0, child = priv->children; child != NULL; child = child->next)
+ if (progress >= 1)
{
+ finish_invert_animation (self);
- child_widget = GTK_WIDGET (child->data);
- if (!gtk_revealer_get_reveal_child (GTK_REVEALER (child_widget)) &&
- !gtk_revealer_get_child_revealed (GTK_REVEALER (child_widget)))
- {
- gtk_widget_set_child_visible (child_widget, FALSE);
- continue;
- }
+ return;
+ }
- gtk_widget_set_child_visible (child_widget, TRUE);
- child_allocation.x = x;
- child_allocation.y = allocation->y;
- if (gtk_widget_get_hexpand (child_widget))
- child_allocation.width = sizes[i].minimum_size + extra_space;
- else
- child_allocation.width = sizes[i].minimum_size;
+ if (priv->inverted)
+ adjustment_value = 1 / (progress * (gtk_adjustment_get_lower (priv->hadjustment) - gtk_adjustment_get_upper (priv->hadjustment)));
+ else
+ adjustment_value = progress * (gtk_adjustment_get_lower (priv->hadjustment) - gtk_adjustment_get_upper (priv->hadjustment));
+
+ gtk_adjustment_set_value (priv->hadjustment, adjustment_value);
+}
- child_allocation.height = allocation->height;
- if (direction == GTK_TEXT_DIR_RTL)
- child_allocation.x = allocation->x + allocation->width - (child_allocation.x - allocation->x) - child_allocation.width;
+static void
+start_invert_animation (GtkHidingBox *self)
+{
+ GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (self);
+ GList *child;
+
+ priv->invert_animation = TRUE;
+
+ for (child = priv->children; child != NULL; child = child->next)
+ {
+ GtkWidget *revealer;
- /* Let this child be visible */
- gtk_widget_size_allocate (child_widget, &child_allocation);
- x += child_allocation.width + spacing;
- ++i;
+ revealer = gtk_widget_get_parent (GTK_WIDGET (child->data));
+ gtk_revealer_set_transition_duration (GTK_REVEALER (revealer), 0);
+ gtk_revealer_set_reveal_child (GTK_REVEALER (revealer), TRUE);
}
- _gtk_widget_set_simple_clip (widget, NULL);
+ priv->tick_id = gtk_widget_add_tick_callback (priv->scrolled_window,
+ (GtkTickCallback) invert_animation_on_tick,
+ self, NULL);
+}
+
+static void
+hadjustment_on_changed (GtkAdjustment *hadjustment,
+ gpointer user_data)
+{
+ GtkHidingBox *box = GTK_HIDING_BOX (user_data);
+ GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (box);
+
+ if (priv->invert_animation)
+ return;
+
+ if (priv->inverted)
+ gtk_adjustment_set_value (hadjustment, gtk_adjustment_get_upper (hadjustment));
+ else
+ gtk_adjustment_set_value (hadjustment, gtk_adjustment_get_lower (hadjustment));
}
static void
@@ -593,11 +735,31 @@ gtk_hiding_box_get_request_mode (GtkWidget *self)
}
static void
+on_what (gpointer data,
+ GObject *where_the_object_was)
+{
+ G_BREAKPOINT ();
+}
+
+static void
gtk_hiding_box_init (GtkHidingBox *box)
{
GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (box);
+ GtkAdjustment *hadjustment;
+ GtkWidget *hscrollbar;
gtk_widget_set_has_window (GTK_WIDGET (box), FALSE);
+ priv->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+ priv->hadjustment = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (priv->scrolled_window));
+ g_signal_connect (priv->hadjustment, "changed", (GCallback) hadjustment_on_changed, box);
+ hscrollbar = gtk_scrolled_window_get_hscrollbar (GTK_SCROLLED_WINDOW (priv->scrolled_window));
+ gtk_widget_hide (hscrollbar);
+ priv->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ g_object_weak_ref (G_OBJECT (priv->box), on_what, NULL);
+ gtk_container_add (GTK_CONTAINER (priv->scrolled_window), priv->box);
+ gtk_widget_set_parent (priv->scrolled_window, GTK_WIDGET (box));
+
+ priv->invert_animation = FALSE;
priv->spacing = 0;
priv->inverted = FALSE;
priv->widgets_to_hide = NULL;
@@ -605,8 +767,8 @@ gtk_hiding_box_init (GtkHidingBox *box)
priv->widgets_to_remove = NULL;
priv->widgets_shown = NULL;
priv->animation_phase = ANIMATION_PHASE_NONE;
- priv->current_width = 0;
- priv->current_height = 0;
+
+ gtk_widget_show_all (priv->scrolled_window);
}
static void
diff --git a/gtk/gtkhidingboxprivate.h b/gtk/gtkhidingbox.h
index b44dc55701..e1254959ad 100644
--- a/gtk/gtkhidingboxprivate.h
+++ b/gtk/gtkhidingbox.h
@@ -18,8 +18,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef __GTK_HIDING_BOX_PRIVATE_H__
-#define __GTK_HIDING_BOX_PRIVATE_H__
+#ifndef __GTK_HIDING_BOX_H__
+#define __GTK_HIDING_BOX_H__
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
@@ -74,4 +74,4 @@ GDK_AVAILABLE_IN_3_20
GList *gtk_hiding_box_get_overflow_children (GtkHidingBox *box);
G_END_DECLS
-#endif /* GTK_HIDING_BOX_PRIVATE_H_ */
+#endif /* GTK_HIDING_BOX_H_ */
diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c
index b507c63d0b..a983f100c6 100644
--- a/gtk/gtkpathbar.c
+++ b/gtk/gtkpathbar.c
@@ -37,7 +37,7 @@
#include "gtkintl.h"
#include "gtkmarshalers.h"
#include "gtktypebuiltins.h"
-#include "gtkhidingboxprivate.h"
+#include "gtkhidingbox.h"
/**
* SECTION:gtkpathbar
diff --git a/gtk/gtkpathbarcontainer.c b/gtk/gtkpathbarcontainer.c
index 876bfbcce0..f68d9dc231 100644
--- a/gtk/gtkpathbarcontainer.c
+++ b/gtk/gtkpathbarcontainer.c
@@ -25,7 +25,7 @@
#include "gtkwidget.h"
#include "gtkmenubutton.h"
#include "gtksizerequest.h"
-#include "gtkhidingboxprivate.h"
+#include "gtkhidingbox.h"
#include "gtkwidgetprivate.h"
#include "glib-object.h"
diff --git a/gtk/gtkrevealer.c b/gtk/gtkrevealer.c
index b23f66a7e1..45a0beda5e 100644
--- a/gtk/gtkrevealer.c
+++ b/gtk/gtkrevealer.c
@@ -456,6 +456,7 @@ gtk_revealer_real_size_allocate (GtkWidget *widget,
g_return_if_fail (allocation != NULL);
+ g_print ("revealer allocation %d %d %d %d\n", allocation->height, allocation->width, allocation->x, allocation->y);
gtk_widget_set_allocation (widget, allocation);
gtk_revealer_get_child_allocation (revealer, allocation, &child_allocation);
diff --git a/gtk/theme/Adwaita/_common.scss b/gtk/theme/Adwaita/_common.scss
index 77faa759aa..bbc39017fc 100644
--- a/gtk/theme/Adwaita/_common.scss
+++ b/gtk/theme/Adwaita/_common.scss
@@ -1621,6 +1621,20 @@ path-bar button.flat, .path-bar-overflow-popover button.flat {
}
}
+.pathbar-initial-opacity {
+ opacity: 0;
+}
+
+.pathbar-opacity-on {
+ opacity: 1;
+ transition-duration: 250ms;
+}
+
+.pathbar-opacity-off {
+ opacity: 0;
+ transition-duration: 250ms;
+}
+
/**************
* Tree Views *
**************/
diff --git a/gtk/theme/Adwaita/gtk-contained-dark.css b/gtk/theme/Adwaita/gtk-contained-dark.css
index 08df53e1c3..c89ceec8f0 100644
--- a/gtk/theme/Adwaita/gtk-contained-dark.css
+++ b/gtk/theme/Adwaita/gtk-contained-dark.css
@@ -2116,6 +2116,17 @@ path-bar button.flat, .path-bar-overflow-popover button.flat {
border-color: transparent;
background-image: none; }
+.pathbar-initial-opacity {
+ opacity: 0; }
+
+.pathbar-opacity-on {
+ opacity: 1;
+ transition-duration: 250ms; }
+
+.pathbar-opacity-off {
+ opacity: 0;
+ transition-duration: 250ms; }
+
/**************
* Tree Views *
**************/
diff --git a/gtk/theme/Adwaita/gtk-contained.css b/gtk/theme/Adwaita/gtk-contained.css
index 755d45b2d2..583b4bc081 100644
--- a/gtk/theme/Adwaita/gtk-contained.css
+++ b/gtk/theme/Adwaita/gtk-contained.css
@@ -2123,6 +2123,17 @@ path-bar button.flat, .path-bar-overflow-popover button.flat {
border-color: transparent;
background-image: none; }
+.pathbar-initial-opacity {
+ opacity: 0; }
+
+.pathbar-opacity-on {
+ opacity: 1;
+ transition-duration: 250ms; }
+
+.pathbar-opacity-off {
+ opacity: 0;
+ transition-duration: 250ms; }
+
/**************
* Tree Views *
**************/
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0d9308fe66..3352d9ab30 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -86,6 +86,7 @@ noinst_PROGRAMS = $(TEST_PROGS) \
testgtk \
testheaderbar \
testheightforwidth \
+ testhidingbox \
testiconview \
testiconview-keynav \
testicontheme \
@@ -293,6 +294,7 @@ testpixbuf_save_DEPENDENCIES = $(TEST_DEPS)
testpixbuf_color_DEPENDENCIES = $(TEST_DEPS)
testpixbuf_scale_DEPENDENCIES = $(TEST_DEPS)
testpathbar_DEPENDENCIES = $(TEST_DEPS)
+testhidingbox_DEPENDENCIES = $(TEST_DEPS)
testgmenu_DEPENDENCIES = $(TEST_DEPS)
testlogout_DEPENDENCIES = $(TEST_DEPS)
teststack_DEPENDENCIES = $(TEST_DEPS)
@@ -396,6 +398,9 @@ testmenubutton_SOURCES = \
testpathbar_SOURCES = \
testpathbar.c
+testhidingbox_SOURCES = \
+ testhidingbox.c
+
testprint_SOURCES = \
testprint.c \
testprintfileoperation.h \
diff --git a/tests/testhidingbox.c b/tests/testhidingbox.c
index 7093f5389b..8ac75bf964 100644
--- a/tests/testhidingbox.c
+++ b/tests/testhidingbox.c
@@ -1,9 +1,26 @@
#include "config.h"
#include "glib.h"
#include <gtk/gtk.h>
-#include <gtk/gtkhidingboxprivate.h>
+
+#define N_BUTTONS 10
static GtkWidget *hiding_box;
+static char *lorem_ipsum = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
+
+static char*
+get_lorem_ipsum ()
+{
+ static char **lorem_ipsum_split;
+ static int n_lorem_ipsum_words;
+
+ if (!lorem_ipsum_split)
+ {
+ lorem_ipsum_split = g_strsplit (lorem_ipsum, " ", -1);
+ n_lorem_ipsum_words = g_strv_length (lorem_ipsum_split);
+ }
+
+ return lorem_ipsum_split [g_random_int_range (0, n_lorem_ipsum_words)];
+}
static void
on_path_selected (GtkPathBar *path_bar,
@@ -17,6 +34,7 @@ static void
on_button_clicked (GtkWidget *button,
gpointer user_data)
{
+ g_print ("button clicked\n");
gtk_container_remove (GTK_CONTAINER (user_data), button);
}
@@ -25,14 +43,46 @@ on_reset_button_clicked (GtkButton *reset_button)
{
GtkWidget *button;
- gtk_container_foreach (GTK_CONTAINER (hiding_box), gtk_widget_destroy);
+ gtk_container_foreach (GTK_CONTAINER (hiding_box), (GtkCallback) gtk_widget_destroy, NULL);
+
+ for (int i = 0; i < N_BUTTONS; i++)
+ {
+ button = gtk_button_new_with_label (get_lorem_ipsum ());
+ g_signal_connect (button, "clicked", (GCallback) on_button_clicked, hiding_box);
+ gtk_container_add (GTK_CONTAINER (hiding_box), button);
+ }
+
+ gtk_widget_show_all (hiding_box);
+}
+
+static void
+on_add_button (gint line)
+{
+ GtkWidget *button;
+
+ button = gtk_button_new_with_label (get_lorem_ipsum ());
+ gtk_widget_show (button);
+ g_signal_connect (button, "clicked", (GCallback) on_button_clicked, hiding_box);
+ gtk_container_add (GTK_CONTAINER (hiding_box), button);
+}
- button = gtk_button_new_with_label ("test1");
- g_signal_connect (button, "clicked", on_button_clicked, hiding_box);
- gtk_container_add (GTK_CONTAINER (hiding_box), );
- gtk_container_add (GTK_CONTAINER (hiding_box), gtk_button_new_with_label ("test2"));
- gtk_container_add (GTK_CONTAINER (hiding_box), gtk_button_new_with_label ("test3"));
- gtk_container_add (GTK_CONTAINER (hiding_box), gtk_button_new_with_label ("test4"));
+static void
+on_remove_button (gint line)
+{
+ GList *children;
+ GList *last;
+
+ children = gtk_container_get_children (hiding_box);
+ last = g_list_last (children);
+ if (last)
+ gtk_container_remove (hiding_box, GTK_WIDGET (last->data));
+}
+
+static void
+on_invert_button (gint line)
+{
+ gtk_hiding_box_set_inverted (GTK_HIDING_BOX (hiding_box),
+ !gtk_hiding_box_get_inverted (GTK_HIDING_BOX (hiding_box)));
}
int
@@ -41,6 +91,9 @@ main (int argc, char *argv[])
GtkWidget *window;
GtkWidget *grid;
GtkWidget *reset_button;
+ GtkWidget *add_button;
+ GtkWidget *remove_button;
+ GtkWidget *invert_button;
GtkWidget *label;
GFile *file = NULL;
GIcon *icon;
@@ -63,8 +116,25 @@ main (int argc, char *argv[])
gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 2, 1);
/* ----------------------------------------------------------------------- */
- hiding_box = gtk_hiding_box ();
+ hiding_box = gtk_hiding_box_new ();
gtk_grid_attach (GTK_GRID (grid), hiding_box, 0, 1, 1, 1);
+ gtk_widget_show_all (hiding_box);
+ /* Add/Remove buttons */
+ add_button = gtk_button_new_with_label ("Add");
+ gtk_widget_set_halign (add_button, GTK_ALIGN_END);
+ remove_button = gtk_button_new_with_label ("Remove");
+ gtk_widget_set_halign (remove_button, GTK_ALIGN_END);
+ gtk_grid_attach_next_to (GTK_GRID (grid), add_button, hiding_box, GTK_POS_RIGHT, 1, 1);
+ g_signal_connect_swapped (add_button, "clicked", (GCallback) on_add_button, GINT_TO_POINTER (0));
+ gtk_grid_attach_next_to (GTK_GRID (grid), remove_button, add_button, GTK_POS_RIGHT, 1, 1);
+ g_signal_connect_swapped (remove_button, "clicked", (GCallback) on_remove_button, GINT_TO_POINTER (0));
+ gtk_widget_show (add_button);
+ gtk_widget_show (remove_button);
+ /* Inverted button */
+ invert_button = gtk_button_new_with_label ("Invert");
+ gtk_widget_set_halign (invert_button, GTK_ALIGN_END);
+ gtk_grid_attach_next_to (GTK_GRID (grid), invert_button, remove_button, GTK_POS_RIGHT, 1, 1);
+ g_signal_connect_swapped (invert_button, "clicked", (GCallback) on_invert_button, GINT_TO_POINTER (0));
/* Reset button */
reset_button = gtk_button_new_with_label ("Reset State");