### ----------------------------------------------------
### -- Gnome::Gtk3
### -- Licenses: Artistic-2.0
### -- Authors: Marcel Timmerman
### -- File: lib/Gnome/Gtk3/StyleContext.rakumod
### ----------------------------------------------------
### -- Chunk 1 of 4
#TL:1:Gnome::Gtk3::StyleContext:

use v6;
#-------------------------------------------------------------------------------
=begin pod

=head1 Gnome::Gtk3::StyleContext

Rendering UI elements

=head1 Description

B<Gnome::Gtk3::StyleContext> is an object that stores styling information affecting a widget.

In order to construct the final style information, B<Gnome::Gtk3::StyleContext> queries information from all attached B<Gnome::Gtk3::StyleProviders>. Style providers can be either attached explicitly to the context through C<add-provider()>, or to the screen through C<add-provider-for-screen()>. The resulting style is a combination of all providers’ information in priority order.

For GTK+ widgets, any B<Gnome::Gtk3::StyleContext> returned by C<Gnome::Gtk3::Widget.get-style-context()> will already have a B<Gnome::Gtk3::WidgetPath>, a B<Gnome::Gdk3::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 C<set_path()> and C<set_screen()>.
=comment TODO, such as a change in the property C<gtk-theme-name> setting or a hierarchy change in the rendered widget. See the “Foreign drawing“ example in gtk3-demo.

=head2 Style 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.

=begin comment
=head2 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.
=end comment

=head2 Custom styling in UI libraries and applications

If you are developing a library with custom B<Gnome::Gtk3::Widgets> that render differently than standard components, you may need to add a B<Gnome::Gtk3::StyleProvider> yourself with the C<GTK_STYLE_PROVIDER_PRIORITY_FALLBACK> priority, either a B<Gnome::Gtk3::CssProvider> or a custom object implementing the B<Gnome::Gtk3::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 application, you probably want then to make your style information prevail to the theme’s, so you must use a B<Gnome::Gtk3::StyleProvider> with the C<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 C<GTK_STYLE_PROVIDER_PRIORITY_USER> priority.

=head1 Synopsis
=head2 Declaration

  unit class Gnome::Gtk3::StyleContext;
  also is Gnome::GObject::Object;

=comment head2 Uml Diagram

=comment ![](plantuml/.svg)


=head2 Inheriting this class

Inheriting is done in a special way in that it needs a call from new() to get the native object created by the class you are inheriting from.

  use Gnome::Gtk3::StyleContext:api<1>;

  unit class MyGuiClass;
  also is Gnome::Gtk3::StyleContext;

  submethod new ( |c ) {
    # let the Gnome::Gtk3::StyleContext class process the options
    self.bless( :GtkStyleContext, |c);
  }

  submethod BUILD ( ... ) {
    ...
  }


=head2 Example

=end pod
#-------------------------------------------------------------------------------
use NativeCall;

use Gnome::N::X:api<1>;
use Gnome::N::N-GObject:api<1>;
use Gnome::N::NativeLib:api<1>;
use Gnome::N::GlibToRakuTypes:api<1>;

use Gnome::GObject::Object:api<1>;
use Gnome::GObject::Value:api<1>;

use Gnome::Glib::List:api<1>;

use Gnome::Gdk3::Screen:api<1>;
use Gnome::Gdk3::RGBA:api<1>;
use Gnome::Gdk3::Types:api<1>;

use Gnome::Gtk3::Border:api<1>;
use Gnome::Gtk3::Enums:api<1>;
use Gnome::Gtk3::WidgetPath:api<1>;

use Gnome::Cairo::Types:api<1>;
use Gnome::Cairo;

#-------------------------------------------------------------------------------
# See /usr/include/gtk-3.0/gtk/gtkstylecontext.h
# https://developer.gnome.org/gtk3/stable/GtkStyleContext.html
unit class Gnome::Gtk3::StyleContext:auth<github:MARTIMM>:api<1>;
also is Gnome::GObject::Object;

#-------------------------------------------------------------------------------
=begin pod
=head1 Types
=head2 GtkStyleContextPrintFlags

Flags that modify the behavior of gtk_style_context_to_string(). New values may be added to this enumeration.

=item GTK_STYLE_CONTEXT_PRINT_NONE;
=item GTK_STYLE_CONTEXT_PRINT_RECURSE; Print the entire tree of CSS nodes starting at the style context's node
=item GTK_STYLE_CONTEXT_PRINT_SHOW_STYLE; Show the values of the CSS properties for each node

=end pod

#TT:1:GtkStyleContextPrintFlags:
enum GtkStyleContextPrintFlags is export (
  GTK_STYLE_CONTEXT_PRINT_NONE         => 0,
  GTK_STYLE_CONTEXT_PRINT_RECURSE      => 1 +< 0,
  GTK_STYLE_CONTEXT_PRINT_SHOW_STYLE   => 1 +< 1
);


#-------------------------------------------------------------------------------
my Bool $signals-added = False;
#-------------------------------------------------------------------------------
=begin pod
=head1 Methods
=head2 new
=head3 default, no options

Create a new plain object. The value doesn't have to be True nor False. The name only will suffice.

  multi method new ( )


=head3 :native-object

Create a StyleContext object using a native object from elsewhere. See also B<Gnome::N::TopLevelClassSupport>.

  multi method new ( N-GObject :$native-object! )


=head3 :build-id

Create a StyleContext object using a native object returned from a builder. See also B<Gnome::GObject::Object>.

  multi method new ( Str :$build-id! )

=end pod

#TM:1:new():inheriting
#TM:1:new():
#TM:4:new(:native-object):Gnome::N::TopLevelClassSupport
#TM:4:new(:build-id):Gnome::GObject::Object
submethod BUILD ( *%options ) {

  $signals-added = self.add-signal-types( $?CLASS.^name,
    :w0<changed>,

    # signals from interfaces
    #_add_..._signal_types($?CLASS.^name);
  ) unless $signals-added;


  # prevent creating wrong native-objects
  if self.^name eq 'Gnome::Gtk3::StyleContext' or %options<GtkStyleContext> {

    # check if native object is set by a parent class
    if self.is-valid { }

    # check if common options are handled by some parent
    elsif %options<native-object>:exists { }
    elsif %options<build-id>:exists { }

    # process all other options
    else {
      my $no;
      if ? %options<___x___> {
        #$no = %options<___x___>;
        #$no .= _get-native-object-no-reffing unless $no ~~ N-GObject;
        #$no = _gtk_style_context_new___x___($no);
      }

      #`{{ use this when the module is not made inheritable
      # check if there are unknown options
      elsif %options.elems {
        die X::Gnome.new(
          :message(
            'Unsupported, undefined, incomplete or wrongly typed options for ' ~
            self.^name ~ ': ' ~ %options.keys.join(', ')
          )
        );
      }
      }}

      #`{{ when there are no defaults use this
      # check if there are any options
      elsif %options.elems == 0 {
        die X::Gnome.new(:message('No options specified ' ~ self.^name));
      }
      }}

      ##`{{ when there are defaults use this instead
      # create default object
      elsif %options<empty>:exists {
        Gnome::N::deprecate( 'new(:empty)', 'new()', '0.41.0', '0.45.0');
        $no = _gtk_style_context_new();
      }

      else {
        $no = _gtk_style_context_new();
      }
      #}}

      self._set-native-object($no);
    }

    # only after creating the native-object, the gtype is known
    self._set-class-info('GtkStyleContext');
  }
}

#-------------------------------------------------------------------------------
method _fallback ( $native-sub is copy --> Callable ) {

  my Callable $s;
  try { $s = &::("gtk_style_context_$native-sub"); };
  try { $s = &::("gtk_$native-sub"); } unless ?$s;
  try { $s = &::($native-sub); } if !$s and $native-sub ~~ m/^ 'gtk_' /;

  self._set-class-name-of-sub('GtkStyleContext');
  $s = callsame unless ?$s;

  $s
}


