Compare commits

...

349 Commits

Author SHA1 Message Date
Philip Zander
e06176ae44 Win32 IME fixes
See merge request !1063
2020-11-04 17:11:56 +08:00
Chun-wei Fan
e47ddfb107 demos/gtk-demo: Temporarily disable gui_app attribute 2020-11-04 16:55:16 +08:00
kai-berlin
499e4b4c50 broadway: Set modifier state of scroll events
Set modifier state of scroll events, so Ctrl-scroll
works.

Fixes: #2733
2020-11-03 19:21:00 -05:00
Matthias Clasen
fd52220b1b Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3318, #3319, and #3320

See merge request GNOME/gtk!2776
2020-11-03 20:15:08 +00:00
Matthias Clasen
e9438224ab texthandle: Queue a draw when role changes
This helps with role changes not taking immediate
effect.

Fixes: #3320
2020-11-03 14:39:29 -05:00
Matthias Clasen
2120e9df88 Simplify gdk_surface_queue_render
We can just call gdk_surface_invalidate_rect here
like we do elsewhere in gdk, and I'm a bit uncertain
about the current code that adds an empty update
region.
2020-11-03 14:37:27 -05:00
Matthias Clasen
ddd16dd312 texthandle: Fix positioning
Use the same approach we use for popovers, using
gtk_widget_get_surface_allocation. It works.

Fixes: #3319
2020-11-03 12:37:39 -05:00
Matthias Clasen
7624f66fec widget-factory: Make sure we close popover on page 3
We don't want the popover to stay open when we open
an about dialog or shortcuts window. Since cascade-popdown
would also affect e.g. the context menu of the text widgets,
do this explicitly.
2020-11-03 12:09:43 -05:00
Matthias Clasen
dab11ea841 popover: Change default for cascade-popdown
We've found a number of cases where this cascading
has unexpected side-effects. So, turn it off by
default, and only set it for menus.
2020-11-03 11:00:32 -05:00
Matthias Clasen
a3f3dc0f1c Adwaita: Set a background for magnifiers
The magnifier in entries is magnifying the GtkText
widget, which does not draw any background itself.
Therefore, we give the magnifier a background, to
make things look as expected.

Fixes: #3318
2020-11-03 11:00:32 -05:00
Matthias Clasen
5d59447ccb magnifier: Set a css name
Predictably, we use the name "magnifier".
2020-11-03 11:00:32 -05:00
Matthias Clasen
e3c38e4143 NEWS: Updates 2020-11-03 11:00:32 -05:00
Matthias Clasen
e5ec4df702 docs: Mention g_file_get_basename
Mention g_file_get_basename in the migration guide section
about GtkFileChooser api changes.
2020-11-03 11:00:32 -05:00
Matthias Clasen
dbdc909e19 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2774
2020-11-03 12:14:21 +00:00
Matthias Clasen
c6ef1943e4 gtk-demo: Remove more gtk3-demo icon uses
Use our own logo everywhere.
2020-11-02 22:50:03 -05:00
Matthias Clasen
a3c9f8594a gtk-demo: Tweak images demo
Use our own logo instead of the gtk3-demo one, and
tweak the headings to refledct what we show.
2020-11-02 22:43:44 -05:00
Matthias Clasen
354f2b65fa gtk-demo: Reanimate floppy buddy
Implement a GdkPaintable wrapper around GdkPixbufAnimation,
so floppy buddy can waive again.
2020-11-02 21:38:02 -05:00
Matthias Clasen
b3657d5f2e widget-factory: Restore modality of the about dialog
Make the about dialog of widget-factory modal again.
This was lost in 87a8fda163.
2020-11-02 21:37:55 -05:00
Timm Bäder
82ca65956f gl renderer: Make debugging code shorter 2020-11-02 14:55:14 -05:00
Timm Bäder
c8c2106f3e gl renderer: Refactor vertex data loading code 2020-11-02 14:55:14 -05:00
Timm Bäder
8178dfb85a gl renderer: Use the load_vertex_data* functions more often 2020-11-02 14:55:14 -05:00
Timm Bäder
50e78198a8 gl renderer: More load_vertex_data* usage 2020-11-02 14:55:14 -05:00
Timm Bäder
ee04cbcfa8 gl renderer: Reword a comment 2020-11-02 14:55:14 -05:00
Timm Bäder
fc312f7ffe gl renderer: Remove an outdated comment 2020-11-02 14:55:14 -05:00
Timm Bäder
e6e964c3f3 gl renderer: Refactor rendering shadow nodes
Also use load_vertex_data_with_region here.
2020-11-02 14:55:14 -05:00
Timm Bäder
df5e796d99 gl renderer: Refactor blurred shadow drawing code
We already have various load_vertex_data* code, so try to reuse that
here.
2020-11-02 14:55:14 -05:00
Timm Bäder
d3239c953d gl renderer: Nine-slice unblurred outset shadows
See #3284
2020-11-02 14:55:13 -05:00
Timm Bäder
fb9a3bf32b printoperation: Remove double assignment 2020-11-02 14:55:13 -05:00
Matthias Clasen
ace83a938d Merge branch 'matthiasc/for-master' into 'master'
gtk-demo polish

See merge request GNOME/gtk!2773
2020-11-02 19:36:09 +00:00
Matthias Clasen
fb028f0fe7 gtk-demo: Renovate the paned demo
Make this look less like testgtk from GTK 2.
2020-11-02 13:56:19 -05:00
Matthias Clasen
8a13909bab fixup: window titles 2020-11-02 12:02:19 -05:00
Matthias Clasen
4e745f06e9 gtk-demo: Polish all entry demos
Make the spacing a bit more consistent, and tweak
some strings here and there.
2020-11-02 12:01:11 -05:00
Matthias Clasen
14b65a3c4f gtk-demo: Polish the search bar demo
Rename this, and make it look a bit less like a
debugging tool, and more like a demo.
2020-11-02 12:00:24 -05:00
Matthias Clasen
64ad490bc1 gtk-demo: Tweak tagged entry styling
Move the tags closer together, and avoid resizing too much.
2020-11-02 11:59:22 -05:00
Matthias Clasen
d2d7a4bcab gtk-demo: Tweak window titles
This is an attempt to improve consistency in the sidebar
and the window titles.
2020-11-02 11:11:44 -05:00
Matthias Clasen
14cbd13ef2 gtk-demo: Use typographic style classes
We don't need to hardcode <u> in markup anymore.
Use the heading style class instead.
2020-11-02 08:38:20 -05:00
Matthias Clasen
efc314196d Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2769
2020-11-02 11:52:13 +00:00
Matthias Clasen
403a70ca89 testsuite: Add tests for gtk4-builder-tool validate 2020-11-01 23:09:26 -05:00
Matthias Clasen
44b36b6321 builder-tool: Stop rewriting GtkPopoverMenu
We no longer allow manual creation of GtkPopoverMenu,
translating individual properties is not going to
change that.
2020-11-01 23:09:26 -05:00
Matthias Clasen
4bd829e3e1 testsuite: Test GtkFixed rewriting 2020-11-01 23:09:26 -05:00
Matthias Clasen
38f74d8a23 builder-tool: Rewrite GtkFixed more
GtkFixedLayout does not have layout properties
for x and y, so turn those into a transform.
2020-11-01 23:09:26 -05:00
Matthias Clasen
2613c2ef9b builder-tool: Avoid duplicate path prefixes
It is enough to print the file in which the error
occurred once; GtkBuilder already makes that part
of its error message.
2020-11-01 23:09:26 -05:00
Matthias Clasen
5751cd662d builder-tool: Install a log writer
Install a log writer function that is a bit simpler than
the default GLib log writer, and does not put PIDs and
timestamps in the output, so we can compare easily in
our testsuite.
2020-11-01 23:09:26 -05:00
Matthias Clasen
4039b713c3 Set G_LOG_USE_STRUCTURED globally
It doesn't make much sense to set this in per-directory
meson files, since that makes use use different logging
facilities in different parts of the project. Set it
globally.
2020-11-01 21:23:35 -05:00
Matthias Clasen
c3f8010b19 testsuite: Test GtkToolbar rewriting 2020-11-01 21:23:35 -05:00
Matthias Clasen
3e8a22ae8a builder-tool: Rewrite GtkToolbar more
Replace GtkToolbar with GtkBox and GtkToolButton with
GtkButton.
2020-11-01 21:23:35 -05:00
Matthias Clasen
c01f3be6e6 testsuite: Test GtkActionBar rewriting 2020-11-01 21:23:35 -05:00
Matthias Clasen
0cf372c814 testsuite: Test GtkPaned rewriting 2020-11-01 21:23:35 -05:00
Matthias Clasen
ac20c9cd41 builder-tool: Fix rewriting GtkPaned
The properties have been renamed in bc6643f3c2.
2020-11-01 21:23:35 -05:00
Matthias Clasen
d74c2a74e5 builder-tool: Drop unneeded code
We are rewriting the tree before simplifying it,
so there is no need to 'keep things for rewriting'
in the simplify phase.
2020-11-01 21:23:35 -05:00
Matthias Clasen
b79637ac41 testsuite: Test GtkOverlay rewriting 2020-11-01 21:23:35 -05:00
Matthias Clasen
e135772119 buildertool: Improve GtkOverlay rewriting
Translate the GtkOverlay:pass-through child property to
the GtkWidget:measure property, and drop the :index
child property.
2020-11-01 21:23:35 -05:00
Matthias Clasen
3cf26b471b Fix the definition of GtkWidget:can-target
We are setting the value to TRUE initially, but
the property had a declared default of FALSE.
This is messing up the simplification of .ui files
with gtk4-builder-tool, since it thinks it can
omit can-target properties when it really can't.
2020-11-01 21:23:35 -05:00
Matthias Clasen
c630285692 Cosmetics 2020-11-01 21:23:35 -05:00
Matthias Clasen
5702b71037 Remove leftover file
This was never used in tests.
2020-11-01 21:23:35 -05:00
Matthias Clasen
a4e5f5ca50 testsuite: More gtk4-builder-tool tests 2020-11-01 21:23:35 -05:00
Matthias Clasen
b0b00d49d2 testsuite: Test gtk4-builder-tool simplify --replace
Run all gtk4-builder-tool test with and without --replace.
This improves test coverage for gtk4-builder-tool
2020-11-01 21:23:35 -05:00
Matthias Clasen
cb018ec047 builder-tool: Avoid a crash
Be more careful about types that have been removed.
I was getting criticals when converting ui files
containing GtkToolbars.
2020-11-01 21:23:35 -05:00
Matthias Clasen
168b21c77e testsuite: Improve coverage for GdkTexture 2020-11-01 21:23:35 -05:00
Matthias Clasen
2dcc641d5a testsuite: Improve coverage for GdkDisplayManager 2020-11-01 21:23:35 -05:00
Matthias Clasen
c8432ae668 testsuite: Improve coverage for seats 2020-11-01 21:23:35 -05:00
Matthias Clasen
642ad4e06f testsuite: Improve coverage for rectangles 2020-11-01 21:23:35 -05:00
Tim Sabsch
924796b478 Update German translation 2020-11-01 14:08:13 +00:00
Piotr Drąg
319d4c7e01 Update Polish translation 2020-11-01 10:37:21 +01:00
Matthias Clasen
07c491f235 testsuite: Improve coverage for keys 2020-10-31 14:57:02 -04:00
Matthias Clasen
970f91ec24 testsuite: Add more css parser tests
Add tests for url parsing.
2020-10-31 09:18:40 -04:00
Matthias Clasen
48381bd4f6 testsuite: Add a forgotten test
I've written this test a while ago, but did not add
it to the test data list in meson.build.
2020-10-31 08:30:02 -04:00
Matthias Clasen
1a12999431 testsuite: Add a css test
This test verifies that CDO and CDC are ignored
as required.
2020-10-31 00:38:49 -04:00
Matthias Clasen
90676540ec css: Fix tokenization of CDO
A CDO is 4 characters: <!--, not 3 as our tokenizer
was pretending.
2020-10-31 00:38:49 -04:00
Matthias Clasen
7db58d5f8d gsk: Don't compile unused code
The NodeSample and GskGLImage code is not used,
so don't compile it.
2020-10-30 23:36:39 -04:00
Matthias Clasen
875452b476 testsuite: Improve coverage for GtkMultiSorter 2020-10-30 23:33:34 -04:00
Matthias Clasen
1c4c5e3b80 testsuite: Improve coverage for GtkStringList 2020-10-30 23:33:15 -04:00
Matthias Clasen
af5e13b9a1 Remove an unused function
The only property of GtkStringObject is readonly since
commit fb14f50ec1, so we don't need a
set_property implementation.
2020-10-30 23:32:30 -04:00
Matthias Clasen
9b78bc4af7 testsuite: Improve coverage 2020-10-30 23:04:23 -04:00
Matthias Clasen
1702a4c223 Drop an unused private function 2020-10-30 22:51:54 -04:00
Matthias Clasen
f0e35c8ed8 Drop unused includes 2020-10-30 22:50:38 -04:00
Matthias Clasen
26150d8489 testsuite: Improve coverage for GtkExpression 2020-10-30 22:27:40 -04:00
Matthias Clasen
48dcbf4935 expression: Fix property expressions for interfaces
We were not checking the passed-in type in the right
way. An interface type can still pass the
g_type_is_a (..., G_TYPE_OBJECT) check, if G_TYPE_OBJECT
is one of its prerequisites. What we need to check is
whether the fundamental type is G_TYPE_OBJECT.
2020-10-30 22:27:40 -04:00
Matthias Clasen
59dd7d8900 testsuite: Improve coverage for GtkMultiFilter 2020-10-30 22:27:40 -04:00
Matthias Clasen
c279bdaa81 testsuite: Improve coverage for GtkStringFilter 2020-10-30 20:15:25 -04:00
Matthias Clasen
01d52a7292 testsuite: Make all css tests run again
The tests in subdirectories of testsuite/css were
using an environment defined in the parent directory,
causing them to not find their test data. Give each
test directory its own environment.
2020-10-30 20:14:17 -04:00
Matthias Clasen
2b38d14bf5 tests: Improve coverage for css data url parsing
Cover the error conditions as well.
2020-10-30 19:26:56 -04:00
Matthias Clasen
d35a21873e testsuite: Improve coverage for GtkBoolFilter 2020-10-30 18:17:50 -04:00
Matthias Clasen
b23cae9643 Drop unused gtk_buildable_set_buildable_property 2020-10-30 17:19:52 -04:00
Matthias Clasen
505df337c2 Add a test for constraints in ui files
Test the various values that are possible for the constraint
attributes.
2020-10-30 16:21:14 -04:00
Matthias Clasen
117997da54 Merge branch 'wip/chergert/gdk-macos-gl-renderer' into 'master'
macos: add more aggressive clip to transparent subview

See merge request GNOME/gtk!2762
2020-10-30 19:48:57 +00:00
Matthias Clasen
19052d4360 gtk-demo: Tweak descriptions of constraints demos
Make these a little longer, and include more details.
2020-10-30 15:26:37 -04:00
Matthias Clasen
2dbaca2464 constraintlayout: Make sure guides get their constraints
When using GtkBuilder to create constraints and guides,
the layout manager is already rooted when the guides get
created, and we were forgetting to create the guides
constraints in this case. Fix it by adding a call to
gtk_constraint_guide_update().

This was showing up in the new builder-based constraints
demo as the guide not having the expected effect.
2020-10-30 15:04:13 -04:00
Matthias Clasen
4b8134b19b constraintlayout: Emit less change notification
This isn't strictly required for correctness, but
it makes the GtkBuilder codepath do the same that
the vfl codepath does: call gtk_layout_manager_layout_changed
only once, after all the constraints have been added.
2020-10-30 15:04:13 -04:00
Matthias Clasen
588fe5b5c1 gtk-demo: Tweak the new constraints demo
With these somewhat random ordering changes, things get
closer to working the same as the code example. Still,
the guide doesn't work right.
2020-10-30 15:04:13 -04:00
Matthias Clasen
b8f44de48e constraintlayout: Fix parsing from ui file
Guides were not properly looked up when creating
constraints in a ui file.
2020-10-30 15:04:13 -04:00
Matthias Clasen
49bdc4f0c2 Add another constraints demo
This one attempts to use constraints in a ui file.
It doesn't work.
2020-10-30 15:04:13 -04:00
Matthias Clasen
a0ee25a21e gtk-demo: Remove unnecessary code
I was distracted by this code that sets names
on widgets in the constraints demo - the names
aren't used and aren't needed, so remove them.
2020-10-30 15:01:50 -04:00
Christian Hergert
d8192013f3 macos: add more aggressive clip to transparent subview
The Cairo implementation for the Macos backend uses a toplevel
window with full transparency and a series of NSView to create opaque
regions. This improves compositor performance because it allows the
display server to avoid costly blends.

However, we want to ensure we clip better when exposing the
transparent region so that we only expose the shadows/corners as
necessary.
2020-10-29 19:41:21 -07:00
Matthias Clasen
8ed1f51f7f Merge branch 'wip/chergert/remove-GDK_WINDOWING_QUARTZ' into 'master'
gdk: remove remaining GDK_WINDOWING_QUARTZ usage

See merge request GNOME/gtk!2761
2020-10-30 01:36:10 +00:00
Matthias Clasen
03fec389f4 docs: Add details for gsk_renderer_new_for_surface
Mention the GSK_RENDERER variable here.
2020-10-29 18:21:44 -04:00
Matthias Clasen
38c39e2aa1 NEWS: Updates 2020-10-29 18:21:32 -04:00
Christian Hergert
6298fd1eef gdk: remove remaining GDK_WINDOWING_QUARTZ usage 2020-10-29 13:57:28 -07:00
Matthias Clasen
5a77994516 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2760
2020-10-29 18:55:53 +00:00
Matthias Clasen
6142238237 Merge branch 'wip/chergert/gdk-macos-gl-renderer' into 'master'
macos: implement GL rendering on with Cairo renderer

See merge request GNOME/gtk!2759
2020-10-29 18:33:13 +00:00
Matthias Clasen
3164f328b5 docs: Some restructuring
Give the GDK docs some more structure.
2020-10-29 14:23:46 -04:00
Matthias Clasen
ce78d0c301 docs: Tweak GdkToplevel docs 2020-10-29 14:23:46 -04:00
Matthias Clasen
94305f248b docs: Tweak GdkPopup docs 2020-10-29 14:23:46 -04:00
Matthias Clasen
3afd5d7a89 docs: Tweak GdkSurface docs
Add more details, and refer to the GdkToplevel / GdkPopup
docs.
2020-10-29 14:23:46 -04:00
Matthias Clasen
d2adbad408 docs: Tweak frame clock docs 2020-10-29 14:23:46 -04:00
Matthias Clasen
2df382277d docs: Small additions for GdkCursor docs 2020-10-29 14:23:46 -04:00
Matthias Clasen
9f71bdd045 docs: Cosmetics
Make the GdkRGBA heading less repetitive.
2020-10-29 14:23:46 -04:00
Matthias Clasen
838d0924b9 docs: Tweak GdkPaintable docs
Minor additions here and there.
2020-10-29 14:23:46 -04:00
Matthias Clasen
1f8d593931 docs: Add some detail to GdkTexture docs
Minor additions here and there.
2020-10-29 14:23:46 -04:00
Matthias Clasen
574a3a456d gdk: Drop GdkPoint from the api
This typedef was not used in any public APIs, and is
only used in the MacOS backend. It is not worth preserving
as public API, move it to the only user.
2020-10-29 14:23:46 -04:00
Matthias Clasen
3617fbab42 docs: Include GDK_WINDOWING_MACOS
We no longer have a Quartz backend, it is called
MacOS now.
2020-10-29 14:23:46 -04:00
Matthias Clasen
29ccd13e15 docs: Stop referring to the Quartz backend
Its MacOS now.
2020-10-29 14:23:46 -04:00
Christian Hergert
de9c9efa6f macos: implement GL context
This implements the basics for a GdkGLContext on macOS. Currently, rendering
only is fully working for the GskCairoRenderer case where we read back pixels
into a cairo surface for rendering. More work on synchronization is required for
the GL on GskGLRenderer case.

When we attempt to render a surface itself with GL, the context will ensure that
the new GdkMacosGLView is placed within the NSWindow. In other cases, we
use a dummy NSView and NSWindow for backing the NSOpenGLContext to
ensure that we can get accelerated drawing.

This gets GtkGLArea working when running with GSK_RENDERER=cairo.
2020-10-29 10:57:02 -07:00
Christian Hergert
eb809ba425 macos: tweak gravity while resizing
This helps a situation where the window contents has not changed
in time for a drawing. Setting the texture gravity helps that side or
corner to be less jittery while moving.

Ideally, we can get to a point where we are synchronized and keeping
up with drawing fast enough to not need this. That may require some
work to drive frame clocks from drawRect: though.
2020-10-29 10:57:02 -07:00
Christian Hergert
adf60fb3a1 macos: be tolerant of NULL GL context
Some code appears to unconditionally attempt to make the context current,
so this makes things tolerant to a NULL GdkGLContext and just return FALSE.
2020-10-29 10:57:02 -07:00
Christian Hergert
a3fd46c516 glsl: tweak pre-processor to support Apple GLSL compiler
The Apple GLSL compiler cannot deal with empty pre-processor blocks such as

  #if GSK_GLES
  #elif GSK_LEGACY
2020-10-29 10:57:02 -07:00
Christian Hergert
0040667965 macos: remove unused GL layer
This isn't being used, and instead we'll go the route of a NSView for
the OpenGL implementation.
2020-10-29 10:57:02 -07:00
Christian Hergert
60e67a62e6 macos: move setNeedsDisplay helper to GdkMacosCairoView
This isn't needed in the base class, which will eventually get a GL subclass.
2020-10-29 10:57:02 -07:00
Matthias Clasen
931f130377 Merge branch 'wip/chergert/gdk-remove-texture_from_surface' into 'master'
gl: remove unused texture_from_surface API

See merge request GNOME/gtk!2756
2020-10-29 15:50:01 +00:00
Christian Hergert
524fbc35a7 gl: remove unused texture_from_surface API
This is not used anywhere and only exists within the X11 backend. It
can be removed now.
2020-10-29 08:26:27 -07:00
Matthias Clasen
51d35750f6 Cosmetics
Whitespace fix.
2020-10-29 07:40:30 -04:00
Matthias Clasen
90fde9c939 Merge branch 'matthiasc/for-master' into 'master'
textview: Update child allocations

See merge request GNOME/gtk!2757
2020-10-29 11:21:30 +00:00
Matthias Clasen
5cbc55578f textview: Update child allocations
This was accidentally lost when display line caching
was introduced.
2020-10-28 20:18:54 -04:00
Piotr Drąg
f90e7b9c56 Update POTFILES.skip 2020-10-28 15:12:01 +01:00
Matthias Clasen
d5b9489408 Merge branch 'wip/baedert/for-master' into 'master'
Wip/baedert/for master

Closes #3282

See merge request GNOME/gtk!2755
2020-10-27 22:38:58 +00:00
Matthias Clasen
975d763db1 Merge branch 'dropdown-checkmark' into 'master'
Dropdown checkmark

Closes #3291

See merge request GNOME/gtk!2754
2020-10-27 20:41:34 +00:00
Matthias Clasen
907fc30fac gtk-demo: Add checkmarks to all dropdown demos
This follows the mockups that these demos are
copied from. Unfortunately, it has to be implemented
for every item factory, so we repeat it here.

Fixes: #3291
2020-10-27 16:13:44 -04:00
Matthias Clasen
25d2efeabe dropdown: Add a checkmark to the selected item
Make the default factory add a checkmark to the
currently selected item (not the hovered item)
in the popup. This will unfortunately have to be
done in non-default factories too.

Related: #3291
2020-10-27 16:13:38 -04:00
Matthias Clasen
3a119a3d3a dropdown: Make search entry shrink
We don't want the popup to be wider than the button
if we can help it. The search entry does not need
to be very wide.
2020-10-27 15:35:34 -04:00
Matthias Clasen
8df883ed71 Merge branch 'matthiasc/atspi-child' into 'master'
Emit ChildrenChanged signal on hierarchy updates

See merge request GNOME/gtk!2752
2020-10-27 18:24:43 +00:00
Matthias Clasen
0c49f7349d Merge branch 'matthiasc/a11y-buildable' into 'master'
Implement accessible attributes for ui files

See merge request GNOME/gtk!2751
2020-10-27 18:13:44 +00:00
Benjamin Otte
08004d4eed Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master

Closes #3295

See merge request GNOME/gtk!2748
2020-10-27 16:27:10 +00:00
Benjamin Otte
6d7e56bed6 cloudprint: Make compile without warnings 2020-10-27 16:43:34 +01:00
Benjamin Otte
8e6701c9a6 gtkmediafile: Use cubic volume function
Gstreamer suggests doing that.

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/1439

Fixes #3295
2020-10-27 16:32:53 +01:00
Jakub Steiner
6d5c512571 Merge branch 'wip/jimmac/gtk4-dropdown-papercuts' into 'master'
Adwaita: dropdown search box

See merge request GNOME/gtk!2747
2020-10-27 12:55:33 +00:00
Jakub Steiner
b94ea1b4f7 Adwaita: dropdown search box
- have some whitespace around entry

Partial fix for https://gitlab.gnome.org/GNOME/gtk/-/issues/3291
2020-10-27 13:32:04 +01:00
Matthias Clasen
b2d6011679 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2746
2020-10-27 05:05:33 +00:00
Matthias Clasen
c0aa1c8a49 Merge branch 'popover-menu-custom-child' into 'master'
popovermenu: Allow custom items

Closes #3260

See merge request GNOME/gtk!2728
2020-10-27 04:51:00 +00:00
Matthias Clasen
5fe837483c docs: Add GtkOverlay to the widget gallery 2020-10-27 00:42:38 -04:00
Matthias Clasen
4f15b988e7 docs: Add box, grid and center box to the gallery 2020-10-27 00:24:54 -04:00
Matthias Clasen
6cd3bc7384 modelbutton: Explicitly set up LABELLED-By relation
GTK does this automatically based on mnemonics, but only
if the string actually contains a mnemonic. This makes
orca read out menuitems, as expected.
2020-10-26 22:48:01 -04:00
Matthias Clasen
0faadef36f widget-factory: Add a scale to the gear menu
This tests the custom menuitem support, and lets you
control the transition duration for the main stack.
2020-10-26 22:43:12 -04:00
Matthias Clasen
af6c3017fb popovermenu: Allow adding custom items in ui files
Support <child type="ID"> to fill custom child slots
in both GtkPopoverMenus and GtkPopoverMenuBars that
are created in ui files.
2020-10-26 22:42:28 -04:00
Matthias Clasen
8157abe591 popovermenu: Allow custom items
Add a way to add children at certain places in
the generated menu for both GtkPopoverMenu and
GtkPopoverMenuBar.

New apis:
gtk_popover_menu_add_child
gtk_popover_menu_remove_child
gtk_popover_menu_bar_add_child
gtk_popover_menu_bar_remove_child

Fixes: #3260
2020-10-26 22:41:33 -04:00
Matthias Clasen
61e08baec1 Merge branch 'master' into 'master'
Fix the build with cups < 2.2.12

Closes #2968

See merge request GNOME/gtk!2744
2020-10-26 20:09:30 +00:00
Thomas Lange
0493e89897 Fix the build with cups < 2.2.12
PPD_CUSTOM_UNKNOWN was introduced in cups 2.3.
and has been backported to 2.2.12.
Only handle it when we build against a new enough cups.

Fixes: #2968
2020-10-26 19:16:26 +01:00
Matthias Clasen
c783e9aa5f Treat tristate as an enum when parsing
This makes it so that you have to explicitly specify
"true" and "false" for the checked state, but it
matches how this enumeration is meant to be used.
2020-10-26 08:01:13 -04:00
Matthias Clasen
4661f15fab Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2741
2020-10-26 05:28:43 +00:00
Matthias Clasen
e51a98d184 docs: Add GtkDrawingArea to the gallery 2020-10-26 01:08:49 -04:00
Matthias Clasen
b67eee5741 docs: Add GtkShortcutsWindow to the widget gallery 2020-10-26 01:08:49 -04:00
Matthias Clasen
d9259fc958 docs: Add GtkPopoverMenu to the widget gallery 2020-10-26 01:08:49 -04:00
Matthias Clasen
65f748fc62 docs: Add GtkPopover to the widget gallery 2020-10-26 01:08:49 -04:00
Matthias Clasen
bed3616bf0 docs: Add GtkPopoverMenuBar to the gallery 2020-10-26 01:08:49 -04:00
Matthias Clasen
1605ca0140 docs: Add GtkExpander to the gallery 2020-10-26 01:08:49 -04:00
Matthias Clasen
8692f5d8e3 docs: Add GtkEmojiChooser to the gallery
To make this possible enable the doc shooter
to take screenshots of popovers.
2020-10-26 01:08:49 -04:00
Matthias Clasen
42e2c54922 docs: Redo the GtkColorChooserDialog gallery image
Show the new palette.
2020-10-25 22:54:53 -04:00
Matthias Clasen
291c61891a docs: Improve the GtkStackSidebar gallery image 2020-10-25 22:54:41 -04:00
Matthias Clasen
59e08c0dac docs: Tweak gallery layout
Now that the volume button image is small, move it
to a better place in its section. Improves the layout.
2020-10-25 22:46:30 -04:00
Matthias Clasen
a70c9c69a0 docs: Fix the GtkVolumeButton gallery image
Give up on showing the popup, we don't do that
for other buttons either.
2020-10-25 22:42:40 -04:00
Matthias Clasen
dffe6b87e4 docs: Add GtkCalendar to the gallery
It has been missing far too long.
2020-10-25 22:32:27 -04:00
Matthias Clasen
28b7962bee docs: Improve the GtkMediaControls gallery image 2020-10-25 22:26:19 -04:00
Matthias Clasen
64e131f285 docs: Improve the GtkVideo gallery image 2020-10-25 22:17:15 -04:00
Matthias Clasen
a9f0f18c3a docs: Tweak gallery layout
Improve the breaks in the container section.
2020-10-25 22:16:26 -04:00
Matthias Clasen
2e0822bed0 docs: Shrink the editable label gallery image
Makes it fit better with the other entries.
2020-10-25 21:52:51 -04:00
Matthias Clasen
b0fb31fc96 docs: Some reordering in the gallery
Align things better.
2020-10-25 21:47:40 -04:00
Matthias Clasen
163d32eea1 docs: Work around GtkPicture growing
Make the GtkPicture gallery image stay within its
limits, by overpowering its request mode.
2020-10-25 21:30:15 -04:00
Matthias Clasen
b7728a884b docs: Tweak gallery ordering
Move GtkSpinButton to the entries, where it
belongs, despite its name.
2020-10-25 21:10:12 -04:00
Matthias Clasen
86b4b2eef2 docs: Fix links from the gallery
It turns out gtk-doc can't even parse its own custom
links if you don't arrange for the <link> element to
on a single line, since it is just a glorified sed
script :(
2020-10-25 21:07:12 -04:00
Matthias Clasen
09eda804f7 docs: Add GtkWindowControls to the gallery 2020-10-25 21:06:46 -04:00
Matthias Clasen
37d4932b31 a11y: Add more tests
Test some of the attributes that GTK maintains
for every widget.
2020-10-25 19:29:00 -04:00
Matthias Clasen
0fddf73ddb a11y: Add some parser tests
Checking basic support for acessible states, properties
and relations in ui files.
2020-10-25 13:01:44 -04:00
Matthias Clasen
f981ab7a9e Remove erroneous preconditions
Tests found these functions to be non-working.
2020-10-25 12:43:52 -04:00
Matthias Clasen
677ea5f22d a11y: Reuse builder parsing for enums
No need to manually write all these parsing functions
when _gtk_builder_enum_from_string does exactly what
is needed here.
2020-10-25 12:38:52 -04:00
Matthias Clasen
fce455ae0b a11y: Parse booleans in ui files as expected
Accept the same syntax for booleans as GtkBuilder
does elsewhere.
2020-10-25 12:20:55 -04:00
Matthias Clasen
e050a2661c builder: Expot _gtk_builder_boolean_from_string privately
When specifying accessible properties in ui files, it
is better to accept the same syntax for booleans as
elsewhere, so lets reuse this function.
2020-10-25 12:19:21 -04:00
Piotr Drąg
a03581ce39 Update Polish translation 2020-10-25 10:37:47 +01:00
Matthias Clasen
13b9b9b7d8 scale: Set round-digits to -1 initially
This ensures that keybindings for small-step changes
work despite draw-value being FALSE now. This was
fallout from 8ca612c966 that showed up
as arrow keys not working anymore for the color scales
in the color chooser.
2020-10-25 00:31:18 -04:00
Matthias Clasen
0a3b370805 Cosmetics
Remove some comments that refer to no longer
existing menu code.
2020-10-25 00:31:18 -04:00
Matthias Clasen
313ba0280a color editor: Add accessible labels
Add some labels to the controls in this dialog.
2020-10-24 23:55:56 -04:00
Matthias Clasen
adb7676fc1 a11y: More State<>Change confusion
We should really avoid this needless duplication
- the 'state' is never stored anywhere.
2020-10-24 23:12:36 -04:00
Matthias Clasen
8ffb398517 a11y: Handle all cases for state change
Make state_change handle state changes for non-widgets,
and handle the cases for HIDDEN involving stack pages.
2020-10-24 22:05:17 -04:00
Matthias Clasen
9a943e21d3 stack: Update HIDDEN a11y state for stack pages
This will let us handle additions and removals
in the AT-SPI backend.
2020-10-24 22:04:26 -04:00
Matthias Clasen
7c106578ed Cosmetics
Make gtk_at_spi_root_child_changed take a
GtkAccessible for the child.
2020-10-24 21:35:35 -04:00
Matthias Clasen
d1d9b92aee Merge branch 'meson-deps-continued' into 'master'
Turn more options into "feature"

See merge request GNOME/gtk!2708
2020-10-25 01:10:01 +00:00
Matthias Clasen
434b145ee0 stack: Don't transition when the visible child is remove
This is a corner-case, and it is causing crashes in
the shortcuts window, after a11ab6c995.
2020-10-24 20:54:55 -04:00
Matthias Clasen
2546b88661 a11y: Redo child-added/-removed for toplevels
Instead of monitoring the list of toplevels, rely
on GtkWindow updating the HIDDEN state before windows
get removed. This is better, since we still have the
object available when it happens, so we can pass it
to the ATs.
2020-10-24 15:26:12 -04:00
Matthias Clasen
bba6d604f0 window: Maintain accessible HIDDEN state
We want to use the HIDDEN state to control when
things get added and removed from the accessible
tree, so ensure that we a) set HIDDEN to true
initially for windows, and b) we update HIDDEN
when a window is shown or hidden.

The second part is handled by gtk_widget_hide
for other widgets, but hiding a window does not
always go through that code path.
2020-10-24 15:25:03 -04:00
Matthias Clasen
274f9ad919 a11y: Emit child notification when toplevels get hidden
When a toplevel window gets hidden (and not destroyed),
the frontend code set the HIDDEN state, and we need to
emit child notification when that happens.
2020-10-24 13:17:20 -04:00
Matthias Clasen
89a8c89663 a11y: Improve child index helpers
We need to use gtk_accessible_should_present() whenever we
calculate accessible tree positions, to avoid inconsistencies.

While we are at it, make these helpers usable for finding
the position of accesibles that are now ignored, by not
looking at should_present for the object itself. This will
be relevant when we calculate the position of objects whose
HIDDEN state changes.
2020-10-24 13:14:44 -04:00
Matthias Clasen
e7b290debb a11y: Improve child notification for toplevels
We need to translate the list model position into
an accessible tree position, since hidden toplevels
will be skipped.

While we are at it, add an api for this notification
that will be used in the next commit.
2020-10-24 13:13:07 -04:00
Matthias Clasen
46e754a17d a11y: Skip non-presented children when required
Whenever we determine the index of a child, we need
to skip its non-presented siblings.
2020-10-24 11:22:09 -04:00
Matthias Clasen
b12992c1cb a11y: Handle HIDDEN state changes
Hidden elements are not presented in the accessible
tree, so when then HIDDEN state changes, we should
emit child-added or -removed signals.

This commit does not yet handle all cases (HIDDEN
toplevels or hidden stack pages are not handled),
but it should cover the common case.
2020-10-24 11:17:56 -04:00
Matthias Clasen
374a451eeb a11y: Don't present HIDDEN accessibles
The ARIA spec is clear on this: when an element has the
HIDDEN state, it should not be presented in the accessible
tree.

This change is incomplete, we also need to emit child-added/
removed signals when the state changes, but that needs to
wait for the child added infrastructure to land.
2020-10-24 11:17:56 -04:00
Matthias Clasen
1e13acb206 widget: Don't add reordered children
gtk_widget_reposition_after is called both to add new children,
and to reposition existing children. We only want to emit
accessible changes in the former case (since AT-SPI doesn't
have events for reordering).
2020-10-24 11:17:56 -04:00
Matthias Clasen
5b2b2feb9f a11y: Fix up state / change enum confusion 2020-10-24 11:17:56 -04:00
Matthias Clasen
77af993181 Merge branch 'flush-events' into 'master'
Flush events

See merge request GNOME/gtk!2740
2020-10-24 12:53:01 +00:00
Matthias Clasen
c5ed5c5ff9 gdk: Deliver queued events on flush
The current code was marking queued events as flushed,
but left them in the queue. That doesn't make sense to
me - we should deliver all events we have before we
reach the paint phase of the frame cycle.
2020-10-23 17:03:00 -04:00
Matthias Clasen
6b53a55dd7 NEWS: Updates 2020-10-23 15:07:25 -04:00
Matthias Clasen
83fbdcd5e6 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3226

See merge request GNOME/gtk!2739
2020-10-23 17:25:33 +00:00
Matthias Clasen
cb8bf6540c editablelabel: Properly clean up in dispose
Unparenting the stack finalizes the entry and label,
but at least the label is available via the
gtk_editable_get_delegate API, and the a11y
implementation uses that at dispose time. So, clear
the pointers to prevent them from being dangling.

This was showing up as a segfault of the doc-shooter.
2020-10-23 12:27:55 -04:00
Matthias Clasen
fdb1fa4d08 Give all search entries an icon
This was first requested for the search entry in
GtkDropDown, but it is better to be consistent and
give every search entry an icon.

Related: #3291
2020-10-23 12:19:31 -04:00
Matthias Clasen
10d7ccc8e0 window: Fix state updates
When the compositor unmaximized the window, we get a
state-changed signal, and we update the maximized field.
But then we go and recompute our layout based on the
maximize_initially field, and that is still TRUE, when
we were maximized initially. So we need to update both
fields.

This fixes a problem where using the window menu to
unmaximize an initially maximized window would not
work.

Fixes: #3226
2020-10-23 11:51:02 -04:00
Matthias Clasen
b973f7f375 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2737
2020-10-23 01:45:22 +00:00
Matthias Clasen
7671c1074b Tweak focus tests
These tests are a bit fragile because the initial focus
that is taken depends on what ends up in the center of
the window, horizontally or vertically, which depends
on things like fonts, or theme spacing.

This commit makes some tweaks to push things in the
widget-factory example around far enough to make the
tests work again.

We should figure out a way to make this more robust.
2020-10-22 21:18:46 -04:00
Matthias Clasen
6ce2e19bbe Merge branch 'ebassi/for-master' into 'master'
Ebassi/for master

See merge request GNOME/gtk!2735
2020-10-22 22:53:34 +00:00
Matthias Clasen
3a08706e40 dropdown: Add an icon the search entry
A small detail for #3291.
2020-10-22 14:33:41 -04:00
Matthias Clasen
e5722fe9d2 passwordentry: Respect border spacing
We are not using a box layout here since we want
to ignore the icons for measuring. But we still
want the layout to respect border spacing that
comes from the theme.
2020-10-22 14:27:19 -04:00
Matthias Clasen
700f957d9a Adwaita: Set border-spacing for entries
When our entries contain icons, they should not run
directly into the text, so put some spacing between
the children of entries.
2020-10-22 14:26:21 -04:00
Timm Bäder
9109dee072 gl renderer: Don't use blur node bounds
The blur node bounds are different/larger than the ones we use. This
made the textures get stretched to the blur node bounds.

Fixes #3282
2020-10-22 17:46:34 +02:00
Timm Bäder
b6a843a05b gl renderer: Fix two scale_x/y mixups 2020-10-22 17:46:34 +02:00
Timm Bäder
ff1fb4f10d text: Remove empty root() implementation 2020-10-22 17:46:34 +02:00
Timm Bäder
1bf79a4dae text: Fix a documentation mishap 2020-10-22 17:46:34 +02:00
Timm Bäder
85d4b86545 text: Fold focus_{in,out} into only caller 2020-10-22 17:46:34 +02:00
Timm Bäder
98e88b7b53 text: Avoid a crash
Calculate the "was previous focus in a child widget" condition before
chaining up into grab_focus, to a void that unreffing the prev_focus
widget.
2020-10-22 17:46:34 +02:00
Timm Bäder
85702f8f5d dnd demo: Make the transform code a bit more idiomatic 2020-10-22 17:46:34 +02:00
Timm Bäder
d97cb851f1 textview: Remove a broken debug output statement
redraw_rect does not exist.
2020-10-22 17:46:34 +02:00
Timm Bäder
6dcdb4a601 atspitextbuffer: Explicitly cast between pango and gtk enums 2020-10-22 17:46:34 +02:00
Timm Bäder
41ef1d87ef atspicontext: Add a few missing break statements 2020-10-22 17:46:34 +02:00
Timm Bäder
44728d09a9 stack: assert for some assumptions 2020-10-22 17:46:34 +02:00
Timm Bäder
b1664534af gdksurface: Ensure some assumptions
Just to please scan-build
2020-10-22 17:46:34 +02:00
Timm Bäder
56e89e8d26 demos: Remove a dead assignment 2020-10-22 17:46:34 +02:00
Timm Bäder
f6ebc06767 filechooserwidget: Avoid an uninitialized value
If the operation mode is OPERATION_MODE_RECENT and we end up in the
'goto file_entry' case, we don't set info.result. Then later after
calling check_save_entry, is_empty is TRUE which causes a goto out and
here we then try to use info.result, which is uninitialized.

Initialize info.result before doing all this.

Found by scan-build
2020-10-22 17:46:33 +02:00
Timm Bäder
3db5e15bde filechooserwidget: gtk_widget_get_root() can return NULL 2020-10-22 17:46:33 +02:00
Timm Bäder
a2291fb989 showrendernode: Pass error to deserialize() 2020-10-22 17:46:33 +02:00
Timm Bäder
af97f19926 textview: Respect return value of get_text_surface_coords() 2020-10-22 17:46:33 +02:00
Timm Bäder
0dae1f48fd listbox test: Only compare values for rows we have
This shouldn't happen, but don't compare 100 values if we didnt' get 100
values from the listbox.
2020-10-22 17:46:33 +02:00
Timm Bäder
c7dbb8ef91 label: Plug a potential memory leak
This only happens in error cases so pretty insignificant.

Found by scan-build
2020-10-22 17:46:33 +02:00
Timm Bäder
3a1e019e83 print-editor: Fix a wrong comparison
If error is NULL, replacing the file contents worked and we don't
show the error dialog. The previous version pretty explicitly
dereferenced a NULL pointer by first ensuring that error is NULL and
then accessing error->message.

Found by scan-build
2020-10-22 17:46:33 +02:00
Matthias Clasen
a923be95b3 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2736
2020-10-22 14:52:57 +00:00
Matthias Clasen
a11ab6c995 a11y: Handle stack case for addition/removal
Since we interpose stack pages as non-widget accessibles,
we need to tweak the signals we emit when their corresponding
widgets get added or removed.
2020-10-22 10:06:06 -04:00
Matthias Clasen
1d802881eb stack: Change ordering for removal
Unparent the child widget before tearing down its
stack page. This is necessary so a11y can still access
the stack page accessible to emit change notification
when it learns that the child is removed.
2020-10-22 10:05:17 -04:00
Emmanuele Bassi
6c796cf201 docs: Fix cross-linking for GIO types 2020-10-22 13:33:49 +01:00
Matthias Clasen
44c6619660 gtk-demo: Speed up image demo
The progressive loading demo here was so slow as to appear
broken. Make it faster, and ensure that it updates regularly.
2020-10-22 07:51:44 -04:00
Matthias Clasen
ef7499a31b gtk-demo: Add alternative text to a GtkPicture
This lets us text GtkPicture a11y support.
2020-10-22 07:51:44 -04:00
Matthias Clasen
ed571ae68a picture: Set alternative text as description
Use the alternative text as accessible description
for GtkPicture.
2020-10-22 07:51:44 -04:00
Matthias Clasen
e2b3cbac23 colorbutton: Improve accessibility
Make the swatch not appear selectable, and
set an accessible label on it.
2020-10-22 07:51:44 -04:00
Matthias Clasen
ba290eb9b0 a11y: Add actions for color swatches
Add the same actions that we exported in GTK 3.
2020-10-21 23:36:22 -04:00
Matthias Clasen
3805e1d507 colorswatch: Export some functions for a11y
Make simple functions to activate, select or customize
a GtkColorSwatch. These will be exported by a11y as
actions.
2020-10-21 23:36:22 -04:00
Matthias Clasen
daf3b3a3b4 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2734
2020-10-22 02:52:46 +00:00
Matthias Clasen
800eb76a2d linkbutton: Use the LINK role
It is a bit ambiguous, but I think link buttons are
more links than buttons. See WAI-ARIA for a discussion
of the differences.

Update tests to match.
2020-10-21 22:19:54 -04:00
Matthias Clasen
bcbc6159f4 a11y: Document abstract roles
Since we mention abstract roles in the documentation
for GtkAccessibleRole, we should say what roles are
abstract. Doing this shows that we actually use two
abstract roles heavily, ourselves: WIDGET and WINDOW.
2020-10-21 21:47:14 -04:00
Matthias Clasen
5f8c6d2287 a11y: Document roles used in menu 2020-10-21 21:40:19 -04:00
Matthias Clasen
88eb3a9c34 atspi: Give model buttons a click action too
GtkModelButton is no longer derived from GtkButton,
but can still treat it like a button for the purposes
of having a click action. This lets ATs activate
menu items again.
2020-10-21 21:27:38 -04:00
Matthias Clasen
3e43dda9d4 modelbutton: Recreate our AT context
When the button role changes, we want to update the
accessible role to match. Since accessible roles are
unchangeable post-creation of the AT context, we have
to cheat a bit and recreate the whole context.
2020-10-21 21:27:38 -04:00
Matthias Clasen
f96a1cfadd modelbutton: Initial accessibility setup
Set the accessible role to GTK_ACCESSIBLE_ROLE_MENU_ITEM.
This is incomplete, we need to recreate the context when
the buttons role changes, and there are other things that
need to be set.
2020-10-21 21:27:38 -04:00
Matthias Clasen
758bcd5343 popovermenubar: Initial accessibility setup
Set roles, properties and relations according to the
ARIA authoring practices document. This is not quite
complete.
2020-10-21 21:27:38 -04:00
Matthias Clasen
2bfd4196fb popovermenu: Initial accessibility setup
Set roles, properties and relations according to the
ARIA authoring practices document.
2020-10-21 21:27:38 -04:00
Xavier Claessens
1b7a99cb24 Apply 1 suggestion(s) to 1 file(s) 2020-10-22 00:36:23 +00:00
Matthias Clasen
087c0078ca menubutton: initial accessibility setup
Set roles, properties and relations according to the
ARIA authoring practices document.
2020-10-21 19:47:48 -04:00
Matthias Clasen
b9ae54c951 separator: Remove unnecessary code
gtk_widget_update_orientation already sets the
accessible property, no need to do it again.
2020-10-21 19:47:48 -04:00
Emmanuele Bassi
7ac6e25ffc Use GtkApplication in the examples
Some people read the "Getting Started" section as a series of
incremental lessons, and having the examples go from GtkApplication to
the old style "init / spin the main loop" confuses them.

We should be using GtkApplication everywhere in our examples.
2020-10-21 22:44:53 +01:00
Matthias Clasen
d3089ebbc2 progressbar: Hide internal structure from a11y
According to section 7.1 of WAI-ARIA, the progressbar role
has the "Children presentational" characteristic, which
indicates that children should not be represented in
the a11y tree.
2020-10-21 15:09:55 -04:00
Matthias Clasen
14a64c7372 levelbar: Hide internal structure from a11y
According to section 7.1 of WAI-ARIA, the meter role
has the "Children presentational" characteristic, which
indicates that children should not be represented in
the a11y tree.
2020-10-21 15:04:34 -04:00
Matthias Clasen
ca9b06878d switch: Hide internal structure from a11y
According to section 7.1 of WAI-ARIA, the switch role
has the "Children presentational" characteristic, which
indicates that children should not be represented in
the a11y tree.
2020-10-21 14:55:13 -04:00
Matthias Clasen
8f100269ad scale: Hide internal structure from a11y
According to section 7.1 of WAI-ARIA, the slider role
has the "Children presentational" characteristic, which
indicates that children should not be represented in
the a11y tree, which makes sense, since these are all
just internal gizmos.
2020-10-21 14:53:17 -04:00
Matthias Clasen
48bb9200d9 a11y: Treat PRESENTATION like NONE
This is what ARIA tells us to do. NONE is just another
name for PRESENTATION.
2020-10-21 14:40:34 -04:00
Matthias Clasen
d7794bf608 docs: Add some more to the migration guide
Expand the section on life-cycle handling with some
more details.
2020-10-21 14:30:17 -04:00
Matthias Clasen
3151906157 docs: Small corrections to the a11y overview
The section titles were mixed up wrt to the content
of the sections.
2020-10-21 14:23:10 -04:00
Matthias Clasen
6153efd02a Document GTK_ACCESSIBLE_ROLE_NONE
We use it for a specific purpose now, so document it.
2020-10-21 14:21:12 -04:00
Matthias Clasen
b5b8f42a0c Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #3285

See merge request GNOME/gtk!2733
2020-10-21 18:09:42 +00:00
Matthias Clasen
043ffd38bc text: React to text attribute changes in css
Recompute the layout when the css style change
affects text attributes. This matches what we do
in GtkLabel, and without this, changing the
font-features-setting css property in the Inspector
does not have immediate effect.
2020-10-21 13:46:58 -04:00
Carlos Garnacho
32b826e312 Merge branch 'wip/exalm/swipe4' into 'master'
gestureswipe: Count last event when calculating velocity

See merge request GNOME/gtk!2715
2020-10-21 16:20:58 +00:00
Alexander Mikhaylenko
700ca3b946 gestureswipe: Count last event when calculating velocity
The last event, matching lifting the finger/releasing the mouse button,
is important when there's a large delay between it and the previous events,
as in when performing a movement, stopping, then releasing fingers as
opposed to doing a swipe.

If this event is skipped, doing this will result in kinetic deceleration
matching the previous finger movement, while the expected behavior would
be no deceleration.

See also 5dc6194b98 for a similar fix in
GtkEventControllerScroll.
2020-10-21 20:59:15 +05:00
Emmanuele Bassi
e45dd771db a11y: Emit ChildrenChanged for toplevel list changes
GtkAtSpiRoot is not a context, which means it needs to emit
ChildrenChanged events by itself whenever a toplevel is added to, or
removed from, the list of toplevels.
2020-10-21 15:37:57 +01:00
Emmanuele Bassi
698cbee1fb a11y: Move ChildrenChanged emitter to ATSPI utilities
We are going to use it from GtkAtSpiRoot, which is not a
GtkAtSpiContext.
2020-10-21 15:18:23 +01:00
Emmanuele Bassi
80756322cd a11y: Handle relations in UI files
A bit hacky: we skip parsing values that have a reference or
reference-list type, but we do not error out. Instead, we return a NULL
value, which we catch in the GtkBuildable interface implementation to
get the actual object, and construct a reference list value.

There's still some ickyness around the value type that can only be
solved by having an attribute and role taxonomy.
2020-10-21 14:48:49 +01:00
Emmanuele Bassi
f1e14c4858 a11y: Implement ChildrenChanged atspi.Event 2020-10-21 14:33:20 +01:00
Emmanuele Bassi
8d46bd1d7c a11y: Notify of changes in the children list 2020-10-21 14:04:49 +01:00
Emmanuele Bassi
fbb08a30e2 a11y: Add child state change to GtkATContext
And the required private API in GtkAccessible to notify AT contexts of
changes in the children list.
2020-10-21 14:04:49 +01:00
Matthias Clasen
81371e7c79 columnview: Put overshoot underneath the headers
This matches what we do in GtkTreeView.

Fixes: #3285
2020-10-21 08:39:50 -04:00
Emmanuele Bassi
7702670d86 docs: Document the "accessibility" custom tag 2020-10-21 13:33:37 +01:00
Emmanuele Bassi
9e4316bf96 a11y: Add an "accessibility" section to the builder XML tree
Accessible attributes are not GObject properties. This means that we
need a custom parser for setting attributes in our UI description files.

