[plugin_installer] Use NewConfirmationCheckDialog

This commit is contained in:
Daniel Brötzmann
2019-06-21 13:10:42 +02:00
parent c550f6fc8e
commit 3df231fcef

View File

@@ -40,14 +40,17 @@ from gi.repository import GLib
from gajim.common import app from gajim.common import app
from gajim.common import configpaths from gajim.common import configpaths
from gajim.plugins import GajimPlugin from gajim.plugins import GajimPlugin
from gajim.plugins.gui import GajimPluginConfigDialog from gajim.plugins.gui import GajimPluginConfigDialog
from gajim.plugins.plugins_i18n import _ from gajim.plugins.plugins_i18n import _
from gajim.plugins.helpers import get_builder from gajim.plugins.helpers import get_builder
from gajim.gtk.dialogs import DialogButton
from gajim.gtk.dialogs import NewConfirmationCheckDialog
from gajim.gtk.dialogs import InformationDialog
from gajim.gtk.dialogs import WarningDialog from gajim.gtk.dialogs import WarningDialog
from gajim.gtk.dialogs import HigDialog
from gajim.gtk.dialogs import YesNoDialog from gajim.gtk.dialogs import YesNoDialog
from gajim.gtk.dialogs import ConfirmationDialogCheck
from gajim.gtkgui_helpers import get_action from gajim.gtkgui_helpers import get_action
log = logging.getLogger('gajim.p.plugin_installer') log = logging.getLogger('gajim.p.plugin_installer')
@@ -126,20 +129,24 @@ class PluginInstaller(GajimPlugin):
self.on_activate(app.interface.instances['plugins']) self.on_activate(app.interface.instances['plugins'])
def warn_update(self, plugins): def warn_update(self, plugins):
def open_update(checked): def _open_update(is_checked):
if checked: if is_checked:
self.config['auto_update'] = True self.config['auto_update'] = True
get_action('plugins').activate() get_action('plugins').activate()
page = self.notebook.page_num(self.available_plugins_box) page = self.notebook.page_num(self.available_plugins_box)
self.notebook.set_current_page(page) self.notebook.set_current_page(page)
if plugins: if plugins:
plugins_str = '\n' + '\n'.join(plugins) plugins_str = '\n' + '\n'.join(plugins)
YesNoDialog( NewConfirmationCheckDialog(
_('Plugin updates'), _('Plugin Updates'),
_('Plugin Updates Available'),
_('There are updates available for plugins you have installed.\n' _('There are updates available for plugins you have installed.\n'
'Do you want to update those plugins:\n%s') % plugins_str, 'Do you want to update those plugins:\n%s') % plugins_str,
checktext=_('Update plugins automatically next time'), _('Update plugins automatically next time'),
on_response_yes=open_update) [DialogButton.make('Cancel'),
DialogButton.make('OK',
text=_('_Update'),
callback=_open_update)]).show()
else: else:
log.info('No updates found') log.info('No updates found')
if hasattr(self, 'thread'): if hasattr(self, 'thread'):
@@ -303,31 +310,29 @@ class PluginInstaller(GajimPlugin):
else: else:
need_restart = True need_restart = True
if need_restart:
txt = _('All plugins downloaded.\nThe updates will '
'be installed the next time Gajim is started.')
else:
txt = _('All selected plugins downloaded and activated')
if not auto_update: if not auto_update:
dialog = HigDialog( if need_restart:
self.window, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, '', txt) sectext = _('Updates will be installed next time Gajim is started.')
dialog.set_modal(False) else:
dialog.popup() sectext = _('All selected plugins downloaded and activated')
InformationDialog(_('Plugin Updates Downloaded'), sectext)
if auto_update and self.config['auto_update_feedback']: if auto_update and self.config['auto_update_feedback']:
def on_ok(checked): def _on_ok(is_checked):
if checked: if is_checked:
self.config['auto_update_feedback'] = False self.config['auto_update_feedback'] = False
# Hide cancel button to mimic InfoDialogCheck NewConfirmationCheckDialog(
ConfirmationDialogCheck(_('Plugins updated'), _('Plugins Updated'),
_('Plugin updates have successfully been downloaded.' _('Plugins Updated'),
'Updates will be installed on next Gajim restart.'), _('Plugin updates have successfully been downloaded.\n'
_('Do not show this message again'), 'Updates will be installed next time Gajim is started.'),
on_response_ok=on_ok).get_widget_for_response( _('Do not show this message again'),
Gtk.ResponseType.CANCEL).hide() [DialogButton.make('OK',
callback=_on_ok)]).show()
if auto_update and not self.config['auto_update_feedback']: if auto_update and not self.config['auto_update_feedback']:
log.info('Updates downloaded, will install on next restart') log.info('Updates downloaded, will install on next restart')
def available_plugins_treeview_selection_changed(self, treeview_selection): def available_plugins_treeview_selection_changed(self, treeview_selection):
model, iter_ = treeview_selection.get_selected() model, iter_ = treeview_selection.get_selected()
if not iter_: if not iter_: