Compare commits

...

455 Commits

Author SHA1 Message Date
Matthias Clasen
825b2a4139 wip: benchmarks 2020-07-12 20:54:46 -04:00
Matthias Clasen
8a23649d40 stringlist: Reuse objects
Keep a bitset of positions where the array contains
objects, and check those for reusable objects whenever
we need a new object.

We still keep the low-bit marking of string pointers,
so we can implement g_list_model_get_item without having
to consult the bitset.

In scrolling through the words demo, this keeps the
number of live string objects at ~200.
2020-07-12 20:52:48 -04:00
Matthias Clasen
bf367b219b stringlist: Use an array
A version of GtkStringList that uses a GPtrArray
to hold the strings / objects. We avoid a second
array by marking strings using a low bit of the
pointer.
2020-06-30 23:37:21 -04:00
Matthias Clasen
77435d31fa gtk-demo: Use a progressbar in the words demo
This looks better and a bit more polished.
2020-07-01 02:47:50 +02:00
Matthias Clasen
6edb8f096f gtk-demo: No selection in the words demo
This demo is about filtering, not about selection,
so use a GtkNoSelection.
2020-07-01 02:46:05 +02:00
Matthias Clasen
c4dfee8860 gtk-demo: Cosmetic fixes for the words demo
Set a window size, and don't put newlines in titles, left align and
ellipsize the label.
2020-07-01 02:46:05 +02:00
Benjamin Otte
8ac1e77c9a demo: Make words listview load async
And add an "Open" button (why are filechooser buttons such a catastrophe
that I can't make them smaller?).
2020-07-01 02:46:05 +02:00
Benjamin Otte
65ceb6c15a stringlist: Call splice() for adding items after construction
This has the benefit of actually allowing NULL to be passed.
2020-07-01 02:46:05 +02:00
Benjamin Otte
f70d10f6ac stringlist: Remove n_additions argument from gtk_string_list_splice()
char ** arrays are null-terminated everywhere, so make sure they are in
splice(), too.

Also fix the argument to be a const char * const * like in the
constructor.
2020-07-01 02:46:05 +02:00
Benjamin Otte
0bbd083d79 stringlist: Clarify docs for gtk_string_list_get_string()
Make sure it's obvious that it behaves like g_list_model_get_item() and
returns NULL for pos >= n_items.
2020-07-01 02:46:05 +02:00
Benjamin Otte
102d2986c6 stringlist: Make one constructor call the other
Simplifies code.
2020-07-01 02:46:05 +02:00
Benjamin Otte
c74201ca87 filterlistmodel: Look at type of change
This way we can avoid refiltering most of an already filtered list when
the change becomes more strict.
2020-07-01 02:46:05 +02:00
Benjamin Otte
b09019a5b4 gtk-demo: Add incremental filtering to words demo 2020-07-01 02:46:05 +02:00
Benjamin Otte
1dd08ad8db filterlistmodel: Add gtk_filter_list_model_get_pending()
This allows tracking if the model is busy filtering.
2020-07-01 02:46:05 +02:00
Benjamin Otte
eb0704855f filterlistmodel: Add incremental filtering 2020-07-01 02:46:05 +02:00
Benjamin Otte
c4c1d4a1b3 bitset: Add gtk_bitset_new_range()
It's a common use.
2020-07-01 02:46:05 +02:00
Benjamin Otte
e6756f605e stringlist: Make property not construct-only
Massively speeds up creation of long stringlists.
2020-07-01 02:46:05 +02:00
Benjamin Otte
1f4b8e089e filterlistmodel: Rewrite with bitset data structure
Bitsets are more powerful, less memory intensive and faster than the old
GtkRbTree version.
2020-07-01 02:46:05 +02:00
Benjamin Otte
c0e08db739 bitset: Add APIs needed for a filterlistmodel 2020-06-30 00:46:56 +02:00
Benjamin Otte
1c337d350d tests: Make testlistview be a list again
The grid conversion was for testing and should never have been
committed.
2020-06-30 00:46:56 +02:00
Benjamin Otte
81e675dfbf gtk-demo: Add a listview demo for filtering strings 2020-06-30 00:36:14 +02:00
Benjamin Otte
8556221429 stringlist: Take a const char const * argument
Sucks that we need to cast a char**, but otherwise we need to cast
{"foo", "bar", "baz" } arrays.
2020-06-30 00:36:14 +02:00
Benjamin Otte
1b4109a7fd scrolledwindow: Expand by default
Use gtk_scrolled_window_set_hexpand/vexpand(FALSE) to make the scrolled
window not expand.
2020-06-30 00:36:13 +02:00
Benjamin Otte
df0786be7a stringfilter: Don't crash if the expression returns "" 2020-06-30 00:36:13 +02:00
Benjamin Otte
3f545da08d a11y: Remove double initialization of variables 2020-06-30 00:36:13 +02:00
Carlos Garnacho
7170fdebb9 Merge branch 'wip/Jehan/GtkIMContextWayland-master' into 'master'
gtk: focus out the GtkIMContextWayland upon finalization.

See merge request GNOME/gtk!2170
2020-06-29 22:24:32 +00:00
Jehan
7ccf32db57 gtk: focus out the GtkIMContextWayland upon finalization.
In particular, it will NULL-ified the current global context if this is
the finalized one, avoiding dangling invalid pointers.

Would have been a cherry-pick from branch gtk-3-24 of commit
b592ded80a, but files moved.
2020-06-29 22:17:08 +02:00
Daniel Mustieles
520c2116a3 Updated Spanish translation 2020-06-29 16:03:40 +02:00
Emmanuele Bassi
e818685921 Merge branch 'ci-style' into 'master'
ci: Create new origin for forks

See merge request GNOME/gtk!2164
2020-06-29 13:45:03 +00:00
Matthias Clasen
6ddd9793f3 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #1887

See merge request GNOME/gtk!2167
2020-06-29 12:30:41 +00:00
Emmanuele Bassi
6bdca276a2 ci: Create new origin for forks
We don't need to create a new remote and fetch its master if we're
checking a merge request done on the upstream repository.
2020-06-29 13:14:40 +01:00
Matthias Clasen
d4ff275002 node-editor: Add a help window
Add a Help item to the gear menu that opens the
node-format.md file in a new window. This could
be improved if we could parse markdown and apply
tags, similar to how we can load pango markup.
2020-06-29 07:36:55 -04:00
Matthias Clasen
2b6f243578 node-editor: Cosmetics
Use a title style class for the labels.
2020-06-29 07:36:55 -04:00
Matthias Clasen
8770584bfb node-editor: Add a gear menu
Add a gear menu with Inspector and About menu items.
2020-06-29 07:36:55 -04:00
Matthias Clasen
4f7f15700c node-editor: Document the node format
Add a markdown file with the documentation of the
node format.

Fixes: #1887
2020-06-29 07:36:55 -04:00
Matthias Clasen
cab6808673 gtk-demo: Fix binary name in --version
We are gtk4-demo, not gtk3-demo.
2020-06-28 23:36:35 -04:00
Matthias Clasen
b77110c35a bitset: Fix documentation syntax 2020-06-28 22:38:23 -04:00
Matthias Clasen
c4e8218f49 bitset: Add more tests
Add some tests for rectangles, and for iters.
2020-06-28 22:38:23 -04:00
Matthias Clasen
c8b57154cb bitset: Correct preconditions in gtk_bitset_add_rectangle
We want to make sure that the rectangle fits in the grid.
2020-06-28 22:38:22 -04:00
Matthias Clasen
c4b2112f16 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #2743

See merge request GNOME/gtk!2161
2020-06-28 23:47:09 +00:00
Matthias Clasen
3132353ec5 ci: Drop one of the focus tests
One of the widget-factory focus tests is flaky in ci,
perhaps due to font changes causing size computations
to go slightly differently.

Drop this for now.
2020-06-28 18:59:48 -04:00
Matthias Clasen
3dc6267146 testsuite: Bump the per-test timeout to 60s
The bitset test has repeatedly run into the 30s timeout
in the ci, so give it some more time.
2020-06-28 17:02:01 -04:00
Matthias Clasen
6a6146a9e0 bitset: Fix the right-shift implementation
This was not doing the right thing at all.

This commit also adds tests for left- and
right-shift.
2020-06-28 16:37:30 -04:00
Matthias Clasen
01fbf8444b Stop setting GTK_IM_MODULE_FILE
GTK no longer reads this environment variable, so
setting it can have no benefit for uninstalled demos
anymore.
2020-06-28 13:42:02 -04:00
Matthias Clasen
1f8c79eca1 Add g_intern_static_string to valgrind suppressions
That function can also trigger a quark table reallocation.
2020-06-28 13:42:02 -04:00
Matthias Clasen
5229069101 widget: Avoid uninitialized access
Initialize all field in the GtkCrossingData struct
when synthesizing crossing events.

Fixes: #2743
2020-06-28 13:42:02 -04:00
Matthias Clasen
a6752bd3e0 gtk: Better help for GTK_DEBUG
Reuse the newly introduced gdk_parse_debug_var for
GTK_DEBUG.
2020-06-28 13:42:02 -04:00
Matthias Clasen
93a51f77c4 gsk: Better help for GSK_DEBUG
Reuse the newly introduced gdk_parse_debug_var for
GSK_DEBUG.
2020-06-28 13:42:02 -04:00
Matthias Clasen
9f2926dde3 gdk: Better help for GDK_DEBUG
Include docstrings and format the list of supported
values better.

Also, add the same warning we have for GTK_DEBUG when
the environment variable is ignored.
2020-06-28 13:42:02 -04:00
Matthias Clasen
d31bb8b503 testsuite: Don't pass GDK_DEBUG for release builds
The debug env vars are ignored in release builds,
and may spew warnings about that fact that break
tests.
2020-06-28 13:42:02 -04:00
Matthias Clasen
d46b04631e wayland: Respect GDK_DEBUG=default-settings
You can get this in other ways for Wayland (by
setting GSETTINGS_BACKEND=memory), but it is better
to be consistent across backends.
2020-06-28 13:42:02 -04:00
Matthias Clasen
30eca5a523 Drop GTK_DEBUG_SHORTCUTS
It is unused.
2020-06-28 13:42:02 -04:00
Matthias Clasen
4fa71fd82a shortcuts: Use GTK_DEBUG_KEYBINDINGS
There was just a single message under GTK_DEBUG_SHORTCUTS.
Consolidate with GTK_DEBUG_KEYBINDINGS.
2020-06-28 13:42:02 -04:00
Matthias Clasen
6819c7c792 docs: Update environment sections
Fix links in markdown, and add details about
Wayland environment variables.
2020-06-28 13:42:01 -04:00
Matthias Clasen
0c9a0dfed1 Merge branch 'print-editor' into 'master'
Install the print editor

See merge request GNOME/gtk!2165
2020-06-28 16:44:32 +00:00
Matthias Clasen
5d9bcfb64a stringlist: Cosmetic documentation fix 2020-06-28 12:43:16 -04:00
Matthias Clasen
7047d68404 gtk: Add some missing symbols to the docs 2020-06-28 12:43:16 -04:00
Matthias Clasen
334f95479b sorter: Some doc corrections
The docs were referring to some non-existing enum value.
Fix things up to match the current code.
2020-06-28 12:43:11 -04:00
Matthias Clasen
9dff4d6ff3 stack: Remove nonexisting api from headers
The homogeneous property was dropped a while ago.
2020-06-28 12:43:11 -04:00
Matthias Clasen
4d7d031ee0 gdk: Small documentation fixes
Make sure gdk_event_get_seat shows up.
2020-06-28 12:24:03 -04:00
Matthias Clasen
7c98af6358 stack: Cosmetic documentation fixes
Fix parameter mismatches.
2020-06-28 12:23:52 -04:00
Matthias Clasen
ddcba4d33f bitset: Cosmetic documentation changes 2020-06-28 12:23:52 -04:00
Matthias Clasen
59fe4a3a09 printeditor: Add desktop file and appdata
All our installed demos have this.
2020-06-28 10:51:16 -04:00
Matthias Clasen
6774f36636 print-editor: Allow opening files
Since it calls itself an editor, it should really
support opening files on the commandline.
2020-06-28 10:51:16 -04:00
Matthias Clasen
608cbc28af printeditor: Cosmetics
Bring this up to our standards for an installable demo,
by touching up the about dialog and menus.
2020-06-28 10:51:16 -04:00
Emmanuele Bassi
117c71faeb Merge branch 'issue-2900' into 'master'
Nullable this_ argument in gtk_expression_bind()

Closes #2900

See merge request GNOME/gtk!2163
2020-06-28 13:28:52 +00:00
Emmanuele Bassi
24d6a190af Add pre-condition check on nullable argument
Even if `gtk_expression_watch()` will do the same, we're calling public
API, so we should perform a check at the point of use, to ensure that
warnings are easily debuggable.
2020-06-28 13:42:03 +01:00
Emmanuele Bassi
6a4b5ead86 Annotate nullable argument
The `this_` argument is passed to `gtk_expression_watch()`, which
accepts it as nullable.

Fixes: #2900
2020-06-28 13:41:54 +01:00
Matthias Clasen
674ede8665 docs: Remove ancient version information
We treat 4.0 as a new era.
2020-06-27 21:46:22 -04:00
Matthias Clasen
8a269de89a multiselection: Update docs
Remove information that is no longer true. GtkMultiSelection
is persistent across sorting changes since 3d8b6f6b79.
2020-06-27 21:40:26 -04:00
Matthias Clasen
ace4eac25a Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2160
2020-06-27 22:19:27 +00:00
Matthias Clasen
66bce08d10 docs: Migration guide additions 2020-06-27 17:38:10 -04:00
Matthias Clasen
65902367c6 builder: Documentation tweaks
Don't use no-longer-existing enums as examples,
and drop the +.
2020-06-27 17:28:15 -04:00
Matthias Clasen
8f0b92e42d Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2159
2020-06-27 19:43:18 +00:00
Baurzhan Muftakhidinov
f3d5f6628d Update Kazakh translation 2020-06-27 19:11:12 +00:00
Baurzhan Muftakhidinov
4d687366ed Update Kazakh translation 2020-06-27 18:52:16 +00:00
Matthias Clasen
3aa5019e70 gtk-demo: Drop an unused object
The main ui file was still creating a tree store,
but we've switched everything over to use list models.
2020-06-27 09:47:29 -04:00
Matthias Clasen
4fb495d0fe builder: Warn about dropped objects
Use GTK_DEBUG=builder-objects to make GtkBuilder warn
if a named object from a ui files doesn't get claimed
by gtk_builder_get_object(). This is useful for finding
dead wood in .ui files.
2020-06-27 09:47:00 -04:00
Matthias Clasen
c447fa8442 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #2897 and #2898

See merge request GNOME/gtk!2158
2020-06-27 03:51:21 +00:00
Matthias Clasen
3a70ca9d03 listitem: Correct the docs 2020-06-26 23:10:21 -04:00
Matthias Clasen
5d11e9812d gtk-demo: Improve formatting in the color demo
Properly align and format the numbers in the size
dropdown.
2020-06-26 22:57:56 -04:00
Matthias Clasen
0d10982379 text: Support reverse selection
Take ordering of cursor_position and selection_bound
into account when copying text to the clipboard, and
ensure that both orders work the same.

Fixes: #2898
2020-06-26 22:22:47 -04:00
Matthias Clasen
c20a966f06 text: Update action enabled state correctly
Take the editable property into account when updating
the emoji.insert action state, and update the action
when it changes.

Fixes: #2897
2020-06-26 22:13:12 -04:00
Matthias Clasen
64db05d3dd shortcutcontroller: Add some debug spew
This helps in debugging event routing and keyboard
shortcut issues.
2020-06-26 22:12:42 -04:00
Matthias Clasen
913cd91df0 widget: Fix an oversight
g_message comes with a builtin newline, don't add one
to the message.
2020-06-26 22:12:14 -04:00
Matthias Clasen
2c5533589d Merge branch 'matthiasc/for-master' into 'master'
Adwaita: Fix block cursors in spinbuttons

Closes #2871

See merge request GNOME/gtk!2156
2020-06-27 00:35:51 +00:00
Matthias Clasen
cfdc81af02 Adwaita: Fix block cursors in spinbuttons
Fix block cursors in vertical spinbuttons with Adwaita.

Fixes: #2871
2020-06-26 19:56:10 -04:00
Matthias Clasen
7fa8a69fdc Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #2869

See merge request GNOME/gtk!2155
2020-06-26 21:14:27 +00:00
Matthias Clasen
fd2861d683 docs: Add css docs to entries
The various entries were missing the semi-standard
"CSS Nodes" section in their long descriptions. Add
them.
2020-06-26 16:13:02 -04:00
Matthias Clasen
cd9f5733b3 text: Be more selective when selecting on focus-in
We don't want to select on focus-in when the focus
comes from a child. The case where this does harm
is when you activate copy or paste actions from the
context menu. We close the menu before triggering the
action, and if that causes the text in the entry to
be selected, unexpected things happen, since the action
applies to the current selection.

Fixes: #2869
2020-06-26 15:49:39 -04:00
Matthias Clasen
8b4560cbfb Revert "text: Avoid creating a PangoAttrList we don't need"
This reverts commit 67c2665028.

The splicing we do here has the important side-effect
of shifting the preedit attributes to the right position.
Without it, we end up always underlining the first chars
in the entry, regardless where the preedit happens.
2020-06-26 15:27:17 -04:00
Matthias Clasen
2d914d52be text: Handle key events in the target phase
This makes sure that we do actual key input right
in the middle between all the capture and bubble
event controllers, and are not dependent on the
ordering of those controllers.

The bug that triggered this change was that the
shortcut for activation (Enter) was getting triggered
before the key input, causing Ctrl-Shift-u hex
to stop working, since it never received the enter
to commit the sequence.
2020-06-26 14:08:35 -04:00
Matthias Clasen
a26865e741 widget: Add a debug message for consumed key events
Run the application with GTK_DEBUG=keybindings to
get some hints where key events get lost.
2020-06-26 14:08:14 -04:00
Matthias Clasen
3558beaa61 text: Give names to event controllers
It helps with debugging.
2020-06-26 14:08:11 -04:00
Matthias Clasen
9b9a9f14e2 Merge branch 'wip/carlosg/sequence-state-fixups' into 'master'
Fixups to gesture sequence states

Closes #2895

See merge request GNOME/gtk!2154
2020-06-26 17:08:09 +00:00
Carlos Garnacho
0ce4f66976 gtktext: Don't accept (twice!) all press actions
The gesture should claim the sequence after triggering uncancellable
actions, like pasting, showing a menu or selecting words/lines. A
single first button press initiating a drag does not trigger
anything yet, so it should avoid claiming the sequence.
2020-06-26 17:48:10 +02:00
Carlos Garnacho
b81bbde7c8 gtkswitch: Don't be eager in accepting the gesture
The gesture should be accepted whenever it triggers uncancellable
actions in the widget. This means it should be accepted if the
click does result in toggling the switch.

This leaves the pan gesture room to handle dragging the handle.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2895
2020-06-26 17:48:10 +02:00
Matthias Clasen
3f55bfe2cb Merge branch 'matthiasc/for-master' into 'master'
main: Avoid a warning

Closes #2894

See merge request GNOME/gtk!2153
2020-06-26 14:31:20 +00:00
Matthias Clasen
4185ba242b docs: Some tweaks to the list widget overview 2020-06-26 09:05:56 -04:00
Matthias Clasen
e04191a5ea Merge branch 'wip/otte/bitset' into 'master'
Improve selection handling API for rubberbanding

See merge request GNOME/gtk!2086
2020-06-26 12:43:49 +00:00
Matthias Clasen
f07d304f19 main: Avoid a warning
transient-for relationships only exist between
windows, so check that both candidates are such.

Fixes: #2894
2020-06-26 08:19:32 -04:00
Emmanuele Bassi
1d1f618a13 Merge branch 'tintou/dropdown-annotations' into 'master'
dropdown: Annotate the get_selected_item method

See merge request GNOME/gtk!2152
2020-06-26 08:48:51 +00:00
Emmanuele Bassi
e20610cdc6 Merge branch 'wip/ricotz/annotations' into 'master'
gtk: Add some g-i annotations to GtkStringList

See merge request GNOME/gtk!2150
2020-06-26 08:46:35 +00:00
Corentin Noël
721396b6d6 dropdown: Annotate the get_selected_item method
We need to specify the type as we already know that it is at least a GObject and in case of no selection, NULL is returned.
2020-06-26 10:00:59 +02:00
Benjamin Otte
dc1dbe6158 listbase: Make rubberbanding a threshold drag 2020-06-26 07:13:32 +02:00
Benjamin Otte
30488e60e2 listbase: Only compute the modifiers when releasing the rubberband
... and do the right things:

nothing:    selection = rubberband
ctrl:       selection = selection OR rubberband
shift:      selection = selection AND (NOT rubberband)
ctrl+shift: selection = selection XOR rubberband
            (not sure this one makes sense, but toggling is fun)
2020-06-26 07:13:32 +02:00
Benjamin Otte
a5949960bc listbase: Compute rubberband region on-demand
Instead of storing the active items as we go, compute the affected items
whenever the rubberband changes and in particular when the rubberband
ends.
That way, the rubberband is guaranteed to select a rectangle even
after scrolling very far.

This is achieved by having a get_items_in_rect() vfunc that selects all
the items in the rubberbanded rectangle and returns them as a bitset.
2020-06-26 07:13:32 +02:00
Benjamin Otte
ec4a489093 listview: Allocate rubberband at end of size_allocate()
Otherwise the rubberband uses the wrong scroll offsets.
2020-06-26 07:13:32 +02:00
Benjamin Otte
7c52e03815 listbase: Flip autoscroll deltas if adjustments are flipped
Fixes autoscroll on RTL languages.
2020-06-26 07:13:32 +02:00
Benjamin Otte
724c9361f3 listbase: Allocate gridview items properly on RTL
We need to flip the items.
2020-06-26 07:13:32 +02:00
Benjamin Otte
147388e69a multiselection: Implement get_selection_in_range() 2020-06-26 07:13:32 +02:00
Benjamin Otte
64aa281c97 listbase: Allocate rubberband according to list coords
The rubberband is now handled on the list coordinate system.

When starting the rubberband, we track the item under the pointer and
follow it when it is moving.
This may lead to the rubberband start position changing position and
while this may be confusing, it alerts users to the fact that something
crazy is going on.
2020-06-26 07:13:32 +02:00
Benjamin Otte
c2b0330c56 listbase: Move a common function from the children into GtkListBase
We want to use it for the rubberband later.
2020-06-26 07:13:32 +02:00
Benjamin Otte
de4803bb21 listbase: Don't do extra work
Scrolling causes a queue_resize() which will update the rubberband in
size_allocate() and queue a draw.
2020-06-26 07:13:32 +02:00
Benjamin Otte
e574dcb091 Fix indentation 2020-06-26 07:13:32 +02:00
Benjamin Otte
488b0cbb69 gtk: Remove GtkPropertySelection
GtkMultiSelection is so much faster than this that it isn't needed.
2020-06-26 07:13:32 +02:00
Benjamin Otte
6ceab55148 gtk-demo: Port listview-colors demo to multiselection again 2020-06-26 07:13:32 +02:00
Benjamin Otte
3d8b6f6b79 multiselection: Track items across resorts
In particular, track which items remain in ::items-changed
signal emissions.

But the main use case is sorting, which causes items-changed(0, n, n)
to be emitted.
2020-06-26 07:13:32 +02:00
Benjamin Otte
58d3213eef Remove GtkSet
It's been superceded by GtkBitset.
2020-06-26 07:13:32 +02:00
Benjamin Otte
006dfdc55a selectionmodel: Remove select_callback() functions
gtk_selection_model_set_selection() takes care of those now.
2020-06-26 07:13:32 +02:00
Benjamin Otte
a38c423ddb listbase: Port rubberband to gtk_selection_model_set_selection() 2020-06-26 07:13:32 +02:00
Benjamin Otte
fa0295629b selectionmodel: Add gtk_selection_model_set_selection()
Also port the testsuite.
2020-06-26 07:13:32 +02:00
Benjamin Otte
8395698090 selectionmodel: Replace query_range() with get_selection() 2020-06-26 07:13:32 +02:00
Benjamin Otte
277a91dbf8 multiselection: Port to GtkBitset 2020-06-26 07:13:32 +02:00
Benjamin Otte
ff36cfb5be testsuite: Add tests for GtkBitset 2020-06-26 07:13:32 +02:00
Benjamin Otte
db452f0c45 Add GtkBitset 2020-06-26 07:13:32 +02:00
Rico Tzschichholz
5b1195f874 gtk: Add some g-i annotations to GtkStringList 2020-06-26 06:36:23 +02:00
Benjamin Otte
d830724d4f Add amalgamated roaring bitmaps source code
Taken from https://github.com/RoaringBitmap/CRoaring and fixed to
not spew warnings.
2020-06-26 06:19:56 +02:00
Matthias Clasen
0ef0edfa9a Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2149
2020-06-25 22:28:07 +00:00
Matthias Clasen
0ec868bd69 inspector: Adapt to dropdown api change
The suppported syntax for dropdowns in ui files
has changed. Get with the program.
2020-06-25 16:42:30 -04:00
Matthias Clasen
30e79e8412 docs: Fix a typo 2020-06-25 14:29:24 -04:00
Matthias Clasen
c9b032acab gtk-demo: Fix a typo in the listbox demo 2020-06-25 14:28:29 -04:00
Matthias Clasen
1f410faccb searchentry: Update the docs slightly
Update the docs to get closer to describing reality.
2020-06-25 14:27:44 -04:00
Matthias Clasen
d0e56106fe Drop unused includes
Don't include gtkfilechooserentry.h where it
isn't used.
2020-06-25 14:27:31 -04:00
Matthias Clasen
3d3d7dbc59 stringfilter: Fix a typo 2020-06-25 14:27:23 -04:00
Emin Tufan Çetin
c0cbf9db5f Update Turkish translation 2020-06-25 01:05:12 +00:00
Matthias Clasen
db82eaec0a Merge branch 'wip/carlosg/input-cleanups' into 'master'
Some input cleanups

Closes #2851

See merge request GNOME/gtk!2147
2020-06-24 21:32:30 +00:00
Matthias Clasen
f4e200708d Merge branch 'scrolled-window-api' into 'master'
scrolledwindow: Don't take adjustments in new()

See merge request GNOME/gtk!2146
2020-06-24 19:58:03 +00:00
Matthias Clasen
ba1944ded2 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2145
2020-06-24 19:50:37 +00:00
Carlos Garnacho
8eeef54b2e gtktextview: Remove child textview items last
The function tries to go through every child, so it's convenient
to remove all internal ones first.
2020-06-24 20:35:23 +02:00
Carlos Garnacho
8e549d73a0 gtkwidget: Drop _gtk_widget_[gs]et_shadowed()
This API is meaningless now, with grab-notify being handled internally.
2020-06-24 20:35:23 +02:00
Carlos Garnacho
102d2a36f3 gtkwidget: Avoid use of shadowed flag
This is going away, look up whether there is a grab, and whether
the widget is within it, instead.
2020-06-24 20:35:23 +02:00
Carlos Garnacho
f046e27bb4 gtkwidget: Drop gtk_widget_device_is_shadowed()
A widget no longer needs updating on GTK grabs on itself, drop
this miscellaneous and no longer used API.
2020-06-24 20:35:23 +02:00
Carlos Garnacho
1c5cf17f1c gtkwidget: Drop internal checks in grab-notify
There's no need to check if the widget is already shadowed, we
implicitly have that from the signal argument.
2020-06-24 20:35:23 +02:00
Carlos Garnacho
ddb3a4be3e gtkmain: Make grab-notify notifications more targeted
We only want to send grab-notify to widgets that might have been
interacting with devices via events. Instead of going through all
widgets in all toplevels, we have the window/pointer focus information,
so we can just traverse the widget stacks for every involved foci.
2020-06-24 20:35:23 +02:00
Carlos Garnacho
994f32704b gtkwidget: Drop ::grab-notify signal and vfunc
We don't expect widgets to react directly to these anymore.
Internally we still reset the controllers.
2020-06-24 20:35:23 +02:00
Carlos Garnacho
1f798643c8 gtkprintoperation-win32: Don't track grab-notify
Further grabs could presumably only come from events handled within
the dialog itself. It seems overeager to do this.
2020-06-24 20:35:23 +02:00
Carlos Garnacho
2f8d5e2dcd gtkvideo: Track child focus to determine whether controls should autohide
Move away from grab_notify, and use the set_child_focus() vfunc to track
child widgets being set the keyboard focus. This is not 1:1, but seems
good enough at the moment.
2020-06-24 20:35:22 +02:00
Carlos Garnacho
df30741535 gtkbutton: Drop grab_notify handler
The click gesture already has a ::cancel handler, and does almost
everything it should. Move the last bits and remove the grab_notify
handler.
2020-06-24 20:35:22 +02:00
Carlos Garnacho
762748028a gtkspinbutton: Drop grab_notify handler
The press gesture on the buttons already has a ::cancel handler,
this is redundant.
2020-06-24 20:35:22 +02:00
Carlos Garnacho
f7c5cf137c gtknotebook: Move away from grab_notify
Connect to ::cancel on the relevant gesture instead.
2020-06-24 20:35:22 +02:00
Matthias Clasen
455d91b0fc testgtk: Update list of cursor names
Use the standard names, since that is what we want
everybody else to use too.
2020-06-24 14:06:50 -04:00
Matthias Clasen
e834e51c0f Install gtkstringlist.h 2020-06-24 13:02:50 -04:00
Matthias Clasen
bce518b214 entrycompletion: Various fixes
Fix various issues that prevented inline completion
and inline selection from working reliably. We were
passing byte counts to gtk_editable_select_region in
one place, but that function expects char counts.
We were listening for GtkEditable::insert-text on
the GtkText widget, but that does not emit those signals,
so listen for GtkEntryBuffer::inserted-text instead.
Finally, we were not clearing the stored completion_prefix
enough, leading to situations where the stored prefix
does not match the text in the entry anymore.
2020-06-24 13:02:50 -04:00
Matthias Clasen
3656994f82 gtk-demo: Enable inline completion
Enable inline completion in the entry completion
demo, to have some code exercising this feature.
It is broken.
2020-06-24 13:02:50 -04:00
Matthias Clasen
fd5f6ef57f gtk-demo: Improve the entry completion demo
Add more strings.
2020-06-24 13:02:50 -04:00
Matthias Clasen
386b63b85d scrolledwindow: Don't take adjustments in new()
In 99.9% of all cases, these are just NULL, NULL.
So just do away with these arguments, people can
use the setters for the rare cases where they want
the scrolled window to use a different adjustment.
2020-06-24 11:25:09 -04:00
Carlos Garnacho
803103640a gtkwindowhandle: Drop has-grab checks
While it's worth thinking about bringing the "windows can be dragged
with open popovers" behavior back, this does not kick in anymore, nor
should be the way to handle this given all the autoclose surface
semantic changes.
2020-06-24 13:41:28 +02:00
Carlos Garnacho
469a4a73f9 gdk: Drop gdk_device_get_last_event_surface()
This kind of transient state sets the expectative that events update
devices, while it's more accurate to say that devices generate events.
It does not make to expose this function anymore.
2020-06-24 11:24:04 +02:00
Carlos Garnacho
f401b05e7b gtkwidget: Avoid poking surfaces and events in gtk_widget_list_devices()
This got stuck in ancient times when widgets were windowed, so the devices
in a window to know the devices in that widget would pan out. We do only
want here the devices that are inside the widget, not spread over the
surface, so rewrite this helper function to poke the toplevel foci, and
look they are contained inside the widget.
2020-06-24 11:14:52 +02:00
Carlos Garnacho
42ed8a2748 gtkwidget: Drop _gtk_widget_get_device_surface()
A widget cannot have multiple surfaces anymore, nor needs to
fetch the last event surface as it ought to handle its own.
2020-06-24 10:47:15 +02:00
Carlos Garnacho
f872eb64b5 gtkmain: Drop unused struct field
Grabs are, ironically, not about devices anymore. This struct field
is never set.
2020-06-24 10:47:15 +02:00
Carlos Garnacho
29d054c421 gtkwidget: Remove dead code
This variable got unused over time.
2020-06-24 10:47:15 +02:00
Carlos Garnacho
7be6afe84d gdk: Depend less on gdk_event_get_device()
For the most part, we are interested in seats here.
2020-06-23 23:42:53 +02:00
Carlos Garnacho
cf1fbdf8b5 gdk: Add gdk_event_get_seat()
It currently fetches the seat from the event device, will be changed
in future commits.
2020-06-23 23:42:53 +02:00
Carlos Garnacho
6d2860efb7 gdk: Drop gdk_seat_get_logical_pointers()
Events come from hardware devices and are handled by controllers,
there's no need to use logical pointers, nor to peek them. Drop this
unused API.
2020-06-23 23:42:53 +02:00
Carlos Garnacho
5f29b8fcec gdk: Drop GdkGrabOwnership
We no longer expose such low level tweaks, this is essentially
unused.
2020-06-23 23:42:53 +02:00
Carlos Garnacho
59a8106373 gdk: Drop supports_multidevice API
Crossing events are now detached from widget state, all tricky consequences
from getting multiple crossing events are now somewhat moot. Resort to sending
all generated crossing events, and drop this barely (ever?) used API.
2020-06-23 23:42:53 +02:00
Carlos Garnacho
c1d90273ca gdk: Drop GDK_SOURCE_ERASER
All tools come from devices with GDK_SOURCE_PEN.
2020-06-23 23:42:53 +02:00
Carlos Garnacho
31b95ce47f gtkmain: Look up transient-for hierarchies to determine modality
Windows that are not modal, but are transient-for a modal window should
still be able to receive and handle events. Inspect the window hierarchy
in those cases, so these windows are handled just like widgets within
the modal dialog.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2851
Related: https://gitlab.gnome.org/GNOME/gtk/-/issues/2850
2020-06-23 23:42:53 +02:00
Carlos Garnacho
4fe608e423 gtkwidget: Cancel all gestures in other groups
When a gesture (group) claims a sequence, all other gesture groups
in the same widget should get cancelled. Not just previously claimed
ones, that shouldn't happen actually.
2020-06-23 23:42:53 +02:00
Matthias Clasen
2cfeb1048c Merge branch 'stringlist' into 'master'
add a public stringlist api

See merge request GNOME/gtk!2134
2020-06-23 20:43:49 +00:00
Matthias Clasen
e8210d5865 Add GtkStringList as public api
This is a list model holding strings, initialized
from a char **. String lists are buildable as well,
and that replaces the buildable support in GktDropDowns.
2020-06-23 16:11:46 -04:00
Matthias Clasen
fff981b220 Merge branch 'wip/jimmac/notebook-legibility' into 'master'
Adwaita: notebook legibility fixes

Closes #2652

See merge request GNOME/gtk!2142
2020-06-23 19:12:52 +00:00
Matthias Clasen
a3f4caa291 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2141
2020-06-23 19:10:54 +00:00
Jakub Steiner
ec54399d89 Adwaita: notebook legibility fixes
- make inactive tabs more legible

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/2652
2020-06-23 19:54:54 +02:00
Matthias Clasen
83f22fcce2 Add a few missing includes
These sources are using GtkListStore apis,
but were replying on indirect includes to
get the header. Make this explicit, to prepare
for GtkEntryCompletion losing its tree view
dependencies.
2020-06-23 07:55:53 -04:00
Matthias Clasen
34a12f47f1 entry completion: Drop the Private struct
This is in preparation for porting GtkEntryCompletion
to use GtkListView.
2020-06-23 07:55:38 -04:00
Ray Strode
518462d882 Merge branch 'wip/fencing-without-context-is-discouraged' into 'master'
x11: Ensure bound context is compatible with sync fence

See merge request GNOME/gtk!2139
2020-06-23 09:53:35 +00:00
Ray Strode
1912513d7a x11: Ensure bound context is compatible with sync fence
Commit a0f6ff101e made sure that a
context was bound before calling glClientWaitSync, but it doesn't
check that the context shares objects with the context that created
the fence.

This commit does a little more validation before deciding the current
context is good enough.
2020-06-22 19:09:43 -04:00
Matthias Clasen
1643e81c47 Merge branch 'wip/fencing-without-context-is-discouraged' into 'master'
x11: ensure some context is bound before calling glClientWaitSync

See merge request GNOME/gtk!2138
2020-06-22 23:01:11 +00:00
Matthias Clasen
7ff427b456 Merge branch 'drop-entry-completion-actions' into 'master'
entrycompletion: Drop action support

See merge request GNOME/gtk!2136
2020-06-22 22:59:17 +00:00
Matthias Clasen
91a96d27f1 Merge branch 'matthiasc/for-master' into 'master'
Add a basic clipboard test

See merge request GNOME/gtk!2137
2020-06-22 22:13:30 +00:00
Ray Strode
a0f6ff101e x11: ensure some context is bound before calling glClientWaitSync
Since commit 972134abe4 we now call
glClientWaitSync for the vendor nvidia driver, to know when a frame
is ready for the compositor to process.

glClientWaitSync can be called regardless of which context is currently
bound, but if no context is bound at all, it returns 0 without
doing anything.

This commit checks for that edge case, and ensures a context gets
made current in the event no context is already current, before calling
glClientWaitSync.
2020-06-22 17:13:54 -04:00
Matthias Clasen
9bcf401ef7 Add a basic clipboard test
This is not reproducing the failure I'm after, unfortunately.
2020-06-22 16:55:01 -04:00
Matthias Clasen
67a7ad069f entrycompletion: Drop action support
This api has not really been kept up with current
user experiences in popups, and we're better off
just dropping it and letting people do their own
popups if they need custom UI.
2020-06-22 14:43:36 -04:00
Matthias Clasen
367d24be7f Merge branch 'keyval-to-uni-fix' into 'master'
gdk: Make gdk_keyval_to_unicode platform-independent

See merge request GNOME/gtk!2132
2020-06-22 18:13:25 +00:00
Matthias Clasen
1791c637d0 Merge branch 'fix-entry-completion' into 'master'
Fix entry completion

See merge request GNOME/gtk!2135
2020-06-22 17:56:43 +00:00
Matthias Clasen
c6fe8818ed gdk: Clarify the docs of gdk_keyval_to_unicode
Explicitly state that the conversion does not
take locale into account, and point out GDK_KEY_KP_Decimal
as a candidate for special-casing.
2020-06-22 13:24:34 -04:00
Matthias Clasen
53a30eaa12 entry completion: Make keynav work again
Use gtk_widget_prepend_controller to supersede entry keynav
while the popup is open. This fixes selecting completions
with the keyboard - the Enter keypress was ending up
triggering GtkText::activate instead of inserting the
selected completion into the entry.
2020-06-22 12:48:42 -04:00
Matthias Clasen
692cc42e10 Add gtk_widget_prepend_controller
Add a variant of gtk_widget_add_controller that
inserts the controller at the beginning, instead
of the end. This will be used in entry completion
to make sure the entry completion key event handling
supersedes the entry one while the popup is open.

Keep this private for now, until we determine if
it needs to be public api.
2020-06-22 12:47:27 -04:00
Matthias Clasen
9faaa5e8be Fix change notification for event controllers
We were adding event controllers at the end, but
announcing a change at the beginning, in
gtk_widget_add_controller. Fix that by emitting
::items-changed for the position where we actually
inserted the controller.
2020-06-22 12:46:12 -04:00
Matthias Clasen
418bbb2685 entrycompletion: Name the controllers
This helps with debugging.
2020-06-22 12:31:15 -04:00
Matthias Clasen
fb148027d9 Merge branch 'wip/dont-assert-without-evidence' into 'master'
x11: be more verbose when glClientWaitSync behaves unexpectedtly

See merge request GNOME/gtk!2133
2020-06-22 15:47:27 +00:00
Ray Strode
05736afaf8 x11: be more verbose when glClientWaitSync behaves unexpectedtly
When given a 0 timeout, glClientWaitSync is only supposed to return one
of three possible values:

 - GL_ALREADY_SIGNALED - fence fired
 - GL_WAIT_FAILED - there was an error
 - GL_TIMEOUT_EXPIRED - fence hasn't fired yet

In addition, it can also return GL_CONDITION_SATISFIED if a non-zero
timeout is passed, and the fence fires while waiting on the timeout.

Since commit 972134abe4 we now call
glClientWaitSync (with a 0 timeout), but one user is reporting it's
returning some value that's not one of the above four.

This commit changes the g_assert to a g_error so we can see what
value is getting returned.

May help with https://gitlab.gnome.org/GNOME/gtk/-/issues/2858
2020-06-22 11:16:32 -04:00
Matthias Clasen
8a91d1d1ce Merge branch 'matthiasc/for-master' into 'master'
gtk-demo: Add a warning to the colors demo

See merge request GNOME/gtk!2131
2020-06-22 13:11:13 +00:00
Matthias Clasen
2df139cf40 gdk: Make gdk_keyval_to_unicode platform-independent
The result of gdk_keyval_to_unicode should not depend
on the platform.
2020-06-22 08:31:10 -04:00
Timm Bäder
9f1208b595 Merge branch 'master.msvc' into 'master'
demos: Fix builds against Visual Studio headers

See merge request GNOME/gtk!2130
2020-06-22 12:02:26 +00:00
Matthias Clasen
9fd3212241 gtk-demo: Add a warning to the colors demo
Explain that the big sizes cause lockups.
2020-06-22 07:43:47 -04:00
Chun-wei Fan
293f2e6b1c demos: Fix builds against Visual Studio headers
According to [1], '_timezone' is already used for a global variable in the
time.h system header that is supplied by Microsoft, so using that for our
variable name when we are including time.h either directly or indirectly
will cause trouble.

This renames such variables to '_tz' to avoid that

[1]: https://docs.microsoft.com/en-us/cpp/c-runtime-library/daylight-dstbias-timezone-and-tzname
2020-06-22 17:04:18 +08:00
Matthias Clasen
f83aa16f59 Merge branch 'port-icon-browser' into 'master'
Port icon browser

See merge request GNOME/gtk!2127
2020-06-22 00:09:00 +00:00
Matthias Clasen
c73dd9ecaf Merge branch 'matthiasc/for-master' into 'master'
filter: Make GtkEveryFilter buildable

See merge request GNOME/gtk!2125
2020-06-21 17:57:31 +00:00
Matthias Clasen
607f08e79b Port the icon browser to GtkGridView 2020-06-21 13:36:57 -04:00
Matthias Clasen
511e5f39fa filter: Make GtkEveryFilter buildable
Due to an oversight, when multi filters were split into
any and every, any ended up with the listmodel and buildable
implementations, and every didn't get any.

Move the implementations up.
2020-06-21 13:10:18 -04:00
Matthias Clasen
7d409dd2e0 Merge branch 'wip/otte/listview-colors' into 'master'
Improve listview-colors demo

See merge request GNOME/gtk!2123
2020-06-21 12:49:49 +00:00
Matthias Clasen
9b8c0f3c7f gtk-demo: Cosmetic improvement to the colors demo
Make the count label not jump around, as the model
is refilled.
2020-06-21 14:17:47 +02:00
Benjamin Otte
727a78a74f gtk-demo: Add an "Unsorted" option (and default to it)
Tests the previous commit and ensures that selecting 16M colors actually
works quickly (it does).
2020-06-21 14:17:47 +02:00
Benjamin Otte
a928ea6c57 sortlistmodel: Look at order
For now, we just look at SORT_ORDER_NONE to bypass any sorting.
2020-06-21 14:17:47 +02:00
Benjamin Otte
d3f7dea624 gtk-demo: Reinstate incremental filling
Do it via the new size setting on the color list.

Also add an option to set the maximum size of the color list that it'll
be filled to so rudimentary performance testing is possible.

Hint: Do not select 16777216.

This reinstates commit c16848c2bb683f7ddf51571aa5951f8a4a1ea622.
2020-06-21 14:17:47 +02:00
Benjamin Otte
456b7628ee gtk-demo: Allow color list to have any size
For now, limit it to 1<<12 so the sorters don't explode.
2020-06-21 14:17:47 +02:00
Benjamin Otte
f149beb474 gtk-demo: Add a permutation to compute colors from the position
This way, the colors are furthest apart at the start and fill up the
remaining spots towards the end.
2020-06-21 14:17:47 +02:00
Benjamin Otte
1b0451761a gtk-demo: Add custom listmodel for all true colors. 2020-06-21 14:17:47 +02:00
Benjamin Otte
1d26341b03 gtk-demo: Make colors demo contain all 16,777,216 colors
This makes it slightly slow, so not sure it should stay like this.
2020-06-21 14:17:47 +02:00
Benjamin Otte
8348a113c6 gtk-demo: Compute HSV values directly 2020-06-21 14:17:47 +02:00
Benjamin Otte
bfdede7acc Revert "gtk-demo: Make the colors demo populate incrementally"
This eases adding a bunch of follow-up features. After those features
have landed, this functionality will be readded.

This reverts commit a10340859d.
2020-06-21 14:17:47 +02:00
Benjamin Otte
70894b48af gtk-demo: Embed the RGBA value 2020-06-21 14:17:47 +02:00
Aurimas Černius
b0c6b282fd Updated Lithuanian translation 2020-06-21 14:47:05 +03:00
Piotr Drąg
393054dd3f Update Polish translation 2020-06-21 11:37:46 +02:00
Matthias Clasen
97b10df723 Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master

See merge request GNOME/gtk!2122
2020-06-21 05:58:15 +00:00
Matthias Clasen
62b214ffdf filechooserwidget: Use gtk_drop_down_get_selected_item
This showed up as a test failure when we get NULL as
selected item and then try to unref it. Luckily
get_selected_item is transfer none, so we don't have
to worry about it.
2020-06-21 01:20:05 -04:00
Benjamin Otte
3549f43902 demo: Use GtkDropDown::selected-item 2020-06-21 02:23:46 +02:00
Benjamin Otte
45167d5c0d dropdown: emit notify for selected from the changed callback
Otherwise we don't emit it when the selection itself changes it - for
exaple because the model changed.
2020-06-21 02:23:46 +02:00
Matthias Clasen
0214b98c5e Merge branch 'matthiasc/for-master' into 'master'
misc listview scrolling fixes

See merge request GNOME/gtk!2119
2020-06-20 21:21:29 +00:00
Matthias Clasen
19c38158fc Merge branch 'incremental-colors' into 'master'
Incremental colors demo

See merge request GNOME/gtk!2121
2020-06-20 20:35:23 +00:00
Matthias Clasen
7ff35340ca Merge branch 'drop-down-selected-item' into 'master'
dropdown: Add GtkDropDown:selected-item

Closes #2861

See merge request GNOME/gtk!2120
2020-06-20 18:51:18 +00:00
Matthias Clasen
a10340859d gtk-demo: Make the colors demo populate incrementally
Add a refill button that incrementally refills the color
demo. This is useful to test how the grid view operates
when the model is frequently changed.
2020-06-20 14:47:57 -04:00
Matthias Clasen
8475d88af0 gtk-demo: Clean up initial selection handling
We call selection_cb now, so we don't need to manually
do part of what that call does ahead of time.

This should have been noticed in 10bcbae68c.
2020-06-20 14:47:39 -04:00
Matthias Clasen
79b1d24128 Merge branch 'gtk4-arb_fbo' into 'master'
Switch to GL_ARB_framebuffer_object

See merge request GNOME/gtk!2079
2020-06-20 17:12:52 +00:00
Matthias Clasen
ad98e72884 dropdown: Add GtkDropDown:selected-item
This is the same readonly property we have in
GtkSingleSelection.

Fixes: #2861
2020-06-20 13:11:48 -04:00
Matthias Clasen
3fab2b55cc gtk-demo: Clean up memory handling in the weather demo
gtk_weather_info_new was consuming the info, but not
the timestamp, which confused me. Make it not consume
either, and be more explicit about where the unrefs
happen.
2020-06-20 12:18:17 -04:00
Matthias Clasen
2842030e59 gridview: Don't assert on a condition that can happen
We are currently not robust against model changes or
widget invalidations, so we can actually end up in
situations where we run out of items here. Handle
the failure a bit more gracefully, by returning NULL.

This is good enough to make scrolling work okish most
of the time. We still need a proper fix to handle
other situations.
2020-06-20 12:11:59 -04:00
Benjamin Otte
7c2d21892f gridview: Compute right amount of items to skip
We only want to skip the remaining items in the current row, not since
the start of the widget.
2020-06-20 12:08:46 -04:00
Matthias Clasen
677bfe6857 gtk-demo: Clean up initial selection handling
We call selection_cb now, so we don't need to manually
do part of what that call does ahead of time.

This should have been noticed in 10bcbae68c.
2020-06-20 08:48:29 -04:00
Matthias Clasen
b7ddf0b2e5 Merge branch 'dnd-demo-animation' into 'master'
gtk-demo: Add animated icons to the dnd demo

See merge request GNOME/gtk!2117
2020-06-19 23:57:47 +00:00
Matthias Clasen
eb25fc1d5a gtk-demo: Add animated icons to the dnd demo
This is to test animated drag icons.
2020-06-19 19:26:43 -04:00
Matthias Clasen
395d40485d Merge branch 'listview-dnd' into 'master'
Listview dnd

See merge request GNOME/gtk!2116
2020-06-19 22:24:36 +00:00
Matthias Clasen
17af979b24 testlistdnd: Use editable labels
Use editable labels instead of entries, and write
changes back to the model.
2020-06-19 16:30:25 -04:00
Matthias Clasen
8511f25b97 editablelabel: Allow to drag text
If we allow editing, we should allow direct drags too.
2020-06-19 15:26:53 -04:00
Matthias Clasen
290611f9ce editablelabel: Accept text drops
This seems natural. If we allow editing, we should
allow drops too.
2020-06-19 15:26:53 -04:00
Matthias Clasen
6280066207 testlistdnd: Add a tree
This lets us test auto-expand of tree expanders.
2020-06-19 15:26:47 -04:00
Matthias Clasen
f054c317ee expander: Remove a pointless return
GtkDropControllerMotion::enter does not expect
a boolean return value, so don't provide one.
2020-06-19 15:26:47 -04:00
Matthias Clasen
9555e611e1 treeexpander: Auto-expand during DND
When hovering over a tree expander during DND,
expand the tree after a timeout. This matches
the behavior of GtkTreeView and GtkExpander.
2020-06-19 15:26:47 -04:00
Matthias Clasen
5629ac3c63 Add a list dnd example
Add a test for dnd with listview, gridview and columnview.
2020-06-19 15:26:10 -04:00
Matthias Clasen
110c316810 columnview: Increase the autoscroll threshold
With autoscroll during DND, we stop when you hit the edge
of the widget, so a larger threshold makes sense to avoid
hitting the edge by accident.
2020-06-19 15:26:10 -04:00
Matthias Clasen
470a1aabdd columnview: Autoscroll during DND
Use a drop motion controller to autoscroll horizontally
while a drag operation is hovering over the list. The
vertical scrolling is handled by the listview.
2020-06-19 15:26:10 -04:00
Matthias Clasen
b299d62a73 columnview: separate autoscroll from headers
Break out an update_autoscroll() function that can
be used for other things than header DND. It will
be used for autoscroll during DND in the future.
2020-06-19 15:26:10 -04:00
Matthias Clasen
02b293b59c listbase: Don't use adjustments for autoscrolling
Don't consult the adjustments when determining
scroll deltas. It isn't necessary.
2020-06-19 15:26:10 -04:00
Matthias Clasen
c659a231d6 listbase: Increase the autoscroll threshold
With autoscroll during DND, we stop when you hit the edge
of the widget, so a larger threshold makes sense to avoid
hitting the edge by accident.
2020-06-19 15:26:10 -04:00
Matthias Clasen
4e56581222 listbase: Autoscroll during DND
Use a drop motion controller to autoscroll while
a drag operation is hovering over the list.
2020-06-19 15:26:10 -04:00
Matthias Clasen
e8ba16d9c2 listbase: separate autoscroll from rubberband
Break out an update_autoscroll() function that can
be used for other things than rubberbanding. It will
be used for autoscroll during DND in the future.
2020-06-19 15:26:10 -04:00
Matthias Clasen
4a43c77f66 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2115
2020-06-19 16:17:27 +00:00
Matthias Clasen
55936087e0 columview: Fix cell creation
We were getting lost in the columnview internal
structure here. The rows are children of the listview,
not of the columnview itself.
2020-06-19 11:42:58 -04:00
Matthias Clasen
3141eaecd0 gtk-demo: Modernize the tag entry demo
Use a layout manager, and reduce boilerplate.
2020-06-19 11:42:47 -04:00
Matthias Clasen
69e14ba02f Revert "notebook: Don't capture clicks"
This reverts commit 37eb0496b6.

This change broke notebook scroll arrows.
2020-06-19 11:42:47 -04:00
Benjamin Otte
dffbcd8fdf Merge branch 'wip/otte/for-master' into 'master'
listbase: Fix copy/paste error

See merge request GNOME/gtk!2114
2020-06-19 15:20:32 +00:00
Benjamin Otte
ff3b03c5e2 listbase: Fix copy/paste error
This could lead to "flickering" scroll behavior when scrolling
horizontally.
2020-06-19 15:51:52 +02:00
Florentina Mușat
32f4aa12cd Update Romanian translation 2020-06-19 06:17:36 +00:00
Timm Bäder
fbb7948c13 stack: Avoid using an uninitialized value
This was showing up as criticals since for_size != >= -1.
2020-06-19 05:58:52 +02:00
Timm Bäder
d81a5a8338 stack: Add missing accessors for GtkStackPage properties 2020-06-19 05:26:25 +02:00
Timm Bäder
652323a4bf stack: Fix some documentation mishaps 2020-06-19 05:26:25 +02:00
Timm Bäder
e45518fb5f stack: Fix :needs-attention docs
This is a property on GtkStackPage these days.
2020-06-19 05:26:25 +02:00
Timm Bäder
424e46849a widget: Don't leak css transform 2020-06-19 05:26:25 +02:00
Timm Bäder
68886ba847 treeview: Remove identical if branches
Fixes #2725
2020-06-19 05:26:25 +02:00
Timm Bäder
da85815399 transform: Fix docs to use "transform" instead of "matrix" 2020-06-19 05:26:25 +02:00
Timm Bäder
3bd648e72e stack: stop keeping a cached child render node around
All widgets cache their render node already. Just allocate the
last_visible_child always at 0/0 and then move its rendernode around
during snapshot.

Fixes #2678
2020-06-19 05:26:25 +02:00
Timm Bäder
2ae8ace784 cssselector: Only copy max_selector once 2020-06-19 05:26:25 +02:00
Timm Bäder
1f89f21ca9 numbervalue: Remove some leftover debugging code 2020-06-19 05:26:25 +02:00
Timm Bäder
c6921cdc9d builder: Use default size of 8 for the ObjectProperty arrays 2020-06-19 05:26:25 +02:00
Timm Bäder
7c9f2949ce builder: Avoid allocating things we don't use
We pretty often have no parameters at all, so avoid allocating
ObjectProperties+GArray+GPtrArray in that case.
2020-06-19 05:26:25 +02:00
Timm Bäder
0b13e68bca Avoid calling g_list_model_get_n_items() all the time
These are used in hot paths, e.g. widget construction.
2020-06-19 05:26:25 +02:00
Timm Bäder
5dde4c0a39 transform: Fix equal() docs
This has nothing to do with matrices.
2020-06-19 05:26:25 +02:00
Timm Bäder
b2875d7b19 window: Add automatic titlebar before content widget
Just like we do with explicitly set titlebars
2020-06-19 05:26:24 +02:00
Timm Bäder
0c1cfbbad1 transform: Compare 3d points directly 2020-06-19 05:26:24 +02:00
Timm Bäder
ddacf8cc43 window: Don't add class to css node directly
Use gtk_widget_add_css_class instead
2020-06-19 05:26:24 +02:00
Timm Bäder
395d13d5f1 window: Stop adding css nodes manually
No decoration node, no need to do this.
2020-06-19 05:26:24 +02:00
Timm Bäder
1e6e522a93 window: Remove dead code
There is no decoration node anymore.
2020-06-19 05:26:24 +02:00
Timm Bäder
f49a02e5b5 adwaita: Use proper transform for spinners 2020-06-19 05:26:24 +02:00
Timm Bäder
1e4dc90d62 widget: don't queue a redraw on css transform changes 2020-06-19 05:26:24 +02:00
Timm Bäder
2c3a41a81a csstransformvalue: Make no-transform case explicit 2020-06-19 05:26:24 +02:00
Timm Bäder
203bb42cc1 widget: Re-shuffle preconditions in snapshot_child()
The GtkNative type check is more expensive than the mapped one, so avoid
the former for unmapped widgets
2020-06-19 05:26:24 +02:00
Timm Bäder
461497e8d4 widget: Avoid doing GtkSnapshot work just to append one node
We already know that a widget will have literally 1 node, not more.
Avoid doing the GtkSnapshot state stack dance and just append a new
transform node instead.

Seems to give me around 400 more icons in the fishbowl
2020-06-19 05:26:24 +02:00
Timm Bäder
a974c83423 gsktransform: Make next == NULL case explicit
This is handled with the is_identity() check as well but this way it's
much more obvious what's happening
2020-06-19 05:26:24 +02:00
Timm Bäder
5eb181281a fishbowl: Remove visibility handling
First, almost all widgets are either visible and mapped, or visible and
unmapped because they are !child_visible. In both cases, we do care
about the size. If they are indeed invisible, gtk_widget_measure() will
take care of that by returning all 0.

And gtk_widget_unparent() already queues a resize on the parent if
necessary, so that is unneeded as well.
2020-06-19 05:26:24 +02:00
Timm Bäder
9eaeb04863 Fix print dialog node name 2020-06-19 05:25:52 +02:00
Matthias Clasen
5e6c316603 Merge branch 'better-naming' into 'master'
Stop using loaded terms

See merge request GNOME/gtk!2109
2020-06-19 00:09:03 +00:00
Matthias Clasen
77b4f6d68e Merge branch 'quartz-openfile-fix' into 'master'
quartz: gtk-application - inhibit openFiles events from cmdline

See merge request GNOME/gtk!2112
2020-06-18 21:43:59 +00:00
Friedrich Beckmann
a614716d0f quartz: gtk-application - inhibit openFiles events from cmdline
When an application is started via cmdline, then openFiles events
from MacOS are generated although gtkapplication already interprets
the cmdline arguments and opens suitable arguments as files. So they
would be opened twice. Depending on the exact situation the
openFiles event can also be issued before the startup signal
is given. Depending on the application this can result in a crash
due to unexpected behaviour. I took this idea from the
gedit-app-osx.m file. Also from Jesse van den Kieboom.

See:
https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/2098#note_842975
https://gitlab.gnome.org/GNOME/gtk/-/commit/a3ad7fa80f764fb7bcbe
https://gitlab.gnome.org/GNOME/gedit/-/blob/master/gedit/gedit-app-osx.m#L592
2020-06-18 16:42:54 -04:00
Emmanuele Bassi
1c856a208f Rename master and slave device
We already use the "logical/virtual" and "physical" names in the
documentation, there's no reason to use loaded terms just because X11
uses them.
2020-06-18 19:22:20 +01:00
Emmanuele Bassi
c7916c8e48 Use the appropriate name for Juneteenth
Juneteenth (a portmanteau of June and nineteenth)[2] (also known as
Freedom Day,[3] Jubilee Day,[4] and Liberation Day,[5]) is an unofficial
American holiday celebrated annually on the 19th of June in the United
States.
        -- https://en.wikipedia.org/wiki/Juneteenth
2020-06-18 17:43:46 +01:00
Emmanuele Bassi
0c023bb5bb Clarify document
We don't use the branch name to determine whether we should enable or
disable deprecation warnings coming from our dependencies.
2020-06-18 17:36:44 +01:00
Emmanuele Bassi
df73bf38c2 Rename internal object for the Quartz input method context
Like GtkIMMultiContext, the Quartz input method object uses a delegate
object internally. Let's not use loaded terms like "slave".
2020-06-18 17:33:30 +01:00
Emmanuele Bassi
7a1df3f914 Rename delegate input method context
The GtkIMMultiContext uses a delegate pattern to proxy an existing input
method context. Let's not use loaded terms like "slave" when we have
perfectly fungible terms like "delegate".
2020-06-18 17:32:05 +01:00
Emmanuele Bassi
3f78199cd5 Rename (unused) argument 2020-06-18 17:31:48 +01:00
Emmanuele Bassi
0a55d4c981 docs: Clean up the GtkBuilder description
Drop the reference to a long since removed RNC schema file and to
GtkUIManager; clean up the typography for code elements.
2020-06-18 17:21:09 +01:00
Emmanuele Bassi
7e03288724 Fix typo in a comment 2020-06-18 17:20:56 +01:00
Emmanuele Bassi
979bf5c6fb cups: Use allow/ignore list
Don't use loaded terms like "whitelist" and "blacklist".
2020-06-18 16:58:43 +01:00
Emmanuele Bassi
a7f5b2e8fc Update a comment
Drop the use of "blacklist" from the comment, since everything else
refers to "ignored" properties.
2020-06-18 16:57:27 +01:00
Yuri Chornoivan
94f246240d Update Ukrainian translation 2020-06-18 15:29:05 +00:00
Matthias Clasen
bd5fcf2998 Merge branch 'typo_fix' into 'master'
Fix minor typos

See merge request GNOME/gtk!2108
2020-06-18 15:22:53 +00:00
Yuri Chornoivan
c0cf839729 Fix minor typos 2020-06-18 10:47:16 +03:00
Matthias Clasen
2a51d4fba8 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2107
2020-06-18 03:21:18 +00:00
Matthias Clasen
cd1078563d gtk-demo: Fix the settings demo
This was not updated to the latest api of GtkEditableLabel.
2020-06-17 18:21:28 -04:00
Matthias Clasen
a9943922d5 gtk-demo: Cosmetic changes
Reword the titles and texts for several demos.
2020-06-17 18:12:01 -04:00
Matthias Clasen
b46bfcafd1 gtk-demo: Cosmetic changes to the tagged entry demo 2020-06-17 18:06:28 -04:00
Matthias Clasen
6141c139e6 gtk-demo: Fix the tagged entry demo
We were using gtk_box_append on a button. Fallout
from the container removal.
2020-06-17 17:53:40 -04:00
Matthias Clasen
0fb83d7619 gtk4-demo: Cosmetic fixes to the dialog demo
Make this look a bit less ancient.
2020-06-17 17:46:40 -04:00
Matthias Clasen
f64d0d8cbf Merge branch 'matthiasc/cloudprovider-ci' into 'master'
Matthiasc/cloudprovider ci

See merge request GNOME/gtk!2106
2020-06-17 21:16:17 +00:00
Matthias Clasen
e5d6bb68ce Fix another cloudprovider include 2020-06-17 16:19:55 -04:00
Matthias Clasen
74899599a6 gtk-demo: Add a missing source file 2020-06-17 16:06:37 -04:00
Emmanuele Bassi
12c38c1d57 Use the appropriate include for libcloudproviders
Libcloudproviders has a single header entry point, so we shouldn't
include a sub-header.

Additionally, the include path provided by the pkg-config file is:

  -I${includedir}/cloudproviders

So the include directive should be:

  #include <cloudproviders.h>

The fact that it worked until now was an accident caused by the blanket:

  -I${includedir}

we get for free; it broke the build when using libcloudproviders as a
subproject.
2020-06-17 20:49:57 +01:00
Emmanuele Bassi
d243c6d7f9 ci: Enable libcloudproviders support
We ended up breaking the build when it's enabled, so we should test the
feature in our CI pipeline.
2020-06-17 14:06:20 -04:00
Emmanuele Bassi
c5481a125e Add libcloudproviders as a fallback subproject
We require a new version of libcloudproviders so that we can enable it
in our CI pipeline.
2020-06-17 14:06:20 -04:00
Matthias Clasen
68d80babce Merge branch 'fix-initial-demo-selection' into 'master'
gtk-demo: Select the initial demo properly

See merge request GNOME/gtk!2105
2020-06-17 17:37:12 +00:00
Emmanuele Bassi
981c71c497 Merge branch 'no-more-testdbus' into 'master'
Stop using GTestDBus

See merge request GNOME/gtk!2104
2020-06-17 16:54:06 +00:00
Matthias Clasen
10bcbae68c gtk-demo: Select the initial demo properly
GtkSingleSelection does not give us a notification when
autoselect kicks in to select the first item. This was
barely noticeable, since the notebook ends up correctly
populated anyway, but the window title is not.
2020-06-17 12:25:28 -04:00
Matthias Clasen
1b265a7971 Stop using GTestDBus
It is causing tests to timeout when libraries we are using
leak bus connections, and it turns out our tests run fine
without a session bus.
2020-06-17 12:06:09 -04:00
Florentina Mușat
29c0dfb1d2 Update Romanian translation 2020-06-17 15:38:14 +00:00
Florentina Mușat
dbec5a8ce5 Update Romanian translation 2020-06-17 15:31:22 +00:00
Matthias Clasen
53eb85ba64 Merge branch 'ebassi/ci-cleanup-master' into 'master'
Small clean ups for the CI file

See merge request GNOME/gtk!2102
2020-06-17 15:06:44 +00:00
Emmanuele Bassi
73fdefd65c ci: Move backend Meson flags into a variable
So we don't have to copy them around.
2020-06-17 13:29:14 +01:00
Emmanuele Bassi
86562a6c5a ci: Move images into environment variables
Currently we have to hunt all the `image` keys when updating the image
in use for a job. We should centralise them all at the top of the file,
so they are easy to update in one simple change.
2020-06-17 13:28:07 +01:00
Daniel Mustieles
ceb63b83f2 Updated Spanish translation 2020-06-17 13:54:04 +02:00
Yuri Chornoivan
7373e73067 Update Ukrainian translation 2020-06-17 08:28:31 +00:00
Matthias Clasen
985ba832fb Merge branch 'page-setup-combos' into 'master'
Page setup combos

See merge request GNOME/gtk!2100
2020-06-16 20:00:13 +00:00
Matthias Clasen
de729e936d Merge branch 'wip/jimmac/dropdown-styling' into 'master'
Adwaita: dropdown styling

Closes #2846

See merge request GNOME/gtk!2101
2020-06-16 19:52:51 +00:00
Jakub Steiner
019f4b6b34 Adwaita: dropdown styling
- selected item color
- offset dropdown form the parent control
- special styling for the top search entry

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/2846
2020-06-16 21:11:28 +02:00
Matthias Clasen
5bcb01e182 pagesetupdialog: Convert the printer combo
Turn the printer combo into a dropdown.
2020-06-16 14:44:30 -04:00
Matthias Clasen
25c2059abb pagesetupdialog: Port the papersize combo
Turn the papersize combo into a dropdown.
2020-06-16 14:34:54 -04:00
Matthias Clasen
2a9c92f8e2 Drop unused includes
This is just cleanup to help tracking down
remaining GtkComboBox uses.
2020-06-16 14:34:54 -04:00
Friedrich Beckmann
d468ea3efa quartz: added open capability to gtk_application
This patch implements the openFiles delegate which is required
to open files which are associated with an application via the
Finder or via open on the command line. The patch has been
proposed by jessevdk@gmail.com.

See: https://gitlab.gnome.org/GNOME/gtk/-/issues/463

I tested the patch with the GNU pspp application on MacOS with
the quartz backend.
2020-06-16 12:42:48 -04:00
Piotr Drąg
d2cfe9f69a Update POTFILES.in 2020-06-16 18:16:43 +02:00
Emmanuele Bassi
8dbe9e975b Merge branch 'wip/ricotz/cleanup' into 'master'
gdk: Drop gdk_device_get_axis_value leftovers

See merge request GNOME/gtk!2097
2020-06-16 15:05:25 +00:00
Benjamin Otte
dd6174c496 Merge branch 'cherry-pick-947c3e9f' into 'master'
Merge branch 'benzea/fix-css-update' into 'gtk-3-24'

See merge request GNOME/gtk!2096
2020-06-16 13:57:49 +00:00
Rico Tzschichholz
7c1cf7781b gdk: Drop gdk_device_get_axis_value leftovers 2020-06-16 15:31:29 +02:00
Benjamin Otte
9b363a62fe Merge branch 'benzea/fix-css-update' into 'gtk-3-24'
Fix CSS update loop

See merge request GNOME/gtk!2093

(cherry picked from commit 947c3e9f72)

7a5caf1b cssnode: Don't queue_validate/deque_validate invisible nodes
2020-06-16 13:10:15 +00:00
Daniel Mustieles
2cc39fe282 Updated Spanish translation 2020-06-16 09:47:37 +02:00
Daniel Mustieles
6255bd6c08 Updated Spanish translation 2020-06-16 09:46:49 +02:00
Matthias Clasen
ab50d2090d Merge branch 'printer-combo-conversion' into 'master'
Printer combo conversion

See merge request GNOME/gtk!2095
2020-06-16 05:02:44 +00:00
Matthias Clasen
c8843d0730 fontchooser: Drop unused includes 2020-06-15 23:10:40 -04:00
Matthias Clasen
687da2ca6b text: Drop unused includes 2020-06-15 23:10:32 -04:00
Matthias Clasen
990a87fd79 printdialog: Convert some leftover code
There was still some code expecting to deal with tree
models. Convert it to work with list models.
2020-06-15 23:10:23 -04:00
Matthias Clasen
c4215a2bec pagesetupdialog: Drop the Private struct
We don't need it here.
2020-06-15 23:10:12 -04:00
Matthias Clasen
342400d155 paperdialog: Convert the printer combo
Use a GtkDropDown for the printer combo.
2020-06-15 22:42:03 -04:00
Matthias Clasen
1ca308a5fd Merge branch 'fix-notebook-tabs' into 'master'
Fix notebook tabs

Closes #2842 and #2841

See merge request GNOME/gtk!2092
2020-06-15 20:42:53 +00:00
Matthias Clasen
37eb0496b6 notebook: Don't capture clicks
Using the bubble works just fine here, and keeps buttons
in notebook tabs working without side-effects.

Fixes: #2841
2020-06-15 14:16:45 -04:00
Matthias Clasen
6a13bbbfef Merge branch 'michaelweghorn/master_issue1820_gtkfilechoosernativeportal_get_filter' into 'master'
Make gtk_file_chooser_get_filter work for portal case (issue #1820, master)

Closes #1820

See merge request GNOME/gtk!2070
2020-06-15 17:49:17 +00:00
Matthias Clasen
c175a7a470 searchentry: Fix keynav
Shift-Tabbing was getting stuck in GtkSearchEntry and
GtkPasswordEntry, since they grab the focus to a child
of theirs. Copy the same fix that we are already using
in GtkEntry.

Fixes: #2842
2020-06-15 13:48:03 -04:00
Matthias Clasen
937317e674 docs: Cosmetics
Remove a few instances of GTK+ in the docs.
2020-06-15 13:48:03 -04:00
Matthias Clasen
4248835ba1 Merge branch 'matthiasc/for-master' into 'master'
button: Center images

See merge request GNOME/gtk!2090
2020-06-15 17:01:25 +00:00
Matthias Clasen
180f7e4861 Merge branch 'editable-label' into 'master'
Editable label

See merge request GNOME/gtk!2081
2020-06-15 16:47:57 +00:00
Matthias Clasen
b526722000 button: Center images
If we leave the valign to be the default fill, then
the images pick up baseline alignment from the environment,
which can occasionally lead to misplaced -/+ icons in
spinbuttons, for example in the "Page Setup" tab of
the print dialog.
2020-06-15 12:24:48 -04:00
Matthias Clasen
b25bba4862 paperdialog: Port to use GtkListView
Use GtkListView and GtkEditableLabel here.
2020-06-15 12:08:54 -04:00
Matthias Clasen
02ce417279 gtk-demo: Use editable labels in the settings demo
This is more in line with the expected behavior for
editable lists.
2020-06-15 12:08:54 -04:00
Matthias Clasen
b0d2ae612f Add a GtkEditableLabel widget 2020-06-15 12:08:54 -04:00
Matthias Clasen
23e3d48eb9 Merge branch 'matthiasc/for-master' into 'master'
inspector: Don't set style classes on app widgets

See merge request GNOME/gtk!2089
2020-06-15 16:01:22 +00:00
Matthias Clasen
14f26d2345 inspector: Don't set style classes on app widgets
Due to a mixup, the inspector was setting .dim-label on
widgets that get unmapped, instead of the labels representing
them in the object tree.
2020-06-15 11:22:32 -04:00
Matthias Clasen
7c357423a3 Merge branch 'matthiasc/for-master' into 'master'
dropdown: Style fixups

See merge request GNOME/gtk!2088
2020-06-15 15:05:14 +00:00
Matthias Clasen
cf2d6f6ec5 dropdown: Style fixups
Make the dropdown popover have a .menu style class,
and add padding to the rows in the popover. Also,
make the popover left-aligned with the button.
2020-06-15 10:25:31 -04:00
Alexander Larsson
1443ef85be Merge branch 'final-frame-clock-work' into 'master'
Final frame clock work

See merge request GNOME/gtk!2087
2020-06-15 10:27:02 +00:00
Yariv Barkan
887aa2abdd frame clock: fix scheduling
Fix scheduling of the frame clock when we don't receive "frame drawn"
messages from the compositor.

If we received "frame drawn" events recently, then the "smooth frame
time" would be in sync with the vsync time. When we don't receive frame
drawn events, the "smooth frame time" is simply incremented by constant
multiples of the refresh interval. In both cases we can use this smooth
time as the basis for scheduling the next clock cycle.

By only using the "smooth frame time" as a basis we also benefit from
more consistent scheduling cadence. If, for example, we got "frame
drawn" events, then didn't receive them for a few frames, we would still
be in sync when we start receiving these events again.
2020-06-15 08:54:18 +02:00
Yariv Barkan
9c5d6eaa71 frame clock: adjust reported frame time
When an animation is started while the application is idle, that often
happens as a result of some external event. This can be an input event,
an expired timer, data arriving over the network etc. The result is that
the first animation clock cycle could be scheduled at some random time,
as opposed to follow up cycles which are usually scheduled right after a
vsync.

Since the frame time we report to the application is correlated to the
time when the frame clock was scheduled to run, this can result in
uneven times reported in the first few animation frames. In order to fix
that, we measure the phase of the first clock cycle - i.e. the offset
between the first cycle and the preceding vsync. Once we start receiving
"frame drawn" signals, the cadence of the frame clock scheduling becomes
tied to the vsync. In order to maintain the regularity of the reported
frame times, we adjust subsequent reported frame times with the
aforementioned phase.
2020-06-15 08:54:17 +02:00
Yuri Chornoivan
c49318e973 Update Ukrainian translation 2020-06-15 06:33:54 +00:00
Matthias Clasen
131cc6497a Merge branch 'mingw-x64-compiler-warnings' into 'master'
Fix various compiler warnings with the 64bit mingw build

See merge request GNOME/gtk!2020
2020-06-15 01:26:45 +00:00
Matthias Clasen
d9d591ff7a Merge branch 'fix-spin-button-auto-sizing' into 'master'
spinbutton: Bring back auto-sizing

See merge request GNOME/gtk!2085
2020-06-14 22:06:16 +00:00
Christoph Reiter
f16b34f286 CI: Switch to 64bit mingw for the MSYS2 job
64 bit is more common now and also tests more things because
sizeof(glong) != sizeof(gpointer)
2020-06-14 20:02:46 +02:00
Christoph Reiter
85d822b2e8 Fix various compiler warnings with the 64bit mingw build
Use better matching format modifiers/specifiers, initialise some things
which in theory wont be written to because of getters using g_return_if_fail(),
a cast, and gsize as input for malloc because gsize!=glong on 64bit Windows.
2020-06-14 20:02:36 +02:00
Matthias Clasen
4e5689abeb Merge branch 'tchaik/fix-lpr-build' into 'master'
Fix the lpr print backend build (redundant-decls)

See merge request GNOME/gtk!2084
2020-06-14 14:57:42 +00:00
Matthias Clasen
b046c8d4ad spinbutton: Bring back auto-sizing
We lost this when GtkSpinButton was first ported
to the new editable regime, and then the GtkBoxLayout.

Bring it back, but without text measurement, by overriding
width-chars for the GtkText inside, and only do it if
GtkSpinButton::width-chars is unset (ie -1).

Also adjust the documentation slightly to point out
how auto-sizing can be turned off.
2020-06-14 10:55:30 -04:00
Martin Blanchard
72c72d0b37 Fix the lpr print backend build (redundant-decls)
Class and instance _init() functions are already declared by
G_DEFINE_DYNAMIC_TYPE ().
2020-06-14 16:14:24 +02:00
Asier Sarasua Garmendia
5e69181d8d Update Basque translation 2020-06-13 20:19:00 +00:00
Asier Sarasua Garmendia
9c5a9fb100 Update Basque translation 2020-06-13 19:40:17 +00:00
Matthias Clasen
ceb2349823 Merge branch 'matthiasc/for-master' into 'master'
widget-factory: Make the print dialog more functional

See merge request GNOME/gtk!2083
2020-06-13 16:17:49 +00:00
Matthias Clasen
818b7c44be widget-factory: Make the print dialog more functional
Allow opening the papersize dialog.
2020-06-13 08:59:21 -04:00
Yuri Chornoivan
044026d330 Update Ukrainian translation 2020-06-13 11:45:35 +00:00
Piotr Drąg
66882f3825 Update POTFILES.in and POTFILES.skip 2020-06-13 12:48:27 +02:00
Matthias Clasen
1d0235780c Merge branch 'matthiasc/for-master' into 'master'
paperdialog: Drop the private struct

See merge request GNOME/gtk!2082
2020-06-12 21:53:48 +00:00
Matthias Clasen
770d6cb2bd paperdialog: Drop the private struct
Not needed here.
2020-06-12 12:54:21 -04:00
Matthias Clasen
106e1080ae Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2080
2020-06-12 16:39:46 +00:00
Matthias Clasen
07ecb3cb78 Merge branch 'fix-custom-paper-dialog' into 'master'
Fix the custom paper dialog

See merge request GNOME/gtk!2078
2020-06-12 14:01:17 +00:00
Matthias Clasen
74ac435ae6 printdialog: Replace the papersize combo with a dropdown
This one is more complicated, since it involves
separators and a custom item.
2020-06-12 09:22:36 -04:00
Matthias Clasen
c80ba49a60 Adwaita: Allow separators on individual list items
Allow setting a .separator style class on list items
to put a separator before the item.
2020-06-12 09:22:36 -04:00
Emmanuel Gil Peyrot
404d79153e Switch to GL_ARB_framebuffer_object
GTK 4.0 was currently using GL_EXT_framebuffer_object, which is
deprecated as the ARB version has been merged into OpenGL 3.0 as well as
OpenGL ES 2.0, and provides laxer requirements.

This is a port of !2076 for 4.x.
2020-06-12 15:08:44 +02:00
Matthias Clasen
ed9941ec2c printdialog: Replace some combo boxes with drop downs
These are just the simple cases.
2020-06-12 08:49:01 -04:00
Matthias Clasen
c3b43f2ad2 printeroptionwidget: Port to GtkDropDown
Use GtkDropDown instead of GtkComboBox in the print dialog.
2020-06-12 08:49:01 -04:00
Matthias Clasen
86718439be testdropdown: Add some more tests
Add a homegrown combobox entry replacement that
combines a dropdown with a plain entry.
2020-06-12 08:49:01 -04:00
Matthias Clasen
933e373b07 dropdown: Make the stack nonhomogeneous
Without this, the (None) in the empty page forces
the button to have a large minimum width, even when
we don't put a widget in it.
2020-06-12 08:49:01 -04:00
Matthias Clasen
e6dcd55480 Fix the custom paper dialog
This broke during the container removal.
2020-06-12 08:46:18 -04:00
Yuri Chornoivan
0d901ef174 Update Ukrainian translation 2020-06-12 06:40:07 +00:00
Matthias Clasen
716e0db690 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2077
2020-06-11 23:44:48 +00:00
Matthias Clasen
90b78132d4 dropdown: Make the popup as wide as the button
Having narrow popups on a wide button looks awkward.
Do the same as the combo box, and ensure the popup
is at least as wide as the button.
2020-06-11 18:29:58 -04:00
Matthias Clasen
c2285d923d iconbrowser: Drop app menu leftovers
We don't use menus.ui anymore, so don't put it in a resource.
2020-06-11 18:16:36 -04:00
Matthias Clasen
4a79ac4473 Adwaita: bring dropdown arrows back
These got lost when the css name changed from combobox
to dropdown.
2020-06-11 18:09:12 -04:00
Matthias Clasen
2a3e5422ad docs: Cosmetics
Remove a few instances of GTK+ from the docs, and
remove references to ancient versions.
2020-06-11 17:25:57 -04:00
Matthias Clasen
e0c39dbf7e Merge branch 'recent-model' into 'master'
Add a list model for recent files

See merge request GNOME/gtk!2073
2020-06-11 20:58:52 +00:00
Matthias Clasen
8c670b3b5d testcolumnview: Add recent file support
Use testcolumnview --recent to see recent files.
2020-06-11 16:14:47 -04:00
Matthias Clasen
5dddec4dd9 Add GtkBookmarkList
This is a listmodel similar to GtkDirectoryList,
for tracking recent files.
2020-06-11 16:14:47 -04:00
Matthias Clasen
93017bb8db Merge branch 'property-selection-getters' into 'master'
propertyselection: Add getters

See merge request GNOME/gtk!2075
2020-06-11 13:08:47 +00:00
Matthias Clasen
059c45a85b propertyselection: Add getters
These were missing.
2020-06-11 07:35:20 -04:00
Matthias Clasen
63692a491d Merge branch 'michaelweghorn/master_issue1820_gtkfilechoosernative_get_filter' into 'master'
filechoosernative: Make get_filter work for (non-portal) native chooser (master, issue #1820)

Closes #1820

See merge request GNOME/gtk!2069
2020-06-10 14:47:36 +00:00
Emmanuele Bassi
bbe79c1ef9 Merge branch 'wip/carlosg/zoom-no-touchpad-warnings' into 'master'
gtkgesturezoom: Do not check touchpad phase on generic events

Closes #2825

See merge request GNOME/gtk!2071
2020-06-10 14:35:10 +00:00
Matthias Clasen
4b241f8da2 Merge branch 'scroll-compression' into 'master'
gdk: Compress scroll events

Closes #2800

See merge request GNOME/gtk!2066
2020-06-10 14:35:01 +00:00
Matthias Clasen
bdd6ae3252 Merge branch 'device-cleanup' into 'master'
Device cleanup

See merge request GNOME/gtk!2068
2020-06-10 13:06:13 +00:00
sicklylife
24a3ff3aef Update Japanese translation 2020-06-10 12:34:42 +00:00
Carlos Garnacho
ba988cd899 gtkgesturezoom: Do not check touchpad phase on generic events
This gesture handles both individual touch events and touchpad gesture
events, and was checking the touchpad phase in generic code paths. This
is dubious since event methods error out on the wrong GdkEventTypes.

Check the touchpad gesture phase within the branch handling touchpad
events, and make it clear which is the gesture phase of all that we are
ignoring.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2825
2020-06-10 14:30:58 +02:00
sicklylife
1bf1646d25 Update Japanese translation 2020-06-10 12:18:55 +00:00
Matthias Clasen
2c82151d65 gdk: Drop axis labels
This was only ever implemented on X11, and the labels
here were atom names, so unlikely to be useful for
anything interesting.
2020-06-10 07:36:30 -04:00
Alexander Larsson
d2235b71f3 Merge branch 'win32-use-g-stat' into 'master'
gtkiconcache: Use g_stat instead of fstat

See merge request GNOME/gtk!2019
2020-06-10 07:19:22 +00:00
Michael Weghorn
ecc6c255ef Make gtk_file_chooser_get_filter work for portal case
This makes 'gtk_file_chooser_get_filter' work for the
portal native file chooser by handling the corresponding
'current_filter' argument in the response retrieved via
D-Bus.

In order to try to map the retrieved 'current_filter' to one
of the existing list of filters, use the retrieved filter's name,
similar to how xdg-desktop-portal-gtk does it when evaluating the
'current_filter' input parameter in 'options'.)

Note: This depends on the following merge/pull requests
which fix the filter handling in gtk for native file choosers
and introduce the 'current_filter' handling for FileChooser portal.

* https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/1959
* https://github.com/flatpak/xdg-desktop-portal/pull/493
* https://github.com/flatpak/xdg-desktop-portal-gtk/pull/311

This fixes #1820 for desktop portal case.

Fixes: #1820
2020-06-09 22:59:54 +02:00
Michael Weghorn
57135acd2d filechoosernative: Make get_filter work for (non-portal) native chooser
'gtk_file_chooser_get_filter' did not work for GtkFileChooserNative,
since the previous way did not properly handle the delegate dialog,
s.a. commit a136cbae8f
("filechoosernative: forward current_filter to delegate dialog",
2018-11-29) for details, wich basiscally fixed the same thing for
the 'gtk_file_chooser_set_filter' case.

This fixes #1820 for the fallback dialog. A solution for the portal
one (which also requires changes to xdg-desktop-portal and
xdg-desktop-portal-gtk as well) will be suggested in a subsequent step.

Bug: #1820
2020-06-09 22:59:34 +02:00
Matthias Clasen
54c098761f gdk: Drop gdk_device_set_axis_use
If you need some axes changed, you can just flip
the values when you receive them.
2020-06-09 15:27:34 -04:00
Matthias Clasen
2f98400b80 gdk: Drop gdk_device_get/set_keys
This functionality was only ever half-implemented
on X11, and is not useful enough to keep around.
2020-06-09 15:27:33 -04:00
Matthias Clasen
ea7c9b93ea x11: Stop setting device keys
This is very vestigial functionality, and basically
unused.
2020-06-09 15:05:55 -04:00
Matthias Clasen
4317c008f0 Address review comments
We were casting scroll events to motion events
rather carelessly. Don't do that.
2020-06-09 14:13:22 -04:00
Matthias Clasen
d605d9ae73 gdk: Add documentation
Add some useful information about event history.
2020-06-09 13:59:26 -04:00
Matthias Clasen
c9fad25131 gdk: Rename gdk_motion_event_get_history
Scroll events can have history too, so make a
getter that works for both. This drops the
gdk_scroll_event_get_history getter that was
added a few commits earlier, since we now
store scroll history in the same way as
motion history.

Update the docs, and all callers.
2020-06-09 13:43:12 -04:00
Matthias Clasen
693200f1eb gdk: Shrink GdkTimeCoord
There is really no need to store 128 doubles as axes,
ever. We can do just fine with 10. At the same time,
add a GdkAxisFlags member, so we can interpret the
values without having to go chasing the right device
for this information.
2020-06-09 13:43:03 -04:00
Matthias Clasen
5f087a9dff gdk: Add scroll delta x/y as device axes
They really are axes, and having them present
in these enums lets use store delta values in
GdkTimeCoord for keeping history.
2020-06-09 13:43:03 -04:00
Matthias Clasen
b9cde6f8ea Keep scroll history
Similar to how we keep motion history for compressed
events, keep scroll history for compressed scroll
events.
2020-06-09 13:43:03 -04:00
Matthias Clasen
86eece78b1 gdk: Compress scroll events
Only return one accumulated scroll event per frame.
Compress them by adding up the deltas.

Still missing: a way to capture history, like
we do for motion events.

Fixes: #2800
2020-06-09 13:43:03 -04:00
Daniel Mustieles
8cb50ac6e9 Updated Spanish translation 2020-06-09 17:19:50 +02:00
Matthias Clasen
997fbbde8f Merge branch 'drop-device-history' into 'master'
Drop device history

See merge request GNOME/gtk!2065
2020-06-08 23:56:30 +00:00
Matthias Clasen
805ddc3c3a gdk: Drop gdk_device_get_history
This function is not implemented anywhere.
2020-06-08 18:24:20 -04:00
Matthias Clasen
da9b3a9256 win32: Drop pointless vfuncs
These are not useful.
2020-06-08 18:24:20 -04:00
Matthias Clasen
876560924f wayland: Drop a pointless vfunc
A vfunc that just returns FALSE is not useful.
2020-06-08 18:24:20 -04:00
Matthias Clasen
ca1c89c5bd broadway: Drop a pointless vfunc
A vfunc that just returns FALSE is not useful.
2020-06-08 18:24:20 -04:00
Jordi Mas
7875e28d9f Update Catalan translation 2020-06-08 22:50:03 +02:00
Benjamin Otte
bd2f2a6f65 Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master

See merge request GNOME/gtk!2064
2020-06-08 18:43:31 +00:00
Benjamin Otte
541aaa2392 selectionmodel: Add unselect_rest argument to select_callback
This is not just about consistency with other functions.

It is about avoiding reentrancy problems.

GtkListBase first doing an unselect_all() will then force the
SelectionModel to consider a state where all items are unselected
(and potentially deciding to autoselect one) and then cause a
"selection-changed" emission that unselects all items and potentially
updates all the list item widgets in the GtkListBase to the unselected
state.

After this, GtkListBase selects new items, but to the SelectionModel and
the list item widgets this looks like an enitrely new operation and
there is no way to associate it with the previous state, so the
SelectionModel cannot undo any previous actions it took when
unselecting.
And all listitem widgets will now think they were just selected and
start running animations about selecting.
2020-06-08 19:06:56 +02:00
Benjamin Otte
d294b01cee selectionmodel: Rename "exclusive" to "unselect_rest"
The name is better at explaining what this boolean is meant to do.
2020-06-08 18:26:48 +02:00
Benjamin Otte
5d9dc25115 listitemmanager: Update selections properly
Replace a previous fix with a more correct one: Update the
selected state from the model instead of reusing the old state, the
model might have updated the selected state.
2020-06-08 18:14:24 +02:00
Daniel Mustieles
c8988ec784 Updated Spanish translation 2020-06-08 17:21:58 +02:00
Daniel Mustieles
071dbc1115 Updated Spanish translation 2020-06-08 16:11:28 +02:00
Matthias Clasen
80c5e4a156 Merge branch 'matthiasc/for-master' into 'master'
dropdown: Use our own CSS name

See merge request GNOME/gtk!2061
2020-06-08 11:15:28 +00:00
Emmanuele Bassi
6eac3063fa Merge branch 'tintou/places-sidebar-cloudproviders' into 'master'
placessidebar: Fix build with libcloudproviders

See merge request GNOME/gtk!2062
2020-06-08 09:35:23 +00:00
Corentin Noël
27925fcb0e placessidebar: Fix build with libcloudproviders
Make it build with cloudproviders=true as the GtkPopover API for menus is now in GtkPopoverMenu.

Fix some leaks while looking at the code.
2020-06-08 10:40:46 +02:00
Matthias Clasen
5f4d21422a Merge branch 'fix-cell-editing' into 'master'
Fix cell editing

Closes #2831

See merge request GNOME/gtk!2060
2020-06-07 14:54:37 +00:00
Matthias Clasen
b0bb413faa dropdown: Use our own CSS name
Use the name dropdown for the css node, and document it.
2020-06-07 09:01:20 -04:00
Matthias Clasen
37633985bd Drop gtknativeprivate.h
No need to ship empty headers.
2020-06-07 08:52:45 -04:00
Matthias Clasen
6ff8f1b2fd Merge branch 'gtk-demo-tweaks' into 'master'
Gtk demo tweaks

See merge request GNOME/gtk!2059
2020-06-07 12:51:34 +00:00
Matthias Clasen
d13a3c7540 Fix cell editing
When translating coordinates from an event, we need to
take the surface transform into account. This makes
double-clicking on editable cells in treeviews work
again.

Fixes: #2831
2020-06-07 08:46:31 -04:00
Yuri Chornoivan
0a469d7bd6 Update Ukrainian translation 2020-06-07 08:51:44 +00:00
Piotr Drąg
115edc5fd1 Update POTFILES.in 2020-06-07 09:27:34 +02:00
Matthias Clasen
a28c75f215 gtk-demo: Expand the sidebar by default
Seems better to show what we have. Plus, clicking
those arrows is a little fiddly.
2020-06-06 22:12:12 -04:00
Matthias Clasen
b9d7dab329 gtk-demo: Improve display of image sources
Make the images expand to fill the space.
2020-06-06 22:12:12 -04:00
Matthias Clasen
bb7500e984 gtk-demo: Cosmetics
Tweak the formatting of the descriptions of
various demos.
2020-06-06 22:05:52 -04:00
Matthias Clasen
e94268944b gtk-demo: Cosmetics
Make the titles of some demos match between sidebar
and window.
2020-06-06 21:42:42 -04:00
Emmanuele Bassi
3225b487e8 Merge branch 'ebassi/for-master' into 'master'
Annotate the GtkSelectionModel callbacks

See merge request GNOME/gtk!2057
2020-06-07 01:42:21 +00:00
Matthias Clasen
e35c0e043e gtk-demo: Add overline to the markup demo
This is a new-ish Pango feature.
2020-06-06 21:38:31 -04:00
Matthias Clasen
b251893030 Drop pango version checks
We are requiring pango 1.45.0 now, so no need to
Keep these ifdefs in the code any longer.
2020-06-06 21:32:55 -04:00
Matthias Clasen
15257e3922 gtk-demo: Fix a leak
The themes demo was leaking its builder, and
therefore couldn't be closed.
2020-06-06 20:09:42 -04:00
Matthias Clasen
180a5a1ad7 gtk-demo: Cosmetic changes to the dropdown demo
Match the window title and the sidebar.
2020-06-06 20:08:50 -04:00
Matthias Clasen
11f971d870 gtk-demo: Cosmetic improvements to clocks demo
Reformat the code comments, and add a 10th clock.
2020-06-06 19:43:21 -04:00
Emmanuele Bassi
7c382c6b47 Annotate the GtkSelectionModel callbacks
We need a scope for the select and unselect callback arguments.
2020-06-07 00:39:33 +01:00
Jordi Mas
087f42d998 Update Catalan translation 2020-06-06 23:13:17 +02:00
Christoph Reiter
e7c9e2060c gtkiconcache: Use g_stat instead of fstat
stat/fstat aren't compatible with GStatBuf on Windows in all cases.
Since we don't really need the file descriptor anyway here replace it with
a g_stat call.

This fixes a compiler warning with 64bit mingw.
And lets us remove this scary ifdeffery.
2020-06-02 20:35:56 +02:00
393 changed files with 53834 additions and 26442 deletions

View File

@@ -17,7 +17,12 @@ stages:
# Common variables
variables:
COMMON_MESON_FLAGS: "--fatal-meson-warnings --werror"
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true -Dvulkan=yes"
FEATURE_FLAGS: "-Dcloudproviders=true"
MESON_TEST_TIMEOUT_MULTIPLIER: 2
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v17"
FLATPAK_IMAGE: "registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master"
DOCS_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora-docs:v19"
.only-default:
only:
@@ -27,14 +32,14 @@ variables:
style-check-diff:
extends: .only-default
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v17
image: $FEDORA_IMAGE
stage: .pre
allow_failure: true
script:
- .gitlab-ci/run-style-check-diff.sh
.build-fedora-default:
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v17
image: $FEDORA_IMAGE
artifacts:
when: always
reports:
@@ -66,11 +71,7 @@ fedora-x86_64:
variables:
EXTRA_MESON_FLAGS: "--buildtype=debug --default-library=both"
script:
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS}
-Dx11-backend=true
-Dwayland-backend=true
-Dbroadway-backend=true
-Dvulkan=yes
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} ${BACKEND_FLAGS} ${FEATURE_FLAGS}
-Dprofiler=true
_build
- ninja -C _build
@@ -84,11 +85,7 @@ release-build:
variables:
EXTRA_MESON_FLAGS: "--buildtype=release"
script:
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS}
-Dx11-backend=true
-Dwayland-backend=true
-Dbroadway-backend=true
-Dvulkan=yes
- meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} ${BACKEND_FLAGS} ${FEATURE_FLAGS}
_build
- ninja -C _build
- .gitlab-ci/run-tests.sh _build x11
@@ -110,14 +107,14 @@ release-build:
- subprojects/libepoxy/
- subprojects/pango/
msys2-mingw32:
msys2-mingw64:
extends: .mingw-defaults
variables:
MSYSTEM: "MINGW32"
MSYSTEM: "MINGW64"
CHERE_INVOKING: "yes"
.flatpak-defaults:
image: registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master
image: $FLATPAK_IMAGE
stage: flatpak
allow_failure: true
tags:
@@ -171,7 +168,7 @@ flatpak-master:icon-browser:
APPID: org.gtk.IconBrowser4
static-scan:
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v16
image: $FEDORA_IMAGE
stage: analysis
variables:
EXTRA_MESON_FLAGS: "--buildtype=debug"
@@ -184,7 +181,7 @@ static-scan:
allow_failure: true
reference:
image: registry.gitlab.gnome.org/gnome/gtk/fedora-docs:v19
image: $DOCS_IMAGE
stage: docs
variables:
EXTRA_MESON_FLAGS: "--buildtype=release"

