[gnome-system-monitor] Support searching for multiple tokens (bgo#789905)
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-system-monitor] Support searching for multiple tokens (bgo#789905)
- Date: Sat, 3 Feb 2018 08:24:28 +0000 (UTC)
commit bf459a0efce5c9193422ab7f93cb2b59ff79697e
Author: Robert Roth <robert roth off gmail com>
Date: Fri Nov 10 01:10:40 2017 +0200
Support searching for multiple tokens (bgo#789905)
src/proctable.cpp | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/src/proctable.cpp b/src/proctable.cpp
index c37a48b..1fadc4d 100644
--- a/src/proctable.cpp
+++ b/src/proctable.cpp
@@ -204,7 +204,7 @@ cb_refresh_icons (GtkIconTheme *theme, gpointer data)
}
static gboolean
-iter_matches_search_key (GtkTreeModel *model, GtkTreeIter *iter, const gchar *key)
+iter_matches_search_key (GtkTreeModel *model, GtkTreeIter *iter, const gchar *search_text)
{
char *name;
char *user;
@@ -212,6 +212,8 @@ iter_matches_search_key (GtkTreeModel *model, GtkTreeIter *iter, const gchar *ke
char *pids;
char *args;
gboolean found;
+ char *search_pattern;
+ char **keys;
gtk_tree_model_get (model, iter,
COL_NAME, &name,
@@ -221,9 +223,17 @@ iter_matches_search_key (GtkTreeModel *model, GtkTreeIter *iter, const gchar *ke
-1);
pids = g_strdup_printf ("%d", pid);
- found = (name && strcasestr (name, key)) || (user && strcasestr (user, key))
- || (pids && strcasestr (pids, key)) || (args && strcasestr (args, key));
+ keys = g_strsplit_set(search_text, " |", -1);
+ search_pattern = g_strjoinv ("|", keys);
+
+ auto regex = Glib::Regex::create(search_pattern, Glib::REGEX_CASELESS);
+
+ found = (name && regex->match(name)) || (user && regex->match(user))
+ || (pids && regex->match(pids)) || (args && regex->match(args));
+
+ g_strfreev (keys);
+ g_free (search_pattern);
g_free (name);
g_free (user);
g_free (args);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]