@@ -11,6 +11,7 @@ const Main = imports.ui.main;
1111const WindowMenu = imports . ui . windowMenu ;
1212const GObject = imports . gi . GObject ;
1313const AppSwitcher = imports . ui . appSwitcher . appSwitcher ;
14+ const Dialog = imports . ui . dialog ;
1415const ModalDialog = imports . ui . modalDialog ;
1516const WmGtkDialogs = imports . ui . wmGtkDialogs ;
1617const CloseDialog = imports . ui . closeDialog ;
@@ -28,6 +29,7 @@ const WINDOW_ANIMATION_TIME_MULTIPLIERS = [
2829]
2930
3031const EASING_MULTIPLIER = 1000 ; // multiplier for tweening.time ---> easing.duration
32+ var ONE_SECOND = 1000 ; // in ms
3133
3234const DIM_TIME = 0.500 ;
3335const DIM_BRIGHTNESS = - 0.2 ;
@@ -62,6 +64,75 @@ const ZONE_TR = 5;
6264const ZONE_BR = 6 ;
6365const ZONE_BL = 7 ;
6466
67+ var DisplayChangeDialog = GObject . registerClass (
68+ class DisplayChangeDialog extends ModalDialog . ModalDialog {
69+ _init ( wm ) {
70+ super . _init ( ) ;
71+
72+ this . _wm = wm ;
73+
74+ this . _countDown = Meta . MonitorManager . get_display_configuration_timeout ( ) ;
75+
76+ // Translators: This string should be shorter than 30 characters
77+ let title = _ ( "Keep these display settings?" ) ;
78+ let description = this . _formatCountDown ( ) ;
79+
80+ this . _content = new Dialog . MessageDialogContent ( { title, description } ) ;
81+ this . contentLayout . add_child ( this . _content ) ;
82+
83+ /* Translators: this and the following message should be limited in length,
84+ to avoid ellipsizing the labels.
85+ */
86+ this . _cancelButton = this . addButton ( { label : _ ( "Revert Settings" ) ,
87+ action : this . _onFailure . bind ( this ) ,
88+ key : Clutter . KEY_Escape } ) ;
89+ this . _okButton = this . addButton ( { label : _ ( "Keep Changes" ) ,
90+ action : this . _onSuccess . bind ( this ) ,
91+ default : true } ) ;
92+
93+ this . _timeoutId = GLib . timeout_add ( GLib . PRIORITY_DEFAULT , ONE_SECOND , this . _tick . bind ( this ) ) ;
94+ GLib . Source . set_name_by_id ( this . _timeoutId , '[cinnamon] this._tick' ) ;
95+ }
96+
97+ close ( timestamp ) {
98+ if ( this . _timeoutId > 0 ) {
99+ GLib . source_remove ( this . _timeoutId ) ;
100+ this . _timeoutId = 0 ;
101+ }
102+
103+ super . close ( timestamp ) ;
104+ }
105+
106+ _formatCountDown ( ) {
107+ let fmt = ngettext ( "Settings changes will revert in %d second" ,
108+ "Settings changes will revert in %d seconds" ) ;
109+ return fmt . format ( this . _countDown ) ;
110+ }
111+
112+ _tick ( ) {
113+ this . _countDown -- ;
114+ if ( this . _countDown == 0 ) {
115+ /* muffin already takes care of failing at timeout */
116+ this . _timeoutId = 0 ;
117+ this . close ( ) ;
118+ return GLib . SOURCE_REMOVE ;
119+ }
120+
121+ this . _content . description = this . _formatCountDown ( ) ;
122+ return GLib . SOURCE_CONTINUE ;
123+ }
124+
125+ _onFailure ( ) {
126+ this . _wm . complete_display_change ( false ) ;
127+ this . close ( ) ;
128+ }
129+
130+ _onSuccess ( ) {
131+ this . _wm . complete_display_change ( true ) ;
132+ this . close ( ) ;
133+ }
134+ } ) ;
135+
65136class WindowDimmer {
66137 constructor ( actor ) {
67138 this . _brightnessEffect = new Clutter . BrightnessContrastEffect ( {
@@ -1398,7 +1469,7 @@ var WindowManager = class WindowManager {
13981469 }
13991470
14001471 _confirmDisplayChange ( ) {
1401- let dialog = new WmGtkDialogs . DisplayChangesDialog ( this . _cinnamonwm ) ;
1472+ let dialog = new DisplayChangeDialog ( this . _cinnamonwm ) ;
14021473 dialog . open ( ) ;
14031474 }
14041475} ;
0 commit comments