View File

@@ -4,8 +4,15 @@ set -e
# We need to add a new remote for the upstream master, since this script could
# be running in a personal fork of the repository which has out of date branches.
git remote add upstream https://gitlab.gnome.org/GNOME/gtk.git
git fetch upstream
if [ "${CI_PROJECT_NAMESPACE}" != "GNOME" ]; then
echo "Retrieving the current upstream repository from ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}..."
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
@@ -13,7 +20,7 @@ git fetch upstream
#
# `${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}` is only defined if were running in
# a merge request pipeline; fall back to `${CI_DEFAULT_BRANCH}` otherwise.
newest_common_ancestor_sha=$(diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent "upstream/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-${CI_DEFAULT_BRANCH}}") <(git rev-list --first-parent HEAD) | head -1)
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)
git diff -U0 --no-color "${newest_common_ancestor_sha}" | .gitlab-ci/clang-format-diff.py -binary "clang-format" -p1
exit_status=$?

View File

@@ -1,7 +1,7 @@
/* Constraints/Interactive
*
* Demonstrate how constraints can be updates during
* user interaction.
* Demonstrate how constraints can be updates during user interaction.
* The vertical edge between the buttons can be dragged with the mouse.
*/
#include <glib/gi18n.h>

View File

@@ -94,7 +94,7 @@ do_css_basics (GtkWidget *do_widget)
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
container = gtk_scrolled_window_new (NULL, NULL);
container = gtk_scrolled_window_new ();
gtk_window_set_child (GTK_WINDOW (window), container);
child = gtk_text_view_new_with_buffer (text);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (container), child);

