Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
a9efde13
by Philipp Hörist at 2019-03-25T21:20:19Z
-
7a5d791b
by Philipp Hörist at 2019-03-25T21:20:19Z
4 changed files:
Changes:
| ... | ... | @@ -51,12 +51,14 @@ import nbxmpp |
| 51 | 51 |
from nbxmpp.stringprepare import nameprep
|
| 52 | 52 |
import precis_i18n.codec # pylint: disable=unused-import
|
| 53 | 53 |
|
| 54 |
+from gajim.common import app
|
|
| 54 | 55 |
from gajim.common import caps_cache
|
| 55 | 56 |
from gajim.common import configpaths
|
| 56 | 57 |
from gajim.common.i18n import Q_
|
| 57 | 58 |
from gajim.common.i18n import _
|
| 58 | 59 |
from gajim.common.i18n import ngettext
|
| 59 | 60 |
from gajim.common.const import ShowConstant
|
| 61 |
+from gajim.common.const import Display
|
|
| 60 | 62 |
|
| 61 | 63 |
log = logging.getLogger('gajim.c.helpers')
|
| 62 | 64 |
|
| ... | ... | @@ -1508,3 +1510,14 @@ class AdditionalDataDict(collections.UserDict): |
| 1508 | 1510 |
del _dict[key]
|
| 1509 | 1511 |
except KeyError:
|
| 1510 | 1512 |
return
|
| 1513 |
+ |
|
| 1514 |
+ |
|
| 1515 |
+def save_roster_position(window):
|
|
| 1516 |
+ if not app.config.get('save-roster-position'):
|
|
| 1517 |
+ return
|
|
| 1518 |
+ if app.is_display(Display.WAYLAND):
|
|
| 1519 |
+ return
|
|
| 1520 |
+ x_pos, y_pos = window.get_position()
|
|
| 1521 |
+ log.debug('Save roster position: %s %s', x_pos, y_pos)
|
|
| 1522 |
+ app.config.set('roster_x-position', x_pos)
|
|
| 1523 |
+ app.config.set('roster_y-position', y_pos)
|
| ... | ... | @@ -28,10 +28,11 @@ from gajim import dialogs |
| 28 | 28 |
from gajim.common import app
|
| 29 | 29 |
from gajim.common import helpers
|
| 30 | 30 |
from gajim.common.i18n import _
|
| 31 |
+from gajim.common.helpers import save_roster_position
|
|
| 31 | 32 |
|
| 32 | 33 |
from gajim.gtk.util import get_builder
|
| 33 | 34 |
from gajim.gtk.util import get_icon_name
|
| 34 |
-from gajim.gtk.util import move_window
|
|
| 35 |
+from gajim.gtk.util import restore_roster_position
|
|
| 35 | 36 |
from gajim.gtk.single_message import SingleMessageWindow
|
| 36 | 37 |
from gajim.gtk.tooltips import NotificationAreaTooltip
|
| 37 | 38 |
|
| ... | ... | @@ -375,18 +376,11 @@ class StatusIcon: |
| 375 | 376 |
# No pending events, so toggle visible/hidden for roster window
|
| 376 | 377 |
if win.get_property('visible'):
|
| 377 | 378 |
if win.get_property('has-toplevel-focus') or os.name == 'nt':
|
| 378 |
- if app.config.get('save-roster-position'):
|
|
| 379 |
- x, y = win.get_position()
|
|
| 380 |
- app.config.set('roster_x-position', x)
|
|
| 381 |
- app.config.set('roster_y-position', y)
|
|
| 379 |
+ save_roster_position(win)
|
|
| 382 | 380 |
win.hide() # else we hide it from VD that was visible in
|
| 383 | 381 |
else:
|
| 384 |
- if not win.get_property('visible'):
|
|
| 385 |
- win.show_all()
|
|
| 386 |
- if app.config.get('save-roster-position'):
|
|
| 387 |
- move_window(win,
|
|
| 388 |
- app.config.get('roster_x-position'),
|
|
| 389 |
- app.config.get('roster_y-position'))
|
|
| 382 |
+ win.show_all()
|
|
| 383 |
+ restore_roster_position(win)
|
|
| 390 | 384 |
if not app.config.get('roster_window_skip_taskbar'):
|
| 391 | 385 |
win.set_property('skip-taskbar-hint', False)
|
| 392 | 386 |
win.present_with_time(Gtk.get_current_event_time())
|
| ... | ... | @@ -398,11 +392,9 @@ class StatusIcon: |
| 398 | 392 |
if not event:
|
| 399 | 393 |
return
|
| 400 | 394 |
win = app.interface.roster.window
|
| 401 |
- if not win.get_property('visible') and app.config.get(
|
|
| 402 |
- 'save-roster-position'):
|
|
| 403 |
- move_window(win,
|
|
| 404 |
- app.config.get('roster_x-position'),
|
|
| 405 |
- app.config.get('roster_y-position'))
|
|
| 395 |
+ if not win.get_property('visible'):
|
|
| 396 |
+ # Needed if we are in one window mode
|
|
| 397 |
+ restore_roster_position(win)
|
|
| 406 | 398 |
app.interface.handle_event(account, jid, event.type_)
|
| 407 | 399 |
|
| 408 | 400 |
def on_middle_click(self):
|
| ... | ... | @@ -40,6 +40,7 @@ from gajim.common.i18n import _ |
| 40 | 40 |
from gajim.common.const import MOODS
|
| 41 | 41 |
from gajim.common.const import ACTIVITIES
|
| 42 | 42 |
from gajim.common.const import LOCATION_DATA
|
| 43 |
+from gajim.common.const import Display
|
|
| 43 | 44 |
|
| 44 | 45 |
from gajim.gtk.const import GajimIconSet
|
| 45 | 46 |
|
| ... | ... | @@ -308,6 +309,16 @@ def move_window(window: Gtk.Window, pos_x: int, pos_y: int) -> None: |
| 308 | 309 |
window.move(pos_x, pos_y)
|
| 309 | 310 |
|
| 310 | 311 |
|
| 312 |
+def restore_roster_position(window):
|
|
| 313 |
+ if not app.config.get('save-roster-position'):
|
|
| 314 |
+ return
|
|
| 315 |
+ if app.is_display(Display.WAYLAND):
|
|
| 316 |
+ return
|
|
| 317 |
+ move_window(window,
|
|
| 318 |
+ app.config.get('roster_x-position'),
|
|
| 319 |
+ app.config.get('roster_y-position'))
|
|
| 320 |
+ |
|
| 321 |
+ |
|
| 311 | 322 |
def get_completion_liststore(entry: Gtk.Entry) -> Gtk.ListStore:
|
| 312 | 323 |
"""
|
| 313 | 324 |
Create a completion model for entry widget completion list consists of
|
| ... | ... | @@ -56,6 +56,7 @@ from gajim.common import helpers |
| 56 | 56 |
from gajim.common import idle
|
| 57 | 57 |
from gajim.common.exceptions import GajimGeneralException
|
| 58 | 58 |
from gajim.common import i18n
|
| 59 |
+from gajim.common.helpers import save_roster_position
|
|
| 59 | 60 |
from gajim.common.i18n import _
|
| 60 | 61 |
from gajim.common.const import PEPEventType, AvatarSize, StyleAttr
|
| 61 | 62 |
from gajim.common.dbus import location
|
| ... | ... | @@ -83,7 +84,7 @@ from gajim.gtk.tooltips import RosterTooltip |
| 83 | 84 |
from gajim.gtk.adhoc_commands import CommandWindow
|
| 84 | 85 |
from gajim.gtk.util import get_icon_name
|
| 85 | 86 |
from gajim.gtk.util import resize_window
|
| 86 |
-from gajim.gtk.util import move_window
|
|
| 87 |
+from gajim.gtk.util import restore_roster_position
|
|
| 87 | 88 |
from gajim.gtk.util import get_metacontact_surface
|
| 88 | 89 |
from gajim.gtk.util import get_builder
|
| 89 | 90 |
from gajim.gtk.util import set_urgency_hint
|
| ... | ... | @@ -2365,11 +2366,7 @@ class RosterWindow: |
| 2365 | 2366 |
if not app.config.get('quit_on_roster_x_button') and (
|
| 2366 | 2367 |
(app.interface.systray_enabled and app.config.get('trayicon') != \
|
| 2367 | 2368 |
'on_event') or app.config.get('allow_hide_roster')):
|
| 2368 |
- if app.config.get('save-roster-position'):
|
|
| 2369 |
- x, y = self.window.get_position()
|
|
| 2370 |
- log.debug('Save roster position (get_position): %s %s', x, y)
|
|
| 2371 |
- app.config.set('roster_x-position', x)
|
|
| 2372 |
- app.config.set('roster_y-position', y)
|
|
| 2369 |
+ save_roster_position(self.window)
|
|
| 2373 | 2370 |
if os.name == 'nt' or app.config.get('hide_on_roster_x_button'):
|
| 2374 | 2371 |
self.window.hide()
|
| 2375 | 2372 |
else:
|
| ... | ... | @@ -2394,11 +2391,7 @@ class RosterWindow: |
| 2394 | 2391 |
# in case show_roster_on_start is False and roster is never shown
|
| 2395 | 2392 |
# window.window is None
|
| 2396 | 2393 |
if self.window.get_window() is not None:
|
| 2397 |
- if app.config.get('save-roster-position'):
|
|
| 2398 |
- x, y = self.window.get_window().get_root_origin()
|
|
| 2399 |
- log.debug('Save roster position (get_root_origin): %s %s', x, y)
|
|
| 2400 |
- app.config.set('roster_x-position', x)
|
|
| 2401 |
- app.config.set('roster_y-position', y)
|
|
| 2394 |
+ save_roster_position(self.window)
|
|
| 2402 | 2395 |
width, height = self.window.get_size()
|
| 2403 | 2396 |
app.config.set('roster_width', width)
|
| 2404 | 2397 |
app.config.set('roster_height', height)
|
| ... | ... | @@ -5625,10 +5618,7 @@ class RosterWindow: |
| 5625 | 5618 |
resize_window(self.window,
|
| 5626 | 5619 |
app.config.get('roster_width'),
|
| 5627 | 5620 |
app.config.get('roster_height'))
|
| 5628 |
- if app.config.get('save-roster-position'):
|
|
| 5629 |
- move_window(self.window,
|
|
| 5630 |
- app.config.get('roster_x-position'),
|
|
| 5631 |
- app.config.get('roster_y-position'))
|
|
| 5621 |
+ restore_roster_position(self.window)
|
|
| 5632 | 5622 |
|
| 5633 | 5623 |
# Remove contact from roster when last event opened
|
| 5634 | 5624 |
# { (contact, account): { backend: boolean }
|