Skip to content

Commit

Permalink
Possible fix for Flatpak preview issue with gmic, #998
Browse files Browse the repository at this point in the history
  • Loading branch information
jliljebl committed Mar 30, 2021
1 parent f28cdf8 commit 0d41b20
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion flowblade-trunk/Flowblade/containeractions.py
Expand Up @@ -440,7 +440,7 @@ def validate_program(self):
test_in_file = str(respaths.IMAGE_PATH + "unrendered_blender.png") # we just need some valid input

# Create command list and launch process.
command_list = ["/usr/bin/gmic", test_in_file]
command_list = [editorstate.gmic_path, test_in_file]
user_script_commands = user_script.split(" ")
command_list.extend(user_script_commands)
command_list.append("-output")
Expand Down
4 changes: 4 additions & 0 deletions flowblade-trunk/Flowblade/editorstate.py
Expand Up @@ -142,6 +142,10 @@
# Trim clips cache for quicker inits, path -> clip
_trim_clips_cache = {}

# Normal installs and Flatpaks have G'Mic bin in different locations.
# Value set in gmic.py module.
gmic_path = None

def current_is_move_mode():
if ((edit_mode == INSERT_MOVE) or (edit_mode == OVERWRITE_MOVE) or (edit_mode == MULTI_MOVE)):
return True
Expand Down
16 changes: 12 additions & 4 deletions flowblade-trunk/Flowblade/tools/gmic.py
Expand Up @@ -100,13 +100,20 @@

#-------------------------------------------------- launch and inits
def test_availablity():
if os.path.exists("/usr/bin/gmic") == True or os.path.exists("/app/bin/gmic") == True: # File system and flatpak
global _gmic_found
set_gmic_path()
if editorstate.gmic_path != None:
print("G'MIC found")
global _gmic_found
_gmic_found = True
else:
print("G'MIC NOT found")


def set_gmic_path():
if os.path.exists("/usr/bin/gmic") == True:
editorstate.gmic_path = "/usr/bin/gmic"
elif os.path.exists("/app/bin/gmic") == True: # File system and flatpak
editorstate.gmic_path = "/app/bin/gmic"

def gmic_available():
return _gmic_found

Expand Down Expand Up @@ -155,6 +162,7 @@ def main(root_path, force_launch=False):

# Set paths.
respaths.set_paths(root_path)
set_gmic_path() # Flatpak has gmic binary in different place.

# Write stdout to log file
userfolders.init()
Expand Down Expand Up @@ -1085,7 +1093,7 @@ def run(self):
Gdk.threads_leave()

# Create command list and launch process.
command_list = ["/usr/bin/gmic", get_current_frame_file()]
command_list = [editorstate.gmic_path, get_current_frame_file()]
user_script_commands = view_text.split(" ")
command_list.extend(user_script_commands)
command_list.append("-output")
Expand Down
7 changes: 7 additions & 0 deletions flowblade-trunk/Flowblade/tools/gmicheadless.py
Expand Up @@ -103,6 +103,13 @@ def main(root_path, session_id, script, clip_path, range_in, range_out, profile_
# Set paths.
respaths.set_paths(root_path)

if os.path.exists("/usr/bin/gmic") == True: # distro install an dev.
editorstate.gmic_path = "/usr/bin/gmic"
elif os.path.exists("/app/bin/gmic") == True: # Flatpak
editorstate.gmic_path = "/app/bin/gmic"
else:
print("No G'Mic in gmicheadless main(), something is wrong.") # Should not be possible

userfolders.init()
editorpersistance.load()

Expand Down
3 changes: 2 additions & 1 deletion flowblade-trunk/Flowblade/tools/gmicplayer.py
Expand Up @@ -32,6 +32,7 @@
import subprocess
import time

import editorstate
import mltprofiles
import userfolders
import utils
Expand Down Expand Up @@ -325,7 +326,7 @@ def write_frames(self):
rendered_file_path = str(self.out_folder + self.frame_name + "_" + filled_number_str + ".png")

# Create command list and launch process.
command_list = ["/usr/bin/gmic", clip_frame_path]
command_list = [editorstate.gmic_path, clip_frame_path]
user_script_commands = self.user_script.split(" ")
command_list.extend(user_script_commands)
command_list.append("-output")
Expand Down

0 comments on commit 0d41b20

Please sign in to comment.