View File

@@ -132,7 +132,7 @@ do_css_multiplebgs (GtkWidget *do_widget)
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
sw = gtk_scrolled_window_new (NULL, NULL);
sw = gtk_scrolled_window_new ();
gtk_paned_set_end_child (GTK_PANED (paned), sw);
child = gtk_text_view_new_with_buffer (text);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), child);

View File

@@ -101,7 +101,7 @@ do_css_pixbufs (GtkWidget *do_widget)
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
container = gtk_scrolled_window_new (NULL, NULL);
container = gtk_scrolled_window_new ();
gtk_paned_set_end_child (GTK_PANED (paned), container);
child = gtk_text_view_new_with_buffer (text);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (container), child);

View File

@@ -119,7 +119,7 @@ do_css_shadows (GtkWidget *do_widget)
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
container = gtk_scrolled_window_new (NULL, NULL);
container = gtk_scrolled_window_new ();
gtk_paned_set_end_child (GTK_PANED (paned), container);
child = gtk_text_view_new_with_buffer (text);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (container), child);

View File

@@ -1,9 +1,8 @@
/* Cursors
*
* Demonstrates a useful set of available cursors. The cursors shown here are the ones
* defined by CSS, which we assume to be available.
*
* The example shows creating cursors by name or from an image, with or without a fallback.
* Demonstrates a useful set of available cursors. The cursors shown here are the
* ones defined by CSS, which we assume to be available. The example shows creating
* cursors by name or from an image, with or without a fallback.
*/
#include <gtk/gtk.h>

View File

@@ -105,6 +105,9 @@
<file>zoom_in_cursor.png</file>
<file>zoom_out_cursor.png</file>
</gresource>
<gresource prefix="/dnd">
<file>dnd.css</file>
</gresource>
<gresource prefix="/fishbowl">
<file>fishbowl.ui</file>
<file>gtkfishbowl.c</file>
@@ -222,6 +225,7 @@
<file>listview_minesweeper.c</file>
<file>listview_settings.c</file>
<file>listview_weather.c</file>
<file>listview_words.c</file>
<file>list_store.c</file>
<file>markup.c</file>
<file>modelbutton.c</file>
@@ -296,6 +300,7 @@
</gresource>
<gresource prefix="/transparent">
<file>portland-rose.jpg</file>
<file>bluroverlay.h</file>
<file>bluroverlay.c</file>
</gresource>
<gresource prefix="/markup">

View File

