src/eric7/Snapshot/SnapshotWaylandGrabber.py

branch
eric7
changeset 10155
722f018e5c08
parent 9653
e67609152c5e
child 10180
3a595df36c9a
diff -r d833c6a8c41f -r 722f018e5c08 src/eric7/Snapshot/SnapshotWaylandGrabber.py
--- a/src/eric7/Snapshot/SnapshotWaylandGrabber.py	Fri Aug 04 15:40:49 2023 +0200
+++ b/src/eric7/Snapshot/SnapshotWaylandGrabber.py	Sun Aug 13 18:20:53 2023 +0200
@@ -38,6 +38,14 @@
 
     grabbed = pyqtSignal(QPixmap)
 
+    GnomeScreenShotService = "org.gnome.Shell"
+    GnomeScreenShotObjectPath = "/org/gnome/Shell/Screenshot"
+    GnomeScreenShotInterface = "org.gnome.Shell.Screenshot"
+
+    KdeScreenShotService = "org.kde.KWin"
+    KdeScreenShotObjectPath = "/Screenshot"
+    KdeScreenShotInterface = "org.kde.kwin.Screenshot"
+
     def __init__(self, parent=None):
         """
         Constructor
@@ -132,7 +140,9 @@
 
         if DesktopUtilities.isKdeDesktop():
             interface = QDBusInterface(
-                "org.kde.KWin", "/Screenshot", "org.kde.kwin.Screenshot"
+                SnapshotWaylandGrabber.KdeScreenShotService,
+                SnapshotWaylandGrabber.KdeScreenShotObjectPath,
+                SnapshotWaylandGrabber.KdeScreenShotInterface,
             )
             reply = interface.call("screenshotFullscreen", self.__captureCursor)
             if self.__checkReply(reply, 1):
@@ -144,9 +154,9 @@
         elif DesktopUtilities.isGnomeDesktop():
             path = self.__temporaryFilename()
             interface = QDBusInterface(
-                "org.gnome.Shell",
-                "/org/gnome/Shell/Screenshot",
-                "org.gnome.Shell.Screenshot",
+                SnapshotWaylandGrabber.GnomeScreenShotService,
+                SnapshotWaylandGrabber.GnomeScreenShotObjectPath,
+                SnapshotWaylandGrabber.GnomeScreenShotInterface,
             )
             reply = interface.call("Screenshot", self.__captureCursor, False, path)
             if self.__checkReply(reply, 2):
@@ -174,7 +184,9 @@
 
             # Step 2: grab the screen
             interface = QDBusInterface(
-                "org.kde.KWin", "/Screenshot", "org.kde.kwin.Screenshot"
+                SnapshotWaylandGrabber.KdeScreenShotService,
+                SnapshotWaylandGrabber.KdeScreenShotObjectPath,
+                SnapshotWaylandGrabber.KdeScreenShotInterface,
             )
             reply = interface.call("screenshotScreen", screenId, self.__captureCursor)
             if self.__checkReply(reply, 1):
@@ -187,9 +199,9 @@
             # Step 1: grab entire desktop
             path = self.__temporaryFilename()
             interface = QDBusInterface(
-                "org.gnome.Shell",
-                "/org/gnome/Shell/Screenshot",
-                "org.gnome.Shell.Screenshot",
+                SnapshotWaylandGrabber.GnomeScreenShotService,
+                SnapshotWaylandGrabber.GnomeScreenShotObjectPath,
+                SnapshotWaylandGrabber.GnomeScreenShotInterface,
             )
             reply = interface.call(
                 "ScreenshotWindow",
@@ -227,7 +239,9 @@
             if self.__captureCursor:
                 mask |= 2
             interface = QDBusInterface(
-                "org.kde.KWin", "/Screenshot", "org.kde.kwin.Screenshot"
+                SnapshotWaylandGrabber.KdeScreenShotService,
+                SnapshotWaylandGrabber.KdeScreenShotObjectPath,
+                SnapshotWaylandGrabber.KdeScreenShotInterface,
             )
             reply = interface.call("interactive", mask)
             if self.__checkReply(reply, 1):
@@ -239,9 +253,9 @@
         elif DesktopUtilities.isGnomeDesktop():
             path = self.__temporaryFilename()
             interface = QDBusInterface(
-                "org.gnome.Shell",
-                "/org/gnome/Shell/Screenshot",
-                "org.gnome.Shell.Screenshot",
+                SnapshotWaylandGrabber.GnomeScreenShotService,
+                SnapshotWaylandGrabber.GnomeScreenShotObjectPath,
+                SnapshotWaylandGrabber.GnomeScreenShotInterface,
             )
             reply = interface.call(
                 "ScreenshotWindow",

eric ide

mercurial