ability to restart adhoc process from every stage
This commit is contained in:
parent
61b26858d5
commit
f1e6e9245e
|
@ -99,6 +99,7 @@ class CommandWindow:
|
|||
self.stage1()
|
||||
|
||||
# displaying the window
|
||||
self.window.set_title('Ad-hoc Commands - Gajim')
|
||||
self.xml.connect_signals(self)
|
||||
self.window.show_all()
|
||||
|
||||
|
@ -120,6 +121,9 @@ class CommandWindow:
|
|||
def stage_close_button_clicked(self, *anything):
|
||||
assert False
|
||||
|
||||
def stage_restart_button_clicked(self, *anything):
|
||||
assert False
|
||||
|
||||
def stage_adhoc_commands_window_delete_event(self, *anything):
|
||||
assert False
|
||||
|
||||
|
@ -142,6 +146,9 @@ class CommandWindow:
|
|||
def on_close_button_clicked(self, *anything):
|
||||
return self.stage_close_button_clicked(*anything)
|
||||
|
||||
def on_restart_button_clicked(self, *anything):
|
||||
return self.stage_restart_button_clicked(*anything)
|
||||
|
||||
def on_adhoc_commands_window_destroy(self, *anything):
|
||||
# TODO: do all actions that are needed to remove this object from memory
|
||||
self.remove_pulsing()
|
||||
|
@ -176,11 +183,12 @@ class CommandWindow:
|
|||
# request command list
|
||||
self.request_command_list()
|
||||
self.setup_pulsing(
|
||||
self.xml.get_object('retrieving_commands_progressbar'))
|
||||
self.xml.get_object('retrieving_commands_progressbar'))
|
||||
|
||||
# setup the callbacks
|
||||
self.stage_finish = self.stage1_finish
|
||||
self.stage_close_button_clicked = self.stage1_close_button_clicked
|
||||
self.stage_restart_button_clicked = self.stage1_restart_button_clicked
|
||||
self.stage_adhoc_commands_window_delete_event = \
|
||||
self.stage1_adhoc_commands_window_delete_event
|
||||
|
||||
|
@ -190,9 +198,13 @@ class CommandWindow:
|
|||
def stage1_close_button_clicked(self, widget):
|
||||
# cancelling in this stage is not critical, so we don't
|
||||
# show any popups to user
|
||||
self.stage1_finish()
|
||||
self.stage_finish()
|
||||
self.window.destroy()
|
||||
|
||||
def stage1_restart_button_clicked(self, widget):
|
||||
self.stage_finish()
|
||||
self.restart()
|
||||
|
||||
def stage1_adhoc_commands_window_delete_event(self, widget):
|
||||
self.stage1_finish()
|
||||
return True
|
||||
|
@ -233,6 +245,7 @@ class CommandWindow:
|
|||
|
||||
self.stage_finish = self.stage2_finish
|
||||
self.stage_close_button_clicked = self.stage2_close_button_clicked
|
||||
self.stage_restart_button_clicked = self.stage2_restart_button_clicked
|
||||
self.stage_forward_button_clicked = self.stage2_forward_button_clicked
|
||||
self.stage_adhoc_commands_window_delete_event = self.do_nothing
|
||||
|
||||
|
@ -248,6 +261,10 @@ class CommandWindow:
|
|||
self.stage_finish()
|
||||
self.window.destroy()
|
||||
|
||||
def stage2_restart_button_clicked(self, widget):
|
||||
self.stage_finish()
|
||||
self.restart()
|
||||
|
||||
def stage2_forward_button_clicked(self, widget):
|
||||
self.stage3()
|
||||
|
||||
|
@ -270,6 +287,7 @@ class CommandWindow:
|
|||
self.stages_notebook.page_num(
|
||||
self.sending_form_stage_vbox))
|
||||
|
||||
self.restart_button.set_sensitive(True)
|
||||
self.close_button.set_sensitive(True)
|
||||
self.back_button.set_sensitive(False)
|
||||
self.forward_button.set_sensitive(False)
|
||||
|
@ -284,12 +302,29 @@ class CommandWindow:
|
|||
self.stage_execute_button_clicked = self.stage3_execute_button_clicked
|
||||
self.stage_finish_button_clicked = self.stage3_finish_button_clicked
|
||||
self.stage_close_button_clicked = self.stage3_close_button_clicked
|
||||
self.stage_restart_button_clicked = self.stage3_restart_button_clicked
|
||||
self.stage_adhoc_commands_window_delete_event = \
|
||||
self.stage3_close_button_clicked
|
||||
|
||||
def stage3_finish(self):
|
||||
pass
|
||||
|
||||
def stage3_can_close(self, cb):
|
||||
if self.form_status == 'completed':
|
||||
cb()
|
||||
return
|
||||
|
||||
def on_yes(button):
|
||||
self.send_cancel()
|
||||
dialog.destroy()
|
||||
cb()
|
||||
|
||||
dialog = dialogs.HigDialog(self.window, gtk.DIALOG_DESTROY_WITH_PARENT \
|
||||
| gtk.DIALOG_MODAL, gtk.BUTTONS_YES_NO, _('Cancel confirmation'),
|
||||
_('You are in process of executing command. Do you really want to '
|
||||
'cancel it?'), on_response_yes=on_yes)
|
||||
dialog.popup()
|
||||
|
||||
def stage3_close_button_clicked(self, widget):
|
||||
"""
|
||||
We are in the middle of executing command. Ask user if he really want to
|
||||
|
@ -297,26 +332,23 @@ class CommandWindow:
|
|||
"""
|
||||
# this works also as a handler for window_delete_event, so we have to
|
||||
# return appropriate values
|
||||
if self.form_status == 'completed':
|
||||
if widget != self.window:
|
||||
self.window.destroy()
|
||||
return False
|
||||
|
||||
if self.allow_stage3_close:
|
||||
return False
|
||||
|
||||
def on_yes(button):
|
||||
self.send_cancel()
|
||||
def on_ok():
|
||||
self.allow_stage3_close = True
|
||||
self.window.destroy()
|
||||
|
||||
dialog = dialogs.HigDialog(self.window, gtk.DIALOG_DESTROY_WITH_PARENT \
|
||||
| gtk.DIALOG_MODAL, gtk.BUTTONS_YES_NO, _('Cancel confirmation'),
|
||||
_('You are in process of executing command. Do you really want to '
|
||||
'cancel it?'), on_response_yes=on_yes)
|
||||
dialog.popup()
|
||||
self.stage3_can_close(on_ok)
|
||||
|
||||
return True # Block event, don't close window
|
||||
|
||||
def stage3_restart_button_clicked(self, widget):
|
||||
def on_ok():
|
||||
self.restart()
|
||||
|
||||
self.stage3_can_close(on_ok)
|
||||
|
||||
def stage3_back_button_clicked(self, widget):
|
||||
self.stage3_submit_form('prev')
|
||||
|
||||
|
@ -407,7 +439,6 @@ class CommandWindow:
|
|||
|
||||
if self.form_status == 'completed':
|
||||
self.close_button.set_sensitive(True)
|
||||
self.restart_button.set_sensitive(True)
|
||||
self.back_button.hide()
|
||||
self.forward_button.hide()
|
||||
self.execute_button.hide()
|
||||
|
@ -425,7 +456,7 @@ class CommandWindow:
|
|||
self.notes_label.set_no_show_all(True)
|
||||
self.notes_label.hide()
|
||||
|
||||
def on_restart_button_clicked(self, widget):
|
||||
def restart(self):
|
||||
self.commandnode = None
|
||||
self.initiate()
|
||||
|
||||
|
@ -448,11 +479,15 @@ class CommandWindow:
|
|||
|
||||
self.stage_finish = self.do_nothing
|
||||
self.stage_close_button_clicked = self.stage4_close_button_clicked
|
||||
self.stage_restart_button_clicked = self.stage4_restart_button_clicked
|
||||
self.stage_adhoc_commands_window_delete_event = self.do_nothing
|
||||
|
||||
def stage4_close_button_clicked(self, widget):
|
||||
self.window.destroy()
|
||||
|
||||
def stage4_restart_button_clicked(self, widget):
|
||||
self.restart()
|
||||
|
||||
def on_check_commands_2_button_clicked(self, widget):
|
||||
self.stage1()
|
||||
|
||||
|
@ -496,11 +531,15 @@ class CommandWindow:
|
|||
|
||||
self.stage_finish = self.do_nothing
|
||||
self.stage_close_button_clicked = self.stage5_close_button_clicked
|
||||
self.stage_restart_button_clicked = self.stage5_restart_button_clicked
|
||||
self.stage_adhoc_commands_window_delete_event = self.do_nothing
|
||||
|
||||
def stage5_close_button_clicked(self, widget):
|
||||
self.window.destroy()
|
||||
|
||||
def stage5_restart_button_clicked(self, widget):
|
||||
self.restart()
|
||||
|
||||
# helpers to handle pulsing in progressbar
|
||||
def setup_pulsing(self, progressbar):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue