summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandru Pandelea <alexandru.pandelea@gmail.com>2017-08-07 17:52:39 +0100
committerAlexandru Pandelea <alexandru.pandelea@gmail.com>2017-08-08 11:23:12 +0100
commit85c28fff02596f4a8335c479ef0ba2f72e158e36 (patch)
tree9afef44cca698fda601733770eb7979946aa8964
parentaae95a43be1afdccd703529c2594716d90e6aeaf (diff)
downloadnautilus-85c28fff02596f4a8335c479ef0ba2f72e158e36.tar.gz
list-view: fix snippet newline removal
Removing only \n from the snippet is not enough, as there are also other newline characters. Use a GRegex to match those new line chars and remove them. https://bugzilla.gnome.org/show_bug.cgi?id=785959
-rw-r--r--src/nautilus-list-view-private.h2
-rw-r--r--src/nautilus-list-view.c13
2 files changed, 14 insertions, 1 deletions
diff --git a/src/nautilus-list-view-private.h b/src/nautilus-list-view-private.h
index e2a09a1e6..2638c36ec 100644
--- a/src/nautilus-list-view-private.h
+++ b/src/nautilus-list-view-private.h
@@ -64,5 +64,7 @@ struct NautilusListViewDetails {
gulong clipboard_handler_id;
GQuark last_sort_attr;
+
+ GRegex *regex;
};
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 36c0c08be..2ba3d6ed4 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -1614,7 +1614,14 @@ filename_cell_data_func (GtkTreeViewColumn *column,
snippet = nautilus_file_get_search_fts_snippet (file);
if (snippet)
{
- replaced_text = eel_str_replace_substring (snippet, "\n", "");
+ replaced_text = g_regex_replace (view->details->regex,
+ snippet,
+ -1,
+ 0,
+ " ",
+ G_REGEX_MATCH_NEWLINE_ANY,
+ NULL);
+
escaped_text = g_markup_escape_text (replaced_text, -1);
g_string_append_printf (display_text, "\n<small><span color='grey'>%s</span></small>", escaped_text);
}
@@ -3367,6 +3374,8 @@ nautilus_list_view_finalize (GObject *object)
g_free (list_view->details);
+ g_regex_unref (list_view->details->regex);
+
G_OBJECT_CLASS (nautilus_list_view_parent_class)->finalize (object);
}
@@ -3650,6 +3659,8 @@ nautilus_list_view_init (NautilusListView *list_view)
/* Keep the action synced with the actual value, so the toolbar can poll it */
g_action_group_change_action_state (nautilus_files_view_get_action_group (NAUTILUS_FILES_VIEW (list_view)),
"zoom-to-level", g_variant_new_int32 (get_default_zoom_level ()));
+
+ list_view->details->regex = g_regex_new ("\\R+", 0, G_REGEX_MATCH_NEWLINE_ANY, NULL);
}
NautilusFilesView *