[commit-gajim] r11216 - trunk/src

asterix at gajim.org asterix at gajim.org
Wed Apr 8 18:28:52 CEST 2009


Author: asterix
Date: 2009-04-08 18:28:51 +0200 (Wed, 08 Apr 2009)
New Revision: 11216

Modified:
   trunk/src/chat_control.py
   trunk/src/groupchat_control.py
   trunk/src/message_control.py
   trunk/src/message_window.py
Log:
Warn user before closing chat window with tabs where we can loose data. Fixes #3645


Modified: trunk/src/chat_control.py
===================================================================
--- trunk/src/chat_control.py	2009-04-08 09:58:49 UTC (rev 11215)
+++ trunk/src/chat_control.py	2009-04-08 16:28:51 UTC (rev 11216)
@@ -2327,6 +2327,9 @@
 		self.conv_textview.del_handlers()
 		self.msg_textview.destroy()
 
+	def safe_shutdown(self):
+		return False
+
 	def allow_shutdown(self, method, on_yes, on_no, on_minimize):
 		if time.time() - gajim.last_message_time[self.account]\
 		[self.get_full_jid()] < 2:

Modified: trunk/src/groupchat_control.py
===================================================================
--- trunk/src/groupchat_control.py	2009-04-08 09:58:49 UTC (rev 11215)
+++ trunk/src/groupchat_control.py	2009-04-08 16:28:51 UTC (rev 11216)
@@ -1796,6 +1796,19 @@
 		# Remove unread events from systray
 		gajim.events.remove_events(self.account, self.room_jid)
 
+	def safe_shutdown(self):
+		if self.contact.jid in gajim.config.get_per('accounts', self.account,
+		'minimized_gc').split(' '):
+			return True
+		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
+		if (gajim.config.get('confirm_close_muc') or self.room_jid in includes) \
+		and gajim.gc_connected[self.account][self.room_jid] and self.room_jid not\
+		in excludes:
+			return False
+		return True
+
 	def allow_shutdown(self, method, on_yes, on_no, on_minimize):
 		if self.contact.jid in gajim.config.get_per('accounts', self.account,
 		'minimized_gc').split(' '):

Modified: trunk/src/message_control.py
===================================================================
--- trunk/src/message_control.py	2009-04-08 09:58:49 UTC (rev 11215)
+++ trunk/src/message_control.py	2009-04-08 16:28:51 UTC (rev 11216)
@@ -71,6 +71,12 @@
 		or inactive (state is False)'''
 		pass  # Derived classes MUST implement this method
 
+	def safe_shutdown(self):
+		'''Called to check if control can be closed without loosing data.
+		returns True if control can be closed safely else False'''
+		# NOTE: Derived classes MAY implement this
+		return True
+
 	def allow_shutdown(self, method, on_response_yes, on_response_no,
 	on_response_minimize):
 		'''Called to check is a control is allowed to shutdown.

Modified: trunk/src/message_window.py
===================================================================
--- trunk/src/message_window.py	2009-04-08 09:58:49 UTC (rev 11215)
+++ trunk/src/message_window.py	2009-04-08 16:28:51 UTC (rev 11216)
@@ -34,6 +34,7 @@
 import common
 import gtkgui_helpers
 import message_control
+import dialogs
 from chat_control import ChatControlBase
 
 from common import gajim
@@ -193,6 +194,29 @@
 			# Destroy the window
 			return False
 
+		# Number of controls that will be closed and for which we'll loose data:
+		# chat, pm, gc that won't go in roster
+		number_of_closed_control = 0
+		for ctrl in self.controls():
+			if not ctrl.safe_shutdown():
+				number_of_closed_control += 1
+
+		if number_of_closed_control > 1:
+			def on_yes1(checked):
+				if checked:
+					gajim.config.set('confirm_close_multiple_tabs', False)
+				self.dont_warn_on_delete = True
+				win.destroy()
+
+			if not gajim.config.get('confirm_close_multiple_tabs'):
+				# destroy window
+				return False
+			dialogs.YesNoDialog(
+				_('You are going to close several tabs'),
+            _('Do you really want to close them all?'),
+				checktext=_('Do _not ask me again'), on_response_yes=on_yes1)
+			return True
+
 		def on_yes(ctrl):
 			if self.on_delete_ok == 1:
 				self.dont_warn_on_delete = True



More information about the Commits mailing list