Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorflorent <florent.pigout@gmail.com>2011-04-20 10:19:55 (GMT)
committer florent <florent.pigout@gmail.com>2011-04-20 10:19:55 (GMT)
commit79baf8c40594ca9f874994cf80508a2b5d44eeae (patch)
tree8efabbd08ef8060a537e42a04767f713272d8721
parent0727ad5bc453bfdeddf6729bb4054ed1f4451142 (diff)
ensure valid sequences in timeline after sequence removal from add screens
-rw-r--r--atoidejouer/story/keys.py25
-rw-r--r--atoidejouer/ui/notebook.py4
-rw-r--r--atoidejouer/ui/screens.py2
-rw-r--r--atoidejouer/ui/timeline.py26
-rw-r--r--atoidejouer/ui/toolbar.py10
5 files changed, 51 insertions, 16 deletions
diff --git a/atoidejouer/story/keys.py b/atoidejouer/story/keys.py
index 10048da..4bebb2e 100644
--- a/atoidejouer/story/keys.py
+++ b/atoidejouer/story/keys.py
@@ -72,10 +72,13 @@ class StoryKeys(object):
self._names.append(_n)
# ensure keys
for _seq_name, _seq_dict in _tmp_keys.items():
+ # get seq_path for check
+ _seq_path = storage.get_sequence_path(self._type, _seq_name)
# little check
if _seq_name in self._keys:
continue
- else:
+ # check path
+ elif os.path.exists(_seq_path):
# init seq dict copy
_tmp_seq_dict = dict()
# work on seq dict copy
@@ -84,6 +87,12 @@ class StoryKeys(object):
_tmp_seq_dict[int(_frame_name)] = _frame_dict
# update main dict
self._keys[_seq_name] = _tmp_seq_dict
+ # sequence does not exist
+ else:
+ if _seq_name in self._names:
+ self._names.remove(_seq_name)
+ else:
+ pass
# ..
return _exist_list
@@ -618,7 +627,21 @@ class StoryKeys(object):
self.set_current(sequence_name, _i, _f,
file_type=_f_type, key_type='transition')
+ def check_sequences(self):
+ # sequence check
+ _s_to_remove = list()
+ for _s_name in self._names:
+ _path = storage.get_sequence_path(self._type, _s_name)
+ if os.path.exists(_path):
+ continue
+ else:
+ _s_to_remove.append(_s_name)
+ # ..
+ for _s_name in _s_to_remove:
+ self.remove_sequence(_s_name)
+
def refresh(self, sequence_name):
+ # ..
if self._type == 'graphics':
self._refresh_graphic_keys(sequence_name)
else:
diff --git a/atoidejouer/ui/notebook.py b/atoidejouer/ui/notebook.py
index 704dff7..517de08 100644
--- a/atoidejouer/ui/notebook.py
+++ b/atoidejouer/ui/notebook.py
@@ -175,10 +175,8 @@ class ResourceNotebook(gtk.Frame):
return
else:
# ..
- _seq_filename = '%s.seq' % self.current_sequence
- # ..
_gfx_filename = storage.get_sequence_first_graphic_name(
- self._type, _seq_filename)
+ self._type, self.current_sequence)
# set current
self.screen.sequence_preview.set_current(_gfx_filename)
diff --git a/atoidejouer/ui/screens.py b/atoidejouer/ui/screens.py
index 951fd76..e943ade 100644
--- a/atoidejouer/ui/screens.py
+++ b/atoidejouer/ui/screens.py
@@ -480,6 +480,8 @@ class ScreenEdit(gtk.HBox):
# show self
self.show_all()
# ..
+ self.toolbar.story_keys.check_sequences()
+ # ..
self.scene.refresh()
# get current time
self.timeline.refresh()
diff --git a/atoidejouer/ui/timeline.py b/atoidejouer/ui/timeline.py
index 5953f9c..51a5f53 100644
--- a/atoidejouer/ui/timeline.py
+++ b/atoidejouer/ui/timeline.py
@@ -105,7 +105,7 @@ class Timeline(gtk.Frame):
# ...
for _i, _r in enumerate(_t_rows):
# title row | row - eventbox - button - label
- _label = _r.get_children()[0].get_children()[0].get_children()[0]
+ _label = _r.get_children()[0].get_children()[0].get_children()[1]
# prepare color
_c = _c1 if _label.get_label() == sequence_name else _c2
# update row color
@@ -265,7 +265,7 @@ class Timeline(gtk.Frame):
# ...
for _i, _r in enumerate(_t_children):
# title row | row - eventbox - button - label
- _label = _r.get_children()[0].get_children()[0].get_children()[0]
+ _label = _r.get_children()[0].get_children()[0].get_children()[1]
# ...
if _label.get_label() in _names:
_index = _names.index(_label.get_label())
@@ -296,7 +296,7 @@ class Timeline(gtk.Frame):
# ...
for _i, _r in enumerate(_t_children):
# title row | row - eventbox - button - label
- _label = _r.get_children()[0].get_children()[0].get_children()[0]
+ _label = _r.get_children()[0].get_children()[0].get_children()[1]
# ...
if _label.get_label() == sequence_name:
_r.destroy()
@@ -308,16 +308,24 @@ class Timeline(gtk.Frame):
# ...
_t_children = self._titles_box.get_children()
_k_children = self._keys_box.get_children()
+ # sequence to remove
+ _seq_to_remove = list()
# ...
for _i, _r in enumerate(_t_children):
# title row | row - eventbox - button - label
_label_wid = _r.get_children()[0].get_children()[0].get_children()[1]
- _label_str = _label_wid.get_label()
+ _seq_name = _label_wid.get_label()
+ # seq check
+ if _seq_name in self.story_keys._names:
+ pass
+ else:
+ _seq_to_remove.append(_seq_name)
+ continue
# ...
for _frame, _c_key in enumerate(_k_children[_i].get_children()[0]):
# ...
_current, _f_type, _k_type = self.story_keys.get_current(
- _label_str, _frame)
+ _seq_name, _frame)
# get button
_button = _c_key.get_children()[0]
# ...
@@ -330,6 +338,10 @@ class Timeline(gtk.Frame):
else:
# _button.set_image(None)
_button.set_label("0")
+ # remove non-exisitng sequences
+ for _s_name in _seq_to_remove:
+ self.remove_sequence(_s_name)
+
def __reset(self):
# ..
@@ -372,5 +384,7 @@ class Timeline(gtk.Frame):
# first avoid current keys colors
for _c in self._current_keys.values():
glib.idle_add(partial(_c.set_visible_window, False))
- # TODO change cell colors
+ # change cell colors
self._refresh_keys(_time)
+ # udpate sequences
+ self.refresh_sequence()
diff --git a/atoidejouer/ui/toolbar.py b/atoidejouer/ui/toolbar.py
index 802eb6d..71a5f96 100644
--- a/atoidejouer/ui/toolbar.py
+++ b/atoidejouer/ui/toolbar.py
@@ -80,14 +80,14 @@ def _cb_seq_remove(widget, toolbar):
else:
# prepare sequence path
_name = _name.replace(' ', '_')
- _name = '%s.seq' % _name.lower()
# get sequence path
- _seq_path = os.path.join(activity.get_activity_root(), 'data',
- 'sequences', _type, _name)
+ _seq_path = storage.get_sequence_path(_type, _name.lower())
# remove dir
if os.path.exists(_seq_path):
# do clean
os.remove(_seq_path)
+ # update sequences in keys
+ # toolbar.story_keys.check_sequences()
# and clear all at the end
_screen.sequence_preview.clear()
# clear entry
@@ -116,10 +116,8 @@ def _cb_seq_save(widget, toolbar):
else:
# prepare sequence path
_name = _name.replace(' ', '_')
- _name = '%s.seq' % _name.lower()
# get sequence path
- _seq_path = os.path.join(activity.get_activity_root(), 'data',
- 'sequences', _type, _name)
+ _seq_path = storage.get_sequence_path(_type, _name.lower())
# open file
_file = open(_seq_path, 'wb')
# TODO - copy files