[gnome-control-center] universal-access: implement main keyboard settings



commit 0171c05880070eefc19cf2f660a0a3b08a25d008
Author: Thomas Wood <thomas wood intel com>
Date:   Wed May 26 12:42:15 2010 +0100

    universal-access: implement main keyboard settings
    
    Connect the main keyboard settings to the corresponding gconf keys.

 panels/universal-access/cc-ua-panel.c |  160 ++++++++++++++++++++++++++++++++-
 panels/universal-access/uap.ui        |   21 +++--
 2 files changed, 170 insertions(+), 11 deletions(-)
---
diff --git a/panels/universal-access/cc-ua-panel.c b/panels/universal-access/cc-ua-panel.c
index 16edc5b..43de9d9 100644
--- a/panels/universal-access/cc-ua-panel.c
+++ b/panels/universal-access/cc-ua-panel.c
@@ -21,6 +21,19 @@
 
 #include "cc-ua-panel.h"
 
+#include <gconf/gconf-client.h>
+
+#include "gconf-property-editor.h"
+
+
+#define CONFIG_ROOT "/desktop/gnome/accessibility"
+
+#define KEY_CONFIG_ROOT CONFIG_ROOT "/keyboard"
+#define MOUSE_CONFIG_ROOT CONFIG_ROOT "/mouse"
+
+#define WID(b, w) (GtkWidget *) gtk_builder_get_object (b, w)
+
+
 G_DEFINE_DYNAMIC_TYPE (CcUaPanel, cc_ua_panel, CC_TYPE_PANEL)
 
 #define UA_PANEL_PRIVATE(o) \
@@ -29,6 +42,7 @@ G_DEFINE_DYNAMIC_TYPE (CcUaPanel, cc_ua_panel, CC_TYPE_PANEL)
 struct _CcUaPanelPrivate
 {
   GtkBuilder *builder;
+  GConfClient *client;
 };
 
 
@@ -62,11 +76,19 @@ static void
 cc_ua_panel_dispose (GObject *object)
 {
   CcUaPanelPrivate *priv = CC_UA_PANEL (object)->priv;
+
   if (priv->builder)
     {
       g_object_unref (priv->builder);
       priv->builder = NULL;
     }
+
+  if (priv->client)
+    {
+      g_object_unref (priv->client);
+      priv->client = NULL;
+    }
+
   G_OBJECT_CLASS (cc_ua_panel_parent_class)->dispose (object);
 }
 
@@ -95,6 +117,134 @@ cc_ua_panel_class_finalize (CcUaPanelClass *klass)
 }
 
 static void
