Skip to content

Commit

Permalink
When the Icon key is missing, or when the Icon key has an empty value…
Browse files Browse the repository at this point in the history
…, create an item without the `icon=""` field. (fixes #34)

Extends previous commit.
  • Loading branch information
trizen committed Nov 30, 2020
1 parent 720bb45 commit 19dbbb2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions obmenu-generator
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ if ($with_icons) {
}

sub begin_category {
if ($with_icons and defined(my $icon_path = check_icon($_[1]))) {
if ($with_icons and (my $icon_path = check_icon($_[1]))) {
<<"MENU_WITH_ICON";
<menu id="${\rand()}" icon="$icon_path" label="$_[0]">
MENU_WITH_ICON
Expand Down Expand Up @@ -564,7 +564,7 @@ foreach my $schema (@$SCHEMA) {
sort { $a->[0] cmp $b->[0] }
map [lc($_) => $_],
map {
$with_icons
($with_icons and $_->{Icon})
? <<"ITEM_WITH_ICON"
<item label="$_->{Name}" icon="$_->{Icon}"><action name="Execute"><command><![CDATA[$_->{Exec}]]></command></action></item>
ITEM_WITH_ICON
Expand All @@ -578,7 +578,7 @@ ITEM
}
elsif (exists $schema->{item}) {
my ($command, $label, $icon) = @{$schema->{item}};
if ($with_icons and defined(my $icon_path = check_icon($icon))) {
if ($with_icons and (my $icon_path = check_icon($icon))) {
$generated_menu .= <<"ITEM_WITH_ICON";
<item label="$label" icon="$icon_path"><action name="Execute"><command><![CDATA[$command]]></command></action></item>
ITEM_WITH_ICON
Expand Down Expand Up @@ -609,7 +609,7 @@ ITEM
}
elsif (exists $schema->{exit}) {
my ($label, $icon) = @{$schema->{exit}};
if ($with_icons and defined(my $icon_path = check_icon($icon))) {
if ($with_icons and (my $icon_path = check_icon($icon))) {
$generated_menu .= <<"EXIT_WITH_ICON";
<item label="$label" icon="$icon_path"><action name="Exit"/></item>
EXIT_WITH_ICON
Expand All @@ -629,7 +629,7 @@ EXIT
}
elsif (exists $schema->{pipe}) {
my ($command, $label, $icon) = @{$schema->{pipe}};
if ($with_icons and defined(my $icon_path = check_icon($icon))) {
if ($with_icons and (my $icon_path = check_icon($icon))) {
$generated_menu .= <<"PIPE_WITH_ICON";
<menu id="${\rand()}" label="$label" execute="$command" icon="$icon_path"/>
PIPE_WITH_ICON
Expand All @@ -642,7 +642,7 @@ PIPE
}
elsif (exists $schema->{obgenmenu}) {
my ($name, $icon) = ref($schema->{obgenmenu}) eq 'ARRAY' ? @{$schema->{obgenmenu}} : $schema->{obgenmenu};
if ($with_icons and defined(my $icon_path = check_icon($icon))) {
if ($with_icons and (my $icon_path = check_icon($icon))) {
$generated_menu .= <<"MENU_WITH_ICON";
<menu id="${\rand()}" label="$name" icon="$icon_path">
MENU_WITH_ICON
Expand Down

0 comments on commit 19dbbb2

Please sign in to comment.