[gnome-software: 1/2] gs-category-page: Sort recently updated apps by release date
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 1/2] gs-category-page: Sort recently updated apps by release date
- Date: Tue, 17 Aug 2021 15:37:20 +0000 (UTC)
commit 297ff50ee4d96bd8f2a19446560512edffef32d6
Author: Philip Withnall <pwithnall endlessos org>
Date: Tue Aug 17 12:22:57 2021 +0100
gs-category-page: Sort recently updated apps by release date
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Fixes: #1400
src/gs-category-page.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
---
diff --git a/src/gs-category-page.c b/src/gs-category-page.c
index 979c25c74..833141768 100644
--- a/src/gs-category-page.c
+++ b/src/gs-category-page.c
@@ -450,10 +450,43 @@ gs_category_page_get_category (GsCategoryPage *self)
return self->category;
}
+static gint
+recently_updated_sort_cb (GtkFlowBoxChild *child1,
+ GtkFlowBoxChild *child2,
+ gpointer user_data)
+{
+ GsSummaryTile *tile1 = GS_SUMMARY_TILE (gtk_bin_get_child (GTK_BIN (child1)));
+ GsSummaryTile *tile2 = GS_SUMMARY_TILE (gtk_bin_get_child (GTK_BIN (child2)));
+ GsApp *app1 = gs_app_tile_get_app (GS_APP_TILE (tile1));
+ GsApp *app2 = gs_app_tile_get_app (GS_APP_TILE (tile2));
+ guint64 release_date1 = 0, release_date2 = 0;
+
+ /* Placeholder tiles have no app. */
+ if (app1 != NULL)
+ release_date1 = gs_app_get_release_date (app1);
+ if (app2 != NULL)
+ release_date2 = gs_app_get_release_date (app2);
+
+ /* Don’t use the normal subtraction trick, as there’s the possibility
+ * for overflow in the conversion from guint64 to gint. */
+ if (release_date1 > release_date2)
+ return -1;
+ else if (release_date2 > release_date1)
+ return 1;
+ else
+ return 0;
+}
+
static void
gs_category_page_init (GsCategoryPage *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
+
+ /* Sort the recently updated apps by update date. */
+ gtk_flow_box_set_sort_func (GTK_FLOW_BOX (self->recently_updated_flow_box),
+ recently_updated_sort_cb,
+ NULL,
+ NULL);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]