Commit Graph

34150 Commits

Author SHA1 Message Date
Matthias Clasen
1b2289ad9b Stop using gtk_get_event_target
This is just a thin wrapper around gdk_event_get_target,
so use that directly.
2020-02-21 00:47:53 -05:00
Matthias Clasen
dd251d85c4 Pass translated coordinates outside the event
We want to make events readonly, so stop translating
their coordinates and instead pass the translated
coordinates separately, when propagating events.
2020-02-21 00:47:53 -05:00
Matthias Clasen
cd2b58574d Drop GDK_NOTHING
Events of type GDK_NOTHING are good for nothing.
2020-02-21 00:47:53 -05:00
Matthias Clasen
c343031a0e Stop using g_object_ref/unref on events
Use gdk_event_ref/unref instead of g_object_ref/unref.
Events will stop being object soon.
2020-02-21 00:47:53 -05:00
Matthias Clasen
9a1497f582 events: Drop GDK_DESTROY
No backend is emitting GDK_DESTROY events anymore, so no
need to carry this around.
2020-02-21 00:40:52 -05:00
Matthias Clasen
7db8be93f4 gtk: Stop handling GDK_DESTROY differently from GDK_DELETE
We don't have child windows anymore, so there is no difference.
2020-02-21 00:40:52 -05:00
Matthias Clasen
c4a2cf03b2 textview: Stop using gdk_event_copy 2020-02-21 00:40:52 -05:00
Matthias Clasen
495de0b78b main: Use constructors instead of gdk_event_copy + rewriting 2020-02-21 00:40:52 -05:00
Matthias Clasen
dac61b3cce imcontextsimple: Use event constructors 2020-02-21 00:40:52 -05:00
Matthias Clasen
080e5de786 widget: Port emulation code to constructors
Use the new event constructors when generating events
for emulating presses.
2020-02-21 00:40:52 -05:00
Matthias Clasen
374c9dd880 window: Use event constructors 2020-02-21 00:40:52 -05:00
Matthias Clasen
a5f58e8d28 main: Use event constructors
At the same time, stop setting child_surface in
crossing events. Nothing in GTK looks at it.
2020-02-21 00:40:52 -05:00
Timm Bäder
018870643a scale: Remove useless extra local variable 2020-02-20 10:30:14 +01:00
Timm Bäder
aa53fef39c scale: Remove unused member 2020-02-20 10:23:09 +01:00
Timm Bäder
faddbb18d3 emojichooser: Add style class to emoji toolbar
Closes #1013
2020-02-20 10:23:09 +01:00
Timm Bäder
f14978c68f filechooserwidget: Fold function into only caller 2020-02-20 10:23:09 +01:00
Timm Bäder
c0de02520c filechooserwidget: Use a proper GtkPopoverMenu
Instead of a fake one where we add .menu to a normal popover. This makes
the menu look like other context menus.
2020-02-20 10:23:09 +01:00
Timm Bäder
b58f9e2aa2 filechoosererrorstack: Set a layout manager
Otherwise it doesn't know what to do with its child widget.
2020-02-20 10:23:09 +01:00
Timm Bäder
b8a752c751 filechooserwidget: Allow typing a location in recent mode
This is triggered by typing / or hitting Ctrl+L. Since we don't have a
visual indicator for this mode right now anyway, the reason for not
allowing it in recent mode cited in the comment just above the
early-exit is irrelevant.

Closes #2178
2020-02-20 10:23:09 +01:00
Timm Bäder
194039c749 filechooserwidget: Remove unused constants 2020-02-20 10:23:09 +01:00
Timm Bäder
64d0f848bc text: Remove gtk_text_get_im_context()
Unused.
2020-02-20 10:23:09 +01:00
Timm Bäder
e18a159f16 spinbutton: Remove manual queue_draw() calls
Everything is automatically redrawn when changing the value, etc.
2020-02-20 10:23:09 +01:00
Timm Bäder
a1bc3ae2c8 popvermenu: Clarify css node docs
We add the .menu css class to the popover main node, not its contents
node.
2020-02-20 10:23:09 +01:00
Timm Bäder
2ad6c045b4 aboutdialog: Clarify docs and fix preconditions 2020-02-20 10:23:09 +01:00
Timm Bäder
ec6d5839bd modelbutton: Un-select on mouse leave
This brings us closer to the old GtkMenuItem behavior and also makes
more sense.
2020-02-20 10:23:09 +01:00
Timm Bäder
2bf9a5bd29 aboutdialog: Replace visited_links GList with GPtrArray 2020-02-20 10:23:09 +01:00
Timm Bäder
b5d4815eb7 aboutdialog: Use new GtkStackPage API 2020-02-20 10:23:09 +01:00
Timm Bäder
188f00e05a stack: Add GtkStackPage:visible accessors 2020-02-20 10:23:09 +01:00
Benjamin Otte
9660ae5556 Merge branch 'wip/xdg-popup-async-relayout' into 'master'
Synchronous popup layout

See merge request GNOME/gtk!1241
2020-02-19 18:57:14 +00:00
Jonas Ådahl
ca71119a40 gdk/surface: Replace move_to_rect() with GdkPopupLayout based API
Replace the gdk_surface_move_to_rect() API with a new GdkSurface
method called gdk_surface_present_popup() taking a new GdkPopupLayout
object describing how they should be laid out on screen.

The layout properties provided are the same as the ones used with
gdk_surface_move_to_rect(), except they are now set up using
GdkPopupLayout.

Calling gdk_surface_present_popup() will either show the popup at the
position described using the popup layout object and a new unconstrained
size, or reposition it accordingly.

In some situations, such as when a popup is set to autohide, presenting
may immediately fail, in case the grab was not granted by the display
server.

After a successful present, the result of the layout can be queried
using the following methods:

 * gdk_surface_get_position() - to get the position relative to its
   parent
 * gdk_surface_get_width() - to get the current width
 * gdk_surface_get_height() - to get the current height
 * gdk_surface_get_rect_anchor() - to get the anchor point on the anchor
   rectangle the popup was effectively positioned against given
   constraints defined by the environment and the layout rules provided
   via GdkPopupLayout.
 * gdk_surface_get_surface_anchor() - the same as the one above but for
   the surface anchor.

A new signal replaces the old "moved-to-rect" one -
"popup-layout-changed". However, it is only intended to be emitted when
the layout changes implicitly by the windowing system, for example if
the monitor resolution changed, or the parent window moved.
2020-02-19 09:47:18 +01:00
Jonas Ådahl
f43717a42e popover: Unrealize when autohide prop changes
Changing the autohide property means the popover needs to be remapped.
Remapping may need user interaction, so lets just unrealize the popover
if the property changes, forcing the application to remap it should it
be shown again.
2020-02-19 09:47:18 +01:00
Timm Bäder
5097c1defc Merge branch 'file-filter-name-property' into 'master'
GtkFileFilter: Add a GObject property for the name

See merge request GNOME/gtk!376
2020-02-19 07:43:51 +00:00
Matthias Clasen
66307f00f1 icontheme: Update the api
Add properties, and use string arrays instead of lists.

Among other things, this renames gtk_icon_theme_list_icons
to gtk_icon_theme_get_icon_names.

Fixes: https://gitlab.gnome.org/GNOME/gtk/issues/2410
2020-02-18 20:32:17 -05:00
Benjamin Otte
732716ba95 debug: When debug-printing, treat NULL as the default display
Otherwise we lose debug prints from all code that allows NULL displays.
2020-02-19 01:21:33 +01:00
Matthias Clasen
03ee4229f2 Merge branch 'wip/otte/dnd' into 'master'
More DND rework

See merge request GNOME/gtk!1445
2020-02-18 22:15:56 +00:00
Sebastian Dröge
8378eb22a3 GtkDialog: Add type Gtk.HeaderBar annotation to headerbar getter return value 2020-02-18 10:55:31 +02:00
Benjamin Otte
0d4d4e9a8c colorbutton: Fix drag source
By running it in the capture phase, it will not be starved for events by
the button's click source and make drags actually start a color drag
operation.
2020-02-18 02:58:58 +01:00
Benjamin Otte
b8cf7ea1c6 dnd: Port the TreeModel machinery to GValue DND 2020-02-18 02:40:00 +01:00
Benjamin Otte
1145da3ea5 placessidebar: Modernize DND
No more shooting pointers through pipes
2020-02-17 21:56:16 +01:00
Benjamin Otte
27d7aa1407 notebook: Use proper DND
Actually use GValues for the DND operation instead of sending GBytes of
pointer addresses through pipes.

This is a bit complicated because we need to special-case rootwindow
drops, because they're handled on the source side, so we need a custom
ContentProvider.
2020-02-17 21:56:16 +01:00
Benjamin Otte
9703fcc605 notebook: Move dnd scrolling via arrows to own drop target
This removes excess code from the tab dnd machinery
2020-02-17 21:56:16 +01:00
Benjamin Otte
e25bfa6a61 dragdest: Handle NULL content formats everywhere
NULL means we don't do content formats checks and accept everything.

