line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Kephra::App::MenuBar; |
2
|
|
|
|
|
|
|
our $VERSION = 0.08; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
1102
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
433
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
my $bar; |
8
|
0
|
0
|
|
0
|
|
|
sub _ref { $bar = ref $_[0] eq 'Wx::MenuBar' ? $_[0] : $bar } |
9
|
0
|
|
|
0
|
|
|
sub _config { Kephra::API::settings()->{app}{menubar} } |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub create { |
12
|
0
|
|
|
0
|
0
|
|
my $menubar_def = Kephra::Config::File::load_from_node_data( _config() ); |
13
|
0
|
0
|
|
|
|
|
unless ($menubar_def) { |
14
|
0
|
|
|
|
|
|
$menubar_def = Kephra::Config::Default::mainmenu(); |
15
|
|
|
|
|
|
|
} |
16
|
0
|
|
|
|
|
|
my $menubar = Wx::MenuBar->new(); |
17
|
0
|
|
|
|
|
|
my $m18n = Kephra::Config::Localisation::strings()->{app}{menu}; |
18
|
0
|
|
|
|
|
|
my ($pos, $menu_name); |
19
|
0
|
|
|
|
|
|
for my $menu_def ( @$menubar_def ){ |
20
|
0
|
|
|
|
|
|
for my $menu_id (keys %$menu_def){ |
21
|
|
|
|
|
|
|
# removing the menu command if there is one |
22
|
0
|
|
|
|
|
|
$pos = index $menu_id, ' '; |
23
|
0
|
0
|
|
|
|
|
if ($pos > -1){ |
24
|
0
|
0
|
|
|
|
|
if ('menu' eq substr $menu_id, 0, $pos ){ |
25
|
0
|
|
|
|
|
|
$menu_name = substr ($menu_id, $pos+1); |
26
|
|
|
|
|
|
|
# ignoring menu structure when command other that menu or blank |
27
|
0
|
|
|
|
|
|
} else { next } |
28
|
|
|
|
|
|
|
} else { |
29
|
0
|
|
|
|
|
|
$menu_name = $menu_id; |
30
|
|
|
|
|
|
|
} |
31
|
0
|
|
|
|
|
|
$menubar->Append( |
32
|
|
|
|
|
|
|
Kephra::Menu::create_static( $menu_name, $menu_def->{$menu_id}), |
33
|
|
|
|
|
|
|
$m18n->{label}{$menu_name} |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
0
|
|
|
|
|
|
_ref($menubar); |
38
|
0
|
|
|
|
|
|
show(); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
0
|
0
|
|
sub get_visibility { _config()->{visible} } |
42
|
0
|
|
|
0
|
0
|
|
sub switch_visibility { _config()->{visible} ^= 1; show(); } |
|
0
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub show { |
44
|
0
|
0
|
|
0
|
0
|
|
Kephra::App::Window::_ref()->SetMenuBar( get_visibility() ? _ref() : undef ); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |