gnome-games r7968 - trunk/glchess/src/lib/gtkui



Author: rancell
Date: Wed Oct  8 08:02:15 2008
New Revision: 7968
URL: http://svn.gnome.org/viewvc/gnome-games?rev=7968&view=rev

Log:
Only allow one new/load game dialog to be visible at once. (Bug #546702)

Modified:
   trunk/glchess/src/lib/gtkui/dialogs.py
   trunk/glchess/src/lib/gtkui/gtkui.py

Modified: trunk/glchess/src/lib/gtkui/dialogs.py
==============================================================================
--- trunk/glchess/src/lib/gtkui/dialogs.py	(original)
+++ trunk/glchess/src/lib/gtkui/dialogs.py	Wed Oct  8 08:02:15 2008
@@ -250,7 +250,7 @@
         self.window.present()
         self.__checking = False
         self.__testReady()
-        
+
     # Private methods
     
     def __setCombo(self, comboName, key):
@@ -384,6 +384,8 @@
         if responseId == gtk.RESPONSE_OK:
             self.__startGame()
         dialog.destroy()
+        if self.__mainUI.newGameDialog is self:
+            self.__mainUI.newGameDialog = None
 
 class GtkLoadGameDialog:
     """
@@ -452,6 +454,8 @@
                 return
 
         dialog.destroy()
+        if self.__mainUI.loadGameDialog is self:
+            self.__mainUI.loadGameDialog = None
         
 class GtkSaveGameDialog:
     """

Modified: trunk/glchess/src/lib/gtkui/gtkui.py
==============================================================================
--- trunk/glchess/src/lib/gtkui/gtkui.py	(original)
+++ trunk/glchess/src/lib/gtkui/gtkui.py	Wed Oct  8 08:02:15 2008
@@ -203,6 +203,8 @@
         self.feedback = feedback
         self._watches = {}
         self.__networkGames = {}
+        self.newGameDialog = None
+        self.loadGameDialog = None
         self.__saveGameDialogs = {}
         self.__joinGameDialogs = []
         
@@ -784,7 +786,10 @@
 
     def _on_new_game_button_clicked(self, widget):
         """Gtk+ callback"""
-        dialogs.GtkNewGameDialog(self, self.__playerModel)
+        if self.newGameDialog:
+            self.newGameDialog.window.present()
+        else:
+            self.newGameDialog = dialogs.GtkNewGameDialog(self, self.__playerModel)
 
     def _on_join_game_button_clicked(self, widget):
         """Gtk+ callback"""
@@ -792,19 +797,30 @@
 
     def _on_open_game_button_clicked(self, widget):
         """Gtk+ callback"""
-        dialogs.GtkLoadGameDialog(self)
+        if self.loadGameDialog:
+            self.loadGameDialog.window.present()
+        else:
+            self.loadGameDialog = dialogs.GtkLoadGameDialog(self)
         
     def _on_save_game_button_clicked(self, widget):
         """Gtk+ callback"""
         if self.view.feedback.getFileName() is not None:
             self.view.feedback.save()
-        elif not self.__saveGameDialogs.has_key(self.view):
-            self.__saveGameDialogs[self.view] = dialogs.GtkSaveGameDialog(self, self.view)
-            
+            return
+        
+        try:
+            dialog = self.__saveGameDialogs[self.view]
+        except KeyError:
+            dialog = self.__saveGameDialogs[self.view] = dialogs.GtkSaveGameDialog(self, self.view)
+        dialog.window.present()
+
     def _on_save_as_game_button_clicked(self, widget):
         """Gtk+ callback"""
-        if not self.__saveGameDialogs.has_key(self.view):
-            self.__saveGameDialogs[self.view] = dialogs.GtkSaveGameDialog(self, self.view, self.view.feedback.getFileName())
+        try:
+            dialog = self.__saveGameDialogs[self.view]
+        except KeyError:
+            dialog = self.__saveGameDialogs[self.view] = dialogs.GtkSaveGameDialog(self, self.view, self.view.feedback.getFileName())
+        dialog.window.present()
 
     def _on_resign_clicked(self, widget):
         """Gtk+ callback"""



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]