improve minimize on close code
This commit is contained in:
parent
0758be7c14
commit
0a165c813b
|
@ -1658,13 +1658,13 @@ class ChatControl(ChatControlBase):
|
|||
[self.get_full_jid()] < 2:
|
||||
# 2 seconds
|
||||
dialog = dialogs.ConfirmationDialog(
|
||||
#%s is being replaced in the code with JID
|
||||
# %s is being replaced in the code with JID
|
||||
_('You just received a new message from "%s"') % self.contact.jid,
|
||||
_('If you close this tab and you have history disabled, '\
|
||||
'this message will be lost.'))
|
||||
if dialog.get_response() != gtk.RESPONSE_OK:
|
||||
return False #stop the propagation of the event
|
||||
return True
|
||||
return 'no' # stop the propagation of the event
|
||||
return 'yes'
|
||||
|
||||
def handle_incoming_chatstate(self):
|
||||
''' handle incoming chatstate that jid SENT TO us '''
|
||||
|
|
|
@ -1439,9 +1439,7 @@ class GroupchatControl(ChatControlBase):
|
|||
instance = dialogs.InputDialog(title, prompt, proposed_nick,
|
||||
is_modal = False, ok_handler = on_ok)
|
||||
|
||||
def shutdown(self, status='offline'):
|
||||
if self.contact.jid in gajim.config.get_per('accounts', self.account,
|
||||
'minimized_gc').split(' '):
|
||||
def minimize(self, status='offline'):
|
||||
# Minimize it
|
||||
win = gajim.interface.msg_win_mgr.get_window(self.contact.jid,
|
||||
self.account)
|
||||
|
@ -1461,7 +1459,8 @@ class GroupchatControl(ChatControlBase):
|
|||
|
||||
gajim.interface.roster.add_groupchat_to_roster(self.account,
|
||||
self.contact.jid, status = self.subject)
|
||||
return
|
||||
|
||||
def shutdown(self, status='offline'):
|
||||
gajim.connections[self.account].send_gc_status(self.nick, self.room_jid,
|
||||
show='offline', status=status)
|
||||
nick_list = gajim.contacts.get_nick_list(self.account, self.room_jid)
|
||||
|
@ -1491,16 +1490,15 @@ class GroupchatControl(ChatControlBase):
|
|||
gajim.events.remove_events(self.account, self.room_jid)
|
||||
|
||||
def allow_shutdown(self, method):
|
||||
'''If check_selection is True, '''
|
||||
if self.contact.jid in gajim.config.get_per('accounts', self.account,
|
||||
'minimized_gc').split(' '):
|
||||
return True
|
||||
return 'minimize'
|
||||
if method == self.parent_win.CLOSE_ESC:
|
||||
model, iter = self.list_treeview.get_selection().get_selected()
|
||||
if iter:
|
||||
self.list_treeview.get_selection().unselect_all()
|
||||
return False
|
||||
retval = True
|
||||
return 'no'
|
||||
retval = 'yes'
|
||||
includes = gajim.config.get('confirm_close_muc_rooms').split(' ')
|
||||
excludes = gajim.config.get('noconfirm_close_muc_rooms').split(' ')
|
||||
# whether to ask for comfirmation before closing muc
|
||||
|
@ -1516,7 +1514,7 @@ class GroupchatControl(ChatControlBase):
|
|||
_('Do _not ask me again'))
|
||||
|
||||
if dialog.get_response() != gtk.RESPONSE_OK:
|
||||
retval = False
|
||||
retval = 'no'
|
||||
|
||||
if dialog.is_checked(): # user does not want to be asked again
|
||||
gajim.config.set('confirm_close_muc', False)
|
||||
|
|
|
@ -56,9 +56,9 @@ class MessageControl:
|
|||
def allow_shutdown(self, method):
|
||||
'''Called to check is a control is allowed to shutdown.
|
||||
If a control is not in a suitable shutdown state this method
|
||||
should return False'''
|
||||
should return 'no', else 'yes' or 'minimize' '''
|
||||
# NOTE: Derived classes MAY implement this
|
||||
return True
|
||||
return 'yes'
|
||||
|
||||
def shutdown(self):
|
||||
# NOTE: Derived classes MUST implement this
|
||||
|
|
|
@ -147,8 +147,12 @@ class MessageWindow:
|
|||
def _on_window_delete(self, win, event):
|
||||
# Make sure all controls are okay with being deleted
|
||||
for ctrl in self.controls():
|
||||
if not ctrl.allow_shutdown(self.CLOSE_CLOSE_BUTTON):
|
||||
if ctrl.allow_shutdown(self.CLOSE_CLOSE_BUTTON) == 'no':
|
||||
return True # halt the delete
|
||||
# If all are ok, minimize the one that need to be minimized
|
||||
for ctrl in self.controls():
|
||||
if ctrl.allow_shutdown(self.CLOSE_CLOSE_BUTTON) == 'minimize':
|
||||
ctrl.minimize()
|
||||
return False
|
||||
|
||||
def _on_window_destroy(self, win):
|
||||
|
@ -301,7 +305,12 @@ class MessageWindow:
|
|||
'''reason is only for gc (offline status message)
|
||||
if force is True, do not ask any confirmation'''
|
||||
# Shutdown the MessageControl
|
||||
if not force and not ctrl.allow_shutdown(method):
|
||||
allow_shutdown = ctrl.allow_shutdown(method)
|
||||
if not force and allow_shutdown == 'no':
|
||||
return
|
||||
if allow_shutdown == 'minimize' and method != self.CLOSE_COMMAND:
|
||||
ctrl.minimize()
|
||||
self.check_tabs()
|
||||
return
|
||||
if reason is not None: # We are leaving gc with a status message
|
||||
ctrl.shutdown(reason)
|
||||
|
|
Loading…
Reference in New Issue