/usr/share/pyshared/ninja_ide/gui/menus/menu_file.py is in ninja-ide 2.3-2.
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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | # -*- coding: utf-8 -*-
#
# This file is part of NINJA-IDE (http://ninja-ide.org).
#
# NINJA-IDE is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# any later version.
#
# NINJA-IDE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NINJA-IDE; If not, see <http://www.gnu.org/licenses/>.
from __future__ import absolute_import
from PyQt4.QtGui import QIcon
from PyQt4.QtGui import QKeySequence
from PyQt4.QtGui import QStyle
from PyQt4.QtCore import QObject
from PyQt4.QtCore import SIGNAL
from ninja_ide import resources
class MenuFile(QObject):
###############################################################################
# MENU FILE SIGNALS
###############################################################################
"""
openFile(QString)
"""
###############################################################################
def __init__(self, menuFile, toolbar, ide):
QObject.__init__(self)
newAction = menuFile.addAction(QIcon(resources.IMAGES['new']),
(self.trUtf8("&New File (%s)") %
resources.get_shortcut("New-file").toString(
QKeySequence.NativeText)))
newProjectAction = menuFile.addAction(
QIcon(resources.IMAGES['newProj']),
(self.trUtf8("New Pro&ject (%s)") %
resources.get_shortcut("New-project").toString(
QKeySequence.NativeText)))
menuFile.addSeparator()
saveAction = menuFile.addAction(QIcon(resources.IMAGES['save']),
(self.trUtf8("&Save (%s)") %
resources.get_shortcut("Save-file").toString(
QKeySequence.NativeText)))
saveAsAction = menuFile.addAction(QIcon(resources.IMAGES['saveAs']),
self.trUtf8("Save &As"))
saveAllAction = menuFile.addAction(QIcon(resources.IMAGES['saveAll']),
self.trUtf8("Save All"))
saveProjectAction = menuFile.addAction(QIcon(
resources.IMAGES['saveAll']),
(self.trUtf8("Save Pro&ject (%s)") %
resources.get_shortcut("Save-project").toString(
QKeySequence.NativeText)))
menuFile.addSeparator()
reloadFileAction = menuFile.addAction(
QIcon(resources.IMAGES['reload-file']),
(self.trUtf8("Reload File (%s)") %
resources.get_shortcut("Reload-file").toString(
QKeySequence.NativeText)))
menuFile.addSeparator()
openAction = menuFile.addAction(QIcon(resources.IMAGES['open']),
(self.trUtf8("&Open (%s)") %
resources.get_shortcut("Open-file").toString(
QKeySequence.NativeText)))
openProjectAction = menuFile.addAction(
QIcon(resources.IMAGES['openProj']),
(self.trUtf8("Open &Project (%s)") %
resources.get_shortcut("Open-project").toString(
QKeySequence.NativeText)))
self.recent_files = menuFile.addMenu(self.trUtf8('Open Recent Files'))
menuFile.addSeparator()
activateProfileAction = menuFile.addAction(
QIcon(resources.IMAGES['activate-profile']),
self.trUtf8("Activate Profile"))
deactivateProfileAction = menuFile.addAction(
QIcon(resources.IMAGES['deactivate-profile']),
self.trUtf8("Deactivate Profile"))
menuFile.addSeparator()
printFile = menuFile.addAction(QIcon(resources.IMAGES['print']),
(self.trUtf8("Pr&int File (%s)") %
resources.get_shortcut("Print-file").toString(
QKeySequence.NativeText)))
closeAction = menuFile.addAction(
ide.style().standardIcon(QStyle.SP_DialogCloseButton),
(self.trUtf8("&Close Tab (%s)") %
resources.get_shortcut("Close-tab").toString(
QKeySequence.NativeText)))
closeProjectsAction = menuFile.addAction(
ide.style().standardIcon(QStyle.SP_DialogCloseButton),
self.trUtf8("&Close All Projects"))
menuFile.addSeparator()
exitAction = menuFile.addAction(
ide.style().standardIcon(QStyle.SP_DialogCloseButton),
self.trUtf8("&Exit"))
self.toolbar_items = {
'new-file': newAction,
'new-project': newProjectAction,
'save-file': saveAction,
'save-as': saveAsAction,
'save-all': saveAllAction,
'save-project': saveProjectAction,
'reload-file': reloadFileAction,
'open-file': openAction,
'open-project': openProjectAction,
'activate-profile': activateProfileAction,
'deactivate-profile': deactivateProfileAction,
'print-file': printFile,
'close-file': closeAction,
'close-projects': closeProjectsAction}
self.connect(newAction, SIGNAL("triggered()"),
ide.mainContainer.add_editor)
self.connect(newProjectAction, SIGNAL("triggered()"),
ide.explorer.create_new_project)
self.connect(openAction, SIGNAL("triggered()"),
ide.mainContainer.open_file)
self.connect(saveAction, SIGNAL("triggered()"),
ide.mainContainer.save_file)
self.connect(saveAsAction, SIGNAL("triggered()"),
ide.mainContainer.save_file_as)
self.connect(saveAllAction, SIGNAL("triggered()"),
ide.actions.save_all)
self.connect(saveProjectAction, SIGNAL("triggered()"),
ide.actions.save_project)
self.connect(openProjectAction, SIGNAL("triggered()"),
ide.explorer.open_project_folder)
self.connect(closeAction, SIGNAL("triggered()"),
ide.mainContainer.actualTab.close_tab)
self.connect(exitAction, SIGNAL("triggered()"),
ide.close)
QObject.connect(reloadFileAction, SIGNAL("triggered()"),
ide.mainContainer.reload_file)
self.connect(printFile, SIGNAL("triggered()"), ide.actions.print_file)
self.connect(closeProjectsAction, SIGNAL("triggered()"),
ide.explorer.close_opened_projects)
self.connect(deactivateProfileAction, SIGNAL("triggered()"),
ide.actions.deactivate_profile)
self.connect(activateProfileAction, SIGNAL("triggered()"),
ide.actions.activate_profile)
self.connect(self.recent_files, SIGNAL("triggered(QAction*)"),
self._open_file)
def update_recent_files(self, files):
"""Recreate the recent files menu."""
self.recent_files.clear()
for file_ in files:
self.recent_files.addAction(file_)
def _open_file(self, action):
"""Open the file selected in the recent files menu."""
path = action.text()
self.emit(SIGNAL("openFile(QString)"), path)
|