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 #[cfg(any(feature = "v3_20", feature = "dox"))] 10 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] 11 use crate::PopoverConstraint; 12 use crate::PositionType; 13 use crate::ResizeMode; 14 use crate::Widget; 15 use glib::object::Cast; 16 use glib::object::IsA; 17 use glib::signal::connect_raw; 18 use glib::signal::SignalHandlerId; 19 use glib::translate::*; 20 use glib::StaticType; 21 use glib::ToValue; 22 use std::boxed::Box as Box_; 23 use std::fmt; 24 use std::mem::transmute; 25 26 glib::wrapper! { 27 #[doc(alias = "GtkPopover")] 28 pub struct Popover(Object<ffi::GtkPopover, ffi::GtkPopoverClass>) @extends Bin, Container, Widget, @implements Buildable; 29 30 match fn { 31 type_ => || ffi::gtk_popover_get_type(), 32 } 33 } 34 35 impl Popover { 36 #[doc(alias = "gtk_popover_new")] new<P: IsA<Widget>>(relative_to: Option<&P>) -> Popover37 pub fn new<P: IsA<Widget>>(relative_to: Option<&P>) -> Popover { 38 assert_initialized_main_thread!(); 39 unsafe { 40 Widget::from_glib_none(ffi::gtk_popover_new( 41 relative_to.map(|p| p.as_ref()).to_glib_none().0, 42 )) 43 .unsafe_cast() 44 } 45 } 46 47 #[doc(alias = "gtk_popover_new_from_model")] 48 #[doc(alias = "new_from_model")] from_model<P: IsA<Widget>, Q: IsA<gio::MenuModel>>( relative_to: Option<&P>, model: &Q, ) -> Popover49 pub fn from_model<P: IsA<Widget>, Q: IsA<gio::MenuModel>>( 50 relative_to: Option<&P>, 51 model: &Q, 52 ) -> Popover { 53 assert_initialized_main_thread!(); 54 unsafe { 55 Widget::from_glib_none(ffi::gtk_popover_new_from_model( 56 relative_to.map(|p| p.as_ref()).to_glib_none().0, 57 model.as_ref().to_glib_none().0, 58 )) 59 .unsafe_cast() 60 } 61 } 62 63 // rustdoc-stripper-ignore-next 64 /// Creates a new builder-pattern struct instance to construct [`Popover`] objects. 65 /// 66 /// This method returns an instance of [`PopoverBuilder`] which can be used to create [`Popover`] objects. builder() -> PopoverBuilder67 pub fn builder() -> PopoverBuilder { 68 PopoverBuilder::default() 69 } 70 } 71 72 #[derive(Clone, Default)] 73 // rustdoc-stripper-ignore-next 74 /// A [builder-pattern] type to construct [`Popover`] objects. 75 /// 76 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html 77 pub struct PopoverBuilder { 78 #[cfg(any(feature = "v3_20", feature = "dox"))] 79 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] 80 constrain_to: Option<PopoverConstraint>, 81 modal: Option<bool>, 82 pointing_to: Option<gdk::Rectangle>, 83 position: Option<PositionType>, 84 relative_to: Option<Widget>, 85 #[cfg_attr(feature = "v3_22", deprecated = "Since 3.22")] 86 transitions_enabled: Option<bool>, 87 border_width: Option<u32>, 88 child: Option<Widget>, 89 resize_mode: Option<ResizeMode>, 90 app_paintable: Option<bool>, 91 can_default: Option<bool>, 92 can_focus: Option<bool>, 93 events: Option<gdk::EventMask>, 94 expand: Option<bool>, 95 #[cfg(any(feature = "v3_20", feature = "dox"))] 96 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] 97 focus_on_click: Option<bool>, 98 halign: Option<Align>, 99 has_default: Option<bool>, 100 has_focus: Option<bool>, 101 has_tooltip: Option<bool>, 102 height_request: Option<i32>, 103 hexpand: Option<bool>, 104 hexpand_set: Option<bool>, 105 is_focus: Option<bool>, 106 margin: Option<i32>, 107 margin_bottom: Option<i32>, 108 margin_end: Option<i32>, 109 margin_start: Option<i32>, 110 margin_top: Option<i32>, 111 name: Option<String>, 112 no_show_all: Option<bool>, 113 opacity: Option<f64>, 114 parent: Option<Container>, 115 receives_default: Option<bool>, 116 sensitive: Option<bool>, 117 tooltip_markup: Option<String>, 118 tooltip_text: Option<String>, 119 valign: Option<Align>, 120 vexpand: Option<bool>, 121 vexpand_set: Option<bool>, 122 visible: Option<bool>, 123 width_request: Option<i32>, 124 } 125 126 impl PopoverBuilder { 127 // rustdoc-stripper-ignore-next 128 /// Create a new [`PopoverBuilder`]. new() -> Self129 pub fn new() -> Self { 130 Self::default() 131 } 132 133 // rustdoc-stripper-ignore-next 134 /// Build the [`Popover`]. build(self) -> Popover135 pub fn build(self) -> Popover { 136 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 137 #[cfg(any(feature = "v3_20", feature = "dox"))] 138 if let Some(ref constrain_to) = self.constrain_to { 139 properties.push(("constrain-to", constrain_to)); 140 } 141 if let Some(ref modal) = self.modal { 142 properties.push(("modal", modal)); 143 } 144 if let Some(ref pointing_to) = self.pointing_to { 145 properties.push(("pointing-to", pointing_to)); 146 } 147 if let Some(ref position) = self.position { 148 properties.push(("position", position)); 149 } 150 if let Some(ref relative_to) = self.relative_to { 151 properties.push(("relative-to", relative_to)); 152 } 153 if let Some(ref transitions_enabled) = self.transitions_enabled { 154 properties.push(("transitions-enabled", transitions_enabled)); 155 } 156 if let Some(ref border_width) = self.border_width { 157 properties.push(("border-width", border_width)); 158 } 159 if let Some(ref child) = self.child { 160 properties.push(("child", child)); 161 } 162 if let Some(ref resize_mode) = self.resize_mode { 163 properties.push(("resize-mode", resize_mode)); 164 } 165 if let Some(ref app_paintable) = self.app_paintable { 166 properties.push(("app-paintable", app_paintable)); 167 } 168 if let Some(ref can_default) = self.can_default { 169 properties.push(("can-default", can_default)); 170 } 171 if let Some(ref can_focus) = self.can_focus { 172 properties.push(("can-focus", can_focus)); 173 } 174 if let Some(ref events) = self.events { 175 properties.push(("events", events)); 176 } 177 if let Some(ref expand) = self.expand { 178 properties.push(("expand", expand)); 179 } 180 #[cfg(any(feature = "v3_20", feature = "dox"))] 181 if let Some(ref focus_on_click) = self.focus_on_click { 182 properties.push(("focus-on-click", focus_on_click)); 183 } 184 if let Some(ref halign) = self.halign { 185 properties.push(("halign", halign)); 186 } 187 if let Some(ref has_default) = self.has_default { 188 properties.push(("has-default", has_default)); 189 } 190 if let Some(ref has_focus) = self.has_focus { 191 properties.push(("has-focus", has_focus)); 192 } 193 if let Some(ref has_tooltip) = self.has_tooltip { 194 properties.push(("has-tooltip", has_tooltip)); 195 } 196 if let Some(ref height_request) = self.height_request { 197 properties.push(("height-request", height_request)); 198 } 199 if let Some(ref hexpand) = self.hexpand { 200 properties.push(("hexpand", hexpand)); 201 } 202 if let Some(ref hexpand_set) = self.hexpand_set { 203 properties.push(("hexpand-set", hexpand_set)); 204 } 205 if let Some(ref is_focus) = self.is_focus { 206 properties.push(("is-focus", is_focus)); 207 } 208 if let Some(ref margin) = self.margin { 209 properties.push(("margin", margin)); 210 } 211 if let Some(ref margin_bottom) = self.margin_bottom { 212 properties.push(("margin-bottom", margin_bottom)); 213 } 214 if let Some(ref margin_end) = self.margin_end { 215 properties.push(("margin-end", margin_end)); 216 } 217 if let Some(ref margin_start) = self.margin_start { 218 properties.push(("margin-start", margin_start)); 219 } 220 if let Some(ref margin_top) = self.margin_top { 221 properties.push(("margin-top", margin_top)); 222 } 223 if let Some(ref name) = self.name { 224 properties.push(("name", name)); 225 } 226 if let Some(ref no_show_all) = self.no_show_all { 227 properties.push(("no-show-all", no_show_all)); 228 } 229 if let Some(ref opacity) = self.opacity { 230 properties.push(("opacity", opacity)); 231 } 232 if let Some(ref parent) = self.parent { 233 properties.push(("parent", parent)); 234 } 235 if let Some(ref receives_default) = self.receives_default { 236 properties.push(("receives-default", receives_default)); 237 } 238 if let Some(ref sensitive) = self.sensitive { 239 properties.push(("sensitive", sensitive)); 240 } 241 if let Some(ref tooltip_markup) = self.tooltip_markup { 242 properties.push(("tooltip-markup", tooltip_markup)); 243 } 244 if let Some(ref tooltip_text) = self.tooltip_text { 245 properties.push(("tooltip-text", tooltip_text)); 246 } 247 if let Some(ref valign) = self.valign { 248 properties.push(("valign", valign)); 249 } 250 if let Some(ref vexpand) = self.vexpand { 251 properties.push(("vexpand", vexpand)); 252 } 253 if let Some(ref vexpand_set) = self.vexpand_set { 254 properties.push(("vexpand-set", vexpand_set)); 255 } 256 if let Some(ref visible) = self.visible { 257 properties.push(("visible", visible)); 258 } 259 if let Some(ref width_request) = self.width_request { 260 properties.push(("width-request", width_request)); 261 } 262 glib::Object::new::<Popover>(&properties).expect("Failed to create an instance of Popover") 263 } 264 265 #[cfg(any(feature = "v3_20", feature = "dox"))] 266 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] constrain_to(mut self, constrain_to: PopoverConstraint) -> Self267 pub fn constrain_to(mut self, constrain_to: PopoverConstraint) -> Self { 268 self.constrain_to = Some(constrain_to); 269 self 270 } 271 modal(mut self, modal: bool) -> Self272 pub fn modal(mut self, modal: bool) -> Self { 273 self.modal = Some(modal); 274 self 275 } 276 pointing_to(mut self, pointing_to: &gdk::Rectangle) -> Self277 pub fn pointing_to(mut self, pointing_to: &gdk::Rectangle) -> Self { 278 self.pointing_to = Some(pointing_to.clone()); 279 self 280 } 281 position(mut self, position: PositionType) -> Self282 pub fn position(mut self, position: PositionType) -> Self { 283 self.position = Some(position); 284 self 285 } 286 relative_to<P: IsA<Widget>>(mut self, relative_to: &P) -> Self287 pub fn relative_to<P: IsA<Widget>>(mut self, relative_to: &P) -> Self { 288 self.relative_to = Some(relative_to.clone().upcast()); 289 self 290 } 291 292 #[cfg_attr(feature = "v3_22", deprecated = "Since 3.22")] transitions_enabled(mut self, transitions_enabled: bool) -> Self293 pub fn transitions_enabled(mut self, transitions_enabled: bool) -> Self { 294 self.transitions_enabled = Some(transitions_enabled); 295 self 296 } 297 border_width(mut self, border_width: u32) -> Self298 pub fn border_width(mut self, border_width: u32) -> Self { 299 self.border_width = Some(border_width); 300 self 301 } 302 child<P: IsA<Widget>>(mut self, child: &P) -> Self303 pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self { 304 self.child = Some(child.clone().upcast()); 305 self 306 } 307 resize_mode(mut self, resize_mode: ResizeMode) -> Self308 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { 309 self.resize_mode = Some(resize_mode); 310 self 311 } 312 app_paintable(mut self, app_paintable: bool) -> Self313 pub fn app_paintable(mut self, app_paintable: bool) -> Self { 314 self.app_paintable = Some(app_paintable); 315 self 316 } 317 can_default(mut self, can_default: bool) -> Self318 pub fn can_default(mut self, can_default: bool) -> Self { 319 self.can_default = Some(can_default); 320 self 321 } 322 can_focus(mut self, can_focus: bool) -> Self323 pub fn can_focus(mut self, can_focus: bool) -> Self { 324 self.can_focus = Some(can_focus); 325 self 326 } 327 events(mut self, events: gdk::EventMask) -> Self328 pub fn events(mut self, events: gdk::EventMask) -> Self { 329 self.events = Some(events); 330 self 331 } 332 expand(mut self, expand: bool) -> Self333 pub fn expand(mut self, expand: bool) -> Self { 334 self.expand = Some(expand); 335 self 336 } 337 338 #[cfg(any(feature = "v3_20", feature = "dox"))] 339 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] focus_on_click(mut self, focus_on_click: bool) -> Self340 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { 341 self.focus_on_click = Some(focus_on_click); 342 self 343 } 344 halign(mut self, halign: Align) -> Self345 pub fn halign(mut self, halign: Align) -> Self { 346 self.halign = Some(halign); 347 self 348 } 349 has_default(mut self, has_default: bool) -> Self350 pub fn has_default(mut self, has_default: bool) -> Self { 351 self.has_default = Some(has_default); 352 self 353 } 354 has_focus(mut self, has_focus: bool) -> Self355 pub fn has_focus(mut self, has_focus: bool) -> Self { 356 self.has_focus = Some(has_focus); 357 self 358 } 359 has_tooltip(mut self, has_tooltip: bool) -> Self360 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { 361 self.has_tooltip = Some(has_tooltip); 362 self 363 } 364 height_request(mut self, height_request: i32) -> Self365 pub fn height_request(mut self, height_request: i32) -> Self { 366 self.height_request = Some(height_request); 367 self 368 } 369 hexpand(mut self, hexpand: bool) -> Self370 pub fn hexpand(mut self, hexpand: bool) -> Self { 371 self.hexpand = Some(hexpand); 372 self 373 } 374 hexpand_set(mut self, hexpand_set: bool) -> Self375 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { 376 self.hexpand_set = Some(hexpand_set); 377 self 378 } 379 is_focus(mut self, is_focus: bool) -> Self380 pub fn is_focus(mut self, is_focus: bool) -> Self { 381 self.is_focus = Some(is_focus); 382 self 383 } 384 margin(mut self, margin: i32) -> Self385 pub fn margin(mut self, margin: i32) -> Self { 386 self.margin = Some(margin); 387 self 388 } 389 margin_bottom(mut self, margin_bottom: i32) -> Self390 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { 391 self.margin_bottom = Some(margin_bottom); 392 self 393 } 394 margin_end(mut self, margin_end: i32) -> Self395 pub fn margin_end(mut self, margin_end: i32) -> Self { 396 self.margin_end = Some(margin_end); 397 self 398 } 399 margin_start(mut self, margin_start: i32) -> Self400 pub fn margin_start(mut self, margin_start: i32) -> Self { 401 self.margin_start = Some(margin_start); 402 self 403 } 404 margin_top(mut self, margin_top: i32) -> Self405 pub fn margin_top(mut self, margin_top: i32) -> Self { 406 self.margin_top = Some(margin_top); 407 self 408 } 409 name(mut self, name: &str) -> Self410 pub fn name(mut self, name: &str) -> Self { 411 self.name = Some(name.to_string()); 412 self 413 } 414 no_show_all(mut self, no_show_all: bool) -> Self415 pub fn no_show_all(mut self, no_show_all: bool) -> Self { 416 self.no_show_all = Some(no_show_all); 417 self 418 } 419 opacity(mut self, opacity: f64) -> Self420 pub fn opacity(mut self, opacity: f64) -> Self { 421 self.opacity = Some(opacity); 422 self 423 } 424 parent<P: IsA<Container>>(mut self, parent: &P) -> Self425 pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self { 426 self.parent = Some(parent.clone().upcast()); 427 self 428 } 429 receives_default(mut self, receives_default: bool) -> Self430 pub fn receives_default(mut self, receives_default: bool) -> Self { 431 self.receives_default = Some(receives_default); 432 self 433 } 434 sensitive(mut self, sensitive: bool) -> Self435 pub fn sensitive(mut self, sensitive: bool) -> Self { 436 self.sensitive = Some(sensitive); 437 self 438 } 439 tooltip_markup(mut self, tooltip_markup: &str) -> Self440 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { 441 self.tooltip_markup = Some(tooltip_markup.to_string()); 442 self 443 } 444 tooltip_text(mut self, tooltip_text: &str) -> Self445 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { 446 self.tooltip_text = Some(tooltip_text.to_string()); 447 self 448 } 449 valign(mut self, valign: Align) -> Self450 pub fn valign(mut self, valign: Align) -> Self { 451 self.valign = Some(valign); 452 self 453 } 454 vexpand(mut self, vexpand: bool) -> Self455 pub fn vexpand(mut self, vexpand: bool) -> Self { 456 self.vexpand = Some(vexpand); 457 self 458 } 459 vexpand_set(mut self, vexpand_set: bool) -> Self460 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { 461 self.vexpand_set = Some(vexpand_set); 462 self 463 } 464 visible(mut self, visible: bool) -> Self465 pub fn visible(mut self, visible: bool) -> Self { 466 self.visible = Some(visible); 467 self 468 } 469 width_request(mut self, width_request: i32) -> Self470 pub fn width_request(mut self, width_request: i32) -> Self { 471 self.width_request = Some(width_request); 472 self 473 } 474 } 475 476 pub const NONE_POPOVER: Option<&Popover> = None; 477 478 pub trait PopoverExt: 'static { 479 #[doc(alias = "gtk_popover_bind_model")] bind_model<P: IsA<gio::MenuModel>>(&self, model: Option<&P>, action_namespace: Option<&str>)480 fn bind_model<P: IsA<gio::MenuModel>>(&self, model: Option<&P>, action_namespace: Option<&str>); 481 482 #[cfg(any(feature = "v3_20", feature = "dox"))] 483 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] 484 #[doc(alias = "gtk_popover_get_constrain_to")] 485 #[doc(alias = "get_constrain_to")] constrain_to(&self) -> PopoverConstraint486 fn constrain_to(&self) -> PopoverConstraint; 487 488 #[doc(alias = "gtk_popover_get_default_widget")] 489 #[doc(alias = "get_default_widget")] default_widget(&self) -> Option<Widget>490 fn default_widget(&self) -> Option<Widget>; 491 492 #[doc(alias = "gtk_popover_get_modal")] 493 #[doc(alias = "get_modal")] is_modal(&self) -> bool494 fn is_modal(&self) -> bool; 495 496 #[doc(alias = "gtk_popover_get_pointing_to")] 497 #[doc(alias = "get_pointing_to")] pointing_to(&self) -> Option<gdk::Rectangle>498 fn pointing_to(&self) -> Option<gdk::Rectangle>; 499 500 #[doc(alias = "gtk_popover_get_position")] 501 #[doc(alias = "get_position")] position(&self) -> PositionType502 fn position(&self) -> PositionType; 503 504 #[doc(alias = "gtk_popover_get_relative_to")] 505 #[doc(alias = "get_relative_to")] relative_to(&self) -> Option<Widget>506 fn relative_to(&self) -> Option<Widget>; 507 508 #[cfg_attr(feature = "v3_22", deprecated = "Since 3.22")] 509 #[doc(alias = "gtk_popover_get_transitions_enabled")] 510 #[doc(alias = "get_transitions_enabled")] is_transitions_enabled(&self) -> bool511 fn is_transitions_enabled(&self) -> bool; 512 513 #[cfg(any(feature = "v3_22", feature = "dox"))] 514 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))] 515 #[doc(alias = "gtk_popover_popdown")] popdown(&self)516 fn popdown(&self); 517 518 #[cfg(any(feature = "v3_22", feature = "dox"))] 519 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))] 520 #[doc(alias = "gtk_popover_popup")] popup(&self)521 fn popup(&self); 522 523 #[cfg(any(feature = "v3_20", feature = "dox"))] 524 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] 525 #[doc(alias = "gtk_popover_set_constrain_to")] set_constrain_to(&self, constraint: PopoverConstraint)526 fn set_constrain_to(&self, constraint: PopoverConstraint); 527 528 #[doc(alias = "gtk_popover_set_default_widget")] set_default_widget<P: IsA<Widget>>(&self, widget: Option<&P>)529 fn set_default_widget<P: IsA<Widget>>(&self, widget: Option<&P>); 530 531 #[doc(alias = "gtk_popover_set_modal")] set_modal(&self, modal: bool)532 fn set_modal(&self, modal: bool); 533 534 #[doc(alias = "gtk_popover_set_pointing_to")] set_pointing_to(&self, rect: &gdk::Rectangle)535 fn set_pointing_to(&self, rect: &gdk::Rectangle); 536 537 #[doc(alias = "gtk_popover_set_position")] set_position(&self, position: PositionType)538 fn set_position(&self, position: PositionType); 539 540 #[doc(alias = "gtk_popover_set_relative_to")] set_relative_to<P: IsA<Widget>>(&self, relative_to: Option<&P>)541 fn set_relative_to<P: IsA<Widget>>(&self, relative_to: Option<&P>); 542 543 #[cfg_attr(feature = "v3_22", deprecated = "Since 3.22")] 544 #[doc(alias = "gtk_popover_set_transitions_enabled")] set_transitions_enabled(&self, transitions_enabled: bool)545 fn set_transitions_enabled(&self, transitions_enabled: bool); 546 547 #[doc(alias = "closed")] connect_closed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId548 fn connect_closed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 549 550 #[cfg(any(feature = "v3_20", feature = "dox"))] 551 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] 552 #[doc(alias = "constrain-to")] connect_constrain_to_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId553 fn connect_constrain_to_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 554 555 #[doc(alias = "modal")] connect_modal_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId556 fn connect_modal_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 557 558 #[doc(alias = "pointing-to")] connect_pointing_to_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId559 fn connect_pointing_to_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 560 561 #[doc(alias = "position")] connect_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId562 fn connect_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 563 564 #[doc(alias = "relative-to")] connect_relative_to_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId565 fn connect_relative_to_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 566 567 #[cfg_attr(feature = "v3_22", deprecated = "Since 3.22")] 568 #[doc(alias = "transitions-enabled")] connect_transitions_enabled_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId569 fn connect_transitions_enabled_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 570 } 571 572 impl<O: IsA<Popover>> PopoverExt for O { bind_model<P: IsA<gio::MenuModel>>( &self, model: Option<&P>, action_namespace: Option<&str>, )573 fn bind_model<P: IsA<gio::MenuModel>>( 574 &self, 575 model: Option<&P>, 576 action_namespace: Option<&str>, 577 ) { 578 unsafe { 579 ffi::gtk_popover_bind_model( 580 self.as_ref().to_glib_none().0, 581 model.map(|p| p.as_ref()).to_glib_none().0, 582 action_namespace.to_glib_none().0, 583 ); 584 } 585 } 586 587 #[cfg(any(feature = "v3_20", feature = "dox"))] 588 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] constrain_to(&self) -> PopoverConstraint589 fn constrain_to(&self) -> PopoverConstraint { 590 unsafe { 591 from_glib(ffi::gtk_popover_get_constrain_to( 592 self.as_ref().to_glib_none().0, 593 )) 594 } 595 } 596 default_widget(&self) -> Option<Widget>597 fn default_widget(&self) -> Option<Widget> { 598 unsafe { 599 from_glib_none(ffi::gtk_popover_get_default_widget( 600 self.as_ref().to_glib_none().0, 601 )) 602 } 603 } 604 is_modal(&self) -> bool605 fn is_modal(&self) -> bool { 606 unsafe { from_glib(ffi::gtk_popover_get_modal(self.as_ref().to_glib_none().0)) } 607 } 608 pointing_to(&self) -> Option<gdk::Rectangle>609 fn pointing_to(&self) -> Option<gdk::Rectangle> { 610 unsafe { 611 let mut rect = gdk::Rectangle::uninitialized(); 612 let ret = from_glib(ffi::gtk_popover_get_pointing_to( 613 self.as_ref().to_glib_none().0, 614 rect.to_glib_none_mut().0, 615 )); 616 if ret { 617 Some(rect) 618 } else { 619 None 620 } 621 } 622 } 623 position(&self) -> PositionType624 fn position(&self) -> PositionType { 625 unsafe { 626 from_glib(ffi::gtk_popover_get_position( 627 self.as_ref().to_glib_none().0, 628 )) 629 } 630 } 631 relative_to(&self) -> Option<Widget>632 fn relative_to(&self) -> Option<Widget> { 633 unsafe { 634 from_glib_none(ffi::gtk_popover_get_relative_to( 635 self.as_ref().to_glib_none().0, 636 )) 637 } 638 } 639 is_transitions_enabled(&self) -> bool640 fn is_transitions_enabled(&self) -> bool { 641 unsafe { 642 from_glib(ffi::gtk_popover_get_transitions_enabled( 643 self.as_ref().to_glib_none().0, 644 )) 645 } 646 } 647 648 #[cfg(any(feature = "v3_22", feature = "dox"))] 649 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))] popdown(&self)650 fn popdown(&self) { 651 unsafe { 652 ffi::gtk_popover_popdown(self.as_ref().to_glib_none().0); 653 } 654 } 655 656 #[cfg(any(feature = "v3_22", feature = "dox"))] 657 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))] popup(&self)658 fn popup(&self) { 659 unsafe { 660 ffi::gtk_popover_popup(self.as_ref().to_glib_none().0); 661 } 662 } 663 664 #[cfg(any(feature = "v3_20", feature = "dox"))] 665 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] set_constrain_to(&self, constraint: PopoverConstraint)666 fn set_constrain_to(&self, constraint: PopoverConstraint) { 667 unsafe { 668 ffi::gtk_popover_set_constrain_to( 669 self.as_ref().to_glib_none().0, 670 constraint.into_glib(), 671 ); 672 } 673 } 674 set_default_widget<P: IsA<Widget>>(&self, widget: Option<&P>)675 fn set_default_widget<P: IsA<Widget>>(&self, widget: Option<&P>) { 676 unsafe { 677 ffi::gtk_popover_set_default_widget( 678 self.as_ref().to_glib_none().0, 679 widget.map(|p| p.as_ref()).to_glib_none().0, 680 ); 681 } 682 } 683 set_modal(&self, modal: bool)684 fn set_modal(&self, modal: bool) { 685 unsafe { 686 ffi::gtk_popover_set_modal(self.as_ref().to_glib_none().0, modal.into_glib()); 687 } 688 } 689 set_pointing_to(&self, rect: &gdk::Rectangle)690 fn set_pointing_to(&self, rect: &gdk::Rectangle) { 691 unsafe { 692 ffi::gtk_popover_set_pointing_to(self.as_ref().to_glib_none().0, rect.to_glib_none().0); 693 } 694 } 695 set_position(&self, position: PositionType)696 fn set_position(&self, position: PositionType) { 697 unsafe { 698 ffi::gtk_popover_set_position(self.as_ref().to_glib_none().0, position.into_glib()); 699 } 700 } 701 set_relative_to<P: IsA<Widget>>(&self, relative_to: Option<&P>)702 fn set_relative_to<P: IsA<Widget>>(&self, relative_to: Option<&P>) { 703 unsafe { 704 ffi::gtk_popover_set_relative_to( 705 self.as_ref().to_glib_none().0, 706 relative_to.map(|p| p.as_ref()).to_glib_none().0, 707 ); 708 } 709 } 710 set_transitions_enabled(&self, transitions_enabled: bool)711 fn set_transitions_enabled(&self, transitions_enabled: bool) { 712 unsafe { 713 ffi::gtk_popover_set_transitions_enabled( 714 self.as_ref().to_glib_none().0, 715 transitions_enabled.into_glib(), 716 ); 717 } 718 } 719 connect_closed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId720 fn connect_closed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 721 unsafe extern "C" fn closed_trampoline<P: IsA<Popover>, F: Fn(&P) + 'static>( 722 this: *mut ffi::GtkPopover, 723 f: glib::ffi::gpointer, 724 ) { 725 let f: &F = &*(f as *const F); 726 f(Popover::from_glib_borrow(this).unsafe_cast_ref()) 727 } 728 unsafe { 729 let f: Box_<F> = Box_::new(f); 730 connect_raw( 731 self.as_ptr() as *mut _, 732 b"closed\0".as_ptr() as *const _, 733 Some(transmute::<_, unsafe extern "C" fn()>( 734 closed_trampoline::<Self, F> as *const (), 735 )), 736 Box_::into_raw(f), 737 ) 738 } 739 } 740 741 #[cfg(any(feature = "v3_20", feature = "dox"))] 742 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] connect_constrain_to_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId743 fn connect_constrain_to_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 744 unsafe extern "C" fn notify_constrain_to_trampoline< 745 P: IsA<Popover>, 746 F: Fn(&P) + 'static, 747 >( 748 this: *mut ffi::GtkPopover, 749 _param_spec: glib::ffi::gpointer, 750 f: glib::ffi::gpointer, 751 ) { 752 let f: &F = &*(f as *const F); 753 f(Popover::from_glib_borrow(this).unsafe_cast_ref()) 754 } 755 unsafe { 756 let f: Box_<F> = Box_::new(f); 757 connect_raw( 758 self.as_ptr() as *mut _, 759 b"notify::constrain-to\0".as_ptr() as *const _, 760 Some(transmute::<_, unsafe extern "C" fn()>( 761 notify_constrain_to_trampoline::<Self, F> as *const (), 762 )), 763 Box_::into_raw(f), 764 ) 765 } 766 } 767 connect_modal_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId768 fn connect_modal_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 769 unsafe extern "C" fn notify_modal_trampoline<P: IsA<Popover>, F: Fn(&P) + 'static>( 770 this: *mut ffi::GtkPopover, 771 _param_spec: glib::ffi::gpointer, 772 f: glib::ffi::gpointer, 773 ) { 774 let f: &F = &*(f as *const F); 775 f(Popover::from_glib_borrow(this).unsafe_cast_ref()) 776 } 777 unsafe { 778 let f: Box_<F> = Box_::new(f); 779 connect_raw( 780 self.as_ptr() as *mut _, 781 b"notify::modal\0".as_ptr() as *const _, 782 Some(transmute::<_, unsafe extern "C" fn()>( 783 notify_modal_trampoline::<Self, F> as *const (), 784 )), 785 Box_::into_raw(f), 786 ) 787 } 788 } 789 connect_pointing_to_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId790 fn connect_pointing_to_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 791 unsafe extern "C" fn notify_pointing_to_trampoline<P: IsA<Popover>, F: Fn(&P) + 'static>( 792 this: *mut ffi::GtkPopover, 793 _param_spec: glib::ffi::gpointer, 794 f: glib::ffi::gpointer, 795 ) { 796 let f: &F = &*(f as *const F); 797 f(Popover::from_glib_borrow(this).unsafe_cast_ref()) 798 } 799 unsafe { 800 let f: Box_<F> = Box_::new(f); 801 connect_raw( 802 self.as_ptr() as *mut _, 803 b"notify::pointing-to\0".as_ptr() as *const _, 804 Some(transmute::<_, unsafe extern "C" fn()>( 805 notify_pointing_to_trampoline::<Self, F> as *const (), 806 )), 807 Box_::into_raw(f), 808 ) 809 } 810 } 811 connect_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId812 fn connect_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 813 unsafe extern "C" fn notify_position_trampoline<P: IsA<Popover>, F: Fn(&P) + 'static>( 814 this: *mut ffi::GtkPopover, 815 _param_spec: glib::ffi::gpointer, 816 f: glib::ffi::gpointer, 817 ) { 818 let f: &F = &*(f as *const F); 819 f(Popover::from_glib_borrow(this).unsafe_cast_ref()) 820 } 821 unsafe { 822 let f: Box_<F> = Box_::new(f); 823 connect_raw( 824 self.as_ptr() as *mut _, 825 b"notify::position\0".as_ptr() as *const _, 826 Some(transmute::<_, unsafe extern "C" fn()>( 827 notify_position_trampoline::<Self, F> as *const (), 828 )), 829 Box_::into_raw(f), 830 ) 831 } 832 } 833 connect_relative_to_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId834 fn connect_relative_to_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 835 unsafe extern "C" fn notify_relative_to_trampoline<P: IsA<Popover>, F: Fn(&P) + 'static>( 836 this: *mut ffi::GtkPopover, 837 _param_spec: glib::ffi::gpointer, 838 f: glib::ffi::gpointer, 839 ) { 840 let f: &F = &*(f as *const F); 841 f(Popover::from_glib_borrow(this).unsafe_cast_ref()) 842 } 843 unsafe { 844 let f: Box_<F> = Box_::new(f); 845 connect_raw( 846 self.as_ptr() as *mut _, 847 b"notify::relative-to\0".as_ptr() as *const _, 848 Some(transmute::<_, unsafe extern "C" fn()>( 849 notify_relative_to_trampoline::<Self, F> as *const (), 850 )), 851 Box_::into_raw(f), 852 ) 853 } 854 } 855 connect_transitions_enabled_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId856 fn connect_transitions_enabled_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 857 unsafe extern "C" fn notify_transitions_enabled_trampoline< 858 P: IsA<Popover>, 859 F: Fn(&P) + 'static, 860 >( 861 this: *mut ffi::GtkPopover, 862 _param_spec: glib::ffi::gpointer, 863 f: glib::ffi::gpointer, 864 ) { 865 let f: &F = &*(f as *const F); 866 f(Popover::from_glib_borrow(this).unsafe_cast_ref()) 867 } 868 unsafe { 869 let f: Box_<F> = Box_::new(f); 870 connect_raw( 871 self.as_ptr() as *mut _, 872 b"notify::transitions-enabled\0".as_ptr() as *const _, 873 Some(transmute::<_, unsafe extern "C" fn()>( 874 notify_transitions_enabled_trampoline::<Self, F> as *const (), 875 )), 876 Box_::into_raw(f), 877 ) 878 } 879 } 880 } 881 882 impl fmt::Display for Popover { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result883 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 884 f.write_str("Popover") 885 } 886 } 887