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)
This commit is contained in:
Michael Natterer 2005-11-22 12:40:15 +00:00 committed by Michael Natterer
parent 1097260aa7
commit dfa4870b74
8 changed files with 152 additions and 48 deletions

View File

@ -1,3 +1,22 @@
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)
2005-11-21 Anders Carlsson <andersca@imendio.com>
* configure.in:

View File

@ -1,3 +1,22 @@
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)
2005-11-21 Anders Carlsson <andersca@imendio.com>
* configure.in:

View File

@ -2286,9 +2286,6 @@ gtk_calendar_expose (GtkWidget *widget,
* Mouse handling *
****************************************/
#define CALENDAR_INITIAL_TIMER_DELAY 200
#define CALENDAR_TIMER_DELAY 20
static void
calendar_arrow_action (GtkCalendar *calendar,
guint arrow)
@ -2327,10 +2324,16 @@ calendar_timer (gpointer data)
if (priv->need_timer)
{
GtkSettings *settings;
guint timeout;
settings = gtk_widget_get_settings (GTK_WIDGET (calendar));
g_object_get (settings, "gtk-timeout-repeat", &timeout, NULL);
priv->need_timer = FALSE;
priv->timer = g_timeout_add (CALENDAR_TIMER_DELAY,
(GSourceFunc) calendar_timer,
(gpointer) calendar);
priv->timer = g_timeout_add (timeout,
(GSourceFunc) calendar_timer,
(gpointer) calendar);
}
else
retval = TRUE;
@ -2351,8 +2354,14 @@ calendar_start_spinning (GtkCalendar *calendar,
if (!priv->timer)
{
GtkSettings *settings;
guint timeout;
settings = gtk_widget_get_settings (GTK_WIDGET (calendar));
g_object_get (settings, "gtk-timeout-initial", &timeout, NULL);
priv->need_timer = TRUE;
priv->timer = g_timeout_add (CALENDAR_INITIAL_TIMER_DELAY,
priv->timer = g_timeout_add (timeout,
calendar_timer,
calendar);
}

View File

@ -39,12 +39,11 @@
#include "gtkalias.h"
#define TAB_OVERLAP 2
#define TAB_CURVATURE 1
#define ARROW_SIZE 12
#define ARROW_SPACING 0
#define NOTEBOOK_INIT_SCROLL_DELAY (200)
#define NOTEBOOK_SCROLL_DELAY (100)
#define TAB_OVERLAP 2
#define TAB_CURVATURE 1
#define ARROW_SIZE 12
#define ARROW_SPACING 0
#define SCROLL_DELAY_FACTOR 5
enum {
@ -1715,8 +1714,13 @@ gtk_notebook_arrow_button_press (GtkNotebook *notebook,
if (!notebook->timer)
{
notebook->timer = g_timeout_add (NOTEBOOK_INIT_SCROLL_DELAY,
(GSourceFunc) gtk_notebook_timer,
GtkSettings *settings = gtk_widget_get_settings (widget);
guint timeout;
g_object_get (settings, "gtk-timeout-initial", &timeout, NULL);
notebook->timer = g_timeout_add (timeout,
(GSourceFunc) gtk_notebook_timer,
(gpointer) notebook);
notebook->need_timer = TRUE;
}
@ -2584,11 +2588,17 @@ gtk_notebook_timer (GtkNotebook *notebook)
{
gtk_notebook_do_arrow (notebook, notebook->click_child);
if (notebook->need_timer)
if (notebook->need_timer)
{
GtkSettings *settings;
guint timeout;
settings = gtk_widget_get_settings (GTK_WIDGET (notebook));
g_object_get (settings, "gtk-timeout-repeat", &timeout, NULL);
notebook->need_timer = FALSE;
notebook->timer = g_timeout_add (NOTEBOOK_SCROLL_DELAY,
(GSourceFunc) gtk_notebook_timer,
notebook->timer = g_timeout_add (timeout * SCROLL_DELAY_FACTOR,
(GSourceFunc) gtk_notebook_timer,
(gpointer) notebook);
}
else

View File

@ -48,8 +48,7 @@ typedef enum {
#define BUTTON_DATA(x) ((ButtonData *)(x))
#define SCROLL_TIMEOUT 150
#define INITIAL_SCROLL_TIMEOUT 300
#define SCROLL_DELAY_FACTOR 5
static guint path_bar_signals [LAST_SIGNAL] = { 0 };
@ -745,16 +744,19 @@ gtk_path_bar_scroll_timeout (GtkPathBar *path_bar)
if (path_bar->need_timer)
{
GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (path_bar));
guint timeout;
g_object_get (settings, "gtk-timeout-repeat", &timeout, NULL);
path_bar->need_timer = FALSE;
path_bar->timer = g_timeout_add (SCROLL_TIMEOUT,
path_bar->timer = g_timeout_add (timeout * SCROLL_DELAY_FACTOR,
(GSourceFunc)gtk_path_bar_scroll_timeout,
path_bar);
}
else
retval = TRUE;
}
GDK_THREADS_LEAVE ();
@ -798,8 +800,13 @@ gtk_path_bar_slider_button_press (GtkWidget *widget,
if (!path_bar->timer)
{
GtkSettings *settings = gtk_widget_get_settings (widget);
guint timeout;
g_object_get (settings, "gtk-timeout-initial", &timeout, NULL);
path_bar->need_timer = TRUE;
path_bar->timer = g_timeout_add (INITIAL_SCROLL_TIMEOUT,
path_bar->timer = g_timeout_add (timeout,
(GSourceFunc)gtk_path_bar_scroll_timeout,
path_bar);
}

View File

@ -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);

View File

@ -32,6 +32,9 @@
#include "x11/gdkx.h"
#endif
#define DEFAULT_TIMEOUT_INITIAL 200
#define DEFAULT_TIMEOUT_REPEAT 20
typedef struct _GtkSettingsValuePrivate GtkSettingsValuePrivate;
typedef enum
@ -79,7 +82,9 @@ enum {
#endif
PROP_ALTERNATIVE_BUTTON_ORDER,
PROP_SHOW_INPUT_METHOD_MENU,
PROP_SHOW_UNICODE_MENU
PROP_SHOW_UNICODE_MENU,
PROP_TIMEOUT_INITIAL,
PROP_TIMEOUT_REPEAT
};
@ -406,6 +411,25 @@ gtk_settings_class_init (GtkSettingsClass *class)
NULL);
g_assert (result == PROP_SHOW_UNICODE_MENU);
result = settings_install_property_parser (class,
g_param_spec_int ("gtk-timeout-initial",
P_("Start timeout"),
P_("Starting value for timeouts, when button is pressed"),
0, G_MAXINT, DEFAULT_TIMEOUT_INITIAL,
G_PARAM_READWRITE),
NULL);
g_assert (result == PROP_TIMEOUT_INITIAL);
result = settings_install_property_parser (class,
g_param_spec_int ("gtk-timeout-repeat",
P_("Repeat timeout"),
P_("Repeat value for timeouts, when button is pressed"),
0, G_MAXINT, DEFAULT_TIMEOUT_REPEAT,
G_PARAM_READWRITE),
NULL);
g_assert (result == PROP_TIMEOUT_REPEAT);
}
static void

View File

@ -43,13 +43,11 @@
#include "gtkintl.h"
#include "gtkalias.h"
#define MIN_SPIN_BUTTON_WIDTH 30
#define SPIN_BUTTON_INITIAL_TIMER_DELAY 200
#define SPIN_BUTTON_TIMER_DELAY 20
#define MAX_TIMER_CALLS 5
#define EPSILON 1e-10
#define MAX_DIGITS 20
#define MIN_ARROW_WIDTH 6
#define MIN_SPIN_BUTTON_WIDTH 30
#define MAX_TIMER_CALLS 5
#define EPSILON 1e-10
#define MAX_DIGITS 20
#define MIN_ARROW_WIDTH 6
enum {
PROP_0,
@ -1050,10 +1048,15 @@ start_spinning (GtkSpinButton *spin,
if (!spin->timer)
{
GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (spin));
guint timeout;
g_object_get (settings, "gtk-timeout-initial", &timeout, NULL);
spin->timer_step = step;
spin->need_timer = TRUE;
spin->timer = g_timeout_add (SPIN_BUTTON_INITIAL_TIMER_DELAY,
(GSourceFunc) gtk_spin_button_timer,
spin->timer = g_timeout_add (timeout,
(GSourceFunc) gtk_spin_button_timer,
(gpointer) spin);
}
gtk_spin_button_real_spin (spin, click_child == GTK_ARROW_UP ? step : -step);
@ -1203,8 +1206,13 @@ gtk_spin_button_timer (GtkSpinButton *spin_button)
if (spin_button->need_timer)
{
GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (spin_button));
guint timeout;
g_object_get (settings, "gtk-timeout-repeat", &timeout, NULL);
spin_button->need_timer = FALSE;
spin_button->timer = g_timeout_add (SPIN_BUTTON_TIMER_DELAY,
spin_button->timer = g_timeout_add (timeout,
(GSourceFunc) gtk_spin_button_timer,
(gpointer) spin_button);
}