Commits

Steve Borho committed 288e39c

hgtk: avoid GTK deprecation warnings for tooltip API

Note: this doesn't use any of the fancy new features. GTK will allow you to
create ad-hoc tooltip widgets now (imagine a csinfo tooltip for annotate). But
it avoids warnings.

I also cleaned up the fact that hgemail was creating a redundant Tooltips
instances.

  • Participants
  • Parent commits f71be55
  • Branches stable

Comments (0)

Files changed (13)

File tortoisehg/hgtk/backout.py

         msgvbox.pack_start(scrolledwindow)
 
         ## tooltips
-        self.tips = gtk.Tooltips()
+        self.tips = gtklib.Tooltips()
         self.tips.set_tip(frame,
                 _('Commit message text for new changeset that reverses the'
                 '  effect of the change being backed out.'))

File tortoisehg/hgtk/commit.py

 
         btn = self.get_toolbutton('commit')
         btn.set_label(label)
-        btn.set_tooltip(self.tooltips, tooltip)
+        self.tooltips.set_tip(btn, tooltip)
 
     def get_head_info(self):
         def ishead(ctx):

File tortoisehg/hgtk/gdialog.py

             self.show_all()
         else:
             self._parse_opts()
-            self.tooltips = gtk.Tooltips()
+            self.tooltips = gtklib.Tooltips()
 
 
     def test_opt(self, opt):
             tbutton = gtk.ToolButton(stock)
 
         if tip:
-            tbutton.set_tooltip(self.tooltips, tip)
+            self.tooltips.set_tip(tbutton, tip)
         if icon:
             image = gtklib.get_icon_image(icon)
             tbutton.set_icon_widget(image)
         if x >= 0 and x < w and y >= 0 and y < h:
             self.move(x, y)
 
-        self.tooltips = gtk.Tooltips()
+        self.tooltips = gtklib.Tooltips()
         toolbar = gtk.Toolbar()
         tbuttons =  self.get_tbbuttons()
         for tbutton in tbuttons:

File tortoisehg/hgtk/gorev.py

 
         self.gotofunc = gotofunc
 
-        self.tips = gtk.Tooltips()
+        self.tips = gtklib.Tooltips()
 
         hbox = gtk.HBox()
         self.revEntry = gtk.Entry()

File tortoisehg/hgtk/gtklib.py

 PYELLOW = '#ffffaa'
 PORANGE = '#ffddaa'
 
+if gtk.pygtk_version < (2, 12, 0):
+    # old nasty
+    Tooltips = gtk.Tooltips
+else:
+    # new shiny
+    class Tooltips(object):
+        def __init__(self):
+            pass
+        def set_tip(self, widget, tip):
+            widget.set_tooltip_text(tip)
+
 def set_tortoise_icon(window, thgicon):
     ico = paths.get_tortoise_icon(thgicon)
     if ico: window.set_icon_from_file(ico)

File tortoisehg/hgtk/hgcmd.py

 
         # tooltips
         if tooltips is None:
-            tooltips = gtk.Tooltips()
+            tooltips = gtklib.Tooltips()
 
         # log viewer
         if self.is_normal:

File tortoisehg/hgtk/hgemail.py

         self.revargs = revargs
 
         self.tbar = gtk.Toolbar()