We use this for notebook arrows or expanders that react to ongoing
drags.
2020-02-17 21:56:16 +01:00
Matthias Clasen
a838a54dca text: Treat Emoji insertion like clipboard
Enter the Emoji inseration in the undo history.
Also, stop stashing away the selection when we
pop up the Emoji chooser, and use the selection
as-is when we insert the Emoji.
2020-02-17 15:05:09 -05:00
Benjamin Otte
f5e3584b5b placessidebar: Don't claim to support text dnd
Because you don't. And never did.
2020-02-17 04:04:21 +01:00
Benjamin Otte
80ba7fd682 dragdest: Make gtk_drop_target_new() args be transfer full
Saves tons of code.
2020-02-17 04:04:21 +01:00
Benjamin Otte
91d91a29e8 colorbutton, colorswatch: Simplify DND
- Use GDK_TYPE_RGBA and let GDK do the conversion from
  application-x-color
- Don't do extra mime type checks when accept() does that for us already
2020-02-17 04:04:21 +01:00
Benjamin Otte
3a7e3cf90d dragdest: Simplify function
Make it obvious that the functions checks one condition and then the
other.
2020-02-17 04:04:21 +01:00
Benjamin Otte
e1f8c1430f dnd: simplify code
The old code did mimetype checks everywhere when type compatibility has
since been moved to the GtkDropTarget::accept signal.

So the code can now just assume a compatible mime type exists.
2020-02-17 04:04:21 +01:00
Benjamin Otte
da83457a60 dnd: Remove gdk_content_provider_new_with_callback()
Content providers are meant to be immutable, apart from very special
cases, but in those cases they need to emit
gdk_content_provider_content_changed().

Having a constructor that just uses a get_func invites abuse of this
by not making developers aware of those requirments.
In fact, all users in GTK failed to do this.

Instead, code should use the GtkDragSource::prepare signal to create
content providers when needed.

The same problem exists with gdk_content_provider_new_with_formats(),
but this commit doesn't touch that.
2020-02-16 20:10:31 +01:00
Benjamin Otte
8d2ed36a1b contentprovider: Add gdk_content_provider_new_typed()
Gets around the boilerplate required to create and initialize a GValue
by having this function doing it via G_VALUE_COLLECT().
2020-02-16 20:10:30 +01:00
Benjamin Otte
410dbdf671 widget: Fix namespacing problem
In Vala and JS at least, gtk_widget_get_css_name() and
gtk_widget_class_get_css_name() are resolved to
GtkWidget.get_css_name().

To avoid this problem, we rename the class version.
2020-02-16 20:05:05 +01:00
Benjamin Otte
43b8aff62c widget: Fix typos for css-clases property 2020-02-16 19:57:45 +01:00
Benjamin Otte
47c8026e38 Merge branch 'wip/otte/dnd' into 'master'
some DND fixes

See merge request GNOME/gtk!1440
2020-02-15 23:45:25 +00:00
Benjamin Otte
894ac6c126 dragdest: Use format matching APIs 2020-02-15 21:04:33 +01:00
Timm Bäder
08501c9510 calendar: Emit {next,prev}-{month,year} signals
Fixes #833
2020-02-15 17:18:27 +01:00
Timm Bäder
a4ecfd8f33 widget: Use get_css_name() in get_property()
Instead of reimplementing it there.
2020-02-15 17:18:27 +01:00
Timm Bäder
28482e52be Adwaita: Add focus outlines back to scale troughs
Fixes #189
2020-02-15 17:18:27 +01:00
Timm Bäder
bf839dbb88 coloreditor: Scale h value to 360
Fixes #1321
2020-02-15 17:18:27 +01:00
Timm Bäder
2529464e21 range: Avoid rounding errors when allocating highlight
Fixes #2438
2020-02-15 17:18:26 +01:00
Timm Bäder
7e43034068 widget: Add css-classes property
Mirroring the values added and removed via {add,remove}_css_class().
2020-02-15 17:18:26 +01:00
Timm Bäder
52979a0e93 infobar: Remove _get_{action,content}_area()
Accessors like these are weird to have and we can add widgets to the
content area via gtk_container_add() as well as add widgets to the
action area via gtk_info_bar_add_action_widget().
2020-02-15 17:18:26 +01:00
Timm Bäder
a7de8e6b2f infobar: Don't store close button visibility separately
We can already set and query that value via
gtk_widget_{get,set}_visible() on the close button.
2020-02-15 17:18:26 +01:00
Timm Bäder
3cc57c2e3a actionbar: Use a bin layout 2020-02-15 17:18:26 +01:00
Timm Bäder
a1d47ec59f calendar: Add style class to today's label
Add the .today style class to the label indicating the current day.

