Make pygtk 2.14 failures more graceful

This commit is contained in:
Chris Jones 2010-01-05 14:24:37 +00:00
parent 0b3cb3df9b
commit 63a17a88b4

View File

@ -1661,6 +1661,7 @@ text/plain
# Center it over the current terminal (not perfect?!?) # Center it over the current terminal (not perfect?!?)
# This could be replaced by a less bothersome dialog, but then that would # This could be replaced by a less bothersome dialog, but then that would
# center over the window, not the terminal # center over the window, not the terminal
try:
screen_w = gtk.gdk.screen_width() screen_w = gtk.gdk.screen_width()
screen_h = gtk.gdk.screen_height() screen_h = gtk.gdk.screen_height()
local_x, local_y = self.allocation.x, self.allocation.y local_x, local_y = self.allocation.x, self.allocation.y
@ -1672,6 +1673,9 @@ text/plain
new_x = min(max(0, x+(local_w/2)-(win.allocation.width/2)), screen_w-win.allocation.width) new_x = min(max(0, x+(local_w/2)-(win.allocation.width/2)), screen_w-win.allocation.width)
new_y = min(max(0, y+(local_h/2)-(win.allocation.height/2)), screen_h-win.allocation.height) new_y = min(max(0, y+(local_h/2)-(win.allocation.height/2)), screen_h-win.allocation.height)
win.move(new_x, new_y) win.move(new_x, new_y)
except AttributeError:
# Old pygtk has no gtk.Widget.get_window()
pass
win.show_all () win.show_all ()