Refactor restoring roster position
This commit is contained in:
		
							parent
							
								
									2f5d00d1f3
								
							
						
					
					
						commit
						0e9422ae9b
					
				
					 3 changed files with 20 additions and 14 deletions
				
			
		| 
						 | 
				
			
			@ -30,6 +30,7 @@ from gajim.common import app
 | 
			
		|||
from gajim.common import configpaths
 | 
			
		||||
from gajim.common import i18n
 | 
			
		||||
from gajim.common.i18n import _
 | 
			
		||||
from gajim.common.const import Display
 | 
			
		||||
 | 
			
		||||
_icon_theme = Gtk.IconTheme.get_default()
 | 
			
		||||
_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)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
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:
 | 
			
		||||
    """
 | 
			
		||||
    Create a completion model for entry widget completion list consists of
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -84,6 +84,8 @@ from gajim.gtk.service_registration import ServiceRegistration
 | 
			
		|||
from gajim.gtk.history import HistoryWindow
 | 
			
		||||
from gajim.gtk.accounts import AccountsWindow
 | 
			
		||||
 | 
			
		||||
from gajim.gtk.util import restore_roster_position
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
log = logging.getLogger('gajim.roster')
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -5699,13 +5701,11 @@ class RosterWindow:
 | 
			
		|||
        if len(app.connections) < 2:
 | 
			
		||||
            # Do not merge accounts if only one exists
 | 
			
		||||
            self.regroup = False
 | 
			
		||||
 | 
			
		||||
        gtkgui_helpers.resize_window(self.window,
 | 
			
		||||
            app.config.get('roster_width'),
 | 
			
		||||
            app.config.get('roster_height'))
 | 
			
		||||
        if app.config.get('save-roster-position'):
 | 
			
		||||
            gtkgui_helpers.move_window(self.window,
 | 
			
		||||
                app.config.get('roster_x-position'),
 | 
			
		||||
                app.config.get('roster_y-position'))
 | 
			
		||||
        restore_roster_position(self.window)
 | 
			
		||||
 | 
			
		||||
        self.popups_notification_height = 0
 | 
			
		||||
        self.popup_notification_windows = []
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,7 +31,7 @@ from gajim.common import app
 | 
			
		|||
from gajim.common import helpers
 | 
			
		||||
from gajim.common.i18n import _
 | 
			
		||||
from gajim.common.helpers import save_roster_position
 | 
			
		||||
 | 
			
		||||
from gajim.gtk.util import restore_roster_position
 | 
			
		||||
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
 | 
			
		||||
            else:
 | 
			
		||||
                win.show_all()
 | 
			
		||||
                if app.config.get('save-roster-position'):
 | 
			
		||||
                    gtkgui_helpers.move_window(win,
 | 
			
		||||
                        app.config.get('roster_x-position'),
 | 
			
		||||
                        app.config.get('roster_y-position'))
 | 
			
		||||
                restore_roster_position(win)
 | 
			
		||||
                if not app.config.get('roster_window_skip_taskbar'):
 | 
			
		||||
                    win.set_property('skip-taskbar-hint', False)
 | 
			
		||||
                win.present_with_time(Gtk.get_current_event_time())
 | 
			
		||||
| 
						 | 
				
			
			@ -392,11 +389,9 @@ class StatusIcon:
 | 
			
		|||
        if not event:
 | 
			
		||||
            return
 | 
			
		||||
        win = app.interface.roster.window
 | 
			
		||||
        if not win.get_property('visible') and app.config.get(
 | 
			
		||||
        'save-roster-position'):
 | 
			
		||||
            gtkgui_helpers.move_window(win,
 | 
			
		||||
                app.config.get('roster_x-position'),
 | 
			
		||||
                app.config.get('roster_y-position'))
 | 
			
		||||
        if not win.get_property('visible'):
 | 
			
		||||
            # Needed if we are in one window mode
 | 
			
		||||
            restore_roster_position(win)
 | 
			
		||||
        app.interface.handle_event(account, jid, event.type_)
 | 
			
		||||
 | 
			
		||||
    def on_middle_click(self):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue