Philipp Hörist pushed to branch master at gajim / gajim
Commits: da400c0d by lovetox at 2022-05-17T22:42:51+02:00 fix: Trayicon: Remove obsolete config option
- Remove "on_event" because it is obsolete and none functional - Rename config value to show_trayicon - Preferences: Change to SwitchSetting
- - - - - 574e387c by lovetox at 2022-05-17T23:33:05+02:00 fix: Main: Show window correctly on startup
When show_main_window_on_startup is set to never, show_all() was never called leading to an empty window after raising the application.
Fixes #10865
- - - - -
4 changed files:
- gajim/common/setting_values.py - gajim/gtk/main.py - gajim/gtk/preferences.py - gajim/gtk/status_icon.py
Changes:
===================================== gajim/common/setting_values.py ===================================== @@ -92,6 +92,7 @@ class _ACCOUNT_DEFAULT: 'show_subject_on_join', 'show_transports_group', 'show_xhtml', + 'show_trayicon', 'showoffline', 'sort_by_show_in_muc', 'sort_by_show_in_roster', @@ -161,7 +162,6 @@ class _ACCOUNT_DEFAULT: 'show_main_window_on_startup', 'speller_language', 'stun_server', - 'trayicon', 'video_framerate', 'video_input_device', 'video_size', @@ -185,7 +185,7 @@ class _ACCOUNT_DEFAULT: 'autoxa_message': '', 'ask_online_status': False, 'ask_offline_status': False, - 'trayicon': 'always', + 'show_trayicon': True, 'allow_hide_roster': False, 'roster_theme': 'default', 'sort_by_show_in_roster': True,
===================================== gajim/gtk/main.py ===================================== @@ -99,6 +99,7 @@ def __init__(self) -> None: self.connect('motion-notify-event', self._on_window_motion_notify) self.connect('notify::is-active', self._on_window_active) self.connect('delete-event', self._on_window_delete) + self.connect('window-state-event', self._on_window_state_changed)
self._ui.connect_signals(self)
@@ -164,18 +165,17 @@ def _prepare_window(self) -> None: window_width = app.settings.get('mainwin_width') window_height = app.settings.get('mainwin_height') resize_window(self, window_width, window_height) + self.show_all()
- if app.settings.get('show_main_window_on_startup') == 'always': - self.show_all() - elif app.settings.get('show_main_window_on_startup') == 'never': - if app.settings.get('trayicon') != 'always': - # Without trayicon, we have to show the main window - self.show_all() - app.settings.set('last_main_window_visible', True) - else: - if (app.settings.get('last_main_window_visible') or - app.settings.get('trayicon') != 'always'): - self.show_all() + show_main_window = app.settings.get('show_main_window_on_startup') + if (show_main_window == 'always' or + not app.settings.get('show_trayicon')): + # Without trayicon, we have to show the main window + return + + if (show_main_window == 'never' or + not app.settings.get('last_main_window_visible')): + self.hide()
def _on_account_enabled(self, event: events.AccountEnabled) -> None: self._account_side_bar.add_account(event.account) @@ -428,6 +428,15 @@ def _on_ok(is_checked: bool) -> None: callback=_on_ok)]).show() return True
+ def _on_window_state_changed(self, + window: MainWindow, + event: Gdk.EventWindowState) -> None: + + iconified = bool(Gdk.WindowState.ICONIFIED & event.new_window_state) + hidden = bool(Gdk.WindowState.WITHDRAWN & event.new_window_state) + visible = not (iconified or hidden) + app.settings.set('last_main_window_visible', visible) + def _set_startup_finished(self) -> None: self._startup_finished = True self._chat_page.set_startup_finished() @@ -807,8 +816,6 @@ def quit(self) -> None: window_width, window_height = self.get_size() app.settings.set('mainwin_width', window_width) app.settings.set('mainwin_height', window_height) - app.settings.set( - 'last_main_window_visible', self.get_property('visible')) app.settings.save()
def on_continue2(message: Optional[str]) -> None:
===================================== gajim/gtk/preferences.py ===================================== @@ -458,18 +458,12 @@ def __init__(self, *args: Any) -> None:
class VisualNotifications(PreferenceBox): def __init__(self, *args: Any) -> None: - trayicon_items = { - 'never': _('Hide icon'), - 'on_event': _('Only show for pending events'), - 'always': _('Always show icon'), - }
settings = [ - Setting(SettingKind.POPOVER, + Setting(SettingKind.SWITCH, _('Notification Area Icon'), SettingType.CONFIG, - 'trayicon', - props={'entries': trayicon_items}), + 'show_trayicon'),
Setting(SettingKind.NOTIFICATIONS, _('Show Notifications'),
===================================== gajim/gtk/status_icon.py ===================================== @@ -59,14 +59,16 @@ class StatusIcon: def __init__(self) -> None: if self._can_use_libindicator(): - app.settings.connect_signal('trayicon', self._on_setting_changed) + app.settings.connect_signal('show_trayicon', + self._on_setting_changed) self._backend = AppIndicator() log.info('Use AppIndicator3 backend') elif app.is_display(Display.WAYLAND): self._backend = NoneBackend() log.info('libappindicator not found or disabled') else: - app.settings.connect_signal('trayicon', self._on_setting_changed) + app.settings.connect_signal('show_trayicon', + self._on_setting_changed) self._backend = GtkStatusIcon() log.info('Use GtkStatusIcon backend')
@@ -236,7 +238,7 @@ def update_state(self, count: int = 0) -> None: # Shutdown in progress, don't update icon return
- if app.settings.get('trayicon') == 'never': + if not app.settings.get('show_trayicon'): self._status_icon.set_visible(False) return
@@ -315,7 +317,7 @@ def __init__(self) -> None: self.update_state()
def update_state(self, count: int = 0) -> None: - if app.settings.get('trayicon') == 'never': + if not app.settings.get('show_trayicon'): self._status_icon.set_status(appindicator.IndicatorStatus.PASSIVE) return
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/597297c2729aa8a27add0141c747d401...