Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions data/theme/cinnamon-sass/widgets/_dialogs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,10 @@
}
}
}

// Popup dialog (non-modal, draggable)
.popup-dialog {
.dialog {
box-shadow: 0 0 3px 2px transparentize($accent_bg_color, 0.6);
}
}
133 changes: 133 additions & 0 deletions js/ui/baseDialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-

const Clutter = imports.gi.Clutter;
const St = imports.gi.St;
const GObject = imports.gi.GObject;

const Params = imports.misc.params;

var State = {
OPENED: 0,
CLOSED: 1,
OPENING: 2,
CLOSING: 3,
};

var BaseDialog = GObject.registerClass({
Properties: {
'state': GObject.ParamSpec.int(
'state', 'Dialog state', 'state',
GObject.ParamFlags.READABLE,
Math.min(...Object.values(State)),
Math.max(...Object.values(State)),
State.CLOSED)
},
Signals: { 'opened': {}, 'closed': {} }
}, class BaseDialog extends St.Widget {

_init(stWidgetProps, params) {
super._init(stWidgetProps);

params = Params.parse(params, {
destroyOnClose: true,
});

this._state = State.CLOSED;
this._destroyOnClose = params.destroyOnClose;

this.openAndCloseTime = 100;
if (!global.settings.get_boolean("desktop-effects-workspace")) {
this.openAndCloseTime = 0;
}

this._initialKeyFocus = null;
this._initialKeyFocusDestroyId = 0;
}

_initDialogLayout(dialogLayout) {
this.dialogLayout = dialogLayout;
this.contentLayout = dialogLayout.contentLayout;
this.buttonLayout = dialogLayout.buttonLayout;
global.focus_manager.add_group(dialogLayout);
}

get state() {
return this._state;
}

_setState(state) {
if (this._state == state)
return;

this._state = state;
this.notify('state');
}

clearButtons() {
this.dialogLayout.clearButtons();
}

setButtons(buttons) {
this.clearButtons();

for (let buttonInfo of buttons) {
this.addButton(buttonInfo);
}
}

addButton(buttonInfo) {
return this.dialogLayout.addButton(buttonInfo);
}

setInitialKeyFocus(actor) {
if (this._initialKeyFocusDestroyId)
this._initialKeyFocus.disconnect(this._initialKeyFocusDestroyId);

this._initialKeyFocus = actor;

this._initialKeyFocusDestroyId = actor.connect('destroy', () => {
this._initialKeyFocus = null;
this._initialKeyFocusDestroyId = 0;
});
}

_grabInitialKeyFocus() {
let focus = this._initialKeyFocus || this.dialogLayout.initialKeyFocus;
focus.grab_key_focus();
}

_animateOpen() {
this._setState(State.OPENING);

this.dialogLayout.opacity = 255;
this.opacity = 0;
this.show();
this.ease({
opacity: 255,
duration: this.openAndCloseTime,
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
onComplete: () => {
this._setState(State.OPENED);
this.emit('opened');
}
});
}

_animateClose() {
this._setState(State.CLOSING);

this.ease({
opacity: 0,
duration: this.openAndCloseTime,
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
onComplete: () => {
this._setState(State.CLOSED);
this.hide();
this.emit('closed');

if (this._destroyOnClose)
this.destroy();
}
});
}
});
2 changes: 1 addition & 1 deletion js/ui/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Dialog extends St.Widget {
vertical: true
});

// modal dialogs are fixed width and grow vertically; set the request
// Dialogs are fixed width and grow vertically; set the request
// mode accordingly so wrapped labels are handled correctly during
// size requests.
this._dialog.set_offscreen_redirect(Clutter.OffscreenRedirect.ALWAYS);
Expand Down
21 changes: 4 additions & 17 deletions js/ui/keyringPrompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ const GObject = imports.gi.GObject;
const Gcr = imports.gi.Gcr;

const Dialog = imports.ui.dialog;
const ModalDialog = imports.ui.modalDialog;
const PopupDialog = imports.ui.popupDialog;
const CinnamonEntry = imports.ui.cinnamonEntry;
const CheckBox = imports.ui.checkBox;
const Util = imports.misc.util;

var KeyringDialog = GObject.registerClass(
class KeyringDialog extends ModalDialog.ModalDialog {
class KeyringDialog extends PopupDialog.PopupDialog {
_init() {
super._init({ styleClass: 'prompt-dialog' });

Expand Down Expand Up @@ -127,21 +127,8 @@ class KeyringDialog extends ModalDialog.ModalDialog {
}

_ensureOpen() {
// NOTE: ModalDialog.open() is safe to call if the dialog is
// already open - it just returns true without side-effects
if (this.open())
return true;

// The above fail if e.g. unable to get input grab
//
// In an ideal world this wouldn't happen (because
// Cinnamon is in complete control of the session) but that's
// just not how things work right now.

log('keyringPrompt: Failed to show modal dialog.' +
' Dismissing prompt request');
this.prompt.cancel();
return false;
this.open();
return true;
}

_onShowPassword() {
Expand Down
Loading
Loading