1 // This file was generated by gir (https://github.com/gtk-rs/gir) 2 // from 3 // from gir-files (https://github.com/gtk-rs/gir-files.git) 4 // DO NOT EDIT 5 6 use glib::object::Cast; 7 use glib::object::IsA; 8 use glib::object::ObjectType as ObjectType_; 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 std::boxed::Box as Box_; 15 use std::fmt; 16 use std::mem::transmute; 17 18 glib::wrapper! { 19 #[doc(alias = "HdyTitleBar")] 20 pub struct TitleBar(Object<ffi::HdyTitleBar, ffi::HdyTitleBarClass>) @extends gtk::Bin, gtk::Container, gtk::Widget, @implements gtk::Buildable; 21 22 match fn { 23 type_ => || ffi::hdy_title_bar_get_type(), 24 } 25 } 26 27 impl TitleBar { 28 #[doc(alias = "hdy_title_bar_new")] new() -> TitleBar29 pub fn new() -> TitleBar { 30 assert_initialized_main_thread!(); 31 unsafe { gtk::Widget::from_glib_none(ffi::hdy_title_bar_new()).unsafe_cast() } 32 } 33 34 // rustdoc-stripper-ignore-next 35 /// Creates a new builder-pattern struct instance to construct [`TitleBar`] objects. 36 /// 37 /// This method returns an instance of [`TitleBarBuilder`] which can be used to create [`TitleBar`] objects. builder() -> TitleBarBuilder38 pub fn builder() -> TitleBarBuilder { 39 TitleBarBuilder::default() 40 } 41 42 #[doc(alias = "hdy_title_bar_get_selection_mode")] 43 #[doc(alias = "get_selection_mode")] is_selection_mode(&self) -> bool44 pub fn is_selection_mode(&self) -> bool { 45 unsafe { from_glib(ffi::hdy_title_bar_get_selection_mode(self.to_glib_none().0)) } 46 } 47 48 #[doc(alias = "hdy_title_bar_set_selection_mode")] set_selection_mode(&self, selection_mode: bool)49 pub fn set_selection_mode(&self, selection_mode: bool) { 50 unsafe { 51 ffi::hdy_title_bar_set_selection_mode( 52 self.to_glib_none().0, 53 selection_mode.into_glib(), 54 ); 55 } 56 } 57 58 #[doc(alias = "selection-mode")] connect_selection_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId59 pub fn connect_selection_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 60 unsafe extern "C" fn notify_selection_mode_trampoline<F: Fn(&TitleBar) + 'static>( 61 this: *mut ffi::HdyTitleBar, 62 _param_spec: glib::ffi::gpointer, 63 f: glib::ffi::gpointer, 64 ) { 65 let f: &F = &*(f as *const F); 66 f(&from_glib_borrow(this)) 67 } 68 unsafe { 69 let f: Box_<F> = Box_::new(f); 70 connect_raw( 71 self.as_ptr() as *mut _, 72 b"notify::selection-mode\0".as_ptr() as *const _, 73 Some(transmute::<_, unsafe extern "C" fn()>( 74 notify_selection_mode_trampoline::<F> as *const (), 75 )), 76 Box_::into_raw(f), 77 ) 78 } 79 } 80 } 81 82 impl Default for TitleBar { default() -> Self83 fn default() -> Self { 84 Self::new() 85 } 86 } 87 88 #[derive(Clone, Default)] 89 // rustdoc-stripper-ignore-next 90 /// A [builder-pattern] type to construct [`TitleBar`] objects. 91 /// 92 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html 93 pub struct TitleBarBuilder { 94 selection_mode: Option<bool>, 95 border_width: Option<u32>, 96 child: Option<gtk::Widget>, 97 resize_mode: Option<gtk::ResizeMode>, 98 app_paintable: Option<bool>, 99 can_default: Option<bool>, 100 can_focus: Option<bool>, 101 double_buffered: Option<bool>, 102 events: Option<gdk::EventMask>, 103 expand: Option<bool>, 104 focus_on_click: Option<bool>, 105 halign: Option<gtk::Align>, 106 has_default: Option<bool>, 107 has_focus: Option<bool>, 108 has_tooltip: Option<bool>, 109 height_request: Option<i32>, 110 hexpand: Option<bool>, 111 hexpand_set: Option<bool>, 112 is_focus: Option<bool>, 113 margin: Option<i32>, 114 margin_bottom: Option<i32>, 115 margin_end: Option<i32>, 116 margin_left: Option<i32>, 117 margin_right: Option<i32>, 118 margin_start: Option<i32>, 119 margin_top: Option<i32>, 120 name: Option<String>, 121 no_show_all: Option<bool>, 122 opacity: Option<f64>, 123 parent: Option<gtk::Container>, 124 receives_default: Option<bool>, 125 sensitive: Option<bool>, 126 //style: /*Unknown type*/, 127 tooltip_markup: Option<String>, 128 tooltip_text: Option<String>, 129 valign: Option<gtk::Align>, 130 vexpand: Option<bool>, 131 vexpand_set: Option<bool>, 132 visible: Option<bool>, 133 width_request: Option<i32>, 134 } 135 136 impl TitleBarBuilder { 137 // rustdoc-stripper-ignore-next 138 /// Create a new [`TitleBarBuilder`]. new() -> Self139 pub fn new() -> Self { 140 Self::default() 141 } 142 143 // rustdoc-stripper-ignore-next 144 /// Build the [`TitleBar`]. build(self) -> TitleBar145 pub fn build(self) -> TitleBar { 146 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 147 if let Some(ref selection_mode) = self.selection_mode { 148 properties.push(("selection-mode", selection_mode)); 149 } 150 if let Some(ref border_width) = self.border_width { 151 properties.push(("border-width", border_width)); 152 } 153 if let Some(ref child) = self.child { 154 properties.push(("child", child)); 155 } 156 if let Some(ref resize_mode) = self.resize_mode { 157 properties.push(("resize-mode", resize_mode)); 158 } 159 if let Some(ref app_paintable) = self.app_paintable { 160 properties.push(("app-paintable", app_paintable)); 161 } 162 if let Some(ref can_default) = self.can_default { 163 properties.push(("can-default", can_default)); 164 } 165 if let Some(ref can_focus) = self.can_focus { 166 properties.push(("can-focus", can_focus)); 167 } 168 if let Some(ref double_buffered) = self.double_buffered { 169 properties.push(("double-buffered", double_buffered)); 170 } 171 if let Some(ref events) = self.events { 172 properties.push(("events", events)); 173 } 174 if let Some(ref expand) = self.expand { 175 properties.push(("expand", expand)); 176 } 177 if let Some(ref focus_on_click) = self.focus_on_click { 178 properties.push(("focus-on-click", focus_on_click)); 179 } 180 if let Some(ref halign) = self.halign { 181 properties.push(("halign", halign)); 182 } 183 if let Some(ref has_default) = self.has_default { 184 properties.push(("has-default", has_default)); 185 } 186 if let Some(ref has_focus) = self.has_focus { 187 properties.push(("has-focus", has_focus)); 188 } 189 if let Some(ref has_tooltip) = self.has_tooltip { 190 properties.push(("has-tooltip", has_tooltip)); 191 } 192 if let Some(ref height_request) = self.height_request { 193 properties.push(("height-request", height_request)); 194 } 195 if let Some(ref hexpand) = self.hexpand { 196 properties.push(("hexpand", hexpand)); 197 } 198 if let Some(ref hexpand_set) = self.hexpand_set { 199 properties.push(("hexpand-set", hexpand_set)); 200 } 201 if let Some(ref is_focus) = self.is_focus { 202 properties.push(("is-focus", is_focus)); 203 } 204 if let Some(ref margin) = self.margin { 205 properties.push(("margin", margin)); 206 } 207 if let Some(ref margin_bottom) = self.margin_bottom { 208 properties.push(("margin-bottom", margin_bottom)); 209 } 210 if let Some(ref margin_end) = self.margin_end { 211 properties.push(("margin-end", margin_end)); 212 } 213 if let Some(ref margin_left) = self.margin_left { 214 properties.push(("margin-left", margin_left)); 215 } 216 if let Some(ref margin_right) = self.margin_right { 217 properties.push(("margin-right", margin_right)); 218 } 219 if let Some(ref margin_start) = self.margin_start { 220 properties.push(("margin-start", margin_start)); 221 } 222 if let Some(ref margin_top) = self.margin_top { 223 properties.push(("margin-top", margin_top)); 224 } 225 if let Some(ref name) = self.name { 226 properties.push(("name", name)); 227 } 228 if let Some(ref no_show_all) = self.no_show_all { 229 properties.push(("no-show-all", no_show_all)); 230 } 231 if let Some(ref opacity) = self.opacity { 232 properties.push(("opacity", opacity)); 233 } 234 if let Some(ref parent) = self.parent { 235 properties.push(("parent", parent)); 236 } 237 if let Some(ref receives_default) = self.receives_default { 238 properties.push(("receives-default", receives_default)); 239 } 240 if let Some(ref sensitive) = self.sensitive { 241 properties.push(("sensitive", sensitive)); 242 } 243 if let Some(ref tooltip_markup) = self.tooltip_markup { 244 properties.push(("tooltip-markup", tooltip_markup)); 245 } 246 if let Some(ref tooltip_text) = self.tooltip_text { 247 properties.push(("tooltip-text", tooltip_text)); 248 } 249 if let Some(ref valign) = self.valign { 250 properties.push(("valign", valign)); 251 } 252 if let Some(ref vexpand) = self.vexpand { 253 properties.push(("vexpand", vexpand)); 254 } 255 if let Some(ref vexpand_set) = self.vexpand_set { 256 properties.push(("vexpand-set", vexpand_set)); 257 } 258 if let Some(ref visible) = self.visible { 259 properties.push(("visible", visible)); 260 } 261 if let Some(ref width_request) = self.width_request { 262 properties.push(("width-request", width_request)); 263 } 264 glib::Object::new::<TitleBar>(&properties) 265 .expect("Failed to create an instance of TitleBar") 266 } 267 selection_mode(mut self, selection_mode: bool) -> Self268 pub fn selection_mode(mut self, selection_mode: bool) -> Self { 269 self.selection_mode = Some(selection_mode); 270 self 271 } 272 border_width(mut self, border_width: u32) -> Self273 pub fn border_width(mut self, border_width: u32) -> Self { 274 self.border_width = Some(border_width); 275 self 276 } 277 child<P: IsA<gtk::Widget>>(mut self, child: &P) -> Self278 pub fn child<P: IsA<gtk::Widget>>(mut self, child: &P) -> Self { 279 self.child = Some(child.clone().upcast()); 280 self 281 } 282 resize_mode(mut self, resize_mode: gtk::ResizeMode) -> Self283 pub fn resize_mode(mut self, resize_mode: gtk::ResizeMode) -> Self { 284 self.resize_mode = Some(resize_mode); 285 self 286 } 287 app_paintable(mut self, app_paintable: bool) -> Self288 pub fn app_paintable(mut self, app_paintable: bool) -> Self { 289 self.app_paintable = Some(app_paintable); 290 self 291 } 292 can_default(mut self, can_default: bool) -> Self293 pub fn can_default(mut self, can_default: bool) -> Self { 294 self.can_default = Some(can_default); 295 self 296 } 297 can_focus(mut self, can_focus: bool) -> Self298 pub fn can_focus(mut self, can_focus: bool) -> Self { 299 self.can_focus = Some(can_focus); 300 self 301 } 302 double_buffered(mut self, double_buffered: bool) -> Self303 pub fn double_buffered(mut self, double_buffered: bool) -> Self { 304 self.double_buffered = Some(double_buffered); 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 focus_on_click(mut self, focus_on_click: bool) -> Self318 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { 319 self.focus_on_click = Some(focus_on_click); 320 self 321 } 322 halign(mut self, halign: gtk::Align) -> Self323 pub fn halign(mut self, halign: gtk::Align) -> Self { 324 self.halign = Some(halign); 325 self 326 } 327 has_default(mut self, has_default: bool) -> Self328 pub fn has_default(mut self, has_default: bool) -> Self { 329 self.has_default = Some(has_default); 330 self 331 } 332 has_focus(mut self, has_focus: bool) -> Self333 pub fn has_focus(mut self, has_focus: bool) -> Self { 334 self.has_focus = Some(has_focus); 335 self 336 } 337 has_tooltip(mut self, has_tooltip: bool) -> Self338 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { 339 self.has_tooltip = Some(has_tooltip); 340 self 341 } 342 height_request(mut self, height_request: i32) -> Self343 pub fn height_request(mut self, height_request: i32) -> Self { 344 self.height_request = Some(height_request); 345 self 346 } 347 hexpand(mut self, hexpand: bool) -> Self348 pub fn hexpand(mut self, hexpand: bool) -> Self { 349 self.hexpand = Some(hexpand); 350 self 351 } 352 hexpand_set(mut self, hexpand_set: bool) -> Self353 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { 354 self.hexpand_set = Some(hexpand_set); 355 self 356 } 357 is_focus(mut self, is_focus: bool) -> Self358 pub fn is_focus(mut self, is_focus: bool) -> Self { 359 self.is_focus = Some(is_focus); 360 self 361 } 362 margin(mut self, margin: i32) -> Self363 pub fn margin(mut self, margin: i32) -> Self { 364 self.margin = Some(margin); 365 self 366 } 367 margin_bottom(mut self, margin_bottom: i32) -> Self368 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { 369 self.margin_bottom = Some(margin_bottom); 370 self 371 } 372 margin_end(mut self, margin_end: i32) -> Self373 pub fn margin_end(mut self, margin_end: i32) -> Self { 374 self.margin_end = Some(margin_end); 375 self 376 } 377 margin_left(mut self, margin_left: i32) -> Self378 pub fn margin_left(mut self, margin_left: i32) -> Self { 379 self.margin_left = Some(margin_left); 380 self 381 } 382 margin_right(mut self, margin_right: i32) -> Self383 pub fn margin_right(mut self, margin_right: i32) -> Self { 384 self.margin_right = Some(margin_right); 385 self 386 } 387 margin_start(mut self, margin_start: i32) -> Self388 pub fn margin_start(mut self, margin_start: i32) -> Self { 389 self.margin_start = Some(margin_start); 390 self 391 } 392 margin_top(mut self, margin_top: i32) -> Self393 pub fn margin_top(mut self, margin_top: i32) -> Self { 394 self.margin_top = Some(margin_top); 395 self 396 } 397 name(mut self, name: &str) -> Self398 pub fn name(mut self, name: &str) -> Self { 399 self.name = Some(name.to_string()); 400 self 401 } 402 no_show_all(mut self, no_show_all: bool) -> Self403 pub fn no_show_all(mut self, no_show_all: bool) -> Self { 404 self.no_show_all = Some(no_show_all); 405 self 406 } 407 opacity(mut self, opacity: f64) -> Self408 pub fn opacity(mut self, opacity: f64) -> Self { 409 self.opacity = Some(opacity); 410 self 411 } 412 parent<P: IsA<gtk::Container>>(mut self, parent: &P) -> Self413 pub fn parent<P: IsA<gtk::Container>>(mut self, parent: &P) -> Self { 414 self.parent = Some(parent.clone().upcast()); 415 self 416 } 417 receives_default(mut self, receives_default: bool) -> Self418 pub fn receives_default(mut self, receives_default: bool) -> Self { 419 self.receives_default = Some(receives_default); 420 self 421 } 422 sensitive(mut self, sensitive: bool) -> Self423 pub fn sensitive(mut self, sensitive: bool) -> Self { 424 self.sensitive = Some(sensitive); 425 self 426 } 427 tooltip_markup(mut self, tooltip_markup: &str) -> Self428 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { 429 self.tooltip_markup = Some(tooltip_markup.to_string()); 430 self 431 } 432 tooltip_text(mut self, tooltip_text: &str) -> Self433 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { 434 self.tooltip_text = Some(tooltip_text.to_string()); 435 self 436 } 437 valign(mut self, valign: gtk::Align) -> Self438 pub fn valign(mut self, valign: gtk::Align) -> Self { 439 self.valign = Some(valign); 440 self 441 } 442 vexpand(mut self, vexpand: bool) -> Self443 pub fn vexpand(mut self, vexpand: bool) -> Self { 444 self.vexpand = Some(vexpand); 445 self 446 } 447 vexpand_set(mut self, vexpand_set: bool) -> Self448 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { 449 self.vexpand_set = Some(vexpand_set); 450 self 451 } 452 visible(mut self, visible: bool) -> Self453 pub fn visible(mut self, visible: bool) -> Self { 454 self.visible = Some(visible); 455 self 456 } 457 width_request(mut self, width_request: i32) -> Self458 pub fn width_request(mut self, width_request: i32) -> Self { 459 self.width_request = Some(width_request); 460 self 461 } 462 } 463 464 impl fmt::Display for TitleBar { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result465 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 466 f.write_str("TitleBar") 467 } 468 } 469