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 gdk; 6 use glib::object::Cast; 7 use glib::object::IsA; 8 use glib::signal::connect_raw; 9 use glib::signal::SignalHandlerId; 10 use glib::translate::*; 11 use glib::GString; 12 use glib::StaticType; 13 use glib::ToValue; 14 use glib_sys; 15 use gtk_sys; 16 use libc; 17 use std::boxed::Box as Box_; 18 use std::fmt; 19 use std::mem::transmute; 20 use Align; 21 use BaselinePosition; 22 use Box; 23 use Buildable; 24 use Container; 25 use Orientable; 26 use ResizeMode; 27 use Widget; 28 29 glib_wrapper! { 30 pub struct Statusbar(Object<gtk_sys::GtkStatusbar, gtk_sys::GtkStatusbarClass, StatusbarClass>) @extends Box, Container, Widget, @implements Buildable, Orientable; 31 32 match fn { 33 get_type => || gtk_sys::gtk_statusbar_get_type(), 34 } 35 } 36 37 impl Statusbar { new() -> Statusbar38 pub fn new() -> Statusbar { 39 assert_initialized_main_thread!(); 40 unsafe { Widget::from_glib_none(gtk_sys::gtk_statusbar_new()).unsafe_cast() } 41 } 42 } 43 44 impl Default for Statusbar { default() -> Self45 fn default() -> Self { 46 Self::new() 47 } 48 } 49 50 pub struct StatusbarBuilder { 51 baseline_position: Option<BaselinePosition>, 52 homogeneous: Option<bool>, 53 spacing: Option<i32>, 54 border_width: Option<u32>, 55 child: Option<Widget>, 56 resize_mode: Option<ResizeMode>, 57 app_paintable: Option<bool>, 58 can_default: Option<bool>, 59 can_focus: Option<bool>, 60 events: Option<gdk::EventMask>, 61 expand: Option<bool>, 62 #[cfg(any(feature = "v3_20", feature = "dox"))] 63 focus_on_click: Option<bool>, 64 halign: Option<Align>, 65 has_default: Option<bool>, 66 has_focus: Option<bool>, 67 has_tooltip: Option<bool>, 68 height_request: Option<i32>, 69 hexpand: Option<bool>, 70 hexpand_set: Option<bool>, 71 is_focus: Option<bool>, 72 margin: Option<i32>, 73 margin_bottom: Option<i32>, 74 margin_end: Option<i32>, 75 margin_start: Option<i32>, 76 margin_top: Option<i32>, 77 name: Option<String>, 78 no_show_all: Option<bool>, 79 opacity: Option<f64>, 80 parent: Option<Container>, 81 receives_default: Option<bool>, 82 sensitive: Option<bool>, 83 //style: /*Unknown type*/, 84 tooltip_markup: Option<String>, 85 tooltip_text: Option<String>, 86 valign: Option<Align>, 87 vexpand: Option<bool>, 88 vexpand_set: Option<bool>, 89 visible: Option<bool>, 90 width_request: Option<i32>, 91 } 92 93 impl StatusbarBuilder { new() -> Self94 pub fn new() -> Self { 95 Self { 96 baseline_position: None, 97 homogeneous: None, 98 spacing: None, 99 border_width: None, 100 child: None, 101 resize_mode: None, 102 app_paintable: None, 103 can_default: None, 104 can_focus: None, 105 events: None, 106 expand: None, 107 #[cfg(any(feature = "v3_20", feature = "dox"))] 108 focus_on_click: None, 109 halign: None, 110 has_default: None, 111 has_focus: None, 112 has_tooltip: None, 113 height_request: None, 114 hexpand: None, 115 hexpand_set: None, 116 is_focus: None, 117 margin: None, 118 margin_bottom: None, 119 margin_end: None, 120 margin_start: None, 121 margin_top: None, 122 name: None, 123 no_show_all: None, 124 opacity: None, 125 parent: None, 126 receives_default: None, 127 sensitive: None, 128 tooltip_markup: None, 129 tooltip_text: None, 130 valign: None, 131 vexpand: None, 132 vexpand_set: None, 133 visible: None, 134 width_request: None, 135 } 136 } 137 build(self) -> Statusbar138 pub fn build(self) -> Statusbar { 139 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 140 if let Some(ref baseline_position) = self.baseline_position { 141 properties.push(("baseline-position", baseline_position)); 142 } 143 if let Some(ref homogeneous) = self.homogeneous { 144 properties.push(("homogeneous", homogeneous)); 145 } 146 if let Some(ref spacing) = self.spacing { 147 properties.push(("spacing", spacing)); 148 } 149 if let Some(ref border_width) = self.border_width { 150 properties.push(("border-width", border_width)); 151 } 152 if let Some(ref child) = self.child { 153 properties.push(("child", child)); 154 } 155 if let Some(ref resize_mode) = self.resize_mode { 156 properties.push(("resize-mode", resize_mode)); 157 } 158 if let Some(ref app_paintable) = self.app_paintable { 159 properties.push(("app-paintable", app_paintable)); 160 } 161 if let Some(ref can_default) = self.can_default { 162 properties.push(("can-default", can_default)); 163 } 164 if let Some(ref can_focus) = self.can_focus { 165 properties.push(("can-focus", can_focus)); 166 } 167 if let Some(ref events) = self.events { 168 properties.push(("events", events)); 169 } 170 if let Some(ref expand) = self.expand { 171 properties.push(("expand", expand)); 172 } 173 #[cfg(any(feature = "v3_20", feature = "dox"))] 174 { 175 if let Some(ref focus_on_click) = self.focus_on_click { 176 properties.push(("focus-on-click", focus_on_click)); 177 } 178 } 179 if let Some(ref halign) = self.halign { 180 properties.push(("halign", halign)); 181 } 182 if let Some(ref has_default) = self.has_default { 183 properties.push(("has-default", has_default)); 184 } 185 if let Some(ref has_focus) = self.has_focus { 186 properties.push(("has-focus", has_focus)); 187 } 188 if let Some(ref has_tooltip) = self.has_tooltip { 189 properties.push(("has-tooltip", has_tooltip)); 190 } 191 if let Some(ref height_request) = self.height_request { 192 properties.push(("height-request", height_request)); 193 } 194 if let Some(ref hexpand) = self.hexpand { 195 properties.push(("hexpand", hexpand)); 196 } 197 if let Some(ref hexpand_set) = self.hexpand_set { 198 properties.push(("hexpand-set", hexpand_set)); 199 } 200 if let Some(ref is_focus) = self.is_focus { 201 properties.push(("is-focus", is_focus)); 202 } 203 if let Some(ref margin) = self.margin { 204 properties.push(("margin", margin)); 205 } 206 if let Some(ref margin_bottom) = self.margin_bottom { 207 properties.push(("margin-bottom", margin_bottom)); 208 } 209 if let Some(ref margin_end) = self.margin_end { 210 properties.push(("margin-end", margin_end)); 211 } 212 if let Some(ref margin_start) = self.margin_start { 213 properties.push(("margin-start", margin_start)); 214 } 215 if let Some(ref margin_top) = self.margin_top { 216 properties.push(("margin-top", margin_top)); 217 } 218 if let Some(ref name) = self.name { 219 properties.push(("name", name)); 220 } 221 if let Some(ref no_show_all) = self.no_show_all { 222 properties.push(("no-show-all", no_show_all)); 223 } 224 if let Some(ref opacity) = self.opacity { 225 properties.push(("opacity", opacity)); 226 } 227 if let Some(ref parent) = self.parent { 228 properties.push(("parent", parent)); 229 } 230 if let Some(ref receives_default) = self.receives_default { 231 properties.push(("receives-default", receives_default)); 232 } 233 if let Some(ref sensitive) = self.sensitive { 234 properties.push(("sensitive", sensitive)); 235 } 236 if let Some(ref tooltip_markup) = self.tooltip_markup { 237 properties.push(("tooltip-markup", tooltip_markup)); 238 } 239 if let Some(ref tooltip_text) = self.tooltip_text { 240 properties.push(("tooltip-text", tooltip_text)); 241 } 242 if let Some(ref valign) = self.valign { 243 properties.push(("valign", valign)); 244 } 245 if let Some(ref vexpand) = self.vexpand { 246 properties.push(("vexpand", vexpand)); 247 } 248 if let Some(ref vexpand_set) = self.vexpand_set { 249 properties.push(("vexpand-set", vexpand_set)); 250 } 251 if let Some(ref visible) = self.visible { 252 properties.push(("visible", visible)); 253 } 254 if let Some(ref width_request) = self.width_request { 255 properties.push(("width-request", width_request)); 256 } 257 glib::Object::new(Statusbar::static_type(), &properties) 258 .expect("object new") 259 .downcast() 260 .expect("downcast") 261 } 262 baseline_position(mut self, baseline_position: BaselinePosition) -> Self263 pub fn baseline_position(mut self, baseline_position: BaselinePosition) -> Self { 264 self.baseline_position = Some(baseline_position); 265 self 266 } 267 homogeneous(mut self, homogeneous: bool) -> Self268 pub fn homogeneous(mut self, homogeneous: bool) -> Self { 269 self.homogeneous = Some(homogeneous); 270 self 271 } 272 spacing(mut self, spacing: i32) -> Self273 pub fn spacing(mut self, spacing: i32) -> Self { 274 self.spacing = Some(spacing); 275 self 276 } 277 border_width(mut self, border_width: u32) -> Self278 pub fn border_width(mut self, border_width: u32) -> Self { 279 self.border_width = Some(border_width); 280 self 281 } 282 child(mut self, child: &Widget) -> Self283 pub fn child(mut self, child: &Widget) -> Self { 284 self.child = Some(child.clone()); 285 self 286 } 287 resize_mode(mut self, resize_mode: ResizeMode) -> Self288 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { 289 self.resize_mode = Some(resize_mode); 290 self 291 } 292 app_paintable(mut self, app_paintable: bool) -> Self293 pub fn app_paintable(mut self, app_paintable: bool) -> Self { 294 self.app_paintable = Some(app_paintable); 295 self 296 } 297 can_default(mut self, can_default: bool) -> Self298 pub fn can_default(mut self, can_default: bool) -> Self { 299 self.can_default = Some(can_default); 300 self 301 } 302 can_focus(mut self, can_focus: bool) -> Self303 pub fn can_focus(mut self, can_focus: bool) -> Self { 304 self.can_focus = Some(can_focus); 305 self 306 } 307 events(mut self, events: gdk::EventMask) -> Self308 pub fn events(mut self, events: gdk::EventMask) -> Self { 309 self.events = Some(events); 310 self 311 } 312 expand(mut self, expand: bool) -> Self313 pub fn expand(mut self, expand: bool) -> Self { 314 self.expand = Some(expand); 315 self 316 } 317 318 #[cfg(any(feature = "v3_20", feature = "dox"))] focus_on_click(mut self, focus_on_click: bool) -> Self319 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { 320 self.focus_on_click = Some(focus_on_click); 321 self 322 } 323 halign(mut self, halign: Align) -> Self324 pub fn halign(mut self, halign: Align) -> Self { 325 self.halign = Some(halign); 326 self 327 } 328 has_default(mut self, has_default: bool) -> Self329 pub fn has_default(mut self, has_default: bool) -> Self { 330 self.has_default = Some(has_default); 331 self 332 } 333 has_focus(mut self, has_focus: bool) -> Self334 pub fn has_focus(mut self, has_focus: bool) -> Self { 335 self.has_focus = Some(has_focus); 336 self 337 } 338 has_tooltip(mut self, has_tooltip: bool) -> Self339 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { 340 self.has_tooltip = Some(has_tooltip); 341 self 342 } 343 height_request(mut self, height_request: i32) -> Self344 pub fn height_request(mut self, height_request: i32) -> Self { 345 self.height_request = Some(height_request); 346 self 347 } 348 hexpand(mut self, hexpand: bool) -> Self349 pub fn hexpand(mut self, hexpand: bool) -> Self { 350 self.hexpand = Some(hexpand); 351 self 352 } 353 hexpand_set(mut self, hexpand_set: bool) -> Self354 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { 355 self.hexpand_set = Some(hexpand_set); 356 self 357 } 358 is_focus(mut self, is_focus: bool) -> Self359 pub fn is_focus(mut self, is_focus: bool) -> Self { 360 self.is_focus = Some(is_focus); 361 self 362 } 363 margin(mut self, margin: i32) -> Self364 pub fn margin(mut self, margin: i32) -> Self { 365 self.margin = Some(margin); 366 self 367 } 368 margin_bottom(mut self, margin_bottom: i32) -> Self369 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { 370 self.margin_bottom = Some(margin_bottom); 371 self 372 } 373 margin_end(mut self, margin_end: i32) -> Self374 pub fn margin_end(mut self, margin_end: i32) -> Self { 375 self.margin_end = Some(margin_end); 376 self 377 } 378 margin_start(mut self, margin_start: i32) -> Self379 pub fn margin_start(mut self, margin_start: i32) -> Self { 380 self.margin_start = Some(margin_start); 381 self 382 } 383 margin_top(mut self, margin_top: i32) -> Self384 pub fn margin_top(mut self, margin_top: i32) -> Self { 385 self.margin_top = Some(margin_top); 386 self 387 } 388 name(mut self, name: &str) -> Self389 pub fn name(mut self, name: &str) -> Self { 390 self.name = Some(name.to_string()); 391 self 392 } 393 no_show_all(mut self, no_show_all: bool) -> Self394 pub fn no_show_all(mut self, no_show_all: bool) -> Self { 395 self.no_show_all = Some(no_show_all); 396 self 397 } 398 opacity(mut self, opacity: f64) -> Self399 pub fn opacity(mut self, opacity: f64) -> Self { 400 self.opacity = Some(opacity); 401 self 402 } 403 parent(mut self, parent: &Container) -> Self404 pub fn parent(mut self, parent: &Container) -> Self { 405 self.parent = Some(parent.clone()); 406 self 407 } 408 receives_default(mut self, receives_default: bool) -> Self409 pub fn receives_default(mut self, receives_default: bool) -> Self { 410 self.receives_default = Some(receives_default); 411 self 412 } 413 sensitive(mut self, sensitive: bool) -> Self414 pub fn sensitive(mut self, sensitive: bool) -> Self { 415 self.sensitive = Some(sensitive); 416 self 417 } 418 tooltip_markup(mut self, tooltip_markup: &str) -> Self419 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { 420 self.tooltip_markup = Some(tooltip_markup.to_string()); 421 self 422 } 423 tooltip_text(mut self, tooltip_text: &str) -> Self424 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { 425 self.tooltip_text = Some(tooltip_text.to_string()); 426 self 427 } 428 valign(mut self, valign: Align) -> Self429 pub fn valign(mut self, valign: Align) -> Self { 430 self.valign = Some(valign); 431 self 432 } 433 vexpand(mut self, vexpand: bool) -> Self434 pub fn vexpand(mut self, vexpand: bool) -> Self { 435 self.vexpand = Some(vexpand); 436 self 437 } 438 vexpand_set(mut self, vexpand_set: bool) -> Self439 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { 440 self.vexpand_set = Some(vexpand_set); 441 self 442 } 443 visible(mut self, visible: bool) -> Self444 pub fn visible(mut self, visible: bool) -> Self { 445 self.visible = Some(visible); 446 self 447 } 448 width_request(mut self, width_request: i32) -> Self449 pub fn width_request(mut self, width_request: i32) -> Self { 450 self.width_request = Some(width_request); 451 self 452 } 453 } 454 455 pub const NONE_STATUSBAR: Option<&Statusbar> = None; 456 457 pub trait StatusbarExt: 'static { get_context_id(&self, context_description: &str) -> u32458 fn get_context_id(&self, context_description: &str) -> u32; 459 get_message_area(&self) -> Option<Box>460 fn get_message_area(&self) -> Option<Box>; 461 pop(&self, context_id: u32)462 fn pop(&self, context_id: u32); 463 push(&self, context_id: u32, text: &str) -> u32464 fn push(&self, context_id: u32, text: &str) -> u32; 465 remove(&self, context_id: u32, message_id: u32)466 fn remove(&self, context_id: u32, message_id: u32); 467 remove_all(&self, context_id: u32)468 fn remove_all(&self, context_id: u32); 469 connect_text_popped<F: Fn(&Self, u32, &str) + 'static>(&self, f: F) -> SignalHandlerId470 fn connect_text_popped<F: Fn(&Self, u32, &str) + 'static>(&self, f: F) -> SignalHandlerId; 471 connect_text_pushed<F: Fn(&Self, u32, &str) + 'static>(&self, f: F) -> SignalHandlerId472 fn connect_text_pushed<F: Fn(&Self, u32, &str) + 'static>(&self, f: F) -> SignalHandlerId; 473 } 474 475 impl<O: IsA<Statusbar>> StatusbarExt for O { get_context_id(&self, context_description: &str) -> u32476 fn get_context_id(&self, context_description: &str) -> u32 { 477 unsafe { 478 gtk_sys::gtk_statusbar_get_context_id( 479 self.as_ref().to_glib_none().0, 480 context_description.to_glib_none().0, 481 ) 482 } 483 } 484 get_message_area(&self) -> Option<Box>485 fn get_message_area(&self) -> Option<Box> { 486 unsafe { 487 from_glib_none(gtk_sys::gtk_statusbar_get_message_area( 488 self.as_ref().to_glib_none().0, 489 )) 490 } 491 } 492 pop(&self, context_id: u32)493 fn pop(&self, context_id: u32) { 494 unsafe { 495 gtk_sys::gtk_statusbar_pop(self.as_ref().to_glib_none().0, context_id); 496 } 497 } 498 push(&self, context_id: u32, text: &str) -> u32499 fn push(&self, context_id: u32, text: &str) -> u32 { 500 unsafe { 501 gtk_sys::gtk_statusbar_push( 502 self.as_ref().to_glib_none().0, 503 context_id, 504 text.to_glib_none().0, 505 ) 506 } 507 } 508 remove(&self, context_id: u32, message_id: u32)509 fn remove(&self, context_id: u32, message_id: u32) { 510 unsafe { 511 gtk_sys::gtk_statusbar_remove(self.as_ref().to_glib_none().0, context_id, message_id); 512 } 513 } 514 remove_all(&self, context_id: u32)515 fn remove_all(&self, context_id: u32) { 516 unsafe { 517 gtk_sys::gtk_statusbar_remove_all(self.as_ref().to_glib_none().0, context_id); 518 } 519 } 520 connect_text_popped<F: Fn(&Self, u32, &str) + 'static>(&self, f: F) -> SignalHandlerId521 fn connect_text_popped<F: Fn(&Self, u32, &str) + 'static>(&self, f: F) -> SignalHandlerId { 522 unsafe extern "C" fn text_popped_trampoline<P, F: Fn(&P, u32, &str) + 'static>( 523 this: *mut gtk_sys::GtkStatusbar, 524 context_id: libc::c_uint, 525 text: *mut libc::c_char, 526 f: glib_sys::gpointer, 527 ) where 528 P: IsA<Statusbar>, 529 { 530 let f: &F = &*(f as *const F); 531 f( 532 &Statusbar::from_glib_borrow(this).unsafe_cast(), 533 context_id, 534 &GString::from_glib_borrow(text), 535 ) 536 } 537 unsafe { 538 let f: Box_<F> = Box_::new(f); 539 connect_raw( 540 self.as_ptr() as *mut _, 541 b"text-popped\0".as_ptr() as *const _, 542 Some(transmute(text_popped_trampoline::<Self, F> as usize)), 543 Box_::into_raw(f), 544 ) 545 } 546 } 547 connect_text_pushed<F: Fn(&Self, u32, &str) + 'static>(&self, f: F) -> SignalHandlerId548 fn connect_text_pushed<F: Fn(&Self, u32, &str) + 'static>(&self, f: F) -> SignalHandlerId { 549 unsafe extern "C" fn text_pushed_trampoline<P, F: Fn(&P, u32, &str) + 'static>( 550 this: *mut gtk_sys::GtkStatusbar, 551 context_id: libc::c_uint, 552 text: *mut libc::c_char, 553 f: glib_sys::gpointer, 554 ) where 555 P: IsA<Statusbar>, 556 { 557 let f: &F = &*(f as *const F); 558 f( 559 &Statusbar::from_glib_borrow(this).unsafe_cast(), 560 context_id, 561 &GString::from_glib_borrow(text), 562 ) 563 } 564 unsafe { 565 let f: Box_<F> = Box_::new(f); 566 connect_raw( 567 self.as_ptr() as *mut _, 568 b"text-pushed\0".as_ptr() as *const _, 569 Some(transmute(text_pushed_trampoline::<Self, F> as usize)), 570 Box_::into_raw(f), 571 ) 572 } 573 } 574 } 575 576 impl fmt::Display for Statusbar { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result577 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 578 write!(f, "Statusbar") 579 } 580 } 581