summaryrefslogtreecommitdiff
path: root/gtk/gtkrange.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2001-02-19 20:06:37 +0000
committerHavoc Pennington <hp@src.gnome.org>2001-02-19 20:06:37 +0000
commit3a99bdf5a75710f1f4cdaf0539fc4290fc862545 (patch)
tree631a9c1deca5877948ebbcb4235a2729c973c338 /gtk/gtkrange.c
parentba46da61a70df8d3471063204e0d51a308a1747c (diff)
downloadgdk-pixbuf-3a99bdf5a75710f1f4cdaf0539fc4290fc862545.tar.gz
use the visual scroll steps.
2001-02-16 Havoc Pennington <hp@redhat.com> * gtk/gtkvscrollbar.c (gtk_vscrollbar_trough_keys): use the visual scroll steps. * gtk/gtkvscale.c (gtk_vscale_trough_keys): use the visual scroll steps, and add Ctrl-arrow shortcuts for paging visually as with HScale, since Page Up and Page Down move logically. * gtk/gtkenums.h (GtkScrollType): add GTK_SCROLL_STEP_UP, GTK_SCROLL_STEP_DOWN, etc. for visual scroll directions * gtk/gtkrange.c (gtk_range_key_press): handle the visual scroll steps (gtk_range_scroll): handle the visual steps * gtk/gtklist.c (gtk_list_scroll_horizontal): handle the up/down scroll steps * gtk/gtkhscale.c (gtk_hscale_trough_keys): use the visual scroll steps, not the logical ones. * gtk/gtkclist.c (move_focus_row): handle the up/down scroll steps (scroll_vertical): handle up/down steps
Diffstat (limited to 'gtk/gtkrange.c')
-rw-r--r--gtk/gtkrange.c116
1 files changed, 112 insertions, 4 deletions
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index 66c3bbf96..0f22f1e74 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -1116,7 +1116,7 @@ gtk_range_key_press (GtkWidget *widget,
range = GTK_RANGE (widget);
return_val = FALSE;
-
+
if (RANGE_CLASS (range)->trough_keys)
return_val = (* RANGE_CLASS (range)->trough_keys) (range, event, &scroll, &pos);
@@ -1125,15 +1125,45 @@ gtk_range_key_press (GtkWidget *widget,
if (scroll != GTK_SCROLL_NONE)
{
range->scroll_type = scroll;
+
gtk_range_scroll (range, -1);
if (range->old_value != range->adjustment->value)
{
gtk_signal_emit_by_name (GTK_OBJECT (range->adjustment), "value_changed");
switch (range->scroll_type)
{
+ case GTK_SCROLL_STEP_LEFT:
+ if (should_invert (range, TRUE))
+ gtk_range_draw_step_forw (range);
+ else
+ gtk_range_draw_step_back (range);
+ break;
+
+ case GTK_SCROLL_STEP_UP:
+ if (should_invert (range, FALSE))
+ gtk_range_draw_step_forw (range);
+ else
+ gtk_range_draw_step_back (range);
+ break;
+
+ case GTK_SCROLL_STEP_RIGHT:
+ if (should_invert (range, TRUE))
+ gtk_range_draw_step_back (range);
+ else
+ gtk_range_draw_step_forw (range);
+ break;
+
+ case GTK_SCROLL_STEP_DOWN:
+ if (should_invert (range, FALSE))
+ gtk_range_draw_step_back (range);
+ else
+ gtk_range_draw_step_forw (range);
+ break;
+
case GTK_SCROLL_STEP_BACKWARD:
gtk_range_draw_step_back (range);
break;
+
case GTK_SCROLL_STEP_FORWARD:
gtk_range_draw_step_forw (range);
break;
@@ -1374,13 +1404,79 @@ gtk_range_scroll (GtkRange *range,
{
gfloat new_value;
gint return_val;
-
+ GtkScrollType scroll_type;
+
g_return_val_if_fail (GTK_IS_RANGE (range), FALSE);
new_value = range->adjustment->value;
return_val = TRUE;
- switch (range->scroll_type)
+ /* Translate visual to logical */
+
+ scroll_type = range->scroll_type;
+ switch (scroll_type)
+ {
+ case GTK_SCROLL_STEP_UP:
+ if (should_invert (range, FALSE))
+ scroll_type = GTK_SCROLL_STEP_FORWARD;
+ else
+ scroll_type = GTK_SCROLL_STEP_BACKWARD;
+ break;
+
+ case GTK_SCROLL_STEP_DOWN:
+ if (should_invert (range, FALSE))
+ scroll_type = GTK_SCROLL_STEP_BACKWARD;
+ else
+ scroll_type = GTK_SCROLL_STEP_FORWARD;
+ break;
+
+ case GTK_SCROLL_PAGE_UP:
+ if (should_invert (range, FALSE))
+ scroll_type = GTK_SCROLL_PAGE_FORWARD;
+ else
+ scroll_type = GTK_SCROLL_PAGE_BACKWARD;
+ break;
+
+ case GTK_SCROLL_PAGE_DOWN:
+ if (should_invert (range, FALSE))
+ scroll_type = GTK_SCROLL_PAGE_BACKWARD;
+ else
+ scroll_type = GTK_SCROLL_PAGE_FORWARD;
+ break;
+
+ case GTK_SCROLL_STEP_LEFT:
+ if (should_invert (range, TRUE))
+ scroll_type = GTK_SCROLL_STEP_FORWARD;
+ else
+ scroll_type = GTK_SCROLL_STEP_BACKWARD;
+ break;
+
+ case GTK_SCROLL_STEP_RIGHT:
+ if (should_invert (range, TRUE))
+ scroll_type = GTK_SCROLL_STEP_BACKWARD;
+ else
+ scroll_type = GTK_SCROLL_STEP_FORWARD;
+ break;
+
+ case GTK_SCROLL_PAGE_LEFT:
+ if (should_invert (range, TRUE))
+ scroll_type = GTK_SCROLL_PAGE_FORWARD;
+ else
+ scroll_type = GTK_SCROLL_PAGE_BACKWARD;
+ break;
+
+ case GTK_SCROLL_PAGE_RIGHT:
+ if (should_invert (range, TRUE))
+ scroll_type = GTK_SCROLL_PAGE_BACKWARD;
+ else
+ scroll_type = GTK_SCROLL_PAGE_FORWARD;
+ break;
+
+ default:
+ break;
+ }
+
+ switch (scroll_type)
{
case GTK_SCROLL_NONE:
break;
@@ -1433,8 +1529,20 @@ gtk_range_scroll (GtkRange *range,
range->timer = 0;
}
break;
- }
+ case GTK_SCROLL_STEP_UP:
+ case GTK_SCROLL_STEP_DOWN:
+ case GTK_SCROLL_PAGE_UP:
+ case GTK_SCROLL_PAGE_DOWN:
+ case GTK_SCROLL_STEP_LEFT:
+ case GTK_SCROLL_STEP_RIGHT:
+ case GTK_SCROLL_PAGE_LEFT:
+ case GTK_SCROLL_PAGE_RIGHT:
+ g_assert_not_reached ();
+ break;
+
+ }
+
if (new_value != range->adjustment->value)
{
range->adjustment->value = new_value;