Daniel Brötzmann pushed to branch mainwindow at gajim / gajim
Commits: 21ad28cc by wurstsalat at 2021-09-05T17:17:50+02:00 Add back X button and taskbar behavior
- - - - -
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 ===================================== @@ -53,6 +53,9 @@ class _ACCOUNT_DEFAULT: 'save_main_window_position': True, 'show_main_window_on_startup': 'always', 'last_main_window_visible': True, + 'quit_on_main_window_x_button': False, + 'hide_on_main_window_x_button': False, + 'main_window_skip_taskbar': False, 'roster_on_the_right': False, 'latest_disco_addresses': '', 'time_stamp': '%x | %X ', @@ -85,8 +88,6 @@ class _ACCOUNT_DEFAULT: 'notification_position_y': -1, 'muc_highlight_words': '', 'muc_prefer_direct_msg': True, - 'quit_on_roster_x_button': False, - 'hide_on_roster_x_button': False, 'show_status_msgs_in_roster': True, 'show_avatars_in_roster': True, 'show_mood_in_roster': True, @@ -96,7 +97,6 @@ class _ACCOUNT_DEFAULT: 'avatar_position_in_roster': 'right', 'print_status_in_chats': False, 'log_contact_status_changes': False, - 'roster_window_skip_taskbar': False, 'use_urgency_hint': True, 'notification_timeout': 5, 'escape_key_closes': False, @@ -390,13 +390,13 @@ class _ACCOUNT_DEFAULT: 'tabs_close_button': _('Show close button in tab?'), 'notification_preview_message': _('Preview new messages in notification popup?'), 'muc_highlight_words': _('A list of words (semicolon separated) that will be highlighted in group chats.'), - 'hide_on_roster_x_button': _('If enabled, Gajim hides the contact list window when pressing the X button instead of minimizing into the notification area.'), + 'hide_on_main_window_x_button': _('If enabled, Gajim hides the main window when pressing the X button instead of minimizing into the notification area.'), + 'main_window_skip_taskbar': _('Don’t show main window in the system taskbar.'), 'show_mood_in_roster': '', 'show_activity_in_roster': '', 'show_tunes_in_roster': '', 'show_location_in_roster': '', 'avatar_position_in_roster': _('Define the position of avatars in the contact list. Can be 'left' or 'right'.'), - 'roster_window_skip_taskbar': _('Don't show contact list window in the system taskbar.'), 'use_urgency_hint': _('If enabled, Gajim makes the window flash (the default behaviour in most Window Managers) when holding pending events.'), 'notification_timeout': '', 'escape_key_closes': _('If enabled, pressing Esc closes a tab/window.'),
===================================== gajim/gtk/main.py ===================================== @@ -1,4 +1,5 @@ import logging +import os
from gi.repository import Gtk from gi.repository import Gdk @@ -18,6 +19,7 @@ from .main_stack import MainStack from .dialogs import DialogButton from .dialogs import ConfirmationDialog +from .dialogs import ConfirmationCheckDialog from .util import get_builder from .util import resize_window from .util import restore_main_window_position @@ -59,6 +61,7 @@ def __init__(self): self._ui.account_box.add(self._account_side_bar)
self.connect('motion-notify-event', self._on_window_motion_notify) + self.connect('delete-event', self._on_window_delete)
self._ui.connect_signals(self)
@@ -90,6 +93,12 @@ def __init__(self): self._add_actions() self._add_actions2()
+ self._prepare_window() + + def _prepare_window(self): + if app.settings.get('main_window_skip_taskbar'): + self.set_property('skip-taskbar-hint', True) + restore_main_window_position() window_width = app.settings.get('mainwin_width') window_height = app.settings.get('mainwin_height') @@ -263,6 +272,36 @@ def _on_window_motion_notify(self, _widget, _event): client.get_module('Chatstate').set_mouse_activity( control.contact, control.msg_textview.has_text())
+ def _on_window_delete(self, _widget, _event): + # Main window X button was clicked + if (not app.settings.get('quit_on_main_window_x_button') and + ((app.interface.systray_enabled and + app.settings.get('trayicon') != 'on_event') or + app.settings.get('allow_hide_roster'))): + save_main_window_position() + if (os.name == 'nt' or + app.settings.get('hide_on_main_window_x_button')): + self.hide() + else: + self.iconify() + elif app.settings.get('quit_on_main_window_x_button'): + self.quit() + else: + def _on_ok(is_checked): + if is_checked: + app.settings.set('quit_on_main_window_x_button', True) + self.quit() + ConfirmationCheckDialog( + _('Quit Gajim'), + _('You are about to quit Gajim'), + _('Are you sure you want to quit Gajim?'), + _('_Always quit when closing Gajim'), + [DialogButton.make('Cancel'), + DialogButton.make('Remove', + text=_('_Quit'), + callback=_on_ok)]).show() + return True + def _set_startup_finished(self): self._startup_finished = True self._chat_page.set_startup_finished()
===================================== gajim/gtk/preferences.py ===================================== @@ -180,10 +180,10 @@ def __init__(self, *args): desc=_('Show window when starting Gajim')),
Setting(SettingKind.SWITCH, - _('Quit on Close'), + _('Quit Gajim on Close'), SettingType.CONFIG, - 'quit_on_roster_x_button', - desc=_('Quit when closing contact list')), + 'quit_on_main_window_x_button', + desc=_('Quit when closing Gajim’s window')), ]
PreferenceBox.__init__(self, settings)
===================================== gajim/gtk/status_icon.py ===================================== @@ -258,7 +258,7 @@ def _on_activate(self, *args): # Window was minimized restore_main_window_position()
- if not app.settings.get('roster_window_skip_taskbar'): + if not app.settings.get('main_window_skip_taskbar'): app.window.set_property('skip-taskbar-hint', False) app.window.present_with_time(Gtk.get_current_event_time())
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/21ad28cca70fbb18a06215f7a22d1cb11...