Add Run pshell menu item with terminal auto-detection
This commit is contained in:
parent
15256a982e
commit
f809a7b321
1 changed files with 22 additions and 0 deletions
22
kpadgtk3.pl
22
kpadgtk3.pl
|
@ -168,6 +168,19 @@ my $which_line_item = Gtk3::MenuItem->new_with_label('Which Line?');
|
|||
$which_line_item->signal_connect(activate => \&which_line_dialog);
|
||||
$tools_menu->append($which_line_item);
|
||||
|
||||
my $run_pshell = Gtk3::MenuItem->new_with_label('Run pshell');
|
||||
$run_pshell->signal_connect(activate => sub {
|
||||
my $pshell_path = "$basedir/pshell";
|
||||
my $terminal = find_terminal();
|
||||
if (-x $pshell_path) {
|
||||
system("$terminal -e $pshell_path &");
|
||||
$statusbar->push(0, "Launched pshell in $terminal");
|
||||
} else {
|
||||
$statusbar->push(0, "Error: pshell not found at $pshell_path");
|
||||
}
|
||||
});
|
||||
$tools_menu->append($run_pshell);
|
||||
|
||||
# HTML menu
|
||||
my $html_menu = Gtk3::Menu->new;
|
||||
my $html_item = Gtk3::MenuItem->new_with_label('HTML');
|
||||
|
@ -280,6 +293,15 @@ while (<*.kpd>) {
|
|||
}
|
||||
my $nop = grep { $_ ne 'auto' } @n;
|
||||
|
||||
# Find available terminal
|
||||
sub find_terminal {
|
||||
my @terminals = qw(gnome-terminal konsole xterm);
|
||||
for my $term (@terminals) {
|
||||
return $term if `which $term 2>/dev/null` =~ /\S/;
|
||||
}
|
||||
return 'xterm'; # Fallback
|
||||
}
|
||||
|
||||
# File handling
|
||||
sub open_file {
|
||||
my $dialog = Gtk3::FileChooserDialog->new(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue