[gnome-software] Improve search page details
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Improve search page details
- Date: Sat, 21 Sep 2013 00:54:17 +0000 (UTC)
commit 9643df3007adf757f0aee699dc9952f3f3e93718
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Sep 20 20:50:44 2013 -0400
Improve search page details
There focus keeping patch from earlier today introduced a segfault
when going back from app details to the search page - this is the
one case where the previous focus widget gets removed too early.
Avoid this by not repeating the search if the search term hasn't
changed. This also avoids an annoying wait.
At the same time, improve the scrolling handling in the same way
we do on other pages - keep the scrolling position when going
back to the search page, scroll to the top in all other cases.
src/gs-shell-search.c | 17 ++++++++++++++++-
src/gs-shell-search.h | 3 ++-
src/gs-shell.c | 4 ++--
3 files changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/src/gs-shell-search.c b/src/gs-shell-search.c
index e824c3e..4b25639 100644
--- a/src/gs-shell-search.c
+++ b/src/gs-shell-search.c
@@ -44,6 +44,7 @@ struct GsShellSearchPrivate
GtkSizeGroup *sizegroup_name;
gboolean waiting;
GsShell *shell;
+ gchar *value;
};
G_DEFINE_TYPE (GsShellSearch, gs_shell_search, G_TYPE_OBJECT)
@@ -207,7 +208,7 @@ out: ;
* gs_shell_search_refresh:
**/
void
-gs_shell_search_refresh (GsShellSearch *shell_search, const gchar *value)
+gs_shell_search_refresh (GsShellSearch *shell_search, const gchar *value, gboolean scroll_up)
{
GsShellSearchPrivate *priv = shell_search->priv;
GtkWidget *widget;
@@ -222,6 +223,19 @@ gs_shell_search_refresh (GsShellSearch *shell_search, const gchar *value)
if (priv->waiting)
return;
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "scrolledwindow_search"));
+ if (scroll_up) {
+ GtkAdjustment *adj;
+ adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (widget));
+ gtk_adjustment_set_value (adj, gtk_adjustment_get_lower (adj));
+ }
+
+ if (g_strcmp0 (value, priv->value) == 0)
+ return;
+
+ g_free (priv->value);
+ priv->value = g_strdup (value);
+
/* remove old entries */
gs_container_remove_all (GTK_CONTAINER (priv->list_box_search));
@@ -372,6 +386,7 @@ gs_shell_search_finalize (GObject *object)
g_object_unref (priv->builder);
g_object_unref (priv->plugin_loader);
g_object_unref (priv->cancellable);
+ g_free (priv->value);
G_OBJECT_CLASS (gs_shell_search_parent_class)->finalize (object);
}
diff --git a/src/gs-shell-search.h b/src/gs-shell-search.h
index cc8a107..5c44b15 100644
--- a/src/gs-shell-search.h
+++ b/src/gs-shell-search.h
@@ -54,7 +54,8 @@ GType gs_shell_search_get_type (void);
GsShellSearch *gs_shell_search_new (void);
void gs_shell_search_refresh (GsShellSearch *shell_search,
- const gchar *text);
+ const gchar *text,
+ gboolean scroll_up);
void gs_shell_search_setup (GsShellSearch *shell_search,
GsShell *shell,
GsPluginLoader *plugin_loader,
diff --git a/src/gs-shell.c b/src/gs-shell.c
index ed0f285..9badc26 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -146,7 +146,7 @@ gs_shell_change_mode (GsShell *shell, GsShellMode mode, GsApp *app, GsCategory *
case GS_SHELL_MODE_SEARCH:
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "entry_search"));
text = gtk_entry_get_text (GTK_ENTRY (widget));
- gs_shell_search_refresh (priv->shell_search, text);
+ gs_shell_search_refresh (priv->shell_search, text, scroll_up);
break;
case GS_SHELL_MODE_UPDATES:
gs_shell_updates_refresh (priv->shell_updates, FALSE, scroll_up);
@@ -258,7 +258,7 @@ gs_shell_search_activated_cb (GtkEntry *entry, GsShell *shell)
return;
if (gs_shell_get_mode (shell) == GS_SHELL_MODE_SEARCH) {
- gs_shell_search_refresh (priv->shell_search, text);
+ gs_shell_search_refresh (priv->shell_search, text, TRUE);
} else {
gs_shell_change_mode (shell, GS_SHELL_MODE_SEARCH, NULL, NULL, TRUE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]