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::translate::*; 9 use glib::StaticType; 10 use glib::ToValue; 11 use glib::Value; 12 use gtk_sys; 13 use std::fmt; 14 use Align; 15 use Bin; 16 use Buildable; 17 use Container; 18 use PackType; 19 use ResizeMode; 20 use Widget; 21 22 glib_wrapper! { 23 pub struct ActionBar(Object<gtk_sys::GtkActionBar, gtk_sys::GtkActionBarClass, ActionBarClass>) @extends Bin, Container, Widget, @implements Buildable; 24 25 match fn { 26 get_type => || gtk_sys::gtk_action_bar_get_type(), 27 } 28 } 29 30 impl ActionBar { new() -> ActionBar31 pub fn new() -> ActionBar { 32 assert_initialized_main_thread!(); 33 unsafe { Widget::from_glib_none(gtk_sys::gtk_action_bar_new()).unsafe_cast() } 34 } 35 } 36 37 impl Default for ActionBar { default() -> Self38 fn default() -> Self { 39 Self::new() 40 } 41 } 42 43 pub struct ActionBarBuilder { 44 border_width: Option<u32>, 45 child: Option<Widget>, 46 resize_mode: Option<ResizeMode>, 47 app_paintable: Option<bool>, 48 can_default: Option<bool>, 49 can_focus: Option<bool>, 50 events: Option<gdk::EventMask>, 51 expand: Option<bool>, 52 #[cfg(any(feature = "v3_20", feature = "dox"))] 53 focus_on_click: Option<bool>, 54 halign: Option<Align>, 55 has_default: Option<bool>, 56 has_focus: Option<bool>, 57 has_tooltip: Option<bool>, 58 height_request: Option<i32>, 59 hexpand: Option<bool>, 60 hexpand_set: Option<bool>, 61 is_focus: Option<bool>, 62 margin: Option<i32>, 63 margin_bottom: Option<i32>, 64 margin_end: Option<i32>, 65 margin_start: Option<i32>, 66 margin_top: Option<i32>, 67 name: Option<String>, 68 no_show_all: Option<bool>, 69 opacity: Option<f64>, 70 parent: Option<Container>, 71 receives_default: Option<bool>, 72 sensitive: Option<bool>, 73 //style: /*Unknown type*/, 74 tooltip_markup: Option<String>, 75 tooltip_text: Option<String>, 76 valign: Option<Align>, 77 vexpand: Option<bool>, 78 vexpand_set: Option<bool>, 79 visible: Option<bool>, 80 width_request: Option<i32>, 81 } 82 83 impl ActionBarBuilder { new() -> Self84 pub fn new() -> Self { 85 Self { 86 border_width: None, 87 child: None, 88 resize_mode: None, 89 app_paintable: None, 90 can_default: None, 91 can_focus: None, 92 events: None, 93 expand: None, 94 #[cfg(any(feature = "v3_20", feature = "dox"))] 95 focus_on_click: None, 96 halign: None, 97 has_default: None, 98 has_focus: None, 99 has_tooltip: None, 100 height_request: None, 101 hexpand: None, 102 hexpand_set: None, 103 is_focus: None, 104 margin: None, 105 margin_bottom: None, 106 margin_end: None, 107 margin_start: None, 108 margin_top: None, 109 name: None, 110 no_show_all: None, 111 opacity: None, 112 parent: None, 113 receives_default: None, 114 sensitive: None, 115 tooltip_markup: None, 116 tooltip_text: None, 117 valign: None, 118 vexpand: None, 119 vexpand_set: None, 120 visible: None, 121 width_request: None, 122 } 123 } 124 build(self) -> ActionBar125 pub fn build(self) -> ActionBar { 126 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 127 if let Some(ref border_width) = self.border_width { 128 properties.push(("border-width", border_width)); 129 } 130 if let Some(ref child) = self.child { 131 properties.push(("child", child)); 132 } 133 if let Some(ref resize_mode) = self.resize_mode { 134 properties.push(("resize-mode", resize_mode)); 135 } 136 if let Some(ref app_paintable) = self.app_paintable { 137 properties.push(("app-paintable", app_paintable)); 138 } 139 if let Some(ref can_default) = self.can_default { 140 properties.push(("can-default", can_default)); 141 } 142 if let Some(ref can_focus) = self.can_focus { 143 properties.push(("can-focus", can_focus)); 144 } 145 if let Some(ref events) = self.events { 146 properties.push(("events", events)); 147 } 148 if let Some(ref expand) = self.expand { 149 properties.push(("expand", expand)); 150 } 151 #[cfg(any(feature = "v3_20", feature = "dox"))] 152 { 153 if let Some(ref focus_on_click) = self.focus_on_click { 154 properties.push(("focus-on-click", focus_on_click)); 155 } 156 } 157 if let Some(ref halign) = self.halign { 158 properties.push(("halign", halign)); 159 } 160 if let Some(ref has_default) = self.has_default { 161 properties.push(("has-default", has_default)); 162 } 163 if let Some(ref has_focus) = self.has_focus { 164 properties.push(("has-focus", has_focus)); 165 } 166 if let Some(ref has_tooltip) = self.has_tooltip { 167 properties.push(("has-tooltip", has_tooltip)); 168 } 169 if let Some(ref height_request) = self.height_request { 170 properties.push(("height-request", height_request)); 171 } 172 if let Some(ref hexpand) = self.hexpand { 173 properties.push(("hexpand", hexpand)); 174 } 175 if let Some(ref hexpand_set) = self.hexpand_set { 176 properties.push(("hexpand-set", hexpand_set)); 177 } 178 if let Some(ref is_focus) = self.is_focus { 179 properties.push(("is-focus", is_focus)); 180 } 181 if let Some(ref margin) = self.margin { 182 properties.push(("margin", margin)); 183 } 184 if let Some(ref margin_bottom) = self.margin_bottom { 185 properties.push(("margin-bottom", margin_bottom)); 186 } 187 if let Some(ref margin_end) = self.margin_end { 188 properties.push(("margin-end", margin_end)); 189 } 190 if let Some(ref margin_start) = self.margin_start { 191 properties.push(("margin-start", margin_start)); 192 } 193 if let Some(ref margin_top) = self.margin_top { 194 properties.push(("margin-top", margin_top)); 195 } 196 if let Some(ref name) = self.name { 197 properties.push(("name", name)); 198 } 199 if let Some(ref no_show_all) = self.no_show_all { 200 properties.push(("no-show-all", no_show_all)); 201 } 202 if let Some(ref opacity) = self.opacity { 203 properties.push(("opacity", opacity)); 204 } 205 if let Some(ref parent) = self.parent { 206 properties.push(("parent", parent)); 207 } 208 if let Some(ref receives_default) = self.receives_default { 209 properties.push(("receives-default", receives_default)); 210 } 211 if let Some(ref sensitive) = self.sensitive { 212 properties.push(("sensitive", sensitive)); 213 } 214 if let Some(ref tooltip_markup) = self.tooltip_markup { 215 properties.push(("tooltip-markup", tooltip_markup)); 216 } 217 if let Some(ref tooltip_text) = self.tooltip_text { 218 properties.push(("tooltip-text", tooltip_text)); 219 } 220 if let Some(ref valign) = self.valign { 221 properties.push(("valign", valign)); 222 } 223 if let Some(ref vexpand) = self.vexpand { 224 properties.push(("vexpand", vexpand)); 225 } 226 if let Some(ref vexpand_set) = self.vexpand_set { 227 properties.push(("vexpand-set", vexpand_set)); 228 } 229 if let Some(ref visible) = self.visible { 230 properties.push(("visible", visible)); 231 } 232 if let Some(ref width_request) = self.width_request { 233 properties.push(("width-request", width_request)); 234 } 235 glib::Object::new(ActionBar::static_type(), &properties) 236 .expect("object new") 237 .downcast() 238 .expect("downcast") 239 } 240 border_width(mut self, border_width: u32) -> Self241 pub fn border_width(mut self, border_width: u32) -> Self { 242 self.border_width = Some(border_width); 243 self 244 } 245 child(mut self, child: &Widget) -> Self246 pub fn child(mut self, child: &Widget) -> Self { 247 self.child = Some(child.clone()); 248 self 249 } 250 resize_mode(mut self, resize_mode: ResizeMode) -> Self251 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { 252 self.resize_mode = Some(resize_mode); 253 self 254 } 255 app_paintable(mut self, app_paintable: bool) -> Self256 pub fn app_paintable(mut self, app_paintable: bool) -> Self { 257 self.app_paintable = Some(app_paintable); 258 self 259 } 260 can_default(mut self, can_default: bool) -> Self261 pub fn can_default(mut self, can_default: bool) -> Self { 262 self.can_default = Some(can_default); 263 self 264 } 265 can_focus(mut self, can_focus: bool) -> Self266 pub fn can_focus(mut self, can_focus: bool) -> Self { 267 self.can_focus = Some(can_focus); 268 self 269 } 270 events(mut self, events: gdk::EventMask) -> Self271 pub fn events(mut self, events: gdk::EventMask) -> Self { 272 self.events = Some(events); 273 self 274 } 275 expand(mut self, expand: bool) -> Self276 pub fn expand(mut self, expand: bool) -> Self { 277 self.expand = Some(expand); 278 self 279 } 280 281 #[cfg(any(feature = "v3_20", feature = "dox"))] focus_on_click(mut self, focus_on_click: bool) -> Self282 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { 283 self.focus_on_click = Some(focus_on_click); 284 self 285 } 286 halign(mut self, halign: Align) -> Self287 pub fn halign(mut self, halign: Align) -> Self { 288 self.halign = Some(halign); 289 self 290 } 291 has_default(mut self, has_default: bool) -> Self292 pub fn has_default(mut self, has_default: bool) -> Self { 293 self.has_default = Some(has_default); 294 self 295 } 296 has_focus(mut self, has_focus: bool) -> Self297 pub fn has_focus(mut self, has_focus: bool) -> Self { 298 self.has_focus = Some(has_focus); 299 self 300 } 301 has_tooltip(mut self, has_tooltip: bool) -> Self302 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { 303 self.has_tooltip = Some(has_tooltip); 304 self 305 } 306 height_request(mut self, height_request: i32) -> Self307 pub fn height_request(mut self, height_request: i32) -> Self { 308 self.height_request = Some(height_request); 309 self 310 } 311 hexpand(mut self, hexpand: bool) -> Self312 pub fn hexpand(mut self, hexpand: bool) -> Self { 313 self.hexpand = Some(hexpand); 314 self 315 } 316 hexpand_set(mut self, hexpand_set: bool) -> Self317 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { 318 self.hexpand_set = Some(hexpand_set); 319 self 320 } 321 is_focus(mut self, is_focus: bool) -> Self322 pub fn is_focus(mut self, is_focus: bool) -> Self { 323 self.is_focus = Some(is_focus); 324 self 325 } 326 margin(mut self, margin: i32) -> Self327 pub fn margin(mut self, margin: i32) -> Self { 328 self.margin = Some(margin); 329 self 330 } 331 margin_bottom(mut self, margin_bottom: i32) -> Self332 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { 333 self.margin_bottom = Some(margin_bottom); 334 self 335 } 336 margin_end(mut self, margin_end: i32) -> Self337 pub fn margin_end(mut self, margin_end: i32) -> Self { 338 self.margin_end = Some(margin_end); 339 self 340 } 341 margin_start(mut self, margin_start: i32) -> Self342 pub fn margin_start(mut self, margin_start: i32) -> Self { 343 self.margin_start = Some(margin_start); 344 self 345 } 346 margin_top(mut self, margin_top: i32) -> Self347 pub fn margin_top(mut self, margin_top: i32) -> Self { 348 self.margin_top = Some(margin_top); 349 self 350 } 351 name(mut self, name: &str) -> Self352 pub fn name(mut self, name: &str) -> Self { 353 self.name = Some(name.to_string()); 354 self 355 } 356 no_show_all(mut self, no_show_all: bool) -> Self357 pub fn no_show_all(mut self, no_show_all: bool) -> Self { 358 self.no_show_all = Some(no_show_all); 359 self 360 } 361 opacity(mut self, opacity: f64) -> Self362 pub fn opacity(mut self, opacity: f64) -> Self { 363 self.opacity = Some(opacity); 364 self 365 } 366 parent(mut self, parent: &Container) -> Self367 pub fn parent(mut self, parent: &Container) -> Self { 368 self.parent = Some(parent.clone()); 369 self 370 } 371 receives_default(mut self, receives_default: bool) -> Self372 pub fn receives_default(mut self, receives_default: bool) -> Self { 373 self.receives_default = Some(receives_default); 374 self 375 } 376 sensitive(mut self, sensitive: bool) -> Self377 pub fn sensitive(mut self, sensitive: bool) -> Self { 378 self.sensitive = Some(sensitive); 379 self 380 } 381 tooltip_markup(mut self, tooltip_markup: &str) -> Self382 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { 383 self.tooltip_markup = Some(tooltip_markup.to_string()); 384 self 385 } 386 tooltip_text(mut self, tooltip_text: &str) -> Self387 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { 388 self.tooltip_text = Some(tooltip_text.to_string()); 389 self 390 } 391 valign(mut self, valign: Align) -> Self392 pub fn valign(mut self, valign: Align) -> Self { 393 self.valign = Some(valign); 394 self 395 } 396 vexpand(mut self, vexpand: bool) -> Self397 pub fn vexpand(mut self, vexpand: bool) -> Self { 398 self.vexpand = Some(vexpand); 399 self 400 } 401 vexpand_set(mut self, vexpand_set: bool) -> Self402 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { 403 self.vexpand_set = Some(vexpand_set); 404 self 405 } 406 visible(mut self, visible: bool) -> Self407 pub fn visible(mut self, visible: bool) -> Self { 408 self.visible = Some(visible); 409 self 410 } 411 width_request(mut self, width_request: i32) -> Self412 pub fn width_request(mut self, width_request: i32) -> Self { 413 self.width_request = Some(width_request); 414 self 415 } 416 } 417 418 pub const NONE_ACTION_BAR: Option<&ActionBar> = None; 419 420 pub trait ActionBarExt: 'static { get_center_widget(&self) -> Option<Widget>421 fn get_center_widget(&self) -> Option<Widget>; 422 pack_end<P: IsA<Widget>>(&self, child: &P)423 fn pack_end<P: IsA<Widget>>(&self, child: &P); 424 pack_start<P: IsA<Widget>>(&self, child: &P)425 fn pack_start<P: IsA<Widget>>(&self, child: &P); 426 set_center_widget<P: IsA<Widget>>(&self, center_widget: Option<&P>)427 fn set_center_widget<P: IsA<Widget>>(&self, center_widget: Option<&P>); 428 get_child_pack_type<T: IsA<Widget>>(&self, item: &T) -> PackType429 fn get_child_pack_type<T: IsA<Widget>>(&self, item: &T) -> PackType; 430 set_child_pack_type<T: IsA<Widget>>(&self, item: &T, pack_type: PackType)431 fn set_child_pack_type<T: IsA<Widget>>(&self, item: &T, pack_type: PackType); 432 get_child_position<T: IsA<Widget>>(&self, item: &T) -> i32433 fn get_child_position<T: IsA<Widget>>(&self, item: &T) -> i32; 434 set_child_position<T: IsA<Widget>>(&self, item: &T, position: i32)435 fn set_child_position<T: IsA<Widget>>(&self, item: &T, position: i32); 436 } 437 438 impl<O: IsA<ActionBar>> ActionBarExt for O { get_center_widget(&self) -> Option<Widget>439 fn get_center_widget(&self) -> Option<Widget> { 440 unsafe { 441 from_glib_none(gtk_sys::gtk_action_bar_get_center_widget( 442 self.as_ref().to_glib_none().0, 443 )) 444 } 445 } 446 pack_end<P: IsA<Widget>>(&self, child: &P)447 fn pack_end<P: IsA<Widget>>(&self, child: &P) { 448 unsafe { 449 gtk_sys::gtk_action_bar_pack_end( 450 self.as_ref().to_glib_none().0, 451 child.as_ref().to_glib_none().0, 452 ); 453 } 454 } 455 pack_start<P: IsA<Widget>>(&self, child: &P)456 fn pack_start<P: IsA<Widget>>(&self, child: &P) { 457 unsafe { 458 gtk_sys::gtk_action_bar_pack_start( 459 self.as_ref().to_glib_none().0, 460 child.as_ref().to_glib_none().0, 461 ); 462 } 463 } 464 set_center_widget<P: IsA<Widget>>(&self, center_widget: Option<&P>)465 fn set_center_widget<P: IsA<Widget>>(&self, center_widget: Option<&P>) { 466 unsafe { 467 gtk_sys::gtk_action_bar_set_center_widget( 468 self.as_ref().to_glib_none().0, 469 center_widget.map(|p| p.as_ref()).to_glib_none().0, 470 ); 471 } 472 } 473 get_child_pack_type<T: IsA<Widget>>(&self, item: &T) -> PackType474 fn get_child_pack_type<T: IsA<Widget>>(&self, item: &T) -> PackType { 475 unsafe { 476 let mut value = Value::from_type(<PackType as StaticType>::static_type()); 477 gtk_sys::gtk_container_child_get_property( 478 self.to_glib_none().0 as *mut gtk_sys::GtkContainer, 479 item.to_glib_none().0 as *mut _, 480 b"pack-type\0".as_ptr() as *const _, 481 value.to_glib_none_mut().0, 482 ); 483 value.get().unwrap() 484 } 485 } 486 set_child_pack_type<T: IsA<Widget>>(&self, item: &T, pack_type: PackType)487 fn set_child_pack_type<T: IsA<Widget>>(&self, item: &T, pack_type: PackType) { 488 unsafe { 489 gtk_sys::gtk_container_child_set_property( 490 self.to_glib_none().0 as *mut gtk_sys::GtkContainer, 491 item.to_glib_none().0 as *mut _, 492 b"pack-type\0".as_ptr() as *const _, 493 Value::from(&pack_type).to_glib_none().0, 494 ); 495 } 496 } 497 get_child_position<T: IsA<Widget>>(&self, item: &T) -> i32498 fn get_child_position<T: IsA<Widget>>(&self, item: &T) -> i32 { 499 unsafe { 500 let mut value = Value::from_type(<i32 as StaticType>::static_type()); 501 gtk_sys::gtk_container_child_get_property( 502 self.to_glib_none().0 as *mut gtk_sys::GtkContainer, 503 item.to_glib_none().0 as *mut _, 504 b"position\0".as_ptr() as *const _, 505 value.to_glib_none_mut().0, 506 ); 507 value.get().unwrap() 508 } 509 } 510 set_child_position<T: IsA<Widget>>(&self, item: &T, position: i32)511 fn set_child_position<T: IsA<Widget>>(&self, item: &T, position: i32) { 512 unsafe { 513 gtk_sys::gtk_container_child_set_property( 514 self.to_glib_none().0 as *mut gtk_sys::GtkContainer, 515 item.to_glib_none().0 as *mut _, 516 b"position\0".as_ptr() as *const _, 517 Value::from(&position).to_glib_none().0, 518 ); 519 } 520 } 521 } 522 523 impl fmt::Display for ActionBar { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result524 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 525 write!(f, "ActionBar") 526 } 527 } 528