[gnome-software: 1/24] gs-category-page: Remove UI for sorting
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 1/24] gs-category-page: Remove UI for sorting
- Date: Mon, 3 May 2021 15:24:12 +0000 (UTC)
commit ebb21fa6d447a98a4d52f0d641cf4c6600ef095f
Author: Philip Withnall <pwithnall endlessos org>
Date: Wed Apr 21 15:06:01 2021 +0100
gs-category-page: Remove UI for sorting
It’s not present in the new design:
https://gitlab.gnome.org/Teams/Design/software-mockups/-/blob/master/adaptive/category-page-mvp.png
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1111
src/gs-category-page.c | 123 ++----------------------------------------------
src/gs-category-page.ui | 82 +-------------------------------
2 files changed, 5 insertions(+), 200 deletions(-)
---
diff --git a/src/gs-category-page.c b/src/gs-category-page.c
index 42f9489d9..0c4b3766f 100644
--- a/src/gs-category-page.c
+++ b/src/gs-category-page.c
@@ -19,11 +19,6 @@
#include "gs-category-page.h"
#include "gs-utils.h"
-typedef enum {
- SUBCATEGORY_SORT_TYPE_RATING,
- SUBCATEGORY_SORT_TYPE_NAME
-} SubcategorySortType;
-
struct _GsCategoryPage
{
GsPage parent_instance;
@@ -33,9 +28,6 @@ struct _GsCategoryPage
GsShell *shell;
GsCategory *category;
GsCategory *subcategory;
- guint sort_rating_handler_id;
- guint sort_name_handler_id;
- SubcategorySortType sort_type;
GtkWidget *category_detail_box;
GtkWidget *scrolledwindow_category;
@@ -43,11 +35,6 @@ struct _GsCategoryPage
GtkWidget *subcats_filter_button_label;
GtkWidget *subcats_filter_button;
GtkWidget *popover_filter_box;
- GtkWidget *subcats_sort_label;
- GtkWidget *subcats_sort_button;
- GtkWidget *subcats_sort_button_label;
- GtkWidget *sort_rating_button;
- GtkWidget *sort_name_button;
GtkWidget *featured_grid;
GtkWidget *featured_heading;
GtkWidget *header_filter_box;
@@ -69,38 +56,6 @@ app_tile_clicked (GsAppTile *tile, gpointer data)
gs_shell_show_app (self->shell, app);
}
-static void
-gs_category_page_sort_by_type (GsCategoryPage *self,
- SubcategorySortType sort_type)
-{
- g_autofree gchar *button_label;
-
- if (sort_type == SUBCATEGORY_SORT_TYPE_NAME)
- g_object_get (self->sort_name_button, "text", &button_label, NULL);
- else
- g_object_get (self->sort_rating_button, "text", &button_label, NULL);
-
- gtk_label_set_text (GTK_LABEL (self->subcats_sort_button_label), button_label);
-
- /* only sort again if the sort type is different */
- if (self->sort_type == sort_type)
- return;
-
- self->sort_type = sort_type;
- gtk_flow_box_invalidate_sort (GTK_FLOW_BOX (self->category_detail_box));
-}
-
-static void
-sort_button_clicked (GtkButton *button, gpointer data)
-{
- GsCategoryPage *self = GS_CATEGORY_PAGE (data);
-
- if (button == GTK_BUTTON (self->sort_rating_button))
- gs_category_page_sort_by_type (self, SUBCATEGORY_SORT_TYPE_RATING);
- else
- gs_category_page_sort_by_type (self, SUBCATEGORY_SORT_TYPE_NAME);
-}
-
static void
gs_category_page_get_apps_cb (GObject *source_object,
GAsyncResult *res,
@@ -135,41 +90,17 @@ gs_category_page_get_apps_cb (GObject *source_object,
gtk_container_add (GTK_CONTAINER (self->category_detail_box), tile);
gtk_widget_set_can_focus (gtk_widget_get_parent (tile), FALSE);
}
-
- g_signal_handler_unblock (self->sort_rating_button, self->sort_rating_handler_id);
- g_signal_handler_unblock (self->sort_name_button, self->sort_name_handler_id);
}
static gint
_max_results_sort_cb (GsApp *app1, GsApp *app2, gpointer user_data)
{
- return gs_app_get_rating (app1) - gs_app_get_rating (app2);
-}
+ gint name_sort = gs_utils_sort_strcmp (gs_app_get_name (app1), gs_app_get_name (app2));
-static gint
-gs_category_page_sort_flow_box_sort_func (GtkFlowBoxChild *child1,
- GtkFlowBoxChild *child2,
- gpointer data)
-{
- GsApp *app1 = gs_app_tile_get_app (GS_APP_TILE (gtk_bin_get_child (GTK_BIN (child1))));
- GsApp *app2 = gs_app_tile_get_app (GS_APP_TILE (gtk_bin_get_child (GTK_BIN (child2))));
- SubcategorySortType sort_type;
-
- if (!GS_IS_APP (app1) || !GS_IS_APP (app2))
- return 0;
-
- sort_type = GS_CATEGORY_PAGE (data)->sort_type;
-
- if (sort_type == SUBCATEGORY_SORT_TYPE_RATING) {
- gint rating_app1 = gs_app_get_rating (app1);
- gint rating_app2 = gs_app_get_rating (app2);
- if (rating_app1 > rating_app2)
- return -1;
- if (rating_app1 < rating_app2)
- return 1;
- }
+ if (name_sort != 0)
+ return name_sort;
- return gs_utils_sort_strcmp (gs_app_get_name (app1), gs_app_get_name (app2));
+ return gs_app_get_rating (app1) - gs_app_get_rating (app2);
}
static void
@@ -284,24 +215,8 @@ gs_category_page_reload (GsPage *page)
gs_category_get_id (self->category),
gs_category_get_id (self->subcategory));
- /* don't show the sort button on addons that cannot be rated */
- if (g_strcmp0 (gs_category_get_id (self->category), "addons") == 0) {
- gtk_widget_set_visible (self->subcats_sort_label, FALSE);
- gtk_widget_set_visible (self->subcats_sort_button, FALSE);
-
- } else {
- gtk_widget_set_visible (self->subcats_sort_label, TRUE);
- gtk_widget_set_visible (self->subcats_sort_button, TRUE);
- }
-
- g_signal_handler_block (self->sort_rating_button, self->sort_rating_handler_id);
- g_signal_handler_block (self->sort_name_button, self->sort_name_handler_id);
-
gs_container_remove_all (GTK_CONTAINER (self->category_detail_box));
- /* just ensure the sort button has the correct label */
- gs_category_page_sort_by_type (self, self->sort_type);
-
count = MIN(30, gs_category_get_size (self->subcategory));
for (i = 0; i < count; i++) {
tile = gs_summary_tile_new (NULL);
@@ -501,18 +416,6 @@ gs_category_page_dispose (GObject *object)
g_cancellable_cancel (self->cancellable);
g_clear_object (&self->cancellable);
- if (self->sort_rating_handler_id > 0) {
- g_signal_handler_disconnect (self->sort_rating_button,
- self->sort_rating_handler_id);
- self->sort_rating_handler_id = 0;
- }
-
- if (self->sort_name_handler_id > 0) {
- g_signal_handler_disconnect (self->sort_name_button,
- self->sort_name_handler_id);
- self->sort_name_handler_id = 0;
- }
-
g_clear_object (&self->category);
g_clear_object (&self->subcategory);
g_clear_object (&self->plugin_loader);
@@ -531,19 +434,6 @@ gs_category_page_setup (GsPage *page,
self->plugin_loader = g_object_ref (plugin_loader);
self->shell = shell;
- self->sort_type = SUBCATEGORY_SORT_TYPE_RATING;
- gtk_flow_box_set_sort_func (GTK_FLOW_BOX (self->category_detail_box),
- gs_category_page_sort_flow_box_sort_func,
- self, NULL);
-
- self->sort_rating_handler_id = g_signal_connect (self->sort_rating_button,
- "clicked",
- G_CALLBACK (sort_button_clicked),
- self);
- self->sort_name_handler_id = g_signal_connect (self->sort_name_button,
- "clicked",
- G_CALLBACK (sort_button_clicked),
- self);
return TRUE;
}
@@ -571,11 +461,6 @@ gs_category_page_class_init (GsCategoryPageClass *klass)
gtk_widget_class_bind_template_child (widget_class, GsCategoryPage, subcats_filter_button_label);
gtk_widget_class_bind_template_child (widget_class, GsCategoryPage, subcats_filter_button);
gtk_widget_class_bind_template_child (widget_class, GsCategoryPage, popover_filter_box);
- gtk_widget_class_bind_template_child (widget_class, GsCategoryPage, subcats_sort_label);
- gtk_widget_class_bind_template_child (widget_class, GsCategoryPage, subcats_sort_button);
- gtk_widget_class_bind_template_child (widget_class, GsCategoryPage, subcats_sort_button_label);
- gtk_widget_class_bind_template_child (widget_class, GsCategoryPage, sort_rating_button);
- gtk_widget_class_bind_template_child (widget_class, GsCategoryPage, sort_name_button);
gtk_widget_class_bind_template_child (widget_class, GsCategoryPage, featured_grid);
gtk_widget_class_bind_template_child (widget_class, GsCategoryPage, featured_heading);
gtk_widget_class_bind_template_child (widget_class, GsCategoryPage, header_filter_box);
diff --git a/src/gs-category-page.ui b/src/gs-category-page.ui
index cbb828402..e3a6f76cb 100644
--- a/src/gs-category-page.ui
+++ b/src/gs-category-page.ui
@@ -12,29 +12,7 @@
</object>
</child>
</object>
- <object class="GtkPopover" id="sorting_popover">
- <property name="visible">False</property>
- <property name="position">bottom</property>
- <child>
- <object class="GtkBox" id="sorting_popover_box">
- <property name="visible">True</property>
- <property name="margin">10</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkModelButton" id="sort_rating_button">
- <property name="visible">True</property>
- <property name="text" translatable="yes" comments="Translators: A label for a button to sort
apps by their rating.">Rating</property>
- </object>
- </child>
- <child>
- <object class="GtkModelButton" id="sort_name_button">
- <property name="visible">True</property>
- <property name="text" translatable="yes" comments="Translators: A label for a button to sort
apps alphabetically.">Name</property>
- </object>
- </child>
- </object>
- </child>
- </object>
+
<template class="GsCategoryPage" parent="GsPage">
<child>
<object class="GtkBox" id="box_category">
@@ -153,56 +131,6 @@
</style>
</object>
</child>
- <child>
- <object class="GtkLabel" id="subcats_sort_label">
- <property name="visible">True</property>
- <property name="label" translatable="yes" comments="TRANSLATORS: This is
a label for the category sort drop down, which all together can read e.g. 'Sort Top Rated'.">Sort</property>
- <property name="margin_start">2</property>
- <accessibility>
- <relation target="subcats_sort_button" type="label-for"/>
- </accessibility>
- </object>
- </child>
- <child>
- <object class="GtkMenuButton" id="subcats_sort_button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="relief">normal</property>
- <property name="popover">sorting_popover</property>
- <child internal-child="accessible">
- <object class="AtkObject">
- <property name="accessible-name" translatable="yes">Subcategories
sorting menu</property>
- </object>
- </child>
- <child>
- <object class="GtkBox" id="grid2">
- <property name="visible">True</property>
- <property name="valign">center</property>
- <property name="spacing">6</property>
- <property name="orientation">horizontal</property>
- <child>
- <object class="GtkLabel" id="subcats_sort_button_label">
- <property name="visible">True</property>
- <property name="xalign">0.0</property>
- </object>
- </child>
- <child>
- <object class="GtkArrow" id="arrow2">
- <property name="visible">True</property>
- <property name="arrow_type">down</property>
- </object>
- <packing>
- <property name="pack-type">end</property>
- </packing>
- </child>
- </object>
- </child>
- <style>
- <class name="text-button"/>
- </style>
- </object>
- </child>
</object>
</child>
@@ -245,12 +173,4 @@
<widget name="popover_filter_box"/>
</widgets>
</object>
- <object class="GtkSizeGroup">
- <property name="ignore-hidden">False</property>
- <property name="mode">horizontal</property>
- <widgets>
- <widget name="subcats_sort_button_label"/>
- <widget name="sorting_popover_box"/>
- </widgets>
- </object>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]