[gnome-builder] flatpak: Dedupe runtimes in preferences pane
- From: Matthew Leeds <mwleeds src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] flatpak: Dedupe runtimes in preferences pane
- Date: Sun, 23 Apr 2017 20:51:11 +0000 (UTC)
commit 3c0c6fe1d506dc9ebc601b92a2e28f0313442e5f
Author: Matthew Leeds <mleeds redhat com>
Date: Sun Apr 23 15:31:13 2017 -0500
flatpak: Dedupe runtimes in preferences pane
If a runtime is, for example, installed in both the user installation and
a system one, just show the user one which can be updated without
permissions issues. The interface doesn't show which installation
runtimes are from so duplicates are confusing.
plugins/flatpak/gbp-flatpak-preferences-addin.c | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/plugins/flatpak/gbp-flatpak-preferences-addin.c b/plugins/flatpak/gbp-flatpak-preferences-addin.c
index d773023..6ad7295 100644
--- a/plugins/flatpak/gbp-flatpak-preferences-addin.c
+++ b/plugins/flatpak/gbp-flatpak-preferences-addin.c
@@ -135,6 +135,21 @@ is_old_gnome_version (const gchar *version)
return g_utf8_collate (MIN_GNOME_VERSION, version) > 0;
}
+static gboolean
+contains_runtime (GPtrArray *runtimes,
+ FlatpakRef *ref)
+{
+ for (guint i = 0; i < runtimes->len; i++)
+ {
+ FlatpakRef *existing_ref = g_ptr_array_index (runtimes, i);
+ if (g_strcmp0 (flatpak_ref_format_ref (existing_ref),
+ flatpak_ref_format_ref (ref)) == 0)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static void
populate_runtimes (GbpFlatpakPreferencesAddin *self,
FlatpakInstallation *installation,
@@ -180,7 +195,8 @@ populate_runtimes (GbpFlatpakPreferencesAddin *self,
if (g_strcmp0 (arch, flatpak_get_default_arch ()) != 0)
continue;
- g_ptr_array_add (runtimes, g_object_ref (ref));
+ if (!contains_runtime (runtimes, ref))
+ g_ptr_array_add (runtimes, g_object_ref (ref));
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]