Skip to main content

gtk/auto/
separator_menu_item.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::{Actionable, Align, Bin, Buildable, Container, Menu, MenuItem, ResizeMode, Widget};
6use glib::{prelude::*, translate::*};
7use std::fmt;
8
9glib::wrapper! {
10    /// The [`SeparatorMenuItem`][crate::SeparatorMenuItem] is a separator used to group
11    /// items within a menu. It displays a horizontal line with a shadow to
12    /// make it appear sunken into the interface.
13    ///
14    /// # CSS nodes
15    ///
16    /// GtkSeparatorMenuItem has a single CSS node with name separator.
17    ///
18    /// # Implements
19    ///
20    /// [`GtkMenuItemExt`][trait@crate::prelude::GtkMenuItemExt], [`BinExt`][trait@crate::prelude::BinExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ActionableExt`][trait@crate::prelude::ActionableExt], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
21    #[doc(alias = "GtkSeparatorMenuItem")]
22    pub struct SeparatorMenuItem(Object<ffi::GtkSeparatorMenuItem, ffi::GtkSeparatorMenuItemClass>) @extends MenuItem, Bin, Container, Widget, @implements Buildable, Actionable;
23
24    match fn {
25        type_ => || ffi::gtk_separator_menu_item_get_type(),
26    }
27}
28
29impl SeparatorMenuItem {
30    pub const NONE: Option<&'static SeparatorMenuItem> = None;
31
32    /// Creates a new [`SeparatorMenuItem`][crate::SeparatorMenuItem].
33    ///
34    /// # Returns
35    ///
36    /// a new [`SeparatorMenuItem`][crate::SeparatorMenuItem].
37    #[doc(alias = "gtk_separator_menu_item_new")]
38    pub fn new() -> SeparatorMenuItem {
39        assert_initialized_main_thread!();
40        unsafe { Widget::from_glib_none(ffi::gtk_separator_menu_item_new()).unsafe_cast() }
41    }
42
43    // rustdoc-stripper-ignore-next
44    /// Creates a new builder-pattern struct instance to construct [`SeparatorMenuItem`] objects.
45    ///
46    /// This method returns an instance of [`SeparatorMenuItemBuilder`](crate::builders::SeparatorMenuItemBuilder) which can be used to create [`SeparatorMenuItem`] objects.
47    pub fn builder() -> SeparatorMenuItemBuilder {
48        SeparatorMenuItemBuilder::new()
49    }
50}
51
52impl Default for SeparatorMenuItem {
53    fn default() -> Self {
54        Self::new()
55    }
56}
57
58// rustdoc-stripper-ignore-next
59/// A [builder-pattern] type to construct [`SeparatorMenuItem`] objects.
60///
61/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
62#[must_use = "The builder must be built to be used"]
63pub struct SeparatorMenuItemBuilder {
64    builder: glib::object::ObjectBuilder<'static, SeparatorMenuItem>,
65}
66
67impl SeparatorMenuItemBuilder {
68    fn new() -> Self {
69        Self {
70            builder: glib::object::Object::builder(),
71        }
72    }
73
74    /// Sets the accelerator path of the menu item, through which runtime
75    /// changes of the menu item's accelerator caused by the user can be
76    /// identified and saved to persistant storage.
77    pub fn accel_path(self, accel_path: impl Into<glib::GString>) -> Self {
78        Self {
79            builder: self.builder.property("accel-path", accel_path.into()),
80        }
81    }
82
83    /// The text for the child label.
84    pub fn label(self, label: impl Into<glib::GString>) -> Self {
85        Self {
86            builder: self.builder.property("label", label.into()),
87        }
88    }
89
90    /// Sets whether the menu item appears justified
91    /// at the right side of a menu bar.
92    pub fn right_justified(self, right_justified: bool) -> Self {
93        Self {
94            builder: self.builder.property("right-justified", right_justified),
95        }
96    }
97
98    /// The submenu attached to the menu item, or [`None`] if it has none.
99    pub fn submenu(self, submenu: &impl IsA<Menu>) -> Self {
100        Self {
101            builder: self.builder.property("submenu", submenu.clone().upcast()),
102        }
103    }
104
105    /// [`true`] if underlines in the text indicate mnemonics.
106    pub fn use_underline(self, use_underline: bool) -> Self {
107        Self {
108            builder: self.builder.property("use-underline", use_underline),
109        }
110    }
111
112    pub fn border_width(self, border_width: u32) -> Self {
113        Self {
114            builder: self.builder.property("border-width", border_width),
115        }
116    }
117
118    pub fn child(self, child: &impl IsA<Widget>) -> Self {
119        Self {
120            builder: self.builder.property("child", child.clone().upcast()),
121        }
122    }
123
124    pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
125        Self {
126            builder: self.builder.property("resize-mode", resize_mode),
127        }
128    }
129
130    pub fn app_paintable(self, app_paintable: bool) -> Self {
131        Self {
132            builder: self.builder.property("app-paintable", app_paintable),
133        }
134    }
135
136    pub fn can_default(self, can_default: bool) -> Self {
137        Self {
138            builder: self.builder.property("can-default", can_default),
139        }
140    }
141
142    pub fn can_focus(self, can_focus: bool) -> Self {
143        Self {
144            builder: self.builder.property("can-focus", can_focus),
145        }
146    }
147
148    pub fn events(self, events: gdk::EventMask) -> Self {
149        Self {
150            builder: self.builder.property("events", events),
151        }
152    }
153
154    /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
155    pub fn expand(self, expand: bool) -> Self {
156        Self {
157            builder: self.builder.property("expand", expand),
158        }
159    }
160
161    /// Whether the widget should grab focus when it is clicked with the mouse.
162    ///
163    /// This property is only relevant for widgets that can take focus.
164    ///
165    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
166    /// GtkComboBox) implemented this property individually.
167    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
168        Self {
169            builder: self.builder.property("focus-on-click", focus_on_click),
170        }
171    }
172
173    /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
174    pub fn halign(self, halign: Align) -> Self {
175        Self {
176            builder: self.builder.property("halign", halign),
177        }
178    }
179
180    pub fn has_default(self, has_default: bool) -> Self {
181        Self {
182            builder: self.builder.property("has-default", has_default),
183        }
184    }
185
186    pub fn has_focus(self, has_focus: bool) -> Self {
187        Self {
188            builder: self.builder.property("has-focus", has_focus),
189        }
190    }
191
192    /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
193    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
194    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
195    /// whether it will provide a tooltip or not.
196    ///
197    /// Note that setting this property to [`true`] for the first time will change
198    /// the event masks of the GdkWindows of this widget to include leave-notify
199    /// and motion-notify events. This cannot and will not be undone when the
200    /// property is set to [`false`] again.
201    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
202        Self {
203            builder: self.builder.property("has-tooltip", has_tooltip),
204        }
205    }
206
207    pub fn height_request(self, height_request: i32) -> Self {
208        Self {
209            builder: self.builder.property("height-request", height_request),
210        }
211    }
212
213    /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
214    pub fn hexpand(self, hexpand: bool) -> Self {
215        Self {
216            builder: self.builder.property("hexpand", hexpand),
217        }
218    }
219
220    /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
221    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
222        Self {
223            builder: self.builder.property("hexpand-set", hexpand_set),
224        }
225    }
226
227    pub fn is_focus(self, is_focus: bool) -> Self {
228        Self {
229            builder: self.builder.property("is-focus", is_focus),
230        }
231    }
232
233    /// Sets all four sides' margin at once. If read, returns max
234    /// margin on any side.
235    pub fn margin(self, margin: i32) -> Self {
236        Self {
237            builder: self.builder.property("margin", margin),
238        }
239    }
240
241    /// Margin on bottom side of widget.
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    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
247        Self {
248            builder: self.builder.property("margin-bottom", margin_bottom),
249        }
250    }
251
252    /// Margin on end of widget, horizontally. This property supports
253    /// left-to-right and right-to-left text directions.
254    ///
255    /// This property adds margin outside of the widget's normal size
256    /// request, the margin will be added in addition to the size from
257    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
258    pub fn margin_end(self, margin_end: i32) -> Self {
259        Self {
260            builder: self.builder.property("margin-end", margin_end),
261        }
262    }
263
264    /// Margin on start of widget, horizontally. This property supports
265    /// left-to-right and right-to-left text directions.
266    ///
267    /// This property adds margin outside of the widget's normal size
268    /// request, the margin will be added in addition to the size from
269    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
270    pub fn margin_start(self, margin_start: i32) -> Self {
271        Self {
272            builder: self.builder.property("margin-start", margin_start),
273        }
274    }
275
276    /// Margin on top side of widget.
277    ///
278    /// This property adds margin outside of the widget's normal size
279    /// request, the margin will be added in addition to the size from
280    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
281    pub fn margin_top(self, margin_top: i32) -> Self {
282        Self {
283            builder: self.builder.property("margin-top", margin_top),
284        }
285    }
286
287    pub fn name(self, name: impl Into<glib::GString>) -> Self {
288        Self {
289            builder: self.builder.property("name", name.into()),
290        }
291    }
292
293    pub fn no_show_all(self, no_show_all: bool) -> Self {
294        Self {
295            builder: self.builder.property("no-show-all", no_show_all),
296        }
297    }
298
299    /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
300    /// more details about window opacity.
301    ///
302    /// Before 3.8 this was only available in GtkWindow
303    pub fn opacity(self, opacity: f64) -> Self {
304        Self {
305            builder: self.builder.property("opacity", opacity),
306        }
307    }
308
309    pub fn parent(self, parent: &impl IsA<Container>) -> Self {
310        Self {
311            builder: self.builder.property("parent", parent.clone().upcast()),
312        }
313    }
314
315    pub fn receives_default(self, receives_default: bool) -> Self {
316        Self {
317            builder: self.builder.property("receives-default", receives_default),
318        }
319    }
320
321    pub fn sensitive(self, sensitive: bool) -> Self {
322        Self {
323            builder: self.builder.property("sensitive", sensitive),
324        }
325    }
326
327    /// Sets the text of tooltip to be the given string, which is marked up
328    /// with the [Pango text markup language][PangoMarkupFormat].
329    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
330    ///
331    /// This is a convenience property which will take care of getting the
332    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
333    /// will automatically be set to [`true`] and there will be taken care of
334    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
335    ///
336    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
337    /// are set, the last one wins.
338    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
339        Self {
340            builder: self
341                .builder
342                .property("tooltip-markup", tooltip_markup.into()),
343        }
344    }
345
346    /// Sets the text of tooltip to be the given string.
347    ///
348    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
349    ///
350    /// This is a convenience property which will take care of getting the
351    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
352    /// will automatically be set to [`true`] and there will be taken care of
353    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
354    ///
355    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
356    /// are set, the last one wins.
357    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
358        Self {
359            builder: self.builder.property("tooltip-text", tooltip_text.into()),
360        }
361    }
362
363    /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
364    pub fn valign(self, valign: Align) -> Self {
365        Self {
366            builder: self.builder.property("valign", valign),
367        }
368    }
369
370    /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
371    pub fn vexpand(self, vexpand: bool) -> Self {
372        Self {
373            builder: self.builder.property("vexpand", vexpand),
374        }
375    }
376
377    /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
378    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
379        Self {
380            builder: self.builder.property("vexpand-set", vexpand_set),
381        }
382    }
383
384    pub fn visible(self, visible: bool) -> Self {
385        Self {
386            builder: self.builder.property("visible", visible),
387        }
388    }
389
390    pub fn width_request(self, width_request: i32) -> Self {
391        Self {
392            builder: self.builder.property("width-request", width_request),
393        }
394    }
395
396    pub fn action_name(self, action_name: impl Into<glib::GString>) -> Self {
397        Self {
398            builder: self.builder.property("action-name", action_name.into()),
399        }
400    }
401
402    pub fn action_target(self, action_target: &glib::Variant) -> Self {
403        Self {
404            builder: self
405                .builder
406                .property("action-target", action_target.clone()),
407        }
408    }
409
410    // rustdoc-stripper-ignore-next
411    /// Build the [`SeparatorMenuItem`].
412    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
413    pub fn build(self) -> SeparatorMenuItem {
414        self.builder.build()
415    }
416}
417
418impl fmt::Display for SeparatorMenuItem {
419    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
420        f.write_str("SeparatorMenuItem")
421    }
422}