Compare commits

..

817 Commits

Author SHA1 Message Date
Matthias Clasen
276535b381 Revert "modules: Fix build on Visual Studio"
This reverts commit acd9c12667.

This commit breaks the build with GLib main,
we now get complaints about _GLIB_EXTERN being
redefined.

Maybe it is not needed anymore anyway, since
export macros have seen Window-related fixes.
2022-10-20 22:16:59 -04:00
Matthias Clasen
375432f0b6 Merge branch 'columnview-sorter-api' into 'main'
gtk-demo: Add more sort columns

Closes #5149

See merge request GNOME/gtk!5152
2022-10-20 19:18:26 +00:00
Matthias Clasen
c00a23ebbc Merge branch 'fix-wayland-keycode-mapping' into 'main'
wayland: Fix keycode->keyval mapping

Closes #5277

See merge request GNOME/gtk!5147
2022-10-20 19:15:38 +00:00
Matthias Clasen
4cd2e2a11f Merge branch 'ebassi/tree-deprecation-docs' into 'main'
docs: Add deprecation messages to GtkTreeStore

See merge request GNOME/gtk!5115
2022-10-20 18:39:29 +00:00
Matthias Clasen
ae7bf4dcf7 Merge branch 'wip/jtojnar/compose-consistent-system' into 'main'
Improve composetable inclusions

See merge request GNOME/gtk!5150
2022-10-20 18:28:47 +00:00
Matthias Clasen
9ed1505073 columnviewtitle: Clean up interactions
Separate the apis we use for updating title,
menu and sort indicator.
2022-10-20 13:57:33 -04:00
Matthias Clasen
e040d3663e columnviewsorter: Add public API
This API should be sufficient to serialize
a columnviews sort configuration.

Fixes: #5149
2022-10-20 13:06:45 -04:00
Matthias Clasen
6af69a7b7d Make GtkColumnViewSorter public
API is yet to come.
2022-10-20 13:01:18 -04:00
Matthias Clasen
a116e0dd26 columnviewsorter: Cosmetics 2022-10-20 13:01:18 -04:00
Matthias Clasen
3e2b962a36 columnviewcolumn: Add an ID
This string can be used when storing columnview
configuration.
2022-10-20 13:01:18 -04:00
Matthias Clasen
abb60ec579 columnviewcolumn: Remove some unused code 2022-10-20 11:44:05 -04:00
Matthias Clasen
b738d4a6ac columnviewcolumn: Cosmetics 2022-10-20 11:44:05 -04:00
Matthias Clasen
0149bd49ca gtk-demo: Add more sort columns
Add a second sort column to the Settings demo,
to make it easier to test column view sorting.
2022-10-20 11:44:05 -04:00
Emmanuele Bassi
e05157437f Add more messages to the deprecation warnings
Point to replacement types for the old GtkTree* API.
2022-10-20 15:39:07 +01:00
Emmanuele Bassi
e045e798a2 Mark GtkStyleContext type as deprecated
Add the Deprecated tag to the type docblock
2022-10-20 15:39:07 +01:00
Emmanuele Bassi
7908a72fa9 Mark GtkEntryCompletion type as deprecated
Add the Deprecated tag to the type docblock.
2022-10-20 15:39:07 +01:00
Emmanuele Bassi
593bf2bc6d Mark GtkTreeView-related types as deprecated
Add the Deprecated annotation to the type docblock.
2022-10-20 15:39:07 +01:00
Jan Tojnar
cf701d5db4 imcontextsimple: Document that Compose file support is incomplete
And that `include "%L"` does something different as introduced in
3b4b1c6878

Note that user can still use `include "/.%L"` as a workaround.
2022-10-20 16:19:13 +02:00
Emmanuele Bassi
bf8d4c5418 Mark GtkAppChooser-related types as deprecated
The type docblock needs a Deprecated annotation.
2022-10-20 14:38:31 +01:00
Emmanuele Bassi
912145c81b Mark GtkCellRenderer-related types as deprecated
The docblock for the type needs a Deprecated annotation, and we can use
it to point to the appropriate replacement.
2022-10-20 14:38:31 +01:00
Emmanuele Bassi
913127b553 Point at the replacement for GtkIconView
In the symbol annotations and in the docblocks.
2022-10-20 14:38:31 +01:00
Emmanuele Bassi
62f85e2f49 Point at the replacements for GtkTreeView
In the symbol annotations and in the docblocks.
2022-10-20 14:38:31 +01:00
Emmanuele Bassi
4b1212eb4a Point to replacement for GtkComboBoxText
GtkDropDown and GtkStringList replace GtkComboBoxText with a simpler
API.
2022-10-20 14:38:31 +01:00
Jan Tojnar
94a096ec4c composetable: Support non-FHS paths for Compose tables
On platforms like NixOS, the libX11 installation prefix may differ from /usr/share,
breaking the hardcoded placeholders. Let’s re-use the X11 path definition from imcontextsimple.
2022-10-20 12:59:17 +02:00
Emmanuele Bassi
404ee55ec4 Point to GtkDropDown as the GtkComboBox replacement 2022-10-20 11:10:57 +01:00
Emmanuele Bassi
5fbd52da49 docs: Add deprecation message for GtkListStore
Point to GListStore and list models instead.
2022-10-20 11:02:29 +01:00
Emmanuele Bassi
7bf094c117 docs: Add deprecation messages to GtkTreeStore
Point to GtkTreeListModel, and while we're at it, let's fix some of the
gtk-doc-isms that are still there.
2022-10-20 11:02:29 +01:00
Matthias Clasen
4bb79decf3 Merge branch 'label-selection-fix' into 'main'
label: Tweak selection behavior

Closes #2024

See merge request GNOME/gtk!5148
2022-10-19 21:37:08 +00:00
Matthias Clasen
60fb93e063 label: Tweak selection behavior
Arrange for double-click-followed-by-drag to do
select by words, not select-and-dnd. This matches
the behavior in GtkTextView better and feels
intuitive.

Fixes: #2024
2022-10-19 16:22:55 -04:00
Matthias Clasen
1894a8960e wayland: Fix keycode->keyval mapping
We were looping over the levels, but not using
the current level value to obtain the keymap
entries. Oops.

Fixes: #5277
2022-10-19 15:46:27 -04:00
Matthias Clasen
4ba5c90bc9 Merge branch 'filechooser-amberol' into 'main'
filechooser: Improve "Open in File Manager"

Closes #5260

See merge request GNOME/gtk!5140
2022-10-19 19:41:15 +00:00
Matthias Clasen
1d16bd7d30 Merge branch 'matthiasc/for-main' into 'main'
docs: Remove mention of ~/.gtk-4.0

Closes #3266

See merge request GNOME/gtk!5146
2022-10-19 19:11:57 +00:00
Matthias Clasen
17819ad4f6 filechooser: Improve "Open in File Manager"
Just relying on GAppInfo leads to suboptimal
results. Instead, call either the OpenURI portal
or the org.freedesktop.FileManager1 interface
directly, and only fall back to GAppInfo.

The wrapper code for the OpenURI portal is taken
from gio, with small adjustments.

Fixes: #5260
2022-10-19 15:01:21 -04:00
Matthias Clasen
ac1ea6faca docs: Remove mention of ~/.gtk-4.0
We are not looking there anymore, for a long time.

Fixes: #3266
2022-10-19 14:36:48 -04:00
Matthias Clasen
8a3f1a1fa1 Merge branch 'builder-tool-scope' into 'main'
docs: Update gtk4-builder-tool docs

See merge request GNOME/gtk!5145
2022-10-19 18:34:25 +00:00
Matthias Clasen
46c7c0c4e6 docs: Document new buildertool options 2022-10-19 13:36:14 -04:00
Matthias Clasen
dd60a9abd6 buildertool: Support enumerating callbacks
The new scope approach makes this easy, and
it can be useful to know what functions are
needed.
2022-10-19 13:36:14 -04:00
Matthias Clasen
50835ffbf6 buildertool: Improve validate implementation
Reimplement deprecation checking via a scope.
This lets us ignore missing callbacks, and helps
for validating templates.
2022-10-19 13:36:14 -04:00
Matthias Clasen
637713fe72 buildertool: Add a builder scope implementation
This will be used in future commits.
2022-10-19 13:36:14 -04:00
Matthias Clasen
7e71c868ab buildertool: Use --deprecations for templates
Use this option for templates too.

We still can't parse most templates, since they are
missing their callbacks.
2022-10-19 13:36:14 -04:00
Matthias Clasen
aaf5c43e78 Merge branch 'matthiasc/for-main' into 'main'
docs: Update gtk4-builder-tool docs

See merge request GNOME/gtk!5144
2022-10-19 17:13:23 +00:00
Matthias Clasen
5fb6f0e410 Merge branch 'wip/clipboard-serials' into 'main'
gdk/wayland: Use serial of the latest implicit grab available

Closes #5250

See merge request GNOME/gtk!5143
2022-10-19 13:57:19 +00:00
Matthias Clasen
cd031de680 docs: Update gtk4-builder-tool docs
Mention the new --deprecations option of the
validate command.
2022-10-19 08:50:34 -04:00
Carlos Garnacho
eeda25ab04 gdk/wayland: Use serial of the latest implicit grab available
When getting the serial for primary/clipboard selections we used a
function that largely relied on a GdkEvent being passed. We have
another available function that looks up the most recent serial
given the ongoing touch/tablet input as well.

This is the second best, compared to actually knowing the
input/device from the event that was received by the UI an triggered
the clipboard operation, and is already in use in other places
(e.g. window dragging). It is valid for these situations too.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5250
2022-10-19 13:54:07 +02:00
Matthias Clasen
acaf04a24e Merge branch 'builder-deprecations' into 'main'
buildertool: Fix template handling

Closes #5256

See merge request GNOME/gtk!5141
2022-10-19 11:20:37 +00:00
Matthias Clasen
bcabe77799 buildertool: Warn about deprecations
Add a new option --deprecations to the validate
command that will warn about use of deprecated types.

The list of current deprecations is unfortunately
hardcoded in the source, so this list will have to
be kept up-to-date.

Fixes: #5256
2022-10-19 02:51:29 -04:00
Matthias Clasen
64cf31f348 buildertool: Fix template handling
We were not properly parsing the error message
here, leading to badness.
2022-10-19 02:51:29 -04:00
Matthias Clasen
e037155a94 Merge branch 'text-overwrite-undo' into 'main'
testsuite: Fix tiff pixbuf tests

Closes #4411

See merge request GNOME/gtk!5138
2022-10-19 05:59:13 +00:00
Matthias Clasen
55cbb8a8d6 Merge branch 'clarify-gapplication-docs' into 'main'
docs: Clarify a point in GtkApplication docs

See merge request GNOME/gtk!5139
2022-10-19 03:54:36 +00:00
Matthias Clasen
db599f2ae6 Merge branch 'fix-pixbuf-tiff-tests' into 'main'
testsuite: Fix tiff pixbuf tests

Closes #4615

See merge request GNOME/gtk!5137
2022-10-19 03:53:08 +00:00
Matthias Clasen
741567868e Merge branch 'modelbutton-tooltip' into 'main'
widgetfactory: Add text to iconic model buttons

Closes #5220

See merge request GNOME/gtk!5136
2022-10-19 03:51:21 +00:00
Matthias Clasen
1e5e0480fd text: Make overwrite undo-friendly
In overwrite mode, every typed character gets
handled as a delete+insert, but we should not
record these as two individually undoable
steps.

This matches how we handle overwrite mode in
GtkTextView.

Fixes: #4411
2022-10-18 23:49:16 -04:00
Matthias Clasen
917aa7928d docs: Clarify a point in GtkApplication docs
Clarify that loading of automatic resources uses
the resource base path that was set at construction
time.

Fixes: #4300
2022-10-18 23:47:48 -04:00
Matthias Clasen
cd4dbd67a2 testsuite: Skip known-broken tests
The tiff pixbuf tests fail because of known
issues with the pixbuf tiff loader. Skip them.

Fixes: #4615
2022-10-18 23:22:47 -04:00
Matthias Clasen
5a6eab05e9 testsuite: Fix tiff pixbuf tests
This test wasn't actually testing what it claims,
since that functionality is broken in gdk-pixbuf.

Test it anyway.
2022-10-18 23:21:28 -04:00
Matthias Clasen
55ccaf9df9 modelbutton: Set up tooltips
Use the text of iconic model buttons as tooltip.

Fixes: #5220
2022-10-18 22:35:28 -04:00
Matthias Clasen
af0e056eec widgetfactory: Add text to iconic model buttons
We want to use this for tooltips in the future.
2022-10-18 22:35:02 -04:00
Matthias Clasen
77d1f0d982 Merge branch 'matthiasc/for-main' into 'main'
fontchooser: Drop a few errant translations

Closes #5146

See merge request GNOME/gtk!5135
2022-10-19 01:53:56 +00:00
Matthias Clasen
d4d7d5eafd fontchooser: Drop a few errant translations
No point in translating these properties, they
are not strings.

Fixes: #5146
2022-10-18 16:40:37 -04:00
Matthias Clasen
f658027c51 Merge branch 'fix-editable-label-spurious-focus-out' into 'main'
window: Keep a reference to move_focus_widget

Closes #4864

See merge request GNOME/gtk!5134
2022-10-18 19:45:19 +00:00
Matthias Clasen
7be993b728 editablelabel: Defer changes on focus-out
We can get spurious focus-out/-in pairs when
the editable label is in a popover that gets
a Wayland keyboard enter event as a result of
clicking the editable label.

A timeout isn't a great solution, but nothing
better is available right now.

Fixes: #4864
2022-10-18 14:23:22 -04:00
Matthias Clasen
e1d78821f6 window: Keep a reference to move_focus_widget
If we don't take a reference, it can happen that
the pointer is no longer valid by the time we
dereference it in after_paint.
2022-10-18 14:23:11 -04:00
Matthias Clasen
94ac1af293 Merge branch 'fix-focus-changes' into 'main'
window: Fix focus updates

Closes #4903

See merge request GNOME/gtk!5127
2022-10-18 11:02:08 +00:00
Matthias Clasen
b4db48935d Merge branch 'fix-windows-build-testmountoperation' into 'main'
tests/testmountoperation.c: Fix build on Windows

See merge request GNOME/gtk!5126
2022-10-18 10:53:21 +00:00
Matthias Clasen
f5063c1435 window: Don't focus invisible widgets
Only clear a queued move_focus if the widget
we are focusing is actually visible.

This was happening in some cases when popovers
are dismissed by clicking outside, and it was
causing us to miss proper focus updates that
were already queued.
2022-10-18 06:42:17 -04:00
Benjamin Otte
8092a6858e Merge branch 'bilelmoussaoui/gi-deprecated' into 'main'
g-i: Fix deprecated version of GtkTreeView

See merge request GNOME/gtk!5131
2022-10-18 09:53:53 +00:00
Bilal Elmoussaoui
0fbaeaabd0 g-i: Fix deprecated version of GtkTreeView 2022-10-18 11:27:39 +02:00
Luca Bacci
995f00d23f Merge branch 'forward-port-mr-991-to-gtk4-2' into 'main'
Use native Windows API for converting keystrokes to characters

Closes #2944

See merge request GNOME/gtk!4986
2022-10-17 19:20:08 +00:00
Matthias Clasen
100605ef0c window: Fix focus updates
This partially undoes changes from 3dbf5038fa.

That commit did two things:
1) Move the focus update to after-paint time
2) Change from grabbing focus to the visible parent
   to  calling move_focus (TAB)

The second part did have the unintended consequence
of moving focus laterally.

Fixes: #4903
2022-10-17 15:10:41 -04:00
Benjamin Otte
1246cd5e73 Merge branch 'wip/otte/for-main' into 'main'
singleselection: Be more careful about notifies

See merge request GNOME/gtk!5129
2022-10-17 18:34:40 +00:00
Benjamin Otte
f30e59fed9 dropdown: Handle ::selected and ::selected-item separately
GtkSingleSelection will only emit either of those signals if they
change. But it is possible that only one of those properties changes,
and in those cases we want to only notify for that property changing in
the dropdown, too.
2022-10-17 20:11:27 +02:00
Benjamin Otte
5e8b294faf singleselection: Be more careful about notifies
We don't want to notify::selected or notify::selected-item if they
didn't change.
This will bring performance benefits on frequently changing lists.

In particular, if lists get filtered or reordered, but the selected item
stays in the list, not doing a notify::selected-item will avoid updates
in connected handlers like GtkDropdown (and its handlers), thereby
avoiding lots of unnecessary updates.
2022-10-17 20:11:27 +02:00
Philip Zander
c84c469b78 Use native Windows API for converting keystrokes to characters 2022-10-17 19:36:48 +02:00
Chun-wei Fan
1a5a65acd0 tests/testmountoperation.c: Fix build on Windows
Sadly, we can't just use an interger for a GPid on Windows, so just cast
it.  Sounds silly for non-Windows, but that's life...
2022-10-17 12:36:17 +08:00
Matthias Clasen
6f5d18a9f5 macos: Fix clipboard data size handling
We were using the allocated memory size, not
the amount of data that has been written.

Fixes: #5261
2022-10-16 23:45:28 -04:00
Matthias Clasen
004f22a51c Merge branch 'matthiasc/for-main' into 'main'
Rename gtk_widget_get_style_color

See merge request GNOME/gtk!5125
2022-10-17 03:26:21 +00:00
Matthias Clasen
d775caff7f Rename gtk_widget_get_style_color
This name wasn't everybody's favorite, so go with
the generic name gtk_widget_get_color() instead.
2022-10-16 21:41:43 -04:00
Piotr Drąg
baf3a3eecd Update POTFILES.in 2022-10-16 14:34:34 +02:00
Benjamin Otte
ca2e14788d Merge branch 'antoniof-main-patch-03677' into 'main'
columnview: Don't be focusable

See merge request GNOME/gtk!5022
2022-10-14 22:39:49 +00:00
Matthias Clasen
c57d8fc6be Merge branch 'gtk_widget_get_style_color-docs-fix' into 'main'
Fix documentation for `gtk_widget_get_style_color()`

See merge request GNOME/gtk!5119
2022-10-14 10:49:15 +00:00
Sebastian Dröge
294e5bb79f Fix documentation for gtk_widget_get_style_color()
It was pointing at `gtk_widget_get_css_style()` instead.
2022-10-14 12:36:11 +03:00
Matthias Clasen
bde19f9b2a Fix blank popovers
This was a typo in 2b00b64e8c, making
us render the background on the wrong snapshot.
2022-10-13 16:38:41 -04:00
Matthias Clasen
1d2071b892 NEWS: Updates 2022-10-12 23:27:36 -04:00
Matthias Clasen
b46eb5c20a Merge branch 'matthiasc/for-main' into 'main'
filechooser: Update the settings docs

See merge request GNOME/gtk!5118
2022-10-13 03:09:47 +00:00
Matthias Clasen
3d605615ce filechooser: Update the settings docs
Document the window-position setting as unused.
2022-10-12 22:47:51 -04:00
Matthias Clasen
c502d7fca6 Merge branch 'matthiasc/for-main' into 'main'
docs: Add a cross-reference

See merge request GNOME/gtk!5117
2022-10-13 02:43:48 +00:00
Matthias Clasen
9f8abc5d74 docs: Add a cross-reference
Note that GtkTreeView is deprecated and link to the
list view introduction from 'Tree and List Widget Overview'.
2022-10-12 22:26:40 -04:00
Matthias Clasen
c8cbb3fbba Merge branch 'matthiasc/for-main' into 'main'
filechooserentry: Add a set_text api

See merge request GNOME/gtk!5116
2022-10-13 02:25:19 +00:00
Matthias Clasen
fa3c8ed5f9 filechooser: Stop using entrycompletion api
The file chooser entry now has an api for this.
2022-10-12 21:59:35 -04:00
Matthias Clasen
8ac5f1983e filechooserentry: Add a set_text api
This function prevents the completion popup
from coming up when setting the entry text.
2022-10-12 21:59:19 -04:00
Matthias Clasen
eccc02d084 Merge branch 'matthiasc/for-main' into 'main'
Start a migration guide for GTK 5

See merge request GNOME/gtk!5114
2022-10-12 21:02:56 +00:00
Matthias Clasen
0c94db7147 Start a migration guide for GTK 5
No need to panic, GTK 5 is still years away!
But it is good to write this material down while
it is fresh in mind.
2022-10-12 16:39:28 -04:00
Matthias Clasen
ed87473bf9 Merge branch 'deprecate-render' into 'main'
wip: Deprecate gtk_render apis

See merge request GNOME/gtk!5100
2022-10-12 20:38:19 +00:00
Matthias Clasen
812a879ec2 inspector: Use gtk_widget_get_style_color
The graph renderer in the statistics page needs
the CSS foreground color to draw the graph. Use
the just introduced api for it.
2022-10-12 15:35:00 -04:00
Matthias Clasen
5627542d7c Add gtk_widget_get_style_color
There is a widespread need to access the CSS foreground
color for custom drawing in snapshot functions, so make
it available after gtk_style_context_get_color was
deprecated with a new widget api.
2022-10-12 15:35:00 -04:00
Matthias Clasen
f42fe500c9 cssnode: Avoid style context api
Duplicate the print flags in gtkcssnodeprivate.h,
so we don't rely on gtkstylecontext.h here.
2022-10-12 15:35:00 -04:00
Matthias Clasen
ac3177ce95 tests: Ignore deprecations
Some of our tests use deprecated style context api.
Most of them should be ported to use global style
providers eventually. For now, ignore deprecations.
2022-10-12 15:35:00 -04:00
Matthias Clasen
ccaaff406f testsuite: Ignore deprecations
Some of our tests use deprecated style context
apis. Ignore the deprecations for now.
2022-10-12 15:35:00 -04:00
Matthias Clasen
b1ec43ae33 demos: Ignore deprecations
Most of these demos should be ported to use
global style providers eventually. For now,
just ignore the deprecations.
2022-10-12 15:35:00 -04:00
Matthias Clasen
ee8c2a235f stylecontext: Deprecate most apis
The notable exception here are the global provider apis,
which are needed in some form and don't have a replacement
yet. Move them to gtkstyleprovider.[hc], so we can wholly
deprecated gtkstylecontext.[hc].
2022-10-12 15:35:00 -04:00
Matthias Clasen
299fbfd722 tests: Ignore deprecations for render api 2022-10-12 15:35:00 -04:00
Matthias Clasen
5f54ecdf2c aboutdialog: Stop using gtk_style_context_save 2022-10-12 15:35:00 -04:00
Matthias Clasen
e09138ce45 textview: Stop using gtk_style_context_save_to_node 2022-10-12 15:35:00 -04:00
Matthias Clasen
a71893f88b text: Stop using gtk_style_context_save_to_node 2022-10-12 15:35:00 -04:00
Matthias Clasen
01324ffaff label: Stop using gtk_style_context_save_to_node 2022-10-12 15:35:00 -04:00
Matthias Clasen
c354465ed8 scrolledwindow: Stop using gtk_style_context_save_to_node 2022-10-12 15:35:00 -04:00
Matthias Clasen
50ab2386ec printunixdialog: Stop using gtk_style_context_save_to_node 2022-10-12 15:35:00 -04:00
Matthias Clasen
bf9f362597 popover: Stop using gtk_style_context_save_to_node 2022-10-12 15:35:00 -04:00
Matthias Clasen
d03ee57cc5 flowbox: Stop using gtk_style_context_save_to_node 2022-10-12 15:35:00 -04:00
Matthias Clasen
6f24bd9ff4 demos: Ignore deprecations for render apis
Eventually, this demo should probably be removed.
2022-10-12 15:35:00 -04:00
Matthias Clasen
616e0a0d32 textview: Stop using gtk_snapshot_render api
The gtk_snapshot_render api is deprecated, so avoid using it.
2022-10-12 15:35:00 -04:00
Matthias Clasen
ee76105119 text: Stop using gtk_snapshot_render api
The gtk_snapshot_render api is deprecated, so avoid using it.
2022-10-12 15:35:00 -04:00
Matthias Clasen
381f863a18 label: Stop using gtk_snapshot_render api
The gtk_snapshot_render api is deprecated, so avoid using it.
2022-10-12 15:35:00 -04:00
Matthias Clasen
57c63d9ce7 Use the new caret rendering api
Implement the deprecated gtk_snapshot_render api
for carets with the new one.
2022-10-12 15:35:00 -04:00
Matthias Clasen
0522dade9f Add gtk_css_style_snapshot_caret 2022-10-12 15:35:00 -04:00
Matthias Clasen
484cff2182 glarea: Stop using gtk_snapshot_render api
The gtk_snapshot_render api is deprecated, stop using it.
2022-10-12 15:35:00 -04:00
Matthias Clasen
dd3c371c08 inscription: Stop using gtk_snapshot_render api
The gtk_snapshot_render api is deprecated, so avoid using it.
2022-10-12 15:35:00 -04:00
Matthias Clasen
3145bce6a1 render: Use the new layout render api 2022-10-12 15:35:00 -04:00
Matthias Clasen
73f991a7fd Add gtk_css_style_snapshot_layout
This function renders a PangoLayout at a given
position, using text shadows and color from css.
2022-10-12 15:35:00 -04:00
Matthias Clasen
0205caa371 scrolledwindow: Port to the gtk_css_style_snapshot api
The gtk_snapshot_render api is deprecated, so avoid using it.
2022-10-12 15:35:00 -04:00
Matthias Clasen
c2c46a7036 printunixdialog: Port to the gtk_css_style_snapshot api
The gtk_snapshot_render api is deprecated, so avoid using it.
2022-10-12 15:35:00 -04:00
Matthias Clasen
2b00b64e8c popover: Port to the gtk_css_style_snapshot api
The gtk_snapshot_render api is deprecated, so avoid using it.
2022-10-12 15:35:00 -04:00
Matthias Clasen
4e2522a080 iconview: Port to the gtk_css_style_snapshot api
The gtk_snapshot_render api is deprecated, so avoid using it.
2022-10-12 15:35:00 -04:00
Matthias Clasen
473065dfeb flowbox: Port to the gtk_css_style_snapshot api
The gtk_snapshot_render api is deprecated, so avoid using it.
2022-10-12 15:35:00 -04:00
Matthias Clasen
60dafebd91 Deprecate gtk_snapshot_render apis
Move the implementations from gtksnapshot.c to
gtk/deprecated/gtkrender.c and deprecated these
functions. We want to get rid of them.

These functions are still used in some of our widgetry,
so use G_GNUC_BEGIN/END_IGNORE_DEPRECATIONS around
them.
2022-10-12 15:35:00 -04:00
Matthias Clasen
35370752d5 Deprecate gtk_render apis
These take a GtkStyleContext as argument, and we
want to get rid of GtkStyleContext eventually.
The proper drawing api these days is gtk_snapshot.
2022-10-12 15:35:00 -04:00
Matthias Clasen
808d00906c printunixdialog: Stop using gtk_render_ apis
These are getting deprecated.
2022-10-12 15:35:00 -04:00
Matthias Clasen
da5d5bd71f popover: Stop using gtk_render_background
The gtk_render_ apis are getting deprecated.
2022-10-12 15:34:59 -04:00
Matthias Clasen
0c99e69423 flowbox: Stop using gtk_render_background
The gtk_render_ apis are getting deprecated.
2022-10-12 15:34:59 -04:00
Matthias Clasen
410813eb6b Merge branch 'deprecate-all-the-cells' into 'main'
Deprecate treeviews and cell renderers

See merge request GNOME/gtk!5098
2022-10-12 19:28:04 +00:00
Luca Bacci
6cc44eb0fe Merge branch 'for-master' into 'main'
For master

See merge request GNOME/gtk!5095
2022-10-12 13:56:51 +00:00
Matthias Clasen
11ee930b9d Merge branch 'inspector_a11y' into 'main'
GtkInspector: make the inspector at least a little bit more accessible

See merge request GNOME/gtk!5109
2022-10-12 11:06:35 +00:00
Matthias Clasen
69e4c9b01e tests: Ignore deprecations
Eventually, most of these tests should be dropped.
2022-10-11 17:18:21 -04:00
Matthias Clasen
c32fed9238 testsuite: Ignore deprecations
For now, just ignore deprecations. Eventually,
we will have to go through, drop demos that are
for wholly deprecated widgets, and update others.
2022-10-11 17:18:21 -04:00
Matthias Clasen
4941ef659f tools: Ignore deprecations
For now, just ignore deprecations. Eventually,
we will have to go through and drop code that is
dealing with widgets that are going away.
2022-10-11 17:18:21 -04:00
Matthias Clasen
6efb18330f demos and examples: Ignore deprecations
For now, just ignore deprecations. Eventually,
we will have to go through, drop demos that are
for wholly deprecated widgets, and update others.
2022-10-11 17:18:21 -04:00
Matthias Clasen
5e256590db Deprecate treeviews and cell renderers
This includes

GtkCellArea
GtkCellAreaBox
GtkCellAreaContext
GtkCellEditable
GtkCellRenderer
GtkCellRendererAccel
GtkCellRendererCombo
GtkCellRendererPixbuf
GtkCellRendererProgress
GtkCellRendererSpin
GtkCellRendererSpinner
GtkCellRendererText
GtkCellRendererToggle
GtkCellView
GtkComboBox
GtkComboBoxText
GtkIconView
GtkListStore
GtkTreeModel
GtkTreeModelFilter
GtkTreeModelSort
GtkTreeStore
GtkTreeView
GtkTreeViewColumn
GtkTreeSelection
2022-10-11 17:18:21 -04:00
Matthias Clasen
79303d7cd3 inspector: Drop an unused file 2022-10-11 17:18:21 -04:00
Matthias Clasen
681a818af2 flowbox: Stop using gtk_render_background
The gtk_render_ apis are getting deprecated.
2022-10-11 17:18:21 -04:00
Matthias Clasen
933b1eb4df Merge branch 'filename-sorter' into 'main'
stringsorter: Add a collate-mode property

See merge request GNOME/gtk!5111
2022-10-11 20:59:08 +00:00
Matthias Clasen
c419b57754 stringsorter: Fix up a doc typo
gi-docgen links can be tricky to get right.
2022-10-11 15:32:05 -04:00
Matthias Clasen
05323869d7 stringsorter: Add more detail to the docs
Mention when a collation value of NONE might
be useful.
2022-10-11 14:09:21 -04:00
Matthias Clasen
2520148ebb Apply 2 suggestion(s) to 2 file(s) 2022-10-11 17:53:26 +00:00
Matthias Clasen
a06a4ad59a ci: Allow macos builds to fail
The runner seems busted, so allow builds to fail
for now.
2022-10-11 13:43:36 -04:00
Matthias Clasen
141aac1a60 stringsorter: Add a collation property
The new property lets us choose between
Unicode collation, filename collation, and
plain strcmp.

This will be used in the filechooser.
2022-10-11 13:42:00 -04:00
Lukáš Tyrychtr
8a1578ede8 GtkInspector: make the inspector at least a little bit more accessible
Namely, it adds accessible name to the property value editors and to a few labels in the a11y panel.
2022-10-11 13:34:53 +02:00
Matthias Clasen
8ba7840528 Merge branch 'wip/corey/file-clipboard' into 'main'
gdkcontentserializer: Use newlines for file separators

Closes #5240

See merge request GNOME/gtk!5107
2022-10-10 21:13:28 +00:00
Corey Berla
3168a3e086 gdkcontentserializer: Use newlines for file separators
Use newlines rather than spaces to separate file paths (or uri's)
when serializing text/plain files.  There isn't a matching
deserializer, so we can do this in isolation.  Newlines
seem to make more sense when pasting into a text editor etc.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5240
2022-10-10 13:27:07 -07:00
Matthias Clasen
3cf9149129 Merge branch 'matthiasc/for-main' into 'main'
Matthiasc/for main

See merge request GNOME/gtk!5106
2022-10-10 03:29:41 +00:00
Matthias Clasen
7c8a098852 emojicompletion: Drop an unused include 2022-10-09 23:08:55 -04:00
Matthias Clasen
ecbdb3104a emojichooser: Drop an unused include 2022-10-09 23:03:43 -04:00
Matthias Clasen
c8a332b3af searchentry: Drop an unused include 2022-10-09 23:03:36 -04:00
Matthias Clasen
b5f7d57124 Merge branch 'matthiasc/for-main' into 'main'
gtk-demo: Modernize accordion demo

See merge request GNOME/gtk!5105
2022-10-09 14:26:58 +00:00
Benjamin Otte
0db5c7f421 testgtk: Use global css provider 2022-10-09 10:13:44 -04:00
Benjamin Otte
ed83272f35 tests: Use per-screen CSS providers 2022-10-09 10:13:10 -04:00
Benjamin Otte
20b49e7c34 gtk-demo: Modernize accordion demo 2022-10-09 10:09:59 -04:00
Matthias Clasen
6a6ef0f437 Merge branch 'matthiasc/for-main' into 'main'
inspector: Fix some criticals

See merge request GNOME/gtk!5104
2022-10-09 13:53:54 +00:00
Benjamin Otte
32ef462f1d fontbutton: Use attributes for custom font
Don't try to use CSS.
2022-10-09 09:10:39 -04:00
Matthias Clasen
b895360f49 inspector: Fix some criticals
This is fallout from the recent porting to GtkColumnView.
2022-10-09 09:10:39 -04:00
Matthias Clasen
c2c094e8a1 Merge branch 'matthiasc/for-main' into 'main'
widget: Changing the scale does no longer require a redraw

See merge request GNOME/gtk!5103
2022-10-09 13:10:24 +00:00
Benjamin Otte
d4d0192405 widget: Changing the scale does no longer require a redraw
It doesn't require one generally anyway, because only the root can
change scale and when that happens the root will queue a redraw.

But even if the root doesn't queue a redraw, render nodes (the only
thing discarded by queue_draw()) are scale-independant.
2022-10-09 08:50:32 -04:00
Matthias Clasen
15ea36e7fd Merge branch 'matthiasc/for-main' into 'main'
glarea: Drop an unused include

See merge request GNOME/gtk!5102
2022-10-09 12:49:42 +00:00
Matthias Clasen
692279586a Merge branch 'main' into 'main'
GtkPaned: Fix symbol names in code example

See merge request GNOME/gtk!5101
2022-10-09 12:22:08 +00:00
Matthias Clasen
9eec475dcc glarea: Drop an unused include
We are not using gtk_render apis here.
2022-10-09 08:10:12 -04:00
Tilo Villwock
661130d429 GtkPaned: Fix symbol names in code example 2022-10-08 13:49:10 +02:00
Matthias Clasen
68b73ebf91 Merge branch 'matthiasc/for-main' into 'main'
paperdialog: Drop an unused function

See merge request GNOME/gtk!5099
2022-10-08 03:01:24 +00:00
Matthias Clasen
08c0020ac3 placesview: Stop using GtkEntryCompletion
We want to get rid of tree models and cell renderers,
and that includes GtkEntryCompletion. The functionality
here is really not that essential.
2022-10-07 22:22:36 -04:00
Matthias Clasen
ac87c72797 paperdialog: Drop an unused function
This gets rid of a GtkListStore use.
2022-10-07 22:03:15 -04:00
Matthias Clasen
5be8710774 Merge branch 'inspector-trees' into 'main'
inspector: Stop using GtkTreeView for css nodes

See merge request GNOME/gtk!5097
2022-10-07 21:55:10 +00:00
Matthias Clasen
5fa027ab8a cssnode: Drop the node-added/-removed signals
These are no longer used, and the children-observer
listmodel is a better approach for monitoring the
children.
2022-10-07 17:21:04 -04:00
Matthias Clasen
dbe04adb1a inspector: Drop the css node tree model
This is not used anymore.
2022-10-07 17:17:41 -04:00
Matthias Clasen
6815f3af6d inspector: Stop using GtkTreeView for css nodes
Replace the css node tree with a GtkColumnView, using
the new gtk_css_node_observe_children api.
2022-10-07 15:54:02 -04:00
Matthias Clasen
f8357512d0 Add gtk_css_node_observe_children 2022-10-07 15:54:01 -04:00
Luca Bacci
8bfc19e7f7 GtkFileChooserNativeWin32: Add some option flags
Avoid changing the current directory.
Also avoid creating a sample file to test if the target file
can be created.

References:

* "Why does the common file dialog change the current directory?"
 -> https://devblogs.microsoft.com/oldnewthing/20101112-00/?p=12293

* "Why does the common file save dialog create a temporary file and then delete it?"
 -> https://devblogs.microsoft.com/oldnewthing/20140429-00/?p=1123
2022-10-07 19:06:09 +02:00
Luca Bacci
d6f7449636 GdkWin32: Return TRUE when processing WM_XBUTTONDOWN/UP messages
As documented on MSDN:

> Unlike the WM_LBUTTONUP, WM_MBUTTONUP, and WM_RBUTTONUP messages, an
> application should return TRUE from this message if it processes it.
2022-10-07 19:05:29 +02:00
Luca Bacci
f4286e8f1a GdkWin32: Use gdk_pixbuf_read_pixels () where applicable
This is an optimization in case of reading unmodifiable GdkPixbufs.
Also replace uses of GLib integral types with <stdlib.h> integral
types.
2022-10-07 19:05:29 +02:00
Matthias Clasen
14e6fd1f12 Merge branch 'wroy-main-patch-03767' into 'main'
Add subproject/libjpeg-turbo.wrap

Closes #5237

See merge request GNOME/gtk!5094
2022-10-07 16:00:36 +00:00
William Roy
2e57621fc5 Add subproject/libjpeg-turbo.wrap 2022-10-07 14:48:49 +00:00
Matthias Clasen
4a8ae3a20c Merge branch 'inspector-trees' into 'main'
inspector: Stop using GtkTreeView for statistics

See merge request GNOME/gtk!5093
2022-10-07 05:57:02 +00:00
Matthias Clasen
61393fdcce inspector: Stop using GtkTreeView for statistics
GtkTreeView is heading towards deprecation; use
a GtkColumnView instead.
2022-10-07 01:40:51 -04:00
Matthias Clasen
6ed6cebcf4 inspector: Fixup
We were overlooking a transfer full here.
2022-10-07 00:12:47 -04:00
Jürgen Benvenuti
2f764f6c18 Update German translation
(cherry picked from commit 52dd917c6a)
2022-10-06 20:48:36 +00:00
Matthias Clasen
a646e50019 Merge branch 'main' into 'main'
Treat XKB_MOD_NAME_LOGO as super key

Closes #4913

See merge request GNOME/gtk!5088
2022-10-06 10:41:56 +00:00
Po Lu
e967dfed2d Treat XKB_MOD_NAME_LOGO as super key 2022-10-06 11:19:31 +04:00
Matthias Clasen
2dc33a9de1 Merge branch 'matthiasc/for-main' into 'main'
gdk: Cosmetics

See merge request GNOME/gtk!5087
2022-10-06 03:48:36 +00:00
Matthias Clasen
7c5e1c6195 gtk: Rename some private headers
Improve the consistency of our private header
naming, by add 'private' to a bunch of them.
2022-10-05 23:01:28 -04:00
Matthias Clasen
8607312fef gdk: Cosmetics
Add a define for each renderer.
2022-10-05 23:01:28 -04:00
Matthias Clasen
abac891bd2 Merge branch 'inspector-trees' into 'main'
inspector: Stop using a treeview for css properties

See merge request GNOME/gtk!5086
2022-10-06 02:52:12 +00:00
Matthias Clasen
2e25a13fc0 Merge branch 'matthiasc/for-main' into 'main'
mountoperation: Add a mnemonic to a button

See merge request GNOME/gtk!5085
2022-10-06 02:15:16 +00:00
Matthias Clasen
7a2c4e8a38 inspector: Stop using a treeview for css properties
Treeviews are heading towards deprecation.
2022-10-05 22:12:57 -04:00
Matthias Clasen
90e0ace325 inspector: Cosmetics 2022-10-05 21:20:04 -04:00
Matthias Clasen
9a2a5d9c8b mountoperation: Add a mnemonic to a button
This is a good practice, even if this is a rarely
used dialog.
2022-10-05 20:14:09 -04:00
Matthias Clasen
d4dd0dcd79 Merge branch 'accessible_range_interface' into 'main'
Introduce GtkAccessibleRange

See merge request GNOME/gtk!5066
2022-10-05 11:33:56 +00:00
Matthias Clasen
d454586927 Review fixes 2022-10-05 11:13:21 +00:00
Matthias Clasen
1917b6a0a3 Merge branch 'matthiasc/for-main' into 'main'
inspector: Use more compact list styles

See merge request GNOME/gtk!5083
2022-10-05 10:14:04 +00:00
Matthias Clasen
a924b820c2 inspector: Use more compact list styles
Use the same style classes throughout for
data lists that benefit from smaller fonts.
2022-10-04 23:25:12 -04:00
Matthias Clasen
9e82d2b843 Merge branch 'inspector-menus' into 'main'
Drop unused includes

See merge request GNOME/gtk!5082
2022-10-05 03:11:41 +00:00
Matthias Clasen
ab7a04d89f inspector: Stop using a treeview for menus
Replace this with a GtkColumnView.
2022-10-04 22:49:05 -04:00
Matthias Clasen
a377f95aac Drop unused includes
This gets rid of treeview includes in a number of places.
2022-10-04 22:49:05 -04:00
Matthias Clasen
4356e0c3ce Merge branch 'mountoperation-trees' into 'main'
mountoperation: Survive on Wayland

See merge request GNOME/gtk!5081
2022-10-05 02:48:39 +00:00
Matthias Clasen
5d5de9f759 mountoperation: Don't use a treeview
Port the process list from GtkTreeView
to GtkListView, and fix a number of broken
things along the way.
2022-10-04 21:26:07 -04:00
Matthias Clasen
e1f69ea278 testmountoperation: Test process dialog
Without this, it is hard to trigger the
dialog. Event with this, we have to force
GtkMountOperation to use its own dialog.
2022-10-04 21:26:07 -04:00
Matthias Clasen
6a76fe41c6 mountoperation: Survive on Wayland
The code was assuming it is dealing with an
X11 display, and trigger assertions. Fix that
to make it work at least as well as it does
on Windows.
2022-10-04 21:26:07 -04:00
Matthias Clasen
aae82d7992 Merge branch 'inspector-trees' into 'main'
inspector: Don't use treeviews in the recorder

See merge request GNOME/gtk!5080
2022-10-04 20:54:10 +00:00
Matthias Clasen
ca576e877f inspector: Don't use treeviews in the recorder
Replace the event and render node details views with
columnviews.
2022-10-04 16:26:28 -04:00
Alexander Shopov
bc23038848 Update Bulgarian translation
(cherry picked from commit 2ca2a15637)
2022-10-04 18:07:24 +00:00
Matthias Clasen
43e8730acd Merge branch 'inspector-fixes' into 'main'
inspector: Fix some lifecycle issues

See merge request GNOME/gtk!5079
2022-10-04 15:34:53 +00:00
Piotr Drąg
c43def5fce Update POTFILES.in 2022-10-04 15:20:57 +02:00
Matthias Clasen
e68b365fa1 inspector: Fix some lifecycle issues
The template use in the inspector was not properly
disposing all widgets. gtk_widget_dispose_template
will only unparent widgets that have been named
as template children, so we need to make the toplevel
elements in the ui file named children, or manually
dispose them. This commit does the former.
2022-10-04 07:10:35 -04:00
Matthias Clasen
3867f9b8ea Merge branch 'deprecate-entry-completion' into 'main'
Deprecate GtkEntryCompletion

See merge request GNOME/gtk!5078
2022-10-04 03:35:26 +00:00
Matthias Clasen
0b20c57867 Merge branch 'deprecate-app-choosers' into 'main'
Deprecate app choosers

See merge request GNOME/gtk!5077
2022-10-04 03:28:09 +00:00
Matthias Clasen
7e9ca5b41d Deprecate GtkEntryCompletion
We want to drop cell renderers and tree models
in GTK 5. The functionality of GtkEntryCompletion
may be replaced by a new widget in GTK 5.
2022-10-03 23:23:56 -04:00
Matthias Clasen
a527a4d82e Deprecate the app chooser widgets
These are a family of pretty specialized widgets, and
are very rarely used. Instead of porting them away
from GtkTreeView and GtkComboBox, deprecate them.
2022-10-03 23:02:09 -04:00
Matthias Clasen
adfc29968a Revert "gtk: Use gnome.mkenums_simple"
This reverts commit 11829fe7d0.

The mkenums_simple function can't properly handle headers
in subdirectories currently, so go back to the template
version.
2022-10-03 22:20:07 -04:00
Benjamin Otte
e17e94d2da Merge branch 'oh-no-my-docs' into 'main'
Remove outdated docs

See merge request GNOME/gtk!5076
2022-10-03 22:21:48 +00:00
Benjamin Otte
9af3bb8dc1 Remove outdated docs
There are a lot of automatic conversions in the blame log.
2022-10-03 21:12:42 +00:00
Matthias Clasen
998dd11cbd Merge branch 'wip/jimmac/combobox-lists' into 'main'
stylesheet: sync combox with other popovers

Closes #5221

See merge request GNOME/gtk!5074
2022-10-03 21:02:25 +00:00
António Fernandes
9cb8d21cb5 columnview: Forward all focus to child
For the same reasoning as the preceding commit.

Also don't make GtkColumnView focusable. Its internal list view
is already focusable, which is enough to take care of the empty
view case.
2022-10-03 20:48:10 +01:00
António Fernandes
4fc4298920 listbase: Grab focus on items instead of container
The container view itself being focusable makes keyboard navigation
slower by adding a useless focus step.

It also means if an item gets removed, the focus jumps back to the view,
instead of jumping to the next item, as seen in nautilus bug report:
https://gitlab.gnome.org/GNOME/nautilus/-/issues/2489

Instead of making the GtkListBase container itself focusable, override
the .grab_focus() vfunc. This way, calling gtk_widget_grab_focus() on
the view container keeps working sucessfully, but focuses the focus
item directly instead.

This is particularly useful to have because applicaiton authors do
not have direct acess to this class's children, so they can't call
gtk_widget_grab_focus() on them directly.
2022-10-03 20:26:24 +01:00
Jakub Steiner
a96c75ff02 stylesheet: sync combox with other popovers
- use the same lists style as everything else (menus, sidebars ...)

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/5221
2022-10-03 15:43:07 +02:00
Carlos Garnacho
1b4ed00509 Merge branch 'evince_crash_popover_motion2' into 'main'
fix crash in gtk_synthesize_crossing_events()

Closes #5190

See merge request GNOME/gtk!5052
2022-10-03 12:19:35 +00:00
Fabio Tomat
a54284b629 Update Friulian translation
(cherry picked from commit 6387863256)
2022-10-03 08:35:56 +00:00
Goran Vidović
ee9e9bb3e1 Update Croatian translation 2022-10-02 14:05:29 +00:00
Aleksandr Melman
cae9689281 Update Russian translation 2022-10-01 15:40:59 +00:00
Emin Tufan Çetin
1f6e2cf291 Update Turkish translation 2022-10-01 14:57:10 +00:00
Zurab Kargareteli
69a76054e8 Update Georgian translation 2022-10-01 10:17:09 +00:00
Emmanuele Bassi
31fea11255 a11y: Drop GtkAccessibleRange.get_minimum_increment()
MinimumIncrement is an AT-SPI-ism that has no counterpart in the ARIA
specification, so it should not live inside public API. Additionally,
it's not really a useful method because it collapses two values on the
adjustment API.

The only method in the GtkAccessibleRange interface should be the
set_current_value(), which allows ATs to control the current position in
a ranged widget.

The AT-SPI implementation can now use all the accessible properties,
including the VALUE_TEXT one, mapped to the Text property on the
AtSpi.Value interface.
2022-09-30 18:36:02 +01:00
Emmanuele Bassi
5dd7e24806 Clean up GtkAccessibleRange
Coding style and documentation fixes.
2022-09-30 16:58:00 +01:00
Goran Vidović
848dc78112 Update Croatian translation 2022-09-30 12:05:09 +00:00
Matthias Clasen
e9d7cd3a48 Merge branch 'wip/handle-zero-bounds' into 'main'
Fix shrinking windows when suspending

See merge request GNOME/gtk!5069
2022-09-30 11:26:29 +00:00
Jonas Ådahl
b3a3a6ceb1 toplevel-size: Report zero bounds as infinite
Empty/zero bounds are sent by the Wayland compositor if there are no
valid bounds to report, e.g. if there are no connected monitors. Report
this to GTK, which uses this to clamp calculated sizes, as INT_MAX, so
that clamping isn't done until there are actual valid bounds to clamp
to.

This fixes clients sometimes shrinking to their minimum size during
hotplugs or after having suspended the session.
2022-09-30 09:31:40 +02:00
Jonas Ådahl
148c133674 surface/wayland: Handle no current monitor when calculating bounds
We shouldn't assume there is always a monitor to derive bounds from.
If there is no monitor, pass empty bounds, as this matches what
xdg_toplevel.configure_bounds do in this case.
2022-09-30 09:31:40 +02:00
Asier Sarasua Garmendia
d2c9cbba4f Update Basque translation 2022-09-29 16:55:20 +00:00
Balázs Úr
8b33900e1d Update Hungarian translation 2022-09-29 16:43:31 +00:00
Nart Tlisha
0c3572312a Update Abkhazian translation 2022-09-29 15:19:37 +00:00
Lukáš Tyrychtr
7e683ed89b Use proper version specifier 2022-09-29 09:55:10 +02:00
Lukáš Tyrychtr
7fb892460a Document that this will be available only in GTK 4.10 2022-09-29 09:36:09 +02:00
Lukáš Tyrychtr
d517804acd Actually use the AccessibleRange interface 2022-09-29 09:36:09 +02:00
Lukáš Tyrychtr
ce761122b2 Implement also for GtkPaned 2022-09-29 09:36:09 +02:00
Lukáš Tyrychtr
76a5354ad7 Implement GtkAccessibleRange for GtkScaleButton 2022-09-29 09:36:08 +02:00
Lukáš Tyrychtr
006b473c0c Improve documentation 2022-09-29 09:36:08 +02:00
Lukáš Tyrychtr
5e1af6d7d5 Implement GtkAccessibleRange for GtkProgressBar 2022-09-29 09:36:08 +02:00
Lukáš Tyrychtr
ec0cd4a994 Implement GtkAccessibleRange for GtkLevelBar 2022-09-29 09:36:08 +02:00
Lukáš Tyrychtr
86864d7bc0 Account for GtkAccessibleRange implementations which do not have a
minimum step and it makes no sense for them to set the current value
2022-09-29 09:36:08 +02:00
Lukáš Tyrychtr
485ffcde38 Implement GtkAccessibleRange for GtkSpinButton 2022-09-29 09:36:08 +02:00
Lukáš Tyrychtr
0304eaec94 Implement GtkAccessibleRange for GtkRange 2022-09-29 09:36:08 +02:00
Lukáš Tyrychtr
a7814a0963 Introduce GtkAccessibleRange
This introduces GtkAccessibleRange, an interface which allows the accessibility backend to work with a control which can adjust a value.
2022-09-29 09:36:08 +02:00
Zurab Kargareteli
160a83023a Update Georgian translation 2022-09-28 18:33:41 +00:00
Matthias Clasen
911abe2d2c Fix expected test output
The major.minor version number shows up in the expected
output of this test, so it needs to be adjusted at the
beginning of every cycle.
2022-09-28 13:32:40 -04:00
Matthias Clasen
0c02573c47 Add 4.10 version macros 2022-09-28 13:30:01 -04:00
Matthias Clasen
4257e1ce4f Post-release version bump
This is an experiment to see if I can keep up with
doing post-release version bumps, so git snapshots
will always have a different version from released
tarballs.

This commit also marks the beginning of the 4.10
development cycle, as 4.8 has been branched.
2022-09-28 13:19:49 -04:00
Matthias Clasen
39bc13c8a7 Merge branch 'matthiasc/for-main' into 'main'
Add more names to sources

See merge request GNOME/gtk!5064
2022-09-28 17:02:09 +00:00
Matthias Clasen
dd7cd6ffdd Add more names to sources
This helps with identifying things in sysprof logs,
and while debugging.
2022-09-28 12:37:21 -04:00
Matthias Clasen
349cda3d36 Merge branch 'post-install' into 'main'
meson: Remove post-install script

See merge request GNOME/gtk!5063
2022-09-28 16:21:49 +00:00
Xavier Claessens
48cc56081d meson: Remove post-install script
GTK depends on Meson >= 0.60 so it was never used.
2022-09-28 11:25:43 -04:00
Matthias Clasen
aa9a7a931d Merge branch 'wip/carlosg/shuffle-reset-take2' into 'main'
gtkimcontextwayland: Shuffle full resets after IM changes

Closes #5200

See merge request GNOME/gtk!5050
2022-09-28 01:39:49 +00:00
Matthias Clasen
3aee45de28 Merge branch 'wroy-main-patch-32519' into 'main'
Fix #5211: Preprocessor conformance with MSVC

Closes #5211

See merge request GNOME/gtk!5058
2022-09-28 01:39:15 +00:00
Matthias Clasen
5f469d8903 Merge branch 'broadway-device-query-state-fix' into 'main'
GTK4 gdk/broadway: correct gdk_broadway_device_query_state() to return pointer coordinates relative to the upper left corner of surface

See merge request GNOME/gtk!5053
2022-09-28 01:38:45 +00:00
Matthias Clasen
2ce2e90205 Merge branch 'fix-scale-crashes' into 'main'
scale: Fix a typo

See merge request GNOME/gtk!5061
2022-09-28 01:22:49 +00:00
Matthias Clasen
8b76cc841d scale: Fix a typo
We want to update the label size request when
the adjustment changes, not when anything else
changes.

This may be the reason for crash reports like
https://retrace.fedoraproject.org/faf/problems/bthash/?bth=1e5cc1318358d5db298e5d6c2ec47361922cce74
2022-09-27 21:03:56 -04:00
Aurimas Černius
75b1d75751 Updated Lithuanian translation 2022-09-27 22:40:49 +03:00
Hugo Carvalho
2d19a1f1ec Update Portuguese translation 2022-09-27 19:39:53 +00:00
Rafael Fontenelle
e57d005076 Update Brazilian Portuguese translation 2022-09-27 13:10:05 +00:00
Matthias Clasen
31d483dfbc Apply 1 suggestion(s) to 1 file(s) 2022-09-27 11:31:55 +00:00
Martin
fc2cb9d063 Update Slovenian translation 2022-09-27 08:03:24 +00:00
Fran Dieguez
91cc03a81a Update Galician translation 2022-09-27 06:22:18 +00:00
Benjamin Otte
67049c3261 Merge branch 'wip/otte/for-main' into 'main'
drop target: Warn about broken signal handler returns

See merge request GNOME/gtk!5060
2022-09-27 02:07:21 +00:00
Benjamin Otte
c98cea3dbb drop target: Warn about broken signal handler returns
Signal handlers ust return their preferred action and that one must be
unique.

Shout at them if they don't do that, before gdk_drop_status() does
tesame thing.

Related: gnome-build-meta#554
Related: gnome-builder#1799
2022-09-27 03:50:29 +02:00
Emmanuele Bassi
0a67ac6d47 Merge branch 'left-right-typo' into 'main'
Fix GtkSettings docs typo

See merge request GNOME/gtk!5059
2022-09-26 22:23:29 +00:00
Mitchell Hentges
f8c0d86d6c Fix GtkSettings docs typo
"left of right" should be "left or right".
There's a small (subjective?) English nit in there as well: I believe
that buttons are placed (for example) "on the right" rather than "at the
right".
2022-09-27 00:00:30 +02:00
William Roy
872e04f94e Fix preprocessor conformance with MSVC 2022-09-26 19:52:57 +00:00
Goran Vidović
d5c60438d1 Update Croatian translation 2022-09-26 19:30:45 +00:00
Anders Jonsson
60788913da Update Swedish translation 2022-09-26 18:28:19 +00:00
Matthias Clasen
f01118f2fc Merge branch 'kjellahl/gtkprintbackendlpr' into 'main'
gtkprintbackendlpr.c: Add #include "gtkprivate.h"

See merge request GNOME/gtk!5057
2022-09-26 18:22:21 +00:00
Kjell Ahlstedt
9db812ea7f gtkprintbackendlpr.c: Add #include "gtkprivate.h"
Necessary after GTK_NOTE was replaced by GTK_DEBUG.
GTK_DEBUG is defined in gtk/gtkprivate.h. GTK_NOTE was defined
in gtk/gtkdebug.h.
2022-09-26 18:38:06 +02:00
Piotr Drąg
d538e78d8a Update Polish translation 2022-09-26 18:01:02 +02:00
Yuri Chornoivan
ba0499a803 Update Ukrainian translation 2022-09-26 14:54:56 +00:00
Matthias Clasen
1318fdc52c Merge branch 'fix_4577' into 'main'
Make the presentation of the stack sidebar listbox nicer for A11Y

Closes #4577

See merge request GNOME/gtk!4661
2022-09-26 14:41:29 +00:00
Luca Bacci
d3c50fad6c Merge branch 'gdk-win32-fix-subclassing-gdk-win32-clipdrop' into 'main'
GdkWin32: Fix subclassing for GdkWin32Clipdrop

Closes #5207

See merge request GNOME/gtk!5055
2022-09-26 12:59:17 +00:00
Luca Bacci
e2219858ae GdkWin32: Fix subclassing for GdkWin32Clipdrop
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/5207
2022-09-26 14:34:24 +02:00
Matthias Clasen
85043a2d1b Merge branch 'bump-meson-req' into 'main'
Bump the meson requirement

See merge request GNOME/gtk!5051
2022-09-25 17:24:53 +00:00
Piotr Drąg
cac813bbc4 Update POTFILES.in 2022-09-25 14:10:28 +02:00
Nelson Benítez León
94a4c2cb40 fix crash in gtk_synthesize_crossing_events()
Update ancestor between GTK_CROSSING_OUT and
GTK_CROSSING_IN as it may have changed.

Fixes #5190
2022-09-24 21:25:05 -04:00
Matthias Clasen
11829fe7d0 gtk: Use gnome.mkenums_simple
This lets us avoid template files, and works just as well.
2022-09-24 21:23:00 -04:00
Matthias Clasen
455eefa854 gdk: Use gnome.mkenums_simple
This lets us avoid template files, and works just as well.
2022-09-24 21:22:53 -04:00
Matthias Clasen
0f4f90d722 Bump the meson requirement
GLib requires meson 0.60 nowadays, and it does not
make much sense for us to support an older meson.
2022-09-24 20:07:03 -04:00
Matthias Clasen
cefb0a3eb8 Merge branch 'header-cleanup' into 'main'
Header cleanup

See merge request GNOME/gtk!5049
2022-09-24 14:23:39 +00:00
Matthias Clasen
bc661a8ed5 gdk: Rename gdkpixbuf-drawable.c
There is nothing particularly specific to drawables
in there (and we don't have that concept anymore),
so just name the source file to match the header.
Easier for everybody.
2022-09-24 10:03:37 -04:00
Matthias Clasen
9ff549799d gdk: Tweaks to keyname handling
Rename the private header to follow our naming
conventions, and drop the extra gdkkeys.c file.
2022-09-24 10:03:37 -04:00
Matthias Clasen
e499a09759 Drop gtkintl.h
Include gtkprivate.h for I_() and glib-i18n.h for
gettext macros.
2022-09-24 10:03:37 -04:00
Carlos Garnacho
fb280e47d6 gtkimcontextwayland: Shuffle full resets after IM changes
Doing reset() on the text widgets after commit and delete_surrounding
is still too eager for some IMs (e.g. those that expect being able
to commit text while keeping a preedit buffer shown).

However, reset() is more of a "synchronize state" action on Wayland,
and it is still desirable to do that after changes that do come from
the IM (e.g. requesting the new surrounding text and cursor/anchor
positions). Notably here, the text_input protocol may still come up
with a preedit string after this state synchronization happens.

Shuffle the code so that the text widgets do not reset() the IM
context after text is deleted or committed, but the Wayland IM does
apply its practical effects after these actions happen. This keeps
the Wayland IM fully up-to-date wrt text widget state, while not
altering the ::commit and ::delete-surrounding-text behavior for
other IM context implementations.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5200
Fixes: 5b78fe2721 (gtktextview: Also reset IM context after IM...)
Fixes: 7c0a395ff9 (gtktext: Also reset IM context after IM...)
Fixes: 52ac71b972 (gtktextview: Shuffle the places doing IM reset)
Fixes: 9e29739e66 (gtktext: Shuffle the places doing IM reset)
2022-09-24 11:52:16 +02:00
Matthias Clasen
4aabc45685 Drop gdkintl.h
This header was merely including gi18n-lib.h.
Just do that directly.
2022-09-23 23:33:42 -04:00
Matthias Clasen
a8af7caae1 Rename gdk-private.h to gdkprivate.h
The extra - does not add any value.
2022-09-23 23:23:27 -04:00
Matthias Clasen
7d2c296357 Rename gdkconstructor.h to gdkconstructorprivate.h
This is the naming convention for private headers.
2022-09-23 23:14:08 -04:00
Matthias Clasen
c24a69549d Rename gdkdebug.h to gdkdebugprivate.h
This is the naming convention for private headers.
2022-09-23 23:12:01 -04:00
Matthias Clasen
f141da6b55 gtk: Dissolve gtk-autocleanup.h
Move the autocleanup declarations into their
respective headers.
2022-09-23 23:07:43 -04:00
Matthias Clasen
3688ece655 gsk: Dissolve gsk-autocleanup.h
Move the autocleanup declarations into their
respective headers.
2022-09-23 19:50:09 -04:00
Matthias Clasen
61a51dea7b gdk: Dissolve gdk-autocleanup.h
Move the autocleanup declarations into their
respective headers.

While we are at it, correct the autocleanup
declaration for GdkEvent to use gdk_event_unref,
not g_object_unref. Oops
2022-09-23 19:49:58 -04:00
Matthias Clasen
bccb4f87be Merge branch 'debug-envvars-cleanup' into 'main'
Clean up debug env vars

See merge request GNOME/gtk!5044
2022-09-23 23:06:47 +00:00
Matthias Clasen
52b6dbf2b4 gtk: Remove old debug macros
These are no longer used.
2022-09-23 18:51:46 -04:00
Matthias Clasen
f33f55bcbb gtk: Use the new debug macros 2022-09-23 18:12:39 -04:00
Matthias Clasen
f4d3f45c16 gtk: Introduce new debug macros
Introduce GTK_DISPLAY_DEBUG() and GTK_DEBUG(), which
mirror the new macros in gdk. They use the same helper
function gdk_debug_message().
2022-09-23 18:12:39 -04:00
Matthias Clasen
1e65d6640f tests: Rewrite the icontheme tests
The lookup order tests were relying on out
debug spew using g_log, so they can redirect
the output by setting a log writer function.

Rewrite this to use g_test_subprocess() and
parse stderr.
2022-09-23 18:12:39 -04:00
Matthias Clasen
8a4fd30797 gsk: drop old debug macros
These are no longer used.
2022-09-23 18:11:48 -04:00
Matthias Clasen
9818ec4ad9 gsk: Use the new debug macros 2022-09-23 18:11:48 -04:00
Matthias Clasen
4d08eb264d gsk: Introduce new debug macros
Introduce GSK_RENDERER_DEBUG() and GSK_DEBUG(), which
mirror the new macros in gdk. They use the same helper
function gdk_debug_message().
2022-09-23 18:11:48 -04:00
Matthias Clasen
bc159207bd gdk: Drop old debug macros
Drop the old GDK_NOTE() and GDK_DISPLAY_NOTE()
macros from gdkdebug.h. Reintroduce them in the
win32 backend, where they are still used.
2022-09-23 18:11:48 -04:00
Matthias Clasen
1f166ae071 macos: Use the new debug macros 2022-09-23 18:11:48 -04:00
Matthias Clasen
ce4c2154f4 x11: Use the new debug macros 2022-09-23 18:11:48 -04:00
Matthias Clasen
71fedee85d wayland: Use the new debug macros 2022-09-23 18:11:48 -04:00
Matthias Clasen
90c2b548e5 broadway: Use the new debug macros 2022-09-23 18:11:48 -04:00
Matthias Clasen
1d48f96fc5 gdk: Use the new debug macros 2022-09-23 18:11:48 -04:00
Matthias Clasen
10255eee72 Introduce new debug macros
Introduce GDK_DISPLAY_DEBUG() and GDK_DEBUG() and
the helper function gdk_debug_message(). This is
meant to clean up the mess of our current debug
statements which wildly mix g_message, g_print
and g_printerr.
2022-09-23 18:11:48 -04:00
Matthias Clasen
5b2568e9e4 Merge branch 'wip/jimmac/backdrop-titles' into 'main'
theme: tone down unfocused title labels

Closes #4468

See merge request GNOME/gtk!5047
2022-09-23 17:27:08 +00:00
Jakub Steiner
be6413b0e7 theme: tone down unfocused title labels
- mimic libadwaita in toning down unfocused titles. Cargo culting the
  filter instead of using normal opacity property.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/4468
2022-09-23 17:01:24 +02:00
Matthias Clasen
15d1c86b2c Merge branch 'wip/carlosg/touchpad-gestures-matching-fingers' into 'main'
gtkgesture: Do not update gestures with mismatching n-points on touchpad

See merge request GNOME/gtk!5046
2022-09-23 14:37:58 +00:00
Marek Černocký
dd47e3bcab Updated Czech translation 2022-09-23 16:22:41 +02:00
Carlos Garnacho
872534e763 gtkgesture: Do not update gestures with mismatching n-points on touchpad
Check that the touchpad gesture event has a matching number of fingers before
updating the GtkGesture point tracking, instead of afterwards. Avoids pointless
tracking of these touchpad events when we know beforehand that the gesture
will never be activated by the touchpad events.

Related: https://gitlab.gnome.org/GNOME/gtk/-/issues/5199
2022-09-23 16:04:32 +02:00
Marek Černocký
d351cbbcea Updated Czech translation 2022-09-23 15:57:50 +02:00
Matthias Clasen
6c95547c3f docs: Some updates
Make the section about environment variables match
current code.

Add a warning about env vars not being stable and
only for debugging.
2022-09-21 21:59:33 -04:00
Matthias Clasen
c7a7e550dc Only print supported debug flags
It is a bit disorienting to print a lot of unavailable
debug flags, with some working ones mixed in. Just show
the ones that work.
2022-09-21 21:51:58 -04:00
Matthias Clasen
ee1a634c25 Mark the invert-text-dir flag as always there
This flag works in non-debug builds too.
2022-09-21 21:47:06 -04:00
Matthias Clasen
55ab99cb98 Make GL flavor flags always available
No need to restrict this to debug builds.
2022-09-21 21:29:34 -04:00
Matthias Clasen
f50b0a0bcb Make the gl-debug debug flag always available
No need to restrict this to debug builds.
2022-09-21 21:17:16 -04:00
Matthias Clasen
01054c9c79 Make the gl-gles debug flag always available
No need to restrict this to debug builds.
2022-09-21 21:12:22 -04:00
Matthias Clasen
8bd3ec2ba1 Make the gl-legacy debug flag always available
No need to restrict this to debug builds.
2022-09-21 21:09:08 -04:00
Matthias Clasen
e08a9ea9ad Drop the gl-texture-rect debug flag
This was not doing anything.
2022-09-21 21:05:25 -04:00
Matthias Clasen
1987398ec5 Drop the software-gl debug flag
This was not doing anything.
2022-09-21 21:03:40 -04:00
Matthias Clasen
fa0fc9acb8 Make the gl-disable flag always available
No need to restrict this to debug builds.
2022-09-21 20:57:22 -04:00
Matthias Clasen
fa1c461c13 Make the portals debug flag always available
No need to restrict this to debug builds.
2022-09-21 20:55:46 -04:00
Matthias Clasen
a99b05525d Make the nograbs flag always available
No need to restrict this to debug builds.
2022-09-21 20:53:46 -04:00
Matthias Clasen
a337b21a4f Make vulkan-disable always available
There is no need to restrict this to debug builds.
2022-09-21 20:51:35 -04:00
Matthias Clasen
1b96828667 Make vulkan-validate always available
There is no need to restrict this debug builds.
2022-09-21 20:49:53 -04:00
Matthias Clasen
7785c18c56 Fix high-depth handling
We mark this flag as always available, but we
were only checking it in debug builds.
2022-09-21 20:47:26 -04:00
Matthias Clasen
183709c522 Fix default-settings handling
This is meant to be always available, but we
were checking for debug in one place.
2022-09-21 20:45:43 -04:00
Emmanuele Bassi
458bf674ad Merge branch 'windows-build-instructions-link' into 'main'
Update GTK on Windows link: use gtk.org, not wiki

See merge request GNOME/gtk!5043
2022-09-21 21:06:23 +00:00
Matthias Clasen
3016edbe72 Merge branch 'font-chooser-docs' into 'main'
fontchooser: Add some details to the docs

See merge request GNOME/gtk!5041
2022-09-21 18:57:58 +00:00
Mitchell Hentges
fa554a8e85 Update GTK on Windows link: use gtk.org, not wiki
The old wiki page has a couple issues:
* It's out-of-date, not having any notes for GTK4 specifically,
  and it doesn't link to `gvsbuild`, which (I believe) is
  the current official (and best) way to build GTK with MSVC.
* It's "locked", so it's harder for contributors to update. This
  is OK, except for one spicy detail:
* It's not clear how to contribute/report issues on the locked wiki
  pages, so out-of-date information falls off the radar.

Regardless :) the gtk.org GTK for Windows docs are a much better
springboard, in my opinion.
2022-09-21 20:12:21 +02:00
Matthias Clasen
5b03f5c531 fontchooser: Add some details to the docs 2022-09-21 09:39:06 -04:00
Maxim Zakharov
2acd10d7b0 gdk/broadway: correct gdk_broadway_device_query_state() to return pointer
coordinates relative to the upper left corner of surface
2022-09-21 15:42:40 +10:00
Matthias Clasen
a012f5bddb Merge branch 'cross-gi-docgen-detection' into 'main'
build: fix gi-docgen detection in cross builds

See merge request GNOME/gtk!5039
2022-09-20 10:58:45 +00:00
Michal Vasilek
98796d4513 build: fix gi-docgen detection in cross builds
gi-docgen is supposed to be ran natively on the build machine, without
native: true dependency() searches for gi-docgen on the host system.
When it doesn't find it, it falls back to a subproject even if gi-docgen
is available on the build machine.

also make gtk_doc require introspection
2022-09-20 01:27:26 +02:00
Matej Urbančič
2bbf7d267a Update Slovenian translation 2022-09-19 19:50:27 +00:00
Bruce Cowan
266d72a82f Update British English translation 2022-09-19 15:17:18 +00:00
Matthias Clasen
873c437235 Merge branch 'wip/smcv/shifted-shortcuts' into 'main'
gdkevents: Don't ignore modifiers that are not currently active

Closes #5095

See merge request GNOME/gtk!5037
2022-09-19 13:55:10 +00:00
Matthias Clasen
15e0f3e8c6 Merge branch 'wip/smcv/reliable-gresource' into 'main'
build: Use more conservative GResource embedding on non-x86_64

Closes #5107

See merge request GNOME/gtk!4956
2022-09-19 13:30:22 +00:00
Martin
af2a4d4a91 Update Slovenian translation 2022-09-19 08:38:02 +00:00
Sabri Ünal
d4e2f23287 Update Turkish translation 2022-09-18 08:21:42 +00:00
Baurzhan Muftakhidinov
332bd868f5 Update Kazakh translation 2022-09-18 04:56:54 +00:00
Simon McVittie
60a83a51c3 build: Use more conservative GResource embedding on non-x86_64
Doing clever things with objcopy is faster and seems to be reliable on
x86_64 Linux, but also doesn't work on all toolchains and architectures:
in particular, Debian has had trouble with this on arm and mips.
In a distro build environment where we are compiling all of GTK every
time, the cost of potentially unreliable builds is higher than the cost
of using slower but more conservative GResource embedding.

Resolves: https://gitlab.gnome.org/GNOME/gtk/-/issues/5107
Signed-off-by: Simon McVittie <smcv@debian.org>
2022-09-17 21:50:38 +01:00
Simon McVittie
79285bd63e gdkevents: Don't ignore modifiers that are not currently active
The X11 backend can mark modifiers like Shift as consumed even if they
aren't actually active, which seems to be something to do with making
shortcuts like `<Control><Shift>plus` and `<Control>plus` work as
intended regardless of whether the plus symbol is obtained by pressing
Shift and a key (like `+/=` on American, British or French keyboards)
or not (like `*/+` on German keyboards).

However, this can go badly wrong when the modifier is *not* pressed.
For example, terminals normally have separate bindings for `<Control>c`
(send SIGINT) and `<Control><Shift>c` (copy). If we disregard the
consumed modifiers completely, when the X11 backend marks Shift as
consumed, pressing Ctrl+c would send SIGINT *and* copy to the clipboard,
which is not what was intended.

By masking out the members of `consumed` that are not in `state`, we
get the same interpretation for X11 and Wayland, and ensure that
keyboard shortcuts that explicitly mention Shift can only be triggered
while holding Shift. It continues to be possible to trigger keyboard
shortcuts that do not explicitly mention Shift (such as `<Control>plus`)
while holding Shift, if the backend reports Shift as having been
consumed in order to generate the plus keysym.

Resolves: https://gitlab.gnome.org/GNOME/gtk/-/issues/5095
Bug-Debian: https://bugs.debian.org/1016927
Signed-off-by: Simon McVittie <smcv@debian.org>
2022-09-17 19:40:53 +01:00
Matthias Clasen
3a941eff4a 4.8.1 2022-09-16 12:29:33 -04:00
Matthias Clasen
65adcec82f Merge branch 'detect-stylus' into 'main'
Recognize "stylus" devices as GDK_SOURCE_PEN

Closes #4394

See merge request GNOME/gtk!4776
2022-09-16 12:12:37 +00:00
Matthias Clasen
ffb6f39715 Merge branch 'fix-filetransfer-mimetype' into 'main'
portal: Use the right mimetype for file transfers

Closes #5182

See merge request GNOME/gtk!5033
2022-09-16 00:35:13 +00:00
Matthias Clasen
9a16269747 Merge branch 'wip/abono/gtk-main-remove-condition' into 'main'
gtk/main: Remove condition that always evaluates TRUE

See merge request GNOME/gtk!5031
2022-09-15 19:24:04 +00:00
Matthias Clasen
32f55a74b0 portal: Use the right mimetype for file transfers
The filetransfer protocol says to use
application/vnd.portal.filetransfer, but I used
application/vnd.portal.files when I implemented the
protocol. Oops.

This commit dds the correct mimetype, but we still
support the old one to preserve interoperatibility
with existing flatpaks using GTK 4.6.

Fixes: #5182
2022-09-15 15:18:17 -04:00
Alessandro Bono
5320acf589 gtk/main: Remove condition that always evaluates TRUE 2022-09-15 16:44:44 +02:00
Benjamin Otte
b9b2ac2ce3 Merge branch 'wip/coreyberla/gridview-rubberband' into 'main'
gridview: Fix rubberbanding from negative x coordinates

Closes nautilus#2492

See merge request GNOME/gtk!5030
2022-09-14 18:48:11 +00:00
Corey Berla
ad041fc5d4 gridview: Fix rubberbanding from negative x coordinates
This is a follow-up to 1e9a36ffa8. For GridView
we also need to make sure that we aren't rubberbanding below x=0 which
causes unexpected rubberbanding behavior.

Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2492
2022-09-14 11:27:52 -07:00
Matthias Clasen
952f85c12d Merge branch 'single-key-compose' into 'main'
input: Accept short compose sequences

Closes #5172

See merge request GNOME/gtk!5026
2022-09-13 10:24:49 +00:00
Matthias Clasen
72d6241c84 Add a test for short compose sequences
Add a table that has a short sequence
to verify that we can parse this.
2022-09-12 22:30:47 -04:00
Matthias Clasen
aac3f1860f Update test results
The table sizes change, even though none of our
test tables include short sequences.
2022-09-12 22:30:47 -04:00
Matthias Clasen
6be27682a8 Regenerate builtin sequences
The table format has changed.
2022-09-12 22:30:47 -04:00
Matthias Clasen
8931169e00 input: Accept short compose sequences
Some of the X keyboard layouts use compose
sequences of length one to make individual
keys generate multiple Unicode characters.

To support this use case, change the index
part of the table format to also include
an offset for length 1. Bump the table
version to indicate this change.

Fixes: #5172
2022-09-12 22:30:47 -04:00
Matthias Clasen
72785c68d6 Cosmetics: Fix a typo 2022-09-12 12:01:30 -04:00
Boyuan Yang
5c831d030a Update Chinese (China) translation 2022-09-11 19:24:40 +00:00
Jordi Mas
f17a924e7b Update Catalan translation 2022-09-11 14:32:27 +02:00
Matthias Clasen
2e542d8cae Merge branch 'misc-gl-fixes' into 'main'
gsk: Make glyph upload more similar to icons

See merge request GNOME/gtk!4074
2022-09-10 20:09:28 +00:00
Matthias Clasen
511a4ec475 gsk: Make glyph upload more similar to icons
When uploading glyphs to the atlas, clear
the padding bytes so that no dirt remains there.
2022-09-10 15:25:59 -04:00
Matthias Clasen
b76a2e44ba Merge branch 'matthiasc/for-main' into 'main'
clang-format: This did not work

See merge request GNOME/gtk!5021
2022-09-10 18:51:14 +00:00
Matthias Clasen
d28b94f0cb clang-format: This did not work
I thought AlignConsecutiveDeclarations would
align function parameters, but it doesn't.
So drop it again.
2022-09-10 14:35:40 -04:00
Cheng-Chia Tseng
c4766b2747 Update Chinese (Taiwan) translation 2022-09-10 09:09:29 +00:00
Matthias Clasen
98bdf67468 Merge branch 'game-sounds' into 'main'
gtk-demo: Make losing games hurt

See merge request GNOME/gtk!5017
2022-09-10 00:32:45 +00:00
Emmanuele Bassi
dca57bebb7 Merge branch 'a11y-state-changes' into 'main'
a11y: Be safe against state type changes

See merge request GNOME/gtk!5018
2022-09-10 00:04:03 +00:00
Matthias Clasen
de9a5f94c2 Merge branch 'less-fetching-in-ci' into 'main'
ci: Improve style check script

See merge request GNOME/gtk!5020
2022-09-10 00:02:41 +00:00
Matthias Clasen
659a129f81 Merge branch 'clang-format-improvement' into 'main'
ci: Improve clang-format style

See merge request GNOME/gtk!3770
2022-09-09 23:59:49 +00:00
Matthias Clasen
0c8bdf2ac2 ci: Improve clang-format style
Add

AlignConsecutiveDeclarations: true
PointerAlignment: Right

which will produce the style we want with llvm 13.
2022-09-09 19:43:27 -04:00
Matthias Clasen
3d2dcb437c ci: Improve style check script
Only fetch the two branches we are about to
compare, and use existing git merge-base to
find the common ancestor.
2022-09-09 19:41:42 -04:00
Emmanuele Bassi
22de54a9dc Merge branch 'ebassi/style-check' into 'main'
ci: Re-sync the style check with GLib

See merge request GNOME/gtk!5019
2022-09-09 23:30:38 +00:00
Matthias Clasen
4b5ed886ce ci: Fix the git usage in scripts
Thanks, git.
2022-09-10 00:16:12 +01:00
Emmanuele Bassi
821dd26934 ci: Move style check to its own stage
Drop the `.pre` phase.
2022-09-10 00:16:12 +01:00
Emmanuele Bassi
d6597098f1 ci: Re-sync the style check with GLib 2022-09-10 00:16:12 +01:00
Matthias Clasen
4c1bc93f6f a11y: Be safe against state type changes
For some of the a11y states, calling gtk_accessible_reset_state
can change the type of the state value from boolean or tristate
to undefined.

Handle that, instead of throwing criticals.

Related: !4910
2022-09-09 16:07:24 -04:00
Matthias Clasen
ef9b844c7f Merge branch 'filechooser-keybindings' into 'main'
filechooser: Restore ~ and . functionality

See merge request GNOME/gtk!5016
2022-09-09 19:38:39 +00:00
Matthias Clasen
681ec04b85 gtk-demo: Make losing games hurt
Use a more annoying sound for losses.
And use it for all games.
2022-09-09 15:36:31 -04:00
Matthias Clasen
7dd3289837 Merge branch 'widget-factory-filechooser' into 'main'
widget-factory: Add a file chooser

See merge request GNOME/gtk!5015
2022-09-09 18:44:31 +00:00
Matthias Clasen
7e54a7e5a5 filechooser: Restore ~ and . functionality
We'll have to keep patching up these things
until somebody rewrites the file chooser :(

Inspired by: !4970
2022-09-09 14:44:28 -04:00
Matthias Clasen
f050a9e889 widget-factory: Add a file chooser
We don't have a readily accessible file chooser
in our demo apps. Fix that by making the Open
menu item on page 2 bring up a file chooser.
2022-09-09 14:28:08 -04:00
Matthias Clasen
ae2964c7c6 Merge branch 'fix-fontrendering-demo' into 'main'
gtk-demo: Avoid a segfault

Closes #5166

See merge request GNOME/gtk!5014
2022-09-09 16:57:27 +00:00
Matthias Clasen
54daad3878 gtk-demo: Avoid a segfault
The code in the fontrendering demo is a bit sloppy
and assumes that we always get a single run when
appending a sequence of 4 chars and 4 spaces.

That is not in general true, such as for Emoji.

Instead of working harder to handle Emoji here,
just give up and fall back to 'a'.

Fixes: #5166
2022-09-09 12:34:54 -04:00
Matthias Clasen
d7817e6fc6 Merge branch 'gtkplaces' into 'main'
gtkplacesview: Right click popover fix crash and align menu with mouse

See merge request GNOME/gtk!4662
2022-09-09 14:59:03 +00:00
Matthias Clasen
de94f3d97f Merge branch 'gtktooltip.c-optimise' into 'main'
gtk/gtktooltip.c: check result of event position get operation

Closes #5134

See merge request GNOME/gtk!4996
2022-09-09 14:56:33 +00:00
Matthias Clasen
066884aed1 Merge branch 'wip/carlosg/im-reset' into 'main'
Avoid early IM reset on updates

Closes #5133

See merge request GNOME/gtk!5012
2022-09-09 12:36:43 +00:00
Rūdolfs Mazurs
e7501185cd Update Latvian translation 2022-09-07 20:56:57 +00:00
Matthias Clasen
a08277adcd Merge branch 'fix-file-transfer-portal' into 'main'
Stop recursion in registering serializers

See merge request GNOME/gtk!5013
2022-09-07 15:04:43 +00:00
Matthias Clasen
e8e69a1208 Make clipboard tests work with portals
This was not working right, since it hasn't been
tested with portals - there are no portals in ci.
2022-09-07 08:45:31 -04:00
Matthias Clasen
e16414b3ac Handle absence of portals
When the documents portal is not on the bus,
we still get an (unowned) proxy, and we need
to handle that situation.
2022-09-07 08:45:31 -04:00
Matthias Clasen
2e42786091 portals: Fix FileTransfer portal calls
We were not passing the right arguments to
the AddFiles call, causing the file transfer
to fail.
2022-09-07 06:47:02 -04:00
Matthias Clasen
b756aa0764 Make the file transfer portal setup sync again
We need to register the portal mime types before
the others to prefer them, doing this call async
messes up that ordering.

This is effectively reverting 69fb3648b2
2022-09-07 06:45:03 -04:00
Matthias Clasen
9654fd451f Stop recursion in registering serializers
This was probably unintentional, and messes up
the ordering of our registration.
2022-09-06 23:35:48 -04:00
Matthias Clasen
7d564ecdc9 Merge branch 'textbuffer-set-text-docs' into 'main'
Document irreversibility of gtk_text_buffer_set_text

See merge request GNOME/gtk!5005
2022-09-06 22:19:30 +00:00
Matthias Clasen
d850dfd245 Merge branch 'launch-uri-no-export' into 'main'
Make gtk_launch_uri more robust

Closes #5152

See merge request GNOME/gtk!5010
2022-09-06 20:50:06 +00:00
Matthias Clasen
a6d5757627 Merge branch 'gtk-scale-set-digits-update-label' into 'main'
GtkScale: Update the label size request from set_digits ()

Closes #5156

See merge request GNOME/gtk!5011
2022-09-06 20:34:39 +00:00
Matthias Clasen
ad8a3e5b45 Merge branch 'wip/antoniof/columnview-rtl' into 'main'
columnview: Invert columns on RTL

Closes nautilus#2302

See merge request GNOME/gtk!5002
2022-09-06 20:30:15 +00:00
Carlos Garnacho
5b78fe2721 gtktextview: Also reset IM context after IM surrounding text deletion
When the IM commands the GtkText to delete text, the cursor position
would change, and so would the surrounding text. Reset the IM context
so that these updates are properly picked up by the IM.

Fixes backspace	key behavior in	the GNOME Shell OSK, since that	relies
on the surrounding text	being properly updated for the next iteration.
2022-09-06 22:17:40 +02:00
Carlos Garnacho
7c0a395ff9 gtktext: Also reset IM context after IM surrounding text deletion
When the IM commands the GtkText to delete text, the cursor position
would change, and so would the surrounding text. Reset the IM context
so that these updates are properly picked up by the IM.

Fixes backspace key behavior in the GNOME Shell OSK, since that relies
on the surrounding text being properly updated for the next iteration.
2022-09-06 22:17:40 +02:00
Carlos Garnacho
41f26975a9 gtktext: Avoid early IM reset on updates
Resetting the IM on IM updates is too eager and indeed the simple
IM context doesn't like that this happens in the middle of dead
key handling.

We however want to reset the IM after actual text buffer changes
(say, a committed string) moved the cursor position, altered the
surrounding text, etc. So that the IM implementation does know to
update its state.

Since there is going to be an actual IM reset anyways, it does
no longer make sense to try to preserve the old priv->need_im_reset
status during commit handling.

Fixes: 52ac71b972 ("gtktextview: Shuffle the places doing IM reset")
Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5133
2022-09-06 22:17:40 +02:00
Carlos Garnacho
085374198f gtktext: Avoid early IM reset on updates
Resetting the IM on IM updates is too eager and indeed the simple
IM context doesn't like that this happens in the middle of dead
key handling.

We however want to reset the IM after actual text buffer changes
(say, a committed string) moved the cursor position, altered the
surrounding text, etc. So that the IM implementation does know to
update its state.

Fixes: 9e29739e66 ("gtktext: Shuffle the places doing IM reset")
Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5133
2022-09-06 22:17:40 +02:00
Matthias Clasen
586675c902 Merge branch 'treepopover-ellipsize' into 'main'
treepopover: Do not propagate natural width of content

See merge request GNOME/gtk!4895
2022-09-06 20:17:33 +00:00
Matthias Clasen
1679fc8675 Merge branch 'display-wayland-update-scale' into 'main'
wayland/display: Remove duplicate update_scale() call

See merge request GNOME/gtk!5003
2022-09-06 20:14:38 +00:00
Matthias Clasen
9cc1dcf2a4 4.8.0 2022-09-06 15:59:04 -04:00
Luca Bacci
cc57692345 GtkScale: Update the label's size request from set_digits ()
Update the label size request when setting the digits property
by calling the update_label_request () util function.

That util function works by measuring the size request of the
label with the lower and upper values of the adjustment, then
taking the max. That way the size requisition is constant
regardless of the actual displayed value.

Since the util function internally works by setting the text
of the label, let it also set the text at last by taking in
account the current adjustment's value. Most of its callers
do that anyway.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/5156
2022-09-06 21:08:31 +02:00
Matthias Clasen
a0db8a24c2 Make gtk_launch_uri more robust
We were failing to launch the uri if we are on
Wayland, but have no xdg_foreign protocol support.

Fixes: #5152
2022-09-06 12:37:56 -04:00
Zurab Kargareteli
e4be073f0a Update Georgian translation 2022-09-06 16:28:59 +00:00
Zurab Kargareteli
4ffefec469 Update Georgian translation 2022-09-06 16:28:00 +00:00
Changwoo Ryu
db2432b5db Update Korean translation 2022-09-06 04:15:30 +00:00
Aurimas Černius
7d29b456b8 Updated Lithuanian translation 2022-09-05 22:38:20 +03:00
Daniel Mustieles
8fbb647daa Updated Spanish translation 2022-09-05 14:30:59 +02:00
Fran Dieguez
c28b8297ee Update Galician translation 2022-09-04 22:24:45 +00:00
Aleksandr Melman
4eb0dd7264 Update Russian translation 2022-09-04 20:45:34 +00:00
Rūdolfs Mazurs
b3d6972803 Update Latvian translation 2022-09-04 15:50:02 +00:00
Jürgen Benvenuti
0eab3c3940 Update German translation 2022-09-04 13:57:48 +00:00
Elliott Sales de Andrade
4cbfb69f74 Document irreversibility of gtk_text_buffer_set_text
If you've begun a user action and call `gtk_text_buffer_set_text`, you
get an unexpected warning:
```
Gtk-WARNING **: Cannot begin irreversible action while in user action
```
which can be fixed by doing the delete/insert yourself. But this is not
documented as occurring, so document it.
2022-09-04 02:47:57 -04:00
Boyuan Yang
4603e7bb18 Update Chinese (China) translation 2022-09-03 21:16:03 +00:00
Rūdolfs Mazurs
8d504cae44 Update Latvian translation 2022-09-03 13:04:54 +00:00
Piotr Drąg
0f35ece2af Update Polish translation 2022-09-03 15:00:46 +02:00
Marek Černocký
204cac7ebf Updated Czech translation 2022-09-03 09:50:27 +02:00
Robert Mader
06a51b6ca6 wayland/display: Remove duplicate update_scale() call
`apply_monitor_change()` already calls `update_scale()`.
Note that this only affects old compositor versions (see
`should_update_monitor()`) so it's just a minor cleanup.
2022-09-03 00:53:02 +02:00
Balázs Úr
853bfcb130 Update Hungarian translation 2022-09-02 21:29:08 +00:00
Jordi Mas
6a1f5c0af5 Update Catalan translation 2022-09-02 20:34:04 +02:00
António Fernandes
91e6f8e4b9 columnview: Invert columns on RTL
Respect text direction.

Fixes https://gitlab.gnome.org/GNOME/nautilus/-/issues/2302
2022-09-02 15:44:59 +01:00
Carlos Garnacho
bce90df49d Merge branch 'treeview-gesture-claim' into 'main'
treeview: Don't claim event sequence too early

Closes #3649, #3985, #4206, and #4669

See merge request GNOME/gtk!4883
2022-09-02 12:40:15 +00:00
Mat
58953671fe treeview: Don't claim event sequence too early
We want to claim the event sequence in the click gesture when appropriate,
such as activating a row or clicking an editable cell, but this is currently
done too early, preventing other gestures for drag-and-drop and rubberband
selection entirely.

Fixes #3649
Fixes #3985
Fixes #4669
2022-09-02 15:04:43 +03:00
Ask Hjorth Larsen
df527758b1 Updated Danish translation 2022-09-02 11:51:27 +02:00
Emin Tufan Çetin
3cd55fdf35 Update Turkish translation 2022-09-01 22:53:55 +00:00
Alexander Shopov
25783573c6 Update Bulgarian translation 2022-09-01 21:11:55 +00:00
Luca Bacci
041a186272 Merge branch 'implement-gtk-color-picker-for-windows' into 'main'
Implement GtkColorPicker for Windows

Closes #5136

See merge request GNOME/gtk!4983
2022-09-01 20:39:15 +00:00
Christian Hergert
f5488bb4b2 gdk: fix typo in frame clock docs 2022-09-01 12:16:10 -07:00
Luca Bacci
86a38918d7 Implement GtkColorPicker for Windows
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/5136
2022-09-01 19:25:07 +02:00
Hugo Carvalho
88f38f598b Update Portuguese translation 2022-09-01 17:18:51 +00:00
Nathan Follens
4aee6edbbd Update Dutch translation 2022-09-01 16:21:14 +00:00
Matthias Clasen
adcec93b02 Merge branch 'gtkplacessidebar' into 'main'
gtkplacessidebar: Fix crash when remove or rename bookmark

See merge request GNOME/gtk!4625
2022-09-01 15:00:42 +00:00
Matthias Clasen
79ff151624 Merge branch 'inscription_a11y' into 'main'
GtkInscription: Set the a11y label when updating the text property

See merge request GNOME/gtk!5000
2022-09-01 14:38:49 +00:00
Lukáš Tyrychtr
27f32b7f9b GtkInscription: Set the a11y label when updating the text property 2022-09-01 16:19:59 +02:00
Anders Jonsson
1771f75c6c Update Swedish translation 2022-09-01 13:15:36 +00:00
Marek Černocký
979c418e46 Updated Czech translation 2022-09-01 14:41:37 +02:00
Marek Černocký
28f63259ab Updated Czech translation 2022-09-01 14:34:27 +02:00
Leônidas Araújo
105a2262dc Update Brazilian Portuguese translation 2022-08-31 14:53:19 +00:00
Danial Behzadi
3615619f41 Update Persian translation 2022-08-31 12:45:30 +00:00
Kukuh Syafaat
0782bfa52b Update Indonesian translation 2022-08-31 09:17:12 +00:00
Asier Sarasua Garmendia
ccd5565f75 Update Basque translation 2022-08-31 07:04:00 +00:00
Matthias Clasen
e502155dfa Merge branch 'gbsneto/cleanup-gsettings' into 'main'
gtk: Remove last-folder-uri from schema

See merge request GNOME/gtk!4998
2022-08-30 19:14:44 +00:00
Georges Basile Stavracas Neto
9261b0079d gtk: Remove last-folder-uri from schema
It's unused since 2013, apparently.
2022-08-30 15:58:47 -03:00
Goran Vidović
4638f942b8 Update Croatian translation 2022-08-30 11:56:21 +00:00
Maxim Zakharov
982b4ff3b2 gtk/gtktooltip.c: check result of event position get operation
Do not perform coordinates transformation when gdk_event_get_position()
returns FALSE as it returns NaNs in that case and these coordinates
are not used anyway in further processing (closes #5134).
2022-08-30 15:54:52 +10:00
Yuri Chornoivan
46483bebcd Update Ukrainian translation 2022-08-29 19:21:22 +00:00
Matthias Clasen
e077a6bffe Merge branch 'wip/jimmac/HC-italic-hints' into 'main'
HC: entry - make hints italic

Closes #5143

See merge request GNOME/gtk!4994
2022-08-29 18:55:34 +00:00
Matthias Clasen
66dc193aeb Merge branch 'font-feature-work' into 'main'
fontchooser: Rename default feature value

See merge request GNOME/gtk!4995
2022-08-29 18:48:00 +00:00
Matthias Clasen
39439aa838 fontchooser: Rename default feature value
"Default" is a better fit than "None" here.
2022-08-29 14:14:07 -04:00
Matthias Clasen
018bd0a927 fontchooser: Add a tooltip to the tweak button
Icon-only buttons are always better with a tooltip.
2022-08-29 12:13:32 -04:00
Matthias Clasen
975ab6e7cf fontchooser: Remove placeholder from preview entry
The way we explicitly set the font on the entry
conflicts with the placeholder text styling. But the
entry isn't normally empty, so placeholder text is
not that important here. Remove it and use a tooltip
instead.
2022-08-29 10:21:37 -04:00
Jordi Mas
53c8975739 Update Catalan translation 2022-08-29 12:28:26 +02:00
Jakub Steiner
09176fc1b3 HC: entry - make hints italic
- to keep contrast but indicated difference between a value and a hint

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/5143
2022-08-29 11:58:29 +02:00
Matthias Clasen
0f2582ff02 Merge branch 'font-feature-work' into 'main'
fontchooser: Improve handling of features

See merge request GNOME/gtk!4992
2022-08-29 01:26:12 +00:00
Matthias Clasen
a217be14f9 Merge branch 'gtknotebook-arrow-press' into 'main'
gtknotebook: Claim event sequence after pressing notebook arrow buttons

See merge request GNOME/gtk!4990
2022-08-28 23:30:00 +00:00
Matthias Clasen
e7b332c532 Merge branch 'gtknotebook-arrow-state' into 'main'
gtknotebook: update arrow button state when reordering tabs

See merge request GNOME/gtk!4991
2022-08-28 23:29:25 +00:00
Piotr Drąg
13382937d1 Update Polish translation 2022-08-28 23:34:58 +02:00
Matthias Clasen
c364f1ee12 fontchooser: Improve handling of features
salt and swsh need to be treated like cvXX, with
a dropdown. Also add examples to the default cases
of radio groups.
2022-08-28 17:02:56 -04:00
Mat
dd8c899737 gtknotebook: update arrow button state when reordering tabs
When reordering notebook tabs, updating the sensitivity state of the
arrow buttons is necessary if the tab is moved to the beginning or
end of the tab list.
2022-08-29 00:00:10 +03:00
Mat
d69fdaa04d gtknotebook: Claim event sequence after pressing notebook arrow buttons
When notebook tabs are reorderable, pressing the notebook arrow buttons to
change the active tab results in tabs reordering unexpectedly.
Claim the event sequence after pressing an arrow button to avoid conflicts
with the motion/drag gesture used for reordering.
2022-08-28 23:42:59 +03:00
Aleksandr Melman
16eced7bf1 Update Russian translation 2022-08-28 18:51:12 +00:00
Matthias Clasen
1276e8868d Merge branch 'notebook-tab-accessibility' into 'main'
gtkatspiselection: Retrieve the correct GtkNotebook tab widget

See merge request GNOME/gtk!4989
2022-08-28 14:53:03 +00:00
Goran Vidović
7539fb4ced Update Croatian translation 2022-08-28 14:41:32 +00:00
Matthias Clasen
f24efd175e Merge branch 'strdup-avoidance' into 'main'
notebook: Use canonical signal names

See merge request GNOME/gtk!4988
2022-08-28 14:05:02 +00:00
Mat
df40efd50d gtkatspiselection: Retrieve the correct GtkNotebook tab widget
A typo resulted in the tab container widget being retrieved instead of
the tab widget. If an adjacent action widget was present, an infinite
loop occurred when switching tabs while a screen reader was enabled.
2022-08-28 17:02:01 +03:00
Hugo Carvalho
db5868d89b Update Portuguese translation 2022-08-28 13:14:19 +00:00
Matthias Clasen
32796cad10 Use gtk_event_controller_set_static_name
This avoids strdups.
2022-08-27 22:35:13 -04:00
Matthias Clasen
b6a965a67c eventcontroller: Allow static names
These names are a debug-only feature, and we
use string literals everywhere, so avoid the
overhead of copying them.
2022-08-27 22:35:13 -04:00
Matthias Clasen
6136f3ab95 shortcutaction: Intern signal names
Signal names are already interned anyway,
so we can avoid strdups here, and just use
the interned names.
2022-08-27 22:35:13 -04:00
Matthias Clasen
d3e79633e1 notebook: Use canonical signal names
No excuse for not doing that.
2022-08-27 22:34:31 -04:00
Goran Vidović
b362098f63 Update Croatian translation 2022-08-27 20:18:12 +00:00
Luca Bacci
35583c8d36 Merge branch 'gl-renderer-make-context-current-in-remove-program' into 'main'
GL Renderer: Make GdkGLContext current in gsk_gl_driver_shader_weak_cb

Closes #5140

See merge request GNOME/gtk!4985
2022-08-27 17:53:39 +00:00
Piotr Drąg
581bfd20e4 Update Polish translation 2022-08-27 16:16:35 +02:00
Piotr Drąg
c5bbdfb7b1 Update POTFILES.in and POTFILES.skip 2022-08-27 15:54:10 +02:00
Luca Bacci
bcccb46b7c GL Renderer: Ensure that GdkGLContext is current in gsk_gl_driver_shader_weak_cb
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/5140
2022-08-27 13:58:17 +02:00
Yuri Chornoivan
916328da2b Update Ukrainian translation 2022-08-27 09:56:43 +00:00
Danial Behzadi
6ca0d616d4 Update Persian translation 2022-08-27 05:32:31 +00:00
Matthias Clasen
137af44f81 Merge branch 'font-chooser-feature-work' into 'main'
fontchooser: Handle font features better

See merge request GNOME/gtk!4984
2022-08-26 22:10:52 +00:00
Matthias Clasen
0441fd3678 fontchooser: Handle font features better
Properly show multiple-choice cvXX features as dropdowns,
include afrc, and fix bugs in feature enumeration that
made some features not show up.
2022-08-26 17:53:55 -04:00
Luca Bacci
3abc3425cb Merge branch 'win32-gir' into 'main'
gdk/win32: do not expose gdk_win32_*_libgtk_only in public headers

See merge request GNOME/gtk!4980
2022-08-26 13:14:30 +00:00
Matthias Clasen
2017f3debe Some strdup avoidance 2022-08-25 14:33:30 -04:00
Marc-André Lureau
4b08570727 gdk/win32: add missing Since tag for gdk_win32_display_get_egl_display
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-08-25 17:33:25 +04:00
Nart Tlisha
1042ca7e52 Update Abkhazian translation 2022-08-25 10:29:34 +00:00
Marc-André Lureau
52e3ed13e2 gdk/win32: deprecate gdk_win32_handle_table_lookup
This function is probably not generally useful for a Gtk+/win32 user,
and it's only used internally by gdk-win32. It's time to deprecate it, I
believe.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-08-24 21:02:57 +04:00
Benjamin Otte
fb7257a1f5 Merge branch 'treelistmodel-collapse-test' into 'main'
treelistmodel: Fix handling of collapsed nodes

Closes #4595

See merge request GNOME/gtk!4981
2022-08-24 13:42:51 +00:00
Matthias Clasen
83bf193218 Add a test for treelistmodel row collapse
Test that we can expand and collapse a row, and then
add another child below it, without crashing.

Adapted from the testcase in #4595.

This tests the fix in the previous commit.
2022-08-24 08:23:22 -04:00
Matthias Clasen
f1c1c979c2 treelistmodel: Fix handling of collapsed nodes
When we collapse a node, we clear out the children,
but we were not disconnecting the signal handler on
the child listmodel, leading to bad outcomes when
that model is persistent and changing.

Fixes: #4595
2022-08-24 08:23:20 -04:00
Marc-André Lureau
6cfb6e0c9c gdk/win32: do not expose gdk_win32_*_libgtk_only in public headers
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-08-24 15:44:32 +04:00
Luca Bacci
ef831235fe Merge branch 'win32-gir' into 'main'
win32: various GI annotations and fixes

See merge request GNOME/gtk!4977
2022-08-24 09:41:11 +00:00
Luca Bacci
5286e9405d Merge branch 'gdk-win32-scale-text-with-dpi-as-gtk3' into 'main'
GdkWin32: Scale text like in GTK3 with SYSTEM_DPI_AWARENESS

Closes #4187

See merge request GNOME/gtk!4979
2022-08-24 09:35:30 +00:00
Luca Bacci
c11ea42644 GdkWin32: Scale text with DPI like in GTK3 with SYSTEM_DPI_AWARENESS
Right now we only support system DPI awareness in GTK4. In that case
it makes sense to scale text with the DPI of the primary monitor, like
done in GTK3.

We plan to land support for proper fractional scaling in Gdk/Win32, so
in the future the "gtk-xft-dpi" setting will be gathered as intended,
i.e. for text magnification, as an a11y feature.
2022-08-23 19:53:44 +02:00
Luca Bacci
d7c04145ee Merge branch 'gdk-win32-fix-monitor-for-popup' into 'main'
GdkWin32: Use primary monitor as fallback if popup layout does not intersect any

See merge request GNOME/gtk!4978
2022-08-23 17:20:02 +00:00
Marc-André Lureau
0d7a0132bb gdk/win32: annotate gdk_win32_surface_lookup_for_display
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-08-23 17:20:39 +04:00
Marc-André Lureau
cad32636ce gdk/win32: annotate gdk_win32_surface_set_urgency_hint
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-08-23 17:06:48 +04:00
Luca Bacci
d125fcd35a GdkWin32: Position popups on the primary monitor if outside of the visible screen area
Fixes a crash caused by attempting to dereference a NULL GdkMonitor*
in GdkWin32.

See https://gitlab.gnome.org/GNOME/gtk/-/issues/5125
2022-08-23 14:54:01 +02:00
Marc-André Lureau
88503bcc3b gtk/win32: fix a switch-default warning
gtk/gtkimcontextime.c:714:3: warning: switch missing default case [-Wswitch-default]

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-08-23 16:42:17 +04:00
Matthias Clasen
e68925a932 Merge branch 'tweak-option-docs' into 'main'
Tweak the vulkan option description

See merge request GNOME/gtk!4976
2022-08-23 12:41:46 +00:00
Marc-André Lureau
a6418d5028 gdk/win32: deprecate gdk_win32_surface_get_impl_hwnd
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-08-23 16:35:07 +04:00
Marc-André Lureau
04ebec0fa7 gtk/win32: use gdk_win32_surface_get_handle
As I propose to deprecate gdk_win32_surface_get_impl_hwnd() next,
replace it with the alternative.

The main difference between the two functions is that
gdk_win32_surface_get_impl_hwnd() fails gracefully by returning NULL if
the surface is not of the win32 implementation.

All the surfaces should be native surfaces here, and the existing code
doesn't seem to deal with NULL case anyway.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-08-23 16:31:09 +04:00
Matthias Clasen
aa0f564aa1 Tweak the vulkan option description
The thing that is experimental is our renderer,
not the vulkan API.
2022-08-23 08:27:24 -04:00
Marc-André Lureau
3cbf6c9d6e gdk/win32: annotate gdk_win32_surface_get_handle
And adjust the argument precondition check.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-08-23 16:25:33 +04:00
Marc-André Lureau
a75de5fb90 gdk/win32: correct gdk_win32_surface_get_handle return type
The associated surface window handle is a HWND, not a HGDIOBJ.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-08-23 16:17:19 +04:00
Sveinn í Felli
1b66373a5d Update Icelandic translation
(cherry picked from commit a27ae5362c)
2022-08-23 11:49:42 +00:00
Sveinn í Felli
8786ac844c Update Icelandic translation
(cherry picked from commit e6d3c58ccf)
2022-08-23 11:38:46 +00:00
Marc-André Lureau
180dd5fb7f gdk/win32: deprecate gdk_win32_surface_is_win32
The function isn't used by Gtk itself anymore, and does not help much.
It creates extra issues for bindings, as it doesn't fit well with code
doing the same job for other objects.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-08-23 15:34:50 +04:00
Marc-André Lureau
a53650d9da gdk/win32: annotate filter callbacks
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-08-23 12:57:20 +04:00
Luca Bacci
0d4d52d322 Merge branch 'win32-gir' into 'main'
Generate gtk/GdkWin32-4.0.gir

Closes #5112

See merge request GNOME/gtk!4965
2022-08-22 22:26:09 +00:00
Aurimas Černius
896155fab7 Updated Lithuanian translation 2022-08-22 23:21:45 +03:00
Matthias Clasen
727ec4cf7d Merge branch 'fix-calc-value-free' into 'main'
css: Fix freeing of calc values

Closes #5130

See merge request GNOME/gtk!4974
2022-08-22 16:31:23 +00:00
Matthias Clasen
a52ee9ee22 css: Fix freeing of calc values
We were getting our memory allocations mixed
up here.

Fixes: #5130
2022-08-22 11:51:56 -04:00
Matthias Clasen
94a9859391 Merge branch 'jpeg-memory-limit' into 'main'
Bump the jpeg memory limit

See merge request GNOME/gtk!4973
2022-08-22 15:03:40 +00:00
Matthias Clasen
d1755337a2 Bump the jpeg memory limit
Commit 59f6c50df8 set the memory limit to 100M,
which turns out to exclude some large, valid jpegs.
So, bump things to 300M, matching what was done
in gdk-pixbuf.
2022-08-22 10:48:00 -04:00
Matthias Clasen
092c166f54 Merge branch 'no-emoji-insert' into 'main'
text: Respect no-emoji hint fully

See merge request GNOME/gtk!4972
2022-08-21 20:47:27 +00:00
Matthias Clasen
13f8eeb3ee text: Respect no-emoji hint fully
We were disabling the insert-emoji action when the
no-emoji input hint is set, but the Ctrl-. shortcut
was bypassing the action and kept working. Make
the shortcut activate the action instead.

Fixes: #5123
2022-08-21 16:31:14 -04:00
Matthias Clasen
36768471e5 Merge branch 'wip/smcv/log-writer' into 'main'
icontheme test: Assert that the subprocess passed

See merge request GNOME/gtk!4969
2022-08-21 11:55:00 +00:00
Simon McVittie
3cfe04aa74 icontheme test: Assert that the subprocess passed
Noticed while backporting GLogWriterFunc fixes to 3.24.x (#5119).

Signed-off-by: Simon McVittie <smcv@debian.org>
2022-08-20 19:38:29 +01:00
Марко Костић
4965a3ea4b Update Serbian translation 2022-08-20 13:06:02 +00:00
Fran Dieguez
adc8a27f7a Update Galician translation 2022-08-20 11:26:34 +00:00
Luca Bacci
37d4dfb6b5 Merge branch 'gdk-win32-fix-handling-of-input-region' into 'main'
GdkWin32: Fix handling of WM_NCHITTEST

Closes #5114

See merge request GNOME/gtk!4966
2022-08-20 10:08:32 +00:00
Zurab Kargareteli
d887af0748 Update Georgian translation 2022-08-20 07:37:42 +00:00
Matthias Clasen
803ba1da4f Merge branch 'fix-emojichooser-keynav' into 'main'
emojichooser: Fix arrow keynav

Closes #5076

See merge request GNOME/gtk!4967
2022-08-19 20:12:51 +00:00
Matthias Clasen
78eaad614a emojichooser: Fix arrow keynav
When some of the Emoji have been filtered out by
a search term, arrow keynav would behave oddly and
get stuck in invisible sections. Fix this by ignoring
any filtered out children when moving between
sections for arrow keynav.

Fixes: #5076
2022-08-19 15:55:10 -04:00
Luca Bacci
749425808d Fix typo
And reword comment
2022-08-19 19:29:17 +02:00
Luca Bacci
5e299cd3d2 GdkWin32: Fix handling of WM_NCHITTEST
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/5114
2022-08-19 19:21:17 +02:00
Marc-André Lureau
8ab57fc8ef build-sys: generate GdkWin32.gir
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-08-19 17:42:30 +04:00
Matthias Clasen
3a8e45963f Merge branch 'mingw' into 'main'
Cross-building with mingw & fixes

See merge request GNOME/gtk!4341
2022-08-19 11:06:10 +00:00
Marc-André Lureau
ff16446b0b build-sys: do not install gdkwin32keys.h
Fixes: commit 89ad7893ad ("gdk: Make GdkKeymap a private api")

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-08-19 11:58:12 +04:00
Marc-André Lureau
82bcebe3de gdk/win32: remove old declaration
The function is gone since commit ea65abc7e2 ("Rewrite
GdkWin32Keymap (load table directly from layout DLL)")

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-08-19 11:58:12 +04:00
Benjamin Otte
a790764a7a Merge branch 'wip/otte/for-main' into 'main'
gdk: Plug a memleak

Closes #5110

See merge request GNOME/gtk!4964
2022-08-19 01:08:59 +00:00
Benjamin Otte
248e33e3c9 gdk: Plug a memleak
Free GdkIOPipe struct when freeing it
Don't just free all its members.

Fixes #5110
2022-08-19 02:38:11 +02:00
Matthias Clasen
44931aa8f8 Merge branch 'treeview-search-focus' into 'main'
treeview: Always call grab_focus_without_selecting on search entry

Closes #4551

See merge request GNOME/gtk!4961
2022-08-18 23:51:02 +00:00
Luca Bacci
fb83adef25 Merge branch 'remove-msys2-ci-subproject-workaround' into 'main'
CI: remove workaround for some subproject builds failing on Windows

See merge request GNOME/gtk!4923
2022-08-18 18:40:05 +00:00
Matthias Clasen
08de13e9d2 Merge branch 'wip/carlosg/im-fixes' into 'main'
gtkimcontextwayland: Refactor handling of client updates

Closes #5106 and #5105

See merge request GNOME/gtk!4962
2022-08-18 17:58:26 +00:00
Carlos Garnacho
f66ffde68d gtkimcontextwayland: Refactor handling of client updates
Currently, the wayland IM context sends zwp_text_input_v3.commit from
a number of places, and some of them with partial data. In order to
make client state updates "atomic" and complete, make the communication
happen over an unified notify_im_change() function that happens on
a narrower set of circumstances:

  - The GtkIMContext is reset
  - The GtkIMContext is just focused
  - The gesture to invoke the OSK is triggered
  - The IM context is reacting to changes coming from the compositor

Notably, setting the cursor location or the surrounding text do not try
to commit state on their own, and now will be flushed with the corresponding
IM update or reset. But also, these requests won't be prevented from
happening individually on serial mismatch, instead it will be the whole
state commit which is held off.

With these changes in place, all client-side updates are notified
atomically to the compositor under a single .commit request.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5106
Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5105
2022-08-18 19:19:53 +02:00
Carlos Garnacho
52ac71b972 gtktextview: Shuffle the places doing IM reset
During text widget manipulation (inserting or deleting text via keyboard)
the IM context is reset somewhat early, before the actual change took place.
This makes IM lag behind in terms of surrounding text and cursor position.

Shuffle these IM reset calls so that they happen after the changes, and
ensure that the IM is actually reset, since that is currently toggled on
a pretty narrow set of circumstances.

Also, fix a bug during GtkEventControllerKey::im-update where the condition
on cursor position editability to reset the IM context was inverted.
2022-08-18 19:07:12 +02:00
Mat
27eaca8b79 treeview: Always call grab_focus_without_selecting on search entry
The search text entry is always a GtkText widget, not GtkEntry. If a
custom search entry is set, this part of the code is never reached.

Fixes #4551
2022-08-18 18:03:04 +03:00
Marc-André Lureau
63dce34396 ci: add fedora-mingw64 job
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-08-18 11:45:21 +04:00
Marc-André Lureau
3585da6b7f build-sys: fix linker warning on win32
[196/296] Linking target testsuite/gtk/builder.exe
/usr/lib/gcc/x86_64-w64-mingw32/11.2.1/../../../../x86_64-w64-mingw32/bin/ld: warning: --export-dynamic is not supported for PE+ targets, did you mean --export-all-symbols?

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-08-18 11:44:34 +04:00
Carlos Garnacho
9e29739e66 gtktext: Shuffle the places doing IM reset
During text widget manipulation (inserting or deleting text via keyboard)
the IM context is reset somewhat early, before the actual change took place.
This makes IM lag behind in terms of surrounding text and cursor position.

Shuffle these IM reset calls so that they happen after the changes, and
ensure that the IM is actually reset, since that is currently toggled on
a pretty narrow set of circumstances.
2022-08-18 00:55:30 +02:00
Matthias Clasen
82395e73ad Merge branch 'wip/smcv/rej' into 'main'
demos: Remove detritus from a patch not applying cleanly

See merge request GNOME/gtk!4957
2022-08-16 12:28:46 +00:00
Simon McVittie
0237713c3a demos: Remove detritus from a patch not applying cleanly
I assume this was committed by mistake. It isn't used, and some
packaging systems will automatically remove it during `clean`.

Signed-off-by: Simon McVittie <smcv@debian.org>
2022-08-16 08:32:45 +01:00
Jordi Mas
7e0e8365bd Update Catalan translation 2022-08-15 23:58:40 +02:00
Luca Bacci
fbd11fc595 Merge branch 'overshoot-win32-fix' into 'main'
GdkWin32: Support high resolution scroll wheel events

See merge request GNOME/gtk!4950
2022-08-15 21:33:19 +00:00
Matthias Clasen
bebaac64e1 Merge branch 'gtktreeview-adjustment' into 'main'
treeview: Do not set top row adjustment value while animating

Closes #4550

See merge request GNOME/gtk!4940
2022-08-14 22:40:32 +00:00
Matthias Clasen
1d232a725f Merge branch 'treeview-widget-coords' into 'main'
treeview: Use widget coordinates where required

See merge request GNOME/gtk!4939
2022-08-14 22:39:21 +00:00
Benjamin Otte
fb4312738d Merge branch 'wip/otte/for-main' into 'main'
listitemwidget: Actually unref the listitems

Closes #5102

See merge request GNOME/gtk!4955
2022-08-14 21:19:48 +00:00
Benjamin Otte
918dd66dca listitemwidget: Actually unref the listitems
Fixes #5102
2022-08-14 22:55:27 +02:00
Ricardo Maia Louro
6ceacee0f9 GdkWin32: Support high resolution scroll wheel events 2022-08-14 18:30:28 +01:00
Piotr Drąg
f1e81d176c Update Polish translation 2022-08-14 15:24:39 +02:00
Matthias Clasen
8d18b2b92d Merge branch 'fix-gears-leak' into 'main'
gtk4-demo: Fix a memory leak

See merge request GNOME/gtk!4954
2022-08-13 21:42:35 +00:00
Matthias Clasen
4a04e468fd gtk4-demo: Fix a memory leak
The gears demo was leaking its vertices.
2022-08-13 17:27:40 -04:00
Matthias Clasen
f8d1912098 Merge branch 'wayland-cursor-texture-leak' into 'main'
wayland: Avoid leaking cursor textures

See merge request GNOME/gtk!4953
2022-08-13 17:35:56 +00:00
Matthias Clasen
0bd15b44f2 wayland: Avoid leaking cursor textures
When we fall back to the default cursor and load it
from a resource, we need to free the texture.
2022-08-13 13:19:49 -04:00
Matthias Clasen
e4fb6933d2 Merge branch 'inscription-leak-fixes' into 'main'
inscription: Plug a memory leak

See merge request GNOME/gtk!4952
2022-08-13 00:49:33 +00:00
Matthias Clasen
33cf8f9404 inscription: Plug a memory leak
PangoFontMetrics also need to be freed.
2022-08-12 20:35:36 -04:00
Matthias Clasen
1640390839 inscription: Plug a memory leak
PangoLayoutIter needs to be freed.
2022-08-12 20:35:36 -04:00
Matthias Clasen
b01f28b9e2 Merge branch 'fix-cups-backend-leak' into 'main'
Add more valgrind suppressions

See merge request GNOME/gtk!4951
2022-08-12 23:00:44 +00:00
Matthias Clasen
62192cba6e cups printbackend: Plug memory leaks
This loop has many early exits, and all of them
need to free this info object that gets allocated
at the beginning.
2022-08-12 18:44:25 -04:00
Matthias Clasen
586826d34c Add more valgrind suppressions
This gets all GQuark functions out of the logs.
2022-08-12 12:44:02 -04:00
Matthias Clasen
c7a55faf37 Merge branch 'fix-a11y-leak' into 'main'
a11y: Fix a memory leak

See merge request GNOME/gtk!4949
2022-08-12 16:17:48 +00:00
Matthias Clasen
e81db46578 a11y: Fix a memory leak
We need to free the queued context list in dispose
if we didn't get to register the contexts, and we also
need to free the list properly when we do get to
register them.

This showed up in valgrind as leaked GList structs.
2022-08-12 12:01:42 -04:00
Goran Vidović
e036eebde8 Update Croatian translation 2022-08-12 14:33:14 +00:00
Goran Vidović
dfa45c0da2 Update Croatian translation 2022-08-12 14:25:29 +00:00
Goran Vidović
6692c7e9c4 Update Croatian translation 2022-08-12 14:22:10 +00:00
Zurab Kargareteli
671f33a7b8 Update Georgian translation 2022-08-12 03:32:05 +00:00
Matthias Clasen
0fee50d1a5 Merge branch 'fix-leak' into 'main'
gtk/css: data_url_path fix leak in error path

See merge request GNOME/gtk!4947
2022-08-12 00:09:15 +00:00
Pablo Correa Gómez
97d3363360 gtk/css: data_url_path fix leak in error path
Fixes 7900032f30
2022-08-12 01:34:18 +02:00
Matthias Clasen
6eb3548192 4.7.2 2022-08-11 14:26:50 -04:00
Matthias Clasen
e5a47b5592 Merge branch 'improve-css-test' into 'main'
css: Propagate charset conversion errors

See merge request GNOME/gtk!4943
2022-08-11 11:58:04 +00:00
Matthias Clasen
6c3119bc33 tests: Check the error first
The error contains useful information when
things fail, so check it first to get useful
output in case of failure.
2022-08-11 07:29:56 -04:00
Matthias Clasen
7900032f30 css: Propagate charset conversion errors
Lets not throw away informtation that
helps to figure out why things fail.
2022-08-11 07:29:56 -04:00
Matthias Clasen
a020cf7534 Merge branch 'matthiasc/for-main' into 'main'
jpeg loader: Limit memory consumption

See merge request GNOME/gtk!4942
2022-08-10 17:57:55 +00:00
Matthias Clasen
59f6c50df8 jpeg loader: Limit memory consumption
This will prevent stupid oom situations with pathological
jpeg files, without affecting our ability to load reasonable
images.
2022-08-10 13:25:17 -04:00
Matthias Clasen
bbd6fdaa04 Merge branch 'jx/hi-res-scrolling' into 'main'
High-resolution scroll wheel support

See merge request GNOME/gtk!3839
2022-08-10 16:51:55 +00:00
Carlos Garnacho
6a7136d5fb ci: Disable -Werror on wayland submodule
CI is mostly interested in GTK not introducing compiler warnings, other
submodules like Wayland might have their own and that shouldn't hinder
CI testing of GTK.

Disable -Werror for the wayland submodule, and let it be fixed independently
at some point.
2022-08-10 16:37:17 +02:00
José Expósito
95860d4989 gtkeventcontrollerscroll: Always accumulate discrete deltas
When GTK_EVENT_CONTROLLER_SCROLL_DISCRETE is set, accumulate deltas also
for mouse scroll so a high-resolution mouse wheel click behaves in the
in the same manner as a low-resolution mouse wheel click.
2022-08-10 14:23:58 +00:00
José Expósito
37a561eb53 gdk/x11: Handle high-resolution scroll events 2022-08-10 14:23:58 +00:00
José Expósito
ed0a2a203c gdk/wayland: Handle high-resolution scroll events
Starting with the Wayland protocol wl_pointer >= 8, discrete axis
events have been deprecated in favour of high-resolution scroll event.

Add a listener for high-resolution scroll events and, for backwards
compatibility, handle discrete events as discrete*120.
2022-08-10 14:23:58 +00:00
José Expósito
fc3aca8223 gdk/wayland: Calculate discrete scroll direction in its helper
Refactor, no functional changes.
2022-08-10 14:23:58 +00:00
José Expósito
6ebb38e12e gdk/events: Set discrete scroll deltas in its constructor
Instead of calculating the discrete scroll deltas in
GtkEventControllerScroll, move that code to the event constructor and
access the precalculated values using gdk_scroll_event_get_deltas.

Refactor, no functional changes.
2022-08-10 14:23:58 +00:00
José Expósito
51ca454eef gdk/events: Add constructor for high-resolution scroll events
Starting with Linux Kernel v5.0 two new axes are available for
mice that support high-resolution wheel scrolling: REL_WHEEL_HI_RES and
REL_HWHEEL_HI_RES.

Both axes send data in fractions of 120 where each multiple of 120
amounts to one logical scroll event. Fractions of 120 indicate a wheel
movement less than one detent.

The 120 magic number is a copy of the Windows API, so this new
constructor can be used both in Linux >= 5.0 and Windows >= Vista.
2022-08-10 14:23:58 +00:00
José Expósito
fb100d719f build: Update Wayland to >= 1.21.0 2022-08-10 14:23:58 +00:00
Jordi Mas
cf1974f6b1 Update Catalan translation 2022-08-10 14:27:44 +02:00
Emmanuele Bassi
3f4a0aa1f3 Merge branch 'rounded-clip-node-new-transfer-full' into 'main'
Mark gsk_rounded_clip_node_new() return value as (transfer full)

See merge request GNOME/gtk!4941
2022-08-10 09:23:02 +00:00
Sebastian Dröge
0cc2d5559b Mark gsk_rounded_clip_node_new() return value as (transfer full)
Like all the other constructors for nodes already do. Without this,
newly created rounded clip nodes are leaked in bindings.
2022-08-10 11:07:51 +03:00
Mat
b4ade026f1 treeview: Do not set top row adjustment value while animating
gtk_tree_view_top_row_to_dy, which is called from GtkTreeView's
size_allocate function, changes the adjustment value. Since this
conflicts with the animation when changing the active row, bail
out until the animation is finished.

Fixes #4550
2022-08-10 08:32:47 +03:00
Mat
102ca838b8 treeview: Use widget coordinates where required
When a GtkTreeView scrolled horizontally, it was not possible to
select rows outside the initial area due to an erroneous comparison
between widget and bin window coordinates.

Original change to widget coordinates occurred in commit
a0de570e47
2022-08-10 04:25:19 +03:00
Carlos Garnacho
378ae4fbc1 Merge branch 'gbsneto/paned-focus-infloop' into 'main'
paned: Protect against NULL variable

Closes #5094

See merge request GNOME/gtk!4938
2022-08-09 18:26:48 +00:00
Matthias Clasen
00f079d705 Merge branch 'wip/carlosg/fix-crossing-on-unmap' into 'main'
gtkwindow: Use pointer-oriented function to deal with crossing events

Closes #5094

See merge request GNOME/gtk!4937
2022-08-09 18:15:41 +00:00
Carlos Garnacho
54465adff2 gtkwindow: Use pointer-oriented function to deal with crossing events
Commit adba0b97 fixed missed pointer crossings by using a helper function that
was already present and looked like did everything that was needed. However
this function was oriented to keyboard focus and it also did update the related
widget state. Doing these changes on pointer-based crossing was misuse, and
could cause weird interactions with keyboard focus management.

Fix this by using gtkmain.c gtk_synthesize_crossing_event() that is in fact
oriented to pointers.

Fixes: adba0b97 (gtkwindow: Synthesize pointer crossing events on state changes)
Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5094
2022-08-09 19:48:15 +02:00
Georges Basile Stavracas Neto
29580d4252 paned: Warn if child is not actually a child
This will at least allow us to debug this in the future.
2022-08-09 14:20:25 -03:00
Carlos Garnacho
25c3616a79 gtkmain: Pass coordinates when synthesizing pointer events
Instead of passing an event and figuring out coordinates from it, pass
directly the toplevel coordinates so that we can use this outside event
handling.

All callers have been updated to pass the coordinates, in practical effects
they were already based on the GtkNative.
2022-08-09 19:13:28 +02:00
Georges Basile Stavracas Neto
120399cc92 paned: Protect against NULL variable
The inner loop in gtk_paned_set_focus_child() tries to find the
topmost GtkPaned, however, if the `w` variable ends up becoming
NULL after bubbling up the entire GtkWidget hierarchy, this loop
never breaks.

Check for NULL in this loop.

Closes https://gitlab.gnome.org/GNOME/gtk/-/issues/5094
2022-08-09 13:59:09 -03:00
Kukuh Syafaat
86e5ad85b7 Update Indonesian translation 2022-08-09 02:12:09 +00:00
Quentin PAGÈS
04ad5e8936 Update Occitan translation 2022-08-08 20:49:35 +00:00
Carlos Garnacho
9691a11076 Merge branch 'wip/exalm/multiplier' into 'main'
scrolledwindow: Lower the scroll multiplier

See merge request GNOME/gtk!4933
2022-08-08 12:00:15 +00:00
Daniel Mustieles
fef3ab0b62 Updated Spanish translation 2022-08-08 12:42:06 +02:00
Alexander Mikhaylenko
493660a296 scrolledwindow: Lower the scroll multiplier
c68247f63b introduced a scroll multiplier,
intended to be significantly lower than the GTK 4.6 behavior but higher
than 1. However, it was _higher_ than 4.6, since 4.6 also had a permanent
1/10 multiplier in GDK, so the cited multiplier values were really 6.4 and
9.7.
2022-08-08 00:07:36 +04:00
Matthias Clasen
73f634435a Merge branch 'build-fix-glib-2.66' into 'main'
build: fix for use with glib 2.66.0 (2nd try)

See merge request GNOME/gtk!4932
2022-08-07 19:09:04 +00:00
Matthias Clasen
b17bba4af2 Merge branch 'wip/carlosg/scroll-overshoot' into 'main'
gtk/scrolledwindow: Check for overshoot setting up kinetic scroll helpers

Closes #4784

See merge request GNOME/gtk!4909
2022-08-07 19:01:25 +00:00
Emmanuele Bassi
ba1a084899 Apply 1 suggestion(s) to 1 file(s) 2022-08-07 18:54:19 +00:00
Carlos Garnacho
0e5a97ae58 gtk/scrolledwindow: Check for overshoot setting up kinetic scroll helpers
We may have situations where velocity is 0/0, but are overshooting. Places where
this happens are mouse wheels, and continuous scroll that ended up still before
finish. In this situation we also want to run the animation for overshoot, so
check for the corresponding axes to also set up the kinetic scroll helper.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4784
2022-08-07 20:26:52 +02:00
Matthias Clasen
7a306fe32f Merge branch 'wip/carlosg/fixes' into 'main'
Some fixes

Closes #2877 and #5003

See merge request GNOME/gtk!4929
2022-08-07 18:06:28 +00:00
Emmanuele Bassi
ac7009d56c Merge branch 'clipboard-seg2' into 'main'
x11: Don't assume valid type

See merge request GNOME/gtk!4912
2022-08-07 16:21:40 +00:00
Carlos Garnacho
c68247f63b gtkscrolledwindow: Add fixed multiplier to scroll events in surface units
The expected configurability is not going to arrive yet from compositors, and
it is precipitate for GTK to gain any configurability. We do know a factor of 1
feels way too slow, and we do know a factor of page_size * pow (2 / 3) feels way
way too fast.

With the previous multiplier, gtk4-demo at its default size had a vertical textview
factor of 64.332901, and maximized on a 1920x1080 screen a factor of 97.585365.
Pick a magic multiplier that is both significantly below these values and above 1,
and stick to it.

Future work will add the configurability of smooth scroll events where it belongs.
At that point this commit may be reverted so we don't pile up on magic numbers again.

Related: https://gitlab.gnome.org/GNOME/gtk/-/issues/4793
2022-08-07 17:16:14 +02:00
Asier Sarasua Garmendia
668a2c0f3e Update Basque translation 2022-08-07 09:49:00 +00:00
Hugo Carvalho
c435c7e764 Update Portuguese translation 2022-08-06 23:01:57 +00:00
Danial Behzadi
4d36a4ebd7 Update Persian translation 2022-08-06 22:43:23 +00:00
Hannes Müller
703fc51d8e build: fix for use with glib 2.66.0
Add missing #define g_memdup2() for gdksurface-broadway.c in case of enabled
broadway-backend as used otherwise.

Copy static would_drop() replacement for g_log_writer_default_would_drop()
from gtk-builder-tool.c to gtk-reftest.c
2022-08-06 21:11:08 +02:00
Aleksandr Melman
fb008578b4 Update Russian translation 2022-08-06 14:44:53 +00:00
Carlos Garnacho
adba0b972e gtkwindow: Synthesize pointer crossing events on state changes
When widgets go mapped/unmapped, we repick but don't generate crossing
events. Since there could be stateful controllers that use those in
the previously picked widget (e.g. GtkEventControllerMotion), skipping
those breaks their state.

Ensure to send the relevant crossing events on every situation that
changes the pointer focus, so these controllers get a fair opportunity
to undo their state.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2877
2022-08-05 19:25:13 +02:00
Carlos Garnacho
c77b98d716 gdk/wayland: Drop surface checks on wl_pointer.leave handling
Even though the argument is non-nullable, GTK sometimes incurs in that
by itself by destroying the surface while the event is in flight. This
is the case of popping down a GtkDropdown. When this happens we simply
ignore the crossing event, but we should let it through instead, the
compositor did not send it in vain and we possibly still have pointer
state to undo.

Drop the surface checks, so that the event is propagated along GTK.
2022-08-05 19:25:13 +02:00
Carlos Garnacho
8eda182f24 gtkeventcontroller: Fix internal enum documentation
Copy and paste typo.
2022-08-05 19:25:13 +02:00
Carlos Garnacho
15e0c175a3 gtkgesturerotate: Filter touchpad holds events
Since the pinch touchpad gestures already have begin/update/end phases,
this gesture has no actual use for these events.
2022-08-05 19:25:13 +02:00
Carlos Garnacho
bc953eebdd gtkgesturerotate: Filter touchpad holds events
Since the pinch touchpad gestures already have begin/update/end phases,
this gesture has no actual use for these events.
2022-08-05 19:25:13 +02:00
Carlos Garnacho
6238f97cb6 gdkevent: Give touchpad hold events a sequence
Following what was done for pinch/swipe events, give hold gestures their
own distinct sequence as well. Without this it was NULL, which was already
distinct to other touchpad gestures.
2022-08-05 19:25:13 +02:00
Carlos Garnacho
023924bca9 gtkgesture: Do not coalesce hold events with other touchpad gestures
This delaying of the cancel event was made to avoid intermediate cancellation
for >=2fg hold gestures followed by pinch/swipe gestures, and it worked as
long as everything was considered to have the same sequence.

Since each pinch/swipe pointer gesture now gets its own sequence, this no
longer applies, nor works. This results in zoom/rotate/swipe gestures being
stuck since the sequence for the touchpad events changes mid-gesture.

Sticking to this pattern of giving touchpad gestures their own sequence,
these hold events cannot be assumed to coalesce with other touchpad gestures,
it is better to let it propagate altogether so that both the hold gesture
and the incoming gesture trigger coherent begin and end/cancel phases.

In the worst case, this results in "::begin, ::cancel, ::begin , ..." before
triggering a touchpad gesture, but the extra begin/cancel ought to be a safe
no-op in widgets.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5003
2022-08-05 19:25:13 +02:00
Matthias Clasen
af6432aa67 Merge branch 'ebassi/textbuffer-private-api' into 'main'
Move private function out of the AT-SPI a11y backend

See merge request GNOME/gtk!4924
2022-08-05 12:01:27 +00:00
Emmanuele Bassi
6c37158bbc Re-enable the TextBuffer wrap-mode serialization test
The private serialization function is now available on all platforms.
2022-08-04 23:39:54 +01:00
Emmanuele Bassi
d030c92d63 Move private function out of the AT-SPI a11y backend
The textbuffer test is calling into a function defined by the AT-SPI
accessibility backend. As of commit 4ddf1b70 we only build and run the
test on Linux, but the function in question isn't really
accessibility-related: it's just a serialization function.
2022-08-04 23:34:41 +01:00
Christoph Reiter
efe100df9e CI: remove workaround for some subproject builds failing on Windows
In some cases subproject builds under MSYS2 failed, see
https://gitlab.gnome.org/GNOME/gtk/-/issues/2243
https://gitlab.gnome.org/GNOME/gtk/-/issues/3002
https://gitlab.gnome.org/GNOME/gtk/-/issues/5053

These manual pango/glib build instructions were added to work around
the problem by avoiding the subprojects.

https://gitlab.gnome.org/GNOME/gtk/-/issues/5053 uncovered the bug in
binutils, which is now fixed in master there and was also backported
into MSYS2 which we use in CI.

So we can just remove the workaround again now.
2022-08-04 22:26:04 +02:00
Yuri Chornoivan
a07ee709d2 Update Ukrainian translation 2022-08-04 14:33:50 +00:00
Matthias Clasen
60b77736b5 Merge branch 'cleanup-ffmpeg' into 'main'
ffmpeg: add audio playback through avdevice

See merge request GNOME/gtk!4852
2022-08-04 10:49:45 +00:00
Stephan Vedder
83ff85d227 ffmpeg: add audio playback through avdevice 2022-08-04 10:49:44 +00:00
Matthias Clasen
f7b3a214f3 Merge branch 'mount_operation' into 'main'
mountoperation: Fix authentication dialog

Closes #5059 and #5058

See merge request GNOME/gtk!4899
2022-08-03 11:56:25 +00:00
Matthias Clasen
c1053096bd Merge branch 'win32-nahimic-nv-notes' into 'main'
running.md: Mention about issue with Nahimic on Windows

Closes #4113

See merge request GNOME/gtk!4915
2022-08-02 11:10:25 +00:00
Chun-wei Fan
f2b85fa1c7 running.md: Mention about issue with Nahimic on Windows
Let people know that they will need to use GTK with the Nahimic service
disabled or OpenGL disabled or put their GTK application into the Nahimic
backlist, or try to use GLES, since there is a known issue in the Windows
nVidia graphics drivers and Nahimic that causes GL operations to fail,
causing crashes in operations such as window resizes.

This will close issue #4113--sadly, there is nothing we can do within
GTK to fix the issue.
2022-08-02 13:50:49 +08:00
Matthias Clasen
a48942bf39 Merge branch 'label-tabs' into 'main'
Label tabs

See merge request GNOME/gtk!4914
2022-08-02 00:18:44 +00:00
Benjamin Otte
c1d6160bd4 Merge branch 'otte-main-patch-86462' into 'main'
Fix g_object_new(GTK_TYPE_SNAPSHOT)

See merge request GNOME/gtk!4919
2022-08-01 20:47:12 +00:00
Benjamin Otte
dbab69c453 snapshot: Don't critical on dispose
When there's remaining state that draws nothing, it returns no
rendernode. So do a NULL-check before unreffing it.
2022-08-01 20:28:46 +00:00
Benjamin Otte
09f0c96b9b Fix g_object_new(GTK_TYPE_SNAPSHOT)
GJS apparent likes g_object_new() over actual constructors, so make that work.
2022-08-01 20:08:58 +00:00
Matthias Clasen
641a589734 Add GtkLabel:tabs
This adds more powerful formatting capabilities to GtkLabel
without costing us much, since Pango already supports tabs.
2022-08-01 08:20:05 -04:00
Christian Hergert
9bce70ed8d Merge branch 'wip/chergert/builder-expose-object-fix' into 'main'
builder: gracefully handle re-exposing builder object

See merge request GNOME/gtk!4913
2022-08-01 05:09:53 +00:00
Christian Hergert
d00d1334ce gtkbuilder: update gtk_builder_expose_object() docs 2022-07-31 21:37:20 -07:00
Christian Hergert
fbe124ca54 gtkbuilder: update gtk_builder_extend_with_templat() docs 2022-07-31 21:25:58 -07:00
Christian Hergert
f680b86130 gtkbuilder: check for existing object before extending template
If gtk_builder_expose_object() is called twice with the same name, it will
result in a g_critical(). This improves that situation by checking for the
object before exposing additional times.

This turns out to be handy in situations where templates are expanded
multiple times, such as application-side implementations of UI merging.
2022-07-31 21:25:58 -07:00
Dr. David Alan Gilbert
dbc4e18bf8 x11: Don't assume valid type
If we get an invalid TARGETS reply, we might not have a valid 'type',
which ends up as NULL and segs in the g_str_equal.

(This is probably fallout from my fix 506566b6a4, which I still
can't reproduce reliably, so the last one just moved the seg a bit
further along, and we still don't know who is sending a bad TARGETS).

This corresponds to:
https://bugzilla.redhat.com/show_bug.cgi?id=2062143
2022-07-30 22:11:59 +01:00
Luca Bacci
924da0e84b Merge branch 'fix-gdk-win32-dnd' into 'main'
Fix DnD on Windows

Closes #4498

See merge request GNOME/gtk!4900
2022-07-29 12:42:57 +00:00
Christian Kirbach
38f14303d8 Update German translation 2022-07-28 21:13:07 +00:00
Nart Tlisha
b896b73e5e Update Abkhazian translation 2022-07-28 19:19:12 +00:00
Matthias Clasen
81a65690f8 Merge branch 'alatiera/node-flatpak' into 'main'
flatpak: add a NodeEditor demo

See merge request GNOME/gtk!4898
2022-07-28 18:08:47 +00:00
Matthias Clasen
33f7d96e8f Merge branch 'ebassi/file-list-fixes' into 'main'
Add constructors for GdkFileList

See merge request GNOME/gtk!4907
2022-07-28 18:07:34 +00:00
Emmanuele Bassi
dcd549aebe Add constructors for GdkFileList
C API users can keep dealing with the implicit equivalence of
GdkFileList and GSList, but language bindings have no idea that one type
is another, and none of them exposes GSList as a type anyway, so they
will need a way to construct a GdkFileList.

Instead of making GdkFileList mutable, and re-implement GSList, we only
provide a constructors pair that lets you create a GdkFileList from a
linked list or from an array.
2022-07-28 14:41:35 +01:00
Emmanuele Bassi
8a4aee583c Merge branch 'barthalion/gnome-runtime-images-quay' into 'main'
Update (or drop) the Docker image used by Flatpak job

See merge request GNOME/gtk!4906
2022-07-27 11:39:55 +00:00
Bartłomiej Piotrowski
ea21923932 Update (or drop) the Docker image used by Flatpak job
The gnome-runtime-images have been recently migrated to Quay. This is already reflected in the template.

Please note this MR has been created semi-automatically. If it doesn't make sense, feel free to close it.
2022-07-27 12:47:50 +02:00
Daniel Mustieles
5ca266f137 Updated Spanish translation 2022-07-27 11:36:48 +02:00
Christian Hergert
b9f374c0c6 Merge branch 'wip/chergert/disable-sysprof-agent' into 'main'
build: configure subproject sysprof with -Dagent=false

See merge request GNOME/gtk!4896
2022-07-26 23:44:37 +00:00
Christian Hergert
a32b9d8b51 build: configure subproject sysprof with -Dagent=false
Sysprof has a new -Dagent=true build option which allows installing a
/usr/bin/sysprof-agent program (simimlar to sysprof-cli). It provides a
P2P D-Bus API to the process which can control subprocesses. It's used by
IDE tooling to have more control across container boundaries.

However, we do not need it for GTK CI.
2022-07-26 16:29:25 -07:00
Emmanuele Bassi
c92b27f41b Merge branch 'markand-main-patch-04776' into 'main'
gtk: Missing end of code block

See merge request GNOME/gtk!4902
2022-07-26 15:09:28 +00:00
David Demelier
06bec5fb45 gtk: Missing end of code block 2022-07-26 14:52:30 +00:00
Nart Tlisha
e0be85ccca Add Abkhazian translation 2022-07-26 11:17:20 +00:00
Benjamin Otte
0c052c9a37 Merge branch 'gridview' into 'main'
Gridview fix rubberbanding issues

Closes #3462 and #3445

See merge request GNOME/gtk!4688
2022-07-26 01:08:08 +00:00
Corey Berla
a7bbc25851 listview: Fix selection for last item in get_items_in_rect
Make the last item dependent on y + height
2022-07-25 17:55:26 -07:00
Corey Berla
d6fab1408a listview: Allow starting rubberband in empty space below last row
Rubberband does not work when initiated past the last row
(warning is printed "Could not start rubberbanding: No item).

Clamp y at the max height of the widgets in the listview
2022-07-25 17:55:15 -07:00
Corey Berla
e14b84ff67 listview: Return an empty bitset when selecting only empty space
Return an empty bitset if the user selects exclusively below the last
row.
2022-07-25 17:54:44 -07:00
Corey Berla
aba2d994e6 gridview: Fix typo in docstring for gtk_grid_view_get_cell_at_y() 2022-07-25 17:54:44 -07:00
Corey Berla
57c032e6cc listbase: Clear selection if rubberband selected an empty set
If rubberband returns an empty bitset the selection should be cleared
unless the shift or ctrl key is held
2022-07-25 17:54:44 -07:00
Corey Berla
f3fc8f5b35 gridview: Return an empty bitset when selecting only empty space
Return an empty bitset if the user selects exclusively below the last
row.  No need to calculate selection.
2022-07-25 17:54:44 -07:00
Corey Berla
ba909cf901 gridview: Fix get_items_in_rect() selection
last_row should be dependent on y + height, not y
2022-07-25 17:54:44 -07:00
Corey Berla
1e9a36ffa8 gridview: Allow starting rubberband in empty space below last row
Rubberband does not work when initiated past the last row
(warning is printed "Could not start rubberbanding: No item).

Clamp y at the max height of the widgets in the gridview

Fixes: #3462
2022-07-25 17:54:35 -07:00
Corey Berla
c6f357e447 gridview: Limit rectangle to gridview columns
The function gtk_grid_view_get_items_in_rect() erroneously calculates
columns less than 0 and greater than n_columns when the user attempts
to rubberband all the way to the left or right respectively.  This
causes the rubberband to persistent and creates unexpected behavior.
Limit the rows to a minimum of 0 and maximum of n_columns - 1.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3445
2022-07-25 17:27:24 -07:00
Corey Berla
2bcae546b3 gridview: Move gtk_grid_view_computer_total_height() up for reuse 2022-07-25 17:27:24 -07:00
Emmanuele Bassi
291696607a Merge branch 'widget-docs-fix' into 'main'
gtkwidget: Fix a small typo in a docs comment

See merge request GNOME/gtk!4901
2022-07-25 21:31:18 +00:00
Philip Withnall
87ba99f66b gtkwidget: Fix a small typo in a docs comment
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-07-25 23:15:58 +02:00
Zurab Kargareteli
fc20268cb8 Update Georgian translation 2022-07-25 16:03:57 +00:00
darkcutler
64a959dad9 Fix DnD on Windows
DnD under Windows needed 3 fixes to work with Gtk.DropTarget.

1. The droptarget_w32format_contentformat_map list never gets
filled so the gdk_win32_drop_read_async throws
"No compatible transfer format found".
This is an easy fix and done the same way in the win32 clipboard code.

2. After a drop no gdk_drop_emit_leave_event gets emitted.
This causes a second drop to trigger a bunch of assertion
'self->drop == drop' failed because the first drop is still active.
This is also an easy fix and done the same way by the macos backend.

3. Handling gdk_drop_status/gdk_drop_get_actions interaction.
In gtk_drop_target_do_drop the code
```gdk_drop_finish (self->drop, gdk_drop_get_actions (self->drop));```
calls the finish operation with the actions of the drop which triggers
```g_return_if_fail (gdk_drag_action_is_unique (action));```
in gdk_drop_finish. The code assumes that GdkDrop::actions gets
narrowed down by calling gdk_drop_status. This is hard to assure
because at the same time gdk_drop_get_actions is used by
gtk_drop_target_accept to figure out if a drag is accepted.
GdkDrop::actions serves a double purpose here as the supported source
actions and the currently agreed on action. Both the x11 and the
wayland backend get this wrong somewhat too. Under wayland/x11 when
a drag coming from a source that supports both MOVE and COPY is
first hovering a drop target that only supports COPY it is afterwards
no longer accepted by other drop targets only accepting MOVE.
Under x11 this is permanent for this drag but with wayland the drag
recovers when hovering other widgets. The win32 backend now sets the
supported source actions before any enter/move/drop and narrows them
down in gdk_win32_drop_status.

The patch only touches the win32 backend and fixes all three issues,
for me restoring DnD under windows.

Closes #4498
2022-07-25 15:16:23 +00:00
Corey Berla
111929593a mountoperation: Free user_widgets list upon dialog destruction
There's a list user_widgets that contains all of the entries and
selections during authentication.  This is only freed  upon
finalizing the GtkMountOperation.  It's possible (and true for the
GVFS SMB implementation) that a MountOperation can have the
gtk_mount_operation_ask_password_do_gtk () function called multiple
times (i.e. bad password).  The user_widgets list grows with now
invalid pointers to old widgets (causing unexpected behavior and
seg faults).

Free the user_widgets list upon dialog destruction, we don't need it
anymore.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5059
Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5058
2022-07-25 06:54:14 -07:00
Jordan Petridis
23bd7c1c05 flatpak-build.sh: change the buildtype to debugoptimized
So that the flatpaks will include debuginfo and make debugging
easier.
2022-07-25 15:42:14 +03:00
Jordan Petridis
f99880a74a flatpak: add a NodeEditor demo 2022-07-25 15:38:55 +03:00
Emmanuele Bassi
61bf5ac009 Merge branch 'content-fit-since' into 'main'
picture: Fix Since and Deprecated annotations for content-fit

See merge request GNOME/gtk!4897
2022-07-25 11:45:43 +00:00
Maximiliano Sandoval R
ef07d1556b picture: Fix Since and Deprecated annotations
gi-docgen will parse four or more whitespaces of indentation as code blocks,
two whitespaces were used.

This was missing in https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4873.
2022-07-25 12:59:47 +02:00
Corey Berla
dd5d1030b5 mountoperation: Select "Anonymous" check button by default
It is already explicitly assumed that anonymous authentication will
be used when available, but it is not clear to the user since neither
of the check buttons are selected.  Select the Anonymous check button
by default.
2022-07-24 20:53:41 -07:00
Jordi Mas
f480ff2e4d Update Catalan translation 2022-07-21 04:25:20 +02:00
Mat
9c919ffa46 treepopover: Do not propagate natural width of content
Propagating the natural width of the tree popover contents breaks ellipsizing of items
(see 'Unconstrained menu' in tests/testcombo).
2022-07-20 16:51:33 +03:00
Carlos Garnacho
2b131f09a8 Merge branch 'fix-controller-key-event-propagation-file-chooser-widget' into 'main'
GtkFileChooserWidget: Propagate captured key events when the location entry is focused

Closes #4880

See merge request GNOME/gtk!4674
2022-07-19 22:15:04 +00:00
Matthias Clasen
b165028e86 Merge branch 'drag-action' into 'main'
tree/iconview: Use a unique drag action in drag_enter/motion callbacks

Closes #3187

See merge request GNOME/gtk!4882
2022-07-18 14:35:11 +00:00
Matthias Clasen
6e379181d9 Merge branch 'treeview-drag-ancestor' into 'main'
treeview: Check for column header area in row click/drag gestures

Closes #4453

See merge request GNOME/gtk!4885
2022-07-18 14:33:26 +00:00
Matthias Clasen
edf8c9e501 Merge branch 'matthiasc/for-main' into 'main'
css: Fix handling of transform values

See merge request GNOME/gtk!4890
2022-07-18 14:24:49 +00:00
Matthias Clasen
f95f992d32 Merge branch 'wip/carlosg/use-press-serial' into 'main'
gdk/wayland: Use last implicit grab serial for DnD start requests

Closes #5048

See merge request GNOME/gtk!4889
2022-07-18 14:18:22 +00:00
Carlos Garnacho
95cf34ab4c gdk/wayland: Stop storing the last serial in GdkWaylandDisplay
This is not used anymore, so we can drop the serial being stored
here.
2022-07-18 15:21:40 +02:00
Matthias Clasen
0cebf6d9c5 Merge branch 'drop-target-unique' into 'main'
droptarget: Provide a unique action for gdk_drop_finish

Closes #5051

See merge request GNOME/gtk!4888
2022-07-18 12:38:52 +00:00
Matthias Clasen
de6b8da6c4 Merge branch 'tree-popover-scroll' into 'main'
treepopover: Add support for scrolling

Closes #3674 and #4877

See merge request GNOME/gtk!4887
2022-07-18 12:28:34 +00:00
Matthias Clasen
03f24bb5cf css: Improve test coverage
Among other things, this includes a test for the fix
in the previous commit.
2022-07-18 07:08:01 -05:00
Matthias Clasen
6ef3968227 css: Fix handling of transform values
When computing a transform value, there is nothing
to do, but we still need to copy the matrix from
src to dest, since it depends on the other transforms
in the array whether we are using the src or the
dest in the end.

This fixes cases like
-gtk-icon-transform: perspective(100px) matrix(1,2,...);
which would otherwise end up with a zero matrix.
2022-07-18 07:08:01 -05:00
Matthias Clasen
eb1a2268bb gtk: Improve test coverage 2022-07-18 07:08:01 -05:00
Matthias Clasen
64193ae706 sortlistmodel: Add more tests 2022-07-18 07:08:01 -05:00
Matthias Clasen
4682eb214a filterlistmodel: Add more tests 2022-07-18 07:08:01 -05:00
Carlos Garnacho
5a34b7ecc6 gdk/wayland: Use last press serial for clipboard/primary selections
This serial observes key and button presses, we can use that instead
of relying on the last serial which might come from other
events/devices.
2022-07-18 13:01:27 +02:00
Carlos Garnacho
eb0b98d5f2 gdk/wayland: Use last implicit grab serial for DnD start requests
This serial should be that from a button press/touch down/etc, use
the last implicit grab here, which will presumably be from the same
device that triggered the event.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5048
2022-07-18 13:00:32 +02:00
Mat
89db59a40d treepopover: Add support for scrolling
Add support for scrolling large tree popovers in a similar fashion to GtkPopoverMenu.

Fixes #3674
Fixes #4877
2022-07-18 00:44:28 +03:00
Mat
9209fd65a5 droptarget: Provide a unique action for gdk_drop_finish
gdk_drop_finish() requires a unique drop action. Reuse the existing
make_action_unique() function to get one.

Fixes #5051
2022-07-17 22:59:59 +03:00
Quentin PAGÈS
7dd874cec8 Update Occitan translation 2022-07-17 15:38:50 +00:00
Emmanuele Bassi
4a5d15535e Merge branch 'picture-suggest-content-fit' into 'main'
picture: Remove keep-aspect-ratio mention in the doc

See merge request GNOME/gtk!4886
2022-07-17 15:00:19 +00:00
Mat
c9a48736d6 treeview: Check for column header area in row click/drag gestures
Bail out if a row click/drag gesture is performed in the column header area,
since separate gestures handle column headers.

Fixes #4453
2022-07-17 17:36:38 +03:00
Marco Melorio
8376f5c9fa picture: Remove keep-aspect-ratio mention in the doc
We were still suggesting to use it in the main doc page. Suggest using
content-fit instead.
2022-07-17 16:21:53 +02:00
Matthias Clasen
1d94c75a78 Merge branch 'matthiasc/for-main' into 'main'
filterlistmodel: Add a test

See merge request GNOME/gtk!4884
2022-07-17 10:50:22 +00:00
Matthias Clasen
d840e082e6 slicelistmodel: Improve a test
Make sure that replacements in the underlying model
don't affect the slice list model if they are outside
the slice window.
2022-07-17 06:32:15 -04:00
Matthias Clasen
2ed954d307 sortlistmodel: Add a test
Add  a test to prove that additions and removals
in the underlying model show up as expected.
2022-07-17 06:22:55 -04:00
Matthias Clasen
7b815768e0 filterlistmodel: Add a test
Test that items added in the underlying model show
up in the filter model (if they pass the filter).

Test removals as well.

See #5050
2022-07-17 06:22:31 -04:00
Mat
d89297b152 tree/iconview: Use a unique drag action in drag_enter/motion callbacks
Functions already exist for providing a unique drag action for gdk_drop_finish().
Reuse these functions in the drag_enter/motion callbacks, since they require
a unique action as the return value.

Fixes #3187
2022-07-17 06:09:53 +03:00
Matthias Clasen
ff038428d8 Merge branch 'matthiasc/for-main' into 'main'
widget-factory: Make the icon work uninstalled

See merge request GNOME/gtk!4881
2022-07-17 01:33:09 +00:00
Matthias Clasen
7321eb881a widget-factory: Make the icon work uninstalled
Include the app logo as a resource, so we can show
it even when uninstalled.
2022-07-16 21:16:40 -04:00
Matthias Clasen
648e423cc5 Merge branch 'fix-wrong-label-wrap-in-popover' into 'main'
popover: Correctly substract arrow height when measuring popover widget

See merge request GNOME/gtk!4880
2022-07-16 23:19:10 +00:00
Benjamin Otte
09da4db81f Merge branch 'dnd' into 'main'
DnD Fix Preferred Action for X11

Closes #4259

See merge request GNOME/gtk!4785
2022-07-16 21:37:15 +00:00
Corey Berla
16fd2608fd gdkdrop-x11: Use the preferred action if possible
The XDND suggested action is a relic from when the source would control
the action for a drop.  With the new GtkDropTarget the target decides
the action (not the source).  That means the all of the returned
results from the ::enter and ::motion handlers will be unexpectely
ignored. Prefer to use the preferred action over the x11 suggested action.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4259
2022-07-16 14:02:47 -07:00
Corey Berla
c9c48d78bf gdkdrop-x11: Fix preferred action
gdk_x11_drop_update_actions() sets actions to
drop_x11->suggested_action when !drop_x11->xdnd_have_actions
and then sets it again to drop_x11->suggested_action if it is.
If xdnd_have_actions is true use xdnd_actions.
2022-07-16 13:42:58 -07:00
Yubao Liu
50a8cbc0da popover: Correctly substract arrow height when measuring popover widget
For default popover arrow position and default height-for-width layout mode,
natural_width is calculated first with for_size=-1 and orientation=HORIZONTAL,
at the end of gtk_popover_measure() natural_width  won't be added with tail_height.

Then to measure with for_size=natural_width and orientation=VERTICAL, obviously
for_size shouldn't be substract with tail_height.

The wrong logic will force content in popover gets less width and then text labels
in popover may get wrapped unnecessarily.
2022-07-17 00:29:42 +08:00
Benjamin Otte
188cb49b44 Merge branch 'content-fit-reftests' into 'main'
reftests: Add content-fit picture tests

See merge request GNOME/gtk!4879
2022-07-16 16:06:57 +00:00
Marco Melorio
6da65b25b6 reftests: Add content-fit picture tests 2022-07-16 17:53:13 +02:00
Matthias Clasen
405cfc8f1f Merge branch 'test-coverage' into 'main'
gtk-demo: Fix icon theme breakage

See merge request GNOME/gtk!4878
2022-07-16 14:08:37 +00:00
Matthias Clasen
9daf83a1da gtk-demo: Make the icon work uninstalled
Include the app logo as a resource, so we can show
it even when uninstalled.
2022-07-16 09:43:46 -04:00
Matthias Clasen
f7811f5dc3 gtk-demo: Add a winning sound to the puzzle
We should celebrate every win.
2022-07-16 09:43:46 -04:00
Matthias Clasen
25ec58be3c gtk-demo: Fix icon theme breakage
The starred emblem silently went away :(
2022-07-16 09:43:46 -04:00
Matthias Clasen
61a843e824 gdk: Improve test coverage 2022-07-16 09:43:46 -04:00
Matthias Clasen
14cb208ec2 png loader: gray can have alpha 2022-07-16 09:43:46 -04:00
Matthias Clasen
c642649311 gdk: Drop an unused function 2022-07-16 09:43:46 -04:00
Matthias Clasen
882c805b53 gdk: Improve test coverage 2022-07-16 09:43:46 -04:00
Benjamin Otte
9cc7dbe9c9 Merge branch 'content-fit-followup' into 'main'
GtkContentFit followups

See merge request GNOME/gtk!4877
2022-07-16 00:24:31 +00:00
Marco Melorio
3eac4ef5c9 picture: Move variable definition at the top 2022-07-16 01:40:08 +02:00
Marco Melorio
f1faa71d6d picture: Set overflow to be hidden
The new content-fit property was wrongly suggesting to manually set
widgets' overflow property, but that property is not really intended to
be set by external code. This commit removes those suggestions and
directly set picture's overflow to be hidden.
2022-07-16 01:40:01 +02:00
Marco Melorio
a08bc46936 picture: Fix replacement for deprecated methods 2022-07-16 01:18:07 +02:00
Matthias Clasen
c6a56b52dc Merge branch 'text-placeholder-visibility' into 'main'
text: Update placeholder visibility more

See merge request GNOME/gtk!4875
2022-07-15 23:00:16 +00:00
Matthias Clasen
63c61340ac Merge branch 'test-coverage' into 'main'
node-editor: Make the help more helpful

See merge request GNOME/gtk!4874
2022-07-15 22:34:02 +00:00
Matthias Clasen
09f99ffb27 Merge branch 'gtk-content-fit' into 'main'
picture: Add content-fit property

Closes #5027

See merge request GNOME/gtk!4873
2022-07-15 22:28:42 +00:00
Matthias Clasen
3cc3a73d97 Merge branch 'nick.richards-main-patch-67353' into 'main'
Improve style in GtkInscription documentation

See merge request GNOME/gtk!4876
2022-07-15 22:21:23 +00:00
Marco Melorio
d8a73cbd03 picture: Add content-fit property
It allows to specify the resize mode of the paintable inside the
GtkPicture allocation. This also deprecates the keep-aspect-ratio
property.

Fixes #5027.
2022-07-15 23:01:23 +02:00
nick richards
624f5ba0ec Improve style in GtkInscription documentation 2022-07-15 20:55:37 +00:00
Matthias Clasen
ac81ed3adb text: Update placeholder visibility more
When the text in the buffer changes, we should
update the placeholder visibility, since we might
have gone from empty to non-empty.
2022-07-15 16:47:02 -04:00
Matthias Clasen
5064a8eac0 gsk: Improve test coverage 2022-07-15 16:41:05 -04:00
Matthias Clasen
a4c6517d06 glshader: Add preconditions
Add preconditions to many of the glshader
uniform apis.
2022-07-15 15:47:11 -04:00
Matthias Clasen
7ebc5454f4 Drop an unused function 2022-07-15 15:47:11 -04:00
Matthias Clasen
35e6a2fdb8 node-editor: Sort help better
Move the gshader section where it belongs.
2022-07-15 15:46:06 -04:00
Matthias Clasen
69336fa5f1 node-editor: Make the help more helpful
I struggled to remember how newlines vs strings work in
this format, so put it in the docs.
2022-07-15 15:46:06 -04:00
Matthias Clasen
2cbb955e49 rendernodeparser: Cosmetics 2022-07-15 15:46:06 -04:00
Matthias Clasen
42042e6811 Add some tests for GtkNoSelection 2022-07-15 15:46:06 -04:00
Matthias Clasen
f8f669b895 Add some tests for the listlistmodel 2022-07-15 15:46:06 -04:00
Matthias Clasen
7743f35972 maplistmodel: Fix an oversight
This was meant to go into 678eb8ab76.
2022-07-14 19:52:54 -04:00
Matthias Clasen
db01233520 Merge branch 'fix-maplistmodel' into 'main'
maplistmodel: Fix items-changed emission

See merge request GNOME/gtk!4872
2022-07-14 23:48:27 +00:00
Matthias Clasen
fa1daf50a7 Add more maplistmodel tests
Add some tests for adding and removing items.
2022-07-14 17:04:02 -04:00
Matthias Clasen
678eb8ab76 maplistmodel: Fix items-changed emission
We were modifying the removed value before passing
it to the items-changed signal, so we always ended
up with removed == 0 in our signal emission, instead
of passing the original value on, as we should.

Pointed out in !4870
2022-07-14 16:53:09 -04:00
Matthias Clasen
c46b5ed646 Merge branch 'matthiasc/for-main' into 'main'
pango_font_description_to_css: Handle numeric weight

See merge request GNOME/gtk!4871
2022-07-14 20:46:37 +00:00
Matthias Clasen
f8945b6325 pango_font_description_to_css: Handle numeric weight
The PangoWeight enum agrees with the numeric values
we use here, so we can do this without a switch and
support numeric weight values at the same time.
2022-07-14 15:50:06 -04:00
Matthias Clasen
3c67f6a457 Merge branch 'add-back-pango-css' into 'main'
pango_font_description_to_css: Add extra-expanded

See merge request GNOME/gtk!4869
2022-07-14 11:43:04 +00:00
Maximiliano Sandoval R
9868143696 pango_font_description_to_css: Add extra-expanded 2022-07-14 12:55:55 +02:00
Matthias Clasen
b51eb4bd72 Merge branch 'coreyberla-main-patch-84997' into 'main'
ci: Remove print-backends build option

See merge request GNOME/gtk!4866
2022-07-13 23:44:53 +00:00
Matthias Clasen
62619a9777 Merge branch 'ebassi/childless-stack-page' into 'main'
stack: Assert that StackPage:child is set

See merge request GNOME/gtk!4201
2022-07-13 21:11:58 +00:00
Corey Berla
d37ccbffa3 ci: Remove print-backends build option
Flatpak CI is failing because of unknown option "print-backends".
print-backends was renamed to print in c4d350c260
and subsequently was removed in a4aa6d79ad
(replaced by print-cups and print-cloudprint as auto options)
2022-07-13 14:21:12 +00:00
Matthias Clasen
b3ecc40cf1 testsuite: Fix up a few test for GtkStackPage changes
GtkStackPage objects can no longer be freely created.
Update our generic object tests to take that into
account.
2022-07-13 15:03:05 +01:00
Matthias Clasen
5b76d0c226 GtkStack: Create stack pages with child
We're requiring stack pages to have a child
at construction time now. Make it so!
2022-07-13 15:03:05 +01:00
Emmanuele Bassi
9eb6de403f stack: Assert that StackPage:child is set
Childless GtkStackPage instances are not allowed, otherwise everything
falls apart in random places.
2022-07-13 15:03:05 +01:00
Kukuh Syafaat
d104357d40 Update Indonesian translation 2022-07-13 12:58:18 +00:00
Matthias Clasen
775435c025 Merge branch 'check-button-s-ancestry' into 'main'
print: Check button is not descendant of toggle button

See merge request GNOME/gtk!4864
2022-07-13 11:20:57 +00:00
Matthias Clasen
24f31b6797 Merge branch 'empty_list_adjustment' into 'main'
listviews: Reset scrollbar adjustment when list is empty

Closes #4370

See merge request GNOME/gtk!4865
2022-07-13 11:17:07 +00:00
Matthias Clasen
45f69d2fbe Merge branch 'main' into 'main'
textview: Include gutter while computing child allocations

Closes #5016

See merge request GNOME/gtk!4849
2022-07-13 11:02:02 +00:00
JCWasmx86
af5f75aa77 textview: Include gutter while computing child allocations
The width of the left gutter and the height of the top gutter
are now used while computing the child allocations for e.g.
anchors, otherwise - if such a gutter is present - the
widget would be at the wrong position.

Closes #5016
2022-07-13 07:02:55 +02:00
Matthias Clasen
74494b0b3a 4.7.1 2022-07-12 22:55:33 -04:00
Corey Berla
94673707e6 listviews: Reset scrollbar adjustment when list is empty
In a list with a visible scrollbar, the scrollbar usually becomes
invisible when the numbers of items is less than the required amount
to scroll.  If, however, the list is emptied all at once,
the scrollbar remains.  This happens because when there's an empty
list gtk_list_view_size_allocate() returns early before the scrollbar
adjustment is updated.

Given that the list is empty, simply reset the adjustment values
to zero.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4370
2022-07-12 12:54:35 -07:00
Marek Kasik
e204910730 print: Check button is not descendant of toggle button
GtkCheckButton is not derived from GtkToggleButton anymore.
This caused some issues in GtkPrinterOptionWidget which
did not port handling of the button.
2022-07-12 16:22:59 +02:00
Matthias Clasen
afe476c2e3 Merge branch 'matthiasc/for-main' into 'main'
search-entry: Add getter/setter annotation

See merge request GNOME/gtk!4862
2022-07-11 19:32:55 +00:00
Matthias Clasen
dfe8eb37ce search-entry: Add getter/setter annotation
This was suggested in !4823.
2022-07-11 15:08:39 -04:00
Matthias Clasen
88e8837587 Merge branch 'wip/otte/for-main' into 'main'
frameclock: Run paint idle from flush idle

Closes #4941

See merge request GNOME/gtk!4858
2022-07-11 18:44:01 +00:00
Matthias Clasen
f218a4e2d2 Merge branch 'free-print-backends' into 'main'
print: Free print backends after use

Closes #5019

See merge request GNOME/gtk!4860
2022-07-11 18:04:46 +00:00
Matthias Clasen
685961a8c6 Merge branch 'ebassi/finish-template' into 'main'
Add gtk_widget_clear_template()

See merge request GNOME/gtk!4735
2022-07-11 18:02:28 +00:00
Matthias Clasen
dced70a8d0 Merge branch 'fix_flatpak' into 'main'
Fix flatpak

See merge request GNOME/gtk!4861
2022-07-11 17:35:45 +00:00
Emmanuele Bassi
f4f683a469 Rename clear_template to dispose_template
Make it more clear that the function is supposed to be called during the
dispose sequence of a widget.
2022-07-11 18:24:37 +01:00
Emmanuele Bassi
63fe3345a7 fontchooserdialog: Use gtk_widget_clear_template() 2022-07-11 18:24:37 +01:00
Emmanuele Bassi
01e99fad1e statusbar: Use gtk_widget_clear_template() 2022-07-11 18:24:37 +01:00
Emmanuele Bassi
0074ee3149 filechooserwidget: Use gtk_widget_clear_template() 2022-07-11 18:24:37 +01:00
Emmanuele Bassi
ad361abc4c filechooserdialog: Use gtk_widget_clear_template() 2022-07-11 18:24:37 +01:00
Emmanuele Bassi
103f52bb8a Port the inspector to gtk_widget_clear_template()
Use clear_template() instead of unparenting widgets manually.
2022-07-11 18:24:37 +01:00
Emmanuele Bassi
c2ec244b84 docs: Include clear_template() in the templates overview
Make sure that it's clear how to use it in idiomatic code, by tying it
to gtk_widget_init_template().
2022-07-11 18:24:37 +01:00
Emmanuele Bassi
e71f9bb79f Port gtk-demo widgets to gtk_widget_clear_template() 2022-07-11 18:24:37 +01:00
Emmanuele Bassi
bf75a21deb Port node editor to gtk_widget_clear_template() 2022-07-11 18:24:37 +01:00
Emmanuele Bassi
1bba874895 Port icon browser to gtk_widget_clear_template() 2022-07-11 18:24:37 +01:00
Emmanuele Bassi
01f5142b00 Port constraint editor to gtk_widget_clear_template() 2022-07-11 18:24:37 +01:00
Emmanuele Bassi
620d48ca0c docs: Clarify scope of gtk_widget_clear_template()
The clear_template() method only clears the template children.
2022-07-11 18:24:37 +01:00
Emmanuele Bassi
e8c5c2f648 emojichooser: Use gtk_widget_clear_template() 2022-07-11 18:24:37 +01:00
Emmanuele Bassi
71eb19bf51 mediacontrols: Use gtk_widget_clear_template() 2022-07-11 18:24:37 +01:00
Emmanuele Bassi
7857c1a66b Add gtk_widget_clear_template()
The dual of gtk_widget_init_template(), which should be used to clear
the template data associated with a specific GtkWidget type.
2022-07-11 18:24:37 +01:00
Corey Berla
1e3ae95b7e flatpak: Bump boost to 1.79 2022-07-11 09:11:59 -07:00
Corey Berla
1ff38cdf6a flatpak: Remove benchmarks build option for graphene
benchmarks was removed in
419edb99f0
2022-07-11 09:11:24 -07:00
Corey Berla
4147dd218d flatpak: Change option enable_vulkan=no to vulkan=disabled
Syntax was modified in c4d350c260
2022-07-11 09:08:47 -07:00
Marek Kasik
e68a3a6123 print: Free print backends after use
Print backends loaded in GtkPrintUnixDialog's load_print_backends()
are not freed later as done in e.g. GtkPageSetupUnixDialog.
This commit destroys and unref those print backends.

Closes #5019
2022-07-11 16:54:36 +02:00
Matthias Clasen
6368278005 NEWS: Updates 2022-07-10 18:52:01 -04:00
Matthias Clasen
edb61cc434 Merge branch 'matthiasc/for-main' into 'main'
inspector: Hide measure graphs by default

See merge request GNOME/gtk!4859
2022-07-10 20:38:29 +00:00
Matthias Clasen
743406998c inspector: Hide measure graphs by default
It is much more valuable to have a responsive inspector,
than to have these graphs.
2022-07-10 16:25:55 -04:00
Matthias Clasen
f56c0bc034 Merge branch 'fix-fractional-letterspacing' into 'main'
css: Allow fractional letterspacing

Closes #5034

See merge request GNOME/gtk!4857
2022-07-10 19:42:25 +00:00
Benjamin Otte
988e20cd53 frameclock: Run paint idle from flush idle
Don't return to the main loop, instead force a run of the paint idle.
The paint idle will know to skip all the phases that aren't requested.

This is critically important becuase gdksurface.c assumes the
FLUSH_EVENTS and RESUME_EVENTS phases are matched, and we cannot
guarantee that if we return to the main loop and let various reentrant
code change the frame clock state.

This would lead to bugs with events being paused and never unpaused
again or even crashes.

Fixes #4941
2022-07-10 21:33:32 +02:00
Matthias Clasen
726c9e83d2 css: Allow fractional letterspacing
Something like letter-spacing: -0.5px make a lot of
sense. But we were handling the number as integer
somewhere, loosing the fractional part.

Fixes: #5034
2022-07-10 15:22:18 -04:00
Matthias Clasen
e7af42c758 Merge branch 'matthiasc/for-main' into 'main'
widget-factory: Fix a missing export

See merge request GNOME/gtk!4855
2022-07-08 02:00:11 +00:00
Matthias Clasen
7c5d71ebf6 widget-factory: Fix a missing export
This broke when we started using a scope.
2022-07-07 21:44:57 -04:00
Matthias Clasen
d659bc8762 Merge branch 'wip/cdavis/use-password-input-purpose' into 'main'
passwordentry: Use password input purpose

See merge request GNOME/gtk!4854
2022-07-06 19:48:57 +00:00
Christopher Davis
9f2a621328 passwordentry: Use password input purpose
Per discussion in #gtk on Matrix
2022-07-06 13:48:25 -04:00
Matthias Clasen
fae2dd9885 Merge branch 'matthiasc/for-main' into 'main'
fontchooser work

See merge request GNOME/gtk!4850
2022-07-05 15:13:20 +00:00
Benjamin Otte
c673d7cd9b Merge branch 'fix-ffmpeg-decoding' into 'main'
ffmpeg: Fix crash on some media files

See merge request GNOME/gtk!4851
2022-07-04 21:27:11 +00:00
Stephan Vedder
1c8bddf3ca ffmpeg: Fix crash on some media files
Return code EAGAIN expects the user to feed more packets into the decoder
2022-07-04 13:29:09 +02:00
Matthias Clasen
ab1cf67432 fontchooser: Make size level effective
We were not hiding the size controls on the tweaks
page, which is arguably what should happen when
the size level is disabled.
2022-07-03 12:50:40 -04:00
Matthias Clasen
1097003f6f Beef up testfontchooserdialog
Allow testing levels.
2022-07-03 12:50:30 -04:00
Nate Eldredge
5faa300c5e Recognize "stylus" devices as GDK_SOURCE_PEN
Add "stylus" to the list of substrings in a device name that cause it to be recognized
as a GDK_SOURCE_PEN device (previously "wacom", "pen" and "eraser").  Some devices
just use "stylus" in their name, and are otherwise recognized as
GDK_SOURCE_TOUCHSCREEN instead.

Fixes #4394.
2022-05-29 15:30:19 -06:00
Corey Berla
7df347d9a5 places: Align popover menu with mouse position
The popover menu previously always pops up in the center of each
row regardless of where the mouse cursor is currently positioned.

Make the popover popup at the current mouse position. If the popover
is triggered by the keyboard (i.e. SHIFT+F10), then align it with the
start of the row.
2022-05-07 18:50:59 +01:00
Corey Berla
7ed8a6ae3c places: Fix crash when right clicking row
After right clicking multiple rows, or after adding / removing rows
(i.e. new network locations), right clicking the row will crash
nautilus.

This happens because the popover may become orphan but still expect
a parent.

Reposition the popover menu instead of reparenting it.
2022-05-07 18:45:17 +01:00
Corey Berla
ff84b96480 places: Fix crash when disconnecting
After disconnecting a network mount in places (when there's 2 or more
mounts), right clicking another mount crashes the application.
Set row_for_action to NULL when successfully unmounted.
2022-05-07 18:22:15 +01:00
António Fernandes
64347f2c79 placessidebar: Point to row instead or reparenting popovers
In GTK 3 we used to move the popovers around using set_relative_to();
this is gone in GTK 4 and the apparent direct replacement is setting
the target widget as the new parent.

But this requires a lot of careful handling least the popover become
orphan, which gets us ready to crash at any moment.

Since we only care about positioning the popovers relative to a row,
let's use the set_pointing_to() instead of reparenting. Now, the
sidebar is always the parent.
2022-05-07 18:10:44 +01:00
Luca Bacci
1af7cde1a8 Propagate key events when the location entry is focused
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/4880
2022-04-29 16:53:02 +02:00
Lukáš Tyrychtr
4ab9592924 Use the correct macro 2022-04-25 14:21:40 +02:00
Lukáš Tyrychtr
6f01d458d5 Localize the a11y label 2022-04-22 11:42:32 +02:00
Lukáš Tyrychtr
6f9013297a Make the presentation of the stack sidebar listbox nicer for A11Y
This fixes #4577.
2022-04-21 17:55:39 +02:00
1187 changed files with 80779 additions and 68572 deletions

View File

@@ -4,6 +4,7 @@ AlwaysBreakAfterDefinitionReturnType: All
BreakBeforeBinaryOperators: None
BinPackParameters: false
SpaceAfterCStyleCast: true
PointerAlignment: Right
# 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

View File

@@ -3,6 +3,7 @@ include:
file: 'flatpak/flatpak_ci_initiative.yml'
stages:
- check
- build
- analysis
- docs
@@ -21,12 +22,12 @@ stages:
# Common variables
variables:
COMMON_MESON_FLAGS: "-Dwerror=true -Dglib:werror=false -Dpango:werror=false -Dgtk-doc:werror=false -Dwayland-protocols:werror=false -Dsysprof:werror=false"
COMMON_MESON_FLAGS: "-Dwerror=true -Dglib:werror=false -Dpango:werror=false -Dgtk-doc:werror=false -Dwayland-protocols:werror=false -Dsysprof:werror=false -Dwayland:werror=false"
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true"
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled"
MESON_TEST_TIMEOUT_MULTIPLIER: 3
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v38"
FLATPAK_IMAGE: "registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master"
FLATPAK_IMAGE: "quay.io/gnome_infrastructure/gnome-runtime-images:gnome-master"
.only-default:
only:
@@ -37,7 +38,7 @@ variables:
style-check-diff:
extends: .only-default
image: $FEDORA_IMAGE
stage: .pre
stage: check
allow_failure: true
script:
- .gitlab-ci/run-style-check-diff.sh
@@ -109,6 +110,29 @@ release-build:
- ninja -C _build
- .gitlab-ci/run-tests.sh _build x11
fedora-mingw64:
extends: .build-fedora-default
stage: build
needs: []
before_script:
- sudo dnf install -y
mingw64-filesystem
mingw64-gcc
mingw64-binutils
mingw64-cairo
mingw64-gdk-pixbuf
mingw64-gstreamer1-plugins-bad-free
mingw64-glib2
mingw64-libepoxy
mingw64-pango
# mingw64-graphene (rawhide)
script:
- .gitlab-ci/show-info-linux.sh
- meson subprojects update
- mkdir _build && cd _build
- mingw64-meson -Dintrospection=disabled -Dgraphene:introspection=disabled
- ninja
installed-tests:
extends: .build-fedora-default
stage: build
@@ -168,6 +192,7 @@ macos:
only:
- branches@GNOME/gtk
stage: build
allow_failure: true
tags:
- macos
needs: []
@@ -269,6 +294,18 @@ flatpak-main:icon-browser:
variables:
APPID: org.gtk.IconBrowser4
flatpak-manual:node-editor:
extends: .flatpak-manual
needs: []
variables:
APPID: org.gtk.gtk4.NodeEditor
flatpak-main:node-editor:
extends: .flatpak-main
needs: []
variables:
APPID: org.gtk.gtk4.NodeEditor
# Publish the demo apps to the GNOME Nightly repo
# https://wiki.gnome.org/Apps/Nightly
# https://gitlab.gnome.org/GNOME/Initiatives/-/wikis/DevOps-with-Flatpak
@@ -287,6 +324,11 @@ nightly icon-browser:
dependencies: ['flatpak-main:icon-browser']
needs: ['flatpak-main:icon-browser']
nightly node-editor:
extends: '.publish_nightly'
dependencies: ['flatpak-main:node-editor']
needs: ['flatpak-main:node-editor']
static-scan:
image: $FEDORA_IMAGE
stage: analysis

View File

@@ -16,10 +16,9 @@ flatpak-builder \
flatpak build ${builddir} meson \
--prefix=/app \
--libdir=/app/lib \
--buildtype=release \
--buildtype=debugoptimized \
-Dx11-backend=true \
-Dwayland-backend=true \
-Dprint-backends=file \
-Dbuild-tests=false \
-Dbuild-examples=false \
-Dintrospection=disabled \

View File

@@ -2,25 +2,43 @@
set -e
# We need to add a new remote for the upstream main, since this script could
# be running in a personal fork of the repository which has out of date branches.
if [ "${CI_PROJECT_NAMESPACE}" != "GNOME" ]; then
echo "Retrieving the current upstream repository from ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}..."
ancestor_horizon=31 # days (one month)
# Recently, git is picky about directory ownership. Tell it not to worry.
git config --global --add safe.directory "$PWD"
# We need to add a new remote for the upstream target branch, since this script
# could be running in a personal fork of the repository which has out of date
# branches.
#
# Limit the fetch to a certain date horizon to limit the amount of data we get.
# If the branch was forked from origin/main before this horizon, it should
# probably be rebased.
if ! git ls-remote --exit-code upstream >/dev/null 2>&1 ; then
git remote add upstream https://gitlab.gnome.org/GNOME/gtk.git
git fetch upstream
ORIGIN="upstream"
else
echo "Reusing the existing repository on ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}"
ORIGIN="origin"
fi
# 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/main` 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 "${ORIGIN}/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-${CI_DEFAULT_BRANCH}}") <(git rev-list --first-parent HEAD) | head -1)
# `upstream/main` or `upstream/glib-2-62`).
# `${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}` or `${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}`
# are only defined if were running in a merge request pipeline,
# fall back to `${CI_DEFAULT_BRANCH}` or `${CI_COMMIT_BRANCH}` respectively
# otherwise.
source_branch="${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:-${CI_COMMIT_BRANCH}}"
target_branch="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-${CI_DEFAULT_BRANCH}}"
git fetch --shallow-since="$(date --date="${ancestor_horizon} days ago" +%Y-%m-%d)" origin "${source_branch}"
git fetch --shallow-since="$(date --date="${ancestor_horizon} days ago" +%Y-%m-%d)" upstream "${target_branch}"
newest_common_ancestor_sha=$(git merge-base upstream/${target_branch} origin/${source_branch})
if [ -z "${newest_common_ancestor_sha}" ]; then
echo "Couldnt find common ancestor with upstream main branch. This typically"
echo "happens if you branched from main a long time ago. Please update"
echo "your clone, rebase, and re-push your branch."
exit 1
fi
git diff -U0 --no-color "${newest_common_ancestor_sha}" | .gitlab-ci/clang-format-diff.py -binary "clang-format" -p1
exit_status=$?
@@ -36,7 +54,7 @@ exit_status=$?
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/main/docs/CODING-STYLE"
echo " https://gitlab.gnome.org/GNOME/gtk/blob/main/docs/CODING-STYLE.md"
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."

View File

@@ -28,7 +28,7 @@ pacman --noconfirm -S --needed \
mingw-w64-$MSYS2_ARCH-graphene \
mingw-w64-$MSYS2_ARCH-json-glib \
mingw-w64-$MSYS2_ARCH-libepoxy \
mingw-w64-$MSYS2_ARCH-pango2 \
mingw-w64-$MSYS2_ARCH-pango \
mingw-w64-$MSYS2_ARCH-fribidi \
mingw-w64-$MSYS2_ARCH-gst-plugins-bad-libs \
mingw-w64-$MSYS2_ARCH-shared-mime-info \
@@ -38,25 +38,6 @@ mkdir -p _ccache
export CCACHE_BASEDIR="$(pwd)"
export CCACHE_DIR="${CCACHE_BASEDIR}/_ccache"
# https://gitlab.gnome.org/GNOME/gtk/-/issues/2243
# https://gitlab.gnome.org/GNOME/gtk/-/issues/3002
if ! pkg-config --atleast-version=2.66.0 glib-2.0; then
git clone https://gitlab.gnome.org/GNOME/glib.git _glib
meson setup _glib_build _glib
meson compile -C _glib_build
meson install -C _glib_build
fi
pkg-config --modversion glib-2.0
if ! pkg-config --atleast-version=1.50.0 pango; then
git clone https://gitlab.gnome.org/GNOME/pango.git _pango
meson setup _pango_build _pango
meson compile -C _pango_build
meson install -C _pango_build
fi
pkg-config --modversion pango
# Build
ccache --zero-stats
ccache --show-stats

308
NEWS
View File

@@ -1,3 +1,311 @@
Overview of Changes in 4.9.1, dd-mm-yyyy
========================================
Note that deprecations are an early outlook
at changes that will appear in an eventual
GTK 5 release, which is still far away.
* GtkTreeView, GtkIconView, GtkComboBox and
auxiliary classes have been deprecated
* GtkEntryCompletion has been deprecated
* GtkStyleContext has been deprecated
* gtk_render_ and gtk_snapshot_render_ APIs
have been deprecated
* GtkAppChooser widgets hae been deprecated
* GtkMountOperation:
- Fix the dialog to look reasonable
- Make it work under non-X11
* GtkStringSorter:
- Support different collation methods
* Accessibility:
- Introduce GtkAccessibleRange and implement it
* Debugging:
- Unify formatting for debug output
- Make make debug options available in
non-debug builds
* Translation updates:
Abkhazian
Basque
Bulgarian
Croatian
Friulian
Georgian
German
Hungarian
Russian
Turkish
Overview of Changes in 4.8.1, 16-09-2022
========================================
* Input:
- Fix problems with input method interactions that caused
dead keys not to work
- Accept single-key compose sequences (these are used with
some keyboard layouts)
* GtkColumnView:
- Flip column order in right-to-left context
* GtkGridView:
- Fix problems with rubberbanding
* GtkFileChooser:
- Fix positioning of popovers in the places view
- Make ~ and . keyboard shortcuts work again
* gsk:
- Make glyph upload more similar to icons
* Make file transfer via portals work, this fixes file
copy/paste and dnd in flatpaks
* Translation updates:
Catalan
Chinese (China)
Chinese (Taiwan)
Latvian
Overview of Changes in 4.8.0, 06-09-2022
========================================
* GtkTreeView:
- Fix a problem with scrolling animations
- Fix some event handling problems
- Drop unreachable code
* GtkText:
- Respect the no-emoji input hint fully
* GtkEmojiChooser:
- Fix arrow key navigation
* GtkFontChooser:
- Improve the handling of OpenType font features
* GtkTreeListModel:
- Fix handling of collapsed child nodes
* GtkInscription:
- Fix accessible name
* Theme:
- Fix placeholder text in HighContrast
* Increase the memory limit for the jpeg loader to 300M
* Miscellaneous memory leak fixes
* Wayland:
- Refator handling of text protocol client updates
* Windows:
- Support high-resolution scroll wheel events
- Generate GdkWin32.gir
- Implement color picking
* Translation updates
Abkhazian
Basque
Brazilian Portuguese
Bulgarian
Catalan
Chinese (China)
Croatian
Czech
Danish
Dutch
Galician
Georgian
German
Hungarian
Icelandic
Indonesian
Korean
Latvian
Lithuanian
Persian
Polish
Portuguese
Russian
Serbian
Spanish
Swedish
Turkish
Ukrainian
Overview of Changes in 4.7.2, 10-08-2022
========================================
* GtkTextView:
- Fix child positioning with gutters
* GtkText:
- Update placeholder visibility when necessary
* GtkPicture:
- Add a content-fit property
* GtkPopover:
- Fix a size allocation problem with the arrow
* GtkTreeView:
- Fix a problem with DND
* GtkTreePopover:
- Support scrolling
* GtkGridView:
- Fix issues with rubberband selection
* GtkLabel:
- Add a tabs property
* GtkSnapshot:
- Make GtkSnapshot work from bindings
* GtkScrolledWindow:
- Scroll at a reasonable speed
* GtkPaned:
- Avoid an infinite loop
* GtkWindow:
- Improve generation and handling of crossing events
* CSS:
- Fix handling of certain transform values
* Media support:
- Add audio support to the ffmpeg backend
- Avoid oom with pathological jpeg images
* GDK:
- Fix handling of touchpad hold events
- Add support for hi-resolution scroll events
* X11:
- Fix preferred action for DND
* Windows:
- Fix DND
* List models:
- Fix items-changed emission
- Add more list model tests
* Demos:
- Add a winning sound to game demos
- Make app icons work uninstalled
* Translation updates:
Abkhazian
Basque
Catalan
Georgian
German
Indonesian
Occitan
Persian
Portuguese
Russian
Spanish
Ukrainian
Overview of Changes in 4.7.1, 12-07-2022
========================================
* GtkInscription:
- A new label-like widget for use in list views
* GtkColorChooser:
- Style improvements
* GtkFontChooser:
- Improve support for OpenType features a bit
* GtkLabel:
- Allow selectable labels to be activated via mnemonic
* GtkTextView:
- Implement GetCharacterExtents for accessibility
* GtkStack:
- Fix a poblem with stack page accessibility
* GtkListView:
- Cull listitems that are out of view
- Make all our list models implement ::n-items and
::item-type properties
* Translations:
- Stop translating property nicks and blurbs
- Fix extracting translations from ui files
* Debugging:
- Support GTK_DEBUG=invert-text-dir
- Allow inspecting inspectors
- Replace GTK_USE_PORTAL with GDK_DEBUG=portals
- Improve responsiveness of the inspector
* CSS:
- Allow fractional letterspacing
* Theme:
- Improve legibility of selectable labels
* Demos:
- Improve the font features demo
- Add demos for GtkInscription
* Wayland:
- Freeze popups when hidden
- Only send smooth scroll events for tablet tools
- Make scaled cursor image have the right size
- Fix problems with the activation protocol
- Don't force the HighContrast icon theme
- Support xdg_toplevel.bounds
* X11:
- Always update the shadoe size
* Windows:
- Improve touchpad support by using DirectManipulation
- Add more directories to the builtin hicolor icon theme
* Translation updates:
Basque
Catalan
Chinese (China)
Galician
German
Lithuanian
Nepali
Occitan
Persian
Polish
Portuguese
Russian
Serbian
Spanish
Swedish
Turkish
Ukrainian
Overview of Changes in 4.7.0, 07-05-2022
========================================

View File

@@ -54,8 +54,7 @@
"builddir" : true,
"config-opts" : [
"--libdir=/app/lib",
"-Dtests=false",
"-Dbenchmarks=false"
"-Dtests=false"
],
"sources" : [
{
@@ -105,8 +104,8 @@
"sources": [
{
"type": "archive",
"url": "https://boostorg.jfrog.io/artifactory/main/release/1.69.0/source/boost_1_69_0.tar.bz2",
"sha256": "8f32d4617390d1c2d16f26a27ab60d97807b35440d45891fa340fc2648b04406"
"url": "https://boostorg.jfrog.io/artifactory/main/release/1.79.0/source/boost_1_79_0.tar.bz2",
"sha256": "475d589d51a7f8b3ba2ba4eda022b170e562ca3b760ee922c146b6c65856ef39"
}
]
},
@@ -186,7 +185,7 @@
"builddir" : true,
"config-opts" : [
"--libdir=/app/lib",
"-Denable_vulkan=no",
"-Dvulkan=disabled",
"-Dbuildtype=debugoptimized",
"-Dprofile=devel"
],

View File

@@ -54,8 +54,7 @@
"builddir" : true,
"config-opts" : [
"--libdir=/app/lib",
"-Dtests=false",
"-Dbenchmarks=false"
"-Dtests=false"
],
"sources" : [
{
@@ -115,7 +114,7 @@
"builddir" : true,
"config-opts" : [
"--libdir=/app/lib",
"-Denable_vulkan=no",
"-Dvulkan=disabled",
"-Dbuildtype=debugoptimized",
"-Dprofile=devel"
],

View File

@@ -54,8 +54,7 @@
"builddir" : true,
"config-opts" : [
"--libdir=/app/lib",
"-Dtests=false",
"-Dbenchmarks=false"
"-Dtests=false"
],
"sources" : [
{
@@ -115,7 +114,7 @@
"builddir" : true,
"config-opts" : [
"--libdir=/app/lib",
"-Denable_vulkan=no",
"-Dvulkan=disabled",
"-Dbuildtype=debugoptimized",
"-Dprofile=devel"
],

View File

@@ -0,0 +1,138 @@
{
"app-id" : "org.gtk.gtk4.NodeEditor",
"runtime" : "org.gnome.Platform",
"runtime-version" : "master",
"sdk" : "org.gnome.Sdk",
"command" : "gtk4-node-editor",
"tags" : [
"devel",
"development",
"nightly"
],
"desktop-file-name-prefix" : "(Development) ",
"finish-args" : [
"--device=dri",
"--share=ipc",
"--socket=fallback-x11",
"--socket=wayland",
"--talk-name=org.gtk.vfs",
"--talk-name=org.gtk.vfs.*"
],
"cleanup" : [
"/include",
"/lib/pkgconfig",
"/share/pkgconfig",
"/share/aclocal",
"/man",
"/share/man",
"/share/gtk-doc",
"*.la",
".a",
"/lib/girepository-1.0",
"/share/gir-1.0",
"/share/doc"
],
"modules" : [
{
"name" : "wayland",
"buildsystem" : "meson",
"builddir" : true,
"config-opts" : [
"-Ddocumentation=false"
],
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.freedesktop.org/wayland/wayland.git",
"branch" : "main"
}
]
},
{
"name" : "graphene",
"buildsystem" : "meson",
"builddir" : true,
"config-opts" : [
"--libdir=/app/lib",
"-Dtests=false"
],
"sources" : [
{
"type" : "git",
"url" : "https://github.com/ebassi/graphene.git"
}
]
},
{
"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" : "pango",
"buildsystem" : "meson",
"builddir" : true,
"config-opts" : [
"--libdir=/app/lib"
],
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.gnome.org/GNOME/pango.git",
"branch" : "main"
}
]
},
{
"name" : "gtk",
"buildsystem" : "meson",
"builddir" : true,
"config-opts" : [
"--libdir=/app/lib",
"-Dvulkan=disabled",
"-Dbuildtype=debugoptimized",
"-Dprofile=devel"
],
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.gnome.org/GNOME/gtk.git",
"branch" : "main"
}
]
}
],
"build-options" : {
"env" : {
"DBUS_SESSION_BUS_ADDRESS" : "''",
"GSK_RENDERER" : "opengl",
"GDK_DEBUG" : "vulkan-disable",
"G_ENABLE_DEBUG" : "true"
}
}
}

View File

@@ -1,45 +0,0 @@
#!/usr/bin/env python3
import os
import sys
import subprocess
if 'DESTDIR' not in os.environ:
gtk_api_version = sys.argv[1]
gtk_abi_version = sys.argv[2]
gtk_libdir = sys.argv[3]
gtk_datadir = sys.argv[4]
gtk_bindir = sys.argv[5]
gtk_moduledir = os.path.join(gtk_libdir, 'gtk-' + gtk_api_version, gtk_abi_version)
gtk_printmodule_dir = os.path.join(gtk_moduledir, 'printbackends')
gtk_mediamodule_dir = os.path.join(gtk_moduledir, 'media')
print('Compiling GSettings schemas...')
glib_compile_schemas = subprocess.check_output(['pkg-config',
'--variable=glib_compile_schemas',
'gio-2.0']).strip()
if not os.path.exists(glib_compile_schemas):
# pkg-config variables only available since GLib 2.62.0.
glib_compile_schemas = 'glib-compile-schemas'
subprocess.call([glib_compile_schemas,
os.path.join(gtk_datadir, 'glib-2.0', 'schemas')])
print('Updating icon cache...')
update_icon_cache = os.path.join(gtk_bindir, 'gtk4-update-icon-cache')
subprocess.call([update_icon_cache, '-q', '-t' ,'-f',
os.path.join(gtk_datadir, 'icons', 'hicolor')])
print('Updating module cache for print backends...')
os.makedirs(gtk_printmodule_dir, exist_ok=True)
gio_querymodules = subprocess.check_output(['pkg-config',
'--variable=gio_querymodules',
'gio-2.0']).strip()
if not os.path.exists(gio_querymodules):
# pkg-config variables only available since GLib 2.62.0.
gio_querymodules = 'gio-querymodules'
subprocess.call([gio_querymodules, gtk_printmodule_dir])
print('Updating module cache for media backends...')
os.makedirs(gtk_mediamodule_dir, exist_ok=True)
subprocess.call([gio_querymodules, gtk_mediamodule_dir])

View File

@@ -361,11 +361,11 @@ save_cb (GtkWidget *button,
}
static void
constraint_editor_window_finalize (GObject *object)
constraint_editor_window_dispose (GObject *object)
{
//ConstraintEditorWindow *self = (ConstraintEditorWindow *)object;
gtk_widget_dispose_template (GTK_WIDGET (object), CONSTRAINT_EDITOR_WINDOW_TYPE);
G_OBJECT_CLASS (constraint_editor_window_parent_class)->finalize (object);
G_OBJECT_CLASS (constraint_editor_window_parent_class)->dispose (object);
}
static int child_counter;
@@ -497,7 +497,7 @@ constraint_editor_window_class_init (ConstraintEditorWindowClass *class)
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
object_class->finalize = constraint_editor_window_finalize;
object_class->dispose = constraint_editor_window_dispose;
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gtk/gtk4/constraint-editor/constraint-editor-window.ui");

View File

@@ -21,6 +21,8 @@
#include "constraint-editor.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
struct _ConstraintEditor
{
GtkWidget parent_instance;
@@ -607,10 +609,11 @@ constraint_editor_dispose (GObject *object)
{
ConstraintEditor *self = (ConstraintEditor *)object;
g_clear_pointer (&self->grid, gtk_widget_unparent);
g_clear_object (&self->model);
g_clear_object (&self->constraint);
gtk_widget_dispose_template (GTK_WIDGET (object), CONSTRAINT_EDITOR_TYPE);
G_OBJECT_CLASS (constraint_editor_parent_class)->dispose (object);
}

View File

@@ -21,6 +21,8 @@
#include "guide-editor.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
struct _GuideEditor
{
GtkWidget parent_instance;
@@ -294,9 +296,10 @@ guide_editor_dispose (GObject *object)
{
GuideEditor *self = (GuideEditor *)object;
g_clear_pointer (&self->grid, gtk_widget_unparent);
g_clear_object (&self->guide);
gtk_widget_dispose_template (GTK_WIDGET (self), GUIDE_EDITOR_TYPE);
G_OBJECT_CLASS (guide_editor_parent_class)->dispose (object);
}

View File

@@ -1,303 +0,0 @@
#include "fontcolors.h"
#include <gtk/gtk.h>
#include <hb-ot.h>
#include "rangeedit.h"
enum {
PROP_FONT_MAP = 1,
PROP_FONT_DESC,
PROP_PALETTE,
NUM_PROPERTIES
};
static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
struct _FontColors
{
GtkWidget parent;
GtkGrid *label;
GtkGrid *grid;
Pango2FontDescription *font_desc;
GSimpleAction *reset_action;
gboolean has_colors;
char *palette;
GtkCheckButton *default_check;
Pango2FontMap *font_map;
};
struct _FontColorsClass
{
GtkWidgetClass parent_class;
};
G_DEFINE_TYPE (FontColors, font_colors, GTK_TYPE_WIDGET);
static Pango2Font *
get_font (FontColors *self)
{
Pango2Context *context;
Pango2Font *font;
context = pango2_context_new_with_font_map (self->font_map);
font = pango2_context_load_font (context, self->font_desc);
g_object_unref (context);
return font;
}
static void
palette_changed (GtkCheckButton *button,
FontColors *self)
{
g_free (self->palette);
self->palette = g_strdup ((const char *) g_object_get_data (G_OBJECT (button), "palette"));
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PALETTE]);
}
static void
update_colors (FontColors *self)
{
Pango2Font *font;
hb_font_t *hb_font;
hb_face_t *hb_face;
GtkWidget *child;
GtkWidget *check;
unsigned int n_colors;
hb_color_t *colors;
GtkWidget *box;
g_object_ref (self->label);
while ((child = gtk_widget_get_first_child (GTK_WIDGET (self->grid))))
gtk_grid_remove (self->grid, child);
gtk_grid_attach (self->grid, GTK_WIDGET (self->label), 0, -4, 2, 1);
g_object_unref (self->label);
self->default_check = NULL;
font = get_font (self);
hb_font = pango2_font_get_hb_font (font);
hb_face = hb_font_get_face (hb_font);
self->has_colors = hb_ot_color_has_palettes (hb_face);
gtk_widget_set_visible (GTK_WIDGET (self), self->has_colors);
if (!self->has_colors)
{
g_simple_action_set_enabled (self->reset_action, FALSE);
return;
}
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
gtk_box_set_homogeneous (GTK_BOX (box), TRUE);
gtk_grid_attach (self->grid, box, 0, -3, 2, 1);
check = gtk_check_button_new_with_label ("Default");
g_object_set_data (G_OBJECT (check), "palette", (gpointer)"default");
if (g_strcmp0 ("default", self->palette) == 0)
gtk_check_button_set_active (GTK_CHECK_BUTTON (check), TRUE);
g_signal_connect (check, "toggled", G_CALLBACK (palette_changed), self);
gtk_box_append (GTK_BOX (box), check);
self->default_check = GTK_CHECK_BUTTON (check);
check = gtk_check_button_new_with_label ("Light");
g_object_set_data (G_OBJECT (check), "palette", (gpointer)"light");
if (g_strcmp0 ("light", self->palette) == 0)
gtk_check_button_set_active (GTK_CHECK_BUTTON (check), TRUE);
g_signal_connect (check, "toggled", G_CALLBACK (palette_changed), self);
gtk_check_button_set_group (GTK_CHECK_BUTTON (check), self->default_check);
gtk_box_append (GTK_BOX (box), check);
check = gtk_check_button_new_with_label ("Dark");
g_object_set_data (G_OBJECT (check), "palette", (gpointer)"dark");
if (g_strcmp0 ("dark", self->palette) == 0)
gtk_check_button_set_active (GTK_CHECK_BUTTON (check), TRUE);
g_signal_connect (check, "toggled", G_CALLBACK (palette_changed), self);
gtk_check_button_set_group (GTK_CHECK_BUTTON (check), self->default_check);
gtk_box_append (GTK_BOX (box), check);
for (int i = 0; i < hb_ot_color_palette_get_count (hb_face); i++)
{
char *id = g_strdup_printf ("palette%d", i);
char *label = g_strdup_printf ("Palette %d", i);
GtkWidget *palette;
check = gtk_check_button_new_with_label (label);
g_object_set_data_full (G_OBJECT (check), "palette", id, g_free);
if (g_strcmp0 (id, self->palette) == 0)
gtk_check_button_set_active (GTK_CHECK_BUTTON (check), TRUE);
g_signal_connect (check, "toggled", G_CALLBACK (palette_changed), self);
gtk_check_button_set_group (GTK_CHECK_BUTTON (check), self->default_check);
gtk_grid_attach (self->grid, check, 0, i, 1, 1);
n_colors = hb_ot_color_palette_get_colors (hb_face, i, 0, NULL, NULL);
colors = g_new (hb_color_t, n_colors);
n_colors = hb_ot_color_palette_get_colors (hb_face, i, 0, &n_colors, colors);
palette = gtk_grid_new ();
gtk_widget_set_valign (palette, GTK_ALIGN_CENTER);
gtk_grid_attach (self->grid, palette, 1, i, 1, 1);
/* HACK - defeat first-child/last-child theming */
gtk_grid_attach (GTK_GRID (palette), gtk_picture_new (), -1, 0, 1, 1);
for (int k = 0; k < n_colors; k++)
{
GtkWidget *swatch;
swatch = g_object_new (g_type_from_name ("GtkColorSwatch"),
"rgba", &(GdkRGBA){ hb_color_get_red (colors[k])/255.,
hb_color_get_green (colors[k])/255.,
hb_color_get_blue (colors[k])/255.,
hb_color_get_alpha (colors[k])/255.},
"selectable", FALSE,
"has-menu", FALSE,
"can-drag", FALSE,
"width-request", 16,
"height-request", 16,
NULL);
gtk_grid_attach (GTK_GRID (palette), swatch, k % 6, k / 6, 1, 1);
}
/* HACK - defeat first-child/last-child theming */
gtk_grid_attach (GTK_GRID (palette), gtk_picture_new (), 6, 0, 1, 1);
}
}
static void
reset (GSimpleAction *action,
GVariant *parameter,
FontColors *self)
{
g_free (self->palette);
self->palette = g_strdup (PANGO2_COLOR_PALETTE_DEFAULT);
if (self->has_colors)
gtk_check_button_set_active (self->default_check, TRUE);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PALETTE]);
g_simple_action_set_enabled (self->reset_action, FALSE);
}
static void
font_colors_init (FontColors *self)
{
self->font_map = g_object_ref (pango2_font_map_get_default ());
self->palette = g_strdup (PANGO2_COLOR_PALETTE_DEFAULT);
gtk_widget_init_template (GTK_WIDGET (self));
self->reset_action = g_simple_action_new ("reset", NULL);
g_simple_action_set_enabled (self->reset_action, FALSE);
g_signal_connect (self->reset_action, "activate", G_CALLBACK (reset), self);
}
static void
font_colors_dispose (GObject *object)
{
gtk_widget_clear_template (GTK_WIDGET (object), FONT_COLORS_TYPE);
G_OBJECT_CLASS (font_colors_parent_class)->dispose (object);
}
static void
font_colors_finalize (GObject *object)
{
FontColors *self = FONT_COLORS (object);
g_clear_pointer (&self->font_desc, pango2_font_description_free);
g_free (self->palette);
g_clear_object (&self->font_map);
G_OBJECT_CLASS (font_colors_parent_class)->finalize (object);
}
static void
font_colors_set_property (GObject *object,
unsigned int prop_id,
const GValue *value,
GParamSpec *pspec)
{
FontColors *self = FONT_COLORS (object);
switch (prop_id)
{
case PROP_FONT_MAP:
g_set_object (&self->font_map, g_value_get_object (value));
break;
case PROP_FONT_DESC:
pango2_font_description_free (self->font_desc);
self->font_desc = pango2_font_description_copy (g_value_get_boxed (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
update_colors (self);
}
static void
font_colors_get_property (GObject *object,
unsigned int prop_id,
GValue *value,
GParamSpec *pspec)
{
FontColors *self = FONT_COLORS (object);
switch (prop_id)
{
case PROP_PALETTE:
g_value_set_string (value, self->palette);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
font_colors_class_init (FontColorsClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->dispose = font_colors_dispose;
object_class->finalize = font_colors_finalize;
object_class->get_property = font_colors_get_property;
object_class->set_property = font_colors_set_property;
properties[PROP_FONT_MAP] =
g_param_spec_object ("font-map", "", "",
PANGO2_TYPE_FONT_MAP,
G_PARAM_READWRITE);
properties[PROP_FONT_DESC] =
g_param_spec_boxed ("font-desc", "", "",
PANGO2_TYPE_FONT_DESCRIPTION,
G_PARAM_WRITABLE);
properties[PROP_PALETTE] =
g_param_spec_string ("palette", "", "",
PANGO2_COLOR_PALETTE_DEFAULT,
G_PARAM_READABLE);
g_object_class_install_properties (G_OBJECT_CLASS (class), NUM_PROPERTIES, properties);
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/fontexplorer/fontcolors.ui");
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontColors, grid);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontColors, label);
gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (class), "fontcolors");
}
GAction *
font_colors_get_reset_action (FontColors *self)
{
return G_ACTION (self->reset_action);
}

View File

@@ -1,15 +0,0 @@
#pragma once
#include <gtk/gtk.h>
#define FONT_COLORS_TYPE (font_colors_get_type ())
#define FONT_COLORS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FONT_COLORS_TYPE, FontColors))
typedef struct _FontColors FontColors;
typedef struct _FontColorsClass FontColorsClass;
GType font_colors_get_type (void);
GAction * font_colors_get_reset_action (FontColors *self);

View File

@@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="FontColors" parent="GtkWidget">
<property name="layout-manager"><object class="GtkBinLayout"/></property>
<child>
<object class="GtkGrid" id="grid">
<child>
<object class="GtkLabel" id="label">
<property name="label" translatable="yes">Colors</property>
<property name="margin-bottom">10</property>
<property name="xalign">0</property>
<style>
<class name="heading"/>
</style>
<layout>
<property name="row">-2</property>
<property name="column">0</property>
<property name="column-span">2</property>
</layout>
</object>
</child>
</object>
</child>
</template>
</interface>

View File

@@ -1,257 +0,0 @@
#include "fontcontrols.h"
#include <gtk/gtk.h>
#include <hb-ot.h>
#include "rangeedit.h"
enum {
PROP_SIZE = 1,
PROP_LETTERSPACING,
PROP_LINE_HEIGHT,
PROP_FOREGROUND,
PROP_BACKGROUND,
NUM_PROPERTIES
};
static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
struct _FontControls
{
GtkWidget parent;
GtkAdjustment *size_adjustment;
GtkAdjustment *letterspacing_adjustment;
GtkAdjustment *line_height_adjustment;
GtkColorButton *foreground;
GtkColorButton *background;
GSimpleAction *reset_action;
};
struct _FontControlsClass
{
GtkWidgetClass parent_class;
};
G_DEFINE_TYPE(FontControls, font_controls, GTK_TYPE_WIDGET);
static void
size_changed (GtkAdjustment *adjustment,
FontControls *self)
{
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SIZE]);
g_simple_action_set_enabled (self->reset_action, TRUE);
}
static void
letterspacing_changed (GtkAdjustment *adjustment,
FontControls *self)
{
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_LETTERSPACING]);
g_simple_action_set_enabled (self->reset_action, TRUE);
}
static void
line_height_changed (GtkAdjustment *adjustment,
FontControls *self)
{
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_LINE_HEIGHT]);
g_simple_action_set_enabled (self->reset_action, TRUE);
}
static void
color_set (GtkColorButton *button,
GParamSpec *pspec,
FontControls *self)
{
if (button == self->foreground)
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FOREGROUND]);
else
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_BACKGROUND]);
g_simple_action_set_enabled (self->reset_action, TRUE);
}
static void
swap_colors (GtkButton *button,
FontControls *self)
{
GdkRGBA fg;
GdkRGBA bg;
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (self->foreground), &fg);
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (self->background), &bg);
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (self->foreground), &bg);
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (self->background), &fg);
}
static void
reset (GSimpleAction *action,
GVariant *parameter,
FontControls *self)
{
gtk_adjustment_set_value (self->size_adjustment, 12.);
gtk_adjustment_set_value (self->letterspacing_adjustment, 0.);
gtk_adjustment_set_value (self->line_height_adjustment, 1.);
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (self->foreground), &(GdkRGBA){0., 0., 0., 1.0 });
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (self->background), &(GdkRGBA){1., 1., 1., 1.0 });
g_simple_action_set_enabled (self->reset_action, FALSE);
}
static void
font_controls_init (FontControls *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
self->reset_action = g_simple_action_new ("reset", NULL);
g_simple_action_set_enabled (self->reset_action, FALSE);
g_signal_connect (self->reset_action, "activate", G_CALLBACK (reset), self);
}
static void
font_controls_dispose (GObject *object)
{
gtk_widget_clear_template (GTK_WIDGET (object), FONT_CONTROLS_TYPE);
G_OBJECT_CLASS (font_controls_parent_class)->dispose (object);
}
static void
font_controls_finalize (GObject *object)
{
//FontControls *self = FONT_CONTROLS (object);
G_OBJECT_CLASS (font_controls_parent_class)->finalize (object);
}
static void
font_controls_set_property (GObject *object,
unsigned int prop_id,
const GValue *value,
GParamSpec *pspec)
{
FontControls *self = FONT_CONTROLS (object);
switch (prop_id)
{
case PROP_SIZE:
gtk_adjustment_set_value (self->size_adjustment, g_value_get_float (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
font_controls_get_property (GObject *object,
unsigned int prop_id,
GValue *value,
GParamSpec *pspec)
{
FontControls *self = FONT_CONTROLS (object);
switch (prop_id)
{
case PROP_SIZE:
g_value_set_float (value, gtk_adjustment_get_value (self->size_adjustment));
break;
case PROP_LETTERSPACING:
g_value_set_int (value, (int) gtk_adjustment_get_value (self->letterspacing_adjustment));
break;
case PROP_LINE_HEIGHT:
g_value_set_float (value, gtk_adjustment_get_value (self->line_height_adjustment));
break;
case PROP_FOREGROUND:
{
GdkRGBA rgba;
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (self->foreground), &rgba);
g_value_set_boxed (value, &rgba);
}
break;
case PROP_BACKGROUND:
{
GdkRGBA rgba;
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (self->background), &rgba);
g_value_set_boxed (value, &rgba);
}
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
font_controls_class_init (FontControlsClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
g_type_ensure (RANGE_EDIT_TYPE);
object_class->dispose = font_controls_dispose;
object_class->finalize = font_controls_finalize;
object_class->get_property = font_controls_get_property;
object_class->set_property = font_controls_set_property;
properties[PROP_SIZE] =
g_param_spec_float ("size", "", "",
0., 100., 12.,
G_PARAM_READABLE);
properties[PROP_LETTERSPACING] =
g_param_spec_int ("letterspacing", "", "",
-G_MAXINT, G_MAXINT, 0,
G_PARAM_READABLE);
properties[PROP_LINE_HEIGHT] =
g_param_spec_float ("line-height", "", "",
0., 100., 1.,
G_PARAM_READABLE);
properties[PROP_FOREGROUND] =
g_param_spec_boxed ("foreground", "", "",
GDK_TYPE_RGBA,
G_PARAM_READABLE);
properties[PROP_BACKGROUND] =
g_param_spec_boxed ("background", "", "",
GDK_TYPE_RGBA,
G_PARAM_READABLE);
g_object_class_install_properties (G_OBJECT_CLASS (class), NUM_PROPERTIES, properties);
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/fontexplorer/fontcontrols.ui");
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontControls, size_adjustment);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontControls, letterspacing_adjustment);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontControls, line_height_adjustment);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontControls, foreground);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontControls, background);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), size_changed);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), letterspacing_changed);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), line_height_changed);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), color_set);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), swap_colors);
gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (class), "fontcontrols");
}
FontControls *
font_controls_new (void)
{
return g_object_new (FONT_CONTROLS_TYPE, NULL);
}
GAction *
font_controls_get_reset_action (FontControls *self)
{
return G_ACTION (self->reset_action);
}

View File

@@ -1,16 +0,0 @@
#pragma once
#include <gtk/gtk.h>
#define FONT_CONTROLS_TYPE (font_controls_get_type ())
#define FONT_CONTROLS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FONT_CONTROLS_TYPE, FontControls))
typedef struct _FontControls FontControls;
typedef struct _FontControlsClass FontControlsClass;
GType font_controls_get_type (void);
FontControls * font_controls_new (void);
GAction * font_controls_get_reset_action (FontControls *self);

View File

@@ -1,173 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="FontControls" parent="GtkWidget">
<property name="layout-manager"><object class="GtkGridLayout"/></property>
<child>
<object class="GtkLabel">
<property name="label">Size</property>
<property name="xalign">0</property>
<property name="valign">baseline</property>
<layout>
<property name="column">0</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="RangeEdit">
<property name="hexpand">1</property>
<property name="width-request">160</property>
<property name="valign">baseline</property>
<property name="adjustment">
<object class="GtkAdjustment" id="size_adjustment">
<property name="lower">7</property>
<property name="upper">100</property>
<property name="value">14</property>
<property name="step_increment">0.5</property>
<property name="page_increment">10</property>
<signal name="value-changed" handler="size_changed"/>
</object>
</property>
<property name="default-value">12</property>
<property name="n-chars">5</property>
<layout>
<property name="column">1</property>
<property name="row">0</property>
<property name="column-span">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Letterspacing</property>
<property name="xalign">0</property>
<property name="valign">baseline</property>
<layout>
<property name="column">0</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="RangeEdit">
<property name="hexpand">1</property>
<property name="width-request">160</property>
<property name="valign">baseline</property>
<property name="adjustment">
<object class="GtkAdjustment" id="letterspacing_adjustment">
<property name="lower">-1024</property>
<property name="upper">8192</property>
<property name="value">0</property>
<property name="step_increment">1</property>
<property name="page_increment">512</property>
<signal name="value-changed" handler="letterspacing_changed"/>
</object>
</property>
<property name="default-value">0</property>
<property name="n-chars">5</property>
<layout>
<property name="column">1</property>
<property name="row">1</property>
<property name="column-span">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Line Height</property>
<property name="xalign">0</property>
<property name="valign">baseline</property>
<layout>
<property name="column">0</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="RangeEdit">
<property name="hexpand">1</property>
<property name="width-request">160</property>
<property name="valign">baseline</property>
<property name="adjustment">
<object class="GtkAdjustment" id="line_height_adjustment">
<property name="lower">0.75</property>
<property name="upper">2.5</property>
<property name="value">1.0</property>
<property name="step_increment">0.1</property>
<property name="page_increment">1</property>
<signal name="value-changed" handler="line_height_changed"/>
</object>
</property>
<property name="default-value">1</property>
<property name="n-chars">5</property>
<layout>
<property name="column">1</property>
<property name="row">2</property>
<property name="column-span">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Foreground</property>
<property name="xalign">0</property>
<property name="valign">baseline</property>
<layout>
<property name="column">0</property>
<property name="row">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkColorButton" id="foreground">
<property name="rgba">black</property>
<signal name="notify::rgba" handler="color_set"/>
<layout>
<property name="column">1</property>
<property name="row">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Background</property>
<property name="xalign">0</property>
<property name="valign">baseline</property>
<layout>
<property name="column">0</property>
<property name="row">4</property>
</layout>
</object>
</child>
<child>
<object class="GtkColorButton" id="background">
<property name="rgba">white</property>
<signal name="notify::rgba" handler="color_set"/>
<layout>
<property name="column">1</property>
<property name="row">4</property>
</layout>
</object>
</child>
<child>
<object class="GtkButton">
<property name="icon-name">object-flip-vertical-symbolic</property>
<property name="halign">start</property>
<property name="valign">center</property>
<style>
<class name="circular"/>
</style>
<signal name="clicked" handler="swap_colors"/>
<layout>
<property name="column">2</property>
<property name="row">3</property>
<property name="row-span">2</property>
</layout>
</object>
</child>
</template>
</interface>

View File

@@ -1,43 +0,0 @@
box.sidebar {
padding: 20px;
border-spacing: 20px;
}
fontcontrols {
border-spacing: 10px;
}
fontvariations > grid {
border-spacing: 10px;
}
fontcolors > grid {
border-spacing: 10px;
}
samplechooser {
border-spacing: 10px;
}
plainview .content {
padding: 20px;
}
waterfallview .content {
padding: 20px;
}
styleview .content {
padding: 20px;
}
glyphsview .content {
padding: 20px;
}
infoview .content {
padding: 20px;
border-spacing: 10px;
}
gridview > child {
padding: 0;
}
glyphview {
padding: 0;
border: 0.6px solid gray;
}
.viewcontrols {
padding: 20px;
border-spacing: 10px;
}

View File

@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gtk/fontexplorer">
<file preprocess="xml-stripblanks">fontcolors.ui</file>
<file preprocess="xml-stripblanks">fontcontrols.ui</file>
<file preprocess="xml-stripblanks">fontexplorerwin.ui</file>
<file preprocess="xml-stripblanks">fontfeatures.ui</file>
<file preprocess="xml-stripblanks">fontvariations.ui</file>
<file preprocess="xml-stripblanks">glyphsview.ui</file>
<file preprocess="xml-stripblanks">infoview.ui</file>
<file preprocess="xml-stripblanks">plainview.ui</file>
<file preprocess="xml-stripblanks">rangeedit.ui</file>
<file preprocess="xml-stripblanks">samplechooser.ui</file>
<file preprocess="xml-stripblanks">sampleeditor.ui</file>
<file preprocess="xml-stripblanks">styleview.ui</file>
<file preprocess="xml-stripblanks">waterfallview.ui</file>
<file>fontexplorer.css</file>
</gresource>
</gresources>

View File

@@ -1,186 +0,0 @@
#include "config.h"
#include "fontexplorerapp.h"
#include <gtk/gtk.h>
#include "fontexplorerwin.h"
#include "demo_conf.h"
struct _FontExplorerApp
{
GtkApplication parent;
};
struct _FontExplorerAppClass
{
GtkApplicationClass parent_class;
};
G_DEFINE_TYPE(FontExplorerApp, font_explorer_app, GTK_TYPE_APPLICATION);
static void
font_explorer_app_init (FontExplorerApp *app)
{
}
static void
quit_activated (GSimpleAction *action,
GVariant *parameter,
gpointer app)
{
g_application_quit (G_APPLICATION (app));
}
static void
inspector_activated (GSimpleAction *action,
GVariant *parameter,
gpointer app)
{
gtk_window_set_interactive_debugging (TRUE);
}
static void
about_activated (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
GtkApplication *app = user_data;
const char *authors[] = {
"The GTK Team",
NULL
};
char *icon_theme;
char *version;
GString *s;
char *os_name;
char *os_version;
g_object_get (gtk_settings_get_default (),
"gtk-icon-theme-name", &icon_theme,
NULL);
s = g_string_new ("");
os_name = g_get_os_info (G_OS_INFO_KEY_NAME);
os_version = g_get_os_info (G_OS_INFO_KEY_VERSION_ID);
if (os_name && os_version)
g_string_append_printf (s, "OS\t%s %s\n\n", os_name, os_version);
g_string_append (s, "System libraries\n");
g_string_append_printf (s, "\tGLib\t%d.%d.%d\n",
glib_major_version,
glib_minor_version,
glib_micro_version);
g_string_append_printf (s, "\tPango2\t%s\n",
pango2_version_string ());
g_string_append_printf (s, "\tGTK \t%d.%d.%d\n",
gtk_get_major_version (),
gtk_get_minor_version (),
gtk_get_micro_version ());
g_string_append_printf (s, "\nIcon theme\n\t%s", icon_theme);
version = g_strdup_printf ("%s%s%s\nRunning against GTK %d.%d.%d",
PACKAGE_VERSION,
g_strcmp0 (PROFILE, "devel") == 0 ? "-" : "",
g_strcmp0 (PROFILE, "devel") == 0 ? VCS_TAG : "",
gtk_get_major_version (),
gtk_get_minor_version (),
gtk_get_micro_version ());
gtk_show_about_dialog (GTK_WINDOW (gtk_application_get_active_window (app)),
"program-name", g_strcmp0 (PROFILE, "devel") == 0
? "GTK Font Explorer (Development)"
: "GTK Font Explorer",
"version", version,
"copyright", "©1997—2021 The GTK Team",
"license-type", GTK_LICENSE_LGPL_2_1,
"website", "http://www.gtk.org",
"comments", "Program to explore font features",
"authors", authors,
"logo-icon-name", "org.gtk.FontExplorer",
"title", "About GTK Font Explorer",
"system-information", s->str,
NULL);
g_string_free (s, TRUE);
g_free (version);
g_free (icon_theme);
g_free (os_name);
g_free (os_version);
}
static GActionEntry app_entries[] =
{
{ "quit", quit_activated, NULL, NULL, NULL },
{ "inspector", inspector_activated, NULL, NULL, NULL },
{ "about", about_activated, NULL, NULL, NULL }
};
static void
font_explorer_app_startup (GApplication *app)
{
const char *quit_accels[2] = { "<Ctrl>Q", NULL };
GtkCssProvider *provider;
G_APPLICATION_CLASS (font_explorer_app_parent_class)->startup (app);
g_action_map_add_action_entries (G_ACTION_MAP (app),
app_entries, G_N_ELEMENTS (app_entries),
app);
gtk_application_set_accels_for_action (GTK_APPLICATION (app),
"app.quit",
quit_accels);
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_resource (provider, "/org/gtk/fontexplorer/fontexplorer.css");
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
static void
font_explorer_app_activate (GApplication *app)
{
FontExplorerWindow *win;
win = font_explorer_window_new (FONT_EXPLORER_APP (app));
if (g_strcmp0 (PROFILE, "devel") == 0)
gtk_widget_add_css_class (GTK_WIDGET (win), "devel");
gtk_window_present (GTK_WINDOW (win));
}
static void
font_explorer_app_open (GApplication *app,
GFile **files,
int n_files,
const char *hint)
{
FontExplorerWindow *win;
int i;
for (i = 0; i < n_files; i++)
{
win = font_explorer_window_new (FONT_EXPLORER_APP (app));
font_explorer_window_load (win, files[i]);
gtk_window_present (GTK_WINDOW (win));
}
}
static void
font_explorer_app_class_init (FontExplorerAppClass *class)
{
G_APPLICATION_CLASS (class)->startup = font_explorer_app_startup;
G_APPLICATION_CLASS (class)->activate = font_explorer_app_activate;
G_APPLICATION_CLASS (class)->open = font_explorer_app_open;
}
FontExplorerApp *
font_explorer_app_new (void)
{
return g_object_new (FONT_EXPLORER_APP_TYPE,
"application-id", "org.gtk.FontExplorer",
"flags", G_APPLICATION_HANDLES_OPEN,
NULL);
}

View File

@@ -1,15 +0,0 @@
#pragma once
#include <gtk/gtk.h>
#define FONT_EXPLORER_APP_TYPE (font_explorer_app_get_type ())
#define FONT_EXPLORER_APP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FONT_EXPLORER_APP_TYPE, FontExplorerApp))
typedef struct _FontExplorerApp FontExplorerApp;
typedef struct _FontExplorerAppClass FontExplorerAppClass;
GType font_explorer_app_get_type (void);
FontExplorerApp * font_explorer_app_new (void);

View File

@@ -1,269 +0,0 @@
#include "fontexplorerwin.h"
#include <gtk/gtk.h>
#include <string.h>
#include "fontcolors.h"
#include "fontcontrols.h"
#include "fontexplorerapp.h"
#include "fontfeatures.h"
#include "fontvariations.h"
#include "glyphsview.h"
#include "infoview.h"
#include "plainview.h"
#include "samplechooser.h"
#include "sampleeditor.h"
#include "styleview.h"
#include "waterfallview.h"
struct _FontExplorerWindow
{
GtkApplicationWindow parent;
Pango2FontMap *font_map;
GtkFontButton *fontbutton;
GtkLabel *path;
FontControls *controls;
FontFeatures *features;
FontVariations *variations;
FontColors *colors;
GtkStack *stack;
GtkToggleButton *plain_toggle;
GtkToggleButton *waterfall_toggle;
GtkToggleButton *style_toggle;
GtkToggleButton *glyphs_toggle;
GtkToggleButton *info_toggle;
GtkToggleButton *edit_toggle;
};
struct _FontExplorerWindowClass
{
GtkApplicationWindowClass parent_class;
};
enum {
PROP_FONT_MAP = 1,
NUM_PROPERTIES
};
static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
G_DEFINE_TYPE(FontExplorerWindow, font_explorer_window, GTK_TYPE_APPLICATION_WINDOW);
static void
reset (GSimpleAction *action,
GVariant *parameter,
FontExplorerWindow *self)
{
g_action_activate (font_controls_get_reset_action (self->controls), NULL);
g_action_activate (font_features_get_reset_action (self->features), NULL);
g_action_activate (font_variations_get_reset_action (self->variations), NULL);
g_action_activate (font_colors_get_reset_action (self->colors), NULL);
}
static void
update_reset (GSimpleAction *action,
GParamSpec *pspec,
FontExplorerWindow *self)
{
gboolean enabled;
GAction *reset_action;
enabled = g_action_get_enabled (font_controls_get_reset_action (self->controls)) ||
g_action_get_enabled (font_features_get_reset_action (self->features)) ||
g_action_get_enabled (font_variations_get_reset_action (self->variations)) ||
g_action_get_enabled (font_colors_get_reset_action (self->colors));
reset_action = g_action_map_lookup_action (G_ACTION_MAP (self), "reset");
g_simple_action_set_enabled (G_SIMPLE_ACTION (reset_action), enabled);
}
static void
font_explorer_window_init (FontExplorerWindow *self)
{
GSimpleAction *reset_action;
self->font_map = g_object_ref (pango2_font_map_get_default ());
gtk_widget_init_template (GTK_WIDGET (self));
reset_action = g_simple_action_new ("reset", NULL);
g_signal_connect (reset_action, "activate", G_CALLBACK (reset), self);
g_signal_connect (font_controls_get_reset_action (self->controls),
"notify::enabled", G_CALLBACK (update_reset), self);
g_signal_connect (font_variations_get_reset_action (self->variations),
"notify::enabled", G_CALLBACK (update_reset), self);
g_signal_connect (font_colors_get_reset_action (self->colors),
"notify::enabled", G_CALLBACK (update_reset), self);
g_signal_connect (font_features_get_reset_action (self->features),
"notify::enabled", G_CALLBACK (update_reset), self);
g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (reset_action));
update_reset (NULL, NULL, self);
}
static void
update_view (GtkToggleButton *button,
FontExplorerWindow *self)
{
if (gtk_toggle_button_get_active (self->edit_toggle))
gtk_stack_set_visible_child_name (self->stack, "edit");
else if (gtk_toggle_button_get_active (self->plain_toggle))
gtk_stack_set_visible_child_name (self->stack, "plain");
else if (gtk_toggle_button_get_active (self->waterfall_toggle))
gtk_stack_set_visible_child_name (self->stack, "waterfall");
else if (gtk_toggle_button_get_active (self->style_toggle))
gtk_stack_set_visible_child_name (self->stack, "style");
else if (gtk_toggle_button_get_active (self->glyphs_toggle))
gtk_stack_set_visible_child_name (self->stack, "glyphs");
else if (gtk_toggle_button_get_active (self->info_toggle))
gtk_stack_set_visible_child_name (self->stack, "info");
}
static void
font_explorer_window_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
FontExplorerWindow *self = FONT_EXPLORER_WINDOW (object);
switch (prop_id)
{
case PROP_FONT_MAP:
g_set_object (&self->font_map, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
font_explorer_window_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
FontExplorerWindow *self = FONT_EXPLORER_WINDOW (object);
switch (prop_id)
{
case PROP_FONT_MAP:
g_value_set_object (value, self->font_map);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
font_explorer_window_dispose (GObject *object)
{
gtk_widget_clear_template (GTK_WIDGET (object), FONT_EXPLORER_WINDOW_TYPE);
G_OBJECT_CLASS (font_explorer_window_parent_class)->dispose (object);
}
static void
font_explorer_window_finalize (GObject *object)
{
FontExplorerWindow *self = FONT_EXPLORER_WINDOW (object);
g_clear_object (&self->font_map);
G_OBJECT_CLASS (font_explorer_window_parent_class)->finalize (object);
}
static void
font_explorer_window_class_init (FontExplorerWindowClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
g_type_ensure (FONT_COLORS_TYPE);
g_type_ensure (FONT_CONTROLS_TYPE);
g_type_ensure (FONT_FEATURES_TYPE);
g_type_ensure (FONT_VARIATIONS_TYPE);
g_type_ensure (GLYPHS_VIEW_TYPE);
g_type_ensure (INFO_VIEW_TYPE);
g_type_ensure (PLAIN_VIEW_TYPE);
g_type_ensure (SAMPLE_CHOOSER_TYPE);
g_type_ensure (SAMPLE_EDITOR_TYPE);
g_type_ensure (STYLE_VIEW_TYPE);
g_type_ensure (WATERFALL_VIEW_TYPE);
object_class->set_property = font_explorer_window_set_property;
object_class->get_property = font_explorer_window_get_property;
object_class->dispose = font_explorer_window_dispose;
object_class->finalize = font_explorer_window_finalize;
properties[PROP_FONT_MAP] =
g_param_spec_object ("font-map", "", "",
PANGO2_TYPE_FONT_MAP,
G_PARAM_READWRITE);
g_object_class_install_properties (G_OBJECT_CLASS (class), NUM_PROPERTIES, properties);
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/fontexplorer/fontexplorerwin.ui");
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontExplorerWindow, fontbutton);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontExplorerWindow, path);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontExplorerWindow, controls);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontExplorerWindow, variations);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontExplorerWindow, colors);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontExplorerWindow, features);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontExplorerWindow, stack);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontExplorerWindow, plain_toggle);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontExplorerWindow, waterfall_toggle);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontExplorerWindow, style_toggle);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontExplorerWindow, glyphs_toggle);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontExplorerWindow, info_toggle);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontExplorerWindow, edit_toggle);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), update_view);
}
FontExplorerWindow *
font_explorer_window_new (FontExplorerApp *app)
{
return g_object_new (FONT_EXPLORER_WINDOW_TYPE, "application", app, NULL);
}
void
font_explorer_window_load (FontExplorerWindow *self,
GFile *file)
{
const char *path;
Pango2FontMap *map;
Pango2HbFace *face;
Pango2FontDescription *desc;
char *basename;
path = g_file_peek_path (file);
basename = g_path_get_basename (path);
face = pango2_hb_face_new_from_file (path, 0, -2, NULL, NULL);
desc = pango2_font_face_describe (PANGO2_FONT_FACE (face));
map = pango2_font_map_new ();
pango2_font_map_add_face (map, PANGO2_FONT_FACE (face));
pango2_font_map_set_fallback (map, pango2_font_map_get_default ());
g_set_object (&self->font_map, map);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FONT_MAP]);
g_object_unref (map);
gtk_font_chooser_set_font_desc (GTK_FONT_CHOOSER (self->fontbutton), desc);
gtk_widget_hide (GTK_WIDGET (self->fontbutton));
gtk_widget_show (GTK_WIDGET (self->path));
gtk_label_set_label (self->path, basename);
pango2_font_description_free (desc);
g_free (basename);
}

View File

@@ -1,18 +0,0 @@
#pragma once
#include <gtk/gtk.h>
#include "fontexplorerapp.h"
#define FONT_EXPLORER_WINDOW_TYPE (font_explorer_window_get_type ())
#define FONT_EXPLORER_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FONT_EXPLORER_WINDOW_TYPE, FontExplorerWindow))
typedef struct _FontExplorerWindow FontExplorerWindow;
typedef struct _FontExplorerWindowClass FontExplorerWindowClass;
GType font_explorer_window_get_type (void);
FontExplorerWindow * font_explorer_window_new (FontExplorerApp *app);
void font_explorer_window_load (FontExplorerWindow *self,
GFile *file);

View File

@@ -1,252 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<menu id="gear_menu">
<section>
<item>
<attribute name="label" translatable="yes">_Inspector</attribute>
<attribute name="action">app.inspector</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_About GTK Font Explorer</attribute>
<attribute name="action">app.about</attribute>
</item>
</section>
</menu>
<template class="FontExplorerWindow" parent="GtkApplicationWindow">
<property name="title" translatable="yes">Font Explorer</property>
<property name="default-width">1024</property>
<property name="default-height">768</property>
<child type="titlebar">
<object class="GtkHeaderBar">
<child>
<object class="GtkButton" id="reset">
<property name="receives-default">1</property>
<property name="tooltip-text">Reset</property>
<property name="icon-name">view-refresh-symbolic</property>
<property name="action-name">win.reset</property>
</object>
</child>
<child type="title">
<object class="GtkBox">
<property name="orientation">horizontal</property>
<style>
<class name="linked"/>
</style>
<child>
<object class="GtkToggleButton" id="plain_toggle">
<property name="label">Plain</property>
<property name="active">1</property>
<signal name="toggled" handler="update_view"/>
</object>
</child>
<child>
<object class="GtkToggleButton" id="waterfall_toggle">
<property name="label">Waterfall</property>
<property name="group">plain_toggle</property>
<signal name="toggled" handler="update_view"/>
</object>
</child>
<child>
<object class="GtkToggleButton" id="style_toggle">
<property name="label">Styles</property>
<property name="group">plain_toggle</property>
<property name="sensitive" bind-source="styleview" bind-property="has-styles" bind-flags="sync-create"/>
<signal name="toggled" handler="update_view"/>
</object>
</child>
<child>
<object class="GtkToggleButton" id="glyphs_toggle">
<property name="label">Glyphs</property>
<property name="group">plain_toggle</property>
<signal name="toggled" handler="update_view"/>
</object>
</child>
<child>
<object class="GtkToggleButton" id="info_toggle">
<property name="label">Info</property>
<property name="group">plain_toggle</property>
<signal name="toggled" handler="update_view"/>
</object>
</child>
</object>
</child>
<child type="end">
<object class="GtkMenuButton" id="gear_menu_button">
<property name="focus-on-click">0</property>
<property name="valign">center</property>
<property name="menu-model">gear_menu</property>
<property name="icon-name">open-menu-symbolic</property>
</object>
</child>
<child type="end">
<object class="GtkToggleButton" id="edit_toggle">
<property name="hexpand">1</property>
<property name="halign">end</property>
<property name="icon-name">document-edit-symbolic</property>
<property name="tooltip-text" translatable="yes">Edit the sample</property>
<signal name="toggled" handler="update_view"/>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<child>
<object class="GtkScrolledWindow">
<property name="hscrollbar-policy">never</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<style>
<class name="sidebar"/>
</style>
<child>
<object class="GtkFontButton" id="fontbutton">
<property name="level">family|style</property>
</object>
</child>
<child>
<object class="GtkLabel" id="path">
<property name="visible">0</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
<child>
<object class="FontControls" id="controls">
</object>
</child>
<child>
<object class="SampleChooser" id="samplechooser"/>
</child>
<child>
<object class="FontVariations" id="variations">
<property name="font-map" bind-source="FontExplorerWindow" bind-flags="sync-create"/>
<property name="font-desc" bind-source="fontbutton" bind-flags="sync-create"/>
</object>
</child>
<child>
<object class="FontFeatures" id="features">
<property name="font-map" bind-source="FontExplorerWindow" bind-flags="sync-create"/>
<property name="font-desc" bind-source="fontbutton" bind-flags="sync-create"/>
<property name="language" bind-source="fontbutton" bind-flags="sync-create"/>
</object>
</child>
<child>
<object class="FontColors" id="colors">
<property name="font-map" bind-source="FontExplorerWindow" bind-flags="sync-create"/>
<property name="font-desc" bind-source="fontbutton" bind-flags="sync-create"/>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkStack" id="stack">
<property name="hexpand">1</property>
<child>
<object class="GtkStackPage">
<property name="name">plain</property>
<property name="child">
<object class="PlainView">
<property name="font-map" bind-source="FontExplorerWindow" bind-flags="sync-create"/>
<property name="font-desc" bind-source="fontbutton" bind-flags="sync-create"/>
<property name="font-desc" bind-source="fontbutton" bind-flags="sync-create"/>
<property name="size" bind-source="controls" bind-flags="sync-create"/>
<property name="letterspacing" bind-source="controls" bind-flags="sync-create"/>
<property name="line-height" bind-source="controls" bind-flags="sync-create"/>
<property name="foreground" bind-source="controls" bind-flags="sync-create"/>
<property name="background" bind-source="controls" bind-flags="sync-create"/>
<property name="sample-text" bind-source="sampleeditor" bind-flags="sync-create"/>
<property name="features" bind-source="features" bind-flags="sync-create"/>
<property name="variations" bind-source="variations" bind-flags="sync-create"/>
<property name="palette" bind-source="colors" bind-flags="sync-create"/>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">waterfall</property>
<property name="child">
<object class="WaterfallView">
<property name="font-map" bind-source="FontExplorerWindow" bind-flags="sync-create"/>
<property name="font-desc" bind-source="fontbutton" bind-flags="sync-create"/>
<property name="size" bind-source="controls" bind-flags="sync-create"/>
<property name="letterspacing" bind-source="controls" bind-flags="sync-create"/>
<property name="line-height" bind-source="controls" bind-flags="sync-create"/>
<property name="foreground" bind-source="controls" bind-flags="sync-create"/>
<property name="background" bind-source="controls" bind-flags="sync-create"/>
<property name="sample-text" bind-source="sampleeditor" bind-flags="sync-create"/>
<property name="features" bind-source="features" bind-flags="sync-create"/>
<property name="variations" bind-source="variations" bind-flags="sync-create"/>
<property name="palette" bind-source="colors" bind-flags="sync-create"/>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">style</property>
<property name="child">
<object class="StyleView" id="styleview">
<property name="font-map" bind-source="FontExplorerWindow" bind-flags="sync-create"/>
<property name="font-desc" bind-source="fontbutton" bind-flags="sync-create"/>
<property name="size" bind-source="controls" bind-flags="sync-create"/>
<property name="letterspacing" bind-source="controls" bind-flags="sync-create"/>
<property name="line-height" bind-source="controls" bind-flags="sync-create"/>
<property name="foreground" bind-source="controls" bind-flags="sync-create"/>
<property name="background" bind-source="controls" bind-flags="sync-create"/>
<property name="sample-text" bind-source="sampleeditor" bind-flags="sync-create"/>
<property name="features" bind-source="features" bind-flags="sync-create"/>
<property name="variations" bind-source="variations" bind-flags="sync-create"/>
<property name="palette" bind-source="colors" bind-flags="sync-create"/>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">glyphs</property>
<property name="child">
<object class="GlyphsView">
<property name="font-map" bind-source="FontExplorerWindow" bind-flags="sync-create"/>
<property name="font-desc" bind-source="fontbutton" bind-flags="sync-create"/>
<property name="variations" bind-source="variations" bind-flags="sync-create"/>
<property name="palette" bind-source="colors" bind-flags="sync-create"/>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">info</property>
<property name="child">
<object class="InfoView">
<property name="font-map" bind-source="FontExplorerWindow" bind-flags="sync-create"/>
<property name="font-desc" bind-source="fontbutton" bind-flags="sync-create"/>
<property name="size" bind-source="controls" bind-flags="sync-create"/>
<property name="variations" bind-source="variations" bind-flags="sync-create"/>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">edit</property>
<property name="child">
<object class="SampleEditor" id="sampleeditor">
<property name="sample-text" bind-source="samplechooser" bind-flags="sync-create"/>
<property name="editing" bind-source="edit_toggle" bind-property="active" bind-flags="sync-create"/>
</object>
</property>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
</interface>

View File

@@ -1,744 +0,0 @@
#include "fontfeatures.h"
#include <gtk/gtk.h>
#include <hb-ot.h>
#include <glib/gi18n.h>
#include "open-type-layout.h"
#include "language-names.h"
enum {
PROP_FONT_MAP = 1,
PROP_FONT_DESC,
PROP_LANGUAGE,
PROP_FEATURES,
NUM_PROPERTIES
};
static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
typedef struct {
unsigned int tag;
const char *name;
GtkWidget *feat;
} FeatureItem;
struct _FontFeatures
{
GtkWidget parent;
GtkGrid *label;
GtkGrid *grid;
Pango2FontDescription *font_desc;
GSimpleAction *reset_action;
Pango2Language *lang;
GList *feature_items;
Pango2FontMap *font_map;
};
struct _FontFeaturesClass
{
GtkWidgetClass parent_class;
};
G_DEFINE_TYPE(FontFeatures, font_features, GTK_TYPE_WIDGET);
static Pango2Font *
get_font (FontFeatures *self)
{
Pango2Context *context;
Pango2Font *font;
context = pango2_context_new_with_font_map (self->font_map);
font = pango2_context_load_font (context, self->font_desc);
g_object_unref (context);
return font;
}
static gboolean
is_ssNN (const char *buf)
{
return g_str_has_prefix (buf, "ss") && g_ascii_isdigit (buf[2]) && g_ascii_isdigit (buf[3]);
}
static gboolean
is_cvNN (const char *buf)
{
return g_str_has_prefix (buf, "cv") && g_ascii_isdigit (buf[2]) && g_ascii_isdigit (buf[3]);
}
static char *
get_feature_display_name (unsigned int tag)
{
int i;
static char buf[5] = { 0, };
if (tag == HB_TAG ('x', 'x', 'x', 'x'))
return g_strdup (_("Default"));
hb_tag_to_string (tag, buf);
if (is_ssNN (buf))
{
int num = (buf[2] - '0') * 10 + (buf[3] - '0');
return g_strdup_printf (g_dpgettext2 (NULL, "OpenType layout", "Stylistic Set %d"), num);
}
else if (is_cvNN (buf))
{
int num = (buf[2] - '0') * 10 + (buf[3] - '0');
return g_strdup_printf (g_dpgettext2 (NULL, "OpenType layout", "Character Variant %d"), num);
}
for (i = 0; i < G_N_ELEMENTS (open_type_layout_features); i++)
{
if (tag == open_type_layout_features[i].tag)
return g_strdup (g_dpgettext2 (NULL, "OpenType layout", open_type_layout_features[i].name));
}
g_warning ("unknown OpenType layout feature tag: %s", buf);
return g_strdup (buf);
}
static void
update_feature_label (FontFeatures *self,
FeatureItem *item,
hb_font_t *hb_font,
hb_tag_t script_tag,
hb_tag_t lang_tag)
{
hb_face_t *hb_face;
unsigned int script_index, lang_index, feature_index;
hb_ot_name_id_t id;
unsigned int len;
char *label;
char name[5] = { 0, };
hb_face = hb_font_get_face (hb_font);
hb_tag_to_string (item->tag, name);
if (!is_ssNN (name) && !is_cvNN (name))
return;
hb_ot_layout_table_find_script (hb_face, HB_OT_TAG_GSUB, script_tag, &script_index);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
hb_ot_layout_script_find_language (hb_face, HB_OT_TAG_GSUB, script_index, lang_tag, &lang_index);
G_GNUC_END_IGNORE_DEPRECATIONS
if (hb_ot_layout_language_find_feature (hb_face, HB_OT_TAG_GSUB, script_index, lang_index, item->tag, &feature_index) &&
hb_ot_layout_feature_get_name_ids (hb_face, HB_OT_TAG_GSUB, feature_index, &id, NULL, NULL, NULL, NULL))
{
len = hb_ot_name_get_utf8 (hb_face, id, HB_LANGUAGE_INVALID, NULL, NULL);
len++;
label = g_new (char, len);
hb_ot_name_get_utf8 (hb_face, id, HB_LANGUAGE_INVALID, &len, label);
gtk_check_button_set_label (GTK_CHECK_BUTTON (item->feat), label);
g_free (label);
}
else
{
label = get_feature_display_name (item->tag);
gtk_check_button_set_label (GTK_CHECK_BUTTON (item->feat), label);
g_free (label);
}
}
static void
set_inconsistent (GtkCheckButton *button,
gboolean inconsistent)
{
gtk_check_button_set_inconsistent (GTK_CHECK_BUTTON (button), inconsistent);
gtk_widget_set_opacity (gtk_widget_get_first_child (GTK_WIDGET (button)), inconsistent ? 0.0 : 1.0);
}
static void
find_language_and_script (FontFeatures *self,
hb_face_t *hb_face,
hb_tag_t *lang_tag,
hb_tag_t *script_tag)
{
int i, j, k;
hb_tag_t scripts[80];
unsigned int n_scripts;
unsigned int count;
hb_tag_t table[2] = { HB_OT_TAG_GSUB, HB_OT_TAG_GPOS };
hb_language_t lang;
const char *langname, *p;
langname = pango2_language_to_string (self->lang);
p = strchr (langname, '-');
lang = hb_language_from_string (langname, p ? p - langname : -1);
n_scripts = 0;
for (i = 0; i < 2; i++)
{
count = G_N_ELEMENTS (scripts);
hb_ot_layout_table_get_script_tags (hb_face, table[i], n_scripts, &count, scripts);
n_scripts += count;
}
for (j = 0; j < n_scripts; j++)
{
hb_tag_t languages[80];
unsigned int n_languages;
n_languages = 0;
for (i = 0; i < 2; i++)
{
count = G_N_ELEMENTS (languages);
hb_ot_layout_script_get_language_tags (hb_face, table[i], j, n_languages, &count, languages);
n_languages += count;
}
for (k = 0; k < n_languages; k++)
{
if (lang == hb_ot_tag_to_language (languages[k]))
{
*script_tag = scripts[j];
*lang_tag = languages[k];
return;
}
}
}
*lang_tag = HB_OT_TAG_DEFAULT_LANGUAGE;
*script_tag = HB_OT_TAG_DEFAULT_SCRIPT;
}
static void
hide_feature_maybe (FeatureItem *item,
gboolean has_feature)
{
gtk_widget_set_visible (item->feat, has_feature);
if (has_feature)
gtk_widget_set_visible (gtk_widget_get_parent (item->feat), TRUE);
}
/* Make features insensitive if the font/langsys does not have them,
* and reset all others to their initial value
*/
static void
update_features (FontFeatures *self)
{
guint script_index, lang_index;
hb_tag_t lang_tag;
hb_tag_t script_tag;
Pango2Font *font;
hb_font_t *hb_font;
hb_face_t *hb_face;
font = get_font (self);
hb_font = pango2_font_get_hb_font (font);
hb_face = hb_font_get_face (hb_font);
{
hb_tag_t table[2] = { HB_OT_TAG_GSUB, HB_OT_TAG_GPOS };
hb_tag_t features[256];
unsigned int count;
unsigned int n_features = 0;
find_language_and_script (self, hb_face, &lang_tag, &script_tag);
/* Collect all features */
for (int i = 0; i < 2; i++)
{
hb_ot_layout_table_find_script (hb_face,
table[i],
script_tag,
&script_index);
hb_ot_layout_script_select_language (hb_face,
table[i],
script_index,
1,
&lang_tag,
&lang_index);
count = G_N_ELEMENTS (features);
hb_ot_layout_language_get_feature_tags (hb_face,
table[i],
script_index,
lang_index,
n_features,
&count,
features);
n_features += count;
}
/* Update all the features */
for (GList *l = self->feature_items; l; l = l->next)
{
FeatureItem *item = l->data;
gboolean has_feature = FALSE;
for (int j = 0; j < n_features; j++)
{
if (item->tag == features[j])
{
has_feature = TRUE;
break;
}
}
update_feature_label (self, item, hb_font, script_tag, lang_tag);
hide_feature_maybe (item, has_feature);
if (GTK_IS_CHECK_BUTTON (item->feat))
{
GtkWidget *def = GTK_WIDGET (g_object_get_data (G_OBJECT (item->feat), "default"));
if (def)
{
gtk_widget_show (def);
gtk_widget_show (gtk_widget_get_parent (def));
gtk_check_button_set_active (GTK_CHECK_BUTTON (def), TRUE);
}
else
set_inconsistent (GTK_CHECK_BUTTON (item->feat), TRUE);
}
}
}
/* Hide empty groups */
for (GList *l = self->feature_items; l; l = l->next)
{
FeatureItem *item = l->data;
GtkWidget *box;
box = gtk_widget_get_parent (item->feat);
if (gtk_widget_get_visible (box))
{
GtkWidget *c;
int count;
count = 0;
for (c = gtk_widget_get_first_child (box); c; c = gtk_widget_get_next_sibling (c))
{
if (gtk_widget_get_visible (c))
count++;
}
if (count == 1)
gtk_widget_hide (box);
else if (count == 2 &&
item->tag == HB_TAG ('x', 'x', 'x', 'x'))
gtk_widget_hide (box);
}
}
}
static void
script_changed (GtkComboBox *combo,
FontFeatures *self)
{
update_features (self);
}
static char *
get_features (FontFeatures *self)
{
GString *s;
char buf[128];
s = g_string_new ("");
for (GList *l = self->feature_items; l; l = l->next)
{
FeatureItem *item = l->data;
if (!gtk_widget_is_sensitive (item->feat))
continue;
if (GTK_IS_CHECK_BUTTON (item->feat) && g_object_get_data (G_OBJECT (item->feat), "default"))
{
if (gtk_check_button_get_active (GTK_CHECK_BUTTON (item->feat)) &&
item->tag != HB_TAG ('x', 'x', 'x', 'x'))
{
hb_feature_to_string (&(hb_feature_t) { item->tag, 1, 0, -1 }, buf, sizeof (buf));
if (s->len > 0)
g_string_append_c (s, ',');
g_string_append (s, buf);
}
}
else if (GTK_IS_CHECK_BUTTON (item->feat))
{
guint32 value;
if (gtk_check_button_get_inconsistent (GTK_CHECK_BUTTON (item->feat)))
continue;
value = gtk_check_button_get_active (GTK_CHECK_BUTTON (item->feat));
hb_feature_to_string (&(hb_feature_t) { item->tag, value, 0, -1 }, buf, sizeof (buf));
if (s->len > 0)
g_string_append_c (s, ',');
g_string_append (s, buf);
}
}
return g_string_free (s, FALSE);
}
static void
update_display (FontFeatures *self)
{
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FEATURES]);
g_simple_action_set_enabled (self->reset_action, TRUE);
}
static GtkWidget *
make_title_label (const char *title)
{
GtkWidget *label;
label = gtk_label_new (title);
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_widget_set_halign (label, GTK_ALIGN_START);
g_object_set (label, "margin-top", 10, "margin-bottom", 10, NULL);
gtk_widget_add_css_class (label, "heading");
return label;
}
static void
feat_toggled_cb (GtkCheckButton *check_button,
gpointer data)
{
set_inconsistent (check_button, FALSE);
}
static void
feat_pressed (GtkGestureClick *gesture,
int n_press,
double x,
double y,
GtkWidget *feat)
{
const guint button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
if (button == GDK_BUTTON_PRIMARY)
{
g_signal_handlers_block_by_func (feat, feat_pressed, NULL);
if (gtk_check_button_get_inconsistent (GTK_CHECK_BUTTON (feat)))
{
set_inconsistent (GTK_CHECK_BUTTON (feat), FALSE);
gtk_check_button_set_active (GTK_CHECK_BUTTON (feat), TRUE);
}
g_signal_handlers_unblock_by_func (feat, feat_pressed, NULL);
}
else if (button == GDK_BUTTON_SECONDARY)
{
gboolean inconsistent = gtk_check_button_get_inconsistent (GTK_CHECK_BUTTON (feat));
set_inconsistent (GTK_CHECK_BUTTON (feat), !inconsistent);
}
}
static void
add_check_group (FontFeatures *self,
const char *title,
const char **tags,
unsigned int n_tags,
int row)
{
GtkWidget *group;
int i;
group = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_set_halign (group, GTK_ALIGN_START);
gtk_box_append (GTK_BOX (group), make_title_label (title));
for (i = 0; i < n_tags; i++)
{
unsigned int tag;
GtkWidget *feat;
FeatureItem *item;
GtkGesture *gesture;
char *name;
tag = hb_tag_from_string (tags[i], -1);
name = get_feature_display_name (tag);
feat = gtk_check_button_new_with_label (name);
g_free (name);
set_inconsistent (GTK_CHECK_BUTTON (feat), TRUE);
g_signal_connect_swapped (feat, "notify::active", G_CALLBACK (update_display), self);
g_signal_connect_swapped (feat, "notify::inconsistent", G_CALLBACK (update_display), self);
g_signal_connect (feat, "toggled", G_CALLBACK (feat_toggled_cb), NULL);
gesture = gtk_gesture_click_new ();
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), GDK_BUTTON_SECONDARY);
g_signal_connect (gesture, "pressed", G_CALLBACK (feat_pressed), feat);
gtk_widget_add_controller (feat, GTK_EVENT_CONTROLLER (gesture));
gtk_box_append (GTK_BOX (group), feat);
item = g_new (FeatureItem, 1);
item->name = tags[i];
item->tag = tag;
item->feat = feat;
self->feature_items = g_list_prepend (self->feature_items, item);
}
gtk_grid_attach (self->grid, group, 0, row, 2, 1);
}
static void
add_radio_group (FontFeatures *self,
const char *title,
const char **tags,
unsigned int n_tags,
int row)
{
GtkWidget *group;
int i;
GtkWidget *group_button = NULL;
group = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_set_halign (group, GTK_ALIGN_START);
gtk_box_append (GTK_BOX (group), make_title_label (title));
for (i = 0; i < n_tags; i++)
{
unsigned int tag;
GtkWidget *feat;
FeatureItem *item;
char *name;
tag = hb_tag_from_string (tags[i], -1);
name = get_feature_display_name (tag);
feat = gtk_check_button_new_with_label (name ? name : _("Default"));
g_free (name);
if (group_button == NULL)
group_button = feat;
else
gtk_check_button_set_group (GTK_CHECK_BUTTON (feat), GTK_CHECK_BUTTON (group_button));
g_signal_connect_swapped (feat, "notify::active", G_CALLBACK (update_display), self);
g_object_set_data (G_OBJECT (feat), "default", group_button);
gtk_box_append (GTK_BOX (group), feat);
item = g_new (FeatureItem, 1);
item->name = tags[i];
item->tag = tag;
item->feat = feat;
self->feature_items = g_list_prepend (self->feature_items, item);
}
gtk_grid_attach (self->grid, group, 0, row, 2, 1);
}
static void
setup_features (FontFeatures *self)
{
const char *kerning[] = { "kern" };
const char *ligatures[] = { "liga", "dlig", "hlig", "clig", "rlig" };
const char *letter_case[] = {
"smcp", "c2sc", "pcap", "c2pc", "unic", "cpsp", "case"
};
const char *number_case[] = { "xxxx", "lnum", "onum" };
const char *number_spacing[] = { "xxxx", "pnum", "tnum" };
const char *fractions[] = { "xxxx", "frac", "afrc" };
const char *num_extras[] = { "zero", "nalt", "sinf" };
const char *char_alt[] = {
"swsh", "cswh", "locl", "calt", "falt", "hist",
"salt", "jalt", "titl", "rand", "subs", "sups",
"ordn", "ltra", "ltrm", "rtla", "rtlm", "rclt"
};
const char *pos_alt[] = {
"init", "medi", "med2", "fina", "fin2", "fin3", "isol"
};
const char *width_var[] = {
"fwid", "hwid", "halt", "pwid", "palt", "twid", "qwid"
};
const char *style_alt[] = {
"ss01", "ss02", "ss03", "ss04", "ss05", "ss06",
"ss07", "ss08", "ss09", "ss10", "ss11", "ss12",
"ss13", "ss14", "ss15", "ss16", "ss17", "ss18",
"ss19", "ss20"
};
const char *char_var[] = {
"cv01", "cv02", "cv03", "cv04", "cv05", "cv06",
"cv07", "cv08", "cv09", "cv10", "cv11", "cv12",
"cv13", "cv14", "cv15", "cv16", "cv17", "cv18",
"cv19", "cv20"
};
const char *math[] = { "dtls", "flac", "mgrk", "ssty" };
const char *bounds[] = { "opbd", "lfbd", "rtbd" };
int row = 0;
add_check_group (self, _("Kerning"), kerning, G_N_ELEMENTS (kerning), row++);
add_check_group (self, _("Ligatures"), ligatures, G_N_ELEMENTS (ligatures), row++);
add_check_group (self, _("Letter Case"), letter_case, G_N_ELEMENTS (letter_case), row++);
add_radio_group (self, _("Number Case"), number_case, G_N_ELEMENTS (number_case), row++);
add_radio_group (self, _("Number Spacing"), number_spacing, G_N_ELEMENTS (number_spacing), row++);
add_radio_group (self, _("Fractions"), fractions, G_N_ELEMENTS (fractions), row++);
add_check_group (self, _("Numeric Extras"), num_extras, G_N_ELEMENTS (num_extras), row++);
add_check_group (self, _("Character Alternatives"), char_alt, G_N_ELEMENTS (char_alt), row++);
add_check_group (self, _("Positional Alternatives"), pos_alt, G_N_ELEMENTS (pos_alt), row++);
add_check_group (self, _("Width Variants"), width_var, G_N_ELEMENTS (width_var), row++);
add_check_group (self, _("Alternative Stylistic Sets"), style_alt, G_N_ELEMENTS (style_alt), row++);
add_check_group (self, _("Character Variants"), char_var, G_N_ELEMENTS (char_var), row++);
add_check_group (self, _("Mathematical"), math, G_N_ELEMENTS (math), row++);
add_check_group (self, _("Optical Bounds"), bounds, G_N_ELEMENTS (bounds), row++);
self->feature_items = g_list_reverse (self->feature_items);
}
static void
reset (GSimpleAction *action,
GVariant *parameter,
FontFeatures *self)
{
update_features (self);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FEATURES]);
g_simple_action_set_enabled (self->reset_action, FALSE);
}
static void
font_features_init (FontFeatures *self)
{
self->font_map = g_object_ref (pango2_font_map_get_default ());
gtk_widget_init_template (GTK_WIDGET (self));
self->font_desc = pango2_font_description_from_string ("sans 12");
self->lang = pango2_language_get_default ();
setup_features (self);
self->reset_action = g_simple_action_new ("reset", NULL);
g_simple_action_set_enabled (self->reset_action, FALSE);
g_signal_connect (self->reset_action, "activate", G_CALLBACK (reset), self);
}
static void
font_features_dispose (GObject *object)
{
FontFeatures *self = FONT_FEATURES (object);
gtk_widget_clear_template (GTK_WIDGET (object), FONT_FEATURES_TYPE);
g_list_free_full (self->feature_items, g_free);
G_OBJECT_CLASS (font_features_parent_class)->dispose (object);
}
static void
font_features_finalize (GObject *object)
{
FontFeatures *self = FONT_FEATURES (object);
g_clear_pointer (&self->font_desc, pango2_font_description_free);
g_clear_object (&self->font_map);
G_OBJECT_CLASS (font_features_parent_class)->finalize (object);
}
static void
font_features_set_property (GObject *object,
unsigned int prop_id,
const GValue *value,
GParamSpec *pspec)
{
FontFeatures *self = FONT_FEATURES (object);
switch (prop_id)
{
case PROP_FONT_MAP:
g_set_object (&self->font_map, g_value_get_object (value));
break;
case PROP_FONT_DESC:
pango2_font_description_free (self->font_desc);
self->font_desc = pango2_font_description_copy (g_value_get_boxed (value));
break;
case PROP_LANGUAGE:
self->lang = pango2_language_from_string (g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
update_features (self);
}
static void
font_features_get_property (GObject *object,
unsigned int prop_id,
GValue *value,
GParamSpec *pspec)
{
FontFeatures *self = FONT_FEATURES (object);
switch (prop_id)
{
case PROP_FONT_MAP:
g_value_set_object (value, self->font_map);
break;
case PROP_FEATURES:
g_value_take_string (value, get_features (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
font_features_class_init (FontFeaturesClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->dispose = font_features_dispose;
object_class->finalize = font_features_finalize;
object_class->get_property = font_features_get_property;
object_class->set_property = font_features_set_property;
properties[PROP_FONT_MAP] =
g_param_spec_object ("font-map", "", "",
PANGO2_TYPE_FONT_MAP,
G_PARAM_READWRITE);
properties[PROP_FONT_DESC] =
g_param_spec_boxed ("font-desc", "", "",
PANGO2_TYPE_FONT_DESCRIPTION,
G_PARAM_WRITABLE);
properties[PROP_LANGUAGE] =
g_param_spec_string ("language", "", "",
"en",
G_PARAM_WRITABLE);
properties[PROP_FEATURES] =
g_param_spec_string ("features", "", "",
"",
G_PARAM_READABLE);
g_object_class_install_properties (G_OBJECT_CLASS (class), NUM_PROPERTIES, properties);
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/fontexplorer/fontfeatures.ui");
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontFeatures, grid);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontFeatures, label);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), script_changed);
gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (class), "fontfeatures");
}
GAction *
font_features_get_reset_action (FontFeatures *self)
{
return G_ACTION (self->reset_action);
}

View File

@@ -1,15 +0,0 @@
#pragma once
#include <gtk/gtk.h>
#define FONT_FEATURES_TYPE (font_features_get_type ())
#define FONT_FEATURES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FONT_FEATURES_TYPE, FontFeatures))
typedef struct _FontFeatures FontFeatures;
typedef struct _FontFeaturesClass FontFeaturesClass;
GType font_features_get_type (void);
GAction * font_features_get_reset_action (FontFeatures *self);

View File

@@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="FontFeatures" parent="GtkWidget">
<property name="layout-manager"><object class="GtkBinLayout"/></property>
<child>
<object class="GtkGrid" id="grid">
<child>
<object class="GtkLabel" id="label">
<property name="label" translatable="yes">Features</property>
<property name="margin-bottom">10</property>
<property name="xalign">0</property>
<style>
<class name="heading"/>
</style>
<layout>
<property name="row">-1</property>
<property name="column">0</property>
<property name="column-span">2</property>
</layout>
</object>
</child>
</object>
</child>
</template>
</interface>

View File

@@ -1,508 +0,0 @@
#include "fontvariations.h"
#include <gtk/gtk.h>
#include <hb-ot.h>
#include "rangeedit.h"
enum {
PROP_FONT_MAP = 1,
PROP_FONT_DESC,
PROP_VARIATIONS,
NUM_PROPERTIES
};
static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
struct _FontVariations
{
GtkWidget parent;
GtkGrid *label;
GtkGrid *grid;
Pango2FontDescription *font_desc;
GSimpleAction *reset_action;
gboolean has_variations;
GtkWidget *instance_combo;
GHashTable *axes;
GHashTable *instances;
Pango2FontMap *font_map;
};
struct _FontVariationsClass
{
GtkWidgetClass parent_class;
};
G_DEFINE_TYPE(FontVariations, font_variations, GTK_TYPE_WIDGET);
static Pango2Font *
get_font (FontVariations *self)
{
Pango2Context *context;
Pango2Font *font;
context = pango2_context_new_with_font_map (self->font_map);
font = pango2_context_load_font (context, self->font_desc);
g_object_unref (context);
return font;
}
typedef struct {
guint32 tag;
GtkAdjustment *adjustment;
double default_value;
} Axis;
static guint
axes_hash (gconstpointer v)
{
const Axis *p = v;
return p->tag;
}
static gboolean
axes_equal (gconstpointer v1, gconstpointer v2)
{
const Axis *p1 = v1;
const Axis *p2 = v2;
return p1->tag == p2->tag;
}
static void
unset_instance (GtkAdjustment *adjustment,
FontVariations *self)
{
if (self->instance_combo)
gtk_combo_box_set_active (GTK_COMBO_BOX (self->instance_combo), 0);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_VARIATIONS]);
g_simple_action_set_enabled (self->reset_action, TRUE);
}
static void
add_axis (FontVariations *self,
hb_face_t *hb_face,
hb_ot_var_axis_info_t *ax,
int i)
{
GtkWidget *axis_label;
GtkWidget *axis_scale;
GtkAdjustment *adjustment;
Axis *axis;
char name[20];
unsigned int name_len = 20;
hb_ot_name_get_utf8 (hb_face, ax->name_id, HB_LANGUAGE_INVALID, &name_len, name);
axis_label = gtk_label_new (name);
gtk_widget_set_halign (axis_label, GTK_ALIGN_START);
gtk_widget_set_valign (axis_label, GTK_ALIGN_BASELINE);
gtk_grid_attach (self->grid, axis_label, 0, i, 1, 1);
adjustment = gtk_adjustment_new (ax->default_value, ax->min_value, ax->max_value,
1.0, 10.0, 0.0);
axis_scale = g_object_new (RANGE_EDIT_TYPE,
"adjustment", adjustment,
"default-value", ax->default_value,
"n-chars", 5,
"hexpand", TRUE,
"halign", GTK_ALIGN_FILL,
"valign", GTK_ALIGN_BASELINE,
NULL);
gtk_grid_attach (self->grid, axis_scale, 1, i, 1, 1);
axis = g_new0 (Axis, 1);
axis->tag = ax->tag;
axis->adjustment = adjustment;
axis->default_value = ax->default_value;
g_hash_table_add (self->axes, axis);
g_signal_connect (adjustment, "value-changed", G_CALLBACK (unset_instance), self);
}
typedef struct {
char *name;
unsigned int index;
} Instance;
static guint
instance_hash (gconstpointer v)
{
const Instance *p = v;
return g_str_hash (p->name);
}
static gboolean
instance_equal (gconstpointer v1, gconstpointer v2)
{
const Instance *p1 = v1;
const Instance *p2 = v2;
return g_str_equal (p1->name, p2->name);
}
static void
free_instance (gpointer data)
{
Instance *instance = data;
g_free (instance->name);
g_free (instance);
}
static void
add_instance (FontVariations *self,
hb_face_t *face,
unsigned int index,
GtkWidget *combo,
int pos)
{
Instance *instance;
hb_ot_name_id_t name_id;
char name[20];
unsigned int name_len = 20;
instance = g_new0 (Instance, 1);
name_id = hb_ot_var_named_instance_get_subfamily_name_id (face, index);
hb_ot_name_get_utf8 (face, name_id, HB_LANGUAGE_INVALID, &name_len, name);
instance->name = g_strdup (name);
instance->index = index;
g_hash_table_add (self->instances, instance);
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), instance->name);
}
static void
instance_changed (GtkComboBox *combo,
FontVariations *self)
{
char *text;
Instance *instance;
Instance ikey;
int i;
unsigned int coords_length;
float *coords = NULL;
hb_ot_var_axis_info_t *ai = NULL;
unsigned int n_axes;
Pango2Font *font = NULL;
hb_font_t *hb_font;
hb_face_t *hb_face;
text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (combo));
if (text[0] == '\0')
goto out;
ikey.name = text;
instance = g_hash_table_lookup (self->instances, &ikey);
if (!instance)
{
g_print ("did not find instance %s\n", text);
goto out;
}
font = get_font (self);
hb_font = pango2_font_get_hb_font (font);
hb_face = hb_font_get_face (hb_font);
n_axes = hb_ot_var_get_axis_infos (hb_face, 0, NULL, NULL);
ai = g_new (hb_ot_var_axis_info_t, n_axes);
hb_ot_var_get_axis_infos (hb_face, 0, &n_axes, ai);
coords = g_new (float, n_axes);
hb_ot_var_named_instance_get_design_coords (hb_face,
instance->index,
&coords_length,
coords);
for (i = 0; i < n_axes; i++)
{
Axis *axis;
Axis akey;
double value;
value = coords[ai[i].axis_index];
akey.tag = ai[i].tag;
axis = g_hash_table_lookup (self->axes, &akey);
if (axis)
{
g_signal_handlers_block_by_func (axis->adjustment, unset_instance, self);
gtk_adjustment_set_value (axis->adjustment, value);
g_signal_handlers_unblock_by_func (axis->adjustment, unset_instance, self);
}
}
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_VARIATIONS]);
g_simple_action_set_enabled (self->reset_action, TRUE);
out:
g_free (text);
g_clear_object (&font);
g_free (ai);
g_free (coords);
}
static void
update_variations (FontVariations *self)
{
GtkWidget *child;
Pango2Font *font;
hb_font_t *hb_font;
hb_face_t *hb_face;
unsigned int n_axes;
hb_ot_var_axis_info_t *ai = NULL;
int i;
font = get_font (self);
hb_font = pango2_font_get_hb_font (font);
hb_face = hb_font_get_face (hb_font);
g_object_ref (self->label);
while ((child = gtk_widget_get_first_child (GTK_WIDGET (self->grid))))
gtk_grid_remove (self->grid, child);
gtk_grid_attach (self->grid, GTK_WIDGET (self->label), 0, -2, 2, 1);
g_object_unref (self->label);
self->instance_combo = NULL;
g_hash_table_remove_all (self->axes);
g_hash_table_remove_all (self->instances);
n_axes = hb_ot_var_get_axis_infos (hb_face, 0, NULL, NULL);
self->has_variations = n_axes > 0;
gtk_widget_set_visible (GTK_WIDGET (self), self->has_variations);
if (!self->has_variations)
{
g_simple_action_set_enabled (self->reset_action, FALSE);
return;
}
if (hb_ot_var_get_named_instance_count (hb_face) > 0)
{
GtkWidget *label;
GtkWidget *combo;
label = gtk_label_new ("Instance");
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_widget_set_halign (label, GTK_ALIGN_START);
gtk_widget_set_valign (label, GTK_ALIGN_BASELINE);
gtk_grid_attach (self->grid, label, 0, -1, 1, 1);
combo = gtk_combo_box_text_new ();
gtk_widget_set_halign (combo, GTK_ALIGN_START);
gtk_widget_set_valign (combo, GTK_ALIGN_BASELINE);
gtk_widget_set_hexpand (combo, TRUE);
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "");
for (i = 0; i < hb_ot_var_get_named_instance_count (hb_face); i++)
add_instance (self, hb_face, i, combo, i);
gtk_grid_attach (GTK_GRID (self->grid), combo, 1, -1, 1, 1);
g_signal_connect (combo, "changed", G_CALLBACK (instance_changed), self);
self->instance_combo = combo;
}
ai = g_new (hb_ot_var_axis_info_t, n_axes);
hb_ot_var_get_axis_infos (hb_face, 0, &n_axes, ai);
for (i = 0; i < n_axes; i++)
add_axis (self, hb_face, &ai[i], i);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_VARIATIONS]);
g_clear_object (&font);
g_free (ai);
}
static char *
get_variations (FontVariations *self)
{
GHashTableIter iter;
Axis *axis;
char buf[G_ASCII_DTOSTR_BUF_SIZE];
const char *sep = "";
GString *s;
if (!self->has_variations)
return g_strdup ("");
s = g_string_new ("");
g_hash_table_iter_init (&iter, self->axes);
while (g_hash_table_iter_next (&iter, (gpointer *)NULL, (gpointer *)&axis))
{
char tag[5];
double value;
hb_tag_to_string (axis->tag, tag);
tag[4] = '\0';
value = gtk_adjustment_get_value (axis->adjustment);
g_string_append_printf (s, "%s%s=%s", sep, tag, g_ascii_dtostr (buf, sizeof (buf), value));
sep = ",";
}
return g_string_free (s, FALSE);
}
static void
reset (GSimpleAction *action,
GVariant *parameter,
FontVariations *self)
{
GHashTableIter iter;
Axis *axis;
if (self->instance_combo)
gtk_combo_box_set_active (GTK_COMBO_BOX (self->instance_combo), 0);
g_hash_table_iter_init (&iter, self->axes);
while (g_hash_table_iter_next (&iter, (gpointer *)NULL, (gpointer *)&axis))
{
g_signal_handlers_block_by_func (axis->adjustment, unset_instance, self);
gtk_adjustment_set_value (axis->adjustment, axis->default_value);
g_signal_handlers_unblock_by_func (axis->adjustment, unset_instance, self);
}
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_VARIATIONS]);
g_simple_action_set_enabled (self->reset_action, FALSE);
}
static void
font_variations_init (FontVariations *self)
{
self->font_map = g_object_ref (pango2_font_map_get_default ());
gtk_widget_init_template (GTK_WIDGET (self));
self->reset_action = g_simple_action_new ("reset", NULL);
g_simple_action_set_enabled (self->reset_action, FALSE);
g_signal_connect (self->reset_action, "activate", G_CALLBACK (reset), self);
self->instances = g_hash_table_new_full (instance_hash, instance_equal,
NULL, free_instance);
self->axes = g_hash_table_new_full (axes_hash, axes_equal,
NULL, g_free);
}
static void
font_variations_dispose (GObject *object)
{
FontVariations *self = FONT_VARIATIONS (object);
gtk_widget_clear_template (GTK_WIDGET (object), FONT_VARIATIONS_TYPE);
g_hash_table_unref (self->instances);
g_hash_table_unref (self->axes);
G_OBJECT_CLASS (font_variations_parent_class)->dispose (object);
}
static void
font_variations_finalize (GObject *object)
{
FontVariations *self = FONT_VARIATIONS (object);
g_clear_pointer (&self->font_desc, pango2_font_description_free);
g_clear_object (&self->font_map);
G_OBJECT_CLASS (font_variations_parent_class)->finalize (object);
}
static void
font_variations_set_property (GObject *object,
unsigned int prop_id,
const GValue *value,
GParamSpec *pspec)
{
FontVariations *self = FONT_VARIATIONS (object);
switch (prop_id)
{
case PROP_FONT_MAP:
g_set_object (&self->font_map, g_value_get_object (value));
break;
case PROP_FONT_DESC:
pango2_font_description_free (self->font_desc);
self->font_desc = pango2_font_description_copy (g_value_get_boxed (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
update_variations (self);
}
static void
font_variations_get_property (GObject *object,
unsigned int prop_id,
GValue *value,
GParamSpec *pspec)
{
FontVariations *self = FONT_VARIATIONS (object);
switch (prop_id)
{
case PROP_FONT_MAP:
g_value_set_object (value, self->font_map);
break;
case PROP_VARIATIONS:
g_value_take_string (value, get_variations (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
font_variations_class_init (FontVariationsClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->dispose = font_variations_dispose;
object_class->finalize = font_variations_finalize;
object_class->get_property = font_variations_get_property;
object_class->set_property = font_variations_set_property;
properties[PROP_FONT_MAP] =
g_param_spec_object ("font-map", "", "",
PANGO2_TYPE_FONT_MAP,
G_PARAM_READWRITE);
properties[PROP_FONT_DESC] =
g_param_spec_boxed ("font-desc", "", "",
PANGO2_TYPE_FONT_DESCRIPTION,
G_PARAM_WRITABLE);
properties[PROP_VARIATIONS] =
g_param_spec_string ("variations", "", "",
"",
G_PARAM_READABLE);
g_object_class_install_properties (G_OBJECT_CLASS (class), NUM_PROPERTIES, properties);
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/fontexplorer/fontvariations.ui");
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontVariations, grid);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), FontVariations, label);
gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (class), "fontvariations");
}
GAction *
font_variations_get_reset_action (FontVariations *self)
{
return G_ACTION (self->reset_action);
}

View File

@@ -1,15 +0,0 @@
#pragma once
#include <gtk/gtk.h>
#define FONT_VARIATIONS_TYPE (font_variations_get_type ())
#define FONT_VARIATIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FONT_VARIATIONS_TYPE, FontVariations))
typedef struct _FontVariations FontVariations;
typedef struct _FontVariationsClass FontVariationsClass;
GType font_variations_get_type (void);
GAction * font_variations_get_reset_action (FontVariations *self);

View File

@@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="FontVariations" parent="GtkWidget">
<property name="layout-manager"><object class="GtkBinLayout"/></property>
<child>
<object class="GtkGrid" id="grid">
<child>
<object class="GtkLabel" id="label">
<property name="label" translatable="yes">Variations</property>
<property name="margin-bottom">10</property>
<property name="xalign">0</property>
<style>
<class name="heading"/>
</style>
<layout>
<property name="row">-2</property>
<property name="column">0</property>
<property name="column-span">2</property>
</layout>
</object>
</child>
</object>
</child>
</template>
</interface>

View File

@@ -1,56 +0,0 @@
#include "glyphitem.h"
struct _GlyphItem {
GObject parent;
Pango2Font *font;
hb_codepoint_t glyph;
};
struct _GlyphItemClass {
GObjectClass parent_class;
};
G_DEFINE_TYPE (GlyphItem, glyph_item, G_TYPE_OBJECT)
static void
glyph_item_init (GlyphItem *self)
{
}
static void
glyph_item_finalize (GObject *object)
{
GlyphItem *item = GLYPH_ITEM (object);
g_object_unref (item->font);
G_OBJECT_CLASS (glyph_item_parent_class)->finalize (object);
}
static void
glyph_item_class_init (GlyphItemClass *class)
{
G_OBJECT_CLASS (class)->finalize = glyph_item_finalize;
}
GlyphItem *
glyph_item_new (Pango2Font *font,
hb_codepoint_t glyph)
{
GlyphItem *item = g_object_new (GLYPH_ITEM_TYPE, NULL);
item->font = g_object_ref (font);
item->glyph = glyph;
return item;
}
Pango2Font *
glyph_item_get_font (GlyphItem *item)
{
return item->font;
}
hb_codepoint_t
glyph_item_get_glyph (GlyphItem *item)
{
return item->glyph;
}

View File

@@ -1,17 +0,0 @@
#pragma once
#include <gtk/gtk.h>
#define GLYPH_ITEM_TYPE (glyph_item_get_type ())
#define GLYPH_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLYPH_ITEM_TYPE, GlyphItem))
typedef struct _GlyphItem GlyphItem;
typedef struct _GlyphItemClass GlyphItemClass;
GType glyph_item_get_type (void);
GlyphItem * glyph_item_new (Pango2Font *font,
hb_codepoint_t glyph);
hb_codepoint_t glyph_item_get_glyph (GlyphItem *item);
Pango2Font * glyph_item_get_font (GlyphItem *item);

View File

@@ -1,97 +0,0 @@
#include "glyphmodel.h"
#include "glyphitem.h"
struct _GlyphModel {
GObject parent;
Pango2Font *font;
unsigned int num_glyphs;
GlyphItem **glyphs;
};
struct _GlyphModelClass {
GObjectClass parent_class;
};
static GType
glyph_model_get_item_type (GListModel *model)
{
return GLYPH_ITEM_TYPE;
}
static guint
glyph_model_get_n_items (GListModel *model)
{
GlyphModel *self = GLYPH_MODEL (model);
return self->num_glyphs;
}
static gpointer
glyph_model_get_item (GListModel *model,
guint position)
{
GlyphModel *self = GLYPH_MODEL (model);
if (position >= self->num_glyphs)
return NULL;
if (self->glyphs[position] == NULL)
self->glyphs[position] = glyph_item_new (self->font, position);
return g_object_ref (self->glyphs[position]);
}
static void
glyph_model_list_model_init (GListModelInterface *iface)
{
iface->get_item_type = glyph_model_get_item_type;
iface->get_n_items = glyph_model_get_n_items;
iface->get_item = glyph_model_get_item;
}
G_DEFINE_TYPE_WITH_CODE (GlyphModel, glyph_model, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, glyph_model_list_model_init))
static void
glyph_model_init (GlyphModel *self)
{
}
static void
glyph_model_finalize (GObject *object)
{
GlyphModel *self = GLYPH_MODEL (object);
g_object_unref (self->font);
for (int i = 0; i < self->num_glyphs; i++)
{
if (self->glyphs[i])
g_object_unref (self->glyphs[i]);
}
g_free (self->glyphs);
G_OBJECT_CLASS (glyph_model_parent_class)->finalize (object);
}
static void
glyph_model_class_init (GlyphModelClass *class)
{
G_OBJECT_CLASS (class)->finalize = glyph_model_finalize;
}
GlyphModel *
glyph_model_new (Pango2Font *font)
{
GlyphModel *self;
hb_face_t *hb_face;
self = g_object_new (GLYPH_MODEL_TYPE, NULL);
self->font = g_object_ref (font);
hb_face = pango2_hb_face_get_hb_face (PANGO2_HB_FACE (pango2_font_get_face (font)));
self->num_glyphs = hb_face_get_glyph_count (hb_face);
self->glyphs = g_new0 (GlyphItem *, self->num_glyphs);
return self;
}

View File

@@ -1,14 +0,0 @@
#pragma once
#include <gtk/gtk.h>
#define GLYPH_MODEL_TYPE (glyph_model_get_type ())
#define GLYPH_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLYPH_MODEL_TYPE, GlyphModel))
typedef struct _GlyphModel GlyphModel;
typedef struct _GlyphModelClass GlyphModelClass;
GType glyph_model_get_type (void);
GlyphModel * glyph_model_new (Pango2Font *font);

View File

@@ -1,239 +0,0 @@
#include "glyphsview.h"
#include <gtk/gtk.h>
#include <hb-ot.h>
#include "glyphitem.h"
#include "glyphmodel.h"
#include "glyphview.h"
enum {
PROP_FONT_MAP = 1,
PROP_FONT_DESC,
PROP_VARIATIONS,
PROP_PALETTE,
NUM_PROPERTIES
};
static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
struct _GlyphsView
{
GtkWidget parent;
Pango2FontMap *font_map;
GtkGridView *glyphs;
Pango2FontDescription *font_desc;
char *variations;
char *palette;
GQuark palette_quark;
};
struct _GlyphsViewClass
{
GtkWidgetClass parent_class;
};
G_DEFINE_TYPE(GlyphsView, glyphs_view, GTK_TYPE_WIDGET);
static void
glyphs_view_init (GlyphsView *self)
{
self->font_map = g_object_ref (pango2_font_map_get_default ());
self->font_desc = pango2_font_description_from_string ("sans 12");
self->variations = g_strdup ("");
self->palette = g_strdup (PANGO2_COLOR_PALETTE_DEFAULT);
self->palette_quark = g_quark_from_string (self->palette);
gtk_widget_set_layout_manager (GTK_WIDGET (self),
gtk_box_layout_new (GTK_ORIENTATION_VERTICAL));
gtk_widget_init_template (GTK_WIDGET (self));
}
static void
glyphs_view_dispose (GObject *object)
{
gtk_widget_clear_template (GTK_WIDGET (object), GLYPHS_VIEW_TYPE);
G_OBJECT_CLASS (glyphs_view_parent_class)->dispose (object);
}
static void
glyphs_view_finalize (GObject *object)
{
GlyphsView *self = GLYPHS_VIEW (object);
g_clear_object (&self->font_map);
pango2_font_description_free (self->font_desc);
g_free (self->variations);
g_free (self->palette);
G_OBJECT_CLASS (glyphs_view_parent_class)->finalize (object);
}
static Pango2Font *
get_font (GlyphsView *self,
int size)
{
Pango2Context *context;
Pango2FontDescription *desc;
Pango2Font *font;
context = pango2_context_new_with_font_map (self->font_map);
desc = pango2_font_description_copy_static (self->font_desc);
pango2_font_description_set_variations (desc, self->variations);
pango2_font_description_set_size (desc, size);
font = pango2_context_load_font (context, desc);
pango2_font_description_free (desc);
g_object_unref (context);
return font;
}
static void
update_glyph_model (GlyphsView *self)
{
Pango2Font *font = get_font (self, 60 * PANGO2_SCALE);
GlyphModel *gm;
GtkSelectionModel *model;
gm = glyph_model_new (font);
model = GTK_SELECTION_MODEL (gtk_no_selection_new (G_LIST_MODEL (gm)));
gtk_grid_view_set_model (self->glyphs, model);
g_object_unref (model);
g_object_unref (font);
}
static void
setup_glyph (GtkSignalListItemFactory *factory,
GObject *listitem)
{
gtk_list_item_set_child (GTK_LIST_ITEM (listitem), GTK_WIDGET (glyph_view_new ()));
}
static void
bind_glyph (GtkSignalListItemFactory *factory,
GObject *listitem,
GlyphsView *self)
{
GlyphView *view;
GObject *item;
view = GLYPH_VIEW (gtk_list_item_get_child (GTK_LIST_ITEM (listitem)));
item = gtk_list_item_get_item (GTK_LIST_ITEM (listitem));
glyph_view_set_font (view, glyph_item_get_font (GLYPH_ITEM (item)));
glyph_view_set_glyph (view, glyph_item_get_glyph (GLYPH_ITEM (item)));
glyph_view_set_palette (view, self->palette_quark);
}
static void
glyphs_view_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GlyphsView *self = GLYPHS_VIEW (object);
switch (prop_id)
{
case PROP_FONT_MAP:
g_set_object (&self->font_map, g_value_get_object (value));
break;
case PROP_FONT_DESC:
pango2_font_description_free (self->font_desc);
self->font_desc = pango2_font_description_copy (g_value_get_boxed (value));
break;
case PROP_VARIATIONS:
g_free (self->variations);
self->variations = g_strdup (g_value_get_string (value));
break;
case PROP_PALETTE:
g_free (self->palette);
self->palette = g_strdup (g_value_get_string (value));
self->palette_quark = g_quark_from_string (self->palette);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
update_glyph_model (self);
}
static void
glyphs_view_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GlyphsView *self = GLYPHS_VIEW (object);
switch (prop_id)
{
case PROP_FONT_MAP:
g_value_set_object (value, self->font_map);
break;
case PROP_FONT_DESC:
g_value_set_boxed (value, self->font_desc);
break;
case PROP_VARIATIONS:
g_value_set_string (value, self->variations);
break;
case PROP_PALETTE:
g_value_set_string (value, self->palette);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
glyphs_view_class_init (GlyphsViewClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->dispose = glyphs_view_dispose;
object_class->finalize = glyphs_view_finalize;
object_class->get_property = glyphs_view_get_property;
object_class->set_property = glyphs_view_set_property;
properties[PROP_FONT_MAP] =
g_param_spec_object ("font-map", "", "",
PANGO2_TYPE_FONT_MAP,
G_PARAM_READWRITE);
properties[PROP_FONT_DESC] =
g_param_spec_boxed ("font-desc", "", "",
PANGO2_TYPE_FONT_DESCRIPTION,
G_PARAM_READWRITE);
properties[PROP_VARIATIONS] =
g_param_spec_string ("variations", "", "",
"",
G_PARAM_READWRITE);
properties[PROP_PALETTE] =
g_param_spec_string ("palette", "", "",
PANGO2_COLOR_PALETTE_DEFAULT,
G_PARAM_READWRITE);
g_object_class_install_properties (G_OBJECT_CLASS (class), NUM_PROPERTIES, properties);
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/fontexplorer/glyphsview.ui");
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), GlyphsView, glyphs);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), setup_glyph);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), bind_glyph);
gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (class), "glyphsview");
}

View File

@@ -1,14 +0,0 @@
#pragma once
#include <gtk/gtk.h>
#define GLYPHS_VIEW_TYPE (glyphs_view_get_type ())
#define GLYPHS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLYPHS_VIEW_TYPE, GlyphsView))
typedef struct _GlyphsView GlyphsView;
typedef struct _GlyphsViewClass GlyphsViewClass;
GType glyphs_view_get_type (void);

View File

@@ -1,29 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GlyphsView" parent="GtkWidget">
<style>
<class name="view"/>
</style>
<child>
<object class="GtkScrolledWindow">
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<property name="hscrollbar-policy">never</property>
<property name="vscrollbar-policy">automatic</property>
<child>
<object class="GtkGridView" id="glyphs">
<style>
<class name="content"/>
</style>
<property name="factory">
<object class="GtkSignalListItemFactory">
<signal name="setup" handler="setup_glyph"/>
<signal name="bind" handler="bind_glyph"/>
</object>
</property>
</object>
</child>
</object>
</child>
</template>
</interface>

View File

@@ -1,321 +0,0 @@
#include "glyphview.h"
#include <gtk/gtk.h>
#include <hb-ot.h>
struct _GlyphView
{
GtkWidget parent;
Pango2Font *font;
GQuark palette;
int palette_index;
hb_codepoint_t glyph;
int n_layers;
int layer;
};
struct _GlyphViewClass
{
GtkWidgetClass parent_class;
};
G_DEFINE_TYPE(GlyphView, glyph_view, GTK_TYPE_WIDGET);
static void
click_cb (GtkGestureClick *gesture,
int n_press,
double x,
double y,
GlyphView *self)
{
if (self->n_layers == 0)
return;
self->layer++;
if (self->layer == self->n_layers)
self->layer = -1;
gtk_widget_queue_draw (GTK_WIDGET (self));
}
static void
glyph_view_init (GlyphView *self)
{
GtkGesture *click;
self->n_layers = 0;
self->layer = -1;
click = gtk_gesture_click_new ();
g_signal_connect (click, "pressed", G_CALLBACK (click_cb), self);
gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (click));
}
static void
glyph_view_dispose (GObject *object)
{
GlyphView *self = GLYPH_VIEW (object);
g_clear_object (&self->font);
G_OBJECT_CLASS (glyph_view_parent_class)->dispose (object);
}
static void
glyph_view_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
{
GlyphView *self = GLYPH_VIEW (widget);
Pango2GlyphString *glyphs;
Pango2Rectangle ink, logical;
cairo_t *cr;
int width, height;
char name[80];
pango2_font_get_glyph_extents (self->font, self->glyph, &ink, &logical);
width = gtk_widget_get_width (widget);
height = gtk_widget_get_height (widget);
cr = gtk_snapshot_append_cairo (snapshot, &GRAPHENE_RECT_INIT (0, 0, width, height));
glyphs = pango2_glyph_string_new ();
pango2_glyph_string_set_size (glyphs, 1);
glyphs->glyphs[0].geometry.width = ink.width;
glyphs->glyphs[0].geometry.x_offset = ink.x;
glyphs->glyphs[0].geometry.y_offset = -ink.y;
if (self->layer == -1)
{
glyphs->glyphs[0].glyph = self->glyph;
cairo_set_source_rgb (cr, 0, 0, 0);
}
else
{
hb_face_t *face = hb_font_get_face (pango2_font_get_hb_font (self->font));
hb_ot_color_layer_t *layers;
unsigned int count;
layers = g_newa (hb_ot_color_layer_t, self->n_layers);
count = self->n_layers;
hb_ot_color_glyph_get_layers (face,
self->glyph,
0,
&count,
layers);
glyphs->glyphs[0].glyph = layers[self->layer].glyph;
if (layers[self->layer].color_index == 0xffff)
{
cairo_set_source_rgb (cr, 0, 0, 0);
}
else
{
hb_color_t *colors;
unsigned int n_colors;
hb_color_t color;
n_colors = hb_ot_color_palette_get_colors (face,
self->palette_index,
0,
NULL,
NULL);
colors = g_newa (hb_color_t, n_colors);
hb_ot_color_palette_get_colors (face,
self->palette_index,
0,
&n_colors,
colors);
color = colors[layers[self->layer].color_index];
cairo_set_source_rgba (cr, hb_color_get_red (color)/255.,
hb_color_get_green (color)/255.,
hb_color_get_blue (color)/255.,
hb_color_get_alpha (color)/255.);
}
}
cairo_move_to (cr, (width - logical.width/1024.)/2, (height - logical.height/1024.)/2);
pango2_cairo_show_color_glyph_string (cr, self->font, self->palette, glyphs);
{
Pango2Layout *layout;
Pango2FontDescription *desc;
char gid[20];
hb_font_t *hb_font;
hb_face_t *hb_face;
g_snprintf (gid, sizeof (gid), "%d", self->glyph);
layout = gtk_widget_create_pango_layout (widget, gid);
desc = pango2_font_description_from_string ("Cantarell 8");
pango2_layout_set_font_description (layout, desc);
pango2_font_description_free (desc);
gtk_snapshot_save (snapshot);
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (5, 5));
gtk_snapshot_append_layout (snapshot, layout, &(GdkRGBA){ 0.,0.,0.,0.7});
gtk_snapshot_restore (snapshot);
hb_font = pango2_font_get_hb_font (self->font);
hb_face = hb_font_get_face (hb_font);
if (hb_ot_layout_has_glyph_classes (hb_face))
{
hb_ot_layout_glyph_class_t class;
const char *class_names[] = {
NULL, "Base", "Ligature", "Mark", "Component"
};
int w, h;
class = hb_ot_layout_get_glyph_class (hb_face, self->glyph);
if (class != HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED)
{
pango2_layout_set_text (layout, class_names[class], -1);
pango2_lines_get_size (pango2_layout_get_lines (layout), &w, &h);
gtk_snapshot_save (snapshot);
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (width - w/1024. - 5, 5));
gtk_snapshot_append_layout (snapshot, layout, &(GdkRGBA){ 0.,0.,0.,.7});
gtk_snapshot_restore (snapshot);
}
}
if (hb_font_get_glyph_name (hb_font, self->glyph, name, sizeof (name)))
{
int w, h;
pango2_layout_set_text (layout, name, -1);
pango2_lines_get_size (pango2_layout_get_lines (layout), &w, &h);
gtk_snapshot_save (snapshot);
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (5, height - h/1024. - 5));
gtk_snapshot_append_layout (snapshot, layout, &(GdkRGBA){ 0.,0.,0.,.7});
gtk_snapshot_restore (snapshot);
}
if (self->n_layers > 0)
{
char buf[128];
int w, h;
if (self->layer == -1)
g_snprintf (buf, sizeof (buf), "%d Layers", self->n_layers);
else
g_snprintf (buf, sizeof (buf), "Layer %d", self->layer);
pango2_layout_set_text (layout, buf, -1);
pango2_lines_get_size (pango2_layout_get_lines (layout), &w, &h);
gtk_snapshot_save (snapshot);
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (width - w/1024. - 5, height - h/1024. - 5));
gtk_snapshot_append_layout (snapshot, layout, &(GdkRGBA){ 0.,0.,0.,.7});
gtk_snapshot_restore (snapshot);
}
g_object_unref (layout);
}
}
static void
glyph_view_measure (GtkWidget *widget,
GtkOrientation orientation,
int for_size,
int *minimum,
int *natural,
int *minimum_baseline,
int *natural_baseline)
{
GlyphView *self = GLYPH_VIEW (widget);
Pango2Rectangle ink, logical;
pango2_font_get_glyph_extents (self->font, self->glyph, &ink, &logical);
if (orientation == GTK_ORIENTATION_HORIZONTAL)
*minimum = *natural = 2 * logical.width / PANGO2_SCALE;
else
*minimum = *natural = 2 * logical.height / PANGO2_SCALE;
}
static void
glyph_view_class_init (GlyphViewClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
object_class->dispose = glyph_view_dispose;
widget_class->snapshot = glyph_view_snapshot;
widget_class->measure = glyph_view_measure;
gtk_widget_class_set_css_name (widget_class, "glyphview");
}
GlyphView *
glyph_view_new (void)
{
return g_object_new (GLYPH_VIEW_TYPE, NULL);
}
void
glyph_view_set_font (GlyphView *self,
Pango2Font *font)
{
if (g_set_object (&self->font, font))
gtk_widget_queue_resize (GTK_WIDGET (self));
}
static unsigned int
find_palette_index_by_flag (hb_face_t *hbface,
hb_ot_color_palette_flags_t flag)
{
unsigned int n_palettes;
n_palettes = hb_ot_color_palette_get_count (hbface);
for (unsigned int i = 0; i < n_palettes; i++)
{
if (hb_ot_color_palette_get_flags (hbface, i) & flag)
return i;
}
return 0;
}
void
glyph_view_set_palette (GlyphView *self,
GQuark palette)
{
if (self->palette == palette)
return;
self->palette = palette;
if (palette == g_quark_from_string (PANGO2_COLOR_PALETTE_DEFAULT))
self->palette_index = 0;
else if (palette == g_quark_from_string (PANGO2_COLOR_PALETTE_LIGHT))
self->palette_index = find_palette_index_by_flag (hb_font_get_face (pango2_font_get_hb_font (self->font)), HB_OT_COLOR_PALETTE_FLAG_USABLE_WITH_LIGHT_BACKGROUND);
else if (palette == g_quark_from_string (PANGO2_COLOR_PALETTE_DARK))
self->palette_index = find_palette_index_by_flag (hb_font_get_face (pango2_font_get_hb_font (self->font)), HB_OT_COLOR_PALETTE_FLAG_USABLE_WITH_DARK_BACKGROUND);
else
{
const char *str = g_quark_to_string (palette);
char *endp;
if (g_str_has_prefix (str, "palette"))
self->palette_index = g_ascii_strtoll (str + strlen ("palette"), &endp, 10);
}
gtk_widget_queue_resize (GTK_WIDGET (self));
}
void
glyph_view_set_glyph (GlyphView *self,
hb_codepoint_t glyph)
{
if (self->glyph == glyph)
return;
self->glyph = glyph;
self->n_layers = hb_ot_color_glyph_get_layers (hb_font_get_face (pango2_font_get_hb_font (self->font)), glyph, 0, NULL, NULL);
self->layer = -1;
gtk_widget_queue_resize (GTK_WIDGET (self));
}

View File

@@ -1,21 +0,0 @@
#pragma once
#include <gtk/gtk.h>
#define GLYPH_VIEW_TYPE (glyph_view_get_type ())
#define GLYPH_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLYPH_VIEW_TYPE, GlyphView))
typedef struct _GlyphView GlyphView;
typedef struct _GlyphViewClass GlyphViewClass;
GType glyph_view_get_type (void);
GlyphView * glyph_view_new (void);
void glyph_view_set_font (GlyphView *view,
Pango2Font *font);
void glyph_view_set_palette (GlyphView *view,
GQuark palette);
void glyph_view_set_glyph (GlyphView *view,
hb_codepoint_t glyph);

View File

@@ -1,423 +0,0 @@
#include "infoview.h"
#include <gtk/gtk.h>
#include <hb-ot.h>
enum {
PROP_FONT_MAP = 1,
PROP_FONT_DESC,
PROP_SIZE,
PROP_VARIATIONS,
NUM_PROPERTIES
};
static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
struct _InfoView
{
GtkWidget parent;
GtkGrid *info;
Pango2FontMap *font_map;
Pango2FontDescription *font_desc;
float size;
char *variations;
};
struct _InfoViewClass
{
GtkWidgetClass parent_class;
};
G_DEFINE_TYPE(InfoView, info_view, GTK_TYPE_WIDGET);
static void
info_view_init (InfoView *self)
{
self->font_map = g_object_ref (pango2_font_map_get_default ());
self->font_desc = pango2_font_description_from_string ("sans 12");
self->size = 12.;
self->variations = g_strdup ("");
gtk_widget_set_layout_manager (GTK_WIDGET (self),
gtk_box_layout_new (GTK_ORIENTATION_VERTICAL));
gtk_widget_init_template (GTK_WIDGET (self));
}
static void
info_view_dispose (GObject *object)
{
gtk_widget_clear_template (GTK_WIDGET (object), INFO_VIEW_TYPE);
G_OBJECT_CLASS (info_view_parent_class)->dispose (object);
}
static void
info_view_finalize (GObject *object)
{
InfoView *self = INFO_VIEW (object);
g_clear_object (&self->font_map);
pango2_font_description_free (self->font_desc);
g_free (self->variations);
G_OBJECT_CLASS (info_view_parent_class)->finalize (object);
}
static Pango2Font *
get_font (InfoView *self,
int size)
{
Pango2Context *context;
Pango2FontDescription *desc;
Pango2Font *font;
context = pango2_context_new_with_font_map (self->font_map);
desc = pango2_font_description_copy_static (self->font_desc);
pango2_font_description_set_variations (desc, self->variations);
pango2_font_description_set_size (desc, size);
font = pango2_context_load_font (context, desc);
pango2_font_description_free (desc);
g_object_unref (context);
return font;
}
static GtkWidget *
make_title_label (const char *title)
{
GtkWidget *label;
label = gtk_label_new (title);
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_widget_set_halign (label, GTK_ALIGN_START);
g_object_set (label, "margin-top", 10, "margin-bottom", 10, NULL);
gtk_widget_add_css_class (label, "heading");
return label;
}
static void
add_misc_line (InfoView *self,
const char *title,
const char *value,
int row)
{
GtkWidget *label;
label = gtk_label_new (title);
gtk_widget_set_halign (label, GTK_ALIGN_START);
gtk_widget_set_valign (label, GTK_ALIGN_START);
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_widget_set_hexpand (label, TRUE);
gtk_grid_attach (self->info, label, 0, row, 1, 1);
label = gtk_label_new (value);
gtk_widget_set_halign (label, GTK_ALIGN_END);
gtk_widget_set_valign (label, GTK_ALIGN_START);
gtk_label_set_xalign (GTK_LABEL (label), 1);
gtk_label_set_wrap (GTK_LABEL (label), TRUE);
gtk_label_set_width_chars (GTK_LABEL (label), 40);
gtk_label_set_max_width_chars (GTK_LABEL (label), 40);
gtk_label_set_selectable (GTK_LABEL (label), TRUE);
gtk_grid_attach (self->info, label, 1, row, 1, 1);
}
static void
add_info_line (InfoView *self,
hb_face_t *face,
hb_ot_name_id_t name_id,
const char *title,
int row)
{
char info[256];
unsigned int len = sizeof (info);
if (hb_ot_name_get_utf8 (face, name_id, HB_LANGUAGE_INVALID, &len, info) > 0)
add_misc_line (self, title, info, row);
}
static void
add_metrics_line (InfoView *self,
hb_font_t *font,
hb_ot_metrics_tag_t metrics_tag,
const char *title,
int row)
{
hb_position_t pos;
if (hb_ot_metrics_get_position (font, metrics_tag, &pos))
{
char buf[128];
g_snprintf (buf, sizeof (buf), "%d", pos);
add_misc_line (self, title, buf, row);
}
}
static void
add_style_line (InfoView *self,
hb_font_t *font,
hb_style_tag_t style_tag,
const char *title,
int row)
{
float value;
char buf[16];
value = hb_style_get_value (font, style_tag);
g_snprintf (buf, sizeof (buf), "%.2f", value);
add_misc_line (self, title, buf, row);
}
static void
update_info (InfoView *self)
{
GtkWidget *child;
int size = pango2_font_description_get_size (self->font_desc);
Pango2Font *pango_font = get_font (self, MAX (size, 10 * PANGO2_SCALE));
hb_font_t *font1 = pango2_font_get_hb_font (pango_font);
hb_face_t *face = hb_font_get_face (font1);
hb_font_t *font = hb_font_create_sub_font (font1);
int row = 0;
char buf[128];
unsigned int count;
GString *s;
hb_tag_t *tables;
const char *path;
hb_font_set_scale (font, hb_face_get_upem (face), hb_face_get_upem (face));
while ((child = gtk_widget_get_first_child (GTK_WIDGET (self->info))) != NULL)
gtk_widget_unparent (child);
gtk_grid_attach (self->info, make_title_label ("General Info"), 0, row++, 2, 1);
path = pango2_hb_face_get_file (PANGO2_HB_FACE (pango2_font_get_face (pango_font)));
if (path)
add_misc_line (self, "File ", path, row++);
add_info_line (self, face, HB_OT_NAME_ID_FONT_FAMILY, "Font Family Name", row++);
add_info_line (self, face, HB_OT_NAME_ID_FONT_SUBFAMILY, "Font Subfamily Name", row++);
add_info_line (self, face, HB_OT_NAME_ID_UNIQUE_ID, "Unique Font Identifier", row++);
add_info_line (self, face, HB_OT_NAME_ID_FULL_NAME, "Full Name", row++);
add_info_line (self, face, HB_OT_NAME_ID_VERSION_STRING, "Version", row++);
add_info_line (self, face, HB_OT_NAME_ID_POSTSCRIPT_NAME, "Postscript Name", row++);
add_info_line (self, face, HB_OT_NAME_ID_TYPOGRAPHIC_FAMILY, "Typographic Family Name", row++);
add_info_line (self, face, HB_OT_NAME_ID_TYPOGRAPHIC_SUBFAMILY, "Typographic Subfamily Name", row++);
add_info_line (self, face, HB_OT_NAME_ID_MANUFACTURER, "Vendor ID", row++);
add_info_line (self, face, HB_OT_NAME_ID_DESIGNER, "Designer", row++);
add_info_line (self, face, HB_OT_NAME_ID_DESCRIPTION, "Description", row++);
add_info_line (self, face, HB_OT_NAME_ID_COPYRIGHT, "Copyright", row++);
gtk_grid_attach (self->info, make_title_label ("Metrics"), 0, row++, 2, 1);
g_snprintf (buf, sizeof (buf), "%d", hb_face_get_upem (face));
add_misc_line (self, "Units per Em", buf, row++);
add_metrics_line (self, font, HB_OT_METRICS_TAG_HORIZONTAL_ASCENDER, "Ascender", row++);
add_metrics_line (self, font, HB_OT_METRICS_TAG_HORIZONTAL_DESCENDER, "Descender", row++);
add_metrics_line (self, font, HB_OT_METRICS_TAG_HORIZONTAL_LINE_GAP, "Line Gap", row++);
add_metrics_line (self, font, HB_OT_METRICS_TAG_HORIZONTAL_CARET_RISE, "Caret Rise", row++);
add_metrics_line (self, font, HB_OT_METRICS_TAG_HORIZONTAL_CARET_RUN, "Caret Run", row++);
add_metrics_line (self, font, HB_OT_METRICS_TAG_HORIZONTAL_CARET_OFFSET, "Caret Offset", row++);
add_metrics_line (self, font, HB_OT_METRICS_TAG_X_HEIGHT, "x Height", row++);
add_metrics_line (self, font, HB_OT_METRICS_TAG_CAP_HEIGHT, "Cap Height", row++);
add_metrics_line (self, font, HB_OT_METRICS_TAG_STRIKEOUT_SIZE, "Strikeout Size", row++);
add_metrics_line (self, font, HB_OT_METRICS_TAG_STRIKEOUT_OFFSET, "Strikeout Offset", row++);
add_metrics_line (self, font, HB_OT_METRICS_TAG_STRIKEOUT_SIZE, "Underline Size", row++);
add_metrics_line (self, font, HB_OT_METRICS_TAG_STRIKEOUT_OFFSET, "Underline Offset", row++);
gtk_grid_attach (self->info, make_title_label ("Style"), 0, row++, 2, 1);
add_style_line (self, font, HB_STYLE_TAG_ITALIC, "Italic", row++);
add_style_line (self, font, HB_STYLE_TAG_OPTICAL_SIZE, "Optical Size", row++);
add_style_line (self, font, HB_STYLE_TAG_SLANT_ANGLE, "Slant Angle", row++);
add_style_line (self, font, HB_STYLE_TAG_WIDTH, "Width", row++);
add_style_line (self, font, HB_STYLE_TAG_WEIGHT, "Weight", row++);
gtk_grid_attach (self->info, make_title_label ("Miscellaneous"), 0, row++, 2, 1);
count = hb_face_get_glyph_count (face);
g_snprintf (buf, sizeof (buf), "%d", count);
add_misc_line (self, "Glyph Count", buf, row++);
if (hb_ot_var_get_axis_count (face) > 0)
{
s = g_string_new ("");
hb_ot_var_axis_info_t *axes;
axes = g_newa (hb_ot_var_axis_info_t, hb_ot_var_get_axis_count (face));
count = hb_ot_var_get_axis_count (face);
hb_ot_var_get_axis_infos (face, 0, &count, axes);
for (int i = 0; i < count; i++)
{
char name[256];
unsigned int len;
len = sizeof (buf);
hb_ot_name_get_utf8 (face, axes[i].name_id, HB_LANGUAGE_INVALID, &len, name);
if (s->len > 0)
g_string_append (s, ", ");
g_string_append (s, name);
}
add_misc_line (self, "Axes", s->str, row++);
g_string_free (s, TRUE);
}
if (hb_ot_var_get_named_instance_count (face) > 0)
{
s = g_string_new ("");
for (int i = 0; i < hb_ot_var_get_named_instance_count (face); i++)
{
hb_ot_name_id_t name_id;
char name[256];
unsigned int len;
name_id = hb_ot_var_named_instance_get_subfamily_name_id (face, i);
len = sizeof (buf);
hb_ot_name_get_utf8 (face, name_id, HB_LANGUAGE_INVALID, &len, name);
if (s->len > 0)
g_string_append (s, ", ");
g_string_append (s, name);
}
add_misc_line (self, "Named Instances", s->str, row++);
g_string_free (s, TRUE);
}
s = g_string_new ("");
count = hb_face_get_table_tags (face, 0, NULL, NULL);
tables = g_newa (hb_tag_t, count);
hb_face_get_table_tags (face, 0, &count, tables);
for (int i = 0; i < count; i++)
{
memset (buf, 0, sizeof (buf));
hb_tag_to_string (tables[i], buf);
if (s->len > 0)
g_string_append (s, ", ");
g_string_append (s, buf);
}
add_misc_line (self, "Tables", s->str, row++);
g_string_free (s, TRUE);
s = g_string_new ("");
if (hb_ot_color_has_palettes (face))
g_string_append_printf (s, "%s", "Palettes");
if (hb_ot_color_has_layers (face))
g_string_append_printf (s, "%s%s", s->len > 0 ? ", " : "", "Layers");
if (hb_ot_color_has_svg (face))
g_string_append_printf (s, "%s%s", s->len > 0 ? ", " : "", "SVG");
if (hb_ot_color_has_png (face))
g_string_append_printf (s, "%s%s", s->len > 0 ? ", " : "", "PNG");
if (s->len > 0)
add_misc_line (self, "Color", s->str, row++);
g_string_free (s, TRUE);
hb_font_destroy (font);
}
static void
info_view_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
InfoView *self = INFO_VIEW (object);
switch (prop_id)
{
case PROP_FONT_MAP:
g_set_object (&self->font_map, g_value_get_object (value));
break;
case PROP_FONT_DESC:
pango2_font_description_free (self->font_desc);
self->font_desc = pango2_font_description_copy (g_value_get_boxed (value));
break;
case PROP_SIZE:
self->size = g_value_get_float (value);
break;
case PROP_VARIATIONS:
g_free (self->variations);
self->variations = g_strdup (g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
update_info (self);
}
static void
info_view_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
InfoView *self = INFO_VIEW (object);
switch (prop_id)
{
case PROP_FONT_MAP:
g_value_set_object (value, self->font_map);
break;
case PROP_FONT_DESC:
g_value_set_boxed (value, self->font_desc);
break;
case PROP_SIZE:
g_value_set_float (value, self->size);
break;
case PROP_VARIATIONS:
g_value_set_string (value, self->variations);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
info_view_class_init (InfoViewClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->dispose = info_view_dispose;
object_class->finalize = info_view_finalize;
object_class->get_property = info_view_get_property;
object_class->set_property = info_view_set_property;
properties[PROP_FONT_MAP] =
g_param_spec_object ("font-map", "", "",
PANGO2_TYPE_FONT_MAP,
G_PARAM_READWRITE);
properties[PROP_FONT_DESC] =
g_param_spec_boxed ("font-desc", "", "",
PANGO2_TYPE_FONT_DESCRIPTION,
G_PARAM_READWRITE);
properties[PROP_SIZE] =
g_param_spec_float ("size", "", "",
0., 100., 12.,
G_PARAM_READWRITE);
properties[PROP_VARIATIONS] =
g_param_spec_string ("variations", "", "",
"",
G_PARAM_READWRITE);
g_object_class_install_properties (G_OBJECT_CLASS (class), NUM_PROPERTIES, properties);
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/fontexplorer/infoview.ui");
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), InfoView, info);
gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (class), "infoview");
}

View File

@@ -1,14 +0,0 @@
#pragma once
#include <gtk/gtk.h>
#define INFO_VIEW_TYPE (info_view_get_type ())
#define INFO_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INFO_VIEW_TYPE, InfoView))
typedef struct _InfoView InfoView;
typedef struct _InfoViewClass InfoViewClass;
GType info_view_get_type (void);

View File

@@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="InfoView" parent="GtkWidget">
<style>
<class name="view"/>
</style>
<child>
<object class="GtkScrolledWindow">
<property name="hscrollbar-policy">never</property>
<property name="vscrollbar-policy">automatic</property>
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<child>
<object class="GtkGrid" id="info">
<style>
<class name="content"/>
</style>
</object>
</child>
</object>
</child>
</template>
</interface>

View File

@@ -1,334 +0,0 @@
#include <stdlib.h>
#include <stdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <string.h>
#include <errno.h>
#include <locale.h>
#include <sys/stat.h>
#include <glib.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
#include <hb-ot.h>
#include "language-names.h"
#ifdef G_OS_WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#else
#ifndef ISO_CODES_PREFIX
#define ISO_CODES_PREFIX "/usr"
#endif
#define ISO_CODES_DATADIR ISO_CODES_PREFIX "/share/xml/iso-codes"
#define ISO_CODES_LOCALESDIR ISO_CODES_PREFIX "/share/locale"
#endif
static GHashTable *language_map;
#ifdef G_OS_WIN32
/* if we are using native Windows use native Windows API for language names */
static BOOL CALLBACK
get_win32_all_locales_scripts (LPWSTR locale_w, DWORD flags, LPARAM param)
{
wchar_t *langname_w = NULL;
wchar_t locale_abbrev_w[9];
gchar *langname, *locale_abbrev, *locale, *p;
gint i;
const LCTYPE iso639_lctypes[] = { LOCALE_SISO639LANGNAME, LOCALE_SISO639LANGNAME2 };
GHashTable *ht_scripts_langs = (GHashTable *) param;
Pango2Language *lang;
gint langname_size, locale_abbrev_size;
langname_size = GetLocaleInfoEx (locale_w, LOCALE_SLOCALIZEDDISPLAYNAME, langname_w, 0);
if (langname_size == 0)
return FALSE;
langname_w = g_new0 (wchar_t, langname_size);
if (langname_size == 0)
return FALSE;
GetLocaleInfoEx (locale_w, LOCALE_SLOCALIZEDDISPLAYNAME, langname_w, langname_size);
langname = g_utf16_to_utf8 (langname_w, -1, NULL, NULL, NULL);
locale = g_utf16_to_utf8 (locale_w, -1, NULL, NULL, NULL);
p = strchr (locale, '-');
lang = pango2_language_from_string (locale);
if (g_hash_table_lookup (ht_scripts_langs, lang) == NULL)
g_hash_table_insert (ht_scripts_langs, lang, langname);
/*
* Track 3+-letter ISO639-2/3 language codes as well (these have a max length of 9 including terminating NUL)
* ISO639-2: iso639_lctypes[0] = LOCALE_SISO639LANGNAME
* ISO639-3: iso639_lctypes[1] = LOCALE_SISO639LANGNAME2
*/
for (i = 0; i < 2; i++)
{
locale_abbrev_size = GetLocaleInfoEx (locale_w, iso639_lctypes[i], locale_abbrev_w, 0);
if (locale_abbrev_size > 0)
{
GetLocaleInfoEx (locale_w, iso639_lctypes[i], locale_abbrev_w, locale_abbrev_size);
locale_abbrev = g_utf16_to_utf8 (locale_abbrev_w, -1, NULL, NULL, NULL);
lang = pango2_language_from_string (locale_abbrev);
if (g_hash_table_lookup (ht_scripts_langs, lang) == NULL)
g_hash_table_insert (ht_scripts_langs, lang, langname);
g_free (locale_abbrev);
}
}
g_free (locale);
g_free (langname_w);
return TRUE;
}
#else /* non-Windows */
static char *
get_first_item_in_semicolon_list (const char *list)
{
char **items;
char *item;
items = g_strsplit (list, "; ", 2);
item = g_strdup (items[0]);
g_strfreev (items);
return item;
}
static char *
capitalize_utf8_string (const char *str)
{
char first[8] = { 0 };
if (!str)
return NULL;
g_unichar_to_utf8 (g_unichar_totitle (g_utf8_get_char (str)), first);
return g_strconcat (first, g_utf8_offset_to_pointer (str, 1), NULL);
}
static char *
get_display_name (const char *language)
{
const char *translated;
char *tmp;
char *name;
translated = dgettext ("iso_639", language);
tmp = get_first_item_in_semicolon_list (translated);
name = capitalize_utf8_string (tmp);
g_free (tmp);
return name;
}
static void
languages_parse_start_tag (GMarkupParseContext *ctx,
const char *element_name,
const char **attr_names,
const char **attr_values,
gpointer user_data,
GError **error)
{
const char *ccode_longB;
const char *ccode_longT;
const char *ccode;
const char *ccode_id;
const char *lang_name;
char *display_name;
const char *long_names[] = {
"Dogri",
"Greek, Modern",
"Interlingua",
"Konkani",
"Tonga",
"Turkish, Ottoman",
};
int i;
if (!(g_str_equal (element_name, "iso_639_entry") ||
g_str_equal (element_name, "iso_639_3_entry")) ||
attr_names == NULL ||
attr_values == NULL)
return;
ccode = NULL;
ccode_longB = NULL;
ccode_longT = NULL;
ccode_id = NULL;
lang_name = NULL;
while (*attr_names && *attr_values)
{
if (g_str_equal (*attr_names, "iso_639_1_code"))
{
if (**attr_values)
{
if (strlen (*attr_values) != 2)
return;
ccode = *attr_values;
}
}
else if (g_str_equal (*attr_names, "iso_639_2B_code"))
{
if (**attr_values)
{
if (strlen (*attr_values) != 3)
return;
ccode_longB = *attr_values;
}
}
else if (g_str_equal (*attr_names, "iso_639_2T_code"))
{
if (**attr_values)
{
if (strlen (*attr_values) != 3)
return;
ccode_longT = *attr_values;
}
}
else if (g_str_equal (*attr_names, "id"))
{
if (**attr_values)
{
if (strlen (*attr_values) != 2 &&
strlen (*attr_values) != 3)
return;
ccode_id = *attr_values;
}
}
else if (g_str_equal (*attr_names, "name"))
{
lang_name = *attr_values;
}
++attr_names;
++attr_values;
}
if (lang_name == NULL)
return;
display_name = get_display_name (lang_name);
/* Fix up some egregious names */
for (i = 0; i < G_N_ELEMENTS (long_names); i++)
{
if (g_str_has_prefix (display_name, long_names[i]))
display_name[strlen (long_names[i])] = '\0';
}
if (ccode != NULL)
g_hash_table_insert (language_map,
pango2_language_from_string (ccode),
g_strdup (display_name));
if (ccode_longB != NULL)
g_hash_table_insert (language_map,
pango2_language_from_string (ccode_longB),
g_strdup (display_name));
if (ccode_longT != NULL)
g_hash_table_insert (language_map,
pango2_language_from_string (ccode_longT),
g_strdup (display_name));
if (ccode_id != NULL)
g_hash_table_insert (language_map,
pango2_language_from_string (ccode_id),
g_strdup (display_name));
g_free (display_name);
}
static void
languages_variant_init (const char *variant)
{
gboolean res;
gsize buf_len;
char *buf;
char *filename;
GError *error;
bindtextdomain (variant, ISO_CODES_LOCALESDIR);
bind_textdomain_codeset (variant, "UTF-8");
error = NULL;
filename = g_strconcat (ISO_CODES_DATADIR, "/", variant, ".xml", NULL);
res = g_file_get_contents (filename, &buf, &buf_len, &error);
if (res)
{
GMarkupParseContext *ctx = NULL;
GMarkupParser parser = { languages_parse_start_tag, NULL, NULL, NULL, NULL };
ctx = g_markup_parse_context_new (&parser, 0, NULL, NULL);
res = g_markup_parse_context_parse (ctx, buf, buf_len, &error);
g_free (ctx);
if (!res)
{
g_warning ("Failed to parse '%s': %s\n", filename, error->message);
g_error_free (error);
}
}
else
{
g_warning ("Failed to load '%s': %s\n", filename, error->message);
g_error_free (error);
}
g_free (filename);
g_free (buf);
}
#endif
static void
languages_init (void)
{
if (language_map)
return;
language_map = g_hash_table_new_full (NULL, NULL, NULL, g_free);
#ifdef G_OS_WIN32
g_return_if_fail (EnumSystemLocalesEx (&get_win32_all_locales_scripts, LOCALE_ALL, (LPARAM) language_map, NULL));
#else
languages_variant_init ("iso_639");
languages_variant_init ("iso_639_3");
#endif
}
const char *
get_language_name (Pango2Language *language)
{
languages_init ();
return (const char *) g_hash_table_lookup (language_map, language);
}
const char *
get_language_name_for_tag (guint32 tag)
{
hb_language_t lang;
const char *s;
lang = hb_ot_tag_to_language (tag);
s = hb_language_to_string (lang);
return get_language_name (pango2_language_from_string (s));
}

View File

@@ -1,13 +0,0 @@
#ifndef LANGUAGE_NAMES_H
#define LANGUAGE_NAMES_H
#include <pango2/pango.h>
G_BEGIN_DECLS
const char * get_language_name (Pango2Language *language);
const char * get_language_name_for_tag (guint32 tag);
G_END_DECLS
#endif

View File

@@ -1,9 +0,0 @@
#include <gtk/gtk.h>
#include <fontexplorerapp.h>
int
main (int argc, char *argv[])
{
return g_application_run (G_APPLICATION (font_explorer_app_new ()), argc, argv);
}

View File

@@ -1,35 +0,0 @@
fontexplorer_sources = [
'fontcolors.c',
'fontcontrols.c',
'fontexplorerapp.c',
'fontexplorerwin.c',
'fontfeatures.c',
'fontvariations.c',
'glyphitem.c',
'glyphmodel.c',
'glyphsview.c',
'glyphview.c',
'infoview.c',
'language-names.c',
'main.c',
'plainview.c',
'rangeedit.c',
'samplechooser.c',
'sampleeditor.c',
'styleview.c',
'waterfallview.c',
]
fontexplorer_resources = gnome.compile_resources('fontexplorer_resources',
'fontexplorer.gresource.xml',
source_dir: '.',
)
executable('gtk4-font-explorer',
sources: [fontexplorer_sources, fontexplorer_resources],
c_args: common_cflags,
dependencies: [ libgtk_dep, demo_conf_h ],
include_directories: confinc,
link_args: extra_demo_ldflags,
install: true,
)

View File

@@ -1,343 +0,0 @@
#include "plainview.h"
#include <gtk/gtk.h>
#include <hb-ot.h>
#include "glyphitem.h"
#include "glyphmodel.h"
#include "glyphview.h"
enum {
PROP_FONT_MAP = 1,
PROP_FONT_DESC,
PROP_SIZE,
PROP_LETTERSPACING,
PROP_LINE_HEIGHT,
PROP_FOREGROUND,
PROP_BACKGROUND,
PROP_VARIATIONS,
PROP_FEATURES,
PROP_PALETTE,
PROP_SAMPLE_TEXT,
NUM_PROPERTIES
};
static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
struct _PlainView
{
GtkWidget parent;
GtkLabel *content;
GtkScrolledWindow *swin;
Pango2FontMap *font_map;
Pango2FontDescription *font_desc;
float size;
char *variations;
char *features;
char *palette;
GQuark palette_quark;
int letterspacing;
float line_height;
GdkRGBA foreground;
GdkRGBA background;
GtkCssProvider *bg_provider;
char *sample_text;
};
struct _PlainViewClass
{
GtkWidgetClass parent_class;
};
G_DEFINE_TYPE(PlainView, plain_view, GTK_TYPE_WIDGET);
static void
plain_view_init (PlainView *self)
{
self->font_map = g_object_ref (pango2_font_map_get_default ());
self->font_desc = pango2_font_description_from_string ("sans 12");
self->size = 12.;
self->letterspacing = 0;
self->line_height = 1.;
self->variations = g_strdup ("");
self->features = g_strdup ("");
self->palette = g_strdup (PANGO2_COLOR_PALETTE_DEFAULT);
self->palette_quark = g_quark_from_string (self->palette);
self->foreground = (GdkRGBA){0., 0., 0., 1. };
self->background = (GdkRGBA){1., 1., 1., 1. };
self->sample_text = g_strdup ("Some sample text is better than other sample text");
gtk_widget_set_layout_manager (GTK_WIDGET (self),
gtk_box_layout_new (GTK_ORIENTATION_VERTICAL));
gtk_widget_init_template (GTK_WIDGET (self));
self->bg_provider = gtk_css_provider_new ();
gtk_style_context_add_provider (gtk_widget_get_style_context (GTK_WIDGET (self->content)),
GTK_STYLE_PROVIDER (self->bg_provider), 800);
}
static void
plain_view_dispose (GObject *object)
{
gtk_widget_clear_template (GTK_WIDGET (object), PLAIN_VIEW_TYPE);
G_OBJECT_CLASS (plain_view_parent_class)->dispose (object);
}
static void
plain_view_finalize (GObject *object)
{
PlainView *self = PLAIN_VIEW (object);
g_clear_object (&self->font_map);
pango2_font_description_free (self->font_desc);
g_free (self->variations);
g_free (self->features);
g_free (self->palette);
G_OBJECT_CLASS (plain_view_parent_class)->finalize (object);
}
static void
update_view (PlainView *self)
{
Pango2FontDescription *desc;
Pango2AttrList *attrs;
char *fg, *bg, *css;
desc = pango2_font_description_copy_static (self->font_desc);
pango2_font_description_set_size (desc, 12 * PANGO2_SCALE);
pango2_font_description_set_variations (desc, self->variations);
attrs = pango2_attr_list_new ();
pango2_attr_list_insert (attrs, pango2_attr_font_desc_new (desc));
pango2_attr_list_insert (attrs, pango2_attr_size_new (self->size * PANGO2_SCALE));
pango2_attr_list_insert (attrs, pango2_attr_letter_spacing_new (self->letterspacing));
pango2_attr_list_insert (attrs, pango2_attr_line_height_new (self->line_height));
pango2_attr_list_insert (attrs, pango2_attr_foreground_new (&(Pango2Color){65535 * self->foreground.red,
65535 * self->foreground.green,
65535 * self->foreground.blue,
65535 * self->foreground.alpha}));
pango2_attr_list_insert (attrs, pango2_attr_font_features_new (self->features));
pango2_attr_list_insert (attrs, pango2_attr_palette_new (self->palette));
pango2_font_description_free (desc);
gtk_label_set_label (self->content, self->sample_text);
gtk_label_set_attributes (self->content, attrs);
pango2_attr_list_unref (attrs);
fg = gdk_rgba_to_string (&self->foreground);
bg = gdk_rgba_to_string (&self->background);
css = g_strdup_printf (".content { caret-color: %s; background-color: %s; }", fg, bg);
gtk_css_provider_load_from_data (self->bg_provider, css, strlen (css));
g_free (css);
g_free (fg);
g_free (bg);
}
static void
plain_view_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
PlainView *self = PLAIN_VIEW (object);
switch (prop_id)
{
case PROP_FONT_MAP:
g_set_object (&self->font_map, g_value_get_object (value));
gtk_widget_set_font_map (GTK_WIDGET (self->content), self->font_map);
break;
case PROP_FONT_DESC:
pango2_font_description_free (self->font_desc);
self->font_desc = pango2_font_description_copy (g_value_get_boxed (value));
break;
case PROP_SIZE:
self->size = g_value_get_float (value);
break;
case PROP_LETTERSPACING:
self->letterspacing = g_value_get_int (value);
break;
case PROP_LINE_HEIGHT:
self->line_height = g_value_get_float (value);
break;
case PROP_FOREGROUND:
self->foreground = *(GdkRGBA *)g_value_get_boxed (value);
break;
case PROP_BACKGROUND:
self->background = *(GdkRGBA *)g_value_get_boxed (value);
break;
case PROP_VARIATIONS:
g_free (self->variations);
self->variations = g_strdup (g_value_get_string (value));
break;
case PROP_FEATURES:
g_free (self->features);
self->features = g_strdup (g_value_get_string (value));
break;
case PROP_PALETTE:
g_free (self->palette);
self->palette = g_strdup (g_value_get_string (value));
self->palette_quark = g_quark_from_string (self->palette);
break;
case PROP_SAMPLE_TEXT:
g_free (self->sample_text);
self->sample_text = g_strdup (g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
update_view (self);
}
static void
plain_view_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
PlainView *self = PLAIN_VIEW (object);
switch (prop_id)
{
case PROP_FONT_MAP:
g_value_set_object (value, self->font_map);
break;
case PROP_FONT_DESC:
g_value_set_boxed (value, self->font_desc);
break;
case PROP_SIZE:
g_value_set_float (value, self->size);
break;
case PROP_LETTERSPACING:
g_value_set_int (value, self->letterspacing);
break;
case PROP_LINE_HEIGHT:
g_value_set_float (value, self->line_height);
break;
case PROP_FOREGROUND:
g_value_set_boxed (value, &self->foreground);
break;
case PROP_BACKGROUND:
g_value_set_boxed (value, &self->background);
break;
case PROP_VARIATIONS:
g_value_set_string (value, self->variations);
break;
case PROP_FEATURES:
g_value_set_string (value, self->features);
break;
case PROP_PALETTE:
g_value_set_string (value, self->palette);
break;
case PROP_SAMPLE_TEXT:
g_value_set_string (value, self->sample_text);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
plain_view_class_init (PlainViewClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->dispose = plain_view_dispose;
object_class->finalize = plain_view_finalize;
object_class->get_property = plain_view_get_property;
object_class->set_property = plain_view_set_property;
properties[PROP_FONT_MAP] =
g_param_spec_object ("font-map", "", "",
PANGO2_TYPE_FONT_MAP,
G_PARAM_READWRITE);
properties[PROP_FONT_DESC] =
g_param_spec_boxed ("font-desc", "", "",
PANGO2_TYPE_FONT_DESCRIPTION,
G_PARAM_READWRITE);
properties[PROP_SIZE] =
g_param_spec_float ("size", "", "",
0., 100., 12.,
G_PARAM_READWRITE);
properties[PROP_LETTERSPACING] =
g_param_spec_int ("letterspacing", "", "",
-G_MAXINT, G_MAXINT, 0,
G_PARAM_READWRITE);
properties[PROP_LINE_HEIGHT] =
g_param_spec_float ("line-height", "", "",
0., 100., 1.,
G_PARAM_READWRITE);
properties[PROP_FOREGROUND] =
g_param_spec_boxed ("foreground", "", "",
GDK_TYPE_RGBA,
G_PARAM_READWRITE);
properties[PROP_BACKGROUND] =
g_param_spec_boxed ("background", "", "",
GDK_TYPE_RGBA,
G_PARAM_READWRITE);
properties[PROP_VARIATIONS] =
g_param_spec_string ("variations", "", "",
"",
G_PARAM_READWRITE);
properties[PROP_FEATURES] =
g_param_spec_string ("features", "", "",
"",
G_PARAM_READWRITE);
properties[PROP_PALETTE] =
g_param_spec_string ("palette", "", "",
PANGO2_COLOR_PALETTE_DEFAULT,
G_PARAM_READWRITE);
properties[PROP_SAMPLE_TEXT] =
g_param_spec_string ("sample-text", "", "",
"",
G_PARAM_READWRITE);
g_object_class_install_properties (G_OBJECT_CLASS (class), NUM_PROPERTIES, properties);
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/fontexplorer/plainview.ui");
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PlainView, swin);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PlainView, content);
gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (class), "plainview");
}

View File

@@ -1,14 +0,0 @@
#pragma once
#include <gtk/gtk.h>
#define PLAIN_VIEW_TYPE (plain_view_get_type ())
#define PLAIN_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PLAIN_VIEW_TYPE, PlainView))
typedef struct _PlainView PlainView;
typedef struct _PlainViewClass PlainViewClass;
GType plain_view_get_type (void);

View File

@@ -1,32 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="PlainView" parent="GtkWidget">
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<child>
<object class="GtkScrolledWindow" id="swin">
<property name="hscrollbar-policy">never</property>
<property name="vscrollbar-policy">automatic</property>
<style>
<class name="view"/>
</style>
<child>
<object class="GtkLabel" id="content">
<property name="label">Content</property>
<property name="wrap">1</property>
<property name="wrap-mode">word-char</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<property name="halign">fill</property>
<property name="valign">fill</property>
<style>
<class name="content"/>
</style>
</object>
</child>
</object>
</child>
</template>
</interface>

View File

@@ -1,174 +0,0 @@
#include "rangeedit.h"
#include <gtk/gtk.h>
#include <hb-ot.h>
enum {
PROP_ADJUSTMENT = 1,
PROP_DEFAULT_VALUE,
PROP_N_CHARS,
NUM_PROPERTIES
};
static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
struct _RangeEdit
{
GtkWidget parent;
GtkAdjustment *adjustment;
GtkScale *scale;
GtkEntry *entry;
double default_value;
int n_chars;
};
struct _RangeEditClass
{
GtkWidgetClass parent_class;
};
G_DEFINE_TYPE (RangeEdit, range_edit, GTK_TYPE_WIDGET);
static void
range_edit_init (RangeEdit *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
}
static void
range_edit_dispose (GObject *object)
{
gtk_widget_clear_template (GTK_WIDGET (object), RANGE_EDIT_TYPE);
G_OBJECT_CLASS (range_edit_parent_class)->dispose (object);
}
static void
range_edit_get_property (GObject *object,
unsigned int prop_id,
GValue *value,
GParamSpec *pspec)
{
RangeEdit *self = RANGE_EDIT (object);
switch (prop_id)
{
case PROP_ADJUSTMENT:
g_value_set_object (value, self->adjustment);
break;
case PROP_DEFAULT_VALUE:
g_value_set_double (value, self->default_value);
break;
case PROP_N_CHARS:
g_value_set_int (value, self->n_chars);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
adjustment_changed (GtkAdjustment *adjustment,
RangeEdit *self)
{
char *str;
str = g_strdup_printf ("%.1f", gtk_adjustment_get_value (adjustment));
gtk_editable_set_text (GTK_EDITABLE (self->entry), str);
g_free (str);
}
static void
range_edit_set_property (GObject *object,
unsigned int prop_id,
const GValue *value,
GParamSpec *pspec)
{
RangeEdit *self = RANGE_EDIT (object);
switch (prop_id)
{
case PROP_ADJUSTMENT:
g_set_object (&self->adjustment, g_value_get_object (value));
g_signal_connect (self->adjustment, "value-changed", G_CALLBACK (adjustment_changed), self);
adjustment_changed (self->adjustment, self);
break;
case PROP_DEFAULT_VALUE:
self->default_value = g_value_get_double (value);
break;
case PROP_N_CHARS:
self->n_chars = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
range_edit_constructed (GObject *object)
{
RangeEdit *self = RANGE_EDIT (object);
gtk_scale_add_mark (self->scale, self->default_value, GTK_POS_TOP, NULL);
}
static void
entry_activated (GtkEntry *entry,
RangeEdit *self)
{
double value;
char *err = NULL;
value = g_strtod (gtk_editable_get_text (GTK_EDITABLE (entry)), &err);
if (err != NULL)
gtk_adjustment_set_value (self->adjustment, value);
}
static void
range_edit_class_init (RangeEditClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->dispose = range_edit_dispose;
object_class->get_property = range_edit_get_property;
object_class->set_property = range_edit_set_property;
object_class->constructed = range_edit_constructed;
properties[PROP_ADJUSTMENT] =
g_param_spec_object ("adjustment", "", "",
GTK_TYPE_ADJUSTMENT,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
properties[PROP_DEFAULT_VALUE] =
g_param_spec_double ("default-value", "", "",
-G_MAXDOUBLE, G_MAXDOUBLE, 0.,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
properties[PROP_N_CHARS] =
g_param_spec_int ("n-chars", "", "",
0, G_MAXINT, 10,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_properties (G_OBJECT_CLASS (class), NUM_PROPERTIES, properties);
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/fontexplorer/rangeedit.ui");
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), RangeEdit, scale);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), RangeEdit, entry);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), entry_activated);
gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (class), "rangeedit");
}
RangeEdit *
range_edit_new (void)
{
return g_object_new (RANGE_EDIT_TYPE, NULL);
}

View File

@@ -1,15 +0,0 @@
#pragma once
#include <gtk/gtk.h>
#define RANGE_EDIT_TYPE (range_edit_get_type ())
#define RANGE_EDIT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RANGE_EDIT_TYPE, RangeEdit))
typedef struct _RangeEdit RangeEdit;
typedef struct _RangeEditClass RangeEditClass;
GType range_edit_get_type (void);
RangeEdit * range_edit_new (void);

View File

@@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="RangeEdit" parent="GtkWidget">
<property name="layout-manager">
<object class="GtkBoxLayout">
<property name="spacing">10</property>
</object>
</property>
<child>
<object class="GtkScale" id="scale">
<property name="orientation">horizontal</property>
<property name="hexpand">1</property>
<property name="adjustment" bind-source="RangeEdit" bind-flags="sync-create"/>
</object>
</child>
<child>
<object class="GtkEntry" id="entry">
<property name="width-chars" bind-source="RangeEdit" bind-property="n-chars" bind-flags="sync-create"/>
<property name="max-width-chars" bind-source="RangeEdit" bind-property="n-chars" bind-flags="sync-create"/>
<signal name="activate" handler="entry_activated"/>
</object>
</child>
</template>
</interface>

View File

@@ -1,163 +0,0 @@
#include "samplechooser.h"
#include <gtk/gtk.h>
#include <hb-ot.h>
enum {
PROP_SAMPLE_TEXT = 1,
NUM_PROPERTIES
};
static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
struct _SampleChooser
{
GtkWidget parent;
int sample;
const char *sample_text;
};
struct _SampleChooserClass
{
GtkWidgetClass parent_class;
};
G_DEFINE_TYPE(SampleChooser, sample_chooser, GTK_TYPE_WIDGET);
static const char *pangrams[] = {
"The quick brown fox jumps over the lazy dog.",
"Waltz, bad nymph, for quick jigs vex.",
"Quick zephyrs blow, vexing daft Jim.",
"Crazy Fredrick bought many very exquisite opal jewels.",
"Jaded zombies acted quaintly but kept driving their oxen forward.",
};
static const char *paragraphs[] = {
"Grumpy wizards make toxic brew for the evil Queen and Jack. A quick movement of the enemy will jeopardize six gunboats. The job of waxing linoleum frequently peeves chintzy kids. My girl wove six dozen plaid jackets before she quit. Twelve ziggurats quickly jumped a finch box.",
" Разъяренный чтец эгоистично бьёт пятью жердями шустрого фехтовальщика. Наш банк вчера же выплатил Ф.Я. Эйхгольду комиссию за ценные вещи. Эх, чужак, общий съём цен шляп (юфть) вдрызг! В чащах юга жил бы цитрус? Да, но фальшивый экземпляр!",
"Τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός",
};
static const char *alphabets[] = {
"abcdefghijklmnopqrstuvwxyz",
"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"0123456789",
"!@#$%^&*()?",
};
static const char *titles[] = {
"From My Cold Dead Hands",
"From Afar Upon the Back of a Tiger",
"Spontaneous Apple Creation",
"Big Bizness (Screwed & Chopped)",
"Pizza Shop Extended",
"Good News & Bad News",
};
static void
next_pangram (GtkButton *button,
SampleChooser *self)
{
self->sample++;
self->sample_text = pangrams[self->sample % G_N_ELEMENTS (pangrams)];
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SAMPLE_TEXT]);
}
static void
next_paragraph (GtkButton *button,
SampleChooser *self)
{
self->sample++;
self->sample_text = paragraphs[self->sample % G_N_ELEMENTS (paragraphs)];
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SAMPLE_TEXT]);
}
static void
next_alphabet (GtkButton *button,
SampleChooser *self)
{
self->sample++;
self->sample_text = alphabets[self->sample % G_N_ELEMENTS (alphabets)];
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SAMPLE_TEXT]);
}
static void
next_title (GtkButton *button,
SampleChooser *self)
{
self->sample++;
self->sample_text = titles[self->sample % G_N_ELEMENTS (titles)];
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SAMPLE_TEXT]);
}
static void
sample_chooser_init (SampleChooser *self)
{
self->sample_text = "Boring sample text";
gtk_widget_init_template (GTK_WIDGET (self));
}
static void
sample_chooser_dispose (GObject *object)
{
GtkWidget *child;
gtk_widget_clear_template (GTK_WIDGET (object), SAMPLE_CHOOSER_TYPE);
while ((child = gtk_widget_get_first_child (GTK_WIDGET (object))) != NULL)
gtk_widget_unparent (child);
G_OBJECT_CLASS (sample_chooser_parent_class)->dispose (object);
}
static void
sample_chooser_get_property (GObject *object,
unsigned int prop_id,
GValue *value,
GParamSpec *pspec)
{
SampleChooser *self = SAMPLE_CHOOSER (object);
switch (prop_id)
{
case PROP_SAMPLE_TEXT:
g_value_set_string (value, self->sample_text);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
sample_chooser_class_init (SampleChooserClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->dispose = sample_chooser_dispose;
object_class->get_property = sample_chooser_get_property;
properties[PROP_SAMPLE_TEXT] =
g_param_spec_string ("sample-text", "", "",
"",
G_PARAM_READABLE);
g_object_class_install_properties (G_OBJECT_CLASS (class), NUM_PROPERTIES, properties);
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/fontexplorer/samplechooser.ui");
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), next_pangram);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), next_paragraph);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), next_alphabet);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), next_title);
gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (class), "samplechooser");
}
SampleChooser *
sample_chooser_new (void)
{
return g_object_new (SAMPLE_CHOOSER_TYPE, NULL);
}

View File

@@ -1,15 +0,0 @@
#pragma once
#include <gtk/gtk.h>
#define SAMPLE_CHOOSER_TYPE (sample_chooser_get_type ())
#define SAMPLE_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SAMPLE_CHOOSER_TYPE, SampleChooser))
typedef struct _SampleChooser SampleChooser;
typedef struct _SampleChooserClass SampleChooserClass;
GType sample_chooser_get_type (void);
SampleChooser * sample_chooser_new (void);

View File

@@ -1,46 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="SampleChooser" parent="GtkWidget">
<property name="layout-manager"><object class="GtkGridLayout"/></property>
<child>
<object class="GtkButton">
<property name="label">Pangram</property>
<signal name="clicked" handler="next_pangram"/>
<layout>
<property name="row">0</property>
<property name="column">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label">Paragraph</property>
<signal name="clicked" handler="next_paragraph"/>
<layout>
<property name="row">0</property>
<property name="column">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label">Alphabet</property>
<signal name="clicked" handler="next_alphabet"/>
<layout>
<property name="row">1</property>
<property name="column">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkButton">
<property name="label">Title</property>
<signal name="clicked" handler="next_title"/>
<layout>
<property name="row">1</property>
<property name="column">1</property>
</layout>
</object>
</child>
</template>
</interface>

View File

@@ -1,162 +0,0 @@
#include "sampleeditor.h"
#include <gtk/gtk.h>
enum {
PROP_SAMPLE_TEXT = 1,
PROP_EDITING,
NUM_PROPERTIES
};
static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
struct _SampleEditor
{
GtkWidget parent;
GtkTextView *edit;
char *sample_text;
gboolean editing;
};
struct _SampleEditorClass
{
GtkWidgetClass parent_class;
};
G_DEFINE_TYPE(SampleEditor, sample_editor, GTK_TYPE_WIDGET);
static void
sample_editor_init (SampleEditor *self)
{
self->sample_text = g_strdup ("Some sample text is better than other sample text");
self->editing = FALSE;
gtk_widget_set_layout_manager (GTK_WIDGET (self),
gtk_box_layout_new (GTK_ORIENTATION_VERTICAL));
gtk_widget_init_template (GTK_WIDGET (self));
}
static void
sample_editor_dispose (GObject *object)
{
gtk_widget_clear_template (GTK_WIDGET (object), SAMPLE_EDITOR_TYPE);
G_OBJECT_CLASS (sample_editor_parent_class)->dispose (object);
}
static void
sample_editor_finalize (GObject *object)
{
SampleEditor *self = SAMPLE_EDITOR (object);
g_free (self->sample_text);
G_OBJECT_CLASS (sample_editor_parent_class)->finalize (object);
}
static void
update_editing (SampleEditor *self,
gboolean editing)
{
GtkTextBuffer *buffer;
if (self->editing == editing)
return;
self->editing = editing;
buffer = gtk_text_view_get_buffer (self->edit);
if (self->editing)
{
gtk_text_buffer_set_text (buffer, self->sample_text, -1);
gtk_widget_grab_focus (GTK_WIDGET (self->edit));
}
else
{
GtkTextIter start, end;
g_free (self->sample_text);
gtk_text_buffer_get_bounds (buffer, &start, &end);
self->sample_text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SAMPLE_TEXT]);
}
}
static void
sample_editor_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
SampleEditor *self = SAMPLE_EDITOR (object);
switch (prop_id)
{
case PROP_SAMPLE_TEXT:
g_free (self->sample_text);
self->sample_text = g_strdup (g_value_get_string (value));
break;
case PROP_EDITING:
update_editing (self, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
sample_editor_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
SampleEditor *self = SAMPLE_EDITOR (object);
switch (prop_id)
{
case PROP_SAMPLE_TEXT:
g_value_set_string (value, self->sample_text);
break;
case PROP_EDITING:
g_value_set_boolean (value, self->editing);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
sample_editor_class_init (SampleEditorClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->dispose = sample_editor_dispose;
object_class->finalize = sample_editor_finalize;
object_class->get_property = sample_editor_get_property;
object_class->set_property = sample_editor_set_property;
properties[PROP_SAMPLE_TEXT] =
g_param_spec_string ("sample-text", "", "",
"",
G_PARAM_READWRITE);
properties[PROP_EDITING] =
g_param_spec_boolean ("editing", "", "",
FALSE,
G_PARAM_READWRITE);
g_object_class_install_properties (G_OBJECT_CLASS (class), NUM_PROPERTIES, properties);
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/fontexplorer/sampleeditor.ui");
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), SampleEditor, edit);
gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (class), "sampleeditor");
}

View File

@@ -1,14 +0,0 @@
#pragma once
#include <gtk/gtk.h>
#define SAMPLE_EDITOR_TYPE (sample_editor_get_type ())
#define SAMPLE_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SAMPLE_EDITOR_TYPE, SampleEditor))
typedef struct _SampleEditor SampleEditor;
typedef struct _SampleEditorClass SampleEditorClass;
GType sample_editor_get_type (void);

View File

@@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="SampleEditor" parent="GtkWidget">
<style>
<class name="view"/>
</style>
<child>
<object class="GtkScrolledWindow">
<property name="hscrollbar-policy">never</property>
<property name="vscrollbar-policy">automatic</property>
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<child>
<object class="GtkTextView" id="edit">
<property name="wrap-mode">word-char</property>
<property name="left-margin">20</property>
<property name="right-margin">20</property>
<property name="top-margin">20</property>
<property name="bottom-margin">20</property>
</object>
</child>
</object>
</child>
</template>
</interface>

View File

@@ -1,506 +0,0 @@
#include "styleview.h"
#include <gtk/gtk.h>
#include <hb-ot.h>
#include "glyphitem.h"
#include "glyphmodel.h"
#include "glyphview.h"
enum {
PROP_FONT_MAP = 1,
PROP_FONT_DESC,
PROP_SIZE,
PROP_LETTERSPACING,
PROP_LINE_HEIGHT,
PROP_FOREGROUND,
PROP_BACKGROUND,
PROP_VARIATIONS,
PROP_FEATURES,
PROP_PALETTE,
PROP_SAMPLE_TEXT,
PROP_HAS_STYLES,
NUM_PROPERTIES
};
static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
struct _StyleView
{
GtkWidget parent;
GtkLabel *content;
GtkScrolledWindow *swin;
Pango2FontMap *font_map;
Pango2FontDescription *font_desc;
float size;
char *variations;
char *features;
char *palette;
GQuark palette_quark;
int letterspacing;
float line_height;
GdkRGBA foreground;
GdkRGBA background;
GtkCssProvider *bg_provider;
char *sample_text;
gboolean has_styles;
};
struct _StyleViewClass
{
GtkWidgetClass parent_class;
};
G_DEFINE_TYPE(StyleView, style_view, GTK_TYPE_WIDGET);
static void
style_view_init (StyleView *self)
{
self->font_map = g_object_ref (pango2_font_map_get_default ());
self->font_desc = pango2_font_description_from_string ("sans 12");
self->size = 12.;
self->letterspacing = 0;
self->line_height = 1.;
self->variations = g_strdup ("");
self->features = g_strdup ("");
self->palette = g_strdup (PANGO2_COLOR_PALETTE_DEFAULT);
self->palette_quark = g_quark_from_string (self->palette);
self->foreground = (GdkRGBA){0., 0., 0., 1. };
self->background = (GdkRGBA){1., 1., 1., 1. };
self->sample_text = g_strdup ("Some sample text is better than other sample text");
self->has_styles = FALSE;
gtk_widget_set_layout_manager (GTK_WIDGET (self),
gtk_box_layout_new (GTK_ORIENTATION_VERTICAL));
gtk_widget_init_template (GTK_WIDGET (self));
self->bg_provider = gtk_css_provider_new ();
gtk_style_context_add_provider (gtk_widget_get_style_context (GTK_WIDGET (self->content)),
GTK_STYLE_PROVIDER (self->bg_provider), 800);
}
static void
style_view_dispose (GObject *object)
{
gtk_widget_clear_template (GTK_WIDGET (object), STYLE_VIEW_TYPE);
G_OBJECT_CLASS (style_view_parent_class)->dispose (object);
}
static void
style_view_finalize (GObject *object)
{
StyleView *self = STYLE_VIEW (object);
g_clear_object (&self->font_map);
pango2_font_description_free (self->font_desc);
g_free (self->variations);
g_free (self->features);
g_free (self->palette);
G_OBJECT_CLASS (style_view_parent_class)->finalize (object);
}
static Pango2Font *
get_font (StyleView *self)
{
Pango2Context *context;
Pango2FontDescription *desc;
Pango2Font *font;
context = pango2_context_new_with_font_map (self->font_map);
desc = pango2_font_description_copy_static (self->font_desc);
pango2_font_description_set_variations (desc, self->variations);
pango2_font_description_set_size (desc, self->size * PANGO2_SCALE);
font = pango2_context_load_font (context, desc);
pango2_font_description_free (desc);
g_object_unref (context);
return font;
}
static void
update_has_styles (StyleView *self)
{
Pango2Font *font = get_font (self);
hb_face_t *hb_face = hb_font_get_face (pango2_font_get_hb_font (font));
gboolean has_styles;
has_styles = hb_ot_var_get_named_instance_count (hb_face) > 0;
g_object_unref (font);
if (self->has_styles == has_styles)
return;
self->has_styles = has_styles;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_HAS_STYLES]);
}
static int
measure_names (Pango2Context *context,
hb_face_t *hb_face)
{
Pango2Layout *layout;
Pango2FontDescription *desc;
GString *str;
int width, height;
layout = pango2_layout_new (context);
desc = pango2_font_description_from_string ("Cantarell Regular 12");
pango2_layout_set_font_description (layout, desc);
pango2_font_description_free (desc);
str = g_string_new ("");
for (int i = 0; i < hb_ot_var_get_named_instance_count (hb_face); i++)
{
hb_ot_name_id_t name_id;
char name[20];
unsigned int name_len = 20;
name_id = hb_ot_var_named_instance_get_subfamily_name_id (hb_face, i);
hb_ot_name_get_utf8 (hb_face, name_id, HB_LANGUAGE_INVALID, &name_len, name);
g_string_append_printf (str, " %s\n", name);
}
pango2_layout_set_text (layout, str->str, -1);
pango2_lines_get_size (pango2_layout_get_lines (layout), &width, &height);
g_string_free (str, TRUE);
g_object_unref (layout);
return width;
}
static void
update_view (StyleView *self)
{
Pango2FontDescription *desc;
Pango2AttrList *attrs;
char *fg, *bg, *css;
GString *str;
int start, end, text_len;
Pango2Font *font = get_font (self);
hb_face_t *hb_face = hb_font_get_face (pango2_font_get_hb_font (font));
unsigned int n_axes;
float *coords = NULL;
hb_ot_var_axis_info_t *axes;
Pango2FontDescription *label_desc;
Pango2TabArray *tabs;
int width;
desc = pango2_font_description_copy_static (self->font_desc);
pango2_font_description_set_variations (desc, self->variations);
pango2_font_description_set_size (desc, self->size * PANGO2_SCALE);
attrs = pango2_attr_list_new ();
pango2_attr_list_insert (attrs, pango2_attr_font_desc_new (desc));
pango2_attr_list_insert (attrs, pango2_attr_letter_spacing_new (self->letterspacing));
pango2_attr_list_insert (attrs, pango2_attr_line_height_new (self->line_height));
pango2_attr_list_insert (attrs, pango2_attr_foreground_new (&(Pango2Color){65535 * self->foreground.red,
65535 * self->foreground.green,
65535 * self->foreground.blue,
65535 * self->foreground.alpha}));
pango2_attr_list_insert (attrs, pango2_attr_font_features_new (self->features));
pango2_attr_list_insert (attrs, pango2_attr_palette_new (self->palette));
str = g_string_new ("");
start = 0;
text_len = strlen (self->sample_text);
n_axes = hb_ot_var_get_axis_count (hb_face);
axes = g_newa (hb_ot_var_axis_info_t, n_axes);
hb_ot_var_get_axis_infos (hb_face, 0, &n_axes, axes);
coords = g_newa (float, n_axes);
label_desc = pango2_font_description_from_string ("Cantarell Regular 12");
width = measure_names (gtk_widget_get_pango_context (GTK_WIDGET (self->content)), hb_face);
tabs = pango2_tab_array_new (1, PANGO2_TAB_POSITIONS_DEFAULT);
pango2_tab_array_set_tab (tabs, 0, PANGO2_TAB_LEFT, width);
gtk_label_set_tabs (self->content, tabs);
pango2_tab_array_free (tabs);
for (int i = 0; i < hb_ot_var_get_named_instance_count (hb_face); i++)
{
unsigned int n_coords = n_axes;
Pango2Attribute *attr;
GString *variations;
hb_ot_name_id_t name_id;
char name[20];
unsigned int name_len = 20;
name_id = hb_ot_var_named_instance_get_subfamily_name_id (hb_face, i);
hb_ot_name_get_utf8 (hb_face, name_id, HB_LANGUAGE_INVALID, &name_len, name);
g_string_append_printf (str, "%s\t", name);
end = str->len;
attr = pango2_attr_font_desc_new (label_desc);
pango2_attribute_set_range (attr, start, end);
pango2_attr_list_insert (attrs, attr);
start = end;
hb_ot_var_named_instance_get_design_coords (hb_face, i, &n_coords, coords);
variations = g_string_new ("");
for (int j = 0; j < n_axes; j++)
{
char buf[5] = { 0, };
if (variations->len > 0)
g_string_append_c (variations, ',');
hb_tag_to_string (axes[j].tag, buf);
g_string_append_printf (variations, "%s=%f", buf, coords[j]);
}
g_string_append (str, self->sample_text);
g_string_append (str, ""); /* Unicode line separator */
end = start + text_len + strlen ("");
pango2_font_description_set_variations (desc, variations->str);
g_string_free (variations, TRUE);
attr = pango2_attr_font_desc_new (desc);
pango2_attribute_set_range (attr, start, end);
pango2_attr_list_insert (attrs, attr);
start = end;
}
pango2_font_description_free (label_desc);
gtk_label_set_text (self->content, str->str);
gtk_label_set_attributes (self->content, attrs);
g_string_free (str, TRUE);
pango2_attr_list_unref (attrs);
pango2_font_description_free (desc);
fg = gdk_rgba_to_string (&self->foreground);
bg = gdk_rgba_to_string (&self->background);
css = g_strdup_printf (".content { caret-color: %s; background-color: %s; }", fg, bg);
gtk_css_provider_load_from_data (self->bg_provider, css, strlen (css));
g_free (css);
g_free (fg);
g_free (bg);
g_object_unref (font);
}
static void
style_view_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
StyleView *self = STYLE_VIEW (object);
switch (prop_id)
{
case PROP_FONT_MAP:
g_set_object (&self->font_map, g_value_get_object (value));
gtk_widget_set_font_map (GTK_WIDGET (self->content), self->font_map);
update_has_styles (self);
break;
case PROP_FONT_DESC:
pango2_font_description_free (self->font_desc);
self->font_desc = pango2_font_description_copy (g_value_get_boxed (value));
update_has_styles (self);
break;
case PROP_SIZE:
self->size = g_value_get_float (value);
break;
case PROP_LETTERSPACING:
self->letterspacing = g_value_get_int (value);
break;
case PROP_LINE_HEIGHT:
self->line_height = g_value_get_float (value);
break;
case PROP_FOREGROUND:
self->foreground = *(GdkRGBA *)g_value_get_boxed (value);
break;
case PROP_BACKGROUND:
self->background = *(GdkRGBA *)g_value_get_boxed (value);
break;
case PROP_VARIATIONS:
g_free (self->variations);
self->variations = g_strdup (g_value_get_string (value));
break;
case PROP_FEATURES:
g_free (self->features);
self->features = g_strdup (g_value_get_string (value));
break;
case PROP_PALETTE:
g_free (self->palette);
self->palette = g_strdup (g_value_get_string (value));
self->palette_quark = g_quark_from_string (self->palette);
break;
case PROP_SAMPLE_TEXT:
g_free (self->sample_text);
self->sample_text = g_strdup (g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
update_view (self);
}
static void
style_view_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
StyleView *self = STYLE_VIEW (object);
switch (prop_id)
{
case PROP_FONT_MAP:
g_value_set_object (value, self->font_map);
break;
case PROP_FONT_DESC:
g_value_set_boxed (value, self->font_desc);
break;
case PROP_SIZE:
g_value_set_float (value, self->size);
break;
case PROP_LETTERSPACING:
g_value_set_int (value, self->letterspacing);
break;
case PROP_LINE_HEIGHT:
g_value_set_float (value, self->line_height);
break;
case PROP_FOREGROUND:
g_value_set_boxed (value, &self->foreground);
break;
case PROP_BACKGROUND:
g_value_set_boxed (value, &self->background);
break;
case PROP_VARIATIONS:
g_value_set_string (value, self->variations);
break;
case PROP_FEATURES:
g_value_set_string (value, self->features);
break;
case PROP_PALETTE:
g_value_set_string (value, self->palette);
break;
case PROP_SAMPLE_TEXT:
g_value_set_string (value, self->sample_text);
break;
case PROP_HAS_STYLES:
g_value_set_boolean (value, self->has_styles);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
style_view_class_init (StyleViewClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->dispose = style_view_dispose;
object_class->finalize = style_view_finalize;
object_class->get_property = style_view_get_property;
object_class->set_property = style_view_set_property;
properties[PROP_FONT_MAP] =
g_param_spec_object ("font-map", "", "",
PANGO2_TYPE_FONT_MAP,
G_PARAM_READWRITE);
properties[PROP_FONT_DESC] =
g_param_spec_boxed ("font-desc", "", "",
PANGO2_TYPE_FONT_DESCRIPTION,
G_PARAM_READWRITE);
properties[PROP_SIZE] =
g_param_spec_float ("size", "", "",
0., 100., 12.,
G_PARAM_READWRITE);
properties[PROP_LETTERSPACING] =
g_param_spec_int ("letterspacing", "", "",
-G_MAXINT, G_MAXINT, 0,
G_PARAM_READWRITE);
properties[PROP_LINE_HEIGHT] =
g_param_spec_float ("line-height", "", "",
0., 100., 1.,
G_PARAM_READWRITE);
properties[PROP_FOREGROUND] =
g_param_spec_boxed ("foreground", "", "",
GDK_TYPE_RGBA,
G_PARAM_READWRITE);
properties[PROP_BACKGROUND] =
g_param_spec_boxed ("background", "", "",
GDK_TYPE_RGBA,
G_PARAM_READWRITE);
properties[PROP_VARIATIONS] =
g_param_spec_string ("variations", "", "",
"",
G_PARAM_READWRITE);
properties[PROP_FEATURES] =
g_param_spec_string ("features", "", "",
"",
G_PARAM_READWRITE);
properties[PROP_PALETTE] =
g_param_spec_string ("palette", "", "",
PANGO2_COLOR_PALETTE_DEFAULT,
G_PARAM_READWRITE);
properties[PROP_SAMPLE_TEXT] =
g_param_spec_string ("sample-text", "", "",
"",
G_PARAM_READWRITE);
properties[PROP_HAS_STYLES] =
g_param_spec_boolean ("has-styles", "", "",
FALSE,
G_PARAM_READABLE);
g_object_class_install_properties (G_OBJECT_CLASS (class), NUM_PROPERTIES, properties);
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/fontexplorer/styleview.ui");
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), StyleView, swin);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), StyleView, content);
gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (class), "styleview");
}

View File

@@ -1,14 +0,0 @@
#pragma once
#include <gtk/gtk.h>
#define STYLE_VIEW_TYPE (style_view_get_type ())
#define STYLE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), STYLE_VIEW_TYPE, StyleView))
typedef struct _StyleView StyleView;
typedef struct _StyleViewClass StyleViewClass;
GType style_view_get_type (void);

View File

@@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="StyleView" parent="GtkWidget">
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<style>
<class name="view"/>
</style>
<child>
<object class="GtkScrolledWindow" id="swin">
<property name="hscrollbar-policy">automatic</property>
<property name="vscrollbar-policy">automatic</property>
<child>
<object class="GtkLabel" id="content">
<property name="label">Content</property>
<property name="wrap">0</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<property name="halign">fill</property>
<property name="valign">fill</property>
<style>
<class name="content"/>
</style>
</object>
</child>
</object>
</child>
</template>
</interface>

View File

@@ -1,401 +0,0 @@
#include "waterfallview.h"
#include <gtk/gtk.h>
#include <hb-ot.h>
#include "glyphitem.h"
#include "glyphmodel.h"
#include "glyphview.h"
enum {
PROP_FONT_MAP = 1,
PROP_FONT_DESC,
PROP_SIZE,
PROP_LETTERSPACING,
PROP_LINE_HEIGHT,
PROP_FOREGROUND,
PROP_BACKGROUND,
PROP_VARIATIONS,
PROP_FEATURES,
PROP_PALETTE,
PROP_SAMPLE_TEXT,
NUM_PROPERTIES
};
static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
struct _WaterfallView
{
GtkWidget parent;
GtkLabel *content;
GtkScrolledWindow *swin;
Pango2FontMap *font_map;
Pango2FontDescription *font_desc;
float size;
char *variations;
char *features;
char *palette;
GQuark palette_quark;
int letterspacing;
float line_height;
GdkRGBA foreground;
GdkRGBA background;
GtkCssProvider *bg_provider;
char *sample_text;
};
struct _WaterfallViewClass
{
GtkWidgetClass parent_class;
};
G_DEFINE_TYPE(WaterfallView, waterfall_view, GTK_TYPE_WIDGET);
static void
waterfall_view_init (WaterfallView *self)
{
self->font_map = g_object_ref (pango2_font_map_get_default ());
self->font_desc = pango2_font_description_from_string ("sans 12");
self->size = 12.;
self->letterspacing = 0;
self->line_height = 1.;
self->variations = g_strdup ("");
self->features = g_strdup ("");
self->palette = g_strdup (PANGO2_COLOR_PALETTE_DEFAULT);
self->palette_quark = g_quark_from_string (self->palette);
self->foreground = (GdkRGBA){0., 0., 0., 1. };
self->background = (GdkRGBA){1., 1., 1., 1. };
self->sample_text = g_strdup ("Some sample text is better than other sample text");
gtk_widget_set_layout_manager (GTK_WIDGET (self),
gtk_box_layout_new (GTK_ORIENTATION_VERTICAL));
gtk_widget_init_template (GTK_WIDGET (self));
self->bg_provider = gtk_css_provider_new ();
gtk_style_context_add_provider (gtk_widget_get_style_context (GTK_WIDGET (self->content)),
GTK_STYLE_PROVIDER (self->bg_provider), 800);
}
static void
waterfall_view_dispose (GObject *object)
{
gtk_widget_clear_template (GTK_WIDGET (object), WATERFALL_VIEW_TYPE);
G_OBJECT_CLASS (waterfall_view_parent_class)->dispose (object);
}
static void
waterfall_view_finalize (GObject *object)
{
WaterfallView *self = WATERFALL_VIEW (object);
g_clear_object (&self->font_map);
pango2_font_description_free (self->font_desc);
g_free (self->variations);
g_free (self->features);
g_free (self->palette);
G_OBJECT_CLASS (waterfall_view_parent_class)->finalize (object);
}
static void
update_view (WaterfallView *self)
{
Pango2FontDescription *desc;
Pango2AttrList *attrs;
char *fg, *bg, *css;
GString *str;
int sizes[] = { 7, 8, 9, 10, 12, 14, 16, 20, 24, 30, 40, 50, 60, 70, 90, 120 };
int start, end, text_len;
Pango2TabArray *tabs;
desc = pango2_font_description_copy_static (self->font_desc);
pango2_font_description_set_size (desc, 12 * PANGO2_SCALE);
pango2_font_description_set_variations (desc, self->variations);
attrs = pango2_attr_list_new ();
pango2_attr_list_insert (attrs, pango2_attr_font_desc_new (desc));
pango2_attr_list_insert (attrs, pango2_attr_size_new (self->size * PANGO2_SCALE));
pango2_attr_list_insert (attrs, pango2_attr_line_height_new (self->line_height));
pango2_attr_list_insert (attrs, pango2_attr_letter_spacing_new (self->letterspacing));
pango2_attr_list_insert (attrs, pango2_attr_foreground_new (&(Pango2Color){65535 * self->foreground.red,
65535 * self->foreground.green,
65535 * self->foreground.blue,
65535 * self->foreground.alpha}));
pango2_attr_list_insert (attrs, pango2_attr_font_features_new (self->features));
pango2_attr_list_insert (attrs, pango2_attr_palette_new (self->palette));
pango2_font_description_free (desc);
tabs = pango2_tab_array_new (2, PANGO2_TAB_POSITIONS_SPACES);
pango2_tab_array_set_tab (tabs, 0, PANGO2_TAB_RIGHT, 5);
pango2_tab_array_set_tab (tabs, 1, PANGO2_TAB_LEFT, 8);
gtk_label_set_tabs (self->content, tabs);
pango2_tab_array_free (tabs);
str = g_string_new ("");
start = 0;
text_len = strlen (self->sample_text);
for (int i = 0; i < G_N_ELEMENTS (sizes); i++)
{
Pango2Attribute *attr;
g_string_append_printf (str, "\t%d\t", sizes[i]);
end = str->len;
attr = pango2_attr_family_new ("Cantarell");
pango2_attribute_set_range (attr, start, end);
pango2_attr_list_insert (attrs, attr);
attr = pango2_attr_weight_new (PANGO2_WEIGHT_NORMAL);
pango2_attribute_set_range (attr, start, end);
pango2_attr_list_insert (attrs, attr);
attr = pango2_attr_style_new (PANGO2_STYLE_NORMAL);
pango2_attribute_set_range (attr, start, end);
pango2_attr_list_insert (attrs, attr);
attr = pango2_attr_size_new (12 * PANGO2_SCALE);
pango2_attribute_set_range (attr, start, end);
pango2_attr_list_insert (attrs, attr);
attr = pango2_attr_font_features_new ("tnum=1");
pango2_attribute_set_range (attr, start, end);
pango2_attr_list_insert (attrs, attr);
attr = pango2_attr_letter_spacing_new (0);
pango2_attribute_set_range (attr, start, end);
pango2_attr_list_insert (attrs, attr);
start = end;
g_string_append (str, self->sample_text);
g_string_append (str, ""); /* Unicode line separator */
end = start + text_len + strlen ("");
attr = pango2_attr_size_new (sizes[i] * PANGO2_SCALE);
pango2_attribute_set_range (attr, start, end);
pango2_attr_list_insert (attrs, attr);
start = end;
}
gtk_label_set_text (self->content, str->str);
gtk_label_set_attributes (self->content, attrs);
g_string_free (str, TRUE);
pango2_attr_list_unref (attrs);
fg = gdk_rgba_to_string (&self->foreground);
bg = gdk_rgba_to_string (&self->background);
css = g_strdup_printf (".content { caret-color: %s; background-color: %s; }", fg, bg);
gtk_css_provider_load_from_data (self->bg_provider, css, strlen (css));
g_free (css);
g_free (fg);
g_free (bg);
}
static void
waterfall_view_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
WaterfallView *self = WATERFALL_VIEW (object);
switch (prop_id)
{
case PROP_FONT_MAP:
g_set_object (&self->font_map, g_value_get_object (value));
gtk_widget_set_font_map (GTK_WIDGET (self->content), self->font_map);
break;
case PROP_FONT_DESC:
pango2_font_description_free (self->font_desc);
self->font_desc = pango2_font_description_copy (g_value_get_boxed (value));
break;
case PROP_SIZE:
self->size = g_value_get_float (value);
break;
case PROP_LETTERSPACING:
self->letterspacing = g_value_get_int (value);
break;
case PROP_LINE_HEIGHT:
self->line_height = g_value_get_float (value);
break;
case PROP_FOREGROUND:
self->foreground = *(GdkRGBA *)g_value_get_boxed (value);
break;
case PROP_BACKGROUND:
self->background = *(GdkRGBA *)g_value_get_boxed (value);
break;
case PROP_VARIATIONS:
g_free (self->variations);
self->variations = g_strdup (g_value_get_string (value));
break;
case PROP_FEATURES:
g_free (self->features);
self->features = g_strdup (g_value_get_string (value));
break;
case PROP_PALETTE:
g_free (self->palette);
self->palette = g_strdup (g_value_get_string (value));
self->palette_quark = g_quark_from_string (self->palette);
break;
case PROP_SAMPLE_TEXT:
g_free (self->sample_text);
self->sample_text = g_strdup (g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
update_view (self);
}
static void
waterfall_view_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
WaterfallView *self = WATERFALL_VIEW (object);
switch (prop_id)
{
case PROP_FONT_MAP:
g_value_set_object (value, self->font_map);
break;
case PROP_FONT_DESC:
g_value_set_boxed (value, self->font_desc);
break;
case PROP_SIZE:
g_value_set_float (value, self->size);
break;
case PROP_LETTERSPACING:
g_value_set_int (value, self->letterspacing);
break;
case PROP_LINE_HEIGHT:
g_value_set_float (value, self->line_height);
break;
case PROP_FOREGROUND:
g_value_set_boxed (value, &self->foreground);
break;
case PROP_BACKGROUND:
g_value_set_boxed (value, &self->background);
break;
case PROP_VARIATIONS:
g_value_set_string (value, self->variations);
break;
case PROP_FEATURES:
g_value_set_string (value, self->features);
break;
case PROP_PALETTE:
g_value_set_string (value, self->palette);
break;
case PROP_SAMPLE_TEXT:
g_value_set_string (value, self->sample_text);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
waterfall_view_class_init (WaterfallViewClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->dispose = waterfall_view_dispose;
object_class->finalize = waterfall_view_finalize;
object_class->get_property = waterfall_view_get_property;
object_class->set_property = waterfall_view_set_property;
properties[PROP_FONT_MAP] =
g_param_spec_object ("font-map", "", "",
PANGO2_TYPE_FONT_MAP,
G_PARAM_READWRITE);
properties[PROP_FONT_DESC] =
g_param_spec_boxed ("font-desc", "", "",
PANGO2_TYPE_FONT_DESCRIPTION,
G_PARAM_READWRITE);
properties[PROP_SIZE] =
g_param_spec_float ("size", "", "",
0., 100., 12.,
G_PARAM_READWRITE);
properties[PROP_LETTERSPACING] =
g_param_spec_int ("letterspacing", "", "",
-G_MAXINT, G_MAXINT, 0,
G_PARAM_READWRITE);
properties[PROP_LINE_HEIGHT] =
g_param_spec_float ("line-height", "", "",
0., 100., 1.,
G_PARAM_READWRITE);
properties[PROP_FOREGROUND] =
g_param_spec_boxed ("foreground", "", "",
GDK_TYPE_RGBA,
G_PARAM_READWRITE);
properties[PROP_BACKGROUND] =
g_param_spec_boxed ("background", "", "",
GDK_TYPE_RGBA,
G_PARAM_READWRITE);
properties[PROP_VARIATIONS] =
g_param_spec_string ("variations", "", "",
"",
G_PARAM_READWRITE);
properties[PROP_FEATURES] =
g_param_spec_string ("features", "", "",
"",
G_PARAM_READWRITE);
properties[PROP_PALETTE] =
g_param_spec_string ("palette", "", "",
PANGO2_COLOR_PALETTE_DEFAULT,
G_PARAM_READWRITE);
properties[PROP_SAMPLE_TEXT] =
g_param_spec_string ("sample-text", "", "",
"",
G_PARAM_READWRITE);
g_object_class_install_properties (G_OBJECT_CLASS (class), NUM_PROPERTIES, properties);
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/fontexplorer/waterfallview.ui");
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), WaterfallView, swin);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), WaterfallView, content);
gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (class), "waterfallview");
}

View File

@@ -1,14 +0,0 @@
#pragma once
#include <gtk/gtk.h>
#define WATERFALL_VIEW_TYPE (waterfall_view_get_type ())
#define WATERFALL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WATERFALL_VIEW_TYPE, WaterfallView))
typedef struct _WaterfallView WaterfallView;
typedef struct _WaterfallViewClass WaterfallViewClass;
GType waterfall_view_get_type (void);

View File

@@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="WaterfallView" parent="GtkWidget">
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<style>
<class name="view"/>
</style>
<child>
<object class="GtkScrolledWindow" id="swin">
<property name="hscrollbar-policy">automatic</property>
<property name="vscrollbar-policy">automatic</property>
<child>
<object class="GtkLabel" id="content">
<property name="label">Content</property>
<property name="wrap">0</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<property name="halign">fill</property>
<property name="valign">fill</property>
<style>
<class name="content"/>
</style>
</object>
</child>
</object>
</child>
</template>
</interface>

View File

@@ -504,6 +504,8 @@ demo_application_window_dispose (GObject *object)
demo_application_window_store_state (window);
gtk_widget_dispose_template (GTK_WIDGET (window), demo_application_window_get_type ());
G_OBJECT_CLASS (demo_application_window_parent_class)->dispose (object);
}

View File

@@ -11,6 +11,8 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
enum
{
ICON_NAME_COL,
@@ -260,13 +262,12 @@ mask_entry_set_background (MaskEntry *entry)
{
if (!g_regex_match_simple (entry->mask, gtk_editable_get_text (GTK_EDITABLE (entry)), 0, 0))
{
Pango2AttrList *attrs;
Pango2Color color = { 65535, 32767, 32767, 65535 };
PangoAttrList *attrs;
attrs = pango2_attr_list_new ();
pango2_attr_list_insert (attrs, pango2_attr_foreground_new (&color));
attrs = pango_attr_list_new ();
pango_attr_list_insert (attrs, pango_attr_foreground_new (65535, 32767, 32767));
gtk_entry_set_attributes (GTK_ENTRY (entry), attrs);
pango2_attr_list_unref (attrs);
pango_attr_list_unref (attrs);
return;
}
}

View File

@@ -1,20 +1,16 @@
/* Theming/CSS Accordion
*
* A simple accordion demo written using CSS transitions and multiple backgrounds
*
*/
#include <gtk/gtk.h>
static void
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
destroy_provider (GtkWidget *window,
GtkStyleProvider *provider)
{
GtkWidget *child;
gtk_style_context_add_provider (gtk_widget_get_style_context (widget), provider, G_MAXUINT);
for (child = gtk_widget_get_first_child (widget);
child != NULL;
child = gtk_widget_get_next_sibling (child))
apply_css (child, provider);
gtk_style_context_remove_provider_for_display (gtk_widget_get_display (window), provider);
}
GtkWidget *
@@ -24,8 +20,8 @@ do_css_accordion (GtkWidget *do_widget)
if (!window)
{
GtkWidget *container, *child;
GtkStyleProvider *provider;
GtkWidget *container, *styled_box, *child;
GtkCssProvider *provider;
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "CSS Accordion");
@@ -33,10 +29,13 @@ do_css_accordion (GtkWidget *do_widget)
gtk_window_set_default_size (GTK_WINDOW (window), 600, 300);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
styled_box = gtk_frame_new (NULL);
gtk_window_set_child (GTK_WINDOW (window), styled_box);
gtk_widget_add_css_class (styled_box, "accordion");
container = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_halign (container, GTK_ALIGN_CENTER);
gtk_widget_set_valign (container, GTK_ALIGN_CENTER);
gtk_window_set_child (GTK_WINDOW (window), container);
gtk_frame_set_child (GTK_FRAME (styled_box), container);
child = gtk_button_new_with_label ("This");
gtk_box_append (GTK_BOX (container), child);
@@ -56,10 +55,16 @@ do_css_accordion (GtkWidget *do_widget)
child = gtk_button_new_with_label (":-)");
gtk_box_append (GTK_BOX (container), child);
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
gtk_css_provider_load_from_resource (GTK_CSS_PROVIDER (provider), "/css_accordion/css_accordion.css");
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_resource (provider, "/css_accordion/css_accordion.css");
apply_css (window, provider);
gtk_style_context_add_provider_for_display (gtk_widget_get_display (window),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_signal_connect (window, "destroy",
G_CALLBACK (destroy_provider), provider);
g_object_unref (provider);
}
if (!gtk_widget_get_visible (window))

View File

@@ -1,13 +1,13 @@
@import url("resource://css_accordion/reset.css");
.accordion, .accordion * {
all: unset;
* {
transition-property: color, background-color, border-color, background-image, padding, border-width;
transition-duration: 1s;
font: 20px Cantarell;
}
window {
.accordion {
background: linear-gradient(153deg, #151515, #151515 5px, transparent 5px) 0 0,
linear-gradient(333deg, #151515, #151515 5px, transparent 5px) 10px 5px,
linear-gradient(153deg, #222, #222 5px, transparent 5px) 0 5px,
@@ -18,7 +18,7 @@ window {
background-size: 20px 20px;
}
button {
.accordion button {
color: black;
background-color: #bbb;
border-style: solid;
@@ -28,25 +28,25 @@ button {
padding: 12px 4px;
}
button:first-child {
.accordion button:first-child {
border-radius: 5px 0 0 5px;
}
button:last-child {
.accordion button:last-child {
border-radius: 0 5px 5px 0;
border-width: 2px;
}
button:hover {
.accordion button:hover {
padding: 12px 48px;
background-color: #4870bc;
}
button *:hover {
.accordion button *:hover {
color: white;
}
button:hover:active,
button:active {
.accordion button:hover:active,
.accordion button:active {
background-color: #993401;
}

View File

@@ -6,6 +6,8 @@
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static void
show_parsing_error (GtkCssProvider *provider,
GtkCssSection *section,
@@ -84,11 +86,11 @@ do_css_basics (GtkWidget *do_widget)
text = gtk_text_buffer_new (NULL);
gtk_text_buffer_create_tag (text,
"warning",
"underline", PANGO2_LINE_STYLE_SOLID,
"underline", PANGO_UNDERLINE_SINGLE,
NULL);
gtk_text_buffer_create_tag (text,
"error",
"underline", PANGO2_LINE_STYLE_DOTTED,
"underline", PANGO_UNDERLINE_ERROR,
NULL);
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());

View File

@@ -6,6 +6,8 @@
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static void
show_parsing_error (GtkCssProvider *provider,
GtkCssSection *section,
@@ -122,11 +124,11 @@ do_css_multiplebgs (GtkWidget *do_widget)
text = gtk_text_buffer_new (NULL);
gtk_text_buffer_create_tag (text,
"warning",
"underline", PANGO2_LINE_STYLE_SOLID,
"underline", PANGO_UNDERLINE_SINGLE,
NULL);
gtk_text_buffer_create_tag (text,
"error",
"underline", PANGO2_LINE_STYLE_DOTTED,
"underline", PANGO_UNDERLINE_ERROR,
NULL);
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());

View File

@@ -7,6 +7,8 @@
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static void
show_parsing_error (GtkCssProvider *provider,
GtkCssSection *section,
@@ -93,11 +95,11 @@ do_css_pixbufs (GtkWidget *do_widget)
text = gtk_text_buffer_new (NULL);
gtk_text_buffer_create_tag (text,
"warning",
"underline", PANGO2_LINE_STYLE_SOLID,
"underline", PANGO_UNDERLINE_SINGLE,
NULL);
gtk_text_buffer_create_tag (text,
"error",
"underline", PANGO2_LINE_STYLE_DOTTED,
"underline", PANGO_UNDERLINE_ERROR,
NULL);
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());

View File

@@ -5,6 +5,8 @@
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static void
show_parsing_error (GtkCssProvider *provider,
GtkCssSection *section,
@@ -111,11 +113,11 @@ do_css_shadows (GtkWidget *do_widget)
text = gtk_text_buffer_new (NULL);
gtk_text_buffer_create_tag (text,
"warning",
"underline", PANGO2_LINE_STYLE_SOLID,
"underline", PANGO_UNDERLINE_SINGLE,
NULL);
gtk_text_buffer_create_tag (text,
"error",
"underline", PANGO2_LINE_STYLE_DOTTED,
"underline", PANGO_UNDERLINE_ERROR,
NULL);
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());

View File

@@ -24,7 +24,6 @@
</gresource>
<gresource prefix="/css_accordion">
<file>css_accordion.css</file>
<file>reset.css</file>
</gresource>
<gresource prefix="/css_basics">
<file>css_basics.css</file>
@@ -428,6 +427,8 @@
<file>icons/16x16/emotes/face-laugh-symbolic.symbolic.png</file>
<file>icons/16x16/status/battery-caution-charging-symbolic.symbolic.png</file>
<file>icons/16x16/categories/applications-other.png</file>
<file>icons/48x48/status/starred.png</file>
<file alias="icons/scalable/apps/org.gtk.Demo4.svg">data/scalable/apps/org.gtk.Demo4.svg</file>
</gresource>
<gresource prefix="/org/gtk/Demo4/gtk">
<file preprocess="xml-stripblanks">help-overlay.ui</file>

View File

@@ -37,7 +37,8 @@ demo3_widget_dispose (GObject *object)
Demo3Widget *self = DEMO3_WIDGET (object);
g_clear_object (&self->paintable);
g_clear_pointer (&self->menu, gtk_widget_unparent);
gtk_widget_dispose_template (GTK_WIDGET (self), DEMO3_TYPE_WIDGET);
G_OBJECT_CLASS (demo3_widget_parent_class)->dispose (object);
}

View File

@@ -11,6 +11,8 @@
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
G_DECLARE_FINAL_TYPE (CanvasItem, canvas_item, CANVAS, ITEM, GtkWidget)
struct _CanvasItem {

View File

@@ -263,7 +263,7 @@ drop_down_new_from_strings (const char *const *titles,
static char *
get_family_name (gpointer item)
{
return g_strdup (pango2_font_family_get_name (PANGO2_FONT_FAMILY (item)));
return g_strdup (pango_font_family_get_name (PANGO_FONT_FAMILY (item)));
}
static char *
@@ -326,8 +326,8 @@ bind_highlight_item (GtkSignalListItemFactory *factory,
{
MatchObject *obj;
GtkWidget *label;
Pango2AttrList *attrs;
Pango2Attribute *attr;
PangoAttrList *attrs;
PangoAttribute *attr;
const char *str;
obj = MATCH_OBJECT (gtk_list_item_get_item (item));
@@ -336,14 +336,13 @@ bind_highlight_item (GtkSignalListItemFactory *factory,
str = match_object_get_string (obj);
gtk_label_set_label (GTK_LABEL (label), str);
attrs = pango2_attr_list_new ();
attr = pango2_attr_weight_new (PANGO2_WEIGHT_BOLD);
pango2_attribute_set_range (attr,
match_object_get_match_start (obj),
match_object_get_match_end (obj));
pango2_attr_list_insert (attrs, attr);
attrs = pango_attr_list_new ();
attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
attr->start_index = match_object_get_match_start (obj);
attr->end_index = match_object_get_match_end (obj);
pango_attr_list_insert (attrs, attr);
gtk_label_set_attributes (GTK_LABEL (label), attrs);
pango2_attr_list_unref (attrs);
pango_attr_list_unref (attrs);
}
static void
@@ -435,7 +434,7 @@ do_dropdown (GtkWidget *do_widget)
button = gtk_drop_down_new (NULL, NULL);
model = G_LIST_MODEL (pango2_font_map_get_default ());
model = G_LIST_MODEL (pango_cairo_font_map_get_default ());
gtk_drop_down_set_model (GTK_DROP_DOWN (button), model);
gtk_drop_down_set_selected (GTK_DROP_DOWN (button), 0);

View File

@@ -14,6 +14,8 @@
#include <string.h>
#include <stdlib.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
typedef struct
{
int number;

View File

@@ -8,6 +8,8 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
/* Creates a tree model containing the completions */
static GtkTreeModel *
create_completion_model (void)

View File

@@ -9,6 +9,8 @@
#include <gtk/gtk.h>
#include <stdlib.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
enum {
WIDTH_COLUMN,
HEIGHT_COLUMN,

View File

@@ -21,6 +21,7 @@
#include "script-names.h"
#include "language-names.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
#define MAKE_TAG(a,b,c,d) (unsigned int)(((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
@@ -35,10 +36,9 @@ typedef struct {
typedef struct {
unsigned int start;
unsigned int end;
Pango2FontDescription *desc;
PangoFontDescription *desc;
char *features;
char *palette;
Pango2Language *language;
PangoLanguage *language;
} Range;
typedef struct {
@@ -59,8 +59,6 @@ typedef struct {
GtkWidget *script_lang;
GtkWidget *feature_list;
GtkWidget *variations_grid;
GtkWidget *colors_grid;
GtkWidget *first_palette;
GtkWidget *instance_combo;
GtkWidget *stack;
GtkWidget *entry;
@@ -84,7 +82,6 @@ typedef struct {
GtkWidget *swin;
GtkCssProvider *provider;
int sample;
int palette;
} FontFeaturesDemo;
static void
@@ -206,12 +203,12 @@ font_features_reset_basic (void)
static void
update_basic (void)
{
Pango2FontDescription *desc;
PangoFontDescription *desc;
desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (demo->font));
gtk_adjustment_set_value (demo->size_adjustment,
pango2_font_description_get_size (desc) / (double) PANGO2_SCALE);
pango_font_description_get_size (desc) / (double) PANGO_SCALE);
}
static void add_font_variations (GString *s);
@@ -222,9 +219,8 @@ free_range (gpointer data)
Range *range = data;
if (range->desc)
pango2_font_description_free (range->desc);
pango_font_description_free (range->desc);
g_free (range->features);
g_free (range->palette);
g_free (range);
}
@@ -249,10 +245,9 @@ compare_range (gconstpointer a, gconstpointer b)
static void
ensure_range (unsigned int start,
unsigned int end,
Pango2FontDescription *desc,
PangoFontDescription *desc,
const char *features,
const char *palette,
Pango2Language *language)
PangoLanguage *language)
{
GList *l;
Range *range;
@@ -276,12 +271,11 @@ ensure_range (unsigned int start,
set:
if (range->desc)
pango2_font_description_free (range->desc);
pango_font_description_free (range->desc);
if (desc)
range->desc = pango2_font_description_copy (desc);
range->desc = pango_font_description_copy (desc);
g_free (range->features);
range->features = g_strdup (features);
range->palette = g_strdup (palette);
range->language = language;
}
@@ -480,20 +474,19 @@ update_display (void)
gboolean has_feature;
GtkTreeIter iter;
GtkTreeModel *model;
Pango2FontDescription *desc;
PangoFontDescription *desc;
GList *l;
Pango2AttrList *attrs;
Pango2Attribute *attr;
PangoAttrList *attrs;
PangoAttribute *attr;
int ins, bound;
guint start, end;
Pango2Language *lang;
PangoLanguage *lang;
char *font_desc;
char *features;
double value;
int text_len;
gboolean do_waterfall;
GString *waterfall;
char *palette;
{
GtkTextBuffer *buffer;
@@ -511,8 +504,8 @@ update_display (void)
if (do_waterfall)
{
start = PANGO2_ATTR_INDEX_FROM_TEXT_BEGINNING;
end = PANGO2_ATTR_INDEX_TO_TEXT_END;
start = PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING;
end = PANGO_ATTR_INDEX_TO_TEXT_END;
}
else if (gtk_label_get_selection_bounds (GTK_LABEL (demo->the_label), &ins, &bound))
{
@@ -521,24 +514,24 @@ update_display (void)
}
else
{
start = PANGO2_ATTR_INDEX_FROM_TEXT_BEGINNING;
end = PANGO2_ATTR_INDEX_TO_TEXT_END;
start = PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING;
end = PANGO_ATTR_INDEX_TO_TEXT_END;
}
desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (demo->font));
value = gtk_adjustment_get_value (demo->size_adjustment);
pango2_font_description_set_size (desc, value * PANGO2_SCALE);
pango_font_description_set_size (desc, value * PANGO_SCALE);
s = g_string_new ("");
add_font_variations (s);
if (s->len > 0)
{
pango2_font_description_set_variations (desc, s->str);
pango_font_description_set_variations (desc, s->str);
g_string_free (s, TRUE);
}
font_desc = pango2_font_description_to_string (desc);
font_desc = pango_font_description_to_string (desc);
s = g_string_new ("");
@@ -583,8 +576,6 @@ update_display (void)
features = g_string_free (s, FALSE);
palette = g_strdup_printf ("palette%d", demo->palette);
if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (demo->script_lang), &iter))
{
hb_tag_t lang_tag;
@@ -592,25 +583,27 @@ update_display (void)
model = gtk_combo_box_get_model (GTK_COMBO_BOX (demo->script_lang));
gtk_tree_model_get (model, &iter, 3, &lang_tag, -1);
lang = pango2_language_from_string (hb_language_to_string (hb_ot_tag_to_language (lang_tag)));
lang = pango_language_from_string (hb_language_to_string (hb_ot_tag_to_language (lang_tag)));
}
else
lang = NULL;
attrs = pango2_attr_list_new ();
attrs = pango_attr_list_new ();
if (gtk_adjustment_get_value (demo->letterspacing_adjustment) != 0.)
{
attr = pango2_attr_letter_spacing_new (gtk_adjustment_get_value (demo->letterspacing_adjustment));
pango2_attribute_set_range (attr, start, end);
pango2_attr_list_insert (attrs, attr);
attr = pango_attr_letter_spacing_new (gtk_adjustment_get_value (demo->letterspacing_adjustment));
attr->start_index = start;
attr->end_index = end;
pango_attr_list_insert (attrs, attr);
}
if (gtk_adjustment_get_value (demo->line_height_adjustment) != 1.)
{
attr = pango2_attr_line_height_new (gtk_adjustment_get_value (demo->line_height_adjustment));
pango2_attribute_set_range (attr, start, end);
pango2_attr_list_insert (attrs, attr);
attr = pango_attr_line_height_new (gtk_adjustment_get_value (demo->line_height_adjustment));
attr->start_index = start;
attr->end_index = end;
pango_attr_list_insert (attrs, attr);
}
{
@@ -618,12 +611,16 @@ update_display (void)
char *fg, *bg, *css;
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (demo->foreground), &rgba);
attr = pango2_attr_foreground_new (&(Pango2Color){ 65535 * rgba.red,
65535 * rgba.green,
65535 * rgba.blue,
65535 * rgba.alpha });
pango2_attribute_set_range (attr, start, end);
pango2_attr_list_insert (attrs, attr);
attr = pango_attr_foreground_new (65535 * rgba.red,
65535 * rgba.green,
65535 * rgba.blue);
attr->start_index = start;
attr->end_index = end;
pango_attr_list_insert (attrs, attr);
attr = pango_attr_foreground_alpha_new (65535 * rgba.alpha);
attr->start_index = start;
attr->end_index = end;
pango_attr_list_insert (attrs, attr);
fg = gdk_rgba_to_string (&rgba);
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (demo->background), &rgba);
@@ -637,40 +634,37 @@ update_display (void)
if (do_waterfall)
{
attr = pango2_attr_font_desc_new (desc);
pango2_attr_list_insert (attrs, attr);
attr = pango2_attr_font_features_new (features);
pango2_attr_list_insert (attrs, attr);
attr = pango2_attr_palette_new (palette);
pango2_attr_list_insert (attrs, attr);
attr = pango2_attr_language_new (lang);
pango2_attr_list_insert (attrs, attr);
attr = pango_attr_font_desc_new (desc);
pango_attr_list_insert (attrs, attr);
attr = pango_attr_font_features_new (features);
pango_attr_list_insert (attrs, attr);
attr = pango_attr_language_new (lang);
pango_attr_list_insert (attrs, attr);
}
else
{
ensure_range (start, end, desc, features, palette, lang);
ensure_range (start, end, desc, features, lang);
for (l = demo->ranges; l; l = l->next)
{
Range *range = l->data;
attr = pango2_attr_font_desc_new (range->desc);
pango2_attribute_set_range (attr, range->start, range->end);
pango2_attr_list_insert (attrs, attr);
attr = pango_attr_font_desc_new (range->desc);
attr->start_index = range->start;
attr->end_index = range->end;
pango_attr_list_insert (attrs, attr);
attr = pango2_attr_font_features_new (range->features);
pango2_attribute_set_range (attr, range->start, range->end);
pango2_attr_list_insert (attrs, attr);
attr = pango2_attr_palette_new (range->palette);
pango2_attribute_set_range (attr, range->start, range->end);
pango2_attr_list_insert (attrs, attr);
attr = pango_attr_font_features_new (range->features);
attr->start_index = range->start;
attr->end_index = range->end;
pango_attr_list_insert (attrs, attr);
if (range->language)
{
attr = pango2_attr_language_new (range->language);
pango2_attribute_set_range (attr, range->start, range->end);
pango2_attr_list_insert (attrs, attr);
attr = pango_attr_language_new (range->language);
attr->start_index = range->start;
attr->end_index = range->end;
pango_attr_list_insert (attrs, attr);
}
}
}
@@ -686,13 +680,14 @@ update_display (void)
for (int i = 0; i < G_N_ELEMENTS (sizes); i++)
{
g_string_append (waterfall, text);
g_string_append (waterfall, ""); /* Unicode line separator */
g_string_append_c (waterfall, '\n');
attr = pango2_attr_size_new (sizes[i] * PANGO2_SCALE);
pango2_attribute_set_range (attr, start, start + text_len);
pango2_attr_list_insert (attrs, attr);
attr = pango_attr_size_new (sizes[i] * PANGO_SCALE);
attr->start_index = start;
attr->end_index = start + text_len;
pango_attr_list_insert (attrs, attr);
start += text_len + strlen ("");
start += text_len + 1;
}
gtk_label_set_text (GTK_LABEL (demo->the_label), waterfall->str);
g_string_free (waterfall, TRUE);
@@ -703,23 +698,22 @@ update_display (void)
gtk_label_set_attributes (GTK_LABEL (demo->the_label), attrs);
g_free (font_desc);
pango2_font_description_free (desc);
pango_font_description_free (desc);
g_free (features);
g_free (palette);
pango2_attr_list_unref (attrs);
pango_attr_list_unref (attrs);
g_free (text);
}
static Pango2Font *
static PangoFont *
get_pango_font (void)
{
Pango2FontDescription *desc;
Pango2Context *context;
PangoFontDescription *desc;
PangoContext *context;
desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (demo->font));
context = gtk_widget_get_pango_context (demo->font);
return pango2_context_load_font (context, desc);
return pango_context_load_font (context, desc);
}
typedef struct {
@@ -772,7 +766,7 @@ update_script_combo (void)
GtkListStore *store;
hb_font_t *hb_font;
int i, j, k;
Pango2Font *pango_font;
PangoFont *pango_font;
GHashTable *tags;
GHashTableIter iter;
TagPair *pair;
@@ -792,7 +786,7 @@ update_script_combo (void)
store = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
pango_font = get_pango_font ();
hb_font = pango2_font_get_hb_font (pango_font);
hb_font = pango_font_get_hb_font (pango_font);
tags = g_hash_table_new_full (tag_pair_hash, tag_pair_equal, g_free, NULL);
@@ -915,7 +909,7 @@ update_features (void)
GtkTreeIter iter;
guint script_index, lang_index;
hb_tag_t lang_tag;
Pango2Font *pango_font;
PangoFont *pango_font;
hb_font_t *hb_font;
GList *l;
@@ -954,19 +948,8 @@ update_features (void)
gtk_check_button_set_active (GTK_CHECK_BUTTON (item->feat), TRUE);
}
/* set feature presence checks from the font features */
if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (demo->script_lang), &iter))
return;
model = gtk_combo_box_get_model (GTK_COMBO_BOX (demo->script_lang));
gtk_tree_model_get (model, &iter,
1, &script_index,
2, &lang_index,
-1);
pango_font = get_pango_font ();
hb_font = pango2_font_get_hb_font (pango_font);
hb_font = pango_font_get_hb_font (pango_font);
if (hb_font)
{
@@ -1194,8 +1177,6 @@ ease_out_cubic (double t)
return p * p * p + 1;
}
static const guint64 period = G_TIME_SPAN_SECOND * 3;
static gboolean
animate_axis (GtkWidget *widget,
GdkFrameClock *frame_clock,
@@ -1207,13 +1188,13 @@ animate_axis (GtkWidget *widget,
now = g_get_monotonic_time ();
if (now >= axis->start_time + period)
if (now >= axis->start_time + G_TIME_SPAN_SECOND)
{
axis->start_time += period;
axis->start_time += G_TIME_SPAN_SECOND;
axis->increasing = !axis->increasing;
}
value = (now - axis->start_time) / (double) period;
value = (now - axis->start_time) / (double) G_TIME_SPAN_SECOND;
value = ease_out_cubic (value);
@@ -1250,7 +1231,7 @@ start_or_stop_axis_animation (GtkButton *button,
lower = gtk_adjustment_get_lower (axis->adjustment);
upper = gtk_adjustment_get_upper (axis->adjustment);
value = value / (upper - lower);
axis->start_time = g_get_monotonic_time () - value * period;
axis->start_time = g_get_monotonic_time () - value * G_TIME_SPAN_SECOND;
axis->increasing = TRUE;
}
}
@@ -1381,7 +1362,7 @@ instance_changed (GtkComboBox *combo)
float *coords = NULL;
hb_ot_var_axis_info_t *ai = NULL;
unsigned int n_axes;
Pango2Font *pango_font = NULL;
PangoFont *pango_font = NULL;
hb_font_t *hb_font;
hb_face_t *hb_face;
@@ -1398,7 +1379,7 @@ instance_changed (GtkComboBox *combo)
}
pango_font = get_pango_font ();
hb_font = pango2_font_get_hb_font (pango_font);
hb_font = pango_font_get_hb_font (pango_font);
hb_face = hb_font_get_face (hb_font);
n_axes = hb_ot_var_get_axis_infos (hb_face, 0, NULL, NULL);
@@ -1499,10 +1480,10 @@ denorm_coord (hb_ot_var_axis_info_t *axis, int coord)
}
static void
update_variations (void)
update_font_variations (void)
{
GtkWidget *child;
Pango2Font *pango_font = NULL;
PangoFont *pango_font = NULL;
hb_font_t *hb_font;
hb_face_t *hb_face;
unsigned int n_axes;
@@ -1521,7 +1502,7 @@ update_variations (void)
g_hash_table_remove_all (demo->instances);
pango_font = get_pango_font ();
hb_font = pango2_font_get_hb_font (pango_font);
hb_font = pango_font_get_hb_font (pango_font);
hb_face = hb_font_get_face (hb_font);
n_axes = hb_ot_var_get_axis_infos (hb_face, 0, NULL, NULL);
@@ -1581,125 +1562,13 @@ done:
g_free (design_coords);
}
static void
palette_changed (GtkCheckButton *button)
{
demo->palette = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (button), "palette"));
update_display ();
}
static void
update_colors (void)
{
Pango2Font *pango_font = NULL;
hb_font_t *hb_font;
hb_face_t *hb_face;
GtkWidget *child;
while ((child = gtk_widget_get_first_child (demo->colors_grid)))
gtk_grid_remove (GTK_GRID (demo->colors_grid), child);
pango_font = get_pango_font ();
hb_font = pango2_font_get_hb_font (pango_font);
hb_face = hb_font_get_face (hb_font);
if (hb_ot_color_has_palettes (hb_face))
{
demo->first_palette = NULL;
for (unsigned int i = 0; i < hb_ot_color_palette_get_count (hb_face); i++)
{
hb_ot_name_id_t name_id;
char *name;
unsigned int n_colors;
hb_color_t *colors;
GtkWidget *palette;
GtkWidget *swatch;
hb_ot_color_palette_flags_t flags;
const char *str;
GtkWidget *toggle;
name_id = hb_ot_color_palette_get_name_id (hb_face, i);
if (name_id != HB_OT_NAME_ID_INVALID)
{
unsigned int len;
char buf[80];
len = sizeof (buf);
hb_ot_name_get_utf8 (hb_face, name_id, HB_LANGUAGE_INVALID, &len, buf);
name = g_strdup (buf);
}
else
name = g_strdup_printf ("Palette %d", i);
toggle = gtk_check_button_new_with_label (name);
if (i == demo->palette)
gtk_check_button_set_active (GTK_CHECK_BUTTON (toggle), TRUE);
g_object_set_data (G_OBJECT (toggle), "palette", GUINT_TO_POINTER (i));
g_signal_connect (toggle, "toggled", G_CALLBACK (palette_changed), NULL);
if (demo->first_palette)
gtk_check_button_set_group (GTK_CHECK_BUTTON (toggle), GTK_CHECK_BUTTON (demo->first_palette));
else
demo->first_palette = toggle;
g_free (name);
gtk_grid_attach (GTK_GRID (demo->colors_grid), toggle, 0, i, 1, 1);
flags = hb_ot_color_palette_get_flags (hb_face, i);
if ((flags & (HB_OT_COLOR_PALETTE_FLAG_USABLE_WITH_LIGHT_BACKGROUND |
HB_OT_COLOR_PALETTE_FLAG_USABLE_WITH_DARK_BACKGROUND)) ==
(HB_OT_COLOR_PALETTE_FLAG_USABLE_WITH_LIGHT_BACKGROUND |
HB_OT_COLOR_PALETTE_FLAG_USABLE_WITH_DARK_BACKGROUND))
str = "(light, dark)";
else if (flags & HB_OT_COLOR_PALETTE_FLAG_USABLE_WITH_LIGHT_BACKGROUND)
str = "(light)";
else if (flags & HB_OT_COLOR_PALETTE_FLAG_USABLE_WITH_DARK_BACKGROUND)
str = "(dark)";
else
str = NULL;
if (str)
gtk_grid_attach (GTK_GRID (demo->colors_grid), gtk_label_new (str), 1, i, 1, 1);
n_colors = hb_ot_color_palette_get_colors (hb_face, i, 0, NULL, NULL);
colors = g_new (hb_color_t, n_colors);
n_colors = hb_ot_color_palette_get_colors (hb_face, i, 0, &n_colors, colors);
palette = gtk_grid_new ();
gtk_grid_attach (GTK_GRID (demo->colors_grid), palette, 2, i, 1, 1);
for (int k = 0; k < n_colors; k++)
{
swatch = g_object_new (g_type_from_name ("GtkColorSwatch"),
"rgba", &(GdkRGBA){ hb_color_get_red (colors[k])/255.,
hb_color_get_green (colors[k])/255.,
hb_color_get_blue (colors[k])/255.,
hb_color_get_alpha (colors[k])/255.},
"width-request", 16,
"height-request", 16,
NULL);
gtk_grid_attach (GTK_GRID (palette), swatch, k % 8, k / 8, 1, 1);
}
}
}
}
static void
font_features_reset_colors (void)
{
gtk_check_button_set_active (GTK_CHECK_BUTTON (demo->first_palette), TRUE);
}
static void
font_features_font_changed (void)
{
update_basic ();
update_script_combo ();
update_features ();
update_variations ();
update_colors ();
update_font_variations ();
}
static void
@@ -1836,7 +1705,6 @@ do_font_features (GtkWidget *do_widget)
gtk_builder_cscope_add_callback (scope, font_features_reset_basic);
gtk_builder_cscope_add_callback (scope, font_features_reset_features);
gtk_builder_cscope_add_callback (scope, font_features_reset_variations);
gtk_builder_cscope_add_callback (scope, font_features_reset_colors);
gtk_builder_cscope_add_callback (scope, font_features_toggle_plain);
gtk_builder_cscope_add_callback (scope, font_features_toggle_edit);
gtk_builder_cscope_add_callback (scope, font_features_stop_edit);
@@ -1875,8 +1743,6 @@ do_font_features (GtkWidget *do_widget)
demo->foreground = GTK_WIDGET (gtk_builder_get_object (builder, "foreground"));
demo->background = GTK_WIDGET (gtk_builder_get_object (builder, "background"));
demo->swin = GTK_WIDGET (gtk_builder_get_object (builder, "swin"));
demo->variations_grid = GTK_WIDGET (gtk_builder_get_object (builder, "variations_grid"));
demo->colors_grid = GTK_WIDGET (gtk_builder_get_object (builder, "colors_grid"));
demo->provider = gtk_css_provider_new ();
gtk_style_context_add_provider (gtk_widget_get_style_context (demo->swin),
@@ -1931,6 +1797,7 @@ do_font_features (GtkWidget *do_widget)
(const char *[]){ "opbd", "lfbd", "rtbd", NULL });
demo->feature_items = g_list_reverse (demo->feature_items);
demo->variations_grid = GTK_WIDGET (gtk_builder_get_object (builder, "variations_grid"));
if (demo->instances == NULL)
demo->instances = g_hash_table_new_full (instance_hash, instance_equal, NULL, free_instance);
else

View File

@@ -1,65 +0,0 @@
--- demos/gtk-demo/font_features.c
+++ demos/gtk-demo/font_features.c
@@ -434,7 +434,7 @@ static void
update_display (void)
{
GString *s;
- const char *text;
+ char *text;
gboolean has_feature;
GtkTreeIter iter;
GtkTreeModel *model;
@@ -452,8 +452,12 @@ update_display (void)
gboolean do_waterfall;
GString *waterfall;
char *palette;
+ GtkTextBuffer *buffer;
+ GtkTextIter start_iter, end_iter;
- text = gtk_editable_get_text (GTK_EDITABLE (demo->the_entry));
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (demo->the_entry));
+ gtk_text_buffer_get_bounds (buffer, &start_iter, &end_iter);
+ text = gtk_text_buffer_get_text (buffer, &start_iter, &end_iter, FALSE);
text_len = strlen (text);
do_waterfall = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (demo->waterfall_toggle));
@@ -631,6 +635,8 @@ update_display (void)
pango2_font_description_free (desc);
g_free (features);
pango2_attr_list_unref (attrs);
+
+ g_free (text);
}
static Pango2Font *
@@ -1603,8 +1609,12 @@ font_features_toggle_edit (void)
{
if (strcmp (gtk_stack_get_visible_child_name (GTK_STACK (demo->stack)), "entry") != 0)
{
+ GtkTextBuffer *buffer;
+ GtkTextIter start, end;
g_free (demo->text);
- demo->text = g_strdup (gtk_editable_get_text (GTK_EDITABLE (demo->the_entry)));
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (demo->the_entry));
+ gtk_text_buffer_get_bounds (buffer, &start, &end);
+ demo->text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
gtk_stack_set_visible_child_name (GTK_STACK (demo->stack), "entry");
gtk_widget_grab_focus (demo->the_entry);
gtk_adjustment_set_value (gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (demo->swin)), 0);
@@ -1632,7 +1642,7 @@ entry_key_press (GtkEventController *controller,
{
if (keyval == GDK_KEY_Escape)
{
- gtk_editable_set_text (GTK_EDITABLE (entry), demo->text);
+ gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (demo->the_entry)), demo->text, -1);
return GDK_EVENT_STOP;
}
@@ -1701,7 +1711,6 @@ do_font_features (GtkWidget *do_widget)
basic_value_changed (demo->line_height_adjustment, demo->line_height_entry);
controller = gtk_event_controller_key_new ();
- g_object_set_data_full (G_OBJECT (demo->the_entry), "controller", g_object_ref (controller), g_object_unref);
g_signal_connect (controller, "key-pressed", G_CALLBACK (entry_key_press), demo->the_entry);
gtk_widget_add_controller (demo->the_entry, controller);

View File

@@ -38,7 +38,6 @@
<signal name="clicked" handler="font_features_reset_basic" swapped="no"/>
<signal name="clicked" handler="font_features_reset_features" swapped="no"/>
<signal name="clicked" handler="font_features_reset_variations" swapped="no"/>
<signal name="clicked" handler="font_features_reset_colors" swapped="no"/>
</object>
</child>
</object>
@@ -297,27 +296,6 @@
</child>
</object>
</child>
<child>
<object class="GtkExpander">
<child type="label">
<object class="GtkLabel">
<property name="label" translatable="yes">Color Palettes</property>
<property name="xalign">0</property>
<property name="margin-top">10</property>
<property name="margin-bottom">10</property>
<style>
<class name="title-4"/>
</style>
</object>
</child>
<child>
<object class="GtkGrid" id="colors_grid">
<property name="column-spacing">10</property>
<property name="row-spacing">10</property>
</object>
</child>
</object>
</child>
</object>
</child>
<style>

View File

@@ -19,7 +19,7 @@
*/
static void
insert_tags_for_attributes (GtkTextBuffer *buffer,
Pango2AttrIterator *iter,
PangoAttrIterator *iter,
GtkTextIter *start,
GtkTextIter *end)
{
@@ -27,12 +27,13 @@ insert_tags_for_attributes (GtkTextBuffer *buffer,
GSList *attrs, *l;
GtkTextTag *tag;
char name[256];
float fg_alpha, bg_alpha;
table = gtk_text_buffer_get_tag_table (buffer);
#define LANGUAGE_ATTR(attr_name) \
{ \
const char *language = pango2_language_to_string (pango2_attribute_get_language (attr)); \
const char *language = pango_language_to_string (((PangoAttrLanguage*)attr)->value); \
g_snprintf (name, 256, "language=%s", language); \
tag = gtk_text_tag_table_lookup (table, name); \
if (!tag) \
@@ -47,7 +48,7 @@ insert_tags_for_attributes (GtkTextBuffer *buffer,
#define STRING_ATTR(attr_name) \
{ \
const char *string = pango2_attribute_get_string (attr); \
const char *string = ((PangoAttrString*)attr)->value; \
g_snprintf (name, 256, #attr_name "=%s", string); \
tag = gtk_text_tag_table_lookup (table, name); \
if (!tag) \
@@ -62,7 +63,7 @@ insert_tags_for_attributes (GtkTextBuffer *buffer,
#define INT_ATTR(attr_name) \
{ \
int value = pango2_attribute_get_int (attr); \
int value = ((PangoAttrInt*)attr)->value; \
g_snprintf (name, 256, #attr_name "=%d", value); \
tag = gtk_text_tag_table_lookup (table, name); \
if (!tag) \
@@ -77,8 +78,8 @@ insert_tags_for_attributes (GtkTextBuffer *buffer,
#define FONT_ATTR(attr_name) \
{ \
Pango2FontDescription *desc = pango2_attribute_get_font_desc (attr); \
char *str = pango2_font_description_to_string (desc); \
PangoFontDescription *desc = ((PangoAttrFontDesc*)attr)->desc; \
char *str = pango_font_description_to_string (desc); \
g_snprintf (name, 256, "font-desc=%s", str); \
g_free (str); \
tag = gtk_text_tag_table_lookup (table, name); \
@@ -94,7 +95,7 @@ insert_tags_for_attributes (GtkTextBuffer *buffer,
#define FLOAT_ATTR(attr_name) \
{ \
float value = pango2_attribute_get_float (attr); \
float value = ((PangoAttrFloat*)attr)->value; \
g_snprintf (name, 256, #attr_name "=%g", value); \
tag = gtk_text_tag_table_lookup (table, name); \
if (!tag) \
@@ -107,14 +108,15 @@ insert_tags_for_attributes (GtkTextBuffer *buffer,
gtk_text_buffer_apply_tag (buffer, tag, start, end); \
}
#define RGBA_ATTR(attr_name) \
#define RGBA_ATTR(attr_name, alpha_value) \
{ \
Pango2Color *color = pango2_attribute_get_color (attr); \
PangoColor *color; \
GdkRGBA rgba; \
color = &((PangoAttrColor*)attr)->color; \
rgba.red = color->red / 65535.; \
rgba.green = color->green / 65535.; \
rgba.blue = color->blue / 65535.; \
rgba.alpha = color->alpha / 65535.; \
rgba.alpha = alpha_value; \
char *str = gdk_rgba_to_string (&rgba); \
g_snprintf (name, 256, #attr_name "=%s", str); \
g_free (str); \
@@ -142,157 +144,173 @@ insert_tags_for_attributes (GtkTextBuffer *buffer,
gtk_text_buffer_apply_tag (buffer, tag, start, end); \
}
attrs = pango2_attr_iterator_get_attrs (iter);
fg_alpha = bg_alpha = 1.;
attrs = pango_attr_iterator_get_attrs (iter);
for (l = attrs; l; l = l->next)
{
Pango2Attribute *attr = l->data;
PangoAttribute *attr = l->data;
switch (pango2_attribute_type (attr))
switch ((int)attr->klass->type)
{
case PANGO2_ATTR_LANGUAGE:
case PANGO_ATTR_FOREGROUND_ALPHA:
fg_alpha = ((PangoAttrInt*)attr)->value / 65535.;
break;
case PANGO_ATTR_BACKGROUND_ALPHA:
bg_alpha = ((PangoAttrInt*)attr)->value / 65535.;
break;
default:
break;
}
}
for (l = attrs; l; l = l->next)
{
PangoAttribute *attr = l->data;
switch (attr->klass->type)
{
case PANGO_ATTR_LANGUAGE:
LANGUAGE_ATTR (language);
break;
case PANGO2_ATTR_FAMILY:
case PANGO_ATTR_FAMILY:
STRING_ATTR (family);
break;
case PANGO2_ATTR_STYLE:
case PANGO_ATTR_STYLE:
INT_ATTR (style);
break;
case PANGO2_ATTR_WEIGHT:
case PANGO_ATTR_WEIGHT:
INT_ATTR (weight);
break;
case PANGO2_ATTR_VARIANT:
case PANGO_ATTR_VARIANT:
INT_ATTR (variant);
break;
case PANGO2_ATTR_STRETCH:
case PANGO_ATTR_STRETCH:
INT_ATTR (stretch);
break;
case PANGO2_ATTR_SIZE:
case PANGO_ATTR_SIZE:
INT_ATTR (size);
break;
case PANGO2_ATTR_FONT_DESC:
case PANGO_ATTR_FONT_DESC:
FONT_ATTR (font-desc);
break;
case PANGO2_ATTR_FOREGROUND:
RGBA_ATTR (foreground_rgba);
case PANGO_ATTR_FOREGROUND:
RGBA_ATTR (foreground_rgba, fg_alpha);
break;
case PANGO2_ATTR_BACKGROUND:
RGBA_ATTR (background_rgba);
case PANGO_ATTR_BACKGROUND:
RGBA_ATTR (background_rgba, bg_alpha);
break;
case PANGO2_ATTR_UNDERLINE:
case PANGO_ATTR_UNDERLINE:
INT_ATTR (underline);
break;
case PANGO2_ATTR_UNDERLINE_COLOR:
RGBA_ATTR (underline_rgba);
case PANGO_ATTR_UNDERLINE_COLOR:
RGBA_ATTR (underline_rgba, fg_alpha);
break;
case PANGO2_ATTR_OVERLINE:
case PANGO_ATTR_OVERLINE:
INT_ATTR (overline);
break;
case PANGO2_ATTR_OVERLINE_COLOR:
RGBA_ATTR (overline_rgba);
case PANGO_ATTR_OVERLINE_COLOR:
RGBA_ATTR (overline_rgba, fg_alpha);
break;
case PANGO2_ATTR_STRIKETHROUGH:
case PANGO_ATTR_STRIKETHROUGH:
INT_ATTR (strikethrough);
break;
case PANGO2_ATTR_STRIKETHROUGH_COLOR:
RGBA_ATTR (strikethrough_rgba);
case PANGO_ATTR_STRIKETHROUGH_COLOR:
RGBA_ATTR (strikethrough_rgba, fg_alpha);
break;
case PANGO2_ATTR_RISE:
case PANGO_ATTR_RISE:
INT_ATTR (rise);
break;
case PANGO2_ATTR_SCALE:
case PANGO_ATTR_SCALE:
FLOAT_ATTR (scale);
break;
case PANGO2_ATTR_FALLBACK:
case PANGO_ATTR_FALLBACK:
INT_ATTR (fallback);
break;
case PANGO2_ATTR_LETTER_SPACING:
case PANGO_ATTR_LETTER_SPACING:
INT_ATTR (letter_spacing);
break;
case PANGO2_ATTR_FONT_FEATURES:
case PANGO_ATTR_FONT_FEATURES:
STRING_ATTR (font_features);
break;
case PANGO2_ATTR_ALLOW_BREAKS:
case PANGO_ATTR_ALLOW_BREAKS:
INT_ATTR (allow_breaks);
break;
case PANGO2_ATTR_SHOW:
case PANGO_ATTR_SHOW:
INT_ATTR (show_spaces);
break;
case PANGO2_ATTR_INSERT_HYPHENS:
case PANGO_ATTR_INSERT_HYPHENS:
INT_ATTR (insert_hyphens);
break;
case PANGO2_ATTR_LINE_HEIGHT:
case PANGO_ATTR_LINE_HEIGHT:
FLOAT_ATTR (line_height);
break;
case PANGO2_ATTR_ABSOLUTE_LINE_HEIGHT:
case PANGO_ATTR_ABSOLUTE_LINE_HEIGHT:
break;
case PANGO2_ATTR_LINE_SPACING:
INT_ATTR (pixels_inside_wrap);
break;
case PANGO2_ATTR_WORD:
case PANGO_ATTR_WORD:
VOID_ATTR (word);
break;
case PANGO2_ATTR_SENTENCE:
case PANGO_ATTR_SENTENCE:
VOID_ATTR (sentence);
break;
case PANGO2_ATTR_PARAGRAPH:
VOID_ATTR (paragraph);
break;
case PANGO2_ATTR_BASELINE_SHIFT:
case PANGO_ATTR_BASELINE_SHIFT:
INT_ATTR (baseline_shift);
break;
case PANGO2_ATTR_FONT_SCALE:
case PANGO_ATTR_FONT_SCALE:
INT_ATTR (font_scale);
break;
case PANGO2_ATTR_ABSOLUTE_SIZE:
case PANGO2_ATTR_GRAVITY:
case PANGO2_ATTR_GRAVITY_HINT:
case PANGO_ATTR_SHAPE:
case PANGO_ATTR_ABSOLUTE_SIZE:
case PANGO_ATTR_GRAVITY:
case PANGO_ATTR_GRAVITY_HINT:
case PANGO_ATTR_FOREGROUND_ALPHA:
case PANGO_ATTR_BACKGROUND_ALPHA:
break;
case PANGO2_ATTR_TEXT_TRANSFORM:
case PANGO_ATTR_TEXT_TRANSFORM:
INT_ATTR (text_transform);
break;
case PANGO2_ATTR_INVALID:
case PANGO_ATTR_INVALID:
default:
g_assert_not_reached ();
break;
}
}
g_slist_free_full (attrs, (GDestroyNotify)pango2_attribute_destroy);
g_slist_free_full (attrs, (GDestroyNotify)pango_attribute_destroy);
#undef LANGUAGE_ATTR
#undef STRING_ATTR
@@ -311,9 +329,9 @@ typedef struct
GtkTextBuffer *buffer;
GtkTextIter iter;
GtkTextMark *mark;
Pango2AttrList *attributes;
PangoAttrList *attributes;
char *text;
Pango2AttrIterator *attr;
PangoAttrIterator *attr;
} MarkupData;
static void
@@ -322,8 +340,8 @@ free_markup_data (MarkupData *mdata)
g_free (mdata->markup);
g_clear_pointer (&mdata->parser, g_markup_parse_context_free);
gtk_text_buffer_delete_mark (mdata->buffer, mdata->mark);
g_clear_pointer (&mdata->attr, pango2_attr_iterator_destroy);
g_clear_pointer (&mdata->attributes, pango2_attr_list_unref);
g_clear_pointer (&mdata->attr, pango_attr_iterator_destroy);
g_clear_pointer (&mdata->attributes, pango_attr_list_unref);
g_free (mdata->text);
g_object_unref (mdata->buffer);
g_free (mdata);
@@ -349,7 +367,7 @@ insert_markup_idle (gpointer data)
return G_SOURCE_REMOVE;
}
pango2_attr_iterator_range (mdata->attr, &start, &end);
pango_attr_iterator_range (mdata->attr, &start, &end);
if (end == G_MAXINT) /* last chunk */
end = start - 1; /* resulting in -1 to be passed to _insert */
@@ -362,7 +380,7 @@ insert_markup_idle (gpointer data)
gtk_text_buffer_get_iter_at_mark (mdata->buffer, &mdata->iter, mdata->mark);
}
while (pango2_attr_iterator_next (mdata->attr));
while (pango_attr_iterator_next (mdata->attr));
free_markup_data (mdata);
return G_SOURCE_REMOVE;
@@ -398,7 +416,7 @@ parse_markup_idle (gpointer data)
mdata->pos += 4096;
} while (mdata->pos < mdata->len);
if (!pango2_markup_parser_finish (mdata->parser,
if (!pango_markup_parser_finish (mdata->parser,
&mdata->attributes,
&mdata->text,
NULL,
@@ -417,7 +435,7 @@ parse_markup_idle (gpointer data)
return G_SOURCE_REMOVE;
}
mdata->attr = pango2_attr_list_get_iterator (mdata->attributes);
mdata->attr = pango_attr_list_get_iterator (mdata->attributes);
insert_markup_idle (data);
return G_SOURCE_REMOVE;
@@ -443,7 +461,7 @@ insert_markup (GtkTextBuffer *buffer,
data->markup = markup;
data->len = len;
data->parser = pango2_markup_parser_new (0);
data->parser = pango_markup_parser_new (0);
data->pos = 0;
/* create mark with right gravity */

View File

@@ -10,6 +10,8 @@
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static GtkWidget *window = NULL;
static GtkWidget *font_button = NULL;
static GtkWidget *entry = NULL;
@@ -25,7 +27,7 @@ static GtkWidget *show_extents = NULL;
static GtkWidget *show_pixels = NULL;
static GtkWidget *show_outlines = NULL;
static Pango2Context *context;
static PangoContext *context;
static int scale = 7;
static double pixel_alpha = 1.0;
@@ -35,9 +37,9 @@ static void
update_image (void)
{
const char *text;
Pango2FontDescription *desc;
Pango2Layout *layout;
Pango2Rectangle ink, logical;
PangoFontDescription *desc;
PangoLayout *layout;
PangoRectangle ink, logical;
int baseline;
cairo_surface_t *surface;
cairo_t *cr;
@@ -56,7 +58,7 @@ update_image (void)
text = gtk_editable_get_text (GTK_EDITABLE (entry));
desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (font_button));
fopt = cairo_font_options_copy (pango2_cairo_context_get_font_options (context));
fopt = cairo_font_options_copy (pango_cairo_context_get_font_options (context));
hint = gtk_combo_box_get_active_id (GTK_COMBO_BOX (hinting));
hintstyle = CAIRO_HINT_STYLE_DEFAULT;
@@ -85,20 +87,20 @@ update_image (void)
antialias = CAIRO_ANTIALIAS_NONE;
cairo_font_options_set_antialias (fopt, antialias);
pango2_context_set_round_glyph_positions (context, hintmetrics == CAIRO_HINT_METRICS_ON);
pango2_cairo_context_set_font_options (context, fopt);
pango_context_set_round_glyph_positions (context, hintmetrics == CAIRO_HINT_METRICS_ON);
pango_cairo_context_set_font_options (context, fopt);
cairo_font_options_destroy (fopt);
pango2_context_changed (context);
pango_context_changed (context);
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (text_radio)))
{
layout = pango2_layout_new (context);
pango2_layout_set_font_description (layout, desc);
pango2_layout_set_text (layout, text, -1);
pango2_lines_get_extents (pango2_layout_get_lines (layout), &ink, &logical);
baseline = pango2_lines_get_baseline (pango2_layout_get_lines (layout));
layout = pango_layout_new (context);
pango_layout_set_font_description (layout, desc);
pango_layout_set_text (layout, text, -1);
pango_layout_get_extents (layout, &ink, &logical);
baseline = pango_layout_get_baseline (layout);
pango2_extents_to_pixels (&ink, NULL);
pango_extents_to_pixels (&ink, NULL);
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, ink.width + 20, ink.height + 20);
cr = cairo_create (surface);
@@ -108,9 +110,9 @@ update_image (void)
cairo_set_source_rgba (cr, 0, 0, 0, pixel_alpha);
cairo_move_to (cr, 10, 10);
pango2_cairo_show_layout (cr, layout);
pango_cairo_show_layout (cr, layout);
pango2_cairo_layout_path (cr, layout);
pango_cairo_layout_path (cr, layout);
path = cairo_copy_path (cr);
cairo_destroy (cr);
@@ -154,15 +156,15 @@ update_image (void)
cairo_set_source_rgb (cr, 0, 0, 1);
cairo_rectangle (cr,
scale * (10 + pango2_units_to_double (logical.x)) - 0.5,
scale * (10 + pango2_units_to_double (logical.y)) - 0.5,
scale * pango2_units_to_double (logical.width) + 1,
scale * pango2_units_to_double (logical.height) + 1);
scale * (10 + pango_units_to_double (logical.x)) - 0.5,
scale * (10 + pango_units_to_double (logical.y)) - 0.5,
scale * pango_units_to_double (logical.width) + 1,
scale * pango_units_to_double (logical.height) + 1);
cairo_stroke (cr);
cairo_move_to (cr, scale * (10 + pango2_units_to_double (logical.x)) - 0.5,
scale * (10 + pango2_units_to_double (baseline)) - 0.5);
cairo_line_to (cr, scale * (10 + pango2_units_to_double (logical.x + logical.width)) + 1,
scale * (10 + pango2_units_to_double (baseline)) - 0.5);
cairo_move_to (cr, scale * (10 + pango_units_to_double (logical.x)) - 0.5,
scale * (10 + pango_units_to_double (baseline)) - 0.5);
cairo_line_to (cr, scale * (10 + pango_units_to_double (logical.x + logical.width)) + 1,
scale * (10 + pango_units_to_double (baseline)) - 0.5);
cairo_stroke (cr);
cairo_set_source_rgb (cr, 1, 0, 0);
cairo_rectangle (cr,
@@ -206,10 +208,9 @@ update_image (void)
}
else
{
Pango2LineIter *iter;
Pango2Run *run;
Pango2GlyphString *glyphs;
Pango2GlyphInfo *g;
PangoLayoutIter *iter;
PangoLayoutRun *run;
PangoGlyphInfo *g;
int i, j;
GString *str;
gunichar ch;
@@ -218,53 +219,61 @@ update_image (void)
text = " ";
ch = g_utf8_get_char (text);
str = g_string_new ("");
layout = pango_layout_new (context);
retry:
for (i = 0; i < 4; i++)
{
g_string_append_unichar (str, ch);
g_string_append_unichar (str, 0x200c);
}
layout = pango2_layout_new (context);
pango2_layout_set_font_description (layout, desc);
pango2_layout_set_text (layout, str->str, -1);
pango_layout_set_font_description (layout, desc);
pango_layout_set_text (layout, str->str, -1);
pango_layout_get_extents (layout, &ink, &logical);
pango_extents_to_pixels (&logical, NULL);
iter = pango_layout_get_iter (layout);
run = pango_layout_iter_get_run (iter);
if (run->glyphs->num_glyphs < 8)
{
/* not a good char to use */
g_string_truncate (str, 0);
ch = 'a';
goto retry;
}
g_string_free (str, TRUE);
pango2_lines_get_extents (pango2_layout_get_lines (layout), &ink, &logical);
pango2_extents_to_pixels (&logical, NULL);
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, logical.width * 3 / 2, 4*logical.height);
cr = cairo_create (surface);
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_paint (cr);
iter = pango2_layout_get_iter (layout);
run = pango2_line_iter_get_run (iter);
glyphs = pango2_run_get_glyphs (run);
cairo_set_source_rgb (cr, 0, 0, 0);
for (i = 0; i < 4; i++)
{
g = &(glyphs->glyphs[2*i]);
g->geometry.width = PANGO2_UNITS_ROUND (g->geometry.width * 3 / 2);
g = &(run->glyphs->glyphs[2*i]);
g->geometry.width = PANGO_UNITS_ROUND (g->geometry.width * 3 / 2);
}
for (j = 0; j < 4; j++)
{
for (i = 0; i < 4; i++)
{
g = &(glyphs->glyphs[2*i]);
g->geometry.x_offset = i * (PANGO2_SCALE / 4);
g->geometry.y_offset = j * (PANGO2_SCALE / 4);
g = &(run->glyphs->glyphs[2*i]);
g->geometry.x_offset = i * (PANGO_SCALE / 4);
g->geometry.y_offset = j * (PANGO_SCALE / 4);
}
cairo_move_to (cr, 0, j * logical.height);
pango2_cairo_show_layout (cr, layout);
pango_cairo_show_layout (cr, layout);
}
cairo_destroy (cr);
pango2_line_iter_free (iter);
pango_layout_iter_free (iter);
g_object_unref (layout);
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, cairo_image_surface_get_width (surface), cairo_image_surface_get_height (surface));
@@ -277,7 +286,7 @@ update_image (void)
g_object_unref (pixbuf2);
pango2_font_description_free (desc);
pango_font_description_free (desc);
}
static gboolean fading = FALSE;

View File

@@ -20,6 +20,8 @@
#include "gtkshadertoy.h"
#include "gskshaderpaintable.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static GtkWidget *demo_window = NULL;
static void

View File

@@ -223,6 +223,7 @@ static void
destroy_gear (struct gear *g)
{
g_free (g->strips);
g_free (g->vertices);
g_free (g);
}

View File

@@ -29,7 +29,7 @@ insert_link (GtkTextBuffer *buffer,
tag = gtk_text_buffer_create_tag (buffer, NULL,
"foreground", "blue",
"underline", PANGO2_LINE_STYLE_SOLID,
"underline", PANGO_UNDERLINE_SINGLE,
NULL);
g_object_set_data (G_OBJECT (tag), "page", GINT_TO_POINTER (page));
gtk_text_buffer_insert_with_tags (buffer, iter, text, -1, tag, NULL);
@@ -72,8 +72,8 @@ show_page (GtkTextView *text_view,
buffer = gtk_text_view_get_buffer (text_view);
bold = gtk_text_buffer_create_tag (buffer, NULL,
"weight", PANGO2_WEIGHT_BOLD,
"scale", PANGO2_SCALE_X_LARGE,
"weight", PANGO_WEIGHT_BOLD,
"scale", PANGO_SCALE_X_LARGE,
NULL);
mono = gtk_text_buffer_create_tag (buffer, NULL,
"family", "monospace",

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@@ -123,11 +123,11 @@ populate_emoji_text (void)
for (int i = 0; i < 500; i++)
{
if (i % 2)
g_string_append (s, "<span underline=\"solid\" underline_color=\"red\">x</span>");
g_string_append (s, "<span underline=\"single\" underline_color=\"red\">x</span>");
for (int j = 0; j < 30; j++)
{
g_string_append (s, "💓");
g_string_append (s, "<span underline=\"solid\" underline_color=\"red\">x</span>");
g_string_append (s, "<span underline=\"single\" underline_color=\"red\">x</span>");
}
g_string_append (s, "\n");
}

View File

@@ -9,6 +9,8 @@
#include <gtk/gtk.h>
#include <string.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static GtkWidget *window = NULL;
#define FOLDER_NAME "/iconview/gnome-fs-directory.png"

View File

@@ -8,6 +8,8 @@
#include <gtk/gtk.h>
#include <string.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
enum
{
COL_TEXT,

View File

@@ -44,7 +44,7 @@ get_win32_all_locales_scripts (LPWSTR locale_w, DWORD flags, LPARAM param)
gint i;
const LCTYPE iso639_lctypes[] = { LOCALE_SISO639LANGNAME, LOCALE_SISO639LANGNAME2 };
GHashTable *ht_scripts_langs = (GHashTable *) param;
Pango2Language *lang;
PangoLanguage *lang;
gint langname_size, locale_abbrev_size;
langname_size = GetLocaleInfoEx (locale_w, LOCALE_SLOCALIZEDDISPLAYNAME, langname_w, 0);
@@ -60,7 +60,7 @@ get_win32_all_locales_scripts (LPWSTR locale_w, DWORD flags, LPARAM param)
langname = g_utf16_to_utf8 (langname_w, -1, NULL, NULL, NULL);
locale = g_utf16_to_utf8 (locale_w, -1, NULL, NULL, NULL);
p = strchr (locale, '-');
lang = pango2_language_from_string (locale);
lang = pango_language_from_string (locale);
if (g_hash_table_lookup (ht_scripts_langs, lang) == NULL)
g_hash_table_insert (ht_scripts_langs, lang, langname);
@@ -77,7 +77,7 @@ get_win32_all_locales_scripts (LPWSTR locale_w, DWORD flags, LPARAM param)
GetLocaleInfoEx (locale_w, iso639_lctypes[i], locale_abbrev_w, locale_abbrev_size);
locale_abbrev = g_utf16_to_utf8 (locale_abbrev_w, -1, NULL, NULL, NULL);
lang = pango2_language_from_string (locale_abbrev);
lang = pango_language_from_string (locale_abbrev);
if (g_hash_table_lookup (ht_scripts_langs, lang) == NULL)
g_hash_table_insert (ht_scripts_langs, lang, langname);
@@ -218,22 +218,22 @@ languages_parse_start_tag (GMarkupParseContext *ctx,
if (ccode != NULL)
g_hash_table_insert (language_map,
pango2_language_from_string (ccode),
pango_language_from_string (ccode),
g_strdup (display_name));
if (ccode_longB != NULL)
g_hash_table_insert (language_map,
pango2_language_from_string (ccode_longB),
pango_language_from_string (ccode_longB),
g_strdup (display_name));
if (ccode_longT != NULL)
g_hash_table_insert (language_map,
pango2_language_from_string (ccode_longT),
pango_language_from_string (ccode_longT),
g_strdup (display_name));
if (ccode_id != NULL)
g_hash_table_insert (language_map,
pango2_language_from_string (ccode_id),
pango_language_from_string (ccode_id),
g_strdup (display_name));
g_free (display_name);
@@ -295,7 +295,7 @@ languages_init (void)
}
const char *
get_language_name (Pango2Language *language)
get_language_name (PangoLanguage *language)
{
languages_init ();
@@ -311,5 +311,5 @@ get_language_name_for_tag (guint32 tag)
lang = hb_ot_tag_to_language (tag);
s = hb_language_to_string (lang);
return get_language_name (pango2_language_from_string (s));
return get_language_name (pango_language_from_string (s));
}

View File

@@ -1,11 +1,11 @@
#ifndef LANGUAGE_NAMES_H
#define LANGUAGE_NAMES_H
#include <pango2/pango.h>
#include <pango/pango.h>
G_BEGIN_DECLS
const char * get_language_name (Pango2Language *language);
const char * get_language_name (PangoLanguage *language);
const char * get_language_name_for_tag (guint32 tag);
G_END_DECLS

View File

@@ -72,7 +72,7 @@ do_links (GtkWidget *do_widget)
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
gtk_label_set_max_width_chars (GTK_LABEL (label), 40);
gtk_label_set_wrap (GTK_LABEL (label), TRUE);
gtk_label_set_wrap_mode (GTK_LABEL (label), PANGO2_WRAP_WORD);
gtk_label_set_wrap_mode (GTK_LABEL (label), PANGO_WRAP_WORD);
g_signal_connect (label, "activate-link", G_CALLBACK (activate_link), NULL);
gtk_widget_set_margin_start (label, 20);
gtk_widget_set_margin_end (label, 20);

View File

@@ -7,6 +7,8 @@
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static GtkWidget *window = NULL;
static GtkTreeModel *model = NULL;
static guint timeout = 0;

View File

@@ -260,12 +260,19 @@ gtk_message_row_state_flags_changed (GtkWidget *widget,
GTK_WIDGET_CLASS (gtk_message_row_parent_class)->state_flags_changed (widget, previous_state_flags);
}
static void
gtk_message_row_dispose (GObject *obj)
{
gtk_widget_dispose_template (GTK_WIDGET (obj), GTK_TYPE_MESSAGE_ROW);
G_OBJECT_CLASS (gtk_message_row_parent_class)->dispose (obj);
}
static void
gtk_message_row_finalize (GObject *obj)
{
GtkMessageRowPrivate *priv = GTK_MESSAGE_ROW (obj)->priv;
g_object_unref (priv->message);
G_OBJECT_CLASS (gtk_message_row_parent_class)->finalize(obj);
G_OBJECT_CLASS (gtk_message_row_parent_class)->finalize (obj);
}
static void
@@ -274,6 +281,7 @@ gtk_message_row_class_init (GtkMessageRowClass *klass)
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = gtk_message_row_dispose;
object_class->finalize = gtk_message_row_finalize;
gtk_widget_class_set_template_from_resource (widget_class, "/listbox/listbox.ui");

View File

@@ -758,15 +758,15 @@ setup_number_item (GtkSignalListItemFactory *factory,
GtkListItem *item)
{
GtkWidget *label;
Pango2AttrList *attrs;
PangoAttrList *attrs;
label = gtk_label_new ("");
gtk_label_set_xalign (GTK_LABEL (label), 1);
attrs = pango2_attr_list_new ();
pango2_attr_list_insert (attrs, pango2_attr_font_features_new ("tnum"));
attrs = pango_attr_list_new ();
pango_attr_list_insert (attrs, pango_attr_font_features_new ("tnum"));
gtk_label_set_attributes (GTK_LABEL (label), attrs);
pango2_attr_list_unref (attrs);
pango_attr_list_unref (attrs);
gtk_list_item_set_child (item, label);
}
@@ -862,7 +862,7 @@ do_listview_colors (GtkWidget *do_widget)
GtkExpression *expression;
GtkWidget *button;
GtkWidget *label;
Pango2AttrList *attrs;
PangoAttrList *attrs;
char *string;
guint len;
GtkWidget *selection_view;
@@ -990,10 +990,10 @@ do_listview_colors (GtkWidget *do_widget)
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), button);
label = gtk_label_new ("0 /");
attrs = pango2_attr_list_new ();
pango2_attr_list_insert (attrs, pango2_attr_font_features_new ("tnum"));
attrs = pango_attr_list_new ();
pango_attr_list_insert (attrs, pango_attr_font_features_new ("tnum"));
gtk_label_set_attributes (GTK_LABEL (label), attrs);
pango2_attr_list_unref (attrs);
pango_attr_list_unref (attrs);
string = g_strdup_printf ("%'u", 4096);
len = g_utf8_strlen (string, -1);
g_free (string);

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