summaryrefslogtreecommitdiff
path: root/gtk/gtkrange.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/gtkrange.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 'gtk/gtkrange.c')
-rw-r--r--gtk/gtkrange.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index a01f72edf..c7ad58ab1 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -73,6 +73,8 @@ static gint gtk_range_focus_in (GtkWidget *widget,
GdkEventFocus *event);
static gint gtk_range_focus_out (GtkWidget *widget,
GdkEventFocus *event);
+static gint gtk_range_scroll_event (GtkWidget *widget,
+ GdkEventScroll *event);
static void gtk_range_style_set (GtkWidget *widget,
GtkStyle *previous_style);
@@ -153,6 +155,7 @@ gtk_range_class_init (GtkRangeClass *class)
widget_class->button_press_event = gtk_range_button_press;
widget_class->button_release_event = gtk_range_button_release;
widget_class->motion_notify_event = gtk_range_motion_notify;
+ widget_class->scroll_event = gtk_range_scroll_event;
widget_class->key_press_event = gtk_range_key_press;
widget_class->enter_notify_event = gtk_range_enter_notify;
widget_class->leave_notify_event = gtk_range_leave_notify;
@@ -979,6 +982,30 @@ gtk_range_button_release (GtkWidget *widget,
}
static gint
+gtk_range_scroll_event (GtkWidget *widget,
+ GdkEventScroll *event)
+{
+ GtkRange *range;
+
+ g_return_val_if_fail (widget != NULL, FALSE);
+ g_return_val_if_fail (GTK_IS_RANGE (widget), FALSE);
+ g_return_val_if_fail (event != NULL, FALSE);
+
+ range = GTK_RANGE (widget);
+
+ if (GTK_WIDGET_VISIBLE (range)) {
+ GtkAdjustment *adj = GTK_RANGE (range)->adjustment;
+ 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 FALSE;
+}
+
+static gint
gtk_range_motion_notify (GtkWidget *widget,
GdkEventMotion *event)
{