summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Villenave <[email protected]>2021-10-07 15:27:52 +0200
committerraveit65 <[email protected]>2021-11-09 22:39:21 +0100
commite4f0153c22cf9639953ce28c4e6e7cda1ef064d9 (patch)
treed4c99a12d0c4c6c9a97eb49f177f36429312ec3d
parent4b2a857fcb5ebbc5e420257d02fc2b66268e3436 (diff)
downloadmate-applets-e4f0153c22cf9639953ce28c4e6e7cda1ef064d9.tar.bz2
mate-applets-e4f0153c22cf9639953ce28c4e6e7cda1ef064d9.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;