From 63a17a88b4d3723c9a83d62519883434eceaedf1 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 5 Jan 2010 14:24:37 +0000 Subject: [PATCH] Make pygtk 2.14 failures more graceful --- terminatorlib/terminatorterm.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/terminatorlib/terminatorterm.py b/terminatorlib/terminatorterm.py index a56474f0..5bbe2617 100755 --- a/terminatorlib/terminatorterm.py +++ b/terminatorlib/terminatorterm.py @@ -1661,17 +1661,21 @@ text/plain # Center it over the current terminal (not perfect?!?) # This could be replaced by a less bothersome dialog, but then that would # center over the window, not the terminal - screen_w = gtk.gdk.screen_width() - screen_h = gtk.gdk.screen_height() - local_x, local_y = self.allocation.x, self.allocation.y - local_w, local_h = self.allocation.width, self.allocation.height - window_x, window_y = self.get_window().get_origin() - x = window_x + local_x - y = window_y + local_y - win.realize() - 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) - win.move(new_x, new_y) + try: + screen_w = gtk.gdk.screen_width() + screen_h = gtk.gdk.screen_height() + local_x, local_y = self.allocation.x, self.allocation.y + local_w, local_h = self.allocation.width, self.allocation.height + window_x, window_y = self.get_window().get_origin() + x = window_x + local_x + y = window_y + local_y + win.realize() + 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) + win.move(new_x, new_y) + except AttributeError: + # Old pygtk has no gtk.Widget.get_window() + pass win.show_all ()