Philipp Hörist pushed to branch master at gajim / gajim
Commits:
64c81bdc by wurstsalat at 2020-07-05T18:12:51+02:00
ChatControl: Add menu item for blocking/reporting
- - - - -
e9a0e679 by wurstsalat at 2020-07-05T18:12:51+02:00
Roster: Adapt strings in blocking dialog
- - - - -
3 changed files:
- gajim/chat_control.py
- gajim/gui_menu_builder.py
- gajim/roster_window.py
Changes:
=====================================
gajim/chat_control.py
=====================================
@@ -251,8 +251,9 @@ class ChatControl(ChatControlBase):
actions = [
('invite-contacts-', self._on_invite_contacts),
('add-to-roster-', self._on_add_to_roster),
+ ('block-contact-', self._on_block_contact),
('information-', self._on_information),
- ]
+ ]
for action in actions:
action_name, func = action
@@ -300,6 +301,11 @@ class ChatControl(ChatControlBase):
win.lookup_action(
'add-to-roster-' + self.control_id).set_enabled(False)
+ # Block contact
+ win.lookup_action(
+ 'block-contact-' + self.control_id).set_enabled(
+ online and con.get_module('Blocking').supported)
+
# Audio
win.lookup_action('toggle-audio-' + self.control_id).set_enabled(
online and self.jingle['audio'].available)
@@ -376,6 +382,33 @@ class ChatControl(ChatControlBase):
def _on_add_to_roster(self, _action, _param):
AddNewContactWindow(self.account, self.contact.jid)
+ def _on_block_contact(self, _action, _param):
+ def _block_contact(report=None):
+ con = app.connections[self.account]
+ con.get_module('Blocking').block([self.contact.jid], report=report)
+
+ self.parent_win.remove_tab(self, None, force=True)
+ if _('Not in contact list') in self.contact.get_shown_groups():
+ app.interface.roster.remove_contact(
+ self.contact.jid, self.account, force=True, backend=True)
+ return
+ app.interface.roster.draw_contact(self.contact.jid, self.account)
+
+ NewConfirmationDialog(
+ _('Block Contact'),
+ _('Really block this contact?'),
+ _('You will appear offline for this contact and you will '
+ 'not receive further messages.'),
+ [DialogButton.make('Cancel'),
+ DialogButton.make('OK',
+ text=_('_Report Spam'),
+ callback=_block_contact,
+ kwargs={'report': 'spam'}),
+ DialogButton.make('Remove',
+ text=_('_Block'),
+ callback=_block_contact)],
+ modal=False).show()
+
def _on_information(self, _action, _param):
app.interface.roster.on_info(None, self.contact, self.account)
=====================================
gajim/gui_menu_builder.py
=====================================
@@ -522,6 +522,7 @@ def get_singlechat_menu(control_id, account, jid):
(_('Send Chatstate'), ['chatstate']),
('win.invite-contacts-', _('Invite Contacts…')),
('win.add-to-roster-', _('Add to Contact List…')),
+ ('win.block-contact-', _('Block Contact…')),
('win.toggle-audio-', _('Voice Chat')),
('win.toggle-video-', _('Video Chat')),
('win.information-', _('Information')),
=====================================
gajim/roster_window.py
=====================================
@@ -2787,8 +2787,8 @@ class RosterWindow:
self.draw_contact(contact.jid, acct)
def _block_it(is_checked=None):
- if is_checked is not None: # dialog has been shown
- if is_checked: # user does not want to be asked again
+ if is_checked is not None: # Dialog has been shown
+ if is_checked:
app.config.set('confirm_block', 'no')
else:
app.config.set('confirm_block', 'yes')
@@ -2804,25 +2804,22 @@ class RosterWindow:
if group is None:
title = _('Block Contact')
pritext = _('Really block this contact?')
- sectext = _('This contact will see you offline and you will not '
- 'receive any messages sent to you by this contact.')
- button_text = _('_Block Contact')
+ sectext = _('You will appear offline for this contact and you '
+ 'will not receive further messages.')
else:
title = _('Block Group')
pritext = _('Really block this group?')
- sectext = _('All contacts of this group will see you as offline '
- 'and you will not receive any messages sent to you '
- 'by any one of these contacts.')
- button_text = _('_Block Group')
+ sectext = _('You will appear offline for these contacts '
+ 'and you will not receive further messages.')
NewConfirmationCheckDialog(
title,
pritext,
sectext,
- _('_Do not ask me again'),
+ _('_Do not ask again'),
[DialogButton.make('Cancel'),
DialogButton.make('Remove',
- text=button_text,
+ text=_('_Block'),
callback=_block_it)],
modal=False).show()
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/6ad2dfb8d2b1c76429ed4b0ce2a94073a2dd78a7...e9a0e679612fdcc1d424e8ad5eb409ddd0ca3af6
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/6ad2dfb8d2b1c76429ed4b0ce2a94073a2dd78a7...e9a0e679612fdcc1d424e8ad5eb409ddd0ca3af6
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits