hggtk/hgcmd: cleaner method for closing dialog 0.1
authorSteve Borho <steve@borho.org>
Wed, 02 Jan 2008 01:56:36 -0600
changeset 531 5c5f39324c00
parent 530 6e0c1f2cde75
child 532 d23efae1e61e
child 555 7c0272d41a7b
hggtk/hgcmd: cleaner method for closing dialog also fixes a long-standing copy-paste bug
hggtk/hgcmd.py
--- a/hggtk/hgcmd.py	Wed Jan 02 00:23:37 2008 -0600
+++ b/hggtk/hgcmd.py	Wed Jan 02 01:56:36 2008 -0600
@@ -17,7 +17,7 @@
 from shlib import set_tortoise_icon
 
 class CmdDialog(gtk.Dialog):
-    def __init__(self, cmdline, width=520, height=400, mainapp=False):
+    def __init__(self, cmdline, width=520, height=400):
         title = 'hg ' + ' '.join(cmdline[1:])
         gtk.Dialog.__init__(self,
                             title=title,
@@ -45,14 +45,11 @@
         self.vbox.pack_start(scrolledwindow, True, True)
         self.connect('map_event', self._on_window_map_event)
 
-        if mainapp:
-            self._button_ok.connect('clicked', gtk.main_quit)
-        else:
-            self._button_ok.connect('clicked', self._on_commit_clicked)
-            self.show_all()
+        self._button_ok.connect('clicked', self._on_ok_clicked)
+        self.show_all()
 
-    def _on_commit_clicked(self, button):
-        """ Commit button clicked handler. """
+    def _on_ok_clicked(self, button):
+        """ Ok button clicked handler. """
         self.response(gtk.RESPONSE_ACCEPT)
         
     def _on_window_map_event(self, event, param):
@@ -89,7 +86,8 @@
             return True
 
 def run(cmdline=[], **opts):
-    dlg = CmdDialog(cmdline, mainapp=True)
+    dlg = CmdDialog(cmdline)
+    dlg.connect('response', gtk.main_quit)
     dlg.show_all()
     gtk.gdk.threads_init()
     gtk.gdk.threads_enter()