[gnome-software/wip/hughsie/fix-alternates-regression: 12/12] details page: Carry over the local file when switching between alternates
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/hughsie/fix-alternates-regression: 12/12] details page: Carry over the local file when switching between alternates
- Date: Tue, 9 Oct 2018 09:53:18 +0000 (UTC)
commit 45ef15fe55d8961ddb2267955ad59ccc4828acde
Author: Kalev Lember <klember redhat com>
Date: Tue Oct 9 09:46:16 2018 +0200
details page: Carry over the local file when switching between alternates
... so that the local file doesn't disappear from the alternates drop
down list when switching to a distro provided alternate.
src/gs-details-page.c | 55 +++++++++++++++++++++++++++++++++------------------
1 file changed, 36 insertions(+), 19 deletions(-)
---
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index a0e1c6fe..06bcc230 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -61,6 +61,7 @@ struct _GsDetailsPage
GCancellable *cancellable;
GCancellable *app_cancellable;
GsApp *app;
+ GsApp *app_local_file;
GsShell *shell;
SoupSession *session;
gboolean enable_reviews;
@@ -762,6 +763,11 @@ gs_details_page_get_alternates_cb (GObject *source_object,
return;
}
+ /* add the local file to the list so that we can carry it over when
+ * switching between alternates */
+ if (self->app_local_file != NULL)
+ gs_app_list_add (list, self->app_local_file);
+
/* no alternates to show */
if (gs_app_list_length (list) < 2) {
gtk_widget_hide (origin_box);
@@ -788,23 +794,6 @@ gs_details_page_get_alternates_cb (GObject *source_object,
gtk_widget_show (origin_box);
}
-static void
-origin_popover_row_activated_cb (GtkListBox *list_box,
- GtkListBoxRow *row,
- gpointer user_data)
-{
- GsDetailsPage *self = GS_DETAILS_PAGE (user_data);
- GsApp *app;
- GtkWidget *popover;
-
- popover = GTK_WIDGET (gtk_builder_get_object (self->builder, "origin_popover"));
- gtk_popover_popdown (GTK_POPOVER (popover));
-
- app = gs_origin_popover_row_get_app (GS_ORIGIN_POPOVER_ROW (row));
- if (app != self->app)
- gs_details_page_set_app (self, app);
-}
-
static void
gs_details_page_refresh_buttons (GsDetailsPage *self)
{
@@ -1730,7 +1719,9 @@ gs_details_page_file_to_app_cb (GObject *source,
/* go back to the overview */
gs_shell_change_mode (self->shell, GS_SHELL_MODE_OVERVIEW, NULL, FALSE);
} else {
- _set_app (self, GS_APP (gs_app_list_index (list, 0)));
+ GsApp *app = gs_app_list_index (list, 0);
+ g_set_object (&self->app_local_file, app);
+ _set_app (self, app);
gs_details_page_load_stage2 (self);
}
}
@@ -1753,7 +1744,8 @@ gs_details_page_url_to_app_cb (GObject *source,
/* go back to the overview */
gs_shell_change_mode (self->shell, GS_SHELL_MODE_OVERVIEW, NULL, FALSE);
} else {
- _set_app (self, GS_APP (gs_app_list_index (list, 0)));
+ GsApp *app = gs_app_list_index (list, 0);
+ _set_app (self, app);
gs_details_page_load_stage2 (self);
}
}
@@ -1763,6 +1755,7 @@ gs_details_page_set_local_file (GsDetailsPage *self, GFile *file)
{
g_autoptr(GsPluginJob) plugin_job = NULL;
gs_details_page_set_state (self, GS_DETAILS_PAGE_STATE_LOADING);
+ g_clear_object (&self->app_local_file);
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_FILE_TO_APP,
"file", file,
"refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON |
@@ -1795,6 +1788,7 @@ gs_details_page_set_url (GsDetailsPage *self, const gchar *url)
{
g_autoptr(GsPluginJob) plugin_job = NULL;
gs_details_page_set_state (self, GS_DETAILS_PAGE_STATE_LOADING);
+ g_clear_object (&self->app_local_file);
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_URL_TO_APP,
"search", url,
"refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON |
@@ -1872,6 +1866,25 @@ gs_details_page_reload (GsPage *page)
gs_details_page_load_stage1 (self);
}
+static void
+origin_popover_row_activated_cb (GtkListBox *list_box,
+ GtkListBoxRow *row,
+ gpointer user_data)
+{
+ GsDetailsPage *self = GS_DETAILS_PAGE (user_data);
+ GsApp *app;
+ GtkWidget *popover;
+
+ popover = GTK_WIDGET (gtk_builder_get_object (self->builder, "origin_popover"));
+ gtk_popover_popdown (GTK_POPOVER (popover));
+
+ app = gs_origin_popover_row_get_app (GS_ORIGIN_POPOVER_ROW (row));
+ if (app != self->app) {
+ _set_app (self, app);
+ gs_details_page_load_stage1 (self);
+ }
+}
+
static void
settings_changed_cb (GsDetailsPage *self, const gchar *key, gpointer data)
{
@@ -1889,6 +1902,9 @@ gs_details_page_set_app (GsDetailsPage *self, GsApp *app)
g_return_if_fail (GS_IS_DETAILS_PAGE (self));
g_return_if_fail (GS_IS_APP (app));
+ /* clear old state */
+ g_clear_object (&self->app_local_file);
+
/* save GsApp */
_set_app (self, app);
gs_details_page_load_stage1 (self);
@@ -2437,6 +2453,7 @@ gs_details_page_dispose (GObject *object)
g_signal_handlers_disconnect_by_func (self->app, gs_details_page_progress_changed_cb, self);
g_clear_object (&self->app);
}
+ g_clear_object (&self->app_local_file);
g_clear_object (&self->builder);
g_clear_object (&self->plugin_loader);
g_clear_object (&self->cancellable);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]