Skip to content

Commit 5d26a0f

Browse files
ogorodniksetton
andcommitted
Apply 1 suggestion(s) to 1 file(s)
Co-authored-by: Nicolas Setton <setton@adacore.com>
1 parent 2d26edc commit 5d26a0f

File tree

7 files changed

+76
-11
lines changed

7 files changed

+76
-11
lines changed

share/plug-ins/explorer.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
"""Contextual menu for Explorer
1+
"""Contextual menu: 'Open in system file explorer'
22
3-
This script provides a contextual menu for
4-
file or directory to open
5-
explorer in this directory.
3+
This plugin adds a contextual menu on files and directories in
4+
the Project View and File View, to reveal the object in the system
5+
file explorer.
66
77
"""
88

99
import os
10+
import sys
1011
import GPS
11-
import os_utils
1212
from gs_utils import interactive
1313
import subprocess
1414

@@ -21,17 +21,17 @@ def can_execute(context):
2121

2222

2323
@interactive(
24-
name="Locate in Explorer",
24+
name="Open in system file explorer",
2525
contextual="Open explorer",
2626
filter=can_execute
2727
)
2828
def on_activate():
2929
gps = os.environ.copy()
30-
sys = os.environ.copy()
30+
restored = os.environ.copy()
3131
for k in gps.keys():
3232
if k.startswith("GPS_STARTUP_"):
3333
if gps[k] != "_ABSENT_VARIABLE_":
34-
sys[k[12:]] = gps[k]
34+
restored[k[12:]] = gps[k]
3535

3636
path = GPS.current_context().directory()
3737

@@ -41,13 +41,13 @@ def on_activate():
4141
else:
4242
path = '.'
4343

44-
if os.name == "nt":
44+
if sys.platform == "win32":
4545
e = 'explorer.exe'
4646
path = '"' + path + '"'
4747
else:
4848
e = 'xdg-open'
4949

5050
try:
51-
subprocess.call([e, path], env=sys)
51+
subprocess.run([e, path], env=restored)
5252
except Exception as ex:
53-
GPS.Console().write(print (ex))
53+
GPS.Console().write(str(ex))
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
project Default is
2+
3+
package Compiler is
4+
for Switches ("Ada") use ("-g", "-O2");
5+
end Compiler;
6+
7+
for Main use ("main.adb");
8+
9+
end Default;
10+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
with Ada.Text_IO;
2+
3+
procedure Main is
4+
5+
procedure P1;
6+
procedure P2;
7+
8+
procedure P1 is
9+
Var : Boolean := False;
10+
begin
11+
P2;
12+
end P1;
13+
14+
procedure P2 is
15+
Var : Boolean := True;
16+
begin
17+
Ada.Text_IO.Put_Line ("Hello");
18+
end P2;
19+
20+
21+
begin
22+
P1;
23+
end Main;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
if [ "$OS" != "Windows_NT" ]; then
2+
export PATH=`pwd`:$PATH
3+
echo `pwd`/ > home.txt
4+
$GPS -Pdefault --load=python:test.py
5+
diff -u home.txt args.txt
6+
fi
7+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import GPS
2+
from gs_utils.internal.utils import *
3+
4+
"""
5+
Verify that 'Open in system file explorer' action
6+
works.
7+
8+
"""
9+
10+
11+
@run_test_driver
12+
def test_driver():
13+
prj_view = Project_View()
14+
yield prj_view.open_and_yield()
15+
explorer = get_widget_by_name("Project Explorer Tree")
16+
explorer.expand_row(Gtk.TreePath((0, 0)), True)
17+
prj_view.select_by_name(column=1, value="main.adb")
18+
yield wait_idle()
19+
GPS.execute_action("Open in system file explorer")
20+
yield wait_idle()
21+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
title: 'gs.530_open_explorer'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
echo "$1" > args.txt
3+

0 commit comments

Comments
 (0)