+cc_ua_panel_stick_keys_toggled (GtkToggleButton *button,
+                                CcUaPanel       *panel)
+{
+  GtkWidget *w;
+  gboolean enabled;
+
+  enabled = gtk_toggle_button_get_active (button);
+
+  w = WID (panel->priv->builder,
+           "typing_sticky_keys_disable_two_keys_checkbutton");
+  gtk_widget_set_sensitive (w, enabled);
+
+  w = WID (panel->priv->builder,
+           "typing_sticky_keys_beep_modifier_checkbutton");
+  gtk_widget_set_sensitive (w, enabled);
+}
+
+static void
+cc_ua_panel_slow_keys_toggled (GtkToggleButton *button,
+                               CcUaPanel       *panel)
+{
+  GtkWidget *w;
+  gboolean enabled;
+
+  enabled = gtk_toggle_button_get_active (button);
+
+  w = WID (panel->priv->builder, "typing_slowkeys_delay_box");
+  gtk_widget_set_sensitive (w, enabled);
+
+  w = WID (panel->priv->builder, "typing_slow_keys_beeb_box");
+  gtk_widget_set_sensitive (w, enabled);
+}
+
+static void
+cc_ua_panel_bounce_keys_toggled (GtkToggleButton *button,
+                                 CcUaPanel       *panel)
+{
+  GtkWidget *w;
+  gboolean enabled;
+
+  enabled = gtk_toggle_button_get_active (button);
+
+  w = WID (panel->priv->builder, "typing_bouncekeys_delay_box");
+  gtk_widget_set_sensitive (w, enabled);
+
+  w = WID (panel->priv->builder,
+           "typing_bounce_keys_beep_rejected_checkbutton");
+  gtk_widget_set_sensitive (w, enabled);
+}
+
+static void
+cc_ua_panel_init_keyboard (CcUaPanel *self)
+{
+  CcUaPanelPrivate *priv = self->priv;
+  GConfChangeSet *changeset = NULL;
+  GtkWidget *w;
+
+
+  /* enable shortcuts */
+  w = WID (priv->builder, "typing_keyboard_toggle_checkbox");
+  gconf_peditor_new_boolean (changeset, KEY_CONFIG_ROOT "/enable", w, NULL);
+
+  /* sticky keys */
+  w = WID (priv->builder, "typing_sticky_keys_on_radiobutton");
+  gconf_peditor_new_boolean (changeset, KEY_CONFIG_ROOT "/stickeykeys_enable",
+                             w, NULL);
+  g_signal_connect (w, "toggled", G_CALLBACK (cc_ua_panel_stick_keys_toggled),
+                    self);
+
+  w = WID (priv->builder, "typing_sticky_keys_disable_two_keys_checkbutton");
+  gconf_peditor_new_boolean (changeset,
+                             KEY_CONFIG_ROOT "/stickykeys_two_key_off", w,
+                             NULL);
+
+  w = WID (priv->builder, "typing_sticky_keys_beep_modifier_checkbutton");
+  gconf_peditor_new_boolean (changeset,
+                             KEY_CONFIG_ROOT "/stickykeys_modifier_beep", w,
+                             NULL);
+
+  /* slow keys */
+  w = WID (priv->builder, "typing_slow_keys_on_radiobutton");
+  gconf_peditor_new_boolean (changeset, KEY_CONFIG_ROOT "/slowkeys_enable", w,
+                             NULL);
+  g_signal_connect (w, "toggled", G_CALLBACK (cc_ua_panel_slow_keys_toggled),
+                    self);
+
+  w = WID (priv->builder, "typing_slowkeys_delay_scale");
+  gconf_peditor_new_numeric_range (changeset, KEY_CONFIG_ROOT "/slowkeys_delay",
+                                   w, NULL);
+
+  w = WID (priv->builder, "typing_slow_keys_beep_pressed_checkbutton");
+  gconf_peditor_new_boolean (changeset, KEY_CONFIG_ROOT "/slowkeys_beep_press",
+                             w, NULL);
+
+  w = WID (priv->builder, "typing_slow_keys_beep_accepted_checkbutton");
+  gconf_peditor_new_boolean (changeset, KEY_CONFIG_ROOT "/slowkeys_beep_accept",
+                             w, NULL);
+
+  w = WID (priv->builder, "typing_slow_keys_beep_rejected_checkbutton");
+  gconf_peditor_new_boolean (changeset, KEY_CONFIG_ROOT "/slowkeys_beep_reject",
+                             w, NULL);
+
+  /* bounce keys */
+  w = WID (priv->builder, "typing_bounce_keys_on_radiobutton");
+  gconf_peditor_new_boolean (changeset, KEY_CONFIG_ROOT "/bouncekeys_enable",
+                             w, NULL);
+  g_signal_connect (w, "toggled", G_CALLBACK (cc_ua_panel_bounce_keys_toggled),
+                    self);
+
+  w = WID (priv->builder, "typing_bouncekeys_delay_scale");
+  gconf_peditor_new_numeric_range (changeset,
+                                   KEY_CONFIG_ROOT "/bouncekeys_delay", w,
+                                   NULL);
+
+  w = WID (priv->builder, "typing_bounce_keys_beep_rejected_checkbutton");
+  gconf_peditor_new_boolean (changeset,
+                             KEY_CONFIG_ROOT "/bouncekeys_beep_reject", w,
+                             NULL);
+
+
+}
+
+static void
+cc_ua_panel_init_mouse (CcUaPanel *self)
+{
+}
+
+static void
 cc_ua_panel_init (CcUaPanel *self)
 {
   CcUaPanelPrivate *priv;
@@ -103,7 +253,8 @@ cc_ua_panel_init (CcUaPanel *self)
   gchar *objects[] = { "universal_access_box", "contrast_model",
                        "text_size_model", "slowkeys_delay_adjustment",
                        "bouncekeys_delay_adjustment", "click_delay_adjustment",
-                       "dwell_time_adjustment", "dwell_threshold_adjustment" };
+                       "dwell_time_adjustment", "dwell_threshold_adjustment",
+                       "NULL" };
 
   priv = self->priv = UA_PANEL_PRIVATE (self);
 
@@ -125,6 +276,13 @@ cc_ua_panel_init (CcUaPanel *self)
       return;
     }
 
+  priv->client = gconf_client_get_default ();
+
+  gconf_client_add_dir (priv->client, CONFIG_ROOT,
+                        GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+
+  cc_ua_panel_init_keyboard (self);
+
   widget = (GtkWidget*) gtk_builder_get_object (priv->builder,
                                                 "universal_access_box");
 
diff --git a/panels/universal-access/uap.ui b/panels/universal-access/uap.ui
index 93e1f12..d88cde1 100644
--- a/panels/universal-access/uap.ui
+++ b/panels/universal-access/uap.ui
@@ -233,9 +233,7 @@
                                                     <property name="active">0</property>
                                                     <child>
                                                       <object class="GtkCellRendererText" id="contrast_renderer">
-                                                        <property name="background_gdk">#000000000000</property>
                                                         <property name="font">Normal</property>
-                                                        <property name="foreground_gdk">#000000000000</property>
                                                       </object>
                                                       <attributes>
                                                         <attribute name="scale">1</attribute>
@@ -1234,7 +1232,7 @@
                                             <property name="visible">True</property>
                                             <property name="spacing">6</property>
                                             <child>
-                                              <object class="GtkRadioButton" id="typing_sticky_keys_on_radiobutton1">
+                                              <object class="GtkRadioButton" id="typing_assistant_on_radiobutton1">
                                                 <property name="label" translatable="yes">On</property>
                                                 <property name="visible">True</property>
                                                 <property name="can_focus">True</property>
@@ -1248,13 +1246,13 @@
                                               </packing>
                                             </child>
                                             <child>
-                                              <object class="GtkRadioButton" id="typing_sticky_keys_off_radiobutton1">
+                                              <object class="GtkRadioButton" id="typing_assistant_off_radiobutton1">
                                                 <property name="label" translatable="yes">Off</property>
                                                 <property name="visible">True</property>
                                                 <property name="can_focus">True</property>
                                                 <property name="receives_default">False</property>
                                                 <property name="draw_indicator">True</property>
-                                                <property name="group">typing_sticky_keys_on_radiobutton</property>
+                                                <property name="group">typing_assistant_on_radiobutton1</property>
                                               </object>
                                               <packing>
                                                 <property name="expand">False</property>
@@ -1347,7 +1345,6 @@
                                                     <property name="visible">True</property>
                                                     <property name="can_focus">True</property>
                                                     <property name="receives_default">False</property>
-                                                    <property name="active">True</property>
                                                     <property name="draw_indicator">True</property>
                                                   </object>
                                                   <packing>
@@ -1361,6 +1358,7 @@
                                                     <property name="visible">True</property>
                                                     <property name="can_focus">True</property>
                                                     <property name="receives_default">False</property>
+                                                    <property name="active">True</property>
                                                     <property name="draw_indicator">True</property>
                                                     <property name="group">typing_sticky_keys_on_radiobutton</property>
                                                   </object>
@@ -1395,6 +1393,7 @@
                                           <object class="GtkCheckButton" id="typing_sticky_keys_disable_two_keys_checkbutton">
                                             <property name="label" translatable="yes">Disable if two keys are pressed together</property>
                                             <property name="visible">True</property>
+                                            <property name="sensitive">False</property>
                                             <property name="can_focus">True</property>
                                             <property name="receives_default">False</property>
                                             <property name="draw_indicator">True</property>
@@ -1408,6 +1407,7 @@
                                           <object class="GtkCheckButton" id="typing_sticky_keys_beep_modifier_checkbutton">
                                             <property name="label" translatable="yes">Beep when a modifer key is pressed</property>
                                             <property name="visible">True</property>
+                                            <property name="sensitive">False</property>
                                             <property name="can_focus">True</property>
                                             <property name="receives_default">False</property>
                                             <property name="draw_indicator">True</property>
@@ -1465,7 +1465,6 @@
                                                     <property name="visible">True</property>
                                                     <property name="can_focus">True</property>
                                                     <property name="receives_default">False</property>
-                                                    <property name="active">True</property>
                                                     <property name="draw_indicator">True</property>
                                                   </object>
                                                   <packing>
@@ -1479,6 +1478,7 @@
                                                     <property name="visible">True</property>
                                                     <property name="can_focus">True</property>
                                                     <property name="receives_default">False</property>
+                                                    <property name="active">True</property>
                                                     <property name="draw_indicator">True</property>
                                                     <property name="group">typing_slow_keys_on_radiobutton</property>
                                                   </object>
@@ -1594,8 +1594,9 @@
                                           </packing>
                                         </child>
                                         <child>
-                                          <object class="GtkHBox" id="hbox1">
+                                          <object class="GtkHBox" id="typing_slow_keys_beeb_box">
                                             <property name="visible">True</property>
+                                            <property name="sensitive">False</property>
                                             <property name="spacing">6</property>
                                             <child>
                                               <object class="GtkLabel" id="label26">
@@ -1702,7 +1703,6 @@
                                                     <property name="visible">True</property>
                                                     <property name="can_focus">True</property>
                                                     <property name="receives_default">False</property>
-                                                    <property name="active">True</property>
                                                     <property name="draw_indicator">True</property>
                                                   </object>
                                                   <packing>
@@ -1716,6 +1716,7 @@
                                                     <property name="visible">True</property>
                                                     <property name="can_focus">True</property>
                                                     <property name="receives_default">False</property>
+                                                    <property name="active">True</property>
                                                     <property name="draw_indicator">True</property>
                                                     <property name="group">typing_bounce_keys_on_radiobutton</property>
                                                   </object>
@@ -1833,6 +1834,7 @@
                                           <object class="GtkCheckButton" id="typing_bounce_keys_beep_rejected_checkbutton">
                                             <property name="label" translatable="yes">Beep when a key is rejected</property>
                                             <property name="visible">True</property>
+                                            <property name="sensitive">False</property>
                                             <property name="can_focus">True</property>
                                             <property name="receives_default">False</property>
                                             <property name="draw_indicator">True</property>
@@ -2719,7 +2721,6 @@
       <widget name="seeing_text_size_box"/>
       <widget name="seeing_zoom_enabled_box"/>
       <widget name="seeing_reader_enabled_box"/>
-      <widget name="seeing_braille_enabled_box"/>
     </widgets>
   </object>
   <object class="GtkListStore" id="contrast_model">



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