11const Applet = imports . ui . applet ;
22const Gio = imports . gi . Gio ;
33const Lang = imports . lang ;
4+ const Main = imports . ui . main ;
45const St = imports . gi . St ;
56const Tooltips = imports . ui . tooltips ;
67const PopupMenu = imports . ui . popupMenu ;
78const GnomeSession = imports . misc . gnomeSession ;
9+ const Settings = imports . ui . settings ;
10+ const Util = imports . misc . util ;
811
912const INHIBIT_IDLE_FLAG = 8 ;
1013const INHIBIT_SLEEP_FLAG = 4 ;
@@ -368,6 +371,11 @@ class CinnamonInhibitApplet extends Applet.IconApplet {
368371
369372 this . menu . addMenuItem ( this . notificationsSwitch ) ;
370373
374+ this . settings = new Settings . AppletSettings ( this , metadata . uuid , instanceId ) ;
375+ this . settings . bind ( "keyPower" , "keyPower" , this . _setKeybinding ) ;
376+ this . settings . bind ( "keyNotifications" , "keyNotifications" , this . _setKeybinding ) ;
377+ this . _setKeybinding ( ) ;
378+
371379 this . _createInhibitorMenuSection ( orientation ) ;
372380 }
373381
@@ -386,11 +394,30 @@ class CinnamonInhibitApplet extends Applet.IconApplet {
386394 }
387395 }
388396
397+ _setKeybinding ( ) {
398+ Main . keybindingManager . addHotKey ( "inhibit-power-" + this . instance_id ,
399+ this . keyPower ,
400+ Lang . bind ( this , this . toggle_inhibit_power ) ) ;
401+ Main . keybindingManager . addHotKey ( "inhibit-notifications-" + this . instance_id ,
402+ this . keyNotifications ,
403+ Lang . bind ( this , this . toggle_inhibit_notifications ) ) ;
404+ }
405+
389406 on_applet_clicked ( event ) {
390407 this . menu . toggle ( ) ;
391408 }
392409
410+ on_btn_open_system_power_settings_clicked ( ) {
411+ Util . spawnCommandLine ( "cinnamon-settings power" ) ;
412+ }
413+
414+ on_btn_open_system_notification_settings_clicked ( ) {
415+ Util . spawnCommandLine ( "cinnamon-settings notifications" ) ;
416+ }
417+
393418 on_applet_removed_from_panel ( ) {
419+ Main . keybindingManager . removeHotKey ( "inhibit-power-" + this . instance_id ) ;
420+ Main . keybindingManager . removeHotKey ( "inhibit-notifications-" + this . instance_id ) ;
394421 this . inhibitSwitch . kill ( ) ;
395422 }
396423
@@ -404,6 +431,27 @@ class CinnamonInhibitApplet extends Applet.IconApplet {
404431 this . inhibitSwitch . updateStatus ( ) ;
405432 }
406433
434+ toggle_inhibit_power ( ) {
435+ this . inhibitSwitch . _switch . toggle ( ) ;
436+ this . inhibitSwitch . toggled ( this . inhibitSwitch . _switch . state ) ;
437+
438+ let _symbol = this . inhibitSwitch . _switch . state ?
439+ "inhibit-symbolic" :
440+ "inhibit-active-symbolic" ;
441+
442+ Main . osdWindowManager . show ( - 1 , Gio . ThemedIcon . new ( _symbol ) ) ;
443+ }
444+
445+ toggle_inhibit_notifications ( ) {
446+ this . notificationsSwitch . toggle ( ) ;
447+
448+ let _symbol = this . notificationsSwitch . _switch . state ?
449+ "inhibit-notification-symbolic" :
450+ "inhibit-notification-active-symbolic" ;
451+
452+ Main . osdWindowManager . show ( - 1 , Gio . ThemedIcon . new ( _symbol ) ) ;
453+ }
454+
407455 get inhibitors ( ) {
408456 return this . _inhibitorMenuSection ;
409457 }
0 commit comments