@@ -25,31 +25,36 @@
#include <gtk/gtk.h>
#include <gtk/gtk-a11y.h>
typedef struct {
struct _DemoTaggedEntry
{
GtkWidget parent_instance;
GtkWidget *box;
GtkWidget *entry;
} DemoTaggedEntryPrivate;
};
struct _DemoTaggedEntryClass
{
GtkWidgetClass parent_class;
};
static void demo_tagged_entry_editable_init (GtkEditableInterface *iface);
G_DEFINE_TYPE_WITH_CODE (DemoTaggedEntry, demo_tagged_entry, GTK_TYPE_WIDGET,
G_ADD_PRIVATE (DemoTaggedEntry)
G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE, demo_tagged_entry_editable_init))
static void
demo_tagged_entry_init (DemoTaggedEntry *entry)
{
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
entry->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_parent (entry->box, GTK_WIDGET (entry));
priv->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_parent (priv->box, GTK_WIDGET (entry));
priv->entry = gtk_text_new ();
gtk_widget_set_hexpand (priv->entry, TRUE);
gtk_widget_set_vexpand (priv->entry, TRUE);
gtk_widget_set_hexpand (priv->box, FALSE);
gtk_widget_set_vexpand (priv->box, FALSE);
gtk_box_append (GTK_BOX (priv->box), priv->entry);
entry->entry = gtk_text_new ();
gtk_widget_set_hexpand (entry->entry, TRUE);
gtk_widget_set_vexpand (entry->entry, TRUE);
gtk_widget_set_hexpand (entry->box, FALSE);
gtk_widget_set_vexpand (entry->box, FALSE);
gtk_box_append (GTK_BOX (entry->box), entry->entry);
gtk_editable_init_delegate (GTK_EDITABLE (entry));
}
@@ -57,23 +62,16 @@ static void
demo_tagged_entry_dispose (GObject *object)
{
DemoTaggedEntry *entry = DEMO_TAGGED_ENTRY (object);
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
if (priv->entry)
if (entry->entry)
gtk_editable_finish_delegate (GTK_EDITABLE (entry));
g_clear_pointer (&priv->entry, gtk_widget_unparent);
g_clear_pointer (&priv->box, gtk_widget_unparent);
g_clear_pointer (&entry->entry, gtk_widget_unparent);
g_clear_pointer (&entry->box, gtk_widget_unparent);
G_OBJECT_CLASS (demo_tagged_entry_parent_class)->dispose (object);
}
static void
demo_tagged_entry_finalize (GObject *object)
{
G_OBJECT_CLASS (demo_tagged_entry_parent_class)->finalize (object);
}
static void
demo_tagged_entry_set_property (GObject *object,
guint prop_id,
@@ -98,44 +96,12 @@ demo_tagged_entry_get_property (GObject *object,
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
static void
demo_tagged_entry_measure (GtkWidget *widget,
GtkOrientation orientation,
int for_size,
int *minimum,
int *natural,
int *minimum_baseline,
int *natural_baseline)
{
DemoTaggedEntry *entry = DEMO_TAGGED_ENTRY (widget);
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
gtk_widget_measure (priv->box, orientation, for_size,
minimum, natural,
minimum_baseline, natural_baseline);
}
static void
demo_tagged_entry_size_allocate (GtkWidget *widget,
int width,
int height,
int baseline)
{
DemoTaggedEntry *entry = DEMO_TAGGED_ENTRY (widget);
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
gtk_widget_size_allocate (priv->box,
&(GtkAllocation) { 0, 0, width, height },
baseline);
}
static gboolean
demo_tagged_entry_grab_focus (GtkWidget *widget)
{
DemoTaggedEntry *entry = DEMO_TAGGED_ENTRY (widget);
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
return gtk_widget_grab_focus (priv->entry);
return gtk_widget_grab_focus (entry->entry);
}
static void
@@ -145,16 +111,14 @@ demo_tagged_entry_class_init (DemoTaggedEntryClass *klass)
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->dispose = demo_tagged_entry_dispose;
object_class->finalize = demo_tagged_entry_finalize;
object_class->get_property = demo_tagged_entry_get_property;
object_class->set_property = demo_tagged_entry_set_property;
widget_class->measure = demo_tagged_entry_measure;
widget_class->size_allocate = demo_tagged_entry_size_allocate;
widget_class->grab_focus = demo_tagged_entry_grab_focus;
gtk_editable_install_properties (object_class, 1);
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_ENTRY_ACCESSIBLE);
gtk_widget_class_set_css_name (widget_class, "entry");
}
@@ -162,10 +126,7 @@ demo_tagged_entry_class_init (DemoTaggedEntryClass *klass)
static GtkEditable *
demo_tagged_entry_get_delegate (GtkEditable *editable)
{
DemoTaggedEntry *entry = DEMO_TAGGED_ENTRY (editable);
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
return GTK_EDITABLE (priv->entry);
return GTK_EDITABLE (DEMO_TAGGED_ENTRY (editable)->entry);
}
static void
@@ -184,11 +145,9 @@ void
demo_tagged_entry_add_tag (DemoTaggedEntry *entry,
GtkWidget *tag)
{
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
g_return_if_fail (DEMO_IS_TAGGED_ENTRY (entry));
gtk_box_append (GTK_BOX (priv->box), tag);
gtk_box_append (GTK_BOX (entry->box), tag);
}
void
@@ -196,30 +155,27 @@ demo_tagged_entry_insert_tag_after (DemoTaggedEntry *entry,
GtkWidget *tag,
GtkWidget *sibling)
{
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
g_return_if_fail (DEMO_IS_TAGGED_ENTRY (entry));
if (sibling == NULL)
gtk_box_append (GTK_BOX (priv->box), tag);
gtk_box_append (GTK_BOX (entry->box), tag);
else
gtk_box_insert_child_after (GTK_BOX (priv->box), tag, sibling);
gtk_box_insert_child_after (GTK_BOX (entry->box), tag, sibling);
}
void
demo_tagged_entry_remove_tag (DemoTaggedEntry *entry,
GtkWidget *tag)
{
DemoTaggedEntryPrivate *priv = demo_tagged_entry_get_instance_private (entry);
g_return_if_fail (DEMO_IS_TAGGED_ENTRY (entry));
gtk_box_remove (GTK_BOX (priv->box), tag);
gtk_box_remove (GTK_BOX (entry->box), tag);
}
struct _DemoTaggedEntryTag
{
GtkWidget parent;
GtkWidget *box;
GtkWidget *label;
GtkWidget *button;
@@ -250,11 +206,11 @@ static guint signals[LAST_SIGNAL] = { 0, };
G_DEFINE_TYPE (DemoTaggedEntryTag, demo_tagged_entry_tag, GTK_TYPE_WIDGET)
static void
on_released (GtkGestureClick *gesture,
int n_press,
double x,
double y,
DemoTaggedEntryTag *tag)
on_released (GtkGestureClick *gesture,
int n_press,
double x,
double y,
DemoTaggedEntryTag *tag)
{
g_signal_emit (tag, signals[SIGNAL_CLICKED], 0);
}
@@ -469,7 +425,7 @@ demo_tagged_entry_tag_set_has_close_button (DemoTaggedEntryTag *tag,
image = gtk_image_new_from_icon_name ("window-close-symbolic");
tag->button = gtk_button_new ();
gtk_box_append (GTK_BOX (tag->button), image);
gtk_button_set_child (GTK_BUTTON (tag->button), image);
gtk_widget_set_halign (tag->button, GTK_ALIGN_CENTER);
gtk_widget_set_valign (tag->button, GTK_ALIGN_CENTER);
gtk_button_set_has_frame (GTK_BUTTON (tag->button), FALSE);

View File

@@ -25,39 +25,11 @@
G_BEGIN_DECLS
#define DEMO_TYPE_TAGGED_ENTRY (demo_tagged_entry_get_type ())
#define DEMO_TAGGED_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEMO_TYPE_TAGGED_ENTRY, DemoTaggedEntry))
#define DEMO_TAGGED_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEMO_TYPE_TAGGED_ENTRY, DemoTaggedEntryClass))
#define DEMO_IS_TAGGED_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEMO_TYPE_TAGGED_ENTRY))
#define DEMO_IS_TAGGED_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEMO_TYPE_TAGGED_ENTRY))
#define DEMO_TAGGED_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEMO_TYPE_TAGGED_ENTRY, DemoTaggedEntryClass))
#define DEMO_TYPE_TAGGED_ENTRY (demo_tagged_entry_get_type ())
G_DECLARE_FINAL_TYPE (DemoTaggedEntry, demo_tagged_entry, DEMO, TAGGED_ENTRY, GtkWidget)
typedef struct _DemoTaggedEntry DemoTaggedEntry;
typedef struct _DemoTaggedEntryClass DemoTaggedEntryClass;
struct _DemoTaggedEntry
{
GtkWidget parent;
};
struct _DemoTaggedEntryClass
{
GtkWidgetClass parent_class;
};
#define DEMO_TYPE_TAGGED_ENTRY_TAG (demo_tagged_entry_tag_get_type ())
#define DEMO_TAGGED_ENTRY_TAG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEMO_TYPE_TAGGED_ENTRY_TAG, DemoTaggedEntryTag))
#define DEMO_TAGGED_ENTRY_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEMO_TYPE_TAGGED_ENTRY_TAG, DemoTaggedEntryTag))
#define DEMO_IS_TAGGED_ENTRY_TAG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEMO_TYPE_TAGGED_ENTRY_TAG))
#define DEMO_IS_TAGGED_ENTRY_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEMO_TYPE_TAGGED_ENTRY_TAG))
#define DEMO_TAGGED_ENTRY_TAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEMO_TYPE_TAGGED_ENTRY_TAG, DemoTaggedEntryTagClass))
typedef struct _DemoTaggedEntryTag DemoTaggedEntryTag;
typedef struct _DemoTaggedEntryTagClass DemoTaggedEntryTagClass;
GType demo_tagged_entry_get_type (void) G_GNUC_CONST;
GType demo_tagged_entry_tag_get_type (void) G_GNUC_CONST;
#define DEMO_TYPE_TAGGED_ENTRY_TAG (demo_tagged_entry_tag_get_type ())
G_DECLARE_FINAL_TYPE (DemoTaggedEntryTag, demo_tagged_entry_tag, DEMO, TAGGED_ENTRY_TAG, GtkWidget)
GtkWidget * demo_tagged_entry_new (void);

View File

@@ -1,6 +1,7 @@
/* Dialogs and Message Boxes
/* Dialogs
*
* Dialog widgets are used to pop up a transient window for user feedback.
* Dialogs are used to pop up transient windows for information
* and user feedback.
*/
#include <glib/gi18n.h>
@@ -21,10 +22,9 @@ message_dialog_clicked (GtkButton *button,
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK_CANCEL,
"This message box has been popped up the following\n"
"number of times:");
"Test message");
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
"%d", i);
ngettext ("Has been shown once", "Has been shown %d times", i), i);
g_signal_connect (dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
gtk_widget_show (dialog);
i++;
@@ -61,8 +61,6 @@ interactive_dialog_clicked (GtkButton *button,
{
GtkWidget *content_area;
GtkWidget *dialog;
GtkWidget *hbox;
GtkWidget *image;
GtkWidget *table;
GtkWidget *local_entry1;
GtkWidget *local_entry2;
@@ -71,26 +69,24 @@ interactive_dialog_clicked (GtkButton *button,
dialog = gtk_dialog_new_with_buttons ("Interactive Dialog",
GTK_WINDOW (window),
GTK_DIALOG_MODAL| GTK_DIALOG_DESTROY_WITH_PARENT,
_("_OK"),
GTK_RESPONSE_OK,
"_Cancel",
GTK_RESPONSE_CANCEL,
GTK_DIALOG_MODAL| GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_USE_HEADER_BAR,
_("_OK"), GTK_RESPONSE_OK,
_("_Cancel"), GTK_RESPONSE_CANCEL,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
gtk_box_append (GTK_BOX (content_area), hbox);
image = gtk_image_new_from_icon_name ("dialog-question");
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
gtk_box_append (GTK_BOX (hbox), image);
table = gtk_grid_new ();
gtk_grid_set_row_spacing (GTK_GRID (table), 4);
gtk_grid_set_column_spacing (GTK_GRID (table), 4);
gtk_box_append (GTK_BOX (hbox), table);
gtk_widget_set_hexpand (table, TRUE);
gtk_widget_set_vexpand (table, TRUE);
gtk_widget_set_halign (table, GTK_ALIGN_CENTER);
gtk_widget_set_valign (table, GTK_ALIGN_CENTER);
gtk_box_append (GTK_BOX (content_area), table);
gtk_grid_set_row_spacing (GTK_GRID (table), 6);
gtk_grid_set_column_spacing (GTK_GRID (table), 6);
label = gtk_label_new_with_mnemonic ("_Entry 1");
gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1);
local_entry1 = gtk_entry_new ();
@@ -123,7 +119,6 @@ interactive_dialog_clicked (GtkButton *button,
GtkWidget *
do_dialog (GtkWidget *do_widget)
{
GtkWidget *frame;
GtkWidget *vbox;
GtkWidget *vbox2;
GtkWidget *hbox;
@@ -136,22 +131,16 @@ do_dialog (GtkWidget *do_widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Dialogs and Message Boxes");
gtk_window_set_title (GTK_WINDOW (window), "Dialogs");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
frame = gtk_frame_new ("Dialogs");
gtk_widget_set_margin_start (frame, 8);
gtk_widget_set_margin_end (frame, 8);
gtk_widget_set_margin_top (frame, 8);
gtk_widget_set_margin_bottom (frame, 8);
gtk_window_set_child (GTK_WINDOW (window), frame);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_widget_set_margin_start (vbox, 8);
gtk_widget_set_margin_end (vbox, 8);
gtk_widget_set_margin_top (vbox, 8);
gtk_widget_set_margin_bottom (vbox, 8);
gtk_frame_set_child (GTK_FRAME (frame), vbox);
gtk_window_set_child (GTK_WINDOW (window), vbox);
/* Standard message dialog */
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);

View File

@@ -38,15 +38,20 @@ set_color (CanvasItem *item,
char *str;
GtkStyleContext *context;
GtkCssProvider *provider;
const char *old_class;
str = gdk_rgba_to_string (color);
css = g_strdup_printf ("* { background: %s; padding: 10px; margin: 1px; }", str);
css = g_strdup_printf ("* { background: %s; }", str);
context = gtk_widget_get_style_context (item->label);
provider = g_object_get_data (G_OBJECT (context), "style-provider");
if (provider)
gtk_style_context_remove_provider (context, GTK_STYLE_PROVIDER (provider));
old_class = (const char *)g_object_get_data (G_OBJECT (item->label), "css-class");
if (old_class)
gtk_widget_remove_css_class (item->label, old_class);
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider, css, -1);
gtk_style_context_add_provider (gtk_widget_get_style_context (item->label), GTK_STYLE_PROVIDER (provider), 800);
@@ -56,6 +61,27 @@ set_color (CanvasItem *item,
g_free (css);
}
static void
set_css (CanvasItem *item,
const char *class)
{
GtkStyleContext *context;
GtkCssProvider *provider;
const char *old_class;
context = gtk_widget_get_style_context (item->label);
provider = g_object_get_data (G_OBJECT (context), "style-provider");
if (provider)
gtk_style_context_remove_provider (context, GTK_STYLE_PROVIDER (provider));
old_class = (const char *)g_object_get_data (G_OBJECT (item->label), "css-class");
if (old_class)
gtk_widget_remove_css_class (item->label, old_class);
g_object_set_data_full (G_OBJECT (item->label), "css-class", g_strdup (class), g_free);
gtk_widget_add_css_class (item->label, class);
}
static gboolean
item_drag_drop (GtkDropTarget *dest,
const GValue *value,
@@ -65,7 +91,10 @@ item_drag_drop (GtkDropTarget *dest,
GtkWidget *label = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (dest));
CanvasItem *item = CANVAS_ITEM (gtk_widget_get_parent (gtk_widget_get_parent (label)));
set_color (item, g_value_get_boxed (value));
if (G_VALUE_TYPE (value) == GDK_TYPE_RGBA)
set_color (item, g_value_get_boxed (value));
else if (G_VALUE_TYPE (value) == G_TYPE_STRING)
set_css (item, g_value_get_string (value));
return TRUE;
}
@@ -132,11 +161,13 @@ canvas_item_init (CanvasItem *item)
GdkRGBA rgba;
GtkDropTarget *dest;
GtkGesture *gesture;
GType types[2] = { GDK_TYPE_RGBA, G_TYPE_STRING };
n_items++;
text = g_strdup_printf ("Item %d", n_items);
item->label = gtk_label_new (text);
gtk_widget_add_css_class (item->label, "canvasitem");
g_free (text);
item->fixed = gtk_fixed_new ();
@@ -154,7 +185,8 @@ canvas_item_init (CanvasItem *item)
item->angle = 0;
dest = gtk_drop_target_new (GDK_TYPE_RGBA, GDK_ACTION_COPY);
dest = gtk_drop_target_new (G_TYPE_INVALID, GDK_ACTION_COPY);
gtk_drop_target_set_gtypes (dest, types, G_N_ELEMENTS (types));
g_signal_connect (dest, "drop", G_CALLBACK (item_drag_drop), NULL);
gtk_widget_add_controller (GTK_WIDGET (item->label), GTK_EVENT_CONTROLLER (dest));
@@ -529,6 +561,42 @@ canvas_new (void)
return canvas;
}
static GdkContentProvider *
css_drag_prepare (GtkDragSource *source,
double x,
double y,
GtkWidget *button)
{
const char *class;
GdkPaintable *paintable;
class = (const char *)g_object_get_data (G_OBJECT (button), "css-class");
paintable = gtk_widget_paintable_new (button);
gtk_drag_source_set_icon (source, paintable, 0, 0);
g_object_unref (paintable);
return gdk_content_provider_new_typed (G_TYPE_STRING, class);
}
static GtkWidget *
css_button_new (const char *class)
{
GtkWidget *button;
GtkDragSource *source;
button = gtk_image_new ();
gtk_widget_set_size_request (button, 48, 32);
gtk_widget_add_css_class (button, class);
g_object_set_data (G_OBJECT (button), "css-class", (gpointer)class);
source = gtk_drag_source_new ();
g_signal_connect (source, "prepare", G_CALLBACK (css_drag_prepare), button);
gtk_widget_add_controller (button, GTK_EVENT_CONTROLLER (source));
return button;
}
static GtkWidget *window = NULL;
GtkWidget *
@@ -548,10 +616,18 @@ do_dnd (GtkWidget *do_widget)
};
int i;
int x, y;
GtkCssProvider *provider;
button = gtk_color_button_new ();
g_object_unref (g_object_ref_sink (button));
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_resource (provider, "/dnd/dnd.css");
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
800);
g_object_unref (provider);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
@@ -583,7 +659,7 @@ do_dnd (GtkWidget *do_widget)
y += 100;
}
sw = gtk_scrolled_window_new (NULL, NULL);
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_NEVER);
@@ -606,6 +682,10 @@ do_dnd (GtkWidget *do_widget)
NULL);
gtk_box_append (GTK_BOX (box3), swatch);
}
gtk_box_append (GTK_BOX (box3), css_button_new ("rainbow1"));
gtk_box_append (GTK_BOX (box3), css_button_new ("rainbow2"));
gtk_box_append (GTK_BOX (box3), css_button_new ("rainbow3"));
}
if (!gtk_widget_get_visible (window))

37
demos/gtk-demo/dnd.css Normal file
View File

@@ -0,0 +1,37 @@
label.canvasitem {
padding: 10px;
margin: 1px;
}
.canvasitem.rainbow1,
image.rainbow1 {
background: linear-gradient(140deg,red,orange,yellow,green,blue,purple);
}
.canvasitem.rainbow2,
image.rainbow2 {
animation: rainbow2 1s infinite linear;
}
@keyframes rainbow2 {
0% { background: linear-gradient(0deg,red,orange,yellow,green,blue,purple); }
25% { background: linear-gradient(90deg,red,orange,yellow,green,blue,purple); }
50% { background: linear-gradient(180deg,red,orange,yellow,green,blue,purple); }
75% { background: linear-gradient(270deg,red,orange,yellow,green,blue,purple); }
100% { background: linear-gradient(360deg,red,orange,yellow,green,blue,purple); }
}
.canvasitem.rainbow3,
image.rainbow3 {
animation: rainbow3 1s infinite linear;
}
@keyframes rainbow3 {
0% { background: linear-gradient(140deg,red,orange,yellow,green,blue,purple); }
16.6% { background: linear-gradient(140deg,purple,red,orange,yellow,green,blue); }
33.2% { background: linear-gradient(140deg,blue,purple,red,orange,yellow,green); }
50% { background: linear-gradient(140deg,green,blue,purple,red,orange,yellow); }
66.6% { background: linear-gradient(140deg,yellow,green,blue,purple,red,orange); }
83.2% { background: linear-gradient(140deg,orange,yellow,green,blue,purple,red); }
100% { background: linear-gradient(140deg,red,orange,yellow,green,blue,purple); }
}

View File

@@ -9,6 +9,7 @@
* display the selected item differently from the presentation
* in the popup.
*/
#include <gtk/gtk.h>
@@ -242,7 +243,7 @@ do_dropdown (GtkWidget *do_widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Drop Down");
gtk_window_set_title (GTK_WINDOW (window), "Drop Downs");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);

View File

@@ -364,7 +364,7 @@ do_editable_cells (GtkWidget *do_widget)
gtk_box_append (GTK_BOX (vbox),
gtk_label_new ("Shopping list (you can edit the cells!)"));
sw = gtk_scrolled_window_new (NULL, NULL);
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,

View File

@@ -1,4 +1,4 @@
/* Entry/Entry Completion
/* Entry/Completion
*
* GtkEntryCompletion provides a mechanism for adding support for
* completion in GtkEntry.
@@ -12,22 +12,48 @@
static GtkTreeModel *
create_completion_model (void)
{
const char *strings[] = {
"GNOME",
"gnominious",
"Gnomonic projection",
"Gnosophy",
"total",
"totally",
"toto",
"tottery",
"totterer",
"Totten trust",
"Tottenham hotspurs",
"totipotent",
"totipotency",
"totemism",
"totem pole",
"Totara",
"totalizer",
"totalizator",
"totalitarianism",
"total parenteral nutrition",
"total eclipse",
"Totipresence",
"Totipalmi",
"zombie",
"aæx",
"aæy",
"aæz",
NULL
};
int i;
GtkListStore *store;
GtkTreeIter iter;
store = gtk_list_store_new (1, G_TYPE_STRING);
/* Append one word */
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, 0, "GNOME", -1);
/* Append another word */
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, 0, "total", -1);
/* And another word */
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, 0, "totally", -1);
for (i = 0; strings[i]; i++)
{
/* Append one word */
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, 0, strings[i], -1);
}
return GTK_TREE_MODEL (store);
}
@@ -48,7 +74,7 @@ do_entry_completion (GtkWidget *do_widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Entry Completion");
gtk_window_set_title (GTK_WINDOW (window), "Completion");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
@@ -60,7 +86,7 @@ do_entry_completion (GtkWidget *do_widget)
gtk_window_set_child (GTK_WINDOW (window), vbox);
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label), "Completion demo, try writing <b>total</b> or <b>gnome</b> for example.");
gtk_label_set_markup (GTK_LABEL (label), "Try writing <b>total</b> or <b>gnome</b> for example.");
gtk_box_append (GTK_BOX (vbox), label);
/* Create our entry */
@@ -81,6 +107,9 @@ do_entry_completion (GtkWidget *do_widget)
/* Use model column 0 as the text column */
gtk_entry_completion_set_text_column (completion, 0);
gtk_entry_completion_set_inline_completion (completion, TRUE);
gtk_entry_completion_set_inline_selection (completion, TRUE);
}
if (!gtk_widget_get_visible (window))

View File

@@ -1,8 +1,8 @@
/* Entry/Entry Undo
/* Entry/Undo and Redo
*
* GtkEntry can provide basic Undo/Redo support using standard keyboard
* accelerators such as Primary+z to undo and Primary+Shift+z to redo.
* Additionally, Primary+y can be used to redo.
* accelerators such as Control+z to undo and Control+Shift+z to redo.
* Additionally, Control+y can be used to redo.
*
* Use gtk_entry_set_enable_undo() to enable undo/redo support.
*/
@@ -23,7 +23,7 @@ do_entry_undo (GtkWidget *do_widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Entry Undo");
gtk_window_set_title (GTK_WINDOW (window), "Undo and Redo");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);

View File

@@ -57,7 +57,7 @@ do_expander (GtkWidget *do_widget)
expander = gtk_expander_new ("Details:");
gtk_widget_set_vexpand (expander, TRUE);
sw = gtk_scrolled_window_new (NULL, NULL);
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (sw), 100);
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),

View File

@@ -1,4 +1,4 @@
/* Fixed layout
/* Fixed Layout
*
* GtkFixed is a container that allows placing and transforming
* widgets manually.
@@ -126,11 +126,11 @@ create_demo_window (GtkWidget *do_widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Fixed layout");
gtk_window_set_title (GTK_WINDOW (window), "Fixed Layout");
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
g_signal_connect (window, "destroy", G_CALLBACK (close_window), NULL);
sw = gtk_scrolled_window_new (NULL, NULL);
sw = gtk_scrolled_window_new ();
gtk_window_set_child (GTK_WINDOW (window), sw);
fixed = gtk_fixed_new ();

View File

@@ -1,9 +1,8 @@
/* Flow Box
*
* GtkFlowBox allows flexible and responsive grids which reflow
* as needed and support sorting and filtering.
*
* The children of a GtkFlowBox are regular widgets
* as needed and support sorting and filtering. The children of
* a GtkFlowBox are regular widgets
*
* The dataset used here has 665 colors.
*/
@@ -728,7 +727,7 @@ do_flowbox (GtkWidget *do_widget)
gtk_window_set_default_size (GTK_WINDOW (window), 400, 600);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
scrolled = gtk_scrolled_window_new (NULL, NULL);
scrolled = gtk_scrolled_window_new ();
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
flowbox = gtk_flow_box_new ();
gtk_widget_set_valign (flowbox, GTK_ALIGN_START);

View File

