Skip to content

Commit 19dbbb2

Browse files
committed
When the Icon key is missing, or when the Icon key has an empty value, create an item without the icon="" field. (fixes #34)
Extends previous commit.
1 parent 720bb45 commit 19dbbb2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

obmenu-generator

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ if ($with_icons) {
474474
}
475475

476476
sub begin_category {
477-
if ($with_icons and defined(my $icon_path = check_icon($_[1]))) {
477+
if ($with_icons and (my $icon_path = check_icon($_[1]))) {
478478
<<"MENU_WITH_ICON";
479479
<menu id="${\rand()}" icon="$icon_path" label="$_[0]">
480480
MENU_WITH_ICON
@@ -564,7 +564,7 @@ foreach my $schema (@$SCHEMA) {
564564
sort { $a->[0] cmp $b->[0] }
565565
map [lc($_) => $_],
566566
map {
567-
$with_icons
567+
($with_icons and $_->{Icon})
568568
? <<"ITEM_WITH_ICON"
569569
<item label="$_->{Name}" icon="$_->{Icon}"><action name="Execute"><command><![CDATA[$_->{Exec}]]></command></action></item>
570570
ITEM_WITH_ICON
@@ -578,7 +578,7 @@ ITEM
578578
}
579579
elsif (exists $schema->{item}) {
580580
my ($command, $label, $icon) = @{$schema->{item}};
581-
if ($with_icons and defined(my $icon_path = check_icon($icon))) {
581+
if ($with_icons and (my $icon_path = check_icon($icon))) {
582582
$generated_menu .= <<"ITEM_WITH_ICON";
583583
<item label="$label" icon="$icon_path"><action name="Execute"><command><![CDATA[$command]]></command></action></item>
584584
ITEM_WITH_ICON
@@ -609,7 +609,7 @@ ITEM
609609
}
610610
elsif (exists $schema->{exit}) {
611611
my ($label, $icon) = @{$schema->{exit}};
612-
if ($with_icons and defined(my $icon_path = check_icon($icon))) {
612+
if ($with_icons and (my $icon_path = check_icon($icon))) {
613613
$generated_menu .= <<"EXIT_WITH_ICON";
614614
<item label="$label" icon="$icon_path"><action name="Exit"/></item>
615615
EXIT_WITH_ICON
@@ -629,7 +629,7 @@ EXIT
629629
}
630630
elsif (exists $schema->{pipe}) {
631631
my ($command, $label, $icon) = @{$schema->{pipe}};
632-
if ($with_icons and defined(my $icon_path = check_icon($icon))) {
632+
if ($with_icons and (my $icon_path = check_icon($icon))) {
633633
$generated_menu .= <<"PIPE_WITH_ICON";
634634
<menu id="${\rand()}" label="$label" execute="$command" icon="$icon_path"/>
635635
PIPE_WITH_ICON
@@ -642,7 +642,7 @@ PIPE
642642
}
643643
elsif (exists $schema->{obgenmenu}) {
644644
my ($name, $icon) = ref($schema->{obgenmenu}) eq 'ARRAY' ? @{$schema->{obgenmenu}} : $schema->{obgenmenu};
645-
if ($with_icons and defined(my $icon_path = check_icon($icon))) {
645+
if ($with_icons and (my $icon_path = check_icon($icon))) {
646646
$generated_menu .= <<"MENU_WITH_ICON";
647647
<menu id="${\rand()}" label="$name" icon="$icon_path">
648648
MENU_WITH_ICON

0 commit comments

Comments
 (0)