Enforce the widget/child realization/mapping invariants.

Sat Jul  7 02:50:14 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkwidget.c (gtk_widget_set_parent): Enforce
	the widget/child realization/mapping invariants.

	* gtk/gtkwidget.[ch] gtk/gtkprivate.h: Add functions
	gtk_widget_[get/set]_child_visible() to control
	whether visible children of a mapped window are
	mapped.

	* docs/widget_system.txt: Updated for changes in
	container contract, and addition of GTK_CHILD_VISIBLE.

	* gtk/gtkcontainer.c: Add generic map()/unmap()
	functions that work for almost all containers.

	* gtk/gtknotebook.c gtk/gtkpacker.c: Use
	gtk_widget_set_child_visible() where necessary.

	* gtk/*.c: Remove excess map(), unmap(), and
	realization/mapping invariant enforcing code
	from many containers.
This commit is contained in:
Owen Taylor 2001-07-19 14:57:15 +00:00 committed by Owen Taylor
parent 8f2bf7976d
commit aa49527fa7
38 changed files with 417 additions and 937 deletions

View File

@ -1,7 +1,30 @@
Sat Jul 7 02:50:14 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_set_parent): Enforce
the widget/child realization/mapping invariants.
* gtk/gtkwidget.[ch] gtk/gtkprivate.h: Add functions
gtk_widget_[get/set]_child_visible() to control
whether visible children of a mapped window are
mapped.
* docs/widget_system.txt: Updated for changes in
container contract, and addition of GTK_CHILD_VISIBLE.
* gtk/gtkcontainer.c: Add generic map()/unmap()
functions that work for almost all containers.
* gtk/gtknotebook.c gtk/gtkpacker.c: Use
gtk_widget_set_child_visible() where necessary.
* gtk/*.c: Remove excess map(), unmap(), and
realization/mapping invariant enforcing code
from many containers.
Wed Jul 18 19:51:45 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.c (gtk_text_view_set_attributes_from_style):
Get the foreground color from 'text', nor 'base'. (#57568)
Get the foreground color from 'text', nor 'fg'. (#57568)
Wed Jul 18 19:28:46 2001 Owen Taylor <otaylor@redhat.com>

View File

@ -1,7 +1,30 @@
Sat Jul 7 02:50:14 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_set_parent): Enforce
the widget/child realization/mapping invariants.
* gtk/gtkwidget.[ch] gtk/gtkprivate.h: Add functions
gtk_widget_[get/set]_child_visible() to control
whether visible children of a mapped window are
mapped.
* docs/widget_system.txt: Updated for changes in
container contract, and addition of GTK_CHILD_VISIBLE.
* gtk/gtkcontainer.c: Add generic map()/unmap()
functions that work for almost all containers.
* gtk/gtknotebook.c gtk/gtkpacker.c: Use
gtk_widget_set_child_visible() where necessary.
* gtk/*.c: Remove excess map(), unmap(), and
realization/mapping invariant enforcing code
from many containers.
Wed Jul 18 19:51:45 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.c (gtk_text_view_set_attributes_from_style):
Get the foreground color from 'text', nor 'base'. (#57568)
Get the foreground color from 'text', nor 'fg'. (#57568)
Wed Jul 18 19:28:46 2001 Owen Taylor <otaylor@redhat.com>

View File

@ -1,7 +1,30 @@
Sat Jul 7 02:50:14 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_set_parent): Enforce
the widget/child realization/mapping invariants.
* gtk/gtkwidget.[ch] gtk/gtkprivate.h: Add functions
gtk_widget_[get/set]_child_visible() to control
whether visible children of a mapped window are
mapped.
* docs/widget_system.txt: Updated for changes in
container contract, and addition of GTK_CHILD_VISIBLE.
* gtk/gtkcontainer.c: Add generic map()/unmap()
functions that work for almost all containers.
* gtk/gtknotebook.c gtk/gtkpacker.c: Use
gtk_widget_set_child_visible() where necessary.
* gtk/*.c: Remove excess map(), unmap(), and
realization/mapping invariant enforcing code
from many containers.
Wed Jul 18 19:51:45 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.c (gtk_text_view_set_attributes_from_style):
Get the foreground color from 'text', nor 'base'. (#57568)
Get the foreground color from 'text', nor 'fg'. (#57568)
Wed Jul 18 19:28:46 2001 Owen Taylor <otaylor@redhat.com>

View File

@ -1,7 +1,30 @@
Sat Jul 7 02:50:14 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_set_parent): Enforce
the widget/child realization/mapping invariants.
* gtk/gtkwidget.[ch] gtk/gtkprivate.h: Add functions
gtk_widget_[get/set]_child_visible() to control
whether visible children of a mapped window are
mapped.
* docs/widget_system.txt: Updated for changes in
container contract, and addition of GTK_CHILD_VISIBLE.
* gtk/gtkcontainer.c: Add generic map()/unmap()
functions that work for almost all containers.
* gtk/gtknotebook.c gtk/gtkpacker.c: Use
gtk_widget_set_child_visible() where necessary.
* gtk/*.c: Remove excess map(), unmap(), and
realization/mapping invariant enforcing code
from many containers.
Wed Jul 18 19:51:45 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.c (gtk_text_view_set_attributes_from_style):
Get the foreground color from 'text', nor 'base'. (#57568)
Get the foreground color from 'text', nor 'fg'. (#57568)
Wed Jul 18 19:28:46 2001 Owen Taylor <otaylor@redhat.com>

View File

@ -1,7 +1,30 @@
Sat Jul 7 02:50:14 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_set_parent): Enforce
the widget/child realization/mapping invariants.
* gtk/gtkwidget.[ch] gtk/gtkprivate.h: Add functions
gtk_widget_[get/set]_child_visible() to control
whether visible children of a mapped window are
mapped.
* docs/widget_system.txt: Updated for changes in
container contract, and addition of GTK_CHILD_VISIBLE.
* gtk/gtkcontainer.c: Add generic map()/unmap()
functions that work for almost all containers.
* gtk/gtknotebook.c gtk/gtkpacker.c: Use
gtk_widget_set_child_visible() where necessary.
* gtk/*.c: Remove excess map(), unmap(), and
realization/mapping invariant enforcing code
from many containers.
Wed Jul 18 19:51:45 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.c (gtk_text_view_set_attributes_from_style):
Get the foreground color from 'text', nor 'base'. (#57568)
Get the foreground color from 'text', nor 'fg'. (#57568)
Wed Jul 18 19:28:46 2001 Owen Taylor <otaylor@redhat.com>

View File

@ -1,7 +1,30 @@
Sat Jul 7 02:50:14 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_set_parent): Enforce
the widget/child realization/mapping invariants.
* gtk/gtkwidget.[ch] gtk/gtkprivate.h: Add functions
gtk_widget_[get/set]_child_visible() to control
whether visible children of a mapped window are
mapped.
* docs/widget_system.txt: Updated for changes in
container contract, and addition of GTK_CHILD_VISIBLE.
* gtk/gtkcontainer.c: Add generic map()/unmap()
functions that work for almost all containers.
* gtk/gtknotebook.c gtk/gtkpacker.c: Use
gtk_widget_set_child_visible() where necessary.
* gtk/*.c: Remove excess map(), unmap(), and
realization/mapping invariant enforcing code
from many containers.
Wed Jul 18 19:51:45 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.c (gtk_text_view_set_attributes_from_style):
Get the foreground color from 'text', nor 'base'. (#57568)
Get the foreground color from 'text', nor 'fg'. (#57568)
Wed Jul 18 19:28:46 2001 Owen Taylor <otaylor@redhat.com>

View File

@ -1,7 +1,30 @@
Sat Jul 7 02:50:14 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_set_parent): Enforce
the widget/child realization/mapping invariants.
* gtk/gtkwidget.[ch] gtk/gtkprivate.h: Add functions
gtk_widget_[get/set]_child_visible() to control
whether visible children of a mapped window are
mapped.
* docs/widget_system.txt: Updated for changes in
container contract, and addition of GTK_CHILD_VISIBLE.
* gtk/gtkcontainer.c: Add generic map()/unmap()
functions that work for almost all containers.
* gtk/gtknotebook.c gtk/gtkpacker.c: Use
gtk_widget_set_child_visible() where necessary.
* gtk/*.c: Remove excess map(), unmap(), and
realization/mapping invariant enforcing code
from many containers.
Wed Jul 18 19:51:45 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.c (gtk_text_view_set_attributes_from_style):
Get the foreground color from 'text', nor 'base'. (#57568)
Get the foreground color from 'text', nor 'fg'. (#57568)
Wed Jul 18 19:28:46 2001 Owen Taylor <otaylor@redhat.com>

View File

@ -396,3 +396,33 @@ Incompatible Changes from GTK+-1.2 to GTK+-2.0:
undefined contents for the offscreen areas. In most cases, code
using gdk_image_get() should really be ported to
gdk_pixbuf_get_from_drawable().
* The core GTK+ now takes care of handling mapping, unmapping and
realizing the child widgets of containers in
gtk_widget_set_parent(). In most cases, this allows container
implementations to be simplifid by removing the code in add()
methods to map and realize children. However, there are
a couple of things to watch out for here:
- If the parent is realized before the add() happens,
gtk_widget_set_parent_window() must be called before
gtk_widget_set_parent(), since gtk_widget_set_parent()
will realize the child.
- If a container depended on its children not being mapped
unless it did so itself (for example, GtkNotebook only
mapped the current page), then the new function
gtk_widget_set_child_visible() must be called to keep
widgets that should not be mapped not mapped.
As part of this change, most containers also will no longer need
custom implementations of the map() and unmap() virtual
functions. The only cases where this is necessary are:
- For !NO_WINDOW widgets, if you create children of widget->window
and don't map them in realize() then you must map them
in map(). [ In almost all cases, you can simply map the
windows in realize() ]
- For NO_WINDOW widgets, if you create windows in your realize()
method, you must map then in map() and unmap them in unmap().

View File

@ -495,7 +495,6 @@ This can later be composited together with other
#GtkRcStyle structures to form a #GtkStyle.
</para>
@parent_instance:
@name:
@bg_pixmap_name:
@font_desc:

View File

@ -88,6 +88,14 @@ GTK_VISIBLE:
Set by gtk_widget_hide.
Implies that a widget is not onscreen, therefore !GTK_MAPPED.
GTK_CHILD_VISIBLE
Set by gtk_widget_set_child_visible, and if FALSE indicates that
the widget should not be mapped even if the parent is mapped
and visible. Containers like GtkNotebook use this flag.
A private flag, not a public flag, so if you need to check
this flag, you should call gtk_widget_get_child_visible().
(Should be very rarely necesary.)
GTK_SENSITIVE:
Set and unset by gtk_widget_set_sensitive.
The sensitivity of a widget determines whether it will receive
@ -228,10 +236,12 @@ In the following
5) if !GTK_WIDGET_TOPLEVEL (widget):
GTK_WIDGET_MAPPED (widget) => GTK_WIDGET_VISIBLE (widget)
=> GTK_WIDGET_CHILD_VISIBLE (widget)
=> GTK_WIDGET_REALIZED (widget)
widget->parent && GTK_WIDGET_MAPPED (widget->parent) &&
GTK_WIDGET_VISIBLE (widget) => GTK_WIDGET_MAPPED (widget)
GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_CHILD_VISIBLE
=> GTK_WIDGET_MAPPED (widget)
Note:, the definition
@ -305,18 +315,9 @@ Adding to a container
When a widget is added to a container, the container:
1) calls gtk_widget_set_parent (widget, container)
2) calls gtk_widget_set_parent_window (widget, window) if
1) calls gtk_widget_set_parent_window (widget, window) if
the widget is being added to something other than container->window
3) if container is realized, and not widget, realizes widget
4) if container is mapped, and not widget and widget is GTK_VISIBLE,
maps widget
5) Queues a resize if the widget is mapped
Note: It would be nice to remove 3) and 4) out of widget specific code
since they are of the invariant-enforcing nature, but it is
a bit hard, since they can't be done until after 2)
2) calls gtk_widget_set_parent (widget, container)
Removing from a container
-------------------------
@ -369,7 +370,9 @@ The Map signal
1) Set the MAPPED flag
2) If the widget has any windows, gdk_window_show those windows
3) call gtk_widget_map for all child widgets that are
VISIBLE and !MAPPED.
VISIBLE, CHILD_VISIBLE and !MAPPED. (A widget will only
be !CHILD_VISIBLE if the container set it that way, so
most containers will not have to check this.)
3) Do any other functions related to putting the widget onscreen.
(for instance, showing extra popup windows...)

View File

@ -29,8 +29,6 @@
static void gtk_bin_class_init (GtkBinClass *klass);
static void gtk_bin_init (GtkBin *bin);
static void gtk_bin_map (GtkWidget *widget);
static void gtk_bin_unmap (GtkWidget *widget);
static void gtk_bin_add (GtkContainer *container,
GtkWidget *widget);
static void gtk_bin_remove (GtkContainer *container,
@ -83,9 +81,6 @@ gtk_bin_class_init (GtkBinClass *class)
parent_class = gtk_type_class (GTK_TYPE_CONTAINER);
widget_class->map = gtk_bin_map;
widget_class->unmap = gtk_bin_unmap;
container_class->add = gtk_bin_add;
container_class->remove = gtk_bin_remove;
container_class->forall = gtk_bin_forall;
@ -110,42 +105,6 @@ gtk_bin_child_type (GtkContainer *container)
return GTK_TYPE_NONE;
}
static void
gtk_bin_map (GtkWidget *widget)
{
GtkBin *bin;
g_return_if_fail (GTK_IS_BIN (widget));
GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
bin = GTK_BIN (widget);
if (bin->child &&
GTK_WIDGET_VISIBLE (bin->child) &&
!GTK_WIDGET_MAPPED (bin->child))
gtk_widget_map (bin->child);
if (!GTK_WIDGET_NO_WINDOW (widget))
gdk_window_show (widget->window);
}
static void
gtk_bin_unmap (GtkWidget *widget)
{
GtkBin *bin;
g_return_if_fail (GTK_IS_BIN (widget));
GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
bin = GTK_BIN (widget);
if (!GTK_WIDGET_NO_WINDOW (widget))
gdk_window_hide (widget->window);
if (bin->child && GTK_WIDGET_MAPPED (bin->child))
gtk_widget_unmap (bin->child);
}
static void
gtk_bin_add (GtkContainer *container,
GtkWidget *child)
@ -171,17 +130,6 @@ gtk_bin_add (GtkContainer *container,
gtk_widget_set_parent (child, GTK_WIDGET (bin));
bin->child = child;
if (GTK_WIDGET_REALIZED (child->parent))
gtk_widget_realize (child);
if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
{
if (GTK_WIDGET_MAPPED (child->parent))
gtk_widget_map (child);
gtk_widget_queue_resize (child);
}
}
static void

View File

@ -52,8 +52,6 @@ static void gtk_box_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void gtk_box_map (GtkWidget *widget);
static void gtk_box_unmap (GtkWidget *widget);
static void gtk_box_add (GtkContainer *container,
GtkWidget *widget);
static void gtk_box_remove (GtkContainer *container,
@ -115,9 +113,6 @@ gtk_box_class_init (GtkBoxClass *class)
gobject_class->set_property = gtk_box_set_property;
gobject_class->get_property = gtk_box_get_property;
widget_class->map = gtk_box_map;
widget_class->unmap = gtk_box_unmap;
container_class->add = gtk_box_add;
container_class->remove = gtk_box_remove;
container_class->forall = gtk_box_forall;
@ -378,16 +373,6 @@ gtk_box_pack_start (GtkBox *box,
gtk_widget_set_parent (child, GTK_WIDGET (box));
if (GTK_WIDGET_REALIZED (box))
gtk_widget_realize (child);
if (GTK_WIDGET_VISIBLE (box) && GTK_WIDGET_VISIBLE (child))
{
if (GTK_WIDGET_MAPPED (box))
gtk_widget_map (child);
gtk_widget_queue_resize (child);
}
gtk_widget_child_notify (child, "expand");
gtk_widget_child_notify (child, "fill");
gtk_widget_child_notify (child, "padding");
@ -423,16 +408,6 @@ gtk_box_pack_end (GtkBox *box,
gtk_widget_set_parent (child, GTK_WIDGET (box));
if (GTK_WIDGET_REALIZED (box))
gtk_widget_realize (child);
if (GTK_WIDGET_VISIBLE (box) && GTK_WIDGET_VISIBLE (child))
{
if (GTK_WIDGET_MAPPED (box))
gtk_widget_map (child);
gtk_widget_queue_resize (child);
}
gtk_widget_child_notify (child, "expand");
gtk_widget_child_notify (child, "fill");
gtk_widget_child_notify (child, "padding");
@ -667,54 +642,6 @@ gtk_box_set_child_packing (GtkBox *box,
gtk_widget_thaw_child_notify (child);
}
static void
gtk_box_map (GtkWidget *widget)
{
GtkBox *box;
GtkBoxChild *child;
GList *children;
g_return_if_fail (GTK_IS_BOX (widget));
box = GTK_BOX (widget);
GTK_WIDGET_SET_FLAGS (box, GTK_MAPPED);
children = box->children;
while (children)
{
child = children->data;
children = children->next;
if (GTK_WIDGET_VISIBLE (child->widget) &&
!GTK_WIDGET_MAPPED (child->widget))
gtk_widget_map (child->widget);
}
}
static void
gtk_box_unmap (GtkWidget *widget)
{
GtkBox *box;
GtkBoxChild *child;
GList *children;
g_return_if_fail (GTK_IS_BOX (widget));
box = GTK_BOX (widget);
GTK_WIDGET_UNSET_FLAGS (box, GTK_MAPPED);
children = box->children;
while (children)
{
child = children->data;
children = children->next;
if (GTK_WIDGET_VISIBLE (child->widget) &&
GTK_WIDGET_MAPPED (child->widget))
gtk_widget_unmap (child->widget);
}
}
static void
gtk_box_add (GtkContainer *container,
GtkWidget *widget)

View File

@ -98,6 +98,9 @@ static void gtk_container_show_all (GtkWidget *widget);
static void gtk_container_hide_all (GtkWidget *widget);
static gint gtk_container_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_container_map (GtkWidget *widget);
static void gtk_container_unmap (GtkWidget *widget);
static gchar* gtk_container_child_default_composite_name (GtkContainer *container,
GtkWidget *child);
@ -186,6 +189,8 @@ gtk_container_class_init (GtkContainerClass *class)
widget_class->show_all = gtk_container_show_all;
widget_class->hide_all = gtk_container_hide_all;
widget_class->expose_event = gtk_container_expose;
widget_class->map = gtk_container_map;
widget_class->unmap = gtk_container_unmap;
widget_class->focus = gtk_container_focus;
class->add = gtk_container_add_unimplemented;
@ -2314,6 +2319,41 @@ gtk_container_expose (GtkWidget *widget,
return TRUE;
}
static void
gtk_container_map_child (GtkWidget *child,
gpointer client_data)
{
if (GTK_WIDGET_VISIBLE (child) &&
GTK_WIDGET_CHILD_VISIBLE (child) &&
!GTK_WIDGET_MAPPED (child))
gtk_widget_map (child);
}
static void
gtk_container_map (GtkWidget *widget)
{
GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
gtk_container_forall (GTK_CONTAINER (widget),
gtk_container_map_child,
NULL);
if (!GTK_WIDGET_NO_WINDOW (widget))
gdk_window_show (widget->window);
}
static void
gtk_container_unmap (GtkWidget *widget)
{
GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
if (!GTK_WIDGET_NO_WINDOW (widget))
gdk_window_hide (widget->window);
else
gtk_container_forall (GTK_CONTAINER (widget),
(GtkCallback)gtk_widget_unmap,
NULL);
}
/**
* gtk_container_propagate_expose:

View File

@ -191,7 +191,6 @@ void gtk_container_child_get_property (GtkContainer *container,
GtkWidget *child,
const gchar *property_name,
GValue *value);
#define GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID(object, property_id, pspec) \
G_OBJECT_WARN_INVALID_PSPEC ((object), "child property id", (property_id), (pspec))

View File

@ -29,7 +29,6 @@
static void gtk_fixed_class_init (GtkFixedClass *klass);
static void gtk_fixed_init (GtkFixed *fixed);
static void gtk_fixed_map (GtkWidget *widget);
static void gtk_fixed_realize (GtkWidget *widget);
static void gtk_fixed_size_request (GtkWidget *widget,
GtkRequisition *requisition);
@ -87,7 +86,6 @@ gtk_fixed_class_init (GtkFixedClass *class)
parent_class = gtk_type_class (GTK_TYPE_CONTAINER);
widget_class->map = gtk_fixed_map;
widget_class->realize = gtk_fixed_realize;
widget_class->size_request = gtk_fixed_size_request;
widget_class->size_allocate = gtk_fixed_size_allocate;
@ -140,17 +138,6 @@ gtk_fixed_put (GtkFixed *fixed,
gtk_widget_set_parent (widget, GTK_WIDGET (fixed));
fixed->children = g_list_append (fixed->children, child_info);
if (GTK_WIDGET_REALIZED (fixed))
gtk_widget_realize (widget);
if (GTK_WIDGET_VISIBLE (fixed) && GTK_WIDGET_VISIBLE (widget))
{
if (GTK_WIDGET_MAPPED (fixed))
gtk_widget_map (widget);
gtk_widget_queue_resize (GTK_WIDGET (fixed));
}
}
void
@ -184,32 +171,6 @@ gtk_fixed_move (GtkFixed *fixed,
}
}
static void
gtk_fixed_map (GtkWidget *widget)
{
GtkFixed *fixed;
GtkFixedChild *child;
GList *children;
g_return_if_fail (GTK_IS_FIXED (widget));
GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
fixed = GTK_FIXED (widget);
children = fixed->children;
while (children)
{
child = children->data;
children = children->next;
if (GTK_WIDGET_VISIBLE (child->widget) &&
!GTK_WIDGET_MAPPED (child->widget))
gtk_widget_map (child->widget);
}
gdk_window_show (widget->window);
}
static void
gtk_fixed_realize (GtkWidget *widget)
{

View File

@ -60,8 +60,6 @@ static void gtk_frame_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_frame_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_frame_map (GtkWidget *widget);
static void gtk_frame_unmap (GtkWidget *widget);
static void gtk_frame_remove (GtkContainer *container,
GtkWidget *child);
static void gtk_frame_forall (GtkContainer *container,
@ -168,8 +166,6 @@ gtk_frame_class_init (GtkFrameClass *class)
widget_class->expose_event = gtk_frame_expose;
widget_class->size_request = gtk_frame_size_request;
widget_class->size_allocate = gtk_frame_size_allocate;
widget_class->map = gtk_frame_map;
widget_class->unmap = gtk_frame_unmap;
container_class->remove = gtk_frame_remove;
container_class->forall = gtk_frame_forall;
@ -638,32 +634,6 @@ gtk_frame_size_allocate (GtkWidget *widget,
}
}
static void
gtk_frame_map (GtkWidget *widget)
{
GtkFrame *frame = GTK_FRAME (widget);
if (frame->label_widget &&
GTK_WIDGET_VISIBLE (frame->label_widget) &&
!GTK_WIDGET_MAPPED (frame->label_widget))
gtk_widget_map (frame->label_widget);
if (GTK_WIDGET_CLASS (parent_class)->map)
(* GTK_WIDGET_CLASS (parent_class)->map) (widget);
}
static void
gtk_frame_unmap (GtkWidget *widget)
{
GtkFrame *frame = GTK_FRAME (widget);
if (GTK_WIDGET_CLASS (parent_class)->unmap)
(* GTK_WIDGET_CLASS (parent_class)->unmap) (widget);
if (frame->label_widget && GTK_WIDGET_MAPPED (frame->label_widget))
gtk_widget_unmap (frame->label_widget);
}
static void
gtk_frame_compute_child_allocation (GtkFrame *frame,
GtkAllocation *child_allocation)

View File

@ -87,8 +87,6 @@ enum {
static void gtk_hsv_class_init (GtkHSVClass *class);
static void gtk_hsv_init (GtkHSV *hsv);
static void gtk_hsv_destroy (GtkObject *object);
static void gtk_hsv_map (GtkWidget *widget);
static void gtk_hsv_unmap (GtkWidget *widget);
static void gtk_hsv_realize (GtkWidget *widget);
static void gtk_hsv_unrealize (GtkWidget *widget);
static void gtk_hsv_size_request (GtkWidget *widget,
@ -162,8 +160,6 @@ gtk_hsv_class_init (GtkHSVClass *class)
object_class->destroy = gtk_hsv_destroy;
widget_class->map = gtk_hsv_map;
widget_class->unmap = gtk_hsv_unmap;
widget_class->realize = gtk_hsv_realize;
widget_class->unrealize = gtk_hsv_unrealize;
widget_class->size_request = gtk_hsv_size_request;
@ -265,42 +261,6 @@ gtk_hsv_destroy (GtkObject *object)
/* Default signal handlers */
/* Map handler for the HSV color selector */
static void
gtk_hsv_map (GtkWidget *widget)
{
GtkHSV *hsv;
HSVPrivate *priv;
hsv = GTK_HSV (widget);
priv = hsv->priv;
if (GTK_WIDGET_MAPPED (widget))
return;
GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
gdk_window_show (priv->window);
}
/* Unmap handler for the HSV color selector */
static void
gtk_hsv_unmap (GtkWidget *widget)
{
GtkHSV *hsv;
HSVPrivate *priv;
hsv = GTK_HSV (widget);
priv = hsv->priv;
if (!GTK_WIDGET_MAPPED (widget))
return;
GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
gdk_window_hide (priv->window);
}
/* Realize handler for the HSV color selector */
static void
gtk_hsv_realize (GtkWidget *widget)

View File

@ -43,8 +43,6 @@ static void gtk_image_menu_item_remove (GtkContainer *con
static void gtk_image_menu_item_toggle_size_request (GtkMenuItem *menu_item,
gint *requisition);
static void gtk_image_menu_item_map (GtkWidget *widget);
static void gtk_image_menu_item_unmap (GtkWidget *widget);
static void gtk_image_menu_item_forall (GtkContainer *container,
gboolean include_internals,
GtkCallback callback,
@ -111,8 +109,6 @@ gtk_image_menu_item_class_init (GtkImageMenuItemClass *klass)
widget_class->size_request = gtk_image_menu_item_size_request;
widget_class->size_allocate = gtk_image_menu_item_size_allocate;
widget_class->map = gtk_image_menu_item_map;
widget_class->unmap = gtk_image_menu_item_unmap;
container_class->forall = gtk_image_menu_item_forall;
container_class->remove = gtk_image_menu_item_remove;
@ -267,44 +263,6 @@ gtk_image_menu_item_size_allocate (GtkWidget *widget,
}
}
static void
gtk_image_menu_item_map (GtkWidget *widget)
{
GtkImageMenuItem *image_menu_item;
g_return_if_fail (GTK_IS_IMAGE_MENU_ITEM (widget));
image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
(* GTK_WIDGET_CLASS (parent_class)->map) (widget);
if (image_menu_item->image &&
GTK_WIDGET_VISIBLE (image_menu_item->image) &&
!GTK_WIDGET_MAPPED (image_menu_item->image))
gtk_widget_map (image_menu_item->image);
if (!GTK_WIDGET_NO_WINDOW (widget))
gdk_window_show (widget->window);
}
static void
gtk_image_menu_item_unmap (GtkWidget *widget)
{
GtkImageMenuItem *image_menu_item;
g_return_if_fail (GTK_IS_IMAGE_MENU_ITEM (widget));
image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
(* GTK_WIDGET_CLASS (parent_class)->unmap) (widget);
if (!GTK_WIDGET_NO_WINDOW (widget))
gdk_window_hide (widget->window);
if (image_menu_item->image && GTK_WIDGET_MAPPED (image_menu_item->image))
gtk_widget_unmap (image_menu_item->image);
}
static void
gtk_image_menu_item_forall (GtkContainer *container,
gboolean include_internals,
@ -442,17 +400,6 @@ gtk_image_menu_item_set_image (GtkImageMenuItem *image_menu_item,
gtk_widget_set_parent (image, GTK_WIDGET (image_menu_item));
g_object_notify (G_OBJECT (image_menu_item), "image");
if (GTK_WIDGET_REALIZED (image->parent))
gtk_widget_realize (image);
if (GTK_WIDGET_VISIBLE (image->parent) && GTK_WIDGET_VISIBLE (image))
{
if (GTK_WIDGET_MAPPED (image->parent))
gtk_widget_map (image);
gtk_widget_queue_resize (image);
}
}
GtkWidget*

View File

@ -38,8 +38,6 @@ enum {
static void gtk_item_class_init (GtkItemClass *klass);
static void gtk_item_init (GtkItem *item);
static void gtk_item_map (GtkWidget *widget);
static void gtk_item_unmap (GtkWidget *widget);
static void gtk_item_realize (GtkWidget *widget);
static gint gtk_item_enter (GtkWidget *widget,
GdkEventCrossing *event);
@ -85,8 +83,6 @@ gtk_item_class_init (GtkItemClass *class)
widget_class = (GtkWidgetClass*) class;
widget_class->map = gtk_item_map;
widget_class->unmap = gtk_item_unmap;
widget_class->realize = gtk_item_realize;
widget_class->enter_notify_event = gtk_item_enter;
widget_class->leave_notify_event = gtk_item_leave;
@ -144,35 +140,6 @@ gtk_item_toggle (GtkItem *item)
}
static void
gtk_item_map (GtkWidget *widget)
{
GtkBin *bin;
g_return_if_fail (GTK_IS_ITEM (widget));
GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
bin = GTK_BIN (widget);
if (bin->child &&
GTK_WIDGET_VISIBLE (bin->child) &&
!GTK_WIDGET_MAPPED (bin->child))
gtk_widget_map (bin->child);
gdk_window_show (widget->window);
}
static void
gtk_item_unmap (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_ITEM (widget));
GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
gdk_window_hide (widget->window);
}
static void
gtk_item_realize (GtkWidget *widget)
{

View File

@ -233,20 +233,10 @@ gtk_layout_put (GtkLayout *layout,
layout->children = g_list_append (layout->children, child);
gtk_widget_set_parent (child_widget, GTK_WIDGET (layout));
if (GTK_WIDGET_REALIZED (layout))
gtk_widget_set_parent_window (child->widget, layout->bin_window);
if (GTK_WIDGET_REALIZED (layout))
gtk_widget_realize (child_widget);
if (GTK_WIDGET_VISIBLE (layout) && GTK_WIDGET_VISIBLE (child_widget))
{
if (GTK_WIDGET_MAPPED (layout))
gtk_widget_map (child_widget);
gtk_widget_queue_resize (child_widget);
}
gtk_widget_set_parent (child_widget, GTK_WIDGET (layout));
}
void

View File

@ -64,7 +64,6 @@ static void gtk_list_size_request (GtkWidget *widget,
static void gtk_list_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_list_realize (GtkWidget *widget);
static void gtk_list_map (GtkWidget *widget);
static void gtk_list_unmap (GtkWidget *widget);
static void gtk_list_style_set (GtkWidget *widget,
GtkStyle *previous_style);
@ -219,7 +218,6 @@ gtk_list_class_init (GtkListClass *class)
object_class->set_arg = gtk_list_set_arg;
object_class->get_arg = gtk_list_get_arg;
widget_class->map = gtk_list_map;
widget_class->unmap = gtk_list_unmap;
widget_class->style_set = gtk_list_style_set;
widget_class->realize = gtk_list_realize;
@ -352,7 +350,6 @@ gtk_list_dispose (GObject *object)
* gtk_list_size_request
* gtk_list_size_allocate
* gtk_list_realize
* gtk_list_map
* gtk_list_unmap
* gtk_list_motion_notify
* gtk_list_button_press
@ -478,32 +475,6 @@ gtk_list_realize (GtkWidget *widget)
&widget->style->base[GTK_STATE_NORMAL]);
}
static void
gtk_list_map (GtkWidget *widget)
{
GtkList *list;
GtkWidget *child;
GList *children;
g_return_if_fail (GTK_IS_LIST (widget));
GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
list = GTK_LIST (widget);
children = list->children;
while (children)
{
child = children->data;
children = children->next;
if (GTK_WIDGET_VISIBLE (child) &&
!GTK_WIDGET_MAPPED (child))
gtk_widget_map (child);
}
gdk_window_show (widget->window);
}
static void
gtk_list_unmap (GtkWidget *widget)
{
@ -1077,17 +1048,6 @@ gtk_list_insert_items (GtkList *list,
gtk_signal_connect (GTK_OBJECT (widget), "toggle",
GTK_SIGNAL_FUNC (gtk_list_signal_item_toggle),
list);
if (GTK_WIDGET_REALIZED (widget->parent))
gtk_widget_realize (widget);
if (GTK_WIDGET_VISIBLE (widget->parent) && GTK_WIDGET_VISIBLE (widget))
{
if (GTK_WIDGET_MAPPED (widget->parent))
gtk_widget_map (widget);
gtk_widget_queue_resize (widget);
}
}

View File

@ -452,9 +452,10 @@ gtk_menu_insert (GtkMenuShell *menu_shell,
GtkWidget *child,
gint position)
{
GTK_MENU_SHELL_CLASS (parent_class)->insert (menu_shell, child, position);
if (GTK_WIDGET_REALIZED (menu_shell))
gtk_widget_set_parent_window (child, GTK_MENU (menu_shell)->bin_window);
gtk_widget_set_parent_window (child, GTK_MENU (menu_shell)->bin_window);
GTK_MENU_SHELL_CLASS (parent_class)->insert (menu_shell, child, position);
}
static void

View File

@ -109,7 +109,6 @@ typedef void (*GtkMenuShellSignal2) (GtkObject *object,
static void gtk_menu_shell_class_init (GtkMenuShellClass *klass);
static void gtk_menu_shell_init (GtkMenuShell *menu_shell);
static void gtk_menu_shell_map (GtkWidget *widget);
static void gtk_menu_shell_realize (GtkWidget *widget);
static gint gtk_menu_shell_button_press (GtkWidget *widget,
GdkEventButton *event);
@ -192,7 +191,6 @@ gtk_menu_shell_class_init (GtkMenuShellClass *klass)
parent_class = gtk_type_class (gtk_container_get_type ());
widget_class->map = gtk_menu_shell_map;
widget_class->realize = gtk_menu_shell_realize;
widget_class->button_press_event = gtk_menu_shell_button_press;
widget_class->button_release_event = gtk_menu_shell_button_release;
@ -337,17 +335,6 @@ gtk_menu_shell_real_insert (GtkMenuShell *menu_shell,
menu_shell->children = g_list_insert (menu_shell->children, child, position);
gtk_widget_set_parent (child, GTK_WIDGET (menu_shell));
if (GTK_WIDGET_REALIZED (child->parent))
gtk_widget_realize (child);
if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
{
if (GTK_WIDGET_MAPPED (child->parent))
gtk_widget_map (child);
gtk_widget_queue_resize (child);
}
}
void
@ -358,31 +345,6 @@ gtk_menu_shell_deactivate (GtkMenuShell *menu_shell)
gtk_signal_emit (GTK_OBJECT (menu_shell), menu_shell_signals[DEACTIVATE]);
}
static void
gtk_menu_shell_map (GtkWidget *widget)
{
GtkMenuShell *menu_shell;
GtkWidget *child;
GList *children;
g_return_if_fail (GTK_IS_MENU_SHELL (widget));
menu_shell = GTK_MENU_SHELL (widget);
GTK_WIDGET_SET_FLAGS (menu_shell, GTK_MAPPED);
children = menu_shell->children;
while (children)
{
child = children->data;
children = children->next;
if (GTK_WIDGET_VISIBLE (child) && !GTK_WIDGET_MAPPED (child))
gtk_widget_map (child);
}
gdk_window_show (widget->window);
}
static void
gtk_menu_shell_realize (GtkWidget *widget)
{

View File

@ -154,8 +154,6 @@ static gint gtk_notebook_motion_notify (GtkWidget *widget,
static gint gtk_notebook_focus_in (GtkWidget *widget,
GdkEventFocus *event);
static void gtk_notebook_draw_focus (GtkWidget *widget);
static void gtk_notebook_style_set (GtkWidget *widget,
GtkStyle *previous_style);
static gint gtk_notebook_focus (GtkWidget *widget,
GtkDirectionType direction);
@ -306,7 +304,6 @@ gtk_notebook_class_init (GtkNotebookClass *class)
widget_class->leave_notify_event = gtk_notebook_leave_notify;
widget_class->motion_notify_event = gtk_notebook_motion_notify;
widget_class->focus_in_event = gtk_notebook_focus_in;
widget_class->style_set = gtk_notebook_style_set;
widget_class->focus = gtk_notebook_focus;
container_class->add = gtk_notebook_add;
@ -840,8 +837,6 @@ gtk_notebook_size_request (GtkWidget *widget,
widget->requisition.height = MAX (widget->requisition.height,
child_requisition.height);
if (GTK_WIDGET_MAPPED (page->child) && page != notebook->cur_page)
gtk_widget_unmap (page->child);
if (notebook->menu && page->menu_label->parent &&
!GTK_WIDGET_VISIBLE (page->menu_label->parent))
gtk_widget_show (page->menu_label->parent);
@ -1447,21 +1442,6 @@ gtk_notebook_draw_focus (GtkWidget *widget)
}
}
static void
gtk_notebook_style_set (GtkWidget *widget,
GtkStyle *previous_style)
{
if (GTK_WIDGET_REALIZED (widget) &&
!GTK_WIDGET_NO_WINDOW (widget))
{
gtk_style_set_background (widget->style, widget->window, widget->state);
if (GTK_WIDGET_DRAWABLE (widget))
gdk_window_clear (widget->window);
}
gtk_notebook_set_shape (GTK_NOTEBOOK(widget));
}
/* Private GtkContainer Methods :
*
* gtk_notebook_set_child_arg
@ -2663,7 +2643,7 @@ gtk_notebook_set_shape (GtkNotebook *notebook)
while (children)
{
page = children->data;
if (GTK_WIDGET_MAPPED (page->tab_label))
if (gtk_widget_get_child_visible (page->tab_label))
{
x = page->allocation.x;
y = page->allocation.y;
@ -2922,16 +2902,16 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook)
STEP_NEXT, TRUE))
{
page = children->data;
if (page->tab_label && GTK_WIDGET_MAPPED (page->tab_label))
gtk_widget_unmap (page->tab_label);
if (page->tab_label)
gtk_widget_set_child_visible (page->tab_label, FALSE);
}
for (children = last_child; children;
children = gtk_notebook_search_page (notebook, children,
STEP_NEXT, TRUE))
{
page = children->data;
if (page->tab_label && GTK_WIDGET_MAPPED (page->tab_label))
gtk_widget_unmap (page->tab_label);
if (page->tab_label)
gtk_widget_set_child_visible (page->tab_label, FALSE);
}
}
else /* !showarrow */
@ -3045,14 +3025,8 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook)
break;
}
if (GTK_WIDGET_REALIZED (notebook) &&
page->tab_label && !GTK_WIDGET_MAPPED (page->tab_label))
{
if (GTK_WIDGET_VISIBLE (page->tab_label))
gtk_widget_map (page->tab_label);
else
gtk_widget_show (page->tab_label);
}
if (page->tab_label)
gtk_widget_set_child_visible (page->tab_label, TRUE);
}
if (children)
@ -3118,14 +3092,8 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook)
break;
}
if (GTK_WIDGET_REALIZED (notebook) && page->tab_label &&
!GTK_WIDGET_MAPPED (page->tab_label))
{
if (GTK_WIDGET_VISIBLE (page->tab_label))
gtk_widget_map (page->tab_label);
else
gtk_widget_show (page->tab_label);
}
if (page->tab_label)
gtk_widget_set_child_visible (page->tab_label, TRUE);
}
}
@ -3383,8 +3351,8 @@ gtk_notebook_real_switch_page (GtkNotebook *notebook,
if (notebook->cur_page == page || !GTK_WIDGET_VISIBLE (page->child))
return;
if (notebook->cur_page && GTK_WIDGET_MAPPED (notebook->cur_page->child))
gtk_widget_unmap (notebook->cur_page->child);
if (notebook->cur_page)
gtk_widget_set_child_visible (notebook->cur_page->child, FALSE);
notebook->cur_page = page;
@ -3393,8 +3361,7 @@ gtk_notebook_real_switch_page (GtkNotebook *notebook,
notebook->focus_tab =
g_list_find (notebook->children, notebook->cur_page);
if (GTK_WIDGET_MAPPED (notebook))
gtk_widget_map (notebook->cur_page->child);
gtk_widget_set_child_visible (notebook->cur_page->child, TRUE);
gtk_widget_queue_resize (GTK_WIDGET (notebook));
g_object_notify (G_OBJECT (notebook), "page");
@ -3834,6 +3801,19 @@ gtk_notebook_insert_page_menu (GtkNotebook *notebook,
if (!notebook->first_tab)
notebook->first_tab = notebook->children;
if (!notebook->cur_page)
gtk_widget_set_child_visible (child, TRUE);
else
gtk_widget_set_child_visible (child, FALSE);
if (tab_label)
{
if (notebook->show_tabs && GTK_WIDGET_VISIBLE (child))
gtk_widget_show (tab_label);
else
gtk_widget_hide (tab_label);
}
gtk_widget_set_parent (child, GTK_WIDGET (notebook));
if (tab_label)
gtk_widget_set_parent (tab_label, GTK_WIDGET (notebook));
@ -3844,41 +3824,6 @@ gtk_notebook_insert_page_menu (GtkNotebook *notebook,
gtk_notebook_switch_focus_tab (notebook, NULL);
}
if (GTK_WIDGET_REALIZED (child->parent))
gtk_widget_realize (child);
if (GTK_WIDGET_VISIBLE (notebook))
{
if (GTK_WIDGET_VISIBLE (child))
{
if (GTK_WIDGET_MAPPED (notebook) &&
!GTK_WIDGET_MAPPED (child) &&
notebook->cur_page == page)
gtk_widget_map (child);
gtk_widget_queue_resize (child);
}
if (tab_label)
{
if (notebook->show_tabs && GTK_WIDGET_VISIBLE (child))
{
if (!GTK_WIDGET_VISIBLE (tab_label))
gtk_widget_show (tab_label);
if (GTK_WIDGET_REALIZED (notebook) &&
!GTK_WIDGET_REALIZED (tab_label))
gtk_widget_realize (tab_label);
if (GTK_WIDGET_MAPPED (notebook) &&
!GTK_WIDGET_MAPPED (tab_label))
gtk_widget_map (tab_label);
}
else if (GTK_WIDGET_VISIBLE (tab_label))
gtk_widget_hide (tab_label);
}
}
if (tab_label)
page->mnemonic_activate_signal =
gtk_signal_connect (GTK_OBJECT (tab_label),

View File

@ -125,8 +125,6 @@ enum {
static void gtk_packer_class_init (GtkPackerClass *klass);
static void gtk_packer_init (GtkPacker *packer);
static void gtk_packer_map (GtkWidget *widget);
static void gtk_packer_unmap (GtkWidget *widget);
static void gtk_packer_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_packer_size_allocate (GtkWidget *widget,
@ -215,9 +213,6 @@ gtk_packer_class_init (GtkPackerClass *klass)
gobject_class->set_property = gtk_packer_set_property;
gobject_class->get_property = gtk_packer_get_property;
widget_class->map = gtk_packer_map;
widget_class->unmap = gtk_packer_unmap;
widget_class->size_request = gtk_packer_size_request;
widget_class->size_allocate = gtk_packer_size_allocate;
@ -697,17 +692,6 @@ gtk_packer_add_defaults (GtkPacker *packer,
packer->children = g_list_append(packer->children, (gpointer) pchild);
gtk_widget_set_parent (child, GTK_WIDGET (packer));
if (GTK_WIDGET_REALIZED (child->parent))
gtk_widget_realize (child);
if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
{
if (GTK_WIDGET_MAPPED (child->parent))
gtk_widget_map (child);
gtk_widget_queue_resize (child);
}
}
void
@ -745,17 +729,6 @@ gtk_packer_add (GtkPacker *packer,
packer->children = g_list_append(packer->children, (gpointer) pchild);
gtk_widget_set_parent (child, GTK_WIDGET (packer));
if (GTK_WIDGET_REALIZED (child->parent))
gtk_widget_realize (child);
if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
{
if (GTK_WIDGET_MAPPED (child->parent))
gtk_widget_map (child);
gtk_widget_queue_resize (child);
}
}
void
@ -904,54 +877,6 @@ gtk_packer_remove (GtkContainer *container,
}
}
static void
gtk_packer_map (GtkWidget *widget)
{
GtkPacker *packer;
GtkPackerChild *child;
GList *children;
g_return_if_fail (GTK_IS_PACKER (widget));
packer = GTK_PACKER (widget);
GTK_WIDGET_SET_FLAGS (packer, GTK_MAPPED);
children = g_list_first(packer->children);
while (children != NULL)
{
child = children->data;
children = g_list_next(children);
if (GTK_WIDGET_VISIBLE (child->widget) &&
!GTK_WIDGET_MAPPED (child->widget))
gtk_widget_map (child->widget);
}
}
static void
gtk_packer_unmap (GtkWidget *widget)
{
GtkPacker *packer;
GtkPackerChild *child;
GList *children;
g_return_if_fail (GTK_IS_PACKER (widget));
packer = GTK_PACKER (widget);
GTK_WIDGET_UNSET_FLAGS (packer, GTK_MAPPED);
children = g_list_first(packer->children);
while (children)
{
child = children->data;
children = g_list_next(children);
if (GTK_WIDGET_VISIBLE (child->widget) &&
GTK_WIDGET_MAPPED (child->widget))
gtk_widget_unmap (child->widget);
}
}
static void
gtk_packer_size_request (GtkWidget *widget,
GtkRequisition *requisition)
@ -1262,7 +1187,7 @@ gtk_packer_size_allocate (GtkWidget *widget,
if (width <= 0 || height <= 0)
{
gtk_widget_unmap(child->widget);
gtk_widget_set_child_visible (child->widget, FALSE);
}
else
{
@ -1272,9 +1197,7 @@ gtk_packer_size_allocate (GtkWidget *widget,
child_allocation.height = height;
gtk_widget_size_allocate (child->widget, &child_allocation);
if (GTK_WIDGET_MAPPED (widget) &&
!(GTK_WIDGET_MAPPED (child->widget)))
gtk_widget_map(child->widget);
gtk_widget_set_child_visible (child->widget, TRUE);
}
list = g_list_next(list);

View File

@ -44,8 +44,6 @@ static void gtk_paned_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
static void gtk_paned_realize (GtkWidget *widget);
static void gtk_paned_map (GtkWidget *widget);
static void gtk_paned_unmap (GtkWidget *widget);
static void gtk_paned_unrealize (GtkWidget *widget);
static gint gtk_paned_expose (GtkWidget *widget,
GdkEventExpose *event);
@ -104,8 +102,6 @@ gtk_paned_class_init (GtkPanedClass *class)
object_class->get_property = gtk_paned_get_property;
widget_class->realize = gtk_paned_realize;
widget_class->map = gtk_paned_map;
widget_class->unmap = gtk_paned_unmap;
widget_class->unrealize = gtk_paned_unrealize;
widget_class->expose_event = gtk_paned_expose;
@ -271,38 +267,6 @@ gtk_paned_realize (GtkWidget *widget)
gdk_window_show (paned->handle);
}
static void
gtk_paned_map (GtkWidget *widget)
{
GtkPaned *paned;
g_return_if_fail (GTK_IS_PANED (widget));
GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
paned = GTK_PANED (widget);
if (paned->child1 &&
GTK_WIDGET_VISIBLE (paned->child1) &&
!GTK_WIDGET_MAPPED (paned->child1))
gtk_widget_map (paned->child1);
if (paned->child2 &&
GTK_WIDGET_VISIBLE (paned->child2) &&
!GTK_WIDGET_MAPPED (paned->child2))
gtk_widget_map (paned->child2);
gdk_window_show (widget->window);
}
static void
gtk_paned_unmap (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_PANED (widget));
GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
gdk_window_hide (widget->window);
}
static void
gtk_paned_unrealize (GtkWidget *widget)
{
@ -381,17 +345,6 @@ gtk_paned_pack1 (GtkPaned *paned,
paned->child1_shrink = shrink;
gtk_widget_set_parent (child, GTK_WIDGET (paned));
if (GTK_WIDGET_REALIZED (child->parent))
gtk_widget_realize (child);
if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
{
if (GTK_WIDGET_MAPPED (child->parent))
gtk_widget_map (child);
gtk_widget_queue_resize (child);
}
}
}
@ -411,17 +364,6 @@ gtk_paned_pack2 (GtkPaned *paned,
paned->child2_shrink = shrink;
gtk_widget_set_parent (child, GTK_WIDGET (paned));
if (GTK_WIDGET_REALIZED (child->parent))
gtk_widget_realize (child);
if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
{
if (GTK_WIDGET_MAPPED (child->parent))
gtk_widget_map (child);
gtk_widget_queue_resize (child);
}
}
}

View File

@ -217,20 +217,10 @@ _gtk_plug_add_to_socket (GtkPlug *plug,
plug->same_app = TRUE;
socket->plug_widget = widget;
gtk_widget_set_parent (widget, GTK_WIDGET (socket));
if (GTK_WIDGET_REALIZED (widget))
gdk_window_reparent (widget->window, plug->socket_window, 0, 0);
else
gtk_widget_realize (widget);
if (GTK_WIDGET_VISIBLE (socket) && GTK_WIDGET_VISIBLE (widget))
{
if (GTK_WIDGET_MAPPED (socket))
gtk_widget_map (widget);
gtk_widget_queue_resize (widget);
}
gtk_widget_set_parent (widget, GTK_WIDGET (socket));
g_signal_emit_by_name (G_OBJECT (socket), "plug_added", 0);
}

View File

@ -49,7 +49,8 @@ typedef enum
PRIVATE_GTK_IN_REPARENT = 1 << 6,
PRIVATE_GTK_DIRECTION_SET = 1 << 7, /* If the reading direction is not DIR_NONE */
PRIVATE_GTK_DIRECTION_LTR = 1 << 8, /* If the reading direction is DIR_LTR */
PRIVATE_GTK_ANCHORED = 1 << 9 /* If widget has a GtkWindow ancestor */
PRIVATE_GTK_ANCHORED = 1 << 9, /* If widget has a GtkWindow ancestor */
PRIVATE_GTK_CHILD_VISIBLE = 1 << 10 /* If widget should be mapped when parent is mapped */
} GtkPrivateFlags;
/* Macros for extracting a widgets private_flags from GtkWidget.
@ -64,6 +65,7 @@ typedef enum
#define GTK_WIDGET_DIRECTION_SET(obj) ((GTK_PRIVATE_FLAGS (obj) & PRIVATE_GTK_DIRECTION_SET) != 0)
#define GTK_WIDGET_DIRECTION_LTR(obj) ((GTK_PRIVATE_FLAGS (obj) & PRIVATE_GTK_DIRECTION_LTR) != 0)
#define GTK_WIDGET_ANCHORED(obj) ((GTK_PRIVATE_FLAGS (obj) & PRIVATE_GTK_ANCHORED) != 0)
#define GTK_WIDGET_CHILD_VISIBLE(obj) ((GTK_PRIVATE_FLAGS (obj) & PRIVATE_GTK_CHILD_VISIBLE) != 0)
/* Macros for setting and clearing private widget flags.
* we use a preprocessor string concatenation here for a clear

View File

@ -88,8 +88,6 @@ static void gtk_scrolled_window_get_arg (GtkObject *object,
guint arg_id);
static void gtk_scrolled_window_destroy (GtkObject *object);
static void gtk_scrolled_window_finalize (GObject *object);
static void gtk_scrolled_window_map (GtkWidget *widget);
static void gtk_scrolled_window_unmap (GtkWidget *widget);
static gint gtk_scrolled_window_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_scrolled_window_size_request (GtkWidget *widget,
@ -158,8 +156,6 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class)
object_class->get_arg = gtk_scrolled_window_get_arg;
object_class->destroy = gtk_scrolled_window_destroy;
widget_class->map = gtk_scrolled_window_map;
widget_class->unmap = gtk_scrolled_window_unmap;
widget_class->expose_event = gtk_scrolled_window_expose;
widget_class->size_request = gtk_scrolled_window_size_request;
widget_class->size_allocate = gtk_scrolled_window_size_allocate;
@ -575,46 +571,6 @@ gtk_scrolled_window_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gtk_scrolled_window_map (GtkWidget *widget)
{
GtkScrolledWindow *scrolled_window;
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (widget));
scrolled_window = GTK_SCROLLED_WINDOW (widget);
/* chain parent class handler to map self and child */
GTK_WIDGET_CLASS (parent_class)->map (widget);
if (GTK_WIDGET_VISIBLE (scrolled_window->hscrollbar) &&
!GTK_WIDGET_MAPPED (scrolled_window->hscrollbar))
gtk_widget_map (scrolled_window->hscrollbar);
if (GTK_WIDGET_VISIBLE (scrolled_window->vscrollbar) &&
!GTK_WIDGET_MAPPED (scrolled_window->vscrollbar))
gtk_widget_map (scrolled_window->vscrollbar);
}
static void
gtk_scrolled_window_unmap (GtkWidget *widget)
{
GtkScrolledWindow *scrolled_window;
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (widget));
scrolled_window = GTK_SCROLLED_WINDOW (widget);
/* chain parent class handler to unmap self and child */
GTK_WIDGET_CLASS (parent_class)->unmap (widget);
if (GTK_WIDGET_MAPPED (scrolled_window->hscrollbar))
gtk_widget_unmap (scrolled_window->hscrollbar);
if (GTK_WIDGET_MAPPED (scrolled_window->vscrollbar))
gtk_widget_unmap (scrolled_window->vscrollbar);
}
static void
gtk_scrolled_window_paint (GtkWidget *widget,
GdkRectangle *area)
@ -1063,17 +1019,6 @@ gtk_scrolled_window_add (GtkContainer *container,
gtk_range_get_adjustment (GTK_RANGE (scrolled_window->vscrollbar))))
g_warning ("gtk_scrolled_window_add(): cannot add non scrollable widget "
"use gtk_scrolled_window_add_with_viewport() instead");
if (GTK_WIDGET_REALIZED (child->parent))
gtk_widget_realize (child);
if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
{
if (GTK_WIDGET_MAPPED (child->parent))
gtk_widget_map (child);
gtk_widget_queue_resize (child);
}
}
static void

View File

@ -54,8 +54,6 @@ enum
static void gtk_table_class_init (GtkTableClass *klass);
static void gtk_table_init (GtkTable *table);
static void gtk_table_finalize (GObject *object);
static void gtk_table_map (GtkWidget *widget);
static void gtk_table_unmap (GtkWidget *widget);
static void gtk_table_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_table_size_allocate (GtkWidget *widget,
@ -141,8 +139,6 @@ gtk_table_class_init (GtkTableClass *class)
gobject_class->get_property = gtk_table_get_property;
gobject_class->set_property = gtk_table_set_property;
widget_class->map = gtk_table_map;
widget_class->unmap = gtk_table_unmap;
widget_class->size_request = gtk_table_size_request;
widget_class->size_allocate = gtk_table_size_allocate;
@ -610,17 +606,6 @@ gtk_table_attach (GtkTable *table,
table->children = g_list_prepend (table->children, table_child);
gtk_widget_set_parent (child, GTK_WIDGET (table));
if (GTK_WIDGET_REALIZED (child->parent))
gtk_widget_realize (child);
if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
{
if (GTK_WIDGET_MAPPED (child->parent))
gtk_widget_map (child);
gtk_widget_queue_resize (child);
}
}
void
@ -833,54 +818,6 @@ gtk_table_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gtk_table_map (GtkWidget *widget)
{
GtkTable *table;
GtkTableChild *child;
GList *children;
g_return_if_fail (GTK_IS_TABLE (widget));
table = GTK_TABLE (widget);
GTK_WIDGET_SET_FLAGS (table, GTK_MAPPED);
children = table->children;
while (children)
{
child = children->data;
children = children->next;
if (GTK_WIDGET_VISIBLE (child->widget) &&
!GTK_WIDGET_MAPPED (child->widget))
gtk_widget_map (child->widget);
}
}
static void
gtk_table_unmap (GtkWidget *widget)
{
GtkTable *table;
GtkTableChild *child;
GList *children;
g_return_if_fail (GTK_IS_TABLE (widget));
table = GTK_TABLE (widget);
GTK_WIDGET_UNSET_FLAGS (table, GTK_MAPPED);
children = table->children;
while (children)
{
child = children->data;
children = children->next;
if (GTK_WIDGET_VISIBLE (child->widget) &&
GTK_WIDGET_MAPPED (child->widget))
gtk_widget_unmap (child->widget);
}
}
static void
gtk_table_size_request (GtkWidget *widget,
GtkRequisition *requisition)

View File

@ -319,17 +319,16 @@ struct _GtkTextViewChild
gint y;
};
static GtkTextViewChild* text_view_child_new_anchored (GtkWidget *child,
GtkTextChildAnchor *anchor,
GtkTextLayout *layout);
static GtkTextViewChild* text_view_child_new_window (GtkWidget *child,
GtkTextWindowType type,
gint x,
gint y);
static void text_view_child_free (GtkTextViewChild *child);
static void text_view_child_realize (GtkTextView *text_view,
GtkTextViewChild *child);
static GtkTextViewChild* text_view_child_new_anchored (GtkWidget *child,
GtkTextChildAnchor *anchor,
GtkTextLayout *layout);
static GtkTextViewChild* text_view_child_new_window (GtkWidget *child,
GtkTextWindowType type,
gint x,
gint y);
static void text_view_child_free (GtkTextViewChild *child);
static void text_view_child_set_parent_window (GtkTextView *text_view,
GtkTextViewChild *child);
struct _GtkTextWindow
{
@ -6233,8 +6232,8 @@ text_view_child_free (GtkTextViewChild *child)
}
static void
text_view_child_realize (GtkTextView *text_view,
GtkTextViewChild *vc)
text_view_child_set_parent_window (GtkTextView *text_view,
GtkTextViewChild *vc)
{
if (vc->anchor)
gtk_widget_set_parent_window (vc->widget,
@ -6246,8 +6245,6 @@ text_view_child_realize (GtkTextView *text_view,
vc->type);
gtk_widget_set_parent_window (vc->widget, window);
}
gtk_widget_realize (vc->widget);
}
static void
@ -6257,18 +6254,10 @@ add_child (GtkTextView *text_view,
text_view->children = g_slist_prepend (text_view->children,
vc);
gtk_widget_set_parent (vc->widget, GTK_WIDGET (text_view));
if (GTK_WIDGET_REALIZED (text_view))
text_view_child_realize (text_view, vc);
if (GTK_WIDGET_VISIBLE (text_view) && GTK_WIDGET_VISIBLE (vc->widget))
{
if (GTK_WIDGET_MAPPED (text_view))
gtk_widget_map (vc->widget);
gtk_widget_queue_resize (vc->widget);
}
text_view_child_set_parent_window (text_view, vc);
gtk_widget_set_parent (vc->widget, GTK_WIDGET (text_view));
}
void

