gtk/auto/tool_palette.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, DestDefaults, IconSize, Orientable, Orientation,
7 ResizeMode, Scrollable, ScrollablePolicy, SelectionData, TargetEntry, ToolItem, ToolItemGroup,
8 ToolPaletteDragTargets, ToolbarStyle, Widget, ffi,
9};
10use glib::{
11 prelude::*,
12 signal::{SignalHandlerId, connect_raw},
13 translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18 ///
19 /// static void
20 /// passive_canvas_drag_data_received (GtkWidget *widget,
21 /// GdkDragContext *context,
22 /// gint x,
23 /// gint y,
24 /// GtkSelectionData *selection,
25 /// guint info,
26 /// guint time,
27 /// gpointer data)
28 /// {
29 /// GtkWidget *palette;
30 /// GtkWidget *item;
31 ///
32 /// // Get the dragged item
33 /// palette = gtk_widget_get_ancestor (gtk_drag_get_source_widget (context),
34 /// GTK_TYPE_TOOL_PALETTE);
35 /// if (palette != NULL)
36 /// item = gtk_tool_palette_get_drag_item (GTK_TOOL_PALETTE (palette),
37 /// selection);
38 ///
39 /// // Do something with item
40 /// }
41 ///
42 /// GtkWidget *target, palette;
43 ///
44 /// palette = gtk_tool_palette_new ();
45 /// target = gtk_drawing_area_new ();
46 ///
47 /// g_signal_connect (G_OBJECT (target), "drag-data-received",
48 /// G_CALLBACK (passive_canvas_drag_data_received), NULL);
49 /// gtk_tool_palette_add_drag_dest (GTK_TOOL_PALETTE (palette), target,
50 /// GTK_DEST_DEFAULT_ALL,
51 /// GTK_TOOL_PALETTE_DRAG_ITEMS,
52 /// GDK_ACTION_COPY);
53 /// ]|
54 ///
55 /// # CSS nodes
56 ///
57 /// GtkToolPalette has a single CSS node named toolpalette.
58 ///
59 /// ## Properties
60 ///
61 ///
62 /// #### `icon-size`
63 /// The size of the icons in a tool palette. When this property is set,
64 /// it overrides the default setting.
65 ///
66 /// This should only be used for special-purpose tool palettes, normal
67 /// application tool palettes should respect the user preferences for the
68 /// size of icons.
69 ///
70 /// Readable | Writable
71 ///
72 ///
73 /// #### `icon-size-set`
74 /// Is [`true`] if the [`icon-size`][struct@crate::ToolPalette#icon-size] property has been set.
75 ///
76 /// Readable | Writable
77 ///
78 ///
79 /// #### `toolbar-style`
80 /// The style of items in the tool palette.
81 ///
82 /// Readable | Writable
83 /// <details><summary><h4>Container</h4></summary>
84 ///
85 ///
86 /// #### `border-width`
87 /// Readable | Writable
88 ///
89 ///
90 /// #### `child`
91 /// Writable
92 ///
93 ///
94 /// #### `resize-mode`
95 /// Readable | Writable
96 /// </details>
97 /// <details><summary><h4>Widget</h4></summary>
98 ///
99 ///
100 /// #### `app-paintable`
101 /// Readable | Writable
102 ///
103 ///
104 /// #### `can-default`
105 /// Readable | Writable
106 ///
107 ///
108 /// #### `can-focus`
109 /// Readable | Writable
110 ///
111 ///
112 /// #### `composite-child`
113 /// Readable
114 ///
115 ///
116 /// #### `double-buffered`
117 /// Whether the widget is double buffered.
118 ///
119 /// Readable | Writable
120 ///
121 ///
122 /// #### `events`
123 /// Readable | Writable
124 ///
125 ///
126 /// #### `expand`
127 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
128 ///
129 /// Readable | Writable
130 ///
131 ///
132 /// #### `focus-on-click`
133 /// Whether the widget should grab focus when it is clicked with the mouse.
134 ///
135 /// This property is only relevant for widgets that can take focus.
136 ///
137 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
138 /// GtkComboBox) implemented this property individually.
139 ///
140 /// Readable | Writable
141 ///
142 ///
143 /// #### `halign`
144 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
145 ///
146 /// Readable | Writable
147 ///
148 ///
149 /// #### `has-default`
150 /// Readable | Writable
151 ///
152 ///
153 /// #### `has-focus`
154 /// Readable | Writable
155 ///
156 ///
157 /// #### `has-tooltip`
158 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
159 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
160 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
161 /// whether it will provide a tooltip or not.
162 ///
163 /// Note that setting this property to [`true`] for the first time will change
164 /// the event masks of the GdkWindows of this widget to include leave-notify
165 /// and motion-notify events. This cannot and will not be undone when the
166 /// property is set to [`false`] again.
167 ///
168 /// Readable | Writable
169 ///
170 ///
171 /// #### `height-request`
172 /// Readable | Writable
173 ///
174 ///
175 /// #### `hexpand`
176 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
177 ///
178 /// Readable | Writable
179 ///
180 ///
181 /// #### `hexpand-set`
182 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
183 ///
184 /// Readable | Writable
185 ///
186 ///
187 /// #### `is-focus`
188 /// Readable | Writable
189 ///
190 ///
191 /// #### `margin`
192 /// Sets all four sides' margin at once. If read, returns max
193 /// margin on any side.
194 ///
195 /// Readable | Writable
196 ///
197 ///
198 /// #### `margin-bottom`
199 /// Margin on bottom side of widget.
200 ///
201 /// This property adds margin outside of the widget's normal size
202 /// request, the margin will be added in addition to the size from
203 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
204 ///
205 /// Readable | Writable
206 ///
207 ///
208 /// #### `margin-end`
209 /// Margin on end of widget, horizontally. This property supports
210 /// left-to-right and right-to-left text directions.
211 ///
212 /// This property adds margin outside of the widget's normal size
213 /// request, the margin will be added in addition to the size from
214 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
215 ///
216 /// Readable | Writable
217 ///
218 ///
219 /// #### `margin-left`
220 /// Margin on left side of widget.
221 ///
222 /// This property adds margin outside of the widget's normal size
223 /// request, the margin will be added in addition to the size from
224 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
225 ///
226 /// Readable | Writable
227 ///
228 ///
229 /// #### `margin-right`
230 /// Margin on right side of widget.
231 ///
232 /// This property adds margin outside of the widget's normal size
233 /// request, the margin will be added in addition to the size from
234 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
235 ///
236 /// Readable | Writable
237 ///
238 ///
239 /// #### `margin-start`
240 /// Margin on start of widget, horizontally. This property supports
241 /// left-to-right and right-to-left text directions.
242 ///
243 /// This property adds margin outside of the widget's normal size
244 /// request, the margin will be added in addition to the size from
245 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
246 ///
247 /// Readable | Writable
248 ///
249 ///
250 /// #### `margin-top`
251 /// Margin on top side of widget.
252 ///
253 /// This property adds margin outside of the widget's normal size
254 /// request, the margin will be added in addition to the size from
255 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
256 ///
257 /// Readable | Writable
258 ///
259 ///
260 /// #### `name`
261 /// Readable | Writable
262 ///
263 ///
264 /// #### `no-show-all`
265 /// Readable | Writable
266 ///
267 ///
268 /// #### `opacity`
269 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
270 /// more details about window opacity.
271 ///
272 /// Before 3.8 this was only available in GtkWindow
273 ///
274 /// Readable | Writable
275 ///
276 ///
277 /// #### `parent`
278 /// Readable | Writable
279 ///
280 ///
281 /// #### `receives-default`
282 /// Readable | Writable
283 ///
284 ///
285 /// #### `scale-factor`
286 /// The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
287 /// more details about widget scaling.
288 ///
289 /// Readable
290 ///
291 ///
292 /// #### `sensitive`
293 /// Readable | Writable
294 ///
295 ///
296 /// #### `style`
297 /// The style of the widget, which contains information about how it will look (colors, etc).
298 ///
299 /// Readable | Writable
300 ///
301 ///
302 /// #### `tooltip-markup`
303 /// Sets the text of tooltip to be the given string, which is marked up
304 /// with the [Pango text markup language][PangoMarkupFormat].
305 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
306 ///
307 /// This is a convenience property which will take care of getting the
308 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
309 /// will automatically be set to [`true`] and there will be taken care of
310 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
311 ///
312 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
313 /// are set, the last one wins.
314 ///
315 /// Readable | Writable
316 ///
317 ///
318 /// #### `tooltip-text`
319 /// Sets the text of tooltip to be the given string.
320 ///
321 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
322 ///
323 /// This is a convenience property which will take care of getting the
324 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
325 /// will automatically be set to [`true`] and there will be taken care of
326 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
327 ///
328 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
329 /// are set, the last one wins.
330 ///
331 /// Readable | Writable
332 ///
333 ///
334 /// #### `valign`
335 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
336 ///
337 /// Readable | Writable
338 ///
339 ///
340 /// #### `vexpand`
341 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
342 ///
343 /// Readable | Writable
344 ///
345 ///
346 /// #### `vexpand-set`
347 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
348 ///
349 /// Readable | Writable
350 ///
351 ///
352 /// #### `visible`
353 /// Readable | Writable
354 ///
355 ///
356 /// #### `width-request`
357 /// Readable | Writable
358 ///
359 ///
360 /// #### `window`
361 /// The widget's window if it is realized, [`None`] otherwise.
362 ///
363 /// Readable
364 /// </details>
365 /// <details><summary><h4>Orientable</h4></summary>
366 ///
367 ///
368 /// #### `orientation`
369 /// The orientation of the orientable.
370 ///
371 /// Readable | Writable
372 /// </details>
373 /// <details><summary><h4>Scrollable</h4></summary>
374 ///
375 ///
376 /// #### `hadjustment`
377 /// Horizontal [`Adjustment`][crate::Adjustment] of the scrollable widget. This adjustment is
378 /// shared between the scrollable widget and its parent.
379 ///
380 /// Readable | Writable | Construct
381 ///
382 ///
383 /// #### `hscroll-policy`
384 /// Determines whether horizontal scrolling should start once the scrollable
385 /// widget is allocated less than its minimum width or less than its natural width.
386 ///
387 /// Readable | Writable
388 ///
389 ///
390 /// #### `vadjustment`
391 /// Verical [`Adjustment`][crate::Adjustment] of the scrollable widget. This adjustment is shared
392 /// between the scrollable widget and its parent.
393 ///
394 /// Readable | Writable | Construct
395 ///
396 ///
397 /// #### `vscroll-policy`
398 /// Determines whether vertical scrolling should start once the scrollable
399 /// widget is allocated less than its minimum height or less than its natural height.
400 ///
401 /// Readable | Writable
402 /// </details>
403 ///
404 /// # Implements
405 ///
406 /// [`ToolPaletteExt`][trait@crate::prelude::ToolPaletteExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`OrientableExt`][trait@crate::prelude::OrientableExt], [`ScrollableExt`][trait@crate::prelude::ScrollableExt], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
407 #[doc(alias = "GtkToolPalette")]
408 pub struct ToolPalette(Object<ffi::GtkToolPalette, ffi::GtkToolPaletteClass>) @extends Container, Widget, @implements Buildable, Orientable, Scrollable;
409
410 match fn {
411 type_ => || ffi::gtk_tool_palette_get_type(),
412 }
413}
414
415impl ToolPalette {
416 pub const NONE: Option<&'static ToolPalette> = None;
417
418 /// Creates a new tool palette.
419 ///
420 /// # Returns
421 ///
422 /// a new [`ToolPalette`][crate::ToolPalette]
423 #[doc(alias = "gtk_tool_palette_new")]
424 pub fn new() -> ToolPalette {
425 assert_initialized_main_thread!();
426 unsafe { Widget::from_glib_none(ffi::gtk_tool_palette_new()).unsafe_cast() }
427 }
428
429 // rustdoc-stripper-ignore-next
430 /// Creates a new builder-pattern struct instance to construct [`ToolPalette`] objects.
431 ///
432 /// This method returns an instance of [`ToolPaletteBuilder`](crate::builders::ToolPaletteBuilder) which can be used to create [`ToolPalette`] objects.
433 pub fn builder() -> ToolPaletteBuilder {
434 ToolPaletteBuilder::new()
435 }
436
437 /// Get the target entry for a dragged [`ToolItemGroup`][crate::ToolItemGroup].
438 ///
439 /// # Returns
440 ///
441 /// the [`TargetEntry`][crate::TargetEntry] for a dragged group
442 #[doc(alias = "gtk_tool_palette_get_drag_target_group")]
443 #[doc(alias = "get_drag_target_group")]
444 pub fn drag_target_group() -> Option<TargetEntry> {
445 assert_initialized_main_thread!();
446 unsafe { from_glib_none(ffi::gtk_tool_palette_get_drag_target_group()) }
447 }
448
449 /// Gets the target entry for a dragged [`ToolItem`][crate::ToolItem].
450 ///
451 /// # Returns
452 ///
453 /// the [`TargetEntry`][crate::TargetEntry] for a dragged item.
454 #[doc(alias = "gtk_tool_palette_get_drag_target_item")]
455 #[doc(alias = "get_drag_target_item")]
456 pub fn drag_target_item() -> Option<TargetEntry> {
457 assert_initialized_main_thread!();
458 unsafe { from_glib_none(ffi::gtk_tool_palette_get_drag_target_item()) }
459 }
460}
461
462impl Default for ToolPalette {
463 fn default() -> Self {
464 Self::new()
465 }
466}
467
468// rustdoc-stripper-ignore-next
469/// A [builder-pattern] type to construct [`ToolPalette`] objects.
470///
471/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
472#[must_use = "The builder must be built to be used"]
473pub struct ToolPaletteBuilder {
474 builder: glib::object::ObjectBuilder<'static, ToolPalette>,
475}
476
477impl ToolPaletteBuilder {
478 fn new() -> Self {
479 Self {
480 builder: glib::object::Object::builder(),
481 }
482 }
483
484 /// The size of the icons in a tool palette. When this property is set,
485 /// it overrides the default setting.
486 ///
487 /// This should only be used for special-purpose tool palettes, normal
488 /// application tool palettes should respect the user preferences for the
489 /// size of icons.
490 pub fn icon_size(self, icon_size: IconSize) -> Self {
491 Self {
492 builder: self.builder.property("icon-size", icon_size),
493 }
494 }
495
496 /// Is [`true`] if the [`icon-size`][struct@crate::ToolPalette#icon-size] property has been set.
497 pub fn icon_size_set(self, icon_size_set: bool) -> Self {
498 Self {
499 builder: self.builder.property("icon-size-set", icon_size_set),
500 }
501 }
502
503 /// The style of items in the tool palette.
504 pub fn toolbar_style(self, toolbar_style: ToolbarStyle) -> Self {
505 Self {
506 builder: self.builder.property("toolbar-style", toolbar_style),
507 }
508 }
509
510 pub fn border_width(self, border_width: u32) -> Self {
511 Self {
512 builder: self.builder.property("border-width", border_width),
513 }
514 }
515
516 pub fn child(self, child: &impl IsA<Widget>) -> Self {
517 Self {
518 builder: self.builder.property("child", child.clone().upcast()),
519 }
520 }
521
522 pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
523 Self {
524 builder: self.builder.property("resize-mode", resize_mode),
525 }
526 }
527
528 pub fn app_paintable(self, app_paintable: bool) -> Self {
529 Self {
530 builder: self.builder.property("app-paintable", app_paintable),
531 }
532 }
533
534 pub fn can_default(self, can_default: bool) -> Self {
535 Self {
536 builder: self.builder.property("can-default", can_default),
537 }
538 }
539
540 pub fn can_focus(self, can_focus: bool) -> Self {
541 Self {
542 builder: self.builder.property("can-focus", can_focus),
543 }
544 }
545
546 pub fn events(self, events: gdk::EventMask) -> Self {
547 Self {
548 builder: self.builder.property("events", events),
549 }
550 }
551
552 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
553 pub fn expand(self, expand: bool) -> Self {
554 Self {
555 builder: self.builder.property("expand", expand),
556 }
557 }
558
559 /// Whether the widget should grab focus when it is clicked with the mouse.
560 ///
561 /// This property is only relevant for widgets that can take focus.
562 ///
563 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
564 /// GtkComboBox) implemented this property individually.
565 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
566 Self {
567 builder: self.builder.property("focus-on-click", focus_on_click),
568 }
569 }
570
571 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
572 pub fn halign(self, halign: Align) -> Self {
573 Self {
574 builder: self.builder.property("halign", halign),
575 }
576 }
577
578 pub fn has_default(self, has_default: bool) -> Self {
579 Self {
580 builder: self.builder.property("has-default", has_default),
581 }
582 }
583
584 pub fn has_focus(self, has_focus: bool) -> Self {
585 Self {
586 builder: self.builder.property("has-focus", has_focus),
587 }
588 }
589
590 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
591 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
592 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
593 /// whether it will provide a tooltip or not.
594 ///
595 /// Note that setting this property to [`true`] for the first time will change
596 /// the event masks of the GdkWindows of this widget to include leave-notify
597 /// and motion-notify events. This cannot and will not be undone when the
598 /// property is set to [`false`] again.
599 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
600 Self {
601 builder: self.builder.property("has-tooltip", has_tooltip),
602 }
603 }
604
605 pub fn height_request(self, height_request: i32) -> Self {
606 Self {
607 builder: self.builder.property("height-request", height_request),
608 }
609 }
610
611 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
612 pub fn hexpand(self, hexpand: bool) -> Self {
613 Self {
614 builder: self.builder.property("hexpand", hexpand),
615 }
616 }
617
618 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
619 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
620 Self {
621 builder: self.builder.property("hexpand-set", hexpand_set),
622 }
623 }
624
625 pub fn is_focus(self, is_focus: bool) -> Self {
626 Self {
627 builder: self.builder.property("is-focus", is_focus),
628 }
629 }
630
631 /// Sets all four sides' margin at once. If read, returns max
632 /// margin on any side.
633 pub fn margin(self, margin: i32) -> Self {
634 Self {
635 builder: self.builder.property("margin", margin),
636 }
637 }
638
639 /// Margin on bottom side of widget.
640 ///
641 /// This property adds margin outside of the widget's normal size
642 /// request, the margin will be added in addition to the size from
643 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
644 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
645 Self {
646 builder: self.builder.property("margin-bottom", margin_bottom),
647 }
648 }
649
650 /// Margin on end of widget, horizontally. This property supports
651 /// left-to-right and right-to-left text directions.
652 ///
653 /// This property adds margin outside of the widget's normal size
654 /// request, the margin will be added in addition to the size from
655 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
656 pub fn margin_end(self, margin_end: i32) -> Self {
657 Self {
658 builder: self.builder.property("margin-end", margin_end),
659 }
660 }
661
662 /// Margin on start of widget, horizontally. This property supports
663 /// left-to-right and right-to-left text directions.
664 ///
665 /// This property adds margin outside of the widget's normal size
666 /// request, the margin will be added in addition to the size from
667 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
668 pub fn margin_start(self, margin_start: i32) -> Self {
669 Self {
670 builder: self.builder.property("margin-start", margin_start),
671 }
672 }
673
674 /// Margin on top side of widget.
675 ///
676 /// This property adds margin outside of the widget's normal size
677 /// request, the margin will be added in addition to the size from
678 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
679 pub fn margin_top(self, margin_top: i32) -> Self {
680 Self {
681 builder: self.builder.property("margin-top", margin_top),
682 }
683 }
684
685 pub fn name(self, name: impl Into<glib::GString>) -> Self {
686 Self {
687 builder: self.builder.property("name", name.into()),
688 }
689 }
690
691 pub fn no_show_all(self, no_show_all: bool) -> Self {
692 Self {
693 builder: self.builder.property("no-show-all", no_show_all),
694 }
695 }
696
697 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
698 /// more details about window opacity.
699 ///
700 /// Before 3.8 this was only available in GtkWindow
701 pub fn opacity(self, opacity: f64) -> Self {
702 Self {
703 builder: self.builder.property("opacity", opacity),
704 }
705 }
706
707 pub fn parent(self, parent: &impl IsA<Container>) -> Self {
708 Self {
709 builder: self.builder.property("parent", parent.clone().upcast()),
710 }
711 }
712
713 pub fn receives_default(self, receives_default: bool) -> Self {
714 Self {
715 builder: self.builder.property("receives-default", receives_default),
716 }
717 }
718
719 pub fn sensitive(self, sensitive: bool) -> Self {
720 Self {
721 builder: self.builder.property("sensitive", sensitive),
722 }
723 }
724
725 /// Sets the text of tooltip to be the given string, which is marked up
726 /// with the [Pango text markup language][PangoMarkupFormat].
727 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
728 ///
729 /// This is a convenience property which will take care of getting the
730 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
731 /// will automatically be set to [`true`] and there will be taken care of
732 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
733 ///
734 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
735 /// are set, the last one wins.
736 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
737 Self {
738 builder: self
739 .builder
740 .property("tooltip-markup", tooltip_markup.into()),
741 }
742 }
743
744 /// Sets the text of tooltip to be the given string.
745 ///
746 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
747 ///
748 /// This is a convenience property which will take care of getting the
749 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
750 /// will automatically be set to [`true`] and there will be taken care of
751 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
752 ///
753 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
754 /// are set, the last one wins.
755 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
756 Self {
757 builder: self.builder.property("tooltip-text", tooltip_text.into()),
758 }
759 }
760
761 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
762 pub fn valign(self, valign: Align) -> Self {
763 Self {
764 builder: self.builder.property("valign", valign),
765 }
766 }
767
768 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
769 pub fn vexpand(self, vexpand: bool) -> Self {
770 Self {
771 builder: self.builder.property("vexpand", vexpand),
772 }
773 }
774
775 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
776 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
777 Self {
778 builder: self.builder.property("vexpand-set", vexpand_set),
779 }
780 }
781
782 pub fn visible(self, visible: bool) -> Self {
783 Self {
784 builder: self.builder.property("visible", visible),
785 }
786 }
787
788 pub fn width_request(self, width_request: i32) -> Self {
789 Self {
790 builder: self.builder.property("width-request", width_request),
791 }
792 }
793
794 /// The orientation of the orientable.
795 pub fn orientation(self, orientation: Orientation) -> Self {
796 Self {
797 builder: self.builder.property("orientation", orientation),
798 }
799 }
800
801 /// Horizontal [`Adjustment`][crate::Adjustment] of the scrollable widget. This adjustment is
802 /// shared between the scrollable widget and its parent.
803 pub fn hadjustment(self, hadjustment: &impl IsA<Adjustment>) -> Self {
804 Self {
805 builder: self
806 .builder
807 .property("hadjustment", hadjustment.clone().upcast()),
808 }
809 }
810
811 /// Determines whether horizontal scrolling should start once the scrollable
812 /// widget is allocated less than its minimum width or less than its natural width.
813 pub fn hscroll_policy(self, hscroll_policy: ScrollablePolicy) -> Self {
814 Self {
815 builder: self.builder.property("hscroll-policy", hscroll_policy),
816 }
817 }
818
819 /// Verical [`Adjustment`][crate::Adjustment] of the scrollable widget. This adjustment is shared
820 /// between the scrollable widget and its parent.
821 pub fn vadjustment(self, vadjustment: &impl IsA<Adjustment>) -> Self {
822 Self {
823 builder: self
824 .builder
825 .property("vadjustment", vadjustment.clone().upcast()),
826 }
827 }
828
829 /// Determines whether vertical scrolling should start once the scrollable
830 /// widget is allocated less than its minimum height or less than its natural height.
831 pub fn vscroll_policy(self, vscroll_policy: ScrollablePolicy) -> Self {
832 Self {
833 builder: self.builder.property("vscroll-policy", vscroll_policy),
834 }
835 }
836
837 // rustdoc-stripper-ignore-next
838 /// Build the [`ToolPalette`].
839 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
840 pub fn build(self) -> ToolPalette {
841 assert_initialized_main_thread!();
842 self.builder.build()
843 }
844}
845
846/// Trait containing all [`struct@ToolPalette`] methods.
847///
848/// # Implementors
849///
850/// [`ToolPalette`][struct@crate::ToolPalette]
851pub trait ToolPaletteExt: IsA<ToolPalette> + 'static {
852 /// Sets `self` as drag source (see [`set_drag_source()`][Self::set_drag_source()])
853 /// and sets `widget` as a drag destination for drags from `self`.
854 /// See [`WidgetExtManual::drag_dest_set()`][crate::prelude::WidgetExtManual::drag_dest_set()].
855 /// ## `widget`
856 /// a [`Widget`][crate::Widget] which should be a drag destination for `self`
857 /// ## `flags`
858 /// the flags that specify what actions GTK+ should take for drops
859 /// on that widget
860 /// ## `targets`
861 /// the [`ToolPaletteDragTargets`][crate::ToolPaletteDragTargets] which the widget
862 /// should support
863 /// ## `actions`
864 /// the `GdkDragActions` which the widget should suppport
865 #[doc(alias = "gtk_tool_palette_add_drag_dest")]
866 fn add_drag_dest(
867 &self,
868 widget: &impl IsA<Widget>,
869 flags: DestDefaults,
870 targets: ToolPaletteDragTargets,
871 actions: gdk::DragAction,
872 ) {
873 unsafe {
874 ffi::gtk_tool_palette_add_drag_dest(
875 self.as_ref().to_glib_none().0,
876 widget.as_ref().to_glib_none().0,
877 flags.into_glib(),
878 targets.into_glib(),
879 actions.into_glib(),
880 );
881 }
882 }
883
884 /// Get the dragged item from the selection.
885 /// This could be a [`ToolItem`][crate::ToolItem] or a [`ToolItemGroup`][crate::ToolItemGroup].
886 /// ## `selection`
887 /// a [`SelectionData`][crate::SelectionData]
888 ///
889 /// # Returns
890 ///
891 /// the dragged item in selection
892 #[doc(alias = "gtk_tool_palette_get_drag_item")]
893 #[doc(alias = "get_drag_item")]
894 fn drag_item(&self, selection: &SelectionData) -> Option<Widget> {
895 unsafe {
896 from_glib_none(ffi::gtk_tool_palette_get_drag_item(
897 self.as_ref().to_glib_none().0,
898 selection.to_glib_none().0,
899 ))
900 }
901 }
902
903 /// Gets the group at position (x, y).
904 /// ## `x`
905 /// the x position
906 /// ## `y`
907 /// the y position
908 ///
909 /// # Returns
910 ///
911 /// the [`ToolItemGroup`][crate::ToolItemGroup] at position
912 /// or [`None`] if there is no such group
913 #[doc(alias = "gtk_tool_palette_get_drop_group")]
914 #[doc(alias = "get_drop_group")]
915 fn drop_group(&self, x: i32, y: i32) -> Option<ToolItemGroup> {
916 unsafe {
917 from_glib_none(ffi::gtk_tool_palette_get_drop_group(
918 self.as_ref().to_glib_none().0,
919 x,
920 y,
921 ))
922 }
923 }
924
925 /// Gets the item at position (x, y).
926 /// See [`drop_group()`][Self::drop_group()].
927 /// ## `x`
928 /// the x position
929 /// ## `y`
930 /// the y position
931 ///
932 /// # Returns
933 ///
934 /// the [`ToolItem`][crate::ToolItem] at position or [`None`] if there is no such item
935 #[doc(alias = "gtk_tool_palette_get_drop_item")]
936 #[doc(alias = "get_drop_item")]
937 fn drop_item(&self, x: i32, y: i32) -> Option<ToolItem> {
938 unsafe {
939 from_glib_none(ffi::gtk_tool_palette_get_drop_item(
940 self.as_ref().to_glib_none().0,
941 x,
942 y,
943 ))
944 }
945 }
946
947 /// Gets whether `group` is exclusive or not.
948 /// See [`set_exclusive()`][Self::set_exclusive()].
949 /// ## `group`
950 /// a [`ToolItemGroup`][crate::ToolItemGroup] which is a child of palette
951 ///
952 /// # Returns
953 ///
954 /// [`true`] if `group` is exclusive
955 #[doc(alias = "gtk_tool_palette_get_exclusive")]
956 #[doc(alias = "get_exclusive")]
957 fn is_exclusive(&self, group: &impl IsA<ToolItemGroup>) -> bool {
958 unsafe {
959 from_glib(ffi::gtk_tool_palette_get_exclusive(
960 self.as_ref().to_glib_none().0,
961 group.as_ref().to_glib_none().0,
962 ))
963 }
964 }
965
966 /// Gets whether group should be given extra space.
967 /// See [`set_expand()`][Self::set_expand()].
968 /// ## `group`
969 /// a [`ToolItemGroup`][crate::ToolItemGroup] which is a child of palette
970 ///
971 /// # Returns
972 ///
973 /// [`true`] if group should be given extra space, [`false`] otherwise
974 #[doc(alias = "gtk_tool_palette_get_expand")]
975 #[doc(alias = "get_expand")]
976 fn expands(&self, group: &impl IsA<ToolItemGroup>) -> bool {
977 unsafe {
978 from_glib(ffi::gtk_tool_palette_get_expand(
979 self.as_ref().to_glib_none().0,
980 group.as_ref().to_glib_none().0,
981 ))
982 }
983 }
984
985 /// Gets the position of `group` in `self` as index.
986 /// See [`set_group_position()`][Self::set_group_position()].
987 /// ## `group`
988 /// a [`ToolItemGroup`][crate::ToolItemGroup]
989 ///
990 /// # Returns
991 ///
992 /// the index of group or -1 if `group` is not a child of `self`
993 #[doc(alias = "gtk_tool_palette_get_group_position")]
994 #[doc(alias = "get_group_position")]
995 fn group_position(&self, group: &impl IsA<ToolItemGroup>) -> i32 {
996 unsafe {
997 ffi::gtk_tool_palette_get_group_position(
998 self.as_ref().to_glib_none().0,
999 group.as_ref().to_glib_none().0,
1000 )
1001 }
1002 }
1003
1004 /// Gets the size of icons in the tool palette.
1005 /// See [`set_icon_size()`][Self::set_icon_size()].
1006 ///
1007 /// # Returns
1008 ///
1009 /// the [`IconSize`][crate::IconSize] of icons in the tool palette
1010 #[doc(alias = "gtk_tool_palette_get_icon_size")]
1011 #[doc(alias = "get_icon_size")]
1012 #[doc(alias = "icon-size")]
1013 fn icon_size(&self) -> IconSize {
1014 unsafe {
1015 from_glib(ffi::gtk_tool_palette_get_icon_size(
1016 self.as_ref().to_glib_none().0,
1017 ))
1018 }
1019 }
1020
1021 /// Gets the style (icons, text or both) of items in the tool palette.
1022 ///
1023 /// # Returns
1024 ///
1025 /// the [`ToolbarStyle`][crate::ToolbarStyle] of items in the tool palette.
1026 #[doc(alias = "gtk_tool_palette_get_style")]
1027 #[doc(alias = "get_style")]
1028 fn style(&self) -> ToolbarStyle {
1029 unsafe {
1030 from_glib(ffi::gtk_tool_palette_get_style(
1031 self.as_ref().to_glib_none().0,
1032 ))
1033 }
1034 }
1035
1036 /// Sets the tool palette as a drag source.
1037 /// Enables all groups and items in the tool palette as drag sources
1038 /// on button 1 and button 3 press with copy and move actions.
1039 /// See [`WidgetExtManual::drag_source_set()`][crate::prelude::WidgetExtManual::drag_source_set()].
1040 /// ## `targets`
1041 /// the [`ToolPaletteDragTargets`][crate::ToolPaletteDragTargets]
1042 /// which the widget should support
1043 #[doc(alias = "gtk_tool_palette_set_drag_source")]
1044 fn set_drag_source(&self, targets: ToolPaletteDragTargets) {
1045 unsafe {
1046 ffi::gtk_tool_palette_set_drag_source(
1047 self.as_ref().to_glib_none().0,
1048 targets.into_glib(),
1049 );
1050 }
1051 }
1052
1053 /// Sets whether the group should be exclusive or not.
1054 /// If an exclusive group is expanded all other groups are collapsed.
1055 /// ## `group`
1056 /// a [`ToolItemGroup`][crate::ToolItemGroup] which is a child of palette
1057 /// ## `exclusive`
1058 /// whether the group should be exclusive or not
1059 #[doc(alias = "gtk_tool_palette_set_exclusive")]
1060 fn set_exclusive(&self, group: &impl IsA<ToolItemGroup>, exclusive: bool) {
1061 unsafe {
1062 ffi::gtk_tool_palette_set_exclusive(
1063 self.as_ref().to_glib_none().0,
1064 group.as_ref().to_glib_none().0,
1065 exclusive.into_glib(),
1066 );
1067 }
1068 }
1069
1070 /// Sets whether the group should be given extra space.
1071 /// ## `group`
1072 /// a [`ToolItemGroup`][crate::ToolItemGroup] which is a child of palette
1073 /// ## `expand`
1074 /// whether the group should be given extra space
1075 #[doc(alias = "gtk_tool_palette_set_expand")]
1076 fn set_expand(&self, group: &impl IsA<ToolItemGroup>, expand: bool) {
1077 unsafe {
1078 ffi::gtk_tool_palette_set_expand(
1079 self.as_ref().to_glib_none().0,
1080 group.as_ref().to_glib_none().0,
1081 expand.into_glib(),
1082 );
1083 }
1084 }
1085
1086 /// Sets the position of the group as an index of the tool palette.
1087 /// If position is 0 the group will become the first child, if position is
1088 /// -1 it will become the last child.
1089 /// ## `group`
1090 /// a [`ToolItemGroup`][crate::ToolItemGroup] which is a child of palette
1091 /// ## `position`
1092 /// a new index for group
1093 #[doc(alias = "gtk_tool_palette_set_group_position")]
1094 fn set_group_position(&self, group: &impl IsA<ToolItemGroup>, position: i32) {
1095 unsafe {
1096 ffi::gtk_tool_palette_set_group_position(
1097 self.as_ref().to_glib_none().0,
1098 group.as_ref().to_glib_none().0,
1099 position,
1100 );
1101 }
1102 }
1103
1104 /// Sets the size of icons in the tool palette.
1105 /// ## `icon_size`
1106 /// the [`IconSize`][crate::IconSize] that icons in the tool
1107 /// palette shall have
1108 #[doc(alias = "gtk_tool_palette_set_icon_size")]
1109 #[doc(alias = "icon-size")]
1110 fn set_icon_size(&self, icon_size: IconSize) {
1111 unsafe {
1112 ffi::gtk_tool_palette_set_icon_size(
1113 self.as_ref().to_glib_none().0,
1114 icon_size.into_glib(),
1115 );
1116 }
1117 }
1118
1119 /// Sets the style (text, icons or both) of items in the tool palette.
1120 /// ## `style`
1121 /// the [`ToolbarStyle`][crate::ToolbarStyle] that items in the tool palette shall have
1122 #[doc(alias = "gtk_tool_palette_set_style")]
1123 fn set_style(&self, style: ToolbarStyle) {
1124 unsafe {
1125 ffi::gtk_tool_palette_set_style(self.as_ref().to_glib_none().0, style.into_glib());
1126 }
1127 }
1128
1129 /// Unsets the tool palette icon size set with [`set_icon_size()`][Self::set_icon_size()],
1130 /// so that user preferences will be used to determine the icon size.
1131 #[doc(alias = "gtk_tool_palette_unset_icon_size")]
1132 fn unset_icon_size(&self) {
1133 unsafe {
1134 ffi::gtk_tool_palette_unset_icon_size(self.as_ref().to_glib_none().0);
1135 }
1136 }
1137
1138 /// Unsets a toolbar style set with [`set_style()`][Self::set_style()],
1139 /// so that user preferences will be used to determine the toolbar style.
1140 #[doc(alias = "gtk_tool_palette_unset_style")]
1141 fn unset_style(&self) {
1142 unsafe {
1143 ffi::gtk_tool_palette_unset_style(self.as_ref().to_glib_none().0);
1144 }
1145 }
1146
1147 /// Is [`true`] if the [`icon-size`][struct@crate::ToolPalette#icon-size] property has been set.
1148 #[doc(alias = "icon-size-set")]
1149 fn is_icon_size_set(&self) -> bool {
1150 ObjectExt::property(self.as_ref(), "icon-size-set")
1151 }
1152
1153 /// Is [`true`] if the [`icon-size`][struct@crate::ToolPalette#icon-size] property has been set.
1154 #[doc(alias = "icon-size-set")]
1155 fn set_icon_size_set(&self, icon_size_set: bool) {
1156 ObjectExt::set_property(self.as_ref(), "icon-size-set", icon_size_set)
1157 }
1158
1159 /// The style of items in the tool palette.
1160 #[doc(alias = "toolbar-style")]
1161 fn toolbar_style(&self) -> ToolbarStyle {
1162 ObjectExt::property(self.as_ref(), "toolbar-style")
1163 }
1164
1165 /// The style of items in the tool palette.
1166 #[doc(alias = "toolbar-style")]
1167 fn set_toolbar_style(&self, toolbar_style: ToolbarStyle) {
1168 ObjectExt::set_property(self.as_ref(), "toolbar-style", toolbar_style)
1169 }
1170
1171 #[doc(alias = "icon-size")]
1172 fn connect_icon_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1173 unsafe extern "C" fn notify_icon_size_trampoline<
1174 P: IsA<ToolPalette>,
1175 F: Fn(&P) + 'static,
1176 >(
1177 this: *mut ffi::GtkToolPalette,
1178 _param_spec: glib::ffi::gpointer,
1179 f: glib::ffi::gpointer,
1180 ) {
1181 unsafe {
1182 let f: &F = &*(f as *const F);
1183 f(ToolPalette::from_glib_borrow(this).unsafe_cast_ref())
1184 }
1185 }
1186 unsafe {
1187 let f: Box_<F> = Box_::new(f);
1188 connect_raw(
1189 self.as_ptr() as *mut _,
1190 c"notify::icon-size".as_ptr(),
1191 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1192 notify_icon_size_trampoline::<Self, F> as *const (),
1193 )),
1194 Box_::into_raw(f),
1195 )
1196 }
1197 }
1198
1199 #[doc(alias = "icon-size-set")]
1200 fn connect_icon_size_set_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1201 unsafe extern "C" fn notify_icon_size_set_trampoline<
1202 P: IsA<ToolPalette>,
1203 F: Fn(&P) + 'static,
1204 >(
1205 this: *mut ffi::GtkToolPalette,
1206 _param_spec: glib::ffi::gpointer,
1207 f: glib::ffi::gpointer,
1208 ) {
1209 unsafe {
1210 let f: &F = &*(f as *const F);
1211 f(ToolPalette::from_glib_borrow(this).unsafe_cast_ref())
1212 }
1213 }
1214 unsafe {
1215 let f: Box_<F> = Box_::new(f);
1216 connect_raw(
1217 self.as_ptr() as *mut _,
1218 c"notify::icon-size-set".as_ptr(),
1219 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1220 notify_icon_size_set_trampoline::<Self, F> as *const (),
1221 )),
1222 Box_::into_raw(f),
1223 )
1224 }
1225 }
1226
1227 #[doc(alias = "toolbar-style")]
1228 fn connect_toolbar_style_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1229 unsafe extern "C" fn notify_toolbar_style_trampoline<
1230 P: IsA<ToolPalette>,
1231 F: Fn(&P) + 'static,
1232 >(
1233 this: *mut ffi::GtkToolPalette,
1234 _param_spec: glib::ffi::gpointer,
1235 f: glib::ffi::gpointer,
1236 ) {
1237 unsafe {
1238 let f: &F = &*(f as *const F);
1239 f(ToolPalette::from_glib_borrow(this).unsafe_cast_ref())
1240 }
1241 }
1242 unsafe {
1243 let f: Box_<F> = Box_::new(f);
1244 connect_raw(
1245 self.as_ptr() as *mut _,
1246 c"notify::toolbar-style".as_ptr(),
1247 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1248 notify_toolbar_style_trampoline::<Self, F> as *const (),
1249 )),
1250 Box_::into_raw(f),
1251 )
1252 }
1253 }
1254}
1255
1256impl<O: IsA<ToolPalette>> ToolPaletteExt for O {}