Commit Graph

400 Commits

Author SHA1 Message Date
Timm Bäder
348871d9fc Fix a few testsuite failures
Adjust default property values, skip GtkRange:adjustment.
2017-07-19 21:27:16 -04:00
Timm Bäder
36ab70ddf5 widget: Add baseline and out_clip parameters to size-allocate
Since setting a clip is mandatory for almost all widgets, we can as well
change the size-allocate signature to include a out_clip parameter, just
like GtkCssGadget did. And since we now always propagate baselines, we
might as well pass that one on to size-allocate.

This way we can also make sure to transform the clip returned from
size-allocate to parent-coordinates, i.e. the same coordinate space
priv->allocation is in.
2017-07-19 21:27:16 -04:00
Timm Bäder
c4f6cea111 fix a few documentation problems 2017-07-19 21:27:15 -04:00
Timm Bäder
f1813e8f88 spinbutton: Fix gesture state
We claimed the gesture previously to keep it from propagating to the
underlying entry, but now that the entry is in a box with the two
buttons, we can do this properly and restore the previous long-press
behavior.
2017-07-19 21:27:14 -04:00
Timm Bäder
70d90a9923 spinbutton: Remove unused import 2017-07-19 21:27:14 -04:00
Timm Bäder
a0ebad70cd spinbutton: Fix property notification 2017-07-19 21:27:14 -04:00
Timm Bäder
121cf9c78c spinbutton: Add docs for new public API 2017-07-19 21:27:13 -04:00
Timm Bäder
218e0b9929 spinbutton: Use 0 as default for (max-)width-chars
This mimics the old spinbutton size request better.
2017-07-19 21:27:13 -04:00
Timm Bäder
9ab43dfe9e spinbutton: Add accessors for (max-)width-chars 2017-07-19 21:27:12 -04:00
Timm Bäder
6aa9ca7b55 spinbutton: Fix activation 2017-07-19 21:27:12 -04:00
Timm Bäder
ede6f2ab59 Slightly rework clip handling
always initialize clips to the (content) allocation, don't walk up the
widget hierarchy in gtk_widget_set_clip, implement
gtk_widget_size_allocate in GtkSeparator. This way we don't end up using
uninitialized clip values.

The entire clip handling is up for major rework since we can't and don't
want to force every single widget to call _set_clip in size-allocate
implementations.
2017-07-19 21:27:12 -04:00
Timm Bäder
f736b071b4 spinbutton: Add text property 2017-07-19 21:27:11 -04:00
Timm Bäder
3c2d2545b2 spinbutton: Inherit from GtkWidget
Use a box, an entry and the current 2 buttons.
Remaining problems: Entry sizing and activation.
2017-07-19 21:27:11 -04:00
Carlos Garnacho
a72404dd5a gtk: Mass delete all GtkWidget event mask API
We now rely on toplevels receiving and forwarding all the events
the windowing should be able to handle. Event masks are no longer a
way to determine whether an event is deliverable ot a widget.

Events will always be delivered in the three captured/target/bubbled
phases, widgets can now just attach GtkEventControllers and let those
handle the events.
2017-05-25 16:25:58 +02:00
Timm Bäder
a919f0c7f3 spinbutton: Add undershoot nodes to CSS docs 2017-04-24 16:24:32 +02:00
Timm Bäder
0acb404166 spinbutton: Remove an unused define 2017-04-24 16:24:20 +02:00
Timm Bäder
f251c5bf94 spinbutton: Fix right and middle click on +/- buttons
Tell the gesture that we handle all buttons and actually claim the
gesture in the ::pressed handler
2017-02-01 21:05:27 +01:00
Timm Bäder
ea897c6df4 Remove gtk_widget_show_all 2017-01-20 21:37:04 +01:00
Timm Bäder
3cfcbe2ccf spinbutton: Restore gtk3 focus behavior
Focus the spinbutton on button press, never focus the buttons.
2017-01-16 17:22:45 +01:00
Alexander Larsson
7bee22bcb6 Avoid some more type checks for internal calls 2017-01-11 15:27:51 +01:00
Timm Bäder
f486805ba0 Unparent child widgets 2017-01-07 17:19:30 +01:00
Timm Bäder
25236dbed8 spinbutton: Use widgets for up/down buttons 2017-01-07 17:19:30 +01:00
Piotr Drąg
a2da4ddceb Use Unicode in translatable strings
See https://developer.gnome.org/hig/stable/typography.html

https://bugzilla.gnome.org/show_bug.cgi?id=772371
2016-12-19 15:08:10 -05:00
Timm Bäder
fa4d6e8918 spinbutton: Remove _get_panels 2016-12-03 13:19:26 +01:00
Benjamin Otte
64e802c441 snapshot: Convert entry and spinbutton 2016-11-15 17:48:45 +01:00
Matthias Clasen
c7d119614f spinbutton: Fix some gadget handling issues
We were not adding the down_button gadget to the parent,
and we were not unreffing the button gadgets.

https://bugzilla.gnome.org/show_bug.cgi?id=774046
2016-11-10 14:46:21 -05:00
Timm Bäder
f483d931ec spinbutton: Convert to indirect rendering 2016-11-05 11:56:36 +01:00
Timm Bäder
9992a616ef widget: Use ::measure vfunc to measure size
Add a new ::measure vfunc similar to GtkCssGadget's that widget
implementations have to override instead of the old get_preferred_width,
get_preferred_height, get_preferred_width_for_height,
get_preferred_height_for_width and
get_preferred_height_and_baseline_for_width.
2016-10-22 19:05:47 +02:00
Benjamin Otte
4ab85723c8 spinbutton: Use gdk_window_new_input() 2016-10-18 00:22:35 +02:00
Benjamin Otte
4df6ddad54 API: container: Remove gtk_container_set_border_width() 2016-10-16 18:18:58 +02:00
Timm Bäder
601839c825 Remove various sizing related style properties 2016-10-16 18:17:21 +02:00
Benjamin Otte
662001b60a API: Remove ability to set visuals on windows
And with it, gtk_widget_get_visual() and gtk_widget_set_visual() are
gone.

We now always use the RGBA visual (if available) and otherwise fall back
to the system visual.
2016-10-16 18:17:21 +02:00
Benjamin Otte
e1a03ead7a Use NULL for generic marshallers in g_signal_new()
glib will use the correct marshaller automatically. And as a side
effect, we also get all glib optimizations, like a va marshaller.
2016-08-29 16:20:54 +02:00
Ignacio Casal Quinteiro
b0f793c8e7 Use g_snprintf instead of snprintf.
snprintf is not compatible with msvc.
2016-08-10 12:45:39 +02:00
Chun-wei Fan
cd44f6d875 Fix build of commit f23e99b
Commit f23e99b made use of snprintf(), which is not universally available.
Fix this by using g_snprintf().
2016-06-27 11:53:30 +08:00
Matthias Clasen
f23e99b063 scale, spinbutton: Avoid -0.0
This is a very longstanding bug; time to finally put it to rest.

https://bugzilla.gnome.org/show_bug.cgi?id=118959
2016-06-07 23:04:40 -04:00
Matthias Clasen
2148708917 box gadget: Redo expand flag handling
We only keep one align flag per child, so it seems odd to
keep separate h/v expand flags. Just keep one expand flag
and interpret it according to orientation. Allow setting
the expand flag for child widgets too, though, so we can
make widget expand without interfering with the recursive
widget expand flag.

Update all callers.

Use the new possibility of expanding child widgets to make
the label of check and radio buttons expand. This fixes
unexpected behavior of these widgets in RTL in some places.

