Compare commits

...

978 Commits

Author SHA1 Message Date
Matthias Clasen
e00d393b6a vulkan: implement subpixel positioning
Pass the glyph position into the glyph caching functions,
not just the glyph index. This allows us to cache different
images for different subpixel positions.
2018-07-28 22:34:05 -04:00
Matthias Clasen
4a87115763 gl: implement subpixel positioning
Pass the glyph position into the glyph caching functions,
not just the glyph index. This allows us to cache different
images for different subpixel positions.
2018-07-28 21:34:37 -04:00
Matthias Clasen
273d60fefa Turn off metrics hinting
This will be necessary to see the effects of subpixel positioning.
2018-07-28 21:34:37 -04:00
Matthias Clasen
e781f986f7 Sync with improvements in the gtk3 version
Add a grid which shows subpixel phases.
2018-07-28 11:34:28 -04:00
Matthias Clasen
40b90a16ab Add a font rendering demo
This renders a magnified version of the text,
to make the effect of various font rendering options
more visible.
2018-07-27 18:42:22 -04:00
Matthias Clasen
f3f32b47cc Merge branch 'wip/gtk-menu-popup-no-more' into 'master'
Remove legacy GtkMenu popup APIs

See merge request GNOME/gtk!270
2018-07-27 18:57:24 +00:00
Matthias Clasen
2c5f2a2bcb Merge branch 'color-picker' into 'master'
Color picker

See merge request GNOME/gtk!273
2018-07-27 18:35:05 +00:00
Matthias Clasen
b6d990af25 tests: Update a11y tests
Some things changed.
2018-07-27 14:23:20 -04:00
Matthias Clasen
16171a232a Add a color picker implementation for gnome-shell
This adds a GtkColorPicker implementation that talks
to gnome-shell to get a color.
2018-07-27 14:23:20 -04:00
Matthias Clasen
031b5cad46 Add a color picker implementation for portals
This adds a GtkColorPicker implementation that talks
to the screnshot portal to get a color.
2018-07-27 14:23:20 -04:00
Matthias Clasen
984274497d color editor: Add a color picker button
The button is shown if we have a GtkColorPicker implemenation.
Currently, there are none, so the button is never shown.
2018-07-27 14:23:20 -04:00
Matthias Clasen
0cc0714312 Add a color picker interface
This will be used in the color chooser, in subsequent commits.
2018-07-27 14:23:19 -04:00
Matthias Clasen
766e2b1e63 testsuite: Update the list of used icons
We use some more now...
2018-07-27 13:37:00 -04:00
Matthias Clasen
c8be597b7f Bring back gtk-orientation icons
These are used in the page setup dialog, so we can't
just drop them.
2018-07-27 13:35:29 -04:00
Jonas Ådahl
4497ac7d75 menu: Remove legacy popup APIs
Remove gtk_menu_popup_for_device() and gtk_menu_popup(), as they cannot
be implemented in a portable manner by all backends. They have been
deprecated for proper alternative APIs for some time, so lets remove
them now before its too late.

While at it, fix the example documentation for mapping a menu.
2018-07-27 17:16:44 +02:00
Jonas Ådahl
af21583d4d tests: Stop using legacy gtk_menu_popup API
Use the new portable APIs, so that menus will be positioned properly on
all backends.
2018-07-27 17:16:44 +02:00
Matthias Clasen
d398c00d20 Fix up the resource generation for icons
The script was looking in the wrong subdirectories.
2018-07-27 09:08:27 -04:00
Matthias Clasen
cb247276f5 Add emoji category icons
This is a temporary measure to make the check-icon-names
test not fail in ci. We still have to figure out the best
way to include a core icontheme with GTK+.
2018-07-27 08:05:55 -04:00
Matthias Clasen
c6141dffd2 Keep picking up icons as resources
We may need to revisit this at some point. For now,
keep the mechanism in place.

This is a partial revert of 806c659efe.
2018-07-27 08:05:55 -04:00
Daniel Mustieles
755d8f8332 Updated Spanish translation 2018-07-27 13:40:20 +02:00
Matthias Clasen
32de29bb68 testsuite: Sort icon names
This is easier to keep track of.
2018-07-27 07:12:23 -04:00
Timm Bäder
540cb58169 Merge branch 'patch-1' into 'master'
doc: Fix there/their typo

See merge request GNOME/gtk!274
2018-07-27 04:47:04 +00:00
Alcaro
a1a6e6a36a doc: Fix there/their typo 2018-07-27 02:28:45 +00:00
Timm Bäder
798ad9f62a Merge branch 'g-clear-pointer-propagate' into 'master'
Remove GDestroyNotify casts in g_clear_pointer() uses

See merge request GNOME/gtk!269
2018-07-26 07:34:12 +00:00
Matthias Clasen
ad6255a841 Merge branch 'xfixes-timestamp' into 'master'
x11: Ignore old XFixesSelectionNotify events

Closes #14

See merge request GNOME/gtk!259
2018-07-25 11:21:01 +00:00
Ernestas Kulik
6adaf7c33d Remove GDestroyNotify casts in g_clear_pointer() uses
GLib master propagates argument types in g_clear_pointer(), which causes
the usual function pointer casts to GDestroyNotify to trip compiler
warnings. Additionally, this commit changes some cleanup functions where
appropriate (wl_data_source_destroy ->
gtk_primary_selection_source_destroy for struct
gtk_primary_selection_source).
2018-07-25 10:05:39 +03:00
Benjamin Otte
95a4eff6ba render: Make gtk_render_icon() use the snapshot API
This removes a lot of duplicated code.
2018-07-24 20:55:45 +02:00
Benjamin Otte
9675c99043 render: Make gtk_render_frame() and gtk_render_focus() use the snapshot API
This removes a lot of duplicated code.
2018-07-24 20:55:45 +02:00
Benjamin Otte
76d0e1e398 API: Remove gtk_render_frame_gap()
That function does not make sense at all in a CSS world. So better don't
support it anymore.
2018-07-24 20:55:45 +02:00
Benjamin Otte
14408b7485 render: Make gtk_render_background() use the snapshot API
This removes a lot of duplicated code.
2018-07-24 20:55:45 +02:00
Benjamin Otte
2a11baf6ea render: Make gtk_render_check/arrow/handle() use the snapshot API
This removes a lot of duplicated code.
2018-07-24 20:55:45 +02:00
Benjamin Otte
51d40ca023 render: Make gtk_render_layout() use the snapshot API
This removes a lot of duplicated code.
2018-07-24 20:55:45 +02:00
Benjamin Otte
5d9d73b090 testsuite: Fix DragContext => Drag renaming 2018-07-24 20:55:45 +02:00
Benjamin Otte
5f7e093168 gtk: Move GtkGesture declaration to gtktypes.h
That way, headers can use the gesture type without having to include
gtkgesture.h
2018-07-24 20:55:45 +02:00
Benjamin Otte
0f70e6d70a docs: Remove remains of Mir backend 2018-07-24 20:55:45 +02:00
Benjamin Otte
259be23ff2 broadway: Remove unused variable 2018-07-24 20:55:45 +02:00
Daniel Șerbănescu
337eedb513 Update Romanian translation 2018-07-24 18:09:59 +00:00
Nirbheek Chauhan
185354555c Merge branch 'nirbheek/misc-meson-fixes' into 'master'
Fix broadway backend build and graphene as a subproject

Closes #1197 and #1218

See merge request GNOME/gtk!265
2018-07-24 08:29:34 +00:00
Daniel Mustieles
29905d1ce6 Updated Spanish translation 2018-07-24 10:03:20 +02:00
Timm Bäder
73dd73c859 Merge branch 'just-popover-menu-things' into 'master'
Post-gizmo GtkPopoverMenu fixes

See merge request GNOME/gtk!264
2018-07-23 18:55:55 +00:00
Nirbheek Chauhan
cfb0df14cc meson: Update pango and gdk-pixbuf wrap locations
See: https://gitlab.gnome.org/GNOME/gtk/issues/1219
2018-07-23 20:17:04 +05:30
Nirbheek Chauhan
b343abfa51 meson: Support graphene as a fallback dependency
Don't assume graphene_dep is always a pkg-config dependency.

Closes https://gitlab.gnome.org/GNOME/gtk/issues/1197
2018-07-23 20:17:04 +05:30
Nirbheek Chauhan
5df4d27752 meson: libgdk-broadway.a depends on broadwayjs.h
Fixes https://gitlab.gnome.org/GNOME/gtk/issues/1218

Also fix another dependency error I found.
2018-07-23 20:15:44 +05:30
Daniel Mustieles
bbf5d142b3 Updated Spanish translation 2018-07-23 12:10:24 +02:00
Ernestas Kulik
1fbbaef49e testpopover: Don’t set margin in menu box
The gizmo already provides sufficient padding.
2018-07-23 13:05:57 +03:00
Ernestas Kulik
d88268c142 gtkpopovermenu: Conditionally chain up in gtk_popover_menu_add()
Otherwise the stack gets parented to the wrong widget and the contents
are never drawn.
2018-07-23 13:01:01 +03:00
Ernestas Kulik
49ae68c2c7 gtkpopovermenu: Drop call to gtk_widget_show()
The stack is already visible.
2018-07-23 13:00:11 +03:00
Matthias Clasen
1d72e3e193 Drop builtin icon test
We don't have these icons anymore.
2018-07-22 17:16:20 +00:00
Jason Crain
77c3ef48cf x11: Ignore old XFixesSelectionNotify events
GtkEntryCompletion can rapidly release and claim ownership of the
primary selection. This generates multiple XFixesSelectionNotify events,
first stating that no one owns the selection, then another stating that
we own the selection. The notification that no one owns the selection
causes GtkEntryCompletion to deselect the text, breaking inline
autocompletion.

This fixes it by ignoring any XFixesSelectionNotify with a timestamp
earlier than our clipboard timestamp.

Fixes #14
2018-07-21 15:22:04 -05:00
Bruce Cowan
20deda2bd6 Update British English translation 2018-07-21 11:08:03 +00:00
Benjamin Otte
447b166ed3 Merge branch 'wip/muktupavels/remove-gtk-css-provider-get-default' into 'master'
gtkcssprovider: remove gtk_css_provider_get_default

See merge request GNOME/gtk!256
2018-07-20 14:03:51 +00:00
Christoph Reiter
1b230324ba ci: add hicolor-icon-theme to the docker image
The tests complain about it, not sure if this helps.
2018-07-20 15:04:26 +02:00
Matthias Clasen
806c659efe Drop unused old icons
We don't need to ship the deprecated old stock-id named
icons and the drag cursors - we don't use them from resources
anyway.
2018-07-20 08:06:07 -04:00
Emin Tufan Çetin
51873ebe37 Update Turkish translation 2018-07-20 11:18:15 +00:00
Matthias Clasen
827219e214 Emoji chooser: Also check for hex boxes
We don't want to see those either.
2018-07-19 17:57:19 -04:00
Matthias Clasen
5c9b25c66e moji chooser: Try harder to avoid fallback
We don't want to see any fallback rendering.
The current check was still letting some fallback
combinations through.

Based on work by Julian Sparber.
2018-07-19 17:50:54 -04:00
Matthias Clasen
37e4ae2fbd Quiet a compiler warning
We don't need to handle GDK_CONFIGURE here, so make the
compiler not warn about it.
2018-07-19 17:48:06 -04:00
Matthias Clasen
14f86ae24d testsuite: Add emoji icon names
We check for all icon names that are used in gtk.
2018-07-19 17:48:06 -04:00
Matthias Clasen
849ffebc21 Emoji chooser: Use icons for sections
This is more reliable than using text-style Emoji
which may not be present.

Based on work by Julian Sparber.
2018-07-19 17:47:50 -04:00
Matthias Clasen
7dabc2a42c Merge branch 'master' into 'master'
widgetfactory: add separator tool item to presentation

See merge request GNOME/gtk!249
2018-07-19 18:06:25 +00:00
Matthias Clasen
bef8a3a0e9 Merge branch 'content-provider-autoptr' into 'master'
gdk: Add auto cleanup func for GdkContentProvider

See merge request GNOME/gtk!251
2018-07-19 18:04:24 +00:00
Matthias Clasen
31d2638088 Merge branch 'content-provider-docs' into 'master'
docs: Fix GdkContentProvider documentation

See merge request GNOME/gtk!254
2018-07-19 17:46:36 +00:00
Ernestas Kulik
40019517cf docs: Fix GdkContentProvider documentation
Currently it’s lacking properties, signals and class vfuncs.
2018-07-19 20:05:19 +03:00
Alberts Muktupāvels
7a8f5ca970 gtkcssprovider: remove gtk_css_provider_get_default
This function is unused since cdc6e82720 commit and does not
contain fallback style.

https://gitlab.gnome.org/GNOME/gtk/issues/1226
2018-07-19 19:25:17 +03:00
Benjamin Otte
4063c3dc31 Merge branch 'content-deserializer-fixes' into 'master'
Content deserializer fixes

See merge request GNOME/gtk!252
2018-07-19 13:59:21 +00:00
Ernestas Kulik
96d0368290 gdk: contentdeserializer: Fix deserializer not returning
file_uri_deserializer does not return on success, only on failure. This
commit fixes clipboard reads never finishing for some types.
2018-07-19 15:55:58 +03:00
Ernestas Kulik
9a0ec5b1e0 gdk: contentdeserializer: Fix stream usage
file_uri_deserializer splices a memory stream, as opposed to
string_deserializer, which uses a converter and filter stream. This
commit fixes erroneous use of GMemoryOutputStream as
GFilterOutputStream.
2018-07-19 15:53:08 +03:00
Ernestas Kulik
7b5a0a829a gdk: Add auto cleanup func for GdkContentProvider 2018-07-19 11:28:21 +03:00
Matthias Clasen
1030d9e5b1 docs: Small updates to the migration guide
Mention that event controllers are available in 3.x, amongst others.
2018-07-18 20:22:18 -04:00
Matthias Clasen
0750b4fd28 Merge branch 'places-sidebar-dnd' into 'master'
placessidebar: Take a GdkDrag in _set_drop_targets_visible()

Closes #1220

See merge request GNOME/gtk!247
2018-07-18 00:23:08 +00:00
Günther Wutz
1d4ce5a544 widgetfactory: add separator tool item to presentation 2018-07-17 21:50:19 +02:00
Ernestas Kulik
4b2d63167e placessidebar: Take a GdkDrag in _set_drop_targets_visible()
Since the function is usually called from GtkWidget::drag-{begin,end} handlers,
taking a GdkDrop does not work, especially given that
::drag-action-requested is emitted without checking the type.

Fixes https://gitlab.gnome.org/GNOME/gtk/issues/1220
2018-07-17 19:19:14 +03:00
Timm Bäder
6fe0a8c6b3 gesturestylus: Clarify a documentation comment
Use the proper gtkdoc syntax for signals.
2018-07-17 17:33:47 +02:00
Timm Bäder
04eb7eef29 Remove icon extents API 2018-07-17 17:33:47 +02:00
Timm Bäder
480a2c2770 widget: Remove another ->priv usage 2018-07-17 17:33:47 +02:00
Timm Bäder
f699fff6e0 sizerequest: Pull locals into closest scope 2018-07-17 17:33:47 +02:00
Timm Bäder
4bc145549d Correctly mark an enum value in a doc comment 2018-07-17 17:33:47 +02:00
Timm Bäder
cf7fa931d3 sizerequest: Only check reported baselines if requested
If the passed-in store locations for the baselines are NULL anyway, we
don't need to check the reported baselines for correctness.
2018-07-17 17:33:47 +02:00
Timm Bäder
392b4d9ac5 gl renderer: Pull a few declarations into the closest scope 2018-07-17 17:33:47 +02:00
Timm Bäder
3f126c7fc8 Remove GTK_CSS_AFFECTS_CLIP
Clips don't exist anymore and this flag is unused outside of the style
property definitions in gtkcssstylepropertyimpl.c
2018-07-17 17:33:47 +02:00
Timm Bäder
960717b273 window: Don't queue an allocate if the css clip changes
clips don't exist anymore.
2018-07-17 17:33:47 +02:00
Timm Bäder
5386cf89f2 GskRoundedRect: Typo 2018-07-17 17:33:47 +02:00
Timm Bäder
b7d948af69 gl renderer: Use a GArray for the shadow cache
It's very small usually, in default Adwaita the only blurred outset
shadow we have is the one for the CSD'd toplevel window.
2018-07-17 17:33:46 +02:00
Timm Bäder
446b2e25d3 Avoid a g_object_get path
We can use gdk_device_get_n_axes instead and will get the same result.
2018-07-17 17:33:46 +02:00
Timm Bäder
17b1e7bae9 docs: Fix scroll and motion controller titles
Controller, not Controler.
2018-07-17 17:33:46 +02:00
Emmanuele Bassi
9dc679370c Merge branch 'legacy-gl' into 'master'
fix the OpenGL renderer for legacy contexts

See merge request GNOME/gtk!240
2018-07-17 11:07:27 +00:00
Piotr Drąg
033cf4bfb7 Update POTFILES.in 2018-07-16 16:35:52 +02:00
Matthias Clasen
bf5f27c6d5 Handle configure events in gdk
The previous attempt at removing configure events entirely
was causing some dialogs not to show up under Wayland.
Presumably due to ordering issues with emitting ::size-change
out of the backend.

Instead, keep configure events in the event queue, but handle
them on the gdk side. This keeps the ordering intact, while
still removing configure events from the api. The dialogs
show up now.
2018-07-15 20:23:45 -04:00
Matthias Clasen
7a1073c3ae Revert "gdk: Drop configure events"
This reverts commit a8926c9d87.
2018-07-15 20:23:45 -04:00
Matthias Clasen
e2fd33f78a Revert "broadway: Stop using configure events"
This reverts commit 9c827cbff4.
2018-07-15 20:23:45 -04:00
Matthias Clasen
89f25d1484 Merge branch 'dnd-cleanups' into 'master'
Dnd cleanups

See merge request GNOME/gtk!243
2018-07-15 22:18:11 +00:00
Matthias Clasen
3c8b3cbf41 win32: Stop accessing GdkDrag members 2018-07-15 16:58:22 -04:00
Matthias Clasen
410d4bca83 wayland: Set actions on drag
We should pass the actions to the newly created
drag in drag_begin.
2018-07-15 16:52:16 -04:00
Matthias Clasen
168523264c x11: Set actions on drag
We should pass the actions to the newly created
drag object in drag_begin.
2018-07-15 16:50:06 -04:00
Matthias Clasen
435f143e2e x11: Rename a file
Keep in line with the parent class.
2018-07-15 16:47:17 -04:00
Matthias Clasen
98ccb67277 drop: stop accessing GdkDrag fields 2018-07-15 16:43:28 -04:00
Matthias Clasen
2d83bb1b91 x11: Stop using GdkDrag fields 2018-07-15 16:43:28 -04:00
Matthias Clasen
298b6ee81a wayland: Stop accessing GdkDrag members 2018-07-15 16:43:28 -04:00
Matthias Clasen
5ce3520a2a Add a GdkDrag::surface property 2018-07-15 16:43:28 -04:00
Matthias Clasen
9cc3e2c8ef gdkdrag: remove an unused member
The drag surface is stored in the subclasses and obtained
by via the get_drag_surface vfunc.
2018-07-15 16:42:07 -04:00
Matthias Clasen
034f89b17f wayland: Drop an unused api
Nothing was calling gdk_wayland_drag_set_source_surface.
2018-07-15 16:42:07 -04:00
Matthias Clasen
1ea09a327a Add a private struct to GdkDrag
This will force subclasses to use proper api.
2018-07-15 16:42:00 -04:00
Matthias Clasen
bc2f484ae9 Revert "GdkDrop: drop the priv struct"
This reverts commit d927c3bee0.

I was wrong. Better to hide the struct fields from subclasses.
2018-07-15 15:58:05 -04:00
Matthias Clasen
228f813c43 dnd: Drop gdk_drag_drop
This is an inconsistently used private api, and just adds
a vfunc indirection for no other benefit.
2018-07-15 15:58:05 -04:00
Matthias Clasen
17386b5cf7 Merge branch 'wip/matthiasc/kill-non-input-events' into 'master'
Wip/matthiasc/kill non input events

See merge request GNOME/gtk!242
2018-07-15 19:50:37 +00:00
Matthias Clasen
288086b899 Fix up some doc mishaps
When GdkWindow was renamed to GdkSurface, 'window managers'
turned into 'surface managers'. Thats not cool.
2018-07-15 15:36:19 -04:00
Matthias Clasen
d148f26658 Drop gdk_surface_withdraw
'withdrawn' is an X11-centric concept, and the function
can just as well be replaced by gdk_surface_hide.
2018-07-15 15:29:58 -04:00
Matthias Clasen
7ca6440f4d gdk: Drop map events
We are really inconsistent about generating these,
and they are not actually used in GTK+. Instead,
add a boolean GdkSurface::mapped property.
2018-07-15 15:10:56 -04:00
Matthias Clasen
1172810768 win32: Stop using expose and configure events
These no longer exist.
2018-07-15 14:07:40 -04:00
Matthias Clasen
9c827cbff4 broadway: Stop using configure events
These no longer exist.
2018-07-15 14:01:59 -04:00
Matthias Clasen
da3aaf39b9 gdk: Drop expose events
Replace expose events with a GdkSurface::expose signal.
This is part of the move to use events only for input.
2018-07-15 13:13:07 -04:00
Matthias Clasen
a8926c9d87 gdk: Drop configure events
Replace configure events with a GdkSurface::size-changed signal.
This is part of the move to use events only for input.
2018-07-15 11:51:09 -04:00
Matthias Clasen
443f8ddf6b popover: Drop some dead code
This will be done differently, using xdg-popup instead
of subsurfaces, so no point in keeping this.
2018-07-15 08:18:08 -04:00
Matthias Clasen
6a7de806dd text display: correct a comment 2018-07-14 13:50:14 -04:00
Elias Aebi
19873e549a gl: implement clipping for legacy contexts 2018-07-14 14:31:50 +02:00
Elias Aebi
05ca6bc189 gl: fix compilation errors for legacy context shaders 2018-07-14 14:24:21 +02:00
Benjamin Otte
cbb1e74bb5 textview: Only create cairo context in gtktextdisplay.c
Everything else is done using GtkSnapshot now, including renaming the
draw_layer vfunc to snapshot_layer.
2018-07-14 05:27:54 +02:00
Benjamin Otte
6afb6bb9d2 x11: Set BackPixmap = None unconditionally
Makes it more obvious what we actually want.

Related: #1134
2018-07-14 05:27:54 +02:00
Piotr Drąg
60afd056e0 Update POTFILES.in 2018-07-13 15:11:45 +02:00
Benjamin Otte
4456b06853 window: Update opaque region if background-color changes
The opaque region is only set when the background color is opaque. So
we need to do something about it when the background color changes.

However, in the case where a size allocation is going to happen, we
already do this update in size_allocate(), so in that case avoid doing
it twice.
2018-07-13 14:56:04 +02:00
Benjamin Otte
2f72353e0e gtk-demo: Update aspect-ratio when selecting new puzzle 2018-07-13 14:56:04 +02:00
Benjamin Otte
88af7b44aa textview: Use snapshot on the sidebars 2018-07-13 14:56:04 +02:00
Benjamin Otte
a7cd1918a8 widgetpaintable: Add a hack to make recursion not infloop
Makes the GUADEC talk not crash that I'm supposed to give in 20 minutes.
2018-07-13 14:56:04 +02:00
Benjamin Otte
bcfd1bbd24 widgetpaintable: Redo implementation
Instead of instantly invalidating, we now cache the old render node and
do the update in an idle handler.
While that gives us a 1 frame delay, it avoids all the tricky things
like queueing resizes while resizing or queueing draws while drawing.

The only remaining issue (and a *big* one at that) is that a nested
widget paintable will now cause the widget to snapshot its previous
render node when creating a new one. And that one will snapshot its
previous render node, and that one will...
And nothing so far breaks this recursion.
2018-07-13 14:56:04 +02:00
Benjamin Otte
1a5e60be7c paintable: Fix return_if_fail() statements
I always switch them up...
2018-07-13 14:56:04 +02:00
Benjamin Otte
3ce3867403 gl: Don't accidentally use ints for float variables
The int was floor()ing the x/y coordinates of glyphs, which could cause
significant repositioning of glyphs when text was scaled via the MVP.
2018-07-13 14:56:04 +02:00
Matthias Clasen
00a61f92b6 docs: Small updates
Remove a few references to no-longer-existing APIs.
2018-07-13 10:13:00 +02:00
Matthias Clasen
986daa8225 Merge branch 'dnd-cleanups' into 'master'
Dnd cleanups

See merge request GNOME/gtk!228
2018-07-13 07:45:57 +00:00
Matthias Clasen
e72ca43a32 Merge branch 'fix-wayland' into 'master'
GtkIMContextSimple: Fix Wayland build when X11 support is disabled

See merge request GNOME/gtk!234
2018-07-12 12:18:59 +00:00
Matthias Clasen
f432c937cc dnd: Drop gdk_drag_abort
This function is never called, so drop it, its vfunc,
and all the backend implementations.
2018-07-12 13:57:45 +02:00
Matthias Clasen
1dd15b5237 dnd: Some documentation updates
Don't mention dnd protocols, and do mention the new,
split objects.
2018-07-12 13:57:45 +02:00
Matthias Clasen
5cdbbc6e61 win32: Build fixes 2018-07-12 13:02:42 +02:00
Matthias Clasen
0e2ac0ebf2 wayland: Rename a source file
Rename gdkdnd-wayland.c to gdkdrag-wayland.c to go along
with gdkdrop-wayland.c.
2018-07-12 13:02:42 +02:00
Matthias Clasen
c73cb2c154 wayland: Drop an unused field
Nothing was using the foreign_dnd_surface anymore, so no
need to create it in the first place.
2018-07-12 13:02:42 +02:00
Matthias Clasen
a756caa106 dnd: Drop suggested_action
The only user of this field was the x11 backend, and it
turns out that it does not need to store the value at all.
2018-07-12 13:02:42 +02:00
Matthias Clasen
da22ba3b86 drag: Split a setter
In preparation for moving the suggested action
to the x11 backend, split the setter off.
2018-07-12 13:02:42 +02:00
Matthias Clasen
7a0a92f2b6 win32: Stop using gdk_drag_get_suggested_action
The suggested action is not set or used in the win32
information, so don't put it in logs either.
2018-07-12 13:02:42 +02:00
Matthias Clasen
d927c3bee0 GdkDrop: drop the priv struct
Its not needed.
2018-07-12 13:02:42 +02:00
Matthias Clasen
59c2efbcd6 Add a GdkDrag::actions property
To go along the GdkDrop::actions property.
2018-07-12 13:02:42 +02:00
Matthias Clasen
94af080fb6 Rename a property
Change GdkDrag::action to GdkDrag::selected-action, which is
more clearly different from actions, and follows the existing
name of the struct field and getter.
2018-07-12 13:02:42 +02:00
Matthias Clasen
40841ec3be GdkDrag: Drop the priv struct
We don't need it.
2018-07-12 13:02:42 +02:00
Matthias Clasen
f69bb2fb2b wayland: set a cursor when starting a drag
Otherwise, we wont have one.
2018-07-12 13:02:42 +02:00
Matthias Clasen
db0b9f61ae dnd: Add a GdkDrag::action property
This lets us drop the ::action-changed signal for the
property change notification. But, can just as well move
the signal class handers which just update the cursor
to the ::action setter. No need to do this in the backends.
2018-07-12 13:02:42 +02:00
Matthias Clasen
63ab523146 wayland: Remove an unused field
GdkDragWayland.suggested_action was entirely unused, so drop it.
2018-07-12 13:02:42 +02:00
Matthias Clasen
b94c3166bf dnd: Rename gtk_drag_begin_with_coordinates
Now that the coordiate-less variant is gone,
rename this back to the shorter gtk_drag_begin.
2018-07-12 13:02:42 +02:00
Daniel Boles
7030e08f9c Merge branch 'master' into 'master'
HighContrast: Restore expander size

Closes #1046

See merge request GNOME/gtk!167
2018-07-09 17:28:49 +00:00
Timm Bäder
2cc6a3ee5c widget factory: Use GtkPicture for background selection
Showing those background images as 16×16 icons doesn't look very nice.
2018-07-08 21:50:59 +02:00
Timm Bäder
3dd188fe7e gl renderer: Cache blurred outset shadow nodes
Since these are particularly expensive to render and we have a pretty
big one used in every client-side decorated window.
2018-07-08 21:50:59 +02:00
Timm Bäder
d41603d82a aboutdialog: Remove priv pointer 2018-07-08 21:50:59 +02:00
Timm Bäder
f7aff03c72 layout: Remove priv pointer 2018-07-08 21:50:59 +02:00
Timm Bäder
a0b8e32462 rendernodes: Fix unconditionally impossible diffs
Some of the _diff implementations did a whole bunch of work just to
throw it away afterwards and invalidate the entire union of the two
render nodes, most notably the two clip nodes. Fix this to only call
gsk_render_node_diff_impossible if the previous if-condition is FALSE
and not always.
2018-07-08 21:50:59 +02:00
Timm Bäder
50f76eb8cc GskRenderer: Add missing nullable annotation 2018-07-08 21:50:59 +02:00
Timm Bäder
9959ea98cd Revert "snapshot: merge container nodes"
This reverts commit 622a150bb4.
2018-07-08 21:50:59 +02:00
Emmanuel Gil Peyrot
8ca3ac1970 GtkIMContextSimple: Fix Wayland build when X11 support is disabled. 2018-07-08 20:11:01 +02:00
Balázs Meskó
27ba2411f0 Update Hungarian translation 2018-07-08 14:04:15 +00:00
Timm Bäder
a6920855ea Implement GtkInspectorLayoutOverlay
To properly replace the old "show layout borders" option.
2018-07-08 11:26:12 +02:00
Timm Bäder
c85e2401fa treeview: Fix column visibility check
This is still fallout from the bin_window removal. We aren't moving the
GdkWindow/GdkSurface anymore so we have to account for the scrolling
ourselves.
2018-07-08 10:32:12 +02:00
Timm Bäder
6fdcafc94a treeview: Move column header widgets when scrolling
Since those are widgets and widgets need to be size-allocate'd properly,
we need to queue an allocate, as well as actually add the hadjustment's
value to the column x position.

Fixes #1202
2018-07-08 10:04:27 +02:00
Timm Bäder
9bab218314 aspectframe: Remove priv pointer 2018-07-08 10:02:43 +02:00
Timm Bäder
2854635850 scalebutton: Remove priv pointer 2018-07-08 09:41:15 +02:00
Timm Bäder
a976aa9740 searchbar: Ignore key presses when unmapped
The purpose of a searchbar is to start a search on visible widgets when
a key is pressed. Starting a search on e.g. a stack page that is not
visible at all is not very useful.
2018-07-08 09:41:15 +02:00
Timm Bäder
074eb2a19d accellabel: Add newline between consecutive if statements 2018-07-08 09:41:15 +02:00
Timm Bäder
96812450fa listbox demo: Hide extra_buttons_box by default
It should only show up when hovering the row.
2018-07-08 09:41:15 +02:00
Timm Bäder
93c688cd93 range: Remove has_origin flag
It's equivalent to the highlight_widget being !NULL.
2018-07-08 09:41:15 +02:00
Timm Bäder
53afc4a9d9 dialog: Remove priv pointer 2018-07-08 09:41:15 +02:00
Timm Bäder
c96077590b dialog: Remove some GtkVBox references 2018-07-08 09:41:15 +02:00
Timm Bäder
6e47d0bf4a GtkSeparatorToolItem: Remove draw flag
We can as well query the current value of the flag using
gtk_style_context_has_class.
2018-07-08 09:41:15 +02:00
Timm Bäder
50b79ae0ab GtkSeparatorToolItem: Remove priv pointer 2018-07-08 09:41:15 +02:00
Timm Bäder
6b4709ea3c GtkApplication: Remove priv pointer 2018-07-08 09:41:15 +02:00
Timm Bäder
f3a83abb54 colorswatch: Remove priv pointer 2018-07-08 09:41:15 +02:00
Timm Bäder
33166b7357 render: Remove gtk_render_slider
The only thing it was doing is render background and frame, which you
get from using a widget for your slider anyway.
2018-07-08 09:41:15 +02:00
Timm Bäder
bb31ce1168 renderborder: Remove some unused API 2018-07-08 09:41:15 +02:00
Timm Bäder
dbf32933bf main: Don't look at first GTK_DISPLAY_DEBUG_CHECK parameter...
... if none of the debug displays have any debug flags set. This way, we
can ignore the first parameter to e.g. GTK_DISPLAY_NOTE, which is
usually a call to gtk_widget_get_display.

Before this patch, gtk_widget_get_display was the slowest part of
gtk_widget_query_size_for_orientation.
2018-07-08 09:41:15 +02:00
Timm Bäder
af8fe182c8 Fix a few documentation warnings 2018-07-08 09:41:15 +02:00
Timm Bäder
731f0d4d01 Merge branch 'gtk-picture-docs' into 'master'
docs: Add GtkPicture to types list

See merge request GNOME/gtk!233
2018-07-07 06:30:37 +00:00
Thomas Bechtold
e42373df89 docs: Add GtkPicture to types list
We want signals, arguments/parameters and position in the hierarchy to
be shown in the documentation for GtkPicture. So fix the types list.

See
https://developer.gnome.org/gtk-doc-manual/unstable/metafiles_types.html.en
2018-07-06 22:14:26 +02:00
Timm Bäder
da8050979e fixed: Remove child list
Use the child widget list from GtkWidget and attach x/y positions via a
qdata.
2018-07-05 19:08:19 +02:00
Timm Bäder
4dd1ff6dd2 GtkLayout: Remove freeze_count member
Unused.
2018-07-05 19:08:19 +02:00
Timm Bäder
8c403c43f0 spinbutton: Keep GParamSpecs around
notify_by_pspec is more efficient and this way the source file is more
in line with the others.
2018-07-05 19:08:19 +02:00
Emmanuele Bassi
2feb5c93ca ci: Update the image for the Flatpak jobs
The gnome-nightly-oci registry was moved to gitlab.gnome.org, so we
need to change the image we use when building Flatpak bundles in our
CI pipeline.
2018-07-04 18:32:59 +01:00
Emmanuele Bassi
9924a92e70 Merge branch '1140-gtk_printer_get_hard_margins_for_paper_size-is-not-external' into 'master'
Resolve "gtk_printer_get_hard_margins_for_paper_size() is not external"

Closes #1140

See merge request GNOME/gtk!229
2018-07-04 16:55:34 +00:00
Kjell Ahlstedt
6c8988e445 gtkprinter: Make gtk_printer_get_hard_margins_for_paper_size() public
The declaration in gtkprinter.h shall be preceded by GDK_AVAILABLE_IN_ALL,
or else the function can't be used in application programs.

Closes #1140
2018-07-04 18:40:33 +02:00
Benjamin Otte
9fb3b84253 rendernode: Make offset nodes use floats
It's OpenGL stuff, use floats.
2018-07-04 15:05:37 +02:00
Benjamin Otte
3439862634 gtkmediafile: Don't leak all the images
We were leaking the GBytes for the image memory, which is a
noticeable memleak to anyone who's casually running a memory monitor.

Go KDE users!

Closes #1200
2018-07-04 15:05:02 +02:00
Benjamin Otte
93c5455796 iconhelper: Plug memleak 2018-07-04 15:04:04 +02:00
Benjamin Otte
e665667bff mediafile: Check if media files are open when trying to play
If no file is open, refuse to play.
2018-07-04 06:15:33 +02:00
Benjamin Otte
3ca59b8701 css: Don't do indirections
We don't need to look up the property by name to query its ID when we
know the ID already because it's inside an enum.
2018-07-04 06:15:33 +02:00
Benjamin Otte
fba0b359d4 css: Report sizes as absolute
All PangoFontDescriptions that GTK creates now use
pango_font_description_set_absolute_size().
2018-07-04 06:15:33 +02:00
Benjamin Otte
e1b6496af7 image: size request is always CONSTANT_SIZE
It's always -gtk-icon-size in both directions, even for paintables.
There's no width-for-height happening.
2018-07-04 06:15:33 +02:00
Daniel Boles
14620423e8 themes: Restore default progressbar min sizes
The min size on the oriented axis used to come from style props with
default values in the source file, used if the theme did not provide a
min size in CSS. When the style props were removed, so was any notion of
a minimal size for proressbars' main axis, meaning that now progressbars
without expand or any other source of min size were just tiny specks.

The right place to do that was always the theme, so in our themes now,
fix that by copying the old default values for the style properties; see:

https://gitlab.gnome.org/GNOME/gtk/issues/1191#note_259393
https://gitlab.gnome.org/GNOME/gtk/blob/gtk-3-24/gtk/gtkprogressbar.c#L92

The result should be the same in that (A) the min size is now what it is
in GTK+ 3 & (B) an app/user can override the theme exactly the same way.

Close https://gitlab.gnome.org/GNOME/gtk/issues/1192
2018-07-03 18:55:31 +01:00
Daniel Boles
55a1f8ccfd HC: merge dupe selectors; linebreaks for legibility 2018-07-03 18:55:17 +01:00
Timm Bäder
19afe454df Merge branch 'gdk4-dnd-docs' into 'master'
docs: Add new DnD types

See merge request GNOME/gtk!227
2018-07-03 17:28:44 +00:00
Piotr Drąg
7d842cb7fc Update POTFILES.in 2018-07-03 17:11:00 +02:00
Ernestas Kulik
3137d326c5 docs: Add new DnD types
7733f646d6 renamed GdkDragContext to
GdkDrag, which broke the docs, as a reference to
gdk_drag_context_get_type() still exists. This commit renames the type
accordingly and adds GdkDrop.
2018-07-03 12:32:41 +03:00
Matthias Clasen
12464731f1 Merge branch 'dnd-cleanups' into 'master'
Dnd cleanups

See merge request GNOME/gtk!226
2018-07-02 21:19:45 +00:00
Daniel Boles
269a9d8528 Adwaita: Drop some unneeded overrides
The pseudoclasses work fine on the subnodes without having to also apply
`parent:class subnode`.
2018-07-02 22:04:35 +01:00
Daniel Boles
c892d2767a Adwaita: Regenerate CSS for text handle overhaul
Commit b3e91b7111 forgot this.
2018-07-02 22:04:35 +01:00
Matthias Clasen
c8e082f296 win32: Adapt to dnd api changes
Follow the GdkDragContext -> GdkDrag change.
2018-07-02 22:52:59 +02:00
Daniel Boles
51981d562b ScrolledWindow: a couple of spelling/grammar fixes
(A) Put a space in "scrolled window" like the other doc comments
(B) Say "i.e." rather than "ie."
(C) Fix grammar from "makes [...] exactly reaches" to "exactly reach"
2018-07-02 20:14:41 +01:00
Daniel Boles
51b77a425a ScrolledWindow: Fix/improve doc of key bindings
Saying 'key + modifiers' is really weird, so reverse that, and explain
why there are 2 cited and what the difference between them is.
2018-07-02 20:14:41 +01:00
Daniel Boles
ae3163b5e0 ScrolledWindow: Add missing apostrophes 2018-07-02 20:14:41 +01:00
Matthias Clasen
af93646b3e Merge branch 'event-controller-key-docs' into 'master'
eventcontrollerkey: Document key-pressed and key-released

See merge request GNOME/gtk!225
2018-07-02 17:16:04 +00:00
Matthias Clasen
64f5afe608 dnd: Rename headers
Rename gdkdnd.h to gdkdrag.h, to go along with gdkdrop.h

This commit includes the necessary updates to the X11, Wayland
and Broadway backends. Other backends have to be updated separately.
2018-07-02 15:00:50 +02:00
Matthias Clasen
fb98f939a5 docs: Update dnd section
Add the separate drag and drop apis.
2018-07-02 15:00:50 +02:00
Matthias Clasen
7733f646d6 gdk: Rename GdkDragContext to GdkDrag
This is to go along with the newly introduced GdkDrop.

This commit includes the necessary updates to the X11, Wayland
and Broadway backends. Other backends have to be updated separately.
2018-07-02 14:59:26 +02:00
Ernestas Kulik
fd69f1cd79 eventcontrollerkey: Document key-pressed and key-released
None of the GtkEventControllerKey signals are documented; this commit
adds documentation for a couple of them.
2018-07-02 12:18:26 +03:00
Daniel Boles
ca94ff10ce testsuite/gtk/defaultvalue: Actually build...& fix
It looks like this got dropped during the move from autotools and never
restored. I can see why, since making it work wasn't a hugely fun task!

Notes on some less then obvious details:
 * PlacesSidebar is private now and didn't seem to be to be particularly
   easy to adapt to, so this moves to checking for it by name, not TYPE.
   I couldn't find a (fast) better way; if you know how, please clean up
 * added 2 casts to avoid warnings from the new type-propagating ref()
 * GdkClipboard and GdkContentProvider need some properties dodged
 * GtkToolItemGroup is gone
 * fixed indentation and used TypeName:property-name syntax in a print()
2018-06-29 20:05:21 +01:00
Matthias Clasen
9c3de51412 Merge branch 'wip/cursor-output-scale-changes' into 'master'
wayland: Update cursor surface scale when output scale changes

See merge request GNOME/gtk!224
2018-06-29 15:08:17 +00:00
Matthias Clasen
d9dcfffce3 Merge branch 'wip/aplazas/modelbutton-markup-master' into 'master'
ModelButton: Add 'use-markup' property

See merge request GNOME/gtk!222
2018-06-29 14:21:24 +00:00
Jonas Ådahl
dfd1372a9b wayland: Update cursor surface scale when output scale changes
Also update the cursor surfaces of every seat when an output changes
scale. This could for example happen when a monitor scale is changed via
Settings.
2018-06-28 12:44:22 +02:00
Benjamin Otte
f3c670ab0c widget: Move opactiy == 0 check
If we check it too early, we will not unset priv->draw_neeeded, which
will then cause queue_draw() calls to not have an effect later. And that
causes changes in opacity to not register.

Closes #1180
2018-06-27 21:50:07 +02:00
Daniel Boles
8aa4b5150e notify test: Remove more nonexistent properties 2018-06-27 17:17:05 +01:00
Timm Bäder
ecaa16c367 notify test: Remove some non-existant properties 2018-06-27 18:03:23 +02:00
Timm Bäder
2f8284a386 testsuite: Remove a GtkColorButton special case
The comment above explains neatly why subclassing GtkButton for
GtkColorButton was a bad idea. Nowadays it's a GtkWidget subclass
containing a GtkButton so let's remove the special case here.
2018-06-27 18:03:23 +02:00
Timm Bäder
73cad1e784 Remove some GtkRecentChooserMenu references
Doesn't exist anymore.
2018-06-27 18:03:23 +02:00
Adrien Plazas
0abd01e288 ModelButton: Add 'use-markup' property
Binds this property to the button's label, allowing a model button to
have text with markup.

This will be convenient for buttons like 'Online Accounts <sup>↗</sup>'.
2018-06-27 17:43:47 +02:00
Rico Tzschichholz
b80942ec88 gdk: Fix some g-i annotations warnings 2018-06-27 09:00:17 +02:00
Timm Bäder
165dab8265 gl renderer: Ignore 0-sized fallback nodes 2018-06-26 21:41:29 +02:00
Emmanuele Bassi
73d736d800 Do not modify a const GdkEvent in place
When deciding whether or not to emulate a press event, we're translating
the last event coordinates and mutating the given event structure
unconditionally.

We should modify the newly created GdkEvent copy, since it's what we're
going to use when emitting the press event.

This avoids mutating a constant GdkEvent and global state, and also
avoids a compiler warning.
2018-06-26 18:06:23 +01:00
Matthias Clasen
88b4076fe5 Docs: Remove more since markers
The idea is that GTK+ 4 will be an epoch, API-wise.
Everything that was around for 4.0 has been there
since the beginning of the epoch and doesn't need
markers.
2018-06-26 12:31:41 -04:00
Matthias Clasen
36396093e6 docs: Document GtkEventControllerKey
The long description was missing.
2018-06-26 12:20:47 -04:00
Matthias Clasen
faba0f0145 Bump version to 3.94.0 2018-06-25 19:55:04 -04:00
Matthias Clasen
8755d884f3 Remove a lot of Since annotations
4.0 will represent a clean epoch. We don't want to have
lots of noise in the docs about 2.x or 3.x.
2018-06-25 19:55:04 -04:00
Matthias Clasen
010f4e90e3 Some updates 2018-06-25 19:06:34 -04:00
Benjamin Otte
0c76264953 reftests: Fix compilation
FOREIGN surfaces are gone.
2018-06-26 00:53:39 +02:00
Benjamin Otte
d13843ee2a gdk: Remove GDK_SURFACE_FOREIGN
We don't create surfaces of that type anymore.
2018-06-26 00:47:40 +02:00
Michael Catanzaro
7869ffbb49 imwayland: Fix a small leak
If the parent get_preedit_string implementation returns a nonnull
zero-length string, then we ignore it, which is almost fine. We have to
free it, though.

Fixes #1174
2018-06-25 22:20:09 +01:00
Matthias Clasen
2f149c378a Merge branch 'master' into 'master'
gtk: also recolor circle and ellipse in symbolic SVG icons.

See merge request GNOME/gtk!214
2018-06-23 19:42:26 +00:00
Jehan
04367acf9b gtk: also recolor circle and ellipse in symbolic SVG icons. 2018-06-23 00:35:17 +02:00
Timm Bäder
1a2052a40e button: Remove unused variable 2018-06-21 20:57:18 +02:00
Timm Bäder
e079fad1d5 scrolledwindow: Avoid a queue_resize path in size-allocate 2018-06-21 20:54:47 +02:00
Samuel Thibault
bada3dbac6 HighContrast: Restore expander size
Expanders used to be 16px high. With the move from the gtk2 rendering
to gtk3 rendering they shrunk to 12px, making them hard to see, because
it's now the icon which is 16px high and the icon contains transparent
borders.

This makes the HighContrast theme use 24px icons instead, to restore
16px expanders. This may expander some containers a bit.

Closes #1046
2018-06-21 16:15:35 +02:00
Daniel Boles
9178423844 TreeView: Get expander size from CSS min-width|height
Rather than hard-coding this, get it from CSS. That way, themes will be
able to set larger expanders than a fixed 16 px, e.g. for accessibility.

See https://gitlab.gnome.org/GNOME/gtk/merge_requests/167
2018-06-21 15:49:00 +02:00
Carlos Garnacho
9df5171962 gtktreeviewcolumn: Implement column dragging through GtkGestureDrag
And remove ::event signal handler.
2018-06-21 12:54:03 +02:00
Carlos Garnacho
b3e91b7111 gtktexthandle: Update to gtk4 rendering/input
GtkTextHandle was neglected by whoever removed the ::draw signal,
leaving it entirely broken. Update to using GtkGizmo so we can
implement snapshot of text handles.

Input has received a revamp too, handling is done through a
GtkGestureDrag and coordinate calculations simplified by storing
the delta to the hotspot on ::begin instead of ::update, as this
value is constant throughout the gesture. Widget state management
on crossing events happens implicitly, so no longer needs to be
done here.

Last but not least, CSS has also been updated so handles are
rendered at the correct size and proportion, and with the padding
that code expects of it.
2018-06-21 12:54:03 +02:00
Carlos Garnacho
ffd89d29df gtkwindow: Queue popover resize on set_popover_position()
So the new position is eventually honored. Fixes magnifier and handles
staying in place after being shown.
2018-06-21 12:54:03 +02:00
Carlos Garnacho
686116ba61 gtkfilechooserwidget: Forward events to filechooser through key controller
Instead of manually calling gtk_binding_set_activate_event() on an ::event
callback in the save entry.
2018-06-21 12:54:03 +02:00
Carlos Garnacho
7fa3183d7f gtkfilechoooserentry: Handle tab completion through key controller 2018-06-21 12:54:03 +02:00
Carlos Garnacho
176fd2fab3 gtkemojicompletion: Use GtkEntry key controller to handle key presses 2018-06-21 12:54:03 +02:00
Carlos Garnacho
419ee6a451 gtkentrycompletion: Properly remove controller from entry
When disconnecting the GtkEntry from the GtkEntryCompletion, we
must remove the controller in order to avoid dangling callbacks.
2018-06-21 12:54:03 +02:00
Carlos Garnacho
2c0d2d332f gtkentrycompletion: Move focus out handling to key controller
We can use the already present key controller to handle focus out.
2018-06-21 12:54:03 +02:00
Carlos Garnacho
5f8fea08ff gtkentrycompletion: Perform event handling on popup through controllers
Instead of a ::event signal handler.
2018-06-21 12:54:03 +02:00
Carlos Garnacho
f92ec7ce41 gtkplacessidebar: Replace ::event signal handlers with gestures
Set up a gesture on the sidebar rows to detect pointer clicks on
it. The row DnD management has been moved to the row widget itself,
it makes more sense even if the drag is began from the sidebar widget.
2018-06-21 12:54:03 +02:00
Carlos Garnacho
ca08cf94d3 gtkwindow: Move map/delete/configure event management to gtkmain
Toplevels are about the only widgets interested in these events,
just handle those without going through the capture/bubble handling
code.
2018-06-21 12:54:03 +02:00
Carlos Garnacho
3d5dc16d63 gtkwindow: Simplify WM drag/resize handling
We still need a drag gesture both on front (capture) and back (bubble)
to handle dragging from both the GtkWindow widget and chrome in the
headerbar. But we can do it through 2 drag gestures, instead of special
event handling code.
2018-06-21 12:52:59 +02:00
Carlos Garnacho
7bfc3a5c74 gtkmenushell: Port to GtkGesture
We still need to poke the current event at places, but this is
better than the ::event vfunc.
2018-06-21 12:50:58 +02:00
Carlos Garnacho
a5414bc404 gtkpopover: Fix key navigation
This has been broken since we switched key event delivery to follow
the same semantics than pointer/touch. There, GTK+ grabs will influence
the topmost widget during event delivery, rendering the toplevel
unable to handle key navigation. The toplevel must handle those key
events in an explicit manner then.

We don't render the keyboard focus rectangle yet, but I assume that's
something else.
2018-06-21 12:50:57 +02:00
Carlos Garnacho
1d97b5fd3c gtkpopover: Port to GtkEventController/GtkGesture
Use GtkEventControllerKey and GtkGestureMultiPress to replace key/button
event handling.
2018-06-21 12:50:57 +02:00
Carlos Garnacho
aa09b0742e gtkwindow: Handle focus in/out through key controller
One less use of ::event in this widget, now mostly left to
map/delete/configure, those puny events.
2018-06-21 12:50:57 +02:00
Carlos Garnacho
c5586f85fb gtkspinbutton: Use GtkEventControllerKey
And drop the ::event vfunc implementation with it.
2018-06-21 12:50:57 +02:00
Carlos Garnacho
3eb1b22651 gtkfontchooser: Use GtkEventControllerKey
Use an event controller on GtkFontChooserDialog, a nice side effect
is that we can use gtk_event_controller_key_forward() and
gtk_search_entry_set_key_capture_widget() instead of passing events
around for dialog search.
2018-06-21 12:50:57 +02:00
Carlos Garnacho
4186a85359 gtkfilechooserwidget: Drop usage of ::event vmethod
Use a key controller set up in the UI file instead.
2018-06-21 12:50:57 +02:00
Carlos Garnacho
aaf1e4995c gtkfilechooserentry: Use GtkEntry key controller for focus-out handling
Expose the GtkEntry key controller in private API, so we don't have to
create yet another one just to handle focus-out.
2018-06-21 12:50:57 +02:00
Carlos Garnacho
e08e15ba51 gtkentry: Use gestures for entry icons
Instead of doing all handling manually in the ::event vfunc,
set up drag/multipress gestures on icon images, and implement
emission of ::icon-press/release and DnD there.

As a side effect, the GdkEvent field in ::icon-press/release
signals has been dropped. Callers that might be interested on it
may still use gtk_get_current_event*().
2018-06-21 12:50:57 +02:00
Carlos Garnacho
7048362e6e gtkbutton: remove keyboard device GTK+ grab
This isn't really necessary, if keyboard focus forcibly goes somewhere
else we will get ::grab-notify, which is sufficient to deactivate the
button again.
2018-06-21 12:50:57 +02:00
Carlos Garnacho
5f0ed088e4 gtkbutton: Use key controller for button (de)activation through keybindings
And stop using GtkWidget::event for good.
2018-06-21 12:50:57 +02:00
Matthias Clasen
5c46c81067 x11: Fix dnd action handling
We were mistakenly assigning an Atom to a flags value.
2018-06-20 18:10:50 -04:00
Daniel Boles
c6fa3c446c EmojiCompletion: Avoid another un/signed warning
The cherry-pick missed this, I guess.
2018-06-20 20:51:50 +01:00
Daniel Boles
f7ebff6aea EmojiCompletion: Avoid un/signed compare warnings
(A) Use gsize to match the result of g_variant_n_children
(B) Use guint for n_matches, like the struct (and all other n_matches)
2018-06-20 20:38:27 +01:00
Daniel Boles
8aeced2c91 themes: Remove leftover bit of .linked workaround
Now that .linked acts like the .path-bar already did, there is no point
in applying the same styles again (with higher specificity).
2018-06-20 20:11:26 +01:00
Timm Bäder
e8fefd92c5 container: Remove SPECIAL_CONTAINER hack
As discussed in !129

Closes !129
2018-06-20 20:47:18 +02:00
Timm Bäder
22390adf11 stackswitcher: Remove icon-size property
This ought to be controlled via css these days.
2018-06-20 20:47:18 +02:00
Timm Bäder
cf9121977f infobar: Remove priv pointer 2018-06-20 20:47:18 +02:00
Timm Bäder
99099a1053 Remove some unnecessary snapshot implementations 2018-06-20 20:47:18 +02:00
Timm Bäder
daba1a7eff fixed: Remove priv pointer 2018-06-20 20:47:17 +02:00
Timm Bäder
f26359db13 listbox: Use widget insert API instead of fiddling with CSS nodes 2018-06-20 20:47:17 +02:00
Timm Bäder
945b844b7c button: Remove ICON_SIZE_BUTTON mention in docs
The icon will have the size given by css, not whatever
GTK_ICON_SIZE_BUTTON was.
2018-06-20 20:47:17 +02:00
Timm Bäder
f33655fa4e adjustment: Only emit ::changed from dispatch_properties_changed 2018-06-20 20:47:17 +02:00
Timm Bäder
ee8ee313c8 adjustment: Remove adjustment_changed_stamp 2018-06-20 20:47:17 +02:00
Timm Bäder
33e113d607 testsuite: Print tested property name in notify test 2018-06-20 20:47:17 +02:00
Timm Bäder
a12d26155f adjustment: Use public setters in set_property 2018-06-20 20:47:17 +02:00
Daniel Boles
cae382c829 themes: Regenerate CSS for recent commits
e.g. the box.linked one, which didn't update the compiled CSS.
2018-06-20 19:26:46 +01:00
Daniel Boles
0a5086d94f HC: Avoid excessive selectors from prev commit
The new rule does not need to affect all those other pseudoclasses. I
just put it in the wrong scope.
2018-06-20 19:26:41 +01:00
Daniel Boles
b103650cb0 HC: Avoid same BG/FG colors in flat treeview entry
Selected rows in tree views in HighContrast have a background colour the
same or nearly as the normal text colour, so we cannot let entries in
such rows have transparent backgrounds, or the text inside the entry
becomes nearly or totally impossible to see.

Dodge this by giving entry.flat inside treeview and with :focus the
$base_color, which is different from the text & so lets that be seen.

https://gitlab.gnome.org/GNOME/gtk/merge_requests/125
2018-06-20 19:13:26 +01:00
Daniel Boles
337e602143 searchenginetracker: Don't leak the hits' GFiles
https://gitlab.gnome.org/GNOME/gtk/merge_requests/206
2018-06-20 17:20:31 +01:00
Matthias Clasen
7ce25293b1 Merge branch 'issue1084' into 'master'
application: Complete the startup sequence before quitting remote instances

Closes #979

See merge request GNOME/gtk!156
2018-06-20 15:34:51 +00:00
Matthias Clasen
cd99f82e0c Merge branch 'master' into 'issue1084'
# Conflicts:
#   gdk/gdk.c
2018-06-20 14:21:24 +00:00
Timm Bäder
29fee2e808 window: Remove priv pointer 2018-06-20 07:49:04 +02:00
Timm Bäder
417b1d8335 pathbar: Remove unused define 2018-06-20 07:48:54 +02:00
Matthias Clasen
443a64a38e docs: Remove a duplicate line in gdk4-sections.txt
This was causing another docs build break.
2018-06-19 17:16:31 -04:00
Matthias Clasen
74455ae75c docs: fix a typo
Invalid syntax in gdk4-sections.txt was causing docs builds to fail.
2018-06-19 17:16:31 -04:00
Daniel Boles
ec096b417c Merge branch '1160-crash-clearing-gtkentry-icon-tooltip-master' into 'master'
Resolve "Crash clearing GtkEntry icon tooltip"

Closes #1160

See merge request GNOME/gtk!205
2018-06-19 20:22:38 +00:00
Benjamin Otte
06bba15f62 win32: Fix typo
This should fix gtk-doc erroring out.
2018-06-19 21:45:44 +02:00
Benjamin Otte
c48be6ef96 Revert "Add aligned allocator functions to GSK"
This reverts commit 8e74eb382f.

This code is not necessary. It worked around a bug in graphene where
graphene was requiring stricter alignment than glib allocators could
guarantee.
2018-06-19 20:00:53 +02:00
Benjamin Otte
0b1f0984f5 Revert "Use aligned allocators for GtkSnapshot"
This reverts commit c02bc22cc5.

This code is not necessary.
The bug causing this problem ws prsent in the graphene library.
2018-06-19 19:52:52 +02:00
Benjamin Otte
6918fb2e4e rendernodepaintable: Fix rendering position
When the given size had an offset, we were moving that offset in the
wrong direction.
2018-06-19 19:44:17 +02:00
Benjamin Otte
3caf8c86c9 dnd: Use a GtkPicture in gtk_dnd_set_icon_paintable()
We don't want to get the paintable scaled down to icon size.

Also set can-shrink = FALSE to replicate GTK3 behavior with size
requests.
2018-06-19 19:44:17 +02:00
Benjamin Otte
8c8dc3aeab snapshot: Compute correct size in gtk_snapshot_to_paintable()
Also, do actually respect the passed in size argument if it isn't NULL.

Fixes text being cut off inside DND icons.
2018-06-19 19:44:17 +02:00
Benjamin Otte
4d4ec2dbfb dnd: gdk_drag_action_is_unique() should return a boolean 2018-06-19 19:44:17 +02:00
Daniel Boles
4f979469f1 a11y/entry: Fix copy-pasteo re 2ndary icon tooltip
The else case was wrongly resetting the accessible description on the
primary icon, which might not exist and can therefore cause a crash.

https://gitlab.gnome.org/GNOME/gtk/issues/1160
2018-06-19 18:37:25 +01:00
Matthias Clasen
87532f0ac3 Merge branch 'wip/carlosg/issue-1159' into 'master'
Fix issue 1159

Closes #1159

See merge request GNOME/gtk!202
2018-06-19 16:40:39 +00:00
Piotr Drąg
0ace7ad219 Update POTFILES.in 2018-06-19 17:52:13 +02:00
myfreeweb
a1bcbdd02a wayland: Use shm_open(SHM_ANON) on FreeBSD
This functionality is similar to Linux's memfd. It creates anonymous shared memory without touching the filesystem, which allows it to work in Capsicum capability mode (sandbox).
2018-06-19 11:45:49 -04:00
Carlos Garnacho
8e3bf65b3b gtkgesture: Check claimed status after event delivery
The claimed status check should happen after ::end is emitted,
as the gesture may deny the sequence that much late. In this
case the event should keep propagating.

https://gitlab.gnome.org/GNOME/gtk/issues/1159

Closes: #1159
2018-06-19 13:47:38 +02:00
Carlos Garnacho
de30a74cdf gtkwidget: Avoid doubly coordinate conversion when emulating press
We are poking again into the event propagation machinery, which
expects events in toplevel coordinates. Since we can't fetch the
original event back at this point, translate the coordinates
back to the toplevel so the emulated press ends up in the right
place.

https://gitlab.gnome.org/GNOME/gtk/issues/1159

Closes: #1159
2018-06-19 13:47:26 +02:00
Benjamin Otte
cbbb7604b6 x11: Set background as transparent as possible
Instead of making the background black, make it transparent black for
RGBA visuals and set a None background otherwise.
2018-06-18 23:49:53 +02:00
Benjamin Otte
9a91d3739d widget: Remove time argument from drag_data_get() vfunc 2018-06-18 23:49:53 +02:00
Benjamin Otte
a2839d157f dnd: Remove unused time arguments 2018-06-18 23:49:53 +02:00
Benjamin Otte
b3d424c2d7 dnd: Remove GdkDragContext.dest_surface
The variable is now unused
2018-06-18 23:49:53 +02:00
Руслан Ижбулатов
bf3ea24489 GDK W32: Remove gdk_win32_surface_foreign_new_for_display
That function is now unused.
2018-06-18 23:49:53 +02:00
Руслан Ижбулатов
997e8c1ae1 GDK W32: Adapt to dest_surface removal, misc changes
* There's no GdkDragContext->dest_surface anymore.
  Add dest_window field to GdkWin32DragContext,
  and use that instead.
* Remove unused function prototypes
* Add more comments
* Rename variables and fields from 'window' to 'surface'
  where appropriate
* Fix header indentation a bit
* Try to ensure that uninitialized/unknown handle variables
  and fields are set to INVALID_HANDLE_VALUE instead of NULL,
  as there may be cases where NULL is a valid handle value.
2018-06-18 23:49:53 +02:00
Benjamin Otte
aa1f0cfd4f dnd: Remove GdkDragContext.is_source
All drag contexts are sources these days, the other ones are GdkDrop
now.
2018-06-18 23:49:53 +02:00
Benjamin Otte
45a6146ca6 x11: Remove gdk_x11_surface_foreign_new_for_display()
People who want to use foreign windows should use X directly.
2018-06-18 23:49:53 +02:00
Benjamin Otte
bc63001deb x11: Store the XID instead of a GdkSurface
This might be foreign Windows and we don't want to create surfaces for
those.

Also, stop using GdkDragContext.dest_surface, that variable is meant to
go away.
2018-06-18 23:49:53 +02:00
Benjamin Otte
47b47f5835 x11: Simplify test
Now that we have gdk_drag_context_get_display(), use it.
2018-06-18 23:49:52 +02:00
Benjamin Otte
1b2dccd143 x11: xdnd_send_event() always returns TRUE
Make it return nothing instead and delete the code that handled the
FALSE case.
2018-06-18 23:49:52 +02:00
Benjamin Otte
7e09aa3caa x11: Don't multiply X values by the scale factor
This is fallout from a too eager change in
bdb442be21.
2018-06-18 23:49:52 +02:00
Benjamin Otte
6633d4130a dnd: Make the base Drag/Drop types abstract
This way, they'll be ignored by the testsuite.

And we don't want to instantiate them anyway, the backends have
their own subclasses.
2018-06-18 23:49:52 +02:00
Benjamin Otte
a960641ace dnd: GdkDragContext is no longer a GdkDrop subclass
This includes a bunch of header cleanup
2018-06-18 23:49:52 +02:00
Benjamin Otte
f982c9c8f8 dnd: Remove gdk_drag_status() and gdk_drag_finish()
Those functions are unused and have been replaced by their equivalents
gdk_drop_status() and gdk_drop_finish().
2018-06-18 23:49:52 +02:00
Benjamin Otte
a1cee7fa65 surface: Kill event masks
In particular, this patch removes:
  gdk_surface_get_events()
  gdk_surface_set_events()
  gdk_surface_get_device_events()
  gdk_surface_set_device_events()

Event masks so far still exist for grabs.
2018-06-18 23:49:52 +02:00
Benjamin Otte
d0ebdf00f8 x11: Store the source surface as an XID
Don't create a foreign GDK surface, just store the XID.

With this, we can avoid GDK APIs that we want to get rid of and just
use the X counterpart.
2018-06-18 23:49:52 +02:00
Benjamin Otte
dd30a288f2 x11: Split drag and drop contexts
While doing so, turn the drop context into a GdkDrop subclass and no
longer pretend to be a GdkDragContext.
2018-06-18 23:49:52 +02:00
Benjamin Otte
005781021e x11: Handle events on drag side differently
Instead of using the filters that the drop side uses, handle events in
the event filter installed by the DragContext.
2018-06-18 23:49:52 +02:00
Benjamin Otte
14f0a25531 x11: Change the way local Drop => Drag is shortcut
This is one step further towards untangling drag and drop parts of X11
DND.
2018-06-18 23:49:52 +02:00
Benjamin Otte
8db379d85b x11: Remove unused argument
The propagate argument is always FALSE, so just use FALSE everywhere.
2018-06-18 23:49:52 +02:00
Benjamin Otte
6b65aaab21 x11: switch a bunch of variable types
GdkDragContext => GdkDrop

This is all in preparation of separation of the drag and drop.

Also, don't check for GDK_DRAG_PROTO_XDND anymore - it's the only
possible value for the protocol on the target side.
2018-06-18 23:49:52 +02:00
Benjamin Otte
905765eed6 broadway: Remove unused variable 2018-06-18 23:49:52 +02:00
Benjamin Otte
e1206763a8 dnd: Remove gdk_drag_context_get_dest_surface()
... and gdk_drag_context_get_source_surface().

In the backends, use direct access to the variables instead.
2018-06-18 23:49:52 +02:00
Benjamin Otte
8a08a325be dnd: Implement gtk_drag_get_source_widget() differently
Instead of keeping a list of source contexts, just use the current
drag's info.
2018-06-18 23:49:52 +02:00
Benjamin Otte
5e159e2ca0 x11: Replace the hardcoded DND filter
Use the new method of connecting to the xevent signal instead.

Also, don't consume the xevent, there might be other code listening for
it. And we don't use PropertyNotify in the generic code path anymore, so
it'll just be ignored there.
2018-06-18 23:49:52 +02:00
Руслан Ижбулатов
392071b66d GDK W32: Remove unused files 2018-06-18 23:49:52 +02:00
Руслан Ижбулатов
8ee4de804c GDK W32: Adapt to GdkDrop and GdkDragContext changes
* Remove clipdrop->dnd_target_state, it's not used anymore
* Remove non-functioning _gdk_dropfiles_store(), store dropfiles
  list in GdkWin32Drop instead
* Fix multiple comment typos
* Fix _gdk_win32_get_clipboard_format_name_as_interned_mimetype() to
  leave names that look like mime/types alone
* Refactor _gdk_win32_add_w32format_to_pairs() to populate
  GdkContentFormatsBuilder directly, instead of making a GList
* Rename context -> drag (still using GdkDragContext type,
  but [almost?] all variables and comments say "drag" now)
* Rename GdkDropContext -> GdkDrop
* Rename some parameter names for clarity
* Rewrite local protocol to look more like OLE2 protocol
  instead of mirroring the structure of the X11 API.
* Add handle_events field to GdkWin32DragContext,
  to shut off event handling (temporary fix until GTK is patched up)
* Remove _gdk_win32_drag_context_find() - the drag object is stored
  in GdkDrop instead. Use _gdk_win32_find_drag_for_dest_surface()
  to get it initially.
* Remove target_ctx_for_window, droptarget context is stored
  in the surface instead.
* Call gdk_drag_context_set_cursor() just like wayland backend does
  (slightly broken for now)
* Clean up the action choosing code (filter source actions by using
  keyboard state, pass that to GTK, get all actions supported by GTK in
  response, match them up with filtered source actions, return the
  result, falling back to COPY in case of multiple actions)
* Check drag_win32->protocol instead of the use_ole2_dnd variable where
  possible
* Remove protocol checks from functions that are only used by the local
  protocol
* Use event state to manufacture the keyboard state for WM_MOUSEMOVE
* Change function names printed by GDK_NOTE to name the actual
  functions, not their theoretical generic GDK stack ancestors
* Consistently use drag_win32 and drop_win32 variables instead of a mix
  of that and win32_drag/win32_drop
* Return FALSE from button handler to ensure that GTK gets the button
  event to break implicit grab
* Emit leave event on failed idroptarget_drop() calls
2018-06-18 23:49:52 +02:00
Benjamin Otte
dcf432d7d0 dnd: Add read_value() and read_text() functions to GdkDrop
These just copy what GdkClipboard does.
2018-06-18 23:49:52 +02:00
Benjamin Otte
ea9d6f0a95 drop: Implement shortcut for local DND
Now that we have the drop->drag, we can use the same shortcut we use in
the clipboard code to shortcut DND operations.
2018-06-18 23:49:52 +02:00
Benjamin Otte
018a17fb8e x11: Pass the drag source when creating a drop context 2018-06-18 23:49:52 +02:00
Benjamin Otte
895f381fd5 x11: Find dest drops differently
Instead of looking at the list of contexts, just look at the current
drop context. There is only one, after all.

Then remove the is_source argument from gdk_drag_context_find().
2018-06-18 23:49:52 +02:00
Benjamin Otte
66bd54d14c wayland: Store the current drag operation
Use it to detect local drags when creating drop objects.
2018-06-18 23:49:52 +02:00
Benjamin Otte
ff38d38444 dnd: Move GdkDragAction to gdktypes.h
That way, both gdkdrag.h and gdkdrop.h can use it without one having to
include the other.
2018-06-18 23:49:52 +02:00
Benjamin Otte
af749532fc gdk: Remove leftover type from autocleanup 2018-06-18 23:49:52 +02:00
Benjamin Otte
7afa0badd8 wayland: Get rid of GdkWaylandSelection
Move data source handling into the DND code instead.
2018-06-18 23:49:52 +02:00
Benjamin Otte
4eb3a9faaa wayland: Split drop context into GdkWaylandDrop
GdkWaylandDrop no longer inherits from GdkDragContext now.
2018-06-18 23:49:52 +02:00
Benjamin Otte
81e1dc9a66 wayland: Remove a bunch of unused functions 2018-06-18 23:49:52 +02:00
Benjamin Otte
c67fb57881 events: Make GdkEventDND have a GdkDrop member
... instead of a GdkDragContext.
2018-06-18 23:49:52 +02:00
Benjamin Otte
81171cc0a2 x11: Refactor DND filter
The filters now return TRUE/FALSE and no longer a GdkFilterReturn. They
also don't conform to the GdkFilterFunc typedef anymore but instead take
the arguments that they need.
2018-06-18 23:49:52 +02:00
Benjamin Otte
aa4e4dd0c7 x11: Use new DND event emitters 2018-06-18 23:49:52 +02:00
Benjamin Otte
7a9afc3a95 win32: Use new DND event emitters 2018-06-18 23:49:52 +02:00
Benjamin Otte
114ab8775a wayland: Use new DND event emitters 2018-06-18 23:49:52 +02:00
Benjamin Otte
657ebd2a78 drop: Add private API for event emission 2018-06-18 23:49:52 +02:00
Benjamin Otte
05bf87cf14 drop: Add GdkDrop:surface property
This replaces gdk_drag_context_get_dest_surface().
2018-06-18 23:49:52 +02:00
Benjamin Otte
4aedf3d003 display: Don't wake up the main loop anymore
This is not needed because GTK must be run in the main thread these days,
which is the same one that runs the main loop. So when this function is
called, the main loop is awake.

https://bugzilla.gnome.org/show_bug.cgi?id=550989
2018-06-18 23:49:52 +02:00
Benjamin Otte
b1f384eec2 x11: Don't sneakily allocate memory in initializers 2018-06-18 23:49:52 +02:00
Benjamin Otte
d02b185a87 dnd: Add gdk_event_get_drop()
And remove gdk_event_get_drag_context().

All GTK code now only uses GdkDrop for dropping.
2018-06-18 23:49:52 +02:00
Benjamin Otte
6048b69145 wayland: Fix drop operations for new semantics 2018-06-18 23:49:52 +02:00
Benjamin Otte
4b85b5299a dnd: Remove GdkDragContext::commit_drag_status() vfunc
The idea behind the vfunc doesn't work as status updates can happen
asynchronously.

A better solution needs to be found.
2018-06-18 23:49:52 +02:00
Benjamin Otte
b00609c21c dnd: Make drag-motion and drag-drop signals use GdkDrop 2018-06-18 23:49:52 +02:00
Benjamin Otte
6d7cb2b781 dnd: Make drag-data-received use a GdkDrop 2018-06-18 23:49:52 +02:00
Benjamin Otte
a862ca41c5 drop: Add gdk_drop_get_drag()
For now, it'll always return NULL. We'll fix that later.
2018-06-18 23:49:20 +02:00
Benjamin Otte
314eaf7d10 widget: Make GtkWidgetClass::drag_leave() take a GdkDrop
Drag Contexts are on their way out!
2018-06-18 23:49:20 +02:00
Benjamin Otte
316bd6a333 dnd: Add gdk_drop_finish()
and move the vfunc into GdkDrop.
2018-06-18 23:49:20 +02:00
Benjamin Otte
5b0a6a52c1 dnd: Get rid of gtk_drag_finish()
It's just a wrapper around gdk_drag_finish(), so use that one instead.
2018-06-18 23:49:20 +02:00
Benjamin Otte
13ae11ee01 dnd: Rename gdk_drop_finish() => gdk_drag_finish()
This is a simple rename, so that we can reintroduce gdk_drop_finish()
with the GdkDrop object.
2018-06-18 23:49:19 +02:00
Benjamin Otte
a05af1f0f3 dnd: Move the gdk_drag_status() function
It's now gdk_drop_status().

Also clarify the intended semantics.
2018-06-18 23:49:19 +02:00
Benjamin Otte
b2dc303e5e dnd: Add gdk_drop_get_actions()
This uses the new method without GDK_ACTION_ASK:

Either it is a single action (queryable via gdk_drag_action_is_unique())
or it is not and then the drop target has to make a decision
(potentially by asking someone).
2018-06-18 23:49:19 +02:00
Benjamin Otte
2e27967814 dnd: Make actions a private member variable
Use a setter in the backends.
2018-06-18 23:49:19 +02:00
Benjamin Otte
18c3b725b4 x11: Remove unused variables 2018-06-18 23:49:19 +02:00
Benjamin Otte
6573d08b08 wayland: Set correct variable
This got messed up in commit 7f8a8f221d.
2018-06-18 23:49:19 +02:00
Benjamin Otte
74a8ffc4a8 dnd: Add gdk_drag_action_is_unique()
This will be necessary once we remove the ASK action.
2018-06-18 23:49:19 +02:00
Benjamin Otte
ac44353f9b dnd: Remove GDK_ACTION_DEFAULT and GDK_ACTION_PRIVATE
They're unused and nobody knows what they're supposed to men anyway.
2018-06-18 23:49:19 +02:00
Benjamin Otte
6919d8c532 drop: Move gdk_drop_read_async() to GdkDrop class 2018-06-18 23:49:19 +02:00
Benjamin Otte
f247d268d4 dnd: Add GdkDrop base class for GdkDragContext
The ultimate goal of this patch series is to split GdkDragContext into
GdkDrop + GdkDrag classes for the destination and source side of a dnd
operation.

The refactoring is meant to work something like this:
1. Introduce GdkDrop as a base class
2. Make all drop related code (like GdkEvent) use GdkDrop instead of
   GdkDragContext. Move/duplicate APIs to allow that.
3. Port all drop contexts in the backends from GdkDragContext to GdkDrop
4. Delete all APIs in GdkDragContext that aren't needed anymore.
5. Make GdkDragContext no longer a GdkDrop subclass
6. Rename GdkDragContext to GdkDrag
2018-06-18 23:49:19 +02:00
Matthias Clasen
841a29837e Merge branch 'lrn/misc-gtk4-fixes' into 'master'
Misc GTK4 fixes

See merge request GNOME/gtk!195
2018-06-18 21:37:42 +00:00
Matthias Clasen
7554384b2d Merge branch 'win32-filechooser-fix-file-list-order' into 'master'
win32 file chooser: add missing g_slist_reverse

See merge request GNOME/gtk!199
2018-06-18 20:09:47 +00:00
Timm Bäder
64313f4a4b themes: Don't handle box.linked special
We don't reverse the css nodes anymore in RTL layouts.
2018-06-18 19:39:32 +02:00
Timm Bäder
34f556fc3e filechooserbutton: Remove priv pointer 2018-06-18 17:35:03 +02:00
Timm Bäder
218b39fe01 GtkStyleContext: Remove the frame clock
It's unused within GtkStyleContext.
2018-06-18 17:35:03 +02:00
Timm Bäder
70c8cfa480 dnd: Fix up a comment
The below function does not take a GtkIconHelper anymore.
2018-06-18 17:35:03 +02:00
Timm Bäder
501efeb6b9 colorscale: Remove priv pointer 2018-06-18 17:35:03 +02:00
Timm Bäder
a7d8127d59 fontbutton: Remove priv pointer 2018-06-18 17:35:03 +02:00
Timm Bäder
beb4cb0e37 radiobutton: remove priv pointer 2018-06-18 17:35:03 +02:00
Timm Bäder
346ec706f7 picture: Fix up some docs
Use nullable instead of allow-none consistently, remove trailing
whitespace and fix some c&p problems.
2018-06-18 17:35:03 +02:00
Timm Bäder
d8274856de drawingarea: Clarify some comments 2018-06-18 17:35:03 +02:00
Timm Bäder
3756234708 messagedialog: Remove priv pointer 2018-06-18 17:35:03 +02:00
Timm Bäder
2d6955285c paned: Allocation x/y are always 0
The allocation position we get passed to size_allocate is always 0/0
these days.
2018-06-18 17:35:03 +02:00
Timm Bäder
10a0d6252e paned: Remove handle_pos member
Query the handle bounds on demand instead.
2018-06-18 17:35:03 +02:00
Timm Bäder
f8ddc42638 paned: Chain up in snapshot
No need to snapshot all child widgets ourselves, the implementation in
GtkWidget can just do it for us.
2018-06-18 17:35:02 +02:00
Timm Bäder
e9a9bb069f paned: Remove unnecessary local variable
We can just pass the given allocation on.
2018-06-18 17:35:02 +02:00
Timm Bäder
df79f02310 paned: Don't unnecessarily redraw handle in size_allocate
We size_allocate it after all, which will redraw it.
2018-06-18 17:35:02 +02:00
Timm Bäder
bd99ca2f04 paned: Store GParamSpecs
So we can use the more efficient g_object_notify_by_pspec everywhere.
2018-06-18 17:35:02 +02:00
Timm Bäder
889fcf64b6 Remove gtk_css_node_reverse_children
Not needed anymore.
2018-06-18 17:35:02 +02:00
Timm Bäder
3fadb536d9 toolbar: Stop reordering css nodes based on text direction 2018-06-18 17:35:02 +02:00
Timm Bäder
fb0d8eacc3 headerbar: Stop reordering css nodes depending on text direction 2018-06-18 17:35:02 +02:00
Timm Bäder
fffb3161bc notebook: Stop reversing tabs based on text direction 2018-06-18 17:35:02 +02:00
Timm Bäder
3be2cb8f63 builder: Fix g-i annotations of _get_translation_domain
The return value can be null and is (transfer none).
2018-06-18 17:35:02 +02:00
Timm Bäder
8267605ba2 builder: Use TRUE/FALSE for error return values
Instead of guint and 0/1.
2018-06-18 17:35:02 +02:00
Timm Bäder
da4d8b7d94 builder: Remove priv pointer 2018-06-18 17:35:02 +02:00
Timm Bäder
01d4538223 box: Don't reorder children based on text direction
Make :first-child always be the first child, i.e. the leftest one in LTR
and the rightest one in RTL.
2018-06-18 17:35:02 +02:00
Timm Bäder
da27627696 paned: Don't reorder css nodes based on text direction 2018-06-18 17:35:02 +02:00
Timm Bäder
85e49a1051 center box: Don't reorder css nodes in RTL
So widget order matches css order. We will do the same thing with GtkBox
eventually.
2018-06-18 17:35:02 +02:00
Timm Bäder
798944cb26 scrolledwindow: Remove priv pointer 2018-06-18 17:35:02 +02:00
Matthias Clasen
5a319f66af Merge branch 'window-activate-grab-4-again' into 'master'
gdk: activate surface on keyboard grabs

Closes #85

See merge request GNOME/gtk!174
2018-06-18 11:36:09 +00:00
Nicolai Syvertsen
2d7cfdd7ed win32 file chooser: add missing g_slist_reverse
the list is prepended to so we need to reverse the list
before returning
2018-06-18 09:44:46 +00:00
Samuel Thibault
35417a5a74 gdk: activate surface on keyboard grabs
In 01455399e8 ("gdk: do not deactivate surface on keyboard grabs"), we
made gdk avoid deactivating surfaces when another application takes a
keyboard grab, by using has_focus_window instead of has_focus. That however
broke activating surfaces when the gdk application acquired a grab itself,
in which case has_focus_window is false but has_focus is true.

We thus actually need to use both: surfaces should be activated either
because we have normal keyboard focus, or because we grabbed the keyboard.

This also renames HAS_FOCUS to APPEARS_FOCUSED to better reflect its
role.

Fixes #85
2018-06-18 10:31:15 +02:00
Piotr Drąg
fdfbbc8246 Update Polish translation 2018-06-17 17:24:07 +02:00
Руслан Ижбулатов
0db6ee9347 GDK W32: don't unref window iconlist textures
We do not own these textures, nor do we ref them, so it's inappropriate
to unref them.
2018-06-16 18:26:29 +00:00
Руслан Ижбулатов
8a1106c639 W32: Use correct hinstance values
According to the old new thing[0], we should use the instance handle
of the GDK/GTK DLL when registering GDK-specific types in the system.
Using the instance handle for the whole application in these circumstances
is not an error, but can potentially clash with the types registered
by the application itself.

Also, extract window class icons from the GDK/GTK DLL, not from the
application executable.

[0]: https://blogs.msdn.microsoft.com/oldnewthing/20050418-59/?p=35873
2018-06-16 18:24:56 +00:00
Руслан Ижбулатов
6e085b3bf1 Pass the correct data to gdk_content_register_serializer()
The argument is eventually passed to g_conv(), so it should
be the charset, not the mime/type. Without this change the
contentype converter will fail to convert UTF-8 strings to, say,
CP-1251 later on.
2018-06-16 18:23:56 +00:00
Руслан Ижбулатов
6bf88d90f3 W32: don't put a string literal into gtk_libdir
In all other instances gtk_libdir is a dynamically-allocated string,
so dup the literal in this case as well.
2018-06-16 18:22:12 +00:00
Руслан Ижбулатов
fb4d76d380 Add forward declaration for DllMain() in gtkwin32.c 2018-06-16 18:21:42 +00:00
Руслан Ижбулатов
dedc1ee1e5 Use const for media type in devmode_to_settings() 2018-06-16 18:20:49 +00:00
Руслан Ижбулатов
fe76984e89 Add foward declarations to gtk_print_operation_run_without_dialog 2018-06-16 18:20:22 +00:00
Timm Bäder
f6d70f7225 search bar example: remove unused function 2018-06-16 10:16:41 +02:00
Timm Bäder
0b12fd9c1b center box: Remove snapshot implementation 2018-06-16 10:09:12 +02:00
Timm Bäder
7f8106f2a9 gl renderer: call glViewport directly 2018-06-16 10:09:12 +02:00
Timm Bäder
d3ffaa0236 button: Remove measure implementation
This is already done by GtkBin.
2018-06-16 10:09:12 +02:00
Timm Bäder
1b208eb457 combobox: Remove priv pointer 2018-06-16 10:09:12 +02:00
Matthias Clasen
1528665662 Merge branch 'wip/lantw/fix-gtkdoc-build-without-wayland' into 'master'
docs: Fix gtk-doc build when wayland is disabled

See merge request GNOME/gtk!193
2018-06-15 16:27:44 +00:00
Ting-Wei Lan
751c1877b1 docs: Fix gtk-doc build when wayland is disabled
Unconditionally putting 'gdkwayland_inc' in src_dir argument of gtkdoc
call tells gtkdoc-scan to scan source files in a non-existent build
directory, gdk/wayland. To avoid causing build failure when a specific
backend is disabled, we should include directories conditionally.
2018-06-15 23:51:15 +08:00
Matthias Clasen
66e0060836 Merge branch 'design_by' into 'master'
aboutbox: use a more fitting 'design by" role

Closes #1153

See merge request GNOME/gtk!192
2018-06-15 02:00:57 +00:00
Mohammed Sadiq
b2db7bb95b examples: Simplify handling events in search-bar
In search-bar example, we can use gtk_search_bar_set_key_capture_widget()
which would simplify handling keyboard events.
2018-06-14 23:23:17 +05:30
Jakub Steiner
c5fa657631 aboutbox: use a more fitting 'design by" role
- in most cases, authors listed under "artwork by" are actually responsible for
  the design of the app as a whole

Fixes issue #1153
2018-06-14 16:36:38 +02:00
Mohammed Sadiq
bdf3b6f64d Revert "imcontext: Make size arguments be gsize and not int"
This was committed accidently.

This reverts commit eefd2d6f10.
2018-06-14 11:15:14 +05:30
Mohammed Sadiq
6033bc56b4 examples: Fix alignment of search-bar example
The search entry was taking the whole window size.
Let's reduce the size so as to have more natural size.
2018-06-14 11:09:19 +05:30
Benjamin Otte
eefd2d6f10 imcontext: Make size arguments be gsize and not int
Otherwise gcc complains when we use these as arguments to g_new() on
32bit architectures with:

../gtk/gtkcomposetable.c: In function ‘gtk_compose_table_list_add_array’:
/usr/include/glib-2.0/glib/gmem.h:217:10: warning: argument 1 range [2147483648, 4294967295] exceeds maximum object size 2147483647 [-Walloc-size-larger-than=]
      __p = g_##func##_n (__n, __s);   \
      ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/glib-2.0/glib/gmem.h:279:42: note: in expansion of macro ‘_G_NEW’
 #define g_new0(struct_type, n_structs)   _G_NEW (struct_type, n_structs, malloc0)
                                          ^~~~~~
../gtk/gtkcomposetable.c:851:22: note: in expansion of macro ‘g_new0’
   gtk_compose_seqs = g_new0 (guint16, length);
                      ^~~~~~
/usr/include/glib-2.0/glib/gmem.h:96:10: note: in a call to allocation function ‘g_malloc0_n’ declared here
 gpointer g_malloc0_n      (gsize  n_blocks,
          ^~~~~~~~~~~
2018-06-14 06:37:00 +05:30
Mohammed Sadiq
daf72e2e96 docs: Update getting started docs
We have removed references to private members in our examples.
Let the docs be updated to reflect that.
2018-06-14 05:30:21 +05:30
Mohammed Sadiq
7e98741793 docs: Use gtk_widget_show() to show window
gtk_window_show_all() is no longer available (and no longer needed)
2018-06-13 20:15:20 +05:30
Mohammed Sadiq
d4693b2dc8 snapshot: Trivial typo fix in comment 2018-06-13 19:58:01 +05:30
Rico Tzschichholz
b1f934d3b0 picture: Fix g-i annotation warning 2018-06-13 13:08:28 +02:00
Mohammed Sadiq
fd4bfd5050 build: Fix compiler warnings 2018-06-11 21:12:41 +05:30
Mario Sanchez Prada
07d6c53346 application: Complete startup notification sequence for remote invocations
When a remote instance of a GTK application implementing the Startup
Notification protocol gets spawned it will pass the startup sequence
ID as "platform data" to the main instance. Thus, we need to make sure
that the startup sequence gets completed in that case, since the remote
instance won't do it by itself, since it won't map any top level window.

Checking for this "platform data" in the implementation of the after_emit()
virtual method in the primary instance should be a good place to do so, since
the existence of such data proves that a remote instance has been spawned.

https://gitlab.gnome.org/GNOME/gtk/issues/1084
2018-06-11 16:28:24 +01:00
Mario Sanchez Prada
479c341545 application: Use the new API to get the startup notification ID
The DESKTOP_STARTUP_ID gets cleared early after the process is spawned,
meaning that it's too late at add_platform_data() to pick it up and send
it over to the primary instance, as it will be always unset at that point.

To solve this, we use the new gdk_display_get_startup_notification_id()
method to pull the startup notification ID for the application, if present,
out of the display and pass it over to that primary instance.

https://gitlab.gnome.org/GNOME/gtk/issues/1084
2018-06-11 16:28:24 +01:00
Mario Sanchez Prada
938448e0ef display: Add new virtual gdk_display_get_startup_notification_id() method.
Includes implementation for Wayland and X11, which are the only backends
implementing the Startup Notification Protocol, returns NULL otherwise.

https://gitlab.gnome.org/GNOME/gtk/issues/1084
2018-06-11 16:28:24 +01:00
Mario Sanchez Prada
ef3427575f display: Avoid unsetting the DESKTOP_STARTUP_ID variable too late
Similar to what has been done recently for DESKTOP_AUTOSTART_ID [1],
we need to get rid of this call to g_unsetenv() in the displays'
backends for X11 and Wayland, so that it's guarantee to happen any
thread is created, while still being accessible when needed.

Let's stash the value of this environment variable when loading the
GDK library, and provide a private method so that it can be retrieved
from the displays' backend when implementing gdk_display_make_default().

[1] https://gitlab.gnome.org/GNOME/gtk/commit/22269902

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/979
2018-06-11 16:28:24 +01:00
Mohammed Sadiq
0c57e3131f overlay: Use the right property variable name 2018-06-11 17:43:16 +05:30
Benjamin Otte
b22f45b2f6 Merge branch 'wip/sadiq/fixes' into 'master'
overlay: Add support for clipping overlay widgets

See merge request GNOME/gtk!189
2018-06-11 11:55:09 +00:00
Mohammed Sadiq
0d46081645 overlay: Add support for clipping overlay widgets
Sometimes users may want to restrict the growth of child
widgets in a GtkOverlay to grow atmost the size of the overlay.

Let's add a support for that.
2018-06-11 16:24:29 +05:30
Matthias Clasen
4f632296a5 Merge branch 'lrn/gtk4warnings' into 'master'
Fix a lot of warnings in GTK4

See merge request GNOME/gtk!188
2018-06-10 23:14:42 +00:00
Matthias Clasen
c047e97cfa Merge branch 'master' into 'master'
gtk: Add gtk_is_initialized() and gtk_get_main_thread()

See merge request GNOME/gtk!186
2018-06-10 23:05:50 +00:00
Matthias Clasen
bc13a58f3c Merge branch 'lrn/aligned-alloc' into 'master'
Aligned allocators for GTK4

Closes #856

See merge request GNOME/gtk!187
2018-06-10 22:05:12 +00:00
Руслан Ижбулатов
43f37894b0 Use correct stat struct for ftw()
check_dir_mtime() is called by ftw() and is given
the real stat struct, not its glib version (which may
or may not be the same as "struct stat").

This is irrelevant for MSVC (it has no ftw()) and
works correctly for MinGW-w64 (which declares stat
structures correctly). If mingw.org complains, add
a special ifdef for it later.
2018-06-10 21:21:27 +00:00
Руслан Ижбулатов
0365dadad9 See if _MSC_VER is defined before checking its value 2018-06-10 21:21:25 +00:00
Руслан Ижбулатов
9330be8cf9 Fix missing default switch case in DllMain 2018-06-10 21:21:24 +00:00
Руслан Ижбулатов
43d6fe2583 Fix missing default switch cases in gtkimcontextsimple 2018-06-10 21:21:22 +00:00
Руслан Ижбулатов
411c535956 Fix some warnings in W32 part of gtkmain
* Add missing default cases
* Cast string literals as non-const
2018-06-10 21:21:20 +00:00
Руслан Ижбулатов
cddc9ff424 Fix a typo in W32 event-handling code
It's quite old, but mostly harmless (both "message == WM_KEYUP"
and "message = WM_KEYUP" evaluate to not-FALSE, and message
value is not used after that line).
2018-06-10 21:21:19 +00:00
Руслан Ижбулатов
e73dc5c779 Fix a warning about uninitialized variable 2018-06-10 21:21:17 +00:00
Руслан Ижбулатов
93f8f3c406 Remove unused code in gdksurface-win32.c 2018-06-10 21:21:16 +00:00
Руслан Ижбулатов
3acd26c64a Fix more signedness issues in W32 backend 2018-06-10 21:21:14 +00:00
Руслан Ижбулатов
cacdef8db7 A quick and dirty fix for a circular allocation issue
query_targets() tried to write to struct that
wasn't yet allocated.
This code is going to change soon, so this is a temporary
fix until then.
2018-06-10 21:21:12 +00:00
Руслан Ижбулатов
1e2ab40539 Fix a missing default case warning
It shouldn't be possible to get DPI_STATUS_PENDING here.
If it does happen, that would be a bug that should be fixed.
2018-06-10 21:21:10 +00:00
Руслан Ижбулатов
f0103eeeb4 Remove unused functions in W32 backend 2018-06-10 21:21:09 +00:00
Руслан Ижбулатов
8bd6936533 Fix signedness issues, remove unused code 2018-06-10 21:21:07 +00:00
Руслан Ижбулатов
0e1710a372 Remove some more unused variables 2018-06-10 21:21:06 +00:00
Руслан Ижбулатов
bc47fa27d4 Fix various type mismatch warnings 2018-06-10 21:21:04 +00:00
Руслан Ижбулатов
aaa4e23a77 Fix gdk_win32_cairo_context_end_frame prototype 2018-06-10 21:21:02 +00:00
Руслан Ижбулатов
58fc1229c1 Remove unused variables (mostly in W32 code) 2018-06-10 21:21:01 +00:00
Руслан Ижбулатов
10b2f6540a Fix wrong format strings in various places 2018-06-10 21:20:59 +00:00
Руслан Ижбулатов
c02bc22cc5 Use aligned allocators for GtkSnapshot
Any data that is later fed to graphene must be
allocated with proper alignment, if graphene
uses SSE2 or GCC vector instructions.

This adds custom array code (a streamlined copy
of GArray with all unnecessary bells and whistles removed),
which is then used for the state_stack instead of GArray.

There's also a runtime check for the size of GtkSnapshotState
itself being a multiple of 16. If that is not so, any array
elements past the 0th element will lose alignment.
There are probably struct attributes that can
make GtkSnapshotState always have size that is a multiple
of 16, but we'll burn that bridge if we cross it.
2018-06-10 20:35:54 +00:00
Piotr Drąg
ef2daa3bdd Update Polish translation 2018-06-10 15:35:50 +02:00
Piotr Drąg
d8c8a25c2f Update POTFILES.in 2018-06-10 15:19:06 +02:00
Benjamin Otte
a34a5df674 picture: Don't use g_str_equal() with potential NULLs 2018-06-10 02:56:18 +02:00
Benjamin Otte
299e2ed44c docs: Add GtkEventControllerKey to index 2018-06-10 02:35:30 +02:00
Benjamin Otte
4c961349ab dnd: Ref the GdkDrop during the DND operation
It might go away if the DND takes too long otherwise...
2018-06-10 02:35:30 +02:00
Benjamin Otte
b7ecfbce21 quartz: Remove gtkdnd-quartz.c
It shows up in my git diff calls and is completely broken.
2018-06-10 02:33:53 +02:00
Benjamin Otte
40321d331f x11: Remove useless check
The check survived from GTK2 when that function could still return
GdkPixmap and GdkFont objects and was accompanied by this comment:

  /* We may receive events such as NoExpose/GraphicsExpose
   * and ShmCompletion for pixmaps
   */
2018-06-10 02:33:53 +02:00
Benjamin Otte
ce6227840d clipboard: Remove return statements from void function 2018-06-10 02:31:10 +02:00
Benjamin Otte
896f72d33b gtk-demo: Use GtkImages to select the puzzle 2018-06-10 02:25:55 +02:00
Benjamin Otte
884aaa2193 iconhelper: Always size contents to icon size
No more special casing for paintables. If you want the special case for
paintables, you should use GtkPicture.
2018-06-10 02:25:28 +02:00
Benjamin Otte
f58c556adb image: Remove gtk_image_set_keep_aspect_ratio()
and gtk_image_set_can_shrink().

Images are meant to always be icon-sized, they can never shrink below
that.

And images are icons, so they are meant to be square. If they are
not, we pretned that's by accident and keep aspect ratio.
2018-06-10 02:25:28 +02:00
Benjamin Otte
7690c2d042 gtk-demo: Make sliding puzzle demo use GtkPicture 2018-06-10 02:25:28 +02:00
Benjamin Otte
cbd47fa770 gtk-demo: Port images demo to use a GtkPicture in places 2018-06-10 02:23:02 +02:00
Benjamin Otte
45d78f360f video: Use a Picture instead of an Image 2018-06-10 02:23:02 +02:00
Benjamin Otte
6546ef3459 picture: Introduce
This commit introduces GtkPicture, which is supposed to complement
GtkImage.

GtkImage will be adapted to always display an icon, while
GtkPicture displays regular imagery.
2018-06-10 02:23:02 +02:00
Matthias Clasen
9d48a95d9a puzzle: fix some compiler warnings
These slipped under the radar, sorry.
2018-06-09 19:39:43 -04:00
Timm Bäder
cfbba2c710 widget: Use priv pointer less
Instead declare a priv local. We should do this even if we don't remove
the priv pointer from GtkWidget entirely, just to stay consistent with
new code we introduce.
2018-06-09 21:25:15 +02:00
Руслан Ижбулатов
a394a86151 Use aligned allocators for GskRenderNode
Any data that is later fed to graphene must be
allocated with proper alignment, if graphene
uses SSE2 or GCC vector instructions.
2018-06-09 14:05:49 +00:00
Руслан Ижбулатов
8e74eb382f Add aligned allocator functions to GSK
The code is mostly stolen from graphene.
Allocators support any alignment, but their implementation
only calls system aligned allocator functions if malloc()
is not aligned to 16-byte boundaries. If it is aligned,
the implementation just calls malloc() regardless of which
alignment is requested by the caller.

This can be fixed by saving the result of meson malloc()
alignment check and adding a few conditions to the implementation,
but right now GSK and GTK only need 16-byte alignment either way.
2018-06-09 14:01:03 +00:00
Руслан Ижбулатов
bd2e3f5b9b Add aligned allocator support to meson
* A bunch of new variables for config.h.meson
* A check for aligned allocation being necessary at all
  (graphene must use GCC vector instructions or SSE2)
* A check for C malloc() being aligned at 16-byte boundaries
* A check for a few special aligned allocator functions being
  present and not being built-ins (posix_memalign is a builtin
  in GCC, even on platforms where there is no posix_memalign
  system function)
* Added -mstackrealign flag on Windows, since otherwise
  stack variables may become unaligned when the stack briefly
  passes through OS code (such as in various callbacks and
  handlers)
2018-06-09 13:52:42 +00:00
Philippe Normand
2f181df1cf gtkmain: Add gtk_get_main_thread()
This utility function can be useful to know which thread was initialized for
GTK+.
2018-06-08 18:41:54 +01:00
Philippe Normand
542ad4fdc5 gtkmain: Add gtk_is_initialized()
This utility function can be useful to check whether GTK+ was already
initialized or not.
2018-06-08 18:39:38 +01:00
Fran Dieguez
085368eb93 Update Galician translation 2018-06-08 08:09:57 +00:00
Matthias Clasen
1ee23d0d49 puzzle: Add mouse support
Make it so that clicking on a puzzle piece moves enough
pieces to move the empty space there, if it is possible.
2018-06-07 21:47:30 -04:00
Matthias Clasen
ebf042d305 puzzle: Use plain labels
The previous code looked cool in the UI, but was too much
of a hack in the code.
2018-06-07 21:47:30 -04:00
Matthias Clasen
a849ffbd79 Add tweaks
Allow setting the puzzle size, and allow chosing between
the rose and the radioactive animation. Change the default
size to 3. 6 is just too hard.
2018-06-07 21:47:30 -04:00
Matthias Clasen
547d63d56a puzzle: Add a reshuffle button 2018-06-07 21:47:30 -04:00
Matthias Clasen
ddad5c3ce9 Keep aspect ratio of the image
Since we don't have a good way to control the window size tightly,
make the content keep aspect ratio.
2018-06-07 21:47:30 -04:00
Benjamin Otte
b6c8943bbf demo: Add the sliding puzzle demo 2018-06-07 21:47:30 -04:00
Matthias Clasen
46d8c84049 Merge branch 'master' into 'master'
Fix reference to user styles in gtkstyleprovider.h

See merge request GNOME/gtk!184
2018-06-07 18:27:25 +00:00
Mohammed Sadiq
59c8fdff29 font-button: Suggest non deprecated function in docs
gtk_font_button_get_font_name() has been deprecated in 3.22 and
its public API is removed from GTK4.
2018-06-07 15:45:32 +05:30
Matijs van Zuijlen
932e5ea34e Fix reference to user styles in gtkstyleprovider.h 2018-06-07 08:54:23 +00:00
Matthias Clasen
d2d4ea6f0a Merge branch 'wip/move-to-rect-public' into 'master'
gdk: Make gdk_surface_move_to_rect public

See merge request GNOME/gtk!179
2018-06-05 21:02:51 +00:00
Daniel Boles
3396c5e983 SizeRequest: Round px values up for min CSS sizes
Otherwise, requesting a min size in em where the equivalent in px had a
fractional part would lead to the widget getting allocated 1 too few px.
You could see this in the CSS property vs. allocation in the Inspector.

Note that margin/border/padding are left alone: the rationale is that we
do as browsers do, and Benjamin said we already do that for those,
whereas his tests on min-(width|height) showed otherwise. My subsequent
analysis indicated it to be far less clear-cut than that, but he remains
unconvinced that we should ceil() all the things! So just do these ones.

https://gitlab.gnome.org/GNOME/gtk/issues/1088
2018-06-05 18:49:52 +01:00
Jonas Ådahl
c0e1044d5c gdk: Make gdk_surface_move_to_rect public
This is the API used by GtkMenu to properly position menus on the screen
without requiring GTK to query the menu window's position or the work
area of where the window is positioned. It makes it possible to position
popup windows properly when using Wayland.

Make this API available to external users so custom popup windows can be
positioned properly as well.

Related: https://gitlab.gnome.org/GNOME/gtk/issues/997
2018-06-05 17:53:05 +02:00
Timm Bäder
5c24bbf00c popover: Add missing close paren in docs 2018-06-04 21:58:44 +02:00
Timm Bäder
a1e3e9dd17 colorbutton: Remove priv pointer 2018-06-04 21:58:44 +02:00
Timm Bäder
d53c28b07a aspectframe: Remove unused member 2018-06-04 21:58:44 +02:00
Timm Bäder
a3987f3386 bin: Remove public GtkBinPrivate typedef 2018-06-04 21:58:44 +02:00
Timm Bäder
4e9a879de0 statusbar: Remove garbage from header file
Nobody will ever read those comments; documentation belongs into the
soruce file so gtk-doc actually picks it up.
2018-06-04 21:58:44 +02:00
Timm Bäder
9109b0c3f2 statusbar: Remove priv pointer 2018-06-04 21:58:44 +02:00
Timm Bäder
758137b5d9 widget: Add docs for {get,set}_focus_child
With get_ being still private.
2018-06-04 21:58:44 +02:00
Timm Bäder
4ab3aada3f gl renderer: use w axis vector from graphene
Instead of initializing our own one every time.
2018-06-04 21:58:44 +02:00
Matthias Clasen
7a5567bf41 Merge branch 'patch-1' into 'master'
GtkWindow: Handle non-square icons with height > width correctly

Closes #657

See merge request GNOME/gtk!170
2018-06-03 18:10:03 +00:00
Christian Stadelmann
a70f0356e9 GtkWindow: Handle non-square icons with height > width correctly 2018-05-31 17:26:17 +02:00
Mohammed Sadiq
f4c1a40446 widget: Fix example code in doc 2018-05-31 16:24:00 +05:30
Matthias Clasen
8b24d59cde Merge branch 'gesture-docs' into 'master'
Gesture stuff

See merge request GNOME/gtk!169
2018-05-30 02:13:04 +00:00
Matthias Clasen
60aeb15116 x11: Don't set NET_WM_PID when sandboxed
It is not useful, and some window managers misinterpret it and
add some "runs as root" indication to the window decoration.

See https://github.com/mate-desktop/marco/issues/301
2018-05-29 20:19:05 -04:00
Matthias Clasen
c83441ae4a gdk: Add a private api to find sandboxes
This will be used in more places in the future.
2018-05-29 20:17:22 -04:00
Benjamin Otte
83a80ab866 events: Mark static function as such 2018-05-29 21:54:47 +02:00
Benjamin Otte
7e574fa98c gdk: Get rid of gdk_event_free()
Events are objects, so use g_object_unref().
2018-05-29 21:53:44 +02:00
Ernestas Kulik
4d2b39d98c gesturemultipress: Don’t fire ::released after ::cancel
Causing a grab in the handler for ::pressed by, e.g., popping up a
context menu will cause the gesture to be canceled and, subsequently,
::end and ::released to be fired, all while the button is still
physically pressed. That results in no event being available to the
::released handler and garbage coordinates, given that
gtk_gesture_get_point() returns FALSE.

Emitting ::released can be avoided by checking the return value
gtk_gesture_get_point().
2018-05-29 19:09:28 +03:00
Ernestas Kulik
e9765c0405 gesture: Fix code snippet
GTK_EVENT_SEQUENCE_ACCEPTED seems to never have been a valid enumeration
value. GTK_EVENT_SEQUENCE_CLAIMED is the closest in meaning.
2018-05-29 18:27:59 +03:00
Ernestas Kulik
334c7911c1 gesture: Fix get_last_event() docs
Querying the event sequence of a gesture will always yield NULL for
non-touch events, but passing NULL in to calls to
gtk_gesture_get_last_event() is a perfectly valid use case.
2018-05-29 18:15:20 +03:00
Victor Toso
d424837496 gdkseatdefault: Don't hide GdkSurface on grab failure
Application is not expecting that.

Bug found due gdk_seat_grab() failure on Lock Screen. When user
Unlock the screen, the application is visible but does not receive
enter-event any more on X11/GNOME.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1485968
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1571422

Signed-off-by: Victor Toso <victortoso@redhat.com>
Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
2018-05-29 14:05:14 +02:00
Carlos Garnacho
694d9aa9f9 gtkpopover: Fix thinko in key press event type check
That code branch is meant to check for key events, seems obvious we want
GDK_KEY_PRESS, not GDK_BUTTON_PRESS (which also broke the branch right
below).

Makes us all able to dismiss popovers again.
2018-05-29 14:05:14 +02:00
Carlos Garnacho
317abed78e Revert "popover: Fix setting priv->button_pressed in ::event handler"
This reverts commit d638ff3afa.

Doesn't look like the right fix. Another one coming that fixes dismissing
through both pointer and keyboard.
2018-05-29 14:03:27 +02:00
Matthias Clasen
979a7e8afa Remove an unused struct
Positive side-effect: visual c no longer has an empty struct
to complain about.
2018-05-27 11:57:49 -04:00
Timm Bäder
d638ff3afa popover: Fix setting priv->button_pressed in ::event handler
There were two cases in that if/else cascade handling the
event_type == GDK_BUTTON_PRESS case, so priv->button_pressed never got
set.
2018-05-27 17:51:51 +02:00
Timm Bäder
c8decbaad0 gdkscreen-x11: Remove redundant typedef
Causes warnings with clang.
2018-05-27 17:51:51 +02:00
Timm Bäder
719b2b0525 gl renderer: Remove an outdated comment 2018-05-27 17:51:51 +02:00
Matthias Clasen
f9875040c6 Merge branch 'master' into 'master'
icontheme: Keep dir_mtimes in order

Closes #1115

See merge request GNOME/gtk!161
2018-05-27 15:50:17 +00:00
Timm Bäder
7f9cd9f9d9 filechooserwidget: Don't chain up in ::event
GtkWidgetClass.event is NULL.
2018-05-27 16:20:55 +02:00
Timm Bäder
251913c80e gl renderer: Use offsets for more node types 2018-05-27 16:20:55 +02:00
Piotr Drąg
d8aa8fc6ce Update Polish translation 2018-05-27 07:58:25 +02:00
Matthias Clasen
d561e52cde a11y: Stop using ::event
We can just as well use notify::has-focus for the purpose of
focus tracking, and we can at the same time avoid emitting the
deprecated AtkObject::focus-event signal.
2018-05-26 08:46:06 -04:00
Christoph Reiter
e610c02a9e ci/msys2: force disable vulkan
A recent dependency change in MSYS2 made it pull in vulkan, which made
meson think it's available but it somehow links against the system vulkan dll
instead.

Disable vulkan for now.
2018-05-26 14:23:58 +02:00
Daniel Boles
e7809f43ec SpinButton: Fix an obviously wrong arg description
:climb-rate is not about what you get when you single-click on a button,
as this implied: it's what happens if you hold down a button or a key.
Fix the description of @climb_rate to new(), and while here, mention the
key in the blurb of :climb-rate itself.
2018-05-26 01:06:00 +01:00
Jan Alexander Steffens (heftig)
1e06838c1c icontheme: Keep dir_mtimes in order
Don't reverse the order each time we insert a theme. Reverse it only
once, after all themes have been loaded.

Fixes https://gitlab.gnome.org/GNOME/gtk/issues/1115
2018-05-23 20:06:01 +02:00
Matthias Clasen
4bb3ac3e81 Merge branch 'kill-key-events' into 'master'
Kill key events

See merge request GNOME/gtk!160
2018-05-23 01:55:05 +00:00
Carlos Garnacho
d94ac2ed61 Merge branch 'issue792' into 'master'
wayland: check native surface for crossing events

Closes #792

See merge request GNOME/gtk!148
2018-05-22 11:10:26 +00:00
Matthias Clasen
8746322d53 Drop the ::key-press/release-event signals
These are the last event-type specific signals,
we are just relying on the generic ::event signal now.
2018-05-21 20:20:55 -04:00
Matthias Clasen
85922f6090 treeview: Stop using ::key-press-event
Use a generic ::event handler instead.
2018-05-21 20:20:49 -04:00
Matthias Clasen
ec2d0edd79 spin button: Stop using ::key-release-event
Just use the generic ::event signal.
2018-05-21 20:20:43 -04:00
Matthias Clasen
b63def0865 font chooser dialog: Stop using ::key-press-event
Use the generic ::event instead.
2018-05-21 20:20:33 -04:00
Matthias Clasen
6084a7ea89 button: Stop using ::key-release-event
Use the generic ::event signal instead.
2018-05-21 20:20:24 -04:00
Matthias Clasen
c78166e190 file chooser widget: Stop using ::key-press-event
Use a generic ::event handler instead.
2018-05-21 20:20:18 -04:00
Matthias Clasen
576dcf65b3 file chooser entry: Stop using key-press-event
Just use the generic ::event signal for now.
2018-05-21 20:20:12 -04:00
Matthias Clasen
7644a9cd72 entry: Stop using ::key-press-event
Use a generic ::event handler instead.
2018-05-21 20:20:06 -04:00
Daniel Boles
acd05d09aa StyleContext: Don't advise using invalidate()
It doesn't exist anymore! Also, set_display() is not needed/used in the
demo cited, and we were still referring to gtk3-demo, not gtk4-demo.
2018-05-21 23:39:47 +01:00
Daniel Boles
19ed1b92b0 Range: Up should only mean ++ if we are a GtkScale
The last round of patches to get the desired direction of value move in
response to scrolls/keypresses on scales had the inadvertent side effect
of giving the opposite direction on scrollbars. Seeing as gtkrange.c is
already a collection of hacks, add another so that fix only holds if the
instance is a GtkScale, since that is what those patches were aimed at.

Close https://gitlab.gnome.org/GNOME/gtk/issues/1065
2018-05-21 20:21:25 +01:00
Matthias Clasen
33b8f087a3 emoji completion: Stop using key-press-event
The generic ::event signal will do.
2018-05-19 23:36:10 -04:00
Matthias Clasen
287c900bdb Remove key-press-event from more docs
This signal will be going away, so stop mentioning it so much.
2018-05-19 23:36:01 -04:00
Matthias Clasen
46da8a031b gtk-demo: Avoid key-press-event 2018-05-19 23:28:44 -04:00
Matthias Clasen
824bbf3117 popover: Drop key_press_event handler
We can do the same in the generic ::event handler.
2018-05-19 23:20:53 -04:00
Matthias Clasen
7928532bc5 emoji: Hide recent section when empty
This is part of https://gitlab.gnome.org/GNOME/gtk/merge_requests/143
by Julian Sperber.
2018-05-19 22:53:24 -04:00
Timm Bäder
3edd24fb01 widget: Properly remove event controllers in finalize
We were mutating the list while iterating over it. This was not a
problem before since remove_controller just set the controller pointer
to NULL instead of actually removing it from the list of controllers.
2018-05-19 23:03:32 +02:00
Timm Bäder
3a8607190f Add GtkEventControllerKey to the docs 2018-05-19 12:38:44 +02:00
Timm Bäder
0aad5da1b3 widget: Remove controller sequence-state-changed signal connection
We can avoid a signal connection per event controller (and the
EventControllerData struct) since every event controller knows the
widget it's attached to.
2018-05-19 10:18:50 +02:00
Timm Bäder
5c339f2844 Add basic searchbar set_key_capture_widget tests
Make sure we're correctly resetting the internal key capture widget
pointer when the widget goes away.
2018-05-19 10:18:50 +02:00
Timm Bäder
8f289227aa searchbar: Add missing GDK_AVAILABLE_IN_ALL marker 2018-05-19 10:18:50 +02:00
Timm Bäder
662e2b1641 snapshot: Remove superfluous typedef
We're already doing this in gtktypes.h

Fixes #214
2018-05-19 10:18:50 +02:00
Timm Bäder
5ff4ef14e6 widget: Directly notify gestures of grab
Since each widget has a list of event controllers now, we don't need to
connect to ::grab-notify of the widget for every controller.
2018-05-19 10:18:50 +02:00
Timm Bäder
f13cccd042 widget: Fix measure docs
Fix a typo and don't ever pass NULL to a ::measure() implementation.
2018-05-19 10:18:50 +02:00
Timm Bäder
c8aa5b8b4e gl renderer: Add helper for printing a render node tree 2018-05-19 10:18:50 +02:00
Timm Bäder
f71b2ee79f gestures demo: widget property is not writable
Use gtk_widget_add_controller instead.
2018-05-19 10:18:50 +02:00
Timm Bäder
a0d0b52034 scrollbar: Remove get_wheel_delta
Unused and undocumented.
2018-05-19 10:18:50 +02:00
Timm Bäder
caaa3f8200 cssvalue: Remove typechecks
This path is more than hot and those type checks ruin any kind of real
life profiling.
2018-05-19 10:18:50 +02:00
Fabio Tomat
90ac5f3755 Update Friulian translation 2018-05-18 16:19:35 +00:00
Matthias Clasen
84364a7ef4 emoji: Improve section scrolling
Leave some space above the section heading when scrolling.

This is a part of https://gitlab.gnome.org/GNOME/gtk/merge_requests/143
by Julian Sperber.
2018-05-17 16:42:00 +01:00
Matthias Clasen
daca4b9a39 Merge branch 'wip/restart-cursor-animation' into 'master'
wayland: Fix restarting cursor animation

See merge request GNOME/gtk!149
2018-05-17 09:59:45 +00:00
Matthias Clasen
1d368b0cd8 Merge branch 'paste-scrolling' into 'master'
textview: Don't scroll for pastes in another view

See merge request GNOME/gtk!152
2018-05-17 09:48:36 +00:00
Emmanuele Bassi
6656130f9c Merge branch 'pages-docs' into 'master'
Publish master docs with gitlab pages.

See merge request GNOME/gtk!135
2018-05-15 08:51:37 +00:00
Chun-wei Fan
9332237bd4 gtkemojicompletion.c: Don't use g_autoptr()
This code is also built with non-GCC/non-CLang compilers, so don't use a
GCCism here.
2018-05-15 13:49:45 +08:00
Chun-wei Fan
04b4c077f6 gdkcairocontext*.h: Include cairo.h consistently
The other sources include cairo.h by just using #include <cairo.h>, so
do likewise here.
2018-05-15 13:49:45 +08:00
Matthias Clasen
71718b9cd1 textview: Don't scroll for pastes in another view
GtkTextView scrolls to the insertion point when the text
buffer signals a paste is done. This is wrong when there
are multiple views on the same buffer, and the paste
happened in another view.

To fix this, flip the handling of the scroll_after_paste
boolean to only be TRUE if we know that we want to scroll.
2018-05-14 13:03:34 +01:00
Fabio Tomat
d7aa13a8e6 Update Friulian translation 2018-05-14 11:12:37 +00:00
Fabio Tomat
e46d286882 Update Friulian translation 2018-05-14 05:21:23 +00:00
Mohammed Sadiq
9a79b090df appchooserdialog: Fix memory leak 2018-05-13 14:57:04 +05:30
Mohammed Sadiq
b59a8c2911 appchooserdialog: Don't fire notify::heading twice
The gtk_app_chooser_dialog_set_heading() function do emit
notify::heading. Since the setter simply calls the function,
the setter itself shouldn't emit a notify signal by itself.
2018-05-13 14:56:49 +05:30
Mohammed Sadiq
0cd9ef8bcf aboutdialog: Fix memory leak 2018-05-13 14:56:34 +05:30
Mohammed Sadiq
1f82697e99 video: Fix memory leak 2018-05-13 14:56:22 +05:30
Mohammed Sadiq
7ddad8aa62 examples: Remove unused variables 2018-05-12 17:32:16 +05:30
Mohammed Sadiq
14e5218753 snapshot: Fix typo in documentation comment 2018-05-12 09:31:32 +05:30
Mohammed Sadiq
8410d87eb5 label: Rearrange struct members
Rearranging so can save us 8 bytes per GtkLabel
on 32/64 bit aligned memory.
Not a big count, but we get it for free.
2018-05-11 16:10:03 +05:30
Mohammed Sadiq
3c7ea78d68 textview: Always show select-all button in touch popup
"Select all" action is possible regardless of the text selection state
or if the text is editable or not.
2018-05-11 16:09:57 +05:30
Mohammed Sadiq
b73857faa9 textview: Reset bubble source id once run
The bubble_timeout_id was reset only on some special case.
And so warnings were shown when the source is being tried
to be removed with the already removed id.

Fix this by unconditionally resetting the id on start of the function.
2018-05-11 16:09:50 +05:30
Mohammed Sadiq
8e0cc8169e textview: Simplify creating bubble action buttons
Buttons can be created simply with gtk_button_new_from_icon_name().
2018-05-11 16:09:44 +05:30
Mohammed Sadiq
33bacb4150 widget: Avoid an unnecessary check
The preceding loop terminates when either the widget is NULL,
or if their type matches. There is no reason to check that again
2018-05-11 16:09:38 +05:30
Jonas Ådahl
a5d000cb5c wayland: Fix restarting cursor animation
When an animated cursor was set and the previous cursor animation delay
happened to be the same, we wouldn't restart the animation timeout and
just return G_SOURCE_CONTINUE assuming the timer would continue. This
assumption is however only valid if the function was called from the
timeout, which is not the case.

Instead also arm the timer also if there is no previous timer active.
2018-05-09 22:17:03 +02:00
Olivier Fourdan
d3885e92a7 wayland: check native surface for crossing events
gdk_wayland_*_grab()/ungrab() would emit crossing events which translate
as focus_in/focus_out events for keyboard.

However, the ungrab() functions compare the native toplevel as this is
what gets the Wayland pointer enter/leave events with the grab surface,
so if the grab is issued on a child gdk surface, those won't match and
we would emit more focus_out events than focus_in.

This means that a widget such as spice-gtk which issues a keyboard grab
whenever the pointer enters the surface and releases the grab when it
leaves the surface would get uneven numbers of focus_in/focus_out
events.

Also, gdk_wayland_seat_ungrab() would not emit crossing events for
keyboard devices, whereas gdk_wayland_device_ungrab() does, which adds
even more potential discrepancies between focus_in/focus_out events.

To solve this problem, introduce two new helper functions which check
the relevant native surfaces to emit crossing events when needed that
get called evenly from both gdk_wayland_seat_grab()/ungrab() and gdk
_wayland_device_grab()/ungrab() APIs.

Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=780422
Closes https://gitlab.gnome.org/GNOME/gtk/issues/792
2018-05-09 17:30:34 +02:00
Mohammed Sadiq
47872e5172 examples: Use icon-name property to set button icons
Gtk4 added an icon-name property for GtkButton.
2018-05-09 15:28:28 +05:30
Mohammed Sadiq
65b423eb05 examples: Simplify counting buffer lines
We do have a gtk_text_buffer_get_line_count() function
to get the line count.
2018-05-09 15:28:15 +05:30
Mohammed Sadiq
88ddda6d60 examples: Remove explicit gtk_widget_show()
In gtk4, widgets are visible by default.
2018-05-09 15:27:55 +05:30
Robert Ancell
e95eeaeef1 Fix comment typo introduced in a32725bc9a 2018-05-09 11:28:53 +12:00
Marek Cernocky
c831a77592 Updated Czech translation 2018-05-08 22:55:59 +02:00
Mohammed Sadiq
8fcc401e05 examples: Take advantage of user_data passed
The last parameter of the signal callback from .ui
is the template's object from which the class is
derived.

And so, we already have access to the window object.
Let's just use it.
2018-05-08 18:55:48 +05:30
Emmanuele Bassi
f07b131362 ci: Disable tests when building Graphene
Our flatpak-builder manifests include building Graphene from Git; since
we're building the GTK demos, it's pointless to build the Graphene tests
as well. Disabling tests and benchmarks avoids pointless installations
inside the Flatpak build repo that will just be removed by the time we
bundle the demo.
2018-05-08 14:20:00 +01:00
Emmanuele Bassi
b702618ed9 docs: List private headers for gtk-doc to ignore
We have a lot of private headers that should not be used by gtk-doc when
scanning for symbols.
2018-05-08 14:20:00 +01:00
Emmanuele Bassi
1262d0c6e5 Avoid absolute paths when building the API reference
We should always use relative paths, or include_directories objects, to
allow using GTK as a subproject.
2018-05-08 14:20:00 +01:00
Daniel Mustieles
547e5bf128 Updated Spanish translation 2018-05-08 15:12:45 +02:00
Daniel Mustieles
ac6d42a119 Updated Spanish translation 2018-05-08 15:06:32 +02:00
Mohammed Sadiq
bf1c344443 examples: Don't use private members for final classes
Only derivable classes are required to have private members
so that derived classes can't override them.
2018-05-08 14:34:43 +05:30
Mohammed Sadiq
555c6d7ac7 reference: Replace reference to gtk3 with gtk4 2018-05-08 06:05:41 +05:30
Mohammed Sadiq
5242073547 reference: Use gtk+-4 for compilation in examples 2018-05-08 06:05:04 +05:30
Mohammed Sadiq
772c994fd0 examples: Simplify .ui files
Run gtk4-builder-tool recursively
2018-05-07 22:30:40 +05:30
Mohammed Sadiq
c5976fed9a examples: Fix Makefiles to use gtk4 for build 2018-05-07 22:29:32 +05:30
Benjamin Otte
34d1ebc562 dnd: Make "formats" a construct-only property
... and hide the member variable inside the DragContextPrivate.
2018-05-07 18:55:09 +02:00
Benjamin Otte
80f5fd8435 wayland: Remove stray if
Leftover from d056be4ea2.

I need more sleep when I need to fixup the fixups of my fixups now.
2018-05-07 18:55:09 +02:00
Benjamin Otte
2ce2a80d40 win32: Remove unused file 2018-05-07 18:55:09 +02:00
Benjamin Otte
fa0a44e811 Merge branch 'wip/sadiq/fixes' into 'master'
icon-browser: Fix typo in description

See merge request GNOME/gtk!138
2018-05-07 15:54:26 +00:00
Mohammed Sadiq
67becb4510 icon-browser: Fix typo in description
This is shown as tooltip-text
2018-05-07 20:50:27 +05:30
Benjamin Otte
69644993f6 gsk: Improve GSK_RENDERER behavior
1. Include the broadway renderer (so we can test it properly fails on
   Wayland or X11)
2. List all potential renderers, print useful information when Vulkan
   is not compiled in instea dof omitting it
3. Improve docs
2018-05-07 16:45:32 +02:00
Benjamin Otte
d056be4ea2 wayland: Fix memleak
7f8a8f221d forgot to free the data offer
passed to it.
2018-05-07 16:28:50 +02:00
Matthias Clasen
3c05a6662b Update docs for debug environment variables
Just the usual pre-release doc fixups.
2018-05-07 07:47:18 -04:00
Matthias Clasen
5469bf0773 Document the GSK_RENDERER environment variable
Just the usual pre-release doc fixups.
2018-05-07 07:47:18 -04:00
Matthias Clasen
335a8aa843 Update build docs
Just the usual pre-release doc fixups.
2018-05-07 07:47:18 -04:00
Matthias Clasen
f5a2ab38f3 Miscellaneous docs improvements
Just the usual pre-release doc fixups.
2018-05-07 07:47:18 -04:00
Matthias Clasen
766185bce5 Add GtkWidgetPaintable to the docs
Just the usual pre-release doc fixups.
2018-05-07 07:47:18 -04:00
Matthias Clasen
c7fd3ebbaf Add GdkPaintable to the docs
Just the usual pre-release doc fixups.
2018-05-07 07:47:18 -04:00
Daniel Boles
e1f1fe9ba6 MediaStream: Fix capitalisation of two new %TRUEs 2018-05-06 21:46:30 +01:00
Matthias Clasen
79e54929a2 Add more media docs 2018-05-06 15:57:10 -04:00
Jordan Petridis
f4a0109377 gitlabci: Build and publish docs with gitlab pages. 2018-05-06 19:56:15 +03:00
Benjamin Otte
7f8a8f221d wayland: Redo DND offer handling
Instead of tracking offers in GdkWaylandSelection objects, track the
pending offer in the GdkWaylandSeat and pass it to the GdkDragContext
once we get an enter event.
2018-05-06 02:10:20 +02:00
Benjamin Otte
03a85ff2a0 gdk: Remove unnecessary assignments
The variable is never read again.
2018-05-06 02:10:20 +02:00
Matthias Clasen
f569717a03 Add media support to docs 2018-05-05 18:28:19 -04:00
Matthias Clasen
7fdf3d1769 Fixes to the gtk docs 2018-05-05 18:03:31 -04:00
Matthias Clasen
702deee799 Add some more content to the migration guide 2018-05-05 13:33:36 -04:00
Matthias Clasen
a34f35d587 More NEWS 2018-05-05 13:33:36 -04:00
Daniel Boles
901aa59b5b GesturePan: Remove widget parameter from docs, too
71991270b0 (note_112519)
2018-05-05 10:51:24 +01:00
Timm Bäder
f6a79559e9 inspector: Don't add controllers to non-window toplevels
That doesn't make sense in this context and breaks grabs.
2018-05-05 09:06:22 +02:00
Timm Bäder
64849426ae inspector: Use unique names for g_object_set_data calls
Otherwise the calls of the different inspector pages might end up
clashing.
2018-05-05 09:05:02 +02:00
Timm Bäder
d1cdb9b5cf widget: Clarify add_tick_callback docs
You don't pass the callback to remove_tick_callback, but the id returned
from add_tick_callback.
2018-05-05 07:39:55 +02:00
Timm Bäder
e379ea617a stylecontext: Draw arrow-less insertion cursors as color nodes
This lets us avoid an often used cairo node.
2018-05-05 07:25:10 +02:00
Timm Bäder
f44959fa59 stylecontext: Remove outdated comment
gtktextview:invalidate_cursor_windwo is no more.
2018-05-05 07:25:10 +02:00
Timm Bäder
af27199102 widget: Directly access priv pointer in even controller API
Spares us a few lines.
2018-05-05 07:25:10 +02:00
Christian Hergert
613f7609c2 build: fix meson.build when quartz is used
We need access to the variable earlier in the file when the quartz
backend is being setup.
2018-05-04 17:46:08 -07:00
Piotr Drąg
0f0be1ee8e Update Polish translation 2018-05-04 21:48:33 +02:00
Matthias Clasen
db095f8cdb Update NEWS 2018-05-04 15:37:48 -04:00
Matthias Clasen
4a72cab818 Document gdk_drop_read_async 2018-05-03 22:04:28 -04:00
Matthias Clasen
e191015aa0 The legacy event controller is still private 2018-05-03 20:45:36 -04:00
Matthias Clasen
45db4a5550 Merge branch 'wip/xdg-shell' into 'master'
xdg shell (stable)

See merge request GNOME/gtk!35
2018-05-04 00:43:01 +00:00
Matthias Clasen
0069de7e75 Merge branch 'altBackspaceEmacs' into 'master'
Add binding for <alt>BackSpace to emacs keys

See merge request GNOME/gtk!96
2018-05-04 00:39:39 +00:00
Matthias Clasen
be2853e5de emoji chooser: Match search terms better
Use g_str_match_string for better results.
2018-05-03 20:36:19 -04:00
Emin Tufan Çetin
0ab4bc80ad Update Turkish translation 2018-05-03 07:04:43 +00:00
Benjamin Otte
35e74a1501 win32: Fix build 2018-05-03 01:56:44 +02:00
Benjamin Otte
eb9105acea dnd: Add a private struct
And put member veriables into it.

Also fix backends to use accessors instead of direct access.
2018-05-03 01:31:40 +02:00
Benjamin Otte
8366ef71c0 dnd: Remove gdk_drop_reply()
It was only necessary for Motif DND, and we don't support that anymore.
2018-05-03 01:31:40 +02:00
Benjamin Otte
fb53568c04 gdk: Remove gdk_drag_grop_succeeded()
It's unused and most backends don't implement it.
2018-05-03 01:31:39 +02:00
Timm Bäder
622a150bb4 snapshot: merge container nodes
A container node inside another container node doesn't make a lot of
sense, we can instead just use the parent container node and add the
child container node's children to it directly.
2018-05-02 19:48:34 +02:00
Timm Bäder
2815054820 recorder: Fix cairo node display
We can only upload image surfaces as a texture but cairo nodes use
recording surfaces now.
2018-05-02 19:48:34 +02:00
Timm Bäder
31e0aaf6b0 gl renderer: Remove ops debug message
Without a node name, this doesn't make much sense anymore.
2018-05-02 19:48:34 +02:00
Matthias Clasen
ee82d73d7a Merge branch 'wip/lantw/gtk4-use-dev-evdev-input-h-on-freebsd' into 'master'
wayland: Use dev/evdev/input.h on FreeBSD (GTK4)

See merge request GNOME/gtk!133
2018-05-02 10:55:38 +00:00
Matthias Clasen
0f4084946a Add missing types to gtk docs 2018-05-01 23:26:28 -04:00
Matthias Clasen
1185b0b447 Add missing types to gdk docs 2018-05-01 23:22:13 -04:00
Ting-Wei Lan
7fed0b74ed wayland: Use dev/evdev/input.h on FreeBSD
The header linux/input.h used by GDK is specific to Linux. It is
possible to get a few Linux headers on FreeBSD by installing v4l_compat,
but it is usually better to use the one shipped with FreeBSD.

We prefer dev/evdev/input.h to linux/input.h here, so it will always use
dev/evdev/input.h on FreeBSD regardless of v4l_compat.

https://svnweb.freebsd.org/changeset/ports/465644
2018-05-01 22:28:57 +08:00
Timm Bäder
d506799e72 gl renderer: Ignore nodes outside of the clip
Pretty sure this will bite me later but for now we avoid rendering nodes
that we are not going to see anyway.
2018-05-01 15:13:11 +02:00
Timm Bäder
3a5a9d9233 gl renderer: Use simple offset for selected offset node children 2018-05-01 15:13:11 +02:00
Timm Bäder
e0205eb27c widget: add shortcut to gtk_widget_set_child_visible
So we don't do unnecessary work when just setting priv->child_visible to
the same value again.
2018-05-01 15:13:11 +02:00
Timm Bäder
a54e5844b6 widget: Don't mention gtk_widget_snapshot() in the docs
It's not public so people can't know about it.
2018-05-01 15:13:11 +02:00
Matthias Clasen
1dcb76bc26 Merge branch 'wip/carlosg/controller' into 'master'
carlosg/controller

See merge request GNOME/gtk!131
2018-05-01 12:35:53 +00:00
Jonas Ådahl
5f19421bc9 wayland: Various whitespace cleanups
Broke up a long line, added an empty one, indented another one, and re-aligned
a large amount of function parameter names that got misaligned in some past
refactoring.

https://bugzilla.gnome.org/show_bug.cgi?id=791939
2018-05-01 13:39:42 +02:00
Jonas Ådahl
a40923b03a wayland: Add support for xdg-shell stable
This commit adds support the stable version of the xdg-shell protocol.
Support for the last version of the unstable series is left intact, but
will not receive new features.

The stable version is prioritized above the older version.

https://bugzilla.gnome.org/show_bug.cgi?id=791939
2018-05-01 13:36:38 +02:00
Rico Tzschichholz
2cf55c1686 Fix some g-i annotation warnings 2018-05-01 12:35:32 +02:00
Matthias Clasen
422262436b Fix the modelbutton demo _again_
It lost the action-target properties again.
2018-04-30 20:49:34 -04:00
Emmanuele Bassi
97e43715fb Merge branch 'docs' into 'master'
gitlabci: Add gtk-doc to the container image.

See merge request GNOME/gtk!130
2018-04-30 16:21:21 +00:00
Jordan Petridis
50985d922a gitlabci: Add gtk-doc to the container image. 2018-04-30 19:04:38 +03:00
Benjamin Otte
995b29d8db Merge branch 'lrn/meson-intl' into 'master'
Link libgtk to libintl

See merge request GNOME/gtk!113
2018-04-30 12:25:43 +00:00
Benjamin Otte
5166767e8b Merge branch '169-gtktextview-accesses-already-disposed-object' into 'master'
Resolve "GtkTextView accesses already disposed object"

Closes #169

See merge request GNOME/gtk!109
2018-04-30 11:56:36 +00:00
Mario Blättermann
bf6aafe460 Update German translation 2018-04-30 10:42:41 +00:00
Benjamin Otte
bcb3a32686 Merge branch 'window-activate-grab-4-2.4' into 'master'
gdk: do not deactivate surface on keyboard grab

Closes #85

See merge request GNOME/gtk!120
2018-04-30 09:48:25 +00:00
Samuel Thibault
01455399e8 gdk: do not deactivate surface on keyboard grabs
When pressing e.g. a window manager shortcut, which acquires keyboard grab,
Xorg would send FocusOut NotifyGrab then FocusIn NotifyUngrab.  Currently
gdk would then deactivate the current surface, which makes accessibility
screen readers think that we have switched to a non-accessible application
and came back again, and thus reannounce the application frame etc. which we
don't want when e.g. just raising volume.

And actually, receiving FocusOut NotifyGrab does not mean losing the
X focus, it only means an application aqcuired a grab, i.e. it is
temporarily stealing keyboard events. On Wayland, this isn't even
notified actually.

This commit makes gdk only deactivate surfaces when there was an actual
focus switch to another window, as determined by has_focus_window (instead
of just has_focus), which happens either normally through FocusOut with
NotifyNormal, or during grabs through FocusOut with NotifyWhileGrabbed.

Fixes #85
2018-04-30 10:57:53 +02:00
Matthias Clasen
3684b72121 Misc documentation fixes
Close some gaps in gdk docs.
2018-04-28 22:34:14 -04:00
Matthias Clasen
059a181f7d Document GdkMemoryTexture 2018-04-28 16:22:29 -04:00
Matthias Clasen
a0f591297a More doc build fixes
If only the errors would make it back to stderr.
2018-04-28 16:02:34 -04:00
Matthias Clasen
b20e68cc91 More doc build fixes 2018-04-28 15:07:35 -04:00
Matthias Clasen
6b7be6643a Add offset nodes to the docs 2018-04-28 15:07:35 -04:00
Matthias Clasen
5e2103f7f0 Fix the gdk doc build
GdkDrawingContext no longer exists.
2018-04-28 15:07:35 -04:00
Fabio Tomat
8fecee4e41 Update Friulian translation 2018-04-28 09:19:30 +00:00
Benjamin Otte
4aaeb7de19 dnd: Make GdkDragContext::device a (construct-only) property
Also remove gdk_drag_context_set_device() and insist on backends using
the property.
2018-04-27 14:32:28 +02:00
Benjamin Otte
a86359af2b wayland: Create drop contexts on demand
Instead of creating and reusing the same one from start to finish.
2018-04-27 14:32:28 +02:00
Benjamin Otte
56cc470663 dragsource: Use capture phase for gesture
Otherwise buttons don't work as drag sources, and we like to do that.
2018-04-27 14:32:28 +02:00
Benjamin Otte
aca20dbb78 gtk-demo: Always have at least 1 icon in the fishbowl
When changing the widget type, don't start out with 0 icons.
2018-04-27 14:32:28 +02:00
Kristjan SCHMIDT
3a4238e199 Update Esperanto translation 2018-04-26 23:24:32 +00:00
Руслан Ижбулатов
76855e8999 imcontextsimple: ensure W32 code only runs on W32 displays
gdk_win32_keymap_check_compose() shouldn't be called for
non-W32 displays (i.e. when using broadway or other backends
that could be made to run on Windows).
2018-04-26 17:50:55 +00:00
Carlos Garnacho
3675f9ccb2 gesturestylus: Port to new API model 2018-04-26 17:59:42 +02:00
Carlos Garnacho
15e00759c7 eventcontrollerkey: Port to new API model 2018-04-26 17:59:42 +02:00
Benjamin Otte
ba7849960e eventcontroller: Make widget no longer a construct-only property
The new API model is now complete. To set a widget on a controller, it
is now necessary to call gtk_widget_add_controller().
2018-04-26 17:59:42 +02:00
Benjamin Otte
c5f12a7326 padcontroller: Port to new API model 2018-04-26 17:59:42 +02:00
Benjamin Otte
4f3058f195 eventcontrollermotion: Port to new API model 2018-04-26 17:59:42 +02:00
Benjamin Otte
74dbb057ed eventcontrollerscroll: Port to new API model 2018-04-26 17:59:42 +02:00
Benjamin Otte
1e6eb1f8b9 draggesture: Port to new API model 2018-04-26 17:59:42 +02:00
Benjamin Otte
bf82149271 longpressgesture: Port to new API model 2018-04-26 17:59:42 +02:00
Benjamin Otte
4ddc94b293 multipressgesture: Port to new API model 2018-04-26 17:59:42 +02:00
Benjamin Otte
71991270b0 pangesture: Port to new API model 2018-04-26 17:59:41 +02:00
Benjamin Otte
66223aaa08 swipegesture: Port to new API model 2018-04-26 17:59:41 +02:00
Benjamin Otte
91efa37fcb zoomgesture: Port to new API model 2018-04-26 17:59:41 +02:00
Benjamin Otte
703d5340f1 rotategesture: Port to new API model 2018-04-26 17:59:41 +02:00
Benjamin Otte
6fb92a0ab9 legacycontroller: Port to new API model
We no longer set the widget on construction, but instead require an
explicit call to gtk_widget_add_controller().

This way, the reference handling becomes explicit and bindable.

Because gtk_widget_add_controller() is (transfer: full), we don't
even need to unref the controller after adding it.
And we don't need to keep track of it, because controllers get cleaned
up by GtkWidget.
2018-04-26 17:59:41 +02:00
Benjamin Otte
31de97749a filechooser: Put event controllers into ui file 2018-04-26 17:59:41 +02:00
Benjamin Otte
fa97236b62 placesviewrow: Put event controllers into ui file 2018-04-26 17:59:41 +02:00
Benjamin Otte
c2ec738a2e widget-factory: Put gesture into ui file 2018-04-26 17:59:41 +02:00
Benjamin Otte
0d7cf79b00 emojichooser: Put event controllers into ui file 2018-04-26 17:59:41 +02:00
Benjamin Otte
40a082de10 aboutdialog: Put event controllers into ui file 2018-04-26 17:59:41 +02:00
Benjamin Otte
9c0acf62b4 widget: Allow adding event controllers in ui files 2018-04-26 17:59:41 +02:00
Benjamin Otte
9af03fa602 widget: Expose gtk_widget_add_controller()
.. and gtk_widget_remove_controller().
2018-04-26 17:59:41 +02:00
Benjamin Otte
8ddba5ffcd eventcontroller: Move declaration
This is in preparation for exposing APIs in gtkwidget.c
2018-04-26 17:59:41 +02:00
Benjamin Otte
e01e9ce092 eventcontroller: Add vfuncs to (un)set widget
This is the first step towards refactoring how widgets deal with event
controllers.

In the future, the widget will treat controllers the same way it treats
child widgets:
1. The controllers will be created without a widget.
2. There will be gtk_widget_add/remove_controller() functions to add
   or remove controllers.
3. The widget will hold a reference to all its controllers.

This way we will ultimately be able to automate controllers with ui
files.
2018-04-26 17:59:41 +02:00
Adrian Johnson
b0bb7f3da4 Add gtk_printer_get_hard_margins_for_paper_size
to retreive paper size specific hard margins and use this
to set the hard margins in the print context.
(modified by Marek Kasik <mkasik@redhat.com>)

https://bugzilla.gnome.org/show_bug.cgi?id=686109
2018-04-26 14:19:55 +02:00
Fabio Tomat
9774b9fabd Update Friulian translation 2018-04-26 07:52:37 +00:00
Carlos Garnacho
77f4204bf4 menu: Set up callback with a return function
The function hooked up to the ::key-pressed signal should have
a return value. Pointed out by Peter Bloomfield.
2018-04-25 19:11:21 +02:00
Benjamin Otte
b442277fd4 comboboxtext: GTK_DISABLE_SINGLE_INCLUDES is not a thing
What you don't find when laughing at vcpkg having a CMake build file for
GTK.
2018-04-25 17:18:16 +02:00
Daniel Mustieles
f00361b246 Updated Spanish translation 2018-04-25 13:18:01 +02:00
Carlos Garnacho
aeda2ad049 notebook: Fetch directly current event state/device
gtk_get_current_event() returns a new reference to the event, it should
be freed across various return branches to avoid the event leak, or we
just fetch the little stuff we're interested in.
2018-04-25 02:17:39 +02:00
Carlos Garnacho
23f4724a23 range: Do not unconditionally stop events in event handler
Prevents keybindings from working on scales.
2018-04-25 02:16:35 +02:00
Carlos Garnacho
0547c0999f combobox: Do not unconditionally stop events in event handler
Prevents combobox menus from being closed.
2018-04-25 02:16:05 +02:00
Benjamin Otte
ae7a677346 cairocontext: Remove fallback implementations
Now that all Cairo contexts are ported to managing cairo surfaces
themselves, the old fallback code that didi the managing is no longer
needed.

Also clarify the behavior of gdk_cairo_context_cairo_create() wrt the
vfunc by doing the early exit and the clipping outside of it.
2018-04-24 23:24:55 +02:00
Руслан Ижбулатов
7002f08cc1 GDK W32: Switch to GdkCairoContext
* Remove DC refcounting (we trust GDK to always do
  begin_frame/end_frame calls in pairs)
* Now that there's no GDK-provided double-buffer up the stack,
  double-buffering is implemented here
  (though it's disabled by default - in my tests it didn't provide
   any visual improvements, but did decrease performance).
* For some reason delaying window resizes until the point where
  we need to blit the double-buffer into the window leads
  to visual glitches, so doulbe-buffered windows are resized
  in begin_frame, same as non-double-buffered ones.
* New code to clear the paint region, for all drawing modes.
  Hopefully, it isn't duplicated anywhere up the stack.
* GL has its own context now, so remove any GL-related comments.
* Layered windows are still used (because cairo actually works
  better with them)
* A bit more code re-use for layered windows
* Some functions that were local to gdksurface-win32.c are made
  usable for the whole backend
* Drag-indicator drawing is temporarily commented out to match
  a similar change in X11 backend
2018-04-24 23:24:55 +02:00
Alexander Larsson
8c5d31d11d broadway: Handle offset nodes 2018-04-24 23:24:55 +02:00
Alexander Larsson
b554f4be20 broadway: Handle cairo nodes of type recording surface 2018-04-24 23:24:55 +02:00
Alexander Larsson
a329de63ea broadway: Add and use GdkBroadwayDrawContext 2018-04-24 23:24:55 +02:00
Alexander Larsson
99c46f263e broadway: Add basic GdkCairoContext implementation 2018-04-24 23:17:14 +02:00
Alexander Larsson
9421cb8b3a broadway: Call _gdk_surface_update_size when resizing surface 2018-04-24 23:17:14 +02:00
Benjamin Otte
83ea0b3714 drawcontext: Only pass the region that matters
We used to pass 2 regions to GdkDrawCotnext.end_frame() but code was
confusing what they meant. So we now don't do that anymore and only pass
the region that matters: The frame region.
2018-04-24 23:16:58 +02:00
Benjamin Otte
fd686afeb2 drawcontext: Add gdk_draw_context_in_frame() API
This makes the previous gdk_draw_context_is_drawing() function public
under a new name.

I decided against the old name because we use the term "frame" for a
drawing operation, so I wanted to have this boolean flag reuse the term.
2018-04-24 23:16:58 +02:00
Benjamin Otte
6aa89f2163 drawcontext: Move variable into private struct
... and get rid of duplicate variable in the process.
2018-04-24 23:16:58 +02:00
Benjamin Otte
a865621519 gdk: Move begin/end_frame() functions
As they require a draw context and the draw context is already bound to
the surface, it makes much more sense and reduces abiguity by moving
these APIs to the draw context.

As a side effect, we simplify GdkSurface APIs to a point where
GdkSurface now does not concern itself with drawing anymore at all,
apart from being the object that creates draw contexts.
2018-04-24 23:16:58 +02:00
Benjamin Otte
48fc18c37b gdk: Get rid of GdkDrawingContext
All information is kept in GdkDrawContext these days, so use that one.
2018-04-24 23:16:58 +02:00
Benjamin Otte
c6ae0ff2d1 gdk: Get rid of gdk_drawing_context_get_clip()
Use the identical gdk_draw_context_get_frame_region() instead.
2018-04-24 23:16:58 +02:00
Benjamin Otte
dbe4f1d766 gdk: Add gdk_draw_context_get_frame_region()
This does the same as gdk_drawing_context_get_clip().
2018-04-24 23:16:58 +02:00
Benjamin Otte
e7d6648f46 gdk: Remove gdk_gl_context_get_damage()
Remove it only form public API, because we still use the vfunc to figure
out the damage area in begin_frame().
2018-04-24 23:16:58 +02:00
Benjamin Otte
4d481ecb95 gsk: Refactor damage computation for GL renderer
Previously, we got the damage, then computed the changed area, then
started a frame with that changed area.

But starting a frame computes the damage for us.

So now we start a frame, then get the damage area from that, then
compute the change area.
2018-04-24 23:16:58 +02:00
Benjamin Otte
4aac0760b3 wayland: Rewrite Cairo rendering
Also, split it into its own file - which was the original reason for
looking at this code, the rewrite was an unintentional side effect.

This changes the context to create surfaces on demand.
So whenever the compositor holds onto a surface while GDK wants to
render, it just creates a new surface. If the compositor releases
surfaces, we will retain one for the next frame to be rendered, but free
all extra ones.
This way, we should get to a stage where we have exactly as many
surfaces as needed and never allocate/free any.
2018-04-24 23:16:58 +02:00
Benjamin Otte
03e6cefe73 x11: Move implementation of Cairo context backends
Also, don't implement SurfaceClass.ref_cairo_surface() anymore. This
means calls to it will crash now. But as they only happen in the generic
GdkCairoContext implementation, we shouldn't be affected by that.

Plus, once all backends have been ported, that call is going away
anyway.
2018-04-24 23:16:13 +02:00
Benjamin Otte
c48d78525e surface: Merge function into only caller 2018-04-24 23:16:13 +02:00
Benjamin Otte
899674d445 gdk: Remove GDK_DEBUG=cairo-image
This is the default now - at least until cairo rendering gets split
into backends.
2018-04-24 23:16:13 +02:00
Benjamin Otte
54a83d0288 surface: Fold function into only user 2018-04-24 23:16:12 +02:00
Benjamin Otte
7a6871ea5f cairocontext: Turn cairo_create() function into a vfunc 2018-04-24 23:16:12 +02:00
Benjamin Otte
a6553b0e20 gdk: Remove unused GL setting 2018-04-24 23:16:12 +02:00
Benjamin Otte
813e9c95fb gdk: Add Cairo context implementations for all backends
And make the GdkCairoContext as abstract.

The idea of this and thje following commits is to get rid of all
Cairo code in gdksurface.c (and $backend/gdksurface-$backend.c)
by moving that code into the Cairo context files.
In particular, the GdkSurfaceClass.begin_frame/end_frame()
functions (which are currently exclusively used by the Cairo code
should end up being moved to GdkDrawContextClass.begin/end_frame().

This has multiple benefits:

1. It unifies code between the different drawing contexts.
   GL lives in GLContext, Vulkan in VulkanContext and Cairo in
   CairoContext. In turn, this makes it way easier to reason about
   what's going on in surface-specific code. Currently pretty much
   all backends do things wrong when they want to sync to drawing
   or to the frame clock.

2. It makes the API of GdkSurface smaller. No drawing code (apart
   from creating the contexts) needs to remain.

3. It confines Cairo to the Drawcontext, thereby making it way
   more obvious when backends are still using it in situations
   where it may now conflict with OpenGL (like when doing the dnd
   failed animation or in the APIs that I'm removing in this
   branch).

4. We have 2 very different types of Cairo contexts: The X/win32
   model, where we have a natively supported Cairo backend but do
   double buffering ourselves and use similar surfaces and the
   Wayland/Broadway model where we use image surfaces without any
   Cairo backend support and have to submit the buffers manually.
   By not sharing code between those 2 versions, we can make the
   actual code way smaller. We also get around the need to create
   1x1 image surfaces in the Wayland backend where we pretend
   there's a native Cairo surface.
2018-04-24 23:16:12 +02:00
Benjamin Otte
a83487a0c4 cairocontext: Move a function
A function of GdkDrawingContext is only used when drawing with Cairo, so
move it to GdkCairoContext.
2018-04-24 23:16:12 +02:00
Benjamin Otte
52de880c1c gdk: Move Cairo code from surface to CairoContext
This just moves code, no actual changes to functionality are happening.
2018-04-24 23:16:12 +02:00
Benjamin Otte
f396786051 gdk: Add GdkCairoContext
This does nothing but disallow passing NULL to gdk_surface_begin_paint()
and instead require this context.

The ultimate goal is to split out Cairo drawing into its own source file
so it doesn't clutter up the generic rendering path.
2018-04-24 23:16:12 +02:00
Benjamin Otte
2210b9a302 gtk-demo: Merge widgetbowl into fishbowl 2018-04-24 21:55:37 +02:00
Benjamin Otte
aa2f415283 demo: Clean up GtkFishbowl widget
1. Remove set_icons property
2. Make it a GtkWidget subclass
3. Add gtk_fishbowl_set_creation_func()
4. Make the widgetbowl use the new benchmarking infrastructure of the
   fishbowl
2018-04-24 21:55:37 +02:00
Benjamin Otte
db5b8ca997 demo: Move benchmarking implementation to fishbowl widget 2018-04-24 21:55:37 +02:00
Kristjan SCHMIDT
8756748525 Update Esperanto translation 2018-04-24 19:17:30 +00:00
Daniel Boles
1e5c79ed47 testentrycompletion: Use the model we already got
cherry-pick of gtk-3-22 commit af350b20b1
2018-04-24 13:45:49 +01:00
Stas Solovey
dbdd3bf179 Update Russian translation 2018-04-24 10:32:36 +00:00
Benjamin Otte
1e0eed79b5 snapshot: Get rid of record_nodes flag
Instead, use GTK_DEBUG=snapshot for it.
2018-04-24 04:06:58 +02:00
Benjamin Otte
b49dccb86d rendernode: Remove gsk_render_node_set_name()
And of course, gsk_render_node_get_name() is gone, too.
The replacement is of course debug nodes.

As a side effect, GskRenderNode is now *really* immutable.
2018-04-24 04:06:58 +02:00
Benjamin Otte
73b4a62f51 snapshot: Redo debug messages
Instead of every snapshot function having debug messages, have an
explicit gtk_snapshot_push_debug() function that appends a debug node.
2018-04-24 04:06:58 +02:00
Benjamin Otte
49f9d2108d gsk: Add GskDebugNode 2018-04-24 04:06:58 +02:00
Matthias Clasen
29d77be03f Merge branch 'wip/matthiasc/emoji-picker' into 'master'
Wip/matthiasc/emoji picker

See merge request GNOME/gtk!115
2018-04-24 00:38:20 +00:00
Matthias Clasen
8be12a2427 Drop Ctrl-Shift-e support
Now that we have Emoji completion, drop the rather limited
Ctrl-Shift-e support in GtkIMContextSimple, and leave this
sequence to input methods.
2018-04-23 18:54:43 -04:00
Matthias Clasen
f0f2dd743f widget-factory: add emoji completion to an entry 2018-04-23 18:54:43 -04:00
Matthias Clasen
5d80086470 entry: Add emoji completion
Pop up completions when the text in the entry matches :word:
This functionality has to be enabled using the enable-emoji-completion
property.
2018-04-23 18:54:43 -04:00
Matthias Clasen
1104a8fdb7 Add an emoji completion popup
This widget provides entry completion-like functionality
for Emoji codes like 😁 or 💋.
2018-04-23 18:54:43 -04:00
Matthias Clasen
e283ed5523 Export some entry functions privately
This will be used in the following commits.
2018-04-23 18:54:43 -04:00
Emmanuele Bassi
3f307c59bd wayland: Allow a NULL inhibitors hash table
The shortcuts inhibitors hash table is created when we create a
GdkWaylandWindow implementation for a GdkWindow, and it's destroyed once
we finalize the instance. The fake "root" window we create for the
Wayland display does not have a backing native window, so the shortcuts
inhibitors hash table is set to NULL; this causes a critical error
message when calling g_hash_table_destroy() on it. The finalization of
the root window happens when we close a display connection.

We should use g_clear_pointer(), instead, as it's NULL safe.

Without this change, the displayclose test fails, as all warnings are
considered fatal.
2018-04-23 18:54:43 -04:00
Ting-Wei Lan
2a87caf529 gtk-demo, testgtk: Don't pass an integer to fabs
It looks like a mistake which compilers are likely to warn.
2018-04-23 18:54:43 -04:00
Ting-Wei Lan
f57c1a2901 imcontextxim: Don't assign a variable to itself
This causes clang to show warnings.
2018-04-23 18:54:43 -04:00
Ting-Wei Lan
1517114d9f Fix header guards
They were found by clang.
2018-04-23 18:54:43 -04:00
Ting-Wei Lan
48af688940 build: Use cc.links to check linker arguments
Instead of hard-coding linker flags for a specific operating system and
a specific compiler, we can should cc.links to test them, so they can be
used on more operating systems and compilers.
2018-04-23 18:54:43 -04:00
Ting-Wei Lan
e882db2763 build: Make the default setting work on non-Linux Unix-like systems
All of the four platform-dependent backends are enabled by default. It
is usually a good default because it requires users to explicitly choose
backends they want to use. Rules in meson.build also automatically
disable unavailable backends for macOS, Windows, Linux, so users on
these 3 major platforms don't have to manually disable things when
running meson commands.

However, meson.build doesn't do the same thing for other Unix-like
systems, which is acceptable but not ideal. To make it easier to build
GTK+ on these systems, the Linux case, which enables X11 and Wayland and
disables Win32 and Quartz, is made the default for all operating systems
that are not Windows or macOS.

This commit also changes most 'host_machine.system()' calls to os_*
variables, which are easier to read and less likely to be used wrongly.
2018-04-23 18:54:43 -04:00
Daniel Mustieles
7bb98674d0 Update Spanish translation 2018-04-23 14:18:20 +00:00
Emmanuele Bassi
fc57d3b5a3 wayland: Allow a NULL inhibitors hash table
The shortcuts inhibitors hash table is created when we create a
GdkWaylandWindow implementation for a GdkWindow, and it's destroyed once
we finalize the instance. The fake "root" window we create for the
Wayland display does not have a backing native window, so the shortcuts
inhibitors hash table is set to NULL; this causes a critical error
message when calling g_hash_table_destroy() on it. The finalization of
the root window happens when we close a display connection.

We should use g_clear_pointer(), instead, as it's NULL safe.

Without this change, the displayclose test fails, as all warnings are
considered fatal.
2018-04-23 10:57:07 +01:00
Matthias Clasen
9178f74067 Merge branch 'wip/lantw/improve-freebsd-build-and-fix-warnings' into 'master'
Improve meson.build for FreeBSD and reduce the number of warnings during compilation

See merge request GNOME/gtk!123
2018-04-23 02:40:00 +00:00
Daniel Boles
e6deaa3a85 Widget: Add missing space in new warning 2018-04-22 23:12:18 +01:00
Daniel Boles
5c152192d7 themes: Fix a new comment
bah.
2018-04-22 22:21:35 +01:00
Daniel Boles
b92e688141 themes: Fix swapped borders on RTL PathBar buttons
.linked assumes the container is a GtkBox, which is documented as never
flipping children in RTL, so :first-child is always the left child, etc.
GtkBox does that by reordering its CSS nodes when the direction changes.

But most widgets don’t do that, so :first|last-child are 1st/last ADDED
and swap sides in RTL. GtkPathBar is so, and ignoring that in our themes
meant that in RTL, its left/right buttons got each other’s borders. Yuk!

This patch adds the groundwork for supporting widgets like that, via the
%linked_flippable placeholder, and applies that to override buttons in
  filechooser .path-bar.linked > button
so that the correct borders get applied to those buttons when using RTL.

Note that I select only PathBars within a FileChooser because we also
have NautilusPathBar, which also uses widget.path-bar – but *does* flip
its nodes for RTL already, so letting that get affected broke it again!

https://bugzilla.gnome.org/show_bug.cgi?id=772817
2018-04-22 22:06:50 +01:00
Daniel Boles
0401e031ad CheckMenuItem: Fix insert_after|before() here too
See the previous commit.

There may be other cases of these being swapped by Gadget conversions,
but hopefully someone else will find and fix those before I have to…

Close https://gitlab.gnome.org/GNOME/gtk/issues/200
2018-04-22 21:51:10 +01:00
Daniel Boles
95f65da038 MenuItem: Fix broken args to insert_before|after()
The widget & its parent were swapped to each other’s place in the calls.

https://gitlab.gnome.org/GNOME/gtk/issues/200
2018-04-22 21:49:41 +01:00
Daniel Boles
f36c8c219c Widget: Show widget name/addrs if fail to reparent
so we can more easily get an idea of where the problematic code is

https://gitlab.gnome.org/GNOME/gtk/issues/200
2018-04-22 21:49:41 +01:00
Daniel Boles
ae14fa4efd Widget: Trivially fix arg name in non-doc comment 2018-04-22 21:40:20 +01:00
Daniel Boles
5f7191b31a MenuButton: popover connects to menu_deactivate_cb
This was missed (even before my recent patches).

https://gitlab.gnome.org/GNOME/gtk/issues/199
2018-04-22 16:33:26 +01:00
Daniel Boles
279344a2e6 MenuButton: Disconnect newly added signal handler
Otherwise, we do stuff we shouldn't, as the failing pipeline showed:
https://gitlab.gnome.org/GNOME/gtk/pipelines/9431

https://gitlab.gnome.org/GNOME/gtk/issues/199
2018-04-22 16:33:26 +01:00
Daniel Boles
f403a311c9 MenuButton: Clarify NULL popup/over/menu/model doc 2018-04-22 16:11:18 +01:00
Daniel Boles
caa9255dd3 MenuButton: Drop ref to Popover on its ::destroy
Otherwise, if the Popover is destroyed before the MenuButton, the latter
still had a non-NULL but invalid instance and tried to use it in dispose

Close https://gitlab.gnome.org/GNOME/gtk/issues/199
2018-04-22 16:11:18 +01:00
Daniel Boles
1d636dc8d4 Entry: Show optional style classes in node diagram 2018-04-22 16:11:09 +01:00
Juan Pablo Ugarte
bc2fad6842 a11y/ScrolledWin|IconView: Connect signals safely
Use g_signal_connect_data() instead of g_signal_connect_object()
to make sure the callback gets disconnected when the data object
is destroyed. This avoids problems in garbage-collected bindings.

https://bugzilla.gnome.org/show_bug.cgi?id=789215
2018-04-22 16:11:08 +01:00
Piotr Drąg
bef44a0c9d Update Polish translation 2018-04-22 16:13:56 +02:00
Ting-Wei Lan
43a7f36993 gtk-demo, testgtk: Don't pass an integer to fabs
It looks like a mistake which compilers are likely to warn.
2018-04-22 21:59:13 +08:00
Ting-Wei Lan
d3f40dc771 imcontextxim: Don't assign a variable to itself
This causes clang to show warnings.
2018-04-22 21:57:10 +08:00
Ting-Wei Lan
77637dc73b Fix header guards
They were found by clang.
2018-04-22 21:57:10 +08:00
Ting-Wei Lan
ff1dd5009c build: Use cc.links to check linker arguments
Instead of hard-coding linker flags for a specific operating system and
a specific compiler, we can should cc.links to test them, so they can be
used on more operating systems and compilers.
2018-04-22 21:57:10 +08:00
Ting-Wei Lan
f922109a9c build: Make the default setting work on non-Linux Unix-like systems
All of the four platform-dependent backends are enabled by default. It
is usually a good default because it requires users to explicitly choose
backends they want to use. Rules in meson.build also automatically
disable unavailable backends for macOS, Windows, Linux, so users on
these 3 major platforms don't have to manually disable things when
running meson commands.

However, meson.build doesn't do the same thing for other Unix-like
systems, which is acceptable but not ideal. To make it easier to build
GTK+ on these systems, the Linux case, which enables X11 and Wayland and
disables Win32 and Quartz, is made the default for all operating systems
that are not Windows or macOS.

This commit also changes most 'host_machine.system()' calls to os_*
variables, which are easier to read and less likely to be used wrongly.
2018-04-22 21:57:10 +08:00
Benjamin Otte
7a09cd4cda widget: Position changes don't require a redraw
Well, they don't require a redraw of the widget, because the widget
itself didn't change.
They require a redraw of the parent, because that now displays the
widget in a different position.

And this means we can keep the cache of the widget's render node.

My fishbowl numbers are through the roof^W water surface. Vulkan gets
4000 now.
2018-04-22 02:57:47 +02:00
Benjamin Otte
c5bcc47ce7 demo: Don't add more icons all the time
If adding new icons takes longer than a second, the frame clock should
run before we add even more icons...
2018-04-22 02:57:47 +02:00
Timm Bäder
8d11e7685a build: Remove 'name' kwarg from has_function calls
They cause warnings with later meson versions.
2018-04-21 19:30:12 +02:00
Timm Bäder
f483fd539e build: Fix copy/paste error 2018-04-21 19:24:25 +02:00
Timm Bäder
5b453ecd19 Always use #ifdef for G_ENABLE_DEBUG
Release builds don't define it to 0, they just don't define it. Avoid
the compilation warning we get otherwise.
2018-04-21 19:18:20 +02:00
Timm Bäder
9b8ff8d6c3 sizerequestcache: Directly initialize some locals
Declaring them and initializing them in the same block of code without
an empty line in between is really just confusing.
2018-04-21 19:06:54 +02:00
Timm Bäder
1313234ae0 Use inlined gtk_widget_get_display version in a few places
We can safely do this whenever we already made sure that the given
pointer is a valid GtkWidget.
2018-04-21 19:06:21 +02:00
Timm Bäder
c3e02b2b22 widget: Add static inline version of gtk_widget_display()
Due to the few type checks in gtk_widget_get_display(), it was the
slowest part of a call to gtk_widget_query_size_for_orientation if the
in case of a cache hit.
2018-04-21 18:48:15 +02:00
Timm Bäder
1a24a360bd textview: Remove handling_key_event flag
It's not used anymore.
2018-04-21 15:45:47 +02:00
Timm Bäder
4f3c7cd48a gsk: Make gsk_text_node_new_with_bounds private
We pulled out the bounds calculation for performance reasons, but the
caller can't know how to properly compute them. Inside gtk+, we can do
that but it's not good enough for public API.
2018-04-21 11:20:15 +02:00
Timm Bäder
d74be1fcf0 gl renderer: Rename texture_id parameter to fbo_id
So this makes sense again.
2018-04-21 10:13:16 +02:00
Timm Bäder
ac268b1c5d widget: Use get_instance_private more often
To be more consistent with newer code. We can also save a few lines here
and there by pulling the priv initialization before the precondition
checks.
2018-04-21 10:06:57 +02:00
Timm Bäder
fae1bbb3fe sizerequestcache: Constify some locals
Make it clear that we only use them for lookups here.
2018-04-21 10:06:57 +02:00
Timm Bäder
bd855c11ab sizerequestcache: Use int instead of gint 2018-04-21 10:06:57 +02:00
Timm Bäder
bb412cdda1 sizerequest: Pull locals in closest scope 2018-04-21 10:06:57 +02:00
Timm Bäder
840504b60a snapshot: Fix some documentation problems 2018-04-21 10:06:57 +02:00
Timm Bäder
c948c9e51d viewport: Remove useless import
Just a debugging remnant
2018-04-21 10:06:57 +02:00
Timm Bäder
746c9dc278 viewport: Remove outdated comment 2018-04-21 10:06:57 +02:00
Timm Bäder
29f38056a9 gl renderer: Fix fallback node scaling 2018-04-21 10:06:57 +02:00
Matthias Clasen
cfa04805a3 Merge branch 'print-deserialize' into 'master'
printing: Be more careful when deserializing

See merge request GNOME/gtk!121
2018-04-20 21:37:13 +00:00
Matthias Clasen
6f4a77bb3c printing: Be more careful when deserializing
The GVariant we are getting here might not be coming
from GTK+, but rather from some other source. Best to
be forgiving and deal with missing data without crashing.

This was causing the GTK+ portal backends to crash on
print requests from Qt.
2018-04-20 16:58:36 -04:00
Daniel Mustieles
09037b261e Updated Spanish translation 2018-04-20 11:42:22 +02:00
Daniel Mustieles
9d746d4ec4 Revert "Update Spanish translation"
This reverts commit 8570d33e08.
2018-04-19 16:13:15 +02:00
Marco Trevisan (Treviño)
c15b64b720 stack: protect set_visible_child_name from NULL stack
Return with error if gtk_stack_set_visible_child_name is called
with NULL parameter


(cherry picked from commit 2ee5aee4a9)
2018-04-19 08:40:17 +00:00
Emmanuele Bassi
e30176a522 Merge branch 'gtkplacesview-finalization-fixes-master' into 'master'
Gtkplacesview finalization fixes

See merge request GNOME/gtk!119
2018-04-19 08:24:49 +00:00
Marco Trevisan (Treviño)
4900c3eb3b gtkplacesview: disconnect from server list monitor changes on destroy
It might happen otherwise that a change is recorded in between the
widget dispose and finalization, causing a crash when setting
the visible name for the GtkStack (as that will be NULL at that point)
2018-04-19 02:59:52 -05:00
Marco Trevisan (Treviño)
f9452957cd gtkplacesview: unset entry_pulse_timeout_id before removing it
Fixes a warning on widget finalize, when trying to remove an invalid
source.
2018-04-19 02:59:43 -05:00
Daniel Boles
06a1477f80 Scale: Document new optional classes on value node 2018-04-18 22:59:19 +01:00
Daniel Boles
45c8c8f934 Range: Make down/up keys act like down/up scrolls
Before now, down/up keys on H Ranges would increase/decrease value resp,
which is unintuitive & worse, contradicts what we already do for scrolls

Fix simply by moving to the new should_invert_move() as scrolls just did
– which also gets us the other benefits explained in the last 2 commits.

https://bugzilla.gnome.org/show_bug.cgi?id=407242
https://bugzilla.gnome.org/show_bug.cgi?id=791802
2018-04-18 18:36:55 +01:00
Daniel Boles
6985dde320 Range: Use should_invert_move() to scroll value
This fixes RTL and/or :inverted Ranges responding to a horizontal scroll
by moving the value/slider button in the opposite direction... See prev.

https://bugzilla.gnome.org/show_bug.cgi?id=791802
2018-04-18 18:36:55 +01:00
Daniel Boles
bc2a38a59e Range: Add should_invert_move() for scrolls & keys
This will be used in subsequent commits to fix the sign by which the
value is changed in response to directional scroll or keypress events.

The idea is: you have a movement to make – in the form of a delta that
follows widget directions, i.e. −1 means left or up, +1 means right or
down – and you want to know whether that delta needs to be inverted in
order to produce the intuitively expected directional change of :value.

The existing should_invert() is not sufficient: it just determines
whether to invert visually, but we need more nuance than that for input.

To answer that – while not doubling up the work for scrolls and keys – I
add a helper should_invert_move(), which considers other relevant state:

 • A parallel movement on priv->orientation should just use the existing
   should_invert(), which already worked OK for this case (not others).

 • Movements on the other orientation now depend on priv->orientation:

    ◦ For a horizontal Range, always invert, so up (i.e. −ve in terms of
      widget coords) always means increase value & vice-versa. This was
      done in get_wheel_delta(), but move it here for use with keys too.

    ◦ For a vertical Range, ignore :invert as it’s only relevant to the
      parallel orientation. Do not care about text direction here either
      as RTL locales do not invert number lines, Cartesian plots, etc.

This returns TRUE if the delta should be inverted before applying to the
value, and we can now use this function in both scroll and key handlers.

https://bugzilla.gnome.org/show_bug.cgi?id=407242
https://bugzilla.gnome.org/show_bug.cgi?id=791802
2018-04-18 18:36:09 +01:00
Benjamin Otte
2db43edbd6 snapshot: Don't handle clip anymore
If widgets want to clip things, they now need to do it themselves.

By not taking care of clip, we avoid the need to track clip. And by not
tracking clip, we can avoid all unnecessary cache invalidations that we
were doing for render nodes whenever the clip changed.

And when you are scrolling, the clip changes *a lot*.
2018-04-17 23:21:37 +02:00
Daniel Boles
3b2a03367c MenuShell: Avoid compiler warning re un/signed cmp
priv->button is a guint, but we assigned it to a local gint.

gtk/gtkmenushell.c:734:37: warning: comparison between signed and
  unsigned integer expressions [-Wsign-compare]
           if (button && (new_button != button) && priv->parent_menu_shell)
                                     ^
2018-04-17 20:53:48 +01:00
Daniel Boles
d13e78831b Menu|Item: Fix FIXME re non-const interned strings
These are members of the private struct, so it hurts no one to fix this.
2018-04-17 20:53:48 +01:00
Daniel Boles
4fae962a03 Menu: Remove redundant typecheck in private func
Everything that calls this already ensured we are a valid GtkMenu.
2018-04-17 20:40:21 +01:00
Daniel Boles
8fd0ee96a6 Menu: Update @accel_path annotation/description 2018-04-17 20:40:21 +01:00
Daniel Boles
48472a4b04 Menu: Typecheck AccelGroup passed via public API 2018-04-17 20:40:21 +01:00
Daniel Boles
24953ab1be Menu: Typecheck before dereferencing to get ->priv 2018-04-17 20:40:21 +01:00
Daniel Boles
2a7e5d5137 MenuShell: Sanitise take_focus bool via public API
We store in priv then compare it later, so better make sure it’s 0 or 1.
2018-04-17 20:40:21 +01:00
Daniel Boles
f6ba206d07 MenuShell: Typecheck the instance @ select_first()
since this is public API and therefore might get junk passed to it.
2018-04-17 20:21:05 +01:00
Daniel Boles
331f9762cc CellRenderer: Link to CellEditable.start_editing()
...from CellRenderer::start-editing, to point people in the direction of
info about the lifecycle of the Editable and how to do generic setup.

https://gitlab.gnome.org/GNOME/gtk/issues/154
2018-04-17 19:07:39 +01:00
Daniel Boles
aaf2e30a48 CellRenderer: Clarify doc of .start_editing()
Drop the line copied from .activate(), replace it with a description of
what this method actually does, and explain what a NULL result means.

https://gitlab.gnome.org/GNOME/gtk/issues/154
2018-04-17 19:07:39 +01:00
Daniel Boles
50feed4c28 CellRenderer: Entry is not the only CellEditable
so link to GtkCellEditable and note that GtkEntry is just one example.
2018-04-17 19:07:39 +01:00
Daniel Boles
0fd9362e91 CellRenderer|Editable: Don't @See_also subclasses
The documentation knows that from the inheritance hierarchy, without us
having to manually duplicate that info here. Link to each other instead.
2018-04-17 19:07:39 +01:00
Daniel Boles
bdb7815b0c CellEditable: Clarify doc on lifecycle of editable
* Note in the intro that we're really thinking about temporary widgets
* Mention a gotcha regarding GtkEntry and how ::focus-out stops editing
* Give some examples of what you'd want to do in ::editing-done
* Be a bit more precise about what ::remove-widget represents
* Summarise the lifecycle between Renderer/Editable in .start_editing()
* Emphasise again there that this should be viewed as a temporary widget

https://gitlab.gnome.org/GNOME/gtk/issues/154
2018-04-17 19:07:39 +01:00
Daniel Boles
59a8ffd35e CellEditable: Move arg description to right place
Move it from the body to the argument line, and while there, update
the deprecated (allow-none) to (nullable).
2018-04-17 19:07:39 +01:00
Daniel Boles
44682256a9 CellEditable: Fix grammar error in doc synopsis 2018-04-17 19:07:39 +01:00
Christoph Reiter
5b2153ad38 ci: move the docker image to gitlab.gnome.org 2018-04-17 19:09:34 +02:00
Daniel Mustieles
8570d33e08 Update Spanish translation 2018-04-17 16:25:45 +00:00
Marek Kasik
0abf8efd2f TextView: Don't access already disposed text mark
Instead of asking of TextMark for its buffer,
let's reference also the buffer in the SelectionData.

Closes #169
2018-04-17 16:01:54 +02:00
Emmanuele Bassi
e23b65e434 Add an issue template for crashers
Better to have separate templates than a large, "choose your own
adventure" one.
2018-04-17 09:39:31 +01:00
gogo
4bb48212a6 Update Croatian translation 2018-04-16 19:09:18 +00:00
Matthias Clasen
8b188c9b41 Merge branch 'code-owners' into 'master'
docs: Start defining the owners of code sections

See merge request GNOME/gtk!116
2018-04-16 16:38:50 +00:00
Emmanuele Bassi
0b4bfd5c93 docs: Start defining the owners of code sections
When filing a new merge request it's often hard to know who to ask for a
review; using the Git log doesn't always help — the person that touched
a file last may just be fixing the build or a compiler warning.

The `CODE-OWNERS` file format is something that GitHub uses in order to
pre-fill the list of reviewers:

  https://help.github.com/articles/about-codeowners/

Ideally, in the future, we'll be able to use this file with a bot like
homu to automatically go through newly filed merge requests and
automatically ask the relevant people for reviews, instead of doing this
manually.
2018-04-16 16:06:33 +01:00
gogo
d79f1fdbce Update Croatian translation 2018-04-16 13:45:29 +00:00
Christoph Reiter
f4857da08f ci: remove allow_failure from flatpak jobs again
It was added in 814b7d7bb7 due to too old wayland in the runtime.
5b160efc76 fixed it by bundling a newer wayland.
2018-04-16 11:54:47 +02:00
Matthias Clasen
3e9a68be83 No need to clear GTK_MODULES anymore
Not a variable we care about nowadays.
2018-04-15 22:03:50 -04:00
Matthias Clasen
651e7aa6a1 Spruce up config summary
Show all the options. Nothing to hide.
2018-04-15 22:03:38 -04:00
Matthias Clasen
5b160efc76 flatpak: Bundle wayland for now
We need a newer wayland than is available in the runtime
currently, so use the power of flatpak and bundle it.
2018-04-15 17:45:45 -04:00
Timm Bäder
b0e9dc4723 tooltip: Ignore events with pressed buttons
We dont' want to show tooltips in those cases.
2018-04-15 17:12:01 +02:00
Timm Bäder
4336c6412a gl renderer: Remove unused viewport member 2018-04-15 17:12:01 +02:00
Timm Bäder
172b0e7ea0 frame: Use underscores in widgets ids in the docs
They will work in composite widget templates this way.
2018-04-15 17:12:01 +02:00
Timm Bäder
bf08537885 frame: Remove priv pointer 2018-04-15 17:12:01 +02:00
Timm Bäder
be77e0d500 frame: Stop saving label and child allocation
We don't use them for anything anymore.
2018-04-15 17:12:01 +02:00
Timm Bäder
2f95b4dd70 Remove gtk_render_icon_surface
As part of removing all the cairo_surace_t usage. There's still
gtk_render_icon for the same purpose that takes a GdkTexture*
2018-04-15 17:12:01 +02:00
Timm Bäder
4b02982e1c widget: Use _set_has_tooltip everywhere
real_set_has_tooltip sounds like it's a vfunc implementation, but it
wasn't. The force parameter was also useless so just remove that.
2018-04-15 17:12:01 +02:00
Timm Bäder
914656b8b6 widget: Use priv pointer directly 2018-04-15 17:12:01 +02:00
Timm Bäder
5f02caf09b widget: Update docs to mention ::draw less 2018-04-15 17:12:01 +02:00
Christoph Reiter
3da9543b63 Revert "ci: Enable the a11y test suite"
This reverts commit 968a8e1cf0.

things still fail in the gitlab runner
2018-04-15 05:48:59 +02:00
Matthias Clasen
d48084dad9 font chooser: Allow tweaking fractions
This makes some sense, and frac is meant to be set globally.
2018-04-14 20:28:27 -04:00
Emmanuele Bassi
968a8e1cf0 ci: Enable the a11y test suite
The accessibility test suite only performs internal validation.
2018-04-14 16:15:52 +01:00
Emmanuele Bassi
e36adbac04 tests: Update the expected a11y dump results
Keep in sync with the current tree.

The changes are mostly caused by updates in the internal hierarchy of
composite widgets, and the fact that the order in which the widget tree
is traversed is not exactly stable.
2018-04-14 16:14:36 +01:00
Emmanuele Bassi
7bd5f8f69c tests: Split out the accessibility dump tests
Instead of having a single massive test running through the a11y
directory, we can split off each individual file into its own unit.

Having individual units has several advantages:

 - units are executed in parallel
 - it's easier to identify the failing units
 - logs for failed units are easier to read
2018-04-14 16:14:10 +01:00
Emmanuele Bassi
84a30e9524 ci: Use a common section for Flatpak jobs
Avoid repeating blobs of YAML manually, and use the proper YAML
mechanism to copy-paste blobs instead.
2018-04-14 16:13:50 +01:00
Timm Bäder
0a0c909e14 GskRenderer: Plug a memory leak 2018-04-14 12:50:17 +02:00
Timm Bäder
1db1a30339 flowbox: Remove unnecessary queue_draw call 2018-04-14 12:50:17 +02:00
Timm Bäder
1195bb3872 paned: Remove outdated comment
The cursor is not updated in state_flags_changed these days.
2018-04-14 12:50:17 +02:00
Timm Bäder
b48422d423 build: Print summary last 2018-04-14 11:47:02 +02:00
Timm Bäder
add82735bb gl renderer: Don't use texture ids in glBindFramebuffer calls 2018-04-14 11:47:02 +02:00
Timm Bäder
c18219c5a8 snapshot: don't create offset nodes inside offset nodes
It's pretty easy to make that one offset node.
2018-04-14 11:47:02 +02:00
Timm Bäder
fdfdada362 gl renderer: Increase GArray size by 2 up front
Since we know we will add two elements anyway.
2018-04-14 11:47:02 +02:00
Timm Bäder
3a995b41d7 widget: Avoid a dead assignment 2018-04-14 11:47:02 +02:00
Timm Bäder
497d2f8c50 tooltip: Avoid some possibly uninitialized values 2018-04-14 11:47:02 +02:00
Aron Xu
26f962eead po: fix zh_CN translation 2018-04-14 13:10:55 +08:00
Benjamin Otte
fc6018f192 wayland: Don't freeze the frame clock too early
We can't freeze the frame clock on commit, but only after-paint,
otherwise the frameclock will resume in the paint stage.

So freeze the frame clock at the end of the frame if we are waiting for
a frame callback.

Note; The diff is only lage because of indentation changes due to
avoiding early returns in favor of a branch.
2018-04-13 02:16:10 +02:00
Benjamin Otte
4aab8e970b gdk: Remove gdk_surface_create_similar_image_surface()
It's unused.
2018-04-12 14:04:33 +02:00
Benjamin Otte
7ef8696a7d gdk: Remove gdk_cairo_surface_create_from_pixbuf()
It's unused and people should use textures and snapshots anyway.
2018-04-12 14:04:20 +02:00
Benjamin Otte
9cecf123f3 widget-factory: Use a pixbuf instead of a surface
This gets rid of the last user of
gdk_cairo_surface_create_from_pixbuf().
2018-04-12 14:03:58 +02:00
Benjamin Otte
af6b2cdb37 testgtk: Don't set cairo surfaces as icons
The code expects textures these days, so use those.
2018-04-12 14:03:48 +02:00
Benjamin Otte
3a1c69dce6 gdk: Remove gdk_cairo_get_drawing_context()
It's unused.
2018-04-12 14:03:40 +02:00
Benjamin Otte
b9c8c146d2 tests: Use gdk_texture_save_to_png() where appropriate 2018-04-12 14:02:59 +02:00
Benjamin Otte
770866f265 texture: Add gdk_texture_save_to_png()
It's needed for debugging Timm's code, so better have it here than
hidden in my random-patch vault.
2018-04-12 14:02:59 +02:00
Benjamin Otte
39d930c065 drawingcontext: Remove unused APIs 2018-04-12 14:02:59 +02:00
Christoph Reiter
814b7d7bb7 ci: allow flatpak jobs to fail for now
We can easily revert this when things are fixed again.
2018-04-11 19:52:21 +02:00
Timm Bäder
0965812e37 scrolledwindow: Fix indicator revealing
We need to increase the scrollbar bounds size.
2018-04-11 19:14:55 +02:00
Timm Bäder
5e81761ad0 gl renderer: Slightly change ops_offset behavior
Add the given delta to the current one instead of replacing it.
2018-04-11 19:14:54 +02:00
Timm Bäder
0336825537 gl renderer: Don't draw all rounded clip nodes to a texture
We only need to do that if the rounde clip node intersects with the
outer one.
2018-04-11 19:14:54 +02:00
Руслан Ижбулатов
8c3ee6a38d Link libgtk to libintl
GTK does use libintl directly (in gtkmain.c, for example) and thus
needs to be linked to it (if found and/or needed).

Previously we most likely were getting libintl from glib, but
that stopped for some reason. Either way, explicit linking is
the right thing to do here.
2018-04-11 16:49:18 +00:00
Руслан Ижбулатов
20f12f9ed7 GDK W32: Fix a missing weak referencing
The changes in a82d67bb7d didn't
preserve a g_object_weak_ref() call that we need to ensure the
objects in hash map don't become stale. Fix this.
2018-04-11 16:39:34 +00:00
Emmanuele Bassi
8fa2db35f8 Merge branch 'gitlab-ci-ccache-again' into 'master'
gitlab-ci: Reenable ccache but disable it during the initial meson call

See merge request GNOME/gtk!111
2018-04-11 14:32:37 +00:00
Emmanuele Bassi
a2a99d27c9 Simplify the Wayland code generation
Instead of going through an ancillary script to strip away the
`WL_EXPORT` annotation from the generated code, we should bump up the
required version of Wayland, and use the `private-code` argument for
wayland-scanner, which does the right thing for us.
2018-04-11 15:06:43 +01:00
Christoph Reiter
c542115906 gitlab-ci: Reenable ccache but disable it during the initial meson call
There where some problems (??) with ccache not detecting changes during meson
checks. Setting CCACHE_DISABLE during the meson execution makes ccache not use
the cache and pass things directly to the compiler.
2018-04-11 15:33:00 +02:00
Timm Bäder
d7af16c8e4 gl renderer: Render everyhing according to MV scale
And not the surface's scale factor. This way the magnifier works.
2018-04-11 15:31:22 +02:00
Timm Bäder
cc66b50dcd gl renderer: Remove unused field 2018-04-11 15:31:22 +02:00
Emmanuele Bassi
d448be007e ci: Update container to Fedora 28
We're going to need updated dependencies that we cannot build as
subprojects, like wayland-protocols.
2018-04-11 13:58:47 +01:00
Benjamin Otte
2dd37e9624 widget: Not all toplevels are containers
Guard against GtkInvisible.
2018-04-11 04:04:37 +02:00
Benjamin Otte
b79c138100 widget: Only start/stop idle sizers for toplevels
They are the only widgets that have idle sizers.
2018-04-11 03:16:34 +02:00
Benjamin Otte
2abf082231 widget: Move frame clock handling to vfunc
Instead of connecting to / disconnecting from the frame clock, do it
inside the vfuncs next to changing the priv->realized boolean.

This removes a race between those 2 cases that could cause child
widgets' unrealize handlers to reconnect this widget to the frame clock
because it was still marked as realize when the widget had already
disconnected from the frame clock.

Fixes #168
2018-04-11 03:16:34 +02:00
Benjamin Otte
7ef8cb652b widget: Remove gtk_widget_set_realized()
Everybody chains up now.
2018-04-11 03:16:34 +02:00
Benjamin Otte
5abc4749de gtk: Chain up in toplevels' realize
Don't call set_realized() manually.
2018-04-11 03:16:34 +02:00
Benjamin Otte
5c51a302a4 widget: Make gtk_widget_real_realize() stricter
But in turn, also allow it to work on widgets with their own surface.

This way, we can chain up from everywhere and won't have to export
gtk_widget_set_realized().
2018-04-11 03:16:34 +02:00
Benjamin Otte
0af5316f00 widget: Assert unrealizing
Instead of just setting the flag, assert that it was set.
2018-04-11 03:16:34 +02:00
Benjamin Otte
2862ee7682 widget: Remove unused member 2018-04-11 03:16:34 +02:00
Benjamin Otte
3ee2aa1b22 container: Remove gtk_container_maybe_start_idle_sizer()
Fold it into gtk_container_start_idle_sizer()
2018-04-11 03:16:34 +02:00
Benjamin Otte
21f15094fb container: Remove gtk_container_queue_resize_handler()
It's the same as gtk_container_maybe_start_idle_sizer()
2018-04-11 03:16:34 +02:00
Benjamin Otte
3df94fe099 container: Use maybe_start_idle_sizer()
That way, we don't accidentally start an idle sizer for unrealized
widgets.
2018-04-11 03:16:34 +02:00
Benjamin Otte
e0415fccd7 window: Don't queue resize handler
It's not needed, because the queue_allocate() call right above it does
this work.
2018-04-11 03:16:34 +02:00
Benjamin Otte
b591d7bc20 widget: Don't queue resize handler twice
We already queue it when we set_alloc_needed(), so there's no need to do
it again.
2018-04-11 03:16:34 +02:00
Benjamin Otte
d6477d0894 container: Don't store the resize clock
Use gtk_widget_get_frame_clock() instead
2018-04-11 03:16:34 +02:00
Benjamin Otte
1738b80efd Merge branch 'gitlab-ci-mingw' into 'master'
gitlab-ci: mingw build

See merge request GNOME/gtk!105
2018-04-10 18:59:49 +00:00
Christoph Reiter
f26b2469af gitlab-ci: Add a 32bit mingw build 2018-04-10 19:24:15 +02:00
Emmanuele Bassi
14c8a603e3 Terminate strncpy() buffers correctly
When using strncpy() with a buffer we need to account for the
terminating NUL character. GCC 8 started warning when using PPD_MAX_NAME
as the buffer length for strncpy() because the buffer we're copying into
has the same length — which means that the terminating NUL may be
skipped if the source string has a length of PPD_MAX_NAME.

The appropriate way to handle the case where we're copying a source with
a length bigger than of PPD_MAX_NAME is, as reported in the strncpy()
documentation, to copy `PPD_MAX_NAME - 1` bytes, and explicitly NUL
terminate the destination buffer. This has the additional benefit of
avoiding the compiler warning.
2018-04-10 14:54:45 +01:00
Benjamin Otte
adc0159bdb wayland: Factor out frame timings request code
Also call the code everywhere we draw and not just with Cairo.
2018-04-10 15:13:38 +02:00
Benjamin Otte
e44bbeb558 filechooserbutton: Fix reserved pointers
So gcc stops complaining about unnecessary parenthesis.
2018-04-10 15:13:38 +02:00
Benjamin Otte
12063fe53e ffmpeg: Fix compile warnings for newest version 2018-04-10 15:13:38 +02:00
Timm Bäder
f24d0725ca vulkancontext: Add new error enum 2018-04-10 09:53:48 +02:00
Timm Bäder
3db4f805ee widgetfocus: Use gtk_widget_compute_bounds
Instead of gtk_widget_get_allocation.
2018-04-10 09:44:14 +02:00
Timm Bäder
3ce6355bf4 widget: Remove _get_own_allocation
Replace all usages of it with _compute_bounds
2018-04-10 09:43:47 +02:00
Timm Bäder
3a5b2f54ea widget: Remove gtk_widget_get_own_allocation
Use compute_bounds everywhere.
2018-04-10 09:43:47 +02:00
Timm Bäder
5d1f93796e widget: Remove get_own_allocation usages 2018-04-10 09:43:47 +02:00
Timm Bäder
b29ee2dc46 notebook: Use compute_bounds 2018-04-10 09:43:47 +02:00
Timm Bäder
d49d391fcd popover: Use gtk_widget_compute_bounds
Instead of the private get_own_allocation
2018-04-10 09:43:47 +02:00
Timm Bäder
3593fd2a29 toolbar: Avoid a get_own_allocation call
We want the content allocation here since we are allocation child
widgets.
2018-04-10 09:43:47 +02:00
Timm Bäder
44390c16b2 widget: Fix typo in compute_bounds docs 2018-04-10 09:43:47 +02:00
Timm Bäder
09f04633ca gdk: Protect against negative GDK_SCALE values
Using those should not happen.
2018-04-10 09:43:47 +02:00
Руслан Ижбулатов
27d9f233d4 GDK W32: use clock after_paint signal for timing updates
* Previous commit had misleading info. The code was
added to begin_paint() instead of end_paint(). Though
that did not affect its performance in any visible way.
* Company advised to move the code to an "after_paint" signal
handler, so that it works on all renderers, not just Cairo.
This change caused high fluctuation in FPS values in fishbowl
when it is put in a situation where it cannot achieve 60fps
(such as using Cairo renderer at ultra-high resolution).
This seems to be deliberate and not a bug.
2018-04-09 20:21:16 +00:00
Emmanuele Bassi
410b20f904 docs: Link to GResource
Since we're referring to GLib's functionality, might as well save some
time to the reader, and link to the GResource API reference page.
2018-04-09 20:55:51 +01:00
Daniel Boles
fae064d5f9 docs/reference/gtk/getting_started: cgit => GitLab
master version of b685eb1779
2018-04-09 20:55:14 +01:00
Руслан Ижбулатов
c7ef697029 GDK W32: set update frequency and timestamp
There is no easily apparent way of being notified when frame updates
happene exactly, so we just query frame info at the end of each paint.
If we query too often (faster than DWM refresh rate), we just get
the same values twice in a row, but that is, hopefully, highly unlikely.
2018-04-09 19:07:10 +00:00
Daniel Boles
b7291ce533 AccelGroup: Remove @See_also of deleted function
gtk_item_factory_new() is not a thing that exists.

Also, maybe the lack of space after the colon was what stopped the link
from rendering.
2018-04-09 19:45:10 +01:00
Benjamin Otte
0afdd84a2a css: Clipping changes don't need a queue_allocate() anymore
Now that queue_draw() isn't restricted to clip anymore, we don't need to
care about clip in the CSS engine either.

We do keep GTK_CSS_AFFECTS_CLIP around though because GtkWindow does
care for the window's size.
2018-04-09 20:20:55 +02:00
Benjamin Otte
78a9b5d1ed entry: Stop being activatable
Activating entries does not do anything.

Activate the default widget instead.
2018-04-09 20:20:55 +02:00
Daniel Boles
d77ede508c Merge branch 'master' into 'master'
gdk_x11_display_get_monitor: fix monitor number test logic

See merge request GNOME/gtk!107
2018-04-09 17:25:08 +00:00
Sébastien Villemot
bb8debe925 gdk_x11_display_get_monitor: fix monitor number test logic
When asked for a nonexistent (positive) monitor number,
gdk_x11_display_get_monitor would (at best) return an uninitialized pointer,
instead of returning NULL.
2018-04-09 18:07:14 +02:00
Benjamin Otte
bb8f6f87ae glcontext: Store the buffer age regions in the GL context
That way, we can store the right region there: The actual painted area
instead of the exposed area (which is way too small).

Also, the GL context is the only user of this data, so storing it there
seems way smarter.
2018-04-09 01:00:31 +02:00
Benjamin Otte
c8e38c6065 vulkan: Use new resize vfunc to recreate swapchain
... instead of checking sizes for every frame.
2018-04-09 01:00:31 +02:00
Benjamin Otte
a115f59950 drawcontext: Add a surface_resized() vfunc
Call this vfunc whenever the surface's size has changed.
2018-04-09 01:00:31 +02:00
Benjamin Otte
7ed0c85c61 surface: Track all draw contexts created for the surface 2018-04-09 01:00:31 +02:00
Benjamin Otte
e8fef1147f widget: Don't do a 0-size check before snapshotting
Even widgets with an empty allocation may still want to draw stuff.
Examples include shadows or child widgets with negative margins.

Fixes GtkEntry's progressbar not showing up anymore.
2018-04-09 01:00:31 +02:00
Daniel Boles
8d8db89669 testmodelbutton: Test :centered, :icon, :inverted
Test more stuff.
2018-04-08 18:48:16 +01:00
Daniel Boles
15b569e64d testmodelbutton: Fix wrongly overridding MB child
I was setting a GtkButton:label, which resulted in the ModelButton's own
custom children getting lost. That doesn't make for a useful test...
2018-04-08 18:48:16 +01:00
Daniel Boles
53a66c0f41 ModelButton: Use WARN_INVALID_PROPERTY, not assert
Do the same thing we do everywhere else for invalid properties.
2018-04-08 18:48:16 +01:00
Daniel Boles
7fd0d3ec51 ModelButton: Fix type Wether => Whether 2018-04-08 18:48:16 +01:00
Daniel Boles
08126ffdf2 testmodelbutton: Add explanatory comments to CSS
and load at an earlier, more sensible place, before creating any widgets
2018-04-08 18:48:16 +01:00
Daniel Boles
57c58f880b ModelButton: Protect against nonsensical gbooleans
the same way we do normally.
2018-04-08 13:17:18 +01:00
Daniel Boles
5bbb185e14 tests/testmodelbutton: Add this
and test whether :action-name, :role, and CSS nodes work as expected

https://gitlab.gnome.org/GNOME/gtk/issues/163
2018-04-08 13:17:18 +01:00
Timm Bäder
6cd53fc491 Merge branch 'wip/sadiq/fixes' into 'master'
listbox: Fix signal name is documentation

See merge request GNOME/gtk!106
2018-04-08 07:30:24 +00:00
Mohammed Sadiq
5ad31616e8 listbox: Fix signal name in documentation 2018-04-08 11:02:23 +05:30
Rico Tzschichholz
ff738269b6 Fix some g-i annotation warnings 2018-04-06 16:26:17 +02:00
Timm Bäder
58aa93be41 menu: Avoid an invalid read 2018-04-06 08:24:19 +02:00
Timm Bäder
d4e4904604 lockbutton: Remove priv pointer 2018-04-06 08:24:19 +02:00
Timm Bäder
b7f98314a5 widgetbowl: Add switch demo 2018-04-06 08:24:19 +02:00
Benjamin Otte
fb33110fd1 gtk-demo: Redo viewing of resources
1. Don't rely on GtkImage as a detector of file type anymore.
   Instead, hardcode all extensions that are in use.
2. Add a display method for videos.
2018-04-06 00:44:18 +02:00
Benjamin Otte
3eddbdc191 video: Add autoplay and loop boolean properties 2018-04-06 00:44:18 +02:00
Piotr Drąg
faaf828c74 Update POTFILES.in 2018-04-05 22:54:03 +02:00
Carlos Garnacho
acb950ffb5 gtkmenushell: Port to using GtkEventControllerKey 2018-04-05 19:26:55 +02:00
Carlos Garnacho
9a80b9e382 gtkcellrendereraccel: Port to using GtkEventControllerKey 2018-04-05 19:26:55 +02:00
Carlos Garnacho
362a6ca469 gtkentry: Use key controller to track focus changes 2018-04-05 19:26:55 +02:00
Carlos Garnacho
73fe140b10 gtkcalendar: Use key controller to track focus changes 2018-04-05 19:26:55 +02:00
Carlos Garnacho
b0cd5cd7c8 gtktextview: Use key controller for focus changes 2018-04-05 19:26:55 +02:00
Carlos Garnacho
3361fe1e62 gtkeventcontrollerkey: Add ::focus-in/out signals
And handle GDK_FOCUS_CHANGE events in order to emit those.
2018-04-05 19:26:55 +02:00
Carlos Garnacho
5a34d0f816 gtkeventcontrollerkey: Add get_group() call
Callers can use this function on a key-pressed/released signal
to find out the key event group, useful in a few places.
2018-04-05 19:26:55 +02:00
Carlos Garnacho
d724506abe gtkmenu: Stop using ::key-press-event
Use GtkEventControllerKey for the task
2018-04-05 19:26:55 +02:00
Carlos Garnacho
d5e826a660 gtkiconview: Stop using ::key-press-event
Use GtkEventControllerKey for the task
2018-04-05 19:26:55 +02:00
Carlos Garnacho
f291541769 gtkcellrendererspin: Stop using ::key-press-event
Use GtkEventControllerKey for the task
2018-04-05 19:26:55 +02:00
Carlos Garnacho
1fa6239509 appchoooserdialog: use search bar key capture API 2018-04-05 19:26:54 +02:00
Carlos Garnacho
0b3b81a8bf inspector: Use search bar API to capture key events from the toplevel 2018-04-05 19:26:54 +02:00
Carlos Garnacho
20c1e24b60 gtksearchbar/entry: Add [gs]et_key_capture_widget() API calls
This lets these widgets actively pull events from a widget, instead
of passively being fed events.
2018-04-05 19:26:54 +02:00
Carlos Garnacho
ad5f0a63a3 gtkwindow: Perform key activation in gtk_main_do_event()
In a similar spirit to the previous commit, make window shortcut
activation happen by default on toplevels, without relying on
legacy controllers.
2018-04-05 19:26:54 +02:00
Carlos Garnacho
6892b5c5ba gtkwidget: Activate key bindings through run_controllers()
Deferring a bit further making those a standalone controller, make
binding activation happen on run_controllers(), so it happens by
default on widgets (unless the key event was consumed earlier)
without the need of a legacy event controller.
2018-04-05 19:26:54 +02:00
Carlos Garnacho
d74ecfb02e gtkwidget: Break early if non-gesture controllers handle the event
Non gesture controllers have no means to collaborate with other
controllers, thus should be considered standalone entities. It makes
no sense to propagate any further if scroll/key controllers handled
the event.
2018-04-05 19:26:54 +02:00
Carlos Garnacho
695549d5a7 eventcontrollerkey: Add function to forward stuff elsewhere 2018-04-05 19:26:54 +02:00
Carlos Garnacho
b55696e551 gtkmain: Don't use special paths for key event propagation
Set the event_widget to the window focus, and let event capture/bubble
handling do the rest.
2018-04-05 19:26:54 +02:00
Carlos Garnacho
385fa18c27 gtkrange: Stop using ::key-press-event
Use GtkEventControllerKey for the task
2018-04-05 19:26:54 +02:00
Carlos Garnacho
cfdf4f650f gtkcellrendereraccel: simplify grabbing code 2018-04-05 19:26:54 +02:00
Matthias Clasen
df386f29ab combo box: Stop using ::key-press-event
Switch to using ::event.
2018-04-05 19:26:54 +02:00
Matthias Clasen
ec84fb90bf app chooser: Stop using ::key-press-event
For now, just switch to using ::event.
2018-04-05 19:26:54 +02:00
Carlos Garnacho
80c3ebe3a0 gtkentrycompletion: Stop using ::key-press-event
Use GtkEventControllerKey for the task
2018-04-05 19:26:54 +02:00
Carlos Garnacho
585aafc2df gtkplacessidebar: Stop using ::key-press-event
Use GtkEventControllerKey for the task
2018-04-05 19:26:54 +02:00
Carlos Garnacho
87b4dc4c67 gtktextview: Stop using ::key-press-event
Use GtkEventControllerKey for the task
2018-04-05 19:26:54 +02:00
Carlos Garnacho
5118f9817a gtkflowbox: Stop using ::key-press-event
Use GtkEventControllerKey for the task
2018-04-05 19:26:54 +02:00
Carlos Garnacho
568054a034 gtkentry: Stop using ::key-press-event
Use GtkEventControllerKey for the task
2018-04-05 19:26:53 +02:00
Carlos Garnacho
0d884d22fb gtkcolorswatch: Stop using ::key-press-event
Use GtkEventControllerKey for the task
2018-04-05 19:26:53 +02:00
Carlos Garnacho
6f4107c8de gtkcolorplane: Stop using ::key-press-event
Use GtkEventControllerKey for the task
2018-04-05 19:26:53 +02:00
Carlos Garnacho
5081472d97 gtkcalendar: Stop using ::key-press-event
Use GtkEventControllerKey for the task
2018-04-05 19:26:53 +02:00
Matthias Clasen
b033e30318 search bar: Stop using ::key-press-event
Use a key event controller instead.
2018-04-05 19:26:53 +02:00
Matthias Clasen
f231ac6541 Shortcuts window: stop using ::key-press-event
Use a key event controller instead.
2018-04-05 19:26:53 +02:00
Matthias Clasen
c971ca7c34 color editor: Stop using ::key-press-event
Use key event controllers instead.
2018-04-05 19:26:53 +02:00
Matthias Clasen
4990842981 about dialog: Stop using ::key-press-event
Use a key event controller instead.
2018-04-05 19:26:53 +02:00
Matthias Clasen
21d1ab42d1 icon-browser: Stop using ::key-press-event 2018-04-05 19:26:53 +02:00
Matthias Clasen
6d1b21a028 places view: Stop using ::key-press-event 2018-04-05 19:26:53 +02:00
Matthias Clasen
c2bd7fcf35 inspector: Stop using ::key-press-event 2018-04-05 19:26:53 +02:00
Matthias Clasen
75024fea60 testgtk: Drop snapshot
This needs to be redone with modern snapshotting infrastructure.
Lets drop it for now, it is somewhat duplicative with inspector
features.
2018-04-05 19:26:53 +02:00
Matthias Clasen
98f31e61d7 testgtk: Drop the event watcher
This is not a very useful test, and it is hard to keep working
in an event controller world.
2018-04-05 19:26:53 +02:00
Matthias Clasen
2cc85df62b docs: Modernize an example
The signals that are showcased here are going away.
2018-04-05 19:26:53 +02:00
Matthias Clasen
918d552472 gtk-demo: Stop using ::key-press-event in font explorer
Use a key controller instead. Note that this currently
breaks the handling of Enter, since we activate key bindings
twice, causing us to switch to the label and back.
2018-04-05 19:26:53 +02:00
Matthias Clasen
8d396991db testsuite: Don't use ::key-press-event
We don't need it here.
2018-04-05 19:26:53 +02:00
Matthias Clasen
19bd57ed1f file chooser: Use a key event controller
We want to get rid of ::key-press-event.
2018-04-05 19:26:53 +02:00
Carlos Garnacho
b1eaeebe7d demos: Add "Paint" demo 2018-04-05 19:26:53 +02:00
Carlos Garnacho
f0c8e9de4f gtk: Add GtkGestureStylus
This is a GtkGesture done to deal with stylus events from drawing tablets.
Those have a special number of characteristics that extend a regular
pointer, so it makes sense to wrap that.
2018-04-05 19:26:53 +02:00
Carlos Garnacho
58eaf5ca16 gtkwindow: Unset focus grab_widget if it ends up unmapped
This may result on the later emission of crossing events, with one of the
sides being already unmapped/unrealized. The widget being unmapped will
result on repick and emission of a set of crossing events anyway.
2018-04-05 19:26:04 +02:00
Carlos Garnacho
1ce79b29e3 gtk: Add GtkEventControllerKey
This event controller is meant to replace usage from key-press/release-event
handlers all through. Optionally it can be set a GtkIMContext, so interaction
is carried by the controller.
2018-04-05 19:26:04 +02:00
Ivan Malison
f876532514 Add binding for <alt>BackSpace to emacs keys 2018-04-01 20:16:05 -07:00
813 changed files with 75266 additions and 63775 deletions

View File

@@ -1,43 +1,82 @@
stages:
- build
- flatpak
- deploy
gtk:
image: ebassi/gitlab-gtk:latest
.cache-paths: &cache-paths
paths:
- _ccache/
- subprojects/gdk-pixbuf/
- subprojects/glib/
- subprojects/graphene/
- subprojects/libepoxy/
- subprojects/pango/
fedora-x86_64:
image: registry.gitlab.gnome.org/gnome/gtk/master:v1
stage: build
before_script:
- export CCACHE_DISABLE=true_
script:
- bash -x ./.gitlab-ci/test-docker.sh
cache:
paths:
- subprojects/gdk-pixbuf/
- subprojects/glib/
- subprojects/graphene/
- subprojects/libepoxy/
- subprojects/pango/
artifacts:
when: on_failure
name: "gtk-${CI_COMMIT_REF_NAME}"
paths:
- "${CI_PROJECT_DIR}/_build/meson-logs"
cache:
key: "$CI_JOB_NAME"
<<: *cache-paths
.mingw-defaults: &mingw-defaults
stage: build
tags:
- win32
script:
- C:\msys64\usr\bin\pacman --noconfirm -Syyuu
- C:\msys64\usr\bin\bash -lc "bash -x ./.gitlab-ci/test-msys2.sh"
cache:
key: "%CI_JOB_NAME%"
<<: *cache-paths
msys2-mingw32:
variables:
MSYSTEM: "MINGW32"
CHERE_INVOKING: "yes"
<<: *mingw-defaults
.flatpak-defaults: &flatpak-defaults
image: registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master
stage: flatpak
artifacts:
paths:
- "${APPID}-dev.flatpak"
expire_in: 1 day
script:
- bash -x ./.gitlab-ci/flatpak-build.sh "${APPID}"
flatpak:demo:
image: registry.gitlab.com/alatiera/gnome-nightly-oci/gnome-master:latest
stage: flatpak
script:
- bash -x ./.gitlab-ci/flatpak-build.sh org.gtk.Demo
artifacts:
paths:
- org.gtk.Demo-dev.flatpak
expire_in: 1 day
variables:
APPID: org.gtk.Demo
<<: *flatpak-defaults
flatpak:widget-factory:
image: registry.gitlab.com/alatiera/gnome-nightly-oci/gnome-master:latest
stage: flatpak
variables:
APPID: org.gtk.WidgetFactory
<<: *flatpak-defaults
pages:
image: registry.gitlab.gnome.org/gnome/gtk/master:v1
stage: deploy
script:
- bash -x ./.gitlab-ci/flatpak-build.sh org.gtk.WidgetFactory
- meson -Ddocumentation=true _build .
- ninja -C _build
- ninja -C _build gdk4-doc gsk4-doc gtk4-doc
- mkdir -p public/
- mv _build/docs/reference/gtk/html/ public/gtk/
- mv _build/docs/reference/gdk/html/ public/gdk/
- mv _build/docs/reference/gsk/html/ public/gsk/
artifacts:
paths:
- org.gtk.WidgetFactory-dev.flatpak
expire_in: 1 day
- public
only:
- master

View File

@@ -1,6 +1,7 @@
FROM fedora:27
FROM fedora:28
RUN dnf -y install \
hicolor-icon-theme \
adwaita-icon-theme \
atk-devel \
at-spi2-atk-devel \
@@ -28,6 +29,7 @@ RUN dnf -y install \
gstreamer1-plugins-good \
gstreamer1-plugins-bad-free-devel \
gstreamer1-plugins-base-devel \
gtk-doc \
iso-codes \
itstool \
json-glib-devel \

View File

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

View File

@@ -4,16 +4,25 @@ set -e
srcdir=$(pwd)
mkdir -p _ccache
export CCACHE_BASEDIR="$(pwd)"
export CCACHE_DIR="${CCACHE_BASEDIR}/_ccache"
ccache --zero-stats
ccache --show-stats
export CCACHE_DISABLE=true
meson \
-Dx11-backend=true \
-Dwayland-backend=true \
-Dbroadway-backend=true \
-Dvulkan=yes \
_build $srcdir
unset CCACHE_DISABLE
cd _build
ninja
ccache --show-stats
xvfb-run -a -s "-screen 0 1024x768x24" \
meson test \

53
.gitlab-ci/test-msys2.sh Normal file
View File

@@ -0,0 +1,53 @@
#!/bin/bash
set -e
if [[ "$MSYSTEM" == "MINGW32" ]]; then
export MSYS2_ARCH="i686"
else
export MSYS2_ARCH="x86_64"
fi
# Update everything
pacman --noconfirm -Suy
# Install the required packages
pacman --noconfirm -S --needed \
base-devel \
git \
mingw-w64-$MSYS2_ARCH-toolchain \
mingw-w64-$MSYS2_ARCH-ccache \
mingw-w64-$MSYS2_ARCH-pkg-config \
mingw-w64-$MSYS2_ARCH-gobject-introspection \
mingw-w64-$MSYS2_ARCH-meson \
mingw-w64-$MSYS2_ARCH-adwaita-icon-theme \
mingw-w64-$MSYS2_ARCH-atk \
mingw-w64-$MSYS2_ARCH-cairo \
mingw-w64-$MSYS2_ARCH-gdk-pixbuf2 \
mingw-w64-$MSYS2_ARCH-glib2 \
mingw-w64-$MSYS2_ARCH-graphene \
mingw-w64-$MSYS2_ARCH-json-glib \
mingw-w64-$MSYS2_ARCH-libepoxy \
mingw-w64-$MSYS2_ARCH-pango \
mingw-w64-$MSYS2_ARCH-fribidi \
mingw-w64-$MSYS2_ARCH-gst-plugins-bad \
mingw-w64-$MSYS2_ARCH-shared-mime-info
mkdir -p _ccache
export CCACHE_BASEDIR="$(pwd)"
export CCACHE_DIR="${CCACHE_BASEDIR}/_ccache"
# Build
ccache --zero-stats
ccache --show-stats
export CCACHE_DISABLE=true
meson \
-Denable-x11-backend=false \
-Denable-wayland-backend=false \
-Denable-win32-backend=true \
-Dvulkan=no \
_build
unset CCACHE_DISABLE
ninja -C _build
ccache --show-stats

View File

@@ -23,17 +23,14 @@
## Version information
<!--
- which version of GTK+ you are using
- what operating system and version
- for Linux, which distribution
- if you built GTK+ yourself, the list of options used to configure the build
- Which version of GTK+ you are using
- What operating system and version
- For Linux, which distribution
- If you built GTK+ yourself, the list of options used to configure the build
-->
## Additional information
<!--
- If the bug was a crash, the exact text that was printed out
when the crash occurred.
- If the bug was a crash, attaching a stack trace obtained using
GDB is appreciated; follow the instructions on the wiki:
https://wiki.gnome.org/Community/GettingInTouch/Bugzilla/GettingTraces
-->
- Screenshots or screen recordings are useful for visual errors
- Please report any warning or message printed on the terminal
-->

View File

@@ -0,0 +1,34 @@
## Steps to reproduce
1. ...
2. ...
3. ...
<!--
You should try and reproduce with the demos applications available
under the `demos` directory, or the test programs in the `tests` directory.
Alternatively, please attach a *small and self-contained* example that
exhibits the issue.
-->
## Version information
<!--
- Which version of GTK+ you are using
- What operating system and version
- for Linux, which distribution
- If you built GTK+ yourself, the list of options used to configure the build
-->
## Warnings
<!--
- If the application generates warning messages before crashing please
report them here
-->
## Backtrace
<!--
- Attaching a stack trace obtained using GDB is appreciated; follow the
instructions on the wiki:
https://wiki.gnome.org/Community/GettingInTouch/Bugzilla/GettingTraces
-->

View File

@@ -60,4 +60,6 @@ $ git checkout -b your-branch
Once you've finished working on the bug fix or feature, push the branch
to the Git repository and open a new merge request, to let the GTK
maintainers review your contribution.
maintainers review your contribution. The [CODE-OWNERS](./docs-CODE-OWNERS)
document contains the list of core contributors to GTK and the areas for
which they are responsible.

88
NEWS
View File

@@ -1,3 +1,91 @@
Overview of Changes in GTK+ 3.94.0
==================================
* GdkPaintable is a new, powerful abstraction for drawable content.
gtk4-demo has a new "Paint" demo to show some of its capabilities.
* There is support for displaying media, with
GtkVideo
GtkMediaFile
GtkMediaStream
GtkMediaControls
* GtkFontChooser now supports OpenType font variations and features.
* The Ctrl-Shift-E support in the simple IM context has been replaced
by an optional completion popup for Emoji alpha codes. This can be
enabled with the GtkEntry::enable-emoji-completion property.
* Wayland has an input method based on the text protocol now
* Input methods, print backends and media backends have been converted
to GIOModules and extension points, and support for generic loadable
modules has been dropped. Platform im modules are always included.
* GdkWindow has been renamed to GdkSurface.
* Applications can now create their own GtkSnapshot objects for
intermediate rendering.
* Widget event signals have been replaced by event controllers,
and some new event controllers have been introduced for this:
GtkEventControllerMotion
GtkEventControllerKey
GtkGestureStylus
* Event controllers can now be created in .ui files.
* Invalidation tracking has been changed, only gtk_widget_queue_draw is left.
* Observing widget contents and size is now done by using the
GtkWidgetPaintable object instead of connecting to widget signals.
* The GtkWidget::draw signal has been removed, widgets need
to implement GtkWidget::snapshot.
* GdkTexture now has GdkMemoryTexture and GdkGLTexture subclasses.
* The Vulkan support in GDK can now use a particular device that is
specified by the GDK_VULKAN_DEVICE environment variable. use
GDK_VULKAN_DEVICE=list to see them all.
* GTK+ Inspector
- has logging support, and the logging settings have been cleaned up
- has an fps overlay
* Removed APIs and features:
Individual event signals such as ::proximity-in-event
The ::draw signal
threading support
non-platform IM modules
papi and test print backends
GtkPlacesSidebar
GtkRecentChooser
GtkToolPalette
GdkStatus
gtk_true, gtk_false
gtk_widget_show_now
gtk_widget_draw
gtk_render_icon_surface
* Incomplete transitions:
The ::event signal is not still there, but it will be removed
The DND apis are not finalized yet
* Translation updates:
Croatian
Esperanto
Estonian
French
Friulian
Icelandic
Latvian
Polish
Russian
Scottish Gaelic
Spanish
Overview of Changes in GTK+ 3.93.0
==================================

View File

@@ -27,12 +27,28 @@
"/share/doc"
],
"modules": [
{
"name" : "wayland",
"buildsystem" : "autotools",
"builddir" : true,
"config-opts" : [
"--disable-documentation"
],
"sources" : [
{
"type" : "git",
"url" : "https://github.com/wayland-project/wayland.git"
}
]
},
{
"name": "graphene",
"buildsystem": "meson",
"builddir": true,
"config-opts": [
"--libdir=/app/lib"
"--libdir=/app/lib",
"-Dtests=false",
"-Dbenchmarks=false"
],
"sources": [
{

View File

@@ -27,12 +27,28 @@
"/share/doc"
],
"modules": [
{
"name" : "wayland",
"buildsystem" : "autotools",
"builddir" : true,
"config-opts" : [
"--disable-documentation"
],
"sources" : [
{
"type" : "git",
"url" : "https://github.com/wayland-project/wayland.git"
}
]
},
{
"name": "graphene",
"buildsystem": "meson",
"builddir": true,
"config-opts": [
"--libdir=/app/lib"
"--libdir=/app/lib",
"-Dtests=false",
"-Dbenchmarks=false"
],
"sources": [
{

View File

@@ -286,6 +286,10 @@
/* Define to 1 if linux/memfd.h exists */
#mesondefine HAVE_LINUX_MEMFD_H
#mesondefine HAVE_LINUX_INPUT_H
#mesondefine HAVE_DEV_EVDEV_INPUT_H
#mesondefine GTK_SYSCONFDIR
#mesondefine GTK_LOCALEDIR
@@ -301,3 +305,13 @@
#mesondefine HAVE_PANGOFT
#mesondefine ISO_CODES_PREFIX
#mesondefine MALLOC_IS_ALIGNED16
#mesondefine HAVE_POSIX_MEMALIGN
#mesondefine HAVE_MEMALIGN
#mesondefine HAVE_ALIGNED_ALLOC
#mesondefine HAVE__ALIGNED_MALLOC

View File

@@ -120,7 +120,7 @@ get_image_paintable (GtkImage *image)
static void
drag_begin (GtkWidget *widget,
GdkDragContext *context,
GdkDrag *drag,
gpointer data)
{
GdkPaintable *paintable;
@@ -128,17 +128,16 @@ drag_begin (GtkWidget *widget,
paintable = get_image_paintable (GTK_IMAGE (widget));
if (paintable)
{
gtk_drag_set_icon_paintable (context, paintable, -2, -2);
gtk_drag_set_icon_paintable (drag, paintable, -2, -2);
g_object_unref (paintable);
}
}
void
drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GdkDrag *drag,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data)
{
GdkPaintable *paintable;
@@ -150,9 +149,8 @@ drag_data_get (GtkWidget *widget,
static void
drag_data_received (GtkWidget *widget,
GdkDragContext *context,
GdkDrop *drop,
GtkSelectionData *selection_data,
guint32 time,
gpointer data)
{
if (gtk_selection_data_get_length (selection_data) > 0)
@@ -321,10 +319,10 @@ do_clipboard (GtkWidget *do_widget)
G_CALLBACK (drag_data_received), image);
/* context menu on image */
gesture = gtk_gesture_multi_press_new (image);
gesture = gtk_gesture_multi_press_new ();
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), GDK_BUTTON_SECONDARY);
g_object_set_data_full (G_OBJECT (image), "gesture", gesture, g_object_unref);
g_signal_connect (gesture, "pressed", G_CALLBACK (pressed_cb), image);
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (gesture));
/* Create the second image */
image = gtk_image_new_from_icon_name ("process-stop");
@@ -346,10 +344,10 @@ do_clipboard (GtkWidget *do_widget)
G_CALLBACK (drag_data_received), image);
/* context menu on image */
gesture = gtk_gesture_multi_press_new (image);
gesture = gtk_gesture_multi_press_new ();
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), GDK_BUTTON_SECONDARY);
g_object_set_data_full (G_OBJECT (image), "gesture", gesture, g_object_unref);
g_signal_connect (gesture, "pressed", G_CALLBACK (pressed_cb), image);
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (gesture));
}
if (!gtk_widget_get_visible (window))

View File

@@ -105,9 +105,6 @@
<file>gnome-fs-directory.png</file>
<file>gnome-fs-regular.png</file>
</gresource>
<gresource prefix="/stack">
<file>stack.ui</file>
</gresource>
<gresource prefix="/shortcuts">
<file>shortcuts.ui</file>
<file>shortcuts-builder.ui</file>
@@ -115,6 +112,14 @@
<file>shortcuts-clocks.ui</file>
<file>shortcuts-boxes.ui</file>
</gresource>
<gresource prefix="/sliding_puzzle">
<file>puzzlepiece.c</file>
<file>puzzlepiece.h</file>
<file>portland-rose.jpg</file>
</gresource>
<gresource prefix="/stack">
<file>stack.ui</file>
</gresource>
<gresource prefix="/revealer">
<file>revealer.ui</file>
</gresource>
@@ -160,11 +165,11 @@
<file>expander.c</file>
<file>filtermodel.c</file>
<file>fishbowl.c</file>
<file>widgetbowl.c</file>
<file>flowbox.c</file>
<file>foreigndrawing.c</file>
<file>font_features.c</file>
<file>fontplane.c</file>
<file>fontrendering.c</file>
<file>gestures.c</file>
<file>glarea.c</file>
<file>headerbar.c</file>
@@ -181,6 +186,7 @@
<file>modelbutton.c</file>
<file>overlay.c</file>
<file>overlay2.c</file>
<file>paint.c</file>
<file>pagesetup.c</file>
<file>paintable.c</file>
<file>paintable_animated.c</file>
@@ -198,6 +204,7 @@
<file>shortcuts.c</file>
<file>sizegroup.c</file>
<file>sidebar.c</file>
<file>sliding_puzzle.c</file>
<file>stack.c</file>
<file>spinbutton.c</file>
<file>spinner.c</file>
@@ -256,4 +263,7 @@
<gresource prefix="/dnd">
<file>dnd.css</file>
</gresource>
<gresource prefix="/fontrendering">
<file>fontrendering.ui</file>
</gresource>
</gresources>

View File

@@ -356,10 +356,11 @@ do_dnd (GtkWidget *do_widget)
gtk_widget_set_hexpand (fixed, TRUE);
gtk_widget_set_vexpand (fixed, TRUE);
multipress = gtk_gesture_multi_press_new (fixed);
multipress = gtk_gesture_multi_press_new ();
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (multipress), 0);
g_signal_connect (multipress, "pressed", G_CALLBACK (pressed_cb), NULL);
g_signal_connect (multipress, "released", G_CALLBACK (released_cb), NULL);
gtk_widget_add_controller (fixed, GTK_EVENT_CONTROLLER (multipress));
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_resource (provider, "/dnd/dnd.css");

View File

@@ -244,13 +244,14 @@ do_drawingarea (GtkWidget *do_widget)
g_signal_connect (da, "size-allocate",
G_CALLBACK (scribble_size_allocate), NULL);
drag = gtk_gesture_drag_new (da);
drag = gtk_gesture_drag_new ();
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (drag), GDK_BUTTON_PRIMARY);
g_object_set_data_full (G_OBJECT (da), "drag", drag, g_object_unref);
gtk_widget_add_controller (da, GTK_EVENT_CONTROLLER (drag));
g_signal_connect (drag, "drag-begin", G_CALLBACK (drag_begin), da);
g_signal_connect (drag, "drag-update", G_CALLBACK (drag_update), da);
g_signal_connect (drag, "drag-end", G_CALLBACK (drag_end), da);
}
if (!gtk_widget_get_visible (window))

View File

@@ -444,7 +444,7 @@ draw_device_info (GtkWidget *widget,
g_string_append_printf (string, "\nTool: %s", tool_type);
if (serial != 0)
g_string_append_printf (string, ", Serial: %lx", serial);
g_string_append_printf (string, ", Serial: %" G_GINT64_MODIFIER "x", serial);
}
cairo_move_to (cr, 10, *y);
@@ -581,8 +581,7 @@ init_pad_controller (GtkWidget *window,
gint i;
action_group = g_simple_action_group_new ();
pad_controller = gtk_pad_controller_new (GTK_WINDOW (window),
G_ACTION_GROUP (action_group),
pad_controller = gtk_pad_controller_new (G_ACTION_GROUP (action_group),
NULL);
for (i = 0; i < G_N_ELEMENTS (pad_actions); i++)
@@ -607,8 +606,7 @@ init_pad_controller (GtkWidget *window,
gtk_pad_controller_set_action_entries (pad_controller, pad_actions,
G_N_ELEMENTS (pad_actions));
g_object_set_data_full (G_OBJECT (window), "pad-controller",
pad_controller, g_object_unref);
gtk_widget_add_controller (window, GTK_EVENT_CONTROLLER (pad_controller));
g_object_unref (action_group);
}

View File

@@ -8,167 +8,245 @@
#include <gtk/gtk.h>
#include "gtkfishbowl.h"
#include "gtkgears.h"
GtkWidget *info_label;
GtkWidget *allow_changes;
const char *const css =
".blurred-button {"
" box-shadow: 0px 0px 5px 10px rgba(0, 0, 0, 0.5);"
"}"
"";
#define N_STATS 5
#define STATS_UPDATE_TIME G_USEC_PER_SEC
typedef struct _Stats Stats;
struct _Stats {
gint last_suggestion;
};
static Stats *
get_stats (GtkWidget *widget)
{
static GQuark stats_quark = 0;
Stats *stats;
if (G_UNLIKELY (stats_quark == 0))
stats_quark = g_quark_from_static_string ("stats");
stats = g_object_get_qdata (G_OBJECT (widget), stats_quark);
if (stats == NULL)
{
stats = g_new0 (Stats, 1);
g_object_set_qdata_full (G_OBJECT (widget), stats_quark, stats, g_free);
}
return stats;
}
static gint64
guess_refresh_interval (GdkFrameClock *frame_clock)
{
gint64 interval;
gint64 i;
interval = G_MAXINT64;
for (i = gdk_frame_clock_get_history_start (frame_clock);
i < gdk_frame_clock_get_frame_counter (frame_clock);
i++)
{
GdkFrameTimings *t, *before;
gint64 ts, before_ts;
t = gdk_frame_clock_get_timings (frame_clock, i);
before = gdk_frame_clock_get_timings (frame_clock, i - 1);
if (t == NULL || before == NULL)
continue;
ts = gdk_frame_timings_get_frame_time (t);
before_ts = gdk_frame_timings_get_frame_time (before);
if (ts == 0 || before_ts == 0)
continue;
interval = MIN (interval, ts - before_ts);
}
if (interval == G_MAXINT64)
return 0;
return interval;
}
char **icon_names = NULL;
gsize n_icon_names = 0;
static void
do_stats (GtkWidget *widget,
gint *suggested_change)
init_icon_names (GtkIconTheme *theme)
{
GdkFrameClock *frame_clock;
Stats *stats;
GdkFrameTimings *start, *end;
gint64 start_counter, end_counter;
gint64 n_frames, expected_frames;
gint64 start_timestamp, end_timestamp;
gint64 interval;
char *new_label;
GPtrArray *icons;
GList *l, *icon_list;
stats = get_stats (widget);
frame_clock = gtk_widget_get_frame_clock (widget);
if (frame_clock == NULL)
if (icon_names)
return;
start_counter = gdk_frame_clock_get_history_start (frame_clock);
end_counter = gdk_frame_clock_get_frame_counter (frame_clock);
start = gdk_frame_clock_get_timings (frame_clock, start_counter);
for (end = gdk_frame_clock_get_timings (frame_clock, end_counter);
end_counter > start_counter && end != NULL && !gdk_frame_timings_get_complete (end);
end = gdk_frame_clock_get_timings (frame_clock, end_counter))
end_counter--;
if (end_counter - start_counter < 4)
icon_list = gtk_icon_theme_list_icons (theme, NULL);
icons = g_ptr_array_new ();
for (l = icon_list; l; l = l->next)
{
if (g_str_has_suffix (l->data, "symbolic"))
continue;
g_ptr_array_add (icons, g_strdup (l->data));
}
n_icon_names = icons->len;
g_ptr_array_add (icons, NULL); /* NULL-terminate the array */
icon_names = (char **) g_ptr_array_free (icons, FALSE);
/* don't free strings, we assigned them to the array */
g_list_free_full (icon_list, g_free);
}
static const char *
get_random_icon_name (GtkIconTheme *theme)
{
init_icon_names (theme);
return icon_names[g_random_int_range(0, n_icon_names)];
}
GtkWidget *
create_icon (void)
{
GtkWidget *image;
image = gtk_image_new_from_icon_name (get_random_icon_name (gtk_icon_theme_get_default ()));
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
return image;
}
static GtkWidget *
create_button (void)
{
return gtk_button_new_with_label ("Button");
}
static GtkWidget *
create_blurred_button (void)
{
GtkWidget *w = gtk_button_new ();
gtk_style_context_add_class (gtk_widget_get_style_context (w), "blurred-button");
return w;
}
static GtkWidget *
create_font_button (void)
{
return gtk_font_button_new ();
}
static GtkWidget *
create_level_bar (void)
{
GtkWidget *w = gtk_level_bar_new_for_interval (0, 100);
gtk_level_bar_set_value (GTK_LEVEL_BAR (w), 50);
/* Force them to be a bit larger */
gtk_widget_set_size_request (w, 200, -1);
return w;
}
static GtkWidget *
create_spinner (void)
{
GtkWidget *w = gtk_spinner_new ();
gtk_spinner_start (GTK_SPINNER (w));
return w;
}
static GtkWidget *
create_spinbutton (void)
{
GtkWidget *w = gtk_spin_button_new_with_range (0, 10, 1);
return w;
}
static GtkWidget *
create_label (void)
{
GtkWidget *w = gtk_label_new ("pLorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.");
gtk_label_set_line_wrap (GTK_LABEL (w), TRUE);
gtk_label_set_max_width_chars (GTK_LABEL (w), 100);
return w;
}
static GtkWidget *
create_video (void)
{
GtkMediaStream *stream = gtk_media_file_new_for_resource ("/images/gtk-logo.webm");
GtkWidget *w = gtk_image_new_from_paintable (GDK_PAINTABLE (stream));
gtk_media_stream_set_loop (stream, TRUE);
gtk_media_stream_play (stream);
g_object_unref (stream);
return w;
}
static GtkWidget *
create_gears (void)
{
GtkWidget *w = gtk_gears_new ();
gtk_widget_set_size_request (w, 100, 100);
return w;
}
static GtkWidget *
create_switch (void)
{
GtkWidget *w = gtk_switch_new ();
gtk_switch_set_state (GTK_SWITCH (w), TRUE);
return w;
}
static const struct {
const char *name;
GtkWidget * (*create_func) (void);
} widget_types[] = {
{ "Icon", create_icon },
{ "Button", create_button },
{ "Blurbutton", create_blurred_button },
{ "Fontbutton", create_font_button },
{ "Levelbar", create_level_bar },
{ "Label", create_label },
{ "Spinner", create_spinner },
{ "Spinbutton", create_spinbutton },
{ "Video", create_video },
{ "Gears", create_gears },
{ "Switch", create_switch },
};
static int selected_widget_type = -1;
static const int N_WIDGET_TYPES = G_N_ELEMENTS (widget_types);
static void
set_widget_type (GtkFishbowl *fishbowl,
int widget_type_index)
{
GtkWidget *window, *headerbar;
if (widget_type_index == selected_widget_type)
return;
start_timestamp = gdk_frame_timings_get_presentation_time (start);
end_timestamp = gdk_frame_timings_get_presentation_time (end);
if (start_timestamp == 0 || end_timestamp == 0)
{
start_timestamp = gdk_frame_timings_get_frame_time (start);
end_timestamp = gdk_frame_timings_get_frame_time (end);
}
selected_widget_type = widget_type_index;
interval = gdk_frame_timings_get_refresh_interval (end);
if (interval == 0)
{
interval = guess_refresh_interval (frame_clock);
if (interval == 0)
return;
}
n_frames = end_counter - start_counter;
expected_frames = round ((double) (end_timestamp - start_timestamp) / interval);
gtk_fishbowl_set_creation_func (fishbowl,
widget_types[selected_widget_type].create_func);
new_label = g_strdup_printf ("icons - %.1f fps",
((double) n_frames) * G_USEC_PER_SEC / (end_timestamp - start_timestamp));
gtk_label_set_label (GTK_LABEL (info_label), new_label);
g_free (new_label);
if (n_frames >= expected_frames)
{
if (stats->last_suggestion > 0)
stats->last_suggestion *= 2;
else
stats->last_suggestion = 1;
}
else if (n_frames + 1 < expected_frames)
{
if (stats->last_suggestion < 0)
stats->last_suggestion--;
else
stats->last_suggestion = -1;
}
else
{
stats->last_suggestion = 0;
}
if (suggested_change)
*suggested_change = stats->last_suggestion;
else
stats->last_suggestion = 0;
window = gtk_widget_get_toplevel (GTK_WIDGET (fishbowl));
headerbar = gtk_window_get_titlebar (GTK_WINDOW (window));
gtk_header_bar_set_title (GTK_HEADER_BAR (headerbar),
widget_types[selected_widget_type].name);
}
static gboolean
move_fish (gpointer bowl)
void
next_button_clicked_cb (GtkButton *source,
gpointer user_data)
{
gint suggested_change = 0, new_count;
do_stats (bowl,
!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (allow_changes)) ? &suggested_change : NULL);
GtkFishbowl *fishbowl = user_data;
int new_index;
new_count = gtk_fishbowl_get_count (GTK_FISHBOWL (bowl)) + suggested_change;
new_count = MAX (1, new_count);
gtk_fishbowl_set_count (GTK_FISHBOWL (bowl), new_count);
if (selected_widget_type + 1 >= N_WIDGET_TYPES)
new_index = 0;
else
new_index = selected_widget_type + 1;
return G_SOURCE_CONTINUE;
set_widget_type (fishbowl, new_index);
}
void
prev_button_clicked_cb (GtkButton *source,
gpointer user_data)
{
GtkFishbowl *fishbowl = user_data;
int new_index;
if (selected_widget_type - 1 < 0)
new_index = N_WIDGET_TYPES - 1;
else
new_index = selected_widget_type - 1;
set_widget_type (fishbowl, new_index);
}
GtkWidget *
do_fishbowl (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
static GtkCssProvider *provider = NULL;
if (provider == NULL)
{
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider, css, -1);
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
if (!window)
{
@@ -178,21 +256,20 @@ do_fishbowl (GtkWidget *do_widget)
g_type_ensure (GTK_TYPE_FISHBOWL);
builder = gtk_builder_new_from_resource ("/fishbowl/fishbowl.ui");
gtk_builder_add_callback_symbols (builder,
"next_button_clicked_cb", G_CALLBACK (next_button_clicked_cb),
"prev_button_clicked_cb", G_CALLBACK (prev_button_clicked_cb),
NULL);
gtk_builder_connect_signals (builder, NULL);
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
bowl = GTK_WIDGET (gtk_builder_get_object (builder, "bowl"));
gtk_fishbowl_set_use_icons (GTK_FISHBOWL (bowl), TRUE);
info_label = GTK_WIDGET (gtk_builder_get_object (builder, "info_label"));
allow_changes = GTK_WIDGET (gtk_builder_get_object (builder, "changes_allow"));
set_widget_type (GTK_FISHBOWL (bowl), 0);
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &window);
gtk_widget_realize (window);
g_timeout_add_seconds (1,
move_fish,
bowl);
}
if (!gtk_widget_get_visible (window))

View File

@@ -7,7 +7,43 @@
<object class="GtkHeaderBar" id="">
<property name="show-title-buttons">1</property>
<child>
<object class="GtkLabel" id="info_label">
<object class="GtkBox">
<style>
<class name="linked"/>
</style>
<child>
<object class="GtkButton">
<property name="icon-name">pan-start-symbolic</property>
<signal name="clicked" handler="prev_button_clicked_cb" object="bowl" swapped="no"/>
</object>
</child>
<child>
<object class="GtkButton">
<property name="icon-name">pan-end-symbolic</property>
<signal name="clicked" handler="next_button_clicked_cb" object="bowl" swapped="no"/>
</object>
</child>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">fps</property>
</object>
<packing>
<property name="pack-type">end</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="label" bind-source="bowl" bind-property="framerate"/>
</object>
<packing>
<property name="pack-type">end</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="label">Icons, </property>
</object>
<packing>
<property name="pack-type">end</property>
@@ -48,6 +84,7 @@
<object class="GtkFishbowl" id="bowl">
<property name="visible">True</property>
<property name="animating">True</property>
<property name="benchmark" bind-source="changes_allow" bind-property="active" bind-flags="invert-boolean">True</property>
</object>
</child>
</object>

View File

@@ -133,7 +133,6 @@
Разъяренный чтец эгоистично бьёт пятью жердями шустрого фехтовальщика. Наш банк вчера же выплатил Ф.Я. Эйхгольду комиссию за ценные вещи. Эх, чужак, общий съём цен шляп (юфть) вдрызг! В чащах юга жил бы цитрус? Да, но фальшивый экземпляр!
Τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός</property>
<signal name="key-press-event" handler="entry_key_press"/>
<signal name="activate" handler="stop_edit"/>
<property name="valign">start</property>
<property name="width-chars">50</property>

View File

@@ -1669,12 +1669,12 @@ stop_edit (void)
}
static gboolean
entry_key_press (GtkEntry *entry, GdkEventKey *event)
entry_key_press (GtkEventController *controller,
guint keyval,
guint keycode,
GdkModifierType modifiers,
GtkEntry *entry)
{
guint keyval;
gdk_event_get_keyval ((GdkEvent *)event, &keyval);
if (keyval == GDK_KEY_Escape)
{
gtk_entry_set_text (GTK_ENTRY (entry), text);
@@ -1694,6 +1694,7 @@ do_font_features (GtkWidget *do_widget)
{
GtkBuilder *builder;
GtkWidget *feature_list;
GtkEventController *controller;
builder = gtk_builder_new_from_resource ("/font_features/font-features.ui");
@@ -1703,7 +1704,6 @@ do_font_features (GtkWidget *do_widget)
gtk_builder_add_callback_symbol (builder, "reset", reset_features);
gtk_builder_add_callback_symbol (builder, "stop_edit", G_CALLBACK (stop_edit));
gtk_builder_add_callback_symbol (builder, "toggle_edit", G_CALLBACK (toggle_edit));
gtk_builder_add_callback_symbol (builder, "entry_key_press", G_CALLBACK (entry_key_press));
gtk_builder_connect_signals (builder, NULL);
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
@@ -1718,6 +1718,11 @@ do_font_features (GtkWidget *do_widget)
entry = GTK_WIDGET (gtk_builder_get_object (builder, "entry"));
edit_toggle = GTK_WIDGET (gtk_builder_get_object (builder, "edit_toggle"));
controller = gtk_event_controller_key_new ();
g_object_set_data_full (G_OBJECT (entry), "controller", controller, g_object_unref);
g_signal_connect (controller, "key-pressed", G_CALLBACK (entry_key_press), entry);
gtk_widget_add_controller (entry, controller);
add_check_group (feature_list, _("Kerning"), (const char *[]){ "kern", NULL });
add_check_group (feature_list, _("Ligatures"), (const char *[]){ "liga",
"dlig",

View File

@@ -68,8 +68,7 @@ plane_snapshot (GtkWidget *widget,
height = gtk_widget_get_allocated_height (widget);
cr = gtk_snapshot_append_cairo (snapshot,
&GRAPHENE_RECT_INIT (0, 0, width, height),
"FontPlane");
&GRAPHENE_RECT_INIT (0, 0, width, height));
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_rectangle (cr, 0, 0, width, height);
@@ -208,23 +207,27 @@ plane_drag_gesture_end (GtkGestureDrag *gesture,
static void
gtk_font_plane_init (GtkFontPlane *plane)
{
GtkGesture *gesture;
gtk_widget_set_has_surface (GTK_WIDGET (plane), FALSE);
gtk_widget_set_can_focus (GTK_WIDGET (plane), TRUE);
plane->drag_gesture = gtk_gesture_drag_new (GTK_WIDGET (plane));
g_signal_connect (plane->drag_gesture, "drag-begin",
gesture = gtk_gesture_drag_new ();
g_signal_connect (gesture, "drag-begin",
G_CALLBACK (plane_drag_gesture_begin), plane);
g_signal_connect (plane->drag_gesture, "drag-update",
g_signal_connect (gesture, "drag-update",
G_CALLBACK (plane_drag_gesture_update), plane);
g_signal_connect (plane->drag_gesture, "drag-end",
g_signal_connect (gesture, "drag-end",
G_CALLBACK (plane_drag_gesture_end), plane);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (plane->drag_gesture), 0);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0);
gtk_widget_add_controller (GTK_WIDGET (plane), GTK_EVENT_CONTROLLER (gesture));
plane->long_press_gesture = gtk_gesture_long_press_new (GTK_WIDGET (plane));
g_signal_connect (plane->long_press_gesture, "pressed",
gesture = gtk_gesture_long_press_new ();
g_signal_connect (gesture, "pressed",
G_CALLBACK (hold_action), plane);
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (plane->long_press_gesture),
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture),
TRUE);
gtk_widget_add_controller (GTK_WIDGET (plane), GTK_EVENT_CONTROLLER (gesture));
}
static void
@@ -235,9 +238,6 @@ plane_finalize (GObject *object)
g_clear_object (&plane->weight_adj);
g_clear_object (&plane->width_adj);
g_clear_object (&plane->drag_gesture);
g_clear_object (&plane->long_press_gesture);
G_OBJECT_CLASS (gtk_font_plane_parent_class)->finalize (object);
}

View File

@@ -41,7 +41,6 @@ struct _GtkFontPlane
GtkAdjustment *width_adj;
GtkGesture *drag_gesture;
GtkGesture *long_press_gesture;
};
struct _GtkFontPlaneClass

View File

@@ -0,0 +1,222 @@
/* Pango/Font Rendering
*
* Demonstrates variations in font rendering.
*/
#include <gtk/gtk.h>
static GtkWidget *window = NULL;
static GtkWidget *font_button = NULL;
static GtkWidget *entry = NULL;
static GtkWidget *image = NULL;
static GtkWidget *hinting = NULL;
static GtkWidget *hint_metrics = NULL;
static GtkWidget *up_button = NULL;
static GtkWidget *down_button = NULL;
static GtkWidget *text_radio = NULL;
static PangoContext *context;
static int scale = 10;
static void
on_destroy (gpointer data)
{
window = NULL;
}
static void
update_image (void)
{
const char *text;
PangoFontDescription *desc;
PangoLayout *layout;
PangoRectangle ink, logical;
cairo_surface_t *surface;
cairo_t *cr;
GdkPixbuf *pixbuf;
GdkPixbuf *pixbuf2;
const char *hint;
cairo_font_options_t *fopt;
cairo_hint_style_t hintstyle;
cairo_hint_metrics_t hintmetrics;
if (!context)
context = gtk_widget_create_pango_context (image);
text = gtk_entry_get_text (GTK_ENTRY (entry));
desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (font_button));
fopt = cairo_font_options_copy (pango_cairo_context_get_font_options (context));
hint = gtk_combo_box_get_active_id (GTK_COMBO_BOX (hinting));
if (strcmp (hint, "none") == 0)
hintstyle = CAIRO_HINT_STYLE_NONE;
else if (strcmp (hint, "slight") == 0)
hintstyle = CAIRO_HINT_STYLE_SLIGHT;
else if (strcmp (hint, "medium") == 0)
hintstyle = CAIRO_HINT_STYLE_MEDIUM;
else if (strcmp (hint, "full") == 0)
hintstyle = CAIRO_HINT_STYLE_FULL;
else
hintstyle = CAIRO_HINT_STYLE_DEFAULT;
cairo_font_options_set_hint_style (fopt, hintstyle);
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (hint_metrics)))
hintmetrics = CAIRO_HINT_METRICS_ON;
else
hintmetrics = CAIRO_HINT_METRICS_OFF;
cairo_font_options_set_hint_metrics (fopt, hintmetrics);
pango_cairo_context_set_font_options (context, fopt);
cairo_font_options_destroy (fopt);
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (text_radio)))
{
layout = pango_layout_new (context);
pango_layout_set_font_description (layout, desc);
pango_layout_set_text (layout, text, -1);
pango_layout_get_extents (layout, &ink, &logical);
pango_extents_to_pixels (&logical, NULL);
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
MAX(1,logical.width),
MAX(1,logical.height));
cr = cairo_create (surface);
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_paint (cr);
cairo_set_source_rgb (cr, 0, 0, 0);
pango_cairo_show_layout (cr, layout);
cairo_destroy (cr);
g_object_unref (layout);
}
else
{
PangoLayoutIter *iter;
PangoGlyphItem *run;
PangoGlyphInfo *g;
int i, j;
layout = pango_layout_new (context);
pango_layout_set_font_description (layout, desc);
pango_layout_set_text (layout, "aaaa", -1);
pango_layout_get_extents (layout, &ink, &logical);
pango_extents_to_pixels (&logical, NULL);
iter = pango_layout_get_iter (layout);
run = pango_layout_iter_get_run (iter);
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
MAX(1, logical.width) * 3 / 2,
MAX(1, logical.height) * 4);
cr = cairo_create (surface);
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_paint (cr);
cairo_set_source_rgb (cr, 0, 0, 0);
for (i = 0; i < 4; i++)
{
g = &(run->glyphs->glyphs[i]);
g->geometry.width = PANGO_UNITS_ROUND (g->geometry.width * 3 / 2);
}
for (j = 0; j < 4; j++)
{
for (i = 0; i < 4; i++)
{
g = &(run->glyphs->glyphs[i]);
g->geometry.x_offset = i * (PANGO_SCALE / 4);
g->geometry.y_offset = j * (PANGO_SCALE / 4);
}
cairo_move_to (cr, 0, j * logical.height);
pango_cairo_show_layout (cr, layout);
}
cairo_destroy (cr);
pango_layout_iter_free (iter);
g_object_unref (layout);
}
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, cairo_image_surface_get_width (surface), cairo_image_surface_get_height (surface));
pixbuf2 = gdk_pixbuf_scale_simple (pixbuf, gdk_pixbuf_get_width (pixbuf) * scale, gdk_pixbuf_get_height (pixbuf) * scale, GDK_INTERP_NEAREST);
gtk_picture_set_pixbuf (GTK_PICTURE (image), pixbuf2);
g_object_unref (pixbuf);
g_object_unref (pixbuf2);
cairo_surface_destroy (surface);
pango_font_description_free (desc);
}
static void
update_buttons (void)
{
gtk_widget_set_sensitive (up_button, scale < 32);
gtk_widget_set_sensitive (down_button, scale > 1);
}
static void
scale_up (void)
{
scale += 1;
update_buttons ();
update_image ();
}
static void
scale_down (void)
{
scale -= 1;
update_buttons ();
update_image ();
}
GtkWidget *
do_fontrendering (GtkWidget *do_widget)
{
if (!window)
{
GtkBuilder *builder;
builder = gtk_builder_new_from_resource ("/fontrendering/fontrendering.ui");
gtk_builder_connect_signals (builder, NULL);
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
g_signal_connect (window, "destroy",
G_CALLBACK (on_destroy), NULL);
g_object_set_data_full (G_OBJECT (window), "builder", builder, g_object_unref);
font_button = GTK_WIDGET (gtk_builder_get_object (builder, "font_button"));
up_button = GTK_WIDGET (gtk_builder_get_object (builder, "up_button"));
down_button = GTK_WIDGET (gtk_builder_get_object (builder, "down_button"));
entry = GTK_WIDGET (gtk_builder_get_object (builder, "entry"));
image = GTK_WIDGET (gtk_builder_get_object (builder, "image"));
hinting = GTK_WIDGET (gtk_builder_get_object (builder, "hinting"));
hint_metrics = GTK_WIDGET (gtk_builder_get_object (builder, "hint_metrics"));
text_radio = GTK_WIDGET (gtk_builder_get_object (builder, "text_radio"));
g_signal_connect (up_button, "clicked", G_CALLBACK (scale_up), NULL);
g_signal_connect (down_button, "clicked", G_CALLBACK (scale_down), NULL);
g_signal_connect (entry, "notify::text", G_CALLBACK (update_image), NULL);
g_signal_connect (font_button, "notify::font-desc", G_CALLBACK (update_image), NULL);
g_signal_connect (hinting, "notify::active", G_CALLBACK (update_image), NULL);
g_signal_connect (hint_metrics, "notify::active", G_CALLBACK (update_image), NULL);
g_signal_connect (text_radio, "notify::active", G_CALLBACK (update_image), NULL);
update_image ();
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
{
gtk_widget_destroy (window);
}
return window;
}

View File

@@ -0,0 +1,185 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.94 -->
<object class="GtkAdjustment" id="scale_adj">
<property name="lower">0</property>
<property name="value">0</property>
<property name="upper">24</property>
<property name="step-increment">1</property>
<property name="page-increment">4</property>
<property name="page-size">0</property>
</object>
<object class="GtkWindow" id="window">
<property name="default-width">600</property>
<property name="default-height">300</property>
<property name="title">Font rendering</property>
<child>
<object class="GtkGrid">
<property name="margin-top">10</property>
<property name="row-spacing">10</property>
<property name="column-spacing">10</property>
<child>
<object class="GtkLabel">
<property name="margin-start">10</property>
<property name="label">Text</property>
<property name="xalign">1</property>
<style><class name="dim-label"/></style>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry">
<property name="text">Fonts render</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="margin-start">10</property>
<property name="label">Font</property>
<property name="xalign">1</property>
<style><class name="dim-label"/></style>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkFontButton" id="font_button">
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="label">Hinting</property>
<property name="xalign">1</property>
<style><class name="dim-label"/></style>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="hinting">
<property name="active">0</property>
<property name="valign">center</property>
<items>
<item translatable="yes" id="none">None</item>
<item translatable="yes" id="slight">Slight</item>
<item translatable="yes" id="medium">Medium</item>
<item translatable="yes" id="full">Full</item>
</items>
</object>
<packing>
<property name="left-attach">3</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="hint_metrics">
<child>
<object class="GtkLabel">
<property name="label">Hint Metrics</property>
<style><class name="dim-label"/></style>
</object>
</child>
</object>
<packing>
<property name="left-attach">3</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="up_button">
<property name="icon-name">list-add-symbolic</property>
<style><class name="circular"/></style>
</object>
<packing>
<property name="left-attach">4</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="down_button">
<property name="icon-name">list-remove-symbolic</property>
<style><class name="circular"/></style>
</object>
<packing>
<property name="left-attach">4</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="label"></property>
<property name="hexpand">1</property>
</object>
<packing>
<property name="left-attach">6</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="orientation">horizontal</property>
<property name="halign">center</property>
<property name="valign">center</property>
<style><class name="linked"/></style>
<child>
<object class="GtkRadioButton" id="text_radio">
<property name="draw-indicator">0</property>
<property name="label">Text</property>
</object>
</child>
<child>
<object class="GtkRadioButton" id="grid_radio">
<property name="draw-indicator">0</property>
<property name="label">Grid</property>
<property name="group">text_radio</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">3</property>
<property name="width">7</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="hscrollbar-policy">automatic</property>
<property name="vscrollbar-policy">automatic</property>
<property name="propagate-natural-height">1</property>
<property name="shadow-type">in</property>
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<child>
<object class="GtkPicture" id="image">
<property name="halign">center</property>
<property name="valign">center</property>
<property name="can-shrink">0</property>
<property name="keep-aspect-ratio">1</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">4</property>
<property name="width">7</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View File

@@ -157,16 +157,15 @@ do_gestures (GtkWidget *do_widget)
NULL, NULL);
/* Swipe */
gesture = gtk_gesture_swipe_new (drawing_area);
gesture = gtk_gesture_swipe_new ();
g_signal_connect (gesture, "swipe",
G_CALLBACK (swipe_gesture_swept), drawing_area);
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture),
GTK_PHASE_BUBBLE);
g_object_weak_ref (G_OBJECT (drawing_area), (GWeakNotify) g_object_unref, gesture);
gtk_widget_add_controller (drawing_area, GTK_EVENT_CONTROLLER (gesture));
/* 3fg swipe for touchpads */
gesture = g_object_new (GTK_TYPE_GESTURE_SWIPE,
"widget", drawing_area,
"n-points", 3,
NULL);
g_signal_connect (gesture, "begin",
@@ -175,33 +174,34 @@ do_gestures (GtkWidget *do_widget)
G_CALLBACK (swipe_gesture_swept), drawing_area);
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture),
GTK_PHASE_BUBBLE);
g_object_weak_ref (G_OBJECT (drawing_area), (GWeakNotify) g_object_unref, gesture);
gtk_widget_add_controller (drawing_area, GTK_EVENT_CONTROLLER (gesture));
/* Long press */
gesture = gtk_gesture_long_press_new (drawing_area);
gesture = gtk_gesture_long_press_new ();
g_signal_connect (gesture, "pressed",
G_CALLBACK (long_press_gesture_pressed), drawing_area);
g_signal_connect (gesture, "end",
G_CALLBACK (long_press_gesture_end), drawing_area);
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture),
GTK_PHASE_BUBBLE);
g_object_weak_ref (G_OBJECT (drawing_area), (GWeakNotify) g_object_unref, gesture);
gtk_widget_add_controller (drawing_area, GTK_EVENT_CONTROLLER (gesture));
/* Rotate */
rotate = gesture = gtk_gesture_rotate_new (drawing_area);
rotate = gesture = gtk_gesture_rotate_new ();
g_signal_connect (gesture, "angle-changed",
G_CALLBACK (rotation_angle_changed), drawing_area);
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture),
GTK_PHASE_BUBBLE);
g_object_weak_ref (G_OBJECT (drawing_area), (GWeakNotify) g_object_unref, gesture);
gtk_widget_add_controller (drawing_area, GTK_EVENT_CONTROLLER (gesture));
/* Zoom */
zoom = gesture = gtk_gesture_zoom_new (drawing_area);
zoom = gesture = gtk_gesture_zoom_new ();
g_signal_connect (gesture, "scale-changed",
G_CALLBACK (zoom_scale_changed), drawing_area);
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture),
GTK_PHASE_BUBBLE);
g_object_weak_ref (G_OBJECT (drawing_area), (GWeakNotify) g_object_unref, gesture);
gtk_widget_add_controller (drawing_area, GTK_EVENT_CONTROLLER (gesture));
}
if (!gtk_widget_get_visible (window))

View File

@@ -24,13 +24,18 @@ typedef struct _GtkFishbowlChild GtkFishbowlChild;
struct _GtkFishbowlPrivate
{
GtkFishCreationFunc creation_func;
GList *children;
guint count;
gint64 last_frame_time;
gint64 update_delay;
guint tick_id;
guint use_icons: 1;
double framerate;
int last_benchmark_change;
guint benchmark : 1;
};
struct _GtkFishbowlChild
@@ -45,18 +50,25 @@ struct _GtkFishbowlChild
enum {
PROP_0,
PROP_ANIMATING,
PROP_BENCHMARK,
PROP_COUNT,
PROP_FRAMERATE,
PROP_UPDATE_DELAY,
NUM_PROPERTIES
};
static GParamSpec *props[NUM_PROPERTIES] = { NULL, };
G_DEFINE_TYPE_WITH_PRIVATE (GtkFishbowl, gtk_fishbowl, GTK_TYPE_CONTAINER)
G_DEFINE_TYPE_WITH_PRIVATE (GtkFishbowl, gtk_fishbowl, GTK_TYPE_WIDGET)
static void
gtk_fishbowl_init (GtkFishbowl *fishbowl)
{
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
gtk_widget_set_has_surface (GTK_WIDGET (fishbowl), FALSE);
priv->update_delay = G_USEC_PER_SEC;
}
/**
@@ -72,15 +84,6 @@ gtk_fishbowl_new (void)
return g_object_new (GTK_TYPE_FISHBOWL, NULL);
}
void
gtk_fishbowl_set_use_icons (GtkFishbowl *fishbowl,
gboolean use_icons)
{
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
priv->use_icons = use_icons;
}
static void
gtk_fishbowl_measure (GtkWidget *widget,
GtkOrientation orientation,
@@ -161,10 +164,9 @@ new_speed (void)
}
static void
gtk_fishbowl_add (GtkContainer *container,
GtkWidget *widget)
gtk_fishbowl_add (GtkFishbowl *fishbowl,
GtkWidget *widget)
{
GtkFishbowl *fishbowl = GTK_FISHBOWL (container);
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
GtkFishbowlChild *child_info;
@@ -186,13 +188,12 @@ gtk_fishbowl_add (GtkContainer *container,
}
static void
gtk_fishbowl_remove (GtkContainer *container,
GtkWidget *widget)
gtk_fishbowl_remove (GtkFishbowl *fishbowl,
GtkWidget *widget)
{
GtkFishbowl *fishbowl = GTK_FISHBOWL (container);
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
GtkFishbowlChild *child;
GtkWidget *widget_container = GTK_WIDGET (container);
GtkWidget *widget_bowl = GTK_WIDGET (fishbowl);
GList *children;
for (children = priv->children; children; children = children->next)
@@ -209,8 +210,8 @@ gtk_fishbowl_remove (GtkContainer *container,
g_list_free (children);
g_free (child);
if (was_visible && gtk_widget_get_visible (widget_container))
gtk_widget_queue_resize (widget_container);
if (was_visible && gtk_widget_get_visible (widget_bowl))
gtk_widget_queue_resize (widget_bowl);
priv->count--;
g_object_notify_by_pspec (G_OBJECT (fishbowl), props[PROP_COUNT]);
@@ -219,26 +220,6 @@ gtk_fishbowl_remove (GtkContainer *container,
}
}
static void
gtk_fishbowl_forall (GtkContainer *container,
GtkCallback callback,
gpointer callback_data)
{
GtkFishbowl *fishbowl = GTK_FISHBOWL (container);
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
GtkFishbowlChild *child;
GList *children;
children = priv->children;
while (children)
{
child = children->data;
children = children->next;
(* callback) (child->widget, callback_data);
}
}
static void
gtk_fishbowl_dispose (GObject *object)
{
@@ -264,10 +245,18 @@ gtk_fishbowl_set_property (GObject *object,
gtk_fishbowl_set_animating (fishbowl, g_value_get_boolean (value));
break;
case PROP_BENCHMARK:
gtk_fishbowl_set_benchmark (fishbowl, g_value_get_boolean (value));
break;
case PROP_COUNT:
gtk_fishbowl_set_count (fishbowl, g_value_get_uint (value));
break;
case PROP_UPDATE_DELAY:
gtk_fishbowl_set_update_delay (fishbowl, g_value_get_int64 (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -288,10 +277,22 @@ gtk_fishbowl_get_property (GObject *object,
g_value_set_boolean (value, gtk_fishbowl_get_animating (fishbowl));
break;
case PROP_BENCHMARK:
g_value_set_boolean (value, gtk_fishbowl_get_benchmark (fishbowl));
break;
case PROP_COUNT:
g_value_set_uint (value, gtk_fishbowl_get_count (fishbowl));
break;
case PROP_FRAMERATE:
g_value_set_double (value, gtk_fishbowl_get_framerate (fishbowl));
break;
case PROP_UPDATE_DELAY:
g_value_set_int64 (value, gtk_fishbowl_get_update_delay (fishbowl));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -303,7 +304,6 @@ gtk_fishbowl_class_init (GtkFishbowlClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
object_class->dispose = gtk_fishbowl_dispose;
object_class->set_property = gtk_fishbowl_set_property;
@@ -312,10 +312,6 @@ gtk_fishbowl_class_init (GtkFishbowlClass *klass)
widget_class->measure = gtk_fishbowl_measure;
widget_class->size_allocate = gtk_fishbowl_size_allocate;
container_class->add = gtk_fishbowl_add;
container_class->remove = gtk_fishbowl_remove;
container_class->forall = gtk_fishbowl_forall;
props[PROP_ANIMATING] =
g_param_spec_boolean ("animating",
"animating",
@@ -323,13 +319,36 @@ gtk_fishbowl_class_init (GtkFishbowlClass *klass)
FALSE,
G_PARAM_READWRITE);
props[PROP_BENCHMARK] =
g_param_spec_boolean ("benchmark",
"Benchmark",
"Adapt the count property to hit the maximum framerate",
FALSE,
G_PARAM_READWRITE);
props[PROP_COUNT] =
g_param_spec_uint ("count",
"Count",
"Number of widgets",
0, G_MAXUINT,
0,
G_PARAM_READABLE);
G_PARAM_READWRITE);
props[PROP_FRAMERATE] =
g_param_spec_double ("framerate",
"Framerate",
"Framerate of this widget in frames per second",
0, G_MAXDOUBLE,
0,
G_PARAM_READABLE);
props[PROP_UPDATE_DELAY] =
g_param_spec_int64 ("update-delay",
"Update delay",
"Number of usecs between updates",
0, G_MAXINT64,
G_USEC_PER_SEC,
G_PARAM_READWRITE);
g_object_class_install_properties (object_class, NUM_PROPERTIES, props);
}
@@ -342,96 +361,58 @@ gtk_fishbowl_get_count (GtkFishbowl *fishbowl)
return priv->count;
}
char **icon_names = NULL;
gsize n_icon_names = 0;
static void
init_icon_names (GtkIconTheme *theme)
{
GPtrArray *icons;
GList *l, *icon_list;
if (icon_names)
return;
icon_list = gtk_icon_theme_list_icons (theme, NULL);
icons = g_ptr_array_new ();
for (l = icon_list; l; l = l->next)
{
if (g_str_has_suffix (l->data, "symbolic"))
continue;
g_ptr_array_add (icons, g_strdup (l->data));
}
n_icon_names = icons->len;
g_ptr_array_add (icons, NULL); /* NULL-terminate the array */
icon_names = (char **) g_ptr_array_free (icons, FALSE);
/* don't free strings, we assigned them to the array */
g_list_free_full (icon_list, g_free);
}
static const char *
get_random_icon_name (GtkIconTheme *theme)
{
init_icon_names (theme);
return icon_names[g_random_int_range(0, n_icon_names)];
}
static GType
get_random_widget_type ()
{
GType types[] = {
GTK_TYPE_SWITCH,
GTK_TYPE_BUTTON,
GTK_TYPE_ENTRY,
GTK_TYPE_SPIN_BUTTON,
GTK_TYPE_FONT_BUTTON,
GTK_TYPE_SCROLLBAR,
GTK_TYPE_SCALE,
GTK_TYPE_LEVEL_BAR,
GTK_TYPE_PROGRESS_BAR,
GTK_TYPE_RADIO_BUTTON,
GTK_TYPE_CHECK_BUTTON
};
return types[g_random_int_range (0, G_N_ELEMENTS (types))];
}
void
gtk_fishbowl_set_count (GtkFishbowl *fishbowl,
guint count)
{
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
if (priv->count == count)
return;
g_object_freeze_notify (G_OBJECT (fishbowl));
while (priv->count > count)
{
gtk_container_remove (GTK_CONTAINER (fishbowl),
((GtkFishbowlChild *) priv->children->data)->widget);
gtk_fishbowl_remove (fishbowl, gtk_widget_get_first_child (GTK_WIDGET (fishbowl)));
}
while (priv->count < count)
{
GtkWidget *new_widget;
if (priv->use_icons)
{
new_widget = gtk_image_new_from_icon_name (get_random_icon_name (gtk_icon_theme_get_default ()));
gtk_image_set_icon_size (GTK_IMAGE (new_widget), GTK_ICON_SIZE_LARGE);
}
else
new_widget = g_object_new (get_random_widget_type (), NULL);
new_widget = priv->creation_func ();
gtk_container_add (GTK_CONTAINER (fishbowl), new_widget);
gtk_fishbowl_add (fishbowl, new_widget);
}
g_object_thaw_notify (G_OBJECT (fishbowl));
}
gboolean
gtk_fishbowl_get_benchmark (GtkFishbowl *fishbowl)
{
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
return priv->benchmark;
}
void
gtk_fishbowl_set_benchmark (GtkFishbowl *fishbowl,
gboolean benchmark)
{
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
if (priv->benchmark == benchmark)
return;
priv->benchmark = benchmark;
if (!benchmark)
priv->last_benchmark_change = 0;
g_object_notify_by_pspec (G_OBJECT (fishbowl), props[PROP_BENCHMARK]);
}
gboolean
gtk_fishbowl_get_animating (GtkFishbowl *fishbowl)
{
@@ -440,6 +421,111 @@ gtk_fishbowl_get_animating (GtkFishbowl *fishbowl)
return priv->tick_id != 0;
}
static gint64
guess_refresh_interval (GdkFrameClock *frame_clock)
{
gint64 interval;
gint64 i;
interval = G_MAXINT64;
for (i = gdk_frame_clock_get_history_start (frame_clock);
i < gdk_frame_clock_get_frame_counter (frame_clock);
i++)
{
GdkFrameTimings *t, *before;
gint64 ts, before_ts;
t = gdk_frame_clock_get_timings (frame_clock, i);
before = gdk_frame_clock_get_timings (frame_clock, i - 1);
if (t == NULL || before == NULL)
continue;
ts = gdk_frame_timings_get_frame_time (t);
before_ts = gdk_frame_timings_get_frame_time (before);
if (ts == 0 || before_ts == 0)
continue;
interval = MIN (interval, ts - before_ts);
}
if (interval == G_MAXINT64)
return 0;
return interval;
}
static void
gtk_fishbowl_do_update (GtkFishbowl *fishbowl)
{
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
GdkFrameClock *frame_clock;
GdkFrameTimings *start, *end;
gint64 start_counter, end_counter;
gint64 n_frames, expected_frames;
gint64 start_timestamp, end_timestamp;
gint64 interval;
frame_clock = gtk_widget_get_frame_clock (GTK_WIDGET (fishbowl));
if (frame_clock == NULL)
return;
start_counter = gdk_frame_clock_get_history_start (frame_clock);
end_counter = gdk_frame_clock_get_frame_counter (frame_clock);
start = gdk_frame_clock_get_timings (frame_clock, start_counter);
for (end = gdk_frame_clock_get_timings (frame_clock, end_counter);
end_counter > start_counter && end != NULL && !gdk_frame_timings_get_complete (end);
end = gdk_frame_clock_get_timings (frame_clock, end_counter))
end_counter--;
if (end_counter - start_counter < 4)
return;
start_timestamp = gdk_frame_timings_get_presentation_time (start);
end_timestamp = gdk_frame_timings_get_presentation_time (end);
if (start_timestamp == 0 || end_timestamp == 0)
{
start_timestamp = gdk_frame_timings_get_frame_time (start);
end_timestamp = gdk_frame_timings_get_frame_time (end);
}
n_frames = end_counter - start_counter;
priv->framerate = ((double) n_frames) * G_USEC_PER_SEC / (end_timestamp - start_timestamp);
g_object_notify_by_pspec (G_OBJECT (fishbowl), props[PROP_FRAMERATE]);
if (!priv->benchmark)
return;
interval = gdk_frame_timings_get_refresh_interval (end);
if (interval == 0)
{
interval = guess_refresh_interval (frame_clock);
if (interval == 0)
return;
}
expected_frames = round ((double) (end_timestamp - start_timestamp) / interval);
if (n_frames >= expected_frames)
{
if (priv->last_benchmark_change > 0)
priv->last_benchmark_change *= 2;
else
priv->last_benchmark_change = 1;
}
else if (n_frames + 1 < expected_frames)
{
if (priv->last_benchmark_change < 0)
priv->last_benchmark_change--;
else
priv->last_benchmark_change = -1;
}
else
{
priv->last_benchmark_change = 0;
}
gtk_fishbowl_set_count (fishbowl, MAX (1, (int) priv->count + priv->last_benchmark_change));
}
static gboolean
gtk_fishbowl_tick (GtkWidget *widget,
GdkFrameClock *frame_clock,
@@ -450,9 +536,11 @@ gtk_fishbowl_tick (GtkWidget *widget,
GtkFishbowlChild *child;
GList *l;
gint64 frame_time, elapsed;
gboolean do_update;
frame_time = gdk_frame_clock_get_frame_time (gtk_widget_get_frame_clock (widget));
elapsed = frame_time - priv->last_frame_time;
do_update = frame_time / priv->update_delay != priv->last_frame_time / priv->update_delay;
priv->last_frame_time = frame_time;
/* last frame was 0, so we're just starting to animate */
@@ -491,6 +579,9 @@ gtk_fishbowl_tick (GtkWidget *widget,
gtk_widget_queue_allocate (widget);
if (do_update)
gtk_fishbowl_do_update (fishbowl);
return G_SOURCE_CONTINUE;
}
@@ -515,8 +606,57 @@ gtk_fishbowl_set_animating (GtkFishbowl *fishbowl,
priv->last_frame_time = 0;
gtk_widget_remove_tick_callback (GTK_WIDGET (fishbowl), priv->tick_id);
priv->tick_id = 0;
priv->framerate = 0;
g_object_notify_by_pspec (G_OBJECT (fishbowl), props[PROP_FRAMERATE]);
}
g_object_notify_by_pspec (G_OBJECT (fishbowl), props[PROP_ANIMATING]);
}
double
gtk_fishbowl_get_framerate (GtkFishbowl *fishbowl)
{
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
return priv->framerate;
}
gint64
gtk_fishbowl_get_update_delay (GtkFishbowl *fishbowl)
{
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
return priv->update_delay;
}
void
gtk_fishbowl_set_update_delay (GtkFishbowl *fishbowl,
gint64 update_delay)
{
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
if (priv->update_delay == update_delay)
return;
priv->update_delay = update_delay;
g_object_notify_by_pspec (G_OBJECT (fishbowl), props[PROP_UPDATE_DELAY]);
}
void
gtk_fishbowl_set_creation_func (GtkFishbowl *fishbowl,
GtkFishCreationFunc creation_func)
{
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
g_object_freeze_notify (G_OBJECT (fishbowl));
gtk_fishbowl_set_count (fishbowl, 0);
priv->last_benchmark_change = 0;
priv->creation_func = creation_func;
gtk_fishbowl_set_count (fishbowl, 1);
g_object_thaw_notify (G_OBJECT (fishbowl));
}

View File

@@ -32,29 +32,37 @@ G_BEGIN_DECLS
typedef struct _GtkFishbowl GtkFishbowl;
typedef struct _GtkFishbowlClass GtkFishbowlClass;
typedef GtkWidget * (* GtkFishCreationFunc) (void);
struct _GtkFishbowl
{
GtkContainer container;
GtkWidget parent;
};
struct _GtkFishbowlClass
{
GtkContainerClass parent_class;
GtkWidgetClass parent_class;
};
GType gtk_fishbowl_get_type (void) G_GNUC_CONST;
GtkWidget* gtk_fishbowl_new (void);
void gtk_fishbowl_set_use_icons (GtkFishbowl *fishbowl,
gboolean use_icons);
guint gtk_fishbowl_get_count (GtkFishbowl *fishbowl);
void gtk_fishbowl_set_count (GtkFishbowl *fishbowl,
guint count);
gboolean gtk_fishbowl_get_animating (GtkFishbowl *fishbowl);
void gtk_fishbowl_set_animating (GtkFishbowl *fishbowl,
gboolean animating);
gboolean gtk_fishbowl_get_benchmark (GtkFishbowl *fishbowl);
void gtk_fishbowl_set_benchmark (GtkFishbowl *fishbowl,
gboolean animating);
double gtk_fishbowl_get_framerate (GtkFishbowl *fishbowl);
gint64 gtk_fishbowl_get_update_delay (GtkFishbowl *fishbowl);
void gtk_fishbowl_set_update_delay (GtkFishbowl *fishbowl,
gint64 update_delay);
void gtk_fishbowl_set_creation_func (GtkFishbowl *fishbowl,
GtkFishCreationFunc creation_func);
G_END_DECLS

View File

@@ -105,14 +105,14 @@ follow_if_link (GtkWidget *text_view,
/* Links can be activated by pressing Enter.
*/
static gboolean
key_press_event (GtkWidget *text_view,
GdkEventKey *event)
key_pressed (GtkEventController *controller,
guint keyval,
guint keycode,
GdkModifierType modifiers,
GtkWidget *text_view)
{
GtkTextIter iter;
GtkTextBuffer *buffer;
guint keyval;
gdk_event_get_keyval ((GdkEvent *)event, &keyval);
switch (keyval)
{
@@ -128,7 +128,7 @@ key_press_event (GtkWidget *text_view,
break;
}
return FALSE;
return GDK_EVENT_PROPAGATE;
}
static void set_cursor_if_appropriate (GtkTextView *text_view,
@@ -241,6 +241,7 @@ do_hypertext (GtkWidget *do_widget)
GtkWidget *view;
GtkWidget *sw;
GtkTextBuffer *buffer;
GtkEventController *controller;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Hypertext");
@@ -255,8 +256,9 @@ do_hypertext (GtkWidget *do_widget)
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD);
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 20);
gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 20);
g_signal_connect (view, "key-press-event",
G_CALLBACK (key_press_event), NULL);
controller = gtk_event_controller_key_new ();
g_signal_connect (controller, "key-pressed", G_CALLBACK (key_pressed), view);
gtk_widget_add_controller (view, controller);
g_signal_connect (view, "event",
G_CALLBACK (event_cb), NULL);

View File

@@ -1,15 +1,15 @@
/* Images
*
* GtkImage is used to display an image; the image can be in a number of formats.
* Typically, you load an image into a GdkPixbuf, then display the pixbuf.
* GtkImage and GtkPicture are used to display an image; the image can be
* in a number of formats.
*
* GtkImage is the widget used to display icons or images that should be
* sized and styled like an icon, while GtkPicture is used for images
* that should be displayed as-is.
*
* This demo code shows some of the more obscure cases, in the simple
* case a call to gtk_image_new_from_file() is all you need.
*
* If you want to put image data in your program as a C variable,
* use the make-inline-pixbuf program that comes with GTK+.
* This way you won't need to depend on loading external files, your
* application binary can be self-contained.
* case a call to gtk_picture_new_for_file() or
* gtk_image_new_from_icon_name() is all you need.
*/
#include <gtk/gtk.h>
@@ -27,9 +27,9 @@ progressive_prepared_callback (GdkPixbufLoader *loader,
gpointer data)
{
GdkPixbuf *pixbuf;
GtkWidget *image;
GtkWidget *picture;
image = GTK_WIDGET (data);
picture = GTK_WIDGET (data);
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
@@ -38,7 +38,7 @@ progressive_prepared_callback (GdkPixbufLoader *loader,
*/
gdk_pixbuf_fill (pixbuf, 0xaaaaaaff);
gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
gtk_picture_set_pixbuf (GTK_PICTURE (picture), pixbuf);
}
static void
@@ -49,21 +49,21 @@ progressive_updated_callback (GdkPixbufLoader *loader,
gint height,
gpointer data)
{
GtkWidget *image;
GtkWidget *picture;
GdkPixbuf *pixbuf;
image = GTK_WIDGET (data);
picture = GTK_WIDGET (data);
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
gtk_picture_set_pixbuf (GTK_PICTURE (picture), pixbuf);
}
static gint
progressive_timeout (gpointer data)
{
GtkWidget *image;
GtkWidget *picture;
image = GTK_WIDGET (data);
picture = GTK_WIDGET (data);
/* This shows off fully-paranoid error handling, so looks scary.
* You could factor out the error handling code into a nice separate
@@ -241,10 +241,10 @@ progressive_timeout (gpointer data)
pixbuf_loader = gdk_pixbuf_loader_new ();
g_signal_connect (pixbuf_loader, "area-prepared",
G_CALLBACK (progressive_prepared_callback), image);
G_CALLBACK (progressive_prepared_callback), picture);
g_signal_connect (pixbuf_loader, "area-updated",
G_CALLBACK (progressive_updated_callback), image);
G_CALLBACK (progressive_updated_callback), picture);
}
/* leave timeout installed */
@@ -252,7 +252,7 @@ progressive_timeout (gpointer data)
}
static void
start_progressive_loading (GtkWidget *image)
start_progressive_loading (GtkWidget *picture)
{
/* This is obviously totally contrived (we slow down loading
* on purpose to show how incremental loading works).
@@ -261,7 +261,7 @@ start_progressive_loading (GtkWidget *image)
* The timeout simply simulates a slow data source by inserting
* pauses in the reading process.
*/
load_timeout = g_timeout_add (150, progressive_timeout, image);
load_timeout = g_timeout_add (150, progressive_timeout, picture);
g_source_set_name_by_id (load_timeout, "[gtk+] progressive_timeout");
}
@@ -323,6 +323,7 @@ do_images (GtkWidget *do_widget)
GtkWidget *hbox;
GtkWidget *base_vbox;
GtkWidget *image;
GtkWidget *picture;
GtkWidget *label;
GtkWidget *button;
GdkPaintable *paintable;
@@ -380,9 +381,9 @@ do_images (GtkWidget *do_widget)
gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
gtk_box_pack_start (GTK_BOX (vbox), frame);
image = gtk_image_new_from_resource ("/images/floppybuddy.gif");
picture = gtk_picture_new_for_resource ("/images/floppybuddy.gif");
gtk_container_add (GTK_CONTAINER (frame), image);
gtk_container_add (GTK_CONTAINER (frame), picture);
/* Symbolic icon */
@@ -422,10 +423,10 @@ do_images (GtkWidget *do_widget)
/* Create an empty image for now; the progressive loader
* will create the pixbuf and fill it in.
*/
image = gtk_image_new_from_pixbuf (NULL);
gtk_container_add (GTK_CONTAINER (frame), image);
picture = gtk_picture_new ();
gtk_container_add (GTK_CONTAINER (frame), picture);
start_progressive_loading (image);
start_progressive_loading (picture);
/* Video */
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
@@ -456,11 +457,10 @@ do_images (GtkWidget *do_widget)
gtk_box_pack_start (GTK_BOX (vbox), label);
paintable = gtk_widget_paintable_new (do_widget);
image = gtk_image_new_from_paintable (paintable);
gtk_image_set_can_shrink (GTK_IMAGE (image), TRUE);
gtk_widget_set_size_request (image, 100, 100);
gtk_widget_set_valign (image, GTK_ALIGN_START);
gtk_container_add (GTK_CONTAINER (vbox), image);
picture = gtk_picture_new_for_paintable (paintable);
gtk_widget_set_size_request (picture, 100, 100);
gtk_widget_set_valign (picture, GTK_ALIGN_START);
gtk_container_add (GTK_CONTAINER (vbox), picture);
/* Sensitivity control */
button = gtk_toggle_button_new_with_mnemonic ("_Insensitive");

View File

@@ -154,6 +154,7 @@
</child>
<child>
<object class="GtkBox" id="extra_buttons_box">
<property name="visible">0</property>
<property name="spacing">6</property>
<child>
<object class="GtkButton" id="reply-button">

View File

@@ -532,7 +532,106 @@ fontify (GtkTextBuffer *source_buffer)
}
}
static GtkWidget *create_text (GtkWidget **text_view, gboolean is_source);
static GtkWidget *
display_image (const char *resource)
{
GtkWidget *sw, *image;
image = gtk_image_new_from_resource (resource);
gtk_widget_set_halign (image, GTK_ALIGN_CENTER);
gtk_widget_set_valign (image, GTK_ALIGN_CENTER);
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_container_add (GTK_CONTAINER (sw), image);
return sw;
}
static GtkWidget *
display_text (const char *resource)
{
GtkTextBuffer *buffer;
GtkWidget *textview, *sw;
GBytes *bytes;
bytes = g_resources_lookup_data (resource, 0, NULL);
g_assert (bytes);
g_assert (g_utf8_validate (g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes), NULL));
textview = gtk_text_view_new ();
g_object_set (textview,
"left-margin", 20,
"right-margin", 20,
"top-margin", 20,
"bottom-margin", 20,
NULL);
gtk_text_view_set_editable (GTK_TEXT_VIEW (textview), FALSE);
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (textview), FALSE);
/* Make it a bit nicer for text. */
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (textview), GTK_WRAP_WORD);
gtk_text_view_set_pixels_above_lines (GTK_TEXT_VIEW (textview), 2);
gtk_text_view_set_pixels_below_lines (GTK_TEXT_VIEW (textview), 2);
buffer = gtk_text_buffer_new (NULL);
gtk_text_buffer_set_text (buffer, g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes));
if (g_str_has_suffix (resource, ".c"))
fontify (buffer);
gtk_text_view_set_buffer (GTK_TEXT_VIEW (textview), buffer);
g_bytes_unref (bytes);
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
GTK_SHADOW_NONE);
gtk_container_add (GTK_CONTAINER (sw), textview);
return sw;
}
static GtkWidget *
display_video (const char *resource)
{
GtkWidget *video;
video = gtk_video_new_for_resource (resource);
gtk_video_set_loop (GTK_VIDEO (video), TRUE);
return video;
}
static GtkWidget *
display_nothing (const char *resource)
{
GtkWidget *widget;
char *str;
str = g_strdup_printf ("The lazy GTK developers forgot to add a way to display the resource '%s'", resource);
widget = gtk_label_new (str);
gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
g_free (str);
return widget;
}
static struct {
const char *extension;
GtkWidget * (* display_func) (const char *resource);
} display_funcs[] = {
{ ".gif", display_image },
{ ".jpg", display_image },
{ ".png", display_image },
{ ".c", display_text },
{ ".css", display_text },
{ ".glsl", display_text },
{ ".h", display_text },
{ ".txt", display_text },
{ ".ui", display_text },
{ ".webm", display_video }
};
static void
add_data_tab (const gchar *demoname)
@@ -540,7 +639,7 @@ add_data_tab (const gchar *demoname)
gchar *resource_dir, *resource_name;
gchar **resources;
GtkWidget *widget, *label;
guint i;
guint i, j;
resource_dir = g_strconcat ("/", demoname, NULL);
resources = g_resources_enumerate_children (resource_dir, 0, NULL);
@@ -554,58 +653,22 @@ add_data_tab (const gchar *demoname)
{
resource_name = g_strconcat (resource_dir, "/", resources[i], NULL);
widget = gtk_image_new_from_resource (resource_name);
if (gtk_image_get_paintable (GTK_IMAGE (widget)) == NULL)
for (j = 0; j < G_N_ELEMENTS(display_funcs); j++)
{
GBytes *bytes;
/* So we've used the best API available to figure out it's
* not an image. Let's try something else then.
*/
g_object_ref_sink (widget);
g_object_unref (widget);
bytes = g_resources_lookup_data (resource_name, 0, NULL);
g_assert (bytes);
if (g_utf8_validate (g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes), NULL))
{
/* Looks like it parses as text. Dump it into a textview then! */
GtkTextBuffer *buffer;
GtkWidget *textview;
widget = create_text (&textview, FALSE);
buffer = gtk_text_buffer_new (NULL);
gtk_text_buffer_set_text (buffer, g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes));
if (g_str_has_suffix (resource_name, ".c"))
fontify (buffer);
gtk_text_view_set_buffer (GTK_TEXT_VIEW (textview), buffer);
}
else
{
g_warning ("Don't know how to display resource '%s'", resource_name);
widget = NULL;
}
g_bytes_unref (bytes);
if (g_str_has_suffix (resource_name, display_funcs[j].extension))
break;
}
if (GTK_IS_IMAGE (widget))
{
GtkWidget *sw;
gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_container_add (GTK_CONTAINER (sw), widget);
widget = sw;
}
if (j < G_N_ELEMENTS(display_funcs))
widget = display_funcs[j].display_func (resource_name);
else
widget = display_nothing (resource_name);
label = gtk_label_new (resources[i]);
gtk_widget_show (label);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), widget, label);
gtk_container_child_set (GTK_CONTAINER (notebook),
GTK_WIDGET (widget),
widget,
"tab-expand", TRUE,
NULL);
@@ -825,49 +888,6 @@ selection_cb (GtkTreeSelection *selection,
g_free (filename);
}
static GtkWidget *
create_text (GtkWidget **view,
gboolean is_source)
{
GtkWidget *scrolled_window;
GtkWidget *text_view;
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_SHADOW_NONE);
*view = text_view = gtk_text_view_new ();
g_object_set (text_view,
"left-margin", 20,
"right-margin", 20,
"top-margin", 20,
"bottom-margin", 20,
NULL);
gtk_text_view_set_editable (GTK_TEXT_VIEW (text_view), FALSE);
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (text_view), FALSE);
gtk_container_add (GTK_CONTAINER (scrolled_window), text_view);
if (is_source)
{
gtk_text_view_set_monospace (GTK_TEXT_VIEW (text_view), TRUE);
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text_view), GTK_WRAP_NONE);
}
else
{
/* Make it a bit nicer for text. */
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text_view), GTK_WRAP_WORD);
gtk_text_view_set_pixels_above_lines (GTK_TEXT_VIEW (text_view), 2);
gtk_text_view_set_pixels_below_lines (GTK_TEXT_VIEW (text_view), 2);
}
return scrolled_window;
}
static void
populate_model (GtkTreeModel *model)
{

View File

@@ -26,7 +26,7 @@ demos = files([
'expander.c',
'filtermodel.c',
'fishbowl.c',
'widgetbowl.c',
'fontrendering.c',
'foreigndrawing.c',
'gestures.c',
'glarea.c',
@@ -45,6 +45,7 @@ demos = files([
'modelbutton.c',
'overlay.c',
'overlay2.c',
'paint.c',
'paintable.c',
'paintable_animated.c',
'paintable_mediastream.c',
@@ -61,6 +62,7 @@ demos = files([
'shortcuts.c',
'sidebar.c',
'sizegroup.c',
'sliding_puzzle.c',
'spinbutton.c',
'spinner.c',
'stack.c',
@@ -76,7 +78,7 @@ demos = files([
gtkdemo_deps = [ libgtk_dep, ]
extra_demo_sources = files(['main.c', 'gtkfishbowl.c', 'fontplane.c', 'gtkgears.c'])
extra_demo_sources = files(['main.c', 'gtkfishbowl.c', 'fontplane.c', 'gtkgears.c', 'puzzlepiece.c'])
if harfbuzz_dep.found() and pangoft_dep.found()
demos += files('font_features.c')

View File

@@ -56,6 +56,7 @@
<child>
<object class="GtkModelButton">
<property name="action-name">win.color</property>
<property name="action-target">'red'</property>
<property name="text">Red</property>
<property name="inverted">1</property>
</object>
@@ -63,6 +64,7 @@
<child>
<object class="GtkModelButton">
<property name="action-name">win.color</property>
<property name="action-target">'green'</property>
<property name="text">Green</property>
<property name="inverted">1</property>
</object>
@@ -70,6 +72,7 @@
<child>
<object class="GtkModelButton">
<property name="action-name">win.color</property>
<property name="action-target">'blue'</property>
<property name="text">Blue</property>
<property name="inverted">1</property>
</object>

283
demos/gtk-demo/paint.c Normal file
View File

@@ -0,0 +1,283 @@
/* Paint
*
* Demonstrates practical handling of drawing tablets in a real world
* usecase.
*/
#include <gtk/gtk.h>
typedef struct
{
GtkWidget parent_instance;
cairo_surface_t *surface;
cairo_t *cr;
GdkRGBA draw_color;
} DrawingArea;
typedef struct
{
GtkWidgetClass parent_class;
} DrawingAreaClass;
G_DEFINE_TYPE (DrawingArea, drawing_area, GTK_TYPE_WIDGET)
static void
drawing_area_ensure_surface (DrawingArea *area,
gint width,
gint height)
{
if (!area->surface ||
cairo_image_surface_get_width (area->surface) != width ||
cairo_image_surface_get_height (area->surface) != height)
{
cairo_surface_t *surface;
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
width, height);
if (area->surface)
{
cairo_t *cr;
cr = cairo_create (surface);
cairo_set_source_surface (cr, area->surface, 0, 0);
cairo_paint (cr);
cairo_surface_destroy (area->surface);
cairo_destroy (area->cr);
cairo_destroy (cr);
}
area->surface = surface;
area->cr = cairo_create (surface);
}
}
static void
drawing_area_size_allocate (GtkWidget *widget,
const GtkAllocation *allocation,
int baseline)
{
DrawingArea *area = (DrawingArea *) widget;
drawing_area_ensure_surface (area, allocation->width, allocation->height);
GTK_WIDGET_CLASS (drawing_area_parent_class)->size_allocate (widget, allocation, baseline);
}
static void
drawing_area_map (GtkWidget *widget)
{
GtkAllocation allocation;
GTK_WIDGET_CLASS (drawing_area_parent_class)->map (widget);
gtk_widget_get_allocation (widget, &allocation);
drawing_area_ensure_surface ((DrawingArea *) widget,
allocation.width, allocation.height);
}
static void
drawing_area_unmap (GtkWidget *widget)
{
DrawingArea *area = (DrawingArea *) widget;
g_clear_pointer (&area->cr, cairo_destroy);
g_clear_pointer (&area->surface, cairo_surface_destroy);
GTK_WIDGET_CLASS (drawing_area_parent_class)->unmap (widget);
}
static void
drawing_area_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
{
DrawingArea *area = (DrawingArea *) widget;
GtkAllocation allocation;
cairo_t *cr;
gtk_widget_get_allocation (widget, &allocation);
cr = gtk_snapshot_append_cairo (snapshot,
&GRAPHENE_RECT_INIT (
0, 0,
allocation.width,
allocation.height
));
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_paint (cr);
cairo_set_source_surface (cr, area->surface, 0, 0);
cairo_paint (cr);
cairo_set_source_rgb (cr, 0.6, 0.6, 0.6);
cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
cairo_stroke (cr);
cairo_destroy (cr);
}
static void
drawing_area_class_init (DrawingAreaClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
widget_class->size_allocate = drawing_area_size_allocate;
widget_class->snapshot = drawing_area_snapshot;
widget_class->map = drawing_area_map;
widget_class->unmap = drawing_area_unmap;
}
static void
drawing_area_apply_stroke (DrawingArea *area,
GdkDeviceTool *tool,
gdouble x,
gdouble y,
gdouble pressure)
{
if (gdk_device_tool_get_tool_type (tool) == GDK_DEVICE_TOOL_TYPE_ERASER)
{
cairo_set_line_width (area->cr, 10 * pressure);
cairo_set_operator (area->cr, CAIRO_OPERATOR_DEST_OUT);
}
else
{
cairo_set_line_width (area->cr, 4 * pressure);
cairo_set_operator (area->cr, CAIRO_OPERATOR_SATURATE);
}
cairo_set_source_rgba (area->cr, area->draw_color.red,
area->draw_color.green, area->draw_color.blue,
area->draw_color.alpha * pressure);
//cairo_set_source_rgba (area->cr, 0, 0, 0, pressure);
cairo_line_to (area->cr, x, y);
cairo_stroke (area->cr);
cairo_move_to (area->cr, x, y);
}
static void
stylus_gesture_down (GtkGestureStylus *gesture,
gdouble x,
gdouble y,
DrawingArea *area)
{
cairo_new_path (area->cr);
}
static void
stylus_gesture_motion (GtkGestureStylus *gesture,
gdouble x,
gdouble y,
DrawingArea *area)
{
GdkTimeCoord *backlog;
GdkDeviceTool *tool;
gdouble pressure;
guint n_items;
tool = gtk_gesture_stylus_get_device_tool (gesture);
if (gtk_gesture_stylus_get_backlog (gesture, &backlog, &n_items))
{
guint i;
for (i = 0; i < n_items; i++)
{
drawing_area_apply_stroke (area, tool,
backlog[i].axes[GDK_AXIS_X],
backlog[i].axes[GDK_AXIS_Y],
backlog[i].axes[GDK_AXIS_PRESSURE]);
}
g_free (backlog);
}
else
{
if (!gtk_gesture_stylus_get_axis (gesture, GDK_AXIS_PRESSURE, &pressure))
pressure = 1;
drawing_area_apply_stroke (area, tool, x, y, pressure);
}
gtk_widget_queue_draw (GTK_WIDGET (area));
}
static void
drawing_area_init (DrawingArea *area)
{
GtkGesture *gesture;
gtk_widget_set_has_surface (GTK_WIDGET (area), FALSE);
gesture = gtk_gesture_stylus_new ();
g_signal_connect (gesture, "down",
G_CALLBACK (stylus_gesture_down), area);
g_signal_connect (gesture, "motion",
G_CALLBACK (stylus_gesture_motion), area);
gtk_widget_add_controller (GTK_WIDGET (area), GTK_EVENT_CONTROLLER (gesture));
area->draw_color = (GdkRGBA) { 0, 0, 0, 1 };
}
GtkWidget *
drawing_area_new (void)
{
return g_object_new (drawing_area_get_type (), NULL);
}
void
drawing_area_set_color (DrawingArea *area,
GdkRGBA *color)
{
area->draw_color = *color;
}
static void
color_button_color_set (GtkColorButton *button,
DrawingArea *draw_area)
{
GdkRGBA color;
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (button), &color);
drawing_area_set_color (draw_area, &color);
}
GtkWidget *
do_paint (GtkWidget *toplevel)
{
static GtkWidget *window = NULL;
if (!window)
{
GtkWidget *draw_area, *headerbar, *colorbutton;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
draw_area = drawing_area_new ();
gtk_container_add (GTK_CONTAINER (window), draw_area);
headerbar = gtk_header_bar_new ();
gtk_header_bar_set_title (GTK_HEADER_BAR (headerbar), "Paint");
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (headerbar), TRUE);
colorbutton = gtk_color_button_new ();
g_signal_connect (colorbutton, "color-set",
G_CALLBACK (color_button_color_set), draw_area);
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (colorbutton),
&(GdkRGBA) { 0, 0, 0, 1 });
gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), colorbutton);
gtk_window_set_titlebar (GTK_WINDOW (window), headerbar);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &window);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_widget_destroy (window);
return window;
}

View File

@@ -56,15 +56,13 @@ gtk_nuclear_snapshot (GtkSnapshot *snapshot,
gtk_snapshot_append_color (snapshot,
&(GdkRGBA) { 0.9, 0.75, 0.15, 1.0 },
&GRAPHENE_RECT_INIT (0, 0, width, height),
"Yellow background");
&GRAPHENE_RECT_INIT (0, 0, width, height));
size = MIN (width, height);
cr = gtk_snapshot_append_cairo (snapshot,
&GRAPHENE_RECT_INIT ((width - size) / 2.0,
(height - size) / 2.0,
size, size),
"Radioactive Icon");
size, size));
cairo_translate (cr, width / 2.0, height / 2.0);
cairo_scale (cr, size, size);
cairo_rotate (cr, rotation);

View File

@@ -77,7 +77,6 @@ entry_size_allocate_cb (GtkEntry *entry,
static void
entry_icon_press_cb (GtkEntry *entry,
GtkEntryIconPosition icon_pos,
GdkEvent *event,
gpointer user_data)
{
GtkWidget *popover = user_data;
@@ -119,7 +118,7 @@ day_selected_cb (GtkCalendar *calendar,
gtk_widget_show (popover);
gdk_event_free (event);
g_object_unref (event);
}
GtkWidget *

View File

@@ -0,0 +1,220 @@
/* Paintable/A simple paintable
*
* GdkPaintable is an interface used by GTK for drawings of any sort
* that do not require layouting or positioning.
*
* This demo code gives a simple example on how a paintable can
* be created.
*
* Paintables can be used in many places inside GTK widgets, but the
* most common usage is inside GtkImage and that's what we're going
* to do here.
*/
#include <gtk/gtk.h>
#include "puzzlepiece.h"
/* Declare the struct. */
struct _GtkPuzzlePiece
{
GObject parent_instance;
GdkPaintable *puzzle;
guint x;
guint y;
guint width;
guint height;
};
struct _GtkPuzzlePieceClass
{
GObjectClass parent_class;
};
/* This is the function that draws the puzzle piece.
* It just draws a rectangular cutout of the puzzle by clipping
* away the rest.
*/
static void
gtk_puzzle_piece_snapshot (GdkPaintable *paintable,
GdkSnapshot *snapshot,
double width,
double height)
{
GtkPuzzlePiece *self = GTK_PUZZLE_PIECE (paintable);
gtk_snapshot_push_clip (snapshot,
&GRAPHENE_RECT_INIT (0, 0, width, height));
gtk_snapshot_offset (snapshot,
- width * self->x,
- height * self->y);
gdk_paintable_snapshot (self->puzzle,
snapshot,
width * self->width,
height * self->height);
gtk_snapshot_pop (snapshot);
}
static GdkPaintableFlags
gtk_puzzle_piece_get_flags (GdkPaintable *paintable)
{
GtkPuzzlePiece *self = GTK_PUZZLE_PIECE (paintable);
/* The flags are the same as the ones of the puzzle.
* If the puzzle changes in some way, so do the pieces.
*/
return gdk_paintable_get_flags (self->puzzle);
}
static int
gtk_puzzle_piece_get_intrinsic_width (GdkPaintable *paintable)
{
GtkPuzzlePiece *self = GTK_PUZZLE_PIECE (paintable);
/* We can compute our width relative to the puzzle.
* This logic even works for the case where the puzzle
* has no width, because the 0 return value is unchanged.
* Round up the value.
*/
return (gdk_paintable_get_intrinsic_width (self->puzzle) + self->width - 1) / self->width;
}
static int
gtk_puzzle_piece_get_intrinsic_height (GdkPaintable *paintable)
{
GtkPuzzlePiece *self = GTK_PUZZLE_PIECE (paintable);
/* Do the same thing we did for the width with the height.
*/
return (gdk_paintable_get_intrinsic_height (self->puzzle) + self->height - 1) / self->height;
}
static double
gtk_puzzle_piece_get_intrinsic_aspect_ratio (GdkPaintable *paintable)
{
GtkPuzzlePiece *self = GTK_PUZZLE_PIECE (paintable);
/* We can compute our aspect ratio relative to the puzzle.
* This logic again works for the case where the puzzle
* has no aspect ratio, because the 0 return value is unchanged.
*/
return gdk_paintable_get_intrinsic_aspect_ratio (self->puzzle) * self->height / self->width;
}
static void
gtk_puzzle_piece_paintable_init (GdkPaintableInterface *iface)
{
iface->snapshot = gtk_puzzle_piece_snapshot;
iface->get_flags = gtk_puzzle_piece_get_flags;
iface->get_intrinsic_width = gtk_puzzle_piece_get_intrinsic_width;
iface->get_intrinsic_height = gtk_puzzle_piece_get_intrinsic_height;
iface->get_intrinsic_aspect_ratio = gtk_puzzle_piece_get_intrinsic_aspect_ratio;
}
/* When defining the GType, we need to implement the GdkPaintable interface */
G_DEFINE_TYPE_WITH_CODE (GtkPuzzlePiece, gtk_puzzle_piece, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
gtk_puzzle_piece_paintable_init))
/* We need to declare a destructor to release our reference to the
* puzzle paintable and disconnect our signal handlers.
*/
static void
gtk_puzzle_piece_dispose (GObject *object)
{
GtkPuzzlePiece *self = GTK_PUZZLE_PIECE (object);
if (self->puzzle)
{
g_signal_handlers_disconnect_by_func (self->puzzle, gdk_paintable_invalidate_contents, self);
g_signal_handlers_disconnect_by_func (self->puzzle, gdk_paintable_invalidate_size, self);
g_clear_object (&self->puzzle);
}
G_OBJECT_CLASS (gtk_puzzle_piece_parent_class)->dispose (object);
}
/* Here's the boilerplate for the GObject declaration.
*/
static void
gtk_puzzle_piece_class_init (GtkPuzzlePieceClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->dispose = gtk_puzzle_piece_dispose;
}
static void
gtk_puzzle_piece_init (GtkPuzzlePiece *self)
{
}
/* And finally, we add a constructor.
* It is declared in the header so that the other examples
* can use it.
*/
GdkPaintable *
gtk_puzzle_piece_new (GdkPaintable *puzzle,
guint x,
guint y,
guint width,
guint height)
{
GtkPuzzlePiece *self;
/* These are sanity checks, so that we get warnings if we accidentally
* do anything stupid. */
g_return_val_if_fail (GDK_IS_PAINTABLE (puzzle), NULL);
g_return_val_if_fail (width > 0, NULL);
g_return_val_if_fail (height > 0, NULL);
g_return_val_if_fail (x < width, NULL);
g_return_val_if_fail (y < height, NULL);
self = g_object_new (GTK_TYPE_PUZZLE_PIECE, NULL);
self->puzzle = g_object_ref (puzzle);
g_signal_connect_swapped (puzzle, "invalidate-contents", G_CALLBACK (gdk_paintable_invalidate_contents), self);
g_signal_connect_swapped (puzzle, "invalidate-size", G_CALLBACK (gdk_paintable_invalidate_size), self);
self->x = x;
self->y = y;
self->width = width;
self->height = height;
return GDK_PAINTABLE (self);
}
/* Here are the accessors that we need to inspect the puzzle
* pieces in other code.
*/
GdkPaintable *
gtk_puzzle_piece_get_puzzle (GtkPuzzlePiece *self)
{
/* Add sanity checks here, too.
* If you make a habit out of this, you can always rely
* on your code having sanity checks, which makes it
* way easier to debug.
*/
g_return_val_if_fail (GTK_IS_PUZZLE_PIECE (self), NULL);
return self->puzzle;
}
guint
gtk_puzzle_piece_get_x (GtkPuzzlePiece *self)
{
g_return_val_if_fail (GTK_IS_PUZZLE_PIECE (self), 0);
return self->x;
}
guint
gtk_puzzle_piece_get_y (GtkPuzzlePiece *self)
{
g_return_val_if_fail (GTK_IS_PUZZLE_PIECE (self), 0);
return self->y;
}

View File

@@ -0,0 +1,23 @@
#ifndef __PUZZLE_PIECE_H__
#define __PUZZLE_PIECE_H__
#include <gtk/gtk.h>
/* First, add the boilerplate for the object itself.
*/
#define GTK_TYPE_PUZZLE_PIECE (gtk_puzzle_piece_get_type ())
G_DECLARE_FINAL_TYPE (GtkPuzzlePiece, gtk_puzzle_piece, GTK, PUZZLE_PIECE, GObject)
/* Then, declare all constructors */
GdkPaintable * gtk_puzzle_piece_new (GdkPaintable *puzzle,
guint x,
guint y,
guint width,
guint height);
/* Next, add the getters and setters for object properties */
GdkPaintable * gtk_puzzle_piece_get_puzzle (GtkPuzzlePiece *self);
guint gtk_puzzle_piece_get_x (GtkPuzzlePiece *self);
guint gtk_puzzle_piece_get_y (GtkPuzzlePiece *self);
#endif /* __PUZZLE_PIECE_H__ */

View File

@@ -151,11 +151,10 @@ create_search_menu (GtkWidget *entry)
static void
icon_press_cb (GtkEntry *entry,
gint position,
GdkEventButton *event,
gpointer data)
{
if (position == GTK_ENTRY_ICON_PRIMARY)
gtk_menu_popup_at_pointer (GTK_MENU (menu), (GdkEvent *) event);
gtk_menu_popup_at_pointer (GTK_MENU (menu), NULL);
}
static void

View File

@@ -27,11 +27,14 @@ changed_cb (GtkEditable *editable)
}
static gboolean
window_key_press_event_cb (GtkWidget *widget,
GdkEvent *event,
GtkSearchBar *bar)
window_event_cb (GtkWidget *widget,
GdkEvent *event,
GtkSearchBar *bar)
{
return gtk_search_bar_handle_event (bar, event);
if (gdk_event_get_event_type (event) == GDK_KEY_PRESS)
return gtk_search_bar_handle_event (bar, event);
return GDK_EVENT_PROPAGATE;
}
static void
@@ -99,8 +102,7 @@ do_search_entry2 (GtkWidget *do_widget)
gtk_box_pack_start (GTK_BOX (vbox), searchbar);
/* Hook the search bar to key presses */
g_signal_connect (window, "key-press-event",
G_CALLBACK (window_key_press_event_cb), searchbar);
g_signal_connect (window, "event", G_CALLBACK (window_event_cb), searchbar);
/* Help */
label = gtk_label_new ("Start Typing to search");

View File

@@ -0,0 +1,486 @@
/* Sliding puzzle
*
* This demo demonstrates how to use gestures and paintables to create a
* small sliding puzzle game.
*
*/
#include <gtk/gtk.h>
/* Include the header for the puzzle piece */
#include "puzzlepiece.h"
#include "paintable.h"
static GtkWidget *window = NULL;
static GtkWidget *frame = NULL;
static GtkWidget *choices = NULL;
static GtkWidget *size_spin = NULL;
static GdkPaintable *puzzle = NULL;
static gboolean solved = TRUE;
static guint width = 3;
static guint height = 3;
static guint pos_x;
static guint pos_y;
static gboolean
move_puzzle (GtkWidget *grid,
int dx,
int dy)
{
GtkWidget *pos, *next;
GdkPaintable *piece;
guint next_x, next_y;
/* We don't move anything if the puzzle is solved */
if (solved)
return FALSE;
/* Return FALSE if we can't move to where the call
* wants us to move.
*/
if ((dx < 0 && pos_x < -dx) ||
dx + pos_x >= width ||
(dy < 0 && pos_y < -dy) ||
dy + pos_y >= height)
return FALSE;
/* Compute the new position */
next_x = pos_x + dx;
next_y = pos_y + dy;
/* Get the current and next image */
pos = gtk_grid_get_child_at (GTK_GRID (grid), pos_x, pos_y);
next = gtk_grid_get_child_at (GTK_GRID (grid), next_x, next_y);
/* Move the displayed piece. */
piece = gtk_picture_get_paintable (GTK_PICTURE (next));
gtk_picture_set_paintable (GTK_PICTURE (pos), piece);
gtk_picture_set_paintable (GTK_PICTURE (next), NULL);
/* Update the current position */
pos_x = next_x;
pos_y = next_y;
/* Return TRUE because we successfully moved the piece */
return TRUE;
}
static void
shuffle_puzzle (GtkWidget *grid)
{
guint i, n_steps;
/* Do this many random moves */
n_steps = width * height * 50;
for (i = 0; i < n_steps; i++)
{
/* Get a random number for the direction to move in */
switch (g_random_int_range (0, 4))
{
case 0:
/* left */
move_puzzle (grid, -1, 0);
break;
case 1:
/* up */
move_puzzle (grid, 0, -1);
break;
case 2:
/* right */
move_puzzle (grid, 1, 0);
break;
case 3:
/* down */
move_puzzle (grid, 0, 1);
break;
default:
g_assert_not_reached ();
continue;
}
}
}
static gboolean
check_solved (GtkWidget *grid)
{
GtkWidget *picture;
GdkPaintable *piece;
guint x, y;
/* Nothing to check if the puzzle is already solved */
if (solved)
return TRUE;
/* If the empty cell isn't in the bottom right,
* the puzzle is obviously not solved */
if (pos_x != width - 1 ||
pos_y != height - 1)
return FALSE;
/* Check that all pieces are in the right position */
for (y = 0; y < height; y++)
{
for (x = 0; x < width; x++)
{
picture = gtk_grid_get_child_at (GTK_GRID (grid), x, y);
piece = gtk_picture_get_paintable (GTK_PICTURE (picture));
/* empty cell */
if (piece == NULL)
continue;
if (gtk_puzzle_piece_get_x (GTK_PUZZLE_PIECE (piece)) != x ||
gtk_puzzle_piece_get_y (GTK_PUZZLE_PIECE (piece)) != y)
return FALSE;
}
}
/* We solved the puzzle!
*/
solved = TRUE;
/* Fill the empty cell to show that we're done.
*/
picture = gtk_grid_get_child_at (GTK_GRID (grid), 0, 0);
piece = gtk_picture_get_paintable (GTK_PICTURE (picture));
piece = gtk_puzzle_piece_new (gtk_puzzle_piece_get_puzzle (GTK_PUZZLE_PIECE (piece)),
pos_x, pos_y,
width, height);
picture = gtk_grid_get_child_at (GTK_GRID (grid), pos_x, pos_y);
gtk_picture_set_paintable (GTK_PICTURE (picture), piece);
return TRUE;
}
static gboolean
puzzle_key_pressed (GtkEventControllerKey *controller,
guint keyval,
guint keycode,
GdkModifierType state,
GtkWidget *grid)
{
int dx, dy;
dx = 0;
dy = 0;
switch (keyval)
{
case GDK_KEY_KP_Left:
case GDK_KEY_Left:
/* left */
dx = -1;
break;
case GDK_KEY_KP_Up:
case GDK_KEY_Up:
/* up */
dy = -1;
break;
case GDK_KEY_KP_Right:
case GDK_KEY_Right:
/* right */
dx = 1;
break;
case GDK_KEY_KP_Down:
case GDK_KEY_Down:
/* down */
dy = 1;
break;
default:
/* We return FALSE here because we didn't handle the key that was pressed */
return FALSE;
}
if (!move_puzzle (grid, dx, dy))
{
/* Make the error sound and then return TRUE.
* We handled this key, even though we didn't
* do anything to the puzzle.
*/
gtk_widget_error_bell (grid);
return TRUE;
}
check_solved (grid);
return TRUE;
}
static void
puzzle_button_pressed (GtkGestureMultiPress *gesture,
int n_press,
double x,
double y,
GtkWidget *grid)
{
GtkWidget *child;
int l, t, i;
int pos;
child = gtk_widget_pick (grid, x, y);
if (!child)
{
gtk_widget_error_bell (grid);
return;
}
gtk_container_child_get (GTK_CONTAINER (grid), child,
"left-attach", &l,
"top-attach", &t,
NULL);
if (l == pos_x && t == pos_y)
{
gtk_widget_error_bell (grid);
}
else if (l == pos_x)
{
pos = pos_y;
for (i = t; i < pos; i++)
{
if (!move_puzzle (grid, 0, -1))
gtk_widget_error_bell (grid);
}
for (i = pos; i < t; i++)
{
if (!move_puzzle (grid, 0, 1))
gtk_widget_error_bell (grid);
}
}
else if (t == pos_y)
{
pos = pos_x;
for (i = l; i < pos; i++)
{
if (!move_puzzle (grid, -1, 0))
gtk_widget_error_bell (grid);
}
for (i = pos; i < l; i++)
{
if (!move_puzzle (grid, 1, 0))
gtk_widget_error_bell (grid);
}
}
else
{
gtk_widget_error_bell (grid);
}
}
static void
start_puzzle (GdkPaintable *puzzle)
{
GtkWidget *picture, *grid;
GtkEventController *controller;
guint x, y;
/* Remove the old grid (if there is one) */
grid = gtk_bin_get_child (GTK_BIN (frame));
if (grid)
gtk_container_remove (GTK_CONTAINER (frame), grid);
/* Create a new grid */
grid = gtk_grid_new ();
gtk_widget_set_can_focus (grid, TRUE);
gtk_container_add (GTK_CONTAINER (frame), grid);
gtk_aspect_frame_set (GTK_ASPECT_FRAME (frame), 0.5, 0.5, (float) gdk_paintable_get_intrinsic_aspect_ratio (puzzle), FALSE);
/* Add a key event controller so people can use the arrow
* keys to move the puzzle */
controller = gtk_event_controller_key_new ();
g_signal_connect (controller, "key-pressed",
G_CALLBACK (puzzle_key_pressed),
grid);
gtk_widget_add_controller (GTK_WIDGET (grid), controller);
controller = GTK_EVENT_CONTROLLER (gtk_gesture_multi_press_new ());
g_signal_connect (controller, "pressed",
G_CALLBACK (puzzle_button_pressed),
grid);
gtk_widget_add_controller (GTK_WIDGET (grid), controller);
/* Make sure the cells have equal size */
gtk_grid_set_row_homogeneous (GTK_GRID (grid), TRUE);
gtk_grid_set_column_homogeneous (GTK_GRID (grid), TRUE);
/* Reset the variables */
solved = FALSE;
pos_x = width - 1;
pos_y = height - 1;
/* add a picture for every cell */
for (y = 0; y < height; y++)
{
for (x = 0; x < width; x++)
{
GdkPaintable *piece;
/* Don't paint anything for the lsiding part of the video */
if (x == pos_x && y == pos_y)
piece = NULL;
else
piece = gtk_puzzle_piece_new (puzzle,
x, y,
width, height);
picture = gtk_picture_new_for_paintable (piece);
gtk_picture_set_keep_aspect_ratio (GTK_PICTURE (picture), FALSE);
gtk_grid_attach (GTK_GRID (grid),
picture,
x, y,
1, 1);
}
}
shuffle_puzzle (grid);
}
static void
reshuffle (void)
{
GtkWidget *grid;
grid = gtk_bin_get_child (GTK_BIN (frame));
if (solved)
start_puzzle (puzzle);
else
shuffle_puzzle (grid);
gtk_widget_grab_focus (grid);
}
static void
reconfigure (void)
{
GtkWidget *popover;
GtkWidget *grid;
GtkWidget *child;
GtkWidget *image;
GList *selected;
width = height = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (size_spin));
selected = gtk_flow_box_get_selected_children (GTK_FLOW_BOX (choices));
if (selected == NULL)
child = gtk_widget_get_first_child (choices);
else
{
child = selected->data;
g_list_free (selected);
}
image = gtk_bin_get_child (GTK_BIN (child));
puzzle = gtk_image_get_paintable (GTK_IMAGE (image));
start_puzzle (puzzle);
popover = gtk_widget_get_ancestor (size_spin, GTK_TYPE_POPOVER);
gtk_popover_popdown (GTK_POPOVER (popover));
grid = gtk_bin_get_child (GTK_BIN (frame));
gtk_widget_grab_focus (grid);
}
static void
add_choice (GtkWidget *choices,
GdkPaintable *paintable)
{
GtkWidget *icon;
icon = gtk_image_new_from_paintable (paintable);
gtk_image_set_icon_size (GTK_IMAGE (icon), GTK_ICON_SIZE_LARGE);
gtk_container_add (GTK_CONTAINER (choices), icon);
}
GtkWidget *
do_sliding_puzzle (GtkWidget *do_widget)
{
if (!window)
{
GtkWidget *header;
GtkWidget *restart;
GtkWidget *tweak;
GtkWidget *popover;
GtkWidget *tweaks;
GtkWidget *apply;
GtkWidget *label;
GtkWidget *sw;
GtkMediaStream *media;
puzzle = GDK_PAINTABLE (gdk_texture_new_from_resource ("/sliding_puzzle/portland-rose.jpg"));
tweaks = gtk_grid_new ();
gtk_grid_set_row_spacing (GTK_GRID (tweaks), 10);
gtk_grid_set_column_spacing (GTK_GRID (tweaks), 10);
g_object_set (tweaks, "margin", 10, NULL);
choices = gtk_flow_box_new ();
gtk_style_context_add_class (gtk_widget_get_style_context (choices), GTK_STYLE_CLASS_VIEW);
add_choice (choices, puzzle);
add_choice (choices, gtk_nuclear_animation_new ());
media = gtk_media_file_new_for_resource ("/images/gtk-logo.webm");
gtk_media_stream_set_loop (media, TRUE);
gtk_media_stream_set_muted (media, TRUE);
gtk_media_stream_play (media);
add_choice (choices, GDK_PAINTABLE (media));
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_container_add (GTK_CONTAINER (sw), choices);
gtk_grid_attach (GTK_GRID (tweaks), sw, 0, 0, 2, 1);
label = gtk_label_new ("Size");
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_grid_attach (GTK_GRID (tweaks), label, 0, 1, 1, 1);
size_spin = gtk_spin_button_new_with_range (2, 10, 1);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (size_spin), width);
gtk_grid_attach (GTK_GRID (tweaks), size_spin, 1, 1, 1, 1);
apply = gtk_button_new_with_label ("Apply");
gtk_widget_set_halign (apply, GTK_ALIGN_END);
gtk_grid_attach (GTK_GRID (tweaks), apply, 1, 2, 1, 1);
g_signal_connect (apply, "clicked", G_CALLBACK (reconfigure), NULL);
popover = gtk_popover_new (NULL);
gtk_popover_set_modal (GTK_POPOVER (popover), TRUE);
gtk_container_add (GTK_CONTAINER (popover), tweaks);
tweak = gtk_menu_button_new ();
gtk_menu_button_set_popover (GTK_MENU_BUTTON (tweak), popover);
gtk_button_set_icon_name (GTK_BUTTON (tweak), "emblem-system-symbolic");
restart = gtk_button_new_from_icon_name ("view-refresh-symbolic");
g_signal_connect (restart, "clicked", G_CALLBACK (reshuffle), NULL);
header = gtk_header_bar_new ();
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE);
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), restart);
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), tweak);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Sliding Puzzle");
gtk_window_set_titlebar (GTK_WINDOW (window), header);
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &window);
frame = gtk_aspect_frame_new (NULL, 0.5, 0.5, (float) gdk_paintable_get_intrinsic_aspect_ratio (puzzle), FALSE);
gtk_container_add (GTK_CONTAINER (window), frame);
start_puzzle (puzzle);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_widget_destroy (window);
return window;
}

View File

@@ -33,14 +33,14 @@ hex_spin_output (GtkSpinButton *spin_button)
{
GtkAdjustment *adjustment;
gchar *buf;
gint val;
gdouble val;
adjustment = gtk_spin_button_get_adjustment (spin_button);
val = (gint) gtk_adjustment_get_value (adjustment);
val = gtk_adjustment_get_value (adjustment);
if (fabs (val) < 1e-5)
buf = g_strdup ("0x00");
else
buf = g_strdup_printf ("0x%.2X", val);
buf = g_strdup_printf ("0x%.2X", (gint) val);
if (strcmp (buf, gtk_spin_button_get_text (spin_button)))
gtk_spin_button_set_text (spin_button, buf);
g_free (buf);

View File

@@ -1,412 +0,0 @@
/* Benchmark/Widgetbowl
*
* This is a version of the Fishbowl demo that instead shows different
* kinds of widgets, which is useful for comparing the rendering performance
* of theme specifics.
*/
#include <gtk/gtk.h>
#include "gtkfishbowl.h"
#include "gtkgears.h"
const char *const css =
".blurred-button {"
" box-shadow: 0px 0px 5px 10px rgba(0, 0, 0, 0.5);"
"}"
"";
GtkWidget *fishbowl;
static GtkWidget *
create_button (void)
{
return gtk_button_new_with_label ("Button");
}
static GtkWidget *
create_blurred_button (void)
{
GtkWidget *w = gtk_button_new ();
gtk_style_context_add_class (gtk_widget_get_style_context (w), "blurred-button");
return w;
}
static GtkWidget *
create_font_button (void)
{
return gtk_font_button_new ();
}
static GtkWidget *
create_level_bar (void)
{
GtkWidget *w = gtk_level_bar_new_for_interval (0, 100);
gtk_level_bar_set_value (GTK_LEVEL_BAR (w), 50);
/* Force them to be a bit larger */
gtk_widget_set_size_request (w, 200, -1);
return w;
}
static GtkWidget *
create_spinner (void)
{
GtkWidget *w = gtk_spinner_new ();
gtk_spinner_start (GTK_SPINNER (w));
return w;
}
static GtkWidget *
create_spinbutton (void)
{
GtkWidget *w = gtk_spin_button_new_with_range (0, 10, 1);
return w;
}
static GtkWidget *
create_label (void)
{
GtkWidget *w = gtk_label_new ("pLorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.");
gtk_label_set_line_wrap (GTK_LABEL (w), TRUE);
gtk_label_set_max_width_chars (GTK_LABEL (w), 100);
return w;
}
static GtkWidget *
create_video (void)
{
GtkMediaStream *stream = gtk_media_file_new_for_resource ("/images/gtk-logo.webm");
GtkWidget *w = gtk_image_new_from_paintable (GDK_PAINTABLE (stream));
gtk_media_stream_set_loop (stream, TRUE);
gtk_media_stream_play (stream);
g_object_unref (stream);
return w;
}
static GtkWidget *
create_gears (void)
{
GtkWidget *w = gtk_gears_new ();
gtk_widget_set_size_request (w, 100, 100);
return w;
}
static const struct {
const char *name;
GtkWidget * (*create_func) (void);
} widget_types[] = {
{ "Button", create_button },
{ "Blurbutton", create_blurred_button },
{ "Fontbutton", create_font_button },
{ "Levelbar" , create_level_bar },
{ "Label" , create_label },
{ "Spinner" , create_spinner },
{ "Spinbutton", create_spinbutton },
{ "Video", create_video },
{ "Gears", create_gears },
};
static int selected_widget_type = -1;
static const int N_WIDGET_TYPES = G_N_ELEMENTS (widget_types);
#define N_STATS 5
#define STATS_UPDATE_TIME G_USEC_PER_SEC
static void
set_widget_type (GtkWidget *headerbar,
int widget_type_index)
{
GList *children, *l;
if (widget_type_index == selected_widget_type)
return;
/* Remove everything */
children = gtk_container_get_children (GTK_CONTAINER (fishbowl));
for (l = children; l; l = l->next)
{
gtk_container_remove (GTK_CONTAINER (fishbowl), (GtkWidget*)l->data);
}
g_list_free (children);
selected_widget_type = widget_type_index;
gtk_header_bar_set_title (GTK_HEADER_BAR (headerbar),
widget_types[selected_widget_type].name);
}
typedef struct _Stats Stats;
struct _Stats {
gint64 last_stats;
gint64 last_frame;
gint last_suggestion;
guint frame_counter_max;
guint stats_index;
guint frame_counter[N_STATS];
guint item_counter[N_STATS];
};
static Stats *
get_stats (GtkWidget *widget)
{
static GQuark stats_quark = 0;
Stats *stats;
if (G_UNLIKELY (stats_quark == 0))
stats_quark = g_quark_from_static_string ("stats");
stats = g_object_get_qdata (G_OBJECT (widget), stats_quark);
if (stats == NULL)
{
stats = g_new0 (Stats, 1);
g_object_set_qdata_full (G_OBJECT (widget), stats_quark, stats, g_free);
stats->last_frame = gdk_frame_clock_get_frame_time (gtk_widget_get_frame_clock (widget));
stats->last_stats = stats->last_frame;
}
return stats;
}
static void
do_stats (GtkWidget *widget,
GtkWidget *info_label,
gint *suggested_change)
{
Stats *stats;
gint64 frame_time;
stats = get_stats (widget);
frame_time = gdk_frame_clock_get_frame_time (gtk_widget_get_frame_clock (widget));
if (stats->last_stats + STATS_UPDATE_TIME < frame_time)
{
char *new_label;
guint i, n_frames;
n_frames = 0;
for (i = 0; i < N_STATS; i++)
{
n_frames += stats->frame_counter[i];
}
new_label = g_strdup_printf ("widgets - %.1f fps",
(double) G_USEC_PER_SEC * n_frames
/ (N_STATS * STATS_UPDATE_TIME));
gtk_label_set_label (GTK_LABEL (info_label), new_label);
g_free (new_label);
if (stats->frame_counter[stats->stats_index] >= 19 * stats->frame_counter_max / 20)
{
if (stats->last_suggestion > 0)
stats->last_suggestion *= 2;
else
stats->last_suggestion = 1;
}
else
{
if (stats->last_suggestion < 0)
stats->last_suggestion--;
else
stats->last_suggestion = -1;
stats->last_suggestion = MAX (stats->last_suggestion, 1 - (int) stats->item_counter[stats->stats_index]);
}
stats->stats_index = (stats->stats_index + 1) % N_STATS;
stats->frame_counter[stats->stats_index] = 0;
stats->item_counter[stats->stats_index] = stats->item_counter[(stats->stats_index + N_STATS - 1) % N_STATS];
stats->last_stats = frame_time;
if (suggested_change)
*suggested_change = stats->last_suggestion;
else
stats->last_suggestion = 0;
}
else
{
if (suggested_change)
*suggested_change = 0;
}
stats->last_frame = frame_time;
stats->frame_counter[stats->stats_index]++;
stats->frame_counter_max = MAX (stats->frame_counter_max, stats->frame_counter[stats->stats_index]);
}
static void
stats_update (GtkWidget *widget)
{
Stats *stats;
stats = get_stats (widget);
stats->item_counter[stats->stats_index] = gtk_fishbowl_get_count (GTK_FISHBOWL (widget));
}
static gboolean
move_fish (GtkWidget *bowl,
GdkFrameClock *frame_clock,
gpointer info_label)
{
gint suggested_change = 0;
do_stats (bowl, info_label, &suggested_change);
if (suggested_change > 0)
{
int i;
for (i = 0; i < suggested_change; i ++)
{
GtkWidget *new_widget = widget_types[selected_widget_type].create_func ();
gtk_container_add (GTK_CONTAINER (fishbowl), new_widget);
}
}
else if (suggested_change < 0)
{
GList *children, *l;
int n_removed = 0;
children = gtk_container_get_children (GTK_CONTAINER (fishbowl));
for (l = children; l; l = l->next)
{
gtk_container_remove (GTK_CONTAINER (fishbowl), (GtkWidget *)l->data);
n_removed ++;
if (n_removed >= (-suggested_change))
break;
}
g_list_free (children);
}
stats_update (bowl);
return G_SOURCE_CONTINUE;
}
static void
next_button_clicked_cb (GtkButton *source,
gpointer user_data)
{
GtkWidget *headerbar = user_data;
int new_index;
if (selected_widget_type + 1 >= N_WIDGET_TYPES)
new_index = 0;
else
new_index = selected_widget_type + 1;
set_widget_type (headerbar, new_index);
}
static void
prev_button_clicked_cb (GtkButton *source,
gpointer user_data)
{
GtkWidget *headerbar = user_data;
int new_index;
if (selected_widget_type - 1 < 0)
new_index = N_WIDGET_TYPES - 1;
else
new_index = selected_widget_type - 1;
set_widget_type (headerbar, new_index);
}
GtkWidget *
do_widgetbowl (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
static GtkCssProvider *provider = NULL;
gtk_init ();
if (provider == NULL)
{
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider, css, -1);
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
if (!window)
{
GtkWidget *info_label;
GtkWidget *count_label;
GtkWidget *titlebar;
GtkWidget *title_box;
GtkWidget *left_box;
GtkWidget *next_button;
GtkWidget *prev_button;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
titlebar = gtk_header_bar_new ();
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (titlebar), TRUE);
info_label = gtk_label_new ("widget - 00.0 fps");
count_label = gtk_label_new ("0");
fishbowl = gtk_fishbowl_new ();
title_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
prev_button = gtk_button_new_from_icon_name ("pan-start-symbolic");
next_button = gtk_button_new_from_icon_name ("pan-end-symbolic");
left_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
g_object_bind_property (fishbowl, "count", count_label, "label", 0);
g_signal_connect (next_button, "clicked", G_CALLBACK (next_button_clicked_cb), titlebar);
g_signal_connect (prev_button, "clicked", G_CALLBACK (prev_button_clicked_cb), titlebar);
gtk_fishbowl_set_animating (GTK_FISHBOWL (fishbowl), TRUE);
gtk_widget_set_hexpand (title_box, TRUE);
gtk_widget_set_halign (title_box, GTK_ALIGN_END);
gtk_window_set_titlebar (GTK_WINDOW (window), titlebar);
gtk_container_add (GTK_CONTAINER (title_box), count_label);
gtk_container_add (GTK_CONTAINER (title_box), info_label);
gtk_header_bar_pack_end (GTK_HEADER_BAR (titlebar), title_box);
gtk_container_add (GTK_CONTAINER (window), fishbowl);
gtk_style_context_add_class (gtk_widget_get_style_context (left_box), "linked");
gtk_container_add (GTK_CONTAINER (left_box), prev_button);
gtk_container_add (GTK_CONTAINER (left_box), next_button);
gtk_header_bar_pack_start (GTK_HEADER_BAR (titlebar), left_box);
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &window);
gtk_widget_realize (window);
gtk_widget_add_tick_callback (fishbowl, move_fish, info_label, NULL);
set_widget_type (titlebar, 0);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_widget_destroy (window);
return window;
}

View File

@@ -32,7 +32,7 @@ media-view-subtitles=The icon used to show subtitles in a media player
[network]
Name=Network
Description=Icons related to network status");
Description=Icons related to network status
network-transmit-receive=The icon used data is being both transmitted and received simultaneously, while the computing device is connected to a network
network-transmit=The icon used when data is being transmitted, while the computing device is connected to a network

View File

@@ -286,13 +286,16 @@ populate (IconBrowserWindow *win)
}
static gboolean
key_press_event_cb (GtkWidget *widget,
GdkEvent *event,
gpointer data)
key_event_cb (GtkEventController *controller,
guint keyval,
guint keycode,
GdkModifierType state,
gpointer data)
{
IconBrowserWindow *win = data;
return gtk_search_bar_handle_event (GTK_SEARCH_BAR (win->searchbar), event);
return gtk_search_bar_handle_event (GTK_SEARCH_BAR (win->searchbar),
gtk_get_current_event ());
}
static void
@@ -373,10 +376,9 @@ search_mode_toggled (GObject *searchbar, GParamSpec *pspec, IconBrowserWindow *w
static void
get_image_data (GtkWidget *widget,
GdkDragContext *context,
GdkDrag *drag,
GtkSelectionData *selection,
guint target_info,
guint time,
gpointer data)
{
GtkWidget *image;
@@ -396,10 +398,9 @@ get_image_data (GtkWidget *widget,
static void
get_scalable_image_data (GtkWidget *widget,
GdkDragContext *context,
GdkDrag *drag,
GtkSelectionData *selection,
guint target_info,
guint time,
gpointer data)
{
gchar *uris[2];
@@ -451,6 +452,7 @@ static void
icon_browser_window_init (IconBrowserWindow *win)
{
GdkContentFormats *list;
GtkEventController *controller;
gtk_widget_init_template (GTK_WIDGET (win));
@@ -480,12 +482,30 @@ icon_browser_window_init (IconBrowserWindow *win)
symbolic_toggled (GTK_TOGGLE_BUTTON (win->symbolic_radio), win);
controller = gtk_event_controller_key_new ();
g_signal_connect (controller, "key-pressed", G_CALLBACK (key_event_cb), win);
gtk_widget_add_controller (GTK_WIDGET (win), controller);
populate (win);
}
static void
icon_browser_window_finalize (GObject *object)
{
IconBrowserWindow *win = ICON_BROWSER_WINDOW (object);
g_hash_table_unref (win->contexts);
G_OBJECT_CLASS (icon_browser_window_parent_class)->finalize (object);
}
static void
icon_browser_window_class_init (IconBrowserWindowClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->finalize = icon_browser_window_finalize;
g_type_ensure (ICON_STORE_TYPE);
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
@@ -516,7 +536,6 @@ icon_browser_window_class_init (IconBrowserWindowClass *class)
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), item_activated);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), selected_context_changed);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), symbolic_toggled);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), key_press_event_cb);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), copy_to_clipboard);
}

View File

@@ -9,7 +9,6 @@
<property name="title" translatable="yes">Icon Browser</property>
<property name="default-width">1024</property>
<property name="default-height">768</property>
<signal name="key-press-event" handler="key_press_event_cb"/>
<child type="titlebar">
<object class="GtkHeaderBar" id="header">
<property name="title" translatable="yes">Icon Browser</property>

View File

@@ -353,7 +353,6 @@ update_pulse_time (GtkAdjustment *adjustment, GtkWidget *widget)
static void
on_entry_icon_release (GtkEntry *entry,
GtkEntryIconPosition icon_pos,
GdkEvent *event,
gpointer user_data)
{
if (icon_pos != GTK_ENTRY_ICON_SECONDARY)
@@ -967,8 +966,8 @@ background_loaded_cb (GObject *source,
return;
}
child = gtk_image_new_from_pixbuf (pixbuf);
gtk_widget_show (child);
child = gtk_picture_new_for_pixbuf (pixbuf);
gtk_widget_set_size_request (child, 110, 70);
gtk_flow_box_insert (GTK_FLOW_BOX (bd->flowbox), child, -1);
child = gtk_widget_get_parent (child);
g_object_set_data_full (G_OBJECT (child), "filename", bd->filename, g_free);
@@ -996,8 +995,7 @@ populate_flowbox (GtkWidget *flowbox)
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 110, 70);
gdk_pixbuf_fill (pixbuf, 0xffffffff);
child = gtk_image_new_from_pixbuf (pixbuf);
gtk_widget_show (child);
child = gtk_picture_new_for_pixbuf (pixbuf);
gtk_flow_box_insert (GTK_FLOW_BOX (flowbox), child, -1);
location = "/usr/share/backgrounds/gnome";
@@ -1082,7 +1080,7 @@ set_accel (GtkApplication *app, GtkWidget *widget)
typedef struct
{
GtkTextView tv;
cairo_surface_t *surface;
GdkTexture *texture;
} MyTextView;
typedef GtkTextViewClass MyTextViewClass;
@@ -1095,18 +1093,23 @@ my_text_view_init (MyTextView *tv)
}
static void
my_tv_draw_layer (GtkTextView *widget,
GtkTextViewLayer layer,
cairo_t *cr)
my_tv_snapshot_layer (GtkTextView *widget,
GtkTextViewLayer layer,
GtkSnapshot *snapshot)
{
MyTextView *tv = (MyTextView *)widget;
if (layer == GTK_TEXT_VIEW_LAYER_BELOW_TEXT && tv->surface)
if (layer == GTK_TEXT_VIEW_LAYER_BELOW_TEXT && tv->texture)
{
cairo_save (cr);
cairo_set_source_surface (cr, tv->surface, 0.0, 0.0);
cairo_paint_with_alpha (cr, 0.333);
cairo_restore (cr);
gtk_snapshot_push_opacity (snapshot, 0.333);
gtk_snapshot_append_texture (snapshot,
tv->texture,
&GRAPHENE_RECT_INIT(
0, 0,
gdk_texture_get_width (tv->texture),
gdk_texture_get_height (tv->texture)
));
gtk_snapshot_pop (snapshot);
}
}
@@ -1115,8 +1118,7 @@ my_tv_finalize (GObject *object)
{
MyTextView *tv = (MyTextView *)object;
if (tv->surface)
cairo_surface_destroy (tv->surface);
g_clear_object (&tv->texture);
G_OBJECT_CLASS (my_text_view_parent_class)->finalize (object);
}
@@ -1128,24 +1130,24 @@ my_text_view_class_init (MyTextViewClass *class)
GObjectClass *o_class = G_OBJECT_CLASS (class);
o_class->finalize = my_tv_finalize;
tv_class->draw_layer = my_tv_draw_layer;
tv_class->snapshot_layer = my_tv_snapshot_layer;
}
static void
my_text_view_set_background (MyTextView *tv, const gchar *filename)
{
GdkPixbuf *pixbuf;
GError *error = NULL;
GFile *file;
if (tv->surface)
cairo_surface_destroy (tv->surface);
tv->surface = NULL;
g_clear_object (&tv->texture);
if (filename == NULL)
return;
pixbuf = gdk_pixbuf_new_from_file (filename, &error);
file = g_file_new_for_path (filename);
tv->texture = gdk_texture_new_from_file (file, &error);
g_object_unref (file);
if (error)
{
g_warning ("%s", error->message);
@@ -1153,10 +1155,6 @@ my_text_view_set_background (MyTextView *tv, const gchar *filename)
return;
}
tv->surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, 1, NULL);
g_object_unref (pixbuf);
gtk_widget_queue_draw (GTK_WIDGET (tv));
}
@@ -1655,7 +1653,6 @@ activate (GApplication *app)
gint i;
GPermission *permission;
GAction *action;
GtkGesture *gesture;
g_type_ensure (my_text_view_get_type ());
@@ -1680,6 +1677,7 @@ activate (GApplication *app)
gtk_builder_add_callback_symbol (builder, "reset_icon_size", (GCallback)reset_icon_size);
gtk_builder_add_callback_symbol (builder, "scale_format_value", (GCallback)scale_format_value);
gtk_builder_add_callback_symbol (builder, "scale_format_value_blank", (GCallback)scale_format_value_blank);
gtk_builder_add_callback_symbol (builder, "osd_frame_pressed", (GCallback)osd_frame_pressed);
gtk_builder_connect_signals (builder, NULL);
@@ -1897,10 +1895,6 @@ activate (GApplication *app)
g_signal_connect (adj, "value-changed", G_CALLBACK (adjustment3_value_changed), widget);
g_signal_connect (adj, "value-changed", G_CALLBACK (adjustment3_value_changed), widget2);
widget = (GtkWidget *)gtk_builder_get_object (builder, "osd_frame");
gesture = gtk_gesture_multi_press_new (widget);
g_signal_connect (gesture, "pressed", G_CALLBACK (osd_frame_pressed), widget);
gtk_widget_show (GTK_WIDGET (window));
g_object_unref (builder);

View File

@@ -468,7 +468,8 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<child>
<object class="GtkEntry" id="entry1">
<property name="can-focus">1</property>
<property name="invisible-char"></property>
<property name="enable-emoji-completion">1</property>
<property name="invisible_char">•</property>
<property name="placeholder-text" translatable="yes">Click icon to change mode</property>
<property name="secondary-icon-name">view-refresh-symbolic</property>
<property name="secondary-icon-tooltip-text">Change mode</property>
@@ -2225,6 +2226,9 @@ microphone-sensitivity-medium-symbolic</property>
<property name="tooltip-text" translatable="yes">Save the current document</property>
</object>
</child>
<child>
<object class="GtkSeparatorToolItem"/>
</child>
<child>
<object class="GtkToolButton">
<property name="label" translatable="yes">Search</property>
@@ -3100,6 +3104,11 @@ microphone-sensitivity-medium-symbolic</property>
</child>
</object>
</child>
<child>
<object class="GtkGestureMultiPress">
<signal name="pressed" handler="osd_frame_pressed" object="osd_frame" swapped="no"/>
</object>
</child>
</object>
</child>
</object>
@@ -3574,4 +3583,4 @@ bad things might happen.</property>
</object>
</child>
</object>
</interface>
</interface>

68
docs/CODE-OWNERS Normal file
View File

@@ -0,0 +1,68 @@
# These are the people responsible for subsystems in GTK; if you're opening
# a merge request for files listed here, please add the following people to
# the list of reviewers
# The syntax of this file is similar to the GitHub CODEOWNERS file:
# https://help.github.com/articles/about-codeowners/
# Which, in turn, is similar to the .gitignore and .gitattributes files:
#
# - comments start with `#`
# - the first column contains paths and globs
# - the second column contains GitLab user names or email addresses,
# separated by spaces
#
# If you want to be responsible for code reviews in specific sections of
# the GTK code base, add yourself here.
# Maintainer
* @matthiasc
# Build system
meson.build @ebassi @nirbheek
*.py @ebassi
# CSS
gtk/gtkcss*.[ch] @otte @baedert
gtk/gtkstyle*.[ch] @otte @baedert
# Gestures
gtk/gtkeventcontroller* @carlosg
gtk/gtkgesture*.[ch] @carlosg
# GtkFileChooser
gtk/gtkfilechooser* @federico
gtk/gtkfilesystem* @federico
gtk/gtkfilefilter* @federico
# GtkFontChooser
gtk/gtkfontchooser* @matthiasc
# Input methods
gtk/gtkimcontext* @carlosg
# Media
gtk/gtkmedia* @otte
# GSK
gsk @otte @baedert @ebassi
# GL rendering
gsk/gl @baedert @ebassi
# Vulkan rendering
gsk/vulkan
# Documentation
docs/ @ebassi @dboles
# Wayland
gdk/wayland @jadahl
# X11
gdk/x11 @ofourdan @matthiasc
# Themes
gtk/themes @lapoc @jimmac
# Inspector
gtk/inspector @otte @matthiasc

View File

@@ -71,10 +71,7 @@ straightforward manner.
void gdk_drag_status (GdkDragContext *context,
GdkDragAction action,
guint32 time);
void gdk_drop_reply (GdkDragContext *context,
gboolean ok,
guint32 time);
void gdk_drop_finish (GdkDragContext *context,
void gdk_drag_finish (GdkDragContext *context,
gboolean success,
guint32 time);
GdkAtom gdk_drag_get_selection (GdkDragContext *context);

View File

@@ -27,12 +27,12 @@
<xi:include href="xml/gdkmonitor.xml" />
<xi:include href="xml/regions.xml" />
<xi:include href="xml/textures.xml" />
<xi:include href="xml/gdkpaintable.xml" />
<xi:include href="xml/rgba_colors.xml" />
<xi:include href="xml/cursors.xml" />
<xi:include href="xml/windows.xml" />
<xi:include href="xml/gdksurface.xml" />
<xi:include href="xml/gdkframeclock.xml" />
<xi:include href="xml/gdkframetimings.xml" />
<xi:include href="xml/gdkdrawingcontext.xml" />
<xi:include href="xml/gdkdrawcontext.xml" />
<xi:include href="xml/gdkglcontext.xml" />
<xi:include href="xml/gdkvulkancontext.xml" />

View File

@@ -167,11 +167,10 @@ gdk_rgba_get_type
</SECTION>
<SECTION>
<TITLE>Windows</TITLE>
<FILE>windows</FILE>
<TITLE>GdkSurface</TITLE>
<FILE>gdksurface</FILE>
GdkSurface
GdkSurfaceType
GdkSurfaceClass
GdkSurfaceHints
GdkGeometry
GdkGravity
@@ -194,7 +193,6 @@ gdk_surface_is_visible
gdk_surface_is_viewable
gdk_surface_is_input_only
gdk_surface_get_state
gdk_surface_withdraw
gdk_surface_iconify
gdk_surface_deiconify
gdk_surface_stick
@@ -233,10 +231,6 @@ gdk_surface_set_opaque_region
gdk_surface_create_gl_context
gdk_surface_create_vulkan_context
<SUBSECTION>
gdk_surface_begin_draw_frame
gdk_surface_end_draw_frame
<SUBSECTION>
gdk_surface_invalidate_rect
gdk_surface_invalidate_region
@@ -286,8 +280,6 @@ gdk_surface_get_toplevel
gdk_surface_get_children
gdk_surface_get_children_with_user_data
gdk_surface_peek_children
gdk_surface_get_events
gdk_surface_set_events
gdk_surface_set_icon_name
gdk_surface_set_transient_for
gdk_surface_set_role
@@ -305,8 +297,6 @@ gdk_surface_get_support_multidevice
gdk_surface_set_support_multidevice
gdk_surface_get_device_cursor
gdk_surface_set_device_cursor
gdk_surface_get_device_events
gdk_surface_set_device_events
<SUBSECTION>
gdk_surface_coords_from_parent
@@ -408,15 +398,12 @@ gdk_pango_layout_line_get_clip_region
<TITLE>Cairo Interaction</TITLE>
<FILE>cairo_interaction</FILE>
gdk_surface_create_similar_surface
gdk_surface_create_similar_image_surface
gdk_cairo_get_clip_rectangle
gdk_cairo_get_drawing_context
gdk_cairo_set_source_rgba
gdk_cairo_set_source_pixbuf
gdk_cairo_rectangle
gdk_cairo_region
gdk_cairo_region_create_from_surface
gdk_cairo_surface_create_from_pixbuf
gdk_cairo_draw_from_gl
gdk_cairo_surface_upload_to_gl
</SECTION>
@@ -634,7 +621,6 @@ GDK_BUTTON_SECONDARY
<SUBSECTION>
gdk_event_new
gdk_event_copy
gdk_event_free
gdk_event_get_axes
gdk_event_get_button
gdk_event_get_click_count
@@ -660,9 +646,9 @@ gdk_event_get_scancode
gdk_event_get_pointer_emulated
gdk_event_get_crossing_detail
gdk_event_get_crossing_mode
gdk_event_get_drag_context
gdk_event_get_drop
gdk_event_get_focus_in
gdk_event_get_grab_window
gdk_event_get_grab_surface
gdk_event_get_motion_history
gdk_event_get_key_group
gdk_event_get_key_is_modifier
@@ -705,20 +691,27 @@ gdk_event_get_type
</SECTION>
<SECTION>
<TITLE>Paintable</TITLE>
<FILE>paintable</FILE>
<FILE>gdkpaintable</FILE>
<TITLE>GdkPaintable</TITLE>
GdkPaintable
gdk_paintable_snapshot
GdkPaintableFlags
gdk_paintable_get_current_image
gdk_paintable_snapshot
gdk_paintable_get_flags
gdk_paintable_get_intrinsic_width
gdk_paintable_get_intrinsic_height
gdk_paintable_get_intrinsic_aspect_ratio
gdk_paintable_compute_concrete_size
<SUBSECTION>
gdk_paintable_invalidate_contents
gdk_paintable_invalidate_size
gdk_paintable_new_empty
<SECTION>
<SUBSECTION Private>
GDK_TYPE_PAINTABLE
gdk_paintable_get_type
</SECTION>
<SECTION>
<TITLE>Textures</TITLE>
@@ -730,8 +723,9 @@ gdk_texture_new_from_file
gdk_texture_get_width
gdk_texture_get_height
gdk_texture_download
gdk_texture_save_to_png
GdkMemoryFormat
GDK_MEMORY_FORMAT_DEFAULT
GDK_MEMORY_DEFAULT
gdk_memory_texture_new
gdk_gl_texture_new
gdk_gl_texture_release
@@ -779,40 +773,60 @@ gdk_cursor_get_type
<SECTION>
<TITLE>Drag and Drop</TITLE>
<FILE>dnd</FILE>
GdkDragContext
GdkDrag
GdkDrop
GdkDragCancelReason
gdk_drop_reply
gdk_drag_drop_done
gdk_drag_begin
gdk_drop_finish
GdkDragAction
gdk_drag_status
gdk_drag_drop_succeeded
GDK_ACTION_ALL
gdk_drag_context_get_display
gdk_drag_context_get_actions
gdk_drag_context_get_suggested_action
gdk_drag_context_get_selected_action
gdk_drag_context_get_formats
gdk_drag_context_get_device
gdk_drag_context_get_source_surface
gdk_drag_context_get_dest_surface
gdk_drag_context_get_drag_surface
gdk_drag_context_set_hotspot
gdk_drag_get_display
gdk_drag_get_actions
gdk_drag_get_suggested_action
gdk_drag_get_selected_action
gdk_drag_get_formats
gdk_drag_get_device
gdk_drag_get_drag_surface
gdk_drag_set_hotspot
<SUBSECTION>
gdk_drag_action_is_unique
<SUBSECTION>
gdk_drop_get_display
gdk_drop_get_device
gdk_drop_get_surface
gdk_drop_get_formats
gdk_drop_get_actions
gdk_drop_get_drag
gdk_drop_status
gdk_drop_finish
gdk_drop_read_async
gdk_drop_read_finish
gdk_drop_read_value_async
gdk_drop_read_value_finish
gdk_drop_read_text_async
gdk_drop_read_text_finish
<SUBSECTION Standard>
GDK_DRAG_CONTEXT
GDK_TYPE_DRAG_CONTEXT
GDK_IS_DRAG_CONTEXT
GDK_DRAG_CONTEXT_CLASS
GDK_DRAG_CONTEXT_GET_CLASS
GDK_IS_DRAG_CONTEXT_CLASS
GDK_DRAG
GDK_TYPE_DRAG
GDK_IS_DRAG
GDK_DRAG_CLASS
GDK_DRAG_GET_CLASS
GDK_IS_DRAG_CLASS
GDK_TYPE_DRAG_ACTION
GDK_TYPE_DRAG_PROTOCOL
GDK_TYPE_DROP
GDK_DROP
GDK_IS_DROP
<SUBSECTION Private>
GdkDragContextClass
gdk_drag_context_get_type
GdkDragClass
gdk_drag_get_type
GdkDropClass
gdk_drop_get_type
</SECTION>
<SECTION>
@@ -855,7 +869,6 @@ gdk_x11_screen_lookup_visual
gdk_x11_screen_supports_net_wm_hint
gdk_x11_screen_get_number_of_desktops
gdk_x11_screen_get_current_desktop
gdk_x11_surface_foreign_new_for_display
gdk_x11_surface_lookup_for_display
gdk_x11_surface_get_xid
gdk_x11_surface_set_theme_variant
@@ -1108,6 +1121,10 @@ gdk_frame_timings_get_type
GdkDrawContext
gdk_draw_context_get_display
gdk_draw_context_get_surface
gdk_draw_context_begin_frame
gdk_draw_context_end_frame
gdk_draw_context_is_in_frame
gdk_draw_context_get_frame_region
<SUBSECTION Standard>
GDK_DRAW_CONTEXT
@@ -1141,7 +1158,6 @@ gdk_gl_context_is_legacy
<SUBSECTION>
GdkGLError
gdk_gl_context_realize
gdk_gl_context_get_damage
gdk_gl_context_make_current
gdk_gl_context_get_current
gdk_gl_context_clear_current
@@ -1186,23 +1202,12 @@ GDK_IS_MONITOR
</SECTION>
<SECTION>
<FILE>gdkdrawingcontext</FILE>
GdkDrawingContext
gdk_drawing_context_get_surface
gdk_drawing_context_get_clip
gdk_drawing_context_get_cairo_context
gdk_drawing_context_is_valid
gdk_drawing_context_get_paint_context
<FILE>gdkcairocontext</FILE>
GdkCairoContext
gdk_cairo_context_cairo_create
<SUBSECTION Standard>
gdk_drawing_context_get_type
GdkDrawingContextClass
GDK_TYPE_DRAWING_CONTEXT
GDK_DRAWING_CONTEXT_CLASS
GDK_DRAWING_CONTEXT_GET_CLASS
GDK_IS_DRAWING_CONTEXT_CLASS
GDK_DRAWING_CONTEXT
GDK_IS_DRAWING_CONTEXT
gdk_cairo_context_get_type
</SECTION>
<SECTION>
@@ -1260,6 +1265,7 @@ gdk_clipboard_get_type
<SECTION>
<FILE>gdkcontentprovider</FILE>
GdkContentProvider
GdkContentProviderClass
gdk_content_provider_new_for_value
gdk_content_provider_new_for_bytes
gdk_content_provider_ref_formats
@@ -1275,7 +1281,6 @@ GDK_CONTENT_PROVIDER_CLASS
GDK_CONTENT_PROVIDER_GET_CLASS
GDK_IS_CONTENT_PROVIDER
GDK_IS_CONTENT_PROVIDER_CLASS
GdkContentProviderClass
gdk_content_provider_get_type
</SECTION>
@@ -1334,3 +1339,4 @@ GDK_CONTENT_DESERIALIZER
GDK_IS_CONTENT_DESERIALIZER
gdk_content_deserializer_get_type
</SECTION>

View File

@@ -1,18 +1,28 @@
gdk_app_launch_context_get_type
gdk_clipboard_get_type
gdk_content_deserializer_get_type
gdk_content_formats_get_type
gdk_content_provider_get_type
gdk_content_serializer_get_type
gdk_cursor_get_type
gdk_device_get_type
gdk_device_pad_get_type
gdk_device_tool_get_type
gdk_display_get_type
gdk_display_manager_get_type
gdk_drag_context_get_type
gdk_drawing_context_get_type
gdk_drag_get_type
gdk_drop_get_type
gdk_event_get_type
gdk_frame_clock_get_type
gdk_gl_context_get_type
gdk_gl_texture_get_type
gdk_keymap_get_type
gdk_memory_texture_get_type
gdk_monitor_get_type
gdk_paintable_get_type
gdk_rgba_get_type
gdk_seat_get_type
gdk_snapshot_get_type
gdk_surface_get_type
gdk_content_serializer_get_type
gdk_content_deserializer_get_type
gdk_clipboard_get_type
gdk_content_formats_get_type
gdk_texture_get_type
gdk_vulkan_context_get_type

View File

@@ -3,7 +3,6 @@ private_headers = [
'gdkmarshalers.h',
'gdkkeysyms.h',
'gdkinternals.h',
'gdkprivate.h',
'gdk-private.h',
'gdkapplaunchcontextprivate.h',
'gdkclipboardprivate.h',
@@ -11,31 +10,39 @@ private_headers = [
'gdkcontentproviderprivate.h',
'gdkcursorprivate.h',
'gdkdeviceprivate.h',
'gdkdevicepadprivate.h',
'gdkdevicetoolprivate.h',
'gdkdisplaymanagerprivate.h',
'gdkdisplayprivate.h',
'gdkdndprivate.h',
'gdkdrawcontextprivate.h',
'gdkeventsprivate.h',
'gdkframeclockidleprivate.h',
'gdkframeclockprivate.h',
'gdkglcontextprivate.h',
'gdkgltextureprivate.h',
'gdkkeysprivate.h',
'gdkmonitorprivate.h',
'gdkmemorytextureprivate.h',
'gdkpipeiostreamprivate.h',
'gdkscreenprivate.h',
'gdkseatdefaultprivate.h',
'gdkseatprivate.h',
'gdksnapshotprivate.h',
'gdksurfaceimpl.h',
'gdktextureprivate.h',
'gdkvisualprivate.h',
'gdkvulkancontextprivate.h',
'keyname-table.h',
'x11/gdkprivate-x11.h',
'gdkprivate-x11.h',
'x11/gdkeventsource.h',
'wayland/keyboard-shortcuts-inhibit-unstable-v1-client-protocol.h',
'wayland/pointer-gestures-unstable-v1-client-protocol.h',
'wayland/server-decoration-client-protocol.h',
'wayland/tablet-unstable-v2-client-protocol.h',
'wayland/xdg-foreign-unstable-v1-client-protocol.h',
'wayland/xdg-shell-unstable-v6-client-protocol.h',
'gtk-primary-selection-client-protocol.h',
'gtk-shell-client-protocol.h',
'keyboard-shortcuts-inhibit-unstable-v1-client-protocol.h',
'pointer-gestures-unstable-v1-client-protocol.h',
'server-decoration-client-protocol.h',
'tablet-unstable-v2-client-protocol.h',
'xdg-foreign-unstable-v1-client-protocol.h',
'xdg-shell-unstable-v6-client-protocol.h',
'win32',
'quartz',
'broadway',
@@ -80,19 +87,24 @@ images = [
'images/zoom_out_cursor.png',
]
src_dir = [ gdkinc ]
if x11_enabled
src_dir += [ gdkx11_inc ]
endif
if wayland_enabled
src_dir += [ gdkwayland_inc ]
endif
configure_file(input: 'version.xml.in', output: 'version.xml', configuration: version_conf)
gnome.gtkdoc('gdk4',
mode: 'none',
main_xml: 'gdk4-docs.xml',
src_dir: [
join_paths(meson.source_root(), 'gdk'),
join_paths(meson.source_root(), 'gdk', 'x11'),
join_paths(meson.source_root(), 'gdk', 'wayland'),
join_paths(meson.build_root(), 'gdk'),
],
src_dir: src_dir,
dependencies: libgtk_dep,
gobject_typesfile: join_paths(meson.source_root(), 'docs/reference/gdk/gdk4.types'),
gobject_typesfile: join_paths(meson.current_source_dir(), 'gdk4.types'),
scan_args: [
'--ignore-decorators=_GDK_EXTERN|G_GNUC_WARN_UNUSED_RESULT',
'--ignore-headers=' + ' '.join(private_headers),

View File

@@ -29,8 +29,6 @@ gsk_render_node_serialize
gsk_render_node_deserialize
gsk_render_node_write_to_file
GskScalingFilter
gsk_render_node_set_name
gsk_render_node_get_name
gsk_render_node_get_bounds
<SUBSECTION Nodes>
@@ -70,6 +68,10 @@ gsk_container_node_get_child
gsk_transform_node_new
gsk_transform_node_get_child
gsk_transform_node_peek_transform
gsk_offset_node_new
gsk_offset_node_get_child
gsk_offset_node_get_x_offset
gsk_offset_node_get_y_offset
gsk_opacity_node_new
gsk_opacity_node_get_child
gsk_opacity_node_get_opacity
@@ -108,6 +110,9 @@ gsk_text_node_get_y
gsk_blur_node_new
gsk_blur_node_get_child
gsk_blur_node_get_radius
gsk_debug_node_new
gsk_debug_node_get_child
gsk_debug_node_get_message
<SUBSECTION Standard>
GSK_IS_RENDER_NODE
GSK_RENDER_NODE

View File

@@ -40,11 +40,10 @@ gnome.gtkdoc('gsk4',
mode: 'none',
main_xml: 'gsk4-docs.xml',
src_dir: [
join_paths(meson.source_root(), 'gsk'),
join_paths(meson.build_root(), 'gsk'),
gskinc,
],
dependencies: libgtk_dep,
gobject_typesfile: join_paths(meson.source_root(), 'docs/reference/gsk/gsk4.types'),
gobject_typesfile: join_paths(meson.current_source_dir(), 'gsk4.types'),
scan_args: [
'--ignore-decorators=_GDK_EXTERN',
'--ignore-headers=' + ' '.join(private_headers),

View File

@@ -46,7 +46,7 @@ broadwayd :5
Then point your web browser at <literal>http://127.0.0.1:8085</literal>.
Start your applications like this:
<programlisting>
GDK_BACKEND=broadway BROADWAY_DISPLAY=:5 gtk3-demo
GDK_BACKEND=broadway BROADWAY_DISPLAY=:5 gtk4-demo
</programlisting>
</para>

View File

@@ -294,13 +294,52 @@ How to compile GTK+ itself
<command>meson</command>
<sbr/>
<group>
<arg choice="plain">-Ddocumentation=true</arg>
<arg choice="plain">-Ddocumentation=false</arg>
<arg choice="plain">-Dx11-backend=true</arg>
<arg choice="plain">-Dx11-backend=false</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Dman-pages=true</arg>
<arg choice="plain">-Dman-pages=false</arg>
<arg choice="plain">-Dwayland-backend=true</arg>
<arg choice="plain">-Dwayland-backend=false</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Dbroadway-backend=true</arg>
<arg choice="plain">-Dbroadway-backend=false</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Dwin32-backend=true</arg>
<arg choice="plain">-Dwin32-backend=false</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Dquartz-backend=true</arg>
<arg choice="plain">-Dquartz-backend=false</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Dmedia=gstreamer</arg>
<arg choice="plain">-Dmedia=ffmpeg</arg>
<arg choice="plain">-Dmedia=all</arg>
<arg choice="plain">-Dmedia=none</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Dvulkan=yes</arg>
<arg choice="plain">-Dvulkan=no</arg>
<arg choice="plain">-Dvulkan=auto</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Dxinerama=yes</arg>
<arg choice="plain">-Dxinerama=no</arg>
<arg choice="plain">-Dxinerama=auto</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Dcloudproviders=true</arg>
<arg choice="plain">-Dcloudproviders=false</arg>
</group>
<sbr/>
<group>
@@ -316,45 +355,13 @@ How to compile GTK+ itself
</group>
<sbr/>
<group>
<arg choice="plain">-Dvulkan=yes</arg>
<arg choice="plain">-Dvulkan=no</arg>
<arg choice="plain">-Dvulkan=auto</arg>
<arg choice="plain">-Ddocumentation=true</arg>
<arg choice="plain">-Ddocumentation=false</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Dx11-backend=true</arg>
<arg choice="plain">-Dx11-backend=false</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Dcloudproviders=true</arg>
<arg choice="plain">-Dcloudproviders=false</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Dxinerama=yes</arg>
<arg choice="plain">-Dxinerama=no</arg>
<arg choice="plain">-Dxinerama=auto</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Dwin32-backend=true</arg>
<arg choice="plain">-Dwin32-backend=false</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Dquartz-backend=true</arg>
<arg choice="plain">-Dquartz-backend=false</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Dbroadway-backend=true</arg>
<arg choice="plain">-Dbroadway-backend=false</arg>
</group>
<sbr/>
<group>
<arg choice="plain">-Dwayland-backend=true</arg>
<arg choice="plain">-Dwayland-backend=false</arg>
<arg choice="plain">-Dman-pages=true</arg>
<arg choice="plain">-Dman-pages=false</arg>
</group>
<sbr/>
<group>

View File

@@ -50,7 +50,7 @@
<para>
You can compile the program above with GCC using:
<literallayout>
<literal>gcc `pkg-config --cflags gtk+-3.0` -o example-0 example-0.c `pkg-config --libs gtk+-3.0`</literal>
<literal>gcc `pkg-config --cflags gtk+-4.0` -o example-0 example-0.c `pkg-config --libs gtk+-4.0`</literal>
</literallayout>
</para>
@@ -120,7 +120,7 @@
here</ulink>.</para>
<para>Finally the window size is set using gtk_window_set_default_size and
the window is then shown by GTK via gtk_widget_show_all().</para>
the window is then shown by GTK via gtk_widget_show().</para>
<para>When you exit the window, by for example pressing the X,
the g_application_run() in the main loop returns with a number
@@ -160,7 +160,7 @@
<para>
You can compile the program above with GCC using:
<literallayout>
<literal>gcc `pkg-config --cflags gtk+-3.0` -o example-1 example-1.c `pkg-config --libs gtk+-3.0`</literal>
<literal>gcc `pkg-config --cflags gtk+-4.0` -o example-1 example-1.c `pkg-config --libs gtk+-4.0`</literal>
</literallayout>
</para>
</section>
@@ -238,7 +238,7 @@
<para>
You can compile the program above with GCC using:
<literallayout>
<literal>gcc `pkg-config --cflags gtk+-3.0` -o example-2 example-2.c `pkg-config --libs gtk+-3.0`</literal>
<literal>gcc `pkg-config --cflags gtk+-4.0` -o example-2 example-2.c `pkg-config --libs gtk+-4.0`</literal>
</literallayout>
</para>
</section>
@@ -264,7 +264,7 @@
<para>
You can compile the program above with GCC using:
<literallayout>
<literal>gcc `pkg-config --cflags gtk+-3.0` -o example-3 example-3.c `pkg-config --libs gtk+-3.0`</literal>
<literal>gcc `pkg-config --cflags gtk+-4.0` -o example-3 example-3.c `pkg-config --libs gtk+-4.0`</literal>
</literallayout>
</para>
@@ -333,7 +333,7 @@
<para>The full, buildable sources for these examples can be found
in the examples/ directory of the GTK+ source distribution, or
<ulink url="https://git.gnome.org/browse/gtk+/tree/examples">online</ulink> in the GTK+ git repository.
<ulink url="https://gitlab.gnome.org/GNOME/gtk/blob/master/examples">online</ulink> in the GTK+ git repository.
You can build each example separately by using make with the <filename>Makefile.example</filename>
file. For more information, see the <filename>README</filename> included in the
examples directory.</para>
@@ -450,13 +450,13 @@ example_app_window_class_init (ExampleAppWindowClass *class)
...
]]></programlisting>
<para>(<ulink url="https://git.gnome.org/browse/gtk+/tree/examples/application2/exampleappwin.c">full source</ulink>)</para>
<para>(<ulink url="https://gitlab.gnome.org/GNOME/gtk/blob/master/examples/application2/exampleappwin.c">full source</ulink>)</para>
</informalexample>
<para>You may have noticed that we used the <literal>_from_resource(<!-- -->)</literal> variant
of the function that sets a template. Now we need to use GLib's resource
functionality to include the ui file in the binary. This is commonly
done by listing all resources in a .gresource.xml file, such as this:
of the function that sets a template. Now we need to use <ulink url="https://developer.gnome.org/gio/stable/GResource.html">GLib's resource functionality</ulink>
to include the ui file in the binary. This is commonly done by listing
all resources in a .gresource.xml file, such as this:
</para>
<informalexample>
@@ -488,23 +488,28 @@ example_app_window_class_init (ExampleAppWindowClass *class)
<para>In this step, we make our application show the content of
all the files that it is given on the commandline.</para>
<para>To this end, we add a private struct to our application
<para>To this end, we add a member to the struct in application
window subclass and keep a reference to the #GtkStack there.
The gtk_widget_class_bind_template_child_private() function
The first member of the struct should be the parent type from
which the class is derived. Here, ExampleAppWindow is derived
from GtkApplicationWindow.
The gtk_widget_class_bind_template_child() function
arranges things so that after instantiating the template, the
@stack member of the private struct will point to the widget of
@stack member of the struct will point to the widget of
the same name from the template.</para>
<informalexample>
<programlisting><![CDATA[
...
struct _ExampleAppWindowPrivate
struct _ExampleAppWindow
{
GtkApplicationWindow parent;
GtkWidget *stack;
};
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
G_DEFINE_TYPE (ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW)
...
@@ -513,12 +518,12 @@ example_app_window_class_init (ExampleAppWindowClass *class)
{
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/exampleapp/window.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
}
...
]]></programlisting>
<para>(<ulink url="https://git.gnome.org/browse/gtk+/tree/examples/application3/exampleappwin.c">full source</ulink>)</para>
<para>(<ulink url="https://gitlab.gnome.org/GNOME/gtk/blob/master/examples/application3/exampleappwin.c">full source</ulink>)</para>
</informalexample>
<para>Now we revisit the example_app_window_open() function that
@@ -533,25 +538,21 @@ void
example_app_window_open (ExampleAppWindow *win,
GFile *file)
{
ExampleAppWindowPrivate *priv;
gchar *basename;
GtkWidget *scrolled, *view;
gchar *contents;
gsize length;
priv = example_app_window_get_instance_private (win);
basename = g_file_get_basename (file);
scrolled = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scrolled);
gtk_widget_set_hexpand (scrolled, TRUE);
gtk_widget_set_vexpand (scrolled, TRUE);
view = gtk_text_view_new ();
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
gtk_widget_show (view);
gtk_container_add (GTK_CONTAINER (scrolled), view);
gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename);
gtk_stack_add_titled (GTK_STACK (win->stack), scrolled, basename, basename);
if (g_file_load_contents (file, NULL, &contents, &length, NULL, NULL))
{
@@ -567,7 +568,7 @@ example_app_window_open (ExampleAppWindow *win,
...
]]></programlisting>
<para>(<ulink url="https://git.gnome.org/browse/gtk+/tree/examples/application3/exampleappwin.c">full source</ulink>)</para>
<para>(<ulink url="https://gitlab.gnome.org/GNOME/gtk/blob/master/examples/application3/exampleappwin.c">full source</ulink>)</para>
</informalexample>
<para>Note that we did not have to touch the stack switcher
@@ -665,7 +666,7 @@ example_app_class_init (ExampleAppClass *class)
...
</programlisting>
<para>(<ulink url="https://git.gnome.org/browse/gtk+/tree/examples/application4/exampleapp.c">full source</ulink>)</para>
<para>(<ulink url="https://gitlab.gnome.org/GNOME/gtk/blob/master/examples/application4/exampleapp.c">full source</ulink>)</para>
</informalexample>
<para>Our preferences menu item does not do anything yet,
@@ -718,20 +719,17 @@ example_app_class_init (ExampleAppClass *class)
static void
example_app_window_init (ExampleAppWindow *win)
{
ExampleAppWindowPrivate *priv;
priv = example_app_window_get_instance_private (win);
gtk_widget_init_template (GTK_WIDGET (win));
priv->settings = g_settings_new ("org.gtk.exampleapp");
win->settings = g_settings_new ("org.gtk.exampleapp");
g_settings_bind (priv->settings, "transition",
priv->stack, "transition-type",
g_settings_bind (win->settings, "transition",
win->stack, "transition-type",
G_SETTINGS_BIND_DEFAULT);
}
...
]]></programlisting>
<para>(<ulink url="https://git.gnome.org/browse/gtk+/tree/examples/application5/exampleappwin.c">full source</ulink>)</para>
<para>(<ulink url="https://gitlab.gnome.org/GNOME/gtk/blob/master/examples/application5/exampleappwin.c">full source</ulink>)</para>
</informalexample>
<para>The code to connect the font setting is a little more involved,
@@ -780,7 +778,7 @@ preferences_activated (GSimpleAction *action,
...
]]></programlisting>
<para>(<ulink url="https://git.gnome.org/browse/gtk+/tree/examples/application6/exampleapp.c">full source</ulink>)</para>
<para>(<ulink url="https://gitlab.gnome.org/GNOME/gtk/blob/master/examples/application6/exampleapp.c">full source</ulink>)</para>
</informalexample>
<para>After all this work, our application can now show
@@ -823,7 +821,6 @@ static void
search_text_changed (GtkEntry *entry,
ExampleAppWindow *win)
{
ExampleAppWindowPrivate *priv;
const gchar *text;
GtkWidget *tab;
GtkWidget *view;
@@ -835,9 +832,7 @@ search_text_changed (GtkEntry *entry,
if (text[0] == '\0')
return;
priv = example_app_window_get_instance_private (win);
tab = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
tab = gtk_stack_get_visible_child (GTK_STACK (win->stack));
view = gtk_bin_get_child (GTK_BIN (tab));
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
@@ -866,7 +861,7 @@ example_app_window_init (ExampleAppWindow *win)
...
]]></programlisting>
<para>(<ulink url="https://git.gnome.org/browse/gtk+/tree/examples/application7/exampleappwin.c">full source</ulink>)</para>
<para>(<ulink url="https://gitlab.gnome.org/GNOME/gtk/blob/master/examples/application7/exampleappwin.c">full source</ulink>)</para>
</informalexample>
<para>With the search bar, our application now looks like this:</para>
@@ -926,7 +921,7 @@ example_app_window_init (ExampleAppWindow *win)
...
]]></programlisting>
<para>(<ulink url="https://git.gnome.org/browse/gtk+/tree/examples/application8/exampleappwin.c">full source</ulink>)</para>
<para>(<ulink url="https://gitlab.gnome.org/GNOME/gtk/blob/master/examples/application8/exampleappwin.c">full source</ulink>)</para>
</informalexample>
<para>What our application looks like now:</para>
@@ -978,23 +973,23 @@ example_app_window_init (ExampleAppWindow *win)
{
...
action = (GAction*) g_property_action_new ("show-lines", priv->lines, "visible");
action = (GAction*) g_property_action_new ("show-lines", win->lines, "visible");
g_action_map_add_action (G_ACTION_MAP (win), action);
g_object_unref (action);
g_object_bind_property (priv->lines, "visible",
priv->lines_label, "visible",
g_object_bind_property (win->lines, "visible",
win->lines_label, "visible",
G_BINDING_DEFAULT);
}
...
</programlisting>
<para>(<ulink url="https://git.gnome.org/browse/gtk+/tree/examples/application9/exampleappwin.c">full source</ulink>)</para>
<para>(<ulink url="https://gitlab.gnome.org/GNOME/gtk/blob/master/examples/application9/exampleappwin.c">full source</ulink>)</para>
</informalexample>
<para>We also need a function that counts the lines of the currently
active tab, and updates the @lines label. See the
<ulink url="https://git.gnome.org/browse/gtk+/tree/examples/application9/exampleappwin.c">full source</ulink>
<ulink url="https://gitlab.gnome.org/GNOME/gtk/blob/master/examples/application9/exampleappwin.c">full source</ulink>
if you are interested in the details.</para>
<para>This brings our example application to this appearance:</para>
@@ -1078,7 +1073,7 @@ example_app_window_init (ExampleAppWindow *win)
<para>
You can compile the program above with GCC using:
<literallayout>
<literal>gcc `pkg-config --cflags gtk+-3.0` -o example-4 example-4.c `pkg-config --libs gtk+-3.0`</literal>
<literal>gcc `pkg-config --cflags gtk+-4.0` -o example-4 example-4.c `pkg-config --libs gtk+-4.0`</literal>
</literallayout>
</para>
</section>

View File

@@ -52,7 +52,7 @@ gtk4-broadwayd :5
Then point your web browser at <literal>http://127.0.0.1:8085</literal>.
Start your applications like this:
<programlisting>
GDK_BACKEND=broadway BROADWAY_DISPLAY=:5 gtk3-demo
GDK_BACKEND=broadway BROADWAY_DISPLAY=:5 gtk4-demo
</programlisting>
You can add password protection for your session by creating a file in

View File

@@ -93,12 +93,22 @@
<title>Display Widgets</title>
<xi:include href="xml/gtklabel.xml" />
<xi:include href="xml/gtkimage.xml" />
<xi:include href="xml/gtkpicture.xml" />
<xi:include href="xml/gtkspinner.xml" />
<xi:include href="xml/gtkinfobar.xml" />
<xi:include href="xml/gtkprogressbar.xml" />
<xi:include href="xml/gtklevelbar.xml" />
<xi:include href="xml/gtkstatusbar.xml" />
<xi:include href="xml/gtkaccellabel.xml" />
<xi:include href="xml/gtkcalendar.xml" />
</chapter>
<chapter id="MediaSupport">
<title>Media Support</title>
<xi:include href="xml/gtkvideo.xml" />
<xi:include href="xml/gtkmediacontrols.xml" />
<xi:include href="xml/gtkmediastream.xml" />
<xi:include href="xml/gtkmediafile.xml" />
</chapter>
<chapter id="ButtonWidgets">
@@ -210,6 +220,12 @@
<xi:include href="xml/gtkfontchooserdialog.xml" />
</chapter>
<chapter id="DrawingWidgets">
<title>Widgets for custom drawing</title>
<xi:include href="xml/gtkdrawingarea.xml" />
<xi:include href="xml/gtkglarea.xml" />
</chapter>
<chapter id="Ornaments">
<title>Ornaments</title>
<xi:include href="xml/gtkframe.xml" />
@@ -221,6 +237,7 @@
<xi:include href="xml/gtkscrollbar.xml" />
<xi:include href="xml/gtkscrolledwindow.xml" />
<xi:include href="xml/gtkscrollable.xml" />
<xi:include href="xml/gtkviewport.xml" />
</chapter>
<chapter id="Printing">
@@ -247,16 +264,12 @@
<chapter id="MiscObjects">
<title>Miscellaneous</title>
<xi:include href="xml/gtkadjustment.xml" />
<xi:include href="xml/gtkcalendar.xml" />
<xi:include href="xml/gtkdrawingarea.xml" />
<xi:include href="xml/gtkglarea.xml" />
<xi:include href="xml/gtkimcontextsimple.xml" />
<xi:include href="xml/gtkimmulticontext.xml" />
<xi:include href="xml/gtksizegroup.xml" />
<xi:include href="xml/gtktooltip.xml" />
<xi:include href="xml/gtkviewport.xml" />
<xi:include href="xml/gtkaccessible.xml" />
<xi:include href="xml/gtksnapshot.xml" />
<xi:include href="xml/gtkwidgetpaintable.xml" />
</chapter>
<chapter id="AbstractObjects">
@@ -268,6 +281,7 @@
<xi:include href="xml/gtkrange.xml" />
<xi:include href="xml/gtkimcontext.xml" />
<xi:include href="xml/gtknativedialog.xml" />
<xi:include href="xml/gtkaccessible.xml" />
</chapter>
<chapter id="RecentDocuments">
@@ -286,6 +300,7 @@
<chapter id="Gestures">
<title>Gestures and event handling</title>
<xi:include href="xml/gtkeventcontroller.xml" />
<xi:include href="xml/gtkeventcontrollerkey.xml" />
<xi:include href="xml/gtkeventcontrollerscroll.xml" />
<xi:include href="xml/gtkeventcontrollermotion.xml" />
<xi:include href="xml/gtkgesture.xml" />
@@ -297,6 +312,7 @@
<xi:include href="xml/gtkgestureswipe.xml" />
<xi:include href="xml/gtkgesturerotate.xml" />
<xi:include href="xml/gtkgesturezoom.xml" />
<xi:include href="xml/gtkgesturestylus.xml" />
<xi:include href="xml/gtkpadcontroller.xml" />
</chapter>
@@ -369,7 +385,6 @@
<xi:include href="osx.sgml" />
<xi:include href="broadway.xml" />
<xi:include href="wayland.xml" />
<xi:include href="mir.xml" />
</part>
<xi:include href="glossary.xml" />

View File

@@ -679,8 +679,6 @@ gtk_combo_box_get_active_id
gtk_combo_box_set_active_id
gtk_combo_box_get_model
gtk_combo_box_set_model
gtk_combo_box_popup_for_device
gtk_combo_box_popup
gtk_combo_box_popdown
gtk_combo_box_get_popup_accessible
gtk_combo_box_get_row_separator_func
@@ -1270,8 +1268,6 @@ gtk_fixed_get_type
GtkFontButton
gtk_font_button_new
gtk_font_button_new_with_font
gtk_font_button_set_font_name
gtk_font_button_get_font_name
gtk_font_button_set_use_font
gtk_font_button_get_use_font
gtk_font_button_set_use_size
@@ -1302,7 +1298,7 @@ gtk_font_chooser_set_font
gtk_font_chooser_get_font_desc
gtk_font_chooser_set_font_desc
gtk_font_chooser_get_font_features
gtk_font_chooser_get_font_language
gtk_font_chooser_set_language
gtk_font_chooser_get_preview_text
gtk_font_chooser_set_preview_text
gtk_font_chooser_get_show_preview_entry
@@ -1483,32 +1479,28 @@ GtkIconViewPrivate
<TITLE>GtkImage</TITLE>
GtkImage
GtkImageType
gtk_image_get_texture
gtk_image_get_icon_name
gtk_image_get_gicon
gtk_image_get_storage_type
gtk_image_new
gtk_image_new_from_file
gtk_image_new_from_resource
gtk_image_new_from_pixbuf
gtk_image_new_from_paintable
gtk_image_new_from_icon_name
gtk_image_new_from_gicon
gtk_image_new_from_resource
gtk_image_new_from_texture
gtk_image_clear
gtk_image_set_from_file
gtk_image_set_from_resource
gtk_image_set_from_pixbuf
gtk_image_set_from_paintable
gtk_image_set_from_icon_name
gtk_image_set_from_gicon
gtk_image_set_from_resource
gtk_image_set_from_texture
gtk_image_clear
gtk_image_new
gtk_image_get_storage_type
gtk_image_get_paintable
gtk_image_get_icon_name
gtk_image_get_gicon
gtk_image_set_pixel_size
gtk_image_get_pixel_size
gtk_image_set_icon_size
gtk_image_get_icon_size
gtk_image_set_keep_aspect_ratio
gtk_image_get_keep_aspect_ratio
gtk_image_set_can_shrink
gtk_image_get_can_shrink
<SUBSECTION Standard>
GTK_IMAGE
GTK_IS_IMAGE
@@ -1730,8 +1722,6 @@ gtk_menu_attach
gtk_menu_popup_at_rect
gtk_menu_popup_at_widget
gtk_menu_popup_at_pointer
gtk_menu_popup_for_device
gtk_menu_popup
gtk_menu_set_accel_group
gtk_menu_get_accel_group
gtk_menu_set_accel_path
@@ -1923,8 +1913,8 @@ gtk_info_bar_set_message_type
gtk_info_bar_get_message_type
gtk_info_bar_get_action_area
gtk_info_bar_get_content_area
gtk_info_bar_get_show_title_buttons
gtk_info_bar_set_show_title_buttons
gtk_info_bar_get_show_close_button
gtk_info_bar_set_show_close_button
gtk_info_bar_get_revealed
gtk_info_bar_set_revealed
@@ -2051,6 +2041,40 @@ GtkPanedPrivate
gtk_paned_get_type
</SECTION>
<SECTION>
<FILE>gtkpicture</FILE>
<TITLE>GtkPicture</TITLE>
GtkPicture
gtk_picture_new
gtk_picture_new_for_paintable
gtk_picture_new_for_pixbuf
gtk_picture_new_for_file
gtk_picture_new_for_filename
gtk_picture_new_for_resource
gtk_picture_set_paintable
gtk_picture_get_paintable
gtk_picture_set_pixbuf
gtk_picture_set_file
gtk_picture_get_file
gtk_picture_set_filename
gtk_picture_set_resource
gtk_picture_set_keep_aspect_ratio
gtk_picture_get_keep_aspect_ratio
gtk_picture_set_can_shrink
gtk_picture_get_can_shrink
gtk_picture_set_alternative_text
gtk_picture_get_alternative_text
<SUBSECTION Standard>
GTK_PICTURE
GTK_IS_PICTURE
GTK_TYPE_PICTURE
GTK_PICTURE_CLASS
GTK_IS_PICTURE_CLASS
GTK_PICTURE_GET_CLASS
<SUBSECTION Private>
gtk_picture_get_type
</SECTION>
<SECTION>
<FILE>gtkprogressbar</FILE>
<TITLE>GtkProgressBar</TITLE>
@@ -2397,6 +2421,8 @@ gtk_search_bar_set_search_mode
gtk_search_bar_get_show_close_button
gtk_search_bar_set_show_close_button
gtk_search_bar_handle_event
gtk_search_bar_set_key_capture_widget
gtk_search_bar_get_key_capture_widget
<SUBSECTION Standard>
GTK_TYPE_SEARCH_BAR
GTK_SEARCH_BAR
@@ -2414,6 +2440,8 @@ gtk_search_bar_get_type
GtkSearchEntry
gtk_search_entry_new
gtk_search_entry_handle_event
gtk_search_entry_set_key_capture_widget
gtk_search_entry_get_key_capture_widget
<SUBSECTION Standard>
GTK_TYPE_SEARCH_ENTRY
GTK_SEARCH_ENTRY
@@ -4168,15 +4196,10 @@ gtk_volume_button_get_type
<TITLE>GtkSnapshot</TITLE>
GtkSnapshot
gtk_snapshot_new
gtk_snapshot_ref
gtk_snapshot_unref
gtk_snapshot_to_node
gtk_snapshot_to_paintable
gtk_snapshot_free_to_node
gtk_snapshot_free_to_paintable
gtk_snapshot_get_renderer
gtk_snapshot_get_record_names
gtk_snapshot_push
gtk_snapshot_push_transform
gtk_snapshot_push_opacity
gtk_snapshot_push_color_matrix
@@ -4193,7 +4216,6 @@ gtk_snapshot_append_cairo
gtk_snapshot_append_texture
gtk_snapshot_append_color
gtk_snapshot_append_layout
gtk_snapshot_clips_rect
gtk_snapshot_render_background
gtk_snapshot_render_frame
gtk_snapshot_render_focus
@@ -4269,6 +4291,8 @@ gtk_widget_get_toplevel
gtk_widget_get_ancestor
gtk_widget_is_ancestor
gtk_widget_translate_coordinates
gtk_widget_add_controller
gtk_widget_remove_controller
gtk_widget_set_direction
GtkTextDirection
gtk_widget_get_direction
@@ -4336,6 +4360,7 @@ gtk_widget_get_can_focus
gtk_widget_set_can_focus
gtk_widget_get_focus_on_click
gtk_widget_set_focus_on_click
gtk_widget_set_focus_child
gtk_widget_get_has_surface
gtk_widget_set_has_surface
gtk_widget_get_sensitive
@@ -4357,7 +4382,6 @@ gtk_widget_set_receives_default
gtk_widget_get_receives_default
gtk_widget_set_support_multidevice
gtk_widget_get_support_multidevice
gtk_widget_set_realized
gtk_widget_get_realized
gtk_widget_get_mapped
gtk_widget_device_is_shadowed
@@ -4837,7 +4861,6 @@ gtk_style_context_get_parent
gtk_style_context_get_path
gtk_style_context_get_property
gtk_style_context_get_display
gtk_style_context_get_frame_clock
gtk_style_context_get_state
gtk_style_context_get_valist
gtk_style_context_get_section
@@ -4860,7 +4883,6 @@ gtk_style_context_remove_class
gtk_style_context_has_class
gtk_style_context_list_classes
gtk_style_context_set_display
gtk_style_context_set_frame_clock
gtk_style_context_set_state
gtk_style_context_set_scale
gtk_style_context_get_scale
@@ -4881,14 +4903,11 @@ gtk_render_check
gtk_render_expander
gtk_render_focus
gtk_render_frame
gtk_render_frame_gap
gtk_render_handle
gtk_render_layout
gtk_render_line
gtk_render_option
gtk_render_slider
gtk_render_activity
gtk_render_icon_surface
gtk_render_icon
gtk_render_insertion_cursor
@@ -4911,7 +4930,6 @@ gtk_border_get_type
<FILE>gtkcssprovider</FILE>
<TITLE>GtkCssProvider</TITLE>
GtkCssProvider
gtk_css_provider_get_default
gtk_css_provider_get_named
gtk_css_provider_load_from_data
gtk_css_provider_load_from_file
@@ -4988,6 +5006,7 @@ gtk_selection_data_get_type
<TITLE>Drag and Drop</TITLE>
GtkDestDefaults
GtkDragResult
<SUBSECTION Destination Side>
gtk_drag_dest_set
gtk_drag_dest_unset
@@ -4999,13 +5018,13 @@ gtk_drag_dest_add_image_targets
gtk_drag_dest_add_uri_targets
gtk_drag_dest_set_track_motion
gtk_drag_dest_get_track_motion
gtk_drag_finish
gtk_drag_get_data
gtk_drag_get_source_widget
gtk_drag_highlight
gtk_drag_unhighlight
<SUBSECTION Source Side>
gtk_drag_begin_with_coordinates
gtk_drag_begin
gtk_drag_cancel
gtk_drag_set_icon_widget
gtk_drag_set_icon_paintable
@@ -5275,6 +5294,7 @@ gtk_printer_request_details
gtk_printer_get_capabilities
gtk_printer_get_default_page_size
gtk_printer_get_hard_margins
gtk_printer_get_hard_margins_for_paper_size
GtkPrinterFunc
gtk_enumerate_printers
@@ -5989,6 +6009,8 @@ gtk_overlay_get_overlay_pass_through
gtk_overlay_set_overlay_pass_through
gtk_overlay_get_measure_overlay
gtk_overlay_set_measure_overlay
gtk_overlay_get_clip_overlay
gtk_overlay_set_clip_overlay
<SUBSECTION Standard>
GTK_TYPE_OVERLAY
@@ -6436,7 +6458,7 @@ gtk_gesture_single_get_type
<SECTION>
<FILE>gtkeventcontrollerscroll</FILE>
<TITLE>GtkEventControlerScroll</TITLE>
<TITLE>GtkEventControllerScroll</TITLE>
GtkEventControllerScroll
GtkEventControllerScrollFlags
gtk_event_controller_scroll_new
@@ -6457,7 +6479,7 @@ gtk_event_controller_scroll_get_type
<SECTION>
<FILE>gtkeventcontrollermotion</FILE>
<TITLE>GtkEventControlerMotion</TITLE>
<TITLE>GtkEventControllerMotion</TITLE>
GtkEventControllerMotion
gtk_event_controller_motion_new
@@ -6473,6 +6495,24 @@ GTK_EVENT_CONTROLLER_MOTION_GET_CLASS
gtk_event_controller_motion_get_type
</SECTION>
<SECTION>
<FILE>gtkeventcontrollerkey</FILE>
<TITLE>GtkEventControllerKey</TITLE>
GtkEventControllerKey
gtk_event_controller_key_new
<SUBSECTION Standard>
GTK_TYPE_EVENT_CONTROLLER_KEY
GTK_EVENT_CONTROLLER_KEY
GTK_EVENT_CONTROLLER_KEY_CLASS
GTK_IS_EVENT_CONTROLLER_KEY
GTK_IS_EVENT_CONTROLLER_KEY_CLASS
GTK_EVENT_CONTROLLER_KEY_GET_CLASS
<SUBSECTION Private>
gtk_event_controller_key_get_type
</SECTION>
<SECTION>
<FILE>gtkgesturedrag</FILE>
<TITLE>GtkGestureDrag</TITLE>
@@ -6631,15 +6671,39 @@ GTK_PAD_CONTROLLER_GET_CLASS
gtk_pad_controller_get_type
</SECTION>
<SECTION>
<FILE>gtkgesturestylus</FILE>
<TITLE>GtkGestureStylus</TITLE>
GtkGestureStylus
gtk_gesture_stylus_new
gtk_gesture_stylus_get_axis
gtk_gesture_stylus_get_axes
gtk_gesture_stylus_get_backlog
gtk_gesture_stylus_get_device_tool
<SUBSECTION Standard>
GTK_TYPE_GESTURE_STYLUS
GTK_GESTURE_STYLUS
GTK_GESTURE_STYLUS_CLASS
GTK_IS_GESTURE_STYLUS
GTK_IS_GESTURE_STYLUS_CLASS
GTK_GESTURE_STYLUS_GET_CLASS
GtkGestureStylusClass
<SUBSECTION Private>
gtk_gesture_stylus_get_type
</SECTION>
<SECTION>
<FILE>gtkstacksidebar</FILE>
GtkStackSidebar
GtkStackSidebarClass
gtk_stack_sidebar_new
gtk_stack_sidebar_set_stack
gtk_stack_sidebar_get_stack
<SUBSECTION Standard>
GtkStackSidebarClass
GTK_TYPE_STACK_SIDEBAR
GTK_STACK_SIDEBAR
GTK_STACK_SIDEBAR_CLASS
@@ -6664,8 +6728,6 @@ gtk_gl_area_attach_buffers
gtk_gl_area_set_error
gtk_gl_area_get_error
<SUBSECTION>
gtk_gl_area_set_has_alpha
gtk_gl_area_get_has_alpha
gtk_gl_area_set_has_depth_buffer
gtk_gl_area_get_has_depth_buffer
gtk_gl_area_set_has_stencil_buffer
@@ -6772,3 +6834,102 @@ GTK_SHORTCUT_LABEL_GET_CLASS
GTK_IS_SHORTCUT_LABEL
GTK_IS_SHORTCUT_LABEL_CLASS
</SECTION>
<SECTION>
<FILE>gtkvideo</FILE>
GtkVideo
gtk_video_new
gtk_video_new_for_media_stream
gtk_video_new_for_file
gtk_video_new_for_filename
gtk_video_new_for_resource
gtk_video_get_media_stream
gtk_video_set_media_stream
gtk_video_get_file
gtk_video_set_file
gtk_video_set_filename
gtk_video_set_resource
gtk_video_get_autoplay
gtk_video_set_autoplay
gtk_video_get_loop
gtk_video_set_loop
<SUBSECTION Private>
gtk_video_get_type
</SECTION>
<SECTION>
<FILE>gtkmediacontrols</FILE>
GtkMediaControls
gtk_media_controls_new
gtk_media_controls_get_media_stream
gtk_media_controls_set_media_stream
<SUBSECTION Private>
gtk_media_controls_get_type
</SECTION>
<SECTION>
<FILE>gtkmediafile</FILE>
GtkMediaFile
gtk_media_file_new
gtk_media_file_new_for_filename
gtk_media_file_new_for_resource
gtk_media_file_new_for_file
gtk_media_file_new_for_input_stream
gtk_media_file_clear
gtk_media_file_set_filename
gtk_media_file_set_resource
gtk_media_file_set_file
gtk_media_file_get_file
gtk_media_file_set_input_stream
gtk_media_file_get_input_stream
<SUBSECTION Private>
GTK_TYPE_MEDIA_FILE
gtk_media_file_get_type
</SECTION>
<SECTION>
<FILE>gtkmediastream</FILE>
GtkMediaStream
GtkMediaStreamClass
gtk_media_stream_is_prepared
gtk_media_stream_get_error
gtk_media_stream_has_audio
gtk_media_stream_has_video
gtk_media_stream_play
gtk_media_stream_pause
gtk_media_stream_get_playing
gtk_media_stream_set_playing
gtk_media_stream_get_ended
gtk_media_stream_get_timestamp
gtk_media_stream_get_duration
gtk_media_stream_is_seekable
gtk_media_stream_is_seeking
gtk_media_stream_seek
gtk_media_stream_get_loop
gtk_media_stream_set_loop
gtk_media_stream_get_muted
gtk_media_stream_set_muted
gtk_media_stream_get_volume
gtk_media_stream_set_volume
gtk_media_stream_realize
gtk_media_stream_unrealize
<SUBSECTION>
gtk_media_stream_prepared
gtk_media_stream_unprepared
gtk_media_stream_update
gtk_media_stream_ended
gtk_media_stream_seek_success
gtk_media_stream_seek_failed
gtk_media_stream_gerror
gtk_media_stream_error
gtk_media_stream_error_valist
<SUBSECTION Private>
GTK_TYPE_MEDIA_STREAM
gtk_media_stream_get_type
</SECTION>

View File

@@ -53,8 +53,9 @@ gtk_entry_buffer_get_type
gtk_entry_completion_get_type
gtk_entry_get_type
gtk_event_controller_get_type
gtk_event_controller_scroll_get_type
gtk_event_controller_key_get_type
gtk_event_controller_motion_get_type
gtk_event_controller_scroll_get_type
gtk_expander_get_type
gtk_file_chooser_button_get_type
gtk_file_chooser_dialog_get_type
@@ -76,6 +77,7 @@ gtk_gesture_multi_press_get_type
gtk_gesture_pan_get_type
gtk_gesture_rotate_get_type
gtk_gesture_single_get_type
gtk_gesture_stylus_get_type
gtk_gesture_swipe_get_type
gtk_gesture_zoom_get_type
gtk_gl_area_get_type
@@ -96,6 +98,9 @@ gtk_list_store_get_type
gtk_list_box_get_type
gtk_list_box_row_get_type
gtk_lock_button_get_type
gtk_media_controls_get_type
gtk_media_file_get_type
gtk_media_stream_get_type
gtk_menu_bar_get_type
gtk_menu_button_get_type
gtk_menu_get_type
@@ -113,6 +118,7 @@ gtk_page_setup_get_type
@DISABLE_ON_W32@gtk_page_setup_unix_dialog_get_type
gtk_paned_get_type
gtk_paper_size_get_type
gtk_picture_get_type
gtk_popover_get_type
gtk_popover_menu_get_type
@DISABLE_ON_W32@gtk_printer_get_type
@@ -179,6 +185,7 @@ gtk_tree_sortable_get_type
gtk_tree_store_get_type
gtk_tree_view_column_get_type
gtk_tree_view_get_type
gtk_video_get_type
gtk_viewport_get_type
gtk_volume_button_get_type
gtk_widget_get_type

View File

@@ -179,41 +179,6 @@
</para>
</refsect2>
<refsect2 id="event-masks">
<title>Event masks</title>
<para>
Each widget instance has a basic event mask and another per input device,
which determine the types of input event it receives. Each event mask set
on a widget is added to the corresponding (basic or per-device) event mask
for the widgets #GdkSurface, and all child #GdkSurfaces.
</para>
<para>
Filtering events against event masks happens inside #GdkSurface, which
exposes event masks to the windowing system to reduce the number of events
GDK receives from it. On receiving an event, it is filtered against the
#GdkSurfaces mask for the input device, if set. Otherwise, it is filtered
against the #GdkSurfaces basic event mask.
</para>
<para>
This means that widgets must add to the event mask for each event type
they expect to receive, using gtk_widget_set_events() or
gtk_widget_add_events() to preserve the existing mask. Widgets which are
aware of floating devices should use gtk_widget_set_device_events() or
gtk_widget_add_device_events(), and must explicitly enable the device
using gtk_widget_set_device_enabled(). See the #GdkDeviceManager
documentation for more information.
</para>
<para>
All standard widgets set the event mask for all events they expect to
receive, and it is not necessary to modify this. Masks should be set when
implementing a new widget.
</para>
</refsect2>
<refsect2>
<title>Touch events</title>

View File

@@ -1,4 +1,195 @@
private_headers = [
'gdkpixbufutilsprivate.h',
'gtkaccelgroupprivate.h',
'gtkaccelmapprivate.h',
'gtkactionhelperprivate.h',
'gtkactionmuxerprivate.h',
'gtkadjustmentprivate.h',
'gtkallocatedbitmaskprivate.h',
'gtkappchooserprivate.h',
'gtkapplicationaccelsprivate.h',
'gtkapplicationprivate.h',
'gtkbindingsprivate.h',
'gtkbitmaskprivate.h',
'gtkboxprivate.h',
'gtkbuilderprivate.h',
'gtkbuttonprivate.h',
'gtkcellareaboxcontextprivate.h',
'gtkcheckbuttonprivate.h',
'gtkcheckmenuitemprivate.h',
'gtkcolorchooserprivate.h',
'gtkcoloreditorprivate.h',
'gtkcolorplaneprivate.h',
'gtkcolorscaleprivate.h',
'gtkcolorswatchprivate.h',
'gtkcomboboxprivate.h',
'gtkcontainerprivate.h',
'gtkcssanimatedstyleprivate.h',
'gtkcssanimationprivate.h',
'gtkcssarrayvalueprivate.h',
'gtkcssbgsizevalueprivate.h',
'gtkcssbordervalueprivate.h',
'gtkcsscalcvalueprivate.h',
'gtkcsscolorvalueprivate.h',
'gtkcsscornervalueprivate.h',
'gtkcssdimensionvalueprivate.h',
'gtkcssdynamicprivate.h',
'gtkcsseasevalueprivate.h',
'gtkcssenumvalueprivate.h',
'gtkcssfiltervalueprivate.h',
'gtkcssfontfeaturesvalueprivate.h',
'gtkcssfontvariationsvalueprivate.h',
'gtkcssiconthemevalueprivate.h',
'gtkcssimagebuiltinprivate.h',
'gtkcssimagecrossfadeprivate.h',
'gtkcssimagefallbackprivate.h',
'gtkcssimageiconthemeprivate.h',
'gtkcssimageinvalidprivate.h',
'gtkcssimagelinearprivate.h',
'gtkcssimagepaintableprivate.h',
'gtkcssimageprivate.h',
'gtkcssimageradialprivate.h',
'gtkcssimagerecolorprivate.h',
'gtkcssimagescaledprivate.h',
'gtkcssimageurlprivate.h',
'gtkcssimagevalueprivate.h',
'gtkcssimagewin32private.h',
'gtkcssinheritvalueprivate.h',
'gtkcssinitialvalueprivate.h',
'gtkcsskeyframesprivate.h',
'gtkcsslookupprivate.h',
'gtkcssmatcherprivate.h',
'gtkcssnodedeclarationprivate.h',
'gtkcssnodeprivate.h',
'gtkcssnodestylecacheprivate.h',
'gtkcssnumbervalueprivate.h',
'gtkcsspalettevalueprivate.h',
'gtkcssparserprivate.h',
'gtkcsspathnodeprivate.h',
'gtkcsspositionvalueprivate.h',
'gtkcssproviderprivate.h',
'gtkcssrepeatvalueprivate.h',
'gtkcssrgbavalueprivate.h',
'gtkcsssectionprivate.h',
'gtkcssselectorprivate.h',
'gtkcssshadowsvalueprivate.h',
'gtkcssshadowvalueprivate.h',
'gtkcssshorthandpropertyprivate.h',
'gtkcssstaticstyleprivate.h',
'gtkcssstringvalueprivate.h',
'gtkcssstylechangeprivate.h',
'gtkcssstyleprivate.h',
'gtkcssstylepropertyprivate.h',
'gtkcsstransformvalueprivate.h',
'gtkcsstransientnodeprivate.h',
'gtkcsstransitionprivate.h',
'gtkcsstypesprivate.h',
'gtkcssunsetvalueprivate.h',
'gtkcssvalueprivate.h',
'gtkcsswidgetnodeprivate.h',
'gtkcsswin32sizevalueprivate.h',
'gtkdialogprivate.h',
'gtkdndprivate.h',
'gtkentryprivate.h',
'gtkeventcontrollerlegacyprivate.h',
'gtkeventcontrollerprivate.h',
'gtkfilechoosererrorstackprivate.h',
'gtkfilechoosernativeprivate.h',
'gtkfilechooserprivate.h',
'gtkfilechooserwidgetprivate.h',
'gtkfilefilterprivate.h',
'gtkfontchooserprivate.h',
'gtkfontchooserwidgetprivate.h',
'gtkgesturedragprivate.h',
'gtkgesturelongpressprivate.h',
'gtkgesturemultipressprivate.h',
'gtkgesturepanprivate.h',
'gtkgestureprivate.h',
'gtkgesturerotateprivate.h',
'gtkgesturesingleprivate.h',
'gtkgesturestylusprivate.h',
'gtkgestureswipeprivate.h',
'gtkgesturezoomprivate.h',
'gtkgizmoprivate.h',
'gtkheaderbarprivate.h',
'gtkhslaprivate.h',
'gtkiconcacheprivate.h',
'gtkiconcachevalidatorprivate.h',
'gtkiconhelperprivate.h',
'gtkiconprivate.h',
'gtkiconthemeprivate.h',
'gtkiconviewprivate.h',
'gtkimagedefinitionprivate.h',
'gtkimageprivate.h',
'gtkimcontextsimpleprivate.h',
'gtkimmoduleprivate.h',
'gtkkineticscrollingprivate.h',
'gtklabelprivate.h',
'gtklockbuttonprivate.h',
'gtkmagnifierprivate.h',
'gtkmediafileprivate.h',
'gtkmenubuttonprivate.h',
'gtkmenuitemprivate.h',
'gtkmenuprivate.h',
'gtkmenushellprivate.h',
'gtkmodulesprivate.h',
'gtkmountoperationprivate.h',
'gtknativedialogprivate.h',
'gtknomediafileprivate.h',
'gtkorientableprivate.h',
'gtkplacessidebarprivate.h',
'gtkplacesviewprivate.h',
'gtkplacesviewrowprivate.h',
'gtkpointerfocusprivate.h',
'gtkpopoverprivate.h',
'gtkprinter-private.h',
'gtkprintoperation-private.h',
'gtkprivate.h',
'gtkprogresstrackerprivate.h',
'gtkrangeprivate.h',
'gtkrbtreeprivate.h',
'gtkrenderbackgroundprivate.h',
'gtkrenderborderprivate.h',
'gtkrendericonprivate.h',
'gtkrendernodepaintableprivate.h',
'gtkroundedboxprivate.h',
'gtkscalerprivate.h',
'gtksearchentryprivate.h',
'gtkselectionprivate.h',
'gtksettingsprivate.h',
'gtkshortcutsshortcutprivate.h',
'gtkshortcutswindowprivate.h',
'gtksidebarrowprivate.h',
'gtksizegroup-private.h',
'gtksizerequestcacheprivate.h',
'gtksnapshotprivate.h',
'gtkstyleanimationprivate.h',
'gtkstylecascadeprivate.h',
'gtkstylecontextprivate.h',
'gtkstylepropertyprivate.h',
'gtkstyleproviderprivate.h',
'gtktextbufferprivate.h',
'gtktextchildprivate.h',
'gtktextdisplayprivate.h',
'gtktexthandleprivate.h',
'gtktextiterprivate.h',
'gtktextlayoutprivate.h',
'gtktextmarkprivate.h',
'gtktexttagprivate.h',
'gtktextviewprivate.h',
'gtktogglebuttonprivate.h',
'gtktoolbarprivate.h',
'gtktooltipprivate.h',
'gtktooltipwindowprivate.h',
'gtktreeprivate.h',
'gtkutilsprivate.h',
'gtkwidgetpaintableprivate.h',
'gtkwidgetpathprivate.h',
'gtkwidgetprivate.h',
'gtkwin32drawprivate.h',
'gtkwin32themeprivate.h',
'gtkwindowprivate.h',
'gtk-text-input-client-protocol.h',
]
images = [
@@ -164,7 +355,6 @@ content_files = [
'input-handling.xml',
'migrating-2to4.xml',
'migrating-3to4.xml',
'mir.xml',
'osx.sgml',
'other_software.sgml',
'overview.xml',
@@ -207,17 +397,18 @@ else
types_conf.set('DISABLE_ON_QUARTZ', '')
endif
configure_file(input: 'gtk4.types.in', output: 'gtk4.types', configuration: types_conf)
gnome.gtkdoc('gtk4',
mode: 'none',
main_xml: 'gtk4-docs.xml',
src_dir: [
join_paths(meson.source_root(), 'gtk'),
join_paths(meson.build_root(), 'gtk'),
gtkinc,
],
dependencies: libgtk_dep,
gobject_typesfile: 'gtk4.types',
gobject_typesfile: configure_file(
input: 'gtk4.types.in',
output: 'gtk4.types',
configuration: types_conf,
),
scan_args: [
'--ignore-decorators=_GDK_EXTERN|G_GNUC_WARN_UNUSED_RESULT',
'--ignore-headers=' + ' '.join(private_headers),

View File

@@ -20,11 +20,11 @@
<para>
The steps outlined in the following sections assume that your
application is working with GTK+ 3.22, which is the final stable
application is working with GTK+ 3.24, which is the final stable
release of GTK+ 3.x. It includes all the necessary APIs and tools
to help you port your application to GTK+ 4. If you are still using
an older version of GTK+ 3.x, you should first get your application
to build and work with the latest minor release in the 3.22 series.
to build and work with the latest minor release in the 3.24 series.
</para>
<section>
@@ -34,7 +34,7 @@
widgets have been deprecated. These deprecations are clearly spelled
out in the API reference, with hints about the recommended replacements.
The API reference for GTK+ 3 also includes an
<ulink url="https://developer.gnome.org/gtk3/3.22/api-index-deprecated.html">index</ulink> of all deprecated symbols.
<ulink url="https://developer.gnome.org/gtk3/3.24/api-index-deprecated.html">index</ulink> of all deprecated symbols.
</para>
<para>
To verify that your program does not use any deprecated symbols,
@@ -79,13 +79,13 @@
<title>Review your window creation flags</title>
<para>
GTK+ 4 removes the GDK_WA_CURSOR flag. Instead, just use
gdk_surface_set_cursor() to set a cursor on the window after
gdk_window_set_cursor() to set a cursor on the window after
creating it.
</para>
<para>
GTK+ 4 also removes the GDK_WA_VISUAL flag, and always uses
an RGBA visual for windows. To prepare your code for this,
use gdk_surface_set_visual (gdk_screen_get_rgba_visual ()) after
use gdk_window_set_visual (gdk_screen_get_rgba_visual ()) after
creating your window.
</para>
<para>
@@ -169,6 +169,14 @@
</para>
</section>
<section>
<title>Stop using GtkWidget event signals</title>
<para>
Event controllers and #GtkGestures replace event signals in GTK+ 4. They
have been backported to GTK+ 3.x so you can prepare for this change.
</para>
</section>
</section>
<section>
@@ -217,9 +225,12 @@
</section>
<section>
<title>Adapt to GdkSurface API changes</title>
<title>Adapt to GdkWindow API changes</title>
<para>
The gdk_surface_new() function has been replaced by a number of more
GdkWindow has been renamed to GdkSurface.
</para>
<para>
The gdk_window_new() function has been replaced by a number of more
specialized constructors: gdk_surface_new_toplevel(), gdk_surface_new_popup(),
gdk_surface_new_temp(), gdk_surface_new_child(), gdk_surface_new_input(),
gdk_wayland_surface_new_subsurface(). Use the appropriate ones to create
@@ -230,7 +241,7 @@
complicating the code and could not be supported across backends.
</para>
<para>
gdk_surface_reparent() is no longer available.
gdk_window_reparent() is no longer available.
</para>
</section>
@@ -416,8 +427,8 @@
<title>GdkPixbuf is deemphasized</title>
<para>
A number of #GdkPixbuf-based APIs have been removed. The available replacements
are either using #GIcon, cairo_surface_t or the newly introduced #GdkTexture class
instead.
are either using #GIcon, or the newly introduced #GdkTexture or #GdkPaintable
classes instead.
</para>
<para>
If you are dealing with pixbufs, you can use gdk_texture_new_for_pixbuf()
@@ -426,12 +437,36 @@
</section>
<section>
<title>GtkWidget event signals are deemphasized</title>
<title>GtkWidget event signals are removed</title>
<para>
Event controllers and #GtkGestures have already been introduced in GTK+ 3 to handle
input for many cases. In GTK+ 4, even more are available, such as #GtkEventControllerScroll
and GtkEventControllerMotion, and the traditional widget signals for handling input,
such as #GtkWidget::motion-event or #GtkWidget::event have been deprecated.
input for many cases. In GTK+ 4, the traditional widget signals for handling input,
such as #GtkWidget::motion-event or #GtkWidget::event have been removed.
</para>
</section>
<section>
<title>Invalidation handling has changed</title>
<para>
Only gtk_widget_queue_draw() is left to mark a widget as needing redraw.
Variations like gtk_widget_queue_draw_rectangle() or gtk_widget_queue_draw_region()
are no longer available.
</para>
</section>
<section>
<title>Stop using GtkWidget::draw</title>
<para>
The #GtkWidget::draw signal has been removed. Widgets need to implement the
#GtkWidget::snapshot function now. Connecting draw signal handlers is no longer possible.
</para>
</section>
<section>
<title>Window content observation has changed</title>
<para>
Observing widget contents and widget size is now done by using the
#GtkWidgetPaintable object instead of connecting to widget signals.
</para>
</section>
@@ -475,6 +510,7 @@
#GtkCellRendererPixbuf:icon-size.
</para>
</section>
</section>
</chapter>

View File

@@ -1,35 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
]>
<refentry id="gtk-mir">
<refmeta>
<refentrytitle>Using GTK+ with Mir</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GTK Library</refmiscinfo>
</refmeta>
<refnamediv>
<refname>Using GTK+ with Mir</refname>
<refpurpose>
Mir-specific aspects of using GTK+
</refpurpose>
</refnamediv>
<refsect1>
<title>Using GTK+ with Mir</title>
<para>
The GDK Mir backend provides support for running GTK+ applications
under Mir based display servers. To run your application in this way,
select the Mir backend by setting <literal>GDK_BACKEND=mir</literal>.
</para>
<para>
Currently, the Mir backend does not use any additional commandline
options or environment variables.
</para>
</refsect1>
</refentry>

View File

@@ -162,10 +162,10 @@ additional environment variables.
Linux and Unix, and the ';' character on Windows.
</para>
<warning>
Note that this environment variable is read by GTK+ 2.x too, which
makes it unsuitable for setting it system-wide (or session-wide),
since doing so will cause either GTK+ 2.x applications or GTK+ 3
applications to see incompatible modules.
Note that this environment variable is read by GTK+ 2.x and GTK+ 3.x too,
which makes it unsuitable for setting it system-wide (or session-wide),
since doing so will cause applications using different GTK+ versions
to see incompatible modules.
</warning>
</formalpara>
@@ -309,7 +309,7 @@ nevertheless.
<listitem><para>Use a legacy OpenGL context</para></listitem>
</varlistentry>
<varlistentry>
<term>gl-legacy</term>
<term>gl-gles</term>
<listitem><para>Use a GLES OpenGL context</para></listitem>
</varlistentry>
<varlistentry>
@@ -320,11 +320,6 @@ nevertheless.
<term>vulkan-validate</term>
<listitem><para>Load the Vulkan validation layer, if available</para></listitem>
</varlistentry>
<varlistentry>
<term>cairo-image</term>
<listitem><para>Use image surfaces for cairo rendering. This essentially
turns off all hardware acceleration with the cairo renderer</para></listitem>
</varlistentry>
</variablelist>
The special value <literal>all</literal> can be used to turn on all
debug options. The special value <literal>help</literal> can be used
@@ -352,6 +347,14 @@ nevertheless.
<term>opengl</term>
<listitem><para>OpenGL renderer information</para></listitem>
</varlistentry>
<varlistentry>
<term>shaders</term>
<listitem><para>Shaders</para></listitem>
</varlistentry>
<varlistentry>
<term>ssurface</term>
<listitem><para>Surfaces</para></listitem>
</varlistentry>
<varlistentry>
<term>vulkan</term>
<listitem><para>Vulkan renderer information</para></listitem>
@@ -367,6 +370,10 @@ nevertheless.
</variablelist>
A number of options affect behavior instead of logging:
<variablelist>
<varlistentry>
<term>diff</term>
<listitem><para>Show differences</para></listitem>
</varlistentry>
<varlistentry>
<term>geometry</term>
<listitem><para>Show borders</para></listitem>
@@ -428,11 +435,6 @@ nevertheless.
<listitem><para>Selects the Wayland backend for connecting to Wayland display servers</para></listitem>
</varlistentry>
<varlistentry>
<term>mir</term>
<listitem><para>Selects the Mir backend for connecting to Mir display servers</para></listitem>
</varlistentry>
</variablelist>
Since 3.10, this environment variable can contain a comma-separated list
of backend names, which are tried in order. The list may also contain
@@ -453,6 +455,44 @@ nevertheless.
</para>
</formalpara>
<formalpara>
<title><envar>GSK_RENDERER</envar></title>
<para>
If set, selects the GSK renderer to use. The following renderers can
be selected, provided they are included in the GTK library you are using
and the GDK backend supports them:
<variablelist>
<varlistentry>
<term>help</term>
<listitem><para>Prints information about available options</para></listitem>
</varlistentry>
<varlistentry>
<term>broadway</term>
<listitem><para>Selects the Broadway-backend specific renderer</para></listitem>
</varlistentry>
<varlistentry>
<term>cairo</term>
<listitem><para>Selects the fallback Cairo renderer</para></listitem>
</varlistentry>
<varlistentry>
<term>gl</term>
<listitem><para>Selects the default OpenGL renderer</para></listitem>
</varlistentry>
<varlistentry>
<term>vulkan</term>
<listitem><para>Selects the Vulkan renderer</para></listitem>
</varlistentry>
</variablelist>
</para>
</formalpara>
<formalpara>
<title><envar>GTK_CSD</envar></title>

View File

@@ -1,7 +1,7 @@
CC ?= gcc
PKGCONFIG = $(shell which pkg-config)
CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-3.0)
LIBS = $(shell $(PKGCONFIG) --libs gtk+-3.0)
CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-4.0)
LIBS = $(shell $(PKGCONFIG) --libs gtk+-4.0)
SRC = main.c exampleapp.c exampleappwin.c

View File

@@ -1,7 +1,7 @@
CC ?= gcc
PKGCONFIG = $(shell which pkg-config)
CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-3.0)
LIBS = $(shell $(PKGCONFIG) --libs gtk+-3.0)
CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-4.0)
LIBS = $(shell $(PKGCONFIG) --libs gtk+-4.0)
GLIB_COMPILE_RESOURCES = $(shell $(PKGCONFIG) --variable=glib_compile_resources gio-2.0)
GLIB_COMPILE_SCHEMAS = $(shell $(PKGCONFIG) --variable=glib_compile_schemas gio-2.0)

View File

@@ -7,43 +7,36 @@
struct _ExampleAppPrefs
{
GtkDialog parent;
};
typedef struct _ExampleAppPrefsPrivate ExampleAppPrefsPrivate;
struct _ExampleAppPrefsPrivate
{
GSettings *settings;
GtkWidget *font;
GtkWidget *transition;
};
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
G_DEFINE_TYPE (ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
static void
example_app_prefs_init (ExampleAppPrefs *prefs)
{
ExampleAppPrefsPrivate *priv;
priv = example_app_prefs_get_instance_private (prefs);
gtk_widget_init_template (GTK_WIDGET (prefs));
priv->settings = g_settings_new ("org.gtk.exampleapp");
prefs->settings = g_settings_new ("org.gtk.exampleapp");
g_settings_bind (priv->settings, "font",
priv->font, "font",
g_settings_bind (prefs->settings, "font",
prefs->font, "font",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (priv->settings, "transition",
priv->transition, "active-id",
g_settings_bind (prefs->settings, "transition",
prefs->transition, "active-id",
G_SETTINGS_BIND_DEFAULT);
}
static void
example_app_prefs_dispose (GObject *object)
{
ExampleAppPrefsPrivate *priv;
ExampleAppPrefs *prefs;
priv = example_app_prefs_get_instance_private (EXAMPLE_APP_PREFS (object));
g_clear_object (&priv->settings);
prefs = EXAMPLE_APP_PREFS (object);
g_clear_object (&prefs->settings);
G_OBJECT_CLASS (example_app_prefs_parent_class)->dispose (object);
}
@@ -55,8 +48,8 @@ example_app_prefs_class_init (ExampleAppPrefsClass *class)
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/exampleapp/prefs.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
}
ExampleAppPrefs *

View File

@@ -6,12 +6,7 @@
struct _ExampleAppWindow
{
GtkApplicationWindow parent;
};
typedef struct _ExampleAppWindowPrivate ExampleAppWindowPrivate;
struct _ExampleAppWindowPrivate
{
GSettings *settings;
GtkWidget *stack;
GtkWidget *search;
@@ -24,13 +19,12 @@ struct _ExampleAppWindowPrivate
GtkWidget *lines_label;
};
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
G_DEFINE_TYPE (ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW)
static void
search_text_changed (GtkEntry *entry)
search_text_changed (GtkEntry *entry,
ExampleAppWindow *win)
{
ExampleAppWindow *win;
ExampleAppWindowPrivate *priv;
const gchar *text;
GtkWidget *tab;
GtkWidget *view;
@@ -42,10 +36,7 @@ search_text_changed (GtkEntry *entry)
if (text[0] == '\0')
return;
win = EXAMPLE_APP_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (entry)));
priv = example_app_window_get_instance_private (win);
tab = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
tab = gtk_stack_get_visible_child (GTK_STACK (win->stack));
view = gtk_bin_get_child (GTK_BIN (tab));
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
@@ -64,19 +55,15 @@ static void
find_word (GtkButton *button,
ExampleAppWindow *win)
{
ExampleAppWindowPrivate *priv;
const gchar *word;
priv = example_app_window_get_instance_private (win);
word = gtk_button_get_label (button);
gtk_entry_set_text (GTK_ENTRY (priv->searchentry), word);
gtk_entry_set_text (GTK_ENTRY (win->searchentry), word);
}
static void
update_words (ExampleAppWindow *win)
{
ExampleAppWindowPrivate *priv;
GHashTable *strings;
GHashTableIter iter;
GtkWidget *tab, *view, *row;
@@ -85,9 +72,7 @@ update_words (ExampleAppWindow *win)
GList *children, *l;
gchar *word, *key;
priv = example_app_window_get_instance_private (win);
tab = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
tab = gtk_stack_get_visible_child (GTK_STACK (win->stack));
if (tab == NULL)
return;
@@ -115,9 +100,9 @@ update_words (ExampleAppWindow *win)
}
done:
children = gtk_container_get_children (GTK_CONTAINER (priv->words));
children = gtk_container_get_children (GTK_CONTAINER (win->words));
for (l = children; l; l = l->next)
gtk_container_remove (GTK_CONTAINER (priv->words), GTK_WIDGET (l->data));
gtk_container_remove (GTK_CONTAINER (win->words), GTK_WIDGET (l->data));
g_list_free (children);
g_hash_table_iter_init (&iter, strings);
@@ -126,8 +111,7 @@ done:
row = gtk_button_new_with_label (key);
g_signal_connect (row, "clicked",
G_CALLBACK (find_word), win);
gtk_widget_show (row);
gtk_container_add (GTK_CONTAINER (priv->words), row);
gtk_container_add (GTK_CONTAINER (win->words), row);
}
g_hash_table_unref (strings);
@@ -136,16 +120,12 @@ done:
static void
update_lines (ExampleAppWindow *win)
{
ExampleAppWindowPrivate *priv;
GtkWidget *tab, *view;
GtkTextBuffer *buffer;
GtkTextIter iter;
int count;
gchar *lines;
priv = example_app_window_get_instance_private (win);
tab = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
tab = gtk_stack_get_visible_child (GTK_STACK (win->stack));
if (tab == NULL)
return;
@@ -153,34 +133,21 @@ update_lines (ExampleAppWindow *win)
view = gtk_bin_get_child (GTK_BIN (tab));
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
count = 0;
gtk_text_buffer_get_start_iter (buffer, &iter);
while (!gtk_text_iter_is_end (&iter))
{
count++;
if (!gtk_text_iter_forward_line (&iter))
break;
}
count = gtk_text_buffer_get_line_count (buffer);
lines = g_strdup_printf ("%d", count);
gtk_label_set_text (GTK_LABEL (priv->lines), lines);
gtk_label_set_text (GTK_LABEL (win->lines), lines);
g_free (lines);
}
static void
visible_child_changed (GObject *stack,
GParamSpec *pspec)
visible_child_changed (GObject *stack,
GParamSpec *pspec,
ExampleAppWindow *win)
{
ExampleAppWindow *win;
ExampleAppWindowPrivate *priv;
if (gtk_widget_in_destruction (GTK_WIDGET (stack)))
return;
win = EXAMPLE_APP_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (stack)));
priv = example_app_window_get_instance_private (win);
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (priv->searchbar), FALSE);
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (win->searchbar), FALSE);
update_words (win);
update_lines (win);
}
@@ -196,45 +163,43 @@ words_changed (GObject *sidebar,
static void
example_app_window_init (ExampleAppWindow *win)
{
ExampleAppWindowPrivate *priv;
GtkBuilder *builder;
GMenuModel *menu;
GAction *action;
priv = example_app_window_get_instance_private (win);
gtk_widget_init_template (GTK_WIDGET (win));
priv->settings = g_settings_new ("org.gtk.exampleapp");
win->settings = g_settings_new ("org.gtk.exampleapp");
g_settings_bind (priv->settings, "transition",
priv->stack, "transition-type",
g_settings_bind (win->settings, "transition",
win->stack, "transition-type",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (priv->settings, "show-words",
priv->sidebar, "reveal-child",
g_settings_bind (win->settings, "show-words",
win->sidebar, "reveal-child",
G_SETTINGS_BIND_DEFAULT);
g_object_bind_property (priv->search, "active",
priv->searchbar, "search-mode-enabled",
g_object_bind_property (win->search, "active",
win->searchbar, "search-mode-enabled",
G_BINDING_BIDIRECTIONAL);
g_signal_connect (priv->sidebar, "notify::reveal-child",
g_signal_connect (win->sidebar, "notify::reveal-child",
G_CALLBACK (words_changed), win);
builder = gtk_builder_new_from_resource ("/org/gtk/exampleapp/gears-menu.ui");
menu = G_MENU_MODEL (gtk_builder_get_object (builder, "menu"));
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (priv->gears), menu);
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (win->gears), menu);
g_object_unref (builder);
action = g_settings_create_action (priv->settings, "show-words");
action = g_settings_create_action (win->settings, "show-words");
g_action_map_add_action (G_ACTION_MAP (win), action);
g_object_unref (action);
action = (GAction*) g_property_action_new ("show-lines", priv->lines, "visible");
action = (GAction*) g_property_action_new ("show-lines", win->lines, "visible");
g_action_map_add_action (G_ACTION_MAP (win), action);
g_object_unref (action);
g_object_bind_property (priv->lines, "visible",
priv->lines_label, "visible",
g_object_bind_property (win->lines, "visible",
win->lines_label, "visible",
G_BINDING_DEFAULT);
g_object_set (gtk_settings_get_default (), "gtk-shell-shows-app-menu", FALSE, NULL);
@@ -245,12 +210,10 @@ static void
example_app_window_dispose (GObject *object)
{
ExampleAppWindow *win;
ExampleAppWindowPrivate *priv;
win = EXAMPLE_APP_WINDOW (object);
priv = example_app_window_get_instance_private (win);
g_clear_object (&priv->settings);
g_clear_object (&win->settings);
G_OBJECT_CLASS (example_app_window_parent_class)->dispose (object);
}
@@ -263,15 +226,15 @@ example_app_window_class_init (ExampleAppWindowClass *class)
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/exampleapp/window.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, search);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchbar);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchentry);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, gears);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, words);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, sidebar);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, lines);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, lines_label);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, search);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchbar);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchentry);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, gears);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, words);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, sidebar);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, lines);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, lines_label);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), search_text_changed);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), visible_child_changed);
@@ -287,7 +250,6 @@ void
example_app_window_open (ExampleAppWindow *win,
GFile *file)
{
ExampleAppWindowPrivate *priv;
gchar *basename;
GtkWidget *scrolled, *view;
gchar *contents;
@@ -296,19 +258,16 @@ example_app_window_open (ExampleAppWindow *win,
GtkTextTag *tag;
GtkTextIter start_iter, end_iter;
priv = example_app_window_get_instance_private (win);
basename = g_file_get_basename (file);
scrolled = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scrolled);
gtk_widget_set_hexpand (scrolled, TRUE);
gtk_widget_set_vexpand (scrolled, TRUE);
view = gtk_text_view_new ();
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
gtk_widget_show (view);
gtk_container_add (GTK_CONTAINER (scrolled), view);
gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename);
gtk_stack_add_titled (GTK_STACK (win->stack), scrolled, basename, basename);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
@@ -319,7 +278,7 @@ example_app_window_open (ExampleAppWindow *win,
}
tag = gtk_text_buffer_create_tag (buffer, NULL, NULL);
g_settings_bind (priv->settings, "font",
g_settings_bind (win->settings, "font",
tag, "font",
G_SETTINGS_BIND_DEFAULT);
@@ -329,7 +288,7 @@ example_app_window_open (ExampleAppWindow *win,
g_free (basename);
gtk_widget_set_sensitive (priv->search, TRUE);
gtk_widget_set_sensitive (win->search, TRUE);
update_words (win);
update_lines (win);

View File

@@ -9,15 +9,13 @@
<object class="GtkBox" id="vbox">
<child>
<object class="GtkGrid" id="grid">
<property name="visible">True</property>
<property name="margin">6</property>
<property name="row-spacing">12</property>
<property name="column-spacing">6</property>
<child>
<object class="GtkLabel" id="fontlabel">
<property name="visible">True</property>
<property name="label">_Font:</property>
<property name="use-underline">True</property>
<property name="use-underline">1</property>
<property name="mnemonic-widget">font</property>
<property name="xalign">1</property>
</object>
@@ -28,7 +26,6 @@
</child>
<child>
<object class="GtkFontButton" id="font">
<property name="visible">True</property>
</object>
<packing>
<property name="left-attach">1</property>
@@ -37,9 +34,8 @@
</child>
<child>
<object class="GtkLabel" id="transitionlabel">
<property name="visible">True</property>
<property name="label">_Transition:</property>
<property name="use-underline">True</property>
<property name="use-underline">1</property>
<property name="mnemonic-widget">transition</property>
<property name="xalign">1</property>
</object>
@@ -50,7 +46,6 @@
</child>
<child>
<object class="GtkComboBoxText" id="transition">
<property name="visible">True</property>
<items>
<item translatable="yes" id="none">None</item>
<item translatable="yes" id="crossfade">Fade</item>

View File

@@ -5,107 +5,79 @@
<property name="title" translatable="yes">Example Application</property>
<property name="default-width">600</property>
<property name="default-height">400</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="header">
<property name="visible">True</property>
<property name="show-title-buttons">True</property>
<child>
<object class="GtkLabel" id="lines_label">
<property name="visible">False</property>
<property name="label" translatable="yes">Lines:</property>
</object>
<packing>
<property name="pack-type">start</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lines">
<property name="visible">False</property>
</object>
<packing>
<property name="pack-type">start</property>
</packing>
</child>
<child type="title">
<object class="GtkStackSwitcher" id="tabs">
<property name="visible">True</property>
<property name="stack">stack</property>
</object>
</child>
<child>
<object class="GtkToggleButton" id="search">
<property name="visible">True</property>
<property name="sensitive">False</property>
<style>
<class name="image-button"/>
</style>
<child>
<object class="GtkImage" id="search-icon">
<property name="visible">True</property>
<property name="icon-name">edit-find-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="pack-type">end</property>
</packing>
</child>
<child>
<object class="GtkMenuButton" id="gears">
<property name="visible">True</property>
<property name="direction">none</property>
<property name="use-popover">True</property>
<style>
<class name="image-button"/>
</style>
</object>
<packing>
<property name="pack-type">end</property>
</packing>
</child>
<child type="titlebar">
<object class="GtkHeaderBar" id="header">
<property name="show-title-buttons">1</property>
<child>
<object class="GtkLabel" id="lines_label">
<property name="visible">0</property>
<property name="label" translatable="yes">Lines:</property>
</object>
</child>
<child>
<object class="GtkLabel" id="lines">
<property name="visible">0</property>
</object>
</child>
<child type="title">
<object class="GtkStackSwitcher" id="tabs">
<property name="stack">stack</property>
</object>
</child>
<child>
<object class="GtkToggleButton" id="search">
<property name="sensitive">0</property>
<property name="icon-name">edit-find-symbolic</property>
</object>
<packing>
<property name="pack-type">end</property>
</packing>
</child>
<child>
<object class="GtkMenuButton" id="gears">
<property name="direction">none</property>
<style>
<class name="image-button"/>
</style>
</object>
<packing>
<property name="pack-type">end</property>
</packing>
</child>
</object>
</child>
<child>
<object class="GtkBox" id="content_box">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkSearchBar" id="searchbar">
<property name="visible">True</property>
<child>
<object class="GtkSearchEntry" id="searchentry">
<signal name="search-changed" handler="search_text_changed"/>
<property name="visible">True</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox" id="hbox">
<property name="visible">True</property>
<child>
<object class="GtkRevealer" id="sidebar">
<property name="visible">True</property>
<property name="transition-type">slide-right</property>
<child>
<object class="GtkScrolledWindow" id="sidebar-sw">
<property name="visible">True</property>
<property name="hscrollbar-policy">never</property>
<property name="vscrollbar-policy">automatic</property>
<child>
<object class="GtkListBox" id="words">
<property name="visible">True</property>
<property name="selection-mode">none</property>
</object>
</child>
</object>
<object class="GtkScrolledWindow" id="sidebar-sw">
<property name="hscrollbar-policy">never</property>
<child>
<object class="GtkListBox" id="words">
<property name="selection-mode">none</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkStack" id="stack">
<signal name="notify::visible-child" handler="visible_child_changed"/>
<property name="visible">True</property>
</object>
</child>
</object>

View File

@@ -1,7 +1,7 @@
CC ?= gcc
PKGCONFIG = $(shell which pkg-config)
CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-3.0)
LIBS = $(shell $(PKGCONFIG) --libs gtk+-3.0)
CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-4.0)
LIBS = $(shell $(PKGCONFIG) --libs gtk+-4.0)
GLIB_COMPILE_RESOURCES = $(shell $(PKGCONFIG) --variable=glib_compile_resources gio-2.0)
SRC = exampleapp.c exampleappwin.c main.c

View File

@@ -7,14 +7,11 @@
<property name="default-height">400</property>
<child>
<object class="GtkBox" id="content_box">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkHeaderBar" id="header">
<property name="visible">True</property>
<child type="title">
<object class="GtkStackSwitcher" id="tabs">
<property name="visible">True</property>
<property name="stack">stack</property>
</object>
</child>
@@ -22,7 +19,6 @@
</child>
<child>
<object class="GtkStack" id="stack">
<property name="visible">True</property>
</object>
</child>
</object>

View File

@@ -1,7 +1,7 @@
CC ?= gcc
PKGCONFIG = $(shell which pkg-config)
CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-3.0)
LIBS = $(shell $(PKGCONFIG) --libs gtk+-3.0)
CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-4.0)
LIBS = $(shell $(PKGCONFIG) --libs gtk+-4.0)
GLIB_COMPILE_RESOURCES = $(shell $(PKGCONFIG) --variable=glib_compile_resources gio-2.0)
SRC = exampleapp.c exampleappwin.c main.c

View File

@@ -6,16 +6,11 @@
struct _ExampleAppWindow
{
GtkApplicationWindow parent;
};
typedef struct _ExampleAppWindowPrivate ExampleAppWindowPrivate;
struct _ExampleAppWindowPrivate
{
GtkWidget *stack;
};
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
G_DEFINE_TYPE (ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW)
static void
example_app_window_init (ExampleAppWindow *win)
@@ -28,7 +23,7 @@ example_app_window_class_init (ExampleAppWindowClass *class)
{
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/exampleapp/window.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
}
ExampleAppWindow *
@@ -41,25 +36,21 @@ void
example_app_window_open (ExampleAppWindow *win,
GFile *file)
{
ExampleAppWindowPrivate *priv;
gchar *basename;
GtkWidget *scrolled, *view;
gchar *contents;
gsize length;
priv = example_app_window_get_instance_private (win);
basename = g_file_get_basename (file);
scrolled = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scrolled);
gtk_widget_set_hexpand (scrolled, TRUE);
gtk_widget_set_vexpand (scrolled, TRUE);
view = gtk_text_view_new ();
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
gtk_widget_show (view);
gtk_container_add (GTK_CONTAINER (scrolled), view);
gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename);
gtk_stack_add_titled (GTK_STACK (win->stack), scrolled, basename, basename);
if (g_file_load_contents (file, NULL, &contents, &length, NULL, NULL))
{

View File

@@ -7,14 +7,11 @@
<property name="default-height">400</property>
<child>
<object class="GtkBox" id="content_box">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkHeaderBar" id="header">
<property name="visible">True</property>
<child type="title">
<object class="GtkStackSwitcher" id="tabs">
<property name="visible">True</property>
<property name="stack">stack</property>
</object>
</child>
@@ -22,7 +19,6 @@
</child>
<child>
<object class="GtkStack" id="stack">
<property name="visible">True</property>
</object>
</child>
</object>

View File

@@ -1,7 +1,7 @@
CC ?= gcc
PKGCONFIG = $(shell which pkg-config)
CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-3.0)
LIBS = $(shell $(PKGCONFIG) --libs gtk+-3.0)
CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-4.0)
LIBS = $(shell $(PKGCONFIG) --libs gtk+-4.0)
GLIB_COMPILE_RESOURCES = $(shell $(PKGCONFIG) --variable=glib_compile_resources gio-2.0)
SRC = exampleapp.c exampleappwin.c main.c

View File

@@ -6,16 +6,11 @@
struct _ExampleAppWindow
{
GtkApplicationWindow parent;
};
typedef struct _ExampleAppWindowPrivate ExampleAppWindowPrivate;
struct _ExampleAppWindowPrivate
{
GtkWidget *stack;
};
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
G_DEFINE_TYPE (ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW)
static void
example_app_window_init (ExampleAppWindow *win)
@@ -28,7 +23,7 @@ example_app_window_class_init (ExampleAppWindowClass *class)
{
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/exampleapp/window.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
}
ExampleAppWindow *
@@ -41,25 +36,21 @@ void
example_app_window_open (ExampleAppWindow *win,
GFile *file)
{
ExampleAppWindowPrivate *priv;
gchar *basename;
GtkWidget *scrolled, *view;
gchar *contents;
gsize length;
priv = example_app_window_get_instance_private (win);
basename = g_file_get_basename (file);
scrolled = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scrolled);
gtk_widget_set_hexpand (scrolled, TRUE);
gtk_widget_set_vexpand (scrolled, TRUE);
view = gtk_text_view_new ();
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
gtk_widget_show (view);
gtk_container_add (GTK_CONTAINER (scrolled), view);
gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename);
gtk_stack_add_titled (GTK_STACK (win->stack), scrolled, basename, basename);
if (g_file_load_contents (file, NULL, &contents, &length, NULL, NULL))
{

View File

@@ -7,14 +7,11 @@
<property name="default-height">400</property>
<child>
<object class="GtkBox" id="content_box">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkHeaderBar" id="header">
<property name="visible">True</property>
<child type="title">
<object class="GtkStackSwitcher" id="tabs">
<property name="visible">True</property>
<property name="stack">stack</property>
</object>
</child>
@@ -22,7 +19,6 @@
</child>
<child>
<object class="GtkStack" id="stack">
<property name="visible">True</property>
</object>
</child>
</object>

View File

@@ -1,7 +1,7 @@
CC ?= gcc
PKGCONFIG = $(shell which pkg-config)
CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-3.0)
LIBS = $(shell $(PKGCONFIG) --libs gtk+-3.0)
CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-4.0)
LIBS = $(shell $(PKGCONFIG) --libs gtk+-4.0)
GLIB_COMPILE_RESOURCES = $(shell $(PKGCONFIG) --variable=glib_compile_resources gio-2.0)
GLIB_COMPILE_SCHEMAS = $(shell $(PKGCONFIG) --variable=glib_compile_schemas gio-2.0)

View File

@@ -6,29 +6,21 @@
struct _ExampleAppWindow
{
GtkApplicationWindow parent;
};
typedef struct _ExampleAppWindowPrivate ExampleAppWindowPrivate;
struct _ExampleAppWindowPrivate
{
GSettings *settings;
GtkWidget *stack;
};
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
G_DEFINE_TYPE (ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW)
static void
example_app_window_init (ExampleAppWindow *win)
{
ExampleAppWindowPrivate *priv;
priv = example_app_window_get_instance_private (win);
gtk_widget_init_template (GTK_WIDGET (win));
priv->settings = g_settings_new ("org.gtk.exampleapp");
win->settings = g_settings_new ("org.gtk.exampleapp");
g_settings_bind (priv->settings, "transition",
priv->stack, "transition-type",
g_settings_bind (win->settings, "transition",
win->stack, "transition-type",
G_SETTINGS_BIND_DEFAULT);
}
@@ -36,12 +28,10 @@ static void
example_app_window_dispose (GObject *object)
{
ExampleAppWindow *win;
ExampleAppWindowPrivate *priv;
win = EXAMPLE_APP_WINDOW (object);
priv = example_app_window_get_instance_private (win);
g_clear_object (&priv->settings);
g_clear_object (&win->settings);
G_OBJECT_CLASS (example_app_window_parent_class)->dispose (object);
}
@@ -53,7 +43,7 @@ example_app_window_class_init (ExampleAppWindowClass *class)
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/exampleapp/window.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
}
ExampleAppWindow *
@@ -66,7 +56,6 @@ void
example_app_window_open (ExampleAppWindow *win,
GFile *file)
{
ExampleAppWindowPrivate *priv;
gchar *basename;
GtkWidget *scrolled, *view;
gchar *contents;
@@ -75,19 +64,16 @@ example_app_window_open (ExampleAppWindow *win,
GtkTextTag *tag;
GtkTextIter start_iter, end_iter;
priv = example_app_window_get_instance_private (win);
basename = g_file_get_basename (file);
scrolled = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scrolled);
gtk_widget_set_hexpand (scrolled, TRUE);
gtk_widget_set_vexpand (scrolled, TRUE);
view = gtk_text_view_new ();
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
gtk_widget_show (view);
gtk_container_add (GTK_CONTAINER (scrolled), view);
gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename);
gtk_stack_add_titled (GTK_STACK (win->stack), scrolled, basename, basename);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
@@ -98,7 +84,7 @@ example_app_window_open (ExampleAppWindow *win,
}
tag = gtk_text_buffer_create_tag (buffer, NULL, NULL);
g_settings_bind (priv->settings, "font", tag, "font", G_SETTINGS_BIND_DEFAULT);
g_settings_bind (win->settings, "font", tag, "font", G_SETTINGS_BIND_DEFAULT);
gtk_text_buffer_get_start_iter (buffer, &start_iter);
gtk_text_buffer_get_end_iter (buffer, &end_iter);

View File

@@ -7,14 +7,11 @@
<property name="default-height">400</property>
<child>
<object class="GtkBox" id="content_box">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkHeaderBar" id="header">
<property name="visible">True</property>
<child type="title">
<object class="GtkStackSwitcher" id="tabs">
<property name="visible">True</property>
<property name="stack">stack</property>
</object>
</child>
@@ -22,7 +19,6 @@
</child>
<child>
<object class="GtkStack" id="stack">
<property name="visible">True</property>
</object>
</child>
</object>

View File

@@ -1,7 +1,7 @@
CC ?= gcc
PKGCONFIG = $(shell which pkg-config)
CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-3.0)
LIBS = $(shell $(PKGCONFIG) --libs gtk+-3.0)
CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-4.0)
LIBS = $(shell $(PKGCONFIG) --libs gtk+-4.0)
GLIB_COMPILE_RESOURCES = $(shell $(PKGCONFIG) --variable=glib_compile_resources gio-2.0)
GLIB_COMPILE_SCHEMAS = $(shell $(PKGCONFIG) --variable=glib_compile_schemas gio-2.0)

View File

@@ -7,43 +7,36 @@
struct _ExampleAppPrefs
{
GtkDialog parent;
};
typedef struct _ExampleAppPrefsPrivate ExampleAppPrefsPrivate;
struct _ExampleAppPrefsPrivate
{
GSettings *settings;
GtkWidget *font;
GtkWidget *transition;
};
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
G_DEFINE_TYPE (ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
static void
example_app_prefs_init (ExampleAppPrefs *prefs)
{
ExampleAppPrefsPrivate *priv;
priv = example_app_prefs_get_instance_private (prefs);
gtk_widget_init_template (GTK_WIDGET (prefs));
priv->settings = g_settings_new ("org.gtk.exampleapp");
prefs->settings = g_settings_new ("org.gtk.exampleapp");
g_settings_bind (priv->settings, "font",
priv->font, "font",
g_settings_bind (prefs->settings, "font",
prefs->font, "font",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (priv->settings, "transition",
priv->transition, "active-id",
g_settings_bind (prefs->settings, "transition",
prefs->transition, "active-id",
G_SETTINGS_BIND_DEFAULT);
}
static void
example_app_prefs_dispose (GObject *object)
{
ExampleAppPrefsPrivate *priv;
ExampleAppPrefs *prefs;
priv = example_app_prefs_get_instance_private (EXAMPLE_APP_PREFS (object));
g_clear_object (&priv->settings);
prefs = EXAMPLE_APP_PREFS (object);
g_clear_object (&prefs->settings);
G_OBJECT_CLASS (example_app_prefs_parent_class)->dispose (object);
}
@@ -55,8 +48,8 @@ example_app_prefs_class_init (ExampleAppPrefsClass *class)
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/exampleapp/prefs.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
}
ExampleAppPrefs *

View File

@@ -6,29 +6,21 @@
struct _ExampleAppWindow
{
GtkApplicationWindow parent;
};
typedef struct ExampleAppWindowPrivate ExampleAppWindowPrivate;
struct ExampleAppWindowPrivate
{
GSettings *settings;
GtkWidget *stack;
};
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
G_DEFINE_TYPE (ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW)
static void
example_app_window_init (ExampleAppWindow *win)
{
ExampleAppWindowPrivate *priv;
priv = example_app_window_get_instance_private (win);
gtk_widget_init_template (GTK_WIDGET (win));
priv->settings = g_settings_new ("org.gtk.exampleapp");
win->settings = g_settings_new ("org.gtk.exampleapp");
g_settings_bind (priv->settings, "transition",
priv->stack, "transition-type",
g_settings_bind (win->settings, "transition",
win->stack, "transition-type",
G_SETTINGS_BIND_DEFAULT);
}
@@ -36,12 +28,10 @@ static void
example_app_window_dispose (GObject *object)
{
ExampleAppWindow *win;
ExampleAppWindowPrivate *priv;
win = EXAMPLE_APP_WINDOW (object);
priv = example_app_window_get_instance_private (win);
g_clear_object (&priv->settings);
g_clear_object (&win->settings);
G_OBJECT_CLASS (example_app_window_parent_class)->dispose (object);
}
@@ -53,7 +43,7 @@ example_app_window_class_init (ExampleAppWindowClass *class)
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/exampleapp/window.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
}
ExampleAppWindow *
@@ -66,7 +56,6 @@ void
example_app_window_open (ExampleAppWindow *win,
GFile *file)
{
ExampleAppWindowPrivate *priv;
gchar *basename;
GtkWidget *scrolled, *view;
gchar *contents;
@@ -75,19 +64,16 @@ example_app_window_open (ExampleAppWindow *win,
GtkTextTag *tag;
GtkTextIter start_iter, end_iter;
priv = example_app_window_get_instance_private (win);
basename = g_file_get_basename (file);
scrolled = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scrolled);
gtk_widget_set_hexpand (scrolled, TRUE);
gtk_widget_set_vexpand (scrolled, TRUE);
view = gtk_text_view_new ();
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
gtk_widget_show (view);
gtk_container_add (GTK_CONTAINER (scrolled), view);
gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename);
gtk_stack_add_titled (GTK_STACK (win->stack), scrolled, basename, basename);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
@@ -98,7 +84,7 @@ example_app_window_open (ExampleAppWindow *win,
}
tag = gtk_text_buffer_create_tag (buffer, NULL, NULL);
g_settings_bind (priv->settings, "font", tag, "font", G_SETTINGS_BIND_DEFAULT);
g_settings_bind (win->settings, "font", tag, "font", G_SETTINGS_BIND_DEFAULT);
gtk_text_buffer_get_start_iter (buffer, &start_iter);
gtk_text_buffer_get_end_iter (buffer, &end_iter);

View File

@@ -9,15 +9,13 @@
<object class="GtkBox" id="vbox">
<child>
<object class="GtkGrid" id="grid">
<property name="visible">True</property>
<property name="margin">6</property>
<property name="row-spacing">12</property>
<property name="column-spacing">6</property>
<child>
<object class="GtkLabel" id="fontlabel">
<property name="visible">True</property>
<property name="label">_Font:</property>
<property name="use-underline">True</property>
<property name="use-underline">1</property>
<property name="mnemonic-widget">font</property>
<property name="xalign">1</property>
</object>
@@ -28,7 +26,6 @@
</child>
<child>
<object class="GtkFontButton" id="font">
<property name="visible">True</property>
</object>
<packing>
<property name="left-attach">1</property>
@@ -37,9 +34,8 @@
</child>
<child>
<object class="GtkLabel" id="transitionlabel">
<property name="visible">True</property>
<property name="label">_Transition:</property>
<property name="use-underline">True</property>
<property name="use-underline">1</property>
<property name="mnemonic-widget">transition</property>
<property name="xalign">1</property>
</object>
@@ -50,7 +46,6 @@
</child>
<child>
<object class="GtkComboBoxText" id="transition">
<property name="visible">True</property>
<items>
<item translatable="yes" id="none">None</item>
<item translatable="yes" id="crossfade">Fade</item>

View File

@@ -7,14 +7,11 @@
<property name="default-height">400</property>
<child>
<object class="GtkBox" id="content_box">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkHeaderBar" id="header">
<property name="visible">True</property>
<child type="title">
<object class="GtkStackSwitcher" id="tabs">
<property name="visible">True</property>
<property name="stack">stack</property>
</object>
</child>
@@ -22,7 +19,6 @@
</child>
<child>
<object class="GtkStack" id="stack">
<property name="visible">True</property>
</object>
</child>
</object>

View File

@@ -1,7 +1,7 @@
CC ?= gcc
PKGCONFIG = $(shell which pkg-config)
CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-3.0)
LIBS = $(shell $(PKGCONFIG) --libs gtk+-3.0)
CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-4.0)
LIBS = $(shell $(PKGCONFIG) --libs gtk+-4.0)
GLIB_COMPILE_RESOURCES = $(shell $(PKGCONFIG) --variable=glib_compile_resources gio-2.0)
GLIB_COMPILE_SCHEMAS = $(shell $(PKGCONFIG) --variable=glib_compile_schemas gio-2.0)

View File

@@ -7,43 +7,36 @@
struct _ExampleAppPrefs
{
GtkDialog parent;
};
typedef struct _ExampleAppPrefsPrivate ExampleAppPrefsPrivate;
struct _ExampleAppPrefsPrivate
{
GSettings *settings;
GtkWidget *font;
GtkWidget *transition;
};
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
G_DEFINE_TYPE (ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
static void
example_app_prefs_init (ExampleAppPrefs *prefs)
{
ExampleAppPrefsPrivate *priv;
priv = example_app_prefs_get_instance_private (prefs);
gtk_widget_init_template (GTK_WIDGET (prefs));
priv->settings = g_settings_new ("org.gtk.exampleapp");
prefs->settings = g_settings_new ("org.gtk.exampleapp");
g_settings_bind (priv->settings, "font",
priv->font, "font",
g_settings_bind (prefs->settings, "font",
prefs->font, "font",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (priv->settings, "transition",
priv->transition, "active-id",
g_settings_bind (prefs->settings, "transition",
prefs->transition, "active-id",
G_SETTINGS_BIND_DEFAULT);
}
static void
example_app_prefs_dispose (GObject *object)
{
ExampleAppPrefsPrivate *priv;
ExampleAppPrefs *prefs;
priv = example_app_prefs_get_instance_private (EXAMPLE_APP_PREFS (object));
g_clear_object (&priv->settings);
prefs = EXAMPLE_APP_PREFS (object);
g_clear_object (&prefs->settings);
G_OBJECT_CLASS (example_app_prefs_parent_class)->dispose (object);
}
@@ -55,8 +48,8 @@ example_app_prefs_class_init (ExampleAppPrefsClass *class)
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/exampleapp/prefs.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
}
ExampleAppPrefs *

View File

@@ -6,25 +6,19 @@
struct _ExampleAppWindow
{
GtkApplicationWindow parent;
};
typedef struct _ExampleAppWindowPrivate ExampleAppWindowPrivate;
struct _ExampleAppWindowPrivate
{
GSettings *settings;
GtkWidget *stack;
GtkWidget *search;
GtkWidget *searchbar;
};
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
G_DEFINE_TYPE (ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW)
static void
search_text_changed (GtkEntry *entry)
search_text_changed (GtkEntry *entry,
ExampleAppWindow *win)
{
ExampleAppWindow *win;
ExampleAppWindowPrivate *priv;
const gchar *text;
GtkWidget *tab;
GtkWidget *view;
@@ -36,10 +30,7 @@ search_text_changed (GtkEntry *entry)
if (text[0] == '\0')
return;
win = EXAMPLE_APP_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (entry)));
priv = example_app_window_get_instance_private (win);
tab = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
tab = gtk_stack_get_visible_child (GTK_STACK (win->stack));
view = gtk_bin_get_child (GTK_BIN (tab));
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
@@ -55,36 +46,28 @@ search_text_changed (GtkEntry *entry)
}
static void
visible_child_changed (GObject *stack,
GParamSpec *pspec)
visible_child_changed (GObject *stack,
GParamSpec *pspec,
ExampleAppWindow *win)
{
ExampleAppWindow *win;
ExampleAppWindowPrivate *priv;
if (gtk_widget_in_destruction (GTK_WIDGET (stack)))
return;
win = EXAMPLE_APP_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (stack)));
priv = example_app_window_get_instance_private (win);
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (priv->searchbar), FALSE);
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (win->searchbar), FALSE);
}
static void
example_app_window_init (ExampleAppWindow *win)
{
ExampleAppWindowPrivate *priv;
priv = example_app_window_get_instance_private (win);
gtk_widget_init_template (GTK_WIDGET (win));
priv->settings = g_settings_new ("org.gtk.exampleapp");
win->settings = g_settings_new ("org.gtk.exampleapp");
g_settings_bind (priv->settings, "transition",
priv->stack, "transition-type",
g_settings_bind (win->settings, "transition",
win->stack, "transition-type",
G_SETTINGS_BIND_DEFAULT);
g_object_bind_property (priv->search, "active",
priv->searchbar, "search-mode-enabled",
g_object_bind_property (win->search, "active",
win->searchbar, "search-mode-enabled",
G_BINDING_BIDIRECTIONAL);
}
@@ -92,12 +75,10 @@ static void
example_app_window_dispose (GObject *object)
{
ExampleAppWindow *win;
ExampleAppWindowPrivate *priv;
win = EXAMPLE_APP_WINDOW (object);
priv = example_app_window_get_instance_private (win);
g_clear_object (&priv->settings);
g_clear_object (&win->settings);
G_OBJECT_CLASS (example_app_window_parent_class)->dispose (object);
}
@@ -110,9 +91,9 @@ example_app_window_class_init (ExampleAppWindowClass *class)
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/exampleapp/window.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, search);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchbar);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, search);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchbar);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), search_text_changed);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), visible_child_changed);
@@ -128,7 +109,6 @@ void
example_app_window_open (ExampleAppWindow *win,
GFile *file)
{
ExampleAppWindowPrivate *priv;
gchar *basename;
GtkWidget *scrolled, *view;
gchar *contents;
@@ -137,19 +117,16 @@ example_app_window_open (ExampleAppWindow *win,
GtkTextTag *tag;
GtkTextIter start_iter, end_iter;
priv = example_app_window_get_instance_private (win);
basename = g_file_get_basename (file);
scrolled = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scrolled);
gtk_widget_set_hexpand (scrolled, TRUE);
gtk_widget_set_vexpand (scrolled, TRUE);
view = gtk_text_view_new ();
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
gtk_widget_show (view);
gtk_container_add (GTK_CONTAINER (scrolled), view);
gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename);
gtk_stack_add_titled (GTK_STACK (win->stack), scrolled, basename, basename);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
@@ -160,7 +137,7 @@ example_app_window_open (ExampleAppWindow *win,
}
tag = gtk_text_buffer_create_tag (buffer, NULL, NULL);
g_settings_bind (priv->settings, "font",
g_settings_bind (win->settings, "font",
tag, "font",
G_SETTINGS_BIND_DEFAULT);
@@ -170,5 +147,5 @@ example_app_window_open (ExampleAppWindow *win,
g_free (basename);
gtk_widget_set_sensitive (priv->search, TRUE);
gtk_widget_set_sensitive (win->search, TRUE);
}

View File

@@ -9,15 +9,13 @@
<object class="GtkBox" id="vbox">
<child>
<object class="GtkGrid" id="grid">
<property name="visible">True</property>
<property name="margin">6</property>
<property name="row-spacing">12</property>
<property name="column-spacing">6</property>
<child>
<object class="GtkLabel" id="fontlabel">
<property name="visible">True</property>
<property name="label">_Font:</property>
<property name="use-underline">True</property>
<property name="use-underline">1</property>
<property name="mnemonic-widget">font</property>
<property name="xalign">1</property>
</object>
@@ -28,7 +26,6 @@
</child>
<child>
<object class="GtkFontButton" id="font">
<property name="visible">True</property>
</object>
<packing>
<property name="left-attach">1</property>
@@ -37,9 +34,8 @@
</child>
<child>
<object class="GtkLabel" id="transitionlabel">
<property name="visible">True</property>
<property name="label">_Transition:</property>
<property name="use-underline">True</property>
<property name="use-underline">1</property>
<property name="mnemonic-widget">transition</property>
<property name="xalign">1</property>
</object>
@@ -50,7 +46,6 @@
</child>
<child>
<object class="GtkComboBoxText" id="transition">
<property name="visible">True</property>
<items>
<item translatable="yes" id="none">None</item>
<item translatable="yes" id="crossfade">Fade</item>

View File

@@ -7,30 +7,18 @@
<property name="default-height">400</property>
<child>
<object class="GtkBox" id="content_box">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkHeaderBar" id="header">
<property name="visible">True</property>
<child type="title">
<object class="GtkStackSwitcher" id="tabs">
<property name="visible">True</property>
<property name="stack">stack</property>
</object>
</child>
<child>
<object class="GtkToggleButton" id="search">
<property name="visible">True</property>
<property name="sensitive">False</property>
<style>
<class name="image-button"/>
</style>
<child>
<object class="GtkImage" id="search-icon">
<property name="visible">True</property>
<property name="icon-name">edit-find-symbolic</property>
</object>
</child>
<property name="sensitive">0</property>
<property name="icon-name">edit-find-symbolic</property>
</object>
<packing>
<property name="pack-type">end</property>
@@ -40,11 +28,9 @@
</child>
<child>
<object class="GtkSearchBar" id="searchbar">
<property name="visible">True</property>
<child>
<object class="GtkSearchEntry" id="searchentry">
<signal name="search-changed" handler="search_text_changed"/>
<property name="visible">True</property>
</object>
</child>
</object>
@@ -52,7 +38,6 @@
<child>
<object class="GtkStack" id="stack">
<signal name="notify::visible-child" handler="visible_child_changed"/>
<property name="visible">True</property>
</object>
</child>
</object>

View File

@@ -1,7 +1,7 @@
CC ?= gcc
PKGCONFIG = $(shell which pkg-config)
CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-3.0)
LIBS = $(shell $(PKGCONFIG) --libs gtk+-3.0)
CFLAGS = $(shell $(PKGCONFIG) --cflags gtk+-4.0)
LIBS = $(shell $(PKGCONFIG) --libs gtk+-4.0)
GLIB_COMPILE_RESOURCES = $(shell $(PKGCONFIG) --variable=glib_compile_resources gio-2.0)
GLIB_COMPILE_SCHEMAS = $(shell $(PKGCONFIG) --variable=glib_compile_schemas gio-2.0)

View File

@@ -7,43 +7,36 @@
struct _ExampleAppPrefs
{
GtkDialog parent;
};
typedef struct _ExampleAppPrefsPrivate ExampleAppPrefsPrivate;
struct _ExampleAppPrefsPrivate
{
GSettings *settings;
GtkWidget *font;
GtkWidget *transition;
};
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
G_DEFINE_TYPE (ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
static void
example_app_prefs_init (ExampleAppPrefs *prefs)
{
ExampleAppPrefsPrivate *priv;
priv = example_app_prefs_get_instance_private (prefs);
gtk_widget_init_template (GTK_WIDGET (prefs));
priv->settings = g_settings_new ("org.gtk.exampleapp");
prefs->settings = g_settings_new ("org.gtk.exampleapp");
g_settings_bind (priv->settings, "font",
priv->font, "font",
g_settings_bind (prefs->settings, "font",
prefs->font, "font",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (priv->settings, "transition",
priv->transition, "active-id",
g_settings_bind (prefs->settings, "transition",
prefs->transition, "active-id",
G_SETTINGS_BIND_DEFAULT);
}
static void
example_app_prefs_dispose (GObject *object)
{
ExampleAppPrefsPrivate *priv;
ExampleAppPrefs *prefs;
priv = example_app_prefs_get_instance_private (EXAMPLE_APP_PREFS (object));
g_clear_object (&priv->settings);
prefs = EXAMPLE_APP_PREFS (object);
g_clear_object (&prefs->settings);
G_OBJECT_CLASS (example_app_prefs_parent_class)->dispose (object);
}
@@ -55,8 +48,8 @@ example_app_prefs_class_init (ExampleAppPrefsClass *class)
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/exampleapp/prefs.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
}
ExampleAppPrefs *

View File

@@ -6,12 +6,7 @@
struct _ExampleAppWindow
{
GtkApplicationWindow parent;
};
typedef struct _ExampleAppWindowPrivate ExampleAppWindowPrivate;
struct _ExampleAppWindowPrivate
{
GSettings *settings;
GtkWidget *stack;
GtkWidget *search;
@@ -22,13 +17,12 @@ struct _ExampleAppWindowPrivate
GtkWidget *words;
};
G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
G_DEFINE_TYPE (ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW)
static void
search_text_changed (GtkEntry *entry)
search_text_changed (GtkEntry *entry,
ExampleAppWindow *win)
{
ExampleAppWindow *win;
ExampleAppWindowPrivate *priv;
const gchar *text;
GtkWidget *tab;
GtkWidget *view;
@@ -40,10 +34,7 @@ search_text_changed (GtkEntry *entry)
if (text[0] == '\0')
return;
win = EXAMPLE_APP_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (entry)));
priv = example_app_window_get_instance_private (win);
tab = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
tab = gtk_stack_get_visible_child (GTK_STACK (win->stack));
view = gtk_bin_get_child (GTK_BIN (tab));
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
@@ -62,19 +53,15 @@ static void
find_word (GtkButton *button,
ExampleAppWindow *win)
{
ExampleAppWindowPrivate *priv;
const gchar *word;
priv = example_app_window_get_instance_private (win);
word = gtk_button_get_label (button);
gtk_entry_set_text (GTK_ENTRY (priv->searchentry), word);
gtk_entry_set_text (GTK_ENTRY (win->searchentry), word);
}
static void
update_words (ExampleAppWindow *win)
{
ExampleAppWindowPrivate *priv;
GHashTable *strings;
GHashTableIter iter;
GtkWidget *tab, *view, *row;
@@ -83,9 +70,7 @@ update_words (ExampleAppWindow *win)
GList *children, *l;
gchar *word, *key;
priv = example_app_window_get_instance_private (win);
tab = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
tab = gtk_stack_get_visible_child (GTK_STACK (win->stack));
if (tab == NULL)
return;
@@ -113,9 +98,9 @@ update_words (ExampleAppWindow *win)
}
done:
children = gtk_container_get_children (GTK_CONTAINER (priv->words));
children = gtk_container_get_children (GTK_CONTAINER (win->words));
for (l = children; l; l = l->next)
gtk_container_remove (GTK_CONTAINER (priv->words), GTK_WIDGET (l->data));
gtk_container_remove (GTK_CONTAINER (win->words), GTK_WIDGET (l->data));
g_list_free (children);
g_hash_table_iter_init (&iter, strings);
@@ -124,27 +109,21 @@ done:
row = gtk_button_new_with_label (key);
g_signal_connect (row, "clicked",
G_CALLBACK (find_word), win);
gtk_widget_show (row);
gtk_container_add (GTK_CONTAINER (priv->words), row);
gtk_container_add (GTK_CONTAINER (win->words), row);
}
g_hash_table_unref (strings);
}
static void
visible_child_changed (GObject *stack,
GParamSpec *pspec)
visible_child_changed (GObject *stack,
GParamSpec *pspec,
ExampleAppWindow *win)
{
ExampleAppWindow *win;
ExampleAppWindowPrivate *priv;
if (gtk_widget_in_destruction (GTK_WIDGET (stack)))
return;
win = EXAMPLE_APP_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (stack)));
priv = example_app_window_get_instance_private (win);
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (priv->searchbar), FALSE);
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (win->searchbar), FALSE);
update_words (win);
}
@@ -159,36 +138,34 @@ words_changed (GObject *sidebar,
static void
example_app_window_init (ExampleAppWindow *win)
{
ExampleAppWindowPrivate *priv;
GtkBuilder *builder;
GMenuModel *menu;
GAction *action;
priv = example_app_window_get_instance_private (win);
gtk_widget_init_template (GTK_WIDGET (win));
priv->settings = g_settings_new ("org.gtk.exampleapp");
win->settings = g_settings_new ("org.gtk.exampleapp");
g_settings_bind (priv->settings, "transition",
priv->stack, "transition-type",
g_settings_bind (win->settings, "transition",
win->stack, "transition-type",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (priv->settings, "show-words",
priv->sidebar, "reveal-child",
g_settings_bind (win->settings, "show-words",
win->sidebar, "reveal-child",
G_SETTINGS_BIND_DEFAULT);
g_object_bind_property (priv->search, "active",
priv->searchbar, "search-mode-enabled",
g_object_bind_property (win->search, "active",
win->searchbar, "search-mode-enabled",
G_BINDING_BIDIRECTIONAL);
g_signal_connect (priv->sidebar, "notify::reveal-child",
g_signal_connect (win->sidebar, "notify::reveal-child",
G_CALLBACK (words_changed), win);
builder = gtk_builder_new_from_resource ("/org/gtk/exampleapp/gears-menu.ui");
menu = G_MENU_MODEL (gtk_builder_get_object (builder, "menu"));
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (priv->gears), menu);
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (win->gears), menu);
g_object_unref (builder);
action = g_settings_create_action (priv->settings, "show-words");
action = g_settings_create_action (win->settings, "show-words");
g_action_map_add_action (G_ACTION_MAP (win), action);
g_object_unref (action);
}
@@ -197,12 +174,10 @@ static void
example_app_window_dispose (GObject *object)
{
ExampleAppWindow *win;
ExampleAppWindowPrivate *priv;
win = EXAMPLE_APP_WINDOW (object);
priv = example_app_window_get_instance_private (win);
g_clear_object (&priv->settings);
g_clear_object (&win->settings);
G_OBJECT_CLASS (example_app_window_parent_class)->dispose (object);
}
@@ -215,13 +190,13 @@ example_app_window_class_init (ExampleAppWindowClass *class)
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/exampleapp/window.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, search);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchbar);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchentry);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, gears);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, words);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), ExampleAppWindow, sidebar);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, search);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchbar);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchentry);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, gears);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, words);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, sidebar);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), search_text_changed);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), visible_child_changed);
@@ -238,7 +213,6 @@ void
example_app_window_open (ExampleAppWindow *win,
GFile *file)
{
ExampleAppWindowPrivate *priv;
gchar *basename;
GtkWidget *scrolled, *view;
gchar *contents;
@@ -247,19 +221,16 @@ example_app_window_open (ExampleAppWindow *win,
GtkTextTag *tag;
GtkTextIter start_iter, end_iter;
priv = example_app_window_get_instance_private (win);
basename = g_file_get_basename (file);
scrolled = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scrolled);
gtk_widget_set_hexpand (scrolled, TRUE);
gtk_widget_set_vexpand (scrolled, TRUE);
view = gtk_text_view_new ();
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
gtk_widget_show (view);
gtk_container_add (GTK_CONTAINER (scrolled), view);
gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename);
gtk_stack_add_titled (GTK_STACK (win->stack), scrolled, basename, basename);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
@@ -270,7 +241,7 @@ example_app_window_open (ExampleAppWindow *win,
}
tag = gtk_text_buffer_create_tag (buffer, NULL, NULL);
g_settings_bind (priv->settings, "font",
g_settings_bind (win->settings, "font",
tag, "font",
G_SETTINGS_BIND_DEFAULT);
@@ -280,7 +251,7 @@ example_app_window_open (ExampleAppWindow *win,
g_free (basename);
gtk_widget_set_sensitive (priv->search, TRUE);
gtk_widget_set_sensitive (win->search, TRUE);
update_words (win);
}

View File

@@ -9,15 +9,13 @@
<object class="GtkBox" id="vbox">
<child>
<object class="GtkGrid" id="grid">
<property name="visible">True</property>
<property name="margin">6</property>
<property name="row-spacing">12</property>
<property name="column-spacing">6</property>
<child>
<object class="GtkLabel" id="fontlabel">
<property name="visible">True</property>
<property name="label">_Font:</property>
<property name="use-underline">True</property>
<property name="use-underline">1</property>
<property name="mnemonic-widget">font</property>
<property name="xalign">1</property>
</object>
@@ -28,7 +26,6 @@
</child>
<child>
<object class="GtkFontButton" id="font">
<property name="visible">True</property>
</object>
<packing>
<property name="left-attach">1</property>
@@ -37,9 +34,8 @@
</child>
<child>
<object class="GtkLabel" id="transitionlabel">
<property name="visible">True</property>
<property name="label">_Transition:</property>
<property name="use-underline">True</property>
<property name="use-underline">1</property>
<property name="mnemonic-widget">transition</property>
<property name="xalign">1</property>
</object>
@@ -50,7 +46,6 @@
</child>
<child>
<object class="GtkComboBoxText" id="transition">
<property name="visible">True</property>
<items>
<item translatable="yes" id="none">None</item>
<item translatable="yes" id="crossfade">Fade</item>

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