Re: Displaying a popup before the main window



Nicolas Courtel <courtel cena fr> writes:

the popup shows up empty, and
I can't figure out what I've done wrong.

It's only drawn when a map/expose/etc comes back from the server, by
which time you're off doing other things.

A window with a background pixmap can show without any action from the
app program.  Eg. per below, except that recent gtk has broken
set_cursor() on new windows like this, so you don't get the busy cursor.
It ought to send an XSetCursor, but for some reason waits to interact
with the server :-(.

Making the image is a bit tedious.  Is there a library to do a whole
temporary popup already?  You'd probably want a sub-window to avoid a
window resize tiling with the image.  Or turn that off in the wm hints,
or use 'popup' window type, or all three :).




#!/usr/bin/perl -w

use strict;
use Gtk2 -init;

my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file
  ('/usr/share/doc/libgtk2-perl-doc/examples/gtk-demo/apple-red.png');
my $width = $pixbuf->get_width;
my $height = $pixbuf->get_height;

my $popup = Gtk2::Window->new ('toplevel');
$popup->set_default_size ($width, $height);
$popup->realize;
my $win = $popup->window;
my $gc = $popup->style->bg_gc('normal');
my $pixmap = Gtk2::Gdk::Pixmap->new ($win, $width, $height, -1);
$pixmap->draw_rectangle ($gc, 1, 0,0, $width,$height); # clear
$pixmap->draw_pixbuf ($gc, $pixbuf, 0,0, 0,0, $width,$height, 'none', 0,0);
$win->set_back_pixmap ($pixmap);
$win->set_cursor (Gtk2::Gdk::Cursor->new('watch'));

$popup->show;
$popup->get_display->flush;
sleep 30;


my $window = Gtk2::Window->new;
$window->set_title ("My window");

my $label = Gtk2::Label->new ("Hello, world!");
$window->add ($label);

$popup->destroy;
$window->show_all;
Gtk2->main;



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