View File

@ -81,8 +81,6 @@ static void gtk_toolbar_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
static void gtk_toolbar_destroy (GtkObject *object);
static void gtk_toolbar_map (GtkWidget *widget);
static void gtk_toolbar_unmap (GtkWidget *widget);
static gint gtk_toolbar_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_toolbar_size_request (GtkWidget *widget,
@ -188,8 +186,6 @@ gtk_toolbar_class_init (GtkToolbarClass *class)
gobject_class->set_property = gtk_toolbar_set_property;
gobject_class->get_property = gtk_toolbar_get_property;
widget_class->map = gtk_toolbar_map;
widget_class->unmap = gtk_toolbar_unmap;
widget_class->expose_event = gtk_toolbar_expose;
widget_class->size_request = gtk_toolbar_size_request;
widget_class->size_allocate = gtk_toolbar_size_allocate;
@ -472,50 +468,6 @@ gtk_toolbar_destroy (GtkObject *object)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static void
gtk_toolbar_map (GtkWidget *widget)
{
GtkToolbar *toolbar;
GList *children;
GtkToolbarChild *child;
g_return_if_fail (GTK_IS_TOOLBAR (widget));
toolbar = GTK_TOOLBAR (widget);
GTK_WIDGET_SET_FLAGS (toolbar, GTK_MAPPED);
for (children = toolbar->children; children; children = children->next)
{
child = children->data;
if ((child->type != GTK_TOOLBAR_CHILD_SPACE)
&& GTK_WIDGET_VISIBLE (child->widget) && !GTK_WIDGET_MAPPED (child->widget))
gtk_widget_map (child->widget);
}
}
static void
gtk_toolbar_unmap (GtkWidget *widget)
{
GtkToolbar *toolbar;
GList *children;
GtkToolbarChild *child;
g_return_if_fail (GTK_IS_TOOLBAR (widget));
toolbar = GTK_TOOLBAR (widget);
GTK_WIDGET_UNSET_FLAGS (toolbar, GTK_MAPPED);
for (children = toolbar->children; children; children = children->next)
{
child = children->data;
if ((child->type != GTK_TOOLBAR_CHILD_SPACE)
&& GTK_WIDGET_VISIBLE (child->widget) && GTK_WIDGET_MAPPED (child->widget))
gtk_widget_unmap (child->widget);
}
}
static void
gtk_toolbar_paint_space_line (GtkWidget *widget,
GdkRectangle *area,
@ -1436,20 +1388,7 @@ gtk_toolbar_internal_insert_element (GtkToolbar *toolbar,
toolbar->num_children++;
if (type != GTK_TOOLBAR_CHILD_SPACE)
{
gtk_widget_set_parent (child->widget, GTK_WIDGET (toolbar));
if (GTK_WIDGET_REALIZED (child->widget->parent))
gtk_widget_realize (child->widget);
if (GTK_WIDGET_VISIBLE (child->widget->parent) && GTK_WIDGET_VISIBLE (child->widget))
{
if (GTK_WIDGET_MAPPED (child->widget->parent))
gtk_widget_map (child->widget);
gtk_widget_queue_resize (child->widget);
}
}
gtk_widget_set_parent (child->widget, GTK_WIDGET (toolbar));
else
gtk_widget_queue_resize (GTK_WIDGET (toolbar));

View File

@ -228,17 +228,6 @@ gtk_tree_insert (GtkTree *tree,
tree->children = g_list_insert (tree->children, tree_item, position);
gtk_widget_set_parent (tree_item, GTK_WIDGET (tree));
if (GTK_WIDGET_REALIZED (tree_item->parent))
gtk_widget_realize (tree_item);
if (GTK_WIDGET_VISIBLE (tree_item->parent) && GTK_WIDGET_VISIBLE (tree_item))
{
if (GTK_WIDGET_MAPPED (tree_item->parent))
gtk_widget_map (tree_item);
gtk_widget_queue_resize (tree_item);
}
}
static void
@ -256,17 +245,6 @@ gtk_tree_add (GtkContainer *container,
gtk_widget_set_parent (child, GTK_WIDGET (container));
if (GTK_WIDGET_REALIZED (child->parent))
gtk_widget_realize (child);
if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
{
if (GTK_WIDGET_MAPPED (child->parent))
gtk_widget_map (child);
gtk_widget_queue_resize (child);
}
if (!tree->selection && (tree->selection_mode == GTK_SELECTION_BROWSE))
gtk_tree_select_child (tree, child);
}

View File

@ -312,17 +312,6 @@ gtk_tree_item_set_subtree (GtkTreeItem *tree_item,
gtk_widget_hide (subtree);
gtk_widget_set_parent (subtree, GTK_WIDGET (tree_item)->parent);
if (GTK_WIDGET_REALIZED (subtree->parent))
gtk_widget_realize (subtree);
if (GTK_WIDGET_VISIBLE (subtree->parent) && GTK_WIDGET_VISIBLE (subtree))
{
if (GTK_WIDGET_MAPPED (subtree->parent))
gtk_widget_map (subtree);
gtk_widget_queue_resize (subtree);
}
}
void

View File

@ -499,9 +499,9 @@ gtk_tree_view_column_create_button (GtkTreeViewColumn *tree_column)
gtk_widget_pop_composite_child ();
/* make sure we own a reference to it as well. */
gtk_widget_set_parent (tree_column->button, GTK_WIDGET (tree_view));
if (tree_view->priv->header_window)
gtk_widget_set_parent_window (tree_column->button, tree_view->priv->header_window);
gtk_widget_set_parent (tree_column->button, GTK_WIDGET (tree_view));
gtk_signal_connect (GTK_OBJECT (tree_column->button), "realize",
(GtkSignalFunc) gtk_tree_view_column_button_realize,

View File

@ -50,8 +50,6 @@ static void gtk_viewport_get_property (GObject *object,
static void gtk_viewport_set_scroll_adjustments (GtkViewport *viewport,
GtkAdjustment *hadjustment,
GtkAdjustment *vadjustment);
static void gtk_viewport_map (GtkWidget *widget);
static void gtk_viewport_unmap (GtkWidget *widget);
static void gtk_viewport_realize (GtkWidget *widget);
static void gtk_viewport_unrealize (GtkWidget *widget);
static void gtk_viewport_paint (GtkWidget *widget,
@ -116,8 +114,6 @@ gtk_viewport_class_init (GtkViewportClass *class)
gobject_class->get_property = gtk_viewport_get_property;
object_class->destroy = gtk_viewport_destroy;
widget_class->map = gtk_viewport_map;
widget_class->unmap = gtk_viewport_unmap;
widget_class->realize = gtk_viewport_realize;
widget_class->unrealize = gtk_viewport_unrealize;
widget_class->expose_event = gtk_viewport_expose;
@ -412,34 +408,6 @@ gtk_viewport_get_shadow_type (GtkViewport *viewport)
return viewport->shadow_type;
}
static void
gtk_viewport_map (GtkWidget *widget)
{
GtkBin *bin;
g_return_if_fail (GTK_IS_VIEWPORT (widget));
GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
bin = GTK_BIN (widget);
if (bin->child &&
GTK_WIDGET_VISIBLE (bin->child) &&
!GTK_WIDGET_MAPPED (bin->child))
gtk_widget_map (bin->child);
gdk_window_show (widget->window);
}
static void
gtk_viewport_unmap (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_VIEWPORT (widget));
GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
gdk_window_hide (widget->window);
}
static void
gtk_viewport_realize (GtkWidget *widget)
{

View File

@ -1290,7 +1290,7 @@ gtk_widget_init (GtkWidget *widget)
{
GdkColormap *colormap;
GTK_PRIVATE_FLAGS (widget) = 0;
GTK_PRIVATE_FLAGS (widget) = PRIVATE_GTK_CHILD_VISIBLE;
widget->state = GTK_STATE_NORMAL;
widget->saved_state = GTK_STATE_NORMAL;
widget->name = NULL;
@ -1606,6 +1606,12 @@ gtk_widget_unparent (GtkWidget *widget)
if (GTK_WIDGET_REALIZED (widget) && !GTK_WIDGET_IN_REPARENT (widget))
gtk_widget_unrealize (widget);
/* Removing a widget from a container restores the child visible
* flag to the default state, so it doesn't affect the child
* in the next parent.
*/
GTK_PRIVATE_SET_FLAG (widget, GTK_CHILD_VISIBLE);
old_parent = widget->parent;
widget->parent = NULL;
gtk_widget_set_parent_window (widget, NULL);
@ -1722,6 +1728,7 @@ gtk_widget_real_show (GtkWidget *widget)
if (widget->parent &&
GTK_WIDGET_MAPPED (widget->parent) &&
GTK_WIDGET_CHILD_VISIBLE (widget) &&
!GTK_WIDGET_MAPPED (widget))
gtk_widget_map (widget);
}
@ -1879,7 +1886,8 @@ void
gtk_widget_map (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (GTK_WIDGET_VISIBLE (widget) == TRUE);
g_return_if_fail (GTK_WIDGET_VISIBLE (widget));
g_return_if_fail (GTK_WIDGET_CHILD_VISIBLE (widget));
if (!GTK_WIDGET_MAPPED (widget))
{
@ -3425,6 +3433,21 @@ gtk_widget_set_parent (GtkWidget *widget,
if (GTK_WIDGET_ANCHORED (widget->parent))
_gtk_widget_propagate_hierarchy_changed (widget, NULL);
g_object_notify (G_OBJECT (widget), "parent");
/* Enforce realized/mapped invariants
*/
if (GTK_WIDGET_REALIZED (widget->parent))
gtk_widget_realize (widget);
if (GTK_WIDGET_VISIBLE (widget->parent) &&
GTK_WIDGET_VISIBLE (widget))
{
if (GTK_WIDGET_CHILD_VISIBLE (widget) &&
GTK_WIDGET_MAPPED (widget->parent))
gtk_widget_map (widget);
gtk_widget_queue_resize (widget);
}
}
/**
@ -4131,6 +4154,86 @@ gtk_widget_set_parent_window (GtkWidget *widget,
}
}
/**
* gtk_widget_set_child_visible:
* @widget: a #GtkWidget
* @is_visible: if %TRUE, @widget should be mapped along with its parent.
*
* Sets whether @widget should be mapped along with its when its parent
* is mapped and @widget has been shown with gtk_widget_show().
*
* The child visibility can be set for widget before it is added to
* a container with gtk_widget_set_parent(), to avoid mapping
* children unnecessary before immediately unmapping them. However
* it will be reset to its default state of %TRUE when the widget
* is removed from a container.
*
* Note that changing the child visibility of a widget does not
* queue a resize on the widget. Most of the time, the size of
* a widget is computed from all visible children, whether or
* not they are mapped. If this is not the case, the container
* can queue a resize itself.
*
* This function is only useful for container implementations and
* never should be called by an application.
**/
void
gtk_widget_set_child_visible (GtkWidget *widget,
gboolean is_visible)
{
gboolean was_visible;
g_return_if_fail (GTK_IS_WIDGET (widget));
was_visible = GTK_WIDGET_CHILD_VISIBLE (widget);
is_visible = is_visible != FALSE;
if (is_visible != was_visible)
{
if (is_visible)
{
GTK_PRIVATE_SET_FLAG (widget, GTK_CHILD_VISIBLE);
if (widget->parent &&
GTK_WIDGET_VISIBLE (widget->parent) &&
GTK_WIDGET_VISIBLE (widget))
{
if (GTK_WIDGET_MAPPED (widget->parent))
gtk_widget_map (widget);
}
}
else
{
GTK_PRIVATE_UNSET_FLAG (widget, GTK_CHILD_VISIBLE);
if (GTK_WIDGET_MAPPED (widget))
gtk_widget_unmap (widget);
}
}
}
/**
* gtk_widget_get_child_visible:
* @widget: a #GtkWidget
*
* Gets the value set with gtk_widget_set_child_visible().
* If you feel a need to use this function, your code probably
* needs reorganization.
*
* This function is only useful for container implementations and
* never should be called by an application.
*
* Return value: %TRUE if the widget is mapped with the parent.
**/
gboolean
gtk_widget_get_child_visible (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
return GTK_WIDGET_CHILD_VISIBLE (widget);
}
/*************************************************************
* gtk_widget_get_parent_window:
* Get widget's parent window
@ -5869,3 +5972,4 @@ gtk_widget_ref_accessible (AtkImplementor *implementor)
g_object_ref (G_OBJECT (accessible));
return accessible;
}

View File

@ -554,6 +554,10 @@ void gtk_widget_set_parent (GtkWidget *widget,
GtkWidget *parent);
void gtk_widget_set_parent_window (GtkWidget *widget,
GdkWindow *parent_window);
void gtk_widget_set_child_visible (GtkWidget *widget,
gboolean is_visible);
gboolean gtk_widget_get_child_visible (GtkWidget *widget);
GtkWidget *gtk_widget_get_parent (GtkWidget *widget);
GdkWindow *gtk_widget_get_parent_window (GtkWidget *widget);
gboolean gtk_widget_child_focus (GtkWidget *widget,