Check to catch the case when the viewport fits in either direction or

Thu Apr 30 23:32:51 1998  Owen Taylor  <otaylor@gtk.org>

	* gtk/gtkscrolledwindow.c (gtk_scrolled_window_size_allocate):
	Check to catch the case when the viewport fits in either
 	direction or both, instead of flip-flopping infinitely.

	Only show/hide the scrollbars once at the end.

Thu Apr 30 21:56:07 1998  Owen Taylor  <otaylor@gtk.org>

	* gtk/gtkscrolledwindow.c (gtk_scrolled_window_foreach):
	Include the scrollbars in the foreach call.
	(gtk-fortier-980405-0.patch;
 	 Patrice Fortier <Patrice.Fortier@aquarel.fr>).

	The notebook widget
	really should also include its tabs, but that might cause
	problems for programs if they
This commit is contained in:
Owen Taylor
1998-05-01 03:37:01 +00:00
committed by Owen Taylor
parent 8435d34838
commit 6349f7cb2c
10 changed files with 262 additions and 51 deletions

View File

@@ -1,3 +1,29 @@
Thu Apr 30 23:32:51 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_size_allocate):
Check to catch the case when the viewport fits in either
direction or both, instead of flip-flopping infinitely.
Only show/hide the scrollbars once at the end.
Thu Apr 30 21:56:07 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_foreach):
Include the scrollbars in the foreach call.
(gtk-fortier-980405-0.patch;
Patrice Fortier <Patrice.Fortier@aquarel.fr>).
The notebook widget
really should also include its tabs, but that might cause
problems for programs if they
Thu Apr 30 21:51:52 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkpixmap.c (gtk_pixmap_set): Only request a
resize if the size actually changed.
(gtk-johannes-980414-0.patch ;
johannes@nada.kth.se (Johannes Keukelaar) )
Thu Apr 30 10:22:59 1998 Owen Taylor <otaylor@gtk.org>
* glib/ltmain.sh glib/ltconfig glib/config.sub glib/config.guess:

View File

@@ -1,3 +1,29 @@
Thu Apr 30 23:32:51 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_size_allocate):
Check to catch the case when the viewport fits in either
direction or both, instead of flip-flopping infinitely.
Only show/hide the scrollbars once at the end.
Thu Apr 30 21:56:07 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_foreach):
Include the scrollbars in the foreach call.
(gtk-fortier-980405-0.patch;
Patrice Fortier <Patrice.Fortier@aquarel.fr>).
The notebook widget
really should also include its tabs, but that might cause
problems for programs if they
Thu Apr 30 21:51:52 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkpixmap.c (gtk_pixmap_set): Only request a
resize if the size actually changed.
(gtk-johannes-980414-0.patch ;
johannes@nada.kth.se (Johannes Keukelaar) )
Thu Apr 30 10:22:59 1998 Owen Taylor <otaylor@gtk.org>
* glib/ltmain.sh glib/ltconfig glib/config.sub glib/config.guess:

View File

@@ -1,3 +1,29 @@
Thu Apr 30 23:32:51 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_size_allocate):
Check to catch the case when the viewport fits in either
direction or both, instead of flip-flopping infinitely.
Only show/hide the scrollbars once at the end.
Thu Apr 30 21:56:07 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_foreach):
Include the scrollbars in the foreach call.
(gtk-fortier-980405-0.patch;
Patrice Fortier <Patrice.Fortier@aquarel.fr>).
The notebook widget
really should also include its tabs, but that might cause
problems for programs if they
Thu Apr 30 21:51:52 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkpixmap.c (gtk_pixmap_set): Only request a
resize if the size actually changed.
(gtk-johannes-980414-0.patch ;
johannes@nada.kth.se (Johannes Keukelaar) )
Thu Apr 30 10:22:59 1998 Owen Taylor <otaylor@gtk.org>
* glib/ltmain.sh glib/ltconfig glib/config.sub glib/config.guess:

View File

@@ -1,3 +1,29 @@
Thu Apr 30 23:32:51 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_size_allocate):
Check to catch the case when the viewport fits in either
direction or both, instead of flip-flopping infinitely.
Only show/hide the scrollbars once at the end.
Thu Apr 30 21:56:07 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_foreach):
Include the scrollbars in the foreach call.
(gtk-fortier-980405-0.patch;
Patrice Fortier <Patrice.Fortier@aquarel.fr>).
The notebook widget
really should also include its tabs, but that might cause
problems for programs if they
Thu Apr 30 21:51:52 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkpixmap.c (gtk_pixmap_set): Only request a
resize if the size actually changed.
(gtk-johannes-980414-0.patch ;
johannes@nada.kth.se (Johannes Keukelaar) )
Thu Apr 30 10:22:59 1998 Owen Taylor <otaylor@gtk.org>
* glib/ltmain.sh glib/ltconfig glib/config.sub glib/config.guess:

