Commit Graph

32779 Commits

Author SHA1 Message Date
Matthias Clasen
499738c903 constraint guide: Avoid redundant constraints
There is no point in creating a stay for nat
size when min == max. And no point in a constraint
for <= G_MAXINT either.
2019-07-01 00:10:11 +01:00
Matthias Clasen
f2d7433bf6 constraint guide: Fix initial property values
This was overlooked when the max-width/max-height/
strength properties were added.
2019-07-01 00:10:11 +01:00
Matthias Clasen
405121bccc constraint solver: Use GTK_NOTE
Allow using GTK_DEBUG=constraints to get debug
output from the constraints solver.
2019-07-01 00:10:11 +01:00
Matthias Clasen
cb96b34315 solver: Add private statistics api
No point in keeping these counters without
a way to show them.
2019-07-01 00:10:11 +01:00
Matthias Clasen
9edf6fb6cb constraint layout: Dont reset constraints in allocate
If trust our allocation algorithm, this can never
trigger (and in fact, it never does).
2019-07-01 00:10:11 +01:00
Matthias Clasen
e3c4fb67ca constraints: Add some internal apis
Checking if a set is empty or a singleton can
be done more efficiently than determining its size.
2019-07-01 00:10:11 +01:00
Matthias Clasen
a9dfca04e4 constraint guide: Make strength tweakable
The strength for the natural width can be used
as a tie-breaker to make instable systems behave
in a more predictable way. This can be seen
in the simple constraints demo in gtk-demo.
2019-07-01 00:10:11 +01:00
Matthias Clasen
f62fc4e2f2 constraint layout: freeze/thaw on mass ops
In measure and allocate we are potentially
changing quite a few constraints. Don't
optimize at every step.
2019-07-01 00:10:11 +01:00
Matthias Clasen
511e2b435e constraints: Use better data structures
Use a GSequence for GtkVariableSet, to avoid
quadratic behavior.
2019-07-01 00:10:11 +01:00
Matthias Clasen
3f36340921 constraint layout: Measure min/nat size separately
Only constraint the opposite direction if we
actually have a for_size, and measure natural
size after removing the edit constraints. With
these changes, the test that compares constraint
layout to grid layout passes.
2019-07-01 00:10:11 +01:00
Matthias Clasen
b1f0f4478e constraint layout: Use stays for natural size
It makes more sense to treat the natural size
of both children and guides as stays, since
we want to meet these values as closely as we
can, under the circumstances.
2019-07-01 00:10:11 +01:00
Matthias Clasen
90f8dcc5e1 constraint layout: Add debug output for guides
Print out the allocation we end up giving to
guides. This helps in making sense of the
allocations of the child widgets that these
guides relate to.
2019-07-01 00:10:11 +01:00
Matthias Clasen
b39a5fe5dc constraint guide: Add a name property
We need to be able to print meaningful debug messages
regarding these objects, and eventually present them
in the inspector too.
2019-07-01 00:10:11 +01:00
Matthias Clasen
c7ef8411bd constraint guide: Shorten names
Now that this is its own source file,
no need for these prefixes anymore.
2019-07-01 00:10:11 +01:00
Matthias Clasen
dab8a8b5c5 constraint layout: Measure more correctly
Set up all constraints for minimum + natural
width + height when measuring, regardless
of the orientation we're measuring. Anything
else will lead to incorrect answers when
there are constraints that cut across
dimensions.
2019-07-01 00:10:11 +01:00
Matthias Clasen
8b9c5e3a04 solver: Fix a copy/paste error 2019-07-01 00:10:11 +01:00
Matthias Clasen
3d3a672deb constraint solver: Fix repeat suggestions
We were not storing the previous value, causing
the first two suggestions to work, but not later
ones.

Fixes the test added in the previous commit.
2019-07-01 00:10:11 +01:00
Matthias Clasen
139a59cae3 Flesh out GtkConstraintGuide
This commit moves GtkConstraintGuide into its own
source files to avoid gtkconstraintlayout.c turning
too messy, adds max size properties and implements
getters and setters.
2019-07-01 00:10:11 +01:00
Matthias Clasen
60fb9092fe Drop an indirection
This struct is not really useful for just
a single hash table, and it gets in the way
of moving the guide code to its own file.
2019-07-01 00:10:11 +01:00
Matthias Clasen
61b4febbaf Detach guides on unroot
We don't want to leave constraints behind.
2019-07-01 00:10:11 +01:00
Matthias Clasen
4f4ba8c4f6 Simplify the guide implementation
Store the values and constraints in
arrays, to facilitate treating them
uniformly.
2019-07-01 00:10:11 +01:00
Emmanuele Bassi
651adbfb39 Return the list of constraints added via VFL description
Otherwise it's impossible to remove them.
2019-07-01 00:10:11 +01:00
Emmanuele Bassi
3204347bb0 Add method to remove all constraints from a layout 2019-07-01 00:10:11 +01:00
Georges Basile Stavracas Neto
b929846cc1
Adwaita: Also apply $color_menu to popover arrows
So that popovers and arrows are always in agreement of
the background color.
2019-06-30 19:51:51 -03:00
Georges Basile Stavracas Neto
fe65da05be
Adwaita: Use $menu_color background in popover.menu
GtkPopoverMenus should mimic menus. Commit d936967b7a introduced
some CSS related to menu popovers, however, it hardcodes 'white'
as the background color. That is problematic for the dark theme.

Use '$menu_color' instead of 'white', since $menu_color both
guarantees menu popovers and menus match, and already handles
different colors for dark and light theme variants.
2019-06-30 19:47:32 -03:00
Emmanuele Bassi
06c825df90 Add a C convenience function for VFL constraints
The dictionary-based function is convenient for language bindings, but C
developers will feel more at home with a variadic arguments list.
2019-06-30 23:42:45 +01:00
Emmanuele Bassi
859c95b435 Allow adding constraints described through VFL 2019-06-30 23:42:45 +01:00
Emmanuele Bassi
5ea8167802 Add VFL parser for constraints
Constraints can be expressed with a compact syntax, called VFL (visual
format language).
2019-06-30 23:42:45 +01:00
Emmanuele Bassi
92d3d55164 Remove GtkConstraintVariable.set_prefix()
The prefix and name are set at construction time.
2019-06-30 23:42:45 +01:00
Matthias Clasen
38d353dc1a Add GtkConstraintGuide
This is meant to be a flexible space.
2019-06-30 23:42:44 +01:00
Emmanuele Bassi
7ae04ba36b Use generic pointers for constraint targets
Since GtkWidget implements GtkConstraintTarget, we can omit the explicit
cast, and validate the type at run time.
2019-06-30 23:42:44 +01:00
Matthias Clasen
39c284c490 Redefine constraints with GtkConstraintTarget
This is in preparation for allowing non-widgets
to act as constraint targets.
2019-06-30 23:42:44 +01:00
Matthias Clasen
895e8e25a8 widget: Implement GtkConstraintTarget 2019-06-30 23:42:44 +01:00
Matthias Clasen
04562a76e3 Add GtkConstraintTarget
This is an marker interface that we will
use to accept other things that widgets
in constraints.
2019-06-30 23:42:44 +01:00
Emmanuele Bassi
b6781e06c1 Notify a layout change when adding and removing constraints
Changing the set of constraints should cause a relayout.
2019-06-30 23:42:44 +01:00
Emmanuele Bassi
54104b6676 Fix the opposite size measurement in GtkConstraintLayout
We cannot use the given "for size" when querying our children, because
the constraint layout has no idea about the opposite size of its
children until the layout is complete.

Additionally, we should only suggest an opposite size for the layout if
we have one, instead of suggesting a weak zero size.
2019-06-30 23:42:44 +01:00
Emmanuele Bassi
21450d5f23 Remove size constraints from ConstraintLayoutChild
The size constraints are transient to measurement and allocation, so
they don't really need to be stored inside the GtkLayoutChild subclass
created by a GtkConstraintLayout.
2019-06-30 23:42:44 +01:00
Matthias Clasen
a39bbb2041 constraints: Make internal consistency required
The relations between left, right, width
and top, bottom, height are required for
internal consistency. It doesn't make sense
to ever drop these.