https://bugzilla.gnome.org/show_bug.cgi?id=765742
2016-04-28 21:59:34 -04:00
Matthias Clasen
3064e4e406 spinbutton: Fix drag highlight problems
Don't propagate :drop(active) to the buttons.
2016-03-11 08:07:30 -05:00
Matthias Clasen
4ab91f09cf spin button: Limit the entry width to reasonable values
When opening the value editor for any GtkAdjustment properties
in the inspector, the popover stretches out for miles, since
it reserves enough space to draw MAXDOUBLE. This is not useful.
Limit the space we reserve to 8 digits.
2016-03-05 23:45:35 -05:00
Jean-François Fortin Tam
cf6c0b09a5 spin button: Use the Ctrl modifier for Home and End key bindings
https://bugzilla.gnome.org/show_bug.cgi?id=309300
2016-02-23 21:20:00 -05:00
Timm Bäder
c44364f1d1 spinbutton: Free the gadget in finalize 2016-02-10 12:30:35 +01:00
Timm Bäder
c5369356e8 Various documentation fixes
Always have Since: annotations at the very bottom, use the correct
ClassName::signal-name/ClassName:property-name syntax, fix a few typos
in type names, wrong function names, non-existing type names, etc.
2016-02-08 22:56:52 +01:00
Matthias Clasen
79fb921ffc spin button: Document sizing peculiarities
Document that it is best to explicitly set width-chars and
max-width-chars to avoid surprises.

https://bugzilla.gnome.org/show_bug.cgi?id=727294
2016-01-27 23:30:25 -05:00
Benjamin Otte
ae31c00092 spinbutton: Don't expand the buttons
When the spinbutton grows larger, distribute horizontal size to the
entry and vertical size to the buttons.

Obviously, horizontal size only matters for horizontal spinbuttons and
vertical for vertical spinbuttons.
2016-01-26 17:59:08 +01:00
Benjamin Otte
5a3a86ec4b spinbutton: Add a base gadget
This really messes up rendering in Adwaita because the code now renders
the spinbutton's entry node when it didn't before.
2016-01-25 16:14:23 +01:00
Benjamin Otte
3982f05be4 entry: Move spinbutton size hack
If we want to do special sizing for the text, we need to do it for the
text. Otherwise paddings, borders and entyr icons will screw up
everything.
2016-01-25 15:49:17 +01:00
Benjamin Otte
a6845091f9 spinbutton: Make the entry gadget be the entry's gadget
This is a big and somewhat evil hack: We replace the entry's gadget's
node with the spinbutton's entry node.
2016-01-22 13:46:01 +01:00
Matthias Clasen
ea4cff1ea4 Use convenience API that was introduced recently
Use gtk_css_gadget_set_state in all the places where we previously
were getting a node from a gadget, just to call gtk_css_node_set_state.
2016-01-13 00:19:31 -05:00
Cosimo Cecchi
0401146896 spinbutton: fix a typo 2016-01-02 15:31:23 -08:00
Matthias Clasen
35c243b26f entry: use a gadget
Use a gadget for the entry. Selection and progress still
just use a CSS node. Most things seem to work correctly
with non-zero margin or padding.
2015-12-17 00:01:58 -05:00
Benjamin Otte
4dee06e04f spinbutton: Port the buttons to gadgets 2015-12-15 08:41:16 -05:00
Benjamin Otte
ad22612ab2 iconhelper: Require passing a cssnode to the constructor
Note that we don't use it yet.
2015-12-15 08:41:16 -05:00
Benjamin Otte
971a277419 cssnode: Change style-changed signal
Instead of having old and new style, now have a GtkCssStyleChange opaque
object that will compute the changes you are interested in for you.

