summaryrefslogtreecommitdiff
path: root/gtk/gtkscrolledwindow.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2000-02-18 20:02:24 +0000
committerOwen Taylor <otaylor@src.gnome.org>2000-02-18 20:02:24 +0000
commitc8a2382b65120b32277f84394c55c7b51383523b (patch)
tree5fa6f133218b9f19106fb6720f1a7f6258f44476 /gtk/gtkscrolledwindow.c
parentab1deac87fa395332b73daf8e2e4c893e23be3e4 (diff)
downloadgtk+-c8a2382b65120b32277f84394c55c7b51383523b.tar.gz
Remove OwnerGrabButtonMask from button entries for GDK_BUTTON_PRESS /
Fri Feb 18 14:37:29 2000 Owen Taylor <otaylor@redhat.com> * gdk/x11/gdkwindow-x11.c (gdk_event_mask_table): Remove OwnerGrabButtonMask from button entries for GDK_BUTTON_PRESS / GDK_BUTTON_RELEASE. * gtk/gtklayout.c (gtk_layout_realize): Always add GDK_SCROLL to the event mask (which will result in button/press release being added to the event mask on Unix) so scrolling works for layouts in scroll windows. * gdk/gdkevents.h (enum): Fix up GDK_ALL_EVENTS_MASK. Patch from Anders Carlsson <andersca@picard.andersnet> to add a scroll event. * gtk/testgtk.c (scroll_test_scroll): Added an example of mouse wheel scrolling to the "Test Scrolling" part of testgtk. * gtk/gtkwidget.h (struct _GtkWidgetClass): Added scroll_event signal. * gtk/gtkwidget.c: Added "scroll_event" GTK+ signal and matched it against GDK_SCROLL. * gtk/gtkrange.c (gtk_range_scroll_event): Updated to use the new way of mouse wheel scrolling. * gtk/gtkscrolledwindow.c (gtk_scrolled_window_scroll_event): Likewise. * gtk/gtkspinbutton.c (gtk_spin_button_scroll): Likewise. * gtk/gtkmain.c: Removed previous mouse wheel hack. * gdk/x11/gdkwindow-x11.c (gdk_event_mask_table): Added entry in gdk_event_mask_table. * gdk/x11/gdkevents-x11.c (gdk_event_translate): Added GdkEventScroll handler. * gdk/gdkevents.h: Added GdkEventScroll structure.
Diffstat (limited to 'gtk/gtkscrolledwindow.c')
-rw-r--r--gtk/gtkscrolledwindow.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index e9f0f1d857..2e7b969247 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -95,6 +95,8 @@ static void gtk_scrolled_window_size_request (GtkWidget *widg
GtkRequisition *requisition);
static void gtk_scrolled_window_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
+static gint gtk_scrolled_window_scroll_event (GtkWidget *widget,
+ GdkEventScroll *event);
static void gtk_scrolled_window_add (GtkContainer *container,
GtkWidget *widget);
static void gtk_scrolled_window_remove (GtkContainer *container,
@@ -108,7 +110,6 @@ static void gtk_scrolled_window_relative_allocation(GtkWidget *widg
static void gtk_scrolled_window_adjustment_changed (GtkAdjustment *adjustment,
gpointer data);
-
static GtkContainerClass *parent_class = NULL;
@@ -180,6 +181,7 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class)
widget_class->draw = gtk_scrolled_window_draw;
widget_class->size_request = gtk_scrolled_window_size_request;
widget_class->size_allocate = gtk_scrolled_window_size_allocate;
+ widget_class->scroll_event = gtk_scrolled_window_scroll_event;
container_class->add = gtk_scrolled_window_add;
container_class->remove = gtk_scrolled_window_remove;
@@ -270,6 +272,7 @@ gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window)
scrolled_window->hscrollbar_visible = FALSE;
scrolled_window->vscrollbar_visible = FALSE;
scrolled_window->window_placement = GTK_CORNER_TOP_LEFT;
+
}
GtkWidget*
@@ -848,6 +851,39 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
gtk_widget_hide (scrolled_window->vscrollbar);
}
+static gint
+gtk_scrolled_window_scroll_event (GtkWidget *widget,
+ GdkEventScroll *event)
+{
+ GtkWidget *range;
+
+ g_return_val_if_fail (widget != NULL, FALSE);
+ g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (widget), FALSE);
+ g_return_val_if_fail (event != NULL, FALSE);
+
+ if (event->direction == GDK_SCROLL_UP || event->direction == GDK_SCROLL_DOWN)
+ range = GTK_SCROLLED_WINDOW (widget)->vscrollbar;
+ else
+ range = GTK_SCROLLED_WINDOW (widget)->hscrollbar;
+
+ if (range && GTK_WIDGET_VISIBLE (range))
+ {
+ GtkAdjustment *adj = GTK_RANGE (range)->adjustment;
+ gfloat new_value;
+
+ if (event->direction == GDK_SCROLL_UP || event->direction == GDK_SCROLL_LEFT)
+ new_value = adj->value - adj->page_increment / 2;
+ else
+ new_value = adj->value + adj->page_increment / 2;
+
+ new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
+ gtk_adjustment_set_value (adj, new_value);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
static void
gtk_scrolled_window_adjustment_changed (GtkAdjustment *adjustment,