@@ -108,10 +108,6 @@ gtk_fishbowl_measure (GtkWidget *widget,
{
child = value;
if (!gtk_widget_get_visible (child->widget))
continue;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
gtk_widget_measure (child->widget, orientation, -1, &child_min, &child_nat, NULL, NULL);
@@ -148,9 +144,6 @@ gtk_fishbowl_size_allocate (GtkWidget *widget,
{
child = value;
if (!gtk_widget_get_visible (child->widget))
continue;
gtk_widget_get_preferred_size (child->widget, &child_requisition, NULL);
child_allocation.x = round (child->x * (width - child_requisition.width));
child_allocation.y = round (child->y * (height - child_requisition.height));
@@ -197,17 +190,11 @@ gtk_fishbowl_remove (GtkFishbowl *fishbowl,
GtkWidget *widget)
{
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
GtkWidget *widget_bowl = GTK_WIDGET (fishbowl);
if (g_hash_table_remove (priv->children, widget))
{
gboolean was_visible = gtk_widget_get_visible (widget);
gtk_widget_unparent (widget);
if (was_visible && gtk_widget_get_visible (widget_bowl))
gtk_widget_queue_resize (widget_bowl);
priv->count--;
g_object_notify_by_pspec (G_OBJECT (fishbowl), props[PROP_COUNT]);
}

View File

@@ -260,7 +260,7 @@ do_hypertext (GtkWidget *do_widget)
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
gtk_text_buffer_set_enable_undo (buffer, TRUE);
sw = gtk_scrolled_window_new (NULL, NULL);
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);

View File

@@ -276,7 +276,7 @@ do_iconview (GtkWidget *do_widget)
gtk_box_append (GTK_BOX (tool_bar), home_button);
sw = gtk_scrolled_window_new (NULL, NULL);
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,

View File

@@ -269,7 +269,7 @@ do_list_store (GtkWidget *do_widget)
label = gtk_label_new ("This is the bug list (note: not based on real data, it would be nice to have a nice ODBC interface to bugzilla or so, though).");
gtk_box_append (GTK_BOX (vbox), label);
sw = gtk_scrolled_window_new (NULL, NULL);
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_NEVER,

View File

@@ -358,7 +358,7 @@ do_listbox (GtkWidget *do_widget)
gtk_window_set_child (GTK_WINDOW (window), vbox);
label = gtk_label_new ("Messages from GTK and friends");
gtk_box_append (GTK_BOX (vbox), label);
scrolled = gtk_scrolled_window_new (NULL, NULL);
scrolled = gtk_scrolled_window_new ();
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_widget_set_vexpand (scrolled, TRUE);
gtk_box_append (GTK_BOX (vbox), scrolled);

View File

@@ -188,7 +188,7 @@ do_listview_applauncher (GtkWidget *do_widget)
* because otherwise they might get too large or they might not
* be scrollable.
*/
sw = gtk_scrolled_window_new (NULL, NULL);
sw = gtk_scrolled_window_new ();
gtk_window_set_child (GTK_WINDOW (window), sw);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list);
}

View File

@@ -3,10 +3,9 @@
* This demo displays the time in different timezones.
*
* The goal is to show how to set up expressions that track changes
* in objects and make them update widgets.
*
* For that, we create a GtkClock object that updates its time every
* second and then use various ways to display that time.
* in objects and make them update widgets. For that, we create a
* GtkClock object that updates its time every second and then use
* various ways to display that time.
*
* Typically, this will be done using GtkBuilder .ui files with the
* help of the <binding> tag, but this demo shows the code that runs
@@ -41,7 +40,8 @@ enum {
/* This function returns the current time in the clock's timezone.
* Note that this returns a new object every time, so we need to
* remember to unref it after use. */
* remember to unref it after use.
*/
static GDateTime *
gtk_clock_get_time (GtkClock *clock)
{
@@ -51,10 +51,11 @@ gtk_clock_get_time (GtkClock *clock)
return g_date_time_new_now_local ();
}
/* Here, we implement the functionality required by the GdkPaintable interface.
* This way we have a trivial way to display an analog clock.
* It also allows demonstrating how to directly use objects in the listview
* later by making this object do something interesting. */
/* Here, we implement the functionality required by the GdkPaintable
* interface. This way we have a trivial way to display an analog clock.
* It also allows demonstrating how to directly use objects in the
* listview later by making this object do something interesting.
*/
static void
gtk_clock_snapshot (GdkPaintable *paintable,
GdkSnapshot *snapshot,
@@ -68,26 +69,31 @@ gtk_clock_snapshot (GdkPaintable *paintable,
#define BLACK ((GdkRGBA) { 0, 0, 0, 1 })
/* save/restore() is necessary so we can undo the transforms we start
* out with. */
* out with.
*/
gtk_snapshot_save (snapshot);
/* First, we move the (0, 0) point to the center of the area so
* we can draw everything relative to it. */
* we can draw everything relative to it.
*/
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (width / 2, height / 2));
/* Next we scale it, so that we can pretend that the clock is
* 100px in size. That way, we don't need to do any complicated
* math later.
* We use MIN() here so that we use the smaller dimension for sizing.
* That way we don't overdraw but keep the aspect ratio. */
* math later. We use MIN() here so that we use the smaller
* dimension for sizing. That way we don't overdraw but keep
* the aspect ratio.
*/
gtk_snapshot_scale (snapshot, MIN (width, height) / 100.0, MIN (width, height) / 100.0);
/* Now we have a circle with diameter 100px (and radius 50px) that
* has its (0, 0) point at the center.
* Let's draw a simple clock into it. */
/* Now we have a circle with diameter 100px (and radius 50px) that
* has its (0, 0) point at the center. Let's draw a simple clock into it.
*/
time = gtk_clock_get_time (self);
/* First, draw a circle. This is a neat little trick to draw a circle
* without requiring Cairo. */
* without requiring Cairo.
*/
gsk_rounded_rect_init_from_rect (&outline, &GRAPHENE_RECT_INIT(-50, -50, 100, 100), 50);
gtk_snapshot_append_border (snapshot,
&outline,
@@ -95,9 +101,11 @@ gtk_clock_snapshot (GdkPaintable *paintable,
(GdkRGBA [4]) { BLACK, BLACK, BLACK, BLACK });
/* Next, draw the hour hand.
* We do this using tranforms again: Instead of computing where the angle points
* to, we just rotate everything and then draw the hand as if if was :00.
* We don't even need to care about am/pm here because rotations just work. */
* We do this using tranforms again: Instead of computing where the angle
* points to, we just rotate everything and then draw the hand as if it
* was :00. We don't even need to care about am/pm here because rotations
* just work.
*/
gtk_snapshot_save (snapshot);
gtk_snapshot_rotate (snapshot, 30 * g_date_time_get_hour (time) + 0.5 * g_date_time_get_minute (time));
gsk_rounded_rect_init_from_rect (&outline, &GRAPHENE_RECT_INIT(-2, -23, 4, 25), 2);
@@ -107,7 +115,8 @@ gtk_clock_snapshot (GdkPaintable *paintable,
gtk_snapshot_restore (snapshot);
/* And the same as above for the minute hand. Just make this one longer
* so people can tell the hands apart. */
* so people can tell the hands apart.
*/
gtk_snapshot_save (snapshot);
gtk_snapshot_rotate (snapshot, 6 * g_date_time_get_minute (time));
gsk_rounded_rect_init_from_rect (&outline, &GRAPHENE_RECT_INIT(-2, -43, 4, 45), 2);
@@ -125,8 +134,9 @@ gtk_clock_snapshot (GdkPaintable *paintable,
gtk_snapshot_pop (snapshot);
gtk_snapshot_restore (snapshot);
/* And finally, don't forget to restore the initial save() that we did for
* the initial transformations. */
/* And finally, don't forget to restore the initial save() that
* we did for the initial transformations.
*/
gtk_snapshot_restore (snapshot);
g_date_time_unref (time);
@@ -145,10 +155,9 @@ gtk_clock_get_intrinsic_height (GdkPaintable *paintable)
return 100;
}
/* Initialize the paintable interface. This way we turn our clock objects
* into objects that can be drawn.
* There are more functions to this interface to define desired size,
* but this is enough.
/* Initialize the paintable interface. This way we turn our clocks
* into objects that can be drawn. There are more functions to this
* interface to define desired size, but this is enough.
*/
static void
gtk_clock_paintable_init (GdkPaintableInterface *iface)
@@ -158,8 +167,9 @@ gtk_clock_paintable_init (GdkPaintableInterface *iface)
iface->get_intrinsic_height = gtk_clock_get_intrinsic_height;
}
/* Finally, we define the type. The important part is adding the paintable
* interface, so GTK knows that this object can indeed be drawm.
/* Finally, we define the type. The important part is adding the
* paintable interface, so GTK knows that this object can indeed
* be drawn.
*/
G_DEFINE_TYPE_WITH_CODE (GtkClock, gtk_clock, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
@@ -221,11 +231,14 @@ gtk_clock_set_property (GObject *object,
/* This is the list of all the ticking clocks */
static GSList *ticking_clocks = NULL;
/* This is the id of the timeout source that is updating all ticking clocks */
/* This is the ID of the timeout source that is updating all
* ticking clocks.
*/
static guint ticking_clock_id = 0;
/* Every second, this function is called to tell everybody that the
* clocks are ticking.
/* Every second, this function is called to tell everybody that
* the clocks are ticking.
*/
static gboolean
gtk_clock_tick (gpointer unused)
@@ -236,10 +249,11 @@ gtk_clock_tick (gpointer unused)
{
GtkClock *clock = l->data;
/* We will now return a different value for the time porperty,
/* We will now return a different value for the time property,
* so notify about that.
*/
g_object_notify_by_pspec (G_OBJECT (clock), properties[PROP_TIME]);
/* We will also draw the hands of the clock differently.
* So notify about that, too.
*/
@@ -309,16 +323,16 @@ gtk_clock_init (GtkClock *self)
static GtkClock *
gtk_clock_new (const char *location,
GTimeZone *_timezone)
GTimeZone *_tz)
{
GtkClock *result;
result = g_object_new (GTK_TYPE_CLOCK,
"location", location,
"timezone", _timezone,
"timezone", _tz,
NULL);
g_clear_pointer (&_timezone, g_time_zone_unref);
g_clear_pointer (&_tz, g_time_zone_unref);
return result;
}
@@ -343,6 +357,9 @@ create_clocks_model (void)
clock = gtk_clock_new ("San Francisco", g_time_zone_new ("America/Los_Angeles"));
g_list_store_append (result, clock);
g_object_unref (clock);
clock = gtk_clock_new ("Xalapa", g_time_zone_new ("America/Mexico_City"));
g_list_store_append (result, clock);
g_object_unref (clock);
clock = gtk_clock_new ("Boston", g_time_zone_new ("America/New_York"));
g_list_store_append (result, clock);
g_object_unref (clock);
@@ -457,7 +474,7 @@ do_listview_clocks (GtkWidget *do_widget)
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *) &window);
/* List widgets go into a scrolled window. Always. */
sw = gtk_scrolled_window_new (NULL, NULL);
sw = gtk_scrolled_window_new ();
gtk_window_set_child (GTK_WINDOW (window), sw);
/* Create the factory that creates the listitems. Because we

View File

@@ -1,12 +1,17 @@
/* Lists/Colors
*
* This demo displays a list of named colors.
* This demo displays a grid of colors.
*
* It is using a GtkGridView, and shows how to display
* and sort the data in various ways. The controls for
* this are implemented using GtkDropDown.
*
* The dataset used here has 9283 items.
* The dataset used here has up to 16777216 items.
*
* Note that this demo also functions as a performance
* test for some of the list model machinery, and the
* biggest sizes here can lock up the application for
* extended times when used with sorting.
*/
#include <gtk/gtk.h>
@@ -23,9 +28,8 @@ struct _GtkColor
GObject parent_instance;
char *name;
GdkRGBA *color;
GdkRGBA color;
int h, s, v;
gboolean selected;
};
enum {
@@ -38,9 +42,8 @@ enum {
PROP_HUE,
PROP_SATURATION,
PROP_VALUE,
PROP_SELECTED,
N_PROPS
N_COLOR_PROPS
};
static void
@@ -51,7 +54,7 @@ gtk_color_snapshot (GdkPaintable *paintable,
{
GtkColor *self = GTK_COLOR (paintable);
gtk_snapshot_append_color (snapshot, self->color, &GRAPHENE_RECT_INIT (0, 0, width, height));
gtk_snapshot_append_color (snapshot, &self->color, &GRAPHENE_RECT_INIT (0, 0, width, height));
}
static int
@@ -82,7 +85,82 @@ G_DEFINE_TYPE_WITH_CODE (GtkColor, gtk_color, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
gtk_color_paintable_init))
static GParamSpec *properties[N_PROPS] = { NULL, };
static GParamSpec *color_properties[N_COLOR_PROPS] = { NULL, };
static void
rgb_to_hsv (GdkRGBA *rgba,
gdouble *h_out,
gdouble *s_out,
gdouble *v_out)
{
gdouble red, green, blue;
gdouble h, s, v;
gdouble min, max;
gdouble delta;
red = rgba->red;
green = rgba->green;
blue = rgba->blue;
h = 0.0;
if (red > green)
{
if (red > blue)
max = red;
else
max = blue;
if (green < blue)
min = green;
else
min = blue;
}
else
{
if (green > blue)
max = green;
else
max = blue;
if (red < blue)
min = red;
else
min = blue;
}
v = max;
if (max != 0.0)
s = (max - min) / max;
else
s = 0.0;
if (s == 0.0)
h = 0.0;
else
{
delta = max - min;
if (red == max)
h = (green - blue) / delta;
else if (green == max)
h = 2 + (blue - red) / delta;
else if (blue == max)
h = 4 + (red - green) / delta;
h /= 6.0;
if (h < 0.0)
h += 1.0;
else if (h > 1.0)
h -= 1.0;
}
*h_out = h;
*s_out = s;
*v_out = v;
}
static void
gtk_color_get_property (GObject *object,
@@ -99,19 +177,19 @@ gtk_color_get_property (GObject *object,
break;
case PROP_COLOR:
g_value_set_boxed (value, self->color);
g_value_set_boxed (value, &self->color);
break;
case PROP_RED:
g_value_set_float (value, self->color->red);
g_value_set_float (value, self->color.red);
break;
case PROP_GREEN:
g_value_set_float (value, self->color->green);
g_value_set_float (value, self->color.green);
break;
case PROP_BLUE:
g_value_set_float (value, self->color->blue);
g_value_set_float (value, self->color.blue);
break;
case PROP_HUE:
@@ -126,10 +204,6 @@ gtk_color_get_property (GObject *object,
g_value_set_int (value, self->v);
break;
case PROP_SELECTED:
g_value_set_boolean (value, self->selected);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -143,6 +217,7 @@ gtk_color_set_property (GObject *object,
GParamSpec *pspec)
{
GtkColor *self = GTK_COLOR (object);
double h, s, v;
switch (property_id)
{
@@ -151,23 +226,11 @@ gtk_color_set_property (GObject *object,
break;
case PROP_COLOR:
self->color = g_value_dup_boxed (value);
break;
case PROP_HUE:
self->h = g_value_get_int (value);
break;
case PROP_SATURATION:
self->s = g_value_get_int (value);
break;
case PROP_VALUE:
self->v = g_value_get_int (value);
break;
case PROP_SELECTED:
self->selected = g_value_get_boolean (value);
self->color = *(GdkRGBA *) g_value_dup_boxed (value);
rgb_to_hsv (&self->color, &h, &s, &v);
self->h = round (360 * h);
self->s = round (100 * s);
self->v = round (100 * v);
break;
default:
@@ -182,7 +245,6 @@ gtk_color_finalize (GObject *object)
GtkColor *self = GTK_COLOR (object);
g_free (self->name);
g_clear_pointer (&self->color, gdk_rgba_free);
G_OBJECT_CLASS (gtk_color_parent_class)->finalize (object);
}
@@ -196,26 +258,24 @@ gtk_color_class_init (GtkColorClass *klass)
gobject_class->set_property = gtk_color_set_property;
gobject_class->finalize = gtk_color_finalize;
properties[PROP_NAME] =
color_properties[PROP_NAME] =
g_param_spec_string ("name", NULL, NULL, NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
properties[PROP_COLOR] =
color_properties[PROP_COLOR] =
g_param_spec_boxed ("color", NULL, NULL, GDK_TYPE_RGBA, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
properties[PROP_RED] =
color_properties[PROP_RED] =
g_param_spec_float ("red", NULL, NULL, 0, 1, 0, G_PARAM_READABLE);
properties[PROP_GREEN] =
color_properties[PROP_GREEN] =
g_param_spec_float ("green", NULL, NULL, 0, 1, 0, G_PARAM_READABLE);
properties[PROP_BLUE] =
color_properties[PROP_BLUE] =
g_param_spec_float ("blue", NULL, NULL, 0, 1, 0, G_PARAM_READABLE);
properties[PROP_HUE] =
g_param_spec_int ("hue", NULL, NULL, 0, 360, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
properties[PROP_SATURATION] =
g_param_spec_int ("saturation", NULL, NULL, 0, 100, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
properties[PROP_VALUE] =
g_param_spec_int ("value", NULL, NULL, 0, 100, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
properties[PROP_SELECTED] =
g_param_spec_boolean ("selected", NULL, NULL, FALSE, G_PARAM_READWRITE);
color_properties[PROP_HUE] =
g_param_spec_int ("hue", NULL, NULL, 0, 360, 0, G_PARAM_READABLE);
color_properties[PROP_SATURATION] =
g_param_spec_int ("saturation", NULL, NULL, 0, 100, 0, G_PARAM_READABLE);
color_properties[PROP_VALUE] =
g_param_spec_int ("value", NULL, NULL, 0, 100, 0, G_PARAM_READABLE);
g_object_class_install_properties (gobject_class, N_PROPS, properties);
g_object_class_install_properties (gobject_class, N_COLOR_PROPS, color_properties);
}
static void
@@ -225,8 +285,7 @@ gtk_color_init (GtkColor *self)
static GtkColor *
gtk_color_new (const char *name,
float r, float g, float b,
int h, int s, int v)
float r, float g, float b)
{
GtkColor *result;
GdkRGBA color = { r, g, b, 1.0 };
@@ -234,24 +293,206 @@ gtk_color_new (const char *name,
result = g_object_new (GTK_TYPE_COLOR,
"name", name,
"color", &color,
"hue", h,
"saturation", s,
"value", v,
NULL);
return result;
}
static GListModel *
create_colors_model (void)
#define N_COLORS (256 * 256 * 256)
#define GTK_TYPE_COLOR_LIST (gtk_color_list_get_type ())
G_DECLARE_FINAL_TYPE (GtkColorList, gtk_color_list, GTK, COLOR_LIST, GObject)
enum {
LIST_PROP_0,
LIST_PROP_SIZE,
N_LIST_PROPS
};
typedef struct _GtkColorList GtkColorList;
struct _GtkColorList
{
GObject parent_instance;
GtkColor **colors; /* Always N_COLORS */
guint size; /* How many colors we allow */
};
static GType
gtk_color_list_get_item_type (GListModel *list)
{
return GTK_TYPE_COLOR;
}
static guint
gtk_color_list_get_n_items (GListModel *list)
{
GtkColorList *self = GTK_COLOR_LIST (list);
return self->size;
}
static guint
position_to_color (guint position)
{
static guint map[] = {
0xFF0000, 0x00FF00, 0x0000FF,
0x7F0000, 0x007F00, 0x00007F,
0x3F0000, 0x003F00, 0x00003F,
0x1F0000, 0x001F00, 0x00001F,
0x0F0000, 0x000F00, 0x00000F,
0x070000, 0x000700, 0x000007,
0x030000, 0x000300, 0x000003,
0x010000, 0x000100, 0x000001
};
guint result, i;
result = 0;
for (i = 0; i < G_N_ELEMENTS (map); i++)
{
if (position & (1 << i))
result ^= map[i];
}
return result;
}
static gpointer
gtk_color_list_get_item (GListModel *list,
guint position)
{
GtkColorList *self = GTK_COLOR_LIST (list);
if (position >= self->size)
return NULL;
position = position_to_color (position);
if (self->colors[position] == NULL)
{
guint red, green, blue;
red = (position >> 16) & 0xFF;
green = (position >> 8) & 0xFF;
blue = position & 0xFF;
self->colors[position] = gtk_color_new ("", red / 255., green / 255., blue / 255.);
}
return g_object_ref (self->colors[position]);
}
static void
gtk_color_list_model_init (GListModelInterface *iface)
{
iface->get_item_type = gtk_color_list_get_item_type;
iface->get_n_items = gtk_color_list_get_n_items;
iface->get_item = gtk_color_list_get_item;
}
G_DEFINE_TYPE_WITH_CODE (GtkColorList, gtk_color_list, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL,
gtk_color_list_model_init))
static GParamSpec *list_properties[N_LIST_PROPS] = { NULL, };
static void
gtk_color_list_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GtkColorList *self = GTK_COLOR_LIST (object);
switch (property_id)
{
case LIST_PROP_SIZE:
g_value_set_uint (value, self->size);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gtk_color_list_set_size (GtkColorList *self,
guint size)
{
guint old_size = self->size;
self->size = size;
if (self->size > old_size)
g_list_model_items_changed (G_LIST_MODEL (self), old_size, 0, self->size - old_size);
else if (old_size > self->size)
g_list_model_items_changed (G_LIST_MODEL (self), self->size, old_size - self->size, 0);
g_object_notify_by_pspec (G_OBJECT (self), list_properties[LIST_PROP_SIZE]);
}
static void
gtk_color_list_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GtkColorList *self = GTK_COLOR_LIST (object);
switch (property_id)
{
case LIST_PROP_SIZE:
gtk_color_list_set_size (self, g_value_get_uint (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gtk_color_list_dispose (GObject *object)
{
GtkColorList *self = GTK_COLOR_LIST (object);
guint i;
for (i = 0; i < N_COLORS; i++)
{
g_clear_object (&self->colors[i]);
}
g_free (self->colors);
G_OBJECT_CLASS (gtk_color_parent_class)->finalize (object);
}
static void
gtk_color_list_class_init (GtkColorListClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->get_property = gtk_color_list_get_property;
gobject_class->set_property = gtk_color_list_set_property;
gobject_class->dispose = gtk_color_list_dispose;
list_properties[LIST_PROP_SIZE] =
g_param_spec_uint ("size", NULL, NULL, 0, N_COLORS, 0, G_PARAM_READWRITE);
g_object_class_install_properties (gobject_class, N_LIST_PROPS, list_properties);
}
static void
gtk_color_list_init (GtkColorList *self)
{
GListStore *result;
GtkColor *color;
GBytes *data;
char **lines;
guint i;
result = g_list_store_new (GTK_TYPE_COLOR);
self->colors = g_new0 (GtkColor *, N_COLORS);
data = g_resources_lookup_data ("/listview_colors/color.names.txt", 0, NULL);
lines = g_strsplit (g_bytes_get_data (data, NULL), "\n", 0);
@@ -260,7 +501,7 @@ create_colors_model (void)
const char *name;
char **fields;
int red, green, blue;
int h, s, v;
guint pos;
if (lines[i][0] == '#' || lines[i][0] == '\0')
continue;
@@ -270,21 +511,24 @@ create_colors_model (void)
red = atoi (fields[3]);
green = atoi (fields[4]);
blue = atoi (fields[5]);
h = atoi (fields[9]);
s = atoi (fields[10]);
v = atoi (fields[11]);
color = gtk_color_new (name, red / 255., green / 255., blue / 255., h, s, v);
g_list_store_append (result, color);
g_object_unref (color);
pos = ((red & 0xFF) << 16) | ((green & 0xFF) << 8) | blue;
if (self->colors[pos] == NULL)
self->colors[pos] = gtk_color_new (name, red / 255., green / 255., blue / 255.);
g_strfreev (fields);
}
g_strfreev (lines);
g_bytes_unref (data);
}
return G_LIST_MODEL (result);
static GListModel *
gtk_color_list_new (guint size)
{
return g_object_new (GTK_TYPE_COLOR_LIST,
"size", size,
NULL);
}
static char *
@@ -295,9 +539,9 @@ get_rgb_markup (gpointer this,
return NULL;
return g_strdup_printf ("<b>R:</b> %d <b>G:</b> %d <b>B:</b> %d",
(int)(color->color->red * 255),
(int)(color->color->green * 255),
(int)(color->color->blue * 255));
(int)(color->color.red * 255),
(int)(color->color.green * 255),
(int)(color->color.blue * 255));
}
static char *
@@ -396,29 +640,6 @@ get_title (gpointer item)
return g_strdup ((char *)g_object_get_data (G_OBJECT (item), "title"));
}
static gboolean
set_item (GBinding *binding,
const GValue *from,
GValue *to,
gpointer data)
{
GObject *source = g_binding_get_source (binding);
GListModel *model;
guint selected;
gpointer item;
selected = g_value_get_uint (from);
model = gtk_drop_down_get_model (GTK_DROP_DOWN (source));
item = g_list_model_get_item (model, selected);
g_value_set_object (to, item);
g_clear_object (&item);
return TRUE;
}
GtkWidget *
create_color_grid (void)
{
@@ -438,8 +659,9 @@ create_color_grid (void)
gtk_grid_view_set_max_columns (GTK_GRID_VIEW (gridview), 24);
gtk_grid_view_set_enable_rubberband (GTK_GRID_VIEW (gridview), TRUE);
model = G_LIST_MODEL (gtk_sort_list_model_new (create_colors_model (), NULL));
selection = G_LIST_MODEL (gtk_property_selection_new (model, "selected"));
model = G_LIST_MODEL (gtk_sort_list_model_new (gtk_color_list_new (0), NULL));
selection = G_LIST_MODEL (gtk_multi_selection_new (model));
gtk_grid_view_set_model (GTK_GRID_VIEW (gridview), selection);
g_object_unref (selection);
g_object_unref (model);
@@ -447,6 +669,114 @@ create_color_grid (void)
return gridview;
}
static gboolean
add_colors (GtkWidget *widget,
GdkFrameClock *clock,
gpointer data)
{
GtkColorList *colors = data;
guint limit;
limit = GPOINTER_TO_UINT (g_object_get_data (data, "limit"));
gtk_color_list_set_size (colors, MIN (limit, colors->size + MAX (1, limit / 4096)));
if (colors->size >= limit)
return G_SOURCE_REMOVE;
else
return G_SOURCE_CONTINUE;
}
static void
refill (GtkWidget *button,
GtkColorList *colors)
{
gtk_color_list_set_size (colors, 0);
gtk_widget_add_tick_callback (button, add_colors, g_object_ref (colors), g_object_unref);
}
static void
limit_changed_cb (GtkDropDown *dropdown,
GParamSpec *pspec,
GtkColorList *colors)
{
guint new_limit, old_limit;
old_limit = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (colors), "limit"));
new_limit = 1 << (3 * (gtk_drop_down_get_selected (dropdown) + 1));
g_object_set_data (G_OBJECT (colors), "limit", GUINT_TO_POINTER (new_limit));
if (old_limit == colors->size)
gtk_color_list_set_size (colors, new_limit);
}
static void
limit_changed_cb2 (GtkDropDown *dropdown,
GParamSpec *pspec,
GtkLabel *label)
{
char *string;
int len;
guint limit;
limit = 1 << (3 * (gtk_drop_down_get_selected (dropdown) + 1));
string = g_strdup_printf ("%'u", limit);
len = g_utf8_strlen (string, -1);
g_free (string);
gtk_label_set_width_chars (label, len + 2); /* for " /" */
}
static void
items_changed_cb (GListModel *model,
guint position,
guint removed,
guint added,
GtkWidget *label)
{
guint n = g_list_model_get_n_items (model);
char *text;
text = g_strdup_printf ("%'u /", n);
gtk_label_set_label (GTK_LABEL (label), text);
g_free (text);
}
static void
setup_number_item (GtkSignalListItemFactory *factory,
GtkListItem *item)
{
GtkWidget *label;
PangoAttrList *attrs;
label = gtk_label_new ("");
gtk_label_set_xalign (GTK_LABEL (label), 1);
attrs = pango_attr_list_new ();
pango_attr_list_insert (attrs, pango_attr_font_features_new ("tnum"));
gtk_label_set_attributes (GTK_LABEL (label), attrs);
pango_attr_list_unref (attrs);
gtk_list_item_set_child (item, label);
}
static void
bind_number_item (GtkSignalListItemFactory *factory,
GtkListItem *item)
{
GtkWidget *label;
guint limit;
char *string;
label = gtk_list_item_get_child (item);
limit = 1 << (3 * (gtk_list_item_get_position (item) + 1));
string = g_strdup_printf ("%'u", limit);
gtk_label_set_label (GTK_LABEL (label), string);
g_free (string);
}
static GtkWidget *window = NULL;
GtkWidget *
@@ -458,11 +788,15 @@ do_listview_colors (GtkWidget *do_widget)
GtkListItemFactory *factory;
GListStore *factories;
GListModel *model;
GtkSorter *sorter;
GtkSorter *multi_sorter;
GListStore *sorters;
GtkExpression *expression;
GtkWidget *button;
GtkWidget *label;
PangoAttrList *attrs;
char *string;
guint len;
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Colors");
@@ -475,7 +809,7 @@ do_listview_colors (GtkWidget *do_widget)
gtk_widget_get_display (do_widget));
g_object_add_weak_pointer (G_OBJECT (window), (gpointer*)&window);
sw = gtk_scrolled_window_new (NULL, NULL);
sw = gtk_scrolled_window_new ();
gtk_window_set_child (GTK_WINDOW (window), sw);
gridview = create_color_grid ();
@@ -483,8 +817,54 @@ do_listview_colors (GtkWidget *do_widget)
model = gtk_grid_view_get_model (GTK_GRID_VIEW (gridview));
g_object_get (model, "model", &model, NULL);
button = gtk_button_new_with_mnemonic ("_Refill");
g_signal_connect (button, "clicked",
G_CALLBACK (refill),
gtk_sort_list_model_get_model (GTK_SORT_LIST_MODEL (model)));
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), button);
label = gtk_label_new ("0 /");
attrs = pango_attr_list_new ();
pango_attr_list_insert (attrs, pango_attr_font_features_new ("tnum"));
gtk_label_set_attributes (GTK_LABEL (label), attrs);
pango_attr_list_unref (attrs);
string = g_strdup_printf ("%'u", 4096);
len = g_utf8_strlen (string, -1);
g_free (string);
gtk_label_set_width_chars (GTK_LABEL (label), len + 2);
gtk_label_set_xalign (GTK_LABEL (label), 1);
g_signal_connect (gtk_grid_view_get_model (GTK_GRID_VIEW (gridview)),
"items-changed", G_CALLBACK (items_changed_cb), label);
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), label);
dropdown = gtk_drop_down_new ();
gtk_drop_down_set_from_strings (GTK_DROP_DOWN (dropdown), (const char *[]) { "8", "64", "512", "4096", "32768", "262144", "2097152", "16777216", NULL });
g_signal_connect (dropdown, "notify::selected",
G_CALLBACK (limit_changed_cb),
gtk_sort_list_model_get_model (GTK_SORT_LIST_MODEL (model)));
g_signal_connect (dropdown, "notify::selected",
G_CALLBACK (limit_changed_cb2),
label);
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_number_item), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_number_item), NULL);
gtk_drop_down_set_factory (GTK_DROP_DOWN (dropdown), factory);
g_object_unref (factory);
gtk_drop_down_set_selected (GTK_DROP_DOWN (dropdown), 3); /* 4096 */
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), dropdown);
sorters = g_list_store_new (GTK_TYPE_SORTER);
/* An empty multisorter doesn't do any sorting and the sortmodel is
* smart enough to know that.
*/
sorter = gtk_multi_sorter_new ();
set_title (sorter, "Unsorted");
g_list_store_append (sorters, sorter);
g_object_unref (sorter);
sorter = gtk_string_sorter_new (gtk_property_expression_new (GTK_TYPE_COLOR, NULL, "name"));
set_title (sorter, "Name");
g_list_store_append (sorters, sorter);
@@ -555,11 +935,7 @@ do_listview_colors (GtkWidget *do_widget)
gtk_drop_down_set_model (GTK_DROP_DOWN (dropdown), G_LIST_MODEL (sorters));
g_object_unref (sorters);
g_object_bind_property_full (dropdown, "selected",
model, "sorter",
G_BINDING_SYNC_CREATE,
set_item, NULL,
NULL, NULL);
g_object_bind_property (dropdown, "selected-item", model, "sorter", G_BINDING_SYNC_CREATE);
factories = g_list_store_new (GTK_TYPE_LIST_ITEM_FACTORY);
@@ -590,11 +966,7 @@ do_listview_colors (GtkWidget *do_widget)
gtk_drop_down_set_model (GTK_DROP_DOWN (dropdown), G_LIST_MODEL (factories));
g_object_unref (factories);
g_object_bind_property_full (dropdown, "selected",
gridview, "factory",
G_BINDING_SYNC_CREATE,
set_item, NULL,
NULL, NULL);
g_object_bind_property (dropdown, "selected-item", gridview, "factory", G_BINDING_SYNC_CREATE);
g_object_unref (model);
}

View File

@@ -143,8 +143,9 @@ settings_key_new (GSettings *settings,
}
static void
item_value_changed (GtkListItem *item,
GtkEntry *entry)
item_value_changed (GtkEditableLabel *label,
GParamSpec *pspec,
GtkListItem *item)
{
SettingsKey *self;
const char *text;
@@ -152,8 +153,9 @@ item_value_changed (GtkListItem *item,
GVariant *variant;
GError *error = NULL;
const char *name;
char *value;
text = gtk_editable_get_text (GTK_EDITABLE (entry));
text = gtk_editable_get_text (GTK_EDITABLE (label));
g_object_get (item, "item", &self, NULL);
g_object_unref (self);
@@ -166,17 +168,25 @@ item_value_changed (GtkListItem *item,
{
g_warning ("%s", error->message);
g_clear_error (&error);
return;
goto revert;
}
if (!g_settings_schema_key_range_check (self->key, variant))
{
g_warning ("Not a valid value for %s", name);
return;
goto revert;
}
g_settings_set_value (self->settings, name, variant);
g_variant_unref (variant);
return;
revert:
gtk_widget_error_bell (GTK_WIDGET (label));
g_object_get (self, "value", &value, NULL);
gtk_editable_set_text (GTK_EDITABLE (label), value);
g_free (value);
}
static int

View File

@@ -113,14 +113,13 @@
<interface>
<template class="GtkListItem">
<property name="child">
<object class="GtkEntry">
<signal name="activate" handler="item_value_changed" object="GtkListItem" swapped="yes"/>
<property name="xalign">0</property>
<object class="GtkEditableLabel">
<binding name="text">
<lookup name="value" type="SettingsKey">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
<signal name="notify::label" handler="item_value_changed"/>
</object>
</property>
</template>

View File

@@ -11,7 +11,7 @@
* A GtkNoSelectionModel is used to make sure no item in the list can be
* selected. All other interactions with the items is still possible.
*
* The dataset used here has 70000 items.
* The dataset used here has 70000 items.
*/
#include <gtk/gtk.h>
@@ -70,7 +70,6 @@ gtk_weather_info_new (GDateTime *timestamp,
{
result->temperature = copy_from->temperature;
result->weather_type = copy_from->weather_type;
g_object_unref (copy_from);
}
return result;
@@ -78,13 +77,13 @@ gtk_weather_info_new (GDateTime *timestamp,
static GDateTime *
parse_timestamp (const char *string,
GTimeZone *_timezone)
GTimeZone *_tz)
{
char *with_seconds;
GDateTime *result;
with_seconds = g_strconcat (string, ":00", NULL);
result = g_date_time_new_from_iso8601 (with_seconds, _timezone);
result = g_date_time_new_from_iso8601 (with_seconds, _tz);
g_free (with_seconds);
return result;
@@ -161,6 +160,7 @@ create_weather_model (void)
timestamp = g_date_time_new (utc, 2011, 1, 1, 0, 0, 0);
info = gtk_weather_info_new (timestamp, NULL);
g_list_store_append (store, info);
g_object_unref (info);
for (i = 0; lines[i] != NULL && *lines[i]; i++)
{
@@ -176,6 +176,7 @@ create_weather_model (void)
timestamp = new_timestamp;
info = gtk_weather_info_new (timestamp, info);
g_list_store_append (store, info);
g_object_unref (info);
}
info->temperature = parse_temperature (fields[1], info->temperature);
@@ -184,6 +185,7 @@ create_weather_model (void)
g_strfreev (fields);
}
g_date_time_unref (timestamp);
g_strfreev (lines);
g_bytes_unref (data);
g_time_zone_unref (utc);
@@ -311,7 +313,7 @@ do_listview_weather (GtkWidget *do_widget)
gtk_window_set_title (GTK_WINDOW (window), "Weather");
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *) &window);
sw = gtk_scrolled_window_new (NULL, NULL);
sw = gtk_scrolled_window_new ();
gtk_window_set_child (GTK_WINDOW (window), sw);
listview = create_weather_view ();
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), listview);

View File

@@ -0,0 +1,241 @@
/* Lists/Words
*
* This demo shows filtering a long list - of words.
*
* You should have the file `/usr/share/dict/words` installed for
* this demo to work.
*/
#include <gtk/gtk.h>
static GtkWidget *window = NULL;
static GtkWidget *progress;
const char *factory_text =
"<?xml version='1.0' encoding='UTF-8'?>\n"
"<interface>\n"
" <template class='GtkListItem'>\n"
" <property name='child'>\n"
" <object class='GtkLabel'>\n"
" <property name='ellipsize'>end</property>\n"
" <property name='xalign'>0</property>\n"
" <binding name='label'>\n"
" <lookup name='string' type='GtkStringObject'>\n"
" <lookup name='item'>GtkListItem</lookup>\n"
" </lookup>\n"
" </binding>\n"
" </object>\n"
" </property>\n"
" </template>\n"
"</interface>\n";
static void
update_title_cb (GtkFilterListModel *model)
{
guint total;
char *title;
guint pending;
total = g_list_model_get_n_items (gtk_filter_list_model_get_model (model));
pending = gtk_filter_list_model_get_pending (model);
title = g_strdup_printf ("%u lines", g_list_model_get_n_items (G_LIST_MODEL (model)));
gtk_widget_set_visible (progress, pending != 0);
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress), (total - pending) / (double) total);
gtk_window_set_title (GTK_WINDOW (window), title);
g_free (title);
}
static void
read_lines_cb (GObject *object,
GAsyncResult *result,
gpointer data)
{
GBufferedInputStream *stream = G_BUFFERED_INPUT_STREAM (object);
GtkStringList *stringlist = data;
GError *error = NULL;
gsize size;
GPtrArray *lines;
gssize n_filled;
const char *buffer, *newline;
n_filled = g_buffered_input_stream_fill_finish (stream, result, &error);
if (n_filled < 0)
{
g_print ("Could not read data: %s\n", error->message);
g_clear_error (&error);
return;
}
buffer = g_buffered_input_stream_peek_buffer (stream, &size);
if (n_filled == 0)
{
if (size)
gtk_string_list_take (stringlist, g_utf8_make_valid (buffer, size));
return;
}
lines = NULL;
while ((newline = memchr (buffer, '\n', size)))
{
if (newline > buffer)
{
if (lines == NULL)
lines = g_ptr_array_new_with_free_func (g_free);
g_ptr_array_add (lines, g_utf8_make_valid (buffer, newline - buffer));
}
if (g_input_stream_skip (G_INPUT_STREAM (stream), newline - buffer + 1, NULL, &error) < 0)
{
g_clear_error (&error);
break;
}
buffer = g_buffered_input_stream_peek_buffer (stream, &size);
}
if (lines == NULL)
{
g_buffered_input_stream_set_buffer_size (stream, g_buffered_input_stream_get_buffer_size (stream) + 4096);
}
else
{
g_ptr_array_add (lines, NULL);
gtk_string_list_splice (stringlist, g_list_model_get_n_items (G_LIST_MODEL (stringlist)), 0, (const char **) lines->pdata);
g_ptr_array_free (lines, TRUE);
}
g_buffered_input_stream_fill_async (stream, -1, G_PRIORITY_HIGH_IDLE, NULL, read_lines_cb, data);
}
static void
file_is_open_cb (GObject *file,
GAsyncResult *result,
gpointer data)
{
GError *error = NULL;
GFileInputStream *file_stream;
GBufferedInputStream *stream;
file_stream = g_file_read_finish (G_FILE (file), result, &error);
if (file_stream == NULL)
{
g_print ("Could not open file: %s\n", error->message);
g_error_free (error);
return;
}
stream = G_BUFFERED_INPUT_STREAM (g_buffered_input_stream_new (G_INPUT_STREAM (file_stream)));
g_buffered_input_stream_fill_async (stream, -1, G_PRIORITY_HIGH_IDLE, NULL, read_lines_cb, data);
g_object_unref (stream);
}
static void
load_file (GtkStringList *list,
GFile *file)
{
gtk_string_list_splice (list, 0, g_list_model_get_n_items (G_LIST_MODEL (list)), NULL);
g_file_read_async (file, G_PRIORITY_HIGH_IDLE, NULL, file_is_open_cb, list);
}
static void
file_selected_cb (GtkWidget *button,
GtkStringList *stringlist)
{
GFile *file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (button));
if (file)
{
load_file (stringlist, file);
g_object_unref (file);
}
}
GtkWidget *
do_listview_words (GtkWidget *do_widget)
{
if (window == NULL)
{
GtkWidget *header, *listview, *sw, *vbox, *search_entry, *open_button, *overlay;
GtkFilterListModel *filter_model;
GtkNoSelection *selection;
GtkStringList *stringlist;
GtkFilter *filter;
GtkExpression *expression;
GFile *file;
file = g_file_new_for_path ("/usr/share/dict/words");
if (g_file_query_exists (file, NULL))
{
stringlist = gtk_string_list_new (NULL);
load_file (stringlist, file);
}
else
{
char **words;
words = g_strsplit ("lorem ipsum dolor sit amet consectetur adipisci elit sed eiusmod tempor incidunt labore et dolore magna aliqua ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat", " ", -1);
stringlist = gtk_string_list_new ((const char **) words);
g_strfreev (words);
}
filter = gtk_string_filter_new ();
expression = gtk_property_expression_new (GTK_TYPE_STRING_OBJECT, NULL, "string");
gtk_string_filter_set_expression (GTK_STRING_FILTER (filter), expression);
gtk_expression_unref (expression);
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (stringlist), filter);
gtk_filter_list_model_set_incremental (filter_model, TRUE);
window = gtk_window_new ();
gtk_window_set_default_size (GTK_WINDOW (window), 400, 600);
header = gtk_header_bar_new ();
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE);
open_button = gtk_file_chooser_button_new ("_Open", GTK_FILE_CHOOSER_ACTION_OPEN);
g_signal_connect (open_button, "file-set", G_CALLBACK (file_selected_cb), stringlist);
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), open_button);
gtk_window_set_titlebar (GTK_WINDOW (window), header);
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
g_object_add_weak_pointer (G_OBJECT (window), (gpointer*)&window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_window_set_child (GTK_WINDOW (window), vbox);
search_entry = gtk_search_entry_new ();
g_object_bind_property (search_entry, "text", filter, "search", 0);
gtk_box_append (GTK_BOX (vbox), search_entry);
overlay = gtk_overlay_new ();
gtk_box_append (GTK_BOX (vbox), overlay);
progress = gtk_progress_bar_new ();
gtk_widget_set_halign (progress, GTK_ALIGN_FILL);
gtk_widget_set_valign (progress, GTK_ALIGN_START);
gtk_widget_set_hexpand (progress, TRUE);
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), progress);
sw = gtk_scrolled_window_new ();
gtk_overlay_set_child (GTK_OVERLAY (overlay), sw);
listview = gtk_list_view_new_with_factory (
gtk_builder_list_item_factory_new_from_bytes (NULL,
g_bytes_new_static (factory_text, strlen (factory_text))));
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), listview);
selection = gtk_no_selection_new (G_LIST_MODEL (filter_model));
gtk_list_view_set_model (GTK_LIST_VIEW (listview), G_LIST_MODEL (selection));
g_object_unref (selection);
g_signal_connect (filter_model, "items-changed", G_CALLBACK (update_title_cb), progress);
g_signal_connect (filter_model, "notify::pending", G_CALLBACK (update_title_cb), progress);
update_title_cb (filter_model);
g_object_unref (filter_model);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_window_destroy (GTK_WINDOW (window));
return window;
}

View File

