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