@@ -12,6 +12,7 @@ const NotificationDestroyedReason = imports.ui.messageTray.NotificationDestroyed
1212const Settings = imports . ui . settings ;
1313const Gettext = imports . gettext . domain ( "cinnamon-applets" ) ;
1414const Util = imports . misc . util ;
15+ const SignalManager = imports . misc . signalManager ;
1516
1617const PANEL_EDIT_MODE_KEY = "panel-edit-mode" ;
1718
@@ -34,17 +35,22 @@ class CinnamonNotificationsApplet extends Applet.TextIconApplet {
3435 // Layout
3536 this . _orientation = orientation ;
3637 this . menuManager = new PopupMenu . PopupMenuManager ( this ) ;
38+ this . menu = new Applet . AppletPopupMenu ( this , orientation ) ;
39+ this . menuManager . addMenu ( this . menu ) ;
3740
3841 // Lists
3942 this . notifications = [ ] ; // The list of notifications, in order from oldest to newest.
4043
4144 // Events
42- Main . messageTray . connect ( 'notify-applet-update' , Lang . bind ( this , this . _notification_added ) ) ;
43- this . panelEditModeHandler = global . settings . connect ( 'changed::' + PANEL_EDIT_MODE_KEY , Lang . bind ( this , this . _on_panel_edit_mode_changed ) ) ;
45+ this . signals = new SignalManager . SignalManager ( null ) ;
46+ this . signals . connect ( Main . messageTray , 'notify-applet-update' , this . _notification_added . bind ( this ) ) ;
47+ this . signals . connect ( global . settings , 'changed::' + PANEL_EDIT_MODE_KEY , this . _on_panel_edit_mode_changed . bind ( this ) ) ;
4448
4549 // States
4650 this . _blinking = false ;
4751 this . _blink_toggle = false ;
52+
53+ this . _display ( ) ;
4854 }
4955
5056 _setKeybinding ( ) {
@@ -55,12 +61,16 @@ class CinnamonNotificationsApplet extends Applet.TextIconApplet {
5561 on_applet_removed_from_panel ( ) {
5662 Main . keybindingManager . removeXletHotKey ( this , "notification-open" ) ;
5763 Main . keybindingManager . removeXletHotKey ( this , "notification-clear" ) ;
58- global . settings . disconnect ( this . panelEditModeHandler ) ;
59-
64+
6065 MessageTray . extensionsHandlingNotifications -- ;
6166 if ( MessageTray . extensionsHandlingNotifications === 0 ) {
6267 this . _clear_all ( ) ;
6368 }
69+
70+ this . signals . disconnectAllSignals ( ) ;
71+ this . settings . finalize ( ) ;
72+ this . _crit_icon . destroy ( ) ;
73+ this . _alt_crit_icon . destroy ( ) ;
6474 }
6575
6676 _openMenu ( ) {
@@ -76,7 +86,6 @@ class CinnamonNotificationsApplet extends Applet.TextIconApplet {
7686 // Setup the notification container.
7787 this . _maincontainer = new St . BoxLayout ( { name : 'traycontainer' , vertical : true } ) ;
7888 this . _notificationbin = new St . BoxLayout ( { vertical :true } ) ;
79- this . button_label_box = new St . BoxLayout ( ) ;
8089
8190 // Setup the tray icon.
8291 this . menu_label = new PopupMenu . PopupMenuItem ( stringify ( this . notifications . length ) ) ;
@@ -90,18 +99,11 @@ class CinnamonNotificationsApplet extends Applet.TextIconApplet {
9099 this . clear_action . connect ( 'activate' , Lang . bind ( this , this . _clear_all ) ) ;
91100 this . clear_action . actor . hide ( ) ;
92101
93- if ( this . _orientation == St . Side . BOTTOM ) {
94- this . menu . addMenuItem ( this . menu_label ) ;
95- this . menu . addActor ( this . _maincontainer ) ;
96- this . menu . addMenuItem ( this . clear_separator ) ;
97- this . menu . addMenuItem ( this . clear_action ) ;
98- } else {
99- this . menu . addMenuItem ( this . clear_action ) ;
100- this . menu . addMenuItem ( this . clear_separator ) ;
101- this . menu . addMenuItem ( this . menu_label ) ;
102- this . menu . addActor ( this . _maincontainer ) ;
103- }
104-
102+ this . menu . addMenuItem ( this . clear_action ) ;
103+ this . menu . addMenuItem ( this . clear_separator ) ;
104+ this . menu . addMenuItem ( this . menu_label ) ;
105+ this . menu . addActor ( this . _maincontainer ) ;
106+
105107 this . scrollview = new St . ScrollView ( { x_fill : true , y_fill : true , y_align : St . Align . START , style_class : "vfade" } ) ;
106108 this . _maincontainer . add ( this . scrollview ) ;
107109 this . scrollview . add_actor ( this . _notificationbin ) ;
@@ -122,7 +124,26 @@ class CinnamonNotificationsApplet extends Applet.TextIconApplet {
122124
123125 this . _on_panel_edit_mode_changed ( ) ;
124126
125- this . menu . addSettingsAction ( _ ( "Notification Settings" ) , 'notifications' ) ;
127+ this . settingsMenuItem = this . menu . addSettingsAction ( _ ( "Notification Settings" ) , 'notifications' ) ;
128+ }
129+
130+ _arrangeDisplay ( ) {
131+ // Remove menu actors so we can put them back in a different order according to orientation.
132+ this . menu . box . remove_all_children ( ) ;
133+
134+ if ( this . _orientation == St . Side . BOTTOM ) {
135+ this . menu . addActor ( this . menu_label . actor ) ;
136+ this . menu . addActor ( this . _maincontainer ) ;
137+ this . menu . addActor ( this . clear_separator . actor ) ;
138+ this . menu . addActor ( this . clear_action . actor ) ;
139+ } else {
140+ this . menu . addActor ( this . clear_action . actor ) ;
141+ this . menu . addActor ( this . clear_separator . actor ) ;
142+ this . menu . addActor ( this . menu_label . actor ) ;
143+ this . menu . addActor ( this . _maincontainer ) ;
144+ }
145+
146+ this . menu . addActor ( this . settingsMenuItem . actor ) ;
126147 }
127148
128149 _notification_added ( mtray , notification ) { // Notification event handler.
@@ -278,12 +299,7 @@ class CinnamonNotificationsApplet extends Applet.TextIconApplet {
278299 on_orientation_changed ( orientation ) {
279300 this . _orientation = orientation ;
280301
281- if ( this . menu ) {
282- this . menu . destroy ( ) ;
283- }
284- this . menu = new Applet . AppletPopupMenu ( this , orientation ) ;
285- this . menuManager . addMenu ( this . menu ) ;
286- this . _display ( ) ;
302+ this . _arrangeDisplay ( ) ;
287303 }
288304
289305 on_applet_clicked ( event ) {
0 commit comments