@@ -133,7 +133,7 @@ gtk_demo_run (GtkDemo *self,
}
return TRUE;
}
static void
activate_about (GSimpleAction *action,
GVariant *parameter,
@@ -599,10 +599,10 @@ display_image (const char *resource)
{
GtkWidget *sw, *image;
image = gtk_image_new_from_resource (resource);
image = gtk_picture_new_for_resource (resource);
gtk_widget_set_halign (image, GTK_ALIGN_CENTER);
gtk_widget_set_valign (image, GTK_ALIGN_CENTER);
sw = gtk_scrolled_window_new (NULL, NULL);
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), image);
return sw;
@@ -642,7 +642,7 @@ display_text (const char *resource)
g_bytes_unref (bytes);
sw = gtk_scrolled_window_new (NULL, NULL);
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
@@ -1035,19 +1035,18 @@ activate (GApplication *app)
listview = GTK_WIDGET (gtk_builder_get_object (builder, "listview"));
g_signal_connect (listview, "activate", G_CALLBACK (activate_cb), window);
load_file (gtk_demos[0].name, gtk_demos[0].filename);
listmodel = create_demo_model ();
treemodel = gtk_tree_list_model_new (FALSE,
G_LIST_MODEL (listmodel),
FALSE,
TRUE,
get_child_model,
NULL,
NULL);
selection = gtk_single_selection_new (G_LIST_MODEL (treemodel));
g_signal_connect (selection, "notify::selected-item", G_CALLBACK (selection_cb), NULL);
gtk_list_view_set_model (GTK_LIST_VIEW (listview),
G_LIST_MODEL (selection));
gtk_list_view_set_model (GTK_LIST_VIEW (listview), G_LIST_MODEL (selection));
selection_cb (selection, NULL, NULL);
g_object_unref (builder);
}
@@ -1156,7 +1155,7 @@ out:
static void
print_version (void)
{
g_print ("gtk3-demo %d.%d.%d\n",
g_print ("gtk4-demo %d.%d.%d\n",
gtk_get_major_version (),
gtk_get_minor_version (),
gtk_get_micro_version ());
@@ -1198,16 +1197,6 @@ main (int argc, char **argv)
};
int i;
/* Most code in gtk-demo is intended to be exemplary, but not
* these few lines, which are just a hack so gtk-demo will work
* in the GTK tree without installing it.
*/
if (g_file_test ("../../modules/input/immodules.cache", G_FILE_TEST_EXISTS))
{
g_setenv ("GTK_IM_MODULE_FILE", "../../modules/input/immodules.cache", TRUE);
}
/* -- End of hack -- */
app = gtk_application_new ("org.gtk.Demo4", G_APPLICATION_NON_UNIQUE|G_APPLICATION_HANDLES_COMMAND_LINE);
g_action_map_add_action_entries (G_ACTION_MAP (app),

View File

@@ -16,15 +16,6 @@
</item>
</section>
</menu>
<object class="GtkTreeStore" id="treestore">
<columns>
<column type="gchararray"/>
<column type="gchararray"/>
<column type="gchararray"/>
<column type="gpointer"/>
<column type="gint"/>
</columns>
</object>
<object class="GtkApplicationWindow" id="window">
<style>
<class name="devel"/>

View File

@@ -81,7 +81,7 @@ do_markup (GtkWidget *do_widget)
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 10);
gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view), 10);
sw = gtk_scrolled_window_new (NULL, NULL);
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
@@ -94,7 +94,7 @@ do_markup (GtkWidget *do_widget)
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view2), 10);
gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view2), 10);
sw = gtk_scrolled_window_new (NULL, NULL);
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);

View File

@@ -5,7 +5,7 @@ Text <span color="gray">c<span color="green">o</span>l<span color="tomato">o</sp
Colorful <span underline="low" underline-color="blue"><span underline="double" underline-color="red">under</span>lines</span> and <span background="pink"><span underline="error">mo</span><span underline="error" underline-color="green">re</span></span>
Colorful <span strikethrough="true" strikethrough-color="magenta">strikethroughs</span>
Colorful <span strikethrough="true" strikethrough-color="magenta">strikethroughs</span> and <span overline="single" overline_color="green">overlines</span>
Superscripts and subscripts: 𝜀<span rise="-6000" size="x-small" font_desc="italic">0</span> = 𝜔<span rise="8000" size="smaller">𝜔<span rise="14000" size="smaller">𝜔<span rise="20000">.<span rise="23000">.<span rise="26000">.</span></span></span></span></span>

View File

@@ -49,6 +49,7 @@ demos = files([
'listview_minesweeper.c',
'listview_settings.c',
'listview_weather.c',
'listview_words.c',
'markup.c',
'modelbutton.c',
'overlay.c',

View File

@@ -259,7 +259,7 @@
259|GTK+ and friends|GTKtoolkit|#java bindings version 4.0.16 released: http://article.gmane.org/gmane.comp.gnome.bindings.java/1796 #gtk|1276885917|0||0|0
260|GTK+ and friends|GTKtoolkit|RT @cwiiis: MxIconTheme and MxIcon respect system's icon theme (and changes) now in #mx master :) Made possible by @thosw's XSettings work|1276883019|0||0|0
261|GTK+ and friends|GTKtoolkit|#javascript mailing list just created. Discuss its usage in GObject libraries: GTK+, Glib ... http://ur1.ca/08lwz by @jwendell #gtk|1276842639|0||0|0
262|GTK+ and friends|GTKtoolkit|Note fot Win32 users: XP theming is back in 2.90.3 . Please test. #gtk|1276829697|0||0|0
262|GTK+ and friends|GTKtoolkit|Note for Win32 users: XP theming is back in 2.90.3 . Please test. #gtk|1276829697|0||0|0
263|GTK+ and friends|GTKtoolkit|GTK+ 2.90.3 (unstable) released: http://mail.gnome.org/archives/gtk-devel-list/2010-June/msg00137.html #gtk|1276829633|0||0|0
264|GTK+ and friends|GTKtoolkit|GLib 2.25.9 (unstable) released: http://ur1.ca/08hrl WARNING: API changes in GDBus, GSettings and GApplication #gtk|1276829581|0||0|0
265|scaroo|scaroo|RT @scaroo: #SeedKit does RGBA window with css shadows and stuff : http://dl.dropbox.com/u/5746554/seedkit-does-rgba.png|1276734086|0|GTKtoolkit|0|1

View File

@@ -40,7 +40,7 @@ do_overlay2 (GtkWidget *do_widget)
gtk_window_set_title (GTK_WINDOW (window), "Decorative Overlay");
overlay = gtk_overlay_new ();
sw = gtk_scrolled_window_new (NULL, NULL);
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);

View File

@@ -1,4 +1,4 @@
/* Sliding puzzle
/* Sliding Puzzle
*
* This demo demonstrates how to use gestures and paintables to create a
* small sliding puzzle game.
@@ -443,7 +443,7 @@ do_sliding_puzzle (GtkWidget *do_widget)
gtk_media_stream_set_muted (media, TRUE);
gtk_media_stream_play (media);
add_choice (choices, GDK_PAINTABLE (media));
sw = gtk_scrolled_window_new (NULL, NULL);
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), choices);
gtk_grid_attach (GTK_GRID (tweaks), sw, 0, 0, 2, 1);

View File

@@ -40,7 +40,7 @@ do_tabs (GtkWidget *do_widget)
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
gtk_text_buffer_set_text (buffer, "one\ttwo\tthree\nfour\tfive\tsix\nseven\teight\tnine", -1);
sw = gtk_scrolled_window_new (NULL, NULL);
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);

View File

@@ -57,7 +57,6 @@ do_tagged_entry (GtkWidget *do_widget)
static GtkWidget *window = NULL;
GtkWidget *box;
GtkWidget *box2;
GtkWidget *header;
GtkWidget *entry;
GtkWidget *button;
@@ -66,12 +65,9 @@ do_tagged_entry (GtkWidget *do_widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
header = gtk_header_bar_new ();
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), FALSE);
gtk_window_set_titlebar (GTK_WINDOW (window), header);
gtk_window_set_title (GTK_WINDOW (window), "A tagged entry");
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
gtk_window_set_deletable (GTK_WINDOW (window), FALSE);
gtk_window_set_title (GTK_WINDOW (window), "Tagged Entry");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
@@ -95,13 +91,6 @@ do_tagged_entry (GtkWidget *do_widget)
button = gtk_check_button_new_with_mnemonic ("_Spinner");
g_signal_connect (button, "toggled", G_CALLBACK (toggle_spinner), entry);
gtk_box_append (GTK_BOX (box2), button);
button = gtk_button_new_with_mnemonic ("_Done");
gtk_widget_add_css_class (button, "suggested-action");
g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_window_destroy), window);
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
gtk_window_set_default_widget (GTK_WINDOW (window), button);
}
if (!gtk_widget_get_visible (window))

View File

@@ -156,7 +156,7 @@ create_text_view (GtkWidget *hbox,
GtkWidget *textview;
guint timeout;
swindow = gtk_scrolled_window_new (NULL, NULL);
swindow = gtk_scrolled_window_new ();
gtk_box_append (GTK_BOX (hbox), swindow);
textview = gtk_text_view_new ();
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (swindow), textview);

View File

@@ -4,7 +4,7 @@
* GtkTextBuffer. You can enable or disable undo support using
* gtk_text_buffer_set_enable_undo().
*
* Use Primary+Z to undo and Primary+Shift+Z or Primary+Y to
* Use Control+z to undo and Control+Shift+z or Control+y to
* redo previously undone operations.
*/
@@ -29,7 +29,7 @@ do_textundo (GtkWidget *do_widget)
gtk_window_set_default_size (GTK_WINDOW (window), 450, 450);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
gtk_window_set_title (GTK_WINDOW (window), "TextView Undo");
gtk_window_set_title (GTK_WINDOW (window), "Undo and Redo");
view = gtk_text_view_new ();
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD);
@@ -46,7 +46,7 @@ do_textundo (GtkWidget *do_widget)
-1);
gtk_text_buffer_end_irreversible_action (buffer);
sw = gtk_scrolled_window_new (NULL, NULL);
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);

View File

@@ -494,7 +494,7 @@ do_textview (GtkWidget *do_widget)
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view1));
view2 = gtk_text_view_new_with_buffer (buffer);
sw = gtk_scrolled_window_new (NULL, NULL);
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
@@ -504,7 +504,7 @@ do_textview (GtkWidget *do_widget)
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), view1);
sw = gtk_scrolled_window_new (NULL, NULL);
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
@@ -590,7 +590,7 @@ easter_egg_callback (GtkWidget *button,
g_object_unref (buffer);
window = gtk_window_new ();
sw = gtk_scrolled_window_new (NULL, NULL);
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);

View File

@@ -92,12 +92,11 @@ static Theme themes[] = {
static int theme;
static gboolean
change_theme (GtkWidget *widget,
change_theme (GtkWidget *widget,
GdkFrameClock *frame_clock,
gpointer data)
gpointer data)
{
GtkBuilder *builder = data;
GtkWidget *label;
GtkWidget *label = data;
Theme next = themes[theme++ % G_N_ELEMENTS (themes)];
char *name;
@@ -110,7 +109,6 @@ change_theme (GtkWidget *widget,
gtk_window_set_title (GTK_WINDOW (widget), name);
g_free (name);
label = GTK_WIDGET (gtk_builder_get_object (builder, "fps"));
if (frame_clock)
{
char *fps;
@@ -127,10 +125,10 @@ change_theme (GtkWidget *widget,
static void
clicked (GtkGestureClick *gesture,
int n_press,
double x,
double y,
gpointer data)
int n_press,
double x,
double y,
gpointer data)
{
GtkWidget *window;
GdkEvent *event;
@@ -198,6 +196,7 @@ do_themes (GtkWidget *do_widget)
GtkBuilder *builder;
GtkWidget *header;
GtkWidget *button;
GtkWidget *label;
GtkGesture *gesture;
builder = gtk_builder_new_from_resource ("/themes/themes.ui");
@@ -207,13 +206,17 @@ do_themes (GtkWidget *do_widget)
gtk_widget_get_display (do_widget));
header = GTK_WIDGET (gtk_builder_get_object (builder, "header"));
label = GTK_WIDGET (gtk_builder_get_object (builder, "fps"));
gesture = gtk_gesture_click_new ();
g_signal_connect (gesture, "pressed", G_CALLBACK (clicked), builder);
g_signal_connect (gesture, "pressed", G_CALLBACK (clicked), label);
gtk_widget_add_controller (header, GTK_EVENT_CONTROLLER (gesture));
button = GTK_WIDGET (gtk_builder_get_object (builder, "toggle"));
g_signal_connect (button, "notify::active", G_CALLBACK (toggle_cycle), builder);
g_signal_connect (button, "notify::active", G_CALLBACK (toggle_cycle), label);
gtk_widget_realize (window);
g_object_unref (builder);
}
if (!gtk_widget_get_visible (window))

View File

@@ -84,7 +84,7 @@ static TreeItem may[] =
static TreeItem june[] =
{
{ "June Fathers' Day", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, NULL },
{ "Juneteenth (Liberation of Slaves)", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ "Juneteenth (Liberation Day)", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
{ "Flag Day", FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, NULL },
{ NULL }
};
@@ -406,7 +406,7 @@ do_tree_store (GtkWidget *do_widget)
gtk_box_append (GTK_BOX (vbox),
gtk_label_new ("Jonathan's Holiday Card Planning Sheet"));
sw = gtk_scrolled_window_new (NULL, NULL);
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,

View File

@@ -2,7 +2,6 @@
<gresources>
<gresource prefix="/org/gtk/iconbrowser/gtk">
<file preprocess="xml-stripblanks">window.ui</file>
<file preprocess="xml-stripblanks">menus.ui</file>
<file>icon.list</file>
</gresource>
</gresources>

View File

@@ -0,0 +1,156 @@
#include "iconbrowsercontext.h"
struct _IbContext
{
GObject parent_instance;
char *id;
char *name;
char *description;
};
struct _IbContextClass
{
GObjectClass parent_class;
};
enum {
PROP_ID = 1,
PROP_NAME,
PROP_DESCRIPTION,
PROP_NUM_PROPERTIES
};
G_DEFINE_TYPE (IbContext, ib_context, G_TYPE_OBJECT)
static void
ib_context_init (IbContext *context)
{
}
static void
ib_context_finalize (GObject *object)
{
IbContext *context = IB_CONTEXT (object);
g_free (context->id);
g_free (context->name);
g_free (context->description);
G_OBJECT_CLASS (ib_context_parent_class)->finalize (object);
}
static void
ib_context_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
IbContext *context = IB_CONTEXT (object);
switch (property_id)
{
case PROP_ID:
g_free (context->id);
context->id = g_value_dup_string (value);
break;
case PROP_NAME:
g_free (context->name);
context->name = g_value_dup_string (value);
break;
case PROP_DESCRIPTION:
g_free (context->description);
context->description = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
ib_context_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
IbContext *context = IB_CONTEXT (object);
switch (property_id)
{
case PROP_ID:
g_value_set_string (value, context->id);
break;
case PROP_NAME:
g_value_set_string (value, context->name);
break;
case PROP_DESCRIPTION:
g_value_set_string (value, context->description);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
ib_context_class_init (IbContextClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GParamSpec *pspec;
object_class->finalize = ib_context_finalize;
object_class->set_property = ib_context_set_property;
object_class->get_property = ib_context_get_property;
pspec = g_param_spec_string ("id", "Id", "Id",
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_ID, pspec);
pspec = g_param_spec_string ("name", "Name", "Name",
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_NAME, pspec);
pspec = g_param_spec_string ("description", "Description", "Description",
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_DESCRIPTION, pspec);
}
IbContext *
ib_context_new (const char *id,
const char *name,
const char *description)
{
return g_object_new (IB_TYPE_CONTEXT,
"id", id,
"name", name,
"description", description,
NULL);
}
const char *
ib_context_get_id (IbContext *context)
{
return context->id;
}
const char *
ib_context_get_name (IbContext *context)
{
return context->name;
}
const char *
ib_context_get_description (IbContext *context)
{
return context->description;
}

View File

@@ -0,0 +1,14 @@
#pragma once
#include <gtk.h>
#define IB_TYPE_CONTEXT (ib_context_get_type ())
G_DECLARE_FINAL_TYPE (IbContext, ib_context, IB, CONTEXT, GObject)
IbContext *ib_context_new (const char *id,
const char *name,
const char *description);
const char *ib_context_get_id (IbContext *context);
const char *ib_context_get_name (IbContext *context);
const char *ib_context_get_description (IbContext *context);

View File

@@ -0,0 +1,228 @@
#include "iconbrowsericon.h"
struct _IbIcon
{
GObject parent_instance;
gboolean use_symbolic;
char *regular_name;
char *symbolic_name;
char *description;
char *context;
};
struct _IbIconClass
{
GObjectClass parent_class;
};
enum {
PROP_NAME = 1,
PROP_REGULAR_NAME,
PROP_SYMBOLIC_NAME,
PROP_USE_SYMBOLIC,
PROP_DESCRIPTION,
PROP_CONTEXT,
PROP_NUM_PROPERTIES
};
G_DEFINE_TYPE (IbIcon, ib_icon, G_TYPE_OBJECT)
static void
ib_icon_init (IbIcon *icon)
{
}
static void
ib_icon_finalize (GObject *object)
{
IbIcon *icon = IB_ICON (object);
g_free (icon->regular_name);
g_free (icon->symbolic_name);
g_free (icon->description);
g_free (icon->context);
G_OBJECT_CLASS (ib_icon_parent_class)->finalize (object);
}
static void
ib_icon_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
IbIcon *icon = IB_ICON (object);
switch (property_id)
{
case PROP_REGULAR_NAME:
g_free (icon->regular_name);
icon->regular_name = g_value_dup_string (value);
if (!icon->use_symbolic)
g_object_notify (object, "name");
break;
case PROP_SYMBOLIC_NAME:
g_free (icon->symbolic_name);
icon->symbolic_name = g_value_dup_string (value);
if (icon->use_symbolic)
g_object_notify (object, "name");
break;
case PROP_USE_SYMBOLIC:
icon->use_symbolic = g_value_get_boolean (value);
g_object_notify (object, "name");
break;
case PROP_DESCRIPTION:
g_free (icon->description);
icon->description = g_value_dup_string (value);
break;
case PROP_CONTEXT:
g_free (icon->context);
icon->context = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
ib_icon_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
IbIcon *icon = IB_ICON (object);
switch (property_id)
{
case PROP_NAME:
g_value_set_string (value, ib_icon_get_name (icon));
break;
case PROP_REGULAR_NAME:
g_value_set_string (value, icon->regular_name);
break;
case PROP_SYMBOLIC_NAME:
g_value_set_string (value, icon->symbolic_name);
break;
case PROP_USE_SYMBOLIC:
g_value_set_boolean (value, icon->use_symbolic);
break;
case PROP_DESCRIPTION:
g_value_set_string (value, icon->description);
break;
case PROP_CONTEXT:
g_value_set_string (value, icon->context);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
ib_icon_class_init (IbIconClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GParamSpec *pspec;
object_class->finalize = ib_icon_finalize;
object_class->set_property = ib_icon_set_property;
object_class->get_property = ib_icon_get_property;
pspec = g_param_spec_string ("name", "Name", "Name",
NULL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_NAME, pspec);
pspec = g_param_spec_string ("regular-name", "Regular Name", "Regular Name",
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_REGULAR_NAME, pspec);
pspec = g_param_spec_string ("symbolic-name", "Symbolic Name", "Symbolic Name",
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_SYMBOLIC_NAME, pspec);
pspec = g_param_spec_boolean ("use-symbolic", "Use Symbolic", "Use Symbolic",
FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_USE_SYMBOLIC, pspec);
pspec = g_param_spec_string ("description", "Description", "Description",
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_DESCRIPTION, pspec);
pspec = g_param_spec_string ("context", "Context", "Context",
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_CONTEXT, pspec);
}
IbIcon *
ib_icon_new (const char *regular_name,
const char *symbolic_name,
const char *description,
const char *context)
{
return g_object_new (IB_TYPE_ICON,
"regular-name", regular_name,
"symbolic-name", symbolic_name,
"description", description,
"context", context,
NULL);
}
const char *
ib_icon_get_name (IbIcon *icon)
{
if (icon->use_symbolic)
return icon->symbolic_name;
else
return icon->regular_name;
}
const char *
ib_icon_get_regular_name (IbIcon *icon)
{
return icon->regular_name;
}
const char *
ib_icon_get_symbolic_name (IbIcon *icon)
{
return icon->symbolic_name;
}
gboolean
ib_icon_get_use_symbolic (IbIcon *icon)
{
return icon->use_symbolic;
}
const char *
ib_icon_get_description (IbIcon *icon)
{
return icon->description;
}
const char *
ib_icon_get_context (IbIcon *icon)
{
return icon->context;
}

View File

@@ -0,0 +1,18 @@
#pragma once
#include <gtk.h>
#define IB_TYPE_ICON (ib_icon_get_type ())
G_DECLARE_FINAL_TYPE (IbIcon, ib_icon, IB, ICON, GObject)
IbIcon *ib_icon_new (const char *regular_name,
const char *symbolic_name,
const char *description,
const char *context);
const char *ib_icon_get_name (IbIcon *icon);
const char *ib_icon_get_regular_name (IbIcon *icon);
const char *ib_icon_get_symbolic_name (IbIcon *icon);
gboolean ib_icon_get_use_symbolic (IbIcon *icon);
const char *ib_icon_get_description (IbIcon *icon);
const char *ib_icon_get_context (IbIcon *icon);

View File

@@ -1,48 +1,22 @@
#include <string.h>
#include "iconbrowserapp.h"
#include "iconbrowserwin.h"
#include "iconstore.h"
#include "iconbrowsericon.h"
#include "iconbrowsercontext.h"
#include <gtk/gtk.h>
/* Drag 'n Drop */
typedef struct
{
gchar *id;
gchar *name;
gchar *description;
} Context;
static void
context_free (gpointer data)
{
Context *context = data;
g_free (context->id);
g_free (context->name);
g_free (context->description);
g_free (context);
}
struct _IconBrowserWindow
{
GtkApplicationWindow parent;
GHashTable *contexts;
GtkWidget *context_list;
Context *current_context;
gboolean symbolic;
GtkWidget *symbolic_radio;
GtkTreeModelFilter *filter_model;
GtkWidget *details;
GtkListStore *store;
GtkCellRenderer *cell;
GtkCellRenderer *text_cell;
GtkWidget *search;
GtkWidget *searchbar;
GtkWidget *searchentry;
GtkWidget *list;
GListModel *icon_filter_model;
GListStore *icon_store;
GListStore *context_store;
GtkFilter *name_filter;
GtkWidget *details;
GtkWidget *image1;
GtkWidget *image2;
GtkWidget *image3;
@@ -68,87 +42,6 @@ icon_browser_window_get_icon_theme (IconBrowserWindow *win)
return gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (win)));
}
static void
search_text_changed (GtkEntry *entry, IconBrowserWindow *win)
{
const gchar *text;
text = gtk_editable_get_text (GTK_EDITABLE (entry));
if (text[0] == '\0')
return;
gtk_tree_model_filter_refilter (win->filter_model);
}
static void
set_image (GtkWidget *image, const gchar *name, gint size)
{
gtk_image_set_from_icon_name (GTK_IMAGE (image), name);
gtk_image_set_pixel_size (GTK_IMAGE (image), size);
}
static void
item_activated (GtkIconView *icon_view, GtkTreePath *path, IconBrowserWindow *win)
{
GtkIconTheme *icon_theme = icon_browser_window_get_icon_theme (win);
GtkTreeIter iter;
gchar *name;
gchar *description;
gint column;
gtk_tree_model_get_iter (GTK_TREE_MODEL (win->filter_model), &iter, path);
if (win->symbolic)
column = ICON_STORE_SYMBOLIC_NAME_COLUMN;
else
column = ICON_STORE_NAME_COLUMN;
gtk_tree_model_get (GTK_TREE_MODEL (win->filter_model), &iter,
column, &name,
ICON_STORE_DESCRIPTION_COLUMN, &description,
-1);
if (name == NULL || !gtk_icon_theme_has_icon (icon_theme, name))
{
g_free (description);
return;
}
gtk_window_set_title (GTK_WINDOW (win->details), name);
set_image (win->image1, name, 8);
set_image (win->image2, name, 16);
set_image (win->image3, name, 18);
set_image (win->image4, name, 24);
set_image (win->image5, name, 32);
set_image (win->image6, name, 48);
set_image (win->image7, name, 64);
if (win->symbolic)
{
gtk_widget_show (win->image8);
gtk_widget_show (win->label8);
set_image (win->image8, name, 64);
}
else
{
gtk_widget_hide (win->image8);
gtk_widget_hide (win->label8);
}
if (description && description[0])
{
gtk_label_set_text (GTK_LABEL (win->description), description);
gtk_widget_show (win->description);
}
else
{
gtk_widget_hide (win->description);
}
gtk_window_present (GTK_WINDOW (win->details));
g_free (name);
g_free (description);
}
static void
add_icon (IconBrowserWindow *win,
const gchar *name,
@@ -158,6 +51,7 @@ add_icon (IconBrowserWindow *win,
GtkIconTheme *icon_theme = icon_browser_window_get_icon_theme (win);
gchar *regular_name;
gchar *symbolic_name;
IbIcon *icon;
regular_name = g_strdup (name);
if (!gtk_icon_theme_has_icon (icon_theme, regular_name))
@@ -173,12 +67,12 @@ add_icon (IconBrowserWindow *win,
symbolic_name = NULL;
}
gtk_list_store_insert_with_values (win->store, NULL, -1,
ICON_STORE_NAME_COLUMN, regular_name,
ICON_STORE_SYMBOLIC_NAME_COLUMN, symbolic_name,
ICON_STORE_DESCRIPTION_COLUMN, description,
ICON_STORE_CONTEXT_COLUMN, context,
-1);
icon = ib_icon_new (regular_name, symbolic_name, description, context);
g_object_bind_property (win->symbolic_radio, "active",
icon, "use-symbolic",
G_BINDING_DEFAULT);
g_list_store_append (win->icon_store, icon);
g_object_unref (icon);
}
static void
@@ -187,50 +81,11 @@ add_context (IconBrowserWindow *win,
const gchar *name,
const gchar *description)
{
Context *c;
GtkWidget *row;
IbContext *context;
c = g_new (Context, 1);
c->id = g_strdup (id);
c->name = g_strdup (name);
c->description = g_strdup (description);
g_hash_table_insert (win->contexts, c->id, c);
row = gtk_label_new (name);
gtk_label_set_xalign (GTK_LABEL (row), 0);
g_object_set_data (G_OBJECT (row), "context", c);
gtk_widget_show (row);
gtk_widget_set_margin_start (row, 10);
gtk_widget_set_margin_end (row, 10);
gtk_widget_set_margin_top (row, 10);
gtk_widget_set_margin_bottom (row, 10);
gtk_list_box_insert (GTK_LIST_BOX (win->context_list), row, -1);
/* set the tooltip on the list box row */
row = gtk_widget_get_parent (row);
gtk_widget_set_tooltip_text (row, description);
if (win->current_context == NULL)
win->current_context = c;
}
static void
selected_context_changed (GtkListBox *list, IconBrowserWindow *win)
{
GtkWidget *row;
GtkWidget *label;
row = GTK_WIDGET (gtk_list_box_get_selected_row (list));
if (row == NULL)
return;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (win->search), FALSE);
label = gtk_list_box_row_get_child (GTK_LIST_BOX_ROW (row));
win->current_context = g_object_get_data (G_OBJECT (label), "context");
gtk_tree_model_filter_refilter (win->filter_model);
context = ib_context_new (id, name, description);
g_list_store_append (win->context_store, context);
g_object_unref (context);
}
static void
@@ -282,6 +137,19 @@ populate (IconBrowserWindow *win)
g_strfreev (groups);
}
static gboolean
filter_by_icon_name (gpointer item,
gpointer data)
{
return ib_icon_get_name (IB_ICON (item)) != NULL;
}
static void
symbolic_toggled (IconBrowserWindow *win)
{
gtk_filter_changed (win->name_filter, GTK_FILTER_CHANGE_DIFFERENT);
}
static void
copy_to_clipboard (GtkButton *button,
IconBrowserWindow *win)
@@ -292,70 +160,60 @@ copy_to_clipboard (GtkButton *button,
gdk_clipboard_set_text (clipboard, gtk_window_get_title (GTK_WINDOW (win->details)));
}
static gboolean
icon_visible_func (GtkTreeModel *model,
GtkTreeIter *iter,
gpointer data)
static void
set_image (GtkWidget *image, const gchar *name, gint size)
{
IconBrowserWindow *win = data;
gchar *context;
gchar *name;
gint column;
gboolean search;
const gchar *search_text;
gboolean visible;
search = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (win->search));
search_text = gtk_editable_get_text (GTK_EDITABLE (win->searchentry));
if (win->symbolic)
column = ICON_STORE_SYMBOLIC_NAME_COLUMN;
else
column = ICON_STORE_NAME_COLUMN;
gtk_tree_model_get (model, iter,
column, &name,
ICON_STORE_CONTEXT_COLUMN, &context,
-1);
if (!name)
visible = FALSE;
else if (search)
visible = strstr (name, search_text) != NULL;
else
visible = win->current_context != NULL && g_strcmp0 (context, win->current_context->id) == 0;
g_free (name);
g_free (context);
return visible;
gtk_image_set_from_icon_name (GTK_IMAGE (image), name);
gtk_image_set_pixel_size (GTK_IMAGE (image), size);
}
static void
symbolic_toggled (GtkToggleButton *toggle, IconBrowserWindow *win)
item_activated (GtkGridView *view,
guint position,
IconBrowserWindow *win)
{
gint column;
GListModel *model = gtk_grid_view_get_model (view);
IbIcon *icon = g_list_model_get_item (model, position);
const char *name;
const char *description;
gboolean symbolic;
win->symbolic = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (toggle));
name = ib_icon_get_name (icon);
description = ib_icon_get_description (icon);
symbolic = ib_icon_get_use_symbolic (icon);
if (win->symbolic)
column = ICON_STORE_SYMBOLIC_NAME_COLUMN;
gtk_window_set_title (GTK_WINDOW (win->details), name);
set_image (win->image1, name, 8);
set_image (win->image2, name, 16);
set_image (win->image3, name, 18);
set_image (win->image4, name, 24);
set_image (win->image5, name, 32);
set_image (win->image6, name, 48);
set_image (win->image7, name, 64);
if (symbolic)
{
gtk_widget_show (win->image8);
gtk_widget_show (win->label8);
set_image (win->image8, name, 64);
}
else
column = ICON_STORE_NAME_COLUMN;
{
gtk_widget_hide (win->image8);
gtk_widget_hide (win->label8);
}
if (description && description[0])
{
gtk_label_set_text (GTK_LABEL (win->description), description);
gtk_widget_show (win->description);
}
else
{
gtk_widget_hide (win->description);
}
icon_store_set_text_column (ICON_STORE (win->store), column);
gtk_window_present (GTK_WINDOW (win->details));
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (win->list), win->cell, "icon-name", column, NULL);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (win->list), win->text_cell, "text", column, NULL);
gtk_tree_model_filter_refilter (win->filter_model);
gtk_widget_queue_draw (win->list);
}
static void
search_mode_toggled (GObject *searchbar, GParamSpec *pspec, IconBrowserWindow *win)
{
if (gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (searchbar)))
gtk_list_box_unselect_all (GTK_LIST_BOX (win->context_list));
g_object_unref (icon);
}
static GdkPaintable *
@@ -381,7 +239,10 @@ get_image_paintable (GtkImage *image)
gtk_widget_get_direction (GTK_WIDGET (image)),
0);
if (icon == NULL)
return NULL;
{
g_print ("no icon for %s\n", icon_name);
return NULL;
}
return GDK_PAINTABLE (icon);
case GTK_IMAGE_GICON:
case GTK_IMAGE_EMPTY:
@@ -419,10 +280,10 @@ drag_prepare_texture (GtkDragSource *source,
{
GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (widget));
if (!GDK_IS_TEXTURE (paintable))
if (!GDK_IS_PAINTABLE (paintable))
return NULL;
return gdk_content_provider_new_typed (GDK_TYPE_TEXTURE, paintable);
return gdk_content_provider_new_typed (GDK_TYPE_PAINTABLE, paintable);
}
static GdkContentProvider *
@@ -476,17 +337,10 @@ setup_scalable_image_dnd (GtkWidget *image)
static void
icon_browser_window_init (IconBrowserWindow *win)
{
GdkContentFormats *list;
GtkFilter *filter;
gtk_widget_init_template (GTK_WIDGET (win));
list = gdk_content_formats_new_for_gtype (G_TYPE_STRING);
gtk_icon_view_enable_model_drag_source (GTK_ICON_VIEW (win->list),
GDK_BUTTON1_MASK,
list,
GDK_ACTION_COPY);
gdk_content_formats_unref (list);
setup_image_dnd (win->image1);
setup_image_dnd (win->image2);
setup_image_dnd (win->image3);
@@ -496,19 +350,16 @@ icon_browser_window_init (IconBrowserWindow *win)
setup_image_dnd (win->image7);
setup_scalable_image_dnd (win->image8);
win->contexts = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, context_free);
gtk_tree_model_filter_set_visible_func (win->filter_model, icon_visible_func, win, NULL);
gtk_window_set_transient_for (GTK_WINDOW (win->details), GTK_WINDOW (win));
g_signal_connect (win->searchbar, "notify::search-mode-enabled",
G_CALLBACK (search_mode_toggled), win);
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (win->searchbar),
GTK_WIDGET (win));
symbolic_toggled (GTK_TOGGLE_BUTTON (win->symbolic_radio), win);
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (win->searchbar), GTK_WIDGET (win));
populate (win);
filter = gtk_filter_list_model_get_filter (GTK_FILTER_LIST_MODEL (win->icon_filter_model));
win->name_filter = gtk_custom_filter_new (filter_by_icon_name, NULL, NULL);
gtk_multi_filter_append (GTK_MULTI_FILTER (filter), g_object_ref (win->name_filter));
}
static void
@@ -516,7 +367,7 @@ icon_browser_window_finalize (GObject *object)
{
IconBrowserWindow *win = ICON_BROWSER_WINDOW (object);
g_hash_table_unref (win->contexts);
g_clear_object (&win->name_filter);
G_OBJECT_CLASS (icon_browser_window_parent_class)->finalize (object);
}
@@ -528,23 +379,19 @@ icon_browser_window_class_init (IconBrowserWindowClass *class)
object_class->finalize = icon_browser_window_finalize;
g_type_ensure (ICON_STORE_TYPE);
g_type_ensure (IB_TYPE_ICON);
g_type_ensure (IB_TYPE_CONTEXT);
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/iconbrowser/gtk/window.ui");
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, context_list);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, filter_model);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, symbolic_radio);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, details);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, store);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, cell);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, text_cell);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, search);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, searchbar);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, searchentry);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, list);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, icon_store);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, icon_filter_model);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, context_store);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, details);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, image1);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, image2);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, image3);
@@ -556,11 +403,9 @@ icon_browser_window_class_init (IconBrowserWindowClass *class)
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, label8);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, description);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), search_text_changed);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), item_activated);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), selected_context_changed);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), symbolic_toggled);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), copy_to_clipboard);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), symbolic_toggled);
}
IconBrowserWindow *

