keyboard: Switch repeat rate/speed to be a fraction
Instead of settings the absolute value of the repeat rate in msecs through the scale, we set the number of chars per sec, and use GSettings' bindings functions to transform those a timeout. https://bugzilla.gnome.org/show_bug.cgi?id=569612
This commit is contained in:
parent
53d4020c8e
commit
84eed6b0cf
2 changed files with 34 additions and 10 deletions
|
@ -815,13 +815,6 @@
|
|||
<action-widget response="0">button1</action-widget>
|
||||
</action-widgets>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="repeat_speed_adjustment">
|
||||
<property name="lower">10</property>
|
||||
<property name="upper">110</property>
|
||||
<property name="value">30</property>
|
||||
<property name="step_increment">10</property>
|
||||
<property name="page_increment">10</property>
|
||||
</object>
|
||||
<object class="GtkSizeGroup" id="lower_sizegroup">
|
||||
<widgets>
|
||||
<widget name="delay_short_label"/>
|
||||
|
@ -836,6 +829,13 @@
|
|||
<property name="step_increment">10</property>
|
||||
<property name="page_increment">10</property>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="repeat_speed_adjustment">
|
||||
<property name="lower">0.5</property>
|
||||
<property name="upper">50</property>
|
||||
<property name="value">33.3</property>
|
||||
<property name="step_increment">1</property>
|
||||
<property name="page_increment">1</property>
|
||||
</object>
|
||||
<object class="GtkSizeGroup" id="sliders_sizegroup">
|
||||
<widgets>
|
||||
<widget name="cursor_blink_time_scale"/>
|
||||
|
|
|
@ -24,6 +24,29 @@
|
|||
static GSettings *keyboard_settings = NULL;
|
||||
static GSettings *interface_settings = NULL;
|
||||
|
||||
static gboolean
|
||||
get_rate (GValue *value,
|
||||
GVariant *variant,
|
||||
gpointer user_data)
|
||||
{
|
||||
int rate;
|
||||
|
||||
rate = g_variant_get_int32 (variant);
|
||||
g_value_set_double (value, 1 / (gdouble) rate / 1000);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GVariant *
|
||||
set_rate (const GValue *value,
|
||||
const GVariantType *expected_type,
|
||||
gpointer user_data)
|
||||
{
|
||||
gdouble rate;
|
||||
|
||||
rate = g_value_get_double (value);
|
||||
return g_variant_new_int32 ((1 / rate) * 1000);
|
||||
}
|
||||
|
||||
void
|
||||
keyboard_general_init (CcPanel *panel, GtkBuilder *builder)
|
||||
{
|
||||
|
@ -39,9 +62,10 @@ keyboard_general_init (CcPanel *panel, GtkBuilder *builder)
|
|||
g_settings_bind (keyboard_settings, "delay",
|
||||
gtk_range_get_adjustment (GTK_RANGE (gtk_builder_get_object (builder, "repeat_delay_scale"))), "value",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
g_settings_bind (keyboard_settings, "rate",
|
||||
gtk_range_get_adjustment (GTK_RANGE (gtk_builder_get_object (builder, "repeat_speed_scale"))), "value",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
g_settings_bind_with_mapping (keyboard_settings, "rate",
|
||||
gtk_range_get_adjustment (GTK_RANGE (gtk_builder_get_object (builder, "repeat_speed_scale"))), "value",
|
||||
G_SETTINGS_BIND_DEFAULT,
|
||||
get_rate, set_rate, NULL, NULL);
|
||||
|
||||
g_settings_bind (interface_settings, "cursor-blink",
|
||||
gtk_builder_get_object (builder, "cursor_toggle"), "active",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue