[Xfce4-commits] <libxfce4ui:xfce-4.10> Primary and Control now conflict.

Jérôme Guelfucci noreply at xfce.org
Sat May 4 12:10:09 CEST 2013


Updating branch refs/heads/xfce-4.10
         to 4561420e4a3fbe33f0e7533b5ae0592b07578695 (commit)
       from 202442c762894e2eabfc9e8953a64674a6a2b6f7 (commit)

commit 4561420e4a3fbe33f0e7533b5ae0592b07578695
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date:   Sun Dec 30 10:21:29 2012 +0100

    Primary and Control now conflict.
    
    When we grab a shortcut with the Primary modifier, we also look for
    conflicts with the Control equivalent as they are the same. That way we
    can handle shortcuts from old configurations which were grabbed with an
    older version of GTK+.

 libxfce4kbd-private/xfce-shortcuts-provider.c |   52 ++++++++++++++++++++++++-
 1 files changed, 51 insertions(+), 1 deletions(-)

diff --git a/libxfce4kbd-private/xfce-shortcuts-provider.c b/libxfce4kbd-private/xfce-shortcuts-provider.c
index 3fbf746..6ee4d7f 100644
--- a/libxfce4kbd-private/xfce-shortcuts-provider.c
+++ b/libxfce4kbd-private/xfce-shortcuts-provider.c
@@ -575,9 +575,9 @@ gboolean
 xfce_shortcuts_provider_has_shortcut (XfceShortcutsProvider *provider,
                                       const gchar           *shortcut)
 {
+  gboolean has_property;
   gchar   *base_property;
   gchar   *property;
-  gboolean has_property;
 
   g_return_val_if_fail (XFCE_IS_SHORTCUTS_PROVIDER (provider), FALSE);
   g_return_val_if_fail (XFCONF_IS_CHANNEL (provider->priv->channel), FALSE);
@@ -591,6 +591,56 @@ xfce_shortcuts_provider_has_shortcut (XfceShortcutsProvider *provider,
   has_property = xfconf_channel_has_property (provider->priv->channel, property);
   g_free (property);
 
+  if (!has_property && g_strrstr (shortcut, "<Primary>"))
+    {
+      /* We want to match a shortcut with <Primary>. Older versions of
+       * GTK+ used <Control> and this might be stored in Xfconf. We need
+       * to check for this too. */
+
+      const gchar *primary;
+      const gchar *p, *s;
+      GString     *replaced;
+      gchar       *with_control_shortcut;
+
+      replaced = g_string_sized_new (strlen (shortcut));
+      primary = "Primary";
+
+      /* Replace Primary in the string by Control using the same logic
+       * as exo_str_replace. */
+
+      while (*shortcut != '\0')
+        {
+          if (G_UNLIKELY (*shortcut == *primary))
+            {
+              /* compare the pattern to the current string */
+              for (p = primary + 1, s = shortcut + 1; *p == *s; ++s, ++p)
+                if (*p == '\0' || *s == '\0')
+                  break;
+
+              /* check if the pattern fully matched */
+              if (G_LIKELY (*p == '\0'))
+                {
+                  g_string_append (replaced, "Control");
+                  shortcut = s;
+                  continue;
+                }
+            }
+
+          g_string_append_c (replaced, *shortcut++);
+        }
+
+      with_control_shortcut = g_string_free (replaced, FALSE);
+
+      DBG ("Looking for old GTK+ shortcut %s", with_control_shortcut);
+
+      property =
+        g_strconcat (base_property, "/", with_control_shortcut, NULL);
+      has_property = xfconf_channel_has_property (provider->priv->channel, property);
+      g_free (property);
+
+      g_free (with_control_shortcut);
+    }
+
   return has_property;
 }
 


More information about the Xfce4-commits mailing list