This simplifies change signal handlers quite a bit and avoids lots of
repeated computation in every signal handler.
2015-12-12 02:16:04 +01:00
Benjamin Otte
ccfc4d3f12 iconhelper: Remove the context argument
Instead, use the widget's context.
2015-12-09 13:30:40 +01:00
Benjamin Otte
e95e2d5048 iconhelper: Get rid of _gtk_icon_helper_set_window()
Instead use the window of the owner widget.
2015-12-09 13:30:40 +01:00
Benjamin Otte
c9d1a45d30 iconhelper: Require a widget as construction argument
Note that the caller needs to ensure the widget lives as long as the
iconhelper as the iconhelper will not ref the widget.
2015-12-09 13:30:40 +01:00
Benjamin Otte
3513e5e87b Chain up in state_flags_changed
When introducing handlers for state_flags_changed in the node
transitions, chaining up was forgotten.
2015-12-02 04:36:31 +01:00
Timm Bäder
6489ec440f GtkSpinButton: Update node state on button release 2015-11-20 20:32:15 +01:00
Matthias Clasen
cf7bb4f2aa spin button: Fix initial button state
We can't use up_panel and down_panel as differentiators for the buttons,
because these window system resources don't exist before realize().
Just use a one-off enum for this purpose.

https://bugzilla.gnome.org/show_bug.cgi?id=758094
2015-11-20 11:40:55 -05:00
Matthias Clasen
43f822e70f Annotate deprecated style properties
Use G_PARAM_DEPRECATED with deprecated style properties.
This will make it easier to identify and remove such stale
properties from css, since it will now trigger warnings.
2015-11-16 15:13:33 -05:00
Matthias Clasen
ed2c14f4aa spinbutton: Document some style properties as deprecated
No code change.
2015-11-16 07:20:18 -05:00
Matthias Clasen
a24de82ced spinbutton: update node state more often
We need to update the entry_node state, and we should
update the node state initially.
2015-11-14 23:18:17 -05:00
Benjamin Otte
37b4b60e91 spinbutton: Use right state when querying padding 2015-11-06 18:59:15 +01:00
Matthias Clasen
65d959bbc8 spin button: Add diagrams to CSS documentation 2015-11-03 14:27:35 -05:00
Benjamin Otte
fc6f41c751 spinbutton: Don't set .entry
Also fix Adwaita to not use .entry anymore
2015-10-29 16:03:15 +01:00
Matthias Clasen
bb7d7851ac entry, spinbutton: Finish css node conversion
This commit creates entry and button subnodes for the buttons
in GtkSpinButton. The nodes are ordered like this for horizontal

  spinbutton
  + entry
    + image.left
    + image.right
    + progress
  + button.down
  + button.up

and like this for vertical ones:

  spinbutton
  + button.down
  + entry
  + button.up

This arrangement requires cooperation from GtkEntry to place
the entry subnodes correctly, and some small changes in the theme.

This commit also fixes progress rendering in vertical spin buttons.
2015-10-28 23:43:32 -04:00
Matthias Clasen
ebcad63e31 wip: spinbutton 2015-10-28 21:55:13 -04:00
Matthias Clasen
811c1c9484 spinbutton: Trivial cleanup
Use g_clear_object in a few places.
2015-10-28 21:55:13 -04:00
Alexander Larsson
d5f1754981 gtk: Stop setting GDK_EXPOSURE_MASK on random widgets
These days exposure happens only on the native windows (generally the
toplevel window) and is propagated down recursively. The expose event
is only useful for backwards compat, and in fact, for double buffered
widgets we totally ignore the event (and non-double buffering breaks
on wayland).

So, by not setting the mask we avoid emitting these events and then
later ignoring them.

We still keep it on eventbox, fixed and layout as these are used
in weird ways that want backwards compat.
2015-09-14 11:01:13 +02:00
Matthias Clasen
f263c11ce8 spin button: Add Home and End as key bindings
Make these go to the lower/upper boundary of the adjustment, like
Ctrl-PageUp/PageDown already do.
https://bugzilla.gnome.org/show_bug.cgi?id=309300
2015-07-19 17:17:53 -04:00
Matthias Clasen
d90847b20e GtkSpinButton: Stop using gtk_adjustment_value_changed
This is just an unnecessary indirection.
2015-05-10 02:34:33 -04:00
Matthias Clasen
eea16f03f5 Stop using GDK_POINTER_MOTION_HINT_MASK in widgets
It is deprecated and no longer needed, and,as observed in
https://bugzilla.gnome.org/show_bug.cgi?id=746253 it
interferes with turning off event compression.
2015-03-22 17:33:38 -04:00
Benjamin Otte
a24aee6bb2 spinbutton: Fix get_text_area_size for vertical spinbuttons
Commit c5905b13b9 changed the semantics of
this vfunc and get_entry_size but I only fixed one of them in the
spinbutton subclass.

