[gnome-software/wip/mcrha/3rd-party-repo-disable] gs-repos-dialog: Cannot disable all 3rd-party repositories
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/mcrha/3rd-party-repo-disable] gs-repos-dialog: Cannot disable all 3rd-party repositories
- Date: Tue, 21 Sep 2021 12:56:34 +0000 (UTC)
commit c72ec9bff88f0b743ecffabec8d8bb779be8db11
Author: Milan Crha <mcrha redhat com>
Date: Tue Sep 21 14:53:27 2021 +0200
gs-repos-dialog: Cannot disable all 3rd-party repositories
All the 3rd-party repositories should be disable-able, thus the 3rd-party
section should not use the heuristics to disallow disable of some of them.
This could be seen on a 'flathub' Flatpak repository installed for
the system, which is not allowed to be disabled in the Flatpak section.
src/gs-repo-row.c | 7 +++++--
src/gs-repo-row.h | 3 ++-
src/gs-repos-dialog.c | 4 ++--
src/gs-repos-section.c | 7 +++++--
src/gs-repos-section.h | 3 ++-
5 files changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/src/gs-repo-row.c b/src/gs-repo-row.c
index 57493c2c7..d16666dc4 100644
--- a/src/gs-repo-row.c
+++ b/src/gs-repo-row.c
@@ -27,6 +27,7 @@ typedef struct
guint busy_counter;
gboolean supports_remove;
gboolean supports_enable_disable;
+ gboolean force_enable;
} GsRepoRowPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (GsRepoRow, gs_repo_row, GTK_TYPE_LIST_BOX_ROW)
@@ -86,7 +87,7 @@ refresh_ui (GsRepoRow *row)
is_system_repo = gs_app_has_quirk (priv->repo, GS_APP_QUIRK_PROVENANCE);
/* Disable for the system repos, if installed */
- gtk_widget_set_sensitive (priv->disable_switch, priv->supports_enable_disable && (state_sensitive ||
!is_system_repo));
+ gtk_widget_set_sensitive (priv->disable_switch, priv->supports_enable_disable && (state_sensitive ||
!is_system_repo || priv->force_enable));
gtk_widget_set_visible (priv->remove_button, priv->supports_remove && !is_system_repo);
/* Set only the 'state' to visually indicate the state is not saved yet */
@@ -339,11 +340,13 @@ gs_repo_row_class_init (GsRepoRowClass *klass)
GtkWidget *
gs_repo_row_new (GsPluginLoader *plugin_loader,
- GsApp *repo)
+ GsApp *repo,
+ gboolean force_enable)
{
GsRepoRow *row = g_object_new (GS_TYPE_REPO_ROW, NULL);
GsRepoRowPrivate *priv = gs_repo_row_get_instance_private (row);
priv->plugin_loader = g_object_ref (plugin_loader);
+ priv->force_enable = force_enable;
gs_repo_row_set_repo (row, repo);
return GTK_WIDGET (row);
}
diff --git a/src/gs-repo-row.h b/src/gs-repo-row.h
index e6f24bc80..dc8d93837 100644
--- a/src/gs-repo-row.h
+++ b/src/gs-repo-row.h
@@ -25,7 +25,8 @@ struct _GsRepoRowClass
};
GtkWidget *gs_repo_row_new (GsPluginLoader *plugin_loader,
- GsApp *repo);
+ GsApp *repo,
+ gboolean force_enable);
GsApp *gs_repo_row_get_repo (GsRepoRow *row);
void gs_repo_row_mark_busy (GsRepoRow *row);
void gs_repo_row_unmark_busy (GsRepoRow *row);
diff --git a/src/gs-repos-dialog.c b/src/gs-repos-dialog.c
index 98aa0f208..0f24149c9 100644
--- a/src/gs-repos-dialog.c
+++ b/src/gs-repos-dialog.c
@@ -484,7 +484,7 @@ add_repo (GsReposDialog *dialog,
origin_ui = g_strdup (gs_app_get_management_plugin (repo));
section = g_hash_table_lookup (dialog->sections, origin_ui);
if (section == NULL) {
- section = gs_repos_section_new (dialog->plugin_loader);
+ section = gs_repos_section_new (dialog->plugin_loader, FALSE);
hdy_preferences_group_set_title (HDY_PREFERENCES_GROUP (section),
origin_ui);
g_signal_connect_object (section, "remove-clicked",
@@ -627,7 +627,7 @@ get_sources_cb (GsPluginLoader *plugin_loader,
gtk_container_add (GTK_CONTAINER (widget), row);
gtk_container_add (GTK_CONTAINER (dialog->content_page), widget);
- section = GS_REPOS_SECTION (gs_repos_section_new (dialog->plugin_loader));
+ section = GS_REPOS_SECTION (gs_repos_section_new (dialog->plugin_loader, TRUE));
gs_repos_section_set_sort_key (section, "900");
g_signal_connect_object (section, "switch-clicked",
G_CALLBACK (repo_section_switch_clicked_cb), dialog, 0);
diff --git a/src/gs-repos-section.c b/src/gs-repos-section.c
index 3bf59ad78..6ea8b760b 100644
--- a/src/gs-repos-section.c
+++ b/src/gs-repos-section.c
@@ -20,6 +20,7 @@ struct _GsReposSection
GtkListBox *list;
GsPluginLoader *plugin_loader;
gchar *sort_key;
+ gboolean force_enable;
};
G_DEFINE_TYPE (GsReposSection, gs_repos_section, HDY_TYPE_PREFERENCES_GROUP)
@@ -131,7 +132,8 @@ gs_repos_section_init (GsReposSection *self)
}
GtkWidget *
-gs_repos_section_new (GsPluginLoader *plugin_loader)
+gs_repos_section_new (GsPluginLoader *plugin_loader,
+ gboolean force_enable)
{
GsReposSection *self;
@@ -140,6 +142,7 @@ gs_repos_section_new (GsPluginLoader *plugin_loader)
self = g_object_new (GS_TYPE_REPOS_SECTION, NULL);
self->plugin_loader = g_object_ref (plugin_loader);
+ self->force_enable = force_enable;
return GTK_WIDGET (self);
}
@@ -159,7 +162,7 @@ gs_repos_section_add_repo (GsReposSection *self,
if (!self->sort_key)
self->sort_key = g_strdup (gs_app_get_metadata_item (repo, "GnomeSoftware::SortKey"));
- row = gs_repo_row_new (self->plugin_loader, repo);
+ row = gs_repo_row_new (self->plugin_loader, repo, self->force_enable);
g_signal_connect (row, "remove-clicked",
G_CALLBACK (repo_remove_clicked_cb), self);
diff --git a/src/gs-repos-section.h b/src/gs-repos-section.h
index 6e29769c5..244959d57 100644
--- a/src/gs-repos-section.h
+++ b/src/gs-repos-section.h
@@ -20,7 +20,8 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GsReposSection, gs_repos_section, GS, REPOS_SECTION, HdyPreferencesGroup)
-GtkWidget *gs_repos_section_new (GsPluginLoader *plugin_loader);
+GtkWidget *gs_repos_section_new (GsPluginLoader *plugin_loader,
+ gboolean force_enable);
void gs_repos_section_add_repo (GsReposSection *self,
GsApp *repo);
const gchar *gs_repos_section_get_title (GsReposSection *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]