-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: rename/create dialog fixes and refactor (#86)
- Loading branch information
Showing
3 changed files
with
76 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// @ts-ignore | ||
import * as Dialog from 'resource:///org/gnome/shell/ui/dialog.js'; | ||
// @ts-ignore | ||
import * as ModalDialog from 'resource:///org/gnome/shell/ui/modalDialog.js'; | ||
// @ts-ignore | ||
import St from 'gi://St'; | ||
// @ts-ignore | ||
import Clutter from 'gi://Clutter'; | ||
|
||
|
||
export class LayoutNameDialog { | ||
private _modalDialog: ModalDialog.ModalDialog; | ||
private _okayCallback: (text: string) => void; | ||
|
||
constructor(title: string, layoutName: string, okayCallback: (text: string) => void) { | ||
this._modalDialog = new ModalDialog.ModalDialog({}); | ||
this._okayCallback = okayCallback; | ||
|
||
const listLayout = new Dialog.ListSection({ title }); | ||
this._modalDialog.contentLayout.add_child(listLayout); | ||
|
||
const entry = new St.Entry({ text: layoutName }); | ||
listLayout.add_child(entry); | ||
|
||
this._modalDialog.setButtons([ | ||
{ | ||
label: "Ok", | ||
key: Clutter.Return, | ||
action: () => { | ||
this._okayCallback(entry.text); | ||
this._modalDialog.close(); | ||
}, | ||
}, | ||
{ | ||
label: "Cancel", | ||
key: Clutter.Escape, | ||
action: () => this._modalDialog.close(), | ||
}]); | ||
} | ||
|
||
open() { | ||
this._modalDialog.open(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters