2021-02-01 04:20:48 -05:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
2023-07-10 05:53:00 -04:00
|
|
|
import Clutter from 'gi://Clutter';
|
|
|
|
import GObject from 'gi://GObject';
|
|
|
|
import Shell from 'gi://Shell';
|
|
|
|
import St from 'gi://St';
|
2021-02-01 04:20:48 -05:00
|
|
|
|
|
|
|
const Config = imports.misc.config;
|
2023-07-10 05:53:00 -04:00
|
|
|
import * as Main from './main.js';
|
|
|
|
import * as Dialog from './dialog.js';
|
|
|
|
import * as ModalDialog from './modalDialog.js';
|
2021-02-01 04:20:48 -05:00
|
|
|
|
2023-07-30 08:56:59 -04:00
|
|
|
/** @enum {number} */
|
2023-07-10 05:53:00 -04:00
|
|
|
const DialogResponse = {
|
2021-02-01 04:20:48 -05:00
|
|
|
NO_THANKS: 0,
|
|
|
|
TAKE_TOUR: 1,
|
|
|
|
};
|
|
|
|
|
2023-07-10 05:53:00 -04:00
|
|
|
export const WelcomeDialog = GObject.registerClass(
|
2021-02-01 04:20:48 -05:00
|
|
|
class WelcomeDialog extends ModalDialog.ModalDialog {
|
|
|
|
_init() {
|
2023-08-06 18:40:20 -04:00
|
|
|
super._init({styleClass: 'welcome-dialog'});
|
2021-02-01 04:20:48 -05:00
|
|
|
|
|
|
|
const appSystem = Shell.AppSystem.get_default();
|
|
|
|
this._tourAppInfo = appSystem.lookup_app('org.gnome.Tour.desktop');
|
|
|
|
|
|
|
|
this._buildLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
open() {
|
|
|
|
if (!this._tourAppInfo)
|
2021-10-30 18:08:12 -04:00
|
|
|
return false;
|
2021-02-01 04:20:48 -05:00
|
|
|
|
2021-10-30 18:08:12 -04:00
|
|
|
return super.open();
|
2021-02-01 04:20:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
_buildLayout() {
|
|
|
|
const [majorVersion] = Config.PACKAGE_VERSION.split('.');
|
2021-10-05 09:05:18 -04:00
|
|
|
const title = _('Welcome to GNOME %s').format(majorVersion);
|
2021-02-01 04:20:48 -05:00
|
|
|
const description = _('If you want to learn your way around, check out the tour.');
|
2023-08-06 18:40:20 -04:00
|
|
|
const content = new Dialog.MessageDialogContent({title, description});
|
2021-02-01 04:20:48 -05:00
|
|
|
|
2023-08-06 18:40:20 -04:00
|
|
|
const icon = new St.Widget({style_class: 'welcome-dialog-image'});
|
2021-02-01 04:20:48 -05:00
|
|
|
content.insert_child_at_index(icon, 0);
|
|
|
|
|
|
|
|
this.contentLayout.add_child(content);
|
|
|
|
|
2020-03-29 17:51:13 -04:00
|
|
|
this.addButton({
|
|
|
|
label: _('No Thanks'),
|
|
|
|
action: () => this._sendResponse(DialogResponse.NO_THANKS),
|
|
|
|
key: Clutter.KEY_Escape,
|
|
|
|
});
|
|
|
|
this.addButton({
|
|
|
|
label: _('Take Tour'),
|
|
|
|
action: () => this._sendResponse(DialogResponse.TAKE_TOUR),
|
|
|
|
});
|
2021-02-01 04:20:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
_sendResponse(response) {
|
2021-02-19 11:11:14 -05:00
|
|
|
if (response === DialogResponse.TAKE_TOUR) {
|
2021-02-01 04:20:48 -05:00
|
|
|
this._tourAppInfo.launch(0, -1, Shell.AppLaunchGpu.APP_PREF);
|
2021-02-19 11:11:14 -05:00
|
|
|
Main.overview.hide();
|
|
|
|
}
|
2021-02-01 04:20:48 -05:00
|
|
|
|
|
|
|
this.close();
|
|
|
|
}
|
|
|
|
});
|