-        self.tips = gtk.Tooltips()
+        self.tips = gtklib.Tooltips()
 
         tbuttons = [
                 self._toolbutton(gtk.STOCK_GOTO_LAST, _('Send'),
         table = gtklib.LayoutTable()
         flagframe.add(table)
 
-        self.tooltips = gtk.Tooltips()
         self._normal = gtk.RadioButton(None, _('Send changesets as Hg patches'))
         table.add_row(self._normal)
-        self.tooltips.set_tip(self._normal,
+        self.tips.set_tip(self._normal,
                 _('Hg patches (as generated by export command) are compatible'
                 ' with most patch programs.  They include a header which'
                 ' contains the most important changeset metadata.'))
         self._git = gtk.RadioButton(self._normal,
                 _('Use extended (git) patch format'))
         table.add_row(self._git)
-        self.tooltips.set_tip(self._git,
+        self.tips.set_tip(self._git,
                 _('Git patches can describe binary files, copies, and'
                 ' permission changes, but recipients may not be able to'
                 ' use them if they are not using git or Mercurial.'))
         self._plain = gtk.RadioButton(self._normal,
                 _('Plain, do not prepend Hg header'))
         table.add_row(self._plain)
-        self.tooltips.set_tip(self._plain,
+        self.tips.set_tip(self._plain,
                 _('Stripping Mercurial header removes username and parent'
                 ' information.  Only useful if recipient is not using'
                 ' Mercurial (and does not like to see the headers).'))
                 _('Send single binary bundle, not patches'))
         table.add_row(self._bundle)
         if revargs[0] in ('--outgoing', '-o'):
-            self.tooltips.set_tip(self._bundle,
+            self.tips.set_tip(self._bundle,
                 _('Bundles store complete changesets in binary form.'
                 ' Upstream users can pull from them. This is the safest'
                 ' way to send changes to recipient Mercurial users.'))
         else:
             self._bundle.set_sensitive(False)
-            self.tooltips.set_tip(self._bundle,
+            self.tips.set_tip(self._bundle,
                 _('This feature is only available when sending outgoing'
                 ' changesets. It is not applicable with revision ranges.'))
 
         self._attach = gtk.CheckButton(_('attach'))
-        self.tooltips.set_tip(self._attach,
+        self.tips.set_tip(self._attach,
                 _('send patches as attachments'))
         self._inline = gtk.CheckButton(_('inline'))
-        self.tooltips.set_tip(self._inline,
+        self.tips.set_tip(self._inline,
                 _('send patches as inline attachments'))
         self._diffstat = gtk.CheckButton(_('diffstat'))
-        self.tooltips.set_tip(self._diffstat,
+        self.tips.set_tip(self._diffstat,
                 _('add diffstat output to messages'))
         table.add_row(self._attach, self._inline, self._diffstat, padding=False)
 
     def _toolbutton(self, stock, label, handler, tip):
         tbutton = gtk.ToolButton(stock)
         tbutton.set_label(label)
-        tbutton.set_tooltip(self.tips, tip)
+        self.tips.set_tip(tbutton, tip)
         tbutton.connect('clicked', handler)
         return tbutton
 
             self._ccbox.child.set_text(hglib.fromutf(repo.ui.config('email', 'cc', '')))
             self._frombox.child.set_text(hglib.fromutf(getfromaddr(repo.ui)))
             self._subjbox.child.set_text(hglib.fromutf(repo.ui.config('email', 'subject', '')))
-            self.tooltips.set_tip(self._eventbox,
+            self.tips.set_tip(self._eventbox,
                     _('Patch series description is sent in initial summary'
                     ' email with [PATCH 0 of N] subject.  It should describe'
                     ' the effects of the entire patch series.  When emailing'

File tortoisehg/hgtk/history.py

 
         # create apply/reject toolbar buttons
         apply = gtk.ToolButton(gtk.STOCK_APPLY)
-        apply.set_tooltip(self.tooltips,
+        self.tooltips.set_tip(apply,
                           _('Accept incoming previewed changesets'))
         apply.set_label(_('Accept'))
         apply.show()
 
         reject = gtk.ToolButton(gtk.STOCK_DIALOG_ERROR)
-        reject.set_tooltip(self.tooltips,
+        self.tooltips.set_tip(reject,
                            _('Reject incoming previewed changesets'))
         reject.set_label(_('Reject'))
         reject.show()

File tortoisehg/hgtk/recovery.py

 
         # toolbar
         self.tbar = gtk.Toolbar()
-        self.tips = gtk.Tooltips()
+        self.tips = gtklib.Tooltips()
         self._stop_button = self._toolbutton(gtk.STOCK_STOP,
                 _('Stop'), self._stop_clicked, tip=_('Stop the hg operation'))
         self._stop_button.set_sensitive(False)
 
         tbutton.set_label(label)
         if tip:
-            tbutton.set_tooltip(self.tips, tip)
+            self.tips.set_tip(tbutton, tip)
         tbutton.connect('clicked', handler, userdata)
         return tbutton
 

File tortoisehg/hgtk/serve.py

 
         # toolbar
         self.tbar = gtk.Toolbar()
-        self.tooltips = gtk.Tooltips()
+        self.tooltips = gtklib.Tooltips()
         self._button_start = self._toolbutton(gtk.STOCK_MEDIA_PLAY,
                                               _('Start'),
                                               self._on_start_clicked,
             tbutton = gtk.ToolButton(stock)
 
         if tip:
-            tbutton.set_tooltip(self.tooltips, tip)
+            self.tooltips.set_tip(tbutton, tip)
 
         tbutton.set_label(label)
         tbutton.connect('clicked', handler, userdata)

File tortoisehg/hgtk/shellconf.py

         hbox.pack_start(self.hgighlight_taskbaricon, False, False, 2)        
 
         # Tooltips
-        tips = gtk.Tooltips()
+        tips = gtklib.Tooltips()
 
         tooltip = _('Enable/Disable the overlay icons globally')
         tips.set_tip(self.ovenable, tooltip)

File tortoisehg/hgtk/synch.py

 
         # toolbar
         self.tbar = gtk.Toolbar()
-        self.tips = gtk.Tooltips()
+        self.tips = gtklib.Tooltips()
         self.stop_button = self.toolbutton(gtk.STOCK_STOP,
                 _('Stop'), self.stop_clicked, tip=_('Stop the hg operation'))
         self.stop_button.set_sensitive(False)
 
         tbutton.set_label(label)
         if tip:
-            tbutton.set_tooltip(self.tips, tip)
+            self.tips.set_tip(tbutton, tip)
         tbutton.connect('clicked', handler, userdata)
         return tbutton
 

File tortoisehg/hgtk/thgconfig.py

 
         self.dirty = False
         self.pages = {}
-        self.tooltips = gtk.Tooltips()
+        self.tooltips = gtklib.Tooltips()
         self.history = settings.Settings('thgconfig')
 
         # add spell ckeck entry if spell check is supported