[gtk+/wip/csoriano/pathbar-bin-view-window: 35/35] Experiment with a view and bin window
- From: Carlos Soriano Sánchez <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/csoriano/pathbar-bin-view-window: 35/35] Experiment with a view and bin window
- Date: Fri, 3 Jun 2016 16:43:14 +0000 (UTC)
commit f8db533e9c5387a7b9701525e5ede5785220e050
Author: Carlos Soriano <csoriano gnome org>
Date: Thu Jun 2 17:01:49 2016 +0200
Experiment with a view and bin window
gtk/gtkhidingbox.c | 424 ++++++++++++++++++++++++++++++-------------------
gtk/gtkhidingbox.h | 13 ++-
gtk/gtkwindow.c | 3 +-
tests/testhidingbox.c | 11 +-
4 files changed, 279 insertions(+), 172 deletions(-)
---
diff --git a/gtk/gtkhidingbox.c b/gtk/gtkhidingbox.c
index 2417741..29fd8bb 100644
--- a/gtk/gtkhidingbox.c
+++ b/gtk/gtkhidingbox.c
@@ -1,6 +1,5 @@
/*
- * Copyright (C) 2015 Rafał Lużyński <digitalfreak lingonborough com>
- * Copyright (C) 2015 Red Hat
+ * Copyright (C) 2016 Red Hat
*
* Licensed under the GNU General Public License Version 2
*
@@ -18,8 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Authors: Rafał Lużyński <digitalfreak lingonborough com>
- * Carlos Soriano <csoriano gnome org>
+ * Authors: Carlos Soriano <csoriano gnome org>
*/
#include "config.h"
@@ -45,7 +43,6 @@
struct _GtkHidingBoxPrivate
{
GList *children;
- gint16 spacing;
gint inverted :1;
GList *widgets_to_hide;
GList *widgets_to_show;
@@ -56,7 +53,9 @@ struct _GtkHidingBoxPrivate
gboolean invert_animation;
- GtkWidget *scrolled_window;
+ GdkWindow *bin_window;
+ GdkWindow *view_window;
+
GtkWidget *box;
GtkAdjustment *hadjustment;
@@ -68,42 +67,10 @@ struct _GtkHidingBoxPrivate
gint previous_child_width;
};
-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 (GTK_HIDING_BOX (buildable));
-
- if (!type)
- {
- gtk_container_add (GTK_CONTAINER (buildable), GTK_WIDGET (child));
- priv->needs_update = TRUE;
- }
- else
- {
- GTK_BUILDER_WARN_INVALID_CHILD_TYPE (GTK_HIDING_BOX (buildable), type);
- }
-}
-
-static void
-gtk_hiding_box_buildable_init (GtkBuildableIface *iface)
-{
- iface->add_child = gtk_hiding_box_buildable_add_child;
-}
+G_DEFINE_TYPE_WITH_PRIVATE (GtkHidingBox, gtk_hiding_box, GTK_TYPE_BIN)
enum {
PROP_0,
- PROP_SPACING,
PROP_INVERTED,
LAST_PROP
};
@@ -120,9 +87,6 @@ gtk_hiding_box_set_property (GObject *object,
switch (prop_id)
{
- case PROP_SPACING:
- gtk_hiding_box_set_spacing (box, g_value_get_int (value));
- break;
case PROP_INVERTED:
gtk_hiding_box_set_inverted (box, g_value_get_boolean (value));
break;
@@ -143,9 +107,6 @@ gtk_hiding_box_get_property (GObject *object,
switch (prop_id)
{
- case PROP_SPACING:
- g_value_set_int (value, priv->spacing);
- break;
case PROP_INVERTED:
g_value_set_boolean (value, priv->inverted);
break;
@@ -155,25 +116,26 @@ gtk_hiding_box_get_property (GObject *object,
}
}
-static void
-gtk_hiding_box_add (GtkContainer *container,
+void
+gtk_hiding_box_add (GtkHidingBox *self,
GtkWidget *widget)
{
- GtkHidingBox *box = GTK_HIDING_BOX (container);
+ GtkHidingBox *box = GTK_HIDING_BOX (self);
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_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);
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);
+ gtk_revealer_set_reveal_child (GTK_REVEALER (revealer), TRUE);
+ gtk_widget_show_all (revealer);
g_print ("add\n");
}
@@ -220,12 +182,11 @@ unrevealed_really_remove_child (GObject *widget,
really_remove_child (self, gtk_bin_get_child (GTK_BIN (widget)));
}
-static void
-gtk_hiding_box_remove (GtkContainer *container,
+void
+gtk_hiding_box_remove (GtkHidingBox *self,
GtkWidget *widget)
{
- GtkHidingBox *box = GTK_HIDING_BOX (container);
- GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (box);
+ GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (self);
GtkWidget *to_remove;
g_print ("remove %p %s\n", widget, G_OBJECT_TYPE_NAME (widget));
@@ -237,29 +198,61 @@ gtk_hiding_box_remove (GtkContainer *container,
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));
+
+ gtk_widget_queue_resize (GTK_WIDGET (self));
}
static void
-gtk_hiding_box_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data)
+get_children_allocation (GtkHidingBox *self,
+ GtkAllocation *allocation,
+ GtkAllocation *child_allocation)
{
- GtkHidingBox *box = GTK_HIDING_BOX (container);
- GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (box);
+ GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (self);
+ GtkWidget *child_widget;
GList *child;
+ GtkRequestedSize *sizes_temp;
+ gint i;
+ GList *children;
+ gint current_children_min_width = 0;
+ gint current_children_nat_width = 0;
- for (child = priv->children; child != NULL; child = child->next)
- (* callback) (child->data, callback_data);
+ children = g_list_copy (priv->children);
+ sizes_temp = g_newa (GtkRequestedSize, g_list_length (priv->children));
+ child_allocation->x = 0;
+ child_allocation->y = 0;
+ child_allocation->height = allocation->height;
+
+ if (priv->inverted)
+ children = g_list_reverse (children);
+
+ /* Retrieve desired size for visible children. */
+ for (i = 0, child = children; child != NULL; i++, child = child->next)
+ {
+ child_widget = GTK_WIDGET (child->data);
- if (include_internals)
- {
- (* callback) (priv->scrolled_window, callback_data);
+ /* 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);
+
+ 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)
+ {
+ current_children_min_width -= sizes_temp[i].minimum_size;
+ current_children_nat_width -= sizes_temp[i].natural_size;
+ break;
+ }
+ }
- for (child = priv->widgets_to_remove; child != NULL; child = child->next)
- (* callback) (child->data, callback_data);
- }
+ if (current_children_nat_width > allocation->width)
+ child_allocation->width = current_children_min_width;
+ else
+ child_allocation->width = current_children_nat_width;
+
+ g_list_free (children);
}
static void
@@ -391,13 +384,13 @@ idle_update_revealers (GtkHidingBox *box)
gdouble max_real_adjustment;
max_real_adjustment = gtk_adjustment_get_upper (priv->hadjustment) -
- gtk_widget_get_allocated_width (priv->scrolled_window);
+ gtk_widget_get_allocated_width (priv->bin_window);
g_print ("animation velocity %f %f\n", max_real_adjustment, velocity);
- revealer_animation_time = (gtk_widget_get_allocated_width (priv->scrolled_window) -
+ revealer_animation_time = (gtk_widget_get_allocated_width (priv->bin_window) -
priv->allocated_children_width) /
velocity;
- g_print ("animation time %d %d %d\n", priv->allocated_children_width,
gtk_widget_get_allocated_width (priv->scrolled_window), revealer_animation_time);
+ g_print ("animation time %d %d %d\n", priv->allocated_children_width,
gtk_widget_get_allocated_width (priv->bin_window), revealer_animation_time);
add_opacity_class (revealer, "pathbar-invert-animation-opacity-off");
g_signal_connect (revealer, "notify::child-revealed", (GCallback) opacity_off, box);
gtk_revealer_set_transition_duration (GTK_REVEALER (revealer), revealer_animation_time);
@@ -469,30 +462,77 @@ idle_update_revealers (GtkHidingBox *box)
}
static void
+update_scrolling (GtkHidingBox *self,
+ GtkAllocation *allocation,
+ GtkAllocation *child_allocation)
+{
+ GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (self);
+ GtkAllocation used_child_allocation;
+ gint scroll_value;
+ gint max_scroll;
+
+ if (gtk_widget_get_realized (GTK_WIDGET (self)))
+ {
+ get_children_allocation (self, allocation, &used_child_allocation);
+ max_scroll = child_allocation->width - allocation->width + (child_allocation->width -
used_child_allocation.width);
+ if (priv->inverted)
+ {
+ scroll_value = max_scroll;
+ }
+ else
+ {
+ scroll_value = 0;
+ }
+
+ gdk_window_move_resize (priv->bin_window,
+ scroll_value, 0,
+ child_allocation->width, child_allocation->height);
+
+ g_print ("bin_window %d %d %d", child_allocation->width, child_allocation->height, scroll_value);
+ }
+
+}
+
+static void
gtk_hiding_box_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
- GtkHidingBox *box = GTK_HIDING_BOX (widget);
- GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (box);
+ GtkHidingBox *self = GTK_HIDING_BOX (widget);
+ GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (self);
GtkAllocation child_allocation;
GtkRequestedSize *sizes;
+ GtkRequisition minimum_size;
+ GtkRequisition natural_size;
gtk_widget_set_allocation (widget, allocation);
sizes = g_newa (GtkRequestedSize, g_list_length (priv->children));
- update_children_visibility (box, allocation);
- idle_update_revealers (box);
+ update_children_visibility (self, allocation);
+ //dle_update_revealers (self);
+
+ gtk_widget_get_preferred_size (priv->box, &minimum_size, &natural_size);
+ child_allocation.x = 0;
+ child_allocation.y = 0;
+ child_allocation.width = natural_size.width;
+ child_allocation.height = natural_size.height;
+ gtk_widget_size_allocate (priv->box, &child_allocation);
- 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_scrolling (self, allocation, &child_allocation);
+
+ if (gtk_widget_get_realized (widget))
+ {
+ gdk_window_move_resize (priv->view_window,
+ allocation->x, allocation->y,
+ allocation->width, allocation->height);
+ g_print ("view window %d %d", allocation->width, allocation->height);
+ gdk_window_show (priv->view_window);
- _gtk_widget_set_simple_clip (widget, NULL);
+ g_print ("visibles? %d %d\n", gdk_window_is_visible (priv->bin_window), gdk_window_is_visible
(priv->view_window));
+ }
}
+#if 0
static void
update_hadjustment (GtkHidingBox *self)
{
@@ -501,9 +541,9 @@ update_hadjustment (GtkHidingBox *self)
gdouble max_real_adjustment;
max_real_adjustment = gtk_adjustment_get_upper (priv->hadjustment) -
- gtk_widget_get_allocated_width (priv->scrolled_window);
+ gtk_widget_get_allocated_width (priv->bin_window);
- g_print ("aligment changed %f %f %d %f\n", max_real_adjustment, gtk_adjustment_get_upper
(priv->hadjustment), gtk_widget_get_allocated_width (priv->scrolled_window), gtk_adjustment_get_lower
(priv->hadjustment));
+ g_print ("aligment changed %f %f %d %f\n", max_real_adjustment, gtk_adjustment_get_upper
(priv->hadjustment), gtk_widget_get_allocated_width (priv->bin_window), gtk_adjustment_get_lower
(priv->hadjustment));
if (priv->invert_animation)
{
if (priv->inverted)
@@ -542,7 +582,7 @@ finish_invert_animation (GtkHidingBox *self)
idle_update_revealers (self);
priv->invert_animation = FALSE;
priv->invert_animation_initial_time = 0;
- gtk_widget_remove_tick_callback (priv->scrolled_window,
+ gtk_widget_remove_tick_callback (priv->bin_window,
priv->invert_animation_tick_id);
priv->invert_animation_tick_id = 0;
}
@@ -559,14 +599,14 @@ invert_animation_on_tick (GtkWidget *widget,
gdouble max_real_adjustment;
max_real_adjustment = gtk_adjustment_get_upper (priv->hadjustment) -
- (gdouble) gtk_widget_get_allocated_width (priv->scrolled_window);
+ (gdouble) gtk_widget_get_allocated_width (priv->bin_window);
if (priv->invert_animation_initial_time == 0)
priv->invert_animation_initial_time = gdk_frame_clock_get_frame_time (frame_clock);
elapsed = gdk_frame_clock_get_frame_time (frame_clock) - priv->invert_animation_initial_time;
priv->invert_animation_progress = elapsed * INVERT_ANIMATION_SPEED / (1000. * max_real_adjustment);
- g_print ("################animation progres %d %f %f %f\n", gtk_widget_get_allocated_width
(priv->scrolled_window), max_real_adjustment, elapsed / 1000., priv->invert_animation_progress);
+ g_print ("################animation progres %d %f %f %f\n", gtk_widget_get_allocated_width
(priv->bin_window), max_real_adjustment, elapsed / 1000., priv->invert_animation_progress);
update_hadjustment (self);
if (priv->invert_animation_progress >= 1)
@@ -602,7 +642,7 @@ start_invert_animation (GtkHidingBox *self)
gtk_revealer_set_reveal_child (GTK_REVEALER (revealer), TRUE);
}
- priv->invert_animation_tick_id = gtk_widget_add_tick_callback (priv->scrolled_window,
+ priv->invert_animation_tick_id = gtk_widget_add_tick_callback (priv->bin_window,
(GtkTickCallback) invert_animation_on_tick,
self, NULL);
}
@@ -613,6 +653,7 @@ hadjustment_on_changed (GtkAdjustment *hadjustment,
{
update_hadjustment (GTK_HIDING_BOX (user_data));
}
+#endif
static void
gtk_hiding_box_get_preferred_width (GtkWidget *widget,
@@ -628,6 +669,7 @@ gtk_hiding_box_get_preferred_width (GtkWidget *widget,
gboolean have_min = FALSE;
GList *children;
+ g_print ("#############3 preferred width %d %d\n", *minimum_width, *natural_width);
*minimum_width = 0;
*natural_width = 0;
@@ -653,13 +695,18 @@ gtk_hiding_box_get_preferred_width (GtkWidget *widget,
*natural_width += child_natural_width;
}
- /* Natural must also include the spacing */
- if (priv->spacing && n_visible_children > 1)
- *natural_width += priv->spacing * (n_visible_children - 1);
-
+ g_print ("#############3 preferred width %d %d\n", *minimum_width, *natural_width);
g_list_free (children);
}
+gtk_revealer_real_get_preferred_width_for_height (GtkWidget *widget,
+ gint height,
+ gint *minimum_width_out,
+ gint *natural_width_out)
+{
+ gtk_hiding_box_get_preferred_width (widget, minimum_width_out, natural_width_out);
+}
+
static void
gtk_hiding_box_get_preferred_height (GtkWidget *widget,
gint *minimum_height,
@@ -671,6 +718,7 @@ gtk_hiding_box_get_preferred_height (GtkWidget *widget,
gint child_natural_height;
GList *child;
+ g_print ("#############3 preferred heigh \n");
*minimum_height = 0;
*natural_height = 0;
for (child = priv->children; child != NULL; child = child->next)
@@ -698,31 +746,127 @@ on_what (gpointer data,
}
static void
-gtk_hiding_box_init (GtkHidingBox *box)
+gtk_hiding_box_container_add (GtkContainer *container,
+ GtkWidget *child)
{
- GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (box);
- 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);
+ g_return_if_fail (child != NULL);
+
+ g_error ("Path bar cannot add children. Use the path bar API instead");
+
+ return;
+}
+
+static void
+gtk_hiding_box_container_remove (GtkContainer *container,
+ GtkWidget *child)
+{
+ g_return_if_fail (child != NULL);
+
+ g_error ("Path bar cannot remove children. Use the path bar API instead");
+
+ return;
+}
+
+static void
+gtk_hiding_box_unrealize (GtkWidget *widget)
+{
+ GtkHidingBox *self = GTK_HIDING_BOX (widget);
+ GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (self);
+
+ gtk_widget_unregister_window (widget, priv->bin_window);
+ gdk_window_destroy (priv->bin_window);
+ priv->view_window = NULL;
+
+ GTK_WIDGET_CLASS (gtk_hiding_box_parent_class)->unrealize (widget);
+}
+
+static void
+gtk_hiding_box_realize (GtkWidget *widget)
+{
+ GtkHidingBox *self = GTK_HIDING_BOX (widget);
+ GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (self);
+ GtkAllocation allocation;
+ GtkAllocation child_allocation;
+ GdkWindowAttr attributes = { 0 };
+ GdkWindowAttributesType attributes_mask;
+
+ g_print ("realize\n");
+ gtk_widget_set_realized (widget, TRUE);
+
+ gtk_widget_get_allocation (widget, &allocation);
+
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
+ attributes.window_type = GDK_WINDOW_CHILD;
+ attributes.wclass = GDK_INPUT_OUTPUT;
+ attributes.visual = gtk_widget_get_visual (widget);
+ attributes.event_mask = gtk_widget_get_events (widget);
+ attributes_mask = (GDK_WA_X | GDK_WA_Y) | GDK_WA_VISUAL;
+
+ priv->view_window = gdk_window_new (gtk_widget_get_parent_window (GTK_WIDGET (self)),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, priv->view_window);
+ gtk_widget_register_window (widget, priv->view_window);
+
+ get_children_allocation (self, &allocation, &child_allocation);
+ attributes.x = 0;
+ attributes.y = 0;
+ attributes.width = child_allocation.width;
+ attributes.height = child_allocation.height;
+
+ priv->bin_window = gdk_window_new (priv->view_window, &attributes,
+ attributes_mask);
+ gtk_widget_register_window (widget, priv->bin_window);
+
+ gtk_widget_set_parent_window (priv->box, priv->bin_window);
+
+ gdk_window_show (priv->bin_window);
+ gdk_window_show (priv->view_window);
+ gtk_widget_show_all (priv->box);
+}
+
+static gboolean
+gtk_hiding_box_draw (GtkWidget *widget,
+ cairo_t *cr)
+{
+ GtkHidingBox *self = GTK_HIDING_BOX (widget);
+ GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (self);
+
+ if (gtk_cairo_should_draw_window (cr, priv->bin_window))
+ {
+ g_print ("draw\n");
+
+ GTK_WIDGET_CLASS (gtk_hiding_box_parent_class)->draw (widget, cr);
+ }
+
+ return GDK_EVENT_PROPAGATE;
+}
+
+static void
+gtk_hiding_box_init (GtkHidingBox *self)
+{
+ GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (self);
+
+ gtk_widget_set_has_window (GTK_WIDGET (self), TRUE);
+ gtk_widget_set_redraw_on_allocate (GTK_WIDGET (self), TRUE);
+
priv->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_widget_set_parent_window (priv->box, priv->bin_window);
+ GTK_CONTAINER_CLASS (gtk_hiding_box_parent_class)->add (GTK_CONTAINER (self), priv->box);
+
+ gtk_widget_show (priv->box);
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->invert_animation_tick_id = 0;
priv->widgets_to_hide = NULL;
priv->widgets_to_show = NULL;
priv->widgets_to_remove = NULL;
- gtk_widget_show_all (priv->scrolled_window);
+ g_print ("init\n");
}
static void
@@ -738,18 +882,14 @@ gtk_hiding_box_class_init (GtkHidingBoxClass *class)
widget_class->size_allocate = gtk_hiding_box_size_allocate;
widget_class->get_preferred_width = gtk_hiding_box_get_preferred_width;
widget_class->get_preferred_height = gtk_hiding_box_get_preferred_height;
+ widget_class->get_preferred_width_for_height = gtk_revealer_real_get_preferred_width_for_height;
widget_class->get_request_mode = gtk_hiding_box_get_request_mode;
+ widget_class->realize = gtk_hiding_box_realize;
+ widget_class->unrealize = gtk_hiding_box_unrealize;
+ widget_class->draw = gtk_hiding_box_draw;
- container_class->add = gtk_hiding_box_add;
- container_class->remove = gtk_hiding_box_remove;
- container_class->forall = gtk_hiding_box_forall;
-
- hiding_box_properties[PROP_SPACING] =
- g_param_spec_int ("spacing",
- _("Spacing"),
- _("The amount of space between children"),
- 0, G_MAXINT, 0,
- G_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+ container_class->add = gtk_hiding_box_container_add;
+ container_class->remove = gtk_hiding_box_container_remove;
hiding_box_properties[PROP_INVERTED] =
g_param_spec_int ("inverted",
@@ -759,6 +899,7 @@ gtk_hiding_box_class_init (GtkHidingBoxClass *class)
G_PARAM_READWRITE);
g_object_class_install_properties (object_class, LAST_PROP, hiding_box_properties);
+ g_print ("class init\n");
}
/**
@@ -774,55 +915,6 @@ gtk_hiding_box_new (void)
return g_object_new (GTK_TYPE_HIDING_BOX, NULL);
}
-/**
- * gtk_hiding_box_set_spacing:
- * @box: a #GtkHidingBox
- * @spacing: the number of pixels to put between children
- *
- * Sets the #GtkHidingBox:spacing property of @box, which is the
- * number of pixels to place between children of @box.
- */
-void
-gtk_hiding_box_set_spacing (GtkHidingBox *box,
- gint spacing)
-{
- GtkHidingBoxPrivate *priv ;
-
- g_return_if_fail (GTK_IS_HIDING_BOX (box));
-
- priv = gtk_hiding_box_get_instance_private (box);
-
- if (priv->spacing != spacing)
- {
- priv->spacing = spacing;
-
- g_object_notify (G_OBJECT (box), "spacing");
-
- gtk_widget_queue_resize (GTK_WIDGET (box));
- }
-}
-
-/**
- * gtk_hiding_box_get_spacing:
- * @box: a #GtkHidingBox
- *
- * Gets the value set by gtk_hiding_box_set_spacing().
- *
- * Returns: spacing between children
- **/
-gint
-gtk_hiding_box_get_spacing (GtkHidingBox *box)
-{
- GtkHidingBoxPrivate *priv ;
-
- g_return_val_if_fail (GTK_IS_HIDING_BOX (box), 0);
-
- priv = gtk_hiding_box_get_instance_private (box);
-
- return priv->spacing;
-}
-
-
void
gtk_hiding_box_set_inverted (GtkHidingBox *box,
gboolean inverted)
@@ -839,7 +931,7 @@ gtk_hiding_box_set_inverted (GtkHidingBox *box,
g_object_notify (G_OBJECT (box), "inverted");
- start_invert_animation (box);
+ //start_invert_animation (box);
gtk_widget_queue_resize (GTK_WIDGET (box));
}
}
diff --git a/gtk/gtkhidingbox.h b/gtk/gtkhidingbox.h
index e125495..e7b0e6f 100644
--- a/gtk/gtkhidingbox.h
+++ b/gtk/gtkhidingbox.h
@@ -25,7 +25,7 @@
#error "Only <gtk/gtk.h> can be included directly."
#endif
-#include <gtk/gtkcontainer.h>
+#include <gtk/gtkbin.h>
G_BEGIN_DECLS
@@ -42,7 +42,7 @@ typedef struct _GtkHidingBoxPrivate GtkHidingBoxPrivate;
struct _GtkHidingBoxClass
{
- GtkContainerClass parent;
+ GtkBinClass parent;
/* Padding for future expansion */
gpointer reserved[10];
@@ -50,7 +50,7 @@ struct _GtkHidingBoxClass
struct _GtkHidingBox
{
- GtkContainer parent_instance;
+ GtkBin parent_instance;
};
GDK_AVAILABLE_IN_3_20
@@ -72,6 +72,13 @@ gboolean gtk_hiding_box_get_inverted (GtkHidingBox *box
GDK_AVAILABLE_IN_3_20
GList *gtk_hiding_box_get_overflow_children (GtkHidingBox *box);
+
+GDK_AVAILABLE_IN_3_20
+void gtk_hiding_box_add (GtkHidingBox *self,
+ GtkWidget *widget);
+GDK_AVAILABLE_IN_3_20
+void gtk_hiding_box_remove (GtkHidingBox *self,
+ GtkWidget *widget);
G_END_DECLS
#endif /* GTK_HIDING_BOX_H_ */
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 95beb5d..3b55c63 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -6107,7 +6107,8 @@ gtk_window_show (GtkWidget *widget)
_gtk_widget_set_visible_flag (widget, TRUE);
- gtk_css_node_validate (gtk_widget_get_css_node (widget));
+ if (gtk_widget_get_css_node (widget))
+ gtk_css_node_validate (gtk_widget_get_css_node (widget));
gtk_widget_realize (widget);
diff --git a/tests/testhidingbox.c b/tests/testhidingbox.c
index fda67ef..bc2446f 100644
--- a/tests/testhidingbox.c
+++ b/tests/testhidingbox.c
@@ -34,8 +34,11 @@ static void
on_button_clicked (GtkWidget *button,
gpointer user_data)
{
+
+#if 0
g_print ("button clicked\n");
gtk_container_remove (GTK_CONTAINER (user_data), button);
+#endif
}
static void
@@ -43,16 +46,18 @@ on_reset_button_clicked (GtkButton *reset_button)
{
GtkWidget *button;
+#if 0
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_hiding_box_add (GTK_HIDING_BOX (hiding_box), button);
}
gtk_widget_show_all (hiding_box);
+#endif
}
static void
@@ -63,7 +68,7 @@ on_add_button (gint line)
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);
+ gtk_hiding_box_add (GTK_HIDING_BOX (hiding_box), button);
}
static void
@@ -72,10 +77,12 @@ on_remove_button (gint line)
GList *children;
GList *last;
+#if 0
children = gtk_container_get_children (hiding_box);
last = g_list_last (children);
if (last)
gtk_container_remove (hiding_box, GTK_WIDGET (last->data));
+#endif
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]