@@ -26,15 +26,12 @@ const SignalManager = imports.misc.signalManager;
2626const GLib = imports . gi . GLib ;
2727
2828const UUID = "pin-unpin-panel@anaximeno" ;
29+
2930// XXX: Sync With Panel.PANEL_AUTOHIDE_KEY. Not using that directly because
3031// the ES6 standard doesn't support direct import of values declared with const or let
3132// from modules.
3233const PANEL_AUTOHIDE_KEY = "panels-autohide" ;
3334
34- // Bindinds Keys
35- const TOGGLE_PANEL_PIN_KEYBINDIND_KEY = `${ UUID } -toggle-panel-pin-binding-keys` ;
36- const PANEL_PIN_KEYBINDIND_KEY = `${ UUID } -peek-panel-bindind-keys` ;
37-
3835
3936Gettext . bindtextdomain ( UUID , GLib . get_home_dir ( ) + "/.local/share/locale" ) ;
4037
@@ -48,16 +45,21 @@ function _(text) {
4845class PinUnpinPanelApplet extends Applet . IconApplet {
4946 constructor ( metadata , orientation , panelHeight , instanceId ) {
5047 super ( orientation , panelHeight , instanceId ) ;
48+ this . instanceId = instanceId ;
5149 this . metadata = metadata ;
50+
5251 this . settings = this . _setup_settings ( metadata . uuid , instanceId ) ;
5352
5453 this . pinned = true ;
5554
5655 this . signalsManager = new SignalManager . SignalManager ( null ) ;
57- this . signalsManager . connect ( global . settings , "changed::" + PANEL_AUTOHIDE_KEY , this . on_panels_autohide_state_changed , this ) ;
56+ this . signalsManager . connect ( global . settings , "changed::" + PANEL_AUTOHIDE_KEY , this . on_panels_autohide_state_changed , this ) ;
57+
58+ this . _default_pin_icon_path = `${ metadata . path } /../icons/pin-symbolic.svg` ;
59+ this . _default_unpin_icon_path = `${ metadata . path } /../icons/unpin-symbolic.svg` ;
5860
59- this . default_pin_icon_path = `${ metadata . path } /../icons/ pin-symbolic.svg ` ;
60- this . default_unpin_icon_path = `${ metadata . path } /../icons/unpin-symbolic.svg ` ;
61+ this . _toggle_panel_pin_binding_id = `${ metadata . uuid } -toggle-panel- pin-binding-keys- ${ this . instanceId } ` ;
62+ this . _panel_peek_binding_id = `${ metadata . uuid } -peek-panel-bindind-keys- ${ this . instanceId } ` ;
6163
6264 this . set_toggle_panel_pin_keydind ( ) ;
6365 this . set_peek_panek_keybind ( ) ;
@@ -131,12 +133,15 @@ class PinUnpinPanelApplet extends Applet.IconApplet {
131133
132134 update_panel_applet_ui_state ( ) {
133135 if ( this . use_custom_icons ) {
134- this . set_applet_icon_name ( this . pinned ? this . custom_unpin_icon : this . custom_pin_icon ) ;
136+ let icon = this . pinned ? this . custom_unpin_icon : this . custom_pin_icon ;
137+ icon . endsWith ( '-symbolic' ) ? this . set_applet_icon_symbolic_name ( icon ) : this . set_applet_icon_name ( icon ) ;
135138 } else {
136- this . set_applet_icon_symbolic_path ( this . pinned ? this . default_unpin_icon_path : this . default_pin_icon_path ) ;
139+ let icon = this . pinned ? this . _default_unpin_icon_path : this . _default_pin_icon_path ;
140+ this . set_applet_icon_symbolic_path ( icon ) ;
137141 }
138142
139- this . set_applet_tooltip ( this . pinned ? _ ( "Click to Unpin the Panel" ) : _ ( "Click to Pin the Panel" ) ) ;
143+ let tooltip = this . pinned ? _ ( "Click to Unpin the Panel" ) : _ ( "Click to Pin the Panel" ) ;
144+ this . set_applet_tooltip ( tooltip ) ;
140145 }
141146
142147 get_panel_autohide_state ( ) {
@@ -178,23 +183,23 @@ class PinUnpinPanelApplet extends Applet.IconApplet {
178183
179184 set_toggle_panel_pin_keydind ( ) {
180185 this . set_keybinding (
181- TOGGLE_PANEL_PIN_KEYBINDIND_KEY ,
186+ this . _toggle_panel_pin_binding_id ,
182187 this . toggle_panel_pin_binding_keys ,
183188 this . toggle_panel_pin_state . bind ( this ) ,
184189 ) ;
185190 }
186191
187192 set_peek_panek_keybind ( ) {
188193 this . set_keybinding (
189- PANEL_PIN_KEYBINDIND_KEY ,
194+ this . _panel_peek_binding_id ,
190195 this . peek_panel_bindind_keys ,
191196 this . peek_panel . bind ( this ) ,
192197 ) ;
193198 }
194199
195200 set_keybinding ( id , keys , cb ) {
196201 this . unset_keybinding ( id ) ;
197- Main . keybindingManager . addHotKey ( id , keys , cb ) ;
202+ Main . keybindingManager . addHotKey ( id , keys , cb ) ;
198203 }
199204
200205 unset_keybinding ( id ) {
@@ -204,8 +209,8 @@ class PinUnpinPanelApplet extends Applet.IconApplet {
204209 destroy ( ) {
205210 this . signalsManager . disconnectAllSignals ( ) ;
206211 this . settings . finalize ( ) ;
207- this . unset_keybinding ( TOGGLE_PANEL_PIN_KEYBINDIND_KEY ) ;
208- this . unset_keybinding ( PANEL_PIN_KEYBINDIND_KEY ) ;
212+ this . unset_keybinding ( this . _toggle_panel_pin_binding_id ) ;
213+ this . unset_keybinding ( this . _panel_peek_binding_id ) ;
209214 }
210215}
211216
0 commit comments