Skip to content

Commit

Permalink
Fix undo and redo button dropdowns when no document open
Browse files Browse the repository at this point in the history
Closes #29
  • Loading branch information
otsaloma committed Aug 11, 2016
1 parent 75ff5e6 commit a46fba5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
3 changes: 3 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ Gaupol 0.92/1.0

* [x] Fix error saving document from a time-based format to a
frame-based or vice versa ([#28][])
* [x] Fix error clicking undo or redo button dropdown arrow when no
document is yet open ([#29][])

[#28]: https://github.com/otsaloma/gaupol/issues/28
[#29]: https://github.com/otsaloma/gaupol/issues/29
18 changes: 14 additions & 4 deletions gaupol/agents/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,13 @@ def _on_redo_button_show_menu(self, *args):
for item in menu.get_children():
menu.remove(item)
self._redo_menu_items = []
page = self.get_current_page()
for i, action in enumerate(page.project.redoables):
redoables = []
with aeidon.util.silent(AttributeError):
# XXX: Gtk.Actionable.set_action_name doesn't affect the dropdown
# arrow making it clickable even when there's nothing to redo.
page = self.get_current_page()
redoables = page.project.redoables
for i, action in enumerate(redoables):
item = Gtk.MenuItem(label=action.description)
item.gaupol_index = i
item.connect("activate", self._on_redo_menu_item_activate)
Expand Down Expand Up @@ -161,8 +166,13 @@ def _on_undo_button_show_menu(self, *args):
for item in menu.get_children():
menu.remove(item)
self._undo_menu_items = []
page = self.get_current_page()
for i, action in enumerate(page.project.undoables):
undoables = []
with aeidon.util.silent(AttributeError):
# XXX: Gtk.Actionable.set_action_name doesn't affect the dropdown
# arrow making it clickable even when there's nothing to undo.
page = self.get_current_page()
undoables = page.project.undoables
for i, action in enumerate(undoables):
item = Gtk.MenuItem(label=action.description)
item.gaupol_index = i
item.connect("activate", self._on_undo_menu_item_activate)
Expand Down

0 comments on commit a46fba5

Please sign in to comment.