Debian Codegraph @

gtk/gtkswitch.c

raw symbols SCIP
1 /* GTK - The GIMP Toolkit
2 *
3 * Copyright (C) 2010 Intel Corporation
4 * Copyright (C) 2010 RedHat, Inc.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * Author:
20 * Emmanuele Bassi <[email protected]>
21 * Matthias Clasen <[email protected]>
22 *
23 * Based on similar code from Mx.
24 */
25
26 /**
27 * GtkSwitch:
28 *
29 * Shows a "light switch" that has two states: on or off.
30 *
31 * <picture>
32 * <source srcset="switch-dark.png" media="(prefers-color-scheme: dark)">
33 * <img alt="An example GtkSwitch" src="switch.png">
34 * </picture>
35 *
36 * The user can control which state should be active by clicking the
37 * empty area, or by dragging the slider.
38 *
39 * `GtkSwitch` can also express situations where the underlying state changes
40 * with a delay. In this case, the slider position indicates the user's recent
41 * change (represented by the [[email protected]:active] property), while the
42 * trough color indicates the present underlying state (represented by the
43 * [[email protected]:state] property).
44 *
45 * <picture>
46 * <source srcset="switch-state-dark.png" media="(prefers-color-scheme: dark)">
47 * <img alt="GtkSwitch with delayed state change" src="switch-state.png">
48 * </picture>
49 *
50 * See [[email protected]::state-set] for details.
51 *
52 * # Shortcuts and Gestures
53 *
54 * `GtkSwitch` supports pan and drag gestures to move the slider.
55 *
56 * # CSS nodes
57 *
58 * ```
59 * switch
60 * ├── image
61 * ├── image
62 * ╰── slider
63 * ```
64 *
65 * `GtkSwitch` has four css nodes, the main node with the name switch and
66 * subnodes for the slider and the on and off images. Neither of them is
67 * using any style classes.
68 *
69 * # Accessibility
70 *
71 * `GtkSwitch` uses the [[email protected]] role.
72 */
73
74 #include "config.h"cxx . . $ `<file>/build/config.h`/
75
76 #include "gtkswitch.h"cxx . . $ `<file>/gtk/gtkswitch.h`/
77
78 #include "gtkactionable.h"cxx . . $ `<file>/gtk/gtkactionable.h`/
79 #include "gtkactionhelperprivate.h"cxx . . $ `<file>/gtk/gtkactionhelperprivate.h`/
80 #include "gtkgestureclick.h"cxx . . $ `<file>/gtk/gtkgestureclick.h`/
81 #include "gtkgesturepan.h"cxx . . $ `<file>/gtk/gtkgesturepan.h`/
82 #include "gtkgesturesingle.h"cxx . . $ `<file>/gtk/gtkgesturesingle.h`/
83 #include "gtkgizmoprivate.h"cxx . . $ `<file>/gtk/gtkgizmoprivate.h`/
84 #include "gtkimage.h"cxx . . $ `<file>/gtk/gtkimage.h`/
85 #include "gtkcustomlayout.h"cxx . . $ `<file>/gtk/gtkcustomlayout.h`/
86 #include "gtkmarshalers.h"cxx . . $ `<file>/build/gtk/gtkmarshalers.h`/
87 #include "gtkprivate.h"cxx . . $ `<file>/gtk/gtkprivate.h`/
88 #include "gtkprogresstrackerprivate.h"cxx . . $ `<file>/gtk/gtkprogresstrackerprivate.h`/
89 #include "gtksettingsprivate.h"cxx . . $ `<file>/gtk/gtksettingsprivate.h`/
90 #include "gtkwidgetprivate.h"cxx . . $ `<file>/gtk/gtkwidgetprivate.h`/
91
92 typedef struct _GtkSwitchClasscxx . . $ _GtkSwitchClass# GtkSwitchClasscxx . . $ GtkSwitchClass#;
93
94 struct _GtkSwitchcxx . . $ _GtkSwitch#
95 {
96 GtkWidgetcxx . . $ GtkWidget# parent_instancecxx . . $ _GtkSwitch#parent_instance.;
97
98 GtkActionHelpercxx . . $ GtkActionHelper# *action_helpercxx . . $ _GtkSwitch#action_helper.;
99
100 GtkGesturecxx . . $ GtkGesture# *pan_gesturecxx . . $ _GtkSwitch#pan_gesture.;
101 GtkGesturecxx . . $ GtkGesture# *click_gesturecxx . . $ _GtkSwitch#click_gesture.;
102
103 double handle_poscxx . . $ _GtkSwitch#handle_pos.;
104 guintcxx . . $ guint# tick_idcxx . . $ _GtkSwitch#tick_id.;
105
106 guintcxx . . $ guint# statecxx . . $ _GtkSwitch#state. : 1;
107 guintcxx . . $ guint# is_activecxx . . $ _GtkSwitch#is_active. : 1;
108
109 GtkProgressTrackercxx . . $ GtkProgressTracker# trackercxx . . $ _GtkSwitch#tracker.;
110
111 GtkWidgetcxx . . $ GtkWidget# *on_imagecxx . . $ _GtkSwitch#on_image.;
112 GtkWidgetcxx . . $ GtkWidget# *off_imagecxx . . $ _GtkSwitch#off_image.;
113 GtkWidgetcxx . . $ GtkWidget# *slidercxx . . $ _GtkSwitch#slider.;
114 };
115
116 struct _GtkSwitchClasscxx . . $ _GtkSwitchClass#
117 {
118 GtkWidgetClasscxx . . $ GtkWidgetClass# parent_classcxx . . $ _GtkSwitchClass#parent_class.;
119
120 void (* activatecxx . . $ _GtkSwitchClass#activate.) (GtkSwitchcxx . . $ GtkSwitch# *self);
121
122 gbooleancxx . . $ gboolean# (* state_setcxx . . $ _GtkSwitchClass#state_set.) (GtkSwitchcxx . . $ GtkSwitch# *self,
123 gbooleancxx . . $ gboolean# state);
124 };
125
126 enumcxx . . $ $anonymous_type_440b2ef6fc7d13bc_0#
127 {
128 PROP_0cxx . . $ PROP_0.,
129 PROP_ACTIVEcxx . . $ PROP_ACTIVE.,
130 PROP_STATEcxx . . $ PROP_STATE.,
131 LAST_PROPcxx . . $ LAST_PROP.,
132 PROP_ACTION_NAMEcxx . . $ PROP_ACTION_NAME.,
133 PROP_ACTION_TARGETcxx . . $ PROP_ACTION_TARGET.
134 };
135
136 enumcxx . . $ $anonymous_type_440b2ef6fc7d13bc_1#
137 {
138 ACTIVATEcxx . . $ ACTIVATE.,
139 STATE_SETcxx . . $ STATE_SET.,
140 LAST_SIGNALcxx . . $ LAST_SIGNAL.
141 };
142
143 static guintcxx . . $ guint# signalscxx . . $ signals.[LAST_SIGNALcxx . . $ LAST_SIGNAL.] = { 0 };
144
145 static GParamSpeccxx . . $ GParamSpec# *switch_propscxx . . $ switch_props.[LAST_PROPcxx . . $ LAST_PROP.] = { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, };
146
147 static void gtk_switch_actionable_iface_initcxx . . $ gtk_switch_actionable_iface_init(16d04ea56a00f533). (GtkActionableInterfacecxx . . $ GtkActionableInterface# *iface);
148
149 G_DEFINE_TYPE_WITH_CODEcxx . . $ `<external>/9567554376676449156/gtype.h:1850:9`! (GtkSwitch, gtk_switch, GTK_TYPE_WIDGETcxx . . $ `gtk/gtkwidget.h:43:9`!,
150 G_IMPLEMENT_INTERFACEcxx . . $ `<external>/9567554376676449156/gtype.h:2115:9`! (GTK_TYPE_ACTIONABLEcxx . . $ `gtk/gtkactionable.h:27:9`!,
151 gtk_switch_actionable_iface_init))
152
153 static gbooleancxx . . $ gboolean#
154 is_right_sidecxx . . $ is_right_side(65d75a856eec1919). (GtkWidgetcxx . . $ GtkWidget# *widget,
155 gbooleancxx . . $ gboolean# active)
156 {
157 if (_gtk_widget_get_directioncxx . . $ _gtk_widget_get_direction(a6537c3bfdacec30). (widget) == GTK_TEXT_DIR_LTRcxx . . $ GTK_TEXT_DIR_LTR.)
158 return active;
159 else
160 return !active;
161 }
162
163 static void
164 gtk_switch_end_toggle_animationcxx . . $ gtk_switch_end_toggle_animation(850a5ed6347ff5eb). (GtkSwitchcxx . . $ GtkSwitch# *self)
165 {
166 if (self->tick_idcxx . . $ _GtkSwitch#tick_id. != 0)
167 {
168 gtk_widget_remove_tick_callbackcxx . . $ gtk_widget_remove_tick_callback(e71da402967e6e4b). (GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self), self->tick_idcxx . . $ _GtkSwitch#tick_id.);
169 self->tick_idcxx . . $ _GtkSwitch#tick_id. = 0;
170 }
171 }
172
173 static gbooleancxx . . $ gboolean#
174 gtk_switch_on_frame_clock_updatecxx . . $ gtk_switch_on_frame_clock_update(d70983e0fefb11f). (GtkWidgetcxx . . $ GtkWidget# *widget,
175 GdkFrameClockcxx . . $ GdkFrameClock# *clock,
176 gpointercxx . . $ gpointer# user_data)
177 {
178 GtkSwitchcxx . . $ GtkSwitch# *self = GTK_SWITCHcxx . . $ `gtk/gtkswitch.h:37:9`! (widget);
179 double progress;
180
181 gtk_progress_tracker_advance_framecxx . . $ gtk_progress_tracker_advance_frame(7bf6683cbbaeba3e). (&self->trackercxx . . $ _GtkSwitch#tracker.,
182 gdk_frame_clock_get_frame_timecxx . . $ gdk_frame_clock_get_frame_time(417c30ec8704d8fe). (clock));
183
184 if (gtk_progress_tracker_get_statecxx . . $ gtk_progress_tracker_get_state(cef4b9c3257cded0). (&self->trackercxx . . $ _GtkSwitch#tracker.) != GTK_PROGRESS_STATE_AFTERcxx . . $ GTK_PROGRESS_STATE_AFTER.)
185 {
186 progress = gtk_progress_tracker_get_ease_out_cubiccxx . . $ gtk_progress_tracker_get_ease_out_cubic(b4682671a7b8a656). (&self->trackercxx . . $ _GtkSwitch#tracker., FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!);
187 if (is_right_sidecxx . . $ is_right_side(65d75a856eec1919). (widget, self->is_activecxx . . $ _GtkSwitch#is_active.))
188 self->handle_poscxx . . $ _GtkSwitch#handle_pos. = 1.0 - progress;
189 else
190 self->handle_poscxx . . $ _GtkSwitch#handle_pos. = progress;
191 }
192 else
193 {
194 gtk_switch_set_activecxx . . $ gtk_switch_set_active(7a6c7e8084d1b078). (self, !self->is_activecxx . . $ _GtkSwitch#is_active.);
195 }
196
197 gtk_widget_queue_allocatecxx . . $ gtk_widget_queue_allocate(d7cf858254b37903). (GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self));
198
199 return G_SOURCE_CONTINUEcxx . . $ `<external>/1856471541377536744/gmain.h:485:9`!;
200 }
201
202 #define ANIMATION_DURATIONcxx . . $ `gtk/gtkswitch.c:202:9`! 100
203
204 static void
205 gtk_switch_begin_toggle_animationcxx . . $ gtk_switch_begin_toggle_animation(850a5ed6347ff5eb). (GtkSwitchcxx . . $ GtkSwitch# *self)
206 {
207 if (gtk_settings_get_enable_animationscxx . . $ gtk_settings_get_enable_animations(8c2d6b4329623181). (gtk_widget_get_settingscxx . . $ gtk_widget_get_settings(ffe4fbf99830fa29). (GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self))))
208 {
209 gtk_progress_tracker_startcxx . . $ gtk_progress_tracker_start(3b78ad0d90561db6). (&self->trackercxx . . $ _GtkSwitch#tracker., 1000 * ANIMATION_DURATIONcxx . . $ `gtk/gtkswitch.c:202:9`!, 0, 1.0);
210 if (self->tick_idcxx . . $ _GtkSwitch#tick_id. == 0)
211 self->tick_idcxx . . $ _GtkSwitch#tick_id. = gtk_widget_add_tick_callbackcxx . . $ gtk_widget_add_tick_callback(358f9307fc320412). (GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self),
212 gtk_switch_on_frame_clock_updatecxx . . $ gtk_switch_on_frame_clock_update(d70983e0fefb11f).,
213 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
214 }
215 else
216 {
217 gtk_switch_set_activecxx . . $ gtk_switch_set_active(7a6c7e8084d1b078). (self, !self->is_activecxx . . $ _GtkSwitch#is_active.);
218 }
219 }
220
221 static void
222 gtk_switch_click_gesture_pressedcxx . . $ gtk_switch_click_gesture_pressed(14106ee8f361b3c0). (GtkGestureClickcxx . . $ GtkGestureClick# *gesture,
223 int n_press,
224 double x,
225 double y,
226 GtkSwitchcxx . . $ GtkSwitch# *self)
227 {
228 graphene_rect_tcxx . . $ graphene_rect_t# switch_bounds;
229
230 if (!gtk_widget_compute_boundscxx . . $ gtk_widget_compute_bounds(167d30efbd6565d7). (GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self), GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self), &switch_bounds))
231 return;
232
233 /* If the press didn't happen in the draggable handle,
234 * cancel the pan gesture right away
235 */
236 if ((self->is_activecxx . . $ _GtkSwitch#is_active. && x <= switch_bounds.sizecxx . . $ _graphene_rect_t#size..widthcxx . . $ _graphene_size_t#width. / 2.0) ||
237 (!self->is_activecxx . . $ _GtkSwitch#is_active. && x > switch_bounds.sizecxx . . $ _graphene_rect_t#size..widthcxx . . $ _graphene_size_t#width. / 2.0))
238 gtk_gesture_set_statecxx . . $ gtk_gesture_set_state(e8b82f7bdf7c1c23). (self->pan_gesturecxx . . $ _GtkSwitch#pan_gesture., GTK_EVENT_SEQUENCE_DENIEDcxx . . $ GTK_EVENT_SEQUENCE_DENIED.);
239 }
240
241 static void
242 gtk_switch_click_gesture_releasedcxx . . $ gtk_switch_click_gesture_released(14106ee8f361b3c0). (GtkGestureClickcxx . . $ GtkGestureClick# *gesture,
243 int n_press,
244 double x,
245 double y,
246 GtkSwitchcxx . . $ GtkSwitch# *self)
247 {
248 GdkEventSequencecxx . . $ GdkEventSequence# *sequence;
249
250 sequence = gtk_gesture_single_get_current_sequencecxx . . $ gtk_gesture_single_get_current_sequence(eacc6d2458a1513d). (GTK_GESTURE_SINGLEcxx . . $ `gtk/gtkgesturesingle.h:32:9`! (gesture));
251
252 if (gtk_widget_containscxx . . $ gtk_widget_contains(84712ec851a55548). (GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self), x, y) &&
253 gtk_gesture_handles_sequencecxx . . $ gtk_gesture_handles_sequence(6aa08b709753b55f). (GTK_GESTUREcxx . . $ `gtk/gtkgesture.h:32:9`! (gesture), sequence))
254 {
255 gtk_gesture_set_statecxx . . $ gtk_gesture_set_state(e8b82f7bdf7c1c23). (GTK_GESTUREcxx . . $ `gtk/gtkgesture.h:32:9`! (gesture), GTK_EVENT_SEQUENCE_CLAIMEDcxx . . $ GTK_EVENT_SEQUENCE_CLAIMED.);
256 gtk_switch_begin_toggle_animationcxx . . $ gtk_switch_begin_toggle_animation(850a5ed6347ff5eb). (self);
257 }
258 }
259
260 static void
261 gtk_switch_pan_gesture_pancxx . . $ gtk_switch_pan_gesture_pan(5767e33d42406c83). (GtkGesturePancxx . . $ GtkGesturePan# *gesture,
262 GtkPanDirectioncxx . . $ GtkPanDirection# direction,
263 double offset,
264 GtkSwitchcxx . . $ GtkSwitch# *self)
265 {
266 GtkWidgetcxx . . $ GtkWidget# *widget = GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self);
267 int width;
268
269 width = gtk_widget_get_widthcxx . . $ gtk_widget_get_width(9247ef2dc26c5426). (widget);
270
271 if (direction == GTK_PAN_DIRECTION_LEFTcxx . . $ GTK_PAN_DIRECTION_LEFT.)
272 offset = -offset;
273
274 gtk_gesture_set_statecxx . . $ gtk_gesture_set_state(e8b82f7bdf7c1c23). (GTK_GESTUREcxx . . $ `gtk/gtkgesture.h:32:9`! (gesture), GTK_EVENT_SEQUENCE_CLAIMEDcxx . . $ GTK_EVENT_SEQUENCE_CLAIMED.);
275
276 if (is_right_sidecxx . . $ is_right_side(65d75a856eec1919). (widget, self->is_activecxx . . $ _GtkSwitch#is_active.))
277 offset += width / 2;
278
279 offset /= width / 2;
280 /* constrain the handle within the trough width */
281 self->handle_poscxx . . $ _GtkSwitch#handle_pos. = CLAMPcxx . . $ `<external>/12741050725406041920/gmacros.h:984:9`! (offset, 0, 1.0);
282
283 /* we need to redraw the handle */
284 gtk_widget_queue_allocatecxx . . $ gtk_widget_queue_allocate(d7cf858254b37903). (widget);
285 }
286
287 static void
288 gtk_switch_pan_gesture_drag_endcxx . . $ gtk_switch_pan_gesture_drag_end(42a538f732e1bee5). (GtkGestureDragcxx . . $ GtkGestureDrag# *gesture,
289 double x,
290 double y,
291 GtkSwitchcxx . . $ GtkSwitch# *self)
292 {
293 GtkWidgetcxx . . $ GtkWidget# *widget = GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self);
294 GdkEventSequencecxx . . $ GdkEventSequence# *sequence;
295 gbooleancxx . . $ gboolean# active;
296
297 sequence = gtk_gesture_single_get_current_sequencecxx . . $ gtk_gesture_single_get_current_sequence(eacc6d2458a1513d). (GTK_GESTURE_SINGLEcxx . . $ `gtk/gtkgesturesingle.h:32:9`! (gesture));
298
299 if (gtk_gesture_get_sequence_statecxx . . $ gtk_gesture_get_sequence_state(7ed3205cdc9bf84c). (GTK_GESTUREcxx . . $ `gtk/gtkgesture.h:32:9`! (gesture), sequence) == GTK_EVENT_SEQUENCE_CLAIMEDcxx . . $ GTK_EVENT_SEQUENCE_CLAIMED.)
300 {
301 /* if half the handle passed the middle of the switch, then we
302 * consider it to be on
303 */
304 if (_gtk_widget_get_directioncxx . . $ _gtk_widget_get_direction(a6537c3bfdacec30). (widget) == GTK_TEXT_DIR_LTRcxx . . $ GTK_TEXT_DIR_LTR.)
305 active = self->handle_poscxx . . $ _GtkSwitch#handle_pos. >= 0.5;
306 else
307 active = self->handle_poscxx . . $ _GtkSwitch#handle_pos. <= 0.5;
308 }
309 else if (!gtk_gesture_handles_sequencecxx . . $ gtk_gesture_handles_sequence(6aa08b709753b55f). (self->click_gesturecxx . . $ _GtkSwitch#click_gesture., sequence))
310 active = self->is_activecxx . . $ _GtkSwitch#is_active.;
311 else
312 return;
313
314 self->handle_poscxx . . $ _GtkSwitch#handle_pos. = is_right_sidecxx . . $ is_right_side(65d75a856eec1919). (widget, active) ? 1.0 : 0.0;
315 gtk_switch_set_activecxx . . $ gtk_switch_set_active(7a6c7e8084d1b078). (self, active);
316 gtk_widget_queue_allocatecxx . . $ gtk_widget_queue_allocate(d7cf858254b37903). (widget);
317 }
318
319 static void
320 gtk_switch_activatecxx . . $ gtk_switch_activate(850a5ed6347ff5eb). (GtkSwitchcxx . . $ GtkSwitch# *self)
321 {
322 gtk_switch_begin_toggle_animationcxx . . $ gtk_switch_begin_toggle_animation(850a5ed6347ff5eb). (self);
323 }
324
325 static void
326 gtk_switch_measurecxx . . $ gtk_switch_measure(d91afbd837fc0c19). (GtkWidgetcxx . . $ GtkWidget# *widget,
327 GtkOrientationcxx . . $ GtkOrientation# orientation,
328 int for_size,
329 int *minimum,
330 int *natural,
331 int *minimum_baseline,
332 int *natural_baseline)
333 {
334 GtkSwitchcxx . . $ GtkSwitch# *self = GTK_SWITCHcxx . . $ `gtk/gtkswitch.h:37:9`! (widget);
335 int slider_minimum, slider_natural;
336 int on_nat, off_nat;
337 int on_baseline, off_baseline;
338
339 gtk_widget_measurecxx . . $ gtk_widget_measure(d91afbd837fc0c19). (self->slidercxx . . $ _GtkSwitch#slider., orientation, -1,
340 &slider_minimum, &slider_natural,
341 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
342
343 gtk_widget_measurecxx . . $ gtk_widget_measure(d91afbd837fc0c19). (self->on_imagecxx . . $ _GtkSwitch#on_image., orientation, for_size, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &on_nat, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &on_baseline);
344 gtk_widget_measurecxx . . $ gtk_widget_measure(d91afbd837fc0c19). (self->off_imagecxx . . $ _GtkSwitch#off_image., orientation, for_size, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &off_nat, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &off_baseline);
345
346 if (orientation == GTK_ORIENTATION_HORIZONTALcxx . . $ GTK_ORIENTATION_HORIZONTAL.)
347 {
348 int text_width = MAXcxx . . $ `<external>/12741050725406041920/gmacros.h:975:9`! (on_nat, off_nat);
349 *minimum = 2 * MAXcxx . . $ `<external>/12741050725406041920/gmacros.h:975:9`! (slider_minimum, text_width);
350 *natural = 2 * MAXcxx . . $ `<external>/12741050725406041920/gmacros.h:975:9`! (slider_natural, text_width);
351 }
352 else
353 {
354 int text_height = MAXcxx . . $ `<external>/12741050725406041920/gmacros.h:975:9`! (on_nat, off_nat);
355
356 *minimum = MAXcxx . . $ `<external>/12741050725406041920/gmacros.h:975:9`! (slider_minimum, text_height);
357 *natural = MAXcxx . . $ `<external>/12741050725406041920/gmacros.h:975:9`! (slider_natural, text_height);
358
359 *minimum_baseline = MAXcxx . . $ `<external>/12741050725406041920/gmacros.h:975:9`! (on_baseline, off_baseline) + MAXcxx . . $ `<external>/12741050725406041920/gmacros.h:975:9`! ((slider_minimum - text_height) / 2, 0);
360 *natural_baseline = MAXcxx . . $ `<external>/12741050725406041920/gmacros.h:975:9`! (on_baseline, off_baseline) + MAXcxx . . $ `<external>/12741050725406041920/gmacros.h:975:9`! ((slider_natural - text_height) / 2, 0);
361 }
362 }
363
364 static void
365 gtk_switch_allocatecxx . . $ gtk_switch_allocate(598a503332136822). (GtkWidgetcxx . . $ GtkWidget# *widget,
366 int width,
367 int height,
368 int baseline)
369 {
370 GtkSwitchcxx . . $ GtkSwitch# *self = GTK_SWITCHcxx . . $ `gtk/gtkswitch.h:37:9`! (widget);
371 GtkAllocationcxx . . $ GtkAllocation# child_alloc;
372 int min;
373
374 gtk_widget_size_allocatecxx . . $ gtk_widget_size_allocate(6dbef67925be57e3). (self->slidercxx . . $ _GtkSwitch#slider.,
375 &(GtkAllocationcxx . . $ GtkAllocation#) {
376 round (self->handle_poscxx . . $ _GtkSwitch#handle_pos. * (width / 2)), 0,
377 width / 2, height
378 }, -1);
379
380 /* Center ON icon in left half */
381 gtk_widget_measurecxx . . $ gtk_widget_measure(d91afbd837fc0c19). (self->on_imagecxx . . $ _GtkSwitch#on_image., GTK_ORIENTATION_HORIZONTALcxx . . $ GTK_ORIENTATION_HORIZONTAL., -1, &min, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
382 child_alloc.xcxx . . $ _cairo_rectangle_int#x. = ((width / 2) - min) / 2;
383 if (is_right_sidecxx . . $ is_right_side(65d75a856eec1919). (widget, FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!))
384 child_alloc.xcxx . . $ _cairo_rectangle_int#x. += width / 2;
385 child_alloc.widthcxx . . $ _cairo_rectangle_int#width. = min;
386 gtk_widget_measurecxx . . $ gtk_widget_measure(d91afbd837fc0c19). (self->on_imagecxx . . $ _GtkSwitch#on_image., GTK_ORIENTATION_VERTICALcxx . . $ GTK_ORIENTATION_VERTICAL., min, &min, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
387 child_alloc.ycxx . . $ _cairo_rectangle_int#y. = (height - min) / 2;
388 child_alloc.heightcxx . . $ _cairo_rectangle_int#height. = min;
389 gtk_widget_size_allocatecxx . . $ gtk_widget_size_allocate(6dbef67925be57e3). (self->on_imagecxx . . $ _GtkSwitch#on_image., &child_alloc, -1);
390
391 /* Center OFF icon in right half */
392 gtk_widget_measurecxx . . $ gtk_widget_measure(d91afbd837fc0c19). (self->off_imagecxx . . $ _GtkSwitch#off_image., GTK_ORIENTATION_HORIZONTALcxx . . $ GTK_ORIENTATION_HORIZONTAL., -1, &min, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
393 child_alloc.xcxx . . $ _cairo_rectangle_int#x. = ((width / 2) - min) / 2;
394 if (is_right_sidecxx . . $ is_right_side(65d75a856eec1919). (widget, TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!))
395 child_alloc.xcxx . . $ _cairo_rectangle_int#x. += width / 2;
396 child_alloc.widthcxx . . $ _cairo_rectangle_int#width. = min;
397 gtk_widget_measurecxx . . $ gtk_widget_measure(d91afbd837fc0c19). (self->off_imagecxx . . $ _GtkSwitch#off_image., GTK_ORIENTATION_VERTICALcxx . . $ GTK_ORIENTATION_VERTICAL., min, &min, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
398 child_alloc.ycxx . . $ _cairo_rectangle_int#y. = (height - min) / 2;
399 child_alloc.heightcxx . . $ _cairo_rectangle_int#height. = min;
400 gtk_widget_size_allocatecxx . . $ gtk_widget_size_allocate(6dbef67925be57e3). (self->off_imagecxx . . $ _GtkSwitch#off_image., &child_alloc, -1);
401 }
402
403 static void
404 gtk_switch_direction_changedcxx . . $ gtk_switch_direction_changed(ca8bba12f0ec948f). (GtkWidgetcxx . . $ GtkWidget# *widget,
405 GtkTextDirectioncxx . . $ GtkTextDirection# previous_dir)
406 {
407 GtkSwitchcxx . . $ GtkSwitch# *self = GTK_SWITCHcxx . . $ `gtk/gtkswitch.h:37:9`! (widget);
408
409 self->handle_poscxx . . $ _GtkSwitch#handle_pos. = 1.0 - self->handle_poscxx . . $ _GtkSwitch#handle_pos.;
410 gtk_widget_queue_allocatecxx . . $ gtk_widget_queue_allocate(d7cf858254b37903). (widget);
411
412 GTK_WIDGET_CLASScxx . . $ `gtk/gtkwidget.h:45:9`! (gtk_switch_parent_class)->direction_changedcxx . . $ _GtkWidgetClass#direction_changed. (widget, previous_dir);
413 }
414
415 static void
416 gtk_switch_set_action_namecxx . . $ gtk_switch_set_action_name(39e9d00c5c2c9a37). (GtkActionablecxx . . $ GtkActionable# *actionable,
417 const char *action_name)
418 {
419 GtkSwitchcxx . . $ GtkSwitch# *self = GTK_SWITCHcxx . . $ `gtk/gtkswitch.h:37:9`! (actionable);
420
421 if (!self->action_helpercxx . . $ _GtkSwitch#action_helper.)
422 self->action_helpercxx . . $ _GtkSwitch#action_helper. = gtk_action_helper_newcxx . . $ gtk_action_helper_new(1fe6472b62321f5a). (actionable);
423
424 gtk_action_helper_set_action_namecxx . . $ gtk_action_helper_set_action_name(6b92d88ae336b7f9). (self->action_helpercxx . . $ _GtkSwitch#action_helper., action_name);
425 }
426
427 static void
428 gtk_switch_set_action_target_valuecxx . . $ gtk_switch_set_action_target_value(c1201f03c921791a). (GtkActionablecxx . . $ GtkActionable# *actionable,
429 GVariantcxx . . $ GVariant# *action_target)
430 {
431 GtkSwitchcxx . . $ GtkSwitch# *self = GTK_SWITCHcxx . . $ `gtk/gtkswitch.h:37:9`! (actionable);
432
433 if (!self->action_helpercxx . . $ _GtkSwitch#action_helper.)
434 self->action_helpercxx . . $ _GtkSwitch#action_helper. = gtk_action_helper_newcxx . . $ gtk_action_helper_new(1fe6472b62321f5a). (actionable);
435
436 gtk_action_helper_set_action_target_valuecxx . . $ gtk_action_helper_set_action_target_value(8f9c9d1e9dacb603). (self->action_helpercxx . . $ _GtkSwitch#action_helper., action_target);
437 }
438
439 static const char *
440 gtk_switch_get_action_namecxx . . $ gtk_switch_get_action_name(fbdd32c1ca7119f8). (GtkActionablecxx . . $ GtkActionable# *actionable)
441 {
442 GtkSwitchcxx . . $ GtkSwitch# *self = GTK_SWITCHcxx . . $ `gtk/gtkswitch.h:37:9`! (actionable);
443
444 return gtk_action_helper_get_action_namecxx . . $ gtk_action_helper_get_action_name(47aa6e242d303022). (self->action_helpercxx . . $ _GtkSwitch#action_helper.);
445 }
446
447 static GVariantcxx . . $ GVariant# *
448 gtk_switch_get_action_target_valuecxx . . $ gtk_switch_get_action_target_value(2f1a9f6a6084d284). (GtkActionablecxx . . $ GtkActionable# *actionable)
449 {
450 GtkSwitchcxx . . $ GtkSwitch# *self = GTK_SWITCHcxx . . $ `gtk/gtkswitch.h:37:9`! (actionable);
451
452 return gtk_action_helper_get_action_target_valuecxx . . $ gtk_action_helper_get_action_target_value(561dfa610e46c748). (self->action_helpercxx . . $ _GtkSwitch#action_helper.);
453 }
454
455 static void
456 gtk_switch_actionable_iface_initcxx . . $ gtk_switch_actionable_iface_init(16d04ea56a00f533). (GtkActionableInterfacecxx . . $ GtkActionableInterface# *iface)
457 {
458 iface->get_action_namecxx . . $ _GtkActionableInterface#get_action_name. = gtk_switch_get_action_namecxx . . $ gtk_switch_get_action_name(fbdd32c1ca7119f8).;
459 iface->set_action_namecxx . . $ _GtkActionableInterface#set_action_name. = gtk_switch_set_action_namecxx . . $ gtk_switch_set_action_name(39e9d00c5c2c9a37).;
460 iface->get_action_target_valuecxx . . $ _GtkActionableInterface#get_action_target_value. = gtk_switch_get_action_target_valuecxx . . $ gtk_switch_get_action_target_value(2f1a9f6a6084d284).;
461 iface->set_action_target_valuecxx . . $ _GtkActionableInterface#set_action_target_value. = gtk_switch_set_action_target_valuecxx . . $ gtk_switch_set_action_target_value(c1201f03c921791a).;
462 }
463
464 static void
465 gtk_switch_set_propertycxx . . $ gtk_switch_set_property(d7c4bb29f36c0dc4). (GObjectcxx . . $ GObject# *gobject,
466 guintcxx . . $ guint# prop_id,
467 const GValuecxx . . $ GValue# *value,
468 GParamSpeccxx . . $ GParamSpec# *pspec)
469 {
470 GtkSwitchcxx . . $ GtkSwitch# *self = GTK_SWITCHcxx . . $ `gtk/gtkswitch.h:37:9`! (gobject);
471
472 switch (prop_id)
473 {
474 case PROP_ACTIVEcxx . . $ PROP_ACTIVE.:
475 gtk_switch_set_activecxx . . $ gtk_switch_set_active(7a6c7e8084d1b078). (self, g_value_get_booleancxx . . $ g_value_get_boolean(f890c5c75ead5b21). (value));
476 break;
477
478 case PROP_STATEcxx . . $ PROP_STATE.:
479 gtk_switch_set_statecxx . . $ gtk_switch_set_state(7a6c7e8084d1b078). (self, g_value_get_booleancxx . . $ g_value_get_boolean(f890c5c75ead5b21). (value));
480 break;
481
482 case PROP_ACTION_NAMEcxx . . $ PROP_ACTION_NAME.:
483 gtk_switch_set_action_namecxx . . $ gtk_switch_set_action_name(39e9d00c5c2c9a37). (GTK_ACTIONABLEcxx . . $ `gtk/gtkactionable.h:28:9`! (self), g_value_get_stringcxx . . $ g_value_get_string(cc0a2be2b8f7bdc8). (value));
484 break;
485
486 case PROP_ACTION_TARGETcxx . . $ PROP_ACTION_TARGET.:
487 gtk_switch_set_action_target_valuecxx . . $ gtk_switch_set_action_target_value(c1201f03c921791a). (GTK_ACTIONABLEcxx . . $ `gtk/gtkactionable.h:28:9`! (self), g_value_get_variantcxx . . $ g_value_get_variant(15d62b30de5f1cbd). (value));
488 break;
489
490 default:
491 G_OBJECT_WARN_INVALID_PROPERTY_IDcxx . . $ `<external>/1341695927569185362/gobject.h:690:9`! (gobject, prop_id, pspec);
492 }
493 }
494
495 static void
496 gtk_switch_get_propertycxx . . $ gtk_switch_get_property(cee2c52f22407c66). (GObjectcxx . . $ GObject# *gobject,
497 guintcxx . . $ guint# prop_id,
498 GValuecxx . . $ GValue# *value,
499 GParamSpeccxx . . $ GParamSpec# *pspec)
500 {
501 GtkSwitchcxx . . $ GtkSwitch# *self = GTK_SWITCHcxx . . $ `gtk/gtkswitch.h:37:9`! (gobject);
502
503 switch (prop_id)
504 {
505 case PROP_ACTIVEcxx . . $ PROP_ACTIVE.:
506 g_value_set_booleancxx . . $ g_value_set_boolean(b698c61e8e30c4ea). (value, self->is_activecxx . . $ _GtkSwitch#is_active.);
507 break;
508
509 case PROP_STATEcxx . . $ PROP_STATE.:
510 g_value_set_booleancxx . . $ g_value_set_boolean(b698c61e8e30c4ea). (value, self->statecxx . . $ _GtkSwitch#state.);
511 break;
512
513 case PROP_ACTION_NAMEcxx . . $ PROP_ACTION_NAME.:
514 g_value_set_stringcxx . . $ g_value_set_string(65b9ea7708b82b9b). (value, gtk_action_helper_get_action_namecxx . . $ gtk_action_helper_get_action_name(47aa6e242d303022). (self->action_helpercxx . . $ _GtkSwitch#action_helper.));
515 break;
516
517 case PROP_ACTION_TARGETcxx . . $ PROP_ACTION_TARGET.:
518 g_value_set_variantcxx . . $ g_value_set_variant(d1a15ae1b11a2e3e). (value, gtk_action_helper_get_action_target_valuecxx . . $ gtk_action_helper_get_action_target_value(561dfa610e46c748). (self->action_helpercxx . . $ _GtkSwitch#action_helper.));
519 break;
520
521 default:
522 G_OBJECT_WARN_INVALID_PROPERTY_IDcxx . . $ `<external>/1341695927569185362/gobject.h:690:9`! (gobject, prop_id, pspec);
523 }
524 }
525
526 static void
527 gtk_switch_disposecxx . . $ gtk_switch_dispose(6087475fa43034d3). (GObjectcxx . . $ GObject# *object)
528 {
529 GtkSwitchcxx . . $ GtkSwitch# *self = GTK_SWITCHcxx . . $ `gtk/gtkswitch.h:37:9`! (object);
530
531 g_clear_objectcxx . . $ `<external>/1341695927569185362/gobject.h:695:9`! (&self->action_helper);
532
533 G_OBJECT_CLASScxx . . $ `<external>/1341695927569185362/gobject.h:61:9`! (gtk_switch_parent_class)->disposecxx . . $ _GObjectClass#dispose. (object);
534 }
535
536 static void
537 gtk_switch_finalizecxx . . $ gtk_switch_finalize(6087475fa43034d3). (GObjectcxx . . $ GObject# *object)
538 {
539 GtkSwitchcxx . . $ GtkSwitch# *self = GTK_SWITCHcxx . . $ `gtk/gtkswitch.h:37:9`! (object);
540
541 gtk_switch_end_toggle_animationcxx . . $ gtk_switch_end_toggle_animation(850a5ed6347ff5eb). (self);
542
543 gtk_widget_unparentcxx . . $ gtk_widget_unparent(d7cf858254b37903). (self->on_imagecxx . . $ _GtkSwitch#on_image.);
544 gtk_widget_unparentcxx . . $ gtk_widget_unparent(d7cf858254b37903). (self->off_imagecxx . . $ _GtkSwitch#off_image.);
545 gtk_widget_unparentcxx . . $ gtk_widget_unparent(d7cf858254b37903). (self->slidercxx . . $ _GtkSwitch#slider.);
546
547 G_OBJECT_CLASScxx . . $ `<external>/1341695927569185362/gobject.h:61:9`! (gtk_switch_parent_class)->finalizecxx . . $ _GObjectClass#finalize. (object);
548 }
549
550 static gbooleancxx . . $ gboolean#
551 state_setcxx . . $ state_set(d29e1ce66449fc26). (GtkSwitchcxx . . $ GtkSwitch# *self,
552 gbooleancxx . . $ gboolean# state)
553 {
554 if (self->action_helpercxx . . $ _GtkSwitch#action_helper.)
555 gtk_action_helper_activatecxx . . $ gtk_action_helper_activate(64e567adf714b3dc). (self->action_helpercxx . . $ _GtkSwitch#action_helper.);
556
557 gtk_switch_set_statecxx . . $ gtk_switch_set_state(7a6c7e8084d1b078). (self, state);
558
559 return TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!;
560 }
561
562 static gbooleancxx . . $ gboolean#
563 translate_switch_shapes_to_opacitycxx . . $ translate_switch_shapes_to_opacity(700fa889cc9dd4c8). (GBindingcxx . . $ GBinding# *binding,
564 const GValuecxx . . $ GValue# *from_value,
565 GValuecxx . . $ GValue# *to_value,
566 gpointercxx . . $ gpointer# user_data)
567 {
568 gbooleancxx . . $ gboolean# visible = g_value_get_booleancxx . . $ g_value_get_boolean(f890c5c75ead5b21). (from_value);
569 g_value_set_doublecxx . . $ g_value_set_double(994eddfdeb9c9cc0). (to_value, visible ? 1.0 : 0.0);
570
571 return TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!;
572 }
573
574 static void
575 gtk_switch_class_initcxx . . $ gtk_switch_class_init(182189221a915635). (GtkSwitchClasscxx . . $ GtkSwitchClass# *klass)
576 {
577 GtkWidgetClasscxx . . $ GtkWidgetClass# *widget_class = GTK_WIDGET_CLASScxx . . $ `gtk/gtkwidget.h:45:9`! (klass);
578 GObjectClasscxx . . $ GObjectClass# *gobject_class = G_OBJECT_CLASScxx . . $ `<external>/1341695927569185362/gobject.h:61:9`! (klass);
579
580 /**
581 * GtkSwitch:active:
582 *
583 * Whether the `GtkSwitch` widget is in its on or off state.
584 */
585 switch_propscxx . . $ switch_props.[PROP_ACTIVEcxx . . $ PROP_ACTIVE.] =
586 g_param_spec_booleancxx . . $ g_param_spec_boolean(315d86b79c0116e0). ("active", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
587 FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!,
588 GTK_PARAM_READWRITEcxx . . $ `gtk/gtkprivate.h:44:9`!|G_PARAM_EXPLICIT_NOTIFYcxx . . $ G_PARAM_EXPLICIT_NOTIFY.);
589
590 /**
591 * GtkSwitch:state:
592 *
593 * The backend state that is controlled by the switch.
594 *
595 * Applications should usually set the [[email protected]:active] property,
596 * except when indicating a change to the backend state which occurs
597 * separately from the user's interaction.
598 *
599 * See [[email protected]::state-set] for details.
600 */
601 switch_propscxx . . $ switch_props.[PROP_STATEcxx . . $ PROP_STATE.] =
602 g_param_spec_booleancxx . . $ g_param_spec_boolean(315d86b79c0116e0). ("state", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
603 FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!,
604 GTK_PARAM_READWRITEcxx . . $ `gtk/gtkprivate.h:44:9`!|G_PARAM_EXPLICIT_NOTIFYcxx . . $ G_PARAM_EXPLICIT_NOTIFY.);
605
606 gobject_class->set_propertycxx . . $ _GObjectClass#set_property. = gtk_switch_set_propertycxx . . $ gtk_switch_set_property(d7c4bb29f36c0dc4).;
607 gobject_class->get_propertycxx . . $ _GObjectClass#get_property. = gtk_switch_get_propertycxx . . $ gtk_switch_get_property(cee2c52f22407c66).;
608 gobject_class->disposecxx . . $ _GObjectClass#dispose. = gtk_switch_disposecxx . . $ gtk_switch_dispose(6087475fa43034d3).;
609 gobject_class->finalizecxx . . $ _GObjectClass#finalize. = gtk_switch_finalizecxx . . $ gtk_switch_finalize(6087475fa43034d3).;
610
611 g_object_class_install_propertiescxx . . $ g_object_class_install_properties(569d03e6a4088541). (gobject_class, LAST_PROPcxx . . $ LAST_PROP., switch_propscxx . . $ switch_props.);
612
613 widget_class->direction_changedcxx . . $ _GtkWidgetClass#direction_changed. = gtk_switch_direction_changedcxx . . $ gtk_switch_direction_changed(ca8bba12f0ec948f).;
614
615 klass->activatecxx . . $ _GtkSwitchClass#activate. = gtk_switch_activatecxx . . $ gtk_switch_activate(850a5ed6347ff5eb).;
616 klass->state_setcxx . . $ _GtkSwitchClass#state_set. = state_setcxx . . $ state_set(d29e1ce66449fc26).;
617
618 /**
619 * GtkSwitch::activate:
620 * @widget: the object which received the signal
621 *
622 * Emitted to animate the switch.
623 *
624 * Applications should never connect to this signal,
625 * but use the [[email protected]:active] property.
626 */
627 signalscxx . . $ signals.[ACTIVATEcxx . . $ ACTIVATE.] =
628 g_signal_newcxx . . $ g_signal_new(b0aa5e8090fb95c0). (I_cxx . . $ `gdk/gdkprivate.h:35:9`!("activate"),
629 G_OBJECT_CLASS_TYPEcxx . . $ `<external>/1341695927569185362/gobject.h:117:9`! (gobject_class),
630 G_SIGNAL_RUN_FIRSTcxx . . $ G_SIGNAL_RUN_FIRST. | G_SIGNAL_ACTIONcxx . . $ G_SIGNAL_ACTION.,
631 G_STRUCT_OFFSETcxx . . $ `<external>/12741050725406041920/gmacros.h:1005:9`! (GtkSwitchClass, activate),
632 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
633 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
634 G_TYPE_NONEcxx . . $ `<external>/9567554376676449156/gtype.h:72:9`!, 0);
635
636 gtk_widget_class_set_activate_signalcxx . . $ gtk_widget_class_set_activate_signal(53d965ee418c3db). (widget_class, signalscxx . . $ signals.[ACTIVATEcxx . . $ ACTIVATE.]);
637
638 /**
639 * GtkSwitch::state-set:
640 * @widget: the object on which the signal was emitted
641 * @state: the new state of the switch
642 *
643 * Emitted to change the underlying state.
644 *
645 * The ::state-set signal is emitted when the user changes the switch
646 * position. The default handler calls [[email protected]_state] with the
647 * value of @state.
648 *
649 * To implement delayed state change, applications can connect to this
650 * signal, initiate the change of the underlying state, and call
651 * [[email protected]_state] when the underlying state change is
652 * complete. The signal handler should return %TRUE to prevent the
653 * default handler from running.
654 *
655 * Returns: %TRUE to stop the signal emission
656 */
657 signalscxx . . $ signals.[STATE_SETcxx . . $ STATE_SET.] =
658 g_signal_newcxx . . $ g_signal_new(b0aa5e8090fb95c0). (I_cxx . . $ `gdk/gdkprivate.h:35:9`!("state-set"),
659 G_OBJECT_CLASS_TYPEcxx . . $ `<external>/1341695927569185362/gobject.h:117:9`! (gobject_class),
660 G_SIGNAL_RUN_LASTcxx . . $ G_SIGNAL_RUN_LAST.,
661 G_STRUCT_OFFSETcxx . . $ `<external>/12741050725406041920/gmacros.h:1005:9`! (GtkSwitchClass, state_set),
662 _gtk_boolean_handled_accumulatorcxx . . $ _gtk_boolean_handled_accumulator(76292f232a01f816)., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
663 _gtk_marshal_BOOLEAN__BOOLEANcxx . . $ _gtk_marshal_BOOLEAN__BOOLEAN(cba270afb0f82555).,
664 G_TYPE_BOOLEANcxx . . $ `<external>/9567554376676449156/gtype.h:99:9`!, 1,
665 G_TYPE_BOOLEANcxx . . $ `<external>/9567554376676449156/gtype.h:99:9`!);
666 g_signal_set_va_marshallercxx . . $ g_signal_set_va_marshaller(4fd870c04a9d6fe7). (signalscxx . . $ signals.[STATE_SETcxx . . $ STATE_SET.],
667 G_TYPE_FROM_CLASScxx . . $ `<external>/9567554376676449156/gtype.h:657:9`! (gobject_class),
668 _gtk_marshal_BOOLEAN__BOOLEANvcxx . . $ _gtk_marshal_BOOLEAN__BOOLEANv(d309f4be92d1737c).);
669
670 g_object_class_override_propertycxx . . $ g_object_class_override_property(3aa56717d1bf1f20). (gobject_class, PROP_ACTION_NAMEcxx . . $ PROP_ACTION_NAME., "action-name");
671 g_object_class_override_propertycxx . . $ g_object_class_override_property(3aa56717d1bf1f20). (gobject_class, PROP_ACTION_TARGETcxx . . $ PROP_ACTION_TARGET., "action-target");
672
673 gtk_widget_class_set_css_namecxx . . $ gtk_widget_class_set_css_name(6333614c746ab65a). (widget_class, I_cxx . . $ `gdk/gdkprivate.h:35:9`!("switch"));
674
675 gtk_widget_class_set_accessible_rolecxx . . $ gtk_widget_class_set_accessible_role(a3df1a29abf28273). (widget_class, GTK_ACCESSIBLE_ROLE_SWITCHcxx . . $ GTK_ACCESSIBLE_ROLE_SWITCH.);
676 }
677
678 static void
679 gtk_switch_initcxx . . $ gtk_switch_init(850a5ed6347ff5eb). (GtkSwitchcxx . . $ GtkSwitch# *self)
680 {
681 GtkLayoutManagercxx . . $ GtkLayoutManager# *layout;
682 GtkGesturecxx . . $ GtkGesture# *gesture;
683 GtkSettingscxx . . $ GtkSettings# *gtk_settings;
684
685 gtk_widget_set_focusablecxx . . $ gtk_widget_set_focusable(81f145f668a0074f). (GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self), TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!);
686
687 gesture = gtk_gesture_click_newcxx . . $ gtk_gesture_click_new(5d22ad75f7119eec). ();
688 gtk_gesture_single_set_touch_onlycxx . . $ gtk_gesture_single_set_touch_only(724cedb1e56be9d7). (GTK_GESTURE_SINGLEcxx . . $ `gtk/gtkgesturesingle.h:32:9`! (gesture), FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!);
689 gtk_gesture_single_set_exclusivecxx . . $ gtk_gesture_single_set_exclusive(724cedb1e56be9d7). (GTK_GESTURE_SINGLEcxx . . $ `gtk/gtkgesturesingle.h:32:9`! (gesture), TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!);
690 g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (gesture, "pressed",
691 G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (gtk_switch_click_gesture_pressed), self);
692 g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (gesture, "released",
693 G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (gtk_switch_click_gesture_released), self);
694 gtk_event_controller_set_propagation_phasecxx . . $ gtk_event_controller_set_propagation_phase(c64e5c05e4165a3c). (GTK_EVENT_CONTROLLERcxx . . $ `gtk/gtkeventcontroller.h:35:9`! (gesture),
695 GTK_PHASE_BUBBLEcxx . . $ GTK_PHASE_BUBBLE.);
696 gtk_widget_add_controllercxx . . $ gtk_widget_add_controller(6d1262f1b7c2f702). (GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self), GTK_EVENT_CONTROLLERcxx . . $ `gtk/gtkeventcontroller.h:35:9`! (gesture));
697 self->click_gesturecxx . . $ _GtkSwitch#click_gesture. = gesture;
698
699 gesture = gtk_gesture_pan_newcxx . . $ gtk_gesture_pan_new(5225b77ef64a9ee9). (GTK_ORIENTATION_HORIZONTALcxx . . $ GTK_ORIENTATION_HORIZONTAL.);
700 gtk_gesture_single_set_touch_onlycxx . . $ gtk_gesture_single_set_touch_only(724cedb1e56be9d7). (GTK_GESTURE_SINGLEcxx . . $ `gtk/gtkgesturesingle.h:32:9`! (gesture), FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!);
701 gtk_gesture_single_set_exclusivecxx . . $ gtk_gesture_single_set_exclusive(724cedb1e56be9d7). (GTK_GESTURE_SINGLEcxx . . $ `gtk/gtkgesturesingle.h:32:9`! (gesture), TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!);
702 g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (gesture, "pan",
703 G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (gtk_switch_pan_gesture_pan), self);
704 g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`! (gesture, "drag-end",
705 G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`! (gtk_switch_pan_gesture_drag_end), self);
706 gtk_event_controller_set_propagation_phasecxx . . $ gtk_event_controller_set_propagation_phase(c64e5c05e4165a3c). (GTK_EVENT_CONTROLLERcxx . . $ `gtk/gtkeventcontroller.h:35:9`! (gesture),
707 GTK_PHASE_CAPTUREcxx . . $ GTK_PHASE_CAPTURE.);
708 gtk_widget_add_controllercxx . . $ gtk_widget_add_controller(6d1262f1b7c2f702). (GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self), GTK_EVENT_CONTROLLERcxx . . $ `gtk/gtkeventcontroller.h:35:9`! (gesture));
709 self->pan_gesturecxx . . $ _GtkSwitch#pan_gesture. = gesture;
710
711 layout = gtk_custom_layout_newcxx . . $ gtk_custom_layout_new(6020fd9aff1eee55). (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
712 gtk_switch_measurecxx . . $ gtk_switch_measure(d91afbd837fc0c19).,
713 gtk_switch_allocatecxx . . $ gtk_switch_allocate(598a503332136822).);
714 gtk_widget_set_layout_managercxx . . $ gtk_widget_set_layout_manager(4079769398e3bd92). (GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self), layout);
715
716 gtk_settings = gtk_settings_get_defaultcxx . . $ gtk_settings_get_default(8554497bfdb03e68). ();
717
718 self->on_imagecxx . . $ _GtkSwitch#on_image. = g_object_newcxx . . $ g_object_new(8485fe61b4be4c78). (GTK_TYPE_IMAGEcxx . . $ `gtk/gtkimage.h:38:9`!,
719 "accessible-role", GTK_ACCESSIBLE_ROLE_NONEcxx . . $ GTK_ACCESSIBLE_ROLE_NONE.,
720 "icon-name", "switch-on-symbolic",
721 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
722 gtk_widget_set_parentcxx . . $ gtk_widget_set_parent(4f261c0971c30e7). (self->on_imagecxx . . $ _GtkSwitch#on_image., GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self));
723
724 g_object_bind_property_fullcxx . . $ g_object_bind_property_full(9c13be986a8a93df). (gtk_settings, "gtk-show-status-shapes",
725 self->on_imagecxx . . $ _GtkSwitch#on_image., "opacity",
726 G_BINDING_SYNC_CREATEcxx . . $ G_BINDING_SYNC_CREATE.,
727 translate_switch_shapes_to_opacitycxx . . $ translate_switch_shapes_to_opacity(700fa889cc9dd4c8).,
728 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
729
730 self->off_imagecxx . . $ _GtkSwitch#off_image. = g_object_newcxx . . $ g_object_new(8485fe61b4be4c78). (GTK_TYPE_IMAGEcxx . . $ `gtk/gtkimage.h:38:9`!,
731 "accessible-role", GTK_ACCESSIBLE_ROLE_NONEcxx . . $ GTK_ACCESSIBLE_ROLE_NONE.,
732 "icon-name", "switch-off-symbolic",
733 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
734 gtk_widget_set_parentcxx . . $ gtk_widget_set_parent(4f261c0971c30e7). (self->off_imagecxx . . $ _GtkSwitch#off_image., GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self));
735
736 g_object_bind_property_fullcxx . . $ g_object_bind_property_full(9c13be986a8a93df). (gtk_settings, "gtk-show-status-shapes",
737 self->off_imagecxx . . $ _GtkSwitch#off_image., "opacity",
738 G_BINDING_SYNC_CREATEcxx . . $ G_BINDING_SYNC_CREATE.,
739 translate_switch_shapes_to_opacitycxx . . $ translate_switch_shapes_to_opacity(700fa889cc9dd4c8).,
740 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
741
742 self->slidercxx . . $ _GtkSwitch#slider. = gtk_gizmo_new_with_rolecxx . . $ gtk_gizmo_new_with_role(f87719e279ae009d). ("slider",
743 GTK_ACCESSIBLE_ROLE_NONEcxx . . $ GTK_ACCESSIBLE_ROLE_NONE.,
744 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
745 gtk_widget_set_parentcxx . . $ gtk_widget_set_parent(4f261c0971c30e7). (self->slidercxx . . $ _GtkSwitch#slider., GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self));
746
747 gtk_accessible_update_statecxx . . $ gtk_accessible_update_state(a322e699be08ab8a). (GTK_ACCESSIBLEcxx . . $ GTK_ACCESSIBLE(4ecffd44f086533a). (self),
748 GTK_ACCESSIBLE_STATE_CHECKEDcxx . . $ GTK_ACCESSIBLE_STATE_CHECKED., FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!,
749 -1);
750 if (is_right_sidecxx . . $ is_right_side(65d75a856eec1919). (GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self), FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!))
751 self->handle_poscxx . . $ _GtkSwitch#handle_pos. = 1.0;
752 else
753 self->handle_poscxx . . $ _GtkSwitch#handle_pos. = 0.0;
754 }
755
756 /**
757 * gtk_switch_new:
758 *
759 * Creates a new `GtkSwitch` widget.
760 *
761 * Returns: the newly created `GtkSwitch` instance
762 */
763 GtkWidgetcxx . . $ GtkWidget# *
764 gtk_switch_newcxx . . $ gtk_switch_new(2369ce5e9f2c7dfd). (void)
765 {
766 return g_object_newcxx . . $ g_object_new(8485fe61b4be4c78). (GTK_TYPE_SWITCHcxx . . $ `gtk/gtkswitch.h:36:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
767 }
768
769 /**
770 * gtk_switch_set_active:
771 * @self: a `GtkSwitch`
772 * @is_active: %TRUE if @self should be active, and %FALSE otherwise
773 *
774 * Changes the state of @self to the desired one.
775 */
776 void
777 gtk_switch_set_activecxx . . $ gtk_switch_set_active(7a6c7e8084d1b078). (GtkSwitchcxx . . $ GtkSwitch# *self,
778 gbooleancxx . . $ gboolean# is_active)
779 {
780 g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (GTK_IS_SWITCHcxx . . $ `gtk/gtkswitch.h:38:9`! (self));
781
782 gtk_switch_end_toggle_animationcxx . . $ gtk_switch_end_toggle_animation(850a5ed6347ff5eb). (self);
783
784 is_active = !!is_active;
785
786 if (self->is_activecxx . . $ _GtkSwitch#is_active. != is_active)
787 {
788 gbooleancxx . . $ gboolean# handled;
789
790 self->is_activecxx . . $ _GtkSwitch#is_active. = is_active;
791
792 if (is_right_sidecxx . . $ is_right_side(65d75a856eec1919). (GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self), self->is_activecxx . . $ _GtkSwitch#is_active.))
793 self->handle_poscxx . . $ _GtkSwitch#handle_pos. = 1.0;
794 else
795 self->handle_poscxx . . $ _GtkSwitch#handle_pos. = 0.0;
796
797 g_signal_emitcxx . . $ g_signal_emit(cc3f7c2ba1c6a182). (self, signalscxx . . $ signals.[STATE_SETcxx . . $ STATE_SET.], 0, is_active, &handled);
798
799 g_object_notify_by_pspeccxx . . $ g_object_notify_by_pspec(89706f8943b9e738). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (self), switch_propscxx . . $ switch_props.[PROP_ACTIVEcxx . . $ PROP_ACTIVE.]);
800
801 gtk_accessible_update_statecxx . . $ gtk_accessible_update_state(a322e699be08ab8a). (GTK_ACCESSIBLEcxx . . $ GTK_ACCESSIBLE(4ecffd44f086533a). (self),
802 GTK_ACCESSIBLE_STATE_CHECKEDcxx . . $ GTK_ACCESSIBLE_STATE_CHECKED., is_active,
803 -1);
804
805 gtk_widget_queue_allocatecxx . . $ gtk_widget_queue_allocate(d7cf858254b37903). (GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self));
806 }
807 }
808
809 /**
810 * gtk_switch_get_active:
811 * @self: a `GtkSwitch`
812 *
813 * Gets whether the `GtkSwitch` is in its “on” or “off” state.
814 *
815 * Returns: %TRUE if the `GtkSwitch` is active, and %FALSE otherwise
816 */
817 gbooleancxx . . $ gboolean#
818 gtk_switch_get_activecxx . . $ gtk_switch_get_active(b492f749442593bf). (GtkSwitchcxx . . $ GtkSwitch# *self)
819 {
820 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GTK_IS_SWITCHcxx . . $ `gtk/gtkswitch.h:38:9`! (self), FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!);
821
822 return self->is_activecxx . . $ _GtkSwitch#is_active.;
823 }
824
825 /**
826 * gtk_switch_set_state:
827 * @self: a `GtkSwitch`
828 * @state: the new state
829 *
830 * Sets the underlying state of the `GtkSwitch`.
831 *
832 * This function is typically called from a [[email protected]::state-set]
833 * signal handler in order to set up delayed state changes.
834 *
835 * See [[email protected]::state-set] for details.
836 */
837 void
838 gtk_switch_set_statecxx . . $ gtk_switch_set_state(7a6c7e8084d1b078). (GtkSwitchcxx . . $ GtkSwitch# *self,
839 gbooleancxx . . $ gboolean# state)
840 {
841 g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (GTK_IS_SWITCHcxx . . $ `gtk/gtkswitch.h:38:9`! (self));
842
843 state = state != FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
844
845 if (self->statecxx . . $ _GtkSwitch#state. == state)
846 return;
847
848 self->statecxx . . $ _GtkSwitch#state. = state;
849
850 if (state)
851 gtk_widget_set_state_flagscxx . . $ gtk_widget_set_state_flags(2b95d95a3c3aa236). (GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self), GTK_STATE_FLAG_CHECKEDcxx . . $ GTK_STATE_FLAG_CHECKED., FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!);
852 else
853 gtk_widget_unset_state_flagscxx . . $ gtk_widget_unset_state_flags(e7d7ee4ea524d63). (GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (self), GTK_STATE_FLAG_CHECKEDcxx . . $ GTK_STATE_FLAG_CHECKED.);
854
855 g_object_notify_by_pspeccxx . . $ g_object_notify_by_pspec(89706f8943b9e738). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (self), switch_propscxx . . $ switch_props.[PROP_STATEcxx . . $ PROP_STATE.]);
856 }
857
858 /**
859 * gtk_switch_get_state:
860 * @self: a `GtkSwitch`
861 *
862 * Gets the underlying state of the `GtkSwitch`.
863 *
864 * Returns: the underlying state
865 */
866 gbooleancxx . . $ gboolean#
867 gtk_switch_get_statecxx . . $ gtk_switch_get_state(b492f749442593bf). (GtkSwitchcxx . . $ GtkSwitch# *self)
868 {
869 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GTK_IS_SWITCHcxx . . $ `gtk/gtkswitch.h:38:9`! (self), FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!);
870
871 return self->statecxx . . $ _GtkSwitch#state.;
872 }