Window positioning/sizing, closes #1260
This commit is contained in:
parent
f74831dd56
commit
1689ae3783
|
@ -104,18 +104,18 @@ class Config:
|
||||||
'msgwin-y-position': [opt_int, -1], # Default is to let the window manager decide
|
'msgwin-y-position': [opt_int, -1], # Default is to let the window manager decide
|
||||||
'msgwin-width': [opt_int, DEFAULT_WINDOW_WIDTH],
|
'msgwin-width': [opt_int, DEFAULT_WINDOW_WIDTH],
|
||||||
'msgwin-height': [opt_int, DEFAULT_WINDOW_HEIGHT],
|
'msgwin-height': [opt_int, DEFAULT_WINDOW_HEIGHT],
|
||||||
'chat_msgwin-x-position': [opt_int, -1], # Default is to let the window manager decide
|
'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-y-position': [opt_int, -1], # Default is to let the window manager decide
|
||||||
'chat_msgwin-width': [opt_int, DEFAULT_WINDOW_WIDTH],
|
'chat-msgwin-width': [opt_int, DEFAULT_WINDOW_WIDTH],
|
||||||
'chat_msgwin-height': [opt_int, DEFAULT_WINDOW_HEIGHT],
|
'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-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-y-position': [opt_int, -1], # Default is to let the window manager decide
|
||||||
'gc_msgwin-width': [opt_int, DEFAULT_WINDOW_WIDTH],
|
'gc-msgwin-width': [opt_int, DEFAULT_WINDOW_WIDTH],
|
||||||
'gc_msgwin-height': [opt_int, DEFAULT_WINDOW_HEIGHT],
|
'gc-msgwin-height': [opt_int, DEFAULT_WINDOW_HEIGHT],
|
||||||
'single_msg-x-position': [opt_int, 0],
|
'single-msg-x-position': [opt_int, 0],
|
||||||
'single_msg-y-position': [opt_int, 0],
|
'single-msg-y-position': [opt_int, 0],
|
||||||
'single_msg-width': [opt_int, 400],
|
'single-msg-width': [opt_int, 400],
|
||||||
'single_msg-height': [opt_int, 280],
|
'single-msg-height': [opt_int, 280],
|
||||||
'roster_x-position': [ opt_int, 0 ],
|
'roster_x-position': [ opt_int, 0 ],
|
||||||
'roster_y-position': [ opt_int, 0 ],
|
'roster_y-position': [ opt_int, 0 ],
|
||||||
'roster_width': [ opt_int, 150 ],
|
'roster_width': [ opt_int, 150 ],
|
||||||
|
|
|
@ -606,8 +606,8 @@ class MessageWindowMgr:
|
||||||
size = (gajim.config.get('msgwin-width'),
|
size = (gajim.config.get('msgwin-width'),
|
||||||
gajim.config.get('msgwin-height'))
|
gajim.config.get('msgwin-height'))
|
||||||
elif self.mode == self.CONFIG_PERACCT:
|
elif self.mode == self.CONFIG_PERACCT:
|
||||||
size = (gajim.config.get_per('msgwin-width', acct),
|
size = (gajim.config.get_per('accounts', acct, 'msgwin-width'),
|
||||||
gajim.config.get_per('msgwin-height', acct))
|
gajim.config.get_per('accounts', acct, 'msgwin-height'))
|
||||||
elif self.mode == self.CONFIG_PERTYPE:
|
elif self.mode == self.CONFIG_PERTYPE:
|
||||||
if type == message_control.TYPE_PM:
|
if type == message_control.TYPE_PM:
|
||||||
type = message_control.TYPE_CHAT
|
type = message_control.TYPE_CHAT
|
||||||
|
@ -627,8 +627,8 @@ class MessageWindowMgr:
|
||||||
pos = (gajim.config.get('msgwin-x-position'),
|
pos = (gajim.config.get('msgwin-x-position'),
|
||||||
gajim.config.get('msgwin-y-position'))
|
gajim.config.get('msgwin-y-position'))
|
||||||
elif self.mode == self.CONFIG_PERACCT:
|
elif self.mode == self.CONFIG_PERACCT:
|
||||||
pos = (gajim.config.get_per('msgwin-x-position', acct),
|
pos = (gajim.config.get_per('accounts', acct, 'msgwin-x-position'),
|
||||||
gajim.config.get_per('msgwin-y-position', acct))
|
gajim.config.get_per('accounts', acct, 'msgwin-y-position'))
|
||||||
elif self.mode == self.CONFIG_PERTYPE:
|
elif self.mode == self.CONFIG_PERTYPE:
|
||||||
pos = (gajim.config.get(type + '-msgwin-x-position'),
|
pos = (gajim.config.get(type + '-msgwin-x-position'),
|
||||||
gajim.config.get(type + '-msgwin-y-position'))
|
gajim.config.get(type + '-msgwin-y-position'))
|
||||||
|
@ -673,42 +673,7 @@ class MessageWindowMgr:
|
||||||
return win
|
return win
|
||||||
|
|
||||||
def _on_window_delete(self, win, event):
|
def _on_window_delete(self, win, event):
|
||||||
if not gajim.config.get('saveposition'):
|
self.save_state(self._gtk_win_to_msg_win(win))
|
||||||
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)
|
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _on_window_destroy(self, win):
|
def _on_window_destroy(self, win):
|
||||||
|
@ -738,3 +703,44 @@ class MessageWindowMgr:
|
||||||
for w in self._windows.values():
|
for w in self._windows.values():
|
||||||
for c in w.controls():
|
for c in w.controls():
|
||||||
yield c
|
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)
|
||||||
|
|
|
@ -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_width', width)
|
||||||
gajim.config.set('roster_height', height)
|
gajim.config.set('roster_height', height)
|
||||||
|
|
||||||
|
gajim.interface.msg_win_mgr.shutdown()
|
||||||
|
|
||||||
gajim.config.set('collapsed_rows', '\t'.join(self.collapsed_rows))
|
gajim.config.set('collapsed_rows', '\t'.join(self.collapsed_rows))
|
||||||
gajim.interface.save_config()
|
gajim.interface.save_config()
|
||||||
for account in gajim.connections:
|
for account in gajim.connections:
|
||||||
|
|
Loading…
Reference in New Issue