2
Flowblade Movie Editor is a nonlinear video editor.
3
Copyright 2012 Janne Liljeblad.
5
This file is part of Flowblade Movie Editor <http://code.google.com/p/flowblade>.
7
Flowblade Movie Editor is free software: you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation, either version 3 of the License, or
10
(at your option) any later version.
12
Flowblade Movie Editor is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with Flowblade Movie Editor. If not, see <http://www.gnu.org/licenses/>.
22
Module handles saving and loading data that is related to the editor and not any particular project.
36
UNDO_STACK_DEFAULT = 30
41
recent_projects = None
45
If docs fail to load, new ones are created and saved.
47
prefs_file_path = utils.get_hidden_user_dir_path() + PREFS_DOC
48
recents_file_path = utils.get_hidden_user_dir_path() + RECENT_DOC
50
global prefs, recent_projects
52
f = open(prefs_file_path)
53
prefs = pickle.load(f)
55
prefs = EditorPreferences()
56
write_file = file(prefs_file_path, "wb")
57
pickle.dump(prefs, write_file)
60
f = open(recents_file_path)
61
recent_projects = pickle.load(f)
63
recent_projects = utils.EmptyClass()
64
recent_projects.projects = []
65
write_file = file(recents_file_path, "wb")
66
pickle.dump(recent_projects, write_file)
68
# version of program may have different prefs objects and
69
# we may need to to update prefs on disk if user has e.g.
70
# installed later version of Flowblade
71
current_prefs = EditorPreferences()
72
if len(prefs.__dict__) != len(current_prefs.__dict__):
73
current_prefs.__dict__.update(prefs.__dict__)
75
write_file = file(prefs_file_path, "wb")
76
pickle.dump(prefs, write_file)
77
print "prefs updated to new version, new param count:", len(prefs.__dict__)
81
Write out prefs and recent_projects files
83
prefs_file_path = utils.get_hidden_user_dir_path() + PREFS_DOC
84
recents_file_path = utils.get_hidden_user_dir_path() + RECENT_DOC
86
write_file = file(prefs_file_path, "wb")
87
pickle.dump(prefs, write_file)
89
write_file = file(recents_file_path, "wb")
90
pickle.dump(recent_projects, write_file)
92
def add_recent_project_path(path):
94
Called when project saved.
96
if len(recent_projects.projects) == MAX_RECENT_PROJS:
97
recent_projects.projects.pop(-1)
100
index = recent_projects.projects.index(path)
101
recent_projects.projects.pop(index)
105
recent_projects.projects.insert(0, path)
108
def fill_recents_menu_widget(menu_item, callback):
110
Fills menu item with menuitems to open recent projects.
112
menu = menu_item.get_submenu()
114
# Remove current items
115
items = menu.get_children()
120
recent_proj_names = get_recent_projects()
121
if len(recent_proj_names) != 0:
122
for i in range (0, len(recent_proj_names) - 1):
123
proj_name = recent_proj_names[i]
124
new_item = gtk.MenuItem(proj_name)
125
new_item.connect("activate", callback, i)
126
menu.append(new_item)
128
# ...or a single non-sensitive Empty item
130
new_item = gtk.MenuItem(_("Empty"))
131
new_item.set_sensitive(False)
132
menu.append(new_item)
135
def get_recent_projects():
137
Returns list of names of recent projects.
140
for proj_path in recent_projects.projects:
141
proj_list.append(os.path.basename(proj_path))
145
def update_prefs_from_widgets(widgets_tuples_tuple):
147
gen_opts_widgets, edit_prefs_widgets = widgets_tuples_tuple
148
default_profile_combo, open_in_last_opened_check, undo_max_spin, disp_splash, default_tracks_combo = gen_opts_widgets
149
auto_play_in_clip_monitor_check, auto_center_check, auto_move_on_edit, grfx_insert_length_spin = edit_prefs_widgets
152
prefs.open_in_last_opended_media_dir = open_in_last_opened_check.get_active()
153
prefs.display_splash_screen = disp_splash.get_active()
155
prefs.default_profile_name = mltprofiles.get_profile_name_for_index(default_profile_combo.get_active())
156
prefs.track_configuration = default_tracks_combo.get_active()
157
prefs.undos_max = undo_max_spin.get_adjustment().get_value()
159
prefs.auto_play_in_clip_monitor = auto_play_in_clip_monitor_check.get_active()
160
prefs.auto_center_on_play_stop = auto_center_check.get_active()
161
prefs.auto_move_after_edit = auto_move_on_edit.get_active()
163
prefs.default_grfx_length = int(grfx_insert_length_spin.get_adjustment().get_value())
165
def get_graphics_default_in_out_length():
166
in_fr = int(15000/2) - int(prefs.default_grfx_length/2)
167
out_fr = in_fr + int(prefs.default_grfx_length) - 1 # -1, out inclusive
168
return (in_fr, out_fr, prefs.default_grfx_length)
171
class EditorPreferences:
173
Class holds data of persistant user preferences for editor.
177
self.open_in_last_opended_media_dir = True
178
self.last_opened_media_dir = None
179
self.img_length = 2000
180
self.auto_save_delay_value_index = 1 # value is index of self.AUTO_SAVE_OPTS
181
self.undos_max = UNDO_STACK_DEFAULT
182
self.default_profile_name = 10 # index of default profile
183
self.auto_play_in_clip_monitor = False
184
self.auto_center_on_play_stop = False
185
self.thumbnail_folder = None
186
self.hidden_profile_names = []
187
self.display_splash_screen = True
188
self.auto_move_after_edit = False
189
self.default_grfx_length = 250 # value is in frames
190
self.track_configuration = 0 # this is index on list appconsts.TRACK_CONFIGURATIONS
191
self.AUTO_SAVE_OPTS = ((-1, _("No Autosave")),(1, _("1 min")),(2, _("2 min")),(5, _("5 min")))