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::signal::connect_raw; 9 use glib::signal::SignalHandlerId; 10 use glib::translate::*; 11 use glib::StaticType; 12 use glib::ToValue; 13 use glib::Value; 14 use glib_sys; 15 use gobject_sys; 16 use gtk_sys; 17 use std::boxed::Box as Box_; 18 use std::fmt; 19 use std::mem::transmute; 20 use Align; 21 use BaselinePosition; 22 use Box; 23 use Buildable; 24 use ColorChooser; 25 use Container; 26 use Orientable; 27 use Orientation; 28 use ResizeMode; 29 use Widget; 30 31 glib_wrapper! { 32 pub struct ColorChooserWidget(Object<gtk_sys::GtkColorChooserWidget, gtk_sys::GtkColorChooserWidgetClass, ColorChooserWidgetClass>) @extends Box, Container, Widget, @implements Buildable, Orientable, ColorChooser; 33 34 match fn { 35 get_type => || gtk_sys::gtk_color_chooser_widget_get_type(), 36 } 37 } 38 39 impl ColorChooserWidget { new() -> ColorChooserWidget40 pub fn new() -> ColorChooserWidget { 41 assert_initialized_main_thread!(); 42 unsafe { Widget::from_glib_none(gtk_sys::gtk_color_chooser_widget_new()).unsafe_cast() } 43 } 44 } 45 46 impl Default for ColorChooserWidget { default() -> Self47 fn default() -> Self { 48 Self::new() 49 } 50 } 51 52 #[derive(Clone, Default)] 53 pub struct ColorChooserWidgetBuilder { 54 show_editor: Option<bool>, 55 baseline_position: Option<BaselinePosition>, 56 homogeneous: Option<bool>, 57 spacing: Option<i32>, 58 border_width: Option<u32>, 59 child: Option<Widget>, 60 resize_mode: Option<ResizeMode>, 61 app_paintable: Option<bool>, 62 can_default: Option<bool>, 63 can_focus: Option<bool>, 64 events: Option<gdk::EventMask>, 65 expand: Option<bool>, 66 #[cfg(any(feature = "v3_20", feature = "dox"))] 67 focus_on_click: Option<bool>, 68 halign: Option<Align>, 69 has_default: Option<bool>, 70 has_focus: Option<bool>, 71 has_tooltip: Option<bool>, 72 height_request: Option<i32>, 73 hexpand: Option<bool>, 74 hexpand_set: Option<bool>, 75 is_focus: Option<bool>, 76 margin: Option<i32>, 77 margin_bottom: Option<i32>, 78 margin_end: Option<i32>, 79 margin_start: Option<i32>, 80 margin_top: Option<i32>, 81 name: Option<String>, 82 no_show_all: Option<bool>, 83 opacity: Option<f64>, 84 parent: Option<Container>, 85 receives_default: Option<bool>, 86 sensitive: Option<bool>, 87 tooltip_markup: Option<String>, 88 tooltip_text: Option<String>, 89 valign: Option<Align>, 90 vexpand: Option<bool>, 91 vexpand_set: Option<bool>, 92 visible: Option<bool>, 93 width_request: Option<i32>, 94 orientation: Option<Orientation>, 95 rgba: Option<gdk::RGBA>, 96 use_alpha: Option<bool>, 97 } 98 99 impl ColorChooserWidgetBuilder { new() -> Self100 pub fn new() -> Self { 101 Self::default() 102 } 103 build(self) -> ColorChooserWidget104 pub fn build(self) -> ColorChooserWidget { 105 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 106 if let Some(ref show_editor) = self.show_editor { 107 properties.push(("show-editor", show_editor)); 108 } 109 if let Some(ref baseline_position) = self.baseline_position { 110 properties.push(("baseline-position", baseline_position)); 111 } 112 if let Some(ref homogeneous) = self.homogeneous { 113 properties.push(("homogeneous", homogeneous)); 114 } 115 if let Some(ref spacing) = self.spacing { 116 properties.push(("spacing", spacing)); 117 } 118 if let Some(ref border_width) = self.border_width { 119 properties.push(("border-width", border_width)); 120 } 121 if let Some(ref child) = self.child { 122 properties.push(("child", child)); 123 } 124 if let Some(ref resize_mode) = self.resize_mode { 125 properties.push(("resize-mode", resize_mode)); 126 } 127 if let Some(ref app_paintable) = self.app_paintable { 128 properties.push(("app-paintable", app_paintable)); 129 } 130 if let Some(ref can_default) = self.can_default { 131 properties.push(("can-default", can_default)); 132 } 133 if let Some(ref can_focus) = self.can_focus { 134 properties.push(("can-focus", can_focus)); 135 } 136 if let Some(ref events) = self.events { 137 properties.push(("events", events)); 138 } 139 if let Some(ref expand) = self.expand { 140 properties.push(("expand", expand)); 141 } 142 #[cfg(any(feature = "v3_20", feature = "dox"))] 143 { 144 if let Some(ref focus_on_click) = self.focus_on_click { 145 properties.push(("focus-on-click", focus_on_click)); 146 } 147 } 148 if let Some(ref halign) = self.halign { 149 properties.push(("halign", halign)); 150 } 151 if let Some(ref has_default) = self.has_default { 152 properties.push(("has-default", has_default)); 153 } 154 if let Some(ref has_focus) = self.has_focus { 155 properties.push(("has-focus", has_focus)); 156 } 157 if let Some(ref has_tooltip) = self.has_tooltip { 158 properties.push(("has-tooltip", has_tooltip)); 159 } 160 if let Some(ref height_request) = self.height_request { 161 properties.push(("height-request", height_request)); 162 } 163 if let Some(ref hexpand) = self.hexpand { 164 properties.push(("hexpand", hexpand)); 165 } 166 if let Some(ref hexpand_set) = self.hexpand_set { 167 properties.push(("hexpand-set", hexpand_set)); 168 } 169 if let Some(ref is_focus) = self.is_focus { 170 properties.push(("is-focus", is_focus)); 171 } 172 if let Some(ref margin) = self.margin { 173 properties.push(("margin", margin)); 174 } 175 if let Some(ref margin_bottom) = self.margin_bottom { 176 properties.push(("margin-bottom", margin_bottom)); 177 } 178 if let Some(ref margin_end) = self.margin_end { 179 properties.push(("margin-end", margin_end)); 180 } 181 if let Some(ref margin_start) = self.margin_start { 182 properties.push(("margin-start", margin_start)); 183 } 184 if let Some(ref margin_top) = self.margin_top { 185 properties.push(("margin-top", margin_top)); 186 } 187 if let Some(ref name) = self.name { 188 properties.push(("name", name)); 189 } 190 if let Some(ref no_show_all) = self.no_show_all { 191 properties.push(("no-show-all", no_show_all)); 192 } 193 if let Some(ref opacity) = self.opacity { 194 properties.push(("opacity", opacity)); 195 } 196 if let Some(ref parent) = self.parent { 197 properties.push(("parent", parent)); 198 } 199 if let Some(ref receives_default) = self.receives_default { 200 properties.push(("receives-default", receives_default)); 201 } 202 if let Some(ref sensitive) = self.sensitive { 203 properties.push(("sensitive", sensitive)); 204 } 205 if let Some(ref tooltip_markup) = self.tooltip_markup { 206 properties.push(("tooltip-markup", tooltip_markup)); 207 } 208 if let Some(ref tooltip_text) = self.tooltip_text { 209 properties.push(("tooltip-text", tooltip_text)); 210 } 211 if let Some(ref valign) = self.valign { 212 properties.push(("valign", valign)); 213 } 214 if let Some(ref vexpand) = self.vexpand { 215 properties.push(("vexpand", vexpand)); 216 } 217 if let Some(ref vexpand_set) = self.vexpand_set { 218 properties.push(("vexpand-set", vexpand_set)); 219 } 220 if let Some(ref visible) = self.visible { 221 properties.push(("visible", visible)); 222 } 223 if let Some(ref width_request) = self.width_request { 224 properties.push(("width-request", width_request)); 225 } 226 if let Some(ref orientation) = self.orientation { 227 properties.push(("orientation", orientation)); 228 } 229 if let Some(ref rgba) = self.rgba { 230 properties.push(("rgba", rgba)); 231 } 232 if let Some(ref use_alpha) = self.use_alpha { 233 properties.push(("use-alpha", use_alpha)); 234 } 235 glib::Object::new(ColorChooserWidget::static_type(), &properties) 236 .expect("object new") 237 .downcast() 238 .expect("downcast") 239 } 240 show_editor(mut self, show_editor: bool) -> Self241 pub fn show_editor(mut self, show_editor: bool) -> Self { 242 self.show_editor = Some(show_editor); 243 self 244 } 245 baseline_position(mut self, baseline_position: BaselinePosition) -> Self246 pub fn baseline_position(mut self, baseline_position: BaselinePosition) -> Self { 247 self.baseline_position = Some(baseline_position); 248 self 249 } 250 homogeneous(mut self, homogeneous: bool) -> Self251 pub fn homogeneous(mut self, homogeneous: bool) -> Self { 252 self.homogeneous = Some(homogeneous); 253 self 254 } 255 spacing(mut self, spacing: i32) -> Self256 pub fn spacing(mut self, spacing: i32) -> Self { 257 self.spacing = Some(spacing); 258 self 259 } 260 border_width(mut self, border_width: u32) -> Self261 pub fn border_width(mut self, border_width: u32) -> Self { 262 self.border_width = Some(border_width); 263 self 264 } 265 child<P: IsA<Widget>>(mut self, child: &P) -> Self266 pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self { 267 self.child = Some(child.clone().upcast()); 268 self 269 } 270 resize_mode(mut self, resize_mode: ResizeMode) -> Self271 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { 272 self.resize_mode = Some(resize_mode); 273 self 274 } 275 app_paintable(mut self, app_paintable: bool) -> Self276 pub fn app_paintable(mut self, app_paintable: bool) -> Self { 277 self.app_paintable = Some(app_paintable); 278 self 279 } 280 can_default(mut self, can_default: bool) -> Self281 pub fn can_default(mut self, can_default: bool) -> Self { 282 self.can_default = Some(can_default); 283 self 284 } 285 can_focus(mut self, can_focus: bool) -> Self286 pub fn can_focus(mut self, can_focus: bool) -> Self { 287 self.can_focus = Some(can_focus); 288 self 289 } 290 events(mut self, events: gdk::EventMask) -> Self291 pub fn events(mut self, events: gdk::EventMask) -> Self { 292 self.events = Some(events); 293 self 294 } 295 expand(mut self, expand: bool) -> Self296 pub fn expand(mut self, expand: bool) -> Self { 297 self.expand = Some(expand); 298 self 299 } 300 301 #[cfg(any(feature = "v3_20", feature = "dox"))] focus_on_click(mut self, focus_on_click: bool) -> Self302 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { 303 self.focus_on_click = Some(focus_on_click); 304 self 305 } 306 halign(mut self, halign: Align) -> Self307 pub fn halign(mut self, halign: Align) -> Self { 308 self.halign = Some(halign); 309 self 310 } 311 has_default(mut self, has_default: bool) -> Self312 pub fn has_default(mut self, has_default: bool) -> Self { 313 self.has_default = Some(has_default); 314 self 315 } 316 has_focus(mut self, has_focus: bool) -> Self317 pub fn has_focus(mut self, has_focus: bool) -> Self { 318 self.has_focus = Some(has_focus); 319 self 320 } 321 has_tooltip(mut self, has_tooltip: bool) -> Self322 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { 323 self.has_tooltip = Some(has_tooltip); 324 self 325 } 326 height_request(mut self, height_request: i32) -> Self327 pub fn height_request(mut self, height_request: i32) -> Self { 328 self.height_request = Some(height_request); 329 self 330 } 331 hexpand(mut self, hexpand: bool) -> Self332 pub fn hexpand(mut self, hexpand: bool) -> Self { 333 self.hexpand = Some(hexpand); 334 self 335 } 336 hexpand_set(mut self, hexpand_set: bool) -> Self337 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { 338 self.hexpand_set = Some(hexpand_set); 339 self 340 } 341 is_focus(mut self, is_focus: bool) -> Self342 pub fn is_focus(mut self, is_focus: bool) -> Self { 343 self.is_focus = Some(is_focus); 344 self 345 } 346 margin(mut self, margin: i32) -> Self347 pub fn margin(mut self, margin: i32) -> Self { 348 self.margin = Some(margin); 349 self 350 } 351 margin_bottom(mut self, margin_bottom: i32) -> Self352 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { 353 self.margin_bottom = Some(margin_bottom); 354 self 355 } 356 margin_end(mut self, margin_end: i32) -> Self357 pub fn margin_end(mut self, margin_end: i32) -> Self { 358 self.margin_end = Some(margin_end); 359 self 360 } 361 margin_start(mut self, margin_start: i32) -> Self362 pub fn margin_start(mut self, margin_start: i32) -> Self { 363 self.margin_start = Some(margin_start); 364 self 365 } 366 margin_top(mut self, margin_top: i32) -> Self367 pub fn margin_top(mut self, margin_top: i32) -> Self { 368 self.margin_top = Some(margin_top); 369 self 370 } 371 name(mut self, name: &str) -> Self372 pub fn name(mut self, name: &str) -> Self { 373 self.name = Some(name.to_string()); 374 self 375 } 376 no_show_all(mut self, no_show_all: bool) -> Self377 pub fn no_show_all(mut self, no_show_all: bool) -> Self { 378 self.no_show_all = Some(no_show_all); 379 self 380 } 381 opacity(mut self, opacity: f64) -> Self382 pub fn opacity(mut self, opacity: f64) -> Self { 383 self.opacity = Some(opacity); 384 self 385 } 386 parent<P: IsA<Container>>(mut self, parent: &P) -> Self387 pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self { 388 self.parent = Some(parent.clone().upcast()); 389 self 390 } 391 receives_default(mut self, receives_default: bool) -> Self392 pub fn receives_default(mut self, receives_default: bool) -> Self { 393 self.receives_default = Some(receives_default); 394 self 395 } 396 sensitive(mut self, sensitive: bool) -> Self397 pub fn sensitive(mut self, sensitive: bool) -> Self { 398 self.sensitive = Some(sensitive); 399 self 400 } 401 tooltip_markup(mut self, tooltip_markup: &str) -> Self402 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { 403 self.tooltip_markup = Some(tooltip_markup.to_string()); 404 self 405 } 406 tooltip_text(mut self, tooltip_text: &str) -> Self407 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { 408 self.tooltip_text = Some(tooltip_text.to_string()); 409 self 410 } 411 valign(mut self, valign: Align) -> Self412 pub fn valign(mut self, valign: Align) -> Self { 413 self.valign = Some(valign); 414 self 415 } 416 vexpand(mut self, vexpand: bool) -> Self417 pub fn vexpand(mut self, vexpand: bool) -> Self { 418 self.vexpand = Some(vexpand); 419 self 420 } 421 vexpand_set(mut self, vexpand_set: bool) -> Self422 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { 423 self.vexpand_set = Some(vexpand_set); 424 self 425 } 426 visible(mut self, visible: bool) -> Self427 pub fn visible(mut self, visible: bool) -> Self { 428 self.visible = Some(visible); 429 self 430 } 431 width_request(mut self, width_request: i32) -> Self432 pub fn width_request(mut self, width_request: i32) -> Self { 433 self.width_request = Some(width_request); 434 self 435 } 436 orientation(mut self, orientation: Orientation) -> Self437 pub fn orientation(mut self, orientation: Orientation) -> Self { 438 self.orientation = Some(orientation); 439 self 440 } 441 rgba(mut self, rgba: &gdk::RGBA) -> Self442 pub fn rgba(mut self, rgba: &gdk::RGBA) -> Self { 443 self.rgba = Some(rgba.clone()); 444 self 445 } 446 use_alpha(mut self, use_alpha: bool) -> Self447 pub fn use_alpha(mut self, use_alpha: bool) -> Self { 448 self.use_alpha = Some(use_alpha); 449 self 450 } 451 } 452 453 pub const NONE_COLOR_CHOOSER_WIDGET: Option<&ColorChooserWidget> = None; 454 455 pub trait ColorChooserWidgetExt: 'static { get_property_show_editor(&self) -> bool456 fn get_property_show_editor(&self) -> bool; 457 set_property_show_editor(&self, show_editor: bool)458 fn set_property_show_editor(&self, show_editor: bool); 459 connect_property_show_editor_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId460 fn connect_property_show_editor_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 461 } 462 463 impl<O: IsA<ColorChooserWidget>> ColorChooserWidgetExt for O { get_property_show_editor(&self) -> bool464 fn get_property_show_editor(&self) -> bool { 465 unsafe { 466 let mut value = Value::from_type(<bool as StaticType>::static_type()); 467 gobject_sys::g_object_get_property( 468 self.to_glib_none().0 as *mut gobject_sys::GObject, 469 b"show-editor\0".as_ptr() as *const _, 470 value.to_glib_none_mut().0, 471 ); 472 value 473 .get() 474 .expect("Return Value for property `show-editor` getter") 475 .unwrap() 476 } 477 } 478 set_property_show_editor(&self, show_editor: bool)479 fn set_property_show_editor(&self, show_editor: bool) { 480 unsafe { 481 gobject_sys::g_object_set_property( 482 self.to_glib_none().0 as *mut gobject_sys::GObject, 483 b"show-editor\0".as_ptr() as *const _, 484 Value::from(&show_editor).to_glib_none().0, 485 ); 486 } 487 } 488 connect_property_show_editor_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId489 fn connect_property_show_editor_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 490 unsafe extern "C" fn notify_show_editor_trampoline<P, F: Fn(&P) + 'static>( 491 this: *mut gtk_sys::GtkColorChooserWidget, 492 _param_spec: glib_sys::gpointer, 493 f: glib_sys::gpointer, 494 ) where 495 P: IsA<ColorChooserWidget>, 496 { 497 let f: &F = &*(f as *const F); 498 f(&ColorChooserWidget::from_glib_borrow(this).unsafe_cast()) 499 } 500 unsafe { 501 let f: Box_<F> = Box_::new(f); 502 connect_raw( 503 self.as_ptr() as *mut _, 504 b"notify::show-editor\0".as_ptr() as *const _, 505 Some(transmute(notify_show_editor_trampoline::<Self, F> as usize)), 506 Box_::into_raw(f), 507 ) 508 } 509 } 510 } 511 512 impl fmt::Display for ColorChooserWidget { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result513 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 514 write!(f, "ColorChooserWidget") 515 } 516 } 517