Fixes #230
2020-02-15 17:18:26 +01:00
Timm Bäder
43a9f9bd02 calendar: Document style classes
Fixes #790
2020-02-15 17:18:26 +01:00
Benjamin Otte
c1f71ee3e8 window: Remove GtkWindowType and window->type
And remove code that was making decisions on the type and just use
the part for toplevels.
2020-02-14 21:18:49 +01:00
Benjamin Otte
de49e47690 textview: Fix docs typo 2020-02-14 21:18:49 +01:00
Benjamin Otte
a278edab22 window: Remove type argument from gtk_window_new() 2020-02-14 21:18:49 +01:00
Benjamin Otte
264967b764 widget: Add gtk_widget_get_css_name() API 2020-02-14 21:18:49 +01:00
Benjamin Otte
d303b5b0eb slicelistmodel: Fix two wrong computations
Both of those are thinkos during math.
Found by Mohammed Sadiq.

Testcases triggering both have been added.
2020-02-14 03:15:22 +01:00
Matthias Clasen
97ec29d3f5 Force-create style contexts in realize
This is necessary as long as style contexts are
required for proper css change tracking.

Fixes #2435
2020-02-13 21:14:01 -05:00
Emmanuele Bassi
2a0dfa9670 Remove gtk_style_context_get_parent()
The function was declared and mentioned in the documentation, but it has
been removed in commit 416182a20d.
2020-02-13 14:53:25 +00:00
Emmanuele Bassi
40852ea952 gi: Skip gtk_custom_layout_new()
The whole GtkCustomLayout class is mostly a C convenience API, and
there's no reason why high level languages should use it.
2020-02-13 14:53:25 +00:00
Emmanuele Bassi
32a2a629dd Fix the function name in the gtk-doc stanza
The documentation is still referring to the old function's name.
2020-02-13 14:53:25 +00:00
Emmanuele Bassi
35ac7de140 Match argument name between declaration and definition
Otherwise the documentation and the introspection data will complain.
2020-02-13 14:53:25 +00:00
Emmanuele Bassi
0d354d1dc4 docs: Match the argument name with its declaration 2020-02-13 14:53:25 +00:00
Emmanuele Bassi
cdd7e4c5ec Add a notify function to GdkContentProvider
The callback-based content providers need a GDestroyNotify function to
free the data passed to them on construction, otherwise they are going
to leak.
2020-02-13 14:53:25 +00:00
Matthias Clasen
14ecc9ec7e Remove unused signal enum values
GtkWidget lost even more signals, so we don't need
these enum values anymore.
2020-02-12 18:25:42 -05:00
Matthias Clasen
073e8dd987 popovermenu: Avoid an uninitialized variable
Pointed out by Timm/clang.

Fixes https://gitlab.gnome.org/GNOME/gtk/issues/2434
2020-02-12 17:58:41 -05:00
Matthias Clasen
6c6b3d0d11 Merge branch 'ci-pages' into 'master'
Rename the SCSS files for our themes

Closes #2423

See merge request GNOME/gtk!1423
2020-02-12 22:35:58 +00:00
Emmanuele Bassi
2ab9be54fb Rename the SCSS files for our themes
It seems that Meson's gnome.compile_resources() cannot deal with two
files with the same name under different directories, which breaks the
build parallelism because the GResource file ends up not depending on
either the Adwaita or the HighContrast gtk-contained.css file.

This commit only changes the on-disk names of the Adwaita and
HighContrast SCSS files, and the corresponding generated CSS files; the
files in the GResource are going to be aliased to the old file names, to
minimise the breakage. We might want to change the theme entry points at
some later date, if we decide to commit to this naming scheme.

Fixes: #2423

See Meson bug: https://github.com/mesonbuild/meson/issues/6615
2020-02-12 20:22:43 +00:00
Matthias Clasen
11ab39617e Fix the Emoji chooser finalize
If the Emoji chooser is finalized before the idle
has run, it would spew criticals, breaking some tests.
Avoid that.
2020-02-12 14:23:01 -05:00
Georges Basile Stavracas Neto
1b95cd27bc build: Install gtkemojichooser.h
It was made public at ef7172dc1e, but the header file
wasn't added to the public headers list.

