Compare commits

...

1599 Commits

Author SHA1 Message Date
Matthias Clasen
16b043a127 treelistmodel: Make constructor transfer full
Make gtk_tree_list_model_new() take the root model
as first argument, and make it transfer full, for
consistency with other wrapping list constructors.

Update all callers.

Still missing here: Make the model property writable,
and allow passing NULL in the constructor.
2020-07-26 16:38:53 -04:00
Matthias Clasen
0b7f7028d9 sortlistmodel: Make constructor transfer full
This is for consistency with other wrapping list constructors.
We want them all to be transfer full, allow-none.

Update all callers.
2020-07-26 16:25:12 -04:00
Matthias Clasen
5dba053ad1 filterlistmodel: Make constructor transfer full
This is for consistency with other wrapping list constructors.
We want them all to be transfer full, allow-none.

Update all callers.
2020-07-26 15:55:44 -04:00
Matthias Clasen
cd8a810d69 slicelistmodel: Make constructor transfer full
This is for consistency with other wrapping list constructors.
We want them all to be transfer full, allow-none.

Update all callers.
2020-07-26 15:38:15 -04:00
Matthias Clasen
8f63a5ab63 listlistmodel: Drop item_type
We are using G_TYPE_OBJECT throughout, so there
is no need for GtkListListModel to do anything else.

Update all callers.
2020-07-26 14:37:55 -04:00
Matthias Clasen
eb3381723f maplistmodel: Make constructor transfer full
This is for consistency with other wrapping list constructors.
We want them all to be transfer full, allow-none.

Update all callers.
2020-07-26 14:23:16 -04:00
Matthias Clasen
7e87ad1887 flattenlistmodel: Make the constructor transfer full
This is for consistency with other wrapping list constructors.
We want them all to be transfer full, allow-none.

Update all callers.
2020-07-26 14:21:28 -04:00
Matthias Clasen
ef6babf896 Merge branch 'matthiasc/for-master' into 'master'
overlaylayout: Document minimally

See merge request GNOME/gtk!2285
2020-07-26 12:00:49 +00:00
Matthias Clasen
7f9570b95b overlaylayout: Document minimally
This layout manager is not reusable, but we
still need to make its layout properties show
up in the docs.
2020-07-25 19:02:33 -04:00
Matthias Clasen
d8d8a71a7a Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2284
2020-07-25 17:30:11 +00:00
Matthias Clasen
2ff3e3d1e4 gtk: Improve struct packing in places
Plug some holes in our structs by rearranging
a few fields. This is was done looking at
pahole output.
2020-07-25 11:57:37 -04:00
Matthias Clasen
73f4f518b8 gdk: Improve struct packing in places
Plug some holes in our structs by rearranging
a few fields. This is was done looking at
pahole output.
2020-07-25 11:57:37 -04:00
Matthias Clasen
6e9dbba130 colorswatch: Remove unused radius fields
The radius fields are never used.
2020-07-25 11:57:37 -04:00
Matthias Clasen
706aa93ab5 hsla: Just store floats
We are using floats for rgb, and we don't need more precision
for hsl colors either. We use hsl for computing color expressions
like shade(), lighter() and darker(), which are not precisely
specified anyway.

This commit updates the one test where the output changes a
tiny bit due to this.
2020-07-25 11:56:05 -04:00
Matthias Clasen
54deed9a5a headerbar: Drop the Private struct 2020-07-25 07:41:05 -04:00
Matthias Clasen
0e70ddcab3 colorplane: Drop the Private struct and padding 2020-07-24 22:56:24 -04:00
Matthias Clasen
f2bdb1fb87 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2283
2020-07-25 00:05:28 +00:00
Matthias Clasen
ec9fd76c87 Merge branch 'wip/otte/types' into 'master'
Get rid of unneeded glib types

See merge request GNOME/gtk!2282
2020-07-24 23:54:01 +00:00
Matthias Clasen
bacaa5eb9a Add another sortlistmodel test
This tests the crash fix in f7b73b2e01.
2020-07-24 19:28:54 -04:00
Matthias Clasen
9a297516ba testsuite: Add an incremental sort test
Add a test that makes changes to a model while it
is incrementally sorted.
2020-07-24 19:23:18 -04:00
Matthias Clasen
e9bff53015 timsort: Avoid a crash
We need to clear the pointer after freeing the data,
since the sortlistmodel keeps its timsort structure
around and reuses it.
2020-07-24 19:23:18 -04:00
Benjamin Otte
3078b180fe Replace "gdouble" with "double" 2020-07-25 00:47:36 +02:00
Benjamin Otte
556997f9df Replace "gfloat" with "float" 2020-07-25 00:47:36 +02:00
Benjamin Otte
d375dce9f5 Replace "gchar" with "char" 2020-07-25 00:47:36 +02:00
Benjamin Otte
d7266b25ba Replace "gint" with "int" 2020-07-25 00:47:36 +02:00
Matthias Clasen
2a43ce1705 testsuite: Use better names for sortlistmodel tests
Name the tests for what they do.
2020-07-24 15:37:49 -04:00
Matthias Clasen
3324a6e6b3 testsuite: Reenable tests for incremental sort
This was unintentionally disabled.
2020-07-24 15:22:14 -04:00
Matthias Clasen
46423e614d Merge branch 'remove-align-widget' into 'master'
menubutton: Remove align-widget property

See merge request GNOME/gtk!2280
2020-07-24 18:17:30 +00:00
Matthias Clasen
f7b73b2e01 sortlistmodel: Fix a crash 2020-07-24 14:15:14 -04:00
Matthias Clasen
c85e424279 dropdown: Fix popup sizing
Setting a width request is not quite enough, since
gtk_widget_set_size_request() only queues a resize
when the widget is visible. Explicitly force one
here. Without this, the popup sometimes shows up
too small.
2020-07-24 14:15:04 -04:00
Florian Müllner
b146c48e23 menubutton: Remove align-widget property
The property has been unused since commit 8701e34f74. That was four
years ago, so it's safe to say that nobody has been missing it terribly.
2020-07-24 13:55:06 +02:00
Timm Bäder
3176d69009 Merge branch 'fix-gdk-array-msvc' into 'master'
gdk/gdkarrayimpl.c: Fix build on Visual Studio

See merge request GNOME/gtk!2279
2020-07-24 09:28:21 +00:00
Chun-wei Fan
89f7d841ab gdk/gdkarrayimpl.c: Fix build on Visual Studio
It seems like initializing something to an empty array using `{}` is a GCCism,
so just stuff a 0 within the braces to accomplish the same thing.
2020-07-24 16:25:24 +08:00
Matthias Clasen
7e2fceebca Merge branch 'matthiasc/for-master' into 'master'
filechooser: Remove a leftover signal emission

Closes #2942

See merge request GNOME/gtk!2276
2020-07-24 02:58:51 +00:00
Matthias Clasen
1e00c887ec docs: Work around escaping bugs
This is truly a russian doll of documentation formats:
a string containing <> inside an xml fragment in an |[ ]|
gtk-doc example in markdown in a doc comment.

Sadly, something gets escaping wrong, so the <> end up
literally in the docbook and mess up the last step of
our document formatting, even after turning them into
entities.

Work around this with an extra level of entities that
really shouldn't be necessary.
2020-07-23 18:24:18 -04:00
Matthias Clasen
561d3c68a0 docs: Pass --standalone to pandoc
This flag causes pandoc to emit a proper doctype
declaration and, crucially, namespace declarations
for the xlink namespace that it insists on using
for href attributes. Without this, putting external
links in md documents doesn't survive the journey
through xml.
2020-07-23 18:24:18 -04:00
Matthias Clasen
03601cb794 docs: Improve shortcut trigger docs
Point out the need to escape <> in xml.
2020-07-23 18:24:18 -04:00
Matthias Clasen
3108b8b4d3 docs: Explain the shortcutcontroller example a bit
Add a reference to the the syntax for shortcut actions
in builder files.
2020-07-23 18:24:18 -04:00
Matthias Clasen
d1afe32762 filechooser: Remove a leftover signal emission
Commit 0145809a94 replace the response-requested
signal with an action, but didn't actually remove the emission
of that no-longer-existing signal.

Fixes: #2942
2020-07-23 12:54:07 -04:00
Benjamin Otte
603dd72b09 Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master

See merge request GNOME/gtk!2277
2020-07-23 14:34:33 +00:00
Benjamin Otte
e81ba8924a searchenginemodel: Remove unused code 2020-07-23 15:31:08 +02:00
Benjamin Otte
8832ab45d9 searchengine: Remove unused set_recursive() call 2020-07-23 15:31:08 +02:00
Florentina Mușat
87d6e17bc7 Update Romanian translation 2020-07-23 10:33:16 +00:00
Florentina Mușat
a5033cd79b Update Romanian translation 2020-07-23 10:32:08 +00:00
Matthias Clasen
44cbf3d605 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2275
2020-07-23 00:19:15 +00:00
Matthias Clasen
fb6288791e NEWS: Updates 2020-07-22 19:51:27 -04:00
Matthias Clasen
2160f52cbf migration guide: Add some tables
Add a table mapping event signals to their event controller
replacements, and a table mapping former GtkContainer
subclasses to their gtk_container_add replacement.
2020-07-22 19:38:58 -04:00
Benjamin Otte
8825e621c9 Merge branch 'wip/otte/for-master' into 'master'
timsort: Actually 0-terminate the array in get_runs()

See merge request GNOME/gtk!2274
2020-07-22 18:08:24 +00:00
Benjamin Otte
e22abd73f2 timsort: Actually 0-terminate the array in get_runs()
This could cause SEGVs when changing the sort during an ongoing sort
operation.
2020-07-22 18:59:22 +02:00
Yuri Chornoivan
f77d4d7fc0 Update Ukrainian translation 2020-07-22 13:27:26 +00:00
Yuri Chornoivan
8243133ca7 Update Ukrainian translation 2020-07-22 13:22:09 +00:00
Matthias Clasen
63a4345d2c Merge branch 'wip/otte/sortlistmodel2' into 'master'
Massively refactor and improve sortlistmodel

See merge request GNOME/gtk!2273
2020-07-22 13:15:45 +00:00
Piotr Drąg
56685a483d Update POTFILES.in 2020-07-22 15:01:05 +02:00
Benjamin Otte
b23f793753 gtk-demo: Add a progress bar when the colors demo resorts 2020-07-22 14:30:49 +02:00
Benjamin Otte
2b19e2fc1f sortlistmodel: Add progress estimation 2020-07-22 14:30:49 +02:00
Benjamin Otte
703f8b8136 timsort: Add progress estimation 2020-07-22 14:30:49 +02:00
Benjamin Otte
5b18968867 sortlistmodel: Make key generation part of the step function
SSave the missing keys as a bitset and iterate over that bitset in the
step function.

Solves the problem with a large UI block at the beginning of a sort
operation when all the keys were generated, in particular when key
generation was slow.

Benchmarks for maximum time taken by a single main loop callback:

     initial sort with complex GFileInfo keys
                       old      new
      32,000 items   137ms      3ms
     128,000 items   520ms     31ms

     initial sort with string keys
                       old      new
      32,000 items   187ms      1ms
     128,000 items   804ms      3ms
2020-07-22 14:30:49 +02:00
Benjamin Otte
e8c4e1205a gtk-demo: Make colors demo do incremental sorting 2020-07-22 14:30:49 +02:00
Benjamin Otte
bf5c540357 sortlistmodel: Properly compute runs
When updating a (partially) sorted model, take the known runs for the
existing sort and apply them to the new sort. That way, we don't have to
check the whole model again.

Benchmarks:

      appending half the items to a model of strings
                        old      new
      512,000 items   437ms    389ms
    1,024,000 items  1006ms    914ms

      appending 10% of the items to a model of strings
                        old      new
      512,000 items   206ms    132ms
    1,024,000 items   438ms    301ms

      appending 1 item to a model of strings
                        old      new
       64,000 items   1.8ms   0.00ms
      512,000 items     ---   0.01ms
2020-07-22 14:30:49 +02:00
Benjamin Otte
c03383d3e5 sortlistmodel: Make sort stable again
Previously, the sort was not stable when items were added/removed while
sorting or the sort algorithm was changed.

Now the sort looks at the item position (via the key's location in the
keys array) to make sure each comparison stays stable with respect to
this position.
2020-07-22 14:30:49 +02:00
Benjamin Otte
eaaa287078 multisorter: Implement GtkSortKeys 2020-07-22 14:30:49 +02:00
Benjamin Otte
554defaf1a treelistrowsorter: Implement GtkSortKeys 2020-07-22 14:30:49 +02:00
Benjamin Otte
659fe52b7b numericsorter: Implement GtkSortKeys 2020-07-22 14:30:49 +02:00
Benjamin Otte
0970077af9 stringsorter: Implement GtkSortKeys 2020-07-22 14:30:49 +02:00
Benjamin Otte
814c88fbc1 sortkeys: Add an equal sort keys
Compares every element as equal.
This is useful when sorters are in an invalid configuration.
2020-07-22 14:30:49 +02:00
Benjamin Otte
3b24c8a0a4 sortlistmodel: Use GtkSortKeys
This massively speeds up sorting with expensive sort functions that it's
the most worthwhile optimization of this whole branch.
It's slower for simple sort functions though.

It's also quite a lot slower when the model doesn't support sort keys
(like GtkCustomSorter), but all the other sorters do support keys.

Of course, this depends on the number of items in the model - the number
of comparisons scales O(N * log N) while the overhead for key handling
scales O(N).
So as the log N part grows, generating keys gets more and more
beneficial.

Benchmarks:

       initial sort of a GFileInfo model with display-name keys
                       items     keys
         8,000 items   715ms     50ms
        64,000 items     ---    554ms

       initial sort of a GFileInfo model with complex keys
                       items     keys
        64,000 items   340ms    295ms
       128,000 items   641ms    605ms

       removing half a GFileInfo model with display-name keys
       (no comparisons, just key freeing overhead of a complex sorter)
                       items     keys
       512,000 items    14ms     21ms
     2,048,000 items    40ms     62ms

       removing half a GFileInfo model with complex keys
       (no comparisons, just key freeing overhead of a complex sorter)
                       items     keys
       512,000 items    90ms    237ms
     2,048,000 items   247ms    601ms
2020-07-22 14:30:49 +02:00
Benjamin Otte
e34c7e6796 sorter: Introduce GtkSortKeys
GtkSortKeys is an immutable struct that can be used to manage "sort
keys" for items.

Sort keys are memory that is created specifically for sorting. Because
sorting involves lots of comparisons, it's a good idea to prepare the
data relevant for sorting in advance and sort on that data.

In measurements with a PropertyExpression on a string sorter, it's about
??? faster
2020-07-22 14:30:49 +02:00
Benjamin Otte
8c608e9c1c sortlistmodel: Split the SortItem into 2 arrays
Instead of one item keeping the item + its position and sorting that
list, keep the items in 1 array and put the positions into a 2nd array.

This is generally slower while sorting, but allows multiple improvements:

1. We can replace items with keys
   This allows avoiding multiple slow lookups when using complex
   comparisons

2. We can keep multiple position arrays
   This allows doing a sorting in the background without actually
   emitting items-changed() until the array is completely sorted.

3. The main list tracks the items in the original model
   So only a single memmove() is necessary there, while the old version
   had to upgrade the position in every item.
Benchmarks:

        sorting a model of simple strings
                          old      new
        256,000 items   256ms    268ms
        512,000 items   569ms    638ms

        sorting a model of file trees, directories first, by size
                          old      new
         64,000 items   350ms    364ms
        128,000 items   667ms    691ms

        removing half the model
                          old      new
        512,000 items    24ms     15ms
      1,024,000 items    49ms     25ms
2020-07-22 14:30:49 +02:00
Benjamin Otte
283c3b70dd sortlistmodel: Add an incremental property
Also refactor a large part of the sortmodel to make this convenient.

A large amount of time has been spent on getting items-changed regions
minimized.
2020-07-22 14:30:49 +02:00
Benjamin Otte
93599c2c48 testsuite: Add exhaustive sortlistmodel test
This is basically a copy/paste from the filterlistmodel test, but
adapted for sorting.
2020-07-22 14:04:40 +02:00
Benjamin Otte
080e625090 sortlistmodel: Make the sort callback useful
1. Run step() for a while to avoid very short steps
   This way, we batch items-changed() emissions.

2. Track the change region accurately
   This way, we can avoid invalidating the whole list if our step just
   touched a small part of a huge list.
   As this is a merge sort, this is a common occurence when we're buys
   merging chunks: The rest of the model outside those chunks isn't
   changed.

Note that the tracking is accurate: It determines the minimum change
region in the model.

This will be important, because the testsuite is going to test this.
2020-07-22 14:04:40 +02:00
Benjamin Otte
26696a741e timsort: Add change tracking to gtk_tim_sort_step() 2020-07-22 14:04:40 +02:00
Benjamin Otte
a209e54b8f timsort: Add gtk_tim_sort_set_max_merge_size()
Makes the SOrtListModel responsive when incrementally sorting.

By making it configurable we can avoid losting performance in the
non-incremental case.
2020-07-22 14:04:40 +02:00
Benjamin Otte
8921dadaa1 timsort: Make sure merges don't take too long
Limit the size of the merged areas and thereby chunk larger merges into
smaller ones.
2020-07-22 14:04:40 +02:00
Benjamin Otte
47232acbd8 sortlistmodel: Make sorting incremental
This is just an experiment so far to see how long it takes to sort.
2020-07-22 14:04:40 +02:00
Benjamin Otte
cbad8ec2e4 timsort: Add gtk_tim_sort_set_runs()
... and use it in the SortListModel

Setting runs allows declaring already sorted regions so the sort does
not attempt to sort them again.

This massively speeds up partial inserts where we can reuse the sorted
model as a run and only resort the newly inserted parts.

Benchmarks:

    appending half the model
                    qsort  timsort
    128,000 items    94ms     69ms
    256,000 items   202ms    143ms
    512,000 items   488ms    328ms

    appending 1 item
                    qsort  timsort
      8,000 items   1.5ms    0.0ms
     16,000 items   3.1ms    0.0ms
              ...
    512,000 items     ---    1.8ms
2020-07-22 14:04:40 +02:00
Benjamin Otte
800170b47d sortlistmodel: Use timsort
Simply replace the old qsort() call with a timsort() call.

This is ultimately relevant because timsort is a LOT faster in merging
to already sorted lists (think items-chaged adding some items) or
reversing an existing list (think columnview sort order changes).

Benchmarks:

    initially sorting the model
                    qsort  timsort
    128,000 items   124ms    111ms
    256,000 items   264ms    250ms
2020-07-22 14:04:40 +02:00
Benjamin Otte
97c5cb3514 Add a timsort() implementation 2020-07-22 14:04:40 +02:00
Benjamin Otte
081afc0477 sortlistmodel: Track item positions
The model now tracks the original positions on top of just the items so that
it can remove items in an items-changed emission.

It now takes twice as much memory but removes items much faster.

Benchmarks:

Removing 50% of a model:
                   before    after
   250,000 items    135ms     10ms
   500,000 items    300ms     25ms

Removing 1 item:
     4,000 items    2.2ms      0ms
     8,000 items    4.6ms      0ms
   500,000 items      ---   0.01ms
2020-07-22 14:04:40 +02:00
Benjamin Otte
e807fc3be0 sortlistmodel: Replace with an array-based model
This is the dumbest possible sortmodel using an array:
Just grab all the items, put them in the array, qsort() the array.

Some benchmarks (setting a new model):

  125,000 items - old: 549ms
                  new: 115ms
  250,000 items - new: 250ms

This performance can not be kept for simple additions and removals
though.
2020-07-22 14:04:40 +02:00
Boyuan Yang
a1bd3389ed Update Chinese (China) translation 2020-07-22 02:58:46 +00:00
Boyuan Yang
03a3b5a0b1 Update Chinese (China) translation 2020-07-22 02:39:21 +00:00
Boyuan Yang
1ee2d9a5fa Update Chinese (China) translation 2020-07-22 02:20:08 +00:00
Matthias Clasen
2e07fcd680 Merge branch 'wip/chergert/quartz4u' into 'master'
Merge GDK macOS branch

See merge request GNOME/gtk!2272
2020-07-21 22:22:41 +00:00
Matthias Clasen
d3365d5a60 Merge branch 'matthiasc/for-master' into 'master'
gdk: Update gdkkeysyms.h

See merge request GNOME/gtk!2271
2020-07-21 21:53:16 +00:00
Christian Hergert
9dbf99d91a macos: prototype new GDK backend for macOS
This is fairly substantial rewrite of the GDK backend for quartz and
renamed to macOS to allow for a greenfield implementation.

Many things have come across from the quartz implementation fairly
intact such as the eventloop integration design and discovery of
event windows from the NSEvent.

However much has been changed to fit in with the new GDK design and
how removal of child GdkWindow have been completely eliminated.
Furthermore, the new GdkPopup allows for regular NSWindow to be used
to provide popovers unlike the previous implementation.

The object design more closely follows the ideal for a GDK backend.

Views have been broken out into subclasses so that we can support
multiple GSK renderer paths such as GL and Cairo (and Metal in the
future). However mixed mode GL and Cairo will not be supported. Currently
only the Cairo renderer has been implemented.

A new frame clock implementation using CVDisplayLink provides more
accurate information about when to draw drawing the next frame. Some
testing will need to be done here to understand the power implications
of this.

This implementation has also gained edge snapping for CSD windows. Some
work was also done to ensure that CSD windows have opaque regions
registered with the display server.

     ** This is still very much a work-in-progress **

Some outstanding work that needs to be done:

 - Finish a GL context for macOS and alternate NSView for GL rendering
   (possibly using speciailized CALayer for OpenGL).
 - Input rework to ensure that we don't loose remapping of keys that was
   dropped from GDK during GTK 4 development.
 - Make sure input methods continue to work.
 - Drag-n-Drop is still very much a work in progress
 - High resolution input scrolling needs various work in GDK to land
   first before we can plumb that to NSEvent.
 - gtk/ has a number of things based on GDK_WINDOWING_QUARTZ that need
   to be updated to use the macOS backend.

But this is good enough to start playing with and breaking things which
is what I'd like to see.
2020-07-21 14:45:12 -07:00
Christian Hergert
0154a7f528 gdk: disable file transfer portal on macOS 2020-07-21 14:45:12 -07:00
Christian Hergert
add47bebc6 build: add ATK fallback subproject wrapper
Very similar to the other fallbacks we use.
2020-07-21 14:45:12 -07:00
Christian Hergert
514b62223d build: squash various warnings with Clang
Otherwise we have really chatty builds that make it difficult to catch
new issues when compiling.
2020-07-21 14:45:12 -07:00
Christian Hergert
7884ab6161 build: fix linking support on macOS with Clang
This was preventing any sort of building on macOS, even though the quartz
backend is currently non-functional. Fixing this is a pre-requisite to
getting a new macOS backend compiling.
2020-07-21 14:45:12 -07:00
Matthias Clasen
bc542c5304 gdk: Update gdkkeysyms.h
Run the gdkkeysyms-update.pl script to pick up several
new keysyms:
GDK_dead_lowline
GDK_dead_aboveverticalline
GDK_dead_belowverticalline
GDK_dead_longsolidusoverlay
GDK_Keyboard
GDK_WWAN
GDK_RFKill
GDK_AudioPreset
2020-07-21 16:55:28 -04:00
Matthias Clasen
d66ac4981e Merge branch 'matthiasc/for-master' into 'master'
inspector: Make picking objects show them

Closes #1876

See merge request GNOME/gtk!2269
2020-07-20 22:06:42 +00:00
Matthias Clasen
9b647a47d1 inspector: Make picking objects show them
Changing the selection in the object tree is
not a useful action if we are already in the
object details. Most likely, a user who picks
an object wants to inspect its details, so
just always show them.

Fixes: #1876
2020-07-20 17:30:16 -04:00
Benjamin Otte
b67ffe9650 sortlistmodel: Test that the model is stable
Stability is measured relative to the child model, not relative to the
previous sorter.
2020-07-20 22:28:01 +02:00
Benjamin Otte
2c519b006d testsuite: Fix a leak 2020-07-20 22:28:01 +02:00
Matthias Clasen
852429d163 Merge branch 'barthalion/asan-runner' into 'master'
ci: Switch ASAN tests to runners tagged so

See merge request GNOME/gtk!2267
2020-07-20 16:17:49 +00:00
Matthias Clasen
ee9c6bbf75 Merge branch 'action-muxer-speedup' into 'master'
Action muxer speedup

See merge request GNOME/gtk!1754
2020-07-20 16:17:17 +00:00
Bartłomiej Piotrowski
d9ece94377 ci: Switch ASAN tests to runners tagged so 2020-07-20 16:41:46 +02:00
Matthias Clasen
486fbce42b actionmuxer: Update docs and clean up headers
Update the doc comment at the top to describe the
current  functionality of GtkActionMuxer.
2020-07-20 08:24:54 -04:00
Matthias Clasen
ed92026632 actionmuxer: Use an array for accels
We have a lot of accels across all the muxers, but the vast
majority has just one or two, so an array is going to be
smaller and faster for this.
2020-07-20 08:24:54 -04:00
Matthias Clasen
05e614feb7 actionmuxer: Create observed_actions and groups on demand
The vast majority of action muxers don't have observers or
groups, so we can avoid the overhead of carrying all these
empty hash tables.
2020-07-20 08:24:54 -04:00
Matthias Clasen
14059afdf1 inspector: Make the actions tab work again
Bring back the actions tab; we don't receive
changes anymore, since GtkActionMuxer lost
the GActionGroup signals for this, and the
action observer machinery has no way to listen
for all changes.
2020-07-20 08:24:54 -04:00
Matthias Clasen
9b294eb94e Add gtk_action_muxer_list_actions
This is needed to reinstate the actions support
in the inspector.
2020-07-20 08:24:53 -04:00
Matthias Clasen
96d42cf1cc actionmuxer: Stop implementing GActionGroup
Instead of implementing the GActionGroup interface
and using its signals for propagating changes up
and down the muxer hierarchy, use the GtkActionObserver
mechanism. This cuts down on the signal emission
overhead.
2020-07-20 08:24:53 -04:00
Matthias Clasen
4786a16696 actionmuxer: Port internal users
Port all internal users of the action muxer
from the GActionGroup interface to the new
action muxer apis.
2020-07-20 08:24:52 -04:00
Matthias Clasen
14bb12125f actionmuxer: Add some more api
We want to drop the GActionGroup interface from
GtkActionMuxer, so add the necessary api directly
to GtkActionMuxer itself.
2020-07-20 08:24:14 -04:00
Matthias Clasen
07e8dafcea inspector: Remove action support temporarily
This is using the action muxer as a GActionGroup,
and we want to remove that interface from GtkActionMuxer.

The support will come back later.
2020-07-20 08:24:14 -04:00
Matthias Clasen
ab67a81f11 Speed up action muxer setup more
Don't emit signals for group insertion/removal
if nobody is listening.
2020-07-20 08:24:14 -04:00
Matthias Clasen
aa76f7e210 Speed up action muxer setup
We don't need to duplicate all these action names and
emit all these signals if nobody is listening.
2020-07-20 08:24:14 -04:00
Matthias Clasen
0c15463e41 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2266
2020-07-20 12:23:12 +00:00
Matthias Clasen
5df1356295 gsk: Remove an unused debug flag
GSK_DEBUG_DIFF was not used anywhere, so remove it.
2020-07-20 07:03:08 -04:00
Matthias Clasen
95fc81c565 inspector: Add a few more debug flags
Add check buttons for GTK_DEBUG=constraints and
GTK_DEBUG=layout in the logs page.
2020-07-20 07:03:08 -04:00
Matthias Clasen
378e594f75 Tweak the GTK_DEBUG=help output
I got the layout flag wrong when I added the
improved help output. It is about layout managers,
not about showing layout borders.
2020-07-20 07:03:08 -04:00
Matthias Clasen
86c7fceb09 Merge branch 'list-model-docs' into 'master'
List model docs

See merge request GNOME/gtk!2182
2020-07-19 23:50:09 +00:00
Matthias Clasen
b5e20a3e37 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2265
2020-07-19 19:14:04 +00:00
Matthias Clasen
75a30b1f98 windowhandle: Don't use an action muxer needlessly
The api that is meant to be used here is
gtk_widget_activate_action.
2020-07-19 13:50:23 -04:00
Matthias Clasen
c64a021af4 NEWS: Updates 2020-07-18 18:28:51 -04:00
Matthias Clasen
9b64635925 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2264
2020-07-18 17:31:31 +00:00
Matthias Clasen
7b76be5360 button: Add explicit key bindings for activation
We should not rely on GtkWindow to have global
"activate-default" key bindings that happen to
fall back to activating the focus widget. This is
unreliable, since the bubbling up from the button
to the toplevel may run across other widgets that
may want to use Enter for their own purpose, and
then the button loses out. By adding our own
key bindings, the button gets to handle it before
its ancestors.

This fixes check buttons in the inspector property
list not reacting to Enter despite having focus.
2020-07-18 12:53:10 -04:00
Matthias Clasen
2e2336ffce text: Claim clicks when grabbing focus
If we don't, an ancestor (such a GtkListItemWidget)
may interpret the click as "I should grab focus!",
and still our focus away. This was causing hard-to-focus
entries in the property list in the inspector.
2020-07-18 12:47:47 -04:00
Matthias Clasen
76d80ef516 inspector: Add focus handling to the property editor
We want to focus the actual control here.
2020-07-18 11:55:19 -04:00
Matthias Clasen
287d80bd36 editablelabel: Stop editing on focus-out
This is the expected behavior for the main use case,
treeview-like 'edit one cell at a time'.
2020-07-18 10:45:27 -04:00
Matthias Clasen
77072b3eaa fixup editing style class 2020-07-18 10:10:28 -04:00
Matthias Clasen
c7833bb090 editablelabel: Document css nodes
Just the usual.
2020-07-18 09:55:46 -04:00
Matthias Clasen
899024cef7 editablelabel: Add a style class while editing
Add the .editing style class to the editable label
while it is editing. The idea is that themes can
show a frame around the entry.
2020-07-18 09:54:55 -04:00
Rico Tzschichholz
4da3edd42e Merge branch 'wip/ricotz/annotations' into 'master'
gtk: Improve g-i annotations for methods of GtkExpression subclasses

See merge request GNOME/gtk!2263
2020-07-18 11:06:47 +00:00
Rico Tzschichholz
6b59626817 gtk: Improve g-i annotations for methods of GtkExpression subclasses 2020-07-18 12:30:05 +02:00
Matthias Clasen
7c02ae00c2 inspector: Clean up GtkInspectorGeneral
Drop the Private struct.
2020-07-18 00:31:04 -04:00
Matthias Clasen
80e29a3627 inspector: Clean up GtkInspectorMiscInfo
Drop the Private struct.
2020-07-18 00:25:46 -04:00
Matthias Clasen
26163a4f30 inspector: Clean up GtkInspectorVisual
Drop the Private struct, and do all cleanup in dispose.
2020-07-18 00:17:42 -04:00
Matthias Clasen
dbd88fc210 inspector: Clean up GtkInspectorActions
Drop the Private struct, dispose properly,
and don't derive from GtkBox.
2020-07-17 23:59:49 -04:00
Matthias Clasen
2de31e4cac inspector: Clean up GtkInspectorActionEditor
Drop the Private struct, dispose properly,
and don't derive from GtkBox.
2020-07-17 23:36:05 -04:00
Matthias Clasen
1bff328895 inspector: Clean up GtkInspectorLogs
Drop the Private struct, dispose properly,
and don't derive from GtkBox.
2020-07-17 23:24:14 -04:00
Matthias Clasen
facf78a5b6 inspector: Allow disposing the inspector
We were hiding the inspector when the window
is closed, but that has the side-effect of
keeping references to application windows,
so we would keep them artificially alive,
which can have side-effects.

So, make the inspector go away when closed.
2020-07-17 23:15:42 -04:00
Matthias Clasen
6b19fcd859 inspector: Properly dispose GtkInspectorWindow 2020-07-17 23:15:25 -04:00
Matthias Clasen
ca784e3e1a inspector: Properly dispose GtkInspectorShortcuts 2020-07-17 23:13:29 -04:00
Matthias Clasen
314c8558d7 inspector: Properly dispose GtkInspectorListData 2020-07-17 23:13:07 -04:00
Matthias Clasen
af30a7fe06 inspector: Dispose tree data properly
Another place where we were leaking children.
2020-07-17 22:54:19 -04:00
Matthias Clasen
9ffd7d1970 inspector: Dispose the recorder properly
We were leaking children here.
2020-07-17 22:54:10 -04:00
Matthias Clasen
cb906c80eb inspector: Drop the recorder Private struct 2020-07-17 22:37:24 -04:00
Matthias Clasen
96ce0eb600 Merge branch 'matthiasc/for-master' into 'master'
gtk-demo: Don't use GtkColorSwatch

See merge request GNOME/gtk!2262
2020-07-18 01:17:43 +00:00
Matthias Clasen
0e476c1f28 gtk-demo: Don't use GtkColorSwatch
Making our own is 80 lines of code, so just do it.
2020-07-17 20:44:06 -04:00
Matthias Clasen
f2924988db Merge branch 'ebassi/for-master' into 'master'
Fix typo in the GtkStrinFilter constructor declaration

See merge request GNOME/gtk!2261
2020-07-17 13:18:59 +00:00
Emmanuele Bassi
671435e07f Fix typo in the GtkStrinFilter constructor declaration 2020-07-17 14:16:46 +01:00
Emmanuele Bassi
b17cfb9b65 Merge branch 'ebassi/for-master' into 'master'
Fix typo in the gtk-doc stanza for gtk_string_filter_new()

See merge request GNOME/gtk!2259
2020-07-17 13:09:55 +00:00
Emmanuele Bassi
0385f1aaf4 Fix typo in the gtk-doc stanza for gtk_string_filter_new() 2020-07-17 12:03:17 +01:00
Matthias Clasen
8611faf338 Merge branch 'wip/baedert/for-master' into 'master'
Wip/baedert/for master

Closes #2776

See merge request GNOME/gtk!2258
2020-07-17 10:56:16 +00:00
Timm Bäder
7e19911d3f testwidgettransforms: Fix GtkBox casts 2020-07-17 07:14:50 +02:00
Timm Bäder
c1f5153f6d boxlayout: Remove unnecessary checks
The pointers passed to GtkLayoutManager::measure() are never NULL. The
ones passed to gtk_layout_manager_measure() can be, however.
2020-07-17 06:31:57 +02:00
Timm Bäder
2bd87ce771 boxlayout: Remove unused include 2020-07-17 06:27:50 +02:00
Timm Bäder
de0547ede7 migration guide: Remove a stray html tag 2020-07-17 06:27:23 +02:00
Timm Bäder
14589c2a59 widget: Save a gtk_css_node_get_style call 2020-07-17 05:49:12 +02:00
Timm Bäder
f678b3804d widget: Remove useless if statement
filter_value is never NULL anyway.
2020-07-17 05:49:12 +02:00
Timm Bäder
720c298786 snapshot: Use collect_default directoy in push_debug()
Instead of going through collect_debug and then doing a collect_default
anyway if the message is NULL.
2020-07-17 05:49:12 +02:00
Timm Bäder
f721d2de15 debug: Remove resize highlighting
This has been broken ever since the debug highlighting moved to
inspector overlays.
2020-07-17 05:49:12 +02:00
Timm Bäder
11f07cb5ad GdkRGBA: Fix typo in documentation 2020-07-17 05:49:11 +02:00
Timm Bäder
37d7ab88dc gl renderer: Avoid 9-slicing things that can't be
The outline needs to be large enough so changing the size of the outline
does not affect the resulting blurred texture.

Fixes #2776
2020-07-17 05:49:11 +02:00
Timm Bäder
6cde64072d gl renderer: Remove outdated comment 2020-07-17 05:49:11 +02:00
Timm Bäder
6a60b0f591 gl renderer: Try to intersect rounded clips more often 2020-07-17 05:49:11 +02:00
Timm Bäder
339d9f05e4 gl renderer: Remove unused flag 2020-07-17 05:49:11 +02:00
Timm Bäder
4e4207457f adwaita: Remove header bar border radius
We get this from the window node these days.
2020-07-17 05:49:11 +02:00
Timm Bäder
46bb3e3046 icontheme: Indentation 2020-07-17 05:49:11 +02:00
Timm Bäder
34008e6aab gl renderer: Ignore rounded clip that only increase the clip
This fixes the widget factory rendering too much.

In the widget-factory, we generally have a pretty small update area (two
spinners and a progressbar). We take the extents of that as a update
area and inital clip.

However, the first clip node we see is from the toplevel window, which
essentially increases the clip again to almost the entire window.

Fix that by ignoring such cases.
2020-07-17 05:49:11 +02:00
Timm Bäder
d6b3ac850d testsuite: Fix test case indentation 2020-07-17 05:49:11 +02:00
Matthias Clasen
9742200ff6 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2257
2020-07-17 03:20:20 +00:00
Matthias Clasen
ec10857b84 docs: Move columns below columnview 2020-07-16 22:14:39 -04:00
Matthias Clasen
353d4d161c Cosmetic docs change 2020-07-16 22:08:15 -04:00
Matthias Clasen
bcd650f169 docs: Revise the filter docs a bit 2020-07-16 21:48:08 -04:00
Matthias Clasen
72d66dfcdd docs: Revise sorter docs a bit 2020-07-16 21:45:11 -04:00
Matthias Clasen
5e97df5058 bitset: try again 2020-07-16 21:44:31 -04:00
Matthias Clasen
059d131e2b Merge branch 'wip/chergert/subclass-treeview' into 'master'
treeview: allow subclassing GtkTreeView

Closes #2936

See merge request GNOME/gtk!2256
2020-07-17 01:05:07 +00:00
Matthias Clasen
8f7c207c7c docs: Add more GtkExpression
Make GtkExpression show up in the object
hierarchy, and add the param spec and GValue
support to the docs.
2020-07-16 21:02:33 -04:00
Matthias Clasen
b9e8935037 docs: Document GtkBitsetIter 2020-07-16 20:28:21 -04:00
Matthias Clasen
5f33f4ae8e docs: Add an example
Add a small example for setting up columnview sorting.
2020-07-16 20:21:21 -04:00
Matthias Clasen
adf0e8b1e6 docs: Fix examples
The formatting for examples in the GtkExpression
long description was messed up.
2020-07-16 20:21:21 -04:00
Christian Hergert
7500f9b255 treeview: allow subclassing GtkTreeView
Porting code from GTK 3 without the ability to subclass GtkTreeView
directly can cause an extreme amount of pain on application developers.
It can also complicate performance when it comes to dealing with
encapsulation as the outer widget would also encapsulate the GtkScrollable
implementation from GtkTreeView, typically through GtkViewport.

Fixes #2936
2020-07-16 17:06:15 -07:00
Matthias Clasen
a8d433dd26 docs: Link to GtkTreeRowReference
The list overview cross-reference table links
to all objects, except for this one.
2020-07-16 19:53:47 -04:00
Matthias Clasen
ecaf6fced0 docs: Add GtkTreeExpander
We want to link to it from various places, so it needs
to be present in the docs.
2020-07-16 19:53:47 -04:00
Matthias Clasen
31a7cac4a6 Merge branch 'matthiasc/arrays' into 'master'
Matthiasc/arrays

See merge request GNOME/gtk!2253
2020-07-16 23:31:31 +00:00
Matthias Clasen
5eec736b07 multifilter: Use GdkArray for the filters 2020-07-16 18:44:25 -04:00
Matthias Clasen
cf4a8e2152 multisorter: Use GdkArray for the sorters 2020-07-16 18:44:25 -04:00
Matthias Clasen
31bb969cce Merge branch 'matthiasc/for-master' into 'master'
gtk-demo: Use better api

See merge request GNOME/gtk!2254
2020-07-16 21:03:21 +00:00
Matthias Clasen
f4a7c7f6bf gtk-demo: Use better api
We have a getter for the model, lets use it.
2020-07-16 16:26:41 -04:00
Benjamin Otte
495069c868 Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master

See merge request GNOME/gtk!2251
2020-07-16 19:43:45 +00:00
Matthias Clasen
dfe470475b Merge branch 'missing-exports' into 'master'
Add missing exports for GtkColumnView methods.

See merge request GNOME/gtk!2252
2020-07-16 18:52:22 +00:00
Benjamin Otte
de56e892aa listitemmanager: Do a better job on double items
Previously, we would unparent the existing item that we were about
to reuse, and not the duplicate one.

Change that.
2020-07-16 20:43:16 +02:00
Benjamin Otte
e518c1f2f3 stringfilter: Make the constructor take an expression
An expression is critically important for a string filter and people
should be made aware of it when constructing the filter.
2020-07-16 20:43:16 +02:00
Benjamin Otte
c5ea59d7d1 gtk-demo: Don't make demos modal
That way, demo windows can be maximized and multiple demos can run at
once.

It's especially useful when using --run because the main window is
invisible then.
2020-07-16 20:43:16 +02:00
Benjamin Otte
22eccbdbb6 testsuite: Don't be too exhaustive
The test was taking over 60s on CI, that's a but much.
2020-07-16 20:43:16 +02:00
Benjamin Otte
58e85c85e4 testsuite: Add a case with escaped Latin-1 code
This came up in recent g_uri_escape() discussions.
2020-07-16 20:43:11 +02:00
Matthias Clasen
6b89148487 Merge branch 'wip/otte/vector' into 'master'
Arrays

See merge request GNOME/gtk!2197
2020-07-16 18:05:43 +00:00
Matthias Clasen
ddb9e428ec Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2250
2020-07-16 17:39:16 +00:00
Andreas Persson
b7fa353db2 Add missing exports for GtkColumnView methods.
GDK_AVAILABLE_IN_ALL was missing for one method in GtkColumnView and one
in GtkColumnViewColumn.
2020-07-16 18:58:41 +02:00
Matthias Clasen
87b5eadb7c treesorter tests: Add a comment
This looks like a leak, but isn't one.
Add a comment to that effect.
2020-07-16 12:14:28 -04:00
Benjamin Otte
60a09e59e8 stringlist: Convert to array
Stringlists are usually built and then never modified, and accessing
items through an array is faster.
2020-07-16 18:09:58 +02:00
Benjamin Otte
6f8e9bf3a9 snapshot: Use GdkArray for the state stack 2020-07-16 18:09:58 +02:00
Benjamin Otte
90b7b84337 array: Add a bunch of new features
* GDK_ARRAY_BY_VALUE
  #define this to get GArray-like behavior
* gdk_array_splice (v, 0, 0, NULL, 25)
  Adding items but passing NULL as the items will zero() them.
* gdk_array_set_size()
  A nicer way to call gdk_array_splice()
* constify getters
2020-07-16 18:09:58 +02:00
Benjamin Otte
088b5fc57f icontheme: Use GdkArray 2020-07-16 18:09:58 +02:00
Benjamin Otte
a4cd974912 array: Add null-termination 2020-07-16 18:09:57 +02:00
Benjamin Otte
65359dcc59 snapshot: Port node list to GdkArray 2020-07-16 18:09:57 +02:00
Benjamin Otte
ac8b398c50 snapshot: Move structs into .c file
They aren't used anywhere else.
2020-07-16 18:09:57 +02:00
Benjamin Otte
aac2417893 Remove preallocated array code
Now with GdkArray, we can use that one instead.
2020-07-16 18:09:57 +02:00
Benjamin Otte
ad8892df10 main: Use a GdkArray 2020-07-16 18:09:57 +02:00
Benjamin Otte
edc7977c4e cssselector: Use GdkArray 2020-07-16 18:09:57 +02:00
Benjamin Otte
8bf8ac5076 Add GdkArray
This is a scary idea where you #define a bunch of preprocessor values
and then #include "gdkarrayimpl.c" and end up with a dynamic array for
that data type.

See https://en.wikipedia.org/wiki/X_Macro for what's going on.

What are the advantages over using GArray or GPtrArray?

 * It's typesafe
   Because it works like C++ templates, we can use the actual type of
   the object instead of having to use gpointer.

 * It's one less indirection
   instead of 2 indirections via self->array->data, this array is
   embedded, so self->array is the actual data, and just one indirection
   away. This is pretty irrelevant in general, but can be very noticable
   in tight loops.

 * It's all inline
   Because the whole API is defined as static inline functions, the
   compiler has full access to everything and can (and does) optimize
   out unnecessary calls, thereby speeding up some operations quite
   significantly, when full optimizations are enabled.

 * It has more features
   In particular preallocation allows for avoiding malloc() calls, which
   can again speed up tight loops a lot.
   But there's also splice(), which is very useful when used with
   listmodels.
2020-07-16 18:09:57 +02:00
Benjamin Otte
c36cbd5140 sortlistmodel: Remove forgotten G_PARAM_CONSTRUCT_ONLY 2020-07-16 17:33:29 +02:00
Matthias Clasen
ee96bc7185 multiselection tests: Plug a leak
g_list_model_get_item is transfer full.
2020-07-16 08:54:36 -04:00
Matthias Clasen
f94f325636 filterlistmodel tests: Plug a leak
g_list_model_get_item is transfer full.
2020-07-16 08:54:36 -04:00
Matthias Clasen
6c1217dd93 filter tests: Plug a leak
g_list_model_get_item is transfer full.
2020-07-16 08:54:36 -04:00
Matthias Clasen
edb792503b printunixdialog: Plug a leak
g_list_model_get_item is transfer full.
2020-07-16 08:54:36 -04:00
Matthias Clasen
3a43859286 Cosmetics 2020-07-16 08:54:36 -04:00
Matthias Clasen
c55dd104d4 placessidebar: Plug a leak
g_list_model_get_item is transfer full.
2020-07-16 08:54:36 -04:00
Matthias Clasen
497d137fb8 filechoosernativewin32: Plug a leak
g_list_model_get_item is transfer full.
2020-07-16 08:54:36 -04:00
Matthias Clasen
df01c5c7a4 columnlistitemfactory: Plug a leak
g_list_model_get_item is transfer full.
2020-07-16 08:54:36 -04:00
Matthias Clasen
2d1135fba6 applicationaccels: Plug a leak
g_list_model_get_item is transfer full.
2020-07-16 08:54:36 -04:00
Matthias Clasen
f54ed6f7dc columviewsorter: Add an assertion 2020-07-16 08:54:36 -04:00
Matthias Clasen
b7efd896b6 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2249
2020-07-16 12:52:46 +00:00
Matthias Clasen
46eb51bc30 inspector: Avoid losing a reference
This was copying the example in the treelistrowsorter
docs that the previous commit fixed, so we apply
the same fix here.
2020-07-16 07:14:01 -04:00
Matthias Clasen
500dbaabc3 treelistrowsorter: Fix a faulty example
gtk_tree_list_row_sorter_new() consumes the
sorter, so we can't pass gtk_column_view_get_sorter(),
since that is transfer none.
2020-07-16 07:14:01 -04:00
Matthias Clasen
594ec3d822 inspector: Don't derive from GtkBox
We don't do that anymore. A bin layout
is sufficient here.
2020-07-16 07:14:01 -04:00
Matthias Clasen
f280508209 inspector: Drop a Private struct
These are really not needed in the inspector.
2020-07-16 07:14:01 -04:00
Matthias Clasen
480b88c776 inspector: Drop an unused field 2020-07-16 07:14:01 -04:00
Efstathios Iosifidis
a4e63905b1 Update Greek translation 2020-07-15 18:12:26 +00:00
Matthias Clasen
5666127dbc Merge branch 'matthiasc/for-master' into 'master'
inspector: Use substring matching in the property list

See merge request GNOME/gtk!2247
2020-07-15 16:52:05 +00:00
Matthias Clasen
c1c110ba65 inspector: Use substring matching in the property list
This is convenient for things like "set both hexpand and
vexpand", since you can then search for "expand"
2020-07-15 11:29:06 -04:00
Florentina Mușat
eb2a839892 Update Romanian translation 2020-07-15 08:58:58 +00:00
Matthias Clasen
1c537a6d2e Merge branch 'wip/jimmac/file-dialog-sidebar-color' into 'master'
Adwaita: sidebar color for file picker

See merge request GNOME/gtk!2242
2020-07-15 01:41:35 +00:00
Matthias Clasen
c12261a6ec Merge branch 'wip/fix-picom-crasher' into 'master'
x11: Don't set up frame sync fence on unsupported compositors

Closes #2927

See merge request GNOME/gtk!2245
2020-07-15 01:40:49 +00:00
Matthias Clasen
5af7d6bff3 Merge branch 'idle-inhibit' into 'master'
Add support for idle inhibition on Wayland

Closes #2202

See merge request GNOME/gtk!2226
2020-07-15 01:38:55 +00:00
Matthias Clasen
de0f4b0f5b Merge branch 'shortcuts-section-reflow-fix' into 'master'
Fix shortcuts section reflow

Closes #2928

See merge request GNOME/gtk!2246
2020-07-15 01:38:38 +00:00
Emmanuel Gil Peyrot
966ab1152d gtk/wayland: Add support for idle inhibition in GtkApplication
This feature was previously only supported on DBus compositors, such as
Mutter, this adds support for other compositors such as all of those
based on wlroots.

This implementation prefers the idle-inhibit Wayland protocol to the
DBus version if it is available, since the inhibitor is per-surface
instead of global it allows a finer control over which displays get
dimmed for instance.  For every case not supported by this protocol, a
fallback to the DBus version is used.

It can’t do anything if the GtkWindow isn’t passed, which might warrant
some documentation change to encourage users to not use NULL for this
argument.

This has been tested on Sway.

Fixes #2202.
2020-07-14 21:47:22 +02:00
Emmanuel Gil Peyrot
74a4432688 gdk/wayland: Add an API to inhibit and uninhibit idle
This uses the idle-inhibit protocol from wayland-protocols, to attach an
inhibitor to the GdkSurface.  The inhibit function can be called as many
times as the user wants, but the uninhibit function MUST be called as
many times to unset the idle inhibition.

This has been tested on Sway.
2020-07-14 21:47:22 +02:00
Matthias Clasen
115d0cdc07 Fix shortcuts section reflow
When this code was ported from gtk_container_get_children
to the dom api, we inadvertendly inverted the order of the
list in one place. With the dom api, we can just avoid
reversing lists altogether, so do that.

Fixes: #2928
2020-07-14 14:48:32 -04:00
Ray Strode
d0ec616fba x11: Don't set up frame sync fence on unsupported compositors
Not all compositors support _NET_WM_FRAME_DRAWN.  In cases
where the compositor doesn't support _NET_WM_FRAME_DRAWN we don't
need to do all the fancy damage tracking and fence watching.

Furthermore, if the compositor doesn't support _NET_WM_FRAME_DRAWN,
it's possible that one frame will start before the previous frame has
made it through the pipeline, leading to a blown assertion.

This commit side-steps the unnecessary code and associated assertion
when _NET_WM_FRAME_DRAWN isn't supported.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2927
2020-07-14 14:33:12 -04:00
Florentina Mușat
38cce2bb18 Update Romanian translation 2020-07-14 14:52:19 +00:00
Matthias Clasen
9cb7002b98 Merge branch 'wip/jimmac/large-title-letterspacing' into 'master'
Adwaita: revert letter-spacing for large-title

Closes #2932

See merge request GNOME/gtk!2243
2020-07-14 11:47:36 +00:00
Yuri Chornoivan
eb9c91c0a9 Update Ukrainian translation 2020-07-14 10:33:34 +00:00
Jakub Steiner
be07153efa Adwaita: revert letter-spacing for large-title
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/2932
2020-07-14 12:24:25 +02:00
Jakub Steiner
627ec82e60 Adwaita: sidebar color for file picker
- use menu like hovers and desaturated selected_bg_color

Partially addresses https://gitlab.gnome.org/GNOME/gtk/-/issues/1586
2020-07-14 11:37:29 +02:00
Matthias Clasen
ccc34ca06c Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2241
2020-07-14 02:43:25 +00:00
Matthias Clasen
2b5dd0082d inspector: Show some information about expressions
This is not too useful, but better than nothing.
2020-07-13 20:49:56 -04:00
Matthias Clasen
7b36b339aa expression: Add some introspection
Add a few apis to peek inside expressions, mainly
for the benefit of GtkInspector and similar uses.
2020-07-13 20:19:07 -04:00
Matthias Clasen
b7eb663b82 gtk-demo: Make the words demo expand
We want to fill the window here.
2020-07-13 17:54:27 -04:00
Matthias Clasen
1b28353be5 inspector: Ellipsize in the object tree
We don't want a long label to blow up the width
of the inspector window.
2020-07-13 17:32:52 -04:00
Matthias Clasen
a07c030d02 inspector: Fix up input enum names
We've recently added and removed a few values in these
enumerations. Keep the names in sync, so we don't show
nonsense.
2020-07-13 17:13:43 -04:00
Matthias Clasen
339cccdf53 NEWS: Updates and fixes 2020-07-13 17:10:22 -04:00
Matthias Clasen
577126e99c Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2240
2020-07-13 20:48:08 +00:00
Matthias Clasen
125ea5ee4a treeexpander: Be focusable
We need to be focusable so that we can take focus
if the child doesn't.
2020-07-13 15:06:35 -04:00
Matthias Clasen
3c5afc06d1 searchbar: Set a focus vfunc
We don't want to take focus ourselves here.
2020-07-13 15:06:08 -04:00
Matthias Clasen
f87c15f4f9 Merge branch 'wip/jimmac/file-dialog-sidebar-color' into 'master'
Adwaita: sidebar color for file picker

Closes #1586

See merge request GNOME/gtk!2238
2020-07-13 16:31:07 +00:00
Jakub Steiner
fe5c0e2fe3 Adwaita: sidebar color for file picker
- avoid using the selected blue for the sidebar

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/1586
2020-07-13 17:03:55 +02:00
Matthias Clasen
c8421cfd82 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2236
2020-07-13 14:38:03 +00:00
Matthias Clasen
fbf99b8d65 Merge branch 'wip/carlosg/windowhandle-gesture-state' into 'master'
gtkwindowhandle: Only claim gesture on action

See merge request GNOME/gtk!2237
2020-07-13 14:32:06 +00:00
Yuri Chornoivan
57312c9b79 Update Ukrainian translation 2020-07-13 14:18:40 +00:00
Carlos Garnacho
35d2539ef8 gtkwindowhandle: Only claim gesture on action
The press gesture does not need to set claimed state just for n-press
tracking, it will however reset all other click gestures on each press
if the event gets propagated all the way up.

Fixes tracking of multi-press in gestures in widgets that are children
of the window handle. E.g. the headerbar listview in the "File browser"
gtk4-demo demo.
2020-07-13 15:48:12 +02:00
Matthias Clasen
08a4f4552c Give the inspector a devel header too
Lets clearly communicate that we're unstable.
2020-07-13 08:28:02 -04:00
Matthias Clasen
6502d3669f print-editor: Set the devel style class
Lets clearly communicate that we're unstable.
2020-07-13 08:27:51 -04:00
Matthias Clasen
53831e67a7 Integrate the new icons
Install and use the node-editor and print-editor icons.
2020-07-13 07:30:46 -04:00
Jakub Steiner
e742fc1206 demos: icons for Print and Node Editors
- probably needs meson build hooks
2020-07-13 07:30:46 -04:00
Piotr Drąg
4ef5ee23e6 Update POTFILES.in 2020-07-13 13:17:37 +02:00
Matthias Clasen
4a8330fda0 Merge branch 'matthiasc/for-master' into 'master'
gtk-demo: Work harder to filter the tree

See merge request GNOME/gtk!2234
2020-07-12 23:16:35 +00:00
Matthias Clasen
b4096cee64 gtk-demo: Work harder to filter the tree
Arrange for an item to be visible if it either
matches the filter or has children that do.
2020-07-12 18:26:56 -04:00
Matthias Clasen
032302c358 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2233
2020-07-12 21:23:07 +00:00
Matthias Clasen
a888e1cb65 demo: Clear filter when search is stopped
When the search entry disappears on Escape,
reset the search string to "", so we don't
end up with a filtered list and no obvious
way to remove the filtering.
2020-07-12 16:47:51 -04:00
Matthias Clasen
c80b33b2ad gtk-demo: Make the search bar appear for typing
Having the search bar present from the start is
a bit jarring. Make it appear when called for.
2020-07-12 16:26:17 -04:00
Matthias Clasen
f32239df1f searchbar: Add a key-capture-widget property
This is handy to set up this relationship in ui files,
and also makes it accessible in the inspector.
2020-07-12 16:25:48 -04:00
Matthias Clasen
22c1b541df Merge branch 'wip/sadiq/demo-filter' into 'master'
demo: Add a search filter

See merge request GNOME/gtk!2232
2020-07-12 19:04:00 +00:00
Matthias Clasen
78a59c95fe Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2231
2020-07-12 16:59:10 +00:00
Mohammed Sadiq
7583d48266 demo: Add a search filter 2020-07-12 22:19:40 +05:30
Matthias Clasen
f1188aaeac Fix gtk_file_chooser_error_stack_set_custom_error
This never worked, due to a typo.
2020-07-12 12:15:08 -04:00
Matthias Clasen
4dac5c222f Drop GtkFileChooserEmbed
This private interface is no longer used.
2020-07-12 12:15:08 -04:00
Matthias Clasen
0145809a94 filechooserdialog: Stop using ::response-requested
Replace the ::response-requested signal by an action.
2020-07-12 12:15:08 -04:00
Matthias Clasen
2e6b8810c0 filechooserdialog: Stop using the embed interface
Just call private GtkFileChooserWidget api. There
is no real justification for diverting this through
an extra interface.
2020-07-12 10:59:49 -04:00
Matthias Clasen
d8abcdb5a1 Remove unused includes
Only GtkFileChooserWidget and GtkFileChooserDialog
use the GtkFileChooserEmbed interface.
2020-07-12 10:59:31 -04:00
Matthias Clasen
65ecfa20dd filechooserwidget: Use dropdown api better
We now have GtkStringList, so we can implement
the choice api a little cleaner with it.
2020-07-12 10:58:33 -04:00
Matthias Clasen
aa5ab02166 filechooserwidget: Remove homegrown profiling
We have sysprof support now, so we no longer have
to use this homegrown profiler.
2020-07-12 10:58:33 -04:00
Matthias Clasen
7ddbbb50ff Merge branch 'drop-file-system' into 'master'
Drop file system

See merge request GNOME/gtk!2229
2020-07-12 14:41:01 +00:00
Matthias Clasen
f2eb036119 Merge branch 'matthiasc/for-master' into 'master'
gtk-demo: Make style apply in the file browser

See merge request GNOME/gtk!2230
2020-07-12 13:58:30 +00:00
Matthias Clasen
8a8b96bf4b Drop GtkFileSystem
It is no longer used.
2020-07-12 09:49:31 -04:00
Matthias Clasen
bdcda2d8f0 filechooserwidget: Stop using GtkFileSystem
Just use gio directly.
2020-07-12 09:49:31 -04:00
Matthias Clasen
ef3f997d55 filechooser: Drop get_file_system from the interface
This is no longer used.
2020-07-12 09:49:31 -04:00
Matthias Clasen
b41d380230 filechooserbutton: Stop using GtkFileSystem
Just use gio directly.
2020-07-12 09:49:31 -04:00
Matthias Clasen
0210850e86 Reduce includes of gtkfilesystem.h
Move a few non-filesystem helpers to gtkfileutils.h,
and drop the include in all the places where it isn't needed.
2020-07-12 09:12:43 -04:00
Matthias Clasen
053223bf65 pathbar: Stop using GtkFileSystem
This is just a thin wrapper around some gio functionality
these days, and we want to get rid of it.
2020-07-12 09:12:43 -04:00
Matthias Clasen
746b84cc0f gtk-demo: Make style apply in the file browser
Commit 5afe6f7825 claims to make this demo
'look good', but it failed to actually make its
css apply. Now it really looks good.
2020-07-12 08:11:42 -04:00
Matthias Clasen
f1ad883e00 pathbar: Drop the Private struct 2020-07-11 17:23:55 -04:00
Matthias Clasen
191e0e8d5e Merge branch 'matthiasc/for-master' into 'master'
Fix the build with clang

See merge request GNOME/gtk!2225
2020-07-10 19:29:18 +00:00
Matthias Clasen
55217e2181 Fix the build with clang
clang doesn't allow G_GNUC_FALLBACK in dead code.
Seems silly, but what can we do.
2020-07-10 13:21:23 -04:00
Emmanuele Bassi
7c8cd23c5f Merge branch 'ebassi/ci-timeout' into 'master'
Ebassi/ci timeout

See merge request GNOME/gtk!2223
2020-07-10 17:01:56 +00:00
Matthias Clasen
6aafb81702 Merge branch 'ci-tweaks' into 'master'
ci: Use lsan again

See merge request GNOME/gtk!2224
2020-07-10 16:13:48 +00:00
Emmanuele Bassi
0578422612 build: Restructure the tests to use dictionaries
Instead of an array of arrays, let's use an array of dictionaries; it's
easier to add optional keys without requiring to remember where to put
empty arrays.
2020-07-10 16:32:15 +01:00
Emmanuele Bassi
ad04da84c9 Add the filtermodel-exhaustive test to the slow suite
This increases the default timeout.
2020-07-10 16:16:15 +01:00
Emmanuele Bassi
333b013f7f Increase the default timeout for slow tests
If a test is part of the 'slow' test suite, we should increment the
default timeout to compensate.
2020-07-10 16:13:37 +01:00
Matthias Clasen
b3dc517565 ci: Use lsan again
Turning it off didn't fix the crashes; and we allow
the asan build to fail anyway now. And the leak reports
are useful whenever it doesn't crash.
2020-07-10 11:11:42 -04:00
Emmanuele Bassi
70e4dabe89 ci: Increase the timeout multiplier
We do have some slow tests.
2020-07-10 16:08:59 +01:00
Emmanuele Bassi
d3443d6f2a ci: Use the timeout multiplier from the environment
When running our test suite on our CI infrastructure.
2020-07-10 16:08:14 +01:00
Matthias Clasen
a508f68044 Merge branch 'asan-ci' into 'master'
Asan ci

See merge request GNOME/gtk!2214
2020-07-10 13:04:34 +00:00
Matthias Clasen
f191b64bbc Disable lsan for now
The leak sanitizer causes on average 3-4 tests
to segfault during a testsuite run. Disable it
for now to see if we can get a successful
testsuite run with asan alone.
2020-07-10 07:32:48 -04:00
Matthias Clasen
e9efe77839 Merge branch 'wip/Jehan/gio-querymodules-pkg-config-master' into 'master'
build-aux: search various Glib/GIO utilities in .pc file.

See merge request GNOME/gtk!2129
2020-07-09 23:53:25 +00:00
Matthias Clasen
d98c0d32f2 ci: Add a build with asan
Run our testsuite under asan. We do this in a
separate build, since we need to turn off
introspection to make the build succeed.

As Michael Catanzaro pointed out, this requires a
privileged runner in order to use kernel apis.
2020-07-09 19:43:06 -04:00
Matthias Clasen
dfa2dcceb8 Merge branch 'matthiasc/for-master' into 'master'
x11: Plug a memory leak

See merge request GNOME/gtk!2222
2020-07-09 23:06:37 +00:00
Matthias Clasen
d441e7106b x11: Plug a memory leak
Don't leak atoms when we're storing the clipboard.
2020-07-09 18:19:32 -04:00
Benjamin Otte
4cd92f979c Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master

See merge request GNOME/gtk!2221
2020-07-09 21:34:02 +00:00
Benjamin Otte
d1a068e5b1 sorter: Remove a return_if_fail()
It's too expsensive.
2020-07-09 22:29:36 +02:00
Benjamin Otte
4d90846182 testsuite: Be more exhaustive
Create larger source models in tests, so that we hit the incremental
batch size more often and have a higher chance to expose bugs there.
2020-07-09 22:29:36 +02:00
Benjamin Otte
986f721938 filterlistmodel: Don't filter out every 513th element
Incremental filtering would skip every 513th element due to an
off-by-one error.

Test included
2020-07-09 22:29:36 +02:00
Matthias Clasen
7903246355 Ignore more leaks in asan
These showed up in ci. The atk-bridge will
be gone before too long anyway. Since we
may not have debug symbols in ci, just at
the so's.
2020-07-09 16:18:07 -04:00
Matthias Clasen
0252ae2be3 Merge branch 'wip/carlosg/range-autoscroll' into 'master'
gtkrange: group gestures the right way around

See merge request GNOME/gtk!2220
2020-07-09 20:05:07 +00:00
Matthias Clasen
fa90e42a38 ci: Set LSAN_OPTIONS for tests
When running the testsuite with the address sanitizer,
many of our dependencies cause it to report cause it
to report memory leaks, causing tests to fail.
Therefore, point the leak sanitizer at a list of
suppressions. The list is kept in the lsan.supp
file in git.
2020-07-09 15:07:50 -04:00
Matthias Clasen
2d36109565 ci: Use the fedora:v20 image
This image includes libasan and libubsan.
2020-07-09 15:07:50 -04:00
Matthias Clasen
de8258171a ci: Mention image layering in the README 2020-07-09 15:07:50 -04:00
Matthias Clasen
2ed6224778 ci: Add libasan and libubsan to the image
Add libasan and libubsan to fedora-base:v20,
and build fedora:20 on top of it.

This is so we can build and run the tests with
the address and undefined behavior sanitizers.
2020-07-09 15:07:50 -04:00
Carlos Garnacho
e1a0171094 gtkrange: group gestures the right way around
The gtk_gesture_group() call is not a commutative operation, it
takes two gestures, maybe detaches the first one from its current
group, and adds it to the same group than the second gesture.

With the flipped argument order here, GtkRange was actually detaching
the same gesture in order to group it with a second one two times, so
the desired effect to group all 3 gestures was not achieved.

Fixes autoscroll as the drag gesture is now actually grouped with the
click one, so drag offsets can be accessed from the autoscroll
timeout.
2020-07-09 20:49:25 +02:00
Matthias Clasen
395521f3d3 x11: Plug a memory leak
Don't leak atoms when we're storing the clipboard.
2020-07-09 13:52:53 -04:00
Matthias Clasen
8c95a84ea4 Merge branch 'matthiasc/for-master' into 'master'
css: Plug a memory leak

Closes #2921

See merge request GNOME/gtk!2219
2020-07-09 17:19:57 +00:00
Matthias Clasen
75db19c789 css: Plug a memory leak
When a rule has no styles, we don't add it
to our ruleset. Since we are not adopting
the selectors in this case, we must free them.

Fixes: #2921
2020-07-09 12:14:18 -04:00
Matthias Clasen
f00d2b30bb Merge branch 'wip/carlosg/scrollbar-fixes' into 'master'
Scrollbar fixes

Closes #2879

See merge request GNOME/gtk!2216
2020-07-09 15:56:13 +00:00
Carlos Garnacho
c0c5ce2f9b gdk/x11: Ignore regular crossing events while in implicit grabs
If we create an implicit grab on a surface, leave the surface, and
release the button, we would get 2 XI_Leave events, one with mode
XINotifyNormal when the pointer leaves the surface, and another with
mode XINotifyUngrab when the button is released.

Meanwhile, the upper layers rely on crossing events being paired,
and particularly in no crossing event being sent until the implicit
grab is dismissed (either by releasing it, or via more pervasive
grabs).

Ignoring the set of XINotifyNormal events while an implicit grab
is active adapts the X11 backend to this behavior. If the grab were
released or taken away by another grab, a crossing event with one
of the other XINotify*Grab/XINotify*Ungrab will be generated.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2879
2020-07-09 17:02:07 +02:00
Matthias Clasen
ee9f9ae05e Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2212
2020-07-09 14:49:42 +00:00
Matthias Clasen
387649ded4 Merge branch 'ebassi/subprojects-depth' into 'master'
Use depth=1 for cloning sub-projects

See merge request GNOME/gtk!2215
2020-07-09 14:39:01 +00:00
Matthias Clasen
be12131d74 Merge branch 'file-chooser-api-cleanup-2' into 'master'
File chooser api cleanup 2

See merge request GNOME/gtk!2213
2020-07-09 14:31:14 +00:00
Carlos Garnacho
896ebdc9d7 gtkscrolledwindow: Look up correctly target in captured motion events
Check correctly that the captured motion events are emitted towards the
content or one of the scrollbars, in order to have it set the expected
"over" state depending on whether the drag begins from the scrolledwindow
content or one of the scrollbars.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2879
2020-07-09 16:10:55 +02:00
Matthias Clasen
bc58bd0b83 NEWS: Updates 2020-07-09 09:29:09 -04:00
Matthias Clasen
8d4c87876b Add a suppression file for asan
This can be used similar to valgrind suppressions:

LSAN_OPTIONS=suppressions=`pwd`/lsan.supp meson  tests -Cbuild
2020-07-09 09:29:09 -04:00
Matthias Clasen
cebc99ddc7 tests: Plug some more memory leaks
These showed up under asan.
2020-07-09 09:29:09 -04:00
Matthias Clasen
1b62203f18 cups: Plug a memory leak
This showed up under asan.
2020-07-09 09:29:09 -04:00
Matthias Clasen
06dd8c2cfd Merge branch 'wayland_surface_app_id_changing' into 'master'
add a way to change the application_id of a toplevel wayland GdkSurface

See merge request GNOME/gtk!2205
2020-07-09 13:28:07 +00:00
Emmanuele Bassi
5da21ca4dc Use depth=1 for cloning sub-projects
We don't really need the full history and branches when building
sub-projects.

This should shave some bandwidth and time in our CI pipeline as well.
2020-07-09 14:07:14 +01:00
Matthias Clasen
3e16ef33b0 Merge branch 'fix-levelbar-layout' into 'master'
levelbar: Chainup to parent buildable when handling custom tags

See merge request GNOME/gtk!2200
2020-07-09 11:42:33 +00:00
Matthias Clasen
2746a2d929 filechooser: Drop the ::selection-changed signal
This signal does not work on native file choosers,
and it exposes internals of the widget that should
not be public. And it is just not very interesting.
2020-07-09 02:06:31 -04:00
Matthias Clasen
e31bacf7be filechooser: Drop the ::current-folder-changed signal
This signal does not work on native file choosers,
and it exposes internals of the widget that should
not be public. And it is just not very interesting.
2020-07-09 01:48:33 -04:00
Matthias Clasen
911ae64931 filechoosernative: Update docs
Remove mention of things that are no longer
in the filechooser api.
2020-07-09 01:44:09 -04:00
Matthias Clasen
99a0b35705 filechooser: Drop the ::file-activated signal
This signal does not work on native file choosers,
and it exposes internals of the widget that should
not be public. And it is just not very interesting.
2020-07-09 01:40:08 -04:00
Matthias Clasen
89bf8af878 filechooser: Make get_files return a list model
Like the other list getters in this interface,
make gtk_file_chooser_get_files() return a
list model.
2020-07-09 01:29:20 -04:00
Matthias Clasen
f3744c991a Cosmetics 2020-07-09 01:02:21 -04:00
Matthias Clasen
dcee15c0f1 filechooser: Drop gtk_file_chooser_[un]select_file
Most use cases for these apis can be handled with
gtk_file_chooser_set_file and/or
gtk_file_chooser_set_current_folder.
2020-07-09 00:50:03 -04:00
Matthias Clasen
2321e9de05 filechooser: Drop gtk_file_chooser_[un]_select_all
For now, we just remove them as public api, they are
still used internally.
2020-07-09 00:50:03 -04:00
Matthias Clasen
73dcda460f tests: Stop using file chooser apis that are going away
gtk_file_chooser_[un]select_all are going away, stop
using them.
2020-07-09 00:50:03 -04:00
Matthias Clasen
0f8bc67a98 docs: Add gtk_file_chooser_get_shortcut_folders 2020-07-09 00:50:03 -04:00
Matthias Clasen
379d830123 Merge branch 'printing-portal-fix-master' into 'master'
Remember to call print_cb even if print operation is cancelled.

Closes #2917

See merge request GNOME/gtk!2211
2020-07-09 04:40:34 +00:00
Matthias Clasen
bc8bc68b80 Add a suppression file for asan
This can be used similar to valgrind suppressions:

LSAN_OPTIONS=suppressions=`pwd`/lsan.supp meson  tests -Cbuild
2020-07-09 00:33:35 -04:00
Matthias Clasen
8c4df51a14 tests: Plug some more memory leaks
These showed up under asan.
2020-07-09 00:33:14 -04:00
Matthias Clasen
06d67d2384 cups: Plug a memory leak
This showed up under asan.
2020-07-09 00:32:17 -04:00
Casey Jao
cc8bb5fc54 Remember to call print_cb even if print operation is cancelled.
Closes #2917.
2020-07-08 23:32:43 -04:00
Matthias Clasen
8fb1e33d0f Merge branch 'matthiasc/for-master' into 'master'
directorylist: Fix file monitoring implementation

See merge request GNOME/gtk!2209
2020-07-09 02:08:53 +00:00
Matthias Clasen
0dc946da63 testsuite: Assorted leak fixes
All found by asan.
2020-07-08 17:44:49 -04:00
Matthias Clasen
26a23d3e56 shortcuttrigger: Fix some leaks in error paths
Found while running the testsuite under asan.
2020-07-08 17:44:42 -04:00
Matthias Clasen
766f4bc8fe css: Fix some memory leaks in error paths
Found while running the testsuite under asan.
2020-07-08 17:44:36 -04:00
Matthias Clasen
3d008d5929 picture: Don't leak alternative-test
This leak showed up while running the testsuite
under asan.
2020-07-08 17:44:29 -04:00
Matthias Clasen
0546e26434 bookmarklist: Don't leak uris
This leak showed up in multiple places while
running the testsuite under asan.
2020-07-08 17:44:23 -04:00
Matthias Clasen
e6d8eedc00 testsuite: Fix a memory leak in the bitmask tests
This was showing up when running under asan.
2020-07-08 17:44:16 -04:00
Matthias Clasen
13b37b0ba4 gsk: Fix a transform leak
This was found by running our testsuite under asan.
2020-07-08 17:44:08 -04:00
Matthias Clasen
779c71b66d testsuite: Fix some memory leaks reported by asan 2020-07-08 15:09:13 -04:00
Matthias Clasen
8e73d007f5 testsuite: Fix an asan error
asan complains that some of the memorytexture tests
read past limits. Avoid that.
2020-07-08 15:09:08 -04:00
Matthias Clasen
e376d638fb directorylist: Fix file monitoring implementation
The while loops were never advancing the iterator.
Oops.
2020-07-08 15:08:53 -04:00
Yuri Chornoivan
52982a88aa Update Ukrainian translation 2020-07-08 18:28:01 +00:00
Baurzhan Muftakhidinov
422c1d9c0d Update Kazakh translation 2020-07-08 17:44:28 +00:00
Daniel Șerbănescu
ccc8ad8700 Update Romanian translation 2020-07-08 16:22:30 +00:00
Florentina Mușat
6b0eb970d8 Update Romanian translation 2020-07-08 16:17:12 +00:00
Florentina Mușat
775e35865c Update Romanian translation 2020-07-08 08:33:20 +00:00
Matthias Clasen
49ce680d53 Merge branch 'directorylist-monitor' into 'master'
directorylist: Add monitoring

See merge request GNOME/gtk!2207
2020-07-08 02:25:46 +00:00
Matthias Clasen
463f3d3a52 directorylist: Add monitoring
Add a GtkDirectoryList:monitored property, and
keep a file monitor if it is set to TRUE. To ensure
that the list reflects reality, we reload the directory
when monitoring is turned on after the fact. This means
that turning monitoring is expensive, while turning it
off is cheap, so we default to monitoring being on.
2020-07-07 21:21:41 -04:00
Jordi Mas
f6347f18b0 Fixes to Catalan translations 2020-07-07 20:24:24 +02:00
Yuri Chornoivan
2e959fe300 Update Ukrainian translation 2020-07-07 18:03:32 +00:00
Yuri Chornoivan
56f771ba29 Update Ukrainian translation 2020-07-07 17:55:52 +00:00
Baurzhan Muftakhidinov
32e96215b4 Update Kazakh translation 2020-07-07 17:21:22 +00:00
Matthias Clasen
86f800e11d Merge branch 'inspector-navigation' into 'master'
Inspector navigation

See merge request GNOME/gtk!2201
2020-07-07 17:04:51 +00:00
Matthias Clasen
4d371b2b16 inspector: Fix property list styling
We use dropdowns here now, so style them.

Also, avoid the swoosh when switching to the
property list, when everything shrinks.
2020-07-07 11:21:42 -04:00
Caolán McNamara
7e97c2513f gtk#767 add a way to change the application_id of a toplevel wayland GdkSurface
so LibreOffice can reuse toplevels and get the right task icons

references;
 https://gitlab.gnome.org/GNOME/gtk/-/issues/767
 https://lists.freedesktop.org/archives/wayland-devel/2019-July/040704.html
 e0d6ad1d5e
 https://bugs.documentfoundation.org/show_bug.cgi?id=125934
 https://bugzilla.redhat.com/show_bug.cgi?id=1334915
 https://bugreports.qt.io/browse/QTBUG-77182
2020-07-07 15:56:12 +01:00
Emmanuele Bassi
2bf5a150e6 Merge branch 'issue-2915' into 'master'
Issue 2915

Closes #2915

See merge request GNOME/gtk!2204
2020-07-07 11:48:07 +00:00
Emmanuele Bassi
18c87faaa5 Annotate string array
Fixes: #2915
2020-07-07 12:06:28 +01:00
Emmanuele Bassi
fdeda388bf Fix "not nullable" annotation 2020-07-07 12:03:44 +01:00
Stefano Facchini
ea2c27c640 levelbar: Chainup to parent buildable when handling custom tags
This is necessary to handle <layout> tags.
2020-07-07 09:34:00 +02:00
Matthias Clasen
dfc04a590d inspector: Reshuffle the sidebar
Move the sidebar in the object page below the
object header, for a more logical hierarchy.
2020-07-07 02:05:18 -04:00
Matthias Clasen
fe5b364675 inspector: Drop unused properties
The individual pages no longer need the object tree
to show object details, this works with the window
now.
2020-07-07 01:25:21 -04:00
Matthias Clasen
9b73c55559 Merge branch 'patch-1' into 'master'
Fix typo: Filer -> Filter

See merge request GNOME/gtk!2203
2020-07-07 05:08:19 +00:00
Matthias Clasen
0b38a0663d inspector: Add dom-like navigation controls
Maintain a stack of objects, and add ˂˅˄˃ buttons
that navigate this stack, as well as the widget
tree and list models.
2020-07-07 00:51:18 -04:00
Matthias Clasen
e5c0716293 inspector: Remove an unused field 2020-07-07 00:48:43 -04:00
Matthias Clasen
54a3293cad stack: Fix handling of GtkStackPage:visible
The stack wasn't updating its visible-child when
the stack pages visible property changes. This
showed up in the inspector, when showing the details
for a list model item.
2020-07-07 00:48:43 -04:00
Yuri Chornoivan
818287a7ce Update Ukrainian translation 2020-07-07 04:45:03 +00:00
Yuri Chornoivan
59119cd898 Fix typo: Filer -> Filter 2020-07-07 04:41:44 +00:00
Daniel Șerbănescu
817da34f7e Update Romanian translation 2020-07-06 20:41:16 +00:00
Daniel Șerbănescu
8fa44fc3e6 Update Romanian translation 2020-07-06 20:38:44 +00:00
Jordi Mas
c7e94151b2 Update Catalan translation 2020-07-06 22:35:10 +02:00
Matthias Clasen
729ba44297 Merge branch 'wip/otte/filterlistmodel' into 'master'
Improve GtkFilterListModel

See merge request GNOME/gtk!2199
2020-07-06 15:42:44 +00:00
Matthias Clasen
2a2a6879c5 Merge branch 'file-chooser-api-cleanups' into 'master'
File chooser api cleanups

See merge request GNOME/gtk!2195
2020-07-06 15:41:56 +00:00
Matthias Clasen
e7b773b031 filechooser: Add a readonly :shortcut-folders property
This makes the shortcut folders list accessible in the
the inspector.
2020-07-06 11:03:48 -04:00
Matthias Clasen
57a225681c filechooser: Add gtk_file_chooser_get_shortcuts
Replace gtk_file_chooser_list_shortcuts with a new
api that returns a list model.

Update all callers.
2020-07-06 11:03:48 -04:00
Matthias Clasen
ea07a92366 filechooser: Add a readonly :filters property
This makes the filters list accessible in the
the inspector.
2020-07-06 11:03:48 -04:00
Matthias Clasen
76290e8ddb filechooser: Add gtk_file_chooser_get_filters
Replace gtk_file_chooser_list_filters with a new
api that returns a list model.

Update all callers.
2020-07-06 10:36:35 -04:00
Jordi Mas
26d83b1ab7 Update Catalan translation 2020-07-06 09:41:45 +02:00
Jordi Mas
2bba856206 Update Catalan translation 2020-07-06 08:54:41 +02:00
Benjamin Otte
bf3382a89e testsuite: Add more filterlistmodel tests
These ones try to be exhaustive and randomly catch weird cases.

As such, the tests are more complicated and harder to grasp.
Sorry.
2020-07-06 03:42:43 +02:00
Benjamin Otte
3162e25671 bitset: Fix typo: gtk_bitset_slice() => gtk_bitset_splice() 2020-07-06 03:42:43 +02:00
Benjamin Otte
3d931b4fe2 bitset: Don't overflow when splicing
Testcase added.
2020-07-06 03:42:43 +02:00
Matthias Clasen
fc770a383a gtk-demo: Use a progressbar in the words demo
This looks better and a bit more polished.
2020-07-06 03:42:43 +02:00
Matthias Clasen
62c385a9dd gtk-demo: No selection in the words demo
This demo is about filtering, not about selection,
so use a GtkNoSelection.
2020-07-06 03:42:43 +02:00
Matthias Clasen
7c4ad1a5c4 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-06 03:42:43 +02:00
Benjamin Otte
ac524bb13a 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-06 03:42:43 +02:00
Benjamin Otte
66fa9380b5 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-06 03:42:43 +02:00
Benjamin Otte
b64eb6ca13 gtk-demo: Add incremental filtering to words demo 2020-07-06 03:42:43 +02:00
Benjamin Otte
9b2d8ac362 filterlistmodel: Add gtk_filter_list_model_get_pending()
This allows tracking if the model is busy filtering.
2020-07-06 03:42:43 +02:00
Benjamin Otte
2a90bc1a9b filterlistmodel: Add incremental filtering 2020-07-06 03:42:43 +02:00
Benjamin Otte
d4b868d9bc filterlistmodel: Rewrite with bitset data structure
Bitsets are more powerful, less memory intensive and faster than the old
GtkRbTree version.
2020-07-06 03:42:43 +02:00
Benjamin Otte
b54f6710a7 gtk-demo: Add a listview demo for filtering strings 2020-07-06 03:42:42 +02:00
Matthias Clasen
6bb7caf155 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2198
2020-07-06 00:42:14 +00:00
Matthias Clasen
202348f9d0 filefilter: Cosmetics
Various cleanups to make this code look less ancient.
2020-07-05 19:54:57 -04:00
Matthias Clasen
1a613de2f6 filefilter: Cosmetics 2020-07-05 19:54:20 -04:00
Matthias Clasen
665df37703 filefilter: Header file cosmetics 2020-07-05 19:36:45 -04:00
Matthias Clasen
acad5e4e3d filefilter: Fix an embarrassing oversight
I forgot to remove some dead code, and left the
pixbuf_formats list in the rule union. Oops.
2020-07-05 19:32:36 -04:00
Matthias Clasen
6267c8469b Merge branch 'file-filter2' into 'master'
Make GtkFileFilter a GtkFilter

See merge request GNOME/gtk!2190
2020-07-05 20:32:05 +00:00
Matthias Clasen
5a2f791bdd filefilter: Cleanups and optimizations
Make mime-type rules hold multiple types. Store the
content types, so we don't have to do mime-type -> content-type
conversion in the match function. Store content types for the
pixbuf-formats rule as well, so we can avoid memory allocation
in the match function altogether.
2020-07-05 15:12:07 -04:00
Matthias Clasen
286a00a1db docs: Cleanups for the file filter docs
Now that GtkFileFilter is a GtkFilter, move it to the
filter section of the docs. While we are at it, touch
up the docs in some places.
2020-07-05 15:10:18 -04:00
Matthias Clasen
11dd602b28 Drop gtk_file_filter_filter
It has been superseded by gtk_filter_match.
2020-07-05 15:10:18 -04:00
Matthias Clasen
35988d659d Stop using gtk_file_filter_filter
Make all users of GtkFileFilter use it via the
GtkFilter api. This is in preparation for dropping
gtk_filter_filter_filter.
2020-07-05 15:10:18 -04:00
Matthias Clasen
be3449b3ce filefilter: Convert to a GtkFilter
Make GtkFileFilter implement GtkFilter.
2020-07-05 15:10:18 -04:00
Matthias Clasen
2d8fddc1e9 filefilter: Drop GtkFileFilterFlags
Replace gtk_file_filter_get_needed by gtk_file_filter_get_attributes,
which directly returns the attributes that are needed.

Update all callers.
2020-07-05 15:10:13 -04:00
Matthias Clasen
644d522d19 filefilter: Drop custom filters
These don't work with native file choosers.
2020-07-05 14:34:33 -04:00
Matthias Clasen
a8b0125da1 filefilter: Drop GtkFileFilterInfo
We can just make the filter operate on GFileInfo.
This is in preparation for making GtkFileFilter a
GtkFilter.

Update all users.
2020-07-05 13:55:42 -04:00
Matthias Clasen
acccac516e filefiler: No more floating
Make GtkFileFilter not be initially unowned anymore.
This is in preparation for deriving GtkFileFilter
from GtkFilter. Update all callers.
2020-07-05 12:36:47 -04:00
Matthias Clasen
d65214fa4e Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master

See merge request GNOME/gtk!2193
2020-07-05 16:06:16 +00:00
Baurzhan Muftakhidinov
1d96fc8237 Update Kazakh translation 2020-07-05 12:51:00 +00:00
Florentina Mușat
882a87ca19 Update Romanian translation 2020-07-05 10:42:46 +00:00
Benjamin Otte
1dbb8df95f stringlist: Export gtk_string_object_new()
There are various use cases where it makes sense to construct these -
from our internal testing to using them in flatten- or mapmodels.
2020-07-05 02:59:21 +02:00
Benjamin Otte
f6c2c2edbd stringlist: Call splice() for adding items after construction
This has the benefit of actually allowing NULL to be passed.
2020-07-05 02:59:21 +02:00
Benjamin Otte
c4e4de36f6 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-05 02:59:21 +02:00
Benjamin Otte
67cbb2a7d3 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-05 02:59:21 +02:00
Benjamin Otte
a979daa8ea stringlist: Make one constructor call the other
Simplifies code.
2020-07-05 02:59:21 +02:00
Benjamin Otte
fb14f50ec1 stringlist: Make property not construct-only
Massively speeds up creation of long stringlists.
2020-07-05 02:59:21 +02:00
Benjamin Otte
6099fbafc1 bitset: Add gtk_bitset_new_range()
It's a common use.
2020-07-05 02:59:21 +02:00
Benjamin Otte
6f2f828bce tests: Make testlistview be a list again
The grid conversion was for testing and should never have been
committed.
2020-07-05 02:59:21 +02:00
Benjamin Otte
795d3122cc selectionmodels: Add set_model() support
Now that we don't care about item types anymore, we can make the child
models settable.

We try to retain the selection, even when the model changes.
2020-07-05 02:59:21 +02:00
Benjamin Otte
5080730728 listmodels: Stop respecting item-type
Simplify all view model APIs and always return G_TYPE_OBJECT as the
item-type for every model.

It turns out nobody uses item-type anyway.

So instead of adding lots of APIs, forcing people to think about it and
trying to figure out how to handle filter or map models that modify item
types, just having an easy life is a better approach.

All the models need to be able to deal with any type of object going
through anyway.
2020-07-05 02:59:21 +02:00
Benjamin Otte
f75a3a0e95 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-07-05 02:34:42 +02:00
Benjamin Otte
b75db7d1c6 stringfilter: Don't crash if the expression returns "" 2020-07-05 00:34:21 +02:00
Benjamin Otte
b03069bdf6 a11y: Remove double initialization of variables 2020-07-05 00:34:21 +02:00
Yuri Chornoivan
1c71e56e75 Update Ukrainian translation 2020-07-04 17:02:55 +00:00
Matthias Clasen
9332d0dcc8 Merge branch 'typo' into 'master'
Fixes typos

See merge request GNOME/gtk!2188
2020-07-04 15:48:29 +00:00
Matthias Clasen
9ad37583e6 Merge branch 'matthiasc/for-master' into 'master'
filechooser: Make filtering work again

See merge request GNOME/gtk!2189
2020-07-04 15:46:19 +00:00
Matthias Clasen
69975627e9 filechooser: Make filtering work again
One too many lines were dropped when this filter combo
was converted to a dropdown. Bring it back, to make
filtering work again.
2020-07-04 10:28:10 -04:00
Piotr Drąg
b74a489aba Update POTFILES.in and POTFILES.skip 2020-07-04 13:37:03 +02:00
Jordi Mas
599b807726 Fixes typos 2020-07-04 10:00:25 +02:00
Jordi Mas
6510ca8bdd Update Catalan translation 2020-07-04 09:58:03 +02:00
Matthias Clasen
be20a04e04 Merge branch 'selection-filter-fixes' into 'master'
Selection filter fixes

See merge request GNOME/gtk!2186
2020-07-03 16:10:03 +00:00
Matthias Clasen
92e5536335 testsuite: Add selection filter model tests
Verify that the selection filter changes mirror
the selection changes of the underlying model,
as expected. These tests verify the fixes in
the previous commit.
2020-07-03 11:12:55 -04:00
Matthias Clasen
c2da2f7ecd selectionfilter: Fix bugs in signal translation
When the position is 0, we can't check for unchanged
elements below with gtk_bitset_size_in_range. And
we don't need to, either.

And be careful when translating [start,length]
intervals to [first,last] ones. Off-by-one errors
lurk everywhere.
2020-07-03 11:12:55 -04:00
Matthias Clasen
130bd5937c docs: Add guidance about list model performance
Add a section about the performance tradeoffs between
different list model implementations.
2020-07-03 09:29:19 -04:00
Boyuan Yang
54bfd380a8 Update Chinese (China) translation 2020-07-03 12:49:24 +00:00
Matthias Clasen
f01d695e6c Merge branch 'matthiasc/for-master' into 'master'
inspector: Fix the monitor list width

Closes #2909

See merge request GNOME/gtk!2185
2020-07-03 05:51:29 +00:00
Matthias Clasen
619b2465c1 inspector: Fix the monitor list width
Fixes #2909
2020-07-03 01:07:13 -04:00
Matthias Clasen
cc18191a8e Merge branch 'wip/exalm/show-title-buttons' into 'master'
headerbar: Show title buttons by default

See merge request GNOME/gtk!2175
2020-07-03 05:05:24 +00:00
Matthias Clasen
1f8e7c8aab Merge branch 'selection-filter' into 'master'
Selection filter

See merge request GNOME/gtk!2184
2020-07-03 04:15:12 +00:00
Matthias Clasen
671daea262 gtk-demo: Track the selection
Use GtkSelectionFilterModel to track and display the
selection. Add some other selection information for
good measure.
2020-07-02 22:59:03 -04:00
Matthias Clasen
76533513c2 Add a selection filter model
This model presents the selection of a GtkSelectionModel
as its own list model.
2020-07-02 22:59:03 -04:00
Matthias Clasen
0d3988365b filterlistmodel: Make model not construct-only
This property wasn't meant to be construct-only.
2020-07-02 22:59:03 -04:00
Benjamin Otte
0966636803 bitset: Add APIs needed for a filterlistmodel 2020-07-02 17:19:16 -04:00
Alexander Mikhaylenko
7c3b30036e headerbar: Show title buttons by default
Most of the time show-title-buttons is set to TRUE. Go ahead and make that
the default.
2020-07-02 23:51:16 +05:00
Matthias Clasen
988901294d Merge branch 'matthiasc/for-master' into 'master'
Add gtk_multi_selection_get_model

See merge request GNOME/gtk!2179
2020-07-01 01:36:47 +00:00
Matthias Clasen
43b9fc6981 Merge branch 'wip/baedert/for-master' into 'master'
Wip/baedert/for master

See merge request GNOME/gtk!2162
2020-07-01 01:35:56 +00:00
Benjamin Otte
25f670faae Merge branch 'wip/chergert/gtk4-remove-textlayout-vtable' into 'master'
textlayout: remove virtual table indirection

See merge request GNOME/gtk!2178
2020-07-01 01:19:12 +00:00
Matthias Clasen
d0068a036f Add gtk_multi_selection_get_model
This getter was missing.
2020-06-30 20:47:03 -04:00
Christian Hergert
fae014eb45 textlayout: remove virtual table indirection
GtkTextLayout is private now and therefore we can drop all of
the indirection through the class vtable. Instead, just call the
implementations directly and remove the unused vtable entries
for default signal handlers.
2020-06-30 17:38:31 -07:00
Matthias Clasen
f0ea0be15d Merge branch 'matthiasc/for-master' into 'master'
Drop unnecessary uses of gtk_style_context_add_class

See merge request GNOME/gtk!2177
2020-06-30 22:52:18 +00:00
Matthias Clasen
9650236b23 Merge branch 'inspector-list-model' into 'master'
Inspector list model support

See merge request GNOME/gtk!2176
2020-06-30 22:17:29 +00:00
Matthias Clasen
c0e2d7c62f Drop unnecessary uses of gtk_style_context_add_class
We can use gtk_widget_add_css_class instead, most places.
2020-06-30 17:42:30 -04:00
Matthias Clasen
cc072eb7cd inspector: Avoid a use of gtk_style_context_add_class
We have gtk_widget_add_css_class for this now.
2020-06-30 17:10:05 -04:00
Matthias Clasen
613213f597 inspector: proper list model support
Add a data tab for list models that allows exploring
the objects in the model.
2020-06-30 17:09:55 -04:00
Matthias Clasen
e25c25fcb5 Merge branch 'wip/on-the-surface-good-fences-can-make-bad-neighbors' into 'master'
x11: Handle window getting unmap while frame still pending

Closes #2902

See merge request GNOME/gtk!2168
2020-06-30 19:21:45 +00:00
Matthias Clasen
52666d6fe5 inspector: Rename DataList -> TreeData
Rename the DataList object to TreeData, in preparation
for adding a ListData object for list models. While
we are touching it, modernize it a bit (drop the Private
struct, use a layout manager, etc).
2020-06-30 15:18:37 -04:00
Ray Strode
56b3669411 x11: Avoid thawing surface until frame is drawn
Since commit 972134abe4 a frame getting
drawn has three states (with the vendor nvidia driver at least):

1. drawn by gtk waiting on the GPU
2. drawn by GPU waiting on the compositor
3. drawn by compositor

Those three states are encoded in two flags: frame_pending and
frame_still_painting.

frame_pending means step 1 is done, but step 2 and 3 are still
in progress.  frame_still_painting means step 2 is still in progress.

After step 1 is finished the surface is frozen until step 3 is finished.

When the compositor notifies gtk it's done with step 3, with a
_NET_WM_FRAME_DRAWN client message, the toolkit thaws the surface to
allow the next frame to proceed.

The compositor sometimes sends gtk a _NET_WM_FRAME_DRAWN client message
between steps 1 and 2.  This message should be ignored because it's not
a reply to the current frame.

Unfortunately, gtk currently assumes if it gets a _NET_WM_FRAME_DRAWN
client message while waiting for step 2 that it's actually at step 3,
and proceeds to draw a new frame while the existing frame is still
pending, leading to a blown assertion.

This commit addresses the problem by ignoring _NET_WM_FRAME_DRAWN
client messages from the compositor unless actually expecting one.

Fixes: #2902
2020-06-30 14:36:15 -04:00
Ray Strode
e3b5b76cdd x11: Handle window getting unmapped while frame still pending
Since commit 972134abe4 we now call
glClientWaitSync for the vendor nvidia driver, to know when a frame
is ready for the compositor to process.

If a surface is hidden while a frame is still being rendered by the GPU,
the surface will never produce the damage event the code relies on to
trigger the call to glClientWaitSync. This leaves the fence dangling,
and the next time the surface is shown, it will start a fresh frame
and blow an assertion since the fence from the last frame is still
hanging around.

This commit ensures a frame gets fully wrapped up before hiding a
surface.
2020-06-30 14:36:07 -04:00
Matthias Clasen
bbb28196e5 inspector: Remove list model support from the property editor
This makes the inspector lock up when used with any production
size list model, and blocks access to properties of the model
itself. Instead, we'll make the model available as an object
and add a data tab for list model contents, like we already
do for tree models.
2020-06-30 14:22:01 -04:00
Matthias Clasen
72d3a9042c Merge branch 'issue-2904' into 'master'
Add nullable annotations for gtk_cclosure_expression_new()

Closes #2904

See merge request GNOME/gtk!2172
2020-06-30 12:03:06 +00:00
Emmanuele Bassi
f2853ffa8e Add nullable annotations for gtk_cclosure_expression_new()
Fixes: #2904
2020-06-30 12:11:21 +01:00
Matthias Clasen
fca2ba963d gtklistitemfactory: Cosmetic documentation fixes 2020-06-29 22:11:44 -04:00
Matthias Clasen
806779769e builderlistitemfactory: Documentation fixes 2020-06-29 22:11:36 -04:00
Matthias Clasen
82aa0d1f7c expression: Add to the docs
Add some more long-form explanation of what expressions
are about and where they are used.
2020-06-29 22:10:34 -04:00
Matthias Clasen
72f1d34eca Drop GtkFunctionsListItemFactory
It has been superseded by GtkSignalsListItemFactory.
2020-06-29 22:10:34 -04:00
Matthias Clasen
c267a75eef Stop using GtkFunctionsListItemFactory
This was an early attempt at a factory, and has been
superseded by GtkSignalsListItemFactory. Port all users
the the newer one.
2020-06-29 22:10:34 -04: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
Jehan
2fb755e0c9 build-aux: fallback to default glib-compile-schemas & gio-querymodules.
The pkg-config variables have been added in GLib 2.62.0. Let's fallback
to default names for these tools in such case (`pkg-config` still
returns a 0 return value, but with empty output for absent variables).
2020-06-28 12:48:27 +02:00
Jehan
cd096819d8 build-aux: search various Glib/GIO utilities in .pc file.
Some distributions are renaming Glib/GIO utilities for multi-arch
reasons so pkg-config variables have been added to find the correct name
of a tool. GTK+ should use these variables instead of searching in PATH.
See glib#1796.
2020-06-28 12:46:32 +02: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
Timm Bäder
83543423e2 widget: Don't get the frame clock if we don't use it 2020-06-27 11:47:42 +02:00
Timm Bäder
d0bb72a2aa label: Only care about clipboard in unrealize of we need to 2020-06-27 11:47:39 +02:00
Timm Bäder
8cc2a44268 recorder: Don't select new row when adding recording
This is what makes the recorder slow. We might want to scroll down in
the list though.
2020-06-27 11:30:02 +02:00
Timm Bäder
4800dd3f95 rendernode: Trivial whitespace change 2020-06-27 11:22:54 +02:00
Timm Bäder
2534310ce9 recorder: Remove frame time from recording rows
We should bring this back in a different way, e.g. in a way that doesn't
just use the time of the previous recording.
2020-06-27 11:15:51 +02:00
Timm Bäder
3a4fbc5e50 recorder: Remove Full/Partial render distinction
It doesn't exist anymore these days
2020-06-27 11:08:09 +02:00
Timm Bäder
89a67ac719 recorder: s/gint/int/g 2020-06-27 11:04:03 +02:00
Timm Bäder
21b84b1890 recorder: Remove some debug spew
Stop printing the number of nodes we have
2020-06-27 11:01:28 +02:00
Timm Bäder
20935f678b scale: Rearrange child widgets
Always keep the order:

 - [value]
 - [marks.top]
 - [marks.bottom]
 - trough

Which makes sense given the rendering order. Slider should be drawn
after the marks.

Makes it possible to simply remove the custom snapshot implementations
in scale and range. And Adwaita does not depend on the node order
anyway.
2020-06-27 10:51:06 +02:00
Timm Bäder
c41b4130c6 textview: Remove unused define 2020-06-27 10:51:06 +02:00
Timm Bäder
f1b010af66 Add .view to view widgets 2020-06-27 10:51:06 +02:00
Timm Bäder
ec1133d6e1 renderbackground: Only query number of layers once
We did it once in snapshot_background and then again in snapshot_color.
2020-06-27 10:51:06 +02:00
Timm Bäder
8fcf1b78a4 renderbackground: Only query h/vrepeat if we need to 2020-06-27 10:51:06 +02:00
Timm Bäder
21f9148155 gl renderer: Fix cross-fade nodes with invisible end child
Only loading the vertex data doesn't draw anything.
2020-06-27 10:51:06 +02:00
Timm Bäder
d4f0593b37 gl renderer: Handle 0/1 progress in crossfade nodes 2020-06-27 10:51:06 +02: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
Matthias Clasen
2abb5b6419 3.98.5 2020-06-06 16:03:38 -04:00
Matthias Clasen
f2259adcdc Disable a failing test
For some reason, empty-linear-gradient is failing here,
with the broadway and opengl renderers, and I don't
know why. Disable it for now.
2020-06-06 15:32:26 -04:00
Matthias Clasen
a73457237d Skip broken a11y tests 2020-06-06 14:18:44 -04:00
Matthias Clasen
9f335d3ee6 docs: Regroup the tree support parts
Give the chapter a title, and put some things in sections.
2020-06-06 13:54:58 -04:00
Matthias Clasen
856c8950ff docs: Put selection models into a section
This makes the documentation structure a bit clearer.
2020-06-06 13:54:58 -04:00
Matthias Clasen
61ccf4e719 docs: Fix up the GtkNativeDialog section
Without GtkNativeDialog in the section list,
links are not generated from the object hierarchy.
2020-06-06 13:54:58 -04:00
Matthias Clasen
1567db1f02 Merge branch 'misc-multiselection' into 'master'
Misc multiselection

See merge request GNOME/gtk!2055
2020-06-06 17:54:42 +00:00
Matthias Clasen
8316d5e366 Merge branch 'list-arrows' into 'master'
listbase: Make up/down arrows work

See merge request GNOME/gtk!2056
2020-06-06 17:47:05 +00:00
Matthias Clasen
8fca040163 Merge branch 'property-selection' into 'master'
Property selection

Closes #2826

See merge request GNOME/gtk!2054
2020-06-06 17:35:05 +00:00
Matthias Clasen
c0fe1a7ffe listbase: Make up/down arrows work
We were missing a binding for up/down without modifiers.
2020-06-06 12:33:12 -04:00
Matthias Clasen
e72c243aca singleselection: Clarify docs
Mention persistence and sorting.
2020-06-06 11:53:33 -04:00
Matthias Clasen
14605d4b92 gtk-demo: Use a property selection in the colors demo
This makes the property persist across sort changes.
2020-06-06 11:41:51 -04:00
Matthias Clasen
d1509971d8 Add GtkPropertySelection
This is a selection model that stores the selection
state in a boolean property of the items, and thus
persists across reordering and similar changes.

Fixes: #2826
2020-06-06 11:41:51 -04:00
Matthias Clasen
951c9c5d73 Merge branch 'listitemmanager-selection' into 'master'
listitemmanager: Handle selection-changes properly

Closes #2827

See merge request GNOME/gtk!2053
2020-06-06 15:23:40 +00:00
Matthias Clasen
3e6e247e56 multiselection: Rewrite the select_callback implementation
Use a for loop to make this more obvious, and add some
assertions that the callback is behaving properly.
2020-06-06 11:22:48 -04:00
Matthias Clasen
27ce68b74a Add tests for select_callback 2020-06-06 11:22:48 -04:00
Matthias Clasen
b0cf7a95b0 Add a forgotten export
gtk_selection_model_unselect_callback needs to be exported.
2020-06-06 11:22:48 -04:00
Matthias Clasen
fd7f19c934 selectionmodel: Document the callback apis 2020-06-06 10:36:57 -04:00
Matthias Clasen
8090e213de Add a test for multiselection persistence
Add a test that verifies that newly added items
are always unselected.
2020-06-06 10:24:14 -04:00
Matthias Clasen
de6327a885 multiselection: Clarify docs
Make it clear that GtkMultiSelection is not persistent
across resorting.
2020-06-06 10:24:14 -04:00
Yuri Chornoivan
8699c0f340 Update Ukrainian translation 2020-06-06 13:46:40 +00:00
Yuri Chornoivan
bda5454549 Update Ukrainian translation 2020-06-06 13:44:29 +00:00
Matthias Clasen
c3a6e35070 Drop an unnecessary include 2020-06-06 09:39:36 -04:00
Matthias Clasen
71c29bfcff listitemmanager: Handle selection-changes properly
The selection model will only emit one of items-changed
or selection-changed, so when we handle an items-changed,
we must assume that selection state may have changed for
any of the newly added items.

This fixes lingering selection state in the visible range
if you change the sorting of the colors demo.

Fixes: #2827
2020-06-06 08:36:11 -04:00
Piotr Drąg
647ed59d11 Update POTFILES.in and POTFILES.skip 2020-06-06 14:00:43 +02:00
Matthias Clasen
a0c489048a Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2052
2020-06-06 05:30:30 +00:00
Benjamin Otte
0f9def660d Merge branch 'wip/otte/for-master' into 'master'
multiselection: Remove unused code

See merge request GNOME/gtk!2051
2020-06-06 05:16:47 +00:00
Matthias Clasen
9fa65eadae listitemwidget: Don't look at rubberbanding
Move the selection changes to button release, to
avoid conflict with the drag gesture for rubberbanding.
This avoids peeking at the parent, and is generally
nicer.

Among other things, you can now shift-click to select
a range in the colors demo in gtk4-demo.
2020-06-06 00:23:04 -04:00
Matthias Clasen
facfff0022 listbase: Fix an off-by-one error
We were accidentally cutting off the set one-too-early,
which showed up as single clicks not selecting an item
anymore.
2020-06-06 00:15:50 -04:00
Matthias Clasen
f8b4083f47 listbase: Fix a problem with rubberbands
When I changed things to only collect the set
in the stop() function, I overlooked that this
has the side-effect of only handling items which
are backed by a widget at the time stop() is called.
If we make a big rubberband and autoscroll down too
far, we loose the items that go out the visible range
at the top. Fix that by maintaining the set as we go.
2020-06-05 23:18:00 -04:00
Matthias Clasen
b047b7838d multiselection: Don't emit nonsensical signals
I forgot to add a check here. We only want to emit
a ::selection-changed if we actually changed it.
2020-06-05 23:15:20 -04:00
Benjamin Otte
b1c00ecee6 multiselection: Remove unused code
This is leftover code from an earlier SelectionModel API.
2020-06-06 05:02:37 +02:00
Matthias Clasen
93abd8da59 NEWS: Updates 2020-06-05 22:50:30 -04:00
Matthias Clasen
3412f0554f gtk: Documentation fixups
Document missing symbols, and other cleanups.
2020-06-05 22:50:30 -04:00
Matthias Clasen
61c83f9ffe gdk: Documentation fixups
Document some missing symbols.
2020-06-05 20:59:51 -04:00
Matthias Clasen
3d7c1f8950 gsk: Documentation fixups
Document a few missing symbols.
2020-06-05 20:19:45 -04:00
Matthias Clasen
b0e81acc12 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2050
2020-06-05 23:55:12 +00:00
Matthias Clasen
a682d97663 Merge branch 'wip/ebassi/a11y-2' into 'master'
Accessibility cleanup

See merge request GNOME/gtk!2049
2020-06-05 23:04:21 +00:00
Matthias Clasen
0e5137ae61 NEWS: Updates 2020-06-05 18:40:53 -04:00
Matthias Clasen
005a3da18f gtk-demo: Another way to trigger theme benchmark
The click on the headerbar seems broken atm, so add
an explicit button to trigger the cycling among the
themes.
2020-06-05 18:40:24 -04:00
Matthias Clasen
be6bcf882d spinbuttonaccessible: Fix an oversight
We need to pass the accessible to the signal handler.
2020-06-05 17:21:26 -04:00
Matthias Clasen
fb344e8108 Trivial typo fix 2020-06-05 17:08:43 -04:00
Emmanuele Bassi
b99389bcb8 a11y: Drop GtkWidgetAccessibleClass.notify_gtk
It's finally unused.

Accessible types should either watch properties they are interested in
directly, or should have (private) API to allow widgets to update the
accessible state directly.
2020-06-05 20:35:11 +01:00
Emmanuele Bassi
0fefdc99b2 a11y: Simplify GtkEntryAccessible
Now that we don't have any additional subclasses of GtkEntryAccessible
in GTK, we can drop all the conditional fluff in the base class.

We still need to subscribe to the global notify signal, because of the
sheer amount of properties watched by GtkEntryAccessible.
2020-06-05 20:35:11 +01:00
Emmanuele Bassi
e63419fbf4 a11y: Implement GtkPasswordEntryAccessible properly
GtkPasswordEntryAccessible is not a GtkEntryAccessible any more, so it
will need a proper implementation of various interfaces and
functionality in order to work like any other entry.
2020-06-05 20:35:11 +01:00
Emmanuele Bassi
428bb09a35 a11y: Make GtkSearchEntryAccessible a full GtkWidgetAccessible
We should not inherit from GtkEntryAccessible, given that GtkSearchEntry
is *not* a GtkEntry.
2020-06-05 20:35:11 +01:00
Emmanuele Bassi
7c2c795681 a11y: Simplify GtkScrollbarAccessible 2020-06-05 20:35:11 +01:00
Emmanuele Bassi
165f352c58 a11y: Simplify GtkScaleButtonAccessible 2020-06-05 20:35:11 +01:00
Emmanuele Bassi
3d6e702f63 a11y: Simplify GtkSpinButtonAccessible
We're already listening to the adjustment property on the spin button,
there's no need to reset the adjustment on widget set/unset, since the
accessible instance is always tied to the same widget.
2020-06-05 20:35:11 +01:00
Emmanuele Bassi
597e9a96b4 a11y: Simplify GtkTextAccessible 2020-06-05 20:35:11 +01:00
Emmanuele Bassi
6f4ed6c105 a11y: Simplify GtkTextViewAccessible
Drop the GtkWidgetAccessible.notify_gtk override.
2020-06-05 20:35:10 +01:00
Emmanuele Bassi
c3eafed472 a11y: Simplify GtkColorSwatchAccessible
Drop the GtkWidgetAccessible.notify_gtk override.
2020-06-05 20:35:10 +01:00
Emmanuele Bassi
7480fb703e a11y: Simplify GtkNotebookAccessible
Let the GtkNotebook explicitly update the accessible object that the
current page has changed, instead of overriding
GtkWidgetAccessible.notify_gtk.
2020-06-05 20:35:10 +01:00
Emmanuele Bassi
24e8b484e0 a11y: Simplify GtkWindowAccessible
Have GtkWindow notify of title changes, instead of overriding
GtkWidgetAccessible.notify_gtk.
2020-06-05 20:35:10 +01:00
Emmanuele Bassi
d60f7f2e7a a11y: Simplify GtkExpanderAccessible
Drop the GtkWidgetAccessible.notify_gtk and AtkObject.initialize
overrides, and have GtkExpander update the state of the accessible
object directly.
2020-06-05 20:35:10 +01:00
Emmanuele Bassi
0dcffe7c33 a11y: Simplify GtkLevelBarAccessible
Drop the GtkWidgetAccessible.notify_gtk and AtkObject.initialize
overrides, and have GtkLevelBar notify the accessible object of value
changes.
2020-06-05 20:35:10 +01:00
Emmanuele Bassi
9f09cfcfbd a11y: Split GtkSearchEntryAccessible from GtkEntryAccessible
Use a separate accessible object for the GtkSearchEntry, just like we
did for GtkPasswordEntry.
2020-06-05 20:35:10 +01:00
Emmanuele Bassi
7373cd962c a11y: Split password entry accessible from GtkEntryAccessible
Use a separate accessible object.
2020-06-05 20:35:10 +01:00
Emmanuele Bassi
ac3f0df083 a11y: Simplify GtkProgressBarAccessible
Drop the GtkWidgetAccessibleClass.notify_gtk and the
AtkObjectClass.initialize overrides: they don't do anything relevant.

Instead, have GtkProgressBar update the accessible state when the
fraction changes.
2020-06-05 20:35:10 +01:00
Emmanuele Bassi
f95d54a13d a11y: Use G_DECLARE macro for GtkWidgetAccessible
Allows us to drop the Private structure typedef.
2020-06-05 20:35:10 +01:00
Emmanuele Bassi
fc512f0b9f a11y: Update the accessible state when GtkIconView:model changes
Do not use a generic "notify" signal handler.

Additionally, clean up the GtkIconViewAccessible implementation to bring
it up with modern idiomatic GObject.
2020-06-05 20:35:10 +01:00
Emmanuele Bassi
f5ed59b7f2 a11y: Drop notify_gtk() from GtkRangeAccessible
Let the GtkRange notify the accessible instance when the adjustment
changes.
2020-06-05 20:35:10 +01:00
Emmanuele Bassi
9d51aa1443 a11y: Drop notify_gtk() from GtkButtonAccessible
Make GtkButton notify the accessible state directly when updating the
label.
2020-06-05 20:35:10 +01:00
Emmanuele Bassi
f0bdc865b9 a11y: Remove GtkToggleButtonAccessible notify_gtk implementation
The base GtkWidgetAccessible class does the right thing by default.
2020-06-05 20:35:10 +01:00
Emmanuele Bassi
eda1703f9d a11y: Update accessible state for GtkTreeView directly
Do not use GtkWidgetAccessibleClass.notify_gtk().
2020-06-05 20:35:10 +01:00
Emmanuele Bassi
51fc382582 Notify accessibility state changes from GtkWidget
Piggybacking on blanket GObject::notify is not very efficient.
2020-06-05 20:35:10 +01:00
Emmanuele Bassi
6e52ef96a4 Move orientable style classes into GtkWidget
It feels slightly wrong to have GtkOrientable operate on widgets, but at
least what happens when an orientable widget changes orientation should
be part of GtkWidget.

This will allow to add more state changes without accessing widget state
from the outside of gtkwidget.c.
2020-06-05 20:35:09 +01:00
Emmanuele Bassi
9606c1eee9 Notify mapped state to the accessible object directly
Do not use signal connections: if we have an accessible object, notify
it directly when getting mapped and unmapped.
2020-06-05 20:32:27 +01:00
Emmanuele Bassi
959c101400 Drop unused AtkRegistry path
We expect widgets to use their own derived GtkWidgetAccessible type,
these days, and given that we hard code the default accessible type of a
GtkWidget to GtkWidgetAccessible, and that we enforce the dependency of
the type passed to gtk_widget_class_set_accessible_type(), the registry
code path is clearly unused.
2020-06-05 20:32:27 +01:00
Emmanuele Bassi
6b096e5c5b Make tooltip properties idiomatic
The tooltip handling in GtkWidget is "special":

 - the string is stored inside the qdata instead of the private
   instance data
 - the accessors call g_object_set() and g_object_get(), and the
   logic is all inside the property implementation, instead of
   being the other way around
 - the getters return a copy of the string
 - the setters don't really notify all the involved properties

The GtkWidgetAccessible uses the (escaped) tooltip text as a source for
the accessible object description, which means it has to store the
tooltip inside the object qdata, and update its copy at construction and
property notification time.

We can simplify this whole circus by making the tooltip properties (text
and markup) more idiomatic:

 - notify all side-effect properties
 - return a constant string from the getter
 - if tooltip-text is set:
   - store the text as is
   - escape the markup and store it separately for the markup getter
 - if tooltip-markup is set:
   - store the markup as is
   - parse the markup and store it separately for the text getter

The part of the testtooltips interactive test that checks that the
getters are doing the right thing is now part of the gtk testsuite, so
we ensure we don't regress in behaviour.
2020-06-05 20:32:26 +01:00
Emmanuele Bassi
9ac1eacdc8 Use modern GObject macros for GtkAccessible 2020-06-05 20:32:26 +01:00
Matthias Clasen
8e7395a7e3 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!2048
2020-06-05 19:25:46 +00:00
Matthias Clasen
80fbc1b72d multiselection: Fix the select_range implementation
When exclusive is TRUE, we would not always emit a
::selection-changed signal that covers all the items
that were unselected.

This commit includes a test.
2020-06-05 14:57:59 -04:00
Matthias Clasen
17ea03eee2 set: Fix gtk_set_get_max
This function had an off-by-one error. Thankfully,
our selection tests are thorough enough to catch it.
2020-06-05 14:57:32 -04:00
Matthias Clasen
985b5a052e dropdown: Connect a forgotten signal handler
The code was exporting a search_stop function, but
the ui file didn't connect it to the ::stop-search
signal. Fix that.
2020-06-05 14:34:38 -04:00
Matthias Clasen
ed1872f0a8 Merge branch 'frame-clock-start-time' into 'master'
Tweaks to frame clock for better ties to vsync

See merge request GNOME/gtk!2043
2020-06-05 18:33:48 +00:00
Matthias Clasen
34841c3a5f Merge branch 'master.msvc' into 'master'
Fix latest GTK master on Visual Studio

See merge request GNOME/gtk!2028
2020-06-05 18:31:08 +00:00
Matthias Clasen
185f0181ac Merge branch 'columnview-reorder-cells' into 'master'
Columnview reorder cells

See merge request GNOME/gtk!2047
2020-06-05 18:29:26 +00:00
Matthias Clasen
60d6a0f2d5 Merge branch 'rubberband-again' into 'master'
Rubberband again

See merge request GNOME/gtk!2041
2020-06-05 17:59:15 +00:00
Matthias Clasen
99a1d10bf1 multiselection: Fix the select_range implementation
When exclusive is TRUE, we would not always emit a
::selection-changed signal that covers all the items
that were unselected.

This commit includes a test.
2020-06-05 13:50:30 -04:00
Matthias Clasen
2f1028ed79 set: Add a few useful functions
Allow to find out if a set is empty, and its
min and max.
2020-06-05 13:49:23 -04:00
Matthias Clasen
f631e0e1e0 columnview: Update column positions on reordering
Tell reordered columns to reorder their cells to
the new position. This is necessary to get things
like separators right. The visible symptom of this
problem was the lack of the right border when the
last column is reorder to another position, since
the title widget was still the last in its container,
so :last-child applied.
2020-06-05 13:28:44 -04:00
Matthias Clasen
6df489d5a9 columnviewcolumn: Add private api to set the position
This is needed to make columns reorder their cells when
their position in the column views list of columns
changes.
2020-06-05 13:28:44 -04:00
Matthias Clasen
15c6ad88c0 listitemwidget: Add api to reorder children
We need this to keep the rows in sync with the columns
when they are reordered.
2020-06-05 13:28:44 -04:00
Matthias Clasen
40f6a9d830 columnviewlayout: Handle for_size propertly
When we are given a for_size as width for the whole
column view, we need to distribute it over the columns
as gtk_column_view_allocate_columns would, in order
to find out which for_size to give to each cell.

This is a bit recursive, but works. Since we are
doing this recursion for every row, we should consider
adding a cache for those distributed widths.
2020-06-05 13:27:50 -04:00
Ray Strode
bd06c00f3a Merge branch 'wip/damaged-but-no-frost-bite' into 'master'
x11: defer _NET_WM_FRAME_DRAWN update until frame usable by compositor

See merge request GNOME/gtk!1982
2020-06-05 15:58:37 +00:00
Matthias Clasen
f6d23f0c29 Merge branch 'matthiasc/for-master' into 'master'
gtk-demo: Bring back the applauncher demo

See merge request GNOME/gtk!2040
2020-06-05 15:38:03 +00:00
Emmanuele Bassi
2a24459b92 Merge branch 'ebassi/for-master' into 'master'
Add missing annotation

See merge request GNOME/gtk!2046
2020-06-05 15:29:41 +00:00
Matthias Clasen
f6da324670 columnview: Split gtk_column_view_allocate_columns
Split off a helper function that just distributes
the widths, without actually allocating the columns.

This will be used in measuring in the future.
2020-06-05 11:27:40 -04:00
Matthias Clasen
11a18bd61a columnview: Take column width into account for measuring
When measuring the height of a cell, we need to give
it it the width of its column, if we expect realistic
results.
2020-06-05 10:42:20 -04:00
Ray Strode
972134abe4 x11: Defer _NET_WM_FRAME_DRAWN update until frame usable by compositor
With the vendor provided Nvidia driver there is a small window of time
after drawing to a GL surface before the updates to that surface
can be used by the compositor.

Drawing is already coordinated with the compositor through the frame
synchronization protocol detailed here:

https://fishsoup.net/misc/wm-spec-synchronization.html

Unfortunately, at the moment, GdkX11Surface tells the compositor the
frame is ready immediately after drawing to the surface, not later,
when it's consumable by the compositor.

This commit defers announcing the frame as ready until it's consumable
by the compositor. It does this by listening for the X server to announce
damage events associated with the frame drawing.  It tries to find the
right damage event by waiting until fence placed at buffer swap time
signals.
2020-06-05 10:01:13 -04:00
Ray Strode
f8770b78ea x11: Factor out some of frame sync code into subroutines
This commit moves some of the end frame sync counter handling
code to subroutines.

It's a minor readability win, but the main motivation is to
make it easier in a subsequent commit to defer updating the
sync counter until a more appropriate time.
2020-06-05 10:01:13 -04:00
Ray Strode
10f2b11fda x11: Add back support for the damage extension
commit 14bf58ec5d dropped support
for using the DAMAGE extension since there was no code that
needed it.

We're going to need it again, however, to address an NVidia
vendor driver issue.

This commit does the plumbing to add it back.
2020-06-05 10:01:13 -04:00
Timm Bäder
ea1cc4b991 filechooserwidget: Avoid an uninitialised value
For NULL filters, we were never calling g_list_store_find, so leaving
filter_index undefined.
2020-06-05 15:38:55 +02:00
Timm Bäder
8bee3e2fe0 demos: Avoid shadowing a global from time.h
Sad but true.
2020-06-05 15:38:55 +02:00
Timm Bäder
1f7adfd9ff filterlistmodel: Fix fallthrough annotations in unreachable code
They are only unreachable in debug builds but still break the build on
clang.
2020-06-05 15:38:55 +02:00
Matthias Clasen
9e55cd68e4 columview: Make cells propagate request mode
I think this is necessary to make wrapping
labels work.
2020-06-05 09:37:21 -04:00
Matthias Clasen
2a6dc67fd7 gtk-demo: Improve wrapping in settings demo
The columnview overrides the width of its content,
so if a label is not willing to wrap its content
below a certain width, it will just get cut off.

Avoid that by not setting width-chars on the wrapping
content.
2020-06-05 09:35:56 -04:00
Emmanuele Bassi
1061ad289a Add missing annotation 2020-06-05 14:33:17 +01:00
Matthias Clasen
0f81b58545 columviewlayout: Skip children when we should
Every layout manager should call gtk_widget_should_layout
on their children before measuring or allocating them.
So do it here too.
2020-06-05 08:44:23 -04:00
Matthias Clasen
2437c5a0ae listview: Add an example to the docs
The example is an excerpt from the applauncher
demo in gtk4-demo.
2020-06-05 08:22:48 -04:00
Matthias Clasen
669a6ddeaa gtk-demo: Bring back the applauncher demo
Just without the coverflow. It was a well-documented
demo, so it is useful to keep around.
2020-06-05 08:22:48 -04:00
Yariv Barkan
f5de46670b frame clock: schedule in refresh intervals
When the application does not receive "frame drawn" signals we schedule
the clock to run more or less at intervals equal to the last known
refresh interval. In order to minimize clock skew we have to aim for
exact intervals.
2020-06-05 11:57:49 +02:00
Alexander Larsson
91af8a705b frame clock: Better handle non-regular clock cycles
We try to step the frame clock in whole refresh_interval steps, but to
avoid drift and rounding issues we additionally try to converge it to
be synced to the physical vblank (actually the time we get the
frame-drawn message from the compositor, but these are tied together).

However, the convergence to vsync only really makes sense if the new
frame_time actually is tied to the vsync. It may very well be that
some other kind of event (say a network or mouse event) triggered
the redraw, and not a vsync presentation.

We used to assume that all frames that are close in time (< 4 frames
apart) were regular and thus tied to the vsync, but there is really no
guarantee of that. Even non regular times could be rapid.

This commit changes the code to only do the convergence-to-real-time
if the cause of the clock cycle was a thaw (i.e. last frame drawn and
animating). Paint cycles for any other kind of reason are always
scheduled an integer number of frames after the last cycle that was
caused by a thaw.
2020-06-05 11:30:47 +02:00
Alexander Larsson
82c314f1af frame clock: Track if paint is caused by thaw or not
When we get to a paint cycle we now know if this was caused by a
thaw, which typically means last frame was drawn, or some other event.

In the first case the time of the cycle is tied to the vblank in some
sense, and in the others it is essentially random. We can use this
information to compute better frame times. (Will be done in later
commits.)
2020-06-05 11:16:57 +02:00
Benjamin Otte
672413f1f6 Merge branch 'cleanup-snapshot-inhibit' into 'master'
reftest: Clean up reftest_inhibit_snapshot()

See merge request GNOME/gtk!2034
2020-06-05 07:38:52 +00:00
Matthias Clasen
843bf23f84 Drop gtk_multi_selection-copy
It is not used anymore.
2020-06-05 00:51:35 -04:00
Matthias Clasen
eeb2d2cc38 listbase: Redo rubberbanding
Make it so that the selection is only updated in the end.
2020-06-05 00:51:35 -04:00
Chun-wei Fan
c370b8f309 demos/gtk-demo/listview*.c: Include stdlib.h
atoi() and qsort() both require this header for them to be defined
2020-06-05 11:16:45 +08:00
Chun-wei Fan
acd9c12667 modules: Fix build on Visual Studio
Visual Studio does not allow decorating functions with '__declspec (dllexport)'
if a prototype exists and is not decorated with '__declspec (dllexport)' as
well, so we cannot just decorate g_io_module_[load|unload|query] in the various
module sources with G_MODULE_EXPORT because the prototypes of these functions
have been marked with _GLIB_EXTERN, which equates to 'extern' unless overridden

Fix this by overriding _GLIB_EXTERN with the appropriate visibility flag, as we
have used to define _GDK_EXTERN.  Unfortunately, we can't just use _GDK_EXTERN
G_MODULE_EXPORT as they may have not been defined yet for our use

Do this across the board for all modules, even if they are not buildable on
Visual Studio nor Windows, for consistency's sake.
2020-06-05 11:16:45 +08:00
Timm Bäder
5535b26395 Merge branch 'fix-quadratic-add' into 'master'
Avoid quadratic slowdown in gtk_widget_add()

See merge request GNOME/gtk!2027
2020-06-05 02:57:38 +00:00
Matthias Clasen
20611cf68c Add gtk_selection_model_[un]select_callback
Add a methods to add or remove a whole set
(specified via a query-range style callback).
2020-06-04 22:28:54 -04:00
Matthias Clasen
06c34ce02f set: Add a few useful functions
Allow to find out if a set is empty, and its
min and max.
2020-06-04 21:36:23 -04:00
Matthias Clasen
4fb50c7408 Merge branch 'matthiasc/for-master' into 'master'
more documentation for list widgets

See merge request GNOME/gtk!2039
2020-06-04 21:17:21 +00:00
Matthias Clasen
c37bea1676 Merge branch 'fribidi-include' into 'master'
wayland: Remove unused fribidi include

See merge request GNOME/gtk!2037
2020-06-04 20:03:13 +00:00
Matthias Clasen
ed985640e8 docs: Expand list widget docs
Begin to flesh out the long descriptions for GtkListView,
GtkGridView and GtkColumnView.
2020-06-04 15:33:53 -04:00
Sebastian Keller
2bd938952d wayland: Remove unused fribidi include
The included fribidi header is not used in gdkkeys-wayland.c and already
included in gdk.c which causes linker issues due to the header defining
a global variable.
2020-06-04 20:44:55 +02:00
Matthias Clasen
623a56391c gtk-demo: Cosmetics
Remove a few instances of double semicolon.
2020-06-04 13:30:13 -04:00
Matthias Clasen
1b7fb10361 Merge branch 'matthiasc/for-master' into 'master'
gtk-demo: Allow editing in the settings demo

See merge request GNOME/gtk!2033
2020-06-04 16:32:21 +00:00
Matthias Clasen
f6b6688186 Merge branch 'list-widget-styles' into 'master'
List widget styles

Closes #2818

See merge request GNOME/gtk!2035
2020-06-04 16:27:37 +00:00
Matthias Clasen
99453e937c Merge branch 'demo-drop-awards' into 'master'
gtk-demo: Drop the awards

See merge request GNOME/gtk!2036
2020-06-04 15:27:23 +00:00
Alexander Larsson
d3e0a1f68c Avoid quadratic slowdown in gtk_widget_add()
If you add a widget to a parent, this will invalidate the css nodes
for parent/siblings. Afterwards, if the parent is mapped, we will
realize the new child. This calls gtk_widget_update_alpha() which
needs the css opacity, so it revalidates the css.

Thus, for each widget_add (while visible) will trigger a full
revalidation of each sibling. If you add N children to a parent that
leads to O(N^2) revalidations.

To demo this I changed gtk-demo to always double the count
(independent of the fps) and print the time it took. Here is the
results (after a bit):

Setting fishbowl count=256 took 3,4 msec
Setting fishbowl count=512 took 10,1 msec
Setting fishbowl count=1024 took 34,1 msec
Setting fishbowl count=2048 took 126,3 msec
Setting fishbowl count=4096 took 480,3 msec
Setting fishbowl count=8192 took 1892,7 msec
Setting fishbowl count=16384 took 7751,0 msec
Setting fishbowl count=32768 took 38097,7 msec
Setting fishbowl count=65536 took 191987,7 msec

To fix this we drop gtk_widget_update_alpha() and just
calculate it when needed (which is only in a single place).
It was really only necessary because we previously set
the alpha on the surface.

With this fix the above becomes:

Setting fishbowl count=256 took 1,0 msec
Setting fishbowl count=512 took 1,9 msec
Setting fishbowl count=1024 took 3,7 msec
Setting fishbowl count=2048 took 7,4 msec
Setting fishbowl count=4096 took 18,1 msec
Setting fishbowl count=8192 took 31,0 msec
Setting fishbowl count=16384 took 66,3 msec
Setting fishbowl count=32768 took 126,7 msec
Setting fishbowl count=65536 took 244,6 msec
Setting fishbowl count=131072 took 492,2 msec
Setting fishbowl count=262144 took 984,3 msec
2020-06-04 16:42:59 +02:00
Matthias Clasen
76ff1a2a49 gtk-demo: Drop the awards
This was a neat idea, but maintaining it at a sufficient
level is too much work.
2020-06-04 10:19:44 -04:00
Matthias Clasen
51c6ce1734 list widgets: Document css structure
We didn't fill in this expected part of the widget
documentation yet.
2020-06-04 10:05:17 -04:00
Benjamin Otte
1998b673f4 Merge branch 'ensure-style-no-recurse' into 'master'
Avoid recursion in gtk_css_node_ensure_style()

See merge request GNOME/gtk!2031
2020-06-04 14:04:55 +00:00
Matthias Clasen
627497f942 docs: Fix a parameter name mismatch 2020-06-04 09:52:17 -04:00
Matthias Clasen
f9287941b4 Change css names of list widget
The new names are

GtkListView - listview row
GtkGridView - gridview child
GtkColumView - columnview header
               columnview listview row

Adwaita css has been updated to preserve
existing styles.

Fixes: #2818
2020-06-04 09:51:49 -04:00
Alexander Larsson
5059854a2e reftest: Clean up reftest_inhibit_snapshot()
This was done in a weird way where we always call reftest_uninhibit_snapshot()
on paint, and then re-inhibited it if it wasn't inhibited. To make this
work it also started with an extra inhibit.

This is very contorted and based on how this historically worked. This
changes it to just do:

  if (inhibit_count > 0)
    return;

And keep inhibit_count at its initial zero value unless it is actually
inhibited.
2020-06-04 15:45:29 +02:00
Benjamin Otte
aa8a061a83 Merge branch 'fix-snapshot' into 'master'
snapshot: Fix assert if paint gets scheduled immediately

See merge request GNOME/gtk!2032
2020-06-04 13:43:44 +00:00
Matthias Clasen
3f2d44d517 gtk-demo: Allow editing in the settings demo
This gives us an example of a columnview with editable
content, which we didn't have so far.
2020-06-04 08:45:47 -04:00
Alexander Larsson
b4af23be23 snapshot: Fix assert in inhibition
In https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/2027 i was getting

Bail out! ERROR:../testsuite/reftests/reftest-snapshot.c:212:reftest_uninhibit_snapshot: assertion failed: (inhibit_count > 0)

In (for example the box-shadow-changes-modify-clip reftest. I can reproduce this (on master) with:

```
$ xvfb-run -a -s "-screen 0 1024x768x24" meson test --suite gtk:reftest "reftest box-shadow-changes-modify-clip.ui"
...
1/1 gtk:reftest / reftest box-shadow-changes-modify-clip.ui ERROR          0.77s
``

Fix this by re-inhibiting if we didn't draw anything, or we will get an assert the next paint.
2020-06-04 14:22:27 +02:00
Matthias Clasen
8ddf1f1ea5 Merge branch 'kjellahl/flowboxremove' into 'master'
flowbox: Don't use a removed and destroyed child

See merge request GNOME/gtk!2029
2020-06-04 12:13:57 +00:00
Matthias Clasen
475d8c4c11 Merge branch 'fishbowl-children' into 'master'
gtk-demo: Avoid list for children in GtkFishBowl

See merge request GNOME/gtk!2030
2020-06-04 12:10:51 +00:00
Alexander Larsson
fc823eb610 Avoid recursion in gtk_css_node_ensure_style()
gtk_css_node_ensure_style() recurses over previous siblings to ensure
these have a style before its following sibling.  As seen in
https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/2027 this can
cause us to stack overflow and crash if we have a lot of children.

And even if we don't have *that* many children its still somewhat
bad to have stack depths of the same magnitude as the number of
children, both for performance reasons and debuggability.
2020-06-04 12:10:31 +02:00
Alexander Larsson
8707bab450 gtk-demo: Avoid list for children in GtkFishBowl
This is a demo that measures performance, so keep the child
info in a hashtable instead of a list. This means adding or removing
a child is not O(n-children).
2020-06-04 12:06:42 +02:00
Kjell Ahlstedt
612955f2b7 flowbox: Don't use a removed child after it has been unparented
In gtk_flow_box_remove(), call g_sequence_remove() before the child is unparented.

See MR !2029
2020-06-04 11:23:46 +02:00
Timm Bäder
36314c3ff7 Merge branch 'santo/gtk4_spelling_fix' into 'master'
docs: Fix spelling of GDK_VERSION_MIN_REQUIRED.

See merge request GNOME/gtk!2026
2020-06-04 07:38:58 +00:00
Daniel Mustieles
33fb38d8de Updated Spanish translation 2020-06-04 09:18:01 +02:00
Daniel Mustieles
38e2a910df Updated Spanish translation 2020-06-04 09:17:16 +02:00
Santosh Mahto
ef32df77be docs: Fix spelling of GDK_VERSION_MIN_REQUIRED. 2020-06-04 12:12:36 +05:30
Matthias Clasen
5154693ea4 Merge branch 'columnview-separators' into 'master'
Columnview separators

See merge request GNOME/gtk!2025
2020-06-03 23:34:48 +00:00
Matthias Clasen
4b68362981 columnview: Add a property for column separators
Rename the show-separators property to show-row-separators,
and add a matching show-column-separators property. It is
implemented by setting the .column-separators style class
on the column view.
2020-06-03 17:57:23 -04:00
Matthias Clasen
658e4c5357 listview: Use gtk_widget_add_css_class
No need to use the style context api for this anymore.
2020-06-03 17:51:22 -04:00
Matthias Clasen
ce0dd650d7 settings demo: Don't select rows
We want no selection here, so use GtkNoSelection.
2020-06-03 17:51:22 -04:00
Matthias Clasen
77b65ada4f Merge branch 'columnview-printdialog' into 'master'
Port the printdialog to column view

See merge request GNOME/gtk!2010
2020-06-03 21:47:58 +00:00
Matthias Clasen
fa37225a42 Merge branch 'columnview-rubberbanding' into 'master'
columnview: Implement rubberbanding

See merge request GNOME/gtk!2008
2020-06-03 21:46:13 +00:00
Matthias Clasen
78a06859b9 Merge branch 'columnview-expand' into 'master'
columnview: Implement expanding columns

See merge request GNOME/gtk!2007
2020-06-03 21:39:33 +00:00
Matthias Clasen
3ec8f4e84e Merge branch 'columnview-reordering' into 'master'
columnview: Implement interactive reordering

See merge request GNOME/gtk!2006
2020-06-03 21:38:59 +00:00
Matthias Clasen
f13a596d15 Merge branch 'columnview-resizing' into 'master'
columnview: Implement interactive resizing

See merge request GNOME/gtk!2004
2020-06-03 20:04:17 +00:00
Matthias Clasen
94f14778a3 Merge branch 'columnview-scrolling' into 'master'
columnview: Implement horizontal scrolling

See merge request GNOME/gtk!1998
2020-06-03 19:50:59 +00:00
Benjamin Otte
7312284e4f Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master

See merge request GNOME/gtk!2024
2020-06-03 17:40:26 +00:00
Matthias Clasen
ebc07d1458 printdialog: Port to column view 2020-06-03 13:35:09 -04:00
Matthias Clasen
510f719975 gtk-demo: Make gridview demo use rubberbanding 2020-06-03 13:34:28 -04:00
Matthias Clasen
03c2202942 Add rubberband api
Add an ::enable-rubberband property to GtkListView,
GtkGridView and GtkColumnView.
2020-06-03 13:34:27 -04:00
Matthias Clasen
b3a97cb755 listbase: Simplify rubberbanding
The new approach is:
 - plain: clear and start a new selection
 - extend: add to the existing selection
 - modify: subtract from the existing selection
2020-06-03 13:32:57 -04:00
Matthias Clasen
a9273e1c73 listbase: Split off rubberband data 2020-06-03 13:32:57 -04:00
Matthias Clasen
14d11ebcab listbase: Use a widget for the rubberband
We no longer need to juggle manual css nodes. Just create
a widget for the rubberband, and update its allocation
as we rubberband.
2020-06-03 13:32:57 -04:00
Matthias Clasen
7dc458d925 Add autoscroll
This is an expected feature with rubberband selection:
as you get close to the edge while doing rubberband
selection, the list scrolls to extend your selection.
2020-06-03 13:32:57 -04:00
Matthias Clasen
a0f04bdcf3 listbase: Add rubberband selection
Implement the typical rubberband selection, including
autoscroll. This is only useful with multiselection,
and not very compatible with single-click-activate.
Therefore, it is not enabled by default, and needs
to be turned on explicitly.
2020-06-03 13:32:57 -04:00
Matthias Clasen
28f6e27276 Add GtkMultiSelection
This is implemented using a private GtkSet helper.

Includes tests.
2020-06-03 13:32:57 -04:00
Matthias Clasen
5ef427bd65 gtk-demo: Expand columns in the settings demo
Expand the columns that are likely to appear
at the end.
2020-06-03 13:32:15 -04:00
Matthias Clasen
03c1fa43f4 inspector: Expand the actions list 2020-06-03 13:32:15 -04:00
Matthias Clasen
3b9f0ab866 inspector: Expand the resource list
This is an experiment with adding a filler column.
2020-06-03 13:32:15 -04:00
Matthias Clasen
9617a00ae3 inspector: Expand the property list
It looks better this way.
2020-06-03 13:32:15 -04:00
Matthias Clasen
1408199957 inspector: Expand the object tree
This is how it used to look, and it looks better that way.
2020-06-03 13:32:15 -04:00
Matthias Clasen
067df8d4dd columnview: Take expand into account
When allocating columns, distribute extra space
to columns that have expand set to TRUE.
2020-06-03 13:32:15 -04:00
Matthias Clasen
2ab1b13092 columnview: Add a GtkColumnViewColumn:expand property
This will be used to determine how to distribute
available extra space in a column view.
2020-06-03 13:32:15 -04:00
Matthias Clasen
964d0c219a columnview: Add autoscroll
Autoscroll when the pointer gets close to the
edge during column resizing or reordering. This
is similar to what the treeview does, but it is
implemented using a tick callback, and has
variable speed.
2020-06-03 13:31:39 -04:00
Matthias Clasen
c58eb9c276 columnview: Allow to cancel reorder with Escape
The treeview does this too.
2020-06-03 13:31:39 -04:00
Matthias Clasen
5d4893b3f0 columnview: Interactive column reordering
Allow rearranging columns by dragging, in the same
way the treeview does.

We add the "dnd" style class to the header while
it is dragged, and we move the header of the dragged
column to the end of its parents children, so that
it gets drawn on top.
2020-06-03 13:31:39 -04:00
Matthias Clasen
11b4e0d4c0 columnview: Add a GtkColumnView:reorderable property
This property controls if users can reorder columns
by drag-and-drop. It defaults to TRUE.
2020-06-03 13:31:39 -04:00
Matthias Clasen
e637693131 columnviewlayout: Use header allocation for titles
Normally, this will be identical to the column
allocation, but we will temporarily change it
during column reordering.
2020-06-03 13:31:39 -04:00
Matthias Clasen
c9d5b77403 columnviewcolumn: Add reordering helpers
Add helper functions that let us temporarily give
a different allocation to headers. These will be
used to implement interactive column reordering
in GtkColumnView.
2020-06-03 13:31:39 -04:00
Matthias Clasen
574595993c columnviewtitle: Trigger action on release
This is necessary to make drag-to-reorder work
without triggering resorting.
2020-06-03 13:31:31 -04:00
Matthias Clasen
50f4e53aef Merge branch 'matthiasc/for-master' into 'master'
gtk-demo: Add a dropdown demo

See merge request GNOME/gtk!2023
2020-06-03 17:30:19 +00:00
Matthias Clasen
ac082e5504 gtk-demo: Make some columns resizable
Make the columns in the List > Settings demo
resizable, to demonstrate this functionality.
2020-06-03 12:49:40 -04:00
Matthias Clasen
f65f9591a1 columnview: Interactive column resizing
This copies just enough of the treeview code to
get columns moving.
2020-06-03 12:49:40 -04:00
Matthias Clasen
a1eadde25b columnviewcolumn: Add a helper
We need to check whether clicks are in the headers
of columns, so let the column view get at the the
header widget.
2020-06-03 12:49:40 -04:00
Matthias Clasen
66e5027756 columnview: Add a GtkColumnViewColumn:resizable property
This will be used for interactive column resizing
in the future.
2020-06-03 12:49:38 -04:00
Matthias Clasen
aa2d339508 columnview: Add a helper
The column code needs to get access to the
listitem widgets that are children of the listview,
so add a getter.
2020-06-03 12:48:56 -04:00
Matthias Clasen
d43aacefc9 columnview: Add GtkColumnViewColumn:fixed-width
Add a fixed-width property similar to the same property
of GtkTreeViewColumn.
2020-06-03 12:48:39 -04:00
Matthias Clasen
f0a0e20b2f columnview: Implement horizontal scrolling
The listview inside always thinks it gets its full size,
and updates its horizontal adjustment accordingly.

So keep our own adjustment, and update it when allocating.
2020-06-03 12:48:20 -04:00
Matthias Clasen
befdd8bb66 columnview: Revise scroll-minimum handling
Tweak the behavior slightly. We don't show
a scrollbar as long as we have at least
min-size available, but we still give the
entire size to the child, up to nat-size.

This matches how viewports handle scroll-minimum.
2020-06-03 12:48:20 -04:00
Benjamin Otte
27ed2cc009 Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master

See merge request GNOME/gtk!2022
2020-06-03 16:33:54 +00:00
Benjamin Otte
a60c866a12 listbase: Don't grab_focus() when moving focus
We want to call gtk_widget_child_focus() to have Tab focus the right
widget.
2020-06-03 18:12:49 +02:00
Benjamin Otte
a84f6228ca listitemwidget: Fix focus handling for columnview
ListItemWidget needs to be aware of potentially having multiple
children, so make it aware.
2020-06-03 18:12:00 +02:00
Matthias Clasen
19da93b675 Merge branch 'columnview-menu' into 'master'
columnview: Add header menus

See merge request GNOME/gtk!2001
2020-06-03 15:51:26 +00:00
Benjamin Otte
aa38fc712f listbase: Fix leak
We were leaking the temporary tracker here.
2020-06-03 17:49:04 +02:00
Matthias Clasen
0b1c91dc7c gtk-demo: Add a dropdown demo
This shows a few examples of GtkDropDown.
Mostly taken from tests/testdropdown.c.
2020-06-03 11:34:06 -04:00
Matthias Clasen
ab2c8de4de Merge branch 'matthiasc/for-master' into 'master'
selection model: Further documentation tweaks

See merge request GNOME/gtk!2021
2020-06-03 15:11:59 +00:00
Benjamin Otte
00f2b134e3 columnview: Make sure focus can move into cells
The cells themselves should never be focusable though.
2020-06-03 16:55:39 +02:00
Benjamin Otte
0b8cebd6ef ffmediafile: Add fixes for recent cflags changes
Related: #2771
2020-06-03 16:23:49 +02:00
Matthias Clasen
53a9b7f6c0 selection model: Further documentation tweaks
Reword this to use plain language instead of throwing
arond reentrancy and ordering.
2020-06-03 07:51:29 -04:00
Matthias Clasen
667fd927ee Merge branch 'selection-model-docs' into 'master'
selectionmodel: Clarify docs

Closes #2806

See merge request GNOME/gtk!2017
2020-06-03 05:27:46 +00:00
Matthias Clasen
a8956838d3 selectionmodel: Clarify docs
Clarify some things that were not clear to me before
discussing them.

Fixes: #2806
2020-06-02 15:09:16 -04: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
Matthias Clasen
f6be407e33 Merge branch 'carlosgc/emoji-chooser-fixes' into 'master'
Fix emoji chooser warnings on destroy

See merge request GNOME/gtk!2016
2020-06-02 16:06:47 +00:00
Carlos Garcia Campos
2bf9b37e59 emojichooser: Unparent the variations popup on dispose and before adding a new one
This was causing warnings when destroying the emoji chooser because it
had children left.
2020-06-02 16:47:56 +02:00
Carlos Garcia Campos
d2e0ada794 textview: Unparent the emoji chooser on dispose
This was causing the warning "GtkEmojiChooser is not a child of
GtkTextView" when destroying a GtkTextView if the emoji chooser was
shown.
2020-06-02 16:47:56 +02:00
Matthias Clasen
c07ae5806e Merge branch 'matthiasc/for-master' into 'master'
Cosmetic improvements to the filebrowser demo

See merge request GNOME/gtk!2015
2020-06-02 04:30:29 +00:00
Matthias Clasen
5afe6f7825 Cosmetic improvements to the filebrowser demo
Make it look good.
2020-06-01 23:13:20 -04:00
Matthias Clasen
d02c48f987 Add more columns to the settings demo
Flesh out this demo more, so we can have a
non-trivial column editor here at some point.
2020-06-01 22:10:53 -04:00
Matthias Clasen
c835214540 Add a header menu to settings demo
Allow toggling column visibility from here.
2020-06-01 22:10:53 -04:00
Matthias Clasen
cb2901ec40 columnviewtitle: Display a context menu
When the ::header-menu property is set on the
column, use the menu model to create and show
a context menu.
2020-06-01 22:10:53 -04:00
Matthias Clasen
f27bd061fb columnviewcolumn: Add a menu property
Add a ::header-menu property that will be used
to create a context menu for the header of the
column.
2020-06-01 22:10:53 -04:00
Matthias Clasen
572386e4ce Merge branch 'matthiasc/for-master' into 'master'
print backend: Fix list model handling in dispose

See merge request GNOME/gtk!2013
2020-06-02 00:07:45 +00:00
Matthias Clasen
67a972182e Merge branch 'ebassi/expression-type' into 'master'
Ebassi/expression type

See merge request GNOME/gtk!2014
2020-06-01 22:48:26 +00:00
Matej Urbančič
5955e11a5a Added Slovenian translation 2020-06-01 22:19:55 +02:00
Emmanuele Bassi
8daaafc864 Document how to define properties using GtkExpression
Use the GtkParamSpecExpression type to describe the property, and the
GValue API to set and get the expression instance.
2020-06-01 21:17:34 +01:00
Emmanuele Bassi
ebaa96c0fa Turn GtkExpression into a GTypeInstance
Since it's a type with sub-classes, we need to use GTypeInstance (at the
very least), otherwise we won't be able to address each sub-class as
such.

This is similar to how GskRenderNode and GdkEvent are handled, with the
added difficulty that GtkExpression is meant to be used in properties,
in order to be deserialised by GtkBuilder. This requires adding a
GParamSpec sub-class that we can match on from within GtkBuilder,
alongside some convenience API for storing a GtkExpression inside a
GValue.
2020-06-01 21:07:53 +01:00
Emmanuele Bassi
fb3d08c651 Print out the file name we're testing
We're printing out the file we're testing once we succeed, but it's hard
to know which file caused a failure. Let's add a g_test_message()
directive so we can look in our logs.
2020-06-01 21:06:04 +01:00
Matthias Clasen
9d15e64f0b gtk-demo: Plug a leak
We were leaking a reference to the settings demo.
This showed up as gtk4-demo --run listview_settings
not exiting when the window is closed.
2020-06-01 15:17:21 -04:00
Matthias Clasen
b62564fd98 columnviewcolumn: Fix visibility implementation
We were not properly syncing initial visibility
with widgets.
2020-06-01 14:47:12 -04:00
Matthias Clasen
0266bcab7a Add a test for the previous fix
This checks that action muxer hierarchy is properly
updated when muxers appear in the middle.
2020-06-01 13:52:50 -04:00
Matthias Clasen
6652e14662 Update action muxer hierarchy propertly
When a new muxer appears, we must not only make it
inherit from the parent, we also have to update all
children to inherit from it.
2020-06-01 13:52:42 -04:00
Matthias Clasen
7a50f86f3f print backend: Fix list model handling in dispose
The print backends do some complicated dispose handling
where the implementations call gtk_print_backend_destroy().

Our tests (in particular, the templates test) trigger
situations where we use print backends after dispose,
and they can't handle the printers listmodel being
NULL at that time. So just remove the printers in
dispose, keep the empty liststore until finalize.
2020-06-01 13:52:21 -04:00
Kukuh Syafaat
59218d02c8 Update Indonesian translation 2020-06-01 13:29:20 +00:00
Matthias Clasen
fe73730d21 Merge branch 'gtk-demo-run-no-main-window' into 'master'
gtk-demo: Don't show main window if --run is passed in

See merge request GNOME/gtk!1979
2020-06-01 12:26:15 +00:00
Matthias Clasen
b814970bdd Merge branch 'fix-frameclock-going-backwards' into 'master'
Fix frameclock going backwards

See merge request GNOME/gtk!2011
2020-06-01 12:25:20 +00:00
Matthias Clasen
8dfbef5e6f Merge branch 'matthiasc/for-master' into 'master'
columnview: Add column reordering

See merge request GNOME/gtk!2005
2020-06-01 11:28:28 +00:00
Emmanuele Bassi
0b9a3fc160 Merge branch 'ebassi/scroll-position' into 'master'
Remove position from GdkScrollEvent

See merge request GNOME/gtk!2012
2020-06-01 10:32:55 +00:00
Emmanuele Bassi
79105962a7 Remove position from GdkScrollEvent
Scroll events do not have a position, so they shouldn't implement the
GdkEventClass.get_position() virtual function; nor they should have an x
and y fields that never get updated.
2020-06-01 10:49:33 +01:00
Alexander Larsson
a36e2bc764 Fix frameclock going backwards
When we run the frameclock RUN_FLUSH_IDLE idle before the paint,
then gdk_frame_clock_flush_idle() sets
```
  priv->phase = GDK_FRAME_CLOCK_PHASE_BEFORE_PAINT
```
at the end if there is a paint comming.

But, before doing the paint cycle it may handle other X events, and
during that time the phase is set to BEFORE_PAINT. This means that the
current check on whether we're inside a paint is wrong:

```
  if (priv->phase != GDK_FRAME_CLOCK_PHASE_NONE &&
     priv->phase != GDK_FRAME_CLOCK_PHASE_FLUSH_EVENTS)
    return priv->smoothed_frame_time_base;
```

This caused us to sometimes use this smoothed_frame_time_base even
though we previously reported a later value during PHASE_NONE, thus
being non-monotonic.

We can't just additionally check for the BEGIN_PAINT phase though,
becasue if we are in the paint loop actually doing that phase we
should use the time base. Instead we check for `!(BEFORE_PAINT &&
in_paint_idle)`.
2020-06-01 10:53:24 +02:00
Matthias Clasen
cc878160bd gtk-demo: Fix a crash in the puzzle
Avoid a crash when clicking the refresh button
after solving the puzzle.
2020-06-01 00:11:50 -04:00
Matthias Clasen
382153e82d gtk-demo: Fix keynav in the puzzle
We need to make shortcut controller have global
scope, otherwise the shortcuts lose against the
window keybindings.
2020-06-01 00:11:43 -04:00
Matthias Clasen
e195341e30 gtk-demo: Flesh out the settings demo
Add columns for type and default value.
2020-05-31 23:43:58 -04:00
Matthias Clasen
c6c8263704 columnview: Add column reordering
Add an API to allow reordering columns.
2020-05-31 21:56:30 -04:00
Matthias Clasen
ed02bea20d Merge branch 'action-tests' into 'master'
Action tests

See merge request GNOME/gtk!2003
2020-05-31 23:32:44 +00:00
Matthias Clasen
f89a1b05fe Merge branch 'matthiasc/for-master' into 'master'
Add a forgotten export

See merge request GNOME/gtk!2002
2020-05-31 22:54:38 +00:00
Matthias Clasen
af65b7e6d7 More action tests
Test actions under hierarchy changes.
2020-05-31 18:13:50 -04:00
Matthias Clasen
1995ad6d63 Add a forgotten export
gtk_column_view_sort_by was missing a GDK_AVAILABLE_IN_ALL
annotation, causing it to not be exported.
2020-05-31 16:47:53 -04:00
Matthias Clasen
83c0937a46 testsuite: Beef up action tests
Check return values from  gtk_widget_activate.
2020-05-31 16:40:50 -04:00
Matthias Clasen
f5cc2c0d20 Merge branch 'column-visible' into 'master'
columnview: Add a GtkColumnViewColumn:visible property

See merge request GNOME/gtk!1997
2020-05-31 20:39:06 +00:00
Emmanuele Bassi
931d68bc92 Merge branch 'drop-coverflow' into 'master'
Drop GtkCoverFlow for now

See merge request GNOME/gtk!2000
2020-05-31 19:12:32 +00:00
Yuri Chornoivan
06946c35d3 Update Ukrainian translation 2020-05-31 19:05:20 +00:00
Matthias Clasen
cbe81fd443 Merge branch 'drop-fallback-c89' into 'master'
Drop fallback-c89.c

See merge request GNOME/gtk!1999
2020-05-31 18:14:14 +00:00
Matthias Clasen
173e919d2a Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1995
2020-05-31 18:13:36 +00:00
Matthias Clasen
73fdb8f7b0 Drop GtkCoverFlow for now
There is no agreement that a coverflow widget is
appropriate for GTK 4.

It would be ok as a demo if it could live in gtk-demo,
but that requires us to make GtkListBase public first.
The demo is also somewhat rough and needs more work
to look plausible.

Drop GtkCoverFlow and the related demo for now.
2020-05-31 13:15:51 -04:00
Matthias Clasen
8e0ba37866 gtk-demo: Fixes for the sliding puzzle
We were calling check_solved only for key presses,
meaning you could never solve the puzzle with the
mouse.
2020-05-31 13:01:17 -04:00
Matthias Clasen
8780f50e7e gtk-demo: Some fixes to awards
Fix things up enough to make the list show up.
Still not a working example, but closer.
2020-05-31 13:01:17 -04:00
Matthias Clasen
06dc357ea0 printer: Fix the default value of icon-name
Just set this to "printer", so we don't have
to fix it up in the print dialog.
2020-05-31 13:01:17 -04:00
Matthias Clasen
fb587cb529 printbackend: Add a list model getter
Now that we have a list model for printers,
we can start using it.
2020-05-31 13:01:17 -04:00
Matthias Clasen
a026677849 printbackend: Use a list store 2020-05-31 13:01:17 -04:00
Matthias Clasen
1c389b1f24 gtk-demo: Add more scrolling benchmarks
Add a listview and gridview to the scrolling
benchmarks.
2020-05-31 13:01:17 -04:00
Emmanuele Bassi
55b9aa0309 Merge branch 'ebassi/annotations' into 'master'
Ebassi/annotations

See merge request GNOME/gtk!1996
2020-05-31 15:18:36 +00:00
Christoph Reiter
2d5cf2b4c4 Drop fallback-c89.c
We require a C compiler supporting C99 now. The main purpose of
these fallbacks was for MSVC. From what I can see this is now all supported
by MSVC 2015+ anyway.

The only other change this includes is to replace isnanf() with the
(type infering) C99 isnan() macro, because MSVC doesn't provide isnanf().
2020-05-31 17:09:23 +02:00
Matthias Clasen
4877bb5b5c columnviewcolumn: Add a visible property
This lets us hide columns, which is an expected
feature of columned lists.
2020-05-31 10:47:48 -04:00
Emmanuele Bassi
b9269d5644 Annotate the GtkFunctionListItemFactory constructor
But skip it, since it cannot really be used by language bindings, as it
binds the same user data to two separate functions.
2020-05-31 15:14:26 +01:00
Emmanuele Bassi
1a4723988e Fix annotations for gtk_cclosure_expression_new()
Missing scope annotations for the various functions.
2020-05-31 15:10:27 +01:00
Matthias Clasen
93353888ca Merge branch 'columnview-1' into 'master'
Convert the inspector to column views

See merge request GNOME/gtk!1994
2020-05-31 14:06:31 +00:00
Emmanuele Bassi
c3a90b76d0 Add missing separator
An annotation is separated from the description by a ':'.
2020-05-31 15:05:59 +01:00
Emmanuele Bassi
43e5ca9a1b docs: Fix annotations
- Use the same name for the argument in the declaration, definition,
   and documentation
 - Use "optional" instead of the deprecated "allow-none"
2020-05-31 15:04:51 +01:00
Christoph Reiter
c5829bd0e2 fallback-c89: Try to make isnanf work 2020-05-31 15:50:09 +02:00
Matthias Clasen
2a9d2cc7e9 inspector: Touch up list styling
This is just the minimal amount of work to make
headers recognizable.
2020-05-31 09:24:19 -04:00
Matthias Clasen
0d9873d8bc inspector: Use a column view for actions
A straight conversion from list box to column view.
2020-05-31 09:24:12 -04:00
Matthias Clasen
23bc38ed06 inspector: Make the resource list sortable
This is using a GtkTreeListRowSorter to keep expanded
state of the tree while changing the sorting.
2020-05-31 09:24:04 -04:00
Matthias Clasen
42d26b4b05 inspector: Use a column view for the resource list
A conversion from tree view to column view.
2020-05-31 09:23:51 -04:00
Matthias Clasen
04700789e1 inspector: Use a column view for properties
Just a straight conversion from list box to column view.
2020-05-31 09:23:45 -04:00
Matthias Clasen
e23baa59f0 inspector: Add columns to the object tree
Add columnview columns in the object tree.
We do the same for treeview columns.
2020-05-31 09:23:37 -04:00
Matthias Clasen
e8e28b61db Merge branch 'fix-mnemonic-zero' into 'master'
label: Fix mnemonic zero

Closes #2805

See merge request GNOME/gtk!1993
2020-05-31 13:02:51 +00:00
Yuri Chornoivan
b766707f28 Update Ukrainian translation 2020-05-31 06:12:49 +00:00
Yuri Chornoivan
0787f262a0 Update Ukrainian translation 2020-05-31 06:09:05 +00:00
Matthias Clasen
d833f4a632 Merge branch 'dropdown-for-merge' into 'master'
Dropdown for merge

Closes #2214

See merge request GNOME/gtk!1992
2020-05-31 05:34:18 +00:00
Matthias Clasen
ce1e364ab8 Merge branch 'listview-for-merge' into 'master'
Listview for merge

Closes #2214

See merge request GNOME/gtk!1991
2020-05-31 05:32:37 +00:00
Matthias Clasen
adb5b299c9 label: Fix mnemonic zero
We were confusing '\0' and '0' when parsing the label
for mnemonics.

Fixes: #2805
2020-05-30 21:42:54 -04:00
Matthias Clasen
fc9462d49e Add some tests for new GtkBuilder syntax
Some valid and invalid examples for <closure>,
<lookup> and <constant>.
2020-05-30 19:31:38 -04:00
Matthias Clasen
9c849d2084 docs: Update the list widget overview
Fill in the GtkComboBox and GtkCellView replacements
in the quick reference table.
2020-05-30 19:31:38 -04:00
Matthias Clasen
336b30c532 gtk-demo: Add a large grid demo
This is similar to the flowbox demo, but much bigger.
2020-05-30 19:31:38 -04:00
Matthias Clasen
b331e29e43 inspector: Use dropdowns in the visual page
Convert everything in the visual page to dropdowns.
2020-05-30 19:31:38 -04:00
Matthias Clasen
54cdafdd67 inspector: Use a dropdown for size groups
Use a GtkDropDown for the modes of size groups.
2020-05-30 19:31:38 -04:00
Matthias Clasen
30541201b6 inspector: Use a dropdown for controllers
Use a GtkDropDown for the phases of event controllers.
2020-05-30 19:31:38 -04:00
Matthias Clasen
6346fa960c inspector: Use a dropdown for attribute mapping
Use a GtkDropDown for the attribute mapping editor.
2020-05-30 19:31:38 -04:00
Matthias Clasen
99c98d0736 inspector: Use dropdowns in property editor
Replace combo boxes by dropdowns in the property editor.
2020-05-30 19:31:38 -04:00
Matthias Clasen
496e673d77 filechooser: Use a dropdown for choices 2020-05-30 19:31:38 -04:00
Matthias Clasen
d3aad3b574 filechooser: Use a dropdown for the filter combo
Replace an internal use of GtkComboBox with GtkDropDown.
2020-05-30 19:31:38 -04:00
Matthias Clasen
371dab51bb Add GtkDropDown
This is a simple drop down control using list models.
2020-05-30 19:31:38 -04:00
Benjamin Otte
3ea2258ce9 xxx: isnanf() is some wtf 2020-05-30 19:30:14 -04:00
Matthias Clasen
c7feae65f1 builderlistitemfactory: Precompile the xml
This is the one place where we can really take advantage
of precompiling, since we instantiate this template
over and over.
2020-05-30 19:30:14 -04:00
Matthias Clasen
b087948933 gtk-demo: Use single-click-activate for minesweeper
The explanation say we do, so do it.
2020-05-30 19:30:14 -04:00
Matthias Clasen
f611d55f16 Spread single-click-activate api
This makes sense to have in all the views,
not just GtkListView.
2020-05-30 19:30:14 -04:00
Matthias Clasen
12b1007046 docs: Add a listview overview section
Add a conceptual overview for all the listmodel-based
widgets.

Fixes: #2214
2020-05-30 19:30:14 -04:00
Matthias Clasen
4a4c15b2ac gtk-demo: Add filtering to the settings demo
A demo of filtering with lists was missing so far.
2020-05-30 19:30:14 -04:00
Matthias Clasen
8804427677 gtk-demo: Demo columnview sorting
Enhance the settings demo to have a sortable column.
2020-05-30 19:30:14 -04:00
Matthias Clasen
d717971f41 gtk-demo: Cosmetic improvements to the listview demos
Set default sizes, window titles and add more
detail to the descriptions.
2020-05-30 19:30:14 -04:00
Matthias Clasen
f33df84eff gtk-builder-tool: Minimally validate <binding>
Check that the toplevel property name is legit.
2020-05-30 19:30:14 -04:00
Benjamin Otte
7910271b6c testsuite: Add tests for GtkTreeListSorter 2020-05-30 19:30:14 -04:00
Matthias Clasen
e3ce99988f Add GtkTreeListRowSorter
This is a special-purpose sorter that can
apply the sorting of another sorter to the
levels of a GtkTreeListModel.
2020-05-30 19:30:14 -04:00
Benjamin Otte
fb78f1ef8e testcolumnview: Add sorters 2020-05-30 19:28:30 -04:00
Matthias Clasen
1ba1eda8ab column view title: Show sort indicators 2020-05-30 19:28:30 -04:00
Matthias Clasen
2945430ad7 columnview: Add a sort-by api 2020-05-30 19:28:28 -04:00
Matthias Clasen
66500a6882 columnview: Add sorting
This is a somewhat large commit that:

- Adds GtkColumnViewSorter
This is a special-purpose, private sorter implementation which sorts
according to multiple sorters, allowing each individual sorter to be
inverted. This will be used with clickable column view headers.

- Adds a read-only GtkColumnView::sorter property
The GtkColumnView creates a GtkColumnViewSorter at startup that it uses
for this property.

- Adds a writable GtkColumnViewColumn::sorter property
This allows defining per-column sorters. Whenever an application sets a
sorter for a column, the header becomes clickable and whenever
a header is clicked, that column's sorter is prepended to the list of
sorters, unless it is already the first sorter, in which case we invert
its order. No column can be in the list more than once.
2020-05-30 19:26:46 -04:00
Matthias Clasen
2c4c07c96d listview: Add single-click-activate
Add a single-click-activate property to GtkListView.
2020-05-30 19:26:46 -04:00
Matthias Clasen
69c86ae385 listitemwidget: Add single-click-activate
Add a mode to GtkListItemWidget that activates on
single click and selects on hover. Make
GtkListItemManager set this on its items
when its own 'property' of the same name is set.
2020-05-30 19:26:46 -04:00
Matthias Clasen
21eac434c3 builder-tool: Pass through CDATA where it makes sense
This avoids a ton of escaping for
GtkBuilderListItemFactory::bytes.
2020-05-30 19:26:46 -04:00
Matthias Clasen
2f21003064 docs: Reorganize list widgets in their own chapter 2020-05-30 19:26:46 -04:00
Benjamin Otte
58b65d1bf6 fontchooserwidget: Port to listmodels
The port is kind of evil, in that it stores either a PangoFontFamily or a
PangoFontFace in the list, depending on if the fontchooser is configured
to select fonts or faces.
It also does not cache the font description anymore, so more calls to
pango_font_describe() may happen.

If both of these issues turn out problematic, the fontchooser would need
to resurrect GtkDelayedFontDescription again and put objects of that
type through the model.

These changes depend on Pango 1.46's introduction of listmodels and
various new getters, so the dependency has been upgraded.
2020-05-30 19:26:46 -04:00
Matthias Clasen
542829ee81 Add some tests for expression binding
In particular, test that expressios can deal with object == this.
2020-05-30 19:26:46 -04:00
Benjamin Otte
b43c8ae646 expression: Allow passing a this object to bind()
This gives a bit more control over the arguments passed to expressions.
2020-05-30 19:26:46 -04:00
Benjamin Otte
22e6fa3a64 gtk-demo: Add a Clocks demo
This demo is meant to showcase expressions.

It also needs the fixes in glib 2.64 to work properly.
2020-05-30 19:26:46 -04:00
Benjamin Otte
c337887e29 xxx: Add a hack to make paintables transform to/from objects
See also: https://gitlab.gnome.org/GNOME/glib/merge_requests/1251
2020-05-30 19:26:46 -04:00
Benjamin Otte
650688c635 inspector: Remove private struct for prop editor 2020-05-30 19:26:46 -04:00
Benjamin Otte
2787e916b2 inspector: Make Controller page a GtkWidget 2020-05-30 19:26:46 -04:00
Benjamin Otte
e72119e9bb inspector: Remove private struct from controllers 2020-05-30 19:26:46 -04:00
Benjamin Otte
efcb3a9d67 columnview: Add header
This uses a custom GtkColumnViewTitle widget. So far that widget is
pretty boring, but that will change once we added
resizing, reordering, dnd, sorting, hiding/showing of columns or
whatever UIs we want.
2020-05-30 19:26:46 -04:00
Benjamin Otte
9f19699806 tests: Add testcolumnview 2020-05-30 19:26:46 -04:00
Benjamin Otte
326cb1148b columnview: Add a custom LayoutManager
The ColumnView now allocates column widths first and then the individual
rows use the new layout manager which looks at the column allocations to
allocate their children.
2020-05-30 19:26:46 -04:00
Benjamin Otte
767e7cb06f constraint-editor: Don't poke around in widget internals 2020-05-30 19:26:46 -04:00
Benjamin Otte
084725e280 columnview: Fix styling with Adwaita
- Use "treeview" as the node name
- Add .view style class
2020-05-30 19:26:46 -04:00
Benjamin Otte
6e3b6980de inspector: Port object tree to GtkColumnView 2020-05-30 19:26:46 -04:00
Benjamin Otte
9927d9bda2 columnview: Add GtkColumnViewCell
It's a GtkListItemWidget subclass that tracks the column it belongs to
and allows the column to track it.

We also use this subclass to implement sizing support so columns share
the same size and get resized in sync.
2020-05-30 19:26:46 -04:00
Benjamin Otte
34c6ef5332 widget: Add a hook for resizes
It's private, no APIs, we don't talk about it. But we will start using
it very soon, so we can do size request caching in columns and avoid
sizegroups...
2020-05-30 19:26:46 -04:00
Benjamin Otte
8af3e407c2 columnview: Implement GtkScrollable
Just forward it to the listview for now.
2020-05-30 19:26:46 -04:00
Benjamin Otte
8736343544 columnview: Add listitems for the columns
They are not aligned in columns yet, but they do exist.
2020-05-30 19:26:46 -04:00
Benjamin Otte
9caca0b127 listitemwidget: Lazily create listitems
We only create them in root/unroot (they should be created in
appear/disappear, but that vfunc doesn't exist yet), that way we can
avoid expensive work while the widget isn't used for anything.
2020-05-30 19:26:46 -04:00
Benjamin Otte
9d86020d4c listitem: Move position/item/selected tracking to widget
This way, we can ensure it's always there when we need it (before the
item gets created) and gone when we don't (if some GC language holds on
to the item after we've destroyed the widget).
2020-05-30 19:26:46 -04:00
Benjamin Otte
32eedec565 listitemwidget: Add a private struct
I had to rename the item property to list_item anyway, so I could just
do the next step with it.
2020-05-30 19:26:46 -04:00
Benjamin Otte
1af004361c listitemfactory: Simplify
Instead of 6 vfuncs, we now have 3 and rely on the factory keeping track
of what it needs to do.

We're doing lots of dancing from one object to another here, but this
will hopefully get simpler with further commits.
2020-05-30 19:26:46 -04:00
Benjamin Otte
b33c56819b listitemfactory: Reorganize vfuncs
Instead of bind/rebind/update/unbind, we now just have update, and the
factories get to interpret that in the way they want.
2020-05-30 19:26:46 -04:00
Benjamin Otte
30f09ea10b listitem: Make this a GObject
This splits GtkListItem into 2 parts:

1. GtkListItem
   This is purely a GObject with public API for developers who want to
   populate lists. There is no chance to cause conflict with GtkWidget
   properties that the list implementation assumed control over and
   defines a clear boundary.
2. GtkListItemWidget
   The widget part of the listitem. This is not only fully in control of
   the list machinery, the machinery can also use different widget
   implementations for different list widgets like I inted to for
   GtkColumnView.
2020-05-30 19:26:46 -04:00
Benjamin Otte
db3e225f09 builder: Make gtk_builder_extend_with_template() work with objects
This will be relevant later when we introduce GtkListItem which is not a
GtkWidget.
2020-05-30 19:26:46 -04:00
Benjamin Otte
a44c06b264 gtk-demo: Add a Coverflow application launcher
This is roughly the simplest demo I could come up with.

But I documented it, so there's your tutorial.

Related: #2214
2020-05-30 19:26:46 -04:00
Benjamin Otte
f5f9f70dd0 Add GtkSignalListItemFactory
So the poor Rust users can actually use this.

I would totally not use this ever!
2020-05-30 19:26:46 -04:00
Benjamin Otte
03e5c6e32d columnview: Allow adding/removing columns
... and make that work in UI files via <child>, too.
2020-05-30 19:26:46 -04:00
Benjamin Otte
ca9e0c0e68 gtk-demo: Add a minesweeper demo
The demo shows creating ones own listmodel and using it to fill a grid.

I am totally getting the hang of React btw:
500 lines of logic with no UI code and 100 lines of GtkBuilder XML and
I get a sweet UI.
2020-05-30 19:26:46 -04:00
Benjamin Otte
0e1632d002 Add GtkColumnView skeleton
It's just a copy/paste of the listview code with all the internals
gutted. The code doesn't do anything.
2020-05-30 19:26:46 -04:00
Benjamin Otte
f4eb026c86 wip: Add GtkCoverFlow
The widget mostly works out of the box, but some tweaking may be
necessary (in particular in the theme) and the gtk-demo changes might
require removing before this is production-ready.
2020-05-30 19:26:46 -04:00
Benjamin Otte
e46fa81927 listbase: Take over anchor handling
With that, pretty much all code but allocating the widgets is gone from
the gridview and listview.
2020-05-30 19:26:46 -04:00
Benjamin Otte
33c6b428f7 listbase: Add vfuncs to convert positions to/from coordinates
... and use that to implement PageUp/PageDown.

With that, all keyboard handling has been moved to GtkListBase.
2020-05-30 19:26:46 -04:00
Benjamin Otte
12331e3376 listbase: Move focus moving keybindings here
The focus tracker is not yet moved because that depends on scroll_to()
support and we don't have that yet.
Whoops.
So we use a hack.
2020-05-30 19:26:46 -04:00
Benjamin Otte
dd5e6d47db Remove gtk_selection_model_user_select_item() again
This reverts commit 6a164ab306dad9096bde736c907494c71086d3c4.

The function was awkward and we now have only one caller again, so we
can fold it back into it.
2020-05-30 19:26:46 -04:00
Benjamin Otte
2541037ec2 listbase: Move orientable implementation here 2020-05-30 19:26:46 -04:00
Benjamin Otte
9d6aa7d88e listbase: Move selection handling here 2020-05-30 19:26:46 -04:00
Benjamin Otte
0bd16308d6 listbase: Move item manager here
Nothing really changes, because both ListView and GridView still keep
self->item_manager around, but it's set up to point at the base's item
manager.

This way we can slowly move things to GtkListBase that need the item
manager (like trackers).
2020-05-30 19:26:46 -04:00
Benjamin Otte
0011ce949c listbase: Move GtkScrollable implementation
Shared code between GtkGridView and GtkListView.
2020-05-30 19:26:46 -04:00
Benjamin Otte
cc987b31ae Add GtkListBase
This is a base item for GTK's list widgets so they can share some (read:
hopefully a lot of) code.
2020-05-30 19:26:46 -04:00
Benjamin Otte
c092d0a616 gridview: Simplify allocation code
It doesn't fix the bug I'm after, but it looks a lot better.
2020-05-30 19:26:46 -04:00
Benjamin Otte
ea390a4a73 listview: Port various gridview improvements
- Handle anchor as align + top/bottom
  This fixes behavior for cells that are higher than the view
- Add gtk_list_view_adjustment_is_flipped()
  This should fix RTL handling of horizontal lists
- Fix scrolling
  This should make scrolling more reliable, particularly on short lists
  that are only a few pages long.
2020-05-30 19:26:46 -04:00
Benjamin Otte
6b98948f9a demo: Add a file browser demo 2020-05-30 19:26:46 -04:00
Benjamin Otte
f57afe51af gridview: Add move keybindings 2020-05-30 19:26:46 -04:00
Benjamin Otte
bc22d04737 gridview: Implement (un)select all
Adds listitem.select-all and listitem.unselect-all actions and installs
the same keybindings as the treeview for those actions.
2020-05-30 19:26:46 -04:00
Benjamin Otte
093677b0f8 gridview: Add a focus tracker
... and use that to properly update selections when moving around with
the arrow keys.
2020-05-30 19:26:46 -04:00
Benjamin Otte
c38e050cc7 gridview: Implement list.scroll-to action 2020-05-30 19:26:46 -04:00
Benjamin Otte
ba0122fd02 gridview: Add activation 2020-05-30 19:26:46 -04:00
Benjamin Otte
affd2737d5 gridview: Implement minimum row height
We only allocate a certain amount of widgets - and we don't want to run
out of them. So we make all widgets high enough for this to never
happen.
2020-05-30 19:26:46 -04:00
Benjamin Otte
cc68073af0 gridview: Implement the list.select-item action 2020-05-30 19:26:46 -04:00
Benjamin Otte
cb2948eda6 selectionmodel: Add gtk_selection_model_user_select_item()
I'm not sure this should be public API because it's incredibly awkward.
But it should definitely be shared between list widget implementations.
2020-05-30 19:26:46 -04:00
Benjamin Otte
1b105cdbef gridview: Implement anchors and scrolling 2020-05-30 19:26:45 -04:00
Benjamin Otte
dd436e8fe6 listitemmanager: Handle NULL factory
Just don't call it and create empty listitems.
2020-05-30 19:26:45 -04:00
Timm Bäder
a8d2bb6b22 demo: Use a listview as sidebar 2020-05-30 19:26:45 -04:00
Benjamin Otte
fcdc5030bd gtk-demo: Introduce awards
We need a way to get a useful listbox, so here we go!
2020-05-30 19:26:45 -04:00
Benjamin Otte
aad9adf8c3 builder: Autofill scope property of listitemfactory
I couldn't come up with a better way to automatically inherit the scope
in the builder list item factory that didn't involve a magic
incantation in the XML file. And I do not want developers to know magic
incantations to do a thing that should pretty much always be done.
2020-05-30 19:26:45 -04:00
Benjamin Otte
48a223abdf builderlistitemfactory: Add scope argument
This way, the scope used when creating builder instances can be
influenced. This way, callbacks can be passed into the factory.
2020-05-30 19:26:45 -04:00
Benjamin Otte
12e720fb23 listitemfactory: Make the builder factory properly buildable
Turn the construct arguments into construct properties so that they can
be set from ui files.
2020-05-30 19:26:45 -04:00
Benjamin Otte
042e13a932 listview: Add move keybindings
My god, these are a lot.

And my god, these are complicated to get right.
2020-05-30 19:26:45 -04:00
Benjamin Otte
2b9481ecdc listview: Add gtk_list_view_get_position_at_y() 2020-05-30 19:26:45 -04:00
Benjamin Otte
933c0c678a listitem: Add "listitem.select" action and keybindings for it
In fact, grab space with all modifiers to toggle selection of the
current item.
2020-05-30 19:26:45 -04:00
Benjamin Otte
2539828eac listview: Add a focus tracker
This ensures that the row with the input focus always stays available,
even when scrolled out of view.
2020-05-30 19:26:45 -04:00
Benjamin Otte
4b6f3e0f2c listview: Implement (un)select all
Adds listitem.select-all and listitem.unselect-all actions and installs
the same keybindings as the treeview for those actions.
2020-05-30 19:26:45 -04:00
Benjamin Otte
b9eb818b57 listview: Track focus movements and update selection
When focus moves via tab/arrow, we need to select the new item.
2020-05-30 19:26:45 -04:00
Benjamin Otte
eda547fc4e listview: Implement activation
- a GtkListview::activate signal
- a GtkListItem::activatable property
- activate list items on double clicks and <Enter> presses
2020-05-30 19:26:45 -04:00
Benjamin Otte
1dbd017766 treeexpander: Implement input support
This implements all the keybindings from GtkTreeView that can be
supported.

It does not implement expand-all, because supporting that means
causing the TreeListModel to emit lots of create_model vfuncs which in
turn would cause many items-changed signal which in turn would cause
many signal handlers to run which in turn would make "expand-all" very
reentrant, and I'm uneasy about supporting that.

For the mouse, just add a click gesture to the expander icon that toggles
expanded state.
2020-05-30 19:26:45 -04:00
Benjamin Otte
08d9a57c6e listitem: Change focus handling
Focus in the listitem now works like this:
1. If any child can take focus, do not ever attempt
   to take focus.
2. Otherwise, if this item is selectable or activatable,
   allow focusing this widget.

This makes sure every item in a list is focusable for
activation and selection handling, but no useless widgets
get focused and moving focus is as fast as possible.
2020-05-30 19:26:45 -04:00
Benjamin Otte
d7b5966fa7 inspector: Make the recorder node list use a ListView
It's quite a bit faster now, but the code is also a bit more awkward.

Pain points:

- GtkTreeListModel cannot be created in UI files because it needs
  a CreateModelFunc.
  Using a signal for this doesn't work because autoexpand wants to
  expand the model before the signal handler is connected.

- The list item factory usage is still awkward. It's bearable here
  because the list items are very simple, but still.
2020-05-30 19:26:45 -04:00
Benjamin Otte
bb44120ae3 inspector: Use a GtkTreeExpander in the object tree 2020-05-30 19:26:45 -04:00
Benjamin Otte
8b1f034242 inspector: Use a treeexpander in the recorder 2020-05-30 19:26:45 -04:00
Benjamin Otte
bb7968ba77 demo: Add a GSettings tree demo
It is meant to look somewhat like dconf-editor when it is done.

So far, it's just a list.
2020-05-30 19:26:45 -04:00
Benjamin Otte
7451e51619 Add GtkTreeExpander
This is a container widget that takes over all the duties of tree
expanding and collapsing.
It has to be a container so it can capture keybindings while focus is
inside the listitem.

So far, this widget does not allow interacting with it, but it shows the
expander arrow in its correct state.

Also, testlistview uses this widget now instead of implementing
expanding itself.
2020-05-30 19:26:45 -04:00
Benjamin Otte
ea93e18081 gridview: Actually do something
Implement measuring and allocating items - which makes the items appear
when drawing and allows interacting with the items.

However, the gridview still does not allow any user interaction
(including scrolling).
2020-05-30 19:26:45 -04:00
Benjamin Otte
443e44853a listview: Pass the CSS name of listitems to the manager
... instead of hardcoding "row".
2020-05-30 19:26:45 -04:00
Benjamin Otte
b73e95655d gridview: Implement GtkOrientable
Again, this is just the skeleton, because the Gridview does nothing yet.
2020-05-30 19:26:45 -04:00
Benjamin Otte
e8bb84e0e2 gridview: Add factory handling
Just copy the listview APIs.

Code still doesn't do anything with it.
2020-05-30 19:26:45 -04:00
Benjamin Otte
626c525706 listview: Expose GtkListItemFactory APIs
Due to the many different ways to set factories, it makes sense to
expose them as custom objects.

This makes the actual APIs for the list widgets simpler, because they
can just have a regular "factory" property.

As a convenience function, gtk_list_view_new_with_factory() was added
to make this whole approach easy to use from C.
2020-05-30 19:26:45 -04:00
Benjamin Otte
2ef2148fb5 gtk-demo: Add a rough start at a Weather demo
This demos a horizontal listview.
2020-05-30 19:26:45 -04:00
Benjamin Otte
86ad1bec16 listview: Implement GtkOrientable 2020-05-30 19:26:45 -04:00
Benjamin Otte
360a728d77 tests: Add a rough form of multiselection
Just store a "filechooser::selected" attribute in the GFileInfo if
the file is meant to be selected.
2020-05-30 19:26:45 -04:00
Benjamin Otte
cfcf0a7a8a listview: Implement extending selections
Shift-clicking to extend selections now also works, imitating the
behavior of normal clicking and Windows Explorer (but not treeview):

1. We track the last selected item (normally, not via extend-clicking).

2. When shift-selecting, we modify the range from the last selected item
   to this item the same way we modify the regular item when not using
   shift:

2a. If Ctrl is not pressed, we select the range and unselect everything
    else.

2b. If Ctrl is pressed, we make the range have the same selection state
    as the last selected item:
    - If the last selected item is selected, select the range.
    - If the last selected item is not selected, unselect the range.
2020-05-30 19:26:45 -04:00
Benjamin Otte
f57fca7a00 listview: Add list.scroll_to_item action
The action scrolls the given item into view.

Listitems activate this action when they gain focus.
2020-05-30 19:26:45 -04:00
Benjamin Otte
7c38ac1954 testlistview: Load icons async
Speeds up loading by 4x, because out of view icons aren't loaded
anymore.
2020-05-30 19:26:45 -04:00
Benjamin Otte
dbe802f685 testlistview: Port to directory list 2020-05-30 19:26:45 -04:00
Benjamin Otte
cfb293d396 listitemfactory: Add a factory for ui files
Reuse <template> magic to initialize GtkListItems. This feels
amazingly hacky, but it also amazingly worked on the first try.
2020-05-30 19:26:45 -04:00
Benjamin Otte
2227fb957f listitemfactory: Split implementation out
.. into gtkfunctionslistitemfactory.c

Now we can add a different implmenetation.
2020-05-30 19:26:45 -04:00
Benjamin Otte
824326a029 listitemfactory: vfuncify
No functional changes other than a new indirection.
2020-05-30 19:26:45 -04:00
Benjamin Otte
10b967ae1f listitemfactory: Sanitize APIs
Make sure the APIs follow a predictable path:

setup
  bind
    rebind/update (0-N times)
  unbind
teardown

This is the first step towards providing multiple different factories.
2020-05-30 19:26:45 -04:00
Benjamin Otte
0174bf4345 listview: Add gtk_list_view_set_show_separators()
Do the same thing that GtkListBox does in commit
0249bd4f8a
2020-05-30 19:26:45 -04:00
Benjamin Otte
1acfae8df2 listitemmanager: Add trackers
... and replace the anchor tracking with a tracker.

Trackers track an item through the list across changes and ensure that
this item (and potentially siblings before/after it) are always backed
by a GtkListItem and that if the item gets removed a replacement gets
chosen.

This is now used for tracking the anchor but can also be used to add
trackers for the cursor later.
2020-05-30 19:26:45 -04:00
Benjamin Otte
ce489f21fb listitemmanager: Simplify
Remove a bunch of API from the headers that isn't used anymore and then
refactor code to not call it anymore.

In particular, get rid of GtkListItemManagerChange and replace it with a
GHashTable.
2020-05-30 19:26:45 -04:00
Benjamin Otte
368f04e06b gridview: Implement GtkScrollable
We can now scroll all the nothing we display.

We also clip it properly.
2020-05-30 19:26:45 -04:00
Benjamin Otte
dc91782165 listitemmanager: Move list of listitems here
All the listview infrastructure moved with it, so the next step is
moving that back...
2020-05-30 19:26:45 -04:00
Benjamin Otte
86a75abe51 gridview: Add API for setting number of columns
The API isn't used yet.
2020-05-30 19:26:45 -04:00
Benjamin Otte
70aaecc937 gtk: Add a GtkGridView skeleton 2020-05-30 19:26:45 -04:00
Benjamin Otte
057effc5d6 listitem: Add a press gesture to select the item
This is implemented by using actions, which are a neat trick to get to
allow the ListItem to call functions on the ListView without actually
needing to be aware of it.
2020-05-30 19:26:45 -04:00
Benjamin Otte
d8c116f20a listview: Add initial support for displaying selections 2020-05-30 19:26:45 -04:00
Benjamin Otte
01386aef29 listview: Reset listitems' CSS animations when rebinding
This way, newly displayed rows don't play an unselect animation (text
fading in) when they are unselected, but the row was previously used for
a selected item.
2020-05-30 19:26:45 -04:00
Benjamin Otte
b3fb80c608 listview: Add selection properties to ListItem
This just brings the infrastructure into place, we're not using the
properties yet.
2020-05-30 19:26:45 -04:00
Benjamin Otte
5b69fd535d listview: Try to keep the list items in order when scrolling
Instead of just destroying all items and then recreating them (or even
hide()ing and then show()ing them again (or even even repositioning
them in the widget tree)), just try to reust them in the order they are.

This works surprisingly well when scrolling and most/all widgets
just moved.
2020-05-30 19:26:45 -04:00
Benjamin Otte
7831980c1d listlistmodel: Add gtk_list_list_model_item_moved()
Use it to fix a case that just said g_warning ("oops").

Apparently I had forgotten the case where a container moved a child
in the widget tree.
2020-05-30 19:26:45 -04:00
Benjamin Otte
fbfc7dc690 listitemmanager: Switch from "insert_before" to "insert_after" argumnet
We reorder widgets start to end, so when reusing a list item, we
correctly know the previous sibling for that list item, but not the
next sibling yet. We just know the widget it should ultimately be in
front of.
So we can do a more correct guess of the list item's place in the widget
tree if we think about where to place an item like this.

Actually using this change will come in the next commit.
2020-05-30 19:26:45 -04:00
Benjamin Otte
d8eec549f0 testlistview: Create widgets only once
Previously, we were recreating all widgets every time the list item was
rebound, which caused a lot of extra work every time we scrolled.

Now we keep the widgets around and only set their properties again when
the item changes.
2020-05-30 19:26:45 -04:00
Benjamin Otte
7389e704dc testlistview: Show the row number
Always show the current row. This is mostly useful for debugging, not
for beauty.
2020-05-30 19:26:45 -04:00
Benjamin Otte
b64da6d268 listview: Only allocate necesary rows
This is the big one.

The listview only allocates 200 rows around the visible row now.
Everything else is kept in ListRow instances with row->widget == NULL.

For rows without a widget, we assign the median height of the child
widgets as the row's height and then do all calculations as if there
were widgets that had requested that height (like setting adjustment
values or reacting to adjustment value changes).

When the view is scrolled, we bind the 200 rows to the new visible area,
so that the part of the listview that can be seen is always allocated.
2020-05-30 19:26:45 -04:00
Benjamin Otte
2ba2a216ca listview: Change anchor handling again
The anchor is now a tuple of { listitem, align }.

Using the actual list item allows keeping the anchor across changes
in position (ie when lists get resorted) while still being able to fall
back to positions (list items store their position) when an item gets
removed.

The align value is in the range [0..1] and defines where in the visible
area to do the alignment.
0.0 means to align the top of the row with the top of the visible area,
1.0 aligns the bottom of the widget with the visible area and 0.5 keeps
the center of the widget at the center of the visible area.
It works conceptually the same as percentages in CSS background-position
(where the background area and the background image's size are matched
the same way) or CSS transform-origin.
2020-05-30 19:26:45 -04:00
Benjamin Otte
e5add36a17 listview: Change how binding is done
We now don't let the functions create widgets for the item from the
listmodel, instead we hand out a GtkListItem for them to add a widget
to.

GtkListItems are created in advance and can only be filled in by the
binding code by gtk_container_add()ing a widget.
However, they are GObjects, so they can provide properties that the
binding code can make use of - either via notify signals or GBinding.
2020-05-30 19:26:45 -04:00
Benjamin Otte
fe14181d4e listitem: Add gtk_list_item_get_position()
Also refactor the whole list item management yet again.

Now, list item APIs doesn't have bind/unbind functions anymore, but only
property setters.

The item factory is the only one doing the binding.
As before, the item manager manages when items need to be bound.
2020-05-30 19:26:45 -04:00
Benjamin Otte
378a573cf4 tests: Make animating listview do random resorts 2020-05-30 19:26:45 -04:00
Benjamin Otte
ec8684e87d listview: Change change management
Add a GtkListItemManagerChange object that tracks all removed list
rows during an item-changed signal so they can be added back later.
2020-05-30 19:26:45 -04:00
Benjamin Otte
54042029d3 listview: Make the listitemmanager stricter
Require that items created with the manager get destroyed via the
manager.

To that purpose, renamed create_list_item() to acquire_list_item() and
add a matching release_list_item() function.

This way, the manager can in the future keep track of all items and
cache information about them.
2020-05-30 19:26:45 -04:00
Benjamin Otte
e1fa627158 listview: Add GtkListItem
GtkListItem is a generic row widget that is supposed to replace
GtkListBoxRow and GtkFlowBoxChild.
2020-05-30 19:26:45 -04:00
Benjamin Otte
9d5bb875b1 listview: Add GtkListItemManager
It's all stubs for now, but here's the basic ideas about what
this object is supposed to do:

(1) It's supposed to be handling all the child GtkWidgets that are
    used by the listview, so that the listview can concern
    itself with how many items it needs and where to put them.
(2) It's meant to do the caching of widgets that are not (currently)
    used.
(3) It's meant to track items that remain in the model across
    items-changed emissions and just change position.
(2) It's code that can be shared between listview and potential
    other widgets like a GridView.

It's also free to assume that the number of items it's supposed to
manage doesn't grow too much, so it's free to use O(N) algorithms.
2020-05-30 19:26:44 -04:00
Benjamin Otte
b3c150e929 listview: Implement an anchor
The anchor selection is very basic: just anchor the top row.

That's vastly better than any other widget already though.
2020-05-30 19:26:44 -04:00
Benjamin Otte
d03a55599b tests: Add a test for a permanently changing listview
This is mostly for dealing with proper anchoring and can be used to
check that things don't scroll or that selection and focus handling
properly works.

For comparison purposes, a ListBox is provided next to it.
2020-05-30 19:26:44 -04:00
Benjamin Otte
ed8fe6c219 listview: Implement GtkScrollable
Scrolling in a very basic form is also supported
2020-05-30 19:26:44 -04:00
Benjamin Otte
c835ae2a02 listview: Make widget actually do something
The thing we're actually doing is create and maintain a widget for every
row. That's it.

Also add a testcase using this. The testcase quickly allocates too many
rows though and then becomes unresponsive though. You have been warned.
2020-05-30 19:26:44 -04:00
Benjamin Otte
e20c207a22 listview: Introduce GtkListItemFactory
Thisis the abstraction I intend to use for creating widgets and binding
them to the item out of the listview.

For now this is a very dumb wrapper around the functions that exist in
the API.

But it leaves the freedom to turn this into public API, make an
interface out of it and most of all write different implementations, in
particular one that uses GtkBuilder.
2020-05-30 19:26:44 -04:00
Benjamin Otte
e19c4a3372 gtk: Add a GtkListView skeleton 2020-05-30 19:26:44 -04:00
Benjamin Otte
934bfc8887 builder: Add <binding> tag
The tag contains an expression that it then gtk_expression_bind()s to
the object it is contained in.
2020-05-30 19:26:44 -04:00
Benjamin Otte
713a6676ff builder: Allow text content in <lookup>
<lookup>foo</lookup>
is now short for
  <lookup>
    <constant>foo</constant>
  </lookup>
ie it looks up the object with the given name so it can then do a
property lookup with it.

This is the most common operation, so it's a nice shortcut.
2020-05-30 19:26:44 -04:00
Benjamin Otte
448a88e4f5 builder: Allow <constant> without a type
A constant without a type is assumed to be an object. This is the most
common case and allows
  <constant>foo</constant>
without requiring updates to the type whenever the foo object changes.
2020-05-30 19:26:44 -04:00
Benjamin Otte
ed22af50bc builder: Make <lookup> type optional
If no type is set, use the type of the expression.
2020-05-30 19:26:44 -04:00
Benjamin Otte
d3dc9c41b4 gtk-demo: Make fishbowl info text use bindings
It's a good demo for how bindings can format multiple properties into an
informative string with 1 line of code (and 5 lines of XML).
2020-05-30 19:26:44 -04:00
Matthias Clasen
d1b2ded7e2 sorter: Add tests
Some basic tests for GtkSorter.
2020-05-30 19:26:44 -04:00
Benjamin Otte
ee3faf24b9 sortlistmodel: Make sort stable
The sort of the sortlistmodel is now stable with respect to the original
list model.

That means that if the sorter compares items as equal, the model
will make sure those items keep the order they were in in the original
model.

Or in other words: The model guarantees a total order based on the
item's position in the original model.
2020-05-30 19:26:44 -04:00
Benjamin Otte
16ab648093 sortlistmodel: Redo the way we store the items
We need to keep this data around for changes in future commits where we
make the sorting stable.

An important part of the new data handling is that the unsorted list
needs to always be dealt with before the sorted list - upon creation we
rely on the unsorted iter and upon destruction, the sorted sequence
frees the entry leaving the unsorted sequence pointer invalid.

This change does not do any behavioral changes.
2020-05-30 19:26:44 -04:00
Matthias Clasen
11a1f8f36a Redo sort list model with GtkSorter
Reshuffle the api to take full advantage
of GtkSorter. Update all callers.
2020-05-30 19:26:44 -04:00
Matthias Clasen
1eda9884a0 Add GtkNumericSorter
This sorter compares numbers obtained from items
by evaluating an expression.
2020-05-30 19:26:44 -04:00
Matthias Clasen
ae4bb2d914 Add GtkMultiSorter
This is a sorter that tries multiple sorters in turn.
2020-05-30 19:26:44 -04:00
Matthias Clasen
6d68c536f3 Add GtkStringSorter
This is a GtkSorter implementation collating strings
2020-05-30 19:26:44 -04:00
Matthias Clasen
e74a9d09e6 Add GtkCustomSorter
This is a GtkSorter implementation which uses a GCompareDataFunc.
2020-05-30 17:48:44 -04:00
Matthias Clasen
b2b847f365 Add GtkSorter
This is a helper object for sorting, similar to GtkFilter.
2020-05-30 17:48:44 -04:00
Benjamin Otte
cb15ec0257 Add GtkOrdering
This is an enum that we're gonna use soon and it's worth introducing as a
separate commit.

The intention is to have meaningful names for return values in
comparison functions.
2020-05-30 17:48:44 -04:00
Matthias Clasen
115923b2d9 More expression tests
Test type mismatches, and the this pointer
during evaluation.
2020-05-30 17:48:44 -04:00
Benjamin Otte
ad60efb5d7 expression: Invalidate bindings before destroying them
Use a weak ref to invalidate bindings. Make sure that this happens
before creating any watches, so that notifies from the
watched expression about changes will not trigger set_property() calls
during dispose()/finalize().

Invalidating also ensures that the watches aren't removed, which can
trigger warnings if the watches are watching the object itself, and the
weak refs cannot be removed anymore.
2020-05-30 17:48:44 -04:00
Benjamin Otte
b7efe4eb4f expression: Add gtk_expression_bind()
Add a simple way to bind expressions to object properties. This is
essentially the thing to replace g_object_bind_property().
2020-05-30 17:48:44 -04:00
Benjamin Otte
92c359ca09 testsuite: Add expression tests 2020-05-30 17:48:44 -04:00
Benjamin Otte
ec742f9373 expression: Add the ability to watch an expression 2020-05-30 17:48:44 -04:00
Benjamin Otte
fde75aa9f6 builder: Add support for parsing expressions 2020-05-30 17:47:47 -04:00
Benjamin Otte
2df3c39e50 filter: Add tests
Some basic tests for GtkFilter
2020-05-30 17:42:09 -04:00
Benjamin Otte
22659afd00 Add GtkMultiFilter, GtkAnyFilter, GtkEveryFilter
GtkMultiFilter is the abstract base class for managing multiple child
filter.
GtkAnyFilter and GtkEveryFilter are the actual implementations.
2020-05-30 17:42:09 -04:00
Benjamin Otte
410e7dcf5d filter: Add GtkStringFilter
Users provide a search filter and an expression that evaluates the items
to a string and then the filter goes and matches those strings to the
search term.
2020-05-30 17:42:09 -04:00
Benjamin Otte
bd8655fdee expression: Add GtkObjectExpression
Weak refs break cycles...
2020-05-30 17:42:09 -04:00
Benjamin Otte
e9f1ee5aab Add GtkExpression
GtkExpressions allow looking up values from objects.

There are a few simple expressions, but the main one is the closure
expression that just calls a user-provided closure.
2020-05-30 17:42:08 -04:00
Benjamin Otte
4abdf695e3 filterlistmodel: Rewrite to use GtkFilter 2020-05-30 12:30:23 -04:00
Benjamin Otte
b1090ac8e2 tests: Remove testtreemodel test
testlistview does everything this test does.
2020-05-30 12:30:23 -04:00
Benjamin Otte
1ab081b584 Add GtkCustomFilter 2020-05-30 12:30:23 -04:00
Benjamin Otte
1df17f2fea Add GtkFilter 2020-05-30 12:30:23 -04:00
Benjamin Otte
682e97826c Add GtkDirectoryList
Adds a new listmodel called GtkDirectoryList that lists the children of
a GFile as GFileInfos.

This is supposed to be used by the filechooser.
2020-05-30 12:30:23 -04:00
Benjamin Otte
805fea20cb eventcontrollermotion: Remove mode argument
It's not used and nobody has documented how it's meant to work anyway.
2020-05-30 12:30:23 -04:00
Matthias Clasen
415bfeb950 Merge branch 'fix-pango-deps' into 'master'
Fix inconsistencies in our pango deps

See merge request GNOME/gtk!1989
2020-05-30 16:29:12 +00:00
Matthias Clasen
2f20a40922 Merge branch 'matthiasc/for-master' into 'master'
Some listview preparations

See merge request GNOME/gtk!1988
2020-05-30 15:51:21 +00:00
Matthias Clasen
5235a4c48a Fix inconsistencies in our pango deps
We were applying the pango version requirements inconsistently,
leading to different pango variables being taking from system
pango vs the subproject at times. Thankfully, meson detects
this and complains, so we can fix it.
2020-05-30 11:13:55 -04:00
Matthias Clasen
bb7f6ed544 Merge branch 'fix-gesture-leak' into 'master'
gesture: Don't leak target widgets

Closes #2801

See merge request GNOME/gtk!1986
2020-05-30 15:12:05 +00:00
Benjamin Otte
f1d6a0a4ed widget: Add gtk_widget_get_size()
A little bit of convenience.
2020-05-30 10:48:02 -04:00
Benjamin Otte
3c1cca13b7 wayland: Remove function declaration for nonexisting function 2020-05-30 10:46:49 -04:00
Benjamin Otte
1ef805328f builder: Allow <property bind /> for objects
Previously, object properties had to always be set to a value.
This now works without it.
2020-05-30 10:46:27 -04:00
Matthias Clasen
fd73f8d972 Merge branch 'pango-bump-v2' into 'master'
pango version bump v2

See merge request GNOME/gtk!1987
2020-05-30 14:45:47 +00:00
Matthias Clasen
3a8ebf4c9f Merge branch 'wip/jimmac/backdrop-assasination' into 'master'
Adwaita: limit scope of :backdrop

Closes #2694

See merge request GNOME/gtk!1978
2020-05-30 14:41:52 +00:00
Matthias Clasen
b482b7d8af Bump the pango dependency
We soon want to rely on the list model apis in
pango 1.45. This commit also fixes a mixup where
using pango as a submodule would break the build
when pangoft2 is required.
2020-05-30 15:47:56 +02:00
Matthias Clasen
0d69c42320 gesture: Don't leak target widgets
This was broken when we started tracking event targets
in dcbecdac31.

Fixes: #2801
2020-05-30 09:47:24 -04:00
Christoph Reiter
011f5afe4e CI: install a newer pango for MSYS2
Uses a build from git master from today
2020-05-30 15:47:02 +02:00
Matthias Clasen
8bab7b237c Merge branch 'matthiasc/for-master' into 'master'
eventcontroller: Fix crossing event scopes

See merge request GNOME/gtk!1983
2020-05-30 13:41:42 +00:00
Matthias Clasen
821a458393 Revert "Bump the pango dependency"
This reverts commit 98df0be43d.

It broke the win32 build.
2020-05-30 08:55:21 -04:00
Matthias Clasen
66120cff4b eventcontroller: Fix crossing event scopes
We want to deliver crossing events to controllers
with scope same-native as long as at least one of
the targets is on the same native. As a new approach,
treat out-of-scope targets like NULL, and deliver
crossing events as long as one of the targets is
not NULL.
2020-05-29 19:41:39 -04:00
Matthias Clasen
8ce1034e87 Add GTK_DEBUG=shortcuts
If the shortcuts debug flag is set, print out
shortcut activations.
2020-05-29 17:59:58 -04:00
Matthias Clasen
a39d708859 meson: Cosmetics
Treat the display backend list like other lists in the summary.
2020-05-29 15:40:34 -04:00
Matthias Clasen
98df0be43d Bump the pango dependency
We soon want to rely on the list model apis in
pango 1.45. This commit also fixes a mixup where
using pango as a submodule would break the build
when pangoft2 is required.
2020-05-29 10:53:39 -04:00
Matthias Clasen
4125eb01ba Merge branch 'matthiasc/for-master' into 'master'
Bring back gdk_display_put_event

See merge request GNOME/gtk!1980
2020-05-29 14:14:02 +00:00
Matthias Clasen
346bba6592 Bring back gdk_display_put_event
It is still needed in WebKit.
2020-05-29 09:26:50 -04:00
Alexander Larsson
0bd039a524 gtk-demo: Don't show main window if --run is passed in
Also, in that case, exit when the demo window is closed.
2020-05-29 13:51:31 +02:00
Jakub Steiner
f4705bab1e Adwaita: limit scope of :backdrop
- most controls don't have:backdrop state
- different :backdrop state reserved for windows, headebars and toolbars
  and some buttons

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/2694
2020-05-29 12:43:13 +02:00
Matthias Clasen
c7a9d7b56b Merge branch 'im-context-key-forward' into 'master'
Add back keyboard related apis

See merge request GNOME/gtk!1977
2020-05-29 00:10:39 +00:00
Matthias Clasen
4d4b836976 Merge branch 'display-api' into 'master'
gdk: Make event-related apis private

See merge request GNOME/gtk!1929
2020-05-28 21:11:54 +00:00
Matthias Clasen
506d73cf32 Add gtk_im_context_filter_key
An event-less variant of the filtering api.
2020-05-28 17:08:33 -04:00
Jordi Mas
d71ad3539e Update Catalan translation 2020-05-28 21:43:02 +02:00
Matthias Clasen
266a3a5267 Export keymap translation again
This is needed in WebKit webdriver test environment.
2020-05-28 15:15:53 -04:00
Matthias Clasen
48f8affb2c gdk: Make event-related apis private
Without a way to create events, there is no point
in allowing gdk_display_put_event to be used from
the outside. And little good can come out of using
the other apis, so just make them all private.
2020-05-28 14:53:08 -04:00
Alexander Larsson
2503251576 Merge branch 'frame-clock-alternative-approach-gtk4' into 'master'
Frame clock alternative approach for gtk4

See merge request GNOME/gtk!1932
2020-05-28 16:22:53 +00:00
Alexander Larsson
a27fed47e0 frame-clock: Ensure we're always monotonic
A call to frame gdk_frame_clock_get_frame_time() outside of the paint
cycle could report an un-error-corrected frame time, and later a
corrected value could be earlier than the previously reported value.

We now always store the latest reported time so we can ensure
monotonicity.
2020-05-28 17:44:51 +02:00
Matthias Clasen
56030a7a81 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1976
2020-05-28 13:43:22 +00:00
Alexander Larsson
fee3aaae94 tests: Disable idle locking in headless weston
In my local testing i was burned by the default 300sec value here.
I'm not sure if we actually hit this in the CI, but lets not
take any chances.
2020-05-28 15:15:04 +02:00
Alexander Larsson
20f15f5111 reftests: Fix frame inhibiting
Actually inhibit snapshotting of frames from reftest_inhibit_snapshot.
We were not ignoring the case where inhibit_count > 0, and then disconnected
the callback meaning we only ever got the first snapshot.
2020-05-28 15:13:13 +02:00
Alexander Larsson
9ef3e70040 frame-clock: New approach in smoothing frame clock
In commit c6901a8b, the frame clock reported time was changed from
simply reporting the time we ran the frame clock cycle to reporting a
smoothed value that increased by the frame interval each time it was
called.

However, this change caused some problems, such as:
 https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/1415
 https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/1416
 https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/1482

I think a lot of this is caused by the fact that we just overwrote the
old frame time with the smoothed, monotonous timestamp, breaking
some things that relied on knowing the actual time something happened.

This is a new approach to doing the smoothing that is more explicit.
The "frame_time" we store is the actual time we ran the update cycle,
and then we separately compute and store the derived smoothed time and
its period, allowing us to easily return a smoothed time at any time
by rounding the time difference to an integer number of frames.

The initial frame_time can be somewhat arbitrary, as it depends on the
first cycle which is not driven by the frame clock. But follow-up
cycles are typically tied to the the compositor sending the drawn
signal. It may happen that the initial frame is exactly in the middle
between two frames where jitter causes us to randomly round in
different directions when rounding to nearest frame. To fix this we
additionally do a quadratic convergence towards the "real" time,
during presentation driven clock cycles (i.e. when the frame times are
small).
2020-05-28 15:13:07 +02:00
Alexander Larsson
f1215d2d77 frame clock: Use compositor refresh rate info even if presentation time not set
On my X11 + nvidia setup gnome-shell doesn't report presentation times.
However it does report refresh rate. We were mostly using this in our
calculation except when computing predicted presentation time, were
it fell back on the default 60Hz.
2020-05-28 15:12:32 +02:00
Alexander Larsson
0ad73da68a frame clock: Used drawn_time (as well as presentation time) in profiler marks. 2020-05-28 15:12:32 +02:00
Alexander Larsson
e2a4be0243 FrameClock debug: Log drawn_time if set 2020-05-28 15:12:32 +02:00
Matthias Clasen
2d80b105ce shortcut controller: Fix mnemonic cycling
Iterate the shortcuts we found in order, not in
reverse. Otherwise, we always end up activating
the last_selected one, since it is last in the
list.

This broke in fb9b54d4b2 when a list was
turned into an array.
2020-05-28 08:52:55 -04:00
Matthias Clasen
1f4130b927 widget-factory: Add a mnemonic conflict
Make Alt-e the mnemionic for both the Edit menu
and the Select button on page 2. This shows that
mnemonic cycling doesn't currently work, we always
open the menu.
2020-05-28 08:34:06 -04:00
Yuri Chornoivan
bdf40943db Update Ukrainian translation 2020-05-28 10:05:11 +00:00
Emmanuele Bassi
4c9357aaef Merge branch 'fix_typos' into 'master'
Fix minor typos

See merge request GNOME/gtk!1974
2020-05-28 09:11:43 +00:00
Yuri Chornoivan
01bd4cc4e1 Fix minor typos 2020-05-28 11:00:03 +03:00
Matthias Clasen
92bc78c12f Merge branch 'matthiasc/for-master' into 'master'
a11y: Widgets have children

See merge request GNOME/gtk!1973
2020-05-28 03:58:02 +00:00
Matthias Clasen
8e427b7d69 a11y: Widgets have children
This brings back some of what we lost when
GtkContainerAccessible went away.
2020-05-27 22:56:33 -04:00
Matthias Clasen
2ad127d290 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1972
2020-05-28 00:55:42 +00:00
Matthias Clasen
2c80691be6 aboutdialog: Stop overriding show()
This is entirely unnecessary.
2020-05-27 20:05:26 -04:00
Matthias Clasen
1cd71203b8 volumebutton: Enable the tooltips
Little point in having a query-tooltip handler if
we don't make sure ::query-tooltip is emitted.
2020-05-27 19:02:30 -04:00
Matthias Clasen
9c5fc0fb7a volumebutton: Remove broken a11y code
The accessible of a button is not an AtkImage,
so whatever this code was trying to do isn't
working. Remove it.
2020-05-27 19:02:19 -04:00
Matthias Clasen
1927a8af71 tooltips: Fix a line wrap mishap
We don't want wrapping labels to cause tooltips to
have excessive height, so we need to set a reasonable
value for width-chars, without forcing short tooltips
into a full line length. Also be careful to respect
preexisting line breaks (we have such examples in
widget factory).
2020-05-27 19:01:46 -04:00
Emmanuele Bassi
fe40e674c5 Merge branch 'ebassi/overlay-docs' into 'master'
Ebassi/overlay docs

See merge request GNOME/gtk!1970
2020-05-27 16:50:55 +00:00
Matthias Clasen
194b0be8bf Merge branch 'matthiasc/for-master' into 'master'
Add to the docs README

See merge request GNOME/gtk!1971
2020-05-27 16:36:18 +00:00
Matthias Clasen
c42219cd5b Add to the docs README
Mention markdown syntax and gtk-doc additions.
2020-05-27 11:11:30 -04:00
Emmanuele Bassi
637186976c Remove spurious annotations
Boolean values are not nullable, and have no ownership to transfer.
2020-05-27 15:49:24 +01:00
Emmanuele Bassi
175d4ef03e Add missing documentation for GtkOverlayLayout
We're missing the documentation for the constructor, and for the child
properties.
2020-05-27 15:49:24 +01:00
Emmanuele Bassi
85af410b8b Merge branch 'ebassi/howto-docs' into 'master'
Ebassi/howto docs

See merge request GNOME/gtk!1969
2020-05-27 14:10:40 +00:00
Emmanuele Bassi
347cb94c43 docs: Link the documentation guidelines
From the coding style.
2020-05-27 13:44:50 +01:00
Emmanuele Bassi
c5485cd6b1 Add the beginnings of a docs contribution guide
We have one for the whole project, but the documentation should have a
proper introduction and a proper style guide.
2020-05-27 13:44:50 +01:00
Emmanuele Bassi
e30c974646 Add myself to more sections 2020-05-27 13:44:50 +01:00
Emmanuele Bassi
6b6c76e3a2 docs: Remove last two steps from the release howto
Drop the GTK list announcements, as we don't have lists any more.

The GTK website updates itself automatically, these days.
2020-05-27 13:44:50 +01:00
Emmanuele Bassi
25a8fa73f8 docs: Turn coding style into a markdown document
It was mostly one already, just needed some minor fixes.
2020-05-27 13:44:50 +01:00
Timm Bäder
7f2e3c44b3 Merge branch 'carlosgc/fix-build' into 'master'
build: add gtkoverlaylayout.h to the list of public headers

See merge request GNOME/gtk!1968
2020-05-27 10:06:53 +00:00
Carlos Garcia Campos
a2aa25d28e build: add gtkoverlaylayout.h to the list of public headers
GtkOverlayLayout is now public but the header is not installed.
2020-05-27 11:13:02 +02:00
Matthias Clasen
9f4da7dfd1 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1967
2020-05-27 03:54:59 +00:00
Matthias Clasen
646a1c2b88 win32: Drop an unsed variable 2020-05-26 22:23:43 -04:00
Matthias Clasen
c47553e319 gdk: Drop no-longer-used documentation
Thread support is gone, and we don't have that
section in the docs anymore.
2020-05-26 20:52:41 -04:00
Matthias Clasen
45f162fc50 gdk: Remove an unused texture api
gdk_gl_texture_from_surface wasn't used anywhere,
so lets drop it.
2020-05-26 20:43:47 -04:00
Matthias Clasen
a20291f235 gdk: Drop some unused event queue functions 2020-05-26 20:43:47 -04:00
Matthias Clasen
3468b2fc44 gdk: Clean up gdkinternals.h
Remove definitions that are just leftovers with
nothing behind them anymore.
2020-05-26 20:43:47 -04:00
Matthias Clasen
aa0d0dc510 gdk: Drop _gdk_windowing_args
We are no longer parsing commandline args, so this
was a useless leftover that was still defined in
the win32 backend.
2020-05-26 20:13:13 -04:00
Matthias Clasen
9c82946e45 docs: Drop a mention of gdk_window_move()
We don't have windows anymore, and they don't move
anymore either.
2020-05-26 20:05:34 -04:00
Matthias Clasen
e5a9255555 gdk: Move the GdkGeometry typedef to gdkinternals.h
The struct was already there, so this is just a leftover.
2020-05-26 20:04:40 -04:00
Matthias Clasen
e14322137f gdk: Drop the GdkByteOrder enum
Move it to the private gdkvisual-x11.h header, which
is the only place where its used.
2020-05-26 19:45:01 -04:00
Matthias Clasen
f27d855c68 gdk: Drop the GdkEventMask enum
This is not used in public api anymore.
Some of the backends still use it internally,
so keep it in gdkinternals.h for now.
2020-05-26 19:39:31 -04:00
Matthias Clasen
0553b10214 gdk: Drop the GdkSurfaceTypeHint enum
This is not used in public api anymore.
Some of the backends still use it internally,
so keep it in gdkinternals.h for now.
2020-05-26 19:34:59 -04:00
Matthias Clasen
105fc16a9a testsuite: Drop the type-hint property from tests
No point in excluding a property that no longer
exists.
2020-05-26 19:31:12 -04:00
Matthias Clasen
efbc661620 window: Drop an unused field
The type-hint property is gone, and nothing reads
or writes the type_hint field anymore.
2020-05-26 19:30:26 -04:00
Matthias Clasen
7fb5b970f5 gdk: Drop GDK_PARENT_RELATIVE
This define is not used anywhere.
2020-05-26 19:21:55 -04:00
Matthias Clasen
5f9bcd0409 accelgroup: Expand translator comment
Add details about the use of KP.
2020-05-25 22:50:03 -04:00
Matthias Clasen
bd3f4599ed Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #2778

See merge request GNOME/gtk!1966
2020-05-26 02:41:37 +00:00
Matthias Clasen
ddf6138d07 Merge branch 'ebassi/for-master' into 'master'
Ebassi/for master

Closes #2783

See merge request GNOME/gtk!1962
2020-05-26 01:35:11 +00:00
Matthias Clasen
8c6bbcdc2e docs: Mention shortcuts in the migration guide
Add a few paragraphs about GtkAccelGroup, GtkBindingSet
and GtkAccelMap to the migration guide.

Fixes: #2778
2020-05-25 21:27:58 -04:00
Matthias Clasen
a55d179215 accelgroup: Drop some unused code 2020-05-25 20:56:09 -04:00
Matthias Clasen
ec39ddee63 Help static analysis with an assertion
It is hard for clang to see that layouts will
always be smaller than num_layouts, so just assert
that.
2020-05-25 20:56:09 -04:00
Matthias Clasen
0f096d6ad9 bitmask: add an assertion
The static analysis in ci is complaining about
this, since it doesn't know that start is always
smaller than end.
2020-05-25 20:56:09 -04:00
Matthias Clasen
92d42d4b67 printing: Drop a redundant assignment
This showed up as a warning in static analysis in ci.
2020-05-25 20:56:09 -04:00
Matthias Clasen
17b5cfc924 docs: Mention pandoc as build dependency 2020-05-25 20:56:09 -04:00
Matthias Clasen
5590e2f6f2 Merge branch 'doc-chapters-markdown' into 'master'
Include markdown content, via pandoc

See merge request GNOME/gtk!1961
2020-05-26 00:55:10 +00:00
Matthias Clasen
ae2e548b4b docs: Use the right python 2020-05-25 18:40:09 -04:00
Matthias Clasen
4dbf73d9aa Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1965
2020-05-25 20:23:06 +00:00
Matthias Clasen
86f8be41d0 ci: Use fedora-docs for the doc build
Our doc build now uses pandoc, so use an image
that has it.
2020-05-25 16:11:18 -04:00
Matthias Clasen
f60149cd9e ci: Add a fedora-docs image
Split the fedora image into fedora-base (containing just
the packages) and fedora (adding the user setup), and add
a fedora-docs image that is adding pandoc on top of the
fedora-base image.
2020-05-25 16:11:18 -04:00
Matthias Clasen
aca8090a09 docs: Convert question index to markdown
With this, the expand_content_files list has been
completely converted to markdown files. Whats left
in content_files is man pages, and a few special
cases.
2020-05-25 16:11:18 -04:00
Matthias Clasen
84437ee0e0 docs: Allow interrupted lists
We use such an interrupted, numbered list in the
q&a section, so tell pandoc to pay attention to
start numbers.
2020-05-25 16:11:18 -04:00
Matthias Clasen
dc858c9686 docs: Convert treeview and textview overview to markdown 2020-05-25 16:11:18 -04:00
Matthias Clasen
581b39a38d docs: Allow influencing pandoc divisons
Arrange for files named section-foo.md to be turned
into docbook sections, while others get turned into
chapters. This is necessary to allow including such
content in chapters, since chapters in docbook don't
nest.
2020-05-25 16:11:18 -04:00
Matthias Clasen
a37b9d7578 docs: Drop the glossary
It is very incomplete, somewhat outdated, and
we lack the resources to maintain it properly.
2020-05-25 16:11:18 -04:00
Matthias Clasen
5a3fe9e5f5 docs: Convert resources section to markdown 2020-05-25 16:11:18 -04:00
Matthias Clasen
f44d611f77 docs: Drop a long-stale file
The other_software.xml section has not been included in
the docs since 2.x, as far as I can tell. It was clearly
written before GIO existed.
2020-05-25 16:11:18 -04:00
Matthias Clasen
29fb9ae2d6 docs: Convert platform sections to markdown 2020-05-25 16:11:18 -04:00
Matthias Clasen
2595cd5a93 docs: Convert getting_started to markdown
As part of the conversion, give up on including
sources files from the examples directory, and
instead include the content directly. All include
mechanisms add complications. They were already
complicated with xml, and markdown is not making
things easier.

We already did that for fragments, and if you
make changes to these example sources, you
probably need to revise the surrounding text
anyway.
2020-05-25 16:11:18 -04:00
Matthias Clasen
bf14d75cad docs: Refresh the inspector screenshot 2020-05-25 16:11:18 -04:00
Matthias Clasen
b99511ee55 docs: Convert building, compiling, running to markdown 2020-05-25 16:11:18 -04:00
Matthias Clasen
3bf90b4218 doc: Check for pandoc
Add an explicit check for pandoc, so we get a clear
error message if it is missing.
2020-05-25 16:11:18 -04:00
Matthias Clasen
9873d983ed docs: Convert css overview to markdown 2020-05-25 16:11:18 -04:00
Matthias Clasen
3338d24da4 docs: Be more careful when expanding abbreviations
We must not expand #symbol in the middle of a url,
where it is probably a fragment identifier. Restrict
problem.
2020-05-25 16:11:18 -04:00
Matthias Clasen
10cd539104 wip: Include markdown content, via pandoc
Use pandoc to convert freestanding markdown files to docbook for
inclusion in the generated docs, and use bits and pieces of
gtk-doc code to continue expanding typical gtk-doc abbreviations.
The new tool for markdown -> docbook is a python script called
gtk-markdown-to-docbook.

The markdown dialect is specified via a list of pandoc extension
in gtk-markdown-to-docbook. It includes header annocations,
definition lists and tables, among other things.

This commit converts the 3 overview chapters (drawing, input
handling and actions) and the migration guide to markdown
syntax. Other files that are still listed in content_files
can be converted later.

This commit adds a pandoc dependency.
2020-05-25 16:11:18 -04:00
Matthias Clasen
e4623fd0c4 Add GtkOverlayLayout to the docs 2020-05-25 15:18:14 -04:00
Matthias Clasen
9fa3742c09 Make GtkOverlayLayout public
Keeping the layout manager type private does not
really work when it has layout child properties
that need to be usable in ui files.
2020-05-25 14:22:10 -04:00
Matthias Clasen
5317e4bc07 constraint-editor: Don't use g_type_ensure
This isn't necessary if we export the get_type function.
2020-05-25 14:14:28 -04:00
Timm Bäder
2127cc1943 adwaita: move backdrop box shadows to .csd
Fixes #2781
2020-05-25 10:36:29 +02:00
Timm Bäder
04b7dd802a compare-render: Fix some memory leaks 2020-05-24 17:14:18 +02:00
Emmanuele Bassi
7de9eb005e Add a comment for translators
"KP" refers to the numeric keypad, in this context.

Fixes: #2783
2020-05-24 15:20:13 +01:00
Emmanuele Bassi
d68e312c2b Use the private GdkKeyEvent.translated_key getter
We can avoid poking directly at the GdkKeyEvent structure, now.
2020-05-24 15:19:01 +01:00
Emmanuele Bassi
0cf5b66e7b Add private accessor for GdkKeyEvent.translated
Avoid accessing the event structure directly, even from within GTK.
2020-05-24 15:19:01 +01:00
Timm Bäder
d5bf3c2cd1 gl renderer: Improve clipping code
don't render a clip to a texture if the new clip does not intersect with
any of the corners of the currently rounded clip.

Fixes #2770
2020-05-24 15:59:05 +02:00
Timm Bäder
094788f1a3 gl renderer: Refactor render_clipped_child 2020-05-24 15:59:05 +02:00
Timm Bäder
23e68c0988 gl renderer: Cache whether clips is rectilinear 2020-05-24 15:59:05 +02:00
Timm Bäder
60902484fd applicationwindow: Simplify measure implementation
We already chain up first thing in this function, so no need to do it
again.
2020-05-24 15:59:05 +02:00
Timm Bäder
48c9c86626 window: Remove private _get_shadow_width()
Unused now.
2020-05-24 15:59:05 +02:00
Timm Bäder
2e27a76edd applicationwindow: Stop querying shadow width
don't need to do this anymore.
2020-05-24 15:59:05 +02:00
Piotr Drąg
be8fc8f26b Update Polish translation 2020-05-24 15:07:03 +02:00
Florentina Mușat
f1e3581347 Update Romanian translation 2020-05-24 10:48:29 +00:00
Florentina Mușat
0606dd511a Update Romanian translation 2020-05-24 10:37:15 +00:00
Emin Tufan Çetin
3e68c694b9 Update Turkish translation 2020-05-23 08:50:36 +00:00
Matthias Clasen
ffa5334a2d Merge branch 'matthiasc/for-master' into 'master'
gtk-demo: Fix the dnd demo drop highlight

See merge request GNOME/gtk!1958
2020-05-23 00:05:16 +00:00
Matthias Clasen
5e25ba6c5a Merge branch 'no-app-menu' into 'master'
Drop the app menu

Closes #2731

See merge request GNOME/gtk!1951
2020-05-22 23:46:56 +00:00
Matthias Clasen
5f6d072459 gtk-demo: Fix the dnd demo drop highlight
We want the drop highlight to be around the label,
not around the item containing it, so move the drop
target gesture to the right widget.
2020-05-22 18:52:56 -04:00
Matthias Clasen
1038b9b8a1 docs: Mention app menus in the migration guide 2020-05-22 18:46:51 -04:00
Matthias Clasen
0dc384265c Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1957
2020-05-22 22:19:59 +00:00
Matthias Clasen
133461581f Merge branch 'BUG_filechooserbutton_remote_GTK4' into 'master'
FileChooserButton: query 'display name' also for unbookmarked files

Closes #1966

See merge request GNOME/gtk!1725
2020-05-22 21:37:40 +00:00
Matthias Clasen
79d6a77d58 gtkapplication: Drop app menu support
Drop apis and code related to appmenus from
both GtkApplication and GtkApplicationWindow.

We still keep the menubar support, since it
is needed for system integration on OS X.

Fixes: #2731
2020-05-22 17:31:05 -04:00
Matthias Clasen
d5da3b9199 print-editor: Stop using appmenu apis
The appmenu-related GtkApplication apis are going away.
2020-05-22 17:31:05 -04:00
Matthias Clasen
a8df81b27c inspector: Drop app-menu support
Don't add app menu to the object tree anymore;
this property is going away.
2020-05-22 17:31:05 -04:00
Matthias Clasen
6c31092c69 examples: Stop using appmenu apis
The appmenu-related GtkApplication apis are going away.
2020-05-22 17:31:05 -04:00
Matthias Clasen
ca1c570c21 gtk-demo: Stop using appmenu apis
The appmenu-related GtkApplication apis are going away.
2020-05-22 17:31:05 -04:00
Matthias Clasen
33b836af7f fixed: Change coordinate apis to doubles
We are using floating point for coordinates
everywhere now, so be consistent here.

This commit also changes the implementation of
gtk_fixed_get_child_position to work with
non-translation child transforms.
2020-05-22 17:26:08 -04:00
Matthias Clasen
e7a420c40e testsuite: Re-add the sizegroups-evolution reftest
It doesn't seem to cause problems in ci anymore.
2020-05-22 17:10:28 -04:00
Matthias Clasen
962c4d6a69 Merge branch 'matthiasc/for-master' into 'master'
text: Avoid clash of preedit and placeholder

See merge request GNOME/gtk!1955
2020-05-22 20:59:44 +00:00
Matthias Clasen
0f053d1804 gtk-demo: Improve rotation in the dnd demo
Make the drag icon preserve the rotation, and improve
placement for the editor and for dnd to take the offset
into account.
2020-05-22 15:38:02 -04:00
Timm Bäder
930d779eb3 gl renderer: don't pretend all transform nodes support being transformed
It doesn't work in the general case. The transform handling could use a
general overhaul though.

Fixes #2773
2020-05-22 21:29:10 +02:00
Timm Bäder
f3ca814f3d gl renderer: Fix some off-by-one and rounding errors in the shadow code
Take 24

Fixes #2759
2020-05-22 21:29:10 +02:00
Matthias Clasen
7fac6b37db gtk-demo: Improve editing in the dnd demo
Add a scale for the angle, make the edits apply immediately,
and keep the item visible.
2020-05-22 14:06:00 -04:00
Matthias Clasen
d2f979ffaf gtk-demo: Improve drag icon handling in dnd example
Make the opacity change only apply to the 'ghost' of
the item, not the drag icon.
2020-05-22 13:25:17 -04:00
Matthias Clasen
e54060bac2 gtk-demo: Fix entry position in dnd demo
gtk_fixed_get_child_position does not work if children
have transforms that are not just 2D translations.
Use gtk_widget_translate_coordinates instead.
2020-05-22 13:17:59 -04:00
Matthias Clasen
965483eb67 gtk-demo: Reorganize the dnd demo
Introduce a CanvasItem widget to make things a
bit less ad hoc.
2020-05-22 12:35:18 -04:00
Matthias Clasen
dff5986ec2 main: Keep the target widget alive
We are passing the event to the tooltip handle_event
function at the very end. Unfortunately, the target_widget
may have already died at that point. We prevent that
by taking a ref during propagage_event, but the tooltip
code was outside of that. Keep a ref until the very
end ot prevent crashes.
2020-05-22 12:25:23 -04:00
Matthias Clasen
028bccc188 gtk-demo: Use proper drag icons in the dnd demo
Use a widget paintable to make the drag icon appear
in two places at once.
2020-05-22 10:50:09 -04:00
Matthias Clasen
78b427c99d dragsource: Actually use the paintable
We were just ignoring a paintable provided by
gtk_drag_source_set_icon().
2020-05-22 10:49:57 -04:00
Matthias Clasen
aec0a49e91 colorswatch: Remove a redundant include 2020-05-22 10:48:49 -04:00
Matthias Clasen
e60ea00e8b reftests: Fix the background-origin test
This was broken when I accidentally removed
one of the buttons.
2020-05-22 10:48:33 -04:00
Matthias Clasen
01df133401 text: Avoid clash of preedit and placeholder
Take preedit into account when determining the
visibility of placeholder text.
2020-05-22 10:48:33 -04:00
Matthias Clasen
56a6120136 Merge branch 'fix-printbackend' into 'master'
Build media backends with common_cflags and export the symbol

Closes #2771

See merge request GNOME/gtk!1956
2020-05-22 14:20:35 +00:00
Qiu Wenbo
340a8e11b0 Build media backends with common_cflags and export the symbol
Fixes: #2771
2020-05-22 17:00:06 +08:00
Yuri Chornoivan
2da14da32c Update Ukrainian translation 2020-05-22 05:47:20 +00:00
Matthias Clasen
641f2f72cd Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #227, #328, and #1010

See merge request GNOME/gtk!1954
2020-05-22 01:59:34 +00:00
Ondrej Holy
e8a120e5af trash-monitor: Rate limit updates
Trash monitor queries info from gvfsd-trash after each file monitor
change which can be problematic when too many changes happen in
a short time. Let's rate limit the number of queries...

Fixes: #1010
2020-05-21 21:15:12 -04:00
Matthias Clasen
e9872d52d8 range: Treat lower and upper limit the same
When clamping values to be within the range of
the adjustment, treat the lower and upper limit
the same.

Fixes: #328
2020-05-21 20:37:54 -04:00
Matthias Clasen
3b8bd265a3 windowhandle: Drop Move and Resize from the fallback menu
The expected behavior is that we trigger a keyboard-driven
interactive move or resize operation. But that doesn't work
with common compositors like mutter or weston, so lets not
expose non-working menuitems.
2020-05-21 19:38:36 -04:00
Matthias Clasen
af162b70c5 tooltip: Avoid criticals
It is possible that the target widget is already
unparented at the time that we call the tooltips
handle_event function. Quietly return in that case,
no need to emit a critical.
2020-05-21 19:38:36 -04:00
Matthias Clasen
061f257e83 accelgroup: Use Unicode in string literals
Its 2020, non-ASCII characters are not taboo anymore.
2020-05-21 19:38:36 -04:00
Matthias Clasen
c58d9446f4 Differentiate keypad keysyms in accelerators
When displaying accelerators, differentiate keypad
symbols with a 'KP' prefix. Fixing a 17 year old bug.

Update expected output in accelerator tests.

Fixes: #227
2020-05-21 19:38:19 -04:00
Matthias Clasen
e4d684b116 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1953
2020-05-21 21:31:17 +00:00
Matthias Clasen
8f5444c75b gtk-demo: Fix breakage in a css demo
This is fallout from container api changes. We
were treating a GtkOverlay like a GtkBox, which
it isn't.
2020-05-21 16:24:56 -04:00
Matthias Clasen
96c0fbf209 gtk-demo: Plug another leak
We were leaking the builder in the css blendmodes demo,
by creating a ref cycle. This was showing up as
the list entry not going back to upright after
closing the window.
2020-05-21 16:24:20 -04:00
Matthias Clasen
98178d8823 gtk-demo: Plug another leak
We were leaking the builder in the revealers demo,
by creating a ref cycle. This was showing up as
the list entry not going back to upright after
closing the window.
2020-05-21 16:23:42 -04:00
Matthias Clasen
3f6dd34b18 gtk-demo: Plug another leak
We were leaking the builder in the cursors demo,
by creating a ref cycle. This was showing up as
the list entry not going back to upright after
closing the window.
2020-05-21 15:41:54 -04:00
Matthias Clasen
aaed61de66 gtk-demo: Plug a leak
We were leaking the builder in the builder demo,
by creating a ref cycle. This was showing up as
the list entry not going back to upright after
closing the window.
2020-05-21 15:41:48 -04:00
Timm Bäder
1aa86d23f4 gl renderer: Fix blurred outset shadow slicing
Take 23.

Fixes #2759
2020-05-21 15:32:12 +02:00
Matthias Clasen
c4607f72d1 Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

See merge request GNOME/gtk!1950
2020-05-20 20:57:34 +00:00
Matthias Clasen
f5f4c3cdfc Merge branch 'wip/exalm/window-polish' into 'master'
window: Fix tiled style class names

See merge request GNOME/gtk!1949
2020-05-20 20:13:30 +00:00
Matthias Clasen
9a1b4a766f mediastream: Volume is a double
Another obvious copy-paste error in the property
declarations of GtkMediaStream. Volume should be
a double, with range [0, 1], not a boolean.
2020-05-20 16:07:50 -04:00
Matthias Clasen
87d2e86429 mediastream: Some properties were meant to be readonly
These properties aren't covered by set_property(), and
it doesn't make sense to do so. They were just declared
as read-write by mistake.
2020-05-20 16:07:50 -04:00
Matthias Clasen
ee2c55379c mediacontrols: Make volume control react to has-audio 2020-05-20 16:07:50 -04:00
Matthias Clasen
be8a831496 Merge branch 'matthiasc/for-master' into 'master'
gdk: Short-circuit some surface setters

See merge request GNOME/gtk!1947
2020-05-20 18:01:07 +00:00
Alexander Mikhaylenko
2ce8c82846 window: Fix tiled style class names
This should fix the round corners on tiled windows.
2020-05-20 22:10:32 +05:00
Timm Bäder
7d57f978c5 Merge branch 'wip/baedert/single-node-window' into 'master'
single node GtkWindow

See merge request GNOME/gtk!1863
2020-05-20 17:06:37 +00:00
Timm Bäder
22e7d11583 window: Use GtkNative's check_resize everywhere 2020-05-20 18:12:22 +02:00
Timm Bäder
9cc6ddf80d window: Create default titlebar directly in realize
Instead of having two functions that are only called from one place but
look like they can be called from anywhere.
2020-05-20 18:12:22 +02:00
Timm Bäder
ee9d99cba3 update documentation for new style classes and node names 2020-05-20 18:12:22 +02:00
Timm Bäder
5c458e3061 Adwaita: style updates for new window node hierarchy 2020-05-20 18:12:20 +02:00
Timm Bäder
dfbcd475f3 window: Fix the surface coordinates everywhere 2020-05-20 17:08:24 +02:00
Timm Bäder
018efdb8eb window: Inline gtk_window_configure() into only caller
And remove the prototype from gtkwindowprivate.h
2020-05-20 17:08:24 +02:00
Timm Bäder
ec594f80dc window: Rewrite edge region detection 2020-05-20 17:08:24 +02:00
Timm Bäder
131837087b window: Fix computing the opaque region
We need to look at the surface transform here as well now.
2020-05-20 17:08:21 +02:00
Timm Bäder
7eec162502 window: Avoid using GtkStyleContext in subtract_decoration_corners
We can do this by just using the GtkCssStyle these days.
2020-05-20 17:06:54 +02:00
Timm Bäder
8c884e94c2 window: Fix get_surface_transform()
Look at the shadow here.
2020-05-20 17:06:54 +02:00
Timm Bäder
7659d8af3d window: Set overflow to HIDDEN
It really doesn't make sense for the general window to allow drawing
outside of it.
2020-05-20 17:06:54 +02:00
Timm Bäder
a5e7e72dd8 inspector: Fix overlay coordinates
Get the native transform only once, for all overlays. Unfortunately we
have to undo this for the updates overlay since that one gets values
in surface coordinates.
2020-05-20 17:06:54 +02:00
Timm Bäder
8e8e869853 inspector: Don't offset layout overlay too much
We already do this earlier.
2020-05-20 17:06:54 +02:00
Timm Bäder
b41838a7fd Window: Remove extra_input_region API
This is unused.
2020-05-20 17:06:54 +02:00
Timm Bäder
5ebabd7cf6 Call all window subclasses "window"
And add style classes to differentiate them
2020-05-20 17:06:54 +02:00
Timm Bäder
388733fe77 testsuite: Remove window decoration nodes from reference results 2020-05-20 17:06:54 +02:00
Timm Bäder
e1007e6c2b window: Remove decoration node 2020-05-20 17:06:54 +02:00
Timm Bäder
2c2092e7b8 window: Don't care about shadow in measure() 2020-05-20 17:06:54 +02:00
Timm Bäder
2579f66150 window: Don't care about shadow in size_allocate() 2020-05-20 17:06:54 +02:00
Timm Bäder
077692a8e1 window: Remove custom snapshot() implementation 2020-05-20 17:06:54 +02:00
Timm Bäder
5b77d3fde3 widget: Remove GtkWindow special case in create_render_node() 2020-05-20 17:06:54 +02:00
Matthias Clasen
6d8153d8fd gdk: Short-circuit some surface setters
Don't call into the backends when the input region
or shadow width don't actually change. This avoid
distracting calls in debug logs, and just generally
is the right thing to do.
2020-05-20 10:55:27 -04:00
Timm Bäder
ae711d8301 gdkdisplay-wayland: only remove one monitor
Ids here are unique, so break out of the loop once we found the monitor
with the given ID.
2020-05-20 15:51:11 +02:00
Emmanuele Bassi
00d889b4b6 Merge branch 'wip/ricotz/annotations' into 'master'
gdk: Preserve typed event parameter of GdkSurface:event signal for gir

See merge request GNOME/gtk!1946
2020-05-20 11:57:00 +00:00
Daniel Mustieles
401e2d16a8 Updated Spanish translation 2020-05-20 12:08:17 +02:00
Timm Bäder
4b5a8c45b4 gtk4-demo: Fix css_basics demo 2020-05-20 10:29:50 +02:00
Timm Bäder
ae54517b33 gtk4-demo: Fix sliding puzzle demo 2020-05-20 10:29:50 +02:00
Rico Tzschichholz
ebaeb9f3b8 gdk: Preserve typed event parameter of GdkSurface:event signal for gir
In conjunction to https://gitlab.gnome.org/GNOME/gtk/merge_requests/1936
2020-05-20 08:48:34 +02:00
Christian Hergert
a21d97db2e Merge branch 'wip/chergert/remove-get_toplevel' into 'master'
device: remove get_toplevel from surface_at_position vfunc

Closes #2765

See merge request GNOME/gtk!1941
2020-05-19 22:59:41 +00:00
Matthias Clasen
ebc8b01718 Merge branch 'wip/baedert/for-master' into 'master'
Wip/baedert/for master

See merge request GNOME/gtk!1935
2020-05-19 22:40:57 +00:00
Matthias Clasen
cf5e923d84 Merge branch 'wip/carlosg/tracker3' into 'master'
Move to tracker3 search engine

See merge request GNOME/gtk!1944
2020-05-19 22:37:34 +00:00
Christian Hergert
fa08d848ca device: remove get_toplevel from surface_at_position vfunc
This is not used anymore now that surfaces are always toplevel in the
semantics of GdkWindow where child windows were available. We can drop
that and simplify the vfunc just a bit more.

Fixes #2765
2020-05-19 13:07:38 -07:00
Carlos Garnacho
d29d59d1f9 gtksearchengine: Drop tracker 2.x search engine
This is being superseded by 3.x
2020-05-19 22:05:07 +02:00
Carlos Garnacho
edf6f9e108 gtksearchenginetracker3: Pre-fill GFileInfo from query
Provide the minimal info necessary. Improves apparent responsiveness
(since we don't visibly clear and repopulate the list) and saves doing
file stat/reads on every file in the result set.
2020-05-19 22:05:07 +02:00
Carlos Garnacho
98f376a19e gtksearchengine: Add tracker3 search engine
Make this dependency optional at build time, and prefer it over
the old tracker <= 2.x implementation.
2020-05-19 22:05:07 +02:00
Carlos Garnacho
de68925f0c gtksearchengine: Add autoptr handler for this type
So subclasses can just use G_DECLARE_*_TYPE.
2020-05-19 22:04:25 +02:00
Carlos Garnacho
b890e87818 gtksearchengine: Add "got_results" argument to ::finished
The filechooser tries to figure out whether it got results by poking
the model, but all files might go through the async GFileInfo querying
state.

Make all search engines (and the composite one) just notify about this
fact, so the file chooser can behave appropriately without waiting for
the async operations to finish.
2020-05-19 22:04:25 +02:00
Matthias Clasen
e0f4e44044 Merge branch 'matthiasc/for-master' into 'master'
docs: Refresh the build and backend sections

See merge request GNOME/gtk!1942
2020-05-19 19:59:46 +00:00
Timm Bäder
db76b52744 treeview: Remove animate parameters
Nothing ever reads them.
2020-05-19 08:32:33 +02:00
Timm Bäder
7235472a58 text: Assert that we have ranges before using them
We never hit this code path otherwise but let's make sure.
2020-05-19 08:32:33 +02:00
Timm Bäder
99871639fe unsetvalue: Add G_GNUC_NORETURN annotation 2020-05-19 08:32:33 +02:00
Timm Bäder
eebc2f20fa testgtk: Add G_GNUC_NORETURN to usage() 2020-05-19 08:32:33 +02:00
Timm Bäder
b92f4177aa builder-tool Make preview closeable 2020-05-19 08:32:33 +02:00
Timm Bäder
20b906cee8 Build print backends with common_cflags 2020-05-19 08:32:33 +02:00
Timm Bäder
7a768a2581 build: Pass common_cflags to focus-chain test 2020-05-19 08:32:33 +02:00
Timm Bäder
17c7662a6c bloatpad: Pass common_cflags to the build 2020-05-19 08:32:33 +02:00
Timm Bäder
14c3bc542d tetsuite/a11y: Pass common_cflags to build 2020-05-19 08:32:33 +02:00
Timm Bäder
dd370db62a reftests: Pass common_cflags 2020-05-19 08:32:33 +02:00
Timm Bäder
43ba86b7af tools: Pass common_cflags to executables 2020-05-19 08:32:33 +02:00
Timm Bäder
2425d61516 Pass common_cflags to testuite/gsk executables 2020-05-19 08:32:33 +02:00
Timm Bäder
3bf4c5687c Pass common_cflags to print backends 2020-05-19 08:32:33 +02:00
Nelson Benítez León
13506e36aa FileChooserButton: query 'display name' also for unbookmarked files
Do also the async file info query for remote files when they
are not bookmarked, because otherwise "None" will be shown as
file name (and fallback text generic icon will be used).

The remote file was already browsed by the file chooser
instance when selecting it, so querying the display name
again should be using gio cache and not be slow.

Even if it's were slow it's better than showing 'None'
which makes it seem as if nothing was selected.

Fixes #1966
2020-04-19 16:59:33 -04:00
1636 changed files with 241544 additions and 95185 deletions

View File

@@ -17,7 +17,12 @@ stages:
# Common variables
variables:
COMMON_MESON_FLAGS: "--fatal-meson-warnings --werror"
MESON_TEST_TIMEOUT_MULTIPLIER: 2
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true -Dvulkan=yes"
FEATURE_FLAGS: "-Dcloudproviders=true"
MESON_TEST_TIMEOUT_MULTIPLIER: 3
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v20"
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"
@@ -183,8 +180,24 @@ static-scan:
- _scan_build/meson-logs
allow_failure: true
# Run tests with the address sanitizer. We need to turn off introspection,
# since it is incompatible with asan
asan-build:
image: $FEDORA_IMAGE
tags: [ asan ]
stage: analysis
variables:
script:
- CC=clang meson --buildtype=debugoptimized -Db_sanitize=address -Db_lundef=false -Dintrospection=false _build
- ninja -C _build
- .gitlab-ci/run-tests.sh _build wayland
artifacts:
paths:
- _build/meson-logs
allow_failure: true
reference:
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v16
image: $DOCS_IMAGE
stage: docs
variables:
EXTRA_MESON_FLAGS: "--buildtype=release"

0
.gitlab-ci/.lock Normal file
View File

View File

@@ -35,4 +35,13 @@ branch, as well as their available versions.
- [ ] Add the new job to `.gitlab-ci.yml` referencing the image
- [ ] Open a merge request with your changes and let it run
### Checklist for Adding a new dependency to a CI image
Our images are layered, and the base (called fedora-base) contains
all the rpm payload. Therefore, adding a new dependency is a 2-step
process:
1. [ ] Build and upload fedora-base:$version+1
1. [ ] Build and upload fedora:$version+1 based on fedora-base:version+1
[registry]: https://gitlab.gnome.org/GNOME/gtk/container_registry

View File

@@ -0,0 +1,90 @@
FROM fedora:31
RUN dnf -y install \
adwaita-icon-theme \
atk-devel \
at-spi2-atk-devel \
avahi-gobject-devel \
cairo-devel \
cairo-gobject-devel \
ccache \
clang \
clang-analyzer \
colord-devel \
cups-devel \
dbus-daemon \
dbus-x11 \
dejavu-sans-mono-fonts \
desktop-file-utils \
diffutils \
elfutils-libelf-devel \
fribidi-devel \
gcc \
gcc-c++ \
gdk-pixbuf2-devel \
gdk-pixbuf2-modules \
gettext \
git \
glib2-devel \
glib2-static \
glibc-devel \
glibc-headers \
gobject-introspection-devel \
graphene-devel \
gstreamer1-devel \
gstreamer1-plugins-good \
gstreamer1-plugins-bad-free-devel \
gstreamer1-plugins-base-devel \
gtk-doc \
hicolor-icon-theme \
iso-codes \
itstool \
json-glib-devel \
lcov \
libasan \
libattr-devel \
libepoxy-devel \
libffi-devel \
libmount-devel \
librsvg2 \
libselinux-devel \
libubsan \
libXcomposite-devel \
libXcursor-devel \
libXcursor-devel \
libXdamage-devel \
libXfixes-devel \
libXi-devel \
libXinerama-devel \
libxkbcommon-devel \
libXrandr-devel \
libXrender-devel \
libXtst-devel \
libxslt \
mesa-dri-drivers \
mesa-libEGL-devel \
mesa-libwayland-egl-devel \
ninja-build \
pango-devel \
pcre-devel \
pcre-static \
python3 \
python3-jinja2 \
python3-pip \
python3-pygments \
python3-wheel \
redhat-rpm-config \
sassc \
sysprof-devel \
systemtap-sdt-devel \
vulkan-devel \
wayland-devel \
wayland-protocols-devel \
weston \
weston-libs \
which \
xorg-x11-server-Xvfb \
&& dnf clean all
RUN pip3 install meson==0.53.1

View File

@@ -0,0 +1,12 @@
FROM registry.gitlab.gnome.org/gnome/gtk/fedora-base:v19
RUN dnf -y install pandoc
ARG HOST_USER_ID=5555
ENV HOST_USER_ID ${HOST_USER_ID}
RUN useradd -u $HOST_USER_ID -ms /bin/bash user
USER user
WORKDIR /home/user
ENV LANG C.UTF-8

View File

@@ -1,90 +1,4 @@
FROM fedora:31
RUN dnf -y install \
adwaita-icon-theme \
atk-devel \
at-spi2-atk-devel \
avahi-gobject-devel \
cairo-devel \
cairo-gobject-devel \
ccache \
clang \
clang-analyzer \
colord-devel \
cups-devel \
dbus-daemon \
dbus-x11 \
dejavu-sans-mono-fonts \
desktop-file-utils \
diffutils \
elfutils-libelf-devel \
fribidi-devel \
gcc \
gcc-c++ \
gdk-pixbuf2-devel \
gdk-pixbuf2-modules \
gettext \
git \
glib2-devel \
glib2-static \
glibc-devel \
glibc-headers \
gobject-introspection-devel \
graphene-devel \
gstreamer1-devel \
gstreamer1-plugins-good \
gstreamer1-plugins-bad-free-devel \
gstreamer1-plugins-base-devel \
gtk-doc \
hicolor-icon-theme \
iso-codes \
itstool \
json-glib-devel \
lcov \
libattr-devel \
libepoxy-devel \
libffi-devel \
libmount-devel \
librsvg2 \
libselinux-devel \
libXcomposite-devel \
libXcursor-devel \
libXcursor-devel \
libXdamage-devel \
libXfixes-devel \
libXi-devel \
libXinerama-devel \
libxkbcommon-devel \
libXrandr-devel \
libXrender-devel \
libXtst-devel \
libxslt \
mesa-dri-drivers \
mesa-libEGL-devel \
mesa-libwayland-egl-devel \
ninja-build \
pango-devel \
pcre-devel \
pcre-static \
python3 \
python3-jinja2 \
python3-pip \
python3-pygments \
python3-wheel \
redhat-rpm-config \
sassc \
sysprof-devel \
systemtap-sdt-devel \
vulkan-devel \
wayland-devel \
wayland-protocols-devel \
weston \
weston-libs \
which \
xorg-x11-server-Xvfb \
&& dnf clean all
RUN pip3 install meson==0.53.1
FROM registry.gitlab.gnome.org/gnome/gtk/fedora-base:v20
ARG HOST_USER_ID=5555
ENV HOST_USER_ID ${HOST_USER_ID}

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

@@ -7,10 +7,14 @@ srcdir=$( pwd )
builddir=$1
backend=$2
# Ignore memory leaks lower in dependencies
export LSAN_OPTIONS=suppressions=$srcdir/lsan.supp
case "${backend}" in
x11)
xvfb-run -a -s "-screen 0 1024x768x24" \
meson test -C ${builddir} \
--timeout-multiplier "${MESON_TEST_TIMEOUT_MULTIPLIER}" \
--print-errorlogs \
--setup=${backend} \
--suite=gtk \
@@ -25,11 +29,12 @@ case "${backend}" in
wayland)
export XDG_RUNTIME_DIR="$(mktemp -p $(pwd) -d xdg-runtime-XXXXXX)"
weston --backend=headless-backend.so --socket=wayland-5 &
weston --backend=headless-backend.so --socket=wayland-5 --idle-time=0 &
compositor=$!
export WAYLAND_DISPLAY=wayland-5
meson test -C ${builddir} \
--timeout-multiplier "${MESON_TEST_TIMEOUT_MULTIPLIER}" \
--print-errorlogs \
--setup=${backend} \
--suite=gtk \
@@ -48,6 +53,7 @@ case "${backend}" in
export BROADWAY_DISPLAY=:5
meson test -C ${builddir} \
--timeout-multiplier "${MESON_TEST_TIMEOUT_MULTIPLIER}" \
--print-errorlogs \
--setup=${backend} \
--suite=gtk \

View File

@@ -34,8 +34,8 @@ pacman --noconfirm -S --needed \
mingw-w64-$MSYS2_ARCH-shared-mime-info
# https://gitlab.gnome.org/GNOME/gtk/issues/2243
wget "https://gitlab.gnome.org/creiter/gitlab-ci-win32-runner-v2/raw/master/pango/mingw-w64-$MSYS2_ARCH-pango-1.44.7-1-any.pkg.tar.xz"
pacman --noconfirm -U "mingw-w64-$MSYS2_ARCH-pango-1.44.7-1-any.pkg.tar.xz"
wget "https://gitlab.gnome.org/creiter/gitlab-ci-win32-runner-v2/raw/master/pango/mingw-w64-$MSYS2_ARCH-pango-git-1.44.7.90.ge48ae523-1-any.pkg.tar.zst"
pacman --noconfirm -U "mingw-w64-$MSYS2_ARCH-pango-git-1.44.7.90.ge48ae523-1-any.pkg.tar.zst"
# https://github.com/msys2/MINGW-packages/pull/6465
pacman --noconfirm -S --needed mingw-w64-$MSYS2_ARCH-brotli

175
NEWS
View File

@@ -1,3 +1,178 @@
Overview of Changes in GTK 3.99.0
=================================
* Add GtkEditableLabel, a label that can be edited
* Add GtkBookmarkList, a list model for bookmarks
* Add GtkStringList, a list model for strings
* Add GtkBitset, and use it for representing selections
* GtkTreeView:
- Make cell editing work again
* GtkSpinButton:
- Make autosizing work again
* Printing:
- Use GtkDropDown in the print dialog
* GtkApplication
- Support opening files on OS X
* GtkFileChooser:
- Fix libcloudproviders support
- Turn GtkFileFilter into a GtkFilter
- Simplify the api
* GtkGridView, GtkListView:
- Improve scrolling behavior
- Autoscroll and autoexpand during DND
* GtkScrolledWindow:
- Make autoscrolling work again
* GtkFilterListModel:
- Add incremental filtering
* GtkSortListModel:
- Use timsort
- Add various tweaks that massively speed up sorting
- Add incremental sorting
* GtkWidget:
- Massively speed up action handling
* GtkEntry:
- Make entry completion work again
- Drop action support from GtkEntryCompletion
* Inspector:
- Improve list model support
- Add direct navigation between objects
* GDK:
- Compress scroll events
- Keep a scroll history
- Clean up GdkDevice api
- Improve frame clock accuracy
- Add a new macOS backend
* GSK:
- Use GL_ARB_framebuffer_object
* gtk-demo:
- Add incremental refill to the color grid
- Improve performance of the color grid
- Add an incrementally filtering word list
- Improve the sidebar
* Install print-editor as another demo
* Translation updates
Basque
Catalan
Chinese
Japanese
Kazakh
Lithuanian
Polish
Romanian
Spanish
Turkish
Ukrainian
Overview of Changes in GTK 3.98.5
=================================
* Introduce new list widgets and supporting infrastructure.
The main APIs are:
- GtkListView
- GtkGridView
- GtkColumnView and GtkColumnViewColumn
- GtkDropDown
- GtkListItemFactory and implementations
- GtkExpression
- GtkFilter and subclasses, and GtkFilterListModel
- GtkSorter and subclasses, and GtkSortListModel
- GtkSelectionModel and subclasses
- GtkTreeListModel, GtkTreeExpander and GtkTreeListRowSorter
* GtkFileChooser:
- Add a tracker3-based search engine implementation
- Rate-limit updates from the trash monitor
* GtkWindow:
- Redo the css node setup. There is now a single 'window' node
- Fix rounded corners on tiled windows
* GtkApplication:
- Drop app menu support. Menubar support is still there
* GtkFixed:
- Change coordinate APIs to take doubles
* GtkOverlay:
- Make GtkOverlayLayout public
* GtkTooltips:
- Fix line wrapping of tooltips
* Shortcuts:
- Fix mnemonic cycling
- Fix using '0' as a mnemonic
* Menus:
- Differentiate keypad keys in accelerators
* GtkIMContext:
- Add gtk_im_context_filter_key to allow event reinjection
* Themes:
- Adwaita: Limit the scope of backdrop
* Accessibility:
- Clean up and reorganize the code to prepare for the
dropping of ATK
* GDK:
- Drop unused enum and struct definitions from headers
- Make keymap translation API public again. Still needed
- Frameclock: Always use compositor refresh rate info
- Frameclock: Use quadratic correction for frame time jitter
- Frameclock: Ensure monotonicity
- Frameclock: Track resason for paint
- X11: Improve sync when the Nvidia driver is used
* GSK:
- GL renderer: Fix blurred outset shadows
- GL renderer: handle nested transform nodes properly
- GL renderer: Optimize clip handling
* gtk-demo:
- Improve the Drag-and-Drop demo with proper drag icons
- Don't show the main window if --run is given
- Add demos for list widgets and GtkDropDrown
* Documentation:
- Convert freestanding sections to markdown
- Drop the glossary
- Expand and improve the migration guide
* Build:
- We require pandoc now, for building the documentation
- Require Pango 1.45
* Translation updates:
Polish
Romanian
Slovenian
Turkish
Ukrainian
Overview of Changes in GTK 3.98.4
=================================

View File

@@ -1,29 +1,38 @@
{
"app-id": "org.gtk.WidgetFactory4",
"runtime": "org.gnome.Platform",
"runtime-version": "master",
"sdk": "org.gnome.Sdk",
"command": "gtk4-widget-factory",
"tags": ["devel", "development", "nightly"],
"desktop-file-name-prefix": "(Development) ",
"finish-args": [
"app-id" : "org.gtk.WidgetFactory4",
"runtime" : "org.gnome.Platform",
"runtime-version" : "master",
"sdk" : "org.gnome.Sdk",
"command" : "gtk4-widget-factory",
"tags" : [
"devel",
"development",
"nightly"
],
"desktop-file-name-prefix" : "(Development) ",
"finish-args" : [
"--device=dri",
"--share=ipc",
"--socket=fallback-x11",
"--socket=wayland",
"--talk-name=org.gtk.vfs", "--talk-name=org.gtk.vfs.*"
"--talk-name=org.gtk.vfs",
"--talk-name=org.gtk.vfs.*"
],
"cleanup": [
"cleanup" : [
"/include",
"/lib/pkgconfig", "/share/pkgconfig",
"/lib/pkgconfig",
"/share/pkgconfig",
"/share/aclocal",
"/man", "/share/man", "/share/gtk-doc",
"*.la", ".a",
"/man",
"/share/man",
"/share/gtk-doc",
"*.la",
".a",
"/lib/girepository-1.0",
"/share/gir-1.0",
"/share/doc"
],
"modules": [
"modules" : [
{
"name" : "wayland",
"buildsystem" : "autotools",
@@ -39,18 +48,18 @@
]
},
{
"name": "graphene",
"buildsystem": "meson",
"builddir": true,
"config-opts": [
"name" : "graphene",
"buildsystem" : "meson",
"builddir" : true,
"config-opts" : [
"--libdir=/app/lib",
"-Dtests=false",
"-Dbenchmarks=false"
],
"sources": [
"sources" : [
{
"type": "git",
"url": "https://github.com/ebassi/graphene.git"
"type" : "git",
"url" : "https://github.com/ebassi/graphene.git"
}
]
},
@@ -58,7 +67,7 @@
"name" : "libsass",
"buildsystem" : "meson",
"builddir" : true,
"config-opts": [
"config-opts" : [
"--libdir=/app/lib"
],
"sources" : [
@@ -73,7 +82,7 @@
"name" : "sassc",
"buildsystem" : "meson",
"builddir" : true,
"config-opts": [
"config-opts" : [
"--libdir=/app/lib"
],
"sources" : [
@@ -85,18 +94,23 @@
]
},
{
"name": "gtk",
"buildsystem": "meson",
"builddir": true,
"config-opts": [
"name" : "gtk",
"buildsystem" : "meson",
"builddir" : true,
"config-opts" : [
"--libdir=/app/lib"
],
"sources": [
"sources" : [
{
"type": "git",
"url": "https://gitlab.gnome.org/GNOME/gtk.git"
"type" : "git",
"url" : "https://gitlab.gnome.org/GNOME/gtk.git"
}
]
}
]
],
"build-options" : {
"env" : {
"DBUS_SESSION_BUS_ADDRESS" : "''"
}
}
}

View File

@@ -15,7 +15,13 @@ if 'DESTDIR' not in os.environ:
gtk_immodule_dir = os.path.join(gtk_moduledir, 'immodules')
print('Compiling GSettings schemas...')
subprocess.call(['glib-compile-schemas',
glib_compile_schemas = subprocess.check_output(['pkg-config',
'--variable=glib_compile_schemas',
'gio-2.0']).strip()
if not os.path.exists(glib_compile_schemas):
# pkg-config variables only available since GLib 2.62.0.
glib_compile_schemas = 'glib-compile-schemas'
subprocess.call([glib_compile_schemas,
os.path.join(gtk_datadir, 'glib-2.0', 'schemas')])
print('Updating icon cache...')
@@ -24,8 +30,14 @@ if 'DESTDIR' not in os.environ:
print('Updating module cache for print backends...')
os.makedirs(gtk_printmodule_dir, exist_ok=True)
subprocess.call(['gio-querymodules', gtk_printmodule_dir])
gio_querymodules = subprocess.check_output(['pkg-config',
'--variable=gio_querymodules',
'gio-2.0']).strip()
if not os.path.exists(gio_querymodules):
# pkg-config variables only available since GLib 2.62.0.
gio_querymodules = 'gio-querymodules'
subprocess.call([gio_querymodules, gtk_printmodule_dir])
print('Updating module cache for input methods...')
os.makedirs(gtk_immodule_dir, exist_ok=True)
subprocess.call(['gio-querymodules', gtk_immodule_dir])
subprocess.call([gio_querymodules, gtk_immodule_dir])

View File

@@ -27,14 +27,6 @@
/* Define to 1 if you have the `dcgettext' function. */
#mesondefine HAVE_DCGETTEXT
/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't.
*/
#mesondefine HAVE_DECL_ISINF
/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't.
*/
#mesondefine HAVE_DECL_ISNAN
/* Define to 1 if you have the <dlfcn.h> header file. */
#mesondefine HAVE_DLFCN_H
@@ -80,9 +72,6 @@
/* Define to 1 if you have a working `mmap' system call. */
#mesondefine HAVE_MMAP
/* Define to 1 if you have the `nearbyint' function. */
#mesondefine HAVE_NEARBYINT
/* Define to 1 if you have the `posix_fallocate' function. */
#mesondefine HAVE_POSIX_FALLOCATE
@@ -92,21 +81,9 @@
/* Have the Xrandr 1.5 extension library */
#mesondefine HAVE_RANDR15
/* Define to 1 if you have the `rint' function. */
#mesondefine HAVE_RINT
/* Define to 1 if you have the `round' function. */
#mesondefine HAVE_ROUND
/* Define to 1 if you have the `sincos' function. */
#mesondefine HAVE_SINCOS
/* Define to 1 if you have the `log2` function */
#mesondefine HAVE_LOG2
/* Define to 1 if you ahve the `exp2` function */
#mesondefine HAVE_EXP2
/* Define to 1 if you have the <stdint.h> header file. */
#mesondefine HAVE_STDINT_H
@@ -146,6 +123,9 @@
/* Have the Xcursor library */
#mesondefine HAVE_XCURSOR
/* Have the XDAMAGE X extension */
#mesondefine HAVE_XDAMAGE
/* Have the XFIXES X extension */
#mesondefine HAVE_XFIXES
@@ -292,3 +272,6 @@
#mesondefine HAVE_PANGOFT
#mesondefine ISO_CODES_PREFIX
/* Define if tracker3 is available */
#mesondefine HAVE_TRACKER3

View File

@@ -81,11 +81,11 @@ constraint_editor_application_activate (GApplication *app)
static void
constraint_editor_application_open (GApplication *app,
GFile **files,
gint n_files,
const gchar *hint)
int n_files,
const char *hint)
{
ConstraintEditorWindow *win;
gint i;
int i;
for (i = 0; i < n_files; i++)
{

View File

@@ -193,7 +193,7 @@ constraint_editor_window_load (ConstraintEditorWindow *self,
static void
open_response_cb (GtkNativeDialog *dialog,
gint response,
int response,
ConstraintEditorWindow *self)
{
gtk_native_dialog_hide (dialog);
@@ -285,7 +285,7 @@ serialize_model (GListModel *list)
static void
save_response_cb (GtkNativeDialog *dialog,
gint response,
int response,
ConstraintEditorWindow *self)
{
gtk_native_dialog_hide (dialog);
@@ -487,8 +487,6 @@ constraint_editor_window_class_init (ConstraintEditorWindowClass *class)
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
g_type_ensure (CONSTRAINT_VIEW_TYPE);
object_class->finalize = constraint_editor_window_finalize;
gtk_widget_class_set_template_from_resource (widget_class,

View File

@@ -9,7 +9,6 @@
<property name="default-height">768</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="header">
<property name="show-title-buttons">1</property>
<child type="start">
<object class="GtkButton">
<property name="icon-name">document-open-symbolic</property>

View File

@@ -169,28 +169,30 @@ constraint_view_init (ConstraintView *self)
GListModel *guides;
GListModel *children;
GListModel *constraints;
GtkFilter *filter;
manager = gtk_constraint_layout_new ();
gtk_widget_set_layout_manager (GTK_WIDGET (self), manager);
all_children = gtk_widget_observe_children (GTK_WIDGET (self));
all_constraints = gtk_constraint_layout_observe_constraints (GTK_CONSTRAINT_LAYOUT (manager));
guides = gtk_constraint_layout_observe_guides (GTK_CONSTRAINT_LAYOUT (manager));
constraints = (GListModel *)gtk_filter_list_model_new (all_constraints, omit_internal, NULL, NULL);
children = (GListModel *)gtk_filter_list_model_new (all_children, omit_internal, NULL, NULL);
all_constraints = gtk_constraint_layout_observe_constraints (GTK_CONSTRAINT_LAYOUT (manager));
filter = gtk_custom_filter_new (omit_internal, NULL, NULL);
constraints = (GListModel *)gtk_filter_list_model_new (all_constraints, filter);
all_children = gtk_widget_observe_children (GTK_WIDGET (self));
filter = gtk_custom_filter_new (omit_internal, NULL, NULL);
children = (GListModel *)gtk_filter_list_model_new (all_children, filter);
list = g_list_store_new (G_TYPE_LIST_MODEL);
g_list_store_append (list, children);
g_list_store_append (list, guides);
g_list_store_append (list, constraints);
self->model = G_LIST_MODEL (gtk_flatten_list_model_new (G_TYPE_OBJECT, G_LIST_MODEL (list)));
g_object_unref (children);
g_object_unref (guides);
g_object_unref (constraints);
g_object_unref (all_children);
g_object_unref (all_constraints);
g_object_unref (list);
self->model = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (list)));
controller = (GtkEventController *)gtk_gesture_drag_new ();
g_signal_connect (controller, "drag-begin", G_CALLBACK (drag_begin), self);

View File

@@ -23,6 +23,7 @@
#define CONSTRAINT_VIEW_TYPE (constraint_view_get_type ())
G_MODULE_EXPORT
G_DECLARE_FINAL_TYPE (ConstraintView, constraint_view, CONSTRAINT, VIEW, GtkWidget)
ConstraintView * constraint_view_new (void);

View File

@@ -184,58 +184,6 @@ max_input (GtkSpinButton *spin_button,
return FALSE;
}
static gboolean
min_output (GtkSpinButton *spin_button)
{
GtkAdjustment *adjustment;
double value;
GtkWidget *box, *text;
adjustment = gtk_spin_button_get_adjustment (spin_button);
value = gtk_adjustment_get_value (adjustment);
box = gtk_widget_get_first_child (GTK_WIDGET (spin_button));
text = gtk_widget_get_first_child (box);
if (value == 0.0)
{
gtk_editable_set_text (GTK_EDITABLE (spin_button), "");
gtk_text_set_placeholder_text (GTK_TEXT (text), "unset");
return TRUE;
}
else
{
gtk_text_set_placeholder_text (GTK_TEXT (text), "");
return FALSE;
}
}
static gboolean
max_output (GtkSpinButton *spin_button)
{
GtkAdjustment *adjustment;
double value;
GtkWidget *box, *text;
adjustment = gtk_spin_button_get_adjustment (spin_button);
value = gtk_adjustment_get_value (adjustment);
box = gtk_widget_get_first_child (GTK_WIDGET (spin_button));
text = gtk_widget_get_first_child (box);
if (value == (double)G_MAXINT)
{
gtk_editable_set_text (GTK_EDITABLE (spin_button), "");
gtk_text_set_placeholder_text (GTK_TEXT (text), "unset");
return TRUE;
}
else
{
gtk_text_set_placeholder_text (GTK_TEXT (text), "");
return FALSE;
}
}
static void
guide_editor_constructed (GObject *object)
{
@@ -244,16 +192,12 @@ guide_editor_constructed (GObject *object)
guide_strength_combo (editor->strength);
g_signal_connect (editor->min_width, "input", G_CALLBACK (min_input), NULL);
g_signal_connect (editor->min_width, "output", G_CALLBACK (min_output), NULL);
g_signal_connect (editor->min_height, "input", G_CALLBACK (min_input), NULL);
g_signal_connect (editor->min_height, "output", G_CALLBACK (min_output), NULL);
g_signal_connect (editor->max_width, "input", G_CALLBACK (max_input), NULL);
g_signal_connect (editor->max_width, "output", G_CALLBACK (max_output), NULL);
g_signal_connect (editor->max_height, "input", G_CALLBACK (max_input), NULL);
g_signal_connect (editor->max_height, "output", G_CALLBACK (max_output), NULL);
if (editor->guide)
{

View File

@@ -34,7 +34,7 @@ static void create_window (GApplication *app, const char *contents);
static void
show_action_dialog (GSimpleAction *action)
{
const gchar *name;
const char *name;
GtkWidget *dialog;
name = g_action_get_name (G_ACTION (action));
@@ -58,9 +58,9 @@ show_action_infobar (GSimpleAction *action,
gpointer data)
{
DemoApplicationWindow *window = data;
gchar *text;
const gchar *name;
const gchar *value;
char *text;
const char *name;
const char *value;
name = g_action_get_name (G_ACTION (action));
value = g_variant_get_string (parameter, NULL);
@@ -92,7 +92,7 @@ activate_new (GSimpleAction *action,
static void
open_response_cb (GtkNativeDialog *dialog,
gint response_id,
int response_id,
gpointer user_data)
{
GtkFileChooserNative *native = user_data;
@@ -185,7 +185,7 @@ activate_about (GSimpleAction *action,
{
GtkWidget *window = user_data;
const gchar *authors[] = {
const char *authors[] = {
"Peter Mattis",
"Spencer Kimball",
"Josh MacDonald",
@@ -193,7 +193,7 @@ activate_about (GSimpleAction *action,
NULL
};
const gchar *documentors[] = {
const char *documentors[] = {
"Owen Taylor",
"Tony Gale",
"Matthias Clasen <mclasen@redhat.com>",
@@ -244,9 +244,9 @@ static void
update_statusbar (GtkTextBuffer *buffer,
DemoApplicationWindow *window)
{
gchar *msg;
gint row, col;
gint count;
char *msg;
int row, col;
int count;
GtkTextIter iter;
/* clear any previous message, underflow is allowed */
@@ -328,19 +328,14 @@ static void
startup (GApplication *app)
{
GtkBuilder *builder;
GMenuModel *appmenu;
GMenuModel *menubar;
G_APPLICATION_CLASS (demo_application_parent_class)->startup (app);
builder = gtk_builder_new ();
gtk_builder_add_from_resource (builder, "/application_demo/menus.ui", NULL);
appmenu = (GMenuModel *)gtk_builder_get_object (builder, "appmenu");
menubar = (GMenuModel *)gtk_builder_get_object (builder, "menubar");
gtk_application_set_app_menu (GTK_APPLICATION (app), appmenu);
gtk_application_set_menubar (GTK_APPLICATION (app), menubar);
gtk_application_set_menubar (GTK_APPLICATION (app),
G_MENU_MODEL (gtk_builder_get_object (builder, "menubar")));
g_object_unref (builder);
}
@@ -353,6 +348,7 @@ create_window (GApplication *app,
window = (DemoApplicationWindow *)g_object_new (demo_application_window_get_type (),
"application", app,
"show-menubar", TRUE,
NULL);
if (content)
gtk_text_buffer_set_text (window->buffer, content, -1);

View File

@@ -16,8 +16,8 @@ static GtkWidget *placeholder;
static void
on_name_appeared (GDBusConnection *connection,
const gchar *name,
const gchar *name_owner,
const char *name,
const char *name_owner,
gpointer user_data)
{
name_seen = TRUE;
@@ -25,7 +25,7 @@ on_name_appeared (GDBusConnection *connection,
static void
on_name_vanished (GDBusConnection *connection,
const gchar *name,
const char *name,
gpointer user_data)
{
if (!name_seen)
@@ -55,7 +55,7 @@ do_application_demo (GtkWidget *toplevel)
if (placeholder == NULL)
{
const gchar *command;
const char *command;
GError *error = NULL;
if (g_file_test ("./gtk4-demo-application" APP_EXTENSION, G_FILE_TEST_IS_EXECUTABLE))

View File

@@ -1,18 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<menu id="appmenu">
<section>
<item>
<attribute name="label" translatable="yes">About</attribute>
<attribute name="action">app.about</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">_Quit</attribute>
<attribute name="action">app.quit</attribute>
<attribute name="accel">&lt;Control&gt;q</attribute>
</item>
</section>
</menu>
</interface>

View File

@@ -12,7 +12,7 @@ static GtkWidget *progress_bar = NULL;
static gboolean
apply_changes_gradually (gpointer data)
{
gdouble fraction;
double fraction;
/* Work, work, work... */
fraction = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (progress_bar));
@@ -47,8 +47,8 @@ on_assistant_close_cancel (GtkWidget *widget, gpointer data)
static void
on_assistant_prepare (GtkWidget *widget, GtkWidget *page, gpointer data)
{
gint current_page, n_pages;
gchar *title;
int current_page, n_pages;
char *title;
current_page = gtk_assistant_get_current_page (GTK_ASSISTANT (widget));
n_pages = gtk_assistant_get_n_pages (GTK_ASSISTANT (widget));
@@ -70,8 +70,8 @@ on_entry_changed (GtkWidget *widget, gpointer data)
{
GtkAssistant *assistant = GTK_ASSISTANT (data);
GtkWidget *current_page;
gint page_number;
const gchar *text;
int page_number;
const char *text;
page_number = gtk_assistant_get_current_page (assistant);
current_page = gtk_assistant_get_nth_page (assistant, page_number);

View File

@@ -83,7 +83,7 @@ do_builder (GtkWidget *do_widget)
window);
gtk_widget_insert_action_group (window, "win", actions);
g_object_set_data_full (G_OBJECT(window), "builder", builder, g_object_unref);
g_object_unref (builder);
}
if (!gtk_widget_get_visible (window))

File diff suppressed because it is too large Load Diff

View File

@@ -38,7 +38,7 @@ create_icon_store (void)
GtkTreeIter iter;
GtkListStore *store;
gint i;
int i;
store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
@@ -77,7 +77,7 @@ set_sensitive (GtkCellLayout *cell_layout,
gpointer data)
{
GtkTreePath *path;
gint *indices;
int *indices;
gboolean sensitive;
path = gtk_tree_model_get_path (tree_model, iter);
@@ -175,7 +175,7 @@ create_capital_store (void)
GtkTreeIter iter, iter2;
GtkTreeStore *store;
gint i;
int i;
store = gtk_tree_store_new (1, G_TYPE_STRING);

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,10 +94,10 @@ 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_box_append (GTK_BOX (container), child);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (container), child);
g_signal_connect (text, "changed",
G_CALLBACK (css_text_changed), provider);

View File

@@ -38,14 +38,14 @@ struct {
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
static void
update_css_for_blend_mode (GtkCssProvider *provider,
const gchar *blend_mode)
const char *blend_mode)
{
GBytes *bytes;
gchar *css;
char *css;
bytes = g_resources_lookup_data ("/css_blendmodes/css_blendmodes.css", 0, NULL);
css = g_strdup_printf ((gchar*) g_bytes_get_data (bytes, NULL),
css = g_strdup_printf ((char *) g_bytes_get_data (bytes, NULL),
blend_mode,
blend_mode,
blend_mode);
@@ -62,7 +62,7 @@ row_activated (GtkListBox *listbox,
GtkListBoxRow *row,
GtkCssProvider *provider)
{
const gchar *blend_mode;
const char *blend_mode;
blend_mode = blend_modes[gtk_list_box_row_get_index (row)].id;
@@ -75,7 +75,7 @@ setup_listbox (GtkBuilder *builder,
{
GtkWidget *normal_row;
GtkWidget *listbox;
gint i;
int i;
normal_row = NULL;
listbox = gtk_list_box_new ();
@@ -134,6 +134,8 @@ do_css_blendmodes (GtkWidget *do_widget)
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
setup_listbox (builder, provider);
g_object_unref (builder);
}
if (!gtk_widget_get_visible (window))

View File

@@ -85,7 +85,7 @@ do_css_multiplebgs (GtkWidget *do_widget)
if (!window)
{
GtkWidget *paned, *container, *child;
GtkWidget *paned, *overlay, *child, *sw;
GtkStyleProvider *provider;
GtkTextBuffer *text;
GBytes *bytes;
@@ -96,25 +96,25 @@ do_css_multiplebgs (GtkWidget *do_widget)
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
container = gtk_overlay_new ();
gtk_window_set_child (GTK_WINDOW (window), container);
overlay = gtk_overlay_new ();
gtk_window_set_child (GTK_WINDOW (window), overlay);
child = gtk_drawing_area_new ();
gtk_widget_set_name (child, "canvas");
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (child),
drawing_area_draw,
NULL, NULL);
gtk_box_append (GTK_BOX (container), child);
gtk_overlay_set_child (GTK_OVERLAY (overlay), child);
child = gtk_button_new ();
gtk_overlay_add_overlay (GTK_OVERLAY (container), child);
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), child);
gtk_widget_set_name (child, "bricks-button");
gtk_widget_set_halign (child, GTK_ALIGN_CENTER);
gtk_widget_set_valign (child, GTK_ALIGN_CENTER);
gtk_widget_set_size_request (child, 250, 84);
paned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
gtk_overlay_add_overlay (GTK_OVERLAY (container), paned);
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), paned);
/* Need a filler so we get a handle */
child = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
@@ -132,10 +132,10 @@ do_css_multiplebgs (GtkWidget *do_widget)
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
container = gtk_scrolled_window_new (NULL, NULL);
gtk_paned_set_end_child (GTK_PANED (paned), container);
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 (container), child);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), child);
g_signal_connect (text,
"changed",
G_CALLBACK (css_text_changed),

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>
@@ -29,7 +28,7 @@ do_cursors (GtkWidget *do_widget)
gtk_widget_get_display (do_widget));
g_signal_connect (window, "destroy",
G_CALLBACK (on_destroy), NULL);
g_object_set_data_full (G_OBJECT (window), "builder", builder, g_object_unref);
g_object_unref (builder);
}
if (!gtk_widget_get_visible (window))

View File

@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/">
</gresource>
<gresource prefix="/ui">
<file preprocess="xml-stripblanks">main.ui</file>
<file preprocess="xml-stripblanks">appmenu.ui</file>
<file preprocess="xml-stripblanks">main-listitem.ui</file>
</gresource>
<gresource prefix="/application_demo">
<file>application.c</file>
@@ -103,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>
@@ -119,6 +124,24 @@
<file>gnome-fs-directory.png</file>
<file>gnome-fs-regular.png</file>
</gresource>
<gresource prefix="/listview_filebrowser">
<file>listview_filebrowser.ui</file>
<file>listview_filebrowser.css</file>
</gresource>
<gresource prefix="/listview_minesweeper">
<file>listview_minesweeper.ui</file>
<file>listview_minesweeper_cell.ui</file>
</gresource>
<gresource prefix="/listview_settings">
<file>listview_settings.ui</file>
</gresource>
<gresource prefix="/listview_weather">
<file compressed="true">listview_weather.txt</file>
</gresource>
<gresource prefix="/listview_colors">
<file compressed="true">color.names.txt</file>
<file>listview_colors.css</file>
</gresource>
<gresource prefix="/shortcuts">
<file>shortcuts.ui</file>
<file>shortcuts-builder.ui</file>
@@ -171,6 +194,7 @@
<file>cursors.c</file>
<file>dialog.c</file>
<file>drawingarea.c</file>
<file>dropdown.c</file>
<file>dnd.c</file>
<file>editable_cells.c</file>
<file>entry_completion.c</file>
@@ -195,6 +219,14 @@
<file>infobar.c</file>
<file>links.c</file>
<file>listbox.c</file>
<file>listview_applauncher.c</file>
<file>listview_colors.c</file>
<file>listview_clocks.c</file>
<file>listview_filebrowser.c</file>
<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>
@@ -269,6 +301,7 @@
</gresource>
<gresource prefix="/transparent">
<file>portland-rose.jpg</file>
<file>bluroverlay.h</file>
<file>bluroverlay.c</file>
</gresource>
<gresource prefix="/markup">

View File

@@ -17,7 +17,7 @@ G_DEFINE_TYPE(DemoImage, demo_image, GTK_TYPE_WIDGET)
static GdkPaintable *
get_image_paintable (GtkImage *image)
{
const gchar *icon_name;
const char *icon_name;
GtkIconTheme *icon_theme;
GtkIconPaintable *icon;

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>
@@ -15,16 +16,15 @@ message_dialog_clicked (GtkButton *button,
gpointer user_data)
{
GtkWidget *dialog;
static gint i = 1;
static int i = 1;
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
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

@@ -7,6 +7,324 @@
#include <gtk/gtk.h>
G_DECLARE_FINAL_TYPE (CanvasItem, canvas_item, CANVAS, ITEM, GtkWidget)
struct _CanvasItem {
GtkWidget parent;
GtkWidget *fixed;
GtkWidget *label;
double r;
double angle;
double delta;
GtkWidget *editor;
};
struct _CanvasItemClass {
GtkWidgetClass parent_class;
};
G_DEFINE_TYPE (CanvasItem, canvas_item, GTK_TYPE_WIDGET)
static int n_items = 0;
static void
set_color (CanvasItem *item,
GdkRGBA *color)
{
char *css;
char *str;
GtkStyleContext *context;
GtkCssProvider *provider;
const char *old_class;
str = gdk_rgba_to_string (color);
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);
g_object_set_data_full (G_OBJECT (context), "style-provider", provider, g_object_unref);
g_free (str);
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,
double x,
double y)
{
GtkWidget *label = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (dest));
CanvasItem *item = CANVAS_ITEM (gtk_widget_get_parent (gtk_widget_get_parent (label)));
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;
}
static void
apply_transform (CanvasItem *item)
{
GskTransform *transform;
double x, y;
x = gtk_widget_get_allocated_width (item->label) / 2.0;
y = gtk_widget_get_allocated_height (item->label) / 2.0;
item->r = sqrt (x*x + y*y);
transform = gsk_transform_translate (
gsk_transform_rotate (
gsk_transform_translate (NULL,
&(graphene_point_t) { item->r, item->r }),
item->angle + item->delta),
&(graphene_point_t) { - x, - y });
gtk_fixed_set_child_transform (GTK_FIXED (item->fixed), item->label, transform);
gsk_transform_unref (transform);
}
static void
angle_changed (GtkGestureRotate *gesture,
double angle,
double delta)
{
CanvasItem *item = CANVAS_ITEM (gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture)));
item->delta = angle / M_PI * 180.0;
apply_transform (item);
}
static void
rotate_done (GtkGesture *gesture)
{
CanvasItem *item = CANVAS_ITEM (gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture)));
item->angle = item->angle + item->delta;
item->delta = 0;
}
static void
click_done (GtkGesture *gesture)
{
GtkWidget *item = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
GtkWidget *canvas = gtk_widget_get_parent (item);
GtkWidget *last_child;
last_child = gtk_widget_get_last_child (canvas);
if (item != last_child)
gtk_widget_insert_after (item, canvas, last_child);
}
static void
canvas_item_init (CanvasItem *item)
{
char *text;
char *id;
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 ();
gtk_widget_set_parent (item->fixed, GTK_WIDGET (item));
gtk_fixed_put (GTK_FIXED (item->fixed), item->label, 0, 0);
gtk_widget_add_css_class (item->label, "frame");
id = g_strdup_printf ("item%d", n_items);
gtk_widget_set_name (item->label, id);
g_free (id);
gdk_rgba_parse (&rgba, "yellow");
set_color (item, &rgba);
item->angle = 0;
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));
gesture = gtk_gesture_rotate_new ();
g_signal_connect (gesture, "angle-changed", G_CALLBACK (angle_changed), NULL);
g_signal_connect (gesture, "end", G_CALLBACK (rotate_done), NULL);
gtk_widget_add_controller (GTK_WIDGET (item), GTK_EVENT_CONTROLLER (gesture));
gesture = gtk_gesture_click_new ();
g_signal_connect (gesture, "released", G_CALLBACK (click_done), NULL);
gtk_widget_add_controller (GTK_WIDGET (item), GTK_EVENT_CONTROLLER (gesture));
}
static void
canvas_item_dispose (GObject *object)
{
CanvasItem *item = CANVAS_ITEM (object);
g_clear_pointer (&item->fixed, gtk_widget_unparent);
g_clear_pointer (&item->editor, gtk_widget_unparent);
G_OBJECT_CLASS (canvas_item_parent_class)->dispose (object);
}
static void
canvas_item_map (GtkWidget *widget)
{
CanvasItem *item = CANVAS_ITEM (widget);
GTK_WIDGET_CLASS (canvas_item_parent_class)->map (widget);
apply_transform (item);
}
static void
canvas_item_class_init (CanvasItemClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
object_class->dispose = canvas_item_dispose;
widget_class->map = canvas_item_map;
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
gtk_widget_class_set_css_name (widget_class, "item");
}
static GtkWidget *
canvas_item_new (void)
{
CanvasItem *item = g_object_new (canvas_item_get_type (), NULL);
return GTK_WIDGET (item);
}
static GdkPaintable *
canvas_item_get_drag_icon (CanvasItem *item)
{
return gtk_widget_paintable_new (item->fixed);
}
static gboolean
canvas_item_is_editing (CanvasItem *item)
{
return item->editor != NULL;
}
static void
scale_changed (GtkRange *range,
CanvasItem *item)
{
item->angle = gtk_range_get_value (range);
apply_transform (item);
}
static void
text_changed (GtkEditable *editable,
GParamSpec *pspec,
CanvasItem *item)
{
gtk_label_set_text (GTK_LABEL (item->label), gtk_editable_get_text (editable));
apply_transform (item);
}
static void
canvas_item_stop_editing (CanvasItem *item)
{
GtkWidget *scale;
if (!item->editor)
return;
scale = gtk_widget_get_last_child (item->editor);
g_signal_handlers_disconnect_by_func (scale, scale_changed, item);
gtk_fixed_remove (GTK_FIXED (gtk_widget_get_parent (item->editor)), item->editor);
item->editor = NULL;
}
static void
canvas_item_start_editing (CanvasItem *item)
{
GtkWidget *canvas = gtk_widget_get_parent (GTK_WIDGET (item));
GtkWidget *entry;
GtkWidget *scale;
double x, y;
if (item->editor)
return;
item->editor = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
entry = gtk_entry_new ();
gtk_editable_set_text (GTK_EDITABLE (entry),
gtk_label_get_text (GTK_LABEL (item->label)));
gtk_editable_set_width_chars (GTK_EDITABLE (entry), 12);
g_signal_connect (entry, "notify::text", G_CALLBACK (text_changed), item);
g_signal_connect_swapped (entry, "activate", G_CALLBACK (canvas_item_stop_editing), item);
gtk_box_append (GTK_BOX (item->editor), entry);
scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 360, 1);
gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
gtk_range_set_value (GTK_RANGE (scale), fmod (item->angle, 360));
g_signal_connect (scale, "value-changed", G_CALLBACK (scale_changed), item);
gtk_box_append (GTK_BOX (item->editor), scale);
gtk_widget_translate_coordinates (GTK_WIDGET (item), canvas, 0, 0, &x, &y);
gtk_fixed_put (GTK_FIXED (canvas), item->editor, x, y + 2 * item->r);
gtk_widget_grab_focus (entry);
}
static GdkContentProvider *
prepare (GtkDragSource *source,
double x,
@@ -18,7 +336,8 @@ prepare (GtkDragSource *source,
canvas = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (source));
item = gtk_widget_pick (canvas, x, y, GTK_PICK_DEFAULT);
if (!GTK_IS_LABEL (item))
item = gtk_widget_get_ancestor (item, canvas_item_get_type ());
if (!item)
return NULL;
g_object_set_data (G_OBJECT (canvas), "dragged-item", item);
@@ -31,12 +350,17 @@ drag_begin (GtkDragSource *source,
GdkDrag *drag)
{
GtkWidget *canvas;
GtkWidget *item;
CanvasItem *item;
GdkPaintable *paintable;
canvas = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (source));
item = g_object_get_data (G_OBJECT (canvas), "dragged-item");
item = CANVAS_ITEM (g_object_get_data (G_OBJECT (canvas), "dragged-item"));
gtk_widget_set_opacity (item, 0.5);
paintable = canvas_item_get_drag_icon (item);
gtk_drag_source_set_icon (source, paintable, item->r, item->r);
g_object_unref (paintable);
gtk_widget_set_opacity (GTK_WIDGET (item), 0.3);
}
static void
@@ -61,110 +385,56 @@ drag_cancel (GtkDragSource *source,
return FALSE;
}
typedef struct {
double x, y;
double angle;
double delta;
} TransformData;
static void
apply_transform (GtkWidget *item)
{
GtkWidget *canvas = gtk_widget_get_parent (item);
TransformData *data;
GskTransform *transform;
data = g_object_get_data (G_OBJECT (item), "transform-data");
transform = gsk_transform_rotate (gsk_transform_translate (NULL, &(graphene_point_t){data->x, data->y}),
data->angle + data->delta);
gtk_fixed_set_child_transform (GTK_FIXED (canvas), item, transform);
gsk_transform_unref (transform);
}
static gboolean
drag_drop (GtkDropTarget *target,
const GValue *value,
double x,
double y)
{
GtkWidget *item;
TransformData *transform_data;
CanvasItem *item;
GtkWidget *canvas;
GtkWidget *last_child;
item = g_value_get_object (value);
transform_data = g_object_get_data (G_OBJECT (item), "transform-data");
transform_data->x = x;
transform_data->y = y;
canvas = gtk_widget_get_parent (item);
canvas = gtk_widget_get_parent (GTK_WIDGET (item));
last_child = gtk_widget_get_last_child (canvas);
if (item != last_child)
gtk_widget_insert_after (item, canvas, last_child);
if (GTK_WIDGET (item) != last_child)
gtk_widget_insert_after (GTK_WIDGET (item), canvas, last_child);
apply_transform (item);
gtk_fixed_move (GTK_FIXED (canvas), GTK_WIDGET (item), x - item->r, y - item->r);
return TRUE;
}
static double pos_x, pos_y;
static GtkWidget * canvas_item_new (double x, double y);
static void
new_item_cb (GtkWidget *button, gpointer data)
{
GtkWidget *canvas = data;
GtkWidget *popover;
GtkWidget *item;
GdkRectangle rect;
item = canvas_item_new (pos_x, pos_y);
gtk_fixed_put (GTK_FIXED (canvas), item, 0, 0);
apply_transform (item);
popover = gtk_widget_get_ancestor (button, GTK_TYPE_POPOVER);
gtk_popover_get_pointing_to (GTK_POPOVER (popover), &rect);
item = canvas_item_new ();
gtk_fixed_put (GTK_FIXED (canvas), item, rect.x, rect.y);
apply_transform (CANVAS_ITEM (item));
gtk_popover_popdown (GTK_POPOVER (gtk_widget_get_ancestor (button, GTK_TYPE_POPOVER)));
}
static void
edit_label_done (GtkWidget *entry, gpointer data)
{
GtkWidget *canvas = gtk_widget_get_parent (entry);
GtkWidget *label;
int x, y;
gtk_fixed_get_child_position (GTK_FIXED (canvas), entry, &x, &y);
label = GTK_WIDGET (g_object_get_data (G_OBJECT (entry), "label"));
gtk_label_set_text (GTK_LABEL (label), gtk_editable_get_text (GTK_EDITABLE (entry)));
gtk_widget_show (label);
gtk_fixed_remove (GTK_FIXED (canvas), entry);
}
static void
edit_cb (GtkWidget *button, GtkWidget *child)
{
GtkWidget *canvas = gtk_widget_get_parent (child);
int x, y;
gtk_fixed_get_child_position (GTK_FIXED (canvas), child, &x, &y);
if (GTK_IS_LABEL (child))
{
GtkWidget *entry = gtk_entry_new ();
g_object_set_data (G_OBJECT (entry), "label", child);
gtk_editable_set_text (GTK_EDITABLE (entry), gtk_label_get_text (GTK_LABEL (child)));
gtk_editable_set_width_chars (GTK_EDITABLE (entry), 12);
g_signal_connect (entry, "activate", G_CALLBACK (edit_label_done), NULL);
gtk_fixed_put (GTK_FIXED (canvas), entry, x, y);
gtk_widget_grab_focus (entry);
gtk_widget_hide (child);
}
CanvasItem *item = CANVAS_ITEM (child);
if (button)
gtk_popover_popdown (GTK_POPOVER (gtk_widget_get_ancestor (button, GTK_TYPE_POPOVER)));
if (!canvas_item_is_editing (item))
canvas_item_start_editing (item);
}
static void
@@ -189,6 +459,7 @@ pressed_cb (GtkGesture *gesture,
widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
child = gtk_widget_pick (widget, x, y, GTK_PICK_DEFAULT);
child = gtk_widget_get_ancestor (child, canvas_item_get_type ());
if (gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture)) == GDK_BUTTON_SECONDARY)
{
@@ -196,9 +467,6 @@ pressed_cb (GtkGesture *gesture,
GtkWidget *box;
GtkWidget *item;
pos_x = x;
pos_y = y;
menu = gtk_popover_new ();
gtk_widget_set_parent (menu, widget);
gtk_popover_set_has_arrow (GTK_POPOVER (menu), FALSE);
@@ -242,14 +510,20 @@ released_cb (GtkGesture *gesture,
{
GtkWidget *widget;
GtkWidget *child;
CanvasItem *item;
widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
child = gtk_widget_pick (widget, x, y, 0);
item = (CanvasItem *)gtk_widget_get_ancestor (child, canvas_item_get_type ());
if (!item)
return;
if (gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture)) == GDK_BUTTON_PRIMARY)
{
if (child != NULL && child != widget)
edit_cb (NULL, child);
if (canvas_item_is_editing (item))
canvas_item_stop_editing (item);
else
canvas_item_start_editing (item);
}
}
@@ -287,129 +561,117 @@ canvas_new (void)
return canvas;
}
static void
set_color (GtkWidget *item,
GdkRGBA *color)
static GdkContentProvider *
css_drag_prepare (GtkDragSource *source,
double x,
double y,
GtkWidget *button)
{
char *css;
char *str;
GtkStyleContext *context;
GtkCssProvider *provider;
const char *class;
GdkPaintable *paintable;
str = gdk_rgba_to_string (color);
css = g_strdup_printf ("* { background: %s; padding: 10px; }", str);
class = (const char *)g_object_get_data (G_OBJECT (button), "css-class");
context = gtk_widget_get_style_context (item);
provider = g_object_get_data (G_OBJECT (context), "style-provider");
if (provider)
gtk_style_context_remove_provider (context, GTK_STYLE_PROVIDER (provider));
paintable = gtk_widget_paintable_new (button);
gtk_drag_source_set_icon (source, paintable, 0, 0);
g_object_unref (paintable);
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), GTK_STYLE_PROVIDER (provider), 800);
g_object_set_data_full (G_OBJECT (context), "style-provider", provider, g_object_unref);
g_free (str);
g_free (css);
return gdk_content_provider_new_typed (G_TYPE_STRING, class);
}
static gboolean
item_drag_drop (GtkDropTarget *dest,
const GValue *value,
double x,
double y)
{
GtkWidget *item = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (dest));
set_color (item, g_value_get_boxed (value));
return TRUE;
}
static void
angle_changed (GtkGestureRotate *gesture,
double angle,
double delta)
{
GtkWidget *item = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
TransformData *data = g_object_get_data (G_OBJECT (item), "transform-data");
data->delta = angle / M_PI * 180.0;
apply_transform (item);
}
static void
rotate_done (GtkGesture *gesture)
{
GtkWidget *item = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
TransformData *data = g_object_get_data (G_OBJECT (item), "transform-data");
data->angle = data->angle + data->delta;
data->delta = 0;
}
static void
click_done (GtkGesture *gesture)
{
GtkWidget *item = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
GtkWidget *canvas = gtk_widget_get_parent (item);
GtkWidget *last_child;
last_child = gtk_widget_get_last_child (canvas);
if (item != last_child)
gtk_widget_insert_after (item, canvas, last_child);
}
static int n_items = 0;
static GtkWidget *
canvas_item_new (double x,
double y)
css_button_new (const char *class)
{
GtkWidget *widget;
char *label;
char *id;
TransformData *transform_data;
GdkRGBA rgba;
GtkDropTarget *dest;
GtkGesture *gesture;
GtkWidget *button;
GtkDragSource *source;
n_items++;
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);
label = g_strdup_printf ("Item %d", n_items);
id = g_strdup_printf ("item%d", n_items);
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));
gdk_rgba_parse (&rgba, "yellow");
return button;
}
widget = gtk_label_new (label);
gtk_widget_add_css_class (widget, "frame");
gtk_widget_set_name (widget, id);
typedef struct
{
GtkWidget parent_instance;
GdkRGBA color;
} ColorSwatch;
set_color (widget, &rgba);
transform_data = g_new0 (TransformData, 1);
transform_data->x = x;
transform_data->y = y;
transform_data->angle = 0.0;
g_object_set_data_full (G_OBJECT (widget), "transform-data", transform_data, g_free);
typedef struct
{
GtkWidgetClass parent_class;
} ColorSwatchClass;
g_free (label);
g_free (id);
G_DEFINE_TYPE (ColorSwatch, color_swatch, GTK_TYPE_WIDGET)
dest = gtk_drop_target_new (GDK_TYPE_RGBA, GDK_ACTION_COPY);
g_signal_connect (dest, "drop", G_CALLBACK (item_drag_drop), NULL);
gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (dest));
static GdkContentProvider *
color_swatch_drag_prepare (GtkDragSource *source,
double x,
double y,
ColorSwatch *swatch)
{
return gdk_content_provider_new_typed (GDK_TYPE_RGBA, &swatch->color);
}
gesture = gtk_gesture_rotate_new ();
g_signal_connect (gesture, "angle-changed", G_CALLBACK (angle_changed), NULL);
g_signal_connect (gesture, "end", G_CALLBACK (rotate_done), NULL);
gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (gesture));
static void
color_swatch_init (ColorSwatch *swatch)
{
GtkDragSource *source = gtk_drag_source_new ();
g_signal_connect (source, "prepare", G_CALLBACK (color_swatch_drag_prepare), swatch);
gtk_widget_add_controller (GTK_WIDGET (swatch), GTK_EVENT_CONTROLLER (source));
}
gesture = gtk_gesture_click_new ();
g_signal_connect (gesture, "released", G_CALLBACK (click_done), NULL);
gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (gesture));
return widget;
static void
color_swatch_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
{
ColorSwatch *swatch = (ColorSwatch *)widget;
float w = gtk_widget_get_width (widget);
float h = gtk_widget_get_height (widget);
gtk_snapshot_append_color (snapshot, &swatch->color,
&GRAPHENE_RECT_INIT(0, 0, w, h));
}
void
color_swatch_measure (GtkWidget *widget,
GtkOrientation orientation,
int for_size,
int *minimum_size,
int *natural_size,
int *minimum_baseline,
int *natural_baseline)
{
if (orientation == GTK_ORIENTATION_HORIZONTAL)
*minimum_size = *natural_size = 48;
else
*minimum_size = *natural_size = 32;
}
static void
color_swatch_class_init (ColorSwatchClass *class)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
widget_class->snapshot = color_swatch_snapshot;
widget_class->measure = color_swatch_measure;
gtk_widget_class_set_css_name (widget_class, "colorswatch");
}
static GtkWidget *
color_swatch_new (const char *color)
{
ColorSwatch *swatch = g_object_new (color_swatch_get_type (), NULL);
gdk_rgba_parse (&swatch->color, color);
return GTK_WIDGET (swatch);
}
static GtkWidget *window = NULL;
@@ -431,10 +693,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));
@@ -458,15 +728,15 @@ do_dnd (GtkWidget *do_widget)
{
GtkWidget *item;
item = canvas_item_new (x, y);
gtk_fixed_put (GTK_FIXED (canvas), item, 0, 0);
apply_transform (item);
item = canvas_item_new ();
gtk_fixed_put (GTK_FIXED (canvas), item, x, y);
apply_transform (CANVAS_ITEM (item));
x += 150;
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);
@@ -477,18 +747,11 @@ do_dnd (GtkWidget *do_widget)
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), box3);
for (i = 0; colors[i]; i++)
{
GdkRGBA rgba;
GtkWidget *swatch;
gtk_box_append (GTK_BOX (box3), color_swatch_new (colors[i]));
gdk_rgba_parse (&rgba, colors[i]);
swatch = g_object_new (g_type_from_name ("GtkColorSwatch"),
"rgba", &rgba,
"selectable", FALSE,
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

@@ -64,8 +64,8 @@ scribble_draw (GtkDrawingArea *da,
/* Draw a rectangle on the screen */
static void
draw_brush (GtkWidget *widget,
gdouble x,
gdouble y)
double x,
double y)
{
GdkRectangle update_rect;
cairo_t *cr;

305
demos/gtk-demo/dropdown.c Normal file
View File

@@ -0,0 +1,305 @@
/* Drop Downs
*
* The GtkDropDown widget is a modern alternative to GtkComboBox.
* It uses list models instead of tree models, and the content is
* displayed using widgets instead of cell renderers.
*
* The examples here demonstrate how to use different kinds of
* list models with GtkDropDown, how to use search and how to
* display the selected item differently from the presentation
* in the popup.
*/
#include <gtk/gtk.h>
#define STRING_TYPE_HOLDER (string_holder_get_type ())
G_DECLARE_FINAL_TYPE (StringHolder, string_holder, STRING, HOLDER, GObject)
struct _StringHolder {
GObject parent_instance;
char *title;
char *icon;
char *description;
};
G_DEFINE_TYPE (StringHolder, string_holder, G_TYPE_OBJECT);
static void
string_holder_init (StringHolder *holder)
{
}
static void
string_holder_finalize (GObject *object)
{
StringHolder *holder = STRING_HOLDER (object);
g_free (holder->title);
g_free (holder->icon);
g_free (holder->description);
G_OBJECT_CLASS (string_holder_parent_class)->finalize (object);
}
static void
string_holder_class_init (StringHolderClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->finalize = string_holder_finalize;
}
static StringHolder *
string_holder_new (const char *title, const char *icon, const char *description)
{
StringHolder *holder = g_object_new (STRING_TYPE_HOLDER, NULL);
holder->title = g_strdup (title);
holder->icon = g_strdup (icon);
holder->description = g_strdup (description);
return holder;
}
static void
strings_setup_item_single_line (GtkSignalListItemFactory *factory,
GtkListItem *item)
{
GtkWidget *box, *image, *title;
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
image = gtk_image_new ();
title = gtk_label_new ("");
gtk_label_set_xalign (GTK_LABEL (title), 0.0);
gtk_box_append (GTK_BOX (box), image);
gtk_box_append (GTK_BOX (box), title);
g_object_set_data (G_OBJECT (item), "title", title);
g_object_set_data (G_OBJECT (item), "image", image);
gtk_list_item_set_child (item, box);
}
static void
strings_setup_item_full (GtkSignalListItemFactory *factory,
GtkListItem *item)
{
GtkWidget *box, *box2, *image, *title, *description;
image = gtk_image_new ();
title = gtk_label_new ("");
gtk_label_set_xalign (GTK_LABEL (title), 0.0);
description = gtk_label_new ("");
gtk_label_set_xalign (GTK_LABEL (description), 0.0);
gtk_widget_add_css_class (description, "dim-label");
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
gtk_box_append (GTK_BOX (box), image);
gtk_box_append (GTK_BOX (box), box2);
gtk_box_append (GTK_BOX (box2), title);
gtk_box_append (GTK_BOX (box2), description);
g_object_set_data (G_OBJECT (item), "title", title);
g_object_set_data (G_OBJECT (item), "image", image);
g_object_set_data (G_OBJECT (item), "description", description);
gtk_list_item_set_child (item, box);
}
static void
strings_bind_item (GtkSignalListItemFactory *factory,
GtkListItem *item)
{
GtkWidget *image, *title, *description;
StringHolder *holder;
holder = gtk_list_item_get_item (item);
title = g_object_get_data (G_OBJECT (item), "title");
image = g_object_get_data (G_OBJECT (item), "image");
description = g_object_get_data (G_OBJECT (item), "description");
gtk_label_set_label (GTK_LABEL (title), holder->title);
if (image)
{
gtk_image_set_from_icon_name (GTK_IMAGE (image), holder->icon);
gtk_widget_set_visible (image, holder->icon != NULL);
}
if (description)
{
gtk_label_set_label (GTK_LABEL (description), holder->description);
gtk_widget_set_visible (description , holder->description != NULL);
}
}
static GtkListItemFactory *
strings_factory_new (gboolean full)
{
GtkListItemFactory *factory;
factory = gtk_signal_list_item_factory_new ();
if (full)
g_signal_connect (factory, "setup", G_CALLBACK (strings_setup_item_full), NULL);
else
g_signal_connect (factory, "setup", G_CALLBACK (strings_setup_item_single_line), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (strings_bind_item), NULL);
return factory;
}
static GListModel *
strings_model_new (const char *const *titles,
const char *const *icons,
const char *const *descriptions)
{
GListStore *store;
int i;
store = g_list_store_new (STRING_TYPE_HOLDER);
for (i = 0; titles[i]; i++)
{
StringHolder *holder = string_holder_new (titles[i],
icons ? icons[i] : NULL,
descriptions ? descriptions[i] : NULL);
g_list_store_append (store, holder);
g_object_unref (holder);
}
return G_LIST_MODEL (store);
}
static GtkWidget *
drop_down_new_from_strings (const char *const *titles,
const char *const *icons,
const char *const *descriptions)
{
GtkWidget *widget;
GListModel *model;
GtkListItemFactory *factory;
GtkListItemFactory *list_factory;
g_return_val_if_fail (titles != NULL, NULL);
g_return_val_if_fail (icons == NULL || g_strv_length ((char **)icons) == g_strv_length ((char **)titles), NULL);
g_return_val_if_fail (descriptions == NULL || g_strv_length ((char **)icons) == g_strv_length ((char **)descriptions), NULL);
model = strings_model_new (titles, icons, descriptions);
factory = strings_factory_new (FALSE);
if (icons != NULL || descriptions != NULL)
list_factory = strings_factory_new (TRUE);
else
list_factory = NULL;
widget = g_object_new (GTK_TYPE_DROP_DOWN,
"model", model,
"factory", factory,
"list-factory", list_factory,
NULL);
g_object_unref (model);
g_object_unref (factory);
if (list_factory)
g_object_unref (list_factory);
return widget;
}
static char *
get_family_name (gpointer item)
{
return g_strdup (pango_font_family_get_name (PANGO_FONT_FAMILY (item)));
}
static char *
get_title (gpointer item)
{
return g_strdup (STRING_HOLDER (item)->title);
}
GtkWidget *
do_dropdown (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
GtkWidget *button, *box, *spin, *check;
GListModel *model;
GtkExpression *expression;
const char * const times[] = { "1 minute", "2 minutes", "5 minutes", "20 minutes", NULL };
const char * const many_times[] = {
"1 minute", "2 minutes", "5 minutes", "10 minutes", "15 minutes", "20 minutes",
"25 minutes", "30 minutes", "35 minutes", "40 minutes", "45 minutes", "50 minutes",
"55 minutes", "1 hour", "2 hours", "3 hours", "5 hours", "6 hours", "7 hours",
"8 hours", "9 hours", "10 hours", "11 hours", "12 hours", NULL
};
const char * const device_titles[] = { "Digital Output", "Headphones", "Digital Output", "Analog Output", NULL };
const char * const device_icons[] = { "audio-card-symbolic", "audio-headphones-symbolic", "audio-card-symbolic", "audio-card-symbolic", NULL };
const char * const device_descriptions[] = {
"Built-in Audio", "Built-in audio", "Thinkpad Tunderbolt 3 Dock USB Audio", "Thinkpad Tunderbolt 3 Dock USB Audio", NULL
};
if (!window)
{
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 Downs");
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, 10);
gtk_widget_set_margin_start (box, 10);
gtk_widget_set_margin_end (box, 10);
gtk_widget_set_margin_top (box, 10);
gtk_widget_set_margin_bottom (box, 10);
gtk_window_set_child (GTK_WINDOW (window), box);
button = gtk_drop_down_new ();
model = G_LIST_MODEL (pango_cairo_font_map_get_default ());
gtk_drop_down_set_model (GTK_DROP_DOWN (button), model);
gtk_drop_down_set_selected (GTK_DROP_DOWN (button), 0);
expression = gtk_cclosure_expression_new (G_TYPE_STRING, NULL,
0, NULL,
(GCallback)get_family_name,
NULL, NULL);
gtk_drop_down_set_expression (GTK_DROP_DOWN (button), expression);
gtk_expression_unref (expression);
gtk_box_append (GTK_BOX (box), button);
spin = gtk_spin_button_new_with_range (-1, g_list_model_get_n_items (G_LIST_MODEL (model)), 1);
gtk_widget_set_halign (spin, GTK_ALIGN_START);
g_object_bind_property (button, "selected", spin, "value", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
gtk_box_append (GTK_BOX (box), spin);
check = gtk_check_button_new_with_label ("Enable search");
g_object_bind_property (button, "enable-search", check, "active", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
gtk_box_append (GTK_BOX (box), check);
g_object_unref (model);
button = drop_down_new_from_strings (times, NULL, NULL);
gtk_box_append (GTK_BOX (box), button);
button = drop_down_new_from_strings (many_times, NULL, NULL);
gtk_drop_down_set_enable_search (GTK_DROP_DOWN (button), TRUE);
expression = gtk_cclosure_expression_new (G_TYPE_STRING, NULL,
0, NULL,
(GCallback)get_title,
NULL, NULL);
gtk_drop_down_set_expression (GTK_DROP_DOWN (button), expression);
gtk_expression_unref (expression);
gtk_box_append (GTK_BOX (box), button);
button = drop_down_new_from_strings (device_titles, device_icons, device_descriptions);
gtk_box_append (GTK_BOX (box), button);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_window_destroy (GTK_WINDOW (window));
return window;
}

View File

@@ -16,9 +16,9 @@
typedef struct
{
gint number;
gchar *product;
gint yummy;
int number;
char *product;
int yummy;
}
Item;
@@ -74,7 +74,7 @@ add_items (void)
static GtkTreeModel *
create_items_model (void)
{
gint i = 0;
int i = 0;
GtkListStore *model;
GtkTreeIter iter;
@@ -109,7 +109,7 @@ static GtkTreeModel *
create_numbers_model (void)
{
#define N_NUMBERS 10
gint i = 0;
int i = 0;
GtkListStore *model;
GtkTreeIter iter;
@@ -192,7 +192,7 @@ remove_item (GtkWidget *widget, gpointer data)
if (gtk_tree_selection_get_selected (selection, NULL, &iter))
{
gint i;
int i;
GtkTreePath *path;
path = gtk_tree_model_get_path (model, &iter);
@@ -211,7 +211,7 @@ separator_row (GtkTreeModel *model,
gpointer data)
{
GtkTreePath *path;
gint idx;
int idx;
path = gtk_tree_model_get_path (model, iter);
idx = gtk_tree_path_get_indices (path)[0];
@@ -224,7 +224,7 @@ separator_row (GtkTreeModel *model,
static void
editing_started (GtkCellRenderer *cell,
GtkCellEditable *editable,
const gchar *path,
const char *path,
gpointer data)
{
gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (editable),
@@ -233,15 +233,15 @@ editing_started (GtkCellRenderer *cell,
static void
cell_edited (GtkCellRendererText *cell,
const gchar *path_string,
const gchar *new_text,
const char *path_string,
const char *new_text,
gpointer data)
{
GtkTreeModel *model = (GtkTreeModel *)data;
GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
GtkTreeIter iter;
gint column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column"));
int column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column"));
gtk_tree_model_get_iter (model, &iter, path);
@@ -249,7 +249,7 @@ cell_edited (GtkCellRendererText *cell,
{
case COLUMN_ITEM_NUMBER:
{
gint i;
int i;
i = gtk_tree_path_get_indices (path)[0];
g_array_index (articles, Item, i).number = atoi (new_text);
@@ -261,8 +261,8 @@ cell_edited (GtkCellRendererText *cell,
case COLUMN_ITEM_PRODUCT:
{
gint i;
gchar *old_text;
int i;
char *old_text;
gtk_tree_model_get (model, &iter, column, &old_text, -1);
g_free (old_text);
@@ -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

@@ -13,7 +13,7 @@
static GtkWidget *window = NULL;
static void
response_cb (GtkDialog *dialog, gint response_id)
response_cb (GtkDialog *dialog, int response_id)
{
gtk_window_destroy (GTK_WINDOW (window));
window = NULL;
@@ -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

@@ -22,8 +22,8 @@ format_number (GtkTreeViewColumn *col,
GtkTreeIter *iter,
gpointer data)
{
gint num;
gchar *text;
int num;
char *text;
gtk_tree_model_get (model, iter, GPOINTER_TO_INT (data), &num, -1);
text = g_strdup_printf ("%d", num);
@@ -35,11 +35,11 @@ static void
filter_modify_func (GtkTreeModel *model,
GtkTreeIter *iter,
GValue *value,
gint column,
int column,
gpointer data)
{
GtkTreeModelFilter *filter_model = GTK_TREE_MODEL_FILTER (model);
gint width, height;
int width, height;
GtkTreeModel *child_model;
GtkTreeIter child_iter;
@@ -75,7 +75,7 @@ visible_func (GtkTreeModel *model,
GtkTreeIter *iter,
gpointer data)
{
gint width;
int width;
gtk_tree_model_get (model, iter,
WIDTH_COLUMN, &width,

View File

@@ -249,6 +249,14 @@ fishbowl_changes_toggled_cb (GtkToggleButton *button,
gtk_button_set_icon_name (GTK_BUTTON (button), "changes-allow");
}
char *
format_header_cb (GObject *object,
guint count,
double fps)
{
return g_strdup_printf ("%u Icons, %.2f fps", count, fps);
}
GtkWidget *
do_fishbowl (GtkWidget *do_widget)
{

View File

@@ -6,7 +6,6 @@
<property name="default-height">400</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="">
<property name="show-title-buttons">1</property>
<child>
<object class="GtkBox">
<style>
@@ -28,22 +27,12 @@
</child>
<child type="end">
<object class="GtkLabel">
<property name="label">fps</property>
</object>
</child>
<child type="end">
<object class="GtkLabel">
<property name="label" bind-source="bowl" bind-property="framerate-string"/>
</object>
</child>
<child type="end">
<object class="GtkLabel">
<property name="label">Icons, </property>
</object>
</child>
<child type="end">
<object class="GtkLabel">
<property name="label" bind-source="bowl" bind-property="count"/>
<binding name="label">
<closure type="gchararray" function="format_header_cb">
<lookup name="count">bowl</lookup>
<lookup name="framerate">bowl</lookup>
</closure>
</binding>
</object>
</child>
<child type="end">

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,10 @@
/* Flow Box
*
* GtkFlowBox allows flexible and responsive grids which reflow
* as needed and support sorting and filtering.
* as needed and support sorting and filtering. The children of
* a GtkFlowBox are regular widgets
*
* The children of a GtkFlowBox are regular widgets
* The dataset used here has 665 colors.
*/
#include <gtk/gtk.h>
@@ -28,7 +29,7 @@ draw_color (GtkDrawingArea *drawingarea,
}
static GtkWidget *
color_swatch_new (const gchar *color)
color_swatch_new (const char *color)
{
GtkWidget *button, *area;
@@ -47,7 +48,7 @@ do_flowbox (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
GtkWidget *scrolled, *flowbox;
const gchar *colors[] = {
const char *colors[] = {
"AliceBlue",
"AntiqueWhite",
"AntiqueWhite1",
@@ -715,7 +716,7 @@ do_flowbox (GtkWidget *do_widget)
"YellowGreen",
NULL
};
gint i;
int i;
if (!window)
{
@@ -726,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

@@ -7,7 +7,6 @@
<property name="title">Font Explorer</property>
<child type="titlebar">
<object class="GtkHeaderBar">
<property name="show-title-buttons">1</property>
<child>
<object class="GtkButton" id="reset">
<property name="receives-default">1</property>

View File

@@ -295,7 +295,7 @@ update_display (void)
GList *l;
PangoAttrList *attrs;
PangoAttribute *attr;
gint ins, bound;
int ins, bound;
guint start, end;
PangoLanguage *lang;
char *font_desc;
@@ -479,7 +479,7 @@ update_script_combo (void)
{
GtkListStore *store;
hb_font_t *hb_font;
gint i, j, k;
int i, j, k;
PangoFont *pango_font;
GHashTable *tags;
GHashTableIter iter;
@@ -593,7 +593,7 @@ update_script_combo (void)
static void
update_features (void)
{
gint i, j;
int i, j;
GtkTreeModel *model;
GtkTreeIter iter;
guint script_index, lang_index;
@@ -728,8 +728,8 @@ static void
entry_activated (GtkEntry *entry,
GtkAdjustment *adjustment)
{
gdouble value;
gchar *err = NULL;
double value;
char *err = NULL;
value = g_strtod (gtk_editable_get_text (GTK_EDITABLE (entry)), &err);
if (err != NULL)
@@ -939,7 +939,7 @@ instance_changed (GtkComboBox *combo)
{
Axis *axis;
Axis akey;
gdouble value;
double value;
value = coords[ai[i].axis_index];

View File

@@ -36,11 +36,11 @@ adjustment_get_normalized_value (GtkAdjustment *adj)
static void
val_to_xy (GtkFontPlane *plane,
gint *x,
gint *y)
int *x,
int *y)
{
gdouble u, v;
gint width, height;
double u, v;
int width, height;
width = gtk_widget_get_allocated_width (GTK_WIDGET (plane));
height = gtk_widget_get_allocated_height (GTK_WIDGET (plane));
@@ -57,8 +57,8 @@ plane_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
{
GtkFontPlane *plane = GTK_FONT_PLANE (widget);
gint x, y;
gint width, height;
int x, y;
int width, height;
cairo_t *cr;
val_to_xy (plane, &x, &y);
@@ -125,11 +125,11 @@ adjustment_set_normalized_value (GtkAdjustment *adj,
static void
update_value (GtkFontPlane *plane,
gint x,
gint y)
int x,
int y)
{
GtkWidget *widget = GTK_WIDGET (plane);
gdouble u, v;
double u, v;
u = CLAMP (x * (1.0 / gtk_widget_get_allocated_width (widget)), 0, 1);
v = CLAMP (1 - y * (1.0 / gtk_widget_get_allocated_height (widget)), 0, 1);
@@ -142,8 +142,8 @@ update_value (GtkFontPlane *plane,
static void
plane_drag_gesture_begin (GtkGestureDrag *gesture,
gdouble start_x,
gdouble start_y,
double start_x,
double start_y,
GtkFontPlane *plane)
{
guint button;
@@ -164,11 +164,11 @@ plane_drag_gesture_begin (GtkGestureDrag *gesture,
static void
plane_drag_gesture_update (GtkGestureDrag *gesture,
gdouble offset_x,
gdouble offset_y,
double offset_x,
double offset_y,
GtkFontPlane *plane)
{
gdouble start_x, start_y;
double start_x, start_y;
gtk_gesture_drag_get_start_point (GTK_GESTURE_DRAG (gesture),
&start_x, &start_y);
@@ -177,8 +177,8 @@ plane_drag_gesture_update (GtkGestureDrag *gesture,
static void
plane_drag_gesture_end (GtkGestureDrag *gesture,
gdouble offset_x,
gdouble offset_y,
double offset_x,
double offset_y,
GtkFontPlane *plane)
{
set_cross_cursor (GTK_WIDGET (plane), FALSE);

View File

@@ -13,17 +13,16 @@ in_files = sys.argv[2:]
file_output = """
typedef GtkWidget *(*GDoDemoFunc) (GtkWidget *do_widget);
typedef struct _Demo Demo;
typedef struct _DemoData DemoData;
struct _Demo
struct _DemoData
{
const char *name;
const char *title;
const char *filename;
GDoDemoFunc func;
Demo *children;
DemoData *children;
};
"""
# Demo = namedtuple('Demo', ['name', 'title', 'file', 'func'])
@@ -67,7 +66,7 @@ for demo in demos:
i = 0
for parent in parents:
id = parent_ids[i]
file_output += "\nDemo child" + str(id) + "[] = {\n"
file_output += "\nDemoData child" + str(id) + "[] = {\n"
# iterate over all demos and check if the name starts with the given parent name
for child in demos:
if child[1].startswith(parent + "/"):
@@ -82,7 +81,7 @@ for parent in parents:
# Sort demos by title
demos = sorted(demos, key=lambda x: x[1])
file_output += "\nDemo gtk_demos[] = {\n"
file_output += "\nDemoData gtk_demos[] = {\n"
for demo in demos:
# Do not generate one of these for demos with a parent demo
if "/" not in demo[1]:

View File

@@ -9,8 +9,8 @@
static GtkGesture *rotate = NULL;
static GtkGesture *zoom = NULL;
static gdouble swipe_x = 0;
static gdouble swipe_y = 0;
static double swipe_x = 0;
static double swipe_y = 0;
static gboolean long_pressed = FALSE;
static gboolean
@@ -26,8 +26,8 @@ touchpad_swipe_gesture_begin (GtkGesture *gesture,
static void
swipe_gesture_swept (GtkGestureSwipe *gesture,
gdouble velocity_x,
gdouble velocity_y,
double velocity_x,
double velocity_y,
GtkWidget *widget)
{
swipe_x = velocity_x / 10;
@@ -37,8 +37,8 @@ swipe_gesture_swept (GtkGestureSwipe *gesture,
static void
long_press_gesture_pressed (GtkGestureLongPress *gesture,
gdouble x,
gdouble y,
double x,
double y,
GtkWidget *widget)
{
long_pressed = TRUE;
@@ -56,8 +56,8 @@ long_press_gesture_end (GtkGesture *gesture,
static void
rotation_angle_changed (GtkGestureRotate *gesture,
gdouble angle,
gdouble delta,
double angle,
double delta,
GtkWidget *widget)
{
gtk_widget_queue_draw (widget);
@@ -65,7 +65,7 @@ rotation_angle_changed (GtkGestureRotate *gesture,
static void
zoom_scale_changed (GtkGestureZoom *gesture,
gdouble scale,
double scale,
GtkWidget *widget)
{
gtk_widget_queue_draw (widget);
@@ -93,8 +93,8 @@ drawing_area_draw (GtkDrawingArea *area,
{
cairo_pattern_t *pat;
cairo_matrix_t matrix;
gdouble angle, scale;
gdouble x_center, y_center;
double angle, scale;
double x_center, y_center;
gtk_gesture_get_bounding_box_center (GTK_GESTURE (zoom), &x_center, &y_center);

View File

@@ -25,7 +25,7 @@ typedef struct _GtkFishbowlChild GtkFishbowlChild;
struct _GtkFishbowlPrivate
{
GtkFishCreationFunc creation_func;
GList *children;
GHashTable *children;
guint count;
gint64 last_frame_time;
@@ -53,7 +53,6 @@ enum {
PROP_BENCHMARK,
PROP_COUNT,
PROP_FRAMERATE,
PROP_FRAMERATE_STRING,
PROP_UPDATE_DELAY,
NUM_PROPERTIES
};
@@ -68,6 +67,8 @@ gtk_fishbowl_init (GtkFishbowl *fishbowl)
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
priv->update_delay = G_USEC_PER_SEC;
priv->children = g_hash_table_new_full (NULL, NULL,
NULL, (GDestroyNotify) g_free);
}
/**
@@ -94,20 +95,18 @@ gtk_fishbowl_measure (GtkWidget *widget,
{
GtkFishbowl *fishbowl = GTK_FISHBOWL (widget);
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
GHashTableIter iter;
gpointer key, value;
GtkFishbowlChild *child;
GList *children;
gint child_min, child_nat;
int child_min, child_nat;
*minimum = 0;
*natural = 0;
for (children = priv->children; children; children = children->next)
g_hash_table_iter_init (&iter, priv->children);
while (g_hash_table_iter_next (&iter, &key, &value))
{
child = children->data;
if (!gtk_widget_get_visible (child->widget))
continue;
child = value;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
@@ -137,14 +136,13 @@ gtk_fishbowl_size_allocate (GtkWidget *widget,
GtkFishbowlChild *child;
GtkAllocation child_allocation;
GtkRequisition child_requisition;
GList *children;
GHashTableIter iter;
gpointer key, value;
for (children = priv->children; children; children = children->next)
g_hash_table_iter_init (&iter, priv->children);
while (g_hash_table_iter_next (&iter, &key, &value))
{
child = children->data;
if (!gtk_widget_get_visible (child->widget))
continue;
child = value;
gtk_widget_get_preferred_size (child->widget, &child_requisition, NULL);
child_allocation.x = round (child->x * (width - child_requisition.width));
@@ -182,7 +180,7 @@ gtk_fishbowl_add (GtkFishbowl *fishbowl,
gtk_widget_set_parent (widget, GTK_WIDGET (fishbowl));
priv->children = g_list_prepend (priv->children, child_info);
g_hash_table_insert (priv->children, widget, child_info);
priv->count++;
g_object_notify_by_pspec (G_OBJECT (fishbowl), props[PROP_COUNT]);
}
@@ -192,34 +190,26 @@ gtk_fishbowl_remove (GtkFishbowl *fishbowl,
GtkWidget *widget)
{
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
GtkFishbowlChild *child;
GtkWidget *widget_bowl = GTK_WIDGET (fishbowl);
GList *children;
for (children = priv->children; children; children = children->next)
if (g_hash_table_remove (priv->children, widget))
{
child = children->data;
gtk_widget_unparent (widget);
if (child->widget == widget)
{
gboolean was_visible = gtk_widget_get_visible (widget);
gtk_widget_unparent (widget);
priv->children = g_list_remove_link (priv->children, children);
g_list_free (children);
g_free (child);
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]);
break;
}
priv->count--;
g_object_notify_by_pspec (G_OBJECT (fishbowl), props[PROP_COUNT]);
}
}
static void
gtk_fishbowl_finalize (GObject *object)
{
GtkFishbowl *fishbowl = GTK_FISHBOWL (object);
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
g_hash_table_destroy (priv->children);
priv->children = NULL;
}
static void
gtk_fishbowl_dispose (GObject *object)
{
@@ -289,14 +279,6 @@ gtk_fishbowl_get_property (GObject *object,
g_value_set_double (value, gtk_fishbowl_get_framerate (fishbowl));
break;
case PROP_FRAMERATE_STRING:
{
char *s = g_strdup_printf ("%.2f", gtk_fishbowl_get_framerate (fishbowl));
g_value_set_string (value, s);
g_free (s);
}
break;
case PROP_UPDATE_DELAY:
g_value_set_int64 (value, gtk_fishbowl_get_update_delay (fishbowl));
break;
@@ -313,6 +295,7 @@ gtk_fishbowl_class_init (GtkFishbowlClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->finalize = gtk_fishbowl_finalize;
object_class->dispose = gtk_fishbowl_dispose;
object_class->set_property = gtk_fishbowl_set_property;
object_class->get_property = gtk_fishbowl_get_property;
@@ -350,13 +333,6 @@ gtk_fishbowl_class_init (GtkFishbowlClass *klass)
0,
G_PARAM_READABLE);
props[PROP_FRAMERATE_STRING] =
g_param_spec_string ("framerate-string",
"Framerate as string",
"Framerate as string, with 2 decimals",
NULL,
G_PARAM_READABLE);
props[PROP_UPDATE_DELAY] =
g_param_spec_int64 ("update-delay",
"Update delay",
@@ -508,7 +484,6 @@ gtk_fishbowl_do_update (GtkFishbowl *fishbowl)
priv->framerate = ((int)(priv->framerate * 100))/100.0;
g_object_notify_by_pspec (G_OBJECT (fishbowl), props[PROP_FRAMERATE]);
g_object_notify_by_pspec (G_OBJECT (fishbowl), props[PROP_FRAMERATE_STRING]);
if (!priv->benchmark)
return;
@@ -552,8 +527,9 @@ gtk_fishbowl_tick (GtkWidget *widget,
GtkFishbowl *fishbowl = GTK_FISHBOWL (widget);
GtkFishbowlPrivate *priv = gtk_fishbowl_get_instance_private (fishbowl);
GtkFishbowlChild *child;
GList *l;
gint64 frame_time, elapsed;
GHashTableIter iter;
gpointer key, value;
gboolean do_update;
frame_time = gdk_frame_clock_get_frame_time (gtk_widget_get_frame_clock (widget));
@@ -565,9 +541,10 @@ gtk_fishbowl_tick (GtkWidget *widget,
if (elapsed == frame_time)
return G_SOURCE_CONTINUE;
for (l = priv->children; l; l = l->next)
g_hash_table_iter_init (&iter, priv->children);
while (g_hash_table_iter_next (&iter, &key, &value))
{
child = l->data;
child = value;
child->x += child->dx * ((double) elapsed / G_USEC_PER_SEC);
child->y += child->dy * ((double) elapsed / G_USEC_PER_SEC);

View File

@@ -197,7 +197,7 @@ gtk_gears_class_init (GtkGearsClass *klass)
* @param v the vertex to fill
* @param x the x coordinate
* @param y the y coordinate
* @param z the z coortinate
* @param z the z coordinate
* @param n pointer to the normal table
*
* @return the operation error code

View File

@@ -30,7 +30,6 @@ do_headerbar (GtkWidget *do_widget)
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
header = gtk_header_bar_new ();
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE);
button = gtk_button_new ();
icon = g_themed_icon_new ("mail-send-receive-symbolic");

View File

@@ -18,7 +18,7 @@ static void
insert_link (GtkTextBuffer *buffer,
GtkTextIter *iter,
const char *text,
gint page)
int page)
{
GtkTextTag *tag;
@@ -35,7 +35,7 @@ insert_link (GtkTextBuffer *buffer,
*/
static void
show_page (GtkTextBuffer *buffer,
gint page)
int page)
{
GtkTextIter iter;
@@ -91,7 +91,7 @@ follow_if_link (GtkWidget *text_view,
for (tagp = tags; tagp != NULL; tagp = tagp->next)
{
GtkTextTag *tag = tagp->data;
gint page = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tag), "page"));
int page = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tag), "page"));
if (page != 0)
{
@@ -134,14 +134,14 @@ key_pressed (GtkEventController *controller,
}
static void set_cursor_if_appropriate (GtkTextView *text_view,
gint x,
gint y);
int x,
int y);
static void
released_cb (GtkGestureClick *gesture,
guint n_press,
gdouble x,
gdouble y,
double x,
double y,
GtkWidget *text_view)
{
GtkTextIter start, end, iter;
@@ -168,8 +168,8 @@ released_cb (GtkGestureClick *gesture,
static void
motion_cb (GtkEventControllerMotion *controller,
gdouble x,
gdouble y,
double x,
double y,
GtkTextView *text_view)
{
set_cursor_if_appropriate (text_view, x, y);
@@ -183,8 +183,8 @@ static gboolean hovering_over_link = FALSE;
*/
static void
set_cursor_if_appropriate (GtkTextView *text_view,
gint x,
gint y)
int x,
int y)
{
GSList *tags = NULL, *tagp = NULL;
GtkTextIter iter;
@@ -196,7 +196,7 @@ set_cursor_if_appropriate (GtkTextView *text_view,
for (tagp = tags; tagp != NULL; tagp = tagp->next)
{
GtkTextTag *tag = tagp->data;
gint page = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tag), "page"));
int page = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tag), "page"));
if (page != 0)
{
@@ -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

@@ -12,7 +12,7 @@ static GtkWidget *window = NULL;
static GtkWidget *scrolledwindow;
static int selected;
#define N_WIDGET_TYPES 4
#define N_WIDGET_TYPES 6
static int hincrement = 5;
@@ -64,6 +64,7 @@ populate_icons (void)
gtk_grid_attach (GTK_GRID (grid), create_icon (), left, top, 1, 1);
hincrement = 0;
vincrement = 5;
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
GTK_POLICY_NEVER,
@@ -100,6 +101,7 @@ populate_text (gboolean hilight)
gtk_text_view_set_buffer (GTK_TEXT_VIEW (textview), buffer);
hincrement = 0;
vincrement = 5;
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
GTK_POLICY_NEVER,
@@ -124,6 +126,7 @@ populate_image (void)
gtk_picture_set_can_shrink (GTK_PICTURE (image), FALSE);
hincrement = 5;
vincrement = 5;
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
GTK_POLICY_AUTOMATIC,
@@ -131,6 +134,42 @@ populate_image (void)
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolledwindow), image);
}
extern GtkWidget *create_weather_view (void);
static void
populate_list (void)
{
GtkWidget *list;
list = create_weather_view ();
hincrement = 5;
vincrement = 0;
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolledwindow), list);
}
extern GtkWidget *create_color_grid (void);
static void
populate_grid (void)
{
GtkWidget *list;
list = create_color_grid ();
hincrement = 0;
vincrement = 5;
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolledwindow), list);
}
static void
set_widget_type (int type)
{
@@ -164,6 +203,16 @@ set_widget_type (int type)
populate_image ();
break;
case 4:
gtk_window_set_title (GTK_WINDOW (window), "Scrolling a list");
populate_list ();
break;
case 5:
gtk_window_set_title (GTK_WINDOW (window), "Scrolling a grid");
populate_grid ();
break;
default:
g_assert_not_reached ();
}

View File

@@ -6,7 +6,6 @@
<property name="default-height">500</property>
<child type="titlebar">
<object class="GtkHeaderBar">
<property name="show-title-buttons">1</property>
<child>
<object class="GtkBox">
<style>

View File

@@ -25,7 +25,7 @@ enum
static GdkPixbuf *file_pixbuf, *folder_pixbuf;
gchar *parent;
char *parent;
GtkWidget *up_button;
/* Loads the images for the demo and returns whether the operation succeeded */
@@ -47,7 +47,7 @@ static void
fill_store (GtkListStore *store)
{
GDir *dir;
const gchar *name;
const char *name;
GtkTreeIter iter;
/* First clear the store */
@@ -62,7 +62,7 @@ fill_store (GtkListStore *store)
name = g_dir_read_name (dir);
while (name != NULL)
{
gchar *path, *display_name;
char *path, *display_name;
gboolean is_dir;
/* We ignore hidden files that start with a '.' */
@@ -90,14 +90,14 @@ fill_store (GtkListStore *store)
g_dir_close (dir);
}
static gint
static int
sort_func (GtkTreeModel *model,
GtkTreeIter *a,
GtkTreeIter *b,
gpointer user_data)
{
gboolean is_dir_a, is_dir_b;
gchar *name_a, *name_b;
char *name_a, *name_b;
int ret;
/* We need this function because we want to sort
@@ -158,7 +158,7 @@ item_activated (GtkIconView *icon_view,
gpointer user_data)
{
GtkListStore *store;
gchar *path;
char *path;
GtkTreeIter iter;
gboolean is_dir;
@@ -192,7 +192,7 @@ up_clicked (GtkButton *item,
gpointer user_data)
{
GtkListStore *store;
gchar *dir_name;
char *dir_name;
store = GTK_LIST_STORE (user_data);
@@ -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

@@ -19,8 +19,8 @@ static void
fill_store (GtkListStore *store)
{
GtkTreeIter iter;
const gchar *text[] = { "Red", "Green", "Blue", "Yellow" };
gint i;
const char *text[] = { "Red", "Green", "Blue", "Yellow" };
int i;
/* First clear the store */
gtk_list_store_clear (store);
@@ -49,7 +49,7 @@ set_cell_color (GtkCellLayout *cell_layout,
GtkTreeIter *iter,
gpointer data)
{
gchar *text;
char *text;
GdkRGBA color;
guint32 pixel = 0;
GdkPixbuf *pixbuf;
@@ -60,10 +60,10 @@ set_cell_color (GtkCellLayout *cell_layout,
if (gdk_rgba_parse (&color, text))
pixel =
((gint)(color.red * 255)) << 24 |
((gint)(color.green * 255)) << 16 |
((gint)(color.blue * 255)) << 8 |
((gint)(color.alpha * 255));
((int)(color.red * 255)) << 24 |
((int)(color.green * 255)) << 16 |
((int)(color.blue * 255)) << 8 |
((int)(color.alpha * 255));
g_free (text);
@@ -77,8 +77,8 @@ set_cell_color (GtkCellLayout *cell_layout,
static void
edited (GtkCellRendererText *cell,
gchar *path_string,
gchar *text,
char *path_string,
char *text,
gpointer data)
{
GtkTreeModel *model;

View File

@@ -43,10 +43,10 @@ progressive_prepared_callback (GdkPixbufLoader *loader,
static void
progressive_updated_callback (GdkPixbufLoader *loader,
gint x,
gint y,
gint width,
gint height,
int x,
int y,
int width,
int height,
gpointer data)
{
GtkWidget *picture;
@@ -58,7 +58,7 @@ progressive_updated_callback (GdkPixbufLoader *loader,
gtk_picture_set_pixbuf (GTK_PICTURE (picture), pixbuf);
}
static gint
static int
progressive_timeout (gpointer data)
{
GtkWidget *picture;

View File

@@ -8,7 +8,7 @@
static void
on_bar_response (GtkInfoBar *info_bar,
gint response_id,
int response_id,
gpointer user_data)
{
GtkWidget *dialog;

View File

@@ -9,7 +9,7 @@
static void
response_cb (GtkWidget *dialog,
gint response_id,
int response_id,
gpointer data)
{
gtk_window_destroy (GTK_WINDOW (dialog));
@@ -17,7 +17,7 @@ response_cb (GtkWidget *dialog,
static gboolean
activate_link (GtkWidget *label,
const gchar *uri,
const char *uri,
gpointer data)
{
if (g_strcmp0 (uri, "keynav") == 0)

View File

@@ -81,7 +81,7 @@ spinner_timeout (gpointer data)
static GtkTreeModel *
create_model (void)
{
gint i = 0;
int i = 0;
GtkListStore *store;
GtkTreeIter iter;
@@ -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

@@ -236,7 +236,6 @@ reshare_clicked (GtkMessageRow *row,
priv->message->n_reshares++;
gtk_message_row_update (row);
}
static void
@@ -255,11 +254,12 @@ gtk_message_row_state_flags_changed (GtkWidget *widget,
{
GtkMessageRowPrivate *priv = GTK_MESSAGE_ROW (widget)->priv;
GtkStateFlags flags;
gboolean visible;
flags = gtk_widget_get_state_flags (widget);
gtk_widget_set_visible (priv->extra_buttons_box,
flags & (GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_SELECTED));
visible = flags & (GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_SELECTED) ? TRUE : FALSE;
gtk_widget_set_visible (priv->extra_buttons_box, visible);
GTK_WIDGET_CLASS (gtk_message_row_parent_class)->state_flags_changed (widget, previous_state_flags);
}
@@ -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

@@ -150,7 +150,7 @@
</object>
</child>
<child>
<object class="GtkButton" id="favorite-buttton">
<object class="GtkButton" id="favorite-button">
<property name="label" translatable="yes">Favorite</property>
<property name="receives-default">1</property>
<property name="has-frame">0</property>

View File

@@ -0,0 +1,202 @@
/* Lists/Application launcher
*
* This demo uses the GtkListView widget as a fancy application launcher.
*
* It is also a very small introduction to listviews.
*/
#include <gtk/gtk.h>
/* This is the function that creates the #GListModel that we need.
* GTK list widgets need a #GListModel to display, as models support change
* notifications.
* Unfortunately various older APIs do not provide list models, so we create
* our own.
*/
static GListModel *
create_application_list (void)
{
GListStore *store;
GList *apps, *l;
/* We use a #GListStore here, which is a simple array-like list implementation
* for manual management.
* List models need to know what type of data they provide, so we need to
* provide the type here. As we want to do a list of applications, #GAppInfo
* is the object we provide.
*/
store = g_list_store_new (G_TYPE_APP_INFO);
apps = g_app_info_get_all ();
for (l = apps; l; l = l->next)
g_list_store_append (store, l->data);
g_list_free_full (apps, g_object_unref);
return G_LIST_MODEL (store);
}
/* This is the function we use for setting up new listitems to display.
* We add just an #GtkImage and a #GtkKabel here to display the application's
* icon and name, as this is just a simple demo.
*/
static void
setup_listitem_cb (GtkListItemFactory *factory,
GtkListItem *list_item)
{
GtkWidget *box;
GtkWidget *image;
GtkWidget *label;
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
image = gtk_image_new ();
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
gtk_box_append (GTK_BOX (box), image);
label = gtk_label_new ("");
gtk_box_append (GTK_BOX (box), label);
gtk_list_item_set_child (list_item, box);
}
/* Here we need to prepare the listitem for displaying its item. We get the
* listitem already set up from the previous function, so we can reuse the
* #GtkImage widget we set up above.
* We get the item - which we know is a #GAppInfo because it comes out of
* the model we set up above, grab its icon and display it.
*/
static void
bind_listitem_cb (GtkListItemFactory *factory,
GtkListItem *list_item)
{
GtkWidget *image;
GtkWidget *label;
GAppInfo *app_info;
image = gtk_widget_get_first_child (gtk_list_item_get_child (list_item));
label = gtk_widget_get_next_sibling (image);
app_info = gtk_list_item_get_item (list_item);
gtk_image_set_from_gicon (GTK_IMAGE (image), g_app_info_get_icon (app_info));
gtk_label_set_label (GTK_LABEL (label), g_app_info_get_display_name (app_info));
}
/* In more complex code, we would also need functions to unbind and teardown
* the listitem, but this is simple code, so the default implementations are
* enough. If we had connected signals, this step would have been necessary.
*
* The #GtkSignalListItemFactory documentation contains more information about
* this step.
*/
/* This function is called whenever an item in the list is activated. This is
* the simple way to allow reacting to the Enter key or double-clicking on a
* listitem.
* Of course, it is possible to use far more complex interactions by turning
* off activation and adding buttons or other widgets in the setup function
* above, but this is a simple demo, so we'll use the simple way.
*/
static void
activate_cb (GtkListView *list,
guint position,
gpointer unused)
{
GAppInfo *app_info;
GdkAppLaunchContext *context;
GError *error = NULL;
app_info = g_list_model_get_item (gtk_list_view_get_model (list), position);
/* Prepare the context for launching the application and launch it. This
* code is explained in detail in the documentation for #GdkAppLaunchContext
* and #GAppInfo.
*/
context = gdk_display_get_app_launch_context (gtk_widget_get_display (GTK_WIDGET (list)));
if (!g_app_info_launch (app_info,
NULL,
G_APP_LAUNCH_CONTEXT (context),
&error))
{
GtkWidget *dialog;
/* And because error handling is important, even a simple demo has it:
* We display an error dialog that something went wrong.
*/
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (list))),
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
"Could not launch %s", g_app_info_get_display_name (app_info));
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
g_clear_error (&error);
gtk_widget_show (dialog);
}
g_object_unref (context);
g_object_unref (app_info);
}
static GtkWidget *window = NULL;
GtkWidget *
do_listview_applauncher (GtkWidget *do_widget)
{
if (window == NULL)
{
GtkWidget *list, *sw;
GListModel *model;
GtkListItemFactory *factory;
/* Create a window and set a few defaults */
window = gtk_window_new ();
gtk_window_set_default_size (GTK_WINDOW (window), 640, 320);
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Application Launcher");
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *) &window);
/* The #GtkListitemFactory is what is used to create #GtkListItems
* to display the data from the model. So it is absolutely necessary
* to create one.
* We will use a #GtkSignalListItemFactory because it is the simplest
* one to use. Different ones are available for different use cases.
* The most powerful one is #GtkBuilderListItemFactory which uses
* #GtkBuilder .ui files, so it requires little code.
*/
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_listitem_cb), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_listitem_cb), NULL);
/* Create the list widget here.
*/
list = gtk_list_view_new_with_factory (factory);
/* We connect the activate signal here. It's the function we defined
* above for launching the selected application.
*/
g_signal_connect (list, "activate", G_CALLBACK (activate_cb), NULL);
/* And of course we need to set the data model. Here we call the function
* we wrote above that gives us the list of applications. Then we set
* it on the list widget.
* The list will now take items from the model and use the factory
* to create as many listitems as it needs to show itself to the user.
*/
model = create_application_list ();
gtk_list_view_set_model (GTK_LIST_VIEW (list), model);
g_object_unref (model);
/* List widgets should always be contained in a #GtkScrolledWindow,
* because otherwise they might get too large or they might not
* be scrollable.
*/
sw = gtk_scrolled_window_new ();
gtk_window_set_child (GTK_WINDOW (window), sw);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_window_destroy (GTK_WINDOW (window));
return window;
}

View File

@@ -0,0 +1,506 @@
/* Lists/Clocks
*
* 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.
*
* Typically, this will be done using GtkBuilder .ui files with the
* help of the <binding> tag, but this demo shows the code that runs
* behind that.
*/
#include <gtk/gtk.h>
#define GTK_TYPE_CLOCK (gtk_clock_get_type ())
G_DECLARE_FINAL_TYPE (GtkClock, gtk_clock, GTK, CLOCK, GObject)
/* This is our object. It's just a timezone */
typedef struct _GtkClock GtkClock;
struct _GtkClock
{
GObject parent_instance;
/* We allow this to be NULL for the local timezone */
GTimeZone *timezone;
/* Name of the location we're displaying time for */
char *location;
};
enum {
PROP_0,
PROP_LOCATION,
PROP_TIME,
PROP_TIMEZONE,
N_PROPS
};
/* 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.
*/
static GDateTime *
gtk_clock_get_time (GtkClock *clock)
{
if (clock->timezone)
return g_date_time_new_now (clock->timezone);
else
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.
*/
static void
gtk_clock_snapshot (GdkPaintable *paintable,
GdkSnapshot *snapshot,
double width,
double height)
{
GtkClock *self = GTK_CLOCK (paintable);
GDateTime *time;
GskRoundedRect outline;
#define BLACK ((GdkRGBA) { 0, 0, 0, 1 })
/* save/restore() is necessary so we can undo the transforms we start
* 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.
*/
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.
*/
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.
*/
time = gtk_clock_get_time (self);
/* First, draw a circle. This is a neat little trick to draw a circle
* without requiring Cairo.
*/
gsk_rounded_rect_init_from_rect (&outline, &GRAPHENE_RECT_INIT(-50, -50, 100, 100), 50);
gtk_snapshot_append_border (snapshot,
&outline,
(float[4]) { 4, 4, 4, 4 },
(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 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);
gtk_snapshot_push_rounded_clip (snapshot, &outline);
gtk_snapshot_append_color (snapshot, &BLACK, &outline.bounds);
gtk_snapshot_pop (snapshot);
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.
*/
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);
gtk_snapshot_push_rounded_clip (snapshot, &outline);
gtk_snapshot_append_color (snapshot, &BLACK, &outline.bounds);
gtk_snapshot_pop (snapshot);
gtk_snapshot_restore (snapshot);
/* and finally, the second indicator. */
gtk_snapshot_save (snapshot);
gtk_snapshot_rotate (snapshot, 6 * g_date_time_get_second (time));
gsk_rounded_rect_init_from_rect (&outline, &GRAPHENE_RECT_INIT(-2, -43, 4, 10), 2);
gtk_snapshot_push_rounded_clip (snapshot, &outline);
gtk_snapshot_append_color (snapshot, &BLACK, &outline.bounds);
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.
*/
gtk_snapshot_restore (snapshot);
g_date_time_unref (time);
}
/* Our desired size is 100px. That sounds okay for an analog clock */
static int
gtk_clock_get_intrinsic_width (GdkPaintable *paintable)
{
return 100;
}
static int
gtk_clock_get_intrinsic_height (GdkPaintable *paintable)
{
return 100;
}
/* 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)
{
iface->snapshot = gtk_clock_snapshot;
iface->get_intrinsic_width = gtk_clock_get_intrinsic_width;
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 drawn.
*/
G_DEFINE_TYPE_WITH_CODE (GtkClock, gtk_clock, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
gtk_clock_paintable_init))
static GParamSpec *properties[N_PROPS] = { NULL, };
static void
gtk_clock_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GtkClock *self = GTK_CLOCK (object);
switch (property_id)
{
case PROP_LOCATION:
g_value_set_string (value, self->location);
break;
case PROP_TIME:
g_value_take_boxed (value, gtk_clock_get_time (self));
break;
case PROP_TIMEZONE:
g_value_set_boxed (value, self->timezone);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gtk_clock_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GtkClock *self = GTK_CLOCK (object);
switch (property_id)
{
case PROP_LOCATION:
self->location = g_value_dup_string (value);
break;
case PROP_TIMEZONE:
self->timezone = g_value_dup_boxed (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
/* 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.
*/
static guint ticking_clock_id = 0;
/* Every second, this function is called to tell everybody that
* the clocks are ticking.
*/
static gboolean
gtk_clock_tick (gpointer unused)
{
GSList *l;
for (l = ticking_clocks; l; l = l->next)
{
GtkClock *clock = l->data;
/* 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.
*/
gdk_paintable_invalidate_contents (GDK_PAINTABLE (clock));
}
return G_SOURCE_CONTINUE;
}
static void
gtk_clock_stop_ticking (GtkClock *self)
{
ticking_clocks = g_slist_remove (ticking_clocks, self);
/* If no clock is remaining, stop running the tick updates */
if (ticking_clocks == NULL && ticking_clock_id != 0)
g_clear_handle_id (&ticking_clock_id, g_source_remove);
}
static void
gtk_clock_start_ticking (GtkClock *self)
{
/* if no clock is ticking yet, start */
if (ticking_clock_id == 0)
ticking_clock_id = g_timeout_add_seconds (1, gtk_clock_tick, NULL);
ticking_clocks = g_slist_prepend (ticking_clocks, self);
}
static void
gtk_clock_finalize (GObject *object)
{
GtkClock *self = GTK_CLOCK (object);
gtk_clock_stop_ticking (self);
g_free (self->location);
g_clear_pointer (&self->timezone, g_time_zone_unref);
G_OBJECT_CLASS (gtk_clock_parent_class)->finalize (object);
}
static void
gtk_clock_class_init (GtkClockClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->get_property = gtk_clock_get_property;
gobject_class->set_property = gtk_clock_set_property;
gobject_class->finalize = gtk_clock_finalize;
properties[PROP_LOCATION] =
g_param_spec_string ("location", NULL, NULL, NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
properties[PROP_TIME] =
g_param_spec_boxed ("time", NULL, NULL, G_TYPE_DATE_TIME, G_PARAM_READABLE);
properties[PROP_TIMEZONE] =
g_param_spec_boxed ("timezone", NULL, NULL, G_TYPE_TIME_ZONE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_properties (gobject_class, N_PROPS, properties);
}
static void
gtk_clock_init (GtkClock *self)
{
gtk_clock_start_ticking (self);
}
static GtkClock *
gtk_clock_new (const char *location,
GTimeZone *_tz)
{
GtkClock *result;
result = g_object_new (GTK_TYPE_CLOCK,
"location", location,
"timezone", _tz,
NULL);
g_clear_pointer (&_tz, g_time_zone_unref);
return result;
}
static GListModel *
create_clocks_model (void)
{
GListStore *result;
GtkClock *clock;
result = g_list_store_new (GTK_TYPE_CLOCK);
/* local time */
clock = gtk_clock_new ("local", NULL);
g_list_store_append (result, clock);
g_object_unref (clock);
/* UTC time */
clock = gtk_clock_new ("UTC", g_time_zone_new_utc ());
g_list_store_append (result, clock);
g_object_unref (clock);
/* A bunch of timezones with GTK hackers */
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);
clock = gtk_clock_new ("London", g_time_zone_new ("Europe/London"));
g_list_store_append (result, clock);
g_object_unref (clock);
clock = gtk_clock_new ("Berlin", g_time_zone_new ("Europe/Berlin"));
g_list_store_append (result, clock);
g_object_unref (clock);
clock = gtk_clock_new ("Moscow", g_time_zone_new ("Europe/Moscow"));
g_list_store_append (result, clock);
g_object_unref (clock);
clock = gtk_clock_new ("New Delhi", g_time_zone_new ("Asia/Kolkata"));
g_list_store_append (result, clock);
g_object_unref (clock);
clock = gtk_clock_new ("Shanghai", g_time_zone_new ("Asia/Shanghai"));
g_list_store_append (result, clock);
g_object_unref (clock);
return G_LIST_MODEL (result);
}
static char *
convert_time_to_string (GObject *image,
GDateTime *time,
gpointer unused)
{
return g_date_time_format (time, "%x\n%X");
}
/* And this function is the crux for this whole demo.
* It shows how to use expressions to set up bindings.
*/
static void
setup_listitem_cb (GtkListItemFactory *factory,
GtkListItem *list_item)
{
GtkWidget *box, *picture, *location_label, *time_label;
GtkExpression *clock_expression, *expression;
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_list_item_set_child (list_item, box);
/* First, we create an expression that gets us the clock from the listitem:
* 1. Create an expression that gets the list item.
* 2. Use that expression's "item" property to get the clock
*/
expression = gtk_constant_expression_new (GTK_TYPE_LIST_ITEM, list_item);
clock_expression = gtk_property_expression_new (GTK_TYPE_LIST_ITEM, expression, "item");
/* Bind the clock's location to a label.
* This is easy: We just get the "location" property of the clock.
*/
expression = gtk_property_expression_new (GTK_TYPE_CLOCK,
gtk_expression_ref (clock_expression),
"location");
/* Now create the label and bind the expression to it. */
location_label = gtk_label_new (NULL);
gtk_expression_bind (expression, location_label, "label", location_label);
gtk_box_append (GTK_BOX (box), location_label);
/* Here we bind the item itself to a GdkPicture.
* This is simply done by using the clock expression itself.
*/
expression = gtk_expression_ref (clock_expression);
/* Now create the widget and bind the expression to it. */
picture = gtk_picture_new ();
gtk_expression_bind (expression, picture, "paintable", picture);
gtk_box_append (GTK_BOX (box), picture);
/* And finally, everything comes together.
* We create a label for displaying the time as text.
* For that, we need to transform the "GDateTime" of the
* time property into a string so that the label can display it.
*/
expression = gtk_property_expression_new (GTK_TYPE_CLOCK,
gtk_expression_ref (clock_expression),
"time");
expression = gtk_cclosure_expression_new (G_TYPE_STRING,
NULL,
1, (GtkExpression *[1]) { expression },
G_CALLBACK (convert_time_to_string),
NULL, NULL);
/* Now create the label and bind the expression to it. */
time_label = gtk_label_new (NULL);
gtk_expression_bind (expression, time_label, "label", time_label);
gtk_box_append (GTK_BOX (box), time_label);
gtk_expression_unref (clock_expression);
}
static GtkWidget *window = NULL;
GtkWidget *
do_listview_clocks (GtkWidget *do_widget)
{
if (window == NULL)
{
GtkWidget *gridview, *sw;
GtkListItemFactory *factory;
GListModel *model;
GtkNoSelection *selection;
/* This is the normal window setup code every demo does */
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Clocks");
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (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 ();
gtk_window_set_child (GTK_WINDOW (window), sw);
/* Create the factory that creates the listitems. Because we
* used bindings above during setup, we only need to connect
* to the setup signal.
* The bindings take care of the bind step.
*/
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_listitem_cb), NULL);
gridview = gtk_grid_view_new_with_factory (factory);
gtk_scrollable_set_hscroll_policy (GTK_SCROLLABLE (gridview), GTK_SCROLL_NATURAL);
gtk_scrollable_set_vscroll_policy (GTK_SCROLLABLE (gridview), GTK_SCROLL_NATURAL);
model = create_clocks_model ();
selection = gtk_no_selection_new (model);
gtk_grid_view_set_model (GTK_GRID_VIEW (gridview), G_LIST_MODEL (selection));
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), gridview);
g_object_unref (selection);
g_object_unref (model);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_window_destroy (GTK_WINDOW (window));
return window;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
.view.compact > child {
padding: 1px;
}

View File

@@ -0,0 +1,281 @@
/* Lists/File browser
*
* This demo shows off the different layouts that are quickly achievable
* with GtkListview and GtkGridView by implementing a file browser with
* different views.
*/
#include <glib/gi18n.h>
#include <gtk/gtk.h>
static GtkWidget *window = NULL;
/* Create a simple object that holds the data for the different views */
typedef struct _FileBrowserView FileBrowserView;
struct _FileBrowserView
{
GObject parent_instance;
GtkListItemFactory *factory;
char *icon_name;
char *title;
GtkOrientation orientation;
};
enum {
PROP_0,
PROP_FACTORY,
PROP_ICON_NAME,
PROP_TITLE,
PROP_ORIENTATION,
N_PROPS
};
#define FILE_BROWSER_TYPE_VIEW (file_browser_view_get_type ())
G_DECLARE_FINAL_TYPE (FileBrowserView, file_browser_view, FILE_BROWSER, VIEW, GObject);
G_DEFINE_TYPE (FileBrowserView, file_browser_view, G_TYPE_OBJECT);
static GParamSpec *properties[N_PROPS] = { NULL, };
static void
file_browser_view_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
FileBrowserView *self = FILE_BROWSER_VIEW (object);
switch (property_id)
{
case PROP_FACTORY:
g_value_set_object (value, self->factory);
break;
case PROP_ICON_NAME:
g_value_set_string (value, self->icon_name);
break;
case PROP_TITLE:
g_value_set_string (value, self->title);
break;
case PROP_ORIENTATION:
g_value_set_enum (value, self->orientation);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
file_browser_view_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
FileBrowserView *self = FILE_BROWSER_VIEW (object);
switch (prop_id)
{
case PROP_FACTORY:
g_set_object (&self->factory, g_value_get_object (value));
break;
case PROP_ICON_NAME:
g_free (self->icon_name);
self->icon_name = g_value_dup_string (value);
break;
case PROP_TITLE:
g_free (self->title);
self->title = g_value_dup_string (value);
break;
case PROP_ORIENTATION:
self->orientation = g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
file_browser_view_finalize (GObject *object)
{
FileBrowserView *self = FILE_BROWSER_VIEW (object);
g_object_unref (self->factory);
g_free (self->icon_name);
g_free (self->title);
G_OBJECT_CLASS (file_browser_view_parent_class)->dispose (object);
}
static void
file_browser_view_class_init (FileBrowserViewClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->get_property = file_browser_view_get_property;
gobject_class->set_property = file_browser_view_set_property;
gobject_class->finalize = file_browser_view_finalize;
properties[PROP_FACTORY] =
g_param_spec_object ("factory",
"factory",
"factory to use in the main view",
GTK_TYPE_LIST_ITEM_FACTORY,
G_PARAM_READWRITE);
properties[PROP_ICON_NAME] =
g_param_spec_string ("icon-name",
"icon name",
"icon to display for selecting this view",
NULL,
G_PARAM_READWRITE);
properties[PROP_TITLE] =
g_param_spec_string ("title",
"title",
"title to display for selecting this view",
NULL,
G_PARAM_READWRITE);
properties[PROP_ORIENTATION] =
g_param_spec_enum ("orientation",
"orientation",
"orientation of the view",
GTK_TYPE_ORIENTATION,
GTK_ORIENTATION_VERTICAL,
G_PARAM_READWRITE);
g_object_class_install_properties (gobject_class, N_PROPS, properties);
}
static void file_browser_view_init (FileBrowserView *self)
{
}
char *
filebrowser_get_display_name (GObject *object,
GFileInfo *info)
{
if (!info)
return NULL;
return g_strdup (g_file_info_get_attribute_string (info, "standard::display-name"));
}
char *
filebrowser_get_content_type (GObject *object,
GFileInfo *info)
{
if (!info)
return NULL;
return g_strdup (g_file_info_get_attribute_string (info, "standard::content-type"));
}
char *
filebrowser_get_size (GObject *object,
GFileInfo *info)
{
if (!info)
return NULL;
return g_format_size (g_file_info_get_attribute_uint64 (info, "standard::size"));
}
GIcon *
filebrowser_get_icon (GObject *object,
GFileInfo *info)
{
GIcon *icon;
if (info)
icon = G_ICON (g_file_info_get_attribute_object (info, "standard::icon"));
else
icon = NULL;
if (icon)
g_object_ref (icon);
return icon;
}
void
filebrowser_up_clicked_cb (GtkButton *button,
GtkDirectoryList *list)
{
GFile *file;
file = g_file_get_parent (gtk_directory_list_get_file (list));
if (file == NULL)
return;
gtk_directory_list_set_file (list, file);
}
void
filebrowser_view_activated_cb (GtkGridView *view,
guint pos,
GtkDirectoryList *list)
{
GFileInfo *info;
info = g_list_model_get_item (gtk_grid_view_get_model (view), pos);
if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY)
gtk_directory_list_set_file (list, G_FILE (g_file_info_get_attribute_object (info, "standard::file")));
g_object_unref (info);
}
GtkWidget *
do_listview_filebrowser (GtkWidget *do_widget)
{
if (!window)
{
GtkWidget *view;
GtkBuilder *builder;
GtkDirectoryList *dirlist;
GFile *file;
char *cwd;
GtkCssProvider *provider;
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_resource (provider, "/listview_filebrowser/listview_filebrowser.css");
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
800);
g_object_unref (provider);
builder = gtk_builder_new_from_resource ("/listview_filebrowser/listview_filebrowser.ui");
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *) &window);
/* Create the model and fill it with the contents of the current directory */
cwd = g_get_current_dir ();
file = g_file_new_for_path (cwd);
g_free (cwd);
dirlist = GTK_DIRECTORY_LIST (gtk_builder_get_object (builder, "dirlist"));
gtk_directory_list_set_file (dirlist, file);
g_object_unref (file);
/* grab focus in the view */
view = GTK_WIDGET (gtk_builder_get_object (builder, "view"));
gtk_widget_grab_focus (view);
g_object_unref (builder);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_window_destroy (GTK_WINDOW (window));
return window;
}

View File

@@ -0,0 +1,11 @@
listview.viewswitcher {
border: 1px solid gray;
}
listview.viewswitcher > row {
padding: 5px;
}
listview.viewswitcher row:selected {
background: gray;
}

View File

@@ -0,0 +1,248 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GListStore" id="viewlist">
<property name="item-type">FileBrowserView</property>
<child>
<object class="FileBrowserView">
<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">
<child>
<object class="GtkImage">
<binding name="gicon">
<closure type="GIcon" function="filebrowser_get_icon">
<lookup name="item">GtkListItem</lookup>
</closure>
</binding>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="halign">start</property>
<binding name="label">
<closure type="gchararray" function="filebrowser_get_display_name">
<lookup name="item">GtkListItem</lookup>
</closure>
</binding>
</object>
</child>
</object>
</property>
</template>
</interface>
]]></property>
</object>
</property>
<property name="icon-name">view-list-symbolic</property>
<property name="title" translatable="yes">List</property>
<property name="orientation">horizontal</property>
</object>
</child>
<child>
<object class="FileBrowserView">
<property name="icon-name">view-grid-symbolic</property>
<property name="title" translatable="yes">Grid</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="icon-size">large</property>
<binding name="gicon">
<closure type="GIcon" function="filebrowser_get_icon">
<lookup name="item">GtkListItem</lookup>
</closure>
</binding>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="wrap">1</property>
<property name="wrap-mode">word-char</property>
<property name="lines">2</property>
<property name="ellipsize">end</property>
<property name="width-chars">10</property>
<property name="max-width-chars">30</property>
<binding name="label">
<closure type="gchararray" function="filebrowser_get_display_name">
<lookup name="item">GtkListItem</lookup>
</closure>
</binding>
</object>
</child>
</object>
</property>
</template>
</interface>
]]></property>
</object>
</property>
<property name="orientation">vertical</property>
</object>
</child>
<child>
<object class="FileBrowserView">
<property name="icon-name">view-paged-symbolic</property>
<property name="title" translatable="yes">Paged</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">
<child>
<object class="GtkImage">
<property name="icon-size">large</property>
<binding name="gicon">
<closure type="GIcon" function="filebrowser_get_icon">
<lookup name="item">GtkListItem</lookup>
</closure>
</binding>
</object>
</child>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<property name="halign">start</property>
<binding name="label">
<closure type="gchararray" function="filebrowser_get_display_name">
<lookup name="item">GtkListItem</lookup>
</closure>
</binding>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="halign">start</property>
<binding name="label">
<closure type="gchararray" function="filebrowser_get_size">
<lookup name="item">GtkListItem</lookup>
</closure>
</binding>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="halign">start</property>
<binding name="label">
<closure type="gchararray" function="filebrowser_get_content_type">
<lookup name="item">GtkListItem</lookup>
</closure>
</binding>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
</object>
</child>
</object>
</property>
</template>
</interface>
]]></property>
</object>
</property>
<property name="orientation">horizontal</property>
</object>
</child>
</object>
<object class="GtkDirectoryList" id="dirlist">
<property name="attributes">standard::name,standard::display-name,standard::icon,standard::size,standard::content-type</property>
</object>
<object class="GtkWindow" id="window">
<property name="title" translatable="yes">File browser</property>
<property name="default-width">600</property>
<property name="default-height">400</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="">
<child>
<object class="GtkButton">
<property name="icon-name">go-up-symbolic</property>
<signal name="clicked" handler="filebrowser_up_clicked_cb" object="dirlist" swapped="no"/>
</object>
</child>
<child type="end">
<object class="GtkListView">
<property name="valign">center</property>
<property name="orientation">horizontal</property>
<style>
<class name="linked"/>
<class name="viewswitcher"/>
</style>
<property name="model">
<object class="GtkSingleSelection" id="selected-view">
<property name="model">viewlist</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="GtkImage">
<binding name="icon-name">
<lookup type="FileBrowserView" name="icon-name">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
<binding name="tooltip-text">
<lookup type="FileBrowserView" name="title">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</property>
</template>
</interface>
]]></property>
</object>
</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="can-focus">1</property>
<child>
<object class="GtkGridView" id="view">
<property name="model">dirlist</property>
<property name="max-columns">15</property>
<binding name="factory">
<lookup name="factory" type="FileBrowserView">
<lookup name="selected-item">selected-view</lookup>
</lookup>
</binding>
<binding name="orientation">
<lookup name="orientation" type="FileBrowserView">
<lookup name="selected-item">selected-view</lookup>
</lookup>
</binding>
<signal name="activate" handler="filebrowser_view_activated_cb" object="dirlist" swapped="no"/>
</object>
</child>
</object>
</child>
</object>
</interface>

View File

@@ -0,0 +1,472 @@
/* Lists/Minesweeper
*
* This demo shows how to develop a user interface for small game using a
* gridview.
*
* It demonstrates how to use the activate signal and single-press behavior
* to implement rather different interaction behavior to a typical list.
*/
#include <glib/gi18n.h>
#include <gtk/gtk.h>
/*** The cell object ***/
/* Create an object that holds the data for a cell in the game */
typedef struct _SweeperCell SweeperCell;
struct _SweeperCell
{
GObject parent_instance;
gboolean is_mine;
gboolean is_visible;
guint neighbor_mines;
};
enum {
CELL_PROP_0,
CELL_PROP_LABEL,
N_CELL_PROPS
};
#define SWEEPER_TYPE_CELL (sweeper_cell_get_type ())
G_DECLARE_FINAL_TYPE (SweeperCell, sweeper_cell, SWEEPER, CELL, GObject);
G_DEFINE_TYPE (SweeperCell, sweeper_cell, G_TYPE_OBJECT);
static GParamSpec *cell_properties[N_CELL_PROPS] = { NULL, };
static const char *
sweeper_cell_get_label (SweeperCell *self)
{
static const char *minecount_labels[10] = { "", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
if (!self->is_visible)
return "?";
if (self->is_mine)
return "💣";
return minecount_labels[self->neighbor_mines];
}
static void
sweeper_cell_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
SweeperCell *self = SWEEPER_CELL (object);
switch (property_id)
{
case CELL_PROP_LABEL:
g_value_set_string (value, sweeper_cell_get_label (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
sweeper_cell_class_init (SweeperCellClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->get_property = sweeper_cell_get_property;
cell_properties[CELL_PROP_LABEL] =
g_param_spec_string ("label",
"label",
"label to display for this row",
NULL,
G_PARAM_READABLE);
g_object_class_install_properties (gobject_class, N_CELL_PROPS, cell_properties);
}
static void
sweeper_cell_init (SweeperCell *self)
{
}
static void
sweeper_cell_reveal (SweeperCell *self)
{
if (self->is_visible)
return;
self->is_visible = TRUE;
g_object_notify_by_pspec (G_OBJECT (self), cell_properties[CELL_PROP_LABEL]);
}
static SweeperCell *
sweeper_cell_new (void)
{
return g_object_new (SWEEPER_TYPE_CELL, NULL);
}
/*** The board object ***/
/* Create an object that holds the data for the game */
typedef struct _SweeperGame SweeperGame;
struct _SweeperGame
{
GObject parent_instance;
GPtrArray *cells;
guint width;
guint height;
gboolean playing;
gboolean win;
};
enum {
GAME_PROP_0,
GAME_PROP_HEIGHT,
GAME_PROP_PLAYING,
GAME_PROP_WIDTH,
GAME_PROP_WIN,
N_GAME_PROPS
};
#define SWEEPER_TYPE_GAME (sweeper_game_get_type ())
G_DECLARE_FINAL_TYPE (SweeperGame, sweeper_game, SWEEPER, GAME, GObject);
static GType
sweeper_game_list_model_get_item_type (GListModel *model)
{
return SWEEPER_TYPE_GAME;
}
static guint
sweeper_game_list_model_get_n_items (GListModel *model)
{
SweeperGame *self = SWEEPER_GAME (model);
return self->width * self->height;
}
static gpointer
sweeper_game_list_model_get_item (GListModel *model,
guint position)
{
SweeperGame *self = SWEEPER_GAME (model);
return g_object_ref (g_ptr_array_index (self->cells, position));
}
static void
sweeper_game_list_model_init (GListModelInterface *iface)
{
iface->get_item_type = sweeper_game_list_model_get_item_type;
iface->get_n_items = sweeper_game_list_model_get_n_items;
iface->get_item = sweeper_game_list_model_get_item;
}
G_DEFINE_TYPE_WITH_CODE (SweeperGame, sweeper_game, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, sweeper_game_list_model_init))
static GParamSpec *game_properties[N_GAME_PROPS] = { NULL, };
static void
sweeper_game_dispose (GObject *object)
{
SweeperGame *self = SWEEPER_GAME (object);
g_clear_pointer (&self->cells, g_ptr_array_unref);
G_OBJECT_CLASS (sweeper_game_parent_class)->dispose (object);
}
static void
sweeper_game_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
SweeperGame *self = SWEEPER_GAME (object);
switch (property_id)
{
case GAME_PROP_HEIGHT:
g_value_set_uint (value, self->height);
break;
case GAME_PROP_PLAYING:
g_value_set_boolean (value, self->playing);
break;
case GAME_PROP_WIDTH:
g_value_set_uint (value, self->width);
break;
case GAME_PROP_WIN:
g_value_set_boolean (value, self->win);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
sweeper_game_class_init (SweeperGameClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->dispose = sweeper_game_dispose;
gobject_class->get_property = sweeper_game_get_property;
game_properties[GAME_PROP_HEIGHT] =
g_param_spec_uint ("height",
"height",
"height of the game grid",
1, G_MAXUINT, 8,
G_PARAM_READABLE);
game_properties[GAME_PROP_PLAYING] =
g_param_spec_boolean ("playing",
"playing",
"if the game is still going on",
FALSE,
G_PARAM_READABLE);
game_properties[GAME_PROP_WIDTH] =
g_param_spec_uint ("width",
"width",
"width of the game grid",
1, G_MAXUINT, 8,
G_PARAM_READABLE);
game_properties[GAME_PROP_WIN] =
g_param_spec_boolean ("win",
"win",
"if the game was won",
FALSE,
G_PARAM_READABLE);
g_object_class_install_properties (gobject_class, N_GAME_PROPS, game_properties);
}
static void
sweeper_game_reset_board (SweeperGame *self,
guint width,
guint height)
{
guint i;
g_ptr_array_set_size (self->cells, 0);
for (i = 0; i < width * height; i++)
{
g_ptr_array_add (self->cells, sweeper_cell_new ());
}
if (self->width != width)
{
self->width = width;
g_object_notify_by_pspec (G_OBJECT (self), game_properties[GAME_PROP_WIDTH]);
}
if (self->height != height)
{
self->height = height;
g_object_notify_by_pspec (G_OBJECT (self), game_properties[GAME_PROP_HEIGHT]);
}
if (!self->playing)
{
self->playing = TRUE;
g_object_notify_by_pspec (G_OBJECT (self), game_properties[GAME_PROP_PLAYING]);
}
if (self->win)
{
self->win = FALSE;
g_object_notify_by_pspec (G_OBJECT (self), game_properties[GAME_PROP_WIN]);
}
}
static void
sweeper_game_place_mines (SweeperGame *self,
guint n_mines)
{
guint i;
for (i = 0; i < n_mines; i++)
{
SweeperCell *cell;
do {
cell = g_ptr_array_index (self->cells, g_random_int_range (0, self->cells->len));
} while (cell->is_mine);
cell->is_mine = TRUE;
}
}
static SweeperCell *
get_cell (SweeperGame *self,
guint x,
guint y)
{
return g_ptr_array_index (self->cells, y * self->width + x);
}
static void
sweeper_game_count_neighbor_mines (SweeperGame *self,
guint width,
guint height)
{
guint x, y, x2, y2;
for (y = 0; y < height; y++)
{
for (x = 0; x < width; x++)
{
SweeperCell *cell = get_cell (self, x, y);
for (y2 = MAX (1, y) - 1; y2 < MIN (height, y + 2); y2++)
{
for (x2 = MAX (1, x) - 1; x2 < MIN (width, x + 2); x2++)
{
SweeperCell *other = get_cell (self, x2, y2);
if (other->is_mine)
cell->neighbor_mines++;
}
}
}
}
}
static void
sweeper_game_new_game (SweeperGame *self,
guint width,
guint height,
guint n_mines)
{
guint n_items_before;
g_return_if_fail (n_mines <= width * height);
n_items_before = self->width * self->height;
g_object_freeze_notify (G_OBJECT (self));
sweeper_game_reset_board (self, width, height);
sweeper_game_place_mines (self, n_mines);
sweeper_game_count_neighbor_mines (self, width, height);
g_list_model_items_changed (G_LIST_MODEL (self), 0, n_items_before, width * height);
g_object_thaw_notify (G_OBJECT (self));
}
static void
sweeper_game_init (SweeperGame *self)
{
self->cells = g_ptr_array_new_with_free_func (g_object_unref);
sweeper_game_new_game (self, 8, 8, 10);
}
static void
sweeper_game_end (SweeperGame *self,
gboolean win)
{
if (self->playing)
{
self->playing = FALSE;
g_object_notify_by_pspec (G_OBJECT (self), game_properties[GAME_PROP_PLAYING]);
}
if (self->win != win)
{
self->win = win;
g_object_notify_by_pspec (G_OBJECT (self), game_properties[GAME_PROP_WIN]);
}
}
static void
sweeper_game_check_finished (SweeperGame *self)
{
guint i;
if (!self->playing)
return;
for (i = 0; i < self->cells->len; i++)
{
SweeperCell *cell = g_ptr_array_index (self->cells, i);
/* There's still a non-revealed cell that isn't a mine */
if (!cell->is_visible && !cell->is_mine)
return;
}
sweeper_game_end (self, TRUE);
}
static void
sweeper_game_reveal_cell (SweeperGame *self,
guint position)
{
SweeperCell *cell;
if (!self->playing)
return;
cell = g_ptr_array_index (self->cells, position);
sweeper_cell_reveal (cell);
if (cell->is_mine)
sweeper_game_end (self, FALSE);
sweeper_game_check_finished (self);
}
void
minesweeper_cell_clicked_cb (GtkGridView *gridview,
guint pos,
SweeperGame *game)
{
sweeper_game_reveal_cell (game, pos);
}
void
minesweeper_new_game_cb (GtkButton *button,
SweeperGame *game)
{
sweeper_game_new_game (game, 8, 8, 10);
}
static GtkWidget *window = NULL;
GtkWidget *
do_listview_minesweeper (GtkWidget *do_widget)
{
if (window == NULL)
{
GtkBuilder *builder;
g_type_ensure (SWEEPER_TYPE_GAME);
builder = gtk_builder_new_from_resource ("/listview_minesweeper/listview_minesweeper.ui");
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *) &window);
g_object_unref (builder);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_window_destroy (GTK_WINDOW (window));
return window;
}

View File

@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="SweeperGame" id="game">
</object>
<object class="GtkWindow" id="window">
<property name="title" translatable="yes">Minesweeper</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="">
<child>
<object class="GtkButton">
<property name="label">New Game</property>
<signal name="clicked" handler="minesweeper_new_game_cb" object="game" swapped="no"/>
</object>
</child>
<child type="title">
<object class="GtkImage">
<property name="icon-name">trophy-gold</property>
<binding name="visible">
<lookup name="win">game</lookup>
</binding>
</object>
</child>
</object>
</child>
<child>
<object class="GtkGridView" id="view">
<property name="model">
<object class="GtkNoSelection">
<property name="model">game</property>
</object>
</property>
<property name="single-click-activate">1</property>
<binding name="max-columns">
<lookup name="width">game</lookup>
</binding>
<binding name="min-columns">
<lookup name="width">game</lookup>
</binding>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="resource">/listview_minesweeper/listview_minesweeper_cell.ui</property>
</object>
</property>
<signal name="activate" handler="minesweeper_cell_clicked_cb" object="game" swapped="no"/>
</object>
</child>
</object>
</interface>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GtkListItem">
<property name="child">
<object class="GtkLabel">
<property name="halign">center</property>
<property name="valign">center</property>
<binding name="label">
<lookup name="label" type="SweeperCell">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</property>
</template>
</interface>

View File

@@ -0,0 +1,432 @@
/* Lists/Settings
*
* This demo shows a settings viewer for GSettings.
*
* It demonstrates how to implement support for trees with GtkListView.
* It also shows how to set up sorting and filtering for columns in a
* GtkColumnView.
*/
#include <gtk/gtk.h>
#include <stdlib.h>
/* Create an object that wraps GSettingsSchemaKey because that's a boxed type */
typedef struct _SettingsKey SettingsKey;
struct _SettingsKey
{
GObject parent_instance;
GSettings *settings;
GSettingsSchemaKey *key;
};
enum {
PROP_0,
PROP_NAME,
PROP_SUMMARY,
PROP_DESCRIPTION,
PROP_VALUE,
PROP_TYPE,
PROP_DEFAULT_VALUE,
N_PROPS
};
#define SETTINGS_TYPE_KEY (settings_key_get_type ())
G_DECLARE_FINAL_TYPE (SettingsKey, settings_key, SETTINGS, KEY, GObject);
G_DEFINE_TYPE (SettingsKey, settings_key, G_TYPE_OBJECT);
static GParamSpec *properties[N_PROPS] = { NULL, };
static void
settings_key_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
SettingsKey *self = SETTINGS_KEY (object);
switch (property_id)
{
case PROP_DESCRIPTION:
g_value_set_string (value, g_settings_schema_key_get_description (self->key));
break;
case PROP_NAME:
g_value_set_string (value, g_settings_schema_key_get_name (self->key));
break;
case PROP_SUMMARY:
g_value_set_string (value, g_settings_schema_key_get_summary (self->key));
break;
case PROP_VALUE:
{
GVariant *variant = g_settings_get_value (self->settings, g_settings_schema_key_get_name (self->key));
g_value_take_string (value, g_variant_print (variant, FALSE));
g_variant_unref (variant);
}
break;
case PROP_TYPE:
{
const GVariantType *type = g_settings_schema_key_get_value_type (self->key);
g_value_set_string (value, g_variant_type_peek_string (type));
}
break;
case PROP_DEFAULT_VALUE:
{
GVariant *variant = g_settings_schema_key_get_default_value (self->key);
g_value_take_string (value, g_variant_print (variant, FALSE));
g_variant_unref (variant);
}
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
settings_key_finalize (GObject *object)
{
SettingsKey *self = SETTINGS_KEY (object);
g_object_unref (self->settings);
g_settings_schema_key_unref (self->key);
G_OBJECT_CLASS (settings_key_parent_class)->finalize (object);
}
static void
settings_key_class_init (SettingsKeyClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = settings_key_finalize;
gobject_class->get_property = settings_key_get_property;
properties[PROP_DESCRIPTION] =
g_param_spec_string ("description", NULL, NULL, NULL, G_PARAM_READABLE);
properties[PROP_NAME] =
g_param_spec_string ("name", NULL, NULL, NULL, G_PARAM_READABLE);
properties[PROP_SUMMARY] =
g_param_spec_string ("summary", NULL, NULL, NULL, G_PARAM_READABLE);
properties[PROP_VALUE] =
g_param_spec_string ("value", NULL, NULL, NULL, G_PARAM_READABLE);
properties[PROP_TYPE] =
g_param_spec_string ("type", NULL, NULL, NULL, G_PARAM_READABLE);
properties[PROP_DEFAULT_VALUE] =
g_param_spec_string ("default-value", NULL, NULL, NULL, G_PARAM_READABLE);
g_object_class_install_properties (gobject_class, N_PROPS, properties);
}
static void
settings_key_init (SettingsKey *self)
{
}
static SettingsKey *
settings_key_new (GSettings *settings,
GSettingsSchemaKey *key)
{
SettingsKey *result = g_object_new (SETTINGS_TYPE_KEY, NULL);
result->settings = g_object_ref (settings);
result->key = g_settings_schema_key_ref (key);
return result;
}
static void
item_value_changed (GtkEditableLabel *label,
GParamSpec *pspec,
GtkListItem *item)
{
SettingsKey *self;
const char *text;
const GVariantType *type;
GVariant *variant;
GError *error = NULL;
const char *name;
char *value;
text = gtk_editable_get_text (GTK_EDITABLE (label));
g_object_get (item, "item", &self, NULL);
g_object_unref (self);
type = g_settings_schema_key_get_value_type (self->key);
name = g_settings_schema_key_get_name (self->key);
variant = g_variant_parse (type, text, NULL, NULL, &error);
if (!variant)
{
g_warning ("%s", error->message);
g_clear_error (&error);
goto revert;
}
if (!g_settings_schema_key_range_check (self->key, variant))
{
g_warning ("Not a valid value for %s", name);
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
strvcmp (gconstpointer p1,
gconstpointer p2)
{
const char * const *s1 = p1;
const char * const *s2 = p2;
return strcmp (*s1, *s2);
}
static GtkFilter *current_filter;
static gboolean
transform_settings_to_keys (GBinding *binding,
const GValue *from_value,
GValue *to_value,
gpointer data)
{
GtkTreeListRow *treelistrow;
GSettings *settings;
GSettingsSchema *schema;
GListStore *store;
GtkSortListModel *sort_model;
GtkFilterListModel *filter_model;
GtkFilter *filter;
GtkNoSelection *selection_model;
char **keys;
guint i;
treelistrow = g_value_get_object (from_value);
if (treelistrow == NULL)
return TRUE;
settings = gtk_tree_list_row_get_item (treelistrow);
g_object_get (settings, "settings-schema", &schema, NULL);
store = g_list_store_new (SETTINGS_TYPE_KEY);
keys = g_settings_schema_list_keys (schema);
for (i = 0; keys[i] != NULL; i++)
{
GSettingsSchemaKey *almost_there = g_settings_schema_get_key (schema, keys[i]);
SettingsKey *finally = settings_key_new (settings, almost_there);
g_list_store_append (store, finally);
g_object_unref (finally);
g_settings_schema_key_unref (almost_there);
}
g_strfreev (keys);
g_settings_schema_unref (schema);
g_object_unref (settings);
sort_model = gtk_sort_list_model_new (G_LIST_MODEL (store),
g_object_ref (gtk_column_view_get_sorter (GTK_COLUMN_VIEW (data))));
filter = gtk_string_filter_new (gtk_property_expression_new (SETTINGS_TYPE_KEY, NULL, "name"));
g_set_object (&current_filter, filter);
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (sort_model), filter);
selection_model = gtk_no_selection_new (G_LIST_MODEL (filter_model));
g_object_unref (filter_model);
g_value_take_object (to_value, selection_model);
return TRUE;
}
static GListModel *
create_settings_model (gpointer item,
gpointer unused)
{
GSettings *settings = item;
char **schemas;
GListStore *result;
guint i;
if (settings == NULL)
{
g_settings_schema_source_list_schemas (g_settings_schema_source_get_default (),
TRUE,
&schemas,
NULL);
}
else
{
schemas = g_settings_list_children (settings);
}
if (schemas == NULL || schemas[0] == NULL)
{
g_free (schemas);
return NULL;
}
qsort (schemas, g_strv_length (schemas), sizeof (char *), strvcmp);
result = g_list_store_new (G_TYPE_SETTINGS);
for (i = 0; schemas[i] != NULL; i++)
{
GSettings *child;
if (settings == NULL)
child = g_settings_new (schemas[i]);
else
child = g_settings_get_child (settings, schemas[i]);
g_list_store_append (result, child);
g_object_unref (child);
}
g_strfreev (schemas);
return G_LIST_MODEL (result);
}
static void
search_enabled (GtkSearchEntry *entry)
{
gtk_editable_set_text (GTK_EDITABLE (entry), "");
}
static void
search_changed (GtkSearchEntry *entry,
gpointer data)
{
const char *text = gtk_editable_get_text (GTK_EDITABLE (entry));
if (current_filter)
gtk_string_filter_set_search (GTK_STRING_FILTER (current_filter), text);
}
static void
stop_search (GtkSearchEntry *entry,
gpointer data)
{
gtk_editable_set_text (GTK_EDITABLE (entry), "");
if (current_filter)
gtk_string_filter_set_search (GTK_STRING_FILTER (current_filter), "");
}
static GtkWidget *window = NULL;
GtkWidget *
do_listview_settings (GtkWidget *do_widget)
{
if (window == NULL)
{
GtkWidget *listview, *columnview;
GListModel *model;
GtkTreeListModel *treemodel;
GtkSingleSelection *selection;
GtkBuilderScope *scope;
GtkBuilder *builder;
GtkColumnViewColumn *name_column;
GtkColumnViewColumn *type_column;
GtkColumnViewColumn *default_column;
GtkColumnViewColumn *summary_column;
GtkColumnViewColumn *description_column;
GtkSorter *sorter;
GActionGroup *actions;
GAction *action;
g_type_ensure (SETTINGS_TYPE_KEY);
scope = gtk_builder_cscope_new ();
gtk_builder_cscope_add_callback_symbol (GTK_BUILDER_CSCOPE (scope), "search_enabled", (GCallback)search_enabled);
gtk_builder_cscope_add_callback_symbol (GTK_BUILDER_CSCOPE (scope), "search_changed", (GCallback)search_changed);
gtk_builder_cscope_add_callback_symbol (GTK_BUILDER_CSCOPE (scope), "stop_search", (GCallback)stop_search);
gtk_builder_cscope_add_callback_symbol (GTK_BUILDER_CSCOPE (scope), "item_value_changed", (GCallback)item_value_changed);
builder = gtk_builder_new ();
gtk_builder_set_scope (builder, scope);
gtk_builder_add_from_resource (builder, "/listview_settings/listview_settings.ui", NULL);
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *) &window);
listview = GTK_WIDGET (gtk_builder_get_object (builder, "listview"));
columnview = GTK_WIDGET (gtk_builder_get_object (builder, "columnview"));
type_column = GTK_COLUMN_VIEW_COLUMN (gtk_builder_get_object (builder, "type_column"));
default_column = GTK_COLUMN_VIEW_COLUMN (gtk_builder_get_object (builder, "default_column"));
summary_column = GTK_COLUMN_VIEW_COLUMN (gtk_builder_get_object (builder, "summary_column"));
description_column = GTK_COLUMN_VIEW_COLUMN (gtk_builder_get_object (builder, "description_column"));
actions = G_ACTION_GROUP (g_simple_action_group_new ());
action = G_ACTION (g_property_action_new ("show-type", type_column, "visible"));
g_action_map_add_action (G_ACTION_MAP (actions), action);
g_object_unref (action);
action = G_ACTION (g_property_action_new ("show-default", default_column, "visible"));
g_action_map_add_action (G_ACTION_MAP (actions), action);
g_object_unref (action);
action = G_ACTION (g_property_action_new ("show-summary", summary_column, "visible"));
g_action_map_add_action (G_ACTION_MAP (actions), action);
g_object_unref (action);
action = G_ACTION (g_property_action_new ("show-description", description_column, "visible"));
g_action_map_add_action (G_ACTION_MAP (actions), action);
g_object_unref (action);
gtk_widget_insert_action_group (columnview, "columnview", actions);
g_object_unref (actions);
model = create_settings_model (NULL, NULL);
treemodel = gtk_tree_list_model_new (model,
FALSE,
TRUE,
create_settings_model,
NULL,
NULL);
selection = gtk_single_selection_new (G_LIST_MODEL (treemodel));
g_object_bind_property_full (selection, "selected-item",
columnview, "model",
G_BINDING_SYNC_CREATE,
transform_settings_to_keys,
NULL,
columnview, NULL);
gtk_list_view_set_model (GTK_LIST_VIEW (listview), G_LIST_MODEL (selection));
g_object_unref (selection);
g_object_unref (treemodel);
name_column = GTK_COLUMN_VIEW_COLUMN (gtk_builder_get_object (builder, "name_column"));
sorter = gtk_string_sorter_new (gtk_property_expression_new (SETTINGS_TYPE_KEY, NULL, "name"));
gtk_column_view_column_set_sorter (name_column, sorter);
g_object_unref (sorter);
g_object_unref (builder);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_window_destroy (GTK_WINDOW (window));
return window;
}

View File

@@ -0,0 +1,279 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkWindow" id="window">
<property name="title" translatable="yes">Settings</property>
<property name="default-width">640</property>
<property name="default-height">480</property>
<child type="titlebar">
<object class="GtkHeaderBar">
<child type="end">
<object class="GtkToggleButton" id="search_button">
<property name="icon-name">system-search-symbolic</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkPaned">
<property name="position">300</property>
<child>
<object class="GtkScrolledWindow">
<child>
<object class="GtkListView" id="listview">
<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="GtkTreeExpander" id="expander">
<binding name="list-row">
<lookup name="item">GtkListItem</lookup>
</binding>
<property name="child">
<object class="GtkLabel">
<property name="xalign">0</property>
<binding name="label">
<lookup name="schema" type="GSettings">
<lookup name="item">expander</lookup>
</lookup>
</binding>
</object>
</property>
</object>
</property>
</template>
</interface>
]]></property>
</object>
</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkSearchBar">
<property name="search-mode-enabled" bind-source="search_button" bind-property="active" bind-flags="bidirectional"/>
<signal name="notify::search-mode-enabled" handler="search_enabled" object="entry"/>
<child>
<object class="GtkSearchEntry" id="entry">
<signal name="search-changed" handler="search_changed"/>
<signal name="stop-search" handler="stop_search"/>
</object>
</child>
</object>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<child>
<object class="GtkColumnView" id="columnview">
<child>
<object class="GtkColumnViewColumn" id="name_column">
<property name="title">Name</property>
<property name="header-menu">header_menu</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="SettingsKey">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</property>
</template>
</interface>
]]></property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkColumnViewColumn">
<property name="title">Value</property>
<property name="resizable">1</property>
<property name="header-menu">header_menu</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="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>
</interface>
]]></property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkColumnViewColumn" id="type_column">
<property name="title">Type</property>
<property name="resizable">1</property>
<property name="header-menu">header_menu</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="type" type="SettingsKey">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</property>
</template>
</interface>
]]></property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkColumnViewColumn" id="default_column">
<property name="title">Default</property>
<property name="resizable">1</property>
<property name="expand">1</property>
<property name="header-menu">header_menu</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="default-value" type="SettingsKey">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</property>
</template>
</interface>
]]></property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkColumnViewColumn" id="summary_column">
<property name="title">Summary</property>
<property name="resizable">1</property>
<property name="visible">0</property>
<property name="expand">1</property>
<property name="header-menu">header_menu</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>
<property name="wrap">1</property>
<binding name="label">
<lookup name="summary" type="SettingsKey">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</property>
</template>
</interface>
]]></property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkColumnViewColumn" id="description_column">
<property name="title">Description</property>
<property name="resizable">1</property>
<property name="visible">0</property>
<property name="expand">1</property>
<property name="header-menu">header_menu</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>
<property name="wrap">1</property>
<binding name="label">
<lookup name="description" type="SettingsKey">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</property>
</template>
</interface>
]]></property>
</object>
</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
<menu id="header_menu">
<section>
<item>
<attribute name="label" translatable="yes">Type</attribute>
<attribute name="action">columnview.show-type</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Default value</attribute>
<attribute name="action">columnview.show-default</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Summary</attribute>
<attribute name="action">columnview.show-summary</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Description</attribute>
<attribute name="action">columnview.show-description</attribute>
</item>
</section>
</menu>
</interface>

View File

@@ -0,0 +1,329 @@
/* Lists/Weather
*
* This demo shows a few of the rarer features of GtkListView and
* how they can be used to display weather information.
*
* The hourly weather info uses a horizontal listview. This is easy
* to achieve because GtkListView implements the GtkOrientable interface.
* To make the items in the list stand out more, the listview uses
* separators.
*
* 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.
*/
#include <gtk/gtk.h>
#define GTK_TYPE_WEATHER_INFO (gtk_weather_info_get_type ())
G_DECLARE_FINAL_TYPE (GtkWeatherInfo, gtk_weather_info, GTK, WEATHER_INFO, GObject)
typedef enum {
GTK_WEATHER_CLEAR,
GTK_WEATHER_FEW_CLOUDS,
GTK_WEATHER_FOG,
GTK_WEATHER_OVERCAST,
GTK_WEATHER_SCATTERED_SHOWERS,
GTK_WEATHER_SHOWERS,
GTK_WEATHER_SNOW,
GTK_WEATHER_STORM
} GtkWeatherType;
struct _GtkWeatherInfo
{
GObject parent_instance;
gint64 timestamp;
int temperature;
GtkWeatherType weather_type;
};
struct _GtkWeatherInfoClass
{
GObjectClass parent_class;
};
G_DEFINE_TYPE (GtkWeatherInfo, gtk_weather_info, G_TYPE_OBJECT)
static void
gtk_weather_info_class_init (GtkWeatherInfoClass *klass)
{
}
static void
gtk_weather_info_init (GtkWeatherInfo *self)
{
}
static GtkWeatherInfo *
gtk_weather_info_new (GDateTime *timestamp,
GtkWeatherInfo *copy_from)
{
GtkWeatherInfo *result;
result = g_object_new (GTK_TYPE_WEATHER_INFO, NULL);
result->timestamp = g_date_time_to_unix (timestamp);
if (copy_from)
{
result->temperature = copy_from->temperature;
result->weather_type = copy_from->weather_type;
}
return result;
}
static GDateTime *
parse_timestamp (const char *string,
GTimeZone *_tz)
{
char *with_seconds;
GDateTime *result;
with_seconds = g_strconcat (string, ":00", NULL);
result = g_date_time_new_from_iso8601 (with_seconds, _tz);
g_free (with_seconds);
return result;
}
static GtkWeatherType
parse_weather_type (const char *clouds,
const char *precip,
GtkWeatherType fallback)
{
if (strstr (precip, "SN"))
return GTK_WEATHER_SNOW;
if (strstr (precip, "TS"))
return GTK_WEATHER_STORM;
if (strstr (precip, "DZ"))
return GTK_WEATHER_SCATTERED_SHOWERS;
if (strstr (precip, "SH") || strstr (precip, "RA"))
return GTK_WEATHER_SHOWERS;
if (strstr (precip, "FG"))
return GTK_WEATHER_FOG;
if (g_str_equal (clouds, "M") ||
g_str_equal (clouds, ""))
return fallback;
if (strstr (clouds, "OVC") ||
strstr (clouds, "BKN"))
return GTK_WEATHER_OVERCAST;
if (strstr (clouds, "BKN") ||
strstr (clouds, "SCT"))
return GTK_WEATHER_FEW_CLOUDS;
if (strstr (clouds, "VV"))
return GTK_WEATHER_FOG;
return GTK_WEATHER_CLEAR;
}
static double
parse_temperature (const char *s,
double fallback)
{
char *endptr;
double d;
d = g_ascii_strtod (s, &endptr);
if (*endptr != '\0')
return fallback;
return d;
}
static GListModel *
create_weather_model (void)
{
GListStore *store;
GTimeZone *utc;
GDateTime *timestamp;
GtkWeatherInfo *info;
GBytes *data;
char **lines;
guint i;
store = g_list_store_new (GTK_TYPE_WEATHER_INFO);
data = g_resources_lookup_data ("/listview_weather/listview_weather.txt", 0, NULL);
lines = g_strsplit (g_bytes_get_data (data, NULL), "\n", 0);
utc = g_time_zone_new_utc ();
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++)
{
char **fields;
GDateTime *date;
fields = g_strsplit (lines[i], ",", 0);
date = parse_timestamp (fields[0], utc);
while (g_date_time_difference (date, timestamp) > 30 * G_TIME_SPAN_MINUTE)
{
GDateTime *new_timestamp = g_date_time_add_hours (timestamp, 1);
g_date_time_unref (timestamp);
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);
info->weather_type = parse_weather_type (fields[2], fields[3], info->weather_type);
g_date_time_unref (date);
g_strfreev (fields);
}
g_date_time_unref (timestamp);
g_strfreev (lines);
g_bytes_unref (data);
g_time_zone_unref (utc);
return G_LIST_MODEL (store);
}
static void
setup_widget (GtkSignalListItemFactory *factory,
GtkListItem *list_item)
{
GtkWidget *box, *child;
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_list_item_set_child (list_item, box);
child = gtk_label_new (NULL);
gtk_label_set_width_chars (GTK_LABEL (child), 5);
gtk_box_append (GTK_BOX (box), child);
child = gtk_image_new ();
gtk_image_set_icon_size (GTK_IMAGE (child), GTK_ICON_SIZE_LARGE);
gtk_box_append (GTK_BOX (box), child);
child = gtk_label_new (NULL);
gtk_widget_set_vexpand (child, TRUE);
gtk_widget_set_valign (child, GTK_ALIGN_END);
gtk_label_set_width_chars (GTK_LABEL (child), 4);
gtk_box_append (GTK_BOX (box), child);
}
static void
bind_widget (GtkSignalListItemFactory *factory,
GtkListItem *list_item)
{
GtkWidget *box, *child;
GtkWeatherInfo *info;
GDateTime *timestamp;
char *s;
box = gtk_list_item_get_child (list_item);
info = gtk_list_item_get_item (list_item);
child = gtk_widget_get_first_child (box);
timestamp = g_date_time_new_from_unix_utc (info->timestamp);
s = g_date_time_format (timestamp, "%R");
gtk_label_set_text (GTK_LABEL (child), s);
g_free (s);
g_date_time_unref (timestamp);
child = gtk_widget_get_next_sibling (child);
switch (info->weather_type)
{
case GTK_WEATHER_CLEAR:
gtk_image_set_from_icon_name (GTK_IMAGE (child), "weather-clear-symbolic");
break;
case GTK_WEATHER_FEW_CLOUDS:
gtk_image_set_from_icon_name (GTK_IMAGE (child), "weather-few-clouds-symbolic");
break;
case GTK_WEATHER_FOG:
gtk_image_set_from_icon_name (GTK_IMAGE (child), "weather-fog-symbolic");
break;
case GTK_WEATHER_OVERCAST:
gtk_image_set_from_icon_name (GTK_IMAGE (child), "weather-overcast-symbolic");
break;
case GTK_WEATHER_SCATTERED_SHOWERS:
gtk_image_set_from_icon_name (GTK_IMAGE (child), "weather-showers-scattered-symbolic");
break;
case GTK_WEATHER_SHOWERS:
gtk_image_set_from_icon_name (GTK_IMAGE (child), "weather-showers-symbolic");
break;
case GTK_WEATHER_SNOW:
gtk_image_set_from_icon_name (GTK_IMAGE (child), "weather-snow-symbolic");
break;
case GTK_WEATHER_STORM:
gtk_image_set_from_icon_name (GTK_IMAGE (child), "weather-storm-symbolic");
break;
default:
gtk_image_clear (GTK_IMAGE (child));
break;
}
child = gtk_widget_get_next_sibling (child);
s = g_strdup_printf ("%d°", info->temperature);
gtk_label_set_text (GTK_LABEL (child), s);
g_free (s);
}
static GtkWidget *window = NULL;
GtkWidget *
create_weather_view (void)
{
GtkWidget *listview;
GListModel *model, *selection;
GtkListItemFactory *factory;
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_widget), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_widget), NULL);
listview = gtk_list_view_new_with_factory (factory);
gtk_orientable_set_orientation (GTK_ORIENTABLE (listview), GTK_ORIENTATION_HORIZONTAL);
gtk_list_view_set_show_separators (GTK_LIST_VIEW (listview), TRUE);
model = create_weather_model ();
selection = G_LIST_MODEL (gtk_no_selection_new (model));
gtk_list_view_set_model (GTK_LIST_VIEW (listview), selection);
g_object_unref (selection);
g_object_unref (model);
return listview;
}
GtkWidget *
do_listview_weather (GtkWidget *do_widget)
{
if (window == NULL)
{
GtkWidget *listview, *sw;
window = gtk_window_new ();
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
gtk_window_set_title (GTK_WINDOW (window), "Weather");
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (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 ();
gtk_window_set_child (GTK_WINDOW (window), sw);
listview = create_weather_view ();
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), listview);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_window_destroy (GTK_WINDOW (window));
return window;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,238 @@
/* 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;
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 (gtk_property_expression_new (GTK_TYPE_STRING_OBJECT, NULL, "string"));
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_widget_set_vexpand (sw, TRUE);
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

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GtkListItem">
<property name="child">
<object class="GtkTreeExpander" id="expander">
<binding name="list-row">
<lookup name="item">GtkListItem</lookup>
</binding>
<property name="child">
<object class="GtkLabel">
<property name="halign">start</property>
<binding name="label">
<lookup name="title" type="GtkDemo">
<lookup name="item">expander</lookup>
</lookup>
</binding>
</object>
</property>
</object>
</property>
</template>
</interface>

View File

@@ -13,21 +13,100 @@
static GtkWidget *info_view;
static GtkWidget *source_view;
static gchar *current_file = NULL;
static char *current_file = NULL;
static GtkWidget *notebook;
static GtkWidget *treeview;
static GtkSingleSelection *selection;
static GtkWidget *toplevel;
static char **search_needle;
typedef struct _GtkDemo GtkDemo;
struct _GtkDemo
{
GObject parent_instance;
const char *name;
const char *title;
const char *filename;
GDoDemoFunc func;
GListModel *children_model;
};
enum {
NAME_COLUMN,
TITLE_COLUMN,
FILENAME_COLUMN,
FUNC_COLUMN,
STYLE_COLUMN,
NUM_COLUMNS
PROP_0,
PROP_FILENAME,
PROP_NAME,
PROP_TITLE,
N_PROPS
};
# define GTK_TYPE_DEMO (gtk_demo_get_type ())
G_DECLARE_FINAL_TYPE (GtkDemo, gtk_demo, GTK, DEMO, GObject);
G_DEFINE_TYPE (GtkDemo, gtk_demo, G_TYPE_OBJECT);
static GParamSpec *properties[N_PROPS] = { NULL, };
static void
gtk_demo_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GtkDemo *self = GTK_DEMO (object);
switch (property_id)
{
case PROP_FILENAME:
g_value_set_string (value, self->filename);
break;
case PROP_NAME:
g_value_set_string (value, self->name);
break;
case PROP_TITLE:
g_value_set_string (value, self->title);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void gtk_demo_class_init (GtkDemoClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->get_property = gtk_demo_get_property;
properties[PROP_FILENAME] =
g_param_spec_string ("filename",
"filename",
"filename",
NULL,
G_PARAM_READABLE);
properties[PROP_NAME] =
g_param_spec_string ("name",
"name",
"name",
NULL,
G_PARAM_READABLE);
properties[PROP_TITLE] =
g_param_spec_string ("title",
"title",
"title",
NULL,
G_PARAM_READABLE);
g_object_class_install_properties (gobject_class, N_PROPS, properties);
}
static void gtk_demo_init (GtkDemo *self)
{
}
typedef struct _CallbackData CallbackData;
struct _CallbackData
{
@@ -35,13 +114,34 @@ struct _CallbackData
GtkTreePath *path;
};
static gboolean
gtk_demo_run (GtkDemo *self,
GtkWidget *window)
{
GtkWidget *result;
if (!self->func)
return FALSE;
result = self->func (window);
if (result == NULL)
return FALSE;
if (GTK_IS_WINDOW (result))
{
gtk_window_set_transient_for (GTK_WINDOW (result), GTK_WINDOW (window));
gtk_window_set_modal (GTK_WINDOW (result), TRUE);
}
return TRUE;
}
static void
activate_about (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
GtkApplication *app = user_data;
const gchar *authors[] = {
const char *authors[] = {
"The GTK Team",
NULL
};
@@ -61,7 +161,7 @@ activate_about (GSimpleAction *action,
gtk_get_major_version (),
gtk_get_minor_version (),
gtk_get_micro_version ());
g_string_append_printf (s, "\nA link can apppear here: <http://www.gtk.org>");
g_string_append_printf (s, "\nA link can appear here: <http://www.gtk.org>");
version = g_strdup_printf ("%s\nRunning against GTK %d.%d.%d",
PACKAGE_VERSION,
@@ -115,82 +215,15 @@ activate_inspector (GSimpleAction *action,
gtk_window_set_interactive_debugging (TRUE);
}
static void
window_closed_cb (GtkWidget *window, gpointer data)
{
CallbackData *cbdata = data;
GtkTreeIter iter;
PangoStyle style;
gtk_tree_model_get_iter (cbdata->model, &iter, cbdata->path);
gtk_tree_model_get (GTK_TREE_MODEL (cbdata->model), &iter,
STYLE_COLUMN, &style,
-1);
if (style == PANGO_STYLE_ITALIC)
gtk_tree_store_set (GTK_TREE_STORE (cbdata->model), &iter,
STYLE_COLUMN, PANGO_STYLE_NORMAL,
-1);
gtk_tree_path_free (cbdata->path);
g_free (cbdata);
}
static void
run_example_for_row (GtkWidget *window,
GtkTreeModel *model,
GtkTreeIter *iter)
{
PangoStyle style;
GDoDemoFunc func;
GtkWidget *demo;
gtk_tree_model_get (GTK_TREE_MODEL (model),
iter,
FUNC_COLUMN, &func,
STYLE_COLUMN, &style,
-1);
if (func)
{
gtk_tree_store_set (GTK_TREE_STORE (model),
iter,
STYLE_COLUMN, (style == PANGO_STYLE_ITALIC ? PANGO_STYLE_NORMAL : PANGO_STYLE_ITALIC),
-1);
demo = (func) (window);
if (demo != NULL)
{
CallbackData *cbdata;
cbdata = g_new (CallbackData, 1);
cbdata->model = model;
cbdata->path = gtk_tree_model_get_path (model, iter);
if (GTK_IS_WINDOW (demo))
{
gtk_window_set_transient_for (GTK_WINDOW (demo), GTK_WINDOW (window));
gtk_window_set_modal (GTK_WINDOW (demo), TRUE);
}
g_signal_connect (demo, "destroy",
G_CALLBACK (window_closed_cb), cbdata);
}
}
}
static void
activate_run (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
gpointer window)
{
GtkWidget *window = user_data;
GtkTreeSelection *selection;
GtkTreeModel *model;
GtkTreeIter iter;
GtkTreeListRow *row = gtk_single_selection_get_selected_item (selection);
GtkDemo *demo = gtk_tree_list_row_get_item (row);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
if (gtk_tree_selection_get_selected (selection, &model, &iter))
run_example_for_row (window, model, &iter);
gtk_demo_run (demo, window);
}
/* Stupid syntax highlighting.
@@ -219,11 +252,9 @@ static const char *types[] =
"static",
"const ",
"void",
"gint",
" int ",
" char ",
"gchar ",
"gfloat",
"char ",
"float",
"double",
"gint8",
@@ -239,8 +270,6 @@ static const char *types[] =
"gshort",
"gushort",
"gulong",
"gdouble",
"gldouble",
"gpointer",
"NULL",
"GList",
@@ -352,14 +381,14 @@ static const char *control[] =
NULL
};
void
parse_chars (gchar *text,
gchar **end_ptr,
gint *state,
parse_chars (char *text,
char **end_ptr,
int *state,
const char **tag,
gboolean start)
{
gint i;
gchar *next_token;
int i;
char *next_token;
/* Handle comments first */
if (*state == STATE_IN_COMMENT)
@@ -429,7 +458,7 @@ parse_chars (gchar *text,
/* check for string */
if (text[0] == '"')
{
gint maybe_escape = FALSE;
int maybe_escape = FALSE;
*end_ptr = text + 1;
*tag = "string";
@@ -492,9 +521,9 @@ void
fontify (GtkTextBuffer *source_buffer)
{
GtkTextIter start_iter, next_iter, tmp_iter;
gint state;
gchar *text;
gchar *start_ptr, *end_ptr;
int state;
char *text;
char *start_ptr, *end_ptr;
const char *tag;
gtk_text_buffer_create_tag (source_buffer, "source",
@@ -567,10 +596,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;
@@ -610,7 +639,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);
@@ -662,10 +691,10 @@ static struct {
};
static void
add_data_tab (const gchar *demoname)
add_data_tab (const char *demoname)
{
gchar *resource_dir, *resource_name;
gchar **resources;
char *resource_dir, *resource_name;
char **resources;
GtkWidget *widget, *label;
guint i, j;
@@ -709,15 +738,15 @@ add_data_tab (const gchar *demoname)
static void
remove_data_tabs (void)
{
gint i;
int i;
for (i = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook)) - 1; i > 1; i--)
gtk_notebook_remove_page (GTK_NOTEBOOK (notebook), i);
}
void
load_file (const gchar *demoname,
const gchar *filename)
load_file (const char *demoname,
const char *filename)
{
GtkTextBuffer *info_buffer, *source_buffer;
GtkTextIter start, end;
@@ -725,9 +754,9 @@ load_file (const gchar *demoname,
GError *err = NULL;
int state = 0;
gboolean in_para = 0;
gchar **lines;
char **lines;
GBytes *bytes;
gint i;
int i;
if (!g_strcmp0 (current_file, filename))
return;
@@ -767,9 +796,9 @@ load_file (const gchar *demoname,
gtk_text_buffer_get_iter_at_offset (info_buffer, &start, 0);
for (i = 0; lines[i] != NULL; i++)
{
gchar *p;
gchar *q;
gchar *r;
char *p;
char *q;
char *r;
/* Make sure \r is stripped at the end for the poor windows people */
lines[i] = g_strchomp (lines[i]);
@@ -895,124 +924,194 @@ load_file (const gchar *demoname,
}
static void
selection_cb (GtkTreeSelection *selection,
GtkTreeModel *model)
activate_cb (GtkWidget *widget,
guint position,
gpointer window)
{
GtkTreeIter iter;
char *name;
char *filename;
char *title;
GtkTreeListRow *row = g_list_model_get_item (gtk_list_view_get_model (GTK_LIST_VIEW (widget)), position);
GtkDemo *demo = gtk_tree_list_row_get_item (row);
if (! gtk_tree_selection_get_selected (selection, NULL, &iter))
return;
gtk_demo_run (demo, window);
gtk_tree_model_get (model, &iter,
NAME_COLUMN, &name,
TITLE_COLUMN, &title,
FILENAME_COLUMN, &filename,
-1);
if (filename)
load_file (name, filename);
gtk_window_set_title (GTK_WINDOW (toplevel), title);
g_free (name);
g_free (title);
g_free (filename);
g_object_unref (row);
}
static void
populate_model (GtkTreeModel *model)
selection_cb (GtkSingleSelection *sel,
GParamSpec *pspec,
gpointer user_data)
{
Demo *d = gtk_demos;
GtkTreeListRow *row = gtk_single_selection_get_selected_item (sel);
GtkDemo *demo;
/* this code only supports 1 level of children. If we
* want more we probably have to use a recursing function.
*/
while (d->title)
gtk_widget_set_sensitive (GTK_WIDGET (notebook), !!row);
if (!row)
{
Demo *children = d->children;
GtkTreeIter iter;
gtk_window_set_title (GTK_WINDOW (toplevel), "No match");
gtk_tree_store_append (GTK_TREE_STORE (model), &iter, NULL);
return;
}
gtk_tree_store_set (GTK_TREE_STORE (model),
&iter,
NAME_COLUMN, d->name,
TITLE_COLUMN, d->title,
FILENAME_COLUMN, d->filename,
FUNC_COLUMN, d->func,
STYLE_COLUMN, PANGO_STYLE_NORMAL,
-1);
demo = gtk_tree_list_row_get_item (row);
d++;
if (demo->filename)
load_file (demo->name, demo->filename);
if (!children)
gtk_window_set_title (GTK_WINDOW (toplevel), demo->title);
}
static gboolean
filter_demo (GtkDemo *demo)
{
int i;
/* Show only if the name maches every needle */
for (i = 0; search_needle[i]; i++)
{
if (!demo->title)
return FALSE;
if (g_str_match_string (search_needle[i], demo->title, TRUE))
continue;
while (children->title)
return FALSE;
}
return TRUE;
}
static gboolean
demo_filter_by_name (GtkTreeListRow *row,
GtkFilterListModel *model)
{
GListModel *children;
GtkDemo *demo;
guint i, n;
/* Show all items if search is empty */
if (!search_needle || !search_needle[0] || !*search_needle[0])
return TRUE;
g_assert (GTK_IS_TREE_LIST_ROW (row));
g_assert (GTK_IS_FILTER_LIST_MODEL (model));
children = gtk_tree_list_row_get_children (row);
if (children)
{
n = g_list_model_get_n_items (children);
for (i = 0; i < n; i++)
{
GtkTreeIter child_iter;
demo = g_list_model_get_item (children, i);
g_assert (GTK_IS_DEMO (demo));
gtk_tree_store_append (GTK_TREE_STORE (model), &child_iter, &iter);
gtk_tree_store_set (GTK_TREE_STORE (model),
&child_iter,
NAME_COLUMN, children->name,
TITLE_COLUMN, children->title,
FILENAME_COLUMN, children->filename,
FUNC_COLUMN, children->func,
STYLE_COLUMN, PANGO_STYLE_NORMAL,
-1);
children++;
if (filter_demo (demo))
{
g_object_unref (demo);
return TRUE;
}
g_object_unref (demo);
}
}
demo = gtk_tree_list_row_get_item (row);
g_assert (GTK_IS_DEMO (demo));
return filter_demo (demo);
}
static void
startup (GApplication *app)
demo_search_changed_cb (GtkSearchEntry *entry,
GtkFilter *filter)
{
GtkBuilder *builder;
GMenuModel *appmenu;
const char *ids[] = { "appmenu", NULL };
const char *text;
builder = gtk_builder_new ();
gtk_builder_add_objects_from_resource (builder, "/ui/appmenu.ui", ids, NULL);
g_assert (GTK_IS_SEARCH_ENTRY (entry));
g_assert (GTK_IS_FILTER (filter));
appmenu = (GMenuModel *)gtk_builder_get_object (builder, "appmenu");
text = gtk_editable_get_text (GTK_EDITABLE (entry));
gtk_application_set_app_menu (GTK_APPLICATION (app), appmenu);
g_clear_pointer (&search_needle, g_strfreev);
g_object_unref (builder);
if (text && *text)
search_needle = g_strsplit (text, " ", 0);
gtk_filter_changed (filter, GTK_FILTER_CHANGE_DIFFERENT);
}
static GListModel *
create_demo_model (void)
{
GListStore *store = g_list_store_new (GTK_TYPE_DEMO);
DemoData *demo = gtk_demos;
while (demo->title)
{
GtkDemo *d = GTK_DEMO (g_object_new (GTK_TYPE_DEMO, NULL));
DemoData *children = demo->children;
d->name = demo->name;
d->title = demo->title;
d->filename = demo->filename;
d->func = demo->func;
g_list_store_append (store, d);
if (children)
{
d->children_model = G_LIST_MODEL (g_list_store_new (GTK_TYPE_DEMO));
while (children->title)
{
GtkDemo *child = GTK_DEMO (g_object_new (GTK_TYPE_DEMO, NULL));
child->name = children->name;
child->title = children->title;
child->filename = children->filename;
child->func = children->func;
g_list_store_append (G_LIST_STORE (d->children_model), child);
children++;
}
}
demo++;
}
return G_LIST_MODEL (store);
}
static GListModel *
get_child_model (gpointer item,
gpointer user_data)
{
GtkDemo *demo = item;
if (demo->children_model)
return g_object_ref (G_LIST_MODEL (demo->children_model));
return NULL;
}
static void
row_activated_cb (GtkWidget *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *column)
clear_search (GtkSearchBar *bar)
{
GtkTreeIter iter;
GtkWidget *window;
GtkTreeModel *model;
window = GTK_WIDGET (gtk_widget_get_root (tree_view));
model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
gtk_tree_model_get_iter (model, &iter, path);
run_example_for_row (window, model, &iter);
if (!gtk_search_bar_get_search_mode (bar))
{
GtkWidget *entry = gtk_search_bar_get_child (GTK_SEARCH_BAR (bar));
gtk_editable_set_text (GTK_EDITABLE (entry), "");
}
}
static void
activate (GApplication *app)
{
GtkBuilder *builder;
GtkWindow *window;
GtkWidget *widget;
GtkTreeModel *model;
GtkTreeIter iter;
GListModel *listmodel;
GtkTreeListModel *treemodel;
GtkWidget *window, *listview, *search_entry, *search_bar;
GtkFilterListModel *filter_model;
GtkFilter *filter;
static GActionEntry win_entries[] = {
{ "run", activate_run, NULL, NULL, NULL }
@@ -1020,35 +1119,41 @@ activate (GApplication *app)
builder = gtk_builder_new_from_resource ("/ui/main.ui");
window = (GtkWindow *)gtk_builder_get_object (builder, "window");
gtk_application_add_window (GTK_APPLICATION (app), window);
window = (GtkWidget *)gtk_builder_get_object (builder, "window");
gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (window));
g_action_map_add_action_entries (G_ACTION_MAP (window),
win_entries, G_N_ELEMENTS (win_entries),
window);
notebook = (GtkWidget *)gtk_builder_get_object (builder, "notebook");
notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook"));
info_view = (GtkWidget *)gtk_builder_get_object (builder, "info-textview");
source_view = (GtkWidget *)gtk_builder_get_object (builder, "source-textview");
treeview = (GtkWidget *)gtk_builder_get_object (builder, "treeview");
model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
info_view = GTK_WIDGET (gtk_builder_get_object (builder, "info-textview"));
source_view = GTK_WIDGET (gtk_builder_get_object (builder, "source-textview"));
toplevel = GTK_WIDGET (window);
listview = GTK_WIDGET (gtk_builder_get_object (builder, "listview"));
g_signal_connect (listview, "activate", G_CALLBACK (activate_cb), window);
search_bar = GTK_WIDGET (gtk_builder_get_object (builder, "searchbar"));
g_signal_connect (search_bar, "notify::search-mode-enabled", G_CALLBACK (clear_search), NULL);
load_file (gtk_demos[0].name, gtk_demos[0].filename);
listmodel = create_demo_model ();
treemodel = gtk_tree_list_model_new (G_LIST_MODEL (listmodel),
FALSE,
TRUE,
get_child_model,
NULL,
NULL);
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (treemodel), NULL);
filter = gtk_custom_filter_new ((GtkCustomFilterFunc)demo_filter_by_name, filter_model, NULL);
gtk_filter_list_model_set_filter (filter_model, filter);
g_object_unref (filter);
search_entry = GTK_WIDGET (gtk_builder_get_object (builder, "search-entry"));
g_signal_connect (search_entry, "search-changed", G_CALLBACK (demo_search_changed_cb), filter);
populate_model (model);
selection = gtk_single_selection_new (G_LIST_MODEL (filter_model));
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));
g_signal_connect (treeview, "row-activated", G_CALLBACK (row_activated_cb), model);
widget = (GtkWidget *)gtk_builder_get_object (builder, "treeview-selection");
g_signal_connect (widget, "changed", G_CALLBACK (selection_cb), model);
gtk_tree_model_get_iter_first (gtk_tree_view_get_model (GTK_TREE_VIEW (treeview)), &iter);
gtk_tree_selection_select_iter (GTK_TREE_SELECTION (widget), &iter);
gtk_tree_view_collapse_all (GTK_TREE_VIEW (treeview));
gtk_widget_show (GTK_WIDGET (window));
selection_cb (selection, NULL, NULL);
g_object_unref (builder);
}
@@ -1063,7 +1168,7 @@ auto_quit (gpointer data)
static void
list_demos (void)
{
Demo *d, *c;
DemoData *d, *c;
d = gtk_demos;
@@ -1082,15 +1187,15 @@ list_demos (void)
}
}
static gint
static int
command_line (GApplication *app,
GApplicationCommandLine *cmdline)
{
GVariantDict *options;
const gchar *name = NULL;
const char *name = NULL;
gboolean autoquit = FALSE;
gboolean list = FALSE;
Demo *d, *c;
DemoData *d, *c;
GDoDemoFunc func = 0;
GtkWidget *window, *demo;
@@ -1108,11 +1213,11 @@ command_line (GApplication *app,
return 0;
}
window = gtk_application_get_windows (GTK_APPLICATION (app))->data;
if (name == NULL)
goto out;
window = gtk_application_get_windows (GTK_APPLICATION (app))->data;
d = gtk_demos;
while (d->title)
@@ -1141,8 +1246,11 @@ out:
demo = (func) (window);
gtk_window_set_transient_for (GTK_WINDOW (demo), GTK_WINDOW (window));
gtk_window_set_modal (GTK_WINDOW (demo), TRUE);
g_signal_connect_swapped (G_OBJECT (demo), "destroy", G_CALLBACK (g_application_quit), app);
}
else
gtk_widget_show (GTK_WIDGET (window));
if (autoquit)
g_timeout_add_seconds (1, auto_quit, app);
@@ -1153,7 +1261,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 ());
@@ -1187,24 +1295,14 @@ main (int argc, char **argv)
{ "inspector", activate_inspector, NULL, NULL, NULL },
};
struct {
const gchar *action_and_target;
const gchar *accelerators[2];
const char *action_and_target;
const char *accelerators[2];
} accels[] = {
{ "app.about", { "F1", NULL } },
{ "app.quit", { "<Control>q", NULL } },
};
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),
@@ -1219,7 +1317,6 @@ main (int argc, char **argv)
g_application_add_main_option (G_APPLICATION (app), "list", 0, 0, G_OPTION_ARG_NONE, "List examples", NULL);
g_application_add_main_option (G_APPLICATION (app), "autoquit", 0, 0, G_OPTION_ARG_NONE, "Quit after a delay", NULL);
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, "handle-local-options", G_CALLBACK (local_options), NULL);

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"/>
@@ -33,7 +24,6 @@
<property name="default-height">600</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="headerbar">
<property name="show-title-buttons">1</property>
<child>
<object class="GtkButton">
<property name="valign">center</property>
@@ -65,30 +55,29 @@
<property name="hscrollbar-policy">never</property>
<property name="min-content-width">150</property>
<child>
<object class="GtkTreeView" id="treeview">
<property name="model">treestore</property>
<property name="headers-visible">0</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection">
<property name="mode">browse</property>
</object>
</child>
<object class="GtkBox">
<property name="width-request">220</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkTreeViewColumn">
<object class="GtkSearchBar" id="searchbar">
<property name="key-capture-widget">window</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="style">4</attribute>
<attribute name="text">1</attribute>
</attributes>
</child>
<child>
<object class="GtkCellRendererText">
<property name="text"> </property>
</object>
<object class="GtkSearchEntry" id="search-entry"/>
</child>
</object>
</child>
<child>
<object class="GtkListView" id="listview">
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="resource">/ui/main-listitem.ui</property>
</object>
</property>
</object>
</child>
</object>
</child>
</object>

View File

@@ -21,7 +21,7 @@ source_toggled (GtkToggleButton *button)
{
GtkTextBuffer *buffer;
GtkTextIter start, end;
gchar *markup;
char *markup;
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view2));
gtk_text_buffer_get_bounds (buffer, &start, &end);
@@ -50,7 +50,7 @@ do_markup (GtkWidget *do_widget)
GtkTextBuffer *buffer;
GtkTextIter iter;
GBytes *bytes;
const gchar *markup;
const char *markup;
GtkWidget *header;
GtkWidget *show_source;
@@ -69,7 +69,6 @@ do_markup (GtkWidget *do_widget)
g_signal_connect (show_source, "toggled", G_CALLBACK (source_toggled), stack);
header = gtk_header_bar_new ();
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE);
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), show_source);
gtk_window_set_titlebar (GTK_WINDOW (window), header);
@@ -81,7 +80,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 +93,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);
@@ -103,7 +102,7 @@ do_markup (GtkWidget *do_widget)
gtk_stack_add_named (GTK_STACK (stack), sw, "source");
bytes = g_resources_lookup_data ("/markup/markup.txt", 0, NULL);
markup = (const gchar *)g_bytes_get_data (bytes, NULL);
markup = (const char *)g_bytes_get_data (bytes, NULL);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
gtk_text_buffer_get_start_iter (buffer, &iter);

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

@@ -1,38 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<menu id="appmenu">
<section>
<item>
<attribute name="label" translatable="yes">_New</attribute>
<attribute name="action">app.new</attribute>
<attribute name="accel">&lt;Control&gt;n</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Open</attribute>
<attribute name="action">app.open</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Save</attribute>
<attribute name="action">app.save</attribute>
<attribute name="accel">&lt;Control&gt;s</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Save _As...</attribute>
<attribute name="action">app.save-as</attribute>
<attribute name="accel">&lt;Control&gt;s</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">_Quit</attribute>
<attribute name="action">app.quit</attribute>
<attribute name="accel">&lt;Control&gt;q</attribute>
</item>
</section>
</menu>
<menu id="menubar">
<submenu>
<attribute name="label" translatable="yes">_Preferences</attribute>
<attribute name="label" translatable="yes">_Application</attribute>
<section>
<item>
<attribute name="label" translatable="yes">_New</attribute>
<attribute name="action">app.new</attribute>
<attribute name="accel">&lt;Control&gt;n</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Open</attribute>
<attribute name="action">app.open</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Save</attribute>
<attribute name="action">app.save</attribute>
<attribute name="accel">&lt;Control&gt;s</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Save _As...</attribute>
<attribute name="action">app.save-as</attribute>
<attribute name="accel">&lt;Control&gt;s</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">_Quit</attribute>
<attribute name="action">app.quit</attribute>
<attribute name="accel">&lt;Control&gt;q</attribute>
</item>
</section>
</submenu>
<submenu>
<attribute name="label" translatable="yes">_File</attribute>
<section>
<item>
<attribute name="label" translatable="yes">_Prefer Dark Theme</attribute>

View File

@@ -18,6 +18,7 @@ demos = files([
'cursors.c',
'dialog.c',
'drawingarea.c',
'dropdown.c',
'dnd.c',
'editable_cells.c',
'entry_completion.c',
@@ -41,6 +42,14 @@ demos = files([
'listbox.c',
'flowbox.c',
'list_store.c',
'listview_applauncher.c',
'listview_clocks.c',
'listview_colors.c',
'listview_filebrowser.c',
'listview_minesweeper.c',
'listview_settings.c',
'listview_weather.c',
'listview_words.c',
'markup.c',
'modelbutton.c',
'overlay.c',
@@ -95,7 +104,7 @@ extra_demo_sources = files(['main.c',
if harfbuzz_dep.found() and pangoft_dep.found()
demos += files('font_features.c')
extra_demo_sources += files(['script-names.c', 'language-names.c'])
gtkdemo_deps += [ harfbuzz_dep, ]
gtkdemo_deps += [ harfbuzz_dep, epoxy_dep ]
endif
if os_unix

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

@@ -4,9 +4,7 @@
<property name="title" translatable="yes">Model Button</property>
<property name="resizable">0</property>
<child type="titlebar">
<object class="GtkHeaderBar">
<property name="show-title-buttons">1</property>
</object>
<object class="GtkHeaderBar"/>
</child>
<child>
<object class="GtkBox">

View File

@@ -12,9 +12,9 @@ static void
margin_changed (GtkAdjustment *adjustment,
GtkTextView *text)
{
gint value;
int value;
value = (gint)gtk_adjustment_get_value (adjustment);
value = (int)gtk_adjustment_get_value (adjustment);
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (text), value);
g_object_set (tag, "pixels-above-lines", value, NULL);
}
@@ -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

@@ -9,7 +9,7 @@
#include <gtk/gtkunixprint.h>
static void
done_cb (GtkDialog *dialog, gint response, gpointer data)
done_cb (GtkDialog *dialog, int response, gpointer data)
{
gtk_window_destroy (GTK_WINDOW (dialog));
}

View File

@@ -20,7 +20,7 @@ typedef struct
cairo_t *cr;
GdkRGBA draw_color;
GtkPadController *pad_controller;
gdouble brush_size;
double brush_size;
} DrawingArea;
typedef struct
@@ -38,7 +38,7 @@ static GtkPadActionEntry pad_actions[] = {
{ GTK_PAD_ACTION_STRIP, -1, -1, N_("Brush size"), "pad.brush_size" },
};
static const gchar *pad_colors[] = {
static const char *pad_colors[] = {
"black",
"pink",
"green",
@@ -55,8 +55,8 @@ static void drawing_area_set_color (DrawingArea *area,
static void
drawing_area_ensure_surface (DrawingArea *area,
gint width,
gint height)
int width,
int height)
{
if (!area->surface ||
cairo_image_surface_get_width (area->surface) != width ||
@@ -154,7 +154,7 @@ on_pad_button_activate (GSimpleAction *action,
GVariant *parameter,
DrawingArea *area)
{
const gchar *color = g_object_get_data (G_OBJECT (action), "color");
const char *color = g_object_get_data (G_OBJECT (action), "color");
GdkRGBA rgba;
gdk_rgba_parse (&rgba, color);
@@ -166,7 +166,7 @@ on_pad_knob_change (GSimpleAction *action,
GVariant *parameter,
DrawingArea *area)
{
gdouble value = g_variant_get_double (parameter);
double value = g_variant_get_double (parameter);
area->brush_size = value;
}
@@ -195,7 +195,7 @@ drawing_area_root (GtkWidget *widget)
GSimpleActionGroup *action_group;
GSimpleAction *action;
GtkWidget *toplevel;
gint i;
int i;
GTK_WIDGET_CLASS (drawing_area_parent_class)->root (widget);
@@ -255,9 +255,9 @@ drawing_area_class_init (DrawingAreaClass *klass)
static void
drawing_area_apply_stroke (DrawingArea *area,
GdkDeviceTool *tool,
gdouble x,
gdouble y,
gdouble pressure)
double x,
double y,
double pressure)
{
if (gdk_device_tool_get_tool_type (tool) == GDK_DEVICE_TOOL_TYPE_ERASER)
{
@@ -281,8 +281,8 @@ drawing_area_apply_stroke (DrawingArea *area,
static void
stylus_gesture_down (GtkGestureStylus *gesture,
gdouble x,
gdouble y,
double x,
double y,
DrawingArea *area)
{
cairo_new_path (area->cr);
@@ -290,13 +290,13 @@ stylus_gesture_down (GtkGestureStylus *gesture,
static void
stylus_gesture_motion (GtkGestureStylus *gesture,
gdouble x,
gdouble y,
double x,
double y,
DrawingArea *area)
{
GdkTimeCoord *backlog;
GdkDeviceTool *tool;
gdouble pressure;
double pressure;
guint n_items;
tool = gtk_gesture_stylus_get_device_tool (gesture);
@@ -392,7 +392,6 @@ do_paint (GtkWidget *toplevel)
gtk_window_set_child (GTK_WINDOW (window), draw_area);
headerbar = gtk_header_bar_new ();
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (headerbar), TRUE);
colorbutton = gtk_color_button_new ();
g_signal_connect (colorbutton, "color-set",

View File

@@ -218,7 +218,7 @@ gtk_nuclear_media_stream_seek (GtkMediaStream *stream,
gtk_media_stream_seek_success (stream);
/* We also have to update our timestamp and tell the
* paintable interface abbout the seek
* paintable interface about the seek
*/
gtk_media_stream_update (stream, nuclear->progress);
gdk_paintable_invalidate_contents (GDK_PAINTABLE (nuclear));
@@ -263,7 +263,7 @@ gtk_nuclear_media_stream_init (GtkNuclearMediaStream *nuclear)
/* This time, we don't have to add a timer here, because media
* streams start paused.
*
* However, media streams need to tell GTK once they are intialized,
* However, media streams need to tell GTK once they are initialized,
* so we do that here.
*/
gtk_media_stream_prepared (GTK_MEDIA_STREAM (nuclear),

View File

@@ -47,9 +47,9 @@ toggle_shrink (GtkWidget *widget,
static GtkWidget *
create_pane_options (GtkPaned *paned,
const gchar *frame_label,
const gchar *label1,
const gchar *label2)
const char *frame_label,
const char *label1,
const char *label2)
{
GtkWidget *child1, *child2;
GtkWidget *frame;

View File

@@ -11,6 +11,7 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
static GtkWidget *entry;
static GtkWidget *entry2;
static GtkWidget *button;
@@ -27,6 +28,13 @@ update_button (GObject *object,
text[0] != '\0' && g_str_equal (text, text2));
}
static void
button_pressed (GtkButton *widget,
GtkWidget *window)
{
gtk_window_destroy (GTK_WINDOW (window));
}
GtkWidget *
do_password_entry (GtkWidget *do_widget)
{
@@ -74,7 +82,7 @@ do_password_entry (GtkWidget *do_widget)
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);
g_signal_connect (button, "clicked", G_CALLBACK (button_pressed), window);
gtk_widget_set_sensitive (button, FALSE);
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);

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