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 5 use crate::Align; 6 use crate::Bin; 7 use crate::Buildable; 8 use crate::Container; 9 use crate::ResizeMode; 10 use crate::ToolItem; 11 use crate::Widget; 12 use glib::object::Cast; 13 use glib::object::IsA; 14 use glib::signal::connect_raw; 15 use glib::signal::SignalHandlerId; 16 use glib::translate::*; 17 use glib::StaticType; 18 use glib::ToValue; 19 use std::boxed::Box as Box_; 20 use std::fmt; 21 use std::mem::transmute; 22 23 glib::wrapper! { 24 #[doc(alias = "GtkSeparatorToolItem")] 25 pub struct SeparatorToolItem(Object<ffi::GtkSeparatorToolItem, ffi::GtkSeparatorToolItemClass>) @extends ToolItem, Bin, Container, Widget, @implements Buildable; 26 27 match fn { 28 type_ => || ffi::gtk_separator_tool_item_get_type(), 29 } 30 } 31 32 impl SeparatorToolItem { 33 #[doc(alias = "gtk_separator_tool_item_new")] new() -> SeparatorToolItem34 pub fn new() -> SeparatorToolItem { 35 assert_initialized_main_thread!(); 36 unsafe { ToolItem::from_glib_none(ffi::gtk_separator_tool_item_new()).unsafe_cast() } 37 } 38 39 // rustdoc-stripper-ignore-next 40 /// Creates a new builder-pattern struct instance to construct [`SeparatorToolItem`] objects. 41 /// 42 /// This method returns an instance of [`SeparatorToolItemBuilder`] which can be used to create [`SeparatorToolItem`] objects. builder() -> SeparatorToolItemBuilder43 pub fn builder() -> SeparatorToolItemBuilder { 44 SeparatorToolItemBuilder::default() 45 } 46 } 47 48 impl Default for SeparatorToolItem { default() -> Self49 fn default() -> Self { 50 Self::new() 51 } 52 } 53 54 #[derive(Clone, Default)] 55 // rustdoc-stripper-ignore-next 56 /// A [builder-pattern] type to construct [`SeparatorToolItem`] objects. 57 /// 58 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html 59 pub struct SeparatorToolItemBuilder { 60 draw: Option<bool>, 61 is_important: Option<bool>, 62 visible_horizontal: Option<bool>, 63 visible_vertical: Option<bool>, 64 border_width: Option<u32>, 65 child: Option<Widget>, 66 resize_mode: Option<ResizeMode>, 67 app_paintable: Option<bool>, 68 can_default: Option<bool>, 69 can_focus: Option<bool>, 70 events: Option<gdk::EventMask>, 71 expand: Option<bool>, 72 #[cfg(any(feature = "v3_20", feature = "dox"))] 73 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] 74 focus_on_click: Option<bool>, 75 halign: Option<Align>, 76 has_default: Option<bool>, 77 has_focus: Option<bool>, 78 has_tooltip: Option<bool>, 79 height_request: Option<i32>, 80 hexpand: Option<bool>, 81 hexpand_set: Option<bool>, 82 is_focus: Option<bool>, 83 margin: Option<i32>, 84 margin_bottom: Option<i32>, 85 margin_end: Option<i32>, 86 margin_start: Option<i32>, 87 margin_top: Option<i32>, 88 name: Option<String>, 89 no_show_all: Option<bool>, 90 opacity: Option<f64>, 91 parent: Option<Container>, 92 receives_default: Option<bool>, 93 sensitive: Option<bool>, 94 tooltip_markup: Option<String>, 95 tooltip_text: Option<String>, 96 valign: Option<Align>, 97 vexpand: Option<bool>, 98 vexpand_set: Option<bool>, 99 visible: Option<bool>, 100 width_request: Option<i32>, 101 } 102 103 impl SeparatorToolItemBuilder { 104 // rustdoc-stripper-ignore-next 105 /// Create a new [`SeparatorToolItemBuilder`]. new() -> Self106 pub fn new() -> Self { 107 Self::default() 108 } 109 110 // rustdoc-stripper-ignore-next 111 /// Build the [`SeparatorToolItem`]. build(self) -> SeparatorToolItem112 pub fn build(self) -> SeparatorToolItem { 113 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 114 if let Some(ref draw) = self.draw { 115 properties.push(("draw", draw)); 116 } 117 if let Some(ref is_important) = self.is_important { 118 properties.push(("is-important", is_important)); 119 } 120 if let Some(ref visible_horizontal) = self.visible_horizontal { 121 properties.push(("visible-horizontal", visible_horizontal)); 122 } 123 if let Some(ref visible_vertical) = self.visible_vertical { 124 properties.push(("visible-vertical", visible_vertical)); 125 } 126 if let Some(ref border_width) = self.border_width { 127 properties.push(("border-width", border_width)); 128 } 129 if let Some(ref child) = self.child { 130 properties.push(("child", child)); 131 } 132 if let Some(ref resize_mode) = self.resize_mode { 133 properties.push(("resize-mode", resize_mode)); 134 } 135 if let Some(ref app_paintable) = self.app_paintable { 136 properties.push(("app-paintable", app_paintable)); 137 } 138 if let Some(ref can_default) = self.can_default { 139 properties.push(("can-default", can_default)); 140 } 141 if let Some(ref can_focus) = self.can_focus { 142 properties.push(("can-focus", can_focus)); 143 } 144 if let Some(ref events) = self.events { 145 properties.push(("events", events)); 146 } 147 if let Some(ref expand) = self.expand { 148 properties.push(("expand", expand)); 149 } 150 #[cfg(any(feature = "v3_20", feature = "dox"))] 151 if let Some(ref focus_on_click) = self.focus_on_click { 152 properties.push(("focus-on-click", focus_on_click)); 153 } 154 if let Some(ref halign) = self.halign { 155 properties.push(("halign", halign)); 156 } 157 if let Some(ref has_default) = self.has_default { 158 properties.push(("has-default", has_default)); 159 } 160 if let Some(ref has_focus) = self.has_focus { 161 properties.push(("has-focus", has_focus)); 162 } 163 if let Some(ref has_tooltip) = self.has_tooltip { 164 properties.push(("has-tooltip", has_tooltip)); 165 } 166 if let Some(ref height_request) = self.height_request { 167 properties.push(("height-request", height_request)); 168 } 169 if let Some(ref hexpand) = self.hexpand { 170 properties.push(("hexpand", hexpand)); 171 } 172 if let Some(ref hexpand_set) = self.hexpand_set { 173 properties.push(("hexpand-set", hexpand_set)); 174 } 175 if let Some(ref is_focus) = self.is_focus { 176 properties.push(("is-focus", is_focus)); 177 } 178 if let Some(ref margin) = self.margin { 179 properties.push(("margin", margin)); 180 } 181 if let Some(ref margin_bottom) = self.margin_bottom { 182 properties.push(("margin-bottom", margin_bottom)); 183 } 184 if let Some(ref margin_end) = self.margin_end { 185 properties.push(("margin-end", margin_end)); 186 } 187 if let Some(ref margin_start) = self.margin_start { 188 properties.push(("margin-start", margin_start)); 189 } 190 if let Some(ref margin_top) = self.margin_top { 191 properties.push(("margin-top", margin_top)); 192 } 193 if let Some(ref name) = self.name { 194 properties.push(("name", name)); 195 } 196 if let Some(ref no_show_all) = self.no_show_all { 197 properties.push(("no-show-all", no_show_all)); 198 } 199 if let Some(ref opacity) = self.opacity { 200 properties.push(("opacity", opacity)); 201 } 202 if let Some(ref parent) = self.parent { 203 properties.push(("parent", parent)); 204 } 205 if let Some(ref receives_default) = self.receives_default { 206 properties.push(("receives-default", receives_default)); 207 } 208 if let Some(ref sensitive) = self.sensitive { 209 properties.push(("sensitive", sensitive)); 210 } 211 if let Some(ref tooltip_markup) = self.tooltip_markup { 212 properties.push(("tooltip-markup", tooltip_markup)); 213 } 214 if let Some(ref tooltip_text) = self.tooltip_text { 215 properties.push(("tooltip-text", tooltip_text)); 216 } 217 if let Some(ref valign) = self.valign { 218 properties.push(("valign", valign)); 219 } 220 if let Some(ref vexpand) = self.vexpand { 221 properties.push(("vexpand", vexpand)); 222 } 223 if let Some(ref vexpand_set) = self.vexpand_set { 224 properties.push(("vexpand-set", vexpand_set)); 225 } 226 if let Some(ref visible) = self.visible { 227 properties.push(("visible", visible)); 228 } 229 if let Some(ref width_request) = self.width_request { 230 properties.push(("width-request", width_request)); 231 } 232 glib::Object::new::<SeparatorToolItem>(&properties) 233 .expect("Failed to create an instance of SeparatorToolItem") 234 } 235 draw(mut self, draw: bool) -> Self236 pub fn draw(mut self, draw: bool) -> Self { 237 self.draw = Some(draw); 238 self 239 } 240 is_important(mut self, is_important: bool) -> Self241 pub fn is_important(mut self, is_important: bool) -> Self { 242 self.is_important = Some(is_important); 243 self 244 } 245 visible_horizontal(mut self, visible_horizontal: bool) -> Self246 pub fn visible_horizontal(mut self, visible_horizontal: bool) -> Self { 247 self.visible_horizontal = Some(visible_horizontal); 248 self 249 } 250 visible_vertical(mut self, visible_vertical: bool) -> Self251 pub fn visible_vertical(mut self, visible_vertical: bool) -> Self { 252 self.visible_vertical = Some(visible_vertical); 253 self 254 } 255 border_width(mut self, border_width: u32) -> Self256 pub fn border_width(mut self, border_width: u32) -> Self { 257 self.border_width = Some(border_width); 258 self 259 } 260 child<P: IsA<Widget>>(mut self, child: &P) -> Self261 pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self { 262 self.child = Some(child.clone().upcast()); 263 self 264 } 265 resize_mode(mut self, resize_mode: ResizeMode) -> Self266 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { 267 self.resize_mode = Some(resize_mode); 268 self 269 } 270 app_paintable(mut self, app_paintable: bool) -> Self271 pub fn app_paintable(mut self, app_paintable: bool) -> Self { 272 self.app_paintable = Some(app_paintable); 273 self 274 } 275 can_default(mut self, can_default: bool) -> Self276 pub fn can_default(mut self, can_default: bool) -> Self { 277 self.can_default = Some(can_default); 278 self 279 } 280 can_focus(mut self, can_focus: bool) -> Self281 pub fn can_focus(mut self, can_focus: bool) -> Self { 282 self.can_focus = Some(can_focus); 283 self 284 } 285 events(mut self, events: gdk::EventMask) -> Self286 pub fn events(mut self, events: gdk::EventMask) -> Self { 287 self.events = Some(events); 288 self 289 } 290 expand(mut self, expand: bool) -> Self291 pub fn expand(mut self, expand: bool) -> Self { 292 self.expand = Some(expand); 293 self 294 } 295 296 #[cfg(any(feature = "v3_20", feature = "dox"))] 297 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] focus_on_click(mut self, focus_on_click: bool) -> Self298 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { 299 self.focus_on_click = Some(focus_on_click); 300 self 301 } 302 halign(mut self, halign: Align) -> Self303 pub fn halign(mut self, halign: Align) -> Self { 304 self.halign = Some(halign); 305 self 306 } 307 has_default(mut self, has_default: bool) -> Self308 pub fn has_default(mut self, has_default: bool) -> Self { 309 self.has_default = Some(has_default); 310 self 311 } 312 has_focus(mut self, has_focus: bool) -> Self313 pub fn has_focus(mut self, has_focus: bool) -> Self { 314 self.has_focus = Some(has_focus); 315 self 316 } 317 has_tooltip(mut self, has_tooltip: bool) -> Self318 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { 319 self.has_tooltip = Some(has_tooltip); 320 self 321 } 322 height_request(mut self, height_request: i32) -> Self323 pub fn height_request(mut self, height_request: i32) -> Self { 324 self.height_request = Some(height_request); 325 self 326 } 327 hexpand(mut self, hexpand: bool) -> Self328 pub fn hexpand(mut self, hexpand: bool) -> Self { 329 self.hexpand = Some(hexpand); 330 self 331 } 332 hexpand_set(mut self, hexpand_set: bool) -> Self333 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { 334 self.hexpand_set = Some(hexpand_set); 335 self 336 } 337 is_focus(mut self, is_focus: bool) -> Self338 pub fn is_focus(mut self, is_focus: bool) -> Self { 339 self.is_focus = Some(is_focus); 340 self 341 } 342 margin(mut self, margin: i32) -> Self343 pub fn margin(mut self, margin: i32) -> Self { 344 self.margin = Some(margin); 345 self 346 } 347 margin_bottom(mut self, margin_bottom: i32) -> Self348 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { 349 self.margin_bottom = Some(margin_bottom); 350 self 351 } 352 margin_end(mut self, margin_end: i32) -> Self353 pub fn margin_end(mut self, margin_end: i32) -> Self { 354 self.margin_end = Some(margin_end); 355 self 356 } 357 margin_start(mut self, margin_start: i32) -> Self358 pub fn margin_start(mut self, margin_start: i32) -> Self { 359 self.margin_start = Some(margin_start); 360 self 361 } 362 margin_top(mut self, margin_top: i32) -> Self363 pub fn margin_top(mut self, margin_top: i32) -> Self { 364 self.margin_top = Some(margin_top); 365 self 366 } 367 name(mut self, name: &str) -> Self368 pub fn name(mut self, name: &str) -> Self { 369 self.name = Some(name.to_string()); 370 self 371 } 372 no_show_all(mut self, no_show_all: bool) -> Self373 pub fn no_show_all(mut self, no_show_all: bool) -> Self { 374 self.no_show_all = Some(no_show_all); 375 self 376 } 377 opacity(mut self, opacity: f64) -> Self378 pub fn opacity(mut self, opacity: f64) -> Self { 379 self.opacity = Some(opacity); 380 self 381 } 382 parent<P: IsA<Container>>(mut self, parent: &P) -> Self383 pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self { 384 self.parent = Some(parent.clone().upcast()); 385 self 386 } 387 receives_default(mut self, receives_default: bool) -> Self388 pub fn receives_default(mut self, receives_default: bool) -> Self { 389 self.receives_default = Some(receives_default); 390 self 391 } 392 sensitive(mut self, sensitive: bool) -> Self393 pub fn sensitive(mut self, sensitive: bool) -> Self { 394 self.sensitive = Some(sensitive); 395 self 396 } 397 tooltip_markup(mut self, tooltip_markup: &str) -> Self398 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { 399 self.tooltip_markup = Some(tooltip_markup.to_string()); 400 self 401 } 402 tooltip_text(mut self, tooltip_text: &str) -> Self403 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { 404 self.tooltip_text = Some(tooltip_text.to_string()); 405 self 406 } 407 valign(mut self, valign: Align) -> Self408 pub fn valign(mut self, valign: Align) -> Self { 409 self.valign = Some(valign); 410 self 411 } 412 vexpand(mut self, vexpand: bool) -> Self413 pub fn vexpand(mut self, vexpand: bool) -> Self { 414 self.vexpand = Some(vexpand); 415 self 416 } 417 vexpand_set(mut self, vexpand_set: bool) -> Self418 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { 419 self.vexpand_set = Some(vexpand_set); 420 self 421 } 422 visible(mut self, visible: bool) -> Self423 pub fn visible(mut self, visible: bool) -> Self { 424 self.visible = Some(visible); 425 self 426 } 427 width_request(mut self, width_request: i32) -> Self428 pub fn width_request(mut self, width_request: i32) -> Self { 429 self.width_request = Some(width_request); 430 self 431 } 432 } 433 434 pub const NONE_SEPARATOR_TOOL_ITEM: Option<&SeparatorToolItem> = None; 435 436 pub trait SeparatorToolItemExt: 'static { 437 #[doc(alias = "gtk_separator_tool_item_get_draw")] 438 #[doc(alias = "get_draw")] draws(&self) -> bool439 fn draws(&self) -> bool; 440 441 #[doc(alias = "gtk_separator_tool_item_set_draw")] set_draw(&self, draw: bool)442 fn set_draw(&self, draw: bool); 443 444 #[doc(alias = "draw")] connect_draw_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId445 fn connect_draw_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 446 } 447 448 impl<O: IsA<SeparatorToolItem>> SeparatorToolItemExt for O { draws(&self) -> bool449 fn draws(&self) -> bool { 450 unsafe { 451 from_glib(ffi::gtk_separator_tool_item_get_draw( 452 self.as_ref().to_glib_none().0, 453 )) 454 } 455 } 456 set_draw(&self, draw: bool)457 fn set_draw(&self, draw: bool) { 458 unsafe { 459 ffi::gtk_separator_tool_item_set_draw(self.as_ref().to_glib_none().0, draw.into_glib()); 460 } 461 } 462 connect_draw_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId463 fn connect_draw_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 464 unsafe extern "C" fn notify_draw_trampoline< 465 P: IsA<SeparatorToolItem>, 466 F: Fn(&P) + 'static, 467 >( 468 this: *mut ffi::GtkSeparatorToolItem, 469 _param_spec: glib::ffi::gpointer, 470 f: glib::ffi::gpointer, 471 ) { 472 let f: &F = &*(f as *const F); 473 f(SeparatorToolItem::from_glib_borrow(this).unsafe_cast_ref()) 474 } 475 unsafe { 476 let f: Box_<F> = Box_::new(f); 477 connect_raw( 478 self.as_ptr() as *mut _, 479 b"notify::draw\0".as_ptr() as *const _, 480 Some(transmute::<_, unsafe extern "C" fn()>( 481 notify_draw_trampoline::<Self, F> as *const (), 482 )), 483 Box_::into_raw(f), 484 ) 485 } 486 } 487 } 488 489 impl fmt::Display for SeparatorToolItem { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result490 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 491 f.write_str("SeparatorToolItem") 492 } 493 } 494