+static gboolean pan_view_list_contains_kw_pattern(GList *haystack, PanViewFilterElement *filter, gchar **found_kw)
+{
+ if (filter->kw_regex)
+ {
+ // regex compile succeeded; attempt regex match.
+ GList *work = g_list_first(haystack);
+ while (work)
+ {
+ gchar *keyword = work->data;
+ work = work->next;
+ if (g_regex_match(filter->kw_regex, keyword, 0x0, NULL))
+ {
+ if (found_kw) *found_kw = keyword;
+ return TRUE;
+ }
+ }
+ return FALSE;
+ }
+ else
+ {
+ // regex compile failed; fall back to exact string match.
+ GList *found_elem = g_list_find_custom(haystack, filter->keyword, (GCompareFunc)g_strcmp0);
+ if (found_elem && found_kw) *found_kw = found_elem->data;
+ return !!found_elem;
+ }
+}
+