[gnome-software/1141-flatpak-remove-of-a-repository-doesn-t-remove-it-from-the-gui] flatpak: Remove of a repository doesn't remove it from the GUI




commit 16e5759eacd86a048830caf602df5ae373157f1b
Author: Milan Crha <mcrha redhat com>
Date:   Tue Feb 16 12:26:26 2021 +0100

    flatpak: Remove of a repository doesn't remove it from the GUI
    
    Changes:
    * Allow REMOVING state to change to UNAVAILABLE - avoids to call
      the gs_app_set_state() twice, once with UNKNOWN, then with the UNAVAILABLE
    * Set the UNAVAILABLE state for the repository when it is removed
    * Destroy any repository rows, whose state changes to UNAVAILABLE
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1141

 lib/gs-app.c                   |  1 +
 plugins/flatpak/gs-flatpak.c   |  2 +-
 plugins/flatpak/gs-self-test.c | 14 +++++++-------
 src/gs-repo-row.c              |  6 +++++-
 4 files changed, 14 insertions(+), 9 deletions(-)
---
diff --git a/lib/gs-app.c b/lib/gs-app.c
index d3cd67546..ffc995e67 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -1072,6 +1072,7 @@ gs_app_set_state_internal (GsApp *app, GsAppState state)
        case GS_APP_STATE_REMOVING:
                /* removing has to go into an stable state */
                if (state == GS_APP_STATE_UNKNOWN ||
+                   state == GS_APP_STATE_UNAVAILABLE ||
                    state == GS_APP_STATE_AVAILABLE ||
                    state == GS_APP_STATE_INSTALLED)
                        state_change_ok = TRUE;
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index cc9937c93..062dd3c6f 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -2937,7 +2937,7 @@ gs_flatpak_app_remove_source (GsFlatpak *self,
                xb_silo_invalidate (self->silo);
        g_rw_lock_reader_unlock (&self->silo_lock);
 
-       gs_app_set_state (app, GS_APP_STATE_AVAILABLE);
+       gs_app_set_state (app, GS_APP_STATE_UNAVAILABLE);
        return TRUE;
 }
 
diff --git a/plugins/flatpak/gs-self-test.c b/plugins/flatpak/gs-self-test.c
index 476d9883c..34bf459db 100644
--- a/plugins/flatpak/gs-self-test.c
+++ b/plugins/flatpak/gs-self-test.c
@@ -200,7 +200,7 @@ gs_plugins_flatpak_repo_func (GsPluginLoader *plugin_loader)
        gs_test_flush_main_context ();
        g_assert_no_error (error);
        g_assert_true (ret);
-       g_assert_cmpint (gs_app_get_state (app), ==, GS_APP_STATE_AVAILABLE);
+       g_assert_cmpint (gs_app_get_state (app), ==, GS_APP_STATE_UNAVAILABLE);
        g_assert_cmpint (gs_app_get_progress (app), ==, GS_APP_PROGRESS_UNKNOWN);
 }
 
@@ -504,7 +504,7 @@ gs_plugins_flatpak_app_with_runtime_func (GsPluginLoader *plugin_loader)
        gs_test_flush_main_context ();
        g_assert_no_error (error);
        g_assert_true (ret);
-       g_assert_cmpint (gs_app_get_state (app_source), ==, GS_APP_STATE_AVAILABLE);
+       g_assert_cmpint (gs_app_get_state (app_source), ==, GS_APP_STATE_UNAVAILABLE);
 }
 
 static void
@@ -602,7 +602,7 @@ gs_plugins_flatpak_app_missing_runtime_func (GsPluginLoader *plugin_loader)
        gs_test_flush_main_context ();
        g_assert_no_error (error);
        g_assert_true (ret);
-       g_assert_cmpint (gs_app_get_state (app_source), ==, GS_APP_STATE_AVAILABLE);
+       g_assert_cmpint (gs_app_get_state (app_source), ==, GS_APP_STATE_UNAVAILABLE);
 }
 
 static void
@@ -777,7 +777,7 @@ gs_plugins_flatpak_runtime_repo_func (GsPluginLoader *plugin_loader)
        gs_test_flush_main_context ();
        g_assert_no_error (error);
        g_assert_true (ret);
-       g_assert_cmpint (gs_app_get_state (app_source), ==, GS_APP_STATE_AVAILABLE);
+       g_assert_cmpint (gs_app_get_state (app_source), ==, GS_APP_STATE_UNAVAILABLE);
 }
 
 /* same as gs_plugins_flatpak_runtime_repo_func, but this time manually
@@ -938,7 +938,7 @@ gs_plugins_flatpak_runtime_repo_redundant_func (GsPluginLoader *plugin_loader)
        gs_test_flush_main_context ();
        g_assert_no_error (error);
        g_assert_true (ret);
-       g_assert_cmpint (gs_app_get_state (app_source), ==, GS_APP_STATE_AVAILABLE);
+       g_assert_cmpint (gs_app_get_state (app_source), ==, GS_APP_STATE_UNAVAILABLE);
 }
 
 static void
@@ -1581,7 +1581,7 @@ gs_plugins_flatpak_app_update_func (GsPluginLoader *plugin_loader)
        gs_test_flush_main_context ();
        g_assert_no_error (error);
        g_assert_true (ret);
-       g_assert_cmpint (gs_app_get_state (app_source), ==, GS_APP_STATE_AVAILABLE);
+       g_assert_cmpint (gs_app_get_state (app_source), ==, GS_APP_STATE_UNAVAILABLE);
 }
 
 static void
@@ -1818,7 +1818,7 @@ gs_plugins_flatpak_runtime_extension_func (GsPluginLoader *plugin_loader)
        gs_test_flush_main_context ();
        g_assert_no_error (error);
        g_assert_true (ret);
-       g_assert_cmpint (gs_app_get_state (app_source), ==, GS_APP_STATE_AVAILABLE);
+       g_assert_cmpint (gs_app_get_state (app_source), ==, GS_APP_STATE_UNAVAILABLE);
 
        /* verify that the extension has been removed by the app's removal */
        g_assert_false (gs_app_is_installed (extension));
diff --git a/src/gs-repo-row.c b/src/gs-repo-row.c
index 9dda6c7b8..e9529e9e3 100644
--- a/src/gs-repo-row.c
+++ b/src/gs-repo-row.c
@@ -132,6 +132,9 @@ refresh_ui (GsRepoRow *row)
                /* disable button */
                gtk_widget_set_sensitive (priv->button, FALSE);
                break;
+       case GS_APP_STATE_UNAVAILABLE:
+               gtk_widget_destroy (GTK_WIDGET (row));
+               return;
        default:
                break;
        }
@@ -160,9 +163,10 @@ refresh_idle (gpointer user_data)
        g_autoptr(GsRepoRow) row = (GsRepoRow *) user_data;
        GsRepoRowPrivate *priv = gs_repo_row_get_instance_private (row);
 
+       priv->refresh_idle_id = 0;
+
        refresh_ui (row);
 
-       priv->refresh_idle_id = 0;
        return G_SOURCE_REMOVE;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]