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::Align; 6 use crate::BaselinePosition; 7 use crate::Box; 8 use crate::Buildable; 9 use crate::Container; 10 use crate::FontChooser; 11 #[cfg(any(feature = "v3_24", feature = "dox"))] 12 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_24")))] 13 use crate::FontChooserLevel; 14 use crate::Orientable; 15 use crate::Orientation; 16 use crate::ResizeMode; 17 use crate::Widget; 18 use glib::object::Cast; 19 use glib::object::IsA; 20 use glib::signal::connect_raw; 21 use glib::signal::SignalHandlerId; 22 use glib::translate::*; 23 use glib::StaticType; 24 use glib::ToValue; 25 use std::boxed::Box as Box_; 26 use std::fmt; 27 use std::mem::transmute; 28 29 glib::wrapper! { 30 #[doc(alias = "GtkFontChooserWidget")] 31 pub struct FontChooserWidget(Object<ffi::GtkFontChooserWidget, ffi::GtkFontChooserWidgetClass>) @extends Box, Container, Widget, @implements Buildable, Orientable, FontChooser; 32 33 match fn { 34 type_ => || ffi::gtk_font_chooser_widget_get_type(), 35 } 36 } 37 38 impl FontChooserWidget { 39 #[doc(alias = "gtk_font_chooser_widget_new")] new() -> FontChooserWidget40 pub fn new() -> FontChooserWidget { 41 assert_initialized_main_thread!(); 42 unsafe { Widget::from_glib_none(ffi::gtk_font_chooser_widget_new()).unsafe_cast() } 43 } 44 45 // rustdoc-stripper-ignore-next 46 /// Creates a new builder-pattern struct instance to construct [`FontChooserWidget`] objects. 47 /// 48 /// This method returns an instance of [`FontChooserWidgetBuilder`] which can be used to create [`FontChooserWidget`] objects. builder() -> FontChooserWidgetBuilder49 pub fn builder() -> FontChooserWidgetBuilder { 50 FontChooserWidgetBuilder::default() 51 } 52 } 53 54 impl Default for FontChooserWidget { default() -> Self55 fn default() -> Self { 56 Self::new() 57 } 58 } 59 60 #[derive(Clone, Default)] 61 // rustdoc-stripper-ignore-next 62 /// A [builder-pattern] type to construct [`FontChooserWidget`] objects. 63 /// 64 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html 65 pub struct FontChooserWidgetBuilder { 66 baseline_position: Option<BaselinePosition>, 67 homogeneous: Option<bool>, 68 spacing: Option<i32>, 69 border_width: Option<u32>, 70 child: Option<Widget>, 71 resize_mode: Option<ResizeMode>, 72 app_paintable: Option<bool>, 73 can_default: Option<bool>, 74 can_focus: Option<bool>, 75 events: Option<gdk::EventMask>, 76 expand: Option<bool>, 77 #[cfg(any(feature = "v3_20", feature = "dox"))] 78 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] 79 focus_on_click: Option<bool>, 80 halign: Option<Align>, 81 has_default: Option<bool>, 82 has_focus: Option<bool>, 83 has_tooltip: Option<bool>, 84 height_request: Option<i32>, 85 hexpand: Option<bool>, 86 hexpand_set: Option<bool>, 87 is_focus: Option<bool>, 88 margin: Option<i32>, 89 margin_bottom: Option<i32>, 90 margin_end: Option<i32>, 91 margin_start: Option<i32>, 92 margin_top: Option<i32>, 93 name: Option<String>, 94 no_show_all: Option<bool>, 95 opacity: Option<f64>, 96 parent: Option<Container>, 97 receives_default: Option<bool>, 98 sensitive: Option<bool>, 99 tooltip_markup: Option<String>, 100 tooltip_text: Option<String>, 101 valign: Option<Align>, 102 vexpand: Option<bool>, 103 vexpand_set: Option<bool>, 104 visible: Option<bool>, 105 width_request: Option<i32>, 106 orientation: Option<Orientation>, 107 font: Option<String>, 108 font_desc: Option<pango::FontDescription>, 109 #[cfg(any(feature = "v3_24", feature = "dox"))] 110 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_24")))] 111 language: Option<String>, 112 #[cfg(any(feature = "v3_24", feature = "dox"))] 113 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_24")))] 114 level: Option<FontChooserLevel>, 115 preview_text: Option<String>, 116 show_preview_entry: Option<bool>, 117 } 118 119 impl FontChooserWidgetBuilder { 120 // rustdoc-stripper-ignore-next 121 /// Create a new [`FontChooserWidgetBuilder`]. new() -> Self122 pub fn new() -> Self { 123 Self::default() 124 } 125 126 // rustdoc-stripper-ignore-next 127 /// Build the [`FontChooserWidget`]. build(self) -> FontChooserWidget128 pub fn build(self) -> FontChooserWidget { 129 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 130 if let Some(ref baseline_position) = self.baseline_position { 131 properties.push(("baseline-position", baseline_position)); 132 } 133 if let Some(ref homogeneous) = self.homogeneous { 134 properties.push(("homogeneous", homogeneous)); 135 } 136 if let Some(ref spacing) = self.spacing { 137 properties.push(("spacing", spacing)); 138 } 139 if let Some(ref border_width) = self.border_width { 140 properties.push(("border-width", border_width)); 141 } 142 if let Some(ref child) = self.child { 143 properties.push(("child", child)); 144 } 145 if let Some(ref resize_mode) = self.resize_mode { 146 properties.push(("resize-mode", resize_mode)); 147 } 148 if let Some(ref app_paintable) = self.app_paintable { 149 properties.push(("app-paintable", app_paintable)); 150 } 151 if let Some(ref can_default) = self.can_default { 152 properties.push(("can-default", can_default)); 153 } 154 if let Some(ref can_focus) = self.can_focus { 155 properties.push(("can-focus", can_focus)); 156 } 157 if let Some(ref events) = self.events { 158 properties.push(("events", events)); 159 } 160 if let Some(ref expand) = self.expand { 161 properties.push(("expand", expand)); 162 } 163 #[cfg(any(feature = "v3_20", feature = "dox"))] 164 if let Some(ref focus_on_click) = self.focus_on_click { 165 properties.push(("focus-on-click", focus_on_click)); 166 } 167 if let Some(ref halign) = self.halign { 168 properties.push(("halign", halign)); 169 } 170 if let Some(ref has_default) = self.has_default { 171 properties.push(("has-default", has_default)); 172 } 173 if let Some(ref has_focus) = self.has_focus { 174 properties.push(("has-focus", has_focus)); 175 } 176 if let Some(ref has_tooltip) = self.has_tooltip { 177 properties.push(("has-tooltip", has_tooltip)); 178 } 179 if let Some(ref height_request) = self.height_request { 180 properties.push(("height-request", height_request)); 181 } 182 if let Some(ref hexpand) = self.hexpand { 183 properties.push(("hexpand", hexpand)); 184 } 185 if let Some(ref hexpand_set) = self.hexpand_set { 186 properties.push(("hexpand-set", hexpand_set)); 187 } 188 if let Some(ref is_focus) = self.is_focus { 189 properties.push(("is-focus", is_focus)); 190 } 191 if let Some(ref margin) = self.margin { 192 properties.push(("margin", margin)); 193 } 194 if let Some(ref margin_bottom) = self.margin_bottom { 195 properties.push(("margin-bottom", margin_bottom)); 196 } 197 if let Some(ref margin_end) = self.margin_end { 198 properties.push(("margin-end", margin_end)); 199 } 200 if let Some(ref margin_start) = self.margin_start { 201 properties.push(("margin-start", margin_start)); 202 } 203 if let Some(ref margin_top) = self.margin_top { 204 properties.push(("margin-top", margin_top)); 205 } 206 if let Some(ref name) = self.name { 207 properties.push(("name", name)); 208 } 209 if let Some(ref no_show_all) = self.no_show_all { 210 properties.push(("no-show-all", no_show_all)); 211 } 212 if let Some(ref opacity) = self.opacity { 213 properties.push(("opacity", opacity)); 214 } 215 if let Some(ref parent) = self.parent { 216 properties.push(("parent", parent)); 217 } 218 if let Some(ref receives_default) = self.receives_default { 219 properties.push(("receives-default", receives_default)); 220 } 221 if let Some(ref sensitive) = self.sensitive { 222 properties.push(("sensitive", sensitive)); 223 } 224 if let Some(ref tooltip_markup) = self.tooltip_markup { 225 properties.push(("tooltip-markup", tooltip_markup)); 226 } 227 if let Some(ref tooltip_text) = self.tooltip_text { 228 properties.push(("tooltip-text", tooltip_text)); 229 } 230 if let Some(ref valign) = self.valign { 231 properties.push(("valign", valign)); 232 } 233 if let Some(ref vexpand) = self.vexpand { 234 properties.push(("vexpand", vexpand)); 235 } 236 if let Some(ref vexpand_set) = self.vexpand_set { 237 properties.push(("vexpand-set", vexpand_set)); 238 } 239 if let Some(ref visible) = self.visible { 240 properties.push(("visible", visible)); 241 } 242 if let Some(ref width_request) = self.width_request { 243 properties.push(("width-request", width_request)); 244 } 245 if let Some(ref orientation) = self.orientation { 246 properties.push(("orientation", orientation)); 247 } 248 if let Some(ref font) = self.font { 249 properties.push(("font", font)); 250 } 251 if let Some(ref font_desc) = self.font_desc { 252 properties.push(("font-desc", font_desc)); 253 } 254 #[cfg(any(feature = "v3_24", feature = "dox"))] 255 if let Some(ref language) = self.language { 256 properties.push(("language", language)); 257 } 258 #[cfg(any(feature = "v3_24", feature = "dox"))] 259 if let Some(ref level) = self.level { 260 properties.push(("level", level)); 261 } 262 if let Some(ref preview_text) = self.preview_text { 263 properties.push(("preview-text", preview_text)); 264 } 265 if let Some(ref show_preview_entry) = self.show_preview_entry { 266 properties.push(("show-preview-entry", show_preview_entry)); 267 } 268 glib::Object::new::<FontChooserWidget>(&properties) 269 .expect("Failed to create an instance of FontChooserWidget") 270 } 271 baseline_position(mut self, baseline_position: BaselinePosition) -> Self272 pub fn baseline_position(mut self, baseline_position: BaselinePosition) -> Self { 273 self.baseline_position = Some(baseline_position); 274 self 275 } 276 homogeneous(mut self, homogeneous: bool) -> Self277 pub fn homogeneous(mut self, homogeneous: bool) -> Self { 278 self.homogeneous = Some(homogeneous); 279 self 280 } 281 spacing(mut self, spacing: i32) -> Self282 pub fn spacing(mut self, spacing: i32) -> Self { 283 self.spacing = Some(spacing); 284 self 285 } 286 border_width(mut self, border_width: u32) -> Self287 pub fn border_width(mut self, border_width: u32) -> Self { 288 self.border_width = Some(border_width); 289 self 290 } 291 child<P: IsA<Widget>>(mut self, child: &P) -> Self292 pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self { 293 self.child = Some(child.clone().upcast()); 294 self 295 } 296 resize_mode(mut self, resize_mode: ResizeMode) -> Self297 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { 298 self.resize_mode = Some(resize_mode); 299 self 300 } 301 app_paintable(mut self, app_paintable: bool) -> Self302 pub fn app_paintable(mut self, app_paintable: bool) -> Self { 303 self.app_paintable = Some(app_paintable); 304 self 305 } 306 can_default(mut self, can_default: bool) -> Self307 pub fn can_default(mut self, can_default: bool) -> Self { 308 self.can_default = Some(can_default); 309 self 310 } 311 can_focus(mut self, can_focus: bool) -> Self312 pub fn can_focus(mut self, can_focus: bool) -> Self { 313 self.can_focus = Some(can_focus); 314 self 315 } 316 events(mut self, events: gdk::EventMask) -> Self317 pub fn events(mut self, events: gdk::EventMask) -> Self { 318 self.events = Some(events); 319 self 320 } 321 expand(mut self, expand: bool) -> Self322 pub fn expand(mut self, expand: bool) -> Self { 323 self.expand = Some(expand); 324 self 325 } 326 327 #[cfg(any(feature = "v3_20", feature = "dox"))] 328 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] focus_on_click(mut self, focus_on_click: bool) -> Self329 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { 330 self.focus_on_click = Some(focus_on_click); 331 self 332 } 333 halign(mut self, halign: Align) -> Self334 pub fn halign(mut self, halign: Align) -> Self { 335 self.halign = Some(halign); 336 self 337 } 338 has_default(mut self, has_default: bool) -> Self339 pub fn has_default(mut self, has_default: bool) -> Self { 340 self.has_default = Some(has_default); 341 self 342 } 343 has_focus(mut self, has_focus: bool) -> Self344 pub fn has_focus(mut self, has_focus: bool) -> Self { 345 self.has_focus = Some(has_focus); 346 self 347 } 348 has_tooltip(mut self, has_tooltip: bool) -> Self349 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { 350 self.has_tooltip = Some(has_tooltip); 351 self 352 } 353 height_request(mut self, height_request: i32) -> Self354 pub fn height_request(mut self, height_request: i32) -> Self { 355 self.height_request = Some(height_request); 356 self 357 } 358 hexpand(mut self, hexpand: bool) -> Self359 pub fn hexpand(mut self, hexpand: bool) -> Self { 360 self.hexpand = Some(hexpand); 361 self 362 } 363 hexpand_set(mut self, hexpand_set: bool) -> Self364 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { 365 self.hexpand_set = Some(hexpand_set); 366 self 367 } 368 is_focus(mut self, is_focus: bool) -> Self369 pub fn is_focus(mut self, is_focus: bool) -> Self { 370 self.is_focus = Some(is_focus); 371 self 372 } 373 margin(mut self, margin: i32) -> Self374 pub fn margin(mut self, margin: i32) -> Self { 375 self.margin = Some(margin); 376 self 377 } 378 margin_bottom(mut self, margin_bottom: i32) -> Self379 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { 380 self.margin_bottom = Some(margin_bottom); 381 self 382 } 383 margin_end(mut self, margin_end: i32) -> Self384 pub fn margin_end(mut self, margin_end: i32) -> Self { 385 self.margin_end = Some(margin_end); 386 self 387 } 388 margin_start(mut self, margin_start: i32) -> Self389 pub fn margin_start(mut self, margin_start: i32) -> Self { 390 self.margin_start = Some(margin_start); 391 self 392 } 393 margin_top(mut self, margin_top: i32) -> Self394 pub fn margin_top(mut self, margin_top: i32) -> Self { 395 self.margin_top = Some(margin_top); 396 self 397 } 398 name(mut self, name: &str) -> Self399 pub fn name(mut self, name: &str) -> Self { 400 self.name = Some(name.to_string()); 401 self 402 } 403 no_show_all(mut self, no_show_all: bool) -> Self404 pub fn no_show_all(mut self, no_show_all: bool) -> Self { 405 self.no_show_all = Some(no_show_all); 406 self 407 } 408 opacity(mut self, opacity: f64) -> Self409 pub fn opacity(mut self, opacity: f64) -> Self { 410 self.opacity = Some(opacity); 411 self 412 } 413 parent<P: IsA<Container>>(mut self, parent: &P) -> Self414 pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self { 415 self.parent = Some(parent.clone().upcast()); 416 self 417 } 418 receives_default(mut self, receives_default: bool) -> Self419 pub fn receives_default(mut self, receives_default: bool) -> Self { 420 self.receives_default = Some(receives_default); 421 self 422 } 423 sensitive(mut self, sensitive: bool) -> Self424 pub fn sensitive(mut self, sensitive: bool) -> Self { 425 self.sensitive = Some(sensitive); 426 self 427 } 428 tooltip_markup(mut self, tooltip_markup: &str) -> Self429 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { 430 self.tooltip_markup = Some(tooltip_markup.to_string()); 431 self 432 } 433 tooltip_text(mut self, tooltip_text: &str) -> Self434 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { 435 self.tooltip_text = Some(tooltip_text.to_string()); 436 self 437 } 438 valign(mut self, valign: Align) -> Self439 pub fn valign(mut self, valign: Align) -> Self { 440 self.valign = Some(valign); 441 self 442 } 443 vexpand(mut self, vexpand: bool) -> Self444 pub fn vexpand(mut self, vexpand: bool) -> Self { 445 self.vexpand = Some(vexpand); 446 self 447 } 448 vexpand_set(mut self, vexpand_set: bool) -> Self449 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { 450 self.vexpand_set = Some(vexpand_set); 451 self 452 } 453 visible(mut self, visible: bool) -> Self454 pub fn visible(mut self, visible: bool) -> Self { 455 self.visible = Some(visible); 456 self 457 } 458 width_request(mut self, width_request: i32) -> Self459 pub fn width_request(mut self, width_request: i32) -> Self { 460 self.width_request = Some(width_request); 461 self 462 } 463 orientation(mut self, orientation: Orientation) -> Self464 pub fn orientation(mut self, orientation: Orientation) -> Self { 465 self.orientation = Some(orientation); 466 self 467 } 468 font(mut self, font: &str) -> Self469 pub fn font(mut self, font: &str) -> Self { 470 self.font = Some(font.to_string()); 471 self 472 } 473 font_desc(mut self, font_desc: &pango::FontDescription) -> Self474 pub fn font_desc(mut self, font_desc: &pango::FontDescription) -> Self { 475 self.font_desc = Some(font_desc.clone()); 476 self 477 } 478 479 #[cfg(any(feature = "v3_24", feature = "dox"))] 480 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_24")))] language(mut self, language: &str) -> Self481 pub fn language(mut self, language: &str) -> Self { 482 self.language = Some(language.to_string()); 483 self 484 } 485 486 #[cfg(any(feature = "v3_24", feature = "dox"))] 487 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_24")))] level(mut self, level: FontChooserLevel) -> Self488 pub fn level(mut self, level: FontChooserLevel) -> Self { 489 self.level = Some(level); 490 self 491 } 492 preview_text(mut self, preview_text: &str) -> Self493 pub fn preview_text(mut self, preview_text: &str) -> Self { 494 self.preview_text = Some(preview_text.to_string()); 495 self 496 } 497 show_preview_entry(mut self, show_preview_entry: bool) -> Self498 pub fn show_preview_entry(mut self, show_preview_entry: bool) -> Self { 499 self.show_preview_entry = Some(show_preview_entry); 500 self 501 } 502 } 503 504 pub const NONE_FONT_CHOOSER_WIDGET: Option<&FontChooserWidget> = None; 505 506 pub trait FontChooserWidgetExt: 'static { 507 //#[doc(alias = "tweak-action")] 508 //fn tweak_action(&self) -> /*Ignored*/Option<gio::Action>; 509 510 #[doc(alias = "tweak-action")] connect_tweak_action_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId511 fn connect_tweak_action_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 512 } 513 514 impl<O: IsA<FontChooserWidget>> FontChooserWidgetExt for O { 515 //fn tweak_action(&self) -> /*Ignored*/Option<gio::Action> { 516 // unsafe { 517 // let mut value = glib::Value::from_type(</*Unknown type*/ as StaticType>::static_type()); 518 // glib::gobject_ffi::g_object_get_property(self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"tweak-action\0".as_ptr() as *const _, value.to_glib_none_mut().0); 519 // value.get().expect("Return Value for property `tweak-action` getter") 520 // } 521 //} 522 connect_tweak_action_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId523 fn connect_tweak_action_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 524 unsafe extern "C" fn notify_tweak_action_trampoline< 525 P: IsA<FontChooserWidget>, 526 F: Fn(&P) + 'static, 527 >( 528 this: *mut ffi::GtkFontChooserWidget, 529 _param_spec: glib::ffi::gpointer, 530 f: glib::ffi::gpointer, 531 ) { 532 let f: &F = &*(f as *const F); 533 f(FontChooserWidget::from_glib_borrow(this).unsafe_cast_ref()) 534 } 535 unsafe { 536 let f: Box_<F> = Box_::new(f); 537 connect_raw( 538 self.as_ptr() as *mut _, 539 b"notify::tweak-action\0".as_ptr() as *const _, 540 Some(transmute::<_, unsafe extern "C" fn()>( 541 notify_tweak_action_trampoline::<Self, F> as *const (), 542 )), 543 Box_::into_raw(f), 544 ) 545 } 546 } 547 } 548 549 impl fmt::Display for FontChooserWidget { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result550 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 551 f.write_str("FontChooserWidget") 552 } 553 } 554