Commit e616eaf6 authored by Alexander Mikhaylenko's avatar Alexander Mikhaylenko
Browse files

leaflet: Add allow-visible child property



This will be used to prevent swiping to widgets such as separators.
Signed-off-by: Alexander Mikhaylenko's avatarAlexander Mikhaylenko <alexm@gnome.org>
parent 9f3c8cd9
......@@ -98,6 +98,7 @@ enum {
enum {
CHILD_PROP_0,
CHILD_PROP_NAME,
CHILD_PROP_ALLOW_VISIBLE,
LAST_CHILD_PROP,
};
......@@ -110,6 +111,7 @@ struct _HdyLeafletChildInfo
{
GtkWidget *widget;
gchar *name;
gboolean allow_visible;
/* Convenience storage for per-child temporary frequently computed values. */
GtkAllocation alloc;
......@@ -2785,6 +2787,7 @@ hdy_leaflet_add (GtkContainer *container,
child_info = g_new0 (HdyLeafletChildInfo, 1);
child_info->widget = widget;
child_info->allow_visible = TRUE;
priv->children = g_list_append (priv->children, child_info);
priv->children_reversed = g_list_prepend (priv->children_reversed, child_info);
......@@ -3035,6 +3038,10 @@ hdy_leaflet_get_child_property (GtkContainer *container,
g_value_set_string (value, child_info->name);
break;
case CHILD_PROP_ALLOW_VISIBLE:
g_value_set_boolean (value, child_info->allow_visible);
break;
default:
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
break;
......@@ -3087,6 +3094,16 @@ hdy_leaflet_set_child_property (GtkContainer *container,
break;
case CHILD_PROP_ALLOW_VISIBLE:
child_info->allow_visible = g_value_get_boolean (value);
gtk_container_child_notify_by_pspec (container, widget, pspec);
if (!child_info->allow_visible &&
hdy_leaflet_get_visible_child (self) == widget)
set_visible_child_info (self, NULL, get_old_child_transition_type (self), priv->child_transition.duration);
break;
default:
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
break;
......@@ -3385,6 +3402,23 @@ hdy_leaflet_class_init (HdyLeafletClass *klass)
NULL,
G_PARAM_READWRITE);
/**
* HdyLeaflet:allow-visible:
*
* Whether the child can be visible when folded. This can be used used in
* conjunction with #HdyLeaflet:can-swipe-back or
* #HdyLeaflet:can-swipe-forward to prevent switching to widgets like
* separators.
*
* Since: 0.0.12
*/
child_props[CHILD_PROP_ALLOW_VISIBLE] =
g_param_spec_boolean ("allow-visible",
_("Allow visible"),
_("Whether the child can be visible in folded mode"),
TRUE,
G_PARAM_READWRITE);
gtk_container_class_install_child_properties (container_class, LAST_CHILD_PROP, child_props);
gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_PANEL);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment