PluginExtensionCorba.py

changeset 12
58b645cde6e3
parent 10
c88be5019d60
child 17
40f44cfcb661
--- a/PluginExtensionCorba.py	Sun Dec 11 11:17:15 2022 +0100
+++ b/PluginExtensionCorba.py	Mon Dec 12 16:43:08 2022 +0100
@@ -14,6 +14,7 @@
 from eric7 import Globals, Preferences
 from eric7.EricWidgets import EricMessageBox
 from eric7.EricWidgets.EricApplication import ericApp
+from ExtensionCorba import idlclbr
 from ExtensionCorba.ProjectInterfacesBrowser import ProjectInterfacesBrowser
 
 # Start-Of-Header
@@ -21,7 +22,7 @@
 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
 autoactivate = True
 deactivateable = True
-version = "10.0.2"
+version = "10.1.0"
 className = "CorbaExtensionPlugin"
 packageName = "ExtensionCorba"
 shortDescription = "Support for the development of CORBA projects"
@@ -95,9 +96,7 @@
     return {
         "corbaPage": [
             QCoreApplication.translate("CorbaExtensionPlugin", "CORBA"),
-            os.path.join(
-                "ExtensionCorba", "icons", "preferences-corba-{0}".format(iconSuffix)
-            ),
+            os.path.join("ExtensionCorba", "icons", "corba-{0}".format(iconSuffix)),
             createCorbaPage,
             None,
             None,
@@ -170,6 +169,9 @@
         @return tuple of None and activation status
         @rtype bool
         """
+        from eric7.QScintilla import Lexers
+        from eric7.Utilities import ClassBrowsers
+
         global error, corbaExtensionPluginObject
         error = ""  # clear previous error
 
@@ -178,6 +180,22 @@
 
             self.__browser = ProjectInterfacesBrowser(self)
 
+            iconSuffix = "dark" if ericApp().usesDarkPalette() else "light"
+            Lexers.registerLexer(
+                "IDL",
+                self.tr("IDL"),
+                "dummy.idl",
+                self.getLexer,
+                [self.tr("Corba IDL Files (*.idl)")],
+                [self.tr("Corba IDL Files (*.idl)")],
+                ["*.idl"],
+                os.path.join("ExtensionCorba", "icons", "corba-{0}".format(iconSuffix)),
+            )
+
+            ClassBrowsers.registerClassBrowser(
+                "IDL", idlclbr.readmodule_ex, idlclbr.scan, self.getFileIcon, [".idl"]
+            )
+
             return None, True
         else:
             EricMessageBox.warning(
@@ -199,6 +217,12 @@
         """
         Public method to deactivate this plug-in.
         """
+        from eric7.QScintilla import Lexers
+        from eric7.Utilities import ClassBrowsers
+
+        Lexers.unregisterLexer("IDL")
+        ClassBrowsers.registerClassBrowser("IDL")
+
         self.__browser.deactivate()
 
         self.__initialize()
@@ -250,6 +274,31 @@
         """
         Preferences.Prefs.settings.setValue(self.PreferencesKey + "/" + key, value)
 
+    def getLexer(self, parent=None):
+        """
+        Public method to instantiate a QScintilla CORBA IDL lexer object.
+
+        @param parent reference to the parent object
+        @type QObject
+        @return reference to the instanciated lexer object
+        @rtype QsciLexer
+        """
+        from ExtensionCorba.LexerIDL import LexerIDL
+
+        return LexerIDL(parent=parent)
+
+    def getFileIcon(self, filename=""):
+        """
+        Public method to get the name of a file icon.
+
+        @param filename file name (defaults to "")
+        @type str (optional)
+        @return name of a file icon
+        @rtype str
+        """
+        iconSuffix = "dark" if ericApp().usesDarkPalette() else "light"
+        return os.path.join("ExtensionCorba", "icons", "corba-{0}".format(iconSuffix))
+
 
 #
 # eflag: noqa = M801

eric ide

mercurial