1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::Border;
use crate::CssSection;
use crate::JunctionSides;
use crate::StateFlags;
#[cfg(any(feature = "v3_20", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
use crate::StyleContextPrintFlags;
use crate::StyleProvider;
use crate::TextDirection;
use crate::WidgetPath;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib::StaticType;
use glib::ToValue;
use std::boxed::Box as Box_;
use std::fmt;
use std::mem::transmute;
glib::wrapper! {
/// [`StyleContext`][crate::StyleContext] is an object that stores styling information affecting
/// a widget defined by [`WidgetPath`][crate::WidgetPath].
///
/// In order to construct the final style information, [`StyleContext`][crate::StyleContext]
/// queries information from all attached `GtkStyleProviders`. Style providers
/// can be either attached explicitly to the context through
/// [`StyleContextExt::add_provider()`][crate::prelude::StyleContextExt::add_provider()], or to the screen through
/// [`add_provider_for_screen()`][Self::add_provider_for_screen()]. The resulting style is a
/// combination of all providers’ information in priority order.
///
/// For GTK+ widgets, any [`StyleContext`][crate::StyleContext] returned by
/// [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()] will already have a [`WidgetPath`][crate::WidgetPath], a
/// [`gdk::Screen`][crate::gdk::Screen] and RTL/LTR information set. The style context will also be
/// updated automatically if any of these settings change on the widget.
///
/// If you are using the theming layer standalone, you will need to set a
/// widget path and a screen yourself to the created style context through
/// [`StyleContextExt::set_path()`][crate::prelude::StyleContextExt::set_path()] and possibly [`StyleContextExt::set_screen()`][crate::prelude::StyleContextExt::set_screen()]. See
/// the “Foreign drawing“ example in gtk3-demo.
///
/// # Style Classes # {`gtkstylecontext`-classes}
///
/// Widgets can add style classes to their context, which can be used to associate
/// different styles by class. The documentation for individual widgets lists
/// which style classes it uses itself, and which style classes may be added by
/// applications to affect their appearance.
///
/// GTK+ defines macros for a number of style classes.
///
/// # Style Regions
///
/// Widgets can also add regions with flags to their context. This feature is
/// deprecated and will be removed in a future GTK+ update. Please use style
/// classes instead.
///
/// GTK+ defines macros for a number of style regions.
///
/// # Custom styling in UI libraries and applications
///
/// If you are developing a library with custom `GtkWidgets` that
/// render differently than standard components, you may need to add a
/// [`StyleProvider`][crate::StyleProvider] yourself with the `GTK_STYLE_PROVIDER_PRIORITY_FALLBACK`
/// priority, either a [`CssProvider`][crate::CssProvider] or a custom object implementing the
/// [`StyleProvider`][crate::StyleProvider] interface. This way themes may still attempt
/// to style your UI elements in a different way if needed so.
///
/// If you are using custom styling on an applications, you probably want then
/// to make your style information prevail to the theme’s, so you must use
/// a [`StyleProvider`][crate::StyleProvider] with the `GTK_STYLE_PROVIDER_PRIORITY_APPLICATION`
/// priority, keep in mind that the user settings in
/// `XDG_CONFIG_HOME/gtk-3.0/gtk.css` will
/// still take precedence over your changes, as it uses the
/// `GTK_STYLE_PROVIDER_PRIORITY_USER` priority.
///
/// # Implements
///
/// [`StyleContextExt`][trait@crate::prelude::StyleContextExt], [`trait@glib::ObjectExt`], [`StyleContextExtManual`][trait@crate::prelude::StyleContextExtManual]
#[doc(alias = "GtkStyleContext")]
pub struct StyleContext(Object<ffi::GtkStyleContext, ffi::GtkStyleContextClass>);
match fn {
type_ => || ffi::gtk_style_context_get_type(),
}
}
impl StyleContext {
pub const NONE: Option<&'static StyleContext> = None;
/// Creates a standalone [`StyleContext`][crate::StyleContext], this style context
/// won’t be attached to any widget, so you may want
/// to call [`StyleContextExt::set_path()`][crate::prelude::StyleContextExt::set_path()] yourself.
///
/// This function is only useful when using the theming layer
/// separated from GTK+, if you are using [`StyleContext`][crate::StyleContext] to
/// theme `GtkWidgets`, use [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()]
/// in order to get a style context ready to theme the widget.
///
/// # Returns
///
/// A newly created [`StyleContext`][crate::StyleContext].
#[doc(alias = "gtk_style_context_new")]
pub fn new() -> StyleContext {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::gtk_style_context_new()) }
}
// rustdoc-stripper-ignore-next
/// Creates a new builder-pattern struct instance to construct [`StyleContext`] objects.
///
/// This method returns an instance of [`StyleContextBuilder`](crate::builders::StyleContextBuilder) which can be used to create [`StyleContext`] objects.
pub fn builder() -> StyleContextBuilder {
StyleContextBuilder::default()
}
/// Adds a global style provider to `screen`, which will be used
/// in style construction for all `GtkStyleContexts` under `screen`.
///
/// GTK+ uses this to make styling information from [`Settings`][crate::Settings]
/// available.
///
/// Note: If both priorities are the same, A [`StyleProvider`][crate::StyleProvider]
/// added through [`StyleContextExt::add_provider()`][crate::prelude::StyleContextExt::add_provider()] takes precedence
/// over another added through this function.
/// ## `screen`
/// a [`gdk::Screen`][crate::gdk::Screen]
/// ## `provider`
/// a [`StyleProvider`][crate::StyleProvider]
/// ## `priority`
/// the priority of the style provider. The lower
/// it is, the earlier it will be used in the style
/// construction. Typically this will be in the range
/// between `GTK_STYLE_PROVIDER_PRIORITY_FALLBACK` and
/// `GTK_STYLE_PROVIDER_PRIORITY_USER`
#[doc(alias = "gtk_style_context_add_provider_for_screen")]
pub fn add_provider_for_screen(
screen: &gdk::Screen,
provider: &impl IsA<StyleProvider>,
priority: u32,
) {
skip_assert_initialized!();
unsafe {
ffi::gtk_style_context_add_provider_for_screen(
screen.to_glib_none().0,
provider.as_ref().to_glib_none().0,
priority,
);
}
}
/// Removes `provider` from the global style providers list in `screen`.
/// ## `screen`
/// a [`gdk::Screen`][crate::gdk::Screen]
/// ## `provider`
/// a [`StyleProvider`][crate::StyleProvider]
#[doc(alias = "gtk_style_context_remove_provider_for_screen")]
pub fn remove_provider_for_screen(screen: &gdk::Screen, provider: &impl IsA<StyleProvider>) {
skip_assert_initialized!();
unsafe {
ffi::gtk_style_context_remove_provider_for_screen(
screen.to_glib_none().0,
provider.as_ref().to_glib_none().0,
);
}
}
/// This function recomputes the styles for all widgets under a particular
/// [`gdk::Screen`][crate::gdk::Screen]. This is useful when some global parameter has changed that
/// affects the appearance of all widgets, because when a widget gets a new
/// style, it will both redraw and recompute any cached information about
/// its appearance. As an example, it is used when the color scheme changes
/// in the related [`Settings`][crate::Settings] object.
/// ## `screen`
/// a [`gdk::Screen`][crate::gdk::Screen]
#[doc(alias = "gtk_style_context_reset_widgets")]
pub fn reset_widgets(screen: &gdk::Screen) {
assert_initialized_main_thread!();
unsafe {
ffi::gtk_style_context_reset_widgets(screen.to_glib_none().0);
}
}
}
impl Default for StyleContext {
fn default() -> Self {
Self::new()
}
}
#[derive(Clone, Default)]
// rustdoc-stripper-ignore-next
/// A [builder-pattern] type to construct [`StyleContext`] objects.
///
/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
#[must_use = "The builder must be built to be used"]
pub struct StyleContextBuilder {
direction: Option<TextDirection>,
paint_clock: Option<gdk::FrameClock>,
parent: Option<StyleContext>,
screen: Option<gdk::Screen>,
}
impl StyleContextBuilder {
// rustdoc-stripper-ignore-next
/// Create a new [`StyleContextBuilder`].
pub fn new() -> Self {
Self::default()
}
// rustdoc-stripper-ignore-next
/// Build the [`StyleContext`].
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> StyleContext {
let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
if let Some(ref direction) = self.direction {
properties.push(("direction", direction));
}
if let Some(ref paint_clock) = self.paint_clock {
properties.push(("paint-clock", paint_clock));
}
if let Some(ref parent) = self.parent {
properties.push(("parent", parent));
}
if let Some(ref screen) = self.screen {
properties.push(("screen", screen));
}
glib::Object::new::<StyleContext>(&properties)
.expect("Failed to create an instance of StyleContext")
}
pub fn direction(mut self, direction: TextDirection) -> Self {
self.direction = Some(direction);
self
}
pub fn paint_clock(mut self, paint_clock: &gdk::FrameClock) -> Self {
self.paint_clock = Some(paint_clock.clone());
self
}
/// Sets or gets the style context’s parent. See [`StyleContextExt::set_parent()`][crate::prelude::StyleContextExt::set_parent()]
/// for details.
pub fn parent(mut self, parent: &impl IsA<StyleContext>) -> Self {
self.parent = Some(parent.clone().upcast());
self
}
pub fn screen(mut self, screen: &gdk::Screen) -> Self {
self.screen = Some(screen.clone());
self
}
}
/// Trait containing all [`struct@StyleContext`] methods.
///
/// # Implementors
///
/// [`StyleContext`][struct@crate::StyleContext]
pub trait StyleContextExt: 'static {
/// Adds a style class to `self`, so posterior calls to
/// `gtk_style_context_get()` or any of the gtk_render_*()
/// functions will make use of this new class for styling.
///
/// In the CSS file format, a [`Entry`][crate::Entry] defining a “search”
/// class, would be matched by:
///
///
///
/// **⚠️ The following code is in CSS ⚠️**
///
/// ```CSS
/// entry.search { ... }
/// ```
///
/// While any widget defining a “search” class would be
/// matched by:
///
///
/// **⚠️ The following code is in CSS ⚠️**
///
/// ```CSS
/// .search { ... }
/// ```
/// ## `class_name`
/// class name to use in styling
#[doc(alias = "gtk_style_context_add_class")]
fn add_class(&self, class_name: &str);
/// Adds a style provider to `self`, to be used in style construction.
/// Note that a style provider added by this function only affects
/// the style of the widget to which `self` belongs. If you want
/// to affect the style of all widgets, use
/// [`StyleContext::add_provider_for_screen()`][crate::StyleContext::add_provider_for_screen()].
///
/// Note: If both priorities are the same, a [`StyleProvider`][crate::StyleProvider]
/// added through this function takes precedence over another added
/// through [`StyleContext::add_provider_for_screen()`][crate::StyleContext::add_provider_for_screen()].
/// ## `provider`
/// a [`StyleProvider`][crate::StyleProvider]
/// ## `priority`
/// the priority of the style provider. The lower
/// it is, the earlier it will be used in the style
/// construction. Typically this will be in the range
/// between `GTK_STYLE_PROVIDER_PRIORITY_FALLBACK` and
/// `GTK_STYLE_PROVIDER_PRIORITY_USER`
#[doc(alias = "gtk_style_context_add_provider")]
fn add_provider(&self, provider: &impl IsA<StyleProvider>, priority: u32);
/// Gets the border for a given state as a [`Border`][crate::Border].
///
/// See [`style_property_for_state()`][Self::style_property_for_state()] and
/// [`STYLE_PROPERTY_BORDER_WIDTH`][crate::STYLE_PROPERTY_BORDER_WIDTH] for details.
/// ## `state`
/// state to retrieve the border for
///
/// # Returns
///
///
/// ## `border`
/// return value for the border settings
#[doc(alias = "gtk_style_context_get_border")]
#[doc(alias = "get_border")]
fn border(&self, state: StateFlags) -> Border;
/// Gets the foreground color for a given state.
///
/// See [`style_property_for_state()`][Self::style_property_for_state()] and
/// [`STYLE_PROPERTY_COLOR`][crate::STYLE_PROPERTY_COLOR] for details.
/// ## `state`
/// state to retrieve the color for
///
/// # Returns
///
///
/// ## `color`
/// return value for the foreground color
#[doc(alias = "gtk_style_context_get_color")]
#[doc(alias = "get_color")]
fn color(&self, state: StateFlags) -> gdk::RGBA;
/// Returns the [`gdk::FrameClock`][crate::gdk::FrameClock] to which `self` is attached.
///
/// # Returns
///
/// a [`gdk::FrameClock`][crate::gdk::FrameClock], or [`None`]
/// if `self` does not have an attached frame clock.
#[doc(alias = "gtk_style_context_get_frame_clock")]
#[doc(alias = "get_frame_clock")]
fn frame_clock(&self) -> Option<gdk::FrameClock>;
/// Returns the sides where rendered elements connect visually with others.
///
/// # Returns
///
/// the junction sides
#[doc(alias = "gtk_style_context_get_junction_sides")]
#[doc(alias = "get_junction_sides")]
fn junction_sides(&self) -> JunctionSides;
/// Gets the margin for a given state as a [`Border`][crate::Border].
/// See `gtk_style_property_get()` and [`STYLE_PROPERTY_MARGIN`][crate::STYLE_PROPERTY_MARGIN]
/// for details.
/// ## `state`
/// state to retrieve the border for
///
/// # Returns
///
///
/// ## `margin`
/// return value for the margin settings
#[doc(alias = "gtk_style_context_get_margin")]
#[doc(alias = "get_margin")]
fn margin(&self, state: StateFlags) -> Border;
/// Gets the padding for a given state as a [`Border`][crate::Border].
/// See `gtk_style_context_get()` and [`STYLE_PROPERTY_PADDING`][crate::STYLE_PROPERTY_PADDING]
/// for details.
/// ## `state`
/// state to retrieve the padding for
///
/// # Returns
///
///
/// ## `padding`
/// return value for the padding settings
#[doc(alias = "gtk_style_context_get_padding")]
#[doc(alias = "get_padding")]
fn padding(&self, state: StateFlags) -> Border;
/// Gets the parent context set via [`set_parent()`][Self::set_parent()].
/// See that function for details.
///
/// # Returns
///
/// the parent context or [`None`]
#[doc(alias = "gtk_style_context_get_parent")]
#[doc(alias = "get_parent")]
#[must_use]
fn parent(&self) -> Option<StyleContext>;
/// Returns the widget path used for style matching.
///
/// # Returns
///
/// A [`WidgetPath`][crate::WidgetPath]
#[doc(alias = "gtk_style_context_get_path")]
#[doc(alias = "get_path")]
fn path(&self) -> Option<WidgetPath>;
/// Gets a style property from `self` for the given state.
///
/// Note that not all CSS properties that are supported by GTK+ can be
/// retrieved in this way, since they may not be representable as [`glib::Value`][crate::glib::Value].
/// GTK+ defines macros for a number of properties that can be used
/// with this function.
///
/// Note that passing a state other than the current state of `self`
/// is not recommended unless the style context has been saved with
/// [`save()`][Self::save()].
///
/// When `value` is no longer needed, [`glib::Value::unset()`][crate::glib::Value::unset()] must be called
/// to free any allocated memory.
/// ## `property`
/// style property name
/// ## `state`
/// state to retrieve the property value for
///
/// # Returns
///
///
/// ## `value`
/// return location for the style property value
#[doc(alias = "gtk_style_context_get_property")]
#[doc(alias = "get_property")]
fn style_property_for_state(&self, property: &str, state: StateFlags) -> glib::Value;
/// Returns the scale used for assets.
///
/// # Returns
///
/// the scale
#[doc(alias = "gtk_style_context_get_scale")]
#[doc(alias = "get_scale")]
fn scale(&self) -> i32;
/// Returns the [`gdk::Screen`][crate::gdk::Screen] to which `self` is attached.
///
/// # Returns
///
/// a [`gdk::Screen`][crate::gdk::Screen].
#[doc(alias = "gtk_style_context_get_screen")]
#[doc(alias = "get_screen")]
fn screen(&self) -> Option<gdk::Screen>;
/// Queries the location in the CSS where `property` was defined for the
/// current `self`. Note that the state to be queried is taken from
/// [`state()`][Self::state()].
///
/// If the location is not available, [`None`] will be returned. The
/// location might not be available for various reasons, such as the
/// property being overridden, `property` not naming a supported CSS
/// property or tracking of definitions being disabled for performance
/// reasons.
///
/// Shorthand CSS properties cannot be queried for a location and will
/// always return [`None`].
/// ## `property`
/// style property name
///
/// # Returns
///
/// [`None`] or the section where a value
/// for `property` was defined
#[doc(alias = "gtk_style_context_get_section")]
#[doc(alias = "get_section")]
fn section(&self, property: &str) -> Option<CssSection>;
/// Returns the state used for style matching.
///
/// This method should only be used to retrieve the [`StateFlags`][crate::StateFlags]
/// to pass to [`StyleContext`][crate::StyleContext] methods, like [`padding()`][Self::padding()].
/// If you need to retrieve the current state of a [`Widget`][crate::Widget], use
/// [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
///
/// # Returns
///
/// the state flags
#[doc(alias = "gtk_style_context_get_state")]
#[doc(alias = "get_state")]
fn state(&self) -> StateFlags;
//#[doc(alias = "gtk_style_context_get_style")]
//#[doc(alias = "get_style")]
//fn style(&self, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs);
/// Gets the value for a widget style property.
///
/// When `value` is no longer needed, [`glib::Value::unset()`][crate::glib::Value::unset()] must be called
/// to free any allocated memory.
/// ## `property_name`
/// the name of the widget style property
///
/// # Returns
///
///
/// ## `value`
/// Return location for the property value
#[doc(alias = "gtk_style_context_get_style_property")]
#[doc(alias = "get_style_property")]
fn style_property(&self, property_name: &str) -> glib::Value;
//#[doc(alias = "gtk_style_context_get_style_valist")]
//#[doc(alias = "get_style_valist")]
//fn style_valist(&self, args: /*Unknown conversion*//*Unimplemented*/Unsupported);
//#[doc(alias = "gtk_style_context_get_valist")]
//#[doc(alias = "get_valist")]
//fn valist(&self, state: StateFlags, args: /*Unknown conversion*//*Unimplemented*/Unsupported);
/// Returns [`true`] if `self` currently has defined the
/// given class name.
/// ## `class_name`
/// a class name
///
/// # Returns
///
/// [`true`] if `self` has `class_name` defined
#[doc(alias = "gtk_style_context_has_class")]
fn has_class(&self, class_name: &str) -> bool;
/// Returns the list of classes currently defined in `self`.
///
/// # Returns
///
/// a `GList` of
/// strings with the currently defined classes. The contents
/// of the list are owned by GTK+, but you must free the list
/// itself with `g_list_free()` when you are done with it.
#[doc(alias = "gtk_style_context_list_classes")]
fn list_classes(&self) -> Vec<glib::GString>;
/// Looks up and resolves a color name in the `self` color map.
/// ## `color_name`
/// color name to lookup
///
/// # Returns
///
/// [`true`] if `color_name` was found and resolved, [`false`] otherwise
///
/// ## `color`
/// Return location for the looked up color
#[doc(alias = "gtk_style_context_lookup_color")]
fn lookup_color(&self, color_name: &str) -> Option<gdk::RGBA>;
/// Removes `class_name` from `self`.
/// ## `class_name`
/// class name to remove
#[doc(alias = "gtk_style_context_remove_class")]
fn remove_class(&self, class_name: &str);
/// Removes `provider` from the style providers list in `self`.
/// ## `provider`
/// a [`StyleProvider`][crate::StyleProvider]
#[doc(alias = "gtk_style_context_remove_provider")]
fn remove_provider(&self, provider: &impl IsA<StyleProvider>);
/// Restores `self` state to a previous stage.
/// See [`save()`][Self::save()].
#[doc(alias = "gtk_style_context_restore")]
fn restore(&self);
/// Saves the `self` state, so temporary modifications done through
/// [`add_class()`][Self::add_class()], [`remove_class()`][Self::remove_class()],
/// [`set_state()`][Self::set_state()], etc. can quickly be reverted
/// in one go through [`restore()`][Self::restore()].
///
/// The matching call to [`restore()`][Self::restore()] must be done
/// before GTK returns to the main loop.
#[doc(alias = "gtk_style_context_save")]
fn save(&self);
/// Attaches `self` to the given frame clock.
///
/// The frame clock is used for the timing of animations.
///
/// If you are using a [`StyleContext`][crate::StyleContext] returned from
/// [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()], you do not need to
/// call this yourself.
/// ## `frame_clock`
/// a [`gdk::FrameClock`][crate::gdk::FrameClock]
#[doc(alias = "gtk_style_context_set_frame_clock")]
fn set_frame_clock(&self, frame_clock: &gdk::FrameClock);
/// Sets the sides where rendered elements (mostly through
/// [`render_frame()`][crate::render_frame()]) will visually connect with other visual elements.
///
/// This is merely a hint that may or may not be honored
/// by themes.
///
/// Container widgets are expected to set junction hints as appropriate
/// for their children, so it should not normally be necessary to call
/// this function manually.
/// ## `sides`
/// sides where rendered elements are visually connected to
/// other elements
#[doc(alias = "gtk_style_context_set_junction_sides")]
fn set_junction_sides(&self, sides: JunctionSides);
/// Sets the parent style context for `self`. The parent style
/// context is used to implement
/// [inheritance](http://www.w3.org/TR/css3-cascade/`inheritance`)
/// of properties.
///
/// If you are using a [`StyleContext`][crate::StyleContext] returned from
/// [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()], the parent will be set for you.
/// ## `parent`
/// the new parent or [`None`]
#[doc(alias = "gtk_style_context_set_parent")]
fn set_parent(&self, parent: Option<&impl IsA<StyleContext>>);
/// Sets the [`WidgetPath`][crate::WidgetPath] used for style matching. As a
/// consequence, the style will be regenerated to match
/// the new given path.
///
/// If you are using a [`StyleContext`][crate::StyleContext] returned from
/// [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()], you do not need to call
/// this yourself.
/// ## `path`
/// a [`WidgetPath`][crate::WidgetPath]
#[doc(alias = "gtk_style_context_set_path")]
fn set_path(&self, path: &WidgetPath);
/// Sets the scale to use when getting image assets for the style.
/// ## `scale`
/// scale
#[doc(alias = "gtk_style_context_set_scale")]
fn set_scale(&self, scale: i32);
/// Attaches `self` to the given screen.
///
/// The screen is used to add style information from “global” style
/// providers, such as the screen’s [`Settings`][crate::Settings] instance.
///
/// If you are using a [`StyleContext`][crate::StyleContext] returned from
/// [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()], you do not need to
/// call this yourself.
/// ## `screen`
/// a [`gdk::Screen`][crate::gdk::Screen]
#[doc(alias = "gtk_style_context_set_screen")]
fn set_screen(&self, screen: &gdk::Screen);
/// Sets the state to be used for style matching.
/// ## `flags`
/// state to represent
#[doc(alias = "gtk_style_context_set_state")]
fn set_state(&self, flags: StateFlags);
/// Converts the style context into a string representation.
///
/// The string representation always includes information about
/// the name, state, id, visibility and style classes of the CSS
/// node that is backing `self`. Depending on the flags, more
/// information may be included.
///
/// This function is intended for testing and debugging of the
/// CSS implementation in GTK+. There are no guarantees about
/// the format of the returned string, it may change.
/// ## `flags`
/// Flags that determine what to print
///
/// # Returns
///
/// a newly allocated string representing `self`
#[cfg(any(feature = "v3_20", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
#[doc(alias = "gtk_style_context_to_string")]
fn to_string(&self, flags: StyleContextPrintFlags) -> Option<glib::GString>;
fn direction(&self) -> TextDirection;
fn set_direction(&self, direction: TextDirection);
#[doc(alias = "paint-clock")]
fn paint_clock(&self) -> Option<gdk::FrameClock>;
#[doc(alias = "paint-clock")]
fn set_paint_clock(&self, paint_clock: Option<&gdk::FrameClock>);
/// The ::changed signal is emitted when there is a change in the
/// [`StyleContext`][crate::StyleContext].
///
/// For a [`StyleContext`][crate::StyleContext] returned by [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()], the
/// `signal::Widget::style-updated` signal/vfunc might be more convenient to use.
///
/// This signal is useful when using the theming layer standalone.
#[doc(alias = "changed")]
fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
#[doc(alias = "direction")]
fn connect_direction_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
#[doc(alias = "paint-clock")]
fn connect_paint_clock_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
#[doc(alias = "parent")]
fn connect_parent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
#[doc(alias = "screen")]
fn connect_screen_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<StyleContext>> StyleContextExt for O {
fn add_class(&self, class_name: &str) {
unsafe {
ffi::gtk_style_context_add_class(
self.as_ref().to_glib_none().0,
class_name.to_glib_none().0,
);
}
}
fn add_provider(&self, provider: &impl IsA<StyleProvider>, priority: u32) {
unsafe {
ffi::gtk_style_context_add_provider(
self.as_ref().to_glib_none().0,
provider.as_ref().to_glib_none().0,
priority,
);
}
}
fn border(&self, state: StateFlags) -> Border {
unsafe {
let mut border = Border::uninitialized();
ffi::gtk_style_context_get_border(
self.as_ref().to_glib_none().0,
state.into_glib(),
border.to_glib_none_mut().0,
);
border
}
}
fn color(&self, state: StateFlags) -> gdk::RGBA {
unsafe {
let mut color = gdk::RGBA::uninitialized();
ffi::gtk_style_context_get_color(
self.as_ref().to_glib_none().0,
state.into_glib(),
color.to_glib_none_mut().0,
);
color
}
}
fn frame_clock(&self) -> Option<gdk::FrameClock> {
unsafe {
from_glib_none(ffi::gtk_style_context_get_frame_clock(
self.as_ref().to_glib_none().0,
))
}
}
fn junction_sides(&self) -> JunctionSides {
unsafe {
from_glib(ffi::gtk_style_context_get_junction_sides(
self.as_ref().to_glib_none().0,
))
}
}
fn margin(&self, state: StateFlags) -> Border {
unsafe {
let mut margin = Border::uninitialized();
ffi::gtk_style_context_get_margin(
self.as_ref().to_glib_none().0,
state.into_glib(),
margin.to_glib_none_mut().0,
);
margin
}
}
fn padding(&self, state: StateFlags) -> Border {
unsafe {
let mut padding = Border::uninitialized();
ffi::gtk_style_context_get_padding(
self.as_ref().to_glib_none().0,
state.into_glib(),
padding.to_glib_none_mut().0,
);
padding
}
}
fn parent(&self) -> Option<StyleContext> {
unsafe {
from_glib_none(ffi::gtk_style_context_get_parent(
self.as_ref().to_glib_none().0,
))
}
}
fn path(&self) -> Option<WidgetPath> {
unsafe {
from_glib_none(ffi::gtk_style_context_get_path(
self.as_ref().to_glib_none().0,
))
}
}
fn style_property_for_state(&self, property: &str, state: StateFlags) -> glib::Value {
unsafe {
let mut value = glib::Value::uninitialized();
ffi::gtk_style_context_get_property(
self.as_ref().to_glib_none().0,
property.to_glib_none().0,
state.into_glib(),
value.to_glib_none_mut().0,
);
value
}
}
fn scale(&self) -> i32 {
unsafe { ffi::gtk_style_context_get_scale(self.as_ref().to_glib_none().0) }
}
fn screen(&self) -> Option<gdk::Screen> {
unsafe {
from_glib_none(ffi::gtk_style_context_get_screen(
self.as_ref().to_glib_none().0,
))
}
}
fn section(&self, property: &str) -> Option<CssSection> {
unsafe {
from_glib_none(ffi::gtk_style_context_get_section(
self.as_ref().to_glib_none().0,
property.to_glib_none().0,
))
}
}
fn state(&self) -> StateFlags {
unsafe {
from_glib(ffi::gtk_style_context_get_state(
self.as_ref().to_glib_none().0,
))
}
}
//fn style(&self, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
// unsafe { TODO: call ffi:gtk_style_context_get_style() }
//}
fn style_property(&self, property_name: &str) -> glib::Value {
unsafe {
let mut value = glib::Value::uninitialized();
ffi::gtk_style_context_get_style_property(
self.as_ref().to_glib_none().0,
property_name.to_glib_none().0,
value.to_glib_none_mut().0,
);
value
}
}
//fn style_valist(&self, args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
// unsafe { TODO: call ffi:gtk_style_context_get_style_valist() }
//}
//fn valist(&self, state: StateFlags, args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
// unsafe { TODO: call ffi:gtk_style_context_get_valist() }
//}
fn has_class(&self, class_name: &str) -> bool {
unsafe {
from_glib(ffi::gtk_style_context_has_class(
self.as_ref().to_glib_none().0,
class_name.to_glib_none().0,
))
}
}
fn list_classes(&self) -> Vec<glib::GString> {
unsafe {
FromGlibPtrContainer::from_glib_container(ffi::gtk_style_context_list_classes(
self.as_ref().to_glib_none().0,
))
}
}
fn lookup_color(&self, color_name: &str) -> Option<gdk::RGBA> {
unsafe {
let mut color = gdk::RGBA::uninitialized();
let ret = from_glib(ffi::gtk_style_context_lookup_color(
self.as_ref().to_glib_none().0,
color_name.to_glib_none().0,
color.to_glib_none_mut().0,
));
if ret {
Some(color)
} else {
None
}
}
}
fn remove_class(&self, class_name: &str) {
unsafe {
ffi::gtk_style_context_remove_class(
self.as_ref().to_glib_none().0,
class_name.to_glib_none().0,
);
}
}
fn remove_provider(&self, provider: &impl IsA<StyleProvider>) {
unsafe {
ffi::gtk_style_context_remove_provider(
self.as_ref().to_glib_none().0,
provider.as_ref().to_glib_none().0,
);
}
}
fn restore(&self) {
unsafe {
ffi::gtk_style_context_restore(self.as_ref().to_glib_none().0);
}
}
fn save(&self) {
unsafe {
ffi::gtk_style_context_save(self.as_ref().to_glib_none().0);
}
}
fn set_frame_clock(&self, frame_clock: &gdk::FrameClock) {
unsafe {
ffi::gtk_style_context_set_frame_clock(
self.as_ref().to_glib_none().0,
frame_clock.to_glib_none().0,
);
}
}
fn set_junction_sides(&self, sides: JunctionSides) {
unsafe {
ffi::gtk_style_context_set_junction_sides(
self.as_ref().to_glib_none().0,
sides.into_glib(),
);
}
}
fn set_parent(&self, parent: Option<&impl IsA<StyleContext>>) {
unsafe {
ffi::gtk_style_context_set_parent(
self.as_ref().to_glib_none().0,
parent.map(|p| p.as_ref()).to_glib_none().0,
);
}
}
fn set_path(&self, path: &WidgetPath) {
unsafe {
ffi::gtk_style_context_set_path(self.as_ref().to_glib_none().0, path.to_glib_none().0);
}
}
fn set_scale(&self, scale: i32) {
unsafe {
ffi::gtk_style_context_set_scale(self.as_ref().to_glib_none().0, scale);
}
}
fn set_screen(&self, screen: &gdk::Screen) {
unsafe {
ffi::gtk_style_context_set_screen(
self.as_ref().to_glib_none().0,
screen.to_glib_none().0,
);
}
}
fn set_state(&self, flags: StateFlags) {
unsafe {
ffi::gtk_style_context_set_state(self.as_ref().to_glib_none().0, flags.into_glib());
}
}
#[cfg(any(feature = "v3_20", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
fn to_string(&self, flags: StyleContextPrintFlags) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::gtk_style_context_to_string(
self.as_ref().to_glib_none().0,
flags.into_glib(),
))
}
}
fn direction(&self) -> TextDirection {
glib::ObjectExt::property(self.as_ref(), "direction")
}
fn set_direction(&self, direction: TextDirection) {
glib::ObjectExt::set_property(self.as_ref(), "direction", &direction)
}
fn paint_clock(&self) -> Option<gdk::FrameClock> {
glib::ObjectExt::property(self.as_ref(), "paint-clock")
}
fn set_paint_clock(&self, paint_clock: Option<&gdk::FrameClock>) {
glib::ObjectExt::set_property(self.as_ref(), "paint-clock", &paint_clock)
}
fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn changed_trampoline<P: IsA<StyleContext>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkStyleContext,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(StyleContext::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"changed\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
changed_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_direction_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_direction_trampoline<
P: IsA<StyleContext>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GtkStyleContext,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(StyleContext::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::direction\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_direction_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_paint_clock_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_paint_clock_trampoline<
P: IsA<StyleContext>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GtkStyleContext,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(StyleContext::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::paint-clock\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_paint_clock_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_parent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_parent_trampoline<P: IsA<StyleContext>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkStyleContext,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(StyleContext::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::parent\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_parent_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
fn connect_screen_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_screen_trampoline<P: IsA<StyleContext>, F: Fn(&P) + 'static>(
this: *mut ffi::GtkStyleContext,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(StyleContext::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::screen\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_screen_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl fmt::Display for StyleContext {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("StyleContext")
}
}