diff options
author | Michael Natterer <mitch@imendio.com> | 2005-11-22 12:40:15 +0000 |
---|---|---|
committer | Michael Natterer <mitch@src.gnome.org> | 2005-11-22 12:40:15 +0000 |
commit | dfa4870b74be2ade513ffda504cd4fdfede19bb3 (patch) | |
tree | 7d61b49610f0e32e36c7b9476fca4cc4f5299a20 /gtk/gtkrange.c | |
parent | 1097260aa7ed40e508e181feed4d736727268eb5 (diff) | |
download | gtk+-dfa4870b74be2ade513ffda504cd4fdfede19bb3.tar.gz |
Made button-press timeouts which work like key repeat timeouts
2005-11-22 Michael Natterer <mitch@imendio.com>
Made button-press timeouts which work like key repeat timeouts
configurable. Addresses bug #142582:
* gtk/gtksettings.c: added properties "gtk-timeout-initial" and
"gtk-timeout-repeat" which defalt to 200/20 (ms).
Use the values from GtkSettings instead of hardcoding them
(the repeat value is either taken as-is for fast repeat or
multiplied by 5 for slow repeat). Changed all places to use these
two standard initial/repeat timings:
* gtk/gtkcalendar.c (unchanged 200/20)
* gtk/gtknotebook.c (unchanged 200/100)
* gtk/gtkpathbar.c (changed from 300/150 to 200/100)
* gtk/gtkrange.c (changed from 250/100 to 200/100)
* gtk/gtkspinbutton.c (unchanged 200/20)
Diffstat (limited to 'gtk/gtkrange.c')
-rw-r--r-- | gtk/gtkrange.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index f9c62932a5..f8e409899b 100644 --- a/gtk/gtkrange.c +++ b/gtk/gtkrange.c @@ -37,9 +37,8 @@ #include "gtkprivate.h" #include "gtkalias.h" -#define SCROLL_INITIAL_DELAY 250 /* must hold button this long before ... */ -#define SCROLL_LATER_DELAY 100 /* ... it starts repeating at this rate */ -#define UPDATE_DELAY 300 /* Delay for queued update */ +#define SCROLL_DELAY_FACTOR 5 /* Scroll repeat multiplier */ +#define UPDATE_DELAY 300 /* Delay for queued update */ enum { PROP_0, @@ -2693,14 +2692,18 @@ second_timeout (gpointer data) static gboolean initial_timeout (gpointer data) { - GtkRange *range; + GtkRange *range; + GtkSettings *settings; + guint timeout; GDK_THREADS_ENTER (); + settings = gtk_widget_get_settings (GTK_WIDGET (data)); + g_object_get (settings, "gtk-timeout-repeat", &timeout, NULL); + range = GTK_RANGE (data); - range->timer->timeout_id = - g_timeout_add (SCROLL_LATER_DELAY, - second_timeout, - range); + range->timer->timeout_id = g_timeout_add (timeout * SCROLL_DELAY_FACTOR, + second_timeout, + range); GDK_THREADS_LEAVE (); /* remove self */ @@ -2711,15 +2714,20 @@ static void gtk_range_add_step_timer (GtkRange *range, GtkScrollType step) { + GtkSettings *settings; + guint timeout; + g_return_if_fail (range->timer == NULL); g_return_if_fail (step != GTK_SCROLL_NONE); - + + settings = gtk_widget_get_settings (GTK_WIDGET (range)); + g_object_get (settings, "gtk-timeout-initial", &timeout, NULL); + range->timer = g_new (GtkRangeStepTimer, 1); - range->timer->timeout_id = - g_timeout_add (SCROLL_INITIAL_DELAY, - initial_timeout, - range); + range->timer->timeout_id = g_timeout_add (timeout, + initial_timeout, + range); range->timer->step = step; gtk_range_scroll (range, range->timer->step); |