[gnome-control-center] Revert "Add the input-source-switcher to the shortcuts"



commit 971e6a81ae01db95fc5f7946856e50dd969d9f94
Author: Rui Matos <tiagomatos gmail com>
Date:   Mon Apr 1 20:02:51 2013 +0200

    Revert "Add the input-source-switcher to the shortcuts"
    
    This reverts commit 77b7569c3ddb83db9cb866f7f9d87e6f6d1dd5ad.

 panels/keyboard/cc-keyboard-option.c |  222 ++++++----------------------------
 1 files changed, 40 insertions(+), 182 deletions(-)
---
diff --git a/panels/keyboard/cc-keyboard-option.c b/panels/keyboard/cc-keyboard-option.c
index a8ff9a0..229ceae 100644
--- a/panels/keyboard/cc-keyboard-option.c
+++ b/panels/keyboard/cc-keyboard-option.c
@@ -39,9 +39,6 @@
 #define XKB_OPTION_GROUP_LVL3 "lv3"
 #define XKB_OPTION_GROUP_COMP "Compose key"
 
-#define INPUT_SWITCHER_SCHEMA "org.gnome.settings-daemon.peripherals.keyboard"
-#define INPUT_SWITCHER_KEY "input-sources-switcher"
-
 enum
 {
   PROP_0,
@@ -65,10 +62,6 @@ struct _CcKeyboardOption
   GtkListStore *store;
 
   const gchar * const *whitelist;
-
-  gboolean is_xkb;
-
-  gchar *current_description;
 };
 
 typedef struct _CcKeyboardOptionClass CcKeyboardOptionClass;
@@ -81,7 +74,6 @@ static guint keyboard_option_signals[LAST_SIGNAL] = { 0 };
 
 static GnomeXkbInfo *xkb_info = NULL;
 static GSettings *input_sources_settings = NULL;
-static GSettings *input_switcher_settings = NULL;
 static gchar **current_xkb_options = NULL;
 
 static const gchar *xkb_option_lvl3_whitelist[] = {
@@ -127,9 +119,6 @@ reload_setting (CcKeyboardOption *self)
 {
   gchar **iter;
 
-  if (!self->is_xkb)
-    return;
-
   for (iter = current_xkb_options; *iter; ++iter)
     if (strv_contains (self->whitelist, *iter))
       {
@@ -164,21 +153,6 @@ xkb_options_changed (GSettings *settings,
 }
 
 static void
-input_switcher_changed (GSettings *settings,
-                        gchar     *key,
-                        gpointer   data)
-{
-  CcKeyboardOption *option = data;
-
-  g_free (option->current_value);
-  g_free (option->current_description);
-  option->current_value = g_settings_get_string (settings, key);
-  option->current_description = NULL;
-
-  g_signal_emit (option, keyboard_option_signals[CHANGED_SIGNAL], 0);
-}
-
-static void
 cc_keyboard_option_get_property (GObject    *object,
                                  guint       prop_id,
                                  GValue     *value,
@@ -239,42 +213,11 @@ cc_keyboard_option_finalize (GObject *object)
   g_clear_pointer (&self->group, g_free);
   g_clear_pointer (&self->description, g_free);
   g_clear_pointer (&self->current_value, g_free);
-  g_clear_pointer (&self->current_description, g_free);
   g_clear_object (&self->store);
 
   G_OBJECT_CLASS (cc_keyboard_option_parent_class)->finalize (object);
 }
 
-static struct
-{
-  const gchar *value;
-  const gchar *description;
-} input_switcher_options[] =
-{
-  { "off", N_("Disabled") },
-  { "shift-l", N_("Left Shift") },
-  { "alt-l", N_("Left Alt") },
-  { "ctrl-l", N_("Left Ctrl") },
-  { "shift-r", N_("Right Shift") },
-  { "alt-r", N_("Right Alt") },
-  { "ctrl-r", N_("Right Ctrl") },
-  { "alt-shift-l", N_("Left Alt+Shift") },
-  { "alt-shift-r", N_("Right Alt+Shift") },
-  { "ctrl-shift-l", N_("Left Ctrl+Shift") },
-  { "ctrl-shift-r", N_("Right Ctrl+Shift") },
-  { "shift-l-shift-r", N_("Left+Right Shift") },
-  { "alt-l-alt-r", N_("Left+Right Alt") },
-  { "ctrl-l-ctrl-r", N_("Left+Right Ctrl") },
-  { "alt-shift", N_("Alt+Shift") },
-  { "ctrl-shift", N_("Ctrl+Shift") },
-  { "alt-ctrl", N_("Alt+Ctrl") },
-  { "caps", N_("Caps") },
-  { "shift-caps", N_("Shift+Caps") },
-  { "alt-caps", N_("Alt+Caps") },
-  { "ctrl-caps", N_("Ctrl+Caps") },
-  { NULL, NULL }
-};
-
 static void
 cc_keyboard_option_constructed (GObject *object)
 {
@@ -285,11 +228,7 @@ cc_keyboard_option_constructed (GObject *object)
 
   G_OBJECT_CLASS (cc_keyboard_option_parent_class)->constructed (object);
 
-  self->is_xkb = TRUE;
-
-  if (self->group == NULL)
-    self->is_xkb = FALSE;
-  else if (g_str_equal (self->group, XKB_OPTION_GROUP_LVL3))
+  if (g_str_equal (self->group, XKB_OPTION_GROUP_LVL3))
     self->whitelist = xkb_option_lvl3_whitelist;
   else if (g_str_equal (self->group, XKB_OPTION_GROUP_COMP))
     self->whitelist = xkb_option_comp_whitelist;
@@ -297,41 +236,29 @@ cc_keyboard_option_constructed (GObject *object)
     g_assert_not_reached ();
 
   self->store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
-
-  if (self->is_xkb)
-    {
-      gtk_list_store_insert_with_values (self->store, &iter, -1,
-                                         XKB_OPTION_DESCRIPTION_COLUMN, _("Disabled"),
-                                         XKB_OPTION_ID_COLUMN, NULL,
-                                         -1);
-      options = gnome_xkb_info_get_options_for_group (xkb_info, self->group);
-      for (l = options; l; l = l->next)
-        {
-          option_id = l->data;
-          if (strv_contains (self->whitelist, option_id))
-            {
-              gtk_list_store_insert_with_values (self->store, &iter, -1,
-                                                 XKB_OPTION_DESCRIPTION_COLUMN,
-                                                 gnome_xkb_info_description_for_option (xkb_info, 
self->group, option_id),
-                                                 XKB_OPTION_ID_COLUMN, option_id,
-                                                 -1);
-            }
-        }
-      g_list_free (options);
-
-      reload_setting (self);
-    }
-  else
+  gtk_list_store_append (self->store, &iter);
+  gtk_list_store_set (self->store, &iter,
+                      XKB_OPTION_DESCRIPTION_COLUMN, _("Disabled"),
+                      XKB_OPTION_ID_COLUMN, NULL,
+                      -1);
+  options = gnome_xkb_info_get_options_for_group (xkb_info, self->group);
+  for (l = options; l; l = l->next)
     {
-      gint i;
-      for (i = 0; input_switcher_options[i].value; i++)
+      option_id = l->data;
+      if (strv_contains (self->whitelist, option_id))
         {
-          gtk_list_store_insert_with_values (self->store, NULL, -1,
-                                             XKB_OPTION_DESCRIPTION_COLUMN, 
input_switcher_options[i].description,
-                                             XKB_OPTION_ID_COLUMN, input_switcher_options[i].value,
-                                             -1);
+          gtk_list_store_append (self->store, &iter);
+          gtk_list_store_set (self->store, &iter,
+                              XKB_OPTION_DESCRIPTION_COLUMN,
+                              gnome_xkb_info_description_for_option (xkb_info, self->group, option_id),
+                              XKB_OPTION_ID_COLUMN,
+                              option_id,
+                              -1);
         }
     }
+  g_list_free (options);
+
+  reload_setting (self);
 }
 
 static void
@@ -370,8 +297,6 @@ cc_keyboard_option_class_init (CcKeyboardOptionClass *klass)
 GList *
 cc_keyboard_option_get_all (void)
 {
-  CcKeyboardOption *option;
-
   if (objects_list)
     return objects_list;
 
@@ -394,18 +319,6 @@ cc_keyboard_option_get_all (void)
                                                "group", XKB_OPTION_GROUP_COMP,
                                                "description", _("Compose Key"),
                                                NULL));
-
-  option = g_object_new (CC_TYPE_KEYBOARD_OPTION,
-                         "description", _("Modifiers-only switch to next source"),
-                         NULL);
-
-  input_switcher_settings = g_settings_new (INPUT_SWITCHER_SCHEMA);
-  g_signal_connect (input_switcher_settings, "changed::" INPUT_SWITCHER_KEY,
-                    G_CALLBACK (input_switcher_changed), option);
-  input_switcher_changed (input_switcher_settings, INPUT_SWITCHER_KEY, option);
-
-  objects_list = g_list_prepend (objects_list, option);
-
   return objects_list;
 }
 
@@ -430,44 +343,10 @@ cc_keyboard_option_get_current_value_description (CcKeyboardOption *self)
 {
   g_return_val_if_fail (CC_IS_KEYBOARD_OPTION (self), NULL);
 
-  if (self->is_xkb)
-    {
-      if (!self->current_value)
-        return _("Disabled");
-
-      return gnome_xkb_info_description_for_option (xkb_info, self->group, self->current_value);
-    }
-  else
-    {
-      GtkTreeIter iter;
-      gboolean ret;
-      gchar *desc;
-      gchar *id;
-
-      if (self->current_description)
-        return self->current_description;
+  if (!self->current_value)
+    return _("Disabled");
 
-      ret = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (self->store), &iter);
-      while (ret)
-        {
-          gtk_tree_model_get (GTK_TREE_MODEL (self->store), &iter,
-                              XKB_OPTION_DESCRIPTION_COLUMN, &desc,
-                              XKB_OPTION_ID_COLUMN, &id,
-                              -1);
-          if (g_strcmp0 (self->current_value, id) == 0)
-            {
-              g_free (id);
-              g_free (self->current_description);
-              self->current_description = desc;
-              break;
-            }
-          g_free (id);
-          g_free (desc);
-          ret = gtk_tree_model_iter_next (GTK_TREE_MODEL (self->store), &iter);
-        }
-
-      return self->current_description;
-    }
+  return gnome_xkb_info_description_for_option (xkb_info, self->group, self->current_value);
 }
 
 static void
@@ -528,51 +407,31 @@ void
 cc_keyboard_option_set_selection (CcKeyboardOption *self,
                                   GtkTreeIter      *iter)
 {
-  g_return_if_fail (CC_IS_KEYBOARD_OPTION (self));
+  gchar *new_value = NULL;
 
-  if (self->is_xkb)
-    {
-      gchar *new_value = NULL;
-
-      gtk_tree_model_get (GTK_TREE_MODEL (self->store), iter,
-                          XKB_OPTION_ID_COLUMN, &new_value,
-                          -1);
-
-      if (!new_value)
-        {
-          if (self->current_value)
-            remove_value (self->current_value);
-        }
-      else
-        {
-          if (self->current_value)
-            replace_value (self->current_value, new_value);
-          else
-            add_value (new_value);
-        }
+  g_return_if_fail (CC_IS_KEYBOARD_OPTION (self));
 
-      g_settings_set_strv (input_sources_settings, XKB_OPTIONS_KEY,
-                           (const gchar * const *) current_xkb_options);
+  gtk_tree_model_get (GTK_TREE_MODEL (self->store), iter,
+                      XKB_OPTION_ID_COLUMN, &new_value,
+                      -1);
 
-      g_free (new_value);
+  if (!new_value)
+    {
+      if (self->current_value)
+        remove_value (self->current_value);
     }
   else
     {
-      gchar *value = NULL;
-      gchar *description = NULL;
-
-      gtk_tree_model_get (GTK_TREE_MODEL (self->store), iter,
-                          XKB_OPTION_ID_COLUMN, &value,
-                          XKB_OPTION_DESCRIPTION_COLUMN, &description,
-                          -1);
+      if (self->current_value)
+        replace_value (self->current_value, new_value);
+      else
+        add_value (new_value);
+    }
 
-      g_free (self->current_value);
-      g_free (self->current_description);
-      self->current_value = value;
-      self->current_description = description;
+  g_settings_set_strv (input_sources_settings, XKB_OPTIONS_KEY,
+                       (const gchar * const *) current_xkb_options);
 
-      g_settings_set_string (input_switcher_settings, INPUT_SWITCHER_KEY, self->current_value);
-    }
+  g_free (new_value);
 }
 
 void
@@ -586,6 +445,5 @@ cc_keyboard_option_clear_all (void)
   g_clear_pointer (&objects_list, g_list_free);
   g_clear_pointer (&current_xkb_options, g_strfreev);
   g_clear_object (&input_sources_settings);
-  g_clear_object (&input_switcher_settings);
   g_clear_object (&xkb_info);
 }


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