Commit Graph

144 Commits

Author SHA1 Message Date
Matt Watson
7ad64a20aa switch: port to progress tracker 2016-04-08 16:09:30 -07:00
Benjamin Otte
41195f6300 switch: An active switch is :checked
Fix an oversight that should have happened in the gadget refactoring:
An active switch should be :checked, just like togglebuttons,
checkbuttons, etc.
2016-03-23 18:14:57 +01:00
Timm Bäder
1331b60029 A few more documentation fixes 2016-02-09 08:05:16 +01:00
Timm Bäder
680ec087ab switch: Don't queue draws after setting state flags 2016-02-04 20:00:21 +01:00
Timm Bäder
b8db48079f switch: Fix text positioning
https://bugzilla.gnome.org/show_bug.cgi?id=760509
2016-01-12 21:56:53 +01:00
Timm Bäder
a8ceeb1766 switch: Don't include margins in input window size
https://bugzilla.gnome.org/show_bug.cgi?id=760509
2016-01-12 21:56:53 +01:00
Matthias Clasen
abbd6b11f6 switch: Deprecate style properties
CSS min-width and min-height on the slider node fit this
perfectly. We still fall back to the slider-width and
slider-height style properties if the CSS properties are
not set.
2015-12-16 13:53:13 -05:00
Benjamin Otte
0f8233bd7b switch: Port to gadgets 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
Matthias Clasen
870461475a switch: Add a diagram to CSS node documentation 2015-11-03 14:27:35 -05:00
Matthias Clasen
bab20f1d10 trivial formatting fix 2015-10-31 19:23:47 -04:00
Matthias Clasen
7ea33d82ed Remove a duplicate include 2015-10-31 19:19:53 -04:00
Matthias Clasen
506d5b5b48 switch: Document css names a bit
This is still provisional. Better gtk-doc support will be needed
to do better here.
2015-10-22 23:27:43 -04:00
Matthias Clasen
48b30e8e91 switch: Convert to element names
Use the element names switch and slider for the two css nodes,
and drop the .trough and .slider classes.
2015-10-22 21:40:31 -04:00
Benjamin Otte
1f1c7547da switch: Use the right state when querying padding
We were using the state of the widget node, not the state of the slider
node.

This caused layout loops due to invalidations.
2015-10-22 18:43:55 +02:00
Benjamin Otte
950b1fb65c switch: Port to GtkCssNode
This is a simple port, no code modifications so far other than replacing
gtk_style_context_save() with gtk_style_context_save_to_node().
2015-10-22 16:42:46 +02:00
Matthias Clasen
83b8bcb63a switch: Unclip the slider shadow
This commit arranges things so the shadow of the slider can
extend outside the widget, even if the switch itself has no
shadow.

https://bugzilla.gnome.org/show_bug.cgi?id=755791
2015-10-03 16:20:50 -04:00
Matthias Clasen
1be338fd44 GtkSwitch: fix a reentry issue
The introduction of state broke some users which relied on
being able to set active in a notify::active handler.

https://bugzilla.gnome.org/show_bug.cgi?id=751754
2015-07-01 18:04:56 -07:00
Cosimo Cecchi
9913b02e3b switch: add a style property for the switch height
Instead of hardcoding an aspect ratio.
This will be replaced by min-height/max-height when we have them.

https://bugzilla.gnome.org/show_bug.cgi?id=751689
2015-06-30 13:28:26 -07: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
Chun-wei Fan
e31a936e3e gtkswitch.c: Fix Build on C89 Compilers
This file now uses round(), which was not available until C99, so include
fallback-c89.c instead of math.h, which includes math.h and does a fallback
implementation of round().
2015-03-03 12:14:24 +08:00
Benjamin Otte
da559c08f9 switch: Have a priv varibale in the constructor 2015-02-16 23:57:04 +01:00
Benjamin Otte
e1081bc471 switch: Change handle_x to handle_pos
Make that variable go from 0.0 to 1.0 where 0.0 means inactive (slider
is on the left) and 1.0 means active (slider is on the right).

