Commit Graph

34150 Commits

Author SHA1 Message Date
Alexander Larsson
8f1253ad26 GtkIconPaintable: Add properties for file, icon-name and is-symbolic 2020-02-10 13:17:05 +01:00
Alexander Larsson
904eecd1ed icon paintable: Replace get_filename and get_resource_path with get_file()
This returns a GFile which can represent both the above.
2020-02-10 12:33:17 +01:00
Alexander Larsson
344ad65031 Rename GTK_ICON_LOOKUP_LOAD_IN_THREAD to GTK_ICON_LOOKUP_PRELOAD 2020-02-10 11:43:47 +01:00
Alexander Larsson
14b3b684ef icontheme: Always return some icon name in get_icon_name() for lookup results
If you called gtk_icon_theme_lookup(), then always return some useful
icon name from gtk_icon_paintable_get_icon_name(), even if we picked
an unthemed icon.

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

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

Over the years the filechooser code has changed so that it now would do
this by default, yet the hack had been retained.
2020-02-09 16:54:38 -05:00
Benjamin Otte
fce37b137d gdk: Make gdk_keyval_name() return a const char
The string is const, so return it like that.
2020-02-09 16:50:22 -05:00
Matthias Clasen
998384aa08 Remove unused include 2020-02-09 16:50:22 -05:00
Emmanuele Bassi
327441fa3e cssprovider: Remove unused include 2020-02-09 16:50:22 -05:00
Matthias Clasen
b927609e21 Remove gtk_propagate_event from public API
This is not a function that can be safely called
outside of GTK.
2020-02-09 11:00:53 -05:00
Matthias Clasen
688f8bf085 Remove gtk_main_do_event from public API 2020-02-09 10:55:56 -05:00
Matthias Clasen
057f41532b Remove gtk_main_do_event from the docs 2020-02-09 10:55:37 -05:00
Matthias Clasen
c1970009ff docs: Remove more mentions of gtk_main_do_event 2020-02-09 10:45:33 -05:00
Matthias Clasen
c4b16f7424 css: Add a comment
All the other color values have this comment,
best to be consistent.
2020-02-09 10:23:27 -05:00
Matthias Clasen
cffff36436 Merge branch 'wip/baedert/remove-outline-properties' into 'master'
css: Remove outline border radius properties

Closes #2414

See merge request GNOME/gtk!1402
2020-02-09 15:03:44 +00:00
Matthias Clasen
f240bcbbc4 emojichooser: Fix the docs
Make the emojichooser show up in the docs.
2020-02-08 19:21:57 -05:00
Matthias Clasen
621a427627 Fix the build with -Dgtk_doc=true
We need to export the emoji chooser symbols to
really make it public api.
2020-02-08 19:04:19 -05:00
Timm Bäder
01ba11fc71 css: Remove outline border radius properties
These are always set to the same value as the corresponding border
radius properties. They are also non-standard, so remove them and
replace them with the border radius properties everywhere.

Fixes #2414
2020-02-08 20:43:16 +01:00
Matthias Clasen
2f17ab3ce7 Avoid mime sniffing where possible
When we are loading symbolic pngs or svgs, we know
that we need to the png or svg loader, so there is
no need to go through (surprisingly expensive) mime
sniffing to find the right loader.
2020-02-08 10:22:54 -05:00
Matthias Clasen
1f74695758 Adwaita: Fix selection in vertical spin buttons
This was broken by more specific selectors.
2020-02-07 15:43:07 -05:00
Matthias Clasen
e3afb2fec8 label: Don't use gtk_widget_peek_style_context
We may just not have a style context. And we can just
as well go directly to the css styles.
2020-02-07 13:16:45 -05:00
Timm Bäder
d3857f8bd3 window: Move variable initialziation just before usage 2020-02-07 13:16:45 -05:00
Timm Bäder
655711fef2 Rename gtk_widget{get,set,has}_style_class to _css_class
We want to use css instead of style everywhere now.
2020-02-07 13:16:45 -05:00
Timm Bäder
69fa15981c treepopover: Fix header guard 2020-02-07 13:16:32 -05:00
Timm Bäder
2a46d5960d box: Move vfunc implementations before class_init
Just like we do everywhere else. This way we can also get rid of all the
prototypes.
2020-02-07 13:16:32 -05:00
Timm Bäder
b9b5cae6d2 calendar: Remove day-selected-double-click signal
It doesn't really make sense to treat double clicks here different than
single clicks (and is bad UX), and it also breaks switching months by
quickly trying to single-click the last/first days in the calendar.
2020-02-07 13:16:32 -05:00
Timm Bäder
3249756648 calendar: Remove an unused enum 2020-02-07 13:16:32 -05:00
Timm Bäder
8ef9009bde calendar: Remove month-changed signal
Listen to notify::month instead.
2020-02-07 13:16:32 -05:00
Timm Bäder
093eac9441 calendar: Keep a GDateTime around
Instead of a year/month/day triple.
2020-02-07 13:16:32 -05:00
Timm Bäder
93c6f2256f calendar: Return a GDateTime from get_date() 2020-02-07 13:16:32 -05:00
Timm Bäder
1151da5cf3 calendar: Use GDateTime to select days 2020-02-07 13:16:32 -05:00
Timm Bäder
a6f9052cf1 calendar: Use widgets for everything 2020-02-07 13:16:32 -05:00
Timm Bäder
a437162f6d calendar: Try to avoid changing size when changing the year 2020-02-07 13:16:32 -05:00
Timm Bäder
9ecd448682 calendar: Remove spinning code
This is dead code
2020-02-07 13:16:32 -05:00
Timm Bäder
74cb1ca2f5 calendar: Add accessors for display properties
Instead of having a display flags enum and bitfield, just add proper
accessors for the properties, which is what we do everywhere else.
2020-02-07 13:16:32 -05:00
Timm Bäder
4cceba06bc calendar: Remove details
This is an unused feature that's way too complicated for a default
calendar widget and complicates the implementation a lot. Since we want
to eventually replace this with actual widgets, remove the details
support now.
2020-02-07 13:16:32 -05:00
Timm Bäder
ab84b17c1a calendar: Fix an uninitialized value
Values pased to gtk_widget_measure must be initialized to 0. This failed
if the header widget of the calendar was invisible.
2020-02-07 13:16:32 -05:00
Timm Bäder
7fd06cacbd Adwaita: Fix levelbar styling
The block nodes are inside a trough node.
2020-02-07 13:16:32 -05:00
Timm Bäder
b471158e38 {box,grid}layout: Access border spacing directly
Instead of going through the style context
2020-02-07 13:16:32 -05:00
Timm Bäder
4cfac3b91c snapshot: Remove new_with_parent
Unneeded now that we have push_collect()/pop_collect()
2020-02-07 13:16:32 -05:00
Timm Bäder
17ddae5bf9 textlayout: Use gtk_snapshot_{push,pop}_collect() 2020-02-07 13:16:32 -05:00
Timm Bäder
47b8facca4 widget: Use gtk_snapshot_{push,pop})_collect
So we avoid allocating a new snapshot just for that.
2020-02-07 13:16:32 -05:00
Timm Bäder
bf8fb2c1a5 snapshot: Add _push_collect() and _pop_collect()
These will replace the previous gtk_snapshot_new_with_parent(), which
allocated an entirely new GObject just to push()/pop() some state. This
is already a problem but will be more important in the future as we
start using this more.
2020-02-07 13:16:32 -05:00
Timm Bäder
b7ee2cbc28 Start using GtkWidget's new style class API 2020-02-07 13:16:32 -05:00
Timm Bäder
b1d64a6b3a renderborder: Make simple border case more obvious
When reaching this point, it is impossible that all border styles are
HIDDEN or NONE, but up to 3 of them can still be that style. In any
case, the "none or solid" border style is the most common on there is,
so try to make this simpler here by just appending a border node
directly instead of going through the snapshot_border path.
2020-02-07 13:15:59 -05:00
Timm Bäder
60095ade9b Move GTK_BORDER_STYLE_HIDDEN before GTK_BORDER_STYLE_SOLID
The simple case when drawing border is "solid or nothing", which we can
now check for as simple as "style <= GTK_BORDER_STYE_SOLID".
2020-02-07 13:15:59 -05:00
Timm Bäder
64c6229f54 searchbar: Use proper getter in _get_property()
Instead of retuning a seemingly random boolean, just use
gtk_search_bar_get_search_mode().
2020-02-07 13:15:59 -05:00
Timm Bäder
60be37d63a searchbar: Use g_object_notify_by_pspec
We already keep the pspecs around, so use them.
2020-02-07 13:15:59 -05:00
Timm Bäder
e044656d99 progressbar: Remove a few unneeded queue_resize() calls
This will happen automatically when adding style classes, setting the
label text, etc.
2020-02-07 13:15:59 -05:00
Timm Bäder
c0fef36692 Window: inline function into only caller 2020-02-07 13:15:59 -05:00
Timm Bäder
a67bd7a04e widget: Fix a from_string/try_string mixup 2020-02-07 13:15:59 -05:00
Timm Bäder
e152d25ac0 widget: Speed up verify_invariants()
Hide the expensive GTK_IS_ROOT() checks behind the cheaper realized,
mapped, etc. checks. This way we only check for the widget being a root
if the invariant does not hold.

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

This causes us to load most icons early on, in parallel instead of
during the first snapshot.
2020-02-07 17:26:22 +01:00
Alexander Larsson
e27413a9ed icon-theme: Add GTK_ICON_LOOKUP_LOAD_IN_THREAD flag
This causes lookup to trigger a thread that loads the icon texture.
2020-02-07 17:25:18 +01:00
Benjamin Otte
44e153d8a8 GtkToolbar: remove 2020-02-07 14:08:26 +01:00
Benjamin Otte
e00030dff2 css: Remove .primary-toolbar
It's not used anywhere anymore.
2020-02-07 14:08:08 +01:00
Benjamin Otte
9cccb944ef css: Remove .inline-toolbar
It's not used anywhere anymore.
2020-02-07 14:08:08 +01:00
Benjamin Otte
3d9e622fda print: Don't use a toolbar in the custom paper dialog
Use a regular linked box instead.
2020-02-07 14:08:08 +01:00
Benjamin Otte
645af0917c cssnode: Remove leftover vfunc 2020-02-07 14:06:20 +01:00
Matthias Clasen
c247e7680b Remove accidentally added files 2020-02-07 08:05:45 -05:00
Alexander Larsson
bdbafe63f9 icontheme: Optimize memory use and lookup speed by internalizing icon names
Instead of having the IconTheme have a hashtable that owns
individual strings and then IconThemeDirSize have a similar
hash (but with the strings owned by the other hash), we
have a consecutive memory chunks where we store the icon names
and then the hashtable has pointers into this.

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

Closes #13

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

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

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/13
2020-02-07 01:02:47 +01:00
Carlos Garnacho
56dc99a9fb gtkroot: Make enum a typedef
Seems a typo, and prevents building as GtkRootProperties is deemed
to be defined multiple times.
2020-02-07 01:00:52 +01:00
Matthias Clasen
769dae2c71 infobar: Implement forall
As a container, that is what you have to do.
2020-02-06 18:04:36 -05:00
Matthias Clasen
bc682bef74 colorchooser: Use a composite accessible
This makes the content show up in the a11y tree again.
2020-02-06 16:54:59 -05:00
Matthias Clasen
145ccfe1c4 stackswitcher: Use a composite accessible
This makes the buttons show up in the a11y tree again.
2020-02-06 16:54:59 -05:00
Matthias Clasen
d01070d472 a11y: Add an accessible for widgets with children
We've started to turns containers into widgets which
just happen to have children, and some of these need
to be exposed to the a11y stack.

