[gnome-software/wip/ubuntu-3-22: 4/13] Limit search entry to 100 characters.
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/ubuntu-3-22: 4/13] Limit search entry to 100 characters.
- Date: Thu, 26 Oct 2017 21:46:22 +0000 (UTC)
commit 16eef1a6b654e3d02b76264697ddd63717566a24
Author: Robert Ancell <robert ancell canonical com>
Date: Fri May 12 11:39:26 2017 +1200
Limit search entry to 100 characters.
The search entry can be linked to a remote server - by limiting the number of
characters this stops accidental input (e.g. cat sitting on keyboard) from
generating continuous searches.
src/gnome-software.ui | 1 +
src/gs-shell.c | 12 ++++++++++++
2 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/src/gnome-software.ui b/src/gnome-software.ui
index 027e306..1d6a1f9 100644
--- a/src/gnome-software.ui
+++ b/src/gnome-software.ui
@@ -284,6 +284,7 @@
<property name="can_focus">True</property>
<property name="activates_default">True</property>
<property name="width_request">500</property>
+ <property name="max_length">100</property>
<property name="hexpand">True</property>
<property name="halign">center</property>
</object>
diff --git a/src/gs-shell.c b/src/gs-shell.c
index 0a41c0a..09f5628 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -84,6 +84,7 @@ typedef struct
GPtrArray *modal_dialogs;
gulong search_changed_id;
gboolean in_mode_change;
+ gchar *last_search;
} GsShellPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (GsShell, gs_shell, G_TYPE_OBJECT)
@@ -529,6 +530,16 @@ search_changed_handler (GObject *entry, GsShell *shell)
const gchar *text;
text = gtk_entry_get_text (GTK_ENTRY (entry));
+
+ /* ignore if search text not changed. This is a workaround since GtkEntry
+ * emits changed even when the character limit is hit
+ * https://bugzilla.gnome.org/show_bug.cgi?id=782636
+ */
+ if (g_strcmp0 (text, priv->last_search) == 0)
+ return;
+ g_free (priv->last_search);
+ priv->last_search = g_strdup (text);
+
if (strlen (text) > 2) {
if (gs_shell_get_mode (shell) != GS_SHELL_MODE_SEARCH) {
save_back_entry (shell);
@@ -990,6 +1001,7 @@ gs_shell_dispose (GObject *object)
g_clear_object (&priv->header_start_widget);
g_clear_object (&priv->header_end_widget);
g_clear_pointer (&priv->modal_dialogs, (GDestroyNotify) g_ptr_array_unref);
+ g_clear_pointer (&priv->last_search, g_free);
G_OBJECT_CLASS (gs_shell_parent_class)->dispose (object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]