def main(root_path): """ Called at application start. Initializes application with a default project. """ # Print OS, Python version and GTK+ version try: os_release_file = open("/etc/os-release", "r") os_text = os_release_file.read() s_index = os_text.find("PRETTY_NAME=") e_index = os_text.find("\n", s_index) print "OS: " + os_text[s_index + 13:e_index - 1] except: pass print "Python", sys.version print "GTK+ version:", gtk.gtk_version editorstate.gtk_version = gtk.gtk_version try: editorstate.mlt_version = mlt.LIBMLT_VERSION except: editorstate.mlt_version = "0.0.99" # magic string for "not found" # Create hidden folders if not present user_dir = utils.get_hidden_user_dir_path() if not os.path.exists(user_dir): os.mkdir(user_dir) if not os.path.exists(user_dir + mltprofiles.USER_PROFILES_DIR): os.mkdir(user_dir + mltprofiles.USER_PROFILES_DIR) if not os.path.exists(user_dir + AUTOSAVE_DIR): os.mkdir(user_dir + AUTOSAVE_DIR) if not os.path.exists(user_dir + BATCH_DIR): os.mkdir(user_dir + BATCH_DIR) if not os.path.exists(user_dir + appconsts.AUDIO_LEVELS_DIR): os.mkdir(user_dir + appconsts.AUDIO_LEVELS_DIR) if not os.path.exists(utils.get_hidden_screenshot_dir_path()): os.mkdir(utils.get_hidden_screenshot_dir_path()) # Set paths. respaths.set_paths(root_path) # Init translations module with translations data translations.init_languages() translations.load_filters_translations() mlttransitions.init_module() # Load editor prefs and list of recent projects editorpersistance.load() if editorpersistance.prefs.dark_theme == True: respaths.apply_dark_theme() editorpersistance.create_thumbs_folder_if_needed(user_dir) editorpersistance.create_rendered_clips_folder_if_needed(user_dir) editorpersistance.save() # Init gtk threads gtk.gdk.threads_init() gtk.gdk.threads_enter() # Load drag'n'drop images dnd.init() # Adjust gui parameters for smaller screens scr_w = gtk.gdk.screen_width() scr_h = gtk.gdk.screen_height() editorstate.SCREEN_WIDTH = scr_w editorstate.SCREEN_HEIGHT = scr_h _set_draw_params(scr_w, scr_h) # Refuse to run on too small screen. if scr_w < 1151 or scr_h < 767: _too_small_screen_exit() return # Splash screen if editorpersistance.prefs.display_splash_screen == True: show_splash_screen() # Init MLT framework repo = mlt.Factory().init() # Set numeric locale to use "." as radix, MLT initilizes this to OS locale and this causes bugs locale.setlocale(locale.LC_NUMERIC, 'C') # Check for codecs and formats on the system mltenv.check_available_features(repo) renderconsumer.load_render_profiles() # Load filter and compositor descriptions from xml files. mltfilters.load_filters_xml(mltenv.services) mlttransitions.load_compositors_xml(mltenv.transitions) # Replace some services if better replacements available mltfilters.replace_services(mltenv.services) # Create list of available mlt profiles mltprofiles.load_profile_list() # Launch association file if found in arguments launch_file_path = get_assoc_file_path() if launch_file_path != None: try: print "Launching assoc file:" + launch_file_path persistance.show_messages = False editorstate.project = persistance.load_project(launch_file_path) persistance.show_messages = True check_crash = False except: editorstate.project = projectdata.get_default_project() persistance.show_messages = True check_crash = True else: # There is always a project open, so at startup we create a default project. # Set default project as the project being edited. editorstate.project = projectdata.get_default_project() check_crash = True # Audiomonitoring being available needs to be known before GUI creation audiomonitoring.init(editorstate.project.profile) # Do JACK audio start-up action jackaudio.start_up() # Create player object create_player() # Create main window and set widget handles in gui.py for more convenient reference. create_gui() # Inits widgets with project data init_project_gui() # Inits widgets with current sequence data init_sequence_gui() # Launch player now that data and gui exist launch_player() # Editor and modules need some more initializing init_editor_state() # Tracks need to be recentered if window is resized. # Connect listener for this now that the tline panel size allocation is sure to be available. gui.editor_window.window.connect("size-allocate", lambda w, e: updater.window_resized()) gui.editor_window.window.connect("window-state-event", lambda w, e: updater.window_resized()) # Get existing autosave files autosave_files = get_autosave_files() # Show splash if ((editorpersistance.prefs.display_splash_screen == True) and len(autosave_files) == 0): global splash_timeout_id splash_timeout_id = gobject.timeout_add(2600, destroy_splash_screen) splash_screen.show_all() appconsts.SAVEFILE_VERSION = projectdata.SAVEFILE_VERSION # THIS IS A QUESTIONABLE IDEA TO SIMPLIFY IMPORTS, NOT DRY. WHEN DOING TOOLS THAT RUN IN ANOTHER PROCESSES AND SAVE PROJECTS, THIS LINE NEEDS TO BE THERE ALSO. # Every running instance has unique autosave file which is deleted at exit set_instance_autosave_id() # Existance of autosave file hints that program was exited abnormally if check_crash == True and len(autosave_files) > 0: if len(autosave_files) == 1: gobject.timeout_add(10, autosave_recovery_dialog) else: gobject.timeout_add(10, autosaves_many_recovery_dialog) else: start_autosave() # We prefer to monkeypatch some callbacks into some modules, usually to # maintain a simpler and non-circular import structure monkeypatch_callbacks() # Launch gtk+ main loop gtk.main() gtk.gdk.threads_leave()
def main(root_path): """ Called at application start. Initializes application with a default project. """ # DEBUG: Direct output to log file if log file set if _log_file != None: log_print_output_to_file() print "Application version: " + editorstate.appversion # Print OS, Python version and GTK+ version try: os_release_file = open("/etc/os-release","r") os_text = os_release_file.read() s_index = os_text.find("PRETTY_NAME=") e_index = os_text.find("\n", s_index) print "OS: " + os_text[s_index + 13:e_index - 1] except: pass print "Python", sys.version gtk_version = "%s.%s.%s" % (Gtk.get_major_version(), Gtk.get_minor_version(), Gtk.get_micro_version()) print "GTK+ version:", gtk_version editorstate.gtk_version = gtk_version try: editorstate.mlt_version = mlt.LIBMLT_VERSION except: editorstate.mlt_version = "0.0.99" # magic string for "not found" #print "SDL version:", str(editorstate.get_sdl_version()) # passing -xdg as a flag will change the user_dir location with XDG_CONFIG_HOME # For full xdg-app support all the launch processes need to add this too, currently not impl. for arg in sys.argv: if arg.lower() == "-xdg": editorstate.use_xdg = True # Create hidden folders if not present user_dir = utils.get_hidden_user_dir_path() print "User dir:",user_dir if not os.path.exists(user_dir): os.mkdir(user_dir) if not os.path.exists(user_dir + mltprofiles.USER_PROFILES_DIR): os.mkdir(user_dir + mltprofiles.USER_PROFILES_DIR) if not os.path.exists(user_dir + AUTOSAVE_DIR): os.mkdir(user_dir + AUTOSAVE_DIR) if not os.path.exists(user_dir + BATCH_DIR): os.mkdir(user_dir + BATCH_DIR) if not os.path.exists(user_dir + appconsts.AUDIO_LEVELS_DIR): os.mkdir(user_dir + appconsts.AUDIO_LEVELS_DIR) if not os.path.exists(utils.get_hidden_screenshot_dir_path()): os.mkdir(utils.get_hidden_screenshot_dir_path()) if not os.path.exists(user_dir + appconsts.GMIC_DIR): os.mkdir(user_dir + appconsts.GMIC_DIR) if not os.path.exists(user_dir + appconsts.MATCH_FRAME_DIR): os.mkdir(user_dir + appconsts.MATCH_FRAME_DIR) if not os.path.exists(user_dir + appconsts.TRIM_VIEW_DIR): os.mkdir(user_dir + appconsts.TRIM_VIEW_DIR) if not os.path.exists(user_dir + appconsts.NATRON_DIR): os.mkdir(user_dir + appconsts.NATRON_DIR) # Set paths. respaths.set_paths(root_path) # Load editor prefs and list of recent projects editorpersistance.load() if editorpersistance.prefs.theme != appconsts.LIGHT_THEME: respaths.apply_dark_theme() if editorpersistance.prefs.display_all_audio_levels == False: editorstate.display_all_audio_levels = False editorpersistance.create_thumbs_folder_if_needed(user_dir) editorpersistance.create_rendered_clips_folder_if_needed(user_dir) editorpersistance.save() # Init translations module with translations data translations.init_languages() translations.load_filters_translations() mlttransitions.init_module() # Apr-2017 - SvdB - Keyboard shortcuts shortcuts.load_shortcut_files() shortcuts.load_shortcuts() # We respaths and translations data available so we need to init in a function. workflow.init_data() # RHEL7/CentOS compatibility fix if gtk_version == "3.8.8": GObject.threads_init() # Init gtk threads Gdk.threads_init() Gdk.threads_enter() # Themes if editorpersistance.prefs.theme == appconsts.FLOWBLADE_THEME: success = gui.apply_gtk_css() if not success: editorpersistance.prefs.theme = appconsts.LIGHT_THEME editorpersistance.save() if editorpersistance.prefs.theme != appconsts.LIGHT_THEME: Gtk.Settings.get_default().set_property("gtk-application-prefer-dark-theme", True) # Load drag'n'drop images dnd.init() # Adjust gui parameters for smaller screens scr_w = Gdk.Screen.width() scr_h = Gdk.Screen.height() editorstate.SCREEN_WIDTH = scr_w editorstate.SCREEN_HEIGHT = scr_h print "Screen size:", scr_w, "x", scr_h print "Small height:", editorstate.screen_size_small_height() print "Small width:", editorstate.screen_size_small_width() _set_draw_params() # Refuse to run on too small screen. if scr_w < 1151 or scr_h < 767: _too_small_screen_exit() return # Splash screen if editorpersistance.prefs.display_splash_screen == True: show_splash_screen() # Init MLT framework repo = mlt.Factory().init() processutils.prepare_mlt_repo(repo) # Set numeric locale to use "." as radix, MLT initilizes this to OS locale and this causes bugs. locale.setlocale(locale.LC_NUMERIC, 'C') # Check for codecs and formats on the system. mltenv.check_available_features(repo) renderconsumer.load_render_profiles() # Load filter and compositor descriptions from xml files. mltfilters.load_filters_xml(mltenv.services) mlttransitions.load_compositors_xml(mltenv.transitions) # Replace some services if better replacements available. mltfilters.replace_services(mltenv.services) # Create list of available mlt profiles. mltprofiles.load_profile_list() # Save assoc file path if found in arguments. global assoc_file_path assoc_file_path = get_assoc_file_path() # There is always a project open, so at startup we create a default project. # Set default project as the project being edited. editorstate.project = projectdata.get_default_project() check_crash = True # Audiomonitoring being available needs to be known before GUI creation. audiomonitoring.init(editorstate.project.profile) # Set trim view mode to current default value. editorstate.show_trim_view = editorpersistance.prefs.trim_view_default # Check for tools and init tools integration. gmic.test_availablity() toolnatron.init() toolsintegration.init() #toolsintegration.test() # Create player object. create_player() # Create main window and set widget handles in gui.py for more convenient reference. create_gui() # Inits widgets with project data. init_project_gui() # Inits widgets with current sequence data. init_sequence_gui() # Launch player now that data and gui exist launch_player() # Editor and modules need some more initializing. init_editor_state() # Tracks need to be recentered if window is resized. # Connect listener for this now that the tline panel size allocation is sure to be available. global window_resize_id, window_state_id window_resize_id = gui.editor_window.window.connect("size-allocate", lambda w, e:updater.window_resized()) window_state_id = gui.editor_window.window.connect("window-state-event", lambda w, e:updater.window_resized()) # Get existing autosave files autosave_files = get_autosave_files() # Show splash if ((editorpersistance.prefs.display_splash_screen == True) and len(autosave_files) == 0) and not editorstate.runtime_version_greater_then_test_version(editorpersistance.prefs.workflow_dialog_last_version_shown, editorstate.appversion): global splash_timeout_id splash_timeout_id = GLib.timeout_add(2600, destroy_splash_screen) splash_screen.show_all() appconsts.SAVEFILE_VERSION = projectdata.SAVEFILE_VERSION # THIS IS A QUESTIONABLE IDEA TO SIMPLIFY IMPORTS, NOT DRY. WHEN DOING TOOLS THAT RUN IN ANOTHER PROCESSES AND SAVE PROJECTS, THIS LINE NEEDS TO BE THERE ALSO. # Every running instance has unique autosave file which is deleted at exit set_instance_autosave_id() # Existance of autosave file hints that program was exited abnormally. if check_crash == True and len(autosave_files) > 0: if len(autosave_files) == 1: GObject.timeout_add(10, autosave_recovery_dialog) else: GObject.timeout_add(10, autosaves_many_recovery_dialog) else: start_autosave() # We prefer to monkeypatch some callbacks into some modules, usually to # maintain a simpler and/or non-circular import structure. monkeypatch_callbacks() # File in assoc_file_path is opened after very short delay. if not(check_crash == True and len(autosave_files) > 0): if assoc_file_path != None: print "Launch assoc file:", assoc_file_path global assoc_timeout_id assoc_timeout_id = GObject.timeout_add(10, open_assoc_file) if editorpersistance.prefs.theme == appconsts.FLOWBLADE_THEME: gui.apply_flowblade_theme_fixes() # SDL 2 consumer needs to created after Gtk.main() has run enough for window to be visble #if editorstate.get_sdl_version() == editorstate.SDL_2: # needs more state considerion still # print "SDL2 timeout launch" # global sdl2_timeout_id # sdl2_timeout_id = GObject.timeout_add(1500, create_sdl_2_consumer) # In PositionNumericalEntries we are using Gtk.Entry objects in a way that works for us nicely, but is somehow "error" for Gtk, so we just kill this. Gtk.Settings.get_default().set_property("gtk-error-bell", False) # Show first run worflow info dialog if not shown for this version of application. if editorstate.runtime_version_greater_then_test_version(editorpersistance.prefs.workflow_dialog_last_version_shown, editorstate.appversion): GObject.timeout_add(500, show_worflow_info_dialog) # Launch gtk+ main loop Gtk.main() Gdk.threads_leave()
def main(root_path): """ Called at application start. Initializes application with a default project. """ # DEBUG: Direct output to log file if log file set if _log_file != None: log_print_output_to_file() set_quiet_if_requested() print("Application version: " + editorstate.appversion) # Print OS, Python version and GTK+ version try: os_release_file = open("/etc/os-release","r") os_text = os_release_file.read() s_index = os_text.find("PRETTY_NAME=") e_index = os_text.find("\n", s_index) print("OS: " + os_text[s_index + 13:e_index - 1]) except: pass print("Python", sys.version) gtk_version = "%s.%s.%s" % (Gtk.get_major_version(), Gtk.get_minor_version(), Gtk.get_micro_version()) print("GTK+ version:", gtk_version) editorstate.gtk_version = gtk_version try: editorstate.mlt_version = mlt.LIBMLT_VERSION except: editorstate.mlt_version = "0.0.99" # magic string for "not found" # Create user folders if needed and determine if we're using xdg or dotfile user folders. userfolders.init() # Flatpak still needs to use standard home XDG cache folder for Blender. # Flatpak only uses XDG cache folder for Blender and we are keeping this around if we ever # succeed in getting Blender going for Flatpak. if editorstate.app_running_from == editorstate.RUNNING_FROM_FLATPAK: userfolders.init_user_cache_for_flatpak() # Set paths. respaths.set_paths(root_path) # Load editor prefs and list of recent projects editorpersistance.load() if editorpersistance.prefs.theme != appconsts.LIGHT_THEME: respaths.apply_dark_theme() if editorpersistance.prefs.display_all_audio_levels == False: editorstate.display_all_audio_levels = False editorpersistance.save() # Init translations module with translations data translations.init_languages() translations.load_filters_translations() mlttransitions.init_module() # Keyboard shortcuts shortcuts.load_shortcut_files() shortcuts.load_shortcuts() shortcuts.update_custom_shortcuts(editorpersistance.prefs.shortcuts) # The test for len != 4 is to make sure that if we change the number of values below the prefs are reset to the correct list # So when we add or remove a value, make sure we also change the len test # Only use positive numbers. if( not editorpersistance.prefs.AUTO_SAVE_OPTS or len(editorpersistance.prefs.AUTO_SAVE_OPTS) != 4): print("Initializing Auto Save Options") editorpersistance.prefs.AUTO_SAVE_OPTS = ((0, _("No Autosave")),(1, _("1 min")),(2, _("2 min")),(5, _("5 min"))) # We need respaths and translations data available so we need to do init in a function. workflow.init_data() # RHEL7/CentOS compatibility fix if gtk_version == "3.8.8": GObject.threads_init() # Init gtk threads Gdk.threads_init() Gdk.threads_enter() # Handle userfolders init error and quit. if userfolders.get_init_error() != None: _xdg_error_exit(userfolders.get_init_error()) return # After moving to Python 3 we need at least MLT 6.18 if editorstate.mlt_version_is_greater_correct("6.17.99") == False: _too_low_mlt_version_exit() return # Apply custom themes. if editorpersistance.prefs.theme == appconsts.FLOWBLADE_THEME \ or editorpersistance.prefs.theme == appconsts.FLOWBLADE_THEME_GRAY \ or editorpersistance.prefs.theme == appconsts.FLOWBLADE_THEME_NEUTRAL: success = gui.apply_gtk_css(editorpersistance.prefs.theme) if not success: print("Applying custom theme failed.") editorpersistance.prefs.theme = appconsts.LIGHT_THEME editorpersistance.save() if editorpersistance.prefs.theme != appconsts.LIGHT_THEME: Gtk.Settings.get_default().set_property("gtk-application-prefer-dark-theme", True) # Load drag'n'drop images dnd.init() # Save screen size data and modify rendering based on screen size/s and number of monitors. scr_w, scr_h = _set_screen_size_data() _set_draw_params() # Refuse to run on too small screen. if scr_w < 1151 or scr_h < 767: _too_small_screen_exit() return # Splash screen if editorpersistance.prefs.display_splash_screen == True: show_splash_screen() # Init MLT framework repo = mlt.Factory().init() processutils.prepare_mlt_repo(repo) # Set numeric locale to use "." as radix, MLT initilizes this to OS locale and this causes bugs. locale.setlocale(locale.LC_NUMERIC, 'C') # Check for codecs and formats on the system. mltenv.check_available_features(repo) renderconsumer.load_render_profiles() # Load filter and compositor descriptions from xml files. mltfilters.load_filters_xml(mltenv.services) mlttransitions.load_compositors_xml(mltenv.transitions) # Replace some services if better replacements available. mltfilters.replace_services(mltenv.services) # Create list of available mlt profiles. mltprofiles.load_profile_list() # If we have crashed we could have large amount of disk space wasted unless we delete all files here. tlinerender.app_launch_clean_up() # Save assoc file path if found in arguments. global assoc_file_path assoc_file_path = get_assoc_file_path() # There is always a project open, so at startup we create a default project. # Set default project as the project being edited. editorstate.project = projectdata.get_default_project() check_crash = True # Audiomonitoring being available needs to be known before GUI creation. audiomonitoring.init(editorstate.project.profile) # Set trim view mode to current default value. editorstate.show_trim_view = editorpersistance.prefs.trim_view_default # Check for tools and init tools integration. gmic.test_availablity() containerclip.test_blender_availebility() toolsintegration.init() # Media Plugins mediaplugin.init() # Create player object. create_player() # Create main window and set widget handles in gui.py for more convenient reference. create_gui() # Inits widgets with project data. init_project_gui() # Inits widgets with current sequence data. init_sequence_gui() # Launch player now that data and gui exist launch_player() # Editor and modules need some more initializing. init_editor_state() # Tracks need to be recentered if window is resized. # Connect listener for this now that the tline panel size allocation is sure to be available. global window_resize_id, window_state_id window_resize_id = gui.editor_window.window.connect("size-allocate", lambda w, e:updater.window_resized()) window_state_id = gui.editor_window.window.connect("window-state-event", lambda w, e:updater.window_resized()) # Get existing autosave files autosave_files = get_autosave_files() # Show splash if ((editorpersistance.prefs.display_splash_screen == True) and len(autosave_files) == 0) and not editorstate.runtime_version_greater_then_test_version(editorpersistance.prefs.workflow_dialog_last_version_shown, editorstate.appversion): global splash_timeout_id splash_timeout_id = GLib.timeout_add(2600, destroy_splash_screen) splash_screen.show_all() appconsts.SAVEFILE_VERSION = projectdata.SAVEFILE_VERSION # THIS IS A QUESTIONABLE IDEA TO SIMPLIFY IMPORTS, NOT DRY. WHEN DOING TOOLS THAT RUN IN ANOTHER PROCESSES AND SAVE PROJECTS, THIS LINE NEEDS TO BE THERE ALSO. # Every running instance has unique autosave file which is deleted at exit set_instance_autosave_id() # Existance of autosave file hints that program was exited abnormally. if check_crash == True and len(autosave_files) > 0: if len(autosave_files) == 1: GObject.timeout_add(10, autosave_recovery_dialog) else: GObject.timeout_add(10, autosaves_many_recovery_dialog) else: tlinerender.init_session() start_autosave() projectaction.clear_changed_since_last_save_flags() # We prefer to monkeypatch some callbacks into some modules, usually to # maintain a simpler and/or non-circular import structure. monkeypatch_callbacks() # File in assoc_file_path is opened after very short delay. if not(check_crash == True and len(autosave_files) > 0): if assoc_file_path != None: print("Launch assoc file:", assoc_file_path) global assoc_timeout_id assoc_timeout_id = GObject.timeout_add(10, open_assoc_file) # SDL 2 consumer needs to created after Gtk.main() has run enough for window to be visble #if editorstate.get_sdl_version() == editorstate.SDL_2: # needs more state considerion still # print "SDL2 timeout launch" # global sdl2_timeout_id # sdl2_timeout_id = GObject.timeout_add(1500, create_sdl_2_consumer) # In PositionNumericalEntries we are using Gtk.Entry objects in a way that works for us nicely, but is somehow "error" for Gtk, so we just kill this. Gtk.Settings.get_default().set_property("gtk-error-bell", False) # Show first run worflow info dialog if not shown for this version of application. if editorstate.runtime_version_greater_then_test_version(editorpersistance.prefs.workflow_dialog_last_version_shown, editorstate.appversion): GObject.timeout_add(500, show_worflow_info_dialog) # Copy to XDG. if userfolders.data_copy_needed(): GObject.timeout_add(500, show_user_folders_copy_dialog) else: print("No user folders actions needed.") global disk_cache_timeout_id disk_cache_timeout_id = GObject.timeout_add(2500, check_disk_cache_size) # Launch gtk+ main loop Gtk.main() Gdk.threads_leave()
def main(root_path): """ Called at application start. Initializes application with a default project. """ # Print OS, Python version and GTK+ version try: os_release_file = open("/etc/os-release","r") os_text = os_release_file.read() s_index = os_text.find("PRETTY_NAME=") e_index = os_text.find("\n", s_index) print "OS: " + os_text[s_index + 13:e_index - 1] except: pass print "Python", sys.version gtk_version = "%s.%s.%s" % (Gtk.get_major_version(), Gtk.get_minor_version(), Gtk.get_micro_version()) print "GTK+ version:", gtk_version editorstate.gtk_version = gtk_version try: editorstate.mlt_version = mlt.LIBMLT_VERSION except: editorstate.mlt_version = "0.0.99" # magic string for "not found" # passing -xdg as a flag will change the user_dir location with XDG_CONFIG_HOME # For full xdg-app support all the launch processes need to add this too, currently not impl. for arg in sys.argv: if arg.lower() == "-xdg": editorstate.use_xdg = True # Create hidden folders if not present user_dir = utils.get_hidden_user_dir_path() print "User dir:",user_dir if not os.path.exists(user_dir): os.mkdir(user_dir) if not os.path.exists(user_dir + mltprofiles.USER_PROFILES_DIR): os.mkdir(user_dir + mltprofiles.USER_PROFILES_DIR) if not os.path.exists(user_dir + AUTOSAVE_DIR): os.mkdir(user_dir + AUTOSAVE_DIR) if not os.path.exists(user_dir + BATCH_DIR): os.mkdir(user_dir + BATCH_DIR) if not os.path.exists(user_dir + appconsts.AUDIO_LEVELS_DIR): os.mkdir(user_dir + appconsts.AUDIO_LEVELS_DIR) if not os.path.exists(utils.get_hidden_screenshot_dir_path()): os.mkdir(utils.get_hidden_screenshot_dir_path()) if not os.path.exists(user_dir + appconsts.GMIC_DIR): os.mkdir(user_dir + appconsts.GMIC_DIR) # Set paths. respaths.set_paths(root_path) # Load editor prefs and list of recent projects editorpersistance.load() if editorpersistance.prefs.dark_theme == True: respaths.apply_dark_theme() if editorpersistance.prefs.display_all_audio_levels == False: editorstate.display_all_audio_levels = False editorpersistance.create_thumbs_folder_if_needed(user_dir) editorpersistance.create_rendered_clips_folder_if_needed(user_dir) editorpersistance.save() # Init translations module with translations data translations.init_languages() translations.load_filters_translations() mlttransitions.init_module() # RHEL7/CentOS compatibility fix if gtk_version == "3.8.8": GObject.threads_init() # Init gtk threads Gdk.threads_init() Gdk.threads_enter() # Request dark them if so desired if editorpersistance.prefs.dark_theme == True: Gtk.Settings.get_default().set_property("gtk-application-prefer-dark-theme", True) # Load drag'n'drop images dnd.init() # Adjust gui parameters for smaller screens scr_w = Gdk.Screen.width() scr_h = Gdk.Screen.height() editorstate.SCREEN_WIDTH = scr_w editorstate.SCREEN_HEIGHT = scr_h print "Small height:", editorstate.screen_size_small_height() print "Small width:", editorstate.screen_size_small_width() _set_draw_params() # Refuse to run on too small screen. if scr_w < 1151 or scr_h < 767: _too_small_screen_exit() return # Splash screen if editorpersistance.prefs.display_splash_screen == True: show_splash_screen() # Init MLT framework repo = mlt.Factory().init() # Set numeric locale to use "." as radix, MLT initilizes this to OS locale and this causes bugs locale.setlocale(locale.LC_NUMERIC, 'C') # Check for codecs and formats on the system mltenv.check_available_features(repo) renderconsumer.load_render_profiles() # Load filter and compositor descriptions from xml files. mltfilters.load_filters_xml(mltenv.services) mlttransitions.load_compositors_xml(mltenv.transitions) # Replace some services if better replacements available mltfilters.replace_services(mltenv.services) # Create list of available mlt profiles mltprofiles.load_profile_list() # Launch association file if found in arguments launch_file_path = get_assoc_file_path() if launch_file_path != None: try: print "Launching assoc file:" + launch_file_path persistance.show_messages = False editorstate.project = persistance.load_project(launch_file_path) persistance.show_messages = True check_crash = False except: editorstate.project = projectdata.get_default_project() persistance.show_messages = True check_crash = True else: # There is always a project open, so at startup we create a default project. # Set default project as the project being edited. editorstate.project = projectdata.get_default_project() check_crash = True # Audiomonitoring being available needs to be known before GUI creation audiomonitoring.init(editorstate.project.profile) # Create player object create_player() # Create main window and set widget handles in gui.py for more convenient reference. create_gui() # Inits widgets with project data init_project_gui() # Inits widgets with current sequence data init_sequence_gui() # Launch player now that data and gui exist launch_player() # Editor and modules need some more initializing init_editor_state() # Tracks need to be recentered if window is resized. # Connect listener for this now that the tline panel size allocation is sure to be available. global window_resize_id, window_state_id window_resize_id = gui.editor_window.window.connect("size-allocate", lambda w, e:updater.window_resized()) window_state_id = gui.editor_window.window.connect("window-state-event", lambda w, e:updater.window_resized()) # Get existing autosave files autosave_files = get_autosave_files() # Show splash if ((editorpersistance.prefs.display_splash_screen == True) and len(autosave_files) == 0): global splash_timeout_id splash_timeout_id = GLib.timeout_add(2600, destroy_splash_screen) splash_screen.show_all() appconsts.SAVEFILE_VERSION = projectdata.SAVEFILE_VERSION # THIS IS A QUESTIONABLE IDEA TO SIMPLIFY IMPORTS, NOT DRY. WHEN DOING TOOLS THAT RUN IN ANOTHER PROCESSES AND SAVE PROJECTS, THIS LINE NEEDS TO BE THERE ALSO. # Every running instance has unique autosave file which is deleted at exit set_instance_autosave_id() # Existance of autosave file hints that program was exited abnormally if check_crash == True and len(autosave_files) > 0: if len(autosave_files) == 1: GObject.timeout_add(10, autosave_recovery_dialog) else: GObject.timeout_add(10, autosaves_many_recovery_dialog) else: start_autosave() # We prefer to monkeypatch some callbacks into some modules, usually to # maintain a simpler and/or non-circular import structure monkeypatch_callbacks() # Launch gtk+ main loop Gtk.main() Gdk.threads_leave()
def main(root_path): """ Called at application start. Initializes application with a default project. """ # DEBUG: Direct output to log file if log file set if _log_file != None: log_print_output_to_file() print "Application version: " + editorstate.appversion # Print OS, Python version and GTK+ version try: os_release_file = open("/etc/os-release","r") os_text = os_release_file.read() s_index = os_text.find("PRETTY_NAME=") e_index = os_text.find("\n", s_index) print "OS: " + os_text[s_index + 13:e_index - 1] except: pass print "Python", sys.version gtk_version = "%s.%s.%s" % (Gtk.get_major_version(), Gtk.get_minor_version(), Gtk.get_micro_version()) print "GTK+ version:", gtk_version editorstate.gtk_version = gtk_version try: editorstate.mlt_version = mlt.LIBMLT_VERSION except: editorstate.mlt_version = "0.0.99" # magic string for "not found" # Create user folders if need and determine if were using xdg or dotfile userf folders. userfolders.init() # Set paths. respaths.set_paths(root_path) # Load editor prefs and list of recent projects editorpersistance.load() if editorpersistance.prefs.theme != appconsts.LIGHT_THEME: respaths.apply_dark_theme() if editorpersistance.prefs.display_all_audio_levels == False: editorstate.display_all_audio_levels = False editorpersistance.save() # Init translations module with translations data translations.init_languages() translations.load_filters_translations() mlttransitions.init_module() # Apr-2017 - SvdB - Keyboard shortcuts shortcuts.load_shortcut_files() shortcuts.load_shortcuts() # We respaths and translations data available so we need to init in a function. workflow.init_data() # RHEL7/CentOS compatibility fix if gtk_version == "3.8.8": GObject.threads_init() # Init gtk threads Gdk.threads_init() Gdk.threads_enter() # Themes if editorpersistance.prefs.theme == appconsts.FLOWBLADE_THEME: success = gui.apply_gtk_css() if not success: editorpersistance.prefs.theme = appconsts.LIGHT_THEME editorpersistance.save() if editorpersistance.prefs.theme != appconsts.LIGHT_THEME: Gtk.Settings.get_default().set_property("gtk-application-prefer-dark-theme", True) # Load drag'n'drop images dnd.init() # Adjust gui parameters for smaller screens scr_w = Gdk.Screen.width() scr_h = Gdk.Screen.height() editorstate.SCREEN_WIDTH = scr_w editorstate.SCREEN_HEIGHT = scr_h print "Screen size:", scr_w, "x", scr_h print "Small height:", editorstate.screen_size_small_height() print "Small width:", editorstate.screen_size_small_width() _set_draw_params() # Refuse to run on too small screen. if scr_w < 1151 or scr_h < 767: _too_small_screen_exit() return # Splash screen if editorpersistance.prefs.display_splash_screen == True: show_splash_screen() # Init MLT framework repo = mlt.Factory().init() processutils.prepare_mlt_repo(repo) # Set numeric locale to use "." as radix, MLT initilizes this to OS locale and this causes bugs. locale.setlocale(locale.LC_NUMERIC, 'C') # Check for codecs and formats on the system. mltenv.check_available_features(repo) renderconsumer.load_render_profiles() # Load filter and compositor descriptions from xml files. mltfilters.load_filters_xml(mltenv.services) mlttransitions.load_compositors_xml(mltenv.transitions) # Replace some services if better replacements available. mltfilters.replace_services(mltenv.services) # Create list of available mlt profiles. mltprofiles.load_profile_list() # Save assoc file path if found in arguments. global assoc_file_path assoc_file_path = get_assoc_file_path() # There is always a project open, so at startup we create a default project. # Set default project as the project being edited. editorstate.project = projectdata.get_default_project() check_crash = True # Audiomonitoring being available needs to be known before GUI creation. audiomonitoring.init(editorstate.project.profile) # Set trim view mode to current default value. editorstate.show_trim_view = editorpersistance.prefs.trim_view_default # Check for tools and init tools integration. gmic.test_availablity() toolsintegration.init() # Create player object. create_player() # Create main window and set widget handles in gui.py for more convenient reference. create_gui() # Inits widgets with project data. init_project_gui() # Inits widgets with current sequence data. init_sequence_gui() # Launch player now that data and gui exist launch_player() # Editor and modules need some more initializing. init_editor_state() # Tracks need to be recentered if window is resized. # Connect listener for this now that the tline panel size allocation is sure to be available. global window_resize_id, window_state_id window_resize_id = gui.editor_window.window.connect("size-allocate", lambda w, e:updater.window_resized()) window_state_id = gui.editor_window.window.connect("window-state-event", lambda w, e:updater.window_resized()) # Get existing autosave files autosave_files = get_autosave_files() # Show splash if ((editorpersistance.prefs.display_splash_screen == True) and len(autosave_files) == 0) and not editorstate.runtime_version_greater_then_test_version(editorpersistance.prefs.workflow_dialog_last_version_shown, editorstate.appversion): global splash_timeout_id splash_timeout_id = GLib.timeout_add(2600, destroy_splash_screen) splash_screen.show_all() appconsts.SAVEFILE_VERSION = projectdata.SAVEFILE_VERSION # THIS IS A QUESTIONABLE IDEA TO SIMPLIFY IMPORTS, NOT DRY. WHEN DOING TOOLS THAT RUN IN ANOTHER PROCESSES AND SAVE PROJECTS, THIS LINE NEEDS TO BE THERE ALSO. # Every running instance has unique autosave file which is deleted at exit set_instance_autosave_id() # Existance of autosave file hints that program was exited abnormally. if check_crash == True and len(autosave_files) > 0: if len(autosave_files) == 1: GObject.timeout_add(10, autosave_recovery_dialog) else: GObject.timeout_add(10, autosaves_many_recovery_dialog) else: start_autosave() # We prefer to monkeypatch some callbacks into some modules, usually to # maintain a simpler and/or non-circular import structure. monkeypatch_callbacks() # File in assoc_file_path is opened after very short delay. if not(check_crash == True and len(autosave_files) > 0): if assoc_file_path != None: print "Launch assoc file:", assoc_file_path global assoc_timeout_id assoc_timeout_id = GObject.timeout_add(10, open_assoc_file) if editorpersistance.prefs.theme == appconsts.FLOWBLADE_THEME: gui.apply_flowblade_theme_fixes() # SDL 2 consumer needs to created after Gtk.main() has run enough for window to be visble #if editorstate.get_sdl_version() == editorstate.SDL_2: # needs more state considerion still # print "SDL2 timeout launch" # global sdl2_timeout_id # sdl2_timeout_id = GObject.timeout_add(1500, create_sdl_2_consumer) # In PositionNumericalEntries we are using Gtk.Entry objects in a way that works for us nicely, but is somehow "error" for Gtk, so we just kill this. Gtk.Settings.get_default().set_property("gtk-error-bell", False) # Show first run worflow info dialog if not shown for this version of application. if editorstate.runtime_version_greater_then_test_version(editorpersistance.prefs.workflow_dialog_last_version_shown, editorstate.appversion): GObject.timeout_add(500, show_worflow_info_dialog) # Handle userfolders init error and data copy. if userfolders.get_init_error() != None: GObject.timeout_add(500, show_user_folders_init_error_dialog, userfolders.get_init_error()) elif userfolders.data_copy_needed(): GObject.timeout_add(500, show_user_folders_copy_dialog) else: print "No user folders actions needed." # Launch gtk+ main loop Gtk.main() Gdk.threads_leave()