Window positioning/sizing, closes #1260

This commit is contained in:
Travis Shirk 2006-01-12 05:45:30 +00:00
parent f74831dd56
commit 1689ae3783
3 changed files with 60 additions and 52 deletions

View File

@ -104,18 +104,18 @@ class Config:
'msgwin-y-position': [opt_int, -1], # Default is to let the window manager decide
'msgwin-width': [opt_int, DEFAULT_WINDOW_WIDTH],
'msgwin-height': [opt_int, DEFAULT_WINDOW_HEIGHT],
'chat_msgwin-x-position': [opt_int, -1], # Default is to let the window manager decide
'chat_msgwin-y-position': [opt_int, -1], # Default is to let the window manager decide
'chat_msgwin-width': [opt_int, DEFAULT_WINDOW_WIDTH],
'chat_msgwin-height': [opt_int, DEFAULT_WINDOW_HEIGHT],
'gc_msgwin-x-position': [opt_int, -1], # Default is to let the window manager decide
'gc_msgwin-y-position': [opt_int, -1], # Default is to let the window manager decide
'gc_msgwin-width': [opt_int, DEFAULT_WINDOW_WIDTH],
'gc_msgwin-height': [opt_int, DEFAULT_WINDOW_HEIGHT],
'single_msg-x-position': [opt_int, 0],
'single_msg-y-position': [opt_int, 0],
'single_msg-width': [opt_int, 400],
'single_msg-height': [opt_int, 280],
'chat-msgwin-x-position': [opt_int, -1], # Default is to let the window manager decide
'chat-msgwin-y-position': [opt_int, -1], # Default is to let the window manager decide
'chat-msgwin-width': [opt_int, DEFAULT_WINDOW_WIDTH],
'chat-msgwin-height': [opt_int, DEFAULT_WINDOW_HEIGHT],
'gc-msgwin-x-position': [opt_int, -1], # Default is to let the window manager decide
'gc-msgwin-y-position': [opt_int, -1], # Default is to let the window manager decide
'gc-msgwin-width': [opt_int, DEFAULT_WINDOW_WIDTH],
'gc-msgwin-height': [opt_int, DEFAULT_WINDOW_HEIGHT],
'single-msg-x-position': [opt_int, 0],
'single-msg-y-position': [opt_int, 0],
'single-msg-width': [opt_int, 400],
'single-msg-height': [opt_int, 280],
'roster_x-position': [ opt_int, 0 ],
'roster_y-position': [ opt_int, 0 ],
'roster_width': [ opt_int, 150 ],

View File

@ -606,8 +606,8 @@ class MessageWindowMgr:
size = (gajim.config.get('msgwin-width'),
gajim.config.get('msgwin-height'))
elif self.mode == self.CONFIG_PERACCT:
size = (gajim.config.get_per('msgwin-width', acct),
gajim.config.get_per('msgwin-height', acct))
size = (gajim.config.get_per('accounts', acct, 'msgwin-width'),
gajim.config.get_per('accounts', acct, 'msgwin-height'))
elif self.mode == self.CONFIG_PERTYPE:
if type == message_control.TYPE_PM:
type = message_control.TYPE_CHAT
@ -627,8 +627,8 @@ class MessageWindowMgr:
pos = (gajim.config.get('msgwin-x-position'),
gajim.config.get('msgwin-y-position'))
elif self.mode == self.CONFIG_PERACCT:
pos = (gajim.config.get_per('msgwin-x-position', acct),
gajim.config.get_per('msgwin-y-position', acct))
pos = (gajim.config.get_per('accounts', acct, 'msgwin-x-position'),
gajim.config.get_per('accounts', acct, 'msgwin-y-position'))
elif self.mode == self.CONFIG_PERTYPE:
pos = (gajim.config.get(type + '-msgwin-x-position'),
gajim.config.get(type + '-msgwin-y-position'))
@ -673,42 +673,7 @@ class MessageWindowMgr:
return win
def _on_window_delete(self, win, event):
if not gajim.config.get('saveposition'):
return False
msg_win = self._gtk_win_to_msg_win(win)
# Save window size and postion
pos_x_key = 'msgwin-x-position'
pos_y_key = 'msgwin-y-position'
size_width_key = 'msgwin-width'
size_height_key = 'msgwin-height'
acct = None
x, y = win.get_position()
width, height = win.get_size()
if self.mode == self.CONFIG_NEVER:
x = y = -1
elif self.mode == self.CONFIG_PERACCT:
acct = msg_win.account
elif self.mode == self.CONFIG_PERTYPE:
type = msg_win.type
pos_x_key = type + "-msgwin-x-position"
pos_y_key = type + "-msgwin-y-position"
size_width_key = type + "-msgwin-width"
size_height_key = type + "-msgwin-height"
if acct:
gajim.config.set_per('accounts', acct, pos_x_key, x)
gajim.config.set_per('accounts', acct, pos_y_key, y)
gajim.config.set_per('accounts', acct, size_width_key, width)
gajim.config.set_per('accounts', acct, size_height_key, height)
else:
gajim.config.set(pos_x_key, x)
gajim.config.set(pos_y_key, y)
gajim.config.set(size_width_key, width)
gajim.config.set(size_height_key, height)
self.save_state(self._gtk_win_to_msg_win(win))
return False
def _on_window_destroy(self, win):
@ -738,3 +703,44 @@ class MessageWindowMgr:
for w in self._windows.values():
for c in w.controls():
yield c
def shutdown(self):
for w in self.windows():
self.save_state(w)
w.window.hide()
def save_state(self, msg_win):
if not gajim.config.get('saveposition'):
return False
# Save window size and postion
pos_x_key = 'msgwin-x-position'
pos_y_key = 'msgwin-y-position'
size_width_key = 'msgwin-width'
size_height_key = 'msgwin-height'
acct = None
x, y = msg_win.window.get_position()
width, height = msg_win.window.get_size()
if self.mode == self.CONFIG_NEVER:
x = y = -1
elif self.mode == self.CONFIG_PERACCT:
acct = msg_win.account
elif self.mode == self.CONFIG_PERTYPE:
type = msg_win.type
pos_x_key = type + "-msgwin-x-position"
pos_y_key = type + "-msgwin-y-position"
size_width_key = type + "-msgwin-width"
size_height_key = type + "-msgwin-height"
if acct:
gajim.config.set_per('accounts', acct, pos_x_key, x)
gajim.config.set_per('accounts', acct, pos_y_key, y)
gajim.config.set_per('accounts', acct, size_width_key, width)
gajim.config.set_per('accounts', acct, size_height_key, height)
else:
gajim.config.set(pos_x_key, x)
gajim.config.set(pos_y_key, y)
gajim.config.set(size_width_key, width)
gajim.config.set(size_height_key, height)

View File

@ -1940,6 +1940,8 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
gajim.config.set('roster_width', width)
gajim.config.set('roster_height', height)
gajim.interface.msg_win_mgr.shutdown()
gajim.config.set('collapsed_rows', '\t'.join(self.collapsed_rows))
gajim.interface.save_config()
for account in gajim.connections: