menu.pm untested

filter: Statementstmt 0.0% 0 / 72 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 15 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 105 CC 4 SCAR 26.4
CC
4
Cov
0%
menu
20.0
BEGIN
2.0
BEGIN
2.0
CRAP 14.0
1 #* Copyright (C) 2008 Christian Guine
2 # * This program is free software; you can redistribute it and/or modify it
3 # * under the terms of the GNU General Public License as published by the Free
4 # * Software Fondation; either version 2 of the License, or (at your option)
5 # * any later version.
6 # * This program is distributed in the hope that it will be useful, but WITHOUT
7 # * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8 # * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
9 # * more details.
10 # * You should have received a copy of the GNU General Public License along with
11 # * this program; if not, write to the Free Software Foundation, Inc., 59
12 # * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
13 # */
14 # menu.pm menu management
15 sub menu {
16 use Games::Sudoku::affichgrille;
17 use Games::Sudoku::newgrille;
18 my ($origine) = @_;
19 #print "menu " . $origine . "\n";
20 # definition of menu
21 if ($origine ne "sudoku") {
22 $menubar -> destroy;
23 }
24 $menubar = $main->Frame;
25 $menubar->pack(
26 -fill => 'x');
27 # File menu
28 my $fichiermenu = $menubar->Menubutton(-text => tr1('Fichier'));
29 $fichiermenu->pack(
30 '-side' => 'left');
31  
32 #save
33 $fichiermenu->command(
34 -label => tr1('Sauver'),
35 -command => [\&sauve],
36 -accelerator => 'Ctrl+s'
37 );
38 $main->bind('<Control-s>' => [\&sauve]);
39
40 # Exit
41 $fichiermenu->command(
42 -label => tr1('Quitter'),
43 -command => [$main => 'destroy'],
44 -accelerator => 'Ctrl+q'
45 );
46 $main->bind('<Control-q>' => [$main => 'destroy']);
47
48 if ($origine eq "affichgrille" or $origine eq "affichgrilleS" or $origine eq "sudoku"
49 or $origine eq "V") {
50 # Options Menu
51 my $optionmenu = $menubar->Menubutton(-text => tr1('Options'));
52 $optionmenu->pack(
53 '-side' => 'left');
54 # resolve of a seized grid
55 $optionmenu->command(
56 -label => tr1('Resoudre une grille saisie'),
57 -command => [\&affichgrille,"R"],
58 -accelerator => 'Ctrl+s',
59 );
60 $main->bind('<Control-s>' => [\&affichgrille,"R"]);
61  
62 # ask for a new grid
63 $optionmenu->command(
64 -label => tr1('Demander une nouvelle grille'),
65 -command => [\&affichgrille,"C"],
66 -accelerator => 'Ctrl+r',
67 );
68 $main->bind('<Control-n>' => [\&affichgrille,"R"]);
69
70 # Creation of a new grid
71 $optionmenu->command(
72 -label => tr1('Creer une grille'),
73 -command => [\&creation_grille],
74 -accelerator => 'Ctrl+c',
75 );
76 my $text2 = tr1('Creer une grille') . ' C+c\n';
77 $main->bind('<Control-c>' => [\&creation_grille]);
78
79 if (($origine ne "affichgrilleS"
80 and $origine ne "sudoku") or $trait eq "V") {
81 # Solution
82 $optionmenu->command(
83 -label => tr1('Solution'),
84 -command => [\&solutiond,"S"],
85 -accelerator => 'Ctrl+s',
86 );
87 my $text3 = tr1('Solution') . 'C+s\n';
88 $main->bind('Control-s>' => [\&solutiond,"S"]);
89 }
90 }
91 # Drawing
92 my $dessinmenu = $menubar->Menubutton(-text => tr1('affichage'));
93 $dessinmenu->pack(
94 '-side' => 'left');
95 # selection of drawing of cases
96 $dessinmenu->radiobutton(-label => tr1('chiffres'),
97 -command => [sub{$dessin = "chiffres"}]);
98 $dessinmenu->radiobutton(-label => tr1('animaux'),
99 -command => [sub{$dessin = "animaux"}]);
100 $dessinmenu->radiobutton(-label => tr1('lettres'),
101 -command => [sub{$dessin = "lettres"}]);
102 $dessinmenu->radiobutton(-label => tr1('couleurs'),
103 -command => [sub{$dessin = "couleurs"}]);
104 # Language Menu
105 my $languemenu = $menubar->Menubutton(-text => tr1('Langues'));
106 $languemenu->pack(
107 '-side' => 'left');
108 # selection of languages
109 $languemenu->radiobutton(-label => tr1('français'),
110 -command => [\&changelang,"fr"]);
111 $languemenu->radiobutton(-label => tr1('anglais'),
112 -command => [\&changelang,"en"]);
113 $languemenu->radiobutton(-label => tr1('allemand'),
114 -command => [\&changelang,"ge"]);
115 $languemenu->radiobutton(-label => tr1('espagnol'),
116 -command => [\&changelang,"sp"]);
117 $languemenu->radiobutton(-label => tr1('italien'),
118 -command => [\&changelang,"it"]);
119 $languemenu->radiobutton(-label => tr1('portuguais'),
120 -command => [\&changelang,"pt"]);
121 }
122 1;