[gnome-builder/gnome-builder-3-24] flatpak: Dedupe runtimes in preferences pane
- From: Matthew Leeds <mwleeds src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/gnome-builder-3-24] flatpak: Dedupe runtimes in preferences pane
- Date: Sun, 23 Apr 2017 23:14:57 +0000 (UTC)
commit e5fd1c5ef58339e07888203a21ae9b9dc70e7499
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 | 22 +++++++++++++++++++++-
1 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/plugins/flatpak/gbp-flatpak-preferences-addin.c b/plugins/flatpak/gbp-flatpak-preferences-addin.c
index dd74053..06d6b46 100644
--- a/plugins/flatpak/gbp-flatpak-preferences-addin.c
+++ b/plugins/flatpak/gbp-flatpak-preferences-addin.c
@@ -137,6 +137,25 @@ 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);
+ g_autofree gchar *existing_ref_name = NULL;
+ g_autofree gchar *ref_name = NULL;
+
+ existing_ref_name = flatpak_ref_format_ref (existing_ref);
+ ref_name = flatpak_ref_format_ref (ref);
+ if (g_strcmp0 (existing_ref_name, ref_name) == 0)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static void
populate_runtimes (GbpFlatpakPreferencesAddin *self,
FlatpakInstallation *installation,
@@ -182,7 +201,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]