View File

@@ -1,91 +0,0 @@
#include "iconstore.h"
#include <gtk/gtk.h>
struct _IconStore
{
GtkListStore parent;
gint text_column;
};
struct _IconStoreClass
{
GtkListStoreClass parent_class;
};
static void icon_store_drag_source_init (GtkTreeDragSourceIface *iface);
G_DEFINE_TYPE_WITH_CODE (IconStore, icon_store, GTK_TYPE_LIST_STORE,
G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_DRAG_SOURCE,
icon_store_drag_source_init))
static void
icon_store_init (IconStore *store)
{
GType types[4] = { G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING };
gtk_list_store_set_column_types (GTK_LIST_STORE (store), 4, types);
store->text_column = ICON_STORE_NAME_COLUMN;
}
static void
icon_store_class_init (IconStoreClass *class)
{
}
static gboolean
row_draggable (GtkTreeDragSource *drag_source,
GtkTreePath *path)
{
return TRUE;
}
static gboolean
drag_data_delete (GtkTreeDragSource *drag_source,
GtkTreePath *path)
{
GtkTreeIter iter;
if (gtk_tree_model_get_iter (GTK_TREE_MODEL (drag_source), &iter, path))
return gtk_list_store_remove (GTK_LIST_STORE (drag_source), &iter);
return FALSE;
}
static GdkContentProvider *
drag_data_get (GtkTreeDragSource *drag_source,
GtkTreePath *path)
{
GdkContentProvider *content;
GtkTreeIter iter;
gchar *text;
if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (drag_source), &iter, path))
return NULL;
gtk_tree_model_get (GTK_TREE_MODEL (drag_source), &iter,
ICON_STORE (drag_source)->text_column, &text,
-1);
content = gdk_content_provider_new_typed (G_TYPE_STRING, text);
g_free (text);
return content;
}
static void
icon_store_drag_source_init (GtkTreeDragSourceIface *iface)
{
iface->row_draggable = row_draggable;
iface->drag_data_delete = drag_data_delete;
iface->drag_data_get = drag_data_get;
}
void
icon_store_set_text_column (IconStore *store, gint text_column)
{
store->text_column = text_column;
}

View File

@@ -1,26 +0,0 @@
#ifndef __ICON_STORE_H
#define __ICON_STORE_H
#include <gtk/gtk.h>
#define ICON_STORE_TYPE (icon_store_get_type ())
#define ICON_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ICON_STORE_TYPE, IconStore))
typedef struct _IconStore IconStore;
typedef struct _IconStoreClass IconStoreClass;
enum {
ICON_STORE_NAME_COLUMN,
ICON_STORE_SYMBOLIC_NAME_COLUMN,
ICON_STORE_DESCRIPTION_COLUMN,
ICON_STORE_CONTEXT_COLUMN
};
GType icon_store_get_type (void);
void icon_store_set_text_column (IconStore *store,
gint column);
#endif /* __ICON_STORE_H */

View File

@@ -1,10 +0,0 @@
<interface>
<menu id="app-menu">
<section>
<item>
<attribute name="label" translatable="yes">_Quit</attribute>
<attribute name="action">app.quit</attribute>
</item>
</section>
</menu>
</interface>

View File

@@ -2,7 +2,8 @@ iconbrowser_sources = [
'main.c',
'iconbrowserapp.c',
'iconbrowserwin.c',
'iconstore.c'
'iconbrowsericon.c',
'iconbrowsercontext.c'
]
iconbrowser_resources = gnome.compile_resources('iconbrowser_resources',
@@ -17,14 +18,3 @@ executable('gtk4-icon-browser',
gui_app: true,
link_args: extra_demo_ldflags,
install: true)
install_data('org.gtk.IconBrowser4.desktop', install_dir: gtk_applicationsdir)
# icons
icontheme_dir = join_paths(gtk_datadir, 'icons/hicolor')
foreach size: ['scalable', 'symbolic']
install_subdir('data/' + size,
install_dir: icontheme_dir
)
endforeach

View File

@@ -12,10 +12,6 @@
</item>
</section>
</menu>
<object class="IconStore" id="store"/>
<object class="GtkTreeModelFilter" id="filter_model">
<property name="child-model">store</property>
</object>
<template class="IconBrowserWindow" parent="GtkApplicationWindow">
<style>
<class name="devel"/>
@@ -42,7 +38,7 @@
<property name="draw-indicator">0</property>
<property name="label" translatable="yes">Symbolic</property>
<property name="group">normal_radio</property>
<signal name="toggled" handler="symbolic_toggled"/>
<signal name="notify::active" handler="symbolic_toggled" swapped="yes" after="yes"/>
</object>
</child>
</object>
@@ -71,8 +67,44 @@
<child>
<object class="GtkBox">
<child>
<object class="GtkListBox" id="context_list">
<signal name="selected-rows-changed" handler="selected_context_changed"/>
<object class="GtkScrolledWindow">
<property name="hscrollbar-policy">never</property>
<child>
<object class="GtkListView">
<property name="model">
<object class="GtkSingleSelection" id="context_model">
<property name="model">
<object class="GListStore" id="context_store">
<property name="item-type">IbContext</property>
</object>
</property>
</object>
</property>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="bytes">
<![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GtkListItem">
<property name="child">
<object class="GtkLabel">
<property name="xalign">0</property>
<binding name="label">
<lookup name="name" type="IbContext">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</property>
</template>
</interface>
]]>
</property>
</object>
</property>
</object>
</child>
</object>
</child>
<child>
@@ -88,7 +120,6 @@
<property name="search-mode-enabled" bind-source="search" bind-property="active" bind-flags="bidirectional"/>
<child>
<object class="GtkSearchEntry" id="searchentry">
<signal name="search-changed" handler="search_text_changed"/>
</object>
</child>
</object>
@@ -99,23 +130,91 @@
<property name="vexpand">1</property>
<property name="hscrollbar-policy">never</property>
<child>
<object class="GtkIconView" id="list">
<property name="model">filter_model</property>
<property name="selection-mode">none</property>
<property name="activate-on-single-click">1</property>
<signal name="item_activated" handler="item_activated"/>
<child>
<object class="GtkCellRendererPixbuf" id="cell">
<property name="xpad">10</property>
<property name="ypad">10</property>
<object class="GtkGridView" id="list">
<signal name="activate" handler="item_activated"/>
<property name="single-click-activate">1</property>
<property name="model">
<object class="GtkNoSelection">
<property name="model">
<object class="GtkFilterListModel" id="icon_filter_model">
<property name="filter">
<object class="GtkEveryFilter">
<child>
<object class="GtkStringFilter">
<property name="expression">
<lookup name="name" type="IbIcon"/>
</property>
<binding name="search">
<lookup name="text" type="GtkSearchEntry">
searchentry
</lookup>
</binding>
</object>
</child>
<child>
<object class="GtkStringFilter">
<property name="ignore-case">0</property>
<property name="match-mode">exact</property>
<property name="expression">
<lookup name="context" type="IbIcon"/>
</property>
<binding name="search">
<lookup name="id" type="IbContext">
<lookup name="selected-item" type="GtkSingleSelection">
context_model
</lookup>
</lookup>
</binding>
</object>
</child>
</object>
</property>
<property name="model">
<object class="GListStore" id="icon_store">
<property name="item-type">IbIcon</property>
</object>
</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkCellRendererText" id="text_cell">
<property name="xpad">10</property>
<property name="ypad">10</property>
</property>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="bytes">
<![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GtkListItem">
<property name="child">
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkImage">
<property name="pixel-size">48</property>
<binding name="icon-name">
<lookup name="name" type="IbIcon">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</child>
<child>
<object class="GtkLabel">
<binding name="label">
<lookup name="name" type="IbIcon">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</child>
</object>
</property>
</template>
</interface>
]]>
</property>
</object>
</child>
</property>
</object>
</child>
</object>
@@ -125,14 +224,7 @@
</object>
</child>
</template>
<object class="GtkSizeGroup">
<property name="mode">vertical</property>
<widgets>
<widget name="normal_radio"/>
<widget name="symbolic_radio"/>
<widget name="search"/>
</widgets>
</object>
<object class="GtkDialog" id="details">
<property name="modal">1</property>
<property name="use-header-bar">1</property>
@@ -164,7 +256,7 @@
</object>
</child>
<child>
<object class="GtkImage" id="image2">
<object class="GtkImage" id="image2">
<property name="halign">center</property>
<property name="valign">end</property>
<accessibility>
@@ -373,7 +465,7 @@
</layout>
</object>
</child>
<child>
<child>
<object class="GtkLabel" id="label8">
<property name="halign">center</property>
<property name="valign">baseline</property>
@@ -404,7 +496,7 @@
<signal name="clicked" handler="copy_to_clipboard"/>
</object>
</child>
<child>
<child>
<object class="GtkLabel" id="description">
<property name="margin-start">10</property>
<property name="margin-end">10</property>
@@ -419,3 +511,4 @@
</child>
</object>
</interface>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkWindow" id="window">
<style>
<class name="devel"/>
</style>
<property name="title" translatable="yes">Help</property>
<property name="default-width">720</property>
<property name="default-height">520</property>
<child>
<object class="GtkScrolledWindow">
<child>
<object class="GtkTextView" id="text_view">
<property name="wrap-mode">word</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>
<property name="buffer">
<object class="GtkTextBuffer" id="buffer"/>
</property>
</object>
</child>
</object>
</child>
</object>
</interface>

View File

