summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Villenave <[email protected]>2021-10-07 15:27:52 +0200
committerraveit65 <[email protected]>2021-10-26 16:00:45 +0200
commit130e2e12a7d5e54165b25effee5fadb1693a096a (patch)
tree26b251681641c0a902f7f0f0fd72e7347f238f77
parent77ea4ad2917ac2054b08026f205d623b38229c1a (diff)
downloadmate-applets-130e2e12a7d5e54165b25effee5fadb1693a096a.tar.bz2
mate-applets-130e2e12a7d5e54165b25effee5fadb1693a096a.tar.xz
Mate Trash applet: add accessible Atk object with proper label.
The accessible object’s description mentions how many items are in the Trash.
-rw-r--r--trashapplet/src/trashapplet.c23
1 files 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;