[nautilus] query-editor: Don't set the entry's text if not strictly needed
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] query-editor: Don't set the entry's text if not strictly needed
- Date: Mon, 25 Mar 2013 17:33:19 +0000 (UTC)
commit 54270d1bae66ec24c56a10fe1973ec271433f6b0
Author: Rui Matos <tiagomatos gmail com>
Date: Fri Mar 22 22:53:16 2013 +0100
query-editor: Don't set the entry's text if not strictly needed
If the current text in the entry is equal to the new query's text we
shouldn't needlessly set the text on the entry since that affects the
cursor position.
gtk_entry_set_text() already does a similar check internally but that
isn't enough here because NautilusQuery doesn't keep the full string
but instead a stripped version of it.
https://bugzilla.gnome.org/show_bug.cgi?id=696430
src/nautilus-query-editor.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/src/nautilus-query-editor.c b/src/nautilus-query-editor.c
index c9473af..d72d81c 100644
--- a/src/nautilus-query-editor.c
+++ b/src/nautilus-query-editor.c
@@ -1210,6 +1210,7 @@ nautilus_query_editor_set_query (NautilusQueryEditor *editor,
NautilusQuery *query)
{
char *text = NULL;
+ char *current_text = NULL;
if (query != NULL) {
text = nautilus_query_get_text (query);
@@ -1220,7 +1221,12 @@ nautilus_query_editor_set_query (NautilusQueryEditor *editor,
}
editor->details->change_frozen = TRUE;
- gtk_entry_set_text (GTK_ENTRY (editor->details->entry), text);
+
+ current_text = g_strstrip (g_strdup (gtk_entry_get_text (GTK_ENTRY (editor->details->entry))));
+ if (!g_str_equal (current_text, text)) {
+ gtk_entry_set_text (GTK_ENTRY (editor->details->entry), text);
+ }
+ g_free (current_text);
g_free (editor->details->current_uri);
editor->details->current_uri = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]