[gnome-software/1064-gs-search-page-execute-load-when-there-s-an-application-to-be-shown: 226/226] gs-search-page: Execute load when there's an application to be shown
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1064-gs-search-page-execute-load-when-there-s-an-application-to-be-shown: 226/226] gs-search-page: Execute load when there's an application to be shown
- Date: Mon, 18 Jan 2021 15:13:40 +0000 (UTC)
commit bd9cc67549c974d1963a38b649b722de2ce286c0
Author: Milan Crha <mcrha redhat com>
Date: Mon Jan 18 16:12:54 2021 +0100
gs-search-page: Execute load when there's an application to be shown
Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1064
src/gs-search-page.c | 24 +++++++++++++++++++-----
src/gs-shell.c | 1 +
2 files changed, 20 insertions(+), 5 deletions(-)
---
diff --git a/src/gs-search-page.c b/src/gs-search-page.c
index ef79c85b6..783dfc44a 100644
--- a/src/gs-search-page.c
+++ b/src/gs-search-page.c
@@ -36,6 +36,7 @@ struct _GsSearchPage
gchar *value;
guint waiting_id;
guint max_results;
+ gboolean changed;
GtkWidget *list_box_search;
GtkWidget *scrolledwindow_search;
@@ -166,7 +167,10 @@ gs_search_page_get_search_cb (GObject *source_object,
} else {
a = gs_app_new (self->appid_to_show);
}
- gs_shell_show_app (self->shell, a);
+
+ if (a)
+ gs_shell_show_app (self->shell, a);
+
g_clear_pointer (&self->appid_to_show, g_free);
}
}
@@ -236,6 +240,8 @@ gs_search_page_load (GsSearchPage *self)
{
g_autoptr(GsPluginJob) plugin_job = NULL;
+ self->changed = FALSE;
+
/* cancel any pending searches */
g_cancellable_cancel (self->search_cancellable);
g_clear_object (&self->search_cancellable);
@@ -302,8 +308,14 @@ gs_search_page_reload (GsPage *page)
void
gs_search_page_set_appid_to_show (GsSearchPage *self, const gchar *appid)
{
+ if (appid == self->appid_to_show ||
+ g_strcmp0 (appid, self->appid_to_show) == 0)
+ return;
+
g_free (self->appid_to_show);
self->appid_to_show = g_strdup (appid);
+
+ self->changed = TRUE;
}
const gchar *
@@ -315,15 +327,14 @@ gs_search_page_get_text (GsSearchPage *self)
void
gs_search_page_set_text (GsSearchPage *self, const gchar *value)
{
- if (value == self->value)
- return;
- if (g_strcmp0 (value, self->value) == 0)
+ if (value == self->value ||
+ g_strcmp0 (value, self->value) == 0)
return;
g_free (self->value);
self->value = g_strdup (value);
- gs_search_page_load (self);
+ self->changed = TRUE;
}
static void
@@ -355,6 +366,9 @@ gs_search_page_switch_to (GsPage *page, gboolean scroll_up)
adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (self->scrolledwindow_search));
gtk_adjustment_set_value (adj, gtk_adjustment_get_lower (adj));
}
+
+ if (self->value && self->changed)
+ gs_search_page_load (self);
}
static void
diff --git a/src/gs-shell.c b/src/gs-shell.c
index e523a2251..d8ac5efbf 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -493,6 +493,7 @@ gs_shell_change_mode (GsShell *shell,
case GS_SHELL_MODE_SEARCH:
page = GS_PAGE (g_hash_table_lookup (priv->pages, "search"));
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "entry_search"));
+ gs_search_page_set_text (GS_SEARCH_PAGE (page), data);
gtk_entry_set_text (GTK_ENTRY (widget), data);
gtk_editable_set_position (GTK_EDITABLE (widget), -1);
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]