Add NewConfirmationCheckDialog
This commit is contained in:
parent
4c062bf93d
commit
760b94f27f
2 changed files with 54 additions and 13 deletions
|
@ -15,6 +15,7 @@
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
|
from gi.repository import Pango
|
||||||
|
|
||||||
from gajim.common import app
|
from gajim.common import app
|
||||||
from gajim.common import helpers
|
from gajim.common import helpers
|
||||||
|
@ -53,6 +54,11 @@ class DialogButton(namedtuple('DialogButton', ('response text callback args '
|
||||||
default_kwargs['response'] = Gtk.ResponseType.OK
|
default_kwargs['response'] = Gtk.ResponseType.OK
|
||||||
default_kwargs['text'] = _('Delete')
|
default_kwargs['text'] = _('Delete')
|
||||||
default_kwargs['action'] = ButtonAction.DESTRUCTIVE
|
default_kwargs['action'] = ButtonAction.DESTRUCTIVE
|
||||||
|
|
||||||
|
elif type_ == 'Remove':
|
||||||
|
default_kwargs['response'] = Gtk.ResponseType.OK
|
||||||
|
default_kwargs['text'] = _('Remove')
|
||||||
|
default_kwargs['action'] = ButtonAction.DESTRUCTIVE
|
||||||
else:
|
else:
|
||||||
raise ValueError('Unknown button type: %s ' % type_)
|
raise ValueError('Unknown button type: %s ' % type_)
|
||||||
|
|
||||||
|
@ -1037,6 +1043,37 @@ class NewConfirmationDialog(Gtk.MessageDialog):
|
||||||
self.show_all()
|
self.show_all()
|
||||||
|
|
||||||
|
|
||||||
|
class NewConfirmationCheckDialog(NewConfirmationDialog):
|
||||||
|
def __init__(self, title, text, sec_text, check_text,
|
||||||
|
buttons, modal=True, transient_for=None):
|
||||||
|
NewConfirmationDialog.__init__(self,
|
||||||
|
title,
|
||||||
|
text,
|
||||||
|
sec_text,
|
||||||
|
buttons,
|
||||||
|
transient_for=transient_for,
|
||||||
|
modal=modal)
|
||||||
|
|
||||||
|
self._checkbutton = Gtk.CheckButton.new_with_mnemonic(check_text)
|
||||||
|
self._checkbutton.set_can_focus(False)
|
||||||
|
self._checkbutton.set_margin_start(30)
|
||||||
|
self._checkbutton.set_margin_end(30)
|
||||||
|
label = self._checkbutton.get_child()
|
||||||
|
label.set_line_wrap(True)
|
||||||
|
label.set_max_width_chars(50)
|
||||||
|
label.set_halign(Gtk.Align.START)
|
||||||
|
label.set_line_wrap_mode(Pango.WrapMode.WORD)
|
||||||
|
label.set_margin_start(10)
|
||||||
|
|
||||||
|
self.get_content_area().add(self._checkbutton)
|
||||||
|
|
||||||
|
def _on_response(self, _dialog, response):
|
||||||
|
button = self._buttons.get(response)
|
||||||
|
if button is not None:
|
||||||
|
button.args.insert(0, self._checkbutton.get_active())
|
||||||
|
super()._on_response(_dialog, response)
|
||||||
|
|
||||||
|
|
||||||
class ShortcutsWindow:
|
class ShortcutsWindow:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
transient = app.app.get_active_window()
|
transient = app.app.get_active_window()
|
||||||
|
|
|
@ -71,6 +71,8 @@ from gajim.gtk.dialogs import InputDialog
|
||||||
from gajim.gtk.dialogs import WarningDialog
|
from gajim.gtk.dialogs import WarningDialog
|
||||||
from gajim.gtk.dialogs import InformationDialog
|
from gajim.gtk.dialogs import InformationDialog
|
||||||
from gajim.gtk.dialogs import NonModalConfirmationDialog
|
from gajim.gtk.dialogs import NonModalConfirmationDialog
|
||||||
|
from gajim.gtk.dialogs import NewConfirmationCheckDialog
|
||||||
|
from gajim.gtk.dialogs import DialogButton
|
||||||
from gajim.gtk.join_groupchat import JoinGroupchatWindow
|
from gajim.gtk.join_groupchat import JoinGroupchatWindow
|
||||||
from gajim.gtk.single_message import SingleMessageWindow
|
from gajim.gtk.single_message import SingleMessageWindow
|
||||||
from gajim.gtk.add_contact import AddNewContactWindow
|
from gajim.gtk.add_contact import AddNewContactWindow
|
||||||
|
@ -3347,7 +3349,7 @@ class RosterWindow:
|
||||||
"""
|
"""
|
||||||
Remove a contact. list_ is a list of (contact, account) tuples
|
Remove a contact. list_ is a list of (contact, account) tuples
|
||||||
"""
|
"""
|
||||||
def on_ok(is_checked, list_):
|
def on_ok(is_checked):
|
||||||
remove_auth = True
|
remove_auth = True
|
||||||
if len(list_) == 1:
|
if len(list_) == 1:
|
||||||
contact = list_[0][0]
|
contact = list_[0][0]
|
||||||
|
@ -3366,8 +3368,8 @@ class RosterWindow:
|
||||||
contact.show = 'offline'
|
contact.show = 'offline'
|
||||||
app.contacts.add_contact(account, contact)
|
app.contacts.add_contact(account, contact)
|
||||||
self.add_contact(contact.jid, account)
|
self.add_contact(contact.jid, account)
|
||||||
def on_ok2(list_):
|
def on_ok2():
|
||||||
on_ok(False, list_)
|
on_ok(False)
|
||||||
|
|
||||||
if len(list_) == 1:
|
if len(list_) == 1:
|
||||||
contact = list_[0][0]
|
contact = list_[0][0]
|
||||||
|
@ -3380,19 +3382,22 @@ class RosterWindow:
|
||||||
ConfirmationDialog(pritext, sectext + \
|
ConfirmationDialog(pritext, sectext + \
|
||||||
_('By removing this contact you also remove authorization '
|
_('By removing this contact you also remove authorization '
|
||||||
'resulting in them always seeing you as offline.'),
|
'resulting in them always seeing you as offline.'),
|
||||||
on_response_ok=(on_ok2, list_))
|
on_response_ok=on_ok2)
|
||||||
elif _('Not in Roster') in contact.get_shown_groups():
|
elif _('Not in Roster') in contact.get_shown_groups():
|
||||||
# Contact is not in roster
|
# Contact is not in roster
|
||||||
ConfirmationDialog(pritext, sectext + \
|
ConfirmationDialog(pritext, sectext + \
|
||||||
_('Do you want to continue?'), on_response_ok=(on_ok2,
|
_('Do you want to continue?'), on_response_ok=on_ok2)
|
||||||
list_))
|
|
||||||
else:
|
else:
|
||||||
ConfirmationDialogCheck(pritext, sectext + \
|
NewConfirmationCheckDialog(
|
||||||
|
_('Remove'),
|
||||||
|
pritext, sectext + \
|
||||||
_('By removing this contact you also by default remove '
|
_('By removing this contact you also by default remove '
|
||||||
'authorization resulting in them always seeing you as'
|
'authorization resulting in them always seeing you as'
|
||||||
' offline.'),
|
' offline.'),
|
||||||
_('I want this contact to know my status after removal'),
|
_('_I want this contact to know my status after removal'),
|
||||||
on_response_ok=(on_ok, list_))
|
[DialogButton.make('Cancel'),
|
||||||
|
DialogButton.make('Remove', callback=on_ok)],
|
||||||
|
modal=False).show()
|
||||||
else:
|
else:
|
||||||
# several contact to remove at the same time
|
# several contact to remove at the same time
|
||||||
pritext = _('Contacts will be removed from your roster')
|
pritext = _('Contacts will be removed from your roster')
|
||||||
|
@ -3403,8 +3408,7 @@ class RosterWindow:
|
||||||
sectext = _('By removing these contacts:%s\nyou also remove '
|
sectext = _('By removing these contacts:%s\nyou also remove '
|
||||||
'authorization resulting in them always seeing you as '
|
'authorization resulting in them always seeing you as '
|
||||||
'offline.') % jids
|
'offline.') % jids
|
||||||
ConfirmationDialog(pritext, sectext,
|
ConfirmationDialog(pritext, sectext, on_response_ok=on_ok2)
|
||||||
on_response_ok=(on_ok2, list_))
|
|
||||||
|
|
||||||
def on_send_custom_status(self, widget, contact_list, show, group=None):
|
def on_send_custom_status(self, widget, contact_list, show, group=None):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Reference in a new issue