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: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2621>
This commit is contained in:
Balló György 2023-02-02 07:26:20 +00:00
parent 852b2786d1
commit 266a19f05c

View File

@ -294,10 +294,15 @@ var ShellMountPasswordDialog = GObject.registerClass({
content.add_child(this._keyfilesCheckbox); content.add_child(this._keyfilesCheckbox);
this._keyfilesLabel = new St.Label({ visible: false }); this._keyfilesLabel = new St.Label({ visible: false });
this._keyfilesLabel.clutter_text.set_markup( if (disksApp) {
/* Translators: %s is the Disks application */ this._keyfilesLabel.clutter_text.set_markup(
_('To unlock a volume that uses keyfiles, use the <i>%s</i> utility instead.') /* Translators: %s is the Disks application */
.format(disksApp.get_name())); _('To unlock a volume that uses keyfiles, use the <i>%s</i> utility instead.')
.format(disksApp.get_name()));
} else {
this._keyfilesLabel.clutter_text.set_markup(
_('You need an external utility like <i>Disks</i> to unlock a volume that uses keyfiles.'));
}
this._keyfilesLabel.clutter_text.ellipsize = Pango.EllipsizeMode.NONE; this._keyfilesLabel.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
this._keyfilesLabel.clutter_text.line_wrap = true; this._keyfilesLabel.clutter_text.line_wrap = true;
content.add_child(this._keyfilesLabel); content.add_child(this._keyfilesLabel);
@ -387,13 +392,20 @@ var ShellMountPasswordDialog = GObject.registerClass({
label: _("Cancel"), label: _("Cancel"),
action: this._onCancelButton.bind(this), action: this._onCancelButton.bind(this),
key: Clutter.KEY_Escape, 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); this.setButtons(this._defaultButtons);
} }
@ -455,20 +467,6 @@ var ShellMountPasswordDialog = GObject.registerClass({
this._keyfilesLabel.visible = useKeyfiles; this._keyfilesLabel.visible = useKeyfiles;
this.setButtons(useKeyfiles ? this._usesKeyfilesButtons : this._defaultButtons); 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 */
_('Couldnt find the %s application').format(app.get_name()));
}
this._onCancelButton();
}
}); });
var ShellProcessesDialog = GObject.registerClass({ var ShellProcessesDialog = GObject.registerClass({