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::BaselinePosition; 7 use crate::Box; 8 use crate::Buildable; 9 use crate::Container; 10 use crate::Orientable; 11 use crate::Orientation; 12 use crate::ResizeMode; 13 use crate::Widget; 14 use glib::object::Cast; 15 use glib::object::IsA; 16 use glib::signal::connect_raw; 17 use glib::signal::SignalHandlerId; 18 use glib::translate::*; 19 use glib::StaticType; 20 use glib::ToValue; 21 use std::boxed::Box as Box_; 22 use std::fmt; 23 use std::mem::transmute; 24 25 glib::wrapper! { 26 #[doc(alias = "GtkStatusbar")] 27 pub struct Statusbar(Object<ffi::GtkStatusbar, ffi::GtkStatusbarClass>) @extends Box, Container, Widget, @implements Buildable, Orientable; 28 29 match fn { 30 type_ => || ffi::gtk_statusbar_get_type(), 31 } 32 } 33 34 impl Statusbar { 35 #[doc(alias = "gtk_statusbar_new")] new() -> Statusbar36 pub fn new() -> Statusbar { 37 assert_initialized_main_thread!(); 38 unsafe { Widget::from_glib_none(ffi::gtk_statusbar_new()).unsafe_cast() } 39 } 40 41 // rustdoc-stripper-ignore-next 42 /// Creates a new builder-pattern struct instance to construct [`Statusbar`] objects. 43 /// 44 /// This method returns an instance of [`StatusbarBuilder`] which can be used to create [`Statusbar`] objects. builder() -> StatusbarBuilder45 pub fn builder() -> StatusbarBuilder { 46 StatusbarBuilder::default() 47 } 48 } 49 50 impl Default for Statusbar { default() -> Self51 fn default() -> Self { 52 Self::new() 53 } 54 } 55 56 #[derive(Clone, Default)] 57 // rustdoc-stripper-ignore-next 58 /// A [builder-pattern] type to construct [`Statusbar`] objects. 59 /// 60 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html 61 pub struct StatusbarBuilder { 62 baseline_position: Option<BaselinePosition>, 63 homogeneous: Option<bool>, 64 spacing: Option<i32>, 65 border_width: Option<u32>, 66 child: Option<Widget>, 67 resize_mode: Option<ResizeMode>, 68 app_paintable: Option<bool>, 69 can_default: Option<bool>, 70 can_focus: Option<bool>, 71 events: Option<gdk::EventMask>, 72 expand: Option<bool>, 73 #[cfg(any(feature = "v3_20", feature = "dox"))] 74 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] 75 focus_on_click: Option<bool>, 76 halign: Option<Align>, 77 has_default: Option<bool>, 78 has_focus: Option<bool>, 79 has_tooltip: Option<bool>, 80 height_request: Option<i32>, 81 hexpand: Option<bool>, 82 hexpand_set: Option<bool>, 83 is_focus: Option<bool>, 84 margin: Option<i32>, 85 margin_bottom: Option<i32>, 86 margin_end: Option<i32>, 87 margin_start: Option<i32>, 88 margin_top: Option<i32>, 89 name: Option<String>, 90 no_show_all: Option<bool>, 91 opacity: Option<f64>, 92 parent: Option<Container>, 93 receives_default: Option<bool>, 94 sensitive: Option<bool>, 95 tooltip_markup: Option<String>, 96 tooltip_text: Option<String>, 97 valign: Option<Align>, 98 vexpand: Option<bool>, 99 vexpand_set: Option<bool>, 100 visible: Option<bool>, 101 width_request: Option<i32>, 102 orientation: Option<Orientation>, 103 } 104 105 impl StatusbarBuilder { 106 // rustdoc-stripper-ignore-next 107 /// Create a new [`StatusbarBuilder`]. new() -> Self108 pub fn new() -> Self { 109 Self::default() 110 } 111 112 // rustdoc-stripper-ignore-next 113 /// Build the [`Statusbar`]. build(self) -> Statusbar114 pub fn build(self) -> Statusbar { 115 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 116 if let Some(ref baseline_position) = self.baseline_position { 117 properties.push(("baseline-position", baseline_position)); 118 } 119 if let Some(ref homogeneous) = self.homogeneous { 120 properties.push(("homogeneous", homogeneous)); 121 } 122 if let Some(ref spacing) = self.spacing { 123 properties.push(("spacing", spacing)); 124 } 125 if let Some(ref border_width) = self.border_width { 126 properties.push(("border-width", border_width)); 127 } 128 if let Some(ref child) = self.child { 129 properties.push(("child", child)); 130 } 131 if let Some(ref resize_mode) = self.resize_mode { 132 properties.push(("resize-mode", resize_mode)); 133 } 134 if let Some(ref app_paintable) = self.app_paintable { 135 properties.push(("app-paintable", app_paintable)); 136 } 137 if let Some(ref can_default) = self.can_default { 138 properties.push(("can-default", can_default)); 139 } 140 if let Some(ref can_focus) = self.can_focus { 141 properties.push(("can-focus", can_focus)); 142 } 143 if let Some(ref events) = self.events { 144 properties.push(("events", events)); 145 } 146 if let Some(ref expand) = self.expand { 147 properties.push(("expand", expand)); 148 } 149 #[cfg(any(feature = "v3_20", feature = "dox"))] 150 if let Some(ref focus_on_click) = self.focus_on_click { 151 properties.push(("focus-on-click", focus_on_click)); 152 } 153 if let Some(ref halign) = self.halign { 154 properties.push(("halign", halign)); 155 } 156 if let Some(ref has_default) = self.has_default { 157 properties.push(("has-default", has_default)); 158 } 159 if let Some(ref has_focus) = self.has_focus { 160 properties.push(("has-focus", has_focus)); 161 } 162 if let Some(ref has_tooltip) = self.has_tooltip { 163 properties.push(("has-tooltip", has_tooltip)); 164 } 165 if let Some(ref height_request) = self.height_request { 166 properties.push(("height-request", height_request)); 167 } 168 if let Some(ref hexpand) = self.hexpand { 169 properties.push(("hexpand", hexpand)); 170 } 171 if let Some(ref hexpand_set) = self.hexpand_set { 172 properties.push(("hexpand-set", hexpand_set)); 173 } 174 if let Some(ref is_focus) = self.is_focus { 175 properties.push(("is-focus", is_focus)); 176 } 177 if let Some(ref margin) = self.margin { 178 properties.push(("margin", margin)); 179 } 180 if let Some(ref margin_bottom) = self.margin_bottom { 181 properties.push(("margin-bottom", margin_bottom)); 182 } 183 if let Some(ref margin_end) = self.margin_end { 184 properties.push(("margin-end", margin_end)); 185 } 186 if let Some(ref margin_start) = self.margin_start { 187 properties.push(("margin-start", margin_start)); 188 } 189 if let Some(ref margin_top) = self.margin_top { 190 properties.push(("margin-top", margin_top)); 191 } 192 if let Some(ref name) = self.name { 193 properties.push(("name", name)); 194 } 195 if let Some(ref no_show_all) = self.no_show_all { 196 properties.push(("no-show-all", no_show_all)); 197 } 198 if let Some(ref opacity) = self.opacity { 199 properties.push(("opacity", opacity)); 200 } 201 if let Some(ref parent) = self.parent { 202 properties.push(("parent", parent)); 203 } 204 if let Some(ref receives_default) = self.receives_default { 205 properties.push(("receives-default", receives_default)); 206 } 207 if let Some(ref sensitive) = self.sensitive { 208 properties.push(("sensitive", sensitive)); 209 } 210 if let Some(ref tooltip_markup) = self.tooltip_markup { 211 properties.push(("tooltip-markup", tooltip_markup)); 212 } 213 if let Some(ref tooltip_text) = self.tooltip_text { 214 properties.push(("tooltip-text", tooltip_text)); 215 } 216 if let Some(ref valign) = self.valign { 217 properties.push(("valign", valign)); 218 } 219 if let Some(ref vexpand) = self.vexpand { 220 properties.push(("vexpand", vexpand)); 221 } 222 if let Some(ref vexpand_set) = self.vexpand_set { 223 properties.push(("vexpand-set", vexpand_set)); 224 } 225 if let Some(ref visible) = self.visible { 226 properties.push(("visible", visible)); 227 } 228 if let Some(ref width_request) = self.width_request { 229 properties.push(("width-request", width_request)); 230 } 231 if let Some(ref orientation) = self.orientation { 232 properties.push(("orientation", orientation)); 233 } 234 glib::Object::new::<Statusbar>(&properties) 235 .expect("Failed to create an instance of Statusbar") 236 } 237 baseline_position(mut self, baseline_position: BaselinePosition) -> Self238 pub fn baseline_position(mut self, baseline_position: BaselinePosition) -> Self { 239 self.baseline_position = Some(baseline_position); 240 self 241 } 242 homogeneous(mut self, homogeneous: bool) -> Self243 pub fn homogeneous(mut self, homogeneous: bool) -> Self { 244 self.homogeneous = Some(homogeneous); 245 self 246 } 247 spacing(mut self, spacing: i32) -> Self248 pub fn spacing(mut self, spacing: i32) -> Self { 249 self.spacing = Some(spacing); 250 self 251 } 252 border_width(mut self, border_width: u32) -> Self253 pub fn border_width(mut self, border_width: u32) -> Self { 254 self.border_width = Some(border_width); 255 self 256 } 257 child<P: IsA<Widget>>(mut self, child: &P) -> Self258 pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self { 259 self.child = Some(child.clone().upcast()); 260 self 261 } 262 resize_mode(mut self, resize_mode: ResizeMode) -> Self263 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { 264 self.resize_mode = Some(resize_mode); 265 self 266 } 267 app_paintable(mut self, app_paintable: bool) -> Self268 pub fn app_paintable(mut self, app_paintable: bool) -> Self { 269 self.app_paintable = Some(app_paintable); 270 self 271 } 272 can_default(mut self, can_default: bool) -> Self273 pub fn can_default(mut self, can_default: bool) -> Self { 274 self.can_default = Some(can_default); 275 self 276 } 277 can_focus(mut self, can_focus: bool) -> Self278 pub fn can_focus(mut self, can_focus: bool) -> Self { 279 self.can_focus = Some(can_focus); 280 self 281 } 282 events(mut self, events: gdk::EventMask) -> Self283 pub fn events(mut self, events: gdk::EventMask) -> Self { 284 self.events = Some(events); 285 self 286 } 287 expand(mut self, expand: bool) -> Self288 pub fn expand(mut self, expand: bool) -> Self { 289 self.expand = Some(expand); 290 self 291 } 292 293 #[cfg(any(feature = "v3_20", feature = "dox"))] 294 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] focus_on_click(mut self, focus_on_click: bool) -> Self295 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { 296 self.focus_on_click = Some(focus_on_click); 297 self 298 } 299 halign(mut self, halign: Align) -> Self300 pub fn halign(mut self, halign: Align) -> Self { 301 self.halign = Some(halign); 302 self 303 } 304 has_default(mut self, has_default: bool) -> Self305 pub fn has_default(mut self, has_default: bool) -> Self { 306 self.has_default = Some(has_default); 307 self 308 } 309 has_focus(mut self, has_focus: bool) -> Self310 pub fn has_focus(mut self, has_focus: bool) -> Self { 311 self.has_focus = Some(has_focus); 312 self 313 } 314 has_tooltip(mut self, has_tooltip: bool) -> Self315 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { 316 self.has_tooltip = Some(has_tooltip); 317 self 318 } 319 height_request(mut self, height_request: i32) -> Self320 pub fn height_request(mut self, height_request: i32) -> Self { 321 self.height_request = Some(height_request); 322 self 323 } 324 hexpand(mut self, hexpand: bool) -> Self325 pub fn hexpand(mut self, hexpand: bool) -> Self { 326 self.hexpand = Some(hexpand); 327 self 328 } 329 hexpand_set(mut self, hexpand_set: bool) -> Self330 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { 331 self.hexpand_set = Some(hexpand_set); 332 self 333 } 334 is_focus(mut self, is_focus: bool) -> Self335 pub fn is_focus(mut self, is_focus: bool) -> Self { 336 self.is_focus = Some(is_focus); 337 self 338 } 339 margin(mut self, margin: i32) -> Self340 pub fn margin(mut self, margin: i32) -> Self { 341 self.margin = Some(margin); 342 self 343 } 344 margin_bottom(mut self, margin_bottom: i32) -> Self345 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { 346 self.margin_bottom = Some(margin_bottom); 347 self 348 } 349 margin_end(mut self, margin_end: i32) -> Self350 pub fn margin_end(mut self, margin_end: i32) -> Self { 351 self.margin_end = Some(margin_end); 352 self 353 } 354 margin_start(mut self, margin_start: i32) -> Self355 pub fn margin_start(mut self, margin_start: i32) -> Self { 356 self.margin_start = Some(margin_start); 357 self 358 } 359 margin_top(mut self, margin_top: i32) -> Self360 pub fn margin_top(mut self, margin_top: i32) -> Self { 361 self.margin_top = Some(margin_top); 362 self 363 } 364 name(mut self, name: &str) -> Self365 pub fn name(mut self, name: &str) -> Self { 366 self.name = Some(name.to_string()); 367 self 368 } 369 no_show_all(mut self, no_show_all: bool) -> Self370 pub fn no_show_all(mut self, no_show_all: bool) -> Self { 371 self.no_show_all = Some(no_show_all); 372 self 373 } 374 opacity(mut self, opacity: f64) -> Self375 pub fn opacity(mut self, opacity: f64) -> Self { 376 self.opacity = Some(opacity); 377 self 378 } 379 parent<P: IsA<Container>>(mut self, parent: &P) -> Self380 pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self { 381 self.parent = Some(parent.clone().upcast()); 382 self 383 } 384 receives_default(mut self, receives_default: bool) -> Self385 pub fn receives_default(mut self, receives_default: bool) -> Self { 386 self.receives_default = Some(receives_default); 387 self 388 } 389 sensitive(mut self, sensitive: bool) -> Self390 pub fn sensitive(mut self, sensitive: bool) -> Self { 391 self.sensitive = Some(sensitive); 392 self 393 } 394 tooltip_markup(mut self, tooltip_markup: &str) -> Self395 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { 396 self.tooltip_markup = Some(tooltip_markup.to_string()); 397 self 398 } 399 tooltip_text(mut self, tooltip_text: &str) -> Self400 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { 401 self.tooltip_text = Some(tooltip_text.to_string()); 402 self 403 } 404 valign(mut self, valign: Align) -> Self405 pub fn valign(mut self, valign: Align) -> Self { 406 self.valign = Some(valign); 407 self 408 } 409 vexpand(mut self, vexpand: bool) -> Self410 pub fn vexpand(mut self, vexpand: bool) -> Self { 411 self.vexpand = Some(vexpand); 412 self 413 } 414 vexpand_set(mut self, vexpand_set: bool) -> Self415 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { 416 self.vexpand_set = Some(vexpand_set); 417 self 418 } 419 visible(mut self, visible: bool) -> Self420 pub fn visible(mut self, visible: bool) -> Self { 421 self.visible = Some(visible); 422 self 423 } 424 width_request(mut self, width_request: i32) -> Self425 pub fn width_request(mut self, width_request: i32) -> Self { 426 self.width_request = Some(width_request); 427 self 428 } 429 orientation(mut self, orientation: Orientation) -> Self430 pub fn orientation(mut self, orientation: Orientation) -> Self { 431 self.orientation = Some(orientation); 432 self 433 } 434 } 435 436 pub const NONE_STATUSBAR: Option<&Statusbar> = None; 437 438 pub trait StatusbarExt: 'static { 439 #[doc(alias = "gtk_statusbar_get_context_id")] 440 #[doc(alias = "get_context_id")] context_id(&self, context_description: &str) -> u32441 fn context_id(&self, context_description: &str) -> u32; 442 443 #[doc(alias = "gtk_statusbar_get_message_area")] 444 #[doc(alias = "get_message_area")] message_area(&self) -> Option<Box>445 fn message_area(&self) -> Option<Box>; 446 447 #[doc(alias = "gtk_statusbar_pop")] pop(&self, context_id: u32)448 fn pop(&self, context_id: u32); 449 450 #[doc(alias = "gtk_statusbar_push")] push(&self, context_id: u32, text: &str) -> u32451 fn push(&self, context_id: u32, text: &str) -> u32; 452 453 #[doc(alias = "gtk_statusbar_remove")] remove(&self, context_id: u32, message_id: u32)454 fn remove(&self, context_id: u32, message_id: u32); 455 456 #[doc(alias = "gtk_statusbar_remove_all")] remove_all(&self, context_id: u32)457 fn remove_all(&self, context_id: u32); 458 459 #[doc(alias = "text-popped")] connect_text_popped<F: Fn(&Self, u32, &str) + 'static>(&self, f: F) -> SignalHandlerId460 fn connect_text_popped<F: Fn(&Self, u32, &str) + 'static>(&self, f: F) -> SignalHandlerId; 461 462 #[doc(alias = "text-pushed")] connect_text_pushed<F: Fn(&Self, u32, &str) + 'static>(&self, f: F) -> SignalHandlerId463 fn connect_text_pushed<F: Fn(&Self, u32, &str) + 'static>(&self, f: F) -> SignalHandlerId; 464 } 465 466 impl<O: IsA<Statusbar>> StatusbarExt for O { context_id(&self, context_description: &str) -> u32467 fn context_id(&self, context_description: &str) -> u32 { 468 unsafe { 469 ffi::gtk_statusbar_get_context_id( 470 self.as_ref().to_glib_none().0, 471 context_description.to_glib_none().0, 472 ) 473 } 474 } 475 message_area(&self) -> Option<Box>476 fn message_area(&self) -> Option<Box> { 477 unsafe { 478 from_glib_none(ffi::gtk_statusbar_get_message_area( 479 self.as_ref().to_glib_none().0, 480 )) 481 } 482 } 483 pop(&self, context_id: u32)484 fn pop(&self, context_id: u32) { 485 unsafe { 486 ffi::gtk_statusbar_pop(self.as_ref().to_glib_none().0, context_id); 487 } 488 } 489 push(&self, context_id: u32, text: &str) -> u32490 fn push(&self, context_id: u32, text: &str) -> u32 { 491 unsafe { 492 ffi::gtk_statusbar_push( 493 self.as_ref().to_glib_none().0, 494 context_id, 495 text.to_glib_none().0, 496 ) 497 } 498 } 499 remove(&self, context_id: u32, message_id: u32)500 fn remove(&self, context_id: u32, message_id: u32) { 501 unsafe { 502 ffi::gtk_statusbar_remove(self.as_ref().to_glib_none().0, context_id, message_id); 503 } 504 } 505 remove_all(&self, context_id: u32)506 fn remove_all(&self, context_id: u32) { 507 unsafe { 508 ffi::gtk_statusbar_remove_all(self.as_ref().to_glib_none().0, context_id); 509 } 510 } 511 connect_text_popped<F: Fn(&Self, u32, &str) + 'static>(&self, f: F) -> SignalHandlerId512 fn connect_text_popped<F: Fn(&Self, u32, &str) + 'static>(&self, f: F) -> SignalHandlerId { 513 unsafe extern "C" fn text_popped_trampoline< 514 P: IsA<Statusbar>, 515 F: Fn(&P, u32, &str) + 'static, 516 >( 517 this: *mut ffi::GtkStatusbar, 518 context_id: libc::c_uint, 519 text: *mut libc::c_char, 520 f: glib::ffi::gpointer, 521 ) { 522 let f: &F = &*(f as *const F); 523 f( 524 Statusbar::from_glib_borrow(this).unsafe_cast_ref(), 525 context_id, 526 &glib::GString::from_glib_borrow(text), 527 ) 528 } 529 unsafe { 530 let f: Box_<F> = Box_::new(f); 531 connect_raw( 532 self.as_ptr() as *mut _, 533 b"text-popped\0".as_ptr() as *const _, 534 Some(transmute::<_, unsafe extern "C" fn()>( 535 text_popped_trampoline::<Self, F> as *const (), 536 )), 537 Box_::into_raw(f), 538 ) 539 } 540 } 541 connect_text_pushed<F: Fn(&Self, u32, &str) + 'static>(&self, f: F) -> SignalHandlerId542 fn connect_text_pushed<F: Fn(&Self, u32, &str) + 'static>(&self, f: F) -> SignalHandlerId { 543 unsafe extern "C" fn text_pushed_trampoline< 544 P: IsA<Statusbar>, 545 F: Fn(&P, u32, &str) + 'static, 546 >( 547 this: *mut ffi::GtkStatusbar, 548 context_id: libc::c_uint, 549 text: *mut libc::c_char, 550 f: glib::ffi::gpointer, 551 ) { 552 let f: &F = &*(f as *const F); 553 f( 554 Statusbar::from_glib_borrow(this).unsafe_cast_ref(), 555 context_id, 556 &glib::GString::from_glib_borrow(text), 557 ) 558 } 559 unsafe { 560 let f: Box_<F> = Box_::new(f); 561 connect_raw( 562 self.as_ptr() as *mut _, 563 b"text-pushed\0".as_ptr() as *const _, 564 Some(transmute::<_, unsafe extern "C" fn()>( 565 text_pushed_trampoline::<Self, F> as *const (), 566 )), 567 Box_::into_raw(f), 568 ) 569 } 570 } 571 } 572 573 impl fmt::Display for Statusbar { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result574 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 575 f.write_str("Statusbar") 576 } 577 } 578