The math is simpler that way and most importantly the value is
independent of size.
2015-02-16 23:57:04 +01:00
Benjamin Otte
86a41b108e switch: Get rid of offset member variable
We can compute it on-demand whereever we need it.
2015-02-16 23:57:04 +01:00
Benjamin Otte
1b171e812e switch: Remove unused variables from private struct 2015-02-16 23:57:03 +01:00
Benjamin Otte
abfc9cd4eb switch: Use trough style class by default
This allows animating the trough, and saves a save/restore pair.
2014-10-13 04:39:58 +02:00
Benjamin Otte
d1118071dd switch: Set PRELIGHT state on widget 2014-10-13 04:39:58 +02:00
Matthias Clasen
7a81aaf3c8 GtkSwitch: Use gtk_widget_add_tick_callback
This api automatically takes care of dealing with disappearing
frame clocks, which we currently forget to and pay with crashes.
2014-09-23 11:23:20 -04:00
Benjamin Otte
b5a8b7ef3b widget: Make _gtk_set_simple_clip() take an optional content clip 2014-08-21 00:54:07 +02:00
Matthias Clasen
5131472984 GtkSwitch: Initialize offset when beginning animation
handle_x always corresponds to the visible position of the handle,
which is where we want to start the animation. Without this, repeated
keyboard activation will not always animate.
2014-08-04 14:36:42 +02:00
Matthias Clasen
1569952d0e GtkSwitch: Update handle_x in size-allocate
Since we are storing positions here that depend on the allocation,
we need to update them in size-allocate. This fixes incorrect
positioning of the handle if the switch is active initially.

https://bugzilla.gnome.org/show_bug.cgi?id=734213
2014-08-04 14:36:42 +02:00
Matthias Clasen
2e85046b8f GtkSwitch: Don't store dest_offset
Instead, calculate it on the spot in the tick callback, and
update handle_x in gtk_switch_set_active, based on the new
active property.
2014-08-04 14:36:42 +02:00
Matthias Clasen
d4bd9e9c46 GtkSwitch: End animations on finalize
Handle the unlikely case that a switch gets finalized while its
toggle animation is running.
2014-08-04 14:36:42 +02:00
Matthias Clasen
007ba3bc14 GtkSwitch: End animation in set_active
End any running toggle animation before setting the set,
otherwise things get confused.
2014-08-04 14:36:42 +02:00
Matthias Clasen
8820c46ff0 GtkSwitch: Also animate for keyboard activation 2014-08-04 14:36:41 +02:00
Paolo Borelli
a0c89af801 GtkSwitch: implement animation 2014-08-03 10:22:41 +02:00
Paolo Borelli
22bd23adf3 GtkSwitch: remove unused assignment 2014-08-03 10:22:41 +02:00
Matthias Clasen
51a5cfc783 GtkSwitch: implement clipping
So switches can have shadows, too.

https://bugzilla.gnome.org/show_bug.cgi?id=733360
2014-07-18 16:37:18 -04:00
Jasper St. Pierre
fc75f459b0 gtkswitch: Fix docs 2014-06-29 19:10:42 -04:00
Matthias Clasen
1c57abb02b GtkSwitch: Implement hover for GtkSwitch
This makes switches more similar to other activatable widgets
like buttons or scales.
2014-06-21 21:34:50 -04:00
Matthias Clasen
eed1ae682b GtkSwitch: Use G_PARAM_EXPLICIT_NOTIFY 2014-06-09 13:31:12 -04:00
Carlos Garnacho
907e9f1946 gtk: Update GtkGesture users to the GtkPropagationPhase semantics change
Mainly doing s/TARGET/BUBBLE/ on the fully ported widgets, but GtkTreeView
where the double click handler has moved to GTK_PHASE_TARGET so it runs
parallelly to the still existing event handlers.
2014-05-27 17:47:12 +02: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
ad6606e8af gtk: Update callers of GtkGesturePan orientation 2014-05-27 17:47:12 +02:00
Carlos Garnacho
8f20780fb9 switch: Use GtkGesture to handle input events
A pan gesture is used to handle switch dragging, which is only triggered
by horizontal panning movements. A multipress gesture handles the cases
where clicking without dragging happens, just toggling the switch.
2014-05-23 19:54:32 +02:00
Cosimo Cecchi
92d23be47d switch: don't use focus-line-width 2014-05-09 11:02:45 -07:00
Cosimo Cecchi
ceab6ee15d switch: don't use focus padding 2014-05-09 11:02:42 -07:00
Benjamin Otte
ddbd71e22a switch: Remove unneeded checks
Size vfuncs always get non-null out variables passed, so no need to
check for NULL.
2014-05-01 14:51:28 +02:00
Matthias Clasen
7b11f761b3 switch: Add a delayed state capability
This commit makes it possible for GtkSwitch to indicate when
the underlying state changes with a delay, causing the switch
to temporarily go 'out of sync' with the underlying change.

https://bugzilla.gnome.org/show_bug.cgi?id=725648
2014-04-06 01:52:47 -04:00
William Jon McCann
469d333aa2 docs: use Returns: consistently
Instead of Return value:
2014-02-19 18:56:05 -05:00
William Jon McCann
2a45418b67 docs: use proper quotes 2014-02-05 15:08:42 -05:00
Alejandro Piñeiro
ef41c2a60f a11y: Remove default description from GtkSwitch
https://bugzilla.gnome.org/show_bug.cgi?id=707926
2013-09-12 11:52:51 +02:00
Matthias Clasen
0aa57d26b5 Move wholly deprecated classes to gtk/deprecated/
We've recently a number of classes wholly. For these cases,
move the headers and sources to gtk/deprecated/ and adjust
Makefiles and includes accordingly.

Affected classes:
GtkAction
GtkActionGroup
GtkActivatable
GtkIconFactory
GtkImageMenuItem
GtkRadioAction
GtkRecentAction
GtkStock
GtkToggleAction
GtkUIManager
2013-07-19 21:39:47 -04:00
Emmanuele Bassi
0899ef7cc9 gtk: Use new macros for defining private data
https://bugzilla.gnome.org/show_bug.cgi?id=702996
2013-07-09 09:30:02 +01:00
William Jon McCann
c96a1c4980 Deprecate GtkAction and GtkUIManager
It is recommended to use GAction et al and GtkBuilder.
2013-06-30 11:19:50 -04:00
Bastien Nocera
41b07bdc96 GtkSwitch: Don't handle events from extra mouse buttons
Also use GDK_EVENT_{STOP,PROPAGATE} to make return
values clearer.

https://bugzilla.gnome.org/show_bug.cgi?id=696640
2013-05-18 14:49:55 +02:00
Juan Pablo Ugarte
1a06842425 GtkSwitch: moved focus drawing from outside border inside the handle. 2013-04-16 03:16:43 -03:00
Alexander Larsson
3d4cd4db3e Add gtk_widget_(un)register_window
This replaces the previously hardcoded calls to gdk_window_set_user_data,
and also lets us track which windows are a part of a widget. Old code
should continue working as is, but new features that require the
windows may not work perfectly.

We need this for the transparent widget support to work, as we need
to specially mark the windows of child widgets.

https://bugzilla.gnome.org/show_bug.cgi?id=687842
2013-02-07 11:11:37 +01:00
Benjamin Otte
82a6106920 switch: Remove hack to change text size
The same effect can now be achieved via
  .switch { font-size: smaller; }
so there is no need to hardcode things.
2012-12-06 02:57:18 +01:00
Ryan Lortie
fbb38e95ac port GtkSwitch to GtkActionHelper 2012-08-20 13:11:01 -04:00
Benjamin Otte
04c5fdaca6 css: Remove old animation code
Deprecate public API where appropriate and make it no-ops.
Remove all calls to it.
Get rid of the 'transition' css property.

For now, this means spinners don't animate anymore.
2012-04-17 08:59:19 +02:00
Benjamin Otte
8e17f9c233 switch: Set ACTIVE state flag with is_active property 2012-04-17 08:59:15 +02:00
Javier Jardón
9d0febc9a6 Change FSF Address 2012-02-27 17:06:11 +00:00
Ryan Lortie
ab91527032 Rename gtk_application_window_get_observer
This should have been called _create_observer

https://bugzilla.gnome.org/show_bug.cgi?id=667394

Fixup switch
2012-01-11 00:26:47 -05:00
Matthias Clasen
fdc2e29d69 GtkSwitch: Implement GtkActionable 2012-01-11 00:10:34 -05:00
Matthias Clasen
c83db6cdf0 GtkSwitch: Return FALSE from the button press handler
This makes the behavior identical to other widgets which
handle button presses, and it avoids problems when placing
switches into a windows main toolbar.

https://bugzilla.gnome.org/show_bug.cgi?id=656986
2011-08-23 23:29:19 -04:00
Matthias Clasen
2ba9c4b4a7 Make focus rectangles optional
This commit introduces a new setting, gtk-visible-focus, backed
by the Gtk/VisibleFocus X setting. Its three values control how
focus rectangles are displayed.

'always' is equivalent to the traditional GTK+ behaviour of always
rendering focus rectangles.

'never' does what it says, and is intended for keyboardless
situations, e.g. tablets.

'automatic' hides focus rectangles initially, until the user
interacts with the keyboard, at which point focus rectangles
become visible.

https://bugzilla.gnome.org/show_bug.cgi?id=649567
2011-08-10 16:34:20 +02:00
Matthias Clasen
3e05518881 Drop unneeded includes
We no longer use the private GtkAccessible api here.
2011-07-14 19:40:50 -04:00
Matthias Clasen
eb81d45024 Move GtkSwitchAccessible to a11y/ 2011-07-05 16:10:25 -04:00
Matthias Clasen
775ccf39e7 Initial conversion of GailWidget to GtkWidgetAccessible 2011-07-05 16:09:57 -04:00
Matthias Clasen
17e219fbce Remove debug spew 2011-07-05 16:08:01 -04:00
Matthias Clasen
054057a640 Fix GtkSwitchAccessible type definition
It turns out that ATK_DEFINE_TYPE_WITH_CODE() is broken; it
tells GType that the class and instance size for the accessible
type are the same as for its parent type. Which is not true
if your instance struct has members such as 'description' here.
This was causing hard-to-track-down memory corruption, since
description and the GtkAccessible private pointer were sharing
the same memory location.
2011-07-05 16:08:00 -04:00
Matthias Clasen
5eb8ca1882 Remove unnecessary includes
gtkstyle.h is similarly unused.
2011-06-16 23:35:24 -04:00
Cosimo Cecchi
6c3c26d9c3 switch: hardcode a smaller font size for the switch label
This should not really be done here, but we can't override font size
from the theme just yet.

