Compare commits

..

243 Commits

Author SHA1 Message Date
Emmanuele Bassi
2d158da7a4 Move ATK inside GTK
This is a temporary move that aims to make GTK's accessibility support
independent of external components.

ATK has lived outside of GTK since its inception, as it was meant to be
a generic API implemented by different toolkits; that mostly failed, and
we're now stuck with an abstraction layer that doesn't really abstract
anything of value. What it did bring, on the other hand, was maintenance
burden, with changes being propagated across different projects—ATK,
GTK, and whatever accessibility layer implemented the bridge to ATSPI on
Linux. This complexity is completely unwarranted for the benefits it
gives us.

Ideally, we'd get rid of ATK entirely, and expose the accessility API as
part of the GTK namespace, but that is a fairly sizeable work, so we can
start from this step. The ATK namespace is maintained, similarly to how
we maintain the GDK, GSK, and GTK namespaces. The API is still public,
so that GTK and out of tree widgets can consume it.

The inclusion of ATK comes with the removal of the deprecated entry
points and types, as that's a good chance to begin the cleanup of this
mess of an API. Sadly, this also means we have to disable the a11y tests
for the time being, as they depend on rando API from 2002.

Another side effect of moving ATK in tree is that we cannot link to
atk-bridge on X11, as that will link to the out of tree ATK; this means
that accessibility is disabled on X11.
2020-01-21 18:21:25 +00:00
Matthias Clasen
975f6529b1 Merge branch 'wip/carlosg/x11-dnd' into 'master'
X11 dnd fixes.

See merge request GNOME/gtk!1321
2020-01-16 14:29:48 +00:00
Carlos Garnacho
357e215fb8 gdkdrag/x11: Issue XdndLeave on cancellation
According to XDND "The XdndLeave message cancels the session.",
issue one when cancelling a drag, so the dest side has an opportunity
to forget about the GdkDrop.
2020-01-16 15:03:24 +01:00
Carlos Garnacho
4716c9ae2f gdkdrag/x11: Drop timestamp argument from gdk_drag_do_leave()
This is not necessary for the XdndLeave message, nor used.
2020-01-16 15:02:16 +01:00
Carlos Garnacho
5aad3d7d0e gdk/x11: Ensure to hide DnD surface after failed operation
The drag source might be cached and held alive, only disposed after
future drag begin operations. Ensure the drag surface gets hidden
properly or might might stay transparent but mapped till then.
2020-01-16 13:34:08 +01:00
Carlos Garnacho
fe36c24b07 gdk/x11: Ensure to sync type list after sending XdndEnter
Otherwise we are not ensured the GdkDrop is up-to-date, might even
be a stale one from an older DnD operation.
2020-01-16 13:33:57 +01:00
Carlos Garnacho
682068f887 gdk/x11: Serialize gtype content formats before sending Xdnd enter
This ensures GType handlers get serialized to mimetypes at the time
the drag dest inspects the XdndTypeList property.
2020-01-16 13:31:40 +01:00
Matthias Clasen
e8eb1df29f Speed up gtk_widget_pick
Add early exits, and avoid as much work as
possible.
2020-01-15 11:01:20 -05:00
Matthias Clasen
82dc7b903c Fix the filetransfer portal initialization
Reusing the cancellable only works if you don't throw
it away after first use.
2020-01-15 10:58:54 -05:00
Matthias Clasen
b020a3fcf9 Try harder to make ci not timeout
Make getting the file transfer portal proxy more
async, and avoid leaking a bus connection. This
causes GTestDBus to hang at the end of the test
run.
2020-01-14 18:32:05 -05:00
Matthias Clasen
cb88de5938 css: Drop unsused bitmasks
GtkCssProvider was maintaining bitmasks for the
set properties in each ruleset. The masks are never
used, so drop them.
2020-01-14 18:32:05 -05:00
Matthias Clasen
94b1e72aa3 css: Remove an unused function
_gtk_css_style_property_get_mask_affecting was superseded
by GtkCssStyleChange back in 2015.
2020-01-14 18:32:05 -05:00
Matthias Clasen
20b92638ec testsuite: Improve --generate support
We don't want annoying spew from GTest when
using --generate, since it interferes with just
piping the output to a text file.
2020-01-14 18:32:05 -05:00
Matthias Clasen
dccb83c9ec quiet a compiler warning in release builds 2020-01-14 18:32:05 -05:00
Alex Samorukov
d668d2fa25 Use bundle id instead of package name for the macOS preview as filename is now changed 2020-01-14 22:15:05 +00:00
Matthias Clasen
34f1ae8fad fontchooser: Fix up the previous commit 2020-01-14 15:42:01 -05:00
Matthias Clasen
042537cf0d fontchooser: Fix objects-finalize test
The treeview is evil and keeps reference cycles in the
form of various tree row references. That gets cleaned up
if you explicitly gtk_widget_destroy the treeview. But since
07f2024bfc, the scrolled window no longer destroys
its child, exposing this issue as a reference leak in
the objects-finalize test.

The font chooser widget is affected here because it calls
gtk_tree_view_scroll_to_path from init(), which creates one
of those reference cycles. Work around this in the font
chooser by unsetting the tree view model in dispose, which
clears up this cycle.
2020-01-14 15:25:27 -05:00
Matthias Clasen
d03f38470e Fix encoding symbolic pixbufs
This was broken in 1a931da046.
2020-01-14 14:14:45 -05:00
Sucipto
a7d72cf69b Update Indonesian translation 2020-01-14 15:11:27 +00:00
Matthias Clasen
256139baab testsuite: Skip GtkDragIcon
GtkDragIcon needs a special surface, so skip it
in the notify tests.
2020-01-14 09:20:18 -05:00
Daniel Mustieles
a935aae6f1 Updated Spanish translation 2020-01-14 12:39:44 +01:00
Kukuh Syafaat
9955d686ee Update Indonesian translation 2020-01-14 06:27:18 +00:00
Matthias Clasen
a9da41c66a Merge branch 'adwaita-cross-fade-fix-gtk4' into 'master'
Adwaita: Fix syntax error in cross-fade() (GTK4)

Closes #2371

See merge request GNOME/gtk!1308
2020-01-14 06:08:24 +00:00
Matthias Clasen
4d8691b762 Merge branch 'wip/chergert/fix-dragicon-installation' into 'master'
build: fix gtkdragicon header installation

See merge request GNOME/gtk!1306
2020-01-14 06:06:35 +00:00
Matthias Clasen
806e159b8b Handle lack of file transfer portal
Don't block for 25 seconds trying to get a bus
connection. Give up after 1 second.
2020-01-14 01:03:48 -05:00
Matthias Clasen
794ee0b8c0 gtk-demo: Use a default action in the infobars demo
This makes the question infobar activatable by clicking
anywhere in it.
2020-01-14 00:05:23 -05:00
Matthias Clasen
2b7de841a9 Adwaita: Add hover for clickable infobars 2020-01-14 00:05:23 -05:00
Matthias Clasen
45309811c5 infobar: Activate default action on clicks
When we have a default action set on the infobar, activate it
for clicks anywhere in the infobar.  Also add an .action style
class in this case, so we can add a hover highlight to the infobar
just for this case.
2020-01-14 00:05:23 -05:00
Matthias Clasen
2b695ac8d1 Merge branch 'wip/chergert/textview-propagate-undo-state' into 'master'
textview: propagate GtkTextBuffer can-undo/redo action state

See merge request GNOME/gtk!1311
2020-01-14 01:59:22 +00:00
Christian Hergert
cb03969c5f textview: propagate GtkTextBuffer can-undo/redo action state
This ensures the action state for undo and redo are propagated from the
buffer. Doing so means menu items now properly show sensitivity.
2020-01-13 17:26:18 -08:00
Matthias Clasen
57e71a6a69 Merge branch 'wip/chergert/textview-undo-menu-item' into 'master'
textview: add undo/redo menu actions

See merge request GNOME/gtk!1310
2020-01-13 23:51:40 +00:00
Christian Hergert
15b5a404b8 textview: add undo/redo menu actions 2020-01-13 15:25:05 -08:00
nana-4
4056a40d2d Adwaita: Fix syntax error in cross-fade()
cross-fade() requires two images.

Fixes https://gitlab.gnome.org/GNOME/gtk/issues/2371
2020-01-14 06:19:12 +09:00
Christian Hergert
c1e9523f0e build: fix gtkdragicon header installation 2020-01-13 09:07:24 -08:00
Daniel Mustieles
4c1ccfd7be Updated Spanish translation 2020-01-13 16:51:22 +01:00
Daniel Mustieles
823e00dec9 Updated Spanish translation 2020-01-13 16:50:21 +01:00
Timm Bäder
3e51966ea9 Merge branch 'wip/jimmac/updated-checkmark' into 'master'
Adwaita: update checkbox & radio

Closes #2291

See merge request GNOME/gtk!1289
2020-01-13 14:12:51 +00:00
Jakub Steiner
e292767a01 Adwaita: update checkbox & radio
Fixes https://gitlab.gnome.org/GNOME/gtk/issues/2291
2020-01-13 13:45:34 +01:00
Matthias Clasen
75c433fb5f Merge branch 'closure-annotations' into 'master'
Fix incorrect use of GIR closure annotations.

See merge request GNOME/gtk!1305
2020-01-13 05:00:12 +00:00
Robert Ancell
83867f9cbf Add missing (closure) GIR annotations 2020-01-13 14:26:50 +13:00
Robert Ancell
ea9f0df67b Fix incorrect use of GIR closure annotations.
They were being applied to the callback function, not the data that is passed
to that function.
2020-01-13 14:11:15 +13:00
Matthias Clasen
15c7980ba6 Merge branch 'textbuffer-missing-api-docs' into 'master'
Add missing public API documentation.

See merge request GNOME/gtk!1301
2020-01-13 00:51:24 +00:00
Matthias Clasen
de5fde1e12 Merge branch 'menutoolbutton-missing-api-docs' into 'master'
menutoolbutton: Add missing public API documentation.

See merge request GNOME/gtk!1303
2020-01-13 00:50:58 +00:00
Matthias Clasen
a83b360224 Merge branch 'docstring-typos' into 'master'
Fix docstring errors with drag and drop code

See merge request GNOME/gtk!1304
2020-01-13 00:50:16 +00:00
Matthias Clasen
4d55d23c1a Merge branch 'missing-transfer-notation' into 'master'
Add missing transfer notation for function return types.

See merge request GNOME/gtk!1302
2020-01-13 00:49:25 +00:00
Robert Ancell
2b6162116d Fix docstring errors with drag and drop code 2020-01-13 12:30:17 +13:00
Robert Ancell
b2ca947934 textbuffer: Add missing public API documentation.
This API was added in a52757874e.
2020-01-13 12:19:43 +13:00
Robert Ancell
3eaf88b84c menutoolbutton: Add missing public API documentation.
This API was added in 03e30431a8
2020-01-13 12:17:55 +13:00
Robert Ancell
9e9eae3ad4 Add missing transfer notation for function return types. 2020-01-13 12:14:08 +13:00
Matthias Clasen
903afcbddd Adwaita: Fix needs-attention
Stack switchers are now stackswitcher, no longer .stack-switcher.

Fixes: https://gitlab.gnome.org/GNOME/gtk/issues/2370
2020-01-11 20:14:35 -05:00
Piotr Drąg
d37612a476 Update POTFILES.in 2020-01-11 16:07:48 +01:00
Matthias Clasen
f5daecf353 Merge branch 'dnd-gestures-2' into 'master'
Add new dnd api

See merge request GNOME/gtk!1278
2020-01-11 06:09:58 +00:00
Matthias Clasen
b76940bab5 dragdest: More documentation 2020-01-11 00:50:22 -05:00
Matthias Clasen
ec255f9bb1 Update all callers 2020-01-11 00:50:22 -05:00
Matthias Clasen
9dc6be4fb0 Reshuffle droptarget api a little bit
Add a ::drag-motion signal back, remove x,y from
the ::accept signal, and only emit ::accept once.
2020-01-11 00:49:59 -05:00
Matthias Clasen
186b783f9d Merge branch 'wip/chergert/gtk4-gtk-main-sync' into 'master'
Rubustness fixes for gtk_main_sync()

See merge request GNOME/gtk!1299
2020-01-11 04:41:46 +00:00
Christian Hergert
2f3518c80d gtkmain: be deterministic in source removal
Fixes gtk_main_sync() to only remove a source if it has not
already executed (and been removed). The previous code was
using gtk_main_quit() directly which would be non-determinstic
based on the previous value in the return register.
2020-01-10 15:04:44 -08:00
Christian Hergert
4a7f68e79e gtkmain: short-circuit gtk_main_sync() where no display
If there is no display, we will hit the slow path here which
can introduce long latencies in unit tests. This checks for
a NULL list of displays and simply short-circuits.
2020-01-10 15:00:10 -08:00
Matthias Clasen
65af983ddb Merge branch 'css-font-values' into 'master'
Css font values

See merge request GNOME/gtk!1298
2020-01-10 22:47:41 +00:00
Matthias Clasen
f0dc5e0be5 css: Simplify font features
Don't store numbers as GtkCssValues needlessly.
2020-01-10 16:59:56 -05:00
Alex Samorukov
f0cbd175cd gdk_quartz_keymap_translate_keyboard_state fills consumed_modifiers
incorrectly (closes #2102)

See merge request GNOME/gtk!1225
2020-01-10 22:18:24 +01:00
Matthias Clasen
99aa47185e css: Simplify compute for font variations
Just like font features, font variations are stored
as a hash table mapping strings to pure number values,
which never change during compute.
2020-01-10 15:49:00 -05:00
Matthias Clasen
898e29c989 css: Simplify compute for font features
Font features consist of a hash table of number
values, which will never change during compute,
so there is no point in recreating a new value
with a copy of the hash table, constaining the
same string->number mapping.
2020-01-10 15:48:51 -05:00
Matthias Clasen
cf1700fd13 Merge branch 'kill-builtin-image' into 'master'
Kill builtin image

See merge request GNOME/gtk!1297
2020-01-10 19:43:14 +00:00
Matthias Clasen
112aed590f Remove builtin icons altogether
This removes support for GtkCssImageBuiltin and
GtkCssImageBuiltinType from everywhere.
2020-01-10 14:34:56 -05:00
Matthias Clasen
6763443c5d css: Stop supporting builtin images
Change the default value of -gtk-icon-source to 'none',
and stop parsing 'builtin' as a value.
2020-01-10 14:32:06 -05:00
Matthias Clasen
f33fe6daed testdnd: Fix up for current api 2020-01-09 10:29:33 -05:00
Matthias Clasen
c7dc17d837 docs: Expand the dnd migration hints 2020-01-09 07:47:28 -05:00
Matthias Clasen
a51ee20ed9 dragicon: Add docs 2020-01-09 00:50:33 -05:00
Matthias Clasen
8d3e1eb314 docs: Fix a typo 2020-01-09 00:31:13 -05:00
Matthias Clasen
c941a2d9c6 Properly export GtkDragIcon
The get_type function was missing.
2020-01-09 00:30:41 -05:00
Matthias Clasen
1c03bbeb9c Update all users 2020-01-08 18:48:23 -05:00
Matthias Clasen
a4059cd02d dragdest: Rename ::drag-motion to ::accept 2020-01-08 18:48:23 -05:00
Matthias Clasen
eab6df31ac dragdest: Allow denying drops asynchronously
Add an api to deny a drop, this is meant to be used
when delaying the decision on whether to accept a
drop until after reading the data.
2020-01-08 18:48:23 -05:00
Matthias Clasen
8a085fcc5a remove debug spew 2020-01-08 18:48:23 -05:00
Matthias Clasen
7668669d56 dragdest: Add a ::drag-enter signal
Mainly for symmetry with ::drag-leave.
2020-01-08 18:48:22 -05:00
Matthias Clasen
5e57b3d07a testdnd2: Fix the text case
We must take mime types into account when checking.
2020-01-08 18:48:22 -05:00
Matthias Clasen
187a701a99 content provider impl: Take mime types into account 2020-01-08 18:48:22 -05:00
Matthias Clasen
d5f4579384 dragdest: Steps towards allowing nested drop sites 2020-01-08 18:48:22 -05:00
Matthias Clasen
0297039b38 Add another dnd testcase
This one tests nested drop sites and interaction between
DND and other gestures.
2020-01-08 18:48:22 -05:00
Matthias Clasen
5206a92522 Update all callers 2020-01-08 18:48:22 -05:00
Matthias Clasen
233ec1a5d6 Add GdkDrop back to signal signatures 2020-01-08 18:48:22 -05:00
Matthias Clasen
579d8e427b Drop gtk_drag_(un)highlight 2020-01-08 18:48:22 -05:00
Matthias Clasen
9c11c60530 filechooser: Remove code for sidebar pre-arming
This is just not a feature we can support currently.
Doing it properly would require infrastructure for
a generalized :drag(sensitive) state highlighting
potential drag sites everywhere.
2020-01-08 18:48:22 -05:00
Matthias Clasen
66c8da4750 listbox: Stop using gtk_drag_(un)highlight
This api is going away, so just do what needs to
be done manually.
2020-01-08 18:48:22 -05:00
Matthias Clasen
05a9b72fc8 calendar: Remove drag highlighting calls
This is happening unconditionally, anyway.
2020-01-08 18:48:22 -05:00
Matthias Clasen
4fe5710456 textview: Remove unnecessary drag highlighting
GTK does this unconditionally anyway, now.
2020-01-08 18:48:22 -05:00
Matthias Clasen
ac5b4a6307 text: Remove unnecessary drag highlighting
GTK does this unconditionally anyway, now.
2020-01-08 18:48:22 -05:00
Matthias Clasen
5ce7bfbbd8 notebook: Receive tab dnd on the tabs
Don't make the whole notebook a drop target
for tab dnd, but just the tab bar. This will
help with drag highlighting, and it arguably
more correct anyway.
2020-01-08 18:48:22 -05:00
Matthias Clasen
7646d1b22c Adwaita: No drag highlight for placessidebar
It does its own custom thing.
2020-01-08 18:48:22 -05:00
Matthias Clasen
61db81ab8e Adwaita: No dnd highlight for iconviews
We only want to highlight the drop location
that is rendered with a separate css node now.
2020-01-08 18:48:22 -05:00
Matthias Clasen
24d7586163 iconview: Use a named subnode for dnd highlight
This is necessary because we want to style the
iconview itself and the item highlighting differently.
2020-01-08 18:48:22 -05:00
Matthias Clasen
b150625105 Adwaita: No dnd highlight for treeviews
We only want to highlight the drop location
that is rendered with a separate css node now.
2020-01-08 18:48:22 -05:00
Matthias Clasen
5787146238 treeview: Use a named subnode for dnd highlight
This is necessary because we want to style the
treeview itself and the row highlighting differently.
2020-01-08 18:48:22 -05:00
Matthias Clasen
8a72031e99 Adwaita: No drag highlight for stack switchers 2020-01-08 18:48:22 -05:00
Matthias Clasen
201a791076 Adwaita: No drag highlight for expanders
This is pretty ugly, because Adwaita has a very
generic drop-highlight implementaiton that we
need to overrule.
2020-01-08 18:48:22 -05:00
Matthias Clasen
359003670a dragdest: Rename ::armed to ::contains 2020-01-08 18:48:22 -05:00
Matthias Clasen
6b7c5174ed gtk-demo: Update the ::prepare handler 2020-01-08 18:48:22 -05:00
Matthias Clasen
8a521accbc dragsource: Change the ::prepare return type
Make it return the content provider to use for
the next drag. This allows just-in-time provision
of the content provider. The default handler just
returns the value of the ::content property.
2020-01-08 18:48:22 -05:00
Matthias Clasen
d116bbf0c8 docs: Expand the GDK dnd docs 2020-01-08 18:48:22 -05:00
Matthias Clasen
42e440a111 docs: Add GtkDragIcon 2020-01-08 18:48:22 -05:00
Matthias Clasen
13adb2591c docs: Add GtkDropTarget section 2020-01-08 18:48:22 -05:00
Matthias Clasen
7b73824dfe docs: Remove dropped drag source apis 2020-01-08 18:48:22 -05:00
Matthias Clasen
403aba82a9 docs: Remove the dnd section
These functions in this section are all gone.
2020-01-08 18:48:22 -05:00
Matthias Clasen
a053d7ddb1 dragsource: Drop gtk_drag_source_drag_begin
No longer used. Also, minor cleanups all over.
2020-01-08 18:48:22 -05:00
Matthias Clasen
c878f650ce dragksource: Small doc fix 2020-01-08 18:48:22 -05:00
Matthias Clasen
2d2cdeae88 Drop GTK content formats apis
These functions have been superseded by better
facilities in GDK.
2020-01-08 18:48:22 -05:00
Matthias Clasen
009228471c testdnd2: Use GDK content formats api 2020-01-08 18:48:22 -05:00
Matthias Clasen
379166e1ff text: Use GDK content formats API 2020-01-08 18:48:22 -05:00
Matthias Clasen
a59a20c1d4 placessidebar: Use GDK content formats api 2020-01-08 18:48:22 -05:00
Matthias Clasen
fb4b5c666b filechooserwidget: Use GDK content formats api: 2020-01-08 18:48:22 -05:00
Matthias Clasen
b59c70aaeb filechooserbutton: Use GDK content formats api 2020-01-08 18:48:22 -05:00
Matthias Clasen
6fcae42dde calendar: Use GDK content formats api 2020-01-08 18:48:22 -05:00
Matthias Clasen
2ee087f25f iconbrowser: Use GDK content formats api 2020-01-08 18:48:22 -05:00
Matthias Clasen
9cc29efa25 gtk-demo: Use GDK content formats api 2020-01-08 18:48:22 -05:00
Matthias Clasen
a04d314910 text: Fix dragging of text across focus changes
When dragging selected text from an entry over a stackswitcher
to show a different page, the focus changes, causing the selection
to be lost; we should not lose the dragged content in this case.
2020-01-08 18:48:22 -05:00
Matthias Clasen
f83f7a2b4d Adwaita: Add drop highlight for iconview items 2020-01-08 18:48:22 -05:00
Matthias Clasen
edb175cf75 iconview: Render drop highlight properly
Use :drop(active) and render a frame, not focus.
2020-01-08 18:48:22 -05:00
Matthias Clasen
1eefaf8b41 dragsource: Fix cancellation
We need to properly end the drag.
2020-01-08 18:48:22 -05:00
Matthias Clasen
0224517806 filechooser: Stop using gtk_drag_source_get_drag 2020-01-08 18:48:22 -05:00
Matthias Clasen
27c521cce8 placessidebar: Update a comment 2020-01-08 18:48:22 -05:00
Matthias Clasen
62b87182c5 Remove an unused enum
We are not using GtkDragResult anymore.
2020-01-08 18:48:22 -05:00
Matthias Clasen
c95659bf32 testdnd2: Update to the api change in the previous commit 2020-01-08 18:48:22 -05:00
Matthias Clasen
865fc9c925 dragsource: Rename ::drag-failed to ::drag-cancel
This matches the names of the GdkDrag signals.
2020-01-08 18:48:22 -05:00
Matthias Clasen
a1f4f52fcb dragsource: Tweak docs more 2020-01-08 18:48:22 -05:00
Matthias Clasen
bdb4bf00c5 dragsource: Document prepare 2020-01-08 18:48:22 -05:00
Matthias Clasen
aca252837d dragsource: Make ::prepare return a boolean
Make ::prepare return TRUE to start a drag.
The default handler simply checks that we
have a content provider and actions.
2020-01-08 18:48:22 -05:00
Matthias Clasen
8b058572f0 dragsource: Drop gtk_drag_get_source 2020-01-08 18:48:22 -05:00
Matthias Clasen
df050c51bb notebook: Stop using gtk_drag_get_source 2020-01-08 18:48:21 -05:00
Matthias Clasen
bd20ae4fa5 dragsource: Drop gtk_drag_source_get_origin 2020-01-08 18:48:21 -05:00
Matthias Clasen
818b456f9f filechooserwidget: Stop using gtk_drag_source_get_origin 2020-01-08 18:48:21 -05:00
Matthias Clasen
c1c8abf275 notebook: Stop using gtk_drag_source_get_origin 2020-01-08 18:48:21 -05:00
Matthias Clasen
c1029535ca testtoolbar: Use gtk_widget_add_controller for drag source 2020-01-08 18:48:21 -05:00
Matthias Clasen
a5ca5eb865 testlist3: Use gtk_widget_add_controller for drag source 2020-01-08 18:48:21 -05:00
Matthias Clasen
2227d2a2b5 testdnd2: Use gtk_widget_add_controller for drag source 2020-01-08 18:48:21 -05:00
Matthias Clasen
61559e38f4 testdnd: Use gtk_widget_add_controller for drag source 2020-01-08 18:48:21 -05:00
Matthias Clasen
134fca47e3 pathbar: Use gtk_widget_add_controller for drag source 2020-01-08 18:48:21 -05:00
Matthias Clasen
4630dd8d68 notebook: Use gtk_widget_add_controller for drag source 2020-01-08 18:48:21 -05:00
Matthias Clasen
d2f7d1b1d7 linkbutton: Use gtk_widget_add_controller for drag source 2020-01-08 18:48:21 -05:00
Matthias Clasen
cfa9e6da4a colorswatch: Use gtk_widget_add_controller for drag source 2020-01-08 18:48:21 -05:00
Matthias Clasen
ceca2f9202 colorbutton: Use gtk_widget_add_controller for drag source 2020-01-08 18:48:21 -05:00
Matthias Clasen
bf98ebcb12 iconbrowser: Use gtk_widget_add_controller for drag source 2020-01-08 18:48:21 -05:00
Matthias Clasen
1a5dece09c gtk-demo: Use gtk_widget_add_controller for drag source 2020-01-08 18:48:21 -05:00
Matthias Clasen
8e8254feae filechooserwidget: wip 2020-01-08 18:48:21 -05:00
Matthias Clasen
90cda9e307 treeview: Use gdk_drag_begin 2020-01-08 18:48:21 -05:00
Matthias Clasen
fdfa371d90 iconview: Use gdk_drag_begin
This is a little more involved here.
2020-01-08 18:48:21 -05:00
Matthias Clasen
deb16c1a00 Make GtkDragSource a gesture 2020-01-08 18:48:21 -05:00
Matthias Clasen
8c3736709e notebook: Use gdk_drag_begin
Use gdk_drag_begin for one-off drags.
2020-01-08 18:48:21 -05:00
Matthias Clasen
f459164f8a placessidebar: Use gdk_drag_begin
Use gdk_drag_begin for one-off drags.
2020-01-08 18:48:21 -05:00
Matthias Clasen
00169a06bf textview: Use gdk_drag_begin
Use gdk_drag_begin for one-off drags.
2020-01-08 18:48:21 -05:00
Matthias Clasen
e09f2b8b56 entry: Use gdk_drag_begin
Use gdk_drag_begin for one-off drags.
2020-01-08 18:48:21 -05:00
Matthias Clasen
092c115ff0 text: Use gdk_drag_begin
Use gdk_drag_begin directly for one-off drags.
2020-01-08 18:48:21 -05:00
Matthias Clasen
5144d15168 calendar: Use gdk_drag_begin
Use gdk_drag_begin directly for one-off drags.
2020-01-08 18:48:21 -05:00
Matthias Clasen
5a6ab8cbd3 label: Use gdk_drag_begin
Use gdk_drag_begin directly for one-off drags.
2020-01-08 18:48:21 -05:00
Matthias Clasen
8c73f882af dragsource: Use public drag icon api 2020-01-08 18:48:21 -05:00
Matthias Clasen
78832c65b5 Make GtkDragIcon public
This is needed if we want to use gdk_drag_begin
for one-off drags, without a GtkDragSource.
2020-01-08 18:48:21 -05:00
Matthias Clasen
e8b830a3dd dragsource: Reshuffle api a bit
Remove arguments from the constructor.

For actions, we now default to COPY, which is the most common one
that we should enable by default (MOVE requires handling deletion
on the the source side, and ASK only makes sense if we have
multiple actions).

For the content provider, we add a new ::prepare signal where
it should be provided just-in-time.
2020-01-08 18:48:21 -05:00
Matthias Clasen
38974d7d2b dragsource: Tweak api, update all callers
Add GdkDrag back to signals, drop ::drag-data-delete,
and replace it with a boolean in ::drag-end.
2020-01-08 18:48:21 -05:00
Carlos Garnacho
f6f331efe3 gdk/x11: Forward suggested action (if any) to XdndStatus
Go ahead with the suggested action, so the drag source may update
cursor feedback properly, and eventually result in the correct
action.
2020-01-08 18:48:21 -05:00
Carlos Garnacho
dbb3727b03 popover: Use g_signal_connect_object on parent widget signal
The popover may be destroyed, leaving this dangling signal. This
may cause crashes on future parent widget resizes.
2020-01-08 18:48:21 -05:00
Matthias Clasen
508570864d Remove gtk_drop_target_get_target
Now that drop targets are event controllers,
we can just use gtk_event_controller_get_widget.
Update all callers.
2020-01-08 18:48:21 -05:00
Matthias Clasen
96c77b61c1 Remove an unused signal 2020-01-08 18:48:21 -05:00
Matthias Clasen
2b819c830b docs: Tweak GtkDropTarget docs 2020-01-08 18:48:21 -05:00
Matthias Clasen
f3be49838f Move code over
Move remaining code from gtkdnd.c to gtkdragdest.c
and nuke gtkdnd.c and gtkdndprivate.h.
2020-01-08 18:48:21 -05:00
Matthias Clasen
e9067ae2db Replace gtk_drop_target_attach/detach
Since drop targets are now just event controller,
gtk_widget_add/remove_controller works just fine
for them.
2020-01-08 18:48:21 -05:00
Matthias Clasen
f898bee032 Use normal event propagation for DND events
This works just fine, now that drop targets are
event controllers. There is only a very vestigial
gtk_drag_dest_handle_event() left that deals with
corner cases.
2020-01-08 18:48:21 -05:00
Matthias Clasen
6a7f39e6d2 Get rid of GtkDragDestInfo
We can just attach the GtkDropTarget directly to
the GdkDrop.
2020-01-08 18:48:21 -05:00
Matthias Clasen
dfb2cbdfdb Turn GtkDropTarget into an event controller
We are still propagating the drag events manually,
but we are now calling gtk_widget_run_controllers
to pass them to drop targets.
2020-01-08 18:48:21 -05:00
Matthias Clasen
f960eb6ab4 More internal restructuring 2020-01-08 18:48:21 -05:00
Matthias Clasen
60fc2c6a7a dnd: Another internal refactoring step 2020-01-08 18:48:21 -05:00
Matthias Clasen
3080592234 gdk: Make gdk_event_set_coords support dnd events
GTK event propagation code relies on this working.
2020-01-08 18:48:21 -05:00
Matthias Clasen
532fdde720 dnd: More internal restructuring 2020-01-08 18:48:21 -05:00
Matthias Clasen
f8399588e9 dnd: Some internal restructuring
Nudge the code towards being like event controllers.
2020-01-08 18:48:20 -05:00
Matthias Clasen
ad019be75b Drop an unused define 2020-01-08 18:48:20 -05:00
Matthias Clasen
e505dab487 Stop passing timestamps around
We were not using these in a useful way in the end,
so stop passing them around.
2020-01-08 18:48:20 -05:00
Matthias Clasen
1262184269 droptarget: Drop the track-motion property
It does not have any effect anymore.

Update all callers
2020-01-08 18:48:20 -05:00
Matthias Clasen
46f42fc53d droptarget: Drop defaults flags
These no longer have any effect.

Update all callers.
2020-01-08 18:48:20 -05:00
Matthias Clasen
cb26cd7391 Simplify some drag dest internals
Change things around to make the default handler
of GtkDropTarget::drag-motion implement the default
handling. Always emit ::drag-motion and ::drag-leave,
and always arm the drop target.

This makes the GTK_DEST_DEFAULT_MOTION flag and
the ::track-motion property unnecessary.

Drop targets that are purely after track-motion
handling for ui switching purposes, such as
GtkStackSwitcher, will have to undo the automatic
arming in a notify::armed handler.
2020-01-08 18:48:20 -05:00
Matthias Clasen
1a3eeb1233 Drop GTK_DEST_DEFAULT_HIGHLIGHT
Redo highlight handling slightly. GtkDropTarget now has
a ::armed property that can be tracked to do custom highlighting,
and we always add the dnd style class to armed drop sites.
2020-01-08 18:48:20 -05:00
Matthias Clasen
e1f74c8f69 dragdest: Clean up internals
Remove the no-longer needed GtkDragDest struct
and just attach the GtkDropTarget directly.
2020-01-08 18:48:20 -05:00
Matthias Clasen
58106af54d testdnd2: Add a test for ASK handling
It is a bit unfortunate that we need to extend the
lifespan of the drop object by keeping our own
ref, but I don't see a better way of doing it.
2020-01-08 18:48:20 -05:00
Matthias Clasen
1e000c3dac Remove gtkdnd.h 2020-01-08 18:48:20 -05:00
Matthias Clasen
19ee9b4c57 Remove gdk_drag_get_data
This is not used anymore, so we can remove it,
and the GtkDropTarget::drag-data-received signal
that it emits.
2020-01-08 18:48:20 -05:00
Matthias Clasen
1075607528 treeview: Stop using ::drag-data-received 2020-01-08 18:48:20 -05:00
Matthias Clasen
d2bd9b0850 iconview: Avoid drag-data-received 2020-01-08 18:48:20 -05:00
Matthias Clasen
74d445636c testtreednd: Use the new asyn selection read 2020-01-08 18:48:20 -05:00
Matthias Clasen
7048790931 testlist3: Use async read api for selection 2020-01-08 18:48:20 -05:00
Matthias Clasen
b9034015d7 filechooser: Convert to GtkDropTarget 2020-01-08 18:48:20 -05:00
Matthias Clasen
c7b70b122a placessidebar: Port to GtkDropTarget 2020-01-08 18:48:20 -05:00
Matthias Clasen
6e01a49d10 iconview: Port to GtkDropTarget
A small api change here is that
gtk_icon_view_enable_model_drag_dest now returns
a GtkDropTarget that can be used to connect signals.
2020-01-08 18:48:20 -05:00
Matthias Clasen
c290bd6367 Add an async read function for selection
This is meant as a replacement for ::drag-data-received
in cases where a #GtkSelectionData object is still needed,
such as when using GtkTreeModel DND support.
2020-01-08 18:48:20 -05:00
Matthias Clasen
853063bea7 Remove old drag dest api 2020-01-08 18:48:20 -05:00
Matthias Clasen
69e3fee5e2 Move some remaining api over 2020-01-08 18:48:20 -05:00
Matthias Clasen
aa276a181e listbox: Remove unhighlighting
This will have to be done differently, if necessary.
2020-01-08 18:48:20 -05:00
Matthias Clasen
583705b4ae notebook: Convert to GtkDropTarget 2020-01-08 18:48:20 -05:00
Matthias Clasen
cd7303d47c testtreednd: Convert to GtkDropTarget 2020-01-08 18:48:20 -05:00
Matthias Clasen
0f9cbf49ac testnotebookdnd: Fix, partially
Make this mostly work again.
2020-01-08 18:48:20 -05:00
Matthias Clasen
a309e74be7 testtoolbar: Convert to GtkDropTarget 2020-01-08 18:48:20 -05:00
Matthias Clasen
ccaf70e1b7 testlist3: Convert to GtkDropTarget 2020-01-08 18:48:20 -05:00
Matthias Clasen
2fd9431f23 testdnd: Convert to GtkDropTarget 2020-01-08 18:48:20 -05:00
Matthias Clasen
3f33a0ed27 testdnd2: Port to GtkDropTarget 2020-01-08 18:48:20 -05:00
Matthias Clasen
4ea18a22e6 treeview: Port to GtkDropTarget
A small api change here is that
gtk_tree_view_enable_model_drag_dest now returns
a GtkDropTarget that can be used to connect signals.
2020-01-08 18:48:20 -05:00
Matthias Clasen
746dc5c3a2 textview: Port to GtkDropTarget 2020-01-08 18:48:20 -05:00
Matthias Clasen
17131f1137 filechoserbutton: Convert to GtkDropTarget 2020-01-08 18:48:20 -05:00
Matthias Clasen
07c889c5ea stackswitcher: Port to GtkDropTarget 2020-01-08 18:48:20 -05:00
Matthias Clasen
b0d9a6ff20 expander: Port to GtkDropTarget 2020-01-08 18:48:20 -05:00
Matthias Clasen
802c7975e2 window: Port to GtkDragDest 2020-01-08 18:48:20 -05:00
Matthias Clasen
6e602e052b text: Port to GtkDropTarget 2020-01-08 18:48:20 -05:00
Matthias Clasen
025eee112c colorswatch: Port to GtkDropTarget 2020-01-08 18:48:20 -05:00
Matthias Clasen
70cdd4e951 colorbutton: Port to GtkDropTarget 2020-01-08 18:48:20 -05:00
Matthias Clasen
75b789f20f calendar: Port to GtkDropTarget 2020-01-08 18:48:20 -05:00
Matthias Clasen
ac09500d74 gtk-demo: Convert clipboard demo to GtkDropTarget 2020-01-08 18:48:20 -05:00
Matthias Clasen
a76b187a5b drop: Add a convenience api
This is a question that drag-drop handlers frequently
need to answer, so make it easy.
2020-01-08 18:48:20 -05:00
Matthias Clasen
45679d7bc3 dragdest: doc improvements 2020-01-08 18:48:20 -05:00
Matthias Clasen
6dc8fc3a4d Add a GtkDropTarget object
Add an explicit GtkDropTarget object, and move the destination-side
DND signals here. The object is used by connecting to its signals
and attaching it to a widget with gtk_drop_target_attach().
2020-01-08 18:48:20 -05:00
Matthias Clasen
e53e0f461e Hook up the GtkDragSource docs 2020-01-08 18:48:20 -05:00
Matthias Clasen
37b849b808 Move the rest of the drag-source api over
Just reshuffling some source.
2020-01-08 18:48:20 -05:00
Matthias Clasen
e03bdbe307 docs: Mention DND in the migration guide 2020-01-08 18:48:20 -05:00
Matthias Clasen
9b01d9a784 Remove traditional drag source API
gtk_drag_source_set, gtk_drag_begin, related apis
and the GtkWidget source-side signals have all been
replaced by GtkDragSource.
2020-01-08 18:48:20 -05:00
Matthias Clasen
b4c689ecd6 tests: Convert to GtkDragSource
Some tests, such as testimage did not have
anything particularly worth keeping, so
were removed instead of fixed.
2020-01-08 18:48:19 -05:00
Matthias Clasen
78a0913f0f notebook: Port to GtkDragSource 2020-01-08 18:48:19 -05:00
Matthias Clasen
74722fb10e filechooser: Port to GtkDragSource 2020-01-08 18:48:19 -05:00
Matthias Clasen
3891ce36fe treeview: Port to GtkDragSource
A small api change here is that
gtk_tree_view_enable_model_drag_source now returns
a GtkDragSource that can be used to connect signals.
2020-01-08 18:48:19 -05:00
Matthias Clasen
5a940408fe placessidebar: Port to GtkDragSource 2020-01-08 18:48:19 -05:00
Matthias Clasen
efce8c2899 iconview: Port to GtkDragSource
A small api change here is that
gtk_icon_view_enable_model_drag_source now returns
a GtkDragSource that can be used to connect signals.
2020-01-08 18:48:19 -05:00
Matthias Clasen
ea9f2abcc4 Add another callback-based provider
This one can be used in cases where data needs
to be served in multiple formats that may not
all be covered by content serializers.
2020-01-08 18:48:19 -05:00
Matthias Clasen
993d6388ee iconbrowser: Port to GtkDragSource 2020-01-08 18:48:19 -05:00
Matthias Clasen
5ad4b75ae2 gtk-demo: Convert the clipboard demo to GtkDragSource 2020-01-08 18:48:19 -05:00
Matthias Clasen
24ef9df0f1 pathbar: Convert to GtkDragSource 2020-01-08 18:48:19 -05:00
Matthias Clasen
5d49b11ffd colorswatch: Convert to GtkDragSource 2020-01-08 18:48:19 -05:00
Matthias Clasen
8e3db48482 colorbutton: Port to GtkDragSource 2020-01-08 18:48:19 -05:00
Matthias Clasen
fdcfe0e80a Add a generic callback content provider
This one is convenient to use in cases where a
drag is just serving an existing GType which
is covered by content serializers.
2020-01-08 18:48:19 -05:00
Matthias Clasen
8137dea8c1 Add (de)serializers for GdkRGBA
This is a format that we use in various
color picker widgets, so support it in GDK.
2020-01-08 18:48:19 -05:00
Matthias Clasen
b15c31a3f7 textview: Port to GtkDragSource 2020-01-08 18:48:19 -05:00
Matthias Clasen
a52757874e textbuffer: Add a content provider api
We need a content provider for the selection,
to implement DND, and the text buffer already
has one. Just add an api to get it.
2020-01-08 18:48:19 -05:00
Matthias Clasen
e9203eeef7 text: Convert to GtkDragSource 2020-01-08 18:48:19 -05:00
Matthias Clasen
337057eb35 entry: Port icon dnd to GtkDragSource
This requires a small change in the api,
since we need to provide a GdkContentProvider now.
2020-01-08 18:48:19 -05:00
Matthias Clasen
2803a15a51 calendar: Port to GtkDragSource 2020-01-08 18:48:19 -05:00
Matthias Clasen
d145032cb6 linkbutton: Port to GtkDragSource 2020-01-08 18:48:19 -05:00
Matthias Clasen
2612331282 label: Port to GtkDragSource 2020-01-08 18:48:19 -05:00
Matthias Clasen
d3fd071809 dnd: Patch up gtk_drag_get_source_widget
This is temporary until gtk_drag_dest_set users
have been ported over.
2020-01-08 18:48:19 -05:00
Matthias Clasen
303c9becf8 Add a GtkDragSource object
Add an explicit GtkDragSource object, and move the source-side
DND signals here. The object can be used on the spot, by calling
gtk_drag_source_drag_begin() yourself, or for static drag-source
configuration, by calling gtk_drag_source_attach(). In the latter
case, we set up and conect a drag gesture to trigger the drag_begin
call.
2020-01-08 18:48:19 -05:00
Matthias Clasen
6bf46c8f30 marshalers: Add another 2020-01-08 18:48:19 -05:00
280 changed files with 27638 additions and 12410 deletions

62
atk/atk.h Normal file
View File

@@ -0,0 +1,62 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_H__
#define __ATK_H__
#define __ATK_H_INSIDE__
#include <atk/atktypes.h>
#include <atk/atkobject.h>
#include <atk/atkaction.h>
#include <atk/atkcomponent.h>
#include <atk/atkdocument.h>
#include <atk/atkeditabletext.h>
#include <atk/atkenums.h>
#include <atk/atkgobjectaccessible.h>
#include <atk/atkhyperlink.h>
#include <atk/atkhyperlinkimpl.h>
#include <atk/atkhypertext.h>
#include <atk/atkimage.h>
#include <atk/atknoopobject.h>
#include <atk/atknoopobjectfactory.h>
#include <atk/atkobjectfactory.h>
#include <atk/atkplug.h>
#include <atk/atkrange.h>
#include <atk/atkregistry.h>
#include <atk/atkrelation.h>
#include <atk/atkrelationset.h>
#include <atk/atkselection.h>
#include <atk/atksocket.h>
#include <atk/atkstate.h>
#include <atk/atkstateset.h>
#include <atk/atkstreamablecontent.h>
#include <atk/atktable.h>
#include <atk/atktablecell.h>
#include <atk/atktext.h>
#include <atk/atkutil.h>
#include <atk/atkvalue.h>
#include <atk/atkwindow.h>
#include <atk/atkenumtypes.h>
#undef __ATK_H_INSIDE__
#endif /* __ATK_H__ */

286
atk/atkaction.c Normal file
View File

@@ -0,0 +1,286 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "atkaction.h"
/**
* SECTION:atkaction
* @Short_description: The ATK interface provided by UI components
* which the user can activate/interact with.
* @Title:AtkAction
*
* #AtkAction should be implemented by instances of #AtkObject classes
* with which the user can interact directly, i.e. buttons,
* checkboxes, scrollbars, e.g. components which are not "passive"
* providers of UI information.
*
* Exceptions: when the user interaction is already covered by another
* appropriate interface such as #AtkEditableText (insert/delete text,
* etc.) or #AtkValue (set value) then these actions should not be
* exposed by #AtkAction as well.
*
* Though most UI interactions on components should be invocable via
* keyboard as well as mouse, there will generally be a close mapping
* between "mouse actions" that are possible on a component and the
* AtkActions. Where mouse and keyboard actions are redundant in
* effect, #AtkAction should expose only one action rather than
* exposing redundant actions if possible. By convention we have been
* using "mouse centric" terminology for #AtkAction names.
*
*/
GType
atk_action_get_type (void)
{
static GType type = 0;
if (!type) {
GTypeInfo tinfo =
{
sizeof (AtkActionIface),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
};
type = g_type_register_static (G_TYPE_INTERFACE, "AtkAction", &tinfo, 0);
}
return type;
}
/**
* atk_action_do_action:
* @action: a #GObject instance that implements AtkActionIface
* @i: the action index corresponding to the action to be performed
*
* Perform the specified action on the object.
*
* Returns: %TRUE if success, %FALSE otherwise
*
**/
gboolean
atk_action_do_action (AtkAction *obj,
gint i)
{
AtkActionIface *iface;
g_return_val_if_fail (ATK_IS_ACTION (obj), FALSE);
iface = ATK_ACTION_GET_IFACE (obj);
if (iface->do_action)
return (iface->do_action) (obj, i);
else
return FALSE;
}
/**
* atk_action_get_n_actions:
* @action: a #GObject instance that implements AtkActionIface
*
* Gets the number of accessible actions available on the object.
* If there are more than one, the first one is considered the
* "default" action of the object.
*
* Returns: a the number of actions, or 0 if @action does not
* implement this interface.
**/
gint
atk_action_get_n_actions (AtkAction *obj)
{
AtkActionIface *iface;
g_return_val_if_fail (ATK_IS_ACTION (obj), 0);
iface = ATK_ACTION_GET_IFACE (obj);
if (iface->get_n_actions)
return (iface->get_n_actions) (obj);
else
return 0;
}
/**
* atk_action_get_description:
* @action: a #GObject instance that implements AtkActionIface
* @i: the action index corresponding to the action to be performed
*
* Returns a description of the specified action of the object.
*
* Returns: (nullable): a description string, or %NULL if @action does
* not implement this interface.
**/
const gchar*
atk_action_get_description (AtkAction *obj,
gint i)
{
AtkActionIface *iface;
g_return_val_if_fail (ATK_IS_ACTION (obj), NULL);
iface = ATK_ACTION_GET_IFACE (obj);
if (iface->get_description)
return (iface->get_description) (obj, i);
else
return NULL;
}
/**
* atk_action_get_name:
* @action: a #GObject instance that implements AtkActionIface
* @i: the action index corresponding to the action to be performed
*
* Returns a non-localized string naming the specified action of the
* object. This name is generally not descriptive of the end result
* of the action, but instead names the 'interaction type' which the
* object supports. By convention, the above strings should be used to
* represent the actions which correspond to the common point-and-click
* interaction techniques of the same name: i.e.
* "click", "press", "release", "drag", "drop", "popup", etc.
* The "popup" action should be used to pop up a context menu for the
* object, if one exists.
*
* For technical reasons, some toolkits cannot guarantee that the
* reported action is actually 'bound' to a nontrivial user event;
* i.e. the result of some actions via atk_action_do_action() may be
* NIL.
*
* Returns: (nullable): a name string, or %NULL if @action does not
* implement this interface.
**/
const gchar*
atk_action_get_name (AtkAction *obj,
gint i)
{
AtkActionIface *iface;
g_return_val_if_fail (ATK_IS_ACTION (obj), NULL);
iface = ATK_ACTION_GET_IFACE (obj);
if (iface->get_name)
return (iface->get_name) (obj, i);
else
return NULL;
}
/**
* atk_action_get_localized_name:
* @action: a #GObject instance that implements AtkActionIface
* @i: the action index corresponding to the action to be performed
*
* Returns the localized name of the specified action of the object.
*
* Returns: (nullable): a name string, or %NULL if @action does not
* implement this interface.
**/
const gchar*
atk_action_get_localized_name (AtkAction *obj,
gint i)
{
AtkActionIface *iface;
g_return_val_if_fail (ATK_IS_ACTION (obj), NULL);
iface = ATK_ACTION_GET_IFACE (obj);
if (iface->get_localized_name)
return (iface->get_localized_name) (obj, i);
else
return NULL;
}
/**
* atk_action_get_keybinding:
* @action: a #GObject instance that implements AtkActionIface
* @i: the action index corresponding to the action to be performed
*
* Gets the keybinding which can be used to activate this action, if one
* exists. The string returned should contain localized, human-readable,
* key sequences as they would appear when displayed on screen. It must
* be in the format "mnemonic;sequence;shortcut".
*
* - The mnemonic key activates the object if it is presently enabled onscreen.
* This typically corresponds to the underlined letter within the widget.
* Example: "n" in a traditional "New..." menu item or the "a" in "Apply" for
* a button.
* - The sequence is the full list of keys which invoke the action even if the
* relevant element is not currently shown on screen. For instance, for a menu
* item the sequence is the keybindings used to open the parent menus before
* invoking. The sequence string is colon-delimited. Example: "Alt+F:N" in a
* traditional "New..." menu item.
* - The shortcut, if it exists, will invoke the same action without showing
* the component or its enclosing menus or dialogs. Example: "Ctrl+N" in a
* traditional "New..." menu item.
*
* Example: For a traditional "New..." menu item, the expected return value
* would be: "N;Alt+F:N;Ctrl+N" for the English locale and "N;Alt+D:N;Strg+N"
* for the German locale. If, hypothetically, this menu item lacked a mnemonic,
* it would be represented by ";;Ctrl+N" and ";;Strg+N" respectively.
*
* Returns: (nullable): the keybinding which can be used to activate
* this action, or %NULL if there is no keybinding for this action.
*
**/
const gchar*
atk_action_get_keybinding (AtkAction *obj,
gint i)
{
AtkActionIface *iface;
g_return_val_if_fail (ATK_IS_ACTION (obj), NULL);
iface = ATK_ACTION_GET_IFACE (obj);
if (iface->get_keybinding)
return (iface->get_keybinding) (obj, i);
else
return NULL;
}
/**
* atk_action_set_description:
* @action: a #GObject instance that implements AtkActionIface
* @i: the action index corresponding to the action to be performed
* @desc: the description to be assigned to this action
*
* Sets a description of the specified action of the object.
*
* Returns: a gboolean representing if the description was successfully set;
**/
gboolean
atk_action_set_description (AtkAction *obj,
gint i,
const gchar *desc)
{
AtkActionIface *iface;
g_return_val_if_fail (ATK_IS_ACTION (obj), FALSE);
iface = ATK_ACTION_GET_IFACE (obj);
if (iface->set_description)
return (iface->set_description) (obj, i, desc);
else
return FALSE;
}

130
atk/atkaction.h Normal file
View File

@@ -0,0 +1,130 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_ACTION_H__
#define __ATK_ACTION_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <atk/atktypes.h>
G_BEGIN_DECLS
/*
*/
#define ATK_TYPE_ACTION (atk_action_get_type ())
#define ATK_IS_ACTION(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_ACTION)
#define ATK_ACTION(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_ACTION, AtkAction)
#define ATK_ACTION_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_ACTION, AtkActionIface))
#ifndef _TYPEDEF_ATK_ACTION_
#define _TYPEDEF_ATK_ACTION_
typedef struct _AtkAction AtkAction;
#endif
typedef struct _AtkActionIface AtkActionIface;
/**
* AtkActionIface:
* @do_action:
* @get_n_actions:
* @get_description:
* @get_name:
* @get_keybinding:
* @set_description:
* @get_localized_name:
*
* The #AtkAction interface should be supported by any object that can
* perform one or more actions. The interface provides the standard
* mechanism for an assistive technology to determine what those actions
* are as well as tell the object to perform them. Any object that can
* be manipulated should support this interface.
*/
struct _AtkActionIface
{
/*< private >*/
GTypeInterface parent;
/*< public >*/
gboolean (*do_action) (AtkAction *action,
gint i);
gint (*get_n_actions) (AtkAction *action);
const gchar* (*get_description) (AtkAction *action,
gint i);
const gchar* (*get_name) (AtkAction *action,
gint i);
const gchar* (*get_keybinding) (AtkAction *action,
gint i);
gboolean (*set_description) (AtkAction *action,
gint i,
const gchar *desc);
const gchar* (*get_localized_name)(AtkAction *action,
gint i);
};
GDK_AVAILABLE_IN_ALL
GType atk_action_get_type (void);
/*
* These are the function which would be called by an application with
* the argument being a AtkObject object cast to (AtkAction).
*
* The function will just check that * the corresponding
* function pointer is not NULL and will call it.
*
* The "real" implementation of the function for accessible will be
* provided in a support library
*/
GDK_AVAILABLE_IN_ALL
gboolean atk_action_do_action (AtkAction *action,
gint i);
GDK_AVAILABLE_IN_ALL
gint atk_action_get_n_actions (AtkAction *action);
GDK_AVAILABLE_IN_ALL
const gchar* atk_action_get_description (AtkAction *action,
gint i);
GDK_AVAILABLE_IN_ALL
const gchar* atk_action_get_name (AtkAction *action,
gint i);
GDK_AVAILABLE_IN_ALL
const gchar* atk_action_get_keybinding (AtkAction *action,
gint i);
GDK_AVAILABLE_IN_ALL
gboolean atk_action_set_description (AtkAction *action,
gint i,
const gchar *desc);
/* NEW in ATK 1.1: */
GDK_AVAILABLE_IN_ALL
const gchar* atk_action_get_localized_name (AtkAction *action,
gint i);
/*
* Additional GObject properties exported by AtkAction:
* "accessible_action"
* (an accessible action, or the list of actions, has changed)
*/
G_END_DECLS
#endif /* __ATK_ACTION_H__ */

598
atk/atkcomponent.c Normal file
View File

@@ -0,0 +1,598 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "atkcomponent.h"
/**
* SECTION:atkcomponent
* @Short_description: The ATK interface provided by UI components
* which occupy a physical area on the screen.
* which the user can activate/interact with.
* @Title:AtkComponent
*
* #AtkComponent should be implemented by most if not all UI elements
* with an actual on-screen presence, i.e. components which can be
* said to have a screen-coordinate bounding box. Virtually all
* widgets will need to have #AtkComponent implementations provided
* for their corresponding #AtkObject class. In short, only UI
* elements which are *not* GUI elements will omit this ATK interface.
*
* A possible exception might be textual information with a
* transparent background, in which case text glyph bounding box
* information is provided by #AtkText.
*/
enum {
BOUNDS_CHANGED,
LAST_SIGNAL
};
static void atk_component_base_init (AtkComponentIface *class);
static gboolean atk_component_real_contains (AtkComponent *component,
gint x,
gint y,
AtkCoordType coord_type);
static AtkObject* atk_component_real_ref_accessible_at_point (AtkComponent *component,
gint x,
gint y,
AtkCoordType coord_type);
static void atk_component_real_get_position (AtkComponent *component,
gint *x,
gint *y,
AtkCoordType coord_type);
static void atk_component_real_get_size (AtkComponent *component,
gint *width,
gint *height);
static guint atk_component_signals[LAST_SIGNAL] = { 0 };
GType
atk_component_get_type (void)
{
static GType type = 0;
if (!type) {
static const GTypeInfo tinfo =
{
sizeof (AtkComponentIface),
(GBaseInitFunc) atk_component_base_init,
(GBaseFinalizeFunc) NULL,
};
type = g_type_register_static (G_TYPE_INTERFACE, "AtkComponent", &tinfo, 0);
}
return type;
}
static void
atk_component_base_init (AtkComponentIface *class)
{
static gboolean initialized = FALSE;
if (! initialized)
{
class->ref_accessible_at_point = atk_component_real_ref_accessible_at_point;
class->contains = atk_component_real_contains;
class->get_position = atk_component_real_get_position;
class->get_size = atk_component_real_get_size;
/**
* AtkComponent::bounds-changed:
* @atkcomponent: the object which received the signal.
* @arg1: The AtkRectangle giving the new position and size.
*
* The 'bounds-changed" signal is emitted when the bposition or
* size of the component changes.
*/
atk_component_signals[BOUNDS_CHANGED] =
g_signal_new ("bounds_changed",
ATK_TYPE_COMPONENT,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (AtkComponentIface, bounds_changed),
(GSignalAccumulator) NULL, NULL,
g_cclosure_marshal_VOID__BOXED,
G_TYPE_NONE, 1,
ATK_TYPE_RECTANGLE | G_SIGNAL_TYPE_STATIC_SCOPE);
initialized = TRUE;
}
}
/**
* atk_component_contains:
* @component: the #AtkComponent
* @x: x coordinate
* @y: y coordinate
* @coord_type: specifies whether the coordinates are relative to the screen
* or to the components top level window
*
* Checks whether the specified point is within the extent of the @component.
*
* Toolkit implementor note: ATK provides a default implementation for
* this virtual method. In general there are little reason to
* re-implement it.
*
* Returns: %TRUE or %FALSE indicating whether the specified point is within
* the extent of the @component or not
**/
gboolean
atk_component_contains (AtkComponent *component,
gint x,
gint y,
AtkCoordType coord_type)
{
AtkComponentIface *iface = NULL;
g_return_val_if_fail (ATK_IS_COMPONENT (component), FALSE);
iface = ATK_COMPONENT_GET_IFACE (component);
if (iface->contains)
return (iface->contains) (component, x, y, coord_type);
else
return FALSE;
}
/**
* atk_component_ref_accessible_at_point:
* @component: the #AtkComponent
* @x: x coordinate
* @y: y coordinate
* @coord_type: specifies whether the coordinates are relative to the screen
* or to the components top level window
*
* Gets a reference to the accessible child, if one exists, at the
* coordinate point specified by @x and @y.
*
* Returns: (nullable) (transfer full): a reference to the accessible
* child, if one exists
**/
AtkObject*
atk_component_ref_accessible_at_point (AtkComponent *component,
gint x,
gint y,
AtkCoordType coord_type)
{
AtkComponentIface *iface = NULL;
g_return_val_if_fail (ATK_IS_COMPONENT (component), NULL);
iface = ATK_COMPONENT_GET_IFACE (component);
if (iface->ref_accessible_at_point)
return (iface->ref_accessible_at_point) (component, x, y, coord_type);
else
return NULL;
}
/**
* atk_component_get_extents:
* @component: an #AtkComponent
* @x: (out) (optional): address of #gint to put x coordinate
* @y: (out) (optional): address of #gint to put y coordinate
* @width: (out) (optional): address of #gint to put width
* @height: (out) (optional): address of #gint to put height
* @coord_type: specifies whether the coordinates are relative to the screen
* or to the components top level window
*
* Gets the rectangle which gives the extent of the @component.
*
* If the extent can not be obtained (e.g. a non-embedded plug or missing
* support), all of x, y, width, height are set to -1.
*
**/
void
atk_component_get_extents (AtkComponent *component,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coord_type)
{
AtkComponentIface *iface = NULL;
gint local_x, local_y, local_width, local_height;
gint *real_x, *real_y, *real_width, *real_height;
g_return_if_fail (ATK_IS_COMPONENT (component));
if (x)
real_x = x;
else
real_x = &local_x;
if (y)
real_y = y;
else
real_y = &local_y;
if (width)
real_width = width;
else
real_width = &local_width;
if (height)
real_height = height;
else
real_height = &local_height;
iface = ATK_COMPONENT_GET_IFACE (component);
if (iface->get_extents)
(iface->get_extents) (component, real_x, real_y, real_width, real_height, coord_type);
else
{
*real_x = -1;
*real_y = -1;
*real_width = -1;
*real_height = -1;
}
}
/**
* atk_component_get_layer:
* @component: an #AtkComponent
*
* Gets the layer of the component.
*
* Returns: an #AtkLayer which is the layer of the component
**/
AtkLayer
atk_component_get_layer (AtkComponent *component)
{
AtkComponentIface *iface;
g_return_val_if_fail (ATK_IS_COMPONENT (component), ATK_LAYER_INVALID);
iface = ATK_COMPONENT_GET_IFACE (component);
if (iface->get_layer)
return (iface->get_layer) (component);
else
return ATK_LAYER_WIDGET;
}
/**
* atk_component_get_mdi_zorder:
* @component: an #AtkComponent
*
* Gets the zorder of the component. The value G_MININT will be returned
* if the layer of the component is not ATK_LAYER_MDI or ATK_LAYER_WINDOW.
*
* Returns: a gint which is the zorder of the component, i.e. the depth at
* which the component is shown in relation to other components in the same
* container.
**/
gint
atk_component_get_mdi_zorder (AtkComponent *component)
{
AtkComponentIface *iface;
g_return_val_if_fail (ATK_IS_COMPONENT (component), G_MININT);
iface = ATK_COMPONENT_GET_IFACE (component);
if (iface->get_mdi_zorder)
return (iface->get_mdi_zorder) (component);
else
return G_MININT;
}
/**
* atk_component_get_alpha:
* @component: an #AtkComponent
*
* Returns the alpha value (i.e. the opacity) for this
* @component, on a scale from 0 (fully transparent) to 1.0
* (fully opaque).
*
* Returns: An alpha value from 0 to 1.0, inclusive.
* Since: 1.12
**/
gdouble
atk_component_get_alpha (AtkComponent *component)
{
AtkComponentIface *iface;
g_return_val_if_fail (ATK_IS_COMPONENT (component), G_MININT);
iface = ATK_COMPONENT_GET_IFACE (component);
if (iface->get_alpha)
return (iface->get_alpha) (component);
else
return (gdouble) 1.0;
}
/**
* atk_component_grab_focus:
* @component: an #AtkComponent
*
* Grabs focus for this @component.
*
* Returns: %TRUE if successful, %FALSE otherwise.
**/
gboolean
atk_component_grab_focus (AtkComponent *component)
{
AtkComponentIface *iface = NULL;
g_return_val_if_fail (ATK_IS_COMPONENT (component), FALSE);
iface = ATK_COMPONENT_GET_IFACE (component);
if (iface->grab_focus)
return (iface->grab_focus) (component);
else
return FALSE;
}
/**
* atk_component_set_extents:
* @component: an #AtkComponent
* @x: x coordinate
* @y: y coordinate
* @width: width to set for @component
* @height: height to set for @component
* @coord_type: specifies whether the coordinates are relative to the screen
* or to the components top level window
*
* Sets the extents of @component.
*
* Returns: %TRUE or %FALSE whether the extents were set or not
**/
gboolean
atk_component_set_extents (AtkComponent *component,
gint x,
gint y,
gint width,
gint height,
AtkCoordType coord_type)
{
AtkComponentIface *iface = NULL;
g_return_val_if_fail (ATK_IS_COMPONENT (component), FALSE);
iface = ATK_COMPONENT_GET_IFACE (component);
if (iface->set_extents)
return (iface->set_extents) (component, x, y, width, height, coord_type);
else
return FALSE;
}
/**
* atk_component_set_position:
* @component: an #AtkComponent
* @x: x coordinate
* @y: y coordinate
* @coord_type: specifies whether the coordinates are relative to the screen
* or to the component's top level window
*
* Sets the position of @component.
*
* Contrary to atk_component_scroll_to, this does not trigger any scrolling,
* this just moves @component in its parent.
*
* Returns: %TRUE or %FALSE whether or not the position was set or not
**/
gboolean
atk_component_set_position (AtkComponent *component,
gint x,
gint y,
AtkCoordType coord_type)
{
AtkComponentIface *iface = NULL;
g_return_val_if_fail (ATK_IS_COMPONENT (component), FALSE);
iface = ATK_COMPONENT_GET_IFACE (component);
if (iface->set_position)
return (iface->set_position) (component, x, y, coord_type);
else
return FALSE;
}
/**
* atk_component_set_size:
* @component: an #AtkComponent
* @width: width to set for @component
* @height: height to set for @component
*
* Set the size of the @component in terms of width and height.
*
* Returns: %TRUE or %FALSE whether the size was set or not
**/
gboolean
atk_component_set_size (AtkComponent *component,
gint x,
gint y)
{
AtkComponentIface *iface = NULL;
g_return_val_if_fail (ATK_IS_COMPONENT (component), FALSE);
iface = ATK_COMPONENT_GET_IFACE (component);
if (iface->set_size)
return (iface->set_size) (component, x, y);
else
return FALSE;
}
/**
* atk_component_scroll_to:
* @component: an #AtkComponent
* @type: specify where the object should be made visible.
*
* Makes @component visible on the screen by scrolling all necessary parents.
*
* Contrary to atk_component_set_position, this does not actually move
* @component in its parent, this only makes the parents scroll so that the
* object shows up on the screen, given its current position within the parents.
*
* Returns: whether scrolling was successful.
*
* Since: 2.30
*/
gboolean
atk_component_scroll_to (AtkComponent *component,
AtkScrollType type)
{
AtkComponentIface *iface = NULL;
g_return_val_if_fail (ATK_IS_COMPONENT (component), FALSE);
iface = ATK_COMPONENT_GET_IFACE (component);
if (iface->scroll_to)
return (iface->scroll_to) (component, type);
return FALSE;
}
/**
* atk_component_scroll_to_point:
* @component: an #AtkComponent
* @coords: specify whether coordinates are relative to the screen or to the
* parent object.
* @x: x-position where to scroll to
* @y: y-position where to scroll to
*
* Move the top-left of @component to a given position of the screen by
* scrolling all necessary parents.
*
* Returns: whether scrolling was successful.
*
* Since: 2.30
*/
gboolean
atk_component_scroll_to_point (AtkComponent *component,
AtkCoordType coords,
gint x,
gint y)
{
AtkComponentIface *iface = NULL;
g_return_val_if_fail (ATK_IS_COMPONENT (component), FALSE);
iface = ATK_COMPONENT_GET_IFACE (component);
if (iface->scroll_to_point)
return (iface->scroll_to_point) (component, coords, x, y);
return FALSE;
}
static gboolean
atk_component_real_contains (AtkComponent *component,
gint x,
gint y,
AtkCoordType coord_type)
{
gint real_x, real_y, width, height;
real_x = real_y = width = height = 0;
atk_component_get_extents (component, &real_x, &real_y, &width, &height, coord_type);
if ((x >= real_x) &&
(x < real_x + width) &&
(y >= real_y) &&
(y < real_y + height))
return TRUE;
else
return FALSE;
}
static AtkObject*
atk_component_real_ref_accessible_at_point (AtkComponent *component,
gint x,
gint y,
AtkCoordType coord_type)
{
gint count, i;
count = atk_object_get_n_accessible_children (ATK_OBJECT (component));
for (i = 0; i < count; i++)
{
AtkObject *obj;
obj = atk_object_ref_accessible_child (ATK_OBJECT (component), i);
if (obj != NULL)
{
if (atk_component_contains (ATK_COMPONENT (obj), x, y, coord_type))
{
return obj;
}
else
{
g_object_unref (obj);
}
}
}
return NULL;
}
static void
atk_component_real_get_position (AtkComponent *component,
gint *x,
gint *y,
AtkCoordType coord_type)
{
gint width, height;
atk_component_get_extents (component, x, y, &width, &height, coord_type);
}
static void
atk_component_real_get_size (AtkComponent *component,
gint *width,
gint *height)
{
gint x, y;
AtkCoordType coord_type;
/*
* Pick one coordinate type; it does not matter for size
*/
coord_type = ATK_XY_WINDOW;
atk_component_get_extents (component, &x, &y, width, height, coord_type);
}
static AtkRectangle *
atk_rectangle_copy (const AtkRectangle *rectangle)
{
AtkRectangle *result = g_new (AtkRectangle, 1);
*result = *rectangle;
return result;
}
GType
atk_rectangle_get_type (void)
{
static GType our_type = 0;
if (our_type == 0)
our_type = g_boxed_type_register_static ("AtkRectangle",
(GBoxedCopyFunc)atk_rectangle_copy,
(GBoxedFreeFunc)g_free);
return our_type;
}

232
atk/atkcomponent.h Normal file
View File

@@ -0,0 +1,232 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_COMPONENT_H__
#define __ATK_COMPONENT_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <atk/atktypes.h>
#include <atk/atkobject.h>
G_BEGIN_DECLS
#define ATK_TYPE_COMPONENT (atk_component_get_type ())
#define ATK_IS_COMPONENT(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_COMPONENT)
#define ATK_COMPONENT(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_COMPONENT, AtkComponent)
#define ATK_COMPONENT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_COMPONENT, AtkComponentIface))
#ifndef _TYPEDEF_ATK_COMPONENT_
#define _TYPEDEF_ATK_COMPONENT_
typedef struct _AtkComponent AtkComponent;
#endif
typedef struct _AtkComponentIface AtkComponentIface;
typedef struct _AtkRectangle AtkRectangle;
/**
* AtkRectangle:
* @x: X coordinate of the left side of the rectangle.
* @y: Y coordinate of the top side of the rectangle.
* @width: width of the rectangle.
* @height: height of the rectangle.
*
* A data structure for holding a rectangle. Those coordinates are
* relative to the component top-level parent.
*/
struct _AtkRectangle
{
gint x;
gint y;
gint width;
gint height;
};
GDK_AVAILABLE_IN_ALL
GType atk_rectangle_get_type (void);
#define ATK_TYPE_RECTANGLE (atk_rectangle_get_type ())
/**
* AtkComponentIface:
* @add_focus_handler: This virtual function is deprecated since 2.9.4
* and it should not be overriden. See atk_component_add_focus_handler()
* for more information.
* @get_position: This virtual function is deprecated since 2.12 and
* it should not be overriden. Use @AtkComponentIface.get_extents instead.
* @get_size: This virtual function is deprecated since 2.12 and it
* should not be overriden. Use @AtkComponentIface.get_extents instead.
* @remove_focus_handler: This virtual function is deprecated since
* 2.9.4 and it should not be overriden. See atk_component_remove_focus_handler()
* for more information.
* @contains:
* @ref_accessible_at_point:
* @get_extents:
* @grab_focus:
* @set_extents:
* @set_position:
* @set_size:
* @get_layer:
* @get_mdi_zorder:
* @bounds_changed:
* @get_alpha:
* @scroll_to:
* @scroll_to_point:
*
* The AtkComponent interface should be supported by any object that is
* rendered on the screen. The interface provides the standard mechanism
* for an assistive technology to determine and set the graphical
* representation of an object.
*/
struct _AtkComponentIface
{
/*< private >*/
GTypeInterface parent;
/*< public >*/
gboolean (* contains) (AtkComponent *component,
gint x,
gint y,
AtkCoordType coord_type);
AtkObject* (* ref_accessible_at_point) (AtkComponent *component,
gint x,
gint y,
AtkCoordType coord_type);
void (* get_extents) (AtkComponent *component,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coord_type);
void (* get_position) (AtkComponent *component,
gint *x,
gint *y,
AtkCoordType coord_type);
void (* get_size) (AtkComponent *component,
gint *width,
gint *height);
gboolean (* grab_focus) (AtkComponent *component);
void (* remove_focus_handler) (AtkComponent *component,
guint handler_id);
gboolean (* set_extents) (AtkComponent *component,
gint x,
gint y,
gint width,
gint height,
AtkCoordType coord_type);
gboolean (* set_position) (AtkComponent *component,
gint x,
gint y,
AtkCoordType coord_type);
gboolean (* set_size) (AtkComponent *component,
gint width,
gint height);
AtkLayer (* get_layer) (AtkComponent *component);
gint (* get_mdi_zorder) (AtkComponent *component);
/*
* signal handlers
*/
void (* bounds_changed) (AtkComponent *component,
AtkRectangle *bounds);
gdouble (* get_alpha) (AtkComponent *component);
/*
* Scrolls this object so it becomes visible on the screen.
*
* scroll_to lets the implementation compute an appropriate target
* position on the screen, with type used as a positioning hint.
*
* scroll_to_point lets the client specify a precise target position
* on the screen for the top-left of the object.
*
* Since ATK 2.30
*/
gboolean (*scroll_to) (AtkComponent *component,
AtkScrollType type);
gboolean (*scroll_to_point) (AtkComponent *component,
AtkCoordType coords,
gint x,
gint y);
};
GDK_AVAILABLE_IN_ALL
GType atk_component_get_type (void);
/* convenience functions */
GDK_AVAILABLE_IN_ALL
gboolean atk_component_contains (AtkComponent *component,
gint x,
gint y,
AtkCoordType coord_type);
GDK_AVAILABLE_IN_ALL
AtkObject* atk_component_ref_accessible_at_point(AtkComponent *component,
gint x,
gint y,
AtkCoordType coord_type);
GDK_AVAILABLE_IN_ALL
void atk_component_get_extents (AtkComponent *component,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coord_type);
GDK_AVAILABLE_IN_ALL
AtkLayer atk_component_get_layer (AtkComponent *component);
GDK_AVAILABLE_IN_ALL
gint atk_component_get_mdi_zorder (AtkComponent *component);
GDK_AVAILABLE_IN_ALL
gboolean atk_component_grab_focus (AtkComponent *component);
GDK_AVAILABLE_IN_ALL
gboolean atk_component_set_extents (AtkComponent *component,
gint x,
gint y,
gint width,
gint height,
AtkCoordType coord_type);
GDK_AVAILABLE_IN_ALL
gboolean atk_component_set_position (AtkComponent *component,
gint x,
gint y,
AtkCoordType coord_type);
GDK_AVAILABLE_IN_ALL
gboolean atk_component_set_size (AtkComponent *component,
gint width,
gint height);
GDK_AVAILABLE_IN_ALL
gdouble atk_component_get_alpha (AtkComponent *component);
GDK_AVAILABLE_IN_ALL
gboolean atk_component_scroll_to (AtkComponent *component,
AtkScrollType type);
GDK_AVAILABLE_IN_ALL
gboolean atk_component_scroll_to_point (AtkComponent *component,
AtkCoordType coords,
gint x,
gint y);
G_END_DECLS
#endif /* __ATK_COMPONENT_H__ */

324
atk/atkdocument.c Normal file
View File

@@ -0,0 +1,324 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "atkdocument.h"
/**
* SECTION:atkdocument
* @Short_description: The ATK interface which represents the toplevel
* container for document content.
* @Title:AtkDocument
*
* The AtkDocument interface should be supported by any object whose
* content is a representation or view of a document. The AtkDocument
* interface should appear on the toplevel container for the document
* content; however AtkDocument instances may be nested (i.e. an
* AtkDocument may be a descendant of another AtkDocument) in those
* cases where one document contains "embedded content" which can
* reasonably be considered a document in its own right.
*
*/
enum {
LOAD_COMPLETE,
RELOAD,
LOAD_STOPPED,
PAGE_CHANGED,
LAST_SIGNAL
};
static void atk_document_base_init (AtkDocumentIface *class);
static guint atk_document_signals[LAST_SIGNAL] = {0};
GType
atk_document_get_type (void)
{
static GType type = 0;
if (!type) {
static const GTypeInfo tinfo =
{
sizeof (AtkDocumentIface),
(GBaseInitFunc) atk_document_base_init,
(GBaseFinalizeFunc) NULL,
};
type = g_type_register_static (G_TYPE_INTERFACE, "AtkDocument", &tinfo, 0);
}
return type;
}
static void
atk_document_base_init (AtkDocumentIface *class)
{
static gboolean initialized = FALSE;
if (!initialized)
{
/**
* AtkDocument::load-complete:
* @atkdocument: the object which received the signal.
*
* The 'load-complete' signal is emitted when a pending load of
* a static document has completed. This signal is to be
* expected by ATK clients if and when AtkDocument implementors
* expose ATK_STATE_BUSY. If the state of an AtkObject which
* implements AtkDocument does not include ATK_STATE_BUSY, it
* should be safe for clients to assume that the AtkDocument's
* static contents are fully loaded into the container.
* (Dynamic document contents should be exposed via other
* signals.)
*/
atk_document_signals[LOAD_COMPLETE] =
g_signal_new ("load_complete",
ATK_TYPE_DOCUMENT,
G_SIGNAL_RUN_LAST,
0,
(GSignalAccumulator) NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
/**
* AtkDocument::reload:
* @atkdocument: the object which received the signal.
*
* The 'reload' signal is emitted when the contents of a
* document is refreshed from its source. Once 'reload' has
* been emitted, a matching 'load-complete' or 'load-stopped'
* signal should follow, which clients may await before
* interrogating ATK for the latest document content.
*/
atk_document_signals[RELOAD] =
g_signal_new ("reload",
ATK_TYPE_DOCUMENT,
G_SIGNAL_RUN_LAST,
0,
(GSignalAccumulator) NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
/**
* AtkDocument::load-stopped:
* @atkdocument: the object which received the signal.
*
* The 'load-stopped' signal is emitted when a pending load of
* document contents is cancelled, paused, or otherwise
* interrupted by the user or application logic. It should not
* however be emitted while waiting for a resource (for instance
* while blocking on a file or network read) unless a
* user-significant timeout has occurred.
*/
atk_document_signals[LOAD_STOPPED] =
g_signal_new ("load_stopped",
ATK_TYPE_DOCUMENT,
G_SIGNAL_RUN_LAST,
0,
(GSignalAccumulator) NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
/**
* AtkDocument::page-changed:
* @atkdocument: the object on which the signal was emitted
* @page_number: the new page number. If this value is unknown
* or not applicable, -1 should be provided.
*
* The 'page-changed' signal is emitted when the current page of
* a document changes, e.g. pressing page up/down in a document
* viewer.
*
* Since: 2.12
*/
atk_document_signals[PAGE_CHANGED] =
g_signal_new ("page_changed",
ATK_TYPE_DOCUMENT,
G_SIGNAL_RUN_LAST,
0,
(GSignalAccumulator) NULL, NULL,
g_cclosure_marshal_VOID__INT,
G_TYPE_NONE, 1, G_TYPE_INT);
initialized = TRUE;
}
}
/**
* atk_document_get_attributes: (virtual get_document_attributes)
* @document: a #GObject instance that implements AtkDocumentIface
*
* Gets an AtkAttributeSet which describes document-wide
* attributes as name-value pairs.
*
* Since: 1.12
*
* Returns: (transfer none): An AtkAttributeSet containing the explicitly
* set name-value-pair attributes associated with this document
* as a whole.
**/
AtkAttributeSet *
atk_document_get_attributes (AtkDocument *document)
{
AtkDocumentIface *iface;
g_return_val_if_fail (ATK_IS_DOCUMENT (document), NULL);
iface = ATK_DOCUMENT_GET_IFACE (document);
if (iface->get_document_attributes)
{
return (iface->get_document_attributes) (document);
}
else
{
return NULL;
}
}
/**
* atk_document_get_attribute_value: (virtual get_document_attribute_value)
* @document: a #GObject instance that implements AtkDocumentIface
* @attribute_name: a character string representing the name of the attribute
* whose value is being queried.
*
* Retrieves the value of the given @attribute_name inside @document.
*
* Returns: (nullable): a string value associated with the named
* attribute for this document, or %NULL if a value for
* @attribute_name has not been specified for this document.
*
* Since: 1.12
*/
const gchar *
atk_document_get_attribute_value (AtkDocument *document,
const gchar *attribute_name)
{
AtkDocumentIface *iface;
g_return_val_if_fail (ATK_IS_DOCUMENT (document), NULL);
iface = ATK_DOCUMENT_GET_IFACE (document);
if (iface->get_document_attribute_value)
{
return (iface->get_document_attribute_value) (document, attribute_name);
}
else
{
return NULL;
}
}
/**
* atk_document_set_attribute_value: (virtual set_document_attribute)
* @document: a #GObject instance that implements #AtkDocumentIface
* @attribute_name: a character string representing the name of the attribute
* whose value is being set.
* @attribute_value: a string value to be associated with @attribute_name.
*
* Sets the value for the given @attribute_name inside @document.
*
* Since: 1.12
*
* Returns: %TRUE if @attribute_value is successfully associated
* with @attribute_name for this @document, and %FALSE if if the
* document does not allow the attribute to be modified
*/
gboolean
atk_document_set_attribute_value (AtkDocument *document,
const gchar *attribute_name,
const gchar *attribute_value)
{
AtkDocumentIface *iface;
g_return_val_if_fail (ATK_IS_DOCUMENT (document), FALSE);
iface = ATK_DOCUMENT_GET_IFACE (document);
if (iface->set_document_attribute)
{
return (iface->set_document_attribute) (document, attribute_name, attribute_value);
}
else
{
return FALSE;
}
}
/**
* atk_document_get_current_page_number:
* @document: the #AtkDocument
*
* Retrieves the current page number inside @document.
*
* Returns: the current page number inside @document, or -1 if
* not implemented, not know by the implementor, or irrelevant.
*
* Since: 2.12
*/
gint
atk_document_get_current_page_number (AtkDocument *document)
{
AtkDocumentIface *iface;
g_return_val_if_fail (ATK_IS_DOCUMENT (document), FALSE);
iface = ATK_DOCUMENT_GET_IFACE (document);
if (iface->get_current_page_number)
{
return (iface->get_current_page_number) (document);
}
else
{
return -1;
}
}
/**
* atk_document_get_page_count:
* @document: the #AtkDocument
*
* Retrieves the total number of pages inside @document.
*
* Returns: total page count of @document, or -1 if not implemented,
* not know by the implementor or irrelevant.
*
* Since: 2.12
*/
gint
atk_document_get_page_count (AtkDocument *document)
{
AtkDocumentIface *iface;
g_return_val_if_fail (ATK_IS_DOCUMENT (document), FALSE);
iface = ATK_DOCUMENT_GET_IFACE (document);
if (iface->get_page_count)
{
return (iface->get_page_count) (document);
}
else
{
return -1;
}
}

103
atk/atkdocument.h Normal file
View File

@@ -0,0 +1,103 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_DOCUMENT_H__
#define __ATK_DOCUMENT_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <atk/atkobject.h>
G_BEGIN_DECLS
/*
* The AtkDocument interface should be supported by any object that is a container
* for 'document content' as opposed to a collection of user interface elements.
*
*/
#define ATK_TYPE_DOCUMENT (atk_document_get_type ())
#define ATK_IS_DOCUMENT(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_DOCUMENT)
#define ATK_DOCUMENT(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_DOCUMENT, AtkDocument)
#define ATK_DOCUMENT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_DOCUMENT, AtkDocumentIface))
#ifndef _TYPEDEF_ATK_DOCUMENT_
#define _TYPEDEF_ATK_DOCUMENT_
typedef struct _AtkDocument AtkDocument;
#endif
typedef struct _AtkDocumentIface AtkDocumentIface;
/**
* AtkDocumentIface:
* @get_document_type: gets a string indicating the document
* type. This virtual function is deprecated since 2.12 and it
* should not be overriden.
* @get_document: a #GObject instance that implements
* AtkDocumentIface. This virtual method is deprecated since 2.12
* and it should not be overriden.
* @get_document_locale: gets locale. This virtual function is
* deprecated since 2.7.90 and it should not be overriden.
* @get_document_attributes: gets an AtkAttributeSet which describes
* document-wide attributes as name-value pairs.
* @get_document_attribute_value: returns a string value assocciated
* with the named attribute for this document, or NULL
* @set_document_attribute: sets the value of an attribute. Returns
* TRUE on success, FALSE otherwise
* @get_current_page_number: gets the current page number. Since 2.12
* @get_page_count: gets the page count of the document. Since 2.12
*/
struct _AtkDocumentIface
{
GTypeInterface parent;
const gchar* ( *get_document_type) (AtkDocument *document);
gpointer ( *get_document) (AtkDocument *document);
const gchar* ( *get_document_locale) (AtkDocument *document);
AtkAttributeSet * ( *get_document_attributes) (AtkDocument *document);
const gchar* ( *get_document_attribute_value) (AtkDocument *document,
const gchar *attribute_name);
gboolean ( *set_document_attribute) (AtkDocument *document,
const gchar *attribute_name,
const gchar *attribute_value);
gint ( *get_current_page_number) (AtkDocument *document);
gint ( *get_page_count) (AtkDocument *document);
};
GDK_AVAILABLE_IN_ALL
GType atk_document_get_type (void);
GDK_AVAILABLE_IN_ALL
AtkAttributeSet* atk_document_get_attributes (AtkDocument *document);
GDK_AVAILABLE_IN_ALL
const gchar* atk_document_get_attribute_value (AtkDocument *document,
const gchar *attribute_name);
GDK_AVAILABLE_IN_ALL
gboolean atk_document_set_attribute_value (AtkDocument *document,
const gchar *attribute_name,
const gchar *attribute_value);
GDK_AVAILABLE_IN_ALL
gint atk_document_get_current_page_number (AtkDocument *document);
GDK_AVAILABLE_IN_ALL
gint atk_document_get_page_count (AtkDocument *document);
G_END_DECLS
#endif /* __ATK_DOCUMENT_H__ */

237
atk/atkeditabletext.c Normal file
View File

@@ -0,0 +1,237 @@
/* ATK - The Accessibility Toolkit for GTK+
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "atkeditabletext.h"
/**
* SECTION:atkeditabletext
* @Short_description: The ATK interface implemented by components
* containing user-editable text content.
* @Title:AtkEditableText
*
* #AtkEditableText should be implemented by UI components which
* contain text which the user can edit, via the #AtkObject
* corresponding to that component (see #AtkObject).
*
* #AtkEditableText is a subclass of #AtkText, and as such, an object
* which implements #AtkEditableText is by definition an #AtkText
* implementor as well.
*
* See also: #AtkText
*/
GType
atk_editable_text_get_type (void)
{
static GType type = 0;
if (!type) {
static const GTypeInfo tinfo =
{
sizeof (AtkEditableTextIface),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
};
type = g_type_register_static (G_TYPE_INTERFACE, "AtkEditableText", &tinfo, 0);
}
return type;
}
/**
*atk_editable_text_set_run_attributes:
*@text: an #AtkEditableText
*@attrib_set: an #AtkAttributeSet
*@start_offset: start of range in which to set attributes
*@end_offset: end of range in which to set attributes
*
*Sets the attributes for a specified range. See the ATK_ATTRIBUTE
*macros (such as #ATK_ATTRIBUTE_LEFT_MARGIN) for examples of attributes
*that can be set. Note that other attributes that do not have corresponding
*ATK_ATTRIBUTE macros may also be set for certain text widgets.
*
*Returns: %TRUE if attributes successfully set for the specified
*range, otherwise %FALSE
**/
gboolean
atk_editable_text_set_run_attributes (AtkEditableText *text,
AtkAttributeSet *attrib_set,
gint start_offset,
gint end_offset)
{
AtkEditableTextIface *iface;
g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (text), FALSE);
iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
if (iface->set_run_attributes)
{
return (*(iface->set_run_attributes)) (text, attrib_set, start_offset, end_offset);
}
else
{
return FALSE;
}
}
/**
* atk_editable_text_set_text_contents:
* @text: an #AtkEditableText
* @string: string to set for text contents of @text
*
* Set text contents of @text.
**/
void
atk_editable_text_set_text_contents (AtkEditableText *text,
const gchar *string)
{
AtkEditableTextIface *iface;
g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
if (iface->set_text_contents)
(*(iface->set_text_contents)) (text, string);
}
/**
* atk_editable_text_insert_text:
* @text: an #AtkEditableText
* @string: the text to insert
* @length: the length of text to insert, in bytes
* @position: The caller initializes this to
* the position at which to insert the text. After the call it
* points at the position after the newly inserted text.
*
* Insert text at a given position.
**/
void
atk_editable_text_insert_text (AtkEditableText *text,
const gchar *string,
gint length,
gint *position)
{
AtkEditableTextIface *iface;
g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
if (iface->insert_text)
(*(iface->insert_text)) (text, string, length, position);
}
/**
* atk_editable_text_copy_text:
* @text: an #AtkEditableText
* @start_pos: start position
* @end_pos: end position
*
* Copy text from @start_pos up to, but not including @end_pos
* to the clipboard.
**/
void
atk_editable_text_copy_text (AtkEditableText *text,
gint start_pos,
gint end_pos)
{
AtkEditableTextIface *iface;
g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
if (iface->copy_text)
(*(iface->copy_text)) (text, start_pos, end_pos);
}
/**
* atk_editable_text_cut_text:
* @text: an #AtkEditableText
* @start_pos: start position
* @end_pos: end position
*
* Copy text from @start_pos up to, but not including @end_pos
* to the clipboard and then delete from the widget.
**/
void
atk_editable_text_cut_text (AtkEditableText *text,
gint start_pos,
gint end_pos)
{
AtkEditableTextIface *iface;
g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
if (iface->cut_text)
(*(iface->cut_text)) (text, start_pos, end_pos);
}
/**
* atk_editable_text_delete_text:
* @text: an #AtkEditableText
* @start_pos: start position
* @end_pos: end position
*
* Delete text @start_pos up to, but not including @end_pos.
**/
void
atk_editable_text_delete_text (AtkEditableText *text,
gint start_pos,
gint end_pos)
{
AtkEditableTextIface *iface;
g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
if (iface->delete_text)
(*(iface->delete_text)) (text, start_pos, end_pos);
}
/**
* atk_editable_text_paste_text:
* @text: an #AtkEditableText
* @position: position to paste
*
* Paste text from clipboard to specified @position.
**/
void
atk_editable_text_paste_text (AtkEditableText *text,
gint position)
{
AtkEditableTextIface *iface;
g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
if (iface->paste_text)
(*(iface->paste_text)) (text, position);
}

108
atk/atkeditabletext.h Normal file
View File

@@ -0,0 +1,108 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_EDITABLE_TEXT_H__
#define __ATK_EDITABLE_TEXT_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <atk/atkobject.h>
G_BEGIN_DECLS
/*
* AtkEditableText is used to support access in an "accessibility" context
* to editing features of editable text widgets.
*/
#define ATK_TYPE_EDITABLE_TEXT (atk_editable_text_get_type ())
#define ATK_IS_EDITABLE_TEXT(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_EDITABLE_TEXT)
#define ATK_EDITABLE_TEXT(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_EDITABLE_TEXT, AtkEditableText)
#define ATK_EDITABLE_TEXT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_EDITABLE_TEXT, AtkEditableTextIface))
#ifndef _TYPEDEF_ATK_EDITABLE_TEXT_
#define _TYPEDEF_ATK_EDITABLE_TEXT_
typedef struct _AtkEditableText AtkEditableText;
#endif
typedef struct _AtkEditableTextIface AtkEditableTextIface;
struct _AtkEditableTextIface
{
GTypeInterface parent_interface;
gboolean (* set_run_attributes) (AtkEditableText *text,
AtkAttributeSet *attrib_set,
gint start_offset,
gint end_offset);
void (* set_text_contents) (AtkEditableText *text,
const gchar *string);
void (* insert_text) (AtkEditableText *text,
const gchar *string,
gint length,
gint *position);
void (* copy_text) (AtkEditableText *text,
gint start_pos,
gint end_pos);
void (* cut_text) (AtkEditableText *text,
gint start_pos,
gint end_pos);
void (* delete_text) (AtkEditableText *text,
gint start_pos,
gint end_pos);
void (* paste_text) (AtkEditableText *text,
gint position);
};
GDK_AVAILABLE_IN_ALL
GType atk_editable_text_get_type (void);
GDK_AVAILABLE_IN_ALL
gboolean atk_editable_text_set_run_attributes (AtkEditableText *text,
AtkAttributeSet *attrib_set,
gint start_offset,
gint end_offset);
GDK_AVAILABLE_IN_ALL
void atk_editable_text_set_text_contents (AtkEditableText *text,
const gchar *string);
GDK_AVAILABLE_IN_ALL
void atk_editable_text_insert_text (AtkEditableText *text,
const gchar *string,
gint length,
gint *position);
GDK_AVAILABLE_IN_ALL
void atk_editable_text_copy_text (AtkEditableText *text,
gint start_pos,
gint end_pos);
GDK_AVAILABLE_IN_ALL
void atk_editable_text_cut_text (AtkEditableText *text,
gint start_pos,
gint end_pos);
GDK_AVAILABLE_IN_ALL
void atk_editable_text_delete_text (AtkEditableText *text,
gint start_pos,
gint end_pos);
GDK_AVAILABLE_IN_ALL
void atk_editable_text_paste_text (AtkEditableText *text,
gint position);
G_END_DECLS
#endif /* __ATK_EDITABLE_TEXT_H__ */

870
atk/atkenums.h Normal file
View File

@@ -0,0 +1,870 @@
#pragma once
#include <glib-object.h>
G_BEGIN_DECLS
/**
* AtkHyperlinkStateFlags:
* @ATK_HYPERLINK_IS_INLINE: Link is inline
*
* Describes the type of link
*/
typedef enum
{
ATK_HYPERLINK_IS_INLINE = 1 << 0
} AtkHyperlinkStateFlags;
/**
*AtkStateType:
*@ATK_STATE_INVALID: Indicates an invalid state - probably an error condition.
*@ATK_STATE_ACTIVE: Indicates a window is currently the active window, or an object is the active subelement within a container or table. ATK_STATE_ACTIVE should not be used for objects which have ATK_STATE_FOCUSABLE or ATK_STATE_SELECTABLE: Those objects should use ATK_STATE_FOCUSED and ATK_STATE_SELECTED respectively. ATK_STATE_ACTIVE is a means to indicate that an object which is not focusable and not selectable is the currently-active item within its parent container.
*@ATK_STATE_ARMED: Indicates that the object is 'armed', i.e. will be activated by if a pointer button-release event occurs within its bounds. Buttons often enter this state when a pointer click occurs within their bounds, as a precursor to activation. ATK_STATE_ARMED has been deprecated since ATK-2.16 and should not be used in newly-written code.
*@ATK_STATE_BUSY: Indicates the current object is busy, i.e. onscreen representation is in the process of changing, or the object is temporarily unavailable for interaction due to activity already in progress. This state may be used by implementors of Document to indicate that content loading is underway. It also may indicate other 'pending' conditions; clients may wish to interrogate this object when the ATK_STATE_BUSY flag is removed.
*@ATK_STATE_CHECKED: Indicates this object is currently checked, for instance a checkbox is 'non-empty'.
*@ATK_STATE_DEFUNCT: Indicates that this object no longer has a valid backing widget (for instance, if its peer object has been destroyed)
*@ATK_STATE_EDITABLE: Indicates that this object can contain text, and that the
* user can change the textual contents of this object by editing those contents
* directly. For an object which is expected to be editable due to its type, but
* which cannot be edited due to the application or platform preventing the user
* from doing so, that object's #AtkStateSet should lack ATK_STATE_EDITABLE and
* should contain ATK_STATE_READ_ONLY.
*@ATK_STATE_ENABLED: Indicates that this object is enabled, i.e. that it currently reflects some application state. Objects that are "greyed out" may lack this state, and may lack the STATE_SENSITIVE if direct user interaction cannot cause them to acquire STATE_ENABLED. See also: ATK_STATE_SENSITIVE
*@ATK_STATE_EXPANDABLE: Indicates this object allows progressive disclosure of its children
*@ATK_STATE_EXPANDED: Indicates this object its expanded - see ATK_STATE_EXPANDABLE above
*@ATK_STATE_FOCUSABLE: Indicates this object can accept keyboard focus, which means all events resulting from typing on the keyboard will normally be passed to it when it has focus
*@ATK_STATE_FOCUSED: Indicates this object currently has the keyboard focus
*@ATK_STATE_HORIZONTAL: Indicates the orientation of this object is horizontal; used, for instance, by objects of ATK_ROLE_SCROLL_BAR. For objects where vertical/horizontal orientation is especially meaningful.
*@ATK_STATE_ICONIFIED: Indicates this object is minimized and is represented only by an icon
*@ATK_STATE_MODAL: Indicates something must be done with this object before the user can interact with an object in a different window
*@ATK_STATE_MULTI_LINE: Indicates this (text) object can contain multiple lines of text
*@ATK_STATE_MULTISELECTABLE: Indicates this object allows more than one of its children to be selected at the same time, or in the case of text objects, that the object supports non-contiguous text selections.
*@ATK_STATE_OPAQUE: Indicates this object paints every pixel within its rectangular region.
*@ATK_STATE_PRESSED: Indicates this object is currently pressed.
*@ATK_STATE_RESIZABLE: Indicates the size of this object is not fixed
*@ATK_STATE_SELECTABLE: Indicates this object is the child of an object that allows its children to be selected and that this child is one of those children that can be selected
*@ATK_STATE_SELECTED: Indicates this object is the child of an object that allows its children to be selected and that this child is one of those children that has been selected
*@ATK_STATE_SENSITIVE: Indicates this object is sensitive, e.g. to user interaction.
* STATE_SENSITIVE usually accompanies STATE_ENABLED for user-actionable controls,
* but may be found in the absence of STATE_ENABLED if the current visible state of the
* control is "disconnected" from the application state. In such cases, direct user interaction
* can often result in the object gaining STATE_SENSITIVE, for instance if a user makes
* an explicit selection using an object whose current state is ambiguous or undefined.
* @see STATE_ENABLED, STATE_INDETERMINATE.
*@ATK_STATE_SHOWING: Indicates this object, the object's parent, the object's parent's parent, and so on,
* are all 'shown' to the end-user, i.e. subject to "exposure" if blocking or obscuring objects do not interpose
* between this object and the top of the window stack.
*@ATK_STATE_SINGLE_LINE: Indicates this (text) object can contain only a single line of text
*@ATK_STATE_STALE: Indicates that the information returned for this object may no longer be
* synchronized with the application state. This is implied if the object has STATE_TRANSIENT,
* and can also occur towards the end of the object peer's lifecycle. It can also be used to indicate that
* the index associated with this object has changed since the user accessed the object (in lieu of
* "index-in-parent-changed" events).
*@ATK_STATE_TRANSIENT: Indicates this object is transient, i.e. a snapshot which may not emit events when its
* state changes. Data from objects with ATK_STATE_TRANSIENT should not be cached, since there may be no
* notification given when the cached data becomes obsolete.
*@ATK_STATE_VERTICAL: Indicates the orientation of this object is vertical
*@ATK_STATE_VISIBLE: Indicates this object is visible, e.g. has been explicitly marked for exposure to the user.
* **note**: %ATK_STATE_VISIBLE is no guarantee that the object is actually unobscured on the screen, only
* that it is 'potentially' visible, barring obstruction, being scrolled or clipped out of the
* field of view, or having an ancestor container that has not yet made visible.
* A widget is potentially onscreen if it has both %ATK_STATE_VISIBLE and %ATK_STATE_SHOWING.
* The absence of %ATK_STATE_VISIBLE and %ATK_STATE_SHOWING is semantically equivalent to saying
* that an object is 'hidden'. See also %ATK_STATE_TRUNCATED, which applies if an object with
* %ATK_STATE_VISIBLE and %ATK_STATE_SHOWING set lies within a viewport which means that its
* contents are clipped, e.g. a truncated spreadsheet cell or
* an image within a scrolling viewport. Mostly useful for screen-review and magnification
* algorithms.
*@ATK_STATE_MANAGES_DESCENDANTS: Indicates that "active-descendant-changed" event
* is sent when children become 'active' (i.e. are selected or navigated to onscreen).
* Used to prevent need to enumerate all children in very large containers, like tables.
* The presence of STATE_MANAGES_DESCENDANTS is an indication to the client.
* that the children should not, and need not, be enumerated by the client.
* Objects implementing this state are expected to provide relevant state
* notifications to listening clients, for instance notifications of visibility
* changes and activation of their contained child objects, without the client
* having previously requested references to those children.
*@ATK_STATE_INDETERMINATE: Indicates that the value, or some other quantifiable
* property, of this AtkObject cannot be fully determined. In the case of a large
* data set in which the total number of items in that set is unknown (e.g. 1 of
* 999+), implementors should expose the currently-known set size (999) along
* with this state. In the case of a check box, this state should be used to
* indicate that the check box is a tri-state check box which is currently
* neither checked nor unchecked.
*@ATK_STATE_TRUNCATED: Indicates that an object is truncated, e.g. a text value in a speradsheet cell.
*@ATK_STATE_REQUIRED: Indicates that explicit user interaction with an object is required by the user interface, e.g. a required field in a "web-form" interface.
*@ATK_STATE_INVALID_ENTRY: Indicates that the object has encountered an error condition due to failure of input validation. For instance, a form control may acquire this state in response to invalid or malformed user input.
*@ATK_STATE_SUPPORTS_AUTOCOMPLETION: Indicates that the object in question implements some form of ¨typeahead¨ or
* pre-selection behavior whereby entering the first character of one or more sub-elements
* causes those elements to scroll into view or become selected. Subsequent character input
* may narrow the selection further as long as one or more sub-elements match the string.
* This state is normally only useful and encountered on objects that implement Selection.
* In some cases the typeahead behavior may result in full or partial ¨completion¨ of
* the data in the input field, in which case these input events may trigger text-changed
* events from the AtkText interface. This state supplants @ATK_ROLE_AUTOCOMPLETE.
*@ATK_STATE_SELECTABLE_TEXT:Indicates that the object in question supports text selection. It should only be exposed on objects which implement the Text interface, in order to distinguish this state from @ATK_STATE_SELECTABLE, which infers that the object in question is a selectable child of an object which implements Selection. While similar, text selection and subelement selection are distinct operations.
*@ATK_STATE_DEFAULT: Indicates that the object is the "default" active component, i.e. the object which is activated by an end-user press of the "Enter" or "Return" key. Typically a "close" or "submit" button.
*@ATK_STATE_ANIMATED: Indicates that the object changes its appearance dynamically as an inherent part of its presentation. This state may come and go if an object is only temporarily animated on the way to a 'final' onscreen presentation.
* **note**: some applications, notably content viewers, may not be able to detect
* all kinds of animated content. Therefore the absence of this state should not
* be taken as definitive evidence that the object's visual representation is
* static; this state is advisory.
*@ATK_STATE_VISITED: Indicates that the object (typically a hyperlink) has already been 'activated', and/or its backing data has already been downloaded, rendered, or otherwise "visited".
*@ATK_STATE_CHECKABLE: Indicates this object has the potential to be
* checked, such as a checkbox or toggle-able table cell. @Since:
* ATK-2.12
*@ATK_STATE_HAS_POPUP: Indicates that the object has a popup context
* menu or sub-level menu which may or may not be showing. This means
* that activation renders conditional content. Note that ordinary
* tooltips are not considered popups in this context. @Since: ATK-2.12
*@ATK_STATE_HAS_TOOLTIP: Indicates this object has a tooltip. @Since: ATK-2.16
*@ATK_STATE_READ_ONLY: Indicates that a widget which is ENABLED and SENSITIVE
* has a value which can be read, but not modified, by the user. Note that this
* state should only be applied to widget types whose value is normally directly
* user modifiable, such as check boxes, radio buttons, spin buttons, text input
* fields, and combo boxes, as a means to convey that the expected interaction
* with that widget is not possible. When the expected interaction with a
* widget does not include modification by the user, as is the case with
* labels and containers, ATK_STATE_READ_ONLY should not be applied. See also
* ATK_STATE_EDITABLE. @Since: ATK-2-16
*@ATK_STATE_LAST_DEFINED: Not a valid state, used for finding end of enumeration
*
*The possible types of states of an object
**/
typedef enum
{
ATK_STATE_INVALID,
ATK_STATE_ACTIVE,
ATK_STATE_ARMED,
ATK_STATE_BUSY,
ATK_STATE_CHECKED,
ATK_STATE_DEFUNCT,
ATK_STATE_EDITABLE,
ATK_STATE_ENABLED,
ATK_STATE_EXPANDABLE,
ATK_STATE_EXPANDED,
ATK_STATE_FOCUSABLE,
ATK_STATE_FOCUSED,
ATK_STATE_HORIZONTAL,
ATK_STATE_ICONIFIED,
ATK_STATE_MODAL,
ATK_STATE_MULTI_LINE,
ATK_STATE_MULTISELECTABLE,
ATK_STATE_OPAQUE,
ATK_STATE_PRESSED,
ATK_STATE_RESIZABLE,
ATK_STATE_SELECTABLE,
ATK_STATE_SELECTED,
ATK_STATE_SENSITIVE,
ATK_STATE_SHOWING,
ATK_STATE_SINGLE_LINE,
ATK_STATE_STALE,
ATK_STATE_TRANSIENT,
ATK_STATE_VERTICAL,
ATK_STATE_VISIBLE,
ATK_STATE_MANAGES_DESCENDANTS,
ATK_STATE_INDETERMINATE,
ATK_STATE_TRUNCATED,
ATK_STATE_REQUIRED,
ATK_STATE_INVALID_ENTRY,
ATK_STATE_SUPPORTS_AUTOCOMPLETION,
ATK_STATE_SELECTABLE_TEXT,
ATK_STATE_DEFAULT,
ATK_STATE_ANIMATED,
ATK_STATE_VISITED,
ATK_STATE_CHECKABLE,
ATK_STATE_HAS_POPUP,
ATK_STATE_HAS_TOOLTIP,
ATK_STATE_READ_ONLY,
ATK_STATE_LAST_DEFINED
} AtkStateType;
/**
* AtkScrollType:
* @ATK_SCROLL_TOP_LEFT: Scroll the object vertically and horizontally to bring
* its top left corner to the top left corner of the window.
* @ATK_SCROLL_BOTTOM_RIGHT: Scroll the object vertically and horizontally to
* bring its bottom right corner to the bottom right corner of the window.
* @ATK_SCROLL_TOP_EDGE: Scroll the object vertically to bring its top edge to
* the top edge of the window.
* @ATK_SCROLL_BOTTOM_EDGE: Scroll the object vertically to bring its bottom
* edge to the bottom edge of the window.
* @ATK_SCROLL_LEFT_EDGE: Scroll the object vertically and horizontally to bring
* its left edge to the left edge of the window.
* @ATK_SCROLL_RIGHT_EDGE: Scroll the object vertically and horizontally to
* bring its right edge to the right edge of the window.
* @ATK_SCROLL_ANYWHERE: Scroll the object vertically and horizontally so that
* as much as possible of the object becomes visible. The exact placement is
* determined by the application.
*
* Specifies where an object should be placed on the screen when using scroll_to.
*/
typedef enum {
ATK_SCROLL_TOP_LEFT,
ATK_SCROLL_BOTTOM_RIGHT,
ATK_SCROLL_TOP_EDGE,
ATK_SCROLL_BOTTOM_EDGE,
ATK_SCROLL_LEFT_EDGE,
ATK_SCROLL_RIGHT_EDGE,
ATK_SCROLL_ANYWHERE
} AtkScrollType;
/**
*AtkRelationType:
*@ATK_RELATION_NULL: Not used, represens "no relationship" or an error condition.
*@ATK_RELATION_CONTROLLED_BY: Indicates an object controlled by one or more target objects.
*@ATK_RELATION_CONTROLLER_FOR: Indicates an object is an controller for one or more target objects.
*@ATK_RELATION_LABEL_FOR: Indicates an object is a label for one or more target objects.
*@ATK_RELATION_LABELLED_BY: Indicates an object is labelled by one or more target objects.
*@ATK_RELATION_MEMBER_OF: Indicates an object is a member of a group of one or more target objects.
*@ATK_RELATION_NODE_CHILD_OF: Indicates an object is a cell in a treetable which is displayed because a cell in the same column is expanded and identifies that cell.
*@ATK_RELATION_FLOWS_TO: Indicates that the object has content that flows logically to another
* AtkObject in a sequential way, (for instance text-flow).
*@ATK_RELATION_FLOWS_FROM: Indicates that the object has content that flows logically from
* another AtkObject in a sequential way, (for instance text-flow).
*@ATK_RELATION_SUBWINDOW_OF: Indicates a subwindow attached to a component but otherwise has no connection in the UI heirarchy to that component.
*@ATK_RELATION_EMBEDS: Indicates that the object visually embeds
* another object's content, i.e. this object's content flows around
* another's content.
*@ATK_RELATION_EMBEDDED_BY: Reciprocal of %ATK_RELATION_EMBEDS, indicates that
* this object's content is visualy embedded in another object.
*@ATK_RELATION_POPUP_FOR: Indicates that an object is a popup for another object.
*@ATK_RELATION_PARENT_WINDOW_OF: Indicates that an object is a parent window of another object.
*@ATK_RELATION_DESCRIBED_BY: Reciprocal of %ATK_RELATION_DESCRIPTION_FOR. Indicates that one
* or more target objects provide descriptive information about this object. This relation
* type is most appropriate for information that is not essential as its presentation may
* be user-configurable and/or limited to an on-demand mechanism such as an assistive
* technology command. For brief, essential information such as can be found in a widget's
* on-screen label, use %ATK_RELATION_LABELLED_BY. For an on-screen error message, use
* %ATK_RELATION_ERROR_MESSAGE. For lengthy extended descriptive information contained in
* an on-screen object, consider using %ATK_RELATION_DETAILS as assistive technologies may
* provide a means for the user to navigate to objects containing detailed descriptions so
* that their content can be more closely reviewed.
*@ATK_RELATION_DESCRIPTION_FOR: Reciprocal of %ATK_RELATION_DESCRIBED_BY. Indicates that this
* object provides descriptive information about the target object(s). See also
* %ATK_RELATION_DETAILS_FOR and %ATK_RELATION_ERROR_FOR.
*@ATK_RELATION_NODE_PARENT_OF: Indicates an object is a cell in a treetable and is expanded to display other cells in the same column.
*@ATK_RELATION_DETAILS: Reciprocal of %ATK_RELATION_DETAILS_FOR. Indicates that this object
* has a detailed or extended description, the contents of which can be found in the target
* object(s). This relation type is most appropriate for information that is sufficiently
* lengthy as to make navigation to the container of that information desirable. For less
* verbose information suitable for announcement only, see %ATK_RELATION_DESCRIBED_BY. If
* the detailed information describes an error condition, %ATK_RELATION_ERROR_FOR should be
* used instead. @Since: ATK-2.26.
*@ATK_RELATION_DETAILS_FOR: Reciprocal of %ATK_RELATION_DETAILS. Indicates that this object
* provides a detailed or extended description about the target object(s). See also
* %ATK_RELATION_DESCRIPTION_FOR and %ATK_RELATION_ERROR_FOR. @Since: ATK-2.26.
*@ATK_RELATION_ERROR_MESSAGE: Reciprocal of %ATK_RELATION_ERROR_FOR. Indicates that this object
* has one or more errors, the nature of which is described in the contents of the target
* object(s). Objects that have this relation type should also contain %ATK_STATE_INVALID_ENTRY
* in their #AtkStateSet. @Since: ATK-2.26.
*@ATK_RELATION_ERROR_FOR: Reciprocal of %ATK_RELATION_ERROR_MESSAGE. Indicates that this object
* contains an error message describing an invalid condition in the target object(s). @Since:
* ATK_2.26.
*@ATK_RELATION_LAST_DEFINED: Not used, this value indicates the end of the enumeration.
*
*Describes the type of the relation
**/
typedef enum
{
ATK_RELATION_NULL = 0,
ATK_RELATION_CONTROLLED_BY,
ATK_RELATION_CONTROLLER_FOR,
ATK_RELATION_LABEL_FOR,
ATK_RELATION_LABELLED_BY,
ATK_RELATION_MEMBER_OF,
ATK_RELATION_NODE_CHILD_OF,
ATK_RELATION_FLOWS_TO,
ATK_RELATION_FLOWS_FROM,
ATK_RELATION_SUBWINDOW_OF,
ATK_RELATION_EMBEDS,
ATK_RELATION_EMBEDDED_BY,
ATK_RELATION_POPUP_FOR,
ATK_RELATION_PARENT_WINDOW_OF,
ATK_RELATION_DESCRIBED_BY,
ATK_RELATION_DESCRIPTION_FOR,
ATK_RELATION_NODE_PARENT_OF,
ATK_RELATION_DETAILS,
ATK_RELATION_DETAILS_FOR,
ATK_RELATION_ERROR_MESSAGE,
ATK_RELATION_ERROR_FOR,
ATK_RELATION_LAST_DEFINED
} AtkRelationType;
/**
*AtkTextAttribute:
*@ATK_TEXT_ATTR_INVALID: Invalid attribute, like bad spelling or grammar.
*@ATK_TEXT_ATTR_LEFT_MARGIN: The pixel width of the left margin
*@ATK_TEXT_ATTR_RIGHT_MARGIN: The pixel width of the right margin
*@ATK_TEXT_ATTR_INDENT: The number of pixels that the text is indented
*@ATK_TEXT_ATTR_INVISIBLE: Either "true" or "false" indicating whether text is visible or not
*@ATK_TEXT_ATTR_EDITABLE: Either "true" or "false" indicating whether text is editable or not
*@ATK_TEXT_ATTR_PIXELS_ABOVE_LINES: Pixels of blank space to leave above each newline-terminated line.
*@ATK_TEXT_ATTR_PIXELS_BELOW_LINES: Pixels of blank space to leave below each newline-terminated line.
*@ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP: Pixels of blank space to leave between wrapped lines inside the same newline-terminated line (paragraph).
*@ATK_TEXT_ATTR_BG_FULL_HEIGHT: "true" or "false" whether to make the background color for each character the height of the highest font used on the current line, or the height of the font used for the current character.
*@ATK_TEXT_ATTR_RISE: Number of pixels that the characters are risen above the baseline. See also ATK_TEXT_ATTR_TEXT_POSITION.
*@ATK_TEXT_ATTR_UNDERLINE: "none", "single", "double", "low", or "error"
*@ATK_TEXT_ATTR_STRIKETHROUGH: "true" or "false" whether the text is strikethrough
*@ATK_TEXT_ATTR_SIZE: The size of the characters in points. eg: 10
*@ATK_TEXT_ATTR_SCALE: The scale of the characters. The value is a string representation of a double
*@ATK_TEXT_ATTR_WEIGHT: The weight of the characters.
*@ATK_TEXT_ATTR_LANGUAGE: The language used
*@ATK_TEXT_ATTR_FAMILY_NAME: The font family name
*@ATK_TEXT_ATTR_BG_COLOR: The background color. The value is an RGB value of the format "%u,%u,%u"
*@ATK_TEXT_ATTR_FG_COLOR:The foreground color. The value is an RGB value of the format "%u,%u,%u"
*@ATK_TEXT_ATTR_BG_STIPPLE: "true" if a #GdkBitmap is set for stippling the background color.
*@ATK_TEXT_ATTR_FG_STIPPLE: "true" if a #GdkBitmap is set for stippling the foreground color.
*@ATK_TEXT_ATTR_WRAP_MODE: The wrap mode of the text, if any. Values are "none", "char", "word", or "word_char".
*@ATK_TEXT_ATTR_DIRECTION: The direction of the text, if set. Values are "none", "ltr" or "rtl"
*@ATK_TEXT_ATTR_JUSTIFICATION: The justification of the text, if set. Values are "left", "right", "center" or "fill"
*@ATK_TEXT_ATTR_STRETCH: The stretch of the text, if set. Values are "ultra_condensed", "extra_condensed", "condensed", "semi_condensed", "normal", "semi_expanded", "expanded", "extra_expanded" or "ultra_expanded"
*@ATK_TEXT_ATTR_VARIANT: The capitalization variant of the text, if set. Values are "normal" or "small_caps"
*@ATK_TEXT_ATTR_STYLE: The slant style of the text, if set. Values are "normal", "oblique" or "italic"
*@ATK_TEXT_ATTR_TEXT_POSITION: The vertical position with respect to the baseline. Values are "baseline", "super", or "sub". Note that a super or sub text attribute refers to position with respect to the baseline of the prior character.
*@ATK_TEXT_ATTR_LAST_DEFINED: not a valid text attribute, used for finding end of enumeration
*
* Describes the text attributes supported
**/
typedef enum
{
ATK_TEXT_ATTR_INVALID = 0,
ATK_TEXT_ATTR_LEFT_MARGIN,
ATK_TEXT_ATTR_RIGHT_MARGIN,
ATK_TEXT_ATTR_INDENT,
ATK_TEXT_ATTR_INVISIBLE,
ATK_TEXT_ATTR_EDITABLE,
ATK_TEXT_ATTR_PIXELS_ABOVE_LINES,
ATK_TEXT_ATTR_PIXELS_BELOW_LINES,
ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP,
ATK_TEXT_ATTR_BG_FULL_HEIGHT,
ATK_TEXT_ATTR_RISE,
ATK_TEXT_ATTR_UNDERLINE,
ATK_TEXT_ATTR_STRIKETHROUGH,
ATK_TEXT_ATTR_SIZE,
ATK_TEXT_ATTR_SCALE,
ATK_TEXT_ATTR_WEIGHT,
ATK_TEXT_ATTR_LANGUAGE,
ATK_TEXT_ATTR_FAMILY_NAME,
ATK_TEXT_ATTR_BG_COLOR,
ATK_TEXT_ATTR_FG_COLOR,
ATK_TEXT_ATTR_BG_STIPPLE,
ATK_TEXT_ATTR_FG_STIPPLE,
ATK_TEXT_ATTR_WRAP_MODE,
ATK_TEXT_ATTR_DIRECTION,
ATK_TEXT_ATTR_JUSTIFICATION,
ATK_TEXT_ATTR_STRETCH,
ATK_TEXT_ATTR_VARIANT,
ATK_TEXT_ATTR_STYLE,
ATK_TEXT_ATTR_TEXT_POSITION,
ATK_TEXT_ATTR_LAST_DEFINED
} AtkTextAttribute;
/**
*AtkTextBoundary:
*@ATK_TEXT_BOUNDARY_CHAR: Boundary is the boundary between characters
* (including non-printing characters)
*@ATK_TEXT_BOUNDARY_WORD_START: Boundary is the start (i.e. first character) of a word.
*@ATK_TEXT_BOUNDARY_WORD_END: Boundary is the end (i.e. last
* character) of a word.
*@ATK_TEXT_BOUNDARY_SENTENCE_START: Boundary is the first character in a sentence.
*@ATK_TEXT_BOUNDARY_SENTENCE_END: Boundary is the last (terminal)
* character in a sentence; in languages which use "sentence stop"
* punctuation such as English, the boundary is thus the '.', '?', or
* similar terminal punctuation character.
*@ATK_TEXT_BOUNDARY_LINE_START: Boundary is the initial character of the content or a
* character immediately following a newline, linefeed, or return character.
*@ATK_TEXT_BOUNDARY_LINE_END: Boundary is the linefeed, or return
* character.
*
* Text boundary types used for specifying boundaries for regions of text.
* This enumeration is deprecated since 2.9.4 and should not be used. Use
* AtkTextGranularity with #atk_text_get_string_at_offset instead.
**/
typedef enum {
ATK_TEXT_BOUNDARY_CHAR,
ATK_TEXT_BOUNDARY_WORD_START,
ATK_TEXT_BOUNDARY_WORD_END,
ATK_TEXT_BOUNDARY_SENTENCE_START,
ATK_TEXT_BOUNDARY_SENTENCE_END,
ATK_TEXT_BOUNDARY_LINE_START,
ATK_TEXT_BOUNDARY_LINE_END
} AtkTextBoundary;
/**
*AtkTextGranularity:
*@ATK_TEXT_GRANULARITY_CHAR: Granularity is defined by the boundaries between characters
* (including non-printing characters)
*@ATK_TEXT_GRANULARITY_WORD: Granularity is defined by the boundaries of a word,
* starting at the beginning of the current word and finishing at the beginning of
* the following one, if present.
*@ATK_TEXT_GRANULARITY_SENTENCE: Granularity is defined by the boundaries of a sentence,
* starting at the beginning of the current sentence and finishing at the beginning of
* the following one, if present.
*@ATK_TEXT_GRANULARITY_LINE: Granularity is defined by the boundaries of a line,
* starting at the beginning of the current line and finishing at the beginning of
* the following one, if present.
*@ATK_TEXT_GRANULARITY_PARAGRAPH: Granularity is defined by the boundaries of a paragraph,
* starting at the beginning of the current paragraph and finishing at the beginning of
* the following one, if present.
*
* Text granularity types used for specifying the granularity of the region of
* text we are interested in.
**/
typedef enum {
ATK_TEXT_GRANULARITY_CHAR,
ATK_TEXT_GRANULARITY_WORD,
ATK_TEXT_GRANULARITY_SENTENCE,
ATK_TEXT_GRANULARITY_LINE,
ATK_TEXT_GRANULARITY_PARAGRAPH
} AtkTextGranularity;
/**
*AtkTextClipType:
*@ATK_TEXT_CLIP_NONE: No clipping to be done
*@ATK_TEXT_CLIP_MIN: Text clipped by min coordinate is omitted
*@ATK_TEXT_CLIP_MAX: Text clipped by max coordinate is omitted
*@ATK_TEXT_CLIP_BOTH: Only text fully within mix/max bound is retained
*
*Describes the type of clipping required.
**/
typedef enum {
ATK_TEXT_CLIP_NONE,
ATK_TEXT_CLIP_MIN,
ATK_TEXT_CLIP_MAX,
ATK_TEXT_CLIP_BOTH
} AtkTextClipType;
/**
*AtkKeyEventType:
*@ATK_KEY_EVENT_PRESS: specifies a key press event
*@ATK_KEY_EVENT_RELEASE: specifies a key release event
*@ATK_KEY_EVENT_LAST_DEFINED: Not a valid value; specifies end of enumeration
*
*Specifies the type of a keyboard evemt.
**/
typedef enum
{
ATK_KEY_EVENT_PRESS,
ATK_KEY_EVENT_RELEASE,
ATK_KEY_EVENT_LAST_DEFINED
} AtkKeyEventType;
/**
*AtkCoordType:
*@ATK_XY_SCREEN: specifies xy coordinates relative to the screen
*@ATK_XY_WINDOW: specifies xy coordinates relative to the widget's
* top-level window
*@ATK_XY_PARENT: specifies xy coordinates relative to the widget's
* immediate parent. Since: 2.30
*
*Specifies how xy coordinates are to be interpreted. Used by functions such
*as atk_component_get_position() and atk_text_get_character_extents()
**/
typedef enum {
ATK_XY_SCREEN,
ATK_XY_WINDOW,
ATK_XY_PARENT
}AtkCoordType;
/**
*AtkRole:
*@ATK_ROLE_INVALID: Invalid role
*@ATK_ROLE_ACCEL_LABEL: A label which represents an accelerator
*@ATK_ROLE_ALERT: An object which is an alert to the user. Assistive Technologies typically respond to ATK_ROLE_ALERT by reading the entire onscreen contents of containers advertising this role. Should be used for warning dialogs, etc.
*@ATK_ROLE_ANIMATION: An object which is an animated image
*@ATK_ROLE_ARROW: An arrow in one of the four cardinal directions
*@ATK_ROLE_CALENDAR: An object that displays a calendar and allows the user to select a date
*@ATK_ROLE_CANVAS: An object that can be drawn into and is used to trap events
*@ATK_ROLE_CHECK_BOX: A choice that can be checked or unchecked and provides a separate indicator for the current state
*@ATK_ROLE_CHECK_MENU_ITEM: A menu item with a check box
*@ATK_ROLE_COLOR_CHOOSER: A specialized dialog that lets the user choose a color
*@ATK_ROLE_COLUMN_HEADER: The header for a column of data
*@ATK_ROLE_COMBO_BOX: A collapsible list of choices the user can select from
*@ATK_ROLE_DATE_EDITOR: An object whose purpose is to allow a user to edit a date
*@ATK_ROLE_DESKTOP_ICON: An inconifed internal frame within a DESKTOP_PANE
*@ATK_ROLE_DESKTOP_FRAME: A pane that supports internal frames and iconified versions of those internal frames
*@ATK_ROLE_DIAL: An object whose purpose is to allow a user to set a value
*@ATK_ROLE_DIALOG: A top level window with title bar and a border
*@ATK_ROLE_DIRECTORY_PANE: A pane that allows the user to navigate through and select the contents of a directory
*@ATK_ROLE_DRAWING_AREA: An object used for drawing custom user interface elements
*@ATK_ROLE_FILE_CHOOSER: A specialized dialog that lets the user choose a file
*@ATK_ROLE_FILLER: A object that fills up space in a user interface
*@ATK_ROLE_FONT_CHOOSER: A specialized dialog that lets the user choose a font
*@ATK_ROLE_FRAME: A top level window with a title bar, border, menubar, etc.
*@ATK_ROLE_GLASS_PANE: A pane that is guaranteed to be painted on top of all panes beneath it
*@ATK_ROLE_HTML_CONTAINER: A document container for HTML, whose children represent the document content
*@ATK_ROLE_ICON: A small fixed size picture, typically used to decorate components
*@ATK_ROLE_IMAGE: An object whose primary purpose is to display an image
*@ATK_ROLE_INTERNAL_FRAME: A frame-like object that is clipped by a desktop pane
*@ATK_ROLE_LABEL: An object used to present an icon or short string in an interface
*@ATK_ROLE_LAYERED_PANE: A specialized pane that allows its children to be drawn in layers, providing a form of stacking order
*@ATK_ROLE_LIST: An object that presents a list of objects to the user and allows the user to select one or more of them
*@ATK_ROLE_LIST_ITEM: An object that represents an element of a list
*@ATK_ROLE_MENU: An object usually found inside a menu bar that contains a list of actions the user can choose from
*@ATK_ROLE_MENU_BAR: An object usually drawn at the top of the primary dialog box of an application that contains a list of menus the user can choose from
*@ATK_ROLE_MENU_ITEM: An object usually contained in a menu that presents an action the user can choose
*@ATK_ROLE_OPTION_PANE: A specialized pane whose primary use is inside a DIALOG
*@ATK_ROLE_PAGE_TAB: An object that is a child of a page tab list
*@ATK_ROLE_PAGE_TAB_LIST: An object that presents a series of panels (or page tabs), one at a time, through some mechanism provided by the object
*@ATK_ROLE_PANEL: A generic container that is often used to group objects
*@ATK_ROLE_PASSWORD_TEXT: A text object uses for passwords, or other places where the text content is not shown visibly to the user
*@ATK_ROLE_POPUP_MENU: A temporary window that is usually used to offer the user a list of choices, and then hides when the user selects one of those choices
*@ATK_ROLE_PROGRESS_BAR: An object used to indicate how much of a task has been completed
*@ATK_ROLE_PUSH_BUTTON: An object the user can manipulate to tell the application to do something
*@ATK_ROLE_RADIO_BUTTON: A specialized check box that will cause other radio buttons in the same group to become unchecked when this one is checked
*@ATK_ROLE_RADIO_MENU_ITEM: A check menu item which belongs to a group. At each instant exactly one of the radio menu items from a group is selected
*@ATK_ROLE_ROOT_PANE: A specialized pane that has a glass pane and a layered pane as its children
*@ATK_ROLE_ROW_HEADER: The header for a row of data
*@ATK_ROLE_SCROLL_BAR: An object usually used to allow a user to incrementally view a large amount of data.
*@ATK_ROLE_SCROLL_PANE: An object that allows a user to incrementally view a large amount of information
*@ATK_ROLE_SEPARATOR: An object usually contained in a menu to provide a visible and logical separation of the contents in a menu
*@ATK_ROLE_SLIDER: An object that allows the user to select from a bounded range
*@ATK_ROLE_SPLIT_PANE: A specialized panel that presents two other panels at the same time
*@ATK_ROLE_SPIN_BUTTON: An object used to get an integer or floating point number from the user
*@ATK_ROLE_STATUSBAR: An object which reports messages of minor importance to the user
*@ATK_ROLE_TABLE: An object used to represent information in terms of rows and columns
*@ATK_ROLE_TABLE_CELL: A cell in a table
*@ATK_ROLE_TABLE_COLUMN_HEADER: The header for a column of a table
*@ATK_ROLE_TABLE_ROW_HEADER: The header for a row of a table
*@ATK_ROLE_TEAR_OFF_MENU_ITEM: A menu item used to tear off and reattach its menu
*@ATK_ROLE_TERMINAL: An object that represents an accessible terminal. (Since: 0.6)
*@ATK_ROLE_TEXT: An interactive widget that supports multiple lines of text and
* optionally accepts user input, but whose purpose is not to solicit user input.
* Thus ATK_ROLE_TEXT is appropriate for the text view in a plain text editor
* but inappropriate for an input field in a dialog box or web form. For widgets
* whose purpose is to solicit input from the user, see ATK_ROLE_ENTRY and
* ATK_ROLE_PASSWORD_TEXT. For generic objects which display a brief amount of
* textual information, see ATK_ROLE_STATIC.
*@ATK_ROLE_TOGGLE_BUTTON: A specialized push button that can be checked or unchecked, but does not provide a separate indicator for the current state
*@ATK_ROLE_TOOL_BAR: A bar or palette usually composed of push buttons or toggle buttons
*@ATK_ROLE_TOOL_TIP: An object that provides information about another object
*@ATK_ROLE_TREE: An object used to represent hierarchical information to the user
*@ATK_ROLE_TREE_TABLE: An object capable of expanding and collapsing rows as well as showing multiple columns of data. (Since: 0.7)
*@ATK_ROLE_UNKNOWN: The object contains some Accessible information, but its role is not known
*@ATK_ROLE_VIEWPORT: An object usually used in a scroll pane
*@ATK_ROLE_WINDOW: A top level window with no title or border.
*@ATK_ROLE_HEADER: An object that serves as a document header. (Since: 1.1.1)
*@ATK_ROLE_FOOTER: An object that serves as a document footer. (Since: 1.1.1)
*@ATK_ROLE_PARAGRAPH: An object which is contains a paragraph of text content. (Since: 1.1.1)
*@ATK_ROLE_RULER: An object which describes margins and tab stops, etc. for text objects which it controls (should have CONTROLLER_FOR relation to such). (Since: 1.1.1)
*@ATK_ROLE_APPLICATION: The object is an application object, which may contain @ATK_ROLE_FRAME objects or other types of accessibles. The root accessible of any application's ATK hierarchy should have ATK_ROLE_APPLICATION. (Since: 1.1.4)
*@ATK_ROLE_AUTOCOMPLETE: The object is a dialog or list containing items for insertion into an entry widget, for instance a list of words for completion of a text entry. (Since: 1.3)
*@ATK_ROLE_EDITBAR: The object is an editable text object in a toolbar. (Since: 1.5)
*@ATK_ROLE_EMBEDDED: The object is an embedded container within a document or panel. This role is a grouping "hint" indicating that the contained objects share a context. (Since: 1.7.2)
*@ATK_ROLE_ENTRY: The object is a component whose textual content may be entered or modified by the user, provided @ATK_STATE_EDITABLE is present. (Since: 1.11)
*@ATK_ROLE_CHART: The object is a graphical depiction of quantitative data. It may contain multiple subelements whose attributes and/or description may be queried to obtain both the quantitative data and information about how the data is being presented. The LABELLED_BY relation is particularly important in interpreting objects of this type, as is the accessible-description property. (Since: 1.11)
*@ATK_ROLE_CAPTION: The object contains descriptive information, usually textual, about another user interface element such as a table, chart, or image. (Since: 1.11)
*@ATK_ROLE_DOCUMENT_FRAME: The object is a visual frame or container which contains a view of document content. Document frames may occur within another Document instance, in which case the second document may be said to be embedded in the containing instance. HTML frames are often ROLE_DOCUMENT_FRAME. Either this object, or a singleton descendant, should implement the Document interface. (Since: 1.11)
*@ATK_ROLE_HEADING: The object serves as a heading for content which follows it in a document. The 'heading level' of the heading, if availabe, may be obtained by querying the object's attributes.
*@ATK_ROLE_PAGE: The object is a containing instance which encapsulates a page of information. @ATK_ROLE_PAGE is used in documents and content which support a paginated navigation model. (Since: 1.11)
*@ATK_ROLE_SECTION: The object is a containing instance of document content which constitutes a particular 'logical' section of the document. The type of content within a section, and the nature of the section division itself, may be obtained by querying the object's attributes. Sections may be nested. (Since: 1.11)
*@ATK_ROLE_REDUNDANT_OBJECT: The object is redundant with another object in the hierarchy, and is exposed for purely technical reasons. Objects of this role should normally be ignored by clients. (Since: 1.11)
*@ATK_ROLE_FORM: The object is a container for form controls, for instance as part of a
* web form or user-input form within a document. This role is primarily a tag/convenience for
* clients when navigating complex documents, it is not expected that ordinary GUI containers will
* always have ATK_ROLE_FORM. (Since: 1.12.0)
*@ATK_ROLE_LINK: The object is a hypertext anchor, i.e. a "link" in a
* hypertext document. Such objects are distinct from 'inline'
* content which may also use the Hypertext/Hyperlink interfaces
* to indicate the range/location within a text object where
* an inline or embedded object lies. (Since: 1.12.1)
*@ATK_ROLE_INPUT_METHOD_WINDOW: The object is a window or similar viewport
* which is used to allow composition or input of a 'complex character',
* in other words it is an "input method window." (Since: 1.12.1)
*@ATK_ROLE_TABLE_ROW: A row in a table. (Since: 2.1.0)
*@ATK_ROLE_TREE_ITEM: An object that represents an element of a tree. (Since: 2.1.0)
*@ATK_ROLE_DOCUMENT_SPREADSHEET: A document frame which contains a spreadsheet. (Since: 2.1.0)
*@ATK_ROLE_DOCUMENT_PRESENTATION: A document frame which contains a presentation or slide content. (Since: 2.1.0)
*@ATK_ROLE_DOCUMENT_TEXT: A document frame which contains textual content, such as found in a word processing application. (Since: 2.1.0)
*@ATK_ROLE_DOCUMENT_WEB: A document frame which contains HTML or other markup suitable for display in a web browser. (Since: 2.1.0)
*@ATK_ROLE_DOCUMENT_EMAIL: A document frame which contains email content to be displayed or composed either in plain text or HTML. (Since: 2.1.0)
*@ATK_ROLE_COMMENT: An object found within a document and designed to present a comment, note, or other annotation. In some cases, this object might not be visible until activated. (Since: 2.1.0)
*@ATK_ROLE_LIST_BOX: A non-collapsible list of choices the user can select from. (Since: 2.1.0)
*@ATK_ROLE_GROUPING: A group of related widgets. This group typically has a label. (Since: 2.1.0)
*@ATK_ROLE_IMAGE_MAP: An image map object. Usually a graphic with multiple hotspots, where each hotspot can be activated resulting in the loading of another document or section of a document. (Since: 2.1.0)
*@ATK_ROLE_NOTIFICATION: A transitory object designed to present a message to the user, typically at the desktop level rather than inside a particular application. (Since: 2.1.0)
*@ATK_ROLE_INFO_BAR: An object designed to present a message to the user within an existing window. (Since: 2.1.0)
*@ATK_ROLE_LEVEL_BAR: A bar that serves as a level indicator to, for instance, show the strength of a password or the state of a battery. (Since: 2.7.3)
*@ATK_ROLE_TITLE_BAR: A bar that serves as the title of a window or a
* dialog. (Since: 2.12)
*@ATK_ROLE_BLOCK_QUOTE: An object which contains a text section
* that is quoted from another source. (Since: 2.12)
*@ATK_ROLE_AUDIO: An object which represents an audio element. (Since: 2.12)
*@ATK_ROLE_VIDEO: An object which represents a video element. (Since: 2.12)
*@ATK_ROLE_DEFINITION: A definition of a term or concept. (Since: 2.12)
*@ATK_ROLE_ARTICLE: A section of a page that consists of a
* composition that forms an independent part of a document, page, or
* site. Examples: A blog entry, a news story, a forum post. (Since: 2.12)
*@ATK_ROLE_LANDMARK: A region of a web page intended as a
* navigational landmark. This is designed to allow Assistive
* Technologies to provide quick navigation among key regions within a
* document. (Since: 2.12)
*@ATK_ROLE_LOG: A text widget or container holding log content, such
* as chat history and error logs. In this role there is a
* relationship between the arrival of new items in the log and the
* reading order. The log contains a meaningful sequence and new
* information is added only to the end of the log, not at arbitrary
* points. (Since: 2.12)
*@ATK_ROLE_MARQUEE: A container where non-essential information
* changes frequently. Common usages of marquee include stock tickers
* and ad banners. The primary difference between a marquee and a log
* is that logs usually have a meaningful order or sequence of
* important content changes. (Since: 2.12)
*@ATK_ROLE_MATH: A text widget or container that holds a mathematical
* expression. (Since: 2.12)
*@ATK_ROLE_RATING: A widget whose purpose is to display a rating,
* such as the number of stars associated with a song in a media
* player. Objects of this role should also implement
* AtkValue. (Since: 2.12)
*@ATK_ROLE_TIMER: An object containing a numerical counter which
* indicates an amount of elapsed time from a start point, or the time
* remaining until an end point. (Since: 2.12)
*@ATK_ROLE_DESCRIPTION_LIST: An object that represents a list of
* term-value groups. A term-value group represents a individual
* description and consist of one or more names
* (ATK_ROLE_DESCRIPTION_TERM) followed by one or more values
* (ATK_ROLE_DESCRIPTION_VALUE). For each list, there should not be
* more than one group with the same term name. (Since: 2.12)
*@ATK_ROLE_DESCRIPTION_TERM: An object that represents a term or phrase
* with a corresponding definition. (Since: 2.12)
*@ATK_ROLE_DESCRIPTION_VALUE: An object that represents the
* description, definition or value of a term. (Since: 2.12)
*@ATK_ROLE_STATIC: A generic non-container object whose purpose is to display a
* brief amount of information to the user and whose role is known by the
* implementor but lacks semantic value for the user. Examples in which
* %ATK_ROLE_STATIC is appropriate include the message displayed in a message box
* and an image used as an alternative means to display text. %ATK_ROLE_STATIC
* should not be applied to widgets which are traditionally interactive, objects
* which display a significant amount of content, or any object which has an
* accessible relation pointing to another object. Implementors should expose the
* displayed information through the accessible name of the object. If doing so seems
* inappropriate, it may indicate that a different role should be used. For
* labels which describe another widget, see %ATK_ROLE_LABEL. For text views, see
* %ATK_ROLE_TEXT. For generic containers, see %ATK_ROLE_PANEL. For objects whose
* role is not known by the implementor, see %ATK_ROLE_UNKNOWN. (Since: 2.16)
*@ATK_ROLE_MATH_FRACTION: An object that represents a mathematical fraction.
* (Since: 2.16)
*@ATK_ROLE_MATH_ROOT: An object that represents a mathematical expression
* displayed with a radical. (Since: 2.16)
*@ATK_ROLE_SUBSCRIPT: An object that contains text that is displayed as a
* subscript. (Since: 2.16)
*@ATK_ROLE_SUPERSCRIPT: An object that contains text that is displayed as a
* superscript. (Since: 2.16)
*@ATK_ROLE_FOOTNOTE: An object that contains the text of a footnote. (Since: 2.26)
*@ATK_ROLE_CONTENT_DELETION: Content previously deleted or proposed to be
* deleted, e.g. in revision history or a content view providing suggestions
* from reviewers. (Since: 2.34)
*@ATK_ROLE_CONTENT_INSERTION: Content previously inserted or proposed to be
* inserted, e.g. in revision history or a content view providing suggestions
* from reviewers. (Since: 2.34)
*@ATK_ROLE_MARK: A run of content that is marked or highlighted, such as for
* reference purposes, or to call it out as having a special purpose. If the
* marked content has an associated section in the document elaborating on the
* reason for the mark, then %ATK_RELATION_DETAILS should be used on the mark
* to point to that associated section. In addition, the reciprocal relation
* %ATK_RELATION_DETAILS_FOR should be used on the associated content section
* to point back to the mark. (Since: 2.36)
*@ATK_ROLE_SUGGESTION: A container for content that is called out as a proposed
* change from the current version of the document, such as by a reviewer of the
* content. This role should include either %ATK_ROLE_CONTENT_DELETION and/or
* %ATK_ROLE_CONTENT_INSERTION children, in any order, to indicate what the
* actual change is. (Since: 2.36)
*@ATK_ROLE_LAST_DEFINED: not a valid role, used for finding end of the enumeration
*
* Describes the role of an object
*
* These are the built-in enumerated roles that UI components can have
* in ATK. Other roles may be added at runtime, so an AtkRole >=
* %ATK_ROLE_LAST_DEFINED is not necessarily an error.
*/
typedef enum
{
ATK_ROLE_INVALID = 0,
ATK_ROLE_ACCEL_LABEL, /*<nick=accelerator-label>*/
ATK_ROLE_ALERT,
ATK_ROLE_ANIMATION,
ATK_ROLE_ARROW,
ATK_ROLE_CALENDAR,
ATK_ROLE_CANVAS,
ATK_ROLE_CHECK_BOX,
ATK_ROLE_CHECK_MENU_ITEM,
ATK_ROLE_COLOR_CHOOSER,
ATK_ROLE_COLUMN_HEADER,
ATK_ROLE_COMBO_BOX,
ATK_ROLE_DATE_EDITOR,
ATK_ROLE_DESKTOP_ICON,
ATK_ROLE_DESKTOP_FRAME,
ATK_ROLE_DIAL,
ATK_ROLE_DIALOG,
ATK_ROLE_DIRECTORY_PANE,
ATK_ROLE_DRAWING_AREA,
ATK_ROLE_FILE_CHOOSER,
ATK_ROLE_FILLER,
ATK_ROLE_FONT_CHOOSER,
ATK_ROLE_FRAME,
ATK_ROLE_GLASS_PANE,
ATK_ROLE_HTML_CONTAINER,
ATK_ROLE_ICON,
ATK_ROLE_IMAGE,
ATK_ROLE_INTERNAL_FRAME,
ATK_ROLE_LABEL,
ATK_ROLE_LAYERED_PANE,
ATK_ROLE_LIST,
ATK_ROLE_LIST_ITEM,
ATK_ROLE_MENU,
ATK_ROLE_MENU_BAR,
ATK_ROLE_MENU_ITEM,
ATK_ROLE_OPTION_PANE,
ATK_ROLE_PAGE_TAB,
ATK_ROLE_PAGE_TAB_LIST,
ATK_ROLE_PANEL,
ATK_ROLE_PASSWORD_TEXT,
ATK_ROLE_POPUP_MENU,
ATK_ROLE_PROGRESS_BAR,
ATK_ROLE_PUSH_BUTTON,
ATK_ROLE_RADIO_BUTTON,
ATK_ROLE_RADIO_MENU_ITEM,
ATK_ROLE_ROOT_PANE,
ATK_ROLE_ROW_HEADER,
ATK_ROLE_SCROLL_BAR,
ATK_ROLE_SCROLL_PANE,
ATK_ROLE_SEPARATOR,
ATK_ROLE_SLIDER,
ATK_ROLE_SPLIT_PANE,
ATK_ROLE_SPIN_BUTTON,
ATK_ROLE_STATUSBAR,
ATK_ROLE_TABLE,
ATK_ROLE_TABLE_CELL,
ATK_ROLE_TABLE_COLUMN_HEADER,
ATK_ROLE_TABLE_ROW_HEADER,
ATK_ROLE_TEAR_OFF_MENU_ITEM,
ATK_ROLE_TERMINAL,
ATK_ROLE_TEXT,
ATK_ROLE_TOGGLE_BUTTON,
ATK_ROLE_TOOL_BAR,
ATK_ROLE_TOOL_TIP,
ATK_ROLE_TREE,
ATK_ROLE_TREE_TABLE,
ATK_ROLE_UNKNOWN,
ATK_ROLE_VIEWPORT,
ATK_ROLE_WINDOW,
ATK_ROLE_HEADER,
ATK_ROLE_FOOTER,
ATK_ROLE_PARAGRAPH,
ATK_ROLE_RULER,
ATK_ROLE_APPLICATION,
ATK_ROLE_AUTOCOMPLETE,
ATK_ROLE_EDITBAR, /*<nick=edit-bar>*/
ATK_ROLE_EMBEDDED,
ATK_ROLE_ENTRY,
ATK_ROLE_CHART,
ATK_ROLE_CAPTION,
ATK_ROLE_DOCUMENT_FRAME,
ATK_ROLE_HEADING,
ATK_ROLE_PAGE,
ATK_ROLE_SECTION,
ATK_ROLE_REDUNDANT_OBJECT,
ATK_ROLE_FORM,
ATK_ROLE_LINK,
ATK_ROLE_INPUT_METHOD_WINDOW,
ATK_ROLE_TABLE_ROW,
ATK_ROLE_TREE_ITEM,
ATK_ROLE_DOCUMENT_SPREADSHEET,
ATK_ROLE_DOCUMENT_PRESENTATION,
ATK_ROLE_DOCUMENT_TEXT,
ATK_ROLE_DOCUMENT_WEB,
ATK_ROLE_DOCUMENT_EMAIL,
ATK_ROLE_COMMENT,
ATK_ROLE_LIST_BOX,
ATK_ROLE_GROUPING,
ATK_ROLE_IMAGE_MAP,
ATK_ROLE_NOTIFICATION,
ATK_ROLE_INFO_BAR,
ATK_ROLE_LEVEL_BAR,
ATK_ROLE_TITLE_BAR,
ATK_ROLE_BLOCK_QUOTE,
ATK_ROLE_AUDIO,
ATK_ROLE_VIDEO,
ATK_ROLE_DEFINITION,
ATK_ROLE_ARTICLE,
ATK_ROLE_LANDMARK,
ATK_ROLE_LOG,
ATK_ROLE_MARQUEE,
ATK_ROLE_MATH,
ATK_ROLE_RATING,
ATK_ROLE_TIMER,
ATK_ROLE_DESCRIPTION_LIST,
ATK_ROLE_DESCRIPTION_TERM,
ATK_ROLE_DESCRIPTION_VALUE,
ATK_ROLE_STATIC,
ATK_ROLE_MATH_FRACTION,
ATK_ROLE_MATH_ROOT,
ATK_ROLE_SUBSCRIPT,
ATK_ROLE_SUPERSCRIPT,
ATK_ROLE_FOOTNOTE,
ATK_ROLE_CONTENT_DELETION,
ATK_ROLE_CONTENT_INSERTION,
ATK_ROLE_MARK,
ATK_ROLE_SUGGESTION,
ATK_ROLE_LAST_DEFINED
} AtkRole;
/**
*AtkLayer:
*@ATK_LAYER_INVALID: The object does not have a layer
*@ATK_LAYER_BACKGROUND: This layer is reserved for the desktop background
*@ATK_LAYER_CANVAS: This layer is used for Canvas components
*@ATK_LAYER_WIDGET: This layer is normally used for components
*@ATK_LAYER_MDI: This layer is used for layered components
*@ATK_LAYER_POPUP: This layer is used for popup components, such as menus
*@ATK_LAYER_OVERLAY: This layer is reserved for future use.
*@ATK_LAYER_WINDOW: This layer is used for toplevel windows.
*
* Describes the layer of a component
*
* These enumerated "layer values" are used when determining which UI
* rendering layer a component is drawn into, which can help in making
* determinations of when components occlude one another.
**/
typedef enum
{
ATK_LAYER_INVALID,
ATK_LAYER_BACKGROUND,
ATK_LAYER_CANVAS,
ATK_LAYER_WIDGET,
ATK_LAYER_MDI,
ATK_LAYER_POPUP,
ATK_LAYER_OVERLAY,
ATK_LAYER_WINDOW
} AtkLayer;
/**
* AtkValueType:
*
* Default types for a given value. Those are defined in order to
* easily get localized strings to describe a given value or a given
* subrange, using atk_value_type_get_localized_name().
*
*/
typedef enum
{
ATK_VALUE_VERY_WEAK,
ATK_VALUE_WEAK,
ATK_VALUE_ACCEPTABLE,
ATK_VALUE_STRONG,
ATK_VALUE_VERY_STRONG,
ATK_VALUE_VERY_LOW,
ATK_VALUE_LOW,
ATK_VALUE_MEDIUM,
ATK_VALUE_HIGH,
ATK_VALUE_VERY_HIGH,
ATK_VALUE_VERY_BAD,
ATK_VALUE_BAD,
ATK_VALUE_GOOD,
ATK_VALUE_VERY_GOOD,
ATK_VALUE_BEST,
ATK_VALUE_LAST_DEFINED
}AtkValueType;
G_END_DECLS

View File

@@ -0,0 +1,38 @@
/*** BEGIN file-header ***/
#include "config.h"
#include "atktypes.h"
/*** END file-header ***/
/*** BEGIN file-production ***/
/* enumerations from "@basename@" */
/*** END file-production ***/
/*** BEGIN value-header ***/
GType
@enum_name@_get_type (void)
{
static volatile gsize g_define_type_id__volatile;
if (g_once_init_enter (&g_define_type_id__volatile))
{
static const G@Type@Value values[] = {
/*** END value-header ***/
/*** BEGIN value-production ***/
{ @VALUENAME@, "@VALUENAME@", "@valuenick@" },
/*** END value-production ***/
/*** BEGIN value-tail ***/
{ 0, NULL, NULL }
};
GType g_define_type_id =
g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
}
return g_define_type_id__volatile;
}
/*** END value-tail ***/

View File

@@ -0,0 +1,26 @@
/*** BEGIN file-header ***/
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#pragma once
#include <glib-object.h>
G_BEGIN_DECLS
/*** END file-header ***/
/*** BEGIN file-production ***/
/* enumerations from "@basename@" */
/*** END file-production ***/
/*** BEGIN value-header ***/
GDK_AVAILABLE_IN_ALL
GType @enum_name@_get_type (void);
#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type())
/*** END value-header ***/
/*** BEGIN file-tail ***/
G_END_DECLS
/*** END file-tail ***/

206
atk/atkgobjectaccessible.c Normal file
View File

@@ -0,0 +1,206 @@
/* ATK - Accessibility Toolkit
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <atk/atkgobjectaccessible.h>
#include <atk/atkregistry.h>
#include <atk/atkutil.h>
/**
* SECTION:atkgobjectaccessible
* @Short_description: This object class is derived from AtkObject and
* can be used as a basis implementing accessible objects.
* @Title:AtkGObjectAccessible
*
* This object class is derived from AtkObject. It can be used as a
* basis for implementing accessible objects for GObjects which are
* not derived from GtkWidget. One example of its use is in providing
* an accessible object for GnomeCanvasItem in the GAIL library.
*/
static void atk_gobject_accessible_class_init (AtkGObjectAccessibleClass *klass);
static void atk_real_gobject_accessible_initialize (AtkObject *atk_obj,
gpointer data);
static void atk_gobject_accessible_object_gone_cb (gpointer data);
static GQuark quark_accessible_object = 0;
static GQuark quark_object = 0;
static gpointer parent_class = NULL;
GType
atk_gobject_accessible_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (AtkGObjectAccessibleClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) atk_gobject_accessible_class_init,
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (AtkGObjectAccessible),
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
type = g_type_register_static (ATK_TYPE_OBJECT,
"AtkGObjectAccessible", &tinfo, 0);
}
return type;
}
/**
* atk_gobject_accessible_for_object:
* @obj: a #GObject
*
* Gets the accessible object for the specified @obj.
*
* Returns: (transfer none): a #AtkObject which is the accessible object for
* the @obj
**/
AtkObject*
atk_gobject_accessible_for_object (GObject *obj)
{
AtkObject* accessible;
g_return_val_if_fail (G_IS_OBJECT (obj), NULL);
/* See if we have a cached accessible for this object */
accessible = quark_accessible_object ? g_object_get_qdata (obj, quark_accessible_object) : NULL;
if (!accessible)
{
AtkObjectFactory *factory;
AtkRegistry *default_registry;
default_registry = atk_get_default_registry ();
factory = atk_registry_get_factory (default_registry,
G_OBJECT_TYPE (obj));
accessible = atk_object_factory_create_accessible (factory,
obj);
if (!ATK_IS_GOBJECT_ACCESSIBLE (accessible))
{
/*
* The AtkObject which was created was not a AtkGObjectAccessible
*/
g_object_weak_ref (obj,
(GWeakNotify) g_object_unref,
accessible);
if (!quark_accessible_object)
quark_accessible_object = g_quark_from_static_string ("accessible-object");
}
g_object_set_qdata (obj, quark_accessible_object, accessible);
}
return accessible;
}
/**
* atk_gobject_accessible_get_object:
* @obj: a #AtkGObjectAccessible
*
* Gets the GObject for which @obj is the accessible object.
*
* Returns: (transfer none): a #GObject which is the object for which @obj is
* the accessible object
**/
GObject *
atk_gobject_accessible_get_object (AtkGObjectAccessible *obj)
{
g_return_val_if_fail (ATK_IS_GOBJECT_ACCESSIBLE (obj), NULL);
return g_object_get_qdata (G_OBJECT (obj), quark_object);
}
static void
atk_real_gobject_accessible_initialize (AtkObject *atk_obj,
gpointer data)
{
AtkGObjectAccessible *atk_gobj;
atk_gobj = ATK_GOBJECT_ACCESSIBLE (atk_obj);
g_object_set_qdata (G_OBJECT (atk_gobj), quark_object, data);
atk_obj->layer = ATK_LAYER_WIDGET;
g_object_weak_ref (data,
(GWeakNotify) atk_gobject_accessible_object_gone_cb,
atk_gobj);
}
static void
atk_gobject_accessible_object_gone_cb (gpointer data)
{
GObject *object;
g_return_if_fail (ATK_IS_GOBJECT_ACCESSIBLE (data));
object = atk_gobject_accessible_get_object (data);
if (object)
g_object_set_qdata (object, quark_accessible_object, NULL);
g_object_set_qdata (G_OBJECT (data), quark_object, NULL);
atk_object_notify_state_change (ATK_OBJECT (data), ATK_STATE_DEFUNCT,
TRUE);
g_object_unref (data);
}
static void
atk_gobject_accessible_dispose (GObject *atk_obj)
{
GObject *obj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (atk_obj));
if (obj) {
g_object_set_qdata (obj, quark_accessible_object, NULL);
g_object_weak_unref (obj,
(GWeakNotify) atk_gobject_accessible_object_gone_cb,
atk_obj);
g_object_set_qdata (atk_obj, quark_object, NULL);
atk_object_notify_state_change (ATK_OBJECT (atk_obj), ATK_STATE_DEFUNCT,
TRUE);
}
G_OBJECT_CLASS (parent_class)->dispose (atk_obj);
}
static void
atk_gobject_accessible_class_init (AtkGObjectAccessibleClass *klass)
{
AtkObjectClass *class;
GObjectClass *object_class;
class = ATK_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
class->initialize = atk_real_gobject_accessible_initialize;
object_class = G_OBJECT_CLASS (klass);
object_class->dispose = atk_gobject_accessible_dispose;
if (!quark_accessible_object)
quark_accessible_object = g_quark_from_static_string ("accessible-object");
quark_object = g_quark_from_static_string ("object-for-accessible");
}

View File

@@ -0,0 +1,68 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_GOBJECT_ACCESSIBLE_H__
#define __ATK_GOBJECT_ACCESSIBLE_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <atk/atkobject.h>
G_BEGIN_DECLS
/*
* The AtkGObjectAccessible class is provided as a basis for implementing
* accessibility support for objects which are not GTK+ widgets
*/
#define ATK_TYPE_GOBJECT_ACCESSIBLE (atk_gobject_accessible_get_type ())
#define ATK_GOBJECT_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_GOBJECT_ACCESSIBLE, AtkGObjectAccessible))
#define ATK_GOBJECT_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_GOBJECT_ACCESSIBLE, AtkGObjectAccessibleClass))
#define ATK_IS_GOBJECT_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_GOBJECT_ACCESSIBLE))
#define ATK_IS_GOBJECT_ACCESSIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_GOBJECT_ACCESSIBLE))
#define ATK_GOBJECT_ACCESSIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_GOBJECT_ACCESSIBLE, AtkGObjectAccessibleClass))
typedef struct _AtkGObjectAccessible AtkGObjectAccessible;
typedef struct _AtkGObjectAccessibleClass AtkGObjectAccessibleClass;
struct _AtkGObjectAccessible
{
AtkObject parent;
};
GDK_AVAILABLE_IN_ALL
GType atk_gobject_accessible_get_type (void);
struct _AtkGObjectAccessibleClass
{
AtkObjectClass parent_class;
AtkFunction pad1;
AtkFunction pad2;
};
GDK_AVAILABLE_IN_ALL
AtkObject *atk_gobject_accessible_for_object (GObject *obj);
GDK_AVAILABLE_IN_ALL
GObject *atk_gobject_accessible_get_object (AtkGObjectAccessible *obj);
G_END_DECLS
#endif /* __ATK_GOBJECT_ACCESSIBLE_H__ */

373
atk/atkhyperlink.c Normal file
View File

@@ -0,0 +1,373 @@
/* ATK - Accessibility Toolkit
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "atkhyperlink.h"
#include <glib/gi18n-lib.h>
/**
* SECTION:atkhyperlink
* @Short_description: An ATK object which encapsulates a link or set
* of links in a hypertext document.
* @Title:AtkHyperlink
*
* An ATK object which encapsulates a link or set of links (for
* instance in the case of client-side image maps) in a hypertext
* document. It may implement the AtkAction interface. AtkHyperlink
* may also be used to refer to inline embedded content, since it
* allows specification of a start and end offset within the host
* AtkHypertext object.
*/
enum
{
LINK_ACTIVATED,
LAST_SIGNAL
};
enum
{
PROP_0, /* gobject convention */
PROP_NUMBER_ANCHORS,
PROP_END_INDEX,
PROP_START_INDEX,
PROP_LAST
};
static void atk_hyperlink_class_init (AtkHyperlinkClass *klass);
static void atk_hyperlink_init (AtkHyperlink *link,
AtkHyperlinkClass *klass);
static void atk_hyperlink_real_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void atk_hyperlink_action_iface_init (AtkActionIface *iface);
static guint atk_hyperlink_signals[LAST_SIGNAL] = { 0, };
static gpointer parent_class = NULL;
GType
atk_hyperlink_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo typeInfo =
{
sizeof (AtkHyperlinkClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) atk_hyperlink_class_init,
(GClassFinalizeFunc) NULL,
NULL,
sizeof (AtkHyperlink),
0,
(GInstanceInitFunc) atk_hyperlink_init,
} ;
static const GInterfaceInfo action_info =
{
(GInterfaceInitFunc) atk_hyperlink_action_iface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
type = g_type_register_static (G_TYPE_OBJECT, "AtkHyperlink", &typeInfo, 0) ;
g_type_add_interface_static (type, ATK_TYPE_ACTION, &action_info);
}
return type;
}
static void
atk_hyperlink_class_init (AtkHyperlinkClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
gobject_class->get_property = atk_hyperlink_real_get_property;
klass->link_activated = NULL;
g_object_class_install_property (gobject_class,
PROP_NUMBER_ANCHORS,
g_param_spec_int ("number-of-anchors",
_("Number of Anchors"),
_("The number of anchors associated with the AtkHyperlink object"),
0,
G_MAXINT,
0,
G_PARAM_READABLE));
g_object_class_install_property (gobject_class,
PROP_END_INDEX,
g_param_spec_int ("end-index",
_("End index"),
_("The end index of the AtkHyperlink object"),
0,
G_MAXINT,
0,
G_PARAM_READABLE));
g_object_class_install_property (gobject_class,
PROP_START_INDEX,
g_param_spec_int ("start-index",
_("Start index"),
_("The start index of the AtkHyperlink object"),
0,
G_MAXINT,
0,
G_PARAM_READABLE));
/**
* AtkHyperlink::link-activated:
* @atkhyperlink: the object which received the signal.
*
* The signal link-activated is emitted when a link is activated.
*/
atk_hyperlink_signals[LINK_ACTIVATED] =
g_signal_new ("link_activated",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (AtkHyperlinkClass, link_activated),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
}
static void
atk_hyperlink_init (AtkHyperlink *link,
AtkHyperlinkClass *klass)
{
}
static void
atk_hyperlink_real_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
AtkHyperlink* link;
link = ATK_HYPERLINK (object);
switch (prop_id)
{
case PROP_NUMBER_ANCHORS:
g_value_set_int (value, atk_hyperlink_get_n_anchors (link));
break;
case PROP_END_INDEX:
g_value_set_int (value, atk_hyperlink_get_end_index (link));
break;
case PROP_START_INDEX:
g_value_set_int (value, atk_hyperlink_get_start_index (link));
break;
default:
break;
}
}
/**
* atk_hyperlink_get_uri:
* @link_: an #AtkHyperlink
* @i: a (zero-index) integer specifying the desired anchor
*
* Get a the URI associated with the anchor specified
* by @i of @link_.
*
* Multiple anchors are primarily used by client-side image maps.
*
* Returns: a string specifying the URI
**/
gchar*
atk_hyperlink_get_uri (AtkHyperlink *link,
gint i)
{
AtkHyperlinkClass *klass;
g_return_val_if_fail (ATK_IS_HYPERLINK (link), NULL);
klass = ATK_HYPERLINK_GET_CLASS (link);
if (klass->get_uri)
return (klass->get_uri) (link, i);
else
return NULL;
}
/**
* atk_hyperlink_get_object:
* @link_: an #AtkHyperlink
* @i: a (zero-index) integer specifying the desired anchor
*
* Returns the item associated with this hyperlinks nth anchor.
* For instance, the returned #AtkObject will implement #AtkText
* if @link_ is a text hyperlink, #AtkImage if @link_ is an image
* hyperlink etc.
*
* Multiple anchors are primarily used by client-side image maps.
*
* Returns: (transfer none): an #AtkObject associated with this hyperlinks
* i-th anchor
**/
AtkObject*
atk_hyperlink_get_object (AtkHyperlink *link,
gint i)
{
AtkHyperlinkClass *klass;
g_return_val_if_fail (ATK_IS_HYPERLINK (link), NULL);
klass = ATK_HYPERLINK_GET_CLASS (link);
if (klass->get_object)
return (klass->get_object) (link, i);
else
return NULL;
}
/**
* atk_hyperlink_get_end_index:
* @link_: an #AtkHyperlink
*
* Gets the index with the hypertext document at which this link ends.
*
* Returns: the index with the hypertext document at which this link ends
**/
gint
atk_hyperlink_get_end_index (AtkHyperlink *link)
{
AtkHyperlinkClass *klass;
g_return_val_if_fail (ATK_IS_HYPERLINK (link), 0);
klass = ATK_HYPERLINK_GET_CLASS (link);
if (klass->get_end_index)
return (klass->get_end_index) (link);
else
return 0;
}
/**
* atk_hyperlink_get_start_index:
* @link_: an #AtkHyperlink
*
* Gets the index with the hypertext document at which this link begins.
*
* Returns: the index with the hypertext document at which this link begins
**/
gint
atk_hyperlink_get_start_index (AtkHyperlink *link)
{
AtkHyperlinkClass *klass;
g_return_val_if_fail (ATK_IS_HYPERLINK (link), 0);
klass = ATK_HYPERLINK_GET_CLASS (link);
if (klass->get_start_index)
return (klass->get_start_index) (link);
else
return 0;
}
/**
* atk_hyperlink_is_valid:
* @link_: an #AtkHyperlink
*
* Since the document that a link is associated with may have changed
* this method returns %TRUE if the link is still valid (with
* respect to the document it references) and %FALSE otherwise.
*
* Returns: whether or not this link is still valid
**/
gboolean
atk_hyperlink_is_valid (AtkHyperlink *link)
{
AtkHyperlinkClass *klass;
g_return_val_if_fail (ATK_IS_HYPERLINK (link), FALSE);
klass = ATK_HYPERLINK_GET_CLASS (link);
if (klass->is_valid)
return (klass->is_valid) (link);
else
return FALSE;
}
/**
* atk_hyperlink_is_inline:
* @link_: an #AtkHyperlink
*
* Indicates whether the link currently displays some or all of its
* content inline. Ordinary HTML links will usually return
* %FALSE, but an inline &lt;src&gt; HTML element will return
* %TRUE.
*
* Returns: whether or not this link displays its content inline.
*
**/
gboolean
atk_hyperlink_is_inline (AtkHyperlink *link)
{
AtkHyperlinkClass *klass;
g_return_val_if_fail (ATK_IS_HYPERLINK (link), FALSE);
klass = ATK_HYPERLINK_GET_CLASS (link);
if (klass->link_state)
return (klass->link_state (link) & ATK_HYPERLINK_IS_INLINE);
else
return FALSE;
}
/**
* atk_hyperlink_get_n_anchors:
* @link_: an #AtkHyperlink
*
* Gets the number of anchors associated with this hyperlink.
*
* Returns: the number of anchors associated with this hyperlink
**/
gint
atk_hyperlink_get_n_anchors (AtkHyperlink *link)
{
AtkHyperlinkClass *klass;
g_return_val_if_fail (ATK_IS_HYPERLINK (link), 0);
klass = ATK_HYPERLINK_GET_CLASS (link);
if (klass->get_n_anchors)
return (klass->get_n_anchors) (link);
else
return 0;
}
static void atk_hyperlink_action_iface_init (AtkActionIface *iface)
{
/*
* We do nothing here
*
* When we come to derive a class from AtkHyperlink we will provide an
* implementation of the AtkAction interface.
*/
}

101
atk/atkhyperlink.h Normal file
View File

@@ -0,0 +1,101 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_HYPERLINK_H__
#define __ATK_HYPERLINK_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <atk/atkaction.h>
#include <atk/atkobject.h>
G_BEGIN_DECLS
/*
* AtkHyperlink encapsulates a link or set of links in a hypertext document.
*
* It implements the AtkAction interface.
*/
#define ATK_TYPE_HYPERLINK (atk_hyperlink_get_type ())
#define ATK_HYPERLINK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_HYPERLINK, AtkHyperlink))
#define ATK_HYPERLINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_HYPERLINK, AtkHyperlinkClass))
#define ATK_IS_HYPERLINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_HYPERLINK))
#define ATK_IS_HYPERLINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_HYPERLINK))
#define ATK_HYPERLINK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_HYPERLINK, AtkHyperlinkClass))
typedef struct _AtkHyperlink AtkHyperlink;
typedef struct _AtkHyperlinkClass AtkHyperlinkClass;
struct _AtkHyperlink
{
GObject parent;
};
struct _AtkHyperlinkClass
{
GObjectClass parent;
gchar* (* get_uri) (AtkHyperlink *link_,
gint i);
AtkObject* (* get_object) (AtkHyperlink *link_,
gint i);
gint (* get_end_index) (AtkHyperlink *link_);
gint (* get_start_index) (AtkHyperlink *link_);
gboolean (* is_valid) (AtkHyperlink *link_);
gint (* get_n_anchors) (AtkHyperlink *link_);
guint (* link_state) (AtkHyperlink *link_);
gboolean (* is_selected_link) (AtkHyperlink *link_);
/* Signals */
void ( *link_activated) (AtkHyperlink *link_);
AtkFunction pad1;
};
GDK_AVAILABLE_IN_ALL
GType atk_hyperlink_get_type (void);
GDK_AVAILABLE_IN_ALL
gchar* atk_hyperlink_get_uri (AtkHyperlink *link_,
gint i);
GDK_AVAILABLE_IN_ALL
AtkObject* atk_hyperlink_get_object (AtkHyperlink *link_,
gint i);
GDK_AVAILABLE_IN_ALL
gint atk_hyperlink_get_end_index (AtkHyperlink *link_);
GDK_AVAILABLE_IN_ALL
gint atk_hyperlink_get_start_index (AtkHyperlink *link_);
GDK_AVAILABLE_IN_ALL
gboolean atk_hyperlink_is_valid (AtkHyperlink *link_);
GDK_AVAILABLE_IN_ALL
gboolean atk_hyperlink_is_inline (AtkHyperlink *link_);
GDK_AVAILABLE_IN_ALL
gint atk_hyperlink_get_n_anchors (AtkHyperlink *link_);
G_END_DECLS
#endif /* __ATK_HYPERLINK_H__ */

108
atk/atkhyperlinkimpl.c Normal file
View File

@@ -0,0 +1,108 @@
/* ATK - Accessibility Toolkit
* Copyright 2006 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <string.h>
#include "atkhyperlinkimpl.h"
/**
* SECTION:atkhyperlinkimpl
* @Short_description: An interface from which the AtkHyperlink
* associated with an AtkObject may be obtained.
* @Title:AtkHyperlinImpl
*
* AtkHyperlinkImpl allows AtkObjects to refer to their associated
* AtkHyperlink instance, if one exists. AtkHyperlinkImpl differs
* from AtkHyperlink in that AtkHyperlinkImpl is an interface, whereas
* AtkHyperlink is a object type. The AtkHyperlinkImpl interface
* allows a client to query an AtkObject for the availability of an
* associated AtkHyperlink instance, and obtain that instance. It is
* thus particularly useful in cases where embedded content or inline
* content within a text object is present, since the embedding text
* object implements AtkHypertext and the inline/embedded objects are
* exposed as children which implement AtkHyperlinkImpl, in addition
* to their being obtainable via AtkHypertext:getLink followed by
* AtkHyperlink:getObject.
*
* The AtkHyperlinkImpl interface should be supported by objects
* exposed within the hierarchy as children of an AtkHypertext
* container which correspond to "links" or embedded content within
* the text. HTML anchors are not, for instance, normally exposed
* this way, but embedded images and components which appear inline in
* the content of a text object are. The AtkHyperlinkIface interface
* allows a means of determining which children are hyperlinks in this
* sense of the word, and for obtaining their corresponding
* AtkHyperlink object, from which the embedding range, URI, etc. can
* be obtained.
*
* To some extent this interface exists because, for historical
* reasons, AtkHyperlink was defined as an object type, not an
* interface. Thus, in order to interact with AtkObjects via
* AtkHyperlink semantics, a new interface was required.
*/
GType
atk_hyperlink_impl_get_type (void)
{
static GType type = 0;
if (!type) {
GTypeInfo tinfo =
{
sizeof (AtkHyperlinkImplIface),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
};
type = g_type_register_static (G_TYPE_INTERFACE, "AtkHyperlinkImpl", &tinfo, 0);
}
return type;
}
/**
* atk_hyperlink_impl_get_hyperlink:
* @impl: a #GObject instance that implements AtkHyperlinkImplIface
*
* Gets the hyperlink associated with this object.
*
* Returns: (transfer full): an AtkHyperlink object which points to this
* implementing AtkObject.
*
* Since: 1.12
**/
AtkHyperlink *
atk_hyperlink_impl_get_hyperlink (AtkHyperlinkImpl *impl)
{
AtkHyperlinkImplIface *iface;
g_return_val_if_fail (impl != NULL, NULL);
g_return_val_if_fail (ATK_IS_HYPERLINK_IMPL (impl), NULL);
iface = ATK_HYPERLINK_IMPL_GET_IFACE (impl);
if (iface->get_hyperlink)
{
return (iface->get_hyperlink) (impl);
}
return NULL;
}

67
atk/atkhyperlinkimpl.h Normal file
View File

@@ -0,0 +1,67 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_HYPERLINK_IMPL_H__
#define __ATK_HYPERLINK_IMPL_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <atk/atkhyperlink.h>
G_BEGIN_DECLS
#define ATK_TYPE_HYPERLINK_IMPL (atk_hyperlink_impl_get_type ())
#define ATK_IS_HYPERLINK_IMPL(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_HYPERLINK_IMPL)
#define ATK_HYPERLINK_IMPL(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_HYPERLINK_IMPL, AtkHyperlinkImpl)
#define ATK_HYPERLINK_IMPL_GET_IFACE(obj) G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_HYPERLINK_IMPL, AtkHyperlinkImplIface)
#ifndef _TYPEDEF_ATK_HYPERLINK_IMPL_
#define _TYPEDEF_ATK_HYPERLINK_IMPL__
/**
* AtkHyperlinkImpl:
*
* A queryable interface which allows AtkHyperlink instances
* associated with an AtkObject to be obtained. AtkHyperlinkImpl
* corresponds to AT-SPI's Hyperlink interface, and differs from
* AtkHyperlink in that AtkHyperlink is an object type, rather than an
* interface, and thus cannot be directly queried. FTW
*/
typedef struct _AtkHyperlinkImpl AtkHyperlinkImpl;
#endif
typedef struct _AtkHyperlinkImplIface AtkHyperlinkImplIface;
struct _AtkHyperlinkImplIface
{
GTypeInterface parent;
AtkHyperlink* (* get_hyperlink) (AtkHyperlinkImpl *impl);
};
GDK_AVAILABLE_IN_ALL
GType atk_hyperlink_impl_get_type (void);
GDK_AVAILABLE_IN_ALL
AtkHyperlink *atk_hyperlink_impl_get_hyperlink (AtkHyperlinkImpl *impl);
G_END_DECLS
#endif /* __ATK_HYPERLINK_IMPL_H__ */

181
atk/atkhypertext.c Normal file
View File

@@ -0,0 +1,181 @@
/* ATK - The Accessibility Toolkit for GTK+
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "atkhypertext.h"
/**
* SECTION:atkhypertext
* @Short_description: The ATK interface which provides standard
* mechanism for manipulating hyperlinks.
* @Title:AtkHypertext
*
* An interface used for objects which implement linking between
* multiple resource or content locations, or multiple 'markers'
* within a single document. A Hypertext instance is associated with
* one or more Hyperlinks, which are associated with particular
* offsets within the Hypertext's included content. While this
* interface is derived from Text, there is no requirement that
* Hypertext instances have textual content; they may implement Image
* as well, and Hyperlinks need not have non-zero text offsets.
*/
enum {
LINK_SELECTED,
LAST_SIGNAL
};
static void atk_hypertext_base_init (AtkHypertextIface *class);
static guint atk_hypertext_signals[LAST_SIGNAL] = { 0 };
GType
atk_hypertext_get_type (void)
{
static GType type = 0;
if (!type) {
static const GTypeInfo tinfo =
{
sizeof (AtkHypertextIface),
(GBaseInitFunc) atk_hypertext_base_init,
(GBaseFinalizeFunc) NULL,
};
type = g_type_register_static (G_TYPE_INTERFACE, "AtkHypertext", &tinfo, 0);
}
return type;
}
static void
atk_hypertext_base_init (AtkHypertextIface *class)
{
static gboolean initialized = FALSE;
if (!initialized)
{
/**
* AtkHypertext::link-selected:
* @atkhypertext: the object which received the signal.
* @arg1: the index of the hyperlink which is selected
*
* The "link-selected" signal is emitted by an AtkHyperText
* object when one of the hyperlinks associated with the object
* is selected.
*/
atk_hypertext_signals[LINK_SELECTED] =
g_signal_new ("link_selected",
ATK_TYPE_HYPERTEXT,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (AtkHypertextIface, link_selected),
(GSignalAccumulator) NULL, NULL,
g_cclosure_marshal_VOID__INT,
G_TYPE_NONE,
1, G_TYPE_INT);
initialized = TRUE;
}
}
/**
* atk_hypertext_get_link:
* @hypertext: an #AtkHypertext
* @link_index: an integer specifying the desired link
*
* Gets the link in this hypertext document at index
* @link_index
*
* Returns: (transfer none): the link in this hypertext document at
* index @link_index
**/
AtkHyperlink*
atk_hypertext_get_link (AtkHypertext *hypertext,
gint link_index)
{
AtkHypertextIface *iface;
g_return_val_if_fail (ATK_IS_HYPERTEXT (hypertext), NULL);
if (link_index < 0)
return NULL;
iface = ATK_HYPERTEXT_GET_IFACE (hypertext);
if (iface->get_link)
return (*(iface->get_link)) (hypertext, link_index);
else
return NULL;
}
/**
* atk_hypertext_get_n_links:
* @hypertext: an #AtkHypertext
*
* Gets the number of links within this hypertext document.
*
* Returns: the number of links within this hypertext document
**/
gint
atk_hypertext_get_n_links (AtkHypertext *hypertext)
{
AtkHypertextIface *iface;
g_return_val_if_fail (ATK_IS_HYPERTEXT (hypertext), 0);
iface = ATK_HYPERTEXT_GET_IFACE (hypertext);
if (iface->get_n_links)
return (*(iface->get_n_links)) (hypertext);
else
return 0;
}
/**
* atk_hypertext_get_link_index:
* @hypertext: an #AtkHypertext
* @char_index: a character index
*
* Gets the index into the array of hyperlinks that is associated with
* the character specified by @char_index.
*
* Returns: an index into the array of hyperlinks in @hypertext,
* or -1 if there is no hyperlink associated with this character.
**/
gint
atk_hypertext_get_link_index (AtkHypertext *hypertext,
gint char_index)
{
AtkHypertextIface *iface;
g_return_val_if_fail (ATK_IS_HYPERTEXT (hypertext), -1);
if (char_index < 0)
return -1;
iface = ATK_HYPERTEXT_GET_IFACE (hypertext);
if (iface->get_link_index)
return (*(iface->get_link_index)) (hypertext, char_index);
else
return -1;
}

77
atk/atkhypertext.h Normal file
View File

@@ -0,0 +1,77 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_HYPERTEXT_H__
#define __ATK_HYPERTEXT_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <atk/atkhyperlink.h>
G_BEGIN_DECLS
/*
* The AtkHypertext interface provides standard mechanisms for manipulating
* hyperlinks.
*/
#define ATK_TYPE_HYPERTEXT (atk_hypertext_get_type ())
#define ATK_IS_HYPERTEXT(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_HYPERTEXT)
#define ATK_HYPERTEXT(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_HYPERTEXT, AtkHypertext)
#define ATK_HYPERTEXT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_HYPERTEXT, AtkHypertextIface))
#ifndef _TYPEDEF_ATK_HYPERTEXT_
#define _TYPEDEF_ATK_HYPERTEXT_
typedef struct _AtkHypertext AtkHypertext;
#endif
typedef struct _AtkHypertextIface AtkHypertextIface;
struct _AtkHypertextIface
{
GTypeInterface parent;
AtkHyperlink*(* get_link) (AtkHypertext *hypertext,
gint link_index);
gint (* get_n_links) (AtkHypertext *hypertext);
gint (* get_link_index) (AtkHypertext *hypertext,
gint char_index);
/*
* signal handlers
*/
void (* link_selected) (AtkHypertext *hypertext,
gint link_index);
};
GDK_AVAILABLE_IN_ALL
GType atk_hypertext_get_type (void);
GDK_AVAILABLE_IN_ALL
AtkHyperlink* atk_hypertext_get_link (AtkHypertext *hypertext,
gint link_index);
GDK_AVAILABLE_IN_ALL
gint atk_hypertext_get_n_links (AtkHypertext *hypertext);
GDK_AVAILABLE_IN_ALL
gint atk_hypertext_get_link_index (AtkHypertext *hypertext,
gint char_index);
G_END_DECLS
#endif /* __ATK_HYPERTEXT_H__ */

246
atk/atkimage.c Normal file
View File

@@ -0,0 +1,246 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "atkimage.h"
/**
* SECTION:atkimage
* @Short_description: The ATK Interface implemented by components
* which expose image or pixmap content on-screen.
* @Title:AtkImage
*
* #AtkImage should be implemented by #AtkObject subtypes on behalf of
* components which display image/pixmap information onscreen, and
* which provide information (other than just widget borders, etc.)
* via that image content. For instance, icons, buttons with icons,
* toolbar elements, and image viewing panes typically should
* implement #AtkImage.
*
* #AtkImage primarily provides two types of information: coordinate
* information (useful for screen review mode of screenreaders, and
* for use by onscreen magnifiers), and descriptive information. The
* descriptive information is provided for alternative, text-only
* presentation of the most significant information present in the
* image.
*/
GType
atk_image_get_type (void)
{
static GType type = 0;
if (!type) {
static const GTypeInfo tinfo =
{
sizeof (AtkImageIface),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL
};
type = g_type_register_static (G_TYPE_INTERFACE, "AtkImage", &tinfo, 0);
}
return type;
}
/**
* atk_image_get_image_description:
* @image: a #GObject instance that implements AtkImageIface
*
* Get a textual description of this image.
*
* Returns: a string representing the image description
**/
const gchar*
atk_image_get_image_description (AtkImage *image)
{
AtkImageIface *iface;
g_return_val_if_fail (ATK_IS_IMAGE (image), NULL);
iface = ATK_IMAGE_GET_IFACE (image);
if (iface->get_image_description)
{
return (iface->get_image_description) (image);
}
else
{
return NULL;
}
}
/**
* atk_image_get_image_size:
* @image: a #GObject instance that implements AtkImageIface
* @width: (out) (optional): filled with the image width, or -1 if the value cannot be obtained.
* @height: (out) (optional): filled with the image height, or -1 if the value cannot be obtained.
*
* Get the width and height in pixels for the specified image.
* The values of @width and @height are returned as -1 if the
* values cannot be obtained (for instance, if the object is not onscreen).
*
* If the size can not be obtained (e.g. missing support), x and y are set
* to -1.
**/
void
atk_image_get_image_size (AtkImage *image,
int *width,
int *height)
{
AtkImageIface *iface;
gint local_width, local_height;
gint *real_width, *real_height;
g_return_if_fail (ATK_IS_IMAGE (image));
if (width)
real_width = width;
else
real_width = &local_width;
if (height)
real_height = height;
else
real_height = &local_height;
iface = ATK_IMAGE_GET_IFACE (image);
if (iface->get_image_size)
{
iface->get_image_size (image, real_width, real_height);
}
else
{
*real_width = -1;
*real_height = -1;
}
}
/**
* atk_image_set_image_description:
* @image: a #GObject instance that implements AtkImageIface
* @description: a string description to set for @image
*
* Sets the textual description for this image.
*
* Returns: boolean TRUE, or FALSE if operation could
* not be completed.
**/
gboolean
atk_image_set_image_description (AtkImage *image,
const gchar *description)
{
AtkImageIface *iface;
g_return_val_if_fail (ATK_IS_IMAGE (image), FALSE);
iface = ATK_IMAGE_GET_IFACE (image);
if (iface->set_image_description)
{
return (iface->set_image_description) (image, description);
}
else
{
return FALSE;
}
}
/**
* atk_image_get_image_position:
* @image: a #GObject instance that implements AtkImageIface
* @x: (out) (optional): address of #gint to put x coordinate position; otherwise, -1 if value cannot be obtained.
* @y: (out) (optional): address of #gint to put y coordinate position; otherwise, -1 if value cannot be obtained.
* @coord_type: specifies whether the coordinates are relative to the screen
* or to the components top level window
*
* Gets the position of the image in the form of a point specifying the
* images top-left corner.
*
* If the position can not be obtained (e.g. missing support), x and y are set
* to -1.
**/
void
atk_image_get_image_position (AtkImage *image,
gint *x,
gint *y,
AtkCoordType coord_type)
{
AtkImageIface *iface;
gint local_x, local_y;
gint *real_x, *real_y;
g_return_if_fail (ATK_IS_IMAGE (image));
if (x)
real_x = x;
else
real_x = &local_x;
if (y)
real_y = y;
else
real_y = &local_y;
iface = ATK_IMAGE_GET_IFACE (image);
if (iface->get_image_position)
{
(iface->get_image_position) (image, real_x, real_y, coord_type);
}
else
{
*real_x = -1;
*real_y = -1;
}
}
/**
* atk_image_get_image_locale:
* @image: An #AtkImage
*
* Retrieves the locale identifier associated to the #AtkImage.
*
* Since: 1.12
*
* Returns: (nullable): a string corresponding to the POSIX
* `LC_MESSAGES` locale used by the image description, or
* %NULL if the image does not specify a locale.
*
*/
const gchar*
atk_image_get_image_locale (AtkImage *image)
{
AtkImageIface *iface;
g_return_val_if_fail (ATK_IS_IMAGE (image), NULL);
iface = ATK_IMAGE_GET_IFACE (image);
if (iface->get_image_locale)
{
return (iface->get_image_locale) (image);
}
else
{
return NULL;
}
}

89
atk/atkimage.h Normal file
View File

@@ -0,0 +1,89 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_IMAGE_H__
#define __ATK_IMAGE_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <atk/atktypes.h>
G_BEGIN_DECLS
/*
* The AtkImage interface should be supported by any object that has an
* associated image. This interface provides the standard mechanism for
* an assistive technology to get descriptive information about images.
*/
#define ATK_TYPE_IMAGE (atk_image_get_type ())
#define ATK_IS_IMAGE(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_IMAGE)
#define ATK_IMAGE(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_IMAGE, AtkImage)
#define ATK_IMAGE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_IMAGE, AtkImageIface))
#ifndef _TYPEDEF_ATK_IMAGE_
#define _TYPEDEF_ATK_IMAGE_
typedef struct _AtkImage AtkImage;
#endif
typedef struct _AtkImageIface AtkImageIface;
struct _AtkImageIface
{
GTypeInterface parent;
void ( *get_image_position) (AtkImage *image,
gint *x,
gint *y,
AtkCoordType coord_type);
const gchar* ( *get_image_description) (AtkImage *image);
void ( *get_image_size) (AtkImage *image,
gint *width,
gint *height);
gboolean ( *set_image_description) (AtkImage *image,
const gchar *description);
const gchar* ( *get_image_locale) (AtkImage *image);
};
GDK_AVAILABLE_IN_ALL
GType atk_image_get_type (void);
GDK_AVAILABLE_IN_ALL
const gchar* atk_image_get_image_description (AtkImage *image);
GDK_AVAILABLE_IN_ALL
void atk_image_get_image_size (AtkImage *image,
gint *width,
gint *height);
GDK_AVAILABLE_IN_ALL
gboolean atk_image_set_image_description (AtkImage *image,
const gchar *description);
GDK_AVAILABLE_IN_ALL
void atk_image_get_image_position (AtkImage *image,
gint *x,
gint *y,
AtkCoordType coord_type);
GDK_AVAILABLE_IN_ALL
const gchar* atk_image_get_image_locale (AtkImage *image);
G_END_DECLS
#endif /* __ATK_IMAGE_H__ */

29
atk/atkmarshal.list Normal file
View File

@@ -0,0 +1,29 @@
# see glib-genmarshal(1) for a detailed description of the file format,
# possible parameter types are:
# VOID indicates no return type, or no extra
# parameters. if VOID is used as the parameter
# list, no additional parameters may be present.
# BOOLEAN for boolean types (gboolean)
# CHAR for signed char types (gchar)
# UCHAR for unsigned char types (guchar)
# INT for signed integer types (gint)
# UINT for unsigned integer types (guint)
# LONG for signed long integer types (glong)
# ULONG for unsigned long integer types (gulong)
# ENUM for enumeration types (gint)
# FLAGS for flag enumeration types (guint)
# FLOAT for single-precision float types (gfloat)
# DOUBLE for double-precision float types (gdouble)
# STRING for string types (gchar*)
# PARAM for GParamSpec or derived types (GParamSpec*)
# BOXED for boxed (anonymous but reference counted) types (GBoxed*)
# POINTER for anonymous pointer types (gpointer)
# OBJECT for GObject or derived types (GObject*)
# NONE deprecated alias for VOID
# BOOL deprecated alias for BOOLEAN
VOID:INT,INT
VOID:INT,INT,STRING
VOID:INT,INT,INT,STRING
VOID:STRING,BOOLEAN
VOID:DOUBLE,STRING

208
atk/atknoopobject.c Normal file
View File

@@ -0,0 +1,208 @@
/* ATK - Accessibility Toolkit
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "atk.h"
#include "atknoopobject.h"
/**
* SECTION:atknoopobject
* @Short_description: An AtkObject which purports to implement all ATK interfaces.
* @Title:AtkNoOpObject
*
* An AtkNoOpObject is an AtkObject which purports to implement all
* ATK interfaces. It is the type of AtkObject which is created if an
* accessible object is requested for an object type for which no
* factory type is specified.
*
*/
static void atk_no_op_object_class_init (AtkNoOpObjectClass *klass);
static gpointer parent_class = NULL;
GType
atk_no_op_object_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (AtkObjectClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) atk_no_op_object_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (AtkNoOpObject), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
static const GInterfaceInfo atk_component_info =
{
(GInterfaceInitFunc) NULL,
(GInterfaceFinalizeFunc) NULL,
NULL
};
static const GInterfaceInfo atk_action_info =
{
(GInterfaceInitFunc) NULL,
(GInterfaceFinalizeFunc) NULL,
NULL
};
static const GInterfaceInfo atk_editable_text_info =
{
(GInterfaceInitFunc) NULL,
(GInterfaceFinalizeFunc) NULL,
NULL
};
static const GInterfaceInfo atk_image_info =
{
(GInterfaceInitFunc) NULL,
(GInterfaceFinalizeFunc) NULL,
NULL
};
static const GInterfaceInfo atk_selection_info =
{
(GInterfaceInitFunc) NULL,
(GInterfaceFinalizeFunc) NULL,
NULL
};
static const GInterfaceInfo atk_table_info =
{
(GInterfaceInitFunc) NULL,
(GInterfaceFinalizeFunc) NULL,
NULL
};
static const GInterfaceInfo atk_table_cell_info =
{
(GInterfaceInitFunc) NULL,
(GInterfaceFinalizeFunc) NULL,
NULL
};
static const GInterfaceInfo atk_text_info =
{
(GInterfaceInitFunc) NULL,
(GInterfaceFinalizeFunc) NULL,
NULL
};
static const GInterfaceInfo atk_hypertext_info =
{
(GInterfaceInitFunc) NULL,
(GInterfaceFinalizeFunc) NULL,
NULL
};
static const GInterfaceInfo atk_value_info =
{
(GInterfaceInitFunc) NULL,
(GInterfaceFinalizeFunc) NULL,
NULL
};
static const GInterfaceInfo atk_document_info =
{
(GInterfaceInitFunc) NULL,
(GInterfaceFinalizeFunc) NULL,
NULL
};
static const GInterfaceInfo atk_window_info =
{
(GInterfaceInitFunc) NULL,
(GInterfaceFinalizeFunc) NULL,
NULL
};
type = g_type_register_static (ATK_TYPE_OBJECT,
"AtkNoOpObject", &tinfo, 0);
g_type_add_interface_static (type, ATK_TYPE_COMPONENT,
&atk_component_info);
g_type_add_interface_static (type, ATK_TYPE_ACTION,
&atk_action_info);
g_type_add_interface_static (type, ATK_TYPE_EDITABLE_TEXT,
&atk_editable_text_info);
g_type_add_interface_static (type, ATK_TYPE_IMAGE,
&atk_image_info);
g_type_add_interface_static (type, ATK_TYPE_SELECTION,
&atk_selection_info);
g_type_add_interface_static (type, ATK_TYPE_TABLE,
&atk_table_info);
g_type_add_interface_static (type, ATK_TYPE_TABLE_CELL,
&atk_table_cell_info);
g_type_add_interface_static (type, ATK_TYPE_TEXT,
&atk_text_info);
g_type_add_interface_static (type, ATK_TYPE_HYPERTEXT,
&atk_hypertext_info);
g_type_add_interface_static (type, ATK_TYPE_VALUE,
&atk_value_info);
g_type_add_interface_static (type, ATK_TYPE_DOCUMENT,
&atk_document_info);
g_type_add_interface_static (type, ATK_TYPE_WINDOW,
&atk_window_info);
}
return type;
}
static void
atk_no_op_object_class_init (AtkNoOpObjectClass *klass)
{
parent_class = g_type_class_peek_parent (klass);
}
/**
* atk_no_op_object_new:
* @obj: a #GObject
*
* Provides a default (non-functioning stub) #AtkObject.
* Application maintainers should not use this method.
*
* Returns: a default (non-functioning stub) #AtkObject
**/
AtkObject*
atk_no_op_object_new (GObject *obj)
{
AtkObject *accessible;
g_return_val_if_fail (obj != NULL, NULL);
accessible = g_object_new (ATK_TYPE_NO_OP_OBJECT, NULL);
g_return_val_if_fail (accessible != NULL, NULL);
accessible->role = ATK_ROLE_INVALID;
accessible->layer = ATK_LAYER_INVALID;
return accessible;
}

59
atk/atknoopobject.h Normal file
View File

@@ -0,0 +1,59 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <atk/atkobject.h>
#ifndef __ATK_NO_OP_OBJECT_H__
#define __ATK_NO_OP_OBJECT_H__
G_BEGIN_DECLS
#define ATK_TYPE_NO_OP_OBJECT (atk_no_op_object_get_type ())
#define ATK_NO_OP_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_NO_OP_OBJECT, AtkNoOpObject))
#define ATK_NO_OP_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_NO_OP_OBJECT, AtkNoOpObjectClass))
#define ATK_IS_NO_OP_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_NO_OP_OBJECT))
#define ATK_IS_NO_OP_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_NO_OP_OBJECT))
#define ATK_NO_OP_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_NO_OP_OBJECT, AtkNoOpObjectClass))
typedef struct _AtkNoOpObject AtkNoOpObject;
typedef struct _AtkNoOpObjectClass AtkNoOpObjectClass;
struct _AtkNoOpObject
{
AtkObject parent;
};
GDK_AVAILABLE_IN_ALL
GType atk_no_op_object_get_type (void);
struct _AtkNoOpObjectClass
{
AtkObjectClass parent_class;
};
GDK_AVAILABLE_IN_ALL
AtkObject *atk_no_op_object_new (GObject *obj);
G_END_DECLS
#endif /* __ATK_NO_OP_OBJECT_H__ */

116
atk/atknoopobjectfactory.c Normal file
View File

@@ -0,0 +1,116 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "atkobject.h"
#include "atknoopobject.h"
#include "atknoopobjectfactory.h"
/**
* SECTION:atknoopobjectfactory
* @Short_description: The AtkObjectFactory which creates an AtkNoOpObject.
* @Title:AtkNoOpObjectFactory
*
* The AtkObjectFactory which creates an AtkNoOpObject. An instance of
* this is created by an AtkRegistry if no factory type has not been
* specified to create an accessible object of a particular type.
*/
static void atk_no_op_object_factory_class_init (
AtkNoOpObjectFactoryClass *klass);
static AtkObject* atk_no_op_object_factory_create_accessible (
GObject *obj);
static GType atk_no_op_object_factory_get_accessible_type (void);
static gpointer parent_class = NULL;
GType
atk_no_op_object_factory_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (AtkNoOpObjectFactoryClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) atk_no_op_object_factory_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (AtkNoOpObjectFactory), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
type = g_type_register_static (
ATK_TYPE_OBJECT_FACTORY,
"AtkNoOpObjectFactory" , &tinfo, 0);
}
return type;
}
static void
atk_no_op_object_factory_class_init (AtkNoOpObjectFactoryClass *klass)
{
AtkObjectFactoryClass *class = ATK_OBJECT_FACTORY_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
class->create_accessible = atk_no_op_object_factory_create_accessible;
class->get_accessible_type = atk_no_op_object_factory_get_accessible_type;
}
/**
* atk_no_op_object_factory_new:
*
* Creates an instance of an #AtkObjectFactory which generates primitive
* (non-functioning) #AtkObjects.
*
* Returns: an instance of an #AtkObjectFactory
**/
AtkObjectFactory*
atk_no_op_object_factory_new (void)
{
GObject *factory;
factory = g_object_new (ATK_TYPE_NO_OP_OBJECT_FACTORY, NULL);
g_return_val_if_fail (factory != NULL, NULL);
return ATK_OBJECT_FACTORY (factory);
}
static AtkObject*
atk_no_op_object_factory_create_accessible (GObject *obj)
{
AtkObject *accessible;
accessible = atk_no_op_object_new (obj);
return accessible;
}
static GType
atk_no_op_object_factory_get_accessible_type (void)
{
return ATK_TYPE_NO_OP_OBJECT;
}

View File

@@ -0,0 +1,59 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_NO_OP_OBJECT_FACTORY_H__
#define __ATK_NO_OP_OBJECT_FACTORY_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <atk/atkobjectfactory.h>
G_BEGIN_DECLS
#define ATK_TYPE_NO_OP_OBJECT_FACTORY (atk_no_op_object_factory_get_type ())
#define ATK_NO_OP_OBJECT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_NO_OP_OBJECT_FACTORY, AtkNoOpObjectFactory))
#define ATK_NO_OP_OBJECT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_NO_OP_OBJECT_FACTORY, AtkNoOpObjectFactoryClass))
#define ATK_IS_NO_OP_OBJECT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_NO_OP_OBJECT_FACTORY))
#define ATK_IS_NO_OP_OBJECT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_NO_OP_OBJECT_FACTORY))
#define ATK_NO_OP_OBJECT_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ( (obj), ATK_TYPE_NO_OP_OBJECT_FACTORY, AtkNoOpObjectFactoryClass))
typedef struct _AtkNoOpObjectFactory AtkNoOpObjectFactory;
typedef struct _AtkNoOpObjectFactoryClass AtkNoOpObjectFactoryClass;
struct _AtkNoOpObjectFactory
{
AtkObjectFactory parent;
};
struct _AtkNoOpObjectFactoryClass
{
AtkObjectFactoryClass parent_class;
};
GDK_AVAILABLE_IN_ALL
GType atk_no_op_object_factory_get_type(void);
GDK_AVAILABLE_IN_ALL
AtkObjectFactory *atk_no_op_object_factory_new(void);
G_END_DECLS
#endif /* __ATK_NO_OP_OBJECT_FACTORY_H__ */

1514
atk/atkobject.c Normal file

File diff suppressed because it is too large Load Diff

389
atk/atkobject.h Normal file
View File

@@ -0,0 +1,389 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_OBJECT_H__
#define __ATK_OBJECT_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <atk/atktypes.h>
#include <atk/atkstate.h>
G_BEGIN_DECLS
/**
* AtkAttributeSet:
*
* This is a singly-linked list (a #GSList) of #AtkAttribute. It is
* used by atk_text_get_run_attributes(),
* atk_text_get_default_attributes(),
* atk_editable_text_set_run_attributes(),
* atk_document_get_attributes() and atk_object_get_attributes()
**/
typedef GSList AtkAttributeSet;
/**
* AtkAttribute:
* @name: The attribute name.
* @value: the value of the attribute, represented as a string.
*
* AtkAttribute is a string name/value pair representing a generic
* attribute. This can be used to expose additional information from
* an accessible object as a whole (see atk_object_get_attributes())
* or an document (see atk_document_get_attributes()). In the case of
* text attributes (see atk_text_get_default_attributes()),
* #AtkTextAttribute enum defines all the possible text attribute
* names. You can use atk_text_attribute_get_name() to get the string
* name from the enum value. See also atk_text_attribute_for_name()
* and atk_text_attribute_get_value() for more information.
*
* A string name/value pair representing a generic attribute.
**/
typedef struct _AtkAttribute AtkAttribute;
struct _AtkAttribute {
gchar* name;
gchar* value;
};
#define ATK_TYPE_OBJECT (atk_object_get_type ())
#define ATK_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_OBJECT, AtkObject))
#define ATK_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_OBJECT, AtkObjectClass))
#define ATK_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_OBJECT))
#define ATK_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_OBJECT))
#define ATK_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_OBJECT, AtkObjectClass))
#define ATK_TYPE_IMPLEMENTOR (atk_implementor_get_type ())
#define ATK_IS_IMPLEMENTOR(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_IMPLEMENTOR)
#define ATK_IMPLEMENTOR(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_IMPLEMENTOR, AtkImplementor)
#define ATK_IMPLEMENTOR_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_IMPLEMENTOR, AtkImplementorIface))
typedef struct _AtkImplementor AtkImplementor; /* dummy typedef */
typedef struct _AtkImplementorIface AtkImplementorIface;
typedef struct _AtkObject AtkObject;
typedef struct _AtkObjectClass AtkObjectClass;
typedef struct _AtkRelationSet AtkRelationSet;
typedef struct _AtkStateSet AtkStateSet;
/**
* AtkPropertyValues:
* @property_name: The name of the ATK property which has changed.
* @old_value: NULL. This field is not used anymore.
* @new_value: The new value of the named property.
*
* Note: @old_value field of #AtkPropertyValues will not contain a
* valid value. This is a field defined with the purpose of contain
* the previous value of the property, but is not used anymore.
*
**/
struct _AtkPropertyValues
{
const gchar *property_name;
GValue old_value;
GValue new_value;
};
typedef struct _AtkPropertyValues AtkPropertyValues;
/**
* AtkFunction:
* @user_data: custom data defined by the user
*
* An AtkFunction is a function definition used for padding which has
* been added to class and interface structures to allow for expansion
* in the future.
*
* Returns: not used
*/
typedef gboolean (*AtkFunction) (gpointer user_data);
/*
* For most properties the old_value field of AtkPropertyValues will
* not contain a valid value.
*
* Currently, the only property for which old_value is used is
* accessible-state; for instance if there is a focus state the
* property change handler will be called for the object which lost the focus
* with the old_value containing an AtkState value corresponding to focused
* and the property change handler will be called for the object which
* received the focus with the new_value containing an AtkState value
* corresponding to focused.
*/
struct _AtkObject
{
GObject parent;
gchar *description;
gchar *name;
AtkObject *accessible_parent;
AtkRole role;
AtkRelationSet *relation_set;
AtkLayer layer;
};
/**
* AtkObjectClass:
* @connect_property_change_handler: specifies a function to be called
* when a property changes value. This virtual function is
* deprecated since 2.12 and it should not be overriden. Connect
* directly to property-change or notify signal instead.
* @remove_property_change_handler: removes a property changed handler
* as returned by @connect_property_change_handler. This virtual
* function is deprecated sice 2.12 and it should not be overriden.
* @focus_event: The signal handler which is executed when there is a
* focus event for an object. This virtual function is deprecated
* since 2.9.4 and it should not be overriden. Use
* the #AtkObject::state-change "focused" signal instead.
*/
struct _AtkObjectClass
{
GObjectClass parent;
/*
* Gets the accessible name of the object
*/
const gchar* (* get_name) (AtkObject *accessible);
/*
* Gets the accessible description of the object
*/
const gchar* (* get_description) (AtkObject *accessible);
/*
* Gets the accessible parent of the object
*/
AtkObject* (*get_parent) (AtkObject *accessible);
/*
* Gets the number of accessible children of the object
*/
gint (* get_n_children) (AtkObject *accessible);
/*
* Returns a reference to the specified accessible child of the object.
* The accessible children are 0-based so the first accessible child is
* at index 0, the second at index 1 and so on.
*/
AtkObject* (* ref_child) (AtkObject *accessible,
gint i);
/*
* Gets the 0-based index of this object in its parent; returns -1 if the
* object does not have an accessible parent.
*/
gint (* get_index_in_parent) (AtkObject *accessible);
/*
* Gets the RelationSet associated with the object
*/
AtkRelationSet* (* ref_relation_set) (AtkObject *accessible);
/*
* Gets the role of the object
*/
AtkRole (* get_role) (AtkObject *accessible);
AtkLayer (* get_layer) (AtkObject *accessible);
gint (* get_mdi_zorder) (AtkObject *accessible);
/*
* Gets the state set of the object
*/
AtkStateSet* (* ref_state_set) (AtkObject *accessible);
/*
* Sets the accessible name of the object
*/
void (* set_name) (AtkObject *accessible,
const gchar *name);
/*
* Sets the accessible description of the object
*/
void (* set_description) (AtkObject *accessible,
const gchar *description);
/*
* Sets the accessible parent of the object
*/
void (* set_parent) (AtkObject *accessible,
AtkObject *parent);
/*
* Sets the accessible role of the object
*/
void (* set_role) (AtkObject *accessible,
AtkRole role);
/*
* Removes a property change handler which was specified using
* connect_property_change_handler
*/
void (* remove_property_change_handler) (AtkObject
*accessible,
guint
handler_id);
void (* initialize) (AtkObject *accessible,
gpointer data);
/*
* The signal handler which is executed when there is a change in the
* children of the object
*/
void (* children_changed) (AtkObject *accessible,
guint change_index,
gpointer changed_child);
/*
* The signal handler which is executed when there is a focus event
* for an object.
*/
void (* focus_event) (AtkObject *accessible,
gboolean focus_in);
/*
* The signal handler which is executed when there is a property_change
* signal for an object.
*/
void (* property_change) (AtkObject *accessible,
AtkPropertyValues *values);
/*
* The signal handler which is executed when there is a state_change
* signal for an object.
*/
void (* state_change) (AtkObject *accessible,
const gchar *name,
gboolean state_set);
/*
* The signal handler which is executed when there is a change in the
* visible data for an object
*/
void (*visible_data_changed) (AtkObject *accessible);
/*
* The signal handler which is executed when there is a change in the
* 'active' child or children of the object, for instance when
* interior focus changes in a table or list. This signal should be emitted
* by objects whose state includes ATK_STATE_MANAGES_DESCENDANTS.
*/
void (*active_descendant_changed) (AtkObject *accessible,
gpointer *child);
/*
* Gets a list of properties applied to this object as a whole, as an #AtkAttributeSet consisting of name-value pairs.
* Since ATK 1.12
*/
AtkAttributeSet* (*get_attributes) (AtkObject *accessible);
const gchar* (*get_object_locale) (AtkObject *accessible);
AtkFunction pad1;
};
GDK_AVAILABLE_IN_ALL
GType atk_object_get_type (void);
/**
* AtkImplementorIface:
*
* The AtkImplementor interface is implemented by objects for which
* AtkObject peers may be obtained via calls to
* iface->(ref_accessible)(implementor);
*/
struct _AtkImplementorIface
{
GTypeInterface parent;
AtkObject* (*ref_accessible) (AtkImplementor *implementor);
};
GDK_AVAILABLE_IN_ALL
GType atk_implementor_get_type (void);
GDK_AVAILABLE_IN_ALL
AtkObject* atk_implementor_ref_accessible (AtkImplementor *implementor);
/*
* Properties directly supported by AtkObject
*/
GDK_AVAILABLE_IN_ALL
const gchar* atk_object_get_name (AtkObject *accessible);
GDK_AVAILABLE_IN_ALL
const gchar* atk_object_get_description (AtkObject *accessible);
GDK_AVAILABLE_IN_ALL
AtkObject* atk_object_get_parent (AtkObject *accessible);
GDK_AVAILABLE_IN_ALL
AtkObject* atk_object_peek_parent (AtkObject *accessible);
GDK_AVAILABLE_IN_ALL
gint atk_object_get_n_accessible_children (AtkObject *accessible);
GDK_AVAILABLE_IN_ALL
AtkObject* atk_object_ref_accessible_child (AtkObject *accessible,
gint i);
GDK_AVAILABLE_IN_ALL
AtkRelationSet* atk_object_ref_relation_set (AtkObject *accessible);
GDK_AVAILABLE_IN_ALL
AtkRole atk_object_get_role (AtkObject *accessible);
GDK_AVAILABLE_IN_ALL
AtkAttributeSet* atk_object_get_attributes (AtkObject *accessible);
GDK_AVAILABLE_IN_ALL
AtkStateSet* atk_object_ref_state_set (AtkObject *accessible);
GDK_AVAILABLE_IN_ALL
gint atk_object_get_index_in_parent (AtkObject *accessible);
GDK_AVAILABLE_IN_ALL
void atk_object_set_name (AtkObject *accessible,
const gchar *name);
GDK_AVAILABLE_IN_ALL
void atk_object_set_description (AtkObject *accessible,
const gchar *description);
GDK_AVAILABLE_IN_ALL
void atk_object_set_parent (AtkObject *accessible,
AtkObject *parent);
GDK_AVAILABLE_IN_ALL
void atk_object_set_role (AtkObject *accessible,
AtkRole role);
GDK_AVAILABLE_IN_ALL
void atk_object_notify_state_change (AtkObject *accessible,
AtkState state,
gboolean value);
GDK_AVAILABLE_IN_ALL
void atk_object_initialize (AtkObject *accessible,
gpointer data);
GDK_AVAILABLE_IN_ALL
const gchar* atk_role_get_name (AtkRole role);
GDK_AVAILABLE_IN_ALL
AtkRole atk_role_for_name (const gchar *name);
GDK_AVAILABLE_IN_ALL
gboolean atk_object_add_relationship (AtkObject *object,
AtkRelationType relationship,
AtkObject *target);
GDK_AVAILABLE_IN_ALL
gboolean atk_object_remove_relationship (AtkObject *object,
AtkRelationType relationship,
AtkObject *target);
GDK_AVAILABLE_IN_ALL
const gchar* atk_role_get_localized_name (AtkRole role);
GDK_AVAILABLE_IN_ALL
const gchar* atk_object_get_object_locale (AtkObject *accessible);
GDK_AVAILABLE_IN_ALL
const gchar* atk_object_get_accessible_id (AtkObject *accessible);
GDK_AVAILABLE_IN_ALL
void atk_object_set_accessible_id (AtkObject *accessible,
const gchar *name);
G_END_DECLS
#endif /* __ATK_OBJECT_H__ */

147
atk/atkobjectfactory.c Normal file
View File

@@ -0,0 +1,147 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "atkobjectfactory.h"
#include "atknoopobjectfactory.h"
/**
* SECTION:atkobjectfactory
* @Short_description: The base object class for a factory used to
* create accessible objects for objects of a specific GType.
* @Title:AtkObjectFactory
*
* This class is the base object class for a factory used to create an
* accessible object for a specific GType. The function
* atk_registry_set_factory_type() is normally called to store in the
* registry the factory type to be used to create an accessible of a
* particular GType.
*/
static void atk_object_factory_class_init (AtkObjectFactoryClass *klass);
static gpointer parent_class = NULL;
GType
atk_object_factory_get_type (void)
{
static GType type = 0;
if (!type) {
GTypeInfo tinfo =
{
sizeof (AtkObjectFactoryClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) atk_object_factory_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (AtkObjectFactory), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
type = g_type_register_static (G_TYPE_OBJECT, "AtkObjectFactory", &tinfo, 0);
}
return type;
}
static void
atk_object_factory_class_init (AtkObjectFactoryClass *klass)
{
parent_class = g_type_class_peek_parent (klass);
}
/**
* atk_object_factory_create_accessible:
* @factory: The #AtkObjectFactory associated with @obj's
* object type
* @obj: a #GObject
*
* Provides an #AtkObject that implements an accessibility interface
* on behalf of @obj
*
* Returns: (transfer full): an #AtkObject that implements an accessibility
* interface on behalf of @obj
**/
AtkObject*
atk_object_factory_create_accessible (AtkObjectFactory *factory,
GObject *obj)
{
AtkObjectFactoryClass *klass;
AtkObject *accessible = NULL;
g_return_val_if_fail (ATK_IS_OBJECT_FACTORY (factory), NULL);
g_return_val_if_fail (G_IS_OBJECT (obj), NULL);
klass = ATK_OBJECT_FACTORY_GET_CLASS (factory);
if (klass->create_accessible)
{
accessible = klass->create_accessible (obj);
}
return accessible;
}
/**
* atk_object_factory_invalidate:
* @factory: an #AtkObjectFactory to invalidate
*
* Inform @factory that it is no longer being used to create
* accessibles. When called, @factory may need to inform
* #AtkObjects which it has created that they need to be re-instantiated.
* Note: primarily used for runtime replacement of #AtkObjectFactorys
* in object registries.
**/
void
atk_object_factory_invalidate (AtkObjectFactory *factory)
{
AtkObjectFactoryClass *klass;
g_return_if_fail (ATK_OBJECT_FACTORY (factory));
klass = ATK_OBJECT_FACTORY_GET_CLASS (factory);
if (klass->invalidate)
(klass->invalidate) (factory);
}
/**
* atk_object_factory_get_accessible_type:
* @factory: an #AtkObjectFactory
*
* Gets the GType of the accessible which is created by the factory.
* Returns: the type of the accessible which is created by the @factory.
* The value G_TYPE_INVALID is returned if no type if found.
**/
GType
atk_object_factory_get_accessible_type (AtkObjectFactory *factory)
{
AtkObjectFactoryClass *klass;
g_return_val_if_fail (ATK_OBJECT_FACTORY (factory), G_TYPE_INVALID);
klass = ATK_OBJECT_FACTORY_GET_CLASS (factory);
if (klass->get_accessible_type)
return (klass->get_accessible_type) ();
else
return G_TYPE_INVALID;
}

72
atk/atkobjectfactory.h Normal file
View File

@@ -0,0 +1,72 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_OBJECT_FACTORY_H__
#define __ATK_OBJECT_FACTORY_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <glib-object.h>
#include <atk/atkobject.h>
G_BEGIN_DECLS
#define ATK_TYPE_OBJECT_FACTORY (atk_object_factory_get_type ())
#define ATK_OBJECT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_OBJECT_FACTORY, AtkObjectFactory))
#define ATK_OBJECT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_OBJECT_FACTORY, AtkObjectFactoryClass))
#define ATK_IS_OBJECT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_OBJECT_FACTORY))
#define ATK_IS_OBJECT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_OBJECT_FACTORY))
#define ATK_OBJECT_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_OBJECT_FACTORY, AtkObjectFactoryClass))
typedef struct _AtkObjectFactory AtkObjectFactory;
typedef struct _AtkObjectFactoryClass AtkObjectFactoryClass;
struct _AtkObjectFactory
{
GObject parent;
};
struct _AtkObjectFactoryClass
{
GObjectClass parent_class;
AtkObject* (* create_accessible) (GObject *obj);
void (* invalidate) (AtkObjectFactory *factory);
GType (* get_accessible_type) (void);
AtkFunction pad1;
AtkFunction pad2;
};
GDK_AVAILABLE_IN_ALL
GType atk_object_factory_get_type(void);
GDK_AVAILABLE_IN_ALL
AtkObject* atk_object_factory_create_accessible (AtkObjectFactory *factory, GObject *obj);
GDK_AVAILABLE_IN_ALL
void atk_object_factory_invalidate (AtkObjectFactory *factory);
GDK_AVAILABLE_IN_ALL
GType atk_object_factory_get_accessible_type (AtkObjectFactory *factory);
G_END_DECLS
#endif /* __GTK_OBJECT_FACTORY_H__ */

194
atk/atkplug.c Normal file
View File

@@ -0,0 +1,194 @@
/* ATK - Accessibility Toolkit
* Copyright (C) 2009 Novell, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "atk.h"
#include "atkplug.h"
/**
* SECTION:atkplug
* @Short_description: Toplevel for embedding into other processes
* @Title: AtkPlug
* @See_also: #AtkPlug
*
* See #AtkSocket
*
*/
static void atk_component_interface_init (AtkComponentIface *iface);
typedef struct {
AtkObject *child;
} AtkPlugPrivate;
static gint AtkPlug_private_offset;
G_DEFINE_TYPE_WITH_CODE (AtkPlug, atk_plug, ATK_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, atk_component_interface_init)
G_ADD_PRIVATE(AtkPlug))
static AtkObject*
atk_plug_ref_child (AtkObject *obj, int i)
{
AtkPlugPrivate *private = atk_plug_get_instance_private (ATK_PLUG (obj));
AtkObject *child;
if (i != 0)
return NULL;
child = private->child;
if (child == NULL)
return NULL;
return g_object_ref (child);
}
static int
atk_plug_get_n_children (AtkObject *obj)
{
AtkPlugPrivate *private = atk_plug_get_instance_private (ATK_PLUG (obj));
if (private->child == NULL)
return 0;
return 1;
}
static AtkStateSet*
atk_plug_ref_state_set (AtkObject *obj)
{
AtkPlugPrivate *private = atk_plug_get_instance_private (ATK_PLUG (obj));
AtkObject *child;
child = private->child;
if (child == NULL)
return NULL;
return atk_object_ref_state_set (child);
}
static void
atk_plug_init (AtkPlug* obj)
{
AtkObject *accessible = ATK_OBJECT (obj);
accessible->role = ATK_ROLE_FILLER;
accessible->layer = ATK_LAYER_WIDGET;
}
static void
atk_plug_class_init (AtkPlugClass* klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
if (AtkPlug_private_offset != 0)
g_type_class_adjust_private_offset (klass, &AtkPlug_private_offset);
klass->get_object_id = NULL;
class->get_n_children = atk_plug_get_n_children;
class->ref_child = atk_plug_ref_child;
class->ref_state_set = atk_plug_ref_state_set;
}
static void
atk_component_interface_init (AtkComponentIface *iface)
{
}
/**
* atk_plug_new:
*
* Creates a new #AtkPlug instance.
*
* Returns: (transfer full): the newly created #AtkPlug
*
* Since: 1.30
*/
AtkObject *
atk_plug_new (void)
{
return g_object_new (ATK_TYPE_PLUG, NULL);
}
/**
* atk_plug_set_child:
* @plug: an #AtkPlug to be set as accessible parent of @child.
* @child: an #AtkObject to be set as accessible child of @plug.
*
* Sets @child as accessible child of @plug and @plug as accessible parent of
* @child. @child can be NULL.
*
* In some cases, one can not use the AtkPlug type directly as accessible
* object for the toplevel widget of the application. For instance in the gtk
* case, GtkPlugAccessible can not inherit both from GtkWindowAccessible and
* from AtkPlug. In such a case, one can create, in addition to the standard
* accessible object for the toplevel widget, an AtkPlug object, and make the
* former the child of the latter by calling atk_plug_set_child().
*
* Since: 2.35.0
*/
void
atk_plug_set_child (AtkPlug *plug, AtkObject *child)
{
AtkPlugPrivate *private = atk_plug_get_instance_private (plug);
if (private->child)
atk_object_set_parent (private->child, NULL);
private->child = child;
if (child)
atk_object_set_parent (child, ATK_OBJECT(plug));
}
/**
* atk_plug_get_id:
* @plug: an #AtkPlug
*
* Gets the unique ID of an #AtkPlug object, which can be used to
* embed inside of an #AtkSocket using atk_socket_embed().
*
* Internally, this calls a class function that should be registered
* by the IPC layer (usually at-spi2-atk). The implementor of an
* #AtkPlug object should call this function (after atk-bridge is
* loaded) and pass the value to the process implementing the
* #AtkSocket, so it could embed the plug.
*
* Returns: the unique ID for the plug
*
* Since: 1.30
**/
gchar*
atk_plug_get_id (AtkPlug* plug)
{
AtkPlugClass *klass;
g_return_val_if_fail (ATK_IS_PLUG (plug), NULL);
klass = g_type_class_peek (ATK_TYPE_PLUG);
if (klass && klass->get_object_id)
return (klass->get_object_id) (plug);
else
return NULL;
}

68
atk/atkplug.h Normal file
View File

@@ -0,0 +1,68 @@
/* ATK - Accessibility Toolkit
* Copyright 2009 Novell, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_PLUG_H__
#define __ATK_PLUG_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <atk/atkobject.h>
G_BEGIN_DECLS
#define ATK_TYPE_PLUG (atk_plug_get_type ())
#define ATK_PLUG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_PLUG, AtkPlug))
#define ATK_IS_PLUG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_PLUG))
#define ATK_PLUG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_PLUG, AtkPlugClass))
#define ATK_IS_PLUG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_PLUG))
#define ATK_PLUG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_PLUG, AtkPlugClass))
typedef struct _AtkPlug AtkPlug;
typedef struct _AtkPlugClass AtkPlugClass;
struct _AtkPlug
{
AtkObject parent;
};
GDK_AVAILABLE_IN_ALL
GType atk_plug_get_type (void);
struct _AtkPlugClass
{
AtkObjectClass parent_class;
/* to be subscribed to by atk-bridge */
/*< protected >*/
gchar* (* get_object_id) (AtkPlug* obj);
};
GDK_AVAILABLE_IN_ALL
AtkObject* atk_plug_new (void);
GDK_AVAILABLE_IN_ALL
void atk_plug_set_child (AtkPlug *plug, AtkObject *child);
GDK_AVAILABLE_IN_ALL
gchar* atk_plug_get_id (AtkPlug* plug);
G_END_DECLS
#endif /* __ATK_PLUG_H__ */

131
atk/atkprivate.c Normal file
View File

@@ -0,0 +1,131 @@
/* ATK - Accessibility Toolkit
*
* Copyright (C) 2014 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <string.h>
#include <locale.h>
#include <glib-object.h>
#include <glib/gi18n-lib.h>
#include "atkprivate.h"
#ifdef G_OS_WIN32
#define STRICT
#include <windows.h>
#undef STRICT
static HMODULE atk_dll;
BOOL WINAPI
DllMain (HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
atk_dll = (HMODULE) hinstDLL;
break;
}
return TRUE;
}
static const char *
get_atk_locale_dir (void)
{
static gchar *atk_localedir = NULL;
if (!atk_localedir)
{
const gchar *p;
gchar *root, *temp;
/* ATK_LOCALEDIR might end in either /lib/locale or
* /share/locale. Scan for that slash.
*/
p = ATK_LOCALEDIR + strlen (ATK_LOCALEDIR);
while (*--p != '/')
;
while (*--p != '/')
;
root = g_win32_get_package_installation_directory_of_module (atk_dll);
temp = g_build_filename (root, p, NULL);
g_free (root);
/* atk_localedir is passed to bindtextdomain() which isn't
* UTF-8-aware.
*/
atk_localedir = g_win32_locale_filename_from_utf8 (temp);
g_free (temp);
}
return atk_localedir;
}
#undef ATK_LOCALEDIR
#define ATK_LOCALEDIR get_atk_locale_dir()
#endif
void
_gettext_initialization (void)
{
#ifdef ENABLE_NLS
static gboolean gettext_initialized = FALSE;
if (!gettext_initialized)
{
const char *dir = g_getenv ("ATK_ALT_LOCALEDIR");
gettext_initialized = TRUE;
if (dir == NULL)
dir = ATK_LOCALEDIR;
bindtextdomain (GETTEXT_PACKAGE, dir);
#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#endif
}
#endif
}
/*
* Compacts a name. For example: to get "accelerator label" instead of
* "accelerator-label"
*/
void
_compact_name (gchar *name)
{
gchar *p = name;
while (*p)
{
if (*p == '-')
*p = ' ';
p++;
}
}

36
atk/atkprivate.h Normal file
View File

@@ -0,0 +1,36 @@
/* ATK - Accessibility Toolkit
* Copyright (C) 2014 Igalia, S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_PRIVATE_H__
#define __ATK_PRIVATE_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
G_BEGIN_DECLS
void _gettext_initialization (void);
void _compact_name (gchar *name);
G_END_DECLS
#endif /* __ATK_PRIVATE_H__ */

169
atk/atkrange.c Normal file
View File

@@ -0,0 +1,169 @@
/* ATK - Accessibility Toolkit
* Copyright 2014 Igalia S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "atkvalue.h"
/**
* SECTION:atkrange
* @Short_description: A given range or subrange, to be used with #AtkValue
* @Title:AtkRange
*
* #AtkRange are used on #AtkValue, in order to represent the full
* range of a given component (for example an slider or a range
* control), or to define each individual subrange this full range is
* splitted if available. See #AtkValue documentation for further
* details.
*/
struct _AtkRange {
gdouble lower;
gdouble upper;
gchar *description;
};
/**
* atk_range_copy:
* @src: #AtkRange to copy
*
* Returns a new #AtkRange that is a exact copy of @src
*
* Since: 2.12
*
* Returns: (transfer full): a new #AtkRange copy of @src
*/
AtkRange *
atk_range_copy (AtkRange *src)
{
g_return_val_if_fail (src != NULL, NULL);
return atk_range_new (src->lower,
src->upper,
src->description);
}
/**
* atk_range_free:
* @range: #AtkRange to free
*
* Free @range
*
* Since: 2.12
*/
void
atk_range_free (AtkRange *range)
{
g_return_if_fail (range != NULL);
if (range->description)
g_free (range->description);
g_slice_free (AtkRange, range);
}
G_DEFINE_BOXED_TYPE (AtkRange, atk_range, atk_range_copy,
atk_range_free)
/**
* atk_range_new:
* @lower_limit: inferior limit for this range
* @upper_limit: superior limit for this range
* @description: human readable description of this range.
*
* Creates a new #AtkRange.
*
* Since: 2.12
*
* Returns: (transfer full): a new #AtkRange
*
*/
AtkRange*
atk_range_new (gdouble lower_limit,
gdouble upper_limit,
const gchar *description)
{
AtkRange *range;
range = g_slice_new0 (AtkRange);
range->lower = lower_limit;
range->upper = upper_limit;
if (description != NULL)
range->description = g_strdup (description);
return range;
}
/**
* atk_range_get_lower_limit:
* @range: an #AtkRange
*
* Returns the lower limit of @range
*
* Since: 2.12
*
* Returns: the lower limit of @range
*/
gdouble
atk_range_get_lower_limit (AtkRange *range)
{
g_return_val_if_fail (range != NULL, 0);
return range->lower;
}
/**
* atk_range_get_upper_limit:
* @range: an #AtkRange
*
* Returns the upper limit of @range
*
* Since: 2.12
*
* Returns: the upper limit of @range
*/
gdouble
atk_range_get_upper_limit (AtkRange *range)
{
g_return_val_if_fail (range != NULL, 0);
return range->upper;
}
/**
* atk_range_get_description:
* @range: an #AtkRange
*
* Returns the human readable description of @range
*
* Since: 2.12
*
* Returns: the human-readable description of @range
*/
const gchar*
atk_range_get_description (AtkRange *range)
{
g_return_val_if_fail (range != NULL, NULL);
return range->description;
}

58
atk/atkrange.h Normal file
View File

@@ -0,0 +1,58 @@
/* ATK - Accessibility Toolkit
* Copyright 2014 Igalia S.L.
*
* Author: Alejandro Piñeiro Iglesias <apinheiro@igalia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_RANGE_H__
#define __ATK_RANGE_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <glib-object.h>
G_BEGIN_DECLS
#define ATK_TYPE_RANGE (atk_range_get_type ())
typedef struct _AtkRange AtkRange;
/* AtkRange methods */
GDK_AVAILABLE_IN_ALL
GType atk_range_get_type (void);
GDK_AVAILABLE_IN_ALL
AtkRange* atk_range_copy (AtkRange *src);
GDK_AVAILABLE_IN_ALL
void atk_range_free (AtkRange *range);
GDK_AVAILABLE_IN_ALL
gdouble atk_range_get_lower_limit (AtkRange *range);
GDK_AVAILABLE_IN_ALL
gdouble atk_range_get_upper_limit (AtkRange *range);
GDK_AVAILABLE_IN_ALL
const gchar* atk_range_get_description (AtkRange *range);
GDK_AVAILABLE_IN_ALL
AtkRange* atk_range_new (gdouble lower_limit,
gdouble upper_limit,
const gchar *description);
G_END_DECLS
#endif /* __ATK_RANGE_H__ */

274
atk/atkregistry.c Normal file
View File

@@ -0,0 +1,274 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "atkregistry.h"
#include "atknoopobjectfactory.h"
/**
* SECTION:atkregistry
* @Short_description: An object used to store the GType of the
* factories used to create an accessible object for an object of a
* particular GType.
* @Title:AtkRegistry
*
* The AtkRegistry is normally used to create appropriate ATK "peers"
* for user interface components. Application developers usually need
* only interact with the AtkRegistry by associating appropriate ATK
* implementation classes with GObject classes via the
* atk_registry_set_factory_type call, passing the appropriate GType
* for application custom widget classes.
*/
static AtkRegistry *default_registry = NULL;
static void atk_registry_init (AtkRegistry *instance,
AtkRegistryClass *klass);
static void atk_registry_finalize (GObject *instance);
static void atk_registry_class_init (AtkRegistryClass *klass);
static AtkRegistry* atk_registry_new (void);
static gpointer parent_class = NULL;
GType
atk_registry_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo info =
{
sizeof (AtkRegistryClass),
(GBaseInitFunc) NULL, /* base_init */
(GBaseFinalizeFunc) NULL, /* base_finalize */
(GClassInitFunc) atk_registry_class_init, /* class_init */
(GClassFinalizeFunc) NULL, /* class_finalize */
NULL, /* class_data */
sizeof (AtkRegistry), /* instance size */
0, /* n_preallocs */
(GInstanceInitFunc) atk_registry_init, /* instance init */
NULL /* value table */
};
type = g_type_register_static (G_TYPE_OBJECT, "AtkRegistry", &info, 0);
}
return type;
}
static void
atk_registry_class_init (AtkRegistryClass *klass)
{
GObjectClass *object_class = (GObjectClass *) klass;
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = atk_registry_finalize;
}
static void
atk_registry_init (AtkRegistry *instance, AtkRegistryClass *klass)
{
instance->factory_type_registry = g_hash_table_new ((GHashFunc) NULL,
(GEqualFunc) NULL);
instance->factory_singleton_cache = g_hash_table_new ((GHashFunc) NULL,
(GEqualFunc) NULL);
}
static AtkRegistry *
atk_registry_new (void)
{
GObject *object;
object = g_object_new (ATK_TYPE_REGISTRY, NULL);
g_return_val_if_fail (ATK_IS_REGISTRY (object), NULL);
return (AtkRegistry *) object;
}
static void
atk_registry_finalize (GObject *object)
{
AtkRegistry *registry = ATK_REGISTRY (object);
g_hash_table_destroy (registry->factory_type_registry);
g_hash_table_destroy (registry->factory_singleton_cache);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
/**
* atk_registry_set_factory_type:
* @registry: the #AtkRegistry in which to register the type association
* @type: an #AtkObject type
* @factory_type: an #AtkObjectFactory type to associate with @type. Must
* implement AtkObject appropriate for @type.
*
* Associate an #AtkObjectFactory subclass with a #GType. Note:
* The associated @factory_type will thereafter be responsible for
* the creation of new #AtkObject implementations for instances
* appropriate for @type.
**/
void
atk_registry_set_factory_type (AtkRegistry *registry,
GType type,
GType factory_type)
{
GType old_type;
gpointer value;
AtkObjectFactory *old_factory;
g_return_if_fail (ATK_IS_REGISTRY (registry));
value = g_hash_table_lookup (registry->factory_type_registry,
(gpointer) type);
old_type = (GType) value;
if (old_type && old_type != factory_type)
{
g_hash_table_remove (registry->factory_type_registry,
(gpointer) type);
/*
* If the old factory was created, notify it that it has
* been replaced, then free it.
*/
old_factory = g_hash_table_lookup (registry->factory_singleton_cache,
(gpointer) old_type);
if (old_factory)
{
atk_object_factory_invalidate (old_factory);
g_type_free_instance ((GTypeInstance *) old_factory);
}
}
g_hash_table_insert (registry->factory_type_registry,
(gpointer) type,
(gpointer) factory_type);
}
/**
* atk_registry_get_factory_type:
* @registry: an #AtkRegistry
* @type: a #GType with which to look up the associated #AtkObjectFactory
* subclass
*
* Provides a #GType indicating the #AtkObjectFactory subclass
* associated with @type.
*
* Returns: a #GType associated with type @type
**/
GType
atk_registry_get_factory_type (AtkRegistry *registry,
GType type)
{
GType factory_type;
gpointer value;
/*
* look up factory type in first hash;
* if there isn't an explicitly registered factory type,
* try inheriting one...
*/
do {
value =
g_hash_table_lookup (registry->factory_type_registry,
(gpointer) type);
type = g_type_parent (type);
if (type == G_TYPE_INVALID)
{
break;
}
} while (value == NULL);
factory_type = (GType) value;
return factory_type;
}
/**
* atk_registry_get_factory:
* @registry: an #AtkRegistry
* @type: a #GType with which to look up the associated #AtkObjectFactory
*
* Gets an #AtkObjectFactory appropriate for creating #AtkObjects
* appropriate for @type.
*
* Returns: (transfer none): an #AtkObjectFactory appropriate for creating
* #AtkObjects appropriate for @type.
**/
AtkObjectFactory*
atk_registry_get_factory (AtkRegistry *registry,
GType type)
{
gpointer factory_pointer = NULL;
GType factory_type;
factory_type = atk_registry_get_factory_type (registry, type);
if (factory_type == G_TYPE_INVALID)
{
/* Factory type has not been specified for this object type */
static AtkObjectFactory* default_factory = NULL;
if (!default_factory)
default_factory = atk_no_op_object_factory_new ();
return default_factory;
}
/* ask second hashtable for instance of factory type */
factory_pointer =
g_hash_table_lookup (registry->factory_singleton_cache,
(gpointer) factory_type);
/* if there isn't one already, create one and save it */
if (factory_pointer == NULL)
{
factory_pointer = g_type_create_instance (factory_type);
g_hash_table_insert (registry->factory_singleton_cache,
(gpointer) factory_type,
factory_pointer);
}
return ATK_OBJECT_FACTORY (factory_pointer);
}
/**
* atk_get_default_registry:
*
* Gets a default implementation of the #AtkObjectFactory/type
* registry.
* Note: For most toolkit maintainers, this will be the correct
* registry for registering new #AtkObject factories. Following
* a call to this function, maintainers may call atk_registry_set_factory_type()
* to associate an #AtkObjectFactory subclass with the GType of objects
* for whom accessibility information will be provided.
*
* Returns: (transfer full): a default implementation of the
* #AtkObjectFactory/type registry
**/
AtkRegistry*
atk_get_default_registry (void)
{
if (!default_registry)
{
default_registry = atk_registry_new ();
}
return default_registry;
}

74
atk/atkregistry.h Normal file
View File

@@ -0,0 +1,74 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_REGISTRY_H__
#define __ATK_REGISTRY_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <glib-object.h>
#include "atkobjectfactory.h"
G_BEGIN_DECLS
#define ATK_TYPE_REGISTRY (atk_registry_get_type ())
#define ATK_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_REGISTRY, AtkRegistry))
#define ATK_REGISTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_REGISTRY, AtkRegistryClass))
#define ATK_IS_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_REGISTRY))
#define ATK_IS_REGISTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_REGISTRY))
#define ATK_REGISTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_REGISTRY, AtkRegistryClass))
struct _AtkRegistry
{
GObject parent;
GHashTable *factory_type_registry;
GHashTable *factory_singleton_cache;
};
struct _AtkRegistryClass
{
GObjectClass parent_class;
};
typedef struct _AtkRegistry AtkRegistry;
typedef struct _AtkRegistryClass AtkRegistryClass;
GDK_AVAILABLE_IN_ALL
GType atk_registry_get_type (void);
GDK_AVAILABLE_IN_ALL
void atk_registry_set_factory_type (AtkRegistry *registry,
GType type,
GType factory_type);
GDK_AVAILABLE_IN_ALL
GType atk_registry_get_factory_type (AtkRegistry *registry,
GType type);
GDK_AVAILABLE_IN_ALL
AtkObjectFactory* atk_registry_get_factory (AtkRegistry *registry,
GType type);
GDK_AVAILABLE_IN_ALL
AtkRegistry* atk_get_default_registry (void);
G_END_DECLS
#endif /* __ATK_REGISTRY_H__ */

501
atk/atkrelation.c Normal file
View File

@@ -0,0 +1,501 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <string.h>
#include <glib-object.h>
#include "atk.h"
/**
* SECTION:atkrelation
* @Short_description: An object used to describe a relation between a
* object and one or more other objects.
* @Title:AtkRelation
*
* An AtkRelation describes a relation between an object and one or
* more other objects. The actual relations that an object has with
* other objects are defined as an AtkRelationSet, which is a set of
* AtkRelations.
*/
enum {
PROP_0,
PROP_RELATION_TYPE,
PROP_TARGET,
PROP_LAST
};
static GPtrArray *extra_names = NULL;
static gpointer parent_class = NULL;
static void atk_relation_class_init (AtkRelationClass *klass);
static void atk_relation_finalize (GObject *object);
static void atk_relation_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void atk_relation_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static GPtrArray* atk_relation_get_ptr_array_from_value_array (GValueArray *array);
static GValueArray* atk_relation_get_value_array_from_ptr_array (GPtrArray *array);
GType
atk_relation_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo typeInfo =
{
sizeof (AtkRelationClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) atk_relation_class_init,
(GClassFinalizeFunc) NULL,
NULL,
sizeof (AtkRelation),
0,
(GInstanceInitFunc) NULL,
} ;
type = g_type_register_static (G_TYPE_OBJECT, "AtkRelation", &typeInfo, 0) ;
}
return type;
}
static void
atk_relation_class_init (AtkRelationClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
gobject_class->finalize = atk_relation_finalize;
gobject_class->set_property = atk_relation_set_property;
gobject_class->get_property = atk_relation_get_property;
g_object_class_install_property (gobject_class,
PROP_RELATION_TYPE,
g_param_spec_enum ("relation_type",
"Relation Type",
"The type of the relation",
ATK_TYPE_RELATION_TYPE,
ATK_RELATION_NULL,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_TARGET,
g_param_spec_value_array ("target",
"Target",
"An array of the targets for the relation",
NULL,
G_PARAM_READWRITE));
}
/**
* atk_relation_type_register:
* @name: a name string
*
* Associate @name with a new #AtkRelationType
* Returns: an #AtkRelationType associated with @name
**/
AtkRelationType
atk_relation_type_register (const gchar *name)
{
g_return_val_if_fail (name, ATK_RELATION_NULL);
if (!extra_names)
extra_names = g_ptr_array_new ();
g_ptr_array_add (extra_names, g_strdup (name));
return extra_names->len + ATK_RELATION_LAST_DEFINED;
}
/**
* atk_relation_type_get_name:
* @type: The #AtkRelationType whose name is required
*
* Gets the description string describing the #AtkRelationType @type.
*
* Returns: the string describing the AtkRelationType
*/
const gchar*
atk_relation_type_get_name (AtkRelationType type)
{
GTypeClass *type_class;
GEnumValue *value;
const gchar *name = NULL;
type_class = g_type_class_ref (ATK_TYPE_RELATION_TYPE);
g_return_val_if_fail (G_IS_ENUM_CLASS (type_class), NULL);
value = g_enum_get_value (G_ENUM_CLASS (type_class), type);
if (value)
{
name = value->value_nick;
}
else
{
if (extra_names)
{
gint n = type;
n -= ATK_RELATION_LAST_DEFINED + 1;
if (n < extra_names->len)
name = g_ptr_array_index (extra_names, n);
}
}
g_type_class_unref (type_class);
return name;
}
/**
* atk_relation_type_for_name:
* @name: a string which is the (non-localized) name of an ATK relation type.
*
* Get the #AtkRelationType type corresponding to a relation name.
*
* Returns: the #AtkRelationType enumerated type corresponding to the specified name,
* or #ATK_RELATION_NULL if no matching relation type is found.
**/
AtkRelationType
atk_relation_type_for_name (const gchar *name)
{
GTypeClass *type_class;
GEnumValue *value;
AtkRelationType type = ATK_RELATION_NULL;
g_return_val_if_fail (name, ATK_RELATION_NULL);
type_class = g_type_class_ref (ATK_TYPE_RELATION_TYPE);
g_return_val_if_fail (G_IS_ENUM_CLASS (type_class), ATK_RELATION_NULL);
value = g_enum_get_value_by_nick (G_ENUM_CLASS (type_class), name);
if (value)
{
type = value->value;
}
else
{
gint i;
if (extra_names)
{
for (i = 0; i < extra_names->len; i++)
{
gchar *extra_name = (gchar *)g_ptr_array_index (extra_names, i);
g_return_val_if_fail (extra_name, ATK_RELATION_NULL);
if (strcmp (name, extra_name) == 0)
{
type = i + 1 + ATK_RELATION_LAST_DEFINED;
break;
}
}
}
}
g_type_class_unref (type_class);
return type;
}
/**
* atk_relation_new:
* @targets: (array length=n_targets): an array of pointers to
* #AtkObjects
* @n_targets: number of #AtkObjects pointed to by @targets
* @relationship: an #AtkRelationType with which to create the new
* #AtkRelation
*
* Create a new relation for the specified key and the specified list
* of targets. See also atk_object_add_relationship().
*
* Returns: a pointer to a new #AtkRelation
**/
AtkRelation*
atk_relation_new (AtkObject **targets,
gint n_targets,
AtkRelationType relationship)
{
AtkRelation *relation;
int i;
GValueArray *array;
GValue *value;
g_return_val_if_fail (targets != NULL, NULL);
array = g_value_array_new (n_targets);
for (i = 0; i < n_targets; i++)
{
value = g_new0 (GValue, 1);
g_value_init (value, ATK_TYPE_OBJECT);
g_value_set_object (value, targets[i]);
array = g_value_array_append (array, value);
g_value_unset (value);
g_free (value);
}
relation = g_object_new (ATK_TYPE_RELATION,
"relation_type", relationship,
"target", array,
NULL);
g_value_array_free (array);
return relation;
}
/**
* atk_relation_get_relation_type:
* @relation: an #AtkRelation
*
* Gets the type of @relation
*
* Returns: the type of @relation
**/
AtkRelationType
atk_relation_get_relation_type (AtkRelation *relation)
{
g_return_val_if_fail (ATK_IS_RELATION (relation), 0);
return relation->relationship;
}
/**
* atk_relation_get_target:
* @relation: an #AtkRelation
*
* Gets the target list of @relation
*
* Returns: (transfer none) (element-type Atk.Object): the target list of @relation
**/
GPtrArray*
atk_relation_get_target (AtkRelation *relation)
{
g_return_val_if_fail (ATK_IS_RELATION (relation), NULL);
return relation->target;
}
static void
delete_object_while_in_relation (gpointer callback_data,
GObject *where_the_object_was)
{
GPtrArray *array;
g_assert (callback_data != NULL);
array = callback_data;
g_ptr_array_remove (array, where_the_object_was);
}
/**
* atk_relation_add_target:
* @relation: an #AtkRelation
* @target: an #AtkObject
*
* Adds the specified AtkObject to the target for the relation, if it is
* not already present. See also atk_object_add_relationship().
*
*
* Since: 1.9
**/
void
atk_relation_add_target (AtkRelation *relation,
AtkObject *target)
{
guint i;
g_return_if_fail (ATK_IS_RELATION (relation));
g_return_if_fail (ATK_IS_OBJECT (target));
/* first check if target occurs in array ... */
for (i = 0; i < relation->target->len; i++)
if (g_ptr_array_index(relation->target, i) == target)
return;
g_ptr_array_add (relation->target, target);
g_object_weak_ref (G_OBJECT (target), (GWeakNotify) delete_object_while_in_relation, relation->target);
}
/**
* atk_relation_remove_target:
* @relation: an #AtkRelation
* @target: an #AtkObject
*
* Remove the specified AtkObject from the target for the relation.
*
* Returns: TRUE if the removal is successful.
**/
gboolean
atk_relation_remove_target (AtkRelation *relation,
AtkObject *target)
{
gboolean ret = FALSE;
GPtrArray *array;
array = atk_relation_get_target (relation);
if (array && g_ptr_array_remove (array, target))
{
g_object_weak_unref (G_OBJECT (target),
(GWeakNotify) delete_object_while_in_relation,
relation->target);
ret = TRUE;
}
return ret;
}
static void
atk_relation_finalize (GObject *object)
{
AtkRelation *relation;
g_return_if_fail (ATK_IS_RELATION (object));
relation = ATK_RELATION (object);
if (relation->target)
{
gint i;
for (i = 0; i < relation->target->len; i++)
{
g_object_weak_unref (G_OBJECT (g_ptr_array_index (relation->target, i)),
(GWeakNotify) delete_object_while_in_relation,
relation->target);
}
g_ptr_array_free (relation->target, TRUE);
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
atk_relation_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
AtkRelation *relation;
gpointer boxed;
relation = ATK_RELATION (object);
switch (prop_id)
{
case PROP_RELATION_TYPE:
relation->relationship = g_value_get_enum (value);
break;
case PROP_TARGET:
if (relation->target)
{
gint i;
for (i = 0; i < relation->target->len; i++)
{
g_object_weak_unref (G_OBJECT (g_ptr_array_index (relation->target, i)),
(GWeakNotify) delete_object_while_in_relation,
relation->target);
}
g_ptr_array_free (relation->target, TRUE);
}
boxed = g_value_get_boxed (value);
relation->target = atk_relation_get_ptr_array_from_value_array ( (GValueArray *) boxed);
break;
default:
break;
}
}
static void
atk_relation_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
AtkRelation *relation;
GValueArray *array;
relation = ATK_RELATION (object);
switch (prop_id)
{
case PROP_RELATION_TYPE:
g_value_set_enum (value, relation->relationship);
break;
case PROP_TARGET:
array = atk_relation_get_value_array_from_ptr_array (relation->target);
g_value_set_boxed (value, array);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static GPtrArray*
atk_relation_get_ptr_array_from_value_array (GValueArray *array)
{
gint i;
GPtrArray *return_array;
GValue *value;
GObject *obj;
return_array = g_ptr_array_sized_new (array->n_values);
for (i = 0; i < array->n_values; i++)
{
value = g_value_array_get_nth (array, i);
obj = g_value_get_object (value);
g_ptr_array_add (return_array, obj);
g_object_weak_ref (obj, (GWeakNotify) delete_object_while_in_relation, return_array);
}
return return_array;
}
static GValueArray*
atk_relation_get_value_array_from_ptr_array (GPtrArray *array)
{
int i;
GValueArray *return_array;
GValue *value;
return_array = g_value_array_new (array->len);
for (i = 0; i < array->len; i++)
{
value = g_new0 (GValue, 1);
g_value_init (value, ATK_TYPE_OBJECT);
g_value_set_object (value, g_ptr_array_index (array, i));
return_array = g_value_array_append (return_array, value);
}
return return_array;
}

97
atk/atkrelation.h Normal file
View File

@@ -0,0 +1,97 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_RELATION_H__
#define __ATK_RELATION_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
G_BEGIN_DECLS
#include <atk/atktypes.h>
/*
* An AtkRelation describes a relation between the object and one or more
* other objects. The actual relations that an object has with other objects
* are defined as an AtkRelationSet, which is a set of AtkRelations.
*/
#define ATK_TYPE_RELATION (atk_relation_get_type ())
#define ATK_RELATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_RELATION, AtkRelation))
#define ATK_RELATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_RELATION, AtkRelationClass))
#define ATK_IS_RELATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_RELATION))
#define ATK_IS_RELATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_RELATION))
#define ATK_RELATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_RELATION, AtkRelationClass))
typedef struct _AtkRelation AtkRelation;
typedef struct _AtkRelationClass AtkRelationClass;
struct _AtkRelation
{
GObject parent;
GPtrArray *target;
AtkRelationType relationship;
};
struct _AtkRelationClass
{
GObjectClass parent;
};
GDK_AVAILABLE_IN_ALL
GType atk_relation_get_type (void);
GDK_AVAILABLE_IN_ALL
AtkRelationType atk_relation_type_register (const gchar *name);
GDK_AVAILABLE_IN_ALL
const gchar* atk_relation_type_get_name (AtkRelationType type);
GDK_AVAILABLE_IN_ALL
AtkRelationType atk_relation_type_for_name (const gchar *name);
/*
* Create a new relation for the specified key and the specified list
* of targets.
*/
GDK_AVAILABLE_IN_ALL
AtkRelation* atk_relation_new (AtkObject **targets,
gint n_targets,
AtkRelationType relationship);
/*
* Returns the type of a relation.
*/
GDK_AVAILABLE_IN_ALL
AtkRelationType atk_relation_get_relation_type (AtkRelation *relation);
/*
* Returns the target list of a relation.
*/
GDK_AVAILABLE_IN_ALL
GPtrArray* atk_relation_get_target (AtkRelation *relation);
GDK_AVAILABLE_IN_ALL
void atk_relation_add_target (AtkRelation *relation,
AtkObject *target);
GDK_AVAILABLE_IN_ALL
gboolean atk_relation_remove_target (AtkRelation *relation,
AtkObject *target);
G_END_DECLS
#endif /* __ATK_RELATION_H__ */

409
atk/atkrelationset.c Normal file
View File

@@ -0,0 +1,409 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <glib-object.h>
#include "atk.h"
/**
* SECTION:atkrelationset
* @Short_description: A set of AtkRelations, normally the set of
* AtkRelations which an AtkObject has.
* @Title:AtkRelationSet
*
* The AtkRelationSet held by an object establishes its relationships
* with objects beyond the normal "parent/child" hierarchical
* relationships that all user interface objects have.
* AtkRelationSets establish whether objects are labelled or
* controlled by other components, share group membership with other
* components (for instance within a radio-button group), or share
* content which "flows" between them, among other types of possible
* relationships.
*/
static gpointer parent_class = NULL;
static void atk_relation_set_class_init (AtkRelationSetClass *klass);
static void atk_relation_set_finalize (GObject *object);
GType
atk_relation_set_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo typeInfo =
{
sizeof (AtkRelationSetClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) atk_relation_set_class_init,
(GClassFinalizeFunc) NULL,
NULL,
sizeof (AtkRelationSet),
0,
(GInstanceInitFunc) NULL,
} ;
type = g_type_register_static (G_TYPE_OBJECT, "AtkRelationSet", &typeInfo, 0) ;
}
return type;
}
static void
atk_relation_set_class_init (AtkRelationSetClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
gobject_class->finalize = atk_relation_set_finalize;
}
/**
* atk_relation_set_new:
*
* Creates a new empty relation set.
*
* Returns: a new #AtkRelationSet
**/
AtkRelationSet*
atk_relation_set_new (void)
{
AtkRelationSet *relation_set;
relation_set = g_object_new (ATK_TYPE_RELATION_SET, NULL);
return relation_set;
}
/**
* atk_relation_set_contains:
* @set: an #AtkRelationSet
* @relationship: an #AtkRelationType
*
* Determines whether the relation set contains a relation that matches the
* specified type.
*
* Returns: %TRUE if @relationship is the relationship type of a relation
* in @set, %FALSE otherwise
**/
gboolean
atk_relation_set_contains (AtkRelationSet *set,
AtkRelationType relationship)
{
GPtrArray *array_item;
AtkRelation *item;
gint i;
g_return_val_if_fail (ATK_IS_RELATION_SET (set), FALSE);
array_item = set->relations;
if (array_item == NULL)
return FALSE;
for (i = 0; i < array_item->len; i++)
{
item = g_ptr_array_index (array_item, i);
if (item->relationship == relationship)
return TRUE;
}
return FALSE;
}
/**
* atk_relation_set_remove:
* @set: an #AtkRelationSet
* @relation: an #AtkRelation
*
* Removes a relation from the relation set.
* This function unref's the #AtkRelation so it will be deleted unless there
* is another reference to it.
**/
void
atk_relation_set_remove (AtkRelationSet *set,
AtkRelation *relation)
{
GPtrArray *array_item;
AtkRelationType relationship;
g_return_if_fail (ATK_IS_RELATION_SET (set));
array_item = set->relations;
if (array_item == NULL)
return;
if (g_ptr_array_remove (array_item, relation))
{
g_object_unref (relation);
}
else
{
relationship = atk_relation_get_relation_type (relation);
if (atk_relation_set_contains (set, relationship))
{
AtkRelation *exist_relation;
gint i;
exist_relation = atk_relation_set_get_relation_by_type (set, relationship);
for (i = 0; i < relation->target->len; i++)
{
AtkObject *target = g_ptr_array_index(relation->target, i);
atk_relation_remove_target (exist_relation, target);
}
}
}
}
/**
* atk_relation_set_add:
* @set: an #AtkRelationSet
* @relation: an #AtkRelation
*
* Add a new relation to the current relation set if it is not already
* present.
* This function ref's the AtkRelation so the caller of this function
* should unref it to ensure that it will be destroyed when the AtkRelationSet
* is destroyed.
**/
void
atk_relation_set_add (AtkRelationSet *set,
AtkRelation *relation)
{
AtkRelationType relationship;
g_return_if_fail (ATK_IS_RELATION_SET (set));
g_return_if_fail (relation != NULL);
if (set->relations == NULL)
{
set->relations = g_ptr_array_new ();
}
relationship = atk_relation_get_relation_type (relation);
if (!atk_relation_set_contains (set, relationship))
{
g_ptr_array_add (set->relations, relation);
g_object_ref (relation);
}
else
{
AtkRelation *exist_relation;
gint i;
exist_relation = atk_relation_set_get_relation_by_type (set, relationship);
for (i = 0; i < relation->target->len; i++)
{
AtkObject *target = g_ptr_array_index(relation->target, i);
atk_relation_add_target (exist_relation, target);
}
}
}
/**
* atk_relation_set_get_n_relations:
* @set: an #AtkRelationSet
*
* Determines the number of relations in a relation set.
*
* Returns: an integer representing the number of relations in the set.
**/
gint
atk_relation_set_get_n_relations (AtkRelationSet *set)
{
g_return_val_if_fail (ATK_IS_RELATION_SET (set), 0);
if (set->relations == NULL)
return 0;
return set->relations->len;
}
/**
* atk_relation_set_get_relation:
* @set: an #AtkRelationSet
* @i: a gint representing a position in the set, starting from 0.
*
* Determines the relation at the specified position in the relation set.
*
* Returns: (transfer none): a #AtkRelation, which is the relation at
* position i in the set.
**/
AtkRelation*
atk_relation_set_get_relation (AtkRelationSet *set,
gint i)
{
GPtrArray *array_item;
AtkRelation* item;
g_return_val_if_fail (ATK_IS_RELATION_SET (set), NULL);
g_return_val_if_fail (i >= 0, NULL);
array_item = set->relations;
if (array_item == NULL)
return NULL;
item = g_ptr_array_index (array_item, i);
if (item == NULL)
return NULL;
return item;
}
/**
* atk_relation_set_get_relation_by_type:
* @set: an #AtkRelationSet
* @relationship: an #AtkRelationType
*
* Finds a relation that matches the specified type.
*
* Returns: (transfer none): an #AtkRelation, which is a relation matching the
* specified type.
**/
AtkRelation*
atk_relation_set_get_relation_by_type (AtkRelationSet *set,
AtkRelationType relationship)
{
GPtrArray *array_item;
AtkRelation *item;
gint i;
g_return_val_if_fail (ATK_IS_RELATION_SET (set), NULL);
array_item = set->relations;
if (array_item == NULL)
return NULL;
for (i = 0; i < array_item->len; i++)
{
item = g_ptr_array_index (array_item, i);
if (item->relationship == relationship)
return item;
}
return NULL;
}
static void
atk_relation_set_finalize (GObject *object)
{
AtkRelationSet *relation_set;
GPtrArray *array;
gint i;
g_return_if_fail (ATK_IS_RELATION_SET (object));
relation_set = ATK_RELATION_SET (object);
array = relation_set->relations;
if (array)
{
for (i = 0; i < array->len; i++)
{
g_object_unref (g_ptr_array_index (array, i));
}
g_ptr_array_free (array, TRUE);
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
/**
* atk_relation_set_add_relation_by_type:
* @set: an #AtkRelationSet
* @relationship: an #AtkRelationType
* @target: an #AtkObject
*
* Add a new relation of the specified type with the specified target to
* the current relation set if the relation set does not contain a relation
* of that type. If it is does contain a relation of that typea the target
* is added to the relation.
*
* Since: 1.9
**/
void
atk_relation_set_add_relation_by_type (AtkRelationSet *set,
AtkRelationType relationship,
AtkObject *target)
{
AtkRelation *relation;
g_return_if_fail (ATK_IS_RELATION_SET (set));
g_return_if_fail (ATK_IS_OBJECT (target));
relation = atk_relation_set_get_relation_by_type (set,
relationship);
if (relation)
{
atk_relation_add_target (relation, target);
}
else
{
/* the relation hasn't been created yet ... */
relation = atk_relation_new (&target, 1, relationship);
atk_relation_set_add (set, relation);
g_object_unref(relation);
}
}
/**
* atk_relation_set_contains_target:
* @set: an #AtkRelationSet
* @relationship: an #AtkRelationType
* @target: an #AtkObject
*
* Determines whether the relation set contains a relation that
* matches the specified pair formed by type @relationship and object
* @target.
*
* Returns: %TRUE if @set contains a relation with the relationship
* type @relationship with an object @target, %FALSE otherwise
**/
gboolean
atk_relation_set_contains_target (AtkRelationSet *set,
AtkRelationType relationship,
AtkObject *target)
{
GPtrArray *array_relations;
GPtrArray *array_target;
AtkObject *current_target;
AtkRelation *relation;
gint i;
gint c;
g_return_val_if_fail (ATK_IS_RELATION_SET (set), FALSE);
g_return_val_if_fail (ATK_IS_OBJECT (target), FALSE);
array_relations = set->relations;
if (array_relations == NULL)
return FALSE;
for (i = 0; i < array_relations->len; i++)
{
relation = g_ptr_array_index (array_relations, i);
if (relation->relationship == relationship)
{
array_target = atk_relation_get_target (relation);
for (c = 0; c < array_target->len; c++)
{
current_target = g_ptr_array_index (array_target, c);
if (target == current_target)
return TRUE;
}
}
}
return FALSE;
}

91
atk/atkrelationset.h Normal file
View File

@@ -0,0 +1,91 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_RELATION_SET_H__
#define __ATK_RELATION_SET_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
G_BEGIN_DECLS
#include <glib-object.h>
#include <atk/atkobject.h>
#include <atk/atkrelation.h>
#define ATK_TYPE_RELATION_SET (atk_relation_set_get_type ())
#define ATK_RELATION_SET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_RELATION_SET, AtkRelationSet))
#define ATK_RELATION_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_RELATION_SET, AtkRelationSetClass))
#define ATK_IS_RELATION_SET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_RELATION_SET))
#define ATK_IS_RELATION_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_RELATION_SET))
#define ATK_RELATION_SET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_RELATION_SET, AtkRelationSetClass))
typedef struct _AtkRelationSetClass AtkRelationSetClass;
struct _AtkRelationSet
{
GObject parent;
GPtrArray *relations;
};
struct _AtkRelationSetClass
{
GObjectClass parent;
AtkFunction pad1;
AtkFunction pad2;
};
GDK_AVAILABLE_IN_ALL
GType atk_relation_set_get_type (void);
GDK_AVAILABLE_IN_ALL
AtkRelationSet* atk_relation_set_new (void);
GDK_AVAILABLE_IN_ALL
gboolean atk_relation_set_contains (AtkRelationSet *set,
AtkRelationType relationship);
GDK_AVAILABLE_IN_ALL
gboolean atk_relation_set_contains_target (AtkRelationSet *set,
AtkRelationType relationship,
AtkObject *target);
GDK_AVAILABLE_IN_ALL
void atk_relation_set_remove (AtkRelationSet *set,
AtkRelation *relation);
GDK_AVAILABLE_IN_ALL
void atk_relation_set_add (AtkRelationSet *set,
AtkRelation *relation);
GDK_AVAILABLE_IN_ALL
gint atk_relation_set_get_n_relations (AtkRelationSet *set);
GDK_AVAILABLE_IN_ALL
AtkRelation* atk_relation_set_get_relation (AtkRelationSet *set,
gint i);
GDK_AVAILABLE_IN_ALL
AtkRelation* atk_relation_set_get_relation_by_type (AtkRelationSet *set,
AtkRelationType relationship);
GDK_AVAILABLE_IN_ALL
void atk_relation_set_add_relation_by_type (AtkRelationSet *set,
AtkRelationType relationship,
AtkObject *target);
G_END_DECLS
#endif /* __ATK_RELATION_SET_H__ */

33
atk/atkrelationtype.h Normal file
View File

@@ -0,0 +1,33 @@
/* ATK - Accessibility Toolkit
* Copyright 2002 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_RELATION_TYPE_H__
#define __ATK_RELATION_TYPE_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <glib.h>
G_BEGIN_DECLS
G_END_DECLS
#endif /* __ATK_RELATION_TYPE_H__ */

289
atk/atkselection.c Normal file
View File

@@ -0,0 +1,289 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "atkselection.h"
/**
* SECTION:atkselection
* @Short_description: The ATK interface implemented by container
* objects whose #AtkObject children can be selected.
* @Title:AtkSelection
*
* #AtkSelection should be implemented by UI components with children
* which are exposed by #atk_object_ref_child and
* #atk_object_get_n_children, if the use of the parent UI component
* ordinarily involves selection of one or more of the objects
* corresponding to those #AtkObject children - for example,
* selectable lists.
*
* Note that other types of "selection" (for instance text selection)
* are accomplished a other ATK interfaces - #AtkSelection is limited
* to the selection/deselection of children.
*/
enum {
SELECTION_CHANGED,
LAST_SIGNAL
};
static void atk_selection_base_init (gpointer *g_class);
static guint atk_selection_signals[LAST_SIGNAL] = { 0 };
GType
atk_selection_get_type (void)
{
static GType type = 0;
if (!type) {
GTypeInfo tinfo =
{
sizeof (AtkSelectionIface),
(GBaseInitFunc)atk_selection_base_init,
(GBaseFinalizeFunc) NULL,
};
type = g_type_register_static (G_TYPE_INTERFACE, "AtkSelection", &tinfo, 0);
}
return type;
}
static void
atk_selection_base_init (gpointer *g_class)
{
static gboolean initialized = FALSE;
if (! initialized)
{
/**
* AtkSelection::selection-changed:
* @atkselection: the object which received the signal.
*
* The "selection-changed" signal is emitted by an object which
* implements AtkSelection interface when the selection changes.
*/
atk_selection_signals[SELECTION_CHANGED] =
g_signal_new ("selection_changed",
ATK_TYPE_SELECTION,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (AtkSelectionIface, selection_changed),
(GSignalAccumulator) NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
initialized = TRUE;
}
}
/**
* atk_selection_add_selection:
* @selection: a #GObject instance that implements AtkSelectionIface
* @i: a #gint specifying the child index.
*
* Adds the specified accessible child of the object to the
* object's selection.
*
* Returns: TRUE if success, FALSE otherwise.
**/
gboolean
atk_selection_add_selection (AtkSelection *obj,
gint i)
{
AtkSelectionIface *iface;
g_return_val_if_fail (ATK_IS_SELECTION (obj), FALSE);
iface = ATK_SELECTION_GET_IFACE (obj);
if (iface->add_selection)
return (iface->add_selection) (obj, i);
else
return FALSE;
}
/**
* atk_selection_clear_selection:
* @selection: a #GObject instance that implements AtkSelectionIface
*
* Clears the selection in the object so that no children in the object
* are selected.
*
* Returns: TRUE if success, FALSE otherwise.
**/
gboolean
atk_selection_clear_selection (AtkSelection *obj)
{
AtkSelectionIface *iface;
g_return_val_if_fail (ATK_IS_SELECTION (obj), FALSE);
iface = ATK_SELECTION_GET_IFACE (obj);
if (iface->clear_selection)
return (iface->clear_selection) (obj);
else
return FALSE;
}
/**
* atk_selection_ref_selection:
* @selection: a #GObject instance that implements AtkSelectionIface
* @i: a #gint specifying the index in the selection set. (e.g. the
* ith selection as opposed to the ith child).
*
* Gets a reference to the accessible object representing the specified
* selected child of the object.
* Note: callers should not rely on %NULL or on a zero value for
* indication of whether AtkSelectionIface is implemented, they should
* use type checking/interface checking macros or the
* atk_get_accessible_value() convenience method.
*
* Returns: (nullable) (transfer full): an #AtkObject representing the
* selected accessible, or %NULL if @selection does not implement this
* interface.
**/
AtkObject*
atk_selection_ref_selection (AtkSelection *obj,
gint i)
{
AtkSelectionIface *iface;
g_return_val_if_fail (ATK_IS_SELECTION (obj), NULL);
iface = ATK_SELECTION_GET_IFACE (obj);
if (iface->ref_selection)
return (iface->ref_selection) (obj, i);
else
return NULL;
}
/**
* atk_selection_get_selection_count:
* @selection: a #GObject instance that implements AtkSelectionIface
*
* Gets the number of accessible children currently selected.
* Note: callers should not rely on %NULL or on a zero value for
* indication of whether AtkSelectionIface is implemented, they should
* use type checking/interface checking macros or the
* atk_get_accessible_value() convenience method.
*
* Returns: a gint representing the number of items selected, or 0
* if @selection does not implement this interface.
**/
gint
atk_selection_get_selection_count (AtkSelection *obj)
{
AtkSelectionIface *iface;
g_return_val_if_fail (ATK_IS_SELECTION (obj), 0);
iface = ATK_SELECTION_GET_IFACE (obj);
if (iface->get_selection_count)
return (iface->get_selection_count) (obj);
else
return 0;
}
/**
* atk_selection_is_child_selected:
* @selection: a #GObject instance that implements AtkSelectionIface
* @i: a #gint specifying the child index.
*
* Determines if the current child of this object is selected
* Note: callers should not rely on %NULL or on a zero value for
* indication of whether AtkSelectionIface is implemented, they should
* use type checking/interface checking macros or the
* atk_get_accessible_value() convenience method.
*
* Returns: a gboolean representing the specified child is selected, or 0
* if @selection does not implement this interface.
**/
gboolean
atk_selection_is_child_selected (AtkSelection *obj,
gint i)
{
AtkSelectionIface *iface;
g_return_val_if_fail (ATK_IS_SELECTION (obj), FALSE);
iface = ATK_SELECTION_GET_IFACE (obj);
if (iface->is_child_selected)
return (iface->is_child_selected) (obj, i);
else
return FALSE;
}
/**
* atk_selection_remove_selection:
* @selection: a #GObject instance that implements AtkSelectionIface
* @i: a #gint specifying the index in the selection set. (e.g. the
* ith selection as opposed to the ith child).
*
* Removes the specified child of the object from the object's selection.
*
* Returns: TRUE if success, FALSE otherwise.
**/
gboolean
atk_selection_remove_selection (AtkSelection *obj,
gint i)
{
AtkSelectionIface *iface;
g_return_val_if_fail (ATK_IS_SELECTION (obj), FALSE);
iface = ATK_SELECTION_GET_IFACE (obj);
if (iface->remove_selection)
return (iface->remove_selection) (obj, i);
else
return FALSE;
}
/**
* atk_selection_select_all_selection:
* @selection: a #GObject instance that implements AtkSelectionIface
*
* Causes every child of the object to be selected if the object
* supports multiple selections.
*
* Returns: TRUE if success, FALSE otherwise.
**/
gboolean
atk_selection_select_all_selection (AtkSelection *obj)
{
AtkSelectionIface *iface;
g_return_val_if_fail (ATK_IS_SELECTION (obj), FALSE);
iface = ATK_SELECTION_GET_IFACE (obj);
if (iface->select_all_selection)
return (iface->select_all_selection) (obj);
else
return FALSE;
}

100
atk/atkselection.h Normal file
View File

@@ -0,0 +1,100 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_SELECTION_H__
#define __ATK_SELECTION_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <atk/atkobject.h>
G_BEGIN_DECLS
/*
* This AtkSelection interface provides the standard mechanism for an
* assistive technology to determine what the current selected children are,
* as well as modify the selection set. Any object that has children that
* can be selected should support the AtkSelection interface.
*/
#define ATK_TYPE_SELECTION (atk_selection_get_type ())
#define ATK_IS_SELECTION(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_SELECTION)
#define ATK_SELECTION(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_SELECTION, AtkSelection)
#define ATK_SELECTION_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_SELECTION, AtkSelectionIface))
#ifndef _TYPEDEF_ATK_SELECTION_
#define _TYPEDEF_ATK_SELECTION_
typedef struct _AtkSelection AtkSelection;
#endif
typedef struct _AtkSelectionIface AtkSelectionIface;
struct _AtkSelectionIface
{
GTypeInterface parent;
gboolean (* add_selection) (AtkSelection *selection,
gint i);
gboolean (* clear_selection) (AtkSelection *selection);
AtkObject* (* ref_selection) (AtkSelection *selection,
gint i);
gint (* get_selection_count) (AtkSelection *selection);
gboolean (* is_child_selected) (AtkSelection *selection,
gint i);
gboolean (* remove_selection) (AtkSelection *selection,
gint i);
gboolean (* select_all_selection) (AtkSelection *selection);
/* signal handlers */
void (*selection_changed) (AtkSelection *selection);
};
GDK_AVAILABLE_IN_ALL
GType atk_selection_get_type (void);
GDK_AVAILABLE_IN_ALL
gboolean atk_selection_add_selection (AtkSelection *selection,
gint i);
GDK_AVAILABLE_IN_ALL
gboolean atk_selection_clear_selection (AtkSelection *selection);
GDK_AVAILABLE_IN_ALL
AtkObject* atk_selection_ref_selection (AtkSelection *selection,
gint i);
GDK_AVAILABLE_IN_ALL
gint atk_selection_get_selection_count (AtkSelection *selection);
GDK_AVAILABLE_IN_ALL
gboolean atk_selection_is_child_selected (AtkSelection *selection,
gint i);
GDK_AVAILABLE_IN_ALL
gboolean atk_selection_remove_selection (AtkSelection *selection,
gint i);
GDK_AVAILABLE_IN_ALL
gboolean atk_selection_select_all_selection (AtkSelection *selection);
G_END_DECLS
#endif /* __ATK_SELECTION_H__ */

199
atk/atksocket.c Normal file
View File

@@ -0,0 +1,199 @@
/* ATK - Accessibility Toolkit
* Copyright (C) 2009 Novell, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "atk.h"
#include "atksocket.h"
/**
* SECTION:atksocket
* @Short_description: Container for AtkPlug objects from other processes
* @Title: AtkSocket
* @See_also: #AtkPlug
*
* Together with #AtkPlug, #AtkSocket provides the ability to embed
* accessibles from one process into another in a fashion that is
* transparent to assistive technologies. #AtkSocket works as the
* container of #AtkPlug, embedding it using the method
* atk_socket_embed(). Any accessible contained in the #AtkPlug will
* appear to the assistive technologies as being inside the
* application that created the #AtkSocket.
*
* The communication between a #AtkSocket and a #AtkPlug is done by
* the IPC layer of the accessibility framework, normally implemented
* by the D-Bus based implementation of AT-SPI (at-spi2). If that is
* the case, at-spi-atk2 is the responsible to implement the abstract
* methods atk_plug_get_id() and atk_socket_embed(), so an ATK
* implementor shouldn't reimplement them. The process that contains
* the #AtkPlug is responsible to send the ID returned by
* atk_plug_id() to the process that contains the #AtkSocket, so it
* could call the method atk_socket_embed() in order to embed it.
*
* For the same reasons, an implementor doesn't need to implement
* atk_object_get_n_accessible_children() and
* atk_object_ref_accessible_child(). All the logic related to those
* functions will be implemented by the IPC layer.
*/
static void atk_socket_finalize (GObject *obj);
static void atk_component_interface_init (AtkComponentIface *iface);
static void atk_socket_component_real_get_extents (AtkComponent *component,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coord_type);
G_DEFINE_TYPE_WITH_CODE (AtkSocket, atk_socket, ATK_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, atk_component_interface_init))
static void
atk_socket_init (AtkSocket* obj)
{
AtkObject *accessible = ATK_OBJECT (obj);
obj->embedded_plug_id = NULL;
accessible->role = ATK_ROLE_FILLER;
accessible->layer = ATK_LAYER_WIDGET;
}
static void
atk_socket_class_init (AtkSocketClass* klass)
{
GObjectClass *obj_class = G_OBJECT_CLASS (klass);
obj_class->finalize = atk_socket_finalize;
klass->embed = NULL;
}
static void
atk_socket_finalize (GObject *_obj)
{
AtkSocket *obj = ATK_SOCKET (_obj);
g_free (obj->embedded_plug_id);
obj->embedded_plug_id = NULL;
G_OBJECT_CLASS (atk_socket_parent_class)->finalize (_obj);
}
static void
atk_component_interface_init (AtkComponentIface *iface)
{
iface->get_extents = atk_socket_component_real_get_extents;
}
/**
* atk_socket_new:
*
* Creates a new #AtkSocket.
*
* Returns: (transfer full): the newly created #AtkSocket instance
*/
AtkObject*
atk_socket_new (void)
{
return g_object_new (ATK_TYPE_SOCKET, NULL);
}
/**
* atk_socket_embed:
* @obj: an #AtkSocket
* @plug_id: the ID of an #AtkPlug
*
* Embeds the children of an #AtkPlug as the children of the
* #AtkSocket. The plug may be in the same process or in a different
* process.
*
* The class item used by this function should be filled in by the IPC
* layer (usually at-spi2-atk). The implementor of the AtkSocket
* should call this function and pass the id for the plug as returned
* by atk_plug_get_id(). It is the responsibility of the application
* to pass the plug id on to the process implementing the #AtkSocket
* as needed.
*
* Since: 1.30
**/
void
atk_socket_embed (AtkSocket* obj, const gchar* plug_id)
{
AtkSocketClass *klass;
g_return_if_fail (plug_id != NULL);
g_return_if_fail (ATK_IS_SOCKET (obj));
klass = g_type_class_peek (ATK_TYPE_SOCKET);
if (klass && klass->embed)
{
if (obj->embedded_plug_id)
g_free (obj->embedded_plug_id);
obj->embedded_plug_id = g_strdup (plug_id);
(klass->embed) (obj, plug_id);
}
}
/**
* atk_socket_is_occupied:
* @obj: an #AtkSocket
*
* Determines whether or not the socket has an embedded plug.
*
* Returns: TRUE if a plug is embedded in the socket
*
* Since: 1.30
**/
gboolean
atk_socket_is_occupied (AtkSocket* obj)
{
g_return_val_if_fail (ATK_IS_SOCKET (obj), FALSE);
return (obj->embedded_plug_id != NULL);
}
static void
atk_socket_component_real_get_extents (AtkComponent *component,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coord_type)
{
AtkObject *parent = atk_object_get_parent (ATK_OBJECT (component));
if (parent == NULL || !ATK_IS_COMPONENT (parent))
{
if (x)
*x = -1;
if (y)
*y = -1;
if (width)
*width = -1;
if (height)
*height = -1;
return;
}
atk_component_get_extents (ATK_COMPONENT (parent), x, y, width, height, coord_type);
}

71
atk/atksocket.h Normal file
View File

@@ -0,0 +1,71 @@
/* ATK - Accessibility Toolkit
* Copyright 2009 Novell, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_SOCKET_H__
#define __ATK_SOCKET_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <atk/atkobject.h>
G_BEGIN_DECLS
#define ATK_TYPE_SOCKET (atk_socket_get_type ())
#define ATK_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_SOCKET, AtkSocket))
#define ATK_IS_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_SOCKET))
#define ATK_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_SOCKET, AtkSocketClass))
#define ATK_IS_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_SOCKET))
#define ATK_SOCKET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_SOCKET, AtkSocketClass))
typedef struct _AtkSocket AtkSocket;
typedef struct _AtkSocketClass AtkSocketClass;
struct _AtkSocket
{
AtkObject parent;
/*< private >*/
gchar* embedded_plug_id;
};
GDK_AVAILABLE_IN_ALL
GType atk_socket_get_type (void);
struct _AtkSocketClass
{
AtkObjectClass parent_class;
/* to be subscribed to by atk-bridge */
/*< protected >*/
void (* embed) (AtkSocket *obj, const gchar* plug_id);
};
GDK_AVAILABLE_IN_ALL
AtkObject* atk_socket_new (void);
GDK_AVAILABLE_IN_ALL
void atk_socket_embed (AtkSocket* obj, const gchar* plug_id);
GDK_AVAILABLE_IN_ALL
gboolean atk_socket_is_occupied (AtkSocket* obj);
G_END_DECLS
#endif /* __ATK_SOCKET_H__ */

143
atk/atkstate.c Normal file
View File

@@ -0,0 +1,143 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "atk.h"
#include <string.h>
/**
* SECTION:atkstate
* @Short_description: An AtkState describes a single state of an object.
* @Title:AtkState
*
* An AtkState describes a single state of an object. The full set of states
* that apply to an object at a given time are contained in its #AtkStateSet.
* See also #atk_object_ref_state_set and #atk_object_notify_state_change.
*/
static guint last_type = ATK_STATE_LAST_DEFINED;
#define NUM_POSSIBLE_STATES (sizeof(AtkState)*8)
static gchar* state_names[NUM_POSSIBLE_STATES];
/**
* atk_state_type_register:
* @name: a character string describing the new state.
*
* Register a new object state.
*
* Returns: an #AtkState value for the new state.
**/
AtkStateType
atk_state_type_register (const gchar *name)
{
g_return_val_if_fail (name, ATK_STATE_INVALID);
if (last_type < NUM_POSSIBLE_STATES -1)
{
state_names[++last_type] = g_strdup (name);
return (last_type);
}
return ATK_STATE_INVALID; /* caller needs to check */
}
/**
* atk_state_type_get_name:
* @type: The #AtkStateType whose name is required
*
* Gets the description string describing the #AtkStateType @type.
*
* Returns: the string describing the AtkStateType
*/
const gchar*
atk_state_type_get_name (AtkStateType type)
{
GTypeClass *type_class;
GEnumValue *value;
const gchar *name = NULL;
type_class = g_type_class_ref (ATK_TYPE_STATE_TYPE);
g_return_val_if_fail (G_IS_ENUM_CLASS (type_class), NULL);
value = g_enum_get_value (G_ENUM_CLASS (type_class), type);
if (value)
{
name = value->value_nick;
}
else
{
if (type <= last_type)
{
if (type >= 0)
name = state_names[type];
}
}
g_type_class_unref (type_class);
return name;
}
/**
* atk_state_type_for_name:
* @name: a character string state name
*
* Gets the #AtkStateType corresponding to the description string @name.
*
* Returns: an #AtkStateType corresponding to @name
*/
AtkStateType
atk_state_type_for_name (const gchar *name)
{
GTypeClass *type_class;
GEnumValue *value;
AtkStateType type = ATK_STATE_INVALID;
g_return_val_if_fail (name, ATK_STATE_INVALID);
type_class = g_type_class_ref (ATK_TYPE_STATE_TYPE);
g_return_val_if_fail (G_IS_ENUM_CLASS (type_class), ATK_STATE_INVALID);
value = g_enum_get_value_by_nick (G_ENUM_CLASS (type_class), name);
if (value)
{
type = value->value;
}
else
{
gint i;
for (i = ATK_STATE_LAST_DEFINED + 1; i <= last_type; i++)
{
if (state_names[i] == NULL)
continue;
if (!strcmp(name, state_names[i]))
{
type = i;
break;
}
}
}
return type;
}

43
atk/atkstate.h Normal file
View File

@@ -0,0 +1,43 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_STATE_H__
#define __ATK_STATE_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <atk/atktypes.h>
G_BEGIN_DECLS
typedef guint64 AtkState;
GDK_AVAILABLE_IN_ALL
AtkStateType atk_state_type_register (const gchar *name);
GDK_AVAILABLE_IN_ALL
const gchar* atk_state_type_get_name (AtkStateType type);
GDK_AVAILABLE_IN_ALL
AtkStateType atk_state_type_for_name (const gchar *name);
G_END_DECLS
#endif /* __ATK_STATE_H__ */

384
atk/atkstateset.c Normal file
View File

@@ -0,0 +1,384 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <glib-object.h>
#include "atkobject.h"
#include "atkstateset.h"
/**
* SECTION:atkstateset
* @Short_description: An AtkStateSet contains the states of an object.
* @Title:AtkStateSet
*
* An AtkStateSet is a read-only representation of the full set of #AtkStates
* that apply to an object at a given time. This set is not meant to be
* modified, but rather created when #atk_object_ref_state_set() is called.
*/
#define ATK_STATE(state_enum) ((AtkState)((guint64)1 << ((state_enum)%64)))
struct _AtkRealStateSet
{
GObject parent;
AtkState state;
};
typedef struct _AtkRealStateSet AtkRealStateSet;
static void atk_state_set_class_init (AtkStateSetClass *klass);
GType
atk_state_set_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo typeInfo =
{
sizeof (AtkStateSetClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) atk_state_set_class_init,
(GClassFinalizeFunc) NULL,
NULL,
sizeof (AtkRealStateSet),
0,
(GInstanceInitFunc) NULL,
} ;
type = g_type_register_static (G_TYPE_OBJECT, "AtkStateSet", &typeInfo, 0) ;
}
return type;
}
static void
atk_state_set_class_init (AtkStateSetClass *klass)
{
}
/**
* atk_state_set_new:
*
* Creates a new empty state set.
*
* Returns: a new #AtkStateSet
**/
AtkStateSet*
atk_state_set_new (void)
{
return (AtkStateSet*) g_object_new (ATK_TYPE_STATE_SET, NULL);
}
/**
* atk_state_set_is_empty:
* @set: an #AtkStateType
*
* Checks whether the state set is empty, i.e. has no states set.
*
* Returns: %TRUE if @set has no states set, otherwise %FALSE
**/
gboolean
atk_state_set_is_empty (AtkStateSet *set)
{
AtkRealStateSet *real_set;
g_return_val_if_fail (ATK_IS_STATE_SET (set), FALSE);
real_set = (AtkRealStateSet *)set;
if (real_set->state)
return FALSE;
else
return TRUE;
}
/**
* atk_state_set_add_state:
* @set: an #AtkStateSet
* @type: an #AtkStateType
*
* Adds the state of the specified type to the state set if it is not already
* present.
*
* Note that because an #AtkStateSet is a read-only object, this method should
* be used to add a state to a newly-created set which will then be returned by
* #atk_object_ref_state_set. It should not be used to modify the existing state
* of an object. See also #atk_object_notify_state_change.
*
* Returns: %TRUE if the state for @type is not already in @set.
**/
gboolean
atk_state_set_add_state (AtkStateSet *set,
AtkStateType type)
{
AtkRealStateSet *real_set;
g_return_val_if_fail (ATK_IS_STATE_SET (set), FALSE);
real_set = (AtkRealStateSet *)set;
if (real_set->state & ATK_STATE (type))
return FALSE;
else
{
real_set->state |= ATK_STATE (type);
return TRUE;
}
}
/**
* atk_state_set_add_states:
* @set: an #AtkStateSet
* @types: (array length=n_types): an array of #AtkStateType
* @n_types: The number of elements in the array
*
* Adds the states of the specified types to the state set.
*
* Note that because an #AtkStateSet is a read-only object, this method should
* be used to add states to a newly-created set which will then be returned by
* #atk_object_ref_state_set. It should not be used to modify the existing state
* of an object. See also #atk_object_notify_state_change.
**/
void
atk_state_set_add_states (AtkStateSet *set,
AtkStateType *types,
gint n_types)
{
AtkRealStateSet *real_set;
gint i;
g_return_if_fail (ATK_IS_STATE_SET (set));
real_set = (AtkRealStateSet *)set;
for (i = 0; i < n_types; i++)
{
real_set->state |= ATK_STATE (types[i]);
}
}
/**
* atk_state_set_clear_states:
* @set: an #AtkStateSet
*
* Removes all states from the state set.
**/
void
atk_state_set_clear_states (AtkStateSet *set)
{
AtkRealStateSet *real_set;
g_return_if_fail (ATK_IS_STATE_SET (set));
real_set = (AtkRealStateSet *)set;
real_set->state = 0;
}
/**
* atk_state_set_contains_state:
* @set: an #AtkStateSet
* @type: an #AtkStateType
*
* Checks whether the state for the specified type is in the specified set.
*
* Returns: %TRUE if @type is the state type is in @set.
**/
gboolean
atk_state_set_contains_state (AtkStateSet *set,
AtkStateType type)
{
AtkRealStateSet *real_set;
g_return_val_if_fail (ATK_IS_STATE_SET (set), FALSE);
real_set = (AtkRealStateSet *)set;
if (real_set->state & ATK_STATE (type))
return TRUE;
else
return FALSE;
}
/**
* atk_state_set_contains_states:
* @set: an #AtkStateSet
* @types: (array length=n_types): an array of #AtkStateType
* @n_types: The number of elements in the array
*
* Checks whether the states for all the specified types are in the
* specified set.
*
* Returns: %TRUE if all the states for @type are in @set.
**/
gboolean
atk_state_set_contains_states (AtkStateSet *set,
AtkStateType *types,
gint n_types)
{
AtkRealStateSet *real_set;
gint i;
g_return_val_if_fail (ATK_IS_STATE_SET (set), FALSE);
real_set = (AtkRealStateSet *)set;
for (i = 0; i < n_types; i++)
{
if (!(real_set->state & ATK_STATE (types[i])))
return FALSE;
}
return TRUE;
}
/**
* atk_state_set_remove_state:
* @set: an #AtkStateSet
* @type: an #AtkType
*
* Removes the state for the specified type from the state set.
*
* Note that because an #AtkStateSet is a read-only object, this method should
* be used to remove a state to a newly-created set which will then be returned
* by #atk_object_ref_state_set. It should not be used to modify the existing
* state of an object. See also #atk_object_notify_state_change.
*
* Returns: %TRUE if @type was the state type is in @set.
**/
gboolean
atk_state_set_remove_state (AtkStateSet *set,
AtkStateType type)
{
AtkRealStateSet *real_set;
g_return_val_if_fail (ATK_IS_STATE_SET (set), FALSE);
real_set = (AtkRealStateSet *)set;
if (real_set->state & ATK_STATE (type))
{
real_set->state ^= ATK_STATE (type);
return TRUE;
}
else
return FALSE;
}
/**
* atk_state_set_and_sets:
* @set: an #AtkStateSet
* @compare_set: another #AtkStateSet
*
* Constructs the intersection of the two sets, returning %NULL if the
* intersection is empty.
*
* Returns: (transfer full): a new #AtkStateSet which is the intersection of
* the two sets.
**/
AtkStateSet*
atk_state_set_and_sets (AtkStateSet *set,
AtkStateSet *compare_set)
{
AtkRealStateSet *real_set, *real_compare_set;
AtkStateSet *return_set = NULL;
AtkState state;
g_return_val_if_fail (ATK_IS_STATE_SET (set), NULL);
g_return_val_if_fail (ATK_IS_STATE_SET (compare_set), NULL);
real_set = (AtkRealStateSet *)set;
real_compare_set = (AtkRealStateSet *)compare_set;
state = real_set->state & real_compare_set->state;
if (state)
{
return_set = atk_state_set_new();
((AtkRealStateSet *) return_set)->state = state;
}
return return_set;
}
/**
* atk_state_set_or_sets:
* @set: an #AtkStateSet
* @compare_set: another #AtkStateSet
*
* Constructs the union of the two sets.
*
* Returns: (nullable) (transfer full): a new #AtkStateSet which is
* the union of the two sets, returning %NULL is empty.
**/
AtkStateSet*
atk_state_set_or_sets (AtkStateSet *set,
AtkStateSet *compare_set)
{
AtkRealStateSet *real_set, *real_compare_set;
AtkStateSet *return_set = NULL;
AtkState state;
g_return_val_if_fail (ATK_IS_STATE_SET (set), NULL);
g_return_val_if_fail (ATK_IS_STATE_SET (compare_set), NULL);
real_set = (AtkRealStateSet *)set;
real_compare_set = (AtkRealStateSet *)compare_set;
state = real_set->state | real_compare_set->state;
if (state)
{
return_set = atk_state_set_new();
((AtkRealStateSet *) return_set)->state = state;
}
return return_set;
}
/**
* atk_state_set_xor_sets:
* @set: an #AtkStateSet
* @compare_set: another #AtkStateSet
*
* Constructs the exclusive-or of the two sets, returning %NULL is empty.
* The set returned by this operation contains the states in exactly
* one of the two sets.
*
* Returns: (transfer full): a new #AtkStateSet which contains the states
* which are in exactly one of the two sets.
**/
AtkStateSet*
atk_state_set_xor_sets (AtkStateSet *set,
AtkStateSet *compare_set)
{
AtkRealStateSet *real_set, *real_compare_set;
AtkStateSet *return_set = NULL;
AtkState state, state1, state2;
g_return_val_if_fail (ATK_IS_STATE_SET (set), NULL);
g_return_val_if_fail (ATK_IS_STATE_SET (compare_set), NULL);
real_set = (AtkRealStateSet *)set;
real_compare_set = (AtkRealStateSet *)compare_set;
state1 = real_set->state & (~real_compare_set->state);
state2 = (~real_set->state) & real_compare_set->state;
state = state1 | state2;
if (state)
{
return_set = atk_state_set_new();
((AtkRealStateSet *) return_set)->state = state;
}
return return_set;
}

92
atk/atkstateset.h Normal file
View File

@@ -0,0 +1,92 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_STATE_SET_H__
#define __ATK_STATE_SET_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <glib-object.h>
#include <atk/atkobject.h>
#include <atk/atkstate.h>
G_BEGIN_DECLS
#define ATK_TYPE_STATE_SET (atk_state_set_get_type ())
#define ATK_STATE_SET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_STATE_SET, AtkStateSet))
#define ATK_STATE_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_STATE_SET, AtkStateSetClass))
#define ATK_IS_STATE_SET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_STATE_SET))
#define ATK_IS_STATE_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_STATE_SET))
#define ATK_STATE_SET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_STATE_SET, AtkStateSetClass))
typedef struct _AtkStateSetClass AtkStateSetClass;
struct _AtkStateSet
{
GObject parent;
};
struct _AtkStateSetClass
{
GObjectClass parent;
};
GDK_AVAILABLE_IN_ALL
GType atk_state_set_get_type (void);
GDK_AVAILABLE_IN_ALL
AtkStateSet* atk_state_set_new (void);
GDK_AVAILABLE_IN_ALL
gboolean atk_state_set_is_empty (AtkStateSet *set);
GDK_AVAILABLE_IN_ALL
gboolean atk_state_set_add_state (AtkStateSet *set,
AtkStateType type);
GDK_AVAILABLE_IN_ALL
void atk_state_set_add_states (AtkStateSet *set,
AtkStateType *types,
gint n_types);
GDK_AVAILABLE_IN_ALL
void atk_state_set_clear_states (AtkStateSet *set);
GDK_AVAILABLE_IN_ALL
gboolean atk_state_set_contains_state (AtkStateSet *set,
AtkStateType type);
GDK_AVAILABLE_IN_ALL
gboolean atk_state_set_contains_states (AtkStateSet *set,
AtkStateType *types,
gint n_types);
GDK_AVAILABLE_IN_ALL
gboolean atk_state_set_remove_state (AtkStateSet *set,
AtkStateType type);
GDK_AVAILABLE_IN_ALL
AtkStateSet* atk_state_set_and_sets (AtkStateSet *set,
AtkStateSet *compare_set);
GDK_AVAILABLE_IN_ALL
AtkStateSet* atk_state_set_or_sets (AtkStateSet *set,
AtkStateSet *compare_set);
GDK_AVAILABLE_IN_ALL
AtkStateSet* atk_state_set_xor_sets (AtkStateSet *set,
AtkStateSet *compare_set);
G_END_DECLS
#endif /* __ATK_STATE_SET_H__ */

181
atk/atkstreamablecontent.c Normal file
View File

@@ -0,0 +1,181 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "atkstreamablecontent.h"
/**
* SECTION:atkstreamablecontent
* @Short_description: The ATK interface which provides access to
* streamable content.
* @Title:AtkStreamableContent
*
* An interface whereby an object allows its backing content to be
* streamed to clients. Typical implementors would be images or
* icons, HTML content, or multimedia display/rendering widgets.
*
* Negotiation of content type is allowed. Clients may examine the
* backing data and transform, convert, or parse the content in order
* to present it in an alternate form to end-users.
*
* The AtkStreamableContent interface is particularly useful for
* saving, printing, or post-processing entire documents, or for
* persisting alternate views of a document. If document content
* itself is being serialized, stored, or converted, then use of the
* AtkStreamableContent interface can help address performance
* issues. Unlike most ATK interfaces, this interface is not strongly
* tied to the current user-agent view of the a particular document,
* but may in some cases give access to the underlying model data.
*/
GType
atk_streamable_content_get_type (void)
{
static GType type = 0;
if (!type) {
GTypeInfo tinfo =
{
sizeof (AtkStreamableContentIface),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
};
type = g_type_register_static (G_TYPE_INTERFACE, "AtkStreamableContent", &tinfo, 0);
}
return type;
}
/**
* atk_streamable_content_get_n_mime_types:
* @streamable: a GObject instance that implements AtkStreamableContentIface
*
* Gets the number of mime types supported by this object.
*
* Returns: a gint which is the number of mime types supported by the object.
**/
gint
atk_streamable_content_get_n_mime_types (AtkStreamableContent *streamable)
{
AtkStreamableContentIface *iface;
g_return_val_if_fail (ATK_IS_STREAMABLE_CONTENT (streamable), 0);
iface = ATK_STREAMABLE_CONTENT_GET_IFACE (streamable);
if (iface->get_n_mime_types)
return (iface->get_n_mime_types) (streamable);
else
return 0;
}
/**
* atk_streamable_content_get_mime_type:
* @streamable: a GObject instance that implements AtkStreamableContent
* @i: a gint representing the position of the mime type starting from 0
*
* Gets the character string of the specified mime type. The first mime
* type is at position 0, the second at position 1, and so on.
*
* Returns: a gchar* representing the specified mime type; the caller
* should not free the character string.
**/
const gchar*
atk_streamable_content_get_mime_type (AtkStreamableContent *streamable,
gint i)
{
AtkStreamableContentIface *iface;
g_return_val_if_fail (i >= 0, NULL);
g_return_val_if_fail (ATK_IS_STREAMABLE_CONTENT (streamable), NULL);
iface = ATK_STREAMABLE_CONTENT_GET_IFACE (streamable);
if (iface->get_mime_type)
return (iface->get_mime_type) (streamable, i);
else
return NULL;
}
/**
* atk_streamable_content_get_stream:
* @streamable: a GObject instance that implements AtkStreamableContentIface
* @mime_type: a gchar* representing the mime type
*
* Gets the content in the specified mime type.
*
* Returns: (transfer full): A #GIOChannel which contains the content in the
* specified mime type.
**/
GIOChannel*
atk_streamable_content_get_stream (AtkStreamableContent *streamable,
const gchar *mime_type)
{
AtkStreamableContentIface *iface;
g_return_val_if_fail (mime_type != NULL, NULL);
g_return_val_if_fail (ATK_IS_STREAMABLE_CONTENT (streamable), NULL);
iface = ATK_STREAMABLE_CONTENT_GET_IFACE (streamable);
if (iface->get_stream)
return (iface->get_stream) (streamable, mime_type);
else
return NULL;
}
/**
* atk_streamable_content_get_uri:
* @streamable: a GObject instance that implements AtkStreamableContentIface
* @mime_type: a gchar* representing the mime type, or NULL to request a URI
* for the default mime type.
*
* Get a string representing a URI in IETF standard format
* (see http://www.ietf.org/rfc/rfc2396.txt) from which the object's content
* may be streamed in the specified mime-type, if one is available.
* If mime_type is NULL, the URI for the default (and possibly only) mime-type is
* returned.
*
* Note that it is possible for get_uri to return NULL but for
* get_stream to work nonetheless, since not all GIOChannels connect to URIs.
*
* Returns: (nullable): Returns a string representing a URI, or %NULL
* if no corresponding URI can be constructed.
*
* Since: 1.12
**/
const gchar*
atk_streamable_content_get_uri (AtkStreamableContent *streamable,
const gchar *mime_type)
{
AtkStreamableContentIface *iface;
g_return_val_if_fail (mime_type != NULL, NULL);
g_return_val_if_fail (ATK_IS_STREAMABLE_CONTENT (streamable), NULL);
iface = ATK_STREAMABLE_CONTENT_GET_IFACE (streamable);
if (iface->get_uri)
return (iface->get_uri) (streamable, mime_type);
else
return NULL;
}

110
atk/atkstreamablecontent.h Normal file
View File

@@ -0,0 +1,110 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_STREAMABLE_CONTENT_H__
#define __ATK_STREAMABLE_CONTENT_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <atk/atkobject.h>
G_BEGIN_DECLS
#define ATK_TYPE_STREAMABLE_CONTENT (atk_streamable_content_get_type ())
#define ATK_IS_STREAMABLE_CONTENT(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_STREAMABLE_CONTENT)
#define ATK_STREAMABLE_CONTENT(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_STREAMABLE_CONTENT, AtkStreamableContent)
#define ATK_STREAMABLE_CONTENT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_STREAMABLE_CONTENT, AtkStreamableContentIface))
#ifndef _TYPEDEF_ATK_STREAMABLE_CONTENT
#define _TYPEDEF_ATK_STREAMABLE_CONTENT
typedef struct _AtkStreamableContent AtkStreamableContent;
#endif
typedef struct _AtkStreamableContentIface AtkStreamableContentIface;
struct _AtkStreamableContentIface
{
GTypeInterface parent;
/*
* Get the number of mime types supported by this object
*/
gint (* get_n_mime_types) (AtkStreamableContent *streamable);
/*
* Gets the specified mime type supported by this object.
* The mime types are 0-based so the first mime type is
* at index 0, the second at index 1 and so on. The mime-type
* at index 0 should be considered the "default" data type for the stream.
*
* This assumes that the strings for the mime types are stored in the
* AtkStreamableContent. Alternatively the const could be removed
* and the caller would be responsible for calling g_free() on the
* returned value.
*/
const gchar* (* get_mime_type) (AtkStreamableContent *streamable,
gint i);
/*
* One possible implementation for this method is that it constructs the
* content appropriate for the mime type and then creates a temporary
* file containing the content, opens the file and then calls
* g_io_channel_unix_new_fd().
*/
GIOChannel* (* get_stream) (AtkStreamableContent *streamable,
const gchar *mime_type);
/*
* Returns a string representing a URI in IETF standard format
* (see http://www.ietf.org/rfc/rfc2396.txt) from which the object's content
* may be streamed in the specified mime-type.
* If mime_type is NULL, the URI for the default (and possibly only) mime-type is
* returned.
*
* returns NULL if the mime-type is not supported, or if no URI can be
* constructed. Note that it is possible for get_uri to return NULL but for
* get_stream to work nonetheless, since not all GIOChannels connect to URIs.
*/
const gchar* (* get_uri) (AtkStreamableContent *streamable,
const gchar *mime_type);
AtkFunction pad1;
AtkFunction pad2;
AtkFunction pad3;
};
GDK_AVAILABLE_IN_ALL
GType atk_streamable_content_get_type (void);
GDK_AVAILABLE_IN_ALL
gint atk_streamable_content_get_n_mime_types (AtkStreamableContent *streamable);
GDK_AVAILABLE_IN_ALL
const gchar* atk_streamable_content_get_mime_type (AtkStreamableContent *streamable,
gint i);
GDK_AVAILABLE_IN_ALL
GIOChannel* atk_streamable_content_get_stream (AtkStreamableContent *streamable,
const gchar *mime_type);
GDK_AVAILABLE_IN_ALL
const gchar* atk_streamable_content_get_uri (AtkStreamableContent *streamable,
const gchar *mime_type);
G_END_DECLS
#endif /* __ATK_STREAMABLE_CONTENT_H__ */

892
atk/atktable.c Normal file
View File

@@ -0,0 +1,892 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "atktable.h"
#include "atkmarshal.h"
/**
* SECTION:atktable
* @Short_description: The ATK interface implemented for UI components
* which contain tabular or row/column information.
* @Title:AtkTable
*
* #AtkTable should be implemented by components which present
* elements ordered via rows and columns. It may also be used to
* present tree-structured information if the nodes of the trees can
* be said to contain multiple "columns". Individual elements of an
* #AtkTable are typically referred to as "cells". Those cells should
* implement the interface #AtkTableCell, but #Atk doesn't require
* them to be direct children of the current #AtkTable. They can be
* grand-children, grand-grand-children etc. #AtkTable provides the
* API needed to get a individual cell based on the row and column
* numbers.
*
* Children of #AtkTable are frequently "lightweight" objects, that
* is, they may not have backing widgets in the host UI toolkit. They
* are therefore often transient.
*
* Since tables are often very complex, #AtkTable includes provision
* for offering simplified summary information, as well as row and
* column headers and captions. Headers and captions are #AtkObjects
* which may implement other interfaces (#AtkText, #AtkImage, etc.) as
* appropriate. #AtkTable summaries may themselves be (simplified)
* #AtkTables, etc.
*
* Note for implementors: in the past, #AtkTable required that all the
* cells should be direct children of #AtkTable, and provided some
* index based methods to request the cells. The practice showed that
* that forcing made #AtkTable implementation complex, and hard to
* expose other kind of children, like rows or captions. Right now,
* index-based methods are deprecated.
*/
enum {
ROW_INSERTED,
ROW_DELETED,
COLUMN_INSERTED,
COLUMN_DELETED,
ROW_REORDERED,
COLUMN_REORDERED,
MODEL_CHANGED,
LAST_SIGNAL
};
static void atk_table_base_init (gpointer *g_class);
static guint atk_table_signals[LAST_SIGNAL] = { 0 };
GType
atk_table_get_type (void)
{
static GType type = 0;
if (!type) {
GTypeInfo tinfo =
{
sizeof (AtkTableIface),
(GBaseInitFunc) atk_table_base_init,
(GBaseFinalizeFunc) NULL,
};
type = g_type_register_static (G_TYPE_INTERFACE, "AtkTable", &tinfo, 0);
}
return type;
}
static void
atk_table_base_init (gpointer *g_class)
{
static gboolean initialized = FALSE;
if (!initialized)
{
/**
* AtkTable::row-inserted:
* @atktable: the object which received the signal.
* @arg1: The index of the first row inserted.
* @arg2: The number of rows inserted.
*
* The "row-inserted" signal is emitted by an object which
* implements the AtkTable interface when a row is inserted.
*/
atk_table_signals[ROW_INSERTED] =
g_signal_new ("row_inserted",
ATK_TYPE_TABLE,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (AtkTableIface, row_inserted),
(GSignalAccumulator) NULL, NULL,
atk_marshal_VOID__INT_INT,
G_TYPE_NONE,
2, G_TYPE_INT, G_TYPE_INT);
/**
* AtkTable::column-inserted:
* @atktable: the object which received the signal.
* @arg1: The index of the column inserted.
* @arg2: The number of colums inserted.
*
* The "column-inserted" signal is emitted by an object which
* implements the AtkTable interface when a column is inserted.
*/
atk_table_signals[COLUMN_INSERTED] =
g_signal_new ("column_inserted",
ATK_TYPE_TABLE,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (AtkTableIface, column_inserted),
(GSignalAccumulator) NULL, NULL,
atk_marshal_VOID__INT_INT,
G_TYPE_NONE,
2, G_TYPE_INT, G_TYPE_INT);
/**
* AtkTable::row-deleted:
* @atktable: the object which received the signal.
* @arg1: The index of the first row deleted.
* @arg2: The number of rows deleted.
*
* The "row-deleted" signal is emitted by an object which
* implements the AtkTable interface when a row is deleted.
*/
atk_table_signals[ROW_DELETED] =
g_signal_new ("row_deleted",
ATK_TYPE_TABLE,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (AtkTableIface, row_deleted),
(GSignalAccumulator) NULL, NULL,
atk_marshal_VOID__INT_INT,
G_TYPE_NONE,
2, G_TYPE_INT, G_TYPE_INT);
/**
* AtkTable::column-deleted:
* @atktable: the object which received the signal.
* @arg1: The index of the first column deleted.
* @arg2: The number of columns deleted.
*
* The "column-deleted" signal is emitted by an object which
* implements the AtkTable interface when a column is deleted.
*/
atk_table_signals[COLUMN_DELETED] =
g_signal_new ("column_deleted",
ATK_TYPE_TABLE,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (AtkTableIface, column_deleted),
(GSignalAccumulator) NULL, NULL,
atk_marshal_VOID__INT_INT,
G_TYPE_NONE,
2, G_TYPE_INT, G_TYPE_INT);
/**
* AtkTable::row-reordered:
* @atktable: the object which received the signal.
*
* The "row-reordered" signal is emitted by an object which
* implements the AtkTable interface when the rows are
* reordered.
*/
atk_table_signals[ROW_REORDERED] =
g_signal_new ("row_reordered",
ATK_TYPE_TABLE,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (AtkTableIface, row_reordered),
(GSignalAccumulator) NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
/**
* AtkTable::column-reordered:
* @atktable: the object which received the signal.
*
* The "column-reordered" signal is emitted by an object which
* implements the AtkTable interface when the columns are
* reordered.
*/
atk_table_signals[COLUMN_REORDERED] =
g_signal_new ("column_reordered",
ATK_TYPE_TABLE,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (AtkTableIface, column_reordered),
(GSignalAccumulator) NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
/**
* AtkTable::model-changed:
* @atktable: the object which received the signal.
*
* The "model-changed" signal is emitted by an object which
* implements the AtkTable interface when the model displayed by
* the table changes.
*/
atk_table_signals[MODEL_CHANGED] =
g_signal_new ("model_changed",
ATK_TYPE_TABLE,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (AtkTableIface, model_changed),
(GSignalAccumulator) NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
initialized = TRUE;
}
}
/**
* atk_table_ref_at:
* @table: a GObject instance that implements AtkTableIface
* @row: a #gint representing a row in @table
* @column: a #gint representing a column in @table
*
* Get a reference to the table cell at @row, @column. This cell
* should implement the interface #AtkTableCell
*
* Returns: (transfer full): an #AtkObject representing the referred
* to accessible
**/
AtkObject*
atk_table_ref_at (AtkTable *table,
gint row,
gint column)
{
AtkTableIface *iface;
g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
g_return_val_if_fail (row >= 0, NULL);
g_return_val_if_fail (column >= 0, NULL);
iface = ATK_TABLE_GET_IFACE (table);
if (iface->ref_at)
return (iface->ref_at) (table, row, column);
else
return NULL;
}
/**
* atk_table_get_caption:
* @table: a GObject instance that implements AtkTableInterface
*
* Gets the caption for the @table.
*
* Returns: (nullable) (transfer none): a AtkObject* representing the
* table caption, or %NULL if value does not implement this interface.
**/
AtkObject*
atk_table_get_caption (AtkTable *table)
{
AtkTableIface *iface;
g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
iface = ATK_TABLE_GET_IFACE (table);
if (iface->get_caption)
return (iface->get_caption) (table);
else
return NULL;
}
/**
* atk_table_get_n_columns:
* @table: a GObject instance that implements AtkTableIface
*
* Gets the number of columns in the table.
*
* Returns: a gint representing the number of columns, or 0
* if value does not implement this interface.
**/
gint
atk_table_get_n_columns (AtkTable *table)
{
AtkTableIface *iface;
g_return_val_if_fail (ATK_IS_TABLE (table), 0);
iface = ATK_TABLE_GET_IFACE (table);
if (iface->get_n_columns)
return (iface->get_n_columns) (table);
else
return 0;
}
/**
* atk_table_get_column_description:
* @table: a GObject instance that implements AtkTableIface
* @column: a #gint representing a column in @table
*
* Gets the description text of the specified @column in the table
*
* Returns: a gchar* representing the column description, or %NULL
* if value does not implement this interface.
**/
const gchar*
atk_table_get_column_description (AtkTable *table,
gint column)
{
AtkTableIface *iface;
g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
iface = ATK_TABLE_GET_IFACE (table);
if (iface->get_column_description)
return (iface->get_column_description) (table, column);
else
return NULL;
}
/**
* atk_table_get_column_extent_at:
* @table: a GObject instance that implements AtkTableIface
* @row: a #gint representing a row in @table
* @column: a #gint representing a column in @table
*
* Gets the number of columns occupied by the accessible object
* at the specified @row and @column in the @table.
*
* Returns: a gint representing the column extent at specified position, or 0
* if value does not implement this interface.
**/
gint
atk_table_get_column_extent_at (AtkTable *table,
gint row,
gint column)
{
AtkTableIface *iface;
g_return_val_if_fail (ATK_IS_TABLE (table), 0);
iface = ATK_TABLE_GET_IFACE (table);
if (iface->get_column_extent_at)
return (iface->get_column_extent_at) (table, row, column);
else
return 0;
}
/**
* atk_table_get_column_header:
* @table: a GObject instance that implements AtkTableIface
* @column: a #gint representing a column in the table
*
* Gets the column header of a specified column in an accessible table.
*
* Returns: (nullable) (transfer none): a AtkObject* representing the
* specified column header, or %NULL if value does not implement this
* interface.
**/
AtkObject*
atk_table_get_column_header (AtkTable *table, gint column)
{
AtkTableIface *iface;
g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
iface = ATK_TABLE_GET_IFACE (table);
if (iface->get_column_header)
return (iface->get_column_header) (table, column);
else
return NULL;
}
/**
* atk_table_get_n_rows:
* @table: a GObject instance that implements AtkTableIface
*
* Gets the number of rows in the table.
*
* Returns: a gint representing the number of rows, or 0
* if value does not implement this interface.
**/
gint
atk_table_get_n_rows (AtkTable *table)
{
AtkTableIface *iface;
g_return_val_if_fail (ATK_IS_TABLE (table), 0);
iface = ATK_TABLE_GET_IFACE (table);
if (iface->get_n_rows)
return (iface->get_n_rows) (table);
else
return 0;
}
/**
* atk_table_get_row_description:
* @table: a GObject instance that implements AtkTableIface
* @row: a #gint representing a row in @table
*
* Gets the description text of the specified row in the table
*
* Returns: (nullable): a gchar* representing the row description, or
* %NULL if value does not implement this interface.
**/
const gchar*
atk_table_get_row_description (AtkTable *table,
gint row)
{
AtkTableIface *iface;
g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
iface = ATK_TABLE_GET_IFACE (table);
if (iface->get_row_description)
return (iface->get_row_description) (table, row);
else
return NULL;
}
/**
* atk_table_get_row_extent_at:
* @table: a GObject instance that implements AtkTableIface
* @row: a #gint representing a row in @table
* @column: a #gint representing a column in @table
*
* Gets the number of rows occupied by the accessible object
* at a specified @row and @column in the @table.
*
* Returns: a gint representing the row extent at specified position, or 0
* if value does not implement this interface.
**/
gint
atk_table_get_row_extent_at (AtkTable *table,
gint row,
gint column)
{
AtkTableIface *iface;
g_return_val_if_fail (ATK_IS_TABLE (table), 0);
iface = ATK_TABLE_GET_IFACE (table);
if (iface->get_row_extent_at)
return (iface->get_row_extent_at) (table, row, column);
else
return 0;
}
/**
* atk_table_get_row_header:
* @table: a GObject instance that implements AtkTableIface
* @row: a #gint representing a row in the table
*
* Gets the row header of a specified row in an accessible table.
*
* Returns: (nullable) (transfer none): a AtkObject* representing the
* specified row header, or %NULL if value does not implement this
* interface.
**/
AtkObject*
atk_table_get_row_header (AtkTable *table, gint row)
{
AtkTableIface *iface;
g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
iface = ATK_TABLE_GET_IFACE (table);
if (iface->get_row_header)
return (iface->get_row_header) (table, row);
else
return NULL;
}
/**
* atk_table_get_summary:
* @table: a GObject instance that implements AtkTableIface
*
* Gets the summary description of the table.
*
* Returns: (transfer full): a AtkObject* representing a summary description
* of the table, or zero if value does not implement this interface.
**/
AtkObject*
atk_table_get_summary (AtkTable *table)
{
AtkTableIface *iface;
g_return_val_if_fail (ATK_IS_TABLE (table), NULL);
iface = ATK_TABLE_GET_IFACE (table);
if (iface->get_summary)
return (iface->get_summary) (table);
else
return NULL;
}
/**
* atk_table_get_selected_rows:
* @table: a GObject instance that implements AtkTableIface
* @selected: a #gint** that is to contain the selected row numbers
*
* Gets the selected rows of the table by initializing **selected with
* the selected row numbers. This array should be freed by the caller.
*
* Returns: a gint representing the number of selected rows,
* or zero if value does not implement this interface.
**/
gint
atk_table_get_selected_rows (AtkTable *table, gint **selected)
{
AtkTableIface *iface;
g_return_val_if_fail (ATK_IS_TABLE (table), 0);
iface = ATK_TABLE_GET_IFACE (table);
if (iface->get_selected_rows)
return (iface->get_selected_rows) (table, selected);
else
return 0;
}
/**
* atk_table_get_selected_columns:
* @table: a GObject instance that implements AtkTableIface
* @selected: a #gint** that is to contain the selected columns numbers
*
* Gets the selected columns of the table by initializing **selected with
* the selected column numbers. This array should be freed by the caller.
*
* Returns: a gint representing the number of selected columns,
* or %0 if value does not implement this interface.
**/
gint
atk_table_get_selected_columns (AtkTable *table, gint **selected)
{
AtkTableIface *iface;
g_return_val_if_fail (ATK_IS_TABLE (table), 0);
iface = ATK_TABLE_GET_IFACE (table);
if (iface->get_selected_columns)
return (iface->get_selected_columns) (table, selected);
else
return 0;
}
/**
* atk_table_is_column_selected:
* @table: a GObject instance that implements AtkTableIface
* @column: a #gint representing a column in @table
*
* Gets a boolean value indicating whether the specified @column
* is selected
*
* Returns: a gboolean representing if the column is selected, or 0
* if value does not implement this interface.
**/
gboolean
atk_table_is_column_selected (AtkTable *table,
gint column)
{
AtkTableIface *iface;
g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
iface = ATK_TABLE_GET_IFACE (table);
if (iface->is_column_selected)
return (iface->is_column_selected) (table, column);
else
return FALSE;
}
/**
* atk_table_is_row_selected:
* @table: a GObject instance that implements AtkTableIface
* @row: a #gint representing a row in @table
*
* Gets a boolean value indicating whether the specified @row
* is selected
*
* Returns: a gboolean representing if the row is selected, or 0
* if value does not implement this interface.
**/
gboolean
atk_table_is_row_selected (AtkTable *table,
gint row)
{
AtkTableIface *iface;
g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
iface = ATK_TABLE_GET_IFACE (table);
if (iface->is_row_selected)
return (iface->is_row_selected) (table, row);
else
return FALSE;
}
/**
* atk_table_is_selected:
* @table: a GObject instance that implements AtkTableIface
* @row: a #gint representing a row in @table
* @column: a #gint representing a column in @table
*
* Gets a boolean value indicating whether the accessible object
* at the specified @row and @column is selected
*
* Returns: a gboolean representing if the cell is selected, or 0
* if value does not implement this interface.
**/
gboolean
atk_table_is_selected (AtkTable *table,
gint row,
gint column)
{
AtkTableIface *iface;
g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
iface = ATK_TABLE_GET_IFACE (table);
if (iface->is_selected)
return (iface->is_selected) (table, row, column);
else
return FALSE;
}
/**
* atk_table_add_row_selection:
* @table: a GObject instance that implements AtkTableIface
* @row: a #gint representing a row in @table
*
* Adds the specified @row to the selection.
*
* Returns: a gboolean representing if row was successfully added to selection,
* or 0 if value does not implement this interface.
**/
gboolean
atk_table_add_row_selection (AtkTable *table,
gint row)
{
AtkTableIface *iface;
g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
iface = ATK_TABLE_GET_IFACE (table);
if (iface->add_row_selection)
return (iface->add_row_selection) (table, row);
else
return FALSE;
}
/**
* atk_table_remove_row_selection:
* @table: a GObject instance that implements AtkTableIface
* @row: a #gint representing a row in @table
*
* Removes the specified @row from the selection.
*
* Returns: a gboolean representing if the row was successfully removed from
* the selection, or 0 if value does not implement this interface.
**/
gboolean
atk_table_remove_row_selection (AtkTable *table,
gint row)
{
AtkTableIface *iface;
g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
iface = ATK_TABLE_GET_IFACE (table);
if (iface->remove_row_selection)
return (iface->remove_row_selection) (table, row);
else
return FALSE;
}
/**
* atk_table_add_column_selection:
* @table: a GObject instance that implements AtkTableIface
* @column: a #gint representing a column in @table
*
* Adds the specified @column to the selection.
*
* Returns: a gboolean representing if the column was successfully added to
* the selection, or 0 if value does not implement this interface.
**/
gboolean
atk_table_add_column_selection (AtkTable *table,
gint column)
{
AtkTableIface *iface;
g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
iface = ATK_TABLE_GET_IFACE (table);
if (iface->add_column_selection)
return (iface->add_column_selection) (table, column);
else
return FALSE;
}
/**
* atk_table_remove_column_selection:
* @table: a GObject instance that implements AtkTableIface
* @column: a #gint representing a column in @table
*
* Adds the specified @column to the selection.
*
* Returns: a gboolean representing if the column was successfully removed from
* the selection, or 0 if value does not implement this interface.
**/
gboolean
atk_table_remove_column_selection (AtkTable *table,
gint column)
{
AtkTableIface *iface;
g_return_val_if_fail (ATK_IS_TABLE (table), FALSE);
iface = ATK_TABLE_GET_IFACE (table);
if (iface->remove_column_selection)
return (iface->remove_column_selection) (table, column);
else
return FALSE;
}
/**
* atk_table_set_caption:
* @table: a GObject instance that implements AtkTableIface
* @caption: a #AtkObject representing the caption to set for @table
*
* Sets the caption for the table.
**/
void
atk_table_set_caption (AtkTable *table,
AtkObject *caption)
{
AtkTableIface *iface;
g_return_if_fail (ATK_IS_TABLE (table));
iface = ATK_TABLE_GET_IFACE (table);
if (iface->set_caption)
(iface->set_caption) (table, caption);
}
/**
* atk_table_set_column_description:
* @table: a GObject instance that implements AtkTableIface
* @column: a #gint representing a column in @table
* @description: a #gchar representing the description text
* to set for the specified @column of the @table
*
* Sets the description text for the specified @column of the @table.
**/
void
atk_table_set_column_description (AtkTable *table,
gint column,
const gchar *description)
{
AtkTableIface *iface;
g_return_if_fail (ATK_IS_TABLE (table));
iface = ATK_TABLE_GET_IFACE (table);
if (iface->set_column_description)
(iface->set_column_description) (table, column, description);
}
/**
* atk_table_set_column_header:
* @table: a GObject instance that implements AtkTableIface
* @column: a #gint representing a column in @table
* @header: an #AtkTable
*
* Sets the specified column header to @header.
**/
void
atk_table_set_column_header (AtkTable *table,
gint column,
AtkObject *header)
{
AtkTableIface *iface;
g_return_if_fail (ATK_IS_TABLE (table));
iface = ATK_TABLE_GET_IFACE (table);
if (iface->set_column_header)
(iface->set_column_header) (table, column, header);
}
/**
* atk_table_set_row_description:
* @table: a GObject instance that implements AtkTableIface
* @row: a #gint representing a row in @table
* @description: a #gchar representing the description text
* to set for the specified @row of @table
*
* Sets the description text for the specified @row of @table.
**/
void
atk_table_set_row_description (AtkTable *table,
gint row,
const gchar *description)
{
AtkTableIface *iface;
g_return_if_fail (ATK_IS_TABLE (table));
iface = ATK_TABLE_GET_IFACE (table);
if (iface->set_row_description)
(iface->set_row_description) (table, row, description);
}
/**
* atk_table_set_row_header:
* @table: a GObject instance that implements AtkTableIface
* @row: a #gint representing a row in @table
* @header: an #AtkTable
*
* Sets the specified row header to @header.
**/
void
atk_table_set_row_header (AtkTable *table,
gint row,
AtkObject *header)
{
AtkTableIface *iface;
g_return_if_fail (ATK_IS_TABLE (table));
iface = ATK_TABLE_GET_IFACE (table);
if (iface->set_row_header)
(iface->set_row_header) (table, row, header);
}
/**
* atk_table_set_summary:
* @table: a GObject instance that implements AtkTableIface
* @accessible: an #AtkObject representing the summary description
* to set for @table
*
* Sets the summary description of the table.
**/
void
atk_table_set_summary (AtkTable *table,
AtkObject *accessible)
{
AtkTableIface *iface;
g_return_if_fail (ATK_IS_TABLE (table));
iface = ATK_TABLE_GET_IFACE (table);
if (iface->set_summary)
(iface->set_summary) (table, accessible);
}

223
atk/atktable.h Normal file
View File

@@ -0,0 +1,223 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_TABLE_H__
#define __ATK_TABLE_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <atk/atkobject.h>
G_BEGIN_DECLS
#define ATK_TYPE_TABLE (atk_table_get_type ())
#define ATK_IS_TABLE(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_TABLE)
#define ATK_TABLE(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_TABLE, AtkTable)
#define ATK_TABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_TABLE, AtkTableIface))
#ifndef _TYPEDEF_ATK_TABLE_
#define _TYPEDEF_ATK_TABLE_
typedef struct _AtkTable AtkTable;
#endif
typedef struct _AtkTableIface AtkTableIface;
struct _AtkTableIface
{
GTypeInterface parent;
AtkObject* (* ref_at) (AtkTable *table,
gint row,
gint column);
gint (* get_index_at) (AtkTable *table,
gint row,
gint column);
gint (* get_column_at_index) (AtkTable *table,
gint index_);
gint (* get_row_at_index) (AtkTable *table,
gint index_);
gint (* get_n_columns) (AtkTable *table);
gint (* get_n_rows) (AtkTable *table);
gint (* get_column_extent_at) (AtkTable *table,
gint row,
gint column);
gint (* get_row_extent_at) (AtkTable *table,
gint row,
gint column);
AtkObject*
(* get_caption) (AtkTable *table);
const gchar* (* get_column_description) (AtkTable *table,
gint column);
AtkObject* (* get_column_header) (AtkTable *table,
gint column);
const gchar* (* get_row_description) (AtkTable *table,
gint row);
AtkObject* (* get_row_header) (AtkTable *table,
gint row);
AtkObject* (* get_summary) (AtkTable *table);
void (* set_caption) (AtkTable *table,
AtkObject *caption);
void (* set_column_description) (AtkTable *table,
gint column,
const gchar *description);
void (* set_column_header) (AtkTable *table,
gint column,
AtkObject *header);
void (* set_row_description) (AtkTable *table,
gint row,
const gchar *description);
void (* set_row_header) (AtkTable *table,
gint row,
AtkObject *header);
void (* set_summary) (AtkTable *table,
AtkObject *accessible);
gint (* get_selected_columns) (AtkTable *table,
gint **selected);
gint (* get_selected_rows) (AtkTable *table,
gint **selected);
gboolean (* is_column_selected) (AtkTable *table,
gint column);
gboolean (* is_row_selected) (AtkTable *table,
gint row);
gboolean (* is_selected) (AtkTable *table,
gint row,
gint column);
gboolean (* add_row_selection) (AtkTable *table,
gint row);
gboolean (* remove_row_selection) (AtkTable *table,
gint row);
gboolean (* add_column_selection) (AtkTable *table,
gint column);
gboolean (* remove_column_selection) (AtkTable *table,
gint column);
/*
* signal handlers
*/
void (* row_inserted) (AtkTable *table,
gint row,
gint num_inserted);
void (* column_inserted) (AtkTable *table,
gint column,
gint num_inserted);
void (* row_deleted) (AtkTable *table,
gint row,
gint num_deleted);
void (* column_deleted) (AtkTable *table,
gint column,
gint num_deleted);
void (* row_reordered) (AtkTable *table);
void (* column_reordered) (AtkTable *table);
void (* model_changed) (AtkTable *table);
};
GDK_AVAILABLE_IN_ALL
GType atk_table_get_type (void);
GDK_AVAILABLE_IN_ALL
AtkObject* atk_table_ref_at (AtkTable *table,
gint row,
gint column);
GDK_AVAILABLE_IN_ALL
gint atk_table_get_n_columns (AtkTable *table);
GDK_AVAILABLE_IN_ALL
gint atk_table_get_n_rows (AtkTable *table);
GDK_AVAILABLE_IN_ALL
gint atk_table_get_column_extent_at (AtkTable *table,
gint row,
gint column);
GDK_AVAILABLE_IN_ALL
gint atk_table_get_row_extent_at (AtkTable *table,
gint row,
gint column);
GDK_AVAILABLE_IN_ALL
AtkObject*
atk_table_get_caption (AtkTable *table);
GDK_AVAILABLE_IN_ALL
const gchar* atk_table_get_column_description
(AtkTable *table,
gint column);
GDK_AVAILABLE_IN_ALL
AtkObject* atk_table_get_column_header (AtkTable *table,
gint column);
GDK_AVAILABLE_IN_ALL
const gchar* atk_table_get_row_description (AtkTable *table,
gint row);
GDK_AVAILABLE_IN_ALL
AtkObject* atk_table_get_row_header (AtkTable *table,
gint row);
GDK_AVAILABLE_IN_ALL
AtkObject* atk_table_get_summary (AtkTable *table);
GDK_AVAILABLE_IN_ALL
void atk_table_set_caption (AtkTable *table,
AtkObject *caption);
GDK_AVAILABLE_IN_ALL
void atk_table_set_column_description
(AtkTable *table,
gint column,
const gchar *description);
GDK_AVAILABLE_IN_ALL
void atk_table_set_column_header (AtkTable *table,
gint column,
AtkObject *header);
GDK_AVAILABLE_IN_ALL
void atk_table_set_row_description (AtkTable *table,
gint row,
const gchar *description);
GDK_AVAILABLE_IN_ALL
void atk_table_set_row_header (AtkTable *table,
gint row,
AtkObject *header);
GDK_AVAILABLE_IN_ALL
void atk_table_set_summary (AtkTable *table,
AtkObject *accessible);
GDK_AVAILABLE_IN_ALL
gint atk_table_get_selected_columns (AtkTable *table,
gint **selected);
GDK_AVAILABLE_IN_ALL
gint atk_table_get_selected_rows (AtkTable *table,
gint **selected);
GDK_AVAILABLE_IN_ALL
gboolean atk_table_is_column_selected (AtkTable *table,
gint column);
GDK_AVAILABLE_IN_ALL
gboolean atk_table_is_row_selected (AtkTable *table,
gint row);
GDK_AVAILABLE_IN_ALL
gboolean atk_table_is_selected (AtkTable *table,
gint row,
gint column);
GDK_AVAILABLE_IN_ALL
gboolean atk_table_add_row_selection (AtkTable *table,
gint row);
GDK_AVAILABLE_IN_ALL
gboolean atk_table_remove_row_selection (AtkTable *table,
gint row);
GDK_AVAILABLE_IN_ALL
gboolean atk_table_add_column_selection (AtkTable *table,
gint column);
GDK_AVAILABLE_IN_ALL
gboolean atk_table_remove_column_selection
(AtkTable *table,
gint column);
G_END_DECLS
#endif /* __ATK_TABLE_H__ */

277
atk/atktablecell.c Normal file
View File

@@ -0,0 +1,277 @@
/* ATK - Accessibility Toolkit
* Copyright 2014 SUSE LLC.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "atktablecell.h"
/**
* SECTION:atktablecell
* @Short_description: The ATK interface implemented for a cell inside
* a two-dimentional #AtkTable
* @Title:AtkTableCell
*
* Being #AtkTable a component which present elements ordered via rows
* and columns, an #AtkTableCell is the interface which each of those
* elements, so "cells" should implement.
*
* See also #AtkTable.
*/
typedef AtkTableCellIface AtkTableCellInterface;
G_DEFINE_INTERFACE (AtkTableCell, atk_table_cell, ATK_TYPE_OBJECT)
static gboolean atk_table_cell_real_get_row_column_span (AtkTableCell *cell,
gint *row,
gint *column,
gint *row_span,
gint *column_span);
static void
atk_table_cell_default_init (AtkTableCellInterface *iface)
{
iface->get_row_column_span = atk_table_cell_real_get_row_column_span;
}
/**
* atk_table_cell_get_column_span:
* @cell: a GObject instance that implements AtkTableCellIface
*
* Returns the number of columns occupied by this cell accessible.
*
* Returns: a gint representing the number of columns occupied by this cell,
* or 0 if the cell does not implement this method.
*
* Since: 2.12
*/
gint
atk_table_cell_get_column_span (AtkTableCell *cell)
{
AtkTableCellIface *iface;
g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), 0);
iface = ATK_TABLE_CELL_GET_IFACE (cell);
if (iface->get_column_span)
return (iface->get_column_span) (cell);
else
return 0;
}
/**
* atk_table_cell_get_column_header_cells:
* @cell: a GObject instance that implements AtkTableCellIface
*
* Returns the column headers as an array of cell accessibles.
*
* Returns: (element-type AtkObject) (transfer full): a GPtrArray of AtkObjects
* representing the column header cells.
*
* Since: 2.12
*/
GPtrArray *
atk_table_cell_get_column_header_cells (AtkTableCell *cell)
{
AtkTableCellIface *iface;
g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), NULL);
iface = ATK_TABLE_CELL_GET_IFACE (cell);
if (iface->get_column_header_cells)
return (iface->get_column_header_cells) (cell);
else
return NULL;
}
/**
* atk_table_cell_get_position:
* @cell: a GObject instance that implements AtkTableCellIface
* @row: (out): the row of the given cell.
* @column: (out): the column of the given cell.
*
* Retrieves the tabular position of this cell.
*
* Returns: TRUE if successful; FALSE otherwise.
*
* Since: 2.12
*/
gboolean
atk_table_cell_get_position (AtkTableCell *cell,
gint *row,
gint *column)
{
AtkTableCellIface *iface;
gint tmp_row, tmp_column;
gint *real_row = (row ? row : &tmp_row);
gint *real_column = (column ? column : &tmp_column);
*real_row = -1;
*real_column = -1;
g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), FALSE);
iface = ATK_TABLE_CELL_GET_IFACE (cell);
if (iface->get_position)
return (iface->get_position) (cell, real_row, real_column);
else
return FALSE;
}
/**
* atk_table_cell_get_row_span:
* @cell: a GObject instance that implements AtkTableCellIface
*
* Returns the number of rows occupied by this cell accessible.
*
* Returns: a gint representing the number of rows occupied by this cell,
* or 0 if the cell does not implement this method.
*
* Since: 2.12
*/
gint
atk_table_cell_get_row_span (AtkTableCell *cell)
{
AtkTableCellIface *iface;
g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), 0);
iface = ATK_TABLE_CELL_GET_IFACE (cell);
if (iface->get_row_span)
return (iface->get_row_span) (cell);
else
return 0;
}
/**
* atk_table_cell_get_row_header_cells:
* @cell: a GObject instance that implements AtkTableCellIface
*
* Returns the row headers as an array of cell accessibles.
*
* Returns: (element-type AtkObject) (transfer full): a GPtrArray of AtkObjects
* representing the row header cells.
*
* Since: 2.12
*/
GPtrArray *
atk_table_cell_get_row_header_cells (AtkTableCell *cell)
{
AtkTableCellIface *iface;
g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), NULL);
iface = ATK_TABLE_CELL_GET_IFACE (cell);
if (iface->get_row_header_cells)
return (iface->get_row_header_cells) (cell);
else
return NULL;
}
/**
* atk_table_cell_get_row_column_span:
* @cell: a GObject instance that implements AtkTableCellIface
* @row: (out): the row index of the given cell.
* @column: (out): the column index of the given cell.
* @row_span: (out): the number of rows occupied by this cell.
* @column_span: (out): the number of columns occupied by this cell.
*
* Gets the row and column indexes and span of this cell accessible.
*
* Note: If the object does not implement this function, then, by default, atk
* will implement this function by calling get_row_span and get_column_span
* on the object.
*
* Returns: TRUE if successful; FALSE otherwise.
*
* Since: 2.12
*/
gboolean
atk_table_cell_get_row_column_span (AtkTableCell *cell,
gint *row,
gint *column,
gint *row_span,
gint *column_span)
{
AtkTableCellIface *iface;
gint local_row = 0, local_column = 0;
gint local_row_span = 0, local_column_span = 0;
gint *real_row, *real_column;
gint *real_row_span, *real_column_span;
g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), FALSE);
real_row = (row ? row : &local_row);
real_column = (column ? column : &local_column);
real_row_span = (row_span ? row_span : &local_row_span);
real_column_span = (column_span ? column_span : &local_column_span);
iface = ATK_TABLE_CELL_GET_IFACE (cell);
if (iface->get_row_column_span)
return (iface->get_row_column_span) (cell, real_row, real_column,
real_row_span,
real_column_span);
else
return FALSE;
}
/**
* atk_table_cell_get_table:
* @cell: a GObject instance that implements AtkTableCellIface
*
* Returns a reference to the accessible of the containing table.
*
* Returns: (transfer full): the atk object for the containing table.
*
* Since: 2.12
*/
AtkObject *
atk_table_cell_get_table (AtkTableCell *cell)
{
AtkTableCellIface *iface;
g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), FALSE);
iface = ATK_TABLE_CELL_GET_IFACE (cell);
if (iface->get_table)
return (iface->get_table) (cell);
else
return NULL;
}
static gboolean
atk_table_cell_real_get_row_column_span (AtkTableCell *cell,
gint *row,
gint *column,
gint *row_span,
gint *column_span)
{
atk_table_cell_get_position (cell, row, column);
*row_span = atk_table_cell_get_row_span (cell);
*column_span = atk_table_cell_get_column_span (cell);
return (*row != 0 && *column != 0 && *row_span > 0 && *column_span > 0);
}

110
atk/atktablecell.h Normal file
View File

@@ -0,0 +1,110 @@
/* ATK - Accessibility Toolkit
* Copyright 2014 SUSE LLC.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_TABLE_CELL_H__
#define __ATK_TABLE_CELL_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <atk/atkobject.h>
G_BEGIN_DECLS
#define ATK_TYPE_TABLE_CELL (atk_table_cell_get_type ())
#define ATK_IS_TABLE_CELL(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_TABLE_CELL)
#define ATK_TABLE_CELL(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_TABLE_CELL, AtkTableCell)
#define ATK_TABLE_CELL_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_TABLE_CELL, AtkTableCellIface))
#ifndef _TYPEDEF_ATK_TABLE_CELL_
#define _TYPEDEF_ATK_TABLE_CELL_
typedef struct _AtkTableCell AtkTableCell;
#endif
typedef struct _AtkTableCellIface AtkTableCellIface;
/**
* AtkTableCellIface:
* @get_column_span: virtual function that returns the number of
* columns occupied by this cell accessible
* @get_column_header_cells: virtual function that returns the column
* headers as an array of cell accessibles
* @get_position: virtual function that retrieves the tabular position
* of this cell
* @get_row_span: virtual function that returns the number of rows
* occupied by this cell
* @get_row_header_cells: virtual function that returns the row
* headers as an array of cell accessibles
* @get_row_column_span: virtual function that get the row an column
* indexes and span of this cell
* @get_table: virtual function that returns a reference to the
* accessible of the containing table
*
* AtkTableCell is an interface for cells inside an #AtkTable.
*
* Since: 2.12
*/
struct _AtkTableCellIface
{
/*< private >*/
GTypeInterface parent;
/*< public >*/
gint (*get_column_span) (AtkTableCell *cell);
GPtrArray * (*get_column_header_cells) (AtkTableCell *cell);
gboolean (*get_position) (AtkTableCell *cell,
gint *row,
gint *column);
gint (*get_row_span) (AtkTableCell *cell);
GPtrArray * (*get_row_header_cells) (AtkTableCell *cell);
gboolean (*get_row_column_span) (AtkTableCell *cell,
gint *row,
gint *column,
gint *row_span,
gint *column_span);
AtkObject * (*get_table) (AtkTableCell *cell);
};
GDK_AVAILABLE_IN_ALL
GType atk_table_cell_get_type (void);
GDK_AVAILABLE_IN_ALL
gint atk_table_cell_get_column_span (AtkTableCell *cell);
GDK_AVAILABLE_IN_ALL
GPtrArray * atk_table_cell_get_column_header_cells (AtkTableCell *cell);
GDK_AVAILABLE_IN_ALL
gboolean atk_table_cell_get_position (AtkTableCell *cell,
gint *row,
gint *column);
GDK_AVAILABLE_IN_ALL
gint atk_table_cell_get_row_span (AtkTableCell *cell);
GDK_AVAILABLE_IN_ALL
GPtrArray * atk_table_cell_get_row_header_cells (AtkTableCell *cell);
GDK_AVAILABLE_IN_ALL
gboolean atk_table_cell_get_row_column_span (AtkTableCell *cell,
gint *row,
gint *column,
gint *row_span,
gint *column_span);
GDK_AVAILABLE_IN_ALL
AtkObject * atk_table_cell_get_table (AtkTableCell *cell);
G_END_DECLS
#endif /* __ATK_TABLE_CELL_H__ */

1444
atk/atktext.c Normal file

File diff suppressed because it is too large Load Diff

329
atk/atktext.h Normal file
View File

@@ -0,0 +1,329 @@
/* ATK - The Accessibility Toolkit for GTK+
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_TEXT_H__
#define __ATK_TEXT_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <glib-object.h>
#include <atk/atkobject.h>
#include <atk/atkutil.h>
#include <atk/atkcomponent.h>
G_BEGIN_DECLS
GDK_AVAILABLE_IN_ALL
AtkTextAttribute atk_text_attribute_register (const gchar *name);
#define ATK_TYPE_TEXT (atk_text_get_type ())
#define ATK_IS_TEXT(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_TEXT)
#define ATK_TEXT(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_TEXT, AtkText)
#define ATK_TEXT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_TEXT, AtkTextIface))
#ifndef _TYPEDEF_ATK_TEXT_
#define _TYPEDEF_ATK_TEXT_
typedef struct _AtkText AtkText;
#endif
typedef struct _AtkTextIface AtkTextIface;
/**
* AtkTextRectangle:
* @x: The horizontal coordinate of a rectangle
* @y: The vertical coordinate of a rectangle
* @width: The width of a rectangle
* @height: The height of a rectangle
*
* A structure used to store a rectangle used by AtkText.
**/
typedef struct _AtkTextRectangle AtkTextRectangle;
struct _AtkTextRectangle {
gint x;
gint y;
gint width;
gint height;
};
/**
* AtkTextRange:
* @bounds: A rectangle giving the bounds of the text range
* @start_offset: The start offset of a AtkTextRange
* @end_offset: The end offset of a AtkTextRange
* @content: The text in the text range
*
* A structure used to describe a text range.
**/
typedef struct _AtkTextRange AtkTextRange;
struct _AtkTextRange {
AtkTextRectangle bounds;
gint start_offset;
gint end_offset;
gchar* content;
};
GDK_AVAILABLE_IN_ALL
GType atk_text_range_get_type (void);
/**
* AtkTextIface:
* @get_text_after_offset: Gets specified text. This virtual function
* is deprecated and it should not be overridden.
* @get_text_at_offset: Gets specified text. This virtual function
* is deprecated and it should not be overridden.
* @get_text_before_offset: Gets specified text. This virtual function
* is deprecated and it should not be overridden.
* @get_string_at_offset: Gets a portion of the text exposed through
* an AtkText according to a given offset and a specific
* granularity, along with the start and end offsets defining the
* boundaries of such a portion of text.
* @text_changed: the signal handler which is executed when there is a
* text change. This virtual function is deprecated sice 2.9.4 and
* it should not be overriden.
*/
struct _AtkTextIface
{
GTypeInterface parent;
gchar* (* get_text) (AtkText *text,
gint start_offset,
gint end_offset);
gchar* (* get_text_after_offset) (AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset);
gchar* (* get_text_at_offset) (AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset);
gunichar (* get_character_at_offset) (AtkText *text,
gint offset);
gchar* (* get_text_before_offset) (AtkText *text,
gint offset,
AtkTextBoundary boundary_type,
gint *start_offset,
gint *end_offset);
gint (* get_caret_offset) (AtkText *text);
AtkAttributeSet* (* get_run_attributes) (AtkText *text,
gint offset,
gint *start_offset,
gint *end_offset);
AtkAttributeSet* (* get_default_attributes) (AtkText *text);
void (* get_character_extents) (AtkText *text,
gint offset,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coords);
gint (* get_character_count) (AtkText *text);
gint (* get_offset_at_point) (AtkText *text,
gint x,
gint y,
AtkCoordType coords);
gint (* get_n_selections) (AtkText *text);
gchar* (* get_selection) (AtkText *text,
gint selection_num,
gint *start_offset,
gint *end_offset);
gboolean (* add_selection) (AtkText *text,
gint start_offset,
gint end_offset);
gboolean (* remove_selection) (AtkText *text,
gint selection_num);
gboolean (* set_selection) (AtkText *text,
gint selection_num,
gint start_offset,
gint end_offset);
gboolean (* set_caret_offset) (AtkText *text,
gint offset);
/*
* signal handlers
*/
void (* text_changed) (AtkText *text,
gint position,
gint length);
void (* text_caret_moved) (AtkText *text,
gint location);
void (* text_selection_changed) (AtkText *text);
void (* text_attributes_changed) (AtkText *text);
void (* get_range_extents) (AtkText *text,
gint start_offset,
gint end_offset,
AtkCoordType coord_type,
AtkTextRectangle *rect);
AtkTextRange** (* get_bounded_ranges) (AtkText *text,
AtkTextRectangle *rect,
AtkCoordType coord_type,
AtkTextClipType x_clip_type,
AtkTextClipType y_clip_type);
gchar* (* get_string_at_offset) (AtkText *text,
gint offset,
AtkTextGranularity granularity,
gint *start_offset,
gint *end_offset);
/*
* Scrolls this text range so it becomes visible on the screen.
*
* scroll_substring_to lets the implementation compute an appropriate target
* position on the screen, with type used as a positioning hint.
*
* scroll_substring_to_point lets the client specify a precise target position
* on the screen for the top-left of the substring.
*
* Since ATK 2.32
*/
gboolean (* scroll_substring_to) (AtkText *text,
gint start_offset,
gint end_offset,
AtkScrollType type);
gboolean (* scroll_substring_to_point) (AtkText *text,
gint start_offset,
gint end_offset,
AtkCoordType coords,
gint x,
gint y);
};
GDK_AVAILABLE_IN_ALL
GType atk_text_get_type (void);
/*
* Additional AtkObject properties used by AtkText:
* "accessible_text" (accessible text has changed)
* "accessible_caret" (accessible text cursor position changed:
* editable text only)
*/
GDK_AVAILABLE_IN_ALL
gchar* atk_text_get_text (AtkText *text,
gint start_offset,
gint end_offset);
GDK_AVAILABLE_IN_ALL
gunichar atk_text_get_character_at_offset (AtkText *text,
gint offset);
GDK_AVAILABLE_IN_ALL
gchar* atk_text_get_string_at_offset (AtkText *text,
gint offset,
AtkTextGranularity granularity,
gint *start_offset,
gint *end_offset);
GDK_AVAILABLE_IN_ALL
gint atk_text_get_caret_offset (AtkText *text);
GDK_AVAILABLE_IN_ALL
void atk_text_get_character_extents (AtkText *text,
gint offset,
gint *x,
gint *y,
gint *width,
gint *height,
AtkCoordType coords);
GDK_AVAILABLE_IN_ALL
AtkAttributeSet* atk_text_get_run_attributes (AtkText *text,
gint offset,
gint *start_offset,
gint *end_offset);
GDK_AVAILABLE_IN_ALL
AtkAttributeSet* atk_text_get_default_attributes (AtkText *text);
GDK_AVAILABLE_IN_ALL
gint atk_text_get_character_count (AtkText *text);
GDK_AVAILABLE_IN_ALL
gint atk_text_get_offset_at_point (AtkText *text,
gint x,
gint y,
AtkCoordType coords);
GDK_AVAILABLE_IN_ALL
gint atk_text_get_n_selections (AtkText *text);
GDK_AVAILABLE_IN_ALL
gchar* atk_text_get_selection (AtkText *text,
gint selection_num,
gint *start_offset,
gint *end_offset);
GDK_AVAILABLE_IN_ALL
gboolean atk_text_add_selection (AtkText *text,
gint start_offset,
gint end_offset);
GDK_AVAILABLE_IN_ALL
gboolean atk_text_remove_selection (AtkText *text,
gint selection_num);
GDK_AVAILABLE_IN_ALL
gboolean atk_text_set_selection (AtkText *text,
gint selection_num,
gint start_offset,
gint end_offset);
GDK_AVAILABLE_IN_ALL
gboolean atk_text_set_caret_offset (AtkText *text,
gint offset);
GDK_AVAILABLE_IN_ALL
void atk_text_get_range_extents (AtkText *text,
gint start_offset,
gint end_offset,
AtkCoordType coord_type,
AtkTextRectangle *rect);
GDK_AVAILABLE_IN_ALL
AtkTextRange** atk_text_get_bounded_ranges (AtkText *text,
AtkTextRectangle *rect,
AtkCoordType coord_type,
AtkTextClipType x_clip_type,
AtkTextClipType y_clip_type);
GDK_AVAILABLE_IN_ALL
void atk_text_free_ranges (AtkTextRange **ranges);
GDK_AVAILABLE_IN_ALL
void atk_attribute_set_free (AtkAttributeSet *attrib_set);
GDK_AVAILABLE_IN_ALL
const gchar* atk_text_attribute_get_name (AtkTextAttribute attr);
GDK_AVAILABLE_IN_ALL
AtkTextAttribute atk_text_attribute_for_name (const gchar *name);
GDK_AVAILABLE_IN_ALL
const gchar* atk_text_attribute_get_value (AtkTextAttribute attr,
gint index_);
GDK_AVAILABLE_IN_ALL
gboolean atk_text_scroll_substring_to (AtkText *text,
gint start_offset,
gint end_offset,
AtkScrollType type);
GDK_AVAILABLE_IN_ALL
gboolean atk_text_scroll_substring_to_point (AtkText *text,
gint start_offset,
gint end_offset,
AtkCoordType coords,
gint x,
gint y);
G_END_DECLS
#endif /* __ATK_TEXT_H__ */

9
atk/atktypes.h Normal file
View File

@@ -0,0 +1,9 @@
#pragma once
#if !defined(__ATK_H_INSIDE__) && !defined(GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <glib-object.h>
#include <gdk/gdk.h>
#include <atk/atkenums.h>

374
atk/atkutil.c Normal file
View File

@@ -0,0 +1,374 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "atkutil.h"
#include "atkmarshal.h"
/**
* SECTION:atkutil
* @Short_description: A set of ATK utility functions for event and toolkit support.
* @Title:AtkUtil
*
* A set of ATK utility functions which are used to support event
* registration of various types, and obtaining the 'root' accessible
* of a process and information about the current ATK implementation
* and toolkit version.
*/
static void atk_util_class_init (AtkUtilClass *klass);
static AtkObject *previous_focus_object = NULL;
typedef struct _AtkUtilListenerInfo AtkUtilListenerInfo;
struct _AtkUtilListenerInfo
{
gint key;
guint signal_id;
gulong hook_id;
};
static GHashTable *listener_list = NULL;
GType
atk_util_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo typeInfo =
{
sizeof (AtkUtilClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) atk_util_class_init,
(GClassFinalizeFunc) NULL,
NULL,
sizeof (AtkUtil),
0,
(GInstanceInitFunc) NULL,
} ;
type = g_type_register_static (G_TYPE_OBJECT, "AtkUtil", &typeInfo, 0) ;
}
return type;
}
typedef struct _FocusTracker FocusTracker;
struct _FocusTracker {
guint index;
AtkEventListener func;
};
static guint
add_listener (GSignalEmissionHook listener,
const gchar *object_type,
const gchar *signal_name,
const gchar *detail_string,
const gchar *hook_data)
{
GType type;
guint signal_id;
gint rc = 0;
static gint listener_idx = 1;
GQuark detail_quark = 0;
type = g_type_from_name (object_type);
if (type)
{
signal_id = g_signal_lookup (signal_name, type);
detail_quark = g_quark_from_string (detail_string);
if (signal_id > 0)
{
AtkUtilListenerInfo *listener_info;
rc = listener_idx;
listener_info = g_new (AtkUtilListenerInfo, 1);
listener_info->key = listener_idx;
listener_info->hook_id =
g_signal_add_emission_hook (signal_id, detail_quark, listener,
g_strdup (hook_data),
(GDestroyNotify) g_free);
listener_info->signal_id = signal_id;
g_hash_table_insert(listener_list, &(listener_info->key), listener_info);
listener_idx++;
}
else
{
g_debug ("Signal type %s not supported\n", signal_name);
}
}
else
{
g_warning("Invalid object type %s\n", object_type);
}
return rc;
}
static guint
atk_util_real_add_global_event_listener (GSignalEmissionHook listener,
const gchar *event_type)
{
guint rc = 0;
gchar **split_string;
guint length;
split_string = g_strsplit (event_type, ":", 0);
length = g_strv_length (split_string);
if ((length == 3) || (length == 4))
rc = add_listener (listener, split_string[1], split_string[2],
split_string[3], event_type);
g_strfreev (split_string);
return rc;
}
static void
atk_util_real_remove_global_event_listener (guint remove_listener)
{
if (remove_listener > 0)
{
AtkUtilListenerInfo *listener_info;
gint tmp_idx = remove_listener;
listener_info = (AtkUtilListenerInfo *)
g_hash_table_lookup(listener_list, &tmp_idx);
if (listener_info != NULL)
{
/* Hook id of 0 and signal id of 0 are invalid */
if (listener_info->hook_id != 0 && listener_info->signal_id != 0)
{
/* Remove the emission hook */
g_signal_remove_emission_hook(listener_info->signal_id,
listener_info->hook_id);
/* Remove the element from the hash */
g_hash_table_remove(listener_list, &tmp_idx);
}
else
{
g_warning("Invalid listener hook_id %ld or signal_id %d\n",
listener_info->hook_id, listener_info->signal_id);
}
}
else
{
g_warning("No listener with the specified listener id %d",
remove_listener);
}
}
else
{
g_warning("Invalid listener_id %d", remove_listener);
}
}
/**
* atk_add_global_event_listener: (skip)
* @listener: the listener to notify
* @event_type: the type of event for which notification is requested
*
* Adds the specified function to the list of functions to be called
* when an ATK event of type event_type occurs.
*
* The format of event_type is the following:
* "ATK:&lt;atk_type&gt;:&lt;atk_event&gt;:&lt;atk_event_detail&gt;
*
* Where "ATK" works as the namespace, &lt;atk_interface&gt; is the name of
* the ATK type (interface or object), &lt;atk_event&gt; is the name of the
* signal defined on that interface and &lt;atk_event_detail&gt; is the
* gsignal detail of that signal. You can find more info about gsignal
* details here:
* http://developer.gnome.org/gobject/stable/gobject-Signals.html
*
* The first three parameters are mandatory. The last one is optional.
*
* For example:
* ATK:AtkObject:state-change
* ATK:AtkText:text-selection-changed
* ATK:AtkText:text-insert:system
*
* Toolkit implementor note: ATK provides a default implementation for
* this virtual method. ATK implementors are discouraged from
* reimplementing this method.
*
* Toolkit implementor note: this method is not intended to be used by
* ATK implementors but by ATK consumers.
*
* ATK consumers note: as this method adds a listener for a given ATK
* type, that type should be already registered on the GType system
* before calling this method. A simple way to do that is creating an
* instance of #AtkNoOpObject. This class implements all ATK
* interfaces, so creating the instance will register all ATK types as
* a collateral effect.
*
* Returns: added event listener id, or 0 on failure.
**/
guint
atk_add_global_event_listener (GSignalEmissionHook listener,
const gchar *event_type)
{
guint retval;
AtkUtilClass *klass = g_type_class_ref (ATK_TYPE_UTIL);
if (klass->add_global_event_listener)
{
retval = klass->add_global_event_listener (listener, event_type);
}
else
{
retval = 0;
}
g_type_class_unref (klass);
return retval;
}
/**
* atk_remove_global_event_listener:
* @listener_id: the id of the event listener to remove
*
* @listener_id is the value returned by #atk_add_global_event_listener
* when you registered that event listener.
*
* Toolkit implementor note: ATK provides a default implementation for
* this virtual method. ATK implementors are discouraged from
* reimplementing this method.
*
* Toolkit implementor note: this method is not intended to be used by
* ATK implementors but by ATK consumers.
*
* Removes the specified event listener
**/
void
atk_remove_global_event_listener (guint listener_id)
{
AtkUtilClass *klass = g_type_class_peek (ATK_TYPE_UTIL);
if (klass && klass->remove_global_event_listener)
klass->remove_global_event_listener (listener_id);
}
/**
* atk_add_key_event_listener: (skip)
* @listener: the listener to notify
* @data: a #gpointer that points to a block of data that should be sent to the registered listeners,
* along with the event notification, when it occurs.
*
* Adds the specified function to the list of functions to be called
* when a key event occurs. The @data element will be passed to the
* #AtkKeySnoopFunc (@listener) as the @func_data param, on notification.
*
* Returns: added event listener id, or 0 on failure.
**/
guint
atk_add_key_event_listener (AtkKeySnoopFunc listener, gpointer data)
{
guint retval;
AtkUtilClass *klass = g_type_class_peek (ATK_TYPE_UTIL);
if (klass && klass->add_key_event_listener)
{
retval = klass->add_key_event_listener (listener, data);
}
else
{
retval = 0;
}
return retval;
}
/**
* atk_remove_key_event_listener:
* @listener_id: the id of the event listener to remove
*
* @listener_id is the value returned by #atk_add_key_event_listener
* when you registered that event listener.
*
* Removes the specified event listener.
**/
void
atk_remove_key_event_listener (guint listener_id)
{
AtkUtilClass *klass = g_type_class_peek (ATK_TYPE_UTIL);
if (klass->remove_key_event_listener)
klass->remove_key_event_listener (listener_id);
}
/**
* atk_get_root:
*
* Gets the root accessible container for the current application.
*
* Returns: (transfer none): the root accessible container for the current
* application
**/
AtkObject*
atk_get_root (void)
{
AtkUtilClass *klass = g_type_class_ref (ATK_TYPE_UTIL);
AtkObject *retval;
if (klass->get_root)
{
retval = klass->get_root ();
}
else
{
retval = NULL;
}
g_type_class_unref (klass);
return retval;
}
/**
* atk_get_focus_object:
*
* Gets the currently focused object.
*
* Since: 1.6
*
* Returns: (transfer none): the currently focused object for the current
* application
**/
AtkObject*
atk_get_focus_object (void)
{
return previous_focus_object;
}
static void
atk_util_class_init (AtkUtilClass *klass)
{
klass->add_global_event_listener = atk_util_real_add_global_event_listener;
klass->remove_global_event_listener = atk_util_real_remove_global_event_listener;
klass->get_root = NULL;
listener_list = g_hash_table_new_full (g_int_hash, g_int_equal, NULL,
g_free);
}

306
atk/atkutil.h Normal file
View File

@@ -0,0 +1,306 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_UTIL_H__
#define __ATK_UTIL_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <atk/atkobject.h>
G_BEGIN_DECLS
#define ATK_TYPE_UTIL (atk_util_get_type ())
#define ATK_IS_UTIL(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_UTIL)
#define ATK_UTIL(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_UTIL, AtkUtil)
#define ATK_UTIL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATK_TYPE_UTIL, AtkUtilClass))
#define ATK_IS_UTIL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATK_TYPE_UTIL))
#define ATK_UTIL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATK_TYPE_UTIL, AtkUtilClass))
#ifndef _TYPEDEF_ATK_UTIL_
#define _TYPEDEF_ATK_UTIL_
typedef struct _AtkUtil AtkUtil;
typedef struct _AtkUtilClass AtkUtilClass;
typedef struct _AtkKeyEventStruct AtkKeyEventStruct;
#endif
/**
* AtkEventListener:
* @obj: An #AtkObject instance for whom the callback will be called when
* the specified event (e.g. 'focus:') takes place.
*
* A function which is called when an object emits a matching event,
* as used in #atk_add_focus_tracker.
* Currently the only events for which object-specific handlers are
* supported are events of type "focus:". Most clients of ATK will prefer to
* attach signal handlers for the various ATK signals instead.
*
* see atk_add_focus_tracker.
**/
typedef void (*AtkEventListener) (AtkObject* obj);
/**
* AtkEventListenerInit:
*
* An #AtkEventListenerInit function is a special function that is
* called in order to initialize the per-object event registration system
* used by #AtkEventListener, if any preparation is required.
*
* see atk_focus_tracker_init.
**/
typedef void (*AtkEventListenerInit) (void);
/**
* AtkKeySnoopFunc:
* @event: an AtkKeyEventStruct containing information about the key event for which
* notification is being given.
* @user_data: a block of data which will be passed to the event listener, on notification.
*
* An #AtkKeySnoopFunc is a type of callback which is called whenever a key event occurs,
* if registered via atk_add_key_event_listener. It allows for pre-emptive
* interception of key events via the return code as described below.
*
* Returns: TRUE (nonzero) if the event emission should be stopped and the event
* discarded without being passed to the normal GUI recipient; FALSE (zero) if the
* event dispatch to the client application should proceed as normal.
*
* see atk_add_key_event_listener.
**/
typedef gint (*AtkKeySnoopFunc) (AtkKeyEventStruct *event,
gpointer user_data);
/**
* AtkKeyEventStruct:
* @type: An AtkKeyEventType, generally one of ATK_KEY_EVENT_PRESS or ATK_KEY_EVENT_RELEASE
* @state: A bitmask representing the state of the modifier keys immediately after the event takes place.
* The meaning of the bits is currently defined to match the bitmask used by GDK in
* GdkEventType.state, see
* http://developer.gnome.org/doc/API/2.0/gdk/gdk-Event-Structures.html#GdkEventKey
* @keyval: A guint representing a keysym value corresponding to those used by GDK and X11: see
* /usr/X11/include/keysymdef.h.
* @length: The length of member #string.
* @string: A string containing one of the following: either a string approximating the text that would
* result from this keypress, if the key is a control or graphic character, or a symbolic name for this keypress.
* Alphanumeric and printable keys will have the symbolic key name in this string member, for instance "A". "0",
* "semicolon", "aacute". Keypad keys have the prefix "KP".
* @keycode: The raw hardware code that generated the key event. This field is raraly useful.
* @timestamp: A timestamp in milliseconds indicating when the event occurred.
* These timestamps are relative to a starting point which should be considered arbitrary,
* and only used to compare the dispatch times of events to one another.
*
* Encapsulates information about a key event.
**/
struct _AtkKeyEventStruct {
gint type;
guint state;
guint keyval;
gint length;
gchar *string;
guint16 keycode;
guint32 timestamp;
};
struct _AtkUtil
{
GObject parent;
};
/**
* AtkUtilClass:
* @add_global_event_listener: adds the specified function to the list
* of functions to be called when an ATK event occurs. ATK
* implementors are discouraged from reimplementing this method.
* @remove_global_event_listener: removes the specified function to
* the list of functions to be called when an ATK event occurs. ATK
* implementors are discouraged from reimplementing this method.
* @add_key_event_listener: adds the specified function to the list of
* functions to be called when a key event occurs.
* @remove_key_event_listener: remove the specified function to the
* list of functions to be called when a key event occurs.
* @get_root: gets the root accessible container for the current
* application.
*/
struct _AtkUtilClass
{
GObjectClass parent;
guint (* add_global_event_listener) (GSignalEmissionHook listener,
const gchar *event_type);
void (* remove_global_event_listener) (guint listener_id);
guint (* add_key_event_listener) (AtkKeySnoopFunc listener,
gpointer data);
void (* remove_key_event_listener) (guint listener_id);
AtkObject* (* get_root) (void);
};
GDK_AVAILABLE_IN_ALL
GType atk_util_get_type (void);
GDK_AVAILABLE_IN_ALL
guint atk_add_global_event_listener (GSignalEmissionHook listener,
const gchar *event_type);
GDK_AVAILABLE_IN_ALL
void atk_remove_global_event_listener (guint listener_id);
GDK_AVAILABLE_IN_ALL
guint atk_add_key_event_listener (AtkKeySnoopFunc listener, gpointer data);
GDK_AVAILABLE_IN_ALL
void atk_remove_key_event_listener (guint listener_id);
GDK_AVAILABLE_IN_ALL
AtkObject* atk_get_root(void);
GDK_AVAILABLE_IN_ALL
AtkObject* atk_get_focus_object (void);
/* --- GType boilerplate --- */
/* convenience macros for atk type implementations, which for a type GtkGadgetAccessible will:
* - prototype: static void gtk_gadget_accessible_class_init (GtkGadgetClass *klass);
* - prototype: static void gtk_gadget_accessible_init (GtkGadget *self);
* - define: static gpointer gtk_gadget_accessible_parent_class = NULL;
* gtk_gadget_accessible_parent_class is initialized prior to calling gtk_gadget_class_init()
* - implement: GType gtk_gadget_accessible_get_type (void) { ... }
* - support custom code in gtk_gadget_accessible_get_type() after the type is registered.
*
* macro arguments: TypeName, type_name, TYPE_PARENT, CODE
* example: ATK_DEFINE_TYPE_WITH_CODE (GtkGadgetAccessible, gtk_gadget_accessible, GTK_TYPE_GADGET,
* G_IMPLEMENT_INTERFACE (ATK_TYPE_TABLE, gtk_gadget_accessible_table_iface_init))
*/
/**
* ATK_DEFINE_TYPE:
* @TN: The name of the new type, in Camel case.
* @t_n: The name of the new type, in lowercase, with words separated by '_'.
* @T_P: The #GType of the parent type.
*
* A convenience macro for type ATK implementations, which declares a class
* initialization function, an instance initialization function (see #GTypeInfo
* for information about these) and a static variable named
* @t_n _parent_class pointing to the parent class. Furthermore, it
* defines a _get_type() function.
*
* Since: 1.22
*/
#define ATK_DEFINE_TYPE(TN, t_n, T_P) ATK_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, {})
/**
* ATK_DEFINE_TYPE_WITH_CODE:
* @TN: The name of the new type, in Camel case.
* @t_n: The name of the new type in lowercase, with words separated by '_'.
* @T_P: The #GType of the parent type.
* @_C_: Custom code that gets inserted in the _get_type() function.
*
* A convenience macro for ATK type implementations.
* Similar to ATK_DEFINE_TYPE(), but allows you to insert custom code into the
* _get_type() function, e.g. interface implementations via G_IMPLEMENT_INTERFACE().
*
* Since: 1.22
*/
#define ATK_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_) _ATK_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, 0) {_C_;} _ATK_DEFINE_TYPE_EXTENDED_END()
/**
* ATK_DEFINE_ABSTRACT_TYPE:
* @TN: The name of the new type, in Camel case.
* @t_n: The name of the new type, in lowercase, with words separated by '_'.
* @T_P: The #GType of the parent type.
*
* A convenience macro for ATK type implementations.
* Similar to ATK_DEFINE_TYPE(), but defines an abstract type.
*
* Since: 1.22
*/
#define ATK_DEFINE_ABSTRACT_TYPE(TN, t_n, T_P) ATK_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT, {})
/**
* ATK_DEFINE_ABSTRACT_TYPE_WITH_CODE:
* @TN: The name of the new type, in Camel case.
* @t_n: The name of the new type, in lowercase, with words separated by '_'.
* @T_P: The #GType of the parent type.
* @_C_: Custom code that gets inserted in the _get_type() function.
*
* A convenience macro for ATK type implementations.
* Similar to ATK_DEFINE_TYPE_WITH_CODE(), but defines an abstract type.
*
* Since: 1.22
*/
#define ATK_DEFINE_ABSTRACT_TYPE_WITH_CODE(TN, t_n, T_P, _C_) _ATK_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT) {_C_;} _ATK_DEFINE_TYPE_EXTENDED_END()
/**
* ATK_DEFINE_TYPE_EXTENDED:
* @TN: The name of the new type, in Camel case.
* @t_n: The name of the new type, in lowercase, with words separated by '_'.
* @T_P: The #GType of the parent type.
* @_f_: #GTypeFlags to pass to g_type_register_static()
* @_C_: Custom code that gets inserted in the _get_type() function.
*
* The most general convenience macro for ATK type implementations, on which
* ATK_DEFINE_TYPE(), etc are based.
*
* Since: 1.22
*/
#define ATK_DEFINE_TYPE_EXTENDED(TN, t_n, T_P, _f_, _C_) _ATK_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, _f_) {_C_;} _ATK_DEFINE_TYPE_EXTENDED_END()
#define _ATK_DEFINE_TYPE_EXTENDED_BEGIN(TypeName, type_name, TYPE, flags) \
\
static void type_name##_init (TypeName *self); \
static void type_name##_class_init (TypeName##Class *klass); \
static gpointer type_name##_parent_class = NULL; \
static void type_name##_class_intern_init (gpointer klass) \
{ \
type_name##_parent_class = g_type_class_peek_parent (klass); \
type_name##_class_init ((TypeName##Class*) klass); \
} \
\
GDK_AVAILABLE_IN_ALL \
GType \
type_name##_get_type (void) \
{ \
static volatile gsize g_define_type_id__volatile = 0; \
if (g_once_init_enter (&g_define_type_id__volatile)) \
{ \
AtkObjectFactory *factory; \
GType derived_type; \
GTypeQuery query; \
GType derived_atk_type; \
GType g_define_type_id; \
\
/* Figure out the size of the class and instance we are deriving from */ \
derived_type = g_type_parent (TYPE); \
factory = atk_registry_get_factory (atk_get_default_registry (), \
derived_type); \
derived_atk_type = atk_object_factory_get_accessible_type (factory); \
g_type_query (derived_atk_type, &query); \
\
g_define_type_id = \
g_type_register_static_simple (derived_atk_type, \
g_intern_static_string (#TypeName), \
query.class_size, \
(GClassInitFunc) type_name##_class_intern_init, \
query.instance_size, \
(GInstanceInitFunc) type_name##_init, \
(GTypeFlags) flags); \
{ /* custom code follows */
#define _ATK_DEFINE_TYPE_EXTENDED_END() \
/* following custom code */ \
} \
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); \
} \
return g_define_type_id__volatile; \
} /* closes type_name##_get_type() */
G_END_DECLS
#endif /* __ATK_UTIL_H__ */

591
atk/atkvalue.c Normal file
View File

@@ -0,0 +1,591 @@
/* ATK - Accessibility Toolkit
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <string.h>
#include <glib/gi18n-lib.h>
#include "atkvalue.h"
#include "atkmarshal.h"
#include "atkenumtypes.h"
#include "atkprivate.h"
/**
* SECTION:atkvalue
* @Short_description: The ATK interface implemented by valuators and
* components which display or select a value from a bounded range of
* values.
* @Title:AtkValue
*
* #AtkValue should be implemented for components which either display
* a value from a bounded range, or which allow the user to specify a
* value from a bounded range, or both. For instance, most sliders and
* range controls, as well as dials, should have #AtkObject
* representations which implement #AtkValue on the component's
* behalf. #AtKValues may be read-only, in which case attempts to
* alter the value return would fail.
*
* <refsect1 id="current-value-text">
* <title>On the subject of current value text</title>
* <para>
* In addition to providing the current value, implementors can
* optionally provide an end-user-consumable textual description
* associated with this value. This description should be included
* when the numeric value fails to convey the full, on-screen
* representation seen by users.
* </para>
*
* <example>
* <title>Password strength</title>
* A password strength meter whose value changes as the user types
* their new password. Red is used for values less than 4.0, yellow
* for values between 4.0 and 7.0, and green for values greater than
* 7.0. In this instance, value text should be provided by the
* implementor. Appropriate value text would be "weak", "acceptable,"
* and "strong" respectively.
* </example>
*
* A level bar whose value changes to reflect the battery charge. The
* color remains the same regardless of the charge and there is no
* on-screen text reflecting the fullness of the battery. In this
* case, because the position within the bar is the only indication
* the user has of the current charge, value text should not be
* provided by the implementor.
*
* <refsect2 id="implementor-notes">
* <title>Implementor Notes</title>
* <para>
* Implementors should bear in mind that assistive technologies will
* likely prefer the value text provided over the numeric value when
* presenting a widget's value. As a result, strings not intended for
* end users should not be exposed in the value text, and strings
* which are exposed should be localized. In the case of widgets which
* display value text on screen, for instance through a separate label
* in close proximity to the value-displaying widget, it is still
* expected that implementors will expose the value text using the
* above API.
* </para>
*
* <para>
* #AtkValue should NOT be implemented for widgets whose displayed
* value is not reflective of a meaningful amount. For instance, a
* progress pulse indicator whose value alternates between 0.0 and 1.0
* to indicate that some process is still taking place should not
* implement #AtkValue because the current value does not reflect
* progress towards completion.
* </para>
* </refsect2>
* </refsect1>
*
* <refsect1 id="ranges">
* <title>On the subject of ranges</title>
* <para>
* In addition to providing the minimum and maximum values,
* implementors can optionally provide details about subranges
* associated with the widget. These details should be provided by the
* implementor when both of the following are communicated visually to
* the end user:
* </para>
* <itemizedlist>
* <listitem>The existence of distinct ranges such as "weak",
* "acceptable", and "strong" indicated by color, bar tick marks,
* and/or on-screen text.</listitem>
* <listitem>Where the current value stands within a given subrange,
* for instance illustrating progression from very "weak" towards
* nearly "acceptable" through changes in shade and/or position on
* the bar within the "weak" subrange.</listitem>
* </itemizedlist>
* <para>
* If both of the above do not apply to the widget, it should be
* sufficient to expose the numeric value, along with the value text
* if appropriate, to make the widget accessible.
* </para>
*
* <refsect2 id="ranges-implementor-notes">
* <title>Implementor Notes</title>
* <para>
* If providing subrange details is deemed necessary, all possible
* values of the widget are expected to fall within one of the
* subranges defined by the implementor.
* </para>
* </refsect2>
* </refsect1>
*
* <refsect1 id="localization">
* <title>On the subject of localization of end-user-consumable text
* values</title>
* <para>
* Because value text and subrange descriptors are human-consumable,
* implementors are expected to provide localized strings which can be
* directly presented to end users via their assistive technology. In
* order to simplify this for implementors, implementors can use
* atk_value_type_get_localized_name() with the following
* already-localized constants for commonly-needed values can be used:
* </para>
*
* <itemizedlist>
* <listitem>ATK_VALUE_VERY_WEAK</listitem>
* <listitem>ATK_VALUE_WEAK</listitem>
* <listitem>ATK_VALUE_ACCEPTABLE</listitem>
* <listitem>ATK_VALUE_STRONG</listitem>
* <listitem>ATK_VALUE_VERY_STRONG</listitem>
* <listitem>ATK_VALUE_VERY_LOW</listitem>
* <listitem>ATK_VALUE_LOW</listitem>
* <listitem>ATK_VALUE_MEDIUM</listitem>
* <listitem>ATK_VALUE_HIGH</listitem>
* <listitem>ATK_VALUE_VERY_HIGH</listitem>
* <listitem>ATK_VALUE_VERY_BAD</listitem>
* <listitem>ATK_VALUE_BAD</listitem>
* <listitem>ATK_VALUE_GOOD</listitem>
* <listitem>ATK_VALUE_VERY_GOOD</listitem>
* <listitem>ATK_VALUE_BEST</listitem>
* <listitem>ATK_VALUE_SUBSUBOPTIMAL</listitem>
* <listitem>ATK_VALUE_SUBOPTIMAL</listitem>
* <listitem>ATK_VALUE_OPTIMAL</listitem>
* </itemizedlist>
* <para>
* Proposals for additional constants, along with their use cases,
* should be submitted to the GNOME Accessibility Team.
* </para>
* </refsect1>
*
* <refsect1 id="changes">
* <title>On the subject of changes</title>
* <para>
* Note that if there is a textual description associated with the new
* numeric value, that description should be included regardless of
* whether or not it has also changed.
* </para>
* </refsect1>
*/
static GPtrArray *value_type_names = NULL;
enum {
VALUE_CHANGED,
LAST_SIGNAL
};
/* These are listed here for extraction by intltool */
#if 0
/* Translators: This string describes a range within value-related
* widgets such as a password-strength meter. Note that what such a
* widget presents is controlled by application developers. Thus
* assistive technologies such as screen readers are expected to
* present this string alone or as a token in a list.
*/
N_("very weak")
/* Translators: This string describes a range within value-related
* widgets such as a password-strength meter. Note that what such a
* widget presents is controlled by application developers. Thus
* assistive technologies such as screen readers are expected to
* present this string alone or as a token in a list.
*/
N_("weak")
/* Translators: This string describes a range within value-related
* widgets such as a password-strength meter. Note that what such a
* widget presents is controlled by application developers. Thus
* assistive technologies such as screen readers are expected to
* present this string alone or as a token in a list.
*/
N_("acceptable")
/* Translators: This string describes a range within value-related
* widgets such as a password-strength meter. Note that what such a
* widget presents is controlled by application developers. Thus
* assistive technologies such as screen readers are expected to
* present this string alone or as a token in a list.
*/
N_("strong")
/* Translators: This string describes a range within value-related
* widgets such as a password-strength meter. Note that what such a
* widget presents is controlled by application developers. Thus
* assistive technologies such as screen readers are expected to
* present this string alone or as a token in a list.
*/
N_("very strong")
/* Translators: This string describes a range within value-related
* widgets such as a volume slider. Note that what such a widget
* presents (e.g. temperature, volume, price) is controlled by
* application developers. Thus assistive technologies such as screen
* readers are expected to present this string alone or as a token in
* a list.
*/
N_("very low")
/* Translators: This string describes a range within value-related
* widgets such as a volume slider. Note that what such a widget
* presents (e.g. temperature, volume, price) is controlled by
* application developers. Thus assistive technologies such as screen
* readers are expected to present this string alone or as a token in
* a list.
*/
N_("medium")
/* Translators: This string describes a range within value-related
* widgets such as a volume slider. Note that what such a widget
* presents (e.g. temperature, volume, price) is controlled by
* application developers. Thus assistive technologies such as screen
* readers are expected to present this string alone or as a token in
* a list.
*/
N_("high")
/* Translators: This string describes a range within value-related
* widgets such as a volume slider. Note that what such a widget
* presents (e.g. temperature, volume, price) is controlled by
* application developers. Thus assistive technologies such as screen
* readers are expected to present this string alone or as a token in
* a list.
*/
N_("very high")
/* Translators: This string describes a range within value-related
* widgets such as a hard drive usage. Note that what such a widget
* presents (e.g. hard drive usage, network traffic) is controlled by
* application developers. Thus assistive technologies such as screen
* readers are expected to present this string alone or as a token in
* a list.
*/
N_("very bad")
/* Translators: This string describes a range within value-related
* widgets such as a hard drive usage. Note that what such a widget
* presents (e.g. hard drive usage, network traffic) is controlled by
* application developers. Thus assistive technologies such as screen
* readers are expected to present this string alone or as a token in
* a list.
*/
N_("bad")
/* Translators: This string describes a range within value-related
* widgets such as a hard drive usage. Note that what such a widget
* presents (e.g. hard drive usage, network traffic) is controlled by
* application developers. Thus assistive technologies such as screen
* readers are expected to present this string alone or as a token in
* a list.
*/
N_("good")
/* Translators: This string describes a range within value-related
* widgets such as a hard drive usage. Note that what such a widget
* presents (e.g. hard drive usage, network traffic) is controlled by
* application developers. Thus assistive technologies such as screen
* readers are expected to present this string alone or as a token in
* a list.
*/
N_("very good")
/* Translators: This string describes a range within value-related
* widgets such as a hard drive usage. Note that what such a widget
* presents (e.g. hard drive usage, network traffic) is controlled by
* application developers. Thus assistive technologies such as screen
* readers are expected to present this string alone or as a token in
* a list.
*/
N_("best")
#endif
static void atk_value_base_init (AtkValueIface *class);
static guint atk_value_signals[LAST_SIGNAL] = {0};
GType
atk_value_get_type (void)
{
static GType type = 0;
if (!type) {
GTypeInfo tinfo =
{
sizeof (AtkValueIface),
(GBaseInitFunc) atk_value_base_init,
(GBaseFinalizeFunc) NULL,
};
type = g_type_register_static (G_TYPE_INTERFACE, "AtkValue", &tinfo, 0);
}
return type;
}
static void
atk_value_base_init (AtkValueIface *class)
{
static gboolean initialized = FALSE;
if (!initialized)
{
/**
* AtkValue::value-changed:
* @atkvalue: the object on which the signal was emitted.
* @value: the new value in a numerical form.
* @text: human readable text alternative (also called
* description) of this object. NULL if not available.
*
* The 'value-changed' signal is emitted when the current value
* that represent the object changes. @value is the numerical
* representation of this new value. @text is the human
* readable text alternative of @value, and can be NULL if it is
* not available. Note that if there is a textual description
* associated with the new numeric value, that description
* should be included regardless of whether or not it has also
* changed.
*
* Example: a password meter whose value changes as the user
* types their new password. Appropiate value text would be
* "weak", "acceptable" and "strong".
*
* Since: 2.12
*/
atk_value_signals[VALUE_CHANGED] =
g_signal_new ("value_changed",
ATK_TYPE_VALUE,
G_SIGNAL_RUN_LAST,
0,
(GSignalAccumulator) NULL, NULL,
atk_marshal_VOID__DOUBLE_STRING,
G_TYPE_NONE,
2, G_TYPE_DOUBLE, G_TYPE_STRING);
initialized = TRUE;
}
}
/**
* atk_value_get_value_and_text:
* @obj: a GObject instance that implements AtkValueIface
* @value: (out): address of #gdouble to put the current value of @obj
* @text: (out) (allow-none): address of #gchar to put the human
* readable text alternative for @value
*
* Gets the current value and the human readable text alternative of
* @obj. @text is a newly created string, that must be freed by the
* caller. Can be NULL if no descriptor is available.
*
* Since: 2.12
**/
void
atk_value_get_value_and_text (AtkValue *obj,
gdouble *value,
gchar **text)
{
AtkValueIface *iface;
g_return_if_fail (ATK_IS_VALUE (obj));
iface = ATK_VALUE_GET_IFACE (obj);
if (iface->get_value_and_text)
{
(iface->get_value_and_text) (obj, value, text);
}
else
{
*value = 0.0;
*text = NULL;
}
}
/**
* atk_value_get_range:
* @obj: a GObject instance that implements AtkValueIface
*
* Gets the range of this object.
*
* Returns: (nullable) (transfer full): a newly allocated #AtkRange
* that represents the minimum, maximum and descriptor (if available)
* of @obj. NULL if that range is not defined.
*
* Since: 2.12
**/
AtkRange*
atk_value_get_range (AtkValue *obj)
{
AtkValueIface *iface;
g_return_val_if_fail (ATK_IS_VALUE (obj), NULL);
iface = ATK_VALUE_GET_IFACE (obj);
if (iface->get_range)
{
return (iface->get_range) (obj);
}
else
return NULL;
}
/**
* atk_value_get_increment:
* @obj: a GObject instance that implements AtkValueIface
*
* Gets the minimum increment by which the value of this object may be
* changed. If zero, the minimum increment is undefined, which may
* mean that it is limited only by the floating point precision of the
* platform.
*
* Return value: the minimum increment by which the value of this
* object may be changed. zero if undefined.
*
* Since: 2.12
**/
gdouble
atk_value_get_increment (AtkValue *obj)
{
AtkValueIface *iface;
g_return_val_if_fail (ATK_IS_VALUE (obj), 0);
iface = ATK_VALUE_GET_IFACE (obj);
if (iface->get_increment)
{
return (iface->get_increment) (obj);
}
else
return 0;
}
/**
* atk_value_get_sub_ranges:
* @obj: a GObject instance that implements AtkValueIface
*
* Gets the list of subranges defined for this object. See #AtkValue
* introduction for examples of subranges and when to expose them.
*
* Returns: (element-type AtkRange) (transfer full): an #GSList of
* #AtkRange which each of the subranges defined for this object. Free
* the returns list with g_slist_free().
*
* Since: 2.12
**/
GSList*
atk_value_get_sub_ranges (AtkValue *obj)
{
AtkValueIface *iface;
g_return_val_if_fail (ATK_IS_VALUE (obj), NULL);
iface = ATK_VALUE_GET_IFACE (obj);
if (iface->get_sub_ranges)
{
return (iface->get_sub_ranges) (obj);
}
else
return NULL;
}
/**
* atk_value_set_value:
* @obj: a GObject instance that implements AtkValueIface
* @new_value: a double which is the desired new accessible value.
*
* Sets the value of this object.
*
* This method is intended to provide a way to change the value of the
* object. In any case, it is possible that the value can't be
* modified (ie: a read-only component). If the value changes due this
* call, it is possible that the text could change, and will trigger
* an #AtkValue::value-changed signal emission.
*
* Note for implementors: the deprecated atk_value_set_current_value()
* method returned TRUE or FALSE depending if the value was assigned
* or not. In the practice several implementors were not able to
* decide it, and returned TRUE in any case. For that reason it is not
* required anymore to return if the value was properly assigned or
* not.
*
* Since: 2.12
**/
void
atk_value_set_value (AtkValue *obj,
const gdouble new_value)
{
AtkValueIface *iface;
g_return_if_fail (ATK_IS_VALUE (obj));
iface = ATK_VALUE_GET_IFACE (obj);
if (iface->set_value)
{
(iface->set_value) (obj, new_value);
}
}
static void
initialize_value_type_names ()
{
GTypeClass *enum_class;
GEnumValue *enum_value;
int i;
gchar *value_type_name = NULL;
if (value_type_names)
return;
value_type_names = g_ptr_array_new ();
enum_class = g_type_class_ref (ATK_TYPE_VALUE_TYPE);
if (!G_IS_ENUM_CLASS(enum_class))
return;
for (i = 0; i < ATK_VALUE_LAST_DEFINED; i++)
{
enum_value = g_enum_get_value (G_ENUM_CLASS (enum_class), i);
value_type_name = g_strdup (enum_value->value_nick);
_compact_name (value_type_name);
g_ptr_array_add (value_type_names, value_type_name);
}
g_type_class_unref (enum_class);
}
/**
* atk_value_type_get_name:
* @value_type: The #AtkValueType whose name is required
*
* Gets the description string describing the #AtkValueType @value_type.
*
* Returns: the string describing the #AtkValueType
*/
const gchar*
atk_value_type_get_name (AtkValueType value_type)
{
g_return_val_if_fail (value_type >= 0, NULL);
if (!value_type_names)
initialize_value_type_names ();
if (value_type < value_type_names->len)
return g_ptr_array_index (value_type_names, value_type);
return NULL;
}
/**
* atk_value_type_get_localized_name:
* @value_type: The #AtkValueType whose localized name is required
*
* Gets the localized description string describing the #AtkValueType @value_type.
*
* Returns: the localized string describing the #AtkValueType
**/
const gchar*
atk_value_type_get_localized_name (AtkValueType value_type)
{
_gettext_initialization ();
return dgettext (GETTEXT_PACKAGE, atk_value_type_get_name (value_type));
}

96
atk/atkvalue.h Normal file
View File

@@ -0,0 +1,96 @@
/* ATK - Accessibility Toolkit
* Copyright 2001 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_VALUE_H__
#define __ATK_VALUE_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <atk/atkobject.h>
#include <atk/atkrange.h>
G_BEGIN_DECLS
#define ATK_TYPE_VALUE (atk_value_get_type ())
#define ATK_IS_VALUE(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_VALUE)
#define ATK_VALUE(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_VALUE, AtkValue)
#define ATK_VALUE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_VALUE, AtkValueIface))
#ifndef _TYPEDEF_ATK_VALUE_
#define _TYPEDEF_ATK_VALUE__
typedef struct _AtkValue AtkValue;
#endif
typedef struct _AtkValueIface AtkValueIface;
/**
* AtkValueIface:
* @get_value_and_text: gets the current value and the human readable
* text alternative (if available) of this object. Since 2.12.
* @get_range: gets the range that defines the minimum and maximum
* value of this object. Returns NULL if there is no range
* defined. Since 2.12.
* @get_increment: gets the minimum increment by which the value of
* this object may be changed. If zero it is undefined. Since 2.12.
* @get_sub_ranges: returns a list of different subranges, and their
* description (if available) of this object. Returns NULL if there
* is not subranges defined. Since 2.12.
* @set_value: sets the value of this object. Since 2.12.
*/
struct _AtkValueIface
{
GTypeInterface parent;
void (* get_value_and_text) (AtkValue *obj,
gdouble *value,
gchar **text);
AtkRange*(* get_range) (AtkValue *obj);
gdouble (* get_increment) (AtkValue *obj);
GSList* (* get_sub_ranges) (AtkValue *obj);
void (* set_value) (AtkValue *obj,
const gdouble new_value);
};
GDK_AVAILABLE_IN_ALL
GType atk_value_get_type (void);
GDK_AVAILABLE_IN_ALL
void atk_value_get_value_and_text (AtkValue *obj,
gdouble *value,
gchar **text);
GDK_AVAILABLE_IN_ALL
AtkRange* atk_value_get_range (AtkValue *obj);
GDK_AVAILABLE_IN_ALL
gdouble atk_value_get_increment (AtkValue *obj);
GDK_AVAILABLE_IN_ALL
GSList* atk_value_get_sub_ranges (AtkValue *obj);
GDK_AVAILABLE_IN_ALL
void atk_value_set_value (AtkValue *obj,
const gdouble new_value);
/* AtkValueType methods */
GDK_AVAILABLE_IN_ALL
const gchar* atk_value_type_get_name (AtkValueType value_type);
GDK_AVAILABLE_IN_ALL
const gchar* atk_value_type_get_localized_name (AtkValueType value_type);
G_END_DECLS
#endif /* __ATK_VALUE_H__ */

168
atk/atkwindow.c Normal file
View File

@@ -0,0 +1,168 @@
/* ATK - Accessibility Toolkit
* Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "atkwindow.h"
#include "atkmarshal.h"
/**
* SECTION:atkwindow
* @Short_description: The ATK Interface provided by UI components that represent a top-level window.
* @Title: AtkWindow
* @See_also: #AtkObject
*
* #AtkWindow should be implemented by the UI elements that represent
* a top-level window, such as the main window of an application or
* dialog.
*
*/
enum {
ACTIVATE,
CREATE,
DEACTIVATE,
DESTROY,
MAXIMIZE,
MINIMIZE,
MOVE,
RESIZE,
RESTORE,
LAST_SIGNAL
};
static guint atk_window_signals[LAST_SIGNAL] = { 0 };
static guint
atk_window_add_signal (const gchar *name)
{
return g_signal_new (name,
ATK_TYPE_WINDOW,
G_SIGNAL_RUN_LAST,
0,
(GSignalAccumulator) NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
}
typedef AtkWindowIface AtkWindowInterface;
G_DEFINE_INTERFACE (AtkWindow, atk_window, ATK_TYPE_OBJECT)
static void
atk_window_default_init (AtkWindowIface *iface)
{
static gboolean initialized = FALSE;
if (!initialized)
{
/**
* AtkWindow::activate:
* @object: the object which received the signal
*
* The signal #AtkWindow::activate is emitted when a window
* becomes the active window of the application or session.
*
* Since: 2.2
*/
atk_window_signals[ACTIVATE] = atk_window_add_signal ("activate");
/**
* AtkWindow::create:
* @object: the object which received the signal
*
* The signal #AtkWindow::create is emitted when a new window
* is created.
*
* Since: 2.2
*/
atk_window_signals[CREATE] = atk_window_add_signal ("create");
/**
* AtkWindow::deactivate:
* @object: the object which received the signal
*
* The signal #AtkWindow::deactivate is emitted when a window is
* no longer the active window of the application or session.
*
* Since: 2.2
*/
atk_window_signals[DEACTIVATE] = atk_window_add_signal ("deactivate");
/**
* AtkWindow::destroy:
* @object: the object which received the signal
*
* The signal #AtkWindow::destroy is emitted when a window is
* destroyed.
*
* Since: 2.2
*/
atk_window_signals[DESTROY] = atk_window_add_signal ("destroy");
/**
* AtkWindow::maximize:
* @object: the object which received the signal
*
* The signal #AtkWindow::maximize is emitted when a window
* is maximized.
*
* Since: 2.2
*/
atk_window_signals[MAXIMIZE] = atk_window_add_signal ("maximize");
/**
* AtkWindow::minimize:
* @object: the object which received the signal
*
* The signal #AtkWindow::minimize is emitted when a window
* is minimized.
*
* Since: 2.2
*/
atk_window_signals[MINIMIZE] = atk_window_add_signal ("minimize");
/**
* AtkWindow::move:
* @object: the object which received the signal
*
* The signal #AtkWindow::move is emitted when a window
* is moved.
*
* Since: 2.2
*/
atk_window_signals[MOVE] = atk_window_add_signal ("move");
/**
* AtkWindow::resize:
* @object: the object which received the signal
*
* The signal #AtkWindow::resize is emitted when a window
* is resized.
*
* Since: 2.2
*/
atk_window_signals[RESIZE] = atk_window_add_signal ("resize");
/**
* AtkWindow::restore:
* @object: the object which received the signal
*
* The signal #AtkWindow::restore is emitted when a window
* is restored.
*
* Since: 2.2
*/
atk_window_signals[RESTORE] = atk_window_add_signal ("restore");
initialized = TRUE;
}
}

53
atk/atkwindow.h Normal file
View File

@@ -0,0 +1,53 @@
/* ATK - Accessibility Toolkit
* Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __ATK_WINDOW_H__
#define __ATK_WINDOW_H__
#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <atk/atk.h> can be included directly."
#endif
#include <atk/atkobject.h>
G_BEGIN_DECLS
/*
* AtkWindow describes signals pertaining to on-screen windows.
*/
#define ATK_TYPE_WINDOW (atk_window_get_type ())
#define ATK_IS_WINDOW(obj) G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_WINDOW)
#define ATK_WINDOW(obj) G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_WINDOW, AtkWindow)
#define ATK_WINDOW_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_WINDOW, AtkWindowIface))
typedef struct _AtkWindow AtkWindow; /* Dummy typedef */
typedef struct _AtkWindowIface AtkWindowIface;
struct _AtkWindowIface
{
GTypeInterface parent;
};
GDK_AVAILABLE_IN_ALL
GType atk_window_get_type (void);
G_END_DECLS
#endif /* __ATK_WINDOW_H__ */

114
atk/meson.build Normal file
View File

@@ -0,0 +1,114 @@
atk_public_sources = files([
'atkaction.c',
'atkcomponent.c',
'atkdocument.c',
'atkeditabletext.c',
'atkgobjectaccessible.c',
'atkhyperlink.c',
'atkhyperlinkimpl.c',
'atkhypertext.c',
'atkimage.c',
'atknoopobject.c',
'atknoopobjectfactory.c',
'atkobject.c',
'atkobjectfactory.c',
'atkplug.c',
'atkprivate.c',
'atkrange.c',
'atkregistry.c',
'atkrelation.c',
'atkrelationset.c',
'atkselection.c',
'atksocket.c',
'atkstate.c',
'atkstateset.c',
'atkstreamablecontent.c',
'atktable.c',
'atktablecell.c',
'atktext.c',
'atkutil.c',
'atkvalue.c',
'atkwindow.c',
])
atk_public_headers = files([
'atkaction.h',
'atkcomponent.h',
'atkdocument.h',
'atkeditabletext.h',
'atkenums.h',
'atkgobjectaccessible.h',
'atkhyperlink.h',
'atkhyperlinkimpl.h',
'atkhypertext.h',
'atkimage.h',
'atknoopobject.h',
'atknoopobjectfactory.h',
'atkobject.h',
'atkobjectfactory.h',
'atkplug.h',
'atkrange.h',
'atkregistry.h',
'atkrelation.h',
'atkrelationset.h',
'atkselection.h',
'atksocket.h',
'atkstate.h',
'atkstateset.h',
'atkstreamablecontent.h',
'atktable.h',
'atktablecell.h',
'atktext.h',
'atktypes.h',
'atkutil.h',
'atkvalue.h',
'atkwindow.h',
])
install_headers(atk_public_headers + ['atk.h'], subdir: 'gtk-4.0/atk')
# Marshallers
atk_marshals = gnome.genmarshal('atkmarshal',
sources: 'atkmarshal.list',
prefix: 'atk_marshal',
)
atk_marshal_h = atk_marshals[1]
# Enumerations for GType
atk_enums = gnome.mkenums('atkenumtypes',
sources: atk_public_headers,
c_template: 'atkenumtypes.c.template',
h_template: 'atkenumtypes.h.template',
install_dir: gtk_includedir / 'gtk-4.0' / 'atk',
install_header: true,
)
atk_enum_h = atk_enums[1]
atk_deps = [
libgdk_dep,
]
libatk = static_library('atk',
sources: [atk_public_sources, atk_enums, atk_marshals],
dependencies: atk_deps,
include_directories: [confinc, ],
c_args: [
'-DGTK_COMPILATION',
'-DG_LOG_DOMAIN="Atk"',
'-DG_LOG_USE_STRUCTURED=1',
'-DGLIB_DISABLE_DEPRECATION_WARNINGS',
'-DATK_DISABLE_DEPRECATION_WARNINGS',
'-DATK_LOCALEDIR="@0@"'.format(join_paths(gtk_datadir, 'locale')),
],
link_with: libgdk,
link_args: common_ldflags,
)
# We don't have link_with: to internal static libs here on purpose, just
# list the dependencies and generated headers and such, for use in the
# "public" libgtk_dep used by internal executables.
libatk_dep = declare_dependency(
include_directories: confinc,
sources: [atk_enum_h],
dependencies: libgdk_dep,
)

View File

@@ -119,48 +119,76 @@ get_image_paintable (GtkImage *image)
}
static void
drag_begin (GtkWidget *widget,
GdkDrag *drag,
gpointer data)
drag_begin (GtkDragSource *source,
GdkDrag *drag,
GtkWidget *widget)
{
GdkPaintable *paintable;
paintable = get_image_paintable (GTK_IMAGE (widget));
if (paintable)
{
gtk_drag_set_icon_paintable (drag, paintable, -2, -2);
gtk_drag_source_set_icon (source, paintable, -2, -2);
g_object_unref (paintable);
}
}
void
drag_data_get (GtkWidget *widget,
GdkDrag *drag,
GtkSelectionData *selection_data,
guint info,
gpointer data)
static void
get_texture (GValue *value,
gpointer data)
{
GdkPaintable *paintable;
GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (data));
paintable = get_image_paintable (GTK_IMAGE (widget));
if (GDK_IS_TEXTURE (paintable))
gtk_selection_data_set_texture (selection_data, GDK_TEXTURE (paintable));
g_value_set_object (value, paintable);
}
static GdkContentProvider *
prepare_drag (GtkDragSource *source,
double x,
double y,
GtkWidget *image)
{
return gdk_content_provider_new_with_callback (GDK_TYPE_TEXTURE, get_texture, image);
}
static void
drag_data_received (GtkWidget *widget,
GdkDrop *drop,
GtkSelectionData *selection_data,
gpointer data)
got_texture (GObject *source,
GAsyncResult *result,
gpointer data)
{
if (gtk_selection_data_get_length (selection_data) > 0)
{
GdkTexture *texture;
GdkDrop *drop = GDK_DROP (source);
GtkWidget *image = data;
const GValue *value;
GError *error = NULL;
texture = gtk_selection_data_get_texture (selection_data);
gtk_image_set_from_paintable (GTK_IMAGE (data), GDK_PAINTABLE (texture));
g_object_unref (texture);
value = gdk_drop_read_value_finish (drop, result, &error);
if (value)
{
GdkTexture *texture = g_value_get_object (value);
gtk_image_set_from_paintable (GTK_IMAGE (image), GDK_PAINTABLE (texture));
}
else
{
g_print ("Failed to get data: %s\n", error->message);
g_error_free (error);
}
}
static gboolean
drag_drop (GtkDropTarget *dest,
GdkDrop *drop,
int x,
int y,
GtkWidget *widget)
{
if (gdk_drop_has_value (drop, GDK_TYPE_TEXTURE))
{
gdk_drop_read_value_async (drop, GDK_TYPE_TEXTURE, G_PRIORITY_DEFAULT, NULL, got_texture, widget);
return TRUE;
}
return FALSE;
}
static void
@@ -171,12 +199,8 @@ copy_image (GSimpleAction *action,
GdkClipboard *clipboard = gtk_widget_get_clipboard (GTK_WIDGET (data));
GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (data));
g_print ("copy image\n");
if (GDK_IS_TEXTURE (paintable))
{
g_print ("set clipboard\n");
gdk_clipboard_set_texture (clipboard, GDK_TEXTURE (paintable));
}
gdk_clipboard_set_texture (clipboard, GDK_TEXTURE (paintable));
if (paintable)
g_object_unref (paintable);
@@ -247,6 +271,9 @@ do_clipboard (GtkWidget *do_widget)
{ "paste", paste_image, NULL, NULL, NULL },
};
GActionGroup *actions;
GtkDragSource *source;
GtkDropTarget *dest;
GdkContentFormats *formats;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_display (GTK_WINDOW (window),
@@ -305,22 +332,21 @@ do_clipboard (GtkWidget *do_widget)
/* Create the first image */
image = gtk_image_new_from_icon_name ("dialog-warning");
gtk_image_set_pixel_size (GTK_IMAGE (image), 48);
gtk_container_add (GTK_CONTAINER (hbox), image);
/* make image a drag source */
gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
gtk_drag_source_add_image_targets (image);
g_signal_connect (image, "drag-begin",
G_CALLBACK (drag_begin), image);
g_signal_connect (image, "drag-data-get",
G_CALLBACK (drag_data_get), image);
source = gtk_drag_source_new ();
g_signal_connect (source, "prepare", G_CALLBACK (prepare_drag), NULL);
g_signal_connect (source, "drag-begin", G_CALLBACK (drag_begin), image);
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
/* accept drops on image */
gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL,
NULL, GDK_ACTION_COPY);
gtk_drag_dest_add_image_targets (image);
g_signal_connect (image, "drag-data-received",
G_CALLBACK (drag_data_received), image);
formats = gdk_content_formats_new_for_gtype (GDK_TYPE_TEXTURE);
dest = gtk_drop_target_new (formats, GDK_ACTION_COPY);
gdk_content_formats_unref (formats);
g_signal_connect (dest, "drag-drop", G_CALLBACK (drag_drop), image);
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (dest));
/* context menu on image */
gesture = gtk_gesture_click_new ();
@@ -337,22 +363,21 @@ do_clipboard (GtkWidget *do_widget)
/* Create the second image */
image = gtk_image_new_from_icon_name ("process-stop");
gtk_image_set_pixel_size (GTK_IMAGE (image), 48);
gtk_container_add (GTK_CONTAINER (hbox), image);
/* make image a drag source */
gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
gtk_drag_source_add_image_targets (image);
g_signal_connect (image, "drag-begin",
G_CALLBACK (drag_begin), image);
g_signal_connect (image, "drag-data-get",
G_CALLBACK (drag_data_get), image);
source = gtk_drag_source_new ();
g_signal_connect (source, "prepare", G_CALLBACK (prepare_drag), NULL);
g_signal_connect (source, "drag-begin", G_CALLBACK (drag_begin), image);
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
/* accept drops on image */
gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL,
NULL, GDK_ACTION_COPY);
gtk_drag_dest_add_image_targets (image);
g_signal_connect (image, "drag-data-received",
G_CALLBACK (drag_data_received), image);
formats = gdk_content_formats_new_for_gtype (GDK_TYPE_TEXTURE);
dest = gtk_drop_target_new (formats, GDK_ACTION_COPY);
gdk_content_formats_unref (formats);
g_signal_connect (dest, "drag-drop", G_CALLBACK (drag_drop), image);
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (dest));
/* context menu on image */
gesture = gtk_gesture_click_new ();

View File

@@ -97,6 +97,7 @@ do_infobar (GtkWidget *do_widget)
gtk_label_set_wrap (GTK_LABEL (label), TRUE);
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))), label);
gtk_info_bar_set_default_response (GTK_INFO_BAR (bar), GTK_RESPONSE_OK);
button = gtk_toggle_button_new_with_label ("Question");
g_object_bind_property (bar, "revealed", button, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);

View File

@@ -5,9 +5,6 @@
#include <gtk/gtk.h>
/* Drag 'n Drop */
static const char *target_table[] = {
"text/uri-list"
};
typedef struct
{
@@ -76,30 +73,11 @@ search_text_changed (GtkEntry *entry, IconBrowserWindow *win)
gtk_tree_model_filter_refilter (win->filter_model);
}
static GdkPixbuf *
get_icon (GtkWidget *image, const gchar *name, gint size)
{
GtkIconInfo *info;
GtkStyleContext *context;
GdkTexture *texture;
GdkPixbuf *pixbuf;
context = gtk_widget_get_style_context (image);
info = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_default (), name, size, 0);
texture = GDK_TEXTURE (gtk_icon_info_load_symbolic_for_context (info, context, NULL, NULL));
pixbuf = gdk_pixbuf_get_from_texture (texture);
g_object_unref (texture);
g_object_unref (info);
return pixbuf;
}
static void
set_image (GtkWidget *image, const gchar *name, gint size)
{
gtk_image_set_from_icon_name (GTK_IMAGE (image), name);
gtk_image_set_pixel_size (GTK_IMAGE (image), size);
gtk_drag_source_set_icon_name (image, name);
}
static void
@@ -365,78 +343,107 @@ search_mode_toggled (GObject *searchbar, GParamSpec *pspec, IconBrowserWindow *w
gtk_list_box_unselect_all (GTK_LIST_BOX (win->context_list));
}
static void
get_image_data (GtkWidget *widget,
GdkDrag *drag,
GtkSelectionData *selection,
guint target_info,
gpointer data)
static GdkPaintable *
get_image_paintable (GtkImage *image)
{
GtkWidget *image;
const gchar *name;
gint size;
GdkPixbuf *pixbuf;
const gchar *icon_name;
GtkIconTheme *icon_theme;
GtkIconInfo *icon_info;
int size;
image = gtk_bin_get_child (GTK_BIN (widget));
name = gtk_image_get_icon_name (GTK_IMAGE (image));
size = gtk_image_get_pixel_size (GTK_IMAGE (image));
pixbuf = get_icon (image, name, size);
gtk_selection_data_set_pixbuf (selection, pixbuf);
g_object_unref (pixbuf);
switch (gtk_image_get_storage_type (image))
{
case GTK_IMAGE_PAINTABLE:
return g_object_ref (gtk_image_get_paintable (image));
case GTK_IMAGE_ICON_NAME:
icon_name = gtk_image_get_icon_name (image);
size = gtk_image_get_pixel_size (image);
icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (image)));
icon_info = gtk_icon_theme_lookup_icon (icon_theme, icon_name, size,
GTK_ICON_LOOKUP_FORCE_SIZE | GTK_ICON_LOOKUP_GENERIC_FALLBACK);
if (icon_info == NULL)
return NULL;
return gtk_icon_info_load_icon (icon_info, NULL);
default:
g_warning ("Image storage type %d not handled",
gtk_image_get_storage_type (image));
return NULL;
}
}
static void
get_scalable_image_data (GtkWidget *widget,
GdkDrag *drag,
GtkSelectionData *selection,
guint target_info,
gpointer data)
drag_begin (GtkDragSource *source,
GdkDrag *drag,
GtkWidget *widget)
{
gchar *uris[2];
GtkIconInfo *info;
GtkWidget *image;
GFile *file;
const gchar *name;
GdkPaintable *paintable;
image = gtk_bin_get_child (GTK_BIN (widget));
name = gtk_image_get_icon_name (GTK_IMAGE (image));
paintable = get_image_paintable (GTK_IMAGE (widget));
if (paintable)
{
int w, h;
w = gdk_paintable_get_intrinsic_width (paintable);
h = gdk_paintable_get_intrinsic_height (paintable);
gtk_drag_source_set_icon (source, paintable, w, h);
g_object_unref (paintable);
}
}
static void
get_texture (GValue *value,
gpointer data)
{
GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (data));
if (GDK_IS_TEXTURE (paintable))
g_value_set_object (value, paintable);
}
static void
get_file (GValue *value,
gpointer data)
{
const char *name;
GtkIconInfo *info;
GFile *file;
name = gtk_image_get_icon_name (GTK_IMAGE (data));
info = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_default (), name, -1, 0);
file = g_file_new_for_path (gtk_icon_info_get_filename (info));
uris[0] = g_file_get_uri (file);
uris[1] = NULL;
gtk_selection_data_set_uris (selection, uris);
g_free (uris[0]);
g_object_unref (info);
g_value_set_object (value, file);
g_object_unref (file);
g_object_unref (info);
}
static void
setup_image_dnd (GtkWidget *image)
{
gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
gtk_drag_source_add_image_targets (image);
g_signal_connect (image, "drag-data-get", G_CALLBACK (get_image_data), NULL);
GdkContentProvider *content;
GtkDragSource *source;
source = gtk_drag_source_new ();
content = gdk_content_provider_new_with_callback (GDK_TYPE_TEXTURE, get_texture, image);
gtk_drag_source_set_content (source, content);
g_object_unref (content);
g_signal_connect (source, "drag-begin", G_CALLBACK (drag_begin), image);
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
}
static void
setup_scalable_image_dnd (GtkWidget *image)
{
GtkWidget *parent;
GdkContentFormats *targets;
GdkContentProvider *content;
GtkDragSource *source;
parent = gtk_widget_get_parent (image);
targets = gdk_content_formats_new (target_table, G_N_ELEMENTS (target_table));
gtk_drag_source_set (parent, GDK_BUTTON1_MASK,
targets,
GDK_ACTION_COPY);
gdk_content_formats_unref (targets);
source = gtk_drag_source_new ();
content = gdk_content_provider_new_with_callback (G_TYPE_FILE, get_file, image);
gtk_drag_source_set_content (source, content);
g_object_unref (content);
g_signal_connect (parent, "drag-data-get", G_CALLBACK (get_scalable_image_data), NULL);
g_signal_connect (source, "drag-begin", G_CALLBACK (drag_begin), image);
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
}
static void
@@ -446,8 +453,7 @@ icon_browser_window_init (IconBrowserWindow *win)
gtk_widget_init_template (GTK_WIDGET (win));
list = gdk_content_formats_new (NULL, 0);
list = gtk_content_formats_add_text_targets (list);
list = gdk_content_formats_new_for_gtype (G_TYPE_STRING);
gtk_icon_view_enable_model_drag_source (GTK_ICON_VIEW (win->list),
GDK_BUTTON1_MASK,
list,
@@ -459,7 +465,6 @@ icon_browser_window_init (IconBrowserWindow *win)
setup_image_dnd (win->image3);
setup_image_dnd (win->image4);
setup_image_dnd (win->image5);
setup_image_dnd (win->image6);
setup_scalable_image_dnd (win->image6);
win->contexts = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, context_free);

View File

@@ -344,6 +344,13 @@
<xi:include href="xml/gtkpadcontroller.xml" />
</chapter>
<chapter>
<title>Data exchange, clipboards and Drag-and-Drop</title>
<xi:include href="xml/gtkdragsource.xml"/>
<xi:include href="xml/gtkdragicon.xml"/>
<xi:include href="xml/gtkdroptarget.xml"/>
</chapter>
</part>
<part id="gtkbase">
@@ -352,7 +359,6 @@
<xi:include href="xml/gtkfeatures.xml" />
<xi:include href="xml/gtkaccelgroup.xml" />
<xi:include href="xml/gtkaccelmap.xml" />
<xi:include href="xml/gtkdnd.xml" />
<xi:include href="xml/gtksettings.xml" />
<xi:include href="xml/gtkbindings.xml" />
<xi:include href="xml/gtkenums.xml" />

View File

@@ -5001,49 +5001,6 @@ GTK_TYPE_SELECTION_DATA
gtk_selection_data_get_type
</SECTION>
<SECTION>
<FILE>gtkdnd</FILE>
<TITLE>Drag and Drop</TITLE>
GtkDestDefaults
GtkDragResult
<SUBSECTION Destination Side>
gtk_drag_dest_set
gtk_drag_dest_unset
gtk_drag_dest_find_target
gtk_drag_dest_get_target_list
gtk_drag_dest_set_target_list
gtk_drag_dest_add_text_targets
gtk_drag_dest_add_image_targets
gtk_drag_dest_add_uri_targets
gtk_drag_dest_set_track_motion
gtk_drag_dest_get_track_motion
gtk_drag_get_data
gtk_drag_get_source_widget
gtk_drag_highlight
gtk_drag_unhighlight
<SUBSECTION Source Side>
gtk_drag_begin
gtk_drag_cancel
gtk_drag_set_icon_widget
gtk_drag_set_icon_paintable
gtk_drag_set_icon_name
gtk_drag_set_icon_gicon
gtk_drag_set_icon_default
gtk_drag_check_threshold
gtk_drag_source_set
gtk_drag_source_set_icon_name
gtk_drag_source_set_icon_gicon
gtk_drag_source_set_icon_paintable
gtk_drag_source_unset
gtk_drag_source_set_target_list
gtk_drag_source_get_target_list
gtk_drag_source_add_text_targets
gtk_drag_source_add_image_targets
gtk_drag_source_add_uri_targets
</SECTION>
<SECTION>
<FILE>gtkbindings</FILE>
<TITLE>Bindings</TITLE>
@@ -7191,3 +7148,69 @@ gtk_constraint_guide_get_max_size
GTK_TYPE_CONSTRAINT_GUIDE
gtk_constraint_guide_get_tyoe
</SECTION>
<SECTION>
<FILE>gtkdragsource</FILE>
GtkDragSource
gtk_drag_source_new
gtk_drag_source_set_content
gtk_drag_source_get_content
gtk_drag_source_set_actions
gtk_drag_source_get_actions
gtk_drag_source_set_icon
gtk_drag_source_drag_cancel
gtk_drag_source_get_drag
gtk_drag_check_threshold
<SUBSECTION Standard>
GTK_TYPE_DRAG_SOURCE
GTK_DRAG_SOURCE
GTK_DRAG_SOURCE_CLASS
GTK_IS_DRAG_SOURCE
GTK_IS_DRAG_SOURCE_CLASS
GTK_DRAG_SOURCE_GET_CLASS
<SUBSECTION Private>
gtk_drag_source_get_type
</SECTION>
<SECTION>
<FILE>gtkdroptarget</FILE>
GtkDropTarget
gtk_drop_target_new
gtk_drop_target_set_formats
gtk_drop_target_get_formats
gtk_drop_target_set_actions
gtk_drop_target_get_actions
gtk_drop_target_get_drop
gtk_drop_target_find_mimetype
gtk_drop_target_read_selection
gtk_drop_target_read_selection_finish
gtk_drag_highlight
gtk_drag_unhighlight
<SUBSECTION Standard>
GTK_TYPE_DROP_TARGET
GTK_DROP_TARGET
GTK_DROP_TARGET_CLASS
GTK_IS_DROP_TARGET
GTK_IS_DROP_TARGET_CLASS
GTK_DROP_TARGET_GET_CLASS
<SUBSECTION Private>
gtk_drop_target_get_type
</SECTION>
<SECTION>
<FILE>gtkdragicon</FILE>
GtkDragIcon
gtk_drag_icon_new_for_drag
gtk_drag_icon_set_from_paintable
<SUBSECTION Standard>
GTK_TYPE_DRAG_ICON
GTK_DRAG_ICON
GTK_DRAG_ICON_CLASS
GTK_IS_DRAG_ICON
GTK_IS_DRAG_ICON_CLASS
GTK_DRAG_ICON_GET_CLASS
<SUBSECTION Private>
gtk_drag_icon_get_type
</SECTION>

View File

@@ -57,7 +57,10 @@ gtk_constraint_target_get_type
gtk_container_get_type
gtk_css_provider_get_type
gtk_dialog_get_type
gtk_drag_icon_get_type
gtk_drag_source_get_type
gtk_drawing_area_get_type
gtk_drop_target_get_type
gtk_editable_get_type
gtk_entry_buffer_get_type
gtk_entry_completion_get_type

View File

@@ -48,7 +48,6 @@ private_headers = [
'gtkcssfontfeaturesvalueprivate.h',
'gtkcssfontvariationsvalueprivate.h',
'gtkcssiconthemevalueprivate.h',
'gtkcssimagebuiltinprivate.h',
'gtkcssimagecrossfadeprivate.h',
'gtkcssimagefallbackprivate.h',
'gtkcssimageiconthemeprivate.h',
@@ -97,7 +96,6 @@ private_headers = [
'gtkcsswidgetnodeprivate.h',
'gtkcsswin32sizevalueprivate.h',
'gtkdialogprivate.h',
'gtkdndprivate.h',
'gtkentryprivate.h',
'gtkeventcontrollerlegacyprivate.h',
'gtkeventcontrollerprivate.h',

View File

@@ -903,6 +903,37 @@
gtk_tooltip_set_custom().
</para>
</section>
<section>
<title>Switch to the new DND api</title>
<para>
The source-side DND apis in GTK 4 have been changed to use an event controller, #GtkDragSource.
</para>
<para>
Instead of calling gtk_drag_source_set() and connecting to #GtkWidget signals, you create
a #GtkDragSource object, attach it to the widget with gtk_widget_add_controller(), and connect
to #GtkDragSource signals. Instead of calling gtk_drag_begin() on a widget to start a drag
manually, call gdk_drag_begin().
</para>
<para>
The ::drag-data-get signal has been replaced by the #GtkDragSource::prepare signal, which
returns a #GdkContentProvider for the drag operation.
</para>
<para>
The destination-side DND apis in GTK 4 have also been changed to use and event controller,
#GTkDropTarget.
</para>
<para>
Instead of calling gtk_drag_dest_set() and connecting to #GtkWidget signals, you create
a #GtkDropTarget object, attach it to the widget with gtk_widget_add_controller(), and
connect to #GtkDropTarget signals.
</para>
<para>
The ::drag-motion signal has been renamed to #GtkDragSource::accept, and instead of
::drag-data-received, you need to use async read methods on the #GdkDrop object, such
as gdk_drop_read_value_async() or gdk_drop_read_text_async().
</para>
</section>
</section>
</chapter>

View File

@@ -42,29 +42,116 @@
#include "filetransferportalprivate.h"
static GDBusProxy *file_transfer_proxy = NULL;
static gboolean done;
static guint timeout_id;
static void
got_proxy (GObject *source,
GAsyncResult *result,
gpointer data)
{
GError *error = NULL;
file_transfer_proxy = g_dbus_proxy_new_for_bus_finish (result, &error);
if (!file_transfer_proxy)
{
g_message ("failed to get file transfer portal proxy: %s", error->message);
g_error_free (error);
}
if (timeout_id)
{
g_source_remove (timeout_id);
timeout_id = 0;
}
done = TRUE;
g_main_context_wakeup (NULL);
}
static void
got_bus (GObject *source,
GAsyncResult *result,
gpointer data)
{
GDBusConnection **bus = data;
GError *error = NULL;
*bus = g_bus_get_finish (result, &error);
if (!*bus)
{
g_message ("failed to get session bus connection: %s", error->message);
g_error_free (error);
}
if (timeout_id)
{
g_source_remove (timeout_id);
timeout_id = 0;
}
done = TRUE;
g_main_context_wakeup (NULL);
}
static gboolean
give_up_on_proxy (gpointer data)
{
GCancellable *cancellable = data;
g_cancellable_cancel (cancellable);
timeout_id = 0;
done = TRUE;
g_main_context_wakeup (NULL);
return G_SOURCE_REMOVE;
}
static GDBusProxy *
ensure_file_transfer_portal (void)
{
if (file_transfer_proxy == NULL)
{
GError *error = NULL;
GCancellable *cancellable;
GDBusConnection *bus = NULL;
file_transfer_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES
| G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS
| G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
NULL,
"org.freedesktop.portal.Documents",
"/org/freedesktop/portal/documents",
"org.freedesktop.portal.FileTransfer",
NULL, &error);
cancellable = g_cancellable_new ();
done = FALSE;
timeout_id = g_timeout_add (500, give_up_on_proxy, cancellable);
g_bus_get (G_BUS_TYPE_SESSION,
cancellable,
got_bus,
&bus);
if (error)
while (!done)
g_main_context_iteration (NULL, TRUE);
if (bus)
{
g_debug ("Failed to get proxy: %s", error->message);
g_error_free (error);
done = FALSE;
timeout_id = g_timeout_add (500, give_up_on_proxy, cancellable);
g_dbus_proxy_new (bus,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES
| G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS
| G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
NULL,
"org.freedesktop.portal.Documents",
"/org/freedesktop/portal/documents",
"org.freedesktop.portal.FileTransfer",
cancellable,
got_proxy,
NULL);
while (!done)
g_main_context_iteration (NULL, TRUE);
g_clear_object (&bus);
}
g_clear_object (&cancellable);
}
if (file_transfer_proxy)

View File

@@ -24,6 +24,7 @@
#include "gdkcontentformats.h"
#include "filetransferportalprivate.h"
#include "gdktexture.h"
#include "gdkrgbaprivate.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
@@ -848,6 +849,63 @@ file_uri_deserializer (GdkContentDeserializer *deserializer)
g_object_unref (output);
}
static void
color_deserializer_finish (GObject *source,
GAsyncResult *result,
gpointer deserializer)
{
GOutputStream *stream = G_OUTPUT_STREAM (source);
GError *error = NULL;
gssize written;
written = g_output_stream_splice_finish (stream, result, &error);
if (written < 0)
{
gdk_content_deserializer_return_error (deserializer, error);
return;
}
else if (written == 0)
{
GdkRGBA black = GDK_RGBA ("000");
/* Never return NULL, we only return that on error */
g_value_set_boxed (gdk_content_deserializer_get_value (deserializer), &black);
}
else
{
guint16 *data;
GdkRGBA rgba;
data = (guint16 *)g_memory_output_stream_get_data (G_MEMORY_OUTPUT_STREAM (stream));
rgba.red = data[0] / 65535.0;
rgba.green = data[1] / 65535.0;
rgba.blue = data[2] / 65535.0;
rgba.alpha = data[3] / 65535.0;
g_value_set_boxed (gdk_content_deserializer_get_value (deserializer), &rgba);
}
gdk_content_deserializer_return_success (deserializer);
}
static void
color_deserializer (GdkContentDeserializer *deserializer)
{
GOutputStream *output;
guint16 *data;
data = g_new0 (guint16, 4);
output = g_memory_output_stream_new (data, 4 * sizeof (guint16), NULL, g_free);
g_output_stream_splice_async (output,
gdk_content_deserializer_get_input_stream (deserializer),
G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
gdk_content_deserializer_get_priority (deserializer),
gdk_content_deserializer_get_cancellable (deserializer),
color_deserializer_finish,
deserializer);
g_object_unref (output);
}
static void
init (void)
{
@@ -956,5 +1014,11 @@ init (void)
string_deserializer,
(gpointer) "ASCII",
NULL);
gdk_content_register_deserializer ("application/x-color",
GDK_TYPE_RGBA,
color_deserializer,
NULL,
NULL);
}

View File

@@ -21,6 +21,7 @@
#include "gdkcontentprovider.h"
#include "gdkcontentformats.h"
#include "gdkcontentserializer.h"
#include "gdkintl.h"
#include "gdkcontentproviderimpl.h"
@@ -280,3 +281,232 @@ gdk_content_provider_new_for_bytes (const char *mime_type,
return GDK_CONTENT_PROVIDER (content);
}
#define GDK_TYPE_CONTENT_PROVIDER_CALLBACK (gdk_content_provider_callback_get_type ())
#define GDK_CONTENT_PROVIDER_CALLBACK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_CONTENT_PROVIDER_CALLBACK, GdkContentProviderCallback))
typedef struct _GdkContentProviderCallback GdkContentProviderCallback;
typedef struct _GdkContentProviderCallbackClass GdkContentProviderCallbackClass;
struct _GdkContentProviderCallback
{
GdkContentProvider parent;
GType type;
GdkContentProviderGetValueFunc func;
gpointer data;
};
struct _GdkContentProviderCallbackClass
{
GdkContentProviderClass parent_class;
};
GType gdk_content_provider_callback_get_type (void) G_GNUC_CONST;
G_DEFINE_TYPE (GdkContentProviderCallback, gdk_content_provider_callback, GDK_TYPE_CONTENT_PROVIDER)
static GdkContentFormats *
gdk_content_provider_callback_ref_formats (GdkContentProvider *provider)
{
GdkContentProviderCallback *callback = GDK_CONTENT_PROVIDER_CALLBACK (provider);
return gdk_content_formats_new_for_gtype (callback->type);
}
static gboolean
gdk_content_provider_callback_get_value (GdkContentProvider *provider,
GValue *value,
GError **error)
{
GdkContentProviderCallback *callback = GDK_CONTENT_PROVIDER_CALLBACK (provider);
if (G_VALUE_HOLDS (value, callback->type) && callback->func != NULL)
{
callback->func (value, callback->data);
return TRUE;
}
return GDK_CONTENT_PROVIDER_CLASS (gdk_content_provider_callback_parent_class)->get_value (provider, value, error);
}
static void
gdk_content_provider_callback_class_init (GdkContentProviderCallbackClass *class)
{
GdkContentProviderClass *provider_class = GDK_CONTENT_PROVIDER_CLASS (class);
provider_class->ref_formats = gdk_content_provider_callback_ref_formats;
provider_class->get_value = gdk_content_provider_callback_get_value;
}
static void
gdk_content_provider_callback_init (GdkContentProviderCallback *content)
{
}
/**
* gdk_content_provider_new_for_callback:
* @type: the type that the callback provides
* @func: callback to populate a #GValue
* @data: (closure): data that gets passed to @func
*
* Create a content provider that provides data that is provided via a callback.
*
* Returns: a new #GdkContentProvider
**/
GdkContentProvider *
gdk_content_provider_new_with_callback (GType type,
GdkContentProviderGetValueFunc func,
gpointer data)
{
GdkContentProviderCallback *content;
content = g_object_new (GDK_TYPE_CONTENT_PROVIDER_CALLBACK, NULL);
content->type = type;
content->func = func;
content->data = data;
return GDK_CONTENT_PROVIDER (content);
}
#define GDK_TYPE_CONTENT_PROVIDER_CALLBACK2 (gdk_content_provider_callback2_get_type ())
#define GDK_CONTENT_PROVIDER_CALLBACK2(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_CONTENT_PROVIDER_CALLBACK2, GdkContentProviderCallback2))
typedef struct _GdkContentProviderCallback2 GdkContentProviderCallback2;
typedef struct _GdkContentProviderCallback2Class GdkContentProviderCallback2Class;
struct _GdkContentProviderCallback2
{
GdkContentProvider parent;
GdkContentFormats *formats;
GdkContentProviderGetBytesFunc func;
gpointer data;
};
struct _GdkContentProviderCallback2Class
{
GdkContentProviderClass parent_class;
};
GType gdk_content_provider_callback2_get_type (void) G_GNUC_CONST;
G_DEFINE_TYPE (GdkContentProviderCallback2, gdk_content_provider_callback2, GDK_TYPE_CONTENT_PROVIDER)
static GdkContentFormats *
gdk_content_provider_callback2_ref_formats (GdkContentProvider *provider)
{
GdkContentProviderCallback2 *callback = GDK_CONTENT_PROVIDER_CALLBACK2 (provider);
return gdk_content_formats_ref (callback->formats);
}
static void
gdk_content_provider_callback2_write_mime_type_done (GObject *stream,
GAsyncResult *result,
gpointer task)
{
GError *error = NULL;
if (!g_output_stream_write_all_finish (G_OUTPUT_STREAM (stream), result, NULL, &error))
g_task_return_error (task, error);
else
g_task_return_boolean (task, TRUE);
g_object_unref (task);
}
static void
gdk_content_provider_callback2_write_mime_type_async (GdkContentProvider *provider,
const char *mime_type,
GOutputStream *stream,
int io_priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GdkContentProviderCallback2 *content = GDK_CONTENT_PROVIDER_CALLBACK2 (provider);
GTask *task;
GBytes *bytes;
task = g_task_new (content, cancellable, callback, user_data);
g_task_set_priority (task, io_priority);
g_task_set_source_tag (task, gdk_content_provider_callback2_write_mime_type_async);
if (!gdk_content_formats_contain_mime_type (content->formats, mime_type))
{
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
_("Cannot provide contents as “%s”"), mime_type);
g_object_unref (task);
return;
}
bytes = content->func (mime_type, content->data);
if (!bytes)
{
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
_("Failed to get contents as “%s”"), mime_type);
g_object_unref (task);
return;
}
g_object_set_data_full (G_OBJECT (task), "bytes", bytes, (GDestroyNotify)g_bytes_unref);
g_output_stream_write_all_async (stream,
g_bytes_get_data (bytes, NULL),
g_bytes_get_size (bytes),
io_priority,
cancellable,
gdk_content_provider_callback2_write_mime_type_done,
task);
}
static gboolean
gdk_content_provider_callback2_write_mime_type_finish (GdkContentProvider *provider,
GAsyncResult *result,
GError **error)
{
g_return_val_if_fail (g_task_is_valid (result, provider), FALSE);
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gdk_content_provider_callback2_write_mime_type_async, FALSE);
return g_task_propagate_boolean (G_TASK (result), error);
}
static void
gdk_content_provider_callback2_class_init (GdkContentProviderCallback2Class *class)
{
GdkContentProviderClass *provider_class = GDK_CONTENT_PROVIDER_CLASS (class);
provider_class->ref_formats = gdk_content_provider_callback2_ref_formats;
provider_class->write_mime_type_async = gdk_content_provider_callback2_write_mime_type_async;
provider_class->write_mime_type_finish = gdk_content_provider_callback2_write_mime_type_finish;
}
static void
gdk_content_provider_callback2_init (GdkContentProviderCallback2 *content)
{
}
/**
* gdk_content_provider_new_with_formats:
* @formats: formats to advertise
* @func: callback to populate a #GValue
* @data: data that gets passed to @func
*
* Create a content provider that provides data that is provided via a callback.
*
* Returns: a new #GdkContentProvider
**/
GdkContentProvider *
gdk_content_provider_new_with_formats (GdkContentFormats *formats,
GdkContentProviderGetBytesFunc func,
gpointer data)
{
GdkContentProviderCallback2 *content;
content = g_object_new (GDK_TYPE_CONTENT_PROVIDER_CALLBACK2, NULL);
content->formats = gdk_content_formats_union_serialize_mime_types (gdk_content_formats_ref (formats));
content->func = func;
content->data = data;
return GDK_CONTENT_PROVIDER (content);
}

View File

@@ -35,6 +35,21 @@ GDK_AVAILABLE_IN_ALL
GdkContentProvider * gdk_content_provider_new_for_bytes (const char *mime_type,
GBytes *bytes);
typedef void (*GdkContentProviderGetValueFunc) (GValue *value,
gpointer data);
GDK_AVAILABLE_IN_ALL
GdkContentProvider * gdk_content_provider_new_with_callback (GType type,
GdkContentProviderGetValueFunc func,
gpointer data);
typedef GBytes * (*GdkContentProviderGetBytesFunc) (const char *mime_type,
gpointer data);
GDK_AVAILABLE_IN_ALL
GdkContentProvider * gdk_content_provider_new_with_formats (GdkContentFormats *formats,
GdkContentProviderGetBytesFunc func,
gpointer data);
G_END_DECLS

View File

@@ -25,6 +25,7 @@
#include "gdkpixbuf.h"
#include "filetransferportalprivate.h"
#include "gdktextureprivate.h"
#include "gdkrgba.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <string.h>
@@ -862,6 +863,48 @@ file_text_serializer (GdkContentSerializer *serializer)
gdk_content_serializer_set_task_data (serializer, path, g_free);
}
static void
color_serializer_finish (GObject *source,
GAsyncResult *result,
gpointer serializer)
{
GOutputStream *stream = G_OUTPUT_STREAM (source);
GError *error = NULL;
if (!g_output_stream_write_all_finish (stream, result, NULL, &error))
gdk_content_serializer_return_error (serializer, error);
else
gdk_content_serializer_return_success (serializer);
}
static void
color_serializer (GdkContentSerializer *serializer)
{
const GValue *value;
GdkRGBA *rgba;
guint16 *data;
value = gdk_content_serializer_get_value (serializer);
rgba = g_value_get_boxed (value);
data = g_new0 (guint16, 4);
if (rgba)
{
data[0] = (guint16) (rgba->red * 65535);
data[1] = (guint16) (rgba->green * 65535);
data[2] = (guint16) (rgba->blue * 65535);
data[3] = (guint16) (rgba->alpha * 65535);
}
g_output_stream_write_all_async (gdk_content_serializer_get_output_stream (serializer),
data,
4 * sizeof (guint16),
gdk_content_serializer_get_priority (serializer),
gdk_content_serializer_get_cancellable (serializer),
color_serializer_finish,
serializer);
gdk_content_serializer_set_task_data (serializer, data, g_free);
}
static void
init (void)
{
@@ -984,5 +1027,11 @@ init (void)
string_serializer,
(gpointer) "ASCII",
NULL);
gdk_content_register_serializer (GDK_TYPE_RGBA,
"application/x-color",
color_serializer,
NULL,
NULL);
}

View File

@@ -90,20 +90,30 @@ G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkDrag, gdk_drag, G_TYPE_OBJECT)
/**
* SECTION:dnd
* @title: Drag And Drop
* @short_description: Functions for controlling drag and drop handling
* @Title: Drag And Drop
* @Short_description: Functions for controlling drag and drop handling
*
* These functions provide a low level interface for drag and drop.
* These functions provide a low-level interface for drag and drop.
*
* The GdkDrag object represents the source side of an ongoing DND operation.
* It is created when a drag is started, and stays alive for duration of
* the DND operation.
* the DND operation. After a drag has been started with gdk_drag_begin(),
* the caller gets informed about the status of the ongoing drag operation
* with signals on the #GtkDrag object.
*
* The GdkDrop object represents the target side of an ongoing DND operation.
* Possible drop sites get informed about the status of the ongoing drag operation
* with events of type %GDK_DRAG_ENTER, %GDK_DRAG_LEAVE, %GDK_DRAG_MOTION and
* %GDK_DROP_START. The #GdkDrop object can be obtained from these #GdkEvents
* using gdk_event_get_drop().
*
* The actual data transfer is initiated from the target side via an async
* read, using one of the GdkDrop functions for this purpose: gdk_drop_read_async(),
* gdk_drop_read_value_async() or gdk_drop_read_text_async().
*
* GTK+ provides a higher level abstraction based on top of these functions,
* and so they are not normally needed in GTK+ applications. See the
* [Drag and Drop][gtk4-Drag-and-Drop] section of the GTK+ documentation
* GTK provides a higher level abstraction based on top of these functions,
* and so they are not normally needed in GTK applications. See the
* [Drag and Drop][gtk4-Drag-and-Drop] section of the GTK documentation
* for more information.
*/

View File

@@ -1001,3 +1001,30 @@ gdk_drop_emit_drop_event (GdkDrop *self,
gdk_drop_do_emit_event (event, dont_queue);
}
/**
* gdk_drop_has_value:
* @self: a #GdkDrop
* @type: the type to check
*
* Returns whether calling gdk_drop_read_value_async() for @type
* can succeed.
*
* Returns: %TRUE if the data can be deserialized to the given type
*/
gboolean
gdk_drop_has_value (GdkDrop *self,
GType type)
{
GdkContentFormats *formats;
gboolean ret;
formats = gdk_content_formats_ref (gdk_drop_get_formats (self));
formats = gdk_content_formats_union_deserialize_gtypes (formats);
ret = gdk_content_formats_contain_gtype (formats, type);
gdk_content_formats_unref (formats);
return ret;
}

View File

@@ -92,6 +92,9 @@ char * gdk_drop_read_text_finish (GdkDrop
GAsyncResult *result,
GError **error);
GDK_AVAILABLE_IN_ALL
gboolean gdk_drop_has_value (GdkDrop *self,
GType type);
G_END_DECLS

View File

@@ -1013,6 +1013,13 @@ gdk_event_set_coords (GdkEvent *event,
event->touchpad_pinch.x = x;
event->touchpad_pinch.y = y;
break;
case GDK_DRAG_ENTER:
case GDK_DRAG_LEAVE:
case GDK_DRAG_MOTION:
case GDK_DROP_START:
event->dnd.x = x;
event->dnd.y = y;
break;
default:
break;
}

View File

@@ -248,10 +248,10 @@ gdk_seat_get_capabilities (GdkSeat *seat)
* elsewhere.
* @event: (nullable): the event that is triggering the grab, or %NULL if none
* is available.
* @prepare_func: (nullable) (scope call) (closure prepare_func_data): function to
* @prepare_func: (nullable) (scope call): function to
* prepare the surface to be grabbed, it can be %NULL if @surface is
* visible before this call.
* @prepare_func_data: user data to pass to @prepare_func
* @prepare_func_data: (closure): user data to pass to @prepare_func
*
* Grabs the seat so that all events corresponding to the given @capabilities
* are passed to this application until the seat is ungrabbed with gdk_seat_ungrab(),

View File

@@ -3583,7 +3583,13 @@ gdk_surface_register_dnd (GdkSurface *surface)
*
* Starts a drag and creates a new drag context for it.
*
* This function is called by the drag source.
* This function is called by the drag source. After this call, you
* probably want to set up the drag icon using the surface returned
* by gdk_drag_get_drag_surface().
*
* Note: if @actions include %GDK_ACTION_MOVE, you need to listen for
* the #GdkDrag::dnd-finished signal and delete the data at the source
* if gdk_drag_get_selected_action() returns %GDK_ACTION_MOVE.
*
* Returns: (transfer full) (nullable): a newly created #GdkDrag or
* %NULL on error.

View File

@@ -680,7 +680,6 @@ gdk_quartz_keymap_translate_keyboard_state (GdkKeymap *keymap,
{
guint tmp_keyval;
GdkModifierType bit;
guint tmp_modifiers = 0;
if (keyval)
*keyval = 0;
@@ -694,24 +693,23 @@ gdk_quartz_keymap_translate_keyboard_state (GdkKeymap *keymap,
if (hardware_keycode < 0 || hardware_keycode >= NUM_KEYCODES)
return FALSE;
/* Check if modifiers modify the keyval */
for (bit = GDK_SHIFT_MASK; bit < GDK_BUTTON1_MASK; bit <<= 1)
{
if (translate_keysym (hardware_keycode,
(bit == GDK_MOD1_MASK) ? 0 : group,
state & ~bit,
NULL, NULL) !=
translate_keysym (hardware_keycode,
(bit == GDK_MOD1_MASK) ? 1 : group,
state | bit,
NULL, NULL))
tmp_modifiers |= bit;
}
tmp_keyval = translate_keysym (hardware_keycode, group, state, level, effective_group);
/* Check if modifiers modify the keyval */
if (consumed_modifiers)
*consumed_modifiers = tmp_modifiers;
{
guint tmp_modifiers = (state & GDK_MODIFIER_MASK);
for (bit = 1; bit <= tmp_modifiers; bit <<= 1)
{
if ((bit & tmp_modifiers) &&
translate_keysym (hardware_keycode, group, state & ~bit,
NULL, NULL) == tmp_keyval)
tmp_modifiers &= ~bit;
}
*consumed_modifiers = tmp_modifiers;
}
if (keyval)
*keyval = tmp_keyval;

View File

@@ -4109,7 +4109,7 @@ gdk_wayland_surface_is_exported (GdkSurface *surface)
* gdk_wayland_surface_export_handle:
* @surface: the #GdkSurface to obtain a handle for
* @callback: callback to call with the handle
* @user_data: user data for @callback
* @user_data: (closure): user data for @callback
* @destroy_func: destroy notify for @user_data
*
* Asynchronously obtains a handle for a surface that can be passed

View File

@@ -1061,6 +1061,7 @@ xdnd_send_enter (GdkX11Drag *drag_x11)
{
GdkDrag *drag = GDK_DRAG (drag_x11);
GdkDisplay *display = gdk_drag_get_display (drag);
GdkContentFormats *formats;
const char * const *atoms;
gsize i, n_atoms;
XEvent xev;
@@ -1080,7 +1081,10 @@ xdnd_send_enter (GdkX11Drag *drag_x11)
GDK_DISPLAY_NOTE (display, DND,
g_message ("Sending enter source window %#lx XDND protocol version %d\n",
GDK_SURFACE_XID (drag_x11->ipc_surface), drag_x11->version));
atoms = gdk_content_formats_get_mime_types (gdk_drag_get_formats (drag), &n_atoms);
formats = gdk_content_formats_ref (gdk_drag_get_formats (drag));
formats = gdk_content_formats_union_serialize_mime_types (formats);
atoms = gdk_content_formats_get_mime_types (formats, &n_atoms);
if (n_atoms > 3)
{
@@ -1300,8 +1304,7 @@ xdnd_precache_atoms (GdkDisplay *display)
/* Source side */
static void
gdk_drag_do_leave (GdkX11Drag *drag_x11,
guint32 time)
gdk_drag_do_leave (GdkX11Drag *drag_x11)
{
if (drag_x11->proxy_xid)
{
@@ -1502,27 +1505,10 @@ gdk_x11_drag_drag_motion (GdkDrag *drag,
}
}
/* When we have a Xdnd target, make sure our XdndActionList
* matches the current actions;
*/
if (protocol == GDK_DRAG_PROTO_XDND && drag_x11->xdnd_actions != gdk_drag_get_actions (drag))
{
if (proxy_xid)
{
GdkDisplay *display = gdk_drag_get_display (drag);
GdkDrop *drop = GDK_X11_DISPLAY (display)->current_drop;
if (drop && GDK_SURFACE_XID (gdk_drop_get_surface (drop)) == proxy_xid)
gdk_x11_drop_read_actions (drop);
else
xdnd_set_actions (drag_x11);
}
}
if (drag_x11->proxy_xid != proxy_xid)
{
/* Send a leave to the last destination */
gdk_drag_do_leave (drag_x11, time);
gdk_drag_do_leave (drag_x11);
drag_x11->drag_status = GDK_DRAG_STATUS_DRAG;
/* Check if new destination accepts drags, and which protocol */
@@ -1558,6 +1544,23 @@ gdk_x11_drag_drag_motion (GdkDrag *drag,
drag_x11->current_action = gdk_drag_get_selected_action (drag);
}
/* When we have a Xdnd target, make sure our XdndActionList
* matches the current actions;
*/
if (protocol == GDK_DRAG_PROTO_XDND && drag_x11->xdnd_actions != gdk_drag_get_actions (drag))
{
if (proxy_xid)
{
GdkDisplay *display = gdk_drag_get_display (drag);
GdkDrop *drop = GDK_X11_DISPLAY (display)->current_drop;
if (drop && GDK_SURFACE_XID (gdk_drop_get_surface (drop)) == proxy_xid)
gdk_x11_drop_read_actions (drop);
else
xdnd_set_actions (drag_x11);
}
}
/* Send a drag-motion event */
drag_x11->last_x = x_root;
@@ -1814,6 +1817,7 @@ struct _GdkDragAnim {
static void
gdk_drag_anim_destroy (GdkDragAnim *anim)
{
gdk_surface_hide (anim->drag->drag_surface);
g_object_unref (anim->drag);
g_slice_free (GdkDragAnim, anim);
}
@@ -2137,6 +2141,7 @@ static void
gdk_x11_drag_cancel (GdkDrag *drag,
GdkDragCancelReason reason)
{
gdk_drag_do_leave (GDK_X11_DRAG (drag));
drag_ungrab (drag);
gdk_drag_drop_done (drag, FALSE);
}

View File

@@ -747,7 +747,7 @@ gdk_x11_drop_status (GdkDrop *drop,
GdkDragAction actions)
{
GdkX11Drop *drop_x11 = GDK_X11_DROP (drop);
GdkDragAction possible_actions;
GdkDragAction possible_actions, suggested_action;
XEvent xev;
GdkDisplay *display;
@@ -755,6 +755,17 @@ gdk_x11_drop_status (GdkDrop *drop,
possible_actions = actions & gdk_drop_get_actions (drop);
if (drop_x11->suggested_action != 0)
suggested_action = drop_x11->suggested_action;
else if (possible_actions & GDK_ACTION_COPY)
suggested_action = GDK_ACTION_COPY;
else if (possible_actions & GDK_ACTION_MOVE)
suggested_action = GDK_ACTION_MOVE;
else if (possible_actions & GDK_ACTION_ASK)
suggested_action = GDK_ACTION_ASK;
else
suggested_action = 0;
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "XdndStatus");
xev.xclient.format = 32;
@@ -764,7 +775,7 @@ gdk_x11_drop_status (GdkDrop *drop,
xev.xclient.data.l[1] = (possible_actions != 0) ? (2 | 1) : 0;
xev.xclient.data.l[2] = 0;
xev.xclient.data.l[3] = 0;
xev.xclient.data.l[4] = xdnd_action_to_atom (display, possible_actions);
xev.xclient.data.l[4] = xdnd_action_to_atom (display, suggested_action);
if (gdk_drop_get_drag (drop))
{

View File

@@ -20,10 +20,6 @@
#include "gtkaccessibility.h"
#include "gtkaccessibilityutil.h"
#ifdef GDK_WINDOWING_X11
#include <atk-bridge.h>
#endif
static int initialized = FALSE;
void
@@ -35,9 +31,4 @@ _gtk_accessibility_init (void)
initialized = TRUE;
_gtk_accessibility_override_atk_util ();
#ifdef GDK_WINDOWING_X11
atk_bridge_adaptor_init (NULL, NULL);
#endif
}

View File

@@ -84,18 +84,6 @@ get_root (void)
return root;
}
static const gchar *
get_toolkit_name (void)
{
return "gtk";
}
static const gchar *
get_toolkit_version (void)
{
return GTK_VERSION;
}
void
_gtk_accessibility_override_atk_util (void)
{
@@ -104,8 +92,6 @@ _gtk_accessibility_override_atk_util (void)
atk_class->add_key_event_listener = add_key_event_listener;
atk_class->remove_key_event_listener = remove_key_event_listener;
atk_class->get_root = get_root;
atk_class->get_toolkit_name = get_toolkit_name;
atk_class->get_toolkit_version = get_toolkit_version;
}
static void

View File

@@ -70,66 +70,6 @@ gtk_level_bar_accessible_init (GtkLevelBarAccessible *button)
{
}
static void
gtk_level_bar_accessible_get_current_value (AtkValue *obj,
GValue *value)
{
GtkWidget *widget;
GtkLevelBar *level_bar;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
level_bar = GTK_LEVEL_BAR (widget);
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_level_bar_get_value (level_bar));
}
static void
gtk_level_bar_accessible_get_maximum_value (AtkValue *obj,
GValue *value)
{
GtkWidget *widget;
GtkLevelBar *level_bar;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
level_bar = GTK_LEVEL_BAR (widget);
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_level_bar_get_max_value (level_bar));
}
static void
gtk_level_bar_accessible_get_minimum_value (AtkValue *obj,
GValue *value)
{
GtkWidget *widget;
GtkLevelBar *level_bar;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
level_bar = GTK_LEVEL_BAR (widget);
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_level_bar_get_min_value (level_bar));
}
static gboolean
gtk_level_bar_accessible_set_current_value (AtkValue *obj,
const GValue *value)
{
GtkWidget *widget;
GtkLevelBar *level_bar;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
level_bar = GTK_LEVEL_BAR (widget);
gtk_level_bar_set_value (level_bar, g_value_get_double (value));
return TRUE;
}
static void
gtk_level_bar_accessible_get_value_and_text (AtkValue *obj,
gdouble *value,
@@ -175,11 +115,6 @@ gtk_level_bar_accessible_set_value (AtkValue *obj,
static void
atk_value_interface_init (AtkValueIface *iface)
{
iface->get_current_value = gtk_level_bar_accessible_get_current_value;
iface->get_maximum_value = gtk_level_bar_accessible_get_maximum_value;
iface->get_minimum_value = gtk_level_bar_accessible_get_minimum_value;
iface->set_current_value = gtk_level_bar_accessible_set_current_value;
iface->get_value_and_text = gtk_level_bar_accessible_get_value_and_text;
iface->get_range = gtk_level_bar_accessible_get_range;
iface->set_value = gtk_level_bar_accessible_set_value;

View File

@@ -60,88 +60,6 @@ gtk_paned_accessible_init (GtkPanedAccessible *paned)
{
}
static void
gtk_paned_accessible_get_current_value (AtkValue *obj,
GValue *value)
{
GtkWidget* widget;
gint current_value;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return;
current_value = gtk_paned_get_position (GTK_PANED (widget));
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_INT);
g_value_set_int (value, current_value);
}
static void
gtk_paned_accessible_get_maximum_value (AtkValue *obj,
GValue *value)
{
GtkWidget* widget;
gint maximum_value;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return;
g_object_get (GTK_PANED (widget),
"max-position", &maximum_value,
NULL);
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_INT);
g_value_set_int (value, maximum_value);
}
static void
gtk_paned_accessible_get_minimum_value (AtkValue *obj,
GValue *value)
{
GtkWidget* widget;
gint minimum_value;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return;
g_object_get (GTK_PANED (widget),
"min-position", &minimum_value,
NULL);
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_INT);
g_value_set_int (value, minimum_value);
}
/* Calling atk_value_set_current_value() is no guarantee that the value
* is acceptable; it is necessary to listen for accessible-value signals
* and check whether the current value has been changed or check what the
* maximum and minimum values are.
*/
static gboolean
gtk_paned_accessible_set_current_value (AtkValue *obj,
const GValue *value)
{
GtkWidget* widget;
gint new_value;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return FALSE;
if (G_VALUE_HOLDS_INT (value))
{
new_value = g_value_get_int (value);
gtk_paned_set_position (GTK_PANED (widget), new_value);
return TRUE;
}
else
return FALSE;
}
static void
gtk_paned_accessible_get_value_and_text (AtkValue *obj,
gdouble *value,
@@ -190,11 +108,6 @@ gtk_paned_accessible_set_value (AtkValue *obj,
static void
atk_value_interface_init (AtkValueIface *iface)
{
iface->get_current_value = gtk_paned_accessible_get_current_value;
iface->get_maximum_value = gtk_paned_accessible_get_maximum_value;
iface->get_minimum_value = gtk_paned_accessible_get_minimum_value;
iface->set_current_value = gtk_paned_accessible_set_current_value;
iface->get_value_and_text = gtk_paned_accessible_get_value_and_text;
iface->get_range = gtk_paned_accessible_get_range;
iface->set_value = gtk_paned_accessible_set_value;

View File

@@ -69,37 +69,6 @@ gtk_progress_bar_accessible_init (GtkProgressBarAccessible *bar)
{
}
static void
gtk_progress_bar_accessible_get_current_value (AtkValue *obj,
GValue *value)
{
GtkWidget *widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (widget)));
}
static void
gtk_progress_bar_accessible_get_maximum_value (AtkValue *obj,
GValue *value)
{
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, 1.0);
}
static void
gtk_progress_bar_accessible_get_minimum_value (AtkValue *obj,
GValue *value)
{
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, 0.0);
}
static void
gtk_progress_bar_accessible_get_value_and_text (AtkValue *obj,
gdouble *value,
@@ -122,10 +91,6 @@ gtk_progress_bar_accessible_get_range (AtkValue *obj)
static void
atk_value_interface_init (AtkValueIface *iface)
{
iface->get_current_value = gtk_progress_bar_accessible_get_current_value;
iface->get_maximum_value = gtk_progress_bar_accessible_get_maximum_value;
iface->get_minimum_value = gtk_progress_bar_accessible_get_minimum_value;
iface->get_value_and_text = gtk_progress_bar_accessible_get_value_and_text;
iface->get_range = gtk_progress_bar_accessible_get_range;
}

View File

@@ -120,98 +120,6 @@ gtk_range_accessible_init (GtkRangeAccessible *range)
range->priv = gtk_range_accessible_get_instance_private (range);
}
static void
gtk_range_accessible_get_current_value (AtkValue *obj,
GValue *value)
{
GtkWidget *widget;
GtkAdjustment *adjustment;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
adjustment = gtk_range_get_adjustment (GTK_RANGE (widget));
if (adjustment == NULL)
return;
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_adjustment_get_value (adjustment));
}
static void
gtk_range_accessible_get_maximum_value (AtkValue *obj,
GValue *value)
{
GtkWidget *widget;
GtkAdjustment *adjustment;
gdouble max;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
adjustment = gtk_range_get_adjustment (GTK_RANGE (widget));
if (adjustment == NULL)
return;
max = gtk_adjustment_get_upper (adjustment)
- gtk_adjustment_get_page_size (adjustment);
if (gtk_range_get_restrict_to_fill_level (GTK_RANGE (widget)))
max = MIN (max, gtk_range_get_fill_level (GTK_RANGE (widget)));
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, max);
}
static void
gtk_range_accessible_get_minimum_value (AtkValue *obj,
GValue *value)
{
GtkWidget *widget;
GtkAdjustment *adjustment;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
adjustment = gtk_range_get_adjustment (GTK_RANGE (widget));
if (adjustment == NULL)
return;
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_adjustment_get_lower (adjustment));
}
static void
gtk_range_accessible_get_minimum_increment (AtkValue *obj,
GValue *value)
{
GtkWidget *widget;
GtkAdjustment *adjustment;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
adjustment = gtk_range_get_adjustment (GTK_RANGE (widget));
if (adjustment == NULL)
return;
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_adjustment_get_minimum_increment (adjustment));
}
static gboolean
gtk_range_accessible_set_current_value (AtkValue *obj,
const GValue *value)
{
GtkWidget *widget;
GtkAdjustment *adjustment;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
adjustment = gtk_range_get_adjustment (GTK_RANGE (widget));
if (adjustment == NULL)
return FALSE;
gtk_adjustment_set_value (adjustment, g_value_get_double (value));
return TRUE;
}
static void
gtk_range_accessible_get_value_and_text (AtkValue *obj,
gdouble *value,
@@ -283,12 +191,6 @@ gtk_range_accessible_get_increment (AtkValue *obj)
static void
atk_value_interface_init (AtkValueIface *iface)
{
iface->get_current_value = gtk_range_accessible_get_current_value;
iface->get_maximum_value = gtk_range_accessible_get_maximum_value;
iface->get_minimum_value = gtk_range_accessible_get_minimum_value;
iface->get_minimum_increment = gtk_range_accessible_get_minimum_increment;
iface->set_current_value = gtk_range_accessible_set_current_value;
iface->get_value_and_text = gtk_range_accessible_get_value_and_text;
iface->get_range = gtk_range_accessible_get_range;
iface->set_value = gtk_range_accessible_set_value;

View File

@@ -185,91 +185,6 @@ atk_action_interface_init (AtkActionIface *iface)
iface->get_localized_name = gtk_scale_button_accessible_action_get_localized_name;
}
static void
gtk_scale_button_accessible_get_current_value (AtkValue *obj,
GValue *value)
{
GtkWidget *widget;
GtkAdjustment *adjustment;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
adjustment = gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (widget));
if (adjustment == NULL)
return;
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_adjustment_get_value (adjustment));
}
static void
gtk_scale_button_accessible_get_maximum_value (AtkValue *obj,
GValue *value)
{
GtkWidget *widget;
GtkAdjustment *adjustment;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
adjustment = gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (widget));
if (adjustment == NULL)
return;
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_adjustment_get_upper (adjustment));
}
static void
gtk_scale_button_accessible_get_minimum_value (AtkValue *obj,
GValue *value)
{
GtkWidget *widget;
GtkAdjustment *adjustment;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
adjustment = gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (widget));
if (adjustment == NULL)
return;
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_adjustment_get_lower (adjustment));
}
static void
gtk_scale_button_accessible_get_minimum_increment (AtkValue *obj,
GValue *value)
{
GtkWidget *widget;
GtkAdjustment *adjustment;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
adjustment = gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (widget));
if (adjustment == NULL)
return;
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_adjustment_get_minimum_increment (adjustment));
}
static gboolean
gtk_scale_button_accessible_set_current_value (AtkValue *obj,
const GValue *value)
{
GtkWidget *widget;
GtkAdjustment *adjustment;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
adjustment = gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (widget));
if (adjustment == NULL)
return FALSE;
gtk_adjustment_set_value (adjustment, g_value_get_double (value));
return TRUE;
}
static void
gtk_scale_button_accessible_get_value_and_text (AtkValue *obj,
gdouble *value,
@@ -335,12 +250,6 @@ gtk_scale_button_accessible_get_increment (AtkValue *obj)
static void
atk_value_interface_init (AtkValueIface *iface)
{
iface->get_current_value = gtk_scale_button_accessible_get_current_value;
iface->get_maximum_value = gtk_scale_button_accessible_get_maximum_value;
iface->get_minimum_value = gtk_scale_button_accessible_get_minimum_value;
iface->get_minimum_increment = gtk_scale_button_accessible_get_minimum_increment;
iface->set_current_value = gtk_scale_button_accessible_set_current_value;
iface->get_value_and_text = gtk_scale_button_accessible_get_value_and_text;
iface->get_range = gtk_scale_button_accessible_get_range;
iface->set_value = gtk_scale_button_accessible_set_value;

View File

@@ -120,91 +120,6 @@ gtk_spin_button_accessible_init (GtkSpinButtonAccessible *button)
button->priv = gtk_spin_button_accessible_get_instance_private (button);
}
static void
gtk_spin_button_accessible_get_current_value (AtkValue *obj,
GValue *value)
{
GtkWidget *widget;
GtkAdjustment *adjustment;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget));
if (adjustment == NULL)
return;
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_adjustment_get_value (adjustment));
}
static void
gtk_spin_button_accessible_get_maximum_value (AtkValue *obj,
GValue *value)
{
GtkWidget *widget;
GtkAdjustment *adjustment;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget));
if (adjustment == NULL)
return;
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_adjustment_get_upper (adjustment));
}
static void
gtk_spin_button_accessible_get_minimum_value (AtkValue *obj,
GValue *value)
{
GtkWidget *widget;
GtkAdjustment *adjustment;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget));
if (adjustment == NULL)
return;
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_adjustment_get_lower (adjustment));
}
static void
gtk_spin_button_accessible_get_minimum_increment (AtkValue *obj,
GValue *value)
{
GtkWidget *widget;
GtkAdjustment *adjustment;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget));
if (adjustment == NULL)
return;
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_adjustment_get_minimum_increment (adjustment));
}
static gboolean
gtk_spin_button_accessible_set_current_value (AtkValue *obj,
const GValue *value)
{
GtkWidget *widget;
GtkAdjustment *adjustment;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget));
if (adjustment == NULL)
return FALSE;
gtk_adjustment_set_value (adjustment, g_value_get_double (value));
return TRUE;
}
static void
gtk_spin_button_accessible_get_value_and_text (AtkValue *obj,
gdouble *value,
@@ -270,12 +185,6 @@ gtk_spin_button_accessible_get_increment (AtkValue *obj)
static void
atk_value_interface_init (AtkValueIface *iface)
{
iface->get_current_value = gtk_spin_button_accessible_get_current_value;
iface->get_maximum_value = gtk_spin_button_accessible_get_maximum_value;
iface->get_minimum_value = gtk_spin_button_accessible_get_minimum_value;
iface->get_minimum_increment = gtk_spin_button_accessible_get_minimum_increment;
iface->set_current_value = gtk_spin_button_accessible_set_current_value;
iface->get_value_and_text = gtk_spin_button_accessible_get_value_and_text;
iface->get_range = gtk_spin_button_accessible_get_range;
iface->set_value = gtk_spin_button_accessible_set_value;

View File

@@ -90,8 +90,8 @@
#include <gtk/gtkcustomlayout.h>
#include <gtk/gtkdebug.h>
#include <gtk/gtkdialog.h>
#include <gtk/gtkdnd.h>
#include <gtk/gtkdragdest.h>
#include <gtk/gtkdragicon.h>
#include <gtk/gtkdragsource.h>
#include <gtk/gtkdrawingarea.h>
#include <gtk/gtkeditable.h>

Some files were not shown because too many files have changed in this diff Show More