Add the header file to the list.
2020-02-12 15:41:49 -03:00
Alexander Larsson
b4b00e2887 icon theme: Don't add profiler marks for short async icon loads
We do a bunch of preloads, and most of these are not really interesting
anyway.
2020-02-12 12:43:27 +01:00
Alexander Larsson
e134eef505 builder: Don't add profiler marks for short parses
There are a lot of thes (since we're recursing), so don't spew the
output with uninteresting ones.
2020-02-12 12:42:29 +01:00
Alexander Larsson
2890cd849f profiler: Add _end_mark() version of _add_mark()
These don't take a duration, instead they call g_get_monotonic_time() to
and subtract the start time for it.

Almost all our calls are like this, and this makes the callsites clearer
and avoids inlining the clock call into the call site.
2020-02-12 11:25:34 +01:00
Alexander Larsson
01d5ad2056 profiler: Make profiler-is-running a macro
When we use if (GDK_PROFILER_IS_RUNNING) this means we get an
inlined if (FALSE) when the compiler support is not compiled in, which
gets rid of all the related code completely.

We also expand to  G_UNLIKELY(gdk_profiler_is_running ()) in the supported
case which might cause somewhat better code generation.
2020-02-12 11:05:01 +01:00
Alexander Larsson
cc643df88b Convert all profiler times from nsec to usec
usec is the scale of the monotonic timer which is where we get almost
all the times from. The only actual source of nsec is the opengl
GPU time (but who knows what the actual resulution of that is).

Changing this to usec allows us to get rid of " * 1000" in a *lot* of
places all over the codebase, which are ugly and confusing.
2020-02-12 10:44:17 +01:00
Alexander Larsson
13eedf1a9f Use markf in one more place 2020-02-12 10:40:26 +01:00
Matthias Clasen
9062607d5f Merge branch 'wip/baedert/outline-radius' into 'master'
css boxes: Compute box from border box

Closes #2425

See merge request GNOME/gtk!1408
2020-02-11 16:59:11 +00:00
Alexander Larsson
dc6fe091b9 revealer: Fix child size allocation at small scales
As pointed out in https://gitlab.gnome.org/GNOME/gtk/issues/1481
and seen from critical warnings with swinging revealers in widget-factory
there are some size allocation issues in GtkRevealer.

What happens is that we request a size of the revealer itself
based on the child natural size and the current stage of the transition
by applying a scale to the natural size. We then round up to nearest
int size. However, we want the widget to render as if it did get the
natural size so we can transform it, rather than the scaled down size.
For example, a label should not start ellipsizing in the animation.
So we inverse the scale when allocating the child.

Unfortunately, for very small scales the inversion of the scale can
result in very large sizes, and for such scales we rounded up the
requested size to 1, so we will be allocating huuuuge children.

In order to avoid such issue we pick an arbitrary maximum upscale
scale factor of 100. This means that in the case where the allocated
size is 1 we never allocate the child at > 100 px. This means
that in large downscaling cases we may run into the clipping issue
described above. However, at these downscaling levels (100 times!)
we're unlikely to notice much detail anyway.
2020-02-11 13:52:12 +01:00
Matthias Clasen
af98c46d04 Typo fix 2020-02-11 07:46:12 -05:00
Timm Bäder
8561860aa1 css boxes: Compute inline box from border box
We can't just use the outline rect and apply the border radius because
the outline box is the border box grown by the outline offset, which
will also grow the resulting border radius.

Fixes #2425
2020-02-11 12:10:16 +01:00
Matthias Clasen
c0dcaccf4b calendar: Fix mismatches with GDateTime
GDatetime uses 1-based month and day numbers, whereas
GktCalendars are 0-based. Correct for this.
2020-02-10 14:59:40 -05:00
Matthias Clasen
11cd955591 Calendar: Make year/month/day writable again
Our a11y tests were relying on this.
2020-02-10 14:14:18 -05:00
Matthias Clasen
59b935af38 Merge branch 'mainloop-cleanup' into 'master'
Mainloop cleanup

See merge request GNOME/gtk!1404
2020-02-10 14:32:09 +00:00
Alexander Larsson
1698369d52 Merge branch 'icon-theme-api-rework' into 'master'
Icon theme api rework

See merge request GNOME/gtk!1390
2020-02-10 12:45:56 +00:00
Alexander Larsson
96a4bb446c Fix typo in GtkIconPaintable is-symbolic property 2020-02-10 13:30:57 +01:00
Alexander Larsson
ad0e901061 icon-theme: Add back and fix test for handling non-square icons
We test this by looking at the produced render nodes now that
we don't actualluy scale the icon. Also, it turns out that this
code was broken due to some typos, so we also fix those.
2020-02-10 13:17:15 +01:00
Alexander Larsson
ba781eca74 Expose gtk_icon_paintable_new_for_file 2020-02-10 13:17:15 +01:00