[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: getting system background color



muppet <scott asofyet org> writes:

> Just ask the style object for it, e.g.
>
>     $bg = $style->bg ('normal');
>
> or
>
>     $bg = $label->get_style->bg ($label->state);
>
>
> Or, a little more obtusely:
>
>
> #!/usr/bin/perl -w
> use strict;
> use Gtk2 -init;
>
> my $window = Gtk2::Window->new;  # possibly unnecessary, but i'm lazy
> $window->ensure_style ();
> my $style = $window->get_style;
>
> my @states = map { $_->{nick} } Glib::Type->list_values  
> ('Gtk2::StateType');
>
> print join ' ', sprintf ("%12s", "color"), map { sprintf "%12s", $_ }  
> @states;
> print "\n";
> foreach my $which (qw(fg bg text base dark mid light)) {
> 	print join ' ',
> 	     sprintf ("%12s", $which),
> 	     map { sprintf "%12s", color_to_str ($style->$which ($_)) }  
> @states,
> 	     ;
> 	print "\n";
> }
>
> sub color_to_str {
> 	my ($color) = @_;
> 	return sprintf "#%02x%02x%02x",
> 	       	       $color->red >> 8, $color->green >> 8, $color->blue >> 8;
> }

Thank you for the help!

-- 
Radek




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]