diff options
Diffstat (limited to 'gtk/gtkoptionlist.c')
-rw-r--r-- | gtk/gtkoptionlist.c | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/gtk/gtkoptionlist.c b/gtk/gtkoptionlist.c index 759440d0cc..bee1d3c717 100644 --- a/gtk/gtkoptionlist.c +++ b/gtk/gtkoptionlist.c @@ -382,21 +382,45 @@ static gboolean gtk_option_list_row_matches (GtkOptionListRow *row, const gchar *match) { - gchar *row_text; - gchar *search_text; - gchar *hit; + gchar *hit = NULL; + PangoAttrList *attrs = NULL; + gboolean ret = TRUE; - if (match[0] == '\0') - return TRUE; + if (match[0] != '\0') + { + gchar *row_text; + gchar *search_text; + + row_text = g_utf8_strdown (row->text, -1); + search_text = g_utf8_strdown (match, -1); + + hit = strstr (row_text, search_text); + ret = hit != NULL; - row_text = g_utf8_strdown (row->text, -1); - search_text = g_utf8_strdown (match, -1); - hit = strstr (row_text, search_text); + if (hit != NULL) + { + gint offset; + gint length; + PangoAttribute *attr; + + /* FIXME: this is not utf8 safe */ + offset = hit - row_text; + length = strlen (match); + + attrs = pango_attr_list_new (); + attr = pango_attr_underline_new (PANGO_UNDERLINE_SINGLE); + attr->start_index = offset; + attr->end_index = offset + length; + pango_attr_list_insert (attrs, attr); + } + + g_free (row_text); + g_free (search_text); + } - g_free (row_text); - g_free (search_text); + gtk_label_set_attributes (GTK_LABEL (row->label), attrs); - return hit != NULL; + return ret; } static const gchar * |