Refactor restoring roster position

This commit is contained in:
Philipp Hörist 2019-03-25 22:14:18 +01:00
parent 2f5d00d1f3
commit 0e9422ae9b
3 changed files with 20 additions and 14 deletions

View File

@ -30,6 +30,7 @@ from gajim.common import app
from gajim.common import configpaths from gajim.common import configpaths
from gajim.common import i18n from gajim.common import i18n
from gajim.common.i18n import _ from gajim.common.i18n import _
from gajim.common.const import Display
_icon_theme = Gtk.IconTheme.get_default() _icon_theme = Gtk.IconTheme.get_default()
_icon_theme.append_search_path(configpaths.get('ICONS')) _icon_theme.append_search_path(configpaths.get('ICONS'))
@ -155,6 +156,16 @@ def move_window(window: Gtk.Window, pos_x: int, pos_y: int) -> None:
window.move(pos_x, pos_y) window.move(pos_x, pos_y)
def restore_roster_position(window):
if not app.config.get('save-roster-position'):
return
if app.is_display(Display.WAYLAND):
return
move_window(window,
app.config.get('roster_x-position'),
app.config.get('roster_y-position'))
def get_completion_liststore(entry: Gtk.Entry) -> Gtk.ListStore: def get_completion_liststore(entry: Gtk.Entry) -> Gtk.ListStore:
""" """
Create a completion model for entry widget completion list consists of Create a completion model for entry widget completion list consists of

View File

@ -84,6 +84,8 @@ from gajim.gtk.service_registration import ServiceRegistration
from gajim.gtk.history import HistoryWindow from gajim.gtk.history import HistoryWindow
from gajim.gtk.accounts import AccountsWindow from gajim.gtk.accounts import AccountsWindow
from gajim.gtk.util import restore_roster_position
log = logging.getLogger('gajim.roster') log = logging.getLogger('gajim.roster')
@ -5699,13 +5701,11 @@ class RosterWindow:
if len(app.connections) < 2: if len(app.connections) < 2:
# Do not merge accounts if only one exists # Do not merge accounts if only one exists
self.regroup = False self.regroup = False
gtkgui_helpers.resize_window(self.window, gtkgui_helpers.resize_window(self.window,
app.config.get('roster_width'), app.config.get('roster_width'),
app.config.get('roster_height')) app.config.get('roster_height'))
if app.config.get('save-roster-position'): restore_roster_position(self.window)
gtkgui_helpers.move_window(self.window,
app.config.get('roster_x-position'),
app.config.get('roster_y-position'))
self.popups_notification_height = 0 self.popups_notification_height = 0
self.popup_notification_windows = [] self.popup_notification_windows = []

View File

@ -31,7 +31,7 @@ from gajim.common import app
from gajim.common import helpers from gajim.common import helpers
from gajim.common.i18n import _ from gajim.common.i18n import _
from gajim.common.helpers import save_roster_position from gajim.common.helpers import save_roster_position
from gajim.gtk.util import restore_roster_position
from gajim.gtk.single_message import SingleMessageWindow from gajim.gtk.single_message import SingleMessageWindow
@ -377,10 +377,7 @@ class StatusIcon:
win.hide() # else we hide it from VD that was visible in win.hide() # else we hide it from VD that was visible in
else: else:
win.show_all() win.show_all()
if app.config.get('save-roster-position'): restore_roster_position(win)
gtkgui_helpers.move_window(win,
app.config.get('roster_x-position'),
app.config.get('roster_y-position'))
if not app.config.get('roster_window_skip_taskbar'): if not app.config.get('roster_window_skip_taskbar'):
win.set_property('skip-taskbar-hint', False) win.set_property('skip-taskbar-hint', False)
win.present_with_time(Gtk.get_current_event_time()) win.present_with_time(Gtk.get_current_event_time())
@ -392,11 +389,9 @@ class StatusIcon:
if not event: if not event:
return return
win = app.interface.roster.window win = app.interface.roster.window
if not win.get_property('visible') and app.config.get( if not win.get_property('visible'):
'save-roster-position'): # Needed if we are in one window mode
gtkgui_helpers.move_window(win, restore_roster_position(win)
app.config.get('roster_x-position'),
app.config.get('roster_y-position'))
app.interface.handle_event(account, jid, event.type_) app.interface.handle_event(account, jid, event.type_)
def on_middle_click(self): def on_middle_click(self):