Re: Gtk RC file - How to set bagkground pixmap to only one window?

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

 



On Mon, 8 Dec 2008 12:13:41 +0530"Harinandan S" <harinandans@xxxxxxxxx> wrote:
>I want to set a background pixmap of only one window. I tried example rc>file but that sets background of all windows to the same image. I also tried>calling>gtk_widget_set_name (ui_home_window,"home window");
>in my rc file. I also loaded the rc file but I'm not seeing any changes. I>was able to set the same pixmap to all windows but how to set it only for>one window?>>Regards,>Harinandan S
See Tadej Borovšak's response to a similar question a few days ago,for a c example.
I'm only good at Perl, and this is how you would do it in Perl.The mainwindow has the default pixmap theme, but the toplevelhas a custom background image.
#!/usr/bin/perluse warnings;use strict;use Gtk2 '-init';
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 $entry = Gtk2::Entry->new();$vbox->pack_start( $entry, 0, 0, 5 );
my $red = Gtk2::Gdk::Color->new (0xFFFF,0x0000,0x0000);my $label = Gtk2::Label->new('Normal pixmap theme ');$label->modify_fg('normal', $red);$vbox->pack_start( $label, 0, 0, 5 );    # expand?, fill?, padding
my $button = Gtk2::Widget->new( "Gtk2::Button", label => "Quit" );$button->signal_connect( clicked => sub{exit} );$vbox->pack_start( $button, 0, 0, 5 );
my $button1 = Gtk2::Widget->new( "Gtk2::Button", label => "Launch new toplevel" );$button1->signal_connect( clicked => \&launch );$vbox->pack_start( $button1, 0, 0, 5 );
$window->show_all();
Gtk2->main;
sub launch{
 my $toplevel = Gtk2::Window->new; my $back_pixbuf =  Gtk2::Gdk::Pixbuf->new_from_file("1Zen16.png"); my ($pixmap,$mask) = $back_pixbuf->render_pixmap_and_mask(255); my $style = $toplevel->get_style(); $style=$style->copy(); $style->bg_pixmap("normal",$pixmap); $toplevel->set_style($style);   my $vbox = Gtk2::VBox->new();  $vbox->set( "border_width" => 10 );  $toplevel->add($vbox);
  my $entry = Gtk2::Entry->new();  $vbox->pack_start( $entry, 0, 0, 5 );
  my $white = Gtk2::Gdk::Color->new (0xFFFF,0xFFFF,0xFFFF);  my $label = Gtk2::Label->new('Custom pixmap override style');  $label->modify_fg('normal', $white);  $vbox->pack_start( $label, 0, 0, 5 );    # expand?, fill?, padding  $toplevel->show_all();}__END__

zentara
-- I'm not really a human, but I play one on earth.http://zentara.net/Remember_How_Lucky_You_Are.html _______________________________________________gtk-list mailing listgtk-list@xxxxxxxxxxxxx://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux