From e4f0153c22cf9639953ce28c4e6e7cda1ef064d9 Mon Sep 17 00:00:00 2001 From: Valentin Villenave Date: Thu, 7 Oct 2021 15:27:52 +0200 Subject: Mate Trash applet: add accessible Atk object with proper label. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The accessible object’s description mentions how many items are in the Trash. --- trashapplet/src/trashapplet.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/trashapplet/src/trashapplet.c b/trashapplet/src/trashapplet.c index 2ba46c7c..6f4b7f0f 100644 --- a/trashapplet/src/trashapplet.c +++ b/trashapplet/src/trashapplet.c @@ -85,6 +85,7 @@ trash_applet_monitor_changed (TrashApplet *applet) GError *error = NULL; GFileInfo *info; GIcon *icon; + AtkObject *atk_obj; gint items; info = g_file_query_info (applet->trash, @@ -92,6 +93,8 @@ trash_applet_monitor_changed (TrashApplet *applet) G_FILE_ATTRIBUTE_TRASH_ITEM_COUNT, 0, NULL, &error); + atk_obj = gtk_widget_get_accessible (GTK_WIDGET (applet)); + if (!info) { g_critical ("could not query trash:/: '%s'", error->message); @@ -120,19 +123,20 @@ trash_applet_monitor_changed (TrashApplet *applet) if (items != applet->items) { + char *text; + if (items) { - char *text; - text = g_strdup_printf (ngettext ("%d Item in Trash", "%d Items in Trash", items), items); - gtk_widget_set_tooltip_text (GTK_WIDGET (applet), text); - g_free (text); } else - gtk_widget_set_tooltip_text (GTK_WIDGET (applet), - _("No Items in Trash")); + text = g_strdup (_("No Items in Trash")); + + gtk_widget_set_tooltip_text (GTK_WIDGET (applet), text); + atk_object_set_description (atk_obj, text); + g_free (text); applet->items = items; } @@ -615,6 +619,7 @@ trash_applet_factory (MatePanelApplet *applet, if (!strcmp (iid, "TrashApplet")) { + AtkObject *atk_obj; GtkActionGroup *action_group; g_set_application_name (_("Trash Applet")); @@ -633,6 +638,12 @@ trash_applet_factory (MatePanelApplet *applet, action_group); g_object_unref (action_group); + atk_obj = gtk_widget_get_accessible (GTK_WIDGET (applet)); + + if (GTK_IS_ACCESSIBLE (atk_obj)) { + atk_object_set_name (atk_obj, _("Trash Applet")); + } + gtk_widget_show (GTK_WIDGET (applet)); retval = TRUE; -- cgit v1.2.1