[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: Wed, 22 Sep 2021 15:32:04 +0000 (UTC)
commit 429ec744e6cdf2155772d7db463ca193231facdc
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 | 22 ++++++++++++++++++++--
src/gs-repo-row.h | 3 ++-
src/gs-repos-dialog.c | 4 ++--
src/gs-repos-section.c | 21 +++++++++++++++++++--
src/gs-repos-section.h | 3 ++-
5 files changed, 45 insertions(+), 8 deletions(-)
---
diff --git a/src/gs-repo-row.c b/src/gs-repo-row.c
index 57493c2c7..7df24e0e3 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 always_allow_enable_disable;
} 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->always_allow_enable_disable));
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 */
@@ -337,13 +338,30 @@ gs_repo_row_class_init (GsRepoRowClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GsRepoRow, disable_switch);
}
+/*
+ * gs_repo_row_new:
+ * @plugin_loader: a #GsPluginLoader
+ * @repo: a #GsApp to represent the repo in the new row
+ * @always_allow_enable_disable: always allow enabled/disable of the @repo
+ *
+ * The @plugin_loader is used to check which operations the associated plugin
+ * for the @repo can do and which not, to show only relevant buttons on the row.
+ *
+ * The @always_allow_enable_disable, when %TRUE, means that the @repo in this row
+ * can be always enabled/disabled by the user, if supported by the related plugin,
+ * regardless of the other heuristics, which can avoid the repo enable/disable.
+ *
+ * Returns: (transfer full): a newly created #GsRepoRow
+ */
GtkWidget *
gs_repo_row_new (GsPluginLoader *plugin_loader,
- GsApp *repo)
+ GsApp *repo,
+ gboolean always_allow_enable_disable)
{
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->always_allow_enable_disable = always_allow_enable_disable;
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..83c8cdf48 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 always_allow_enable_disable);
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..a9b08200f 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 always_allow_enable_disable;
};
G_DEFINE_TYPE (GsReposSection, gs_repos_section, HDY_TYPE_PREFERENCES_GROUP)
@@ -130,8 +131,23 @@ gs_repos_section_init (GsReposSection *self)
G_CALLBACK (gs_repos_section_row_activated_cb), self);
}
+/*
+ * gs_repos_section_new:
+ * @plugin_loader: a #GsPluginLoader
+ * @always_allow_enable_disable: always allow enable/disable of the repos in this section
+ *
+ * Creates a new #GsReposSection. The %plugin_loader is passed
+ * to each #GsRepoRow, the same as the @always_allow_enable_disable.
+ *
+ * The @always_allow_enable_disable, when %TRUE, means that every repo in this section
+ * can be enabled/disabled by the user, if supported by the related plugin, regardless
+ * of the other heuristics, which can avoid the repo enable/disable.
+ *
+ * Returns: (transfer full): a newly created #GsReposSection
+ */
GtkWidget *
-gs_repos_section_new (GsPluginLoader *plugin_loader)
+gs_repos_section_new (GsPluginLoader *plugin_loader,
+ gboolean always_allow_enable_disable)
{
GsReposSection *self;
@@ -140,6 +156,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->always_allow_enable_disable = always_allow_enable_disable;
return GTK_WIDGET (self);
}
@@ -159,7 +176,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->always_allow_enable_disable);
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..9a58a3e1a 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 always_allow_enable_disable);
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]