This adds a very minimal implementation, it does not
currently emit change notification when children are
added or removed.
2020-02-06 16:54:59 -05:00
Matthias Clasen
b3f5243aeb a11y: Report children of widgets
We want children of composite accessibles to be
reported.
2020-02-06 16:54:59 -05:00
Alexander Larsson
a772bf7517 Add gtk_icon_paintable_get_resource_path()
Also, return NULL from gtk_icon_paintable_get_filename() if the path
is really a resource path.
2020-02-06 17:47:57 +01:00
Alexander Larsson
57ecb2829a Add gtk_icon_paintable_get_icon_name()
This allows you to see which icon was actually chosen.
2020-02-06 17:47:57 +01:00
Alexander Larsson
d45d604df1 Remove gtk_icon_paintable_download_texture() public API
This allows us do do what we want internally, and anyway it didn't
really do what you'd expect anymore now that we do resizing during
rendering.
2020-02-06 17:47:57 +01:00
Alexander Larsson
6317fd3529 Replace last users of gtk_icon_paintable_download_texture ()
These now render the paintable to a cairo surface and convert that
to a texture. This is sort of a hack, but its only used in two
special cases internally and in two hacky test apps.
2020-02-06 17:47:56 +01:00
Alexander Larsson
8282698201 textview: Use paintables instead of textures, and fix the support
This changes gtk_text_buffer_insert_texture() to
gtk_text_buffer_insert_paintable() which is strictly more useful
(as textures are paintables). It also fixes the code to actually
support drawing the paintables (as well as tracking changes
to the paintables.
2020-02-06 17:47:56 +01:00
Alexander Larsson
fcc3c12919 gtk_css_style_snapshot_icon_paintable: Fix uninitialized memory access
We were reading the foreground color alpha even when we didn't read it.
2020-02-06 17:47:56 +01:00
Alexander Larsson
7c73f2fb02 GskPango: Allow specifying a custom shape snapshot handler
We will need this for GtkTextView to render the textures in it.
2020-02-06 17:47:56 +01:00
Alexander Larsson
6ff9f2198d GtkBuilder: Directly load the fallback missing image
No need for all this complexity with the icon theme, especially when
its now a lot more work to get the texture back. We can just load
the pixbuf.
2020-02-06 17:47:56 +01:00
Alexander Larsson
1c253f5dfa icontheme: Move IMAGE_MISSING_RESOURCE_PATH to (private) header
This way other code can use this resource too for fallbacks, avoing
having to go through the icon theme.
2020-02-06 17:47:56 +01:00
Alexander Larsson
a0533923fb icontheme: Handle GEmblemIcon in lookup_by_gicon() 2020-02-06 17:47:52 +01:00
Matthias Clasen
5c594fc46a Merge branch 'WindowsPrintDriverPreferencesMaster' into 'master'
Fixed bug that prevented GTK from storing printer driver preferences in the…

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

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

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

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

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

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

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

See merge request GNOME/gtk!1393
2020-02-06 06:38:17 +00:00
Matthias Clasen
9746b728ca Merge branch 'public-emojichooser' into 'master'
emojichooser: Make public

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

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

To be fair, it was entirely useless without widget paths already.
2020-02-05 04:03:43 +01:00
Benjamin Otte
db9730b734 stylecontext: Remove the "changed" signal
Instead, always go directly to the GtkWidget::css_changed() call.
2020-02-05 04:03:43 +01:00
Benjamin Otte
546a748cd8 widget: Replace style-updated signal with css_changed vfunc
1. Rename the thing
2. Turn it from a signal to a vfunc
3. Pass the GtkCssStyleChange to it

We don't export any public API about the GtkCssStyleChange yet, it's
just a boring opaque struct.
2020-02-05 02:46:13 +01:00
Benjamin Otte
8722837e67 pathbar: Remove unneeded code
The icons here are GIcons, they don't depend on the theme.
2020-02-05 00:18:41 +01:00
Benjamin Otte
3177ac4270 cssnode: Remove redundant check
We assert that cssnode->parent is NULL, no need to check it again.
2020-02-04 23:24:50 +01:00
Timm Bäder
903af75fa1 widget: Skip not-drawable widgets in snapshot_child
Otherwise we transform the snapshot just to not do anything.
2020-02-04 17:53:15 +01:00
Matthias Clasen
6640881711 maplistmodel: Add an example to the docs 2020-02-04 17:51:01 +01:00
Matthias Clasen
3bb8b56ab3 treelistmodel: Small documentation tweaks 2020-02-04 17:51:01 +01:00
Benjamin Otte
a1635719fc widgetfocus: Remove unnecessary check
Mapped widgets are always realized.
2020-02-04 17:51:01 +01:00
Benjamin Otte
3cb150abbe widget: Remove _gtk_widget_is_drawable()
Use _gtk_widget_get_mapped() instead.

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

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

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

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

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

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

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

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

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

Use the correct version instead:
  gtk_icon_theme_get_for_display (gtk_widget_get_display ())
2020-02-04 16:41:36 +01:00
Matthias Clasen
b8ffe5b245 css: Fix the initial values optimization
Fix up the index computation. We have duplicate entries
in the type enum, so to go from one of the 'initial' types
to it corresponding type you subtract one, but to find
the size array entry for a type, you divide by 2.
2020-02-04 12:19:23 +01:00
Alexander Larsson
046de4ccbf icon-theme: Only have one copy of the icon flags enum
It turns out with the icon cache now using the virtual SYMBOLIC_PNG_SUFFIX
flag the two enums are now identical, so lets just use one of them, the
one GtkIconCache (so we move it to the header).
2020-02-04 09:35:20 +01:00
Matthias Clasen
ef7172dc1e emojichooser: Make public
This is a useful widget to have, and it has minimal api.

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

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

if best_directory
  return icon from best_directory

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

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

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

This brings down the time of the initial css validation from 20msec to 15msec for
me when running icon-factory.
2020-02-03 12:49:26 +01:00
Alexander Larsson
0a8d7603ea icon-cache: Add new function to list all the icons in a directory
This lists the icons in a particular director, with their flags in a
hashtable. We also convert from "icon.symbolic" + SUFFIX_PNG to
"icon" + SUFFIX_SYMBOLIC_PNG.
2020-02-03 12:49:26 +01:00
Rico Tzschichholz
4ab12ab755 Remove last GtkWidgetPath reference
See 49b47c9133
2020-02-03 10:51:50 +01:00
Matthias Clasen
621120d1d3 css: Fix an oversight in style change computation
Take the 'color == NULL means currentColor' trick into account
when computing the changes between two styles.
2020-02-02 16:41:14 +01:00
Matthias Clasen
27223f7956 Merge branch 'initial-style' into 'master'
Make it easy to recognize initial style values

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

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

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

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

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

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

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

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

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

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

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

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