mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug #141239. Remove tabs from code and clean up indenting in the c files. Not part of the build.
This commit is contained in:
parent
5e8334177b
commit
fe8a51501b
@ -861,19 +861,19 @@ long keysym2ucs(KeySym keysym)
|
||||
|
||||
/* also check for directly encoded 24-bit UCS characters */
|
||||
if ((keysym & 0xff000000) == 0x01000000)
|
||||
return keysym & 0x00ffffff;
|
||||
return keysym & 0x00ffffff;
|
||||
|
||||
/* binary search in table */
|
||||
while (max >= min) {
|
||||
mid = (min + max) / 2;
|
||||
if (keysymtab[mid].keysym < keysym)
|
||||
min = mid + 1;
|
||||
else if (keysymtab[mid].keysym > keysym)
|
||||
max = mid - 1;
|
||||
else {
|
||||
/* found it */
|
||||
return keysymtab[mid].ucs;
|
||||
}
|
||||
mid = (min + max) / 2;
|
||||
if (keysymtab[mid].keysym < keysym)
|
||||
min = mid + 1;
|
||||
else if (keysymtab[mid].keysym > keysym)
|
||||
max = mid - 1;
|
||||
else {
|
||||
/* found it */
|
||||
return keysymtab[mid].ucs;
|
||||
}
|
||||
}
|
||||
|
||||
/* no matching Unicode value found */
|
||||
|
@ -49,26 +49,26 @@ 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,
|
||||
GtkAllocation *allocation);
|
||||
GtkAllocation *allocation);
|
||||
|
||||
/* container class methods */
|
||||
static void moz_container_remove (GtkContainer *container,
|
||||
GtkWidget *child_widget);
|
||||
GtkWidget *child_widget);
|
||||
static void moz_container_forall (GtkContainer *container,
|
||||
gboolean include_internals,
|
||||
GtkCallback callback,
|
||||
gpointer callback_data);
|
||||
gboolean include_internals,
|
||||
GtkCallback callback,
|
||||
gpointer callback_data);
|
||||
|
||||
typedef struct _MozContainerChild MozContainerChild;
|
||||
|
||||
struct _MozContainerChild {
|
||||
GtkWidget *widget;
|
||||
gint x;
|
||||
gint y;
|
||||
GtkWidget *widget;
|
||||
gint x;
|
||||
gint y;
|
||||
};
|
||||
|
||||
static void moz_container_allocate_child (MozContainer *container,
|
||||
MozContainerChild *child);
|
||||
MozContainerChild *child);
|
||||
static MozContainerChild *
|
||||
moz_container_get_child (MozContainer *container, GtkWidget *child);
|
||||
|
||||
@ -79,86 +79,85 @@ static GtkContainerClass *parent_class = NULL;
|
||||
GtkType
|
||||
moz_container_get_type(void)
|
||||
{
|
||||
static GtkType moz_container_type = 0;
|
||||
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 */
|
||||
};
|
||||
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);
|
||||
moz_container_type = g_type_register_static (GTK_TYPE_CONTAINER,
|
||||
"MozContainer",
|
||||
&moz_container_info, 0);
|
||||
}
|
||||
|
||||
return moz_container_type;
|
||||
return moz_container_type;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
moz_container_new (void)
|
||||
{
|
||||
MozContainer *container;
|
||||
MozContainer *container;
|
||||
|
||||
container = gtk_type_new (MOZ_CONTAINER_TYPE);
|
||||
container = gtk_type_new (MOZ_CONTAINER_TYPE);
|
||||
|
||||
return GTK_WIDGET(container);
|
||||
return GTK_WIDGET(container);
|
||||
}
|
||||
|
||||
void
|
||||
moz_container_put (MozContainer *container, GtkWidget *child_widget,
|
||||
gint x, gint y)
|
||||
gint x, gint y)
|
||||
{
|
||||
MozContainerChild *child;
|
||||
MozContainerChild *child;
|
||||
|
||||
child = g_new (MozContainerChild, 1);
|
||||
child = g_new (MozContainerChild, 1);
|
||||
|
||||
child->widget = child_widget;
|
||||
child->x = x;
|
||||
child->y = y;
|
||||
child->widget = child_widget;
|
||||
child->x = x;
|
||||
child->y = y;
|
||||
|
||||
/* printf("moz_container_put %p %p %d %d\n", (void *)container,
|
||||
(void *)child_widget, x, y); */
|
||||
/* printf("moz_container_put %p %p %d %d\n", (void *)container,
|
||||
(void *)child_widget, x, y); */
|
||||
|
||||
container->children = g_list_append (container->children, child);
|
||||
container->children = g_list_append (container->children, child);
|
||||
|
||||
/* 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));
|
||||
/* 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));
|
||||
}
|
||||
|
||||
void
|
||||
moz_container_move (MozContainer *container, GtkWidget *child_widget,
|
||||
gint x, gint y, gint width, gint height)
|
||||
gint x, gint y, gint width, gint height)
|
||||
{
|
||||
MozContainerChild *child;
|
||||
GtkAllocation new_allocation;
|
||||
MozContainerChild *child;
|
||||
GtkAllocation new_allocation;
|
||||
|
||||
child = moz_container_get_child (container, child_widget);
|
||||
child = moz_container_get_child (container, child_widget);
|
||||
|
||||
child->x = x;
|
||||
child->y = y;
|
||||
child->x = x;
|
||||
child->y = y;
|
||||
|
||||
new_allocation.x = x;
|
||||
new_allocation.y = y;
|
||||
new_allocation.width = width;
|
||||
new_allocation.height = height;
|
||||
new_allocation.x = x;
|
||||
new_allocation.y = y;
|
||||
new_allocation.width = width;
|
||||
new_allocation.height = height;
|
||||
|
||||
/* 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);
|
||||
/* 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);
|
||||
}
|
||||
|
||||
/* This function updates the allocation on a child widget without
|
||||
@ -168,27 +167,27 @@ event created by the scroll will update any widgets that come into view. */
|
||||
|
||||
void
|
||||
moz_container_scroll_update (MozContainer *container, GtkWidget *child_widget,
|
||||
gint x, gint y)
|
||||
gint x, gint y)
|
||||
{
|
||||
MozContainerChild *child;
|
||||
GtkAllocation new_allocation;
|
||||
MozContainerChild *child;
|
||||
GtkAllocation new_allocation;
|
||||
|
||||
child = moz_container_get_child (container, child_widget);
|
||||
child = moz_container_get_child (container, child_widget);
|
||||
|
||||
child->x = x;
|
||||
child->y = y;
|
||||
child->x = x;
|
||||
child->y = y;
|
||||
|
||||
new_allocation.x = x;
|
||||
new_allocation.y = y;
|
||||
new_allocation.width = child_widget->allocation.width;
|
||||
new_allocation.height = child_widget->allocation.height;
|
||||
new_allocation.x = x;
|
||||
new_allocation.y = y;
|
||||
new_allocation.width = child_widget->allocation.width;
|
||||
new_allocation.height = child_widget->allocation.height;
|
||||
|
||||
/* 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); */
|
||||
/* 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); */
|
||||
|
||||
gtk_widget_size_allocate(child_widget, &new_allocation);
|
||||
gtk_widget_size_allocate(child_widget, &new_allocation);
|
||||
}
|
||||
|
||||
/* static methods */
|
||||
@ -196,234 +195,233 @@ moz_container_scroll_update (MozContainer *container, GtkWidget *child_widget,
|
||||
void
|
||||
moz_container_class_init (MozContainerClass *klass)
|
||||
{
|
||||
/*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);
|
||||
/*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);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
container_class->remove = moz_container_remove;
|
||||
container_class->forall = moz_container_forall;
|
||||
container_class->remove = moz_container_remove;
|
||||
container_class->forall = moz_container_forall;
|
||||
}
|
||||
|
||||
void
|
||||
moz_container_init (MozContainer *container)
|
||||
{
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
void
|
||||
moz_container_map (GtkWidget *widget)
|
||||
{
|
||||
MozContainer *container;
|
||||
GList *tmp_list;
|
||||
GtkWidget *tmp_child;
|
||||
MozContainer *container;
|
||||
GList *tmp_list;
|
||||
GtkWidget *tmp_child;
|
||||
|
||||
g_return_if_fail (IS_MOZ_CONTAINER(widget));
|
||||
container = MOZ_CONTAINER (widget);
|
||||
g_return_if_fail (IS_MOZ_CONTAINER(widget));
|
||||
container = MOZ_CONTAINER (widget);
|
||||
|
||||
GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
|
||||
GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
|
||||
|
||||
tmp_list = container->children;
|
||||
while (tmp_list) {
|
||||
tmp_child = ((MozContainerChild *)tmp_list->data)->widget;
|
||||
tmp_list = container->children;
|
||||
while (tmp_list) {
|
||||
tmp_child = ((MozContainerChild *)tmp_list->data)->widget;
|
||||
|
||||
if (GTK_WIDGET_VISIBLE(tmp_child)) {
|
||||
if (!GTK_WIDGET_MAPPED(tmp_child))
|
||||
gtk_widget_map(tmp_child);
|
||||
}
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
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);
|
||||
gdk_window_show (widget->window);
|
||||
}
|
||||
|
||||
void
|
||||
moz_container_unmap (GtkWidget *widget)
|
||||
{
|
||||
MozContainer *container;
|
||||
MozContainer *container;
|
||||
|
||||
g_return_if_fail (IS_MOZ_CONTAINER (widget));
|
||||
container = MOZ_CONTAINER (widget);
|
||||
g_return_if_fail (IS_MOZ_CONTAINER (widget));
|
||||
container = MOZ_CONTAINER (widget);
|
||||
|
||||
GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
|
||||
GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
|
||||
|
||||
gdk_window_hide (widget->window);
|
||||
gdk_window_hide (widget->window);
|
||||
}
|
||||
|
||||
void
|
||||
moz_container_realize (GtkWidget *widget)
|
||||
{
|
||||
GdkWindowAttr attributes;
|
||||
gint attributes_mask = 0;
|
||||
MozContainer *container;
|
||||
GdkWindowAttr attributes;
|
||||
gint attributes_mask = 0;
|
||||
MozContainer *container;
|
||||
|
||||
g_return_if_fail(IS_MOZ_CONTAINER(widget));
|
||||
g_return_if_fail(IS_MOZ_CONTAINER(widget));
|
||||
|
||||
container = MOZ_CONTAINER(widget);
|
||||
container = MOZ_CONTAINER(widget);
|
||||
|
||||
GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
|
||||
GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
|
||||
|
||||
/* create the shell window */
|
||||
/* create the shell window */
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
attributes_mask |= GDK_WA_VISUAL | GDK_WA_COLORMAP |
|
||||
GDK_WA_X | GDK_WA_Y;
|
||||
attributes_mask |= GDK_WA_VISUAL | GDK_WA_COLORMAP |
|
||||
GDK_WA_X | GDK_WA_Y;
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
widget->style = gtk_style_attach (widget->style, widget->window);
|
||||
|
||||
/* 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);
|
||||
widget->style = gtk_style_attach (widget->style, widget->window);
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
void
|
||||
moz_container_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation)
|
||||
GtkAllocation *allocation)
|
||||
{
|
||||
MozContainer *container;
|
||||
GList *tmp_list;
|
||||
GtkAllocation tmp_allocation;
|
||||
GtkRequisition tmp_requisition;
|
||||
GtkWidget *tmp_child;
|
||||
MozContainer *container;
|
||||
GList *tmp_list;
|
||||
GtkAllocation tmp_allocation;
|
||||
GtkRequisition tmp_requisition;
|
||||
GtkWidget *tmp_child;
|
||||
|
||||
g_return_if_fail (IS_MOZ_CONTAINER (widget));
|
||||
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); */
|
||||
/* 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 */
|
||||
if (widget->allocation.x == allocation->x &&
|
||||
widget->allocation.y == allocation->y &&
|
||||
widget->allocation.width == allocation->width &&
|
||||
widget->allocation.height == allocation->height) {
|
||||
return;
|
||||
}
|
||||
/* short circuit if you can */
|
||||
if (widget->allocation.x == allocation->x &&
|
||||
widget->allocation.y == allocation->y &&
|
||||
widget->allocation.width == allocation->width &&
|
||||
widget->allocation.height == allocation->height) {
|
||||
return;
|
||||
}
|
||||
|
||||
container = MOZ_CONTAINER (widget);
|
||||
container = MOZ_CONTAINER (widget);
|
||||
|
||||
widget->allocation = *allocation;
|
||||
widget->allocation = *allocation;
|
||||
|
||||
tmp_list = container->children;
|
||||
tmp_list = container->children;
|
||||
|
||||
while (tmp_list) {
|
||||
MozContainerChild *child = tmp_list->data;
|
||||
while (tmp_list) {
|
||||
MozContainerChild *child = tmp_list->data;
|
||||
|
||||
moz_container_allocate_child (container, child);
|
||||
moz_container_allocate_child (container, child);
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
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);
|
||||
}
|
||||
if (GTK_WIDGET_REALIZED (widget)) {
|
||||
gdk_window_move_resize(widget->window,
|
||||
widget->allocation.x,
|
||||
widget->allocation.y,
|
||||
widget->allocation.width,
|
||||
widget->allocation.height);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
moz_container_remove (GtkContainer *container, GtkWidget *child_widget)
|
||||
{
|
||||
MozContainerChild *child;
|
||||
MozContainer *moz_container;
|
||||
GList *tmp_list;
|
||||
MozContainerChild *child;
|
||||
MozContainer *moz_container;
|
||||
GList *tmp_list;
|
||||
|
||||
g_return_if_fail (IS_MOZ_CONTAINER(container));
|
||||
g_return_if_fail (GTK_IS_WIDGET(child_widget));
|
||||
g_return_if_fail (IS_MOZ_CONTAINER(container));
|
||||
g_return_if_fail (GTK_IS_WIDGET(child_widget));
|
||||
|
||||
moz_container = MOZ_CONTAINER(container);
|
||||
moz_container = MOZ_CONTAINER(container);
|
||||
|
||||
child = moz_container_get_child (moz_container, child_widget);
|
||||
g_return_if_fail (child);
|
||||
child = moz_container_get_child (moz_container, child_widget);
|
||||
g_return_if_fail (child);
|
||||
|
||||
moz_container->children = g_list_remove(moz_container->children, child);
|
||||
g_free(child);
|
||||
moz_container->children = g_list_remove(moz_container->children, child);
|
||||
g_free(child);
|
||||
}
|
||||
|
||||
void
|
||||
moz_container_forall (GtkContainer *container, gboolean include_internals,
|
||||
GtkCallback callback, gpointer callback_data)
|
||||
GtkCallback callback, gpointer callback_data)
|
||||
{
|
||||
MozContainer *moz_container;
|
||||
GList *tmp_list;
|
||||
MozContainer *moz_container;
|
||||
GList *tmp_list;
|
||||
|
||||
g_return_if_fail (IS_MOZ_CONTAINER(container));
|
||||
g_return_if_fail (callback != NULL);
|
||||
g_return_if_fail (IS_MOZ_CONTAINER(container));
|
||||
g_return_if_fail (callback != NULL);
|
||||
|
||||
moz_container = MOZ_CONTAINER(container);
|
||||
moz_container = MOZ_CONTAINER(container);
|
||||
|
||||
tmp_list = moz_container->children;
|
||||
while (tmp_list) {
|
||||
MozContainerChild *child;
|
||||
child = tmp_list->data;
|
||||
(* callback) (child->widget, callback_data);
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
tmp_list = moz_container->children;
|
||||
while (tmp_list) {
|
||||
MozContainerChild *child;
|
||||
child = tmp_list->data;
|
||||
(* callback) (child->widget, callback_data);
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
moz_container_allocate_child (MozContainer *container,
|
||||
MozContainerChild *child)
|
||||
MozContainerChild *child)
|
||||
{
|
||||
GtkAllocation allocation;
|
||||
GtkRequisition requisition;
|
||||
GtkAllocation allocation;
|
||||
GtkRequisition requisition;
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
gtk_widget_size_allocate (child->widget, &allocation);
|
||||
gtk_widget_size_allocate (child->widget, &allocation);
|
||||
}
|
||||
|
||||
MozContainerChild *
|
||||
moz_container_get_child (MozContainer *container, GtkWidget *child_widget)
|
||||
{
|
||||
GList *tmp_list;
|
||||
GList *tmp_list;
|
||||
|
||||
tmp_list = container->children;
|
||||
while (tmp_list) {
|
||||
MozContainerChild *child;
|
||||
tmp_list = container->children;
|
||||
while (tmp_list) {
|
||||
MozContainerChild *child;
|
||||
|
||||
child = tmp_list->data;
|
||||
tmp_list = tmp_list->next;
|
||||
child = tmp_list->data;
|
||||
tmp_list = tmp_list->next;
|
||||
|
||||
if (child->widget == child_widget)
|
||||
return child;
|
||||
}
|
||||
if (child->widget == child_widget)
|
||||
return child;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -44,8 +44,8 @@ static void moz_drawingarea_init (MozDrawingarea *drawingarea);
|
||||
|
||||
/* static methods */
|
||||
static void moz_drawingarea_create_windows (MozDrawingarea *drawingarea,
|
||||
GdkWindow *parent,
|
||||
GtkWidget *widget);
|
||||
GdkWindow *parent,
|
||||
GtkWidget *widget);
|
||||
|
||||
static void moz_drawingarea_finalize (GObject *object);
|
||||
|
||||
@ -54,169 +54,166 @@ static GObjectClass *parent_class = NULL;
|
||||
GtkType
|
||||
moz_drawingarea_get_type(void)
|
||||
{
|
||||
static GtkType moz_drawingarea_type = 0;
|
||||
static GtkType moz_drawingarea_type = 0;
|
||||
|
||||
if (!moz_drawingarea_type)
|
||||
{
|
||||
static GTypeInfo moz_drawingarea_info = {
|
||||
sizeof(MozDrawingareaClass), /* class size */
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc) moz_drawingarea_class_init, /* class_init */
|
||||
NULL, /* class_destroy */
|
||||
NULL, /* class_data */
|
||||
sizeof(MozDrawingarea), /* instance_size */
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) moz_drawingarea_init, /* instance_init */
|
||||
NULL, /* value_table */
|
||||
};
|
||||
if (!moz_drawingarea_type) {
|
||||
static GTypeInfo moz_drawingarea_info = {
|
||||
sizeof(MozDrawingareaClass), /* class size */
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc) moz_drawingarea_class_init, /* class_init */
|
||||
NULL, /* class_destroy */
|
||||
NULL, /* class_data */
|
||||
sizeof(MozDrawingarea), /* instance_size */
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) moz_drawingarea_init, /* instance_init */
|
||||
NULL, /* value_table */
|
||||
};
|
||||
moz_drawingarea_type =
|
||||
g_type_register_static (G_TYPE_OBJECT,
|
||||
"MozDrawingarea",
|
||||
&moz_drawingarea_info, 0);
|
||||
}
|
||||
|
||||
moz_drawingarea_type = g_type_register_static (G_TYPE_OBJECT,
|
||||
"MozDrawingarea",
|
||||
&moz_drawingarea_info, 0);
|
||||
}
|
||||
|
||||
return moz_drawingarea_type;
|
||||
return moz_drawingarea_type;
|
||||
}
|
||||
|
||||
MozDrawingarea *
|
||||
moz_drawingarea_new (MozDrawingarea *parent, MozContainer *widget_parent)
|
||||
{
|
||||
MozDrawingarea *drawingarea;
|
||||
MozDrawingarea *drawingarea;
|
||||
|
||||
drawingarea = g_object_new(MOZ_DRAWINGAREA_TYPE, NULL);
|
||||
drawingarea = g_object_new(MOZ_DRAWINGAREA_TYPE, NULL);
|
||||
|
||||
drawingarea->parent = parent;
|
||||
drawingarea->parent = parent;
|
||||
|
||||
if (!parent)
|
||||
moz_drawingarea_create_windows(drawingarea,
|
||||
GTK_WIDGET(widget_parent)->window,
|
||||
GTK_WIDGET(widget_parent));
|
||||
else
|
||||
moz_drawingarea_create_windows(drawingarea,
|
||||
parent->inner_window,
|
||||
GTK_WIDGET(widget_parent));
|
||||
if (!parent)
|
||||
moz_drawingarea_create_windows(drawingarea,
|
||||
GTK_WIDGET(widget_parent)->window,
|
||||
GTK_WIDGET(widget_parent));
|
||||
else
|
||||
moz_drawingarea_create_windows(drawingarea,
|
||||
parent->inner_window,
|
||||
GTK_WIDGET(widget_parent));
|
||||
|
||||
return drawingarea;
|
||||
return drawingarea;
|
||||
}
|
||||
|
||||
void
|
||||
moz_drawingarea_class_init (MozDrawingareaClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = moz_drawingarea_finalize;
|
||||
object_class->finalize = moz_drawingarea_finalize;
|
||||
|
||||
parent_class = g_type_class_peek_parent(klass);
|
||||
parent_class = g_type_class_peek_parent(klass);
|
||||
}
|
||||
|
||||
void
|
||||
moz_drawingarea_init (MozDrawingarea *drawingarea)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
moz_drawingarea_create_windows (MozDrawingarea *drawingarea, GdkWindow *parent,
|
||||
GtkWidget *widget)
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GdkWindowAttr attributes;
|
||||
gint attributes_mask = 0;
|
||||
|
||||
/* create the clipping window */
|
||||
attributes.event_mask = 0;
|
||||
attributes.x = 0;
|
||||
attributes.y = 0;
|
||||
attributes.width = 1;
|
||||
attributes.height = 1;
|
||||
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;
|
||||
GdkWindowAttr attributes;
|
||||
gint attributes_mask = 0;
|
||||
|
||||
attributes_mask |= GDK_WA_VISUAL | GDK_WA_COLORMAP |
|
||||
GDK_WA_X | GDK_WA_Y;
|
||||
/* create the clipping window */
|
||||
attributes.event_mask = 0;
|
||||
attributes.x = 0;
|
||||
attributes.y = 0;
|
||||
attributes.width = 1;
|
||||
attributes.height = 1;
|
||||
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;
|
||||
|
||||
drawingarea->clip_window = gdk_window_new (parent, &attributes,
|
||||
attributes_mask);
|
||||
gdk_window_set_user_data(drawingarea->clip_window, widget);
|
||||
attributes_mask |= GDK_WA_VISUAL | GDK_WA_COLORMAP |
|
||||
GDK_WA_X | GDK_WA_Y;
|
||||
|
||||
/* set the default pixmap to None so that you don't end up with the
|
||||
gtk default which is BlackPixel. */
|
||||
gdk_window_set_back_pixmap(drawingarea->clip_window, NULL, FALSE);
|
||||
drawingarea->clip_window = gdk_window_new (parent, &attributes,
|
||||
attributes_mask);
|
||||
gdk_window_set_user_data(drawingarea->clip_window, widget);
|
||||
|
||||
attributes.event_mask = (GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK |
|
||||
GDK_VISIBILITY_NOTIFY_MASK |
|
||||
GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
|
||||
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
|
||||
GDK_POINTER_MOTION_MASK);
|
||||
/* create the inner window */
|
||||
drawingarea->inner_window = gdk_window_new (drawingarea->clip_window,
|
||||
&attributes, attributes_mask);
|
||||
gdk_window_set_user_data(drawingarea->inner_window, widget);
|
||||
/* set the default pixmap to None so that you don't end up with the
|
||||
gtk default which is BlackPixel. */
|
||||
gdk_window_set_back_pixmap(drawingarea->clip_window, NULL, FALSE);
|
||||
|
||||
/* set the default pixmap to None so that you don't end up with the
|
||||
gtk default which is BlackPixel. */
|
||||
gdk_window_set_back_pixmap(drawingarea->inner_window, NULL, FALSE);
|
||||
attributes.event_mask = (GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK |
|
||||
GDK_VISIBILITY_NOTIFY_MASK |
|
||||
GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
|
||||
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
|
||||
GDK_POINTER_MOTION_MASK);
|
||||
/* create the inner window */
|
||||
drawingarea->inner_window = gdk_window_new (drawingarea->clip_window,
|
||||
&attributes, attributes_mask);
|
||||
gdk_window_set_user_data(drawingarea->inner_window, widget);
|
||||
|
||||
/* set the default pixmap to None so that you don't end up with the
|
||||
gtk default which is BlackPixel. */
|
||||
gdk_window_set_back_pixmap(drawingarea->inner_window, NULL, FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
moz_drawingarea_finalize (GObject *object)
|
||||
{
|
||||
MozDrawingarea *drawingarea;
|
||||
|
||||
g_return_if_fail(IS_MOZ_DRAWINGAREA(object));
|
||||
MozDrawingarea *drawingarea;
|
||||
|
||||
drawingarea = MOZ_DRAWINGAREA(object);
|
||||
g_return_if_fail(IS_MOZ_DRAWINGAREA(object));
|
||||
|
||||
gdk_window_destroy(drawingarea->inner_window);
|
||||
gdk_window_destroy(drawingarea->clip_window);
|
||||
drawingarea = MOZ_DRAWINGAREA(object);
|
||||
|
||||
(* parent_class->finalize) (object);
|
||||
gdk_window_destroy(drawingarea->inner_window);
|
||||
gdk_window_destroy(drawingarea->clip_window);
|
||||
|
||||
(* parent_class->finalize) (object);
|
||||
}
|
||||
|
||||
void
|
||||
moz_drawingarea_move (MozDrawingarea *drawingarea,
|
||||
gint x, gint y)
|
||||
gint x, gint y)
|
||||
{
|
||||
gdk_window_move(drawingarea->clip_window, x, y);
|
||||
gdk_window_move(drawingarea->clip_window, x, y);
|
||||
}
|
||||
|
||||
void
|
||||
moz_drawingarea_resize (MozDrawingarea *drawingarea,
|
||||
gint width, gint height)
|
||||
gint width, gint height)
|
||||
{
|
||||
gdk_window_resize(drawingarea->clip_window, width, height);
|
||||
gdk_window_resize(drawingarea->inner_window, width, height);
|
||||
gdk_window_resize(drawingarea->clip_window, width, height);
|
||||
gdk_window_resize(drawingarea->inner_window, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
moz_drawingarea_move_resize (MozDrawingarea *drawingarea,
|
||||
gint x, gint y, gint width, gint height)
|
||||
gint x, gint y, gint width, gint height)
|
||||
{
|
||||
gdk_window_resize(drawingarea->inner_window, width, height);
|
||||
gdk_window_move_resize(drawingarea->clip_window, x, y, width, height);
|
||||
gdk_window_resize(drawingarea->inner_window, width, height);
|
||||
gdk_window_move_resize(drawingarea->clip_window, x, y, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
moz_drawingarea_set_visibility (MozDrawingarea *drawingarea,
|
||||
gboolean visibility)
|
||||
gboolean visibility)
|
||||
{
|
||||
if (visibility)
|
||||
{
|
||||
gdk_window_show(drawingarea->inner_window);
|
||||
gdk_window_show(drawingarea->clip_window);
|
||||
if (visibility) {
|
||||
gdk_window_show(drawingarea->inner_window);
|
||||
gdk_window_show(drawingarea->clip_window);
|
||||
}
|
||||
else
|
||||
{
|
||||
gdk_window_hide(drawingarea->clip_window);
|
||||
gdk_window_hide(drawingarea->inner_window);
|
||||
else {
|
||||
gdk_window_hide(drawingarea->clip_window);
|
||||
gdk_window_hide(drawingarea->inner_window);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
moz_drawingarea_scroll (MozDrawingarea *drawingarea,
|
||||
gint x, gint y)
|
||||
gint x, gint y)
|
||||
{
|
||||
gdk_window_scroll(drawingarea->inner_window, x, y);
|
||||
gdk_window_scroll(drawingarea->inner_window, x, y);
|
||||
}
|
||||
|
@ -38,12 +38,12 @@ int main(int argc, char **argv)
|
||||
moz_container = moz_container_new();
|
||||
printf("moz_container is %p\n", moz_container);
|
||||
gtk_signal_connect(GTK_OBJECT(moz_container), "expose_event",
|
||||
GTK_SIGNAL_FUNC(expose_handler), NULL);
|
||||
GTK_SIGNAL_FUNC(expose_handler), NULL);
|
||||
gtk_signal_connect(GTK_OBJECT(moz_container), "size_allocate",
|
||||
GTK_SIGNAL_FUNC(size_allocate_handler), NULL);
|
||||
GTK_SIGNAL_FUNC(size_allocate_handler), NULL);
|
||||
|
||||
gtk_container_add(GTK_CONTAINER(toplevel_window),
|
||||
moz_container);
|
||||
moz_container);
|
||||
|
||||
gtk_widget_realize(moz_container);
|
||||
|
||||
@ -74,12 +74,12 @@ gint
|
||||
expose_handler (GtkWidget *widget, GdkEventExpose *event)
|
||||
{
|
||||
printf("expose %p %p %d %d %d %d\n",
|
||||
widget,
|
||||
event->window,
|
||||
event->area.x,
|
||||
event->area.y,
|
||||
event->area.width,
|
||||
event->area.height);
|
||||
widget,
|
||||
event->window,
|
||||
event->area.x,
|
||||
event->area.y,
|
||||
event->area.width,
|
||||
event->area.height);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -87,6 +87,6 @@ void
|
||||
size_allocate_handler (GtkWidget *widget, GtkAllocation *allocation)
|
||||
{
|
||||
printf("size_allocate_handler %p %d %d %d %d\n", widget,
|
||||
allocation->x, allocation->y, allocation->width, allocation->height);
|
||||
allocation->x, allocation->y, allocation->width, allocation->height);
|
||||
moz_drawingarea_resize(drawingarea1, allocation->width, allocation->height);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user