https://bugzilla.gnome.org/show_bug.cgi?id=746282
2015-03-16 15:24:16 +01:00
Benjamin Otte
c5905b13b9 entry: Make code do what it's meant to do
With the 3.0 transition, this code went from just querying the entry's
height request to doing a full size request.
Then it got code to revert the features that a full size request does.
And then it grew code that manually computed the baseline.

Avoid this and just do what happened back in the days: Do a regular
height request.

This changes the semantics of the get_frame_size() vfunc wrt its
behavior towards subclasses overwriting the get_height() vfuncs, but I'm
happy to live with that.
2015-03-14 15:46:13 +01:00
Matthias Clasen
80dbb4186a GtkSpinButton: Use the proper state
Use the style contexts current state when querying it.
2014-11-26 18:38:43 -05:00
Matthias Clasen
9ca9fccace GtkSpinButton: Set the screen on the panel contexts
Failure to do so results in custom styling leaking through in
the inspector. This is pretty obvious, now that the inspector
is using a separate display connection and is generally isolated
from style changes.
2014-10-25 13:31:57 -04:00
Matthias Clasen
8889565735 GtkSpinButton: Simplify code
No need to explicitly specify a parser function, it will be
correctly guessed from the property type.
2014-10-19 22:07:19 -04:00
Benjamin Otte
998feeb2bc spinbutton: Set the correct state on the button contexts
With the recent save-is-child changes, using
  gtk_style_context_get_padding (context, different_state)
will now open a subelement.

This is not what we want, so we check the state whenever we get the
button contexts.
2014-10-16 17:18:34 +02:00
Carlos Garnacho
b7412a1d9b spinbutton: Make the swipe gesture only work on touch devices
This code was relying on the previous GtkGestureSingle::touch-only default
value.

https://bugzilla.gnome.org/show_bug.cgi?id=734285
2014-08-15 13:53:39 +02:00
Debarshi Ray
137abd6f70 GtkSpinButton: Prevent public API from unsetting the adjustment
A spin button really needs an adjustment to work. So don't let the
user unset the adjustment by passing NULL to
gtk_spin_button_set_adjustment.

https://bugzilla.gnome.org/show_bug.cgi?id=734660
2014-08-13 23:42:11 -04:00
Debarshi Ray
1e304e6deb GtkSpinButton: Always emit value-changed when the adjustment is changed
Changing adjustment via the property setter would not emit
value-changed, however changing it via gtk_spin_button_configure would.

This inconsistency had the following side-effects:

  - Setting an adjustment with a different value would not update the
    value shown by the spin button.

  - Creating a spin button like this (common in GtkBuilder XML) will
    not show the initial value:
      g_object_new (GTK_TYPE_SPIN_BUTTON, "adjustment", adj, NULL);

Let's use the same code path (ie. gtk_spin_button_configure) for all
public facing API for setting adjustment. The code that handled the
details of swapping out the old adjustment with the new has been split
into an unset_adjustment method and the rest has been folded into
gtk_spin_button_configure.

A spin button really needs an adjustment to work, so we don't need
most of the NULL checks. However we do need to check in
unset_adjustment because setting a new adjustment during object
creation might try to unset a non-existent one.

