[gnome-software/1364-implement-other-apps-by-author-section-in-app-details-page: 154/156] gs-details-page: Consider app IDs with and without ".desktop" the same
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1364-implement-other-apps-by-author-section-in-app-details-page: 154/156] gs-details-page: Consider app IDs with and without ".desktop" the same
- Date: Fri, 6 May 2022 08:51:37 +0000 (UTC)
commit 702468075f45bb2253f9335227fc1290bb4a6bfe
Author: Milan Crha <mcrha redhat com>
Date: Fri May 6 10:47:50 2022 +0200
gs-details-page: Consider app IDs with and without ".desktop" the same
Let the app IDs with and without the ".desktop" suffix being considered
the same apps and remove them from the list of other apps of the developer.
src/gs-details-page.c | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
---
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index 67fb1cb17..8c9395319 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -974,6 +974,33 @@ gs_details_page_app_tile_clicked (GsAppTile *tile,
gs_details_page_set_app (self, app);
}
+/* Consider app IDs with and without the ".desktop" suffix being the same app */
+static gboolean
+gs_details_page_app_id_equal (GsApp *app1,
+ GsApp *app2)
+{
+ const gchar *id1, *id2;
+
+ id1 = gs_app_get_id (app1);
+ id2 = gs_app_get_id (app2);
+ if (g_strcmp0 (id1, id2) == 0)
+ return TRUE;
+
+ if (id1 == NULL || id2 == NULL)
+ return FALSE;
+
+ if (g_str_has_suffix (id1, ".desktop")) {
+ return !g_str_has_suffix (id2, ".desktop") &&
+ strlen (id1) == strlen (id2) + 8 /* strlen (".desktop") */ &&
+ g_str_has_prefix (id1, id2);
+ }
+
+ return g_str_has_suffix (id2, ".desktop") &&
+ !g_str_has_suffix (id1, ".desktop") &&
+ strlen (id2) == strlen (id1) + 8 /* strlen (".desktop") */ &&
+ g_str_has_prefix (id2, id1);
+}
+
static void
gs_details_page_search_other_apps_cb (GObject *source_object,
GAsyncResult *result,
@@ -1000,7 +1027,7 @@ gs_details_page_search_other_apps_cb (GObject *source_object,
for (guint i = 0; i < gs_app_list_length (list); i++) {
GsApp *app = gs_app_list_index (list, i);
- if (g_strcmp0 (gs_app_get_id (app), gs_app_get_id (self->app)) != 0) {
+ if (!gs_details_page_app_id_equal (app, self->app)) {
GtkWidget *tile = gs_summary_tile_new (app);
g_signal_connect (tile, "clicked", G_CALLBACK (gs_details_page_app_tile_clicked),
self);
gtk_flow_box_insert (GTK_FLOW_BOX (self->box_other_apps), tile, -1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]