@@ -51,21 +51,121 @@ node_editor_application_init (NodeEditorApplication *app)
}
static void
quit_activated (GSimpleAction *action,
activate_about (GSimpleAction *action,
GVariant *parameter,
gpointer data)
gpointer user_data)
{
GtkApplication *app = user_data;
char *version;
GString *s;
GskRenderer *gsk_renderer;
const char *renderer;
s = g_string_new ("");
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, "\tPango\t%s\n",
pango_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 ());
gsk_renderer = gtk_native_get_renderer (GTK_NATIVE (gtk_application_get_active_window (app)));
if (strcmp (G_OBJECT_TYPE_NAME (gsk_renderer), "GskVulkanRenderer") == 0)
renderer = "Vulkan";
else if (strcmp (G_OBJECT_TYPE_NAME (gsk_renderer), "GskGLRenderer") == 0)
renderer = "OpenGL";
else if (strcmp (G_OBJECT_TYPE_NAME (gsk_renderer), "GskCairoRenderer") == 0)
renderer = "Cairo";
else
renderer = "Unknown";
g_string_append_printf (s, "\nRenderer\n\t%s", renderer);
version = g_strdup_printf ("%s\nRunning against GTK %d.%d.%d",
PACKAGE_VERSION,
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", "GTK Node Editor",
"version", version,
"copyright", "©2019—2020 The GTK Team",
"license-type", GTK_LICENSE_LGPL_2_1,
"website", "http://www.gtk.org",
"comments", "Program to test GTK rendering",
"authors", (const char *[]){ "Benjamin Otte", "Timm Bäder", NULL},
"logo-icon-name", "text-editor-symbolic",
"title", "About GTK Node Editor",
"system-information", s->str,
NULL);
g_string_free (s, TRUE);
g_free (version);
}
static void
activate_quit (GSimpleAction *action,
GVariant *parameter,
gpointer data)
{
g_application_quit (G_APPLICATION (data));
}
static void
activate_inspector (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
gtk_window_set_interactive_debugging (TRUE);
}
static void
activate_help (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
GtkBuilder *builder;
GtkWidget *window;
GtkTextBuffer *buffer;
GBytes *bytes;
const char *text;
gsize len;
builder = gtk_builder_new ();
gtk_builder_add_from_resource (builder, "/org/gtk/gtk4/node-editor/help-window.ui", NULL);
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
buffer = GTK_TEXT_BUFFER (gtk_builder_get_object (builder, "buffer"));
bytes = g_resources_lookup_data ("/org/gtk/gtk4/node-editor/node-format.md",
G_RESOURCE_LOOKUP_FLAGS_NONE,
NULL);
text = g_bytes_get_data (bytes, &len);
gtk_text_buffer_set_text (buffer, text, len);
g_bytes_unref (bytes);
gtk_window_present (GTK_WINDOW (window));
g_object_unref (builder);
}
static GActionEntry app_entries[] =
{
{ "quit", quit_activated, NULL, NULL, NULL }
{ "about", activate_about, NULL, NULL, NULL },
{ "quit", activate_quit, NULL, NULL, NULL },
{ "inspector", activate_inspector, NULL, NULL, NULL },
{ "help", activate_help, NULL, NULL, NULL },
};
static void
node_editor_application_startup (GApplication *app)
{
const char *help_accels[2] = { "F1", NULL };
const char *quit_accels[2] = { "<Ctrl>Q", NULL };
const char *open_accels[2] = { "<Ctrl>O", NULL };
GtkCssProvider *provider;
@@ -75,6 +175,7 @@ node_editor_application_startup (GApplication *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.help", help_accels);
gtk_application_set_accels_for_action (GTK_APPLICATION (app), "app.quit", quit_accels);
gtk_application_set_accels_for_action (GTK_APPLICATION (app), "win.open", open_accels);

View File

@@ -825,6 +825,7 @@ node_editor_window_create_renderer_widget (gpointer item,
gtk_widget_set_size_request (box, 120, 90);
label = gtk_label_new (g_object_get_data (G_OBJECT (paintable), "description"));
gtk_widget_add_css_class (label, "title-4");
gtk_box_append (GTK_BOX (box), label);
picture = gtk_picture_new_for_paintable (paintable);

View File

@@ -1,5 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<menu id="gear_menu">
<section>
<item>
<attribute name="label" translatable="yes">_Help</attribute>
<attribute name="action">app.help</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Inspector</attribute>
<attribute name="action">app.inspector</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_About Node Editor</attribute>
<attribute name="action">app.about</attribute>
</item>
</section>
</menu>
<object class="GtkPopover" id="testcase_popover">
<child>
<object class="GtkGrid">
@@ -119,6 +136,13 @@
<property name="popover">testcase_popover</property>
</object>
</child>
<child type="end">
<object class="GtkMenuButton" id="gear_menu_button">
<property name="valign">center</property>
<property name="menu-model">gear_menu</property>
<property name="icon-name">open-menu-symbolic</property>
</object>
</child>
</object>
</child>
<child>

View File

@@ -2,5 +2,7 @@
<gresources>
<gresource prefix="/org/gtk/gtk4/node-editor">
<file preprocess="xml-stripblanks">node-editor-window.ui</file>
<file preprocess="xml-stripblanks">help-window.ui</file>
<file>node-format.md</file>
</gresource>
</gresources>

View File

@@ -0,0 +1,213 @@
# The Node file format
GSK render nodes can be serialized and deserialized using APIs such as `gsk_render_node_serialize()` and `gsk_render_node_deserialize()`. The intended use for this is development - primarily the development of GTK - by allowing things such as creating testsuites and benchmarks, exchanging nodes in bug reports. GTK includes the `gtk4-node-editor` application for creating such test files.
The format is a text format that follows the [CSS syntax rules](https://drafts.csswg.org/css-syntax-3/). In particular, this means that every array of bytes will produce a render node when parsed, as there is a defined error recovery method. For more details on error handling, please refer to the documentation of the aprsing APIs.
The grammar of a node text representation using [the CSS value definition syntax](https://drafts.csswg.org/css-values-3/#value-defs) looks like this:
**document**: `<node>\*`
**node**: container { <document> } | `<node-name> { <property>* }`
**property**: `<property-name>: <node> | <value> ;`
Each node has its own `<node-name>` and supports a custom set of properties, each with their own `<property-name>` and syntax. The following paragraphs document each of the nodes and their properties.
When serializing and the value of a property equals the default value, this value will not be serialized. Serialization aims to produce an output as small as possible.
# Nodes
### container
The **container** node is a special node that allows specifying a list of child nodes. Its contents follow the same rules as an empty document.
### blend
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| bottom | `<node>` | color { color: #AF0; } | always |
| mode | `<blend-mode>` | normal | non-default |
| top | `<node>` | color { } | always |
Creates a node like `gsk_blend_node_new()` with the given properties.
### blur
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| blur | `<number>` | 1 | non-default |
| child | `<node>` | color { } | always |
Creates a node like `gsk_blur_node_new()` with the given properties.
### border
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| color | `<color>{1,4}` | black | non-default |
| outline | `<rounded-rect>` | 50 | always |
| width | `<number>{1,4}` | 1 | non-default |
Creates a node like `gsk_border_node_new()` with the given properties.
For the color and width properties, the values follow the typical CSS order of top, right, bottom, left. If the last/left value isn't given, the 2nd/right value is used. If the 3rd/bottom value isn't given, the 1st/top value is used. And if the 2nd/right value also isn't given, the 1st/top value is used for every 4 values.
### clip
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| child | `<node>` | color { } | always |
| clip | `<rounded-rect>` | 50 | always |
Creates a node like `gsk_clip_node_new()` with the given properties.
As an extension, this node allows specifying a rounded rectangle for the clip property. If that rectangle is indeed rounded, a node like `gsk_rounded_clip_node_new()` will be created instead.
### color
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| bounds | `<rect>` | 50 | always |
| color | `<color>` | #FF00CC | always |
Creates a node like `gsk_color_node_new()` with the given properties.
The color is chosen as an error pink so it is visible while also reminding people to change it.
### color-matrix
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| child | `<node>` | color { } | always |
| matrix | `<transform>` | none | non-default |
| offset | `<number>{4}` | 0 0 0 0 | non-default |
Creates a node like `gsk_color_matrix_node_new()` with the given properties.
The matrix property accepts a <transform> for compatibility purposes, but you should be aware that the allowed values are meant to be used on 3D transformations, so their naming might appear awkward. However, it is always possible to use the matrix3d() production to specify all 16 values individually.
### cross-fade
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| end | `<node>` | color { } | always |
| mode | `<number>` | 0.5 | non-default |
| start | `<node>` | color { color: #AF0; } | always |
Creates a node like `gsk_cross_fade_node_new()` with the given properties.
### debug
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| child | `<node>` | color { } | always |
| message | `<string>` | "" | non-default |
Creates a node like `gsk_debug_node_new()` with the given properties.
### inset-shadow
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| blur | `<number>` | 0 | non-default |
| color | `<color>` | black | non-default |
| dx | `<number>` | 1 | non-default |
| dy | `<number>` | 1 | non-default |
| outline | `<rounded-rect>` | 50 | always |
| spread | `<number>` | 0 | non-default |
Creates a node like `gsk_inset_shadow_node_new()` with the given properties.
### linear-gradient
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| bounds | `<rect>` | 50 | always |
| end | `<point>` | 0 50 | always |
| start | `<point>` | 0 0 | always |
| stops | `<color-stop>` | 0 #AF0, 1 #F0C | always |
Creates a node like `gsk_linear_gradient_node_new()` with the given properties.
### opacity
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| child | `<node>` | color { } | always |
| opacity | `<number>` | 0.5 | non-default |
Creates a node like `gsk_transform_node_new()` with the given properties.
### outset-shadow
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| blur | `<number>` | 0 | non-default |
| color | `<color>` | black | non-default |
| dx | `<number>` | 1 | non-default |
| dy | `<number>` | 1 | non-default |
| outline | `<rounded-rect>` | 50 | always |
| spread | `<number>` | 0 | non-default |
Creates a node like `gsk_outset_shadow_node_new()` with the given properties.
### repeat
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| bounds | `<rect>` | *bounds of child node* | non-default |
| child | `<node>` | color { } | always |
| child-bounds| `<rect>` | *bounds of child node* | non-default |
Creates a node like `gsk_repeat_node_new()` with the given properties.
### rounded-clip
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| child | `<node>` | color { } | always |
| clip | `<rounded-rect>` | 50 | always |
Creates a node like `gsk_rounded_clip_node_new()` with the given properties.
### shadow
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| child | `<node>` | color { } | always |
| shadow | `<shadow>` | black 1 1 | always |
Creates a node like `gsk_shadow_node_new()` with the given properties.
### text
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| color | `<color>` | black | non-default |
| font | `<string>` | "Cantarell 11" | always |
| glyphs | `<glyphs>` | "Hello" | always |
| offset | `<point>` | 0 0 | non-default |
Creates a node like `gsk_text_node_new()` with the given properties.
If the given font does not exist or the given glyphs are invalid for the given font, an error node will be returned.
### texture
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| bounds | `<rect>` | 50 | always |
| texture | `<url>` | *see below* | always |
Creates a node like `gsk_texture_node_new()` with the given properties.
The default texture is a 10x10 checkerboard with the top left and bottom right 5x5 being in the color #FF00CC and the other part being transparent. A possible representation for this texture is `url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABmJLR0QA/wD/AP+gvaeTAAAAKUlEQVQYlWP8z3DmPwMaYGQwYUQXY0IXwAUGUCGGoxkYGBiweXAoeAYAz44F3e3U1xUAAAAASUVORK5CYII=")
`.
### transform
| property | syntax | default | printed |
| -------- | ---------------- | ---------------------- | ----------- |
| child | `<node>` | color { } | always |
| transform| `<transform>` | none | non-default |
Creates a node like `gsk_transform_node_new()` with the given properties.

View File

@@ -1,7 +1,14 @@
executable('print-editor',
executable('gtk4-print-editor',
['print-editor.c'],
c_args: common_cflags,
dependencies: libgtk_dep,
include_directories: confinc,
gui_app: true,
link_args: extra_demo_ldflags)
link_args: extra_demo_ldflags,
install: true)
# desktop file
install_data('org.gtk.PrintEditor4.desktop', install_dir: gtk_applicationsdir)
# appdata
install_data('org.gtk.PrintEditor4.appdata.xml', install_dir: gtk_appdatadir)

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>org.gtk.PrintEditor4.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>LGPL-2.0+</project_license>
<name>GTK Print Editor</name>
<summary>Program to demonstrate GTK printing</summary>
<description>
<p>
GTK Print Editor is a simple editor to demonstrate GTK printing.
</p>
</description>
<screenshots>
<screenshot>
<image>https://static.gnome.org/appdata/gtk4-print-editor/gtk-print-editor1.png</image>
<caption>Print Editor</caption>
</screenshot>
</screenshots>
<kudos>
<kudo>HiDpiIcon</kudo>
<kudo>ModernToolkit</kudo>
</kudos>
<url type="homepage">https://www.gtk.org</url>
<translation type="gettext">gtk-4.0</translation>
<update_contact>matthias.clasen_at_gmail.com</update_contact>
<developer_name>Matthias Clasen and others</developer_name>
<releases>
<release version="3.99.0" date="2020">
<description>
<p>A new developers snapshot towards GTK 4.0.</p>
</description>
</release>
</releases>
</component>

View File

@@ -0,0 +1,10 @@
[Desktop Entry]
Name=Print Editor
Comment=A simple editor demonstrating GTK printing
Exec=gtk4-print-editor %f
Icon=text-editor-symbolic
Terminal=false
Type=Application
StartupNotify=true
Categories=Development;GTK;
NoDisplay=true

View File

@@ -23,7 +23,7 @@ update_title (GtkWindow *window)
else
basename = g_file_get_basename (filename);
title = g_strdup_printf ("Simple Editor with printing - %s", basename);
title = g_strdup_printf ("GTK Print Editor — %s", basename);
g_free (basename);
gtk_window_set_title (window, title);
@@ -592,18 +592,54 @@ activate_about (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
const gchar *authors[] = {
"Alexander Larsson",
NULL
};
char *version;
GString *sysinfo;
char *setting;
char **backends;
int i;
sysinfo = g_string_new ("System libraries\n");
g_string_append_printf (sysinfo, "\tGLib\t%d.%d.%d\n",
glib_major_version,
glib_minor_version,
glib_micro_version);
g_string_append_printf (sysinfo, "\tPango\t%s\n",
pango_version_string ());
g_string_append_printf (sysinfo, "\tGTK\t%d.%d.%d\n",
gtk_get_major_version (),
gtk_get_minor_version (),
gtk_get_micro_version ());
g_string_append (sysinfo, "\nPrint backends\n");
g_object_get (gtk_settings_get_default (), "gtk-print-backends", &setting, NULL);
backends = g_strsplit (setting, ",", -1);
for (i = 0; backends[i]; i++)
g_string_append_printf (sysinfo, "\t%s\n", backends[i]);
g_strfreev (backends);
g_free (setting);
version = g_strdup_printf ("%s\nRunning against GTK %d.%d.%d",
PACKAGE_VERSION,
gtk_get_major_version (),
gtk_get_minor_version (),
gtk_get_micro_version ());
gtk_show_about_dialog (GTK_WINDOW (main_window),
"name", "Print Test Editor",
"logo-icon-name", "text-editor-symbolic",
"version", PACKAGE_VERSION,
"program-name", "GTK Print Editor",
"version", version,
"copyright", "© 2006-2020 Red Hat, Inc",
"comments", "Program to demonstrate GTK printing.",
"authors", authors,
"license-type", GTK_LICENSE_LGPL_2_1,
"website", "http://www.gtk.org",
"comments", "Program to demonstrate GTK printing",
"authors", (const char *[]){ "Alexander Larsson", NULL },
"logo-icon-name", "text-editor-symbolic",
"title", "About GTK Print Editor",
"system-information", sysinfo->str,
NULL);
g_string_free (sysinfo, TRUE);
g_free (version);
}
static void
@@ -643,23 +679,6 @@ static const gchar ui_info[] =
"<interface>"
" <menu id='menubar'>"
" <submenu>"
" <attribute name='label'>_Application</attribute>"
" <section>"
" <item>"
" <attribute name='label'>_About</attribute>"
" <attribute name='action'>app.about</attribute>"
" <attribute name='accel'>&lt;Primary&gt;a</attribute>"
" </item>"
" </section>"
" <section>"
" <item>"
" <attribute name='label'>_Quit</attribute>"
" <attribute name='action'>app.quit</attribute>"
" <attribute name='accel'>&lt;Primary&gt;q</attribute>"
" </item>"
" </section>"
" </submenu>"
" <submenu>"
" <attribute name='label'>_File</attribute>"
" <section>"
" <item>"
@@ -696,6 +715,23 @@ static const gchar ui_info[] =
" <attribute name='action'>app.print</attribute>"
" </item>"
" </section>"
" <section>"
" <item>"
" <attribute name='label'>_Quit</attribute>"
" <attribute name='action'>app.quit</attribute>"
" <attribute name='accel'>&lt;Primary&gt;q</attribute>"
" </item>"
" </section>"
" </submenu>"
" <submenu>"
" <attribute name='label'>_Help</attribute>"
" <section>"
" <item>"
" <attribute name='label'>_About Print Editor</attribute>"
" <attribute name='action'>app.about</attribute>"
" <attribute name='accel'>&lt;Primary&gt;a</attribute>"
" </item>"
" </section>"
" </submenu>"
" </menu>"
"</interface>";
@@ -716,25 +752,6 @@ mark_set_callback (GtkTextBuffer *text_buffer,
update_statusbar ();
}
static gint
command_line (GApplication *application,
GApplicationCommandLine *command_line)
{
int argc;
char **argv;
argv = g_application_command_line_get_arguments (command_line, &argc);
if (argc == 2)
{
GFile *file = g_file_new_for_commandline_arg (argv[1]);
load_file (file);
g_object_unref (file);
}
return 0;
}
static void
startup (GApplication *app)
{
@@ -768,7 +785,7 @@ activate (GApplication *app)
gtk_window_set_child (GTK_WINDOW (main_window), box);
/* Create document */
sw = gtk_scrolled_window_new (NULL, NULL);
sw = gtk_scrolled_window_new ();
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
@@ -809,6 +826,20 @@ activate (GApplication *app)
gtk_widget_show (main_window);
}
static void
open (GApplication *application,
GFile **files,
int n_files,
const char *hint)
{
if (n_files > 1)
g_warning ("Can only open a single file");
activate (application);
load_file (files[0]);
}
int
main (int argc, char **argv)
{
@@ -832,7 +863,7 @@ main (int argc, char **argv)
g_clear_error (&error);
}
app = gtk_application_new ("org.gtk.PrintEditor", 0);
app = gtk_application_new ("org.gtk.PrintEditor4", G_APPLICATION_HANDLES_OPEN);
g_action_map_add_action_entries (G_ACTION_MAP (app),
app_entries, G_N_ELEMENTS (app_entries),
@@ -840,7 +871,7 @@ main (int argc, char **argv)
g_signal_connect (app, "startup", G_CALLBACK (startup), NULL);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
g_signal_connect (app, "command-line", G_CALLBACK (command_line), NULL);
g_signal_connect (app, "open", G_CALLBACK (open), NULL);
g_application_run (G_APPLICATION (app), argc, argv);

View File

@@ -408,6 +408,8 @@ activate_print (GSimpleAction *action,
g_signal_connect (op, "draw-page", G_CALLBACK (print_operation_page), window);
g_signal_connect (op, "done", G_CALLBACK (print_operation_done), NULL);
gtk_print_operation_set_embed_page_setup (op, TRUE);
res = gtk_print_operation_run (op, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, window, NULL);
if (res == GTK_PRINT_OPERATION_RESULT_IN_PROGRESS)

View File

@@ -207,8 +207,6 @@ GdkModifierType
GDK_MODIFIER_MASK
<SUBSECTION>
gdk_surface_get_support_multidevice
gdk_surface_set_support_multidevice
gdk_surface_get_device_cursor
gdk_surface_set_device_cursor
@@ -357,17 +355,13 @@ gdk_device_get_name
gdk_device_get_vendor_id
gdk_device_get_product_id
gdk_device_get_source
gdk_device_set_key
gdk_device_get_key
gdk_device_set_axis_use
gdk_device_get_axis_use
gdk_device_get_associated_device
gdk_device_list_slave_devices
gdk_device_list_physical_devices
gdk_device_get_device_type
gdk_device_get_display
gdk_device_get_has_cursor
gdk_device_get_n_axes
gdk_device_get_n_keys
gdk_device_get_axes
gdk_device_get_seat
gdk_device_get_num_touches
@@ -382,13 +376,8 @@ gdk_device_has_bidi_layouts
<SUBSECTION>
gdk_device_get_state
gdk_device_get_surface_at_position
gdk_device_get_history
gdk_device_free_history
GdkTimeCoord
gdk_device_get_axis
gdk_device_get_axis_names
gdk_device_get_axis_value
gdk_device_get_last_event_surface
<SUBSECTION>
gdk_device_tool_get_serial
@@ -449,8 +438,7 @@ gdk_seat_get_display
gdk_seat_get_capabilities
gdk_seat_get_pointer
gdk_seat_get_keyboard
gdk_seat_get_slaves
gdk_seat_get_master_pointers
gdk_seat_get_physical_devices
<SUBSECTION Standard>
GDK_SEAT
@@ -494,12 +482,14 @@ gdk_event_get_source_device
gdk_event_get_device_tool
gdk_event_get_time
gdk_event_get_display
gdk_event_get_seat
GdkEventSequence
gdk_event_get_event_sequence
gdk_event_get_modifier_state
gdk_event_get_position
gdk_event_get_axes
gdk_event_get_axis
gdk_event_get_history
gdk_event_get_pointer_emulated
gdk_event_triggers_context_menu
gdk_button_event_get_button
@@ -531,7 +521,6 @@ gdk_touchpad_event_get_pinch_scale
gdk_pad_event_get_axis_value
gdk_pad_event_get_button
gdk_pad_event_get_group_mode
gdk_motion_event_get_history
<SUBSECTION>
gdk_events_get_angle

View File

@@ -48,6 +48,7 @@
<chapter id="Lists">
<title>GListModel support</title>
<xi:include href="xml/gtkbitset.xml" />
<xi:include href="xml/gtkexpression.xml" />
<xi:include href="xml/gtkfilterlistmodel.xml" />
<section>
@@ -72,9 +73,10 @@
<xi:include href="xml/gtknoselection.xml" />
<xi:include href="xml/gtksingleselection.xml" />
<xi:include href="xml/gtkmultiselection.xml" />
<xi:include href="xml/gtkpropertyselection.xml" />
</section>
<xi:include href="xml/gtkbookmarklist.xml" />
<xi:include href="xml/gtkdirectorylist.xml" />
<xi:include href="xml/gtkstringlist.xml" />
</chapter>
<chapter id="ListContainers">
@@ -216,6 +218,7 @@
<xi:include href="xml/gtkspinbutton.xml" />
<xi:include href="xml/gtksearchentry.xml" />
<xi:include href="xml/gtksearchbar.xml" />
<xi:include href="xml/gtkeditablelabel.xml" />
</chapter>
<chapter id="TextWidgetObjects">

View File

@@ -312,6 +312,8 @@ gtk_list_box_bind_model
gtk_list_box_row_new
gtk_list_box_row_changed
gtk_list_box_row_is_selected
gtk_list_box_row_get_child
gtk_list_box_row_set_child
gtk_list_box_row_get_header
gtk_list_box_row_set_header
gtk_list_box_row_get_index
@@ -339,21 +341,69 @@ gtk_list_box_get_type
gtk_list_box_row_get_type
</SECTION>
<SECTION>
<FILE>gtkbitset</FILE>
<TITLE>GtkBitset</TITLE>
GtkBitset
gtk_bitset_ref
gtk_bitset_unref
gtk_bitset_new_empty
gtk_bitset_new_range
gtk_bitset_copy
<SUBSECTION>
gtk_bitset_contains
gtk_bitset_is_empty
gtk_bitset_equals
gtk_bitset_get_minimum
gtk_bitset_get_maximum
gtk_bitset_get_size
gtk_bitset_get_size_in_range
gtk_bitset_get_nth
<SUBSECTION>
gtk_bitset_remove_all
gtk_bitset_add
gtk_bitset_remove
gtk_bitset_add_range
gtk_bitset_remove_range
gtk_bitset_add_range_closed
gtk_bitset_remove_range_closed
gtk_bitset_add_rectangle
gtk_bitset_remove_rectangle
gtk_bitset_union
gtk_bitset_intersect
gtk_bitset_subtract
gtk_bitset_difference
gtk_bitset_shift_left
gtk_bitset_shift_right
gtk_bitset_slice
<SUBSECTION>
GtkBitsetIter
gtk_bitset_iter_init_first
gtk_bitset_iter_init_last
gtk_bitset_iter_init_at
gtk_bitset_iter_next
gtk_bitset_iter_previous
gtk_bitset_iter_get_value
gtk_bitset_iter_is_valid
<SUBSECTION Private>
GTK_TYPE_BITSET
gtk_bitset_get_type
</SECTION>
<SECTION>
<FILE>gtkselectionmodel</FILE>
<TITLE>GtkSelectionModel</TITLE>
GtkSelectionModel
gtk_selection_model_is_selected
gtk_selection_model_get_selection
gtk_selection_model_get_selection_in_range
gtk_selection_model_select_item
gtk_selection_model_unselect_item
gtk_selection_model_select_range
gtk_selection_model_unselect_range
gtk_selection_model_select_all
gtk_selection_model_unselect_all
GtkSelectionCallback
gtk_selection_model_select_callback
gtk_selection_model_unselect_callback
gtk_selection_model_query_range
gtk_selection_model_set_selection
<SUBSECTION>
gtk_selection_model_selection_changed
<SUBSECTION Standard>
@@ -404,15 +454,6 @@ gtk_multi_selection_new
gtk_multi_selection_get_type
</SECTION>
<SECTION>
<FILE>gtkpropertyselection</FILE>
<TITLE>GtkPropertySelection</TITLE>
GtkPropertySelection
gtk_property_selection_new
<SUBSECTION Private>
gtk_property_selection_get_type
</SECTION>
<SECTION>
<FILE>gtklistitem</FILE>
<TITLE>GtkListItem</TITLE>
@@ -424,6 +465,8 @@ gtk_list_item_set_child
gtk_list_item_get_selected
gtk_list_item_get_selectable
gtk_list_item_set_selectable
gtk_list_item_get_activatable
gtk_list_item_set_activatable
<SUBSECTION Standard>
GTK_LIST_ITEM
GTK_LIST_ITEM_CLASS
@@ -587,6 +630,7 @@ gtk_column_view_column_get_type
<TITLE>GtkGridView</TITLE>
GtkGridView
gtk_grid_view_new
gtk_grid_view_new_with_factory
gtk_grid_view_set_model
gtk_grid_view_get_model
gtk_grid_view_set_max_columns
@@ -597,6 +641,8 @@ gtk_grid_view_set_single_click_activate
gtk_grid_view_get_single_click_activate
gtk_grid_view_set_enable_rubberband
gtk_grid_view_get_enable_rubberband
gtk_grid_view_set_factory
gtk_grid_view_get_factory
<SUBSECTION Standard>
GTK_GRID_VIEW
GTK_GRID_VIEW_CLASS
@@ -980,6 +1026,18 @@ GTK_EDITABLE_GET_IFACE
gtk_editable_get_type
</SECTION>
<SECTION>
<FILE>gtkeditablelabel</FILE>
<TITLE>GtkEditableLabel</TITLE>
GtkEditableLabel
gtk_editable_label_new
gtk_editable_label_get_editing
gtk_editable_label_start_editing
gtk_editable_label_stop_editing
<SUBSECTION Private>
gtk_editable_label_get_type
</SECTION>
<SECTION>
<FILE>gtktext</FILE>
<TITLE>GtkText</TITLE>
@@ -1400,6 +1458,21 @@ GTK_DIRECTORY_LIST_GET_CLASS
gtk_directory_list_get_type
</SECTION>
<SECTION>
<FILE>gtkbookmarklist</FILE>
<TITLE>GtkBookmarkList</TITLE>
GtkBookmarkList
gtk_bookmark_list_new
gtk_bookmark_list_get_filename
gtk_bookmark_list_set_attributes
gtk_bookmark_list_get_attributes
gtk_bookmark_list_set_io_priority
gtk_bookmark_list_get_io_priority
gtk_bookmark_list_is_loading
<SUBSECTION Standard>
GTK_TYPE_BOOKMARK_LIST
</SECTION>
<SECTION>
<FILE>gtkfilter</FILE>
<TITLE>GtkFilter</TITLE>
@@ -1409,8 +1482,6 @@ gtk_filter_get_strictness
<SUBSECTION>
GtkFilterChange
gtk_filter_changed
<SUBSECTION>
gtk_custom_filter_new
<SUBSECTION Standard>
GTK_FILTER
GTK_IS_FILTER
@@ -1428,6 +1499,7 @@ gtk_filter_get_type
GtkCustomFilter
GtkCustomFilterFunc
gtk_custom_filter_new
gtk_custom_filter_set_filter_func
<SUBSECTION Standard>
GTK_CUSTOM_FILTER
GTK_IS_CUSTOM_FILTER
@@ -1472,6 +1544,9 @@ gtk_filter_list_model_set_model
gtk_filter_list_model_get_model
gtk_filter_list_model_set_filter
gtk_filter_list_model_get_filter
gtk_filter_list_model_set_incremental
gtk_filter_list_model_get_incremental
gtk_filter_list_model_get_pending
<SUBSECTION Standard>
GTK_FILTER_LIST_MODEL
GTK_IS_FILTER_LIST_MODEL
@@ -1491,6 +1566,9 @@ gtk_fixed_new
gtk_fixed_put
gtk_fixed_remove
gtk_fixed_move
gtk_fixed_get_child_position
gtk_fixed_get_child_transform
gtk_fixed_set_child_transform
<SUBSECTION Standard>
GTK_FIXED
GTK_IS_FIXED
@@ -2704,6 +2782,8 @@ gtk_numeric_sorter_get_type
<TITLE>GtkCustomSorter</TITLE>
GtkCustomSorter
gtk_custom_sorter_new
gtk_custom_sorter_set_sort_func
<SUBSECTION Standard>
GTK_CUSTOM_SORTER
GTK_IS_CUSTOM_SORTER
@@ -4472,11 +4552,8 @@ gtk_widget_has_visible_focus
gtk_widget_is_drawable
gtk_widget_set_receives_default
gtk_widget_get_receives_default
gtk_widget_set_support_multidevice
gtk_widget_get_support_multidevice
gtk_widget_get_realized
gtk_widget_get_mapped
gtk_widget_device_is_shadowed
gtk_widget_get_opacity
gtk_widget_set_opacity
gtk_widget_get_overflow
@@ -6031,6 +6108,16 @@ gtk_header_bar_get_type
GtkStackPage
gtk_stack_page_get_visible
gtk_stack_page_set_visible
gtk_stack_page_get_title
gtk_stack_page_set_title
gtk_stack_page_get_name
gtk_stack_page_set_name
gtk_stack_page_get_needs_attention
gtk_stack_page_set_needs_attention
gtk_stack_page_get_use_underline
gtk_stack_page_set_use_underline
gtk_stack_page_get_icon_name
gtk_stack_page_set_icon_name
gtk_stack_page_get_child
GtkStack
gtk_stack_new
@@ -7501,6 +7588,7 @@ gtk_drop_down_set_model
gtk_drop_down_get_model
gtk_drop_down_set_selected
gtk_drop_down_get_selected
gtk_drop_down_get_selected_item
gtk_drop_down_set_factory
gtk_drop_down_get_factory
gtk_drop_down_set_list_factory
@@ -7514,3 +7602,17 @@ GTK_TYPE_DROP_DOWN
<SUBSECTION Private>
gtk_drop_down_get_type
</SECTION>
<SECTION>
<FILE>gtkstringlist</FILE>
<TITLE>GtkStringList</TITLE>
GtkStringList
gtk_string_list_new
gtk_string_list_append
gtk_string_list_take
gtk_string_list_remove
gtk_string_list_splice
gtk_string_list_get_string
GtkStringObject
gtk_string_object_get_string
</SECTION>

View File

@@ -18,6 +18,8 @@ gtk_aspect_frame_get_type
gtk_assistant_get_type
gtk_assistant_page_get_type
gtk_bin_layout_get_type
gtk_bitset_get_type
gtk_bookmark_list_get_type
gtk_box_get_type
gtk_box_layout_get_type
gtk_buildable_get_type
@@ -68,6 +70,7 @@ gtk_drop_target_get_type
gtk_drop_target_async_get_type
gtk_drop_down_get_type
gtk_editable_get_type
gtk_editable_label_get_type
gtk_emoji_chooser_get_type
gtk_entry_buffer_get_type
gtk_entry_completion_get_type
@@ -169,7 +172,6 @@ gtk_print_operation_preview_get_type
gtk_print_settings_get_type
@DISABLE_ON_W32@gtk_print_unix_dialog_get_type
gtk_progress_bar_get_type
gtk_property_selection_get_type
gtk_radio_button_get_type
gtk_range_get_type
gtk_recent_manager_get_type
@@ -208,6 +210,8 @@ gtk_stack_sidebar_get_type
gtk_stack_switcher_get_type
gtk_statusbar_get_type
gtk_string_filter_get_type
gtk_string_list_get_type
gtk_string_object_get_type
gtk_string_sorter_get_type
gtk_switch_get_type
gtk_level_bar_get_type

View File

@@ -5,7 +5,7 @@ in what happens to translate a key press or mouse motion of the users into a
change of a GTK widget, you should read this chapter. This knowledge will also
be useful if you decide to implement your own widgets.
Devices and events
## Devices and events
The most basic input devices that every computer user has interacted with are
keyboards and mice; beyond these, GTK supports touchpads, touchscreens and
@@ -13,14 +13,14 @@ more exotic input devices such as graphics tablets. Inside GTK, every such
input device is represented by a #GdkDevice object.
To simplify dealing with the variability between these input devices, GTK
has a concept of master and slave devices. The concrete physical devices that
has a concept of logical and physical devices. The concrete physical devices that
have many different characteristics (mice may have 2 or 3 or 8 buttons,
keyboards have different layouts and may or may not have a separate number
block, etc) are represented as slave devices. Each slave device is
associated with a virtual master device. Master devices always come in
block, etc) are represented as physical devices. Each physical device is
associated with a virtual logical device. Logical devices always come in
pointer/keyboard pairs - you can think of such a pair as a 'seat'.
GTK widgets generally deal with the master devices, and thus can be used
GTK widgets generally deal with the logical devices, and thus can be used
with any pointing device or keyboard.
When a user interacts with an input device (e.g. moves a mouse or presses

View File

@@ -176,7 +176,6 @@ private_headers = [
'gtkroundedboxprivate.h',
'gtkscalerprivate.h',
'gtksearchentryprivate.h',
'gtkset.h',
'gtksettingsprivate.h',
'gtkshortcutcontrollerprivate.h',
'gtkshortcutsshortcutprivate.h',
@@ -216,6 +215,7 @@ private_headers = [
'gtkwin32themeprivate.h',
'gtkwindowprivate.h',
'gtk-text-input-client-protocol.h',
'roaring.h',
]
images = [

View File

@@ -457,6 +457,11 @@ as property. GtkNotebook and GtkAssistant are similar.
gtk4-builder-tool can help with this conversion, with the --3to4 option
of the simplify command.
### Adapt to GtkScrolledWindow API changes
The constructor for GtkScrolledWindow no longer takes the adjustments
as arguments - these were almost always %NULL.
### Adapt to GtkBin removal
The abstract base class GtkBin for single-child containers has been
@@ -638,7 +643,7 @@ nodes.
If you are using a #GtkDrawingArea for custom drawing, you need to switch
to using gtk_drawing_area_set_draw_func() to set a draw function instead
of connnecting a handler to the #GtkWidget::draw signal.
of connecting a handler to the #GtkWidget::draw signal.
### Stop using APIs to query GdkSurfaces
@@ -940,3 +945,18 @@ You can replace calls to <function>gtk_dialog_run()</function>
by specifying that the #GtkDialog must be modal using
gtk_window_set_modal() or the %GTK_DIALOG_MODAL flag, and
connecting to the #GtkDialog::response signal.
## Changes to consider after the switch
GTK 4 has a number of new features that you may want to take
advantage of once the dust has settled over the initial migration.
### Consider porting to the new list widgets
In GTK 2 and 3, GtkTreeModel and GtkCellRenderer and widgets using
these were the primary way of displaying data and lists. GTK 4 brings
a new family of widgets for this purpose that uses list models instead
of tree models, and widgets instead of cell renderers.
To learn more about the new list widgets, you can read the [List Widget
Overview](#ListWidget).

View File

@@ -4,9 +4,10 @@
GTK inspects a number of environment variables in addition to
standard variables like `LANG`, `PATH`, `HOME` or `DISPLAY`; mostly
to determine paths to look for certain files. The [X11]{#x11-envar},
[Windows]{#win32-envar} and [Broadway]{#broadway-envar} GDK backends
use some additional environment variables.
to determine paths to look for certain files. The [X11](#x11-envar),
[Wayland](#wayland-envar), [Windows](#win32-envar) and
[Broadway](#broadway-envar) GDK backends use some additional
environment variables.
### GTK_DEBUG {#GTK_Debug-Options}

View File

@@ -4,8 +4,8 @@ GTK provides powerful widgets to display and edit lists of data. This document
gives an overview over the concepts and how they work together to allow
developers to implement lists.
Lists are intended to be used whenever developers want to display lists of
objects in roughly the same way.
Lists are intended to be used whenever developers want to display many objects
in roughly the same way.
Lists are perfectly fine to be used for very short list of only 2 or 3 elements,
but generally scale fine to millions of items. Of course, the larger the list
@@ -32,8 +32,8 @@ be provided in 3 ways or combinations thereof:
specific data, like #GtkDirectoryList. And there are models like #GListStore
that allow building lists manually.
* Wrapping list models exists like #GtkFilterListModel or #GtkSortListModel
that modify or adapt or combine other models.
* Wrapping list models like #GtkFilterListModel or #GtkSortListModel
modify, adapt or combine other models.
* Last but not least, developers are encouraged to create their own #GListModel
implementations. The interface is kept deliberately small to make this easy.
@@ -44,8 +44,9 @@ multiple different models at once.
The elements in a model are called **_items_**. All items are #GObjects.
Every item in a model has a **_position_** which is the unsigned integer that
describes where in the model the item is located. This position can of course
change as items are added or removed from the model.
describes where in the model the item is located. The first item in a model is
at position 0. The position of an item can of course change as other items are
added or removed from the model.
It is important to be aware of the difference between items and positions
because the mapping from position to item is not permanent, so developers
@@ -80,7 +81,7 @@ The behavior of selection models - ie which items they allow selecting and
what effect this has on other items - is completely up to the selection model.
As such, single-selections, multi-selections or sharing selection state between
different selection models and/or views is possible. The selection state of an
item is exposed in the listitem via the GtkListItem:selected property.
item is exposed in the listitem via the #GtkListItem:selected property.
Views and listitems also support activation. Activation means that double
clicking or pressing enter while inside a focused row will cause the view

View File

@@ -7,4 +7,13 @@ the Wayland backend by setting `GDK_BACKEND=wayland`.
On UNIX, the Wayland backend is enabled by default, so you don't need to
do anything special when compiling it, and everything should "just work."
Currently, the Wayland backend does not use any additional environment variables.
## Wayland-specific environment variables {#wayland-envar}
### WAYLAND_DISPLAY
Specifies the name of the Wayland display to use. Typically, wayland-0
or wayland-1.
### XDG_RUNTIME_DIR
Used to locate the Wayland socket to use.

View File

@@ -16,7 +16,6 @@ variables.
### GDK_IGNORE_WINTAB
If this variable is set, GTK doesn't use the Wintab API for tablet support.
</para>
### GDK_USE_WINTAB
@@ -37,10 +36,10 @@ can override GTK settings in the `settings.ini` file or at runtime in the
GTK Inspector.
Themes are loaded from normal Windows variants of the XDG locations:
`%HOME%/icons/THEME/cursors`,
`%APPDATA%/icons/THEME/cursors`,
`%HOME%/icons/THEME/cursors`,
`%APPDATA%/icons/THEME/cursors`,
`RUNTIME_PREFIX/share/icons/THEME/cursors`
The `gtk-cursor-theme-size`> setting is ignored, GTK will use
The `gtk-cursor-theme-size` setting is ignored, GTK will use
the cursor size that Windows tells it to use.

View File

@@ -881,7 +881,7 @@ create_scrolledwindow (void)
{
GtkWidget *scrolledwin, *label;
scrolledwin = gtk_scrolled_window_new (NULL, NULL);
scrolledwin = gtk_scrolled_window_new ();
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwin),
GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
label = gtk_label_new ("Scrolled Window");

View File

@@ -258,7 +258,7 @@ example_app_window_open (ExampleAppWindow *win,
basename = g_file_get_basename (file);
scrolled = gtk_scrolled_window_new (NULL, NULL);
scrolled = gtk_scrolled_window_new ();
gtk_widget_set_hexpand (scrolled, TRUE);
gtk_widget_set_vexpand (scrolled, TRUE);
view = gtk_text_view_new ();

View File

@@ -43,7 +43,7 @@ example_app_window_open (ExampleAppWindow *win,
basename = g_file_get_basename (file);
scrolled = gtk_scrolled_window_new (NULL, NULL);
scrolled = gtk_scrolled_window_new ();
gtk_widget_set_hexpand (scrolled, TRUE);
gtk_widget_set_vexpand (scrolled, TRUE);
view = gtk_text_view_new ();

View File

@@ -53,7 +53,7 @@ example_app_window_open (ExampleAppWindow *win,
basename = g_file_get_basename (file);
scrolled = gtk_scrolled_window_new (NULL, NULL);
scrolled = gtk_scrolled_window_new ();
gtk_widget_set_hexpand (scrolled, TRUE);
gtk_widget_set_vexpand (scrolled, TRUE);
view = gtk_text_view_new ();

View File

@@ -76,7 +76,7 @@ example_app_window_open (ExampleAppWindow *win,
basename = g_file_get_basename (file);
scrolled = gtk_scrolled_window_new (NULL, NULL);
scrolled = gtk_scrolled_window_new ();
gtk_widget_set_hexpand (scrolled, TRUE);
gtk_widget_set_vexpand (scrolled, TRUE);
view = gtk_text_view_new ();

View File

@@ -77,7 +77,7 @@ example_app_window_open (ExampleAppWindow *win,
basename = g_file_get_basename (file);
scrolled = gtk_scrolled_window_new (NULL, NULL);
scrolled = gtk_scrolled_window_new ();
gtk_widget_set_hexpand (scrolled, TRUE);
gtk_widget_set_vexpand (scrolled, TRUE);
view = gtk_text_view_new ();

View File

@@ -130,7 +130,7 @@ example_app_window_open (ExampleAppWindow *win,
basename = g_file_get_basename (file);
scrolled = gtk_scrolled_window_new (NULL, NULL);
scrolled = gtk_scrolled_window_new ();
gtk_widget_set_hexpand (scrolled, TRUE);
gtk_widget_set_vexpand (scrolled, TRUE);
view = gtk_text_view_new ();

View File

@@ -222,7 +222,7 @@ example_app_window_open (ExampleAppWindow *win,
basename = g_file_get_basename (file);
scrolled = gtk_scrolled_window_new (NULL, NULL);
scrolled = gtk_scrolled_window_new ();
gtk_widget_set_hexpand (scrolled, TRUE);
gtk_widget_set_vexpand (scrolled, TRUE);
view = gtk_text_view_new ();

View File

@@ -256,7 +256,7 @@ example_app_window_open (ExampleAppWindow *win,
basename = g_file_get_basename (file);
scrolled = gtk_scrolled_window_new (NULL, NULL);
scrolled = gtk_scrolled_window_new ();
gtk_widget_set_hexpand (scrolled, TRUE);
gtk_widget_set_vexpand (scrolled, TRUE);
view = gtk_text_view_new ();

View File

@@ -252,7 +252,7 @@ new_window (GApplication *app,
gtk_grid_attach (GTK_GRID (grid), toolbar, 0, 0, 1, 1);
scrolled = gtk_scrolled_window_new (NULL, NULL);
scrolled = gtk_scrolled_window_new ();
gtk_widget_set_hexpand (scrolled, TRUE);
gtk_widget_set_vexpand (scrolled, TRUE);
view = gtk_text_view_new ();

View File

@@ -86,7 +86,7 @@ new_window (GApplication *app,
grid = gtk_grid_new ();
gtk_window_set_child (GTK_WINDOW (window), grid);
scrolled = gtk_scrolled_window_new (NULL, NULL);
scrolled = gtk_scrolled_window_new ();
gtk_widget_set_hexpand (scrolled, TRUE);
gtk_widget_set_vexpand (scrolled, TRUE);
view = gtk_text_view_new ();

View File

@@ -21,7 +21,7 @@ new_window (GApplication *app,
overlay = gtk_overlay_new ();
gtk_window_set_child (GTK_WINDOW (window), overlay);
scrolled = gtk_scrolled_window_new (NULL, NULL);
scrolled = gtk_scrolled_window_new ();
gtk_widget_set_hexpand (scrolled, TRUE);
gtk_widget_set_vexpand (scrolled, TRUE);
view = gtk_text_view_new ();

View File

@@ -23,12 +23,6 @@
#include "gdksurfaceprivate.h"
#include "gdkprivate-broadway.h"
static gboolean gdk_broadway_device_get_history (GdkDevice *device,
GdkSurface *surface,
guint32 start,
guint32 stop,
GdkTimeCoord ***events,
gint *n_events);
static void gdk_broadway_device_get_state (GdkDevice *device,
GdkSurface *surface,
gdouble *axes,
@@ -64,7 +58,6 @@ gdk_broadway_device_class_init (GdkBroadwayDeviceClass *klass)
{
GdkDeviceClass *device_class = GDK_DEVICE_CLASS (klass);
device_class->get_history = gdk_broadway_device_get_history;
device_class->get_state = gdk_broadway_device_get_state;
device_class->set_surface_cursor = gdk_broadway_device_set_surface_cursor;
device_class->query_state = gdk_broadway_device_query_state;
@@ -80,19 +73,8 @@ gdk_broadway_device_init (GdkBroadwayDevice *device_core)
device = GDK_DEVICE (device_core);
_gdk_device_add_axis (device, NULL, GDK_AXIS_X, 0, 0, 1);
_gdk_device_add_axis (device, NULL, GDK_AXIS_Y, 0, 0, 1);
}
static gboolean
gdk_broadway_device_get_history (GdkDevice *device,
GdkSurface *surface,
guint32 start,
guint32 stop,
GdkTimeCoord ***events,
gint *n_events)
{
return FALSE;
_gdk_device_add_axis (device, GDK_AXIS_X, 0, 0, 1);
_gdk_device_add_axis (device, GDK_AXIS_Y, 0, 0, 1);
}
static void
@@ -175,7 +157,7 @@ _gdk_broadway_surface_grab_check_unmap (GdkSurface *surface,
seat = gdk_display_get_default_seat (display);
devices = gdk_seat_get_slaves (seat, GDK_SEAT_CAPABILITY_ALL);
devices = gdk_seat_get_physical_devices (seat, GDK_SEAT_CAPABILITY_ALL);
devices = g_list_prepend (devices, gdk_seat_get_keyboard (seat));
devices = g_list_prepend (devices, gdk_seat_get_pointer (seat));

View File

@@ -119,7 +119,7 @@ create_core_pointer (GdkDisplay *display)
{
return g_object_new (GDK_TYPE_BROADWAY_DEVICE,
"name", "Core Pointer",
"type", GDK_DEVICE_TYPE_MASTER,
"type", GDK_DEVICE_TYPE_LOGICAL,
"source", GDK_SOURCE_MOUSE,
"has-cursor", TRUE,
"display", display,
@@ -131,7 +131,7 @@ create_core_keyboard (GdkDisplay *display)
{
return g_object_new (GDK_TYPE_BROADWAY_DEVICE,
"name", "Core Keyboard",
"type", GDK_DEVICE_TYPE_MASTER,
"type", GDK_DEVICE_TYPE_LOGICAL,
"source", GDK_SOURCE_KEYBOARD,
"has-cursor", FALSE,
"display", display,
@@ -143,7 +143,7 @@ create_pointer (GdkDisplay *display)
{
return g_object_new (GDK_TYPE_BROADWAY_DEVICE,
"name", "Pointer",
"type", GDK_DEVICE_TYPE_SLAVE,
"type", GDK_DEVICE_TYPE_PHYSICAL,
"source", GDK_SOURCE_MOUSE,
"has-cursor", TRUE,
"display", display,
@@ -155,7 +155,7 @@ create_keyboard (GdkDisplay *display)
{
return g_object_new (GDK_TYPE_BROADWAY_DEVICE,
"name", "Keyboard",
"type", GDK_DEVICE_TYPE_SLAVE,
"type", GDK_DEVICE_TYPE_PHYSICAL,
"source", GDK_SOURCE_KEYBOARD,
"has-cursor", FALSE,
"display", display,
@@ -167,7 +167,7 @@ create_touchscreen (GdkDisplay *display)
{
return g_object_new (GDK_TYPE_BROADWAY_DEVICE,
"name", "Touchscreen",
"type", GDK_DEVICE_TYPE_SLAVE,
"type", GDK_DEVICE_TYPE_PHYSICAL,
"source", GDK_SOURCE_TOUCHSCREEN,
"has-cursor", FALSE,
"display", display,
@@ -196,15 +196,15 @@ _gdk_broadway_display_open (const gchar *display_name)
_gdk_device_set_associated_device (broadway_display->pointer, broadway_display->core_pointer);
_gdk_device_set_associated_device (broadway_display->keyboard, broadway_display->core_keyboard);
_gdk_device_set_associated_device (broadway_display->touchscreen, broadway_display->core_pointer);
_gdk_device_add_slave (broadway_display->core_pointer, broadway_display->touchscreen);
_gdk_device_add_physical_device (broadway_display->core_pointer, broadway_display->touchscreen);
seat = gdk_seat_default_new_for_master_pair (broadway_display->core_pointer,
broadway_display->core_keyboard);
seat = gdk_seat_default_new_for_logical_pair (broadway_display->core_pointer,
broadway_display->core_keyboard);
gdk_display_add_seat (display, seat);
gdk_seat_default_add_slave (GDK_SEAT_DEFAULT (seat), broadway_display->pointer);
gdk_seat_default_add_slave (GDK_SEAT_DEFAULT (seat), broadway_display->keyboard);
gdk_seat_default_add_slave (GDK_SEAT_DEFAULT (seat), broadway_display->touchscreen);
gdk_seat_default_add_physical_device (GDK_SEAT_DEFAULT (seat), broadway_display->pointer);
gdk_seat_default_add_physical_device (GDK_SEAT_DEFAULT (seat), broadway_display->keyboard);
gdk_seat_default_add_physical_device (GDK_SEAT_DEFAULT (seat), broadway_display->touchscreen);
g_object_unref (seat);
gdk_event_init (display);

View File

@@ -1107,13 +1107,12 @@ create_moveresize_surface (MoveResizeData *mv_resize,
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
status = gdk_device_grab (pointer,
mv_resize->moveresize_emulation_surface,
GDK_OWNERSHIP_APPLICATION,
FALSE,
GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK,
NULL,
timestamp);
mv_resize->moveresize_emulation_surface,
FALSE,
GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK,
NULL,
timestamp);
G_GNUC_END_IGNORE_DEPRECATIONS;
if (status != GDK_GRAB_SUCCESS)

View File

@@ -40,4 +40,15 @@ void gdk_surface_set_widget (GdkSurface *surface,
gpointer widget);
gpointer gdk_surface_get_widget (GdkSurface *surface);
typedef struct
{
const char *key;
guint value;
const char *help;
} GdkDebugKey;
guint gdk_parse_debug_var (const char *variable,
const GdkDebugKey *keys,
guint nkeys);
#endif /* __GDK__PRIVATE_H__ */

146
gdk/gdk.c
View File

@@ -42,6 +42,8 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <fribidi.h>
@@ -128,28 +130,28 @@ static int gdk_initialized = 0; /* 1 if the library is initi
*/
#ifdef G_ENABLE_DEBUG
static const GDebugKey gdk_debug_keys[] = {
{ "misc", GDK_DEBUG_MISC },
{ "events", GDK_DEBUG_EVENTS },
{ "dnd", GDK_DEBUG_DND },
{ "input", GDK_DEBUG_INPUT },
{ "eventloop", GDK_DEBUG_EVENTLOOP },
{ "frames", GDK_DEBUG_FRAMES },
{ "settings", GDK_DEBUG_SETTINGS },
{ "opengl", GDK_DEBUG_OPENGL },
{ "vulkan", GDK_DEBUG_VULKAN },
{ "selection", GDK_DEBUG_SELECTION },
{ "clipboard", GDK_DEBUG_CLIPBOARD },
{ "nograbs", GDK_DEBUG_NOGRABS },
{ "gl-disable", GDK_DEBUG_GL_DISABLE },
{ "gl-software", GDK_DEBUG_GL_SOFTWARE },
{ "gl-texture-rect", GDK_DEBUG_GL_TEXTURE_RECT },
{ "gl-legacy", GDK_DEBUG_GL_LEGACY },
{ "gl-gles", GDK_DEBUG_GL_GLES },
{ "gl-debug", GDK_DEBUG_GL_DEBUG },
{ "vulkan-disable", GDK_DEBUG_VULKAN_DISABLE },
{ "vulkan-validate", GDK_DEBUG_VULKAN_VALIDATE },
{ "default-settings",GDK_DEBUG_DEFAULT_SETTINGS },
static const GdkDebugKey gdk_debug_keys[] = {
{ "misc", GDK_DEBUG_MISC, "Miscellaneous information" },
{ "events", GDK_DEBUG_EVENTS, "Information about events" },
{ "dnd", GDK_DEBUG_DND, "Information about Drag-and-Drop" },
{ "input", GDK_DEBUG_INPUT, "Information about input (Windows)" },
{ "eventloop", GDK_DEBUG_EVENTLOOP, "Information about event loop operation (Quartz)" },
{ "frames", GDK_DEBUG_FRAMES, "Information about the frame clock" },
{ "settings", GDK_DEBUG_SETTINGS, "Information about xsettings" },
{ "opengl", GDK_DEBUG_OPENGL, "Information about OpenGL" },
{ "vulkan", GDK_DEBUG_VULKAN, "Information about Vulkan" },
{ "selection", GDK_DEBUG_SELECTION, "Information about selections" },
{ "clipboard", GDK_DEBUG_CLIPBOARD, "Information about clipboards" },
{ "nograbs", GDK_DEBUG_NOGRABS, "Disable pointer and keyboard grabs (X11)" },
{ "gl-disable", GDK_DEBUG_GL_DISABLE, "Disable OpenGL support" },
{ "gl-software", GDK_DEBUG_GL_SOFTWARE, "Force OpenGL software rendering" },
{ "gl-texture-rect", GDK_DEBUG_GL_TEXTURE_RECT, "Use OpenGL texture rectangle extension" },
{ "gl-legacy", GDK_DEBUG_GL_LEGACY, "Use a legacy OpenGL context" },
{ "gl-gles", GDK_DEBUG_GL_GLES, "Use a GLES OpenGL context" },
{ "gl-debug", GDK_DEBUG_GL_DEBUG, "Insert debugging information in OpenGL" },
{ "vulkan-disable", GDK_DEBUG_VULKAN_DISABLE, "Disable Vulkan support" },
{ "vulkan-validate", GDK_DEBUG_VULKAN_VALIDATE, "Load the Vulkan validation layer" },
{ "default-settings",GDK_DEBUG_DEFAULT_SETTINGS, "Force default values for xsettings" },
};
#endif
@@ -199,6 +201,93 @@ gdk_ensure_resources (void)
g_once (&register_resources_once, register_resources, NULL);
}
guint
gdk_parse_debug_var (const char *variable,
const GdkDebugKey *keys,
guint nkeys)
{
guint i;
guint result = 0;
const char *string;
const gchar *p;
const gchar *q;
gboolean invert;
gboolean help;
string = g_getenv (variable);
if (string == NULL)
return 0;
p = string;
invert = FALSE;
help = FALSE;
while (*p)
{
q = strpbrk (p, ":;, \t");
if (!q)
q = p + strlen (p);
if (3 == q - p && g_ascii_strncasecmp ("all", p, q - p) == 0)
{
invert = TRUE;
}
else if (4 == q - p && g_ascii_strncasecmp ("help", p, q - p) == 0)
{
help = TRUE;
}
else
{
for (i = 0; i < nkeys; i++)
{
if (strlen (keys[i].key) == q - p &&
g_ascii_strncasecmp (keys[i].key, p, q - p) == 0)
{
result |= keys[i].value;
break;
}
}
if (i == nkeys)
{
char *val = g_strndup (p, q - p);
fprintf (stderr, "Unrecognized value \"%s\". Try %s=help\n", val, variable);
g_free (val);
}
}
p = q;
if (*p)
p++;
}
if (help)
{
int max_width = 4;
for (i = 0; i < nkeys; i++)
max_width = MAX (max_width, strlen (keys[i].key));
max_width += 4;
fprintf (stderr, "Supported %s values:\n", variable);
for (i = 0; i < nkeys; i++)
fprintf (stderr, " %s%*s%s\n", keys[i].key, (int)(max_width - strlen (keys[i].key)), " ", keys[i].help);
fprintf (stderr, " %s%*s%s\n", "all", max_width - 3, " ", "Enable all values");
fprintf (stderr, " %s%*s%s\n", "help", max_width - 4, " ", "Print this help");
fprintf (stderr, "\nMultiple values can be given, separated by : or space.\n");
}
if (invert)
{
guint all_flags = 0;
for (i = 0; i < nkeys; i++)
all_flags |= keys[i].value;
result = all_flags & (~result);
}
return result;
}
void
gdk_pre_parse (void)
{
@@ -207,13 +296,12 @@ gdk_pre_parse (void)
gdk_ensure_resources ();
#ifdef G_ENABLE_DEBUG
{
gchar *debug_string = getenv("GDK_DEBUG");
if (debug_string != NULL)
_gdk_debug_flags = g_parse_debug_string (debug_string,
(GDebugKey *) gdk_debug_keys,
G_N_ELEMENTS (gdk_debug_keys));
}
_gdk_debug_flags = gdk_parse_debug_var ("GDK_DEBUG",
gdk_debug_keys,
G_N_ELEMENTS (gdk_debug_keys));
#else
if (g_getenv ("GDK_DEBUG"))
g_warning ("GDK_DEBUG set but ignored because GTK isn't built with G_ENABLE_DEBUG");
#endif /* G_ENABLE_DEBUG */
if (g_getenv ("GTK_TRACE_FD"))

View File

@@ -1290,7 +1290,7 @@ gdk_clipboard_set_valist (GdkClipboard *clipboard,
g_warning ("%s: %s", G_STRLOC, error);
g_free (error);
/* we purposely leak the value here, it might not be
* in a sane state if an error condition occoured
* in a sane state if an error condition occurred
*/
return;
}

View File

@@ -156,7 +156,7 @@ gdk_content_provider_new_typed (GType type,
g_warning ("%s: %s", G_STRLOC, error);
g_free (error);
/* we purposely leak the value here, it might not be
* in a sane state if an error condition occoured
* in a sane state if an error condition occurred
*/
}
va_end (args);

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