1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368
use serde::{Deserialize, Serialize};
use zvariant::Type;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Type, Hash)]
/// An accessible object role.
/// To think of it in terms of HTML, any semantic element likely has a corollary in this enum.
/// For example: `<button>`, `<input>`, `<form>` or `<h4>`.
/// Non-semantic elements like `<span>`, `<div>` and `<b>` will not be represented here, and this information is not passed through via the atspi library.
/// TODO: add examples for GTK/Qt libraries in addition to HTML examples.
#[repr(u32)]
pub enum Role {
/// An invalid role used for either an invalid deserialization, or when trying to match for any possible role. TODO: confirm
Invalid,
/// Unknown role TODO
AcceleratorLabel,
/// Alert: this is triggered in a web browser through the alert(...); function.
Alert,
/// Animation: unknown use TODO
Animation,
/// Arrow: unknown use TODO
Arrow,
/// Calendar: a calendar widget, or in HTML terms, `<input type="datetime-local">`
Calendar,
/// A canvas on which any direct rendering may be called. In web terms, this would be the `<canvas>` element.
Canvas,
/// A (multiple) checkbox. In HTML terms, `<input type="checkbox">`, note that there is a different role for radio buttons and for multiple select dropdowns.
CheckBox,
/// CheckMenuItem: unknown use. TODO
CheckMenuItem,
/// ColorChooser: a color picker input. In HTML terms, `<input type="color">`
ColorChooser,
/// Column header: in HTML terms, a `<th>`.
ColumnHeader,
/// A multiple select dropdown menu.
ComboBox,
/// Date editor: unknown use case. TODO
DateEditor,
/// A desktop icon: on Windows this would be the "Recycle Bin", or "My Computer" on your desktop. On Linux this would be similar to any applications showing on your desktop.
DesktopIcon,
/// The frame within all windows live. A DesktopFrame will generally share siblings with others of the same type if you use multiple desktops.
DesktopFrame,
/// Dial: unknown use case. TODO
Dial,
/// Dialog: a pop-up dialog. In HTML terms, the `<dialog>` tag.
Dialog,
/// Directory pane: unknown use case.
DirectoryPane,
DrawingArea,
/// File chooser: this is a window which will display when
FileChooser,
/// Filter: unknown use: TODO.
Filler,
/// Focus traversable: TODO
FocusTraversable,
/// Font chooser: TODO, but obvious?
FontChooser,
/// Frame: generally the parent of InternalFrame.
Frame,
/// Glass pane? TODO
GlassPane,
/// Constraining container of which only HTML resides in. This is useful during structural navigation calls to bound the search area to only HTML elements of the page.
HTMLContainer,
/// TODO: icon
Icon,
/// An image. In HTML, this would be the <img> tag, or it could be an image embedded within a non-web application.
Image,
/// Internal frame: this is the constraining role for a graphical window. This is a good bounding role for finding things from within an application.
InternalFrame,
/// A label, which is generally associated with an item with a different role. In HTML terms, this would be a `<label for="X">` being attached to whatever `<Y id="X">` is.
Label,
/// Layered pane? TODO
LayeredPane,
/// List: a list with [`Self::ListItem`] contained within it. In HTML, this would be the same as the `<ul>` or `<ol>` elements.
List,
/// ListItem: a list's item. This would be the same as an `<li>` in HTML terms.
ListItem,
Menu,
MenuBar,
MenuItem,
OptionPane,
PageTab,
PageTabList,
Panel,
/// A password input, like `<input type="password">`.
PasswordText,
PopupMenu,
/// Progress bar: this indicates progress of some process, and generally is indicated by successively higher-pitched beeps on a screen reader as it is updated to a more and more highly completed state. In HTML this would be the same as `<progress>` tag.
ProgressBar,
/// PushButton: this is what everybody else calls a button. In HTML, `<button>`
PushButton,
/// Radio button: a multiple-choice, single-selection option. In HTML: `<input type="radio">`.
RadioButton,
RadioMenuItem,
/// Root pane: the mother of *ALL* panes. This is the pane from which all other panes descend. If you wanted to, for some reason, search within a bound of the entire active desktop, this would be your bounding pane.
RootPane,
/// Row header: a heading to a row. In HTML this would be the same as `<th role="rowheader">` without the additional role="..." attribute, the header will still be recognized as a column header.
RowHeader,
/// A scroll bar itself: the item you may click on and scroll up and down.
ScrollBar,
/// A scroll pane: the pane in which the scrollable content is contained within.
ScrollPane,
/// Separator: commonly used in desktop applications to pad out the interface. This also is the same as the `<hr>` element in HTML.
Separator,
/// Slider: a slider to control a granular value like volume, pitch, or speed.
Slider,
/// spin button: ? TODO
SpinButton,
/// Split pane: ? TODO
SplitPane,
/// Status bar: ? TODO
StatusBar,
/// Table: a table. This may hold any tabular data with rows and columns. This would be the same as the `<table>` element in HTML.
Table,
/// A table cell: this may hold a singular piece of data at a row+column combo. This is the same as `<td>` in HTML.
TableCell,
/// The column header of a table, represented in HTML as a `<th>`
TableColumnHeader,
/// The row heading of a table, represented in HTML as a `<th scope="row">`.
TableRowHeader,
TearoffMenuItem,
/// A virtual terminal like MATE Terminal, Foot, or `st`.
Terminal,
Text,
ToggleButton,
ToolBar,
ToolTip,
/// The root of a tree, which may have many sub trees and tree items (leafs).
Tree,
TreeTable,
/// When the role cannot be accurately reported, this role will be set.
Unknown,
Viewport,
/// A window itself, not the same thing as a Pane or a Frame, which are both contained within a
/// Window.
Window,
Extended,
/// A header with upfront information about a document, site, or application. The same as `<header>` in HTML.
Header,
/// A footer with additional (usually optional) information about a web page, document, or application. The same as `<footer>` in HTML.
Footer,
/// A paragraph of text: the same as `<p>` in HTML.
Paragraph,
/// A horizontal line between two items. Usually a `<hr>` in HTML.
Ruler,
Application,
Autocomplete,
Editbar,
Embedded,
Entry,
CHART,
Caption,
DocumentFrame,
/// Heading: this is a heading with a level (usually 1-6). This is represented by `<h1>` through `<h6>` in HTML.
Heading,
Page,
/// Section: pieces of grouped content for semantic purposes. This is the same as the `<section>` tag in HTML.
Section,
RedundantObject,
/// Form: a form where a user will input information and send the form out (usually to an online service). The same as the `<form>` element in HTML.
Form,
/// Link: a hyperlink that leads to a new destination. The same as the `<a>` tag in HTML.
Link,
InputMethodWindow,
/// Table row: a row of table data. This is the same as the `<tr>` tag from HTML.
TableRow,
/// A leaf or node within a tree.
TreeItem,
/// A spreadsheet document (almost exclusively used by LibreofficeCalc).
DocumentSpreadsheet,
/// A presentation document (almost exclusively used by LibreofficePresent).
DocumentPresentation,
/// A text document (almost exclusively used by LibreofficeWriter).
DocumentText,
/// A web document, used for any web browser.
DocumentWeb,
/// An email document, used primarily by Thunderbird.
DocumentEmail,
Comment,
ListBox,
Grouping,
ImageMap,
/// Notification: this is generally displayed and made accessible by a notification daemon. For example `dunst`.
Notification,
InfoBar,
LevelBar,
TitleBar,
/// Block quote: when a quote is longer than around one full sentence, a block-style quote often make more sense. This is the same as the `<blockquote>` HTML tag.
BlockQuote,
/// Audio: a role which can play sound. In HTML: `<audio>`
Audio,
/// Video: a role which can play a video (with optional sound). In HTML: `<video>`
Video,
Definition,
Article,
Landmark,
Log,
Marquee,
/// Math: a special role for when math equations appear. This is the same as the `<math>` tag in HTML, indicating embedded MathML.
Math,
/// A rating system, generally out of five stars, but it does not need to be that way. There is no tag nor role for this in HTML, however.
Rating,
Timer,
Static,
MathFraction,
MathRoot,
Subscript,
Superscript,
/// A list with Term/Value subitems. This is the same as `<dl>` in HTML.
DescriptionList,
/// An item (usually inside a [`Self::DescriptionList`]) that has a term as its content.
/// The same as the `<dt>` tag in HTML.
DescriptionTerm,
/// An item (usually inside a [`Self::DescriptionList`]) that has a term's value as its
/// content. This is the same as a `<dd>` tag in HTML.
DescriptionValue,
Footnote,
ContentDeletion,
ContentInsertion,
Mark,
Suggestion,
PushButtonMenu,
}
const ROLE_NAMES: &[&str] = &[
"invalid",
"accelerator label",
"alert",
"animation",
"arrow",
"calendar",
"canvas",
"check box",
"check menu item",
"color chooser",
"column header",
"combo box",
"date editor",
"desktop icon",
"desktop frame",
"dial",
"dialog",
"directory pane",
"drawing area",
"file chooser",
"filler",
"focus traversable",
"font chooser",
"frame",
"glass pane",
"html container",
"icon",
"image",
"internal frame",
"label",
"layered pane",
"list",
"list item",
"menu",
"menu bar",
"menu item",
"option pane",
"page tab",
"page tab list",
"panel",
"password text",
"popup menu",
"progress bar",
"push button",
"radio button",
"radio menu item",
"root pane",
"row header",
"scroll bar",
"scroll pane",
"separator",
"slider",
"spin button",
"split pane",
"status bar",
"table",
"table cell",
"table column header",
"table row header",
"tearoff menu item",
"terminal",
"text",
"toggle button",
"tool bar",
"tool tip",
"tree",
"tree table",
"unknown",
"viewport",
"window",
"extended",
"header",
"footer",
"paragraph",
"ruler",
"application",
"autocomplete",
"editbar",
"embedded",
"entry",
"chart",
"caption",
"document frame",
"heading",
"page",
"section",
"redundant object",
"form",
"link",
"input method window",
"table row",
"tree item",
"document spreadsheet",
"document presentation",
"document text",
"document web",
"document email",
"comment",
"list box",
"grouping",
"image map",
"notification",
"info bar",
"level bar",
"title bar",
"block quote",
"audio",
"video",
"definition",
"article",
"landmark",
"log",
"marquee",
"math",
"rating",
"timer",
"static",
"math fraction",
"math root",
"subscript",
"superscript",
"description list",
"description term",
"description value",
"footnote",
"content deletion",
"content insertion",
"mark",
"suggestion",
"push button menu",
];
impl Role {
#[must_use]
pub fn name(&self) -> &'static str {
ROLE_NAMES[*self as usize]
}
}
impl std::fmt::Display for Role {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.name())
}
}