Daniel Brötzmann pushed to branch mainwindow at gajim / gajim
Commits:
-
21ad28cc
by wurstsalat at 2021-09-05T17:17:50+02:00
4 changed files:
Changes:
| ... | ... | @@ -53,6 +53,9 @@ class _ACCOUNT_DEFAULT: |
| 53 | 53 |
'save_main_window_position': True,
|
| 54 | 54 |
'show_main_window_on_startup': 'always',
|
| 55 | 55 |
'last_main_window_visible': True,
|
| 56 |
+ 'quit_on_main_window_x_button': False,
|
|
| 57 |
+ 'hide_on_main_window_x_button': False,
|
|
| 58 |
+ 'main_window_skip_taskbar': False,
|
|
| 56 | 59 |
'roster_on_the_right': False,
|
| 57 | 60 |
'latest_disco_addresses': '',
|
| 58 | 61 |
'time_stamp': '%x | %X ',
|
| ... | ... | @@ -85,8 +88,6 @@ class _ACCOUNT_DEFAULT: |
| 85 | 88 |
'notification_position_y': -1,
|
| 86 | 89 |
'muc_highlight_words': '',
|
| 87 | 90 |
'muc_prefer_direct_msg': True,
|
| 88 |
- 'quit_on_roster_x_button': False,
|
|
| 89 |
- 'hide_on_roster_x_button': False,
|
|
| 90 | 91 |
'show_status_msgs_in_roster': True,
|
| 91 | 92 |
'show_avatars_in_roster': True,
|
| 92 | 93 |
'show_mood_in_roster': True,
|
| ... | ... | @@ -96,7 +97,6 @@ class _ACCOUNT_DEFAULT: |
| 96 | 97 |
'avatar_position_in_roster': 'right',
|
| 97 | 98 |
'print_status_in_chats': False,
|
| 98 | 99 |
'log_contact_status_changes': False,
|
| 99 |
- 'roster_window_skip_taskbar': False,
|
|
| 100 | 100 |
'use_urgency_hint': True,
|
| 101 | 101 |
'notification_timeout': 5,
|
| 102 | 102 |
'escape_key_closes': False,
|
| ... | ... | @@ -390,13 +390,13 @@ class _ACCOUNT_DEFAULT: |
| 390 | 390 |
'tabs_close_button': _('Show close button in tab?'),
|
| 391 | 391 |
'notification_preview_message': _('Preview new messages in notification popup?'),
|
| 392 | 392 |
'muc_highlight_words': _('A list of words (semicolon separated) that will be highlighted in group chats.'),
|
| 393 |
- '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.'),
|
|
| 393 |
+ '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.'),
|
|
| 394 |
+ 'main_window_skip_taskbar': _('Don’t show main window in the system taskbar.'),
|
|
| 394 | 395 |
'show_mood_in_roster': '',
|
| 395 | 396 |
'show_activity_in_roster': '',
|
| 396 | 397 |
'show_tunes_in_roster': '',
|
| 397 | 398 |
'show_location_in_roster': '',
|
| 398 | 399 |
'avatar_position_in_roster': _('Define the position of avatars in the contact list. Can be \'left\' or \'right\'.'),
|
| 399 |
- 'roster_window_skip_taskbar': _('Don\'t show contact list window in the system taskbar.'),
|
|
| 400 | 400 |
'use_urgency_hint': _('If enabled, Gajim makes the window flash (the default behaviour in most Window Managers) when holding pending events.'),
|
| 401 | 401 |
'notification_timeout': '',
|
| 402 | 402 |
'escape_key_closes': _('If enabled, pressing Esc closes a tab/window.'),
|
| 1 | 1 |
import logging
|
| 2 |
+import os
|
|
| 2 | 3 |
|
| 3 | 4 |
from gi.repository import Gtk
|
| 4 | 5 |
from gi.repository import Gdk
|
| ... | ... | @@ -18,6 +19,7 @@ |
| 18 | 19 |
from .main_stack import MainStack
|
| 19 | 20 |
from .dialogs import DialogButton
|
| 20 | 21 |
from .dialogs import ConfirmationDialog
|
| 22 |
+from .dialogs import ConfirmationCheckDialog
|
|
| 21 | 23 |
from .util import get_builder
|
| 22 | 24 |
from .util import resize_window
|
| 23 | 25 |
from .util import restore_main_window_position
|
| ... | ... | @@ -59,6 +61,7 @@ def __init__(self): |
| 59 | 61 |
self._ui.account_box.add(self._account_side_bar)
|
| 60 | 62 |
|
| 61 | 63 |
self.connect('motion-notify-event', self._on_window_motion_notify)
|
| 64 |
+ self.connect('delete-event', self._on_window_delete)
|
|
| 62 | 65 |
|
| 63 | 66 |
self._ui.connect_signals(self)
|
| 64 | 67 |
|
| ... | ... | @@ -90,6 +93,12 @@ def __init__(self): |
| 90 | 93 |
self._add_actions()
|
| 91 | 94 |
self._add_actions2()
|
| 92 | 95 |
|
| 96 |
+ self._prepare_window()
|
|
| 97 |
+ |
|
| 98 |
+ def _prepare_window(self):
|
|
| 99 |
+ if app.settings.get('main_window_skip_taskbar'):
|
|
| 100 |
+ self.set_property('skip-taskbar-hint', True)
|
|
| 101 |
+ |
|
| 93 | 102 |
restore_main_window_position()
|
| 94 | 103 |
window_width = app.settings.get('mainwin_width')
|
| 95 | 104 |
window_height = app.settings.get('mainwin_height')
|
| ... | ... | @@ -263,6 +272,36 @@ def _on_window_motion_notify(self, _widget, _event): |
| 263 | 272 |
client.get_module('Chatstate').set_mouse_activity(
|
| 264 | 273 |
control.contact, control.msg_textview.has_text())
|
| 265 | 274 |
|
| 275 |
+ def _on_window_delete(self, _widget, _event):
|
|
| 276 |
+ # Main window X button was clicked
|
|
| 277 |
+ if (not app.settings.get('quit_on_main_window_x_button') and
|
|
| 278 |
+ ((app.interface.systray_enabled and
|
|
| 279 |
+ app.settings.get('trayicon') != 'on_event') or
|
|
| 280 |
+ app.settings.get('allow_hide_roster'))):
|
|
| 281 |
+ save_main_window_position()
|
|
| 282 |
+ if (os.name == 'nt' or
|
|
| 283 |
+ app.settings.get('hide_on_main_window_x_button')):
|
|
| 284 |
+ self.hide()
|
|
| 285 |
+ else:
|
|
| 286 |
+ self.iconify()
|
|
| 287 |
+ elif app.settings.get('quit_on_main_window_x_button'):
|
|
| 288 |
+ self.quit()
|
|
| 289 |
+ else:
|
|
| 290 |
+ def _on_ok(is_checked):
|
|
| 291 |
+ if is_checked:
|
|
| 292 |
+ app.settings.set('quit_on_main_window_x_button', True)
|
|
| 293 |
+ self.quit()
|
|
| 294 |
+ ConfirmationCheckDialog(
|
|
| 295 |
+ _('Quit Gajim'),
|
|
| 296 |
+ _('You are about to quit Gajim'),
|
|
| 297 |
+ _('Are you sure you want to quit Gajim?'),
|
|
| 298 |
+ _('_Always quit when closing Gajim'),
|
|
| 299 |
+ [DialogButton.make('Cancel'),
|
|
| 300 |
+ DialogButton.make('Remove',
|
|
| 301 |
+ text=_('_Quit'),
|
|
| 302 |
+ callback=_on_ok)]).show()
|
|
| 303 |
+ return True
|
|
| 304 |
+ |
|
| 266 | 305 |
def _set_startup_finished(self):
|
| 267 | 306 |
self._startup_finished = True
|
| 268 | 307 |
self._chat_page.set_startup_finished()
|
| ... | ... | @@ -180,10 +180,10 @@ def __init__(self, *args): |
| 180 | 180 |
desc=_('Show window when starting Gajim')),
|
| 181 | 181 |
|
| 182 | 182 |
Setting(SettingKind.SWITCH,
|
| 183 |
- _('Quit on Close'),
|
|
| 183 |
+ _('Quit Gajim on Close'),
|
|
| 184 | 184 |
SettingType.CONFIG,
|
| 185 |
- 'quit_on_roster_x_button',
|
|
| 186 |
- desc=_('Quit when closing contact list')),
|
|
| 185 |
+ 'quit_on_main_window_x_button',
|
|
| 186 |
+ desc=_('Quit when closing Gajim’s window')),
|
|
| 187 | 187 |
]
|
| 188 | 188 |
|
| 189 | 189 |
PreferenceBox.__init__(self, settings)
|
| ... | ... | @@ -258,7 +258,7 @@ def _on_activate(self, *args): |
| 258 | 258 |
# Window was minimized
|
| 259 | 259 |
restore_main_window_position()
|
| 260 | 260 |
|
| 261 |
- if not app.settings.get('roster_window_skip_taskbar'):
|
|
| 261 |
+ if not app.settings.get('main_window_skip_taskbar'):
|
|
| 262 | 262 |
app.window.set_property('skip-taskbar-hint', False)
|
| 263 | 263 |
app.window.present_with_time(Gtk.get_current_event_time())
|
| 264 | 264 |
|