Skip to content

Commit 5b79868

Browse files
authored
Merge pull request #3017 from ferdnyc/simplify-unity
Simplify Unity Launcher logic
2 parents ea3ee9c + 628dbc2 commit 5b79868

File tree

2 files changed

+24
-27
lines changed

2 files changed

+24
-27
lines changed

src/classes/info.py

+3
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@
7979
"email": "[email protected]",
8080
"website": "http://openshot.org/developers/jonathan"}
8181

82+
# Desktop launcher ID, for Linux
83+
DESKTOP_ID = "org.openshot.OpenShot.desktop"
84+
8285
# Blender minimum version required (a string value)
8386
BLENDER_MIN_VERSION = "2.80"
8487

src/windows/main_window.py

+21-27
Original file line numberDiff line numberDiff line change
@@ -2533,34 +2533,21 @@ def InitCacheSettings(self):
25332533
self.cache_object = new_cache_object
25342534

25352535
def FrameExported(self, title_message, start_frame, end_frame, current_frame):
2536-
"""Connect to Unity launcher (for Linux)"""
2536+
"""Update progress in Unity Launcher (if connected)"""
25372537
try:
2538-
if sys.platform == "linux" and self.has_launcher:
2539-
if not self.unity_launchers:
2540-
# Get launcher only once
2541-
import gi
2542-
gi.require_version('Unity', '7.0')
2543-
from gi.repository import Unity
2544-
self.unity_launchers.append(Unity.LauncherEntry.get_for_desktop_id("openshot-qt.desktop"))
2545-
self.unity_launchers.append(Unity.LauncherEntry.get_for_desktop_id("appimagekit-openshot-qt.desktop"))
2546-
2547-
# Set progress and show progress bar
2548-
for launcher in self.unity_launchers:
2549-
launcher.set_property("progress", current_frame / (end_frame - start_frame))
2550-
launcher.set_property("progress_visible", True)
2551-
2538+
# Set progress and show progress bar
2539+
self.unity_launcher.set_property("progress", current_frame / (end_frame - start_frame))
2540+
self.unity_launcher.set_property("progress_visible", True)
25522541
except Exception:
25532542
# Just ignore
2554-
self.has_launcher = False
2543+
pass
25552544

25562545
def ExportFinished(self, path):
2557-
"""Export has completed"""
2546+
"""Show completion in Unity Launcher (if connected)"""
25582547
try:
2559-
if sys.platform == "linux" and self.has_launcher:
2560-
for launcher in self.unity_launchers:
2561-
# Set progress on Unity launcher and hide progress bar
2562-
launcher.set_property("progress", 0.0)
2563-
launcher.set_property("progress_visible", False)
2548+
# Set progress on Unity launcher and hide progress bar
2549+
self.unity_launcher.set_property("progress", 0.0)
2550+
self.unity_launcher.set_property("progress_visible", False)
25642551
except Exception:
25652552
pass
25662553

@@ -2796,11 +2783,18 @@ def __init__(self, mode=None):
27962783
self.tutorial_manager = TutorialManager(self)
27972784

27982785
# Connect to Unity DBus signal (if linux)
2799-
if sys.platform == "linux":
2800-
self.unity_launchers = []
2801-
self.has_launcher = True
2802-
self.ExportFrame.connect(self.FrameExported)
2803-
self.ExportEnded.connect(self.ExportFinished)
2786+
self.unity_launcher = None
2787+
if "linux" in sys.platform:
2788+
try:
2789+
# Get connection to Unity Launcher
2790+
from gi.repository import Unity
2791+
self.unity_launcher = Unity.LauncherEntry.get_for_desktop_id(info.DESKTOP_ID)
2792+
except Exception:
2793+
# Guess we're not on Ubuntu
2794+
pass
2795+
else:
2796+
self.ExportFrame.connect(self.FrameExported)
2797+
self.ExportEnded.connect(self.ExportFinished)
28042798

28052799
# Save settings
28062800
s.save()

0 commit comments

Comments
 (0)