https://bugzilla.gnome.org/show_bug.cgi?id=645458
2011-03-23 10:00:01 -04:00
Cosimo Cecchi
55c86bd44d switch: fix boundaries for the switch motion
We were ignoring the focus ring padding, and we were incorrectly setting
handle_x to padding.left, while the draw handler already takes padding
into account while redrawing.

https://bugzilla.gnome.org/show_bug.cgi?id=645134
2011-03-18 09:52:58 -04:00
Cosimo Cecchi
8da124aa1f Cleanup unused variables 2011-03-03 17:48:26 -05:00
Cosimo Cecchi
ea7661cb3f switch: remove slider padding from available allocation when drawing
This also simplifies the code a bit, and makes previous workarounds
useless.
2011-03-03 17:48:25 -05:00
Cosimo Cecchi
6abbd68674 switch: fetch the padding values from the slider
It's the slider which acts as a child inside the container through, so
we should fetch the slider padding when computing height/width.
2011-03-03 17:48:25 -05:00
Cosimo Cecchi
c310c35a7a switch: propagate the active state to the slider 2011-03-03 17:48:25 -05:00
Matthias Clasen
46cc85fd7e GtkSwitch: use regular activation
GtkSwitch was listening for Space/Enter keyreleases itself, instead
of providing an 'activate' action signal, like e.g GtkButton. As a
side-effect, this fixes
https://bugzilla.gnome.org/show_bug.cgi?id=643321
2011-02-25 15:47:03 -05:00
Matthias Clasen
6d3b8c2c6b GtkSwitch: Add an AtkAction implementation 2011-02-17 23:06:33 -05:00
Matthias Clasen
163f0daf6a GtkSwitch: Use ATK_DEFINE_TYPE properly 2011-02-17 21:55:54 -05:00
Matthias Clasen
221415f71f Use _gtk_accessible_set_factory_type in GtkSwitch 2011-02-17 01:32:24 -05:00
Thomas Wood
0c6251d0d2 switch: allow the user to toggle the switch by clicking on the handle 2011-01-12 18:50:45 -05:00
Matthias Clasen
b5c6904c2f Drop explicit includes of gdkkeysyms.h
These are no longer needed. At the same time, port gtkimcontextsimpleseqs.h
to use the new GDK_KEY_ symbols.
2011-01-04 12:21:41 -05:00
Carlos Garnacho
cb21085187 GtkSwitch: remove deprecated call. 2011-01-04 03:06:11 +01:00
Carlos Garnacho
029fb53ac2 Make GtkSwitch use GtkStyleContext 2010-12-28 19:25:48 +01:00
Emmanuele Bassi
b9859de917 switch: Fix the attribution line
Thomas Wood pointed out that the original MxGtkLightSwitch widget upon
which I based the behaviour of GtkSwitch was not written by him; the
original authors are:

  Joshua Lock
  Robert Staudinger
  Jussi Kukkonen

My apologies to all of them.
2010-11-30 21:54:48 +00:00
Matthias Clasen
2fffce2c23 Forgotten changes 2010-11-29 16:47:45 -05:00
Javier Jardón
f07480eb44 GtkSwitch: Add missing "Since: 3.0" tags 2010-11-29 22:00:49 +01:00
Emmanuele Bassi
1f71d641e8 switch: Use ATK macros to reduce the amount of code
And the insanity.

Reviewed-by: Christian Persch <chpe@gnome.org>
2010-11-29 14:06:02 +00:00
Emmanuele Bassi
9ad31a5a21 switch: Use the right value for comparison 2010-11-29 13:23:28 +00:00
Emmanuele Bassi
ae95cdf8fc switch: Add accessibility implementation
Modelled on GailToggleButton.

https://bugzilla.gnome.org/show_bug.cgi?id=634987
2010-11-29 12:52:10 +00:00
Emmanuele Bassi
0cd0e4091f Add GtkSwitch, a "light-switch" like widget
The GtkSwitch widget is a simple UI control that has two states: on and
off. Toggling between the states is possible by clicking the widget or
by dragging the handle.

https://bugzilla.gnome.org/show_bug.cgi?id=634987
2010-11-29 12:52:10 +00:00