gtk/auto/scale.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{
6 Adjustment, Align, Buildable, Container, Orientable, Orientation, PositionType, Range,
7 SensitivityType, Widget,
8};
9use glib::{
10 prelude::*,
11 signal::{connect_raw, SignalHandlerId},
12 translate::*,
13};
14use std::{boxed::Box as Box_, fmt, mem, mem::transmute};
15
16glib::wrapper! {
17 /// A GtkScale is a slider control used to select a numeric value.
18 /// To use it, you’ll probably want to investigate the methods on
19 /// its base class, [`Range`][crate::Range], in addition to the methods for GtkScale itself.
20 /// To set the value of a scale, you would normally use [`RangeExt::set_value()`][crate::prelude::RangeExt::set_value()].
21 /// To detect changes to the value, you would normally use the
22 /// [`value-changed`][struct@crate::Range#value-changed] signal.
23 ///
24 /// Note that using the same upper and lower bounds for the [`Scale`][crate::Scale] (through
25 /// the [`Range`][crate::Range] methods) will hide the slider itself. This is useful for
26 /// applications that want to show an undeterminate value on the scale, without
27 /// changing the layout of the application (such as movie or music players).
28 ///
29 /// # GtkScale as GtkBuildable
30 ///
31 /// GtkScale supports a custom ``<marks>`` element, which can contain multiple
32 /// ``<mark>`` elements. The “value” and “position” attributes have the same
33 /// meaning as [`ScaleExt::add_mark()`][crate::prelude::ScaleExt::add_mark()] parameters of the same name. If the
34 /// element is not empty, its content is taken as the markup to show at
35 /// the mark. It can be translated with the usual ”translatable” and
36 /// “context” attributes.
37 ///
38 /// # CSS nodes
39 ///
40 ///
41 ///
42 /// **⚠️ The following code is in plain ⚠️**
43 ///
44 /// ```plain
45 /// scale[.fine-tune][.marks-before][.marks-after]
46 /// ├── marks.top
47 /// │ ├── mark
48 /// │ ┊ ├── [label]
49 /// │ ┊ ╰── indicator
50 /// ┊ ┊
51 /// │ ╰── mark
52 /// ├── [value]
53 /// ├── contents
54 /// │ ╰── trough
55 /// │ ├── slider
56 /// │ ├── [highlight]
57 /// │ ╰── [fill]
58 /// ╰── marks.bottom
59 /// ├── mark
60 /// ┊ ├── indicator
61 /// ┊ ╰── [label]
62 /// ╰── mark
63 /// ```
64 ///
65 /// GtkScale has a main CSS node with name scale and a subnode for its contents,
66 /// with subnodes named trough and slider.
67 ///
68 /// The main node gets the style class .fine-tune added when the scale is in
69 /// 'fine-tuning' mode.
70 ///
71 /// If the scale has an origin (see [`ScaleExt::set_has_origin()`][crate::prelude::ScaleExt::set_has_origin()]), there is a
72 /// subnode with name highlight below the trough node that is used for rendering
73 /// the highlighted part of the trough.
74 ///
75 /// If the scale is showing a fill level (see [`RangeExt::set_show_fill_level()`][crate::prelude::RangeExt::set_show_fill_level()]),
76 /// there is a subnode with name fill below the trough node that is used for
77 /// rendering the filled in part of the trough.
78 ///
79 /// If marks are present, there is a marks subnode before or after the contents
80 /// node, below which each mark gets a node with name mark. The marks nodes get
81 /// either the .top or .bottom style class.
82 ///
83 /// The mark node has a subnode named indicator. If the mark has text, it also
84 /// has a subnode named label. When the mark is either above or left of the
85 /// scale, the label subnode is the first when present. Otherwise, the indicator
86 /// subnode is the first.
87 ///
88 /// The main CSS node gets the 'marks-before' and/or 'marks-after' style classes
89 /// added depending on what marks are present.
90 ///
91 /// If the scale is displaying the value (see [`draw-value`][struct@crate::Scale#draw-value]), there is
92 /// subnode with name value.
93 ///
94 /// ## Properties
95 ///
96 ///
97 /// #### `digits`
98 /// Readable | Writeable
99 ///
100 ///
101 /// #### `draw-value`
102 /// Readable | Writeable
103 ///
104 ///
105 /// #### `has-origin`
106 /// Readable | Writeable
107 ///
108 ///
109 /// #### `value-pos`
110 /// Readable | Writeable
111 /// <details><summary><h4>Range</h4></summary>
112 ///
113 ///
114 /// #### `adjustment`
115 /// Readable | Writeable | Construct
116 ///
117 ///
118 /// #### `fill-level`
119 /// The fill level (e.g. prebuffering of a network stream).
120 /// See [`RangeExt::set_fill_level()`][crate::prelude::RangeExt::set_fill_level()].
121 ///
122 /// Readable | Writeable
123 ///
124 ///
125 /// #### `inverted`
126 /// Readable | Writeable
127 ///
128 ///
129 /// #### `lower-stepper-sensitivity`
130 /// Readable | Writeable
131 ///
132 ///
133 /// #### `restrict-to-fill-level`
134 /// The restrict-to-fill-level property controls whether slider
135 /// movement is restricted to an upper boundary set by the
136 /// fill level. See [`RangeExt::set_restrict_to_fill_level()`][crate::prelude::RangeExt::set_restrict_to_fill_level()].
137 ///
138 /// Readable | Writeable
139 ///
140 ///
141 /// #### `round-digits`
142 /// The number of digits to round the value to when
143 /// it changes, or -1. See [`change-value`][struct@crate::Range#change-value].
144 ///
145 /// Readable | Writeable
146 ///
147 ///
148 /// #### `show-fill-level`
149 /// The show-fill-level property controls whether fill level indicator
150 /// graphics are displayed on the trough. See
151 /// [`RangeExt::set_show_fill_level()`][crate::prelude::RangeExt::set_show_fill_level()].
152 ///
153 /// Readable | Writeable
154 ///
155 ///
156 /// #### `upper-stepper-sensitivity`
157 /// Readable | Writeable
158 /// </details>
159 /// <details><summary><h4>Widget</h4></summary>
160 ///
161 ///
162 /// #### `app-paintable`
163 /// Readable | Writeable
164 ///
165 ///
166 /// #### `can-default`
167 /// Readable | Writeable
168 ///
169 ///
170 /// #### `can-focus`
171 /// Readable | Writeable
172 ///
173 ///
174 /// #### `composite-child`
175 /// Readable
176 ///
177 ///
178 /// #### `double-buffered`
179 /// Whether the widget is double buffered.
180 ///
181 /// Readable | Writeable
182 ///
183 ///
184 /// #### `events`
185 /// Readable | Writeable
186 ///
187 ///
188 /// #### `expand`
189 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
190 ///
191 /// Readable | Writeable
192 ///
193 ///
194 /// #### `focus-on-click`
195 /// Whether the widget should grab focus when it is clicked with the mouse.
196 ///
197 /// This property is only relevant for widgets that can take focus.
198 ///
199 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
200 /// GtkComboBox) implemented this property individually.
201 ///
202 /// Readable | Writeable
203 ///
204 ///
205 /// #### `halign`
206 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
207 ///
208 /// Readable | Writeable
209 ///
210 ///
211 /// #### `has-default`
212 /// Readable | Writeable
213 ///
214 ///
215 /// #### `has-focus`
216 /// Readable | Writeable
217 ///
218 ///
219 /// #### `has-tooltip`
220 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
221 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
222 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
223 /// whether it will provide a tooltip or not.
224 ///
225 /// Note that setting this property to [`true`] for the first time will change
226 /// the event masks of the GdkWindows of this widget to include leave-notify
227 /// and motion-notify events. This cannot and will not be undone when the
228 /// property is set to [`false`] again.
229 ///
230 /// Readable | Writeable
231 ///
232 ///
233 /// #### `height-request`
234 /// Readable | Writeable
235 ///
236 ///
237 /// #### `hexpand`
238 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
239 ///
240 /// Readable | Writeable
241 ///
242 ///
243 /// #### `hexpand-set`
244 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
245 ///
246 /// Readable | Writeable
247 ///
248 ///
249 /// #### `is-focus`
250 /// Readable | Writeable
251 ///
252 ///
253 /// #### `margin`
254 /// Sets all four sides' margin at once. If read, returns max
255 /// margin on any side.
256 ///
257 /// Readable | Writeable
258 ///
259 ///
260 /// #### `margin-bottom`
261 /// Margin on bottom side of widget.
262 ///
263 /// This property adds margin outside of the widget's normal size
264 /// request, the margin will be added in addition to the size from
265 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
266 ///
267 /// Readable | Writeable
268 ///
269 ///
270 /// #### `margin-end`
271 /// Margin on end of widget, horizontally. This property supports
272 /// left-to-right and right-to-left text directions.
273 ///
274 /// This property adds margin outside of the widget's normal size
275 /// request, the margin will be added in addition to the size from
276 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
277 ///
278 /// Readable | Writeable
279 ///
280 ///
281 /// #### `margin-left`
282 /// Margin on left side of widget.
283 ///
284 /// This property adds margin outside of the widget's normal size
285 /// request, the margin will be added in addition to the size from
286 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
287 ///
288 /// Readable | Writeable
289 ///
290 ///
291 /// #### `margin-right`
292 /// Margin on right side of widget.
293 ///
294 /// This property adds margin outside of the widget's normal size
295 /// request, the margin will be added in addition to the size from
296 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
297 ///
298 /// Readable | Writeable
299 ///
300 ///
301 /// #### `margin-start`
302 /// Margin on start of widget, horizontally. This property supports
303 /// left-to-right and right-to-left text directions.
304 ///
305 /// This property adds margin outside of the widget's normal size
306 /// request, the margin will be added in addition to the size from
307 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
308 ///
309 /// Readable | Writeable
310 ///
311 ///
312 /// #### `margin-top`
313 /// Margin on top side of widget.
314 ///
315 /// This property adds margin outside of the widget's normal size
316 /// request, the margin will be added in addition to the size from
317 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
318 ///
319 /// Readable | Writeable
320 ///
321 ///
322 /// #### `name`
323 /// Readable | Writeable
324 ///
325 ///
326 /// #### `no-show-all`
327 /// Readable | Writeable
328 ///
329 ///
330 /// #### `opacity`
331 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
332 /// more details about window opacity.
333 ///
334 /// Before 3.8 this was only available in GtkWindow
335 ///
336 /// Readable | Writeable
337 ///
338 ///
339 /// #### `parent`
340 /// Readable | Writeable
341 ///
342 ///
343 /// #### `receives-default`
344 /// Readable | Writeable
345 ///
346 ///
347 /// #### `scale-factor`
348 /// The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
349 /// more details about widget scaling.
350 ///
351 /// Readable
352 ///
353 ///
354 /// #### `sensitive`
355 /// Readable | Writeable
356 ///
357 ///
358 /// #### `style`
359 /// The style of the widget, which contains information about how it will look (colors, etc).
360 ///
361 /// Readable | Writeable
362 ///
363 ///
364 /// #### `tooltip-markup`
365 /// Sets the text of tooltip to be the given string, which is marked up
366 /// with the [Pango text markup language][PangoMarkupFormat].
367 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
368 ///
369 /// This is a convenience property which will take care of getting the
370 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
371 /// will automatically be set to [`true`] and there will be taken care of
372 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
373 ///
374 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
375 /// are set, the last one wins.
376 ///
377 /// Readable | Writeable
378 ///
379 ///
380 /// #### `tooltip-text`
381 /// Sets the text of tooltip to be the given string.
382 ///
383 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
384 ///
385 /// This is a convenience property which will take care of getting the
386 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
387 /// will automatically be set to [`true`] and there will be taken care of
388 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
389 ///
390 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
391 /// are set, the last one wins.
392 ///
393 /// Readable | Writeable
394 ///
395 ///
396 /// #### `valign`
397 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
398 ///
399 /// Readable | Writeable
400 ///
401 ///
402 /// #### `vexpand`
403 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
404 ///
405 /// Readable | Writeable
406 ///
407 ///
408 /// #### `vexpand-set`
409 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
410 ///
411 /// Readable | Writeable
412 ///
413 ///
414 /// #### `visible`
415 /// Readable | Writeable
416 ///
417 ///
418 /// #### `width-request`
419 /// Readable | Writeable
420 ///
421 ///
422 /// #### `window`
423 /// The widget's window if it is realized, [`None`] otherwise.
424 ///
425 /// Readable
426 /// </details>
427 /// <details><summary><h4>Orientable</h4></summary>
428 ///
429 ///
430 /// #### `orientation`
431 /// The orientation of the orientable.
432 ///
433 /// Readable | Writeable
434 /// </details>
435 ///
436 /// ## Signals
437 ///
438 ///
439 /// #### `format-value`
440 /// Signal which allows you to change how the scale value is displayed.
441 /// Connect a signal handler which returns an allocated string representing
442 /// `value`. That string will then be used to display the scale's value.
443 ///
444 /// If no user-provided handlers are installed, the value will be displayed on
445 /// its own, rounded according to the value of the [`digits`][struct@crate::Scale#digits] property.
446 ///
447 /// Here's an example signal handler which displays a value 1.0 as
448 /// with "-->1.0<--".
449 ///
450 ///
451 /// **⚠️ The following code is in C ⚠️**
452 ///
453 /// ```C
454 /// static gchar*
455 /// format_value_callback (GtkScale *scale,
456 /// gdouble value)
457 /// {
458 /// return g_strdup_printf ("-->\%0.*g<--",
459 /// gtk_scale_get_digits (scale), value);
460 /// }
461 /// ```
462 ///
463 ///
464 /// <details><summary><h4>Range</h4></summary>
465 ///
466 ///
467 /// #### `adjust-bounds`
468 /// Emitted before clamping a value, to give the application a
469 /// chance to adjust the bounds.
470 ///
471 ///
472 ///
473 ///
474 /// #### `change-value`
475 /// The [`change-value`][struct@crate::Range#change-value] signal is emitted when a scroll action is
476 /// performed on a range. It allows an application to determine the
477 /// type of scroll event that occurred and the resultant new value.
478 /// The application can handle the event itself and return [`true`] to
479 /// prevent further processing. Or, by returning [`false`], it can pass
480 /// the event to other handlers until the default GTK+ handler is
481 /// reached.
482 ///
483 /// The value parameter is unrounded. An application that overrides
484 /// the GtkRange::change-value signal is responsible for clamping the
485 /// value to the desired number of decimal digits; the default GTK+
486 /// handler clamps the value based on [`round-digits`][struct@crate::Range#round-digits].
487 ///
488 ///
489 ///
490 ///
491 /// #### `move-slider`
492 /// Virtual function that moves the slider. Used for keybindings.
493 ///
494 /// Action
495 ///
496 ///
497 /// #### `value-changed`
498 /// Emitted when the range value changes.
499 ///
500 ///
501 /// </details>
502 /// <details><summary><h4>Widget</h4></summary>
503 ///
504 ///
505 /// #### `accel-closures-changed`
506 ///
507 ///
508 ///
509 /// #### `button-press-event`
510 /// The ::button-press-event signal will be emitted when a button
511 /// (typically from a mouse) is pressed.
512 ///
513 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
514 /// widget needs to enable the [`gdk::EventMask::BUTTON_PRESS_MASK`][crate::gdk::EventMask::BUTTON_PRESS_MASK] mask.
515 ///
516 /// This signal will be sent to the grab widget if there is one.
517 ///
518 ///
519 ///
520 ///
521 /// #### `button-release-event`
522 /// The ::button-release-event signal will be emitted when a button
523 /// (typically from a mouse) is released.
524 ///
525 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
526 /// widget needs to enable the [`gdk::EventMask::BUTTON_RELEASE_MASK`][crate::gdk::EventMask::BUTTON_RELEASE_MASK] mask.
527 ///
528 /// This signal will be sent to the grab widget if there is one.
529 ///
530 ///
531 ///
532 ///
533 /// #### `can-activate-accel`
534 /// Determines whether an accelerator that activates the signal
535 /// identified by `signal_id` can currently be activated.
536 /// This signal is present to allow applications and derived
537 /// widgets to override the default [`Widget`][crate::Widget] handling
538 /// for determining whether an accelerator can be activated.
539 ///
540 ///
541 ///
542 ///
543 /// #### `child-notify`
544 /// The ::child-notify signal is emitted for each
545 /// [child property][child-properties] that has
546 /// changed on an object. The signal's detail holds the property name.
547 ///
548 /// Detailed
549 ///
550 ///
551 /// #### `composited-changed`
552 /// The ::composited-changed signal is emitted when the composited
553 /// status of `widgets` screen changes.
554 /// See [`Screen::is_composited()`][crate::gdk::Screen::is_composited()].
555 ///
556 /// Action
557 ///
558 ///
559 /// #### `configure-event`
560 /// The ::configure-event signal will be emitted when the size, position or
561 /// stacking of the `widget`'s window has changed.
562 ///
563 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
564 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
565 /// automatically for all new windows.
566 ///
567 ///
568 ///
569 ///
570 /// #### `damage-event`
571 /// Emitted when a redirected window belonging to `widget` gets drawn into.
572 /// The region/area members of the event shows what area of the redirected
573 /// drawable was drawn into.
574 ///
575 ///
576 ///
577 ///
578 /// #### `delete-event`
579 /// The ::delete-event signal is emitted if a user requests that
580 /// a toplevel window is closed. The default handler for this signal
581 /// destroys the window. Connecting [`WidgetExtManual::hide_on_delete()`][crate::prelude::WidgetExtManual::hide_on_delete()] to
582 /// this signal will cause the window to be hidden instead, so that
583 /// it can later be shown again without reconstructing it.
584 ///
585 ///
586 ///
587 ///
588 /// #### `destroy`
589 /// Signals that all holders of a reference to the widget should release
590 /// the reference that they hold. May result in finalization of the widget
591 /// if all references are released.
592 ///
593 /// This signal is not suitable for saving widget state.
594 ///
595 ///
596 ///
597 ///
598 /// #### `destroy-event`
599 /// The ::destroy-event signal is emitted when a [`gdk::Window`][crate::gdk::Window] is destroyed.
600 /// You rarely get this signal, because most widgets disconnect themselves
601 /// from their window before they destroy it, so no widget owns the
602 /// window at destroy time.
603 ///
604 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
605 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
606 /// automatically for all new windows.
607 ///
608 ///
609 ///
610 ///
611 /// #### `direction-changed`
612 /// The ::direction-changed signal is emitted when the text direction
613 /// of a widget changes.
614 ///
615 ///
616 ///
617 ///
618 /// #### `drag-begin`
619 /// The ::drag-begin signal is emitted on the drag source when a drag is
620 /// started. A typical reason to connect to this signal is to set up a
621 /// custom drag icon with e.g. [`WidgetExt::drag_source_set_icon_pixbuf()`][crate::prelude::WidgetExt::drag_source_set_icon_pixbuf()].
622 ///
623 /// Note that some widgets set up a drag icon in the default handler of
624 /// this signal, so you may have to use `g_signal_connect_after()` to
625 /// override what the default handler did.
626 ///
627 ///
628 ///
629 ///
630 /// #### `drag-data-delete`
631 /// The ::drag-data-delete signal is emitted on the drag source when a drag
632 /// with the action [`gdk::DragAction::MOVE`][crate::gdk::DragAction::MOVE] is successfully completed. The signal
633 /// handler is responsible for deleting the data that has been dropped. What
634 /// "delete" means depends on the context of the drag operation.
635 ///
636 ///
637 ///
638 ///
639 /// #### `drag-data-get`
640 /// The ::drag-data-get signal is emitted on the drag source when the drop
641 /// site requests the data which is dragged. It is the responsibility of
642 /// the signal handler to fill `data` with the data in the format which
643 /// is indicated by `info`. See [`SelectionData::set()`][crate::SelectionData::set()] and
644 /// [`SelectionData::set_text()`][crate::SelectionData::set_text()].
645 ///
646 ///
647 ///
648 ///
649 /// #### `drag-data-received`
650 /// The ::drag-data-received signal is emitted on the drop site when the
651 /// dragged data has been received. If the data was received in order to
652 /// determine whether the drop will be accepted, the handler is expected
653 /// to call `gdk_drag_status()` and not finish the drag.
654 /// If the data was received in response to a [`drag-drop`][struct@crate::Widget#drag-drop] signal
655 /// (and this is the last target to be received), the handler for this
656 /// signal is expected to process the received data and then call
657 /// `gtk_drag_finish()`, setting the `success` parameter depending on
658 /// whether the data was processed successfully.
659 ///
660 /// Applications must create some means to determine why the signal was emitted
661 /// and therefore whether to call `gdk_drag_status()` or `gtk_drag_finish()`.
662 ///
663 /// The handler may inspect the selected action with
664 /// [`DragContext::selected_action()`][crate::gdk::DragContext::selected_action()] before calling
665 /// `gtk_drag_finish()`, e.g. to implement [`gdk::DragAction::ASK`][crate::gdk::DragAction::ASK] as
666 /// shown in the following example:
667 ///
668 ///
669 /// **⚠️ The following code is in C ⚠️**
670 ///
671 /// ```C
672 /// void
673 /// drag_data_received (GtkWidget *widget,
674 /// GdkDragContext *context,
675 /// gint x,
676 /// gint y,
677 /// GtkSelectionData *data,
678 /// guint info,
679 /// guint time)
680 /// {
681 /// if ((data->length >= 0) && (data->format == 8))
682 /// {
683 /// GdkDragAction action;
684 ///
685 /// // handle data here
686 ///
687 /// action = gdk_drag_context_get_selected_action (context);
688 /// if (action == GDK_ACTION_ASK)
689 /// {
690 /// GtkWidget *dialog;
691 /// gint response;
692 ///
693 /// dialog = gtk_message_dialog_new (NULL,
694 /// GTK_DIALOG_MODAL |
695 /// GTK_DIALOG_DESTROY_WITH_PARENT,
696 /// GTK_MESSAGE_INFO,
697 /// GTK_BUTTONS_YES_NO,
698 /// "Move the data ?\n");
699 /// response = gtk_dialog_run (GTK_DIALOG (dialog));
700 /// gtk_widget_destroy (dialog);
701 ///
702 /// if (response == GTK_RESPONSE_YES)
703 /// action = GDK_ACTION_MOVE;
704 /// else
705 /// action = GDK_ACTION_COPY;
706 /// }
707 ///
708 /// gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time);
709 /// }
710 /// else
711 /// gtk_drag_finish (context, FALSE, FALSE, time);
712 /// }
713 /// ```
714 ///
715 ///
716 ///
717 ///
718 /// #### `drag-drop`
719 /// The ::drag-drop signal is emitted on the drop site when the user drops
720 /// the data onto the widget. The signal handler must determine whether
721 /// the cursor position is in a drop zone or not. If it is not in a drop
722 /// zone, it returns [`false`] and no further processing is necessary.
723 /// Otherwise, the handler returns [`true`]. In this case, the handler must
724 /// ensure that `gtk_drag_finish()` is called to let the source know that
725 /// the drop is done. The call to `gtk_drag_finish()` can be done either
726 /// directly or in a [`drag-data-received`][struct@crate::Widget#drag-data-received] handler which gets
727 /// triggered by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] to receive the data for one
728 /// or more of the supported targets.
729 ///
730 ///
731 ///
732 ///
733 /// #### `drag-end`
734 /// The ::drag-end signal is emitted on the drag source when a drag is
735 /// finished. A typical reason to connect to this signal is to undo
736 /// things done in [`drag-begin`][struct@crate::Widget#drag-begin].
737 ///
738 ///
739 ///
740 ///
741 /// #### `drag-failed`
742 /// The ::drag-failed signal is emitted on the drag source when a drag has
743 /// failed. The signal handler may hook custom code to handle a failed DnD
744 /// operation based on the type of error, it returns [`true`] is the failure has
745 /// been already handled (not showing the default "drag operation failed"
746 /// animation), otherwise it returns [`false`].
747 ///
748 ///
749 ///
750 ///
751 /// #### `drag-leave`
752 /// The ::drag-leave signal is emitted on the drop site when the cursor
753 /// leaves the widget. A typical reason to connect to this signal is to
754 /// undo things done in [`drag-motion`][struct@crate::Widget#drag-motion], e.g. undo highlighting
755 /// with [`WidgetExt::drag_unhighlight()`][crate::prelude::WidgetExt::drag_unhighlight()].
756 ///
757 ///
758 /// Likewise, the [`drag-leave`][struct@crate::Widget#drag-leave] signal is also emitted before the
759 /// ::drag-drop signal, for instance to allow cleaning up of a preview item
760 /// created in the [`drag-motion`][struct@crate::Widget#drag-motion] signal handler.
761 ///
762 ///
763 ///
764 ///
765 /// #### `drag-motion`
766 /// The ::drag-motion signal is emitted on the drop site when the user
767 /// moves the cursor over the widget during a drag. The signal handler
768 /// must determine whether the cursor position is in a drop zone or not.
769 /// If it is not in a drop zone, it returns [`false`] and no further processing
770 /// is necessary. Otherwise, the handler returns [`true`]. In this case, the
771 /// handler is responsible for providing the necessary information for
772 /// displaying feedback to the user, by calling `gdk_drag_status()`.
773 ///
774 /// If the decision whether the drop will be accepted or rejected can't be
775 /// made based solely on the cursor position and the type of the data, the
776 /// handler may inspect the dragged data by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] and
777 /// defer the `gdk_drag_status()` call to the [`drag-data-received`][struct@crate::Widget#drag-data-received]
778 /// handler. Note that you must pass [`DestDefaults::DROP`][crate::DestDefaults::DROP],
779 /// [`DestDefaults::MOTION`][crate::DestDefaults::MOTION] or [`DestDefaults::ALL`][crate::DestDefaults::ALL] to [`WidgetExtManual::drag_dest_set()`][crate::prelude::WidgetExtManual::drag_dest_set()]
780 /// when using the drag-motion signal that way.
781 ///
782 /// Also note that there is no drag-enter signal. The drag receiver has to
783 /// keep track of whether he has received any drag-motion signals since the
784 /// last [`drag-leave`][struct@crate::Widget#drag-leave] and if not, treat the drag-motion signal as
785 /// an "enter" signal. Upon an "enter", the handler will typically highlight
786 /// the drop site with [`WidgetExt::drag_highlight()`][crate::prelude::WidgetExt::drag_highlight()].
787 ///
788 ///
789 /// **⚠️ The following code is in C ⚠️**
790 ///
791 /// ```C
792 /// static void
793 /// drag_motion (GtkWidget *widget,
794 /// GdkDragContext *context,
795 /// gint x,
796 /// gint y,
797 /// guint time)
798 /// {
799 /// GdkAtom target;
800 ///
801 /// PrivateData *private_data = GET_PRIVATE_DATA (widget);
802 ///
803 /// if (!private_data->drag_highlight)
804 /// {
805 /// private_data->drag_highlight = 1;
806 /// gtk_drag_highlight (widget);
807 /// }
808 ///
809 /// target = gtk_drag_dest_find_target (widget, context, NULL);
810 /// if (target == GDK_NONE)
811 /// gdk_drag_status (context, 0, time);
812 /// else
813 /// {
814 /// private_data->pending_status
815 /// = gdk_drag_context_get_suggested_action (context);
816 /// gtk_drag_get_data (widget, context, target, time);
817 /// }
818 ///
819 /// return TRUE;
820 /// }
821 ///
822 /// static void
823 /// drag_data_received (GtkWidget *widget,
824 /// GdkDragContext *context,
825 /// gint x,
826 /// gint y,
827 /// GtkSelectionData *selection_data,
828 /// guint info,
829 /// guint time)
830 /// {
831 /// PrivateData *private_data = GET_PRIVATE_DATA (widget);
832 ///
833 /// if (private_data->suggested_action)
834 /// {
835 /// private_data->suggested_action = 0;
836 ///
837 /// // We are getting this data due to a request in drag_motion,
838 /// // rather than due to a request in drag_drop, so we are just
839 /// // supposed to call gdk_drag_status(), not actually paste in
840 /// // the data.
841 ///
842 /// str = gtk_selection_data_get_text (selection_data);
843 /// if (!data_is_acceptable (str))
844 /// gdk_drag_status (context, 0, time);
845 /// else
846 /// gdk_drag_status (context,
847 /// private_data->suggested_action,
848 /// time);
849 /// }
850 /// else
851 /// {
852 /// // accept the drop
853 /// }
854 /// }
855 /// ```
856 ///
857 ///
858 ///
859 ///
860 /// #### `draw`
861 /// This signal is emitted when a widget is supposed to render itself.
862 /// The `widget`'s top left corner must be painted at the origin of
863 /// the passed in context and be sized to the values returned by
864 /// [`WidgetExt::allocated_width()`][crate::prelude::WidgetExt::allocated_width()] and
865 /// [`WidgetExt::allocated_height()`][crate::prelude::WidgetExt::allocated_height()].
866 ///
867 /// Signal handlers connected to this signal can modify the cairo
868 /// context passed as `cr` in any way they like and don't need to
869 /// restore it. The signal emission takes care of calling `cairo_save()`
870 /// before and `cairo_restore()` after invoking the handler.
871 ///
872 /// The signal handler will get a `cr` with a clip region already set to the
873 /// widget's dirty region, i.e. to the area that needs repainting. Complicated
874 /// widgets that want to avoid redrawing themselves completely can get the full
875 /// extents of the clip region with `gdk_cairo_get_clip_rectangle()`, or they can
876 /// get a finer-grained representation of the dirty region with
877 /// `cairo_copy_clip_rectangle_list()`.
878 ///
879 ///
880 ///
881 ///
882 /// #### `enter-notify-event`
883 /// The ::enter-notify-event will be emitted when the pointer enters
884 /// the `widget`'s window.
885 ///
886 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
887 /// to enable the [`gdk::EventMask::ENTER_NOTIFY_MASK`][crate::gdk::EventMask::ENTER_NOTIFY_MASK] mask.
888 ///
889 /// This signal will be sent to the grab widget if there is one.
890 ///
891 ///
892 ///
893 ///
894 /// #### `event`
895 /// The GTK+ main loop will emit three signals for each GDK event delivered
896 /// to a widget: one generic ::event signal, another, more specific,
897 /// signal that matches the type of event delivered (e.g.
898 /// [`key-press-event`][struct@crate::Widget#key-press-event]) and finally a generic
899 /// [`event-after`][struct@crate::Widget#event-after] signal.
900 ///
901 ///
902 ///
903 ///
904 /// #### `event-after`
905 /// After the emission of the [`event`][struct@crate::Widget#event] signal and (optionally)
906 /// the second more specific signal, ::event-after will be emitted
907 /// regardless of the previous two signals handlers return values.
908 ///
909 ///
910 ///
911 ///
912 /// #### `focus`
913 ///
914 ///
915 ///
916 /// #### `focus-in-event`
917 /// The ::focus-in-event signal will be emitted when the keyboard focus
918 /// enters the `widget`'s window.
919 ///
920 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
921 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
922 ///
923 ///
924 ///
925 ///
926 /// #### `focus-out-event`
927 /// The ::focus-out-event signal will be emitted when the keyboard focus
928 /// leaves the `widget`'s window.
929 ///
930 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
931 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
932 ///
933 ///
934 ///
935 ///
936 /// #### `grab-broken-event`
937 /// Emitted when a pointer or keyboard grab on a window belonging
938 /// to `widget` gets broken.
939 ///
940 /// On X11, this happens when the grab window becomes unviewable
941 /// (i.e. it or one of its ancestors is unmapped), or if the same
942 /// application grabs the pointer or keyboard again.
943 ///
944 ///
945 ///
946 ///
947 /// #### `grab-focus`
948 /// Action
949 ///
950 ///
951 /// #### `grab-notify`
952 /// The ::grab-notify signal is emitted when a widget becomes
953 /// shadowed by a GTK+ grab (not a pointer or keyboard grab) on
954 /// another widget, or when it becomes unshadowed due to a grab
955 /// being removed.
956 ///
957 /// A widget is shadowed by a [`WidgetExt::grab_add()`][crate::prelude::WidgetExt::grab_add()] when the topmost
958 /// grab widget in the grab stack of its window group is not
959 /// its ancestor.
960 ///
961 ///
962 ///
963 ///
964 /// #### `hide`
965 /// The ::hide signal is emitted when `widget` is hidden, for example with
966 /// [`WidgetExt::hide()`][crate::prelude::WidgetExt::hide()].
967 ///
968 ///
969 ///
970 ///
971 /// #### `hierarchy-changed`
972 /// The ::hierarchy-changed signal is emitted when the
973 /// anchored state of a widget changes. A widget is
974 /// “anchored” when its toplevel
975 /// ancestor is a [`Window`][crate::Window]. This signal is emitted when
976 /// a widget changes from un-anchored to anchored or vice-versa.
977 ///
978 ///
979 ///
980 ///
981 /// #### `key-press-event`
982 /// The ::key-press-event signal is emitted when a key is pressed. The signal
983 /// emission will reoccur at the key-repeat rate when the key is kept pressed.
984 ///
985 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
986 /// to enable the [`gdk::EventMask::KEY_PRESS_MASK`][crate::gdk::EventMask::KEY_PRESS_MASK] mask.
987 ///
988 /// This signal will be sent to the grab widget if there is one.
989 ///
990 ///
991 ///
992 ///
993 /// #### `key-release-event`
994 /// The ::key-release-event signal is emitted when a key is released.
995 ///
996 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
997 /// to enable the [`gdk::EventMask::KEY_RELEASE_MASK`][crate::gdk::EventMask::KEY_RELEASE_MASK] mask.
998 ///
999 /// This signal will be sent to the grab widget if there is one.
1000 ///
1001 ///
1002 ///
1003 ///
1004 /// #### `keynav-failed`
1005 /// Gets emitted if keyboard navigation fails.
1006 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
1007 ///
1008 ///
1009 ///
1010 ///
1011 /// #### `leave-notify-event`
1012 /// The ::leave-notify-event will be emitted when the pointer leaves
1013 /// the `widget`'s window.
1014 ///
1015 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1016 /// to enable the [`gdk::EventMask::LEAVE_NOTIFY_MASK`][crate::gdk::EventMask::LEAVE_NOTIFY_MASK] mask.
1017 ///
1018 /// This signal will be sent to the grab widget if there is one.
1019 ///
1020 ///
1021 ///
1022 ///
1023 /// #### `map`
1024 /// The ::map signal is emitted when `widget` is going to be mapped, that is
1025 /// when the widget is visible (which is controlled with
1026 /// [`WidgetExt::set_visible()`][crate::prelude::WidgetExt::set_visible()]) and all its parents up to the toplevel widget
1027 /// are also visible. Once the map has occurred, [`map-event`][struct@crate::Widget#map-event] will
1028 /// be emitted.
1029 ///
1030 /// The ::map signal can be used to determine whether a widget will be drawn,
1031 /// for instance it can resume an animation that was stopped during the
1032 /// emission of [`unmap`][struct@crate::Widget#unmap].
1033 ///
1034 ///
1035 ///
1036 ///
1037 /// #### `map-event`
1038 /// The ::map-event signal will be emitted when the `widget`'s window is
1039 /// mapped. A window is mapped when it becomes visible on the screen.
1040 ///
1041 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1042 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1043 /// automatically for all new windows.
1044 ///
1045 ///
1046 ///
1047 ///
1048 /// #### `mnemonic-activate`
1049 /// The default handler for this signal activates `widget` if `group_cycling`
1050 /// is [`false`], or just makes `widget` grab focus if `group_cycling` is [`true`].
1051 ///
1052 ///
1053 ///
1054 ///
1055 /// #### `motion-notify-event`
1056 /// The ::motion-notify-event signal is emitted when the pointer moves
1057 /// over the widget's [`gdk::Window`][crate::gdk::Window].
1058 ///
1059 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget
1060 /// needs to enable the [`gdk::EventMask::POINTER_MOTION_MASK`][crate::gdk::EventMask::POINTER_MOTION_MASK] mask.
1061 ///
1062 /// This signal will be sent to the grab widget if there is one.
1063 ///
1064 ///
1065 ///
1066 ///
1067 /// #### `move-focus`
1068 /// Action
1069 ///
1070 ///
1071 /// #### `parent-set`
1072 /// The ::parent-set signal is emitted when a new parent
1073 /// has been set on a widget.
1074 ///
1075 ///
1076 ///
1077 ///
1078 /// #### `popup-menu`
1079 /// This signal gets emitted whenever a widget should pop up a context
1080 /// menu. This usually happens through the standard key binding mechanism;
1081 /// by pressing a certain key while a widget is focused, the user can cause
1082 /// the widget to pop up a menu. For example, the [`Entry`][crate::Entry] widget creates
1083 /// a menu with clipboard commands. See the
1084 /// [Popup Menu Migration Checklist][checklist-popup-menu]
1085 /// for an example of how to use this signal.
1086 ///
1087 /// Action
1088 ///
1089 ///
1090 /// #### `property-notify-event`
1091 /// The ::property-notify-event signal will be emitted when a property on
1092 /// the `widget`'s window has been changed or deleted.
1093 ///
1094 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1095 /// to enable the [`gdk::EventMask::PROPERTY_CHANGE_MASK`][crate::gdk::EventMask::PROPERTY_CHANGE_MASK] mask.
1096 ///
1097 ///
1098 ///
1099 ///
1100 /// #### `proximity-in-event`
1101 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1102 /// to enable the [`gdk::EventMask::PROXIMITY_IN_MASK`][crate::gdk::EventMask::PROXIMITY_IN_MASK] mask.
1103 ///
1104 /// This signal will be sent to the grab widget if there is one.
1105 ///
1106 ///
1107 ///
1108 ///
1109 /// #### `proximity-out-event`
1110 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1111 /// to enable the [`gdk::EventMask::PROXIMITY_OUT_MASK`][crate::gdk::EventMask::PROXIMITY_OUT_MASK] mask.
1112 ///
1113 /// This signal will be sent to the grab widget if there is one.
1114 ///
1115 ///
1116 ///
1117 ///
1118 /// #### `query-tooltip`
1119 /// Emitted when [`has-tooltip`][struct@crate::Widget#has-tooltip] is [`true`] and the hover timeout
1120 /// has expired with the cursor hovering "above" `widget`; or emitted when `widget` got
1121 /// focus in keyboard mode.
1122 ///
1123 /// Using the given coordinates, the signal handler should determine
1124 /// whether a tooltip should be shown for `widget`. If this is the case
1125 /// [`true`] should be returned, [`false`] otherwise. Note that if
1126 /// `keyboard_mode` is [`true`], the values of `x` and `y` are undefined and
1127 /// should not be used.
1128 ///
1129 /// The signal handler is free to manipulate `tooltip` with the therefore
1130 /// destined function calls.
1131 ///
1132 ///
1133 ///
1134 ///
1135 /// #### `realize`
1136 /// The ::realize signal is emitted when `widget` is associated with a
1137 /// [`gdk::Window`][crate::gdk::Window], which means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called or the
1138 /// widget has been mapped (that is, it is going to be drawn).
1139 ///
1140 ///
1141 ///
1142 ///
1143 /// #### `screen-changed`
1144 /// The ::screen-changed signal gets emitted when the
1145 /// screen of a widget has changed.
1146 ///
1147 ///
1148 ///
1149 ///
1150 /// #### `scroll-event`
1151 /// The ::scroll-event signal is emitted when a button in the 4 to 7
1152 /// range is pressed. Wheel mice are usually configured to generate
1153 /// button press events for buttons 4 and 5 when the wheel is turned.
1154 ///
1155 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1156 /// to enable the [`gdk::EventMask::SCROLL_MASK`][crate::gdk::EventMask::SCROLL_MASK] mask.
1157 ///
1158 /// This signal will be sent to the grab widget if there is one.
1159 ///
1160 ///
1161 ///
1162 ///
1163 /// #### `selection-clear-event`
1164 /// The ::selection-clear-event signal will be emitted when the
1165 /// the `widget`'s window has lost ownership of a selection.
1166 ///
1167 ///
1168 ///
1169 ///
1170 /// #### `selection-get`
1171 ///
1172 ///
1173 ///
1174 /// #### `selection-notify-event`
1175 ///
1176 ///
1177 ///
1178 /// #### `selection-received`
1179 ///
1180 ///
1181 ///
1182 /// #### `selection-request-event`
1183 /// The ::selection-request-event signal will be emitted when
1184 /// another client requests ownership of the selection owned by
1185 /// the `widget`'s window.
1186 ///
1187 ///
1188 ///
1189 ///
1190 /// #### `show`
1191 /// The ::show signal is emitted when `widget` is shown, for example with
1192 /// [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
1193 ///
1194 ///
1195 ///
1196 ///
1197 /// #### `show-help`
1198 /// Action
1199 ///
1200 ///
1201 /// #### `size-allocate`
1202 ///
1203 ///
1204 ///
1205 /// #### `state-changed`
1206 /// The ::state-changed signal is emitted when the widget state changes.
1207 /// See `gtk_widget_get_state()`.
1208 ///
1209 ///
1210 ///
1211 ///
1212 /// #### `state-flags-changed`
1213 /// The ::state-flags-changed signal is emitted when the widget state
1214 /// changes, see [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
1215 ///
1216 ///
1217 ///
1218 ///
1219 /// #### `style-set`
1220 /// The ::style-set signal is emitted when a new style has been set
1221 /// on a widget. Note that style-modifying functions like
1222 /// `gtk_widget_modify_base()` also cause this signal to be emitted.
1223 ///
1224 /// Note that this signal is emitted for changes to the deprecated
1225 /// `GtkStyle`. To track changes to the [`StyleContext`][crate::StyleContext] associated
1226 /// with a widget, use the [`style-updated`][struct@crate::Widget#style-updated] signal.
1227 ///
1228 ///
1229 ///
1230 ///
1231 /// #### `style-updated`
1232 /// The ::style-updated signal is a convenience signal that is emitted when the
1233 /// [`changed`][struct@crate::StyleContext#changed] signal is emitted on the `widget`'s associated
1234 /// [`StyleContext`][crate::StyleContext] as returned by [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()].
1235 ///
1236 /// Note that style-modifying functions like `gtk_widget_override_color()` also
1237 /// cause this signal to be emitted.
1238 ///
1239 ///
1240 ///
1241 ///
1242 /// #### `touch-event`
1243 ///
1244 ///
1245 ///
1246 /// #### `unmap`
1247 /// The ::unmap signal is emitted when `widget` is going to be unmapped, which
1248 /// means that either it or any of its parents up to the toplevel widget have
1249 /// been set as hidden.
1250 ///
1251 /// As ::unmap indicates that a widget will not be shown any longer, it can be
1252 /// used to, for example, stop an animation on the widget.
1253 ///
1254 ///
1255 ///
1256 ///
1257 /// #### `unmap-event`
1258 /// The ::unmap-event signal will be emitted when the `widget`'s window is
1259 /// unmapped. A window is unmapped when it becomes invisible on the screen.
1260 ///
1261 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1262 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1263 /// automatically for all new windows.
1264 ///
1265 ///
1266 ///
1267 ///
1268 /// #### `unrealize`
1269 /// The ::unrealize signal is emitted when the [`gdk::Window`][crate::gdk::Window] associated with
1270 /// `widget` is destroyed, which means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been
1271 /// called or the widget has been unmapped (that is, it is going to be
1272 /// hidden).
1273 ///
1274 ///
1275 ///
1276 ///
1277 /// #### `visibility-notify-event`
1278 /// The ::visibility-notify-event will be emitted when the `widget`'s
1279 /// window is obscured or unobscured.
1280 ///
1281 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1282 /// to enable the [`gdk::EventMask::VISIBILITY_NOTIFY_MASK`][crate::gdk::EventMask::VISIBILITY_NOTIFY_MASK] mask.
1283 ///
1284 ///
1285 ///
1286 ///
1287 /// #### `window-state-event`
1288 /// The ::window-state-event will be emitted when the state of the
1289 /// toplevel window associated to the `widget` changes.
1290 ///
1291 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget
1292 /// needs to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable
1293 /// this mask automatically for all new windows.
1294 ///
1295 ///
1296 /// </details>
1297 ///
1298 /// # Implements
1299 ///
1300 /// [`ScaleExt`][trait@crate::prelude::ScaleExt], [`RangeExt`][trait@crate::prelude::RangeExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`OrientableExt`][trait@crate::prelude::OrientableExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
1301 #[doc(alias = "GtkScale")]
1302 pub struct Scale(Object<ffi::GtkScale, ffi::GtkScaleClass>) @extends Range, Widget, @implements Buildable, Orientable;
1303
1304 match fn {
1305 type_ => || ffi::gtk_scale_get_type(),
1306 }
1307}
1308
1309impl Scale {
1310 pub const NONE: Option<&'static Scale> = None;
1311
1312 /// Creates a new [`Scale`][crate::Scale].
1313 /// ## `orientation`
1314 /// the scale’s orientation.
1315 /// ## `adjustment`
1316 /// the [`Adjustment`][crate::Adjustment] which sets the range
1317 /// of the scale, or [`None`] to create a new adjustment.
1318 ///
1319 /// # Returns
1320 ///
1321 /// a new [`Scale`][crate::Scale]
1322 #[doc(alias = "gtk_scale_new")]
1323 pub fn new(orientation: Orientation, adjustment: Option<&impl IsA<Adjustment>>) -> Scale {
1324 assert_initialized_main_thread!();
1325 unsafe {
1326 Widget::from_glib_none(ffi::gtk_scale_new(
1327 orientation.into_glib(),
1328 adjustment.map(|p| p.as_ref()).to_glib_none().0,
1329 ))
1330 .unsafe_cast()
1331 }
1332 }
1333
1334 /// Creates a new scale widget with the given orientation that lets the
1335 /// user input a number between `min` and `max` (including `min` and `max`)
1336 /// with the increment `step`. `step` must be nonzero; it’s the distance
1337 /// the slider moves when using the arrow keys to adjust the scale
1338 /// value.
1339 ///
1340 /// Note that the way in which the precision is derived works best if `step`
1341 /// is a power of ten. If the resulting precision is not suitable for your
1342 /// needs, use [`ScaleExt::set_digits()`][crate::prelude::ScaleExt::set_digits()] to correct it.
1343 /// ## `orientation`
1344 /// the scale’s orientation.
1345 /// ## `min`
1346 /// minimum value
1347 /// ## `max`
1348 /// maximum value
1349 /// ## `step`
1350 /// step increment (tick size) used with keyboard shortcuts
1351 ///
1352 /// # Returns
1353 ///
1354 /// a new [`Scale`][crate::Scale]
1355 #[doc(alias = "gtk_scale_new_with_range")]
1356 #[doc(alias = "new_with_range")]
1357 pub fn with_range(orientation: Orientation, min: f64, max: f64, step: f64) -> Scale {
1358 assert_initialized_main_thread!();
1359 unsafe {
1360 Widget::from_glib_none(ffi::gtk_scale_new_with_range(
1361 orientation.into_glib(),
1362 min,
1363 max,
1364 step,
1365 ))
1366 .unsafe_cast()
1367 }
1368 }
1369
1370 // rustdoc-stripper-ignore-next
1371 /// Creates a new builder-pattern struct instance to construct [`Scale`] objects.
1372 ///
1373 /// This method returns an instance of [`ScaleBuilder`](crate::builders::ScaleBuilder) which can be used to create [`Scale`] objects.
1374 pub fn builder() -> ScaleBuilder {
1375 ScaleBuilder::new()
1376 }
1377}
1378
1379impl Default for Scale {
1380 fn default() -> Self {
1381 glib::object::Object::new::<Self>()
1382 }
1383}
1384
1385// rustdoc-stripper-ignore-next
1386/// A [builder-pattern] type to construct [`Scale`] objects.
1387///
1388/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1389#[must_use = "The builder must be built to be used"]
1390pub struct ScaleBuilder {
1391 builder: glib::object::ObjectBuilder<'static, Scale>,
1392}
1393
1394impl ScaleBuilder {
1395 fn new() -> Self {
1396 Self {
1397 builder: glib::object::Object::builder(),
1398 }
1399 }
1400
1401 pub fn digits(self, digits: i32) -> Self {
1402 Self {
1403 builder: self.builder.property("digits", digits),
1404 }
1405 }
1406
1407 pub fn draw_value(self, draw_value: bool) -> Self {
1408 Self {
1409 builder: self.builder.property("draw-value", draw_value),
1410 }
1411 }
1412
1413 pub fn has_origin(self, has_origin: bool) -> Self {
1414 Self {
1415 builder: self.builder.property("has-origin", has_origin),
1416 }
1417 }
1418
1419 pub fn value_pos(self, value_pos: PositionType) -> Self {
1420 Self {
1421 builder: self.builder.property("value-pos", value_pos),
1422 }
1423 }
1424
1425 pub fn adjustment(self, adjustment: &impl IsA<Adjustment>) -> Self {
1426 Self {
1427 builder: self
1428 .builder
1429 .property("adjustment", adjustment.clone().upcast()),
1430 }
1431 }
1432
1433 /// The fill level (e.g. prebuffering of a network stream).
1434 /// See [`RangeExt::set_fill_level()`][crate::prelude::RangeExt::set_fill_level()].
1435 pub fn fill_level(self, fill_level: f64) -> Self {
1436 Self {
1437 builder: self.builder.property("fill-level", fill_level),
1438 }
1439 }
1440
1441 pub fn inverted(self, inverted: bool) -> Self {
1442 Self {
1443 builder: self.builder.property("inverted", inverted),
1444 }
1445 }
1446
1447 pub fn lower_stepper_sensitivity(self, lower_stepper_sensitivity: SensitivityType) -> Self {
1448 Self {
1449 builder: self
1450 .builder
1451 .property("lower-stepper-sensitivity", lower_stepper_sensitivity),
1452 }
1453 }
1454
1455 /// The restrict-to-fill-level property controls whether slider
1456 /// movement is restricted to an upper boundary set by the
1457 /// fill level. See [`RangeExt::set_restrict_to_fill_level()`][crate::prelude::RangeExt::set_restrict_to_fill_level()].
1458 pub fn restrict_to_fill_level(self, restrict_to_fill_level: bool) -> Self {
1459 Self {
1460 builder: self
1461 .builder
1462 .property("restrict-to-fill-level", restrict_to_fill_level),
1463 }
1464 }
1465
1466 /// The number of digits to round the value to when
1467 /// it changes, or -1. See [`change-value`][struct@crate::Range#change-value].
1468 pub fn round_digits(self, round_digits: i32) -> Self {
1469 Self {
1470 builder: self.builder.property("round-digits", round_digits),
1471 }
1472 }
1473
1474 /// The show-fill-level property controls whether fill level indicator
1475 /// graphics are displayed on the trough. See
1476 /// [`RangeExt::set_show_fill_level()`][crate::prelude::RangeExt::set_show_fill_level()].
1477 pub fn show_fill_level(self, show_fill_level: bool) -> Self {
1478 Self {
1479 builder: self.builder.property("show-fill-level", show_fill_level),
1480 }
1481 }
1482
1483 pub fn upper_stepper_sensitivity(self, upper_stepper_sensitivity: SensitivityType) -> Self {
1484 Self {
1485 builder: self
1486 .builder
1487 .property("upper-stepper-sensitivity", upper_stepper_sensitivity),
1488 }
1489 }
1490
1491 pub fn app_paintable(self, app_paintable: bool) -> Self {
1492 Self {
1493 builder: self.builder.property("app-paintable", app_paintable),
1494 }
1495 }
1496
1497 pub fn can_default(self, can_default: bool) -> Self {
1498 Self {
1499 builder: self.builder.property("can-default", can_default),
1500 }
1501 }
1502
1503 pub fn can_focus(self, can_focus: bool) -> Self {
1504 Self {
1505 builder: self.builder.property("can-focus", can_focus),
1506 }
1507 }
1508
1509 pub fn events(self, events: gdk::EventMask) -> Self {
1510 Self {
1511 builder: self.builder.property("events", events),
1512 }
1513 }
1514
1515 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
1516 pub fn expand(self, expand: bool) -> Self {
1517 Self {
1518 builder: self.builder.property("expand", expand),
1519 }
1520 }
1521
1522 /// Whether the widget should grab focus when it is clicked with the mouse.
1523 ///
1524 /// This property is only relevant for widgets that can take focus.
1525 ///
1526 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
1527 /// GtkComboBox) implemented this property individually.
1528 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1529 Self {
1530 builder: self.builder.property("focus-on-click", focus_on_click),
1531 }
1532 }
1533
1534 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
1535 pub fn halign(self, halign: Align) -> Self {
1536 Self {
1537 builder: self.builder.property("halign", halign),
1538 }
1539 }
1540
1541 pub fn has_default(self, has_default: bool) -> Self {
1542 Self {
1543 builder: self.builder.property("has-default", has_default),
1544 }
1545 }
1546
1547 pub fn has_focus(self, has_focus: bool) -> Self {
1548 Self {
1549 builder: self.builder.property("has-focus", has_focus),
1550 }
1551 }
1552
1553 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
1554 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
1555 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
1556 /// whether it will provide a tooltip or not.
1557 ///
1558 /// Note that setting this property to [`true`] for the first time will change
1559 /// the event masks of the GdkWindows of this widget to include leave-notify
1560 /// and motion-notify events. This cannot and will not be undone when the
1561 /// property is set to [`false`] again.
1562 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1563 Self {
1564 builder: self.builder.property("has-tooltip", has_tooltip),
1565 }
1566 }
1567
1568 pub fn height_request(self, height_request: i32) -> Self {
1569 Self {
1570 builder: self.builder.property("height-request", height_request),
1571 }
1572 }
1573
1574 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
1575 pub fn hexpand(self, hexpand: bool) -> Self {
1576 Self {
1577 builder: self.builder.property("hexpand", hexpand),
1578 }
1579 }
1580
1581 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
1582 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1583 Self {
1584 builder: self.builder.property("hexpand-set", hexpand_set),
1585 }
1586 }
1587
1588 pub fn is_focus(self, is_focus: bool) -> Self {
1589 Self {
1590 builder: self.builder.property("is-focus", is_focus),
1591 }
1592 }
1593
1594 /// Sets all four sides' margin at once. If read, returns max
1595 /// margin on any side.
1596 pub fn margin(self, margin: i32) -> Self {
1597 Self {
1598 builder: self.builder.property("margin", margin),
1599 }
1600 }
1601
1602 /// Margin on bottom side of widget.
1603 ///
1604 /// This property adds margin outside of the widget's normal size
1605 /// request, the margin will be added in addition to the size from
1606 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1607 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1608 Self {
1609 builder: self.builder.property("margin-bottom", margin_bottom),
1610 }
1611 }
1612
1613 /// Margin on end of widget, horizontally. This property supports
1614 /// left-to-right and right-to-left text directions.
1615 ///
1616 /// This property adds margin outside of the widget's normal size
1617 /// request, the margin will be added in addition to the size from
1618 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1619 pub fn margin_end(self, margin_end: i32) -> Self {
1620 Self {
1621 builder: self.builder.property("margin-end", margin_end),
1622 }
1623 }
1624
1625 /// Margin on start of widget, horizontally. This property supports
1626 /// left-to-right and right-to-left text directions.
1627 ///
1628 /// This property adds margin outside of the widget's normal size
1629 /// request, the margin will be added in addition to the size from
1630 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1631 pub fn margin_start(self, margin_start: i32) -> Self {
1632 Self {
1633 builder: self.builder.property("margin-start", margin_start),
1634 }
1635 }
1636
1637 /// Margin on top side of widget.
1638 ///
1639 /// This property adds margin outside of the widget's normal size
1640 /// request, the margin will be added in addition to the size from
1641 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1642 pub fn margin_top(self, margin_top: i32) -> Self {
1643 Self {
1644 builder: self.builder.property("margin-top", margin_top),
1645 }
1646 }
1647
1648 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1649 Self {
1650 builder: self.builder.property("name", name.into()),
1651 }
1652 }
1653
1654 pub fn no_show_all(self, no_show_all: bool) -> Self {
1655 Self {
1656 builder: self.builder.property("no-show-all", no_show_all),
1657 }
1658 }
1659
1660 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
1661 /// more details about window opacity.
1662 ///
1663 /// Before 3.8 this was only available in GtkWindow
1664 pub fn opacity(self, opacity: f64) -> Self {
1665 Self {
1666 builder: self.builder.property("opacity", opacity),
1667 }
1668 }
1669
1670 pub fn parent(self, parent: &impl IsA<Container>) -> Self {
1671 Self {
1672 builder: self.builder.property("parent", parent.clone().upcast()),
1673 }
1674 }
1675
1676 pub fn receives_default(self, receives_default: bool) -> Self {
1677 Self {
1678 builder: self.builder.property("receives-default", receives_default),
1679 }
1680 }
1681
1682 pub fn sensitive(self, sensitive: bool) -> Self {
1683 Self {
1684 builder: self.builder.property("sensitive", sensitive),
1685 }
1686 }
1687
1688 /// Sets the text of tooltip to be the given string, which is marked up
1689 /// with the [Pango text markup language][PangoMarkupFormat].
1690 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1691 ///
1692 /// This is a convenience property which will take care of getting the
1693 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1694 /// will automatically be set to [`true`] and there will be taken care of
1695 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1696 ///
1697 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1698 /// are set, the last one wins.
1699 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1700 Self {
1701 builder: self
1702 .builder
1703 .property("tooltip-markup", tooltip_markup.into()),
1704 }
1705 }
1706
1707 /// Sets the text of tooltip to be the given string.
1708 ///
1709 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1710 ///
1711 /// This is a convenience property which will take care of getting the
1712 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1713 /// will automatically be set to [`true`] and there will be taken care of
1714 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1715 ///
1716 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1717 /// are set, the last one wins.
1718 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1719 Self {
1720 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1721 }
1722 }
1723
1724 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
1725 pub fn valign(self, valign: Align) -> Self {
1726 Self {
1727 builder: self.builder.property("valign", valign),
1728 }
1729 }
1730
1731 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
1732 pub fn vexpand(self, vexpand: bool) -> Self {
1733 Self {
1734 builder: self.builder.property("vexpand", vexpand),
1735 }
1736 }
1737
1738 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
1739 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1740 Self {
1741 builder: self.builder.property("vexpand-set", vexpand_set),
1742 }
1743 }
1744
1745 pub fn visible(self, visible: bool) -> Self {
1746 Self {
1747 builder: self.builder.property("visible", visible),
1748 }
1749 }
1750
1751 pub fn width_request(self, width_request: i32) -> Self {
1752 Self {
1753 builder: self.builder.property("width-request", width_request),
1754 }
1755 }
1756
1757 /// The orientation of the orientable.
1758 pub fn orientation(self, orientation: Orientation) -> Self {
1759 Self {
1760 builder: self.builder.property("orientation", orientation),
1761 }
1762 }
1763
1764 // rustdoc-stripper-ignore-next
1765 /// Build the [`Scale`].
1766 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1767 pub fn build(self) -> Scale {
1768 self.builder.build()
1769 }
1770}
1771
1772mod sealed {
1773 pub trait Sealed {}
1774 impl<T: super::IsA<super::Scale>> Sealed for T {}
1775}
1776
1777/// Trait containing all [`struct@Scale`] methods.
1778///
1779/// # Implementors
1780///
1781/// [`Scale`][struct@crate::Scale]
1782pub trait ScaleExt: IsA<Scale> + sealed::Sealed + 'static {
1783 /// Adds a mark at `value`.
1784 ///
1785 /// A mark is indicated visually by drawing a tick mark next to the scale,
1786 /// and GTK+ makes it easy for the user to position the scale exactly at the
1787 /// marks value.
1788 ///
1789 /// If `markup` is not [`None`], text is shown next to the tick mark.
1790 ///
1791 /// To remove marks from a scale, use [`clear_marks()`][Self::clear_marks()].
1792 /// ## `value`
1793 /// the value at which the mark is placed, must be between
1794 /// the lower and upper limits of the scales’ adjustment
1795 /// ## `position`
1796 /// where to draw the mark. For a horizontal scale, [`PositionType::Top`][crate::PositionType::Top]
1797 /// and [`PositionType::Left`][crate::PositionType::Left] are drawn above the scale, anything else below.
1798 /// For a vertical scale, [`PositionType::Left`][crate::PositionType::Left] and [`PositionType::Top`][crate::PositionType::Top] are drawn to
1799 /// the left of the scale, anything else to the right.
1800 /// ## `markup`
1801 /// Text to be shown at the mark, using [Pango markup][PangoMarkupFormat], or [`None`]
1802 #[doc(alias = "gtk_scale_add_mark")]
1803 fn add_mark(&self, value: f64, position: PositionType, markup: Option<&str>) {
1804 unsafe {
1805 ffi::gtk_scale_add_mark(
1806 self.as_ref().to_glib_none().0,
1807 value,
1808 position.into_glib(),
1809 markup.to_glib_none().0,
1810 );
1811 }
1812 }
1813
1814 /// Removes any marks that have been added with [`add_mark()`][Self::add_mark()].
1815 #[doc(alias = "gtk_scale_clear_marks")]
1816 fn clear_marks(&self) {
1817 unsafe {
1818 ffi::gtk_scale_clear_marks(self.as_ref().to_glib_none().0);
1819 }
1820 }
1821
1822 /// Gets the number of decimal places that are displayed in the value.
1823 ///
1824 /// # Returns
1825 ///
1826 /// the number of decimal places that are displayed
1827 #[doc(alias = "gtk_scale_get_digits")]
1828 #[doc(alias = "get_digits")]
1829 fn digits(&self) -> i32 {
1830 unsafe { ffi::gtk_scale_get_digits(self.as_ref().to_glib_none().0) }
1831 }
1832
1833 /// Returns whether the current value is displayed as a string
1834 /// next to the slider.
1835 ///
1836 /// # Returns
1837 ///
1838 /// whether the current value is displayed as a string
1839 #[doc(alias = "gtk_scale_get_draw_value")]
1840 #[doc(alias = "get_draw_value")]
1841 fn draws_value(&self) -> bool {
1842 unsafe {
1843 from_glib(ffi::gtk_scale_get_draw_value(
1844 self.as_ref().to_glib_none().0,
1845 ))
1846 }
1847 }
1848
1849 /// Returns whether the scale has an origin.
1850 ///
1851 /// # Returns
1852 ///
1853 /// [`true`] if the scale has an origin.
1854 #[doc(alias = "gtk_scale_get_has_origin")]
1855 #[doc(alias = "get_has_origin")]
1856 fn has_origin(&self) -> bool {
1857 unsafe {
1858 from_glib(ffi::gtk_scale_get_has_origin(
1859 self.as_ref().to_glib_none().0,
1860 ))
1861 }
1862 }
1863
1864 /// Gets the [`pango::Layout`][crate::pango::Layout] used to display the scale. The returned
1865 /// object is owned by the scale so does not need to be freed by
1866 /// the caller.
1867 ///
1868 /// # Returns
1869 ///
1870 /// the [`pango::Layout`][crate::pango::Layout] for this scale,
1871 /// or [`None`] if the [`draw-value`][struct@crate::Scale#draw-value] property is [`false`].
1872 #[doc(alias = "gtk_scale_get_layout")]
1873 #[doc(alias = "get_layout")]
1874 fn layout(&self) -> Option<pango::Layout> {
1875 unsafe { from_glib_none(ffi::gtk_scale_get_layout(self.as_ref().to_glib_none().0)) }
1876 }
1877
1878 /// Obtains the coordinates where the scale will draw the
1879 /// [`pango::Layout`][crate::pango::Layout] representing the text in the scale. Remember
1880 /// when using the [`pango::Layout`][crate::pango::Layout] function you need to convert to
1881 /// and from pixels using PANGO_PIXELS() or `PANGO_SCALE`.
1882 ///
1883 /// If the [`draw-value`][struct@crate::Scale#draw-value] property is [`false`], the return
1884 /// values are undefined.
1885 ///
1886 /// # Returns
1887 ///
1888 ///
1889 /// ## `x`
1890 /// location to store X offset of layout, or [`None`]
1891 ///
1892 /// ## `y`
1893 /// location to store Y offset of layout, or [`None`]
1894 #[doc(alias = "gtk_scale_get_layout_offsets")]
1895 #[doc(alias = "get_layout_offsets")]
1896 fn layout_offsets(&self) -> (i32, i32) {
1897 unsafe {
1898 let mut x = mem::MaybeUninit::uninit();
1899 let mut y = mem::MaybeUninit::uninit();
1900 ffi::gtk_scale_get_layout_offsets(
1901 self.as_ref().to_glib_none().0,
1902 x.as_mut_ptr(),
1903 y.as_mut_ptr(),
1904 );
1905 (x.assume_init(), y.assume_init())
1906 }
1907 }
1908
1909 /// Gets the position in which the current value is displayed.
1910 ///
1911 /// # Returns
1912 ///
1913 /// the position in which the current value is displayed
1914 #[doc(alias = "gtk_scale_get_value_pos")]
1915 #[doc(alias = "get_value_pos")]
1916 fn value_pos(&self) -> PositionType {
1917 unsafe { from_glib(ffi::gtk_scale_get_value_pos(self.as_ref().to_glib_none().0)) }
1918 }
1919
1920 /// Sets the number of decimal places that are displayed in the value. Also
1921 /// causes the value of the adjustment to be rounded to this number of digits,
1922 /// so the retrieved value matches the displayed one, if [`draw-value`][struct@crate::Scale#draw-value] is
1923 /// [`true`] when the value changes. If you want to enforce rounding the value when
1924 /// [`draw-value`][struct@crate::Scale#draw-value] is [`false`], you can set [`round-digits`][struct@crate::Range#round-digits] instead.
1925 ///
1926 /// Note that rounding to a small number of digits can interfere with
1927 /// the smooth autoscrolling that is built into [`Scale`][crate::Scale]. As an alternative,
1928 /// you can use the [`format-value`][struct@crate::Scale#format-value] signal to format the displayed
1929 /// value yourself.
1930 /// ## `digits`
1931 /// the number of decimal places to display,
1932 /// e.g. use 1 to display 1.0, 2 to display 1.00, etc
1933 #[doc(alias = "gtk_scale_set_digits")]
1934 fn set_digits(&self, digits: i32) {
1935 unsafe {
1936 ffi::gtk_scale_set_digits(self.as_ref().to_glib_none().0, digits);
1937 }
1938 }
1939
1940 /// Specifies whether the current value is displayed as a string next
1941 /// to the slider.
1942 /// ## `draw_value`
1943 /// [`true`] to draw the value
1944 #[doc(alias = "gtk_scale_set_draw_value")]
1945 fn set_draw_value(&self, draw_value: bool) {
1946 unsafe {
1947 ffi::gtk_scale_set_draw_value(self.as_ref().to_glib_none().0, draw_value.into_glib());
1948 }
1949 }
1950
1951 /// If [`has-origin`][struct@crate::Scale#has-origin] is set to [`true`] (the default), the scale will
1952 /// highlight the part of the trough between the origin (bottom or left side)
1953 /// and the current value.
1954 /// ## `has_origin`
1955 /// [`true`] if the scale has an origin
1956 #[doc(alias = "gtk_scale_set_has_origin")]
1957 fn set_has_origin(&self, has_origin: bool) {
1958 unsafe {
1959 ffi::gtk_scale_set_has_origin(self.as_ref().to_glib_none().0, has_origin.into_glib());
1960 }
1961 }
1962
1963 /// Sets the position in which the current value is displayed.
1964 /// ## `pos`
1965 /// the position in which the current value is displayed
1966 #[doc(alias = "gtk_scale_set_value_pos")]
1967 fn set_value_pos(&self, pos: PositionType) {
1968 unsafe {
1969 ffi::gtk_scale_set_value_pos(self.as_ref().to_glib_none().0, pos.into_glib());
1970 }
1971 }
1972
1973 /// Signal which allows you to change how the scale value is displayed.
1974 /// Connect a signal handler which returns an allocated string representing
1975 /// `value`. That string will then be used to display the scale's value.
1976 ///
1977 /// If no user-provided handlers are installed, the value will be displayed on
1978 /// its own, rounded according to the value of the [`digits`][struct@crate::Scale#digits] property.
1979 ///
1980 /// Here's an example signal handler which displays a value 1.0 as
1981 /// with "-->1.0<--".
1982 ///
1983 ///
1984 /// **⚠️ The following code is in C ⚠️**
1985 ///
1986 /// ```C
1987 /// static gchar*
1988 /// format_value_callback (GtkScale *scale,
1989 /// gdouble value)
1990 /// {
1991 /// return g_strdup_printf ("-->\%0.*g<--",
1992 /// gtk_scale_get_digits (scale), value);
1993 /// }
1994 /// ```
1995 /// ## `value`
1996 /// the value to format
1997 ///
1998 /// # Returns
1999 ///
2000 /// allocated string representing `value`
2001 #[doc(alias = "format-value")]
2002 fn connect_format_value<F: Fn(&Self, f64) -> String + 'static>(&self, f: F) -> SignalHandlerId {
2003 unsafe extern "C" fn format_value_trampoline<
2004 P: IsA<Scale>,
2005 F: Fn(&P, f64) -> String + 'static,
2006 >(
2007 this: *mut ffi::GtkScale,
2008 value: libc::c_double,
2009 f: glib::ffi::gpointer,
2010 ) -> *mut libc::c_char {
2011 let f: &F = &*(f as *const F);
2012 f(Scale::from_glib_borrow(this).unsafe_cast_ref(), value).to_glib_full()
2013 }
2014 unsafe {
2015 let f: Box_<F> = Box_::new(f);
2016 connect_raw(
2017 self.as_ptr() as *mut _,
2018 b"format-value\0".as_ptr() as *const _,
2019 Some(transmute::<_, unsafe extern "C" fn()>(
2020 format_value_trampoline::<Self, F> as *const (),
2021 )),
2022 Box_::into_raw(f),
2023 )
2024 }
2025 }
2026
2027 #[doc(alias = "digits")]
2028 fn connect_digits_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2029 unsafe extern "C" fn notify_digits_trampoline<P: IsA<Scale>, F: Fn(&P) + 'static>(
2030 this: *mut ffi::GtkScale,
2031 _param_spec: glib::ffi::gpointer,
2032 f: glib::ffi::gpointer,
2033 ) {
2034 let f: &F = &*(f as *const F);
2035 f(Scale::from_glib_borrow(this).unsafe_cast_ref())
2036 }
2037 unsafe {
2038 let f: Box_<F> = Box_::new(f);
2039 connect_raw(
2040 self.as_ptr() as *mut _,
2041 b"notify::digits\0".as_ptr() as *const _,
2042 Some(transmute::<_, unsafe extern "C" fn()>(
2043 notify_digits_trampoline::<Self, F> as *const (),
2044 )),
2045 Box_::into_raw(f),
2046 )
2047 }
2048 }
2049
2050 #[doc(alias = "draw-value")]
2051 fn connect_draw_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2052 unsafe extern "C" fn notify_draw_value_trampoline<P: IsA<Scale>, F: Fn(&P) + 'static>(
2053 this: *mut ffi::GtkScale,
2054 _param_spec: glib::ffi::gpointer,
2055 f: glib::ffi::gpointer,
2056 ) {
2057 let f: &F = &*(f as *const F);
2058 f(Scale::from_glib_borrow(this).unsafe_cast_ref())
2059 }
2060 unsafe {
2061 let f: Box_<F> = Box_::new(f);
2062 connect_raw(
2063 self.as_ptr() as *mut _,
2064 b"notify::draw-value\0".as_ptr() as *const _,
2065 Some(transmute::<_, unsafe extern "C" fn()>(
2066 notify_draw_value_trampoline::<Self, F> as *const (),
2067 )),
2068 Box_::into_raw(f),
2069 )
2070 }
2071 }
2072
2073 #[doc(alias = "has-origin")]
2074 fn connect_has_origin_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2075 unsafe extern "C" fn notify_has_origin_trampoline<P: IsA<Scale>, F: Fn(&P) + 'static>(
2076 this: *mut ffi::GtkScale,
2077 _param_spec: glib::ffi::gpointer,
2078 f: glib::ffi::gpointer,
2079 ) {
2080 let f: &F = &*(f as *const F);
2081 f(Scale::from_glib_borrow(this).unsafe_cast_ref())
2082 }
2083 unsafe {
2084 let f: Box_<F> = Box_::new(f);
2085 connect_raw(
2086 self.as_ptr() as *mut _,
2087 b"notify::has-origin\0".as_ptr() as *const _,
2088 Some(transmute::<_, unsafe extern "C" fn()>(
2089 notify_has_origin_trampoline::<Self, F> as *const (),
2090 )),
2091 Box_::into_raw(f),
2092 )
2093 }
2094 }
2095
2096 #[doc(alias = "value-pos")]
2097 fn connect_value_pos_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2098 unsafe extern "C" fn notify_value_pos_trampoline<P: IsA<Scale>, F: Fn(&P) + 'static>(
2099 this: *mut ffi::GtkScale,
2100 _param_spec: glib::ffi::gpointer,
2101 f: glib::ffi::gpointer,
2102 ) {
2103 let f: &F = &*(f as *const F);
2104 f(Scale::from_glib_borrow(this).unsafe_cast_ref())
2105 }
2106 unsafe {
2107 let f: Box_<F> = Box_::new(f);
2108 connect_raw(
2109 self.as_ptr() as *mut _,
2110 b"notify::value-pos\0".as_ptr() as *const _,
2111 Some(transmute::<_, unsafe extern "C" fn()>(
2112 notify_value_pos_trampoline::<Self, F> as *const (),
2113 )),
2114 Box_::into_raw(f),
2115 )
2116 }
2117 }
2118}
2119
2120impl<O: IsA<Scale>> ScaleExt for O {}
2121
2122impl fmt::Display for Scale {
2123 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2124 f.write_str("Scale")
2125 }
2126}