[Pkg-bazaar-commits] ./bzr-gtk/unstable r577: Merge fix for dialogs to set parent window

Jasper Groenewegen colbrac at xs4all.nl
Fri Apr 10 07:44:31 UTC 2009


------------------------------------------------------------
revno: 577
committer: Jasper Groenewegen <colbrac at xs4all.nl>
branch nick: trunk
timestamp: Sun 2008-07-27 13:45:14 +0200
message:
  Merge fix for dialogs to set parent window
modified:
  NEWS
  commit.py
  dialog.py
    ------------------------------------------------------------
    revno: 576.1.1
    committer: Jasper Groenewegen <colbrac at xs4all.nl>
    branch nick: LP252208-dialogsparents
    timestamp: Sun 2008-07-27 09:59:23 +0200
    message:
      Add parent setting to dialogs and implement in gcommit
    modified:
      commit.py
      dialog.py
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2008-07-25 19:54:31 +0000
+++ b/NEWS	2008-07-27 11:45:14 +0000
@@ -59,6 +59,8 @@
   * Automatically change to history mode on selecting a revision from the list. (Jasper Groenewegen, #144963)
 
   * Check if file is versioned before opening gannotate window from olive. (Jasper Groenewegen, #115358)
+  
+  * Make sure error/info/warning dialogs know their parent window. (Jasper Groenewegen, #252208)
 
  CHANGES
 

=== modified file 'commit.py'
--- a/commit.py	2008-06-07 09:00:24 +0000
+++ b/commit.py	2008-07-27 07:59:23 +0000
@@ -14,6 +14,9 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+import os.path
+import re
+
 try:
     import pygtk
     pygtk.require("2.0")
@@ -24,16 +27,13 @@
 import gobject
 import pango
 
-import os.path
-import re
-
 from bzrlib import errors, osutils
 from bzrlib.trace import mutter
 from bzrlib.util import bencode
 
 from bzrlib.plugins.gtk import _i18n
-from dialog import error_dialog, question_dialog
-from errors import show_bzr_error
+from bzrlib.plugins.gtk.dialog import question_dialog
+from bzrlib.plugins.gtk.errors import show_bzr_error
 
 try:
     import dbus
@@ -105,7 +105,6 @@
                                   parent=parent,
                                   flags=0,
                                   buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
-        self._question_dialog = question_dialog
 
         self._wt = wt
         # TODO: Do something with this value, it is used by Olive
@@ -651,9 +650,10 @@
         message = self._get_global_commit_message()
 
         if message == '':
-            response = self._question_dialog(
+            response = question_dialog(
                 _i18n('Commit with an empty message?'),
-                _i18n('You can describe your commit intent in the message.'))
+                _i18n('You can describe your commit intent in the message.'),
+                parent=self)
             if response == gtk.RESPONSE_NO:
                 # Kindly give focus to message area
                 self._global_message_text_view.grab_focus()
@@ -671,9 +671,11 @@
         #       entirely, since there isn't a way for them to add the unknown
         #       files at this point.
         for path in self._wt.unknowns():
-            response = self._question_dialog(
+            response = question_dialog(
                 _i18n("Commit with unknowns?"),
-                _i18n("Unknown files exist in the working tree. Commit anyway?"))
+                _i18n("Unknown files exist in the working tree. Commit anyway?"),
+                parent=self)
+                # Doesn't set a parent for the dialog..
             if response == gtk.RESPONSE_NO:
                 return
             break
@@ -690,10 +692,11 @@
                        specific_files=specific_files,
                        revprops=revprops)
         except errors.PointlessCommit:
-            response = self._question_dialog(
+            response = question_dialog(
                 _i18n('Commit with no changes?'),
                 _i18n('There are no changes in the working tree.'
-                      ' Do you want to commit anyway?'))
+                      ' Do you want to commit anyway?'),
+                parent=self)
             if response == gtk.RESPONSE_YES:
                 rev_id = self._wt.commit(message,
                                allow_pointless=True,

=== modified file 'dialog.py'
--- a/dialog.py	2008-04-11 20:34:06 +0000
+++ b/dialog.py	2008-07-27 07:59:23 +0000
@@ -21,17 +21,16 @@
     pass
 
 import gtk
-import gtk.glade
-
-
-def _message_dialog(type, primary, secondary, buttons=gtk.BUTTONS_OK):
+
+
+def _message_dialog(type, primary, secondary, parent=None, buttons=gtk.BUTTONS_OK):
     """ Display a given type of MessageDialog with the given message.
     
     :param type: message dialog type
     
     :param message: the message you want to display.
     """
-    dialog = gtk.MessageDialog(flags=gtk.DIALOG_MODAL, type=type,
+    dialog = gtk.MessageDialog(flags=gtk.DIALOG_MODAL, type=type, parent=parent,
                                buttons=buttons)
     dialog.set_markup('<big><b>' + primary + '</b></big>')
     dialog.format_secondary_markup(secondary)
@@ -39,18 +38,18 @@
     dialog.destroy()
     return response
 
-def error_dialog(primary, secondary):
+def error_dialog(primary, secondary, parent=None):
     """ Display an error dialog with the given message. """
-    return _message_dialog(gtk.MESSAGE_ERROR, primary, secondary)
+    return _message_dialog(gtk.MESSAGE_ERROR, primary, secondary, parent)
 
-def info_dialog(primary, secondary):
+def info_dialog(primary, secondary, parent=None):
     """ Display an info dialog with the given message. """
-    return _message_dialog(gtk.MESSAGE_INFO, primary, secondary)
+    return _message_dialog(gtk.MESSAGE_INFO, primary, secondary, parent)
 
-def warning_dialog(primary, secondary):
+def warning_dialog(primary, secondary, parent=None):
     """ Display a warning dialog with the given message. """
-    return _message_dialog(gtk.MESSAGE_WARNING, primary, secondary)
+    return _message_dialog(gtk.MESSAGE_WARNING, primary, secondary, parent)
 
-def question_dialog(primary, secondary):
+def question_dialog(primary, secondary, parent=None):
     """ Display a dialog with the given question. """
-    return _message_dialog(gtk.MESSAGE_QUESTION, primary, secondary, gtk.BUTTONS_YES_NO)
+    return _message_dialog(gtk.MESSAGE_QUESTION, primary, secondary, parent, gtk.BUTTONS_YES_NO)



More information about the Pkg-bazaar-commits mailing list