https://bugzilla.gnome.org/show_bug.cgi?id=734660
2014-08-13 23:42:11 -04:00
Debarshi Ray
225bb95795 GtkSpinButton: Only notify 'adjustment' if the property changed
https://bugzilla.gnome.org/show_bug.cgi?id=734649
2014-08-12 11:54:29 +02:00
Gergely POLONKAI
7f7084f7f5 GtkSpinButton: Document some signals
Based on a patch by Gergely Polonkai,
https://bugzilla.gnome.org/show_bug.cgi?id=733174
2014-07-19 18:34:58 -04:00
Matthias Clasen
f7c838ce5f Trivial: Use the canonical signal name 2014-07-19 18:34:58 -04:00
Matthias Clasen
87b7103db1 GtkSpinButton: Set orientable style classes initially
This was an omission, horizontal/vertical would only be set
when the orientation is changed.
2014-07-18 19:39:56 -04:00
Matthias Clasen
d03752cdcc GtkSpinButton: Use G_PARAM_EXPLICIT_NOTIFY 2014-06-09 13:31:10 -04:00
Carlos Garnacho
d05a9f9a7b gesture: Replace gtk_gesture_attach/detach with event controller API
Event controllers now auto-attach, and the GtkCapturePhase only determines
when are events dispatched, but all controllers are managed by the widget wrt
grabs.

All callers have been updated.
2014-05-27 17:47:12 +02:00
Carlos Garnacho
60e15deb83 spinbutton: Avoid touch text handles to pop up
Those get in the middle more than help on these widgets, the widget
is already packed with clickable areas and having handles (and their
invisible clickable area around) hovering above don't help, plus the
purpose in most likely numeric values is a bit doubtful.

All touch events are either consumed by the up/down panels, or
the swipe gesture, all GtkEntry handling of touch events on the text
window is avoided, so handles to not appear anymore.
2014-05-23 19:54:33 +02:00
Carlos Garnacho
d59c909663 spinbutton: Use GTK_PHASE_CAPTURE for touch swipes
The gesture must be able to catch first events for it to be seen
as recognized in event handlers.
2014-05-23 19:54:33 +02:00
Carlos Garnacho
d559cade42 spinbutton: Attach "swipe to spin" controllers to the bubble phase
It is unnecessary to have those process events manually, just attach
those to the bubble phase.
2014-05-23 19:54:31 +02:00
Carlos Garnacho
5369c77029 gesture: Simplify gesture/widget interaction public API
The propagation phase property/methods in GtkEventController are gone,
This is now set directly on the GtkWidget add/remove controller API,
which has been made private.

The only public bit now are the new functions gtk_gesture_attach() and
gtk_gesture_detach() that will use the private API underneath.

All callers have been updated.
2014-05-23 19:54:29 +02:00
Matthias Clasen
93b7883372 GtkSpinButton: Don't leak the gestures 2014-05-23 19:54:28 +02:00
Carlos Garnacho
6296aa84b2 spinbutton: increase/decrease value on upwards/downwards touch swipes
This is somewhat analogous to scroll events on pointer devices, the
greater the velocity, the faster the spinbutton spins.
2014-05-23 19:54:26 +02:00
Cosimo Cecchi
1627c903d8 spinbutton: remove unused code 2014-05-09 11:02:45 -07:00
Cosimo Cecchi
5a16ec366d spinbutton: remove unused code 2014-05-09 11:02:41 -07:00
William Jon McCann
469d333aa2 docs: use Returns: consistently
Instead of Return value:
2014-02-19 18:56:05 -05:00
Matthias Clasen
c779b42476 Docs: use // for comments in examples
Without sgml mode, we can't escape /* as /* anymore,
so just switch to // for comments in examples.
2014-02-14 23:34:22 -05:00
William Jon McCann
7a208fbbf3 docs: use proper apostrophe
https://wiki.gnome.org/Design/OS/Typography
2014-02-07 13:06:10 -05:00
William Jon McCann
63e887e165 docs: replace all <examples> with markdown headings 2014-02-04 16:58:54 -05:00
William Jon McCann
4c8bd8e7cf docs: Identify examples that are C code
https://bugzilla.gnome.org/show_bug.cgi?id=723119
2014-01-29 12:45:49 -05:00