summaryrefslogtreecommitdiff
path: root/tests/testgtk.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 /tests/testgtk.c
parentab1deac87fa395332b73daf8e2e4c893e23be3e4 (diff)
downloadgdk-pixbuf-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 'tests/testgtk.c')
-rw-r--r--tests/testgtk.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/tests/testgtk.c b/tests/testgtk.c
index c004a077f..5331dea4d 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -7609,6 +7609,19 @@ scroll_test_expose (GtkWidget *widget, GdkEventExpose *event,
return TRUE;
}
+static gint
+scroll_test_scroll (GtkWidget *widget, GdkEventScroll *event,
+ GtkAdjustment *adj)
+{
+ gfloat new_value = adj->value + ((event->direction == GDK_SCROLL_UP) ?
+ -adj->page_increment / 2:
+ 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;
+}
+
static void
scroll_test_configure (GtkWidget *widget, GdkEventConfigure *event,
GtkAdjustment *adj)
@@ -7728,7 +7741,7 @@ create_scroll_test (void)
gtk_box_pack_start (GTK_BOX (hbox), drawing_area, TRUE, TRUE, 0);
gtk_widget_show (drawing_area);
- gtk_widget_set_events (drawing_area, GDK_EXPOSURE_MASK);
+ gtk_widget_set_events (drawing_area, GDK_EXPOSURE_MASK | GDK_SCROLL_MASK);
adj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 1000.0, 1.0, 180.0, 200.0));
scroll_test_pos = 0.0;
@@ -7741,7 +7754,8 @@ create_scroll_test (void)
GTK_SIGNAL_FUNC (scroll_test_expose), adj);
gtk_signal_connect (GTK_OBJECT (drawing_area), "configure_event",
GTK_SIGNAL_FUNC (scroll_test_configure), adj);
-
+ gtk_signal_connect (GTK_OBJECT (drawing_area), "scroll_event",
+ GTK_SIGNAL_FUNC (scroll_test_scroll), adj);
gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
GTK_SIGNAL_FUNC (scroll_test_adjustment_changed),