#-------------------------------------------------------------------------------
#TM:1:add-class:
=begin pod
=head2 add-class

Adds a style class to I<context>, so posterior calls to C<get()> or any of the gtk-render-*() functions will make use of this new class for styling.

In the CSS file format, a B<Gnome::Gtk3::Entry> defining a “search” class, would be matched by:

  entry.search { … }

While any widget defining a “search” class would be matched by:
=begin code
  .search { … }
=end code

=begin code
  method add-class ( Str $class_name )
=end code

=item Str $class_name; class name to use in styling
=end pod

method add-class ( Str $class_name ) {
  gtk_style_context_add_class( self._get-native-object-no-reffing, $class_name);
}

sub gtk_style_context_add_class (
  N-GObject $context, gchar-ptr $class_name
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:add-provider:
=begin pod
=head2 add-provider

Adds a style provider to I<context>, to be used in style construction. Note that a style provider added by this function only affects the style of the widget to which I<context> belongs. If you want to affect the style of all widgets, use C<add-provider-for-screen()>.

Note: If both priorities are the same, a B<Gnome::Gtk3::StyleProvider> added through this function takes precedence over another added through C<add-provider-for-screen()>.

  method add-provider ( N-GObject $provider, UInt $priority )

=item N-GObject $provider; a B<Gnome::Gtk3::StyleProvider>
=item UInt $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 C<GTK-STYLE-PROVIDER-PRIORITY-FALLBACK> and C<GTK-STYLE-PROVIDER-PRIORITY-USER>
=end pod

method add-provider ( $provider is copy, UInt $priority ) {
  $provider .= _get-native-object-no-reffing unless $provider ~~ N-GObject;

  gtk_style_context_add_provider(
    self._get-native-object-no-reffing, $provider, $priority
  );
}

sub gtk_style_context_add_provider (
  N-GObject $context, N-GObject $provider, guint $priority
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:add-provider-for-screen:
=begin pod
=head2 add-provider-for-screen

Adds a global style provider to I<screen>, which will be used in style construction for all B<Gnome::Gtk3::StyleContexts> under I<screen>.

GTK+ uses this to make styling information from B<Gnome::Gtk3::Settings> available.

Note: If both priorities are the same, A B<Gnome::Gtk3::StyleProvider> added through C<add-provider()> takes precedence over another added through this function.

  method add-provider-for-screen ( N-GObject $screen, N-GObject $provider, UInt $priority )

=item N-GObject $screen; a B<Gnome::Gtk3::Screen>
=item N-GObject $provider; a B<Gnome::Gtk3::StyleProvider>
=item UInt $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 C<GTK-STYLE-PROVIDER-PRIORITY-FALLBACK> and C<GTK-STYLE-PROVIDER-PRIORITY-USER>
=end pod

method add-provider-for-screen (
  $screen is copy, $provider is copy, UInt $priority
) {
  $screen .= _get-native-object-no-reffing unless $screen ~~ N-GObject;
  $provider .= _get-native-object-no-reffing unless $provider ~~ N-GObject;

  _gtk_style_context_add_provider_for_screen(
    $screen, $provider, $priority
  );
}


# needed to apply this trick to prevent a wrong interpretation of N-GObject
# $screen argument in test-call() from Gnome::N::X. It would be replaced by the
# N-GObject $context argument which is wrong.
sub gtk_style_context_add_provider_for_screen( |c ) is inlinable {
  _gtk_style_context_add_provider_for_screen(|c);
}


sub _gtk_style_context_add_provider_for_screen (
  N-GObject $screen, N-GObject $provider, guint $priority
) is native(&gtk-lib)
  is symbol('gtk_style_context_add_provider_for_screen')
  { * }

#`{{
#-------------------------------------------------------------------------------
#TM:0:get:
=begin pod
=head2 get

Retrieves several style property values from I<context> for a given state.

See C<get-property()> for details.

  method get ( UInt $state, List $properties --> List )

=item UInt $state; state to retrieve the property values for @...: property name /return value pairs, followed by C<undefined> GtkStateFlags
=end pod

method get ( UInt $state, List $properties --> List ) {

  # create parameter list and start with inserting fixed arguments
  my @parameterList = (
    Parameter.new(type => Str),         # $context
  }

# cannot do it because of differing types

#  gtk_style_context_get(
#    self._get-native-object-no-reffing, $state
#  );
}

#sub gtk_style_context_get (
#  N-GObject $context, GFlag $state, Any $any = Any
#) is native(&gtk-lib)
#  { * }
}}

