trying to set the back ground



Just started playing around with the idea of setting the back ground
image on the desktop using GTK and I've been trying it using the code
listed below.

Unfortunately I have bit of a problem, blanks the screen and only
displays the image. After that windows are not displayed till
something is done to cause them to re-draw them selves.

Any ideas?




use Gtk2;
use warnings;
use strict;

my $file='/tmp/bg.jpg';

Gtk2->init;

my $screen=Gtk2::Gdk::Screen->get_default;
my $window=$screen->get_root_window;

my $pixbuf=Gtk2::Gdk::Pixbuf->new_from_file($file);

my ($pixmap, $mask)=$pixbuf->render_pixmap_and_mask(1);

my $atom_root=Gtk2::Gdk::Atom->intern("_XROOTMAP_ID", 1);
my $atom_eroot=Gtk2::Gdk::Atom->intern("ESETROOT_PMAP_ID", 1);

my $XA_PIXMAP=Gtk2::Gdk::Atom->intern('PIXMAP', 0);

#if the atoms already exist we need to do something...
if (defined($atom_root) && defined($atom_eroot)) {
        my $any=Gtk2::Gdk::Atom->intern("AnyPropertyType", 0);
        my ($type, $format, $data)=$window->property_get($atom_root,
$any, 0, 1, 0); }

$atom_eroot=Gtk2::Gdk::Atom->intern("_XROOTMAP_ID", 0);
$atom_eroot=Gtk2::Gdk::Atom->intern("ESETROOT_PMAP_ID", 0);

$window->property_change($atom_root, $XA_PIXMAP, 32, 'replace',
$pixmap, 1); $window->property_change($atom_eroot, $XA_PIXMAP, 32,
'replace', $pixmap, 1);

$window->set_back_pixmap($pixmap);
#$window->show_all;
$window->clear;
Gtk2->main_iteration while Gtk2->events_pending;

Attachment: signature.asc
Description: PGP signature



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