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;
7 use glib::object::Cast;
8 use glib::object::IsA;
9 use glib::signal::connect_raw;
10 use glib::signal::SignalHandlerId;
11 use glib::translate::*;
12 use glib::StaticType;
13 use glib::ToValue;
14 use glib::Value;
15 use glib_sys;
16 use gobject_sys;
17 use gtk_sys;
18 use std::boxed::Box as Box_;
19 use std::fmt;
20 use std::mem::transmute;
21 use Actionable;
22 use Adjustment;
23 use Align;
24 use Bin;
25 use Buildable;
26 use Button;
27 use Container;
28 use IconSize;
29 use Orientable;
30 use Orientation;
31 use PositionType;
32 use ReliefStyle;
33 use ResizeMode;
34 use ScaleButton;
35 use Widget;
36 
37 glib_wrapper! {
38     pub struct VolumeButton(Object<gtk_sys::GtkVolumeButton, gtk_sys::GtkVolumeButtonClass, VolumeButtonClass>) @extends ScaleButton, Button, Bin, Container, Widget, @implements Buildable, Actionable, Orientable;
39 
40     match fn {
41         get_type => || gtk_sys::gtk_volume_button_get_type(),
42     }
43 }
44 
45 impl VolumeButton {
new() -> VolumeButton46     pub fn new() -> VolumeButton {
47         assert_initialized_main_thread!();
48         unsafe { Widget::from_glib_none(gtk_sys::gtk_volume_button_new()).unsafe_cast() }
49     }
50 }
51 
52 impl Default for VolumeButton {
default() -> Self53     fn default() -> Self {
54         Self::new()
55     }
56 }
57 
58 #[derive(Clone, Default)]
59 pub struct VolumeButtonBuilder {
60     use_symbolic: Option<bool>,
61     adjustment: Option<Adjustment>,
62     icons: Option<Vec<String>>,
63     size: Option<IconSize>,
64     value: Option<f64>,
65     always_show_image: Option<bool>,
66     image: Option<Widget>,
67     image_position: Option<PositionType>,
68     label: Option<String>,
69     relief: Option<ReliefStyle>,
70     use_underline: Option<bool>,
71     border_width: Option<u32>,
72     child: Option<Widget>,
73     resize_mode: Option<ResizeMode>,
74     app_paintable: Option<bool>,
75     can_default: Option<bool>,
76     can_focus: Option<bool>,
77     events: Option<gdk::EventMask>,
78     expand: Option<bool>,
79     #[cfg(any(feature = "v3_20", feature = "dox"))]
80     focus_on_click: Option<bool>,
81     halign: Option<Align>,
82     has_default: Option<bool>,
83     has_focus: Option<bool>,
84     has_tooltip: Option<bool>,
85     height_request: Option<i32>,
86     hexpand: Option<bool>,
87     hexpand_set: Option<bool>,
88     is_focus: Option<bool>,
89     margin: Option<i32>,
90     margin_bottom: Option<i32>,
91     margin_end: Option<i32>,
92     margin_start: Option<i32>,
93     margin_top: Option<i32>,
94     name: Option<String>,
95     no_show_all: Option<bool>,
96     opacity: Option<f64>,
97     parent: Option<Container>,
98     receives_default: Option<bool>,
99     sensitive: Option<bool>,
100     tooltip_markup: Option<String>,
101     tooltip_text: Option<String>,
102     valign: Option<Align>,
103     vexpand: Option<bool>,
104     vexpand_set: Option<bool>,
105     visible: Option<bool>,
106     width_request: Option<i32>,
107     action_name: Option<String>,
108     action_target: Option<glib::Variant>,
109     orientation: Option<Orientation>,
110 }
111 
112 impl VolumeButtonBuilder {
new() -> Self113     pub fn new() -> Self {
114         Self::default()
115     }
116 
build(self) -> VolumeButton117     pub fn build(self) -> VolumeButton {
118         let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
119         if let Some(ref use_symbolic) = self.use_symbolic {
120             properties.push(("use-symbolic", use_symbolic));
121         }
122         if let Some(ref adjustment) = self.adjustment {
123             properties.push(("adjustment", adjustment));
124         }
125         if let Some(ref icons) = self.icons {
126             properties.push(("icons", icons));
127         }
128         if let Some(ref size) = self.size {
129             properties.push(("size", size));
130         }
131         if let Some(ref value) = self.value {
132             properties.push(("value", value));
133         }
134         if let Some(ref always_show_image) = self.always_show_image {
135             properties.push(("always-show-image", always_show_image));
136         }
137         if let Some(ref image) = self.image {
138             properties.push(("image", image));
139         }
140         if let Some(ref image_position) = self.image_position {
141             properties.push(("image-position", image_position));
142         }
143         if let Some(ref label) = self.label {
144             properties.push(("label", label));
145         }
146         if let Some(ref relief) = self.relief {
147             properties.push(("relief", relief));
148         }
149         if let Some(ref use_underline) = self.use_underline {
150             properties.push(("use-underline", use_underline));
151         }
152         if let Some(ref border_width) = self.border_width {
153             properties.push(("border-width", border_width));
154         }
155         if let Some(ref child) = self.child {
156             properties.push(("child", child));
157         }
158         if let Some(ref resize_mode) = self.resize_mode {
159             properties.push(("resize-mode", resize_mode));
160         }
161         if let Some(ref app_paintable) = self.app_paintable {
162             properties.push(("app-paintable", app_paintable));
163         }
164         if let Some(ref can_default) = self.can_default {
165             properties.push(("can-default", can_default));
166         }
167         if let Some(ref can_focus) = self.can_focus {
168             properties.push(("can-focus", can_focus));
169         }
170         if let Some(ref events) = self.events {
171             properties.push(("events", events));
172         }
173         if let Some(ref expand) = self.expand {
174             properties.push(("expand", expand));
175         }
176         #[cfg(any(feature = "v3_20", feature = "dox"))]
177         {
178             if let Some(ref focus_on_click) = self.focus_on_click {
179                 properties.push(("focus-on-click", focus_on_click));
180             }
181         }
182         if let Some(ref halign) = self.halign {
183             properties.push(("halign", halign));
184         }
185         if let Some(ref has_default) = self.has_default {
186             properties.push(("has-default", has_default));
187         }
188         if let Some(ref has_focus) = self.has_focus {
189             properties.push(("has-focus", has_focus));
190         }
191         if let Some(ref has_tooltip) = self.has_tooltip {
192             properties.push(("has-tooltip", has_tooltip));
193         }
194         if let Some(ref height_request) = self.height_request {
195             properties.push(("height-request", height_request));
196         }
197         if let Some(ref hexpand) = self.hexpand {
198             properties.push(("hexpand", hexpand));
199         }
200         if let Some(ref hexpand_set) = self.hexpand_set {
201             properties.push(("hexpand-set", hexpand_set));
202         }
203         if let Some(ref is_focus) = self.is_focus {
204             properties.push(("is-focus", is_focus));
205         }
206         if let Some(ref margin) = self.margin {
207             properties.push(("margin", margin));
208         }
209         if let Some(ref margin_bottom) = self.margin_bottom {
210             properties.push(("margin-bottom", margin_bottom));
211         }
212         if let Some(ref margin_end) = self.margin_end {
213             properties.push(("margin-end", margin_end));
214         }
215         if let Some(ref margin_start) = self.margin_start {
216             properties.push(("margin-start", margin_start));
217         }
218         if let Some(ref margin_top) = self.margin_top {
219             properties.push(("margin-top", margin_top));
220         }
221         if let Some(ref name) = self.name {
222             properties.push(("name", name));
223         }
224         if let Some(ref no_show_all) = self.no_show_all {
225             properties.push(("no-show-all", no_show_all));
226         }
227         if let Some(ref opacity) = self.opacity {
228             properties.push(("opacity", opacity));
229         }
230         if let Some(ref parent) = self.parent {
231             properties.push(("parent", parent));
232         }
233         if let Some(ref receives_default) = self.receives_default {
234             properties.push(("receives-default", receives_default));
235         }
236         if let Some(ref sensitive) = self.sensitive {
237             properties.push(("sensitive", sensitive));
238         }
239         if let Some(ref tooltip_markup) = self.tooltip_markup {
240             properties.push(("tooltip-markup", tooltip_markup));
241         }
242         if let Some(ref tooltip_text) = self.tooltip_text {
243             properties.push(("tooltip-text", tooltip_text));
244         }
245         if let Some(ref valign) = self.valign {
246             properties.push(("valign", valign));
247         }
248         if let Some(ref vexpand) = self.vexpand {
249             properties.push(("vexpand", vexpand));
250         }
251         if let Some(ref vexpand_set) = self.vexpand_set {
252             properties.push(("vexpand-set", vexpand_set));
253         }
254         if let Some(ref visible) = self.visible {
255             properties.push(("visible", visible));
256         }
257         if let Some(ref width_request) = self.width_request {
258             properties.push(("width-request", width_request));
259         }
260         if let Some(ref action_name) = self.action_name {
261             properties.push(("action-name", action_name));
262         }
263         if let Some(ref action_target) = self.action_target {
264             properties.push(("action-target", action_target));
265         }
266         if let Some(ref orientation) = self.orientation {
267             properties.push(("orientation", orientation));
268         }
269         glib::Object::new(VolumeButton::static_type(), &properties)
270             .expect("object new")
271             .downcast()
272             .expect("downcast")
273     }
274 
use_symbolic(mut self, use_symbolic: bool) -> Self275     pub fn use_symbolic(mut self, use_symbolic: bool) -> Self {
276         self.use_symbolic = Some(use_symbolic);
277         self
278     }
279 
adjustment<P: IsA<Adjustment>>(mut self, adjustment: &P) -> Self280     pub fn adjustment<P: IsA<Adjustment>>(mut self, adjustment: &P) -> Self {
281         self.adjustment = Some(adjustment.clone().upcast());
282         self
283     }
284 
icons(mut self, icons: Vec<String>) -> Self285     pub fn icons(mut self, icons: Vec<String>) -> Self {
286         self.icons = Some(icons);
287         self
288     }
289 
size(mut self, size: IconSize) -> Self290     pub fn size(mut self, size: IconSize) -> Self {
291         self.size = Some(size);
292         self
293     }
294 
value(mut self, value: f64) -> Self295     pub fn value(mut self, value: f64) -> Self {
296         self.value = Some(value);
297         self
298     }
299 
always_show_image(mut self, always_show_image: bool) -> Self300     pub fn always_show_image(mut self, always_show_image: bool) -> Self {
301         self.always_show_image = Some(always_show_image);
302         self
303     }
304 
image<P: IsA<Widget>>(mut self, image: &P) -> Self305     pub fn image<P: IsA<Widget>>(mut self, image: &P) -> Self {
306         self.image = Some(image.clone().upcast());
307         self
308     }
309 
image_position(mut self, image_position: PositionType) -> Self310     pub fn image_position(mut self, image_position: PositionType) -> Self {
311         self.image_position = Some(image_position);
312         self
313     }
314 
label(mut self, label: &str) -> Self315     pub fn label(mut self, label: &str) -> Self {
316         self.label = Some(label.to_string());
317         self
318     }
319 
relief(mut self, relief: ReliefStyle) -> Self320     pub fn relief(mut self, relief: ReliefStyle) -> Self {
321         self.relief = Some(relief);
322         self
323     }
324 
use_underline(mut self, use_underline: bool) -> Self325     pub fn use_underline(mut self, use_underline: bool) -> Self {
326         self.use_underline = Some(use_underline);
327         self
328     }
329 
border_width(mut self, border_width: u32) -> Self330     pub fn border_width(mut self, border_width: u32) -> Self {
331         self.border_width = Some(border_width);
332         self
333     }
334 
child<P: IsA<Widget>>(mut self, child: &P) -> Self335     pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self {
336         self.child = Some(child.clone().upcast());
337         self
338     }
339 
resize_mode(mut self, resize_mode: ResizeMode) -> Self340     pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self {
341         self.resize_mode = Some(resize_mode);
342         self
343     }
344 
app_paintable(mut self, app_paintable: bool) -> Self345     pub fn app_paintable(mut self, app_paintable: bool) -> Self {
346         self.app_paintable = Some(app_paintable);
347         self
348     }
349 
can_default(mut self, can_default: bool) -> Self350     pub fn can_default(mut self, can_default: bool) -> Self {
351         self.can_default = Some(can_default);
352         self
353     }
354 
can_focus(mut self, can_focus: bool) -> Self355     pub fn can_focus(mut self, can_focus: bool) -> Self {
356         self.can_focus = Some(can_focus);
357         self
358     }
359 
events(mut self, events: gdk::EventMask) -> Self360     pub fn events(mut self, events: gdk::EventMask) -> Self {
361         self.events = Some(events);
362         self
363     }
364 
expand(mut self, expand: bool) -> Self365     pub fn expand(mut self, expand: bool) -> Self {
366         self.expand = Some(expand);
367         self
368     }
369 
370     #[cfg(any(feature = "v3_20", feature = "dox"))]
focus_on_click(mut self, focus_on_click: bool) -> Self371     pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
372         self.focus_on_click = Some(focus_on_click);
373         self
374     }
375 
halign(mut self, halign: Align) -> Self376     pub fn halign(mut self, halign: Align) -> Self {
377         self.halign = Some(halign);
378         self
379     }
380 
has_default(mut self, has_default: bool) -> Self381     pub fn has_default(mut self, has_default: bool) -> Self {
382         self.has_default = Some(has_default);
383         self
384     }
385 
has_focus(mut self, has_focus: bool) -> Self386     pub fn has_focus(mut self, has_focus: bool) -> Self {
387         self.has_focus = Some(has_focus);
388         self
389     }
390 
has_tooltip(mut self, has_tooltip: bool) -> Self391     pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
392         self.has_tooltip = Some(has_tooltip);
393         self
394     }
395 
height_request(mut self, height_request: i32) -> Self396     pub fn height_request(mut self, height_request: i32) -> Self {
397         self.height_request = Some(height_request);
398         self
399     }
400 
hexpand(mut self, hexpand: bool) -> Self401     pub fn hexpand(mut self, hexpand: bool) -> Self {
402         self.hexpand = Some(hexpand);
403         self
404     }
405 
hexpand_set(mut self, hexpand_set: bool) -> Self406     pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
407         self.hexpand_set = Some(hexpand_set);
408         self
409     }
410 
is_focus(mut self, is_focus: bool) -> Self411     pub fn is_focus(mut self, is_focus: bool) -> Self {
412         self.is_focus = Some(is_focus);
413         self
414     }
415 
margin(mut self, margin: i32) -> Self416     pub fn margin(mut self, margin: i32) -> Self {
417         self.margin = Some(margin);
418         self
419     }
420 
margin_bottom(mut self, margin_bottom: i32) -> Self421     pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
422         self.margin_bottom = Some(margin_bottom);
423         self
424     }
425 
margin_end(mut self, margin_end: i32) -> Self426     pub fn margin_end(mut self, margin_end: i32) -> Self {
427         self.margin_end = Some(margin_end);
428         self
429     }
430 
margin_start(mut self, margin_start: i32) -> Self431     pub fn margin_start(mut self, margin_start: i32) -> Self {
432         self.margin_start = Some(margin_start);
433         self
434     }
435 
margin_top(mut self, margin_top: i32) -> Self436     pub fn margin_top(mut self, margin_top: i32) -> Self {
437         self.margin_top = Some(margin_top);
438         self
439     }
440 
name(mut self, name: &str) -> Self441     pub fn name(mut self, name: &str) -> Self {
442         self.name = Some(name.to_string());
443         self
444     }
445 
no_show_all(mut self, no_show_all: bool) -> Self446     pub fn no_show_all(mut self, no_show_all: bool) -> Self {
447         self.no_show_all = Some(no_show_all);
448         self
449     }
450 
opacity(mut self, opacity: f64) -> Self451     pub fn opacity(mut self, opacity: f64) -> Self {
452         self.opacity = Some(opacity);
453         self
454     }
455 
parent<P: IsA<Container>>(mut self, parent: &P) -> Self456     pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self {
457         self.parent = Some(parent.clone().upcast());
458         self
459     }
460 
receives_default(mut self, receives_default: bool) -> Self461     pub fn receives_default(mut self, receives_default: bool) -> Self {
462         self.receives_default = Some(receives_default);
463         self
464     }
465 
sensitive(mut self, sensitive: bool) -> Self466     pub fn sensitive(mut self, sensitive: bool) -> Self {
467         self.sensitive = Some(sensitive);
468         self
469     }
470 
tooltip_markup(mut self, tooltip_markup: &str) -> Self471     pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
472         self.tooltip_markup = Some(tooltip_markup.to_string());
473         self
474     }
475 
tooltip_text(mut self, tooltip_text: &str) -> Self476     pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
477         self.tooltip_text = Some(tooltip_text.to_string());
478         self
479     }
480 
valign(mut self, valign: Align) -> Self481     pub fn valign(mut self, valign: Align) -> Self {
482         self.valign = Some(valign);
483         self
484     }
485 
vexpand(mut self, vexpand: bool) -> Self486     pub fn vexpand(mut self, vexpand: bool) -> Self {
487         self.vexpand = Some(vexpand);
488         self
489     }
490 
vexpand_set(mut self, vexpand_set: bool) -> Self491     pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
492         self.vexpand_set = Some(vexpand_set);
493         self
494     }
495 
visible(mut self, visible: bool) -> Self496     pub fn visible(mut self, visible: bool) -> Self {
497         self.visible = Some(visible);
498         self
499     }
500 
width_request(mut self, width_request: i32) -> Self501     pub fn width_request(mut self, width_request: i32) -> Self {
502         self.width_request = Some(width_request);
503         self
504     }
505 
action_name(mut self, action_name: &str) -> Self506     pub fn action_name(mut self, action_name: &str) -> Self {
507         self.action_name = Some(action_name.to_string());
508         self
509     }
510 
action_target(mut self, action_target: &glib::Variant) -> Self511     pub fn action_target(mut self, action_target: &glib::Variant) -> Self {
512         self.action_target = Some(action_target.clone());
513         self
514     }
515 
orientation(mut self, orientation: Orientation) -> Self516     pub fn orientation(mut self, orientation: Orientation) -> Self {
517         self.orientation = Some(orientation);
518         self
519     }
520 }
521 
522 pub const NONE_VOLUME_BUTTON: Option<&VolumeButton> = None;
523 
524 pub trait VolumeButtonExt: 'static {
get_property_use_symbolic(&self) -> bool525     fn get_property_use_symbolic(&self) -> bool;
526 
set_property_use_symbolic(&self, use_symbolic: bool)527     fn set_property_use_symbolic(&self, use_symbolic: bool);
528 
connect_property_use_symbolic_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId529     fn connect_property_use_symbolic_notify<F: Fn(&Self) + 'static>(&self, f: F)
530         -> SignalHandlerId;
531 }
532 
533 impl<O: IsA<VolumeButton>> VolumeButtonExt for O {
get_property_use_symbolic(&self) -> bool534     fn get_property_use_symbolic(&self) -> bool {
535         unsafe {
536             let mut value = Value::from_type(<bool as StaticType>::static_type());
537             gobject_sys::g_object_get_property(
538                 self.to_glib_none().0 as *mut gobject_sys::GObject,
539                 b"use-symbolic\0".as_ptr() as *const _,
540                 value.to_glib_none_mut().0,
541             );
542             value
543                 .get()
544                 .expect("Return Value for property `use-symbolic` getter")
545                 .unwrap()
546         }
547     }
548 
set_property_use_symbolic(&self, use_symbolic: bool)549     fn set_property_use_symbolic(&self, use_symbolic: bool) {
550         unsafe {
551             gobject_sys::g_object_set_property(
552                 self.to_glib_none().0 as *mut gobject_sys::GObject,
553                 b"use-symbolic\0".as_ptr() as *const _,
554                 Value::from(&use_symbolic).to_glib_none().0,
555             );
556         }
557     }
558 
connect_property_use_symbolic_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId559     fn connect_property_use_symbolic_notify<F: Fn(&Self) + 'static>(
560         &self,
561         f: F,
562     ) -> SignalHandlerId {
563         unsafe extern "C" fn notify_use_symbolic_trampoline<P, F: Fn(&P) + 'static>(
564             this: *mut gtk_sys::GtkVolumeButton,
565             _param_spec: glib_sys::gpointer,
566             f: glib_sys::gpointer,
567         ) where
568             P: IsA<VolumeButton>,
569         {
570             let f: &F = &*(f as *const F);
571             f(&VolumeButton::from_glib_borrow(this).unsafe_cast())
572         }
573         unsafe {
574             let f: Box_<F> = Box_::new(f);
575             connect_raw(
576                 self.as_ptr() as *mut _,
577                 b"notify::use-symbolic\0".as_ptr() as *const _,
578                 Some(transmute(
579                     notify_use_symbolic_trampoline::<Self, F> as usize,
580                 )),
581                 Box_::into_raw(f),
582             )
583         }
584     }
585 }
586 
587 impl fmt::Display for VolumeButton {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result588     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
589         write!(f, "VolumeButton")
590     }
591 }
592