[gtk/gtk-3-22] appchooserwidget: search text using g_str_match_string()
- From: Nelson Benítez León <nbenitez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gtk-3-22] appchooserwidget: search text using g_str_match_string()
- Date: Sat, 31 Mar 2018 08:40:58 +0000 (UTC)
commit 7a11fcf0548e30cbd6daba196cd9c31446714c38
Author: Nelson Benítez León <nbenitezl+gnome gmail com>
Date: Wed Nov 15 19:46:31 2017 +0500
appchooserwidget: search text using g_str_match_string()
so we match on diacritics (eg. accented letters) and also
search on text tokens. As a plus we also reduce code size.
https://bugzilla.gnome.org/show_bug.cgi?id=745128
gtk/gtkappchooserwidget.c | 47 +++++++----------------------------------------
1 file changed, 7 insertions(+), 40 deletions(-)
---
diff --git a/gtk/gtkappchooserwidget.c b/gtk/gtkappchooserwidget.c
index c8da419055..9205bdd45f 100644
--- a/gtk/gtkappchooserwidget.c
+++ b/gtk/gtkappchooserwidget.c
@@ -309,58 +309,25 @@ gtk_app_chooser_search_equal_func (GtkTreeModel *model,
GtkTreeIter *iter,
gpointer user_data)
{
- gchar *normalized_key;
- gchar *name, *normalized_name;
- gchar *path, *normalized_path;
- gchar *basename, *normalized_basename;
+ gchar *name;
+ gchar *exec_name;
gboolean ret;
if (key != NULL)
{
- normalized_key = g_utf8_casefold (key, -1);
- g_assert (normalized_key != NULL);
-
ret = TRUE;
gtk_tree_model_get (model, iter,
COLUMN_NAME, &name,
- COLUMN_EXEC, &path,
+ COLUMN_EXEC, &exec_name,
-1);
- if (name != NULL)
- {
- normalized_name = g_utf8_casefold (name, -1);
- g_assert (normalized_name != NULL);
-
- if (strncmp (normalized_name, normalized_key, strlen (normalized_key)) == 0)
- ret = FALSE;
-
- g_free (normalized_name);
- }
-
- if (ret && path != NULL)
- {
- normalized_path = g_utf8_casefold (path, -1);
- g_assert (normalized_path != NULL);
-
- basename = g_path_get_basename (path);
- g_assert (basename != NULL);
-
- normalized_basename = g_utf8_casefold (basename, -1);
- g_assert (normalized_basename != NULL);
-
- if (strncmp (normalized_path, normalized_key, strlen (normalized_key)) == 0 ||
- strncmp (normalized_basename, normalized_key, strlen (normalized_key)) == 0)
- ret = FALSE;
-
- g_free (basename);
- g_free (normalized_basename);
- g_free (normalized_path);
- }
+ if ((name != NULL && g_str_match_string (key, name, TRUE)) ||
+ (exec_name != NULL && g_str_match_string (key, exec_name, FALSE)))
+ ret = FALSE;
g_free (name);
- g_free (path);
- g_free (normalized_key);
+ g_free (exec_name);
return ret;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]