diff --git a/data/glade/adhoc_commands_window.glade b/data/glade/adhoc_commands_window.glade index 1339776b9..6d7a4b8b6 100644 --- a/data/glade/adhoc_commands_window.glade +++ b/data/glade/adhoc_commands_window.glade @@ -92,26 +92,7 @@ - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - tab - + @@ -157,6 +138,41 @@ True + + + + True + False + 0 + + + + + + + + True + True + Check once more + True + GTK_RELIEF_NORMAL + True + + + + 0 + False + False + GTK_PACK_END + + + + + 0 + True + True + + False @@ -165,26 +181,7 @@ - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - tab - + @@ -245,45 +242,79 @@ - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - tab - + - + True - This jabber entity doesn't expose any commands. - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 + False + 0 + + + + True + This jabber entity does not expose any commands. + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + + + + + True + False + 0 + + + + + + + + True + True + Check once more + True + GTK_RELIEF_NORMAL + True + + + + 0 + False + False + GTK_PACK_END + + + + + 0 + True + True + GTK_PACK_END + + False @@ -292,45 +323,64 @@ - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - tab - + - + True - An error has occured. - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 + False + 0 + + + + True + An error has occured: + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + Error description... + False + False + GTK_JUSTIFY_LEFT + True + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + False @@ -339,26 +389,7 @@ - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - tab - + diff --git a/src/adhoc_commands.py b/src/adhoc_commands.py index ec2b7b2b0..ce0a936a9 100644 --- a/src/adhoc_commands.py +++ b/src/adhoc_commands.py @@ -56,7 +56,8 @@ class CommandWindow: 'execute_button','stages_notebook', 'retrieving_commands_stage_vbox', 'command_list_stage_vbox','command_list_vbox', - 'sending_form_stage_vbox'): + 'sending_form_stage_vbox','no_commands_stage_vbox', + 'error_stage_vbox', 'error_description_label'): self.__dict__[name] = self.xml.get_widget(name) # setting initial stage @@ -78,6 +79,7 @@ class CommandWindow: def on_forward_button_clicked(self, *anything): pass def on_execute_button_clicked(self, *anything): pass def on_adhoc_commands_window_destroy(self, *anything): pass + def do_nothing(self, *anything): pass # stage 1: waiting for command list def stage1(self): @@ -142,10 +144,16 @@ class CommandWindow: self.command_list_vbox.pack_end(radio, expand=False) self.command_list_vbox.show_all() - self.stage_finish = self.stage_finish + self.stage_finish = self.stage2_finish self.on_cancel_button_clicked = self.stage2_on_cancel_button_clicked self.on_forward_button_clicked = self.stage2_on_forward_button_clicked + def stage2_finish(self): + '''Remove widgets we created.''' + def remove_widget(widget): + self.command_list_vbox.remove(widget) + self.command_list_vbox.foreach(remove_widget) + def stage2_on_cancel_button_clicked(self): self.stage_finish() self.window.destroy() @@ -153,6 +161,58 @@ class CommandWindow: def stage2_on_forward_button_clicked(self): pass + def on_check_commands_1_button_clicked(self, widget): + self.stage1() + +# stage 4: no commands are exposed + def stage4(self): + '''Display the message. Wait for user to close the window''' + # close old stage + self.stage_finish() + + self.stages_notebook.set_current_page( + self.stages_notebook.page_num( + self.no_commands_stage_vbox)) + + self.cancel_button.set_sensitive(True) + self.back_button.set_sensitive(False) + self.forward_button.set_sensitive(False) + self.execute_button.set_sensitive(False) + + self.stage_finish = self.do_nothing + self.on_cancel_button_clicked = self.stage4_on_cancel_button_clicked + + def stage4_on_cancel_button_clicked(self): + self.window.destroy() + + def on_check_commands_2_button_clicked(self, widget): + self.stage1() + +# stage 5: an error has occured + def stage5(self, error): + '''Display the error message. Wait for user to close the window''' + # close old stage + self.stage_finish() + + assert isinstance(error, unicode) + + self.stages_notebook.set_current_page( + self.stages_notebook.page_num( + self.error_stage_vbox)) + + self.cancel_button.set_sensitive(True) + self.back_button.set_sensitive(False) + self.forward_button.set_sensitive(False) + self.execute_button.set_sensitive(False) + + self.error_description_label.set_text(error) + + self.stage_finish = self.do_nothing + self.on_cancel_button_clicked = self.stage5_on_cancel_button_clicked + + def stage5_on_cancel_button_clicked(self): + self.window.destroy() + # helpers to handle pulsing in progressbar def setup_pulsing(self, progressbar): '''Set the progressbar to pulse. Makes a custom @@ -184,14 +244,18 @@ class CommandWindow: # is error => error stage error = response.getError() if error is not None: - pass + # extracting error description from xmpp/protocol.py + errorname=xmpp.NS_STANZAS + ' ' + str(error) + errordesc=xmpp.ERRORS[errorname][2] + self.stage5(errordesc.decode('utf-8')) + return # no commands => no commands stage # commands => command selection stage items = response.getTag('query').getTags('item') if len(items)==0: self.commandlist = [] - self.stage2() # stageX, where X is the number for error page + self.stage4() else: self.commandlist = [(t.getAttr('node'), t.getAttr('name')) for t in items] self.stage2()