#-------------------------------------------------------------------------------
#TM:1:get-border:
#TM:1:get-border-rk:
=begin pod
=head2 get-border, get-border-rk

Returns the border for a given state as a B<Gnome::Gtk3::Border>.
=comment See C<get-property()> and C<GTK_STYLE_PROPERTY_BORDER_WIDTH> for details.

  method get-border ( UInt $state --> N-GtkBorder )
  method get-border-rk ( UInt $state --> Gnome::Gtk3::Border )

=item UInt $state; state flags from GtkStateFlags to retrieve the border for
=end pod

method get-border ( UInt $state --> N-GtkBorder ) {
  my N-GtkBorder $border .= new;
  gtk_style_context_get_border(
    self._get-native-object-no-reffing, $state, $border
  );

  $border
}

method get-border-rk ( UInt $state --> Gnome::Gtk3::Border ) {
  my N-GtkBorder $border .= new;
  gtk_style_context_get_border(
    self._get-native-object-no-reffing, $state, $border
  );

  Gnome::Gtk3::Border.new(:native-object($border))
}

sub gtk_style_context_get_border (
  N-GObject $context, GFlag $state, N-GtkBorder $border
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:get-color:
#TM:1:get-color-rk:
=begin pod
=head2 get-color, get-color-rk

Returns the foreground color for a given state.

=comment See C<get-property()> and B<GTK_STYLE_PROPERTY_COLOR> for details.

  method get-color ( Uint $state --> N-GdkRGBA )
  method get-color-rk ( UInt $state --> Gnome::Gdk3::RGBA )

=item UInt $state; state flags from GtkStateFlags to retrieve the color for
=end pod

method get-color ( UInt $state --> N-GdkRGBA ) {
  my N-GdkRGBA $color .= new;
  gtk_style_context_get_color(
    self._get-native-object-no-reffing, $state, $color
  );

  $color
}

method get-color-rk ( UInt $state --> Gnome::Gdk3::RGBA ) {
  my N-GdkRGBA $color .= new;
  gtk_style_context_get_color(
    self._get-native-object-no-reffing, $state, $color
  );

  Gnome::Gdk3::RGBA.new(:native-object($color))
}

sub gtk_style_context_get_color (
  N-GObject $context, GFlag $state, N-GdkRGBA $color
) is native(&gtk-lib)
  { * }

#`{{
#-------------------------------------------------------------------------------
#TM:0:get-frame-clock:
=begin pod
=head2 get-frame-clock

Returns the B<Gnome::Gtk3::FrameClock> to which I<context> is attached.

Returns: a B<Gnome::Gtk3::FrameClock>, or C<undefined> if I<context> does not have an attached frame clock.

  method get-frame-clock ( --> N-GObject )

=end pod

method get-frame-clock ( --> N-GObject ) {
  gtk_style_context_get_frame_clock(
    self._get-native-object-no-reffing,
  )
}

sub gtk_style_context_get_frame_clock (
  N-GObject $context --> N-GObject
) is native(&gtk-lib)
  { * }
}}

#-------------------------------------------------------------------------------
#TM:1:get-junction-sides:
=begin pod
=head2 get-junction-sides

Returns the sides where rendered elements connect visually with others.

