[gnome-software/1364-implement-other-apps-by-author-section-in-app-details-page: 213/215] 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: 213/215] gs-details-page: Consider app IDs with and without ".desktop" the same
- Date: Mon, 30 May 2022 09:50:40 +0000 (UTC)
commit 2ddfe486bbd21a97f47485f8eaca191b3e13b60f
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 d3a19a48f..6e2370a73 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -972,6 +972,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_developer_apps_cb (GObject *source_object,
GAsyncResult *result,
@@ -998,7 +1025,7 @@ gs_details_page_search_developer_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_developer_apps), tile, -1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]