Commit c18cc281 authored by Daniel Brötzmann's avatar Daniel Brötzmann Committed by Philipp Hörist

Rework DoubleInputDialog to DestroyMucDialog

parent 519d8644
Pipeline #3530 passed with stages
in 3 minutes and 8 seconds
......@@ -71,7 +71,7 @@ from gajim.common.connection_handlers_events import GcMessageOutgoingEvent
from gajim.gtk.dialogs import ErrorDialog
from gajim.gtk.dialogs import InputTextDialog
from gajim.gtk.dialogs import ConfirmationDialogCheck
from gajim.gtk.dialogs import DoubleInputDialog
from gajim.gtk.dialogs import DestroyMucDialog
from gajim.gtk.dialogs import InputDialog
from gajim.gtk.dialogs import ChangeNickDialog
from gajim.gtk.single_message import SingleMessageWindow
......@@ -643,7 +643,7 @@ class GroupchatControl(ChatControlBase):
self.force_non_minimizable = False
def _on_destroy_room(self, action, param):
def on_ok(reason, jid):
def _on_confirm(reason, jid):
if jid:
# Test jid
try:
......@@ -658,12 +658,8 @@ class GroupchatControl(ChatControlBase):
con = app.connections[self.account]
con.get_module('MUC').destroy(self.room_jid, reason, jid)
# Ask for a reason
DoubleInputDialog(_('Destroying %s') % '\u200E' + \
self.room_jid, _('You are going to remove this room permanently.'
'\nYou may specify a reason below:'),
_('You may also enter an alternate venue:'), ok_handler=on_ok,
transient_for=self.parent_win.window)
# Ask for a reason (and an alternate venue)
DestroyMucDialog(self.room_jid, destroy_handler=_on_confirm)
def _on_configure_room(self, _action, _param):
contact = app.contacts.get_gc_contact(
......
......@@ -814,72 +814,48 @@ class InputTextDialog(CommonInputDialog):
return self.input_buffer.get_text(start_iter, end_iter, True)
class DoubleInputDialog:
class DestroyMucDialog:
"""
Class for Double Input dialog
Class for Destroy MUC Dialog
"""
def __init__(self, room_jid, destroy_handler=None):
self._ui = get_builder('destroy_muc_dialog.ui')
self._ui.destroy_muc_dialog.set_transient_for(
app.app.get_active_window())
self.destroy_handler = destroy_handler
title = _('Destroy %s') % room_jid
self._ui.destroy_muc_dialog.set_title(title)
label_header = _('Destroy this group chat permanently?')
self._ui.label_header.set_markup(label_header)
label_alt_venue = _('Where participants should go (optional)')
self._ui.alt_venue_label.set_markup(label_alt_venue)
self._ui.reason_entry.connect('activate', self._on_entry_activate)
self._ui.alt_venue_entry.connect('activate', self._on_entry_activate)
self._ui.destroy_button.connect(
'clicked', self._on_destroy_button_clicked)
self._ui.cancel_button.connect(
'clicked', self._on_cancel_button_clicked)
self._ui.connect_signals(self)
self._ui.destroy_muc_dialog.show_all()
def __init__(self, title, label_str1, label_str2, input_str1=None,
input_str2=None, is_modal=True, ok_handler=None, cancel_handler=None,
transient_for=None):
self.xml = get_builder('dubbleinput_dialog.ui')
self.dialog = self.xml.get_object('dubbleinput_dialog')
label1 = self.xml.get_object('label1')
self.input_entry1 = self.xml.get_object('input_entry1')
label2 = self.xml.get_object('label2')
self.input_entry2 = self.xml.get_object('input_entry2')
self.dialog.set_title(title)
label1.set_markup(label_str1)
label2.set_markup(label_str2)
self.cancel_handler = cancel_handler
if input_str1:
self.input_entry1.set_text(input_str1)
self.input_entry1.select_region(0, -1) # select all
if input_str2:
self.input_entry2.set_text(input_str2)
self.input_entry2.select_region(0, -1) # select all
if transient_for is None:
transient_for = app.app.get_active_window()
self.dialog.set_transient_for(transient_for)
def _on_entry_activate(self, widget, *args):
self._ui.destroy_button.set_active(True)
self.dialog.set_modal(is_modal)
def _on_reason_mnemonic_activate(self, widget, group_cycling=False):
self._ui.reason_expander.set_expanded(True)
self.ok_handler = ok_handler
okbutton = self.xml.get_object('okbutton')
okbutton.connect('clicked', self.on_okbutton_clicked)
cancelbutton = self.xml.get_object('cancelbutton')
cancelbutton.connect('clicked', self.on_cancelbutton_clicked)
self.xml.connect_signals(self)
self.dialog.show_all()
def _on_destroy_button_clicked(self, widget):
user_input_reason = self._ui.reason_entry.get_text()
user_input_alt_venue = self._ui.alt_venue_entry.get_text()
self._ui.destroy_muc_dialog.destroy()
self.destroy_handler(user_input_reason, user_input_alt_venue)
def on_dubbleinput_dialog_destroy(self, widget):
if not self.cancel_handler:
return False
if isinstance(self.cancel_handler, tuple):
self.cancel_handler[0](*self.cancel_handler[1:])
else:
self.cancel_handler()
def on_okbutton_clicked(self, widget):
user_input1 = self.input_entry1.get_text()
user_input2 = self.input_entry2.get_text()
self.cancel_handler = None
self.dialog.destroy()
if not self.ok_handler:
return
if isinstance(self.ok_handler, tuple):
self.ok_handler[0](user_input1, user_input2, *self.ok_handler[1:])
else:
self.ok_handler(user_input1, user_input2)
def on_cancelbutton_clicked(self, widget):
self.dialog.destroy()
if not self.cancel_handler:
return
if isinstance(self.cancel_handler, tuple):
self.cancel_handler[0](*self.cancel_handler[1:])
else:
self.cancel_handler()
def _on_cancel_button_clicked(self, widget):
self._ui.destroy_muc_dialog.destroy()
class CertificateDialog(Gtk.ApplicationWindow):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment