Restructure how we look for Read files slightly.
[fvwm.git] / tests / perl / show-commands
blobe8026320211c3f6eb278d7dd17aa3fbd2b304b2d
1 #!/usr/bin/perl
3 use strict;
4 use warnings;
6 use lib '../../perllib', '../perllib', 'perllib', `fvwm-perllib dir`;
7 use FVWM::Commands;
9 my $mode = shift || "--autodetect-gtk"; # -t|--text-only -x|--x-dialog
11 my $title = "Commands of fvwm-$FVWM::Commands::VERS";
12 my $commands_text = join('', map {
13 sprintf " %-21s - %s\n", $_->{name}, $_->{descr}
14 } @FVWM::Commands::LIST);
16 if ($mode =~ /-t/) {
17 print "$title:\n\n$commands_text";
18 exit;
21 if ($mode =~ /-x/ || !eval "use Gtk2 -init; 1;") {
22 require FVWM::Module::Toolkit;
23 FVWM::Module::Toolkit->show_message($commands_text, $title, 1);
24 exit;
27 my %cursor_to_stock_icon = (
28 '' => 'gtk-yes',
29 DESTROY => 'gtk-close',
30 SELECT => 'gtk-find',
31 RESIZE => 'gtk-fullscreen',
32 MOVE => 'gtk-leave-fullscreen',
35 my $command_entries = Gtk2::ListStore->new(('Glib::String') x 3);
36 foreach (@FVWM::Commands::LIST) {
37 $command_entries->set($command_entries->append,
38 0 => $cursor_to_stock_icon{$_->{cursor}} || 'gtk-no',
39 1 => $_->{name},
40 2 => $_->{descr},
44 my $combo_box = Gtk2::ComboBox->new($command_entries);
45 my $renderer = Gtk2::CellRendererPixbuf->new;
46 $combo_box->pack_start($renderer, 0);
47 $combo_box->add_attribute($renderer, stock_id => 0);
48 $renderer = Gtk2::CellRendererText->new;
49 $combo_box->pack_start($renderer, 1);
50 $combo_box->add_attribute($renderer, text => 1);
51 $renderer = Gtk2::CellRendererText->new;
52 $renderer->set(scale => 0.8);
53 $combo_box->pack_start($renderer, 0);
54 $combo_box->add_attribute($renderer, text => 2);
56 my $window = Gtk2::Dialog->new;
57 $window->set_title($title);
58 $window->add_button('gtk-close' => 'close');
59 $combo_box->show;
60 $window->vbox->add($combo_box);
61 $window->run;