hggtk/hgemail: new window style, add tooltips
authorSteve Borho <steve@borho.org>
Thu, 31 Jan 2008 23:07:16 -0600
changeset 976 fce4f4d4fe97
parent 975 a70d8cf2da50
child 977 b5fc8cec07f9
hggtk/hgemail: new window style, add tooltips
hggtk/hgemail.py
hggtk/history.py
hggtk/synch.py
--- a/hggtk/hgemail.py	Thu Jan 31 22:57:23 2008 -0600
+++ b/hggtk/hgemail.py	Thu Jan 31 23:07:16 2008 -0600
@@ -17,29 +17,41 @@
 from thgconfig import ConfigDialog
 from hgcmd import CmdDialog
 
-class EmailDialog(gtk.Dialog):
+class EmailDialog(gtk.Window):
     """ Send patches or bundles via email """
     def __init__(self, root='', revargs=[]):
         """ Initialize the Dialog """
-        buttons = (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
-        super(EmailDialog, self).__init__(flags=gtk.DIALOG_MODAL, 
-                                           buttons=buttons)
+        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
+
         shlib.set_tortoise_icon(self, 'hg.ico')
         self.root = root
         self.revargs = revargs
         
         self.tbar = gtk.Toolbar()
+        self.tips = gtk.Tooltips()
+
+        sep = gtk.SeparatorToolItem()
+        sep.set_expand(True)
+        sep.set_draw(False)
+        self._btn_close = self._toolbutton(gtk.STOCK_CLOSE, 'Close',
+                self._close_clicked, 'Close Window')
+
         tbuttons = [
                 self._toolbutton(gtk.STOCK_GOTO_LAST, 'Send',
-                                 self._on_send_clicked),
+                                 self._on_send_clicked,
+                                 'Send email(s)'),
                 gtk.SeparatorToolItem(),
                 self._toolbutton(gtk.STOCK_PREFERENCES, 'configure',
-                                 self._on_conf_clicked),
-                gtk.SeparatorToolItem(),
+                                 self._on_conf_clicked,
+                                 'Configure email settings'),
+                sep,
+                self._btn_close
             ]
         for btn in tbuttons:
             self.tbar.insert(btn, -1)
-        self.vbox.pack_start(self.tbar, False, False, 2)
+        mainvbox = gtk.VBox()
+        self.add(mainvbox)
+        mainvbox.pack_start(self.tbar, False, False, 2)
 
         # set dialog title
         if revargs[0] in ('--outgoing', '-o'):
@@ -55,7 +67,7 @@
         flagframe = gtk.Frame('Options')
         hbox.pack_start(envframe, True, True, 4)
         hbox.pack_start(flagframe, False, False, 4)
-        self.vbox.pack_start(hbox, False, True, 4)
+        mainvbox.pack_start(hbox, False, True, 4)
 
         vbox = gtk.VBox()
         envframe.add(vbox)
@@ -147,19 +159,18 @@
                 ' the effects of the entire patch series.  When emailing'
                 ' a bundle, these fields make up the message subject and body.'
                 ' The description field is unused when sending a single patch')
-        self.vbox.pack_start(frame, True, True, 4)
+        mainvbox.pack_start(frame, True, True, 4)
 
         self.connect('map_event', self._on_window_map_event)
 
-    def _toolbutton(self, stock, label, handler, menu=None, userdata=None):
-        if menu:
-            tbutton = gtk.MenuToolButton(stock)
-            tbutton.set_menu(menu)
-        else:
-            tbutton = gtk.ToolButton(stock)
-            
+    def _close_clicked(self, toolbutton, data=None):
+        self.destroy()
+
+    def _toolbutton(self, stock, label, handler, tip):
+        tbutton = gtk.ToolButton(stock)
         tbutton.set_label(label)
-        tbutton.connect('clicked', handler, userdata)
+        tbutton.set_tooltip(self.tips, tip)
+        tbutton.connect('clicked', handler)
         return tbutton
         
     def _on_window_map_event(self, event, param):
@@ -216,7 +227,7 @@
                 self._plain.set_active(True)
                 self._plain.set_sensitive(False)
 
-    def _on_conf_clicked(self, button, userdata):
+    def _on_conf_clicked(self, button):
         dlg = ConfigDialog(self.root, False)
         dlg.show_all()
         dlg.focus_field('email.from')
@@ -224,7 +235,7 @@
         dlg.hide()
         self._refresh(False)
 
-    def _on_send_clicked(self, button, userdata):
+    def _on_send_clicked(self, button):
         def record_new_value(cpath, history, newvalue):
             if not newvalue: return
             if cpath not in history:
@@ -301,7 +312,7 @@
     # place for testing purposes.
     dialog = EmailDialog(root, ['tip'])
     dialog.show_all()
-    dialog.connect('response', gtk.main_quit)
+    dialog.connect('destroy', gtk.main_quit)
     gtk.gdk.threads_init()
     gtk.gdk.threads_enter()
     gtk.main()
--- a/hggtk/history.py	Thu Jan 31 22:57:23 2008 -0600
+++ b/hggtk/history.py	Thu Jan 31 23:07:16 2008 -0600
@@ -450,9 +450,10 @@
         from hgemail import EmailDialog
         rev = self.currow[treemodel.REVID]
         dlg = EmailDialog(self.repo.root, ['--rev', str(rev)])
+        dlg.set_transient_for(self)
         dlg.show_all()
-        dlg.run()
-        dlg.hide()
+        dlg.present()
+        dlg.set_transient_for(None)
 
     def _checkout(self, menuitem):
         rev = self.currow[treemodel.REVID]
--- a/hggtk/synch.py	Thu Jan 31 22:57:23 2008 -0600
+++ b/hggtk/synch.py	Thu Jan 31 23:07:16 2008 -0600
@@ -293,9 +293,10 @@
             return
         from hgemail import EmailDialog
         dlg = EmailDialog(self.root, ['--outgoing', path])
+        dlg.set_transient_for(self)
         dlg.show_all()
-        dlg.run()
-        dlg.hide()
+        dlg.present()
+        dlg.set_transient_for(None)
 
     def _incoming_clicked(self, toolbutton, data=None):
         cmd = ['incoming']