From b1bc8c407ede70afbb2f18321a1162aaae5e990c Mon Sep 17 00:00:00 2001 From: "shaver%netscape.com" Date: Wed, 25 Nov 1998 17:50:35 +0000 Subject: [PATCH] revert pavlov's changes at his request --- widget/src/gtk/gtklayout.c | 162 +++++++++++-------------------------- widget/src/gtk/gtklayout.h | 21 ++--- 2 files changed, 57 insertions(+), 126 deletions(-) diff --git a/widget/src/gtk/gtklayout.c b/widget/src/gtk/gtklayout.c index 11f1698dfa91..df1c49a6c08b 100644 --- a/widget/src/gtk/gtklayout.c +++ b/widget/src/gtk/gtklayout.c @@ -2,6 +2,9 @@ * * This file may be distributed under either the terms of the * Netscape Public License, or the GNU Library General Public License + * + * Note: No GTK+ or Mozilla code should be added to this file. + * The coding style should be that of the the GTK core. */ #include "gtklayout.h" @@ -30,9 +33,6 @@ static void gtk_layout_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); -static void gtk_layout_set_adjustments (GtkLayout *layout, - GtkAdjustment *hadj, - GtkAdjustment *vadj); static void gtk_layout_realize_child (GtkLayout *layout, GtkLayoutChild *child); @@ -73,7 +73,8 @@ gtk_layout_new (GtkAdjustment *hadjustment, layout = gtk_type_new (gtk_layout_get_type()); - gtk_layout_set_adjustments (layout, hadjustment, vadjustment); + gtk_layout_set_hadjustment (layout, hadjustment); + gtk_layout_set_vadjustment (layout, vadjustment); return GTK_WIDGET (layout); } @@ -95,65 +96,6 @@ gtk_layout_get_vadjustment (GtkLayout *layout) return layout->vadjustment; } -static void -gtk_layout_set_adjustments (GtkLayout *layout, - GtkAdjustment *hadj, - GtkAdjustment *vadj) -{ - gboolean need_adjust = FALSE; - - g_return_if_fail (layout != NULL); - g_return_if_fail (GTK_IS_LAYOUT (layout)); - - if (hadj) - g_return_if_fail (GTK_IS_ADJUSTMENT (hadj)); - else - hadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); - if (vadj) - g_return_if_fail (GTK_IS_ADJUSTMENT (vadj)); - else - vadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); - - if (layout->hadjustment && (layout->hadjustment != hadj)) - { - gtk_signal_disconnect_by_data (GTK_OBJECT (layout->hadjustment), layout); - gtk_object_unref (GTK_OBJECT (layout->hadjustment)); - } - - if (layout->vadjustment && (layout->vadjustment != vadj)) - { - gtk_signal_disconnect_by_data (GTK_OBJECT (layout->vadjustment), layout); - gtk_object_unref (GTK_OBJECT (layout->vadjustment)); - } - - if (layout->hadjustment != hadj) - { - layout->hadjustment = hadj; - gtk_object_ref (GTK_OBJECT (layout->hadjustment)); - gtk_object_sink (GTK_OBJECT (layout->hadjustment)); - - gtk_signal_connect (GTK_OBJECT (layout->hadjustment), "value_changed", - (GtkSignalFunc) gtk_layout_adjustment_changed, - layout); - need_adjust = TRUE; - } - - if (layout->vadjustment != vadj) - { - layout->vadjustment = vadj; - gtk_object_ref (GTK_OBJECT (layout->vadjustment)); - gtk_object_sink (GTK_OBJECT (layout->vadjustment)); - - gtk_signal_connect (GTK_OBJECT (layout->vadjustment), "value_changed", - (GtkSignalFunc) gtk_layout_adjustment_changed, - layout); - need_adjust = TRUE; - } - - if (need_adjust) - gtk_layout_adjustment_changed (NULL, layout); -} - void gtk_layout_set_hadjustment (GtkLayout *layout, GtkAdjustment *adjustment) @@ -161,7 +103,19 @@ gtk_layout_set_hadjustment (GtkLayout *layout, g_return_if_fail (layout != NULL); g_return_if_fail (GTK_IS_LAYOUT (layout)); - gtk_layout_set_adjustments (layout, adjustment, layout->vadjustment); + if (layout->hadjustment) + gtk_object_unref (GTK_OBJECT (layout->hadjustment)); + + if (!adjustment) + adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 10.0, 0.0, 0.0)); + else + gtk_object_ref (GTK_OBJECT (adjustment)); + + gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed", + GTK_SIGNAL_FUNC (gtk_layout_adjustment_changed), + layout); + + layout->hadjustment = adjustment; } @@ -172,7 +126,19 @@ gtk_layout_set_vadjustment (GtkLayout *layout, g_return_if_fail (layout != NULL); g_return_if_fail (GTK_IS_LAYOUT (layout)); - gtk_layout_set_adjustments (layout, layout->hadjustment, adjustment); + if (layout->vadjustment) + gtk_object_unref (GTK_OBJECT (layout->hadjustment)); + + if (!adjustment) + adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 10.0, 0.0, 0.0)); + else + gtk_object_ref (GTK_OBJECT (adjustment)); + + gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed", + GTK_SIGNAL_FUNC (gtk_layout_adjustment_changed), + layout); + + layout->vadjustment = adjustment; } @@ -195,7 +161,6 @@ gtk_layout_put (GtkLayout *layout, child->y = y; child->widget->requisition.width = 0; child->widget->requisition.height = 0; - child->mapped = FALSE; layout->children = g_list_append (layout->children, child); @@ -326,20 +291,10 @@ gtk_layout_class_init (GtkLayoutClass *class) widget_class->draw = gtk_layout_draw; widget_class->expose_event = gtk_layout_expose; - widget_class->scroll_adjustments_signal = - gtk_signal_new ("scroll_adjustments", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (GtkLayoutClass, scroll_adjustments), - gtk_marshal_NONE__POINTER_POINTER, - GTK_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT); - gravity_works = gtk_layout_gravity_works (); container_class->remove = gtk_layout_remove; container_class->forall = gtk_layout_forall; - - class->scroll_adjustments = gtk_layout_set_adjustments; } static void @@ -445,14 +400,12 @@ gtk_layout_map (GtkWidget *widget) { GtkLayoutChild *child = tmp_list->data; - if (child->mapped && GTK_WIDGET_VISIBLE (child->widget)) - { - if (!GTK_WIDGET_MAPPED (child->widget)) - gtk_widget_map (child->widget); - - if (child->window) - gdk_window_show (child->window); - } + if (GTK_WIDGET_VISIBLE (child->widget) && + !GTK_WIDGET_MAPPED (child->widget)) + gtk_widget_map (child->widget); + + if (child->window) + gdk_window_show (child->window); tmp_list = tmp_list->next; } @@ -727,21 +680,12 @@ gtk_layout_position_child (GtkLayout *layout, if ((x >= G_MINSHORT) && (x <= G_MAXSHORT) && (y >= G_MINSHORT) && (y <= G_MAXSHORT)) { - if (!child->mapped) + if (GTK_WIDGET_VISIBLE (child->widget) && + GTK_WIDGET_MAPPED (layout) && + !GTK_WIDGET_MAPPED (child->widget)) { - child->mapped = TRUE; - - if (GTK_WIDGET_MAPPED (layout) && - GTK_WIDGET_VISIBLE (child->widget)) - { - if (child->window) - gdk_window_show (child->window); - if (!GTK_WIDGET_MAPPED (child->widget)) - gtk_widget_map (child->widget); - - child->mapped = TRUE; - force_allocate = TRUE; - } + gtk_widget_map (child->widget); + force_allocate = TRUE; } if (force_allocate) @@ -775,14 +719,10 @@ gtk_layout_position_child (GtkLayout *layout, } else { - if (child->mapped) - { - child->mapped = FALSE; - if (child->window) - gdk_window_hide (child->window); - else if (GTK_WIDGET_MAPPED (child->widget)) - gtk_widget_unmap (child->widget); - } + if (child->window) + gdk_window_hide (child->window); + else if (GTK_WIDGET_MAPPED (child->widget)) + gtk_widget_unmap (child->widget); } } @@ -893,11 +833,10 @@ gtk_layout_adjustment_changed (GtkAdjustment *adjustment, if (layout->frozen) return; + gtk_layout_position_children (layout); + if (!GTK_WIDGET_MAPPED (layout)) - { - gtk_layout_position_children (layout); - return; - } + return; if (dx > 0) { @@ -996,8 +935,6 @@ gtk_layout_adjustment_changed (GtkAdjustment *adjustment, -dy); } - gtk_layout_position_children (layout); - /* We have to make sure that all exposes from this scroll get * processed before we scroll again, or the expose events will * have invalid coordinates. @@ -1200,4 +1137,3 @@ gtk_layout_gravity_works (void) return (y == -20); } - diff --git a/widget/src/gtk/gtklayout.h b/widget/src/gtk/gtklayout.h index 640ead07cc8b..924b5390477d 100644 --- a/widget/src/gtk/gtklayout.h +++ b/widget/src/gtk/gtklayout.h @@ -1,7 +1,10 @@ /* Copyright Owen Taylor, 1998 - * + * * This file may be distributed under either the terms of the * Netscape Public License, or the GNU Library General Public License + * + * Note: No GTK+ or Mozilla code should be added to this file. + * The coding style should be that of the the GTK core. */ #ifndef __GTK_LAYOUT_H @@ -11,10 +14,6 @@ #include #include -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - /* * We don't want to require gnome-libs, in which GtkLayout now lives, but @@ -47,9 +46,10 @@ extern "C" { #define gtk_layout_set_hadjustment moz_gtk_layout_set_hadjustment #define gtk_layout_set_vadjustment moz_gtk_layout_set_vadjustment -#define GtkLayout MozGtkLayout -#define GtkLayoutClass MozGtkLayoutClass -#define GtkLayoutChild MozGtkLayoutChild + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ #define GTK_LAYOUT(obj) GTK_CHECK_CAST (obj, gtk_layout_get_type (), GtkLayout) #define GTK_LAYOUT_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_layout_get_type (), GtkLayoutClass) @@ -64,7 +64,6 @@ struct _GtkLayoutChild { GdkWindow *window; /* For NO_WINDOW widgets */ gint x; gint y; - gboolean mapped : 1; }; struct _GtkLayout { @@ -93,10 +92,6 @@ struct _GtkLayout { struct _GtkLayoutClass { GtkContainerClass parent_class; - - void (*scroll_adjustments) (GtkLayout *text, - GtkAdjustment *hadjustment, - GtkAdjustment *vadjustment); }; GtkWidget* gtk_layout_new (GtkAdjustment *hadjustment,