The new section is defined as a sub-tree with the `<accessibility>`
element at its root, and elements for each type of accessible
attributes, i.e. properties, relations, and states:

```xml
  <object class="..." id="...">
    <accessibility>
      <property name="label">The accessible label</property>
      <state name="pressed">false</state>
      <relation name="labelled-by">label1</relation>
    </accessibility>
  </object>
```

The name of the attribute is the enumeration value; the value is defined
by the WAI-ARIA specification.
2020-10-21 13:33:37 +01:00
Emmanuele Bassi
4ea2a6628f a11y: Add parsing code for accessible values
We need to be able to go from a string representation of an accessible
value to its GtkAccessibleValue instance.
2020-10-21 13:33:37 +01:00
Matthias Clasen
39dfdac771 range: Hide internals from accessibility
The nameless, faceless gizmos inside a range do not
contribute to the accessible experience at all, lets
not add them to the tree. All the accessible functionality
is on the main widget (either a scale or a scrollbar).
2020-10-21 08:01:25 -04:00
Matthias Clasen
b7fa00e22d Cosmetics 2020-10-21 08:01:25 -04:00
Matthias Clasen
3df0a333ad frame: Set up accessible relations
Mark the child as labelled-by the label.
2020-10-21 08:01:25 -04:00
Matthias Clasen
8880e3bd2e Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2729
2020-10-21 11:43:58 +00:00
Timm Bäder
0b5b908a74 Merge branch 'wip/exalm/nullable' into 'master'
widget: Add missing (nullable) on binding functions

See merge request GNOME/gtk!2730
2020-10-21 08:17:45 +00:00
Alexander Mikhaylenko
31a072497d widget: Add missing (nullable) on binding functions
Even though they are marked as (skip), they are used in Vala and have wrong
types there atm.
2020-10-21 12:27:51 +05:00
Matthias Clasen
cbb6828657 docs: Document more accessible roles
Document that GtkText is skipped in accessibility.
2020-10-20 23:19:30 -04:00
Matthias Clasen
8e170217a1 Cosmetics
Typo fix.
2020-10-20 23:19:18 -04:00
Matthias Clasen
36d4a8090f docs: Document more accessible roles
GtkColumnView and its various components use a lot
of accessible roles.
2020-10-20 23:09:11 -04:00
Matthias Clasen
341244203f docs: Document more accessible roles
GtkListView and GtkGridView were missing this as well.
2020-10-20 22:53:30 -04:00
Matthias Clasen
2023914186 docs: Document accessible roles of some classes
GtkListBox and GtkFlowBox were missing this.
2020-10-20 22:51:11 -04:00
Matthias Clasen
ef9ec43469 a11y: Add some more tests 2020-10-20 22:44:24 -04:00
Matthias Clasen
67411701c6 inspector: Show accessible object path
Show the object path of the object on the a11y bus,
this is can be useful information. While we are here,
make sure that the Inspector does not throw criticals
when used with GTK_NO_A11Y=1.
2020-10-20 21:56:54 -04:00
Matthias Clasen
e20a3339bf atsi: Fix emission of text selection changes
We were not emitting text-selection-changed and
text-caret-moved as expected.
2020-10-20 21:31:23 -04:00
Matthias Clasen
a8baee342c a11y: Fix handling of LABELLED_BY relation
There were several places where we were confusing
GList and GSList and list->data and list->next, causing
a crash in the accessible name computation for buttons
with mnemonic labels.
2020-10-20 21:27:39 -04:00
Matthias Clasen
6a1cb3304b docs: Mention subclassing and destroy in the migration guide
Mention changes regarding subclassing and life-cycle
handling in the migration guide.
2020-10-20 18:26:38 -04:00
Benjamin Otte
45400fe381 Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master

Closes #3280

See merge request GNOME/gtk!2725
2020-10-20 14:05:49 +00:00
Matthias Clasen
5504278b78 Merge branch 'matthiasc/for-master' into 'master'
Some more a11y tests

See merge request GNOME/gtk!2726
2020-10-20 05:57:45 +00:00
Matthias Clasen
93481e6c2e a11y: Add tests for GtkFlowBox
Test that roles, states and properties are as expected.
2020-10-20 01:12:20 -04:00
Matthias Clasen
b9e9898212 a11y: Add tests for GtkListBox
Test that roles, states and properties are as expected.
2020-10-20 01:07:13 -04:00
Matthias Clasen
7c47b6907b a11y: Add tests for GtkStack and GtkStackSwitcher
Test that the roles, states and relations are
as expected.
2020-10-20 00:46:07 -04:00
Matthias Clasen
b10d5ec8ff a11y: Add a test for label properties
Now that we set the label property, we should test it too.
2020-10-20 00:25:39 -04:00
Benjamin Otte
8dad615f04 gtk: Remove unused header include
gtkcssnodeprivate.h was mainly used for repositioning CSS nodes in
gadgets, and gadgets are gone now.
2020-10-20 04:50:12 +02:00
Benjamin Otte
23e086089d entry: Keep widget order
... instead of just ordering the CSS nodes.
2020-10-20 04:50:12 +02:00
Benjamin Otte
9317a9f35c flowbox: Keep widget order
... instead of just ordering the CSS nodes.
2020-10-20 04:50:12 +02:00
Benjamin Otte
22100089c3 listbox: Reorder the widgets when sorting
... instead of just reordering the CSS nodes.
2020-10-20 04:50:12 +02:00
Benjamin Otte
074d54ef5a listitemwidget: Remove unnecessary code
gtk_widget_insert_after() reorders CSS nodes properly.
2020-10-20 04:50:12 +02:00
Benjamin Otte
ddd1b0958d notebook: Remove unnecessary code
gtk_widget_insert_after() reorders CSS nodes properly.

Also fix page reordering code to actually reorder the widget instead of
just the CSS nodes.
2020-10-20 04:50:12 +02:00
Benjamin Otte
d77902365d box: Remove unnecessary code
gtk_widget_insert_after() reorders CSS nodes properly.
2020-10-20 04:50:12 +02:00
Benjamin Otte
d9b216e629 widget: Always update the CSS node
Anybody who keeps their own CSS nodes around or wants to order CSS nodes
different from widgets will from now on have to do it manually all the
time.

This is outdated behavior, nobody should be doing either of those two
things.

Also, the correct case is much more common, and not doing it
automatically was causing bugs.

Fixes #3280
2020-10-20 04:50:12 +02:00
Matthias Clasen
a7bd6b094a Merge branch 'matthiasc/for-master' into 'master'
Some a11y docs and fixes

See merge request GNOME/gtk!2724
2020-10-20 01:45:17 +00:00
Matthias Clasen
eeae1b1ea7 a11y: Fix accessible tree inconsistency
The stack page objects were not properly integrated
in the accessible tree - they were appearing as parent
of the pages when navigating up, but not as children
of the stack when navigating down.
2020-10-19 21:15:44 -04:00
Matthias Clasen
0a71dc1bed stack: Minor doc addition 2020-10-19 21:15:44 -04:00
Matthias Clasen
feb73a5ebb docs: Flesh out a11y section
Add some advice for making custom widgets accessible.
2020-10-19 20:01:57 -04:00
Matthias Clasen
83d8ae2f30 Merge branch 'wip/chergert/fix-macos-surface-under-pointer' into 'master'
macos: fix discovery of surface under pointer

See merge request GNOME/gtk!2722
2020-10-19 21:26:47 +00:00
Emmanuele Bassi
51f5690ae3 Merge branch 'ebassi/for-master' into 'master'
Ebassi/for master

See merge request GNOME/gtk!2720
2020-10-19 20:26:57 +00:00
Matthias Clasen
e58e6a0fbe Merge branch 'a11y/editable' into 'master'
Improve the accessible support for editables

See merge request GNOME/gtk!2719
2020-10-19 20:16:21 +00:00
Christian Hergert
eb82b2a9ca macos: fix discovery of surface under pointer 2020-10-19 12:35:41 -07:00
Matthias Clasen
dfc7d26275 a11y: Tweak name and description computation
Instead of falling back to the role nick for both,
fall back to the class name for the name, and to
the empty string for the description. This makes
labels show up in Accerciser the same way they
did in GTK 3, and seems more useful to me than
the alternative.
2020-10-19 14:58:34 -04:00
Matthias Clasen
77d1026c5a atspi: Use name and description as provided
GtkATContext already does fallbacks to derive values
for these, so no need for the atspi implementation to
do its own fallback on top of that.
2020-10-19 14:57:43 -04:00
Matthias Clasen
08ae513064 label: Set the accessible label property
This will make label text show up in ATs again.
2020-10-19 14:29:19 -04:00
Emmanuele Bassi
f52c86ae21 docs: Add a section on a11y patterns 2020-10-19 18:39:40 +01:00
Emmanuele Bassi
03745a489c docs: Start outlining a11y authoring practices
We should have documentation for application developers and widget
authors, so they can deal with the new accessibility API.
2020-10-19 18:37:30 +01:00
Matthias Clasen
63421b1876 a11y: Rename some methods
Our EditableText implementation works fine for any
editable, so don't name the functions in a way that
looks like they are only for entries.
2020-10-19 12:58:29 -04:00
Matthias Clasen
80e0e3fe4f gtk-demo: Set an accessible role
Set the expected accessible role on the tagged entry
widget in the demo of the same name. Accessible tools
may decide to ignore widgets that have the wrong role,
so setting an appropriate role is important.
2020-10-19 12:56:50 -04:00
Matthias Clasen
ef46fe0e8e Merge branch 'a11y/component' into 'master'
a11y: Implement Component

See merge request GNOME/gtk!2718
2020-10-19 16:54:45 +00:00
Emmanuele Bassi
7c7dabae8c a11y: Rework accessible name/description computation
The ARIA spec determines the name and description of accessible elements
in a more complex way that simply mapping to a single property; instead,
it will chain up multiple definitions (if it finds them). For instance,
let's assume we have a button that saves a file selected from a file
selection widget; the widgets have the following attributes:

 - the file selection widget has a "label" attribute set to the
   selected file, e.g. "Final paper.pdf"
 - the "download" button has a "label" attribute set to the
   "Download" string
 - the "download" button has a "labelled-by" attribute set to
   reference the file selection widget

The ARIA spec says that the accessible name of the "Download" button
should be computed as "Download Final paper.pdf".

The algorithm defined in section 4.3 of the WAI-ARIA specification
applies to both accessible names (using the "label" and "labelled-by"
attributes), and to accessible descriptions (using the "description" and
"described-by" attributes).
2020-10-19 17:54:14 +01:00
Matthias Clasen
9f9e7dffef atspi: Implement Text for more editables
Our Text implementation requires that we have
a GtkEditable with a delegate that is a GtkText
widget.

This change make the Text implementation work for
the custom widget in the tagged entry demo.
2020-10-19 12:44:50 -04:00
Goran Vidović
94729b4880 Update Croatian translation
(cherry picked from commit fab2558747)
2020-10-19 16:37:36 +00:00
Matthias Clasen
3918dd4643 Add gtk_editable_get_delegate
We need access to the delegate in the a11y layer,
so we might as well make this function public.
2020-10-19 12:36:54 -04:00
Matthias Clasen
04a51837f7 atspi: Emit bounds-changed
This is using the new bounds_change vfunc in GtkATContext.
2020-10-19 12:19:55 -04:00
Matthias Clasen
75a0bef921 widget: Mark the size as changed when it changes
This notifies the AT context that the widgets size
has changed.
2020-10-19 12:19:55 -04:00
Matthias Clasen
d50ebd947c a11y: Add bounds change api
Add a way for GTK to pass bounds change information
to the AT context.
2020-10-19 12:19:55 -04:00
Matthias Clasen
8e4f8a45a9 atspi: Implement Component
Implement the non-questionable parts of the Component interface
for accessibles which are widgets.

This does not include:
 - global coordinates
 - setters
 - scrolling
 - alpha, layers, zorder, and the like
2020-10-19 12:19:55 -04:00
Matthias Clasen
3ad03b1706 a11y: Add a separate vfunc for platform changes
The state_change vfunc is becoming unwieldy. Lets move
the platform changes to their own vfunc, as a start.
2020-10-19 12:09:08 -04:00
Matthias Clasen
dfe00c4ac4 atspi: Be more careful
We have non-widget accessibles now, so guard against
change notification being emitted on them.
2020-10-19 12:09:08 -04:00
Matthias Clasen
5bb656af4c Cosmetics
Add some more fold markers.
2020-10-19 12:08:47 -04:00
Matthias Clasen
469b913cdf Cosmetics 2020-10-19 12:00:53 -04:00
Matthias Clasen
9c1c8a554a Cosmetics 2020-10-19 11:46:25 -04:00
Matthias Clasen
2359510b1f Merge branch 'matthiasc/for-master' into 'master'
Various columnview fixes

Closes #3265, #3272, and #3276

See merge request GNOME/gtk!2717
2020-10-19 15:00:17 +00:00
Xavier Claessens
25a1c421b5 Merge branch 'msvc' into 'master'
gdkglcontext: Fix build with MSVC

Closes #3268

See merge request GNOME/gtk!2713
2020-10-19 13:46:54 +00:00
Matthias Clasen
ef308e5f17 Merge branch 'annotations_gtkaboutdialog' into 'master'
Add nullable return annotations in GtkAboutDialog

See merge request GNOME/gtk!2712
2020-10-19 13:46:32 +00:00
Sophie Herold
33f0809784 Add nullable return annotations in GtkAboutDialog 2020-10-19 13:46:32 +00:00
Matthias Clasen
81ee273e98 columnview: Make right-aligned content work
Make right-aligned content work in resized columns.
There is currently no way to make a title right-aligned,
but we can still make it work correctly. This is a follow
up to 7eb0ae39c5.

Fixes: #3276
2020-10-19 09:39:07 -04:00
Matthias Clasen
f3fe1812aa Adwaita: Put column separators on the left
When resizing columns, we clip a shrunk column
on the right, so the separator disappears in that
case unless we put it on the left side of the other
column.
2020-10-19 09:39:05 -04:00
Xavier Claessens
be8246a6cb gdkglcontext: Fix build with MSVC
GLDEBUGPROC callback is defined with APIENTRY which is a windows
specific calling convention. That macro expands to nothing when building
on other platforms.

Fixes: #3268.
2020-10-19 09:17:53 -04:00
Matthias Clasen
25d0fb4c76 columview: Make resize area a bit larger
This make column resizing feel less like a game
of hit-and-miss. Ultimatively, we should add an
alternative to this.
2020-10-19 08:31:37 -04:00
Matthias Clasen
98b66acbdd columview: Implement double-click to reset headers
Implement the same behavior as GtkTreeView:
double-click on the header boundary resets the
header to its automatic width.

Fixes: #3272
2020-10-19 08:31:37 -04:00
Matthias Clasen
1976df1e54 columnview: Make resize cursors reliable
Ensure that the column resize cursor stays in place
for the duration of the resize drag. This is a bit
annoying, since the implicit grab can end up on the
header of a different column from the one we are
resizing, so just set the cursor on all column headers.
2020-10-19 08:30:22 -04:00
Matthias Clasen
39baf4fff4 columnview: Fix more issues with column resizing
Make it so that for overlapping resize rectangles (with
very narrow columns), we prefer the narrow column, so you
can regrow a column after shrinking it all the way.

Related: #3274
2020-10-19 08:30:05 -04:00
Matthias Clasen
a88e5a5f4e columnview: Fix some issues with column resizing
Ensure that we place the resize rectangle at the visible
right edge of the column, not where the allocation ends
(we clip the header drawing, after all).

Related: #3274
2020-10-19 08:29:29 -04:00
Matthias Clasen
a39e519bed inspector: Clear overlays on unroot
In dispose(), we can't access the root anymore,
since we're already unrooted.

Fixes: #3265
2020-10-17 13:11:58 -04:00
Xavier Claessens
a4aa6d79ad meson: Use feature options for media and print backends
This gracefully disable ffmpeg, gstreamer, cups and cloudprint optional
dependencies when they are not available, while still giving full
control to distributors using -Dauto_features=enabled.
2020-10-17 09:54:47 -04:00
Xavier Claessens
ea3933b87a meson: Make vulkan and xinerama optional deps default to 'auto'
It is nicer for contributors to have a build that works by default.
Distributors should be using -Dauto_features=enabled to get ride of
automagic options.
2020-10-17 09:54:47 -04:00
Xavier Claessens
6ae9f7e7c3 meson: Simplify xinerama dependency check 2020-10-17 09:54:47 -04:00
Xavier Claessens
efbbfb6547 meson: Simplify how cairo dependencies are checked
There is no reason to fallback to find_library for cairo and still rely
on pkg-config for all other dependencies, and just when using MSVC. When
building and pkg-config is not working it is preferable to fallback to a
subproject just like for all other dependencies.

Also add cairo.wrap now that meson support has been merged upstream.
2020-10-17 09:54:47 -04:00
327 changed files with 11241 additions and 4803 deletions

76
NEWS
View File

@@ -1,3 +1,79 @@
Overview of Changes in master
=============================
* GtkColumnView:
- Improve column resizing
- Make double-click reset column widths
- Move header outside of scrollbars
* GtkSearchEntry:
- Add an icon
* GtkDropDown:
- Polish the appearance
* GtkColorChooser:
- Accessibility improvements
* GtkPopoverMenu:
- Add accessibility support
- Allow custom items. This adds new API:
gtk_popover_menu_add/remove_child
gtk_popover_menu_bar_add/remove_child
* GtkTextView:
- Fix rendering and positioning of anchored children
* Constraints:
- Fix loading constraints from ui files
* Media support:
- Use cubic instead of linear volume
* Accessibility:
- Implement Component for all widgets
- Implement Text and EditableText for all editables
- Rework accessible name/description computation
- Add documentation for app and widget developers
- Handle HIDDEN state changes by adding/removing elements
- Support setting accessibility attributes in ui files
* Introspection:
- Add some missing annotations
* gdk:
- Deliver events on flush
- Drop the unused GdkPoint struct from the API
* Demos:
- Add another constraints demo
- Tweak various demos to improve consistency
* Tools:
- Improve gtk4-builder-tool handling of various
widgets when converting ui files from GTK 3
* Documentation:
- Use GtkApplication in all examples
- Improve and expand the widget gallery
* Testsuite:
- Improve coverage of GDK
- Improve coverage of gtk4-builder-tool
* Build:
- Fix the build with cups 2.2.12
- Make cloudprint support build without warnings
* OS X:
- Fix various input issues
- Make GtkGLArea work (with the cairo backend)
* Translation updates:
German
Polish
Overview of Changes in 3.99.3
=============================

View File

@@ -1,8 +1,9 @@
/* config.h.in. Generated from configure.ac by autoheader. */
/* always defined to indicate that i18n is enabled */
#define ENABLE_NLS 1
/* Use structured logging */
#define G_LOG_STRUCTURED 1
/* The prefix for our gettext translation domains. */
#mesondefine GETTEXT_PACKAGE

View File

@@ -1,9 +1,16 @@
/* Constraints/Simple
/* Constraints/Simple Constraints
* #Keywords: GtkLayoutManager
*
* GtkConstraintLayout provides a layout manager that uses relations
* between widgets (also known as "constraints") to compute the position
* between widgets (also known as constraints) to compute the position
* and size of each child.
*
* In addition to child widgets, the constraints can involve spacer
* objects (also known as “guides”). This example has a guide between
* the two buttons in the top row.
*
* Try resizing the window to see how the constraints react to update
* the layout.
*/
#include <glib/gi18n.h>
@@ -234,15 +241,12 @@ simple_grid_init (SimpleGrid *self)
self->button1 = gtk_button_new_with_label ("Child 1");
gtk_widget_set_parent (self->button1, widget);
gtk_widget_set_name (self->button1, "button1");
self->button2 = gtk_button_new_with_label ("Child 2");
gtk_widget_set_parent (self->button2, widget);
gtk_widget_set_name (self->button2, "button2");
self->button3 = gtk_button_new_with_label ("Child 3");
gtk_widget_set_parent (self->button3, widget);
gtk_widget_set_name (self->button3, "button3");
GtkLayoutManager *manager = gtk_widget_get_layout_manager (GTK_WIDGET (self));
build_constraints (self, GTK_CONSTRAINT_LAYOUT (manager));
@@ -259,7 +263,8 @@ do_constraints (GtkWidget *do_widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Constraints");
gtk_window_set_title (GTK_WINDOW (window), "Simple Constraints");
gtk_window_set_default_size (GTK_WINDOW (window), 260, -1);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);

View File

@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkWindow" id="window1">
<property name="title" translatable="yes">ConstraintsBuilder</property>
<property name="default-width">260</property>
<child>
<object class="ConstraintsGrid">
<property name="layout-manager">
<object class="GtkConstraintLayout">
<constraints>
<guide name="space"
min-width="10" min-height="10"
nat-width="100" nat-height="10"
max-width="200" max-height="20"
strength="strong"/>
<constraint target="button1" target-attribute="width"
relation="le"
constant="200"
strength="required"/>
<constraint target="super" target-attribute="start"
relation="eq"
source="button1" source-attribute="start"
constant="-8"
strength="required"/>
<constraint target="button1" target-attribute="width"
relation="eq"
source="button2" source-attribute="width"
strength="required"/>
<constraint target="button1" target-attribute="end"
relation="eq"
source="space" source-attribute="start"
strength="required"/>
<constraint target="space" target-attribute="end"
relation="eq"
source="button2" source-attribute="start"
strength="required"/>
<constraint target="super" target-attribute="end"
relation="eq"
source="button2" source-attribute="end"
constant="8"
strength="required"/>
<constraint target="super" target-attribute="start"
relation="eq"
source="button3" source-attribute="start"
constant="-8"
strength="required"/>
<constraint target="super" target-attribute="end"
relation="eq"
source="button3" source-attribute="end"
constant="8"
strength="required"/>
<constraint target="super" target-attribute="top"
relation="eq"
source="button1" source-attribute="top"
constant="-8"
strength="required"/>
<constraint target="super" target-attribute="top"
relation="eq"
source="button2" source-attribute="top"
constant="-8"
strength="required"/>
<constraint target="button1" target-attribute="bottom"
relation="eq"
source="button3" source-attribute="top"
constant="-12"
strength="required"/>
<constraint target="button2" target-attribute="bottom"
relation="eq"
source="button3" source-attribute="top"
constant="-12"
strength="required"/>
<constraint target="button3" target-attribute="height"
relation="eq"
source="button1" source-attribute="height"
strength="required"/>
<constraint target="button3" target-attribute="height"
relation="eq"
source="button2" source-attribute="height"
strength="required"/>
<constraint target="super" target-attribute="bottom"
relation="eq"
source="button3" source-attribute="bottom"
constant="8"
strength="required"/>
</constraints>
</object>
</property>
<child>
<object class="GtkButton" id="button1">
<property name="label">Child 1</property>
</object>
</child>
<child>
<object class="GtkButton" id="button2">
<property name="label">Child 2</property>
</object>
</child>
<child>
<object class="GtkButton" id="button3">
<property name="label">Child 3</property>
</object>
</child>
</object>
</child>
</object>
</interface>

View File

@@ -1,7 +1,7 @@
/* Constraints/Interactive
/* Constraints/Interactive Constraints
* #Keywords: GtkConstraintLayout
*
* Demonstrate how constraints can be updates during user interaction.
* This example shows how constraints can be updated during user interaction.
* The vertical edge between the buttons can be dragged with the mouse.
*/
@@ -215,7 +215,8 @@ do_constraints2 (GtkWidget *do_widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Constraints");
gtk_window_set_title (GTK_WINDOW (window), "Interactive Constraints");
gtk_window_set_default_size (GTK_WINDOW (window), 260, -1);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);

View File

@@ -2,6 +2,10 @@
*
* GtkConstraintLayout allows defining constraints using a
* compact syntax called Visual Format Language, or VFL.
*
* A typical example of a VFL specification looks like this:
*
* H:|-[button1(==button2)]-12-[button2]-|
*/
#include <glib/gi18n.h>
@@ -134,7 +138,8 @@ do_constraints3 (GtkWidget *do_widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Constraints");
gtk_window_set_title (GTK_WINDOW (window), "ConstraintsVFL");
gtk_window_set_default_size (GTK_WINDOW (window), 260, -1);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);

View File

@@ -0,0 +1,72 @@
/* Constraints/Builder
*
* GtkConstraintLayouts can be created in .ui files, and constraints can be
* set up at that time as well, as this example demonstrates. It uses the
* same setup as the “Simple” constraints demo.
*/
#include <glib/gi18n.h>
#include <gtk/gtk.h>
G_DECLARE_FINAL_TYPE (ConstraintsGrid, constraints_grid, CONSTRAINTS, GRID, GtkWidget)
struct _ConstraintsGrid
{
GtkWidget parent_instance;
};
G_DEFINE_TYPE (ConstraintsGrid, constraints_grid, GTK_TYPE_WIDGET)
static void
constraints_grid_init (ConstraintsGrid *grid)
{
}
static void
constraints_grid_dispose (GObject *object)
{
GtkWidget *widget = GTK_WIDGET (object);
GtkWidget *child;
while ((child = gtk_widget_get_first_child (widget)))
gtk_widget_unparent (child);
G_OBJECT_CLASS (constraints_grid_parent_class)->dispose (object);
}
static void
constraints_grid_class_init (ConstraintsGridClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = constraints_grid_dispose;
}
GtkWidget *
do_constraints4 (GtkWidget *do_widget)
{
static GtkWidget *window;
if (!window)
{
GtkBuilder *builder;
g_type_ensure (constraints_grid_get_type ());
builder = gtk_builder_new_from_resource ("/constraints4/constraints.ui");
window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
g_object_unref (builder);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_window_destroy (GTK_WINDOW (window));
return window;
}

View File

@@ -18,6 +18,9 @@
<file>demoimage.c</file>
<file>demoimage.h</file>
</gresource>
<gresource prefix="/constraints4">
<file>constraints.ui</file>
</gresource>
<gresource prefix="/css_accordion">
<file>css_accordion.css</file>
<file>reset.css</file>
@@ -226,9 +229,12 @@
<file>revealer.ui</file>
</gresource>
<gresource prefix="/images">
<file>pixbufpaintable.h</file>
<file>pixbufpaintable.c</file>
<file>alphatest.png</file>
<file>floppybuddy.gif</file>
<file>gtk-logo.webm</file>
<file alias="org.gtk.Demo4.svg">data/scalable/apps/org.gtk.Demo4.svg</file>
</gresource>
<gresource prefix="/video-player">
<file>bbb.png</file>
@@ -242,6 +248,7 @@
<file>constraints.c</file>
<file>constraints2.c</file>
<file>constraints3.c</file>
<file>constraints4.c</file>
<file>css_accordion.c</file>
<file>css_basics.c</file>
<file>css_blendmodes.c</file>

View File

@@ -83,7 +83,7 @@
</menu>
<object class="GtkAboutDialog" id="aboutdialog1">
<property name="program-name" translatable="yes">Builder demo</property>
<property name="logo-icon-name" translatable="yes">gtk3-demo</property>
<property name="logo-icon-name" translatable="yes">org.gtk.Demo4</property>
<property name="modal">True</property>
</object>
<object class="GtkWindow" id="window1">

View File

@@ -44,11 +44,23 @@ G_DEFINE_TYPE_WITH_CODE (DemoTaggedEntry, demo_tagged_entry, GTK_TYPE_WIDGET,
static void
demo_tagged_entry_init (DemoTaggedEntry *entry)
{
GtkCssProvider *provider;
entry->text = gtk_text_new ();
gtk_widget_set_hexpand (entry->text, TRUE);
gtk_widget_set_vexpand (entry->text, TRUE);
gtk_widget_set_parent (entry->text, GTK_WIDGET (entry));
gtk_editable_init_delegate (GTK_EDITABLE (entry));
gtk_editable_set_width_chars (GTK_EDITABLE (entry->text), 6);
gtk_editable_set_max_width_chars (GTK_EDITABLE (entry->text), 6);
gtk_widget_add_css_class (GTK_WIDGET (entry), "tagged");
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_resource (provider, "/tagged_entry/tagstyle.css");
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
800);
g_object_unref (provider);
}
static void
@@ -116,6 +128,7 @@ demo_tagged_entry_class_init (DemoTaggedEntryClass *klass)
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BOX_LAYOUT);
gtk_widget_class_set_css_name (widget_class, "entry");
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_TEXT_BOX);
}
static GtkEditable *
@@ -211,7 +224,6 @@ static void
demo_tagged_entry_tag_init (DemoTaggedEntryTag *tag)
{
GtkGesture *gesture;
GtkCssProvider *provider;
tag->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_parent (tag->box, GTK_WIDGET (tag));
@@ -221,13 +233,6 @@ demo_tagged_entry_tag_init (DemoTaggedEntryTag *tag)
gesture = gtk_gesture_click_new ();
g_signal_connect (gesture, "released", G_CALLBACK (on_released), tag);
gtk_widget_add_controller (GTK_WIDGET (tag), GTK_EVENT_CONTROLLER (gesture));
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_resource (provider, "/tagged_entry/tagstyle.css");
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
800);
g_object_unref (provider);
}
static void

View File

@@ -113,12 +113,9 @@ apply_transform (CanvasItem *item)
y = gtk_widget_get_allocated_height (item->label) / 2.0;
item->r = sqrt (x*x + y*y);
transform = gsk_transform_translate (
gsk_transform_rotate (
gsk_transform_translate (NULL,
&(graphene_point_t) { item->r, item->r }),
item->angle + item->delta),
&(graphene_point_t) { - x, - y });
transform = gsk_transform_translate (NULL, &(graphene_point_t) { item->r, item->r });
transform = gsk_transform_rotate (transform, item->angle + item->delta);
transform = gsk_transform_translate (transform, &(graphene_point_t) { -x, -y });
gtk_fixed_set_child_transform (GTK_FIXED (item->fixed), item->label, transform);
gsk_transform_unref (transform);

View File

@@ -325,9 +325,8 @@ do_drawingarea (GtkWidget *do_widget)
/*
* Create the groups area
*/
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label),
"<u>Knockout groups</u>");
label = gtk_label_new ("Knockout groups");
gtk_widget_add_css_class (label, "heading");
gtk_box_append (GTK_BOX (vbox), label);
frame = gtk_frame_new (NULL);
@@ -344,9 +343,8 @@ do_drawingarea (GtkWidget *do_widget)
* Create the scribble area
*/
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label),
"<u>Scribble area</u>");
label = gtk_label_new ("Scribble area");
gtk_widget_add_css_class (label, "heading");
gtk_box_append (GTK_BOX (vbox), label);
frame = gtk_frame_new (NULL);

View File

@@ -65,18 +65,22 @@ strings_setup_item_single_line (GtkSignalListItemFactory *factory,
GtkListItem *item)
{
GtkWidget *box, *image, *title;
GtkWidget *checkmark;
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
image = gtk_image_new ();
title = gtk_label_new ("");
gtk_label_set_xalign (GTK_LABEL (title), 0.0);
checkmark = gtk_image_new_from_icon_name ("object-select-symbolic");
gtk_box_append (GTK_BOX (box), image);
gtk_box_append (GTK_BOX (box), title);
gtk_box_append (GTK_BOX (box), checkmark);
g_object_set_data (G_OBJECT (item), "title", title);
g_object_set_data (G_OBJECT (item), "image", image);
g_object_set_data (G_OBJECT (item), "checkmark", checkmark);
gtk_list_item_set_child (item, box);
}
@@ -86,6 +90,7 @@ strings_setup_item_full (GtkSignalListItemFactory *factory,
GtkListItem *item)
{
GtkWidget *box, *box2, *image, *title, *description;
GtkWidget *checkmark;
image = gtk_image_new ();
title = gtk_label_new ("");
@@ -93,6 +98,7 @@ strings_setup_item_full (GtkSignalListItemFactory *factory,
description = gtk_label_new ("");
gtk_label_set_xalign (GTK_LABEL (description), 0.0);
gtk_widget_add_css_class (description, "dim-label");
checkmark = gtk_image_new_from_icon_name ("object-select-symbolic");
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
@@ -101,26 +107,48 @@ strings_setup_item_full (GtkSignalListItemFactory *factory,
gtk_box_append (GTK_BOX (box), box2);
gtk_box_append (GTK_BOX (box2), title);
gtk_box_append (GTK_BOX (box2), description);
gtk_box_append (GTK_BOX (box), checkmark);
g_object_set_data (G_OBJECT (item), "title", title);
g_object_set_data (G_OBJECT (item), "image", image);
g_object_set_data (G_OBJECT (item), "description", description);
g_object_set_data (G_OBJECT (item), "checkmark", checkmark);
gtk_list_item_set_child (item, box);
}
static void
strings_bind_item (GtkSignalListItemFactory *factory,
GtkListItem *item)
selected_item_changed (GtkDropDown *dropdown,
GParamSpec *pspec,
GtkListItem *item)
{
GtkWidget *checkmark;
checkmark = g_object_get_data (G_OBJECT (item), "checkmark");
if (gtk_drop_down_get_selected_item (dropdown) == gtk_list_item_get_item (item))
gtk_widget_set_opacity (checkmark, 1.0);
else
gtk_widget_set_opacity (checkmark, 0.0);
}
static void
strings_bind_item (GtkSignalListItemFactory *factory,
GtkListItem *item,
gpointer data)
{
GtkDropDown *dropdown = data;
GtkWidget *image, *title, *description;
GtkWidget *checkmark;
StringHolder *holder;
GtkWidget *popup;
holder = gtk_list_item_get_item (item);
title = g_object_get_data (G_OBJECT (item), "title");
image = g_object_get_data (G_OBJECT (item), "image");
description = g_object_get_data (G_OBJECT (item), "description");
checkmark = g_object_get_data (G_OBJECT (item), "checkmark");
gtk_label_set_label (GTK_LABEL (title), holder->title);
if (image)
@@ -133,19 +161,43 @@ strings_bind_item (GtkSignalListItemFactory *factory,
gtk_label_set_label (GTK_LABEL (description), holder->description);
gtk_widget_set_visible (description , holder->description != NULL);
}
popup = gtk_widget_get_ancestor (title, GTK_TYPE_POPOVER);
if (popup && gtk_widget_is_ancestor (popup, GTK_WIDGET (dropdown)))
{
gtk_widget_show (checkmark);
g_signal_connect (dropdown, "notify::selected-item",
G_CALLBACK (selected_item_changed), item);
selected_item_changed (dropdown, NULL, item);
}
else
{
gtk_widget_hide (checkmark);
}
}
static void
strings_unbind_item (GtkSignalListItemFactory *factory,
GtkListItem *list_item,
gpointer data)
{
GtkDropDown *dropdown = data;
g_signal_handlers_disconnect_by_func (dropdown, selected_item_changed, list_item);
}
static GtkListItemFactory *
strings_factory_new (gboolean full)
strings_factory_new (gpointer data, gboolean full)
{
GtkListItemFactory *factory;
factory = gtk_signal_list_item_factory_new ();
if (full)
g_signal_connect (factory, "setup", G_CALLBACK (strings_setup_item_full), NULL);
g_signal_connect (factory, "setup", G_CALLBACK (strings_setup_item_full), data);
else
g_signal_connect (factory, "setup", G_CALLBACK (strings_setup_item_single_line), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (strings_bind_item), NULL);
g_signal_connect (factory, "setup", G_CALLBACK (strings_setup_item_single_line), data);
g_signal_connect (factory, "bind", G_CALLBACK (strings_bind_item), data);
g_signal_connect (factory, "unbind", G_CALLBACK (strings_unbind_item), data);
return factory;
}
@@ -186,19 +238,22 @@ drop_down_new_from_strings (const char *const *titles,
g_return_val_if_fail (descriptions == NULL || g_strv_length ((char **)icons) == g_strv_length ((char **)descriptions), NULL);
model = strings_model_new (titles, icons, descriptions);
factory = strings_factory_new (FALSE);
widget = g_object_new (GTK_TYPE_DROP_DOWN,
"model", model,
NULL);
g_object_unref (model);
factory = strings_factory_new (widget, FALSE);
if (icons != NULL || descriptions != NULL)
list_factory = strings_factory_new (TRUE);
list_factory = strings_factory_new (widget, TRUE);
else
list_factory = NULL;
widget = g_object_new (GTK_TYPE_DROP_DOWN,
"model", model,
"factory", factory,
"list-factory", list_factory,
NULL);
g_object_set (widget,
"factory", factory,
"list-factory", list_factory,
NULL);
g_object_unref (model);
g_object_unref (factory);
if (list_factory)
g_object_unref (list_factory);

View File

@@ -78,11 +78,11 @@ do_entry_completion (GtkWidget *do_widget)
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
gtk_widget_set_margin_start (vbox, 5);
gtk_widget_set_margin_end (vbox, 5);
gtk_widget_set_margin_top (vbox, 5);
gtk_widget_set_margin_bottom (vbox, 5);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_widget_set_margin_start (vbox, 18);
gtk_widget_set_margin_end (vbox, 18);
gtk_widget_set_margin_top (vbox, 18);
gtk_widget_set_margin_bottom (vbox, 18);
gtk_window_set_child (GTK_WINDOW (window), vbox);
label = gtk_label_new (NULL);

View File

@@ -27,16 +27,16 @@ do_entry_undo (GtkWidget *do_widget)
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
gtk_widget_set_margin_start (vbox, 5);
gtk_widget_set_margin_end (vbox, 5);
gtk_widget_set_margin_top (vbox, 5);
gtk_widget_set_margin_bottom (vbox, 5);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_widget_set_margin_start (vbox, 18);
gtk_widget_set_margin_end (vbox, 18);
gtk_widget_set_margin_top (vbox, 18);
gtk_widget_set_margin_bottom (vbox, 18);
gtk_window_set_child (GTK_WINDOW (window), vbox);
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label),
"Use Primary+z or Primary+Shift+z to undo or redo changes");
"Use Control+z or Control+Shift+z to undo or redo changes");
gtk_box_append (GTK_BOX (vbox), label);
/* Create our entry */

View File

@@ -1,4 +1,4 @@
/* Error states
/* Error States
*
* GtkLabel and GtkEntry can indicate errors if you set the .error
* style class on them.

View File

@@ -5,7 +5,7 @@
<property name="modal">1</property>
<property name="resizable">0</property>
<property name="use-header-bar">1</property>
<property name="title" translatable="yes">Settings</property>
<property name="title" translatable="yes">Error States</property>
<property name="hide-on-close">1</property>
<child internal-child="content_area">
<object class="GtkBox">

View File

@@ -1068,7 +1068,6 @@ update_font_variations (void)
unsigned int length;
int i;
child = gtk_widget_get_first_child (variations_grid);
while ((child = gtk_widget_get_first_child (variations_grid)))
gtk_grid_remove (GTK_GRID (variations_grid), child);

View File

@@ -1,4 +1,4 @@
/* Pango/Font rendering
/* Pango/Font Rendering
*
* Demonstrates various aspects of font rendering.
*/

View File

@@ -1,4 +1,4 @@
/* OpenGL/Transitions
/* OpenGL/Transitions and Effects
* #Keywords: OpenGL, shader, effect
*
* Create transitions between pages using a custom fragment shader.
@@ -282,11 +282,12 @@ create_gltransition_window (GtkWidget *do_widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Transitions");
gtk_window_set_title (GTK_WINDOW (window), "Transitions and Effects");
headerbar = gtk_header_bar_new ();
scale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, NULL);
gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
gtk_widget_set_size_request (scale, 100, -1);
gtk_widget_set_tooltip_text (scale, "Transition duration");
gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), scale);
gtk_window_set_titlebar (GTK_WINDOW (window), headerbar);
gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);

View File

@@ -17,6 +17,7 @@
#include <glib/gstdio.h>
#include <stdio.h>
#include <errno.h>
#include "pixbufpaintable.h"
static GtkWidget *window = NULL;
static GdkPixbufLoader *pixbuf_loader = NULL;
@@ -56,6 +57,7 @@ progressive_updated_callback (GdkPixbufLoader *loader,
picture = GTK_WIDGET (data);
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
gtk_picture_set_pixbuf (GTK_PICTURE (picture), NULL);
gtk_picture_set_pixbuf (GTK_PICTURE (picture), pixbuf);
}
@@ -262,7 +264,7 @@ start_progressive_loading (GtkWidget *picture)
* The timeout simply simulates a slow data source by inserting
* pauses in the reading process.
*/
load_timeout = g_timeout_add (1500, progressive_timeout, picture);
load_timeout = g_timeout_add (300, progressive_timeout, picture);
g_source_set_name_by_id (load_timeout, "[gtk] progressive_timeout");
}
@@ -345,9 +347,8 @@ do_images (GtkWidget *do_widget)
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_box_append (GTK_BOX (hbox), vbox);
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label),
"<u>Image loaded from a file</u>");
label = gtk_label_new ("Image from a resource");
gtk_widget_add_css_class (label, "heading");
gtk_box_append (GTK_BOX (vbox), label);
frame = gtk_frame_new (NULL);
@@ -355,7 +356,7 @@ do_images (GtkWidget *do_widget)
gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
gtk_box_append (GTK_BOX (vbox), frame);
image = gtk_image_new_from_icon_name ("gtk3-demo");
image = gtk_image_new_from_resource ("/images/org.gtk.Demo4.svg");
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
gtk_frame_set_child (GTK_FRAME (frame), image);
@@ -363,9 +364,8 @@ do_images (GtkWidget *do_widget)
/* Animation */
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label),
"<u>Animation loaded from a file</u>");
label = gtk_label_new ("Animation from a resource");
gtk_widget_add_css_class (label, "heading");
gtk_box_append (GTK_BOX (vbox), label);
frame = gtk_frame_new (NULL);
@@ -373,15 +373,16 @@ do_images (GtkWidget *do_widget)
gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
gtk_box_append (GTK_BOX (vbox), frame);
picture = gtk_picture_new_for_resource ("/images/floppybuddy.gif");
paintable = pixbuf_paintable_new_from_resource ("/images/floppybuddy.gif");
picture = gtk_picture_new_for_paintable (paintable);
g_object_unref (paintable);
gtk_frame_set_child (GTK_FRAME (frame), picture);
/* Symbolic icon */
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label),
"<u>Symbolic themed icon</u>");
label = gtk_label_new ("Symbolic themed icon");
gtk_widget_add_css_class (label, "heading");
gtk_box_append (GTK_BOX (vbox), label);
frame = gtk_frame_new (NULL);
@@ -400,9 +401,8 @@ do_images (GtkWidget *do_widget)
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_box_append (GTK_BOX (hbox), vbox);
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label),
"<u>Progressive image loading</u>");
label = gtk_label_new ("Progressive image loading");
gtk_widget_add_css_class (label, "heading");
gtk_box_append (GTK_BOX (vbox), label);
frame = gtk_frame_new (NULL);
@@ -414,6 +414,7 @@ do_images (GtkWidget *do_widget)
* will create the pixbuf and fill it in.
*/
picture = gtk_picture_new ();
gtk_picture_set_alternative_text (GTK_PICTURE (picture), "A slowly loading image");
gtk_frame_set_child (GTK_FRAME (frame), picture);
start_progressive_loading (picture);
@@ -422,9 +423,8 @@ do_images (GtkWidget *do_widget)
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_box_append (GTK_BOX (hbox), vbox);
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label),
"<u>Displaying video</u>");
label = gtk_label_new ("Displaying video");
gtk_widget_add_css_class (label, "heading");
gtk_box_append (GTK_BOX (vbox), label);
frame = gtk_frame_new (NULL);
@@ -440,9 +440,8 @@ do_images (GtkWidget *do_widget)
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_box_append (GTK_BOX (hbox), vbox);
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label),
"<u>GtkWidgetPaintable</u>");
label = gtk_label_new ("GtkWidgetPaintable");
gtk_widget_add_css_class (label, "heading");
gtk_box_append (GTK_BOX (vbox), label);
paintable = gtk_widget_paintable_new (do_widget);

View File

@@ -34,7 +34,7 @@ do_layoutmanager (GtkWidget *parent)
int i;
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Layout ManagerTransition");
gtk_window_set_title (GTK_WINDOW (window), "Layout Manager — Transition");
gtk_window_set_default_size (GTK_WINDOW (window), 600, 600);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);

View File

@@ -170,7 +170,7 @@ do_layoutmanager2 (GtkWidget *parent)
int i;
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Layout ManagerTransformation");
gtk_window_set_title (GTK_WINDOW (window), "Layout Manager — Transformation");
gtk_window_set_default_size (GTK_WINDOW (window), 600, 620);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);

View File

@@ -1,4 +1,4 @@
/* List Box/Complex list
/* List Box/Complex
*
* GtkListBox allows lists with complicated layouts, using
* regular widgets supporting sorting and filtering.
@@ -197,7 +197,7 @@ gtk_message_row_update (GtkMessageRow *row)
if (strcmp (priv->message->sender_nick, "@GTKtoolkit") == 0)
{
gtk_image_set_from_icon_name (priv->avatar_image, "gtk3-demo");
gtk_image_set_from_icon_name (priv->avatar_image, "org.gtk.Demo4");
gtk_image_set_icon_size (priv->avatar_image, GTK_ICON_SIZE_LARGE);
}
else
@@ -349,7 +349,7 @@ do_listbox (GtkWidget *do_widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "List Box");
gtk_window_set_title (GTK_WINDOW (window), "List BoxComplex");
gtk_window_set_default_size (GTK_WINDOW (window), 400, 600);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);

View File

@@ -9,6 +9,7 @@ demos = files([
'constraints.c',
'constraints2.c',
'constraints3.c',
'constraints4.c',
'css_accordion.c',
'css_basics.c',
'css_blendmodes.c',
@@ -118,7 +119,8 @@ extra_demo_sources = files(['main.c',
'singular_value_decomposition.c',
'four_point_transform.c',
'demo2widget.c',
'demo3widget.c'])
'demo3widget.c',
'pixbufpaintable.c'])
if harfbuzz_dep.found() and pangoft_dep.found()
demos += files(['font_features.c', 'listview_ucd.c'])
@@ -160,7 +162,7 @@ executable('gtk4-demo',
c_args: gtkdemo_args + demo_cflags,
dependencies: gtkdemo_deps,
include_directories: confinc,
gui_app: true,
# gui_app: true,
link_args: extra_demo_ldflags,
install: true)
@@ -169,7 +171,7 @@ executable('gtk4-demo-application',
c_args: gtkdemo_args + common_cflags,
dependencies: gtkdemo_deps,
include_directories: confinc,
gui_app: true,
# gui_app: true,
link_args: extra_demo_ldflags,
install: true)

View File

@@ -1,4 +1,4 @@
/* Paintable/A simple paintable
/* Paintable/Simple Paintable
*
* GdkPaintable is an interface used by GTK for drawings of any sort
* that do not require layouting or positioning.

View File

@@ -1,4 +1,4 @@
/* Paintable/An animated paintable
/* Paintable/Animated Paintable
*
* GdkPaintable also allows paintables to change.
*

View File

@@ -1,4 +1,4 @@
/* Paintable/A media stream
/* Paintable/Media Stream
*
* GdkPaintable is also used by the GtkMediaStream class.
*

View File

@@ -3,100 +3,16 @@
* The GtkPaned Widget divides its content area into two panes
* with a divider in between that the user can adjust. A separate
* child is placed into each pane. GtkPaned widgets can be split
* horizontally or vertially.
* horizontally or vertically. This test contains both a horizontal
* and a vertical GtkPaned widget.
*
* There are a number of options that can be set for each pane.
* This test contains both a horizontal and a vertical GtkPaned
* widget, and allows you to adjust the options for each side of
* each widget.
* You can use the Inspector to adjust the options for each side
* of each widget.
*/
#include <gtk/gtk.h>
static void
toggle_resize (GtkWidget *widget,
GtkWidget *child)
{
GtkWidget *parent;
GtkPaned *paned;
parent = gtk_widget_get_parent (child);
paned = GTK_PANED (parent);
if (child == gtk_paned_get_start_child (paned))
gtk_paned_set_resize_start_child (paned, !gtk_paned_get_resize_start_child (paned));
else
gtk_paned_set_resize_end_child (paned, !gtk_paned_get_resize_end_child (paned));
}
static void
toggle_shrink (GtkWidget *widget,
GtkWidget *child)
{
GtkWidget *parent;
GtkPaned *paned;
parent = gtk_widget_get_parent (child);
paned = GTK_PANED (parent);
if (child == gtk_paned_get_start_child (paned))
gtk_paned_set_shrink_start_child (paned, !gtk_paned_get_shrink_start_child (paned));
else
gtk_paned_set_shrink_end_child (paned, !gtk_paned_get_shrink_end_child (paned));
}
static GtkWidget *
create_pane_options (GtkPaned *paned,
const char *frame_label,
const char *label1,
const char *label2)
{
GtkWidget *child1, *child2;
GtkWidget *frame;
GtkWidget *table;
GtkWidget *label;
GtkWidget *check_button;
child1 = gtk_paned_get_start_child (paned);
child2 = gtk_paned_get_end_child (paned);
frame = gtk_frame_new (frame_label);
table = gtk_grid_new ();
gtk_frame_set_child (GTK_FRAME (frame), table);
label = gtk_label_new (label1);
gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1);
check_button = gtk_check_button_new_with_mnemonic ("_Resize");
gtk_grid_attach (GTK_GRID (table), check_button, 0, 1, 1, 1);
g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_resize), child1);
check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
gtk_grid_attach (GTK_GRID (table), check_button, 0, 2, 1, 1);
gtk_check_button_set_active (GTK_CHECK_BUTTON (check_button), TRUE);
g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_shrink), child1);
label = gtk_label_new (label2);
gtk_grid_attach (GTK_GRID (table), label, 1, 0, 1, 1);
check_button = gtk_check_button_new_with_mnemonic ("_Resize");
gtk_grid_attach (GTK_GRID (table), check_button, 1, 1, 1, 1);
gtk_check_button_set_active (GTK_CHECK_BUTTON (check_button), TRUE);
g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_resize), child2);
check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
gtk_grid_attach (GTK_GRID (table), check_button, 1, 2, 1, 1);
gtk_check_button_set_active (GTK_CHECK_BUTTON (check_button), TRUE);
g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_shrink), child2);
return frame;
}
GtkWidget *
do_panes (GtkWidget *do_widget)
{
@@ -104,19 +20,19 @@ do_panes (GtkWidget *do_widget)
GtkWidget *frame;
GtkWidget *hpaned;
GtkWidget *vpaned;
GtkWidget *button;
GtkWidget *label;
GtkWidget *vbox;
GtkWidget *box;
if (!window)
{
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Paned Widgets");
gtk_window_set_default_size (GTK_WINDOW (window), 330, 250);
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_title (GTK_WINDOW (window), "Paned Widgets");
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_widget_set_margin_start (vbox, 8);
gtk_widget_set_margin_end (vbox, 8);
@@ -132,41 +48,37 @@ do_panes (GtkWidget *do_widget)
hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
gtk_paned_set_start_child (GTK_PANED (vpaned), hpaned);
gtk_paned_set_shrink_start_child (GTK_PANED (vpaned), FALSE);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_set_size_request (box, 60, 60);
gtk_paned_set_start_child (GTK_PANED (hpaned), box);
label = gtk_label_new ("Hi there");
gtk_widget_set_margin_start (label, 4);
gtk_widget_set_margin_end (label, 4);
gtk_widget_set_margin_top (label, 4);
gtk_widget_set_margin_bottom (label, 4);
gtk_widget_set_hexpand (label, TRUE);
gtk_widget_set_vexpand (label, TRUE);
gtk_paned_set_start_child (GTK_PANED (hpaned), label);
gtk_paned_set_shrink_start_child (GTK_PANED (hpaned), FALSE);
button = gtk_button_new_with_mnemonic ("_Hi there");
gtk_widget_set_margin_start (button, 4);
gtk_widget_set_margin_end (button, 4);
gtk_widget_set_margin_top (button, 4);
gtk_widget_set_margin_bottom (button, 4);
gtk_widget_set_hexpand (button, TRUE);
gtk_widget_set_vexpand (button, TRUE);
gtk_box_append (GTK_BOX (box), button);
label = gtk_label_new ("Hello");
gtk_widget_set_margin_start (label, 4);
gtk_widget_set_margin_end (label, 4);
gtk_widget_set_margin_top (label, 4);
gtk_widget_set_margin_bottom (label, 4);
gtk_widget_set_hexpand (label, TRUE);
gtk_widget_set_vexpand (label, TRUE);
gtk_paned_set_end_child (GTK_PANED (hpaned), label);
gtk_paned_set_shrink_end_child (GTK_PANED (hpaned), FALSE);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_set_size_request (box, 80, 60);
gtk_paned_set_end_child (GTK_PANED (hpaned), box);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_set_size_request (box, 60, 80);
gtk_paned_set_end_child (GTK_PANED (vpaned), box);
/* Now create toggle buttons to control sizing */
gtk_box_append (GTK_BOX (vbox),
create_pane_options (GTK_PANED (hpaned),
"Horizontal",
"Left",
"Right"));
gtk_box_append (GTK_BOX (vbox),
create_pane_options (GTK_PANED (vpaned),
"Vertical",
"Top",
"Bottom"));
label = gtk_label_new ("Goodbye");
gtk_widget_set_margin_start (label, 4);
gtk_widget_set_margin_end (label, 4);
gtk_widget_set_margin_top (label, 4);
gtk_widget_set_margin_bottom (label, 4);
gtk_widget_set_hexpand (label, TRUE);
gtk_widget_set_vexpand (label, TRUE);
gtk_paned_set_end_child (GTK_PANED (vpaned), label);
gtk_paned_set_shrink_end_child (GTK_PANED (vpaned), FALSE);
}
if (!gtk_widget_get_visible (window))

View File

@@ -0,0 +1,187 @@
#include <gtk/gtk.h>
#include "pixbufpaintable.h"
struct _PixbufPaintable {
GObject parent_instance;
char *resource_path;
GdkPixbufAnimation *anim;
GdkPixbufAnimationIter *iter;
guint timeout;
};
enum {
PROP_RESOURCE_PATH = 1,
NUM_PROPERTIES
};
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
static void
pixbuf_paintable_snapshot (GdkPaintable *paintable,
GdkSnapshot *snapshot,
double width,
double height)
{
PixbufPaintable *self = PIXBUF_PAINTABLE (paintable);
GTimeVal val;
GdkPixbuf *pixbuf;
GdkTexture *texture;
g_get_current_time (&val);
gdk_pixbuf_animation_iter_advance (self->iter, &val);
pixbuf = gdk_pixbuf_animation_iter_get_pixbuf (self->iter);
texture = gdk_texture_new_for_pixbuf (pixbuf);
gdk_paintable_snapshot (GDK_PAINTABLE (texture), snapshot, width, height);
g_object_unref (texture);
}
G_GNUC_END_IGNORE_DEPRECATIONS;
static int
pixbuf_paintable_get_intrinsic_width (GdkPaintable *paintable)
{
PixbufPaintable *self = PIXBUF_PAINTABLE (paintable);
return gdk_pixbuf_animation_get_width (self->anim);
}
static int
pixbuf_paintable_get_intrinsic_height (GdkPaintable *paintable)
{
PixbufPaintable *self = PIXBUF_PAINTABLE (paintable);
return gdk_pixbuf_animation_get_height (self->anim);
}
static void
pixbuf_paintable_init_interface (GdkPaintableInterface *iface)
{
iface->snapshot = pixbuf_paintable_snapshot;
iface->get_intrinsic_width = pixbuf_paintable_get_intrinsic_width;
iface->get_intrinsic_height = pixbuf_paintable_get_intrinsic_height;
}
G_DEFINE_TYPE_WITH_CODE(PixbufPaintable, pixbuf_paintable, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
pixbuf_paintable_init_interface))
static void
pixbuf_paintable_init (PixbufPaintable *paintable)
{
}
static gboolean
delay_cb (gpointer data)
{
PixbufPaintable *self = data;
int delay;
delay = gdk_pixbuf_animation_iter_get_delay_time (self->iter);
self->timeout = g_timeout_add (delay, delay_cb, self);
gdk_paintable_invalidate_contents (GDK_PAINTABLE (self));
return G_SOURCE_REMOVE;
}
static void
pixbuf_paintable_set_resource_path (PixbufPaintable *self,
const char *resource_path)
{
int delay;
g_free (self->resource_path);
self->resource_path = g_strdup (resource_path);
g_clear_object (&self->anim);
self->anim = gdk_pixbuf_animation_new_from_resource (resource_path, NULL);
g_clear_object (&self->iter);
self->iter = gdk_pixbuf_animation_get_iter (self->anim, NULL);
delay = gdk_pixbuf_animation_iter_get_delay_time (self->iter);
self->timeout = g_timeout_add (delay, delay_cb, self);
gdk_paintable_invalidate_contents (GDK_PAINTABLE (self));
g_object_notify (G_OBJECT (self), "resource-path");
}
static void
pixbuf_paintable_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
PixbufPaintable *self = PIXBUF_PAINTABLE (object);
switch (prop_id)
{
case PROP_RESOURCE_PATH:
pixbuf_paintable_set_resource_path (self, g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
pixbuf_paintable_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
PixbufPaintable *self = PIXBUF_PAINTABLE (object);
switch (prop_id)
{
case PROP_RESOURCE_PATH:
g_value_set_string (value, self->resource_path);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
pixbuf_paintable_dispose (GObject *object)
{
PixbufPaintable *self = PIXBUF_PAINTABLE (object);
g_clear_pointer (&self->resource_path, g_free);
g_clear_object (&self->anim);
g_clear_object (&self->iter);
if (self->timeout)
{
g_source_remove (self->timeout);
self->timeout = 0;
}
G_OBJECT_CLASS (pixbuf_paintable_parent_class)->dispose (object);
}
static void
pixbuf_paintable_class_init (PixbufPaintableClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->dispose = pixbuf_paintable_dispose;
object_class->get_property = pixbuf_paintable_get_property;
object_class->set_property = pixbuf_paintable_set_property;
g_object_class_install_property (object_class, PROP_RESOURCE_PATH,
g_param_spec_string ("resource-path", "Resource path", "Resource path",
NULL, G_PARAM_READWRITE));
}
GdkPaintable *
pixbuf_paintable_new_from_resource (const char *path)
{
return g_object_new (PIXBUF_TYPE_PAINTABLE,
"resource-path", path,
NULL);
}

View File

@@ -0,0 +1,13 @@
#pragma once
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define PIXBUF_TYPE_PAINTABLE (pixbuf_paintable_get_type ())
G_DECLARE_FINAL_TYPE(PixbufPaintable, pixbuf_paintable, PIXBUF, PAINTABLE, GObject)
GdkPaintable * pixbuf_paintable_new_from_resource (const char *path);
G_END_DECLS

View File

@@ -110,17 +110,17 @@ set_search_by (GSimpleAction *action,
if (g_str_equal (term, "name"))
{
gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, "Search by name");
gtk_entry_set_placeholder_text (entry, "name");
gtk_entry_set_placeholder_text (entry, "Name");
}
else if (g_str_equal (term, "description"))
{
gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, "Search by description");
gtk_entry_set_placeholder_text (entry, "description");
gtk_entry_set_placeholder_text (entry, "Description");
}
else if (g_str_equal (term, "filename"))
{
gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, "Search by file name");
gtk_entry_set_placeholder_text (entry, "file name");
gtk_entry_set_placeholder_text (entry, "File name");
}
}
@@ -254,7 +254,6 @@ do_search_entry (GtkWidget *do_widget)
{
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *label;
GtkWidget *entry;
GtkWidget *find_button;
GtkWidget *cancel_button;
@@ -268,18 +267,14 @@ do_search_entry (GtkWidget *do_widget)
g_object_weak_ref (G_OBJECT (window), search_entry_destroyed, &window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
gtk_widget_set_margin_start (vbox, 5);
gtk_widget_set_margin_end (vbox, 5);
gtk_widget_set_margin_top (vbox, 5);
gtk_widget_set_margin_bottom (vbox, 5);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_widget_set_margin_start (vbox, 18);
gtk_widget_set_margin_end (vbox, 18);
gtk_widget_set_margin_top (vbox, 18);
gtk_widget_set_margin_bottom (vbox, 18);
gtk_window_set_child (GTK_WINDOW (window), vbox);
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label), "Search entry demo");
gtk_box_append (GTK_BOX (vbox), label);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
gtk_box_append (GTK_BOX (vbox), hbox);
/* Create our entry */