Returns: the junction sides mask. Bits are from GtkJunctionSides.

  method get-junction-sides ( --> UInt )

=end pod

method get-junction-sides ( --> UInt ) {
  gtk_style_context_get_junction_sides(self._get-native-object-no-reffing)
}

sub gtk_style_context_get_junction_sides (
  N-GObject $context --> GEnum
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:get-margin:
#TM:1:get-margin-rk:
=begin pod
=head2 get-margin, get-margin-rk

Returns the margin for a given state as a B<Gnome::Gtk3::Border>.
=comment See C<gtk-style-property-get()> and B<GTK_STYLE_PROPERTY_MARGIN> for details.

  method get-margin ( UInt $state --> N-GtkBorder )
  method get-margin-rk ( UInt $state --> Gnome::Gtk3::Border )

=item UInt $state; state flags from GtkStateFlags to retrieve the border for
=end pod

method get-margin ( UInt $state --> N-GtkBorder ) {
  my N-GtkBorder $margin .= new;
  gtk_style_context_get_margin(
    self._get-native-object-no-reffing, $state, $margin
  );

  $margin
}

method get-margin-rk ( UInt $state --> Gnome::Gtk3::Border ) {
  my N-GtkBorder $margin .= new;
  gtk_style_context_get_margin(
    self._get-native-object-no-reffing, $state, $margin
  );

  Gnome::Gtk3::Border.new(:native-object($margin))
}

sub gtk_style_context_get_margin (
  N-GObject $context, GFlag $state, N-GtkBorder $margin
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:get-padding:
#TM:1:get-padding-rk:
=begin pod
=head2 get-padding, get-padding-rk

Returns the padding for a given state as a B<Gnome::Gtk3::Border>.
=comment See C<get()> and B<GTK_STYLE_PROPERTY_PADDING> for details.

  method get-padding ( UInt $state --> N-GtkBorder )
  method get-padding-rk ( UInt $state --> Gnome::Gtk3::Border )

=item UInt $state; state  flags from GtkStateFlagsto retrieve the padding for
=end pod

method get-padding ( UInt $state --> N-GtkBorder ) {
  my N-GtkBorder $padding .= new;
  gtk_style_context_get_padding(
    self._get-native-object-no-reffing, $state, $padding
  );

  $padding
}

method get-padding-rk ( UInt $state --> Gnome::Gtk3::Border ) {
  my N-GtkBorder $padding .= new;
  gtk_style_context_get_padding(
    self._get-native-object-no-reffing, $state, $padding
  );

  Gnome::Gtk3::Border.new(:native-object($padding))
}

sub gtk_style_context_get_padding (
  N-GObject $context, GFlag $state, N-GtkBorder $padding
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:get-parent:
#TM:1:get-parent-rk:
=begin pod
=head2 get-parent, get-parent-rk

Gets the parent context set via C<set-parent()>. See that function for details.

Returns: the parent context or C<undefined>

  method get-parent ( --> N-GObject )
  method get-parent-rk ( --> Gnome::Gtk3::StyleContext )

=end pod

method get-parent ( --> N-GObject ) {
  gtk_style_context_get_parent(self._get-native-object-no-reffing)
}

method get-parent-rk ( --> Gnome::Gtk3::StyleContext ) {
  self._wrap-native-type-from-no(
    gtk_style_context_get_parent(self._get-native-object-no-reffing)
  )
}

sub gtk_style_context_get_parent (
  N-GObject $context --> N-GObject
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:get-path:
#TM:1:get-path-rk:
=begin pod
=head2 get-path, get-path-rk

Returns the widget path used for style matching.

Returns: A B<Gnome::Gtk3::WidgetPath>

  method get-path ( --> N-GObject )
  method get-path-rk ( --> Gnome::Gtk3::WidgetPath )

=end pod

method get-path ( --> N-GObject ) {
  gtk_style_context_get_path(self._get-native-object-no-reffing)
}

method get-path-rk ( --> Gnome::Gtk3::WidgetPath ) {
  Gnome::Gtk3::WidgetPath.new(
    :native-object(
      gtk_style_context_get_path(self._get-native-object-no-reffing)
    )
  )
}

sub gtk_style_context_get_path (
  N-GObject $context --> N-GObject
) is native(&gtk-lib)
  { * }

#`{{
#-------------------------------------------------------------------------------
#TM:1:get-property:
#TM:1:get-property-rk:
=begin pod
=head2 get-property

Gets a style property from I<context> 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 B<Gnome::Gtk3::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 I<context> is not recommended unless the style context has been saved with C<save()>.

When I<value> is no longer needed, C<clear-object()> must be called to free any allocated memory.

  method get-property ( Str $property, UInt $state --> N-GValue )
  method get-property-rk (
    Str $property, UInt $state --> Gnome::GObject::Value
  )

=item Str $property; style property name
=item UInt $state; state flags from GtkStateFlags to retrieve the property value for
=item N-GObject $value; return location for the style property value
=end pod

method get-property ( Str $property, UInt $state --> N-GValue ) {
  my N-GValue $value .= new;
  gtk_style_context_get_property(
    self._get-native-object-no-reffing, $property, $state, $value
  );

  N-GValue
}

method get-property-rk (
  Str $property, UInt $state --> Gnome::GObject::Value
) {
  my N-GValue $value .= new;
  gtk_style_context_get_property(
    self._get-native-object-no-reffing, $property, $state, $value
  );

  Gnome::GObject::Value.new(:native-object($value))
}

sub gtk_style_context_get_property (
  N-GObject $context, gchar-ptr $property, GFlag $state, N-GValue $value
) is native(&gtk-lib)
  { * }
}}

#-------------------------------------------------------------------------------
#TM:1:get-scale:
=begin pod
=head2 get-scale

Returns the scale used for assets.

Returns: the scale

  method get-scale ( --> Int )

=end pod

method get-scale ( --> Int ) {
  gtk_style_context_get_scale(self._get-native-object-no-reffing)
}

sub gtk_style_context_get_scale (
  N-GObject $context --> gint
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:get-screen:
#TM:1:get-screen-rk:
=begin pod
=head2 get-screen, get-screen-rk

Returns the B<Gnome::Gtk3::Screen> to which I<context> is attached.

Returns: a B<Gnome::Gtk3::Screen>.

  method get-screen ( --> N-GObject )
  method get-screen-rk ( --> Gnome::Gdk3::Screen )

=end pod

method get-screen ( --> N-GObject ) {
  gtk_style_context_get_screen(self._get-native-object-no-reffing)
}

method get-screen-rk ( --> Gnome::Gdk3::Screen ) {
  Gnome::Gdk3::Screen.new(
    :native-object(
      gtk_style_context_get_screen(self._get-native-object-no-reffing)
    )
  )
}

sub gtk_style_context_get_screen (
  N-GObject $context --> N-GObject
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:get-section:
#TM:1:get-section-rk:
=begin pod
=head2 get-section, get-section-rk

Queries the location in the CSS where I<$property> was defined for the current I<context>. Note that the state to be queried is taken from C<get-state()>.

If the location is not available, C<undefined> will be returned. The location might not be available for various reasons, such as the property being overridden, I<$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 C<undefined>.

Returns: C<undefined> or the section where a value for I<$property> was defined

  method get-section ( Str $property --> N-GObject )
  method get-section-rk ( Str $property --> Gnome::Gtk3::CssSection )

=item $property; style property name
=end pod

method get-section ( Str $property --> N-GObject ) {
  gtk_style_context_get_section(
    self._get-native-object-no-reffing, $property
  )
}

method get-section-rk ( Str $property --> Any:D ) {
  self._wrap-native-type(
    'Gnome::Gtk3::CssSection',
    gtk_style_context_get_section(
      self._get-native-object-no-reffing, $property
    )
  )
}

sub gtk_style_context_get_section (
  N-GObject $context, gchar-ptr $property --> N-GObject
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:get-state:
=begin pod
=head2 get-state

Returns the state used for style matching.

This method should only be used to retrieve the bit mask of GtkStateFlags to pass to B<Gnome::Gtk3::StyleContext> methods, like C<get-padding()>. If you need to retrieve the current state of a B<Gnome::Gtk3::Widget>, use C<Gnome::Gtk3::Widget.get-state-flags()>.

Returns: the state flags bit mask from C<GtkStateFlags>

  method get-state ( --> UInt )


=end pod

method get-state ( --> UInt ) {
  gtk_style_context_get_state(self._get-native-object-no-reffing)
}

sub gtk_style_context_get_state (
  N-GObject $context --> GFlag
) is native(&gtk-lib)
  { * }

#`{{
#-------------------------------------------------------------------------------
#TM:0:get-style:
=begin pod
=head2 get-style

Retrieves several widget style properties from I<context> according to the current style.

  method get-style ( )

=end pod

method get-style ( ) {

  gtk_style_context_get_style(
    self._get-native-object-no-reffing,
  );
}

sub gtk_style_context_get_style (
  N-GObject $context, Any $any = Any
) is native(&gtk-lib)
  { * }
}}

#-------------------------------------------------------------------------------
#TM:1:get-style-property:
#TM:1:get-style-property-rk:
=begin pod
=head2 get-style-property, get-style-property-rk

Gets the value for a widget style property.

When I<value> is no longer needed, C<g-value-unset()> must be called to free any allocated memory.

  method get-style-property ( Str $property_name --> N-GValue )
  method get-style-property-rk ( Str $property_name --> Gnome::GObject::Value )

=item Str $property_name; the name of the widget style property
=item N-GObject $value; Return location for the property value
=end pod

method get-style-property ( Str $property_name --> N-GValue ) {
  my N-GValue $value .= new;
  gtk_style_context_get_style_property(
    self._get-native-object-no-reffing, $property_name, $value
  );

  N-GValue
}

method get-style-property-rk ( Str $property_name --> Gnome::GObject::Value ) {
  my N-GValue $value .= new;
  gtk_style_context_get_style_property(
    self._get-native-object-no-reffing, $property_name, $value
  );

  Gnome::GObject::Value.new(:native-object($value))
}

sub gtk_style_context_get_style_property (
  N-GObject $context, gchar-ptr $property_name, N-GValue $value
) is native(&gtk-lib)
  { * }

#`{{
#-------------------------------------------------------------------------------
#TM:0:get-style-valist:
=begin pod
=head2 get-style-valist

Retrieves several widget style properties from I<context> according to the current style.

  method get-style-valist ( va_list $args )

=item va_list $args; va-list of property name/return location pairs, followed by C<undefined>
=end pod

method get-style-valist ( va_list $args ) {

  gtk_style_context_get_style_valist(
    self._get-native-object-no-reffing, $args
  );
}

sub gtk_style_context_get_style_valist (
  N-GObject $context, va_list $args
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-valist:
=begin pod
=head2 get-valist

Retrieves several style property values from I<context> for a given state.

See C<get-property()> for details.

  method get-valist ( UInt $state, va_list $args )

=item UInt $state; state flags from GtkStateFlags to retrieve the property values for
=item va_list $args; va-list of property name/return location pairs, followed by C<undefined>
=end pod

method get-valist ( UInt $state, va_list $args ) {

  gtk_style_context_get_valist(
    self._get-native-object-no-reffing, $state, $args
  );
}

sub gtk_style_context_get_valist (
  N-GObject $context, GFlag $state, va_list $args
) is native(&gtk-lib)
  { * }
}}
#`{{
#-------------------------------------------------------------------------------
#TM:0:gtk-render-insertion-cursor:
=begin pod
=head2 gtk-render-insertion-cursor

Draws a text caret on I<cr> at the specified index of I<layout>.

  method gtk-render-insertion-cursor ( cairo_t $cr, Num() $x, Num() $y, N-GObject $layout, Int() $index, PangoDirection $direction )

=item cairo_t $cr; a B<cairo-t>
=item Num() $x; X origin
=item Num() $y; Y origin
=item N-GObject $layout; the B<PangoLayout> of the text
=item Int() $index; the index in the B<PangoLayout>
=item PangoDirection $direction; the B<PangoDirection> of the text
=end pod

method gtk-render-insertion-cursor ( cairo_t $cr, Num() $x, Num() $y, $layout is copy, Int() $index, PangoDirection $direction ) {
  $layout .= _get-native-object-no-reffing unless $layout ~~ N-GObject;

  gtk_render_insertion_cursor(
    self._get-native-object-no-reffing, $cr, $x, $y, $layout, $index, $direction
  );
}

sub gtk_render_insertion_cursor (
  N-GObject $context, cairo_t $cr, gdouble $x, gdouble $y, N-GObject $layout, int $index, PangoDirection $direction
) is native(&gtk-lib)
  { * }
}}

#-------------------------------------------------------------------------------
#TM:1:has-class:
=begin pod
=head2 has-class

Returns C<True> if I<context> currently has defined the given class name.

Returns: C<True> if I<context> has I<class-name> defined

  method has-class ( Str $class_name --> Bool )

=item Str $class_name; a class name
=end pod

method has-class ( Str $class_name --> Bool ) {
  gtk_style_context_has_class(
    self._get-native-object-no-reffing, $class_name
  ).Bool
}

sub gtk_style_context_has_class (
  N-GObject $context, gchar-ptr $class_name --> gboolean
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:list-classes:
#TM:1:list-classes-rk:
=begin pod
=head2 list-classes, list-classes-rk

Returns the list of classes currently defined in I<context>.

Returns: a B<Gnome::Gtk3::List> of strings with the currently defined classes. The contents of the list are owned by GTK+, but you must free the list itself with C<clear-object()> when you are done with it.

  method list-classes ( --> N-GList )
  method list-classes-rk ( --> Gnome::Glib::List )

=end pod

method list-classes ( --> N-GList ) {
  gtk_style_context_list_classes(
    self._get-native-object-no-reffing,
  )
}

method list-classes-rk ( --> Gnome::Glib::List ) {
  Gnome::Glib::List.new(
    :native-object(
      gtk_style_context_list_classes(self._get-native-object-no-reffing)
    )
  )
}

sub gtk_style_context_list_classes (
  N-GObject $context --> N-GList
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:lookup-color:
#TM:1:lookup-color-rk:
=begin pod
=head2 lookup-color, lookup-color-rk

Looks up and resolves a color name in the I<context> color map.

Returns: N-GdkRGBA color if I<color-name> was found and resolved, undefined or invalid otherwise

  method lookup-color ( Str $color_name --> N-GdkRGBA )
  method lookup-color-rk ( Str $color_name --> Gnome::Gdk3::RGBA )

=item Str $color_name; color name to lookup
=end pod

method lookup-color ( Str $color_name --> N-GdkRGBA ) {
  my N-GdkRGBA $color .= new;
  gtk_style_context_lookup_color(
    self._get-native-object-no-reffing, $color_name, $color
  );

  $color
}

method lookup-color-rk ( Str $color_name --> Gnome::Gdk3::RGBA ) {
  my N-GdkRGBA $color .= new;
  gtk_style_context_lookup_color(
    self._get-native-object-no-reffing, $color_name, $color
  );

  Gnome::Gdk3::RGBA.new(:native-object($color))
}

sub gtk_style_context_lookup_color (
  N-GObject $context, gchar-ptr $color_name, N-GdkRGBA $color --> gboolean
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:remove-class:
=begin pod
=head2 remove-class

Removes I<class-name> from I<context>.

  method remove-class ( Str $class_name )

=item Str $class_name; class name to remove
=end pod

method remove-class ( Str $class_name ) {
  gtk_style_context_remove_class(
    self._get-native-object-no-reffing