diff options
author | MShrimp4 <mshrimp@sogang.ac.kr> | 2022-02-18 13:13:41 +0900 |
---|---|---|
committer | Andre Miranda <andreldm@xfce.org> | 2022-02-21 21:33:55 +0000 |
commit | 1dbf1ffcc6f9e11a0ec583cb1de2029ae9eb1d24 (patch) | |
tree | 64519d24f47ce60ba3b59b4777d59993d6ff2a02 | |
parent | bbd31aa98399475b0ebb42e7efc784d4b95b1d46 (diff) | |
download | libxfce4ui-1dbf1ffcc6f9e11a0ec583cb1de2029ae9eb1d24.tar.gz |
Replace duplicate logic with xfce_str_replace
Related: exo#82 (https://gitlab.xfce.org/xfce/exo/-/issues/82#note_42725),
libxfce4util!24
-rw-r--r-- | libxfce4kbd-private/xfce-shortcuts-provider.c | 32 |
1 files changed, 1 insertions, 31 deletions
diff --git a/libxfce4kbd-private/xfce-shortcuts-provider.c b/libxfce4kbd-private/xfce-shortcuts-provider.c index 36b3271..1c1c95a 100644 --- a/libxfce4kbd-private/xfce-shortcuts-provider.c +++ b/libxfce4kbd-private/xfce-shortcuts-provider.c @@ -599,39 +599,9 @@ xfce_shortcuts_provider_has_shortcut (XfceShortcutsProvider *provider, * 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); + with_control_shortcut = xfce_str_replace (shortcut, "Primary", "Control"); DBG ("Looking for old GTK+ shortcut %s", with_control_shortcut); |