/usr/share/gps/library/createfile.py is in gnat-gps-common 6.1.1-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 | """
This plugin adds a new contextual menu in the Project View and editors, which
allow you to create a new file in the corresponding directory.
In some cases, this is more convenient than using the /File/New menu, and
then have to navigate to the directory in which you want to create the new
file.
"""
from GPS import *
import os.path
class Create_File_Contextual (Contextual):
def __init__(self):
Contextual.__init__(self, "Create File From Dir")
self.create(
on_activate=self.on_activate,
label=self.label,
filter=self.filter)
def label(self, context):
return "File operations/New File..."
def on_activate(self, context):
dir = context.directory()
name, = MDI.input_dialog(
"Enter file name (in directory \n%s)" % dir, "Name")
if name:
name = os.path.join(dir, name)
if not os.path.isfile(name):
f = file(name, "w")
f.write("")
f.close()
Project.recompute()
EditorBuffer.get(File(name))
def filter(self, context):
try:
dir = context.directory()
return True
except:
return False
Create_File_Contextual()
|