2002-04-27 16:26:10 +00:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim:expandtab:shiftwidth=4:tabstop=4:
|
|
|
|
*/
|
2001-12-10 17:37:36 +00:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
2004-12-01 22:27:03 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
2001-12-10 17:37:36 +00:00
|
|
|
*
|
2004-12-01 22:27:03 +00:00
|
|
|
* The Initial Developer of the Original Code is Christopher Blizzard
|
2001-12-10 17:37:36 +00:00
|
|
|
* <blizzard@mozilla.org>. Portions created by the Initial Developer
|
|
|
|
* are Copyright (C) 2001 the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
2001-12-04 16:58:04 +00:00
|
|
|
#include "mozcontainer.h"
|
|
|
|
#include <gtk/gtkprivate.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2006-07-13 05:49:45 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
#include <atk/atk.h>
|
|
|
|
#include "maiRedundantObjectFactory.h"
|
|
|
|
#endif
|
|
|
|
|
2001-12-04 16:58:04 +00:00
|
|
|
/* init methods */
|
|
|
|
static void moz_container_class_init (MozContainerClass *klass);
|
|
|
|
static void moz_container_init (MozContainer *container);
|
|
|
|
|
|
|
|
/* widget class methods */
|
|
|
|
static void moz_container_map (GtkWidget *widget);
|
|
|
|
static void moz_container_unmap (GtkWidget *widget);
|
|
|
|
static void moz_container_realize (GtkWidget *widget);
|
|
|
|
static void moz_container_size_allocate (GtkWidget *widget,
|
2002-04-30 19:29:00 +00:00
|
|
|
GtkAllocation *allocation);
|
2001-12-04 16:58:04 +00:00
|
|
|
|
|
|
|
/* container class methods */
|
|
|
|
static void moz_container_remove (GtkContainer *container,
|
2002-04-30 19:29:00 +00:00
|
|
|
GtkWidget *child_widget);
|
2001-12-04 16:58:04 +00:00
|
|
|
static void moz_container_forall (GtkContainer *container,
|
2002-04-30 19:29:00 +00:00
|
|
|
gboolean include_internals,
|
|
|
|
GtkCallback callback,
|
|
|
|
gpointer callback_data);
|
2002-09-02 05:11:10 +00:00
|
|
|
static void moz_container_add (GtkContainer *container,
|
|
|
|
GtkWidget *widget);
|
2001-12-04 16:58:04 +00:00
|
|
|
|
2001-12-17 22:05:58 +00:00
|
|
|
typedef struct _MozContainerChild MozContainerChild;
|
|
|
|
|
|
|
|
struct _MozContainerChild {
|
2002-04-30 19:29:00 +00:00
|
|
|
GtkWidget *widget;
|
|
|
|
gint x;
|
|
|
|
gint y;
|
2001-12-17 22:05:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void moz_container_allocate_child (MozContainer *container,
|
2002-04-30 19:29:00 +00:00
|
|
|
MozContainerChild *child);
|
2001-12-17 22:05:58 +00:00
|
|
|
static MozContainerChild *
|
|
|
|
moz_container_get_child (MozContainer *container, GtkWidget *child);
|
|
|
|
|
2001-12-04 16:58:04 +00:00
|
|
|
static GtkContainerClass *parent_class = NULL;
|
|
|
|
|
2001-12-17 22:05:58 +00:00
|
|
|
/* public methods */
|
|
|
|
|
2001-12-04 16:58:04 +00:00
|
|
|
GtkType
|
|
|
|
moz_container_get_type(void)
|
|
|
|
{
|
2002-04-30 19:29:00 +00:00
|
|
|
static GtkType moz_container_type = 0;
|
|
|
|
|
|
|
|
if (!moz_container_type) {
|
|
|
|
static GTypeInfo moz_container_info = {
|
|
|
|
sizeof(MozContainerClass), /* class_size */
|
|
|
|
NULL, /* base_init */
|
|
|
|
NULL, /* base_finalize */
|
|
|
|
(GClassInitFunc) moz_container_class_init, /* class_init */
|
|
|
|
NULL, /* class_destroy */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof(MozContainer), /* instance_size */
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) moz_container_init, /* instance_init */
|
|
|
|
NULL, /* value_table */
|
|
|
|
};
|
|
|
|
|
|
|
|
moz_container_type = g_type_register_static (GTK_TYPE_CONTAINER,
|
|
|
|
"MozContainer",
|
|
|
|
&moz_container_info, 0);
|
2006-07-13 05:49:45 +00:00
|
|
|
#if defined(ACCESSIBILITY) && defined(USE_ATK_ROLE_REDUNDANT_OBJECT)
|
|
|
|
/* Set a factory to return accessible object with ROLE_REDUNDANT for
|
|
|
|
* MozContainer, so that gail won't send focus notification for it */
|
|
|
|
atk_registry_set_factory_type(atk_get_default_registry(),
|
|
|
|
moz_container_type,
|
|
|
|
mai_redundant_object_factory_get_type());
|
|
|
|
#endif
|
2001-12-04 16:58:04 +00:00
|
|
|
}
|
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
return moz_container_type;
|
2001-12-04 16:58:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
moz_container_new (void)
|
|
|
|
{
|
2002-04-30 19:29:00 +00:00
|
|
|
MozContainer *container;
|
2001-12-04 16:58:04 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
container = gtk_type_new (MOZ_CONTAINER_TYPE);
|
2001-12-04 16:58:04 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
return GTK_WIDGET(container);
|
2001-12-04 16:58:04 +00:00
|
|
|
}
|
|
|
|
|
2001-12-17 22:05:58 +00:00
|
|
|
void
|
|
|
|
moz_container_put (MozContainer *container, GtkWidget *child_widget,
|
2002-04-30 19:29:00 +00:00
|
|
|
gint x, gint y)
|
2001-12-17 22:05:58 +00:00
|
|
|
{
|
2002-04-30 19:29:00 +00:00
|
|
|
MozContainerChild *child;
|
2001-12-17 22:05:58 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
child = g_new (MozContainerChild, 1);
|
2001-12-17 22:05:58 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
child->widget = child_widget;
|
|
|
|
child->x = x;
|
|
|
|
child->y = y;
|
2001-12-17 22:05:58 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
/* printf("moz_container_put %p %p %d %d\n", (void *)container,
|
|
|
|
(void *)child_widget, x, y); */
|
2001-12-17 22:05:58 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
container->children = g_list_append (container->children, child);
|
2001-12-17 22:05:58 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
/* we assume that the caller of this function will have already set
|
|
|
|
the parent GdkWindow because we can have many anonymous children. */
|
|
|
|
gtk_widget_set_parent(child_widget, GTK_WIDGET(container));
|
2001-12-17 22:05:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
moz_container_move (MozContainer *container, GtkWidget *child_widget,
|
2002-04-30 19:29:00 +00:00
|
|
|
gint x, gint y, gint width, gint height)
|
2001-12-17 22:05:58 +00:00
|
|
|
{
|
2002-04-30 19:29:00 +00:00
|
|
|
MozContainerChild *child;
|
|
|
|
GtkAllocation new_allocation;
|
2001-12-17 22:05:58 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
child = moz_container_get_child (container, child_widget);
|
2001-12-17 22:05:58 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
child->x = x;
|
|
|
|
child->y = y;
|
2001-12-17 22:05:58 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
new_allocation.x = x;
|
|
|
|
new_allocation.y = y;
|
|
|
|
new_allocation.width = width;
|
|
|
|
new_allocation.height = height;
|
2001-12-17 22:05:58 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
/* printf("moz_container_move %p %p will allocate to %d %d %d %d\n",
|
|
|
|
(void *)container, (void *)child_widget,
|
|
|
|
new_allocation.x, new_allocation.y,
|
|
|
|
new_allocation.width, new_allocation.height); */
|
|
|
|
|
|
|
|
gtk_widget_size_allocate(child_widget, &new_allocation);
|
2001-12-17 22:05:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* This function updates the allocation on a child widget without
|
|
|
|
causing a size_allocate event to be generated on that widget. This
|
|
|
|
should only be used for scrolling since it's assumed that the expose
|
|
|
|
event created by the scroll will update any widgets that come into view. */
|
|
|
|
|
|
|
|
void
|
|
|
|
moz_container_scroll_update (MozContainer *container, GtkWidget *child_widget,
|
2002-04-30 19:29:00 +00:00
|
|
|
gint x, gint y)
|
2001-12-17 22:05:58 +00:00
|
|
|
{
|
2002-04-30 19:29:00 +00:00
|
|
|
MozContainerChild *child;
|
|
|
|
GtkAllocation new_allocation;
|
2001-12-17 22:05:58 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
child = moz_container_get_child (container, child_widget);
|
2001-12-17 22:05:58 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
child->x = x;
|
|
|
|
child->y = y;
|
2001-12-17 22:05:58 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
new_allocation.x = x;
|
|
|
|
new_allocation.y = y;
|
|
|
|
new_allocation.width = child_widget->allocation.width;
|
|
|
|
new_allocation.height = child_widget->allocation.height;
|
2001-12-17 22:05:58 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
/* printf("moz_container_update %p %p will allocate to %d %d %d %d\n",
|
|
|
|
(void *)container, (void *)child_widget,
|
|
|
|
new_allocation.x, new_allocation.y,
|
|
|
|
new_allocation.width, new_allocation.height); */
|
2001-12-17 22:05:58 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
gtk_widget_size_allocate(child_widget, &new_allocation);
|
2001-12-17 22:05:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static methods */
|
|
|
|
|
2001-12-04 16:58:04 +00:00
|
|
|
void
|
|
|
|
moz_container_class_init (MozContainerClass *klass)
|
|
|
|
{
|
2002-04-30 19:29:00 +00:00
|
|
|
/*GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); */
|
|
|
|
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
2001-12-04 16:58:04 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-12-04 16:58:04 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
widget_class->map = moz_container_map;
|
|
|
|
widget_class->unmap = moz_container_unmap;
|
|
|
|
widget_class->realize = moz_container_realize;
|
|
|
|
widget_class->size_allocate = moz_container_size_allocate;
|
2001-12-04 16:58:04 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
container_class->remove = moz_container_remove;
|
|
|
|
container_class->forall = moz_container_forall;
|
2002-09-02 05:11:10 +00:00
|
|
|
container_class->add = moz_container_add;
|
2001-12-04 16:58:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
moz_container_init (MozContainer *container)
|
|
|
|
{
|
2002-04-30 19:29:00 +00:00
|
|
|
GTK_WIDGET_SET_FLAGS(container, GTK_CAN_FOCUS);
|
|
|
|
container->container.resize_mode = GTK_RESIZE_IMMEDIATE;
|
|
|
|
gtk_widget_set_redraw_on_allocate(GTK_WIDGET(container),
|
|
|
|
FALSE);
|
2003-07-07 17:54:57 +00:00
|
|
|
|
|
|
|
/* Mozilla uses the the gdbrgb colormap and visual throughout the
|
|
|
|
backend so for widgets we just use that colormap instead of the
|
|
|
|
default one. */
|
|
|
|
gtk_widget_set_colormap(GTK_WIDGET(container), gdk_rgb_get_colormap());
|
2001-12-04 16:58:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
moz_container_map (GtkWidget *widget)
|
|
|
|
{
|
2002-04-30 19:29:00 +00:00
|
|
|
MozContainer *container;
|
|
|
|
GList *tmp_list;
|
|
|
|
GtkWidget *tmp_child;
|
2001-12-04 16:58:04 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
g_return_if_fail (IS_MOZ_CONTAINER(widget));
|
|
|
|
container = MOZ_CONTAINER (widget);
|
2001-12-04 16:58:04 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
|
2001-12-04 16:58:04 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
tmp_list = container->children;
|
|
|
|
while (tmp_list) {
|
|
|
|
tmp_child = ((MozContainerChild *)tmp_list->data)->widget;
|
2001-12-17 22:05:58 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
if (GTK_WIDGET_VISIBLE(tmp_child)) {
|
|
|
|
if (!GTK_WIDGET_MAPPED(tmp_child))
|
|
|
|
gtk_widget_map(tmp_child);
|
|
|
|
}
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
gdk_window_show (widget->window);
|
2001-12-04 16:58:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
moz_container_unmap (GtkWidget *widget)
|
|
|
|
{
|
2002-04-30 19:29:00 +00:00
|
|
|
MozContainer *container;
|
2001-12-04 16:58:04 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
g_return_if_fail (IS_MOZ_CONTAINER (widget));
|
|
|
|
container = MOZ_CONTAINER (widget);
|
2001-12-04 16:58:04 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
|
2001-12-04 16:58:04 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
gdk_window_hide (widget->window);
|
2001-12-04 16:58:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
moz_container_realize (GtkWidget *widget)
|
|
|
|
{
|
2002-04-30 19:29:00 +00:00
|
|
|
GdkWindowAttr attributes;
|
|
|
|
gint attributes_mask = 0;
|
|
|
|
MozContainer *container;
|
2001-12-04 16:58:04 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
g_return_if_fail(IS_MOZ_CONTAINER(widget));
|
2001-12-04 16:58:04 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
container = MOZ_CONTAINER(widget);
|
2001-12-04 16:58:04 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
|
2001-12-04 16:58:04 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
/* create the shell window */
|
2001-12-04 16:58:04 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
attributes.event_mask = gtk_widget_get_events (widget);
|
|
|
|
attributes.event_mask |= (GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK);
|
|
|
|
attributes.x = widget->allocation.x;
|
|
|
|
attributes.y = widget->allocation.y;
|
|
|
|
attributes.width = widget->allocation.width;
|
|
|
|
attributes.height = widget->allocation.height;
|
|
|
|
attributes.wclass = GDK_INPUT_OUTPUT;
|
|
|
|
attributes.visual = gtk_widget_get_visual (widget);
|
|
|
|
attributes.colormap = gtk_widget_get_colormap (widget);
|
|
|
|
attributes.window_type = GDK_WINDOW_CHILD;
|
2001-12-04 16:58:04 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
attributes_mask |= GDK_WA_VISUAL | GDK_WA_COLORMAP |
|
|
|
|
GDK_WA_X | GDK_WA_Y;
|
2001-12-04 16:58:04 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
|
|
|
|
&attributes, attributes_mask);
|
|
|
|
/* printf("widget->window is %p\n", (void *)widget->window); */
|
|
|
|
gdk_window_set_user_data (widget->window, container);
|
2001-12-04 16:58:04 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
widget->style = gtk_style_attach (widget->style, widget->window);
|
2001-12-04 16:58:04 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
/* set the back pixmap to None so that you don't end up with the gtk
|
|
|
|
default which is BlackPixel */
|
|
|
|
gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
|
2001-12-04 16:58:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
moz_container_size_allocate (GtkWidget *widget,
|
2002-04-30 19:29:00 +00:00
|
|
|
GtkAllocation *allocation)
|
2001-12-04 16:58:04 +00:00
|
|
|
{
|
2002-04-30 19:29:00 +00:00
|
|
|
MozContainer *container;
|
|
|
|
GList *tmp_list;
|
|
|
|
GtkAllocation tmp_allocation;
|
|
|
|
GtkRequisition tmp_requisition;
|
|
|
|
GtkWidget *tmp_child;
|
|
|
|
|
|
|
|
g_return_if_fail (IS_MOZ_CONTAINER (widget));
|
|
|
|
|
|
|
|
/* printf("moz_container_size_allocate %p %d %d %d %d\n",
|
|
|
|
(void *)widget,
|
|
|
|
allocation->x,
|
|
|
|
allocation->y,
|
|
|
|
allocation->width,
|
|
|
|
allocation->height); */
|
|
|
|
|
|
|
|
/* short circuit if you can */
|
2002-09-02 05:11:10 +00:00
|
|
|
container = MOZ_CONTAINER (widget);
|
|
|
|
if (!container->children &&
|
|
|
|
widget->allocation.x == allocation->x &&
|
2002-04-30 19:29:00 +00:00
|
|
|
widget->allocation.y == allocation->y &&
|
|
|
|
widget->allocation.width == allocation->width &&
|
|
|
|
widget->allocation.height == allocation->height) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
widget->allocation = *allocation;
|
|
|
|
|
|
|
|
tmp_list = container->children;
|
|
|
|
|
|
|
|
while (tmp_list) {
|
|
|
|
MozContainerChild *child = tmp_list->data;
|
|
|
|
|
|
|
|
moz_container_allocate_child (container, child);
|
|
|
|
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GTK_WIDGET_REALIZED (widget)) {
|
|
|
|
gdk_window_move_resize(widget->window,
|
|
|
|
widget->allocation.x,
|
|
|
|
widget->allocation.y,
|
|
|
|
widget->allocation.width,
|
|
|
|
widget->allocation.height);
|
|
|
|
}
|
2001-12-04 16:58:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-12-17 22:05:58 +00:00
|
|
|
moz_container_remove (GtkContainer *container, GtkWidget *child_widget)
|
2001-12-04 16:58:04 +00:00
|
|
|
{
|
2002-04-30 19:29:00 +00:00
|
|
|
MozContainerChild *child;
|
|
|
|
MozContainer *moz_container;
|
|
|
|
GList *tmp_list;
|
2001-12-04 16:58:04 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
g_return_if_fail (IS_MOZ_CONTAINER(container));
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET(child_widget));
|
2001-12-04 16:58:04 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
moz_container = MOZ_CONTAINER(container);
|
2001-12-04 16:58:04 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
child = moz_container_get_child (moz_container, child_widget);
|
|
|
|
g_return_if_fail (child);
|
2001-12-17 22:05:58 +00:00
|
|
|
|
2002-09-02 05:11:10 +00:00
|
|
|
if(child->widget == child_widget) {
|
|
|
|
gtk_widget_unparent(child_widget);
|
|
|
|
}
|
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
moz_container->children = g_list_remove(moz_container->children, child);
|
|
|
|
g_free(child);
|
2001-12-04 16:58:04 +00:00
|
|
|
}
|
|
|
|
|
2001-12-17 22:05:58 +00:00
|
|
|
void
|
2001-12-04 16:58:04 +00:00
|
|
|
moz_container_forall (GtkContainer *container, gboolean include_internals,
|
2002-04-30 19:29:00 +00:00
|
|
|
GtkCallback callback, gpointer callback_data)
|
2001-12-04 16:58:04 +00:00
|
|
|
{
|
2002-04-30 19:29:00 +00:00
|
|
|
MozContainer *moz_container;
|
|
|
|
GList *tmp_list;
|
2001-12-04 16:58:04 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
g_return_if_fail (IS_MOZ_CONTAINER(container));
|
|
|
|
g_return_if_fail (callback != NULL);
|
2001-12-04 16:58:04 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
moz_container = MOZ_CONTAINER(container);
|
2001-12-04 16:58:04 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
tmp_list = moz_container->children;
|
|
|
|
while (tmp_list) {
|
|
|
|
MozContainerChild *child;
|
|
|
|
child = tmp_list->data;
|
|
|
|
tmp_list = tmp_list->next;
|
2004-02-03 03:40:03 +00:00
|
|
|
(* callback) (child->widget, callback_data);
|
2002-04-30 19:29:00 +00:00
|
|
|
}
|
2001-12-17 22:05:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
moz_container_allocate_child (MozContainer *container,
|
2002-04-30 19:29:00 +00:00
|
|
|
MozContainerChild *child)
|
2001-12-17 22:05:58 +00:00
|
|
|
{
|
2002-04-30 19:29:00 +00:00
|
|
|
GtkAllocation allocation;
|
|
|
|
GtkRequisition requisition;
|
2001-12-17 22:05:58 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
allocation.x = child->x;
|
|
|
|
allocation.y = child->y;
|
|
|
|
/* gtk_widget_get_child_requisition (child->widget, &requisition); */
|
|
|
|
/* gtk_widget_size_request (child->widget, &requisition); */
|
|
|
|
allocation.width = child->widget->allocation.width;
|
|
|
|
allocation.height = child->widget->allocation.height;
|
2001-12-17 22:05:58 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
gtk_widget_size_allocate (child->widget, &allocation);
|
2001-12-17 22:05:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MozContainerChild *
|
|
|
|
moz_container_get_child (MozContainer *container, GtkWidget *child_widget)
|
|
|
|
{
|
2002-04-30 19:29:00 +00:00
|
|
|
GList *tmp_list;
|
2001-12-17 22:05:58 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
tmp_list = container->children;
|
|
|
|
while (tmp_list) {
|
|
|
|
MozContainerChild *child;
|
2001-12-17 22:05:58 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
child = tmp_list->data;
|
|
|
|
tmp_list = tmp_list->next;
|
2001-12-17 22:05:58 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
if (child->widget == child_widget)
|
|
|
|
return child;
|
|
|
|
}
|
2001-12-17 22:05:58 +00:00
|
|
|
|
2002-04-30 19:29:00 +00:00
|
|
|
return NULL;
|
2001-12-04 16:58:04 +00:00
|
|
|
}
|
2002-09-02 05:11:10 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
moz_container_add(GtkContainer *container, GtkWidget *widget)
|
|
|
|
{
|
|
|
|
moz_container_put(MOZ_CONTAINER(container), widget, 0, 0);
|
|
|
|
}
|
|
|
|
|