my $testWindow = Gtk2::Window->new('toplevel');
$testWindow->set_title('my_test_window');
$testWindow->set_size_request(100, 100)
####
my $screen = Gnome2::Wnck::Screen->get(0);
$screen->force_update();
my @winList = $screen->get_windows();
####
foreach my $win (@winList) {
if ($win->get_name() eq 'my_test_window') {
# Success!
}
}
####
foreach my $win (@winList) {
if ($win->get_name() eq 'my_test_window') {
# Success!
my @geometryList = $win->get_client_window_geometry();
}
}
####
$wnckWin->move()
$wnckWin->resize()
$wnckWin->set_geometry()
####
$gtkWin->get_title()
$wnckWin->get_name()
####
#!/usr/bin/perl -w
use strict;
use warnings;
use diagnostics;
use Glib qw/TRUE FALSE/;
use Gtk2 '-init';
use Gnome2::Wnck;
# ##############################################################################
# Gnome2::Wnck test
#
# Creates ten Gtk2::Windows, each in a slightly different position
# Asks WNCK for a list of all open windows, and sees if our test window is among them
# This test fails, usually on the second or third window
#
# ##############################################################################
LOOP: for (my $count = 1; $count <= 10; $count++) {
# Each windows has a different title
my $title = 'my_test_window_' . $count;
# Create a Gtk2::Window
my $testWindow = Gtk2::Window->new('toplevel');
$testWindow->signal_connect('delete_event' => sub { exit; });
$testWindow->set_title($title);
$testWindow->set_size_request(100, 100);
$testWindow->show();
# Move each window to a different position than the previous one
$testWindow->move((50 * $count), (50 * $count));
# Now try to get the created window via WNCK
# Set up Gnome2::Wnck
Gtk2->main_iteration while Gtk2->events_pending;
my $screen = Gnome2::Wnck::Screen->get(0);
$screen->force_update();
# Get a list of all open windows
my @windowList = $screen->get_windows();
# Check each window, looking for the one named $title
foreach my $window (@windowList) {
if ($window->get_name() eq $title) {
print "Success! I found the right window!\n";
print "Window $window, named " . $window->get_name() . "\n";
next LOOP;
}
}
print "Failure! I couldn't find the window $title\n";
}
# Main event loop
Gtk2->main();