container: Remove gtk_container_set_resize_mode()

This commit is contained in:
Benjamin Otte 2016-10-09 03:14:32 +02:00
parent 4df6ddad54
commit d4d3374729
7 changed files with 20 additions and 241 deletions

View File

@ -974,9 +974,6 @@ GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID
gtk_container_add gtk_container_add
gtk_container_remove gtk_container_remove
gtk_container_add_with_properties gtk_container_add_with_properties
GtkResizeMode
gtk_container_get_resize_mode
gtk_container_set_resize_mode
gtk_container_check_resize gtk_container_check_resize
gtk_container_foreach gtk_container_foreach
gtk_container_get_children gtk_container_get_children

View File

@ -283,8 +283,6 @@ struct _GtkContainerPrivate
guint has_focus_chain : 1; guint has_focus_chain : 1;
guint reallocate_redraws : 1; guint reallocate_redraws : 1;
guint restyle_pending : 1; guint restyle_pending : 1;
guint resize_mode : 2;
guint resize_mode_set : 1;
guint request_mode : 2; guint request_mode : 2;
}; };
@ -298,7 +296,6 @@ enum {
enum { enum {
PROP_0, PROP_0,
PROP_RESIZE_MODE,
PROP_CHILD, PROP_CHILD,
LAST_PROP LAST_PROP
}; };
@ -502,14 +499,6 @@ gtk_container_class_init (GtkContainerClass *class)
class->composite_name = gtk_container_child_default_composite_name; class->composite_name = gtk_container_child_default_composite_name;
class->get_path_for_child = gtk_container_real_get_path_for_child; class->get_path_for_child = gtk_container_real_get_path_for_child;
container_props[PROP_RESIZE_MODE] =
g_param_spec_enum ("resize-mode",
P_("Resize mode"),
P_("Specify how resize events are handled"),
GTK_TYPE_RESIZE_MODE,
GTK_RESIZE_PARENT,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY|G_PARAM_DEPRECATED);
container_props[PROP_CHILD] = container_props[PROP_CHILD] =
g_param_spec_object ("child", g_param_spec_object ("child",
P_("Child"), P_("Child"),
@ -1642,7 +1631,6 @@ gtk_container_init (GtkContainer *container)
priv = container->priv; priv = container->priv;
priv->focus_child = NULL; priv->focus_child = NULL;
priv->resize_mode = GTK_RESIZE_PARENT;
priv->reallocate_redraws = FALSE; priv->reallocate_redraws = FALSE;
} }
@ -1678,11 +1666,6 @@ gtk_container_set_property (GObject *object,
switch (prop_id) switch (prop_id)
{ {
case PROP_RESIZE_MODE:
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gtk_container_set_resize_mode (container, g_value_get_enum (value));
G_GNUC_END_IGNORE_DEPRECATIONS;
break;
case PROP_CHILD: case PROP_CHILD:
gtk_container_add (container, GTK_WIDGET (g_value_get_object (value))); gtk_container_add (container, GTK_WIDGET (g_value_get_object (value)));
break; break;
@ -1698,14 +1681,11 @@ gtk_container_get_property (GObject *object,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GtkContainer *container = GTK_CONTAINER (object); //GtkContainer *container = GTK_CONTAINER (object);
GtkContainerPrivate *priv = container->priv; //GtkContainerPrivate *priv = container->priv;
switch (prop_id) switch (prop_id)
{ {
case PROP_RESIZE_MODE:
g_value_set_enum (value, priv->resize_mode);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -1790,91 +1770,6 @@ gtk_container_remove (GtkContainer *container,
g_object_unref (container); g_object_unref (container);
} }
static void
gtk_container_real_set_resize_mode (GtkContainer *container,
GtkResizeMode resize_mode)
{
GtkWidget *widget = GTK_WIDGET (container);
GtkContainerPrivate *priv = container->priv;
if (_gtk_widget_is_toplevel (widget) &&
resize_mode == GTK_RESIZE_PARENT)
{
resize_mode = GTK_RESIZE_QUEUE;
}
if (priv->resize_mode != resize_mode)
{
priv->resize_mode = resize_mode;
gtk_widget_queue_resize (widget);
g_object_notify_by_pspec (G_OBJECT (container), container_props[PROP_RESIZE_MODE]);
}
}
/**
* gtk_container_set_resize_mode:
* @container: a #GtkContainer
* @resize_mode: the new resize mode
*
* Sets the resize mode for the container.
*
* The resize mode of a container determines whether a resize request
* will be passed to the containers parent, queued for later execution
* or executed immediately.
*
* Deprecated: 3.12: Resize modes are deprecated. They arent necessary
* anymore since frame clocks and might introduce obscure bugs if
* used.
**/
void
gtk_container_set_resize_mode (GtkContainer *container,
GtkResizeMode resize_mode)
{
GtkContainerPrivate *priv;
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (resize_mode <= GTK_RESIZE_IMMEDIATE);
priv = container->priv;
priv->resize_mode_set = TRUE;
gtk_container_real_set_resize_mode (container, resize_mode);
}
void
gtk_container_set_default_resize_mode (GtkContainer *container,
GtkResizeMode resize_mode)
{
GtkContainerPrivate *priv = container->priv;
if (priv->resize_mode_set)
return;
gtk_container_real_set_resize_mode (container, resize_mode);
}
/**
* gtk_container_get_resize_mode:
* @container: a #GtkContainer
*
* Returns the resize mode for the container. See
* gtk_container_set_resize_mode ().
*
* Returns: the current resize mode
*
* Deprecated: 3.12: Resize modes are deprecated. They arent necessary
* anymore since frame clocks and might introduce obscure bugs if
* used.
**/
GtkResizeMode
gtk_container_get_resize_mode (GtkContainer *container)
{
g_return_val_if_fail (GTK_IS_CONTAINER (container), GTK_RESIZE_PARENT);
return container->priv->resize_mode;
}
/** /**
* gtk_container_set_reallocate_redraws: * gtk_container_set_reallocate_redraws:
* @container: a #GtkContainer * @container: a #GtkContainer
@ -1901,15 +1796,9 @@ gtk_container_needs_idle_sizer (GtkContainer *container)
{ {
GtkContainerPrivate *priv = container->priv; GtkContainerPrivate *priv = container->priv;
if (priv->resize_mode == GTK_RESIZE_PARENT) if (priv->restyle_pending)
return FALSE;
if (container->priv->restyle_pending)
return TRUE; return TRUE;
if (priv->resize_mode == GTK_RESIZE_IMMEDIATE)
return FALSE;
return gtk_widget_needs_allocate (GTK_WIDGET (container)); return gtk_widget_needs_allocate (GTK_WIDGET (container));
} }
@ -1991,32 +1880,13 @@ gtk_container_queue_resize_handler (GtkContainer *container)
{ {
GtkWidget *widget; GtkWidget *widget;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
g_return_if_fail (GTK_IS_RESIZE_CONTAINER (container));
G_GNUC_END_IGNORE_DEPRECATIONS;
widget = GTK_WIDGET (container); widget = GTK_WIDGET (container);
if (_gtk_widget_get_visible (widget) && if (_gtk_widget_get_visible (widget) &&
(_gtk_widget_is_toplevel (widget) || gtk_widget_needs_allocate (widget) &&
_gtk_widget_get_realized (widget))) _gtk_widget_is_toplevel (widget))
{ {
switch (container->priv->resize_mode) gtk_container_start_idle_sizer (container);
{
case GTK_RESIZE_QUEUE:
if (gtk_widget_needs_allocate (widget))
gtk_container_start_idle_sizer (container);
break;
case GTK_RESIZE_IMMEDIATE:
gtk_container_check_resize (container);
break;
case GTK_RESIZE_PARENT:
default:
g_assert_not_reached ();
break;
}
} }
} }
@ -2061,25 +1931,19 @@ gtk_container_real_check_resize (GtkContainer *container)
if (_gtk_widget_get_alloc_needed (widget)) if (_gtk_widget_get_alloc_needed (widget))
{ {
gtk_widget_get_preferred_size (widget, &requisition, NULL); if (_gtk_widget_is_toplevel (widget))
gtk_widget_get_allocated_size (widget, &allocation, &baseline); {
gtk_widget_get_preferred_size (widget, &requisition, NULL);
gtk_widget_get_allocated_size (widget, &allocation, &baseline);
if (requisition.width > allocation.width || if (allocation.width < requisition.width)
requisition.height > allocation.height) allocation.width = requisition.width;
{ if (allocation.height < requisition.height)
G_GNUC_BEGIN_IGNORE_DEPRECATIONS; allocation.height = requisition.height;
if (GTK_IS_RESIZE_CONTAINER (container))
{
gtk_widget_size_allocate (widget, &allocation);
}
else
gtk_widget_queue_resize (widget);
G_GNUC_END_IGNORE_DEPRECATIONS;
}
else
{
gtk_widget_size_allocate_with_baseline (widget, &allocation, baseline); gtk_widget_size_allocate_with_baseline (widget, &allocation, baseline);
} }
else
gtk_widget_queue_resize (widget);
} }
else else
{ {
@ -2087,39 +1951,6 @@ gtk_container_real_check_resize (GtkContainer *container)
} }
} }
/* The container hasn't changed size but one of its children
* queued a resize request. Which means that the allocation
* is not sufficient for the requisition of some child.
* Weve already performed a size request at this point,
* so we simply need to reallocate and let the allocation
* trickle down via GTK_WIDGET_ALLOC_NEEDED flags.
*/
/**
* gtk_container_resize_children:
* @container: a #GtkContainer
*
* Deprecated: 3.10
**/
void
gtk_container_resize_children (GtkContainer *container)
{
GtkAllocation allocation;
GtkWidget *widget;
gint baseline;
/* resizing invariants:
* toplevels have *always* resize_mode != GTK_RESIZE_PARENT set.
* containers that have an idle sizer pending must be flagged with
* RESIZE_PENDING.
*/
g_return_if_fail (GTK_IS_CONTAINER (container));
widget = GTK_WIDGET (container);
gtk_widget_get_allocated_size (widget, &allocation, &baseline);
gtk_widget_size_allocate_with_baseline (widget, &allocation, baseline);
}
typedef struct { typedef struct {
gint hfw; gint hfw;
gint wfh; gint wfh;

View File

@ -119,20 +119,6 @@ struct _GtkContainerClass
}; };
/**
* GtkResizeMode:
* @GTK_RESIZE_PARENT: Pass resize request to the parent
* @GTK_RESIZE_QUEUE: Queue resizes on this widget
* @GTK_RESIZE_IMMEDIATE: Resize immediately. Deprecated.
*/
typedef enum
{
GTK_RESIZE_PARENT,
GTK_RESIZE_QUEUE,
GTK_RESIZE_IMMEDIATE
} GtkResizeMode;
/* Application-level methods */ /* Application-level methods */
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
@ -145,12 +131,6 @@ GDK_AVAILABLE_IN_ALL
void gtk_container_remove (GtkContainer *container, void gtk_container_remove (GtkContainer *container,
GtkWidget *widget); GtkWidget *widget);
GDK_DEPRECATED_IN_3_12
void gtk_container_set_resize_mode (GtkContainer *container,
GtkResizeMode resize_mode);
GDK_DEPRECATED_IN_3_12
GtkResizeMode gtk_container_get_resize_mode (GtkContainer *container);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
void gtk_container_check_resize (GtkContainer *container); void gtk_container_check_resize (GtkContainer *container);
@ -175,9 +155,6 @@ gboolean gtk_container_get_focus_chain (GtkContainer *container,
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
void gtk_container_unset_focus_chain (GtkContainer *container); void gtk_container_unset_focus_chain (GtkContainer *container);
#define GTK_IS_RESIZE_CONTAINER(widget) (GTK_IS_CONTAINER (widget) && \
(gtk_container_get_resize_mode (GTK_CONTAINER (widget)) != GTK_RESIZE_PARENT))
/* Widget-level methods */ /* Widget-level methods */
GDK_DEPRECATED_IN_3_14 GDK_DEPRECATED_IN_3_14
@ -200,9 +177,6 @@ void gtk_container_set_focus_hadjustment (GtkContainer *container,
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GtkAdjustment *gtk_container_get_focus_hadjustment (GtkContainer *container); GtkAdjustment *gtk_container_get_focus_hadjustment (GtkContainer *container);
GDK_DEPRECATED_IN_3_10
void gtk_container_resize_children (GtkContainer *container);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GType gtk_container_child_type (GtkContainer *container); GType gtk_container_child_type (GtkContainer *container);

View File

@ -41,8 +41,6 @@ void _gtk_container_stop_idle_sizer (GtkContainer *container);
void _gtk_container_maybe_start_idle_sizer (GtkContainer *container); void _gtk_container_maybe_start_idle_sizer (GtkContainer *container);
void gtk_container_get_children_clip (GtkContainer *container, void gtk_container_get_children_clip (GtkContainer *container,
GtkAllocation *out_clip); GtkAllocation *out_clip);
void gtk_container_set_default_resize_mode (GtkContainer *container,
GtkResizeMode resize_mode);
G_END_DECLS G_END_DECLS

View File

@ -94,13 +94,11 @@ gtk_css_widget_node_queue_validate (GtkCssNode *node)
{ {
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node); GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS if (widget_node->widget && _gtk_widget_is_toplevel (widget_node->widget))
if (GTK_IS_RESIZE_CONTAINER (widget_node->widget))
widget_node->validate_cb_id = gtk_widget_add_tick_callback (widget_node->widget, widget_node->validate_cb_id = gtk_widget_add_tick_callback (widget_node->widget,
gtk_css_widget_node_queue_callback, gtk_css_widget_node_queue_callback,
node, node,
NULL); NULL);
G_GNUC_END_IGNORE_DEPRECATIONS
} }
static void static void
@ -108,11 +106,9 @@ gtk_css_widget_node_dequeue_validate (GtkCssNode *node)
{ {
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node); GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS if (widget_node->widget && _gtk_widget_is_toplevel (widget_node->widget))
if (GTK_IS_RESIZE_CONTAINER (widget_node->widget))
gtk_widget_remove_tick_callback (widget_node->widget, gtk_widget_remove_tick_callback (widget_node->widget,
widget_node->validate_cb_id); widget_node->validate_cb_id);
G_GNUC_END_IGNORE_DEPRECATIONS
} }
static void static void

View File

@ -5272,11 +5272,9 @@ G_GNUC_END_IGNORE_DEPRECATIONS
} }
} }
G_GNUC_BEGIN_IGNORE_DEPRECATIONS; if (_gtk_widget_is_toplevel (widget))
if (GTK_IS_RESIZE_CONTAINER (widget))
{ {
gtk_container_queue_resize_handler (GTK_CONTAINER (widget)); gtk_container_queue_resize_handler (GTK_CONTAINER (widget));
G_GNUC_END_IGNORE_DEPRECATIONS;
} }
else if (_gtk_widget_get_visible (widget)) else if (_gtk_widget_get_visible (widget))
{ {
@ -14948,13 +14946,11 @@ gtk_widget_set_alloc_needed (GtkWidget *widget)
if (!priv->visible) if (!priv->visible)
break; break;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS; if (_gtk_widget_is_toplevel (widget))
if (GTK_IS_RESIZE_CONTAINER (widget))
{ {
gtk_container_queue_resize_handler (GTK_CONTAINER (widget)); gtk_container_queue_resize_handler (GTK_CONTAINER (widget));
break; break;
} }
G_GNUC_END_IGNORE_DEPRECATIONS;
widget = priv->parent; widget = priv->parent;
if (widget == NULL) if (widget == NULL)

View File

@ -1603,8 +1603,6 @@ gtk_window_init (GtkWindow *window)
_gtk_widget_set_is_toplevel (widget, TRUE); _gtk_widget_set_is_toplevel (widget, TRUE);
_gtk_widget_set_anchored (widget, TRUE); _gtk_widget_set_anchored (widget, TRUE);
gtk_container_set_default_resize_mode (GTK_CONTAINER (window), GTK_RESIZE_QUEUE);
priv->title = NULL; priv->title = NULL;
priv->wm_role = NULL; priv->wm_role = NULL;
priv->geometry_info = NULL; priv->geometry_info = NULL;
@ -6893,8 +6891,6 @@ gtk_window_realize (GtkWidget *widget)
if (gtk_widget_get_parent_window (widget)) if (gtk_widget_get_parent_window (widget))
{ {
gtk_container_set_default_resize_mode (GTK_CONTAINER (widget), GTK_RESIZE_PARENT);
attributes.x = allocation.x; attributes.x = allocation.x;
attributes.y = allocation.y; attributes.y = allocation.y;
attributes.width = allocation.width; attributes.width = allocation.width;
@ -6925,8 +6921,6 @@ gtk_window_realize (GtkWidget *widget)
return; return;
} }
gtk_container_set_default_resize_mode (GTK_CONTAINER (window), GTK_RESIZE_QUEUE);
/* ensure widget tree is properly size allocated */ /* ensure widget tree is properly size allocated */
if (allocation.x == -1 && if (allocation.x == -1 &&
allocation.y == -1 && allocation.y == -1 &&
@ -9080,7 +9074,6 @@ gtk_window_move_resize (GtkWindow *window)
*/ */
GtkWindowPrivate *priv = window->priv; GtkWindowPrivate *priv = window->priv;
GtkWidget *widget; GtkWidget *widget;
GtkContainer *container;
GtkWindowGeometryInfo *info; GtkWindowGeometryInfo *info;
GdkGeometry new_geometry; GdkGeometry new_geometry;
GdkWindow *gdk_window; GdkWindow *gdk_window;
@ -9095,7 +9088,6 @@ gtk_window_move_resize (GtkWindow *window)
widget = GTK_WIDGET (window); widget = GTK_WIDGET (window);
gdk_window = _gtk_widget_get_window (widget); gdk_window = _gtk_widget_get_window (widget);
container = GTK_CONTAINER (widget);
info = gtk_window_get_geometry_info (window, TRUE); info = gtk_window_get_geometry_info (window, TRUE);
configure_request_size_changed = FALSE; configure_request_size_changed = FALSE;
@ -9378,11 +9370,6 @@ gtk_window_move_resize (GtkWindow *window)
allocation.height = new_request.height; allocation.height = new_request.height;
gtk_widget_size_allocate (widget, &allocation); gtk_widget_size_allocate (widget, &allocation);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
if (gtk_container_get_resize_mode (container) == GTK_RESIZE_QUEUE)
gtk_widget_queue_draw (widget);
G_GNUC_END_IGNORE_DEPRECATIONS;
} }
else else
{ {