@@ -146,6 +146,17 @@ class FigureCanvasGTK (gtk.DrawingArea, FigureCanvasBase):
146
146
65421 : 'enter' ,
147
147
}
148
148
149
+ # Setting this as a static constant prevents
150
+ # this resulting expression from leaking
151
+ event_mask = (gdk .BUTTON_PRESS_MASK |
152
+ gdk .BUTTON_RELEASE_MASK |
153
+ gdk .EXPOSURE_MASK |
154
+ gdk .KEY_PRESS_MASK |
155
+ gdk .KEY_RELEASE_MASK |
156
+ gdk .LEAVE_NOTIFY_MASK |
157
+ gdk .POINTER_MOTION_MASK |
158
+ gdk .POINTER_MOTION_HINT_MASK )
159
+
149
160
def __init__ (self , figure ):
150
161
if _debug : print 'FigureCanvasGTK.%s' % fn_name ()
151
162
FigureCanvasBase .__init__ (self , figure )
@@ -166,15 +177,7 @@ def __init__(self, figure):
166
177
self .connect ('key_release_event' , self .key_release_event )
167
178
self .connect ('motion_notify_event' , self .motion_notify_event )
168
179
169
- self .set_events (
170
- gdk .BUTTON_PRESS_MASK |
171
- gdk .BUTTON_RELEASE_MASK |
172
- gdk .EXPOSURE_MASK |
173
- gdk .KEY_PRESS_MASK |
174
- gdk .KEY_RELEASE_MASK |
175
- gdk .LEAVE_NOTIFY_MASK |
176
- gdk .POINTER_MOTION_MASK |
177
- gdk .POINTER_MOTION_HINT_MASK )
180
+ self .set_events (self .__class__ .event_mask )
178
181
179
182
self .set_double_buffered (False )
180
183
self .set_flags (gtk .CAN_FOCUS )
@@ -558,6 +561,10 @@ def __init__(self, canvas, window):
558
561
NavigationToolbar2 .__init__ (self , canvas )
559
562
self ._idleId = 0
560
563
564
+ def destroy (* args ):
565
+ self .fileselect .destroy ()
566
+ self .connect ("destroy" , destroy )
567
+
561
568
def set_message (self , s ):
562
569
if self ._idleId == 0 :
563
570
self .message .set_label (s )
@@ -783,19 +790,23 @@ def __init__(self, canvas, window):
783
790
self .show_all ()
784
791
self .update ()
785
792
793
+ def destroy (* args ):
794
+ self .fileselect .destroy ()
795
+ self .connect ("destroy" , destroy )
786
796
787
797
def _create_toolitems_2_4 (self ):
788
798
# use the GTK+ 2.4 GtkToolbar API
789
799
iconSize = gtk .ICON_SIZE_SMALL_TOOLBAR
790
800
self .tooltips = gtk .Tooltips ()
791
801
792
- for text , tooltip_text , image , callback , callback_arg , scroll \
802
+ for text , tooltip_text , image_num , callback , callback_arg , scroll \
793
803
in self .toolitems :
794
804
if text is None :
795
805
self .insert ( gtk .SeparatorToolItem (), - 1 )
796
806
continue
797
- tbutton = gtk .ToolButton (gtk .image_new_from_stock (image , iconSize ),
798
- text )
807
+ image = gtk .Image ()
808
+ image .set_from_stock (image_num , iconSize )
809
+ tbutton = gtk .ToolButton (image , text )
799
810
self .insert (tbutton , - 1 )
800
811
if callback_arg :
801
812
tbutton .connect ('clicked' , getattr (self , callback ),
@@ -863,13 +874,14 @@ def _create_toolitems_2_2(self):
863
874
# use the GTK+ 2.2 (and lower) GtkToolbar API
864
875
iconSize = gtk .ICON_SIZE_SMALL_TOOLBAR
865
876
866
- for text , tooltip_text , image , callback , callback_arg , scroll \
877
+ for text , tooltip_text , image_num , callback , callback_arg , scroll \
867
878
in self .toolitems :
868
879
if text is None :
869
880
self .append_space ()
870
881
continue
871
- item = self .append_item (text , tooltip_text , 'Private' ,
872
- gtk .image_new_from_stock (image , iconSize ),
882
+ image = gtk .Image ()
883
+ image .set_from_stock (image_num , iconSize )
884
+ item = self .append_item (text , tooltip_text , 'Private' , image ,
873
885
getattr (self , callback ), callback_arg )
874
886
if scroll :
875
887
item .connect ("scroll_event" , getattr (self , callback ))
@@ -1045,7 +1057,11 @@ def __init__ (self,
1045
1057
hbox = gtk .HBox (spacing = 10 )
1046
1058
hbox .pack_start (gtk .Label ("Image Format:" ), expand = False )
1047
1059
1048
- self .cbox = gtk .combo_box_new_text ()
1060
+ liststore = gtk .ListStore (gobject .TYPE_STRING )
1061
+ self .cbox = gtk .ComboBox (liststore )
1062
+ cell = gtk .CellRendererText ()
1063
+ self .cbox .pack_start (cell , True )
1064
+ self .cbox .add_attribute (cell , 'text' , 0 )
1049
1065
hbox .pack_start (self .cbox )
1050
1066
1051
1067
for item in IMAGE_FORMAT :
@@ -1069,8 +1085,7 @@ def cb_cbox_changed (cbox, data=None):
1069
1085
1070
1086
hbox .show_all ()
1071
1087
self .set_extra_widget (hbox )
1072
-
1073
-
1088
+
1074
1089
def get_filename_from_user (self ):
1075
1090
while True :
1076
1091
filename = None
@@ -1259,11 +1274,12 @@ def on_dialog_lineprops_okbutton_clicked(self, button):
1259
1274
def on_dialog_lineprops_cancelbutton_clicked (self , button ):
1260
1275
self .dlg .hide ()
1261
1276
1262
- # set icon used when windows are minimized, it requires
1263
- # gtk.pygtk_version >= (2,2,0) with a GDK pixbuf loader for SVG installed
1277
+ # set icon used when windows are minimized
1278
+ # Unfortunately, the SVG renderer (rsvg) leaks memory like a sieve,
1279
+ # so we use a PNG file instead.
1264
1280
try :
1265
1281
gtk .window_set_default_icon_from_file (
1266
- os .path .join (matplotlib .rcParams ['datapath' ], 'images' , 'matplotlib.svg ' ))
1282
+ os .path .join (matplotlib .rcParams ['datapath' ], 'images' , 'matplotlib.png ' ))
1267
1283
except :
1268
1284
verbose .report ('Could not load matplotlib icon: %s' % sys .exc_info ()[1 ])
1269
1285
0 commit comments