View File

@@ -1,10 +1,10 @@
/* Entry/Delayed Search Entry
/* Entry/Type to Search
*
* GtkSearchEntry provides an entry that is ready for search.
*
* Search entries have their "changed" signal delayed and should
* be used when the searched operation is slow such as loads of
* entries to search, or online searches.
* Search entries have their "search-changed" signal delayed and
* should be used when the search operation is slow, such as big
* datasets to search, or online searches.
*
* GtkSearchBar allows have a hidden search entry that 'springs
* into action' upon keyboard input.
@@ -18,101 +18,69 @@ search_changed_cb (GtkSearchEntry *entry,
{
const char *text;
text = gtk_editable_get_text (GTK_EDITABLE (entry));
g_message ("search changed: %s", text);
gtk_label_set_text (result_label, text ? text : "");
}
static void
changed_cb (GtkEditable *editable)
{
const char *text;
text = gtk_editable_get_text (GTK_EDITABLE (editable));
g_message ("changed: %s", text);
}
static void
search_changed (GtkSearchEntry *entry,
GtkLabel *label)
{
gtk_label_set_text (label, "search-changed");
}
static void
next_match (GtkSearchEntry *entry,
GtkLabel *label)
{
gtk_label_set_text (label, "next-match");
}
static void
previous_match (GtkSearchEntry *entry,
GtkLabel *label)
{
gtk_label_set_text (label, "previous-match");
}
static void
stop_search (GtkSearchEntry *entry,
GtkLabel *label)
{
gtk_label_set_text (label, "stop-search");
}
GtkWidget *
do_search_entry2 (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *box;
GtkWidget *label;
GtkWidget *entry;
GtkWidget *container;
GtkWidget *searchbar;
GtkWidget *button;
GtkWidget *header;
if (!window)
{
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Delayed Search Entry");
gtk_window_set_title (GTK_WINDOW (window), "Type to Search");
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
gtk_widget_set_size_request (window, 200, -1);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
header = gtk_header_bar_new ();
gtk_window_set_titlebar (GTK_WINDOW (window), header);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_window_set_child (GTK_WINDOW (window), vbox);
entry = gtk_search_entry_new ();
container = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
gtk_widget_set_halign (container, GTK_ALIGN_CENTER);
gtk_box_append (GTK_BOX (container), entry);
gtk_widget_set_halign (entry, GTK_ALIGN_CENTER);
searchbar = gtk_search_bar_new ();
gtk_search_bar_connect_entry (GTK_SEARCH_BAR (searchbar), GTK_EDITABLE (entry));
gtk_search_bar_set_show_close_button (GTK_SEARCH_BAR (searchbar), FALSE);
gtk_search_bar_set_child (GTK_SEARCH_BAR (searchbar), container);
gtk_search_bar_set_child (GTK_SEARCH_BAR (searchbar), entry);
gtk_box_append (GTK_BOX (vbox), searchbar);
/* Hook the search bar to key presses */
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (searchbar), window);
/* Help */
label = gtk_label_new ("Start Typing to search");
gtk_box_append (GTK_BOX (vbox), label);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
gtk_widget_set_margin_start (box, 18);
gtk_widget_set_margin_end (box, 18);
gtk_widget_set_margin_top (box, 18);
gtk_widget_set_margin_bottom (box, 18);
gtk_box_append (GTK_BOX (vbox), box);
/* Toggle button */
button = gtk_toggle_button_new_with_label ("Search");
button = gtk_toggle_button_new ();
gtk_button_set_icon_name (GTK_BUTTON (button), "system-search-symbolic");
g_object_bind_property (button, "active",
searchbar, "search-mode-enabled",
G_BINDING_BIDIRECTIONAL);
gtk_box_append (GTK_BOX (vbox), button);
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
/* Result */
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
gtk_box_append (GTK_BOX (vbox), hbox);
gtk_box_append (GTK_BOX (box), hbox);
label = gtk_label_new ("Result:");
label = gtk_label_new ("Searching for:");
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_widget_set_margin_start (label, 6);
gtk_box_append (GTK_BOX (hbox), label);
label = gtk_label_new ("");
@@ -120,28 +88,6 @@ do_search_entry2 (GtkWidget *do_widget)
g_signal_connect (entry, "search-changed",
G_CALLBACK (search_changed_cb), label);
g_signal_connect (entry, "changed",
G_CALLBACK (changed_cb), label);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
gtk_box_append (GTK_BOX (vbox), hbox);
label = gtk_label_new ("Signal:");
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_widget_set_margin_start (label, 6);
gtk_box_append (GTK_BOX (hbox), label);
label = gtk_label_new ("");
gtk_box_append (GTK_BOX (hbox), label);
g_signal_connect (entry, "search-changed",
G_CALLBACK (search_changed), label);
g_signal_connect (entry, "next-match",
G_CALLBACK (next_match), label);
g_signal_connect (entry, "previous-match",
G_CALLBACK (previous_match), label);
g_signal_connect (entry, "stop-search",
G_CALLBACK (stop_search), label);
}
if (!gtk_widget_get_visible (window))

View File

@@ -66,6 +66,7 @@ do_tagged_entry (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Tagged Entry");
gtk_window_set_default_size (GTK_WINDOW (window), 260, -1);
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);

View File

