Revision: 8203
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8203&view=rev
Author:   efiring
Date:     2010-03-20 22:49:25 +0000 (Sat, 20 Mar 2010)

Log Message:
-----------
backend_gtk: support new tooltip API for pygtk >= 2.12

Modified Paths:
--------------
    trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py

Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py     2010-03-20 
08:58:06 UTC (rev 8202)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py     2010-03-20 
22:49:25 UTC (rev 8203)
@@ -17,6 +17,8 @@
                       % (gtk.pygtk_version + pygtk_version_required))
 del pygtk_version_required
 
+_new_tooltip_api =  (gtk.pygtk_version[1] >= 12)
+
 import matplotlib
 from matplotlib import verbose
 from matplotlib._pylab_helpers import Gcf
@@ -448,7 +450,7 @@
                 # diong a blanket catch here, but an not sure what a
                 # better way is - JDH
                 verbose.report('Could not load matplotlib icon: %s' % 
sys.exc_info()[1])
-                
+
         self.vbox = gtk.VBox()
         self.window.add(self.vbox)
         self.vbox.show()
@@ -618,7 +620,8 @@
 
     def _init_toolbar2_4(self):
         basedir = os.path.join(matplotlib.rcParams['datapath'],'images')
-        self.tooltips = gtk.Tooltips()
+        if not _new_tooltip_api:
+            self.tooltips = gtk.Tooltips()
 
         for text, tooltip_text, image_file, callback in self.toolitems:
             if text is None:
@@ -630,7 +633,10 @@
             tbutton = gtk.ToolButton(image, text)
             self.insert(tbutton, -1)
             tbutton.connect('clicked', getattr(self, callback))
-            tbutton.set_tooltip(self.tooltips, tooltip_text, 'Private')
+            if _new_tooltip_api:
+                tbutton.set_tooltip_text(tooltip_text)
+            else:
+                tbutton.set_tooltip(self.tooltips, tooltip_text, 'Private')
 
         toolitem = gtk.SeparatorToolItem()
         self.insert(toolitem, -1)
@@ -760,7 +766,8 @@
     def _create_toolitems_2_4(self):
         # use the GTK+ 2.4 GtkToolbar API
         iconSize = gtk.ICON_SIZE_SMALL_TOOLBAR
-        self.tooltips = gtk.Tooltips()
+        if not _new_tooltip_api:
+            self.tooltips = gtk.Tooltips()
 
         for text, tooltip_text, image_num, callback, callback_arg, scroll \
                 in self.toolitems:
@@ -778,15 +785,22 @@
                 tbutton.connect('clicked', getattr(self, callback))
             if scroll:
                 tbutton.connect('scroll_event', getattr(self, callback))
-            tbutton.set_tooltip(self.tooltips, tooltip_text, 'Private')
+            if _new_tooltip_api:
+                tbutton.set_tooltip_text(tooltip_text)
+            else:
+                tbutton.set_tooltip(self.tooltips, tooltip_text, 'Private')
 
         # Axes toolitem, is empty at start, update() adds a menu if >=2 axes
         self.axes_toolitem = gtk.ToolItem()
         self.insert(self.axes_toolitem, 0)
-        self.axes_toolitem.set_tooltip (
-            self.tooltips,
-            tip_text='Select axes that controls affect',
-            tip_private = 'Private')
+        if _new_tooltip_api:
+            self.axes_toolitem.set_tooltip_text(
+                                'Select axes that controls affect')
+        else:
+            self.axes_toolitem.set_tooltip (
+                self.tooltips,
+                tip_text='Select axes that controls affect',
+                tip_private = 'Private')
 
         align = gtk.Alignment (xalign=0.5, yalign=0.5, xscale=0.0, yscale=0.0)
         self.axes_toolitem.add(align)


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Matplotlib-checkins mailing list
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to