gcal-search-button: Announce number of search results to screen reader
We do not have anything like live regions yet, so put raw announce calls in the right place. Fixes #1470. Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/675>
This commit is contained in:
committed by
Georges Basile Stavracas Neto
parent
f07f4ad25d
commit
6c36048ae3
@@ -25,6 +25,7 @@
|
||||
#include "gcal-search-button.h"
|
||||
#include "gcal-search-hit.h"
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <math.h>
|
||||
|
||||
#define MIN_WIDTH 450
|
||||
@@ -164,6 +165,8 @@ on_search_finished_cb (GObject *source_object,
|
||||
g_autoptr (GListModel) model = NULL;
|
||||
g_autoptr (GError) error = NULL;
|
||||
GcalSearchButton *self;
|
||||
const gchar *message;
|
||||
guint n_results;
|
||||
|
||||
GCAL_ENTRY;
|
||||
|
||||
@@ -172,6 +175,14 @@ on_search_finished_cb (GObject *source_object,
|
||||
|
||||
set_model (self, model);
|
||||
|
||||
n_results = model ? g_list_model_get_n_items (model) : 0;
|
||||
message = n_results == 0 ? _("No results found") : g_strdup_printf (ngettext ("One result found",
|
||||
"%u results found",
|
||||
n_results),
|
||||
n_results),
|
||||
|
||||
gtk_accessible_announce (GTK_ACCESSIBLE (self), message, GTK_ACCESSIBLE_ANNOUNCEMENT_PRIORITY_MEDIUM);
|
||||
|
||||
GCAL_EXIT;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user