Re: modify style in gtkperl

H. Pennington wrote a nice little primer, available at

It is written for C, though... so here's the basics of how to do it in
Perl.  Be sure to give it a read anyhow, since it touches on some (non
c-specific) important points.

# create a new Gtk::Gdk::Color instance.
$color = Gtk::Gdk::Color->parse_color("red");

# Aside note:
# You can optionally set the r, g, b values to whatever you want.
# These are 16-bit values.
# I've never done it this way, and am not sure how you'd get a color
# object in the first place.  Maybe create your own little constructor?:
# $color = bless { 'blue' => 0, 'green' => 0, 'red' => 0, pixel => 0},
#          'Gtk::Gdk::Color';

# Get the widget's colormap
$colormap = $widget->get_colormap();
# Allocate your $color in the colormap

# Create a new RcStyle object
$style = Gtk::RcStyle->new();

# Note that modify_color() wants a Gtk::RcFlags object as it's first
#   argument, but I'm not sure how to do this.  An array ref of text
#   flags seems to work. RcFlags (in C) is just an enum. See
#   for more info about styles, and their flags.
# You may need different flags here, depending on what you're doing.
$flags = [ 'fg', 'bg', 'text' ];

# the StateType can be any, we'll just use the current.
$state = $widget->state();
$style->modify_color($flags, $state, $color); 


On Wed, 2002-01-23 at 15:58, Max Moser wrote:
Hi there

I just want to know how to change a style of a widget. in the gtk references i saw modify style function.
I want to change the color of the progressbar depending on his value.

Any hints / samples how to do that in gtkperl?


Max Moser
gtk-perl-list mailing list
gtk-perl-list gnome org

@j=qw{-.2-2.- -2.4- -3.2-. -2.-.-2};
print map{s e(.)(\d)e$1x$2eeg;y.-.1.;y-.-0-;
chr unpack"N",pack"B32",substr'0'x32 .$_,-32} j;

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