Compare commits

...

1799 Commits

Author SHA1 Message Date
Matthias Clasen
b1038c5d19 settings: Add a :theme-change signal
This signal allows applications to intercept and override
what theme gets loaded when the theme settings change.
One possibility is to only load themes from a fixed list
of supported themes. Another is to ignore the user preference
and only load dark themes.
2020-04-13 10:40:32 -04:00
Matthias Clasen
b16b44f1ae inspector: Use theme apis
We can now use gtk_theme_get_available_themes instead
of our own copy of that code.
2020-04-13 10:40:32 -04:00
Matthias Clasen
37c151ce0f Add some theme apis
Add apis to get the list of available themes,
as well as the dark or light variant of a theme.
2020-04-13 10:40:32 -04:00
Matthias Clasen
eb7ad4bbad Introduce a gtk-user-theme-preference setting
This setting will be interpreted as prefers dark/
prefers light/don't care. Since we don't have any
useful metadata for themes, we simply look for
the NAME/NAME-dark naming convention when identifying
light or dark theme variants.
2020-04-13 10:20:36 -04:00
Matthias Clasen
cdec487998 cssprovider: Stop supporting theme variants
We are no longer using variants, so drop the variant
argument from gtk_css_provider_load_named().
2020-04-13 10:20:36 -04:00
Matthias Clasen
80d3c68615 testsuite: Stop loading theme variants 2020-04-13 10:20:35 -04:00
Matthias Clasen
ed4b3f8033 Drop the prefer-dark setting
There is no way to win with this setting, so instead
of trying to add yet more override knobs for application
developers, do away with theme variants altogether.

As a user, just pick your favorite theme, and if it
is dark, so be it.

As an app developer, you can inspect the gtk-theme-name
property and match that against your supported themes.
If that is not good enough for you, you can volunteer
to implement a theme property API that would let themes
declare whether they are dark or light.
2020-04-13 10:20:35 -04:00
Matthias Clasen
451e7a5ad2 themes: Make Adwaita-dark a separate theme
We are moving away from theme variants.
2020-04-13 10:20:35 -04:00
Matthias Clasen
89360b26af window: Stop dealing with prefer-dark
Its 2020.  If you want maching window decorations, use CSD.
2020-04-13 10:20:35 -04:00
Matthias Clasen
d3d4fe14c2 inspector: Stop dealing with prefer-dark
This setting is going away.
2020-04-13 10:20:35 -04:00
Matthias Clasen
040175cd92 widget-factory: Stop dealing with prefer-dark
Instead, just toggle between known light/dark pairs
for the builtin themes.
2020-04-13 10:20:35 -04:00
Matthias Clasen
64b0c63190 Merge branch 'modal-buttons' into 'master'
Modal buttons

See merge request GNOME/gtk!1679
2020-04-13 11:15:14 +00:00
Matthias Clasen
8ff540eb4c appchooserbutton: Drop the Private struct 2020-04-13 01:08:52 -04:00
Matthias Clasen
9194b7388f Add a GtkAppChooserButton:modal property
Nowadays, dialogs are expected to be attached, typically,
and that only happens when they are marked as modal.
2020-04-13 00:43:19 -04:00
Matthias Clasen
6831d3e28e fontbutton: Drop the Private struct 2020-04-13 00:32:50 -04:00
Matthias Clasen
800f1c03d5 Add a GtkFontButton:modal property
Nowadays, dialogs are expected to be attached, typically,
and that only happens when they are marked as modal.
2020-04-13 00:28:34 -04:00
Matthias Clasen
7a0355fcb1 colorbutton: Drop the Private struct 2020-04-13 00:28:11 -04:00
Matthias Clasen
15d58a868a Add a GtkColorButton:modal property
Nowadays, dialogs are expected to be attached, typically,
and that only happens when they are marked as modal.
2020-04-13 00:17:00 -04:00
Matthias Clasen
61f21fc9e9 filechooserbutton: Make dialog modal by default
This is the expected behavior, so default to it.
2020-04-13 00:12:30 -04:00
Matthias Clasen
9e068d3a46 filechooserbutton: Drop the Private struct 2020-04-12 23:57:49 -04:00
Matthias Clasen
2aa136a19c Add a GtkFileChooserButton:modal property
Nowadays, dialogs are expected to be attached, typically,
and that only happens when they are marked as modal.
2020-04-12 23:45:03 -04:00
Matthias Clasen
1dfd514f7f Merge branch 'matthiasc/for-master' into 'master'
Adwaita: visible focus outline for color swatches

See merge request GNOME/gtk!1678
2020-04-13 03:42:26 +00:00
Matthias Clasen
08fbd012ec window: Make resize cursors work for modal dialogs
We were inadvertedly not letting the grab_widget determine
a cursor. This was showing up as resize cursors not appearing.
2020-04-12 22:18:50 -04:00
Matthias Clasen
638508fa20 gtk-demo: Group the OpenGL demos 2020-04-12 21:58:07 -04:00
Matthias Clasen
ce6c7bae51 gtk-demo: Add a gears demo 2020-04-12 20:52:15 -04:00
Matthias Clasen
19f7b7ed40 Adwaita: visible focus outline for color swatches
Make the focus outline for color swatches visible
again.
2020-04-12 20:13:50 -04:00
Matthias Clasen
e3dba28666 Merge branch 'arnaudb/better-substitution' into 'master'
Fix some gtk-builder-tool substitutions.

See merge request GNOME/gtk!1675
2020-04-12 22:53:54 +00:00
Matthias Clasen
88aa548965 Merge branch 'matthiasc/for-master' into 'master'
text: Fix placing the cursor on click

See merge request GNOME/gtk!1673
2020-04-12 22:07:20 +00:00
Matthias Clasen
17a9b13af2 text: Be more careful with cached layouts
If we call any functions that may call ensure_layout
themeselves, we risk having the cached layout pulled
out from underneath. Better play it safe and take a
reference.
2020-04-12 17:32:57 -04:00
Matthias Clasen
1efa781a19 window: Cosmetic cleanup
Use a convenience function to get the current event time.
2020-04-12 17:32:13 -04:00
Matthias Clasen
0a19d7ef08 textview: Fix an erroneous unref
This was left behind by accident in 0ee58e9ef4.
2020-04-12 17:32:13 -04:00
Arnaud Bonatti
926fb208ba Coding style improvements. 2020-04-12 21:21:24 +02:00
Arnaud Bonatti
e76dee07c5 Fix tests for margin-left and margin-right. 2020-04-12 19:28:33 +02:00
Arnaud Bonatti
11a43cf554 Replace also margin-left and margin-right. 2020-04-12 19:28:29 +02:00
Arnaud Bonatti
a7218da202 Fix tests for hexpand and vexpand. 2020-04-12 19:28:29 +02:00
Arnaud Bonatti
ed362fcc5b Fix --3to4 tests for margin substitution. 2020-04-12 19:28:29 +02:00
Arnaud Bonatti
17ec74da35 Fix a gtk-builder-tool substitution.
The margin-left and margin-right properties have been
removed in favor of margin-start and margin-end ones.
2020-04-12 19:28:29 +02:00
Matthias Clasen
754d6d1a04 wayland: Avoid criticals when unsetting transient parents
Must not check the display when parent is NULL.
2020-04-12 12:10:18 -04:00
Matthias Clasen
ff53d5ba11 stylecontext: Respect cursor aspect ratio everywhere
We were using the new cursor aspect ratio setting in
the snapshotting code, but not in gtk_render_insertion_cursor.

Make them both behave the same.
2020-04-12 11:44:13 -04:00
Matthias Clasen
7233a70d47 reftest: get backtraces
In the hope of making ci-only failures less of a black hole,
add a backtrace to the messsage for criticals.

This could eventually go into GLib (pass backtrace symbols along
as a log field for criticals), but for now this will do.
2020-04-12 11:44:13 -04:00
Emmanuele Bassi
12990b3520 Merge branch 'ci-error-report' into 'master'
ci: Count 'ERROR' codes as failures

See merge request GNOME/gtk!1674
2020-04-12 13:58:55 +00:00
Emmanuele Bassi
95d807ab61 ci: Count 'ERROR' codes as failures
Otherwise they'll be dropped from our reports.
2020-04-12 14:28:59 +01:00
Matthias Clasen
8a1a96a47e text: Fix placing the cursor on click
Commit c297d45b8a accidentally removed the
check for the right modifier mask, causing us to
always extend the selection.
2020-04-12 09:19:12 -04:00
sicklylife
c31916081f Update Japanese translation 2020-04-12 08:53:45 +00:00
Piotr Drąg
0a1e19f4e3 Update POTFILES.in 2020-04-12 10:45:54 +02:00
Matthias Clasen
7d3f3b7ab8 Merge branch 'show-uri-async' into 'master'
Redo gtk_show_uri_on_window

See merge request GNOME/gtk!1671
2020-04-12 02:27:38 +00:00
Matthias Clasen
432b741ab7 gtk: Port all users to the new gtk_show_uri()
We were only handling the error in one place anyway.
2020-04-11 22:10:08 -04:00
Matthias Clasen
703f18ce66 Redo gtk_show_uri_on_window
Make this a full async function, and add a simple wrapper.

Call gtk_show_uri_full() if you need control over the
results, and use gtk_show_uri() if you are fine with
ignoring any errors.
2020-04-11 21:56:32 -04:00
Matthias Clasen
4da82bde7b Merge branch 'current-event-apis' into 'master'
Current event apis

See merge request GNOME/gtk!1668
2020-04-12 00:24:14 +00:00
Matthias Clasen
feee281cf8 Drop gtk_get_current_ apis
We have event controller apis to replace these.
There is one remaining use of gtk_get_current_event_time
in gtkwindow.c, so we can't drop the implementation yet.

Add a section in the migration guide for this.
2020-04-11 17:29:27 -04:00
Matthias Clasen
443fd4d63d tests: Stop using gtk_get_current_ apis
Replace these by equivalent event controller
apis where needed.
2020-04-11 17:29:27 -04:00
Matthias Clasen
4b346538e2 gtk: Port widgets away from gtk_get_current_ apis
This commit handles complicated cases where we selections.
We handle this by adding extend and modify parameters to
the ::move-cursor signals, and adjust the bindings
accordingly.
2020-04-11 17:29:27 -04:00
Matthias Clasen
0ee58e9ef4 gtk: Port widgets away from gtk_get_current_ apis
Use the event controller equivalents where needed.
This commit covers the simple cases.
2020-04-11 17:29:27 -04:00
Matthias Clasen
bd56bc9055 Add gtk_event_controller_get_current_event[_state]
For now these are private, to replace internal uses
of gtk_get_current_event[_state], but we may want to
make them public.
2020-04-11 17:29:27 -04:00
Matthias Clasen
3e7e862415 gtk: Just use current time for showing urls
We don't really have an event anywhere close in most
cases, and we already pass GDK_CURRENT_TIME in half
the cases anyway.

If we want to be serious about this, we need to pass
the event itself, since future focus-stealing protocols
may not rely on just a timestamp.
2020-04-11 17:29:27 -04:00
Matthias Clasen
4eeb413047 entrycompletion: Remove an unused field
No point in storing a device that is never used.
2020-04-11 17:29:27 -04:00
Matthias Clasen
661f3466c2 Merge branch 'matthiasc/for-master' into 'master'
broadway: Fix the build

See merge request GNOME/gtk!1670
2020-04-11 21:16:11 +00:00
Matthias Clasen
e735554ced broadway: Fix the build
We need to depend on gdkenum_h, since we are (indirectly)
including gdkenumtypes.h in the broadway server build.
2020-04-11 16:24:05 -04:00
Matthias Clasen
520ea7c39d Merge branch 'jjardon/more_licenses' into 'master'
gtk/gtkaboutdialog: Add some more very common licenses:

See merge request GNOME/gtk!1667
2020-04-11 16:47:32 +00:00
Javier Jardón
ffa345e4ab gtk/gtkaboutdialog: Add some more very common licenses:
- BSD 3-Clause "New" or "Revised" license
- Apache License 2.0
- Mozilla Public License 2.0
2020-04-11 16:49:09 +01:00
Emmanuele Bassi
e072d9b28b Merge branch 'gsk-public-symbols' into 'master'
Install all headers with public symbols

Closes #2607

See merge request GNOME/gtk!1666
2020-04-11 15:21:11 +00:00
Matthias Clasen
9f5b04e65c Merge branch 'action-docs' into 'master'
Action docs

See merge request GNOME/gtk!1665
2020-04-11 15:12:22 +00:00
Emmanuele Bassi
d08310096c Conditionally include the GSK broadway and vulkan symbols
In case GTK is built without these features.
2020-04-11 15:42:51 +01:00
Emmanuele Bassi
20d0d6fae2 Revert "Do not install GSK headers for missing backends"
This reverts commit cd5cded430.

The headers are public, but the symbols availability is conditional on
the GTK build.
2020-04-11 15:41:47 +01:00
Matthias Clasen
6b9ac1043b Document actions 2020-04-11 10:07:31 -04:00
Matthias Clasen
c5b4066714 gdk: Small documentation fixes 2020-04-11 10:07:31 -04:00
Matthias Clasen
b09b2dd2cd testsuite: Make actions test order-independent
We only want to check that the actions are what we
expect, not that they are registered in a particular
order.
2020-04-11 10:07:31 -04:00
Matthias Clasen
72a0828101 Merge branch 'respect-window-cursors' into 'master'
window: Respect widget cursors

See merge request GNOME/gtk!1663
2020-04-10 18:56:44 +00:00
Matthias Clasen
7379c34a39 window: Respect widget cursors
gtk_widget_set_cursor can be used on a GtkWindow; we
should not blow away the result when temporarily installing
resize cursors.
2020-04-10 14:36:55 -04:00
Matthias Clasen
6cd1b9955b Merge branch 'remove-style-reset' into 'master'
Remove gtk_style_context_reset_widgets

See merge request GNOME/gtk!1662
2020-04-10 17:36:03 +00:00
Matthias Clasen
a6a31827bc Remove gtk_style_context_reset_widgets
This should never be necessary to call from the outside.
Whenever we fail to update styles properly, it is a bug.
2020-04-10 12:45:28 -04:00
Matthias Clasen
84939a612c Merge branch 'reduce-style-context-use' into 'master'
Use gtk_widget_add/remove_css_class more

See merge request GNOME/gtk!1661
2020-04-10 16:43:05 +00:00
Matthias Clasen
394ea32e93 Use gtk_widget_add/remove_css_class more
Replace most uses of gtk_style_context_add/remove_class
by the new APIs. The only remaining uses of the old API
are in save/restore situations.
2020-04-10 12:09:57 -04:00
Matthias Clasen
2bd36d490b Merge branch 'fix-accel-length' into 'master'
accelgroup: Fix an invalid write

Closes #2602

See merge request GNOME/gtk!1660
2020-04-10 13:27:07 +00:00
Matthias Clasen
ad1bc75dd2 accelgroup: Fix an invalid write
This was lost by accident in d110fddbce.

Fixes: #2602
2020-04-10 08:24:03 -04:00
Piotr Drąg
7505c1fd7c Update POTFILES.in and POTFILES.skip 2020-04-10 13:56:58 +02:00
Matthias Clasen
8780906b93 Merge branch 'fix-radiobuttons' into 'master'
radiobutton: Fix selection on focus-in

Closes #2326

See merge request GNOME/gtk!1658
2020-04-10 04:17:37 +00:00
Matthias Clasen
0ed2e970be Merge branch 'popover-initial-focus' into 'master'
Popover initial focus

See merge request GNOME/gtk!1657
2020-04-10 04:17:15 +00:00
Matthias Clasen
58253d567f radiobutton: Fix selection on focus-in
We need to unselect the previously selected button
to preserve radioness.

Fixes: #2326
2020-04-09 22:38:30 -04:00
Matthias Clasen
c09c61769c modelbutton: Catch focus-in more carefully
We need to unset the propagation limit on the focus
controller, else we miss the focus-in when the focus
enters the popover upon initial popup, when it comes
from the parent button.
2020-04-09 22:22:28 -04:00
Matthias Clasen
9b5dc35650 popovermenu: Remove debug spew 2020-04-09 21:41:02 -04:00
Matthias Clasen
3c9ada14fe Merge branch 'label-double-focus' into 'master'
Avoid double focus in labels

Closes #135

See merge request GNOME/gtk!1656
2020-04-10 01:34:49 +00:00
Matthias Clasen
6b4d6c3771 Merge branch 'scale-button-double-focus' into 'master'
scalebutton: Don't derive from GtkButton

See merge request GNOME/gtk!1655
2020-04-10 01:21:25 +00:00
Matthias Clasen
b15f16e8db Adwaita: Don't render focus around labels with links
This avoids the 'double outline' problem for labels
with links.

Fixes: #135
2020-04-09 21:19:36 -04:00
Matthias Clasen
e3b9dfef1c label: Improve link styling
Add a .link style class on labels that contain links,
so we can avoid the focus outline around the label
when individual links are focused, and use the link
node when rendering the focus on links.
2020-04-09 21:19:22 -04:00
Matthias Clasen
822c2aba36 scalebutton: Don't derive from GtkButton
Make GtkScaleButton a widget that has a toggle button
as a child, just like all the other button widgets now.
The immediate benefit of this arrangement is to avoid
the "double focus" problem when we pop up the popup.

Update accessible, demos and tests to match.
2020-04-09 20:43:45 -04:00
Matthias Clasen
a11f9fea76 Merge branch 'wip/matthiasc/can-focus' into 'master'
Implement new focus behavior

See merge request GNOME/gtk!1652
2020-04-10 00:26:53 +00:00
Matthias Clasen
f16c829190 Mention focus changes in the migration guide 2020-04-09 18:26:31 -04:00
Matthias Clasen
16c820c2f0 Small documentation tweaks
Update the docs for GtkWidget:can-focus and :focus-on-click.
2020-04-09 18:26:31 -04:00
Matthias Clasen
72ae6daa1e Move focus to the parent if a popover is dismissed
This is better than just dropping focus altogether,
and is expected behavior in most cases.
2020-04-09 18:26:31 -04:00
Matthias Clasen
35ba24d2e8 Update a11y test results 2020-04-09 18:26:10 -04:00
Matthias Clasen
508cb6160c a11y: Fix focusable state
The :can-focus property is no longer very useful to
give an indication of what is focusable, since it is
TRUE for almost all widgets now. Patch things up
to by looking at known widget types.
2020-04-09 18:14:15 -04:00
Matthias Clasen
b9a76ddd75 Fix the tools tests to not set can-focus 2020-04-09 17:50:29 -04:00
Matthias Clasen
038190c5a8 Disable focus-chain test that depends on the environment
The color editor shows a color picker button only if it
finds a suitable implementation, which it does not in ci.
So disable the focus-chain test for page 3.
2020-04-09 17:50:29 -04:00
Matthias Clasen
2ae08e632c color editor: Make the sample non-focusable again
This is one of the situations, where can-focus can still
be used to tweak focus behavior of leaf widgets. Color
swatches are focusable by default to allow selecting colors
with the keyboard. But when used as color samples, they
should not take focus.
2020-04-09 17:50:29 -04:00
Matthias Clasen
99eed078bd Remove focusable-container tests
Like the previous commit, these tests were relying
on setting :can-focus to make an unsuspecting container
focusable, which does not work anymore.
2020-04-09 17:50:29 -04:00
Matthias Clasen
6720552afd Remove the focus test
This test was expecting to make existing widgets like
GtkBox focusable by setting :can-focus. That just doesn't
work anymore.

The focus chain testing that is done here is already
better covered by test-focus-chain, so lets just remove this.
2020-04-09 17:50:29 -04:00
Matthias Clasen
6f01508aa8 Fix up focus chain result
The notebook grab_focus change in the previous commit made
backwards tabbing work as expected, and thereby changed the
output of one of the focus-chain tests.
2020-04-09 17:50:29 -04:00
Matthias Clasen
632524f679 Reinstate expected focus behavior
After the :can-focus change in the previous commit, widgets
need to set suitable focus and grab_focus implementations
to implement the desired focus behavior.

This commit does that for all widgets.
2020-04-09 17:50:29 -04:00
Matthias Clasen
22e1827f84 Change the default value of GtkWidget:can-focus
Make widgets can-focus by default, and change the semantics
of can-focus to be recursive . If it is set to FALSE, focus
can not enter the widget or its descendents at all anymore.

This commit temporarily breaks focus behavior of widgets
that did not expect to receive focus.
2020-04-09 17:50:29 -04:00
Matthias Clasen
3c39613d9c widget: Add common focus vfunc implementations
Privately export a number of implementations for the focus
and grab_focus vfuncs that cover many common cases.
2020-04-09 17:50:29 -04:00
Matthias Clasen
46ff9f891a gizmo: Allow passing changing focus behavior
We need this in popovers. Maybe it could be done better
by defining one-off custom widgets.
2020-04-09 17:50:29 -04:00
Matthias Clasen
97ff1b83dc widget: Make the :has-focus property readonly
The only place where this should be set is when making
a widget the focus-widget of a window. We still keep
the property around in readonly form, since there are
a few places where we rely on property notification
for it.
2020-04-09 17:50:29 -04:00
Matthias Clasen
9416856420 testsuite: Stop setting :has-focus
This is not necessary, whenever we want to set the initial
focus in a ui file, we can set GtkWindow:focus-widget.
2020-04-09 17:50:29 -04:00
Matthias Clasen
c1459cc45b widget: Drop the :is-focus property
This property doesn't carry any new information compared
to GtkWindow:focus-widget. We still keep the gtk_widget_is_focus
getter, as a convenient shortcut.
2020-04-09 17:50:29 -04:00
Matthias Clasen
4fe8c037c7 reftests: Stop using can-focus 2020-04-09 17:50:29 -04:00
Matthias Clasen
b1afe5ff23 a11y tests: Stop using can-focus 2020-04-09 17:50:29 -04:00
Matthias Clasen
bbd4fb8798 testsuite: Stop using can-focus 2020-04-09 17:50:29 -04:00
Matthias Clasen
b3b29e37fd inspector: Drop more uses of can-focus 2020-04-09 17:50:29 -04:00
Matthias Clasen
f996ba6585 inspector: Remove can-focus from ui files 2020-04-09 17:50:29 -04:00
Matthias Clasen
7ca36cd2d4 Stop setting can-focus in ui files
None of these settings are necessary.
2020-04-09 17:50:29 -04:00
Matthias Clasen
2a18f2150d window: Make set_focus equal to grab_focus
Make gtk_window_set_focus call gtk_widget_grab_focus internally.
This means that set_focus can now end up putting the focus on
a child of the passed-in widget, and makes the focus-widget
property work for setting initial focus to (the child of) an
entry in a ui file.
2020-04-09 17:50:28 -04:00
Matthias Clasen
a65fd81106 root: Reorganize focus handling
Make :focus-widget a GtkWindow property and add vfuncs
to the GtkRoot interface instead of the property.
2020-04-09 17:50:28 -04:00
Matthias Clasen
ff8217db40 Add more focus chain tests
Test page 2 and 3 of widget-factory as well, and try other directions.
2020-04-09 17:50:28 -04:00
Matthias Clasen
a3861bf9a0 Fix running focus-chain tests in ci
The widget-factory ui files require geettings
(for the color chooser), so set GSETTINGS_SCHEMA_DIR.
2020-04-09 17:50:28 -04:00
Matthias Clasen
b86c1446a4 notbook: Fix a bug in focus handling
After the header widget was introduced, focus would get
stuck in a loop between actions and tabs.

This could be seen in the notebook on page 3 of
widget-factory.
2020-04-09 17:50:28 -04:00
Matthias Clasen
9ce58bdb0c coloreditor: Draw a focus around the color plane
Not doing it was just an oversight.
2020-04-09 14:11:18 -04:00
Matthias Clasen
9f252f0ceb colorplane: Set a css name
Every widget should have one.
2020-04-09 14:10:23 -04:00
Matthias Clasen
7008a531bb Merge branch 'wip/xdg-popup-move' into 'master'
Wayland popup moving

See merge request GNOME/gtk!1017
2020-04-08 23:59:02 +00:00
Jonas Ådahl
458b8a6554 wayland: Move transient-for field to GdkWaylandToplevel
A toplevel will only ever be transient-for to another toplevel, and only
a toplevel will ever be transient-for, so move the field into the
GdkWaylandToplevel, and make it a pointer to another GdkWaylandToplevel.
2020-04-08 23:32:47 +02:00
Jonas Ådahl
307cc69adb wayland: Add surface to toplevel list only if toplevel
It was using another check (has parent) to do this, but now we have a
much more obvious way of creating surfaces, so we can use the type
directly.
2020-04-08 23:32:47 +02:00
Jonas Ådahl
ab6b5ae568 wayland: Remove own pointer to the popup parent
It's there already as the GdkSurface::parent, no need to duplicate.
2020-04-08 23:32:47 +02:00
Jonas Ådahl
0e601c0a70 wayland: Move toplevel/popup/drag surface definitions higher up
We them up there, so that code higher up compared to where they are
defined now can make use of them. Also add a few macros for type
checking and casting.
2020-04-08 23:32:47 +02:00
Jonas Ådahl
5425edff82 wayland: Move popups with xdg_popup.reposition
The third version of xdg-shell introduces support for explicit popup
repositioning. If available, make use of this to implement popup
repositioning.

Note that this does *NOT* include atomic parent-child state
synchronization. For that,
https://gitlab.freedesktop.org/wayland/wayland-protocols/issues/13 will
be needed.

This currently uses my own fork of wayland-protocols which adds meson
support, so that we can use it as a subproject. Eventually when
wayland-protocols' meson support lands upstream, we should change it to
point there.

Silence some meson warnings while at it to make CI happy.

This also bumps the glib requirement, since g_warning_once() is used.
2020-04-08 23:32:47 +02:00
Jonas Ådahl
213c471bb7 build: Change wrap revisions to use master instead of origin/master
Using origin/master crashes meson.
2020-04-08 23:32:47 +02:00
Jakub Steiner
9ae0fe7f3a Merge branch 'Gtk4_blue_focus_rings' into 'master'
Blue outlines / focus rings

See merge request GNOME/gtk!1629
2020-04-08 21:12:57 +00:00
Frederik F
abe6876f7c Blue outlines / focus rings
- introduce two new colors: $focus_border_color for focused / outlined elements and $_coloured_focus_border_color for focused / outlined elements with a colored background color, like suggested/destructive buttons or selected elements
- set outline / focus color, offset and style accordingly for all widgets
- adapt entry focus color
2020-04-08 21:12:57 +00:00
Matthias Clasen
53d74fd2dc Merge branch 'render-node-types' into 'master'
Turn GskRenderNode into a fundamental type

See merge request GNOME/gtk!1649
2020-04-08 20:55:14 +00:00
Emmanuele Bassi
3f0a830f3c Properly annotate the render node constructors
Now that the GskRenderNode subclasses are recognised as proper
sub-types, we can annotate the constructors with their type. The C API
remains the same.
2020-04-08 16:17:08 +01:00
Emmanuele Bassi
e0323fcdc2 Add get_type() functions for GskRenderNode subclasses
The introspection scanner tries to match a type name with a get_type()
function, in order to correctly identify a type as a class.

If the function is not available, we have two choices:

 - add some special case inside the introspection scanner, similar to
   how GParamSpec subclasses are handled in GObject
 - add a simple get_type() function

The latter is the simplest approach, and we don't need to change that
much, since we still register all render nodes at once.
2020-04-08 16:07:04 +01:00
Emmanuele Bassi
cd5cded430 Do not install GSK headers for missing backends
Broadway and Vulkan renderers are optional; if GTK hasn't been built
with their GSK renderers, we should not install their headers.
2020-04-08 15:41:21 +01:00
Emmanuele Bassi
54e4e6cd23 Improve the gtktypefuncs.inc generator
Remove the plug/socket exception, and add exceptions for non-X11
windowing systems.

Additionally, speed up the file generation by avoiding string
concatenation in Python.
2020-04-08 15:41:19 +01:00
Emmanuele Bassi
59852d3425 Add missing transfer annotation 2020-04-08 15:40:15 +01:00
Emmanuele Bassi
d701a89281 Turn GskRenderNode into a derivable type
Language bindings—especially ones based on introspection—cannot deal
with custom type hiearchies. Luckily for us, GType has a derivable type
with low overhead: GTypeInstance.

By turning GskRenderNode into a GTypeInstance, and creating derived
types for each class of node, we can provide an introspectable API to
our non-C API consumers, with no functional change to the C API itself.
2020-04-08 15:40:15 +01:00
Emmanuele Bassi
5e095cd208 Add macro for exported variables
The logic is based on the similar macro in GLib, but with the
appropriate GDK symbols.
2020-04-08 15:40:15 +01:00
Emmanuele Bassi
d2bdf3d5a1 Merge branch 'ci-meson-bump' into 'master'
ci: Update the version of Meson in our Docker image

See merge request GNOME/gtk!1651
2020-04-08 12:17:50 +00:00
Emmanuele Bassi
e692385baa ci: Update the version of Meson in our Docker image
Needed for !1017.
2020-04-08 12:26:58 +01:00
Matthias Clasen
1e8df851e9 Merge branch 'matthiasc/for-master' into 'master'
Remove an unused backend includes

See merge request GNOME/gtk!1648
2020-04-07 20:30:43 +00:00
Matthias Clasen
904db0a8f7 Merge branch 'imcontextsimple-drop-ifdefs' into 'master'
impcontextsimple: Drop ifdef'ed platform dependencies

See merge request GNOME/gtk!1647
2020-04-07 19:27:51 +00:00
Matthias Clasen
6b7cc8baa6 Remove an unused backend includes
These includes are just leftovers.

Every time where we do an #ifdef GDK_WINDOWING... in gtk/,
something went wrong. Don't do it needlessly.
2020-04-07 15:13:18 -04:00
Matthias Clasen
71fe843d99 impcontextsimple: Drop ifdef'ed platform dependencies
The proper way to do this would be to adapt the tables
to have the right data for the platform. Since 4.0 is
a new start in many ways, lets clean this up.
2020-04-07 14:54:04 -04:00
Matthias Clasen
552a681816 Merge branch 'private-x11-types' into 'master'
Do not parse all GDK-X11 source files

See merge request GNOME/gtk!1646
2020-04-07 18:18:55 +00:00
Emmanuele Bassi
2f0016eb08 Rename gdkx11keys.h
The header is now private, so it should follow the same naming scheme
for private GDK-X11 headers.
2020-04-07 18:12:58 +01:00
Emmanuele Bassi
f87291cac2 Hide GdkX11Keymap's GType function
It's not a public object.
2020-04-07 18:10:01 +01:00
Emmanuele Bassi
37c3ba2645 Do not parse all GDK-X11 source files
We don't need all of them, only the ones that contain public API. This
allows us to reduce the chance of a stray symbol getting incorrectly
added to the introspection data.
2020-04-07 18:06:08 +01:00
Matthias Clasen
ba05787a06 Merge branch 'attribute-docs' into 'master'
entry: Document buildable support

See merge request GNOME/gtk!1643
2020-04-07 04:15:33 +00:00
Matthias Clasen
12b97ffd24 entry: Document buildable support 2020-04-06 23:33:22 -04:00
Matthias Clasen
1ae60cb713 entry: Add <attributes> support
Make entries support the same <attributes> syntax
as labels.

Closes: #1335
2020-04-06 22:59:54 -04:00
Matthias Clasen
3371e3aa49 Move label attribute parser code
We want to reuse the parser for <attributes> in several
widgets, so move it to a shared place.
2020-04-06 22:59:45 -04:00
Matthias Clasen
baeae71d12 Merge branch 'cross-postinstall' into 'master'
meson: Don't execute post-install.py if cross compiling

See merge request GNOME/gtk!1636
2020-04-06 23:59:33 +00:00
Matthias Clasen
f8be3229b1 Merge branch 'fix-event-match' into 'master'
shortcuttrigger: Don't trigger on key releases

See merge request GNOME/gtk!1642
2020-04-06 23:44:32 +00:00
Matthias Clasen
b9cfcf07e0 Merge branch 'wip/chergert/fix-shortcut-param-order' into 'master'
widget: fix parameter ordering to match implementation

Closes #2586

See merge request GNOME/gtk!1641
2020-04-06 23:30:26 +00:00
Matthias Clasen
eb649d8204 shortcuttrigger: Don't trigger on key releases
This broke when the event type check in gdk_key_event_matches
was removed and replaced by a precondition that accepts both
key press and release events.

Add the check in gtk_keyval_trigger_trigger instead.
2020-04-06 19:16:41 -04:00
Christian Hergert
4a00f3bc9a widget: fix parameter ordering to match implementation
Fixes https://gitlab.gnome.org/GNOME/gtk/issues/2586
2020-04-06 15:44:19 -07:00
Matthias Clasen
0b17658a82 Replace most uses of <Primary> with <Control>
The only place where we are still using <Primary> is
in tests, to ensure we keep parsing it. Otherwise,
<Control> is now the preferred syntax.
2020-04-06 17:05:52 -04:00
Matthias Clasen
2486f46c0b Merge branch 'keymap-rework-2' into 'master'
Keymap rework 2

See merge request GNOME/gtk!1635
2020-04-06 20:56:06 +00:00
Matthias Clasen
c03b7e4d45 reftests: Comment out a test that fails only in ci
Fixing such only-in-ci failures is just too hard,
unfortunately.
2020-04-06 16:32:03 -04:00
Matthias Clasen
e7a8a4eb06 Update migration guide
Rewrite the sections about keymaps and menus, and add
hints about modifiers.
2020-04-06 16:32:03 -04:00
Matthias Clasen
70fbf8dbb6 accelgroup: Small documentation updates
Mention GtkShortcutTrigger, and remove references
to <Release>.
2020-04-06 16:32:03 -04:00
Matthias Clasen
93a1b3027d Reshuffle keymap docs
Since GdkKeymap api is on longer public, move relevant
documentation to the long description.
2020-04-06 16:32:03 -04:00
Matthias Clasen
1de7719e34 Drop gtk_accelerator_set_default_mod_mask
Our new approach to modifiers works with a fixed set,
there is really no need to customize the modifier
masks if the backends are all supposed to deliver
the same modifiers.
2020-04-06 16:32:03 -04:00
Matthias Clasen
f7f103a322 gdk: Remove gdk_keymap_get_modifier_mask
This function is no longer public and no longer used.
2020-04-06 16:32:03 -04:00
Matthias Clasen
14be8f6b73 Remove uses of modifier intents in gdkevents.c
This removes the use of the context menu and shift group
intents in gdkevents.c. If it turns out to be important,
we need to introduce vfuncs for gdk_event_triggers_context_menu
and gdk_event_matches.
2020-04-06 16:32:03 -04:00
Matthias Clasen
99a344f791 display: Remove gdk_display_get_modifier_mask
This is not used anymore.
2020-04-06 16:32:03 -04:00
Matthias Clasen
3419d9c04f gtk: Drop gtk_widget_get_modifier_mask
This is not used anymore.
2020-04-06 16:32:03 -04:00
Matthias Clasen
c297d45b8a gtk: Stop using modifier intents
Reviewing the existing settings, the only backend with
some differences in the modifier intent settings is OS X,
and we would rather have that implemented by interpreting
the existing modifiers in the appropriate way.

                X11      Wayland  Win32    OS X

primary         ctrl     ctrl     ctrl     mod2
mnemonic        alt      alt      alt      alt
context menu    -        -        -        ctrl
extend sel      shift    shift    shift    shift
modify sel      ctrl     ctrl     ctrl     mod2
no text         alt|ctrl alt|ctrl alt|ctrl mod2|ctrl
shift group     varies   -        -        alt

GTK now uses the following modifiers:

primary         ctrl
mnemonic        alt
extend sel      shift
modify sel      ctrl
no text         alt|ctrl

The context menu and shift group intents were not used
in GTK at all.

Update tests to no longer expect <Primary> to roundtrip
through the accelerator parsing and formatting code.
2020-04-06 16:32:03 -04:00
Matthias Clasen
dce8d251c6 keymap: Remove virtual modifier mapping functions
These are not used anymore.

Drop the vfuncs and their implementations in the
broadway, x11, wayland and win32 backends as well.
2020-04-06 16:32:03 -04:00
Matthias Clasen
89ad7893ad gdk: Make GdkKeymap a private api
We have replacement apis in GdkDevice and GdkDisplay.
2020-04-06 16:32:03 -04:00
Matthias Clasen
da6faf321c Merge branch 'misc-meson-fixes' into 'master'
Reduce useless relinking on configure and fix check for buildtype arguments

See merge request GNOME/gtk!1614
2020-04-06 20:22:01 +00:00
Justin van Steijn
c8b791a763 Update Dutch translation 2020-04-06 19:40:22 +00:00
Matthias Clasen
0eb728aa51 imcontextsimple: Disable some win32-only code
This code needs to be redone differently, since keymaps are no
longer going to be exposed. There should really not be this much
ifdef-ed backend-specific code here anyway. Or any, really.
2020-04-06 15:33:49 -04:00
Matthias Clasen
3300686bef gdk: Clean up GdkModifierType
Remove MOD2..MOD5. Backends are expected to just set
the named modifiers.
2020-04-06 15:13:54 -04:00
Matthias Clasen
0a96a483c6 gdk: Redo key events
Add all of the keyboard translation results in the key event,
so we can translate the keyboard state at the time the event
is created, and avoid doing state translation at match time.

We actually need to carry two sets of translation results,
since we ignore CapsLock when matching accelerators, in
gdk_event_matches().

At the same time, drop the scancode field - it is only ever
set on win32, and is basically unused in GTK.

Update all callers.
2020-04-06 15:13:54 -04:00
Matthias Clasen
5071367794 gtk: Remove handling of virtual modifiers
These are going away. We expect to just have
named modifiers in modifier masks now, so we
longer juggle 'real' and 'virtual' modifiers.
2020-04-06 15:13:54 -04:00
Matthias Clasen
5ce05a8fd0 events: Stop doing elaborate virtual modifier handling
These are going away in the GdkModifierType cleanup.
Just compare the modifiers we got.
2020-04-06 15:13:54 -04:00
Matthias Clasen
be2a0971c2 broadway: Stop using MOD2..MOD5
These are going away in the GdkModifierType cleanup.
2020-04-06 15:13:53 -04:00
Matthias Clasen
25e9a54902 win32: Stop using MODx modifiers
The win32 backend is using GDK_MOD2_MASK for AltGr,
so define GDK_MOD2_MASK locally to keep this working,
but remove any mention of GDK_MOD3_MASK,...,GDK_MOD5_MASK.
2020-04-06 15:13:00 -04:00
Yuri Chornoivan
df1c6b6b68 Update Ukrainian translation 2020-04-06 15:46:52 +00:00
Yuri Chornoivan
00c791fcf9 Update Ukrainian translation 2020-04-06 14:06:17 +00:00
Matthias Clasen
a5e73820da Merge branch 'fno-common' into 'master'
Add a missing extern, to fix building with -fno-common

See merge request GNOME/gtk!1631
2020-04-06 12:47:55 +00:00
Matthias Clasen
7fa103717d wayland: Stop setting MOD2..MOD5
These are going away in the GdkModifierType cleanup.
2020-04-06 01:40:49 -04:00
Matthias Clasen
f8646b9733 gdk: Remove reserved bit from GdkModifierType
This really has no purpose and obscures the header.
2020-04-06 01:40:49 -04:00
Matthias Clasen
d110fddbce gtk: Stop using GDK_MODx_MASK
These are never used in practice, and we never want to
see them in the UI, so stop supporting them. This is
in preparation for cleaning up GdkModifierType.
2020-04-06 01:40:49 -04:00
Matthias Clasen
b02db72e17 Rename GDK_MOD1_MASK to GDK_ALT_MASK
We've hardcoded Mod1 = Alt for a long time, there is
no need to keep the confusing naming around anymore.
2020-04-06 01:40:49 -04:00
Matthias Clasen
e8f30c836d tests: Stop using gtk_accelerator_set_default_mod_mask
This is not doing anything useful here.
2020-04-06 01:40:49 -04:00
Matthias Clasen
6eaadba008 testsuite: Stop using keymap apis 2020-04-06 01:40:49 -04:00
Matthias Clasen
4495bacfd1 gtk: Use display apis for keymap mapping
This removes the last uses of GdkKeymap from GTK.
2020-04-06 01:40:49 -04:00
Matthias Clasen
234a21905c gtk: Stop using keymap apis
Stop using most keymap apis in GTK. Only a few calls
related to virtual modifiers are left.
2020-04-06 01:40:49 -04:00
Matthias Clasen
13213c710f x11: Notify new device properties 2020-04-06 01:40:49 -04:00
Matthias Clasen
e165267924 wayland: Notify new device properties 2020-04-06 01:40:49 -04:00
Matthias Clasen
00b25d5594 Move keymap mapping functions to GdkDisplay
We want to stop exposing GdkKeymap, so this
functionality needs a new home.
2020-04-06 01:40:40 -04:00
Matthias Clasen
31fb5c287a Move GdkKeymapKey to gdktypes.h
We are going to use this type in a different header.
2020-04-05 23:43:41 -04:00
Matthias Clasen
416ec580dc gdk: Move modifier mask api to GdkDisplay
GdkKeymap is on the way out.
2020-04-05 23:43:41 -04:00
Matthias Clasen
ee14be8ac1 gdk: Add keymap properties to GdkDevice
GdkKeymap is on the way out.
2020-04-05 23:43:41 -04:00
Matthias Clasen
f27470aaf4 passwordentry: Show caps lock warning more
Show the caps lock warning regardless of whether we
have the peek icon or not.
2020-04-05 23:43:41 -04:00
Matthias Clasen
90eda2b17c Drop some no longer used code 2020-04-05 23:43:41 -04:00
Matthias Clasen
68d43c8e5c cell renderer accel: Use gdk_event_get_match 2020-04-05 23:43:41 -04:00
Matthias Clasen
c9aef3fc4d Add gdk_event_get_match
This is a counterpart to gdk_event_matches() that can
be used to obtain a shortcut matching an event.
2020-04-05 23:37:13 -04:00
Matthias Clasen
e8330c5eec Add gdk_event_matches
Move the elaborate key event matching code from
GtkShortcutTrigger to GdkEvent, which greatly reduces
the amount of keymap api use outside of GDK.
2020-04-05 23:37:13 -04:00
Martin Storsjö
531766fe64 meson: Don't execute post-install.py if cross compiling 2020-04-05 22:57:22 +03:00
Martin Storsjö
25a53276e0 Add a missing extern, to fix building with -fno-common
With C compilers defaulting to -fcommon, this isn't an issue, but
upcoming compilers (GCC 10 and Clang 11) will default to -fno-common,
ending up with duplicate definitions of these variables.
2020-04-05 00:43:16 +03:00
Matthias Clasen
1149502767 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1630
2020-04-04 21:09:12 +00:00
Matthias Clasen
33928a52c3 gtk-demo: Fix a crash
Using the assistant demo repeatedly was crashing.
2020-04-04 15:35:18 -04:00
Matthias Clasen
b636df7784 Merge branch 'matthiasc/for-master' into 'master'
shortcuts: documentation fixes

See merge request GNOME/gtk!1628
2020-04-04 15:33:41 -04:00
Matthias Clasen
005739371c Merge branch 'matthiasc/for-master' into 'master'
shortcuts: documentation fixes

See merge request GNOME/gtk!1628
2020-04-04 16:31:43 +00:00
Matthias Clasen
ec854fc503 shortcuts: documentation fixes
Update symbol lists, and add examples for parsing triggers
and actions.
2020-04-04 12:22:43 -04:00
Piotr Drąg
e75e975a38 Update POTFILES.skip 2020-04-04 11:56:04 +02:00
Matthias Clasen
2bf81b51d9 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1626
2020-04-04 05:00:22 +00:00
Matthias Clasen
22211f29fb colorbutton: Don't add a customize menu
The color swatch in the button does not need a
context menu. Turn it off.
2020-04-04 00:28:52 -04:00
Matthias Clasen
8991275fbd colorbutton: Fix focus
The colorbutton contains a button which contains a colorswatch.
We want the focus to go straight to the button, nowhere else,
so mark the swatch as !can-focus.

Adapt tests to match.
2020-04-04 00:28:45 -04:00
Matthias Clasen
f2d6a7b36a demos: Remove can-focus from ui files 2020-04-04 00:28:34 -04:00
Matthias Clasen
e43eb951d6 Merge branch 'scrollbar-a11y' into 'master'
Add GtkScrollbarAccessible

See merge request GNOME/gtk!1623
2020-04-04 04:03:40 +00:00
Matthias Clasen
5205fa0ff7 scrollbar: Be more defensive
Somehow the scrollbar accessible manages to call
gtk_scrollbar_get_adjustment when priv->range is NULL.
Survive taht.
2020-04-03 23:31:45 -04:00
Matthias Clasen
842af79e97 Merge branch 'shortcut-action-parse' into 'master'
Shortcut action parse

See merge request GNOME/gtk!1625
2020-04-04 03:12:10 +00:00
Matthias Clasen
6b292af6ac testsuite: Add tests for parsing shortcut actions 2020-04-03 22:42:00 -04:00
Matthias Clasen
1424dd9786 Add an api to parse shortcut actions
This is so we can test this code. While doing it
I also fixed the missing else that was caused it
not to work.
2020-04-03 22:41:15 -04:00
Matthias Clasen
339d3e41b0 Add GtkScrollbarAccessible
When GtkScrollbar stopped being a GtkRange,
GtkRangeAccessible stopped working for scrollbars.

Update a11y tests to match.
2020-04-03 15:20:27 -04:00
Carlos Garnacho
9a2f7338df Merge branch 'wip/carlosg/fix-surrounding-text-master' into 'master'
imwayland: Clamp the surrounding string end correctly

Closes #2565

See merge request GNOME/gtk!1621
2020-04-03 18:37:44 +00:00
Matthias Clasen
bdb127e54c Merge branch 'focus-test' into 'master'
Focus test

See merge request GNOME/gtk!1622
2020-04-03 18:23:27 +00:00
Carlos Garnacho
e5d23aaaaf imwayland: Clamp the surrounding string end correctly
In the paths where len > MAX_LEN and cursor/anchor are separated by
at least MAX_LEN from text edges, we were clamping the right end of
the surrounding string at MAX_LEN. Oops.

This end anchor may go as far as the string length, although just
up to len - MAX_LEN in real terms (due to the condition above that
caches cursor/anchor positions being near enough the text end).

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2565

(cherry-picked from commit d7fb15c822)
2020-04-03 19:55:55 +02:00
Matthias Clasen
d662512c44 testsuite: Add a big focus chain testcase 2020-04-03 11:35:34 -04:00
Matthias Clasen
324af2f701 testsuite: Try harder to record a full focus chain
It is hard to avoid widgets with the same name in a
large ui file - try harder to record a full focus chain
before decide that we've wrapped, by including the widget
address in the comparison. Note that we don't include
the addresses in the generated output, since that would
make expected output vary from run to run.
2020-04-03 11:35:26 -04:00
Emmanuele Bassi
de481a7b5e Merge branch 'gir-fixes' into 'master'
Annotation fixes

See merge request GNOME/gtk!1616
2020-04-03 15:21:59 +00:00
Matthias Clasen
c8018e267a Merge branch 'move-gdkgrab-decl' into 'master'
gdk: Move GdkGrabStatus and GdkGrabOwnership decl.

See merge request GNOME/gtk!1615
2020-04-03 15:03:51 +00:00
Emmanuele Bassi
4e264a74be Annotation fixes
Match the arguments name in the declaration and the definition, and make
sure we have the proper transfer annotations.
2020-04-03 15:30:56 +01:00
Olivier Fourdan
4f49d83e43 gdk: Move GdkGrabStatus and GdkGrabOwnership decl.
With the removal of `gdk_seat_grab` we do not need to keep the
definitions of `GdkGrabStatus` and `GdkGrabOwnership` public.

Move those definitions to become internal only.
2020-04-03 15:23:01 +02:00
Nirbheek Chauhan
eaef24c527 meson: Fix check for builtype arguments
`get_option('buildtype')` will return `'custom'` for most combinations
of `-Doptimization` and `-Ddebug`, but those two will always be set
correctly if only `-Dbuildtype` is set. So we should look at those
options directly.

For the two-way mapping between `buildtype` and `optimization`
+ `debug`, see this table:
https://mesonbuild.com/Builtin-options.html#build-type-options
2020-04-03 18:41:55 +05:30
Nirbheek Chauhan
777435c470 meson: Reduce useless relinking on reconfigure
When we reconfigure, `configure_file()` is called again, and
`*.gresource.xml` files are regenerated, which causes many (all?)
binaries to be relinked. Now we only write those out if the contents
actually changed (or if the output didn't already exist).

This is exactly what Meson already does with `configure_file()` when
`command:` is not used.

While we're at it, also do the same for `gen-c-array.py` and
`gentypefuncs.py` for completeness. Now even if the input to those
changes, re-building of those custom targets may not result in
relinking if the outputted C files have the same contents.
2020-04-03 18:41:55 +05:30
Timm Bäder
fb325afc79 shortcutcontroller: fix transfer full annotation 2020-04-03 08:03:32 +02:00
Timm Bäder
046190cb8a window: Don't leak toplevel layout 2020-04-03 07:37:54 +02:00
Matthias Clasen
53592497a4 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1611
2020-04-03 01:07:14 +00:00
Matthias Clasen
cffa45d5ff wayland: Add a comment about keyboard state handling
Clarify a point that took me a few hours to fully track
down, so lets preserve what I found for the next poor
sould coming this way.
2020-04-02 17:43:14 -04:00
Matthias Clasen
14166b09b5 a11y tests: Update for focus state changes 2020-04-02 17:35:15 -04:00
Matthias Clasen
8a0035333a a11y: Set focus-related states properly
Entries and menubuttons are no longer focusable themselves,
they have focusable children. Since we don't have accessible
objects for those, transfer the focus-related state (focusable
and focused) from the children to the main accessible object.
2020-04-02 17:35:09 -04:00
Matthias Clasen
1f8e633fff window: tie focus to surface state changes
We don't get a focus-out on the event controller, when
the surface is losing keyboard focus, since we are not
moving our focus to some other widget, so we are never
unsetting the mnemonics-visible property. Do that in
response to surface state changes instead.
2020-04-02 17:21:01 -04:00
Matthias Clasen
6e6b4a851f Merge branch 'cherry-picked-wayland-keyboard-fix' into 'master'
gdk/wayland: Clear modifiers when we lose keyboard focus

Closes #2112

See merge request GNOME/gtk!1610
2020-04-02 20:43:29 +00:00
Jan Alexander Steffens (heftig)
7444b15d47 gdk/wayland: Clear modifiers when we lose keyboard focus
When we `Alt+Tab` away from a GTK application, it loses keyboard focus.
If we don't clear the modifiers, events from other devices that we
receive while unfocused will assume `Alt` is still pressed. This results
in e.g. Firefox navigating through the history instead of scrolling the
page when using the mouse wheel on it.

We don't get any information about modifiers while we are missing
keyboard focus, so assuming no modifiers are active is the best we can
do.

The shell sends us a modifier update immediately before we regain
keyboard focus, so the state shouldn't get out of sync.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/2112
2020-04-02 16:18:18 -04:00
Matthias Clasen
dd625abfc1 Merge branch 'wip/smcv/libdir-independent-valgrind-suppressions' into 'master'
supp: Use a single suppressions file for lib, lib64 and multiarch

See merge request GNOME/gtk!1603
2020-04-02 14:46:45 +00:00
Matthias Clasen
b6f6df9662 Merge branch 'im-context-wayland-fixes' into 'master'
Im context wayland fixes

See merge request GNOME/gtk!1605
2020-04-02 13:29:32 +00:00
Matthias Clasen
aaa4e40a1f imcontexsimple: Move Compose file loading to class_init
This ensures that it is done only once.
2020-04-02 09:04:23 -04:00
Matthias Clasen
8ec254e2bb imcontextsimple: Simpify Compose file loading
We are not loading the Compose file for individual contexts,
it just gets added to a global list. So don't pass an im context
along. This will let us move the loading out of the initialization
of individual contexts, and only do it once.
2020-04-02 09:02:05 -04:00
Matthias Clasen
2a9911724f imcontextsimple: Load ~/.Compose unconditionally
There is nothing display-specific in the ~/.Compose file,
so we can just try to load it without looking at the
display we are on.
2020-04-02 09:02:05 -04:00
Matthias Clasen
a9b4ac3d59 imcontextsimple: Add a profiler mark for IO
We are loading a file here, thankfully in a thread, but
we do it every time an entry is created. Add a profiler
mark, to make this visible.
2020-04-02 09:02:05 -04:00
Simon McVittie
9df7f0197d supp: Use a single suppressions file for lib, lib64 and multiarch
In addition to the traditional library directory lib and the 64-bit
multilib directory lib64, this will cover Debian-style multiarch
(lib/x86_64-linux-gnu etc.), Arch Linux 32-bit (lib32), x32 and
various others.

Signed-off-by: Simon McVittie <smcv@debian.org>
2020-04-02 09:18:55 +01:00
Matthias Clasen
f169d23cdb Merge branch 'fix-menu-flicker' into 'master'
Fix crossing event generation

Closes #2536

See merge request GNOME/gtk!1601
2020-04-02 05:19:13 +00:00
Matthias Clasen
fcd36e59b1 Fix crossing event generation
We were not properly setting the new_descendent field
in Crossing structs for GTK_CROSSING_OUT events. This
was causing extraneous ::leave signals to be emitted,
and make model buttons in popover menus flicker when
hovered.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2536
2020-04-02 00:39:46 -04:00
Matthias Clasen
8196478b19 Merge branch 'drop-popover-demo' into 'master'
gtk-demo: Remove the popover demo

Closes #2429

See merge request GNOME/gtk!1600
2020-04-01 20:40:17 +00:00
Matthias Clasen
e31bbb41d2 gtk-demo: Remove the popover demo
It doesn't work anymore, since popovers now need
support in the parent, and we don't really need
a demo just for popovers. They are used everywhere
already.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2429
2020-04-01 15:45:13 -04:00
Emmanuele Bassi
9c948909ac Merge branch 'flow-box-typo' into 'master'
gtkflowbox: Fix a minor typo in the documentation

See merge request GNOME/gtk!1599
2020-04-01 13:45:19 +00:00
Philip Withnall
544b8d5a7f gtkflowbox: Fix a minor typo in the documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-04-01 14:04:46 +01:00
Matthias Clasen
6ae5d9ac22 Merge branch 'matthiasc/for-master' into 'master'
keynav: Fix Shift-Tab

See merge request GNOME/gtk!1598
2020-04-01 05:04:02 +00:00
Matthias Clasen
63c6af8d13 Merge branch 'cursor-aspect-ratio' into 'master'
Add a cursor-aspect-ratio setting

See merge request GNOME/gtk!1597
2020-04-01 05:02:15 +00:00
Matthias Clasen
199a539ae7 Update the settings test 2020-04-01 00:24:56 -04:00
Matthias Clasen
dc3d778e01 keynav: Fix Shift-Tab
This was broken by the shortcuts branch merge.
2020-04-01 00:21:19 -04:00
Matthias Clasen
2154b8e745 Add a cursor-aspect-ratio setting
Add a setting that controls how thick the text caret is drawn.
The default value is 0.04.
2020-03-31 23:30:20 -04:00
Matthias Clasen
9f93464ea4 3.98.2 2020-03-31 21:09:30 -04:00
Matthias Clasen
5987bc5d71 Merge branch 'wip/carlosg/stuck-pointer-focus' into 'master'
gtkmain: Do not try to coalesce/ignore crossing events

See merge request GNOME/gtk!1594
2020-04-01 00:16:26 +00:00
Matthias Clasen
298218b1d2 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1593
2020-03-31 23:19:09 +00:00
Carlos Garnacho
fa7f6ad910 gtkmain: Do not try to coalesce/ignore crossing events
Under grabbing circumstances we used to get several crossing events,
some corresponding to the grab itself and some corresponding to
pointer motion.

The backends now do a better job at keeping those simple, which
means we sit listening for events that don't actually arrive. This
triggers pointer focus issues when dragging windows or opening
grabbing popups.

Actually obey those events, they will be the only ones we get now.
2020-04-01 00:40:17 +02:00
Matthias Clasen
b92b7f45b5 testsuite: Add a test for transforms in builder files 2020-03-31 16:49:51 -04:00
Matthias Clasen
2bacc0d4ef testsuite: Add a test for parsing layout properties
and drop the child properties test that doesn't
do anything anymore.
2020-03-31 16:49:51 -04:00
Matthias Clasen
e4fb4b635c Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1591
2020-03-31 18:32:18 +00:00
Matthias Clasen
5432f73095 window: Fix residual resizing issues
After the GdkToplevel split, GtkWindow occasionally
forgets its minimum size. Fix this by keeping a GdkToplevelLayout
around and reusing it.
2020-03-31 13:07:44 -04:00
Chun-wei Fan
2f64651a3f meson.build: Fix Visual Studio builds
We need to make the C++ language available before we can access the C++
compiler object...
2020-03-31 12:00:26 +08:00
Matthias Clasen
0852d66f6e NEWS: Updates 2020-03-30 21:58:24 -04:00
Matthias Clasen
f3e826f4d6 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1589
2020-03-31 00:39:37 +00:00
Matthias Clasen
15eb3bbbf1 shortcutcontroller: Document buildable support 2020-03-30 20:09:29 -04:00
Matthias Clasen
96f822434f testsuite: Add a builder test for shortcut controllers 2020-03-30 20:08:25 -04:00
Matthias Clasen
ace183f38f shortcutcontroller: Fix builder support
The GtkBuilder support was not working anymore after
triggers and actions have been turned into objects.

Fix this.
2020-03-30 19:02:35 -04:00
Matthias Clasen
5bf030413b Add new api to the docs 2020-03-30 14:12:14 -04:00
Matthias Clasen
2a3dab5b94 Merge branch 'wip/hadess/portal-fixes' into 'master'
Portal fixes

See merge request GNOME/gtk!1585
2020-03-30 17:45:40 +00:00
Matthias Clasen
96f0c26306 Merge branch 'issue982' into 'master'
gdk: Add gdk_toplevel_inhibit_system_shortcuts API

Closes #982

See merge request GNOME/gtk!1542
2020-03-30 17:41:12 +00:00
Bastien Nocera
8cf41c1b66 filechoosernativeportal: Fall back if portal is too old
Add portal version checking as originally implemented for the GTK 3.x
branch.

See: 35fec1c6b2
2020-03-30 18:31:24 +02:00
Bastien Nocera
027ca22def Add portal version checking helper
Add gtk_get_portal_interface_version() to check the version of a portal.
2020-03-30 18:31:23 +02:00
Bastien Nocera
bd55c5842e colorpickerportal: Simplify version fetching code
Simplify version checking code by using a function to fetch the uint out
of the GVariant and don't throw a warning if it can't be fetched.
2020-03-30 18:31:23 +02:00
Olivier Fourdan
c3ff175e3f win32: Add inhibit shortcut properties
Win32 backend doesn't have support for inhibit shortcuts, yet it needs
support the standard set of GdkToplevel properties.

Add support for the "inhibit-list" object property to GdkToplevel on
win32.
2020-03-30 18:25:36 +02:00
Olivier Fourdan
b22c7b8b77 broadway: Add inhibit shortcut properties
Broadway doesn't have support for inhibit shortcuts, yet it needs to
support the standard set of GdkToplevel properties.

Add support for the "inhibit-list" object property to GdkToplevel on
Broadway.
2020-03-30 18:25:36 +02:00
Olivier Fourdan
83027c68f1 x11: Implement inhibit_system_shortcuts API
On X11, there is no such equivalent to the inhibit shortcut protocol
found on Wayland.

To implement the inhibit_system_shortcuts API on X11, we emulate the
same behavior using grabs on the keyboard.

To avoid keeping active grabs on the keyboard that would affect other
X11 applications even when the surface isn't focused, the X11
implementation takes care of releasing the grabs as soon as the toplevel
loses focus.
2020-03-30 18:25:36 +02:00
Olivier Fourdan
44931a66df x11: Use gdk_x11_* rather than gdk_wayland_*
Rename the local functions for the x11 backend as gdk_x11_* rather than
gdk_wayland_*
2020-03-30 18:25:36 +02:00
Olivier Fourdan
36d986f33c wayland: Implement inhibit_system_shortcuts API
On Wayland, this is a direct mapping with the inhibit shortcut protocol
that GDK already supports.

Simply wire the new API to the existing entries.
2020-03-30 18:25:36 +02:00
Olivier Fourdan
5ac73be976 wayland: Use a GdkSeat as key for our internal hash table
With the current implementation, we use a `wl_seat` as the key for our
internal has table where we store the Wayland shortcuts inhibitors.

There is however no technical reason for this, and we could use a
GdkSeat instead, which will ease the implementation of the GdkToplevel
shortcut inhibition API.
2020-03-30 18:25:36 +02:00
Olivier Fourdan
a07a69e24e gdk: add internal gdk_surface_get_seat_from_event()
This can come handy to get the seat from a surface/event.
2020-03-30 18:25:36 +02:00
Olivier Fourdan
3e1f59af61 gdk: Add gdk_toplevel_inhibit_system_shortcuts API
With the removal of grabs from the public API, we need a replacement API
to let applications bypass system keyboard shortcuts.

A typical use case for this API is remote desktop or virtual machine
viewers which need to inhibit the default system keyboard shortcuts so
that the remote session or virtual host gets those instead of the local
environment.

Close: https://gitlab.gnome.org/GNOME/gtk/issues/982
2020-03-30 18:25:36 +02:00
Matthias Clasen
da47ccaf3c Merge branch 'wip/jimmac/avoid-t-word' into 'master'
widget-factory: avoid the T word

See merge request GNOME/gtk!1586
2020-03-30 15:15:51 +00:00
Jakub Steiner
e9082fd9f3 widget-factory: avoid the T word
- style variant sound more appropriate
2020-03-30 14:28:47 +02:00
Matthias Clasen
61e88c7421 Merge branch 'matthiasc/for-master' into 'master'
widget: Remove a leftover vfunc

See merge request GNOME/gtk!1584
2020-03-30 11:37:57 +00:00
Matthias Clasen
de31bb59a1 window: Remove initial-focus leftovers
We removed the way to set initial_focus a year ago,
time to get rid of the leftovers.
2020-03-29 23:39:54 -04:00
Matthias Clasen
07bb29153b widget: Remove a leftover vfunc
The popup-menu signal is gone, so we can remove the vfunc.
2020-03-29 23:18:56 -04:00
Yosef Or Boczko
b35e5eeaf6 Update Hebrew translation 2020-03-29 15:34:36 +00:00
Yosef Or Boczko
c0a450e41b Update Hebrew translation 2020-03-29 15:33:40 +00:00
Timm Bäder
785b33f169 widget: Return an array from list_controllers
Minimize the GList usage throughout the code base.
2020-03-29 15:32:54 +02:00
Matthias Clasen
af749dc1dc Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1583
2020-03-29 13:18:35 +00:00
Matthias Clasen
47982ae272 coloreditor: Drop the Private struct 2020-03-29 09:04:19 -04:00
Matthias Clasen
0020b735d9 colorchooserdialog: Drop the Private struct 2020-03-29 09:04:19 -04:00
Matthias Clasen
e05c1b0244 colorchooserwidget: Drop the Private struct 2020-03-29 09:04:19 -04:00
Matthias Clasen
d0b4f9eb29 notebook: Drop the Private struct 2020-03-29 09:04:19 -04:00
Matthias Clasen
03375b723a listbox: Drop the Private struct 2020-03-29 09:04:19 -04:00
Matthias Clasen
e2beb6ec50 levelbar: Drop the Private struct 2020-03-29 09:04:19 -04:00
Matthias Clasen
ef32cff771 spinbutton: Drop the Private struct 2020-03-29 09:04:19 -04:00
Matthias Clasen
366b007024 filechooserwidget: Drop the Private struct 2020-03-29 09:04:19 -04:00
Matthias Clasen
40337aa1b3 printunixdialog: Drop the Private struct 2020-03-29 09:04:19 -04:00
Matthias Clasen
0bb38b903e printjob: Drop the Private struct 2020-03-29 09:04:19 -04:00
Matthias Clasen
8acd9ffc76 testsuite: Fix notify test no not fail on the 30th
We are setting the month property to 10 different values,
checking that the change succeeds. But the calendar defaults
to the current date, so on every 30th of the month, we
try to set a date of Febuary 30, which fails.

Lets fix this before the 31st, by setting the calendar
to a good date.
2020-03-29 09:04:19 -04:00
Piotr Drąg
23b29341ba Update Polish translation 2020-03-29 14:08:56 +02:00
Matthias Clasen
6e52820fd2 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1582
2020-03-28 21:17:29 +00:00
Matthias Clasen
173b1333ca printing: Avoid a crash
When no printer has been selected (e.g. because we don't
find any printers), the 'print at' radio group should be
insensitive, except for the 'now' choice. Selecting another
option in this situation will lead to a crash.
2020-03-28 15:36:15 -04:00
Matthias Clasen
784d6f8d0c printing: Fix initial page range radio group
Only set one radio button as active in the ui file.
Otherwise we end up with multiple options appearing
as selected initially.
2020-03-28 15:36:15 -04:00
Matthias Clasen
3437f85aaf Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1580
2020-03-28 19:35:36 +00:00
Matthias Clasen
7916b95bc5 gesture: Fix gtk_gesture_get_bounding_box
When we stopped translating event coordinates in-place,
this function inadvertently started returning surface-relative
bounding boxes instead of widget-relative ones, as expected.

Fix this by using the widget-relative coordinates that we
already store.
2020-03-28 15:03:33 -04:00
Matthias Clasen
7b135c96e4 cellarea: Fix cell editing
We need to translate the event coordinates to
widget-relative coordinates. This broke when
we stopped translating event coordinates in-place.
2020-03-28 14:56:26 -04:00
Matthias Clasen
e662438675 button: Fix an event handling gotcha
We no longer translate event coordinates in-place,
so gdk_event_get_position() returns surface-relative
coordinates, not widget-relative ones. Just use the
coordinates we are given.
2020-03-28 14:33:01 -04:00
Matthias Clasen
aa2ca80817 imcontextsimple: Don't use g_object_unref on events
Events are not objects anymore.
2020-03-28 14:29:08 -04:00
Matthias Clasen
9ccd514682 x11: Don't use g_object_unref on events
Events are not object anymore.
2020-03-28 14:28:36 -04:00
Matthias Clasen
2c7afc0556 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1579
2020-03-28 16:09:01 +00:00
Piotr Drąg
182cb81bdb Update POTFILES.in and POTFILES.skip 2020-03-28 16:04:52 +01:00
Matthias Clasen
ceef86895f appchooserdialog: Drop the Private struct 2020-03-28 10:59:12 -04:00
Matthias Clasen
001d076e61 image: Drop the Private struct 2020-03-28 10:49:54 -04:00
Matthias Clasen
408dd37944 infobar: Drop the Private struct 2020-03-28 10:48:15 -04:00
Matthias Clasen
9287e0e7fb texthandle: Drop the Private struct 2020-03-28 10:36:09 -04:00
Matthias Clasen
28eb1fce04 searchentry: Drop the Private struct 2020-03-28 10:28:22 -04:00
Matthias Clasen
49427119ab statusbar: Drop the Private struct 2020-03-28 10:28:01 -04:00
Matthias Clasen
05891b1238 settings: Drop the Private struct
Also drop class padding - pointless for final types.
2020-03-28 10:22:44 -04:00
Matthias Clasen
b14d99ad7a accellabel: Drop unused class fields
We are not using these anymore.
2020-03-28 10:15:50 -04:00
Matthias Clasen
329638280c accellabel: Drop the Private struct 2020-03-28 10:06:26 -04:00
Matthias Clasen
06365cdc38 actionbar: Drop the Private struct 2020-03-28 09:59:49 -04:00
Matthias Clasen
1f808c479a aboutdialog: Drop the Private struct 2020-03-28 09:59:07 -04:00
Matthias Clasen
7e8d61b92c menubutton: Drop the Private struct 2020-03-28 09:49:29 -04:00
Timm Bäder
d01e664c79 applicationaccels: Fix shortcut memory leaks
g_list_model_get_item() is transfer-full.
2020-03-28 08:34:35 +01:00
Matthias Clasen
858997d172 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #2489

See merge request GNOME/gtk!1578
2020-03-28 04:40:52 +00:00
Matthias Clasen
f3d061e879 gtk-demo: Fix the stack demo
The GtkSpinner:active property was renamed to :spinning.
2020-03-28 00:08:12 -04:00
Matthias Clasen
e2c327e025 gtk-demo: Fix the sliding puzzle
Update for a change in gtk_shortcut_controller_add_shortcut
behavior.
2020-03-28 00:08:12 -04:00
Matthias Clasen
48910a6d8e gtk-demo: Fix the shortcuts demo
We don't have margins anymore.
2020-03-28 00:08:12 -04:00
Matthias Clasen
fbed55dff9 gtk-demo: Fix the rotated text demo
Off-by-one on the heart!
2020-03-28 00:08:12 -04:00
Matthias Clasen
059917b83c gtk-demo: Fix the overlay demo
We must use two separate boxes for the label and
the entry, otherwise we can't keep their can-target
properties apart.
2020-03-28 00:08:12 -04:00
Matthias Clasen
163aa82d45 gtk-demo: Use mnemonics in menu buttons
Use GtkMenuButton:use-underline in the modelbutton demo.
2020-03-28 00:08:12 -04:00
Matthias Clasen
ba25e08e7b menubutton: Add a use-underline property
This is necessary since apps no longer have direct
access to the label.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2489
2020-03-28 00:08:12 -04:00
Matthias Clasen
bc2c341d60 gtk-demo: Visual fixes to the model button demo 2020-03-28 00:08:12 -04:00
Matthias Clasen
7e0266004e Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1577
2020-03-27 21:10:19 +00:00
Matthias Clasen
93d54ba10b gtk-demo: Fix the search entry demo
Avoid critical warnings when setting up the context
menu actions.
2020-03-27 16:24:20 -04:00
Matthias Clasen
5d07a66d1d widget-factory: Fix the radio button example
We only want one of the sensitive buttons to be active,
so don't tell them all to be active.
2020-03-27 16:06:03 -04:00
Matthias Clasen
8997dc6f31 Merge branch 'rename-theme-resources' into 'master'
Rename GResources for standard GTK themes

See merge request GNOME/gtk!1576
2020-03-27 16:37:31 +00:00
Matthias Clasen
9f72f4225d Merge branch 'trigger-parser' into 'master'
Improve GtkShortcutTrigger parser

See merge request GNOME/gtk!1572
2020-03-27 15:45:08 +00:00
Emmanuele Bassi
f1003d6ae8 Rename GResources for standard GTK themes
After commit 2ab9be54fb we had to rename
the generated CSS files to be included into the GResource bundle; we
kept the URI stable to avoid too much churn, and allow backporting the
change to the 3.24 stable branch. This had the adverse effect of making
it harder to debug issues, as the on-disk file name does not match the
location in the GResource that will be used to print out warnings,
errors, and debugging messages.
2020-03-27 15:20:59 +00:00
Emmanuele Bassi
b1327167e2 Improve GtkShortcutTrigger parsing tests
Split off all possible cases into sub-tests, and add more thorough
checks on the invalid strings unit.
2020-03-27 14:56:05 +00:00
Emmanuele Bassi
6719d3044d Add parsing for GtkAlternativeTrigger
Alternative triggers are separate by a pipe character.
2020-03-27 14:35:00 +00:00
Emmanuele Bassi
c75fdda8dd tests: Add more cases for the trigger parser 2020-03-27 13:57:19 +00:00
Emmanuele Bassi
170e8bd605 Parse keyval name directly for mnemonic triggers
We don't need to parse the full accelerator format for mnemonic
triggers.
2020-03-27 13:57:19 +00:00
Emmanuele Bassi
96ccb25f97 Return a full reference when parsing triggers
We're not returning a full reference for GtkNeverTrigger, but we are
returning full references for mnemonic and keyval triggers; this means
we're either going to leak mnemonic and keyval triggers if we consider
this function a "transfer none" one, or we are going to trigger an
assertion failure when finalizing a never trigger, if we consider this
function a "transfer full" one.

Let's be consistent, and always return a full reference to the caller.
2020-03-27 13:57:19 +00:00
Timm Bäder
c3c06e60dc calendar: Only highlight one day as today
Fixes #2490
2020-03-27 09:50:30 +01:00
Timm Bäder
ecb8dda309 shortcutscontroller: Make add_shortcut transfer-full
Like all the other shortcut api
2020-03-27 08:36:32 +01:00
Timm Bäder
f7975828bc filechooserwidget: Plug a memory leak 2020-03-27 08:36:32 +01:00
Matthias Clasen
5fdb897f06 Merge branch 'widget-factory-theme' into 'master'
widget-factory: Add theme switch

See merge request GNOME/gtk!1573
2020-03-26 18:23:11 +00:00
Matthias Clasen
8ab2e31b58 widget-factory: Add theme switch
Add a submenu to test the builtin themes. This is mainly
for the benefit of the artists working on those themes.
2020-03-26 13:51:59 -04:00
Matthias Clasen
0d710b0353 Merge branch 'wip/jimmac/HC-redesign' into 'master'
HC: derive from Adwaita

Closes #1450

See merge request GNOME/gtk!1571
2020-03-26 17:24:42 +00:00
Jakub Steiner
06fe4f0205 Adwaita: make insensitive slightly less sensitive
- will expose itself even more in HC
2020-03-26 17:22:47 +01:00
Jakub Steiner
910dd7a20a HC: derive from Adwaita
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/1450
2020-03-26 17:21:47 +01:00
Jakub Steiner
8d8990ccd7 Revert "Adwaita: make insensitive slightly less sensitive"
This reverts commit bf3ccaa1bf.
2020-03-26 17:19:19 +01:00
Jakub Steiner
bf3ccaa1bf Adwaita: make insensitive slightly less sensitive
- will expose itself even more in HC
2020-03-26 15:55:42 +01:00
Matthias Clasen
eaa20f5cdf Merge branch 'wip/matthiasc/shortcut-4' into 'master'
Shortcuts

See merge request GNOME/gtk!1569
2020-03-26 03:40:22 +00:00
Matthias Clasen
d07e22dc03 Some documentation fixes 2020-03-25 23:14:45 -04:00
Matthias Clasen
1ec2d1d9f1 shortcutmanager: Add some more docs 2020-03-25 23:14:45 -04:00
Matthias Clasen
f59cd392ba shortcuttrigger: Some documentation fixups 2020-03-25 23:14:45 -04:00
Matthias Clasen
6bacb0b0ae shortcutaction: Some documentation fixups 2020-03-25 23:14:45 -04:00
Matthias Clasen
530b571d89 shortcutcontroller: Expand the docs 2020-03-25 23:14:45 -04:00
Matthias Clasen
ce22ef18f9 docs: Update the overview input chapter
Update the wording around events to reflect current
usage, and add information about shortcuts and the
shortcut controller.
2020-03-25 23:14:45 -04:00
Matthias Clasen
591f6bd7a9 popovermenu: Show mnemonics on keynav
This is the expected behavior for menus.
2020-03-25 23:14:45 -04:00
Matthias Clasen
642503afb4 popover: Implement auto mnemonics
Unfortunately, this involves copying a bunch of
code from gtkwindow.c. The only difference here
is that we add a private method to turn this off,
which will be used by GtkPopoverMenu to implement
its own auto mnemonics.
2020-03-25 23:14:45 -04:00
Matthias Clasen
fc0b0b14a8 label: Respect GtkPopover::mnemonics-visible
When inside a popover, look to the popover for
whether to show mnemonics or not.
2020-03-25 23:14:45 -04:00
Matthias Clasen
2de4fc3ec0 popover: Add a mnemonics-visible property
This will be handled separately for popovers, so we
need our own property for it.
2020-03-25 23:14:45 -04:00
Matthias Clasen
b2ac42e576 label: Disconnect visible mnemonics in popovers
The controller handling mnemonics is limited to same-native,
so showing mnemonics in other natives.
2020-03-25 23:14:45 -04:00
Matthias Clasen
b19d4b9006 modelbutton: Install accels when inside a popover
When a model button in a popover displays a shortcut,
it is probably from the global shortcut controllers,
and will not work inside the popover, since that is
a different native. Install a shortcut using the same
trigger that just activates the model button. This
shortcut will end up in the managed shortcut controller
of the popover.
2020-03-25 23:14:45 -04:00
Matthias Clasen
2c28a0713d popovermenu: Make mnemonics work without Alt
This is expected menu behavior.
2020-03-25 23:14:45 -04:00
Matthias Clasen
b423f974db shortcutcontroller: Inject accels into the action muxer
This is the way model button pic up accels for their actions.
2020-03-25 23:14:45 -04:00
Matthias Clasen
4a430820bd popover: Implement GtkShortcutManager
This makes mnemonics work in popovers.
2020-03-25 23:14:45 -04:00
Matthias Clasen
5153cdc01d modelbutton: Make activatable
This is expected of button-like widgets, and is necessary
to make keynav in popover menus work as expected.
2020-03-25 23:14:45 -04:00
Matthias Clasen
1db5382c6d modelbutton: Remove accel poking
Stop manually poking GtkApplication for accels.
GtkApplication already feeds them into the action
muxer machinery, so that is where will get them.
2020-03-25 23:14:45 -04:00
Emmanuele Bassi
6e8c78714d Turn GtkShortcutAction into a GObject
Just like we did for GtkShortcutTrigger.

This allows language bindings to properly deal with all the actions.
2020-03-25 23:14:45 -04:00
Emmanuele Bassi
457b6657bb Turn GtkShortcutTrigger into an object
The lightweight inheritance mechanism used for GtkShortcutTrigger is not
going to be usable by bindings, because boxed types cannot have derived
types.

We could use GTypeInstance and derive everything from that, like
GParamSpec, but in the end shortcuts are not really a performance
critical paths, unlike CSS values or render nodes.
2020-03-25 23:14:45 -04:00
Emmanuele Bassi
1ddd8586dd Add definition macro for internal types
GTK defines various types that are meant to be derivable only within GTK
itself, and "final" from the perspective of consumers of the GTK API.
The existing macros defined by GObject, such as G_DECLARE_FINAL_TYPE and
G_DECLARE_DERIVABLE_TYPE, lack this functionality.

While we wait for GObject to get this kind of macro, we should define
our own.
2020-03-25 23:14:45 -04:00
Matthias Clasen
5ea45bf57d widget: Remove some leftover accel group plumbing
The ::can-activate-accel and ::accel-closures-changed signals
are not used anymore, remove them.
2020-03-25 23:14:45 -04:00
Matthias Clasen
4e978d6b7a shortcutcontroller: Only activate shortcuts of visible widgets
Our shortcuts are like mnemonics in this respect - they only
activate when the widget is viewable.
2020-03-25 23:14:45 -04:00
Matthias Clasen
b4722b43a1 Drop GtkKeyHash 2020-03-25 23:14:45 -04:00
Matthias Clasen
fd95cc56b1 window: Remove GtkKeyHash remnants
It is not used anymore.
2020-03-25 23:14:45 -04:00
Matthias Clasen
d66121c61e Drop the keyhash test
GtkKeyHash is going away.
2020-03-25 23:14:45 -04:00
Matthias Clasen
35332eb3b0 shortcutcontroller: Implement mnemonic cycling
Make GtkShortcutController collect matching shortcuts
in the same way GtkKeyHash did (accept fuzzy matches
if we don't have any exact matches), and cycle among
the matches if we have multiple.
2020-03-25 23:14:45 -04:00
Matthias Clasen
586e7749d5 shortcuttrigger: Do elaborate matching for key events
Copy the logic from GtkKeyHash for matching key events
to shortcuts.

Adapt shortcuts test to work with the better matching,
by creating more complete key events.
2020-03-25 23:14:45 -04:00
Matthias Clasen
904835d4b1 shortcuttrigger: Introduce partial matches
Allow GtkShortcutTrigger to return partial matches.
Currently, no triggers produce such results, and
GtkShortcutController treats partial matches like
exact ones.
2020-03-25 23:14:45 -04:00
Matthias Clasen
cb821d5df3 Add tests for shortcut actions 2020-03-25 23:14:45 -04:00
Matthias Clasen
ff056af249 Add a test for shortcut triggers 2020-03-25 23:14:45 -04:00
Matthias Clasen
9cce474106 widget: Drop the ::popup-menu signal
This is now done in widgets which have context
menus.
2020-03-25 23:14:45 -04:00
Matthias Clasen
9d84996fea placesview: Stop using ::popup-menu
This signal is going away.
2020-03-25 23:14:45 -04:00
Matthias Clasen
c2d77a1f37 filechooser: Stop using ::popup-menu
This signal is going away.
2020-03-25 23:14:45 -04:00
Matthias Clasen
54a0037c45 mountoperation: Stop using ::popup-menu
We can just use a shortcut controller directly.
2020-03-25 23:14:45 -04:00
Matthias Clasen
80b988ef6c gtk-demo: Stop emitting ::popup-menu
The signal was not used anyway, in the font explorer demo.
2020-03-25 23:14:45 -04:00
Matthias Clasen
844801580f colorchooser: Stop using ::popup-menu
This signal is going away. Use an action instead.
2020-03-25 23:14:44 -04:00
Matthias Clasen
28b05eea67 range: Remove ::popup-menu emission
This signal is going away, and having context menus
on sliders is not really a thing anyway.
2020-03-25 23:14:44 -04:00
Matthias Clasen
ca1d4322a2 scrollbar: Remove :popup-menu forwarding
This signal is going away.
2020-03-25 23:14:44 -04:00
Matthias Clasen
c94ec4a204 emojichooser: Stop using ::popup-menu
This signal is going away. Use an action instead.
2020-03-25 23:14:44 -04:00
Matthias Clasen
778d884f70 Use an action for the context menu keybinding
The ::popup-menu signal is going away.
2020-03-25 23:14:44 -04:00
Matthias Clasen
e8be45fabc Print mnemonic triggers clearly 2020-03-25 23:14:44 -04:00
Matthias Clasen
c90b0581dd inspector: Show shortcuts
At a tab that lists the shortcuts contained in a
GtkShortcutController.
2020-03-25 23:14:44 -04:00
Benjamin Otte
43c0ea676d filechooser: Trigger the location popup via bindings
Simplifies code quite a bit.
2020-03-25 23:14:44 -04:00
Benjamin Otte
bb4fbe3d8f accels: Remove GtkAccelGroup 2020-03-25 23:14:44 -04:00
Benjamin Otte
7c4d8d49b6 testmenubutton: Don't create a GtkAccelGroup
It's unused.
2020-03-25 23:14:28 -04:00
Benjamin Otte
cac39526a9 testsuite: Remove GtkAccelGroup usage 2020-03-25 23:14:28 -04:00
Benjamin Otte
4c45410d43 widget: Remove gtk_widget_add_accelerator()
People should use shortcut controllers instead (global, capture).

A side effect of this is that GtkAccelLabel now lost its method to
magically look up accelerators to display. Somebody needs to add that
back later.
2020-03-25 23:14:28 -04:00
Benjamin Otte
8e9218df03 doc tools: Create AccelLabel image without using GtkAccelGroup 2020-03-25 23:14:28 -04:00
Emmanuele Bassi
541c478eeb testgtk: Port keyval example to shortcut controllers 2020-03-25 23:14:28 -04:00
Benjamin Otte
78e3e42042 shortcutcontroller: Implement GtkBuildable
Use it to allow adding shortcuts to the controller via the usual <child>
method.
2020-03-25 23:14:28 -04:00
Benjamin Otte
33045c3e0b shortcutaction: Integrate with GtkBuilder property parsing
<property name="action">action(win.quit)</property> style action
specifications now work for GtkShortcutAction properties.
2020-03-25 23:14:28 -04:00
Benjamin Otte
7974751e24 shortcuttrigger: Add gtk_shortcut_triger_new_parse_string()
And hook it up into the GtkBuilder infrastructure.
2020-03-25 23:14:28 -04:00
Benjamin Otte
daa7d9072d application: Replace accelerator handling with shortcuts
API remains the same, but activation is now done via a
shortcutcontroller.

The code uses a controller with global scope so that the
shortcuts are managed with all the other global shortcuts.
2020-03-25 23:14:28 -04:00
Benjamin Otte
90a34312d4 accel: Add display arg to gtk_accelerator_parse_with_keycode()
It was using the default display unconditionally.
2020-03-25 23:14:28 -04:00
Benjamin Otte
580863b112 accelerators: Make gtk_accelerator_parse() return TRUE/FALSE
A parse function should return success or not. So do that.
2020-03-25 23:14:28 -04:00
Benjamin Otte
fb6a8f5fc1 shortcuttrigger: Add hash(), equal(), and compare() functions
Those are useful for putting triggers in hash tables or getting sorted
output.
2020-03-25 23:14:28 -04:00
Matthias Clasen
c2e2e2993b shortcutmanager: Use list models 2020-03-25 23:14:28 -04:00
Matthias Clasen
5763514ab8 shortcutcontroller: Use a list model for shortcuts 2020-03-25 23:14:28 -04:00
Benjamin Otte
4c5d8547be shortcutaction: Add gtk_shortcut_action_to_string()
For all but the callback action, we can print something useful.
2020-03-25 23:14:27 -04:00
Matthias Clasen
34987c0b5c widget: Only create a controller if we have shortcuts
No point in creating objects that just hold empty lists.
2020-03-25 23:14:27 -04:00
Benjamin Otte
3cd4eb0310 widget: Keep keybindings as a GListStore
This way, we can use shortcut_controller_new_for_model() and avoid all
the special casing about run_class.
2020-03-25 23:14:27 -04:00
Benjamin Otte
a1e9ae5259 shortcutcontroller: Add gtk_shortcut_controller_new_for_model()
This is mainly for internal use, but I can't see a reason to not have it
public for people who want to maintain their own lists.

I'm sure gnome-builder will never ever find a way to misuse it.
2020-03-25 23:14:27 -04:00
Benjamin Otte
e738a4d129 shortcutcontroller: Implement GListModel
After all, this controller is a list of shortcuts.
2020-03-25 23:14:27 -04:00
Benjamin Otte
1ec950d14a gtk-demo: Port the sliding puzzle demo to shortcuts 2020-03-25 23:14:27 -04:00
Benjamin Otte
92e20deca1 shortcut: Change the API for creating shortcuts
When creating shortcuts, there almost always are a trigger and an action
available for use. So make gtk_shortcut_new() take those as arguments.

Also add gtk_shortcut_new_with_arguments() so people can easily pass
those in, too.
2020-03-25 23:14:27 -04:00
Benjamin Otte
cd0332aad5 shortcut: Add GtkShortcutAction
Similar to GtkShortcutTrigger, GtkShortCutAction provides all the
different ways to activate a shortcut.

So far, these different ways are supported:

 - do nothing
 - Call a user-provided callback
 - Call gtk_widget_activate()
 - Call gtk_widget_mnemonic_activate()
 - Emit an action signal
 - Activate an action from the widget's action muxer
2020-03-25 23:14:27 -04:00
Benjamin Otte
cdd33bbee6 accelgroup: Remove unneeded APIs
After the removal of GtkAccelMap, these things are no longer necessary.
2020-03-25 23:14:27 -04:00
Emmanuele Bassi
bca1f6b64f gtk: Remove GtkAccelMap
Now that accel paths are gone, the object managing them isn't needed
anymore either.
2020-03-25 23:14:27 -04:00
Benjamin Otte
9b99b89807 gtk: Remove accel paths
It's an outdated technology now that everybody is using GActionGroups.

If somebody wanted to support changeable shortcuts, they'd need to
reintroduce it in another way.
2020-03-25 23:14:27 -04:00
Benjamin Otte
62f96bfda6 Remove GtkMnemonicHash
It's not used anymore.
2020-03-25 23:14:27 -04:00
Emmanuele Bassi
2c62cde780 window: Remove all old mnemonic handling API 2020-03-25 23:14:27 -04:00
Emmanuele Bassi
aab10ea43b Add GtkShortcutManager
This adds an interface for taking care of shortcut controllers with
managed scope.

Only GtkWindow currently implements this interface, so we need to ensure
that we check if any top-level widget we reach is a shortcuts manager
before we call into it.
2020-03-25 23:14:27 -04:00
Benjamin Otte
9428807c57 label: Implement mnemonics using shortcuts 2020-03-25 23:14:27 -04:00
Benjamin Otte
21e6e4c026 shortcut: Add gtk_shortcut_set_mnemonic_activate()
Makes the shortcut call gtk_widget_mnemonic_activate() upon activation.
2020-03-25 23:14:27 -04:00
Benjamin Otte
bde4cbe377 shortcuttrigger: Add support for mnemonics
Mnemonics need to be triggered with help from the controllers (who
determine the modifiers). Support for that has been added, too.

Mnemonics do not use this yet though.
2020-03-25 23:14:27 -04:00
Benjamin Otte
0b7e74318b window: Put F10 accelerator into its own shortcut controller
So instead of relying on gtk_window_activate_key(), it's now using
proper infrastructure.
2020-03-25 23:14:27 -04:00
Benjamin Otte
e398f63bf6 window: Get rid of public APIs that shouldn't be
Event controllers should have replaced all of them.
And if they haven't, apps need to fix their code (I'm
looking at you Gimp).
2020-03-25 23:14:27 -04:00
Benjamin Otte
2244eeb727 gdk: Remove GDK_RELEASE_MASK
It was only ever supported by keybindings and those are gone now.
2020-03-25 23:14:27 -04:00
Benjamin Otte
c3af47f5d9 gtk-demo: Add a dumb demo for shortcut triggers 2020-03-25 23:14:27 -04:00
Benjamin Otte
730154df7d shortcutcontroller: Add GtkShortcutScope
Allow setting the scope for a controller. The scope determines at what
point in event propagation the shortcuts will be activated.

Local scope is the usual activation, global scope means that the root
widget activates the shortcuts - ie they are activated at the very
start of event propagation (for global capture events) or the very end
(for global bubble events).
Managed scope so far is unimplemented.

This is supposed to be used to replace accelerators and mnemonics.
2020-03-25 23:14:27 -04:00
Benjamin Otte
2309e1dd38 shortcuttrigger: Add gtk_shortcut_trigger_to_label()
Provide a user-presentable string.
2020-03-25 23:14:27 -04:00
Benjamin Otte
90c7f4608a accelgroup: Add gtk_accel_group_print_label() 2020-03-25 23:14:27 -04:00
Benjamin Otte
66102dacf1 accellabel: Move gtk_accelerator_get_label() code
The function lives in gtkaccelgroup.c, so there's no need to have that
call a private function in another source file. Instead, make that
other source file call gtk_accelerator_get_label() instead.
2020-03-25 23:14:27 -04:00
Benjamin Otte
d84b60e5f9 accellabel: Get rid of class variables
We can just look them up as-needed, no need to cache them.
2020-03-25 23:14:27 -04:00
Benjamin Otte
9a03c8b4d8 gtk: Remove bindings
The whole binding functionality is now handled by shortcuts.
2020-03-25 23:14:27 -04:00
Emmanuele Bassi
f02521c502 Remove bindings activation from GtkEventControllerKey
We're going to use shortcuts soon.
2020-03-25 22:36:03 -04:00
Matthias Clasen
c1247a7993 popover: Add keynav keybindings
The shortcut controllers are limited to same-native,
so we need to duplicate the Tab and arrow key bindings
for focus handling, as well as the Enter bindings for
activation.
2020-03-25 22:36:03 -04:00
Emmanuele Bassi
b2a747b4d4 popovermenu: Port to shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte
c1ee2fd54a accelgroup: Actually have a default mod mask
Don't just use a value without initializing it.
2020-03-25 22:36:03 -04:00
Benjamin Otte
4c7b00fd20 treeview: Redo event forwarding hack
Reorder the event controllers so that key forwarding to the search
entries really happens after shortcut triggering.
2020-03-25 22:36:03 -04:00
Benjamin Otte
3fba7f9dce combobox: Redo key event forwarding hack
Instead of manualling invoking bindings, we now reorder event
controllers inside the treemenu, so that shortcuts run before the event
forwarding.
2020-03-25 22:36:03 -04:00
Emmanuele Bassi
7ca4a94768 widget: Add private accessor to event controllers 2020-03-25 22:36:03 -04:00
Benjamin Otte
1df0a5eab5 iconview: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte
6a005c815e infobar: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte
cb09211ace label: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte
e430e0e2ff listbox: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte
6ad1078595 notebook: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte
cd7e9dcc27 scale: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte
8752f613d7 scalebutton: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte
f54d3a3aca scrolledwindow: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte
db525ef213 searchentry: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte
3f00e42ec9 shortcutssection: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte
d5fa5b9594 shortcutswindow: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte
2e5fc35e51 flowbox: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte
6ff94f3637 paned: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte
80888d7111 spinbutton: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte
48b46c8d08 textview: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte
df457cadfc filechooserwidget: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte
58e8f2332d shortcutcontroller: Add gtk_shortcut_controller_add_shortcut()
... and gtk_shortcut_controller_remove_shortcut().
2020-03-25 22:36:03 -04:00
Benjamin Otte
376dc4d169 shortcutcontroller: Add private API for running class shortcuts
We don't want regular users to be able to run class shortcuts in their
controllers, so we have to special case that.
2020-03-25 22:36:03 -04:00
Benjamin Otte
dfd81f9c64 treeview: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte
6d418134ee widget: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte
02646d74f4 dialog: Port binding to use shortcuts 2020-03-25 22:36:03 -04:00
Emmanuele Bassi
d62be573ad text: Port to widget shortcuts 2020-03-25 22:36:03 -04:00
Emmanuele Bassi
17eef48835 Allow installing bindings bound to actions
This is just convenience code around GtkShortcut, just like bindings for
signal emission and callback invocation.
2020-03-25 22:36:03 -04:00
Emmanuele Bassi
7ffea02eb4 shortcut: Add action activation 2020-03-25 22:36:03 -04:00
Emmanuele Bassi
0b75edc0e1 bindings: Export action activation internally
We're going to use it, just like we use the signal emission code.
2020-03-25 22:36:03 -04:00
Benjamin Otte
d4bba7de88 shortcut: Add gtk_shortcut_set_callback()
... and gtk_widget_class_add_binding() to go with it.

This allows shortcuts to invoke manually added callbacks.
2020-03-25 22:36:03 -04:00
Benjamin Otte
a8902da4bc assistant: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte
8ff18b3d39 combobox: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte
81fa63260e trigger: Add an alternative trigger
And use it.

I just added it to GtkWidget just to show that I can.
The real reason I want it is for gamepad/joystick triggers
in games, so that it becomes possible to select 2 different
triggers (gamepad and keyboard) for the same shortcut.
2020-03-25 22:36:03 -04:00
Matthias Clasen
6d452f1eb8 shortcut: Add GtkShortcutTrigger
Triggers are meant to describe how to trigger a shortcut.
So far only a keyval + modifiers trigger exists.
2020-03-25 22:36:03 -04:00
Benjamin Otte
d51b8ff058 window: Port bindings to use shortcuts 2020-03-25 22:36:03 -04:00
Benjamin Otte
b11263ae91 bindings: Add more variant types
Also marshal types that the code in gtkbindings.c doesn't use. These
will be used by gtk_widget_class_add_binding_signal().
2020-03-25 22:36:03 -04:00
Benjamin Otte
0eb1228902 widget: Add gtk_widget_class_add_shortcut()
This allows adding shortcuts as a replacement for keybindings.
2020-03-25 22:36:03 -04:00
Benjamin Otte
d8603864a9 gtk: Add GtkShortcut
This is the base class for what is about to take over all sorts of
keyboard shortcuts. The initial version barely deals with keybindings.
2020-03-25 22:36:03 -04:00
Benjamin Otte
f9ee703af4 bindings: Split out function to invoke an action signal
We want to use that in shortcuts later.
2020-03-25 22:36:03 -04:00
Benjamin Otte
a232107122 shortcutcontroller: Introduce
This is a very barebones controller that currently does nothing but
activate the binding signals. Yay.

And because we have bindings on every widget (Yes, a GtkGrid has a
keybinding - 2 in fact), we need that controller everywhere.
2020-03-25 22:36:03 -04:00
Benjamin Otte
27834b04ae bindings: Make gtk_binding_parse_signal() use GVariantBuilder
And because it's the last user of GtkBindingArg and
gtk_binding_entry_add_signall(), also remove those two.
2020-03-25 22:36:03 -04:00
Benjamin Otte
cbe207a8de bindings: Parse into GVariantBuilder directly
Avoids the indirection via GtkBindingArg
2020-03-25 22:36:03 -04:00
Benjamin Otte
1cab5e03ca bindings: Add gtk_binding_entry_add_signal_variant()
This function is the replacement for
gtk_binding_entry_add_signall().

The GVariant will be demarshalled and passed to the action signal upon
binding activation. The same rules apply as used to apply for
GtkBindingArg, in that long, double and string args are now replaced by
"x", "d" and "s" variant types.
2020-03-25 22:36:03 -04:00
Benjamin Otte
f8c523fa72 bindings: Replace GtkBindingArg arguments with GVariant
So far, this only replaces invocation, not yet parsing.
2020-03-25 22:36:03 -04:00
Matthias Clasen
e17db0abde Merge branch 'matthiasc/for-master2' into 'master'
Matthiasc/for master2

See merge request GNOME/gtk!1568
2020-03-26 02:30:54 +00:00
Matthias Clasen
cc9c45a47a Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1567
2020-03-26 01:54:30 +00:00
Emmanuele Bassi
a9c3a33620 passwordentry: Remove unused include 2020-03-25 21:53:12 -04:00
Emmanuele Bassi
f61d520ab1 entry: Remove unused include 2020-03-25 21:53:06 -04:00
Matthias Clasen
7672e6c833 text view: Fix touch selection
We forgot to allocated that popover.
2020-03-25 18:48:01 -04:00
Matthias Clasen
faf61cd112 event controller focus: drop include
This header is not needed here, and it is going away.
2020-03-25 18:47:54 -04:00
Matthias Clasen
1308ecb0ae flattenlistmodel: Give access to child models
Add an api to retrieve the model containing a given
item in a flatten listmodel. This is useful when the
individual items in the list don't have backpointers.
2020-03-25 18:47:46 -04:00
Matthias Clasen
4f6096947e Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1565
2020-03-25 21:48:38 +00:00
Matthias Clasen
dc18572a59 Merge branch 'wip/chergert/muxer-robustness-fix' into 'master'
muxer: force muxer dispoal as part of widget dispose

See merge request GNOME/gtk!1564
2020-03-25 21:34:56 +00:00
Matthias Clasen
8493ebfe98 filechoosererrorstack: Fix object life-cycle
Unparent children in dispose, not in finalize.
2020-03-25 17:04:29 -04:00
Matthias Clasen
5870d9d72a testsuite: Set NO_AT_BRIDGE for gtk tests
The a11y stack insists on spewing hard to control warnings
that make our tests fail. So, no accessibility for gtk tests :(
2020-03-25 17:03:58 -04:00
Christian Hergert
b5b836668a muxer: force muxer dispoal as part of widget dispose
We need to cleanup state here immediately so that we do not potentially
access the g_class private data after it been finalized. This ensures that
the borrowed reference is dropped by the muxer.
2020-03-25 14:02:59 -07:00
Timm Bäder
c155ac98c8 Merge branch 'wip/sadiq/fix-leak' into 'master'
singleselection: Fix a memory leak

See merge request GNOME/gtk!1554
2020-03-25 09:13:50 +00:00
Timm Bäder
600952e295 magnifier: Don't try to use a null widget paintable
We destroy the paintable in dispose, which can be called multiple times.
2020-03-24 10:44:06 +01:00
Timm Bäder
3b2adf5d1f inspector: Fix child widget life cycle
unparent them in dispose
2020-03-24 10:44:06 +01:00
Timm Bäder
56d99ab5cd Merge branch 'patch-2' into 'master'
gtkfilechoosernative: Remove duplicate "the" in the documentation

See merge request GNOME/gtk!1557
2020-03-24 06:08:26 +00:00
LingMan
29c9776daa gtkfilechoosernative: Remove duplicate "the" in the documentation 2020-03-24 04:58:13 +00:00
Marc-Antoine Perennou
eb8e0910c3 testsuite/gtk/flattenlistmodel.c: fix build
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2020-03-22 10:53:59 +01:00
Mohammed Sadiq
cfc44e09a0 singleselection: Fix a memory leak 2020-03-22 14:05:56 +05:30
Matthias Clasen
92b50c5e2a 3.98.1 2020-03-21 21:44:23 -04:00
Matthias Clasen
dabd09bc42 a11y: Don't re turn uninitialized memory
For some reason, this was now showing up in the
a11y tests as random image sizes in the about
dialog test.
2020-03-21 21:44:23 -04:00
Matthias Clasen
d7e5f5b368 Merge branch 'filechooser-popover-fixes' into 'master'
Filechooser popover fixes

See merge request GNOME/gtk!1553
2020-03-22 00:40:15 +00:00
Matthias Clasen
95209290c4 file chooser: Fix the rename file popover
Make this popover work again by attaching it
to the file chooser itself.
2020-03-21 20:14:23 -04:00
Matthias Clasen
90197240d3 filechooser: Fix the file list popover
Make this popover work again.
2020-03-21 20:00:15 -04:00
Matthias Clasen
6555a2f661 filechooser: Fix the new folder popover
We were listening for change notification on a
no-longer-existing property.
2020-03-21 19:32:08 -04:00
Matthias Clasen
a197b202b8 places sidebar: Fix the popovers
We need to check-resize the popovers.
2020-03-21 18:28:57 -04:00
Matthias Clasen
84e58aa393 Merge branch 'portal-dir-chooser' into 'master'
filechoosernativeportal: Allowing selecting folder(s)

See merge request GNOME/gtk!1552
2020-03-21 20:29:11 +00:00
Bastien Nocera
e99d1605dc filechoosernativeportal: Allowing selecting folder(s)
Use the "directory" portal option when asked to select folders.
2020-03-21 15:46:05 -04:00
Matthias Clasen
bf988f8d07 Merge branch 'portal-chooser-fail' into 'master'
portal file chooser: Handle errors

Closes #2527

See merge request GNOME/gtk!1551
2020-03-21 18:34:07 +00:00
Matthias Clasen
245851a6bb portal file chooser: Handle errors
Fall back to showing a local file chooser
if we get DBus errors from the portal.

Closes: #2527
2020-03-21 13:16:43 -04:00
Matthias Clasen
bb3dc16680 Merge branch 'fix-inspector-picking' into 'master'
inspector: Make picking work again

Closes #2528

See merge request GNOME/gtk!1549
2020-03-21 16:21:51 +00:00
Matthias Clasen
fceac594ae Merge branch 'fix-inspector-key' into 'master'
x11: Fix key event state translation

See merge request GNOME/gtk!1550
2020-03-21 14:47:29 +00:00
Matthias Clasen
abeabc39e8 x11: Fix key event state translation
In the event refactoring, a bit was lost.

This makes Ctrl-Shift-i work again to open
the inspector.
2020-03-21 10:26:11 -04:00
Matthias Clasen
fd58b116cf inspector: Make picking work again
We used to either make the inspector see- and click-thru
or lower it, but sadly translucency broke after we
removed surface opacity, and lowering doesn't work
on Wayland. So just hide the inspector window while
we are picking.

Fixes: #2528
2020-03-21 09:42:58 -04:00
Matthias Clasen
a67893fe5a Merge branch 'new-text-attributes' into 'master'
New text attributes

See merge request GNOME/gtk!1547
2020-03-21 05:56:22 +00:00
Matthias Clasen
9259efb5d7 Make overline support conditional
The ci image does not have Pango 1.45, so for the
time being, make the overline support conditional
on Pango being new enough.
2020-03-21 01:18:54 -04:00
Matthias Clasen
72f06abd13 Require pango 1.44.4
This lets use use the insert-hyphen attribute
unconditionally.
2020-03-21 00:39:17 -04:00
Matthias Clasen
923a245a80 gtk-demo: Add hyphenation control to the markup demo 2020-03-20 23:58:33 -04:00
Matthias Clasen
38f1dbaba3 gtk-demo: Allow word breaking in the markup demo
We want to show hyphenation control here.
2020-03-20 23:58:33 -04:00
Matthias Clasen
795ef5b4e3 textbuffer: Parse overline and hyphenation attributes
When inserting Pango markup into a text buffer, translate
Pango attributes for overlines and hyphenation control
into the corresponding text tag properties.
2020-03-20 23:58:23 -04:00
Matthias Clasen
fd9c911c3a textlayout: Handle new text tag properties
Translate tag properties for overlines and
hyphenation control into Pango attributes.
2020-03-20 23:58:23 -04:00
Matthias Clasen
a8c6ae6085 texttag: Support overline and hyphenation control
Add support for recently added Pango attributes
for overlines and hyphenation control. The new
properties of GtkTextTag are
overline, overline-rgba, allow-breaks, show-spaces
and insert-hyphens.
2020-03-20 23:58:23 -04:00
Carlos Garnacho
28e7a0a565 Merge branch 'master_MR1290' into 'master'
Copy of !1290 for master

Closes #2365

See merge request GNOME/gtk!1546
2020-03-20 20:20:41 +00:00
Matthias Clasen
7088bd18e6 Merge branch 'wip/chergert/fix-class-private-data-usage' into 'master'
Fix GtkWidgetClassPrivate data usage

See merge request GNOME/gtk!1545
2020-03-20 18:49:58 +00:00
Christian Hergert
ccac404f28 widget: fix class private data usage to be _init() safe
Before this commit, adding GtkWidgetAction to class private data would
require copying the actions to each subclass as they were built or
modified. This was convenient in that it is a sort of "copy on write"
semantic.

However, due to the way that GTypeInstance works with base _init()
functions, the "g_class" pointer in GTypeInstance is updated as each
_init() function is called. That means you cannot access the subclasses
class private data, but only the parent class private data.

If instead we use a singly linked list of GtkWidgetAction, each subclass
has their own "head" yet all subclasses share the tail of the
GtkWidgetAction chain.

This creates one bit of complexity though. You need a stable way to know
which "bit" is the "enabled" bit of the action so we can track enabled
GAction state. That is easily solved by calculating the distance to the
end of the chain for a given action so that base classes sort ahead of
subclasses. Since the parent class always knows its parent's actions, the
position is stable.

A new dynamic bitarray helper also helps us avoid allocations in all the
current cases (up to 64 actions per widget) and dynamically switches to
malloc if that is to ever be exceeded.
2020-03-20 11:17:56 -07:00
Christian Hergert
6822dce8fb widget: move class private data to gtkwidgetprivate.h
We want access to the private data from the action muxer so we can just
move the structures to the gtkwidgetprivate.h header. Alternatively we
could create accessors, but given that we'll probably need to use this
in other areas, seems reasonable to just put it there.
2020-03-20 11:17:56 -07:00
Matthias Clasen
5b2cdad19e Merge branch 'test-protocol' into 'master'
Test protocol: TAP

See merge request GNOME/gtk!1543
2020-03-20 18:12:09 +00:00
Matthias Clasen
c7caa53917 testsuite: disable performance tests
For some reason, these tests are flaky in ci,
they always work locally for me. So, until
we use the data these tests produce for something,
lets just turn them off.
2020-03-20 13:47:58 -04:00
Matthias Clasen
fa4be719d8 Merge branch 'wip/carlosg/text-handle-natives' into 'master'
Make text handles use native surfaces

See merge request GNOME/gtk!1487
2020-03-20 17:29:17 +00:00
Alexandr Miloslavskiy
32f088e335 gkimmulticontext: Fix crash due to leaked signal handler
The problem is caused by gtk_im_multicontext_set_slave(), which forgets
to disconnect these signal handlers:
* gtk_im_multicontext_retrieve_surrounding_cb
* gtk_im_multicontext_delete_surrounding_cb

If slave GtkImContext emits signal after GtkIMMulticontext context is
destroyed, this leads to reading freed memory, sometimes causing a crash.

Fixes: #2365
2020-03-20 18:02:22 +01:00
Emmanuele Bassi
cb81e3ee47 Merge branch 'ci-dbus-launch' into 'master'
ci: Add dbus-launch to the Docker build

See merge request GNOME/gtk!1544
2020-03-20 16:13:07 +00:00
Matthias Clasen
9eda683060 testsuite: Fix an a11y test
The derive test wasn't producing TAP, so
running it as part of a tap testsuite wasn't
going well. Fix that.
2020-03-20 12:09:21 -04:00
Matthias Clasen
cbb0ca4902 testsuite: Tell meson we use TAP
This makes meson actually parse the individual test
results. Most of the time, it does not make a difference,
but one case where it does is when all the individual
tests of a binary are skipped, meson will mark the
test as skipped.
2020-03-20 11:55:26 -04:00
Matthias Clasen
9403f44aef reftests: Fix an xfail to work
The background-image-multiple.ref.ui file uses
non-existing properties, which gives us a g_warning,
and the glib test framework insists on treating
warnings as fatal, so we end up doing exit(133),
which in turn makes the meson TAP parser ignore
its xfails.

Comment out the nonexisting properties, so we can
fail properly, and then in turn xfail properly.
2020-03-20 11:55:26 -04:00
Matthias Clasen
dc4b7131f1 testsuite: Don't exit unsuccessfully when using TAP
The meson TAP parser doesn't take this lightly and
forgets all about xfails when we exit(1), so don't.
2020-03-20 11:55:26 -04:00
Emmanuele Bassi
bf6087f2da ci: Add dbus-launch to the Docker build 2020-03-20 15:36:39 +00:00
Carlos Garnacho
23f03ca1f2 gtktextview: Set magnifier popover on top
At the bottom, it sometimes has to fight for the same position than
text handles, besides might not be ergonomically convenient (eg.
finger/hand partly covering the popover). Move it at the top to fix
both.
2020-03-20 15:52:19 +01:00
Carlos Garnacho
54a4a18bcf gtktext: Set magnifier popover on top
At the bottom, it sometimes has to fight for the same position than
text handles, besides might not be ergonomically convenient (eg.
finger/hand partly covering the popover). Move it at the top to fix
both.
2020-03-20 15:52:19 +01:00
Carlos Garnacho
9a0b70fc84 gtkpopover: Re-present surface if position/pointing-to change while visible
This ensures the popover will follow the new position parameters. This is
necessary for popovers like the text magnifier that can be repositioned
while visible.
2020-03-20 15:52:19 +01:00
Carlos Garnacho
6431bdcf91 gtkpopover: Ensure the pointed to rectangle has a minimum w/h
On wayland, protocol errors will be raised if the rectangle width/height
are 0. Avoid that situation so it's valid to all popovers.
2020-03-20 15:52:19 +01:00
Carlos Garnacho
0f73e83f44 gtkwindow: Remove internal popover API
This was only used by text handles, and not anymore.
2020-03-20 15:52:19 +01:00
Carlos Garnacho
0264a64f29 gtktexthandle: Refactor and use native surfaces
Instead of being a GObject managing two GtkWidgets, make GtkTextHandle
a GtkWidget subclass, representing a single handle.

From the perspective of users (GtkText and GtkTextView), this is not a
big leap since they have to be aware of a great deal of text handles'
state. It actually makes things more direct and simple.

With text handles being widgets, those can be actual children of the
widget, and may have their own GdkSurface that we move around at will.
This is the second major aspect of this refactor.
2020-03-20 15:52:19 +01:00
Matthias Clasen
c893f79023 reftests: Don't run tests with --verbose
Unexpected output tends to break TAP.
2020-03-20 10:43:25 -04:00
Matthias Clasen
68e1c8d3e9 gsk: Don't unconditionally spew to stdout 2020-03-20 10:43:25 -04:00
Matthias Clasen
cf7dc5b2bb testsuite: Don't g_print from tests
This breaks the TAP output.
2020-03-20 10:03:04 -04:00
Matthias Clasen
068ec58287 testsuite: Fix the accessible test
This test was happily doing nothing.
2020-03-20 10:03:04 -04:00
Matthias Clasen
2747dd5c9f Merge branch 'disable-window-test-2' into 'master'
Disable window test 2

See merge request GNOME/gtk!1541
2020-03-20 13:42:38 +00:00
Matthias Clasen
f6fc3073fb temporarily disable window test
This test was broken by the GdkToplevel refactoring,
and needs a big gtkwindow.c configure request cleanup
before it will work again.
2020-03-19 18:08:06 -04:00
Matthias Clasen
31db615885 Revert "Merge branch 'disable-window-test' into 'master'"
This reverts commit 3ac4c76b18, reversing
changes made to 6ec96d2e98.
2020-03-19 18:03:16 -04:00
Matthias Clasen
3ac4c76b18 Merge branch 'disable-window-test' into 'master'
Disable window test

See merge request GNOME/gtk!1540
2020-03-19 19:35:42 +00:00
Matthias Clasen
89b537bd8a Fix the action test
We have a test that enumerates the GtkText actions,
so when a new open appears, the test needs to be updated.
2020-03-19 14:29:37 -04:00
Matthias Clasen
7d5cfcf61d Fix a compiler warning 2020-03-19 14:13:26 -04:00
Matthias Clasen
2e70b4c323 temporarily disable window test
This test was broken by the GdkToplevel refactoring,
and needs a big gtkwindow.c configure request cleanup
before it will work again.
2020-03-19 11:25:38 -04:00
Matthias Clasen
fcab0943bf text view: Fix touch selection
We forgot to allocated that popover.
2020-03-19 09:46:53 -04:00
Matthias Clasen
c8fd6407a8 widget: Drop the ::popup-menu signal
This is now done in widgets which have context
menus.
2020-03-19 00:56:46 -04:00
Matthias Clasen
53f29ba427 placesview: Stop using ::popup-menu
This signal is going away.
2020-03-19 00:54:23 -04:00
Matthias Clasen
eb3f4b302f filechooser: Stop using ::popup-menu
This signal is going away.
2020-03-19 00:24:53 -04:00
Matthias Clasen
59df45f3f7 mountoperation: Stop using ::popup-menu
We can just use a shortcut controller directly.
2020-03-18 23:00:51 -04:00
Matthias Clasen
98011e6273 gtk-demo: Stop emitting ::popup-menu
The signal was not used anyway, in the font explorer demo.
2020-03-18 23:00:51 -04:00
Matthias Clasen
f40965cc40 colorchooser: Stop using ::popup-menu
This signal is going away. Use an action instead.
2020-03-18 23:00:51 -04:00
Matthias Clasen
ab9b094f80 range: Remove ::popup-menu emission
This signal is going away, and having context menus
on sliders is not really a thing anyway.
2020-03-18 23:00:51 -04:00
Matthias Clasen
4bc60c6110 scrollbar: Remove :popup-menu forwarding
This signal is going away.
2020-03-18 23:00:51 -04:00
Matthias Clasen
48ace13635 emojichooser: Stop using ::popup-menu
This signal is going away. Use an action instead.
2020-03-18 23:00:51 -04:00
Matthias Clasen
908d996b4f Use an action for the context menu keybinding
The ::popup-menu signal is going away.
2020-03-18 23:00:51 -04:00
Matthias Clasen
4e263b4042 Print mnemonic triggers clearly 2020-03-18 23:00:51 -04:00
Matthias Clasen
f5134a833c inspector: Show shortcuts
At a tab that lists the shortcuts contained in a
GtkShortcutController.
2020-03-18 23:00:51 -04:00
Matthias Clasen
f7021e80a7 Only create a class shortcut controller if we have shortcuts
No point in creating objects that just hold empty lists.
2020-03-18 23:00:51 -04:00
Matthias Clasen
3e7d49a8d3 widget: Name the controllers 2020-03-18 23:00:51 -04:00
Matthias Clasen
5a6533d8fb window: Name the the controllers 2020-03-18 23:00:51 -04:00
Matthias Clasen
5a6a9dc149 shortcutmanager: Name the controllers
This is helpful in the inspector.
2020-03-18 23:00:51 -04:00
Matthias Clasen
ad69899a9d Move shortcut manager initialization code
It is just too ugly to use quarks across multiple
source files, so add a private helper function that
attaches the controllers.
2020-03-18 23:00:51 -04:00
Benjamin Otte
3cf56817e7 filechooser: Trigger the location popup via bindings
Simplifies code quite a bit.
2020-03-18 23:00:51 -04:00
Benjamin Otte
ff6df33b6a accels: Remove GtkAccelGroup 2020-03-18 23:00:51 -04:00
Benjamin Otte
e944514664 testmenubutton: Don't create a GtkAccelGroup
It's unused.
2020-03-18 23:00:51 -04:00
Benjamin Otte
93bb3f7144 testsuite: Remove GtkAccelGroup usage 2020-03-18 23:00:51 -04:00
Benjamin Otte
17d9ba362c widget: Remove gtk_widget_add_accelerator()
People should use shortcut controllers instead (global, capture).

A side effect of this is that GtkAccelLabel now lost its method to
magically look up accelerators to display. Somebody needs to add that
back later.
2020-03-18 23:00:51 -04:00
Benjamin Otte
b685d2c00a doc tools: Create AccelLabel image without using GtkAccelGroup 2020-03-18 23:00:51 -04:00
Emmanuele Bassi
1a55f59f23 testgtk: Port keyval example to shortcut controllers 2020-03-18 23:00:51 -04:00
Benjamin Otte
29ced09dc4 shortcutcontroller: Implement GtkBuildable
Use it to allow adding shortcuts to the controller via the usual <child>
method.
2020-03-18 23:00:51 -04:00
Benjamin Otte
458fcba457 shortcutaction: INtegrate with GtkBuilder property parsing
<property name="action">action(win.quit)</property> style action
specifications now work for GtkShortcutAction properties.
2020-03-18 23:00:51 -04:00
Benjamin Otte
5218dd6a34 shortcuttrigger: Add gtk_shortcut_triger_new_parse_string()
And hook it up into the GtkBuilder infrastructure.
2020-03-18 23:00:51 -04:00
Benjamin Otte
df792a088d application: Replace accelerator handling with shortcuts
API remains the same, but activation is now done via a
shortcutcontroller.

The code uses a controller with global scope so that the
shortcuts are managed with all the other global shortcuts.
2020-03-18 23:00:51 -04:00
Benjamin Otte
94ef20ea36 accel: Add display arg to gtk_accelerator_parse_with_keycode()
It was using the default display unconditionally.
2020-03-18 23:00:51 -04:00
Benjamin Otte
87df17e4ce accelerators: Make gtk_accelerator_parse() return TRUE/FALSE
A parse function should return success or not. So do that.
2020-03-18 23:00:51 -04:00
Benjamin Otte
673a0463e0 shortcuttrigger: Add hash(), equal(), and compare() functions
Those are useful for putting triggers in hash tables or getting sorted
output.
2020-03-18 23:00:51 -04:00
Benjamin Otte
0c81698911 shortcuts: Mananage managed shortcuts with a custom model
Reduce the amount of special casing by using a list model
for global and managed shortcuts, too.

This way, the ListModel API will work for the ShortcutController in the
GtkShortcutManager and GtkRoot.

The only special case remaining is shortcut activation, which needs to
pass the right widget to the controller in the global/managed case.
2020-03-18 23:00:51 -04:00
Benjamin Otte
a10a295515 shortcutaction: Add gtk_shortcut_action_to_string()
For all but the callback action, we can print something useful.
2020-03-18 23:00:51 -04:00
Benjamin Otte
3b595f5720 widget: Keep keybindings as a GListStore
This way, we can use shortcut_controller_new_for_model() and avoid all
the special casing about run_class.
2020-03-18 23:00:51 -04:00
Benjamin Otte
d14807b93d shortcutcontroller: Add gtk_shortcut_controller_new_for_model()
This is mainly for internal use, but I can't see a reason to not have it
public for people who want to maintain their own lists.

I'm sure gnome-builder will never ever find a way to misuse it.
2020-03-18 23:00:51 -04:00
Benjamin Otte
538a1a0461 shortcutcontroller: Implement GListModel
After all, this controller is a list of shortcuts.
2020-03-18 23:00:51 -04:00
Benjamin Otte
067bd7019c gtk-demo: Port the sliding puzzle demo to shortcuts 2020-03-18 23:00:51 -04:00
Benjamin Otte
4a4bfa0766 shortcut: Change the API for creating shortcuts
When creating shortcuts, there almost always are a trigger and an action
available for use. So make gtk_shortcut_new() take those as arguments.

Also add gtk_shortcut_new_with_arguments() so people can easily pass
those in, too.
2020-03-18 23:00:51 -04:00
Benjamin Otte
e6d0560a82 shortcut: Add GtkShortcutAction
Similar to GtkShortcutTrigger, GtkShortCutAction provides all the
different ways to activate a shortcut.

So far, these different ways are supported:

 - do nothing
 - Call a user-provided callback
 - Call gtk_widget_activate()
 - Call gtk_widget_mnemonic_activate()
 - Emit an action signal
 - Activate an action from the widget's action muxer
 - Activate a GAction
2020-03-18 23:00:51 -04:00
Benjamin Otte
4d0bab0c24 accelgroup: Remove unneeded APIs
After the removal of GtkAccelMap, these things are no longer necessary.
2020-03-18 23:00:51 -04:00
Emmanuele Bassi
b28da74e90 gtk: Remove GtkAccelMap
Now that accel paths are gone, the object managing them isn't needed
anymore either.
2020-03-18 23:00:51 -04:00
Benjamin Otte
ba3882de83 gtk: Remove accel paths
It's an outdated technology now that everybody is using GActionGroups.

If somebody wanted to support changeable shortcuts, they'd need to
reintroduce it in another way.
2020-03-18 23:00:51 -04:00
Benjamin Otte
20cfa2e280 Remove GtkMnemonicHash
It's not used anymore.
2020-03-18 23:00:51 -04:00
Emmanuele Bassi
a977094e18 window: Remove all old mnemonic handling API 2020-03-18 23:00:51 -04:00
Emmanuele Bassi
09400b6bfe Add GtkShortcutManager
This adds an interface for taking care of shortcut controllers with
managed scope.

Only GtkWindow currently implements this interface, so we need to ensure
that we check if any top-level widget we reach is a shortcuts manager
before we call into it.
2020-03-18 23:00:50 -04:00
Benjamin Otte
bbe98d9f7c label: Implement mnemonics using shortcuts 2020-03-18 23:00:50 -04:00
Benjamin Otte
ab681b0e05 shortcut: Add gtk_shortcut_set_mnemonic_activate()
Makes the shortcut call gtk_widget_mnemonic_activate() upon activation.
2020-03-18 23:00:50 -04:00
Benjamin Otte
ef40f22632 shortcuttrigger: Add support for mnemonics
Mnemonics need to be triggered with help from the controllers (who
determine the modifiers). Support for that has been added, too.

Mnemonics do not use this yet though.
2020-03-18 23:00:50 -04:00
Benjamin Otte
bea2dcef8f window: Put F10 accelerator into its own shortcut controller
So instead of relying on gtk_window_activate_key(), it's now using
proper infrastructure.
2020-03-18 23:00:50 -04:00
Benjamin Otte
cc13b47542 window: Get rid of public APIs that shouldn't be
Event controllers should have replaced all of them.
And if they haven't, apps need to fix their code (I'm
looking at you Gimp).
2020-03-18 23:00:50 -04:00
Benjamin Otte
8c23ccd86e gdk: Remove GDK_RELEASE_MASK
It was only ever supported by keybindings and those are gone now.
2020-03-18 23:00:50 -04:00
Benjamin Otte
662a8a2885 gtk-demo: Add a dumb demo for shortcut triggers 2020-03-18 23:00:50 -04:00
Benjamin Otte
d4127fe0d4 shortcutcontroller: Add GtkShortcutScope
Allow setting the scope for a controller. The scope determines at what
point in event propagation the shortcuts will be activated.

Local scope is the usual activation, global scope means that the root
widget activates the shortcuts - ie they are activated at the very
start of event propagation (for global capture events) or the very end
(for global bubble events).
Managed scope so far is unimplemented.

This is supposed to be used to replace accelerators and mnemonics.
2020-03-18 23:00:50 -04:00
Benjamin Otte
22801f0d4d shortcuttrigger: Add gtk_shortcut_trigger_to_label()
Provide a user-presentable string.
2020-03-18 23:00:50 -04:00
Benjamin Otte
e050288d07 accelgroup: Add gtk_accel_group_print_label() 2020-03-18 23:00:50 -04:00
Benjamin Otte
93af53a2fc accellabel: Move gtk_accelerator_get_label() code
The function lives in gtkaccelgroup.c, so there's no need to have that
call a private function in another source file. Instead, make that
other source file call gtk_accelerator_get_label() instead.
2020-03-18 23:00:50 -04:00
Benjamin Otte
e2a0ed4fcb accellabel: Get rid of class variables
We can just look them up as-needed, no need to cache them.
2020-03-18 23:00:50 -04:00
Benjamin Otte
fb99f834e6 gtk: Remove bindings
The whole binding functionality is now handled by shortcuts.
2020-03-18 23:00:50 -04:00
Matthias Clasen
a062b96051 event controller focus: drop include
This header is not needed here, and it is going away.
2020-03-18 23:00:50 -04:00
Emmanuele Bassi
5033fc62f2 Remove bindings activation from GtkEventControllerKey
We're going to use shortcuts soon.
2020-03-18 23:00:50 -04:00
Emmanuele Bassi
bdde072c06 popover: Remove unused include 2020-03-18 23:00:50 -04:00
Matthias Clasen
f7a4d968e9 popover: Add keynav keybindings
The shortcut controllers are limited to same-native,
so we need to duplicate the Tab and arrow key bindings
for focus handling, as well as the Enter bindings for
activation.
2020-03-18 23:00:50 -04:00
Emmanuele Bassi
252030ba59 popovermenu: Port to shortcuts 2020-03-18 23:00:50 -04:00
Emmanuele Bassi
f24cf29326 passwordentry: Remove unused include 2020-03-18 23:00:50 -04:00
Emmanuele Bassi
9b1d593967 entry: Remove unused include 2020-03-18 23:00:50 -04:00
Benjamin Otte
4e3ac8f52b accelgroup: Actually have a default mod mask
Don't just use a value without initializing it.
2020-03-18 23:00:50 -04:00
Benjamin Otte
7f10641fd9 treeview: Redo event forwarding hack
Reorder the event controllers so that key forwarding to the search
entries really happens after shortcut triggering.
2020-03-18 23:00:50 -04:00
Benjamin Otte
3ef6be0d25 combobox: Redo key event forwarding hack
Instead of manualling invoking bindings, we now reorder event
controllers inside the treemenu, so that shortcuts run before the event
forwarding.
2020-03-18 23:00:50 -04:00
Emmanuele Bassi
56595e7529 widget: Add private accessor to event controllers 2020-03-18 23:00:50 -04:00
Benjamin Otte
4b798e238f iconview: Port bindings to use shortcuts 2020-03-18 23:00:50 -04:00
Benjamin Otte
718faf68ac infobar: Port bindings to use shortcuts 2020-03-18 23:00:50 -04:00
Benjamin Otte
83dc9dabed label: Port bindings to use shortcuts 2020-03-18 23:00:50 -04:00
Benjamin Otte
051f7e4118 listbox: Port bindings to use shortcuts 2020-03-18 23:00:50 -04:00
Benjamin Otte
cbeb096bb3 notebook: Port bindings to use shortcuts 2020-03-18 23:00:50 -04:00
Benjamin Otte
bf7c51cc11 scale: Port bindings to use shortcuts 2020-03-18 23:00:50 -04:00
Benjamin Otte
3803209330 scalebutton: Port bindings to use shortcuts 2020-03-18 23:00:50 -04:00
Benjamin Otte
fb7d1095d1 scrolledwindow: Port bindings to use shortcuts 2020-03-18 23:00:50 -04:00
Benjamin Otte
45ec453b76 searchentry: Port bindings to use shortcuts 2020-03-18 23:00:50 -04:00
Benjamin Otte
e4d628b410 shortcutssection: Port bindings to use shortcuts 2020-03-18 23:00:50 -04:00
Benjamin Otte
e11d799460 shortcutswindow: Port bindings to use shortcuts 2020-03-18 23:00:50 -04:00
Benjamin Otte
6e38af4429 flowbox: Port bindings to use shortcuts 2020-03-18 23:00:50 -04:00
Benjamin Otte
a70635f760 paned: Port bindings to use shortcuts 2020-03-18 23:00:50 -04:00
Benjamin Otte
2c91f15f6d spinbutton: Port bindings to use shortcuts 2020-03-18 23:00:50 -04:00
Benjamin Otte
bad5ee7ed9 textview: Port bindings to use shortcuts 2020-03-18 23:00:50 -04:00
Benjamin Otte
277aaab041 filechooserwidget: Port bindings to use shortcuts 2020-03-18 23:00:50 -04:00
Benjamin Otte
5ade831cd1 shortcutcontroller: Add gtk_shortcut_controller_add_shortcut()
... and gtk_shortcut_controller_remove_shortcut().
2020-03-18 23:00:50 -04:00
Benjamin Otte
3b8a4340da shortcutcontroller: Add private API for running class shortcuts
We don't want regular users to be able to run class shortcuts in their
controllers, so we have to special case that.
2020-03-18 23:00:49 -04:00
Benjamin Otte
ae11b29ee7 treeview: Port bindings to use shortcuts 2020-03-18 23:00:49 -04:00
Benjamin Otte
ac31979805 widget: Port bindings to use shortcuts 2020-03-18 23:00:49 -04:00
Benjamin Otte
0b4d0f4d31 dialog: Port binding to use shortcuts 2020-03-18 23:00:49 -04:00
Emmanuele Bassi
00bc9e6b85 text: Port to widget shortcuts 2020-03-18 23:00:49 -04:00
Emmanuele Bassi
d75fd59ddf Allow installing bindings bound to actions
This is just convenience code around GtkShortcut, just like bindings for
signal emission and callback invocation.
2020-03-18 23:00:49 -04:00
Emmanuele Bassi
84a52e3bbd shortcut: Add action activation 2020-03-18 23:00:49 -04:00
Emmanuele Bassi
9687d69b5a bindings: Export action activation internally
We're going to use it, just like we use the signal emission code.
2020-03-18 23:00:49 -04:00
Benjamin Otte
b18f9da807 shortcut: Add gtk_shortcut_set_callback()
... and gtk_widget_class_add_binding() to go with it.

This allows shortcuts to invoke manually added callbacks.
2020-03-18 23:00:49 -04:00
Benjamin Otte
6c13bbb441 combobox: Port bindings to use shortcuts 2020-03-18 23:00:49 -04:00
Benjamin Otte
4f128a4a21 assistant: Port bindings to use shortcuts 2020-03-18 23:00:49 -04:00
Benjamin Otte
e62154c91f trigger: Add an alternative trigger
And use it.

I just added it to GtkWidget just to show that I can.
The real reason I want it is for gamepad/joystick triggers
in games, so that it becomes possible to select 2 different
triggers (gamepad and keyboard) for the same shortcut.
2020-03-18 23:00:49 -04:00
Matthias Clasen
78f9940ddc shortcut: Add GtkShortcutTrigger
Triggers are meant to describe how to trigger a shortcut.
So far only a keyval + modifiers trigger exists.
2020-03-18 23:00:49 -04:00
Benjamin Otte
0f6c5da28d window: Port bindings to use shortcuts 2020-03-18 23:00:49 -04:00
Benjamin Otte
c7f10e570e bindings: Add more variant types
Also marshal types that the code in gtkbindings.c doesn't use. These
will be used by gtk_widget_class_add_binding_signal().
2020-03-18 23:00:49 -04:00
Benjamin Otte
e19b49f5aa widget: Add gtk_widget_class_add_shortcut()
This allows adding shortcuts as a replacement for keybindings.
2020-03-18 23:00:49 -04:00
Benjamin Otte
ff13ee4b66 gtk: Add GtkShortcut
This is the base class for what is about to take over all sorts of
keyboard shortcuts. The initial version barely deals with keybindings.
2020-03-18 23:00:49 -04:00
Benjamin Otte
fed7d3833f bindings: Split out function to invoke an action signal
We want to use that in shortcuts later.
2020-03-18 23:00:49 -04:00
Benjamin Otte
5c6be5c0cd shortcutcontroller: Introduce
This is a very barebones controller that currently does nothing but
activate the binding signals. Yay.

And because we have bindings on every widget (Yes, a GtkGrid has a
keybinding - 2 in fact), we need that controller everywhere.
2020-03-18 23:00:49 -04:00
Benjamin Otte
06660874ee bindings: Make gtk_binding_parse_signal() use GVariantBuilder
And because it's the last user of GtkBindingArg and
gtk_binding_entry_add_signall(), also remove those two.
2020-03-18 23:00:49 -04:00
Benjamin Otte
4675d74e42 bindings: Parse into GVariantBuilder directly
Avoids the indirection via GtkBindingArg
2020-03-18 23:00:49 -04:00
Benjamin Otte
3b3a5c2d53 bindings: Add gtk_binding_entry_add_signal_variant()
This function is the replacement for
gtk_binding_entry_add_signall().

The GVariant will be demarshalled and passed to the action signal upon
binding activation. The same rules apply as used to apply for
GtkBindingArg, in that long, double and string args are now replaced by
"x", "d" and "s" variant types.
2020-03-18 23:00:49 -04:00
Benjamin Otte
385c5e0569 bindings: Replace GtkBindingArg arguments with GVariant
This only replaces invocation, not yet parsing.
2020-03-18 23:00:49 -04:00
Matthias Clasen
6ec96d2e98 Merge branch 'wip/chergert/speedup-char_is_invisible' into 'master'
textbtree: short-circuit visibility check when possible

See merge request GNOME/gtk!1534
2020-03-19 01:20:21 +00:00
Christian Hergert
6c8d47f585 textbtree: short-circuit visibility check when possible
If we have never seen a GtkTextTag in the GtkTextTagTable with the
invisible bit set, then we do not need to go through the process of
checking the accumulated tags.

Not using invisible tags is overwhelmingly the common case.
2020-03-18 11:32:46 -07:00
Matthias Clasen
1bc1b82256 Merge branch 'wip/jimmac/adwaitadark-lighten-switches' into 'master'
Adwaita: dark switches/check/radios

Closes #2461

See merge request GNOME/gtk!1532
2020-03-18 12:28:15 +00:00
Matthias Clasen
89c0df6cb7 Merge branch 'wip/chergert/textview-fix-gdk_event_unref' into 'master'
textview: use gdk_event_unref()

Closes #2520

See merge request GNOME/gtk!1531
2020-03-18 12:27:08 +00:00
Jakub Steiner
c91dd2cb45 Adwaita: dark switches/check/radios
- lighten up radios, switches and checkboxes

Fixes https://gitlab.gnome.org/GNOME/gtk/issues/2461
2020-03-18 13:01:17 +01:00
Matthias Clasen
3408ff1dd7 emojichooser: Fix keynav
Make arrow and tab keys work in the
variations popover again.
2020-03-17 21:49:29 -04:00
Matthias Clasen
7a46157edf window: Set min size properly
When we are mapping the window, we need to compute
a proper min size, otherwise the 1, 1 sticks and
makes all windows shrinkable to nothing.
2020-03-17 20:46:57 -04:00
Matthias Clasen
01568dc915 Revert "Adwaita: dark switches/check/radios"
This reverts commit 435992600f.

This causes warnings from the CSS parser.
2020-03-17 20:32:23 -04:00
Matthias Clasen
6eb848f0e0 popover: Add keynav keybindings
The shortcut controllers are limited to same-native,
so we need to duplicate the Tab and arrow key bindings
for focus handling, as well as the Enter bindings for
activation.
2020-03-17 20:15:26 -04:00
Christian Hergert
e4578b15c3 textview: use gdk_event_unref()
Fixes #2520
2020-03-17 13:24:03 -07:00
Matthias Clasen
8fab4ceebb Assorted migration guide updates
Mention GdkEvent, GdkPopup, GdkToplevel, GtkIconTheme
changes.
2020-03-17 16:23:03 -04:00
Jakub Steiner
826f237782 Merge branch 'wip/jimmac/adwaitadark-lighten-switches' 2020-03-17 11:05:26 +01:00
Jakub Steiner
435992600f Adwaita: dark switches/check/radios
- lighten up radios, switches and checkboxes

Fixes https://gitlab.gnome.org/GNOME/gtk/issues/2461
2020-03-17 11:03:28 +01:00
Matthias Clasen
5d4b46b2d8 Merge branch 'emoji-chooser-fixes' into 'master'
Emoji chooser fixes

See merge request GNOME/gtk!1530
2020-03-17 05:12:12 +00:00
Matthias Clasen
292cea7310 Adwaita: Fix focus in emoji chooser 2020-03-17 00:28:57 -04:00
Matthias Clasen
4d7f0f330b emojichooser: Make the variation picker work again
We can't attach popovers to unsuspecting widget anymore.
2020-03-17 00:07:37 -04:00
Emmanuele Bassi
5bf51adcce Merge branch 'respect-text-len-gtk4' into 'master'
imcontextwayland: Honour len argument in gtk_im_context_wayland_set_surrounding

See merge request GNOME/gtk!1529
2020-03-16 17:08:53 +00:00
Robert Mader
5343ec3345 imcontextwayland: Honour len argument in gtk_im_context_wayland_set_surrounding
Clients may pass not `NULL`-terminated strings as the function takes a
`len` argument. Use that argument.
2020-03-16 16:53:33 +01:00
Matthias Clasen
c6cc02637e Merge branch 'x11-props' into 'master'
Drop X11-specific properties

See merge request GNOME/gtk!1526
2020-03-15 00:47:03 +00:00
Matthias Clasen
1576cced0f Drop GdkToplevel:accept-focus/:focus-on-map
These properties were only ever implemented in the
X11 backend. If you want to use them, just use the
X properties directly.
2020-03-14 19:28:00 -04:00
Matthias Clasen
c9ec1c6af1 Drop focus-related properties
We don't use these, and they are only implemented on X11.
2020-03-14 19:28:00 -04:00
Matthias Clasen
32b9dd64db Drop GdkToplevel:keep-above/below
These properties were only ever implemented in the X11
backend. If you want to keep windows above or below
on X11, just use the X properties.
2020-03-14 15:46:55 -04:00
Matthias Clasen
6f156dad7f window: Drop keep above/below 2020-03-14 15:16:56 -04:00
Matthias Clasen
103ef3c195 tests: Stop using keep above/below 2020-03-14 15:16:56 -04:00
Matthias Clasen
60ea97187a Drop GdkToplevel:sticky
This was only ever implemented on X11. If you
want to use it there, just use the X properties
yourself.
2020-03-14 15:16:18 -04:00
Matthias Clasen
fb7ef8f62c window: Drop sticky
This is an X11-only concept that we don't have
on Wayland.
2020-03-14 14:34:39 -04:00
Matthias Clasen
d4f49a8cb9 tests: Stop sticking windows 2020-03-14 14:34:39 -04:00
Matthias Clasen
951f821d6a Merge branch 'window-attach' into 'master'
window: Drop gtk_window_set_attached_to

See merge request GNOME/gtk!1527
2020-03-14 13:19:35 +00:00
Matthias Clasen
dfda88038e window: Drop gtk_window_set_attached_to
We are no longer attaching windows to widgets.
2020-03-14 02:00:10 -04:00
Matthias Clasen
50c2b80c74 gdk: Documentation fixes 2020-03-14 01:23:56 -04:00
Matthias Clasen
0d3df4fb1d Document gdk_toplevel_set_modal 2020-03-14 01:23:09 -04:00
Matthias Clasen
4be675b0c9 Small documentation fixes 2020-03-14 01:22:31 -04:00
Matthias Clasen
0c25b4cfa8 Update gtk docs
Updates for recent api renames and removals.
2020-03-14 01:15:07 -04:00
Matthias Clasen
c2e5aed874 NEWS: Updates 2020-03-14 00:59:16 -04:00
Matthias Clasen
60a9e9d342 Merge branch 'x11-resize' into 'master'
x11: Update surface size for popups too

See merge request GNOME/gtk!1525
2020-03-14 03:35:31 +00:00
Matthias Clasen
8010bc4596 x11: Update surface size for popups too
Without this, the back buffers of the wrong size
keep being used, causing flickery misdraws, as
seen when expanding the expander in the popover
in widget-factory.
2020-03-13 21:33:23 -04:00
Matthias Clasen
33db28c288 Merge branch 'fix-tools-tests' into 'master'
Fix tools tests

See merge request GNOME/gtk!1524
2020-03-13 20:36:54 +00:00
Matthias Clasen
7db490ef2a testsuite: Specify the test protocol
If we don't specify protocol: 'tap', meson things
all is good even though my test yells "not ok".
2020-03-13 15:53:19 -04:00
Matthias Clasen
8b1301cecd Update the ui file conversion output
This changed because the popover property got renamed.
2020-03-13 15:53:19 -04:00
Matthias Clasen
bc6953a081 testsuite: Update the settings test output 2020-03-13 15:53:19 -04:00
Matthias Clasen
4b71ed3f5e testsuite: Update tools tests
These tests need to test GTK4 ui file syntax.
2020-03-13 15:34:54 -04:00
Matthias Clasen
8fd51d761b testsuite: Actually run tools tests
The script was looking in the wrong place for the tests.
2020-03-13 15:11:07 -04:00
Matthias Clasen
66a0a8d53e Merge branch 'wip/baedert/test-cflags' into 'master'
Pass (almost) all our cflags to tests, testsuite, examples, demos, ...

See merge request GNOME/gtk!1516
2020-03-13 18:40:46 +00:00
Piotr Drąg
265d9c8703 Update POTFILES.in 2020-03-13 17:32:39 +01:00
Matthias Clasen
eaf9f7e225 Merge branch 'wayland-max-cursor-scale' into 'master'
wayland: Stop capping cursor scales

See merge request GNOME/gtk!1522
2020-03-13 15:49:02 +00:00
Matthias Clasen
331069f378 wayland: Stop capping cursor scales
We don't load entire themes anymore, so we can
easily accomodate larger cursor scales now.
2020-03-13 11:13:02 -04:00
Matthias Clasen
9aa270f928 Merge branch 'update-broadway' into 'master'
Update broadway

See merge request GNOME/gtk!1521
2020-03-13 15:09:47 +00:00
Matthias Clasen
97d189d726 Merge branch 'popover-accessible-private' into 'master'
a11y: Drop the private from GtkPopoverAccessible

See merge request GNOME/gtk!1520
2020-03-13 14:38:51 +00:00
Alexander Larsson
9e2829756f broadway: Inherit frame clock from parent surface 2020-03-13 15:26:22 +01:00
Alexander Larsson
b74a26b275 broadway: Keep popups above their parent
We set the parent as a "transient parent" for popups, which means
they will not be stacked below the parent.
2020-03-13 15:06:02 +01:00
Alexander Larsson
03d6d272f7 broadway: Track surface position correctly
surface->x/y (and various x,y arguments) should be in the parent
coordinates, so treat it as such. We also keep track of the root coords
as these are needed for popup positioning.

Also, drop the isTemp property server side and the weird initial
placement at (100, 100) in the daemon. We now fully control window
placement from the client instead. If this is not we want we should do
a serious design for that but until then lets do the simplest thing.
2020-03-13 15:05:59 +01:00
Alexander Larsson
1a763c440f broadway: Correctly track surface visibility in client
We forgot to unset visible when hiding surfaces
2020-03-13 15:00:32 +01:00
Alexander Larsson
43598fc5f2 broadway: Ensure images are decoded, not only loaded
In firefox, onload will trigger when the image is loaded, but at
that point it may not be decoded yet so showing it will sometimers
trigger flashes. We use the new decode() feature instead which ensures
both that the image is loaded *and* decoded, thus fixing the flashes.
2020-03-13 15:00:24 +01:00
Alexander Larsson
a4b718da4e broadway: Fix image updates for firefox
For whatever reason we need to assign the function to a variable
to be able to call it.
2020-03-13 15:00:18 +01:00
Alexander Larsson
086a577fd1 broadway: Handle browser hidpi scale factor 2020-03-13 14:59:37 +01:00
Matthias Clasen
c5076675aa a11y: Drop the private from GtkPopoverAccessible
It is not used, and empty structs upset msvc.
2020-03-13 09:51:04 -04:00
Matthias Clasen
9d98707f66 Merge branch 'present-toplevel-2' into 'master'
surface api splitup

See merge request GNOME/gtk!1511
2020-03-13 13:34:57 +00:00
Bastien Nocera
179b39eb86 Merge branch 'wip/hadess/fix-remote-filechooser-main' into 'master'
Fix crasher/warnings when browsing remote filesystems

Closes #2482

See merge request GNOME/gtk!1490
2020-03-13 12:36:10 +00:00
Matthias Clasen
19e2ab76ce win32: Build fixes
These fixes were done blindly, to make the ci pass,
and will need review by somebody with access to an
actual win32 system to make sure the surface subtypes
are implemented properly.
2020-03-13 07:47:48 -04:00
Timm Bäder
2fe23409fb Merge branch 'align-docs-fixes' into 'master'
gtk: Tweak GTK_ALIGN_BASELINE docs

See merge request GNOME/gtk!1518
2020-03-13 06:17:46 +00:00
Matthew Leeds
1963ff2951 gtk: Tweak GTK_ALIGN_BASELINE docs 2020-03-12 12:36:09 -07:00
Matthias Clasen
2b2d6bf747 win32: implement subtypes 2020-03-12 15:30:11 -04:00
Matthias Clasen
7fd60ab570 Fix up gdk docs 2020-03-12 15:30:11 -04:00
Matthias Clasen
25b90907ad surface: document gdk_surface_translate_coordinates 2020-03-12 15:30:11 -04:00
Matthias Clasen
f005dfa5fb toplevel: require GdkSurface 2020-03-12 15:30:11 -04:00
Matthias Clasen
31d2b686d6 popup: require GdkSurface 2020-03-12 15:30:11 -04:00
Matthias Clasen
3e06a9b1d2 Drop root coordinates from _gdk_device_query_state
Callers are not using them anyway. Update all callers.
2020-03-12 15:30:11 -04:00
Matthias Clasen
641c8f3252 Drop mwm hints from api
The GdkWMDecoration and GdkWMFunction enums
are no longer used in the api, so move them
to the x11 backend where they are used.
2020-03-12 15:30:11 -04:00
Matthias Clasen
f020d77a23 Move fullscreen-mode to GdkToplevel 2020-03-12 15:30:11 -04:00
Matthias Clasen
81be6ff46b Move edge-constraints to GdkToplevel 2020-03-12 15:30:11 -04:00
Matthias Clasen
b7f51a362e surface: Drop unused vfuncs
These are now entirely unused.
2020-03-12 15:30:11 -04:00
Matthias Clasen
b05408f854 quartz: Drop unused vfuncs 2020-03-12 15:30:11 -04:00
Matthias Clasen
fe19ad7919 win32: Drop some unused vfuncs
toplevel_resize is unused in the frontend.
2020-03-12 15:30:10 -04:00
Matthias Clasen
651b746747 wayland: Drop some unused vfuncs
show, withdraw, raise, lower, toplevel_resize,
present_popup,
are all unused in the frontend.
2020-03-12 15:30:10 -04:00
Matthias Clasen
3654c05cb3 x11: Drop some unused vfuncs
show, withdraw, raise, lower are all unused in the frontend.
2020-03-12 15:30:10 -04:00
Matthias Clasen
b6c8cf72cd broadway: Drop some unused vuncs
show, withdraw, raise, lower, present_popup
are all unused by the frontend.
2020-03-12 15:30:10 -04:00
Matthias Clasen
8b57092958 surface: Drop gdk_surface_show
No longer used.
2020-03-12 15:30:10 -04:00
Matthias Clasen
4dc27ee4a6 win32: Stop using gdk_surface_show 2020-03-12 15:30:10 -04:00
Matthias Clasen
90ff8ca797 broadway: Stop using gdk_surface_show 2020-03-12 15:30:10 -04:00
Matthias Clasen
7e15a13f48 wayland: Drop dead code 2020-03-12 15:30:10 -04:00
Matthias Clasen
b2c5d77883 x11: Stop using gdk_surface_show 2020-03-12 15:30:10 -04:00
Matthias Clasen
90dfca290c gdk: Drop surface-type
We have interfaces for surface subtypes now.
2020-03-12 15:30:10 -04:00
Matthias Clasen
a2dbc729f6 wayland: Stop using surface-type 2020-03-12 15:30:10 -04:00
Matthias Clasen
763321e274 x11: Stop using surface-type 2020-03-12 15:30:10 -04:00
Matthias Clasen
df223ae27b broadway: Stop using surface type 2020-03-12 15:30:10 -04:00
Matthias Clasen
0616fe033d x11: Stop using gdk_surface_get_surface_type 2020-03-12 15:30:10 -04:00
Matthias Clasen
5a516f2a22 wayland: Stop using surface types 2020-03-12 15:30:10 -04:00
Matthias Clasen
70e45aa229 surface: Stop using surface types 2020-03-12 15:30:10 -04:00
Matthias Clasen
c00ec402c1 surface: Don't implement subtypes in the frontend
These are now provided by the backend.
2020-03-12 15:30:10 -04:00
Matthias Clasen
84095febed x11: Only use state of toplevels
Other surface subtypes don't have that property.
2020-03-12 15:30:10 -04:00
Matthias Clasen
4c06c3bb19 broadway: Implement GdkPopup, GdkToplevel and GdkDragSurface
Make subclasses of GdkX11Surface that implement these
interfaces.
2020-03-12 15:30:10 -04:00
Emmanuele Bassi
34ff8f3afb Merge branch 'migration-can-target-docs' into 'master'
Docs: Refer to GtkWidget::can_target in migration guide

See merge request GNOME/gtk!1517
2020-03-12 19:25:58 +00:00
Matthias Clasen
bf08bf667c x11: Implement GdkPopup, GdkToplevel and GdkDragSurface
Make subclasses of GdkX11Surface that implement these
interfaces.
2020-03-12 14:56:21 -04:00
Matthias Clasen
cd773e7cb3 wayland: Implement GdkPopup, GdkToplevel and GdkDragSurface
Make subclasses of GdkWaylandSurface that implement these
interfaces.
2020-03-12 14:56:21 -04:00
Matthias Clasen
b3cabe638f Drop gdk_surface_set_opacity 2020-03-12 14:56:21 -04:00
Matthias Clasen
fafddde4bc x11: Stop using gdk_surface_set_opacity
We can just use the backend api directly.
2020-03-12 14:56:21 -04:00
Matthias Clasen
412a593618 widget: Stop using gdk_surface_set_opacity 2020-03-12 14:56:21 -04:00
Matthias Clasen
d6be419050 Drop gdk_surface_show and gdk_surface_resize
We can now use GdkDragIcon api for the last cases
where this was used.
2020-03-12 14:56:21 -04:00
Matthias Clasen
ceefe34027 gtkdragicon: Use drag surface api 2020-03-12 14:56:21 -04:00
Matthias Clasen
b25be8a42f Add a GdkDragSurface interface
This will provide functionality specific to drag icons.
2020-03-12 14:56:21 -04:00
Matthias Clasen
3a4e647b2d surface: Drop redundant toplevel api
The toplevel functionality to keep is moving to
GdkToplevel, and unused functions can go.
2020-03-12 14:56:21 -04:00
Matthias Clasen
c67d426dc4 docs: Stop using gdk_surface_get_decorations 2020-03-12 14:56:20 -04:00
Matthias Clasen
a79b6fbf35 testgtk: Stop setting decorations and functions 2020-03-12 14:56:20 -04:00
Matthias Clasen
496bd5783c tests: Stop using gdk_surface_fullscreen 2020-03-12 14:56:20 -04:00
Matthias Clasen
8ea80801b4 testgtk: Stop using gdk_surface_set_icon_name
Its not useful api, and will disappear.
2020-03-12 14:56:20 -04:00
Matthias Clasen
f7aec64e6f wayland: Stop using gdk_surface_set_title
Directly call the backend function for this, and for
gdk_surface_set_transient_for.
2020-03-12 14:56:20 -04:00
Matthias Clasen
8e0ad72875 testgtk: Stop using gdk_surface_get_state 2020-03-12 14:56:20 -04:00
Matthias Clasen
703d69692f demo: stop using gdk_surface_get_state 2020-03-12 14:56:20 -04:00
Matthias Clasen
f90c0ccaf0 a11y: Stop using gdk_surface_get_state 2020-03-12 14:56:20 -04:00
Matthias Clasen
f78f8655a6 x11: Stop using gdk_surface_get_state
All the surfaces we are dealing with here are toplevels.
2020-03-12 14:56:20 -04:00
Matthias Clasen
6edff8cd67 gtk: use toplevel state getter 2020-03-12 14:56:20 -04:00
Matthias Clasen
9266881691 window: Use GdkToplevel 2020-03-12 14:56:20 -04:00
Matthias Clasen
dfbde3da4f Introduce GdkToplevel
This is a new interface for toplevel surfaces.
2020-03-12 14:56:20 -04:00
Matthias Clasen
c0c387020b Introduce GdkToplevelLayout
This will be used in a new GdkTopleve interface in
the near future.
2020-03-12 14:44:03 -04:00
Jason Francis
3830e764d7 Docs: Refer to GtkWidget::can_target in migration guide
This makes the docs consistent with the renaming changes in commit
ef982b7d46.
2020-03-12 14:10:38 -04:00
Timm Bäder
73d8f6a090 build: Add -Wno-typedef-redefinition to build
Clang otherwise complains about this
2020-03-12 08:32:34 +01:00
Timm Bäder
822d67295a Replace a few more fallthrough comments 2020-03-12 08:32:03 +01:00
Matthias Clasen
e7ef4a57ca testsuite: Stop using type-hints 2020-03-11 19:36:04 -04:00
Matthias Clasen
11c91065cf window: Drop type hints 2020-03-11 19:36:04 -04:00
Matthias Clasen
eefedccaee x11: Set type hints based on surface type
Set the ewmh type hints based on the surface type and
transient parent, instead of taking it from the type hint.
2020-03-11 19:36:04 -04:00
Matthias Clasen
2ae3b46ee9 Stop setting type hints for dialogs 2020-03-11 19:36:04 -04:00
Matthias Clasen
ef9d7612f6 shortcutswindow: Stop setting type hints 2020-03-11 19:36:04 -04:00
Matthias Clasen
66669e0573 headerbar: Stop looking at type hints 2020-03-11 19:36:04 -04:00
Matthias Clasen
aec3705717 testsuite: Stop using type-hint 2020-03-11 19:35:56 -04:00
Matthias Clasen
ec0fb44958 a11y: Stop using type hints 2020-03-11 19:35:56 -04:00
Matthias Clasen
6c44f7bf07 wayland: Stop tracking orphan dialogs
Wayland has no concept of transient-for-group. If we want to
support that, add proper proper protocol for it, don't hack it
in this like.
2020-03-11 19:35:56 -04:00
Matthias Clasen
b2ae6ce8ff surface: Rename gdk_surface_input_shape_combine_region
There is no shape combining going on anymore, so
call this just gdk_surface_set_input_region, and
remove the offset arguments too. All callers pass
0 anyway.

Update all callers and implementations.
2020-03-11 19:35:56 -04:00
Matthias Clasen
72fdf54e07 x11: Stop using gdk_surface_maximize
Just use the backend function directly.
2020-03-11 19:35:56 -04:00
Matthias Clasen
78ed520a5b x11: Stop using gdk_surface_set_geometry_hints
Just use the backend function directly.
2020-03-11 19:35:56 -04:00
Matthias Clasen
29606af03e wayland: Stop using gdk_surface_set_geometry_hints
Just use the backend function directly.
2020-03-11 19:35:56 -04:00
Matthias Clasen
513eb11c7c inspector: Stop raising and lowering windows
We should always be composited, so this should not
matter in practice.
2020-03-11 19:35:56 -04:00
Matthias Clasen
2a6c08571f x11: Stop using gdk_surface_raise
Avoid a vfunc roundtrip and just use the backend
implementation directly.
2020-03-11 19:35:56 -04:00
Matthias Clasen
3276021a5b broadway: Stop using gdk_surface_raise
We don't implement this anyway. Add a shortcut
to the backend function in case we ever do.
2020-03-11 19:35:56 -04:00
Matthias Clasen
b1fb049277 x11: Stop abusing type hints for dnd
Nothing in GDK depends on this being set, so just
don't do it.
2020-03-11 19:35:55 -04:00
Matthias Clasen
5acbfce264 wayland: Stop abusing type hints
Instead of misusing window type hints, introduce
a private flag for drag surfaces.
2020-03-11 19:35:55 -04:00
Matthias Clasen
dc4f7515bd surface: Drop popup api
We have the GdkPopup interface now.
2020-03-11 19:35:55 -04:00
Matthias Clasen
4e8dfdff2e tooltip: Use GdkPopup 2020-03-11 19:35:55 -04:00
Matthias Clasen
b670bf54f7 popover: Use GdkPopup 2020-03-11 19:35:55 -04:00
Matthias Clasen
530dd5a940 surface: Implement GdkPopup
This is not quite right, and only temporary, since
it makes GDK_IS_POPUP (surface) true for every surface.

Eventually, the implementation will be moved to the
backends.
2020-03-11 19:35:55 -04:00
Matthias Clasen
aee8a02fc8 Introduce GdkPopup
This is a new interface for popup surfaces.
2020-03-11 19:35:55 -04:00
Matthias Clasen
0791363943 popuplayout: Add docs 2020-03-11 19:35:55 -04:00
Matthias Clasen
fe35831112 Move GdkSurface autocleanup declaration
We need this available after including gdksurface.h.
2020-03-11 19:35:55 -04:00
Matthias Clasen
c2f25c0c2f wayland: Stop calling frontend surface api
This is an unnecessary vfunc roundtrip, and the
frontend api is going away shortly.
2020-03-11 19:35:55 -04:00
Matthias Clasen
78d71eb439 Simplify surface move/drag api
Drop the with_device variants, and always pass a device.
2020-03-11 19:35:55 -04:00
Matthias Clasen
c488e86caa testsuite: Update a11y test output 2020-03-11 19:35:55 -04:00
Matthias Clasen
ad322c154c testsuite: Stop using GtkSpinner::active
This property was renamed to ::spinning.
2020-03-11 19:35:55 -04:00
Matthias Clasen
6f36d9865e Drop gtk_window_begin_move/resize_drag
These are just simple wrappers around GdkSurface
api, and we don't need them.
2020-03-11 19:35:55 -04:00
Matthias Clasen
d70c9453ba disable popover test
This is failing atm
2020-03-11 19:35:55 -04:00
Matthias Clasen
ff0909f366 Merge branch 'vfl-error' into 'master'
Fix message for VFL parser errors

See merge request GNOME/gtk!1514
2020-03-11 15:56:46 +00:00
Emmanuele Bassi
7de62118a0 Fix message for VFL parser errors
The loop is iterating over the wrong variable, and it's reimplementing
g_strfill() in a less efficient way.
2020-03-11 15:14:17 +00:00
Benjamin Otte
8742d42f32 Merge branch 'wip/ricotz/annotations' into 'master'
Really fix annotation for GtkDropTarget.get_gtypes()

See merge request GNOME/gtk!1510
2020-03-09 20:47:29 +00:00
Rico Tzschichholz
4af0531e8c Fix annotation for GdkContentFormats.get_gtypes() 2020-03-09 17:36:08 +01:00
Rico Tzschichholz
4232cbe33f Really fix annotation for GtkDropTarget.get_gtypes() 2020-03-09 17:03:58 +01:00
sicklylife
2da445f918 Update Japanese translation 2020-03-09 12:49:58 +00:00
sicklylife
5858b56acc Update Japanese translation 2020-03-09 12:36:08 +00:00
Timm Bäder
7553649c47 testsuite/gtk: Add common_cflags to build
With a few exceptions.
2020-03-07 16:28:04 +01:00
Timm Bäder
7789d0e23f builder: Make object names a const array
We don't take ownership.
2020-03-07 15:30:38 +01:00
Timm Bäder
dc36c21835 demos/gtk-demo: Add common_cflags to build
With a few exceptions.
2020-03-07 15:30:35 +01:00
Timm Bäder
049f841900 padcontroller: Copy action entries
The label and action_name entries of GtkPadActionEntry are supposed to
be const, so copy them into a private ActionEntryData struct that we
later free.
2020-03-07 14:52:45 +01:00
Matthias Clasen
948ab2767b Merge branch 'master' into 'master'
builder-tool: rename show-close-button to show-title-buttons

See merge request GNOME/gtk!1497
2020-03-06 18:02:06 +00:00
Timm Bäder
3c28f6d891 demos/widget-factory: Add common_cflags to build
And fix the generated warnings
2020-03-06 18:56:40 +01:00
Timm Bäder
6f6ed1e4af demos/node-editor: Add common_cflags to build
And fix the generated warnings
2020-03-06 18:54:37 +01:00
Timm Bäder
e444d7315c demos/icon-browser: Add common_cflags to build
And fix the generated warnings
2020-03-06 18:53:05 +01:00
Timm Bäder
5d1e006a95 demos/constraint-editor: Add common_cflags to build
And fix all the warnings and errors generated.
2020-03-06 18:51:10 +01:00
Timm Bäder
6fcd5d5ab5 testsuite/reftests: Add common_cflags to build 2020-03-06 18:24:58 +01:00
Timm Bäder
e759358402 testsuite/a11y: Add common_cflags to build 2020-03-06 18:22:01 +01:00
Timm Bäder
01bd7910ce testsuite/css: Add common_cflags to build
And fix all the errors coming from that.
2020-03-06 18:22:01 +01:00
Timm Bäder
79c60bb7fd testsuite/gdk: Add common_cflags to build 2020-03-06 18:22:01 +01:00
Timm Bäder
b3c332ad9c testsuite/performance: Add common_cflags to build 2020-03-06 18:22:01 +01:00
Timm Bäder
83982a28e7 testuite/gsk: Add common_cflags to build
And fix all the warnings and errors.
2020-03-06 18:22:01 +01:00
Timm Bäder
d1cd6aacba tests: Add common_cflags to build
And fix all the errors and warnings resulting from that

See #2491
2020-03-06 18:21:58 +01:00
Timm Bäder
0e8850bf84 examples: Add common_cflags to build
And fix all the warnings and errors generated by doing so.

See #2491
2020-03-06 16:36:42 +01:00
Timm Bäder
d7fb33caf7 filechooserwidget: Avoid criticals when in recent mode
Don't try to use the browse_files_model just because we have a location
entry. The model might still be NULL at this point.
2020-03-06 16:29:32 +01:00
Alexander Larsson
970d9dc06e Merge branch 'wip/tbaederr/fallthrough' into 'master'
Replace fallthrough comments with G_GNUC_FALLTHROUGH

See merge request GNOME/gtk!1505
2020-03-06 10:48:16 +00:00
Timm Bäder
a1c75795bc Replace fallthrough comments with G_GNUC_FALLTHROUGH 2020-03-06 10:39:42 +01:00
Benjamin Otte
63126a1b3e Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master

See merge request GNOME/gtk!1504
2020-03-06 05:48:56 +00:00
Benjamin Otte
cda9007f0f stack: Make static analyzer happy 2020-03-06 05:56:29 +01:00
Benjamin Otte
394955cceb pathbar: Don't do the same thing twice.
Don't do the same thing twice.
2020-03-06 05:53:20 +01:00
Benjamin Otte
b1a257c0c3 reftest: Plug memleak 2020-03-06 05:52:44 +01:00
Benjamin Otte
a106b54355 treeview: Don't assign value twice. 2020-03-06 05:51:37 +01:00
Benjamin Otte
510e17d123 cellarea: Be very clear
The static analyzer needs to know we absolutely DO NOT want to use this
return value.
2020-03-06 05:50:35 +01:00
Benjamin Otte
317dcddddb builder-tool: Don't allow property to be both resize and shrink
Otherwise builder-tool crashes when you do

  <property name="shrink" name="resize">1</property>

Thanks to the static analyzer for figuring that one out.
2020-03-06 05:44:11 +01:00
Benjamin Otte
df282a13bb applicationaccels: Use g_renew() 2020-03-06 05:44:11 +01:00
Benjamin Otte
e37729756d liststore: Fix gtk_list_store_iter_is_valid()
The iter may be invalid, so we may not read from it.

testsuite/gtk/treemodel tests this and valgrind is shouting about it,
but it never crashed until I just ran it...

This bug is from 2004 and the test is from 2007. I guess invalid memory
accesses don't get caught by CI much.
2020-03-06 05:44:11 +01:00
Benjamin Otte
3b8d9dbd28 testtreeview: Fix 19 year old use-after-free 2020-03-06 05:43:56 +01:00
Benjamin Otte
03e7c7fab1 treepath: Use g_renew() 2020-03-06 05:43:56 +01:00
Benjamin Otte
b231a40106 testsuite: Avoid passing NULL to strcmp()
Use g_strcmp0() instead.
2020-03-06 05:43:56 +01:00
Benjamin Otte
be30f78e62 treeview: Don't initialize variable twice 2020-03-06 05:43:56 +01:00
Benjamin Otte
89e5b8cd3a Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master

See merge request GNOME/gtk!1502
2020-03-05 18:20:36 +00:00
Benjamin Otte
e356d59a92 build: Add -Wnull-dereference
Sprinkle various g_assert() around the code where gcc cannot figure out
on its own that a variable is not NULL and too much refactoring would be
needed to make it do that.

Also fix usage of g_assert_nonnull(x) to use g_assert(x) because the
first is not marked as G_GNUC_NORETURN because of course GTester
supports not aborting on aborts.
2020-03-05 08:14:37 +01:00
Benjamin Otte
4be4799316 icontheme: Remove unused parameter
It's only ever set to NULL (and then dereferenced, too)
2020-03-05 07:59:59 +01:00
Benjamin Otte
7dce9e426e treerbtree: Use for loops
Makes the code more readable.
Also does the NULL check for the initial element, which was misisng
before.
2020-03-05 07:59:05 +01:00
Benjamin Otte
4e88d5a7cf notebook: Don't crash on drags not coming from a notebook 2020-03-05 07:59:05 +01:00
Benjamin Otte
fdd4630952 icontheme: Don't crash on icon lookup failure 2020-03-05 07:59:05 +01:00
Benjamin Otte
a4ed6fde9d device: Handle missing axis 2020-03-05 07:59:05 +01:00
Benjamin Otte
dc86c744bf rbtree: Simplify macros
* NODE_FROM_POINTER() can not be NULL

* shuffle NODE_TO_POINTER() code for readability so that the NULL check
  is on the outside and not the cast
2020-03-05 07:59:05 +01:00
Benjamin Otte
9fedcec82e rbtree: Simplify code
This makes it easier to understand for gcc (and hopefully humans, too)
that by rotating we essentially just swap `node` and `p`.
2020-03-05 07:59:05 +01:00
Benjamin Otte
f6b11a5158 build: Add more useful warning flags
I found those on the interwebs and decided they are useful.
2020-03-05 07:56:28 +01:00
Benjamin Otte
38dcc8f63b mountoperation-x11: Fix copy/paste thinko 2020-03-05 07:05:48 +01:00
Benjamin Otte
18b011a717 tests: Add a test for changing the hovered widget
The add/remove one crashes after a few enter/leave events.
2020-03-05 07:05:48 +01:00
Benjamin Otte
8fc360dac5 imcontextwayland: Fix copy/paste error 2020-03-05 04:03:02 +01:00
Benjamin Otte
4313c47113 textview: Fix copy/paste error 2020-03-05 04:03:02 +01:00
Timm Bäder
b376d9617e Merge branch 'patch-1' into 'master'
gdk_monitor_get_model: Fix a typo in the function documentation

See merge request GNOME/gtk!1499
2020-03-04 11:01:30 +00:00
Antenore Gatta
efbae75f3d gdk_monitor_get_model: Fix a typo in the function documentation 2020-03-04 11:05:46 +01:00
Piotr Drąg
3f7a7d4ca1 Update POTFILES.in 2020-03-03 17:10:36 +01:00
Emmanuele Bassi
2c04e9441a Merge branch 'doc-fixes' into 'master'
Small documentation fixes

See merge request GNOME/gtk!1500
2020-03-03 15:30:43 +00:00
Emmanuele Bassi
a3b9dba13c Fix annotation for GtkDropTarget.get_gtypes()
The argument name must match in the documentation, and the `allow-none`
annotation is deprecated, and should be replaced by `optional` in this
case.
2020-03-03 13:17:31 +00:00
Emmanuele Bassi
5e099e2606 Remove incorrect rename-to annotations
The `rename-to` annotation is used to "shadow" a symbol with another
one, which means both symbols need to exist. It can't be used to rename
a symbol to something else.
2020-03-03 13:13:26 +00:00
Emmanuele Bassi
041043eec1 Fix introspection warnings for GtkDragIcon 2020-03-03 13:12:52 +00:00
Emmanuele Bassi
ec9038a8f2 Add missing annotation for GtkIconTheme 2020-03-03 13:04:06 +00:00
sicklylife
c7414db684 Update Japanese translation 2020-03-03 12:09:06 +00:00
sicklylife
6d2c6b1257 Update Japanese translation 2020-03-03 12:06:32 +00:00
Matthias Clasen
9f829ebd4a Merge branch 'gbsneto/gtkeventcontrollerfocus' into 'master'
build: Install gtkeventcontrollerfocus.h

See merge request GNOME/gtk!1498
2020-03-03 08:40:43 +00:00
Georges Basile Stavracas Neto
8e14b21e52 build: Install gtkeventcontrollerfocus.h
It's a public class, and is included by gtk.h. Ship it.
2020-03-03 00:38:13 -03:00
Matt Guerrette
46ba019522 builder-tool: rename show-close-button to show-title-buttons
For GtkHeaderBar show-close-button has been renamed to
show-title-buttons for GTK4. This commit adds this fixup to the builder
tool
2020-03-02 22:24:46 -05:00
Benjamin Otte
3ef1dca51c Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master

See merge request GNOME/gtk!1496
2020-03-02 21:32:20 +00:00
Benjamin Otte
2e55c9cf8c droptarget: Fast-path local value load
This way, we can ensure that for local same-type drops the GValue
is set when ::enter is emitted.

This is the common case for dnd between widgets inside larger
applications, so it's worth it to speed it up.
2020-03-02 21:45:59 +01:00
Benjamin Otte
7427f4f311 drop: Don't use g_object_get() 2020-03-02 21:45:42 +01:00
Benjamin Otte
c0a63e6dd2 dnd: Fix some documentation gotchas 2020-03-02 21:26:08 +01:00
Benjamin Otte
47230f191f Merge branch 'wip/otte/dnd' into 'master'
DND: Sync drop target

See merge request GNOME/gtk!1495
2020-03-02 18:09:05 +00:00
Benjamin Otte
0e72adf6dd drop: Remove unused convenience APIs
With the new event controllers, these are unused.
2020-03-02 04:43:56 +01:00
Benjamin Otte
f5fda3ae58 themes: Set proper foreground color for DND icons 2020-03-02 04:43:56 +01:00
Benjamin Otte
f4a00e7909 calendar: Use a drag source 2020-03-02 04:43:56 +01:00
Benjamin Otte
e7db386018 dnd: Don't create custom color drag icons
... use the default one. It looks much better.
2020-03-02 04:43:56 +01:00
Benjamin Otte
2a697827e1 dragicon: Add gtk_drag_icon_create_widget_for_value()
... and use it to set a drag icon.
2020-03-02 04:43:56 +01:00
Benjamin Otte
b2c3e39c89 contentformats: Constify some functions 2020-03-02 04:43:56 +01:00
Benjamin Otte
03882e1f96 dragicon: Change how to acquire drag icons
Before, gtk_drag_icon_new_for_drag() allowed creating new drag icons.
This could cause multiple drag icons to exist for a single drag.

Now, gtk_drag_icon_get_for_drag() makes sure that only one drag icon is
created.
2020-03-02 04:43:56 +01:00
Benjamin Otte
9efc4e6777 dragicon: Add GtkDragIcon::child 2020-03-02 04:43:56 +01:00
Benjamin Otte
7cd728a0ea gdk: Make gdk_drop_status() take preferred action
This allows textview/text dnd to properly display a MOVE icon when in
the widget the drag started from but a COPY icon otherwise.
2020-03-02 04:43:56 +01:00
Benjamin Otte
c3fb6ca747 colorswatch: Switch to dragged color during dnd
This is really simple to implement now, so do it.
2020-03-02 03:18:55 +01:00
Benjamin Otte
3f7b401de0 gtk-demo: Add a simple peg solitaire DND demo 2020-03-02 03:18:55 +01:00
Benjamin Otte
a411959c91 droptarget: Redo
This is a huge reorganization of GtkDropTarget. I did not know how to
split this up, so it's unfortunately all one commit.

Highlights:

- Split GtkDropTarget into GtkDropTarget and GtkDropTargetAsync
  GtkDropTarget is the simple one that only works with GTypes and offers
  a synchronous interface.
  GtkDropTargetAsync retains the full old functionality and allows
  handling mime types.

- Drop events are handled differently
  Instead of picking a single drop target and sending all DND events to
  it, every event is sent to every drop target. The first one to handle
  the event gets to call gdk_drop_status(), further handlers do not
  interact with the GdkDrop.
  Of course, for the ultimate GDK_DROP_STARTING event, only the first
  one to accept the drop gets to handle it.
  This allows stacking DND event controllers that aren't necessarily
  interested in handling the event or that might decide later to drop
  it.

- Port all widgets to either of those
  Both have a somewhat changed API due to the new event handling.
  For the ones who should use the sync version, lots of cleanup was
  involved to operate on a sync API.
2020-03-02 03:18:55 +01:00
Benjamin Otte
f4ac74795c placessidebar: Don't use the GdkDrag
First, it should have been a GdkDrop, but even then, proper DND code
should not rely on internals.

It's only been used in an unused signal emission anyway.
2020-03-02 03:18:55 +01:00
Benjamin Otte
b64a0273c5 notebook: Make dnd page switching a drop controller
This untangles tab dnd from page switching.
2020-03-02 03:18:55 +01:00
Benjamin Otte
b799bc5ce1 textview: Move drop scrolling to drop motion controller
Don't confuse the drop target with it.
2020-03-02 03:18:55 +01:00
Benjamin Otte
fdb39b095b treeview, iconview: Don't return the drop target
Not a good idea to hand internal event controllers out to public API.
2020-03-02 03:18:55 +01:00
Benjamin Otte
d9fa839097 testsuite: Use g_assert() in tests 2020-03-02 03:18:55 +01:00
Emmanuele Bassi
35f8f05a63 Merge branch 'piotrdrag/placessidebar-typos' into 'master'
placessidebar: Fix a couple of typos and thinkos in menu labels

See merge request GNOME/gtk!1494
2020-03-01 15:07:17 +00:00
Piotr Drąg
810d567cc9 placessidebar: Fix a couple of typos and thinkos in menu labels 2020-03-01 15:05:28 +01:00
Matthias Clasen
c9d3f87e43 Merge branch 'kill-grabs-2' into 'master'
Kill grabs

See merge request GNOME/gtk!1492
2020-02-29 01:19:48 +00:00
Matthias Clasen
3d11973df8 Drop gtk_grab_add/remove from public api
The only form in which we still allow grabs to take place
is with modal toplevels.
2020-02-28 16:36:17 -05:00
Matthias Clasen
57c8a643ff Drop gtk_grab_get_current
Another grab-related api that we are not using.
2020-02-28 16:29:56 -05:00
Matthias Clasen
0ffb35c9e7 Drop device grabs
We were not using this api at all, so lets drop it.
2020-02-28 16:27:42 -05:00
Matthias Clasen
d60097f8fe Merge branch 'matthiasc/for-master' into 'master'
inspector: Fix the "Software GL" switch

See merge request GNOME/gtk!1491
2020-02-28 20:35:11 +00:00
Matthias Clasen
8f87555176 inspector: Fix the "Software GL" switch
This was crashing.
2020-02-28 14:42:19 -05:00
Bastien Nocera
8cb45cdeae filechooser: Fallback if content-type unavailable
Fallback to fast-content-type if the content-type attribute isn't
available, as is the case for most remote filesystems.

Closes: #2482
2020-02-28 17:33:08 +01:00
Bastien Nocera
823714cf66 filechooser: Fix crash when file has no content-type
This might happen for slow filesystems where a fast-content-type might
be provided instead. Don't try to manipulate that content_type if it's
NULL, otherwise we'll either throw warnings (at best) or crash (at
worse).

Conflicts:
	gtk/gtkfilechooserwidget.c
2020-02-28 17:32:48 +01:00
Piotr Drąg
cf2bcef814 Update POTFILES.in and POTFILES.skip 2020-02-27 22:05:24 +01:00
Matthias Clasen
29d033a8b3 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1488
2020-02-27 20:29:04 +00:00
Matthias Clasen
cf873f3426 Remove a stray g_object_unref
Events are no longer objects, so this does not do
any good. Use gdk_event_unref instead.
2020-02-27 14:31:19 -05:00
Matthias Clasen
527a8048b6 Avoid a crash in css font features values 2020-02-27 14:30:58 -05:00
Nathan Follens
0c1f93cd7c Update Dutch translation 2020-02-27 11:05:23 +00:00
Timm Bäder
d86832ad5a Merge branch 'patch-1' into 'master'
Fix a typo in gtkplacessidebar.c

See merge request GNOME/gtk!1486
2020-02-27 10:41:44 +00:00
Krzesimir Nowak
8df045537e Fix a typo in gtkplacessidebar.c
Some mistyped vim command got into the code in commit 60d2813247.
2020-02-27 10:02:56 +00:00
Matthias Clasen
73d40c2e6e Merge branch 'matthiasc/for-master' into 'master'
Fix a leftover occurrence of ::expand

See merge request GNOME/gtk!1485
2020-02-27 01:12:23 +00:00
Matthias Clasen
90376d6d6e Fix a leftover occurrence of ::expand 2020-02-26 19:31:25 -05:00
Danial Behzadi
6a359c54fb Update Persian translation 2020-02-26 23:23:04 +00:00
Matthias Clasen
17b7aabfc1 Merge branch 'matthiasc/for-master' into 'master'
gesture: Actually track targets

See merge request GNOME/gtk!1484
2020-02-26 22:34:45 +00:00
Matthias Clasen
dcbecdac31 gesture: Actually track targets
Due to a mismerge, this wasn't actually working,
and was causing criticals from gtk_widget_has_grab
when dragging windows.
2020-02-26 17:06:15 -05:00
Matthias Clasen
fa75d7f480 builder-tool: Fix a thinko
We can't rely on the pspec for a removed property.
This code worked until I actually removed the properties.

Update the tests to reflect this.
2020-02-26 10:01:38 -05:00
Matthias Clasen
5430c80361 Merge branch 'expand-margin-cleanup' into 'master'
expand and margin cleanup

See merge request GNOME/gtk!1479
2020-02-26 14:27:47 +00:00
Matthias Clasen
37a2cae10e Small fixups
Trying to get the ci style test to pass.
2020-02-26 08:13:45 -05:00
Emmanuele Bassi
815e18e069 Merge branch 'docs-fixes' into 'master'
Various documentation fixes

See merge request GNOME/gtk!1481
2020-02-26 11:19:09 +00:00
Emmanuele Bassi
c79acb418f Merge branch 'remove-show-hidden' into 'master'
Remove last instances of GtkFileChooser:show-hidden

See merge request GNOME/gtk!1480
2020-02-26 10:41:50 +00:00
Emmanuele Bassi
303e20226c Add missing ownership transfer annotations 2020-02-26 10:29:59 +00:00
Emmanuele Bassi
3c2312a2dd Fix gtk-doc stanza for private symbol 2020-02-26 10:25:46 +00:00
Emmanuele Bassi
7eb7ee33ff Add missing documentation to GdkDevice 2020-02-26 10:23:15 +00:00
Emmanuele Bassi
d4dcb43aa9 Add missing ownership transfer annotations 2020-02-26 10:23:01 +00:00
Emmanuele Bassi
a1bbd25e12 Fix introspection annotation syntax 2020-02-26 10:19:10 +00:00
Emmanuele Bassi
c8f4f903c6 Remove last instances of GtkFileChooser:show-hidden
The file chooser widget is still setting the show-hidden property, even
though it was removed.
2020-02-26 10:15:16 +00:00
Matthias Clasen
b5bacb3be6 Drop the margin property
Replace it with margin-start, -end, -top, -bottom throughout.
2020-02-25 20:59:04 -05:00
Matthias Clasen
a9c05193a7 Drop the expand property
The hexpand and vexpand properties are sufficient.
2020-02-25 18:29:15 -05:00
Matthias Clasen
2d4e1e248d update testsuite
Update the expected results of the tools tests that are
affected by the new property handling for expand and margin.
2020-02-25 18:28:55 -05:00
Matthias Clasen
77ce55b9ac builder-tool: replace some properties
Replace expand by hexpand and vexpand and
margin by margin-left, -right, -top, -bottom.
2020-02-25 17:50:57 -05:00
Emmanuele Bassi
06ff60aa35 Merge branch 'ci-docs' into 'master'
Restructure CI jobs

See merge request GNOME/gtk!1476
2020-02-25 19:47:57 +00:00
Emmanuele Bassi
341b2a3d39 ci: Add a static analysis job
Use the Clang static analysis tool.

For the time being, we're going to allow it to fail, but the plan is to
fix every issue it raises.
2020-02-25 19:06:39 +00:00
Emmanuele Bassi
7bc50b7466 ci: Update the docker wrapper script
Do a better job at detecting whether we have Docker installed.
2020-02-25 19:05:07 +00:00
Emmanuele Bassi
d9608a0357 ci: Move style-check to .pre phase
We want the style checks running at the start of the CI pipeline, no
need to have a specific phase for it.
2020-02-25 17:57:46 +00:00
Emmanuele Bassi
92d86c4a9f ci: Update all fedora images to v14 2020-02-25 17:19:08 +00:00
Emmanuele Bassi
382340c158 ci: Add clang-analyzer to the fedora build image 2020-02-25 17:18:23 +00:00
Emmanuele Bassi
a87966b2bf ci: Rename the "style-check" phase to "analysis"
We want to re-use it for other jobs.
2020-02-25 17:15:00 +00:00
Emmanuele Bassi
8a6d5a77bb ci: Fix style check script
Propagate the exit status from clang-format-diff.py to avoid it being
overwritten by the `echo` at the end of the script.
2020-02-25 17:13:39 +00:00
Emmanuele Bassi
97b5775c1f ci: Add a separate "docs" stage
Don't build the API reference on deploy; build it in a separate job,
instead, so we can run it on all pipelines, and deploy it only for
master.
2020-02-25 17:09:24 +00:00
Timm Bäder
64ff12dbd7 Merge branch 'wip/baedert/for-master' into 'master'
wip/baedert/for-master

See merge request GNOME/gtk!1466
2020-02-25 13:35:34 +00:00
Timm Bäder
02e295ec5d statusbar: Remove _get_message_area() from public API
The message should be manipulated via push() and pop().
2020-02-25 14:18:24 +01:00
Timm Bäder
6ff057f36a scrolledwindow: Remove an unnecessary cast 2020-02-25 14:18:24 +01:00
Timm Bäder
54bf739e8f scrolledwindow: Remove useless local variables 2020-02-25 14:18:24 +01:00
Timm Bäder
d5327a61e6 widget: Remove gtk_widget_input_shape_combine_region()
Widget's don't have surfaces anymore these days.
2020-02-25 14:18:24 +01:00
Timm Bäder
0bca4a276a inspect-button: Use new gtk_window_set_extra_input_region 2020-02-25 14:18:24 +01:00
Timm Bäder
6056ca9265 window: Carry an extra input region
This will be used in the inspector to make it possible to click through
the inspector window.
2020-02-25 14:18:24 +01:00
Timm Bäder
73c212d89b popover: Stop using gtk_widget_input_shape_combine_region()
We control the surface anyway, we can as well set the input shape on it
directly.
2020-02-25 14:18:24 +01:00
Timm Bäder
6b970c6813 widget: Remove set_csd_input_shape
Replace the only caller (unsurprisingly from gtkwindow.c) with a direct
call to gdk_surface_input_shape_combine_region.
2020-02-25 14:18:24 +01:00
Timm Bäder
e552adf05a widget: Remove surface member
Only GtkNatives are supposed to have a surface, so use the widget's
native.
2020-02-25 14:18:23 +01:00
Timm Bäder
a1fc94f1f7 range: Remove an outdated comment
What even is a CList.
2020-02-25 14:18:23 +01:00
Timm Bäder
b81cd8c929 range: Inline function into only caller 2020-02-25 14:18:23 +01:00
Timm Bäder
838fc4fdf4 range: Clean up compute_slider_position() 2020-02-25 14:18:23 +01:00
Timm Bäder
596be280c9 menusectionbox: Avoid a gtk_widget_destroy() call 2020-02-25 11:08:25 +01:00
Timm Bäder
b1d4d24c7b pathbar: Inherit from GtkWidget 2020-02-25 11:08:25 +01:00
Timm Bäder
1baae1f288 colorchooser: Fix typo in checkerboard color 2020-02-25 11:08:25 +01:00
Timm Bäder
dae06d82ae inspector: Remove double borders in recorder 2020-02-25 11:08:25 +01:00
Timm Bäder
549a3a81ae headerbar: Replace gtk_widget_destroy() call 2020-02-25 11:08:25 +01:00
Timm Bäder
ff4a33b69b headerbar: Remove size request on icon button
Doesn't make sense that we force this one button to be this big.
2020-02-25 11:08:25 +01:00
Timm Bäder
68b4c061cf shortcutlabel: Remove unnecessary includes 2020-02-25 11:08:25 +01:00
Timm Bäder
dbd1180ce4 stackswitcher: Avoid calling gtk_widget_destroy() 2020-02-25 11:08:25 +01:00
Timm Bäder
df3b88483d modelbutton: Fix wrong function name in doc comment 2020-02-25 11:08:25 +01:00
Timm Bäder
60d2813247 placessidebar: Convert popover menu to proper GtkPopoverMenu 2020-02-25 11:08:23 +01:00
Timm Bäder
995277f57d placessidebar: Avoid calling gtk_widget_destroy() 2020-02-25 10:43:15 +01:00
Timm Bäder
e1ca83ddbd pathbar: Avoid calling gtk_widget_destroy() 2020-02-25 10:43:15 +01:00
Timm Bäder
f4202c5075 headerbar: Avoid calling gtk_widget_destroy() 2020-02-25 10:43:15 +01:00
Timm Bäder
103b6a9205 popovermenubar: Avoid calling gtk_widget_destroy() 2020-02-25 10:43:15 +01:00
Timm Bäder
ceabe70a42 emojichooser: Avoid using gtk_widget_destroy() 2020-02-25 10:43:15 +01:00
Timm Bäder
73faa9c84a popovermenu: Avoid a gtk_widget_destroy() call 2020-02-25 10:43:15 +01:00
Timm Bäder
1b278b0636 colorchooserwidget: Get rid of a gtk_widget_destroy() call 2020-02-25 10:43:15 +01:00
Matthias Clasen
648a67085f testsuite: Remove outdated exclusions
There were mentions of GtkCList and GtkColorSelection
in these test. The memories!
2020-02-24 23:08:34 -05:00
Matthias Clasen
9d80db29de Merge branch 'spinning-spinner' into 'master'
Rename GtkSpinner::active to ::spinning

See merge request GNOME/gtk!1475
2020-02-25 04:04:46 +00:00
Matthias Clasen
e73a40733f Rename GtkSpinner::active to ::spinning
And add a setter and getter. The old name was
confusing with the widget state of the same
name. 'Active' is just too overloaded.
2020-02-24 22:37:02 -05:00
Matthias Clasen
00f6d1c24b Merge branch 'kill-rtl-media-icons' into 'master'
Drop rtl variants of media-playback-start

See merge request GNOME/gtk!1474
2020-02-25 02:09:52 +00:00
Matthias Clasen
52c948e4e0 Merge branch 'kill-popover-relative-to' into 'master'
Drop GtkPopover::relative-to

See merge request GNOME/gtk!1471
2020-02-25 02:00:50 +00:00
Matthias Clasen
8628c573b5 Drop rtl variants of media-playback-start
According to #2469, they are unwanted.
2020-02-24 20:49:10 -05:00
Matthias Clasen
a43d13aa74 popover: Drop ::relative-to
It is enough to just set the parent (and make the parent
call gtk_native_check_resize in size_allocate).

This commit removes the relative_to argument to the
constructors of GtkPopover and GtkPopoverMenu, and
updates all callers.
2020-02-24 20:46:41 -05:00
Matthias Clasen
259f465e01 Merge branch 'surface-get-mapped' into 'master'
Add gdk_surface_get_mapped

See merge request GNOME/gtk!1473
2020-02-25 00:26:42 +00:00
Matthias Clasen
6fb50ccd0d Drop gdk_surface_is_visible
It has been replaced by gdk_surface_get_mapped.
2020-02-24 19:07:03 -05:00
Matthias Clasen
7a39f2d49d Replace gdk_surface_is_visible by _get_mapped
The property  is called ::mapped, and we want to get
to standard getter naming.
2020-02-24 19:07:03 -05:00
Matthias Clasen
96b7c5f575 Add gdk_surface_get_mapped
Returns the value of the ::mapped property. This is
a direct replacement for gtk_surface_is_visible.
2020-02-24 17:59:12 -05:00
Matthias Clasen
90fb0caf28 Merge branch 'getters-and-setters' into 'master'
gdk:Getters and setters

See merge request GNOME/gtk!1472
2020-02-24 20:31:22 +00:00
Matthias Clasen
3c95798cd3 Add missing GdkDrag getters 2020-02-24 14:38:42 -05:00
Matthias Clasen
ec76f65d09 surface: Add a getter for autohide 2020-02-24 14:38:42 -05:00
Matthias Clasen
6be9e44786 gdk: Drop GdkDevice::input-mode and rename ::input-source
Drop the input-mode, since it only makes sense for
floating devices, which we don't have anymore. And renamt
::input-source to ::source, to match the getter.

Update all users.
2020-02-24 14:38:42 -05:00
Matthias Clasen
9ce6e98487 device: Add missing getters
This adds getters for a few properties that were
missing them, and renames the input-mode and input-source
properties to match their existing getters.
2020-02-24 08:40:16 -05:00
Matthias Clasen
4ca0a93324 Add a getter for GdkAppLaunchContext::display 2020-02-24 08:32:34 -05:00
Matthias Clasen
3735c9d155 Fix the build with docs
This is fallout from filechooser api changes.
2020-02-24 08:22:51 -05:00
Matthias Clasen
7f46b25c04 Merge branch 'wip/ebassi/filechooser-new' into 'master'
Clean up the GtkFileChooser API

Closes #2455

See merge request GNOME/gtk!1454
2020-02-24 00:32:23 +00:00
Matthias Clasen
78d63a412c Merge branch '138-gtk4-install-valgrind-suppressions' into 'master'
build: Install Valgrind suppressions files

Closes #138

See merge request GNOME/gtk!1467
2020-02-24 00:23:11 +00:00
Matthias Clasen
5af865f8cb Merge branch 'matthiasc/for-master' into 'master'
broadway: Remove SURFACE_IS_TOPLEVEL

See merge request GNOME/gtk!1469
2020-02-24 00:03:09 +00:00
Matthias Clasen
247a68d602 broadway: Remove SURFACE_IS_TOPLEVEL
All surfaces are toplevels now.
2020-02-23 18:15:59 -05:00
Philip Chimento
e123853b8b build: Install Valgrind suppressions files
This is so that other programs linking to GTK can use GTK's suppressions
files when performing their own Valgrind analysis.

Closes: #138
2020-02-23 15:00:37 -08:00
Piotr Drąg
9d2d4a69a5 Update POTFILES.in 2020-02-23 12:32:30 +01:00
Matthias Clasen
9036d49bea Merge branch 'wip/otte/dnd' into 'master'
Get rid of GdkAtom

See merge request GNOME/gtk!1465
2020-02-23 01:50:52 +00:00
Benjamin Otte
cc7c1fe108 gdk: Remove GdkAtom
finally!!!!!
2020-02-23 01:59:26 +01:00
Benjamin Otte
f536cf0a43 win32: Get rid of GdkAtom 2020-02-23 01:59:26 +01:00
Benjamin Otte
60307da5b1 wayland: Replace final mention of GdkAtom 2020-02-23 01:59:26 +01:00
Benjamin Otte
6e935d469a x11: Get rid of GdkAtom and APIs supporting it.
replace all uses with const char * (non-interned).
Also remove a lot fo juggling from atom to GdkAtom to string and back.

The X Atom hash table is now mapping to (again, non-interned) strings.
2020-02-23 01:59:26 +01:00
Benjamin Otte
4280ca2263 device: gdk_device_list_axes() => gdk_device_get_axis_names()
Turn a GList of GdkAtom into a char ** - and rename the function to not
cause problems.
2020-02-23 01:59:26 +01:00
Benjamin Otte
28dced597f gdk: Remove gdk_text_property_to_utf8_list_for_display()
A lot of files became empty now, so they have been removed, which makes
this commit seem larger than it is.
2020-02-23 01:59:26 +01:00
Benjamin Otte
6c61c7bf0b Don't use GdkAtom where const char * is used
Those are all forgotten transitions while updating code to new APIs.
2020-02-23 01:59:19 +01:00
Benjamin Otte
6442ec2f8d gdk: Remove gdk_utf8_to_string_target()
Only keep the X11 version around in the backend.
2020-02-23 01:59:00 +01:00
Benjamin Otte
a62d78bf70 selection: Remove GtkSelectionData 2020-02-23 01:59:00 +01:00
Benjamin Otte
a4f7e2ca09 droptarget: Remove selectiondata read functions
They are unused now.
2020-02-23 01:59:00 +01:00
Benjamin Otte
a19066b17c filechooserwidget: Stop using selection data
Use gdk_drop_read_async()
2020-02-23 01:59:00 +01:00
Benjamin Otte
992173c382 x11: Register DND atoms with all other atoms
It's 2020, there's no need to be restrained with registering atoms.
2020-02-23 01:59:00 +01:00
Benjamin Otte
b0f6996892 gdk: Remove gdk_surface_register_dnd()
All surfaces are expected to be DND surfaces from creation.
2020-02-23 01:59:00 +01:00
Matthias Clasen
8d5cece080 Merge branch 'x11-dnd-fixes' into 'master'
X11 dnd fixes

See merge request GNOME/gtk!1464
2020-02-23 00:21:54 +00:00
Matthias Clasen
ec383a2388 Add detail to gdk_drag_begin docs
Mention that GTK keeps a reference while the drag
operation is ongoing.
2020-02-22 19:10:16 -05:00
Matthias Clasen
7c1cfc5533 x11: Fix dnd coordinate handling
We were not properly converting the coordinates we
got to root coordinates. This was showing up as offsets
between the actual drop target and the area where drops
can happen, e.g. when dragging over a stack switcher
to switch pages.
2020-02-22 19:10:16 -05:00
Matthias Clasen
14122d1acb x11: Export gdk_x11_surface_get_root_coords privately
This lets us avoid a roundtrip through the surface vfuncs.
2020-02-22 19:10:16 -05:00
Matthias Clasen
f93d0f8fb5 x11: Keep a ref on GdkDrag objects
It is expected that backends keep a ref on the GdkDrag
objects that they create as long as the drag is ongoing.
2020-02-22 19:02:13 -05:00
Matthias Clasen
833b564946 x11: Avoid crashes in dnd
We were forgetting to clean up the ::xevent signal
handler in some error cases. Move the signal connection
later, when we know the drag is going forward, and
use g_signal_connect_object to make sure the signal
handler is not forgotten.
2020-02-22 19:02:13 -05:00
Matthias Clasen
7edfcc37a3 Merge branch 'wip/wayland-fix-popup-grabs' into 'master'
Fix Wayland popup grabs

See merge request GNOME/gtk!1463
2020-02-22 20:51:32 +00:00
Jonas Ådahl
f0b0076a1c wayland/popup: Emit un-withdrawn event earlier
Otherwise grabbing the seat will appear to have failed.
2020-02-22 20:09:38 +01:00
Jonas Ådahl
71323a8b48 wayland/popup: Remove unnecessary checks when mapping popup
We only call this when we're not already mapped so don't check that. We
also only call this when we should be mapped so don't check that either.
2020-02-22 20:08:37 +01:00
Matthias Clasen
b8db9e124b Merge branch 'matthiasc/for-master' into 'master'
Fix a hard-to-spot typo

See merge request GNOME/gtk!1462
2020-02-22 19:01:18 +00:00
Matthias Clasen
ddd126740e Fix a hard-to-spot typo
The symptom caused by this was scales in
popovers not reacting to dragging.
2020-02-22 13:49:12 -05:00
Emmanuele Bassi
9bf03cfeec docs: Add migration notes for GtkFileChooser 2020-02-22 18:07:11 +00:00
Matthias Clasen
011f58fa64 Merge branch 'matthiasc/for-master' into 'master'
x11: Fix a crash in event handling

See merge request GNOME/gtk!1461
2020-02-22 16:41:29 +00:00
Matthias Clasen
1af94d0bce x11: Fix a crash in event handling
This was overlooked in 79b4510c6d.
2020-02-22 16:41:29 +00:00
Emmanuele Bassi
ff6772fd98 Remove preview widget from GtkFileChooser
The preview widget harks from a platform before time, when we didn't
have GIO, or a thumbnail specification.

Very few applications use it correctly, if at all; it has an horrid hack
to deal with the ownership of the widget's instance when accessed
through the getter function; it messes up the layout of the widget and
its label is less than useful when it comes to file names longer than a
dozen characters; it's a poor substitute for a proper thumbnail view.
2020-02-22 16:39:01 +00:00
Matthias Clasen
be25905a8d Fix gdk docs build 2020-02-22 10:44:21 -05:00
Emmanuele Bassi
e5ef26efa8 Remove GtkFileChooserEntry:local-only
We don't use it any more in GtkFileChooserWidget.
2020-02-22 15:22:06 +00:00
Emmanuele Bassi
ebd23737c0 Remove GtkPlacesSidebar:local-only
We don't use it any more in GtkFileChooserWidget.
2020-02-22 15:22:06 +00:00
Emmanuele Bassi
6e699e3f04 Remove GtkPlacesView:local-only
We don't use it any more from the file chooser widget.
2020-02-22 15:22:06 +00:00
Emmanuele Bassi
4a3742979d Remove GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER
We don't need a whole separate action, now that the file chooser widget
can create folders; we can create use SELECT_FOLDER and create one.
2020-02-22 15:22:06 +00:00
Emmanuele Bassi
b09e7df81b Remove GtkFileChooser:local-only
Now that the whole API goes through GFile we don't have the weird split
between local-only and non-local-only modes.
2020-02-22 15:22:06 +00:00
Emmanuele Bassi
516eab5c43 Remove GtkFileChooser:show-hidden
This is a user setting and a user action, not something that ought to be
programmatically set via the file selection API.
2020-02-22 15:22:06 +00:00
Emmanuele Bassi
063ad28b1a Remove overwrite confirmation machinery from GtkFileChooser
Overwrite confirmation should not be optional, and it should not loop
into application code to create their own dialog and user response.
2020-02-22 15:22:06 +00:00
Emmanuele Bassi
d505573ee6 Drop GtkFileChooser:extra-widget
We have "choices" as a more rational (and portable) API; additionally,
the ownership semantics of the extra widget property getter are a hack.
2020-02-22 15:22:06 +00:00
Emmanuele Bassi
5f070ff233 Remove filename/URI API from GtkFileChooser
GtkFileChooser's API predates GIO by a few years, so it started off with
filenames and URI as character arrays. After introducing GIO as a
dependency, the API included GFile-based entry points.

It's much more appropriate to use GFile everywhere, as we want to
encourage people to use GIO instead of passing random bytes to low level
POSIX API.

See: #2455
2020-02-22 15:22:06 +00:00
Benjamin Otte
b002572824 Merge branch 'wip/otte/dnd' into 'master'
stuff

See merge request GNOME/gtk!1460
2020-02-22 14:53:13 +00:00
Matthias Clasen
767849d6d2 Remove GdkSeatGrabPrepareFunc from headers
It is not used in public api anymore.
2020-02-22 08:11:34 -05:00
Matthias Clasen
76e115b910 Add a warning when a grab fails
This reveals that the grabs for popover menus
always fail now, causing the menus to not properly
hide.
2020-02-22 08:11:34 -05:00
Benjamin Otte
8a098b1343 tests: Guard variables with necessary macros 2020-02-22 07:44:52 +01:00
Benjamin Otte
9d915ff431 treeviewcolumn: Inline variable into return_if_fail() 2020-02-22 07:44:52 +01:00
Benjamin Otte
6f0a0ce7f1 testsuite: Don't use g_return_if_fail()
Use g_assert()
2020-02-22 07:44:52 +01:00
Benjamin Otte
18d7187e4b testsuite: Don't use return_if_fail()
Use assert() instead
2020-02-22 07:35:23 +01:00
Benjamin Otte
d9e3eaaec8 treeview: Guard code by right compiler macros 2020-02-22 07:33:41 +01:00
Benjamin Otte
0c4c88b449 scrolledwindow: Inline variable into return_if_fail() 2020-02-22 07:33:41 +01:00
Benjamin Otte
2cb0007b89 iconview: Inline variables into return_if_fail() 2020-02-22 07:33:41 +01:00
Benjamin Otte
eb70173646 levelbar: Guard function by right compiler macros 2020-02-22 07:33:41 +01:00
Benjamin Otte
2e941acb29 filesystemmodel: Guard variable with correct compiler flags 2020-02-22 07:33:41 +01:00
Benjamin Otte
42d71f1016 combobox: Inline variables into return_if_fail() 2020-02-22 07:33:41 +01:00
Benjamin Otte
99fc31865a comboboxtext: Inline functions into return_if_fail() 2020-02-22 07:33:40 +01:00
Benjamin Otte
f9b7825a47 device: Inline function into return_if_fail() 2020-02-22 07:33:40 +01:00
Benjamin Otte
e3aee62b18 drop: Guard variable with correct compiler flags 2020-02-22 07:33:40 +01:00
Benjamin Otte
ce3ed45e81 surface: Inline function
Fixes compile error with -DG_DISBALE_CHECKS
2020-02-22 07:33:40 +01:00
Benjamin Otte
a12e563cd2 main: Don't synthesize crossing events when nothing changed
This was especially bad because it was confusing the event controllers
so much, they'd emit leave + enter events every time the mouse moved.
2020-02-22 07:33:40 +01:00
Benjamin Otte
a5e2275a72 stackswitcher: Use GdkDropControllerMotion
... and use one controller per button instead of using it on the
switcher and then going through lots of pain attempting to find the
right button for the location under the mouse.
2020-02-22 07:33:40 +01:00
Benjamin Otte
d680e2e344 Port simple cases to GtkDropControllerMotion 2020-02-22 07:33:40 +01:00
Benjamin Otte
2a8fd25a4b testsuite: Check proper notify emissions, too
This is in particular relevant for the ::is-focus property, because
updating that one doesn't cause enter/leave events.

But it also checks that notify and enter/leave happen in the right
order.
2020-02-22 07:33:40 +01:00
Benjamin Otte
34e5f36fdf Add GtkDropControllerMotion 2020-02-22 07:33:40 +01:00
Benjamin Otte
9223d1ee04 eventcontrollermotion: Fix docs 2020-02-22 07:33:40 +01:00
Benjamin Otte
fc43ec0bbc gtk: Bubble drag events like motion events
Emit crossing events - with a new GTK_CROSSING_DROP type - like we do
for motion events. There is no more special casing for them.

Note that the gesture has not been updated yet, so some obscure behavior
may occur.
2020-02-22 07:33:40 +01:00
Benjamin Otte
be4b34aa8f events: Use GdkDrop as event sequence
This allows treating drop events like touch events, which GTK groups by
event sequence.

It's a bit ugly that we just case the GdkDrop pointer, but event
sequences are only meant to be unique pointer ids, so it's fine.
2020-02-22 07:33:40 +01:00
Benjamin Otte
6f73a750a7 widget: Simplify adjust_allocation()
And in particular, only do it if the widget doesn't use ALIGN_FILL.

This avoids lots of measuring in the common case and speeds up
size_allocate() by about 25%.

And because size_allocate() is the bottleneck in the fishbowl, this also
gets ~25% more fishies.
2020-02-22 07:33:40 +01:00
Benjamin Otte
4128ee88b0 widget: Pull margin computation out of adjust_allocation
It's way cheaper to just do it.

Also simplifies adjust_size_allocation a lot.
2020-02-22 07:33:23 +01:00
Benjamin Otte
418bdc87ef sizerequest: Stop clamping for_size to natural size
Widgets should be given the actual size they will be allocated, so they
can do something with it.

If they want to clamp themselves to their natural size, nothing's
stopping them, they know their natural size after all.
2020-02-22 07:33:23 +01:00
Benjamin Otte
612ba7ec15 widget: Don't check for natives
It's the native's job to request a 1px x 1px size, not the job of
gtk_widget_size_allocate()

Also saves 10% of size_allocate() time because checking for an interface
is really expensive.
2020-02-22 05:50:07 +01:00
Benjamin Otte
f656cbdc5b Ensure all natives request at least a 1px wide surface
FIXME: Is this necessary?

Could the surfaces just clamp to 1x1 themselves?
We recently declared that surfaces can decide on whatever size they want
so natives need to inspect the size they requested anyway.
2020-02-22 05:50:07 +01:00
Matthias Clasen
3eea9f3e79 Merge branch 'color-float-fix' into 'master'
color chooser: Fix fallout from floatification

See merge request GNOME/gtk!1459
2020-02-22 03:19:01 +00:00
Matthias Clasen
9fa7a47081 color chooser: Fix fallout from floatification
We are using (dddd) variants to store colors in variants,
which is dangerous now that GdkRGBA members are just floats.

Avoid passsing the GdkRGBA members directly to any varargs
functions.
2020-02-21 19:56:44 -05:00
Matthias Clasen
13ed531301 Merge branch 'wip/xdg-popup-layout-no-op' into 'master'
gdk/wayland: Avoid relayout with the same properties

See merge request GNOME/gtk!1457
2020-02-22 00:27:59 +00:00
Matthias Clasen
7a28118f3a Merge branch 'wip/gdkpopuplayout-section' into 'master'
docs: Add GdkPopupLayout to gdk4-sections.txt

See merge request GNOME/gtk!1458
2020-02-22 00:26:42 +00:00
Jonas Ådahl
b4bce2ff8a docs: Add GdkPopupLayout to gdk4-sections.txt 2020-02-21 23:25:30 +01:00
Jonas Ådahl
2f13ac2e4d gdk/wayland: Avoid relayout with the same properties
When a popup is already showing, and gdk_surface_present_popup() is
called, if the layout didn't change, we're not really interested in
relayouting.

In the future, we'll be able to get notified if position of the popup
would change by some environmental changes, but until then, just don't
support it.
2020-02-21 21:55:16 +01:00
Jonas Ådahl
1d6100e7b0 gdk/popup-layout: Remove leftover struct field
The layouts never "seal", as they did in an earlier revision, so remove
the seal field.
2020-02-21 21:42:52 +01:00
Benjamin Otte
112bc964cb Merge branch 'wip/otte/for-master' into 'master'
surface: Don't take a display argument in gdk_surface_new_popup()

See merge request GNOME/gtk!1456
2020-02-21 20:35:47 +00:00
Benjamin Otte
5577cfa40c surface: Don't take a display argument in gdk_surface_new_popup()
The display can be taken from the surface, it must not be different.
2020-02-21 21:13:09 +01:00
Benjamin Otte
c73ac2ed70 Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master

See merge request GNOME/gtk!1455
2020-02-21 18:24:56 +00:00
Benjamin Otte
7597f6b594 transform: Don't crash for gsk_transform_transform (id, id)
See attached tests
2020-02-21 18:30:13 +01:00
Benjamin Otte
b50093d044 transform: Make sure the identity transform is equal to NULL 2020-02-21 18:25:05 +01:00
Benjamin Otte
608e624ecf x11: When clearing old Drop, emit LEAVE event
This can happen when the old DND operation died (like due to a crash or
a broken XWayland compositor.
2020-02-21 18:19:16 +01:00
Benjamin Otte
808961564c gdk: Make DRAG_ENTER event take x/y coordinates
Make it mirror the behavior of ENTER/LEAVE events.
2020-02-21 18:19:16 +01:00
Benjamin Otte
41ef6e9fa5 transform: Add optimization for common case
Transforming identity by an other transform does not mean we need to
painstakingly apply the individual steps of other to construct a new
transform, it means we can just return other.

Or in math terms:
  I * B = B
so just return B.
2020-02-21 18:19:16 +01:00
Piotr Drąg
4180ad57bc Update POTFILES.in 2020-02-21 18:11:15 +01:00
Matthias Clasen
d7d7957b04 profiling: Avoid one extra printf
We already format the message, no need to use
printf again to combine that with the kind string.
2020-02-21 07:26:19 -05:00
Matthias Clasen
376f5eacbd profiling: Avoid criticals
With events no longer GObjects, the type class is
longer around for peeking.
2020-02-21 07:23:40 -05:00
Matthias Clasen
77e1fd01c3 Merge branch 'readonly-events-1' into 'master'
Redo events

See merge request GNOME/gtk!1443
2020-02-21 06:18:25 +00:00
Matthias Clasen
43aa6d9c49 docs: Remove some no-longer existing api 2020-02-21 00:51:04 -05:00
Matthias Clasen
5ebe5be225 Stop exporting gtk_get_event_widget
This is non-essential convenience API, and we
don't really expose events to applications anymore.
2020-02-21 00:51:03 -05:00
Matthias Clasen
1c7191f45c gtk-demo: Stop using gtk_get_event_widget
This is convenience api that will be going away.
2020-02-21 00:51:03 -05:00
Matthias Clasen
497a43a4ba gdk: Drop event structs from the headers
All events are GdkEvents now.
2020-02-21 00:51:03 -05:00
Matthias Clasen
b2226ea1e3 gtk: Stop using GtkEventButton
Same as the previous commit. All events are
just GdkEvents now.
2020-02-21 00:51:03 -05:00
Matthias Clasen
8823882f97 gtk: Stop using GdkEventKey
We should just use GdkEvent, instead of taking
a GdkEventKey, and then cast it everywhere.
2020-02-21 00:51:03 -05:00
Matthias Clasen
9e415ad017 a11y: drop unused code
We are no longer using key snoopers.
2020-02-21 00:51:03 -05:00
Matthias Clasen
e062137b2c motion controller: Match focus event propagation
Make the crossing event generation for pointer events
match what we do for focus now.
2020-02-21 00:51:03 -05:00
Matthias Clasen
77aed615e8 Keep more event controller api private
We don't want to expose the GtkCrossingData struct, and manually
feeding events to event controllers is not something we want to
encourage, going forward.
2020-02-21 00:51:03 -05:00
Matthias Clasen
4947b94a41 Stop exporting check_event_sanity 2020-02-21 00:51:03 -05:00
Matthias Clasen
0c96b2d8f7 Bring back im context focus-in/out
The key controller still needs to track focus,
in order to emit these signals when required.
2020-02-21 00:51:03 -05:00
Matthias Clasen
cadeca74e2 Go back to ::enter/::leave for pointer changes
These signals are behaving a little differently from
what ::focus-in/::focus-out used to do.
2020-02-21 00:51:03 -05:00
Matthias Clasen
5a2f829a40 Split off GtkEventControllerFocus
Split the focus tracking into a separate
GtkEventControllerFocus, and change the API one more time.
We are back to having ::focus-in and ::focus-out signals.

Update all users.
2020-02-21 00:51:03 -05:00
Matthias Clasen
89c3a7ab24 wip: Add more information to crossing events
Add fields for direct descendents to GtkCrossingData,
and populate them when emitting focus change events.

Also add accessors for these fields to GtkEventControllerKey,
and verify that they are set properly in the focus test.

Not done yet: Do the same for pointer crossing events.
2020-02-21 00:51:03 -05:00
Matthias Clasen
7bb6abb1d4 win32: Remove some leftover event struct access
And leftover old event api calls.
2020-02-21 00:51:03 -05:00
Matthias Clasen
de91e10a1b wayland: Fix a release build warning 2020-02-21 00:51:03 -05:00
Matthias Clasen
4098653974 Update the focus test
This needs an update to handle the new focus-change signal.
2020-02-21 00:51:03 -05:00
Matthias Clasen
71b3f47909 Update event docs section 2020-02-21 00:51:03 -05:00
Matthias Clasen
1ef30c110f Clean up GdkEventType docs 2020-02-21 00:51:03 -05:00
Matthias Clasen
6fd913b361 Some event struct packing improvements
Rearrange a few things, and move some booleans
into the Any struct, by using a bitfield there.

Some more cleanup could be done - the flags field
with its PENDING and FLUSHED members appears
entirely unused. Nobody is setting those flags.
2020-02-21 00:51:03 -05:00
Matthias Clasen
84edce3732 Streamline event structs
Use proper types (GdkModifierType, double), and drop
some unused fields (send_event, display).
2020-02-21 00:51:03 -05:00
Matthias Clasen
2cce508b33 x11: Remove some leftover event struct access 2020-02-21 00:51:03 -05:00
Matthias Clasen
56d44b4cec x11: Stop using the send_event event field
The only use of this field is printing it out in a
debug message. We are going to drop it.
2020-02-21 00:51:03 -05:00
Matthias Clasen
563dd65530 Always deliver focus events to toplevels
Its was GTK expects. This change gets rid of the "Ignoring an
unexpected focus event from GDK on a non-toplevel surface."
warning.
2020-02-21 00:51:03 -05:00
Matthias Clasen
0fc2505ed6 Drop gtk_widget_event from API
We don't want events to be injected randomly from
the outside. Plus, there's no way to create such
events from the outside now.
2020-02-21 00:51:03 -05:00
Matthias Clasen
b1eaa502df events: reorganize getters
Restructure the getters for event fields to
be more targeted at particular event types.

Update all callers, and replace all direct
event struct access with getters.

As a side-effect, this drops some unused getters.
2020-02-21 00:51:03 -05:00
Matthias Clasen
f1cf0eb3fc Drop gdk_set/get_show_events
We don't need a separate api to turn on debugging
for events.
2020-02-21 00:51:02 -05:00
Matthias Clasen
31bf9da63a Strip const from GdkEvent
Events are refcounted structs, and we generally don't
pass these as const.
2020-02-21 00:51:02 -05:00
Matthias Clasen
1026bfb1ac events: Drop all setters
GdkEvent is now truly readonly.
2020-02-21 00:51:02 -05:00
Matthias Clasen
92288205d4 events: Drop target and related target
GTK no longer uses this, so we can drop it.
2020-02-21 00:51:02 -05:00
Matthias Clasen
e5223b1cee main: Stop calling gdk_event_set_target
GTK is no longer relying on this.
2020-02-21 00:51:02 -05:00
Matthias Clasen
2416b4e2a0 Stop using gdk_event_get_target
We can now get the target widget from the gesture
that we are using to find the event in the first
place.
2020-02-21 00:51:02 -05:00
Matthias Clasen
2bac066a63 gesture: Keep the target widget for events
We already store the events; keep the target widget
in addition. This is a step towards getting rid of
gdk_event_get_target.
2020-02-21 00:51:02 -05:00
Matthias Clasen
cd601ffb9e eventcontroller: Make the target widget available
Make it possible for event controllers to obtain
the target widget during handle_event.
2020-02-21 00:51:02 -05:00
Matthias Clasen
e54e48f6d1 Explicitly pass the target to handle_event
Pass the event propagation target explicitly down to
the event controllers. This is a step towards getting
rid of gdk_event_set_target.
2020-02-21 00:51:02 -05:00
Matthias Clasen
b38869b3aa Stop looking at the related target for filtering
We are now sending crossing events (which are the only ones
where a related target makes sense) via handle_crossing.
2020-02-21 00:51:02 -05:00
Matthias Clasen
d063b6b6cc Reinstate filtering for crossing events
The event propagation limit should apply to crossing events
as well.
2020-02-21 00:51:02 -05:00
Matthias Clasen
e3158a1bfb Make crossing events handled the same way 2020-02-21 00:50:59 -05:00
Matthias Clasen
23c67f8c67 New focus change handling
Instead of relying on gdk's antiquated crossing events,
create a new GtkCrossingData struct that contains the
actual widgets, and a new event controller vfunc that
expects this struct. This also saves us from making sense
of X's crossing modes and details, and makes for a
generally simpler api.

The ::focus-in and ::focus-out signals of GtkEventControllerKey
have been replaced by a single ::focus-change signal that
takes GtkCrossingData as an argument. All callers have
been updated.
2020-02-21 00:47:53 -05:00
Matthias Clasen
9402e335d0 wip: scrolledwindow stop using targets 2020-02-21 00:47:53 -05:00
Matthias Clasen
64b9c6aaaa main: Drop gtk_get_event_target
This is no longer used.
2020-02-21 00:47:53 -05:00
Matthias Clasen
61c32f3651 tooltip: stop using gtk_get_event_target 2020-02-21 00:47:53 -05:00
Matthias Clasen
1b2289ad9b Stop using gtk_get_event_target
This is just a thin wrapper around gdk_event_get_target,
so use that directly.
2020-02-21 00:47:53 -05:00
Matthias Clasen
dd251d85c4 Pass translated coordinates outside the event
We want to make events readonly, so stop translating
their coordinates and instead pass the translated
coordinates separately, when propagating events.
2020-02-21 00:47:53 -05:00
Matthias Clasen
cd2b58574d Drop GDK_NOTHING
Events of type GDK_NOTHING are good for nothing.
2020-02-21 00:47:53 -05:00
Matthias Clasen
3830e13b98 Make GdkEvent a boxed type 2020-02-21 00:47:53 -05:00
Matthias Clasen
c343031a0e Stop using g_object_ref/unref on events
Use gdk_event_ref/unref instead of g_object_ref/unref.
Events will stop being object soon.
2020-02-21 00:47:53 -05:00
Matthias Clasen
835556c270 Drop gdk_event_new and gdk_event_copy
These functions are no longer used outside of gdkevents.c.
2020-02-21 00:47:52 -05:00
Matthias Clasen
59cc216985 display: Stop using gdk_event_copy
Events are effectively readonly in GDK now, so we can just
take a reference, no need for a copy.
2020-02-21 00:47:52 -05:00
Matthias Clasen
fe21223d48 win32: Use event constructors 2020-02-21 00:47:52 -05:00
Matthias Clasen
f11b1d258b x11: Pass the right surface to the dnd filter 2020-02-21 00:47:52 -05:00
Matthias Clasen
e45711e727 x11: Remove an unnecessary check
We are not creating GDK_NOTHING events anymore. Yay
2020-02-21 00:47:52 -05:00
Matthias Clasen
79b4510c6d x11: change event translator interface
Make the event translator return a new event, instead of
filling in a half-constructed one.

Update the two implementation in GdkX11Display and
GdkDeviceManagerXI2.
2020-02-21 00:47:51 -05:00
Matthias Clasen
15501afdbb x11: Change the wm protocols filter api
Instead of passing a half-constructed event and expect
it to be filled in, pass the surface as in argument, and
add an out argument for a newly constructed GdkEvent.
2020-02-21 00:40:52 -05:00
Matthias Clasen
94fe0944cc x11: Don't pass a GdkEvent to shape cache filters
The filter functions never look at that event, and
we want to get out of the business of passing half-
constructed events around.
2020-02-21 00:40:52 -05:00
Matthias Clasen
9c4f19e8ed x11: Don't pass a GdkEvent to xsettings filters
The filter functions never look at that event, and
we want to get out of the business of passing half-
constructed events around.
2020-02-21 00:40:52 -05:00
Matthias Clasen
9a1497f582 events: Drop GDK_DESTROY
No backend is emitting GDK_DESTROY events anymore, so no
need to carry this around.
2020-02-21 00:40:52 -05:00
Matthias Clasen
7db8be93f4 gtk: Stop handling GDK_DESTROY differently from GDK_DELETE
We don't have child windows anymore, so there is no difference.
2020-02-21 00:40:52 -05:00
Matthias Clasen
047c18844c x11: Don't generate GDK_DESTROY events
GTK does not differentiate between GDK_DESTROY and GDK_DELETE
anyway.
2020-02-21 00:40:52 -05:00
Matthias Clasen
30740f0e2c x11: use event constructors
This is not quite complete and only handles the
simple cases.
2020-02-21 00:40:52 -05:00
Matthias Clasen
c9d9ccdb8c broadway: Use event constructors
Convert all of Broadways event handling to use the new
constructors.
2020-02-21 00:40:52 -05:00
Matthias Clasen
4cf63f3eb3 wip: Use event constructors in the testsuite
This doesn't work because the constructors aren't exported,
so remove the gestures text temporarily, until we figure
out how to deal with it.
2020-02-21 00:40:52 -05:00
Matthias Clasen
c4a2cf03b2 textview: Stop using gdk_event_copy 2020-02-21 00:40:52 -05:00
Matthias Clasen
495de0b78b main: Use constructors instead of gdk_event_copy + rewriting 2020-02-21 00:40:52 -05:00
Matthias Clasen
dac61b3cce imcontextsimple: Use event constructors 2020-02-21 00:40:52 -05:00
Matthias Clasen
080e5de786 widget: Port emulation code to constructors
Use the new event constructors when generating events
for emulating presses.
2020-02-21 00:40:52 -05:00
Matthias Clasen
374c9dd880 window: Use event constructors 2020-02-21 00:40:52 -05:00
Matthias Clasen
a5f58e8d28 main: Use event constructors
At the same time, stop setting child_surface in
crossing events. Nothing in GTK looks at it.
2020-02-21 00:40:52 -05:00
Matthias Clasen
324aa39cb8 gdk: Use constructor for grab broken 2020-02-21 00:40:52 -05:00
Matthias Clasen
d6c5ecbea3 gdk: Use event constructors for dnd 2020-02-21 00:40:50 -05:00
Matthias Clasen
ef004c64c6 events: Drop x_root/y_root
We are not using these fields anymore.
2020-02-21 00:39:43 -05:00
Matthias Clasen
f15e90b194 broadway: Stop setting x_root/y_root in events
These fields are not used in GTK anymore, and are
going away soon.
2020-02-21 00:39:43 -05:00
Matthias Clasen
91b94f51f2 x11: Stop setting x_root/y_root in events
These fields are not used by GTK anymore and
will be going away soon.
2020-02-21 00:39:43 -05:00
Matthias Clasen
a8e9d6c1f5 x11: Stop relying on root coordinates in events
The X11 dnd code was still using x_root/y_root in
GdkEventMotion in a couple of places. Stop doing so,
these field are going away soon.
2020-02-21 00:39:43 -05:00
Matthias Clasen
7e80c39aee Remove root coords from the GdkDrop api 2020-02-21 00:39:41 -05:00
Matthias Clasen
7f2564aabe wayland: Clean up coordinate handling
Get rid of the get_coordinates function and just
use the structs directly.
2020-02-21 00:39:12 -05:00
Matthias Clasen
07ffa9ad6b wayland: Use event constructors
Convert all of Waylands event handling to use the new
constructors.
2020-02-21 00:39:12 -05:00
Matthias Clasen
67035d2e35 gdk: Add event constructors
Add private API to construct events. This is a step towards
making events readonly, and not objects anymore.

The constructors here are sufficient to convert the Wayland
backend over. More may be added for other backends as needed.

Open issues:
 - history
2020-02-21 00:39:12 -05:00
Matthias Clasen
9330158f11 Make a11y testsuite pass 2020-02-21 00:39:12 -05:00
Matthias Clasen
8318d3bed3 Merge branch 'master' into 'master'
build: gdk/wayland/cursor depends on wayland-client

See merge request GNOME/gtk!1453
2020-02-20 19:08:45 +00:00
Dominique Leuenberger
8b9ad1e963 build: gdk/wayland/cursor depends on wayland-client
On distros where wayland-client.h might not be directly in /usr/include
we fail to find the correct headers otherwise.
2020-02-20 17:07:02 +01:00
Timm Bäder
018870643a scale: Remove useless extra local variable 2020-02-20 10:30:14 +01:00
Timm Bäder
aa53fef39c scale: Remove unused member 2020-02-20 10:23:09 +01:00
Timm Bäder
faddbb18d3 emojichooser: Add style class to emoji toolbar
Closes #1013
2020-02-20 10:23:09 +01:00
Timm Bäder
f14978c68f filechooserwidget: Fold function into only caller 2020-02-20 10:23:09 +01:00
Timm Bäder
c0de02520c filechooserwidget: Use a proper GtkPopoverMenu
Instead of a fake one where we add .menu to a normal popover. This makes
the menu look like other context menus.
2020-02-20 10:23:09 +01:00
Timm Bäder
b58f9e2aa2 filechoosererrorstack: Set a layout manager
Otherwise it doesn't know what to do with its child widget.
2020-02-20 10:23:09 +01:00
Timm Bäder
b8a752c751 filechooserwidget: Allow typing a location in recent mode
This is triggered by typing / or hitting Ctrl+L. Since we don't have a
visual indicator for this mode right now anyway, the reason for not
allowing it in recent mode cited in the comment just above the
early-exit is irrelevant.

Closes #2178
2020-02-20 10:23:09 +01:00
Timm Bäder
194039c749 filechooserwidget: Remove unused constants 2020-02-20 10:23:09 +01:00
Timm Bäder
64d0f848bc text: Remove gtk_text_get_im_context()
Unused.
2020-02-20 10:23:09 +01:00
Timm Bäder
d8a61b3185 docs: Remove focus_tracking.txt
All the info in there is outdated and not useful.
2020-02-20 10:23:09 +01:00
Timm Bäder
d3936f8d93 docs: Remove developers.txt
Everything in there has either been removed in the past or is outdated
information.
2020-02-20 10:23:09 +01:00
Timm Bäder
63bb1c2aaa docs: Remove dnd_internals.txt
This is either already completely outdated or will be soon.
2020-02-20 10:23:09 +01:00
Timm Bäder
e18a159f16 spinbutton: Remove manual queue_draw() calls
Everything is automatically redrawn when changing the value, etc.
2020-02-20 10:23:09 +01:00
Timm Bäder
a1bc3ae2c8 popvermenu: Clarify css node docs
We add the .menu css class to the popover main node, not its contents
node.
2020-02-20 10:23:09 +01:00
Timm Bäder
2ad6c045b4 aboutdialog: Clarify docs and fix preconditions 2020-02-20 10:23:09 +01:00
Timm Bäder
ec6d5839bd modelbutton: Un-select on mouse leave
This brings us closer to the old GtkMenuItem behavior and also makes
more sense.
2020-02-20 10:23:09 +01:00
Timm Bäder
2bf9a5bd29 aboutdialog: Replace visited_links GList with GPtrArray 2020-02-20 10:23:09 +01:00
Timm Bäder
b5d4815eb7 aboutdialog: Use new GtkStackPage API 2020-02-20 10:23:09 +01:00
Timm Bäder
188f00e05a stack: Add GtkStackPage:visible accessors 2020-02-20 10:23:09 +01:00
Benjamin Otte
9660ae5556 Merge branch 'wip/xdg-popup-async-relayout' into 'master'
Synchronous popup layout

See merge request GNOME/gtk!1241
2020-02-19 18:57:14 +00:00
Emmanuele Bassi
da828a9d0c Merge branch 'ci-flatpak' into 'master'
ci: Update flatpak jobs

See merge request GNOME/gtk!1451
2020-02-19 15:35:21 +00:00
Emmanuele Bassi
3a054d5a90 ci: Update flatpak jobs
The CI infrastructure was changed to run with fewer privileges, so we
need to adapt our Flatpak jobs to compensate.

See: https://mail.gnome.org/archives/desktop-devel-list/2020-February/msg00055.html
2020-02-19 15:04:58 +00:00
Jonas Ådahl
ca71119a40 gdk/surface: Replace move_to_rect() with GdkPopupLayout based API
Replace the gdk_surface_move_to_rect() API with a new GdkSurface
method called gdk_surface_present_popup() taking a new GdkPopupLayout
object describing how they should be laid out on screen.

The layout properties provided are the same as the ones used with
gdk_surface_move_to_rect(), except they are now set up using
GdkPopupLayout.

Calling gdk_surface_present_popup() will either show the popup at the
position described using the popup layout object and a new unconstrained
size, or reposition it accordingly.

In some situations, such as when a popup is set to autohide, presenting
may immediately fail, in case the grab was not granted by the display
server.

After a successful present, the result of the layout can be queried
using the following methods:

 * gdk_surface_get_position() - to get the position relative to its
   parent
 * gdk_surface_get_width() - to get the current width
 * gdk_surface_get_height() - to get the current height
 * gdk_surface_get_rect_anchor() - to get the anchor point on the anchor
   rectangle the popup was effectively positioned against given
   constraints defined by the environment and the layout rules provided
   via GdkPopupLayout.
 * gdk_surface_get_surface_anchor() - the same as the one above but for
   the surface anchor.

A new signal replaces the old "moved-to-rect" one -
"popup-layout-changed". However, it is only intended to be emitted when
the layout changes implicitly by the windowing system, for example if
the monitor resolution changed, or the parent window moved.
2020-02-19 09:47:18 +01:00
Jonas Ådahl
37f4c644d3 gdk/surface: Reset position after hiding
The x and y position of GdkSurface is only valid when visible, so reset
them to their inital state after hiding.
2020-02-19 09:47:18 +01:00
Jonas Ådahl
46d40cd4bd wayland: Simplify logic deciding whether to use xdg_popup
From a handful of hueristics and guess-work, to a single
`surface->surface_type == GDK_SURFACE_POPUP`.
2020-02-19 09:47:18 +01:00
Jonas Ådahl
11dbc384ab wayland: Fix top-most-popup check
We can map a non-grabbing popup wherever, it's just the grabbing
popup-chain that needs to be ensured not to break any ordering rules.

Fix this by managing two lists; one of open popups, and another for
grabbing ones.
2020-02-19 09:47:18 +01:00
Jonas Ådahl
ebd3ee9880 gdk: Move GdkGeometry declaration to gdktypes.h 2020-02-19 09:47:18 +01:00
Jonas Ådahl
339a04da7c gdk: Move GdkGravity to gdktypes.h 2020-02-19 09:47:18 +01:00
Jonas Ådahl
40693412d3 x11: Make gdk_surface_get_position() return relative position
The returned position should be relative to the parent surface, but
GdkSurface::x,y were only managed properly for O-R windows. This makes
it correct for regular windows too.
2020-02-19 09:47:18 +01:00
Jonas Ådahl
2bb0eddfb5 wayland: Simplify popup parent discovery
Now popups surfaces are always created with the parent set, so we don't
need to implement vorious guess work to try to find what the parent
might be. Remove that code and just use GdkSurface::parent which is
where the parent set during construction ends up at.
2020-02-19 09:47:18 +01:00
Jonas Ådahl
49fcbc27ca wayland: Remove old "gdk-attached-grab-surface" hackery
The corresponding code in gtk/ is long gone, so it's luckly unused these
days.
2020-02-19 09:47:18 +01:00
Jonas Ådahl
7fafa5133b wayland/surface: Add per surface configuration event queues
Add event queues specifically for surface configuration events
(xdg_surface.configure, xdg_toplevel.configure, xdg_popup.configure etc)
so that a configuration can be completed without having side effects on
other surfaces. This will be used to synchronously configure specific
GdkSurfaces, as is needed by the Gtk layout mechanisms.
2020-02-19 09:47:18 +01:00
Jonas Ådahl
0d086872ae gdk/wayland/surface: Use dedicated bool for frame callback freezing
The freezing is conditioned on various state, so lets make the thawing a
bit more robust. Without this there was a risk that we'd thaw too many
times if there was a frame callback requested while the conditions for
the freezing were not met.
2020-02-19 09:47:18 +01:00
Jonas Ådahl
f284e1d483 wayland: Remove position method split
Position can only be done via gdk_surface_queue_relayout(); the legacy
way is no longer possible, so remove the legacy positioning code.
2020-02-19 09:47:18 +01:00
Jonas Ådahl
4e78dd2ae0 gdk/surface: Use enum type for surface type 2020-02-19 09:47:18 +01:00
Jonas Ådahl
6eaeadb3b9 tests/popover: Add check box for switching autohide prop 2020-02-19 09:47:18 +01:00
Jonas Ådahl
f43717a42e popover: Unrealize when autohide prop changes
Changing the autohide property means the popover needs to be remapped.
Remapping may need user interaction, so lets just unrealize the popover
if the property changes, forcing the application to remap it should it
be shown again.
2020-02-19 09:47:18 +01:00
Timm Bäder
5097c1defc Merge branch 'file-filter-name-property' into 'master'
GtkFileFilter: Add a GObject property for the name

See merge request GNOME/gtk!376
2020-02-19 07:43:51 +00:00
Matthias Clasen
d58a381c93 Merge branch 'icontheme-api' into 'master'
Icontheme api

Closes #2410

See merge request GNOME/gtk!1449
2020-02-19 01:50:49 +00:00
Matthias Clasen
66307f00f1 icontheme: Update the api
Add properties, and use string arrays instead of lists.

Among other things, this renames gtk_icon_theme_list_icons
to gtk_icon_theme_get_icon_names.

Fixes: https://gitlab.gnome.org/GNOME/gtk/issues/2410
2020-02-18 20:32:17 -05:00
Matthias Clasen
db1ca92790 Merge branch 'wip/otte/for-master' into 'master'
debug: When debug-printing, treat NULL as the default display

See merge request GNOME/gtk!1450
2020-02-19 01:18:04 +00:00
Benjamin Otte
732716ba95 debug: When debug-printing, treat NULL as the default display
Otherwise we lose debug prints from all code that allows NULL displays.
2020-02-19 01:21:33 +01:00
Matthias Clasen
03ee4229f2 Merge branch 'wip/otte/dnd' into 'master'
More DND rework

See merge request GNOME/gtk!1445
2020-02-18 22:15:56 +00:00
Emmanuele Bassi
e64cce2ca3 Merge branch 'dialog-headerbar-type-annotation' into 'master'
GtkDialog: Add `type Gtk.HeaderBar` annotation to headerbar getter return value

See merge request GNOME/gtk!1447
2020-02-18 10:58:06 +00:00
Sebastian Dröge
8378eb22a3 GtkDialog: Add type Gtk.HeaderBar annotation to headerbar getter return value 2020-02-18 10:55:31 +02:00
Benjamin Otte
0d4d4e9a8c colorbutton: Fix drag source
By running it in the capture phase, it will not be starved for events by
the button's click source and make drags actually start a color drag
operation.
2020-02-18 02:58:58 +01:00
Benjamin Otte
7ca149ff90 Remove gdk_content_provider_new_with_formats()
See the removal of gdk_content_provider_new_with_callback() for a
rationale.
2020-02-18 02:40:00 +01:00
Benjamin Otte
7ae5fd357c tests: Modernize testdnd2 2020-02-18 02:40:00 +01:00
Benjamin Otte
b8cf7ea1c6 dnd: Port the TreeModel machinery to GValue DND 2020-02-18 02:40:00 +01:00
Matthias Clasen
308d2caf31 Merge branch 'text-emoji-history' into 'master'
text: Treat Emoji insertion like clipboard

See merge request GNOME/gtk!1444
2020-02-17 22:31:17 +00:00
Benjamin Otte
1145da3ea5 placessidebar: Modernize DND
No more shooting pointers through pipes
2020-02-17 21:56:16 +01:00
Benjamin Otte
27d7aa1407 notebook: Use proper DND
Actually use GValues for the DND operation instead of sending GBytes of
pointer addresses through pipes.

This is a bit complicated because we need to special-case rootwindow
drops, because they're handled on the source side, so we need a custom
ContentProvider.
2020-02-17 21:56:16 +01:00
Benjamin Otte
9703fcc605 notebook: Move dnd scrolling via arrows to own drop target
This removes excess code from the tab dnd machinery
2020-02-17 21:56:16 +01:00
Benjamin Otte
e25bfa6a61 dragdest: Handle NULL content formats everywhere
NULL means we don't do content formats checks and accept everything.

We use this for notebook arrows or expanders that react to ongoing
drags.
2020-02-17 21:56:16 +01:00
Benjamin Otte
9a7607b419 contentprovider: Add a union content provider 2020-02-17 21:56:16 +01:00
Matthias Clasen
a838a54dca text: Treat Emoji insertion like clipboard
Enter the Emoji inseration in the undo history.
Also, stop stashing away the selection when we
pop up the Emoji chooser, and use the selection
as-is when we insert the Emoji.
2020-02-17 15:05:09 -05:00
Benjamin Otte
f5e3584b5b placessidebar: Don't claim to support text dnd
Because you don't. And never did.
2020-02-17 04:04:21 +01:00
Benjamin Otte
80ba7fd682 dragdest: Make gtk_drop_target_new() args be transfer full
Saves tons of code.
2020-02-17 04:04:21 +01:00
Benjamin Otte
91d91a29e8 colorbutton, colorswatch: Simplify DND
- Use GDK_TYPE_RGBA and let GDK do the conversion from
  application-x-color
- Don't do extra mime type checks when accept() does that for us already
2020-02-17 04:04:21 +01:00
Benjamin Otte
3a7e3cf90d dragdest: Simplify function
Make it obvious that the functions checks one condition and then the
other.
2020-02-17 04:04:21 +01:00
Benjamin Otte
e1f8c1430f dnd: simplify code
The old code did mimetype checks everywhere when type compatibility has
since been moved to the GtkDropTarget::accept signal.

So the code can now just assume a compatible mime type exists.
2020-02-17 04:04:21 +01:00
Benjamin Otte
da83457a60 dnd: Remove gdk_content_provider_new_with_callback()
Content providers are meant to be immutable, apart from very special
cases, but in those cases they need to emit
gdk_content_provider_content_changed().

Having a constructor that just uses a get_func invites abuse of this
by not making developers aware of those requirments.
In fact, all users in GTK failed to do this.

Instead, code should use the GtkDragSource::prepare signal to create
content providers when needed.

The same problem exists with gdk_content_provider_new_with_formats(),
but this commit doesn't touch that.
2020-02-16 20:10:31 +01:00
Benjamin Otte
dbad440468 testdnd3: Use GValue dnd 2020-02-16 20:10:30 +01:00
Benjamin Otte
8d2ed36a1b contentprovider: Add gdk_content_provider_new_typed()
Gets around the boilerplate required to create and initialize a GValue
by having this function doing it via G_VALUE_COLLECT().
2020-02-16 20:10:30 +01:00
Benjamin Otte
762c4602fb wayland: Destroy the offer on gdk_drop_finish()
Otherwise the compositor won't be aware the dnd failed and will in turn
not notify the drag source.
2020-02-16 20:10:30 +01:00
Benjamin Otte
5a726bc665 drop: Add a state machine for tracking events 2020-02-16 20:10:30 +01:00
Benjamin Otte
410dbdf671 widget: Fix namespacing problem
In Vala and JS at least, gtk_widget_get_css_name() and
gtk_widget_class_get_css_name() are resolved to
GtkWidget.get_css_name().

To avoid this problem, we rename the class version.
2020-02-16 20:05:05 +01:00
Benjamin Otte
43b8aff62c widget: Fix typos for css-clases property 2020-02-16 19:57:45 +01:00
Benjamin Otte
47c8026e38 Merge branch 'wip/otte/dnd' into 'master'
some DND fixes

See merge request GNOME/gtk!1440
2020-02-15 23:45:25 +00:00
Benjamin Otte
b844f34cda tests: Do proper local DND
Just transfer GValues.
2020-02-15 22:33:57 +01:00
Benjamin Otte
46bbb397e1 wayland: Use a magic mime type for local DND
Otherwise the compositor gets all confused when it's trying to make
drag happen but we know it's not going to happen.

After all, we exchange data behind its back, we just need to keep it
informed.
2020-02-15 22:33:57 +01:00
Benjamin Otte
894ac6c126 dragdest: Use format matching APIs 2020-02-15 21:04:33 +01:00
Benjamin Otte
a824da66d9 drop: Ensure all relevant formats are available
1. GdkDrop does deserialization, so add the deserialize formats

2. If the drop is local, we can copy straight from the drag, so we can
   also copy all its formats. This fixes cases where the backend would
   drop formats it doesn't support.
2020-02-15 20:02:44 +01:00
Timm Bäder
08501c9510 calendar: Emit {next,prev}-{month,year} signals
Fixes #833
2020-02-15 17:18:27 +01:00
Timm Bäder
a4ecfd8f33 widget: Use get_css_name() in get_property()
Instead of reimplementing it there.
2020-02-15 17:18:27 +01:00
Timm Bäder
28482e52be Adwaita: Add focus outlines back to scale troughs
Fixes #189
2020-02-15 17:18:27 +01:00
Timm Bäder
bf839dbb88 coloreditor: Scale h value to 360
Fixes #1321
2020-02-15 17:18:27 +01:00
Timm Bäder
2529464e21 range: Avoid rounding errors when allocating highlight
Fixes #2438
2020-02-15 17:18:26 +01:00
Timm Bäder
7e43034068 widget: Add css-classes property
Mirroring the values added and removed via {add,remove}_css_class().
2020-02-15 17:18:26 +01:00
Timm Bäder
52979a0e93 infobar: Remove _get_{action,content}_area()
Accessors like these are weird to have and we can add widgets to the
content area via gtk_container_add() as well as add widgets to the
action area via gtk_info_bar_add_action_widget().
2020-02-15 17:18:26 +01:00
Timm Bäder
78a5bf8e21 Remove gtk_info_bar_get_content_area() uses
We can just add() to the info bar directly.
2020-02-15 17:18:26 +01:00
Timm Bäder
8612a8a39f testinfobar: Stop using gtk_info_bar_get_content_area()
We have an easier way of adding widgets to the content area of an
infobar: Just gtk_container_add() them like usual.
2020-02-15 17:18:26 +01:00
Timm Bäder
a7de8e6b2f infobar: Don't store close button visibility separately
We can already set and query that value via
gtk_widget_{get,set}_visible() on the close button.
2020-02-15 17:18:26 +01:00
Timm Bäder
3cc57c2e3a actionbar: Use a bin layout 2020-02-15 17:18:26 +01:00
Timm Bäder
a1d47ec59f calendar: Add style class to today's label
Add the .today style class to the label indicating the current day.

Fixes #230
2020-02-15 17:18:26 +01:00
Timm Bäder
43a9f9bd02 calendar: Document style classes
Fixes #790
2020-02-15 17:18:26 +01:00
Matthias Clasen
e5d83eea30 events: Make proximity and scroll events have tools
The Wayland backend tries to set device tools on these
events, and it was just an oversight that they don't
carry them.
2020-02-15 09:44:34 -05:00
Benjamin Otte
5f7054862b Merge branch 'wip/otte/for-master' into 'master'
Drop GTK_WINDOW_POPUP

See merge request GNOME/gtk!1437
2020-02-14 20:42:11 +00:00
Matthias Clasen
8ef7013165 Drop gdk_surface_new_temp
GTK is not using this API anymore, and we want
to consolidate our surface types to just toplevels
and popups.
2020-02-14 21:20:12 +01:00
Matthias Clasen
723b894c19 testsuite: Stop using gdk_surface_new_temp
We can just use regular toplevels here.
2020-02-14 21:19:29 +01:00
Benjamin Otte
c1f71ee3e8 window: Remove GtkWindowType and window->type
And remove code that was making decisions on the type and just use
the part for toplevels.
2020-02-14 21:18:49 +01:00
Benjamin Otte
222e6e5d6e testsuite: Use GtkTextDirection instead of GtkWindowType
GtkWindowType is aout to be dropped, so use another enum for the enum
tests - one that is likely to survive for a long time.
2020-02-14 21:18:49 +01:00
Benjamin Otte
de49e47690 textview: Fix docs typo 2020-02-14 21:18:49 +01:00
Benjamin Otte
a278edab22 window: Remove type argument from gtk_window_new() 2020-02-14 21:18:49 +01:00
Benjamin Otte
c2bd4bc3cb testsuite: Replace popups with toplevels
The tests do not depend on the window being a popup.
2020-02-14 21:18:49 +01:00
Benjamin Otte
fb856d96cd builder: Use different construct-only property
The window type is going away, so use the css name instead.
2020-02-14 21:18:49 +01:00
Benjamin Otte
264967b764 widget: Add gtk_widget_get_css_name() API 2020-02-14 21:18:49 +01:00
Benjamin Otte
ad23ce23ad testsuite: Remove popup property from simplify tools
I'm not even sure a popup GtkAssistant should be a thing...
2020-02-14 21:18:49 +01:00
Benjamin Otte
41bdf16b23 testsuite: Turn all CSS test ui files into regular windows
Use undecorated windows instead of popups.
2020-02-14 21:18:49 +01:00
Benjamin Otte
2c843362a0 testsuite: Make a11y tests use regular windows 2020-02-14 21:18:49 +01:00
Benjamin Otte
922f9df86f Merge branch 'wip/otte/for-master' into 'master'
reftests: Change popup windows to non-decorated windows

See merge request GNOME/gtk!1435
2020-02-14 17:12:17 +00:00
Benjamin Otte
980934f82d reftests: Change popup windows to non-decorated windows
This allows getting rid of popup windows.
2020-02-14 17:54:38 +01:00
Matthias Clasen
c45ed9d76e Merge branch 'zhaoqiang/gtk-To_avoid_compiler_warning' 2020-02-14 08:47:36 -05:00
Matthias Clasen
b6cb1a6eb3 Merge branch 'master-subtract-base-size' into 'master'
gdk: Subtract base size when checking aspect ratio

See merge request GNOME/gtk!1331
2020-02-14 13:19:42 +00:00
Mohammed Sadiq
22a6aaf4c5 Merge branch 'wip/otte/for-master' into 'master'
slicelistmodel: Fix two wrong computations

See merge request GNOME/gtk!1433
2020-02-14 02:39:21 +00:00
Benjamin Otte
d303b5b0eb slicelistmodel: Fix two wrong computations
Both of those are thinkos during math.
Found by Mohammed Sadiq.

Testcases triggering both have been added.
2020-02-14 03:15:22 +01:00
Matthias Clasen
97ec29d3f5 Force-create style contexts in realize
This is necessary as long as style contexts are
required for proper css change tracking.

Fixes #2435
2020-02-13 21:14:01 -05:00
Emmanuele Bassi
eb2e0137fa Merge branch 'master' into 'master'
Fixed OpenGL extension detection for extensions promoted to OpenGL core.

Closes #2428

See merge request GNOME/gtk!1424
2020-02-13 19:53:33 +00:00
David Hogan
0969d06925 Fix detection of OpenGL 3.3 core GL_ARB_timer_query.
Some systems (notably macOS) will not allow enumeration of an extension that has been promoted to core OpenGL for context in use. This change assumes that GL_ARB_timer_query is available on OpenGL 3.3+.

I could not find definitive information on whether GL_ARB_debug_output or GL_KHR_debug have been added to core. Other extensions in use were addressed by https://gitlab.gnome.org/GNOME/gtk/merge_requests/1422 .
2020-02-14 05:41:01 +11:00
David Hogan
c4111dad31 Fixed OpenGL extension detection for extensions promoted to OpenGL core.
For a given OpenGL context, macOS in particular does not support enumeration / detection of OpenGL features that have been promoted to core OpenGL functionality. It is possible other drivers are the same. This change assumes support for GL_ARB_texture_non_power_of_two with OpenGL 2.0+, GL_ARB_texture_rectangle with OpenGL 3.1+ and GL_EXT_framebuffer_blit with OpenGL 3.0+. I failed to find definitive information on whether GL_GREMEDY_frame_terminator has been promoted to OpenGL core, or whether GL_ANGLE_framebuffer_blit or GL_EXT_unpack_subimage have been promoted to core in OpenGL ES. This change results in a significant GtkGLArea performance boost on macOS.

Closes #2428
2020-02-14 05:41:01 +11:00
Emmanuele Bassi
33c6032a10 Merge branch 'ci-flatpak' into 'master'
CI pipeline changes for Flatpak jobs

See merge request GNOME/gtk!1429
2020-02-13 18:10:29 +00:00
Emmanuele Bassi
9a631f2942 ci: Remove G_MESSAGES_DEBUG
We don't need all the debugging messages.
2020-02-13 17:10:19 +00:00
Emmanuele Bassi
9332abfd5b ci: Allow flatpak jobs to fail
We have more accurate CI jobs, now; the Flatpak jobs are nice to have.
2020-02-13 17:09:35 +00:00
Matthias Clasen
883980c48c Merge branch 'gi-fixes' into 'master'
Various fixes for documentation and introspectable API

See merge request GNOME/gtk!1427
2020-02-13 16:38:41 +00:00
Matthias Clasen
2e0af29839 Make release builds mandatory for ci
The tests are now passing in release builds, lets keep
it that way.
2020-02-13 11:21:15 -05:00
Matthias Clasen
cdee2ac173 testsuite: Handle icontheme test better
Skip just the failing tests in release builds.
2020-02-13 10:56:26 -05:00
Matthias Clasen
a66ed7c461 gsk: Fix the compiler warning differently 2020-02-13 10:42:21 -05:00
Emmanuele Bassi
09abb43628 Merge branch 'report-fixes' into 'master'
Fixes for the CI test reports

See merge request GNOME/gtk!1426
2020-02-13 15:04:04 +00:00
Emmanuele Bassi
de1543d4fa ci: Use per-suite anchors
Anchors are global, so they need to be namespaced.
2020-02-13 14:55:39 +00:00
Emmanuele Bassi
5ed3f8d98b ci: Rearrange the results in the HTML report
Move the failures up top, so they stand out.
2020-02-13 14:55:39 +00:00
Emmanuele Bassi
affc7b58fa ci: Fix the HTML anchor in the report 2020-02-13 14:55:39 +00:00
Emmanuele Bassi
2b1e273c53 ci: Use result instead of exit code in the JUnit report
We have a result code coming from Meson which is more accurate than just
looking at the exit code of the unit.
2020-02-13 14:55:39 +00:00
Emmanuele Bassi
1a4d1f8994 ci: Unexpected passes are failures
List them as such in our reports.
2020-02-13 14:55:39 +00:00
Emmanuele Bassi
adc7bf9f25 ci: Put the branch name in the HTML header 2020-02-13 14:55:39 +00:00
Emmanuele Bassi
f4a8edf441 ci: Move HTML report meta from header to article
Makes the bar smaller.
2020-02-13 14:55:39 +00:00
Emmanuele Bassi
3dc6a07f5d ci: Re-enable ccache 2020-02-13 14:55:39 +00:00
Emmanuele Bassi
2a0dfa9670 Remove gtk_style_context_get_parent()
The function was declared and mentioned in the documentation, but it has
been removed in commit 416182a20d.
2020-02-13 14:53:25 +00:00
Emmanuele Bassi
40852ea952 gi: Skip gtk_custom_layout_new()
The whole GtkCustomLayout class is mostly a C convenience API, and
there's no reason why high level languages should use it.
2020-02-13 14:53:25 +00:00
Emmanuele Bassi
32a2a629dd Fix the function name in the gtk-doc stanza
The documentation is still referring to the old function's name.
2020-02-13 14:53:25 +00:00
Emmanuele Bassi
35ac7de140 Match argument name between declaration and definition
Otherwise the documentation and the introspection data will complain.
2020-02-13 14:53:25 +00:00
Emmanuele Bassi
0d354d1dc4 docs: Match the argument name with its declaration 2020-02-13 14:53:25 +00:00
Emmanuele Bassi
cdd7e4c5ec Add a notify function to GdkContentProvider
The callback-based content providers need a GDestroyNotify function to
free the data passed to them on construction, otherwise they are going
to leak.
2020-02-13 14:53:25 +00:00
Matthias Clasen
47f2a6cafd Remove border-half-pixel reftest from xfail
It passes both locally and on ci now.
2020-02-13 09:39:27 -05:00
Matthias Clasen
313c399122 Merge branch 'wip/otte/no-clip-on-draw' into 'master'
Various fixes to rendernode drawing with Cairo

See merge request GNOME/gtk!1425
2020-02-13 13:43:59 +00:00
Benjamin Otte
052d0f6e60 gdk: Remove gdk_cairo_get_clip_rectangle()
The function is fundamentally broken for unbounded surfaces.
If a surface is unbounded, we cannot represent this as a
cairo_rectangle_int_t, and using the return value doesn't work because
it's already used for something else.

In GTK3, unbounded surfaces aren't a problem, but GTK4 uses recording
surfaces.

So better remove that function before we keep using it and using it
wrong.
2020-02-13 07:36:38 +01:00
Benjamin Otte
8f6cab6560 cairoblur: Get rid of gdk_cairo_get_clip_rectangle() call
It's about to be removed.
2020-02-13 07:36:38 +01:00
Benjamin Otte
6203cecf97 gsk: Clip shadow node before push_group()
We want to be sure to push a group that's as small as possible, so we
clip to the child's bounds, because that's the smallest we can go.
2020-02-13 07:36:38 +01:00
Benjamin Otte
6f9f18009c gsk: Add a utility function for rectangles
... and use it.
2020-02-13 07:36:38 +01:00
Benjamin Otte
67610b1242 cairoblur: Move the check for early exit
That means we only have one place where we check all kinds of early
exits.
2020-02-13 07:36:38 +01:00
Benjamin Otte
f0993fc881 rendernode: Avoid rounding errors
Compute the pattern matrix directly instead of transforming the cairo_t.

This ensures that when node_size / texture_size is some obscure floating
point value, we don't get rounding issues from scaling by it once we
draw the texture_size rectangle.

I have no actual failure where this comes in handy, but I had written
the code anyway, so decided to keep it.
2020-02-13 07:36:38 +01:00
Benjamin Otte
75b130ed6b testsuite: Add tests for rounded rect code
... including the bug that was fixed in the parent commit.
2020-02-13 07:36:38 +01:00
Benjamin Otte
77d7c713d4 roundedrect: Fix inlining of graphene functions
graphene treats equality for contains() operations as always matching,
so do the same thing.

This is because unlike integer math, floating point cannot do the "as
close as possible to the point, but not reaching it" operation that
integer does by just subtracting 1.
2020-02-13 07:36:38 +01:00
Benjamin Otte
b0369fc300 roundedrect: Fix gsk_rounded_rect_intersects_rect()
The previous code would return FALSE for
  gsk_rounded_rect_intersects_rect (&rounded, &rounded.bounds);
if rounded was indeed rounded.
2020-02-13 07:36:38 +01:00
Benjamin Otte
16e38701b6 testsuite: Don't use gdk_cairo_get_clip_rectangle()
I want to remove it.
2020-02-13 06:15:44 +01:00
Benjamin Otte
9d8ceb0cb2 testsuite: Don't destroy surfaces that are still used
Coercing the surfaces must not unref the old surface, because the old
surface is going to be saved to a file.
2020-02-13 06:15:44 +01:00
Benjamin Otte
c313a71c3a testsuite: Remove accidentally checked in file
This file should go in the listview branch I guess.
2020-02-13 06:14:05 +01:00
Matthias Clasen
fb84fe7065 Fix flickery hover
Commit 47c44644b1 was a bit overzealous in fixing
compiler warnings. We still need to call collect_textures,
even if we don't need the number that it returns.
2020-02-12 22:45:24 -05:00
Matthias Clasen
9be8f8cf43 Merge branch 'wip/baedert/cairo-paint' into 'master'
Remove cairo_clip() when drawing render nodes

Closes #2431

See merge request GNOME/gtk!1418
2020-02-12 23:44:38 +00:00
Matthias Clasen
14ecc9ec7e Remove unused signal enum values
GtkWidget lost even more signals, so we don't need
these enum values anymore.
2020-02-12 18:25:42 -05:00
Matthias Clasen
073e8dd987 popovermenu: Avoid an uninitialized variable
Pointed out by Timm/clang.

Fixes https://gitlab.gnome.org/GNOME/gtk/issues/2434
2020-02-12 17:58:41 -05:00
Matthias Clasen
6c6b3d0d11 Merge branch 'ci-pages' into 'master'
Rename the SCSS files for our themes

Closes #2423

See merge request GNOME/gtk!1423
2020-02-12 22:35:58 +00:00
Emmanuele Bassi
2ab9be54fb Rename the SCSS files for our themes
It seems that Meson's gnome.compile_resources() cannot deal with two
files with the same name under different directories, which breaks the
build parallelism because the GResource file ends up not depending on
either the Adwaita or the HighContrast gtk-contained.css file.

This commit only changes the on-disk names of the Adwaita and
HighContrast SCSS files, and the corresponding generated CSS files; the
files in the GResource are going to be aliased to the old file names, to
minimise the breakage. We might want to change the theme entry points at
some later date, if we decide to commit to this naming scheme.

Fixes: #2423

See Meson bug: https://github.com/mesonbuild/meson/issues/6615
2020-02-12 20:22:43 +00:00
Matthias Clasen
11ab39617e Fix the Emoji chooser finalize
If the Emoji chooser is finalized before the idle
has run, it would spew criticals, breaking some tests.
Avoid that.
2020-02-12 14:23:01 -05:00
Georges Basile Stavracas Neto
7404c393f3 Merge branch 'gbsneto/fix-emojichooser-header' into 'master'
build: Install gtkemojichooser.h

See merge request GNOME/gtk!1420
2020-02-12 18:56:19 +00:00
Georges Basile Stavracas Neto
1b95cd27bc build: Install gtkemojichooser.h
It was made public at ef7172dc1e, but the header file
wasn't added to the public headers list.

Add the header file to the list.
2020-02-12 15:41:49 -03:00
Emmanuele Bassi
88e2a060f8 Merge branch 'ci-pages' into 'master'
Small CI pipeline fixes

See merge request GNOME/gtk!1419
2020-02-12 18:38:39 +00:00
Emmanuele Bassi
4247bf0fb6 ci: Update flatpak job
Use `flatpak build` and point at the nightly repo when generating the
bundle.
2020-02-12 18:24:54 +00:00
Emmanuele Bassi
f2da5e5617 ci: Deploy the API ref before flatpak 2020-02-12 18:12:53 +00:00
Emmanuele Bassi
f51ceb142b ci: Fix linking of the CI assets in the report
The report is relative to the build directory, and so are the generated
assets.
2020-02-12 18:12:53 +00:00
Matthias Clasen
e1d85aeeb0 testsuite: Warn if a necessary env var is missing
Better to warn if we know why the tests are
going to fail. Saves headscratching later.
2020-02-12 12:18:59 -05:00
Matthias Clasen
cc8506ca15 Move performance tests to the right testsuite
This was a copy-paste error.
2020-02-12 12:18:59 -05:00
Timm Bäder
52c46e5c24 rendernode: Don't clip when _draw()ing 2020-02-12 16:54:49 +01:00
Timm Bäder
b12a6be9d9 rendernode: draw() only in node bounds
We currently disable when draw()ing nodes using the cairo fallback path,
which means we can't just use cairo_paint(). Use a proper rectangle
instead.

Fixes #2431
2020-02-12 16:54:46 +01:00
Matthias Clasen
d702c159d5 Merge branch 'cleanup-profiler-marks' into 'master'
Cleanup profiler marks

See merge request GNOME/gtk!1417
2020-02-12 14:31:40 +00:00
Alexander Larsson
6e3dd6dd62 profile: Use separate names for frameclock marks instead of using details
The marks are averaged based on the name, so this makes more sense.

Also rename the map/unmap marks to have the same capitalization as
everything else.
2020-02-12 14:29:31 +01:00
Alexander Larsson
d9c59a7c8c profiler: Add G_GNUC_PRINTF markers to silence warnings
I was getting CI failures like:
 ../gdk/gdkprofiler.c: In function ‘add_markvf’:
../gdk/gdkprofiler.c:111:3: error: function ‘add_markvf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
2020-02-12 13:36:04 +01:00
Alexander Larsson
324202a56c profiler: Clean up profiler marks for frameclock
This drops the marks for before/after-paint as they are internal
things that very rarely use any time, and also flush/resume-events
as any events reported here will get separate marks so will be easy
to see anyway.

Also, we rename the entire frameclock cycle to "frameclock cycle"
rather than "paint_idle" which is rather cryptic.
2020-02-12 13:20:32 +01:00
Alexander Larsson
e3a67385f4 profiler: Add profiler marks for when surfaces are mapped and unmapped
This is done on the X11 side so we can tell when the map/unmap takes
effect and how long it took since the map request.
2020-02-12 12:44:43 +01:00
Alexander Larsson
b4b00e2887 icon theme: Don't add profiler marks for short async icon loads
We do a bunch of preloads, and most of these are not really interesting
anyway.
2020-02-12 12:43:27 +01:00
Alexander Larsson
e134eef505 builder: Don't add profiler marks for short parses
There are a lot of thes (since we're recursing), so don't spew the
output with uninteresting ones.
2020-02-12 12:42:29 +01:00
Alexander Larsson
2890cd849f profiler: Add _end_mark() version of _add_mark()
These don't take a duration, instead they call g_get_monotonic_time() to
and subtract the start time for it.

Almost all our calls are like this, and this makes the callsites clearer
and avoids inlining the clock call into the call site.
2020-02-12 11:25:34 +01:00
Alexander Larsson
01d5ad2056 profiler: Make profiler-is-running a macro
When we use if (GDK_PROFILER_IS_RUNNING) this means we get an
inlined if (FALSE) when the compiler support is not compiled in, which
gets rid of all the related code completely.

We also expand to  G_UNLIKELY(gdk_profiler_is_running ()) in the supported
case which might cause somewhat better code generation.
2020-02-12 11:05:01 +01:00
Alexander Larsson
cc643df88b Convert all profiler times from nsec to usec
usec is the scale of the monotonic timer which is where we get almost
all the times from. The only actual source of nsec is the opengl
GPU time (but who knows what the actual resulution of that is).

Changing this to usec allows us to get rid of " * 1000" in a *lot* of
places all over the codebase, which are ugly and confusing.
2020-02-12 10:44:17 +01:00
Alexander Larsson
13eedf1a9f Use markf in one more place 2020-02-12 10:40:26 +01:00
Alexander Larsson
685fd3c33d fixup! Add gdk_profiler_add_markf() to do printf formating 2020-02-12 10:11:53 +01:00
Alexander Larsson
8a1c51db1c Use the new gdk_profiler_add_markf() function 2020-02-12 09:59:03 +01:00
Alexander Larsson
6de85c0a68 Add gdk_profiler_add_markf() to do printf formating
This allows us to avoid hand-rolling g_strdup_printf calls,
but also moves the printf into the called function where
it doesn't bloat the code of the calling function if the profiler
is not running.
2020-02-12 09:58:52 +01:00
Carmen Bianca BAKKER
c2dcd1bf94 Update Esperanto translation 2020-02-12 07:43:58 +00:00
Matthias Clasen
6e0cf02494 Merge branch 'mark-events-with-kind' into 'master'
profiler: Always mark events with the kind

See merge request GNOME/gtk!1414
2020-02-11 19:01:10 +00:00
Alexander Larsson
36808e0c81 profiler: Always mark events with the kind 2020-02-11 19:51:49 +01:00
Matthias Clasen
9062607d5f Merge branch 'wip/baedert/outline-radius' into 'master'
css boxes: Compute box from border box

Closes #2425

See merge request GNOME/gtk!1408
2020-02-11 16:59:11 +00:00
Emmanuele Bassi
042a5736fa Merge branch 'share-gl-programs' into 'master'
GskGLRenderer: Share programs between different renderers in same display

See merge request GNOME/gtk!1413
2020-02-11 16:30:16 +00:00
Matthias Clasen
720e48ec51 Merge branch 'handle-max-texture-size' into 'master'
gl: Don't require too large texture for offsreen ops

See merge request GNOME/gtk!1411
2020-02-11 16:23:02 +00:00
Matthias Clasen
9d0393d8e6 Merge branch 'fix-angle-normalization' into 'master'
gsk: Fix angle normalization

See merge request GNOME/gtk!1409
2020-02-11 16:17:14 +00:00
Alexander Larsson
7b0b3d9547 GskGLRenderer: Share programs between different renderers in same display
This is similar to how we share texture atlases. Some added complexity
in that the program state also needed to be shared, so it had to move to
the shared Programs object.

With this change realization of additional GskRenderers when opening
popups went from ~60msec to ~35 msec on average.
2020-02-11 16:58:45 +01:00
Emmanuele Bassi
bb71cdd722 Merge branch 'ci-jobs' into 'master'
Update CI jobs

See merge request GNOME/gtk!1412
2020-02-11 15:25:48 +00:00
Emmanuele Bassi
2b425fa88a ci: Allow release job to fail
We need to investigate release-specific failures, and possibly fix our
test suite to deal with debug-specific poking through the internal
state.

For the time being, allow the release job to fail, but this is strictly
a temporary measure.
2020-02-11 15:12:14 +00:00
Emmanuele Bassi
b99a4da939 testsuite/gtk: Add xfail tests
Some tests are expected to fail.

Some tests are expected to fail in non-debugging builds.

The icontheme test is the latter.
2020-02-11 14:53:57 +00:00
Emmanuele Bassi
c69595a3a9 vulkan: Handle VK_ERROR_UNKNOWN
A newly added Vulkan 1.2 error.
2020-02-11 14:47:22 +00:00
Emmanuele Bassi
76aba1f046 ci: Add a style check pass
We should at least try to get the style check done by a machine, as
opposed to have humans go through merge requests with coding style
nitpicks.
2020-02-11 14:47:22 +00:00
Emmanuele Bassi
59028d7d0f ci: Generate the report for the release builds
We are going to need to hide the report generation into the test runner
script, as we want the job to produce the reports even in case of
failure, instead of bailing out immediately.
2020-02-11 14:47:22 +00:00
Emmanuele Bassi
0df542e494 Declare global counters only in debug builds 2020-02-11 14:47:22 +00:00
Emmanuele Bassi
47c44644b1 Silence compiler warnings in non-debug builds 2020-02-11 14:47:22 +00:00
Emmanuele Bassi
1806af1e83 Declare global counter only in debug builds 2020-02-11 14:47:22 +00:00
Matthias Clasen
b5dc03d940 Merge branch 'fix-revealer-scale' into 'master'
revealer: Fix child size allocation at small scales

See merge request GNOME/gtk!1410
2020-02-11 14:06:36 +00:00
Emmanuele Bassi
c4dfacc404 ci: Add missing newline escape
Otherwise we're going to run the accessibility test suite, and it's
going to fail.
2020-02-11 13:39:52 +00:00
Emmanuele Bassi
c00896a090 ci: Remove static build job
Now that we figured out why the build was failing on Fedora when the
profiling code was enabled, we can go back to building both shared and
static libraries by default.
2020-02-11 13:39:52 +00:00
Emmanuele Bassi
5ace9ef4e8 ci: Use the new Fedora image 2020-02-11 13:39:52 +00:00
Emmanuele Bassi
a7d295254f ci: Add static packages for GLib and PCRE
Otherwise Meson will warn about missing static dependencies for
sysprof-capture-3.
2020-02-11 13:39:52 +00:00
Emmanuele Bassi
62352dd1fc Fix compiler warnings in the release build
We have a bunch of debug-only variables that get set and never used
outside of debug code paths, and the compiler is not happy about it.
2020-02-11 13:39:52 +00:00
Emmanuele Bassi
74b5bb12fb ci: Disable ccache 2020-02-11 13:39:52 +00:00
Emmanuele Bassi
02ac7ff0aa Initialise out variable
Otherwise we might return an undefined value, and the compiler will be
very cross at us.
2020-02-11 13:39:52 +00:00
Emmanuele Bassi
c06a08d63a ci: Split the static and shared builds (again)
Sadly, we can't do a static build with the profiling code enabled
because we don't have a static GLib build available.
2020-02-11 13:39:52 +00:00
Emmanuele Bassi
9e38a70c6b ci: Replicate the CI image scripts from GLib
They are easier to use and document, and allow us to add new base images
in the future without making a mess.
2020-02-11 13:39:52 +00:00
Emmanuele Bassi
56f9cdd99d ci: Refactor the CI pipeline
We should have a single job for building both static and shared
versions of GTK. On the other hand, having a separate job for the
release build would be a plus.

Additionally, we shouldn't use an opaque script to build GTK; the only
step in the process that requires hand-holding is running the tests
suites under Xvfb, and having the build options visible from the YAML
file gives us a better idea of what kind of build we're running.
2020-02-11 13:39:52 +00:00
Emmanuele Bassi
153e8a0c92 ci: Use release builds for Flatpak bundles 2020-02-11 13:39:52 +00:00
Chun-wei Fan
6ec546be02 tests/frame-stats.c: Include stdlib.h
It is used for exit().
2020-02-11 20:59:04 +08:00
Alexander Larsson
dc6fe091b9 revealer: Fix child size allocation at small scales
As pointed out in https://gitlab.gnome.org/GNOME/gtk/issues/1481
and seen from critical warnings with swinging revealers in widget-factory
there are some size allocation issues in GtkRevealer.

What happens is that we request a size of the revealer itself
based on the child natural size and the current stage of the transition
by applying a scale to the natural size. We then round up to nearest
int size. However, we want the widget to render as if it did get the
natural size so we can transform it, rather than the scaled down size.
For example, a label should not start ellipsizing in the animation.
So we inverse the scale when allocating the child.

Unfortunately, for very small scales the inversion of the scale can
result in very large sizes, and for such scales we rounded up the
requested size to 1, so we will be allocating huuuuge children.

In order to avoid such issue we pick an arbitrary maximum upscale
scale factor of 100. This means that in the case where the allocated
size is 1 we never allocate the child at > 100 px. This means
that in large downscaling cases we may run into the clipping issue
described above. However, at these downscaling levels (100 times!)
we're unlikely to notice much detail anyway.
2020-02-11 13:52:12 +01:00
Alexander Larsson
1f0438e7fe gsk: Fix angle normalization
I was getting assertions that normalize_angle() failed the
result < 260 check. Doing some research on this it turns out
to be a precision issue. If the incomming angle is very slightly
below zero, then adding 360 to it may end up with exactly 360.

I simplified the code a bit to avoid division and rounding, because in
practice most angles will be "just outside" the 0-360 degree anyway.
And i also added a workaround for the "result is 360" case by just
setting it to 0.
2020-02-11 13:51:06 +01:00
Alexander Larsson
8fdb710c0f gl: Don't require too large texture for offsreen ops
When rendering ops to an offscreen texture we take max-texture-size
in consideration and modify the scale we use such that the required
texture does not exceed the limit.

This means some rendering will be blocky/fuzzy, but that is better
than it being clipped.
2020-02-11 13:50:35 +01:00
Matthias Clasen
af98c46d04 Typo fix 2020-02-11 07:46:12 -05:00
Matthias Clasen
7ac2982617 Revert "Add the label-wrap-justify reftest to xfails"
This reverts commit 5e746d35b2.

Turns out label-wrap-justify isn't failing in ci, and this is
now making ci fail :(
2020-02-11 07:44:01 -05:00
Timm Bäder
8561860aa1 css boxes: Compute inline box from border box
We can't just use the outline rect and apply the border radius because
the outline box is the border box grown by the outline offset, which
will also grow the resulting border radius.

Fixes #2425
2020-02-11 12:10:16 +01:00
Matthias Clasen
37a9d0620d 3.98.0 2020-02-10 15:32:19 -05:00
Matthias Clasen
5e746d35b2 Add the label-wrap-justify reftest to xfails
Seems just like the other label tests, down to details
of text rendering.
2020-02-10 15:19:13 -05:00
Matthias Clasen
d711ca3a67 Drop the toplevel-vs-popup reftest
Popups look different from toplevels. I don't think
a reftest that tries to prove otherwise has much
leg to stand on.
2020-02-10 15:15:05 -05:00
Matthias Clasen
564a43cd3a Disable the buttons a11y test
The test fails because radio buttons are currently broken.
2020-02-10 15:06:56 -05:00
Matthias Clasen
17a5e9b2aa Update expected test output
The a11y test for GtkAssistant produces different
output due to headerbar changes.
2020-02-10 15:03:47 -05:00
Matthias Clasen
c0dcaccf4b calendar: Fix mismatches with GDateTime
GDatetime uses 1-based month and day numbers, whereas
GktCalendars are 0-based. Correct for this.
2020-02-10 14:59:40 -05:00
Matthias Clasen
11cd955591 Calendar: Make year/month/day writable again
Our a11y tests were relying on this.
2020-02-10 14:14:18 -05:00
Matthias Clasen
0677bfeb7f testsuite: Update expected output
The output for combo boxes in a11y tests has changed
because they use popovers now.
2020-02-10 13:55:37 -05:00
Matthias Clasen
b38eb6eab4 Merge branch 'fix-gestures-test' into 'master'
Fix gestures test

See merge request GNOME/gtk!1406
2020-02-10 15:57:54 +00:00
Alexander Larsson
7d23b6dad5 Fix gestures test
This tests was testing gestures by faking an event in the
middle of a window that has a hbox with an expanding image in it.
For me (and I guess this depends on all sorts of issues like whether
CSD is enabled, font sizes, etc) the hbox ended up centered horizontally
but not vertically (probably because of csd at the top), so no events
ever hit the inner widgets.

This is fixed by emitting the events at allocation.x/y of the
hbox, which should contain both the hbox and the image (as it expands).
2020-02-10 16:24:03 +01:00
Matthias Clasen
e5e7dbf2a5 Merge branch 'fix-hidpi-popups' into 'master'
Fix popup placement on hidpi multi-monitor

See merge request GNOME/gtk!1405
2020-02-10 15:08:51 +00:00
Alexander Larsson
23211bcae8 hidpi: Rescan monitors when screen scale factor changes
All the code in e.g. init_randr15() divides the physical resolutions with
the screen scale, however if we get the screen scale from xsettings
rather than e.g. GDK_SCALE the initial setup is using the wrong value.

So, whenever the screen scale size is changed we need to trigger
a re-read of the randr data
2020-02-10 15:34:32 +01:00
Matthias Clasen
59b935af38 Merge branch 'mainloop-cleanup' into 'master'
Mainloop cleanup

See merge request GNOME/gtk!1404
2020-02-10 14:32:09 +00:00
Matthias Clasen
d0f5ce41aa More updates 2020-02-10 08:13:23 -05:00
Alexander Larsson
1698369d52 Merge branch 'icon-theme-api-rework' into 'master'
Icon theme api rework

See merge request GNOME/gtk!1390
2020-02-10 12:45:56 +00:00
Alexander Larsson
96a4bb446c Fix typo in GtkIconPaintable is-symbolic property 2020-02-10 13:30:57 +01:00
Alexander Larsson
ad0e901061 icon-theme: Add back and fix test for handling non-square icons
We test this by looking at the produced render nodes now that
we don't actualluy scale the icon. Also, it turns out that this
code was broken due to some typos, so we also fix those.
2020-02-10 13:17:15 +01:00
Alexander Larsson
ba781eca74 Expose gtk_icon_paintable_new_for_file 2020-02-10 13:17:15 +01:00
Alexander Larsson
8f1253ad26 GtkIconPaintable: Add properties for file, icon-name and is-symbolic 2020-02-10 13:17:05 +01:00
Matthias Clasen
e123fff545 Merge branch 'baselineoverlay' into 'master'
A baseline overlay

See merge request GNOME/gtk!840
2020-02-10 12:07:18 +00:00
Alexander Larsson
904eecd1ed icon paintable: Replace get_filename and get_resource_path with get_file()
This returns a GFile which can represent both the above.
2020-02-10 12:33:17 +01:00
Alexander Larsson
344ad65031 Rename GTK_ICON_LOOKUP_LOAD_IN_THREAD to GTK_ICON_LOOKUP_PRELOAD 2020-02-10 11:43:47 +01:00
Alexander Larsson
14b3b684ef icontheme: Always return some icon name in get_icon_name() for lookup results
If you called gtk_icon_theme_lookup(), then always return some useful
icon name from gtk_icon_paintable_get_icon_name(), even if we picked
an unthemed icon.

Also rewrite the gtk_icon_paintable_get_icon_name() docs to make this
clearer.
2020-02-10 11:40:00 +01:00
Matthias Clasen
9309153abc Remove GTK_DEBUG=baselines
This has been reimplemented differently
in the inspector.
2020-02-10 00:10:43 -05:00
Matthias Clasen
643417dc32 widget: Stop embedding baseline debugging
The inspector has an overlay that achieves the
same, in a cleaner way.
2020-02-10 00:10:43 -05:00
Matthias Clasen
4a978dc8c4 inspector: Draw baselines as an overlay 2020-02-10 00:10:43 -05:00
Matthias Clasen
bc4637fff6 Remove unused includes
We eventually want to get rid of GtkSelectionData.
As a first step, stop including gtkselection.h unnecessarily.
2020-02-09 23:59:22 -05:00
Matthias Clasen
eec219e6c7 docs: Mention gtk_main in the migration guide 2020-02-09 23:13:13 -05:00
Matthias Clasen
a8db322be6 Drop gtk_get_main_thread
This is not a very useful api, and if you need it,
you can just as easily keep track yourself which thread
called gtk_init().
2020-02-09 23:13:13 -05:00
Matthias Clasen
4dd780a96b Drop gtk_main and gtk_main_quit
The alternatives are to use GtkApplication,
or use GMainContext.
2020-02-09 23:13:13 -05:00
Matthias Clasen
4c22939dea docs: Update an example
Don't use gtk_main() in the mainloop example.
It is going away.
2020-02-09 23:12:32 -05:00
Matthias Clasen
a6c5466900 Stop using gtk_main and gtk_main_quit
Replace these calls with direct use of GMainContext api.
2020-02-09 23:12:32 -05:00
Matthias Clasen
c789711652 Stop using gtk_main_quit
Stop using gtk_main and gtk_main_quit in tests and
examples. These APIs are on the way out.
2020-02-09 23:12:32 -05:00
Matthias Clasen
7eb889c7aa Drop gtk_main_level
This api isn't useful without gtk_main, which is also
on the way out.
2020-02-09 23:12:32 -05:00
Matthias Clasen
49a6ad3dd1 Drop gtk_main_iteration
This function and its cousin, gtk_main_iteration_do, are
thin wrappers around GMainContext api that should just
be used directly.
2020-02-09 23:12:32 -05:00
Matthias Clasen
ebc720bfdb Drop gtk_events_pending
This was just a thin wrapper around gtk_main_context_pending,
which should be used directly instead.
2020-02-09 23:11:49 -05:00
Matthias Clasen
24917ac353 tests: Stop using gtk_events_pending
Just use the GMainContext api directly.
2020-02-09 23:11:49 -05:00
Matthias Clasen
9eeeb631ca win32 printing: Stop using gtk_events_pending
Just use the GMainContext API directly.
2020-02-09 23:11:49 -05:00
Matthias Clasen
07988fc17f win32: One more build fix 2020-02-09 23:04:10 -05:00
Matthias Clasen
4f79676b0b win32: Fix the build 2020-02-09 22:58:53 -05:00
Matthias Clasen
900ff743f1 Merge branch 'main-cleanup' into 'master'
Cleanup in gtkmain.h

See merge request GNOME/gtk!1403
2020-02-10 03:55:11 +00:00
Benjamin Otte
810f55c006 filechooser: Remove outdated hack
In GTK2, the filechooser was using a Paned, so switching between sidebar
and files list with the arrow keys didn't work (the slider would be
selected instead). So in
https://bugzilla.gnome.org/show_bug.cgi?id=161489 a crude hack was added
to make this possible.

Over the years the filechooser code has changed so that it now would do
this by default, yet the hack had been retained.
2020-02-09 16:54:38 -05:00
Benjamin Otte
fce37b137d gdk: Make gdk_keyval_name() return a const char
The string is const, so return it like that.
2020-02-09 16:50:22 -05:00
Matthias Clasen
998384aa08 Remove unused include 2020-02-09 16:50:22 -05:00
Emmanuele Bassi
327441fa3e cssprovider: Remove unused include 2020-02-09 16:50:22 -05:00
Matthias Clasen
b927609e21 Remove gtk_propagate_event from public API
This is not a function that can be safely called
outside of GTK.
2020-02-09 11:00:53 -05:00
Matthias Clasen
688f8bf085 Remove gtk_main_do_event from public API 2020-02-09 10:55:56 -05:00
Matthias Clasen
057f41532b Remove gtk_main_do_event from the docs 2020-02-09 10:55:37 -05:00
Matthias Clasen
ebc24d75af testsuite: Stop using gtk_main_do_event
Instead, emit ::event on the surface. Neither of
these is a proper test api, but one works as well
as the other.
2020-02-09 10:54:26 -05:00
Matthias Clasen
c1970009ff docs: Remove more mentions of gtk_main_do_event 2020-02-09 10:45:33 -05:00
Matthias Clasen
8f0fc24516 docs: Remove a reference to gtk_main_do_event
It is not great to put a function in the public api and
document it as "do not call this" only so we can refer
to its docs in other places. Therefore, fold the docs
directly into the input handling overview chapter.
2020-02-09 10:38:01 -05:00
Matthias Clasen
ba825dce29 docs: Remove a mention of gtk_main_do_event 2020-02-09 10:37:24 -05:00
Matthias Clasen
c4b16f7424 css: Add a comment
All the other color values have this comment,
best to be consistent.
2020-02-09 10:23:27 -05:00
Matthias Clasen
cffff36436 Merge branch 'wip/baedert/remove-outline-properties' into 'master'
css: Remove outline border radius properties

Closes #2414

See merge request GNOME/gtk!1402
2020-02-09 15:03:44 +00:00
Matthias Clasen
7de5b391ab gsk: Update docs sections 2020-02-08 19:40:56 -05:00
Matthias Clasen
0e15032635 gsk: Small documentation additions 2020-02-08 19:36:25 -05:00
Matthias Clasen
be2ba89900 Fix a doc comment
Signals take two colons.
2020-02-08 19:27:32 -05:00
Matthias Clasen
a824be2bb9 docs: Drop a few no longer existing symbols 2020-02-08 19:25:13 -05:00
Matthias Clasen
348dcaa4a3 docs: Update the switch thumbnail
Make the thumbnail for switches reflect the
current appearance of this widget.
2020-02-08 19:22:23 -05:00
Matthias Clasen
f240bcbbc4 emojichooser: Fix the docs
Make the emojichooser show up in the docs.
2020-02-08 19:21:57 -05:00
Matthias Clasen
621a427627 Fix the build with -Dgtk_doc=true
We need to export the emoji chooser symbols to
really make it public api.
2020-02-08 19:04:19 -05:00
Matthias Clasen
645f49cf2b Fix build with -Dgtk_doc=true
Toolbars were removed, so don't try to create
thumbnails of them.
2020-02-08 19:02:46 -05:00
Timm Bäder
01ba11fc71 css: Remove outline border radius properties
These are always set to the same value as the corresponding border
radius properties. They are also non-standard, so remove them and
replace them with the border radius properties everywhere.

Fixes #2414
2020-02-08 20:43:16 +01:00
Matthias Clasen
f6b0e0e1c2 Merge branch 'avoid-mime-sniffing' into 'master'
Avoid mime sniffing where possible

See merge request GNOME/gtk!1400
2020-02-08 15:44:16 +00:00
Matthias Clasen
2f17ab3ce7 Avoid mime sniffing where possible
When we are loading symbolic pngs or svgs, we know
that we need to the png or svg loader, so there is
no need to go through (surprisingly expensive) mime
sniffing to find the right loader.
2020-02-08 10:22:54 -05:00
Matthias Clasen
55b60f6da9 gtk-demo: Don't call gtk_main_quit
It doesn't work with GtkApplications that do not
call gtk_main().
2020-02-07 16:25:02 -05:00
Matthias Clasen
1f74695758 Adwaita: Fix selection in vertical spin buttons
This was broken by more specific selectors.
2020-02-07 15:43:07 -05:00
Matthias Clasen
1ab70e2dfa Merge branch 'patch-1' into 'master'
Update migrating-3to4.xml (fixed typo, in line 377)

See merge request GNOME/gtk!1398
2020-02-07 19:23:55 +00:00
J Arun Mani
3cbb3dc0f4 Update migrating-3to4.xml 2020-02-07 18:30:42 +00:00
Matthias Clasen
e3afb2fec8 label: Don't use gtk_widget_peek_style_context
We may just not have a style context. And we can just
as well go directly to the css styles.
2020-02-07 13:16:45 -05:00
Timm Bäder
d3857f8bd3 window: Move variable initialziation just before usage 2020-02-07 13:16:45 -05:00
Timm Bäder
655711fef2 Rename gtk_widget{get,set,has}_style_class to _css_class
We want to use css instead of style everywhere now.
2020-02-07 13:16:45 -05:00
Timm Bäder
69fa15981c treepopover: Fix header guard 2020-02-07 13:16:32 -05:00
Timm Bäder
2a46d5960d box: Move vfunc implementations before class_init
Just like we do everywhere else. This way we can also get rid of all the
prototypes.
2020-02-07 13:16:32 -05:00
Timm Bäder
b9b5cae6d2 calendar: Remove day-selected-double-click signal
It doesn't really make sense to treat double clicks here different than
single clicks (and is bad UX), and it also breaks switching months by
quickly trying to single-click the last/first days in the calendar.
2020-02-07 13:16:32 -05:00
Timm Bäder
3249756648 calendar: Remove an unused enum 2020-02-07 13:16:32 -05:00
Timm Bäder
8ef9009bde calendar: Remove month-changed signal
Listen to notify::month instead.
2020-02-07 13:16:32 -05:00
Timm Bäder
093eac9441 calendar: Keep a GDateTime around
Instead of a year/month/day triple.
2020-02-07 13:16:32 -05:00
Timm Bäder
93c6f2256f calendar: Return a GDateTime from get_date() 2020-02-07 13:16:32 -05:00
Timm Bäder
1151da5cf3 calendar: Use GDateTime to select days 2020-02-07 13:16:32 -05:00
Timm Bäder
a6f9052cf1 calendar: Use widgets for everything 2020-02-07 13:16:32 -05:00
Timm Bäder
a437162f6d calendar: Try to avoid changing size when changing the year 2020-02-07 13:16:32 -05:00
Timm Bäder
9ecd448682 calendar: Remove spinning code
This is dead code
2020-02-07 13:16:32 -05:00
Timm Bäder
74cb1ca2f5 calendar: Add accessors for display properties
Instead of having a display flags enum and bitfield, just add proper
accessors for the properties, which is what we do everywhere else.
2020-02-07 13:16:32 -05:00
Timm Bäder
e94e703685 testcalendar: Remove unused function 2020-02-07 13:16:32 -05:00
Timm Bäder
4cceba06bc calendar: Remove details
This is an unused feature that's way too complicated for a default
calendar widget and complicates the implementation a lot. Since we want
to eventually replace this with actual widgets, remove the details
support now.
2020-02-07 13:16:32 -05:00
Timm Bäder
ab84b17c1a calendar: Fix an uninitialized value
Values pased to gtk_widget_measure must be initialized to 0. This failed
if the header widget of the calendar was invisible.
2020-02-07 13:16:32 -05:00
Timm Bäder
7fd06cacbd Adwaita: Fix levelbar styling
The block nodes are inside a trough node.
2020-02-07 13:16:32 -05:00
Timm Bäder
b471158e38 {box,grid}layout: Access border spacing directly
Instead of going through the style context
2020-02-07 13:16:32 -05:00
Timm Bäder
8388791f87 GskTransform: Remove useless fmod check
All angles are in the [0; 360[ range
2020-02-07 13:16:32 -05:00
Timm Bäder
cbb05a3eab GskTransform: add assertions to make normalize_angle() intentions clear
360deg should be expressed as 0deg and no angle should ever be
negative.
2020-02-07 13:16:32 -05:00
Timm Bäder
4cfac3b91c snapshot: Remove new_with_parent
Unneeded now that we have push_collect()/pop_collect()
2020-02-07 13:16:32 -05:00
Timm Bäder
17ddae5bf9 textlayout: Use gtk_snapshot_{push,pop}_collect() 2020-02-07 13:16:32 -05:00
Timm Bäder
75ef8d8a50 GskRoundedRect: Inline graphene_rect_contains_rect
Brings gsk_rounded_rect_contains_rect down from 0.54% to 0.14% when
rendering rounded backgrounds.
2020-02-07 13:16:32 -05:00
Timm Bäder
47b8facca4 widget: Use gtk_snapshot_{push,pop})_collect
So we avoid allocating a new snapshot just for that.
2020-02-07 13:16:32 -05:00
Timm Bäder
bf8fb2c1a5 snapshot: Add _push_collect() and _pop_collect()
These will replace the previous gtk_snapshot_new_with_parent(), which
allocated an entirely new GObject just to push()/pop() some state. This
is already a problem but will be more important in the future as we
start using this more.
2020-02-07 13:16:32 -05:00
Timm Bäder
b7ee2cbc28 Start using GtkWidget's new style class API 2020-02-07 13:16:32 -05:00
Timm Bäder
b1d64a6b3a renderborder: Make simple border case more obvious
When reaching this point, it is impossible that all border styles are
HIDDEN or NONE, but up to 3 of them can still be that style. In any
case, the "none or solid" border style is the most common on there is,
so try to make this simpler here by just appending a border node
directly instead of going through the snapshot_border path.
2020-02-07 13:15:59 -05:00
Timm Bäder
60095ade9b Move GTK_BORDER_STYLE_HIDDEN before GTK_BORDER_STYLE_SOLID
The simple case when drawing border is "solid or nothing", which we can
now check for as simple as "style <= GTK_BORDER_STYE_SOLID".
2020-02-07 13:15:59 -05:00
Timm Bäder
3a727eed7a testcalendar: Close window properly 2020-02-07 13:15:59 -05:00
Timm Bäder
64c6229f54 searchbar: Use proper getter in _get_property()
Instead of retuning a seemingly random boolean, just use
gtk_search_bar_get_search_mode().
2020-02-07 13:15:59 -05:00
Timm Bäder
60be37d63a searchbar: Use g_object_notify_by_pspec
We already keep the pspecs around, so use them.
2020-02-07 13:15:59 -05:00
Timm Bäder
e044656d99 progressbar: Remove a few unneeded queue_resize() calls
This will happen automatically when adding style classes, setting the
label text, etc.
2020-02-07 13:15:59 -05:00
Timm Bäder
c0fef36692 Window: inline function into only caller 2020-02-07 13:15:59 -05:00
Timm Bäder
a67bd7a04e widget: Fix a from_string/try_string mixup 2020-02-07 13:15:59 -05:00
Timm Bäder
e152d25ac0 widget: Speed up verify_invariants()
Hide the expensive GTK_IS_ROOT() checks behind the cheaper realized,
mapped, etc. checks. This way we only check for the widget being a root
if the invariant does not hold.

This gets pop_verify_invariants() from 16% to 6% when running the
scrolling benchmark in the widget-factory.
2020-02-07 13:15:59 -05:00
Timm Bäder
b561eb8299 widget: Remove verify_child_invariants
Just calls verify_invariants() anyway.
2020-02-07 13:15:59 -05:00
Piotr Drąg
6150344195 Update POTFILES.in 2020-02-07 17:27:16 +01:00
Alexander Larsson
24fede0225 GtkIconHelper: Trigger preload when css sizes is valid
When the css is validated we know the css size, so we can
create the paintable at that point, and we do so passing the
LOAD_IN_THREAD flag.

This causes us to load most icons early on, in parallel instead of
during the first snapshot.
2020-02-07 17:26:22 +01:00
Alexander Larsson
e27413a9ed icon-theme: Add GTK_ICON_LOOKUP_LOAD_IN_THREAD flag
This causes lookup to trigger a thread that loads the icon texture.
2020-02-07 17:25:18 +01:00
Matthias Clasen
03317ec2ec NEWS: Small additions 2020-02-07 09:17:51 -05:00
Matthias Clasen
1a671cfd63 flatpak: Build against the master runtime
This is what the ci is set up to use, and building
against 3.34 fails there.
2020-02-07 09:17:51 -05:00
Matthias Clasen
24e28309fb Merge branch 'wip/otte/toolbar' into 'master'
remove GtkToolbar

See merge request GNOME/gtk!1383
2020-02-07 13:25:51 +00:00
Benjamin Otte
44e153d8a8 GtkToolbar: remove 2020-02-07 14:08:26 +01:00
Benjamin Otte
d72301b3c1 testsuite: Get rid of GtkToolbar
Just use GtkBox instead
2020-02-07 14:08:08 +01:00
Benjamin Otte
e00030dff2 css: Remove .primary-toolbar
It's not used anywhere anymore.
2020-02-07 14:08:08 +01:00
Benjamin Otte
9cccb944ef css: Remove .inline-toolbar
It's not used anywhere anymore.
2020-02-07 14:08:08 +01:00
Benjamin Otte
1363cacb3a widget-factory: Get rid of toolbars 2020-02-07 14:08:08 +01:00
Benjamin Otte
68dbb3f31a gtk-demo: Get rid of toolbars 2020-02-07 14:08:08 +01:00
Benjamin Otte
8a60f5dc78 bloatpad: Use a box, not a toolbar 2020-02-07 14:08:08 +01:00
Benjamin Otte
3d9e622fda print: Don't use a toolbar in the custom paper dialog
Use a regular linked box instead.
2020-02-07 14:08:08 +01:00
Benjamin Otte
645af0917c cssnode: Remove leftover vfunc 2020-02-07 14:06:20 +01:00
Matthias Clasen
c247e7680b Remove accidentally added files 2020-02-07 08:05:45 -05:00
Matthias Clasen
1da23b0c21 Add a forgotten word 2020-02-07 07:59:14 -05:00
Matthias Clasen
de299bb6bf Fix syntax 2020-02-07 07:50:02 -05:00
Matthias Clasen
65cc8305c9 Updates for 3.98 2020-02-07 07:48:30 -05:00
Alexander Larsson
bdbafe63f9 icontheme: Optimize memory use and lookup speed by internalizing icon names
Instead of having the IconTheme have a hashtable that owns
individual strings and then IconThemeDirSize have a similar
hash (but with the strings owned by the other hash), we
have a consecutive memory chunks where we store the icon names
and then the hashtable has pointers into this.

This means we can avoid a bunch of individual strdup()s in a
way that is less fragmented and wastes less space. Additionally,
since we do an initial lookup anyway we have the internalized
icon name during lookup which means we can use g_direct_hash/equal
instead of g_str_hash/equal making the lookup faster too.
2020-02-07 12:00:52 +01:00
Alexander Larsson
2be29f982d Remove stray space 2020-02-07 08:44:46 +01:00
Alexander Larsson
79699cc20d Use G_OBJECT_TYPE_NAME instead of g_type_name_from_instance 2020-02-07 08:44:29 +01:00
Matthias Clasen
c7ab02d38c Merge branch 'wip/carlosg/implicit-grabs-on-leave' into 'master'
Handle implicit grabs on leave events

Closes #13

See merge request GNOME/gtk!1397
2020-02-07 07:06:45 +00:00
Carlos Garnacho
e67f0bfcfd gtkmain: Wait for GDK_CROSSING_UNGRAB leave event with implicit grabs
If there is a passive grab and the pointer leaves the window we would
receive a GDK_CROSSING_NORMAL event when the pointer moves outside
the window, and a GDK_CROSSING_UNGRAB event when we do release the
button and the implicit grab.

We currently would react to the first, but want to react to the
second. In the time between both events, the client would still receive
pointer motion that will reach the implicitly grabbed widget.

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/13
2020-02-07 01:02:47 +01:00
Carlos Garnacho
56dc99a9fb gtkroot: Make enum a typedef
Seems a typo, and prevents building as GtkRootProperties is deemed
to be defined multiple times.
2020-02-07 01:00:52 +01:00
Matthias Clasen
cf69b7d4c2 Merge branch 'a11y-fixes' into 'master'
A11y fixes

See merge request GNOME/gtk!1396
2020-02-06 23:54:39 +00:00
Matthias Clasen
e45b668e04 testsuite: Misc. updates of expected output
The a11y dumps for action and header bars
have changed in harmless ways.
2020-02-06 18:04:36 -05:00
Matthias Clasen
769dae2c71 infobar: Implement forall
As a container, that is what you have to do.
2020-02-06 18:04:36 -05:00
Matthias Clasen
048effdc5a testsuite: Clean up a11y menu tests
We don't need some of the tests anymore, since
we just have popovers now.
2020-02-06 17:21:06 -05:00
Matthias Clasen
b916723baf testsuite: Improve --generate support
When using the test binary to generate expected
output, don't initialize the test machinery, since
that pollutes the output with noise.
2020-02-06 16:54:59 -05:00
Matthias Clasen
2dba92fd0c tests: Fix infobars in ui files
GtkInfoBar no longer exposes the content_area
as internal child.
2020-02-06 16:54:59 -05:00
Matthias Clasen
a11b1bd08e testsuite: Update expected output 2020-02-06 16:54:59 -05:00
Matthias Clasen
bc682bef74 colorchooser: Use a composite accessible
This makes the content show up in the a11y tree again.
2020-02-06 16:54:59 -05:00
Matthias Clasen
580384e962 tests: Update expected output
The stackswitcher is no longer a box, so it doesn't
have the horizontal state anymore.
2020-02-06 16:54:59 -05:00
Matthias Clasen
18965eec83 testsuite: Update some a11y tests
GtkMenuButton::use-popover no longer exists, remove it
from test files.
2020-02-06 16:54:59 -05:00
Matthias Clasen
145ccfe1c4 stackswitcher: Use a composite accessible
This makes the buttons show up in the a11y tree again.
2020-02-06 16:54:59 -05:00
Matthias Clasen
d01070d472 a11y: Add an accessible for widgets with children
We've started to turns containers into widgets which
just happen to have children, and some of these need
to be exposed to the a11y stack.

This adds a very minimal implementation, it does not
currently emit change notification when children are
added or removed.
2020-02-06 16:54:59 -05:00
Matthias Clasen
b3f5243aeb a11y: Report children of widgets
We want children of composite accessibles to be
reported.
2020-02-06 16:54:59 -05:00
Matthias Clasen
20aec5a744 Merge branch 'flatpak-build-sassc' into 'master'
Flatpak build sassc

See merge request GNOME/gtk!1392
2020-02-06 20:09:29 +00:00
Matthias Clasen
4a2d539251 Build sassc as a dependency for flatpaks
Downloading the subproject during the GTK build fails
in a flatpak build due to lack of network access.
flatpak-builder insists on having these things explicitly
spelled out as dependencies.
2020-02-06 14:30:31 -05:00
Alexander Larsson
a772bf7517 Add gtk_icon_paintable_get_resource_path()
Also, return NULL from gtk_icon_paintable_get_filename() if the path
is really a resource path.
2020-02-06 17:47:57 +01:00
Alexander Larsson
57ecb2829a Add gtk_icon_paintable_get_icon_name()
This allows you to see which icon was actually chosen.
2020-02-06 17:47:57 +01:00
Alexander Larsson
d45d604df1 Remove gtk_icon_paintable_download_texture() public API
This allows us do do what we want internally, and anyway it didn't
really do what you'd expect anymore now that we do resizing during
rendering.
2020-02-06 17:47:57 +01:00
Alexander Larsson
6317fd3529 Replace last users of gtk_icon_paintable_download_texture ()
These now render the paintable to a cairo surface and convert that
to a texture. This is sort of a hack, but its only used in two
special cases internally and in two hacky test apps.
2020-02-06 17:47:56 +01:00
Alexander Larsson
8282698201 textview: Use paintables instead of textures, and fix the support
This changes gtk_text_buffer_insert_texture() to
gtk_text_buffer_insert_paintable() which is strictly more useful
(as textures are paintables). It also fixes the code to actually
support drawing the paintables (as well as tracking changes
to the paintables.
2020-02-06 17:47:56 +01:00
Alexander Larsson
fcc3c12919 gtk_css_style_snapshot_icon_paintable: Fix uninitialized memory access
We were reading the foreground color alpha even when we didn't read it.
2020-02-06 17:47:56 +01:00
Alexander Larsson
7c73f2fb02 GskPango: Allow specifying a custom shape snapshot handler
We will need this for GtkTextView to render the textures in it.
2020-02-06 17:47:56 +01:00
Alexander Larsson
6ff9f2198d GtkBuilder: Directly load the fallback missing image
No need for all this complexity with the icon theme, especially when
its now a lot more work to get the texture back. We can just load
the pixbuf.
2020-02-06 17:47:56 +01:00
Alexander Larsson
1c253f5dfa icontheme: Move IMAGE_MISSING_RESOURCE_PATH to (private) header
This way other code can use this resource too for fallbacks, avoing
having to go through the icon theme.
2020-02-06 17:47:56 +01:00
Alexander Larsson
a0533923fb icontheme: Handle GEmblemIcon in lookup_by_gicon() 2020-02-06 17:47:52 +01:00
Matthias Clasen
5c594fc46a Merge branch 'WindowsPrintDriverPreferencesMaster' into 'master'
Fixed bug that prevented GTK from storing printer driver preferences in the…

See merge request GNOME/gtk!397
2020-02-06 13:07:13 +00:00
Matthias Clasen
b6e2699409 notebook: Update arrows when text direction changes
Fixes https://gitlab.gnome.org/GNOME/gtk/issues/103
2020-02-06 07:13:10 -05:00
Alexander Larsson
8788c76bd9 icon theme: Also never fail in gtk_icon_theme_lookup_by_gicon()
Similar to regular lookups, if the icon is some unknown type we return
a missing-image.
2020-02-06 10:26:15 +01:00
Alexander Larsson
6865744034 Remove unnecessary image-missing fallbacks
We now always return something from icon theme lookups, so no need to
do custom fallbacks.
2020-02-06 09:50:04 +01:00
Alexander Larsson
de02769a2f icon-theme: Don't pre-scale pixbufs in gtk_icon_theme_lookup_by_gicon
We do scaling during rendering now anyway.
2020-02-06 09:45:03 +01:00
Alexander Larsson
d69f7fd63e IconTheme: Never fail a lookup or icon load
If icon lookup fails or if loading it fails later, just always
fall back to the built in image-missing icon. Nobody is handling
missing icons in a sane way anyway.

If you *truly* need to handle missing icons, you need to manually
use gtk_icon_theme_has_icon().

While changing the loading code I also fixed an issue where it
was always passing "png" to pixbuf, now it also handles "xpm" if
that is the filename suffix.
2020-02-06 09:38:25 +01:00
Alexander Larsson
adccd1391e Support aspect=TRUE in _gdk_pixbuf_new_from_stream_at_scale
The icon theme test failed without this, and we *should* handle
it if we're accepting the argument.
2020-02-06 09:38:25 +01:00
Alexander Larsson
b529f77827 IconTheme: Simplify icon scaling
We had a pretty complex setup where we tried to avoid scaling up themes from dirs
that specified a size. However, not only was it very complex, but it didn't quite
work with window scales, because when using e.g. a size 32 directory for 16@2x
the dir size is wrong anyway. Additionally it turns out most code either picks
an existing icon size, or uses the FORCE_SIZE flags, so it doesn't seem
like a useful behaviour.

This change drops the FORCE_SIZE flags, and always scales
icons. Additionally it moves the scaling of the icon to rendering,
which seems more modern, and allows us to (later) share icons loaded
for different sizes that happened to use the same source file (at
different scales).

Note that this changes the behaviour of
gtk_icon_paintable_download_texture() is it now returns the unscaled
source icon. However, ignore thats, as I plan to remove this function
and replace it with a way to render a paintable to a cairo-surface
instead.
2020-02-06 09:38:25 +01:00
Alexander Larsson
021aaef824 GtkIconPaintable: Always recolor when snapshotting.
It never makes sense to paint a texture that needs recoloring. If
you call the regular snapshot on a symbolic texture we just use the
default recoloring colors.

To support this we also change gtk_css_style_snapshot_icon_paintable()
to call gtk_icon_paintable_snapshot_with_colors() for IconPaintables
so that we get the correct colors, and we make it not emit the color
matrix.

Since we now rely on the icon to do the recoloring we also drop the
recolor argument in gtk_icon_paintable_snapshot_with_colors() as its
not needed anymore.
2020-02-06 09:38:25 +01:00
Alexander Larsson
c691399a80 icontheme: Align function arguments 2020-02-06 09:38:25 +01:00
Matthias Clasen
2f369b6d7a Merge branch 'kill-simple-search' into 'master'
Remove simple search engine

See merge request GNOME/gtk!1393
2020-02-06 06:38:17 +00:00
Matthias Clasen
8703c7b7ac Merge branch 'better-test-isolation-2' into 'master'
Better test isolation

See merge request GNOME/gtk!1391
2020-02-06 04:53:07 +00:00
Matthias Clasen
e41e8072b1 css tests: Ignore ".csd" vs ".solid-csd"
It it hard to control which of the csd style classes we get,
since it depends on details of the X server or compositor.

Explicitly ignore this difference by replacing .solid-csd
with .csd in the output.
2020-02-05 23:35:39 -05:00
Matthias Clasen
d1bd1270c9 testsuite: Make tests run without a11y bus
Not having an a11y bus around causes warnings from
at-spi, which make tests fail. Explicitly ignore those
warnings.
2020-02-05 22:24:39 -05:00
Matthias Clasen
34cc68003c testsuite: Fix bloomfilter style tests
The results were expecting solid-csd, which is not what
we usually have.
2020-02-05 22:23:52 -05:00
Matthias Clasen
ac7dd02f8f Merge branch 'master.msvc' into 'master'
Fix building recent GTK master on Visual Studio

See merge request GNOME/gtk!1369
2020-02-05 18:26:22 +00:00
Matthias Clasen
9746b728ca Merge branch 'public-emojichooser' into 'master'
emojichooser: Make public

See merge request GNOME/gtk!1382
2020-02-05 18:04:42 +00:00
Benjamin Otte
0ad791277a Merge branch 'wip/otte/css' into 'master'
Some CSS cleanup

See merge request GNOME/gtk!1389
2020-02-05 14:04:12 +00:00
Matthias Clasen
54f6515005 emojichooser: Add profiler marks for loading
This is a long-running operation, and worth showing
in traces.
2020-02-05 06:28:39 -05:00
Matthias Clasen
25c25ba5c1 icontheme: Fix various memory leaks
Tasks need to be unreffed too.
2020-02-05 06:28:39 -05:00
Matthias Clasen
fac435ba98 widget: Fix a memory leak with class actions
This code was doing the wrong thing even if the parent class
doesn't have actions.
2020-02-05 06:28:39 -05:00
Matthias Clasen
b996b85504 Add a lib64 variant of gtk.supp 2020-02-05 06:28:39 -05:00
Matthias Clasen
1cb575a138 icontheme: Remove some dead code 2020-02-05 06:28:39 -05:00
Matthias Clasen
9a446f2041 frameclock: cosmetics
Redo the profiler marks for the frame clock signals
to look more uniform.
2020-02-05 06:28:39 -05:00
Matthias Clasen
9e6ae7acd8 gdk: Silence some compiler warnings
These cause unused variable warnings in release builds.
2020-02-05 06:28:39 -05:00
Matthias Clasen
955305a034 treestore: Silence compiler warnings
This was causing compiler warnings in release builds.
2020-02-05 01:01:47 -05:00
Matthias Clasen
b1d5de78e1 notebook: Don't trigger criticals in dispose
When we dismantle our children in dispose, we
trigger a11y children-changed signals which end
up calling back into the notebook. Handle this
without critical warnings.
2020-02-05 01:01:47 -05:00
Matthias Clasen
47c21a255f textview: Don't update action state in dispose
Only update the action state when we have a text buffer,
there is no need to do it otherwise, since we are going
to get a buffer before we get shown. This avoids triggering
the action state updates from finalize, which is a bad
time to be recreating the action muxer.
2020-02-05 01:01:47 -05:00
Matthias Clasen
005ea7a09d entry: Avoid criticals in dispose
The accessible gets properties of the entry, and
resetting the entry icons triggers accessible change
notification, so do that before we dismantle the entry
too far to respond to a g_object_get () call.
2020-02-05 01:01:47 -05:00
Matthias Clasen
ed6c0dc15c Don't export color picker functions
This is not public API, so it shouldn't be exported.
2020-02-05 01:01:47 -05:00
Matthias Clasen
1e6171a4a7 Read bookmarks async
Do not block the main thread while reading the bookmarks file.
This speeds up initial setup of a GtkPlacesSidebar.
2020-02-05 01:01:47 -05:00
Matthias Clasen
85ad943832 placessidebar: Change some initial property values
Giving these properties the initial value that the file
chooser wants for them avoids some calls to update_places
in the setup code.
2020-02-05 01:01:47 -05:00
Matthias Clasen
b7b251019e testperf: More flexible mark selection
Allow selecting marks not just by their name, but
also by the message detail.
2020-02-05 00:46:47 -05:00
Matthias Clasen
ed742f1d6c testperf: Allow measuring start time
This can be used e.g. to measure how long it takes us
to get the first frame on screen.
2020-02-05 00:46:39 -05:00
Benjamin Otte
fcb08a28bf stylecontext: Remove unused typedef 2020-02-05 04:03:43 +01:00
Timm Bäder
b75d408d6d css: Make some local variables const 2020-02-05 04:03:43 +01:00
Timm Bäder
98b42f6740 css: Remove unused function 2020-02-05 04:03:43 +01:00
Timm Bäder
416182a20d style context: Remove parent relationship
We don't have foreign drawing anymore, so we don't need this.
2020-02-05 04:03:43 +01:00
Benjamin Otte
31713ab5ef stylecontext: Remove gtk_style_context_new()
It's private now, no more foreign drawing of any sort.

To be fair, it was entirely useless without widget paths already.
2020-02-05 04:03:43 +01:00
Benjamin Otte
b9c880f58d testsuite: Remove the stylecontext test
Stylecontexts are on their way out and I'm removing API that the
testsuite was relying on, so remove the tests.

Put the useful parts of the tests elsewhere.
2020-02-05 04:03:43 +01:00
Benjamin Otte
db9730b734 stylecontext: Remove the "changed" signal
Instead, always go directly to the GtkWidget::css_changed() call.
2020-02-05 04:03:43 +01:00
Benjamin Otte
546a748cd8 widget: Replace style-updated signal with css_changed vfunc
1. Rename the thing
2. Turn it from a signal to a vfunc
3. Pass the GtkCssStyleChange to it

We don't export any public API about the GtkCssStyleChange yet, it's
just a boring opaque struct.
2020-02-05 02:46:13 +01:00
Benjamin Otte
8722837e67 pathbar: Remove unneeded code
The icons here are GIcons, they don't depend on the theme.
2020-02-05 00:18:41 +01:00
Benjamin Otte
3177ac4270 cssnode: Remove redundant check
We assert that cssnode->parent is NULL, no need to check it again.
2020-02-04 23:24:50 +01:00
Benjamin Otte
3f7e409428 Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master

See merge request GNOME/gtk!1388
2020-02-04 17:48:58 +00:00
Timm Bäder
903af75fa1 widget: Skip not-drawable widgets in snapshot_child
Otherwise we transform the snapshot just to not do anything.
2020-02-04 17:53:15 +01:00
Matthias Clasen
6640881711 maplistmodel: Add an example to the docs 2020-02-04 17:51:01 +01:00
Matthias Clasen
3bb8b56ab3 treelistmodel: Small documentation tweaks 2020-02-04 17:51:01 +01:00
Benjamin Otte
a1635719fc widgetfocus: Remove unnecessary check
Mapped widgets are always realized.
2020-02-04 17:51:01 +01:00
Benjamin Otte
3cb150abbe widget: Remove _gtk_widget_is_drawable()
Use _gtk_widget_get_mapped() instead.

Drawable checked visible && mapped and mapped widgets are always
visible, so that was an unnecessary check.
2020-02-04 17:51:01 +01:00
Benjamin Otte
cc22987b1b Merge branch 'wip/otte/icontheme' into 'master'
Do simple icontheme API cleanups

See merge request GNOME/gtk!1378
2020-02-04 16:36:46 +00:00
Alexander Larsson
410541f82b Rename GtkIcon to GtkIconPaintable 2020-02-04 17:19:22 +01:00
Benjamin Otte
c91be540c3 tooltip: Don't css-validate
That's a job for toplevels now.

See 17ca95a161 for the same comit on
popovers.
2020-02-04 17:19:04 +01:00
Benjamin Otte
138de60ab2 icontheme: Remove GENERIC_FALLBACKS
Instead, rely on people passing fallbacks explicitly.

Alternatively, GThemedIcon provides the functionality to create
fallbacks, which is what GtkImage and the testsuite now use.
That method is slightly better, too, so the expected test results
have been updated accordingly.
2020-02-04 16:51:54 +01:00
Benjamin Otte
571021cbc1 icontheme: Pass fallbacks as optional argument to lookup_icon()
This way, we can remove gtk_icon_theme_choose_icon() completely.
2020-02-04 16:51:54 +01:00
Benjamin Otte
f7a5dd7b8b icontheme: Remove contexts
There is no way to query contexts or do anything useful with them.

So don't keep track of them and don't make them an argument in public
APIs with the docs saying "I don't know what to use here, maybe read
some spec somewhere".
2020-02-04 16:51:54 +01:00
Benjamin Otte
544cd1acfc icontheme: Clean up includes 2020-02-04 16:43:59 +01:00
Benjamin Otte
4b96ba592f icontheme: Remove gtk_icon_get_base_size() and gtk_icon_get_base_dir()
Those functions are unused and the documentation says "Returns some
random number that the icon theme creator chose" which does not seem at
all useful and an implementation detail.

So get rid of it.
2020-02-04 16:43:59 +01:00
Benjamin Otte
7e8d8218b9 Revert "Break out cairo color matrix recoloring to gdk_cairo_image_surface_recolor()"
We're not in the business of adding Cairo APIs. That's Cairo's job.

Also, we don't need this API anywhere like the original commit claimed,
so there's no need to make it available in any way.

This reverts commit afa6cc2369.
2020-02-04 16:43:59 +01:00
Benjamin Otte
3bba52ed67 icontheme: Remove crayon APIs
We expose no API to get at any colors for drawing symbolics, so we
shouldn't have APIs to draw with them.

Apart from that, those APIs look like a box of crayons, not like an
icontheme.
2020-02-04 16:43:59 +01:00
Benjamin Otte
48b9791989 icontheme: Remove gtk_icon_theme_rescan_if_needed()
If the icon theme needs to be rescanned, it should just do it.
If it doesn't, there's no need for this function.

Ergo: Don't have the function.
2020-02-04 16:43:59 +01:00
Benjamin Otte
4c3363b8c2 icontheme: Remove NO_SVG and FORCE_SVG flags
If the icon theme loads SVGs or not is an implementation detail and
should not be exposed in public API.
2020-02-04 16:41:36 +01:00
Benjamin Otte
10023b5d6d icontheme: Remove GTK_ICON_LOOKUP_USE_BUILTIN
It's unused.
2020-02-04 16:41:36 +01:00
Benjamin Otte
bbbe39fb44 icontheme: Make text direction a lookup argument
Most users were just forgetting to set the proper flags.
And flags aren't the right way to set this anyway, it was just
acceptable as a workaround during GTK3 to not break API.
2020-02-04 16:41:36 +01:00
Benjamin Otte
b713b9f68d icontheme: Remove async APIs
Widgets would not use them properly. In fact, the only user was using
them wrong.

As icons are loaded async by default, this call isn't necessary.
2020-02-04 16:41:36 +01:00
Benjamin Otte
bfebc2b01a icontheme: Remove gtk_icon_theme_get_default()
The API encouraged wrong usage - most of the users were indeed wrong.

Use the correct version instead:
  gtk_icon_theme_get_for_display (gtk_widget_get_display ())
2020-02-04 16:41:36 +01:00
Alexander Larsson
a1856c30d9 a11y tests: Ignore "active" flag on toplevel
All the a11y tests were failing for me with a window state diff
like this:

-  state: active enabled resizable sensitive showing visible
+  state: enabled resizable sensitive showing visible

I guess the windows in the CI always gets the focus, but not when
I run it here. Generally focus seems asynchronous and hard to rely
on so I just made the test ignore the active state on toplevels.
2020-02-04 15:01:48 +01:00
Alexander Larsson
008eb04125 tests: Initialize dbus before gtk
These days initilizing gtk may create a connection to the sesson bus,
so we have to initialize GTestDBus before initalizing gtk, or we'll
use the address of the "real" session bus (and remember that in the
global).

To further muck things up, g_test_dbus_up() resets important env
vars like DISPLAY and XDG_RUNTIME_DIR, which we have to re-set.
2020-02-04 14:13:33 +01:00
Alexander Larsson
85e59220a5 filechooser portal: Free portal proxy when bus connection closes
This was blocking the clean exit from the testdbus shutdown in
the defaultvalues test. The proxy was keeping the connection alive
which blocks g_test_dbus_down().
2020-02-04 14:08:10 +01:00
Matthias Clasen
b8ffe5b245 css: Fix the initial values optimization
Fix up the index computation. We have duplicate entries
in the type enum, so to go from one of the 'initial' types
to it corresponding type you subtract one, but to find
the size array entry for a type, you divide by 2.
2020-02-04 12:19:23 +01:00
Matthias Clasen
4685fe1716 Merge branch 'faster-theme-lookup' into 'master'
Faster icon theme lookup

See merge request GNOME/gtk!1381
2020-02-04 10:51:27 +00:00
Alexander Larsson
046de4ccbf icon-theme: Only have one copy of the icon flags enum
It turns out with the icon cache now using the virtual SYMBOLIC_PNG_SUFFIX
flag the two enums are now identical, so lets just use one of them, the
one GtkIconCache (so we move it to the header).
2020-02-04 09:35:20 +01:00
Alexander Larsson
a3be0ec5f0 Don't use xsettings or xft defaults in testsuite
This adds a GDK_DEBUG=default-settings flag which disables reads
from xsettings and Xft resources, and enables this for the testsuite.

This is one less way to get different testresults depending on the
environment. In particular, it was failing the css tests for me
due to getting the wrong font size because i have a different dpi.
2020-02-03 15:11:35 +01:00
Matthias Clasen
ef7172dc1e emojichooser: Make public
This is a useful widget to have, and it has minimal api.

Not having it public forces apps to recreate a lot of
complicated machinery for not good reason, if they need
an Emoji chooser in a different context.
2020-02-03 12:49:36 +01:00
Alexander Larsson
308d434b57 GtkIconCache: Remove unused code
We're not really using the icon theme cache much anymore, as the
individual per-directory hashes are no longer used, so delete all the
unused code.
2020-02-03 12:49:32 +01:00
Alexander Larsson
e4170661b9 IconTheme: Make icon lookups faster
Traditionally the icon lookup for a theme has been:

lookup (icon_name, size):
  best_directory = NULL
  forearch theme
    foreach directory in theme
       if dir_size_matches (directory, size) && dir_has_icon (directory, icon-name)
         best_directory = chose_best_size_dir (best_directory, directory)

if best_directory
  return icon from best_directory

However, it turns out that there are a lot of subdirectories which have the same
size, as they differ only in the (essentially useless) "context" value. For example
the "16x16/apps" subdirectory is essentially the same as the "16x16/actions" one.

So, instead rathern than keeping all the directories as separate we store the
all the directories with the same size as a single entity (DirSize) and the
icon lookup in that DirSize looks up not only which suffix to use for that icon
but also which subdir it is in.

Additionally we keep a hashtable with all icon names that are
available in the entire theme (i.e. all DirSizes), which allows use
both to store each icon name only once, but also to do a quick
negative lookup and early exit in case we're looking up an icon that
doesn't exist. This is pretty common because we often look up sets of
icons like "image-png-symbolic", "image-png", "image", expecting some
to fail.

This brings down the time of the initial css validation from 20msec to 15msec for
me when running icon-factory.
2020-02-03 12:49:26 +01:00
Alexander Larsson
0a8d7603ea icon-cache: Add new function to list all the icons in a directory
This lists the icons in a particular director, with their flags in a
hashtable. We also convert from "icon.symbolic" + SUFFIX_PNG to
"icon" + SUFFIX_SYMBOLIC_PNG.
2020-02-03 12:49:26 +01:00
Chun-wei Fan
f8d3845b1a meson/MSVC builds: Use -utf-8 where available
This avoids the build from erroring out on C4819 (Unicode handling issue in
Visual Studio compiler), notably when running on Chinese, Japanese and
Korean locales.

Also apply -D_USE_MATH_DEFINES, -FImsvc_recommended_pragmas.h and -utf-8 to
the C++ compiler options as well.
2020-02-03 17:55:09 +08:00
Rico Tzschichholz
4ab12ab755 Remove last GtkWidgetPath reference
See 49b47c9133
2020-02-03 10:51:50 +01:00
Chun-wei Fan
69ed4c90e5 demos/widget-factory/widget-factory.c: Include stdlib.h
Include it for exit().
2020-02-03 17:18:36 +08:00
Chun-wei Fan
f2915180a6 tests/testdnd2.c: Don't include unistd.h unconditionally
Instead, on Windows when it is not available, include io.h for close()
2020-02-03 17:18:36 +08:00
Matthias Clasen
e7f2833703 Merge branch 'wip/muktupavels/update-documentation' into 'master'
display-x11: don't mention gdk_monitor_is_primary in the docs

See merge request GNOME/gtk!1380
2020-02-03 08:15:30 +00:00
Alberts Muktupāvels
66af531ff3 display-x11: don't mention gdk_monitor_is_primary in the docs
https://gitlab.gnome.org/GNOME/gtk/merge_requests/1371#note_699272
2020-02-02 19:18:22 +02:00
Matthias Clasen
621120d1d3 css: Fix an oversight in style change computation
Take the 'color == NULL means currentColor' trick into account
when computing the changes between two styles.
2020-02-02 16:41:14 +01:00
Matthias Clasen
f84fdfc0c1 Merge branch 'sigma' into 'master'
gdk: Handle small final sigma in gdk_keyval_convert_case

See merge request GNOME/gtk!1351
2020-02-02 12:04:09 +00:00
Matthias Clasen
27223f7956 Merge branch 'initial-style' into 'master'
Make it easy to recognize initial style values

See merge request GNOME/gtk!1375
2020-02-01 12:52:44 +00:00
Matthias Clasen
5faf977f66 border: Don't render initial borders
Add a fast exist for comon case that the border
values are unset.
2020-02-01 09:12:12 +01:00
Matthias Clasen
7fbb37a09f background: Don't render initial backgrounds
Add a fast exit for the common case that the background
values are unset.
2020-02-01 09:11:39 +01:00
Matthias Clasen
7027fc9ab6 Make it easy to recognize initial style values
Reuse the type field in GtkCssValues to make initial
style values easily recognizable.
2020-02-01 09:11:22 +01:00
Matthias Clasen
7479564972 modelbutton: Update a11y states
We took care to set the proper role on our accessible object,
but we forgot to update the state for check and radio button
roles.
2020-01-31 19:14:05 +01:00
Matthias Clasen
09612a1b3c filechooser: Remove debug spew 2020-01-31 16:55:01 +01:00
Matthias Clasen
79c8a16b8d Remove simple search engine 2020-01-31 16:52:27 +01:00
Matthias Clasen
6104c12392 Build fix for GtkCssValues 2020-01-31 11:40:06 +01:00
Jor Teron
0c5ba00d59 Update Karbi translation 2020-01-31 10:15:03 +00:00
Daniel Mustieles
9f55377b69 Updated Spanish translation 2020-01-31 09:09:43 +01:00
Matthias Clasen
f140b151e1 Merge branch 'meson-sassc-subproject' into 'master'
build: require sassc and drop generated .css files

See merge request GNOME/gtk!814
2020-01-31 07:26:48 +00:00
Matthias Clasen
c91c4b60e7 Merge branch 'kill-primary-monitor-2' into 'master'
Remove primary monitor api

See merge request GNOME/gtk!1371
2020-01-30 20:51:07 +00:00
Matthias Clasen
a46f9af1c0 Remove primary monitor api
We only have implementations of this on X11 and Win32,
so make it available as backend api there.

Update all callers to use either the backend api, or
just monitor 0.
2020-01-30 21:33:37 +01:00
Christoph Reiter
4071e1e734 build: require sassc and drop generated .css files
Instead of requiring sassc to be installed add meson subprojects
which build libsass and sassc (currently both forks of mine, tested
under linux/mingw/msvc) when needed.

This allows us to drop the generated .css files and build scripts from git.

See #1502
2020-01-30 20:45:38 +01:00
Alexander Larsson
99c89d61e1 Merge branch 'icon-theme-rework' into 'master'
Rework icon themes

See merge request GNOME/gtk!1368
2020-01-30 17:30:10 +00:00
Alexander Larsson
09ef67afbc icon-theme: Add icon theme name in profiler mark 2020-01-30 18:22:11 +01:00
Alexander Larsson
d478ae1ef5 icon-theme: Avoid reentrancy issues while loading icon theme
In gtk_icon_theme_get_for_display() we were calling
gtk_icon_theme_set_display() which eventually (via the css machinery)
called back into gtk_icon_theme_get_for_display() which created a
second icon theme. We avoid this by setting the user-data earlier so
that the css machinery gets back the currently initializing theme
instead.
2020-01-30 18:19:56 +01:00
Alexander Larsson
b67d582230 GtkIconHelper: Preload icons for mapped widgets with higher priority
We look at whether a widget will be mapped (the actual state is not
yet set, so we can't rely on that at css validation time) and use
that to set the i/o priority of the async task.

This means that its likely that widgets that will be displayed soon
are loaded before those that are not yet going to be needed.
2020-01-30 15:41:24 +01:00
Alexander Larsson
498ab6ac6c IconHelper: Only preload icons once
This limits the amount of preloading we to, which can for instance
avoid trashing if the icon cache is full, and in general do less work
when its likely to be wasted such as when e.g. background-color for an
icon helper changes.
2020-01-30 15:17:59 +01:00
Alexander Larsson
c69327caa8 icon-theme: Show which icon loads are threaded in profile mark 2020-01-30 15:16:40 +01:00
Alexander Larsson
d1cd578d59 icon-theme: Add i/o priority to choose_icon_async()
This is set on the GTask and lower priority will be loaded before,
this can be used to prioritize some icons for preloading.
2020-01-30 15:15:08 +01:00
Alexander Larsson
5f8c2b52c6 indentation: fix various alignment issues
Most of these stem from the GtkIconInfo -> GtkIcon rename
2020-01-30 12:27:15 +01:00
Alexander Larsson
27799ba4f5 Remove final references to "icon info" with just "icon" 2020-01-30 10:53:43 +01:00
Alexander Larsson
2ec51b7010 icon-theme: Update the docs 2020-01-30 10:53:43 +01:00
Alexander Larsson
f7cd2a782b Fix warnings in gdk gir build
We now have graphene arguments in a gdk function, so add that to the
dependencies.
2020-01-30 10:53:43 +01:00
Alexander Larsson
ff0642bba6 icon-theme: Remove trailing whitespaces
Since everything is changing anyway lets just clean up all the
trailing whitespace issues in the whole file.
2020-01-30 10:53:43 +01:00
Alexander Larsson
b227a2f190 icon-theme: Use GtkSnapshot, not GdkSnapshot 2020-01-30 10:53:43 +01:00
Alexander Larsson
2b202129bb icon-theme: Fix indentation of matrix values 2020-01-30 10:53:43 +01:00
Alexander Larsson
d1c6d78ebb GtkImage: Preload icons during css validation
At the end of GtkImage css validation (during style-updated) when the
css properties (like the icon size) are valid we call _gtk_icon_helper_preload
which does an async icon theme lookup and load. This will happen on a thread
in parallel with the rest of the css machinery, and hopefully by the
time we need the icon it will be ready. If not we will block when we need
it, but during that blocking all the other icons will be loaded.

Testing widget-factory this changes the time of snapshot() from 31 to
25 msec, but on the other hand we also load a few more icons that we
didn't before causing the css validation phase to be about 8 msec slower.
This is because we're preloading all the images in the window, not only
the ones that are visible.

Unfortunately we still load a bunch of icons in snapshot(), from
GtkCssImageIconTheme, and ideally we should try to preload those also.
2020-01-30 10:53:43 +01:00
Alexander Larsson
6a8001fe7d icon-theme: Preload default icon themes in thread
This happens when we first get the theme for a display, or then the
icon theme setting changes.

This means we don't have to do this scan in the first snapshot
and can do the i/o it in parallel with other stuff. This moves
a 10msec block from the first snapshot cycle to early setup.
2020-01-30 10:53:43 +01:00
Alexander Larsson
ff3e022182 icon helper: Remove profiler mark
This was hitting every time we looked up an icon, and we already
log the actual load of the icon in the icon theme.
2020-01-30 10:53:43 +01:00
Alexander Larsson
d2f26b2f27 icon-theme: Improve profiler mark for icon loads
This adds the actual time it took to them as well as the icon size
and scale.
2020-01-30 10:53:43 +01:00
Alexander Larsson
55db9d07c5 icon-theme: Only add theme load profiler mark if we actually load theme 2020-01-30 10:53:43 +01:00
Alexander Larsson
1be932279c icon theme: Actually use scale in choose_icon_async() 2020-01-30 10:53:43 +01:00
Alexander Larsson
56ec748824 icon theme: Actually don't block in gtk_icon_theme_choose_icon_async()
If some other thread is lock the icon or icon theme locks they are likely
to do so for a long time, doing i/o. So, switch to trylock() for the
nonblocking part of _async(). This way we can return directly if the
result is available, but do a thread otherwise, never blocking the
calling (main) thread.
2020-01-30 10:53:43 +01:00
Alexander Larsson
1e6a82513b icon-theme: Clean up locking
Move the lru cache under the global cache lock to avoid some ABBA
style deadlocks when going from icon_theme->icon lock an icon->icon_theme.
We also move all the icon lock uses to a small part of code and make
sure that code never calls out or blocks with any locks held.

Rename the GtkIcon->cache_lock to texture_lock to avoid confusion withe
the global cache_lock.

Removed any mentions of threadsafety from the API docs, we don't
want apps to rely on this, but rather use it outselves internally.
2020-01-30 10:53:43 +01:00
Alexander Larsson
b087f9ca51 icon-theme: Drop the _for_scale() versions and always take scale 2020-01-30 10:53:43 +01:00
Alexander Larsson
e2f778602b icon-theme: Rename GtkIconInfo to GtkIcon 2020-01-30 10:53:43 +01:00
Alexander Larsson
6a15e9169d Rename GtkIcon widget to GtkBuiltinIcon
This is an internal widget whose name is not very important, and we
want to rename GtkIconInfo to GtkIcon, so lets rename this.
2020-01-30 10:53:33 +01:00
Matthias Clasen
929d325560 profiler: Exit gracefully on SIGTERM
This is nice, since it lets me quickly launch a test app
and terminate it with Ctrl-C and still produce a usable
sysprof trace.
2020-01-30 10:04:38 +01:00
Matthias Clasen
cb60c1b83d builder: Add profiler marks for parsing
This is useful to understand what ui files take
long to load.
2020-01-30 10:04:38 +01:00
Matthias Clasen
ab69d43089 builder: Use a better name for templates
This name can show up in error messages or profiler
traces, so it is nice to provide some hint what
file we are dealing with.
<GtkFileChoser template> is a lot more helpful
than <input>.
2020-01-30 10:04:38 +01:00
Alexander Larsson
6af4b6a644 icon-theme: Drop all load() calls from GtkIconInfo
All users now either use it directly as a paintable or download
the texture to use the pixels.
2020-01-29 19:12:15 +01:00
Alexander Larsson
0d666f0cec icon-theme: Use gtk_icon_theme_choose_icon_async in tests 2020-01-29 19:06:16 +01:00
Alexander Larsson
317b395f0f icon-theme: Drop loading_themes recursion check
This was added in 0b1c9b7cc2 to protect
against reentrancy from the theme-changed signal, but we only emit this
from an idle these days, so thats not necessary anymore, and the recursion
check was causing issues with the async operations where a different
thread loading the theme caused the calling thread to thing the
theme is valid.
2020-01-29 19:06:16 +01:00
Alexander Larsson
71b3b54215 icon-theme: Add async icon loader 2020-01-29 19:06:16 +01:00
Alexander Larsson
97b24b0732 tests: Use gtk_icon_info_download_colored_texture instead of load_symbolic 2020-01-29 19:06:16 +01:00
Alexander Larsson
6ffb54f47f icon-theme: Add gtk_icon_info_download_colored_texture()
This is a way to get at recolored pixels and will replace all existing users
of _load_symbolic*()
2020-01-29 19:06:16 +01:00
Alexander Larsson
afa6cc2369 Break out cairo color matrix recoloring to gdk_cairo_image_surface_recolor()
This is useful in some parts of the icon theme APIs.
2020-01-29 19:06:16 +01:00
Alexander Larsson
dbe021239f icons: Convert use of load() to download_texture() 2020-01-29 19:06:16 +01:00
Alexander Larsson
884e06ad37 icon theme: Add gtk_icon_info_download_texture() function
This returns a reference to the texture (if possible) and can be
used to get access to the pixels of the icon.
2020-01-29 19:06:16 +01:00
Alexander Larsson
53c542765f Add gtk_icon_info_snapshot_with_colors() and use instead of custom code 2020-01-29 19:06:16 +01:00
Alexander Larsson
c42977af04 Convert trivial users of icon theme loading to use info as paintable 2020-01-29 19:06:16 +01:00
Alexander Larsson
aefd8443de GtkIconHelper use GtkIconInfo as paintable 2020-01-29 19:06:16 +01:00
Alexander Larsson
b96ab7453b GtkIconInfo: Implement paintable
This makes GtkIconInfo directly implement paintable by loading
the icon as needed. This is done in a blocking fashion for now, but
could be made more async in the future.

It also means we can't return errors to the called, but I doubt
anyone actually does anything useful with them other than showing
nothing (which we already do).

This also changes a fringe behaviour for unthemed icons. They used to
be never scaled down, but that means we can't tell without i/o the
size of the paintable. Since this is the only case we can't know the
size i took an executive decision and removed that behaviour. I don't
think picking some arbitrary much larger than requested size is ever
right, nor do i think using GtkIconTheme with unthemed icons is overly
useful. If you want to display some random non-iconish image, use
GtkImage instead.
2020-01-29 19:06:16 +01:00
Alexander Larsson
3ac7e30455 icon theme: Make GtkIconInfo cached data threadsafe
Whenever this is accessed or updated we just grab a lock, thus
blocking on whoever is currenly updating it.
2020-01-29 19:06:16 +01:00
Alexander Larsson
aef67bd53a GtkIconTheme: Make the base GtkIconTheme threadsafe
This makes the core icon theme object threadsafe, however its
not yet very useful because the IconInfo objects are not threadsafe.
2020-01-29 19:06:16 +01:00
Piotr Drąg
bba5de7c6d Update POTFILES.skip 2020-01-29 17:20:23 +01:00
Emmanuele Bassi
556a8a8351 Merge branch 'wip/muktupavels/work-areas' into 'master'
per-monitor work areas

Closes #1086 and #980

See merge request GNOME/gtk!1300
2020-01-29 13:38:31 +00:00
Matthias Clasen
5e95e15a03 animatedstyle: Fix the debug build
This wasn't caught by our ci.
2020-01-29 14:10:24 +01:00
Alberts Muktupāvels
248883089c x11: add support for _GTK_WORKAREAS_Dn
If window manager supports _GTK_WORKAREAS use per-monitor work areas.

https://mail.gnome.org/archives/wm-spec-list/2018-December/msg00000.html
https://gitlab.freedesktop.org/xdg/xdg-specs/merge_requests/22

https://gitlab.gnome.org/GNOME/gtk/merge_requests/1300
2020-01-29 14:38:08 +02:00
Carlos Garnacho
aabb250741 Merge branch 'gtk-4-im-wayland-controller-focus-in' into 'master'
imwayland: Connect gtk_im_context_focus_in/out to GtkEventControllerKey

See merge request GNOME/gtk!1349
2020-01-29 11:22:11 +00:00
Matthias Clasen
83cccfc984 Merge branch 'gdk-device-leak-fix' into 'master'
GdkDevice leak fix

See merge request GNOME/gtk!1358
2020-01-29 10:44:42 +00:00
Matthias Clasen
b97054fc38 Merge branch 'css-style-split-2' into 'master'
css: Split styles into groups

See merge request GNOME/gtk!1362
2020-01-29 10:39:43 +00:00
Matthias Clasen
b859407620 Merge branch 'reset-with-click' into 'master'
Always emit reset for IM preedit with mouse click

Closes #1534

See merge request GNOME/gtk!460
2020-01-29 10:39:22 +00:00
Matthias Clasen
75c73ac3cd Merge branch 'robertroth/shortcuts-overlay-accel' into 'master'
Application: Do not reuse Ctrl+F1 for help-overlay

See merge request GNOME/gtk!307
2020-01-29 10:25:40 +00:00
Matthias Clasen
10e4c04e61 Use style values directly
Replace uses of gtk_css_style_get_value with direct access,
throughout the tree. We don't replace all uses, just those
where we are dealing with a fixed property. Be careful to
handle the currentColor special case for color properties.
2020-01-29 11:07:32 +01:00
Matthias Clasen
b378f566d7 Compute style change based on values structs
We can save some time here by comparing struct by
struct and avoiding individual values comparisons
as much as possible.
2020-01-29 11:07:32 +01:00
Matthias Clasen
5776d0dd99 css: Split styles into groups
Introduce refcounted structs for groups of related css properties,
and use them to store the style values. Both GtkCssStaticStyle and
GtkCssAnimatedStyle fill in the structs in GtkCssStyle, and we
can avoid vfuncs for value access, which should be much faster.
We can even start accessing style->core->color directly.
2020-01-29 11:07:32 +01:00
Matthias Clasen
59994bdd22 performance test: Produce better numbers
Try to isolate the test runs from each other in the
eyes of the kernel scheduler, by sleeping a bit. And
ignore the first run, to avoid cache effects.
2020-01-29 11:06:32 +01:00
Matthias Clasen
db8276f470 Merge branch 'wip/baedert/widget-add-style-class' into 'master'
widget: Add style class API

See merge request GNOME/gtk!1366
2020-01-29 09:46:36 +00:00
Matthias Clasen
c3421cea25 Silence a compiler warning 2020-01-29 10:44:25 +01:00
Emmanuele Bassi
6830845fda Merge branch 'gtk-doc-ci' into 'master'
Publish the API reference

See merge request GNOME/gtk!1367
2020-01-29 09:11:15 +00:00
Emmanuele Bassi
db5d9ccdfb Remove reftests from expected-fail list
With an updated version of the base CI image it seems some tests that
were failing have started to pass again.
2020-01-29 10:02:02 +01:00
Emmanuele Bassi
51e155bffa ci: Deploy the API reference on our GitLab pages
Now that we can build gtk-doc as a sub-project, we can go back to
publishing the API reference for the master branch every time we
build it.
2020-01-29 09:46:13 +01:00
Emmanuele Bassi
98e6e0cf77 ci: Update the version of Meson in the CI image
We need at least 0.52.1 to be able to use gtk-doc as a sub-project.
2020-01-29 09:39:21 +01:00
Emmanuele Bassi
058f82d03d Add gtk-doc as a subproject
We rely on a specific minimum version of gtk-doc to be able to build the
GTK API reference for the new API. In order to be able to use gtk-doc as
a subproject, though, we need to use a recent version of Meson.
2020-01-29 09:39:21 +01:00
Timm Bäder
a7b34df6af widget: Add style class API
Add GtkWidget API for adding and removing style classes, as well as
checking whether a widget has a style class applied.

Everyone has to go through GtkStyleContext for this these days but with
GtkStyleContext eventually going away, it makse sense for GtkWidget to
have API for this.
2020-01-29 09:36:48 +01:00
Timm Bäder
b3f454ed98 Merge branch 'fix-doc-typo' into 'master'
Fix a doc typo

See merge request GNOME/gtk!1364
2020-01-29 07:49:13 +00:00
Benjamin Otte
fd021e794c Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master

See merge request GNOME/gtk!1365
2020-01-29 04:35:56 +00:00
Benjamin Otte
5e3cbff8d2 cssselector: Rework how we handle the bloom filter
Instead of foreaching through all the previous selectors every time we
bloom-filter, just bloom-filter the current element and return a special
value if that filter fails (FALSE). If that happens, don't try
filter-matching more nodes in the caller as we know it's an abort.
2020-01-29 04:20:47 +01:00
Luca Bacci
f0fe2e0743 Fix a doc typo 2020-01-28 20:42:03 +00:00
Benjamin Otte
c6158f1684 cssselector: Reorder functions
This just changes the order of functions in the source code in
preparation for the next commit.
2020-01-28 18:28:32 +01:00
Benjamin Otte
65050a1c81 css: Don't do the "all set" test
We have so many properties that it is basically impossible that all of
them are set and the time spent checking is higher than the time saved
if it does indeed happen.
2020-01-28 17:57:59 +01:00
Benjamin Otte
12ec090a7b Merge branch 'wip/otte/for-master' into 'master'
popover: Do not validate the css node on show()

See merge request GNOME/gtk!1363
2020-01-28 16:43:33 +00:00
Benjamin Otte
17ca95a161 popover: Do not validate the css node on show()
This was a good idea back in GTK3 when popovers were toplevels, but now
they're regular child widgets, so they should behave that way.

Also, with the introduction of the bloom filter, gtk_css_node_validate()
now assumes it's only called on root nodes, so assert that that is the
case.
2020-01-28 17:19:28 +01:00
Takao Fujiwara
5be14577d6 imwayland: Connect gtk_im_context_focus_in/out to GtkEventControllerKey
GtkEventControllerKey can handle GDK_FOCUS_CHANGE and call
gtk_im_context_focus_in/out directly.

https://gitlab.gnome.org/GNOME/gtk/issues/2390
2020-01-28 23:47:16 +09:00
Benjamin Otte
1a9ab1a32f Merge branch 'wip/otte/css' into 'master'
selector: Rework iterating over subnodes

See merge request GNOME/gtk!1361
2020-01-28 03:56:49 +00:00
Benjamin Otte
c7dca199ae selector: Rework iterating over subnodes
Instead of a foreach() function, introduce an iterator, so that the
caller can drive the iteration.

This allows doing stuff inbetween callbacks and avoids closures when
more than one data object should be passed.

As a side effect I even get a small, but noticeable performance
improvement in the 2-10% range depending on benchmark, I guess that's
because there's no function pointer passing going on anymore.
2020-01-28 04:32:15 +01:00
Benjamin Otte
50a3d9be6a Merge branch 'wip/otte/css' into 'master'
CSS improvements

See merge request GNOME/gtk!1360
2020-01-28 02:47:25 +00:00
Benjamin Otte
5e4b102273 styleproperty: Remove ability to query properties
With gtk_style_context_get() gone, this is no longer used.
2020-01-28 02:58:02 +01:00
Benjamin Otte
632fab0ca7 stylecontext: Get rid of gtk_style_context_get()
... and replace all the calls to it with
gtk_style_context_peek_property().

All the calls are hacks that need to go away btw.
2020-01-28 02:58:02 +01:00
Benjamin Otte
43339f1c1c testcalendar: Don't do dumb stuff with font sizes.
If you want to test font stuff, it's 2020 and we have an inspector.
2020-01-28 02:17:32 +01:00
Benjamin Otte
afbff574f5 filechooser: Remove default size machinery
The FileChooser ToolKit (fctk) had its own machinery to handle default
sizes which was completely busted and trying to marshal random numbers
through the widget hierarchy that maybe made sense in 2012 but don't do
now.

Get rid of it, just keep the dialog's GSetting - which funnily enough
used to be written by the dialog but written by the widget.
But that's fctk for you.
2020-01-28 02:17:31 +01:00
Benjamin Otte
aff25212df cellrenderertoggle: size based on -gtk-icon-size
Instead of hardcoding 16px.
2020-01-28 02:17:03 +01:00
Benjamin Otte
18cb15a05a stylecontext: Remove gtk_style_context_get_section()
The inspectors gets values differently these days.
2020-01-28 02:17:03 +01:00
Benjamin Otte
6c8b65baf9 stylecontext: Remove GTK_STYLE_PROPERTY_* defines
They shouldn't be (and aren't) used anymore.
2020-01-28 02:17:03 +01:00
Benjamin Otte
495eaf31d4 css: Use the bloom filter for change matching
Instead of just doing radical change matching on the node itself, also
consider the parent nodes via the bloom filter.

This means a radical change is now also one where the parent
name/id/classes change, but since that's considered a radical change on
the parent already, those things are slow anyway.

Improves the benchmark times for CSS validation during backdrop
transitions in widget-factory from 45ms to 35ms on my machine.
2020-01-28 02:17:03 +01:00
Benjamin Otte
ccdc3ee406 selector: Make :not() selectors not radical
:not() selectors cannot be radical because the bloomfilter only knows if
a value is set in any of the nodes, but cannot determine the opposite
(if a value is not set in at least one node), but that would be required
for:not() selectors.
However, this is very unlikely to happen in the real world, so it's not
worth optimizing.

Unfortunately, change tracking could know this, so by excluding the
:not() selectors from radical changes, the change tracking will now pick
them up. If that turns out to be a performance problem, we need to add a
special category for radical not filters, so change tracking and bloom
filters can deal with them.

The testcase demonstrating the problem in widget-factory has been
extrated and added.
2020-01-28 02:17:03 +01:00
Benjamin Otte
93cf76b068 testsuite: Improve diff_with_file() function
Properly handle diff(1) failing.

In this particular case, the test passed a NULL input file to the diff
(that was fixed, too) and then diff only found one input file and
aborted.

But without this fix, we'd also not catch other abortion reasons for
diff() - as long as it exited in any way, we were happy.
2020-01-28 02:17:03 +01:00
Benjamin Otte
170130f1d9 css: Add fast-path for parent selector matching
Add a fast path for parent selector matching that uses a bloom filter to
quickly discard selectors that can't possibly match.

Keep in mind that we match using a bloom filter, so we might
accidentally include too many selectors when hash/bucket collisions
occur.
That's not a correctness problem though, because we'll do a real check
afterwards.

The idea for this change is taken from browsers, in particular WebKit.
2020-01-28 02:17:03 +01:00
Benjamin Otte
6aac56e144 cssnodedeclaration: C99-ify the code
zero-sized arrays are allowed now.
2020-01-28 02:17:03 +01:00
Benjamin Otte
2d5a8974b3 selector: Hash differently
This will be relevant for a bloom filter. And bloom filters want 12bit
hashes, so we try to produce hash values < 4096.
2020-01-28 02:17:03 +01:00
Benjamin Otte
146b921246 cssnode: Convert name + id from interned string to GQuark
The reason for this is simply that I want to get hash functions that
have their values close together, so they can fit in a smaller range
(the goal here is 12 bits). By using GQuark, we get consecutive numbers
starting with 1 (and applications have <1000 quarks usually), whereas
interned strings can be all over the place.

As a side effect we also save 64 bytes per declaration.
2020-01-28 02:17:03 +01:00
Benjamin Otte
8b93ea9238 css: Get rid of GtkCssMatcher 2020-01-28 02:17:02 +01:00
Benjamin Otte
aa7c5e96a6 css: Pass node through the lookup code
... instead of passing a matcher.

The matcher code is now local to the CssProvider/CssSelector machinery.
2020-01-28 02:17:02 +01:00
Benjamin Otte
1953bc92bc cssnode: Remove init_matcher() vfunc
It's unused.
2020-01-28 02:17:02 +01:00
Benjamin Otte
98eeee5bce cssnode: Remove ability to set GType as fallback name 2020-01-28 02:17:02 +01:00
Benjamin Otte
49b47c9133 Remove GtkWidgetPath
... and all associated demos and tests.
2020-01-28 02:17:02 +01:00
Benjamin Otte
af6128b3ab Remove gtkwidgetpath.h include where no longer needed 2020-01-28 02:17:02 +01:00
Benjamin Otte
496f3c17bd Revert "cssmatcher: Inline node values into matcher"
This reverts commit a75529f3c0.

It just complicates code and there are no performance numbers that would
warrant such a commit.
2020-01-28 02:17:02 +01:00
Benjamin Otte
c2d69643a8 css: Move utility function
The function was not selector-specific, so putting it with all the other
utility functions makes more sense.

Also use the utility function in the node declaration printing.
2020-01-28 02:17:02 +01:00
Sebastian Keller
9c6669be48 gdk/x11: Properly unref removed device in XI2 device manager
When a device is added, there are two references to it by the device
manager, the initial one and the one used for the id_table. Removing a
device only removed the reference added by the id_table resulting in the
GdkDevice being leaked.

https://gitlab.gnome.org/GNOME/gtk/merge_requests/1358
2020-01-27 21:42:34 +01:00
Matthias Clasen
d0aa79b5a1 textutil: Stop using GtkStyleContext
We can just use the css style directly.
2020-01-27 13:35:04 -05:00
Matthias Clasen
4b63523b1f gskpango: Don't free rgba's we don't own
We don't copy them anymore, so don't free them.
2020-01-27 13:35:04 -05:00
Matthias Clasen
997186f640 filechooser: Stop using gtk_style_context_get
Just go to the css style directly.
2020-01-27 12:52:24 -05:00
Rafael Fontenelle
3940482820 Update Brazilian Portuguese translation 2020-01-27 17:09:32 +00:00
Timm Bäder
616a83fb53 popover: Fix an oversight in gap coord computation
This caused a border to show up between the popover arrow and the
contents.
2020-01-27 13:37:50 +01:00
Timm Bäder
baeadea342 calendar: Use widgets for the header
This is not meant to be a full GtkCalendar conversion to use widgets
instead of custom drawing, but we lost the arrows in the calendar header
when builtin icons were removed. Using proper button for the year/month
buttons brings them back.
2020-01-27 13:37:50 +01:00
Umarzuki Bin Mochlis Moktar
04beedfef0 Update Malay translation 2020-01-27 12:25:12 +00:00
Umarzuki Bin Mochlis Moktar
da73394abd Update Malay translation 2020-01-27 12:22:47 +00:00
Fabio Tomat
d0f69794a5 Update Friulian translation 2020-01-27 08:56:42 +00:00
Dušan Kazik
185ef214fa Update Slovak translation 2020-01-27 07:01:51 +00:00
Robert Ancell
b530c83d98 GtkFileFilter: Don't set the name from the GtkBuilder ID
Don't use the GtkBuilder ID for the filter name - this is an ID, not a human
readable name. The name can now be set with a property.
2020-01-27 16:01:54 +13:00
Robert Ancell
b83caec6b9 GtkFileFilter: Add a GObject property for the name
The name field was previously not a property, which meant you couldn't set in in
GtkBuilder as translatable.
2020-01-27 16:01:54 +13:00
Matthias Clasen
3cdde3fc4b css: Don't lose inset when computing shadows
This was showing up as reftest failures,
sporadically
2020-01-26 20:18:23 -05:00
Sebastian Keller
5040d81e03 gdkseatdefault: Unref removed slave devices
Adding a slave device adds a ref, but removing it does not unref it.

https://gitlab.gnome.org/GNOME/gtk/merge_requests/1358
2020-01-27 01:37:14 +01:00
Timm Bäder
05b9a99661 gsk: Remove some unused defines
These are from the GVariant days of render nodes.
2020-01-26 18:21:07 +01:00
Timm Bäder
a16e1cbf18 cssdimensionvalue: Remove an outdated comment
It's actually implemented in gtkcssdimensionvalue.c these days.
2020-01-26 18:21:07 +01:00
Timm Bäder
c7ea83cd82 cssboxes: Try to avoid doing work for rectangular boxes
Use the new gtk_css_dimension_value_is_zero() to check if we really need
to e.g. apply a border radius at all.
We compute css boxes a lot so this makes sense here, it especially shows
up during pick(), where we need the border box.
2020-01-26 18:21:07 +01:00
Timm Bäder
352c9ba42a dimensionvalue: Add gtk_css_{dimension,corner}_value_is_zero()
We can usually omit computations when the dimension value ends up being
zero anyway.
2020-01-26 18:21:07 +01:00
Timm Bäder
30b37dd7c5 widget: Restructure pick() a bit
Don't even invert transforms if we can do it easily ourselves. This also
fixes a small GtkTransform memory leak.
2020-01-26 18:21:07 +01:00
Timm Bäder
2e256986c3 renderbackground: Avoid unnecessary work in snapshot_background() 2020-01-26 18:21:07 +01:00
Timm Bäder
77e0d360ed Add pure and const annotations to various functions 2020-01-26 18:21:07 +01:00
Timm Bäder
942a93250a render: Remove gtk_render_background_get_clip 2020-01-26 18:21:07 +01:00
Timm Bäder
7ccd6597c3 Remove gtkutils{.c,private.h}
All but one functions are unused. Move the remaining one into
gtkmodules.c, its only caller.
2020-01-26 18:21:07 +01:00
Timm Bäder
355a417dba cssparser: make a few local variables const 2020-01-26 18:21:07 +01:00
Timm Bäder
36e3f4d902 cssprovider: Parse selectors without a GList
The maximum length of this list in Adwaita is 18, so use a generous
maximum length of 64 for the selector list of a ruleset.
2020-01-26 18:21:07 +01:00
Timm Bäder
69fe705d0d GtkCssImageUrl: Implement is_computed() 2020-01-26 18:21:07 +01:00
Timm Bäder
f62535affc gl renderer: Avoid some work when rendering border nodes 2020-01-26 18:21:07 +01:00
Timm Bäder
1a56a10fc1 cssimage: Add gtk_css_image_to_string()
In line with all the other _to_string() implementations
2020-01-26 18:21:07 +01:00
Timm Bäder
4287f0def4 window: Replace GtkStyleContext use to get surface transform
We have GtkCssBoxes for this these days.
2020-01-26 18:21:07 +01:00
Matthias Clasen
7bebc3e2b2 Revert "lookup stats"
This reverts commit 3d9e3390f1.
2020-01-25 23:49:33 -05:00
Matthias Clasen
b4e2df8fca Revert "css: Split style into groups"
This reverts commit 0df0de0b5d.
2020-01-25 23:49:17 -05:00
Matthias Clasen
0df0de0b5d css: Split style into groups 2020-01-25 23:47:02 -05:00
Matthias Clasen
53c22bf833 Adwaita: take out an unnecessary rule
The comment says setting caret-color to currentColor
shouldn't be necessary, and it is right.
2020-01-25 18:38:42 -05:00
Matthias Clasen
d8144ec497 Adwaita: drop the * 2020-01-25 18:20:40 -05:00
Matthias Clasen
3d9e3390f1 lookup stats 2020-01-25 18:20:26 -05:00
Matthias Clasen
03595f9567 Fix a scrollbar sizing issue
The recent Adwaita changes inadvertendly made scrollbars
resize on hover. Fix that, by reinstating some lost rules.
2020-01-25 15:05:14 -05:00
Matthias Clasen
64e026d0a9 Revert "Ensure icon themes are loaded with other themes"
This reverts commit 88d26b7549.

This change caused GtkShortcutWindow to not work anymore,
and we are fixing icon themes differently, anyway.
2020-01-25 14:32:01 -05:00
Matthias Clasen
0623b00512 Merge branch 'style-context-redux' into 'master'
Stop using GtkStyleContext internally

See merge request GNOME/gtk!1353
2020-01-25 19:29:20 +00:00
Matthias Clasen
ac902e697e popover: Stop using style context getters 2020-01-25 14:18:22 -05:00
Matthias Clasen
f1ff69963e drag icon: Stop using style context getters
Just go to the css node directly.
2020-01-25 14:18:22 -05:00
Matthias Clasen
731ae8f39e gskpango: Stop using style context getters
Just go to the css nodes directly.
2020-01-25 14:18:22 -05:00
Matthias Clasen
7da6fdc30e widget: Stop using style context internally 2020-01-25 11:05:27 -05:00
Matthias Clasen
a297129685 Add a profiler mark around renderer realization
This takes time that is worth calling out.
2020-01-25 01:28:24 -05:00
Alex Henrie
f15a34c7e4 gdk: Handle small final sigma in gdk_keyval_convert_case 2020-01-24 17:10:07 -07:00
Vlad Zahorodnii
b36258f204 gdk: Subtract base size when checking aspect ratio
According to the ICCCM spec [1], one should subtract the base size from
the window size before checking that the aspect ratio falls in range.

This change fixes shrinking Firefox Picture-in-Picture windows when
running KDE Plasma (with KWin as the window manager).

[1] https://tronche.com/gui/x/icccm/sec-4.html#s-4.1.2.3
2020-01-19 02:22:44 +02:00
ZhaoQiang
e75bc172ef Remove some unused variables
To avoid compiler warnings.

See merge request GNOME/gtk!513
2019-04-09 22:06:50 +08:00
Takao Fujiwara
4b2e4f6628 Always emit reset for IM preedit with mouse click
Hangul inputs treat pre-edit text as output text and the pre-edit
text won't be moved with mouse click.
Now the reset signal is always emitted simply with mouse click and
each IM engine could handle the signal whether the preedit is committed,
cleared or kept.

Closes #1534
2019-02-20 18:58:51 +09:00
Rick Yorgason
26febcc3a8 Fixed win32 printer dialogue not saving devmode->dmDeviceName. Caused the print dialogue to select the wrong printer, and potentially feed bad "extra" data to the default printer. 2018-11-01 11:31:05 -07:00
Rick Yorgason
5dd7f20dab Fixed code styling. 2018-10-29 04:04:10 -07:00
Rick Yorgason
fc15a409cc Fixed bug that prevented GTK from storing printer driver preferences in the print dialogue on Windows. 2018-10-27 06:00:20 -07:00
Daniel Boles
4b96e7fc78 Application: Do not reuse Ctrl+F1 for help-overlay
It just gets overridden to do something else, as the 1st GtkWidget’s
class_init() adds it as a binding to toggle tooltips with the keyboard.
The last entity to hook it (& return TRUE) is the only one who gets it.

So, worse: If users needed to manually set accels for a ShortcutsWindow,
coincidentally waited until after the 1st GtkWidget init() to do it, &
copied what GtkApplication said in an attempt to be good & consistent —
they inadvertently broke the keyboard tooltips (except for users with a
GDK_KEY_KP_F1 – whatever that is) as their handler blocked GtkWidget’s.

So, one side has to drop this accelerator, and it seems clear that being
able to open tooltips with the keyboard is more important than having a
second accel for the help-overlay. We can make up a replacement later.

https://gitlab.gnome.org/GNOME/gtk/issues/626
2018-08-24 14:51:21 +03:00
1713 changed files with 131305 additions and 133894 deletions

11
.clang-format Normal file
View File

@@ -0,0 +1,11 @@
# See https://wiki.apertis.org/Guidelines/Coding_conventions#Code_formatting
BasedOnStyle: GNU
AlwaysBreakAfterDefinitionReturnType: All
BreakBeforeBinaryOperators: None
BinPackParameters: false
SpaceAfterCStyleCast: true
# Our column limit is actually 80, but setting that results in clang-format
# making a lot of dubious hanging-indent choices; disable it and assume the
# developer will line wrap appropriately. clang-format will still check
# existing hanging indents.
ColumnLimit: 0

View File

@@ -1,7 +1,9 @@
stages:
- build
- analysis
- docs
- flatpak
# - deploy
- deploy
.cache-paths: &cache-paths
paths:
@@ -12,11 +14,40 @@ stages:
- subprojects/libepoxy/
- subprojects/pango/
fedora-x86_64: &fedora-x86_64-defaults
image: registry.gitlab.gnome.org/gnome/gtk/master:v9
stage: build
# Common variables
variables:
COMMON_MESON_FLAGS: "--fatal-meson-warnings --werror"
MESON_TEST_TIMEOUT_MULTIPLIER: 2
.only-default:
only:
- branches
except:
- tags
style-check-diff:
extends: .only-default
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v16
stage: .pre
allow_failure: true
script:
- bash -x ./.gitlab-ci/test-docker.sh
- .gitlab-ci/run-style-check-diff.sh
fedora-x86_64:
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v16
stage: build
variables:
EXTRA_MESON_FLAGS: "--buildtype=debug --default-library=both"
script:
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS}
-Dx11-backend=true
-Dwayland-backend=true
-Dbroadway-backend=true
-Dvulkan=yes
-Dprofiler=true
_build
- ninja -C _build
- .gitlab-ci/run-tests.sh _build
artifacts:
when: always
reports:
@@ -34,10 +65,36 @@ fedora-x86_64: &fedora-x86_64-defaults
key: "$CI_JOB_NAME"
<<: *cache-paths
fedora-x86_64-staticlibs:
release-build:
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v16
stage: build
variables:
EXTRA_MESON_FLAGS: "-Ddefault_library=both"
<<: *fedora-x86_64-defaults
EXTRA_MESON_FLAGS: "--buildtype=release"
script:
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS}
-Dx11-backend=true
-Dwayland-backend=true
-Dbroadway-backend=true
-Dvulkan=yes
_build
- ninja -C _build
- .gitlab-ci/run-tests.sh _build
artifacts:
when: always
reports:
junit:
- "${CI_PROJECT_DIR}/_build/report.xml"
name: "gtk-${CI_COMMIT_REF_NAME}"
paths:
- "${CI_PROJECT_DIR}/_build/meson-logs"
- "${CI_PROJECT_DIR}/_build/report.xml"
- "${CI_PROJECT_DIR}/_build/report.html"
- "${CI_PROJECT_DIR}/_build/testsuite/reftests/output/*.png"
- "${CI_PROJECT_DIR}/_build/testsuite/gsk/compare/*/*.png"
- "${CI_PROJECT_DIR}/_build/testsuite/css/output/*.syscap"
cache:
key: "$CI_JOB_NAME"
<<: *cache-paths
.mingw-defaults: &mingw-defaults
stage: build
@@ -59,6 +116,9 @@ msys2-mingw32:
.flatpak-defaults: &flatpak-defaults
image: registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master
stage: flatpak
allow_failure: true
tags:
- flatpak
artifacts:
paths:
- "${APPID}-dev.flatpak"
@@ -107,19 +167,41 @@ flatpak-master:icon-browser:
APPID: org.gtk.IconBrowser4
<<: *flatpak-master
#pages:
# image: registry.gitlab.gnome.org/gnome/gtk/master:v6
# stage: deploy
# script:
# - meson -Dgtk_doc=true _build .
# - ninja -C _build
# - ninja -C _build gdk4-doc gsk4-doc gtk4-doc
# - mkdir -p public/
# - mv _build/docs/reference/gtk/html/ public/gtk/
# - mv _build/docs/reference/gdk/html/ public/gdk/
# - mv _build/docs/reference/gsk/html/ public/gsk/
# artifacts:
# paths:
# - public
# only:
# - master
static-scan:
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v16
stage: analysis
variables:
EXTRA_MESON_FLAGS: "--buildtype=debug"
script:
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} _scan_build
- ninja -C _scan_build scan-build
artifacts:
paths:
- _scan_build/meson-logs
allow_failure: true
reference:
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v16
stage: docs
variables:
EXTRA_MESON_FLAGS: "--buildtype=release"
script:
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} -Dgtk_doc=true _build
- ninja -C _build gdk4-doc gsk4-doc gtk4-doc
- mkdir -p _reference/
- mv _build/docs/reference/gdk/html/ _reference/gdk/
- mv _build/docs/reference/gsk/html/ _reference/gsk/
- mv _build/docs/reference/gtk/html/ _reference/gtk/
artifacts:
paths:
- _reference
pages:
stage: deploy
script:
- mv _reference/ public/
artifacts:
paths:
- public
only:
- master

38
.gitlab-ci/README.md Normal file
View File

@@ -0,0 +1,38 @@
## GTK CI infrastructure
GTK uses different CI images depending on platform and jobs.
The CI images are Docker containers, generated either using `docker` or
`podman`, and pushed to the GitLab [container registry][registry].
Each Docker image has a tag composed of two parts:
- `${image}`: the base image for a given platform, like "fedora" or
"debian-stable"
- `${number}`: an incremental version number, or `latest`
See the [container registry][registry] for the available images for each
branch, as well as their available versions.
### Checklist for Updating a CI image
- [ ] Update the `${image}.Dockerfile` file with the dependencies
- [ ] Run `./run-docker.sh build --base ${image} --base-version ${number}`
- [ ] Run `./run-docker.sh push --base ${image} --base-version ${number}`
once the Docker image is built; you may need to log in by using
`docker login` or `podman login`
- [ ] Update the `image` keys in the `.gitlab-ci.yml` file with the new
image tag
- [ ] Open a merge request with your changes and let it run
### Checklist for Adding a new CI image
- [ ] Write a new `${image}.Dockerfile` with the instructions to set up
a build environment
- [ ] Add the `pip3 install meson` incantation
- [ ] Run `./run-docker.sh build --base ${image} --base-version ${number}`
- [ ] Run `./run-docker.sh push --base ${image} --base-version ${number}`
- [ ] Add the new job to `.gitlab-ci.yml` referencing the image
- [ ] Open a merge request with your changes and let it run
[registry]: https://gitlab.gnome.org/GNOME/gtk/container_registry

133
.gitlab-ci/clang-format-diff.py Executable file
View File

@@ -0,0 +1,133 @@
#!/usr/bin/env python3
#
# === clang-format-diff.py - ClangFormat Diff Reformatter ---*- python -*-=== #
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
# ===---------------------------------------------------------------------=== #
"""
This script reads input from a unified diff and reformats all the changed
lines. This is useful to reformat all the lines touched by a specific patch.
Example usage for git/svn users:
git diff -U0 --no-color HEAD^ | clang-format-diff.py -p1 -i
svn diff --diff-cmd=diff -x-U0 | clang-format-diff.py -i
"""
from __future__ import absolute_import, division, print_function
import argparse
import difflib
import re
import subprocess
import sys
if sys.version_info.major >= 3:
from io import StringIO
else:
from io import BytesIO as StringIO
def main():
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('-i', action='store_true', default=False,
help='apply edits to files instead of displaying a '
'diff')
parser.add_argument('-p', metavar='NUM', default=0,
help='strip the smallest prefix containing P slashes')
parser.add_argument('-regex', metavar='PATTERN', default=None,
help='custom pattern selecting file paths to reformat '
'(case sensitive, overrides -iregex)')
parser.add_argument('-iregex', metavar='PATTERN',
default=r'.*\.(cpp|cc|c\+\+|cxx|c|cl|h|hh|hpp|m|mm|inc'
r'|js|ts|proto|protodevel|java|cs)',
help='custom pattern selecting file paths to reformat '
'(case insensitive, overridden by -regex)')
parser.add_argument('-sort-includes', action='store_true', default=False,
help='let clang-format sort include blocks')
parser.add_argument('-v', '--verbose', action='store_true',
help='be more verbose, ineffective without -i')
parser.add_argument('-style',
help='formatting style to apply (LLVM, Google, '
'Chromium, Mozilla, WebKit)')
parser.add_argument('-binary', default='clang-format',
help='location of binary to use for clang-format')
args = parser.parse_args()
# Extract changed lines for each file.
filename = None
lines_by_file = {}
for line in sys.stdin:
match = re.search(r'^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
if match:
filename = match.group(2)
if filename is None:
continue
if args.regex is not None:
if not re.match('^%s$' % args.regex, filename):
continue
else:
if not re.match('^%s$' % args.iregex, filename, re.IGNORECASE):
continue
match = re.search(r'^@@.*\+(\d+)(,(\d+))?', line)
if match:
start_line = int(match.group(1))
line_count = 1
if match.group(3):
line_count = int(match.group(3))
if line_count == 0:
continue
end_line = start_line + line_count - 1
lines_by_file.setdefault(filename, []).extend(
['-lines', str(start_line) + ':' + str(end_line)])
# Reformat files containing changes in place.
# We need to count amount of bytes generated in the output of
# clang-format-diff. If clang-format-diff doesn't generate any bytes it
# means there is nothing to format.
format_line_counter = 0
for filename, lines in lines_by_file.items():
if args.i and args.verbose:
print('Formatting {}'.format(filename))
command = [args.binary, filename]
if args.i:
command.append('-i')
if args.sort_includes:
command.append('-sort-includes')
command.extend(lines)
if args.style:
command.extend(['-style', args.style])
p = subprocess.Popen(command,
stdout=subprocess.PIPE,
stderr=None,
stdin=subprocess.PIPE,
universal_newlines=True)
stdout, _ = p.communicate()
if p.returncode != 0:
sys.exit(p.returncode)
if not args.i:
with open(filename) as f:
code = f.readlines()
formatted_code = StringIO(stdout).readlines()
diff = difflib.unified_diff(code, formatted_code,
filename, filename,
'(before formatting)',
'(after formatting)')
diff_string = ''.join(diff)
if diff_string:
format_line_counter += sys.stdout.write(diff_string)
if format_line_counter > 0:
sys.exit(1)
if __name__ == '__main__':
main()

View File

@@ -8,9 +8,12 @@ RUN dnf -y install \
cairo-devel \
cairo-gobject-devel \
ccache \
clang \
clang-analyzer \
colord-devel \
cups-devel \
dbus-daemon \
dbus-x11 \
dejavu-sans-mono-fonts \
desktop-file-utils \
diffutils \
@@ -23,6 +26,7 @@ RUN dnf -y install \
gettext \
git \
glib2-devel \
glib2-static \
glibc-devel \
glibc-headers \
gobject-introspection-devel \
@@ -61,9 +65,11 @@ RUN dnf -y install \
ninja-build \
pango-devel \
pcre-devel \
pcre-static \
python3 \
python3-jinja2 \
python3-pip \
python3-pygments \
python3-wheel \
redhat-rpm-config \
sassc \
@@ -76,7 +82,7 @@ RUN dnf -y install \
xorg-x11-server-Xvfb \
&& dnf clean all
RUN pip3 install meson==0.50.1
RUN pip3 install meson==0.53.1
ARG HOST_USER_ID=5555
ENV HOST_USER_ID ${HOST_USER_ID}

View File

@@ -4,20 +4,19 @@ set -e
appid=$1
builddir=app
builddir=flatpak_app
repodir=repo
flatpak-builder \
--user --disable-rofiles-fuse \
--stop-at=gtk \
${builddir} \
build-aux/flatpak/${appid}.json
flatpak-builder \
--run ${builddir} build-aux/flatpak/${appid}.json \
meson \
--prefix /app \
--libdir /app/lib \
--buildtype debug \
flatpak build ${builddir} meson \
--prefix=/app \
--libdir=/app/lib \
--buildtype=release \
-Dx11-backend=true \
-Dwayland-backend=true \
-Dprint-backends=file \
@@ -25,13 +24,12 @@ flatpak-builder \
-Dbuild-examples=false \
-Dintrospection=false \
-Ddemos=true \
_build .
flatpak-builder \
--run ${builddir} build-aux/flatpak/${appid}.json \
ninja -C _build install
_flatpak_build
flatpak build ${builddir} ninja -C _flatpak_build install
flatpak-builder \
--user --disable-rofiles-fuse \
--finish-only \
--repo=${repodir} \
${builddir} \
@@ -40,5 +38,5 @@ flatpak-builder \
flatpak build-bundle \
${repodir} \
${appid}-dev.flatpak \
--runtime-repo=https://flathub.org/repo/flathub.flatpakrepo \
--runtime-repo=https://nightly.gnome.org/gnome-nightly.flatpakrepo \
${appid}

View File

@@ -138,22 +138,25 @@ ul.images li {
</head>
<body>
<header>
<h1>{{ report.project_name }} :: Test Reports</h1>
<div class="report-meta">
<p><strong>Branch:</strong> {{ report.branch_name }}</p>
<p><strong>Date:</strong> <time datetime="{{ report.date.isoformat() }}">{{ report.locale_date }}</time></p>
{% if report.job_id %}<p><strong>Job ID:</strong> {{ report.job_id }}</p>{% endif %}
</div>
<h1>{{ report.project_name }}/{{ report.branch_name }} :: Test Reports</h1>
</header>
<article>
<section>
<div class="report-meta">
<p><strong>Branch:</strong> {{ report.branch_name }}</p>
<p><strong>Date:</strong> <time datetime="{{ report.date.isoformat() }}">{{ report.locale_date }}</time></p>
{% if report.job_id %}<p><strong>Job ID:</strong> {{ report.job_id }}</p>{% endif %}
</div>
</section>
<section>
<div class="summary">
<h3><a name="summary">Summary</a></h3>
<ul>
<li><strong>Total units:</strong> {{ report.total_units }}</li>
<li><strong>Passed:</strong> <a href="#passed">{{ report.total_successes }}</a></li>
<li><strong>Failed:</strong> <a href="#failures">{{ report.total_failures }}</a></li>
<li><strong>Failed:</strong> {{ report.total_failures }}</li>
<li><strong>Passed:</strong> {{ report.total_successes }}</li>
</ul>
</div>
</section>
@@ -164,30 +167,47 @@ ul.images li {
<h3><a name="results">Suite: {{ suite_result.suite_name }}</a></h3>
<ul>
<li><strong>Units:</strong> {{ suite_result.n_units }}</li>
<li><strong>Passed:</strong> {{ suite_result.n_successes }}</li>
<li><strong>Failed:</strong> {{ suite_result.n_failures }}</li>
<li><strong>Failed:</strong> <a href="#{{ suite_result.suite_name }}-failed">{{ suite_result.n_failures }}</a></li>
<li><strong>Passed:</strong> <a href="#{{ suite_result.suite_name }}-passed">{{ suite_result.n_successes }}</a></li>
</ul>
<div class="failures">
<h4><a name="{{ suite_result.suite_name }}-failed">Failures</a></h4>
<ul class="failed">
{% for failure in suite_result.failures if failure.result in [ 'ERROR', 'FAIL', 'UNEXPECTEDPASS' ] %}
<li><a name="{{ failure.name }}">{{ failure.name }}</a> - result: <span class="result fail">{{ failure.result }}</span><br/>
{% if failure.stdout %}
Output: <pre>{{ failure.stdout }}</pre>
{% endif %}
{% if failure.image_data is defined %}
<ul class="images">
<li><img alt="ref" src="{{ failure.image_data.ref }}" /></li>
<li><img alt="out" src="{{ failure.image_data.out }}" /></li>
<li><img alt="diff" src="{{ failure.image_data.diff }}" /></li>
</ul>
{% endif %}
</li>
{% else %}
<li>None</li>
{% endfor %}
</ul>
<h4><a name="{{ suite_result.suite_name }}-timed-out">Timed out</a></h4>
<ul class="failed">
{% for failure in suite_result.failures if failure.result == 'TIMEOUT' %}
<li><a name="{{ failure.name }}">{{ failure.name }}</a> - result: <span class="result fail">{{ failure.result }}</span><br/>
{% if failure.stdout %}
Output: <pre>{{ failure.stdout }}</pre>
{% endif %}
</li>
{% else %}
<li>None</li>
{% endfor %}
</ul>
</div>
<div class="successes">
<h4><a name="passed">Passed</a></h4>
<ul class="passed">
{% for success in suite_result.successes if success.result == 'OK' %}
<li>{{ success.name }} - result: <span class="result pass">{{ success.result }}</li>
{% else %}
<li>None</li>
{% endfor %}
</ul>
<h4><a name="skipped">Skipped</a></h4>
<ul>
{% for success in suite_result.successes if success.result == 'SKIP' %}
<li>{{ success.name }} - result: <span class="result skip">{{ success.result }}</li>
{% else %}
<li>None</li>
{% endfor %}
</ul>
<h4><a name="expected-fail">Expected failures</a></h4>
<h4><a name="{{ suite_result.suite_name }}-expected-fail">Expected failures</a></h4>
<ul>
{% for success in suite_result.successes if success.result == 'EXPECTEDFAIL' %}
<li><a name="{{ success.name }}">{{ success.name }}</a> - result: <span class="result xfail">{{ success.result }}</span><br/>
@@ -206,37 +226,20 @@ ul.images li {
<li>None</li>
{% endfor %}
</ul>
</div>
<div class="failures">
<h4><a name="failed">Failed</a></h4>
<ul class="failed">
{% for failure in suite_result.failures if failure.result == 'FAIL' %}
<li><a name="{{ failure.name }}">{{ failure.name }}</a> - result: <span class="result fail">{{ failure.result }}</span><br/>
{% if failure.stdout %}
Output: <pre>{{ failure.stdout }}</pre>
{% endif %}
{% if failure.image_data is defined %}
<ul class="images">
<li><img alt="ref" src="{{ failure.image_data.ref }}" /></li>
<li><img alt="out" src="{{ failure.image_data.out }}" /></li>
<li><img alt="diff" src="{{ failure.image_data.diff }}" /></li>
</ul>
{% endif %}
</li>
<h4><a name="{{ suite_result.suite_name }}-skipped">Skipped</a></h4>
<ul>
{% for success in suite_result.successes if success.result == 'SKIP' %}
<li>{{ success.name }} - result: <span class="result skip">{{ success.result }}</li>
{% else %}
<li>None</li>
{% endfor %}
</ul>
<h4><a name="timed-out">Timed out</a></h4>
<ul class="failed">
{% for failure in suite_result.failures if failure.result == 'TIMEOUT' %}
<li><a name="{{ failure.name }}">{{ failure.name }}</a> - result: <span class="result fail">{{ failure.result }}</span><br/>
{% if failure.stdout %}
Output: <pre>{{ failure.stdout }}</pre>
{% endif %}
</li>
<h4><a name="{{ suite_result.suite_name }}-passed">Passed</a></h4>
<ul class="passed">
{% for success in suite_result.successes if success.result == 'OK' %}
<li>{{ success.name }} - result: <span class="result pass">{{ success.result }}</li>
{% else %}
<li>None</li>
{% endfor %}
@@ -328,7 +331,7 @@ for name, units in suites.items():
print('Processing {} suite {}:'.format(project_name, suite_name))
def if_failed(unit):
if unit['result'] in ['FAIL', 'TIMEOUT']:
if unit['result'] in ['FAIL', 'UNEXPECTEDPASS', 'TIMEOUT', 'ERROR',]:
return True
return False

View File

@@ -51,6 +51,7 @@ for line in args.infile:
duration = data['duration']
return_code = data['returncode']
result = data['result']
log = data['stdout']
unit = {
@@ -58,6 +59,7 @@ for line in args.infile:
'name': unit_name,
'duration': duration,
'returncode': return_code,
'result': result,
'stdout': log,
}
@@ -68,12 +70,12 @@ for name, units in suites.items():
print('Processing suite {} (units: {})'.format(name, len(units)))
def if_failed(unit):
if unit['returncode'] != 0:
if unit['result'] in ['ERROR', 'FAIL', 'UNEXPECTEDPASS', 'TIMEOUT']:
return True
return False
def if_succeded(unit):
if unit['returncode'] == 0:
if unit['result'] in ['OK', 'EXPECTEDFAIL', 'SKIP']:
return True
return False

View File

@@ -1,11 +1,135 @@
#!/bin/bash
read_arg() {
# $1 = arg name
# $2 = arg value
# $3 = arg parameter
local rematch='^[^=]*=(.*)$'
if [[ $2 =~ $rematch ]]; then
read "$1" <<< "${BASH_REMATCH[1]}"
else
read "$1" <<< "$3"
# There is no way to shift our callers args, so
# return 1 to indicate they should do it instead.
return 1
fi
}
set -e
TAG="registry.gitlab.gnome.org/gnome/gtk/master:v7"
build=0
run=0
push=0
list=0
print_help=0
no_login=0
sudo docker build --build-arg HOST_USER_ID="$UID" --tag "${TAG}" \
--file "Dockerfile" .
sudo docker run --rm --security-opt label=disable \
--volume "$(pwd)/..:/home/user/app" --workdir "/home/user/app" \
--tty --interactive "${TAG}" bash
while (($# > 0)); do
case "${1%%=*}" in
build) build=1;;
run) run=1;;
push) push=1;;
list) list=1;;
help) print_help=1;;
--base|-b) read_arg base "$@" || shift;;
--base-version) read_arg base_version "$@" || shift;;
--no-login) no_login=1;;
*) echo -e "\e[1;31mERROR\e[0m: Unknown option '$1'"; exit 1;;
esac
shift
done
if [ $print_help == 1 ]; then
echo "$0 - Build and run Docker images"
echo ""
echo "Usage: $0 <command> [options] [basename]"
echo ""
echo "Available commands"
echo ""
echo " build --base=<BASENAME> - Build Docker image <BASENAME>.Dockerfile"
echo " run --base=<BASENAME> - Run Docker image <BASENAME>"
echo " push --base=<BASENAME> - Push Docker image <BASENAME> to the registry"
echo " list - List available images"
echo " help - This help message"
echo ""
exit 0
fi
cd "$(dirname "$0")"
if [ $list == 1 ]; then
echo "Available Docker images:"
for f in *.Dockerfile; do
filename=$( basename -- "$f" )
basename="${filename%.*}"
echo -e " \e[1;39m$basename\e[0m"
done
exit 0
fi
# All commands after this require --base to be set
if [ -z $base ]; then
echo "Usage: $0 <command>"
exit 1
fi
if [ ! -f "$base.Dockerfile" ]; then
echo -e "\e[1;31mERROR\e[0m: Dockerfile for '$base' not found"
exit 1
fi
if [ -z $base_version ]; then
base_version="latest"
else
base_version="v$base_version"
fi
if [ ! -x "$(command -v docker)" ] || [ docker --help |& grep -q podman ]; then
# Docker is actually implemented by podman, and its OCI output
# is incompatible with some of the dockerd instances on GitLab
# CI runners.
echo "Using: Podman"
format="--format docker"
CMD="podman"
else
echo "Using: Docker"
format=""
CMD="sudo socker"
fi
REGISTRY="registry.gitlab.gnome.org"
TAG="${REGISTRY}/gnome/gtk/${base}:${base_version}"
if [ $build == 1 ]; then
echo -e "\e[1;32mBUILDING\e[0m: ${base} as ${TAG}"
${CMD} build \
${format} \
--build-arg HOST_USER_ID="$UID" \
--tag "${TAG}" \
--file "${base}.Dockerfile" .
exit $?
fi
if [ $push == 1 ]; then
echo -e "\e[1;32mPUSHING\e[0m: ${base} as ${TAG}"
if [ $no_login == 0 ]; then
${CMD} login ${REGISTRY}
fi
${CMD} push ${TAG}
exit $?
fi
if [ $run == 1 ]; then
echo -e "\e[1;32mRUNNING\e[0m: ${base} as ${TAG}"
${CMD} run \
--rm \
--volume "$(pwd)/..:/home/user/app" \
--workdir "/home/user/app" \
--tty \
--interactive "${TAG}" \
bash
exit $?
fi

View File

@@ -0,0 +1,37 @@
#!/bin/bash
set -e
# We need to add a new remote for the upstream master, since this script could
# be running in a personal fork of the repository which has out of date branches.
git remote add upstream https://gitlab.gnome.org/GNOME/gtk.git
git fetch upstream
# Work out the newest common ancestor between the detached HEAD that this CI job
# has checked out, and the upstream target branch (which will typically be
# `upstream/master` or `upstream/gtk-3-24`).
#
# `${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}` is only defined if were running in
# a merge request pipeline; fall back to `${CI_DEFAULT_BRANCH}` otherwise.
newest_common_ancestor_sha=$(diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent "upstream/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-${CI_DEFAULT_BRANCH}}") <(git rev-list --first-parent HEAD) | head -1)
git diff -U0 --no-color "${newest_common_ancestor_sha}" | .gitlab-ci/clang-format-diff.py -binary "clang-format" -p1
exit_status=$?
# The style check is not infallible. The clang-format configuration cannot
# perfectly describe GTKs coding style: in particular, it cannot align
# function arguments. The documented coding style for GTK takes priority over
# clang-format suggestions. Hopefully we can eventually improve clang-format to
# be configurable enough for our coding style. Thats why this CI check is OK
# to fail: the idea is that people can look through the output and ignore it if
# its wrong. (That situation can also happen if someone touches pre-existing
# badly formatted code and it doesnt make sense to tidy up the wider coding
# style with the changes theyre making.)
echo ""
echo "Note that clang-format output is advisory and cannot always match the"
echo "GTK coding style, documented at:"
echo " https://gitlab.gnome.org/GNOME/gtk/blob/master/docs/CODING-STYLE"
echo "Warnings from this tool can be ignored in favour of the documented "
echo "coding style, or in favour of matching the style of existing"
echo "surrounding code."
exit ${exit_status}

34
.gitlab-ci/run-tests.sh Executable file
View File

@@ -0,0 +1,34 @@
#!/bin/bash
set +x
set +e
srcdir=$( pwd )
builddir=$1
export GDK_BACKEND=x11
xvfb-run -a -s "-screen 0 1024x768x24" \
meson test -C ${builddir} \
--print-errorlogs \
--suite=gtk \
--no-suite=gtk:a11y
# Store the exit code for the CI run, but always
# generate the reports
exit_code=$?
cd ${builddir}
$srcdir/.gitlab-ci/meson-junit-report.py \
--project-name=gtk \
--job-id="${CI_JOB_NAME}" \
--output=report.xml \
meson-logs/testlog.json
$srcdir/.gitlab-ci/meson-html-report.py \
--project-name=gtk \
--job-id="${CI_JOB_NAME}" \
--reftest-output-dir="testsuite/reftests/output" \
--output=report.html \
meson-logs/testlog.json
exit $exit_code

169
NEWS
View File

@@ -1,3 +1,170 @@
Overview of Changes in GTK 3.98.2
=================================
* Introduce GtkShortcutController, and replace key bindings,
mnemonics and accelerators by GtkShortcut
* Derive the HighContrast theme from Adwaita
* GtkMenuButton: Add a use-underline property
* GtkTreeView: Fix cell editing
* Add gdk_toplevel_inhibit_system_shortcuts
* gtk-demo: Fix issues in multiple demos
* Translation updates:
Polish
Overview of Changes in GTK 3.98.1
=================================
* GtkFileChooser:
- Remove filename/uri api
- Drop extra-widget
- Remove overwrite confirmation
- Remove show-hidden property
- Remove local-only property
- Remove GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER
- The portal file chooser supports selecting folders
* GtkSpinner:
- Rename active property to spinning
* GtkRevealer:
- Fix size allocation at small scales
* GtkPopover:
- Drop :relative-to, it is always the :parent now
* GtkWindow:
- Drop window-type, it is always a regular toplevel
* GtkWidget:
- Drop expand property
- Drop margin property
- Drop gtk_grab_add, gtk_device_grab_add
* GtkTextView:
- Support overlines in GtkTextTag
- Support visible spaces in GtkTextTag
- Support hyphenation control in GtkTextTag
* Split GtkEventControllerFocus from GtkEventControllerKey
* DND:
- Fix local DND to avoid serialization
- Add new content provider constructors
- Split GtkDropTargetAsync and GtkDropTarget
- Group DND events into event sequences
- Propagate DND events like motion events
- Introduce GtkDropControllerMotion
- Remove GtkSelectionData
* Performance:
- Clean up profiler marks
- Share GL programs between renderers
* GDK:
- Drop gdk_surface_new_temp
- Make GdkEvent an immutable boxed type, not an object
- Remove GdkAtom and property- and selection-related apis
- Introduce GdkPopup and GdkToplevel interfaces
- Implement them in backend-specific surface subtypes
- Rename gdk_surface_input_shape_combine_region to
gdk_surface_set_input_region
- Drop X11-only concepts such as sticky or keep-below
* OS X: Fix OpenGL extension detection
* Broadway: implement scaling
* Translation updates:
Dutch
Japanese
Persian
Overview of Changes in GTK 3.98.0
=================================
While this release gets significantly closer to what we aim for in GTK 4,
there are still a few big items outstanding that we are currently working
on:
- Event controllers for keyboard shortcuts
- Movable popovers
- Row-recycling list and grid views
- Revamped accessibility infrastructure
- Animation API
We will do further 3.98.x snapshots as these land.
*****************
* The DND refactoring has been completed. The GTK API for DND has been turned
into event controllers: GtkDragSource and GtkDropTarget. Support for file
transfers via file transfer portal has been added for both DND and the clipboard.
* Child surfaces have been removed. GDK only supports toplevel and popup surfaces
now. The client-side window implementation has been removed too. On the GTK side,
the GtkNative interface has been introduced for widgets that have their own
surface. This cleanup is not 100% complete yet.
* Global positions and related apis such as gdk_surface_move are no longer available.
* A constraint-based layout manager has been added.
* Many classes have been made explicitly non-subclassable, and the widget hierarchy
has been simplified, by making widgets derive directly from GtkWidget instead of
a container.
* Menu-related changes:
- GtkMenu, GtkMenuBar and related classes have been removed. They are being replaced
by GMenu and popover-based variants. Popover menus can now do traditional, nested
menus, and model buttons show accelerators.
- Context menus are no longer created with ::populate-popup signals, but use menu
models and actions.
- Widget actions can be created in class_init, with gtk_widget_class_install_action.
- GtkToolbar has been removed as well.
* Text-related changed:
- Text cursor blinking has been made smooth.
- GtkTextView is caching rendernodes for the visible text range now, improving the
scrolling performance of text.
- Add a simple undo stack for text edits has been added.
* The native Win32 filechooser backend supports choices.
* GtkTreeView renders tree and grid lines with textures.
* GtkEmojiChooser has been made public.
* GtkGestureMultiPress has been renamed to GtkGestureClick.
* GtkWidget has api to handle style classes: gtk_widget_add_style_class.
This is the first step towards moving away from GtkStyleContext.
* X11-specific changes:
- XI2 is now mandatory
- The xim input method has been removed
* Wayland-specific changes:
- The loading of cursor themes has been improved to load cursors on demand,
and no longer relies on libwayland-cursor.
* The GL renderer is now sharing icon and glyph caches for all surfaces,
and has better support for blurring and shadow rendering.
* Performance-related changes:
- GTK provides profiling information for Sysprof when launched with GTK_TRACE=1.
- Css computation has been optimized
- Css lookups are using a Bloom filter
- Icon loading IO has been moved to a thread
Overview of Changes in GTK+ 3.96.0
==================================
@@ -360,7 +527,7 @@ Overview of Changes in GTK+ 3.92.1, 重庆市
The bulk of the preparation for this release was done during
and after the fantastic GNOME.Asia Summit 2017 in Chongqing, China.
* Drop autotools support. Meson 0.42.1 is now required
* Drop autotools support. Meson 0.42.1 is now required
* Implement most of CSS3 font-variant

View File

@@ -54,6 +54,36 @@
}
]
},
{
"name" : "libsass",
"buildsystem" : "meson",
"builddir" : true,
"config-opts": [
"--libdir=/app/lib"
],
"sources" : [
{
"type" : "git",
"url" : "https://github.com/lazka/libsass.git",
"branch" : "meson"
}
]
},
{
"name" : "sassc",
"buildsystem" : "meson",
"builddir" : true,
"config-opts": [
"--libdir=/app/lib"
],
"sources" : [
{
"type" : "git",
"url" : "https://github.com/lazka/sassc.git",
"branch" : "meson"
}
]
},
{
"name": "gtk",
"buildsystem": "meson",

View File

@@ -54,6 +54,36 @@
}
]
},
{
"name" : "libsass",
"buildsystem" : "meson",
"builddir" : true,
"config-opts": [
"--libdir=/app/lib"
],
"sources" : [
{
"type" : "git",
"url" : "https://github.com/lazka/libsass.git",
"branch" : "meson"
}
]
},
{
"name" : "sassc",
"buildsystem" : "meson",
"builddir" : true,
"config-opts": [
"--libdir=/app/lib"
],
"sources" : [
{
"type" : "git",
"url" : "https://github.com/lazka/sassc.git",
"branch" : "meson"
}
]
},
{
"name": "gtk",
"buildsystem": "meson",

View File

@@ -54,6 +54,36 @@
}
]
},
{
"name" : "libsass",
"buildsystem" : "meson",
"builddir" : true,
"config-opts": [
"--libdir=/app/lib"
],
"sources" : [
{
"type" : "git",
"url" : "https://github.com/lazka/libsass.git",
"branch" : "meson"
}
]
},
{
"name" : "sassc",
"buildsystem" : "meson",
"builddir" : true,
"config-opts": [
"--libdir=/app/lib"
],
"sources" : [
{
"type" : "git",
"url" : "https://github.com/lazka/sassc.git",
"branch" : "meson"
}
]
},
{
"name": "gtk",
"buildsystem": "meson",

View File

@@ -221,9 +221,12 @@ open_cb (GtkWidget *button,
GTK_FILE_CHOOSER_ACTION_OPEN,
"_Load",
"_Cancel");
gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (dialog), TRUE);
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), ".");
GFile *cwd = g_file_new_for_path (".");
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), cwd, NULL);
g_object_unref (cwd);
g_signal_connect (dialog, "response", G_CALLBACK (open_response_cb), self);
gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
}
@@ -290,29 +293,37 @@ save_response_cb (GtkNativeDialog *dialog,
if (response == GTK_RESPONSE_ACCEPT)
{
GListModel *model;
char *text, *filename;
GFile *file;
char *text;
GError *error = NULL;
model = constraint_view_get_model (CONSTRAINT_VIEW (self->view));
text = serialize_model (model);
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
if (!g_file_set_contents (filename, text, -1, &error))
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
g_file_replace_contents (file, text, -1,
NULL, FALSE,
G_FILE_CREATE_NONE,
NULL,
NULL,
&error);
if (error != NULL)
{
GtkWidget *dialog;
GtkWidget *message_dialog;
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (self))),
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
"Saving failed");
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
message_dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (self))),
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
"Saving failed");
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message_dialog),
"%s", error->message);
g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
gtk_widget_show (dialog);
g_signal_connect (message_dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
gtk_widget_show (message_dialog);
g_error_free (error);
}
g_free (filename);
g_free (text);
g_object_unref (file);
}
gtk_native_dialog_destroy (dialog);
@@ -329,9 +340,12 @@ save_cb (GtkWidget *button,
GTK_FILE_CHOOSER_ACTION_SAVE,
"_Save",
"_Cancel");
gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (dialog), TRUE);
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), ".");
GFile *cwd = g_file_new_for_path (".");
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), cwd, NULL);
g_object_unref (cwd);
g_signal_connect (dialog, "response", G_CALLBACK (save_response_cb), self);
gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
}
@@ -400,7 +414,7 @@ edit_constraint (ConstraintEditorWindow *win,
ConstraintEditor *editor;
GListModel *model;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (win));
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
if (constraint)
@@ -440,7 +454,7 @@ edit_guide (ConstraintEditorWindow *win,
GtkWidget *window;
GuideEditor *editor;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (win));
gtk_window_set_title (GTK_WINDOW (window), "Edit Guide");
@@ -587,7 +601,10 @@ create_widget_func (gpointer item,
g_object_bind_property (item, "name",
label, "label",
G_BINDING_DEFAULT);
g_object_set (label, "margin", 10, NULL);
gtk_widget_set_margin_start (label, 10);
gtk_widget_set_margin_end (label, 10);
gtk_widget_set_margin_top (label, 10);
gtk_widget_set_margin_bottom (label, 10);
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_widget_set_hexpand (label, TRUE);
gtk_container_add (GTK_CONTAINER (row), box);

View File

@@ -3,7 +3,10 @@
<template class="ConstraintEditor" parent="GtkWidget">
<child>
<object class="GtkGrid" id="grid">
<property name="margin">20</property>
<property name="margin-start">20</property>
<property name="margin-end">20</property>
<property name="margin-top">20</property>
<property name="margin-bottom">20</property>
<property name="row-spacing">10</property>
<property name="column-spacing">10</property>
<child>

View File

@@ -77,7 +77,7 @@ update_weak_position (ConstraintView *self,
GTK_CONSTRAINT_RELATION_EQ,
x,
GTK_CONSTRAINT_STRENGTH_WEAK);
g_object_set_data (G_OBJECT (constraint), "internal", "yes");
g_object_set_data (G_OBJECT (constraint), "internal", (char *)"yes");
gtk_constraint_layout_add_constraint (GTK_CONSTRAINT_LAYOUT (manager),
constraint);
g_object_set_data (G_OBJECT (child), "x-constraint", constraint);
@@ -97,7 +97,7 @@ update_weak_position (ConstraintView *self,
GTK_CONSTRAINT_RELATION_EQ,
y,
GTK_CONSTRAINT_STRENGTH_WEAK);
g_object_set_data (G_OBJECT (constraint), "internal", "yes");
g_object_set_data (G_OBJECT (constraint), "internal", (char *)"yes");
gtk_constraint_layout_add_constraint (GTK_CONSTRAINT_LAYOUT (manager),
constraint);
g_object_set_data (G_OBJECT (child), "y-constraint", constraint);
@@ -214,7 +214,7 @@ constraint_view_add_child (ConstraintView *view,
label = gtk_label_new (name);
frame = gtk_frame_new (NULL);
gtk_style_context_add_class (gtk_widget_get_style_context (frame), "child");
gtk_widget_add_css_class (frame, "child");
gtk_widget_set_name (frame, name);
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_widget_set_parent (frame, GTK_WIDGET (view));
@@ -257,8 +257,8 @@ constraint_view_add_guide (ConstraintView *view,
G_BINDING_DEFAULT);
frame = gtk_frame_new (NULL);
gtk_style_context_add_class (gtk_widget_get_style_context (frame), "guide");
g_object_set_data (G_OBJECT (frame), "internal", "yes");
gtk_widget_add_css_class (frame, "guide");
g_object_set_data (G_OBJECT (frame), "internal", (char *)"yes");
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_widget_insert_after (frame, GTK_WIDGET (view), NULL);
@@ -276,7 +276,7 @@ constraint_view_add_guide (ConstraintView *view,
names[i].attr,
1.0, 0.0,
GTK_CONSTRAINT_STRENGTH_REQUIRED);
g_object_set_data (G_OBJECT (constraint), "internal", "yes");
g_object_set_data (G_OBJECT (constraint), "internal", (char *)"yes");
gtk_constraint_layout_add_constraint (layout, constraint);
g_object_set_data (G_OBJECT (guide), names[i].name, constraint);
}

View File

@@ -78,7 +78,7 @@ get_strength (const char *id)
return strength;
}
const char *
static const char *
get_strength_nick (GtkConstraintStrength strength)
{
GEnumClass *class = g_type_class_ref (GTK_TYPE_CONSTRAINT_STRENGTH);

View File

@@ -45,7 +45,10 @@
<template class="GuideEditor" parent="GtkWidget">
<child>
<object class="GtkGrid" id="grid">
<property name="margin">20</property>
<property name="margin-start">20</property>
<property name="margin-end">20</property>
<property name="margin-top">20</property>
<property name="margin-bottom">20</property>
<property name="row-spacing">10</property>
<property name="column-spacing">10</property>
<child>

View File

@@ -13,6 +13,7 @@ constraint_editor_resources = gnome.compile_resources('constraint_editor_resourc
executable('gtk4-constraint-editor',
constraint_editor_sources, constraint_editor_resources,
c_args: common_cflags,
dependencies: libgtk_dep,
include_directories: confinc,
gui_app: true,

View File

@@ -6,6 +6,7 @@
typedef GtkApplication DemoApplication;
typedef GtkApplicationClass DemoApplicationClass;
static GType demo_application_get_type (void);
G_DEFINE_TYPE (DemoApplication, demo_application, GTK_TYPE_APPLICATION)
typedef struct {
@@ -14,7 +15,7 @@ typedef struct {
GtkWidget *message;
GtkWidget *infobar;
GtkWidget *status;
GtkWidget *menutool;
GtkWidget *menubutton;
GMenuModel *toolmenu;
GtkTextBuffer *buffer;
@@ -25,6 +26,7 @@ typedef struct {
} DemoApplicationWindow;
typedef GtkApplicationWindowClass DemoApplicationWindowClass;
static GType demo_application_window_get_type (void);
G_DEFINE_TYPE (DemoApplicationWindow, demo_application_window, GTK_TYPE_APPLICATION_WINDOW)
static void create_window (GApplication *app, const char *contents);
@@ -428,8 +430,8 @@ demo_application_window_init (DemoApplicationWindow *window)
gtk_widget_init_template (GTK_WIDGET (window));
popover = gtk_popover_menu_new_from_model (window->menutool, window->toolmenu);
gtk_menu_tool_button_set_popover (GTK_MENU_TOOL_BUTTON (window->menutool), popover);
popover = gtk_popover_menu_new_from_model (window->toolmenu);
gtk_menu_button_set_popover (GTK_MENU_BUTTON (window->menubutton), popover);
g_action_map_add_action_entries (G_ACTION_MAP (window),
win_entries, G_N_ELEMENTS (win_entries),
@@ -477,7 +479,7 @@ surface_state_changed (GtkWidget *widget)
DemoApplicationWindow *window = (DemoApplicationWindow *)widget;
GdkSurfaceState new_state;
new_state = gdk_surface_get_state (gtk_native_get_surface (GTK_NATIVE (widget)));
new_state = gdk_toplevel_get_state (GDK_TOPLEVEL (gtk_native_get_surface (GTK_NATIVE (widget))));
window->maximized = (new_state & GDK_SURFACE_STATE_MAXIMIZED) != 0;
window->fullscreen = (new_state & GDK_SURFACE_STATE_FULLSCREEN) != 0;
}
@@ -528,7 +530,7 @@ demo_application_window_class_init (DemoApplicationWindowClass *class)
gtk_widget_class_bind_template_child (widget_class, DemoApplicationWindow, infobar);
gtk_widget_class_bind_template_child (widget_class, DemoApplicationWindow, status);
gtk_widget_class_bind_template_child (widget_class, DemoApplicationWindow, buffer);
gtk_widget_class_bind_template_child (widget_class, DemoApplicationWindow, menutool);
gtk_widget_class_bind_template_child (widget_class, DemoApplicationWindow, menubutton);
gtk_widget_class_bind_template_child (widget_class, DemoApplicationWindow, toolmenu);
gtk_widget_class_bind_template_callback (widget_class, clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, update_statusbar);

View File

@@ -8,27 +8,24 @@
<child>
<object class="GtkGrid">
<child>
<object class="GtkToolbar">
<object class="GtkBox">
<property name="hexpand">1</property>
<style>
<class name="primary-toolbar"/>
</style>
<child>
<object class="GtkMenuToolButton" id="menutool">
<object class="GtkMenuButton" id="menubutton">
<property name="icon-name">document-open</property>
</object>
</child>
<child>
<object class="GtkToolButton">
<object class="GtkButton">
<property name="icon-name">application-exit</property>
<property name="action-name">app.quit</property>
</object>
</child>
<child>
<object class="GtkSeparatorToolItem"/>
<object class="GtkSeparator"/>
</child>
<child>
<object class="GtkToolButton">
<object class="GtkButton">
<property name="icon-name">applications-other</property>
<property name="action-name">win.logo</property>
</object>

View File

@@ -11,7 +11,7 @@
<item>
<attribute name="label" translatable="yes">_Quit</attribute>
<attribute name="action">app.quit</attribute>
<attribute name="accel">&lt;Primary&gt;q</attribute>
<attribute name="accel">&lt;Control&gt;q</attribute>
</item>
</section>
</menu>

View File

@@ -7,7 +7,6 @@
#include <gtk/gtk.h>
static GtkWidget *assistant = NULL;
static GtkWidget *progress_bar = NULL;
static gboolean
@@ -27,8 +26,7 @@ apply_changes_gradually (gpointer data)
else
{
/* Close automatically once changes are fully applied. */
gtk_widget_destroy (assistant);
assistant = NULL;
gtk_widget_destroy (data);
return G_SOURCE_REMOVE;
}
}
@@ -37,16 +35,13 @@ static void
on_assistant_apply (GtkWidget *widget, gpointer data)
{
/* Start a timer to simulate changes taking a few seconds to apply. */
g_timeout_add (100, apply_changes_gradually, NULL);
g_timeout_add (100, apply_changes_gradually, widget);
}
static void
on_assistant_close_cancel (GtkWidget *widget, gpointer data)
{
GtkWidget **assistant = (GtkWidget **) data;
gtk_widget_destroy (*assistant);
*assistant = NULL;
gtk_widget_destroy (widget);
}
static void
@@ -94,7 +89,10 @@ create_page1 (GtkWidget *assistant)
GtkWidget *box, *label, *entry;
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
g_object_set (box, "margin", 12, NULL);
gtk_widget_set_margin_start (box, 12);
gtk_widget_set_margin_end (box, 12);
gtk_widget_set_margin_top (box, 12);
gtk_widget_set_margin_bottom (box, 12);
label = gtk_label_new ("You must fill out this entry to continue:");
gtk_container_add (GTK_CONTAINER (box), label);
@@ -117,7 +115,10 @@ create_page2 (GtkWidget *assistant)
GtkWidget *box, *checkbutton;
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
g_object_set (box, "margin", 12, NULL);
gtk_widget_set_margin_start (box, 12);
gtk_widget_set_margin_end (box, 12);
gtk_widget_set_margin_top (box, 12);
gtk_widget_set_margin_bottom (box, 12);
checkbutton = gtk_check_button_new_with_label ("This is optional data, you may continue "
"even if you do not check this");
@@ -167,6 +168,8 @@ create_page4 (GtkWidget *assistant)
GtkWidget*
do_assistant (GtkWidget *do_widget)
{
static GtkWidget *assistant;
if (!assistant)
{
assistant = gtk_assistant_new ();
@@ -175,6 +178,8 @@ do_assistant (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (assistant),
gtk_widget_get_display (do_widget));
g_signal_connect (assistant, "destroy",
G_CALLBACK (gtk_widget_destroyed), &assistant);
create_page1 (assistant);
create_page2 (assistant);
@@ -182,9 +187,9 @@ do_assistant (GtkWidget *do_widget)
create_page4 (assistant);
g_signal_connect (G_OBJECT (assistant), "cancel",
G_CALLBACK (on_assistant_close_cancel), &assistant);
G_CALLBACK (on_assistant_close_cancel), NULL);
g_signal_connect (G_OBJECT (assistant), "close",
G_CALLBACK (on_assistant_close_cancel), &assistant);
G_CALLBACK (on_assistant_close_cancel), NULL);
g_signal_connect (G_OBJECT (assistant), "apply",
G_CALLBACK (on_assistant_apply), NULL);
g_signal_connect (G_OBJECT (assistant), "prepare",
@@ -194,10 +199,7 @@ do_assistant (GtkWidget *do_widget)
if (!gtk_widget_get_visible (assistant))
gtk_widget_show (assistant);
else
{
gtk_widget_destroy (assistant);
assistant = NULL;
}
gtk_widget_destroy (assistant);
return assistant;
}

View File

@@ -25,7 +25,6 @@
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow">
<property name="can-focus">1</property>
<property name="vexpand">1</property>
<property name="shadow-type">in</property>
<property name="min-content-width">150</property>

View File

@@ -131,13 +131,11 @@ blur_overlay_child_update_style_classes (BlurOverlay *overlay,
GtkAlign valign, halign;
gboolean is_left, is_right, is_top, is_bottom;
gboolean has_left, has_right, has_top, has_bottom;
GtkStyleContext *context;
context = gtk_widget_get_style_context (child);
has_left = gtk_style_context_has_class (context, GTK_STYLE_CLASS_LEFT);
has_right = gtk_style_context_has_class (context, GTK_STYLE_CLASS_RIGHT);
has_top = gtk_style_context_has_class (context, GTK_STYLE_CLASS_TOP);
has_bottom = gtk_style_context_has_class (context, GTK_STYLE_CLASS_BOTTOM);
has_left = gtk_widget_has_css_class (child, GTK_STYLE_CLASS_LEFT);
has_right = gtk_widget_has_css_class (child, GTK_STYLE_CLASS_RIGHT);
has_top = gtk_widget_has_css_class (child, GTK_STYLE_CLASS_TOP);
has_bottom = gtk_widget_has_css_class (child, GTK_STYLE_CLASS_BOTTOM);
is_left = is_right = is_top = is_bottom = FALSE;
@@ -160,24 +158,24 @@ blur_overlay_child_update_style_classes (BlurOverlay *overlay,
is_bottom = (child_allocation->y + child_allocation->height == height);
if (has_left && !is_left)
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_LEFT);
gtk_widget_remove_css_class (child, GTK_STYLE_CLASS_LEFT);
else if (!has_left && is_left)
gtk_style_context_add_class (context, GTK_STYLE_CLASS_LEFT);
gtk_widget_add_css_class (child, GTK_STYLE_CLASS_LEFT);
if (has_right && !is_right)
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_RIGHT);
gtk_widget_remove_css_class (child, GTK_STYLE_CLASS_RIGHT);
else if (!has_right && is_right)
gtk_style_context_add_class (context, GTK_STYLE_CLASS_RIGHT);
gtk_widget_add_css_class (child, GTK_STYLE_CLASS_RIGHT);
if (has_top && !is_top)
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TOP);
gtk_widget_remove_css_class (child, GTK_STYLE_CLASS_TOP);
else if (!has_top && is_top)
gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP);
gtk_widget_add_css_class (child, GTK_STYLE_CLASS_TOP);
if (has_bottom && !is_bottom)
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BOTTOM);
gtk_widget_remove_css_class (child, GTK_STYLE_CLASS_BOTTOM);
else if (!has_bottom && is_bottom)
gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM);
gtk_widget_add_css_class (child, GTK_STYLE_CLASS_BOTTOM);
}
static void

View File

@@ -63,7 +63,6 @@ GtkWidget *
do_builder (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
GtkWidget *toolbar;
GActionGroup *actions;
if (!window)
@@ -77,9 +76,6 @@ do_builder (GtkWidget *do_widget)
gtk_widget_get_display (do_widget));
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &window);
toolbar = GTK_WIDGET (gtk_builder_get_object (builder, "toolbar1"));
gtk_style_context_add_class (gtk_widget_get_style_context (toolbar),
"primary-toolbar");
actions = (GActionGroup*)g_simple_action_group_new ();
g_action_map_add_action_entries (G_ACTION_MAP (actions),
win_entries, G_N_ELEMENTS (win_entries),

View File

@@ -15,7 +15,7 @@
static GtkWidget *window = NULL;
void
static void
copy_button_clicked (GtkWidget *button,
gpointer user_data)
{
@@ -31,7 +31,7 @@ copy_button_clicked (GtkWidget *button,
gdk_clipboard_set_text (clipboard, gtk_editable_get_text (GTK_EDITABLE (entry)));
}
void
static void
paste_received (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
@@ -75,7 +75,7 @@ paste_received (GObject *source_object,
}
}
void
static void
paste_button_clicked (GtkWidget *button,
gpointer user_data)
{
@@ -98,7 +98,7 @@ get_image_paintable (GtkImage *image)
{
const gchar *icon_name;
GtkIconTheme *icon_theme;
GtkIconInfo *icon_info;
GtkIconPaintable *icon;
switch (gtk_image_get_storage_type (image))
{
@@ -107,10 +107,18 @@ get_image_paintable (GtkImage *image)
case GTK_IMAGE_ICON_NAME:
icon_name = gtk_image_get_icon_name (image);
icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (image)));
icon_info = gtk_icon_theme_lookup_icon (icon_theme, icon_name, 48, GTK_ICON_LOOKUP_GENERIC_FALLBACK);
if (icon_info == NULL)
icon = gtk_icon_theme_lookup_icon (icon_theme,
icon_name,
NULL,
48, 1,
gtk_widget_get_direction (GTK_WIDGET (image)),
0);
if (icon == NULL)
return NULL;
return gtk_icon_info_load_icon (icon_info, NULL);
return GDK_PAINTABLE (icon);
case GTK_IMAGE_EMPTY:
case GTK_IMAGE_GICON:
default:
g_warning ("Image storage type %d not handled",
gtk_image_get_storage_type (image));
@@ -133,62 +141,31 @@ drag_begin (GtkDragSource *source,
}
}
static void
get_texture (GValue *value,
gpointer data)
{
GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (data));
if (GDK_IS_TEXTURE (paintable))
g_value_set_object (value, paintable);
}
static GdkContentProvider *
prepare_drag (GtkDragSource *source,
double x,
double y,
GtkWidget *image)
{
return gdk_content_provider_new_with_callback (GDK_TYPE_TEXTURE, get_texture, image);
}
GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (image));
static void
got_texture (GObject *source,
GAsyncResult *result,
gpointer data)
{
GdkDrop *drop = GDK_DROP (source);
GtkWidget *image = data;
const GValue *value;
GError *error = NULL;
if (!GDK_IS_TEXTURE (paintable))
return NULL;
value = gdk_drop_read_value_finish (drop, result, &error);
if (value)
{
GdkTexture *texture = g_value_get_object (value);
gtk_image_set_from_paintable (GTK_IMAGE (image), GDK_PAINTABLE (texture));
}
else
{
g_print ("Failed to get data: %s\n", error->message);
g_error_free (error);
}
return gdk_content_provider_new_typed (GDK_TYPE_TEXTURE, paintable);
}
static gboolean
drag_drop (GtkDropTarget *dest,
GdkDrop *drop,
int x,
int y,
GtkWidget *widget)
const GValue *value,
double x,
double y,
GtkImage *image)
{
if (gdk_drop_has_value (drop, GDK_TYPE_TEXTURE))
{
gdk_drop_read_value_async (drop, GDK_TYPE_TEXTURE, G_PRIORITY_DEFAULT, NULL, got_texture, widget);
return TRUE;
}
GdkTexture *texture = g_value_get_object (value);
gtk_image_set_from_paintable (GTK_IMAGE (image), GDK_PAINTABLE (texture));
return FALSE;
return TRUE;
}
static void
@@ -248,7 +225,8 @@ pressed_cb (GtkGesture *gesture,
item = g_menu_item_new (_("_Paste"), "clipboard.paste");
g_menu_append_item (menu, item);
popover = gtk_popover_menu_new_from_model (image, G_MENU_MODEL (menu));
popover = gtk_popover_menu_new_from_model (G_MENU_MODEL (menu));
gtk_widget_set_parent (popover, image);
gtk_popover_set_pointing_to (GTK_POPOVER (popover), &(GdkRectangle) { x, y, 1, 1});
gtk_popover_popup (GTK_POPOVER (popover));
@@ -273,9 +251,8 @@ do_clipboard (GtkWidget *do_widget)
GActionGroup *actions;
GtkDragSource *source;
GtkDropTarget *dest;
GdkContentFormats *formats;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Clipboard");
@@ -284,7 +261,10 @@ do_clipboard (GtkWidget *do_widget)
G_CALLBACK (gtk_widget_destroyed), &window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
g_object_set (vbox, "margin", 8, NULL);
gtk_widget_set_margin_start (vbox, 8);
gtk_widget_set_margin_end (vbox, 8);
gtk_widget_set_margin_top (vbox, 8);
gtk_widget_set_margin_bottom (vbox, 8);
gtk_container_add (GTK_CONTAINER (window), vbox);
@@ -293,7 +273,10 @@ do_clipboard (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (vbox), label);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
g_object_set (hbox, "margin", 8, NULL);
gtk_widget_set_margin_start (hbox, 8);
gtk_widget_set_margin_end (hbox, 8);
gtk_widget_set_margin_top (hbox, 8);
gtk_widget_set_margin_bottom (hbox, 8);
gtk_container_add (GTK_CONTAINER (vbox), hbox);
/* Create the first entry */
@@ -310,7 +293,10 @@ do_clipboard (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (vbox), label);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
g_object_set (hbox, "margin", 8, NULL);
gtk_widget_set_margin_start (hbox, 8);
gtk_widget_set_margin_end (hbox, 8);
gtk_widget_set_margin_top (hbox, 8);
gtk_widget_set_margin_bottom (hbox, 8);
gtk_container_add (GTK_CONTAINER (vbox), hbox);
/* Create the second entry */
@@ -327,7 +313,10 @@ do_clipboard (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (vbox), label);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
g_object_set (hbox, "margin", 8, NULL);
gtk_widget_set_margin_start (hbox, 8);
gtk_widget_set_margin_end (hbox, 8);
gtk_widget_set_margin_top (hbox, 8);
gtk_widget_set_margin_bottom (hbox, 8);
gtk_container_add (GTK_CONTAINER (vbox), hbox);
/* Create the first image */
@@ -342,10 +331,8 @@ do_clipboard (GtkWidget *do_widget)
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
/* accept drops on image */
formats = gdk_content_formats_new_for_gtype (GDK_TYPE_TEXTURE);
dest = gtk_drop_target_new (formats, GDK_ACTION_COPY);
gdk_content_formats_unref (formats);
g_signal_connect (dest, "drag-drop", G_CALLBACK (drag_drop), image);
dest = gtk_drop_target_new (GDK_TYPE_TEXTURE, GDK_ACTION_COPY);
g_signal_connect (dest, "drop", G_CALLBACK (drag_drop), image);
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (dest));
/* context menu on image */
@@ -373,10 +360,8 @@ do_clipboard (GtkWidget *do_widget)
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
/* accept drops on image */
formats = gdk_content_formats_new_for_gtype (GDK_TYPE_TEXTURE);
dest = gtk_drop_target_new (formats, GDK_ACTION_COPY);
gdk_content_formats_unref (formats);
g_signal_connect (dest, "drag-drop", G_CALLBACK (drag_drop), image);
dest = gtk_drop_target_new (GDK_TYPE_TEXTURE, GDK_ACTION_COPY);
g_signal_connect (dest, "drop", G_CALLBACK (drag_drop), image);
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (dest));
/* context menu on image */

View File

@@ -16,7 +16,7 @@ static GtkWidget *frame;
/* draw callback for the drawing area
*/
static void
draw_function (GtkDrawingArea *da,
draw_function (GtkDrawingArea *drawing_area,
cairo_t *cr,
int width,
int height,
@@ -69,7 +69,7 @@ do_colorsel (GtkWidget *do_widget)
color.green = 0;
color.alpha = 1;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Color Chooser");
@@ -79,7 +79,10 @@ do_colorsel (GtkWidget *do_widget)
G_CALLBACK (gtk_widget_destroyed), &window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
g_object_set (vbox, "margin", 12, NULL);
gtk_widget_set_margin_start (vbox, 12);
gtk_widget_set_margin_end (vbox, 12);
gtk_widget_set_margin_top (vbox, 12);
gtk_widget_set_margin_bottom (vbox, 12);
gtk_container_add (GTK_CONTAINER (window), vbox);
/*

View File

@@ -19,7 +19,7 @@ enum
static GtkTreeModel *
create_icon_store (void)
{
const gchar *icon_names[6] = {
const char *icon_names[6] = {
"dialog-warning",
"process-stop",
"document-new",
@@ -27,7 +27,7 @@ create_icon_store (void)
NULL,
"document-open"
};
const gchar *labels[6] = {
const char *labels[6] = {
N_("Warning"),
N_("Stop"),
N_("New"),
@@ -111,8 +111,8 @@ static GtkTreeModel *
create_capital_store (void)
{
struct {
gchar *group;
gchar *capital;
const char *group;
const char *capital;
} capitals[] = {
{ "A - B", NULL },
{ NULL, "Albany" },
@@ -234,7 +234,7 @@ typedef struct _MaskEntry MaskEntry;
struct _MaskEntry
{
GtkEntry entry;
gchar *mask;
const char *mask;
};
typedef struct _MaskEntryClass MaskEntryClass;
@@ -246,6 +246,7 @@ struct _MaskEntryClass
static void mask_entry_editable_init (GtkEditableInterface *iface);
static GType mask_entry_get_type (void);
G_DEFINE_TYPE_WITH_CODE (MaskEntry, mask_entry, GTK_TYPE_ENTRY,
G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE,
mask_entry_editable_init));
@@ -310,7 +311,7 @@ do_combobox (GtkWidget *do_widget)
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Combo Boxes");
@@ -319,7 +320,10 @@ do_combobox (GtkWidget *do_widget)
G_CALLBACK (gtk_widget_destroyed), &window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
g_object_set (vbox, "margin", 10, NULL);
gtk_widget_set_margin_start (vbox, 10);
gtk_widget_set_margin_end (vbox, 10);
gtk_widget_set_margin_top (vbox, 10);
gtk_widget_set_margin_bottom (vbox, 10);
gtk_container_add (GTK_CONTAINER (window), vbox);
/* A combobox demonstrating cell renderers, separators and
@@ -329,7 +333,10 @@ do_combobox (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (vbox), frame);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
g_object_set (box, "margin", 5, NULL);
gtk_widget_set_margin_start (box, 5);
gtk_widget_set_margin_end (box, 5);
gtk_widget_set_margin_top (box, 5);
gtk_widget_set_margin_bottom (box, 5);
gtk_container_add (GTK_CONTAINER (frame), box);
model = create_icon_store ();
@@ -370,7 +377,10 @@ do_combobox (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (vbox), frame);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
g_object_set (box, "margin", 5, NULL);
gtk_widget_set_margin_start (box, 5);
gtk_widget_set_margin_end (box, 5);
gtk_widget_set_margin_top (box, 5);
gtk_widget_set_margin_bottom (box, 5);
gtk_container_add (GTK_CONTAINER (frame), box);
model = create_capital_store ();
@@ -398,7 +408,10 @@ do_combobox (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (vbox), frame);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
g_object_set (box, "margin", 5, NULL);
gtk_widget_set_margin_start (box, 5);
gtk_widget_set_margin_end (box, 5);
gtk_widget_set_margin_top (box, 5);
gtk_widget_set_margin_bottom (box, 5);
gtk_container_add (GTK_CONTAINER (frame), box);
combo = gtk_combo_box_text_new_with_entry ();
@@ -416,7 +429,10 @@ do_combobox (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (vbox), frame);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
g_object_set (box, "margin", 5, NULL);
gtk_widget_set_margin_start (box, 5);
gtk_widget_set_margin_end (box, 5);
gtk_widget_set_margin_top (box, 5);
gtk_widget_set_margin_bottom (box, 5);
gtk_container_add (GTK_CONTAINER (frame), box);
combo = gtk_combo_box_text_new ();

View File

@@ -255,7 +255,7 @@ do_constraints (GtkWidget *do_widget)
{
GtkWidget *header, *box, *grid, *button;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
header = gtk_header_bar_new ();

View File

@@ -211,7 +211,7 @@ do_constraints2 (GtkWidget *do_widget)
{
GtkWidget *header, *box, *grid, *button;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
header = gtk_header_bar_new ();

View File

@@ -131,7 +131,7 @@ do_constraints3 (GtkWidget *do_widget)
{
GtkWidget *header, *box, *grid, *button;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
header = gtk_header_bar_new ();

View File

@@ -24,7 +24,7 @@ do_css_accordion (GtkWidget *do_widget)
GtkWidget *container, *child;
GtkStyleProvider *provider;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "CSS Accordion");
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
gtk_window_set_default_size (GTK_WINDOW (window), 600, 300);

View File

@@ -72,7 +72,7 @@ do_css_basics (GtkWidget *do_widget)
GtkTextBuffer *text;
GBytes *bytes;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "CSS Basics");
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);

View File

@@ -11,8 +11,8 @@
* These are the available blend modes.
*/
struct {
gchar *name;
gchar *id;
const char *name;
const char *id;
} blend_modes[] =
{
{ "Color", "color" },

View File

@@ -86,7 +86,7 @@ do_css_multiplebgs (GtkWidget *do_widget)
GtkTextBuffer *text;
GBytes *bytes;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Multiple Backgrounds");
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);

View File

@@ -72,7 +72,7 @@ do_css_pixbufs (GtkWidget *do_widget)
GtkTextBuffer *text;
GBytes *bytes;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Animated Backgrounds");
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);

View File

@@ -58,26 +58,23 @@ apply_css (GtkWidget *widget, GtkStyleProvider *provider)
gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback) apply_css, provider);
}
GtkWidget *
static GtkWidget *
create_toolbar (void)
{
GtkWidget *toolbar;
GtkToolItem *item;
GtkWidget *item;
toolbar = gtk_toolbar_new ();
toolbar = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_widget_set_valign (toolbar, GTK_ALIGN_CENTER);
item = gtk_tool_button_new (NULL, NULL);
gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "go-next");
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
item = gtk_button_new_from_icon_name ("go-next");
gtk_container_add (GTK_CONTAINER (toolbar), item);
item = gtk_tool_button_new (NULL, NULL);
gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "go-previous");
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
item = gtk_button_new_from_icon_name ("go-previous");
gtk_container_add (GTK_CONTAINER (toolbar), item);
item = gtk_tool_button_new (NULL, "Hello World");
gtk_tool_item_set_is_important (item, TRUE);
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
item = gtk_button_new_with_label ("Hello World");
gtk_container_add (GTK_CONTAINER (toolbar), item);
return toolbar;
}
@@ -94,7 +91,7 @@ do_css_shadows (GtkWidget *do_widget)
GtkTextBuffer *text;
GBytes *bytes;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Shadows");
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);

View File

@@ -656,7 +656,10 @@
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="margin">60</property>
<property name="margin-start">60</property>
<property name="margin-end">60</property>
<property name="margin-top">60</property>
<property name="margin-bottom">60</property>
<property name="spacing">10</property>
<property name="halign">center</property>
<child>
@@ -672,7 +675,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -729,7 +735,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -786,7 +795,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -856,7 +868,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -913,7 +928,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -970,7 +988,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -1027,7 +1048,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -1084,7 +1108,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -1154,7 +1181,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -1211,7 +1241,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -1268,7 +1301,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -1325,7 +1361,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -1395,7 +1434,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -1452,7 +1494,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -1509,7 +1554,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -1566,7 +1614,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -1623,7 +1674,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -1680,7 +1734,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -1737,7 +1794,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -1807,7 +1867,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -1864,7 +1927,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -1921,7 +1987,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -1978,7 +2047,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -2035,7 +2107,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -2092,7 +2167,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -2149,7 +2227,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -2206,7 +2287,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -2263,7 +2347,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -2320,7 +2407,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -2377,7 +2467,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -2434,7 +2527,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -2491,7 +2587,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -2548,7 +2647,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -2605,7 +2707,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -2675,7 +2780,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
@@ -2732,7 +2840,10 @@
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">

View File

@@ -104,6 +104,10 @@
<file>gtkfishbowl.c</file>
<file>gtkfishbowl.h</file>
</gresource>
<gresource prefix="/gears">
<file>gtkgears.c</file>
<file>gtkgears.h</file>
</gresource>
<gresource prefix="/iconscroll">
<file>iconscroll.ui</file>
</gresource>
@@ -173,10 +177,10 @@
<file>fishbowl.c</file>
<file>fixed.c</file>
<file>flowbox.c</file>
<file>foreigndrawing.c</file>
<file>font_features.c</file>
<file>fontplane.c</file>
<file>fontrendering.c</file>
<file>gears.c</file>
<file>gestures.c</file>
<file>glarea.c</file>
<file>headerbar.c</file>
@@ -200,9 +204,9 @@
<file>paintable_mediastream.c</file>
<file>panes.c</file>
<file>password_entry.c</file>
<file>peg_solitaire.c</file>
<file>pickers.c</file>
<file>pixbufs.c</file>
<file>popover.c</file>
<file>printing.c</file>
<file>revealer.c</file>
<file>rotated_text.c</file>
@@ -210,6 +214,7 @@
<file>search_entry.c</file>
<file>search_entry2.c</file>
<file>shortcuts.c</file>
<file>shortcut_triggers.c</file>
<file>sizegroup.c</file>
<file>sidebar.c</file>
<file>sliding_puzzle.c</file>
@@ -239,9 +244,6 @@
<file>messages.txt</file>
<file>apple-red.png</file>
</gresource>
<gresource prefix="/popover">
<file>popover.ui</file>
</gresource>
<gresource prefix="/glarea">
<file>glarea-gl.fs.glsl</file>
<file>glarea-gl.vs.glsl</file>

View File

@@ -29,29 +29,29 @@
<item>
<attribute name="label" translatable="yes">_New</attribute>
<attribute name="action">win.new</attribute>
<attribute name="accel">&lt;Primary&gt;n</attribute>
<attribute name="accel">&lt;Control&gt;n</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Open</attribute>
<attribute name="action">win.open</attribute>
<attribute name="accel">&lt;Primary&gt;o</attribute>
<attribute name="accel">&lt;Control&gt;o</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Save</attribute>
<attribute name="action">win.save</attribute>
<attribute name="accel">&lt;Primary&gt;s</attribute>
<attribute name="accel">&lt;Control&gt;s</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Save _As</attribute>
<attribute name="action">win.save-as</attribute>
<attribute name="accel">&lt;Primary&gt;q</attribute>
<attribute name="accel">&lt;Control&gt;q</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">_Quit</attribute>
<attribute name="action">win.quit</attribute>
<attribute name="accel">&lt;Primary&gt;&lt;Shift&gt;s</attribute>
<attribute name="accel">&lt;Control&gt;&lt;Shift&gt;s</attribute>
</item>
</section>
</submenu>
@@ -61,17 +61,17 @@
<item>
<attribute name="label" translatable="yes">_Copy</attribute>
<attribute name="action">win.copy</attribute>
<attribute name="accel">&lt;Primary&gt;c</attribute>
<attribute name="accel">&lt;Control&gt;c</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Cut</attribute>
<attribute name="action">win.cut</attribute>
<attribute name="accel">&lt;Primary&gt;x</attribute>
<attribute name="accel">&lt;Control&gt;x</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Paste</attribute>
<attribute name="action">win.paste</attribute>
<attribute name="accel">&lt;Primary&gt;v</attribute>
<attribute name="accel">&lt;Control&gt;v</attribute>
</item>
</section>
</submenu>
@@ -111,53 +111,52 @@
</object>
</child>
<child>
<object class="GtkToolbar" id="toolbar1">
<object class="GtkBox" id="toolbar1">
<child internal-child="accessible">
<object class="AtkObject" id="a11y-toolbar">
<property name="AtkObject::accessible-name">The toolbar</property>
</object>
</child>
<child>
<object class="GtkToolButton">
<object class="GtkButton">
<property name="label" translatable="yes">New</property>
<property name="tooltip-text" translatable="yes">Create a new file</property>
<property name="icon-name">document-new</property>
</object>
</child>
<child>
<object class="GtkToolButton">
<object class="GtkButton">
<property name="label" translatable="yes">Open</property>
<property name="tooltip-text" translatable="yes">Open a file</property>
<property name="icon-name">document-open</property>
</object>
</child>
<child>
<object class="GtkToolButton">
<object class="GtkButton">
<property name="label" translatable="yes">Save</property>
<property name="tooltip-text" translatable="yes">Save a file</property>
<property name="icon-name">document-save</property>
<property name="is-important">1</property>
</object>
</child>
<child>
<object class="GtkSeparatorToolItem"/>
<object class="GtkSeparator"/>
</child>
<child>
<object class="GtkToolButton">
<object class="GtkButton">
<property name="label" translatable="yes">Copy</property>
<property name="tooltip-text" translatable="yes">Copy selected object into the clipboard</property>
<property name="icon-name">edit-copy</property>
</object>
</child>
<child>
<object class="GtkToolButton">
<object class="GtkButton">
<property name="label" translatable="yes">Cut</property>
<property name="tooltip-text" translatable="yes">Cut selected object into the clipboard</property>
<property name="icon-name">edit-cut</property>
</object>
</child>
<child>
<object class="GtkToolButton">
<object class="GtkButton">
<property name="label" translatable="yes">Paste</property>
<property name="tooltip-text" translatable="yes">Paste object from the clipboard</property>
<property name="icon-name">edit-paste</property>
@@ -168,7 +167,8 @@
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="shadow-type">in</property>
<property name="expand">1</property>
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<child>
<object class="GtkTreeView" id="treeview1">
<property name="model">liststore1</property>

View File

@@ -105,7 +105,7 @@ do_dialog (GtkWidget *do_widget)
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Dialogs and Message Boxes");
@@ -114,11 +114,17 @@ do_dialog (GtkWidget *do_widget)
G_CALLBACK (gtk_widget_destroyed), &window);
frame = gtk_frame_new ("Dialogs");
g_object_set (frame, "margin", 8, NULL);
gtk_widget_set_margin_start (frame, 8);
gtk_widget_set_margin_end (frame, 8);
gtk_widget_set_margin_top (frame, 8);
gtk_widget_set_margin_bottom (frame, 8);
gtk_container_add (GTK_CONTAINER (window), frame);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
g_object_set (vbox, "margin", 8, NULL);
gtk_widget_set_margin_start (vbox, 8);
gtk_widget_set_margin_end (vbox, 8);
gtk_widget_set_margin_top (vbox, 8);
gtk_widget_set_margin_bottom (vbox, 8);
gtk_container_add (GTK_CONTAINER (frame), vbox);
/* Standard message dialog */

View File

@@ -42,7 +42,7 @@ free_demo_widget (gpointer data)
}
#define GTK_TYPE_DEMO_WIDGET (gtk_demo_widget_get_type ())
static GType gtk_demo_widget_get_type (void);
G_DEFINE_BOXED_TYPE (GtkDemoWidget, gtk_demo_widget, copy_demo_widget, free_demo_widget)
static GtkDemoWidget *
@@ -59,7 +59,7 @@ serialize_widget (GtkWidget *widget)
}
else if (GTK_IS_SPINNER (widget))
{
g_object_get (widget, "active", &demo->active, NULL);
g_object_get (widget, "spinning", &demo->active, NULL);
}
else
{
@@ -80,8 +80,8 @@ deserialize_widget (GtkDemoWidget *demo)
}
else if (demo->type == GTK_TYPE_SPINNER)
{
widget = g_object_new (demo->type, "active", demo->active, NULL);
gtk_style_context_add_class (gtk_widget_get_style_context (widget), "demo");
widget = g_object_new (demo->type, "spinning", demo->active, NULL);
gtk_widget_add_css_class (widget, "demo");
}
else
{
@@ -114,7 +114,7 @@ new_spinner_cb (GtkWidget *button,
GtkWidget *widget;
widget = gtk_spinner_new ();
gtk_style_context_add_class (gtk_widget_get_style_context (widget), "demo");
gtk_widget_add_css_class (widget, "demo");
gtk_spinner_start (GTK_SPINNER (widget));
gtk_fixed_put (fixed, widget, pos_x, pos_y);
@@ -240,8 +240,8 @@ edit_cb (GtkWidget *button, GtkWidget *child)
{
gboolean active;
g_object_get (child, "active", &active, NULL);
g_object_set (child, "active", !active, NULL);
g_object_get (child, "spinning", &active, NULL);
g_object_set (child, "spinning", !active, NULL);
}
if (button)
@@ -271,7 +271,8 @@ pressed_cb (GtkGesture *gesture,
pos_x = x;
pos_y = y;
menu = gtk_popover_new (widget);
menu = gtk_popover_new ();
gtk_widget_set_parent (menu, widget);
gtk_popover_set_has_arrow (GTK_POPOVER (menu), FALSE);
gtk_popover_set_pointing_to (GTK_POPOVER (menu), &(GdkRectangle){ x, y, 1, 1});
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
@@ -356,7 +357,7 @@ do_dnd (GtkWidget *do_widget)
GtkGesture *multipress;
GtkCssProvider *provider;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Drag-and-drop");

View File

@@ -189,7 +189,7 @@ do_drawingarea (GtkWidget *do_widget)
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Drawing Area");
@@ -198,7 +198,10 @@ do_drawingarea (GtkWidget *do_widget)
G_CALLBACK (close_window), NULL);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
g_object_set (vbox, "margin", 16, NULL);
gtk_widget_set_margin_start (vbox, 16);
gtk_widget_set_margin_end (vbox, 16);
gtk_widget_set_margin_top (vbox, 16);
gtk_widget_set_margin_bottom (vbox, 16);
gtk_container_add (GTK_CONTAINER (window), vbox);
/*

View File

@@ -275,6 +275,9 @@ cell_edited (GtkCellRendererText *cell,
g_array_index (articles, Item, i).product, -1);
}
break;
default:
g_assert_not_reached ();
}
gtk_tree_path_free (path);
@@ -345,7 +348,7 @@ do_editable_cells (GtkWidget *do_widget)
GtkTreeModel *items_model;
GtkTreeModel *numbers_model;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Editable Cells");
@@ -353,7 +356,10 @@ do_editable_cells (GtkWidget *do_widget)
G_CALLBACK (gtk_widget_destroyed), &window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
g_object_set (vbox, "margin", 5, NULL);
gtk_widget_set_margin_start (vbox, 5);
gtk_widget_set_margin_end (vbox, 5);
gtk_widget_set_margin_top (vbox, 5);
gtk_widget_set_margin_bottom (vbox, 5);
gtk_container_add (GTK_CONTAINER (window), vbox);
gtk_container_add (GTK_CONTAINER (vbox),

View File

@@ -9,7 +9,7 @@
#include <gtk/gtk.h>
/* Creates a tree model containing the completions */
GtkTreeModel *
static GtkTreeModel *
create_completion_model (void)
{
GtkListStore *store;
@@ -45,7 +45,7 @@ do_entry_completion (GtkWidget *do_widget)
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Entry Completion");
@@ -55,7 +55,10 @@ do_entry_completion (GtkWidget *do_widget)
G_CALLBACK (gtk_widget_destroyed), &window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
g_object_set (vbox, "margin", 5, NULL);
gtk_widget_set_margin_start (vbox, 5);
gtk_widget_set_margin_end (vbox, 5);
gtk_widget_set_margin_top (vbox, 5);
gtk_widget_set_margin_bottom (vbox, 5);
gtk_container_add (GTK_CONTAINER (window), vbox);
label = gtk_label_new (NULL);

View File

@@ -20,7 +20,7 @@ do_entry_undo (GtkWidget *do_widget)
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Entry Undo");
@@ -29,7 +29,10 @@ do_entry_undo (GtkWidget *do_widget)
G_CALLBACK (gtk_widget_destroyed), &window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
g_object_set (vbox, "margin", 5, NULL);
gtk_widget_set_margin_start (vbox, 5);
gtk_widget_set_margin_end (vbox, 5);
gtk_widget_set_margin_top (vbox, 5);
gtk_widget_set_margin_bottom (vbox, 5);
gtk_container_add (GTK_CONTAINER (window), vbox);
label = gtk_label_new (NULL);

View File

@@ -31,7 +31,10 @@
<property name="title" translatable="yes">Filter Model</property>
<child>
<object class="GtkGrid" id="grid1">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="row-spacing">10</property>
<property name="column-spacing">10</property>
<property name="column-homogeneous">1</property>
@@ -53,7 +56,6 @@
</child>
<child>
<object class="GtkTreeView" id="treeview1">
<property name="can-focus">1</property>
<property name="model">liststore1</property>
<property name="headers-clickable">0</property>
<child internal-child="selection">
@@ -92,7 +94,6 @@
</child>
<child>
<object class="GtkTreeView" id="treeview2">
<property name="can-focus">1</property>
<property name="headers-clickable">0</property>
<property name="search-column">0</property>
<child internal-child="selection">
@@ -175,7 +176,6 @@
</child>
<child>
<object class="GtkTreeView" id="treeview3">
<property name="can-focus">1</property>
<property name="headers-clickable">0</property>
<property name="search-column">0</property>
<child internal-child="selection">

View File

@@ -22,29 +22,11 @@ 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);
icon_names = gtk_icon_theme_get_icon_names (theme);
n_icon_names = g_strv_length (icon_names);
}
static const char *
@@ -55,13 +37,16 @@ get_random_icon_name (GtkIconTheme *theme)
return icon_names[g_random_int_range(0, n_icon_names)];
}
/* Can't be static because it's also used in iconscroll.c */
GtkWidget *
create_icon (void)
{
GtkWidget *image;
image = gtk_image_new_from_icon_name (get_random_icon_name (gtk_icon_theme_get_default ()));
image = gtk_image_new ();
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
gtk_image_set_from_icon_name (GTK_IMAGE (image),
get_random_icon_name (gtk_icon_theme_get_for_display (gtk_widget_get_display (image))));
return image;
}
@@ -77,7 +62,7 @@ create_blurred_button (void)
{
GtkWidget *w = gtk_button_new ();
gtk_style_context_add_class (gtk_widget_get_style_context (w), "blurred-button");
gtk_widget_add_css_class (w, "blurred-button");
return w;
}
@@ -174,7 +159,7 @@ static GtkWidget *
create_menu_button (void)
{
GtkWidget *w = gtk_menu_button_new ();
GtkWidget *popover = gtk_popover_new (NULL);
GtkWidget *popover = gtk_popover_new ();
gtk_container_add (GTK_CONTAINER (popover), gtk_button_new_with_label ("Hey!"));
gtk_popover_set_autohide (GTK_POPOVER (popover), FALSE);

View File

@@ -52,7 +52,7 @@ create_faces (void)
/* Add a face */
faces[i].face = gtk_frame_new (NULL);
gtk_widget_set_size_request (faces[i].face, face_size, face_size);
gtk_style_context_add_class (gtk_widget_get_style_context (faces[i].face), faces[i].css_class);
gtk_widget_add_css_class (faces[i].face, faces[i].css_class);
gtk_container_add (GTK_CONTAINER (fixed), faces[i].face);
/* Set up the transformation for each face */
@@ -124,7 +124,7 @@ create_demo_window (GtkWidget *do_widget)
{
GtkWidget *window, *sw, *fixed, *cube;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Fixed layout");
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);

View File

@@ -719,7 +719,7 @@ do_flowbox (GtkWidget *do_widget)
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Flow Box");

View File

@@ -10,7 +10,6 @@
<property name="title">Font Explorer</property>
<child>
<object class="GtkButton" id="reset">
<property name="can-focus">1</property>
<property name="receives-default">1</property>
<property name="tooltip-text">Reset</property>
<signal name="clicked" handler="font_features_reset_features" swapped="no"/>
@@ -27,18 +26,19 @@
<object class="GtkBox">
<child>
<object class="GtkScrolledWindow">
<property name="can-focus">1</property>
<property name="hscrollbar-policy">never</property>
<child>
<object class="GtkViewport">
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkFontButton" id="font">
<property name="can-focus">1</property>
<property name="receives-default">1</property>
<property name="font">Sans 12</property>
<property name="level">family|style|size|variations|features</property>
@@ -61,7 +61,6 @@
<property name="orientation">vertical</property>
<child>
<object class="GtkComboBox" id="script_lang">
<property name="can-focus">1</property>
<property name="margin-top">10</property>
<signal name="changed" handler="font_features_script_changed" swapped="no"/>
<child>
@@ -109,7 +108,10 @@
<property name="orientation">vertical</property>
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<property name="margin">20</property>
<property name="margin-start">20</property>
<property name="margin-end">20</property>
<property name="margin-top">20</property>
<property name="margin-bottom">20</property>
<property name="spacing">20</property>
<child>
<object class="GtkStack" id="stack">

View File

@@ -25,14 +25,14 @@
#define MAKE_TAG(a,b,c,d) (unsigned int)(((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
static GtkWidget *label;
static GtkWidget *the_label;
static GtkWidget *settings;
static GtkWidget *description;
static GtkWidget *font;
static GtkWidget *script_lang;
static GtkWidget *resetbutton;
static GtkWidget *stack;
static GtkWidget *entry;
static GtkWidget *the_entry;
static GtkWidget *variations_heading;
static GtkWidget *variations_grid;
static GtkWidget *instance_combo;
@@ -301,9 +301,9 @@ update_display (void)
char *font_desc;
char *features;
text = gtk_editable_get_text (GTK_EDITABLE (entry));
text = gtk_editable_get_text (GTK_EDITABLE (the_entry));
if (gtk_label_get_selection_bounds (GTK_LABEL (label), &ins, &bound))
if (gtk_label_get_selection_bounds (GTK_LABEL (the_label), &ins, &bound))
{
start = g_utf8_offset_to_pointer (text, ins) - text;
end = g_utf8_offset_to_pointer (text, bound) - text;
@@ -409,8 +409,8 @@ update_display (void)
gtk_label_set_text (GTK_LABEL (description), font_desc);
gtk_label_set_text (GTK_LABEL (settings), features);
gtk_label_set_text (GTK_LABEL (label), text);
gtk_label_set_attributes (GTK_LABEL (label), attrs);
gtk_label_set_text (GTK_LABEL (the_label), text);
gtk_label_set_attributes (GTK_LABEL (the_label), attrs);
g_free (font_desc);
pango_font_description_free (desc);
@@ -548,7 +548,7 @@ update_script_combo (void)
{
const char *langname;
char langbuf[5];
GtkTreeIter iter;
GtkTreeIter tree_iter;
if (pair->lang_tag == HB_OT_TAG_DEFAULT_LANGUAGE)
langname = NC_("Language", "Default");
@@ -563,7 +563,7 @@ update_script_combo (void)
}
}
gtk_list_store_insert_with_values (store, &iter, -1,
gtk_list_store_insert_with_values (store, &tree_iter, -1,
0, langname,
1, pair->script_index,
2, pair->lang_index,
@@ -572,7 +572,7 @@ update_script_combo (void)
if (pair->lang_tag == active)
{
have_active = TRUE;
active_iter = iter;
active_iter = tree_iter;
}
}
@@ -751,7 +751,7 @@ add_font_variations (GString *s)
GHashTableIter iter;
Axis *axis;
char buf[G_ASCII_DTOSTR_BUF_SIZE];
char *sep = "";
const char *sep = "";
g_hash_table_iter_init (&iter, axes);
while (g_hash_table_iter_next (&iter, (gpointer *)NULL, (gpointer *)&axis))
@@ -1129,7 +1129,7 @@ font_features_reset_features (void)
{
GList *l;
gtk_label_select_region (GTK_LABEL (label), 0, 0);
gtk_label_select_region (GTK_LABEL (the_label), 0, 0);
g_list_free_full (ranges, free_range);
ranges = NULL;
@@ -1156,9 +1156,9 @@ static char *text;
static void
switch_to_entry (void)
{
text = g_strdup (gtk_editable_get_text (GTK_EDITABLE (entry)));
text = g_strdup (gtk_editable_get_text (GTK_EDITABLE (the_entry)));
gtk_stack_set_visible_child_name (GTK_STACK (stack), "entry");
gtk_widget_grab_focus (entry);
gtk_widget_grab_focus (the_entry);
}
static void
@@ -1217,20 +1217,20 @@ do_font_features (GtkWidget *do_widget)
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
feature_list = GTK_WIDGET (gtk_builder_get_object (builder, "feature_list"));
label = GTK_WIDGET (gtk_builder_get_object (builder, "label"));
the_label = GTK_WIDGET (gtk_builder_get_object (builder, "label"));
settings = GTK_WIDGET (gtk_builder_get_object (builder, "settings"));
description = GTK_WIDGET (gtk_builder_get_object (builder, "description"));
resetbutton = GTK_WIDGET (gtk_builder_get_object (builder, "reset"));
font = GTK_WIDGET (gtk_builder_get_object (builder, "font"));
script_lang = GTK_WIDGET (gtk_builder_get_object (builder, "script_lang"));
stack = GTK_WIDGET (gtk_builder_get_object (builder, "stack"));
entry = GTK_WIDGET (gtk_builder_get_object (builder, "entry"));
the_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", g_object_ref (controller), g_object_unref);
g_signal_connect (controller, "key-pressed", G_CALLBACK (entry_key_press), entry);
gtk_widget_add_controller (entry, controller);
g_object_set_data_full (G_OBJECT (the_entry), "controller", g_object_ref (controller), g_object_unref);
g_signal_connect (controller, "key-pressed", G_CALLBACK (entry_key_press), the_entry);
gtk_widget_add_controller (the_entry, controller);
add_check_group (feature_list, _("Kerning"), (const char *[]){ "kern", NULL });
add_check_group (feature_list, _("Ligatures"), (const char *[]){ "liga",

View File

@@ -140,17 +140,6 @@ update_value (GtkFontPlane *plane,
gtk_widget_queue_draw (widget);
}
static void
hold_action (GtkGestureLongPress *gesture,
gdouble x,
gdouble y,
GtkFontPlane *plane)
{
gboolean handled;
g_signal_emit_by_name (plane, "popup-menu", &handled);
}
static void
plane_drag_gesture_begin (GtkGestureDrag *gesture,
gdouble start_x,
@@ -161,13 +150,6 @@ plane_drag_gesture_begin (GtkGestureDrag *gesture,
button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
if (button == GDK_BUTTON_SECONDARY)
{
gboolean handled;
g_signal_emit_by_name (plane, "popup-menu", &handled);
}
if (button != GDK_BUTTON_PRIMARY)
{
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_DENIED);
@@ -207,8 +189,6 @@ gtk_font_plane_init (GtkFontPlane *plane)
{
GtkGesture *gesture;
gtk_widget_set_can_focus (GTK_WIDGET (plane), TRUE);
gesture = gtk_gesture_drag_new ();
g_signal_connect (gesture, "drag-begin",
G_CALLBACK (plane_drag_gesture_begin), plane);
@@ -218,13 +198,6 @@ gtk_font_plane_init (GtkFontPlane *plane)
G_CALLBACK (plane_drag_gesture_end), plane);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0);
gtk_widget_add_controller (GTK_WIDGET (plane), GTK_EVENT_CONTROLLER (gesture));
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 (gesture),
TRUE);
gtk_widget_add_controller (GTK_WIDGET (plane), GTK_EVENT_CONTROLLER (gesture));
}
static void

View File

@@ -43,7 +43,6 @@ update_image (void)
cairo_font_options_t *fopt;
cairo_hint_style_t hintstyle;
cairo_hint_metrics_t hintmetrics;
int i;
if (!context)
context = gtk_widget_create_pango_context (image);
@@ -116,6 +115,7 @@ update_image (void)
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (show_grid)))
{
int i;
cairo_set_source_rgba (cr, 0.2, 0, 0, 0.2);
for (i = 1; i < ink.height + 20; i++)
{

View File

@@ -1,984 +0,0 @@
/* Foreign drawing
*
* Many applications can't use GTK widgets, for a variety of reasons,
* but still want their user interface to appear integrated with the
* rest of the desktop, and follow GTK themes. This demo shows how to
* use GtkStyleContext and the gtk_render_ APIs to achieve this.
*
* Note that this is a very simple, non-interactive example.
*/
#include <gtk/gtk.h>
#include <string.h>
static void
append_element (GtkWidgetPath *path,
const char *selector)
{
static const struct {
const char *name;
GtkStateFlags state_flag;
} pseudo_classes[] = {
{ "active", GTK_STATE_FLAG_ACTIVE },
{ "hover", GTK_STATE_FLAG_PRELIGHT },
{ "selected", GTK_STATE_FLAG_SELECTED },
{ "disabled", GTK_STATE_FLAG_INSENSITIVE },
{ "indeterminate", GTK_STATE_FLAG_INCONSISTENT },
{ "focus", GTK_STATE_FLAG_FOCUSED },
{ "backdrop", GTK_STATE_FLAG_BACKDROP },
{ "dir(ltr)", GTK_STATE_FLAG_DIR_LTR },
{ "dir(rtl)", GTK_STATE_FLAG_DIR_RTL },
{ "link", GTK_STATE_FLAG_LINK },
{ "visited", GTK_STATE_FLAG_VISITED },
{ "checked", GTK_STATE_FLAG_CHECKED },
{ "drop(active)", GTK_STATE_FLAG_DROP_ACTIVE }
};
const char *next;
char *name;
char type;
guint i;
next = strpbrk (selector, "#.:");
if (next == NULL)
next = selector + strlen (selector);
name = g_strndup (selector, next - selector);
if (g_ascii_isupper (selector[0]))
{
GType gtype;
gtype = g_type_from_name (name);
if (gtype == G_TYPE_INVALID)
{
g_critical ("Unknown type name `%s'", name);
g_free (name);
return;
}
gtk_widget_path_append_type (path, gtype);
}
else
{
/* Omit type, we're using name */
gtk_widget_path_append_type (path, G_TYPE_NONE);
gtk_widget_path_iter_set_object_name (path, -1, name);
}
g_free (name);
while (*next != '\0')
{
type = *next;
selector = next + 1;
next = strpbrk (selector, "#.:");
if (next == NULL)
next = selector + strlen (selector);
name = g_strndup (selector, next - selector);
switch (type)
{
case '#':
gtk_widget_path_iter_set_name (path, -1, name);
break;
case '.':
gtk_widget_path_iter_add_class (path, -1, name);
break;
case ':':
for (i = 0; i < G_N_ELEMENTS (pseudo_classes); i++)
{
if (g_str_equal (pseudo_classes[i].name, name))
{
gtk_widget_path_iter_set_state (path,
-1,
gtk_widget_path_iter_get_state (path, -1)
| pseudo_classes[i].state_flag);
break;
}
}
if (i == G_N_ELEMENTS (pseudo_classes))
g_critical ("Unknown pseudo-class :%s", name);
break;
default:
g_assert_not_reached ();
break;
}
g_free (name);
}
}
static GtkStyleContext *
create_context_for_path (GtkWidgetPath *path,
GtkStyleContext *parent)
{
GtkStyleContext *context;
context = gtk_style_context_new ();
gtk_style_context_set_path (context, path);
gtk_style_context_set_parent (context, parent);
/* Unfortunately, we have to explicitly set the state again here
* for it to take effect
*/
gtk_style_context_set_state (context, gtk_widget_path_iter_get_state (path, -1));
gtk_widget_path_unref (path);
return context;
}
static GtkStyleContext *
get_style (GtkStyleContext *parent,
const char *selector)
{
GtkWidgetPath *path;
if (parent)
path = gtk_widget_path_copy (gtk_style_context_get_path (parent));
else
path = gtk_widget_path_new ();
append_element (path, selector);
return create_context_for_path (path, parent);
}
static GtkStyleContext *
get_style_with_siblings (GtkStyleContext *parent,
const char *selector,
const char **siblings,
gint position)
{
GtkWidgetPath *path, *siblings_path;
guint i;
if (parent)
path = gtk_widget_path_copy (gtk_style_context_get_path (parent));
else
path = gtk_widget_path_new ();
siblings_path = gtk_widget_path_new ();
for (i = 0; siblings[i]; i++)
append_element (siblings_path, siblings[i]);
gtk_widget_path_append_with_siblings (path, siblings_path, position);
gtk_widget_path_unref (siblings_path);
return create_context_for_path (path, parent);
}
static void
draw_style_common (GtkStyleContext *context,
cairo_t *cr,
gint x,
gint y,
gint width,
gint height,
gint *contents_x,
gint *contents_y,
gint *contents_width,
gint *contents_height)
{
GtkBorder margin, border, padding;
int min_width, min_height;
gtk_style_context_get_margin (context, &margin);
gtk_style_context_get_border (context, &border);
gtk_style_context_get_padding (context, &padding);
gtk_style_context_get (context,
"min-width", &min_width,
"min-height", &min_height,
NULL);
x += margin.left;
y += margin.top;
width -= margin.left + margin.right;
height -= margin.top + margin.bottom;
width = MAX (width, min_width);
height = MAX (height, min_height);
gtk_render_background (context, cr, x, y, width, height);
gtk_render_frame (context, cr, x, y, width, height);
if (contents_x)
*contents_x = x + border.left + padding.left;
if (contents_y)
*contents_y = y + border.top + padding.top;
if (contents_width)
*contents_width = width - border.left - border.right - padding.left - padding.right;
if (contents_height)
*contents_height = height - border.top - border.bottom - padding.top - padding.bottom;
}
static void
query_size (GtkStyleContext *context,
gint *width,
gint *height)
{
GtkBorder margin, border, padding;
int min_width, min_height;
gtk_style_context_get_margin (context, &margin);
gtk_style_context_get_border (context, &border);
gtk_style_context_get_padding (context, &padding);
gtk_style_context_get (context,
"min-width", &min_width,
"min-height", &min_height,
NULL);
min_width += margin.left + margin.right + border.left + border.right + padding.left + padding.right;
min_height += margin.top + margin.bottom + border.top + border.bottom + padding.top + padding.bottom;
if (width)
*width = MAX (*width, min_width);
if (height)
*height = MAX (*height, min_height);
}
static void
draw_menu (GtkWidget *widget,
cairo_t *cr,
gint x,
gint y,
gint width,
gint *height)
{
GtkStyleContext *menu_context;
GtkStyleContext *menuitem_context;
GtkStyleContext *hovermenuitem_context;
GtkStyleContext *hoveredarrowmenuitem_context;
GtkStyleContext *arrowmenuitem_context;
GtkStyleContext *checkmenuitem_context;
GtkStyleContext *disabledarrowmenuitem_context;
GtkStyleContext *disabledcheckmenuitem_context;
GtkStyleContext *radiomenuitem_context;
GtkStyleContext *disablemenuitem_context;
GtkStyleContext *disabledradiomenuitem_context;
GtkStyleContext *separatormenuitem_context;
gint menuitem1_height, menuitem2_height, menuitem3_height, menuitem4_height, menuitem5_height;
gint contents_x, contents_y, contents_width, contents_height;
gint menu_x, menu_y, menu_width, menu_height;
gint arrow_width, arrow_height, arrow_size;
gint toggle_x, toggle_y, toggle_width, toggle_height;
/* This information is taken from the GtkMenu docs, see "CSS nodes" */
menu_context = get_style (NULL, "menu");
hovermenuitem_context = get_style (menu_context, "menuitem:hover");
hoveredarrowmenuitem_context = get_style (hovermenuitem_context, "arrow.right:dir(ltr)");
menuitem_context = get_style (menu_context, "menuitem");
arrowmenuitem_context = get_style (menuitem_context, "arrow:dir(rtl)");
disablemenuitem_context = get_style (menu_context, "menuitem:disabled");
disabledarrowmenuitem_context = get_style (disablemenuitem_context, "arrow:dir(rtl)");
checkmenuitem_context = get_style (menuitem_context, "check:checked");
disabledcheckmenuitem_context = get_style (disablemenuitem_context, "check");
separatormenuitem_context = get_style (menu_context, "separator:disabled");
radiomenuitem_context = get_style (menuitem_context, "radio:checked");
disabledradiomenuitem_context = get_style (disablemenuitem_context, "radio");
*height = 0;
query_size (menu_context, NULL, height);
menuitem1_height = 0;
query_size (hovermenuitem_context, NULL, &menuitem1_height);
query_size (hoveredarrowmenuitem_context, NULL, &menuitem1_height);
*height += menuitem1_height;
menuitem2_height = 0;
query_size (menu_context, NULL, &menuitem5_height);
query_size (menuitem_context, NULL, &menuitem2_height);
query_size (arrowmenuitem_context, NULL, &menuitem2_height);
query_size (disabledarrowmenuitem_context, NULL, &menuitem2_height);
*height += menuitem2_height;
menuitem3_height = 0;
query_size (menu_context, NULL, &menuitem5_height);
query_size (menuitem_context, NULL, &menuitem3_height);
query_size (checkmenuitem_context, NULL, &menuitem3_height);
query_size (disabledcheckmenuitem_context, NULL, &menuitem3_height);
*height += menuitem3_height;
menuitem4_height = 0;
query_size (menu_context, NULL, &menuitem5_height);
query_size (separatormenuitem_context, NULL, &menuitem4_height);
*height += menuitem4_height;
menuitem5_height = 0;
query_size (menu_context, NULL, &menuitem5_height);
query_size (menuitem_context, NULL, &menuitem5_height);
query_size (radiomenuitem_context, NULL, &menuitem5_height);
query_size (disabledradiomenuitem_context, NULL, &menuitem5_height);
*height += menuitem5_height;
draw_style_common (menu_context, cr, x, y, width, *height,
&menu_x, &menu_y, &menu_width, &menu_height);
/* Hovered with right arrow */
gtk_style_context_get (hoveredarrowmenuitem_context,
"min-width", &arrow_width, "min-height", &arrow_height, NULL);
arrow_size = MIN (arrow_width, arrow_height);
draw_style_common (hovermenuitem_context, cr, menu_x, menu_y, menu_width, menuitem1_height,
&contents_x, &contents_y, &contents_width, &contents_height);
gtk_render_arrow (hoveredarrowmenuitem_context, cr, G_PI / 2,
contents_x + contents_width - arrow_size,
contents_y + (contents_height - arrow_size) / 2, arrow_size);
/* Left arrow sensitive, and right arrow insensitive */
draw_style_common (menuitem_context, cr, menu_x, menu_y + menuitem1_height, menu_width, menuitem2_height,
&contents_x, &contents_y, &contents_width, &contents_height);
gtk_style_context_get (arrowmenuitem_context,
"min-width", &arrow_width, "min-height", &arrow_height, NULL);
arrow_size = MIN (arrow_width, arrow_height);
gtk_render_arrow (arrowmenuitem_context, cr, G_PI / 2,
contents_x,
contents_y + (contents_height - arrow_size) / 2, arrow_size);
gtk_style_context_get (disabledarrowmenuitem_context,
"min-width", &arrow_width, "min-height", &arrow_height, NULL);
arrow_size = MIN (arrow_width, arrow_height);
gtk_render_arrow (disabledarrowmenuitem_context, cr, G_PI / 2,
contents_x + contents_width - arrow_size,
contents_y + (contents_height - arrow_size) / 2, arrow_size);
/* Left check enabled, sensitive, and right check unchecked, insensitive */
draw_style_common (menuitem_context, cr, menu_x, menu_y + menuitem1_height + menuitem2_height, menu_width, menuitem3_height,
&contents_x, &contents_y, &contents_width, &contents_height);
gtk_style_context_get (checkmenuitem_context,
"min-width", &toggle_width, "min-height", &toggle_height, NULL);
draw_style_common (checkmenuitem_context, cr,
contents_x,
contents_y,
toggle_width, toggle_height,
&toggle_x, &toggle_y, &toggle_width, &toggle_height);
gtk_render_check (checkmenuitem_context, cr, toggle_x, toggle_y, toggle_width, toggle_height);
gtk_style_context_get (disabledcheckmenuitem_context,
"min-width", &toggle_width, "min-height", &toggle_height, NULL);
draw_style_common (disabledcheckmenuitem_context, cr,
contents_x + contents_width - toggle_width,
contents_y,
toggle_width, toggle_height,
&toggle_x, &toggle_y, &toggle_width, &toggle_height);
gtk_render_check (disabledcheckmenuitem_context, cr, toggle_x, toggle_y, toggle_width, toggle_height);
/* Separator */
draw_style_common (separatormenuitem_context, cr, menu_x, menu_y + menuitem1_height + menuitem2_height + menuitem3_height,
menu_width, menuitem4_height,
NULL, NULL, NULL, NULL);
/* Left check enabled, sensitive, and right check unchecked, insensitive */
draw_style_common (menuitem_context, cr, menu_x, menu_y + menuitem1_height + menuitem2_height + menuitem3_height + menuitem4_height,
menu_width, menuitem5_height,
&contents_x, &contents_y, &contents_width, &contents_height);
gtk_style_context_get (radiomenuitem_context,
"min-width", &toggle_width, "min-height", &toggle_height, NULL);
draw_style_common (radiomenuitem_context, cr,
contents_x,
contents_y,
toggle_width, toggle_height,
&toggle_x, &toggle_y, &toggle_width, &toggle_height);
gtk_render_check (radiomenuitem_context, cr, toggle_x, toggle_y, toggle_width, toggle_height);
gtk_style_context_get (disabledradiomenuitem_context,
"min-width", &toggle_width, "min-height", &toggle_height, NULL);
draw_style_common (disabledradiomenuitem_context, cr,
contents_x + contents_width - toggle_width,
contents_y,
toggle_width, toggle_height,
&toggle_x, &toggle_y, &toggle_width, &toggle_height);
gtk_render_check (disabledradiomenuitem_context, cr, toggle_x, toggle_y, toggle_width, toggle_height);
g_object_unref (menu_context);
g_object_unref (menuitem_context);
g_object_unref (hovermenuitem_context);
g_object_unref (hoveredarrowmenuitem_context);
g_object_unref (arrowmenuitem_context);
g_object_unref (checkmenuitem_context);
g_object_unref (disabledarrowmenuitem_context);
g_object_unref (disabledcheckmenuitem_context);
g_object_unref (radiomenuitem_context);
g_object_unref (disablemenuitem_context);
g_object_unref (disabledradiomenuitem_context);
g_object_unref (separatormenuitem_context);
}
static void
draw_menubar (GtkWidget *widget,
cairo_t *cr,
gint x,
gint y,
gint width,
gint *height)
{
GtkStyleContext *frame_context;
GtkStyleContext *border_context;
GtkStyleContext *menubar_context;
GtkStyleContext *hovered_menuitem_context;
GtkStyleContext *menuitem_context;
gint contents_x, contents_y, contents_width, contents_height;
gint item_width;
/* Menubar background is the same color as our base background, so use a frame */
frame_context = get_style (NULL, "frame");
border_context = get_style (frame_context, "border");
/* This information is taken from the GtkPopoverMenuBar docs, see "CSS nodes" */
menubar_context = get_style (NULL, "menubar");
hovered_menuitem_context = get_style (menubar_context, "menuitem:hover");
menuitem_context = get_style (menubar_context, "menuitem");
*height = 0;
query_size (frame_context, NULL, height);
query_size (border_context, NULL, height);
query_size (menubar_context, NULL, height);
query_size (hovered_menuitem_context, NULL, height);
query_size (menuitem_context, NULL, height);
draw_style_common (frame_context, cr, x, y, width, *height,
NULL, NULL, NULL, NULL);
draw_style_common (border_context, cr, x, y, width, *height,
&contents_x, &contents_y, &contents_width, &contents_height);
draw_style_common (menubar_context, cr, contents_x, contents_y, contents_width, contents_height,
NULL, NULL, NULL, NULL);
item_width = contents_width / 3;
draw_style_common (hovered_menuitem_context, cr, contents_x, contents_y, item_width, contents_height,
NULL, NULL, NULL, NULL);
draw_style_common (menuitem_context, cr, contents_x + item_width * 2, contents_y, item_width, contents_height,
NULL, NULL, NULL, NULL);
g_object_unref (menuitem_context);
g_object_unref (hovered_menuitem_context);
g_object_unref (menubar_context);
g_object_unref (border_context);
g_object_unref (frame_context);
}
static void
draw_notebook (GtkWidget *widget,
cairo_t *cr,
gint x,
gint y,
gint width,
gint height)
{
GtkStyleContext *notebook_context;
GtkStyleContext *header_context;
GtkStyleContext *tabs_context;
GtkStyleContext *tab1_context, *tab2_context;
GtkStyleContext *stack_context;
gint header_height;
gint contents_x, contents_y, contents_width, contents_height;
/* This information is taken from the GtkNotebook docs, see "CSS nodes" */
notebook_context = get_style (NULL, "notebook.frame");
header_context = get_style (notebook_context, "header.top");
tabs_context = get_style (header_context, "tabs");
tab1_context = get_style (tabs_context, "tab:checked");
tab2_context = get_style (tabs_context, "tab:hover");
stack_context = get_style (notebook_context, "stack");
header_height = 0;
query_size (notebook_context, NULL, &header_height);
query_size (header_context, NULL, &header_height);
query_size (tabs_context, NULL, &header_height);
query_size (tab1_context, NULL, &header_height);
query_size (tab2_context, NULL, &header_height);
draw_style_common (notebook_context, cr, x, y, width, height, NULL, NULL, NULL, NULL);
draw_style_common (header_context, cr, x, y, width, header_height, NULL, NULL, NULL, NULL);
draw_style_common (tabs_context, cr, x, y, width, header_height, NULL, NULL, NULL, NULL);
draw_style_common (tab1_context, cr, x, y, width / 2, header_height,
&contents_x, &contents_y, &contents_width, &contents_height);
draw_style_common (tab2_context, cr, x + width / 2, y, width / 2, header_height,
NULL, NULL, NULL, NULL);
draw_style_common (stack_context, cr, x, y + header_height, width,height - header_height,
NULL, NULL, NULL, NULL);
g_object_unref (stack_context);
g_object_unref (tabs_context);
g_object_unref (tab1_context);
g_object_unref (tab2_context);
g_object_unref (header_context);
g_object_unref (notebook_context);
}
static void
draw_horizontal_scrollbar (GtkWidget *widget,
cairo_t *cr,
gint x,
gint y,
gint width,
gint position,
GtkStateFlags state,
gint *height)
{
GtkStyleContext *scrollbar_context;
GtkStyleContext *contents_context;
GtkStyleContext *trough_context;
GtkStyleContext *slider_context;
gint slider_width;
/* This information is taken from the GtkScrollbar docs, see "CSS nodes" */
scrollbar_context = get_style (NULL, "scrollbar.horizontal.bottom");
contents_context = get_style (scrollbar_context, "contents");
trough_context = get_style (contents_context, "trough");
slider_context = get_style (trough_context, "slider");
gtk_style_context_set_state (scrollbar_context, state);
gtk_style_context_set_state (contents_context, state);
gtk_style_context_set_state (trough_context, state);
gtk_style_context_set_state (slider_context, state);
*height = 0;
query_size (scrollbar_context, NULL, height);
query_size (contents_context, NULL, height);
query_size (trough_context, NULL, height);
query_size (slider_context, NULL, height);
gtk_style_context_get (slider_context,
"min-width", &slider_width, NULL);
draw_style_common (scrollbar_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
draw_style_common (contents_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
draw_style_common (trough_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
draw_style_common (slider_context, cr, x + position, y, slider_width, *height, NULL, NULL, NULL, NULL);
g_object_unref (slider_context);
g_object_unref (trough_context);
g_object_unref (contents_context);
g_object_unref (scrollbar_context);
}
static void
draw_text (GtkWidget *widget,
cairo_t *cr,
gint x,
gint y,
gint width,
gint height,
const gchar *text,
GtkStateFlags state)
{
GtkStyleContext *label_context;
GtkStyleContext *selection_context;
GtkStyleContext *context;
PangoLayout *layout;
/* This information is taken from the GtkLabel docs, see "CSS nodes" */
label_context = get_style (NULL, "label.view");
selection_context = get_style (label_context, "selection");
gtk_style_context_set_state (label_context, state);
if (state & GTK_STATE_FLAG_SELECTED)
context = selection_context;
else
context = label_context;
layout = gtk_widget_create_pango_layout (widget, text);
gtk_render_background (context, cr, x, y, width, height);
gtk_render_frame (context, cr, x, y, width, height);
gtk_render_layout (context, cr, x, y, layout);
g_object_unref (layout);
g_object_unref (selection_context);
g_object_unref (label_context);
}
static void
draw_check (GtkWidget *widget,
cairo_t *cr,
gint x,
gint y,
GtkStateFlags state,
gint *width,
gint *height)
{
GtkStyleContext *button_context;
GtkStyleContext *check_context;
gint contents_x, contents_y, contents_width, contents_height;
/* This information is taken from the GtkCheckButton docs, see "CSS nodes" */
button_context = get_style (NULL, "checkbutton");
check_context = get_style (button_context, "check");
gtk_style_context_set_state (check_context, state);
*width = *height = 0;
query_size (button_context, width, height);
query_size (check_context, width, height);
draw_style_common (button_context, cr, x, y, *width, *height, NULL, NULL, NULL, NULL);
draw_style_common (check_context, cr, x, y, *width, *height,
&contents_x, &contents_y, &contents_width, &contents_height);
gtk_render_check (check_context, cr, contents_x, contents_y, contents_width, contents_height);
g_object_unref (check_context);
g_object_unref (button_context);
}
static void
draw_radio (GtkWidget *widget,
cairo_t *cr,
gint x,
gint y,
GtkStateFlags state,
gint *width,
gint *height)
{
GtkStyleContext *button_context;
GtkStyleContext *check_context;
gint contents_x, contents_y, contents_width, contents_height;
/* This information is taken from the GtkRadioButton docs, see "CSS nodes" */
button_context = get_style (NULL, "radiobutton");
check_context = get_style (button_context, "radio");
gtk_style_context_set_state (check_context, state);
*width = *height = 0;
query_size (button_context, width, height);
query_size (check_context, width, height);
draw_style_common (button_context, cr, x, y, *width, *height, NULL, NULL, NULL, NULL);
draw_style_common (check_context, cr, x, y, *width, *height,
&contents_x, &contents_y, &contents_width, &contents_height);
gtk_render_check (check_context, cr, contents_x, contents_y, contents_width, contents_height);
g_object_unref (check_context);
g_object_unref (button_context);
}
static void
draw_progress (GtkWidget *widget,
cairo_t *cr,
gint x,
gint y,
gint width,
gint position,
gint *height)
{
GtkStyleContext *bar_context;
GtkStyleContext *trough_context;
GtkStyleContext *progress_context;
/* This information is taken from the GtkProgressBar docs, see "CSS nodes" */
bar_context = get_style (NULL, "progressbar.horizontal");
trough_context = get_style (bar_context, "trough");
progress_context = get_style (trough_context, "progress.left");
*height = 0;
query_size (bar_context, NULL, height);
query_size (trough_context, NULL, height);
query_size (progress_context, NULL, height);
draw_style_common (bar_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
draw_style_common (trough_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
draw_style_common (progress_context, cr, x, y, position, *height, NULL, NULL, NULL, NULL);
g_object_unref (progress_context);
g_object_unref (trough_context);
g_object_unref (bar_context);
}
static void
draw_scale (GtkWidget *widget,
cairo_t *cr,
gint x,
gint y,
gint width,
gint position,
gint *height)
{
GtkStyleContext *scale_context;
GtkStyleContext *contents_context;
GtkStyleContext *trough_context;
GtkStyleContext *slider_context;
GtkStyleContext *highlight_context;
gint contents_x, contents_y, contents_width, contents_height;
gint trough_height, slider_height;
scale_context = get_style (NULL, "scale.horizontal");
contents_context = get_style (scale_context, "contents");
trough_context = get_style (contents_context, "trough");
slider_context = get_style (trough_context, "slider");
highlight_context = get_style (trough_context, "highlight.top");
*height = 0;
query_size (scale_context, NULL, height);
query_size (contents_context, NULL, height);
query_size (trough_context, NULL, height);
query_size (slider_context, NULL, height);
query_size (highlight_context, NULL, height);
draw_style_common (scale_context, cr, x, y, width, *height,
&contents_x, &contents_y, &contents_width, &contents_height);
draw_style_common (contents_context, cr, contents_x, contents_y, contents_width, contents_height,
&contents_x, &contents_y, &contents_width, &contents_height);
/* Scale trough defines its size querying slider and highlight */
trough_height = 0;
query_size (trough_context, NULL, &trough_height);
slider_height = 0;
query_size (slider_context, NULL, &slider_height);
query_size (highlight_context, NULL, &slider_height);
trough_height += slider_height;
draw_style_common (trough_context, cr, contents_x, contents_y, contents_width, trough_height,
&contents_x, &contents_y, &contents_width, &contents_height);
draw_style_common (highlight_context, cr, contents_x, contents_y,
contents_width / 2, contents_height,
NULL, NULL, NULL, NULL);
draw_style_common (slider_context, cr, contents_x + position, contents_y, contents_height, contents_height,
NULL, NULL, NULL, NULL);
g_object_unref (scale_context);
g_object_unref (contents_context);
g_object_unref (trough_context);
g_object_unref (slider_context);
g_object_unref (highlight_context);
}
static void
draw_combobox (GtkWidget *widget,
cairo_t *cr,
gint x,
gint y,
gint width,
gboolean has_entry,
gint *height)
{
GtkStyleContext *combo_context;
GtkStyleContext *box_context;
GtkStyleContext *button_context;
GtkStyleContext *button_box_context;
GtkStyleContext *entry_context;
GtkStyleContext *arrow_context;
gint contents_x, contents_y, contents_width, contents_height;
gint button_width;
gint arrow_width, arrow_height, arrow_size;
/* This information is taken from the GtkComboBox docs, see "CSS nodes" */
combo_context = get_style (NULL, "combobox:focus");
box_context = get_style (combo_context, "box.horizontal.linked");
if (has_entry)
{
const char *siblings[3] = { "entry.combo:focus", "button.combo" , NULL };
entry_context = get_style_with_siblings (box_context, "entry.combo:focus", siblings, 0);
button_context = get_style_with_siblings (box_context, "button.combo", siblings, 1);
}
else
{
const char *siblings[2] = { "button.combo" , NULL };
button_context = get_style_with_siblings (box_context, "button.combo", siblings, 0);
}
button_box_context = get_style (button_context, "box.horizontal");
arrow_context = get_style (button_box_context, "arrow");
*height = 0;
query_size (combo_context, NULL, height);
query_size (box_context, NULL, height);
if (has_entry)
query_size (entry_context, NULL, height);
query_size (button_context, NULL, height);
query_size (button_box_context, NULL, height);
query_size (arrow_context, NULL, height);
gtk_style_context_get (arrow_context,
"min-width", &arrow_width, "min-height", &arrow_height, NULL);
arrow_size = MIN (arrow_width, arrow_height);
draw_style_common (combo_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
draw_style_common (box_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
if (has_entry)
{
button_width = *height;
draw_style_common (entry_context, cr, x, y, width - button_width, *height, NULL, NULL, NULL, NULL);
draw_style_common (button_context, cr, x + width - button_width, y, button_width, *height,
&contents_x, &contents_y, &contents_width, &contents_height);
}
else
{
button_width = width;
draw_style_common (button_context, cr, x, y, width, *height,
&contents_x, &contents_y, &contents_width, &contents_height);
}
draw_style_common (button_box_context, cr, contents_x, contents_y, contents_width, contents_height,
NULL, NULL, NULL, NULL);
draw_style_common (arrow_context, cr, contents_x, contents_y, contents_width, contents_height,
NULL, NULL, NULL, NULL);
gtk_render_arrow (arrow_context, cr, G_PI / 2,
contents_x + contents_width - arrow_size,
contents_y + (contents_height - arrow_size) / 2, arrow_size);
g_object_unref (arrow_context);
if (has_entry)
g_object_unref (entry_context);
g_object_unref (button_context);
g_object_unref (combo_context);
}
static void
draw_spinbutton (GtkWidget *widget,
cairo_t *cr,
gint x,
gint y,
gint width,
gint *height)
{
GtkStyleContext *spin_context;
GtkStyleContext *entry_context;
GtkStyleContext *up_context;
GtkStyleContext *down_context;
GtkIconTheme *icon_theme;
GtkIconInfo *icon_info;
GdkTexture *texture;
gint icon_width, icon_height, icon_size;
gint button_width;
gint contents_x, contents_y, contents_width, contents_height;
/* This information is taken from the GtkSpinButton docs, see "CSS nodes" */
spin_context = get_style (NULL, "spinbutton.horizontal:focus");
entry_context = get_style (spin_context, "entry:focus");
up_context = get_style (spin_context, "button.up:focus:active");
down_context = get_style (spin_context, "button.down:focus");
*height = 0;
query_size (spin_context, NULL, height);
query_size (entry_context, NULL, height);
query_size (up_context, NULL, height);
query_size (down_context, NULL, height);
button_width = *height;
draw_style_common (spin_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
draw_style_common (entry_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL);
icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (widget));
gtk_style_context_get (up_context,
"min-width", &icon_width, "min-height", &icon_height, NULL);
icon_size = MIN (icon_width, icon_height);
icon_info = gtk_icon_theme_lookup_icon (icon_theme, "list-add-symbolic", icon_size, 0);
texture = GDK_TEXTURE (gtk_icon_info_load_symbolic_for_context (icon_info, up_context, NULL, NULL));
g_object_unref (icon_info);
draw_style_common (up_context, cr, x + width - button_width, y, button_width, *height,
&contents_x, &contents_y, &contents_width, &contents_height);
gtk_render_icon (up_context, cr, texture, contents_x, contents_y + (contents_height - icon_size) / 2);
g_object_unref (texture);
gtk_style_context_get (down_context,
"min-width", &icon_width, "min-height", &icon_height, NULL);
icon_size = MIN (icon_width, icon_height);
icon_info = gtk_icon_theme_lookup_icon (icon_theme, "list-remove-symbolic", icon_size, 0);
texture = GDK_TEXTURE (gtk_icon_info_load_symbolic_for_context (icon_info, down_context, NULL, NULL));
g_object_unref (icon_info);
draw_style_common (down_context, cr, x + width - 2 * button_width, y, button_width, *height,
&contents_x, &contents_y, &contents_width, &contents_height);
gtk_render_icon (down_context, cr, texture, contents_x, contents_y + (contents_height - icon_size) / 2);
g_object_unref (texture);
g_object_unref (down_context);
g_object_unref (up_context);
g_object_unref (entry_context);
g_object_unref (spin_context);
}
static void
draw_func (GtkDrawingArea *da,
cairo_t *cr,
int width,
int height,
gpointer data)
{
GtkWidget *widget = GTK_WIDGET (da);
gint panewidth;
gint x, y;
panewidth = width / 2;
cairo_rectangle (cr, 0, 0, width, height);
cairo_set_source_rgb (cr, 0.9, 0.9, 0.9);
cairo_fill (cr);
x = y = 10;
draw_horizontal_scrollbar (widget, cr, x, y, panewidth - 20, 30, GTK_STATE_FLAG_NORMAL, &height);
y += height + 8;
draw_horizontal_scrollbar (widget, cr, x, y, panewidth - 20, 40, GTK_STATE_FLAG_PRELIGHT, &height);
y += height + 8;
draw_horizontal_scrollbar (widget, cr, x, y, panewidth - 20, 50, GTK_STATE_FLAG_ACTIVE|GTK_STATE_FLAG_PRELIGHT, &height);
y += height + 8;
draw_text (widget, cr, x, y, panewidth - 20, 20, "Not selected", GTK_STATE_FLAG_NORMAL);
y += 20 + 10;
draw_text (widget, cr, x, y, panewidth - 20, 20, "Selected", GTK_STATE_FLAG_SELECTED);
x = 10;
y += 20 + 10;
draw_check (widget, cr, x, y, GTK_STATE_FLAG_NORMAL, &width, &height);
x += width + 10;
draw_check (widget, cr, x, y, GTK_STATE_FLAG_CHECKED, &width, &height);
x += width + 10;
draw_radio (widget, cr, x, y, GTK_STATE_FLAG_NORMAL, &width, &height);
x += width + 10;
draw_radio (widget, cr, x, y, GTK_STATE_FLAG_CHECKED, &width, &height);
x = 10;
y += height + 10;
draw_progress (widget, cr, x, y, panewidth - 20, 50, &height);
y += height + 10;
draw_scale (widget, cr, x, y, panewidth - 20, 75, &height);
y += height + 20;
draw_notebook (widget, cr, x, y, panewidth - 20, 160);
/* Second column */
x += panewidth;
y = 10;
draw_menu (widget, cr, x, y, panewidth - 20, &height);
y += height + 10;
draw_menubar (widget, cr, x, y, panewidth - 20, &height);
y += height + 20;
draw_spinbutton (widget, cr, x, y, panewidth - 20, &height);
y += height + 30;
draw_combobox (widget, cr, x, y, panewidth - 20, FALSE, &height);
y += height + 10;
draw_combobox (widget, cr, 10 + panewidth, y, panewidth - 20, TRUE, &height);
}
GtkWidget *
do_foreigndrawing (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
if (!window)
{
GtkWidget *box;
GtkWidget *da;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Foreign drawing");
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &window);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
gtk_container_add (GTK_CONTAINER (window), box);
da = gtk_drawing_area_new ();
gtk_drawing_area_set_content_width (GTK_DRAWING_AREA (da), 400);
gtk_drawing_area_set_content_height (GTK_DRAWING_AREA (da), 400);
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (da), draw_func, NULL, NULL);
gtk_widget_set_hexpand (da, TRUE);
gtk_widget_set_vexpand (da, TRUE);
gtk_container_add (GTK_CONTAINER (box), da);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_widget_destroy (window);
return window;
}

137
demos/gtk-demo/gears.c Normal file
View File

@@ -0,0 +1,137 @@
/* OpenGL/Gears
*
* This is a classic OpenGL demo, running in a GtkGLArea.
*/
#include <stdlib.h>
#include <gtk/gtk.h>
#include "gtkgears.h"
/************************************************************************
* DEMO CODE *
************************************************************************/
static void
on_axis_value_change (GtkAdjustment *adjustment,
gpointer data)
{
GtkGears *gears = GTK_GEARS (data);
int axis = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (adjustment), "axis"));
gtk_gears_set_axis (gears, axis, gtk_adjustment_get_value (adjustment));
}
static GtkWidget *
create_axis_slider (GtkGears *gears,
int axis)
{
GtkWidget *box, *label, *slider;
GtkAdjustment *adj;
const char *text;
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE);
switch (axis)
{
case GTK_GEARS_X_AXIS:
text = "X";
break;
case GTK_GEARS_Y_AXIS:
text = "Y";
break;
case GTK_GEARS_Z_AXIS:
text = "Z";
break;
default:
g_assert_not_reached ();
}
label = gtk_label_new (text);
gtk_container_add (GTK_CONTAINER (box), label);
gtk_widget_show (label);
adj = gtk_adjustment_new (gtk_gears_get_axis (gears, axis), 0.0, 360.0, 1.0, 12.0, 0.0);
g_object_set_data (G_OBJECT (adj), "axis", GINT_TO_POINTER (axis));
g_signal_connect (adj, "value-changed",
G_CALLBACK (on_axis_value_change),
gears);
slider = gtk_scale_new (GTK_ORIENTATION_VERTICAL, adj);
gtk_scale_set_draw_value (GTK_SCALE (slider), FALSE);
gtk_container_add (GTK_CONTAINER (box), slider);
gtk_widget_set_vexpand (slider, TRUE);
gtk_widget_show (slider);
gtk_widget_show (box);
return box;
}
GtkWidget *
do_gears (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
GtkWidget *box, *hbox, *fps_label, *gears, *overlay, *frame;
int i;
if (!window)
{
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Gears");
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
gtk_window_set_default_size (GTK_WINDOW (window), 640, 640);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window);
overlay = gtk_overlay_new ();
gtk_widget_set_margin_start (overlay, 12);
gtk_widget_set_margin_end (overlay, 12);
gtk_widget_set_margin_top (overlay, 12);
gtk_widget_set_margin_bottom (overlay, 12);
gtk_container_add (GTK_CONTAINER (window), overlay);
frame = gtk_frame_new (NULL);
gtk_widget_set_halign (frame, GTK_ALIGN_START);
gtk_widget_set_valign (frame, GTK_ALIGN_START);
gtk_widget_add_css_class (frame, "app-notification");
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), frame);
fps_label = gtk_label_new ("");
gtk_widget_set_halign (fps_label, GTK_ALIGN_START);
gtk_container_add (GTK_CONTAINER (frame), fps_label);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE);
gtk_box_set_spacing (GTK_BOX (box), 6);
gtk_container_add (GTK_CONTAINER (overlay), box);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE);
gtk_box_set_spacing (GTK_BOX (box), 6);
gtk_container_add (GTK_CONTAINER (box), hbox);
gears = gtk_gears_new ();
gtk_widget_set_hexpand (gears, TRUE);
gtk_widget_set_vexpand (gears, TRUE);
gtk_container_add (GTK_CONTAINER (hbox), gears);
for (i = 0; i < GTK_GEARS_N_AXIS; i++)
gtk_container_add (GTK_CONTAINER (hbox), create_axis_slider (GTK_GEARS (gears), i));
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE);
gtk_box_set_spacing (GTK_BOX (hbox), 6);
gtk_container_add (GTK_CONTAINER (box), hbox);
gtk_gears_set_fps_label (GTK_GEARS (gears), GTK_LABEL (fps_label));
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_widget_destroy (window);
return window;
}

View File

@@ -17,9 +17,9 @@ typedef struct _Demo Demo;
struct _Demo
{
gchar *name;
gchar *title;
gchar *filename;
const char *name;
const char *title;
const char *filename;
GDoDemoFunc func;
Demo *children;
};

View File

@@ -146,7 +146,7 @@ do_gestures (GtkWidget *do_widget)
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_default_size (GTK_WINDOW (window), 400, 400);
gtk_window_set_title (GTK_WINDOW (window), "Gestures");
g_signal_connect (window, "destroy",

View File

@@ -1,4 +1,4 @@
/* OpenGL Area
/* OpenGL/OpenGL Area
*
* GtkGLArea is a widget that allows custom drawing using OpenGL calls.
*/
@@ -383,20 +383,23 @@ close_window (GtkWidget *widget)
rotation_angles[Z_AXIS] = 0.0;
}
GtkWidget *
static GtkWidget *
create_glarea_window (GtkWidget *do_widget)
{
GtkWidget *window, *box, *button, *controls;
int i;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "OpenGL Area");
gtk_window_set_default_size (GTK_WINDOW (window), 400, 600);
g_signal_connect (window, "destroy", G_CALLBACK (close_window), NULL);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE);
g_object_set (box, "margin", 12, NULL);
gtk_widget_set_margin_start (box, 12);
gtk_widget_set_margin_end (box, 12);
gtk_widget_set_margin_top (box, 12);
gtk_widget_set_margin_bottom (box, 12);
gtk_box_set_spacing (GTK_BOX (box), 6);
gtk_container_add (GTK_CONTAINER (window), box);

View File

@@ -23,7 +23,7 @@ do_headerbar (GtkWidget *do_widget)
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &window);
@@ -42,7 +42,7 @@ do_headerbar (GtkWidget *do_widget)
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_style_context_add_class (gtk_widget_get_style_context (box), "linked");
gtk_widget_add_css_class (box, "linked");
button = gtk_button_new ();
gtk_container_add (GTK_CONTAINER (button), gtk_image_new_from_icon_name ("pan-start-symbolic"));
gtk_container_add (GTK_CONTAINER (box), button);

View File

@@ -17,7 +17,7 @@
static void
insert_link (GtkTextBuffer *buffer,
GtkTextIter *iter,
gchar *text,
const char *text,
gint page)
{
GtkTextTag *tag;
@@ -232,7 +232,7 @@ do_hypertext (GtkWidget *do_widget)
GtkTextBuffer *buffer;
GtkEventController *controller;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Hypertext");
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));

View File

@@ -52,7 +52,10 @@ populate_icons (void)
grid = gtk_grid_new ();
gtk_widget_set_halign (grid, GTK_ALIGN_CENTER);
g_object_set (grid, "margin", 10, NULL);
gtk_widget_set_margin_start (grid, 10);
gtk_widget_set_margin_end (grid, 10);
gtk_widget_set_margin_top (grid, 10);
gtk_widget_set_margin_bottom (grid, 10);
gtk_grid_set_row_spacing (GTK_GRID (grid), 10);
gtk_grid_set_column_spacing (GTK_GRID (grid), 10);

View File

@@ -26,7 +26,7 @@ enum
static GdkPixbuf *file_pixbuf, *folder_pixbuf;
gchar *parent;
GtkToolItem *up_button;
GtkWidget *up_button;
/* Loads the images for the demo and returns whether the operation succeeded */
static void
@@ -188,8 +188,8 @@ item_activated (GtkIconView *icon_view,
}
static void
up_clicked (GtkToolItem *item,
gpointer user_data)
up_clicked (GtkButton *item,
gpointer user_data)
{
GtkListStore *store;
gchar *dir_name;
@@ -209,8 +209,8 @@ up_clicked (GtkToolItem *item,
}
static void
home_clicked (GtkToolItem *item,
gpointer user_data)
home_clicked (GtkButton *item,
gpointer user_data)
{
GtkListStore *store;
@@ -248,9 +248,9 @@ do_iconview (GtkWidget *do_widget)
GtkListStore *store;
GtkWidget *vbox;
GtkWidget *tool_bar;
GtkToolItem *home_button;
GtkWidget *home_button;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_default_size (GTK_WINDOW (window), 650, 400);
gtk_window_set_display (GTK_WINDOW (window),
@@ -265,23 +265,15 @@ do_iconview (GtkWidget *do_widget)
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (window), vbox);
tool_bar = gtk_toolbar_new ();
tool_bar = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_container_add (GTK_CONTAINER (vbox), tool_bar);
up_button = gtk_tool_button_new (NULL, NULL);
gtk_tool_button_set_label (GTK_TOOL_BUTTON (up_button), _("_Up"));
gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (up_button), TRUE);
gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (up_button), "go-up");
gtk_tool_item_set_is_important (up_button, TRUE);
up_button = gtk_button_new_with_mnemonic ("_Up");
gtk_widget_set_sensitive (GTK_WIDGET (up_button), FALSE);
gtk_toolbar_insert (GTK_TOOLBAR (tool_bar), up_button, -1);
gtk_container_add (GTK_CONTAINER (tool_bar), up_button);
home_button = gtk_tool_button_new (NULL, NULL);
gtk_tool_button_set_label (GTK_TOOL_BUTTON (home_button), _("_Home"));
gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (home_button), TRUE);
gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (home_button), "go-home");
gtk_tool_item_set_is_important (home_button, TRUE);
gtk_toolbar_insert (GTK_TOOLBAR (tool_bar), home_button, -1);
home_button = gtk_button_new_with_mnemonic ("_Home");
gtk_container_add (GTK_CONTAINER (tool_bar), home_button);
sw = gtk_scrolled_window_new (NULL, NULL);

View File

@@ -106,7 +106,7 @@ do_iconview_edit (GtkWidget *do_widget)
GtkListStore *store;
GtkCellRenderer *renderer;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));

View File

@@ -331,7 +331,7 @@ do_images (GtkWidget *do_widget)
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Images");
@@ -342,7 +342,10 @@ do_images (GtkWidget *do_widget)
G_CALLBACK (cleanup_callback), NULL);
base_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
g_object_set (base_vbox, "margin", 16, NULL);
gtk_widget_set_margin_start (base_vbox, 16);
gtk_widget_set_margin_end (base_vbox, 16);
gtk_widget_set_margin_top (base_vbox, 16);
gtk_widget_set_margin_bottom (base_vbox, 16);
gtk_container_add (GTK_CONTAINER (window), base_vbox);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 16);

View File

@@ -53,7 +53,7 @@ do_infobar (GtkWidget *do_widget)
{
actions = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Info Bars");
@@ -61,7 +61,10 @@ do_infobar (GtkWidget *do_widget)
g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
g_object_set (vbox, "margin", 8, NULL);
gtk_widget_set_margin_start (vbox, 8);
gtk_widget_set_margin_end (vbox, 8);
gtk_widget_set_margin_top (vbox, 8);
gtk_widget_set_margin_bottom (vbox, 8);
gtk_container_add (GTK_CONTAINER (window), vbox);
bar = gtk_info_bar_new ();
@@ -70,7 +73,7 @@ do_infobar (GtkWidget *do_widget)
label = gtk_label_new ("This is an info bar with message type GTK_MESSAGE_INFO");
gtk_label_set_wrap (GTK_LABEL (label), TRUE);
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))), label);
gtk_container_add (GTK_CONTAINER (bar), label);
button = gtk_toggle_button_new_with_label ("Message");
g_object_bind_property (bar, "revealed", button, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
@@ -82,7 +85,7 @@ do_infobar (GtkWidget *do_widget)
label = gtk_label_new ("This is an info bar with message type GTK_MESSAGE_WARNING");
gtk_label_set_wrap (GTK_LABEL (label), TRUE);
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))), label);
gtk_container_add (GTK_CONTAINER (bar), label);
button = gtk_toggle_button_new_with_label ("Warning");
g_object_bind_property (bar, "revealed", button, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
@@ -96,7 +99,7 @@ do_infobar (GtkWidget *do_widget)
label = gtk_label_new ("This is an info bar with message type GTK_MESSAGE_QUESTION");
gtk_label_set_wrap (GTK_LABEL (label), TRUE);
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))), label);
gtk_container_add (GTK_CONTAINER (bar), label);
gtk_info_bar_set_default_response (GTK_INFO_BAR (bar), GTK_RESPONSE_OK);
button = gtk_toggle_button_new_with_label ("Question");
@@ -109,7 +112,7 @@ do_infobar (GtkWidget *do_widget)
label = gtk_label_new ("This is an info bar with message type GTK_MESSAGE_ERROR");
gtk_label_set_wrap (GTK_LABEL (label), TRUE);
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))), label);
gtk_container_add (GTK_CONTAINER (bar), label);
button = gtk_toggle_button_new_with_label ("Error");
g_object_bind_property (bar, "revealed", button, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
@@ -122,7 +125,7 @@ do_infobar (GtkWidget *do_widget)
label = gtk_label_new ("This is an info bar with message type GTK_MESSAGE_OTHER");
gtk_label_set_wrap (GTK_LABEL (label), TRUE);
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))), label);
gtk_container_add (GTK_CONTAINER (bar), label);
button = gtk_toggle_button_new_with_label ("Other");
g_object_bind_property (bar, "revealed", button, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
@@ -134,7 +137,10 @@ do_infobar (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (vbox), frame);
vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
g_object_set (vbox2, "margin", 8, NULL);
gtk_widget_set_margin_start (vbox2, 8);
gtk_widget_set_margin_end (vbox2, 8);
gtk_widget_set_margin_top (vbox2, 8);
gtk_widget_set_margin_bottom (vbox2, 8);
gtk_container_add (GTK_CONTAINER (frame), vbox2);
/* Standard message dialog */

View File

@@ -52,7 +52,7 @@ do_links (GtkWidget *do_widget)
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Links");

View File

@@ -16,10 +16,9 @@ typedef struct
{
const gboolean fixed;
const guint number;
const gchar *severity;
const gchar *description;
}
Bug;
const char *severity;
const char *description;
} Bug;
enum
{
@@ -34,7 +33,7 @@ enum
NUM_COLUMNS
};
static Bug data[] =
static Bug bugs[] =
{
{ FALSE, 60482, "Normal", "scrollable notebooks and hidden tabs" },
{ FALSE, 60620, "Critical", "gdk_surface_clear_area (gdksurface-win32.c) is not thread-safe" },
@@ -98,9 +97,9 @@ create_model (void)
G_TYPE_BOOLEAN);
/* add data to the list store */
for (i = 0; i < G_N_ELEMENTS (data); i++)
for (i = 0; i < G_N_ELEMENTS (bugs); i++)
{
gchar *icon_name;
const char *icon_name;
gboolean sensitive;
if (i == 1 || i == 3)
@@ -113,10 +112,10 @@ create_model (void)
sensitive = TRUE;
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
COLUMN_FIXED, data[i].fixed,
COLUMN_NUMBER, data[i].number,
COLUMN_SEVERITY, data[i].severity,
COLUMN_DESCRIPTION, data[i].description,
COLUMN_FIXED, bugs[i].fixed,
COLUMN_NUMBER, bugs[i].number,
COLUMN_SEVERITY, bugs[i].severity,
COLUMN_DESCRIPTION, bugs[i].description,
COLUMN_PULSE, 0,
COLUMN_ICON, icon_name,
COLUMN_ACTIVE, FALSE,
@@ -129,23 +128,23 @@ create_model (void)
static void
fixed_toggled (GtkCellRendererToggle *cell,
gchar *path_str,
char *path_str,
gpointer data)
{
GtkTreeModel *model = (GtkTreeModel *)data;
GtkTreeModel *tree_model = (GtkTreeModel *)data;
GtkTreeIter iter;
GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
gboolean fixed;
/* get toggled iter */
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_model_get (model, &iter, COLUMN_FIXED, &fixed, -1);
gtk_tree_model_get_iter (tree_model, &iter, path);
gtk_tree_model_get (tree_model, &iter, COLUMN_FIXED, &fixed, -1);
/* do something with the value */
fixed ^= 1;
/* set new value */
gtk_list_store_set (GTK_LIST_STORE (model), &iter, COLUMN_FIXED, fixed, -1);
gtk_list_store_set (GTK_LIST_STORE (tree_model), &iter, COLUMN_FIXED, fixed, -1);
/* clean up */
gtk_tree_path_free (path);
@@ -156,7 +155,6 @@ add_columns (GtkTreeView *treeview)
{
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
GtkTreeModel *model = gtk_tree_view_get_model (treeview);
/* column for fixed toggles */
renderer = gtk_cell_renderer_toggle_new ();
@@ -255,7 +253,7 @@ do_list_store (GtkWidget *do_widget)
GtkWidget *treeview;
/* create window, etc */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "List Store");
@@ -264,7 +262,10 @@ do_list_store (GtkWidget *do_widget)
G_CALLBACK (gtk_widget_destroyed), &window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
g_object_set (vbox, "margin", 8, NULL);
gtk_widget_set_margin_start (vbox, 8);
gtk_widget_set_margin_end (vbox, 8);
gtk_widget_set_margin_top (vbox, 8);
gtk_widget_set_margin_bottom (vbox, 8);
gtk_container_add (GTK_CONTAINER (window), vbox);
label = gtk_label_new ("This is the bug list (note: not based on real data, it would be nice to have a nice ODBC interface to bugzilla or so, though).");

View File

@@ -347,7 +347,7 @@ do_listbox (GtkWidget *do_widget)
{
avatar_pixbuf_other = gdk_pixbuf_new_from_resource_at_scale ("/listbox/apple-red.png", 32, 32, FALSE, NULL);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "List Box");

View File

@@ -38,7 +38,6 @@
<property name="baseline-position">top</property>
<child>
<object class="GtkButton" id="button2">
<property name="can-focus">1</property>
<property name="receives-default">1</property>
<property name="valign">baseline</property>
<property name="relief">none</property>
@@ -109,7 +108,6 @@
<child>
<object class="GtkLinkButton" id="resent_by_button">
<property name="label" translatable="0">reshareer</property>
<property name="can-focus">1</property>
<property name="receives-default">1</property>
<property name="relief">none</property>
<property name="uri">http://www.gtk.org</property>
@@ -127,7 +125,6 @@
<child>
<object class="GtkButton" id="expand_button">
<property name="label" translatable="yes">Expand</property>
<property name="can-focus">1</property>
<property name="receives-default">1</property>
<property name="relief">none</property>
<signal name="clicked" handler="expand_clicked" swapped="yes"/>
@@ -140,7 +137,6 @@
<child>
<object class="GtkButton" id="reply-button">
<property name="label" translatable="yes">Reply</property>
<property name="can-focus">1</property>
<property name="receives-default">1</property>
<property name="relief">none</property>
</object>
@@ -148,7 +144,6 @@
<child>
<object class="GtkButton" id="reshare-button">
<property name="label" translatable="yes">Reshare</property>
<property name="can-focus">1</property>
<property name="receives-default">1</property>
<property name="relief">none</property>
<signal name="clicked" handler="reshare_clicked" swapped="yes"/>
@@ -157,7 +152,6 @@
<child>
<object class="GtkButton" id="favorite-buttton">
<property name="label" translatable="yes">Favorite</property>
<property name="can-focus">1</property>
<property name="receives-default">1</property>
<property name="relief">none</property>
<signal name="clicked" handler="favorite_clicked" swapped="yes"/>
@@ -165,7 +159,6 @@
</child>
<child>
<object class="GtkMenuButton" id="more-button">
<property name="can-focus">1</property>
<property name="receives-default">1</property>
<property name="menu-model">menu1</property>
<property name="relief">none</property>
@@ -231,7 +224,6 @@ FAVORITES</property>
<child>
<object class="GtkButton" id="button5">
<property name="label" translatable="yes">Details</property>
<property name="can-focus">1</property>
<property name="receives-default">1</property>
<property name="relief">none</property>
<style>

View File

@@ -205,14 +205,14 @@ enum {
STATE_IN_COMMENT
};
static gchar *tokens[] =
static const char *tokens[] =
{
"/*",
"\"",
NULL
};
static gchar *types[] =
static const char *types[] =
{
"static",
"const ",
@@ -310,7 +310,6 @@ static gchar *types[] =
"GtkIconView ",
"GtkCellRendererText ",
"GtkContainer ",
"GtkAccelGroup ",
"GtkPaned ",
"GtkPrintOperation ",
"GtkPrintContext ",
@@ -337,7 +336,7 @@ static gchar *types[] =
NULL
};
static gchar *control[] =
static const char *control[] =
{
" if ",
" while ",
@@ -351,11 +350,11 @@ static gchar *control[] =
NULL
};
void
parse_chars (gchar *text,
gchar **end_ptr,
gint *state,
gchar **tag,
gboolean start)
parse_chars (gchar *text,
gchar **end_ptr,
gint *state,
const char **tag,
gboolean start)
{
gint i;
gchar *next_token;
@@ -494,7 +493,7 @@ fontify (GtkTextBuffer *source_buffer)
gint state;
gchar *text;
gchar *start_ptr, *end_ptr;
gchar *tag;
const char *tag;
gtk_text_buffer_create_tag (source_buffer, "source",
"font", "monospace",
@@ -868,7 +867,7 @@ load_file (const gchar *demoname,
p = lines[i];
state++;
/* Fall through */
G_GNUC_FALLTHROUGH;
case 3:
/* Reading program body */
@@ -876,6 +875,9 @@ load_file (const gchar *demoname,
if (lines[i+1] != NULL)
gtk_text_buffer_insert (source_buffer, &start, "\n", 1);
break;
default:
g_assert_not_reached ();
}
}
@@ -975,7 +977,7 @@ startup (GApplication *app)
{
GtkBuilder *builder;
GMenuModel *appmenu;
gchar *ids[] = { "appmenu", NULL };
const char *ids[] = { "appmenu", NULL };
builder = gtk_builder_new ();
gtk_builder_add_objects_from_resource (builder, "/ui/appmenu.ui", ids, NULL);

View File

@@ -28,14 +28,12 @@
<property name="default-width">800</property>
<property name="default-height">600</property>
<property name="title">GTK Demo</property>
<signal name="destroy" handler="gtk_main_quit" swapped="no"/>
<child type="titlebar">
<object class="GtkHeaderBar" id="headerbar">
<property name="show-title-buttons">1</property>
<child>
<object class="GtkButton">
<property name="valign">center</property>
<property name="can-focus">1</property>
<property name="action-name">win.run</property>
<style>
<class name="text-button"/>
@@ -63,12 +61,10 @@
<child>
<object class="GtkScrolledWindow">
<property name="width-request">120</property>
<property name="can-focus">1</property>
<property name="hscrollbar-policy">never</property>
<property name="min-content-width">150</property>
<child>
<object class="GtkTreeView" id="treeview">
<property name="can-focus">1</property>
<property name="model">treestore</property>
<property name="headers-visible">0</property>
<child internal-child="selection">
@@ -100,20 +96,18 @@
</child>
<child>
<object class="GtkNotebook" id="notebook">
<property name="can-focus">1</property>
<property name="scrollable">1</property>
<property name="enable-popup">1</property>
<property name="show-border">0</property>
<property name="expand">1</property>
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<child>
<object class="GtkNotebookPage">
<property name="tab-expand">1</property>
<property name="child">
<object class="GtkScrolledWindow">
<property name="can-focus">1</property>
<child>
<object class="GtkTextView" id="info-textview">
<property name="can-focus">1</property>
<property name="left-margin">20</property>
<property name="right-margin">20</property>
<property name="top-margin">20</property>
@@ -141,10 +135,8 @@
<property name="tab-expand">1</property>
<property name="child">
<object class="GtkScrolledWindow" id="source-scrolledwindow">
<property name="can-focus">1</property>
<child>
<object class="GtkTextView" id="source-textview">
<property name="can-focus">1</property>
<property name="left-margin">20</property>
<property name="right-margin">20</property>
<property name="top-margin">20</property>

View File

@@ -54,7 +54,7 @@ do_markup (GtkWidget *do_widget)
GtkWidget *header;
GtkWidget *show_source;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_default_size (GTK_WINDOW (window), 450, 450);
@@ -78,7 +78,7 @@ do_markup (GtkWidget *do_widget)
view = gtk_text_view_new ();
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD);
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD_CHAR);
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 10);
gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 10);

View File

@@ -14,3 +14,7 @@ Superscripts and subscripts: 𝜀<span rise="-6000" size="x-small" font_desc="it
OpenType font features: <span font_desc="sans regular" font_features="dlig=0">feast</span> versus <span font_desc="sans regular" font_features="dlig=1">feast</span>
Shortcuts: <tt>Monospace</tt> <b>Bold</b> <i>Italic</i> <big>Big</big> <small>Small</small> <u>Underlined</u> <s>Strikethrough</s> Super<sup>script</sup> Sub<sub>script</sub>
<span allow_breaks="false">A</span> hy­phen­ation al­go­rithm is a set of rules, espe­ci­ally one co­di­fied for im­ple­men­tation in a com­pu­ter pro­gram, that de­ci­des at which points a word can be bro­ken over two lines with a hy­phen. For ex­am­ple, a hy­phen­ation al­go­rithm might de­cide that im­peach­ment can be broken as <span allow_breaks="false">impeach‧ment</span> or <span allow_breaks="false">im‧peachment</span> but not <span allow_breaks="false">impe‧achment.</span>
<span insert_hyphens="false">one/two three/four five/six seven/eight nine/ten</span>

View File

@@ -5,7 +5,7 @@
<item>
<attribute name="label" translatable="yes">_New</attribute>
<attribute name="action">app.new</attribute>
<attribute name="accel">&lt;Primary&gt;n</attribute>
<attribute name="accel">&lt;Control&gt;n</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Open</attribute>
@@ -14,19 +14,19 @@
<item>
<attribute name="label" translatable="yes">_Save</attribute>
<attribute name="action">app.save</attribute>
<attribute name="accel">&lt;Primary&gt;s</attribute>
<attribute name="accel">&lt;Control&gt;s</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Save _As...</attribute>
<attribute name="action">app.save-as</attribute>
<attribute name="accel">&lt;Primary&gt;s</attribute>
<attribute name="accel">&lt;Control&gt;s</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">_Quit</attribute>
<attribute name="action">app.quit</attribute>
<attribute name="accel">&lt;Primary&gt;q</attribute>
<attribute name="accel">&lt;Control&gt;q</attribute>
</item>
</section>
</menu>
@@ -45,19 +45,19 @@
<attribute name="label" translatable="yes">_Red</attribute>
<attribute name="action">app.color</attribute>
<attribute name="target">red</attribute>
<attribute name="accel">&lt;Primary&gt;r</attribute>
<attribute name="accel">&lt;Control&gt;r</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Green</attribute>
<attribute name="action">app.color</attribute>
<attribute name="target">green</attribute>
<attribute name="accel">&lt;Primary&gt;g</attribute>
<attribute name="accel">&lt;Control&gt;g</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Blue</attribute>
<attribute name="action">app.color</attribute>
<attribute name="target">blue</attribute>
<attribute name="accel">&lt;Primary&gt;b</attribute>
<attribute name="accel">&lt;Control&gt;b</attribute>
</item>
</section>
</submenu>
@@ -68,26 +68,26 @@
<attribute name="label" translatable="yes">_Square</attribute>
<attribute name="action">win.shape</attribute>
<attribute name="target">square</attribute>
<attribute name="accel">&lt;Primary&gt;s</attribute>
<attribute name="accel">&lt;Control&gt;s</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Rectangle</attribute>
<attribute name="action">win.shape</attribute>
<attribute name="target">rectangle</attribute>
<attribute name="accel">&lt;Primary&gt;r</attribute>
<attribute name="accel">&lt;Control&gt;r</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Oval</attribute>
<attribute name="action">win.shape</attribute>
<attribute name="target">oval</attribute>
<attribute name="accel">&lt;Primary&gt;o</attribute>
<attribute name="accel">&lt;Control&gt;o</attribute>
</item>
</section>
</submenu>
<item>
<attribute name="label" translatable="yes">_Bold</attribute>
<attribute name="action">win.bold</attribute>
<attribute name="accel">&lt;Primary&gt;&lt;Shift&gt;b</attribute>
<attribute name="accel">&lt;Control&gt;&lt;Shift&gt;b</attribute>
</item>
</section>
</submenu>
@@ -96,7 +96,7 @@
<item>
<attribute name="label" translatable="yes">_About</attribute>
<attribute name="action">win.about</attribute>
<attribute name="accel">&lt;Primary&gt;a</attribute>
<attribute name="accel">&lt;Control&gt;a</attribute>
</item>
</submenu>
</menu>

View File

@@ -28,7 +28,7 @@ demos = files([
'fishbowl.c',
'fixed.c',
'fontrendering.c',
'foreigndrawing.c',
'gears.c',
'gestures.c',
'glarea.c',
'headerbar.c',
@@ -52,9 +52,9 @@ demos = files([
'paintable_mediastream.c',
'panes.c',
'password_entry.c',
'peg_solitaire.c',
'pickers.c',
'pixbufs.c',
'popover.c',
'printing.c',
'revealer.c',
'rotated_text.c',
@@ -62,6 +62,7 @@ demos = files([
'search_entry.c',
'search_entry2.c',
'shortcuts.c',
'shortcut_triggers.c',
'sidebar.c',
'sizegroup.c',
'sliding_puzzle.c',
@@ -112,9 +113,16 @@ gtkdemo_resources = gnome.compile_resources('gtkdemo_resources',
'demo.gresource.xml',
source_dir: '.')
demo_cflags = []
foreach flag: common_cflags
if flag not in ['-Werror=missing-prototypes', '-Werror=missing-declarations', '-fvisibility=hidden']
demo_cflags += flag
endif
endforeach
executable('gtk4-demo',
demos, demos_h, extra_demo_sources, gtkdemo_resources,
c_args: gtkdemo_args,
c_args: gtkdemo_args + demo_cflags,
dependencies: gtkdemo_deps,
include_directories: confinc,
gui_app: true,
@@ -123,7 +131,7 @@ executable('gtk4-demo',
executable('gtk4-demo-application',
'application.c', gtkdemo_resources,
c_args: gtkdemo_args,
c_args: gtkdemo_args + common_cflags,
dependencies: gtkdemo_deps,
include_directories: confinc,
gui_app: true,

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkWindow" id="window1">
<property name="resizable">0</property>
<child type="titlebar">
<object class="GtkHeaderBar">
<property name="show-title-buttons">1</property>
@@ -10,32 +11,40 @@
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="margin">80</property>
<property name="margin-start">80</property>
<property name="margin-end">80</property>
<property name="margin-top">80</property>
<property name="margin-bottom">80</property>
<child>
<object class="GtkMenuButton">
<property name="popover">thing_a</property>
<property name="label">Color</property>
<property name="label">_Color</property>
<property name="use-underline">1</property>
</object>
</child>
<child>
<object class="GtkMenuButton">
<property name="popover">thing_b</property>
<property name="label">Flavors</property>
<property name="label">_Flavors</property>
<property name="use-underline">1</property>
</object>
</child>
<child>
<object class="GtkMenuButton">
<property name="popover">thing_c</property>
<property name="label">Tools</property>
<property name="label">_Tools</property>
<property name="use-underline">1</property>
</object>
</child>
</object>
</child>
</object>
<object class="GtkPopover" id="thing_a">
<style>
<class name="menu"/>
</style>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkModelButton">
@@ -62,11 +71,12 @@
</child>
</object>
<object class="GtkPopover" id="thing_b">
<style>
<class name="menu"/>
</style>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<child>
<object class="GtkModelButton">
<property name="action-name">win.chocolate</property>
@@ -92,11 +102,12 @@
</child>
</object>
<object class="GtkPopover" id="thing_c">
<style>
<class name="menu"/>
</style>
<child>
<object class="GtkBox">
<property name="margin">10</property>
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<child>
<object class="GtkModelButton">
<property name="text">Hammer</property>

View File

@@ -31,7 +31,7 @@ do_overlay (GtkWidget *do_widget)
int i, j;
char *text;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_default_size (GTK_WINDOW (window), 500, 510);
gtk_window_set_title (GTK_WINDOW (window), "Interactive Overlay");
@@ -56,23 +56,25 @@ do_overlay (GtkWidget *do_widget)
}
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), vbox);
gtk_widget_set_can_target (vbox, FALSE);
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), vbox);
gtk_widget_set_halign (vbox, GTK_ALIGN_CENTER);
gtk_widget_set_valign (vbox, GTK_ALIGN_CENTER);
gtk_widget_set_valign (vbox, GTK_ALIGN_START);
label = gtk_label_new ("<span foreground='blue' weight='ultrabold' font='40'>Numbers</span>");
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
gtk_widget_set_can_target (label, FALSE);
gtk_widget_set_margin_top (label, 8);
gtk_widget_set_margin_bottom (label, 50);
gtk_widget_set_margin_bottom (label, 8);
gtk_container_add (GTK_CONTAINER (vbox), label);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), vbox);
gtk_widget_set_halign (vbox, GTK_ALIGN_CENTER);
gtk_widget_set_valign (vbox, GTK_ALIGN_CENTER);
gtk_entry_set_placeholder_text (GTK_ENTRY (entry), "Your Lucky Number");
gtk_widget_set_margin_top (entry, 50);
gtk_widget_set_margin_top (entry, 8);
gtk_widget_set_margin_bottom (entry, 8);
gtk_container_add (GTK_CONTAINER (vbox), entry);

View File

@@ -35,7 +35,7 @@ do_overlay2 (GtkWidget *do_widget)
GtkTextIter start, end;
GtkAdjustment *adjustment;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_default_size (GTK_WINDOW (window), 500, 510);
gtk_window_set_title (GTK_WINDOW (window), "Decorative Overlay");

View File

@@ -47,6 +47,7 @@ static const gchar *pad_colors[] = {
"orange"
};
static GType drawing_area_get_type (void);
G_DEFINE_TYPE (DrawingArea, drawing_area, GTK_TYPE_WIDGET)
static void drawing_area_set_color (DrawingArea *area,
@@ -340,7 +341,7 @@ drawing_area_init (DrawingArea *area)
area->draw_color = (GdkRGBA) { 0, 0, 0, 1 };
}
GtkWidget *
static GtkWidget *
drawing_area_new (void)
{
return g_object_new (drawing_area_get_type (), NULL);
@@ -384,7 +385,7 @@ do_paint (GtkWidget *toplevel)
{
GtkWidget *draw_area, *headerbar, *colorbutton;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
draw_area = drawing_area_new ();
gtk_container_add (GTK_CONTAINER (window), draw_area);

View File

@@ -156,7 +156,7 @@ do_paintable (GtkWidget *do_widget)
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Nuclear Icon");

View File

@@ -188,7 +188,7 @@ do_paintable_animated (GtkWidget *do_widget)
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Nuclear Animation");

View File

@@ -288,7 +288,7 @@ do_paintable_mediastream (GtkWidget *do_widget)
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Nuclear MediaStream");

View File

@@ -13,7 +13,7 @@
#include <gtk/gtk.h>
void
static void
toggle_resize (GtkWidget *widget,
GtkWidget *child)
{
@@ -47,7 +47,7 @@ toggle_resize (GtkWidget *widget,
g_object_unref (child);
}
void
static void
toggle_shrink (GtkWidget *widget,
GtkWidget *child)
{
@@ -81,7 +81,7 @@ toggle_shrink (GtkWidget *widget,
g_object_unref (child);
}
GtkWidget *
static GtkWidget *
create_pane_options (GtkPaned *paned,
const gchar *frame_label,
const gchar *label1,
@@ -97,7 +97,10 @@ create_pane_options (GtkPaned *paned,
child2 = gtk_paned_get_child2 (paned);
frame = gtk_frame_new (frame_label);
g_object_set (frame, "margin", 4, NULL);
gtk_widget_set_margin_start (frame, 4);
gtk_widget_set_margin_end (frame, 4);
gtk_widget_set_margin_top (frame, 4);
gtk_widget_set_margin_bottom (frame, 4);
table = gtk_grid_new ();
gtk_container_add (GTK_CONTAINER (frame), table);
@@ -146,7 +149,7 @@ do_panes (GtkWidget *do_widget)
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
@@ -159,7 +162,10 @@ do_panes (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (window), vbox);
vpaned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
g_object_set (vpaned, "margin", 5, NULL);
gtk_widget_set_margin_start (vpaned, 5);
gtk_widget_set_margin_end (vpaned, 5);
gtk_widget_set_margin_top (vpaned, 5);
gtk_widget_set_margin_bottom (vpaned, 5);
gtk_container_add (GTK_CONTAINER (vbox), vpaned);
hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);

View File

@@ -36,7 +36,7 @@ do_password_entry (GtkWidget *do_widget)
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
header = gtk_header_bar_new ();
@@ -49,7 +49,10 @@ do_password_entry (GtkWidget *do_widget)
G_CALLBACK (gtk_widget_destroyed), &window);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
g_object_set (box, "margin", 18, NULL);
gtk_widget_set_margin_start (box, 18);
gtk_widget_set_margin_end (box, 18);
gtk_widget_set_margin_top (box, 18);
gtk_widget_set_margin_bottom (box, 18);
gtk_container_add (GTK_CONTAINER (window), box);
entry = gtk_password_entry_new ();
@@ -71,7 +74,7 @@ do_password_entry (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (box), entry2);
button = gtk_button_new_with_mnemonic ("_Done");
gtk_style_context_add_class (gtk_widget_get_style_context (button), "suggested-action");
gtk_widget_add_css_class (button, "suggested-action");
g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window);
gtk_widget_set_sensitive (button, FALSE);
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);

View File

@@ -0,0 +1,356 @@
/* Peg Solitaire
*
* This demo demonstrates how to use drag'n'drop to implement peg solitaire.
*
*/
#include <gtk/gtk.h>
static GtkWidget *window = NULL;
/* Create an object for the pegs that get moved around in the game.
*
* We implement the GdkPaintable interface for them, so we can use GtkPicture
* objects for the wholes we put the pegs into.
*/
#define SOLITAIRE_TYPE_PEG (solitaire_peg_get_type ())
G_DECLARE_FINAL_TYPE (SolitairePeg, solitaire_peg, SOLITAIRE, PEG, GObject)
/* Declare the struct. */
struct _SolitairePeg
{
GObject parent_instance;
int x;
int y;
};
struct _SolitairePegClass
{
GObjectClass parent_class;
};
/* Here, we implement the functionality required by the GdkPaintable interface */
static void
solitaire_peg_snapshot (GdkPaintable *paintable,
GdkSnapshot *snapshot,
double width,
double height)
{
/* The snapshot function is the only function we need to implement.
* It does the actual drawing of the paintable.
*/
gtk_snapshot_append_color (snapshot,
&(GdkRGBA) { 0.6, 0.3, 0.0, 1.0 },
&GRAPHENE_RECT_INIT (0, 0, width, height));
}
static GdkPaintableFlags
solitaire_peg_get_flags (GdkPaintable *paintable)
{
/* The flags are very useful to let GTK know that this image
* is never going to change.
* This allows many optimizations and should therefore always
* be set.
*/
return GDK_PAINTABLE_STATIC_CONTENTS | GDK_PAINTABLE_STATIC_SIZE;
}
static void
solitaire_peg_paintable_init (GdkPaintableInterface *iface)
{
iface->snapshot = solitaire_peg_snapshot;
iface->get_flags = solitaire_peg_get_flags;
}
/* When defining the GType, we need to implement the GdkPaintable interface */
G_DEFINE_TYPE_WITH_CODE (SolitairePeg, solitaire_peg, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
solitaire_peg_paintable_init))
/* Here's the boilerplate for the GObject declaration.
* We don't need to do anything special here, because we keep no
* data of our own.
*/
static void
solitaire_peg_class_init (SolitairePegClass *klass)
{
}
static void
solitaire_peg_init (SolitairePeg *peg)
{
}
/* Add a little setter for the peg's position.
* We want to track those so that we can check for legal moves
* during drag'n'drop operations.
*/
static void
solitaire_peg_set_position (SolitairePeg *peg,
guint x,
guint y)
{
peg->x = x;
peg->y = y;
}
/* And finally, we add a simple constructor.
*/
static SolitairePeg *
solitaire_peg_new (void)
{
return g_object_new (SOLITAIRE_TYPE_PEG, NULL);
}
/*** DRAG AND DROP ***/
/* The user tries to start a drag operation.
* We check if the image contains a peg, and if so, we return the
* peg as the content to be dragged.
*/
static GdkContentProvider *
drag_prepare (GtkDragSource *source,
double x,
double y,
GtkWidget *image)
{
GdkPaintable *paintable = gtk_image_get_paintable (GTK_IMAGE (image));
if (!SOLITAIRE_IS_PEG (paintable))
return NULL;
return gdk_content_provider_new_typed (SOLITAIRE_TYPE_PEG, paintable);
}
/* This notifies us that the drag has begun.
* We can now set up the icon and the widget for the ongoing drag.
*/
static void
drag_begin (GtkDragSource *source,
GdkDrag *drag,
GtkWidget *image)
{
GdkPaintable *paintable = gtk_image_get_paintable (GTK_IMAGE (image));
/* We guaranteed in the drag_prepare function above that we
* only start a drag if a peg is available.
* So let's make sure we did not screw that up.
*/
g_assert (SOLITAIRE_IS_PEG (paintable));
/* We use the peg as the drag icon.
*/
gtk_drag_source_set_icon (source, paintable, -2, -2);
/* We also attach it to the drag operation as custom user data,
* so that we can get it back later if the drag fails.
*/
g_object_set_data (G_OBJECT (drag), "the peg", paintable);
/* Because we are busy dragging the peg, we want to unset it
* on the image.
*/
gtk_image_clear (GTK_IMAGE (image));
}
/* Thie is called once a drag operation has ended (successfully or not).
* We want to undo what we did in drag_begin() above and react
* to a potential move of the peg.
*/
static void
drag_end (GtkDragSource *source,
GdkDrag *drag,
gboolean delete_data,
GtkWidget *image)
{
SolitairePeg *peg;
/* If the drag was successful, we should now delete the peg.
* We did this in drag_begin() above to prepare for the drag, so
* there's no need to do anything anymore.
*/
if (delete_data)
return;
/* However, if the drag did not succeed, we need to undo what
* we did in drag_begin() and reinsert the peg here.
* Because we used it as the drag data
*/
peg = g_object_get_data (G_OBJECT (drag), "the peg");
gtk_image_set_from_paintable (GTK_IMAGE (image), GDK_PAINTABLE (peg));
}
/* Whenever a new drop operation starts, we need to check if we can
* accept it.
* The default check unfortunately is not good enough, because it only
* checks the data type. But we also need to check if our image can
* even accept data.
*/
static gboolean
drop_accept (GtkDropTarget *target,
GdkDrop *drop,
GtkWidget *image)
{
/* First, check the drop is actually trying to drop a peg */
if (!gdk_content_formats_contain_gtype (gdk_drop_get_formats (drop), SOLITAIRE_TYPE_PEG))
return FALSE;
/* If the image already contains a peg, we cannot accept another one */
if (SOLITAIRE_IS_PEG (gtk_image_get_paintable (GTK_IMAGE (image))))
return FALSE;
return TRUE;
}
static gboolean
drop_drop (GtkDropTarget *target,
const GValue *value,
double x,
double y,
GtkWidget *image)
{
GtkGrid *grid;
SolitairePeg *peg;
int image_x, image_y;
GtkWidget *jumped;
grid = GTK_GRID (gtk_widget_get_parent (image));
/* The value contains the data in the type we demanded.
* We demanded a SolitairePeg, so that's what we get.
*/
peg = g_value_get_object (value);
/* Make sure this was a legal move. */
/* First, figure out the image's position in the grid. */
gtk_grid_query_child (grid,
image,
&image_x, &image_y,
NULL, NULL);
/* If the peg was not moved 2 spaces horizontally or vertically,
* this was not a valid jump. Reject it.
*/
if (!((ABS (image_x - peg->x) == 2 && image_y == peg->y) ||
(ABS (image_y - peg->y) == 2 && image_x == peg->x)))
return FALSE;
/* Get the widget that was jumped over
*/
jumped = gtk_grid_get_child_at (grid,
(image_x + peg->x) / 2,
(image_y + peg->y) / 2);
/* If the jumped widget does not have a peg in it, this move
* isn't valid.
*/
if (!SOLITAIRE_IS_PEG (gtk_image_get_paintable (GTK_IMAGE (jumped))))
return FALSE;
/* Finally, we know it's a legal move. */
/* Clear the peg of the jumped-over image */
gtk_image_clear (GTK_IMAGE (jumped));
/* Add the peg to this image */
solitaire_peg_set_position (peg, image_x, image_y);
gtk_image_set_from_paintable (GTK_IMAGE (image), GDK_PAINTABLE (peg));
/* Success! */
return TRUE;
}
GtkWidget *
do_peg_solitaire (GtkWidget *do_widget)
{
if (!window)
{
GtkWidget *header;
GtkWidget *restart;
GtkWidget *grid;
GtkWidget *image;
int x, y;
GtkDragSource *source;
GtkDropTarget *target;
restart = gtk_button_new_from_icon_name ("view-refresh-symbolic");
g_signal_connect (restart, "clicked", G_CALLBACK (restart), NULL);
header = gtk_header_bar_new ();
gtk_header_bar_set_title (GTK_HEADER_BAR (header), "Peg Solitaire");
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE);
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), restart);
window = gtk_window_new ();
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);
grid = gtk_grid_new ();
gtk_widget_set_halign (grid, GTK_ALIGN_CENTER);
gtk_widget_set_valign (grid, GTK_ALIGN_CENTER);
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
gtk_grid_set_row_homogeneous (GTK_GRID (grid), TRUE);
gtk_grid_set_column_homogeneous (GTK_GRID (grid), TRUE);
gtk_container_add (GTK_CONTAINER (window), grid);
for (x = 0; x < 7; x++)
{
for (y = 0; y < 7; y++)
{
if ((x < 2 || x >= 5) && (y < 2 || y >= 5))
continue;
image = gtk_image_new ();
if (x != 3 || y != 3)
{
SolitairePeg *peg = solitaire_peg_new ();
solitaire_peg_set_position (peg, x, y);
gtk_image_set_from_paintable (GTK_IMAGE (image), GDK_PAINTABLE (peg));
}
gtk_grid_attach (GTK_GRID (grid), image, x, y, 1, 1);
/* Set up the drag source.
* This is rather straightforward: Set the supported actions
* (in our case, pegs can only be moved) and connect all the
* relevant signals.
* And because all drag'n'drop handling is done via event controllers,
* we need to add the controller to the widget.
*/
source = gtk_drag_source_new ();
gtk_drag_source_set_actions (source, GDK_ACTION_MOVE);
g_signal_connect (source, "prepare", G_CALLBACK (drag_prepare), image);
g_signal_connect (source, "drag-begin", G_CALLBACK (drag_begin), image);
g_signal_connect (source, "drag-end", G_CALLBACK (drag_end), image);
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
/* Set up the drop target.
* This is more involved, because the game logic goes here.
*/
/* First we specify the data we accept: pegs.
* And we only want moves.
*/
target = gtk_drop_target_new (SOLITAIRE_TYPE_PEG, GDK_ACTION_MOVE);
/* Then we connect our signals.
*/
g_signal_connect (target, "accept", G_CALLBACK (drop_accept), image);
g_signal_connect (target, "drop", G_CALLBACK (drop_drop), image);
/* Finally, like above, we add it to the widget.
*/
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (target));
}
}
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_widget_destroy (window);
return window;
}

View File

@@ -14,7 +14,7 @@ do_pickers (GtkWidget *do_widget)
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Pickers");
@@ -23,7 +23,10 @@ do_pickers (GtkWidget *do_widget)
G_CALLBACK (gtk_widget_destroyed), &window);
table = gtk_grid_new ();
g_object_set (table, "margin", 20, NULL);
gtk_widget_set_margin_start (table, 20);
gtk_widget_set_margin_end (table, 20);
gtk_widget_set_margin_top (table, 20);
gtk_widget_set_margin_bottom (table, 20);
gtk_grid_set_row_spacing (GTK_GRID (table), 3);
gtk_grid_set_column_spacing (GTK_GRID (table), 10);
gtk_container_add (GTK_CONTAINER (window), table);
@@ -50,7 +53,6 @@ do_pickers (GtkWidget *do_widget)
gtk_widget_set_hexpand (label, TRUE);
picker = gtk_file_chooser_button_new ("Pick a File",
GTK_FILE_CHOOSER_ACTION_OPEN);
gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (picker), FALSE);
gtk_grid_attach (GTK_GRID (table), label, 0, 2, 1, 1);
gtk_grid_attach (GTK_GRID (table), picker, 1, 2, 1, 1);

View File

@@ -174,7 +174,7 @@ do_pixbufs (GtkWidget *do_widget)
{
GError *error;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Pixbufs");

View File

@@ -1,176 +0,0 @@
/* Popovers
*
* A bubble-like window containing contextual information or options.
* GtkPopovers can be attached to any widget, and will be displayed
* within the same window, but on top of all its content.
*/
#include <gtk/gtk.h>
static void
toggle_changed_cb (GtkToggleButton *button,
GtkWidget *popover)
{
gtk_widget_set_visible (popover,
gtk_toggle_button_get_active (button));
}
static GtkWidget *
create_popover (GtkWidget *parent,
GtkWidget *child,
GtkPositionType pos)
{
GtkWidget *popover;
popover = gtk_popover_new (parent);
gtk_popover_set_position (GTK_POPOVER (popover), pos);
gtk_container_add (GTK_CONTAINER (popover), child);
g_object_set (child, "margin", 6, NULL);
gtk_widget_show (child);
return popover;
}
static GtkWidget *
create_complex_popover (GtkWidget *parent,
GtkPositionType pos)
{
GtkWidget *popover, *window, *content;
GtkBuilder *builder;
builder = gtk_builder_new ();
gtk_builder_add_from_resource (builder, "/popover/popover.ui", NULL);
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
content = gtk_bin_get_child (GTK_BIN (window));
g_object_ref (content);
gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (content)),
content);
gtk_widget_destroy (window);
g_object_unref (builder);
popover = create_popover (parent, content, GTK_POS_BOTTOM);
g_object_unref (content);
return popover;
}
static void
entry_size_allocate_cb (GtkEntry *entry,
int width,
int height,
int baseline,
gpointer user_data)
{
GtkEntryIconPosition popover_pos;
GtkPopover *popover = user_data;
cairo_rectangle_int_t rect;
if (gtk_widget_is_visible (GTK_WIDGET (popover)))
{
popover_pos =
GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (entry),
"popover-icon-pos"));
gtk_entry_get_icon_area (entry, popover_pos, &rect);
gtk_popover_set_pointing_to (GTK_POPOVER (popover), &rect);
}
}
static void
entry_icon_press_cb (GtkEntry *entry,
GtkEntryIconPosition icon_pos,
gpointer user_data)
{
GtkWidget *popover = user_data;
cairo_rectangle_int_t rect;
gtk_entry_get_icon_area (entry, icon_pos, &rect);
gtk_popover_set_pointing_to (GTK_POPOVER (popover), &rect);
gtk_widget_show (popover);
g_object_set_data (G_OBJECT (entry), "popover-icon-pos",
GUINT_TO_POINTER (icon_pos));
}
static void
day_selected_cb (GtkCalendar *calendar,
gpointer user_data)
{
cairo_rectangle_int_t rect;
GtkWidget *popover;
GdkEvent *event;
gdouble x, y;
event = gtk_get_current_event ();
if (gdk_event_get_event_type (event) != GDK_BUTTON_PRESS)
return;
gdk_event_get_coords (event, &x, &y);
gtk_widget_translate_coordinates (gtk_get_event_widget (event),
GTK_WIDGET (calendar),
x, y,
&rect.x, &rect.y);
rect.width = rect.height = 1;
popover = create_popover (GTK_WIDGET (calendar),
gtk_entry_new (),
GTK_POS_BOTTOM);
gtk_popover_set_pointing_to (GTK_POPOVER (popover), &rect);
gtk_widget_show (popover);
g_object_unref (event);
}
GtkWidget *
do_popover (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
GtkWidget *popover, *box, *widget;
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Popovers");
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 24);
g_object_set (box, "margin", 24, NULL);
gtk_container_add (GTK_CONTAINER (window), box);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &window);
widget = gtk_toggle_button_new_with_label ("Button");
popover = create_popover (widget,
gtk_label_new ("This popover does not grab input"),
GTK_POS_TOP);
gtk_popover_set_autohide (GTK_POPOVER (popover), FALSE);
g_signal_connect (widget, "toggled",
G_CALLBACK (toggle_changed_cb), popover);
gtk_container_add (GTK_CONTAINER (box), widget);
widget = gtk_entry_new ();
popover = create_complex_popover (widget, GTK_POS_TOP);
gtk_entry_set_icon_from_icon_name (GTK_ENTRY (widget),
GTK_ENTRY_ICON_PRIMARY, "edit-find");
gtk_entry_set_icon_from_icon_name (GTK_ENTRY (widget),
GTK_ENTRY_ICON_SECONDARY, "edit-clear");
g_signal_connect (widget, "icon-press",
G_CALLBACK (entry_icon_press_cb), popover);
g_signal_connect (widget, "size-allocate",
G_CALLBACK (entry_size_allocate_cb), popover);
gtk_container_add (GTK_CONTAINER (box), widget);
widget = gtk_calendar_new ();
g_signal_connect (widget, "day-selected",
G_CALLBACK (day_selected_cb), NULL);
gtk_container_add (GTK_CONTAINER (box), widget);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_widget_destroy (window);
return window;
}

View File

@@ -1,85 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkListStore" id="liststore1">
<columns>
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">Item 1</col>
</row>
<row>
<col id="0" translatable="yes">Item 2</col>
</row>
<row>
<col id="0" translatable="yes">Item 3</col>
</row>
<row>
<col id="0" translatable="yes">Item 4</col>
</row>
<row>
<col id="0" translatable="yes">Item 5</col>
</row>
<row>
<col id="0" translatable="yes">Item 6</col>
</row>
<row>
<col id="0" translatable="yes">Item 7</col>
</row>
<row>
<col id="0" translatable="yes">Item 8</col>
</row>
<row>
<col id="0" translatable="yes">Item 9</col>
</row>
<row>
<col id="0" translatable="yes">Item 10</col>
</row>
</data>
</object>
<object class="GtkWindow" id="window">
<child>
<object class="GtkBox" id="box">
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkEntry" id="entry1">
<property name="can-focus">1</property>
<property name="primary-icon-name">edit-find</property>
<property name="secondary-icon-name">edit-clear</property>
</object>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="can-focus">1</property>
<property name="shadow-type">in</property>
<property name="max-content-height">100</property>
<child>
<object class="GtkTreeView" id="treeview1">
<property name="can-focus">1</property>
<property name="vexpand">1</property>
<property name="model">liststore1</property>
<property name="headers-visible">0</property>
<property name="enable-search">0</property>
<property name="search-column">2</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1"/>
</child>
<child>
<object class="GtkTreeViewColumn" id="column1">
<child>
<object class="GtkCellRendererText" id="cellrenderer1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>

View File

@@ -28,26 +28,23 @@ fancy_shape_renderer (cairo_t *cr,
(double) attr->ink_rect.width / PANGO_SCALE,
(double) attr->ink_rect.height / PANGO_SCALE);
switch (GPOINTER_TO_UINT (attr->data))
if (GPOINTER_TO_UINT (attr->data) == 0x2665) /* U+2665 BLACK HEART SUIT */
{
case 0x2665: /* U+2665 BLACK HEART SUIT */
{
cairo_move_to (cr, .5, .0);
cairo_line_to (cr, .9, -.4);
cairo_curve_to (cr, 1.1, -.8, .5, -.9, .5, -.5);
cairo_curve_to (cr, .5, -.9, -.1, -.8, .1, -.4);
cairo_close_path (cr);
}
break;
cairo_move_to (cr, .5, .0);
cairo_line_to (cr, .9, -.4);
cairo_curve_to (cr, 1.1, -.8, .5, -.9, .5, -.5);
cairo_curve_to (cr, .5, -.9, -.1, -.8, .1, -.4);
cairo_close_path (cr);
}
if (!do_path) {
cairo_set_source_rgb (cr, 1., 0., 0.);
cairo_fill (cr);
}
if (!do_path)
{
cairo_set_source_rgb (cr, 1., 0., 0.);
cairo_fill (cr);
}
}
PangoAttrList *
static PangoAttrList *
create_fancy_attr_list_for_layout (PangoLayout *layout)
{
PangoAttrList *attrs;
@@ -145,13 +142,13 @@ rotated_text_draw (GtkDrawingArea *da,
/* Draw the layout N_WORDS times in a circle */
for (i = 0; i < N_WORDS; i++)
{
int width, height;
int layout_width, layout_height;
/* Inform Pango to re-layout the text with the new transformation matrix */
pango_cairo_update_layout (cr, layout);
pango_layout_get_pixel_size (layout, &width, &height);
cairo_move_to (cr, - width / 2, - RADIUS * .9);
pango_layout_get_pixel_size (layout, &layout_width, &layout_height);
cairo_move_to (cr, - layout_width / 2, - RADIUS * .9);
pango_cairo_show_layout (cr, layout);
/* Rotate for the next turn */
@@ -178,7 +175,7 @@ do_rotated_text (GtkWidget *do_widget)
PangoLayout *layout;
PangoAttrList *attrs;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Rotated Text");
@@ -193,8 +190,7 @@ do_rotated_text (GtkWidget *do_widget)
/* Add a drawing area */
drawing_area = gtk_drawing_area_new ();
gtk_container_add (GTK_CONTAINER (box), drawing_area);
gtk_style_context_add_class (gtk_widget_get_style_context (drawing_area),
GTK_STYLE_CLASS_VIEW);
gtk_widget_add_css_class (drawing_area, GTK_STYLE_CLASS_VIEW);
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area),
rotated_text_draw,

View File

@@ -24,7 +24,10 @@
<object class="GtkGrid" id="grid1">
<property name="row-spacing">10</property>
<property name="column-spacing">10</property>
<property name="margin">20</property>
<property name="margin-start">20</property>
<property name="margin-end">20</property>
<property name="margin-top">20</property>
<property name="margin-bottom">20</property>
<child>
<object class="GtkLabel" id="label_plain">
<property name="label">Plain</property>
@@ -40,7 +43,6 @@
</child>
<child>
<object class="GtkScale" id="scale_plain">
<property name="can-focus">1</property>
<property name="width-request">200</property>
<property name="draw-value">0</property>
<property name="adjustment">adjustment1</property>
@@ -69,7 +71,6 @@
</child>
<child>
<object class="GtkScale" id="scale_marks">
<property name="can-focus">1</property>
<property name="width-request">200</property>
<property name="draw-value">0</property>
<property name="adjustment">adjustment2</property>
@@ -105,7 +106,6 @@
</child>
<child>
<object class="GtkScale" id="scale_discrete">
<property name="can-focus">1</property>
<property name="width-request">200</property>
<property name="round-digits">0</property>
<property name="draw-value">0</property>

View File

@@ -185,13 +185,13 @@ text_changed (GObject *object,
gpointer data)
{
GtkEntry *entry = GTK_ENTRY (object);
GActionMap *actions = data;
GActionMap *action_map = data;
GAction *action;
gboolean has_text;
has_text = gtk_entry_get_text_length (entry) > 0;
action = g_action_map_lookup_action (actions, "clear");
action = g_action_map_lookup_action (action_map, "clear");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), has_text);
}
@@ -216,11 +216,18 @@ entry_add_to_context_menu (GtkEntry *entry)
};
GMenuModel *submenu;
GMenuItem *item;
GAction *action;
GVariant *value;
actions = g_simple_action_group_new ();
g_action_map_add_action_entries (G_ACTION_MAP (actions), entries, G_N_ELEMENTS(entries), entry);
gtk_widget_insert_action_group (GTK_WIDGET (entry), "search", G_ACTION_GROUP (actions));
action = g_action_map_lookup_action (G_ACTION_MAP (actions), "search-by");
value = g_variant_ref_sink (g_variant_new_string ("name"));
set_search_by (G_SIMPLE_ACTION (action), value, entry);
g_variant_unref (value);
menu = g_menu_new ();
item = g_menu_item_new (_("C_lear"), "search.clear");
g_menu_item_set_attribute (item, "touch-icon", "s", "edit-clear-symbolic");
@@ -250,7 +257,7 @@ do_search_entry (GtkWidget *do_widget)
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Search Entry");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
@@ -258,7 +265,10 @@ do_search_entry (GtkWidget *do_widget)
G_CALLBACK (search_entry_destroyed), &window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
g_object_set (vbox, "margin", 5, NULL);
gtk_widget_set_margin_start (vbox, 5);
gtk_widget_set_margin_end (vbox, 5);
gtk_widget_set_margin_top (vbox, 5);
gtk_widget_set_margin_bottom (vbox, 5);
gtk_container_add (GTK_CONTAINER (window), vbox);
label = gtk_label_new (NULL);
@@ -294,10 +304,6 @@ do_search_entry (GtkWidget *do_widget)
gtk_widget_show (cancel_button);
/* Set up the search icon */
GVariant *value = g_variant_ref_sink (g_variant_new_string ("name"));
set_search_by (NULL, value, entry);
g_variant_unref (value);
gtk_entry_set_icon_activatable (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, TRUE);
gtk_entry_set_icon_sensitive (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, TRUE);

View File

@@ -68,7 +68,7 @@ do_search_entry2 (GtkWidget *do_widget)
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Delayed Search Entry");
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);

View File

@@ -0,0 +1,94 @@
/* Shortcuts
*
* GtkShortcut is the abstraction used by GTK to handle shortcuts from
* keyboard or other input devices.
*
* Shortcut triggers can be used to weave complex sequences of key
* presses into sophisticated mechanisms to activate shortcuts.
*
* This demo code shows creative ways to do that.
*/
#include <gtk/gtk.h>
static GtkWidget *window = NULL;
static gboolean
shortcut_activated (GtkWidget *widget,
GVariant *unused,
gpointer row)
{
g_print ("activated %s\n", gtk_label_get_label (row));
return TRUE;
}
static GtkShortcutTrigger *
create_ctrl_g (void)
{
return gtk_keyval_trigger_new (GDK_KEY_g, GDK_CONTROL_MASK);
}
static GtkShortcutTrigger *
create_x (void)
{
return gtk_keyval_trigger_new (GDK_KEY_x, 0);
}
struct {
const char *description;
GtkShortcutTrigger * (* create_trigger_func) (void);
} shortcuts[] = {
{ "Press Ctrl-G", create_ctrl_g },
{ "Press X", create_x },
};
GtkWidget *
do_shortcut_triggers (GtkWidget *do_widget)
{
guint i;
if (!window)
{
GtkWidget *list;
GtkEventController *controller;
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Shortcuts");
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &window);
list = gtk_list_box_new ();
gtk_widget_set_margin_top (list, 6);
gtk_widget_set_margin_bottom (list, 6);
gtk_widget_set_margin_start (list, 6);
gtk_widget_set_margin_end (list, 6);
gtk_container_add (GTK_CONTAINER (window), list);
for (i = 0; i < G_N_ELEMENTS (shortcuts); i++)
{
GtkShortcut *shortcut;
GtkWidget *row;
row = gtk_label_new (shortcuts[i].description);
gtk_container_add (GTK_CONTAINER (list), row);
controller = gtk_shortcut_controller_new ();
gtk_shortcut_controller_set_scope (GTK_SHORTCUT_CONTROLLER (controller), GTK_SHORTCUT_SCOPE_GLOBAL);
gtk_widget_add_controller (row, controller);
shortcut = gtk_shortcut_new (shortcuts[i].create_trigger_func(),
gtk_callback_action_new (shortcut_activated, row, NULL));
gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller), shortcut);
}
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_widget_destroy (window);
return window;
}

View File

@@ -76,7 +76,7 @@ do_shortcuts (GtkWidget *do_widget)
if (!icons_added)
{
icons_added = TRUE;
gtk_icon_theme_add_resource_path (gtk_icon_theme_get_default (), "/icons");
gtk_icon_theme_add_resource_path (gtk_icon_theme_get_for_display (gtk_widget_get_display (do_widget)), "/icons");
}
g_type_ensure (G_TYPE_FILE_ICON);

View File

@@ -5,7 +5,10 @@
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="margin">50</property>
<property name="margin-start">50</property>
<property name="margin-end">50</property>
<property name="margin-top">50</property>
<property name="margin-end">50</property>
<property name="spacing">10</property>
<child>
<object class="GtkButton">

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