Changing the strength of these relations makes
my systems behave much more stable.
2019-06-30 23:42:44 +01:00
Matthias Clasen
176d9c6baf Add gtk_constraint_layout_remove_constraint
Otherwise, you can't do many interesting things.
2019-06-30 23:42:44 +01:00
Emmanuele Bassi
64afa765c8 Do not release reference on the subject of an expression
We don't own the reference in the first place.
2019-06-30 23:42:44 +01:00
Matthias Clasen
a246d8c926 constraints solver: Avoid critials
When the solver is finalized with existing
constraints, we end up with criticals when
the constraints ref finalize code calls
back into the hash table. Avoid that by
emptying the hash table beforehand.
2019-06-30 23:42:44 +01:00
Matthias Clasen
0531e663ee constraint solver: Fix thawing
There was an obviously wrong precondition here.
2019-06-30 23:42:44 +01:00
Emmanuele Bassi
bd2349c0a0 Do not leak LayoutChild instances
Since the LayoutManager owns the LayoutChild it creates, it's also
responsible for mopping them up.
2019-06-30 23:42:44 +01:00
Emmanuele Bassi
cdf80f1d65 Add GtkConstraintLayout
A layout manager using GtkConstraintSolver to measure and allocate
children.
2019-06-30 23:42:44 +01:00
Emmanuele Bassi
e7b2c530c5 Propagate rooting and unrooting widgets to layout managers
Layout managers may need to get access to data attached to the root of a
scene graph.
2019-06-30 23:42:44 +01:00
Emmanuele Bassi
e07098da03 window: Create a GtkConstraintSolver
Implement the GtkRoot getter for GtkConstraintSolver.
2019-06-30 23:42:44 +01:00
Emmanuele Bassi
98a21bf498 Assign a GtkConstraintSolver to each GtkRoot
Constraints need to work across different parents, so it's better to
have a single constraint solver per top level.
2019-06-30 23:42:44 +01:00
Emmanuele Bassi
c694dd6049 Move the Root interface to a private header
We don't expect out of tree implementations of GtkRoot, and having the
interface structure private to the GTK code allows us to add virtual
functions involving private types.
2019-06-30 23:42:44 +01:00
Emmanuele Bassi
6b308cd71e Add constraint solver
GtkConstraintSolver is an implementation of the Cassowary constraint
solving algorithm:

  http://constraints.cs.washington.edu/cassowary/

The Cassowary method allows to incrementally solve a tableau of linear
equations, in the form of:

  x = y × coefficient + constant

with different weights, or strengths, applied to each one.

These equations can be used to describe constraints applied to a layout
of UI elements, which allows layout managers using the Cassowary method
to quickly, and efficiently, lay out widgets in complex relations
between themselves and their parent container.
2019-06-30 23:42:44 +01:00
Matthias Clasen
3b6ee32f83 Fix a crash in action muxer destruction
I've seen a crash when the action muxer gets
disposed during widget destroy, and tries to
disconnect from widget signals too late.

There is no real need to disconnect, since the
only time an action muxer is going away is when
its widget is destroyed, so just don't do it.
2019-06-30 18:37:32 +00:00
Timm Bäder
a6a9853676 Adwaita: Fix popover style
We add the .background class to the popover node now.
2019-06-29 09:06:32 +02:00
Matthias Clasen
8fa7de5563 grid layout: Fix initial property values
Too bad that we don't cover layout children
in the default value test - it would have
caught this.
2019-06-28 12:42:06 +00:00
Jakub Steiner
9e6b4e82c9 Adwaita: allow flat list row buttons to be flat
- Be more specific about the list row image buttons

Addresses corner case of https://gitlab.gnome.org/GNOME/gtk/issues/1748
2019-06-27 12:15:51 +02:00
Jakub Steiner
4be2e804ae Adwaita: lighten dark switch sliders
- addresses legibility concerns

Fixes https://gitlab.gnome.org/GNOME/gtk/issues/1819
2019-06-27 10:58:18 +02:00
Alex Monday
1056e9976a Adwaita: Apply border-radius to .csd popovers
Fix popover_radius variable doesn't apply to .csd popover.

Closes https://gitlab.gnome.org/GNOME/gtk/issues/1984
2019-06-27 10:40:22 +02:00
Alex Monday
851bb61455 Adwaita: Fix padding/rounding on submenus
- Apply menubar submenu style for .csd submenus;
- Remove child subemenu style (looks like it is inherited
  from a parent).

Closes https://gitlab.gnome.org/GNOME/gtk/issues/1976
2019-06-27 10:31:11 +02:00
Jakub Steiner
3aadc29af4 Adwaita: darken osd background for A:dark
- OSD background color was too close to $bg_color to make out outline

Fixes https://gitlab.gnome.org/GNOME/gtk/issues/1964
2019-06-27 10:30:01 +02:00
Hodong Kim
19b1fcfee3 Fix a typo 2019-06-24 18:42:40 +00:00
Daniel Boles
98cfbd3712 ShortcutsSection: Fix tiny grammar-o "in for"→"in" 2019-06-24 18:02:15 +01:00
Matthias Clasen
2405e2711e Add a non-varargs variant of activate_action
I recently turned gtk_widget_activate_action()
into a varargs function. That is more convenient
from C, but we need a non-varargs variant for
bindings. So add the old API back, under the
name gtk_widget_activate_action_variant(),
with a rename-to annotation.
2019-06-24 15:51:39 +00:00
Matthias Clasen
3acc014499 Make gtk_widget_activate_action better
As a convenience API, this should be easy to use,
so don't expect callers to manually create a
variant, do it for them.

