Commit Graph

36262 Commits

Author SHA1 Message Date
Matthias Clasen
43000abeff listview: Revise constructors
Make both gtk_list_view_new and gtk_list_view_new_with_factory
take a model as first argument, and make all arguments
allow-none and transfer full.

Update all callers.
2020-07-26 18:27:23 -04:00
Matthias Clasen
72bb7fc701 selectionfiltermodel: Make constructor allow-none
We don't pay attention to item-type anymore, so
drop the item-type property and the _for_item_type()
constructor, and allow passing NULL to the regular
constructor.

We don't make this constructor transfer-full, since
the selection filter model is not a wrapping model
like the others. It is more like fork than a wrap.
2020-07-26 18:04:40 -04:00
Matthias Clasen
cdc263f796 multiselection: Make constructor transfer full
This is for consistency with other wrapping list constructors.
We want them all to be transfer full, allow-none.

Also make the constructor return GtkMultiSelection *.

Update all callers.
2020-07-26 18:04:40 -04:00
Matthias Clasen
ccb9dcc86b singleselection: 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 18:04:40 -04:00
Matthias Clasen
68d6671413 noselection: 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 18:04:40 -04:00
Matthias Clasen
dd1c0c0b22 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 18:04:40 -04:00
Matthias Clasen
a46cfd3ff4 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 18:04:40 -04:00
Matthias Clasen
706d464ae6 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 18:04:40 -04:00
Matthias Clasen
b6d9f3facb 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 18:04:40 -04:00
Matthias Clasen
06c6d62629 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 18:02:51 -04:00
Matthias Clasen
32b8fe40bb 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 18:02:51 -04:00
Matthias Clasen
1e8be87026 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 18:02:44 -04: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
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
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
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
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
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
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
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
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
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
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
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
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