[gnome-control-center] keyboard: Set repeat-interval correctly



commit 6dd3318b8037ff700cc4384941db9dff39f5d3c4
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Mar 30 18:17:50 2011 +0100

    keyboard: Set repeat-interval correctly
    
    This sets the repeat-interval key in milliseconds. From a minimum of
    one char per 2 seconds up to 50 characters per second (as per
    requirements listed in 84eed6b0cf9f0b44db5a030018bfca17dae18fd5).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=646241

 panels/keyboard/keyboard-general.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/panels/keyboard/keyboard-general.c b/panels/keyboard/keyboard-general.c
index 1cef542..b1d45d1 100644
--- a/panels/keyboard/keyboard-general.c
+++ b/panels/keyboard/keyboard-general.c
@@ -30,9 +30,12 @@ get_rate (GValue   *value,
           gpointer  user_data)
 {
   int rate;
+  gdouble fraction;
 
-  rate = g_variant_get_int32 (variant);
-  g_value_set_double (value, 1 / (gdouble) rate / 1000);
+  rate = g_variant_get_uint32 (variant);
+  fraction = 1.0 / ((gdouble) rate / 1000.0);
+  g_value_set_double (value, fraction);
+  g_debug ("Getting fraction %f for msecs %d", fraction, rate);
   return TRUE;
 }
 
@@ -42,9 +45,12 @@ set_rate (const GValue       *value,
           gpointer            user_data)
 {
   gdouble rate;
+  int msecs;
 
   rate = g_value_get_double (value);
-  return g_variant_new_int32 ((1 / rate) * 1000);
+  msecs = (1 / rate) * 1000;
+  g_debug ("Setting repeat rate to %d", msecs);
+  return g_variant_new_uint32 (msecs);
 }
 
 void
@@ -66,7 +72,7 @@ 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_with_mapping (keyboard_settings, "rate",
+  g_settings_bind_with_mapping (keyboard_settings, "repeat-interval",
                                 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);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]