View File

@@ -1,3 +1,29 @@
Thu Apr 30 23:32:51 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_size_allocate):
Check to catch the case when the viewport fits in either
direction or both, instead of flip-flopping infinitely.
Only show/hide the scrollbars once at the end.
Thu Apr 30 21:56:07 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_foreach):
Include the scrollbars in the foreach call.
(gtk-fortier-980405-0.patch;
Patrice Fortier <Patrice.Fortier@aquarel.fr>).
The notebook widget
really should also include its tabs, but that might cause
problems for programs if they
Thu Apr 30 21:51:52 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkpixmap.c (gtk_pixmap_set): Only request a
resize if the size actually changed.
(gtk-johannes-980414-0.patch ;
johannes@nada.kth.se (Johannes Keukelaar) )
Thu Apr 30 10:22:59 1998 Owen Taylor <otaylor@gtk.org>
* glib/ltmain.sh glib/ltconfig glib/config.sub glib/config.guess:

View File

@@ -1,3 +1,29 @@
Thu Apr 30 23:32:51 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_size_allocate):
Check to catch the case when the viewport fits in either
direction or both, instead of flip-flopping infinitely.
Only show/hide the scrollbars once at the end.
Thu Apr 30 21:56:07 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_foreach):
Include the scrollbars in the foreach call.
(gtk-fortier-980405-0.patch;
Patrice Fortier <Patrice.Fortier@aquarel.fr>).
The notebook widget
really should also include its tabs, but that might cause
problems for programs if they
Thu Apr 30 21:51:52 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkpixmap.c (gtk_pixmap_set): Only request a
resize if the size actually changed.
(gtk-johannes-980414-0.patch ;
johannes@nada.kth.se (Johannes Keukelaar) )
Thu Apr 30 10:22:59 1998 Owen Taylor <otaylor@gtk.org>
* glib/ltmain.sh glib/ltconfig glib/config.sub glib/config.guess:

View File

@@ -1,3 +1,29 @@
Thu Apr 30 23:32:51 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_size_allocate):
Check to catch the case when the viewport fits in either
direction or both, instead of flip-flopping infinitely.
Only show/hide the scrollbars once at the end.
Thu Apr 30 21:56:07 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_foreach):
Include the scrollbars in the foreach call.
(gtk-fortier-980405-0.patch;
Patrice Fortier <Patrice.Fortier@aquarel.fr>).
The notebook widget
really should also include its tabs, but that might cause
problems for programs if they
Thu Apr 30 21:51:52 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkpixmap.c (gtk_pixmap_set): Only request a
resize if the size actually changed.
(gtk-johannes-980414-0.patch ;
johannes@nada.kth.se (Johannes Keukelaar) )
Thu Apr 30 10:22:59 1998 Owen Taylor <otaylor@gtk.org>
* glib/ltmain.sh glib/ltconfig glib/config.sub glib/config.guess:

View File

@@ -104,12 +104,16 @@ gtk_pixmap_set (GtkPixmap *pixmap,
{
gint width;
gint height;
gint oldwidth;
gint oldheight;
g_return_if_fail (pixmap != NULL);
g_return_if_fail (GTK_IS_PIXMAP (pixmap));
if (pixmap->pixmap != val)
{
oldwidth = GTK_WIDGET (pixmap)->requisition.width;
oldheight = GTK_WIDGET (pixmap)->requisition.height;
if (pixmap->pixmap)
gdk_pixmap_unref (pixmap->pixmap);
pixmap->pixmap = val;
@@ -128,7 +132,13 @@ gtk_pixmap_set (GtkPixmap *pixmap,
GTK_WIDGET (pixmap)->requisition.height = 0;
}
if (GTK_WIDGET_VISIBLE (pixmap))
gtk_widget_queue_resize (GTK_WIDGET (pixmap));
{
if ((GTK_WIDGET (pixmap)->requisition.width != oldwidth) ||
(GTK_WIDGET (pixmap)->requisition.height != oldheight))
gtk_widget_queue_resize (GTK_WIDGET (pixmap));
else
gtk_widget_queue_draw (GTK_WIDGET (pixmap));
}
}
if (pixmap->mask != mask)

View File

@@ -51,10 +51,10 @@ static void gtk_scrolled_window_adjustment_changed (GtkAdjustment *adju
static GtkContainerClass *parent_class = NULL;
GtkType
guint
gtk_scrolled_window_get_type ()
{
static GtkType scrolled_window_type = 0;
static guint scrolled_window_type = 0;
if (!scrolled_window_type)
{
@@ -371,7 +371,8 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
GtkAllocation child_allocation;
guint previous_hvis;
guint previous_vvis;
gint count;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (widget));
g_return_if_fail (allocation != NULL);
@@ -379,12 +380,12 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
scrolled_window = GTK_SCROLLED_WINDOW (widget);
widget->allocation = *allocation;
gtk_scrolled_window_viewport_allocate (widget, &viewport_allocation);
gtk_container_disable_resize (GTK_CONTAINER (scrolled_window));
if (GTK_WIDGET_VISIBLE (scrolled_window->viewport))
{
count = 0;
do {
gtk_scrolled_window_viewport_allocate (widget, &viewport_allocation);
@@ -393,16 +394,32 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
child_allocation.width = viewport_allocation.width;
child_allocation.height = viewport_allocation.height;
previous_hvis = GTK_WIDGET_VISIBLE (scrolled_window->hscrollbar);
previous_vvis = GTK_WIDGET_VISIBLE (scrolled_window->vscrollbar);
previous_hvis = scrolled_window->hscrollbar_visible;
previous_vvis = scrolled_window->vscrollbar_visible;
gtk_widget_size_allocate (scrolled_window->viewport, &child_allocation);
} while ((previous_hvis != GTK_WIDGET_VISIBLE (scrolled_window->hscrollbar)) ||
(previous_vvis != GTK_WIDGET_VISIBLE (scrolled_window->vscrollbar)));
/* If, after the first iteration, the hscrollbar and the
* vscrollbar flip visiblity, then we need both.
*/
if ((count++) &&
(previous_hvis != scrolled_window->hscrollbar_visible) &&
(previous_vvis != scrolled_window->vscrollbar_visible))
{
scrolled_window->hscrollbar_visible = TRUE;
scrolled_window->vscrollbar_visible = TRUE;
break;
}
count++;
} while ((previous_hvis != scrolled_window->hscrollbar_visible) ||
(previous_vvis != scrolled_window->vscrollbar_visible));
}
if (GTK_WIDGET_VISIBLE (scrolled_window->hscrollbar))
if (scrolled_window->hscrollbar_visible)
{
if (!GTK_WIDGET_VISIBLE (scrolled_window->hscrollbar))
gtk_widget_show (scrolled_window->hscrollbar);
child_allocation.x = viewport_allocation.x;
child_allocation.y = viewport_allocation.y + viewport_allocation.height + SCROLLBAR_SPACING (scrolled_window);
child_allocation.width = viewport_allocation.width;
@@ -412,9 +429,17 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
gtk_widget_size_allocate (scrolled_window->hscrollbar, &child_allocation);
}
if (GTK_WIDGET_VISIBLE (scrolled_window->vscrollbar))
else
{
if (GTK_WIDGET_VISIBLE (scrolled_window->hscrollbar))
gtk_widget_hide (scrolled_window->hscrollbar);
}
if (scrolled_window->vscrollbar_visible)
{
if (!GTK_WIDGET_VISIBLE (scrolled_window->vscrollbar))
gtk_widget_show (scrolled_window->vscrollbar);
child_allocation.x = viewport_allocation.x + viewport_allocation.width + SCROLLBAR_SPACING (scrolled_window);
child_allocation.y = viewport_allocation.y;
child_allocation.width = scrolled_window->vscrollbar->requisition.width;
@@ -424,6 +449,11 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
gtk_widget_size_allocate (scrolled_window->vscrollbar, &child_allocation);
}
else
{
if (GTK_WIDGET_VISIBLE (scrolled_window->vscrollbar))
gtk_widget_hide (scrolled_window->vscrollbar);
}
gtk_container_enable_resize (GTK_CONTAINER (scrolled_window));
}
@@ -480,6 +510,9 @@ gtk_scrolled_window_foreach (GtkContainer *container,
if (scrolled_window->viewport)
(* callback) (scrolled_window->viewport, callback_data);
(* callback) (scrolled_window->vscrollbar, callback_data);
(* callback) (scrolled_window->hscrollbar, callback_data);
}
static void
@@ -498,10 +531,10 @@ gtk_scrolled_window_viewport_allocate (GtkWidget *widget,
allocation->width = MAX (1, widget->allocation.width - allocation->x * 2);
allocation->height = MAX (1, widget->allocation.height - allocation->y * 2);
if (GTK_WIDGET_VISIBLE (scrolled_window->vscrollbar))
if (scrolled_window->vscrollbar_visible)
allocation->width = MAX (1,
allocation->width - (scrolled_window->vscrollbar->requisition.width + SCROLLBAR_SPACING (scrolled_window)));
if (GTK_WIDGET_VISIBLE (scrolled_window->hscrollbar))
if (scrolled_window->hscrollbar_visible)
allocation->height = MAX (1,
allocation->height - (scrolled_window->hscrollbar->requisition.height + SCROLLBAR_SPACING (scrolled_window)));
}
@@ -511,9 +544,6 @@ gtk_scrolled_window_adjustment_changed (GtkAdjustment *adjustment,
gpointer data)
{
GtkScrolledWindow *scrolled_win;
GtkWidget *scrollbar;
gint hide_scrollbar;
gint policy;
g_return_if_fail (adjustment != NULL);
g_return_if_fail (data != NULL);
@@ -522,36 +552,23 @@ gtk_scrolled_window_adjustment_changed (GtkAdjustment *adjustment,
if (adjustment == gtk_range_get_adjustment (GTK_RANGE (scrolled_win->hscrollbar)))
{
scrollbar = scrolled_win->hscrollbar;
policy = scrolled_win->hscrollbar_policy;
if (scrolled_win->hscrollbar_policy == GTK_POLICY_AUTOMATIC)
{
scrolled_win->hscrollbar_visible =
((adjustment->upper - adjustment->lower) > adjustment->page_size);
}
}
else if (adjustment == gtk_range_get_adjustment (GTK_RANGE (scrolled_win->vscrollbar)))
{
scrollbar = scrolled_win->vscrollbar;
policy = scrolled_win->vscrollbar_policy;
if (scrolled_win->vscrollbar_policy == GTK_POLICY_AUTOMATIC)
{
scrolled_win->vscrollbar_visible =
((adjustment->upper - adjustment->lower) > adjustment->page_size);
}
}
else
{
g_warning ("could not determine which adjustment scrollbar received change signal for");
return;
}
if (policy == GTK_POLICY_AUTOMATIC)
{
hide_scrollbar = FALSE;
if ((adjustment->upper - adjustment->lower) <= adjustment->page_size)
hide_scrollbar = TRUE;
if (hide_scrollbar)
{
if (GTK_WIDGET_VISIBLE (scrollbar))
gtk_widget_hide (scrollbar);
}
else
{
if (!GTK_WIDGET_VISIBLE (scrollbar))
gtk_widget_show (scrollbar);
}
}
}

View File

@@ -8,7 +8,7 @@
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
@@ -31,13 +31,13 @@ extern "C" {
#endif /* __cplusplus */
#define GTK_SCROLLED_WINDOW(obj) (GTK_CHECK_CAST (obj, gtk_scrolled_window_get_type (), GtkScrolledWindow))
#define GTK_SCROLLED_WINDOW_CLASS(klass) (GTK_CHECK_CLASS_CAST (klass, gtk_scrolled_window_get_type (), GtkScrolledWindowClass))
#define GTK_IS_SCROLLED_WINDOW(obj) (GTK_CHECK_TYPE (obj, gtk_scrolled_window_get_type ()))
#define GTK_SCROLLED_WINDOW(obj) GTK_CHECK_CAST (obj, gtk_scrolled_window_get_type (), GtkScrolledWindow)
#define GTK_SCROLLED_WINDOW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_scrolled_window_get_type (), GtkScrolledWindowClass)
#define GTK_IS_SCROLLED_WINDOW(obj) GTK_CHECK_TYPE (obj, gtk_scrolled_window_get_type ())
typedef struct _GtkScrolledWindow GtkScrolledWindow;
typedef struct _GtkScrolledWindowClass GtkScrolledWindowClass;
typedef struct _GtkScrolledWindow GtkScrolledWindow;
typedef struct _GtkScrolledWindowClass GtkScrolledWindowClass;
struct _GtkScrolledWindow
{
@@ -49,6 +49,8 @@ struct _GtkScrolledWindow
guint8 hscrollbar_policy;
guint8 vscrollbar_policy;
gint hscrollbar_visible : 1;
gint vscrollbar_visible : 1;
};
struct _GtkScrolledWindowClass
@@ -59,15 +61,15 @@ struct _GtkScrolledWindowClass
};
GtkType gtk_scrolled_window_get_type (void);
GtkWidget* gtk_scrolled_window_new (GtkAdjustment *hadjustment,
guint gtk_scrolled_window_get_type (void);
GtkWidget* gtk_scrolled_window_new (GtkAdjustment *hadjustment,
GtkAdjustment *vadjustment);
void gtk_scrolled_window_construct (GtkScrolledWindow *scrolled_window,
void gtk_scrolled_window_construct (GtkScrolledWindow *scrolled_window,
GtkAdjustment *hadjustment,
GtkAdjustment *vadjustment);
GtkAdjustment* gtk_scrolled_window_get_hadjustment (GtkScrolledWindow *scrolled_window);
GtkAdjustment* gtk_scrolled_window_get_vadjustment (GtkScrolledWindow *scrolled_window);
void gtk_scrolled_window_set_policy (GtkScrolledWindow *scrolled_window,
void gtk_scrolled_window_set_policy (GtkScrolledWindow *scrolled_window,
GtkPolicyType hscrollbar_policy,
GtkPolicyType vscrollbar_policy);