6 use lib
`fvwm-perllib dir`;
10 my $module = new FVWM
::Module
::Gtk
(
11 Name
=> "FvwmPerlGtkWinList",
12 Mask
=> M_WINDOW_NAME
| M_END_WINDOWLIST
| M_STRING
| M_ERROR
,
15 my $dialog = new Gtk
::Dialog
;
16 $dialog->set_title("Window List");
17 $dialog->set_border_width(4);
19 my $smode = 'single'; # initial selection mode, may be changed by user
20 my $clist = new_with_titles Gtk
::CList
(" Id" . " " x
13, " Name" . " " x
20);
21 $clist->set_selection_mode($smode);
22 $clist->signal_connect("click_column", \
&sort_list_by_column
);
23 $dialog->vbox->add($clist);
25 my $creating_window_list = 0;
26 sub request_window_list
() {
27 $creating_window_list = 1;
30 $module->send("Send_WindowList");
35 foreach ($clist->selection) {
36 $module->send($command, hex($clist->get_text($_, 0)));
40 sub sort_list_by_column
($$) {
44 if ($column == $clist->sort_column()) {
45 if ($clist->sort_type() eq 'ascending') {
46 $clist->set_sort_type('descending');
48 $clist->set_sort_type('ascending');
51 $clist->set_sort_column($column);
56 my $button = new Gtk
::CheckButton
"Enable multiple selection";
57 $dialog->vbox->add($button);
58 $button->signal_connect("clicked", sub { $clist->set_selection_mode(
59 $smode = $smode eq 'multiple'?
'single': 'multiple'); });
61 my $hbox = new Gtk
::HBox
(1, 0);
62 $dialog->vbox->pack_end($hbox, 1, 1, 8);
64 $button = new Gtk
::Button
"Iconify";
65 $hbox->pack_start($button, 1, 1, 4);
66 $button->signal_connect("clicked", sub { do_command
("Iconify"); });
68 $button = new Gtk
::Button
"WindowShade";
69 $hbox->pack_start($button, 1, 1, 4);
70 $button->signal_connect("clicked", sub { do_command
("WindowShade"); });
72 $button = new Gtk
::Button
"Refresh";
73 $dialog->action_area->pack_start($button, 1, 1, 0);
74 $button->signal_connect("clicked", sub { request_window_list
(); });
76 $button = new Gtk
::Button
"Quit";
77 $dialog->action_area->pack_start($button, 1, 1, 0);
78 $button->signal_connect("clicked", sub { Gtk
->main_quit; });
82 $module->add_handler(M_WINDOW_NAME
, sub {
83 my ($self, $event) = @_;
84 return unless $creating_window_list;
85 $clist->append(sprintf("0x%07lx", $event->_win_id), $event->_name);
88 $module->add_handler(M_END_WINDOWLIST
, sub {
89 $creating_window_list = 0;
93 $module->add_handler(M_STRING
, sub {
94 my $string = $_[1]->_text;
95 my $winid = $dialog->window->XWINDOW();
96 if ($string =~ /^close|stop|quit|exit/i) {
98 } elsif ($string =~ /^iconify|maximize|windowshade/i) {
99 $module->send($string, $winid)
101 $module->open_error_dialog("Unsupported message: $string");
105 $module->add_default_error_handler;
107 request_window_list
();