Update all callers.
2019-06-23 22:51:55 +00:00
Matthias Clasen
3ebe30bf32 widget: create parent muxers lazily
We need to create a muxer eagerly for every
widget that has class actions, since those
are otherwise missed in the action lookup
on the muxer side. But otherwise, there is
no reason to create parent muxers aggressively,
as long as we update the parent muxers on
root/unroot.

This reduces the number of muxers we create
in widget-factory from 210 to around 50.
2019-06-23 17:59:41 +00:00
Matthias Clasen
996f011ed8 window: Fix the default value of mnemonics-visible
They aren't visible, so why should the property
be TRUE?
2019-06-23 10:59:17 -04:00
Timm Bäder
0611370a5f Merge branch '362-gtk-fileopen-dialog-need-filetype-mime-sort-option-2_GTK4' into 'master'
GtkFileChooser: add a sortable "Type" column

Closes #362

See merge request GNOME/gtk!874
2019-06-23 07:58:26 +00:00
Matthias Clasen
8fd968e5bf action muxer: Don't activate disabled actions
We really shouldn't.
2019-06-23 01:39:26 +00:00
Matthias Clasen
203d612afd widget: Clarify docs for action inheritance
Spell out how action inheritance works wrt to prefixes.
2019-06-22 19:17:30 -04:00
Matthias Clasen
ad4a81e9df action muxer: Change inheritance
Previously, we would not look any further for
an action once we found a match for the prefix,
defining inheritance by groups. Change this to
inheritance for individual actions, since we
are moving towards individual actions as the
main ingredient in GTKs action support.
2019-06-22 22:51:23 +00:00
Matthias Clasen
95e5472ade action muxer: Remove unused api 2019-06-22 22:38:14 +00:00
Matthias Clasen
06ff4a8b6f textview: Stop using action muxer needlessly
This lets us drop some private api.
2019-06-22 22:34:26 +00:00
Matthias Clasen
1f0904d3df widget: Teach query_action about property actions
This might be useful for documentation purposes.
2019-06-22 17:04:01 -04:00
Matthias Clasen
35a88c1440 widget: Rename a function
set_enabled is shorter and more to the point
than enabled_changed, now that we no longer have
a callback to query the state.

Adapt all callers.
2019-06-22 17:03:51 -04:00
Matthias Clasen
d1f4068b94 Replace stateful actions by property actions
The only cases of stateful actions we've seen
so far have been boolean properties, and we
don't really want to add much state handling
API, so lets just go with property actions
for now.

Adapt the only user in GtkText.
2019-06-22 17:03:38 -04:00
Matthias Clasen
7e73da5f73 widget: Add parameter type back to install_action
Adapt all callers.
2019-06-22 16:48:16 -04:00
Nelson Benítez León
c789a39660 GtkFileChooser: add a sortable "Type" column
along with a new 'type-format' setting that allows
to choose the output format for the "Type" column.

The options implemented for this setting are:

'mime' : Output from g_content_type_get_mime_type().

'description' : Output from g_content_type_get_description().

'category' : It uses the corresponding generic icon
  of the mime type to group by categories (aka basic types).

  This produces a more compact output than previous options,
  and allows for type families to be grouped together, so eg.
  after sorting by "Type" column, jpeg and png images will
  be placed together, or the various types of archiver files
  will also be grouped together.

  This format was copied from and currently used by Nautilus
  list view, so we also improve consistency with Nautilus.
  Bugzilla entry for Nautilus implementation is:
  https://bugzilla.gnome.org/show_bug.cgi?id=683722

  The list of type families or categories can be checked on:
  https://developer.gnome.org/icon-naming-spec/#mimetypes

  This 'category' format is set as default.

Issue #362
2019-06-22 13:22:59 -04:00
Matthias Clasen
3c6045e300 css: Fix some doc typos 2019-06-22 09:49:50 -04:00
Matthias Clasen
9389768a17 Add GTK_CSS_PARSER_WARNING_UNIMPLEMENTED
gtk-doc was complaining about it missing,
and it is used in some ifdefed code.
2019-06-22 09:48:34 -04:00
Matthias Clasen
412006ad23 Add owner types for widget actions
This lets us filter out actions from parent classes
when introspecting.
2019-06-22 09:38:30 -04:00
Matthias Clasen
ea456b80da Make actions minimally introspectable
This will let us autogenerate some docs for
actions, in the future.
2019-06-21 22:47:40 -04:00
Matthias Clasen
152eabbaba widget actions: Add an explicit state type
Make the state type part of the API for installing
stateful widget actions. That lets us introspect it.

Update all callers.
2019-06-21 22:47:40 -04:00
Matthias Clasen
9be0b3d76f application: Stop extracting accels from menus
This functionality has been superseded by
gtk_application_set_accels_for_action in GTK3,
and we don't want to carry it forward in GTK4.
2019-06-21 22:47:40 -04:00
Matthias Clasen
9b0d87c5a7 window: Cosmetics 2019-06-21 02:55:27 +00:00
Matthias Clasen
a515fca63f inspector: Fix actions visibility
We need to always hide the page when setting
an object, otherwise the initial visibility
sticks.
2019-06-20 22:49:22 -04:00
Matthias Clasen
b6baa15e0a inspector: Use event controller names
Use these in the same place we use widget names.
2019-06-20 22:48:42 -04:00
Matthias Clasen
955ae40cd6 event controller: Add a name property
This helps identifying controllers in the inspector.
2019-06-20 22:48:33 -04:00
Matthias Clasen
dee9e40ad3 Build fix 2019-06-20 22:47:35 -04:00
Matthias Clasen
a933a9bc79 Fix initial mnemonic visibility
We were showing mnemonics initially, which is not desired.
2019-06-21 02:38:05 +00:00
Matthias Clasen
6a4a082660 main: Move visible mnemonics handling
No need to special-case this anymore; we can use
a regular event controller in GtkWindow for this.
2019-06-21 02:37:51 +00:00
Matthias Clasen
a7cdcdf92c main: Move visible focus handling
No need to special-case this anymore; we can use
a regular event controller in GtkWindow for this.
2019-06-21 02:37:12 +00:00
Daniel Boles
a7a0a34da1 Overlay: Document overlay children aren't measured
Some users expect that the Overlay will automatically request enough
size for its overlay children as well as its main child. It doesn't,
because it's just a GtkBin. Add a short paragraph pointing that out.

Close https://gitlab.gnome.org/GNOME/gtk/issues/1939
2019-06-20 21:41:59 +01:00
Daniel Boles
a03e531772 FileChooserButton: Document the CSS nodes & class
The only glancing mention of this we had was that GtkButton mentioned it
in passing when discussing how `button` could get contextual classes,
and even that's not relevant in master anymore... so drop it from there.
2019-06-20 20:51:37 +01:00
Daniel Boles
217f9ea3b8 ListBox: Document buildable child type placeholder
andyholmes on IRC asked about this and it wasn't documented, so fix that
2019-06-18 21:45:08 +01:00
Daniel Boles
ab7b9d882e Window: Hyperlink to GtkBuildable from its section 2019-06-18 21:45:08 +01:00
Benjamin Otte
27d6276212 bindings: Make gtk_binding_entry_add_signall() private
This function needs a replacement and that will appear after
refactorings.
2019-06-18 15:54:27 -04:00
Benjamin Otte
d8d5cc9788 bindings: Hide structs 2019-06-18 15:54:07 -04:00
Benjamin Otte
2687a2eb8d bindings: Remove unused member variables 2019-06-18 15:53:48 -04:00
Matthias Clasen
7dbeee5d50 color chooser widget: Use the new action machinery
Port GtkColorChooserWidget to use widget class actions.

Note that this also changes the names of
the GtkColorChooserWidget actions away from a generic
"context" prefix.
2019-06-18 14:48:02 -04:00
Matthias Clasen
01e89f9142 link button: Use the new action machinery
Port GtkLinkButton to use widget class actions.

Note that this also changes the names of
the GtkLinkButton actions away from a generic
"context" prefix.
2019-06-18 14:47:33 -04:00
Matthias Clasen
dafb7054a1 window: Use the new action machinery
Change the default.activate action to use the
new action machinery.
2019-06-18 14:47:33 -04:00
Matthias Clasen
04bace1982 textview: Use the new action machinery
Port GtkTextView to use widget class actions.

Note that this also changes the names of
the GtkTextView actions away from a generic
"context" prefix.
2019-06-18 14:47:33 -04:00
Matthias Clasen
90701cb655 label: Use the new action machinery
Port GtkLabel to use widget class actions.

Note that this also changes the names of
the GtkLabel actions away from a generic
"context" prefix.
2019-06-18 14:47:33 -04:00