/usr/share/perl5/App/Asciio/Menues.pm is in asciio 1.02.71-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | package App::Asciio ;
$|++ ;
use strict;
use warnings;
use Data::TreeDumper ;
use Clone;
use List::Util qw(min max) ;
use List::MoreUtils qw(any minmax first_value) ;
use Eval::Context ;
use Glib ':constants';
use Gtk2 -init;
use Gtk2::Gdk::Keysyms ;
my %K = %Gtk2::Gdk::Keysyms ;
my %C = map{$K{$_} => $_} keys %K ;
#------------------------------------------------------------------------------------------------------
sub display_popup_menu
{
my ($self, $event) = @_;
my ($popup_x, $popup_y) = $event->coords() ;
my @menu_items ;
for my $element (@{$self->{ELEMENT_TYPES}})
{
(my $name_with_underscore = $element->{NAME}) =~ s/_/__/g ;
push @menu_items,
[ "/$name_with_underscore", undef , insert_generator($self, $element, $popup_x, $popup_y), 0 , '<Item>', undef],
}
for my $menu_entry (@{$self->get_context_menu_entries($popup_x, $popup_y)})
{
my($name, $sub, $data) = @{$menu_entry} ;
(my $name_with_underscore = $name) =~ s/_/__/g ;
push @menu_items, [ $name_with_underscore, undef , $self->menue_entry_wrapper($sub, $data), 0, '<Item>', undef],
}
push @menu_items,
(
['/File/open', undef , sub {$self->run_actions_by_name('Open') ;}, 0 , '<Item>', undef],
['/File/save', undef , sub {$self->run_actions_by_name('Save') ;}, 0 , '<Item>', undef],
[ '/File/save as', undef , sub {$self->run_actions_by_name(['Save', 1]) ;}, 0 , '<Item>', undef],
) ;
if($self->get_selected_elements(1) == 1)
{
push @menu_items, [ '/File/save stencil', undef , $self->menue_entry_wrapper(\&save_stencil), 0 , '<Item>', undef ] ;
}
my $item_factory = Gtk2::ItemFactory->new("Gtk2::Menu" ,"<popup>") ;
$item_factory ->create_items($self->{widget}, @menu_items) ;
my $menu = $item_factory->get_widget("<popup>") ;
$menu->popup(undef, undef, undef, undef, $event->button, $event->time) ;
}
sub insert_generator
{
my ($self, $element, $x, $y) = @_ ;
my ($character_width, $character_height) = $self->get_character_size() ;
return sub
{
$self->add_new_element_of_type($element, $self->closest_character($x, $y)) ;
$self->update_display();
} ;
}
sub menue_entry_wrapper
{
my ($self, $sub, $data) = @_ ;
return sub
{
$sub->($self, $data) ;
} ;
}
#------------------------------------------------------------------------------------------------------
my Readonly $SHORTCUTS = 0 ;
my Readonly $CODE = 1 ;
my Readonly $ARGUMENTS = 2 ;
my Readonly $CONTEXT_MENUE_SUB = 3 ;
my Readonly $CONTEXT_MENUE_ARGUMENTS = 4 ;
my Readonly $NAME= 5 ;
sub get_context_menu_entries
{
my ($self, $popup_x, $popup_y) = @_ ;
my @context_menu_entries ;
for my $context_menu_handler
(
map {$self->{CURRENT_ACTIONS}{$_}}
grep
{
'ARRAY' eq ref $self->{CURRENT_ACTIONS}{$_} # not a sub actions definition
&& defined $self->{CURRENT_ACTIONS}{$_}[$CONTEXT_MENUE_SUB]
} sort keys %{$self->{CURRENT_ACTIONS}}
)
{
#~ print "Adding context menue from action '$context_menu_handler->[$NAME]'.\n" ;
if(defined $context_menu_handler->[$CONTEXT_MENUE_ARGUMENTS])
{
push @context_menu_entries,
$context_menu_handler->[$CONTEXT_MENUE_SUB]->
(
$self,
$context_menu_handler->[$CONTEXT_MENUE_ARGUMENTS],
$popup_x, $popup_y,
) ;
}
else
{
push @context_menu_entries, $context_menu_handler->[$CONTEXT_MENUE_SUB]->($self, $popup_x, $popup_y) ;
}
}
return(\@context_menu_entries) ;
}
#------------------------------------------------------------------------------------------------------
1 ;
|