Steve Borho avatar Steve Borho committed fce4f4d

hggtk/hgemail: new window style, add tooltips

Comments (0)

Files changed (3)

 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'):
         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)
                 ' 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):
                 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')
         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:
     # 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()
         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]
             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']
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.