From 86e9a38188a2680941f411472e6bd53cc7d45d6e Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Sat, 10 Apr 2010 17:37:54 -0300 Subject: [PATCH] Recheck actions when the updatebox closes. --- mitterlib/ui/ui_pygtk.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/mitterlib/ui/ui_pygtk.py b/mitterlib/ui/ui_pygtk.py index fd7dbd9..87e5b71 100644 --- a/mitterlib/ui/ui_pygtk.py +++ b/mitterlib/ui/ui_pygtk.py @@ -402,6 +402,17 @@ class Interface(object): self._main_window.set_title(mask) return + def _hide_update_field(self): + """Hides the update field and recheck the selected message for + enabling (or not) the actions.""" + self._update_field.hide() + page = self._main_tabs.get_current_page() + child = self._main_tabs.get_nth_page(page) + + if child.selected: + self._message_changed(child, child.selected) + return + # ------------------------------------------------------------ # Widget callback functions # ------------------------------------------------------------ @@ -486,7 +497,7 @@ class Interface(object): status = self._update_field.text.strip() if not status: _log.debug('Empty message, aborting.') - self._update_field.hide() + self._hide_update_field() return page = self._main_tabs.get_current_page() @@ -494,7 +505,7 @@ class Interface(object): if child.selected: if child.selected.reply_prefix.strip() == status: _log.debug('Empty reply, aborting.') - self._udpate_field.hide() + self._hide_update_field() return _log.debug('Status: %s', status) @@ -511,7 +522,7 @@ class Interface(object): def _clear_text(self, widget): """Clear the text field.""" self._clear_reply() - self._update_field.hide() + self._hide_update_field() # change the focus to the grid. page = self._main_tabs.get_current_page() @@ -855,6 +866,15 @@ class Interface(object): self._update_statusbar(_('Your status was updated.')) self._action_group.get_action('Update').set_sensitive(True) self._clear_text(None) + + # re-enable (or not) the actions based on the currently selected + # message + page = self._main_tabs.get_current_page() + grid = self._main_tabs.get_nth_page(page) + message = grid.selected + + if message: + self._message_changed(grid, message) return def _exception_update_status(self, widget, exception):