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

Replace YesNoDialogs with NewConfirmationDialogs

parent c34545bd
......@@ -34,7 +34,6 @@ from gajim.gtk.dialogs import NewConfirmationDialog
from gajim.gtk.dialogs import ConfirmationDialogDoubleRadio
from gajim.gtk.dialogs import ErrorDialog
from gajim.gtk.dialogs import PassphraseDialog
from gajim.gtk.dialogs import YesNoDialog
from gajim.gtk.const import Setting
from gajim.gtk.const import SettingKind
from gajim.gtk.const import SettingType
......@@ -134,12 +133,16 @@ class AccountsWindow(Gtk.ApplicationWindow):
account, 'offline', _('Be right back.'))
GLib.timeout_add(500, login, account, show_before, status_before)
YesNoDialog(
_('Relogin now?'),
_('If you want all the changes to apply instantly, '
'you must relogin.'),
transient_for=self,
on_response_yes=lambda *args: relog(account))
NewConfirmationDialog(
_('Re-Login'),
_('Re-Login now?'),
_('To apply all changes instantly, you have to re-login.'),
[DialogButton.make('Cancel',
text=_('_Later')),
DialogButton.make('OK',
text=_('_Re-Login'),
callback=lambda *args: relog(account))],
transient_for=self).show()
@staticmethod
def _get_relogin_settings(account):
......
......@@ -44,7 +44,6 @@ from gajim.gtk.dialogs import DialogButton
from gajim.gtk.dialogs import NewConfirmationDialog
from gajim.gtk.dialogs import HigDialog
from gajim.gtk.dialogs import InformationDialog
from gajim.gtk.dialogs import YesNoDialog
from gajim.gtk.dialogs import ErrorDialog
from gajim.gtk.filechoosers import FileSaveDialog
from gajim.gtk.filechoosers import FileChooserDialog
......@@ -329,14 +328,20 @@ class FileTransfersWindow:
file_name = os.path.basename(file_props.file_name)
else:
file_name = file_props.name
YesNoDialog(
_('File transfer error'),
_('The file %(file)s has been received, but it seems to have '
NewConfirmationDialog(
_('File Transfer Error'),
_('File Transfer Error'),
_('The file %s has been received, but it seems to have '
'been damaged along the way.\n'
'Do you want to download it again?') %
{'file': file_name},
on_response_yes=(on_yes, jid, file_props, account),
type_=Gtk.MessageType.ERROR)
'Do you want to download it again?') % file_name,
[DialogButton.make('Cancel',
text=_('_No')),
DialogButton.make('OK',
text=_('_Download Again'),
callback=on_yes,
args=[jid,
file_props,
account])]).show()
def show_file_send_request(self, account, contact):
send_callback = partial(self.send_file, account, contact)
......
......@@ -98,8 +98,9 @@ from gajim.gtk.notification import Notification
from gajim.gtk.dialogs import ErrorDialog
from gajim.gtk.dialogs import WarningDialog
from gajim.gtk.dialogs import InformationDialog
from gajim.gtk.dialogs import NewConfirmationDialog
from gajim.gtk.dialogs import DialogButton
from gajim.gtk.dialogs import InputDialog
from gajim.gtk.dialogs import YesNoDialog
from gajim.gtk.dialogs import PassphraseDialog
from gajim.gtk.dialogs import PlainConnectionDialog
from gajim.gtk.dialogs import SSLErrorDialog
......@@ -161,24 +162,35 @@ class Interface:
@staticmethod
def handle_event_http_auth(obj):
#('HTTP_AUTH', account, (method, url, transaction_id, iq_obj, msg))
def response(account, answer):
# ('HTTP_AUTH', account, (method, url, transaction_id, iq_obj, msg))
def _response(account, answer):
obj.conn.get_module('HTTPAuth').build_http_auth_answer(
obj.stanza, answer)
def on_yes(is_checked, obj):
response(obj, 'yes')
account = obj.conn.name
pri_msg = _('HTTP (%(method)s) Authorization '
'for %(url)s (ID: %(id)s)') % {
'method': obj.method,
'url': obj.url,
'id': obj.iq_id}
sec_msg = _('Do you accept this request?')
if app.get_number_of_connected_accounts() > 1:
sec_msg = _('Do you accept this request on account %s?') % account
sec_msg = _('Do you accept this request (account: %s)?') % account
if obj.msg:
sec_msg = obj.msg + '\n' + sec_msg
YesNoDialog(_('HTTP (%(method)s) Authorization for '
'%(url)s (ID: %(id)s)') % {'method': obj.method, 'url': obj.url,
'id': obj.iq_id}, sec_msg, on_response_yes=(on_yes, obj),
on_response_no=(response, obj, 'no'))
NewConfirmationDialog(
_('Authorization'),
pri_msg,
sec_msg,
[DialogButton.make('Cancel',
text=_('_No'),
callback=_response,
args=[obj, 'yes']),
DialogButton.make('OK',
text=_('_Accept'),
callback=_response,
args=[obj, 'no'])]).show()
def handle_event_iq_error(self, event):
ctrl = self.msg_win_mgr.get_control(event.properties.jid.getBare(),
......@@ -424,16 +436,22 @@ class Interface:
% obj.jid)
def show_unsubscribed_dialog(self, account, contact):
def on_yes(is_checked, list_):
def _remove(list_):
self.roster.on_req_usub(None, list_)
list_ = [(contact, account)]
YesNoDialog(
_('Contact "%s" removed subscription from you') % contact.jid,
_('You will always see them as offline.\nDo you want to '
'remove them from your contact list?'),
on_response_yes=(on_yes, list_))
# FIXME: Per RFC 3921, we can "deny" ack as well, but the GUI does
# not show deny
NewConfirmationDialog(
_('Subscription Removed'),
_('Contact \'%s\' removed subscription from you') % contact.jid,
_('You will always see this contact as offline.\n'
'Do you want to remove them from your contact list?'),
[DialogButton.make('Cancel',
text=_('_No')),
DialogButton.make('Remove',
callback=_remove(list_))]).show()
# FIXME: Per RFC 3921, we can "deny" ack as well, but the GUI does
# not show deny
def handle_event_unsubscribed_presence(self, obj):
#('UNSUBSCRIBED', account, jid)
......
......@@ -82,7 +82,6 @@ if is_standalone():
# pylint: disable=C0413
from gajim.common import helpers
from gajim.gtk.dialogs import YesNoDialog
from gajim.gtk.dialogs import ErrorDialog
from gajim.gtk.dialogs import NewConfirmationDialog
from gajim.gtk.dialogs import DialogButton
......@@ -234,27 +233,27 @@ class HistoryManager:
Gtk.main_quit()
return
def on_yes(clicked):
def _on_yes():
self.cur.execute('VACUUM')
self.con.commit()
if is_standalone():
Gtk.main_quit()
def on_no():
def _on_no():
if is_standalone():
Gtk.main_quit()
dialog = YesNoDialog(
NewConfirmationDialog(
_('Database Cleanup'),
_('Do you want to clean up the database? '
'(STRONGLY NOT RECOMMENDED IF GAJIM IS RUNNING)'),
_('Normally allocated database size will not be freed, '
'it will just become reusable. If you really want to reduce '
'database filesize, click YES, else click NO.'
'\n\nIn case you click YES, please wait…'),
on_response_yes=on_yes, on_response_no=on_no)
dialog.set_title(_('Database Cleanup'))
button_box = dialog.get_children()[0].get_children()[1]
button_box.get_children()[0].grab_focus()
_('Normally, the allocated database size will not be freed, it '
'will just become reusable. This operation may take a while.'),
[DialogButton.make('Cancel',
callback=_on_no),
DialogButton.make('Remove',
text=_('_Cleanup'),
callback=_on_yes)]).show()
def _fill_jids_listview(self):
# get those jids that have at least one entry in logs
......@@ -581,7 +580,7 @@ class HistoryManager:
if paths_len == 0: # nothing is selected
return
def on_ok(liststore, list_of_paths):
def on_ok():
# delete rows from db that match log_line_id
list_of_rowrefs = []
for path in list_of_paths: # make them treerowrefs (it's needed)
......
......@@ -40,7 +40,8 @@ from gajim import message_control
from gajim.chat_control_base import ChatControlBase
from gajim.chat_control import ChatControl
from gajim.gtk.dialogs import YesNoDialog
from gajim.gtk.dialogs import DialogButton
from gajim.gtk.dialogs import NewConfirmationCheckDialog
from gajim.gtk.util import get_icon_name
from gajim.gtk.util import resize_window
from gajim.gtk.util import move_window
......@@ -231,7 +232,7 @@ class MessageWindow:
number_of_closed_control += 1
if number_of_closed_control > 1:
def on_yes1(checked):
def _on_yes1(checked):
if checked:
app.config.set('confirm_close_multiple_tabs', False)
self.dont_warn_on_delete = True
......@@ -246,11 +247,16 @@ class MessageWindow:
ctrl.minimize()
# destroy window
return False
YesNoDialog(
NewConfirmationCheckDialog(
_('Close Tabs'),
_('You are going to close several tabs'),
_('Do you really want to close them all?'),
checktext=_('_Do not ask me again'), on_response_yes=on_yes1,
transient_for=self.window)
_('_Do not ask me again'),
[DialogButton.make('Cancel'),
DialogButton.make('OK',
callback=_on_yes1)],
transient_for=self.window).show()
return True
def on_yes(ctrl):
......
......@@ -39,7 +39,8 @@ from gajim.plugins.helpers import GajimPluginActivateException
from gajim.plugins.plugins_i18n import _
from gajim.gtk.dialogs import WarningDialog
from gajim.gtk.dialogs import YesNoDialog
from gajim.gtk.dialogs import DialogButton
from gajim.gtk.dialogs import NewConfirmationDialog
from gajim.gtk.filechoosers import ArchiveChooserDialog
from gajim.gtk.util import get_builder
from gajim.gtk.util import load_icon
......@@ -260,9 +261,9 @@ class PluginsWindow:
dialog.popup()
def _on_plugin_exists(zip_filename):
def on_yes(is_checked):
def _on_yes():
plugin = app.plugin_manager.install_from_zip(zip_filename,
True)
True)
if not plugin:
show_warn_dialog()
return
......@@ -273,13 +274,24 @@ class PluginsWindow:
model.remove(row.iter)
break
iter_ = model.append([plugin, plugin.name, False,
plugin.activatable, self.get_plugin_icon(plugin)])
iter_ = model.append([
plugin,
plugin.name,
False,
plugin.activatable,
self.get_plugin_icon(plugin)])
sel = self.installed_plugins_treeview.get_selection()
sel.select_iter(iter_)
YesNoDialog(_('Plugin already exists'), sectext=_('Overwrite?'),
on_response_yes=on_yes, transient_for=self.window)
NewConfirmationDialog(
_('Overwrite Plugin?'),
_('Plugin already exists'),
_('Do you want to overwrite the currently installed version?'),
[DialogButton.make('Cancel'),
DialogButton.make('Remove',
text=_('_Overwrite'),
callback=_on_yes)],
transient_for=self.window).show()
def _try_install(zip_filename):
try:
......
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