static gboolean
do_filter (GtkWidget *chooser)
{
  CcInputChooserPrivate *priv = GET_PRIVATE (chooser);
  gchar **previous_words;
  gchar *filter_contents = NULL;

  priv->filter_timeout_id = 0;

  previous_words = priv->filter_words;

  filter_contents =
    cc_util_normalize_casefold_and_unaccent (gtk_entry_get_text (GTK_ENTRY (priv->filter_entry)));

  if (filter_contents)
    {
      priv->filter_words = g_strsplit_set (g_strstrip (filter_contents), " ", 0);
      g_free (filter_contents);
    }

  if (!priv->filter_words || !priv->filter_words[0])
    {
      g_clear_pointer (&priv->filter_words, g_strfreev);
      gtk_list_box_invalidate_filter (GTK_LIST_BOX (priv->list));
      gtk_list_box_set_placeholder (GTK_LIST_BOX (priv->list), NULL);
    }
  else
    {
      if (!previous_words || strvs_differ (priv->filter_words, previous_words))
        {
          gtk_list_box_invalidate_filter (GTK_LIST_BOX (priv->list));
          gtk_list_box_set_placeholder (GTK_LIST_BOX (priv->list), priv->no_results);
        }
    }

  g_strfreev (previous_words);

  return G_SOURCE_REMOVE;
}
static void
filter_changed (GtkWidget *chooser)
{
  CcInputChooserPrivate *priv = GET_PRIVATE (chooser);
  gboolean was_filtering;
  gchar **previous_words;
  gchar *filter_contents = NULL;

  previous_words = priv->filter_words;
  was_filtering = previous_words != NULL;

  filter_contents =
    cc_util_normalize_casefold_and_unaccent (gtk_entry_get_text (GTK_ENTRY (priv->filter_entry)));

  if (filter_contents)
    {
      priv->filter_words = g_strsplit_set (g_strstrip (filter_contents), " ", 0);
      g_free (filter_contents);
    }

  if (!priv->filter_words || !priv->filter_words[0])
    {
      g_clear_pointer (&priv->filter_words, g_strfreev);
      if (was_filtering)
        show_locale_widgets (chooser);
    }
  else
    {
      if (!was_filtering)
        show_filter_widgets (chooser);
      else if (strvs_differ (priv->filter_words, previous_words))
        gtk_list_box_invalidate_filter (GTK_LIST_BOX (priv->list));
    }

  g_strfreev (previous_words);
}