Compare commits

...

1598 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
Dušan Kazik
7d99339c39 Update Slovak translation 2020-01-10 06:47:50 +00: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
Timm Bäder
1e2c03beee rename CODE-OWNERS to CODEOWNERS
gitlab reads the new filename but not the old one.
2020-01-08 21:03:15 +01:00
Emmanuele Bassi
b24e10fa30 Merge branch 'fixed-fixed' into 'master'
fixed layout: Actually set child transforms

See merge request GNOME/gtk!1292
2020-01-08 15:46:19 +00:00
Matthias Clasen
173952cbc8 fixed layout: Actually set child transforms
The code was unintentionally appending to the
existing child transform, leading to ever-moving
children when you call gtk_fixed_put.
2020-01-08 10:40:44 -05:00
Alex Samorukov
b31f4f2bae Merge branch 'master-fix-set-functions' into 'master'
quartz: impl_class->set_functions listed twice in the object

See merge request GNOME/gtk!1283
2020-01-08 14:15:45 +00:00
Alex Samorukov
df9d9c1f8a impl_class->set_functions listed twice in the object 2020-01-08 14:15:45 +00:00
Alex Samorukov
7dcb25bd46 Merge branch 'master-eventloop-fix' into 'master'
Move `[NSApplication sharedApplication]` after event loop init to avoid window focus issues (closes #2342).

See merge request GNOME/gtk!1286
2020-01-08 14:10:06 +00:00
Alex Samorukov
d131c8d0e7 move [NSApplication sharedApplication] after _gdk_quartz_events_init() to avoid initialization issues
(cherry picked from commit 46c2451c5a3cd42aa5a94935bfc850a484288ff3)
2020-01-08 14:10:06 +00:00
Timm Bäder
0582a4ef1b Merge branch 'check-for-sincosf' into 'master'
gsk/gsktransform.c: Fix building on non-GCC

See merge request GNOME/gtk!1291
2020-01-08 09:27:51 +00:00
Chun-wei Fan
a9b1d4a389 build: Check for sincosf()
sincosf() is really a GCC-specific function that may more may not be
supported on non-GCC compilers, so we want to check for it, otherwise we
use a fallback implementation, not unlike the one in
demos/gtk-demo/gtkgears.c.
2020-01-08 17:15:29 +08:00
Timm Bäder
ea810f176b gl renderer: Handle repeat nodes with invisible children
We can handle this pretty easily by normally drawing the other
(visible) child node, if any.
2020-01-07 17:27:19 +01:00
Timm Bäder
262ac4247a testsuite: Add a testcase for blend nodes with invisible children 2020-01-07 17:27:19 +01:00
Timm Bäder
8e4f0b9484 sizerequest: Remove _gtk_widget_get_preferred_size_and_baseline
Private and unused function.
2020-01-07 17:27:19 +01:00
Timm Bäder
7669e6e42e transform: Properly compare scale transforms
If the epsilon we use there is too much, we can run into rendering
errors because the GPU will use the actual scale value.
2020-01-07 17:27:19 +01:00
Timm Bäder
a3f14a3395 rendernodepaintable: ceil() bounds for intrinsic size
Otherweise we floor() implicitly when casting to int, resulting in
slight scaling later.
2020-01-07 17:27:19 +01:00
Timm Bäder
73b8212bf3 label: Fix assumptions regaring link 2020-01-07 17:27:18 +01:00
Timm Bäder
6ba6f361be gltextureatlas: Packing must succeed here 2020-01-07 17:27:18 +01:00
Timm Bäder
726909d735 Window: Avoid some redundant assignments 2020-01-07 17:27:18 +01:00
Timm Bäder
04899e3707 colorswatch: Avoid redundant assignment 2020-01-07 17:27:18 +01:00
Timm Bäder
7a27122dab transform: Scale+translate bounds directyl
Make these two code paths look the same.
2020-01-07 17:27:18 +01:00
Timm Bäder
73ce437459 widget: Use cssnode api to get the filter value
it's confusing that we use GtkStyleContext here while we use the CssNode
directly elsewhere.
2020-01-07 17:27:18 +01:00
Timm Bäder
ca4ae81170 transform: Compare class before ->next 2020-01-07 17:27:18 +01:00
Timm Bäder
21a7dfae96 snapshot: Only normalize rectangle if we have to
We can even replace the comment this way.
2020-01-07 17:27:18 +01:00
Timm Bäder
6c188f7c93 bin: Move vfunc implementations before class_init
And avoid every single function prototype.
2020-01-07 17:27:18 +01:00
Timm Bäder
c30e0f78ad bin: Avoid some type checks 2020-01-07 17:27:18 +01:00
Timm Bäder
76795ffba9 gl renderer: Sprinkle some const around 2020-01-07 17:27:18 +01:00
Timm Bäder
c38c5c4ce1 text: Reset cursor opacity when unmapping
Otherwise we might get mapped again with a half-transparent cursor.
2020-01-07 17:27:18 +01:00
Timm Bäder
108aac9ee3 scrolledwindow: Don't snapshot junction if we use indicators
The junction doesn't make sense when we use indicators, since the
scrollbars overlap anyway. Not snappshotting it anymore has no visual
effect since it's being drawn below the scrollbars anyway.
2020-01-07 17:27:18 +01:00
Timm Bäder
c427c2b22a cssimagelinear: Don't call get_start_end if !repeating
This makes it clear that the !repeating case is easier.
2020-01-07 17:27:18 +01:00
Timm Bäder
59111d100f cssimagelinear: Avoid computing the length if we know it
We handlet the common easy cases manually anyway, so don't bother
sqrt()ing the x/y coords in those cases.
2020-01-07 17:27:18 +01:00
Timm Bäder
cee8f78c6e toolitem: Remove unused members 2020-01-07 17:27:18 +01:00
Timm Bäder
0fc35b2124 toolitem: Plug memory leak 2020-01-07 17:27:18 +01:00
Timm Bäder
eebe67cf0a gl renderer: Add util to load vertex data with texture region 2020-01-07 17:27:18 +01:00
Timm Bäder
b9726901a5 gl renderer: Fix inverted dy in inset shadows 2020-01-07 17:27:17 +01:00
Timm Bäder
df1d2b8417 gsk: Add GskParseErrorFunc to the docs 2020-01-07 17:27:17 +01:00
Timm Bäder
8b1af398a0 gl renderer: Avoid another manual rounded rect transform
We have transform_rect() for this now.
2020-01-07 17:27:17 +01:00
Timm Bäder
982d73df0b adwaita: Solve junction problem without border image
This genius piece of CSS colors only the top left (or top right in RTL)
pixel of the scrollbar junction.
Doing it this way is better because we don't have to upload a cairo node
every frame.
2020-01-07 17:27:17 +01:00
Timm Bäder
1e55e01692 scrolledwindow: Remove a useless local variable 2020-01-07 17:27:17 +01:00
Timm Bäder
412fcb0330 scrolledwindow: Avoid using gtk_widget_get_preferred_size
This way we only measure in the direction we need.
2020-01-07 17:27:17 +01:00
Timm Bäder
b8d1c3ab55 gl renderer: Don't force repeat node child offscreen 2020-01-07 17:27:17 +01:00
Timm Bäder
4fb519f04d renderborder: Only get border width if we really need to
We did this unconditionally before the if statement, but we don't need
to do it if any of the early-out checks in the not-border-image branch
hits.
2020-01-07 17:27:17 +01:00
Timm Bäder
054d69aaf9 gl renderer: Fix a misleading comment 2020-01-07 17:27:17 +01:00
Timm Bäder
1dea6d4fc7 gl renderer: Speed up bounds transformation
We started saving the scale of the current modelview directly in the
RenderOpBuilder, so we don't need to poke the modelview stack anymore.
2020-01-07 17:27:17 +01:00
Timm Bäder
022d19a4c6 gl renderer: Add debug code for color nodes 2020-01-07 17:27:17 +01:00
Timm Bäder
ef7276c398 gl renderer: Trivial variable reordering 2020-01-07 17:27:17 +01:00
Timm Bäder
0a8ca49b5e gl renderer: transform border outline like everything else 2020-01-07 17:27:17 +01:00
Timm Bäder
74f18f71d3 gl renderer: Move work to the blur vertex shader 2020-01-07 17:27:17 +01:00
Timm Bäder
c0d4a6fc81 gl renderer: Avoid copying a matrix 2020-01-07 17:27:17 +01:00
Timm Bäder
1dd31d58fb testsuite: Add a test case for rotated border node 2020-01-07 17:27:17 +01:00
Timm Bäder
766d4dff76 GskTransform: Compute sin/deg of 90deg rotations manually
Otherwise we might end up with inaccuracies, e.g. when
gsk_transform_transform_bounds()'ing bounds.
2020-01-07 17:27:17 +01:00
Timm Bäder
e62f135c6a GskTransform: Normalize angles
Make sure all angles are in the [0..365) range
2020-01-07 17:27:17 +01:00
Timm Bäder
4788f88840 snapshot: Repeat color nodes by creating a larger color node 2020-01-07 17:27:17 +01:00
Timm Bäder
587bc82c37 gl renderer: Print debug node message 2020-01-07 17:27:17 +01:00
Timm Bäder
750dc8dbe2 gl driver: Inline function into only caller 2020-01-07 17:27:17 +01:00
Timm Bäder
d490d8f1f3 renderbackground: Try to omit a save/restore pair 2020-01-07 17:27:16 +01:00
Timm Bäder
cb2f523994 rendernodes: Use floats for everything 2020-01-07 17:27:16 +01:00
Timm Bäder
075a0ccb5e renderbackground: Save a snapshot_translate() call
Just add the values manually when really using the snapshot later. Also
unifies the two if branches by pulling out getting the x/y values.
2020-01-07 17:27:16 +01:00
Timm Bäder
db91b6dc61 gl renderer: Load vertex data directly into vertices GArray 2020-01-07 17:27:16 +01:00
Timm Bäder
44ac2d5abb gl renderer: Pass linear gradient stops to shaders directly
No need to copy them into the render ops like this.
2020-01-07 17:27:16 +01:00
Timm Bäder
d7df56b6cb gsk: Make GskColorStop.offset a float
Doesn't make sense for this to be double if everything else is float.
Also makes it possible to 'easily' pass this to the GPU.
2020-01-07 17:27:16 +01:00
Timm Bäder
6a9bc5daef Avoid a few state changes
We can't optimize the save/restore calls away in the snapshot code, so
do it from the caller side.
2020-01-07 17:27:16 +01:00
Timm Bäder
b8aa51d522 gl renderer: Move more work to the vertex shaders 2020-01-07 17:27:16 +01:00
Timm Bäder
f79c807645 gl renderer: Don't invert offset value twice 2020-01-07 17:27:16 +01:00
Timm Bäder
d0d2ad9f5b gl renderer: Remove unused variable from shader 2020-01-07 17:27:16 +01:00
Timm Bäder
0b8298038a gl renderer: Move color computation to vertex shader 2020-01-07 17:27:16 +01:00
Timm Bäder
6ef0bb8bea gl renderer: Move final color computation to vertex shader
.. of the coloring program, which is used all the time for text.
2020-01-07 17:27:16 +01:00
Timm Bäder
91472b2ecd gl renderer: Compute final color in vertex shader
This is a very often used shader. No need to to do this for every
fragment.
2020-01-07 17:27:16 +01:00
Timm Bäder
80ddcf38d4 supp: Ignore calloc in the AMD driver
What'cha gonna do
2020-01-07 17:27:16 +01:00
Timm Bäder
1477882b31 testentryicons: Fix a memory leak 2020-01-07 17:27:16 +01:00
Timm Bäder
73f2167fe4 gl renderer: Avoid an invalid read
We need to copy the color here, since the program state can live across
frame boundaries.
2020-01-07 17:27:16 +01:00
Timm Bäder
2079c898e7 gl renderer: Remove some unneeded calculations from shaders 2020-01-07 17:27:16 +01:00
Timm Bäder
c79c18f39c gl renderer: Shuffle things around a bit 2020-01-07 17:27:16 +01:00
Timm Bäder
cef7f7f87d gl renderer: Move work to the gradient vertex shader
No need to do this stuff once per fragment.
2020-01-07 17:27:16 +01:00
Timm Bäder
fdce30d3f8 gl renderer: Add some in/out compat glue to the shaders
so we can use _IN_ and _OUT_ and get the right things for
desktop/es/legacy GL.
2020-01-07 17:27:16 +01:00
Timm Bäder
f07397f4dd gl renderer: Upload GL_RGBA texture data in GLES
Colored icons are still broken this way, but at least they show up and
text works.
2020-01-07 17:27:16 +01:00
Timm Bäder
f1751f514c gltextureatlas: Use more correct debug name for texture
These aren't all glyph atlases anymore.
2020-01-07 17:27:16 +01:00
Timm Bäder
2cbfb0e980 GdkGLContext: check for GL_KHR_debug for GL debug output
This is available in GLES.
2020-01-07 17:27:16 +01:00
Timm Bäder
8dd7f5aefe gl renderer: Mark beginning of frame if DEBUG_OPS is set 2020-01-07 17:27:16 +01:00
Timm Bäder
398f49ad31 gl renderer: Trivial declaration reorder 2020-01-07 17:27:16 +01:00
Timm Bäder
3d260a950e gl renderer: Remove a few outdated comments 2020-01-07 17:27:16 +01:00
Timm Bäder
f31667f437 gl renderer: Remove unused translation handling 2020-01-07 17:27:15 +01:00
Timm Bäder
219493c818 gl renderer: Don't copy matrix/offset of color matrix nodes into ops 2020-01-07 17:27:15 +01:00
Timm Bäder
06f63764fb gl renderer: Initialize alpha uniform to 1.0
This makes gl-legacy work and gl-gles work except for text and icons.
2020-01-07 17:27:15 +01:00
Timm Bäder
1243174e53 gl renderer: Make RoundedRect work in gles
Which can't return struct types containing arrays. So let's revert to
the previous version but still send the rect along as a vec4[3];
2020-01-07 17:27:15 +01:00
Timm Bäder
cc909b160f gl renderer: Rewrite shader builder
Use a unified approach to write both vertex and fragment shader in the
same file.
2020-01-07 17:27:15 +01:00
Timm Bäder
d12dde07c3 gl renderer: Fix program uniform updating code
This breaks the initial uniform value, but we will fix that in a later
commit in a different way.
2020-01-07 17:27:15 +01:00
Timm Bäder
5191b6fccd gl renderer: Only send clip corners if we need to
We change the clip bounds a lot more ofthen than the clip corners and
they are already split up in the shader, so only send the corners if we
need to.
2020-01-07 17:27:15 +01:00
Timm Bäder
2e6e6c1779 gl renderer: Fix color comparison 2020-01-07 17:27:15 +01:00
Timm Bäder
a29b8fbef4 gl renderer: Shorten debug output impl
This will leak a string but WHATEVER.
2020-01-07 17:27:15 +01:00
Timm Bäder
5b072e716c gl renderer: Fix debug color output 2020-01-07 17:27:15 +01:00
Timm Bäder
49845795d9 gl renderer: Rewort passing rounded rects to shaders 2020-01-07 17:27:15 +01:00
Timm Bäder
ab04c74ec9 gl renderer: Don't copy border outline corner sizes around
We already offset + scale the outline and its corners, just pass those
directly to the shader.
2020-01-07 17:27:15 +01:00
Timm Bäder
4744bb9099 gl renderer: stop copying current color around
Just use a pointer now.
2020-01-07 17:27:15 +01:00
Timm Bäder
91522dda63 gl renderer: remove a memory leak 2020-01-07 17:27:15 +01:00
Timm Bäder
095a378dbc GdkRGBA: Use floats instead of doubles 2020-01-07 17:27:15 +01:00
Timm Bäder
0956c30ee5 progressbar: Remove unnecessary snapshot implementation 2020-01-07 17:27:15 +01:00
Timm Bäder
f85448ffbf gl renderer: Split blurring a node into its own function 2020-01-07 17:27:15 +01:00
Timm Bäder
d3852ca33a gl renderer: Remove some unused uniforms 2020-01-07 17:27:15 +01:00
Timm Bäder
9d9a730659 gl renderer: Drop a dead if statement
We already handle this earlier.
2020-01-07 17:27:15 +01:00
Jordi Mas
3f4cd4190f Update Catalan translation 2020-01-06 20:36:28 +01:00
Matthias Clasen
448a402353 widget: Remove an unused signal
HIERARCHY_CHANGED is no longer used.
2020-01-06 08:19:01 -05:00
Matthias Clasen
2ee9752822 wayland: Remove debug spew 2020-01-06 08:19:01 -05:00
Matthias Clasen
f8a1f796b5 Merge branch 'wayland-dnd-fixes' into 'master'
Wayland dnd fixes

See merge request GNOME/gtk!1284
2020-01-06 05:44:33 +00:00
Piotr Drąg
3b5a4cf215 Update Polish translation 2020-01-05 17:27:40 +01:00
Matthias Clasen
759d53cfa0 wayland: Don't artificially prefer ASK
We were always adding ASK to the list of possible
actions, and preferring it. This was causing the
ask cursor to show up when both the source and
the target support ASK, even though it is only
meant to happen if you hold the Alt modifier.

Instead, use one of the supported actions as
preferred action.
2020-01-04 12:51:32 -05:00
Matthias Clasen
814d20d61a docs: Small clarifications to DND docs
Clear up the documentation around ASK handling
a bit.
2020-01-04 12:48:39 -05:00
Matthias Clasen
6cef520804 wayland: Minor cleanup
Stop storing selected_action, mainly since the name
is confusing. Instead, just pass the value directly
in the 2 places where it is used.
2020-01-04 12:48:39 -05:00
Matthias Clasen
8c77491150 wayland: Fix action handling more
When updating GdkDrop::actions from changes sent by
the compositor, we were inadvertently setting them to 0,
causing drops to appear impossible.
2020-01-04 09:38:31 -05:00
Matthias Clasen
709ebcedd4 wayland: Finish pending offer handling
When creating a new GdkDrop object on drag_enter, take pending
source_actions and action into account. The code to store the
pending actions was already there, they were just not passed
on to the drop object when we create it.
2020-01-04 09:38:01 -05:00
Matthias Clasen
47e6b88555 wayland: Clean up drags
We need to set the drag to NULL in gdk_wayland_drag_drop_done,
otherwise, all future drags will be considered local after the
first local one. Worse, they will also provide the wrong data.
2020-01-04 09:36:38 -05:00
Matthias Clasen
df58d0acf3 Adwaita: Make dnd marks in text views green
We already do this in entries, this just updates
text views to match.
2020-01-03 13:00:53 -05:00
Matthias Clasen
9c2c5665df textview: Render visible marks better
The only other visible mark that is in common use
besides insert and selection_bound is dnd_mark, and
we don't want it to blink or be affected by 'cursor'
visibility.

Therefore, cache not just the cursor positions, but
also whether they are insert or selection_bound,
and take that into account when rendering them.
2020-01-03 13:00:53 -05:00
Matthias Clasen
1be9c6aa3f Merge branch 'remove-xim' into 'master'
Remove the XIM input method

See merge request GNOME/gtk!1195
2020-01-03 17:56:26 +00:00
Matthias Clasen
96d2bf10b9 Add a text view mark/cursor test
This has testcases for some issues around invalidation
of marks.
2020-01-03 11:18:08 -05:00
Matthias Clasen
7a1aefc7f3 Fix the previous commit
We need to actually use the right coordinates.
2020-01-02 00:43:27 -05:00
Matthias Clasen
f7f06f810b stackswitcher: Fix switch-while-drag functionality 2020-01-02 00:24:54 -05:00
Matthias Clasen
e02fd80adb dnd: Be safer
The contents of the selection are documented
to not be NULL if size is non-negative. So
use an empty string instead of NULL for size 0,
avoiding a crash.
2020-01-01 12:51:19 -05:00
Matthias Clasen
4b818495ca wayland: Fix dnd type negotiation
We need to call gdk_content_formats_union_serialize_mime_types
like GdkClipboard does, in order to get mime types that we can
sent out.
2020-01-01 12:51:19 -05:00
Matthias Clasen
1841ec4f8e contentprovider: cosmetic fix 2020-01-01 12:51:19 -05:00
Matthias Clasen
21708e4352 contentserializer: Fix an annotation 2020-01-01 12:51:19 -05:00
Daniel Mustieles
662bcb34b1 Updated Spanish translation 2019-12-31 08:45:12 +01:00
Matthias Clasen
f8a19506ab Merge branch 'drag-icon' into 'master'
Drag icon

See merge request GNOME/gtk!1274
2019-12-30 21:20:26 +00:00
Matthias Clasen
67d1d5ec80 mountoperation: Handle D-Bus missing
Still not great to make sync calls here, but
at least we should handle failure without criticals.
2019-12-30 16:03:47 -05:00
Matthias Clasen
49c6e99970 Merge branch 'fix-dnd' into 'master'
Fix dnd

See merge request GNOME/gtk!1273
2019-12-30 17:12:30 +00:00
Matthias Clasen
15242d66e1 wayland: Pass root coordinates for dnd events
That is what the api currently requires, so provide it.

This fixes DND to work again, for the most part.
2019-12-30 12:00:53 -05:00
Matthias Clasen
94a0bc01f9 gdk: Populate dnd event coords
The GdkDrop emit... apis take root coordinates.
That should be changed to surface coordinates,
eventually. For now, make the functions fill
the x, y fields.
2019-12-30 11:58:11 -05:00
Matthias Clasen
677c4b140c gdk: Fix coordinates in dnd events
Don't store coordinates as shorts. Use doubles,
as everywhere else. Also add x, y in addition
to x_root, y_root, and actually return those
in gdk_event_get_coords.
2019-12-30 11:56:49 -05:00
Piotr Drąg
838ad5ed6d Update POTFILES.in 2019-12-30 17:30:18 +01:00
Matthias Clasen
772ac2b0c5 tooltip: Never set a window to be its own parent
We do get events on the tooltip window too, and
we better ignore them, or bad things may happen,
such as widgets that are their own parents and
cause infinite loops.

Fixes: https://gitlab.gnome.org/GNOME/gtk/issues/2339
2019-12-30 09:52:13 -05:00
Matthias Clasen
68b3b66c03 tooltipwindow: Cosmetic fix 2019-12-30 09:28:22 -05:00
Daniel Mustieles García
0d1614be63 Revert "Updated Spanish translation"
This reverts commit 62b95e33b8
2019-12-30 13:59:22 +00:00
Daniel Mustieles
62b95e33b8 Updated Spanish translation 2019-12-30 12:53:45 +01:00
Daniel Mustieles
dc5c8d2d29 Updated Spanish translation 2019-12-30 12:52:55 +01:00
Daniel Mustieles
425d5cc7c6 Updated Spanish translation 2019-12-30 12:52:01 +01:00
Matthias Clasen
baf99bb868 Remove gtk_window_set_hardcoded_surface
It is not used anymore.
2019-12-30 00:31:32 -05:00
Matthias Clasen
538efd0cc6 container: Be more careful with roots
We were warning if we hit non-container
roots. Instead, call suitable naive api.
2019-12-30 00:30:01 -05:00
Matthias Clasen
9ba184adf7 widget: Be more careful with roots
We were assuming that all roots are windows,
and calling GtkWindow apis on them.
2019-12-30 00:29:52 -05:00
Matthias Clasen
710b8d7f40 dnd: Use GtkDragIcon
Use the new GtkDragIcon instead of a window
of type GTK_WINDOW_POPUP and
gtk_window_set_hardcoded_surface.
2019-12-30 00:29:10 -05:00
Matthias Clasen
a6244a95be Add GtkDragIcon
This is a GtkRoot implemntation for drag icons,
using the surface provided by GdkDrag. This lets
us avoid GTK_WINDOW_POPUP and
gtk_window_set_hardcoded_surface.
2019-12-30 00:28:02 -05:00
Matthias Clasen
133b6f2f23 tooltipwindow: Cosmetic fix 2019-12-29 22:48:25 -05:00
Matthias Clasen
53a634e23e Merge branch 'tooltip-redo' into 'master'
Tooltip redo

See merge request GNOME/gtk!1271
2019-12-30 03:24:58 +00:00
Matthias Clasen
156935e0e9 docs: Mention custom tooltip windows in the migration guide
These no longer exist.
2019-12-29 22:09:13 -05:00
Matthias Clasen
f31a016efb tooltips: Stop using GTK_WINDOW_POPUP
Make GtkTooltipWindow a GtkNative implementation,
instead of using a GTK_WINDOW_POPUP window.
2019-12-29 22:09:13 -05:00
Matthias Clasen
e56eb7b17b testtooltips: Test tooltips on popovers
They do not currently work right.
2019-12-29 22:09:13 -05:00
Matthias Clasen
de694958b5 Drop custom tooltip windows
We want to put tooltips into something other than
windows, so this needs to go. Custom widgets are
still possible.
2019-12-29 20:52:08 -05:00
Matthias Clasen
e12a580b0b Merge branch 'kill-tree-menu' into 'master'
Menu removal, part 2

See merge request GNOME/gtk!1270
2019-12-30 01:46:29 +00:00
Matthias Clasen
52e0eef6cb docs: Touch up menu button docs 2019-12-29 20:31:58 -05:00
Matthias Clasen
85bf4cf895 docs: Mention the demise of menus in the migration guide
This needs more details, but it is a start.

Also add sections about grabs and about toolbar
overflow handling.
2019-12-29 20:31:58 -05:00
Matthias Clasen
b06331218d docs: Rewrite popover menu docs
These were outdated and did not reflect current api.
2019-12-29 20:31:58 -05:00
Matthias Clasen
9b165c8bec treeview: Use a popover for search
This is a more modern way of doing things, and avoids a window
of type GTK_WINDOW_POPUP. With a popover, it doesn't make sense
to have a positioning function, so remove that api.
2019-12-29 20:31:58 -05:00
Matthias Clasen
3fd427cfce win32: Use a regular window for printing
We never show this window, so it should not matter.
Ideally, we'd just create a surface to get handle,
anyway.
2019-12-29 20:31:58 -05:00
Matthias Clasen
0bb9fc65ad Remove gdk_seat_grab
We are no longer using free-standing grabs
in GTK. The replacement is the autohide
functionality of popup surfaces.
2019-12-29 20:31:58 -05:00
Matthias Clasen
3dd6cc405e accelcellrenderer: Stop grabbing
Standalone grabs are going away.
2019-12-29 20:31:58 -05:00
Matthias Clasen
06860bb2be accelcellrenderer: Fix editing 2019-12-29 20:31:58 -05:00
Matthias Clasen
7ee5779efc gtk: Remove menu code
GtkMenu, GtkMenuBar, GtkMenuItem and their subclasses
and supporting classes are replaced by model-based popover
implementations.
2019-12-29 20:31:58 -05:00
Matthias Clasen
53d9445715 doc: Build fixes 2019-12-29 20:31:58 -05:00
Matthias Clasen
54b2727b50 docs: Remove mentions of GtkMenuItem 2019-12-29 20:31:58 -05:00
Matthias Clasen
a2aefa83bb accellabel: Don't mention GtkMenuItem in the docs 2019-12-29 20:31:58 -05:00
Matthias Clasen
0854140b22 label: Stop referring to GtkMenuItem in the docs 2019-12-29 20:31:58 -05:00
Matthias Clasen
57a861723c buildertool: Drop menu properties 2019-12-29 20:31:58 -05:00
Matthias Clasen
b59521bb82 inspector: Remove menu special-casing 2019-12-29 20:31:58 -05:00
Matthias Clasen
7e8393ba0f widget: Remove menu special-casing 2019-12-29 20:31:58 -05:00
Matthias Clasen
9e15f3df75 label: Remove menu support code 2019-12-29 20:31:58 -05:00
Matthias Clasen
5c97f09796 tests: Stop using menus 2019-12-29 20:31:58 -05:00
Matthias Clasen
bf4ec504b2 testsuite: Remove menu special-casing 2019-12-29 20:31:58 -05:00
Matthias Clasen
59aeae3c8e testsuite: Remove menu tests
Menus are going away.
2019-12-29 20:31:57 -05:00
Matthias Clasen
941f22c033 testsuite: Cosmetic change 2019-12-29 20:31:57 -05:00
Matthias Clasen
27543120f2 menubutton: Stop supporting menus 2019-12-29 20:31:57 -05:00
Matthias Clasen
901518ec25 headerbar: Stop using GtkMenuButton::use-popover
This property is going away.
2019-12-29 20:31:57 -05:00
Matthias Clasen
4c9b0d82af menutoolbutton: Stop supporting menus 2019-12-29 20:31:57 -05:00
Matthias Clasen
2c5f4c5871 menutoolbutton: Fix sensitivity handling
We don't need to set the arrow button explicitly
to insensitive, GtkMenuButton handles that automatically.
2019-12-29 20:31:57 -05:00
Matthias Clasen
8ee44d200d toolbar: Simplify overflow implementation
Do away with the proxy menu items, and instead
just have toolitems provide a label for overflow
items. We create the overflow widgets ourselves
already, as model buttons.
Also replace the toggle button used for overflow
with a menubutton, simplifying things further.
2019-12-29 20:31:57 -05:00
Matthias Clasen
57b7e87d76 testsuite: Update combobox tests
Some of the expected output needs to be updated.
2019-12-29 18:45:40 -05:00
Matthias Clasen
e424246134 combobox: Replace GtkTreeMenu with a popover
This does not currently try to reproduce the exact
placement, since GtkPopover doesn't have to have
the necessary placement hints.
2019-12-29 18:45:40 -05:00
Matthias Clasen
ca87048045 gtk-demo: Remove the change display demo
The window picking code has been broken for a while.
Since this is not really functionality that we should
highlight to application developers, remove the demo
instead of patching it up.
2019-12-29 18:45:40 -05:00
Matthias Clasen
5ec9b15d84 gtk-demo: Convert the builder demo to a menu model 2019-12-29 18:45:40 -05:00
Matthias Clasen
6b691bc02d gtk-demo: Remove menus from listbox demo 2019-12-29 18:45:40 -05:00
Matthias Clasen
abcd83dd78 gtk-demo: Cosmetics 2019-12-29 18:45:40 -05:00
Matthias Clasen
5d2113ff5d gtk-demo: Remove the menus demo
Menus are going away.
2019-12-29 18:45:40 -05:00
Matthias Clasen
5c086b9d44 gtk-demo: Convert the dnd demo to a popover 2019-12-29 18:45:40 -05:00
Matthias Clasen
8efa612288 gtk-demo: Remove a somewhat silly bit of code
Putting a context menu on an overlay scrollbar
is too much of an easter egg to count as a useful
demo. Remove it, rather than changing it to a
popover.
2019-12-29 18:45:40 -05:00
Matthias Clasen
928f7faf7d gtk-demo: Use a popover in the clipboard demo 2019-12-29 18:45:40 -05:00
Matthias Clasen
4b4cf36b03 gtk-demo: Replace a menu with a popover 2019-12-29 18:45:40 -05:00
Matthias Clasen
5d821425b3 accellabel: Remove an example using menus 2019-12-29 18:45:40 -05:00
Matthias Clasen
8b3066127f docs: Avoid using a menu for an example 2019-12-29 18:45:40 -05:00
Matthias Clasen
360239a6c8 docs: Remove menubars from the visual index 2019-12-29 18:45:37 -05:00
Matthias Clasen
80e903afeb docs: Stop taking menubar screenshots
The widget is going away.
2019-12-29 18:44:26 -05:00
Matthias Clasen
62e9ea412a widget-factory: Remove the menubar 2019-12-29 18:44:26 -05:00
Matthias Clasen
3d4acf6360 window: Move F10 handling to popover menubars 2019-12-29 18:44:26 -05:00
Matthias Clasen
0cf1e1e106 applicationwindow: Stop using a menu bar
We have a replacement with popovers now.
2019-12-29 17:10:16 -05:00
Matthias Clasen
b23fbe1f39 notebook: Remove menu remnants 2019-12-29 17:10:16 -05:00
Matthias Clasen
f5e79b9bc5 appchooserwidget: Remove ::populate-popup
We are no longer doing menus this way; if a menu turns out to be
needed at all here, we can add a menu model later.
2019-12-29 17:10:16 -05:00
Matthias Clasen
94e238c467 placesview: Use a popover
Replace the context menu with a popover.
2019-12-29 17:10:16 -05:00
Matthias Clasen
22f6787283 mountoperation: Use a popover
Replace the context menu with a popover.
2019-12-29 17:10:16 -05:00
Matthias Clasen
6255dcd8ec filechooserbutton: Be smarter about 'None'
Don't refilter the model while the combo box is popped up,
that wreaks havoc with layout and does not really work.
Instead, repurpose one of the separator rows for the 'none'
case. This works because the row separator function is not
consulted for the cellview in the button.
2019-12-29 17:10:16 -05:00
Matthias Clasen
6f80eee962 window: Complete the popover conversion 2019-12-29 17:10:16 -05:00
Matthias Clasen
fd0f01bcad popovermenubar: Cosmetics 2019-12-29 17:10:16 -05:00
Matthias Clasen
0b6e521dc5 popovermenu: Use a weak ref for active item
Otherwise, we can end up with a dangling pointer,
leading to badness.
2019-12-29 17:10:15 -05:00
Matthias Clasen
ad6fe9d6a0 surface: Only unpause events if we paused them
When a new popup surface is created, it may end up
getting a resume-events signal from its frame clock
without having seen a flush-events first.

Don't unpause events in that case, since it messes
up the displays pause counter.

This was causing criticals with tooltips.
2019-12-29 13:35:36 -05:00
Matthias Clasen
7078765903 Revert unintended changes
I didn't mean to make this a complicated
portal test. Go back to being a simple test.
2019-12-29 13:03:44 -05:00
Matthias Clasen
a73947e54f Remove more mir remnants
The mir backend was removed a while ago, so
GDK_WINDOWING_MIR is never defined.
2019-12-28 21:52:34 -05:00
Matthias Clasen
7525271de1 tooltip: Remove some unneeded includes 2019-12-28 21:49:09 -05:00
Matthias Clasen
0bc65f0bde popover: Remove some dead code 2019-12-28 21:46:39 -05:00
Aurimas Černius
4a0476752c Updated Lithuanian translation 2019-12-28 18:18:53 +02:00
Matthias Clasen
9543a5daeb popovermenu: Fix keynav with submenus
When we right-arrow all the way into a submenu
and then cycle to the next menu in a menubar,
we need to reset all open submenus, so that
left-arrowing back to the menu puts the focus
on the first item again.
2019-12-27 22:54:11 -05:00
Matthias Clasen
28b91a4450 modelbutton: Be focusable
This got lost when modelbuttons stopped being
derived from buttons. It is necessary, since
the GTK focus machinery takes this flag seriously
nowadays, and won't let us grab focus to non-focusable
widgets.
2019-12-27 21:58:54 -05:00
Matthias Clasen
6b89d8a199 inspector: Add a focus overlay
It helps to see what is going on.
2019-12-27 17:35:09 -05:00
Fran Dieguez
e999016273 Update Galician translation 2019-12-27 14:42:53 +00:00
Jordi Mas
7c6e620f16 Fixes to Catalan translation 2019-12-27 14:06:32 +01:00
Piotr Drąg
267d5ae011 Update Polish translation 2019-12-25 16:36:41 +01:00
Matthias Clasen
08d4bb4785 widget: Fix a memory leak
The transform passed to gtk_widget_allocate is
transfer full, so we must consume the reference
before returning.
2019-12-25 09:47:22 -05:00
Matthias Clasen
a02e25ffff widget: Avoid a crash in event handling
I was seeing crashes in gtk_widget_run_controllers.
We were accessing the controller after calling out
to application code that might remove it. Better
be safe and do the access before.
2019-12-25 09:47:22 -05:00
Matthias Clasen
280bdb0567 inspector: Fix a small memory leak
We were leaking overlays.
2019-12-25 09:47:22 -05:00
Matthias Clasen
1a94e5fb0e inspector: Fix a small memory leak
The property editor was leaking a few GValues.
2019-12-25 09:47:22 -05:00
Matthias Clasen
b6cfe59460 inspector: Small cleanup 2019-12-25 09:47:22 -05:00
Matthias Clasen
7db2abf918 widget: Fix a small memory leak 2019-12-25 09:47:22 -05:00
Matthias Clasen
b398af914f eventcontroller: Fix name property
This never worked. Oops.
2019-12-25 09:47:22 -05:00
Matthias Clasen
29e1dac1ff testfilechooser: Test the choice apis 2019-12-25 09:47:22 -05:00
Fran Dieguez
3af8a658a7 Update Galician translation 2019-12-25 04:05:00 +00:00
Fran Dieguez
b5aeb29146 Update Galician translation 2019-12-25 03:16:43 +00:00
Matthias Clasen
85b702b0d1 Merge branch 'print-dialog-fixes' into 'master'
Print dialog fixes

See merge request GNOME/gtk!1268
2019-12-24 17:41:38 +00:00
Matthias Clasen
77c57b4b14 Adwaita: update the README 2019-12-24 12:30:54 -05:00
Matthias Clasen
10d260ec71 HighContrast: print dialog fixes
Fix up the paper drawing.
2019-12-24 12:30:44 -05:00
Matthias Clasen
1ac8bb0128 Adwaita: print dialog tweaks
Fix up the paper drawing.
2019-12-24 12:30:35 -05:00
Matthias Clasen
28539ba838 print dialog: Fix up page drawing
This fixes up page drawing enough to appear properly
with the builtin themes.
2019-12-24 12:30:28 -05:00
Matthias Clasen
f1bb6ef658 Merge branch 'widget-factory-fixes' into 'master'
Widget factory fixes

See merge request GNOME/gtk!1267
2019-12-24 15:08:15 +00:00
Matthias Clasen
24c66f831f widgetfactory: Undo more builder-tool damage
The two volume buttons are supposed to be
vertically arranged.
2019-12-24 09:59:23 -05:00
Matthias Clasen
87502b4f2e Fix the build 2019-12-24 09:58:56 -05:00
Matthias Clasen
3644d3a100 Merge branch 'gtk-demo-fixes' into 'master'
Gtk demo fixes

See merge request GNOME/gtk!1266
2019-12-24 08:47:28 +00:00
Matthias Clasen
9e3147f78d treeview: Fix embedding cell renderers
We need to manually set up the css node,
since the treeview has children whose css
node is not a direct child of the treeview
css node (header buttons).
2019-12-24 03:39:02 -05:00
Matthias Clasen
cc3ecac6d8 cell renderer spin: Bring this back
GtkSpinButton lost its cell editable implementation
when it stopped being a GtkEntry subclass. Add it
back, and make it work.
2019-12-24 03:33:02 -05:00
Matthias Clasen
72932d2776 cell renderer text: Fix this to work again
We were showing the entry, and removing it right
away when the focus moved to the text child.
Avoid that.
2019-12-24 03:13:58 -05:00
Matthias Clasen
58bc9452f6 paper dialog: Make this look less horrible 2019-12-24 03:12:30 -05:00
Matthias Clasen
2a7b5d8229 accelgroup: Fix a buffer overrun
gtk_accelerator_parse_with_keycode can
overrun its buffer for certain inputs.

Fixes: https://gitlab.gnome.org/GNOME/gtk/issues/2325
2019-12-23 23:17:29 -05:00
Matthias Clasen
245546de61 Merge branch 'drop-GtkTreeViewPrivate' into 'master'
tree-view: Drop GtkTreeViewPrivate

See merge request GNOME/gtk!1240
2019-12-24 03:49:48 +00:00
Matthias Clasen
a3793ff137 Merge branch 'drop-gtk-tree-selection-private' into 'master'
tree-selection: Drop GtkTreeSelectionPrivate

See merge request GNOME/gtk!1256
2019-12-24 03:48:18 +00:00
Matthias Clasen
0a98817a6f Merge branch 'wip/oholy/placesview-default-location' into 'master'
placesview: Always open default location after mounting

See merge request GNOME/gtk!1263
2019-12-24 03:47:15 +00:00
Matthias Clasen
663fb93af7 gtk-demo: Fix font explore initial state 2019-12-23 22:35:44 -05:00
Matthias Clasen
db42c23c0a gtk-demo: Fix a crash in the font explorer demo
gtk_widget_add_controller is transfer-full.
2019-12-23 22:33:02 -05:00
Matthias Clasen
33716d1e50 gtk-demo: Cosmetic fixes to the dnd demo 2019-12-23 22:14:52 -05:00
Matthias Clasen
65769fd7a6 gtk-demo: Cosmetic fixes to the assistant demo 2019-12-23 21:58:45 -05:00
Matthias Clasen
e6d3f3d91e gtk-demo: Fix the application demo
This was broken in d223752c55, when the
support for internal children was removed
from GtkInfoBar.
2019-12-23 21:52:52 -05:00
Matthias Clasen
79a17d5a25 Merge branch 'validate-templates' into 'master'
builder-tool: Validate templates again

See merge request GNOME/gtk!1265
2019-12-23 23:40:43 +00:00
Matthias Clasen
c924b48a6c builder-tool: Validate templates again
This wasn't working because it was expecting
some no-longer-existing error message.
2019-12-23 18:32:37 -05:00
Matthias Clasen
519ff576cd colorchooser: Document actions
This is mainly a trial balloon for gtk-doc
support for this syntax.

See https://gitlab.gnome.org/GNOME/gtk-doc/merge_requests/30
2019-12-23 13:39:05 -05:00
Matthias Clasen
5bc3bed461 Merge branch 'inspector-advice' into 'master'
inspector: Give better advice

See merge request GNOME/gtk!1264
2019-12-22 19:02:37 +00:00
Matthias Clasen
442f13ef6f inspector: Give better advice
Provide the meson syntax for building a debug-enabled GLib.
2019-12-21 21:09:18 -05:00
Christoph Reiter
95aeadf36c Merge branch 'ci-msys2-newer-pango' into 'master'
CI: Install a newer MSYS2 pango package; Don't allow failures again

Closes #2243

See merge request GNOME/gtk!1258
2019-12-19 17:59:40 +00:00
Ondrej Holy
267ea7552b placesview: Always open default location after mounting
The default location (obtained over g_mount_get_default_location) is
opened after mounting volume, or when opening mounts from sidebar, but
not after mounting over "Connect to Server". Let's unify the behavior
and always open the default location.

https://gitlab.gnome.org/GNOME/nautilus/issues/1319
2019-12-19 17:28:35 +01:00
Matthias Clasen
08f7526f8f Merge branch 'fix-gtkgesturerotate-potential-leak' into 'master'
gtkgesturerotate: Fix a memory leak

See merge request GNOME/gtk!1260
2019-12-19 03:42:31 +00:00
Yariv Barkan
0604924c20 gtkgesturerotate: Fix a memory leak
On touchpads gtk_gesture_get_sequences() was called without a
corresponding g_list_free(). The same was true for touchscreens
if due to some reason only a single sequence was found.
2019-12-18 23:03:19 +02:00
Christoph Reiter
5ef2748cef CI: Install a newer MSYS2 pango package; Don't allow failures again
gtk master requires a newer pango than msys2 has, so install our own copy on top.

See #2243
2019-12-18 09:25:06 +01:00
Christoph Reiter
8f8229dcd2 Fix various new mingw compiler warnings
These are the result of us missing CI for some time now and
MSYS2 having a newer GCC now I guess.
2019-12-18 09:25:06 +01:00
Peter Bloomfield
a5b5657e96 tree-selection: Drop GtkTreeSelectionPrivate
GtkTreeSelection is now private (since commit 79940b32),
so it doesn't need an instance-private structure.
2019-12-16 20:54:23 -05:00
Emmanuele Bassi
0f2281e267 Merge branch 'ci-update-at-spi' into 'master'
Update CI image

Closes #2313

See merge request GNOME/gtk!1254
2019-12-16 19:26:37 +00:00
Emmanuele Bassi
994a807819 ci: Use latest CI image 2019-12-16 19:01:03 +00:00
Emmanuele Bassi
79f42cec8e ci: Add libXtst-devel to the Docker image
New requirement from at-spi2-core.

Fixes: #2313
2019-12-16 19:00:02 +00:00
Matthias Clasen
0546fd7c8a Merge branch 'fix.nonunix.builds' into 'master'
Fix non-portal (UNIX) builds

See merge request GNOME/gtk!1252
2019-12-16 17:38:56 +00:00
Chun-wei Fan
d51e3e835e tests/: Revert bbb56d8 for non-UNIX
The portal bits are only supported on *nix, so use the old code on
non-*nix.
2019-12-17 00:52:25 +08:00
Chun-wei Fan
3d8d4921af gdk: Build portal bits on *nix only
The newly-added portal items are supported on *nix only, so only build
them on *nix.
2019-12-17 00:52:18 +08:00
Matthias Clasen
ba3549fa34 Merge branch 'matthiasc/for-master' into 'master'
file transfer: Fix build on non-Linux

See merge request GNOME/gtk!1253
2019-12-16 16:48:01 +00:00
Matthias Clasen
721595edea file transfer: Fix build on non-Linux
O_PATH and O_CLOEXEC are not universally available.
2019-12-16 11:38:04 -05:00
Peter Bloomfield
46d960ddfd tree-view: Drop GtkTreeViewPrivate
GtkTreeView is now private, so it doesn't need an instance-private
structure.
2019-12-15 19:19:42 -05:00
Benjamin Otte
ed24f93fb9 popover: Remove unneeded vfunc
The vfunc is identical to the GtkWidget implementation it replaces. So
just keep using that one.
2019-12-15 21:07:54 +01:00
Benjamin Otte
c4043a8eef treelistmodel: Improve docs
- Move into its own section
- Split GtkTreeListRow into its own document

Trees are weird with listmodels and they deserve their own treatment,
they shouldn't be mushed up with the rest of the list machinery.
2019-12-15 21:07:54 +01:00
Benjamin Otte
dff86c0e12 eventcontrollermotion: Add getters for the properties
... and use them.

Also, rename them from is/contains-pointer-focus to is/contains-pointer,
that's clear enough and not too long.

Finally, adapt the semantics of contains-pointer to mirror
GtkEventControllerKey::contains-focus. If is-pointer is set, so is
contains-pointer, they are not exclusive.
Which is what all users of this property wanted, too.
2019-12-15 21:07:54 +01:00
Matthias Clasen
9a5ec33d61 Merge branch 'fix-x11-cursor-crash' into 'master'
x11: Only update cursors if we have any

Closes #2308

See merge request GNOME/gtk!1249
2019-12-13 20:02:43 +00:00
Matthias Clasen
78227bf5b0 Merge branch 'matthiasc/for-master' into 'master'
some builder-tool improvements

See merge request GNOME/gtk!1248
2019-12-13 19:58:53 +00:00
Matthias Clasen
bf2c29a36a x11: Only update cursors if we have any
We were accessing an on-demand created hash table
without checking if it had been created first.

Fixes: https://gitlab.gnome.org/GNOME/gtk/issues/2308
2019-12-13 14:46:00 -05:00
Matthias Clasen
47285c6642 builder: Improve type name mangling
When looking for the get_type function for GThemedIcon,
try both g_themed_icon_get_type and gthemed_icon_get_type
The former is what gio has, the latter is still supported
to avoid breaking gweather_location_get_type.

Update tests to cover this new case.
2019-12-13 14:21:44 -05:00
Matthias Clasen
e4fb4116fd builder-tool: Don't try to find default boxed values
This doesn't work and yields an ugly, unnecessary
error message.
2019-12-13 14:21:44 -05:00
Matthias Clasen
6d3373cb2c gtk-builder-tool: More helpful error messages
Include line numbers in the error messages we
report, so it is possible to find the error.
2019-12-13 14:21:44 -05:00
Marek Kasik
6ddc214e68 printing: Fill device URI for non-Avahi printers
Device URI was not filled for non-Avahi printers by my previous commit.
I've added it back. It was a mistake during rebasing of the patch
to current master.
2019-12-13 17:53:14 +01:00
Matthias Clasen
91a802a1e5 Merge branch '1509-don-t-show-Rejecting-Jobs-when-we-don-t-know' into 'master'
Fix getting info for standalone IPP printers

Closes #1509

See merge request GNOME/gtk!1247
2019-12-13 16:13:17 +00:00
Daniel Mustieles
886ab54eda Updated Spanish translation 2019-12-13 12:24:36 +01:00
Matthias Clasen
4470e5bc93 gtk-demo: Some touchups
Make the theming style classes demo look a bit less odd.
2019-12-12 18:46:53 -05:00
Matthias Clasen
9bbacd3e4c Run gtk-builder-tool simplify over our ui files
This was done mainly to verify that the tool does not
make any unwarranted changes. The changes included here
are all cosmetic.
2019-12-12 18:37:39 -05:00
Matthias Clasen
353df67c0b Add GtkNative to the docs
It was not included in the generated docs.
2019-12-12 18:21:16 -05:00
Matthias Clasen
050eb9ba73 Fix up GtkBuilderScope docs
They were not hooked into the document generation.
2019-12-12 18:18:49 -05:00
Matthias Clasen
4fa5f5497a builder: Another small docs fix 2019-12-12 17:59:24 -05:00
Matthias Clasen
21a032b783 docs: Ignore more private headers 2019-12-12 17:59:24 -05:00
Matthias Clasen
207efd8932 docs: Remove symbols that no longer exist 2019-12-12 17:59:24 -05:00
Matthias Clasen
43c943e48a Merge branch 'issue-179' into 'master'
Use a separate gesture for middle clicks on PlaceView rows

Closes #179

See merge request GNOME/gtk!1199
2019-12-12 22:53:36 +00:00
Matthias Clasen
d6dc5da6db textbuffer: Minor doc fixes
Fix parameter name mismatches.
2019-12-12 17:31:13 -05:00
Matthias Clasen
12d787286e builder: Minor doc fixes
Fix parameter name mismatches.
2019-12-12 17:30:36 -05:00
Matthias Clasen
c33a7670d0 Merge branch 'wip/otte/builder' into 'master'
More builder work

Closes #2267

See merge request GNOME/gtk!1230
2019-12-12 20:36:08 +00:00
Matthias Clasen
bbb56d8216 Merge branch 'file-transfer' into 'master'
clipboard: file transfer portal support

See merge request GNOME/gtk!1244
2019-12-12 19:33:02 +00:00
Matthias Clasen
a20c8af678 clipboard: file transfer portal support
Implement file-list <-> application/vnd.flatpak.file-list
serialization by talking to the file transfer portal.

See https://github.com/flatpak/xdg-desktop-portal/pull/222
2019-12-12 14:25:33 -05:00
Matthias Clasen
0eb2b382a2 Merge branch 'master-gitlab-HC-tooltip' into 'master'
Set HighContrast tooltip back to black text over white background

See merge request GNOME/gtk!1242
2019-12-12 19:18:06 +00:00
Benjamin Otte
101298c54d gtk-demo: Don't include "gtk.h" 2019-12-12 19:50:55 +01:00
Benjamin Otte
f6bdfc32d3 tests: Set an existing font in testfontchooser 2019-12-12 19:50:55 +01:00
Benjamin Otte
5015730212 builder: Turn last dlsym() function into a scope API
Looking up a get_type function by its name is now also part of
GtkBuilderScope.
2019-12-12 19:39:36 +01:00
Benjamin Otte
f8a7f30a0d builder: Add GtkBuilderScope
GtkBuilderScope is an interface that provides the scope that a builder
instance operates in.
It creates closures and resolves types. Language bindings are meant to
use this interface to customize the behavior of builder files, in
particular when instantiating templates.

A default implementation for C is provided via GtkBuilderCScope (to keep
with the awkward naming that glib uses for closures). It is derivable on
purpose so that languages or extensions that extend C can use it.

The reftest code in fact does derive GtkBuilderCScope for its own scope
implementation that implements looking up symbols in modules.

gtk-widget-factory was updated to use the new GtkBuilderCScope to add
its custom callback symbols.
So it does it different from gtk-demo, which uses the normal way of
exporting symbols for dlsym() and thereby makes the 2 demos test the 2
ways GtkBuilder uses for looking up symbols.
2019-12-12 19:39:23 +01:00
Benjamin Otte
1f94028ff7 builder: Add gtk_builder_set_current_object()
Use it as the default object for expression binds and when connecting
signals. It is intended to work kind of as the "this" object while
parsing. In fact, the term "current object" was stolen from the Java
docs and various C++ tutorials for the this pointer.

Set the current object in gtk_widget_init_template() and
GtkListItemBuilder.

This more-or-less replaces the object passed to
gtk_builder_connect_signals() in GTK3.
2019-12-12 19:12:11 +01:00
Benjamin Otte
512c4c13a6 builder: Add gtk_builder_lookup_object()
... and use it. This function looks up an object like
gtk_builder_get_object() but generates an error on failure.

Unlike the evil function _gtk_builder_lookup_object() which also
generates an error but hides it for later lookup.

Use this to avoid continuing applying properties when an error was
encountered.
2019-12-12 19:12:11 +01:00
Benjamin Otte
552db7cb08 types: Move GTK_INVALID_LIST_POSITION here
I have no idea where it should go really - maybe glib?

It certainly shouldn't require everybody including selectionmodel code
just to get at this value.
2019-12-12 19:10:45 +01:00
Matthias Clasen
d564cb2a7e Merge branch 'terminal' into 'master'
imwayland: Suppport terminal purpose

See merge request GNOME/gtk!1243
2019-12-12 17:57:05 +00:00
Marek Kasik
a6e3fc2d2f printing: Fix getting info for standalone IPP printers
Create printer name from name of the advertised service
for standalone IPP printers as opposed to CUPS printers
advertised via Avahi which get name from their
resource path.
This is similar to what cups-filters does.

Pass GtkPrinter class to request for printer info
so that it does not need to be searched for
(such search could fail for standalone IPP printers).

https://gitlab.gnome.org/GNOME/gtk/issues/1509
2019-12-12 17:08:30 +01:00
Marek Kasik
e54049bc26 printing: Don't show Rejecting Jobs when we don't know
Set reasonable default values for printers discovered
by Avahi which do not have 'printer-type' attribute.
This is the case for network printers which were not
published by CUPS.

Related to the issue #1509.
2019-12-12 17:08:30 +01:00
Dorota Czaplejewicz
e331b39ca5 imwayland: Suppport terminal purpose 2019-12-12 14:37:51 +00:00
Jonathan Michalon
e6270ca43f Set HighContrast tooltip back to black text over white background
8abdbfee16 pulled Adwaita tooltip selectors,
but in the meantime the colors were also set to Adwaita's. Push back the same
behaviour as before because it's better for visually-impaired users.
2019-12-12 09:51:40 +01:00
Christoph Reiter
88da95d921 Merge branch 'honor-hotspot-gtk4' into 'master'
gdk/x11: Honor hotspot during drag cancel animation

See merge request GNOME/gtk!1236
2019-12-11 12:59:23 +00:00
Chun-wei Fan
44f9c67466 Merge branch 'vulkan-no-layered-windows' into 'master'
Win32: Do not enable layered windows when using Vulkan

See merge request GNOME/gtk!1217
2019-12-11 06:24:49 +00:00
Matthias Clasen
02bbe399df Merge branch 'matthiasc/for-master' into 'master'
widget factory: Fix more grid layout fallout

See merge request GNOME/gtk!1237
2019-12-10 03:05:09 +00:00
Matthias Clasen
41bb40feee widget factory: Fix more grid layout fallout 2019-12-09 21:29:03 -05:00
Benjamin Otte
336d652be5 a11y: We can peek here
Avoids instantiating a11y objects when we don't need to.
2019-12-09 16:35:41 +01:00
Benjamin Otte
d3e8678955 treeview: Don't create a cyclic reference
TreeRowReference refs the proxy object, so don't use proxies.
2019-12-09 16:35:41 +01:00
Benjamin Otte
503d988c1b label: Compute label baselines correctly
When we were switching smallest and widest, we were not switching the
baselines.
2019-12-09 16:35:41 +01:00
Robert Mader
7a46378e71 gdk/x11: Honor hotspot during drag cancel animation
Otherwise the icon "jumps" to the cursor position with its top left when
the animation starts.
This is especially visible if the dragged item is big, like when dragging
mails in Thunderbird.
2019-12-09 01:45:30 +01:00
Matthias Clasen
9f6d12551f Add GtkTreeListRow type to the docs 2019-12-08 17:58:09 -05:00
Matthias Clasen
43c93d6f85 Add missing listmodel and selection types to the docs 2019-12-08 13:56:47 -05:00
Matthias Clasen
d683d085c0 tree list model: Add a missing annotation
The GtkTreeListModelCreateModelFunc returns
a new reference.
2019-12-08 00:30:32 -05:00
Matthias Clasen
92ab450983 inspector: Avoid critical warnings
We were still using this but it's not defined in the UI xml.

Fixes: https://gitlab.gnome.org/GNOME/gtk/issues/2295
2019-12-07 19:39:02 -05:00
Matthias Clasen
7b14c65b41 Merge branch 'inspector-display' into 'master'
Inspector display

See merge request GNOME/gtk!1234
2019-12-07 23:20:51 +00:00
Matthias Clasen
c89c652401 inspector: Make the css tree respect inspected display
The display is used here to force reparsing the theme
on the right settings object.
2019-12-07 18:07:44 -05:00
Matthias Clasen
f0f57d156b inspector: Make logs respect inspected display 2019-12-07 18:07:05 -05:00
Matthias Clasen
cecf4f2763 inspector: Make inspect button use inspected display
This may not matter, but just for cleanliness.
2019-12-07 18:07:05 -05:00
Matthias Clasen
4eeed47c7b inspector: Make general respect inspected display 2019-12-07 18:07:05 -05:00
Matthias Clasen
bd1f7e057a inspector: Make visual settings respect the inspected display
This is not quite complete, GTK and GSK debug flags
are not per display, and slowdown and text direction
are not either.
2019-12-07 18:07:05 -05:00
Matthias Clasen
174d8b72a5 inspector: Make css editor respect inspected display
Stop using gdk_display_get_default and use the
inspected display instead.
2019-12-07 18:07:05 -05:00
Matthias Clasen
1437b0856c inspector: Make object tree respect inspected display
Stop using gdk_display_get_dfault and use the
inspected display instead.
2019-12-07 14:59:49 -05:00
Matthias Clasen
917181cb67 window: Get rid of the inspector_window static
Use the new per-display inspector plumbing and
stop relying on a static variable.
2019-12-07 14:59:49 -05:00
Matthias Clasen
a207a4b3cd inspector: Attach inspector window to display
Give the inspector window a ::inspected-display
property, and pass a display when obtaining an
inspector window. Update the caller.
2019-12-07 14:59:49 -05:00
Matthias Clasen
39a1d27960 window: Inspector cleanups
Reduce the use of the inspector_window static.
The goal is to have one inspector window per
display, so we need to get rid of the static.
2019-12-07 14:59:49 -05:00
Matthias Clasen
5ef4a64084 window: Remove inspector updating fully
Commit 05e752e096 left some ruins behind.
Clean that up.
2019-12-07 14:59:49 -05:00
Matthias Clasen
baacd9efbf inspector: Init yourself
No need to have GTK call this from the outside.
2019-12-07 14:59:49 -05:00
Matthias Clasen
abde37a4d7 inspector: Cleanup
Remove an unused enum.
2019-12-07 14:59:49 -05:00
Matthias Clasen
3ee9b0cf4b Make a test with a custom display
This completely breaks the inspector.
2019-12-07 10:03:42 -05:00
Matthias Clasen
88049915a2 Merge branch 'doc-update' into 'master'
doc: Cleanup doc removing mentions of gdk_surface_shape_combine_region()

See merge request GNOME/gtk!1232
2019-12-05 22:11:31 +00:00
Hubert Figuière
585397937d doc: Cleanup doc removing mentions of gdk_surface_shape_combine_region() 2019-12-05 11:33:09 -05:00
Matthias Clasen
256b6f1aff Merge branch 'matthiasc/for-master' into 'master'
fix leaks in the testsuite

See merge request GNOME/gtk!1231
2019-12-05 00:01:23 +00:00
Matthias Clasen
acabdafb35 Fix treelistmodel tests
They were failing to return a reference where they
need to. This was uncovered by fixing an unrelated
ref leak.
2019-12-04 18:30:37 -05:00
Matthias Clasen
168c1f440d Fix leaks in tests
All the list model tests were leaking items,
because g_list_model_get_item is transfer full.

Fixing these unveils a crash in the treelistmodel
and maplistmodel tests.
2019-12-04 18:24:56 -05:00
Tim Sabsch
33a8ef4bce Update German translation 2019-12-04 19:37:01 +00:00
Benjamin Otte
33bd8f322c builder: Improve error message 2019-12-03 18:12:25 +01:00
Benjamin Otte
bfe4255807 builder: Allow objects in gtk_builder_value_from_string_type()
Instead of throwing an error, lookup objects with
gtk_builder_get_object().
2019-12-03 18:12:25 +01:00
Benjamin Otte
a15fb95c46 gtk-demo: Use normal way to lookup up symbols
We're a normal application, so we can use the normal way to hook up code
into builder files, which is using dlsym() for the function pointers.

There's no need to to extra work exporting static symbols.
2019-12-03 18:12:25 +01:00
Benjamin Otte
292371932b css: Handle invalid :not() selectors
We weren't correctly ending the ( ) block when encountering an error.

Testcases added.

Fixes #2281
2019-12-03 18:12:25 +01:00
Timm Bäder
564e8f483c Merge branch 'wip/wayland-hidpi-swap-region' into 'master'
Fix HiDPI swap regions on Wayland

See merge request GNOME/gtk!1228
2019-12-03 16:05:08 +00:00
Jonas Ådahl
ba74f41a70 wayland/vulkancontext: Fix present region on HiDPI
VkPresentRegionsKHR is expected to operate in buffer coordinates, but
the region we get passed is in surface coordinates, so it must be scaled.
2019-12-03 16:45:37 +01:00
Jonas Ådahl
d6a6313493 wayland/glcontext: Fix damage region on HiDPI
The passed regions are in surface coordinates, but
eglSwapBuffersWithDamage() is in buffer coordinates.
2019-12-03 16:45:37 +01:00
Emmanuele Bassi
9b5a7ae802 Merge branch 'fix-treemodelsort_processed_as_treemodel' into 'master'
Annotate GtkTreeModelSort.new_with_model() appropriately

See merge request GNOME/gtk!1134
2019-12-03 15:36:43 +00:00
LutzLue
e4b8481dd0 Annotate GtkTreeModelSort.new_with_model() appropriately
The new_with_model() method is a constructor, and it returns a GtkTreeModelSort
instance, even if the C API returns a GtkTreeModel for the convenience of C
developers.

Fixes: #1077
2019-12-03 15:36:42 +00:00
Timm Bäder
d868b23c76 gl renderer: Implement blurred inset shadow nodes
And with this...

Fixes #1101
2019-12-03 08:40:35 +01:00
Timm Bäder
56b456ff21 gl renderer: Remove unused uniform from inset shadow shader 2019-12-03 08:40:35 +01:00
Timm Bäder
b91913d10d opbuffer: Remove unused op member 2019-12-03 08:40:35 +01:00
Timm Bäder
ac1497eb2d testsuite: Add an inset shadow rendering test case 2019-12-03 08:40:35 +01:00
Timm Bäder
1854f3f49c gl renderer: Cache current scale in RenderOpBuilder
We call ops_get_scale a lot, so this should be better. It will also make
a later x/y split for the scaling easier.
2019-12-03 08:40:34 +01:00
Timm Bäder
a75523da68 cssshadowvalue: Simplify inset shadow nodes to color nodes if possible
inset shadows like this are frequently used to implement highlights in
CSS without crowing them min size of the element.
2019-12-03 08:40:34 +01:00
Timm Bäder
ca66e9788c gl renderer: Save one level of indentation 2019-12-03 08:40:34 +01:00
Timm Bäder
83ec7d562a window: Don't set invalid csd input shape
This might happen if the CSS values of the decoration node are broken,
e.g. if people *accidentally* type large negative values for the
margins.

Fixes #2268
2019-12-03 08:40:34 +01:00
Timm Bäder
05e9a9b572 snapshot: Reorder color matrix nodes containing a transform node
A color matrix node that contains a transform node can also be expressed
the other way around, as a transform node containing a color matrix
node.

In the general case, the color matrix node will have to draw its
child to a texture so it can color every pixel of that texture, but the
renderers can short-cut this if the child of the color matrix node is
already a texture node. So if we have a node tree like

Color Matrix
    - Transform
        - Texture

The renderer would have to either check the grandchild of the color
matrix or simply fall back to rendering the transform node to a texture.

In the new configuration:

Transform
    - Color Matrix
        - Texture

The renderer can easily see that the child node of the color matrix node
is a texture, and skip rendering it to a texture.

This is for example happening in current Adwaita for spinners, which are
rotated symbolics.
2019-12-03 08:40:34 +01:00
Timm Bäder
bc7b37d307 snapshot: Factor out color matrix merging
We will use that elsewhere in the next commit.
2019-12-03 08:40:34 +01:00
Timm Bäder
fb5dc73841 gl renderer: Implement blurred shadow nodes 2019-12-03 08:40:34 +01:00
Timm Bäder
8d61d9f627 gl renderer: Take a TextureRegion in blur_texture
So we can refer to textures on a texture atlas.
2019-12-03 08:40:34 +01:00
Timm Bäder
22b6085c32 gl renderer: Scale blur radius
We scale the texture size, so as a consequence we have to scale the blur
radius.
2019-12-03 08:40:34 +01:00
Timm Bäder
2deb1a05a0 gl renderer: Add some often needed debug code 2019-12-03 08:40:34 +01:00
Timm Bäder
8ca46169b1 gl renderer: Blur shader improvements
Use a two-pass blur shader, fix a few other things and unify the
blurring of blur nodes and blurred outset shadow nodes.

Related to #1283
2019-12-03 08:40:34 +01:00
Timm Bäder
642ced0cfc testblur: Fix default blur radius
sync it up with the adjustment value. also just add the destroyed
handler.
2019-12-03 08:40:34 +01:00
Matthias Clasen
a635076106 Merge branch 'improve-popover-menu-style' into 'master'
Adwaita: Improve popover.menu styling

See merge request GNOME/gtk!1083
2019-12-02 13:19:50 +00:00
nana-4
23d8aa40fe Adwaita: Remove unused popover check/radio styling 2019-12-02 20:48:10 +09:00
nana-4
0933630ee5 Adwaita: Flatten circular buttons in popover.menu
Just reuse the list button style.

https://gitlab.gnome.org/GNOME/gtk/issues/1824
2019-12-02 20:48:09 +09:00
nana-4
797cecd9ae Adwaita: Make check & radio symbolic icon style in popover.menu
The disabled modelbutton color needs to be specified explicitly
in order for check & radio to properly read the color with
currentColor.

https://gitlab.gnome.org/GNOME/gtk/issues/1824
2019-12-02 20:48:09 +09:00
nana-4
4c2707916c Adwaita: Improve popover.menu styling
Based on the mockup:
https://gitlab.gnome.org/Teams/Design/os-mockups/blob/master/menus/menu-design-patterns.png

- Remove horizontal padding from popover.menu contents
- Remove roundness from modelbutton
- Adjust sizing to match the mockup
- Fix visual glitches on button.image-button.model
- Add missing mergin to arrow icons
- Fix accelerator position in rtl direction
- Fix accelerator color

https://gitlab.gnome.org/GNOME/gtk/issues/1824
2019-12-02 20:48:09 +09:00
Matthias Clasen
ab32b1bba2 Merge branch 'wip/muktupavels/opaque-region-master' into 'master'
window: fix opaque region

See merge request GNOME/gtk!1222
2019-12-01 15:11:00 +00:00
Matthias Clasen
619c892032 Merge branch 'sass-no-extend-compound-master' into 'master'
themes: remove various @extend with compound selectors

See merge request GNOME/gtk!1223
2019-12-01 15:09:39 +00:00
nana-4
87ea0253aa themes: remove various @extend with compound selectors
They are no longer supported by sass and broken with libsass 3.6.3
(https://github.com/sass/libsass/issues/3033)

This removes them by replacing them with a placeholder selector. This at
least brings the resulting CSS size down a bit so gtk can be build
again.

`%button.flat.suggested-action` has been replaced by
`%selection_mode_button_flat`, which is a more appropriate selector for
`.selection-mode button.titlebutton`.

The CSS was generated with libsass 3.5.5.

Co-authored-by: Christoph Reiter <reiter.christoph@gmail.com>

See https://gitlab.gnome.org/GNOME/gtk/issues/2237
2019-12-01 10:43:16 +09:00
Alberts Muktupāvels
e81a90c432 window: fix opaque region
Decoration node for drawing is used only for client side decorated
windows, but corners from opaque region is subtracted also for
normal windows.

Rename function to better reflect what it does and do not subtract
corners if decoration node was not used for drawing.
2019-11-30 20:19:26 +02:00
Timm Bäder
fe385c28f6 Merge branch 'gtk-link-color' into 'master'
Adwaita: always use link specific colors for link selector

See merge request GNOME/gtk!1201
2019-11-30 07:40:48 +00:00
Matthias Clasen
6c4ab7d208 Merge branch 'matthiasc/for-master' into 'master'
some builder-tool tests

See merge request GNOME/gtk!1220
2019-11-29 15:21:40 +00:00
Matthias Clasen
dd52dd8bb0 Update the test scripts
All tools got renamed to have a gtk4 prefix.
2019-11-29 10:06:39 -05:00
Matthias Clasen
174cdb09a7 Add a test for the previous fix 2019-11-29 10:04:59 -05:00
Matthias Clasen
c3ca34cf51 Merge branch 'matthiasc/for-master' into 'master'
builder-tool: Fix handling of layout properties

See merge request GNOME/gtk!1219
2019-11-29 14:00:05 +00:00
Matthias Clasen
85950afbbd builder-tool: Fix handling of layout properties
We were not properly identifying layout properties
that need to be kept, causing GtkGrid left-attachment
to go missing in widget-factory.ui.
2019-11-29 08:47:35 -05:00
Matthias Clasen
da063a8aa5 Fix up widget-factory ui 2019-11-29 08:34:09 -05:00
Timm Bäder
9d94627f75 Merge branch 'dont-color-labels-directly-gtk4' into 'master'
Adwaita: Avoid directly coloring labels wherever possible (GTK4)

Closes #1643

See merge request GNOME/gtk!1209
2019-11-29 11:53:07 +00:00
Timm Bäder
5bdd25627f reftests: Fix css-multi-state test
Properly unset theme CSS and use the right selector for the toggle
buttons.
2019-11-29 20:26:45 +09:00
Carlo Lobrano
7bb8a480f1 Adwaita: always use link specific colors for link selector
link target uses `$selected_bg_color` and `$selected_fg_color` for the
definition of some selectors (e.g. selected).

While `$link_color` and `$link_visited_color` are based on
`$selected_bg_color`, this does not seem coherent.

Replacing `$selected_*g_color` in link target style with link colors
defined in `_colors.scss file`.
2019-11-29 07:32:16 +01:00
Matthias Clasen
be74be0e3b widget-factory: Fix a popover menu
This one is manually constructed, and things have
changed enough for that to break. Fix it up.
2019-11-27 17:41:44 -05:00
Timm Bäder
982890515d gl renderer: Don't use g_assert() for code that should always run
g_assert can be compiled out.
2019-11-27 16:56:47 +01:00
Timm Bäder
1817025f46 gl renderer: Don't save repeat nodes to disk
This is just debuggin code someone forgot.
2019-11-27 16:47:14 +01:00
Matthias Clasen
c5d24fc5cd Merge branch 'single-compilation-symbol' into 'master'
Use a single compilation symbol

See merge request GNOME/gtk!1216
2019-11-27 15:14:54 +00:00
Timm Bäder
965e37bee9 Merge branch 'fix-issue-1646-master' into 'master'
HighContrast: Add missing color to entry

Closes #1646

See merge request GNOME/gtk!1215
2019-11-27 13:52:08 +00:00
Emmanuele Bassi
def700739d Use a single compilation symbol
We use a compilation symbol in our build to allow the inclusion of
specific headers while building GTK, to avoid the need to include only
the global header.

Each namespace has its own compilation symbol because we used to have
different libraries, and strict symbol visibility between libraries;
now that we have a single library, and we can use private symbols across
namespaces while building GTK, we should have a single compilation
symbol, and simplify the build rules.
2019-11-27 13:33:43 +00:00
nana-4
5590bcb9cc HighContrast: Add missing color to entry
So entries don't inherit color from the parent element anymore.

Fixes https://gitlab.gnome.org/GNOME/gtk/issues/1646
2019-11-27 22:22:11 +09:00
Timm Bäder
9f69c7f3e8 Merge branch 'broken-annotation' into 'master'
builder: Fix broken annotation

See merge request GNOME/gtk!1213
2019-11-27 06:46:15 +00:00
Robert Ancell
0df45f0de0 builder: Fix broken annotation
Missing a ':', was introduced in 0627bba5a0.
2019-11-27 16:06:36 +13:00
Chun-wei Fan
9c5ea8eba4 gdkvulkancontext-win32.c: Suppress layered Windows on Vulkan
The Vulkan renderer does not work well with layered windows enabled, so
turn it off when we successfully created the Vulkan context on Windows.
2019-11-26 17:00:11 +08:00
Timm Bäder
8f6de1f955 gl renderer: Load flipped-y offscreen vertex data directly
Instead of loading the unflipped version first and then flipping it.
Don't do it in add_render_ops either but only in the function actually
adding the render ops for the nodes, since those frequently have
early-out conditions that don't need the vertex data at all.
2019-11-26 09:09:25 +01:00
Timm Bäder
4f532224e0 testsuite: Add another repeat node test case 2019-11-26 09:09:25 +01:00
Timm Bäder
1c2661ed12 gl renderer: Fix repeat node shader once again 2019-11-26 09:09:25 +01:00
Timm Bäder
91f7ac2d58 gl renderer: Care more about 0×0 offscreen nodes
These never result in a rendering of course, but we must make sure not
to create a 0×0 texture for them, since that will cause problems later
on.
2019-11-26 09:09:25 +01:00
Timm Bäder
3d1a9c7484 Merge branch 'unsafe-strdup-printf' into 'master'
gtk-demo: Fix incorrect use of g_strdup_printf

See merge request GNOME/gtk!1211
2019-11-26 07:11:19 +00:00
Robert Ancell
25e4174a38 gtk-demo: Fix incorrect use of g_strdup_printf
Was broken in a refactoring in 4a2f313
2019-11-26 10:11:28 +13:00
Emmanuele Bassi
04bb5aad36 Use a separate gesture for middle clicks on PlaceView rows
The click gesture in GtkListBox is exclusively for primary button
clicks; this means we're never going to get a click from the middle
button. We need to use a separate GtkGestureClick controller for middle
clicks, in order to activate rows with the 'open-in-tab' flag.

Fixes: #179
2019-11-25 16:02:40 +00:00
nana-4
4f82a0de89 Adwaita: Avoid directly coloring labels wherever possible
Directly coloring labels can create a lot of unintended behaviors.
Unfortunately we can't avoid directly coloring `label:disabled` because
it can be used individually. This, however, tries to inherit color from
the parent element of labels wherever possible.

Fixes https://gitlab.gnome.org/GNOME/gtk/issues/1643
2019-11-26 00:39:33 +09:00
Benjamin Otte
9e4901e8ce testsuite: Fix expected test output
This reverts part of 91497348bf
2019-11-23 19:33:36 +01:00
Benjamin Otte
7523a3f2f2 cssprovider: Don't add empty rulesets
This change was lost during the parser changes, but the newly added test
exposes it.

And fix the expected error, the syntax has changed.
2019-11-23 19:02:36 +01:00
Alexandr Miloslavskiy
fd1630e049 Fix crash in parse_border()
The bug was introduced in commit:
	9b7640b8 by Benjamin Otte, 2012-03-26 17:24:02
	styleproperty: Make _gtk_style_property_parse_value() return a CssValue

In that commit, `values` changed from `GValue*` to `GtkCssValue**`,
but one `!G_IS_VALUE (&values[8])` was left untouched. As a result,
if `border` shorthand contains anything after color, it might crash,
depending on memory layout.

New test included.

Fixes: #751
2019-11-23 18:15:19 +01:00
Benjamin Otte
e3c3cbbbcb Merge branch 'wip/otte/builder' into 'master'
Reorganize various GtkBuilder things

See merge request GNOME/gtk!1204
2019-11-23 17:09:15 +00:00
Benjamin Otte
4fbb0d7ce4 builder: Make the struct private
We don't want anyone to subclass it - if we want to allow bindings to
extend GtkBuilder, we will be using delegate objects/functions for it.
2019-11-22 17:42:32 +01:00
Benjamin Otte
245fdc8b38 builder: Remove get_type_from_name() vfunc 2019-11-22 17:42:32 +01:00
Benjamin Otte
420169d5cd builder: Improve signal connecting
- Propagate the error back to the parser, so we get a proper GError
  instead of a g_warning().
- Connect closures by id, don't construct a name from the ids so that
  glib can take it apart again.
2019-11-22 17:42:31 +01:00
Benjamin Otte
b025ee428c builder: Connect signals automatically
gtk_builder_connect_signals() is no longer necessary, because all the
setup that made it necessary to have this extra step is now done
automatically via the closure functions.
2019-11-22 17:42:31 +01:00
Benjamin Otte
82395a93b0 reftests: Switch to gtk_builder_set_closure_func() 2019-11-22 17:42:31 +01:00
Benjamin Otte
b7ff017f8d widget: Change templates to use closure functions
... instead of connect functions.
2019-11-22 17:42:31 +01:00
Benjamin Otte
0627bba5a0 builder: Add gtk_builder_set_closure_func()
This allows bindings and templates to setup a way to create closures.
2019-11-22 08:13:16 +01:00
Benjamin Otte
ab53731f4a widget: Reinstate custom closure func
It turns out it ws used in various places.
2019-11-22 07:46:18 +01:00
Benjamin Otte
094c537001 builder: Add gtk_builder_create_closure()
This will be the future way to connect signals automatically (and be
used for other things, too).

For now, gtk_builder_connect_signals_default() is ported to use it.
2019-11-22 07:46:18 +01:00
Benjamin Otte
27d05102ab builder: Remove user_data argument from gtk_builder_connect_signals()
This is pretty unused and gets in the way of the next steps.

A potential side effect is that for templates the widget was passed as
the user data argument. If that turns out to be important, we have to
special case that situation.
2019-11-22 07:46:18 +01:00
Benjamin Otte
f5e4dc824c builder: Remove application setter/getter
It's unused and doesn't belong to GtkBuilder.
2019-11-22 07:46:18 +01:00
Benjamin Otte
80acc8f296 builder: Carry the module as part of the GtkBuilder object
This way, we don't open the module in every place we want to look up
functions.
2019-11-22 07:46:18 +01:00
Benjamin Otte
e3860d25e9 builder: Fix typo in docs 2019-11-22 07:35:03 +01:00
Benjamin Otte
a2634077e7 testsuite: Print useful statement on notify test error
... and don't instantly abort, test the rest of the properties, too.
2019-11-22 07:35:03 +01:00
Benjamin Otte
c72c0f4d43 types: Remove and unused typedef
GtkRcPropertyParser is gone.
2019-11-22 07:35:03 +01:00
Benjamin Otte
d92cfa2179 settings: Remove RC property parsers
They've not been used for a long time and the APIs where they could
reasonably be used have been gone for as long.
2019-11-22 07:35:03 +01:00
Benjamin Otte
bbdaa4a0ff settings: Remove code dealing with property parsers
They only remained in private code where they were always set to NULL.
2019-11-22 07:35:03 +01:00
Sam Hewitt
5e11a2ae6a adwaita: level bar refinements
- shave a few pixels off large level bar
 - thinner discrete level bar
2019-11-19 11:46:18 -05:00
Timm Bäder
053360df85 gl renderer: Remove unused function 2019-11-19 11:06:08 +01:00
Timm Bäder
39a48de025 testsuite: Add a testcase for repeat nodes that don't repeat 2019-11-19 10:45:35 +01:00
Timm Bäder
600ce68210 gl renderer: Add a short cut for repeat nodes that don't repeat
These happen and we don't even need to draw the child to a texture.
2019-11-19 10:45:02 +01:00
Timm Bäder
604f44da11 gl renderer: Fix repeat nodes that don't repeat
Fixes #2234
2019-11-19 10:31:21 +01:00
Timm Bäder
581f5bd749 csstokenizer: Plug a leak 2019-11-19 09:37:45 +01:00
Timm Bäder
ecc40cf115 rendernodeparser: Only report a GError* if we have one 2019-11-19 09:37:26 +01:00
Timm Bäder
3d7817154c rendernodeparser: Handle resolving NULL urls 2019-11-19 09:37:03 +01:00
Emmanuele Bassi
232e313823 docs: Add migration note for iconify → minimize
See commit b70e4f6de9.
2019-11-18 14:12:41 +00:00
Daniel Mustieles
914e2a6656 Updated Spanish translation 2019-11-18 15:08:59 +01:00
Emmanuele Bassi
9a88d17ef2 Merge branch 'gdk-backend-imports' into 'master'
Correct Gdk backend import paths and related gtk-doc

See merge request GNOME/gtk!1197
2019-11-18 10:27:32 +00:00
Andy Holmes
907a86fd93 Correct Gdk backend import paths and related gtk-doc
Correct the paths in the include guard warnings and use the `@Include`
directive for the Gdk backends.
2019-11-18 00:31:38 -08:00
Matthias Clasen
d4180931f8 Merge branch 'seal-popover-menu' into 'master'
Privatize popover menu pieces

See merge request GNOME/gtk!925
2019-11-18 01:57:55 +00:00
Matthias Clasen
dd913423d3 Merge branch 'signal-naming' into 'master'
gtkstyleprovider: Rename -gtk-style-changed signal to have a valid name

See merge request GNOME/gtk!1176
2019-11-18 01:55:34 +00:00
Matthias Clasen
c296101a2f Merge branch 'issue-67' into 'master'
Rename "iconify" to "minimize"

Closes #67

See merge request GNOME/gtk!1190
2019-11-18 00:52:53 +00:00
Emmanuele Bassi
a439be5161 Remove the XIM input method
It's old and busted, and mostly broken in weird ways when it comes to
extended input devices. All that XIM does, these days, is make a mess
when people enable it by mistake.
2019-11-16 21:05:25 +00:00
Emmanuele Bassi
1ba2923616 Merge branch 'meson-bump' into 'master'
Bump up the required version of Meson

See merge request GNOME/gtk!1191
2019-11-16 20:26:31 +00:00
Emmanuele Bassi
1ec4cb7f17 Disable GdkSurface.minimize on Wayland
The existing xdg-shell protocols do not support minimization in a way
that allows us to implement the GdkSurface API; the only minimization
operation does not come with a state notification, nor it comes with
a way to undo itself.

Closes: #67
2019-11-16 20:25:01 +00:00
Emmanuele Bassi
b70e4f6de9 Rename "iconify" to "minimize"
The "iconified" state is mostly an X11-ism; every other platform calls
this state "minimized" because it may not involve turning a window into
an icon at all.
2019-11-16 20:07:37 +00:00
Emmanuele Bassi
3c11c57755 Bump up the required version of Meson
Match the one we're testing on our CI infrastructure.
2019-11-16 18:40:23 +00:00
Emmanuele Bassi
1b7c6e5687 Merge branch 'gdkx-import-doc' into 'master'
Correct GdkX11 import path in docs and include guards

Closes #2254

See merge request GNOME/gtk!1188
2019-11-16 18:19:26 +00:00
Andy Holmes
d32cd210bb Correct GdkX11 import path in docs and include guards
Update the include directives in the documentation, as well as the
include guards in headers, to point to gdk/x11/gdkx.h.

closes #2254
2019-11-16 01:35:09 -08:00
Emmanuele Bassi
e056e4ff58 Merge branch 'fix-menu-check-radio-styling-gtk4' into 'master'
Adwaita: Fix check/radio styling in menu (GTK4)

See merge request GNOME/gtk!1187
2019-11-15 23:26:17 +00:00
Emmanuele Bassi
ae66c07a70 Merge branch 'dont-hardcode-shared-library' into 'master'
build: Don't hardcode shared_library() in meson

See merge request GNOME/gtk!1172
2019-11-15 23:24:42 +00:00
Niklas Hambüchen
3936412332 Try building static libs on CI 2019-11-15 18:42:36 +01:00
nana-4
ea5eeb7c7a Adwaita: Fix check/radio styling in menu
The new check/radio style increased their specificity, but it was not
synchronized in the menu styling.

This commit increases the specificity to match the updated check/radio
styling.

https://gitlab.gnome.org/GNOME/gtk/issues/2096
2019-11-16 01:08:44 +09:00
Emmanuele Bassi
767df50eda Merge branch 'building-docs' into 'master'
Document the use of build types when configuing GTK

See merge request GNOME/gtk!1113
2019-11-15 13:05:39 +00:00
Emmanuele Bassi
baae2920dc Merge branch 'Master_checkradio_refresh' into 'master'
Refresh check/radio styling, ported from gtk3

See merge request GNOME/gtk!1175
2019-11-15 12:36:12 +00:00
frederik.feichtmeier
832419b2c3 Refresh check/radio styling, ported from gtk3 2019-11-15 13:16:07 +01:00
Emmanuele Bassi
ff78adb25d Merge branch 'fix-emoji-picker-styling' into 'master'
Adwaita: Fix emoji picker styling (GTK4)

See merge request GNOME/gtk!1181
2019-11-14 16:30:49 +00:00
nana-4
e05f404fc5 Adwaita: Fix emoji picker styling
- Adjust the emoji picker appearance to be the same as gtk3's.
- Fix button.emoji-section margins in RTL.
- Prevent the .emoji hover effect from being applied to the entire
  nested popover.
2019-11-15 00:04:18 +09:00
Kjell Ahlstedt
d572b5d94c headerbar: Disconnect signal handlers when children are removed
The signal handler that calls notify_child_cb() is disconnected
from a child widget before the child is removed from the header bar.
gtk_header_bar_dispose() chains up before destroying the start and end
boxes, thus avoiding calls to notify_child_cb() after start_box and
end_box have been cleared.

Fixes #2246
2019-11-14 09:15:58 +01:00
Timm Bäder
c2306d3ba6 inspector: Select an object when activating it 2019-11-14 09:15:58 +01:00
Timm Bäder
edf56b438e css: short-circuit gtk_css_dimension_value_try_add
No need to allocate a new css value for something that we already have,
because one of the two values is 0
2019-11-14 09:15:58 +01:00
Timm Bäder
cd3cd64769 cssdimenstionvalue: Add common degree value singletons 2019-11-14 09:15:58 +01:00
Timm Bäder
fb0b0ddfe0 cssdimensionvalue: Add 50% singleton
Also pretty common
2019-11-14 09:15:58 +01:00
Timm Bäder
3180cdb9ef cssdimensionvalue: Add more common pixel values
These are used for icon sizes, etc.
2019-11-14 09:15:58 +01:00
Timm Bäder
07d1ea4356 cssimagerecolor: Avoid copying colors 2019-11-14 09:15:58 +01:00
Timm Bäder
e5f1ff6a4d popover: Use a bin layout for the contents gizmo 2019-11-14 09:15:58 +01:00
Timm Bäder
f8303c7a22 testpopover: Plug two GtkBuilder leaks 2019-11-14 09:15:58 +01:00
Timm Bäder
af6d1839e1 Merge branch 'wip/christopherdavis/issue-2233' into 'master'
Adwaita: remove unwanted spacing for boxes as titlebars

Closes #2233

See merge request GNOME/gtk!1177
2019-11-13 14:29:01 +00:00
Christopher Davis
b4b7fe122e Adwaita: remove unwanted spacing for boxes as titlebars
A GtkBox in a titlebar could have unwanted spacing.
This caused a glitch in split-header applications where
parts of the titlebar would be transparent or black.

This commit tweaks Adwaita to make sure no spacing is added for boxes when used as titlebars.

Fixes #2233
2019-11-13 06:19:05 -08:00
Timm Bäder
e36940fa8c Merge branch 'master.msvc.fix' into 'master'
gtk/gtkcssrgbavalue.c: Fix build on Visual Studio

See merge request GNOME/gtk!1178
2019-11-13 10:40:02 +00:00
Chun-wei Fan
d2e13dd3e4 gtk/gtkcssrgbavalue.c: Fix build on Visual Studio
Visual Studio does not allow static or global structures to use
static storage duration by compound literals, which is actually a
GCCism[1].

[1]: See https://gcc.gnu.org/onlinedocs/gcc/Compound-Literals.html
2019-11-13 18:08:15 +08:00
Philip Withnall
13f4d639fd gtkstyleprovider: Rename -gtk-style-changed signal to have a valid name
Signal names must start with a letter. They can’t start with a hyphen.

It was originally added in commit 74f4c6f6bd with no given reason
for why the signal name was chosen as it was.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-11-12 19:51:33 +00:00
Emmanuele Bassi
ad48bbb849 Merge branch 'issue-2230' into 'master'
Add GtkCss API to the introspection data

Closes #2230

See merge request GNOME/gtk!1173
2019-11-11 16:11:06 +00:00
Emmanuele Bassi
2497d982b0 Add GtkCss API to the introspection data
Some of the CSS API has been moved to a public namespace, so we need to
include it into the introspection data we build in order for people to
use it.

Fixes: #2230
2019-11-11 15:53:09 +00:00
Niklas Hambüchen
bb9c07d8fe build: Don't hardcode shared_library() in meson.
Instead, use the standard library().
This is a meson best practice.

Fixes -Ddefault_library=static not having any effect.
2019-11-11 16:37:46 +01:00
Emmanuele Bassi
ace2208f45 docs: Rename SGML files
We've been using XML for ages.
2019-11-11 13:52:08 +00:00
Emmanuele Bassi
b8c4009686 docs: Fix the XML indentation 2019-11-11 13:52:08 +00:00
Emmanuele Bassi
6f0ff3a8cb docs: We run meson, not configure 2019-11-11 13:52:08 +00:00
Emmanuele Bassi
209e8b54e9 docs: Add a section on supported build types
GTK uses the Meson `buildtype` option to determine whether to enable or
disable debugging code and safeties. We should document our behaviour
and expectations.
2019-11-11 13:52:08 +00:00
Matthias Clasen
bfa0509f08 Privatize popover menu pieces
Don't allow manual creation of popover menus
anymore. This lets us also make GtkModelButton
private
2019-11-11 12:42:06 +01:00
Piotr Drąg
07d17c5bc1 Update Polish translation 2019-11-10 12:45:22 +01:00
Daniel Mustieles
e26c361d2d Updated Spanish translation 2019-11-08 12:44:39 +01:00
Timm Bäder
290e250886 Merge branch 'adwaita-emoji-picker-adjustments-gtk4' into 'master'
Adwaita: Emoji picker adjustments

See merge request GNOME/gtk!1160
2019-11-07 11:56:17 +00:00
Alex Monday
22d5b9bc41 Adwaita: Emoji picker adjustments
- Add margins for search entry;
- Increase side margins for emoji-section buttons box;
- Apply border-radius on hovered emoji;
- Adjust indication of hovered emoji-section button.
2019-11-06 18:41:11 +05:00
Benjamin Otte
ab407ba57c Merge branch 'kill-entry-buffer-demo' into 'master'
gtk-demo: Drop the entry buffer demo

See merge request GNOME/gtk!1166
2019-11-05 19:08:22 +00:00
Benjamin Otte
07f2024bfc scrolledwindow: Use dispose(), not destroy() 2019-11-05 20:06:44 +01:00
Benjamin Otte
accbfc0083 Merge branch 'wip/chergert/textundo' into 'master'
Add undo/redo support for GtkTextView, GtkText, and GtkEntry

See merge request GNOME/gtk!1158
2019-11-05 18:52:25 +00:00
Matthias Clasen
e8d890ae0c gtk-demo: Drop the entry buffer demo
We all agree that entry buffers are not something
we should promote in demos.
2019-11-05 18:50:06 +00:00
Christian Hergert
bfc1e77b7f migration: add GtkEntryBuffer::deleted-text to migration guide 2019-11-05 10:27:29 -08:00
Christian Hergert
dba9298c14 gtk-demo: set irreversable actions for textview demos 2019-11-05 10:27:29 -08:00
Christian Hergert
67c0f88c00 gtk-demo: add a demo for TextView undo/redo 2019-11-05 10:27:29 -08:00
Christian Hergert
e93408e962 gtk-demo: add an undo demo for GtkEntry 2019-11-05 10:27:29 -08:00
Christian Hergert
6d193d7cb4 gtk-demo: wrap text operations in irreversible actions
This ensures that the actions to set the text for the demo tabs cannot
be undone. This matches the previous behavior for GtkTextBuffer.
2019-11-05 10:27:29 -08:00
Christian Hergert
fb4fbfb2a8 text: add undo support to GtkText
This adds support using the GtkTextHistory helper for undo/redo to the
GtkText widget. It is similar in use to GtkTextView, but with a simplified
interface.

You can disable undo support using the GtkText:enable-undo property. By
default, it is enabled.
2019-11-05 10:27:29 -08:00
Christian Hergert
7e77afe94c entrybuffer: remove text in ::deleted-text default handler
This changes the semantics of ::deleted-text to perform the removal of
text in the default handler. This means, that if you want the old behavior
where your signal handler is called after the text has been deleted, you
should connect with G_CONNECT_AFTER in your signal handler (or use
g_signal_connect_after).

Without this change, there was never a way to get the deleted-text before
the operation had completed and this is necessary to provide undo support
to the text widgets.
2019-11-05 10:27:29 -08:00
Christian Hergert
7587996279 editable: add enable-undo property
This property is intended to be mapped to a GtkText so that undo/redo
support can be used from a number of editable widgets.
2019-11-05 10:27:27 -08:00
Christian Hergert
15b3c0f563 textview: add undo/redo support to GtkTextView
This builds upon the GtkTextHistory helper to provide undo and redo support
for the GtkTextView widget and GtkTextBuffer object.

You can undo/redo using familiar shortcuts such as Primary+Z,
Primary+Shift+Z, ad Primary+Y.

Developers that wish to disable undo, should set the
GtkTextBuffer:enable-undo property to FALSE.

You can wrap irreversible actions
gtk_text_buffer_begin_irreversible_action() and
gtk_text_buffer_end_irreversible_action(). This will cause the undo stack
to drop all undo/redo actions and the changes made between them will be
the "initial state" of the buffer.

Calling gtk_text_buffer_set_text() will do this automatically for you.
2019-11-05 09:34:29 -08:00
Christian Hergert
5e341210a1 texthistory: add GtkTextHistory helper
The GtkTextHistory helper provides the fundamental undo/redo stack that
can be integrated with other text widgets. It allows coalescing related
actions to reduce both the number of undo actions to the user as well as
the memory overhead.

A new istring helper is used by GtkTextHistory to allow for "inline
strings" that gracefully grow to using allocations with g_realloc(). This
ensure that most undo operations require no additional allocations other
than the struct for the action itself.

A queue of undoable and redoable actions are maintained and the link for
the queue is embedded in the undo action union. This allows again, for
reducing the number of allocations involved for undo operations.
2019-11-05 09:34:29 -08:00
Daniel Mustieles
fbea677a5c Updated Spanish translation 2019-11-05 15:44:34 +01:00
Emmanuele Bassi
b271db4f5b ci: Allow msys2 jobs to fail
The msys2 runner has started failing for internal reasons:

 - gtk-3-24 times out
 - master fails with a ld.exe assertion:
   BFD (GNU Binutils) 2.33.1 assertion fail
   ../../binutils-2.33.1/bfd/cofflink.c:2348

Both seem related to some MSYS2 issue. Until the runner is updated, we
should not block on it.
2019-11-05 10:44:05 +00:00
Emmanuele Bassi
b5ed2d310e tests: Add label-sizing.ui to the XFAIL list
Changes in Pango may make this test fail.
2019-11-04 23:46:22 +00:00
Emmanuele Bassi
3bf9277de6 Revert "Adwaita: radios & checkboxes styling updates"
This reverts commit 427b5d187c.

The commit breaks Adwaita:

Theme parsing error: gtk-contained.css:1191:28-44: No property named "-gtk-icon-effect"
2019-11-04 23:35:49 +00:00
Matthias Clasen
53c9eb5a5b Move the ifdef to the right spot 2019-11-04 23:24:49 +00:00
Matthias Clasen
6e5da14294 cell text: Handle new pango enum values
The PangoUnderline enum grew some new values.
2019-11-04 23:14:44 +00:00
Jakub Steiner
427b5d187c Adwaita: radios & checkboxes styling updates
- port from gtk3
2019-11-04 19:41:58 +01:00
Benjamin Otte
5d07877b35 Merge branch 'wip/sadiq/fix-leak' into 'master'
selection-output-stream-x11: Fix a memory leak

See merge request GNOME/gtk!1149
2019-11-04 17:46:28 +00:00
Benjamin Otte
3086715d54 Merge branch 'gtkstack-addnamed-return' into 'master'
stack: return the stack page when adding a child, to ease setting props

See merge request GNOME/gtk!1161
2019-11-04 02:35:22 +00:00
Andy Holmes
44093f4966 stack: return the stack page when adding a child, to ease setting props 2019-11-03 18:05:03 -08:00
Christian Hergert
6d16f7ad35 textview: use g_slice_new0 for proper initial state
This fixes the missuse of the GList embedded node for prev/next.
2019-11-01 11:37:07 -07:00
Matthias Clasen
5f627a2cb6 Merge branch 'reftest-fixes' into 'master'
Reftest fixes

See merge request GNOME/gtk!1157
2019-11-01 17:45:38 +00:00
Matthias Clasen
34d002121d reftests: Print out a helpful error
When module loading fails, print out the error.
2019-11-01 13:37:52 -04:00
Matthias Clasen
22bb1bd568 reftests: Drop libtool hack
We are not using libtool anymore.
2019-11-01 13:37:43 -04:00
Matthias Clasen
28898445ff Merge branch 'bump-pango' into 'master'
Bump pango

See merge request GNOME/gtk!1154
2019-11-01 17:26:33 +00:00
Matthias Clasen
828b58247c label: Handle new pango attributes
overline and overline-color were introduced in Pango 1.45.
2019-11-01 13:01:54 -04:00
Matthias Clasen
de29c3e193 label: Handle insert_hyphens pango attribute
This was introduced in Pango 1.44.4.
2019-11-01 13:01:54 -04:00
Matthias Clasen
8ccf2a722a gsk: Stop using deprecated pango api
Shape engines are not used anymore.
2019-11-01 13:01:54 -04:00
Matthias Clasen
fa8ce17e1e build: We no longer need freetype 2019-11-01 13:01:54 -04:00
Matthias Clasen
4a2f3130d2 gtk-demo: Use harfbuzz for font features
We don't need freetype anymore here; harfbuzz
has what we need.
2019-11-01 13:01:54 -04:00
Matthias Clasen
eaa6301e53 Port the font chooser to just use harfbuzz 2019-11-01 13:01:54 -04:00
Matthias Clasen
41c52e955d Bump the pango dependency
This lets us avoid freetype uses, and simplifies
some other things as well.
2019-11-01 13:01:54 -04:00
Matthias Clasen
eca7fa075e Merge branch 'fix-print-dialog' into 'master'
Update the print dialog for headerbar changes

See merge request GNOME/gtk!1156
2019-11-01 17:00:34 +00:00
Matthias Clasen
19a4e76034 Update the print dialog for headerbar changes
This was breaking the templates test.
2019-11-01 12:51:42 -04:00
Matthias Clasen
6cacff9df1 Merge branch 'ci-update' into 'master'
Update the CI image

See merge request GNOME/gtk!1155
2019-11-01 16:30:17 +00:00
Emmanuele Bassi
2d309725c9 ci: Add internal links to the HTML report
Makes it easier to link to various sections, and to specific failures.
2019-11-01 15:44:12 +00:00
Emmanuele Bassi
a5c00685c5 ci: Add diffutils to the CI image
Some transitive dependency got dropped, and we lost diff.
2019-11-01 15:22:02 +00:00
Emmanuele Bassi
48cc26246f Check for diff's availability
The tests suite calls `diff` in various places, which means we need to
check if it's installed.
2019-11-01 15:20:47 +00:00
Benjamin Otte
4b41dd4eb1 Merge branch 'otte/for-master' into 'master'
Otte/for master

See merge request GNOME/gtk!1153
2019-11-01 14:13:28 +00:00
Benjamin Otte
41beae1956 vulkan: Add missing enum value
Also update comment to point to new header after Vulkan reorganized
their repositories.
2019-11-01 14:52:36 +01:00
Emmanuele Bassi
c48fe6d7ec ci: Update the image to Fedora 31
Fedora 31 ships with a newer version of Pango.
2019-11-01 12:52:19 +00:00
Matthias Clasen
a31a80277c Merge branch 'fallback-rendering' into 'master'
Fallback rendering

See merge request GNOME/gtk!1152
2019-10-31 02:55:34 +00:00
Matthias Clasen
745a701b3d inspector: Add a switch for fallback rendering 2019-10-30 22:31:47 -04:00
Matthias Clasen
d4c97ea2b4 gl: Use the fallback debug flag
This debug flag was unused; use it to enable
fallback highlighting at runtime.
2019-10-30 22:31:47 -04:00
Matthias Clasen
03738634ac inspector: Remove fallback from logs
There are no logs that this debug flag produces.
2019-10-30 22:31:47 -04:00
Matthias Clasen
9dd8652a66 Merge branch 'wl-key-repeat' into 'master'
wayland: Rely on server key repeat info

See merge request GNOME/gtk!1150
2019-10-30 02:39:49 +00:00
Matthias Clasen
cb81a06793 wayland: Drop the keyboard settings object
It is no longer used.
2019-10-29 22:20:57 -04:00
Matthias Clasen
4d9cc483c9 wayland: Rely on server key repeat info
Using gsettings for this information does not work
in sandboxed scenarios, where settings are per-app.
Since the Wayland protocol provides this information
nowadays, just drop the old code for reading
the gsettings.
2019-10-29 21:58:45 -04:00
Benjamin Otte
4cca27a7af builder: Allow parsing G_TYPE_BYTES from strings
Just create a bytes containing the literal string.
2019-10-29 04:56:19 +01:00
Benjamin Otte
553a9c292d togglebutton: Don't emit clicked during set_active()
set_active() is meant to set the state of the property, which happens
during setup.
The clicked signal is emitting events from user actions.

It is impossible to use Togglebuttons for MVC applications as long as it
does that.
2019-10-29 04:56:19 +01:00
Benjamin Otte
abd4754648 messagedialog: Remove useless GTK_TYPE_BUILDABLE interface
It was just chaining up.
2019-10-29 04:56:19 +01:00
Mohammed Sadiq
e79d585b00 gdkselectionoutputstream-x11: Fix a memory leak 2019-10-27 14:05:46 +05:30
Matthias Clasen
1f0310ddff gtk-demo: Add a scrolling image demo
This tests big textures.
2019-10-22 21:20:36 -04:00
Matthias Clasen
0284d40e24 window: Unrealize renderer before children
Unrealize the GSK renderer before destroying children.
This makes the renderer drop any texture caches that
it might have, so that we don't needlessly download
them when releasing the widget-side holder objects.

As a fortunate side effect, this fixes crashes on
exit with GtkGLArea-containing windows under Wayland.
2019-10-22 20:28:28 -04:00
Matthias Clasen
ffaf26fdf5 Merge branch 'readonly-all-the-things' into 'master'
Readonly all the things

See merge request GNOME/gtk!1145
2019-10-22 13:23:06 +00:00
Matthias Clasen
5b508ea94a Revert "gl: Speed up icon cache lookups"
This reverts commit dd5ee87b5b.
2019-10-22 07:16:41 -04:00
Matthias Clasen
472d8eebbe gl: Avoid pointless iteration 2019-10-22 07:16:41 -04:00
Matthias Clasen
dd316c8051 gl: Add some comments 2019-10-22 07:16:41 -04:00
Matthias Clasen
1038bc781a Revert "Cache glyph textures in render nodes"
This reverts commit c5af463843.
2019-10-22 07:16:41 -04:00
Timm Bäder
44137574a1 inspector: Fix expander arrow node names
They vanished after the GtkExpander node rename
2019-10-22 09:37:08 +02:00
Timm Bäder
6b07ce2b13 filechooserwidget: Remove unused function parameter 2019-10-22 09:37:08 +02:00
Timm Bäder
008e8076a1 filechooserwidget: Inline function into only caller 2019-10-22 09:37:08 +02:00
Timm Bäder
2cd4b255cd placesview: open address popover upwards 2019-10-22 09:37:08 +02:00
Timm Bäder
11a38dd455 entry: Remove unused function 2019-10-22 09:37:08 +02:00
Timm Bäder
dfcc40ef9a text: Propagate pango attributes to placeholder
Not sure if this is really always wanted or whether we need to filter
the attributes, or even create a separate property for them.
2019-10-22 09:37:08 +02:00
Timm Bäder
1882034323 text: Fix _set_attributes docs
The list is nullable.
2019-10-22 09:37:08 +02:00
Timm Bäder
aaaa3e141b placessidebar: Remove some unused members 2019-10-22 09:37:08 +02:00
Timm Bäder
15af87345d placesview: Use proper setters for properties 2019-10-22 09:37:08 +02:00
Timm Bäder
640db05b18 text: Remove some unused members 2019-10-22 09:37:08 +02:00
Timm Bäder
31ae93475d text: Fix context menu position
Fixes #2209
2019-10-22 09:37:08 +02:00
Timm Bäder
8fc4d229da text: Inline function into only caller 2019-10-22 09:37:08 +02:00
Timm Bäder
a62efb8257 text: Remove gtk_text_get_text_allocation
We can just replace that with get_width/get_height everywhere.
2019-10-22 09:37:08 +02:00
Timm Bäder
acf927fe14 text: Don't destroy pango layout in size_allocate
It's not needed.
2019-10-22 09:37:08 +02:00
Timm Bäder
ca71340c6b Adwaita: Fix menubutton in headerbar margins
Add the margins to the menubutton and not the button inside the
menubutton. This way popovers properly point to the inner button again
instead to somewhere 6px off.
2019-10-22 09:37:08 +02:00
Timm Bäder
350495cf1c Adwaita: Remove padding from popover.menu
The padding belongs to the contents subnode in this case.
2019-10-22 09:37:08 +02:00
Timm Bäder
426d5ca1b7 filechooserwidget: Add .menu to right-click popover
Make it look like the other menus.
2019-10-22 09:37:08 +02:00
Timm Bäder
aaae141687 filechooserwidget: Focus the searchbar when searching
This code path is taken if the search is already active, so focus the
search entry.
2019-10-22 09:37:08 +02:00
Timm Bäder
4826255ea3 filechooserwidget: Rename a callback 2019-10-22 09:37:08 +02:00
Timm Bäder
9ba08a09cb shortcutlabel: Inherit from GtkWidget 2019-10-22 09:37:08 +02:00
Timm Bäder
bb2c68452c shortcutlabel: Inherit from GtkWidget 2019-10-22 09:37:07 +02:00
Timm Bäder
23be10cf69 searchentry: Make the text entry expand
Fixes the broken layout.
2019-10-22 09:37:07 +02:00
Timm Bäder
17a111968b text: Remove an unnecessary queue_draw() call 2019-10-22 09:37:07 +02:00
Matthias Clasen
d3431f569c Revert "inspector: Fix node recording"
This reverts commit ba7649b388.
2019-10-22 01:32:51 -04:00
Matthias Clasen
7a73f43de3 Merge branch 'wip/matthiasc/icon-theme' into 'master'
Misc icon theme cleanups

See merge request GNOME/gtk!1139
2019-10-19 22:43:34 +00:00
Matthias Clasen
ba7649b388 inspector: Fix node recording
When attaching renderer-specific data, we need to
make sure that we key it off the renderer that is
in use, and cope with the absence of render data.

This fixes recording nodes in the inspector.
2019-10-18 09:33:45 -05:00
Matthias Clasen
1dd55ed600 Drop gtk_icon_info_new_for_pixbuf
It is better to keep icon infos as something you
only get from the icon theme.
2019-10-18 08:53:23 -05:00
Matthias Clasen
416b2cd18d Move symbolic pixbuf recoloring code
This function is better off next to the other
symbolic png code in gdkpixbufutils.c.
2019-10-18 08:53:23 -05:00
Matthias Clasen
15dffb47dc icon theme: Drop icon_file from GtkIconInfo
It is not used anymore.
2019-10-18 08:53:23 -05:00
Matthias Clasen
20e70a78c4 Drop another use of icon_file
Stop using icon_file when loading symbolic svgs.
2019-10-18 08:53:23 -05:00
Matthias Clasen
e190b4536a Drop another use of icon_file 2019-10-18 08:53:23 -05:00
Matthias Clasen
3c219bf968 Add another symbolic pixbuf helper 2019-10-18 08:53:23 -05:00
Matthias Clasen
c3de5e3624 Avoid a use of icon_file
This is a step towards getting rid of GtkIconInfo->icon_file.
2019-10-18 08:53:23 -05:00
Matthias Clasen
dd69bcabf7 icon theme: Start to untangle GtkIconInfo
GtkIconInfo contains too much redundant data,
and it is hard to know which fields are to be
used when.

This commit starts to move towards dropping the
icon_file field - we prefer to work with the
filename directly, since it lets us avoid mime
sniffing and strdups.
2019-10-18 08:53:23 -05:00
Matthias Clasen
6373ced608 Drop gtk_icon_theme_get_example_icon_name
This function is not useful. Every icon theme
on my system either does not have that field,
or has it as 'folder'. So, just use 'folder'
when you need an example icon.
2019-10-18 08:53:23 -05:00
Matthias Clasen
2ea95a7674 Drop gtk_icon_theme_list_contexts
Contexts in icon themes are not useful for anything.
2019-10-18 08:53:23 -05:00
Matthias Clasen
dbbb7eef15 testicontheme: Remove useless function
Contexts in icon themes are not useful for anything,
so drop this function from testicontheme.
2019-10-18 08:53:23 -05:00
Matthias Clasen
233d096261 icon theme: Avoid a string copy
This is in an error path, so mostly cosmetic.
2019-10-18 08:53:23 -05:00
Piotr Drąg
239c178ef4 Update POTFILES.in 2019-10-17 20:11:58 +02:00
Matthias Clasen
fdbb925654 gl: Remove an unimplemented profiler counter 2019-10-17 07:59:34 -05:00
Matthias Clasen
aeabe3c40e gl: Add debug spew to texture atlas 2019-10-17 07:59:34 -05:00
Matthias Clasen
222b6c2b58 glyph cache: Go back to memcmp
Be careful to avoid padding data, and only
compare the relevant parts, leaving out the
hash key.
2019-10-17 07:59:34 -05:00
Matthias Clasen
5ab5ff7677 Cosmetics 2019-10-17 07:59:34 -05:00
Matthias Clasen
8a603ff5bd Revert "icon theme: Avoid a string copy"
This reverts commit 0895f0211e.

This negatively affected icons that are included as
resources, since peek_path returns NULL for them.
2019-10-17 07:16:30 -05:00
Goran Vidović
468295a9f7 Update Croatian translation 2019-10-17 12:03:32 +00:00
Matthias Clasen
6c92b824f3 Merge branch 'wip/chergert/opbuffer' into 'master'
Add OpBuffer helper for building op buffer

See merge request GNOME/gtk!1131
2019-10-17 11:37:07 +00:00
Goran Vidović
77e9788517 Update Croatian translation 2019-10-17 11:36:10 +00:00
Goran Vidović
0b1845b0cb Update Croatian translation 2019-10-17 11:23:00 +00:00
Benjamin Otte
342d88a1dc Merge branch 'otte/for-master' into 'master'
Otte/for master

See merge request GNOME/gtk!1136
2019-10-16 20:25:57 +00:00
Benjamin Otte
bab7f56f64 entry: Return boolean from gtk_entry_grab_focus_without_selecting()
This follows recent changes to gtk_widget_grab_focus().
2019-10-16 22:08:53 +02:00
Benjamin Otte
9b87cace47 render: Fix goto
if we have pushed a shadow, we better pop it again.

Broken since d1ea591f18
2019-10-16 21:45:33 +02:00
Benjamin Otte
c2a32afe97 Initialize cursor alpha to 1.0
That way, non-animated cursors don't disappear.
2019-10-16 21:45:33 +02:00
Benjamin Otte
d0e14f79a6 bindings: Make gtk_bindings_add_callback() allow for variant args 2019-10-16 21:45:33 +02:00
Benjamin Otte
7f2ab0d576 bindings: Refactor
Refactor code so that each bindings type has its own struct instead of
sharing one big union.
2019-10-16 21:45:33 +02:00
Timm Bäder
d36d7d93e6 Merge branch 'fix-popover-styles' into 'master'
Fix popover styles (GTK 4)

Closes #2061

See merge request GNOME/gtk!1079
2019-10-16 07:42:45 +00:00
Matthias Clasen
d777300d4e Fix a crash with glyph caching
We need to treat atlas-less cached glyphs like
atlases, when it comes to invalidating text node
render data.
2019-10-15 22:52:28 -04:00
Matthias Clasen
173bb2e1e8 gsk: Fix uninitialized memory
This was causing crashes in some circumstances.
2019-10-15 20:54:24 -04:00
Matthias Clasen
0895f0211e icon theme: Avoid a string copy
GIO has gained a way to peek at a GFile
path; lets use that.
2019-10-15 19:44:26 -04:00
Matthias Clasen
be13a23722 icon theme: Avoid mime sniffing
Themed icons are always pngs or svgs.
Take advantage of that to avoid costly
mime sniffing.
2019-10-15 19:44:26 -04:00
Matthias Clasen
7197743938 pixbuf utils: Preserve format information
When we are loading themed icons, we know if
we deal with an svg or png file, so it is
entirely unnecessarily to have gdk-pixbuf
use g_content_type guess to rediscover that
information.

Change the pixbuf utils apis we have to allow
passing format information down to where we
can use it when creating the pixbuf loader.
2019-10-15 19:44:26 -04:00
Matthias Clasen
dd5ee87b5b gl: Speed up icon cache lookups
Use gdk_texture_set_render_data to avoid
hash table lookups when we can.
2019-10-15 19:44:26 -04:00
Matthias Clasen
e34d1b8a26 gl: Slightly rework the icon cache api
Return a pointer to the IconData struct. This is
closer to the glyph cache api, and will allow us
to add similar shortcuts. For now, just store
texture coords in the form we need, avoiding
converting them over and over.
2019-10-15 19:44:26 -04:00
Matthias Clasen
c5af463843 Cache glyph textures in render nodes
This is a quick implementation that avoids many
glyph cache lookups. We keep an array of direct
pointers in the text render node, and throw those
cached pointers away whenever any atlases have
been dropped (since that may invalidate the cached
glyphs).
2019-10-15 19:44:26 -04:00
Matthias Clasen
49748c9c23 Some more vertex data reshuffling
In some cases, the vertex data is just a trivial
modification of the default data, so do that instead
of recalculating it.
2019-10-15 19:44:26 -04:00
Matthias Clasen
b53fa48794 Fix load_vertex_data
There was a copy-paste error that set all
uv coordinates to 0,0.
2019-10-15 19:44:26 -04:00
Christian Hergert
97f3371709 gl: avoid calculating vertex_data until necessary
In many cases of the switch, we do not need the vertex data. This moves
the creation of the vertex_data array into a secondary function and only
calculates it the cases for which it is required.
2019-10-15 19:44:26 -04:00
Matthias Clasen
58d57e1087 gl: Drop buffer_size
No need to maintain buffer_size separately.
It is always vertices->len * sizeof (GskQuadVertex).
2019-10-15 19:44:26 -04:00
Matthias Clasen
571068af12 Drop OP_CHANGE_VAO
Instead, we accumulate vertices in a separate
array, which simplifies various things and lets
us avoid the extra copying step for the vao.
2019-10-15 19:44:26 -04:00
Christian Hergert
a00d12c62a prototype OpBuffer helper for building op buffer 2019-10-15 19:44:26 -04:00
Benjamin Otte
7fc74eaeae Merge branch 'otte/for-master' into 'master'
Otte/for master

See merge request GNOME/gtk!1133
2019-10-15 18:47:57 +00:00
Benjamin Otte
4eb077979f widget: Don't grab focus when can-focus == false
... inside the default vfunc.

Instead, walk the children until we find the first widget that can be
focused. If no child can be focused, return FALSE from grab_focus.
2019-10-15 16:33:05 +02:00
Benjamin Otte
9c1b1eb894 widget: Insist that widgets are rooted to be focusable
This check was in the vfunc before, but it's a general rule, so apply it
before.
2019-10-15 16:33:05 +02:00
Benjamin Otte
14c34a7014 widget: Make grab_focus() fail on insensitive widgets
We can return FALSE early now instead of silently failing in
gtk_window_set_focus().
2019-10-15 16:33:05 +02:00
Benjamin Otte
427deb4f13 widget: Make gtk_widget_grab_focus() return a boolean
So now it can actually fail.

It doesn't yet though.
2019-10-15 16:33:05 +02:00
Benjamin Otte
a1a70a1130 bindings: Add gtk_binding_entry_add_callback()
This allows bindings that have no public API.
2019-10-15 07:17:30 +02:00
Benjamin Otte
19304c1d2c bindings: Add gtk_binding_entry_add_action()
Allows registering bindings for activating widget actions, as an
alternative to signal emissions.
2019-10-15 07:17:30 +02:00
Benjamin Otte
01be7f0666 widget: Make gtk_widget_activate_action() return TRUE/FALSE
TRUE if an action was successfully activated, FALSE if it wasn't found.
2019-10-15 07:17:30 +02:00
Benjamin Otte
1b68e76852 gtk: Add GtkNoSelection
Allows not to have anything selected.
2019-10-15 07:17:07 +02:00
Benjamin Otte
9f5ee77a44 singleselection: Fix model property
1. Make the model property construct-only. Allowing to change the
   model has invalid side effects.

2. Add a getter for the model property.
2019-10-15 07:17:07 +02:00
Benjamin Otte
6d20fe0bf9 expander: Rename CSS nodes
The expander icon is renamed from "arrow" to "expander".
The expander widget itself is renamed from "expander" to
"expander-widget" (Better ideas welcome).

This makes it possible to have an "expander" icon in more places then
the GtkExpander widget (in particular in tree lists) and not
confuse it with arrows.
2019-10-15 07:17:07 +02:00
Timm Bäder
bb56b4ef5d cssimagebuiltin: Don't create cairo nodes for empty icons
GTK_CSS_IMAGE_BUILTIN_NONE is not going to draw anything of course, so
don't bother creating an empty cairo node for it.
2019-10-15 07:13:28 +02:00
Timm Bäder
5ea21f7910 gl renderer: Fix an out of bounds read
Fixes #2200
2019-10-15 07:13:14 +02:00
Matthias Clasen
acb7f437fa notebook: Avoid a crash
This is fallout from turning the menu into
a popover, causing it to be be a child.
2019-10-12 19:00:35 -04:00
Matthias Clasen
7bff3abe8e glyph cache: Fix handling of big glyphs
We were putting big glyphs in the cache, in their
own texture, but forgetting to mark the texture
as permanent, so it could be reused, leading to
occasional misrendering. Fix this by marking these
textures as permanent, and explicitly freeing them
when the cache entry gets old.
2019-10-12 18:53:22 -04:00
Matthias Clasen
e46a7ca706 shadow cache: Remove outdated comments
No comments are better than outdated comments.
2019-10-12 17:06:39 -04:00
Matthias Clasen
e9ba7eda47 gl: Increate the cache check frequency
Otherwise, we spread the cache over more atlases
than necessary, increasing the amount of texture
changes in each frame.
2019-10-12 12:37:11 -04:00
Matthias Clasen
88649b6aae gl: Interleave cache aging
Every few frames, we do extra work for the
cache aging. Arrange for the glyph and icon
caches to not cause extra work on the same
frame, to smooth things out.
2019-10-12 12:37:11 -04:00
Matthias Clasen
60d63bbada gl: Improve debug spew for caches
Dump similar information for both caches,
and correct the unused percentage for
the atlases.
2019-10-12 12:37:11 -04:00
Timm Bäder
b8f62d1e10 Update stackswitcher CSS
Add the spacing to circular stack switchers back.
2019-10-12 18:26:54 +02:00
Timm Bäder
989307e4c2 stackswitcher: Inherit from GtkWidget 2019-10-12 18:12:58 +02:00
Timm Bäder
7344723a95 colorscale: Remove some duplicated code 2019-10-12 17:59:23 +02:00
Timm Bäder
4c4bca0c39 menuitem: Remove unused members 2019-10-12 17:59:23 +02:00
Timm Bäder
d570121704 menu: Align function parameters 2019-10-12 17:59:23 +02:00
Timm Bäder
93122ac935 menu: Remove unused members 2019-10-12 17:59:23 +02:00
Timm Bäder
f9e100cb1e menu: Remove menu_queue_resize
The have_layout flag is unused, so this is equal to a normal
gtk_widget_queue_resize().
2019-10-12 17:59:23 +02:00
Matthias Clasen
d3ad178d95 Merge branch 'glyphcache-fiddling' into 'master'
Glyphcache fiddling

See merge request GNOME/gtk!1132
2019-10-12 15:56:08 +00:00
Matthias Clasen
123cbd42bb gl: Make icon cache work like glyph cache
Replace timestamp tracking with an accessed bit
here too, to keep the glyph and icon cache code
similar.
2019-10-12 11:46:10 -04:00
Matthias Clasen
977ac2b31f gl: Do less work on glyph caching
There is no need for us to be very precise about
aging the glyph entries. It is enough to check
occasionally and mark old entries. This reduces
the overhead of work we do every frame on the
caches, at the cost of letting glyphs linger
a bit longer in the cache.
2019-10-12 11:35:46 -04:00
Timm Bäder
bcdc3b706c iconcache: Fix icon padding 2019-10-12 09:17:24 +02:00
Matthias Clasen
61db797f29 gl: Simplify glyph cache lookup
Make this function more similar to the icon
cache equivalent, and simplify it a bit. We
don't use the boolean return, and we don't need
to look at the age of entry when marking it
used.
2019-10-12 01:35:13 -04:00
Matthias Clasen
0a876f11a0 gl: Don't use memcmp for comparing cache keys
Some innocent change made us use a stack-allocated
key, and things broke. Lets go back to comparing
cache keys field by field.
2019-10-12 01:00:08 -04:00
Matthias Clasen
019e3c02ed Make the scrolling demo more versatile
Allow to swap out the content, so we can compare
text and icon scrolling.
2019-10-11 22:04:30 -04:00
Matthias Clasen
1c17316f9c gl: Handle row stride for icon cache upload
Same as the previous commit: Downloading a texture
may in theory give us data with a stride, so handle
that.
2019-10-11 21:17:30 -04:00
Matthias Clasen
646c5f369f gl: Handle row stride for glyph cache upload
In theory, we can have data with a stride here,
so set the necessary parameters to tell GL about
it.
2019-10-11 21:16:40 -04:00
Matthias Clasen
8839e10d44 gl: Do less work to maintain caches
Remember which atlases were removed, and only
check those when looking for icons or glyphs
to remove. For most frames, we don't have to
check at all since no atlases were removed.
2019-10-11 20:42:24 -04:00
Matthias Clasen
9b61bfb3c8 gl: Speed up icon caching
Avoid expensive padding, and just upload the
image in several slices.
2019-10-11 19:36:26 -04:00
Matthias Clasen
60e2242256 Add an icon scrolling demo
This is good to exercise the GL renderer icon cache.
2019-10-11 17:36:38 -04:00
Timm Bäder
4f5a9be465 gl renderer: Get blur node child only once 2019-10-11 22:31:33 +02:00
Timm Bäder
6a4c778791 gl renderer: Shorten function 2019-10-11 22:31:33 +02:00
Timm Bäder
1caa95b814 gl renderer: Avoid copying a rect 2019-10-11 22:31:33 +02:00
Matthias Clasen
cf44ba7847 gl: Avoid stray use of doubles
Everything else in this code is floats,
so stick to that and avoid unnecessary
precision.
2019-10-11 16:16:09 -04:00
Matthias Clasen
30433d7659 Cosmetics 2019-10-11 16:16:09 -04:00
Matthias Clasen
849b950763 gl: glyph cache tweaks
Reduce the cost of lookups by storing
the hash value directly.
2019-10-11 16:15:15 -04:00
Matthias Clasen
8937cd992d gl: Shrink CachedGlyph structs slightly
Plug a hole in this struct.
2019-10-11 16:15:14 -04:00
Matthias Clasen
e296c6a356 gsk: Store color bit info in text nodes
Keep the 'has color glyphs' info in text nodes,
instead of determining it over and over in both
the vulkan and gl backends.
2019-10-11 16:15:14 -04:00
Timm Bäder
136400e8a2 gl renderer: Remove unused modelview matrix 2019-10-11 16:56:24 +02:00
Timm Bäder
90199534e0 gl renderer: Don't copy outset shadow node outline 2019-10-11 16:38:58 +02:00
Timm Bäder
f7c64b4ebb gl renderer: Don't copy colors into render ops 2019-10-11 15:06:51 +02:00
Timm Bäder
f4f060c843 snapshot: Don't move shadows too much
dx/dy are relative to the node bounds, which are already moved by x/y.
2019-10-11 13:47:40 +02:00
Timm Bäder
2977e91aed gl renderer: Grow unblurred outset shadow outline on the gpu 2019-10-11 10:16:39 +02:00
Timm Bäder
0b999c73d1 gl renderer: Fix glsl rounded rect shrinking
Previous code would add rounded corners to a rect with all 0 corners
when growing.
2019-10-11 10:15:58 +02:00
Timm Bäder
9b1e0dd4a3 gl renderer: Cosmetics 2019-10-11 09:32:24 +02:00
Timm Bäder
a29826bb71 gl renderer: Only add outset shadow center piece if dx/dy != 0 2019-10-11 08:46:33 +02:00
Daniel Mustieles
a181136646 Updated Spanish translation 2019-10-10 14:00:22 +02:00
Matthias Clasen
5b04201da8 Merge branch 'wip/chergert/avoid-renderop-copy' into 'master'
gl: avoid copying RenderOp

See merge request GNOME/gtk!1128
2019-10-09 22:49:36 +00:00
Christian Hergert
528297f5e5 gl: avoid copying RenderOp to GArray
Instead of copying the (rather large) RenderOp to the GArray, we can
simply set the fields directly in the allocated space for the struct.
In most cases, there wont be any allocations to make as the array size
is kept in tact across frame renderings.
2019-10-09 15:41:53 -07:00
Christian Hergert
b29feb193e gl: use memcmp to compare glyph cache keys
We can just use memcmp here because even in the use of lookup keys with
C99 initializers, we can rely on any space between fields added by the
compiler to be zeroed. So we might as well use wider memory cmopares.
2019-10-09 14:47:23 -07:00
Matthias Clasen
75b5c2a293 Merge branch 'wip/chergert/const-glyph-cache' into 'master'
gl: avoid copying GskGLCachedGlyph in lookup

See merge request GNOME/gtk!1127
2019-10-09 21:45:41 +00:00
Christian Hergert
e32c992886 gl: avoid copying GskGLCachedGlyph in lookup
This saves a minor amount of CPU time by avoiding the copy of structure
on each lookup (which is short-lived).
2019-10-09 14:37:08 -07:00
Christian Hergert
c7a5d99286 textview: use gtk_snapshot_new_with_parent()
As recommended by Timm Bäder at:

3b959456ac (note_621655)
2019-10-09 12:56:06 -07:00
Christian Hergert
c9ca60c201 gl: short-circuit on NULL program
The NULL check is a more inclusive check than each of the individual
op->op checks.
2019-10-09 11:51:32 -07:00
Matthias Clasen
d9f6f26cd8 Merge branch 'wip/chergert/textview-fix-selection' into 'master'
textview: fix off-by-one in y_range invalidation

See merge request GNOME/gtk!1126
2019-10-09 17:50:40 +00:00
Christian Hergert
e4a00f864d textview: fix off-by-one in y_range invalidation
Previously, with selection bounds, we could have a state where a line
display with selections set would eroniously stay in the cache. This
aggresively releases those at the boundary cases fixing deselection
drawing state.
2019-10-09 10:43:34 -07:00
Timm Bäder
329f7c1c40 gl renderer: Remove rounded rect intersection code
Caused correctness issues.

Fixes #1917
2019-10-09 16:57:22 +02:00
Timm Bäder
c23afb2c86 widget: Compare adjusted sizes in size_allocate 2019-10-09 16:57:22 +02:00
Timm Bäder
e838ea3bc8 gl renderer: Fix scaled fallback node drawing 2019-10-09 16:57:22 +02:00
Timm Bäder
e5de03144f inspector: Don't add padding to spinbuttons
That looks stupid.
2019-10-09 16:57:22 +02:00
Timm Bäder
e325f65c8a spinbutton: Fix adjustment value thinko
Using ints here is wrong as it makes it impossible to e.g. edit a double
in the [0; 1] range.
2019-10-09 16:57:22 +02:00
Timm Bäder
2a40ff1b47 Adwaita: add statusbar padding back
We removed the widget margins from the ui file over 2 years ago.
2019-10-09 16:57:22 +02:00
Timm Bäder
371c325ed1 statusbar: Use a bin layout 2019-10-09 16:57:22 +02:00
Timm Bäder
542b95e7e8 widget-factory: Remove double border around textview
Replace the scrolledwindow border with two separator on top/bottom.
2019-10-09 16:57:22 +02:00
Timm Bäder
3d3525a589 stacksidebar: Inherit from GtkWidget
The child widgets are completely managed by the stacksidebar itself, so
this has no business being a GtkBin.
2019-10-09 16:57:22 +02:00
Timm Bäder
553c458e5a Adwaita: Remove superfluous border from stacksidebar
We already get a border from .sidebar
2019-10-09 16:57:22 +02:00
Timm Bäder
7cdb8d8565 gtk-demo: Fix up sidebar demo style
Remove a superfluous separator and add the icon-dropshadow class to the
gtk logo
2019-10-09 16:57:22 +02:00
Timm Bäder
172f68e77d popovermenu: Switch to main submenu before mapping 2019-10-09 16:57:22 +02:00
Timm Bäder
fb1145d72d popovermenu: Only close if there's a new focus widget
Makes sense and otherwise we end up closing the popover for no reason
2019-10-09 16:57:22 +02:00
Timm Bäder
bd9687a4f2 popovermenu: Switch back to "main" AFTER unmapping
Otherwise we might set things to child visible etc. while being
unmapped, which is a violation of the widget invariants of these
properties.
2019-10-09 16:57:22 +02:00
Timm Bäder
8928323c6b popover2.ui: Stop trying to set GtkModelButton:label
The property is called "text"
2019-10-09 16:57:22 +02:00
Timm Bäder
c7203550a2 testmodelbutton: Remove toggles for removed properties 2019-10-09 16:57:22 +02:00
Timm Bäder
49887d4c81 filechooserbutton: Only destroy existing native dialogs 2019-10-09 16:57:22 +02:00
Timm Bäder
d8c940325c widget: Create finalize assertions in destroy() 2019-10-09 16:57:22 +02:00
Timm Bäder
3944d64d08 demo: Don't manually add labels to menubuttons 2019-10-09 16:57:22 +02:00
Timm Bäder
e20f547317 demo: Fix modelbutton demo 2019-10-09 16:57:22 +02:00
Timm Bäder
a3cef6c05e label: Use TRUE/FALSE instead of 1/0 2019-10-09 16:57:22 +02:00
Timm Bäder
11ee72fc7e dialog: Fix action button rearrangement
The gtk_widget_get_parent() check does not work anymore since the
headerbar adds the buttons to a child box.
2019-10-09 16:57:22 +02:00
Timm Bäder
bcd8941769 widget-factory: Skip xml files in background selection dialog
The default contains a xml file for an animated background, so don't try
loading it as a pixbuf.
2019-10-09 16:57:22 +02:00
Timm Bäder
355d3f070a widget: Plug layout manager leak 2019-10-09 16:57:22 +02:00
Timm Bäder
b5b81dea7f modelbutton: Rework
Create all the widgets on demand and use a box layout to arrange them
instead of manual size allocation.

Also don't inherit from GtkButton
2019-10-09 16:57:21 +02:00
Timm Bäder
5803366f7d button: Remove unused signal enum members 2019-10-09 16:57:21 +02:00
Timm Bäder
d3fc47e149 modelbutton: Use a box layout 2019-10-09 16:57:21 +02:00
Timm Bäder
b8f37da911 modelbutton: Replace map() with root() 2019-10-09 16:57:21 +02:00
Timm Bäder
722f8e825e modelbutton: Remove end_box
it's unused.
2019-10-09 16:57:21 +02:00
Timm Bäder
a743412c58 modelbutton: Create accel label on demand 2019-10-09 16:57:21 +02:00
Timm Bäder
a6f14555d1 Adwaita: Blue check/radiobuttons
Align with 3.24.
2019-10-09 16:57:21 +02:00
Feichtmeier
1c091a03f3 Tiny refactoring
- use checkradio_fg_color for check/radio in treeview, which points to fg_color, so no change of the hex color, thus no change to the parsed CSS
2019-10-09 16:57:21 +02:00
frederik.feichtmeier
2dfb8de0ec Adwaita: Add color defines from 3.24 2019-10-09 16:57:21 +02:00
Jakub Steiner
876e256f94 Adwaita: make links in infobars legible
- No longer tinted blue, make legible

Fixes https://gitlab.gnome.org/GNOME/gnome-software/issues/751
2019-10-09 16:57:21 +02:00
Timm Bäder
eb834b8370 adwaita: Use border-spacing to style checkbuttons 2019-10-09 16:57:21 +02:00
Timm Bäder
dbabdf8341 radiobutton: Fix a warning in a code sample 2019-10-09 16:57:21 +02:00
Timm Bäder
703fda3be8 label: Remove set_selectable_hint
It's just updating the cursor, so do it via update_cursor()
2019-10-09 16:57:21 +02:00
Timm Bäder
2f6d6f2473 label: Remove gtk_label_realize
We don't need this to update the cursor anymore.
2019-10-09 16:57:21 +02:00
Timm Bäder
3f3c8436c5 label: Don't update cursor after unsetting select_info
update_cursor() doesn't do anything in the priv->select_info == NULL
case.
2019-10-09 16:57:21 +02:00
Timm Bäder
d8b0a78c1e label: Change cursor even if unrealized
Cursor don't depend on that anymore.
2019-10-09 16:57:20 +02:00
Timm Bäder
013538daf9 placesviewrow: popup-menu returns a boolean 2019-10-09 16:57:20 +02:00
Matthias Clasen
919d823311 Merge branch 'wip/carlosg/tablet-invalid-reads-master' into 'master'
Fix invalid reads on tablet input (master)

Closes #2157

See merge request GNOME/gtk!1122
2019-10-09 12:18:26 +00:00
Carlos Garnacho
075c77325b gdk: Avoid poking possibly freed memory
The event may end up freed after delivery, ensure to keep a ref in order
to emit the matching emulated crossed event matching a proximity event.

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/2157
2019-10-09 10:35:50 +02:00
Matthias Clasen
5f8dc5459e Merge branch 'wip/chergert/quick-fixes' into 'master'
renderer quick fixes

See merge request GNOME/gtk!1124
2019-10-08 19:43:14 +00:00
Benjamin Otte
adff8c2c60 Merge branch 'wip/chergert/cache-text-render-node' into 'master'
textview: cache paragraph render nodes

See merge request GNOME/gtk!1125
2019-10-08 19:21:57 +00:00
Christian Hergert
3b959456ac textview: cache paragraph render nodes
We can avoid recreating a number of text nodes from render_para() on
sub-sequent runs if we cache the rendernode instead of just the
PangoLayout.

When used with GtkSourceMap, this can yield a ~7 FPS improvement during
smooth scrolling at the cost of some more memory.
2019-10-08 11:44:27 -07:00
Christian Hergert
47ef5af778 gl: remove stray + 2019-10-08 10:58:29 -07:00
Christian Hergert
76ea157f17 rendernode: remove unused macros 2019-10-08 10:57:45 -07:00
Carlos Garnacho
f354a7787a gdk: Fix wl_output accounting on tablet devices
The code managing this accounting mixed seat and tablet output lists,
can't bode well. Fixes invalid reads on list elements, as there are
dangling pointers.

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/2157
2019-10-08 17:59:57 +02:00
Sam Hewitt
83eeeb6a19 Adwaita: circular button fix
- remove old border drawing code that was breaking coloured buttons
 - fixes #2173
2019-10-07 16:50:34 -04:00
Sam Hewitt
6db181980a Adwaita: osd button fixes
- remove text/icon shadow from osd buttons
 - use :only-child to get circular standalone button
 - fixes #1696
2019-10-07 15:27:55 -04:00
Sam Hewitt
023bb2c984 Adwaita: use borders_color for separators
- fixes #2175
2019-10-07 13:05:12 -04:00
Benjamin Otte
a3cfb42888 eventcontrollerkey: Change behavior of contains-focus
contains-focus now returns TRUE when is-focus is TRUE instead of FALSE.

Fixes #2184
2019-10-07 04:49:50 +02:00
Benjamin Otte
578dc9e70b eventcontrollerkey: Add getters for the properties
...and use them.
2019-10-07 04:49:50 +02:00
Benjamin Otte
6769db160d icontheme: Don't try to scale pixbufs to 0px
Always insist on at least 1px, even if the thumbnail we're turning into
an icon was 256 * 3 and should be scaled to 32 * 3/8.
2019-10-07 04:49:50 +02:00
Benjamin Otte
56d16aae42 selectionmodel: Remove doubled semicolon 2019-10-07 04:49:50 +02:00
Alan Mortensen
d614f4c96d Updated Danish translation of gtk 2019-10-06 23:36:47 +02:00
Daniel Boles
98f0d85c4a Builder: Fix a couple of typos in documentation 2019-10-06 20:48:10 +01:00
Piotr Drąg
b3115454ce Update POTFILES.in 2019-10-06 15:13:31 +02:00
Benjamin Otte
cb3b6ff624 Merge branch 'gbsneto/vulkan-fixes' into 'master'
Implement VK_KHR_incremental_present

See merge request GNOME/gtk!1116
2019-10-05 15:19:04 +00:00
Georges Basile Stavracas Neto
a795d6635b vulkan/context: Implement VK_KHR_incremental_present
This is the Vulkan version of eglSwapBuffersWithDamage(), and
it's always a good idea to limit the number of pixels we're
pushing to the GPU and/or swapping into the display.
2019-10-05 12:13:22 -03:00
Georges Basile Stavracas Neto
a2b49322fb vulkan/renderpass: Use GENERAL for initial layout
UNDEFINED initial layouts may not preserve the contents
of the attachment after transitioning the layout. We want
them to be preserved because we do partial rendering.

Use GENERAL as the initial layout for render passes.
2019-10-05 12:13:22 -03:00
Georges Basile Stavracas Neto
0b2006b74f vulkan/image: Set HOST and TRANSFER bits for before barriers
Multiple images in the before barrier array are defined with
VK_ACCESS_TRANSFER_WRITE_BIT and VK_ACCESS_TRANSFER_READ_BIT,
which requires passing VK_PIPELINE_STAGE_TRANSFER_BIT and
VK_PIPELINE_STAGE_HOST_BIT to vkCmdPipelineBarrier().

Pass these flags correctly.
2019-10-05 12:13:22 -03:00
Georges Basile Stavracas Neto
a91d0ac156 wayland: Allow binding to wl_compositor v4
This is a requirement for using VK_KHR_incremental_present.
Vulkan Wayland drivers translate the VkPresentRegionsKHR to
wl_surface.damage_buffer(), which a v4-only request.
2019-10-05 12:13:22 -03:00
Christian Hergert
d71995ab5c Merge branch 'wip/chergert/textview-widgets' into 'master'
textview: use GtkWidget for borders and center_child

See merge request GNOME/gtk!1099
2019-10-04 23:30:04 +00:00
Christian Hergert
fea2a82ef6 textview: use GtkTextViewChild for border and overlay children
This creates a new GtkTextViewChild that can manage overlay children at
given x,y offsets in buffer coordinates. This simplifies GtkTextView by
extracting this from GtkTextWindow as well as providing a real widget for
the borders.

With this change, we also rename gtk_text_view_add_child_in_window() to
gtk_text_view_add_overlay(). For those that were using
GTK_TEXT_WINDOW_WIDGET, they can use a GtkOverlay. It does not appear
that anyone was using GTK_TEXT_WINDOW_(LEFT|RIGHT|TOP|BOTTOM) for widgets
in this fashion, but that can be done by setting a gutter widget with
gtk_text_view_set_gutter(). We can make GtkTextViewChild public if
necessary to simplify this should it become necessary.

GtkTextViewChild will setup a CSS node of either "text" or "border"
depending on the GtkTextWindowType.

The old GtkTextViewChild has been renamed to AnchoredChild as it is only
used for widgets with anchors in the GtkTextBuffer. This also removes the
use of allocated GSList and instead embeds a GQueue and GList to save a
few extraneous allocations.
2019-10-04 14:45:43 -07:00
Christian Hergert
8373cc6c47 textview: revert renaming of buffer_to_surface_coords()
The renaming of this function doesn't make much since because the window
is the GtkTextWindowType, not GdkWindow specifically. So we can keep the
old name which is closer to the proper meaning and less code for consumers
to change when porting to 4.x.
2019-10-04 13:22:49 -07:00
Matthias Clasen
872d2046fd Merge branch 'list-box-headers' into 'master'
Fix reuse of list box header widgets

See merge request GNOME/gtk!1114
2019-10-04 18:27:05 +00:00
Sam Hewitt
44ec142fa9 Adwaita: new levelbar style 2019-10-04 14:16:11 -04:00
Philip Withnall
b70f389b64 gtklistbox: Only unparent header rows if they haven’t been reused
It’s possible for code which uses a `GtkListBox` to reuse a single
header row, and move it around between rows. For example, this might
happen if the code has interactive widgets (like buttons) in the row,
and doesn’t want to continually recreate them and reattach signals to
them whenever the row headers change.

Unfortunately, this was broken, as the old header widget was
unconditionally unparented, even if it had just been set as the header
for a different row in the same `GtkListBox`. This left it assigned as
a child widget in the `GtkListBox` (so it was iterated over by
`forall`), but without its parent widget set.

Fix that by only unparenting the header if it hasn’t already been
assigned as the parent of a different row.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-10-04 18:48:53 +01:00
Philip Withnall
1c73edd9b0 gtklistbox: Factor the new header out into a separate variable
Makes the code a little clearer, but makes no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-10-04 18:48:51 +01:00
Christoph Reiter
94d9088034 Print a warning if GTK_DEBUG is set but gtk isn't built with G_ENABLE_DEBUG
G_ENABLE_DEBUG is tied to the meson builttype property, so building with "plain"
results in G_ENABLE_DEBUG not being defined and the GTK_DEBUG env var just gets ignored
for that build.

Since it can be confusing that GTK_DEBUG has no effect print a warning message instead.

See #2020. This is a port of !1109 to master
2019-10-02 21:35:20 +02:00
Ask Hjorth Larsen
cbd9e560b0 Updated Danish translation of gtk-properties 2019-10-02 05:54:14 +02:00
Ask Hjorth Larsen
abc595b810 Updated Danish translation of gtk 2019-10-02 05:54:12 +02:00
Marek Černocký
7d26d3926c Updated Czech translation 2019-10-02 02:06:50 +02:00
Georges Basile Stavracas Neto
0e55f7a52f wayland/surface: Fix crash when unexporting
This is the exact same problem of 655c9dd526.
2019-10-01 16:13:43 -03:00
Marek Černocký
febe128e72 Updated Czech translation 2019-10-01 17:32:46 +02:00
Georges Basile Stavracas Neto
3afc7b0883 Merge branch 'gbsneto/fix-wayland-export-handle' into 'master'
wayland/surface: Only call destroy func when available

Closes #2179

See merge request GNOME/gtk!1112
2019-10-01 15:22:22 +00:00
Georges Basile Stavracas Neto
655c9dd526 wayland/surface: Only call destroy func when available
When calling gdk_wayland_surface_export_handle(), if we pass
some 'user_data' but no 'destroy_func', GTK4 crashes. That's
because in xdg_exported_handle() we are unconditionally calling
destroy_func -- even when it's NULL.

Fix that by checking if there's a destroy function before calling
it.

Fixes https://gitlab.gnome.org/GNOME/gtk/issues/2179
2019-10-01 11:54:28 -03:00
Matej Urbančič
bcea96528a Updated Slovenian translation 2019-09-28 21:14:54 +02:00
Piotr Drąg
7336e18410 Update Polish translation 2019-09-28 13:59:24 +02:00
Aurimas Černius
412af0269d Updated Lithuanian translation 2019-09-28 12:51:44 +03:00
Matthias Clasen
5e17afbc0a Merge branch 'printing-get-ppd-from-original-host-if-needed' into 'master'
Printing get ppd from original host if needed

See merge request GNOME/gtk!1100
2019-09-27 19:24:00 +00:00
Benjamin Otte
912236439c Merge branch 'wip/ricotz/mediafile' into 'master'
mediafile: Use correct return-type for factory methods

See merge request GNOME/gtk!1105
2019-09-26 10:44:30 +00:00
Rico Tzschichholz
0ad4166482 mediafile: Add g-i annotations for actual return-type of factory methods 2019-09-26 08:19:25 +02:00
Timm Bäder
7ce1055656 eventcontrollerscroll: Events are unhandled by default
While the ::scroll signal always returns whether it handled the event,
the others do not, for example ::decelerate.

Previously, this caused the event to stop at a scroll controller with
CAPTURE phase, never emitting the ::decelerate signal on later
controllers with BUBBLE phase.

Fixes #2151
2019-09-25 17:51:53 +02:00
Timm Bäder
78a376aa7f snapshot: Try to avoid some linear gradient nodes 2019-09-25 17:51:52 +02:00
Timm Bäder
43f2b47fc9 searchentry: Use a box layout 2019-09-25 17:51:52 +02:00
Timm Bäder
413cfed7d7 searchentry: Use edit-clear-all-symbolic as clear icon
Fixes #2109
2019-09-25 17:51:52 +02:00
Timm Bäder
e05b87c8d0 gl renderer: Fix rounded rect intersection 2019-09-25 17:51:52 +02:00
Timm Bäder
1b4bce4182 fontchooserwidget: Use a bin layout 2019-09-25 17:51:52 +02:00
Timm Bäder
387587dedb colorbutton: Use a bin layout 2019-09-25 17:51:52 +02:00
Timm Bäder
5d8c8f33c0 dialog: Remove useless gtk_widget_show() call 2019-09-25 17:51:52 +02:00
Timm Bäder
d032396031 filechooserbutton: Add icon to default (None) combo box item
See #2118
2019-09-25 17:51:52 +02:00
Timm Bäder
12438b30a0 filechooserbutton: Remove priv->child
We never use it except when updating the state flags, but we can as well
do that for both children.
2019-09-25 17:51:52 +02:00
Timm Bäder
ea1ff9c482 filechooserbutton: Remove an outdated comment
The path used is wrong but the string isn't used in the testsuite
anyway.
2019-09-25 17:51:52 +02:00
Timm Bäder
8122156e84 scrolledwindow: Remove set_placement_internal()
set_placement() does the exact same thing.
2019-09-25 17:51:52 +02:00
Timm Bäder
991f4ed993 menubar: Use a box layout 2019-09-25 17:51:51 +02:00
Timm Bäder
29244c5c40 video: Use a bin layout 2019-09-25 17:51:51 +02:00
Timm Bäder
ca3d855c44 levelbar: Use a bin layout 2019-09-25 17:51:51 +02:00
Matthias Clasen
3fcd39f659 docs: Add GtkNative to types
This is needed to make doc generation work
for GtkNative.
2019-09-24 11:38:35 -04:00
Danial Behzadi
c2b823f185 Update Persian translation 2019-09-22 11:36:55 +00:00
Timm Bäder
7de076481e headerbar: Fix end-packed child order
We pack from right to left there.
2019-09-21 09:41:53 +02:00
Marek Kasik
58cfa3fd49 printing: Get PPD from original host if needed
Try to get PPD from original host if there is no PPD for remote printer
on current CUPS server.
2019-09-19 18:35:23 +02:00
Matthias Clasen
87e7fa9917 Merge branch 'wip/kill-menu' into 'master'
Use menus less

See merge request GNOME/gtk!1098
2019-09-16 22:10:02 +00:00
Matthias Clasen
b14b0efefe toolbar: Use a popover for overflow
We are phasing out menus.

This is not quite complete, toolitems still
create menuitems, which we translate on the fly.
2019-09-16 17:30:47 -04:00
Matthias Clasen
1b271f3335 notebook: Use a popover for the tab menu
We are phasing out menus.
2019-09-16 17:30:47 -04:00
Matthias Clasen
03e30431a8 menutoolbutton: Add support for popovers
Just like the underlying menu button, support
popovers too.
2019-09-16 07:24:59 -04:00
Matthias Clasen
5a93449b89 window: Make fallback menu a popover
We want to phase out menus.
2019-09-16 07:23:17 -04:00
Matthias Clasen
222e05c2d2 Remove unused includes
Don't include gtkmenu.h in places where
it isn't used anymore.
2019-09-16 07:23:17 -04:00
Matthias Clasen
c0071a0676 text util: Remove an unused function
_gtk_text_util_append_special_char_menuitems was not used.
2019-09-15 15:01:45 -04:00
Rico Tzschichholz
97231ca231 gtk: Fix some g-i annotation warnings 2019-09-15 17:57:28 +02:00
Rico Tzschichholz
67bd28eaaf gtk: Fix parameter annotations for gtk_buildable_parse_context_get_position 2019-09-15 17:57:28 +02:00
Rico Tzschichholz
51b2fd1777 build: gtkbuilderparser.c contains g-i annotations for public API 2019-09-15 17:57:28 +02:00
Matthias Clasen
ff5eac6da5 Merge branch 'wip/rah/screensaver-active-fix' into 'master'
gtkapplication-dbus: Initialise screensaver-active property

See merge request GNOME/gtk!1091
2019-09-15 15:54:08 +00:00
Matthias Clasen
4987cb0407 Merge branch 'wip/chergert/fix-textview-clip' into 'master'
textview: clip to text window when drawing

See merge request GNOME/gtk!1095
2019-09-14 21:18:02 +00:00
Christian Hergert
7927f7a440 textview: clip to text window when drawing
When drawing the GtkTextView text, we need to clip to the visible area
so that we do not risk drawing under the border windows.
2019-09-13 16:44:04 -07:00
Christian Hergert
605284bc36 textview: fix textview drawing in presence of gutters
When drawing a left or top gutter, we need to adjust the origin of the
text snapshot or we risk the gutter drawing above the text.
2019-09-13 16:02:28 -07:00
Timm Bäder
54ed31ebaf notebook: Use a box layout
And incidentally make the CSS node docs correct again.
2019-09-13 19:21:04 +02:00
Timm Bäder
6320bd5849 fontbutton: Shorten clear_font_data a bit 2019-09-13 19:21:02 +02:00
Timm Bäder
86cc7f6925 fontbutton: Use a bin layout 2019-09-13 11:53:24 +02:00
Timm Bäder
adb77e1a92 appchooserdialog: Remove unnecessary gtk_widget_show() calls 2019-09-13 11:39:34 +02:00
Timm Bäder
097f3c9514 headerbar: Remove spacing property
Replace it with border-spacing in css
2019-09-13 11:07:56 +02:00
Timm Bäder
f0266cbef3 pixbuf: Add a missing return value transfer annotation
And add a (nullable)
2019-09-13 11:07:56 +02:00
Timm Bäder
519967cc69 headerbar: Use a center layout
Get rid of the custom title centering etc. and use a GtkCenterLayout.
Use a box on the start/end to manage the child widgets.
2019-09-13 11:07:56 +02:00
Timm Bäder
a7b9a33efc Add GtkCenterLayout
And use it in GtkCenterBox, different widgets following.
2019-09-13 11:07:54 +02:00
Timm Bäder
32b84b8ab6 native: Don't compare a pointer with 0
We have NULL for that.
2019-09-11 08:12:31 +02:00
Timm Bäder
8ec1c866e1 widget: Inline build_finalize_assertions into only caller 2019-09-11 08:12:31 +02:00
Timm Bäder
3a06394fde headerbar: Don't update window buttons when unrealized
It doesn't make much sense in that case and we will update them again
when realizing.
2019-09-11 08:12:31 +02:00
Timm Bäder
ce72154913 Rename gtkbookmarkmanager.h to gtkbookmarksmanagerprivate.h
It's a private type, so gets a private header file name.
2019-09-11 08:12:31 +02:00
Timm Bäder
ed11f2a9e4 bookmarksmanager: Stop exporting get_xdg_type 2019-09-11 08:12:31 +02:00
Timm Bäder
60f2e452a1 switch: Stop using a private struct
Private type, no private struct needed.
2019-09-11 08:12:31 +02:00
Alexander Larsson
76103ee286 GtkBuildable: Fix indentation 2019-09-10 12:08:20 -04:00
Alexander Larsson
73042bfc54 GtkWidget: Precompile template xml on class creation
Ideally we will precompile during build and store the result in the
resource, but if that doesn't happen at least we will only parse
the xml once.
2019-09-10 12:08:20 -04:00
Alexander Larsson
ff23397701 GtkBuilder: Add support for precompiling builder xml 2019-09-10 12:08:20 -04:00
Alexander Larsson
96b37f4eb8 Use the new GtkBuildableParser type in GtkBuildable interfaces 2019-09-10 12:08:20 -04:00
Alexander Larsson
135cea76fb GtkBuildableParser: Add a wrapper for GMarkupParser
This currenly just wraps GMarkupParser, but the plan is to expose this
instead of GMarkup in the GtkBuildable interfaces, allowing us to
replace the parser with something that handles pre-parsed input
instead.

Note that we duplicate some of the features of GMarkup to implement
the APIs rather then call down to GMarkup, as we need to support these
in the pre-parsed case anyway.
2019-09-10 12:07:15 -04:00
Matthias Clasen
ff087e126f Merge branch 'wip/chergert/tune-linedisplay-cache' into 'master'
textview: optimize linedisplay cache based on number of visible rows

See merge request GNOME/gtk!1090
2019-09-10 01:42:13 +00:00
Matthias Clasen
9501fc2c14 Merge branch 'nested-popover-menu' into 'master'
Nested popover menus

See merge request GNOME/gtk!1076
2019-09-10 01:09:31 +00:00
Piotr Drąg
7547291450 Update POTFILES.in 2019-09-09 19:13:53 +02:00
Timm Bäder
0603b4431a icontheme: Stop using a private struct
The GtkIconTheme/GtkIconInfo structs aren't public anymore, so use the
structs directly instead of a priv pointer.
2019-09-09 17:36:27 +02:00
Timm Bäder
5f48f60a93 Icontheme: Clean up gtk_icon_info_load_async 2019-09-09 17:36:27 +02:00
Timm Bäder
cc9faf3cfa scrolledwindow: Actually add controller to widget
Closes #2127
2019-09-09 17:36:27 +02:00
Timm Bäder
7d93e9963a testlist2: quit on window close 2019-09-09 17:36:27 +02:00
Timm Bäder
32cec6c1cb icontheme: Adapt a code sample to the GdkPaintable transition 2019-09-09 17:36:27 +02:00
Timm Bäder
c0827e2c54 pixbufutils: Escape file data only once 2019-09-09 17:36:27 +02:00
Timm Bäder
1a931da046 pixbufutils: Pass colors as string to load_symbolic_svg
We were converting the same colors over and over again to a string, just
to free them again at the end of the function. We know the colors at
compile time however, so don't convert them at all.
2019-09-09 17:36:27 +02:00
Timm Bäder
8eb62f138b pixbufutils: Only get icon size once
load_symbolic_svg was loading the pixbuf just to get its size via
gdk_pixbuf_get_{width,height}. However, this function is called in a
loop in gtk_make_symbolic_pixbuf_from_data.

So, do this only once and pass the icon size along to load_symbolic_svg.
2019-09-09 17:36:27 +02:00
Timm Bäder
6a8921ec6b icontheme: Remove symbolic pixbuf cache
We recolor icons on via color matrix nodes these days, so this cache is
basically unused.
2019-09-09 17:36:27 +02:00
Timm Bäder
53132d0235 icontheme: Add LRU cache back
Add a cache of icon infos that we keep around a little longer, to avoid
loading icons from disk that only exist for a short amount of time (e.g.
during one frame of a cell renderer snapshot).

We make sure recently used items are kept alive by just adding them to
the cache on lookup.
2019-09-09 17:36:27 +02:00
Timm Bäder
32bed34935 icontheme: Remove GtkIconInfo->pixbuf
Create textures as soon as possible.
2019-09-09 17:36:26 +02:00
Timm Bäder
1873b38a94 icontheme: Remove icon_info_load_pixbuf
What it does overlaps with the only caller a lot now.
2019-09-09 17:36:26 +02:00
Timm Bäder
38b4a2a8e2 icontheme: Optimize suffix_from_name
We call this function a lot, so avoid repeated strlen() calls on @name
and the different suffixes.
2019-09-09 17:36:26 +02:00
Timm Bäder
b65d9ca955 icontheme: Avoid creating useless IconThemeDirs
We were allocating IconThemeDir instances and then only later assign a
value to has_icons. In the !has_icons case, we were directly throwing
the IconThemeDir away again.

Delay allocating the IconThemeDirs until we know that it has icons.
This avoids allocating and then de-allocating around 1400 IconThemeDir
instances when opening the widget-factory.
2019-09-09 17:36:26 +02:00
Timm Bäder
0b472c23d7 icontheme: Inline scan_resources into only caller
The previous code was hiding the fact that the scan_resources function
almost always did nothing and just used g_resources_enumerate_children()
and then returned FALSE, leaving the caller with cleaning up the already
allocated IconThemeDir. By inlining this, we make sure that calling code
does not even need to allocate the IconThemeDir.
2019-09-09 17:36:26 +02:00
Timm Bäder
bb89ee184f icontheme: Remove proxy pixbufs
These were only used for the LRU cache.
2019-09-09 17:36:26 +02:00
Timm Bäder
eb087c9943 icontheme: Remove lru cache
We will replace it with something else later
2019-09-09 17:36:26 +02:00
Timm Bäder
eeec6f8fb9 icontheme: Annotate return value as nullable 2019-09-09 17:36:26 +02:00
Timm Bäder
71339225eb icontheme: Remove gtk_icon_info_load_texture
It's the same as load_icon now.
2019-09-09 17:36:26 +02:00
Timm Bäder
590e70d4d1 icontheme: Return a paintable from gtk_icon_info_load_icon 2019-09-09 17:36:26 +02:00
Timm Bäder
fd16ac4d5e icontheme: Return paintables from more API 2019-09-09 17:36:26 +02:00
Timm Bäder
f3099afcc5 icontheme: Return textures from load_icon{,_for_scale} 2019-09-09 17:36:26 +02:00
Timm Bäder
37f8e6aabd gdk: Add gtk_pixbuf_get_from_texture 2019-09-09 17:36:26 +02:00
Timm Bäder
e0fe2882ad icontheme: Don't try to scale pixbufs to same size 2019-09-09 17:36:26 +02:00
Timm Bäder
4413592a70 recentmanager: Stop using linked lists
It doesn't really make sense to save the applications and groups in
recent infos as linked lists. We get them from glib as arrays, so we can
as well just save them as such.
2019-09-09 17:36:26 +02:00
Timm Bäder
4c28ee80a6 filechooserwidget: Create recent manager when setting operation mode
Creating a recent manager can be fairly expensive and we won't use it if
the widget is not visible or the recent mode has not been entered. Code
other places can already handle a NULL recent manager, so just create it
when entering the recent mode. And shove 25ms of startup time off the
widget-factory this way.
2019-09-09 17:36:26 +02:00
Timm Bäder
f4c4fe860b filechooserwidget: Remove custom recent_info_has_application impl 2019-09-09 17:36:26 +02:00
Timm Bäder
4766b475d0 filechooserwidget: Inline come functions into only callers
Similar to the previous commit(s), make it clearer what this function
does.
2019-09-09 17:36:26 +02:00
Timm Bäder
ae75d4b565 filechooser: Move extract_recent_folders to filechooserwidget
It's not used anywhere else.
2019-09-09 17:36:26 +02:00
Timm Bäder
c102387916 filechooserwidget: Load recent files synchronously
Delaying this by one frame by putting it in an idle just makes the code
more complex for no gain. The actual slow part is reading the
recently-used.xbel, which happens when creating the recent manager.
2019-09-09 17:36:26 +02:00
Timm Bäder
86ad215deb recentmanager: Indentation 2019-09-09 17:36:26 +02:00
Timm Bäder
c3f82534bd widget-factory: Use proper setter to set has-arrow 2019-09-09 17:36:26 +02:00
Timm Bäder
2ffbb37783 icontheme: Annotate return value of load_icon as nullable
It returns NULL in the error case.
2019-09-09 17:36:26 +02:00
Timm Bäder
6821fe0c13 icontheme: Add error argument to _load_texture
Loading an icon might fail.
2019-09-09 17:36:26 +02:00
Timm Bäder
a0947232fa icontheme: optimize icon_uri_is_symbolic as well 2019-09-09 17:36:26 +02:00
Timm Bäder
e3f1a3d27c main: Check if any debug flags are set in gtk_get_debug_flags()
We end up checking the debug flags for the default display, but that's
unnecessary if we know that no display has any debug flags set anyway.
2019-09-09 17:36:26 +02:00
Timm Bäder
d98e05b91a icontheme: Save the min_suffix for the min_dir
We already have to compute that value in the loop before, so just save
it.
2019-09-09 17:36:26 +02:00
Timm Bäder
fa85f4fc2e icontheme: Remove use_builtin parameter from theme_lookup_icon
Unused.
2019-09-09 17:36:26 +02:00
Timm Bäder
44352b375e icontheme: Remove paramter from get_icon_suffix
Turns out nobody care about that one.
2019-09-09 17:36:26 +02:00
Timm Bäder
ebe88ea322 icontheme: Optimize icon_name_is_symbolic
We call this function *a lot* it's doing lots of unnecessary work inside
g_str_has_suffix. Get the icon name length only once instead and
open-code the suffix check.
2019-09-09 17:36:26 +02:00
Timm Bäder
6d77723fe0 gtkicontheme: Avoid a get_icon_flags call
We're only using the value of the first call at all if
symbolic_suffix & ICON_SUFFIX_PNG is FALSE.
2019-09-09 17:36:26 +02:00
Timm Bäder
c5ed51a188 icontheme: Remove outdated comment
It's not called css_fg anymore and it can't possibly be NULL since we
make sure before passing it here.
2019-09-09 17:36:25 +02:00
Timm Bäder
1339c425a8 widget: Queue an allocate on native widgets when changing opacity
This way the opacity change works on toplevel windows on wayland.
2019-09-09 17:36:25 +02:00
Timm Bäder
7c723dfc58 inspect-button: Inline deemphasize_window() into only caller 2019-09-09 17:36:25 +02:00
Timm Bäder
72814a8153 inspect-button: Inline some functions into only caller
Make them clearer for later commits.
2019-09-09 17:36:25 +02:00
Timm Bäder
9952f72680 filechooserwidget: Properly watch for different display
The value returned by gtk_widget_get_settings() depends on the widget's
display, so watch for notify::display instead of using (un)root for
this.

Fixes the warnings seen when show a file chooser from the inspector.
2019-09-09 17:36:25 +02:00
Timm Bäder
b9473bc99c glarea: Fix buffer initialization
This only worked when the vao id and the buffer id accidentally matched,
for example when running gtk4-demo with --run=glarea

Fixes #2042
2019-09-09 17:36:25 +02:00
Timm Bäder
cbc3ce5b03 box: Don't do casts before preconditions 2019-09-09 17:36:25 +02:00
Timm Bäder
d223752c55 infobar: Inherit from GtkContainer
infobars being a GtkBox doesn't make sense.
Also implement infobars without exposing internal children.

Closes #1957 because it adds the bottom border.
2019-09-09 17:36:25 +02:00
Timm Bäder
74208e9e0c text: Fix a crash when retrieving the selected text 2019-09-09 17:36:25 +02:00
Timm Bäder
14b7fa1dd6 textview: Remove useless warning
The output doesn't make sense anymore and it breaks cursor blinking when
moving the focus back into the textview.
2019-09-09 17:36:25 +02:00
Timm Bäder
4bfe8605cb layoutoverlay: Fix everything
This code is better because:

  1) The coordinates translations are actually correct and not sometimes
     wrong like before
  2) We clip widgets that have overflow set
  3) We honor the widget's transform
  4) It is less code
2019-09-09 17:36:25 +02:00
Timm Bäder
e86bf764a8 scale: Allocate value close to slider
The scale might be allocated at a height greater than requested, and in
that case y=0 is just too far away. Allocate the value directly next to
the slider instead.
2019-09-09 17:36:25 +02:00
Timm Bäder
80411fb905 scale: Use top/left/bottom/right style classes on value label
Just top/bottom is not enough anymore.

77769a52b3 broke e.g. horizontal scales
with the value on top/bottom, adding too much space.
2019-09-09 17:36:25 +02:00
Timm Bäder
c9241e83dd gl renderer: Remove unused matrix 2019-09-09 17:36:25 +02:00
Timm Bäder
9166b03c42 fixed: Documentation clarifications 2019-09-09 17:36:25 +02:00
Timm Bäder
31efc882db fixed: x/y passed to get_child_position are not optional 2019-09-09 17:36:25 +02:00
Timm Bäder
1db59d1c89 fixedlayout: Don't call the child transform position
It's a full transform and not just a translation these days.
2019-09-09 17:36:25 +02:00
Timm Bäder
afb3715700 linkbutton: Use widget API to set has-toolip
As God intended.
2019-09-09 17:36:24 +02:00
Timm Bäder
6be4279f39 linkbutton: Use proper action name for right-click menu 2019-09-09 17:36:24 +02:00
Timm Bäder
5782871f91 menubutton: Control sensitivity of child button
Instead of the menubutton itself.
2019-09-09 17:36:24 +02:00
Timm Bäder
0e9ac9e64b magnifier: Remove some unused members 2019-09-09 17:36:24 +02:00
Timm Bäder
13df99fd1e docs: Remove styles.txt
The information is all wrong and superseded by the css docs
2019-09-09 17:36:24 +02:00
Timm Bäder
9f62bd1da6 docs: Remove widget_system.txt
Almost all information in here is incorrect or outdated, most of it is
still from gtk2 and GtkObject days.
2019-09-09 17:36:24 +02:00
Timm Bäder
75c1562df0 docs: Remove widget_geometry.txt
The information in that file is all outdated.
2019-09-09 17:36:24 +02:00
Timm Bäder
0821d5b29d widget: Clear up gtk_widget_class_install_property_action docs 2019-09-09 17:36:24 +02:00
Timm Bäder
b3cffc0516 widget: Remove reference to non-existent function
gtk_widget_class_install_stateful_action() does not exist.
2019-09-09 17:36:24 +02:00
Timm Bäder
80a58672d1 widget: Add some missing annotations to gtk_widget_class_query_action 2019-09-09 17:36:24 +02:00
Timm Bäder
18714e25a8 window: Remove useless deprecation guards
gtk_window_present() is not deprecated.
2019-09-09 17:36:24 +02:00
Timm Bäder
b29c30c9d5 cssprovider: Remove unused member from GtkCssScanner 2019-09-09 17:36:24 +02:00
Timm Bäder
d8df197489 cssprovider: Don't lookup on empty css providers
This should not have a huge performance impact, but debugging is easier
if we don't lookup in empty css providers.
2019-09-09 17:36:24 +02:00
Timm Bäder
514e60c1bb cssnode: GtkCssAnimatedStyle->style is always a static style 2019-09-09 17:36:24 +02:00
Timm Bäder
32a256bd03 gtksettings: Remove unused functions & prototypes 2019-09-09 17:36:24 +02:00
Timm Bäder
b9316a404a cssnode: Remove unused struct 2019-09-09 17:36:24 +02:00
Timm Bäder
ea2a3f3e62 cssstyle: Remove unused _add_difference 2019-09-09 17:36:24 +02:00
Timm Bäder
5cd8009c53 stylecontext: Remove leftover function prototypes 2019-09-09 17:36:24 +02:00
Timm Bäder
26aa620efe stylecontext: Stop exporting _resolve_color
Only used in gtkstylecontext.c
2019-09-09 17:36:24 +02:00
Timm Bäder
e0cf6e4775 csscolorvalue: return the initial color value directly 2019-09-09 17:36:24 +02:00
Timm Bäder
df2d43c893 csscolorvalue: Remove unused new_from_rgba() 2019-09-09 17:36:24 +02:00
Timm Bäder
8d6c5ba90e cssstaticstyle: Compute initial/inherit values directly 2019-09-09 17:36:24 +02:00
Timm Bäder
629f528f6d cssinitialvalue: Make _compute public
So we can use it in cases where the class of css value is known to be an
initial one.
2019-09-09 17:36:24 +02:00
Timm Bäder
191e3bc7e1 csslookup: Remove 'relevant' parameter from _init
Unused.
2019-09-09 17:36:24 +02:00
Timm Bäder
ecad4743bd csslookup: Remove 'missing' bitmask
It's almost never useful to have a bitmask here, since it's only used
for the intersection case in gtk_css_style_provider_lookup. However,
even if that returns true, we still need to check every single style
property for being set again in the look afterwards.

Just remove the bitmask.
2019-09-09 17:36:24 +02:00
Timm Bäder
ceb8aedf97 cssanimatedstyle: Keep transition_info_add from recursing
The slowest part of that fuction is the type check for
GtkCssShorthandProperty. Subproperties of shorthand properties never
refer to more shorthand properties however, so we don't want to have the
type check for those.
2019-09-09 17:36:24 +02:00
Timm Bäder
0cf4eb379f csslookup: Remove tautological if expression
A value is always either set or missing.
This was changed in a1f7c459b7, which
removed the ability for partial style computation.
2019-09-09 17:36:24 +02:00
Timm Bäder
f3fdf58ff7 cssstaticstyle: Avoid ref'ing specified value in compute_value
There are alerady _get functions for GtkCssInheritValue and
GtkCssInitialValue, so use those. We can avoid a ref+unref pair this
way.
2019-09-09 17:36:24 +02:00
Timm Bäder
3073e65851 cssprovider: Fix compilation wth VERIFY_TREE set 2019-09-09 17:36:24 +02:00
Timm Bäder
a75529f3c0 cssmatcher: Inline node values into matcher
So we don't have to go through the matcher->node->decl every time
2019-09-09 17:36:24 +02:00
Timm Bäder
75a48aed0b cssanimatedstyle: Make set_animated_value transfer-full 2019-09-09 17:36:24 +02:00
Timm Bäder
a7f23ebe7d cssimage: Use gtk_internal_return_val_*
GtkCssImage is not public and being used in hot paths, e.g. CSS.
2019-09-09 17:36:23 +02:00
Timm Bäder
0f9a02e6f4 gtkprivate: Only define gtk_internal_return_if* for consistency checks
The wanted behavior here is that these are only defined if the buildtype
is debug, i.e. full debugging.
2019-09-09 17:36:23 +02:00
Timm Bäder
4b4b77ca04 cssanimatedstyle: Save animation in array 2019-09-09 17:36:23 +02:00
Timm Bäder
a231648607 cssanimatedstyle: Avoid type check in loop
We can just do the check once as source is not going to change within
the loop.
2019-09-09 17:36:23 +02:00
Timm Bäder
eeb5cd2321 cssanimatedstyle: Avoid unnecessary transition work
No need to do all the transition work if the transition duration will be
0 for all of them.
2019-09-09 17:36:23 +02:00
Timm Bäder
5c705ae9a5 cssrgbavalue: Add & use new_white() 2019-09-09 17:36:23 +02:00
Timm Bäder
19f69f6ac8 cssrgbavalue: Add an opaque white singleton
Used a few hundred times in the widget-factory.
2019-09-09 17:36:23 +02:00
Timm Bäder
ad1340cab4 cssrgbavalue: Add a singleton for transparent colors
The most common background color is no background color.
2019-09-09 17:36:23 +02:00
Timm Bäder
3a3a59c188 cssdimensionvalue: Create a few more common singletons 2019-09-09 17:36:23 +02:00
Timm Bäder
6ed6cc46de cssstaticstyle: Make set_value (transfer-full)
We only call this in one place and we can avoid a ref + unref pair this
way.
2019-09-09 17:36:23 +02:00
Timm Bäder
6837e80d14 css: Avoid more type checks in hot paths 2019-09-09 17:36:23 +02:00
Timm Bäder
4f3e65e745 csspalettevalue: Use simple arrays instead of a hashtable
Use two sorted name/value arrays to save the colors instead of a
hashtable. This makes palette values faster to compare etc.
2019-09-09 17:36:23 +02:00
Timm Bäder
36a1b69a19 cssanimatedstyle: Remove some casts in hot paths
gtk_css_animated_style_create_css_transitions down from 16% to 11%
when repeatedly clicking on a spinbutton button in the widget factory.
2019-09-09 17:36:23 +02:00
Timm Bäder
1f11892de4 bitmask: Add _gtk_allocated_bitmask_to_string 2019-09-09 17:36:23 +02:00
Timm Bäder
1bc8f3ac6e Adwaita: Hack around list button styling
Once again.
2019-09-09 17:36:23 +02:00
Timm Bäder
e62f10d5f0 widget-factory: Add a spinbutton in a list 2019-09-09 17:36:23 +02:00
Timm Bäder
822547dfef spinbutton: Use a box layout 2019-09-09 17:36:23 +02:00
Timm Bäder
c0214cfcc1 menubutton: Add a create_popup_func
Some use cases require a menu button to create the popup on demand.
2019-09-09 17:36:23 +02:00
Timm Bäder
cb6d96d65f menubutton: Remove unused member 2019-09-09 17:36:23 +02:00
Timm Bäder
4cc4868e93 label: Remove "line" from wrap properties
The property names are "wrap" and "wrap-mode", so it doesn't make sense
that the accessors refer to line_wrap and line_wrap_mode.
2019-09-09 17:36:23 +02:00
Timm Bäder
6c90d3a1b6 gsktransform: Fix documentation comment
There is no @m.
2019-09-09 17:36:23 +02:00
Timm Bäder
ffab342fc4 snapshot: Stop exporting _append_node_internal
Unused outside of gtksnapshot.c
2019-09-09 17:36:23 +02:00
Matthias Clasen
1203dc501c popover menubar: Use nested popover menus
Make the popover menubar use nested menus, to
better match the expected behavior of traditional
menus.
2019-09-08 19:02:06 -04:00
Matthias Clasen
3cbf1845a9 Add a timeout for open submenus
When a popover menu has an open submenu,
delay activating another item until after
the pointer is stationary for a little
while. This avoids the need for precise
horizontal motion when moving towards the
submenu.
2019-09-08 19:02:06 -04:00
Matthias Clasen
ea44eade21 Add nesting popover menus
Add a variant of popover menus that are nesting
like traditional menus. This is a better fit for
replacing traditional main menus.
2019-09-08 19:02:06 -04:00
Matthias Clasen
c75a368bab popover: Support vertical aligment
We already support horizontal alignment, and
we should do the same for vertical alignment.
2019-09-08 19:02:06 -04:00
Matthias Clasen
bc8d2add04 widget-factory: Add more submenus
Split the "Checks & Radios" submenu in the menubar
into two, so we can test opening multiple submenus.
2019-09-08 19:02:06 -04:00
Timm Bäder
c53f58e839 Merge branch 'wip/chergert/remove-emit-by-name' into 'master'
texttag: avoid use of g_signal_emit_by_name()

See merge request GNOME/gtk!1088
2019-09-08 07:40:55 +00:00
Piotr Drąg
50543a7948 Update POTFILES.skip 2019-09-07 13:29:47 +02:00
Marek Černocký
f7cd22d5ec Updated Czech translation 2019-09-07 12:10:12 +02:00
Emin Tufan Çetin
b136c77031 Update Turkish translation 2019-09-06 18:50:05 +00:00
Bob Ham
6bfe171058 gtkapplication-dbus: Initialise screensaver-active property
When GtkApplication starts listening to the screensaver's D-Bus
status, the screensaver-active property is not initialised and
applications making use of the property are out of sync until the
first state change.  Any application starting when the screensaver is
active will think it's inactive.

To fix this, we set the property when we first start monitoring the
screensaver.
2019-09-06 14:59:27 +01:00
Christian Hergert
5e49da1d73 textview: optimize linedisplay cache based on number of visible rows
This tries to estimate the number of visible rows in a textview based on
the default text size and then tunes the GtkTextLineDisplayCache to keep
3*n_rows entries in the cache.

This was found imperically to be near the right cache size. In most cases,
this is less than the number of items we cache now. However, in some cases,
such as the "overview map" from GtkSourceView, it allows us to reach a
higher value such as 1000+. This is needed to keep scrolling smooth on
the larger view sizes.

With this patch, a HiDPI system with a GtkSourceView and GtkSourceMap
from the GTK 4 port can perform smooth scrolling simultaneously.
2019-09-05 19:06:35 -07:00
Christian Hergert
cc7ae525ef texttag: avoid use of g_signal_emit_by_name()
This avoids looking up the signal by name and instead uses the saved
signal identifier from gtktexttagtable.c
2019-09-04 19:39:24 -07:00
Matthias Clasen
a29853f53b Merge branch 'wip/chergert/faster-comparison' into 'master'
textlayout: remove use of GtkTextIter in line comparison

See merge request GNOME/gtk!1087
2019-09-04 17:02:06 +00:00
Christian Hergert
7cea21043e textlayout: remove use of GtkTextIter in line comparison
We do not need to create a GtkTextIter to perform the comparison here as
that will require a number of validation steps that are extra work
compared to just discovering the GtkTextLine number directly.
2019-09-04 09:12:54 -07:00
Matthias Clasen
cbdea09c92 Merge branch 'gtk-4-issue2128' into 'master'
[gtk4] wayland: Fix xdg-output v3 support

See merge request GNOME/gtk!1082
2019-09-03 14:38:30 +00:00
Olivier Fourdan
31393704de wayland: Fix xdg-output v3 support
The xdg_output.done event is deprecated in xdg-output v3, so clients
need to rely on the wl_output.done event instead.

However, applying the changes on the fist wl_output.event when using
xdg-output v3 may lead to an incomplete change, as following xdg-output
updates may follow.

Make sure we apply xdg-output events on wl_output.done events with
xdg-output v3.

https://gitlab.gnome.org/GNOME/gtk/issues/2128
2019-09-03 16:13:24 +02:00
nana-4
3eec90cdc0 node editor: Avoid inheriting textview styles
...to its descendant selectors

Without ">", "text" style is propagated to entry in the emoji chooser.

https://gitlab.gnome.org/GNOME/gtk/issues/2061
2019-09-03 01:44:55 +09:00
nana-4
b9d8eb54b7 Adwaita: Don't inherit font style to popover
https://gitlab.gnome.org/GNOME/gtk/issues/2061
2019-09-03 01:43:41 +09:00
nana-4
a2fdb55384 Adwaita: Fix broken osd popover style
Apply %osd to child arrow and contents instead of parent popover.

https://gitlab.gnome.org/GNOME/gtk/issues/2061
2019-09-03 01:34:05 +09:00
Jordi Mas
848a19a013 Update Catalan translation 2019-09-01 08:28:18 +02:00
Ryuta Fujii
98bc89968a Update Japanese translation 2019-08-31 13:45:30 +00:00
Ryuta Fujii
9c0e9e462b Update Japanese translation 2019-08-31 12:31:35 +00:00
Ryuta Fujii
57d762d5ea Update Japanese translation 2019-08-31 12:27:01 +00:00
Changwoo Ryu
9018ce1125 Update Korean translation 2019-08-30 14:10:45 +00:00
Timm Bäder
1b32f5c28b Merge branch 'typo' into 'master'
popover: fix typo in schema string

See merge request GNOME/gtk!1071
2019-08-29 13:56:13 +00:00
Alexandre Franke
0e35e50f8f Update French translation 2019-08-29 12:53:34 +00:00
Alexandre Franke
88b617646a popover: fix typo in schema string 2019-08-29 14:50:20 +02:00
Ask Hjorth Larsen
27fa7eace1 Updated Danish translation of gtk-properties 2019-08-29 12:37:41 +02:00
Ask Hjorth Larsen
ca996e0e85 Updated Danish translation of gtk 2019-08-29 12:37:41 +02:00
Jordi Mas
df683205d9 Update Catalan translation 2019-08-28 19:37:59 +02:00
Benjamin Otte
6905935fd3 Merge branch 'wip/ricotz/issue2107' into 'master'
gsk: Add missing 'transfer full' annotations of instance parameters

Closes #2107

See merge request GNOME/gtk!1065
2019-08-26 17:00:34 +00:00
Rico Tzschichholz
5504c62af9 gsk: Add missing 'transfer full' annotations of instance parameters
Fixes https://gitlab.gnome.org/GNOME/gtk/issues/2107
2019-08-26 18:05:17 +02:00
Matthias Clasen
9bb58c3eca Merge branch 'office-runner-crash' into 'master'
Fix a crash in gtk-builder-tool

See merge request GNOME/gtk!1064
2019-08-26 13:50:43 +00:00
Matthias Clasen
c0b8eb30de Fix a crash in gtk-builder-tool
Crash pointed out by Bastien Nocera.

Testcase included.
2019-08-26 15:34:15 +02:00
Changwoo Ryu
8a734f947e Update Korean translation 2019-08-26 11:20:16 +00:00
Timm Bäder
e4904f6644 Merge branch 'doc-typos' into 'master'
Minor typos in the Documentation (a/an)

See merge request GNOME/gtk!1061
2019-08-26 09:18:47 +00:00
Дилян Палаузов
6ded38de2b Minor typos in the Documentation (a/an) 2019-08-25 12:52:46 +00:00
Matthias Clasen
4fa1f459dd Merge branch 'gdkmonitor-x11-manufacturer' into 'master'
gdk: x11: Fill GdkMonitor manufacturer with PNP id from EDID

Closes #1765

See merge request GNOME/gtk!859
2019-08-25 11:58:02 +00:00
Balázs Úr
25644aa6b1 Update Hungarian translation 2019-08-24 20:23:45 +00:00
Anders Jonsson
a3f13f9c58 Update Swedish translation 2019-08-22 09:45:38 +00:00
Emmanuele Bassi
d940d801a4 Merge branch 'build-remove-xiproto-xreply-check-gtk4' into 'master'
Remove NEED_XIPROTO_H_FOR_XREPLY check

See merge request GNOME/gtk!1059
2019-08-21 19:18:17 +00:00
Christoph Reiter
7b0af75a57 Remove NEED_XIPROTO_H_FOR_XREPLY check
It was only defined in the old autotools build to support a >20 year old x11,
https://bugzilla.gnome.org/show_bug.cgi?id=148032
2019-08-21 20:46:30 +02:00
Daniel Mustieles
5329ac6d4b Updated Spanish translation 2019-08-20 12:45:23 +02:00
Daniel Șerbănescu
2b123702cc Update Romanian translation 2019-08-19 11:50:59 +00:00
Daniel Șerbănescu
56c2431ed1 Update Romanian translation 2019-08-19 11:09:45 +00:00
Aurimas Černius
0ed5f939e9 Updated Lithuanian translation 2019-08-18 21:41:16 +03:00
Kukuh Syafaat
f3fa4fcb75 Update Indonesian translation 2019-08-16 09:16:05 +00:00
Asier Sarasua Garmendia
bd35ff61e3 Update Basque translation 2019-08-16 08:01:11 +00:00
Asier Sarasua Garmendia
aa6f3a627f Update Basque translation 2019-08-16 07:55:49 +00:00
Timm Bäder
ee27587428 scale: Add a destroy notify to set_format_value_func
Closes #2098
2019-08-15 17:21:47 +02:00
Timm Bäder
d2f76d689f scaler: Avoid some signal connections
We're mainly using this for icons that will never change contents or
size, and we're using a GtkScaler per such icon when on a hidpi setup,
so just avoid the two signal connections per icon.
2019-08-15 17:13:29 +02:00
Timm Bäder
20cd6cc155 spinbutton: Use gtk_button_new_from_icon_name 2019-08-15 16:23:01 +02:00
Timm Bäder
960e766206 widget: Don't duplicate events to translate coordinates 2019-08-15 16:23:01 +02:00
Timm Bäder
1c9fbe3773 widget: Remove captured event handler code 2019-08-15 16:23:01 +02:00
Timm Bäder
6669ddad09 scrolledwindow: Stop using _gtk_widget_set_captured_event_handler
We can use an event controller with phase = CAPTURE these days.
2019-08-15 16:23:01 +02:00
Daniel Șerbănescu
6e872715ef Update Romanian translation
(cherry picked from commit 1e8d46352e)
2019-08-14 09:07:44 +00:00
Daniel Șerbănescu
dc582b478f Update Romanian translation
(cherry picked from commit 10603f9598)
2019-08-14 06:30:36 +00:00
Matthias Clasen
55839dc508 Merge branch '948-patch-renaming-a-file-can-make-it-to-loose-selection_GTK4' into 'master'
filechooser: keep file selected after being renamed

Closes #948

See merge request GNOME/gtk!1053
2019-08-13 21:18:41 +00:00
Matthias Clasen
6dd23b2bf0 text view: Fix a typo
Pointed out in https://gitlab.gnome.org/GNOME/gtk/issues/2094
2019-08-13 15:16:03 -04:00
Jordi Mas
afd64f3740 Update Catalan translation 2019-08-13 08:40:18 +02:00
Daniel Șerbănescu
a7b6663b33 Update Romanian translation
(cherry picked from commit f9acfa1bd8)
2019-08-13 04:37:32 +00:00
Nelson Benítez León
487e095d24 filechooser: keep file selected after being renamed
Because otherwise when the file list is sorted "by name"
and the new name causes the file to be re-sorted to another
row, the selection stays in the old row which is now
occupied by a different file.

Fixed by keeping track of the renamed file and revealing
it in the "row-changed" signal handler, which gets emitted
after a file is renamed.

Fixes issue #948
2019-08-12 17:32:56 -04:00
Daniel Șerbănescu
b487e8f694 Update Romanian translation 2019-08-12 08:35:22 +00:00
Piotr Drąg
171e3454ad Update Polish translation 2019-08-11 14:37:14 +02:00
Timm Bäder
164ebee129 Adwaita: Style spinbutton up/down children explicitly
Once again to increase the specificty above that of the
"list row button.etc." selector. Makes hovering spinbutton buttons in
lists look normal again.
2019-08-11 10:41:58 +02:00
Timm Bäder
76f2c4f0aa Adwaita: Update .devel headerbar styling
Just pull in the changes from gtk-3-24
2019-08-11 10:30:01 +02:00
Timm Bäder
9999ac1255 range: Avoid a divison by 0
Based on a patch by Blake Latchford

Fixes #618
2019-08-11 10:06:52 +02:00
Daniel Boles
3242174f81 AccelLabel: Add get_accel_closure() accessor
Fixes #875
2019-08-11 09:55:43 +02:00
Timm Bäder
6f1cade817 color chooser: Port checkered pattern drawing from cairo 2019-08-11 09:34:50 +02:00
Timm Bäder
c6961f1b61 range: Use public delay-factory API 2019-08-11 09:34:50 +02:00
Timm Bäder
8c88453816 cellrenderer: Add accessors for {get,set}_is_expande{r,d} 2019-08-11 09:34:50 +02:00
Timm Bäder
0415574acf testsuite: Add another repeat node test case 2019-08-11 09:05:31 +02:00
Timm Bäder
c812e1dc94 Adwaita: Fix hovering modelbutton arrows
This CSS snippet was supposed to only recolor the popover arrow but
ended up also recoloring the > arrow on modelbuttons that show a
submenu. Make the selector more specific.
2019-08-11 09:05:31 +02:00
Timm Bäder
251bf45cf2 iconcache: ref textures
We can't just assume that the pointer we'se using as a cache key will
stay unique forever. The texture might be freed, and a later allocated
texture might have the same addres now, causing the cache to return
incorrect results.
2019-08-11 09:05:31 +02:00
Timm Bäder
13c0a9e27b iconcache: Replace broken debugging code 2019-08-11 09:05:31 +02:00
Timm Bäder
4c70bf6c9c testsuite: Add a repeat node test case 2019-08-11 09:05:31 +02:00
Timm Bäder
2914c360a9 gl renderer: Implement a subset of repeat nodes 2019-08-11 09:05:31 +02:00
Timm Bäder
8d1a2247e0 treeview: Redo tree line drawing using textures
Gets rid of the remaining cairo nodes used for line drawing.
2019-08-11 09:05:28 +02:00
Timm Bäder
4fba7f8c59 treeview: Redo grid line drawing using textures
The cairo pattern in use was simple enough, so just use a 2×1 or 1×2
texture to draw horizontal and vertical grid lines. This avoids a bunch
of cairo nodes (that can't be cached by the renderers).
2019-08-11 09:05:25 +02:00
Timm Bäder
a93745238f snapshot: Annotate child_bounds parameter of push_repeat as nullable 2019-08-10 19:51:45 +02:00
Timm Bäder
b812ff2597 treeview: Shorten destroy() implementation 2019-08-10 19:51:45 +02:00
Timm Bäder
8a51796150 treeview: Remove two _dashes members
Tree lines and grid lines always look the same these days.
2019-08-10 19:51:45 +02:00
Timm Bäder
dd7d171186 treeview: Remove GTK_TREE_VIEW_FOREGROUND_LINE 2019-08-10 19:51:45 +02:00
Timm Bäder
0ac20f978e spinbutton: Remove an unnecessary queue_draw() call 2019-08-10 19:51:45 +02:00
Timm Bäder
0a96c3f062 scale: Properly update when inverted
Just queue_resize()ing the range itself doesn't work as it will just
re-allocate all the child widgets (i.e. just the trough) to its old
position and size.
2019-08-10 19:51:45 +02:00
Timm Bäder
42e6630c3e scale: Make a function shorter 2019-08-10 19:51:45 +02:00
Timm Bäder
1125d08f0d range: Remove outdated comment 2019-08-10 19:51:45 +02:00
Timm Bäder
0544633755 Merge branch 'wip/sadiq/buildable-2080' into 'master'
builderparser: Allow bind-source without bind-property

Closes #2080

See merge request GNOME/gtk!1047
2019-08-10 13:39:47 +00:00
Mohammed Sadiq
a642883e33 Add builder tests for bind-source without bind-property
Fixes https://gitlab.gnome.org/GNOME/gtk/issues/2080
2019-08-10 19:03:37 +05:30
Mohammed Sadiq
c1bb699151 builderparser: Allow bind-source without bind-property
This allow users to bind same property of two objects with only
specifing “name” and “bind-source” in UI file.

Fixes https://gitlab.gnome.org/GNOME/gtk/issues/2080
2019-08-10 19:01:36 +05:30
Daniel Șerbănescu
120cfcc120 Update Romanian translation 2019-08-10 07:25:36 +00:00
Mohammed Sadiq
55af84d359 widget: Fix a typo in documentation 2019-08-10 12:11:13 +05:30
Christian Hergert
4ae362d138 textview: clear cached entries before releasing containers
We want to ensure all of the display cache entries are released in the
normal fashion before releasing the structures so that we can maintain
the invariant that cache_iter will always exist while in the cache.
2019-08-09 12:52:16 -07:00
Timm Bäder
fd201e4df7 treeviewcolumn: Remove cell_area parameter from _cell_get_size
Fixes #297
2019-08-09 17:04:58 +02:00
Timm Bäder
21123a1264 iconhelper: Don't snapshot 0 sized icons
This is happening for me when snapshotting small thumbnails in the file
chooser. The GtkScaler will scale the 1px height/width by 2, resulting
in nothing being drawn at all.
2019-08-09 15:55:38 +02:00
Timm Bäder
87aeec2b63 scale: Fix value widget measurement
Since we set the size request of the label, the later measure()
call would return at least the size we set, making the size only ever
grow.
2019-08-09 14:30:01 +02:00
Timm Bäder
ea5fc348fa scale: Replace format-value signal
There is no reason for this to be a signal, since multiple handlers
don't make sense anyway. It was also broken because the scale needs to
know when a signal handler is added so it can update the value
representation.

Replace the signal with a set_format_value_func function which allows us
to do that.

Fixes #113
2019-08-09 14:30:01 +02:00
Timm Bäder
ebc0d3760f range: remove range_size_request vfunc
It's unneeded in GtkScale and named after the gtk2 size_request function
2019-08-09 14:30:01 +02:00
Timm Bäder
b4a6d69f5d scale: Allocate left marks next to trough 2019-08-09 14:30:01 +02:00
Timm Bäder
1c8b746b42 testscale: Properly call gtk_main_quit 2019-08-09 14:30:01 +02:00
Timm Bäder
05cdce2e8d scale: Fix an uninitialized value 2019-08-09 14:30:01 +02:00
Timm Bäder
509b781079 widget: Avoid a few type checks 2019-08-09 14:30:01 +02:00
Aurimas Černius
c38deef753 Updated Lithuanian translation 2019-08-09 14:21:11 +03:00
Timm Bäder
4b7a6a885d Merge branch 'adwaita-scales-marks-fintune-fix-master' into 'master'
Adwaita: Fix fine-tune mode for scales with marks

Closes #1799

See merge request GNOME/gtk!696
2019-08-08 16:41:04 +00:00
Benjamin Otte
68869a0e0f Merge branch 'wip/gtk-icon-theme-no-svg-loader' into 'master'
gtk/icon-theme: Handle lack of SVG loader gracefully

Closes #2084

See merge request GNOME/gtk!1049
2019-08-08 07:27:10 +00:00
Jonas Ådahl
048957cd49 gtk/icon-theme: Handle lack of SVG loader gracefully
When loading a SVG icon from a gresource file only containing SVG icons,
but without having a SVG loader available in gdk-pixbuf, we would crash
when trying to eventually load the resource. Fix this by gracefully
handling this by simply failing to load the icon, while the first time
it happens, log a warning.

Fixes: https://gitlab.gnome.org/GNOME/gtk/issues/2084
2019-08-08 09:05:30 +02:00
Timm Bäder
434d32bf95 Adwaita: Fix round titlebar button outline radius
Fixes #2073
2019-08-07 18:49:50 +02:00
frederik.feichtmeier
1178a0011a Exclude appmenu titlebuttons 2019-08-07 18:46:50 +02:00
frederik.feichtmeier
0af2e65c80 Make titlebuttons round
- use even sides for the titlebuttons so the result is a circle and not an ellipse
- add maximum border radius
- set min width/height to 0
- adjust margin and padding to match the previous look
2019-08-07 18:46:47 +02:00
Timm Bäder
e8f3b47bf3 gesturelongpress: Add getter/setter for delay-factor 2019-08-07 14:11:00 +02:00
Timm Bäder
8b16e44d26 passwordentry: Fix a documentation comment parameter name 2019-08-07 13:12:57 +02:00
Timm Bäder
002abc6d48 placessidebar: Remove popover using gtk_widget_unparent()
the gtk_widget_destroy() does not work anymore.
2019-08-06 17:39:01 +02:00
Timm Bäder
aca31c3ab6 adwaita: Increase spinbutton button styling specificity
So it trumps the 'toned down' button styling.

Fixes #2012
2019-08-06 17:38:54 +02:00
Priit Laes
f43d344aa3 gdk: x11: Fill GdkMonitor manufacturer with PNP id from EDID
Previously, the manufacturer property of the GdkMonitor was NULL,
and having at least PNP id at GdkMonitor.manufacturer makes it
possible to distinguish between different monitors programmatically.
2019-08-06 09:16:01 +03:00
Matthias Clasen
a3609c3f6d Merge branch 'implement-choices-file-chooser-native-win32-for-gtk-4' into 'master'
Implement choices for GtkFileChooserNativeWin32 [Gtk4]

Closes #1982

See merge request GNOME/gtk!1043
2019-08-05 12:20:06 +00:00
Jordi Mas
ddc74a08be Update Catalan translation 2019-08-05 06:18:53 +02:00
Jor Teron
76614ea5f2 Add Karbi translation 2019-08-04 18:24:49 +00:00
Jor Teron
2eabe21aae Add Karbi translation 2019-08-04 18:22:12 +00:00
Christian Kirbach
72f574a9c0 Update German translation 2019-08-04 16:16:01 +00:00
Luca Bacci
02935afe94 GtkFileChooserNativeWin32: Uninitialize COM at end of thread
GtkFileChooserNativeWin32 is created and shown on a secondary thread.
This thread initializes COM support with CoInitializeEx but does not
finalize it, so we have a leak. Fix that by calling CoUninitialize()
before thread terminates.

See Merge Request !1043
2019-08-04 18:03:37 +02:00
Luca Bacci
234d0443b2 GtkFileChoooserNative: change prepend to append for insertions in choices list
Although slightly less efficient, keeping the order in the choices
list makes it easier for GtkFileChooserNative implementations to
add widgets in the order specified by the application.

See Merge Request !1043
2019-08-04 18:03:21 +02:00
Luca Bacci
822deabdfe Implement choices for GtkFileChooserNativeWin32
See Merge Request !1043
2019-08-04 18:03:05 +02:00
Timm Bäder
b2e94f81cf window: Remove some leftover event code 2019-08-03 14:44:25 +02:00
Timm Bäder
109df77d87 popover: Use GTK_POS_BOTTOM as default position
This has always made a lot more sense.
2019-08-03 14:44:25 +02:00
Timm Bäder
76e3284ca1 colorchooserwidget: Inherit from GtkWidget
No reason for this to be a GtkBox.
2019-08-03 14:44:24 +02:00
Timm Bäder
576504390d supp: Add some more exceptions 2019-08-03 14:44:24 +02:00
Matthias Clasen
660f46fcb1 Merge branch 'glsl-switch' into 'master'
glsl: don't use switch statements

See merge request GNOME/gtk!1036
2019-08-02 16:59:27 +00:00
Matthias Clasen
2bd93c1e9e Merge branch 'wip/sort-icons-by-size' into 'master'
window: sort icons before adding to _NET_WM_ICON

See merge request GNOME/gtk!1038
2019-08-01 23:31:44 +00:00
Ray Strode
1612e38cda window: sort icons before adding to _NET_WM_ICON
When processing the list of icons for a window to add them to
_NET_WM_ICON gdk_x11_surface_set_icon_list only adds as many
icon sizes as will fit within X protocol limits.

It achieves this by keeping a running total of the number of
bytes taken up by icons already processed and bails as soon
as it goes over the limit.

The problem is, one 512x512 icon is already over the limit,
and so no icons will get added at all if the first icon in
list is 512x512.

Indeed, the code seems to assume the list is sorted from smallest
icon to biggest icon.

This commit changes the caller to sort the list.
2019-08-01 16:48:58 -04:00
Jordi Mas
176ab784dc Update Catalan translation 2019-08-01 20:19:06 +02:00
Matthias Clasen
b576aef2b1 Revert "gl: Simplify glyph cache rendering"
This reverts commit 7a3eaad193.

The reason we want to keep using pango here
is that we get hex boxes and similar drawing
features that way.
2019-08-01 00:18:19 -04:00
Elias Aebi
a357995484 glsl: don't use switch statements 2019-07-31 18:48:54 +02:00
Matthias Clasen
5d10100fc0 Merge branch 'glyph-cache-fixes' into 'master'
gl: Glyph cache fixes

See merge request GNOME/gtk!1034
2019-07-31 12:26:16 +00:00
Matthias Clasen
6118dfba74 Add missing includes 2019-07-31 08:04:03 -04:00
Matthias Clasen
d276d2629a gl: Glyph cache fixes
Pass the full location to the glyph cache lookup,
and use the same rounding as cairo does. This makes
the output much closer to the cairo renderer.
2019-07-31 00:03:13 -04:00
Matthias Clasen
e3ee1df456 Add an image comparison utility
This comes in handy sometimes, and we
already have the image diff code.
2019-07-30 14:02:43 -04:00
Daniel Mustieles
2691e4e949 Updated Spanish translation 2019-07-30 09:39:55 +02:00
Timm Bäder
20d7b7f59b widget factory: add a tooltip to a button in a popover 2019-07-30 07:05:45 +02:00
Matthias Clasen
1fcd08d76a Merge branch 'issue2057' into 'master'
Bump wayland-protocols requirements

See merge request GNOME/gtk!1030
2019-07-29 12:17:52 +00:00
Olivier Fourdan
060a9f072c Bump wayland-protocols requirements
The `name` and `description` events were added to `xdg-output` protocol
in version 2 which is part of wayland-protocols 1.14.

In xdg-output-v1 version 3, the `xdg-output.done` event was deprecated
and the `xdg-output.description` event was made mutable, but that
doesn't change the actual events so we do not actually need to require
that version of xdg-output from wayland-protocols 1.18.

Update the wayland-protocols requirement to the bare minimum version,
which is 1.14.

https://gitlab.gnome.org/GNOME/gtk/issues/2057
2019-07-29 12:03:07 +02:00
Matthias Clasen
4a631787bd Merge branch 'subpixel-positioning' into 'master'
Subpixel positioning

See merge request GNOME/gtk!1024
2019-07-28 21:02:31 +00:00
Matthias Clasen
032473fef8 reftest: Exclude flaky tests
These depend on details of text rendering,
and started failing with newer pango.
2019-07-28 16:42:52 -04:00
Matthias Clasen
5dd8801ee5 gl: implement subpixel positioning
Pass the glyph position into the glyph caching functions,
not just the glyph index. This allows us to cache different
images for different subpixel positions.
2019-07-28 16:42:52 -04:00
Matthias Clasen
5c9643b6eb vulkan: implement subpixel positioning
Pass the glyph position into the glyph caching functions,
not just the glyph index. This allows us to cache different
images for different subpixel positions.
2019-07-28 16:42:52 -04:00
Matthias Clasen
4de670b0b4 Turn off metrics hinting
This will be necessary to see the effects of subpixel positioning.
2019-07-28 16:42:52 -04:00
Matthias Clasen
ade40a7a0c Merge branch 'wip/chergert/textview-caching' into 'master'
textlayout: introduce caching for GtkTextLineDisplay

See merge request GNOME/gtk!1025
2019-07-28 20:32:56 +00:00
Christian Hergert
9926e6ebde textlayout: introduce caching for GtkTextLineDisplay
This adds a GtkTextLineDisplayCache which can be used to cache a number
of GtkTextLineDisplay (and thus, PangoLayout) while displaying a view.

It uses a GSequence to track the position of the GtkTextLineDisplay
relative to each other, a MRU to cull the least recently used display,
and and a direct hashtable to lookup display by GtkTextLine.

We only cache lines that are to be displayed (!size_only). We may want to
either create a second collection of "size_only" lines to speed that up,
or determine that it is unnecessary (which is likely the case).
2019-07-28 10:34:15 -07:00
Christian Hergert
b930c5a8a2 textiter: add _gtk_text_iter_same_line()
This is a faster form to compare two text iter to see if they are on the
same line.
2019-07-28 10:34:15 -07:00
Matthias Clasen
7eb5dfd294 inspector: Show the pango backend 2019-07-28 11:39:16 -04:00
Matthias Clasen
8752564fea Remove new attributes from tests
Until we can depend on pango 1.44, these will
fail in ci. Partially reverts f1c7803f80
2019-07-28 11:00:29 -04:00
Matthias Clasen
988fac404a Add pango version checks
Seems the ci does not have pango 1.44 yet.
2019-07-28 10:50:14 -04:00
Matthias Clasen
7a3eaad193 gl: Simplify glyph cache rendering
We are currently using a weird mix of pango and cairo,
but there is no need for us to go through a pango
renderer here; we can just use cairo directly.
2019-07-28 09:54:17 -04:00
Matthias Clasen
3fccb16ca6 gsk: Move text-related test out of ci
These are too sensitive to rendering differences
between renderers to run reliably in ci, but we
still want to keep them around. In particular,
the big glyph tests are useful to exercise the
GL glyph cache.
2019-07-28 09:35:37 -04:00
Timm Bäder
2c38b71ca5 glyph cache: Upload large glyphs in lookup () directly
Instead of relying on a texture id of 0, which can happen for other
reasons, e.g. when the glyph is being scaled too small.

Fixes part of #2046
2019-07-28 12:00:15 +02:00
Timm Bäder
1c93bef0d5 glyph cache: check glyphs for scaled size
We can't rely on just the ink_rect, since that might be without the
scaled applied, which is what ends up on the texture.

Fixes #2046
2019-07-28 10:58:10 +02:00
Timm Bäder
eea76e8cce textview: Remove some unnecessary gtk_widget_show() calls
Widgets are visible by default.
2019-07-28 08:44:45 +02:00
Jordi Mas
3b604331ec Update Catalan translation 2019-07-28 01:05:25 +02:00
Matthias Clasen
92546cf9f7 Merge branch 'overview-recursive-dependancy' into 'master'
overview.xml: The GTK library does not depend on the GTK library

See merge request GNOME/gtk!1026
2019-07-27 21:46:52 +00:00
Piotr Drąg
3c9f9d598b Update Polish translation 2019-07-27 15:20:40 +02:00
Piotr Drąg
ed46053dc9 Update POTFILES.skip 2019-07-27 15:03:47 +02:00
Дилян Палаузов
a3db7437b3 overview.xml: The GTK library does not depend on the GTK library
The documentation stated:

GTK is a library.…  GTK depends on the following libraries:

GTK       The GTK library itself contains widgets, that is, GUI
          components such as GtkButton or GtkTextView.

There is no point in stating, that the GTK library
depends on the GTK library.
2019-07-27 11:59:45 +00:00
Timm Bäder
b2d639b6d9 window: Unroot with old display
Things might rely on the old display being set while unrooting.

Fixes #2052
2019-07-27 07:57:06 +02:00
Matthias Clasen
f1c7803f80 label: Parse new pango attributes
Support allow-breaks and show attributes.
These will be in pango 1.44
2019-07-27 00:02:08 -04:00
Matthias Clasen
c179fce6c7 Merge branch 'xdg-output-v3-gtk4' into 'master'
wayland: Add xdg-output v3 support

See merge request GNOME/gtk!1022
2019-07-26 17:13:39 +00:00
Olivier Fourdan
795899f9d5 wayland: Add xdg-output v3 support
xdg-output v3 marks xdg-output.done as deprecated and compositors are
not required to send that event anymore.

So if the xdg-output version is 3 or higher, simply set the initial
value `xdg_output_done` to TRUE so we don't wait/expect that event
from the compositor.

https://gitlab.gnome.org/GNOME/gtk/issues/2053
2019-07-26 17:32:17 +02:00
Matthias Clasen
88ab3a6942 Merge branch 'wip/no-move-surface' into 'master'
Remove surface moving APIs

See merge request GNOME/gtk!1016
2019-07-26 14:31:49 +00:00
Timm Bäder
58e8dd1c0d gl renderer: Fix dx/dy handling on hidpi
Fixes misplaced error squiggles in the node editor.
2019-07-26 16:27:39 +02:00
Timm Bäder
b8bbf7b63b gl renderer: Rework transform handling
Fix all the ref counting mishaps. Makes hidpi work again and without
memory leaks.
2019-07-26 15:35:06 +02:00
Kukuh Syafaat
05e28fb498 Update Indonesian translation 2019-07-26 11:31:46 +00:00
Kjartan Maraas
c6d9963d1a Update Norwegian Bokmål translation 2019-07-26 09:01:15 +00:00
Daniel Mustieles
2d3a902beb Updated Spanish translation 2019-07-26 09:18:25 +02:00
Matthias Clasen
8b1f3936b6 font rendering demo: Make boxes optional 2019-07-26 00:31:07 -04:00
Matthias Clasen
108ea50179 font rendering demo: Show unrounded extents
This makes more sense.
2019-07-25 23:35:09 -04:00
Matthias Clasen
df1892c052 font rendering: Show ink rect too 2019-07-25 22:06:34 -04:00
Matthias Clasen
0820a79bf5 Improve the font rendering demo
Show the pixel grid, extents, and baseline.
2019-07-25 19:07:12 -04:00
Matthias Clasen
4427bde8a7 Merge branch 'fontrendering-demo' into 'master'
Add a font rendering demo

See merge request GNOME/gtk!1019
2019-07-25 21:06:54 +00:00
Matthias Clasen
dec4db5943 Add a font rendering demo
This renders a magnified version of the text,
to make the effect of various font rendering options
more visible.

It also shows the phases of subpixel rendering,
if you have a recent pango and cairo.
2019-07-25 16:43:22 -04:00
Matthias Clasen
fd7f6ca7ad tests: improve error handling 2019-07-25 13:51:34 -04:00
Matthias Clasen
dea309144b gtk-demo: Fix a crash 2019-07-25 13:51:34 -04:00
Emmanuele Bassi
f1e4efebb7 Merge branch 'gtk-4-add-TCRYPT-options-to-ask-password-dialog' into 'master'
gtkmountoperation: Add TCRYPT options to the ask-password dialog

See merge request GNOME/gtk!263
2019-07-25 10:16:11 +00:00
Jonas Ådahl
0885eb0a7b gdk: Remove gdk_surface_move_resize() API
Windows/surface's aren't supposed to be explicitly moved by any external
part, so don't provide API for doing so. Usage throughout Gdk is
replaced by the corresponding backend variants.
2019-07-25 10:35:43 +02:00
Jonas Ådahl
fc68d1b1e6 gdk: Make backends implement move_to_rect()
The generic layer still does the heavy lifting, leaving the backends
more or less just act as thin wrappers, dealing a bit with global
coordinate transformations. The end goal is to remove explicit surface
moving from the generic gdk layer.
2019-07-25 10:24:50 +02:00
Jonas Ådahl
b329090e69 gdk: Remove gdk_surface_move()
Generic gdk code now uses the internal helper; backends use their own
private implementations when necessary.
2019-07-25 10:24:50 +02:00
Jonas Ådahl
6314ebd435 gdk/surface: Add toplevel_resize vfunc
To separate how toplevels and popups are configured, a first step is to
introduce a resize-only vfunc for backends to implement. It's meant to
only configure toplevel windows, i.e. popups. Currently it's used for
both types, but introducing the resize-only API is a first step.
2019-07-25 10:24:50 +02:00
Matthias Clasen
e89e182565 Merge branch 'avoid-redundant-attributes' into 'master'
text layout: Avoid redundant text attributes

See merge request GNOME/gtk!1015
2019-07-24 23:47:41 +00:00
Matthias Clasen
552fe0406c text layout: Avoid redundant text attributes
Don't insert text attributes if the font, or scale
or fallback did not actually change. This helps
Pango avoid excessive item breaks, which in turn
helps shaping to work across things like color
changes.

Related: https://gitlab.gnome.org/GNOME/pango/issues/28
2019-07-24 19:05:32 -04:00
Jonas Ådahl
b062dea1aa wayland: Cleanup surface configuration
Configuration should happen in response to the xdg_surface.configure
event, not in the events that preceeds it. Do this by making all
configured state pending until the committing "configure" event. Also
split up toplevel vs popup configuration in a more clear way.
2019-07-24 22:42:37 +02:00
Jonas Ådahl
9b561581d5 wayland: Rename gdk_wayland_surface_configure to *_resize
It only issues a resize; configuring should imply more state is
configured, e.g. maximized, etc.
2019-07-24 22:42:37 +02:00
Jonas Ådahl
7f6c31c041 tests: Remove obsolete props from popover2.ui 2019-07-24 22:42:37 +02:00
Matthias Clasen
717c55c9aa Merge branch 'gtkapp-opening-str' into 'master'
Use commas to differentiate between text and filename

See merge request GNOME/gtk!1013
2019-07-24 13:51:22 +00:00
Jordi Mas
7d1c6272be Use commas to differentiate between text and filename 2019-07-24 13:51:22 +00:00
Matthias Clasen
2f387c2a23 Merge branch 'missing-gobject-annotation' into 'master'
Add nullable annotation to combo_box_text_get_active_text

See merge request GNOME/gtk!1012
2019-07-24 13:50:04 +00:00
Timm Bäder
0d95c5dfe2 passwordentry: Normalize boolean value 2019-07-24 08:10:37 +02:00
Timm Bäder
f2a2908c59 passwordentry: Remove empty vfunc implementation 2019-07-24 08:10:26 +02:00
Timm Bäder
f4cb60dcca textlayout: Avoid querying CSS state if we don't have to
This is actually pretty slow, and we almost never render a selection.
2019-07-24 07:54:30 +02:00
Timm Bäder
b3d0629709 popover: Remove some unnecessary checks
gtk_popover_move_resize() already checks whether the popover has a
surface.
2019-07-24 07:54:30 +02:00
Matthias Clasen
30f55c4d07 Remove a redundant vfunc
PangoRenderer has a perfectly adequate default
implementation of draw_glyphs, no need to duplicate that.
2019-07-23 23:28:24 -04:00
Ryan Westlund
f00d964f4f Add nullable annotation to combo_box_text_get_active_text 2019-07-23 22:59:35 -04:00
Matthias Clasen
d2920c501d Merge branch 'blink-later' into 'master'
Blink later

See merge request GNOME/gtk!1011
2019-07-24 02:05:32 +00:00
Matthias Clasen
af528b08dc Merge branch 'error-nodes' into 'master'
Render error underlines as render nodes

See merge request GNOME/gtk!1009
2019-07-24 01:39:37 +00:00
Matthias Clasen
a628907891 textview: Defer cursor blinking on input
We were not calling the right cursor functions
in the commit handler.
2019-07-23 21:18:03 -04:00
Matthias Clasen
19ad4d67ef textview: Delay initial cursor blinking
These changes follow the same changes for
gtktext.c in the previous commit.
2019-07-23 21:17:05 -04:00
Matthias Clasen
a4e427b44a text: Delay initial cursor blinking
We used to have a solid cursor for 2/3 of the cycle,
now we start fading after 1/4th. To make up for it,
add half a cycle of delay.
2019-07-23 21:08:47 -04:00
Matthias Clasen
5b94e3c2f2 Merge branch 'wip/chergert/refcount-line-display' into 'master'
make GtkTextLineDisplay ref counted

See merge request GNOME/gtk!1010
2019-07-23 22:44:59 +00:00
Matthias Clasen
3278e9ab6c Render error underlines as render nodes
Use a sequence of transformed squares,
instead of a cairo node. The drawing is not
identical to the previous code, but reasonably
close.
2019-07-23 18:31:39 -04:00
Christian Hergert
02d8e95b73 textlayout: remove use of gtk_text_layout_free_line_display
Now that these are reference counted, we no longer need to use
the variant requiring access to the GtkTextLayout.
2019-07-23 14:59:40 -07:00
Christian Hergert
e0b9b51e9f textlayout: make GtkTextLineDisplay reference counted
This makes GtkTextLineDisplay use GRcBox instead of g_slice_*
directly. By using reference counting for this structure, we
can ensure that we hold an extra ref for one_display_cache as
well as caching additional GtkTextLineDisplay for the visible
range in the future.
2019-07-23 14:52:14 -07:00
Matthias Clasen
fb06b7fa94 text: Remove an outdated comment 2019-07-23 15:14:38 -04:00
Matthias Clasen
7b451678f5 fix the build 2019-07-23 14:26:32 -04:00
Piotr Drąg
3be9e819d6 Update POTFILES.in 2019-07-23 19:47:43 +02:00
Matthias Clasen
758c54eab8 text: Fix incomplete invalidation
When a style change affects the text, we need to
clear the cached content, in order to pick up the
new text style.
2019-07-23 10:41:52 -04:00
Matthias Clasen
c39cc15573 text view: Fix incomplete invalidation
Update the cached text style when a css change affects
content or background. This fixes text views drawing
black-on-dark when switching to the dark theme.
2019-07-23 10:41:43 -04:00
Jordi Mas
8999bb0b78 Update Catalan translation 2019-07-22 11:06:27 +02:00
Matthias Clasen
7a81b7c7be Merge branch 'wip/chergert/fix-textlayout-bounds' into 'master'
textlayout: fix bounds for clipping

See merge request GNOME/gtk!1006
2019-07-22 01:53:17 +00:00
Christian Hergert
e475d4bdc5 textlayout: fix bounds for clipping
This should match gtk_snapshot_append_layout(), which means that we expect the
bounds to be rooted at 0, 0.
2019-07-21 18:21:04 -07:00
Matthias Clasen
980a6a20b1 Merge branch 'wip/textview' into 'master'
textview: port GtkTextView to GskPangoRenderer

See merge request GNOME/gtk!1005
2019-07-21 23:10:41 +00:00
Matthias Clasen
064ad42432 text view: Smooth cursor blinking
Fade the text cursor in and out, instead
of abruptly turning it on and off.
2019-07-21 16:03:49 -07:00
Christian Hergert
4ff9163c47 textview: port GtkTextView to GskPangoRenderer
This removes the use of GtkTextDisplay (a PangoRenderer) to use
the GskPangoRender which generates render nodes. Part of this means
improving the GskPangoRenderer to support the necessary features for
displaying a GtkTextView.

Primarily, this is a merging of GtkTextDisplay features into
GskPangoRender. Additionally, GtkTextDisplay was removed to allow for
gtk_text_layout_snapshot() to be implemented elsewhere.
2019-07-21 16:03:45 -07:00
Matthias Clasen
45ebe47d94 textview: Stop exporting private apis
These headers are no longer 'semi-public, but private
and uninstalled, so exporting these functions does
not do any good.
2019-07-21 13:26:40 -07:00
Matthias Clasen
2803bd93ce gsk: Fix a crash in gsk_render_node_diff
The only thing worse than freeing the same
cairo region twice is freeing it three times.
2019-07-21 13:18:58 -07:00
Matthias Clasen
51161fb0d6 text: Smooth cursor blinking
Fade the text cursor in and out, instead
of abruptly turning it on and off.
2019-07-21 11:35:13 -07:00
Matthias Clasen
63fd97749c Adwaita: Fix entry block cursors 2019-07-21 11:35:04 -07:00
Asier Sarasua Garmendia
f2d736d2cc Update Basque translation 2019-07-21 18:02:07 +00:00
Serdar Sağlam
9b9a656e54 Update Turkish translation 2019-07-21 14:15:15 +00:00
Timm Bäder
8f734b01b2 window: Plug a GList leak
We need to free the GList manually when using g_list_remove_link().
2019-07-21 12:45:10 +02:00
Timm Bäder
69250371b0 gtk.supp: Add glXQueryServerString exceptions 2019-07-21 12:45:10 +02:00
Timm Bäder
731613d70b gl renderer: Remove leftover modelview matrix
We use a GskTransform there nowadays.
2019-07-21 12:45:10 +02:00
Timm Bäder
5f21c45f75 Revert "gl renderer: ops_set_modelview is (transfer full)"
This reverts commit e904c49e8a.

This breaks HiDPI setups, i.e. setups where the call to
ops_set_modelview does not end up with a NULL transform.
2019-07-21 12:45:10 +02:00
Timm Bäder
8beea4d958 window: Merge some functions into their only callers
So it's clear we only add or remove the pointerfocus-es in
_update_pointer_focus.
2019-07-21 11:06:24 +02:00
Timm Bäder
1583200e24 cellrenderertext: Remove some unnecessary NULL checks 2019-07-21 10:26:00 +02:00
Timm Bäder
03fa8ed259 cellrenderertext: Don't unnecessarily ref a layout
We never pass a NULL layout to get_size().
2019-07-21 10:22:05 +02:00
Timm Bäder
0bd939624e textlayout: Remove some outdated comments
These two members have been commented out for 19 years.
2019-07-21 10:02:54 +02:00
Timm Bäder
b658a1a8e3 entry: Measure icons again
This was previously removed because it changes the minimum and natural
size of the entry when the icons are shown/hidden at runtime. Just not
measuring them does not work however, so reintroduce this.
2019-07-21 09:58:08 +02:00
Timm Bäder
7eae9d115c placesview: Make "Other Locations" search case-insensitive
It's just weird to search for "c" and not find the list item labelled
"Computer".
2019-07-21 09:51:54 +02:00
Timm Bäder
2ca56d4c4c linedisplay: Save paragraph bg color inline
No need to allocate this separately.
2019-07-21 09:47:09 +02:00
Timm Bäder
f6d7967e96 gtk.supp: Add a pixman_image_composite32 exception 2019-07-21 09:13:24 +02:00
Timm Bäder
9bddc0ff85 gtk.supp: add a FcDefaultSubstitute exception 2019-07-21 09:07:27 +02:00
Timm Bäder
6e47ebe030 rendernodeparser: Fix a memory leak when parsing glyphs 2019-07-21 09:06:50 +02:00
Timm Bäder
9728dabf12 rendernodeparser: Fix a memory leak when parsing textures 2019-07-21 09:06:29 +02:00
Timm Bäder
e904c49e8a gl renderer: ops_set_modelview is (transfer full)
regarding the passed modelview matrix
2019-07-21 09:06:10 +02:00
Timm Bäder
27ddd39d69 gl renderer: Pull out code from a loop
Does not not actually depend on anything done inside the loop.
2019-07-21 08:39:25 +02:00
Goran Vidović
86e907b088 Update Croatian translation 2019-07-19 21:29:56 +00:00
Goran Vidović
8b46538af9 Update Croatian translation 2019-07-19 21:20:13 +00:00
Timm Bäder
5910a28aa5 gl renderer: Replace a redundant function call
We're already getting the radius from the node above.
2019-07-19 18:14:50 +02:00
Timm Bäder
3935027880 filechooserwidget: Fold function into only caller 2019-07-19 18:14:50 +02:00
Timm Bäder
8665828d7f filechooserwidget: Don't emit default-size-changed() in unroot()
It doesn't make much sense to assume the default size has changed just
because the widget has been unrooted.
2019-07-19 18:14:50 +02:00
Timm Bäder
a8b559e99f filechooser: Remove SETTINGS_KEY_WINDOW_POSITION
Now unused.
2019-07-19 18:14:50 +02:00
Timm Bäder
5674a3db46 filechooserwidget: Don't look at saved window position
We don't save it anymore so no need to look at it here.
2019-07-19 18:14:49 +02:00
Timm Bäder
dd3acc9014 filechooserdialog: Stop using gtk_window_get_position() 2019-07-19 18:14:49 +02:00
Timm Bäder
a9364bc053 Revert "file chooser: Stop using gtk_window_get_position"
This reverts commit 2ed533c3e1.

This also made the filechooser dialog not save the window size anymore,
which does not depend on the gtk_window_get_position() removal.
2019-07-19 18:14:49 +02:00
Timm Bäder
59313e1459 gtkfilechooserwidget: Temporarily disable revealer transitions...
... when going between recent and browse. It just looks weird to have
this transition while the treeview model is just cleared/repopulated
without any transition.
2019-07-19 18:14:49 +02:00
Timm Bäder
3e54d374de placessidebar: Remove sidebar border again 2019-07-19 18:14:49 +02:00
Christoph Reiter
9856218073 Merge branch 'tests-no-box-packing' into 'master'
testsuite: Remove dangling references to box-packing tests

See merge request GNOME/gtk!997
2019-07-18 19:32:19 +00:00
segfault
97cdf87350 gtkmountoperation: Add TCRYPT options to the ask-password dialog 2019-07-18 20:06:20 +02:00
Emmanuele Bassi
d8f91e7df9 Merge branch 'pc-libs-private' into 'master'
gtk4.pc: Move third-party libraries from Libs to Libs.private

See merge request GNOME/gtk!998
2019-07-18 10:31:19 +00:00
Emmanuele Bassi
91d4e2b3e3 Merge branch 'gtk-4-support-tcrypt-with-proxy-handler' into 'master'
gtkmountoperation: Support TCRYPT options when using proxy handler

See merge request GNOME/gtk!245
2019-07-18 10:11:12 +00:00
segfault
e5cccbf5a0 gtkmountoperation: Support TCRYPT options when using proxy handler
GMountOperation now supports options to unlock TCRYPT volumes. This
patch sets these options if they are returned by AskPassword() of a
GtkMountOperationHandlerProxy.
2019-07-18 11:41:45 +02:00
Simon McVittie
5cfe9ab603 testsuite: Remove dangling references to box-packing tests
These were removed in commit c47abb5f, before 3.96.0.

Signed-off-by: Simon McVittie <smcv@debian.org>
2019-07-18 09:26:07 +01:00
Simon McVittie
01a6bbdc73 gtk4.pc: Move third-party libraries from Libs to Libs.private
This avoids "overlinking". These libraries are an implementation detail
of particular backends, so they only need to appear on library consumers'
linker command-lines if the dependency cannot be picked up from the
shared library automatically (when linking statically, or when building
on a deficient OS that doesn't support transitive dependencies between
shared libraries, in which case pkg-config should be built with
--enable-indirect-deps).

Signed-off-by: Simon McVittie <smcv@debian.org>
2019-07-18 09:24:41 +01:00
Timm Bäder
24a4063645 scrollbar: Use a box layout
Makes a lot more sense than the intermediate box just for its layout.
2019-07-15 07:52:42 +02:00
Timm Bäder
4f11bbc59b text: Don't leak emoji chooser 2019-07-15 06:56:19 +02:00
Timm Bäder
9ceb41f9a4 menu: Fix an uninitialized value
If the menu does not have any children, we'd otherwise end up calling
g_object_ref() on an uninitialized value.
2019-07-15 06:43:25 +02:00
Timm Bäder
831309eed2 progressbar: Use box layout
Instead of the custom layouting we did before.
2019-07-15 06:38:51 +02:00
Timm Bäder
4bb4a98493 text: Move some locals into the closest scope 2019-07-15 05:38:25 +02:00
Timm Bäder
70b0f712ad text: Remove some useless casts 2019-07-15 05:19:02 +02:00
Timm Bäder
c6e9372ba3 text: Move some locals into the closest scope 2019-07-15 05:17:46 +02:00
Jordi Mas
13b055ab2d Update Catalan translation 2019-07-14 11:25:12 +02:00
Timm Bäder
38f4a7708e Remove some dead assignments 2019-07-14 10:08:04 +02:00
Timm Bäder
6abcd8d013 Adwaita: Add fontbutton spacing back 2019-07-14 10:08:04 +02:00
Timm Bäder
37906a2200 adwaita: Remove a dead rule
GtkFileChooserButtons are called "filechooserbutton" these days, not
button.file
2019-07-14 10:08:04 +02:00
Timm Bäder
b9b5072668 gl renderer: Fix opacity nodes with overlapping child nodes 2019-07-14 10:08:04 +02:00
Aurimas Černius
459edfa77b Updated Lithuanian translation 2019-07-13 18:28:21 +03:00
Timm Bäder
92a79d3f96 popover: Fix a broken cast
The widget passed here is priv->relative_to, not the popover.
2019-07-13 17:06:22 +02:00
Timm Bäder
984dff54ab rendernodeparser: fix typo 2019-07-13 11:12:47 +02:00
Timm Bäder
1866aa93e3 fishbowl: Plug a small leak 2019-07-13 10:10:17 +02:00
Timm Bäder
2884691740 picture: Unref previous paintable
We were leaking all of them.
2019-07-13 09:38:28 +02:00
Timm Bäder
b8549a142e suppression file: Add glReadPixels mesa exception 2019-07-13 09:38:14 +02:00
Timm Bäder
0f3ca349e7 node editor: Manually unrealize all created renderers
This has not been a problem before since we were leaking them.
2019-07-13 09:37:47 +02:00
Timm Bäder
a13d6bbbdf Merge branch 'fix-issue-2014-gtk4' into 'master'
Fix a string leak in gtkemojicompletion.c [gtk4]

Closes #2014

See merge request GNOME/gtk!993
2019-07-12 09:59:38 +00:00
Luca Bacci
d15dc6f90b Fix a string leak
Fixes #2014
2019-07-12 08:43:44 +00:00
Timm Bäder
58e6c277b0 fpsoverlay: Fix fps overlay position 2019-07-10 18:34:16 +02:00
Matthias Clasen
1d29d44ddb Merge branch 'wip/baedert/accelmap' into 'master'
AccelMap: Sort accels before iterating over them in foreach()

See merge request GNOME/gtk!980
2019-07-09 19:39:58 +00:00
Matthias Clasen
bda3c6c084 Merge branch 'wip/baedert/for-master' into 'master'
Improve the valgrind experience

See merge request GNOME/gtk!984
2019-07-09 19:39:13 +00:00
Kukuh Syafaat
159913be2f Update Indonesian translation 2019-07-09 07:56:21 +00:00
Asier Sarasua Garmendia
b05d1676d3 Update Basque translation 2019-07-08 20:19:10 +00:00
Asier Sarasua Garmendia
0b21ed0c7a Update Basque translation 2019-07-08 20:14:08 +00:00
Asier Sarasua Garmendia
564a92830b Update Basque translation 2019-07-08 19:18:08 +00:00
Chun-wei Fan
a20fd5e14e demos/constraint-editor: Fix linking on MSVC builds
We must apply the /entry:mainCRTStartup linker flag in order to link GTK
apps in pure GUI form.  This follows what is done in demos/gtk-demo,
etc.
2019-07-08 18:37:27 +08:00
Timm Bäder
138986f064 Merge branch 'ui-enum-values' into 'master'
Change the few examples that use a full GTK_ enum value in .ui files.

See merge request GNOME/gtk!987
2019-07-08 07:14:48 +00:00
Timm Bäder
f286c99338 Merge branch 'gltexsubimage2d' into 'master'
use glTexSubImage2D instead of glTextureSubImage2D

Closes #2005

See merge request GNOME/gtk!986
2019-07-08 07:14:13 +00:00
Timm Bäder
ea48d1de5e Merge branch 'glsl-float-literals' into 'master'
glsl: use float literals

See merge request GNOME/gtk!985
2019-07-08 07:10:41 +00:00
Robert Ancell
dbd2a81501 Change the few examples that use a full GTK_ enum value in .ui files.
Lowercase versions work just as well and are much more readable.
2019-07-08 15:52:28 +12:00
Piotr Drąg
be6ec8f50b Update Polish translation 2019-07-07 13:22:10 +02:00
Timm Bäder
264d4bada6 widget: Remove queue_resize_no_redraw
We always invalidate the widget in size_allocate() anyway.
2019-07-07 07:43:08 +02:00
Timm Bäder
633172fd66 widget: Make queue_compute_expand() private
Nobody needs to call this anymore.
2019-07-07 07:36:29 +02:00
Timm Bäder
042f7d117f compare-render: Don't unref an invalid GFile
We already unref it when the g_file_make_directory_with_parents fails.
2019-07-07 07:24:00 +02:00
Timm Bäder
b062594ae6 gl renderer: Properly clean up program state transforms 2019-07-07 07:24:00 +02:00
Timm Bäder
95f30fee87 iconhelper: Try to avoid some save/restore calls
GtkImage already does something similar so we often end up with 0/0
here. Avoid the save()/restore() calls in GtkSnapshot in that case.
2019-07-07 07:24:00 +02:00
Timm Bäder
dbc49e7742 transform: Fix identity transform fast paths
Returning an extra ref will cause leaks later.
2019-07-07 07:24:00 +02:00
Timm Bäder
449c96ffb3 widget: Unref previous transform 2019-07-07 07:24:00 +02:00
Timm Bäder
1459ca2c26 widget factory: Plug a memory leak 2019-07-07 07:24:00 +02:00
Timm Bäder
4123c85021 actionmuxer: Plug a memory leak 2019-07-07 07:24:00 +02:00
Timm Bäder
d1c37c41d9 Add a gtk valgrind suppression file
Not ideal but otherwise I get 30k line output from valgrind when just
running the widget factory. It's mostly mesa but still.
2019-07-07 07:23:57 +02:00
Elias Aebi
ea6d3f589f use glTexSubImage2D instead of glTextureSubImage2D 2019-07-06 16:23:21 +02:00
Elias Aebi
1e6120e776 glsl: use float literals 2019-07-06 14:42:08 +02:00
Timm Bäder
a77f8e886b cssprovider: Fix a memory leak in load_internal
We create a new GBytes but never unref it.
2019-07-06 09:50:07 +02:00
Benjamin Otte
96b782c026 x11: Make sure stream stays alive long enough
When unreffing the stream from a different thread, the close function
will schedule its cleanup asynchornously in the main thread.
We need to make sure the stream object stays alive for as long as
that hasn't happened, so ref() it.

Fixes #2003
2019-07-05 21:17:00 +02:00
Timm Bäder
6455a54f6c Merge branch 'header-custom-title-valign' into 'master'
headerbar: Don't change the custom title's valign

See merge request GNOME/gtk!981
2019-07-04 12:45:13 +00:00
Adrien Plazas
3bae6fa1c7 headerbar: Don't change the custom title's valign
This allows custom titles to use the vertical alignment of their choice
without having to set it manually after it has been added to the header
bar, hence allowing them to define their preferred alignment from a UI
template.

This is useful for widgets like the view switcher which requires filling
the header bar's whole height.
2019-07-04 13:03:37 +02:00
Timm Bäder
68f19a8e6a accelmap: Sort accels before interating over them in foreach() 2019-07-04 08:35:42 +02:00
Timm Bäder
12ebbd1b24 accelmap: Avoid a confusing goto 2019-07-04 08:35:34 +02:00
Emmanuele Bassi
9b7bda6137 ci: Comment job, not just the stage
GitLab doesn't like it when we keep a job but disable the stage.
2019-07-03 17:57:27 +01:00
Emmanuele Bassi
1b4ed58331 ci: Disable deploy jobs
The version of gtk-doc in our CI image is not new enough to cope with
the fact that GTK lost container properties.
2019-07-03 17:54:32 +01:00
Benjamin Otte
b2868d7218 Merge branch 'wip/frame-clock-consumers' into 'master'
Frame clock consumers

See merge request GNOME/gtk!971
2019-07-03 16:21:32 +00:00
Emmanuele Bassi
bdc8f9dccf Merge branch 'layout-manager-ref' into 'master'
widget: Don't lose a layout manager ref

See merge request GNOME/gtk!977
2019-07-03 13:25:44 +00:00
Matthias Clasen
9768f35931 widget: Don't lose a layout manager ref
gtk_widget_set_layout_manager is transfer-full,
so we must give it a new reference from set_property
to implement object property semantics properly.
2019-07-03 09:18:41 -04:00
Daniel Mustieles
19a4ee031d Updated Spanish translation 2019-07-03 11:45:12 +02:00
Jonas Ådahl
a7ee1b4e85 gdksurface: Make all surfaces listen to the frame clock signals
Instead of the toplevel driving popups, have the popups listen to the
frame clock themselves. Otherwise, if the toplevel for some reason isn't
drawn by the compositor and stops drawing new frames, popups wouldn't
get painted either.
2019-07-03 11:42:28 +02:00
Jonas Ådahl
5db079b052 gdk/frameclock: Make surfaces inhibit freeze
To make a frame clock tick as long as any of the associated surfaces
expect to receive ticks, make the surfaces inhibit freezing the clock,
instead of directly tell the frame clock to freeze itself.

This makes it so that as long as any surface using a certain frame clock
is not frozen (e.g. just received a frame event from the display
server), the frame clock will not be frozen.

With this, the frame clock is initiated as frozen, and won't be thawed
until any surface inhibits freeze. It will be frozen again, when every
surface has that previously inhibited freeze uninhibited freeze.
2019-07-03 11:42:28 +02:00
Jonas Ådahl
a2ff6af4b3 tests: Add back testpopupat
It's still useful for testing menus. Fixed the .ui file by removing a
property that no longer exists.

This effectively reverts commit
84d2150077.
2019-07-03 11:42:28 +02:00
Jonas Ådahl
f66e764855 menu: Remove unused variable 2019-07-03 11:42:28 +02:00
Mohammed Sadiq
a8c23d06ac constraint: Fix property name typo in doc 2019-07-03 09:31:39 +05:30
Piotr Drąg
36b4cd4bfc Update POTFILES.in and POTFILES.skip 2019-07-02 19:02:36 +02:00
Matej Urbančič
46c59e3c3d Updated Slovenian translation 2019-07-02 18:51:55 +02:00
Matthias Clasen
b5aee936a9 Merge branch 'constraint-list-model' into 'master'
Constraint list models

See merge request GNOME/gtk!975
2019-07-02 14:18:42 +00:00
Matthias Clasen
aa8687316f constraint editor: Implement loading
Allow to reread the ui builder files we write out.
Just barely.
2019-07-02 10:03:48 -04:00
Matthias Clasen
5a3cf5a194 constraints editor: Stop naming constraints
We don't have a field for the name in ui files,
so stop naming constraints.
2019-07-02 10:03:48 -04:00
Matthias Clasen
c5e1b00994 constraint editor: Implement saving
Save to a ui file.
2019-07-02 10:03:48 -04:00
Matthias Clasen
377f0c1a0a constraint editor: Use name properties 2019-07-02 10:03:48 -04:00
Matthias Clasen
a442e6e8de constraint editor: Use the list models
Instead of handrolling our own list models,
use the ones provided by GtkConstraintLayout.
2019-07-02 10:03:48 -04:00
Matthias Clasen
274c47e5ba constraint layout: Provide list models
Provide list models for the constraints and guides,
so we can show them in the inspector, and use them
in e.g. the constraints editor.
2019-07-02 10:03:48 -04:00
Matthias Clasen
b2f15a622d Merge branch 'wip/ebassi/constraint-layout' into 'master'
Add constraint-based layout manager

Closes #1090

See merge request GNOME/gtk!973
2019-07-02 14:01:01 +00:00
Emmanuele Bassi
04aaf02881 docs: Add more private headers to the list
The various GtkConstraint private API should not be scanned for
documentation.
2019-07-02 09:48:17 +01:00
Emmanuele Bassi
d5f8e1bf29 docs: Fix typo in function name 2019-07-02 09:44:48 +01:00
Daniel Boles
33bd7051f2 widget-factory: Use correct StyleProvider priority
We are an application, not a user.

cherry-pick of !974
2019-07-02 09:09:47 +01:00
Matthias Clasen
61345b3216 Merge branch 'option-names' into 'master'
meson: Rename documentation option to gtk_doc

See merge request GNOME/gtk!972
2019-07-02 01:28:43 +00:00
Benjamin Otte
129691f3a6 flattenlistmodeL: Compute items-changed position properly
The code previously forgot to include the left child of the model's
node. Which of course only happened if that child wasn't NULL, which is
a common case.

Found and test provided by Matthias Clasen.
2019-07-02 02:53:00 +02:00
Matthias Clasen
4eaf860e86 meson: Rename documentation option to gtk_doc
This name is what most of the stack is using.
Lets follow along, even though it is (imo)
uglier.
2019-07-01 20:16:37 -04:00
Christoph Reiter
72814c54a8 meson: cups: use cups-config for looking up cups
We were looking for the cups headers and the cups lib in the default locations
which for example breaks with OpenBSD where the cups headers are under /usr/local/include/

Instead just use the "cups" dependency type from meson which internally uses cups-config.

See #1967

Ported to master from !963
2019-07-01 21:52:06 +02:00
Christoph Reiter
4d4e02c9d0 build/cups: remove checks for httpGetAuthString and http_t.authstring
httpGetAuthString() was added with cups 1.3 and we depend on a newer version
now. The direct field access was a fallback in case httpGetAuthString()
was missing, so this can also be dropped.

Ported to master from !938
2019-07-01 21:34:44 +02:00
Emmanuele Bassi
8ab609e4e7 Add custom parser for guides defined in GtkBuilder UI files
Like we describe constraints, we can also define guides.
2019-07-01 19:22:48 +01:00
Emmanuele Bassi
6bc156c237 Implement GtkBuildable for GtkConstraintLayout
Using GtkBuildable we can provide a custom parser for reading
constraints defined in a GtkBuilder UI file.
2019-07-01 18:03:20 +01:00
Emmanuele Bassi
b435dc4366 Use the right GValue getter for GtkConstraintGuide:strength
The property is defined as an enum.

This fixes the defaultvalue and notify tests.
2019-07-01 18:02:19 +01:00
Emmanuele Bassi
4dd1de4129 Use explicit values for constraint strength
Instead of playing games with mapping negative symbolic values to
positive ones, let's use the appropriate constants everywhere. This
allows us to use:

        GTK_CONSTRAINT_STRENGTH_WEAK * 2

Or

        GTK_CONSTRAINT_STRENGTH_STRONG + 1

In code using the public API.

We also store the strength values as integers, so we can compare them
properly, and only turn them into doubles when they are inserted into
the solver, just like every other variable.
2019-07-01 12:39:24 +01:00
Matthias Clasen
48e6cd4255 constraint editor: Allow dragging children
We add a weak constraint for the position
and update it as the widget is dragged.
2019-07-01 04:24:26 +00:00
Matthias Clasen
658397fad0 Documentation fixes
Make sure all types show up in the docs,
and misc other improvements.
2019-07-01 03:17:58 +00:00
Matthias Clasen
670fc5bb94 constraint editor: Enable max size for guide
Also, use the apis we have now, and make the
spin buttons display 'unset' values as such.
2019-07-01 02:23:39 +00:00
Matthias Clasen
b224df8109 constraint layout: go back to keeping constraints
We want to minimize changes to the solver, so
keep the size constraints around and only update
them when the size changes.
2019-07-01 01:54:57 +00:00
Matthias Clasen
c88e7c180d constraint layout: Use stronger force for min size
We want our edit constraint to be strong enough to
overpower nat. size constraint, therefore use STRONG * 2.
2019-07-01 01:49:20 +00:00
Emmanuele Bassi
2aabd64f1a Fix warnings from the introspection scanner
The name of the arguments of the functions must match the name of the
arguments in the documentation stanza.
2019-07-01 01:13:00 +01:00
Emmanuele Bassi
7990b24287 Add gtkconstraintguide.h to the public headers
It needs to be introspected and installed.
2019-07-01 01:12:25 +01:00
Emmanuele Bassi
c76c1a46e4 Remove specialised API from GtkConstraint
Thet widget-based API for constraint target and source properties is
unused, and not really necessary.
2019-07-01 01:05:04 +01:00
Emmanuele Bassi
68fed63eac Add missing documentation for GtkConstraint 2019-07-01 01:02:56 +01:00
Emmanuele Bassi
46403bac12 docs: Add GtkConstraint and friends to the API reference 2019-07-01 00:49:20 +01:00
Emmanuele Bassi
74c626f835 Document GtkConstraintGuide 2019-07-01 00:48:59 +01:00
Emmanuele Bassi
d45a662679 Move the VFL error domain to a public header
Since the public API will use it to fill out GErrors, it needs to be
publicly available.
2019-07-01 00:48:48 +01:00
Matthias Clasen
f6019f1a16 Merge branch 'gbsneto/fix-popover-dark-theme' into 'master'
Fix GtkPopoverMenu in dark theme

See merge request GNOME/gtk!970
2019-06-30 23:17:40 +00:00
Matthias Clasen
514de0b91a Add a constraint editor demo
This is an initial cut at providing a tool
for interactive exploration of constraints.
2019-07-01 00:10:11 +01:00
Emmanuele Bassi
9a463056d0 constraint layout: Notice when guides change
We need to queue a resize here.
2019-07-01 00:10:11 +01:00
Matthias Clasen
035baa092c Mark the layout as changed
We should mark the layout as changed when
constraints are added or removed.
2019-07-01 00:10:11 +01:00
Matthias Clasen
499738c903 constraint guide: Avoid redundant constraints
There is no point in creating a stay for nat
size when min == max. And no point in a constraint
for <= G_MAXINT either.
2019-07-01 00:10:11 +01:00
Matthias Clasen
f2d7433bf6 constraint guide: Fix initial property values
This was overlooked when the max-width/max-height/
strength properties were added.
2019-07-01 00:10:11 +01:00
Matthias Clasen
405121bccc constraint solver: Use GTK_NOTE
Allow using GTK_DEBUG=constraints to get debug
output from the constraints solver.
2019-07-01 00:10:11 +01:00
Matthias Clasen
cb96b34315 solver: Add private statistics api
No point in keeping these counters without
a way to show them.
2019-07-01 00:10:11 +01:00
Matthias Clasen
9edf6fb6cb constraint layout: Dont reset constraints in allocate
If trust our allocation algorithm, this can never
trigger (and in fact, it never does).
2019-07-01 00:10:11 +01:00
Matthias Clasen
e3c4fb67ca constraints: Add some internal apis
Checking if a set is empty or a singleton can
be done more efficiently than determining its size.
2019-07-01 00:10:11 +01:00
Matthias Clasen
a9dfca04e4 constraint guide: Make strength tweakable
The strength for the natural width can be used
as a tie-breaker to make instable systems behave
in a more predictable way. This can be seen
in the simple constraints demo in gtk-demo.
2019-07-01 00:10:11 +01:00
Matthias Clasen
71b52f485e constraints demo: Update comments 2019-07-01 00:10:11 +01:00
Matthias Clasen
f62fc4e2f2 constraint layout: freeze/thaw on mass ops
In measure and allocate we are potentially
changing quite a few constraints. Don't
optimize at every step.
2019-07-01 00:10:11 +01:00
Matthias Clasen
511e2b435e constraints: Use better data structures
Use a GSequence for GtkVariableSet, to avoid
quadratic behavior.
2019-07-01 00:10:11 +01:00
Matthias Clasen
3f36340921 constraint layout: Measure min/nat size separately
Only constraint the opposite direction if we
actually have a for_size, and measure natural
size after removing the edit constraints. With
these changes, the test that compares constraint
layout to grid layout passes.
2019-07-01 00:10:11 +01:00
Matthias Clasen
b1f0f4478e constraint layout: Use stays for natural size
It makes more sense to treat the natural size
of both children and guides as stays, since
we want to meet these values as closely as we
can, under the circumstances.
2019-07-01 00:10:11 +01:00
Matthias Clasen
90f8dcc5e1 constraint layout: Add debug output for guides
Print out the allocation we end up giving to
guides. This helps in making sense of the
allocations of the child widgets that these
guides relate to.
2019-07-01 00:10:11 +01:00
Matthias Clasen
5a019bfccd constraints demo: Give space a name
Lets call it 'space'.
2019-07-01 00:10:11 +01:00
Matthias Clasen
b39a5fe5dc constraint guide: Add a name property
We need to be able to print meaningful debug messages
regarding these objects, and eventually present them
in the inspector too.
2019-07-01 00:10:11 +01:00
Matthias Clasen
c7ef8411bd constraint guide: Shorten names
Now that this is its own source file,
no need for these prefixes anymore.
2019-07-01 00:10:11 +01:00
Matthias Clasen
dab8a8b5c5 constraint layout: Measure more correctly
Set up all constraints for minimum + natural
width + height when measuring, regardless
of the orientation we're measuring. Anything
else will lead to incorrect answers when
there are constraints that cut across
dimensions.
2019-07-01 00:10:11 +01:00
Matthias Clasen
8b9c5e3a04 solver: Fix a copy/paste error 2019-07-01 00:10:11 +01:00
Matthias Clasen
3d3a672deb constraint solver: Fix repeat suggestions
We were not storing the previous value, causing
the first two suggestions to work, but not later
ones.

Fixes the test added in the previous commit.
2019-07-01 00:10:11 +01:00
Matthias Clasen
2f97134a08 Amend a constraint solver test
Make the 'repeat edit' test make more than to
suggestions in a single edit phase. It turns out
that this does not work, whereas just doing
two in a row does.
2019-07-01 00:10:11 +01:00
Matthias Clasen
47237d32eb demo: Use constraint guide api
Use proper api to create and set up
the guide, and also try max-width.
2019-07-01 00:10:11 +01:00
Matthias Clasen
139a59cae3 Flesh out GtkConstraintGuide
This commit moves GtkConstraintGuide into its own
source files to avoid gtkconstraintlayout.c turning
too messy, adds max size properties and implements
getters and setters.
2019-07-01 00:10:11 +01:00
Matthias Clasen
60fb9092fe Drop an indirection
This struct is not really useful for just
a single hash table, and it gets in the way
of moving the guide code to its own file.
2019-07-01 00:10:11 +01:00
Matthias Clasen
61b4febbaf Detach guides on unroot
We don't want to leave constraints behind.
2019-07-01 00:10:11 +01:00
Matthias Clasen
4f4ba8c4f6 Simplify the guide implementation
Store the values and constraints in
arrays, to facilitate treating them
uniformly.
2019-07-01 00:10:11 +01:00
Emmanuele Bassi
651adbfb39 Return the list of constraints added via VFL description
Otherwise it's impossible to remove them.
2019-07-01 00:10:11 +01:00
Emmanuele Bassi
3204347bb0 Add method to remove all constraints from a layout 2019-07-01 00:10:11 +01:00
Georges Basile Stavracas Neto
b929846cc1 Adwaita: Also apply $color_menu to popover arrows
So that popovers and arrows are always in agreement of
the background color.
2019-06-30 19:51:51 -03:00
Georges Basile Stavracas Neto
fe65da05be Adwaita: Use $menu_color background in popover.menu
GtkPopoverMenus should mimic menus. Commit d936967b7a introduced
some CSS related to menu popovers, however, it hardcodes 'white'
as the background color. That is problematic for the dark theme.

Use '$menu_color' instead of 'white', since $menu_color both
guarantees menu popovers and menus match, and already handles
different colors for dark and light theme variants.
2019-06-30 19:47:32 -03:00
Emmanuele Bassi
06c825df90 Add a C convenience function for VFL constraints
The dictionary-based function is convenient for language bindings, but C
developers will feel more at home with a variadic arguments list.
2019-06-30 23:42:45 +01:00
Emmanuele Bassi
46430ea85b Add Constraints/VFL demo
Shows how to describe constraints using VFL instead of constructing
objects manually.
2019-06-30 23:42:45 +01:00
Emmanuele Bassi
859c95b435 Allow adding constraints described through VFL 2019-06-30 23:42:45 +01:00
Emmanuele Bassi
5ea8167802 Add VFL parser for constraints
Constraints can be expressed with a compact syntax, called VFL (visual
format language).
2019-06-30 23:42:45 +01:00
Emmanuele Bassi
92d3d55164 Remove GtkConstraintVariable.set_prefix()
The prefix and name are set at construction time.
2019-06-30 23:42:45 +01:00
Matthias Clasen
ba2125d8e1 Add an interactive constraints demo 2019-06-30 23:42:44 +01:00
Matthias Clasen
7c96326c18 Make the constraints demo more interesting
Add a max size to the buttons, to force the
space to open up.
2019-06-30 23:42:44 +01:00
Matthias Clasen
38d353dc1a Add GtkConstraintGuide
This is meant to be a flexible space.
2019-06-30 23:42:44 +01:00
Emmanuele Bassi
7ae04ba36b Use generic pointers for constraint targets
Since GtkWidget implements GtkConstraintTarget, we can omit the explicit
cast, and validate the type at run time.
2019-06-30 23:42:44 +01:00
Matthias Clasen
39c284c490 Redefine constraints with GtkConstraintTarget
This is in preparation for allowing non-widgets
to act as constraint targets.
2019-06-30 23:42:44 +01:00
Matthias Clasen
895e8e25a8 widget: Implement GtkConstraintTarget 2019-06-30 23:42:44 +01:00
Matthias Clasen
04562a76e3 Add GtkConstraintTarget
This is an marker interface that we will
use to accept other things that widgets
in constraints.
2019-06-30 23:42:44 +01:00
Emmanuele Bassi
b6781e06c1 Notify a layout change when adding and removing constraints
Changing the set of constraints should cause a relayout.
2019-06-30 23:42:44 +01:00
Emmanuele Bassi
54104b6676 Fix the opposite size measurement in GtkConstraintLayout
We cannot use the given "for size" when querying our children, because
the constraint layout has no idea about the opposite size of its
children until the layout is complete.

Additionally, we should only suggest an opposite size for the layout if
we have one, instead of suggesting a weak zero size.
2019-06-30 23:42:44 +01:00
Emmanuele Bassi
21450d5f23 Remove size constraints from ConstraintLayoutChild
The size constraints are transient to measurement and allocation, so
they don't really need to be stored inside the GtkLayoutChild subclass
created by a GtkConstraintLayout.
2019-06-30 23:42:44 +01:00
Matthias Clasen
a39bbb2041 constraints: Make internal consistency required
The relations between left, right, width
and top, bottom, height are required for
internal consistency. It doesn't make sense
to ever drop these.

Changing the strength of these relations makes
my systems behave much more stable.
2019-06-30 23:42:44 +01:00
Matthias Clasen
176d9c6baf Add gtk_constraint_layout_remove_constraint
Otherwise, you can't do many interesting things.
2019-06-30 23:42:44 +01:00
Emmanuele Bassi
64afa765c8 Do not release reference on the subject of an expression
We don't own the reference in the first place.
2019-06-30 23:42:44 +01:00
Matthias Clasen
a246d8c926 constraints solver: Avoid critials
When the solver is finalized with existing
constraints, we end up with criticals when
the constraints ref finalize code calls
back into the hash table. Avoid that by
emptying the hash table beforehand.
2019-06-30 23:42:44 +01:00
Matthias Clasen
0531e663ee constraint solver: Fix thawing
There was an obviously wrong precondition here.
2019-06-30 23:42:44 +01:00
Emmanuele Bassi
bd2349c0a0 Do not leak LayoutChild instances
Since the LayoutManager owns the LayoutChild it creates, it's also
responsible for mopping them up.
2019-06-30 23:42:44 +01:00
Emmanuele Bassi
636fbc0f1a Add GtkConstraintLayout demo 2019-06-30 23:42:44 +01:00
Emmanuele Bassi
cdf80f1d65 Add GtkConstraintLayout
A layout manager using GtkConstraintSolver to measure and allocate
children.
2019-06-30 23:42:44 +01:00
Emmanuele Bassi
e7b2c530c5 Propagate rooting and unrooting widgets to layout managers
Layout managers may need to get access to data attached to the root of a
scene graph.
2019-06-30 23:42:44 +01:00
Emmanuele Bassi
e07098da03 window: Create a GtkConstraintSolver
Implement the GtkRoot getter for GtkConstraintSolver.
2019-06-30 23:42:44 +01:00
Emmanuele Bassi
98a21bf498 Assign a GtkConstraintSolver to each GtkRoot
Constraints need to work across different parents, so it's better to
have a single constraint solver per top level.
2019-06-30 23:42:44 +01:00
Emmanuele Bassi
c694dd6049 Move the Root interface to a private header
We don't expect out of tree implementations of GtkRoot, and having the
interface structure private to the GTK code allows us to add virtual
functions involving private types.
2019-06-30 23:42:44 +01:00
Emmanuele Bassi
6b308cd71e Add constraint solver
GtkConstraintSolver is an implementation of the Cassowary constraint
solving algorithm:

  http://constraints.cs.washington.edu/cassowary/

The Cassowary method allows to incrementally solve a tableau of linear
equations, in the form of:

  x = y × coefficient + constant

with different weights, or strengths, applied to each one.

These equations can be used to describe constraints applied to a layout
of UI elements, which allows layout managers using the Cassowary method
to quickly, and efficiently, lay out widgets in complex relations
between themselves and their parent container.
2019-06-30 23:42:44 +01:00
Matthias Clasen
3b6ee32f83 Fix a crash in action muxer destruction
I've seen a crash when the action muxer gets
disposed during widget destroy, and tries to
disconnect from widget signals too late.

There is no real need to disconnect, since the
only time an action muxer is going away is when
its widget is destroyed, so just don't do it.
2019-06-30 18:37:32 +00:00
Timm Bäder
3bc3e140dd transform: Add transform_bounds fast path for 2D_AFFINE transforms
E.g. anything involving a scale. This is important when e.g. scrolling
in the node list in the recorder, which scales every recorded node down
to fit in the list.
2019-06-29 09:49:38 +02:00
Timm Bäder
a6a9853676 Adwaita: Fix popover style
We add the .background class to the popover node now.
2019-06-29 09:06:32 +02:00
Timm Bäder
6b42e5b433 gl renderer: Fix push/pop modelview behavior 2019-06-29 08:57:27 +02:00
Timm Bäder
99c01607f1 gl renderer: Remove some dead code 2019-06-29 08:53:36 +02:00
Timm Bäder
071748592d gl renderer: Don't upload GL textures into the icon cache 2019-06-29 07:15:43 +02:00
Timm Bäder
8dd74eac2e transform: Add skew parsing 2019-06-29 07:15:43 +02:00
Matthias Clasen
f6a2678486 Add another grid layout test
This one will be used for comparison
with constraint layouts.
2019-06-28 19:21:21 +00:00
Matthias Clasen
e28ec2a3eb Some more grid layout tests
Add testcases for spanning children and homogeneity.
2019-06-28 18:07:23 +00:00
Matthias Clasen
c4fd786866 Add a test for the grid layout manager
Test some obvious conditions. This is mainly
to test the waters for more intesting tests
with other layout managers later.
2019-06-28 13:30:16 +00:00
Matthias Clasen
8fa7de5563 grid layout: Fix initial property values
Too bad that we don't cover layout children
in the default value test - it would have
caught this.
2019-06-28 12:42:06 +00:00
Jakub Steiner
9e6b4e82c9 Adwaita: allow flat list row buttons to be flat
- Be more specific about the list row image buttons

Addresses corner case of https://gitlab.gnome.org/GNOME/gtk/issues/1748
2019-06-27 12:15:51 +02:00
Jakub Steiner
4be2e804ae Adwaita: lighten dark switch sliders
- addresses legibility concerns

Fixes https://gitlab.gnome.org/GNOME/gtk/issues/1819
2019-06-27 10:58:18 +02:00
Alex Monday
1056e9976a Adwaita: Apply border-radius to .csd popovers
Fix popover_radius variable doesn't apply to .csd popover.

Closes https://gitlab.gnome.org/GNOME/gtk/issues/1984
2019-06-27 10:40:22 +02:00
Alex Monday
851bb61455 Adwaita: Fix padding/rounding on submenus
- Apply menubar submenu style for .csd submenus;
- Remove child subemenu style (looks like it is inherited
  from a parent).

Closes https://gitlab.gnome.org/GNOME/gtk/issues/1976
2019-06-27 10:31:11 +02:00
Jakub Steiner
3aadc29af4 Adwaita: darken osd background for A:dark
- OSD background color was too close to $bg_color to make out outline

Fixes https://gitlab.gnome.org/GNOME/gtk/issues/1964
2019-06-27 10:30:01 +02:00
Alex Monday
afbadc5e1b Adwaita: Fix fine-tune mode for scales with marks
Remove old fine-tune marks style, add margins for fine-tune marks to
compensate trough growth, prevent horizontal fine-tune trough growth in
horizontal direction, prevent vertical fine-tune trough growth in
vertical direction.

Closes https://gitlab.gnome.org/GNOME/gtk/issues/1799
2019-04-01 14:48:45 +05:00
1095 changed files with 166321 additions and 124545 deletions

View File

@@ -1,7 +1,7 @@
stages:
- build
- flatpak
- deploy
# - deploy
.cache-paths: &cache-paths
paths:
@@ -12,8 +12,8 @@ stages:
- subprojects/libepoxy/
- subprojects/pango/
fedora-x86_64:
image: registry.gitlab.gnome.org/gnome/gtk/master:v6
fedora-x86_64: &fedora-x86_64-defaults
image: registry.gitlab.gnome.org/gnome/gtk/master:v8
stage: build
script:
- bash -x ./.gitlab-ci/test-docker.sh
@@ -33,6 +33,11 @@ fedora-x86_64:
key: "$CI_JOB_NAME"
<<: *cache-paths
fedora-x86_64-staticlibs:
variables:
EXTRA_MESON_FLAGS: "-Ddefault_library=both"
<<: *fedora-x86_64-defaults
.mingw-defaults: &mingw-defaults
stage: build
tags:
@@ -101,20 +106,19 @@ flatpak-master:icon-browser:
APPID: org.gtk.IconBrowser4
<<: *flatpak-master
pages:
image: registry.gitlab.gnome.org/gnome/gtk/master:v6
stage: deploy
script:
- meson -Ddocumentation=true _build .
- ninja -C _build
- ninja -C _build gdk4-doc gsk4-doc gtk4-doc
- mkdir -p public/
- mv _build/docs/reference/gtk/html/ public/gtk/
- mv _build/docs/reference/gdk/html/ public/gdk/
- mv _build/docs/reference/gsk/html/ public/gsk/
artifacts:
paths:
- public
only:
- master
#pages:
# image: registry.gitlab.gnome.org/gnome/gtk/master:v6
# stage: deploy
# script:
# - meson -Dgtk_doc=true _build .
# - ninja -C _build
# - ninja -C _build gdk4-doc gsk4-doc gtk4-doc
# - mkdir -p public/
# - mv _build/docs/reference/gtk/html/ public/gtk/
# - mv _build/docs/reference/gdk/html/ public/gdk/
# - mv _build/docs/reference/gsk/html/ public/gsk/
# artifacts:
# paths:
# - public
# only:
# - master

View File

@@ -1,7 +1,6 @@
FROM fedora:30
FROM fedora:31
RUN dnf -y install \
hicolor-icon-theme \
adwaita-icon-theme \
atk-devel \
at-spi2-atk-devel \
@@ -14,6 +13,7 @@ RUN dnf -y install \
dbus-daemon \
dejavu-sans-mono-fonts \
desktop-file-utils \
diffutils \
elfutils-libelf-devel \
fribidi-devel \
gcc \
@@ -32,6 +32,7 @@ RUN dnf -y install \
gstreamer1-plugins-bad-free-devel \
gstreamer1-plugins-base-devel \
gtk-doc \
hicolor-icon-theme \
iso-codes \
itstool \
json-glib-devel \
@@ -52,6 +53,7 @@ RUN dnf -y install \
libxkbcommon-devel \
libXrandr-devel \
libXrender-devel \
libXtst-devel \
libxslt \
mesa-dri-drivers \
mesa-libEGL-devel \

View File

@@ -149,11 +149,11 @@ ul.images li {
<article>
<section>
<div class="summary">
<h3>Summary</h3>
<h3><a name="summary">Summary</a></h3>
<ul>
<li><strong>Total units:</strong> {{ report.total_units }}</li>
<li><strong>Passed:</strong> {{ report.total_successes }}</li>
<li><strong>Failed:</strong> {{ report.total_failures }}</li>
<li><strong>Passed:</strong> <a href="#passed">{{ report.total_successes }}</a></li>
<li><strong>Failed:</strong> <a href="#failures">{{ report.total_failures }}</a></li>
</ul>
</div>
</section>
@@ -161,7 +161,7 @@ ul.images li {
{% for suite_result in report.results_list %}
<section>
<div class="result">
<h3>Suite: {{ suite_result.suite_name }}</h3>
<h3><a name="results">Suite: {{ suite_result.suite_name }}</a></h3>
<ul>
<li><strong>Units:</strong> {{ suite_result.n_units }}</li>
<li><strong>Passed:</strong> {{ suite_result.n_successes }}</li>
@@ -169,7 +169,7 @@ ul.images li {
</ul>
<div class="successes">
<h4>Passed</h4>
<h4><a name="passed">Passed</a></h4>
<ul class="passed">
{% for success in suite_result.successes if success.result == 'OK' %}
<li>{{ success.name }} - result: <span class="result pass">{{ success.result }}</li>
@@ -178,7 +178,7 @@ ul.images li {
{% endfor %}
</ul>
<h4>Skipped</h4>
<h4><a name="skipped">Skipped</a></h4>
<ul>
{% for success in suite_result.successes if success.result == 'SKIP' %}
<li>{{ success.name }} - result: <span class="result skip">{{ success.result }}</li>
@@ -187,10 +187,10 @@ ul.images li {
{% endfor %}
</ul>
<h4>Expected failures</h4>
<h4><a name="expected-fail">Expected failures</a></h4>
<ul>
{% for success in suite_result.successes if success.result == 'EXPECTEDFAIL' %}
<li>{{ success.name }} - result: <span class="result xfail">{{ success.result }}</span><br/>
<li><a name="{{ success.name }}">{{ success.name }}</a> - result: <span class="result xfail">{{ success.result }}</span><br/>
{% if success.stdout %}
Output: <pre>{{ success.stdout }}</pre>
{% endif %}
@@ -209,10 +209,10 @@ ul.images li {
</div>
<div class="failures">
<h4>Failed</h4>
<h4><a name="failed">Failed</a></h4>
<ul class="failed">
{% for failure in suite_result.failures if failure.result == 'FAIL' %}
<li>{{ failure.name }} - result: <span class="result fail">{{ failure.result }}</span><br/>
<li><a name="{{ failure.name }}">{{ failure.name }}</a> - result: <span class="result fail">{{ failure.result }}</span><br/>
{% if failure.stdout %}
Output: <pre>{{ failure.stdout }}</pre>
{% endif %}
@@ -229,10 +229,10 @@ ul.images li {
{% endfor %}
</ul>
<h4>Timed out</h4>
<h4><a name="timed-out">Timed out</a></h4>
<ul class="failed">
{% for failure in suite_result.failures if failure.result == 'TIMEOUT' %}
<li>{{ failure.name }} - result: <span class="result fail">{{ failure.result }}</span><br/>
<li><a name="{{ failure.name }}">{{ failure.name }}</a> - result: <span class="result fail">{{ failure.result }}</span><br/>
{% if failure.stdout %}
Output: <pre>{{ failure.stdout }}</pre>
{% endif %}

View File

@@ -2,7 +2,7 @@
set -e
TAG="registry.gitlab.gnome.org/gnome/gtk/master:v6"
TAG="registry.gitlab.gnome.org/gnome/gtk/master:v7"
sudo docker build --build-arg HOST_USER_ID="$UID" --tag "${TAG}" \
--file "Dockerfile" .

View File

@@ -17,6 +17,7 @@ meson \
-Dbroadway-backend=true \
-Dvulkan=yes \
--werror \
${EXTRA_MESON_FLAGS:-} \
_build $srcdir
unset CCACHE_DISABLE

View File

@@ -33,6 +33,10 @@ pacman --noconfirm -S --needed \
mingw-w64-$MSYS2_ARCH-gst-plugins-bad \
mingw-w64-$MSYS2_ARCH-shared-mime-info
# https://gitlab.gnome.org/GNOME/gtk/issues/2243
wget "https://gitlab.gnome.org/creiter/gitlab-ci-win32-runner/raw/master/pango/mingw-w64-$MSYS2_ARCH-pango-1.44.7-1-any.pkg.tar.xz"
pacman --noconfirm -U "mingw-w64-$MSYS2_ARCH-pango-1.44.7-1-any.pkg.tar.xz"
mkdir -p _ccache
export CCACHE_BASEDIR="$(pwd)"
export CCACHE_DIR="${CCACHE_BASEDIR}/_ccache"

View File

@@ -174,7 +174,7 @@ maintainers review your contribution.
Each contribution is reviewed by the core developers of the GTK project.
The [CODE-OWNERS](./docs/CODE-OWNERS) document contains the list of core
The [CODEOWNERS](./docs/CODEOWNERS) document contains the list of core
contributors to GTK and the areas for which they are responsible; you
should ensure to receive their review and signoff on your changes.

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

@@ -56,12 +56,6 @@
/* Define if GStreamer support is available */
#mesondefine HAVE_GSTREAMER
/* Define to 1 if you have the `httpGetAuthString' function. */
#mesondefine HAVE_HTTPGETAUTHSTRING
/* Define if cups http_t authstring field is accessible */
#mesondefine HAVE_HTTP_AUTHSTRING
/* Define to 1 if you have the <inttypes.h> header file. */
#mesondefine HAVE_INTTYPES_H
@@ -191,9 +185,6 @@
/* Define to the sub-directory where libtool stores uninstalled libraries. */
#mesondefine LT_OBJDIR
/* Define if <X11/extensions/XIproto.h> needed for xReply */
#mesondefine NEED_XIPROTO_H_FOR_XREPLY
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
#mesondefine NO_MINUS_C_MINUS_O

View File

@@ -0,0 +1,115 @@
/*
* Copyright © 2019 Red Hat, 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.1 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, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen
*/
#include "config.h"
#include "constraint-editor-application.h"
#include "constraint-editor-window.h"
struct _ConstraintEditorApplication
{
GtkApplication parent_instance;
};
G_DEFINE_TYPE(ConstraintEditorApplication, constraint_editor_application, GTK_TYPE_APPLICATION);
static void
constraint_editor_application_init (ConstraintEditorApplication *app)
{
}
static void
quit_activated (GSimpleAction *action,
GVariant *parameter,
gpointer data)
{
g_application_quit (G_APPLICATION (data));
}
static GActionEntry app_entries[] =
{
{ "quit", quit_activated, NULL, NULL, NULL }
};
static void
constraint_editor_application_startup (GApplication *app)
{
const char *quit_accels[2] = { "<Ctrl>Q", NULL };
const char *open_accels[2] = { "<Ctrl>O", NULL };
GtkCssProvider *provider;
G_APPLICATION_CLASS (constraint_editor_application_parent_class)->startup (app);
g_action_map_add_action_entries (G_ACTION_MAP (app),
app_entries, G_N_ELEMENTS (app_entries),
app);
gtk_application_set_accels_for_action (GTK_APPLICATION (app), "app.quit", quit_accels);
gtk_application_set_accels_for_action (GTK_APPLICATION (app), "win.open", open_accels);
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_resource (provider, "/org/gtk/gtk4/constraint-editor/constraint-editor.css");
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
static void
constraint_editor_application_activate (GApplication *app)
{
ConstraintEditorWindow *win;
win = constraint_editor_window_new (CONSTRAINT_EDITOR_APPLICATION (app));
gtk_window_present (GTK_WINDOW (win));
}
static void
constraint_editor_application_open (GApplication *app,
GFile **files,
gint n_files,
const gchar *hint)
{
ConstraintEditorWindow *win;
gint i;
for (i = 0; i < n_files; i++)
{
win = constraint_editor_window_new (CONSTRAINT_EDITOR_APPLICATION (app));
constraint_editor_window_load (win, files[i]);
gtk_window_present (GTK_WINDOW (win));
}
}
static void
constraint_editor_application_class_init (ConstraintEditorApplicationClass *class)
{
GApplicationClass *application_class = G_APPLICATION_CLASS (class);
application_class->startup = constraint_editor_application_startup;
application_class->activate = constraint_editor_application_activate;
application_class->open = constraint_editor_application_open;
}
ConstraintEditorApplication *
constraint_editor_application_new (void)
{
return g_object_new (CONSTRAINT_EDITOR_APPLICATION_TYPE,
"application-id", "org.gtk.gtk4.ConstraintEditor",
"flags", G_APPLICATION_HANDLES_OPEN,
NULL);
}

View File

@@ -0,0 +1,28 @@
/*
* Copyright © 2019 Red Hat, 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.1 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, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen
*/
#pragma once
#include <gtk/gtk.h>
#define CONSTRAINT_EDITOR_APPLICATION_TYPE (constraint_editor_application_get_type ())
G_DECLARE_FINAL_TYPE (ConstraintEditorApplication, constraint_editor_application, CONSTRAINT, EDITOR_APPLICATION, GtkApplication)
ConstraintEditorApplication *constraint_editor_application_new (void);

View File

@@ -0,0 +1,639 @@
/*
* Copyright © 2019 Red Hat, 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.1 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, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen
*/
#include "config.h"
#include "constraint-editor-window.h"
#include "constraint-view.h"
#include "constraint-editor.h"
#include "guide-editor.h"
struct _ConstraintEditorWindow
{
GtkApplicationWindow parent_instance;
GtkWidget *paned;
GtkWidget *view;
GtkWidget *list;
};
G_DEFINE_TYPE(ConstraintEditorWindow, constraint_editor_window, GTK_TYPE_APPLICATION_WINDOW);
static GtkConstraintTarget *
find_target (GListModel *model,
GtkConstraintTarget *orig)
{
const char *name;
const char *model_name;
gpointer item;
int i;
if (orig == NULL)
return NULL;
if (GTK_IS_LABEL (orig))
name = gtk_label_get_label (GTK_LABEL (orig));
else if (GTK_IS_CONSTRAINT_GUIDE (orig))
name = gtk_constraint_guide_get_name (GTK_CONSTRAINT_GUIDE (orig));
else
{
g_warning ("Don't know how to handle %s targets", G_OBJECT_TYPE_NAME (orig));
return NULL;
}
for (i = 0; i < g_list_model_get_n_items (model); i++)
{
item = g_list_model_get_item (model, i);
g_object_unref (item);
if (GTK_IS_WIDGET (item))
model_name = gtk_widget_get_name (GTK_WIDGET (item));
else
model_name = gtk_constraint_guide_get_name (GTK_CONSTRAINT_GUIDE (item));
if (strcmp (name, model_name) == 0)
return GTK_CONSTRAINT_TARGET (item);
}
g_warning ("Failed to find target '%s'", name);
return NULL;
}
gboolean
constraint_editor_window_load (ConstraintEditorWindow *self,
GFile *file)
{
char *path;
GtkBuilder *builder;
GError *error = NULL;
GtkWidget *view;
GtkLayoutManager *layout;
GtkWidget *child;
const char *name;
gpointer item;
int i;
GListModel *list;
path = g_file_get_path (file);
builder = gtk_builder_new ();
if (!gtk_builder_add_from_file (builder, path, &error))
{
g_print ("Could not load %s: %s", path, error->message);
g_error_free (error);
g_free (path);
g_object_unref (builder);
return FALSE;
}
view = GTK_WIDGET (gtk_builder_get_object (builder, "view"));
if (!GTK_IS_BOX (view))
{
g_print ("Could not load %s: No GtkBox named 'view'", path);
g_free (path);
g_object_unref (builder);
return FALSE;
}
layout = gtk_widget_get_layout_manager (view);
if (!GTK_IS_CONSTRAINT_LAYOUT (layout))
{
g_print ("Could not load %s: Widget 'view' does not use GtkConstraintLayout", path);
g_free (path);
g_object_unref (builder);
return FALSE;
}
for (child = gtk_widget_get_first_child (view);
child;
child = gtk_widget_get_next_sibling (child))
{
if (!GTK_IS_LABEL (child))
{
g_print ("Skipping non-GtkLabel child\n");
continue;
}
name = gtk_label_get_label (GTK_LABEL (child));
constraint_view_add_child (CONSTRAINT_VIEW (self->view), name);
}
list = gtk_constraint_layout_observe_guides (GTK_CONSTRAINT_LAYOUT (layout));
for (i = 0; i < g_list_model_get_n_items (list); i++)
{
GtkConstraintGuide *guide, *clone;
int w, h;
item = g_list_model_get_item (list, i);
guide = GTK_CONSTRAINT_GUIDE (item);
/* need to clone here, to attach to the right targets */
clone = gtk_constraint_guide_new ();
gtk_constraint_guide_set_name (clone, gtk_constraint_guide_get_name (guide));
gtk_constraint_guide_set_strength (clone, gtk_constraint_guide_get_strength (guide));
gtk_constraint_guide_get_min_size (guide, &w, &h);
gtk_constraint_guide_set_min_size (clone, w, h);
gtk_constraint_guide_get_nat_size (guide, &w, &h);
gtk_constraint_guide_set_nat_size (clone, w, h);
gtk_constraint_guide_get_max_size (guide, &w, &h);
gtk_constraint_guide_set_max_size (clone, w, h);
constraint_view_add_guide (CONSTRAINT_VIEW (self->view), clone);
g_object_unref (guide);
g_object_unref (clone);
}
g_object_unref (list);
list = gtk_constraint_layout_observe_constraints (GTK_CONSTRAINT_LAYOUT (layout));
for (i = 0; i < g_list_model_get_n_items (list); i++)
{
GtkConstraint *constraint;
GtkConstraint *clone;
GtkConstraintTarget *target;
GtkConstraintTarget *source;
item = g_list_model_get_item (list, i);
constraint = GTK_CONSTRAINT (item);
target = gtk_constraint_get_target (constraint);
source = gtk_constraint_get_source (constraint);
clone = gtk_constraint_new (find_target (constraint_view_get_model (CONSTRAINT_VIEW (self->view)), target),
gtk_constraint_get_target_attribute (constraint),
gtk_constraint_get_relation (constraint),
find_target (constraint_view_get_model (CONSTRAINT_VIEW (self->view)), source),
gtk_constraint_get_target_attribute (constraint),
gtk_constraint_get_multiplier (constraint),
gtk_constraint_get_constant (constraint),
gtk_constraint_get_strength (constraint));
constraint_view_add_constraint (CONSTRAINT_VIEW (self->view), clone);
g_object_unref (constraint);
g_object_unref (clone);
}
g_object_unref (list);
g_free (path);
g_object_unref (builder);
return TRUE;
}
static void
open_response_cb (GtkNativeDialog *dialog,
gint response,
ConstraintEditorWindow *self)
{
gtk_native_dialog_hide (dialog);
if (response == GTK_RESPONSE_ACCEPT)
{
GFile *file;
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
constraint_editor_window_load (self, file);
g_object_unref (file);
}
gtk_native_dialog_destroy (dialog);
}
static void
open_cb (GtkWidget *button,
ConstraintEditorWindow *self)
{
GtkFileChooserNative *dialog;
dialog = gtk_file_chooser_native_new ("Open file",
GTK_WINDOW (self),
GTK_FILE_CHOOSER_ACTION_OPEN,
"_Load",
"_Cancel");
gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (dialog), TRUE);
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), ".");
g_signal_connect (dialog, "response", G_CALLBACK (open_response_cb), self);
gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
}
static void
serialize_child (GString *str,
int indent,
GtkWidget *child)
{
const char *name;
name = gtk_widget_get_name (child);
g_string_append_printf (str, "%*s<child>\n", indent, "");
g_string_append_printf (str, "%*s <object class=\"GtkLabel\" id=\"%s\">\n", indent, "", name);
g_string_append_printf (str, "%*s <property name=\"label\">%s</property>\n", indent, "", name);
g_string_append_printf (str, "%*s </object>\n", indent, "");
g_string_append_printf (str, "%*s</child>\n", indent, "");
}
static char *
serialize_model (GListModel *list)
{
GString *str = g_string_new ("");
int i;
g_string_append (str, "<interface>\n");
g_string_append (str, " <object class=\"GtkBox\" id=\"view\">\n");
g_string_append (str, " <property name=\"layout-manager\">\n");
g_string_append (str, " <object class=\"GtkConstraintLayout\">\n");
g_string_append (str, " <constraints>\n");
for (i = 0; i < g_list_model_get_n_items (list); i++)
{
gpointer item = g_list_model_get_item (list, i);
g_object_unref (item);
if (GTK_IS_CONSTRAINT (item))
constraint_editor_serialize_constraint (str, 10, GTK_CONSTRAINT (item));
else if (GTK_IS_CONSTRAINT_GUIDE (item))
guide_editor_serialize_guide (str, 10, GTK_CONSTRAINT_GUIDE (item));
}
g_string_append (str, " </constraints>\n");
g_string_append (str, " </object>\n");
g_string_append (str, " </property>\n");
for (i = 0; i < g_list_model_get_n_items (list); i++)
{
gpointer item = g_list_model_get_item (list, i);
g_object_unref (item);
if (GTK_IS_WIDGET (item))
serialize_child (str, 4, GTK_WIDGET (item));
}
g_string_append (str, " </object>\n");
g_string_append (str, "</interface>\n");
return g_string_free (str, FALSE);
}
static void
save_response_cb (GtkNativeDialog *dialog,
gint response,
ConstraintEditorWindow *self)
{
gtk_native_dialog_hide (dialog);
if (response == GTK_RESPONSE_ACCEPT)
{
GListModel *model;
char *text, *filename;
GError *error = NULL;
model = constraint_view_get_model (CONSTRAINT_VIEW (self->view));
text = serialize_model (model);
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
if (!g_file_set_contents (filename, text, -1, &error))
{
GtkWidget *dialog;
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (self))),
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
"Saving failed");
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
"%s", error->message);
g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
gtk_widget_show (dialog);
g_error_free (error);
}
g_free (filename);
}
gtk_native_dialog_destroy (dialog);
}
static void
save_cb (GtkWidget *button,
ConstraintEditorWindow *self)
{
GtkFileChooserNative *dialog;
dialog = gtk_file_chooser_native_new ("Save constraints",
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (button))),
GTK_FILE_CHOOSER_ACTION_SAVE,
"_Save",
"_Cancel");
gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (dialog), TRUE);
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), ".");
g_signal_connect (dialog, "response", G_CALLBACK (save_response_cb), self);
gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
}
static void
constraint_editor_window_finalize (GObject *object)
{
//ConstraintEditorWindow *self = (ConstraintEditorWindow *)object;
G_OBJECT_CLASS (constraint_editor_window_parent_class)->finalize (object);
}
static int child_counter;
static int guide_counter;
static void
add_child (ConstraintEditorWindow *win)
{
char *name;
child_counter++;
name = g_strdup_printf ("Child %d", child_counter);
constraint_view_add_child (CONSTRAINT_VIEW (win->view), name);
g_free (name);
}
static void
add_guide (ConstraintEditorWindow *win)
{
char *name;
GtkConstraintGuide *guide;
guide_counter++;
name = g_strdup_printf ("Guide %d", guide_counter);
guide = gtk_constraint_guide_new ();
gtk_constraint_guide_set_name (guide, name);
g_free (name);
constraint_view_add_guide (CONSTRAINT_VIEW (win->view), guide);
}
static void
constraint_editor_done (ConstraintEditor *editor,
GtkConstraint *constraint,
ConstraintEditorWindow *win)
{
GtkConstraint *old_constraint;
g_object_get (editor, "constraint", &old_constraint, NULL);
if (old_constraint)
constraint_view_remove_constraint (CONSTRAINT_VIEW (win->view), old_constraint);
constraint_view_add_constraint (CONSTRAINT_VIEW (win->view), constraint);
g_clear_object (&old_constraint);
gtk_widget_destroy (gtk_widget_get_ancestor (GTK_WIDGET (editor), GTK_TYPE_WINDOW));
}
static void
edit_constraint (ConstraintEditorWindow *win,
GtkConstraint *constraint)
{
GtkWidget *window;
ConstraintEditor *editor;
GListModel *model;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (win));
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
if (constraint)
gtk_window_set_title (GTK_WINDOW (window), "Edit Constraint");
else
gtk_window_set_title (GTK_WINDOW (window), "Create Constraint");
model = constraint_view_get_model (CONSTRAINT_VIEW (win->view));
editor = constraint_editor_new (model, constraint);
gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (editor));
g_signal_connect (editor, "done", G_CALLBACK (constraint_editor_done), win);
gtk_widget_show (window);
}
static void
add_constraint (ConstraintEditorWindow *win)
{
edit_constraint (win, NULL);
}
static void
guide_editor_done (GuideEditor *editor,
GtkConstraintGuide *guide,
ConstraintEditorWindow *win)
{
gtk_widget_destroy (gtk_widget_get_ancestor (GTK_WIDGET (editor), GTK_TYPE_WINDOW));
}
static void
edit_guide (ConstraintEditorWindow *win,
GtkConstraintGuide *guide)
{
GtkWidget *window;
GuideEditor *editor;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (win));
gtk_window_set_title (GTK_WINDOW (window), "Edit Guide");
editor = guide_editor_new (guide);
gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (editor));
g_signal_connect (editor, "done", G_CALLBACK (guide_editor_done), win);
gtk_widget_show (window);
}
static void
row_activated (GtkListBox *list,
GtkListBoxRow *row,
ConstraintEditorWindow *win)
{
GObject *item;
item = G_OBJECT (g_object_get_data (G_OBJECT (row), "item"));
if (GTK_IS_CONSTRAINT (item))
edit_constraint (win, GTK_CONSTRAINT (item));
else if (GTK_IS_CONSTRAINT_GUIDE (item))
edit_guide (win, GTK_CONSTRAINT_GUIDE (item));
}
static void
constraint_editor_window_class_init (ConstraintEditorWindowClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
g_type_ensure (CONSTRAINT_VIEW_TYPE);
object_class->finalize = constraint_editor_window_finalize;
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gtk/gtk4/constraint-editor/constraint-editor-window.ui");
gtk_widget_class_bind_template_child (widget_class, ConstraintEditorWindow, paned);
gtk_widget_class_bind_template_child (widget_class, ConstraintEditorWindow, view);
gtk_widget_class_bind_template_child (widget_class, ConstraintEditorWindow, list);
gtk_widget_class_bind_template_callback (widget_class, open_cb);
gtk_widget_class_bind_template_callback (widget_class, save_cb);
gtk_widget_class_bind_template_callback (widget_class, add_child);
gtk_widget_class_bind_template_callback (widget_class, add_guide);
gtk_widget_class_bind_template_callback (widget_class, add_constraint);
gtk_widget_class_bind_template_callback (widget_class, row_activated);
}
static void
row_edit (GtkButton *button,
ConstraintEditorWindow *win)
{
GtkWidget *row;
GObject *item;
row = gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_LIST_BOX_ROW);
item = (GObject *)g_object_get_data (G_OBJECT (row), "item");
if (GTK_IS_CONSTRAINT (item))
edit_constraint (win, GTK_CONSTRAINT (item));
else if (GTK_IS_CONSTRAINT_GUIDE (item))
edit_guide (win, GTK_CONSTRAINT_GUIDE (item));
}
static void
mark_constraints_invalid (ConstraintEditorWindow *win,
gpointer removed)
{
GtkWidget *child;
GObject *item;
for (child = gtk_widget_get_first_child (win->list);
child;
child = gtk_widget_get_next_sibling (child))
{
item = (GObject *)g_object_get_data (G_OBJECT (child), "item");
if (GTK_IS_CONSTRAINT (item))
{
GtkConstraint *constraint = GTK_CONSTRAINT (item);
if (gtk_constraint_get_target (constraint) == (GtkConstraintTarget *)removed ||
gtk_constraint_get_source (constraint) == (GtkConstraintTarget *)removed)
{
GtkWidget *button;
button = (GtkWidget *)g_object_get_data (G_OBJECT (child), "edit");
gtk_button_set_icon_name (GTK_BUTTON (button), "dialog-warning-symbolic");
gtk_widget_set_tooltip_text (button, "Constraint is invalid");
}
}
}
}
static void
row_delete (GtkButton *button,
ConstraintEditorWindow *win)
{
GtkWidget *row;
GObject *item;
row = gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_LIST_BOX_ROW);
item = (GObject *)g_object_get_data (G_OBJECT (row), "item");
if (GTK_IS_CONSTRAINT (item))
constraint_view_remove_constraint (CONSTRAINT_VIEW (win->view),
GTK_CONSTRAINT (item));
else if (GTK_IS_CONSTRAINT_GUIDE (item))
{
mark_constraints_invalid (win, item);
constraint_view_remove_guide (CONSTRAINT_VIEW (win->view),
GTK_CONSTRAINT_GUIDE (item));
}
else if (GTK_IS_WIDGET (item))
{
mark_constraints_invalid (win, item);
constraint_view_remove_child (CONSTRAINT_VIEW (win->view),
GTK_WIDGET (item));
}
}
static GtkWidget *
create_widget_func (gpointer item,
gpointer user_data)
{
ConstraintEditorWindow *win = user_data;
const char *name;
char *freeme = NULL;
GtkWidget *row, *box, *label, *button;
if (GTK_IS_WIDGET (item))
name = gtk_widget_get_name (GTK_WIDGET (item));
else if (GTK_IS_CONSTRAINT_GUIDE (item))
name = gtk_constraint_guide_get_name (GTK_CONSTRAINT_GUIDE (item));
else if (GTK_IS_CONSTRAINT (item))
name = freeme = constraint_editor_constraint_to_string (GTK_CONSTRAINT (item));
else
name = "";
row = gtk_list_box_row_new ();
g_object_set_data_full (G_OBJECT (row), "item", g_object_ref (item), g_object_unref);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
label = gtk_label_new (name);
if (GTK_IS_WIDGET (item) || GTK_IS_CONSTRAINT_GUIDE (item))
g_object_bind_property (item, "name",
label, "label",
G_BINDING_DEFAULT);
g_object_set (label, "margin", 10, NULL);
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_widget_set_hexpand (label, TRUE);
gtk_container_add (GTK_CONTAINER (row), box);
gtk_container_add (GTK_CONTAINER (box), label);
if (GTK_IS_CONSTRAINT (item) || GTK_IS_CONSTRAINT_GUIDE (item))
{
button = gtk_button_new_from_icon_name ("document-edit-symbolic");
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
g_signal_connect (button, "clicked", G_CALLBACK (row_edit), win);
g_object_set_data (G_OBJECT (row), "edit", button);
gtk_container_add (GTK_CONTAINER (box), button);
button = gtk_button_new_from_icon_name ("edit-delete-symbolic");
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
g_signal_connect (button, "clicked", G_CALLBACK (row_delete), win);
gtk_container_add (GTK_CONTAINER (box), button);
}
else if (GTK_IS_WIDGET (item))
{
button = gtk_button_new_from_icon_name ("edit-delete-symbolic");
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
g_signal_connect (button, "clicked", G_CALLBACK (row_delete), win);
gtk_container_add (GTK_CONTAINER (box), button);
}
g_free (freeme);
return row;
}
static void
constraint_editor_window_init (ConstraintEditorWindow *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
gtk_list_box_bind_model (GTK_LIST_BOX (self->list),
constraint_view_get_model (CONSTRAINT_VIEW (self->view)),
create_widget_func,
self,
NULL);
}
ConstraintEditorWindow *
constraint_editor_window_new (ConstraintEditorApplication *application)
{
return g_object_new (CONSTRAINT_EDITOR_WINDOW_TYPE,
"application", application,
NULL);
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright © 2019 Red Hat, 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.1 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, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen
*/
#pragma once
#include <gtk/gtk.h>
#include "constraint-editor-application.h"
#define CONSTRAINT_EDITOR_WINDOW_TYPE (constraint_editor_window_get_type ())
G_DECLARE_FINAL_TYPE (ConstraintEditorWindow, constraint_editor_window, CONSTRAINT, EDITOR_WINDOW, GtkApplicationWindow)
ConstraintEditorWindow * constraint_editor_window_new (ConstraintEditorApplication *application);
gboolean constraint_editor_window_load (ConstraintEditorWindow *self,
GFile *file);

View File

@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="ConstraintEditorWindow" parent="GtkApplicationWindow">
<style>
<class name="devel"/>
</style>
<property name="title" translatable="yes">GTK Constraint Editor</property>
<property name="default-width">1024</property>
<property name="default-height">768</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="header">
<property name="title" translatable="yes">GTK Constraint Editor</property>
<property name="show-title-buttons">1</property>
<child type="start">
<object class="GtkButton">
<property name="icon-name">document-open-symbolic</property>
<property name="tooltip-text">Open ui file</property>
<signal name="clicked" handler="open_cb"/>
</object>
</child>
<child type="start">
<object class="GtkButton">
<property name="icon-name">document-save-symbolic</property>
<property name="tooltip-text">Save to ui file</property>
<signal name="clicked" handler="save_cb"/>
</object>
</child>
</object>
</child>
<child>
<object class="GtkPaned" id="paned">
<property name="orientation">horizontal</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="orientation">horizontal</property>
<child>
<object class="GtkButton">
<property name="label">Add Child</property>
<signal name="clicked" handler="add_child" swapped="yes"/>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label">Add Guide</property>
<signal name="clicked" handler="add_guide" swapped="yes"/>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label">Add Constraint</property>
<signal name="clicked" handler="add_constraint" swapped="yes"/>
</object>
</child>
</object>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="hscrollbar-policy">never</property>
<property name="vscrollbar-policy">automatic</property>
<property name="vexpand">1</property>
<child>
<object class="GtkListBox" id="list">
<property name="show-separators">1</property>
<property name="selection-mode">none</property>
<signal name="row-activated" handler="row_activated"/>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="ConstraintView" id="view">
</object>
</child>
</object>
</child>
</template>
</interface>

View File

@@ -0,0 +1,656 @@
/*
* Copyright © 2019 Red Hat, 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.1 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, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen
*/
#include "config.h"
#include "constraint-editor.h"
struct _ConstraintEditor
{
GtkWidget parent_instance;
GtkWidget *grid;
GtkWidget *target;
GtkWidget *target_attr;
GtkWidget *relation;
GtkWidget *source;
GtkWidget *source_attr;
GtkWidget *multiplier;
GtkWidget *constant;
GtkWidget *strength;
GtkWidget *preview;
GtkWidget *button;
GtkConstraint *constraint;
GListModel *model;
gboolean constructed;
};
enum {
PROP_MODEL = 1,
PROP_CONSTRAINT,
LAST_PROP
};
static GParamSpec *pspecs[LAST_PROP];
enum {
DONE,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL];
G_DEFINE_TYPE(ConstraintEditor, constraint_editor, GTK_TYPE_WIDGET);
static const char *
get_target_name (GtkConstraintTarget *target)
{
if (target == NULL)
return "super";
else if (GTK_IS_WIDGET (target))
return gtk_widget_get_name (GTK_WIDGET (target));
else if (GTK_IS_CONSTRAINT_GUIDE (target))
return gtk_constraint_guide_get_name (GTK_CONSTRAINT_GUIDE (target));
else
return "";
}
static void
constraint_target_combo (GListModel *model,
GtkWidget *combo,
gboolean is_source)
{
int i;
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "super", "Super");
if (model)
{
for (i = 0; i < g_list_model_get_n_items (model); i++)
{
GObject *item = g_list_model_get_object (model, i);
const char *name;
if (GTK_IS_CONSTRAINT (item))
continue;
name = get_target_name (GTK_CONSTRAINT_TARGET (item));
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), name, name);
g_object_unref (item);
}
}
}
static void
constraint_attribute_combo (GtkWidget *combo,
gboolean is_source)
{
if (is_source)
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "none", "None");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "left", "Left");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "right", "Right");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "top", "Top");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "bottom", "Bottom");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "start", "Start");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "end", "End");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "width", "Width");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "height", "Height");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "center-x", "Center X");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "center-y", "Center Y");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "baseline", "Baseline");
}
static void
constraint_relation_combo (GtkWidget *combo)
{
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "le", "");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "eq", "=");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "ge", "");
}
static void
constraint_strength_combo (GtkWidget *combo)
{
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "weak", "Weak");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "medium", "Medium");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "strong", "Strong");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "required", "Required");
}
static gpointer
get_target (GListModel *model,
const char *id)
{
int i;
if (strcmp ("super", id) == 0)
return NULL;
for (i = 0; i < g_list_model_get_n_items (model); i++)
{
GObject *item = g_list_model_get_object (model, i);
g_object_unref (item);
if (GTK_IS_CONSTRAINT (item))
continue;
else if (GTK_IS_WIDGET (item))
{
if (strcmp (id, gtk_widget_get_name (GTK_WIDGET (item))) == 0)
return item;
}
else if (GTK_IS_CONSTRAINT_GUIDE (item))
{
if (strcmp (id, gtk_constraint_guide_get_name (GTK_CONSTRAINT_GUIDE (item))) == 0)
return item;
}
}
return NULL;
}
static GtkConstraintAttribute
get_target_attr (const char *id)
{
GtkConstraintAttribute attr;
GEnumClass *class = g_type_class_ref (GTK_TYPE_CONSTRAINT_ATTRIBUTE);
GEnumValue *value = g_enum_get_value_by_nick (class, id);
attr = value->value;
g_type_class_unref (class);
return attr;
}
static const char *
get_attr_nick (GtkConstraintAttribute attr)
{
GEnumClass *class = g_type_class_ref (GTK_TYPE_CONSTRAINT_ATTRIBUTE);
GEnumValue *value = g_enum_get_value (class, attr);
const char *nick = value->value_nick;
g_type_class_unref (class);
return nick;
}
static GtkConstraintRelation
get_relation (const char *id)
{
GtkConstraintRelation relation;
GEnumClass *class = g_type_class_ref (GTK_TYPE_CONSTRAINT_RELATION);
GEnumValue *value = g_enum_get_value_by_nick (class, id);
relation = value->value;
g_type_class_unref (class);
return relation;
}
static const char *
get_relation_nick (GtkConstraintRelation relation)
{
GEnumClass *class = g_type_class_ref (GTK_TYPE_CONSTRAINT_RELATION);
GEnumValue *value = g_enum_get_value (class, relation);
const char *nick = value->value_nick;
g_type_class_unref (class);
return nick;
}
static GtkConstraintStrength
get_strength (const char *id)
{
GtkConstraintStrength strength;
GEnumClass *class = g_type_class_ref (GTK_TYPE_CONSTRAINT_STRENGTH);
GEnumValue *value = g_enum_get_value_by_nick (class, id);
strength = value->value;
g_type_class_unref (class);
return strength;
}
static const char *
get_strength_nick (GtkConstraintStrength strength)
{
GEnumClass *class = g_type_class_ref (GTK_TYPE_CONSTRAINT_STRENGTH);
GEnumValue *value = g_enum_get_value (class, strength);
const char *nick = value->value_nick;
g_type_class_unref (class);
return nick;
}
void
constraint_editor_serialize_constraint (GString *str,
int indent,
GtkConstraint *constraint)
{
const char *target;
const char *target_attr;
const char *relation;
const char *source;
const char *source_attr;
double multiplier;
double constant;
const char *strength;
target = get_target_name (gtk_constraint_get_target (constraint));
target_attr = get_attr_nick (gtk_constraint_get_target_attribute (constraint));
relation = get_relation_nick (gtk_constraint_get_relation (constraint));
source = get_target_name (gtk_constraint_get_source (constraint));
source_attr = get_attr_nick (gtk_constraint_get_source_attribute (constraint));
multiplier = gtk_constraint_get_multiplier (constraint);
constant = gtk_constraint_get_constant (constraint);
strength = get_strength_nick (gtk_constraint_get_strength (constraint));
g_string_append_printf (str, "%*s<constraint target=\"%s\" target-attribute=\"%s\"\n", indent, "", target, target_attr);
g_string_append_printf (str, "%*s relation=\"%s\"\n", indent, "", relation);
if (strcmp (source_attr, "none") != 0)
{
g_string_append_printf (str, "%*s source=\"%s\" source-attribute=\"%s\"\n", indent, "", source, source_attr);
g_string_append_printf (str, "%*s multiplier=\"%g\"\n", indent, "", multiplier);
}
g_string_append_printf (str, "%*s constant=\"%g\"\n", indent, "", constant);
g_string_append_printf (str, "%*s strength=\"%s\" />\n", indent, "", strength);
}
static void
create_constraint (GtkButton *button,
ConstraintEditor *editor)
{
const char *id;
gpointer target;
GtkConstraintAttribute target_attr;
gpointer source;
GtkConstraintAttribute source_attr;
GtkConstraintRelation relation;
double multiplier;
double constant;
int strength;
GtkConstraint *constraint;
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->target));
target = get_target (editor->model, id);
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->target_attr));
target_attr = get_target_attr (id);
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source));
source = get_target (editor->model, id);
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source_attr));
source_attr = get_target_attr (id);
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->relation));
relation = get_relation (id);
multiplier = g_ascii_strtod (gtk_editable_get_text (GTK_EDITABLE (editor->multiplier)), NULL);
constant = g_ascii_strtod (gtk_editable_get_text (GTK_EDITABLE (editor->constant)), NULL);
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->strength));
strength = get_strength (id);
constraint = gtk_constraint_new (target, target_attr,
relation,
source, source_attr,
multiplier,
constant,
strength);
g_signal_emit (editor, signals[DONE], 0, constraint);
g_object_unref (constraint);
}
static void
source_attr_changed (ConstraintEditor *editor)
{
const char *id;
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source_attr));
if (strcmp (id, "none") == 0)
{
gtk_combo_box_set_active (GTK_COMBO_BOX (editor->source), -1);
gtk_editable_set_text (GTK_EDITABLE (editor->multiplier), "");
gtk_widget_set_sensitive (editor->source, FALSE);
gtk_widget_set_sensitive (editor->multiplier, FALSE);
}
else
{
gtk_widget_set_sensitive (editor->source, TRUE);
gtk_widget_set_sensitive (editor->multiplier, TRUE);
}
}
char *
constraint_editor_constraint_to_string (GtkConstraint *constraint)
{
GString *str;
const char *name;
const char *attr;
const char *relation;
double c, m;
str = g_string_new ("");
name = get_target_name (gtk_constraint_get_target (constraint));
attr = get_attr_nick (gtk_constraint_get_target_attribute (constraint));
relation = get_relation_nick (gtk_constraint_get_relation (constraint));
if (name == NULL)
name = "[ ]";
g_string_append_printf (str, "%s.%s %s ", name, attr, relation);
c = gtk_constraint_get_constant (constraint);
attr = get_attr_nick (gtk_constraint_get_source_attribute (constraint));
if (strcmp (attr, "none") != 0)
{
name = get_target_name (gtk_constraint_get_source (constraint));
m = gtk_constraint_get_multiplier (constraint);
if (name == NULL)
name = "[ ]";
g_string_append_printf (str, "%s.%s", name, attr);
if (m != 1.0)
g_string_append_printf (str, " × %g", m);
if (c > 0.0)
g_string_append_printf (str, " + %g", c);
else if (c < 0.0)
g_string_append_printf (str, " - %g", -c);
}
else
g_string_append_printf (str, "%g", c);
return g_string_free (str, FALSE);
}
static void
update_preview (ConstraintEditor *editor)
{
GString *str;
const char *name;
const char *attr;
char *relation;
const char *multiplier;
const char *constant;
double c, m;
if (!editor->constructed)
return;
str = g_string_new ("");
name = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->target));
attr = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->target_attr));
relation = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (editor->relation));
if (name == NULL)
name = "[ ]";
g_string_append_printf (str, "%s.%s %s ", name, attr, relation);
g_free (relation);
constant = gtk_editable_get_text (GTK_EDITABLE (editor->constant));
c = g_ascii_strtod (constant, NULL);
attr = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source_attr));
if (strcmp (attr, "none") != 0)
{
name = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source));
multiplier = gtk_editable_get_text (GTK_EDITABLE (editor->multiplier));
m = g_ascii_strtod (multiplier, NULL);
if (name == NULL)
name = "[ ]";
g_string_append_printf (str, "%s.%s", name, attr);
if (m != 1.0)
g_string_append_printf (str, " × %g", m);
if (c > 0.0)
g_string_append_printf (str, " + %g", c);
else if (c < 0.0)
g_string_append_printf (str, " - %g", -c);
}
else
g_string_append_printf (str, "%g", c);
gtk_label_set_label (GTK_LABEL (editor->preview), str->str);
g_string_free (str, TRUE);
}
static void
update_button (ConstraintEditor *editor)
{
if (gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->target)) != NULL &&
gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->source)) != NULL)
gtk_widget_set_sensitive (editor->button, TRUE);
else
gtk_widget_set_sensitive (editor->button, FALSE);
}
static void
constraint_editor_init (ConstraintEditor *editor)
{
gtk_widget_init_template (GTK_WIDGET (editor));
}
static void
constraint_editor_constructed (GObject *object)
{
ConstraintEditor *editor = CONSTRAINT_EDITOR (object);
constraint_target_combo (editor->model, editor->target, FALSE);
constraint_attribute_combo (editor->target_attr, FALSE);
constraint_relation_combo (editor->relation);
constraint_target_combo (editor->model, editor->source, TRUE);
constraint_attribute_combo (editor->source_attr, TRUE);
constraint_strength_combo (editor->strength);
if (editor->constraint)
{
GtkConstraintTarget *target;
GtkConstraintAttribute attr;
GtkConstraintRelation relation;
GtkConstraintStrength strength;
const char *nick;
char *val;
double multiplier;
double constant;
target = gtk_constraint_get_target (editor->constraint);
nick = get_target_name (target);
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->target), nick);
attr = gtk_constraint_get_target_attribute (editor->constraint);
nick = get_attr_nick (attr);
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->target_attr), nick);
target = gtk_constraint_get_source (editor->constraint);
nick = get_target_name (target);
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->source), nick);
attr = gtk_constraint_get_source_attribute (editor->constraint);
nick = get_attr_nick (attr);
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->source_attr), nick);
relation = gtk_constraint_get_relation (editor->constraint);
nick = get_relation_nick (relation);
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->relation), nick);
multiplier = gtk_constraint_get_multiplier (editor->constraint);
val = g_strdup_printf ("%g", multiplier);
gtk_editable_set_text (GTK_EDITABLE (editor->multiplier), val);
g_free (val);
constant = gtk_constraint_get_constant (editor->constraint);
val = g_strdup_printf ("%g", constant);
gtk_editable_set_text (GTK_EDITABLE (editor->constant), val);
g_free (val);
strength = gtk_constraint_get_strength (editor->constraint);
nick = get_strength_nick (strength);
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->strength), nick);
gtk_button_set_label (GTK_BUTTON (editor->button), "Apply");
}
else
{
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->target_attr), "left");
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->source_attr), "left");
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->relation), "eq");
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->strength), "required");
gtk_editable_set_text (GTK_EDITABLE (editor->multiplier), "1.0");
gtk_editable_set_text (GTK_EDITABLE (editor->constant), "0.0");
gtk_button_set_label (GTK_BUTTON (editor->button), "Create");
}
editor->constructed = TRUE;
update_preview (editor);
update_button (editor);
}
static void
constraint_editor_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
ConstraintEditor *self = CONSTRAINT_EDITOR (object);
switch (property_id)
{
case PROP_MODEL:
self->model = g_value_dup_object (value);
break;
case PROP_CONSTRAINT:
self->constraint = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
constraint_editor_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
ConstraintEditor *self = CONSTRAINT_EDITOR (object);
switch (property_id)
{
case PROP_MODEL:
g_value_set_object (value, self->model);
break;
case PROP_CONSTRAINT:
g_value_set_object (value, self->constraint);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
constraint_editor_dispose (GObject *object)
{
ConstraintEditor *self = (ConstraintEditor *)object;
g_clear_pointer (&self->grid, gtk_widget_unparent);
g_clear_object (&self->model);
g_clear_object (&self->constraint);
G_OBJECT_CLASS (constraint_editor_parent_class)->dispose (object);
}
static void
constraint_editor_class_init (ConstraintEditorClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
object_class->constructed = constraint_editor_constructed;
object_class->dispose = constraint_editor_dispose;
object_class->set_property = constraint_editor_set_property;
object_class->get_property = constraint_editor_get_property;
pspecs[PROP_CONSTRAINT] =
g_param_spec_object ("constraint", "constraint", "constraint",
GTK_TYPE_CONSTRAINT,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY);
pspecs[PROP_MODEL] =
g_param_spec_object ("model", "model", "model",
G_TYPE_LIST_MODEL,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_properties (object_class, LAST_PROP, pspecs);
signals[DONE] =
g_signal_new ("done",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
NULL,
G_TYPE_NONE, 1, GTK_TYPE_CONSTRAINT);
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gtk/gtk4/constraint-editor/constraint-editor.ui");
gtk_widget_class_bind_template_child (widget_class, ConstraintEditor, grid);
gtk_widget_class_bind_template_child (widget_class, ConstraintEditor, target);
gtk_widget_class_bind_template_child (widget_class, ConstraintEditor, target_attr);
gtk_widget_class_bind_template_child (widget_class, ConstraintEditor, relation);
gtk_widget_class_bind_template_child (widget_class, ConstraintEditor, source);
gtk_widget_class_bind_template_child (widget_class, ConstraintEditor, source_attr);
gtk_widget_class_bind_template_child (widget_class, ConstraintEditor, multiplier);
gtk_widget_class_bind_template_child (widget_class, ConstraintEditor, constant);
gtk_widget_class_bind_template_child (widget_class, ConstraintEditor, strength);
gtk_widget_class_bind_template_child (widget_class, ConstraintEditor, preview);
gtk_widget_class_bind_template_child (widget_class, ConstraintEditor, button);
gtk_widget_class_bind_template_callback (widget_class, update_preview);
gtk_widget_class_bind_template_callback (widget_class, update_button);
gtk_widget_class_bind_template_callback (widget_class, create_constraint);
gtk_widget_class_bind_template_callback (widget_class, source_attr_changed);
}
ConstraintEditor *
constraint_editor_new (GListModel *model,
GtkConstraint *constraint)
{
return g_object_new (CONSTRAINT_EDITOR_TYPE,
"model", model,
"constraint", constraint,
NULL);
}

View File

@@ -0,0 +1,12 @@
constraintview {
background: black;
color: white;
}
constraintview .child {
background: red;
}
constraintview .guide {
background: blue;
}

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gtk/gtk4/constraint-editor">
<file preprocess="xml-stripblanks">constraint-editor-window.ui</file>
<file preprocess="xml-stripblanks">constraint-editor.ui</file>
<file preprocess="xml-stripblanks">guide-editor.ui</file>
<file>constraint-editor.css</file>
</gresource>
</gresources>

View File

@@ -0,0 +1,34 @@
/*
* Copyright © 2019 Red Hat, 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.1 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, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen
*/
#pragma once
#include <gtk/gtk.h>
#define CONSTRAINT_EDITOR_TYPE (constraint_editor_get_type ())
G_DECLARE_FINAL_TYPE (ConstraintEditor, constraint_editor, CONSTRAINT, EDITOR, GtkWidget)
ConstraintEditor * constraint_editor_new (GListModel *model,
GtkConstraint *constraint);
void constraint_editor_serialize_constraint (GString *str,
int indent,
GtkConstraint *constraint);
char *constraint_editor_constraint_to_string (GtkConstraint *constraint);

View File

@@ -0,0 +1,163 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="ConstraintEditor" parent="GtkWidget">
<child>
<object class="GtkGrid" id="grid">
<property name="margin">20</property>
<property name="row-spacing">10</property>
<property name="column-spacing">10</property>
<child>
<object class="GtkLabel">
<property name="label">Target</property>
<layout>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkComboBoxText" id="target">
<signal name="changed" handler="update_preview" swapped="yes"/>
<signal name="changed" handler="update_button" swapped="yes"/>
<layout>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkComboBoxText" id="target_attr">
<signal name="changed" handler="update_preview" swapped="yes"/>
<layout>
<property name="left-attach">2</property>
<property name="top-attach">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Relation</property>
<layout>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkComboBoxText" id="relation">
<signal name="changed" handler="update_preview" swapped="yes"/>
<layout>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Source</property>
<layout>
<property name="left-attach">0</property>
<property name="top-attach">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkComboBoxText" id="source">
<signal name="changed" handler="update_preview" swapped="yes"/>
<signal name="changed" handler="update_button" swapped="yes"/>
<layout>
<property name="left-attach">1</property>
<property name="top-attach">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkComboBoxText" id="source_attr">
<signal name="changed" handler="update_preview" swapped="yes"/>
<signal name="changed" handler="source_attr_changed" swapped="yes"/>
<layout>
<property name="left-attach">2</property>
<property name="top-attach">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Multiplier</property>
<layout>
<property name="left-attach">0</property>
<property name="top-attach">4</property>
</layout>
</object>
</child>
<child>
<object class="GtkEntry" id="multiplier">
<signal name="changed" handler="update_preview" swapped="yes"/>
<layout>
<property name="left-attach">1</property>
<property name="top-attach">4</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Constant</property>
<layout>
<property name="left-attach">0</property>
<property name="top-attach">5</property>
</layout>
</object>
</child>
<child>
<object class="GtkEntry" id="constant">
<signal name="changed" handler="update_preview" swapped="yes"/>
<layout>
<property name="left-attach">1</property>
<property name="top-attach">5</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Strength</property>
<layout>
<property name="left-attach">0</property>
<property name="top-attach">6</property>
</layout>
</object>
</child>
<child>
<object class="GtkComboBoxText" id="strength">
<layout>
<property name="left-attach">1</property>
<property name="top-attach">6</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="preview">
<property name="xalign">0</property>
<layout>
<property name="left-attach">1</property>
<property name="top-attach">7</property>
<property name="column-span">2</property>
</layout>
<attributes>
<attribute name="scale" value="1.44"/>
</attributes>
</object>
</child>
<child>
<object class="GtkButton" id="button">
<property name="label">Create</property>
<signal name="clicked" handler="create_constraint"/>
<layout>
<property name="left-attach">2</property>
<property name="top-attach">8</property>
</layout>
</object>
</child>
</object>
</child>
</template>
</interface>

View File

@@ -0,0 +1,93 @@
/*
* Copyright © 2019 Red Hat, 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.1 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, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen
*/
#include "constraint-view-child.h"
struct _ConstraintViewChild
{
GObject parent_instance;
char *name;
};
enum {
PROP_NAME = 1,
LAST_PROP
};
static GParamSpec props[LAST_PROP];
G_DEFINE_TYPE (ConstraintViewChild, constraint_view_child, G_TYPE_OBJECT)
static void
constraint_view_child_init (ConstraintViewChild *child)
{
}
static void
constraint_view_child_finalize (GObject *object)
{
ConstraintViewChild *child = CONSTRAINT_VIEW_CHILD (object);
g_free (child->name);
G_OBJECT_CLASS (constraint_view_child_parent_class)->finalize (object);
}
static void
constraint_view_child_set_property (GObject *object,
static void
constraint_view_child_class_init (ConstraintViewChildClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->finalize = constraint_view_child_finalize;
object_class->get_property = constraint_view_child_get_property;
object_class->set_property = constraint_view_child_set_property;
props[PROP_NAME] =
g_param_spec_string ("name", "name", "name",
NULL,
G_PARAM_READWRITE);
g_object_class_install_properties (object_class, LAST_PROP, props);
}
#define CONSTRAINT_VIEW_CHILD_TYPE (constraint_view_get_type ())
G_DECLARE_TYPE (ConstraintViewChild, constraint_view_child, CONSTRAINT, VIEW_CHILD, GObject)
#define CONSTRAINT_VIEW_WIDGET_TYPE (constraint_view_widget_get_type ())
G_DECLARE_FINAL_TYPE (ConstraintViewWidget, constraint_view_widget, CONSTRAINT, VIEW_WIDGET, ConstraintViewChild)
ConstraintViewWidget * constraint_view_widget_new (void);
#define CONSTRAINT_VIEW_GUIDE_TYPE (constraint_view_guide_get_type ())
G_DECLARE_FINAL_TYPE (ConstraintViewGuide, constraint_view_guide, CONSTRAINT, VIEW_GUIDE, ConstraintViewChild)
ConstraintViewGuide * constraint_view_guide_new (void);
#define CONSTRAINT_VIEW_CONSTRAINT_TYPE (constraint_view_constraint_get_type ())
G_DECLARE_FINAL_TYPE (ConstraintViewConstraint, constraint_view_constraint, CONSTRAINT, VIEW_CONSTRAINT, ConstraintViewChild)
ConstraintViewGuide * constraint_view_constraint_new (void);

View File

@@ -0,0 +1,44 @@
/*
* Copyright © 2019 Red Hat, 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.1 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, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen
*/
#pragma once
#include <gtk/gtk.h>
#define CONSTRAINT_VIEW_CHILD_TYPE (constraint_view_get_type ())
G_DECLARE_TYPE (ConstraintViewChild, constraint_view_child, CONSTRAINT, VIEW_CHILD, GObject)
#define CONSTRAINT_VIEW_WIDGET_TYPE (constraint_view_widget_get_type ())
G_DECLARE_FINAL_TYPE (ConstraintViewWidget, constraint_view_widget, CONSTRAINT, VIEW_WIDGET, ConstraintViewChild)
ConstraintViewWidget * constraint_view_widget_new (void);
#define CONSTRAINT_VIEW_GUIDE_TYPE (constraint_view_guide_get_type ())
G_DECLARE_FINAL_TYPE (ConstraintViewGuide, constraint_view_guide, CONSTRAINT, VIEW_GUIDE, ConstraintViewChild)
ConstraintViewGuide * constraint_view_guide_new (void);
#define CONSTRAINT_VIEW_CONSTRAINT_TYPE (constraint_view_constraint_get_type ())
G_DECLARE_FINAL_TYPE (ConstraintViewConstraint, constraint_view_constraint, CONSTRAINT, VIEW_CONSTRAINT, ConstraintViewChild)
ConstraintViewGuide * constraint_view_constraint_new (void);

View File

@@ -0,0 +1,343 @@
/* Copyright (C) 2019 Red Hat, 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, see <http://www.gnu.org/licenses/>.
*/
#include <gtk/gtk.h>
#include "constraint-view.h"
struct _ConstraintView
{
GtkWidget parent;
GListModel *model;
GtkWidget *drag_widget;
};
G_DEFINE_TYPE (ConstraintView, constraint_view, GTK_TYPE_WIDGET);
static void
constraint_view_dispose (GObject *object)
{
ConstraintView *view = CONSTRAINT_VIEW (object);
GtkWidget *child;
while ((child = gtk_widget_get_first_child (GTK_WIDGET (view))) != NULL)
gtk_widget_unparent (child);
g_clear_object (&view->model);
G_OBJECT_CLASS (constraint_view_parent_class)->dispose (object);
}
static void
constraint_view_class_init (ConstraintViewClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->dispose = constraint_view_dispose;
gtk_widget_class_set_css_name (widget_class, "constraintview");
}
static void
update_weak_position (ConstraintView *self,
GtkWidget *child,
double x,
double y)
{
GtkLayoutManager *manager;
GtkConstraint *constraint;
manager = gtk_widget_get_layout_manager (GTK_WIDGET (self));
constraint = (GtkConstraint *)g_object_get_data (G_OBJECT (child), "x-constraint");
if (constraint)
{
gtk_constraint_layout_remove_constraint (GTK_CONSTRAINT_LAYOUT (manager),
constraint);
g_object_set_data (G_OBJECT (child), "x-constraint", NULL);
}
if (x != -100)
{
constraint = gtk_constraint_new_constant (child,
GTK_CONSTRAINT_ATTRIBUTE_CENTER_X,
GTK_CONSTRAINT_RELATION_EQ,
x,
GTK_CONSTRAINT_STRENGTH_WEAK);
g_object_set_data (G_OBJECT (constraint), "internal", "yes");
gtk_constraint_layout_add_constraint (GTK_CONSTRAINT_LAYOUT (manager),
constraint);
g_object_set_data (G_OBJECT (child), "x-constraint", constraint);
}
constraint = (GtkConstraint *)g_object_get_data (G_OBJECT (child), "y-constraint");
if (constraint)
{
gtk_constraint_layout_remove_constraint (GTK_CONSTRAINT_LAYOUT (manager),
constraint);
g_object_set_data (G_OBJECT (child), "y-constraint", NULL);
}
if (y != -100)
{
constraint = gtk_constraint_new_constant (child,
GTK_CONSTRAINT_ATTRIBUTE_CENTER_Y,
GTK_CONSTRAINT_RELATION_EQ,
y,
GTK_CONSTRAINT_STRENGTH_WEAK);
g_object_set_data (G_OBJECT (constraint), "internal", "yes");
gtk_constraint_layout_add_constraint (GTK_CONSTRAINT_LAYOUT (manager),
constraint);
g_object_set_data (G_OBJECT (child), "y-constraint", constraint);
}
}
static void
drag_begin (GtkGestureDrag *drag,
double start_x,
double start_y,
ConstraintView *self)
{
GtkWidget *widget;
widget = gtk_widget_pick (GTK_WIDGET (self), start_x, start_y, GTK_PICK_DEFAULT);
if (GTK_IS_LABEL (widget))
{
widget = gtk_widget_get_ancestor (widget, GTK_TYPE_FRAME);
if (widget &&
gtk_widget_get_parent (widget) == (GtkWidget *)self)
{
self->drag_widget = widget;
}
}
}
static void
drag_update (GtkGestureDrag *drag,
double offset_x,
double offset_y,
ConstraintView *self)
{
double x, y;
if (!self->drag_widget)
return;
gtk_gesture_drag_get_start_point (drag, &x, &y);
update_weak_position (self, self->drag_widget, x + offset_x, y + offset_y);
}
static void
drag_end (GtkGestureDrag *drag,
double offset_x,
double offset_y,
ConstraintView *self)
{
self->drag_widget = NULL;
}
static gboolean
omit_internal (gpointer item, gpointer user_data)
{
if (g_object_get_data (G_OBJECT (item), "internal"))
return FALSE;
return TRUE;
}
static void
constraint_view_init (ConstraintView *self)
{
GtkLayoutManager *manager;
GtkEventController *controller;
GListStore *list;
GListModel *all_children;
GListModel *all_constraints;
GListModel *guides;
GListModel *children;
GListModel *constraints;
manager = gtk_constraint_layout_new ();
gtk_widget_set_layout_manager (GTK_WIDGET (self), manager);
all_children = gtk_widget_observe_children (GTK_WIDGET (self));
all_constraints = gtk_constraint_layout_observe_constraints (GTK_CONSTRAINT_LAYOUT (manager));
guides = gtk_constraint_layout_observe_guides (GTK_CONSTRAINT_LAYOUT (manager));
constraints = (GListModel *)gtk_filter_list_model_new (all_constraints, omit_internal, NULL, NULL);
children = (GListModel *)gtk_filter_list_model_new (all_children, omit_internal, NULL, NULL);
list = g_list_store_new (G_TYPE_LIST_MODEL);
g_list_store_append (list, children);
g_list_store_append (list, guides);
g_list_store_append (list, constraints);
self->model = G_LIST_MODEL (gtk_flatten_list_model_new (G_TYPE_OBJECT, G_LIST_MODEL (list)));
g_object_unref (children);
g_object_unref (guides);
g_object_unref (constraints);
g_object_unref (all_children);
g_object_unref (all_constraints);
g_object_unref (list);
controller = (GtkEventController *)gtk_gesture_drag_new ();
g_signal_connect (controller, "drag-begin", G_CALLBACK (drag_begin), self);
g_signal_connect (controller, "drag-update", G_CALLBACK (drag_update), self);
g_signal_connect (controller, "drag-end", G_CALLBACK (drag_end), self);
gtk_widget_add_controller (GTK_WIDGET (self), controller);
}
ConstraintView *
constraint_view_new (void)
{
return g_object_new (CONSTRAINT_VIEW_TYPE, NULL);
}
void
constraint_view_add_child (ConstraintView *view,
const char *name)
{
GtkWidget *frame;
GtkWidget *label;
label = gtk_label_new (name);
frame = gtk_frame_new (NULL);
gtk_style_context_add_class (gtk_widget_get_style_context (frame), "child");
gtk_widget_set_name (frame, name);
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_widget_set_parent (frame, GTK_WIDGET (view));
update_weak_position (view, frame, 100, 100);
}
void
constraint_view_remove_child (ConstraintView *view,
GtkWidget *child)
{
update_weak_position (view, child, -100, -100);
gtk_widget_unparent (child);
}
void
constraint_view_add_guide (ConstraintView *view,
GtkConstraintGuide *guide)
{
GtkConstraintLayout *layout;
GtkWidget *frame;
GtkWidget *label;
const char *name;
GtkConstraint *constraint;
struct {
const char *name;
GtkConstraintAttribute attr;
} names[] = {
{ "left-constraint", GTK_CONSTRAINT_ATTRIBUTE_LEFT },
{ "top-constraint", GTK_CONSTRAINT_ATTRIBUTE_TOP },
{ "width-constraint", GTK_CONSTRAINT_ATTRIBUTE_WIDTH },
{ "height-constraint", GTK_CONSTRAINT_ATTRIBUTE_HEIGHT },
};
int i;
name = gtk_constraint_guide_get_name (guide);
label = gtk_label_new (name);
g_object_bind_property (guide, "name",
label, "label",
G_BINDING_DEFAULT);
frame = gtk_frame_new (NULL);
gtk_style_context_add_class (gtk_widget_get_style_context (frame), "guide");
g_object_set_data (G_OBJECT (frame), "internal", "yes");
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_widget_insert_after (frame, GTK_WIDGET (view), NULL);
g_object_set_data (G_OBJECT (guide), "frame", frame);
layout = GTK_CONSTRAINT_LAYOUT (gtk_widget_get_layout_manager (GTK_WIDGET (view)));
gtk_constraint_layout_add_guide (layout, g_object_ref (guide));
for (i = 0; i < G_N_ELEMENTS (names); i++)
{
constraint = gtk_constraint_new (frame,
names[i].attr,
GTK_CONSTRAINT_RELATION_EQ,
guide,
names[i].attr,
1.0, 0.0,
GTK_CONSTRAINT_STRENGTH_REQUIRED);
g_object_set_data (G_OBJECT (constraint), "internal", "yes");
gtk_constraint_layout_add_constraint (layout, constraint);
g_object_set_data (G_OBJECT (guide), names[i].name, constraint);
}
update_weak_position (view, frame, 150, 150);
}
void
constraint_view_remove_guide (ConstraintView *view,
GtkConstraintGuide *guide)
{
GtkConstraintLayout *layout;
GtkWidget *frame;
GtkConstraint *constraint;
const char *names[] = {
"left-constraint",
"top-constraint",
"width-constraint",
"height-constraint"
};
int i;
layout = GTK_CONSTRAINT_LAYOUT (gtk_widget_get_layout_manager (GTK_WIDGET (view)));
for (i = 0; i < G_N_ELEMENTS (names); i++)
{
constraint = (GtkConstraint*)g_object_get_data (G_OBJECT (guide), names[i]);
gtk_constraint_layout_remove_constraint (layout, constraint);
}
frame = (GtkWidget *)g_object_get_data (G_OBJECT (guide), "frame");
update_weak_position (view, frame, -100, -100);
gtk_widget_unparent (frame);
gtk_constraint_layout_remove_guide (layout, guide);
}
void
constraint_view_add_constraint (ConstraintView *view,
GtkConstraint *constraint)
{
GtkLayoutManager *manager;
manager = gtk_widget_get_layout_manager (GTK_WIDGET (view));
gtk_constraint_layout_add_constraint (GTK_CONSTRAINT_LAYOUT (manager),
g_object_ref (constraint));
}
void
constraint_view_remove_constraint (ConstraintView *view,
GtkConstraint *constraint)
{
GtkLayoutManager *manager;
manager = gtk_widget_get_layout_manager (GTK_WIDGET (view));
gtk_constraint_layout_remove_constraint (GTK_CONSTRAINT_LAYOUT (manager),
constraint);
}
GListModel *
constraint_view_get_model (ConstraintView *view)
{
return view->model;
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright © 2019 Red Hat, 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.1 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, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen
*/
#pragma once
#include <gtk/gtk.h>
#define CONSTRAINT_VIEW_TYPE (constraint_view_get_type ())
G_DECLARE_FINAL_TYPE (ConstraintView, constraint_view, CONSTRAINT, VIEW, GtkWidget)
ConstraintView * constraint_view_new (void);
void constraint_view_add_child (ConstraintView *view,
const char *name);
void constraint_view_remove_child (ConstraintView *view,
GtkWidget *child);
void constraint_view_add_guide (ConstraintView *view,
GtkConstraintGuide *guide);
void constraint_view_remove_guide (ConstraintView *view,
GtkConstraintGuide *guide);
void constraint_view_guide_changed (ConstraintView *view,
GtkConstraintGuide *guide);
void constraint_view_add_constraint (ConstraintView *view,
GtkConstraint *constraint);
void constraint_view_remove_constraint (ConstraintView *view,
GtkConstraint *constraint);
GListModel * constraint_view_get_model (ConstraintView *view);

View File

@@ -0,0 +1,411 @@
/*
* Copyright © 2019 Red Hat, 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.1 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, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen
*/
#include "config.h"
#include "guide-editor.h"
struct _GuideEditor
{
GtkWidget parent_instance;
GtkWidget *grid;
GtkWidget *name;
GtkWidget *min_width;
GtkWidget *min_height;
GtkWidget *nat_width;
GtkWidget *nat_height;
GtkWidget *max_width;
GtkWidget *max_height;
GtkWidget *strength;
GtkWidget *button;
GtkConstraintGuide *guide;
gboolean constructed;
};
enum {
PROP_GUIDE = 1,
LAST_PROP
};
static GParamSpec *pspecs[LAST_PROP];
enum {
DONE,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL];
G_DEFINE_TYPE(GuideEditor, guide_editor, GTK_TYPE_WIDGET);
static void
guide_strength_combo (GtkWidget *combo)
{
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "weak", "Weak");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "medium", "Medium");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "strong", "Strong");
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "required", "Required");
}
static GtkConstraintStrength
get_strength (const char *id)
{
GtkConstraintStrength strength;
GEnumClass *class = g_type_class_ref (GTK_TYPE_CONSTRAINT_STRENGTH);
GEnumValue *value = g_enum_get_value_by_nick (class, id);
strength = value->value;
g_type_class_unref (class);
return strength;
}
const char *
get_strength_nick (GtkConstraintStrength strength)
{
GEnumClass *class = g_type_class_ref (GTK_TYPE_CONSTRAINT_STRENGTH);
GEnumValue *value = g_enum_get_value (class, strength);
const char *nick = value->value_nick;
g_type_class_unref (class);
return nick;
}
void
guide_editor_serialize_guide (GString *str,
int indent,
GtkConstraintGuide *guide)
{
int min_width, min_height;
int nat_width, nat_height;
int max_width, max_height;
const char *name;
const char *strength;
gtk_constraint_guide_get_min_size (guide, &min_width, &min_height);
gtk_constraint_guide_get_nat_size (guide, &nat_width, &nat_height);
gtk_constraint_guide_get_max_size (guide, &max_width, &max_height);
name = gtk_constraint_guide_get_name (guide);
strength = get_strength_nick (gtk_constraint_guide_get_strength (guide));
g_string_append_printf (str, "%*s<guide min-width=\"%d\" min-height=\"%d\"\n", indent, "", min_width, min_height);
g_string_append_printf (str, "%*s nat-width=\"%d\" nat-height=\"%d\"\n", indent, "", nat_width, nat_height);
g_string_append_printf (str, "%*s max-width=\"%d\" max-height=\"%d\"\n", indent, "", max_width, max_height);
g_string_append_printf (str, "%*s name=\"%s\" strength=\"%s\" />\n", indent, "", name, strength);
}
static void
create_guide (GtkButton *button,
GuideEditor *editor)
{
const char *id;
int strength;
const char *name;
int w, h;
GtkConstraintGuide *guide;
if (editor->guide)
guide = g_object_ref (editor->guide);
else
guide = gtk_constraint_guide_new ();
name = gtk_editable_get_text (GTK_EDITABLE (editor->name));
gtk_constraint_guide_set_name (guide, name);
w = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (editor->min_width));
h = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (editor->min_height));
gtk_constraint_guide_set_min_size (guide, w, h);
w = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (editor->nat_width));
h = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (editor->nat_height));
gtk_constraint_guide_set_nat_size (guide, w, h);
w = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (editor->max_width));
h = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (editor->max_height));
gtk_constraint_guide_set_max_size (guide, w, h);
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (editor->strength));
strength = get_strength (id);
gtk_constraint_guide_set_strength (guide, strength);
g_signal_emit (editor, signals[DONE], 0, guide);
g_object_unref (guide);
}
static void
guide_editor_init (GuideEditor *editor)
{
gtk_widget_init_template (GTK_WIDGET (editor));
}
static int guide_counter;
static int
min_input (GtkSpinButton *spin_button,
double *new_val)
{
if (strcmp (gtk_editable_get_text (GTK_EDITABLE (spin_button)), "") == 0)
{
*new_val = 0.0;
return TRUE;
}
return FALSE;
}
static int
max_input (GtkSpinButton *spin_button,
double *new_val)
{
if (strcmp (gtk_editable_get_text (GTK_EDITABLE (spin_button)), "") == 0)
{
*new_val = G_MAXINT;
return TRUE;
}
return FALSE;
}
static gboolean
min_output (GtkSpinButton *spin_button)
{
GtkAdjustment *adjustment;
double value;
GtkWidget *box, *text;
adjustment = gtk_spin_button_get_adjustment (spin_button);
value = gtk_adjustment_get_value (adjustment);
box = gtk_widget_get_first_child (GTK_WIDGET (spin_button));
text = gtk_widget_get_first_child (box);
if (value == 0.0)
{
gtk_editable_set_text (GTK_EDITABLE (spin_button), "");
gtk_text_set_placeholder_text (GTK_TEXT (text), "unset");
return TRUE;
}
else
{
gtk_text_set_placeholder_text (GTK_TEXT (text), "");
return FALSE;
}
}
static gboolean
max_output (GtkSpinButton *spin_button)
{
GtkAdjustment *adjustment;
double value;
GtkWidget *box, *text;
adjustment = gtk_spin_button_get_adjustment (spin_button);
value = gtk_adjustment_get_value (adjustment);
box = gtk_widget_get_first_child (GTK_WIDGET (spin_button));
text = gtk_widget_get_first_child (box);
if (value == (double)G_MAXINT)
{
gtk_editable_set_text (GTK_EDITABLE (spin_button), "");
gtk_text_set_placeholder_text (GTK_TEXT (text), "unset");
return TRUE;
}
else
{
gtk_text_set_placeholder_text (GTK_TEXT (text), "");
return FALSE;
}
}
static void
guide_editor_constructed (GObject *object)
{
GuideEditor *editor = GUIDE_EDITOR (object);
guide_strength_combo (editor->strength);
g_signal_connect (editor->min_width, "input", G_CALLBACK (min_input), NULL);
g_signal_connect (editor->min_width, "output", G_CALLBACK (min_output), NULL);
g_signal_connect (editor->min_height, "input", G_CALLBACK (min_input), NULL);
g_signal_connect (editor->min_height, "output", G_CALLBACK (min_output), NULL);
g_signal_connect (editor->max_width, "input", G_CALLBACK (max_input), NULL);
g_signal_connect (editor->max_width, "output", G_CALLBACK (max_output), NULL);
g_signal_connect (editor->max_height, "input", G_CALLBACK (max_input), NULL);
g_signal_connect (editor->max_height, "output", G_CALLBACK (max_output), NULL);
if (editor->guide)
{
GtkConstraintStrength strength;
const char *nick;
int w, h;
nick = gtk_constraint_guide_get_name (editor->guide);
if (nick)
gtk_editable_set_text (GTK_EDITABLE (editor->name), nick);
gtk_constraint_guide_get_min_size (editor->guide, &w, &h);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->min_width), w);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->min_height), h);
gtk_constraint_guide_get_nat_size (editor->guide, &w, &h);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->nat_width), w);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->nat_height), h);
gtk_constraint_guide_get_max_size (editor->guide, &w, &h);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->max_width), w);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->max_height), h);
strength = gtk_constraint_guide_get_strength (editor->guide);
nick = get_strength_nick (strength);
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->strength), nick);
gtk_button_set_label (GTK_BUTTON (editor->button), "Apply");
}
else
{
char *name;
guide_counter++;
name = g_strdup_printf ("Guide %d", guide_counter);
gtk_editable_set_text (GTK_EDITABLE (editor->name), name);
g_free (name);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->min_width), 0.0);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->min_height), 0.0);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->nat_width), 0.0);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->nat_height), 0.0);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->max_width), G_MAXINT);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->max_height), G_MAXINT);
gtk_combo_box_set_active_id (GTK_COMBO_BOX (editor->strength), "medium");
gtk_button_set_label (GTK_BUTTON (editor->button), "Create");
}
editor->constructed = TRUE;
}
static void
guide_editor_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GuideEditor *self = GUIDE_EDITOR (object);
switch (property_id)
{
case PROP_GUIDE:
self->guide = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
guide_editor_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GuideEditor *self = GUIDE_EDITOR (object);
switch (property_id)
{
case PROP_GUIDE:
g_value_set_object (value, self->guide);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
guide_editor_dispose (GObject *object)
{
GuideEditor *self = (GuideEditor *)object;
g_clear_pointer (&self->grid, gtk_widget_unparent);
g_clear_object (&self->guide);
G_OBJECT_CLASS (guide_editor_parent_class)->dispose (object);
}
static void
guide_editor_class_init (GuideEditorClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
object_class->constructed = guide_editor_constructed;
object_class->dispose = guide_editor_dispose;
object_class->set_property = guide_editor_set_property;
object_class->get_property = guide_editor_get_property;
pspecs[PROP_GUIDE] =
g_param_spec_object ("guide", "guide", "guide",
GTK_TYPE_CONSTRAINT_GUIDE,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_properties (object_class, LAST_PROP, pspecs);
signals[DONE] =
g_signal_new ("done",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
NULL,
G_TYPE_NONE, 1, GTK_TYPE_CONSTRAINT_GUIDE);
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gtk/gtk4/constraint-editor/guide-editor.ui");
gtk_widget_class_bind_template_child (widget_class, GuideEditor, grid);
gtk_widget_class_bind_template_child (widget_class, GuideEditor, name);
gtk_widget_class_bind_template_child (widget_class, GuideEditor, min_width);
gtk_widget_class_bind_template_child (widget_class, GuideEditor, min_height);
gtk_widget_class_bind_template_child (widget_class, GuideEditor, nat_width);
gtk_widget_class_bind_template_child (widget_class, GuideEditor, nat_height);
gtk_widget_class_bind_template_child (widget_class, GuideEditor, max_width);
gtk_widget_class_bind_template_child (widget_class, GuideEditor, max_height);
gtk_widget_class_bind_template_child (widget_class, GuideEditor, strength);
gtk_widget_class_bind_template_child (widget_class, GuideEditor, button);
gtk_widget_class_bind_template_callback (widget_class, create_guide);
}
GuideEditor *
guide_editor_new (GtkConstraintGuide *guide)
{
return g_object_new (GUIDE_EDITOR_TYPE,
"guide", guide,
NULL);
}

View File

@@ -0,0 +1,32 @@
/*
* Copyright © 2019 Red Hat, 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.1 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, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen
*/
#pragma once
#include <gtk/gtk.h>
#define GUIDE_EDITOR_TYPE (guide_editor_get_type ())
G_DECLARE_FINAL_TYPE (GuideEditor, guide_editor, GUIDE, EDITOR, GtkWidget)
GuideEditor * guide_editor_new (GtkConstraintGuide *guide);
void guide_editor_serialize_guide (GString *str,
int indent,
GtkConstraintGuide *guide);

View File

@@ -0,0 +1,188 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkAdjustment" id="min_width_adj">
<property name="lower">0</property>
<property name="upper">2147483647</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
<property name="page-size">0</property>
</object>
<object class="GtkAdjustment" id="min_height_adj">
<property name="lower">0</property>
<property name="upper">2147483647</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
<property name="page-size">0</property>
</object>
<object class="GtkAdjustment" id="nat_width_adj">
<property name="lower">0</property>
<property name="upper">2147483647</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
<property name="page-size">0</property>
</object>
<object class="GtkAdjustment" id="nat_height_adj">
<property name="lower">0</property>
<property name="upper">2147483647</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
<property name="page-size">0</property>
</object>
<object class="GtkAdjustment" id="max_width_adj">
<property name="lower">0</property>
<property name="upper">2147483647</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
<property name="page-size">0</property>
</object>
<object class="GtkAdjustment" id="max_height_adj">
<property name="lower">0</property>
<property name="upper">2147483647</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
<property name="page-size">0</property>
</object>
<template class="GuideEditor" parent="GtkWidget">
<child>
<object class="GtkGrid" id="grid">
<property name="margin">20</property>
<property name="row-spacing">10</property>
<property name="column-spacing">10</property>
<child>
<object class="GtkLabel">
<property name="label">Name</property>
<layout>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkEntry" id="name">
<property name="max-width-chars">20</property>
<layout>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
<property name="column-span">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Min Size</property>
<layout>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkSpinButton" id="min_width">
<property name="adjustment">min_width_adj</property>
<property name="max-width-chars">5</property>
<layout>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkSpinButton" id="min_height">
<property name="adjustment">min_height_adj</property>
<property name="max-width-chars">5</property>
<layout>
<property name="left-attach">2</property>
<property name="top-attach">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Nat Size</property>
<layout>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkSpinButton" id="nat_width">
<property name="adjustment">nat_width_adj</property>
<property name="max-width-chars">5</property>
<layout>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkSpinButton" id="nat_height">
<property name="adjustment">nat_height_adj</property>
<property name="max-width-chars">5</property>
<layout>
<property name="left-attach">2</property>
<property name="top-attach">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Max Size</property>
<layout>
<property name="left-attach">0</property>
<property name="top-attach">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkSpinButton" id="max_width">
<property name="adjustment">max_width_adj</property>
<property name="max-width-chars">5</property>
<layout>
<property name="left-attach">1</property>
<property name="top-attach">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkSpinButton" id="max_height">
<property name="adjustment">max_height_adj</property>
<property name="max-width-chars">5</property>
<layout>
<property name="left-attach">2</property>
<property name="top-attach">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Strength</property>
<layout>
<property name="left-attach">0</property>
<property name="top-attach">4</property>
</layout>
</object>
</child>
<child>
<object class="GtkComboBoxText" id="strength">
<layout>
<property name="left-attach">1</property>
<property name="top-attach">4</property>
<property name="column-span">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkButton" id="button">
<property name="label">Create</property>
<signal name="clicked" handler="create_guide"/>
<layout>
<property name="left-attach">2</property>
<property name="top-attach">5</property>
</layout>
</object>
</child>
</object>
</child>
</template>
</interface>

View File

@@ -0,0 +1,28 @@
/*
* Copyright © 2019 Red Hat, 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.1 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, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen <mclasen@redhat.com>
*/
#include "config.h"
#include <constraint-editor-application.h>
int
main (int argc, char *argv[])
{
return g_application_run (G_APPLICATION (constraint_editor_application_new ()), argc, argv);
}

View File

@@ -0,0 +1,20 @@
constraint_editor_sources = [
'main.c',
'constraint-editor-application.c',
'constraint-editor-window.c',
'constraint-view.c',
'constraint-editor.c',
'guide-editor.c',
]
constraint_editor_resources = gnome.compile_resources('constraint_editor_resources',
'constraint-editor.gresource.xml',
source_dir: '.')
executable('gtk4-constraint-editor',
constraint_editor_sources, constraint_editor_resources,
dependencies: libgtk_dep,
include_directories: confinc,
gui_app: true,
link_args: extra_demo_ldflags,
install: false)

View File

@@ -419,7 +419,7 @@ demo_application_window_load_state (DemoApplicationWindow *win)
static void
demo_application_window_init (DemoApplicationWindow *window)
{
GtkWidget *menu;
GtkWidget *popover;
window->width = -1;
window->height = -1;
@@ -428,8 +428,8 @@ demo_application_window_init (DemoApplicationWindow *window)
gtk_widget_init_template (GTK_WIDGET (window));
menu = gtk_menu_new_from_model (window->toolmenu);
gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (window->menutool), menu);
popover = gtk_popover_menu_new_from_model (window->menutool, window->toolmenu);
gtk_menu_tool_button_set_popover (GTK_MENU_TOOL_BUTTON (window->menutool), popover);
g_action_map_add_action_entries (G_ACTION_MAP (window),
win_entries, G_N_ELEMENTS (win_entries),

View File

@@ -43,25 +43,17 @@
<object class="GtkInfoBar" id="infobar">
<property name="visible">0</property>
<property name="hexpand">1</property>
<child internal-child="content_area">
<object class="GtkBox" id="content_area">
<child>
<object class="GtkLabel" id="message">
<property name="hexpand">1</property>
</object>
</child>
<child>
<object class="GtkLabel" id="message">
<property name="hexpand">1</property>
</object>
</child>
<child internal-child="action_area">
<object class="GtkBox">
<child>
<object class="GtkButton">
<property name="valign">center</property>
<property name="label" translatable="yes">_OK</property>
<property name="use-underline">1</property>
<signal name="clicked" handler="clicked_cb"/>
</object>
</child>
<child type="action">
<object class="GtkButton">
<property name="valign">center</property>
<property name="label" translatable="yes">_OK</property>
<property name="use-underline">1</property>
<signal name="clicked" handler="clicked_cb"/>
</object>
</child>
<layout>

View File

@@ -94,6 +94,7 @@ create_page1 (GtkWidget *assistant)
GtkWidget *box, *label, *entry;
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
g_object_set (box, "margin", 12, NULL);
label = gtk_label_new ("You must fill out this entry to continue:");
gtk_container_add (GTK_CONTAINER (box), label);
@@ -115,10 +116,12 @@ create_page2 (GtkWidget *assistant)
{
GtkWidget *box, *checkbutton;
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
g_object_set (box, "margin", 12, NULL);
checkbutton = gtk_check_button_new_with_label ("This is optional data, you may continue "
"even if you do not check this");
gtk_widget_set_valign (checkbutton, GTK_ALIGN_CENTER);
gtk_container_add (GTK_CONTAINER (box), checkbutton);
gtk_assistant_append_page (GTK_ASSISTANT (assistant), box);

View File

@@ -38,7 +38,22 @@ help_activate (GSimpleAction *action,
g_print ("Help not available\n");
}
static void
not_implemented (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
g_print ("Action “%s” not implemented\n", g_action_get_name (G_ACTION (action)));
}
static GActionEntry win_entries[] = {
{ "new", not_implemented, NULL, NULL, NULL },
{ "open", not_implemented, NULL, NULL, NULL },
{ "save", not_implemented, NULL, NULL, NULL },
{ "save-as", not_implemented, NULL, NULL, NULL },
{ "copy", not_implemented, NULL, NULL, NULL },
{ "cut", not_implemented, NULL, NULL, NULL },
{ "paste", not_implemented, NULL, NULL, NULL },
{ "quit", quit_activate, NULL, NULL, NULL },
{ "about", about_activate, NULL, NULL, NULL },
{ "help", help_activate, NULL, NULL, NULL }
@@ -50,8 +65,6 @@ do_builder (GtkWidget *do_widget)
static GtkWidget *window = NULL;
GtkWidget *toolbar;
GActionGroup *actions;
GtkAccelGroup *accel_group;
GtkWidget *item;
if (!window)
{
@@ -59,7 +72,6 @@ do_builder (GtkWidget *do_widget)
builder = gtk_builder_new_from_resource ("/builder/demo.ui");
gtk_builder_connect_signals (builder, NULL);
window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
@@ -73,44 +85,6 @@ do_builder (GtkWidget *do_widget)
win_entries, G_N_ELEMENTS (win_entries),
window);
gtk_widget_insert_action_group (window, "win", actions);
accel_group = gtk_accel_group_new ();
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
item = (GtkWidget*)gtk_builder_get_object (builder, "new_item");
gtk_widget_add_accelerator (item, "activate", accel_group,
GDK_KEY_n, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
item = (GtkWidget*)gtk_builder_get_object (builder, "open_item");
gtk_widget_add_accelerator (item, "activate", accel_group,
GDK_KEY_o, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
item = (GtkWidget*)gtk_builder_get_object (builder, "save_item");
gtk_widget_add_accelerator (item, "activate", accel_group,
GDK_KEY_s, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
item = (GtkWidget*)gtk_builder_get_object (builder, "quit_item");
gtk_widget_add_accelerator (item, "activate", accel_group,
GDK_KEY_q, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
item = (GtkWidget*)gtk_builder_get_object (builder, "copy_item");
gtk_widget_add_accelerator (item, "activate", accel_group,
GDK_KEY_c, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
item = (GtkWidget*)gtk_builder_get_object (builder, "cut_item");
gtk_widget_add_accelerator (item, "activate", accel_group,
GDK_KEY_x, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
item = (GtkWidget*)gtk_builder_get_object (builder, "paste_item");
gtk_widget_add_accelerator (item, "activate", accel_group,
GDK_KEY_v, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
item = (GtkWidget*)gtk_builder_get_object (builder, "help_item");
gtk_widget_add_accelerator (item, "activate", accel_group,
GDK_KEY_F1, 0, GTK_ACCEL_VISIBLE);
item = (GtkWidget*)gtk_builder_get_object (builder, "about_item");
gtk_widget_add_accelerator (item, "activate", accel_group,
GDK_KEY_F7, 0, GTK_ACCEL_VISIBLE);
g_object_set_data_full (G_OBJECT(window), "builder", builder, g_object_unref);
}

View File

@@ -1,551 +0,0 @@
/* Change Display
*
* Demonstrates migrating a window between different displays.
* A display is a mouse and keyboard with some number of
* associated monitors. The neat thing about having multiple
* displays is that they can be on a completely separate
* computers, as long as there is a network connection to the
* computer where the application is running.
*
* Only some of the windowing systems where GTK runs have the
* concept of multiple displays. (The X Window System is the
* main example.) Other windowing systems can only handle one
* keyboard and mouse, and combine all monitors into
* a single display.
*
* This is a moderately complex example, and demonstrates:
*
* - Tracking the currently open displays
*
* - Changing the display for a window
*
* - Letting the user choose a window by clicking on it
*
* - Using GtkListStore and GtkTreeView
*
* - Using GtkDialog
*/
#include <string.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
/* The ChangeDisplayInfo structure corresponds to a toplevel window and
* holds pointers to widgets inside the toplevel window along with other
* information about the contents of the window.
* This is a common organizational structure in real applications.
*/
typedef struct _ChangeDisplayInfo ChangeDisplayInfo;
struct _ChangeDisplayInfo
{
GtkWidget *window;
GtkSizeGroup *size_group;
GtkTreeModel *display_model;
GdkDisplay *current_display;
};
/* These enumerations provide symbolic names for the columns
* in the two GtkListStore models.
*/
enum
{
DISPLAY_COLUMN_NAME,
DISPLAY_COLUMN_DISPLAY,
DISPLAY_NUM_COLUMNS
};
enum
{
SCREEN_COLUMN_NUMBER,
SCREEN_COLUMN_SCREEN,
SCREEN_NUM_COLUMNS
};
/* Finds the toplevel window under the mouse pointer, if any.
*/
static GtkWidget *
find_toplevel_at_pointer (GdkDisplay *display)
{
GdkSurface *pointer_window;
GtkWidget *widget = NULL;
pointer_window = gdk_device_get_surface_at_position (gtk_get_current_event_device (), NULL, NULL);
if (pointer_window)
widget = GTK_WIDGET (gtk_native_get_for_surface (pointer_window));
return widget;
}
static void
released_cb (GtkGestureClick *gesture,
guint n_press,
gdouble x,
gdouble y,
gboolean *clicked)
{
*clicked = TRUE;
}
/* Asks the user to click on a window, then waits for them click
* the mouse. When the mouse is released, returns the toplevel
* window under the pointer, or NULL, if there is none.
*/
static GtkWidget *
query_for_toplevel (GdkDisplay *display,
const char *prompt)
{
GtkWidget *popup, *label, *frame;
GdkCursor *cursor;
GtkWidget *toplevel = NULL;
GdkDevice *device;
popup = gtk_window_new (GTK_WINDOW_POPUP);
gtk_window_set_display (GTK_WINDOW (popup), display);
gtk_window_set_modal (GTK_WINDOW (popup), TRUE);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_container_add (GTK_CONTAINER (popup), frame);
label = gtk_label_new (prompt);
g_object_set (label, "margin", 10, NULL);
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_widget_show (popup);
cursor = gdk_cursor_new_from_name ("crosshair", NULL);
device = gtk_get_current_event_device ();
if (gdk_seat_grab (gdk_device_get_seat (device),
gtk_native_get_surface (GTK_NATIVE (popup)),
GDK_SEAT_CAPABILITY_ALL_POINTING,
FALSE, cursor, NULL, NULL, NULL) == GDK_GRAB_SUCCESS)
{
GtkGesture *gesture = gtk_gesture_click_new ();
gboolean clicked = FALSE;
g_signal_connect (gesture, "released",
G_CALLBACK (released_cb), &clicked);
gtk_widget_add_controller (popup, GTK_EVENT_CONTROLLER (gesture));
/* Process events until clicked is set by our button release event handler.
* We pass in may_block=TRUE since we want to wait if there
* are no events currently.
*/
while (!clicked)
g_main_context_iteration (NULL, TRUE);
gdk_seat_ungrab (gdk_device_get_seat (device));
toplevel = find_toplevel_at_pointer (display);
if (toplevel == popup)
toplevel = NULL;
}
g_object_unref (cursor);
gtk_widget_destroy (popup);
return toplevel;
}
/* Prompts the user for a toplevel window to move, and then moves
* that window to the currently selected display
*/
static void
query_change_display (ChangeDisplayInfo *info)
{
GdkDisplay *display = gtk_widget_get_display (info->window);
GtkWidget *toplevel;
toplevel = query_for_toplevel (display,
"Please select the toplevel\n"
"to move to the new display");
if (toplevel)
gtk_window_set_display (GTK_WINDOW (toplevel), info->current_display);
else
gdk_display_beep (display);
}
/* Called when the user clicks on a button in our dialog or
* closes the dialog through the window manager. Unless the
* "Change" button was clicked, we destroy the dialog.
*/
static void
response_cb (GtkDialog *dialog,
gint response_id,
ChangeDisplayInfo *info)
{
if (response_id == GTK_RESPONSE_OK)
query_change_display (info);
else
gtk_widget_destroy (GTK_WIDGET (dialog));
}
/* Called when the user clicks on "Open..." in the display
* frame. Prompts for a new display, and then opens a connection
* to that display.
*/
static void
open_display_cb (GtkWidget *button,
ChangeDisplayInfo *info)
{
GtkWidget *content_area;
GtkWidget *dialog;
GtkWidget *display_entry;
GtkWidget *dialog_label;
gchar *new_screen_name = NULL;
GdkDisplay *result = NULL;
dialog = gtk_dialog_new_with_buttons ("Open Display",
GTK_WINDOW (info->window),
GTK_DIALOG_MODAL,
_("_Cancel"), GTK_RESPONSE_CANCEL,
_("_OK"), GTK_RESPONSE_OK,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
display_entry = gtk_entry_new ();
gtk_entry_set_activates_default (GTK_ENTRY (display_entry), TRUE);
dialog_label =
gtk_label_new ("Please enter the name of\nthe new display\n");
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
gtk_container_add (GTK_CONTAINER (content_area), dialog_label);
gtk_container_add (GTK_CONTAINER (content_area), display_entry);
gtk_widget_grab_focus (display_entry);
while (!result)
{
gint response_id = gtk_dialog_run (GTK_DIALOG (dialog));
if (response_id != GTK_RESPONSE_OK)
break;
new_screen_name = gtk_editable_get_chars (GTK_EDITABLE (display_entry),
0, -1);
if (strcmp (new_screen_name, "") != 0)
{
result = gdk_display_open (new_screen_name);
if (!result)
{
gchar *error_msg =
g_strdup_printf ("Can't open display:\n\t%s\nplease try another one\n",
new_screen_name);
gtk_label_set_text (GTK_LABEL (dialog_label), error_msg);
g_free (error_msg);
}
g_free (new_screen_name);
}
}
gtk_widget_destroy (dialog);
}
/* Called when the user clicks on the "Close" button in the
* "Display" frame. Closes the selected display.
*/
static void
close_display_cb (GtkWidget *button,
ChangeDisplayInfo *info)
{
if (info->current_display)
gdk_display_close (info->current_display);
}
/* Called when the selected row in the display list changes.
* Updates info->current_display, then refills the list of
* screens.
*/
static void
display_changed_cb (GtkTreeSelection *selection,
ChangeDisplayInfo *info)
{
GtkTreeModel *model;
GtkTreeIter iter;
if (info->current_display)
g_object_unref (info->current_display);
if (gtk_tree_selection_get_selected (selection, &model, &iter))
gtk_tree_model_get (model, &iter,
DISPLAY_COLUMN_DISPLAY, &info->current_display,
-1);
else
info->current_display = NULL;
}
/* This function is used both for creating the "Display" and
* "Screen" frames, since they have a similar structure. The
* caller hooks up the right context for the value returned
* in tree_view, and packs any relevant buttons into button_vbox.
*/
static void
create_frame (ChangeDisplayInfo *info,
const char *title,
GtkWidget **frame,
GtkWidget **tree_view,
GtkWidget **button_vbox)
{
GtkTreeSelection *selection;
GtkWidget *scrollwin;
GtkWidget *hbox;
*frame = gtk_frame_new (title);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
g_object_set (hbox, "margin", 8, NULL);
gtk_container_add (GTK_CONTAINER (*frame), hbox);
scrollwin = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwin),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrollwin),
GTK_SHADOW_IN);
gtk_container_add (GTK_CONTAINER (hbox), scrollwin);
*tree_view = gtk_tree_view_new ();
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (*tree_view), FALSE);
gtk_container_add (GTK_CONTAINER (scrollwin), *tree_view);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (*tree_view));
gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
*button_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
gtk_container_add (GTK_CONTAINER (hbox), *button_vbox);
if (!info->size_group)
info->size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
gtk_size_group_add_widget (GTK_SIZE_GROUP (info->size_group), *button_vbox);
}
/* If we have a stack of buttons, it often looks better if their contents
* are left-aligned, rather than centered. This function creates a button
* and left-aligns it contents.
*/
GtkWidget *
left_align_button_new (const char *label)
{
GtkWidget *button = gtk_button_new_with_mnemonic (label);
GtkWidget *child = gtk_bin_get_child (GTK_BIN (button));
gtk_widget_set_halign (child, GTK_ALIGN_START);
gtk_widget_set_valign (child, GTK_ALIGN_CENTER);
return button;
}
/* Creates the "Display" frame in the main window.
*/
GtkWidget *
create_display_frame (ChangeDisplayInfo *info)
{
GtkWidget *frame;
GtkWidget *tree_view;
GtkWidget *button_vbox;
GtkTreeViewColumn *column;
GtkTreeSelection *selection;
GtkWidget *button;
create_frame (info, "Display", &frame, &tree_view, &button_vbox);
button = left_align_button_new ("_Open...");
g_signal_connect (button, "clicked", G_CALLBACK (open_display_cb), info);
gtk_container_add (GTK_CONTAINER (button_vbox), button);
button = left_align_button_new ("_Close");
g_signal_connect (button, "clicked", G_CALLBACK (close_display_cb), info);
gtk_container_add (GTK_CONTAINER (button_vbox), button);
info->display_model = (GtkTreeModel *)gtk_list_store_new (DISPLAY_NUM_COLUMNS,
G_TYPE_STRING,
GDK_TYPE_DISPLAY);
gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), info->display_model);
column = gtk_tree_view_column_new_with_attributes ("Name",
gtk_cell_renderer_text_new (),
"text", DISPLAY_COLUMN_NAME,
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
g_signal_connect (selection, "changed",
G_CALLBACK (display_changed_cb), info);
return frame;
}
/* Called when one of the currently open displays is closed.
* Remove it from our list of displays.
*/
static void
display_closed_cb (GdkDisplay *display,
gboolean is_error,
ChangeDisplayInfo *info)
{
GtkTreeIter iter;
gboolean valid;
for (valid = gtk_tree_model_get_iter_first (info->display_model, &iter);
valid;
valid = gtk_tree_model_iter_next (info->display_model, &iter))
{
GdkDisplay *tmp_display;
gtk_tree_model_get (info->display_model, &iter,
DISPLAY_COLUMN_DISPLAY, &tmp_display,
-1);
if (tmp_display == display)
{
gtk_list_store_remove (GTK_LIST_STORE (info->display_model), &iter);
break;
}
}
}
/* Adds a new display to our list of displays, and connects
* to the "closed" signal so that we can remove it from the
* list of displays again.
*/
static void
add_display (ChangeDisplayInfo *info,
GdkDisplay *display)
{
const gchar *name = gdk_display_get_name (display);
GtkTreeIter iter;
gtk_list_store_append (GTK_LIST_STORE (info->display_model), &iter);
gtk_list_store_set (GTK_LIST_STORE (info->display_model), &iter,
DISPLAY_COLUMN_NAME, name,
DISPLAY_COLUMN_DISPLAY, display,
-1);
g_signal_connect (display, "closed",
G_CALLBACK (display_closed_cb), info);
}
/* Called when a new display is opened
*/
static void
display_opened_cb (GdkDisplayManager *manager,
GdkDisplay *display,
ChangeDisplayInfo *info)
{
add_display (info, display);
}
/* Adds all currently open displays to our list of displays,
* and set up a signal connection so that we'll be notified
* when displays are opened in the future as well.
*/
static void
initialize_displays (ChangeDisplayInfo *info)
{
GdkDisplayManager *manager = gdk_display_manager_get ();
GSList *displays = gdk_display_manager_list_displays (manager);
GSList *tmp_list;
for (tmp_list = displays; tmp_list; tmp_list = tmp_list->next)
add_display (info, tmp_list->data);
g_slist_free (tmp_list);
g_signal_connect (manager, "display-opened",
G_CALLBACK (display_opened_cb), info);
}
/* Cleans up when the toplevel is destroyed; we remove the
* connections we use to track currently open displays, then
* free the ChangeDisplayInfo structure.
*/
static void
destroy_info (ChangeDisplayInfo *info)
{
GdkDisplayManager *manager = gdk_display_manager_get ();
GSList *displays = gdk_display_manager_list_displays (manager);
GSList *tmp_list;
g_signal_handlers_disconnect_by_func (manager,
display_opened_cb,
info);
for (tmp_list = displays; tmp_list; tmp_list = tmp_list->next)
g_signal_handlers_disconnect_by_func (tmp_list->data,
display_closed_cb,
info);
g_slist_free (tmp_list);
g_object_unref (info->size_group);
g_object_unref (info->display_model);
if (info->current_display)
g_object_unref (info->current_display);
g_free (info);
}
static void
destroy_cb (GObject *object,
ChangeDisplayInfo **info)
{
destroy_info (*info);
*info = NULL;
}
/* Main entry point. If the dialog for this demo doesn't yet exist, creates
* it. Otherwise, destroys it.
*/
GtkWidget *
do_changedisplay (GtkWidget *do_widget)
{
static ChangeDisplayInfo *info = NULL;
if (!info)
{
GtkWidget *content_area;
GtkWidget *vbox;
GtkWidget *frame;
info = g_new0 (ChangeDisplayInfo, 1);
info->window = gtk_dialog_new_with_buttons ("Change Display",
GTK_WINDOW (do_widget),
0,
"Close", GTK_RESPONSE_CLOSE,
"Change", GTK_RESPONSE_OK,
NULL);
gtk_window_set_default_size (GTK_WINDOW (info->window), 300, 400);
g_signal_connect (info->window, "response",
G_CALLBACK (response_cb), info);
g_signal_connect (info->window, "destroy",
G_CALLBACK (destroy_cb), &info);
content_area = gtk_dialog_get_content_area (GTK_DIALOG (info->window));
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
g_object_set (vbox, "margin", 8, NULL);
gtk_container_add (GTK_CONTAINER (content_area), vbox);
frame = create_display_frame (info);
gtk_container_add (GTK_CONTAINER (vbox), frame);
initialize_displays (info);
gtk_widget_show (info->window);
return info->window;
}
else
{
gtk_widget_destroy (info->window);
return NULL;
}
}

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