diff --git a/src/groupchat_window.py b/src/groupchat_window.py index 248c6956d71884ae700cd3dba3ccce18793750ce..5030f1c3123a272ff63d9570970f2a20a998aa77 100644 --- a/src/groupchat_window.py +++ b/src/groupchat_window.py @@ -90,9 +90,9 @@ def __init__(self, room_jid, nick, plugin, account): # get size and position from config if gajim.config.get('saveposition'): - self.window.move(gajim.config.get('gc-x-position'), - gajim.config.get('gc-y-position')) - self.window.resize(gajim.config.get('gc-width'), + gtkgui_helpers.move_window(self.window, gajim.config.get('gc-x-position'), + gajim.config.get('gc-y-position')) + gtkgui_helpers.resize(self.window, gajim.config.get('gc-width'), gajim.config.get('gc-height')) self.window.show_all() diff --git a/src/gtkgui_helpers.py b/src/gtkgui_helpers.py index e3cefae514b974051c5f371406b1f49c308e81f8..9448354275da06f5e367f79017b0b71d0c4f4b66 100644 --- a/src/gtkgui_helpers.py +++ b/src/gtkgui_helpers.py @@ -27,6 +27,10 @@ from common import gajim from common import helpers +screen = gtk.gdk.Screen() +screen_w, screen_h = screen.get_width(), screen.get_height() +del screen + def get_default_font(): ''' Get the desktop setting for application font first check for GNOME, then XFCE and last KDE @@ -161,3 +165,19 @@ def autodetect_browser_mailer(): gajim.config.set('openwith', 'kfmclient exec') else: gajim.config.set('openwith', 'custom') + +def move_window(window, x, y): + ''' moves the window but also checks if out of screen ''' + if x < 0: + x = 0 + if y < 0: + y = 0 + window.move(x, y) + +def resize_window(window, w, h): + ''' resizes window but also checks if huge window or negative values ''' + if w > screen_w: + w = screen_w + if h > screen_h: + h = screen_h + window.resize(abs(w), abs(h)) \ No newline at end of file diff --git a/src/roster_window.py b/src/roster_window.py index 31c2ea651ac94815a5913a31aca675ec65836e75..7ec627551b00dac6967c3303a9511348b71266fd 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -2040,14 +2040,9 @@ def __init__(self, plugin): # no need of this variable self.have_new_message_accel = False # Is the "Ctrl+N" shown ? if gajim.config.get('saveposition'): - x = gajim.config.get('roster_x-position') - y = gajim.config.get('roster_y-position') - if x < 0: - x = 0 - if y < 0: - y = 0 - self.window.move(x, y) - self.window.resize(gajim.config.get('roster_width'), + gtkgui_helpers.move_window(self.window, gajim.config.get('roster_x-position'), + gajim.config.get('roster_y-position')) + gtkgui_helpers.resize_window(self.window, gajim.config.get('roster_width'), gajim.config.get('roster_height')) self.popups_notification_height = 0 diff --git a/src/tabbed_chat_window.py b/src/tabbed_chat_window.py index 1f9e06a7c97bc0e51e0bbeab0b74db396cab884e..9ccca189f3e529df62cd3b64c2a578e824410e19 100644 --- a/src/tabbed_chat_window.py +++ b/src/tabbed_chat_window.py @@ -72,9 +72,9 @@ def __init__(self, user, plugin, account): if gajim.config.get('saveposition'): # get window position and size from config - self.window.move(gajim.config.get('chat-x-position'), - gajim.config.get('chat-y-position')) - self.window.resize(gajim.config.get('chat-width'), + gtkgui_helpers.move_window(self.window, gajim.config.get('chat-x-position'), + gajim.config.get('chat-y-position')) + gtkgui_helpers.resize(self.window, gajim.config.get('chat-width'), gajim.config.get('chat-height')) # gtk+ doesn't make use of the motion notify on gtkwindow by default