@@ -1,5 +1,5 @@
tag {
margin: 4px;
margin: 4px 0px;
padding: 4px;
border-radius: 4px;
background: lightskyblue;
@@ -17,3 +17,7 @@ tag button {
padding: 0;
border: 1px solid white;
}
entry.tagged {
border-spacing: 4px;
}

View File

@@ -11,6 +11,7 @@
</object>
<object class="GtkWindow" id="window">
<property name="resizable">0</property>
<property name="title">Themes</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="header">
<child type="start">

View File

@@ -164,7 +164,7 @@ save_file (GFile *save_filename)
NULL,
&error);
if (error != NULL)
if (error == NULL)
{
if (save_filename != filename)
{

View File

@@ -91,6 +91,16 @@ change_theme_state (GSimpleAction *action,
static GtkWidget *page_stack;
static void
transition_speed_changed (GtkRange *range,
gpointer data)
{
double value;
value = gtk_range_get_value (range);
gtk_stack_set_transition_duration (GTK_STACK (page_stack), (int)value);
}
static void
change_transition_state (GSimpleAction *action,
GVariant *state,
@@ -250,6 +260,8 @@ activate_about (GSimpleAction *action,
gpointer user_data)
{
GtkApplication *app = user_data;
GtkWindow *window;
GtkWidget *button;
const char *authors[] = {
"Andrea Cimitan",
"Cosimo Cecchi",
@@ -267,6 +279,10 @@ activate_about (GSimpleAction *action,
s = g_string_new ("");
window = gtk_application_get_active_window (app);
button = GTK_WIDGET (g_object_get_data (G_OBJECT (window), "open_menubutton"));
gtk_menu_button_popdown (GTK_MENU_BUTTON (button));
os_name = g_get_os_info (G_OS_INFO_KEY_NAME);
os_version = g_get_os_info (G_OS_INFO_KEY_VERSION_ID);
if (os_name && os_version)
@@ -292,6 +308,7 @@ activate_about (GSimpleAction *action,
dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG,
"transient-for", gtk_application_get_active_window (app),
"modal", TRUE,
"program-name", "GTK Widget Factory",
"version", version,
"copyright", "©1997—2020 The GTK Team",
@@ -315,6 +332,21 @@ activate_about (GSimpleAction *action,
g_free (os_version);
}
static void
activate_shortcuts_window (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
GtkApplication *app = user_data;
GtkWindow *window;
GtkWidget *button;
window = gtk_application_get_active_window (app);
button = GTK_WIDGET (g_object_get_data (G_OBJECT (window), "open_menubutton"));
gtk_menu_button_popdown (GTK_MENU_BUTTON (button));
gtk_widget_activate_action (GTK_WIDGET (window), "win.show-help-overlay", NULL);
}
static void
activate_quit (GSimpleAction *action,
GVariant *parameter,
@@ -2022,6 +2054,7 @@ activate (GApplication *app)
"validate_more_details", (GCallback)validate_more_details,
"mode_switch_state_set", (GCallback)mode_switch_state_set,
"level_scale_value_changed", (GCallback)level_scale_value_changed,
"transition_speed_changed", (GCallback)transition_speed_changed,
NULL);
gtk_builder_set_scope (builder, scope);
g_object_unref (scope);
@@ -2359,6 +2392,7 @@ main (int argc, char *argv[])
GAction *action;
static GActionEntry app_entries[] = {
{ "about", activate_about, NULL, NULL, NULL },
{ "shortcuts", activate_shortcuts_window, NULL, NULL, NULL },
{ "quit", activate_quit, NULL, NULL, NULL },
{ "inspector", activate_inspector, NULL, NULL, NULL },
{ "main", NULL, "s", "'steak'", NULL },

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<menu id="gear_menu">
<menu id="gear_menu_model">
<section>
<item>
<attribute name="label" translatable="yes">Get Busy</attribute>
@@ -40,6 +40,9 @@
<attribute name="label" translatable="yes">Transition Pages</attribute>
<attribute name="action">win.transition</attribute>
</item>
<item>
<attribute name="custom">transition-speed</attribute>
</item>
</section>
<section>
<item>
@@ -48,7 +51,7 @@
</item>
<item>
<attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
<attribute name="action">win.show-help-overlay</attribute>
<attribute name="action">app.shortcuts</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_About Widget Factory</attribute>
@@ -444,7 +447,26 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<child type="end">
<object class="GtkMenuButton" id="gear_menu_button">
<property name="valign">center</property>
<property name="menu-model">gear_menu</property>
<property name="popover">
<object class="GtkPopoverMenu" id="gear_menu">
<property name="menu-model">gear_menu_model</property>
<child type="transition-speed">
<object class="GtkScale">
<property name="adjustment">
<object class="GtkAdjustment">
<property name="lower">0</property>
<property name="upper">1000</property>
<property name="value">250</property>
<property name="step-increment">50</property>
<property name="page-increment">50</property>
<property name="page-size">0</property>
</object>
</property>
<signal name="value-changed" handler="transition_speed_changed"/>
</object>
</child>
</object>
</property>
<property name="icon-name">open-menu-symbolic</property>
</object>
</child>
@@ -3198,7 +3220,7 @@ bad things might happen.</property>
<object class="GtkMenuButton">
<property name="halign">end</property>
<property name="icon-name">emblem-system-symbolic</property>
<property name="menu-model">gear_menu</property>
<property name="menu-model">gear_menu_model</property>
<property name="tooltip-text">This is a menu button</property>
<layout>
<property name="column">1</property>

View File

@@ -16,14 +16,16 @@
</releaseinfo>
</bookinfo>
<reference id="reference">
<chapter>
<title>API Reference</title>
<xi:include href="xml/general.xml" />
<xi:include href="xml/gdkdisplaymanager.xml" />
<xi:include href="xml/gdkdisplay.xml" />
<xi:include href="xml/gdkseat.xml" />
<xi:include href="xml/gdkdevice.xml" />
<xi:include href="xml/gdkdevicepad.xml" />
<section>
<xi:include href="xml/gdkdevicepad.xml" />
</section>
<xi:include href="xml/gdkmonitor.xml" />
<xi:include href="xml/regions.xml" />
<xi:include href="xml/textures.xml" />
@@ -32,16 +34,24 @@
<xi:include href="xml/cursors.xml" />
<xi:include href="xml/gdksurface.xml" />
<xi:include href="xml/gdktoplevel.xml" />
<xi:include href="xml/gdktoplevellayout.xml" />
<xi:include href="xml/gdktoplevelsize.xml" />
<section>
<xi:include href="xml/gdktoplevellayout.xml" />
<xi:include href="xml/gdktoplevelsize.xml" />
</section>
<xi:include href="xml/gdkpopup.xml" />
<xi:include href="xml/gdkpopuplayout.xml" />
<section>
<xi:include href="xml/gdkpopuplayout.xml" />
</section>
<xi:include href="xml/gdkframeclock.xml" />
<xi:include href="xml/gdkframetimings.xml" />
<section>
<xi:include href="xml/gdkframetimings.xml" />
</section>
<xi:include href="xml/gdkdrawcontext.xml" />
<xi:include href="xml/gdkglcontext.xml" />
<xi:include href="xml/gdkvulkancontext.xml" />
<xi:include href="xml/gdkcairocontext.xml" />
<section>
<xi:include href="xml/gdkglcontext.xml" />
<xi:include href="xml/gdkvulkancontext.xml" />
<xi:include href="xml/gdkcairocontext.xml" />
</section>
<xi:include href="xml/events.xml" />
<xi:include href="xml/keys.xml" />
<xi:include href="xml/gdkclipboard.xml" />
@@ -50,13 +60,16 @@
<xi:include href="xml/gdkcontentprovider.xml" />
<xi:include href="xml/gdkcontentserializer.xml" />
<xi:include href="xml/gdkcontentdeserializer.xml" />
<xi:include href="xml/gdkapplaunchcontext.xml" />
<xi:include href="xml/pixbufs.xml" />
<xi:include href="xml/pango_interaction.xml" />
<xi:include href="xml/cairo_interaction.xml" />
</chapter>
<chapter>
<title>GDK Platform Support</title>
<xi:include href="xml/gdkapplaunchcontext.xml" />
<xi:include href="xml/x_interaction.xml" />
<xi:include href="xml/wayland_interaction.xml" />
</reference>
</chapter>
<index id="api-index-full">
<title>Index of all symbols</title>

View File

@@ -10,8 +10,8 @@
</MACRO>
<MACRO>
<NAME>GDK_WINDOWING_QUARTZ</NAME>
#define GDK_WINDOWING_QUARTZ
<NAME>GDK_WINDOWING_MACOS</NAME>
#define GDK_WINDOWING_MACOS
</MACRO>
<MACRO>

View File

@@ -8,7 +8,7 @@
<SUBSECTION>
GDK_WINDOWING_X11
GDK_WINDOWING_WIN32
GDK_WINDOWING_QUARTZ
GDK_WINDOWING_MACOS
GDK_WINDOWING_WAYLAND
<SUBSECTION>
@@ -303,11 +303,8 @@ gdk_cairo_draw_from_gl
</SECTION>
<SECTION>
<TITLE>Points, Rectangles and Regions</TITLE>
<TITLE>Rectangles and Regions</TITLE>
<FILE>regions</FILE>
GdkPoint
<SUBSECTION>
GdkRectangle
gdk_rectangle_intersect
gdk_rectangle_union

View File

@@ -586,53 +586,53 @@ print_hello (GtkWidget *widget,
}
static void
quit_cb (GtkWidget *widget, gpointer data)
quit_cb (GtkWindow *window)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
gtk_window_close (window);
}
int
main (int argc,
char *argv[])
static void
activate (GtkApplication *app,
gpointer user_data)
{
GtkBuilder *builder;
GObject *window;
GObject *button;
gboolean done = FALSE;
#ifdef GTK_SRCDIR
g_chdir (GTK_SRCDIR);
#endif
gtk_init ();
/* Construct a GtkBuilder instance and load our UI description */
builder = gtk_builder_new ();
GtkBuilder *builder = gtk_builder_new ();
gtk_builder_add_from_file (builder, "builder.ui", NULL);
/* Connect signal handlers to the constructed widgets. */
window = gtk_builder_get_object (builder, "window");
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
GObject *window = gtk_builder_get_object (builder, "window");
gtk_window_set_application (GTK_WINDOW (window), app);
button = gtk_builder_get_object (builder, "button1");
GObject *button = gtk_builder_get_object (builder, "button1");
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
button = gtk_builder_get_object (builder, "button2");
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
button = gtk_builder_get_object (builder, "quit");
g_signal_connect (button, "clicked", G_CALLBACK (quit_cb), &done);
g_signal_connect_swapped (button, "clicked", G_CALLBACK (quit_cb), window);
gtk_widget_show (GTK_WIDGET (window));
while (!done)
g_main_context_iteration (NULL, TRUE);
/* We do not need the builder any more */
g_object_unref (builder);
}
return 0;
int
main (int argc,
char *argv[])
{
#ifdef GTK_SRCDIR
g_chdir (GTK_SRCDIR);
#endif
GtkApplication *app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
int status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
return status;
}
```

View File

@@ -971,6 +971,7 @@ gtk_editable_get_enable_undo
gtk_editable_set_enable_undo
<SUBSECTION>
gtk_editable_install_properties
gtk_editable_get_delegate
gtk_editable_init_delegate
gtk_editable_finish_delegate
gtk_editable_delegate_set_property
@@ -6176,6 +6177,8 @@ gtk_popover_menu_new_from_model
gtk_popover_menu_new_from_model_full
gtk_popover_menu_set_menu_model
gtk_popover_menu_get_menu_model
gtk_popover_menu_add_child
gtk_popover_menu_remove_child
<SUBSECTION Standard>
GTK_TYPE_POPOVER_MENU
@@ -6194,6 +6197,8 @@ GtkPopoverMenuBar
gtk_popover_menu_bar_new_from_model
gtk_popover_menu_bar_set_menu_model
gtk_popover_menu_bar_get_menu_model
gtk_popover_menu_bar_add_child
gtk_popover_menu_bar_remove_child
<SUBSECTION Standard>
GTK_TYPE_POPOVER_MENU_BAR

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@@ -240,11 +240,14 @@ images = [
'images/border1.png',
'images/border2.png',
'images/border3.png',
'images/box.png',
'images/box-expand.png',
'images/box-packing.png',
'images/builder-shortcuts.png',
'images/button.png',
'images/calendar.png',
'images/capture-bubble.png',
'images/centerbox.png',
'images/check-button.png',
'images/checks.png',
'images/clocks-shortcuts.png',
@@ -258,14 +261,17 @@ images = [
'images/down-start.png',
'images/drop-down.png',
'images/drawing.png',
'images/drawingarea.png',
'images/ease-in-out.png',
'images/ease-in.png',
'images/ease-out.png',
'images/ease.png',
'images/editable-label.png',
'images/emojichooser.png',
'images/entry.png',
'images/exampleapp.png',
'images/expanders.png',
'images/expander.png',
'images/extensions.png',
'images/figure-hierarchical-drawing.png',
'images/figure-windowed-label.png',
@@ -293,6 +299,7 @@ images = [
'images/gradient2.png',
'images/gradient3.png',
'images/gradient4.png',
'images/grid.png',
'images/grid-packing.png',
'images/handles.png',
'images/headerbar.png',
@@ -324,16 +331,19 @@ images = [
'images/lockbutton-sorry.png',
'images/lockbutton-unlocked.png',
'images/media-controls.png',
'images/menu.png',
'images/menubar.png',
'images/menu-button.png',
'images/messagedialog.png',
'images/multiline-text.png',
'images/notebook.png',
'images/options.png',
'images/overlay.png',
'images/pagesetupdialog.png',
'images/panes.png',
'images/password-entry.png',
'images/picture.png',
'images/popover.png',
'images/popup-anchors.png',
'images/popup-at.svg',
'images/popup-flip.png',
@@ -349,6 +359,7 @@ images = [
'images/search-bar.png',
'images/search-entry.png',
'images/separator.png',
'images/shortcuts-window.png',
'images/sidebar.png',
'images/slices.png',
'images/sliders.png',
@@ -367,6 +378,7 @@ images = [
'images/video.png',
'images/volumebutton.png',
'images/widget-hvalign.png',
'images/windowcontrols.png',
'images/window-default.png',
'images/window.png',
'images/rich-list.png',

View File

@@ -239,6 +239,39 @@ you get to the point that you actually build your application against
GTK 4. Making it possible to prepare for these in GTK 3 would
have been either impossible or impractical.
### Larger changes
Some of the larger themes of GTK 4 development are hard to cover in the form
of checklist items, so we mention them separately up-front.
#### Subclassing
Compared to previous versions, GTK 4 emphasizes composition and delegation
over subclassing. As a consequence, many widgets can no longer be subclassed.
In most cases, you should look deriving your widget directly from GtkWidget
and use complex widgets as child widgets instead of deriving from them.
#### Life-cycle handling
Widgets in GTK 4 are treated like any other objects - their parent widget
holds a reference on them, and GTK holds a reference on toplevel windows.
gtk_window_destroy() will drop the reference on the toplevel window, and
cause the whole widget hierarchy to be finalized unless there are other
references that keep widgets alive.
The #GtkWidget::destroy signal is emitted when a widget is disposed, and
therefore can no longer be used to break reference cycles. A typical sign
of a reference cycle involving a toplevel window is when closing the window
does not make the application quit.
A good rule to follow is: If you set a widget pointer with
gtk_widget_class_bind_template_child() in class_init(), you need to
unparent it in dispose(). The slight complication here is that you need
to respect the widget hierarchy while doing so. Ie if you set both `field1`
and `field2`, but `field1` is an ancestor of `field2`, then you only need
to unparent `field1` — doing so will remove the the entire subtree below
`field1`, including `field2`.
### Stop using GdkScreen
The GdkScreen object has been removed in GTK 4. Most of its APIs already
@@ -1047,12 +1080,12 @@ gtk_icon_paintable_get_icon_name() and set the icon name on a #GtkImage.
### Update to GtkFileChooser API changes
GtkFileChooser moved to a GFile-based API. If you need to convert a
path or a URI, use g_file_new_for_path(), g_file_new_for_commandline_arg(),
or g_file_new_for_uri(); similarly, if you need to get a path or a URI
from a GFile, use g_file_get_path(), or g_file_get_uri(). With the
removal or path and URI-based functions, the "local-only" property has
been removed; GFile can be used to access non-local as well as local
GtkFileChooser moved to a GFile-based API. If you need to convert a path
or a URI, use g_file_new_for_path(), g_file_new_for_commandline_arg(),
or g_file_new_for_uri(); similarly, if you need to get a path, name or URI
from a GFile, use g_file_get_path(), g_file_get_basename() or g_file_get_uri().
With the removal or path and URI-based functions, the "local-only" property
has been removed; GFile can be used to access non-local as well as local
resources.
The GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER action has been removed. Use

View File

@@ -71,12 +71,12 @@ the question you have, this list is a good place to start.
6. How do I use GTK with threads?
GTK requires that all GTK API calls are made from the same thread in which
gtk_init() was called (the _main thread_).
the #GtkApplication was created, or gtk_init() was called (the _main thread_).
If you want to take advantage of multi-threading in a GTK application,
it is usually best to send long-running tasks to worker threads, and feed
the results back to the main thread using g_idle_add() or GAsyncQueue. GIO
offers useful tools for such an approach such as GTask.
the results back to the main thread using g_idle_add() or #GAsyncQueue. GIO
offers useful tools for such an approach such as #GTask.
7. How do I internationalize a GTK program?

View File

@@ -54,9 +54,16 @@ Each role name is part of the #GtkAccessibleRole enumeration.
| `GRID_CELL` | An item in a grid | #GtkFlowBoxChild, #GtkGridView, #GtkColumnView |
| `IMG` | An image | #GtkImage, #GtkPicture |
| `LABEL` | A visible name or caption for a user interface component | #GtkLabel |
| `LINK` | A clickable hyperlink | #GtkLinkButton |
| `LIST` | A list of items | #GtkListBox |
| `LIST_ITEM` | An item in a list | #GtkListBoxRow |
| `MENU` | A menu | #GtkPopoverMenu |
| `MENU_BAR` | A menubar | #GtkPopoverMenuBar |
| `MENU_ITEM` | A menu item | Items in #GtkPopoverMenu |
| `MENU_ITEM_CHECKBOX` | Check menu item | Items in #GtkPopoverMenu |
| `MENU_ITEM_RADIO` | Radio menu item | Items in #GtkPopoverMenu |
| `METER` | Represents a value within a known range | #GtkLevelBar |
| `NONE` | Not represented in the accessibility tree | the slider of a #GtkScale |
| `PROGRESS_BAR` | An element that display progress | #GtkProgressBar |
| `RADIO` | A checkable input in a group of radio roles | #GtkCheckButton |
| `ROW` | A row in a columned list | #GtkColumnView |
@@ -106,9 +113,9 @@ for instance:
See the [WAI-ARIA](https://www.w3.org/WAI/PF/aria/appendices#quickref) list
of attributes for additional information.
#### List of accessible properties
#### List of accessible states
Each state name is part of the #GtkAccessibleProperty enumeration.
Each state name is part of the #GtkAccessibleState enumeration.
| State name | ARIA attribute | Value type | Notes |
|------------|----------------|------------|-------|
@@ -121,9 +128,9 @@ Each state name is part of the #GtkAccessibleProperty enumeration.
| %GTK_ACCESSIBLE_STATE_PRESSED | “aria-pressed” | #GtkAccessibleTristate | Indicates the current state of a #GtkToggleButton |
| %GTK_ACCESSIBLE_STATE_SELECTED | “aria-selected” | boolean or undefined | Set when a widget is selected |
#### List of accessible relations
#### List of accessible properties
Each state name is part of the #GtkAccessibleRelation enumeration.
Each property name is part of the #GtkAccessibleProperty enumeration.
| State name | ARIA attribute | Value type |
|------------|----------------|------------|
@@ -147,9 +154,9 @@ Each state name is part of the #GtkAccessibleRelation enumeration.
| %GTK_ACCESSIBLE_PROPERTY_VALUE_NOW | “aria-valuenow” | double |
| %GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT | “aria-valuetext” | translatable string |
#### List of accessible states
#### List of accessible relations
Each state name is part of the #GtkAccessibleState enumeration.
Each relation name is part of the #GtkAccessibleRelation enumeration.
| State name | ARIA attribute | Value type |
|------------|----------------|------------|
@@ -183,7 +190,7 @@ with a form to fill out, you should ensure that:
* each text entry widget in the form has the `GTK_ACCESSIBLE_RELATION_LABELLED_BY`
relation pointing to the label widget that describes it
Another example: if you create a tool bar containing buttons with only icons,
Another example: if you create a toolbar containing buttons with only icons,
you should ensure that:
* the container has a `GTK_ACCESSIBLE_ROLE_TOOLBAR` role
@@ -192,7 +199,7 @@ you should ensure that:
"Paste", "Add layer", or "Remove"
GTK will try to fill in some information by using ancillary UI control
property, for instance the accessible label will be taken from the label or
properties, for instance the accessible label will be taken from the label or
placeholder text used by the UI control, or from its tooltip, if the
`GTK_ACCESSIBLE_PROPERTY_LABEL` property or the `GTK_ACCESSIBLE_RELATION_LABELLED_BY`
relation are unset. Nevertheless, it is good practice and project hygiene
@@ -220,3 +227,113 @@ which acts as a proxy to the specific platform's accessibility API:
Additionally, an ad hoc accessibility backend is available for the GTK
testsuite, to ensure reproducibility of issues in the CI pipeline.
## Authoring practices {#authoring-practices}
The authoring practices are aimed at application developers, as well as
developers of GUI elements based on GTK.
Functionally, #GtkAccessible roles, states, properties, and relations are
analogous to a CSS for assistive technologies. For screen reader users, for
instance, the various accessible attributes control the rendering of their
non-visual experience. Incorrect roles and attributes may result in a
completely inaccessible user interface.
### A role is a promise
The following code:
```c
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_BUTTON);
```
is a promise that the widget being created will provide the same keyboard
interactions expected for a button. An accessible role of a button will not
turn automatically any widget into a #GtkButton; but if your widget behaves
like a button, using the %GTK_ACCESSIBLE_ROLE_BUTTON will allow any
assistive technology to handle it like they would a #GtkButton.
### Attributes can both hide and enhance
Accessible attributes can be used to override the content of a UI element,
for instance:
```c
gtk_label_set_text (GTK_LABEL (label), "Some text");
gtk_accessible_update_property (GTK_ACCESSIBLE (label),
GTK_ACCESSIBLE_PROPERTY_LABEL,
"Assistive technologies users will perceive "
"this text, not the contents of the label",
-1);
```
In the example above, the "label" property will override the contents of the
label widget.
The attributes can also enhance the UI:
```c
gtk_button_set_label (GTK_BUTTON (button), "Download");
gtk_box_append (GTK_BOX (button), button);
gtk_label_set_text (GTK_LABEL (label), "Final report.pdf");
gtk_box_append (GTK_BOX (box), label);
gtk_accessible_update_relation (GTK_ACCESSIBLE (button),
GTK_ACCESSIBLE_RELATION_LABELLED_BY,
g_list_append (NULL, label),
-1);
```
In the example above, an assistive technology will read the button's
accessible label as "Download Final report.pdf".
The power of hiding and enhancing can be a double-edged sword, as it can
lead to inadvertently overriding the accessible semantics of existing
widgets.
## Design patterns and custom widgets
When creating custom widgets, following established patterns can help
ensuring that the widgets work well for users of accessible technologies
as well.
### Custom entries
For custom entries, it is highly recommended that you implement the
#GtkEditable interface by using a #GtkText widget as delegate. If you
do this, GTK will make your widgets text editing functionality accessible
in the same way as a #GtkSpinButton or #GtkSearchEntry.
### Tab-based UI
If you make a tab-based interface, you should consider using #GtkStack
as the core, and just make a custom tab widget to control the active
stack page. When doing so, the following extra steps will ensure that
your tabs are accessible in the same way as #GtkStackSwitcher or #GtkNotebook:
- Give your tab container the role %GTK_ACCESSIBLE_ROLE_TAB_LIST
- Give your tab widgets the role %GTK_ACCESSIBLE_ROLE_TAB
- Set up the %GTK_ACCESSIBLE_RELATION_CONTROLS relation between each
tab and the #GtkStackPage object for its page
- Set the %GTK_ACCESSIBLE_PROPERTY_SELECTED property on each tab, with
the active tab getting the value %TRUE, all others %FALSE
To allow changing the active tab via accessible technologies, you can
export actions. Since the accessibility interfaces only support actions
without parameters, you can either provide `previous-tab` and `next-tab`
actions on the tab container that let users step through the tabs one-by-one,
or add a `activate-tab` action on each tab.
### Value controls
A value control (ie a widget that controls a one-dimensional quantity
that can be represented by a #GtkAdjustment) can be represented to
accessible technologies by setting the %GTK_ACCESSIBLE_PROPERTY_VALUE_MIN,
%GTK_ACCESSIBLE_PROPERTY_VALUE_MAX, and %GTK_ACCESSIBLE_PROPERTY_VALUE_NOW
properties.
To allow changing the value via accessible technologies, you can export
actions. Since the accessibility interfaces only support actions
without parameters, you should provide actions such as `increase-value`
and `decrease-value`.

View File

@@ -6,210 +6,104 @@
<section id="visual-display">
<title>Display</title>
<para role="gallery">
<link linkend="GtkLabel">
<inlinegraphic fileref="label.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkSpinner">
<inlinegraphic fileref="spinner.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkStatusbar">
<inlinegraphic fileref="statusbar.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkLevelBar">
<inlinegraphic fileref="levelbar.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkProgressBar">
<inlinegraphic fileref="progressbar.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkInfoBar">
<inlinegraphic fileref="info-bar.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkScrollbar">
<inlinegraphic fileref="scrollbar.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkImage">
<inlinegraphic fileref="image.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkSeparator">
<inlinegraphic fileref="separator.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkTextView">
<inlinegraphic fileref="multiline-text.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkScale">
<inlinegraphic fileref="scales.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkGLArea">
<inlinegraphic fileref="glarea.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkPicture">
<inlinegraphic fileref="picture.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkVideo">
<inlinegraphic fileref="video.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkMediaControls">
<inlinegraphic fileref="media-controls.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkLabel"><inlinegraphic fileref="label.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkSpinner"><inlinegraphic fileref="spinner.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkStatusbar"><inlinegraphic fileref="statusbar.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkLevelBar"><inlinegraphic fileref="levelbar.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkProgressBar"><inlinegraphic fileref="progressbar.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkInfoBar"><inlinegraphic fileref="info-bar.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkScrollbar"><inlinegraphic fileref="scrollbar.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkImage"><inlinegraphic fileref="image.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkPicture"><inlinegraphic fileref="picture.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkSeparator"><inlinegraphic fileref="separator.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkTextView"><inlinegraphic fileref="multiline-text.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkScale"><inlinegraphic fileref="scales.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkCalendar"><inlinegraphic fileref="calendar.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkGLArea"><inlinegraphic fileref="glarea.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkDrawingArea"><inlinegraphic fileref="drawingarea.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkVideo"><inlinegraphic fileref="video.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkMediaControls"><inlinegraphic fileref="media-controls.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkWindowControls"><inlinegraphic fileref="windowcontrols.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkEmojiChooser"><inlinegraphic fileref="emojichooser.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkPopoverMenu"><inlinegraphic fileref="menu.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkPopoverMenuBar"><inlinegraphic fileref="menubar.png" format="PNG"></inlinegraphic></link>
</para>
</section>
<section id="visual-buttons">
<title>Buttons</title>
<para role="gallery">
<link linkend="GtkButton">
<inlinegraphic fileref="button.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkCheckButton">
<inlinegraphic fileref="check-button.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkToggleButton">
<inlinegraphic fileref="toggle-button.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkLinkButton">
<inlinegraphic fileref="link-button.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkMenuButton">
<inlinegraphic fileref="menu-button.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkLockButton">
<inlinegraphic fileref="lockbutton.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkSpinButton">
<inlinegraphic fileref="spinbutton.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkColorButton">
<inlinegraphic fileref="color-button.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkSwitch">
<inlinegraphic fileref="switch.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkComboBox">
<inlinegraphic fileref="combo-box.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkComboBoxText">
<inlinegraphic fileref="combo-box-text.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkFontButton">
<inlinegraphic fileref="font-button.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkAppChooserButton">
<inlinegraphic fileref="appchooserbutton.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkVolumeButton">
<inlinegraphic fileref="volumebutton.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkFileChooserButton">
<inlinegraphic fileref="file-button.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkDropDown">
<inlinegraphic fileref="drop-down.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkButton"><inlinegraphic fileref="button.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkToggleButton"><inlinegraphic fileref="toggle-button.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkLinkButton"><inlinegraphic fileref="link-button.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkCheckButton"><inlinegraphic fileref="check-button.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkMenuButton"><inlinegraphic fileref="menu-button.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkLockButton"><inlinegraphic fileref="lockbutton.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkVolumeButton"><inlinegraphic fileref="volumebutton.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkSwitch"><inlinegraphic fileref="switch.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkComboBox"><inlinegraphic fileref="combo-box.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkComboBoxText"><inlinegraphic fileref="combo-box-text.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkDropDown"><inlinegraphic fileref="drop-down.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkColorButton"><inlinegraphic fileref="color-button.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkFontButton"><inlinegraphic fileref="font-button.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkAppChooserButton"><inlinegraphic fileref="appchooserbutton.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkFileChooserButton"><inlinegraphic fileref="file-button.png" format="PNG"></inlinegraphic></link>
</para>
</section>
<section id="visual-entries">
<title>Entries</title>
<para role="gallery">
<link linkend="GtkEntry">
<inlinegraphic fileref="entry.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkSearchEntry">
<inlinegraphic fileref="search-entry.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkPasswordEntry">
<inlinegraphic fileref="password-entry.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkEditableLabel">
<inlinegraphic fileref="editable-label.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkEntry"><inlinegraphic fileref="entry.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkSearchEntry"><inlinegraphic fileref="search-entry.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkPasswordEntry"><inlinegraphic fileref="password-entry.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkSpinButton"><inlinegraphic fileref="spinbutton.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkEditableLabel"><inlinegraphic fileref="editable-label.png" format="PNG"></inlinegraphic></link>
</para>
</section>
<section id="visual-containers">
<title>Containers</title>
<para role="gallery">
<link linkend="GtkScrolledWindow">
<inlinegraphic fileref="scrolledwindow.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkHeaderBar">
<inlinegraphic fileref="headerbar.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkSearchBar">
<inlinegraphic fileref="search-bar.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkActionBar">
<inlinegraphic fileref="action-bar.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkListBox">
<inlinegraphic fileref="list-box.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkFlowBox">
<inlinegraphic fileref="flow-box.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkStack">
<inlinegraphic fileref="stack.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkStackSwitcher">
<inlinegraphic fileref="stackswitcher.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkStackSidebar">
<inlinegraphic fileref="sidebar.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkTreeView">
<inlinegraphic fileref="list-and-tree.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkIconView">
<inlinegraphic fileref="icon-view.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkNotebook">
<inlinegraphic fileref="notebook.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkFrame">
<inlinegraphic fileref="frame.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkPaned">
<inlinegraphic fileref="panes.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkBox"><inlinegraphic fileref="box.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkGrid"><inlinegraphic fileref="grid.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkCenterBox"><inlinegraphic fileref="centerbox.png" format="PNG"></inlinegraphic></link>
</para>
<para role="gallery">
<link linkend="GtkScrolledWindow"><inlinegraphic fileref="scrolledwindow.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkPaned"><inlinegraphic fileref="panes.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkFrame"><inlinegraphic fileref="frame.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkExpander"><inlinegraphic fileref="expander.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkSearchBar"><inlinegraphic fileref="search-bar.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkActionBar"><inlinegraphic fileref="action-bar.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkHeaderBar"><inlinegraphic fileref="headerbar.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkNotebook"><inlinegraphic fileref="notebook.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkListBox"><inlinegraphic fileref="list-box.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkFlowBox"><inlinegraphic fileref="flow-box.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkTreeView"><inlinegraphic fileref="list-and-tree.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkIconView"><inlinegraphic fileref="icon-view.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkOverlay"><inlinegraphic fileref="overlay.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkStack"><inlinegraphic fileref="stack.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkStackSwitcher"><inlinegraphic fileref="stackswitcher.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkStackSidebar"><inlinegraphic fileref="sidebar.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkPopover"><inlinegraphic fileref="popover.png" format="PNG"></inlinegraphic></link>
</para>
</section>
<section id="visual-windows">
<title>Windows</title>
<para role="gallery">
<link linkend="GtkWindow">
<inlinegraphic fileref="window.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkMessageDialog">
<inlinegraphic fileref="messagedialog.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkAboutDialog">
<inlinegraphic fileref="aboutdialog.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkAssistant">
<inlinegraphic fileref="assistant.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkColorChooserDialog">
<inlinegraphic fileref="colorchooser.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkFileChooserDialog">
<inlinegraphic fileref="filechooser.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkFontChooserDialog">
<inlinegraphic fileref="fontchooser.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkAppChooserDialog">
<inlinegraphic fileref="appchooserdialog.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkPageSetupUnixDialog">
<inlinegraphic fileref="pagesetupdialog.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkPrintUnixDialog">
<inlinegraphic fileref="printdialog.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkWindow"><inlinegraphic fileref="window.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkMessageDialog"><inlinegraphic fileref="messagedialog.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkAboutDialog"><inlinegraphic fileref="aboutdialog.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkAssistant"><inlinegraphic fileref="assistant.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkColorChooserDialog"><inlinegraphic fileref="colorchooser.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkFileChooserDialog"><inlinegraphic fileref="filechooser.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkFontChooserDialog"><inlinegraphic fileref="fontchooser.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkAppChooserDialog"><inlinegraphic fileref="appchooserdialog.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkPageSetupUnixDialog"><inlinegraphic fileref="pagesetupdialog.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkPrintUnixDialog"><inlinegraphic fileref="printdialog.png" format="PNG"></inlinegraphic></link>
<link linkend="GtkShortcutsWindow"><inlinegraphic fileref="shortcuts-window.png" format="PNG"></inlinegraphic></link>
</para>
</section>
</para>

View File

@@ -1,4 +1,8 @@
if get_option('gtk_doc')
doc_shooter_resources = gnome.compile_resources('shooter_resources',
'shooter.gresource.xml',
source_dir: '.')
doc_shooter_sources = [
'shooter.c',
'shadow.c',
@@ -6,7 +10,8 @@ if get_option('gtk_doc')
'../../tests/gtkgears.c',
]
doc_shooter = executable('doc-shooter', doc_shooter_sources,
doc_shooter = executable('doc-shooter',
doc_shooter_sources, doc_shooter_resources,
include_directories: [ confinc, gdkinc, gtkinc, testinc, ],
dependencies: libgtk_dep)
endif

View File

@@ -112,11 +112,19 @@ snapshot_widget (GtkWidget *widget)
g_main_loop_unref (loop);
g_object_unref (paintable);
gtk_window_destroy (GTK_WINDOW (widget));
gtk_window_destroy (GTK_WINDOW (gtk_widget_get_root (widget)));
return surface;
}
static gboolean
quit_cb (gpointer data)
{
*(gboolean *)data = TRUE;
g_main_context_wakeup (NULL);
return G_SOURCE_REMOVE;
}
int
main (int argc, char **argv)
{
@@ -132,6 +140,7 @@ main (int argc, char **argv)
char *filename;
cairo_surface_t *surface;
GdkPixbuf *pixbuf;
GtkWidget *widget;
info = node->data;
@@ -144,9 +153,29 @@ main (int argc, char **argv)
NULL);
}
//while (1) g_main_context_iteration (NULL, 1);
if (info->snapshot_popover)
{
GtkWidget *button = gtk_window_get_child (GTK_WINDOW (info->window));
surface = snapshot_widget (info->window);
gtk_menu_button_popup (GTK_MENU_BUTTON (button));
widget = GTK_WIDGET (gtk_menu_button_get_popover (GTK_MENU_BUTTON (button)));
}
else
{
widget = info->window;
}
if (info->wait > 0)
{
gboolean quit = FALSE;
g_timeout_add (info->wait, quit_cb, &quit);
while (!quit)
g_main_context_iteration (NULL, TRUE);
}
surface = snapshot_widget (widget);
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0,
cairo_image_surface_get_width (surface),

View File

@@ -0,0 +1,5 @@
<gresources>
<gresource prefix="/">
<file>shortcuts-boxes.ui</file>
</gresource>
</gresources>

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkShortcutsWindow" id="shortcuts-boxes">
<property name="modal">1</property>
<child>
<object class="GtkShortcutsSection">
<property name="section-name">shortcuts</property>
<property name="max-height">12</property>
<child>
<object class="GtkShortcutsGroup">
<property name="title" translatable="yes">Overview</property>
<property name="view">overview</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">F1</property>
<property name="title" translatable="yes">Help</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">&lt;Ctrl&gt;n</property>
<property name="title" translatable="yes">Create a new box</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">&lt;Ctrl&gt;f</property>
<property name="title" translatable="yes">Search</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">&lt;Ctrl&gt;k</property>
<property name="title" translatable="yes">Keyboard shortcuts</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">&lt;Ctrl&gt;q</property>
<property name="title" translatable="yes">Close Window/Quit Boxes</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkShortcutsGroup">
<property name="title" translatable="yes">Box Creation and Properties</property>
<property name="view">wizard</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="direction">ltr</property>
<property name="accelerator">&lt;Alt&gt;Right</property>
<property name="title" translatable="yes">Switch to the next page</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="direction">ltr</property>
<property name="accelerator">&lt;Alt&gt;Left</property>
<property name="title" translatable="yes">Switch to the previous page</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="direction">rtl</property>
<property name="accelerator">&lt;Alt&gt;Left</property>
<property name="title" translatable="yes">Switch to the next page</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="direction">rtl</property>
<property name="accelerator">&lt;Alt&gt;Right</property>
<property name="title" translatable="yes">Switch to the previous page</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkShortcutsGroup">
<property name="title" translatable="yes">Box Display</property>
<property name="view">display</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">Control_L+Alt_L</property>
<property name="title" translatable="yes">Grab/Ungrab keyboard</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="direction">ltr</property>
<property name="accelerator">&lt;Alt&gt;Left</property>
<property name="title" translatable="yes">Back to overview</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="direction">rtl</property>
<property name="accelerator">&lt;Alt&gt;Right</property>
<property name="title" translatable="yes">Back to overview</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">&lt;Ctrl&gt;q</property>
<property name="title" translatable="yes">Close window/Quit Boxes</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">F11</property>
<property name="title" translatable="yes">Fullscreen/Restore from fullscreen</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>

View File

@@ -33,6 +33,19 @@ new_widget_info (const char *name,
gtk_window_set_resizable (GTK_WINDOW (info->window), FALSE);
info->include_decorations = TRUE;
}
else if (GTK_IS_POPOVER (widget))
{
GtkWidget *button;
info->snapshot_popover = TRUE;
info->window = gtk_window_new ();
gtk_window_set_default_size (GTK_WINDOW (info->window), 200, 200);
gtk_window_set_decorated (GTK_WINDOW (info->window), FALSE);
info->include_decorations = TRUE;
button = gtk_menu_button_new ();
gtk_menu_button_set_popover (GTK_MENU_BUTTON (button), widget);
gtk_window_set_child (GTK_WINDOW (info->window), button);
}
else
{
info->window = gtk_window_new ();
@@ -54,7 +67,7 @@ new_widget_info (const char *name,
gtk_widget_set_size_request (info->window, 240, 240);
break;
default:
break;
break;
}
return info;
@@ -666,8 +679,9 @@ create_editable_label (void)
add_margin (vbox);
return new_widget_info ("editable-label", vbox, MEDIUM);
return new_widget_info ("editable-label", vbox, SMALL);
}
static WidgetInfo *
create_separator (void)
{
@@ -1067,6 +1081,7 @@ create_picture (void)
GtkWidget *vbox;
GtkIconTheme *theme;
GdkPaintable *paintable;
GtkWidget *box;
theme = gtk_icon_theme_get_for_display (gdk_display_get_default ());
paintable = GDK_PAINTABLE (gtk_icon_theme_lookup_icon (theme,
@@ -1080,8 +1095,12 @@ create_picture (void)
gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_append (GTK_BOX (box), g_object_new (GTK_TYPE_IMAGE, "hexpand", TRUE, NULL));
gtk_box_append (GTK_BOX (box), widget);
gtk_box_append (GTK_BOX (box), g_object_new (GTK_TYPE_IMAGE, "hexpand", TRUE, NULL));
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
gtk_box_append (GTK_BOX (vbox), widget);
gtk_box_append (GTK_BOX (vbox), box);
gtk_box_append (GTK_BOX (vbox), gtk_label_new ("Picture"));
add_margin (vbox);
@@ -1094,10 +1113,13 @@ create_video (void)
{
GtkWidget *widget;
GtkWidget *vbox;
WidgetInfo *info;
widget = gtk_video_new_for_filename ("../../demos/gtk-demo/gtk-logo.webm");
gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
widget = gtk_video_new_for_filename ("demos/gtk-demo/gtk-logo.webm");
gtk_video_set_autoplay (GTK_VIDEO (widget), TRUE);
gtk_widget_set_halign (widget, GTK_ALIGN_FILL);
gtk_widget_set_valign (widget, GTK_ALIGN_FILL);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
gtk_box_append (GTK_BOX (vbox), widget);
@@ -1105,7 +1127,10 @@ create_video (void)
add_margin (vbox);
return new_widget_info ("video", vbox, SMALL);
info = new_widget_info ("video", vbox, MEDIUM);
info->wait = 2000;
return info;
}
static WidgetInfo *
@@ -1113,8 +1138,13 @@ create_media_controls (void)
{
GtkWidget *widget;
GtkWidget *vbox;
GtkMediaStream *stream;
WidgetInfo *info;
widget = gtk_media_controls_new (NULL);
stream = gtk_media_file_new_for_filename ("demos/gtk-demo/gtk-logo.webm");
gtk_media_stream_play (stream);
widget = gtk_media_controls_new (stream);
gtk_widget_set_size_request (widget, 210, -1);
gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
@@ -1124,7 +1154,10 @@ create_media_controls (void)
add_margin (vbox);
return new_widget_info ("media-controls", vbox, SMALL);
info = new_widget_info ("media-controls", vbox, SMALL);
info->wait = 2000;
return info;
}
static WidgetInfo *
@@ -1151,25 +1184,18 @@ create_spinner (void)
static WidgetInfo *
create_volume_button (void)
{
GtkWidget *button, *box;
GtkWidget *widget;
GtkWidget *popup;
GtkWidget *widget, *vbox;
widget = gtk_window_new ();
gtk_widget_set_size_request (widget, 100, 250);
widget = gtk_volume_button_new ();
gtk_scale_button_set_value (GTK_SCALE_BUTTON (widget), 33);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_window_set_child (GTK_WINDOW (widget), box);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
gtk_box_append (GTK_BOX (vbox), widget);
gtk_box_append (GTK_BOX (vbox), gtk_label_new ("Volume Button"));
button = gtk_volume_button_new ();
gtk_box_append (GTK_BOX (box), button);
gtk_scale_button_set_value (GTK_SCALE_BUTTON (button), 33);
popup = gtk_scale_button_get_popup (GTK_SCALE_BUTTON (button));
gtk_widget_realize (widget);
gtk_widget_show (popup);
return new_widget_info ("volumebutton", widget, ASIS);
return new_widget_info ("volumebutton", vbox, SMALL);
}
static WidgetInfo *
@@ -1358,6 +1384,7 @@ create_sidebar (void)
gtk_widget_add_css_class (view, "view");
gtk_widget_set_halign (view, GTK_ALIGN_FILL);
gtk_widget_set_valign (view, GTK_ALIGN_FILL);
gtk_widget_set_hexpand (view, TRUE);
gtk_stack_add_titled (GTK_STACK (stack), view, "page1", "Page 1");
view = gtk_text_view_new ();
gtk_stack_add_titled (GTK_STACK (stack), view, "page2", "Page 2");
@@ -1373,7 +1400,7 @@ create_sidebar (void)
gtk_box_append (GTK_BOX (hbox), stack);
gtk_frame_set_child (GTK_FRAME (frame), hbox);
return new_widget_info ("sidebar", frame, ASIS);
return new_widget_info ("sidebar", frame, MEDIUM);
}
static WidgetInfo *
@@ -1471,6 +1498,7 @@ create_flow_box (void)
static WidgetInfo *
create_gl_area (void)
{
GtkWidget *vbox;
WidgetInfo *info;
GtkWidget *widget;
GtkWidget *gears;
@@ -1487,12 +1515,598 @@ create_gl_area (void)
gtk_style_context_add_provider (gtk_widget_get_style_context (gears), GTK_STYLE_PROVIDER (provider), 800);
g_object_unref (provider);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
gtk_widget_set_halign (widget, GTK_ALIGN_FILL);
gtk_widget_set_valign (widget, GTK_ALIGN_FILL);
gtk_box_append (GTK_BOX (vbox), widget);
gtk_box_append (GTK_BOX (vbox), gtk_label_new ("GL Area"));
add_margin (vbox);
info = new_widget_info ("glarea", vbox, MEDIUM);
return info;
}
static WidgetInfo *
create_window_controls (void)
{
GtkWidget *controls;
GtkWidget *vbox;
controls = gtk_window_controls_new (GTK_PACK_END);
gtk_window_controls_set_decoration_layout (GTK_WINDOW_CONTROLS (controls),
":minimize,maximize,close");
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
gtk_widget_set_halign (controls, GTK_ALIGN_CENTER);
gtk_widget_set_valign (controls, GTK_ALIGN_CENTER);
gtk_box_append (GTK_BOX (vbox), controls);
gtk_box_append (GTK_BOX (vbox), gtk_label_new ("Window Controls"));
add_margin (vbox);
return new_widget_info ("windowcontrols", vbox, SMALL);
}
static WidgetInfo *
create_calendar (void)
{
GtkWidget *widget;
GtkWidget *vbox;
widget = gtk_calendar_new ();
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
gtk_box_append (GTK_BOX (vbox), widget);
gtk_box_append (GTK_BOX (vbox), gtk_label_new ("Calendar"));
add_margin (vbox);
return new_widget_info ("calendar", vbox, MEDIUM);
}
static WidgetInfo *
create_emojichooser (void)
{
GtkWidget *widget;
WidgetInfo *info;
widget = gtk_emoji_chooser_new ();
g_object_set (widget, "autohide", FALSE, NULL);
info = new_widget_info ("emojichooser", widget, ASIS);
info->wait = 2000;
return info;
}
static WidgetInfo *
create_expander (void)
{
GtkWidget *widget;
widget = gtk_expander_new ("Expander");
gtk_expander_set_child (GTK_EXPANDER (widget), gtk_label_new ("Hidden Content"));
gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
return new_widget_info ("expander", widget, SMALL);
}
static void
mapped_cb (GtkWidget *widget)
{
gtk_widget_child_focus (widget, GTK_DIR_RIGHT);
}
static WidgetInfo *
create_menu_bar (void)
{
GtkWidget *widget;
GtkWidget *vbox;
GMenu *menu, *menu1;
GMenuItem *item;
menu = g_menu_new ();
menu1 = g_menu_new ();
item = g_menu_item_new ("Item", "action");
g_menu_append_item (menu1, item);
g_menu_append_submenu (menu, "File", G_MENU_MODEL (menu1));
g_object_unref (item);
g_object_unref (menu1);
menu1 = g_menu_new ();
item = g_menu_item_new ("Item", "action");
g_menu_append_item (menu1, item);
g_menu_append_submenu (menu, "Edit", G_MENU_MODEL (menu1));
g_object_unref (item);
g_object_unref (menu1);
menu1 = g_menu_new ();
item = g_menu_item_new ("Item", "action");
g_menu_append_item (menu1, item);
g_menu_append_submenu (menu, "View", G_MENU_MODEL (menu1));
g_object_unref (item);
g_object_unref (menu1);
widget = gtk_popover_menu_bar_new_from_model (G_MENU_MODEL (menu));
g_object_unref (menu);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
gtk_box_append (GTK_BOX (vbox), widget);
gtk_box_append (GTK_BOX (vbox), gtk_label_new ("Menu Bar"));
add_margin (vbox);
g_signal_connect (widget, "map", G_CALLBACK (mapped_cb), NULL);
return new_widget_info ("menubar", vbox, SMALL);
}
static WidgetInfo *
create_popover (void)
{
GtkWidget *widget;
GtkWidget *child;
WidgetInfo *info;
widget = gtk_popover_new ();
gtk_widget_set_size_request (widget, 180, 180);
gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
g_object_set (widget, "autohide", FALSE, NULL);
child = gtk_label_new ("Popover");
gtk_widget_set_halign (child, GTK_ALIGN_CENTER);
gtk_widget_set_valign (child, GTK_ALIGN_CENTER);
gtk_popover_set_child (GTK_POPOVER (widget), child);
info = new_widget_info ("popover", widget, ASIS);
info->wait = 100;
return info;
}
static WidgetInfo *
create_menu (void)
{
GtkWidget *widget;
GMenu *menu, *menu1;
GMenuItem *item;
GSimpleActionGroup *group;
GSimpleAction *action;
GtkEventController *controller;
GtkShortcut *shortcut;
menu = g_menu_new ();
menu1 = g_menu_new ();
item = g_menu_item_new ("Item", "action");
g_menu_append_item (menu1, item);
g_menu_append_submenu (menu, "Style", G_MENU_MODEL (menu1));
g_object_unref (item);
g_object_unref (menu1);
item = g_menu_item_new ("Transition", "menu.transition");
g_menu_append_item (menu, item);
g_object_unref (item);
menu1 = g_menu_new ();
item = g_menu_item_new ("Inspector", "menu.inspector");
g_menu_append_item (menu1, item);
g_object_unref (item);
item = g_menu_item_new ("About", "menu.about");
g_menu_append_item (menu1, item);
g_object_unref (item);
g_menu_append_section (menu, NULL, G_MENU_MODEL (menu1));
g_object_unref (menu1);
widget = gtk_popover_menu_new_from_model (G_MENU_MODEL (menu));
g_object_unref (menu);
group = g_simple_action_group_new ();
action = g_simple_action_new_stateful ("transition", NULL, g_variant_new_boolean (TRUE));
g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (action));
g_object_unref (action);
action = g_simple_action_new ("inspector", NULL);
g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (action));
g_object_unref (action);
action = g_simple_action_new ("about", NULL);
g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (action));
g_object_unref (action);
gtk_widget_insert_action_group (widget, "menu", G_ACTION_GROUP (group));
g_object_unref (group);
g_object_set (widget, "autohide", FALSE, NULL);
controller = gtk_shortcut_controller_new ();
shortcut = gtk_shortcut_new (gtk_keyval_trigger_new (GDK_KEY_F1, 0),
gtk_named_action_new ("menu.about"));
gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller), shortcut);
gtk_widget_add_controller (widget, controller);
return new_widget_info ("menu", widget, ASIS);
}
static WidgetInfo *
create_shortcuts_window (void)
{
GtkBuilder *builder;
GtkWidget *overlay;
builder = gtk_builder_new_from_resource ("/shortcuts-boxes.ui");
overlay = GTK_WIDGET (gtk_builder_get_object (builder, "shortcuts-boxes"));
g_object_set (overlay, "view-name", "display", NULL);
g_object_ref (overlay);
g_object_unref (builder);
return new_widget_info ("shortcuts-window", overlay, ASIS);
}
static void
oval_path (cairo_t *cr,
double xc, double yc,
double xr, double yr)
{
cairo_save (cr);
cairo_translate (cr, xc, yc);
cairo_scale (cr, 1.0, yr / xr);
cairo_move_to (cr, xr, 0.0);
cairo_arc (cr,
0, 0,
xr,
0, 2 * G_PI);
cairo_close_path (cr);
cairo_restore (cr);
}
static void
fill_checks (cairo_t *cr,
int x, int y,
int width, int height)
{
int i, j;
#define CHECK_SIZE 16
cairo_rectangle (cr, x, y, width, height);
cairo_set_source_rgb (cr, 0.4, 0.4, 0.4);
cairo_fill (cr);
/* Only works for CHECK_SIZE a power of 2 */
j = x & (-CHECK_SIZE);
for (; j < height; j += CHECK_SIZE)
{
i = y & (-CHECK_SIZE);
for (; i < width; i += CHECK_SIZE)
if ((i / CHECK_SIZE + j / CHECK_SIZE) % 2 == 0)
cairo_rectangle (cr, i, j, CHECK_SIZE, CHECK_SIZE);
}
cairo_set_source_rgb (cr, 0.7, 0.7, 0.7);
cairo_fill (cr);
#undef CHECK_SIZE
}
static void
draw_3circles (cairo_t *cr,
double xc, double yc,
double radius,
double alpha)
{
double subradius = radius * (2 / 3. - 0.1);
cairo_set_source_rgba (cr, 1., 0., 0., alpha);
oval_path (cr,
xc + radius / 3. * cos (G_PI * (0.5)),
yc - radius / 3. * sin (G_PI * (0.5)),
subradius, subradius);
cairo_fill (cr);
cairo_set_source_rgba (cr, 0., 1., 0., alpha);
oval_path (cr,
xc + radius / 3. * cos (G_PI * (0.5 + 2/.3)),
yc - radius / 3. * sin (G_PI * (0.5 + 2/.3)),
subradius, subradius);
cairo_fill (cr);
cairo_set_source_rgba (cr, 0., 0., 1., alpha);
oval_path (cr,
xc + radius / 3. * cos (G_PI * (0.5 + 4/.3)),
yc - radius / 3. * sin (G_PI * (0.5 + 4/.3)),
subradius, subradius);
cairo_fill (cr);
}
static void
groups_draw (GtkDrawingArea *darea,
cairo_t *cr,
int width,
int height,
gpointer data)
{
cairo_surface_t *overlay, *punch, *circles;
cairo_t *overlay_cr, *punch_cr, *circles_cr;
/* Fill the background */
double radius = 0.5 * (width < height ? width : height) - 10;
double xc = width / 2.;
double yc = height / 2.;
overlay = cairo_surface_create_similar (cairo_get_target (cr),
CAIRO_CONTENT_COLOR_ALPHA,
width, height);
punch = cairo_surface_create_similar (cairo_get_target (cr),
CAIRO_CONTENT_ALPHA,
width, height);
circles = cairo_surface_create_similar (cairo_get_target (cr),
CAIRO_CONTENT_COLOR_ALPHA,
width, height);
fill_checks (cr, 0, 0, width, height);
/* Draw a black circle on the overlay
*/
overlay_cr = cairo_create (overlay);
cairo_set_source_rgb (overlay_cr, 0., 0., 0.);
oval_path (overlay_cr, xc, yc, radius, radius);
cairo_fill (overlay_cr);
/* Draw 3 circles to the punch surface, then cut
* that out of the main circle in the overlay
*/
punch_cr = cairo_create (punch);
draw_3circles (punch_cr, xc, yc, radius, 1.0);
cairo_destroy (punch_cr);
cairo_set_operator (overlay_cr, CAIRO_OPERATOR_DEST_OUT);
cairo_set_source_surface (overlay_cr, punch, 0, 0);
cairo_paint (overlay_cr);
/* Now draw the 3 circles in a subgroup again
* at half intensity, and use OperatorAdd to join up
* without seams.
*/
circles_cr = cairo_create (circles);
cairo_set_operator (circles_cr, CAIRO_OPERATOR_OVER);
draw_3circles (circles_cr, xc, yc, radius, 0.5);
cairo_destroy (circles_cr);
cairo_set_operator (overlay_cr, CAIRO_OPERATOR_ADD);
cairo_set_source_surface (overlay_cr, circles, 0, 0);
cairo_paint (overlay_cr);
cairo_destroy (overlay_cr);
cairo_set_source_surface (cr, overlay, 0, 0);
cairo_paint (cr);
cairo_surface_destroy (overlay);
cairo_surface_destroy (punch);
cairo_surface_destroy (circles);
}
static WidgetInfo *
create_drawing_area (void)
{
GtkWidget *vbox;
WidgetInfo *info;
GtkWidget *widget;
GtkWidget *da;
widget = gtk_frame_new (NULL);
da = gtk_drawing_area_new ();
gtk_widget_set_size_request (da, 96, 96);
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (da), groups_draw, NULL, NULL);
gtk_frame_set_child (GTK_FRAME (widget), da);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_widget_set_halign (widget, GTK_ALIGN_FILL);
gtk_widget_set_valign (widget, GTK_ALIGN_FILL);
add_margin (widget);
gtk_box_append (GTK_BOX (vbox), widget);
gtk_box_append (GTK_BOX (vbox), gtk_label_new ("Drawing Area"));
info = new_widget_info ("glarea", widget, MEDIUM);
add_margin (vbox);
info = new_widget_info ("drawingarea", vbox, MEDIUM);
return info;
}
static WidgetInfo *
create_box (void)
{
GtkWidget *hbox;
GtkWidget *vbox;
GtkWidget *widget;
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 40);
gtk_widget_set_margin_top (hbox, 20);
gtk_widget_set_margin_bottom (hbox, 20);
gtk_widget_set_halign (hbox, GTK_ALIGN_CENTER);
widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
for (int i = 0; i < 2; i++)
{
GtkWidget *button = gtk_button_new ();
gtk_widget_add_css_class (button, "small");
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
gtk_box_append (GTK_BOX (widget), button);
}
gtk_box_append (GTK_BOX (widget), gtk_label_new (""));
gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
gtk_box_append (GTK_BOX (hbox), widget);
widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
for (int i = 0; i < 2; i++)
{
GtkWidget *button = gtk_button_new ();
gtk_widget_add_css_class (button, "small");
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
gtk_box_append (GTK_BOX (widget), button);
}
gtk_box_append (GTK_BOX (widget), gtk_label_new (""));
gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
gtk_box_append (GTK_BOX (hbox), widget);
gtk_box_append (GTK_BOX (vbox), hbox);
gtk_box_append (GTK_BOX (vbox), g_object_new (GTK_TYPE_LABEL,
"label", "Horizontal and Vertical Boxes",
"justify", GTK_JUSTIFY_CENTER,
NULL));
add_margin (vbox);
return new_widget_info ("box", vbox, MEDIUM);
}
static WidgetInfo *
create_center_box (void)
{
GtkWidget *vbox;
GtkWidget *widget;
GtkWidget *button;
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
widget = gtk_center_box_new ();
gtk_widget_set_margin_top (widget, 10);
gtk_widget_set_margin_bottom (widget, 10);
gtk_widget_set_margin_start (widget, 20);
gtk_widget_set_margin_end (widget, 20);
gtk_widget_set_halign (widget, GTK_ALIGN_FILL);
gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
button = gtk_button_new ();
gtk_widget_add_css_class (button, "small");
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
gtk_center_box_set_start_widget (GTK_CENTER_BOX (widget), button);
button = gtk_button_new ();
gtk_widget_add_css_class (button, "small");
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
gtk_center_box_set_center_widget (GTK_CENTER_BOX (widget), button);
button = gtk_button_new ();
gtk_widget_add_css_class (button, "small");
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
gtk_center_box_set_end_widget (GTK_CENTER_BOX (widget), button);
gtk_box_append (GTK_BOX (vbox), widget);
gtk_box_append (GTK_BOX (vbox), g_object_new (GTK_TYPE_LABEL,
"label", "Center Box",
"justify", GTK_JUSTIFY_CENTER,
NULL));
add_margin (vbox);
return new_widget_info ("centerbox", vbox, SMALL);
}
static WidgetInfo *
create_grid (void)
{
GtkWidget *vbox;
GtkWidget *widget;
GtkWidget *button;
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
widget = gtk_grid_new ();
gtk_grid_set_row_spacing (GTK_GRID (widget), 4);
gtk_grid_set_column_spacing (GTK_GRID (widget), 4);
gtk_widget_set_margin_top (widget, 20);
gtk_widget_set_margin_bottom (widget, 20);
gtk_widget_set_margin_start (widget, 20);
gtk_widget_set_margin_end (widget, 20);
gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
button = gtk_button_new ();
gtk_widget_add_css_class (button, "small");
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
gtk_grid_attach (GTK_GRID (widget), button, 0, 0, 1, 1);
button = gtk_button_new ();
gtk_widget_add_css_class (button, "small");
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
gtk_grid_attach (GTK_GRID (widget), button, 0, 1, 1, 1);
button = gtk_button_new ();
gtk_widget_add_css_class (button, "small");
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
gtk_grid_attach (GTK_GRID (widget), button, 1, 0, 1, 1);
button = gtk_button_new ();
gtk_widget_add_css_class (button, "small");
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
gtk_grid_attach (GTK_GRID (widget), button, 1, 1, 1, 1);
gtk_grid_attach (GTK_GRID (widget), gtk_label_new (""), 2, 0, 1, 1);
gtk_grid_attach (GTK_GRID (widget), gtk_label_new (""), 0, 2, 1, 1);
gtk_box_append (GTK_BOX (vbox), widget);
gtk_box_append (GTK_BOX (vbox), g_object_new (GTK_TYPE_LABEL,
"label", "Grid",
"justify", GTK_JUSTIFY_CENTER,
NULL));
add_margin (vbox);
return new_widget_info ("grid", vbox, MEDIUM);
}
static WidgetInfo *
create_overlay (void)
{
GtkWidget *vbox;
WidgetInfo *info;
GtkWidget *widget;
GtkWidget *overlay;
GtkWidget *label;
GtkWidget *child;
widget = gtk_frame_new (NULL);
overlay = gtk_overlay_new ();
gtk_widget_add_css_class (widget, "view");
label = gtk_label_new ("Content");
gtk_widget_set_vexpand (label, TRUE);
gtk_frame_set_child (GTK_FRAME (widget), overlay);
gtk_overlay_set_child (GTK_OVERLAY (overlay), label);
child = gtk_frame_new (NULL);
gtk_widget_add_css_class (child, "app-notification");
gtk_frame_set_child (GTK_FRAME (child), gtk_label_new ("Overlay"));
gtk_widget_set_valign (child, GTK_ALIGN_START);
gtk_widget_set_halign (child, GTK_ALIGN_CENTER);
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), child);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_widget_set_halign (widget, GTK_ALIGN_FILL);
gtk_widget_set_valign (widget, GTK_ALIGN_FILL);
gtk_box_append (GTK_BOX (vbox), widget);
gtk_box_append (GTK_BOX (vbox), gtk_label_new ("Overlay"));
add_margin (vbox);
info = new_widget_info ("overlay", vbox, MEDIUM);
return info;
}
@@ -1501,6 +2115,18 @@ GList *
get_all_widgets (void)
{
GList *retval = NULL;
GtkCssProvider *provider;
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider,
"button.small {\n"
" min-width: 16px;\n"
" min-height: 16px;\n"
" padding: 0;\n"
"}", -1);
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
800);
retval = g_list_prepend (retval, create_search_bar ());
retval = g_list_prepend (retval, create_action_bar ());
@@ -1562,6 +2188,19 @@ get_all_widgets (void)
retval = g_list_prepend (retval, create_password_entry ());
retval = g_list_prepend (retval, create_editable_label ());
retval = g_list_prepend (retval, create_drop_down ());
retval = g_list_prepend (retval, create_window_controls ());
retval = g_list_prepend (retval, create_calendar ());
retval = g_list_prepend (retval, create_emojichooser ());
retval = g_list_prepend (retval, create_expander ());
retval = g_list_prepend (retval, create_menu_bar ());
retval = g_list_prepend (retval, create_popover ());
retval = g_list_prepend (retval, create_menu ());
retval = g_list_prepend (retval, create_shortcuts_window ());
retval = g_list_prepend (retval, create_drawing_area ());
retval = g_list_prepend (retval, create_box ());
retval = g_list_prepend (retval, create_center_box ());
retval = g_list_prepend (retval, create_grid ());
retval = g_list_prepend (retval, create_overlay ());
return retval;
}

View File

@@ -18,6 +18,8 @@ typedef struct WidgetInfo
char *name;
gboolean no_focus;
gboolean include_decorations;
gboolean snapshot_popover;
guint wait;
WidgetSize size;
} WidgetInfo;

View File

@@ -11,49 +11,49 @@ print_hello (GtkWidget *widget,
static void
quit_cb (GtkWidget *widget, gpointer data)
{
gboolean *done = data;
GtkWindow *window = data;
*done = TRUE;
g_main_context_wakeup (NULL);
gtk_window_close (window);
}
int
main (int argc,
char *argv[])
static void
activate (GtkApplication *app,
gpointer user_data)
{
GtkBuilder *builder;
GObject *window;
GObject *button;
gboolean done = FALSE;
#ifdef GTK_SRCDIR
g_chdir (GTK_SRCDIR);
#endif
gtk_init ();
/* Construct a GtkBuilder instance and load our UI description */
builder = gtk_builder_new ();
GtkBuilder *builder = gtk_builder_new ();
gtk_builder_add_from_file (builder, "builder.ui", NULL);
/* Connect signal handlers to the constructed widgets. */
window = gtk_builder_get_object (builder, "window");
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
GObject *window = gtk_builder_get_object (builder, "window");
gtk_window_set_application (GTK_WINDOW (window), app);
button = gtk_builder_get_object (builder, "button1");
GObject *button = gtk_builder_get_object (builder, "button1");
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
button = gtk_builder_get_object (builder, "button2");
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
button = gtk_builder_get_object (builder, "quit");
g_signal_connect (button, "clicked", G_CALLBACK (quit_cb), &done);
g_signal_connect_swapped (button, "clicked", G_CALLBACK (quit_cb), window);
gtk_widget_show (GTK_WIDGET (window));
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
g_object_unref (builder);
}
int
main (int argc,
char *argv[])
{
#ifdef GTK_SRCDIR
g_chdir (GTK_SRCDIR);
#endif
GtkApplication *app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
int status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
return status;
}

View File

@@ -185,7 +185,7 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
display_broadway->core_pointer,
NULL,
message->base.time,
0,
message->pointer.state,
message->scroll.dir == 0
? GDK_SCROLL_UP
: GDK_SCROLL_DOWN,

View File

@@ -87,12 +87,12 @@
*/
/**
* GDK_WINDOWING_QUARTZ:
* GDK_WINDOWING_MACOS:
*
* The #GDK_WINDOWING_QUARTZ macro is defined if the Quartz backend
* The #GDK_WINDOWING_MACOS macro is defined if the MacOS backend
* is supported.
*
* Use this macro to guard code that is specific to the Quartz backend.
* Use this macro to guard code that is specific to the MacOS backend.
*/
/**

View File

@@ -43,13 +43,13 @@
*
* These functions are used to create and destroy cursors. Cursors
* are immutable objects, so once you created them, there is no way
* to modify them later. Create a new cursor, when you want to change
* to modify them later. Create a new cursor when you want to change
* something about it.
*
* Cursors by themselves are not very interesting, they must be
* bound to a window for users to see them. This is done with
* gdk_surface_set_cursor() or gdk_surface_set_device_cursor().
* Applications will typically use higher-level GTK+ functions such
* Applications will typically use higher-level GTK functions such
* as gtk_widget_set_cursor() instead.
*
* Cursors are not bound to a given #GdkDisplay, so they can be shared.
@@ -59,16 +59,19 @@
* There are multiple ways to create cursors. The platform's own cursors
* can be created with gdk_cursor_new_from_name(). That function lists
* the commonly available names that are shared with the CSS specification.
* Other names may be available, depending on the platform in use.
* Other names may be available, depending on the platform in use. On some
* platforms, what images are used for named cursors may be influenced by
* the cursor theme.
*
* Another option to create a cursor is to use gdk_cursor_new_from_texture()
* and provide an image to use for the cursor.
*
* To ease work with unsupported cursors, a fallback cursor can be provided.
* If a #GdkSurface cannot use a cursor because of the reasons mentioned above,
* it will try the fallback cursor. Of course, fallback cursors can themselves
* have fallback cursors again, so it is possible to provide a chain of
* progressively easier to support cursors. If none of the provided cursors
* can be supported, the default cursor will be the ultimate fallback.
* it will try the fallback cursor. Fallback cursors can themselves have fallback
* cursors again, so it is possible to provide a chain of progressively easier
* to support cursors. If none of the provided cursors can be supported, the
* default cursor will be the ultimate fallback.
*/
/**
@@ -175,40 +178,40 @@ gdk_cursor_class_init (GdkCursorClass *cursor_class)
object_class->finalize = gdk_cursor_finalize;
g_object_class_install_property (object_class,
PROP_FALLBACK,
g_param_spec_object ("fallback",
PROP_FALLBACK,
g_param_spec_object ("fallback",
P_("Fallback"),
P_("Cursor image to fall back to if this cursor cannot be displayed"),
GDK_TYPE_CURSOR,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class,
PROP_HOTSPOT_X,
g_param_spec_int ("hotspot-x",
PROP_HOTSPOT_X,
g_param_spec_int ("hotspot-x",
P_("Hotspot X"),
P_("Horizontal offset of the cursor hotspot"),
0, G_MAXINT, 0,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class,
PROP_HOTSPOT_Y,
g_param_spec_int ("hotspot-y",
PROP_HOTSPOT_Y,
g_param_spec_int ("hotspot-y",
P_("Hotspot Y"),
P_("Vertical offset of the cursor hotspot"),
0, G_MAXINT, 0,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class,
PROP_NAME,
g_param_spec_string ("name",
PROP_NAME,
g_param_spec_string ("name",
P_("Name"),
P_("Name of this cursor"),
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class,
PROP_TEXTURE,
g_param_spec_object ("texture",
PROP_TEXTURE,
g_param_spec_object ("texture",
P_("Texture"),
P_("The texture displayed by this cursor"),
GDK_TYPE_TEXTURE,
@@ -345,8 +348,8 @@ gdk_cursor_new_from_name (const char *name,
*/
GdkCursor *
gdk_cursor_new_from_texture (GdkTexture *texture,
int hotspot_x,
int hotspot_y,
int hotspot_x,
int hotspot_y,
GdkCursor *fallback)
{
g_return_val_if_fail (GDK_IS_TEXTURE (texture), NULL);
@@ -390,7 +393,7 @@ gdk_cursor_get_fallback (GdkCursor *cursor)
* @cursor: a #GdkCursor.
*
* Returns the name of the cursor. If the cursor is not a named cursor, %NULL
* will be returned and the GdkCursor::texture property will be set.
* will be returned.
*
* Returns: (transfer none) (nullable): the name of the cursor or %NULL if it is not
* a named cursor
@@ -408,7 +411,7 @@ gdk_cursor_get_name (GdkCursor *cursor)
* @cursor: a #GdkCursor.
*
* Returns the texture for the cursor. If the cursor is a named cursor, %NULL
* will be returned and the GdkCursor::name property will be set.
* will be returned.
*
* Returns: (transfer none) (nullable): the texture for cursor or %NULL if it is a
* named cursor
@@ -428,6 +431,10 @@ gdk_cursor_get_texture (GdkCursor *cursor)
* Returns the horizontal offset of the hotspot. The hotspot indicates the
* pixel that will be directly above the cursor.
*
* Note that named cursors may have a nonzero hotspot, but this function
* will only return the hotspot position for cursors created with
* gdk_cursor_new_from_texture().
*
* Returns: the horizontal offset of the hotspot or 0 for named cursors
*/
int
@@ -445,6 +452,10 @@ gdk_cursor_get_hotspot_x (GdkCursor *cursor)
* Returns the vertical offset of the hotspot. The hotspot indicates the
* pixel that will be directly above the cursor.
*
* Note that named cursors may have a nonzero hotspot, but this function
* will only return the hotspot position for cursors created with
* gdk_cursor_new_from_texture().
*
* Returns: the vertical offset of the hotspot or 0 for named cursors
*/
int
@@ -454,4 +465,3 @@ gdk_cursor_get_hotspot_y (GdkCursor *cursor)
return cursor->hotspot_y;
}

View File

@@ -46,15 +46,15 @@ GType gdk_cursor_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GdkCursor* gdk_cursor_new_from_texture (GdkTexture *texture,
int hotspot_x,
int hotspot_y,
int hotspot_x,
int hotspot_y,
GdkCursor *fallback);
GDK_AVAILABLE_IN_ALL
GdkCursor* gdk_cursor_new_from_name (const char *name,
GdkCursor* gdk_cursor_new_from_name (const char *name,
GdkCursor *fallback);
GDK_AVAILABLE_IN_ALL
GdkCursor * gdk_cursor_get_fallback (GdkCursor *cursor);
GdkCursor * gdk_cursor_get_fallback (GdkCursor *cursor);
GDK_AVAILABLE_IN_ALL
const char *gdk_cursor_get_name (GdkCursor *cursor);
GDK_AVAILABLE_IN_ALL

View File

@@ -36,16 +36,6 @@
#include "x11/gdkprivate-x11.h"
#endif
#ifdef GDK_WINDOWING_QUARTZ
/* When the gdk_quartz_display_open function is removed We can
* immediately include gdkquartzdisplaymanager.h here instead of
* gdkprivate-quartz.h so that we wont have to enable -xobjective-c
* for the “generic” GDK source code.
* #include "quartz/gdkquartzdisplaymanager.h"
*/
#include "quartz/gdkprivate-quartz.h"
#endif
#ifdef GDK_WINDOWING_BROADWAY
#include "broadway/gdkprivate-broadway.h"
#endif
@@ -98,8 +88,8 @@
* }
* else
* #endif
* #ifdef GDK_WINDOWING_QUARTZ
* if (GDK_IS_QUARTZ_DISPLAY (display))
* #ifdef GDK_WINDOWING_MACOS
* if (GDK_IS_MACOS_DISPLAY (display))
* {
* // make Quartz-specific calls here
* }
@@ -263,9 +253,6 @@ struct _GdkBackend {
};
static GdkBackend gdk_backends[] = {
#ifdef GDK_WINDOWING_QUARTZ
{ "quartz", _gdk_quartz_display_open },
#endif
#ifdef GDK_WINDOWING_MACOS
{ "macos", _gdk_macos_display_open },
#endif
@@ -305,7 +292,7 @@ gdk_display_manager_get (void)
if (manager == NULL)
manager = g_object_new (GDK_TYPE_DISPLAY_MANAGER, NULL);
return manager;
}
@@ -344,7 +331,7 @@ gdk_display_get_default (void)
* gdk_display_manager_set_default_display:
* @manager: a #GdkDisplayManager
* @display: a #GdkDisplay
*
*
* Sets @display as the default display.
**/
void

View File

@@ -814,12 +814,17 @@ _gdk_event_queue_handle_motion_compression (GdkDisplay *display)
void
_gdk_event_queue_flush (GdkDisplay *display)
{
GList *tmp_list;
for (tmp_list = display->queued_events.head; tmp_list; tmp_list = tmp_list->next)
while (TRUE)
{
GdkEvent *event = tmp_list->data;
GdkEvent *event;
event = (GdkEvent *)g_queue_pop_head (&display->queued_events);
if (!event)
return;
event->flags |= GDK_EVENT_FLUSHED;
_gdk_event_emit (event);
gdk_event_unref (event);
}
}

View File

@@ -29,11 +29,11 @@
/**
* SECTION:gdkframeclock
* @Short_description: Frame clock syncs painting to a window or display
* @Title: Frame clock
* @Title: GdkFrameClock
* @Short_description: Synchronizes painting to a surface
*
* A #GdkFrameClock tells the application when to update and repaint a
* window. This may be synced to the vertical refresh rate of the
* A #GdkFrameClock tells the application when to update and repaint
* a surface. This may be synced to the vertical refresh rate of the
* monitor, for example. Even when the frame clock uses a simple timer
* rather than a hardware-based vertical sync, the frame clock helps
* because it ensures everything paints at the same time (reducing the

View File

@@ -864,7 +864,7 @@ gdk_gl_context_get_use_es (GdkGLContext *context)
return priv->use_es > 0;
}
static void
static void APIENTRY
gl_debug_message_callback (GLenum source,
GLenum type,
GLuint id,

View File

@@ -49,10 +49,6 @@ struct _GdkGLContextClass
GError **error);
cairo_region_t * (* get_damage) (GdkGLContext *context);
gboolean (* texture_from_surface) (GdkGLContext *context,
cairo_surface_t *surface,
cairo_region_t *region);
};
typedef struct {

View File

@@ -35,7 +35,7 @@ void gtk_snapshot_pop (GdkSnapshot
* @Short_description: An interface for a paintable region
* @See_also: #ClutterContent, #GtkImage, #GdkTexture, #GtkSnapshot
*
* #GdkPaintable is a simple interface used by GDK and GDK to represent
* #GdkPaintable is a simple interface used by GDK and GTK to represent
* objects that can be painted anywhere at any size without requiring any
* sort of layout. The interface is inspired by similar concepts elsewhere,
* such as [ClutterContent](https://developer.gnome.org/clutter/stable/ClutterContent.html),
@@ -347,22 +347,22 @@ gdk_paintable_get_intrinsic_height (GdkPaintable *paintable)
* @paintable: a #GdkPaintable
*
* Gets the preferred aspect ratio the @paintable would like to be displayed at.
* The aspect ration is the width divided by the height, so a value of 0.5 means
* The aspect ratio is the width divided by the height, so a value of 0.5 means
* that the @paintable prefers to be displayed twice as high as it is wide.
* Consumers of this interface can use this to preserve aspect ratio when displaying
* this paintable.
* the paintable.
*
* This is a purely informational value and does not in any way limit the values
* that may be passed to gdk_paintable_snapshot().
*
* Usually when a @paintable returns non-0 values from
* Usually when a @paintable returns nonzero values from
* gdk_paintable_get_intrinsic_width() and gdk_paintable_get_intrinsic_height()
* the aspect ratio should conform to those values, though that is not required.
*
* If the @paintable does not have a preferred aspect ratio, it returns 0.0.
* If the @paintable does not have a preferred aspect ratio, it returns 0.
* Negative values are never returned.
*
* Returns: the intrinsic aspect ratio of @paintable or 0.0 if none.
* Returns: the intrinsic aspect ratio of @paintable or 0 if none.
*/
double
gdk_paintable_get_intrinsic_aspect_ratio (GdkPaintable *paintable)
@@ -379,9 +379,9 @@ gdk_paintable_get_intrinsic_aspect_ratio (GdkPaintable *paintable)
* gdk_paintable_invalidate_contents:
* @paintable: a #GdkPaintable
*
* Called by implementations of #GdkPaintable to invalidate their contents.
* Called by implementations of #GdkPaintable to invalidate their contents.
* Unless the contents are invalidated, implementations must guarantee that
* multiple calls to GdkPaintable::snapshot produce the same output.
* multiple calls of gdk_paintable_snapshot() produce the same output.
*
* This function will emit the #GdkPaintable::invalidate-contents signal.
*
@@ -401,9 +401,9 @@ gdk_paintable_invalidate_contents (GdkPaintable *paintable)
* gdk_paintable_invalidate_size:
* @paintable: a #GdkPaintable
*
* Called by implementations of #GdkPaintable to invalidate their size.
* As long as the size is not invalidated, @paintable must return the same values
* for its width, height and intrinsic height.
* Called by implementations of #GdkPaintable to invalidate their size.
* As long as the size is not invalidated, @paintable must return the same
* values for its intrinsic width, height and aspect ratio.
*
* This function will emit the #GdkPaintable::invalidate-size signal.
*
@@ -435,7 +435,7 @@ gdk_paintable_invalidate_size (GdkPaintable *paintable)
* @concrete_height: (out): will be set to the concrete height
* computed.
*
* Applies the sizing algorithm outlined in
* Applies the sizing algorithm outlined in
* https://drafts.csswg.org/css-images-3/#default-sizing
* to the given @paintable. See that link for more details.
*

View File

@@ -27,9 +27,13 @@
* SECTION:gdkpopup
* @Short_description: Interface for popup surfaces
* @Title: Popups
* @See_also: #GdkToplevel, #GdkSurface
*
* A #GdkPopup is a surface that is attached to another surface,
* and is positioned relative to it.
* called its #GdkPopup:parent, and is positioned relative to it.
*
* #GdkPopups are typically used to implement menus and similar popups.
* They can be modal, which is indicated by the #GdkPopup:autohide property.
*/
G_DEFINE_INTERFACE (GdkPopup, gdk_popup, GDK_TYPE_SURFACE)

View File

@@ -30,21 +30,23 @@
/**
* SECTION:regions
* @Short_description: Simple graphical data types
* @Title: Points and Rectangles
* @Short_description: Simple graphical data type
* @Title: GdkRectangle
*
* GDK provides the #GdkPoint and #GdkRectangle data types for representing pixels
* and sets of pixels on the screen. Together with Cairos #cairo_region_t data
* type, they make up the central types for representing graphical data.
*
* A #GdkPoint represents an x and y coordinate of a point.
* GDK provides a #GdkRectangle data type for representing rectangles.
* Together with Cairos #cairo_region_t data type, these are the central
* types for representing sets of pixels.
*
* A #GdkRectangle represents the position and size of a rectangle.
* The intersection of two rectangles can be computed with
* gdk_rectangle_intersect(). To find the union of two rectangles use
* gdk_rectangle_union().
*
* #cairo_region_t is usually used for managing clipping of graphical operations.
* #cairo_region_t is usually used for managing clipping of graphical
* operations.
*
* The graphene library has a number of other data types for regions and
* volumes in 2D and 3D.
*/

View File

@@ -32,10 +32,10 @@
/**
* SECTION:rgba_colors
* @Title: GdkRGBA
* @Short_description: RGBA colors
* @Title: RGBA Colors
*
* #GdkRGBA is a convenient way to pass rgba colors around.
* #GdkRGBA is a convenient way to pass colors around.
* Its based on cairos way to deal with colors and mirrors its behavior.
* All values are in the range from 0.0 to 1.0 inclusive. So the color
* (0.0, 0.0, 0.0, 0.0) represents transparent black and

View File

@@ -55,10 +55,17 @@
* SECTION:gdksurface
* @Short_description: Onscreen display areas in the target window system
* @Title: Surfaces
* @See_also: #GdkToplevel, #GdkPopup
*
* A #GdkSurface is a (usually) rectangular region on the screen.
* Its a low-level object, used to implement high-level objects such as
* #GtkWindow on the GTK level.
* Its a low-level object, used to implement high-level objects
* such as #GtkWindow or #GtkDialog in GTK.
*
* The surfaces you see in practice are either #GdkToplevel or
* #GdkPopup, and those interfaces provide much of the required
* API to interact with these surfaces. Other, more specialized
* surface types exist, but you will rarely interact with them
* directly.
*/
/**
@@ -1401,13 +1408,9 @@ impl_surface_add_update_area (GdkSurface *impl_surface,
void
gdk_surface_queue_render (GdkSurface *surface)
{
cairo_region_t *region;
g_return_if_fail (GDK_IS_SURFACE (surface));
region = cairo_region_create ();
impl_surface_add_update_area (surface, region);
cairo_region_destroy (region);
gdk_surface_invalidate_rect (surface, NULL);
}
/*
@@ -1488,7 +1491,9 @@ gdk_surface_freeze_updates (GdkSurface *surface)
surface->update_freeze_count++;
if (surface->update_freeze_count == 1)
{
_gdk_frame_clock_uninhibit_freeze (surface->frame_clock);
}
}
/*
@@ -2051,6 +2056,9 @@ update_cursor (GdkDisplay *display,
GdkDeviceGrabInfo *grab;
GdkCursor *cursor;
g_assert (display);
g_assert (device);
pointer_info = _gdk_display_get_pointer_info (display, device);
pointer_surface = pointer_info->surface_under_pointer;

View File

@@ -202,7 +202,7 @@ gdk_texture_class_init (GdkTextureClass *klass)
/**
* GdkTexture:width:
*
* The width of the texture.
* The width of the texture, in pixels.
*/
properties[PROP_WIDTH] =
g_param_spec_int ("width",
@@ -219,7 +219,7 @@ gdk_texture_class_init (GdkTextureClass *klass)
/**
* GdkTexture:height:
*
* The height of the texture.
* The height of the texture, in pixels.
*/
properties[PROP_HEIGHT] =
g_param_spec_int ("height",
@@ -281,7 +281,7 @@ gdk_texture_new_for_surface (cairo_surface_t *surface)
* gdk_texture_new_for_pixbuf:
* @pixbuf: a #GdkPixbuf
*
* Creates a new texture object representing the GdkPixbuf.
* Creates a new texture object representing the #GdkPixbuf.
*
* Returns: a new #GdkTexture
*/
@@ -316,7 +316,9 @@ gdk_texture_new_for_pixbuf (GdkPixbuf *pixbuf)
* @resource_path: the path of the resource file
*
* Creates a new texture by loading an image from a resource.
* The file format is detected automatically.
* The file format is detected automatically, and can be any
* format that is supported by the gdk-pixbuf library, such as
* JPEG or PNG.
*
* It is a fatal error if @resource_path does not specify a valid
* image resource and the program will abort if that happens.
@@ -349,8 +351,12 @@ gdk_texture_new_from_resource (const char *resource_path)
* @file: #GFile to load
* @error: Return location for an error
*
* Creates a new texture by loading an image from a file. The file format is
* detected automatically. If %NULL is returned, then @error will be set.
* Creates a new texture by loading an image from a file.
* The file format is detected automatically, and can be any
* format that is supported by the gdk-pixbuf library, such as
* JPEG or PNG.
*
* If %NULL is returned, then @error will be set.
*
* Return value: A newly-created #GdkTexture or %NULL if an error occurred.
**/
@@ -384,7 +390,7 @@ gdk_texture_new_from_file (GFile *file,
* gdk_texture_get_width:
* @texture: a #GdkTexture
*
* Returns the width of @texture.
* Returns the width of @texture, in pixels.
*
* Returns: the width of the #GdkTexture
*/
@@ -400,7 +406,7 @@ gdk_texture_get_width (GdkTexture *texture)
* gdk_texture_get_height:
* @texture: a #GdkTexture
*
* Returns the height of the @texture.
* Returns the height of the @texture, in pixels.
*
* Returns: the height of the #GdkTexture
*/
@@ -573,4 +579,3 @@ gdk_texture_save_to_png (GdkTexture *texture,
return result;
}

View File

@@ -30,8 +30,14 @@
* SECTION:gdktoplevel
* @Short_description: Interface for toplevel surfaces
* @Title: Toplevels
* @See_also: #GdkSurface, #GdkPopup
*
* A #GdkToplevel is a freestanding toplevel surface.
*
* The #GdkToplevel interface provides useful APIs for
* interacting with the windowing system, such as controlling
* maximization and size of the surface, setting icons and
* transient parents for dialogs.
*/
G_DEFINE_INTERFACE (GdkToplevel, gdk_toplevel, GDK_TYPE_SURFACE)

View File

@@ -53,20 +53,6 @@ G_BEGIN_DECLS
*/
#define GDK_CURRENT_TIME 0L
/**
* GdkPoint:
* @x: the x coordinate of the point
* @y: the y coordinate of the point
*
* Defines the x and y coordinates of a point.
*/
struct _GdkPoint
{
int x;
int y;
};
typedef struct _GdkPoint GdkPoint;
/**
* GdkRectangle:
* @x: the x coordinate of the top left corner

View File

@@ -57,12 +57,6 @@
return self;
}
-(void)setNeedsDisplay:(BOOL)needsDisplay
{
for (id child in [self subviews])
[child setNeedsDisplay:needsDisplay];
}
-(void)setOpaqueRegion:(cairo_region_t *)region
{
/* Do nothing */

View File

@@ -32,6 +32,12 @@
@implementation GdkMacosCairoSubview
-(void)dealloc
{
g_clear_pointer (&self->clip, cairo_region_destroy);
[super dealloc];
}
-(BOOL)isOpaque
{
return _isOpaque;
@@ -95,6 +101,21 @@
cr = cairo_create (dest);
cairo_translate (cr, -abs_bounds.origin.x, -abs_bounds.origin.y);
/* Apply the clip if provided one */
if (self->clip != NULL)
{
cairo_rectangle_int_t area;
n_rects = cairo_region_num_rectangles (self->clip);
for (guint i = 0; i < n_rects; i++)
{
cairo_region_get_rectangle (self->clip, i, &area);
cairo_rectangle (cr, area.x, area.y, area.width, area.height);
}
cairo_clip (cr);
}
/* Clip the cairo context based on the rectangles to be drawn
* within the bounding box :rect.
*/
@@ -168,4 +189,14 @@
self->_isOpaque = opaque;
}
-(void)setClip:(cairo_region_t*)region
{
if (region != self->clip)
{
g_clear_pointer (&self->clip, cairo_region_destroy);
if (region != NULL)
self->clip = cairo_region_reference (region);
}
}
@end

View File

@@ -26,10 +26,12 @@
{
BOOL _isOpaque;
cairo_surface_t *cairoSurface;
cairo_region_t *clip;
}
-(void)setOpaque:(BOOL)opaque;
-(void)setCairoSurface:(cairo_surface_t *)cairoSurface
withDamage:(cairo_region_t *)region;
-(void)setClip:(cairo_region_t*)region;
@end

View File

@@ -53,6 +53,12 @@
return YES;
}
-(void)setNeedsDisplay:(BOOL)needsDisplay
{
for (id child in [self subviews])
[child setNeedsDisplay:needsDisplay];
}
-(void)setCairoSurface:(cairo_surface_t *)cairoSurface
withDamage:(cairo_region_t *)cairoRegion
{
@@ -72,6 +78,7 @@
-(void)setOpaqueRegion:(cairo_region_t *)region
{
cairo_region_t *transparent_clip;
NSRect abs_bounds;
guint n_rects;
@@ -81,6 +88,17 @@
abs_bounds = [self convertRect:[self bounds] toView:nil];
n_rects = cairo_region_num_rectangles (region);
/* First, we create a clip region for the transparent region to use so that
* we dont end up exposing too much other than the corners on CSD.
*/
transparent_clip = cairo_region_create_rectangle (&(cairo_rectangle_int_t) {
abs_bounds.origin.x, abs_bounds.origin.y,
abs_bounds.size.width, abs_bounds.size.height
});
cairo_region_subtract (transparent_clip, region);
[(GdkMacosCairoSubview *)self->transparent setClip:transparent_clip];
cairo_region_destroy (transparent_clip);
/* The common case (at least for opaque windows and CSD) is that we will
* have either one or two opaque rectangles. If we detect that the same
* number of them are available as the previous, we can just resize the

View File

@@ -1,157 +0,0 @@
/* GdkMacosGLLayer.c
*
* Copyright © 2020 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/>.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* Based on Chromium image_transport_surface_calayer_mac.mm
* See the BSD-style license above.
*/
#include "config.h"
#include <OpenGL/gl.h>
#import "GdkMacosGLLayer.h"
@implementation GdkMacosGLLayer
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-(id)initWithContext:(NSOpenGLContext *)shared
{
[super init];
_shared = [shared retain];
return self;
}
-(void)dealloc
{
[_shared release];
_shared = nil;
[super dealloc];
}
-(void)setContentsRect:(NSRect)bounds
{
_pixelSize = bounds.size;
[super setContentsRect:bounds];
}
-(CGLPixelFormatObj)copyCGLPixelFormatForDisplayMask:(uint32_t)mask
{
return CGLRetainPixelFormat ([[_shared pixelFormat] CGLPixelFormatObj]);
}
-(CGLContextObj)copyCGLContextForPixelFormat:(CGLPixelFormatObj)pixelFormat
{
CGLContextObj context = NULL;
CGLCreateContext (pixelFormat, [_shared CGLContextObj], &context);
return context;
}
-(BOOL)canDrawInCGLContext:(CGLContextObj)glContext
pixelFormat:(CGLPixelFormatObj)pixelFormat
forLayerTime:(CFTimeInterval)timeInterval
displayTime:(const CVTimeStamp*)timeStamp
{
return YES;
}
-(void)drawInCGLContext:(CGLContextObj)glContext
pixelFormat:(CGLPixelFormatObj)pixelFormat
forLayerTime:(CFTimeInterval)timeInterval
displayTime:(const CVTimeStamp*)timeStamp
{
if (_texture == 0)
return;
glClearColor (1, 0, 1, 1);
glClear (GL_COLOR_BUFFER_BIT);
GLint viewport[4] = {0, 0, 0, 0};
glGetIntegerv (GL_VIEWPORT, viewport);
NSSize viewportSize = NSMakeSize (viewport[2], viewport[3]);
/* Set the coordinate system to be one-to-one with pixels. */
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glOrtho (0, viewportSize.width, 0, viewportSize.height, -1, 1);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
/* Draw a fullscreen quad. */
glColor4f (1, 1, 1, 1);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, _texture);
glBegin (GL_QUADS);
{
glTexCoord2f (0, 0);
glVertex2f (0, 0);
glTexCoord2f (0, _pixelSize.height);
glVertex2f (0, _pixelSize.height);
glTexCoord2f (_pixelSize.width, _pixelSize.height);
glVertex2f (_pixelSize.width, _pixelSize.height);
glTexCoord2f (_pixelSize.width, 0);
glVertex2f (_pixelSize.width, 0);
}
glEnd ();
glBindTexture (0, _texture);
glDisable (GL_TEXTURE_RECTANGLE_ARB);
[super drawInCGLContext:glContext
pixelFormat:pixelFormat
forLayerTime:timeInterval
displayTime:timeStamp];
}
-(void)setTexture:(GLuint)texture
{
_texture = texture;
[self setNeedsDisplay];
}
G_GNUC_END_IGNORE_DEPRECATIONS
@end

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