From 266a19f05cad26d97c659493cd34ba196ef6eeb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ball=C3=B3=20Gy=C3=B6rgy?= Date: Thu, 2 Feb 2023 07:26:20 +0000 Subject: [PATCH] shellMountOperation: Don't read unavailable desktop file If gnome-disk-utility is not installed on the system, its desktop file is unavailable, so we can't get the application's name. In this case hide the launcher button. Part-of: --- js/ui/shellMountOperation.js | 44 +++++++++++++++++------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/js/ui/shellMountOperation.js b/js/ui/shellMountOperation.js index b04156d1e..00498763b 100644 --- a/js/ui/shellMountOperation.js +++ b/js/ui/shellMountOperation.js @@ -294,10 +294,15 @@ var ShellMountPasswordDialog = GObject.registerClass({ content.add_child(this._keyfilesCheckbox); this._keyfilesLabel = new St.Label({ visible: false }); - this._keyfilesLabel.clutter_text.set_markup( - /* Translators: %s is the Disks application */ - _('To unlock a volume that uses keyfiles, use the %s utility instead.') - .format(disksApp.get_name())); + if (disksApp) { + this._keyfilesLabel.clutter_text.set_markup( + /* Translators: %s is the Disks application */ + _('To unlock a volume that uses keyfiles, use the %s utility instead.') + .format(disksApp.get_name())); + } else { + this._keyfilesLabel.clutter_text.set_markup( + _('You need an external utility like Disks to unlock a volume that uses keyfiles.')); + } this._keyfilesLabel.clutter_text.ellipsize = Pango.EllipsizeMode.NONE; this._keyfilesLabel.clutter_text.line_wrap = true; content.add_child(this._keyfilesLabel); @@ -387,13 +392,20 @@ var ShellMountPasswordDialog = GObject.registerClass({ label: _("Cancel"), action: this._onCancelButton.bind(this), key: Clutter.KEY_Escape, - }, { - /* Translators: %s is the Disks application */ - label: _("Open %s").format(disksApp.get_name()), - action: this._onOpenDisksButton.bind(this), - default: true, }]; + if (disksApp) { + this._usesKeyfilesButtons.push({ + /* Translators: %s is the Disks application */ + label: _('Open %s').format(disksApp.get_name()), + action: () => { + disksApp.activate(); + this._onCancelButton(); + }, + default: true, + }); + } + this.setButtons(this._defaultButtons); } @@ -455,20 +467,6 @@ var ShellMountPasswordDialog = GObject.registerClass({ this._keyfilesLabel.visible = useKeyfiles; this.setButtons(useKeyfiles ? this._usesKeyfilesButtons : this._defaultButtons); } - - _onOpenDisksButton() { - let app = Shell.AppSystem.get_default().lookup_app('org.gnome.DiskUtility.desktop'); - if (app) { - app.activate(); - } else { - Main.notifyError( - /* Translators: %s is the Disks application */ - _("Unable to start %s").format(app.get_name()), - /* Translators: %s is the Disks application */ - _('Couldn’t find the %s application').format(app.get_name())); - } - this._onCancelButton(); - } }); var ShellProcessesDialog = GObject.registerClass({