8 use lib
`fvwm-perllib dir`;
11 my $module = new FVWM
::Module
::Gtk
(
12 Name
=> "FvwmPerlGtkWinList",
13 Mask
=> M_WINDOW_NAME
| M_END_WINDOWLIST
| M_STRING
| M_ERROR
,
16 my $dialog = new Gtk
::Dialog
;
17 $dialog->set_title("Window List");
18 $dialog->set_border_width(4);
20 my $smode = 'single'; # initial selection mode, may be changed by user
21 my $clist = new_with_titles Gtk
::CList
(" Id" . " " x
13, " Name" . " " x
20);
22 $clist->set_selection_mode($smode);
23 $clist->signal_connect("click_column", \
&sortListByColumn
);
24 $dialog->vbox->add($clist);
26 my $creatingWindowList = 0;
27 sub requestWindowList
() {
28 $creatingWindowList = 1;
31 $module->send("Send_WindowList");
36 foreach ($clist->selection) {
37 $module->send($command, hex($clist->get_text($_, 0)));
41 sub sortListByColumn
($$) {
45 if ($column == $clist->sort_column()) {
46 if ($clist->sort_type() eq 'ascending') {
47 $clist->set_sort_type('descending');
49 $clist->set_sort_type('ascending');
52 $clist->set_sort_column($column);
57 my $button = new Gtk
::CheckButton
"Enable multiple selection";
58 $dialog->vbox->add($button);
59 $button->signal_connect("clicked", sub { $clist->set_selection_mode(
60 $smode = $smode eq 'multiple'?
'single': 'multiple'); });
62 my $hbox = new Gtk
::HBox
(1, 0);
63 $dialog->vbox->pack_end($hbox, 1, 1, 8);
65 $button = new Gtk
::Button
"Iconify";
66 $hbox->pack_start($button, 1, 1, 4);
67 $button->signal_connect("clicked", sub { doCommand
("Iconify"); });
69 $button = new Gtk
::Button
"WindowShade";
70 $hbox->pack_start($button, 1, 1, 4);
71 $button->signal_connect("clicked", sub { doCommand
("WindowShade"); });
73 $button = new Gtk
::Button
"Refresh";
74 $dialog->action_area->pack_start($button, 1, 1, 0);
75 $button->signal_connect("clicked", sub { requestWindowList
(); });
77 $button = new Gtk
::Button
"Quit";
78 $dialog->action_area->pack_start($button, 1, 1, 0);
79 $button->signal_connect("clicked", sub { Gtk
->main_quit; });
83 $module->addHandler(M_WINDOW_NAME
, sub {
84 my ($self, $event) = @_;
85 return unless $creatingWindowList;
86 $clist->append(sprintf("0x%07lx", $event->_win_id), $event->_name);
89 $module->addHandler(M_END_WINDOWLIST
, sub {
90 $creatingWindowList = 0;
94 $module->addHandler(M_STRING
, sub {
95 my $string = $_[1]->_text;
96 my $winid = $dialog->window->XWINDOW();
97 if ($string =~ /^close|stop|quit|exit/i) {
99 } elsif ($string =~ /^iconify|maximize|windowshade/i) {
100 $module->send($string, $winid)
102 $module->openErrorDialog("Unsupported message: $string");
106 $module->addDefaultErrorHandler;