Commit 96454134 authored by Philipp Hörist's avatar Philipp Hörist

AdHoc: Adapt to nbxmpp changes

parent ebe2c2ba
...@@ -17,16 +17,16 @@ ...@@ -17,16 +17,16 @@
from gi.repository import Gtk from gi.repository import Gtk
from nbxmpp.util import is_error_result
from nbxmpp.const import AdHocAction from nbxmpp.const import AdHocAction
from nbxmpp.modules import dataforms from nbxmpp.modules import dataforms
from nbxmpp.errors import StanzaError
from nbxmpp.errors import MalformedStanzaError
from gajim.common import app from gajim.common import app
from gajim.common.i18n import _ from gajim.common.i18n import _
from gajim.common.helpers import to_user_string from gajim.common.helpers import to_user_string
from gajim.gtk.dataform import DataFormWidget from gajim.gtk.dataform import DataFormWidget
from gajim.gtk.util import ensure_not_destroyed
from gajim.gtk.util import find_widget from gajim.gtk.util import find_widget
from gajim.gtk.util import MultiLineLabel from gajim.gtk.util import MultiLineLabel
...@@ -186,30 +186,25 @@ def _abort(self, *args): ...@@ -186,30 +186,25 @@ def _abort(self, *args):
command, AdHocAction.CANCEL) command, AdHocAction.CANCEL)
self.set_current_page(Page.COMMANDS) self.set_current_page(Page.COMMANDS)
@ensure_not_destroyed def _received_command_list(self, task):
def _received_command_list(self, commands): try:
error_text = None commands = task.finish()
if is_error_result(commands): except (StanzaError, MalformedStanzaError) as error:
error_text = to_user_string(commands) self._set_error(to_user_string(error), False)
return
elif not commands:
error_text = _('No commands available')
if error_text is not None: if not commands:
self.get_nth_page(Page.ERROR).set_text(error_text) self._set_error(_('No commands available'), False)
self.get_nth_page(Page.ERROR).show_command_button = False
self.set_current_page(Page.ERROR)
return return
self.get_nth_page(Page.COMMANDS).add_commands(commands) self.get_nth_page(Page.COMMANDS).add_commands(commands)
self.set_current_page(Page.COMMANDS) self.set_current_page(Page.COMMANDS)
@ensure_not_destroyed def _received_stage(self, task):
def _received_stage(self, stage): try:
if is_error_result(stage): stage = task.finish()
self.get_nth_page(Page.ERROR).set_text(to_user_string(stage)) except (StanzaError, MalformedStanzaError) as error:
self.get_nth_page(Page.ERROR).show_command_button = True self._set_error(to_user_string(error), True)
self.set_current_page(Page.ERROR)
return return
page = Page.STAGE page = Page.STAGE
...@@ -220,6 +215,11 @@ def _received_stage(self, stage): ...@@ -220,6 +215,11 @@ def _received_stage(self, stage):
stage_page.process_stage(stage) stage_page.process_stage(stage)
self.set_current_page(page) self.set_current_page(page)
def _set_error(self, text, show_command_button):
self.get_nth_page(Page.ERROR).set_text(text)
self.get_nth_page(Page.ERROR).show_command_button = show_command_button
self.set_current_page(Page.ERROR)
def set_stage_complete(self, is_valid): def set_stage_complete(self, is_valid):
self._buttons['next'].set_sensitive(is_valid) self._buttons['next'].set_sensitive(is_valid)
self._buttons['complete'].set_sensitive(is_valid) self._buttons['complete'].set_sensitive(is_valid)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment