22 # Start-Of-Header |
22 # Start-Of-Header |
23 name = "Tabnanny Plugin" |
23 name = "Tabnanny Plugin" |
24 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
24 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
25 autoactivate = True |
25 autoactivate = True |
26 deactivateable = True |
26 deactivateable = True |
27 version = "5.4.0" |
27 version = "5.5.0" |
28 className = "TabnannyPlugin" |
28 className = "TabnannyPlugin" |
29 packageName = "__core__" |
29 packageName = "__core__" |
30 shortDescription = "Show the Tabnanny dialog." |
30 shortDescription = "Show the Tabnanny dialog." |
31 longDescription = """This plugin implements the Tabnanny dialog.""" \ |
31 longDescription = """This plugin implements the Tabnanny dialog.""" \ |
32 """ Tabnanny is used to check Python source files for correct""" \ |
32 """ Tabnanny is used to check Python source files for correct""" \ |
107 @return tuple of None and activation status (boolean) |
107 @return tuple of None and activation status (boolean) |
108 """ |
108 """ |
109 menu = e5App().getObject("Project").getMenu("Checks") |
109 menu = e5App().getObject("Project").getMenu("Checks") |
110 if menu: |
110 if menu: |
111 self.__projectAct = E5Action( |
111 self.__projectAct = E5Action( |
112 self.trUtf8('Check Indentations'), |
112 self.tr('Check Indentations'), |
113 self.trUtf8('&Indentations...'), 0, 0, |
113 self.tr('&Indentations...'), 0, 0, |
114 self, 'project_check_indentations') |
114 self, 'project_check_indentations') |
115 self.__projectAct.setStatusTip( |
115 self.__projectAct.setStatusTip( |
116 self.trUtf8('Check indentations using tabnanny.')) |
116 self.tr('Check indentations using tabnanny.')) |
117 self.__projectAct.setWhatsThis(self.trUtf8( |
117 self.__projectAct.setWhatsThis(self.tr( |
118 """<b>Check Indentations...</b>""" |
118 """<b>Check Indentations...</b>""" |
119 """<p>This checks Python files""" |
119 """<p>This checks Python files""" |
120 """ for bad indentations using tabnanny.</p>""" |
120 """ for bad indentations using tabnanny.</p>""" |
121 )) |
121 )) |
122 self.__projectAct.triggered[()].connect(self.__projectTabnanny) |
122 self.__projectAct.triggered.connect(self.__projectTabnanny) |
123 e5App().getObject("Project").addE5Actions([self.__projectAct]) |
123 e5App().getObject("Project").addE5Actions([self.__projectAct]) |
124 menu.addAction(self.__projectAct) |
124 menu.addAction(self.__projectAct) |
125 |
125 |
126 self.__editorAct = E5Action( |
126 self.__editorAct = E5Action( |
127 self.trUtf8('Check Indentations'), |
127 self.tr('Check Indentations'), |
128 self.trUtf8('&Indentations...'), 0, 0, |
128 self.tr('&Indentations...'), 0, 0, |
129 self, "") |
129 self, "") |
130 self.__editorAct.setWhatsThis(self.trUtf8( |
130 self.__editorAct.setWhatsThis(self.tr( |
131 """<b>Check Indentations...</b>""" |
131 """<b>Check Indentations...</b>""" |
132 """<p>This checks Python files""" |
132 """<p>This checks Python files""" |
133 """ for bad indentations using tabnanny.</p>""" |
133 """ for bad indentations using tabnanny.</p>""" |
134 )) |
134 )) |
135 self.__editorAct.triggered[()].connect(self.__editorTabnanny) |
135 self.__editorAct.triggered.connect(self.__editorTabnanny) |
136 |
136 |
137 e5App().getObject("Project").showMenu.connect(self.__projectShowMenu) |
137 e5App().getObject("Project").showMenu.connect(self.__projectShowMenu) |
138 e5App().getObject("ProjectBrowser").getProjectBrowser("sources")\ |
138 e5App().getObject("ProjectBrowser").getProjectBrowser("sources")\ |
139 .showMenu.connect(self.__projectBrowserShowMenu) |
139 .showMenu.connect(self.__projectBrowserShowMenu) |
140 e5App().getObject("ViewManager").editorOpenedEd.connect( |
140 e5App().getObject("ViewManager").editorOpenedEd.connect( |
202 e5App().getObject("Project").getProjectLanguage() in \ |
202 e5App().getObject("Project").getProjectLanguage() in \ |
203 ["Python3", "Python2", "Python"]: |
203 ["Python3", "Python2", "Python"]: |
204 self.__projectBrowserMenu = menu |
204 self.__projectBrowserMenu = menu |
205 if self.__projectBrowserAct is None: |
205 if self.__projectBrowserAct is None: |
206 self.__projectBrowserAct = E5Action( |
206 self.__projectBrowserAct = E5Action( |
207 self.trUtf8('Check Indentations'), |
207 self.tr('Check Indentations'), |
208 self.trUtf8('&Indentations...'), 0, 0, |
208 self.tr('&Indentations...'), 0, 0, |
209 self, "") |
209 self, "") |
210 self.__projectBrowserAct.setWhatsThis(self.trUtf8( |
210 self.__projectBrowserAct.setWhatsThis(self.tr( |
211 """<b>Check Indentations...</b>""" |
211 """<b>Check Indentations...</b>""" |
212 """<p>This checks Python files""" |
212 """<p>This checks Python files""" |
213 """ for bad indentations using tabnanny.</p>""" |
213 """ for bad indentations using tabnanny.</p>""" |
214 )) |
214 )) |
215 self.__projectBrowserAct.triggered[()].connect( |
215 self.__projectBrowserAct.triggered.connect( |
216 self.__projectBrowserTabnanny) |
216 self.__projectBrowserTabnanny) |
217 if not self.__projectBrowserAct in menu.actions(): |
217 if not self.__projectBrowserAct in menu.actions(): |
218 menu.addAction(self.__projectBrowserAct) |
218 menu.addAction(self.__projectBrowserAct) |
219 |
219 |
220 def __projectTabnanny(self): |
220 def __projectTabnanny(self): |
286 @param editor reference to the editor |
286 @param editor reference to the editor |
287 """ |
287 """ |
288 if menuName == "Checks": |
288 if menuName == "Checks": |
289 if not self.__editorAct in menu.actions(): |
289 if not self.__editorAct in menu.actions(): |
290 menu.addAction(self.__editorAct) |
290 menu.addAction(self.__editorAct) |
291 self.__editorAct.setEnabled(editor.getPyVersion()) |
291 self.__editorAct.setEnabled(editor.isPyFile()) |
292 |
292 |
293 def __editorTabnanny(self): |
293 def __editorTabnanny(self): |
294 """ |
294 """ |
295 Private slot to handle the tabnanny context menu action of the editors. |
295 Private slot to handle the tabnanny context menu action of the editors. |
296 """ |
296 """ |