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::Popover; 10 #[cfg(any(feature = "v3_20", feature = "dox"))] 11 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] 12 use crate::PopoverConstraint; 13 use crate::PositionType; 14 use crate::ResizeMode; 15 use crate::Widget; 16 use glib::object::Cast; 17 use glib::object::IsA; 18 use glib::object::ObjectType as ObjectType_; 19 use glib::signal::connect_raw; 20 use glib::signal::SignalHandlerId; 21 use glib::translate::*; 22 use glib::StaticType; 23 use glib::ToValue; 24 use std::boxed::Box as Box_; 25 use std::fmt; 26 use std::mem::transmute; 27 28 glib::wrapper! { 29 #[doc(alias = "GtkPopoverMenu")] 30 pub struct PopoverMenu(Object<ffi::GtkPopoverMenu, ffi::GtkPopoverMenuClass>) @extends Popover, Bin, Container, Widget, @implements Buildable; 31 32 match fn { 33 type_ => || ffi::gtk_popover_menu_get_type(), 34 } 35 } 36 37 impl PopoverMenu { 38 #[doc(alias = "gtk_popover_menu_new")] new() -> PopoverMenu39 pub fn new() -> PopoverMenu { 40 assert_initialized_main_thread!(); 41 unsafe { Widget::from_glib_none(ffi::gtk_popover_menu_new()).unsafe_cast() } 42 } 43 44 // rustdoc-stripper-ignore-next 45 /// Creates a new builder-pattern struct instance to construct [`PopoverMenu`] objects. 46 /// 47 /// This method returns an instance of [`PopoverMenuBuilder`] which can be used to create [`PopoverMenu`] objects. builder() -> PopoverMenuBuilder48 pub fn builder() -> PopoverMenuBuilder { 49 PopoverMenuBuilder::default() 50 } 51 52 #[doc(alias = "gtk_popover_menu_open_submenu")] open_submenu(&self, name: &str)53 pub fn open_submenu(&self, name: &str) { 54 unsafe { 55 ffi::gtk_popover_menu_open_submenu(self.to_glib_none().0, name.to_glib_none().0); 56 } 57 } 58 59 #[doc(alias = "visible-submenu")] visible_submenu(&self) -> Option<glib::GString>60 pub fn visible_submenu(&self) -> Option<glib::GString> { 61 unsafe { 62 let mut value = glib::Value::from_type(<glib::GString as StaticType>::static_type()); 63 glib::gobject_ffi::g_object_get_property( 64 self.as_ptr() as *mut glib::gobject_ffi::GObject, 65 b"visible-submenu\0".as_ptr() as *const _, 66 value.to_glib_none_mut().0, 67 ); 68 value 69 .get() 70 .expect("Return Value for property `visible-submenu` getter") 71 } 72 } 73 74 #[doc(alias = "visible-submenu")] set_visible_submenu(&self, visible_submenu: Option<&str>)75 pub fn set_visible_submenu(&self, visible_submenu: Option<&str>) { 76 unsafe { 77 glib::gobject_ffi::g_object_set_property( 78 self.as_ptr() as *mut glib::gobject_ffi::GObject, 79 b"visible-submenu\0".as_ptr() as *const _, 80 visible_submenu.to_value().to_glib_none().0, 81 ); 82 } 83 } 84 child_position<T: IsA<Widget>>(&self, item: &T) -> i3285 pub fn child_position<T: IsA<Widget>>(&self, item: &T) -> i32 { 86 unsafe { 87 let mut value = glib::Value::from_type(<i32 as StaticType>::static_type()); 88 crate::ffi::gtk_container_child_get_property( 89 self.as_ptr() as *mut crate::ffi::GtkContainer, 90 item.to_glib_none().0 as *mut _, 91 b"position\0".as_ptr() as *const _, 92 value.to_glib_none_mut().0, 93 ); 94 value 95 .get() 96 .expect("Return Value for property `position` getter") 97 } 98 } 99 set_child_position<T: IsA<Widget>>(&self, item: &T, position: i32)100 pub fn set_child_position<T: IsA<Widget>>(&self, item: &T, position: i32) { 101 unsafe { 102 crate::ffi::gtk_container_child_set_property( 103 self.as_ptr() as *mut crate::ffi::GtkContainer, 104 item.to_glib_none().0 as *mut _, 105 b"position\0".as_ptr() as *const _, 106 position.to_value().to_glib_none().0, 107 ); 108 } 109 } 110 child_submenu<T: IsA<Widget>>(&self, item: &T) -> Option<glib::GString>111 pub fn child_submenu<T: IsA<Widget>>(&self, item: &T) -> Option<glib::GString> { 112 unsafe { 113 let mut value = glib::Value::from_type(<glib::GString as StaticType>::static_type()); 114 crate::ffi::gtk_container_child_get_property( 115 self.as_ptr() as *mut crate::ffi::GtkContainer, 116 item.to_glib_none().0 as *mut _, 117 b"submenu\0".as_ptr() as *const _, 118 value.to_glib_none_mut().0, 119 ); 120 value 121 .get() 122 .expect("Return Value for property `submenu` getter") 123 } 124 } 125 set_child_submenu<T: IsA<Widget>>(&self, item: &T, submenu: Option<&str>)126 pub fn set_child_submenu<T: IsA<Widget>>(&self, item: &T, submenu: Option<&str>) { 127 unsafe { 128 crate::ffi::gtk_container_child_set_property( 129 self.as_ptr() as *mut crate::ffi::GtkContainer, 130 item.to_glib_none().0 as *mut _, 131 b"submenu\0".as_ptr() as *const _, 132 submenu.to_value().to_glib_none().0, 133 ); 134 } 135 } 136 137 #[doc(alias = "visible-submenu")] connect_visible_submenu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId138 pub fn connect_visible_submenu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 139 unsafe extern "C" fn notify_visible_submenu_trampoline<F: Fn(&PopoverMenu) + 'static>( 140 this: *mut ffi::GtkPopoverMenu, 141 _param_spec: glib::ffi::gpointer, 142 f: glib::ffi::gpointer, 143 ) { 144 let f: &F = &*(f as *const F); 145 f(&from_glib_borrow(this)) 146 } 147 unsafe { 148 let f: Box_<F> = Box_::new(f); 149 connect_raw( 150 self.as_ptr() as *mut _, 151 b"notify::visible-submenu\0".as_ptr() as *const _, 152 Some(transmute::<_, unsafe extern "C" fn()>( 153 notify_visible_submenu_trampoline::<F> as *const (), 154 )), 155 Box_::into_raw(f), 156 ) 157 } 158 } 159 } 160 161 impl Default for PopoverMenu { default() -> Self162 fn default() -> Self { 163 Self::new() 164 } 165 } 166 167 #[derive(Clone, Default)] 168 // rustdoc-stripper-ignore-next 169 /// A [builder-pattern] type to construct [`PopoverMenu`] objects. 170 /// 171 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html 172 pub struct PopoverMenuBuilder { 173 visible_submenu: Option<String>, 174 #[cfg(any(feature = "v3_20", feature = "dox"))] 175 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] 176 constrain_to: Option<PopoverConstraint>, 177 modal: Option<bool>, 178 pointing_to: Option<gdk::Rectangle>, 179 position: Option<PositionType>, 180 relative_to: Option<Widget>, 181 #[cfg_attr(feature = "v3_22", deprecated = "Since 3.22")] 182 transitions_enabled: Option<bool>, 183 border_width: Option<u32>, 184 child: Option<Widget>, 185 resize_mode: Option<ResizeMode>, 186 app_paintable: Option<bool>, 187 can_default: Option<bool>, 188 can_focus: Option<bool>, 189 events: Option<gdk::EventMask>, 190 expand: Option<bool>, 191 #[cfg(any(feature = "v3_20", feature = "dox"))] 192 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] 193 focus_on_click: Option<bool>, 194 halign: Option<Align>, 195 has_default: Option<bool>, 196 has_focus: Option<bool>, 197 has_tooltip: Option<bool>, 198 height_request: Option<i32>, 199 hexpand: Option<bool>, 200 hexpand_set: Option<bool>, 201 is_focus: Option<bool>, 202 margin: Option<i32>, 203 margin_bottom: Option<i32>, 204 margin_end: Option<i32>, 205 margin_start: Option<i32>, 206 margin_top: Option<i32>, 207 name: Option<String>, 208 no_show_all: Option<bool>, 209 opacity: Option<f64>, 210 parent: Option<Container>, 211 receives_default: Option<bool>, 212 sensitive: Option<bool>, 213 tooltip_markup: Option<String>, 214 tooltip_text: Option<String>, 215 valign: Option<Align>, 216 vexpand: Option<bool>, 217 vexpand_set: Option<bool>, 218 visible: Option<bool>, 219 width_request: Option<i32>, 220 } 221 222 impl PopoverMenuBuilder { 223 // rustdoc-stripper-ignore-next 224 /// Create a new [`PopoverMenuBuilder`]. new() -> Self225 pub fn new() -> Self { 226 Self::default() 227 } 228 229 // rustdoc-stripper-ignore-next 230 /// Build the [`PopoverMenu`]. build(self) -> PopoverMenu231 pub fn build(self) -> PopoverMenu { 232 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 233 if let Some(ref visible_submenu) = self.visible_submenu { 234 properties.push(("visible-submenu", visible_submenu)); 235 } 236 #[cfg(any(feature = "v3_20", feature = "dox"))] 237 if let Some(ref constrain_to) = self.constrain_to { 238 properties.push(("constrain-to", constrain_to)); 239 } 240 if let Some(ref modal) = self.modal { 241 properties.push(("modal", modal)); 242 } 243 if let Some(ref pointing_to) = self.pointing_to { 244 properties.push(("pointing-to", pointing_to)); 245 } 246 if let Some(ref position) = self.position { 247 properties.push(("position", position)); 248 } 249 if let Some(ref relative_to) = self.relative_to { 250 properties.push(("relative-to", relative_to)); 251 } 252 if let Some(ref transitions_enabled) = self.transitions_enabled { 253 properties.push(("transitions-enabled", transitions_enabled)); 254 } 255 if let Some(ref border_width) = self.border_width { 256 properties.push(("border-width", border_width)); 257 } 258 if let Some(ref child) = self.child { 259 properties.push(("child", child)); 260 } 261 if let Some(ref resize_mode) = self.resize_mode { 262 properties.push(("resize-mode", resize_mode)); 263 } 264 if let Some(ref app_paintable) = self.app_paintable { 265 properties.push(("app-paintable", app_paintable)); 266 } 267 if let Some(ref can_default) = self.can_default { 268 properties.push(("can-default", can_default)); 269 } 270 if let Some(ref can_focus) = self.can_focus { 271 properties.push(("can-focus", can_focus)); 272 } 273 if let Some(ref events) = self.events { 274 properties.push(("events", events)); 275 } 276 if let Some(ref expand) = self.expand { 277 properties.push(("expand", expand)); 278 } 279 #[cfg(any(feature = "v3_20", feature = "dox"))] 280 if let Some(ref focus_on_click) = self.focus_on_click { 281 properties.push(("focus-on-click", focus_on_click)); 282 } 283 if let Some(ref halign) = self.halign { 284 properties.push(("halign", halign)); 285 } 286 if let Some(ref has_default) = self.has_default { 287 properties.push(("has-default", has_default)); 288 } 289 if let Some(ref has_focus) = self.has_focus { 290 properties.push(("has-focus", has_focus)); 291 } 292 if let Some(ref has_tooltip) = self.has_tooltip { 293 properties.push(("has-tooltip", has_tooltip)); 294 } 295 if let Some(ref height_request) = self.height_request { 296 properties.push(("height-request", height_request)); 297 } 298 if let Some(ref hexpand) = self.hexpand { 299 properties.push(("hexpand", hexpand)); 300 } 301 if let Some(ref hexpand_set) = self.hexpand_set { 302 properties.push(("hexpand-set", hexpand_set)); 303 } 304 if let Some(ref is_focus) = self.is_focus { 305 properties.push(("is-focus", is_focus)); 306 } 307 if let Some(ref margin) = self.margin { 308 properties.push(("margin", margin)); 309 } 310 if let Some(ref margin_bottom) = self.margin_bottom { 311 properties.push(("margin-bottom", margin_bottom)); 312 } 313 if let Some(ref margin_end) = self.margin_end { 314 properties.push(("margin-end", margin_end)); 315 } 316 if let Some(ref margin_start) = self.margin_start { 317 properties.push(("margin-start", margin_start)); 318 } 319 if let Some(ref margin_top) = self.margin_top { 320 properties.push(("margin-top", margin_top)); 321 } 322 if let Some(ref name) = self.name { 323 properties.push(("name", name)); 324 } 325 if let Some(ref no_show_all) = self.no_show_all { 326 properties.push(("no-show-all", no_show_all)); 327 } 328 if let Some(ref opacity) = self.opacity { 329 properties.push(("opacity", opacity)); 330 } 331 if let Some(ref parent) = self.parent { 332 properties.push(("parent", parent)); 333 } 334 if let Some(ref receives_default) = self.receives_default { 335 properties.push(("receives-default", receives_default)); 336 } 337 if let Some(ref sensitive) = self.sensitive { 338 properties.push(("sensitive", sensitive)); 339 } 340 if let Some(ref tooltip_markup) = self.tooltip_markup { 341 properties.push(("tooltip-markup", tooltip_markup)); 342 } 343 if let Some(ref tooltip_text) = self.tooltip_text { 344 properties.push(("tooltip-text", tooltip_text)); 345 } 346 if let Some(ref valign) = self.valign { 347 properties.push(("valign", valign)); 348 } 349 if let Some(ref vexpand) = self.vexpand { 350 properties.push(("vexpand", vexpand)); 351 } 352 if let Some(ref vexpand_set) = self.vexpand_set { 353 properties.push(("vexpand-set", vexpand_set)); 354 } 355 if let Some(ref visible) = self.visible { 356 properties.push(("visible", visible)); 357 } 358 if let Some(ref width_request) = self.width_request { 359 properties.push(("width-request", width_request)); 360 } 361 glib::Object::new::<PopoverMenu>(&properties) 362 .expect("Failed to create an instance of PopoverMenu") 363 } 364 visible_submenu(mut self, visible_submenu: &str) -> Self365 pub fn visible_submenu(mut self, visible_submenu: &str) -> Self { 366 self.visible_submenu = Some(visible_submenu.to_string()); 367 self 368 } 369 370 #[cfg(any(feature = "v3_20", feature = "dox"))] 371 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] constrain_to(mut self, constrain_to: PopoverConstraint) -> Self372 pub fn constrain_to(mut self, constrain_to: PopoverConstraint) -> Self { 373 self.constrain_to = Some(constrain_to); 374 self 375 } 376 modal(mut self, modal: bool) -> Self377 pub fn modal(mut self, modal: bool) -> Self { 378 self.modal = Some(modal); 379 self 380 } 381 pointing_to(mut self, pointing_to: &gdk::Rectangle) -> Self382 pub fn pointing_to(mut self, pointing_to: &gdk::Rectangle) -> Self { 383 self.pointing_to = Some(pointing_to.clone()); 384 self 385 } 386 position(mut self, position: PositionType) -> Self387 pub fn position(mut self, position: PositionType) -> Self { 388 self.position = Some(position); 389 self 390 } 391 relative_to<P: IsA<Widget>>(mut self, relative_to: &P) -> Self392 pub fn relative_to<P: IsA<Widget>>(mut self, relative_to: &P) -> Self { 393 self.relative_to = Some(relative_to.clone().upcast()); 394 self 395 } 396 397 #[cfg_attr(feature = "v3_22", deprecated = "Since 3.22")] transitions_enabled(mut self, transitions_enabled: bool) -> Self398 pub fn transitions_enabled(mut self, transitions_enabled: bool) -> Self { 399 self.transitions_enabled = Some(transitions_enabled); 400 self 401 } 402 border_width(mut self, border_width: u32) -> Self403 pub fn border_width(mut self, border_width: u32) -> Self { 404 self.border_width = Some(border_width); 405 self 406 } 407 child<P: IsA<Widget>>(mut self, child: &P) -> Self408 pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self { 409 self.child = Some(child.clone().upcast()); 410 self 411 } 412 resize_mode(mut self, resize_mode: ResizeMode) -> Self413 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { 414 self.resize_mode = Some(resize_mode); 415 self 416 } 417 app_paintable(mut self, app_paintable: bool) -> Self418 pub fn app_paintable(mut self, app_paintable: bool) -> Self { 419 self.app_paintable = Some(app_paintable); 420 self 421 } 422 can_default(mut self, can_default: bool) -> Self423 pub fn can_default(mut self, can_default: bool) -> Self { 424 self.can_default = Some(can_default); 425 self 426 } 427 can_focus(mut self, can_focus: bool) -> Self428 pub fn can_focus(mut self, can_focus: bool) -> Self { 429 self.can_focus = Some(can_focus); 430 self 431 } 432 events(mut self, events: gdk::EventMask) -> Self433 pub fn events(mut self, events: gdk::EventMask) -> Self { 434 self.events = Some(events); 435 self 436 } 437 expand(mut self, expand: bool) -> Self438 pub fn expand(mut self, expand: bool) -> Self { 439 self.expand = Some(expand); 440 self 441 } 442 443 #[cfg(any(feature = "v3_20", feature = "dox"))] 444 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] focus_on_click(mut self, focus_on_click: bool) -> Self445 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { 446 self.focus_on_click = Some(focus_on_click); 447 self 448 } 449 halign(mut self, halign: Align) -> Self450 pub fn halign(mut self, halign: Align) -> Self { 451 self.halign = Some(halign); 452 self 453 } 454 has_default(mut self, has_default: bool) -> Self455 pub fn has_default(mut self, has_default: bool) -> Self { 456 self.has_default = Some(has_default); 457 self 458 } 459 has_focus(mut self, has_focus: bool) -> Self460 pub fn has_focus(mut self, has_focus: bool) -> Self { 461 self.has_focus = Some(has_focus); 462 self 463 } 464 has_tooltip(mut self, has_tooltip: bool) -> Self465 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { 466 self.has_tooltip = Some(has_tooltip); 467 self 468 } 469 height_request(mut self, height_request: i32) -> Self470 pub fn height_request(mut self, height_request: i32) -> Self { 471 self.height_request = Some(height_request); 472 self 473 } 474 hexpand(mut self, hexpand: bool) -> Self475 pub fn hexpand(mut self, hexpand: bool) -> Self { 476 self.hexpand = Some(hexpand); 477 self 478 } 479 hexpand_set(mut self, hexpand_set: bool) -> Self480 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { 481 self.hexpand_set = Some(hexpand_set); 482 self 483 } 484 is_focus(mut self, is_focus: bool) -> Self485 pub fn is_focus(mut self, is_focus: bool) -> Self { 486 self.is_focus = Some(is_focus); 487 self 488 } 489 margin(mut self, margin: i32) -> Self490 pub fn margin(mut self, margin: i32) -> Self { 491 self.margin = Some(margin); 492 self 493 } 494 margin_bottom(mut self, margin_bottom: i32) -> Self495 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { 496 self.margin_bottom = Some(margin_bottom); 497 self 498 } 499 margin_end(mut self, margin_end: i32) -> Self500 pub fn margin_end(mut self, margin_end: i32) -> Self { 501 self.margin_end = Some(margin_end); 502 self 503 } 504 margin_start(mut self, margin_start: i32) -> Self505 pub fn margin_start(mut self, margin_start: i32) -> Self { 506 self.margin_start = Some(margin_start); 507 self 508 } 509 margin_top(mut self, margin_top: i32) -> Self510 pub fn margin_top(mut self, margin_top: i32) -> Self { 511 self.margin_top = Some(margin_top); 512 self 513 } 514 name(mut self, name: &str) -> Self515 pub fn name(mut self, name: &str) -> Self { 516 self.name = Some(name.to_string()); 517 self 518 } 519 no_show_all(mut self, no_show_all: bool) -> Self520 pub fn no_show_all(mut self, no_show_all: bool) -> Self { 521 self.no_show_all = Some(no_show_all); 522 self 523 } 524 opacity(mut self, opacity: f64) -> Self525 pub fn opacity(mut self, opacity: f64) -> Self { 526 self.opacity = Some(opacity); 527 self 528 } 529 parent<P: IsA<Container>>(mut self, parent: &P) -> Self530 pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self { 531 self.parent = Some(parent.clone().upcast()); 532 self 533 } 534 receives_default(mut self, receives_default: bool) -> Self535 pub fn receives_default(mut self, receives_default: bool) -> Self { 536 self.receives_default = Some(receives_default); 537 self 538 } 539 sensitive(mut self, sensitive: bool) -> Self540 pub fn sensitive(mut self, sensitive: bool) -> Self { 541 self.sensitive = Some(sensitive); 542 self 543 } 544 tooltip_markup(mut self, tooltip_markup: &str) -> Self545 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { 546 self.tooltip_markup = Some(tooltip_markup.to_string()); 547 self 548 } 549 tooltip_text(mut self, tooltip_text: &str) -> Self550 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { 551 self.tooltip_text = Some(tooltip_text.to_string()); 552 self 553 } 554 valign(mut self, valign: Align) -> Self555 pub fn valign(mut self, valign: Align) -> Self { 556 self.valign = Some(valign); 557 self 558 } 559 vexpand(mut self, vexpand: bool) -> Self560 pub fn vexpand(mut self, vexpand: bool) -> Self { 561 self.vexpand = Some(vexpand); 562 self 563 } 564 vexpand_set(mut self, vexpand_set: bool) -> Self565 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { 566 self.vexpand_set = Some(vexpand_set); 567 self 568 } 569 visible(mut self, visible: bool) -> Self570 pub fn visible(mut self, visible: bool) -> Self { 571 self.visible = Some(visible); 572 self 573 } 574 width_request(mut self, width_request: i32) -> Self575 pub fn width_request(mut self, width_request: i32) -> Self { 576 self.width_request = Some(width_request); 577 self 578 } 579 } 580 581 impl fmt::Display for PopoverMenu { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result582 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 583 f.write_str("PopoverMenu") 584 } 585 } 586