Commit 9643df30 authored by Matthias Clasen's avatar Matthias Clasen
Browse files

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.
parent cbf0ff60
......@@ -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);
}
......
......@@ -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,
......
......@@ -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);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment