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::Actionable; 6 use crate::Adjustment; 7 use crate::Align; 8 use crate::Bin; 9 use crate::Buildable; 10 use crate::Button; 11 use crate::Container; 12 use crate::IconSize; 13 use crate::Orientable; 14 use crate::Orientation; 15 use crate::PositionType; 16 use crate::ReliefStyle; 17 use crate::ResizeMode; 18 use crate::ScaleButton; 19 use crate::Widget; 20 use glib::object::Cast; 21 use glib::object::IsA; 22 use glib::signal::connect_raw; 23 use glib::signal::SignalHandlerId; 24 use glib::translate::*; 25 use glib::StaticType; 26 use glib::ToValue; 27 use std::boxed::Box as Box_; 28 use std::fmt; 29 use std::mem::transmute; 30 31 glib::wrapper! { 32 #[doc(alias = "GtkVolumeButton")] 33 pub struct VolumeButton(Object<ffi::GtkVolumeButton, ffi::GtkVolumeButtonClass>) @extends ScaleButton, Button, Bin, Container, Widget, @implements Buildable, Actionable, Orientable; 34 35 match fn { 36 type_ => || ffi::gtk_volume_button_get_type(), 37 } 38 } 39 40 impl VolumeButton { 41 #[doc(alias = "gtk_volume_button_new")] new() -> VolumeButton42 pub fn new() -> VolumeButton { 43 assert_initialized_main_thread!(); 44 unsafe { Widget::from_glib_none(ffi::gtk_volume_button_new()).unsafe_cast() } 45 } 46 47 // rustdoc-stripper-ignore-next 48 /// Creates a new builder-pattern struct instance to construct [`VolumeButton`] objects. 49 /// 50 /// This method returns an instance of [`VolumeButtonBuilder`] which can be used to create [`VolumeButton`] objects. builder() -> VolumeButtonBuilder51 pub fn builder() -> VolumeButtonBuilder { 52 VolumeButtonBuilder::default() 53 } 54 } 55 56 impl Default for VolumeButton { default() -> Self57 fn default() -> Self { 58 Self::new() 59 } 60 } 61 62 #[derive(Clone, Default)] 63 // rustdoc-stripper-ignore-next 64 /// A [builder-pattern] type to construct [`VolumeButton`] objects. 65 /// 66 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html 67 pub struct VolumeButtonBuilder { 68 use_symbolic: Option<bool>, 69 adjustment: Option<Adjustment>, 70 icons: Option<Vec<String>>, 71 size: Option<IconSize>, 72 value: Option<f64>, 73 always_show_image: Option<bool>, 74 image: Option<Widget>, 75 image_position: Option<PositionType>, 76 label: Option<String>, 77 relief: Option<ReliefStyle>, 78 use_underline: Option<bool>, 79 border_width: Option<u32>, 80 child: Option<Widget>, 81 resize_mode: Option<ResizeMode>, 82 app_paintable: Option<bool>, 83 can_default: Option<bool>, 84 can_focus: Option<bool>, 85 events: Option<gdk::EventMask>, 86 expand: Option<bool>, 87 #[cfg(any(feature = "v3_20", feature = "dox"))] 88 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] 89 focus_on_click: Option<bool>, 90 halign: Option<Align>, 91 has_default: Option<bool>, 92 has_focus: Option<bool>, 93 has_tooltip: Option<bool>, 94 height_request: Option<i32>, 95 hexpand: Option<bool>, 96 hexpand_set: Option<bool>, 97 is_focus: Option<bool>, 98 margin: Option<i32>, 99 margin_bottom: Option<i32>, 100 margin_end: Option<i32>, 101 margin_start: Option<i32>, 102 margin_top: Option<i32>, 103 name: Option<String>, 104 no_show_all: Option<bool>, 105 opacity: Option<f64>, 106 parent: Option<Container>, 107 receives_default: Option<bool>, 108 sensitive: Option<bool>, 109 tooltip_markup: Option<String>, 110 tooltip_text: Option<String>, 111 valign: Option<Align>, 112 vexpand: Option<bool>, 113 vexpand_set: Option<bool>, 114 visible: Option<bool>, 115 width_request: Option<i32>, 116 action_name: Option<String>, 117 action_target: Option<glib::Variant>, 118 orientation: Option<Orientation>, 119 } 120 121 impl VolumeButtonBuilder { 122 // rustdoc-stripper-ignore-next 123 /// Create a new [`VolumeButtonBuilder`]. new() -> Self124 pub fn new() -> Self { 125 Self::default() 126 } 127 128 // rustdoc-stripper-ignore-next 129 /// Build the [`VolumeButton`]. build(self) -> VolumeButton130 pub fn build(self) -> VolumeButton { 131 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 132 if let Some(ref use_symbolic) = self.use_symbolic { 133 properties.push(("use-symbolic", use_symbolic)); 134 } 135 if let Some(ref adjustment) = self.adjustment { 136 properties.push(("adjustment", adjustment)); 137 } 138 if let Some(ref icons) = self.icons { 139 properties.push(("icons", icons)); 140 } 141 if let Some(ref size) = self.size { 142 properties.push(("size", size)); 143 } 144 if let Some(ref value) = self.value { 145 properties.push(("value", value)); 146 } 147 if let Some(ref always_show_image) = self.always_show_image { 148 properties.push(("always-show-image", always_show_image)); 149 } 150 if let Some(ref image) = self.image { 151 properties.push(("image", image)); 152 } 153 if let Some(ref image_position) = self.image_position { 154 properties.push(("image-position", image_position)); 155 } 156 if let Some(ref label) = self.label { 157 properties.push(("label", label)); 158 } 159 if let Some(ref relief) = self.relief { 160 properties.push(("relief", relief)); 161 } 162 if let Some(ref use_underline) = self.use_underline { 163 properties.push(("use-underline", use_underline)); 164 } 165 if let Some(ref border_width) = self.border_width { 166 properties.push(("border-width", border_width)); 167 } 168 if let Some(ref child) = self.child { 169 properties.push(("child", child)); 170 } 171 if let Some(ref resize_mode) = self.resize_mode { 172 properties.push(("resize-mode", resize_mode)); 173 } 174 if let Some(ref app_paintable) = self.app_paintable { 175 properties.push(("app-paintable", app_paintable)); 176 } 177 if let Some(ref can_default) = self.can_default { 178 properties.push(("can-default", can_default)); 179 } 180 if let Some(ref can_focus) = self.can_focus { 181 properties.push(("can-focus", can_focus)); 182 } 183 if let Some(ref events) = self.events { 184 properties.push(("events", events)); 185 } 186 if let Some(ref expand) = self.expand { 187 properties.push(("expand", expand)); 188 } 189 #[cfg(any(feature = "v3_20", feature = "dox"))] 190 if let Some(ref focus_on_click) = self.focus_on_click { 191 properties.push(("focus-on-click", focus_on_click)); 192 } 193 if let Some(ref halign) = self.halign { 194 properties.push(("halign", halign)); 195 } 196 if let Some(ref has_default) = self.has_default { 197 properties.push(("has-default", has_default)); 198 } 199 if let Some(ref has_focus) = self.has_focus { 200 properties.push(("has-focus", has_focus)); 201 } 202 if let Some(ref has_tooltip) = self.has_tooltip { 203 properties.push(("has-tooltip", has_tooltip)); 204 } 205 if let Some(ref height_request) = self.height_request { 206 properties.push(("height-request", height_request)); 207 } 208 if let Some(ref hexpand) = self.hexpand { 209 properties.push(("hexpand", hexpand)); 210 } 211 if let Some(ref hexpand_set) = self.hexpand_set { 212 properties.push(("hexpand-set", hexpand_set)); 213 } 214 if let Some(ref is_focus) = self.is_focus { 215 properties.push(("is-focus", is_focus)); 216 } 217 if let Some(ref margin) = self.margin { 218 properties.push(("margin", margin)); 219 } 220 if let Some(ref margin_bottom) = self.margin_bottom { 221 properties.push(("margin-bottom", margin_bottom)); 222 } 223 if let Some(ref margin_end) = self.margin_end { 224 properties.push(("margin-end", margin_end)); 225 } 226 if let Some(ref margin_start) = self.margin_start { 227 properties.push(("margin-start", margin_start)); 228 } 229 if let Some(ref margin_top) = self.margin_top { 230 properties.push(("margin-top", margin_top)); 231 } 232 if let Some(ref name) = self.name { 233 properties.push(("name", name)); 234 } 235 if let Some(ref no_show_all) = self.no_show_all { 236 properties.push(("no-show-all", no_show_all)); 237 } 238 if let Some(ref opacity) = self.opacity { 239 properties.push(("opacity", opacity)); 240 } 241 if let Some(ref parent) = self.parent { 242 properties.push(("parent", parent)); 243 } 244 if let Some(ref receives_default) = self.receives_default { 245 properties.push(("receives-default", receives_default)); 246 } 247 if let Some(ref sensitive) = self.sensitive { 248 properties.push(("sensitive", sensitive)); 249 } 250 if let Some(ref tooltip_markup) = self.tooltip_markup { 251 properties.push(("tooltip-markup", tooltip_markup)); 252 } 253 if let Some(ref tooltip_text) = self.tooltip_text { 254 properties.push(("tooltip-text", tooltip_text)); 255 } 256 if let Some(ref valign) = self.valign { 257 properties.push(("valign", valign)); 258 } 259 if let Some(ref vexpand) = self.vexpand { 260 properties.push(("vexpand", vexpand)); 261 } 262 if let Some(ref vexpand_set) = self.vexpand_set { 263 properties.push(("vexpand-set", vexpand_set)); 264 } 265 if let Some(ref visible) = self.visible { 266 properties.push(("visible", visible)); 267 } 268 if let Some(ref width_request) = self.width_request { 269 properties.push(("width-request", width_request)); 270 } 271 if let Some(ref action_name) = self.action_name { 272 properties.push(("action-name", action_name)); 273 } 274 if let Some(ref action_target) = self.action_target { 275 properties.push(("action-target", action_target)); 276 } 277 if let Some(ref orientation) = self.orientation { 278 properties.push(("orientation", orientation)); 279 } 280 glib::Object::new::<VolumeButton>(&properties) 281 .expect("Failed to create an instance of VolumeButton") 282 } 283 use_symbolic(mut self, use_symbolic: bool) -> Self284 pub fn use_symbolic(mut self, use_symbolic: bool) -> Self { 285 self.use_symbolic = Some(use_symbolic); 286 self 287 } 288 adjustment<P: IsA<Adjustment>>(mut self, adjustment: &P) -> Self289 pub fn adjustment<P: IsA<Adjustment>>(mut self, adjustment: &P) -> Self { 290 self.adjustment = Some(adjustment.clone().upcast()); 291 self 292 } 293 icons(mut self, icons: Vec<String>) -> Self294 pub fn icons(mut self, icons: Vec<String>) -> Self { 295 self.icons = Some(icons); 296 self 297 } 298 size(mut self, size: IconSize) -> Self299 pub fn size(mut self, size: IconSize) -> Self { 300 self.size = Some(size); 301 self 302 } 303 value(mut self, value: f64) -> Self304 pub fn value(mut self, value: f64) -> Self { 305 self.value = Some(value); 306 self 307 } 308 always_show_image(mut self, always_show_image: bool) -> Self309 pub fn always_show_image(mut self, always_show_image: bool) -> Self { 310 self.always_show_image = Some(always_show_image); 311 self 312 } 313 image<P: IsA<Widget>>(mut self, image: &P) -> Self314 pub fn image<P: IsA<Widget>>(mut self, image: &P) -> Self { 315 self.image = Some(image.clone().upcast()); 316 self 317 } 318 image_position(mut self, image_position: PositionType) -> Self319 pub fn image_position(mut self, image_position: PositionType) -> Self { 320 self.image_position = Some(image_position); 321 self 322 } 323 label(mut self, label: &str) -> Self324 pub fn label(mut self, label: &str) -> Self { 325 self.label = Some(label.to_string()); 326 self 327 } 328 relief(mut self, relief: ReliefStyle) -> Self329 pub fn relief(mut self, relief: ReliefStyle) -> Self { 330 self.relief = Some(relief); 331 self 332 } 333 use_underline(mut self, use_underline: bool) -> Self334 pub fn use_underline(mut self, use_underline: bool) -> Self { 335 self.use_underline = Some(use_underline); 336 self 337 } 338 border_width(mut self, border_width: u32) -> Self339 pub fn border_width(mut self, border_width: u32) -> Self { 340 self.border_width = Some(border_width); 341 self 342 } 343 child<P: IsA<Widget>>(mut self, child: &P) -> Self344 pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self { 345 self.child = Some(child.clone().upcast()); 346 self 347 } 348 resize_mode(mut self, resize_mode: ResizeMode) -> Self349 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { 350 self.resize_mode = Some(resize_mode); 351 self 352 } 353 app_paintable(mut self, app_paintable: bool) -> Self354 pub fn app_paintable(mut self, app_paintable: bool) -> Self { 355 self.app_paintable = Some(app_paintable); 356 self 357 } 358 can_default(mut self, can_default: bool) -> Self359 pub fn can_default(mut self, can_default: bool) -> Self { 360 self.can_default = Some(can_default); 361 self 362 } 363 can_focus(mut self, can_focus: bool) -> Self364 pub fn can_focus(mut self, can_focus: bool) -> Self { 365 self.can_focus = Some(can_focus); 366 self 367 } 368 events(mut self, events: gdk::EventMask) -> Self369 pub fn events(mut self, events: gdk::EventMask) -> Self { 370 self.events = Some(events); 371 self 372 } 373 expand(mut self, expand: bool) -> Self374 pub fn expand(mut self, expand: bool) -> Self { 375 self.expand = Some(expand); 376 self 377 } 378 379 #[cfg(any(feature = "v3_20", feature = "dox"))] 380 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] focus_on_click(mut self, focus_on_click: bool) -> Self381 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { 382 self.focus_on_click = Some(focus_on_click); 383 self 384 } 385 halign(mut self, halign: Align) -> Self386 pub fn halign(mut self, halign: Align) -> Self { 387 self.halign = Some(halign); 388 self 389 } 390 has_default(mut self, has_default: bool) -> Self391 pub fn has_default(mut self, has_default: bool) -> Self { 392 self.has_default = Some(has_default); 393 self 394 } 395 has_focus(mut self, has_focus: bool) -> Self396 pub fn has_focus(mut self, has_focus: bool) -> Self { 397 self.has_focus = Some(has_focus); 398 self 399 } 400 has_tooltip(mut self, has_tooltip: bool) -> Self401 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { 402 self.has_tooltip = Some(has_tooltip); 403 self 404 } 405 height_request(mut self, height_request: i32) -> Self406 pub fn height_request(mut self, height_request: i32) -> Self { 407 self.height_request = Some(height_request); 408 self 409 } 410 hexpand(mut self, hexpand: bool) -> Self411 pub fn hexpand(mut self, hexpand: bool) -> Self { 412 self.hexpand = Some(hexpand); 413 self 414 } 415 hexpand_set(mut self, hexpand_set: bool) -> Self416 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { 417 self.hexpand_set = Some(hexpand_set); 418 self 419 } 420 is_focus(mut self, is_focus: bool) -> Self421 pub fn is_focus(mut self, is_focus: bool) -> Self { 422 self.is_focus = Some(is_focus); 423 self 424 } 425 margin(mut self, margin: i32) -> Self426 pub fn margin(mut self, margin: i32) -> Self { 427 self.margin = Some(margin); 428 self 429 } 430 margin_bottom(mut self, margin_bottom: i32) -> Self431 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { 432 self.margin_bottom = Some(margin_bottom); 433 self 434 } 435 margin_end(mut self, margin_end: i32) -> Self436 pub fn margin_end(mut self, margin_end: i32) -> Self { 437 self.margin_end = Some(margin_end); 438 self 439 } 440 margin_start(mut self, margin_start: i32) -> Self441 pub fn margin_start(mut self, margin_start: i32) -> Self { 442 self.margin_start = Some(margin_start); 443 self 444 } 445 margin_top(mut self, margin_top: i32) -> Self446 pub fn margin_top(mut self, margin_top: i32) -> Self { 447 self.margin_top = Some(margin_top); 448 self 449 } 450 name(mut self, name: &str) -> Self451 pub fn name(mut self, name: &str) -> Self { 452 self.name = Some(name.to_string()); 453 self 454 } 455 no_show_all(mut self, no_show_all: bool) -> Self456 pub fn no_show_all(mut self, no_show_all: bool) -> Self { 457 self.no_show_all = Some(no_show_all); 458 self 459 } 460 opacity(mut self, opacity: f64) -> Self461 pub fn opacity(mut self, opacity: f64) -> Self { 462 self.opacity = Some(opacity); 463 self 464 } 465 parent<P: IsA<Container>>(mut self, parent: &P) -> Self466 pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self { 467 self.parent = Some(parent.clone().upcast()); 468 self 469 } 470 receives_default(mut self, receives_default: bool) -> Self471 pub fn receives_default(mut self, receives_default: bool) -> Self { 472 self.receives_default = Some(receives_default); 473 self 474 } 475 sensitive(mut self, sensitive: bool) -> Self476 pub fn sensitive(mut self, sensitive: bool) -> Self { 477 self.sensitive = Some(sensitive); 478 self 479 } 480 tooltip_markup(mut self, tooltip_markup: &str) -> Self481 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { 482 self.tooltip_markup = Some(tooltip_markup.to_string()); 483 self 484 } 485 tooltip_text(mut self, tooltip_text: &str) -> Self486 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { 487 self.tooltip_text = Some(tooltip_text.to_string()); 488 self 489 } 490 valign(mut self, valign: Align) -> Self491 pub fn valign(mut self, valign: Align) -> Self { 492 self.valign = Some(valign); 493 self 494 } 495 vexpand(mut self, vexpand: bool) -> Self496 pub fn vexpand(mut self, vexpand: bool) -> Self { 497 self.vexpand = Some(vexpand); 498 self 499 } 500 vexpand_set(mut self, vexpand_set: bool) -> Self501 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { 502 self.vexpand_set = Some(vexpand_set); 503 self 504 } 505 visible(mut self, visible: bool) -> Self506 pub fn visible(mut self, visible: bool) -> Self { 507 self.visible = Some(visible); 508 self 509 } 510 width_request(mut self, width_request: i32) -> Self511 pub fn width_request(mut self, width_request: i32) -> Self { 512 self.width_request = Some(width_request); 513 self 514 } 515 action_name(mut self, action_name: &str) -> Self516 pub fn action_name(mut self, action_name: &str) -> Self { 517 self.action_name = Some(action_name.to_string()); 518 self 519 } 520 action_target(mut self, action_target: &glib::Variant) -> Self521 pub fn action_target(mut self, action_target: &glib::Variant) -> Self { 522 self.action_target = Some(action_target.clone()); 523 self 524 } 525 orientation(mut self, orientation: Orientation) -> Self526 pub fn orientation(mut self, orientation: Orientation) -> Self { 527 self.orientation = Some(orientation); 528 self 529 } 530 } 531 532 pub const NONE_VOLUME_BUTTON: Option<&VolumeButton> = None; 533 534 pub trait VolumeButtonExt: 'static { 535 #[doc(alias = "use-symbolic")] uses_symbolic(&self) -> bool536 fn uses_symbolic(&self) -> bool; 537 538 #[doc(alias = "use-symbolic")] set_use_symbolic(&self, use_symbolic: bool)539 fn set_use_symbolic(&self, use_symbolic: bool); 540 541 #[doc(alias = "use-symbolic")] connect_use_symbolic_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId542 fn connect_use_symbolic_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 543 } 544 545 impl<O: IsA<VolumeButton>> VolumeButtonExt for O { uses_symbolic(&self) -> bool546 fn uses_symbolic(&self) -> bool { 547 unsafe { 548 let mut value = glib::Value::from_type(<bool as StaticType>::static_type()); 549 glib::gobject_ffi::g_object_get_property( 550 self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, 551 b"use-symbolic\0".as_ptr() as *const _, 552 value.to_glib_none_mut().0, 553 ); 554 value 555 .get() 556 .expect("Return Value for property `use-symbolic` getter") 557 } 558 } 559 set_use_symbolic(&self, use_symbolic: bool)560 fn set_use_symbolic(&self, use_symbolic: bool) { 561 unsafe { 562 glib::gobject_ffi::g_object_set_property( 563 self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, 564 b"use-symbolic\0".as_ptr() as *const _, 565 use_symbolic.to_value().to_glib_none().0, 566 ); 567 } 568 } 569 connect_use_symbolic_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId570 fn connect_use_symbolic_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 571 unsafe extern "C" fn notify_use_symbolic_trampoline< 572 P: IsA<VolumeButton>, 573 F: Fn(&P) + 'static, 574 >( 575 this: *mut ffi::GtkVolumeButton, 576 _param_spec: glib::ffi::gpointer, 577 f: glib::ffi::gpointer, 578 ) { 579 let f: &F = &*(f as *const F); 580 f(VolumeButton::from_glib_borrow(this).unsafe_cast_ref()) 581 } 582 unsafe { 583 let f: Box_<F> = Box_::new(f); 584 connect_raw( 585 self.as_ptr() as *mut _, 586 b"notify::use-symbolic\0".as_ptr() as *const _, 587 Some(transmute::<_, unsafe extern "C" fn()>( 588 notify_use_symbolic_trampoline::<Self, F> as *const (), 589 )), 590 Box_::into_raw(f), 591 ) 592 } 593 } 594 } 595 596 impl fmt::Display for VolumeButton { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result597 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 598 f.write_str("VolumeButton") 599 } 600 } 601