This is one of those areas where Gtk2's theme engine makes things tricky. Here are a couple of self-explanatory examples.
#!/usr/bin/perl
use warnings;
use strict;
use Gtk2 '-init';
#the Entry settings in ~/.gtkrc-2.0 dosn't
#seem to do anything except create a subtle outline
#under the entry box. So you need to manually make one.
Gtk2::Rc->parse_string(<<__);
#include "/usr/local/share/themes/Bumblebee/gtk-2.0/gtkrc"
style "normal" {
font_name ="serif 30"
}
style "my_entry" {
font_name ="sans 25"
text[NORMAL] = "#FF0000"
text[INSENSITIVE] = "#555555"
}
widget "*" style "normal"
widget "*Entry*" style "my_entry"
__
my $window = Gtk2::Window->new;
$window->set_title("Hello world");
$window->signal_connect( destroy => sub { Gtk2->main_quit; } );
my $vbox = Gtk2::VBox->new();
$vbox->set( "border_width" => 10 );
$window->add($vbox);
my $label = Gtk2::Label->new("ועפשץי");
$vbox->pack_start( $label, 0, 0, 5 ); # expand?, fill?, padding
my $entry = Gtk2::Entry->new();
$vbox->pack_start( $entry, 0, 0, 5 );
my $button = Gtk2::Widget->new( "Gtk2::Button", label => "Set Insensit
+ive" );
$button->signal_connect( clicked => sub { $entry->set_state('insensiti
+ve') } );
my $button1 = Gtk2::Widget->new( "Gtk2::Button", label => "Quit" );
$button1->signal_connect( clicked => sub { Gtk2->main_quit; } );
$vbox->pack_start( $button, 0, 0, 5 );
$vbox->pack_start( $button1, 0, 0, 5 );
$window->show_all();
Gtk2->main;
#!/usr/bin/perl
use warnings;
use strict;
use Gtk2 '-init';
#the Entry settings in ~/.gtkrc-2.0 dosn't
#seem to do anything except create a subtle outline
#under the entry box. So you need to manually make one.
Gtk2::Rc->parse_string(<<__);
include "/usr/local/share/themes/Bumblebee/gtk-2.0/gtkrc"
style "normal" {
font_name ="serif 30"
}
style "my_entry" {
font_name ="sans 25"
text[NORMAL] = "#FF0000"
}
widget "*" style "normal"
widget "*Entry*" style "my_entry"
__
my $window = Gtk2::Window->new;
$window->set_title("Hello world");
$window->signal_connect( destroy => sub { Gtk2->main_quit; } );
my $vbox = Gtk2::VBox->new();
$vbox->set( "border_width" => 10 );
$window->add($vbox);
my $label = Gtk2::Label->new("ועפשץי");
$vbox->pack_start( $label, 0, 0, 5 ); # expand?, fill?, padding
my $entry = Gtk2::Entry->new();
$vbox->pack_start( $entry, 0, 0, 5 );
my $button = Gtk2::Widget->new( "Gtk2::Button", label => "Quit" );
$button->signal_connect( clicked => sub { Gtk2->main_quit; } );
my $button1 = Gtk2::Widget->new( "Gtk2::Button", label => "Toggle Entr
+y Color" );
$button1->signal_connect( clicked => sub {
my ( $red, $green, $blue, $color);
( $red, $green, $blue) = (int rand 65535, int rand 65535,int ra
+nd 65535 );
$color = Gtk2::Gdk::Color->new ( $red, $green, $blue);
$entry->modify_text ( 'GTK_STATE_NORMAL', $color);
$entry->set_text ("$red $green $blue" );
} );
$vbox->pack_start( $button, 0, 0, 5 );
$vbox->pack_start( $button1, 0, 0, 5 );
$window->show_all();
Gtk2->main;
|