[gtk+/wip/csoriano/pathbar-prototype: 1/3] hiding
- From: Carlos Soriano Sánchez <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/csoriano/pathbar-prototype: 1/3] hiding
- Date: Sun, 22 Nov 2015 01:40:32 +0000 (UTC)
commit 61c93d329eda1e181ac56006f7fd47d04253dde1
Author: Carlos Soriano <csoriano gnome org>
Date: Sat Nov 21 22:53:23 2015 +0100
hiding
gtk/gtkhidingbox.c | 53 ++++++++++++++++++++++-----------------------
gtk/gtkhidingboxprivate.h | 6 ++--
2 files changed, 29 insertions(+), 30 deletions(-)
---
diff --git a/gtk/gtkhidingbox.c b/gtk/gtkhidingbox.c
index b6617e9..ff1bff1 100644
--- a/gtk/gtkhidingbox.c
+++ b/gtk/gtkhidingbox.c
@@ -34,7 +34,7 @@ struct _GtkHidingBoxPrivate
{
GList *children;
gint16 spacing;
- GtkDirectionType hide_direction;
+ gboolean inverted;
};
static void
@@ -62,7 +62,7 @@ G_DEFINE_TYPE_WITH_CODE (GtkHidingBox, gtk_hiding_box, GTK_TYPE_CONTAINER,
enum {
PROP_0,
PROP_SPACING,
- PROP_HIDE_DIRECTION,
+ PROP_INVERTED,
LAST_PROP
};
@@ -81,8 +81,8 @@ gtk_hiding_box_set_property (GObject *object,
case PROP_SPACING:
gtk_hiding_box_set_spacing (box, g_value_get_int (value));
break;
- case PROP_HIDE_DIRECTION:
- gtk_hiding_box_set_hide_direction (box, g_value_get_int (value));
+ case PROP_INVERTED:
+ gtk_hiding_box_set_inverted (box, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -104,8 +104,8 @@ gtk_hiding_box_get_property (GObject *object,
case PROP_SPACING:
g_value_set_int (value, priv->spacing);
break;
- case PROP_HIDE_DIRECTION:
- g_value_set_int (value, priv->hide_direction);
+ case PROP_INVERTED:
+ g_value_set_boolean (value, priv->inverted);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -191,7 +191,7 @@ update_children_visibility (GtkHidingBox *box,
*children_size = -priv->spacing;
children = g_list_copy (priv->children);
sizes_temp = g_newa (GtkRequestedSize, g_list_length (priv->children));
- if (priv->hide_direction == GTK_DIR_LEFT)
+ if (priv->inverted)
children = g_list_reverse (children);
/* Retrieve desired size for visible children. */
@@ -238,15 +238,15 @@ update_children_visibility (GtkHidingBox *box,
for (i = 0; i < *n_visible_children; i++)
{
- if (priv->hide_direction == GTK_DIR_RIGHT)
+ if (priv->inverted)
{
- sizes[i].minimum_size = sizes_temp[i].minimum_size;
- sizes[i].natural_size = sizes_temp[i].natural_size;
+ sizes[*n_visible_children - i - 1].minimum_size = sizes_temp[i].minimum_size;
+ sizes[*n_visible_children - i - 1].natural_size = sizes_temp[i].natural_size;
}
else
{
- sizes[*n_visible_children - i - 1].minimum_size = sizes_temp[i].minimum_size;
- sizes[*n_visible_children - i - 1].natural_size = sizes_temp[i].natural_size;
+ sizes[i].minimum_size = sizes_temp[i].minimum_size;
+ sizes[i].natural_size = sizes_temp[i].natural_size;
}
}
@@ -338,7 +338,7 @@ gtk_hiding_box_get_preferred_width (GtkWidget *widget,
*natural_width = 0;
children = g_list_copy (priv->children);
- if (priv->hide_direction == GTK_DIR_LEFT)
+ if (priv->inverted)
children = g_list_reverse (children);
n_visible_children = 0;
@@ -403,7 +403,7 @@ gtk_hiding_box_init (GtkHidingBox *box)
gtk_widget_set_has_window (GTK_WIDGET (box), FALSE);
priv->spacing = 0;
- priv->hide_direction = GTK_DIR_RIGHT;
+ priv->inverted = FALSE;
}
static void
@@ -432,10 +432,10 @@ gtk_hiding_box_class_init (GtkHidingBoxClass *class)
0, G_MAXINT, 0,
G_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
- hiding_box_properties[PROP_HIDE_DIRECTION] =
- g_param_spec_int ("hide-direction",
- _("Hide direction"),
- _("From where the container will start hiding widgets when there is not enough
space"),
+ hiding_box_properties[PROP_INVERTED] =
+ g_param_spec_int ("inverted",
+ _("Direction of hiding children inverted"),
+ P_("If false the container will start hiding widgets from the end when there is
not enough space, and the oposite in case inverted is true."),
0, G_MAXINT, 0,
G_PARAM_READWRITE);
@@ -505,28 +505,27 @@ gtk_hiding_box_get_spacing (GtkHidingBox *box)
void
-gtk_hiding_box_set_hide_direction (GtkHidingBox *box,
- GtkDirectionType hide_direction)
+gtk_hiding_box_set_inverted (GtkHidingBox *box,
+ gboolean inverted)
{
GtkHidingBoxPrivate *priv ;
g_return_if_fail (GTK_IS_HIDING_BOX (box));
- g_return_if_fail (hide_direction == GTK_DIR_LEFT || hide_direction == GTK_DIR_RIGHT);
priv = gtk_hiding_box_get_instance_private (box);
- if (priv->hide_direction != hide_direction)
+ if (priv->inverted != inverted)
{
- priv->hide_direction = hide_direction;
+ priv->inverted = inverted;
- g_object_notify (G_OBJECT (box), "hide-direction");
+ g_object_notify (G_OBJECT (box), "inverted");
gtk_widget_queue_resize (GTK_WIDGET (box));
}
}
-GtkDirectionType
-gtk_hiding_box_get_hide_direction (GtkHidingBox *box)
+gboolean
+gtk_hiding_box_get_inverted (GtkHidingBox *box)
{
GtkHidingBoxPrivate *priv ;
@@ -534,7 +533,7 @@ gtk_hiding_box_get_hide_direction (GtkHidingBox *box)
priv = gtk_hiding_box_get_instance_private (box);
- return priv->hide_direction;
+ return priv->inverted;
}
GList *
diff --git a/gtk/gtkhidingboxprivate.h b/gtk/gtkhidingboxprivate.h
index adcc248..b44dc55 100644
--- a/gtk/gtkhidingboxprivate.h
+++ b/gtk/gtkhidingboxprivate.h
@@ -65,10 +65,10 @@ GDK_AVAILABLE_IN_3_20
gint gtk_hiding_box_get_spacing (GtkHidingBox *box);
GDK_AVAILABLE_IN_3_20
-void gtk_hiding_box_set_hide_direction (GtkHidingBox *box,
- GtkDirectionType hide_direction);
+void gtk_hiding_box_set_inverted (GtkHidingBox *box,
+ gboolean inverted);
GDK_AVAILABLE_IN_3_20
-GtkDirectionType gtk_hiding_box_get_hide_direction (GtkHidingBox *box);
+gboolean gtk_hiding_box_get_inverted (GtkHidingBox *box);
GDK_AVAILABLE_IN_3_20
GList *gtk_hiding_box_get_overflow_children (GtkHidingBox *box);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]