@@ -32,17 +32,22 @@ class CinnamonNotificationsApplet extends Applet.TextIconApplet {
32
32
// Layout
33
33
this . _orientation = orientation ;
34
34
this . menuManager = new PopupMenu . PopupMenuManager ( this ) ;
35
+ this . menu = new Applet . AppletPopupMenu ( this , orientation ) ;
36
+ this . menuManager . addMenu ( this . menu ) ;
35
37
36
38
// Lists
37
39
this . notifications = [ ] ; // The list of notifications, in order from oldest to newest.
38
40
39
41
// Events
40
42
Main . messageTray . connect ( 'notify-applet-update' , Lang . bind ( this , this . _notification_added ) ) ;
41
43
global . settings . connect ( 'changed::' + PANEL_EDIT_MODE_KEY , Lang . bind ( this , this . _on_panel_edit_mode_changed ) ) ;
44
+ this . menu . connect ( 'menu-animated-closed' , this . _onMenuClosed . bind ( this ) ) ;
42
45
43
46
// States
44
47
this . _blinking = false ;
45
48
this . _blink_toggle = false ;
49
+
50
+ this . _display ( ) ;
46
51
}
47
52
48
53
_setKeybinding ( ) {
@@ -58,14 +63,17 @@ class CinnamonNotificationsApplet extends Applet.TextIconApplet {
58
63
_openMenu ( ) {
59
64
this . _update_timestamp ( ) ;
60
65
61
- this . _notificationbin . remove_all_children ( ) ;
62
66
this . notifications . forEach ( notification => {
63
67
global . reparentActor ( notification . actor , this . _notificationbin ) ;
64
68
} ) ;
65
69
66
70
this . menu . toggle ( ) ;
67
71
}
68
72
73
+ _onMenuClosed ( ) {
74
+ this . _notificationbin . remove_all_children ( ) ;
75
+ }
76
+
69
77
_display ( ) {
70
78
// Always start the applet empty, void of any notifications.
71
79
this . set_applet_icon_symbolic_name ( "empty-notif" ) ;
@@ -88,18 +96,11 @@ class CinnamonNotificationsApplet extends Applet.TextIconApplet {
88
96
this . clear_action . connect ( 'activate' , Lang . bind ( this , this . _clear_all ) ) ;
89
97
this . clear_action . actor . hide ( ) ;
90
98
91
- if ( this . _orientation == St . Side . BOTTOM ) {
92
- this . menu . addMenuItem ( this . menu_label ) ;
93
- this . menu . addActor ( this . _maincontainer ) ;
94
- this . menu . addMenuItem ( this . clear_separator ) ;
95
- this . menu . addMenuItem ( this . clear_action ) ;
96
- } else {
97
- this . menu . addMenuItem ( this . clear_action ) ;
98
- this . menu . addMenuItem ( this . clear_separator ) ;
99
- this . menu . addMenuItem ( this . menu_label ) ;
100
- this . menu . addActor ( this . _maincontainer ) ;
101
- }
102
-
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
+
103
104
this . scrollview = new St . ScrollView ( { x_fill : true , y_fill : true , y_align : St . Align . START , style_class : "vfade" } ) ;
104
105
this . _maincontainer . add ( this . scrollview ) ;
105
106
this . scrollview . add_actor ( this . _notificationbin ) ;
@@ -120,7 +121,27 @@ class CinnamonNotificationsApplet extends Applet.TextIconApplet {
120
121
121
122
this . _on_panel_edit_mode_changed ( ) ;
122
123
123
- this . menu . addSettingsAction ( _ ( "Notification Settings" ) , 'notifications' ) ;
124
+ this . settingsMenuItem = this . menu . addSettingsAction ( _ ( "Notification Settings" ) , 'notifications' ) ;
125
+ }
126
+
127
+ _arrangeDisplay ( ) {
128
+ // Remove menu actors so we can put tham back in a different order according
129
+ // to orientation
130
+ this . menu . box . remove_all_children ( ) ;
131
+
132
+ if ( this . _orientation == St . Side . BOTTOM ) {
133
+ this . menu . box . add ( this . menu_label . actor ) ;
134
+ this . menu . addActor ( this . _maincontainer ) ;
135
+ this . menu . box . add ( this . clear_separator . actor ) ;
136
+ this . menu . box . add ( this . clear_action . actor ) ;
137
+ } else {
138
+ this . menu . box . add ( this . clear_action . actor ) ;
139
+ this . menu . box . add ( this . clear_separator . actor ) ;
140
+ this . menu . box . add ( this . menu_label . actor ) ;
141
+ this . menu . addActor ( this . _maincontainer ) ;
142
+ }
143
+
144
+ this . menu . box . add ( this . settingsMenuItem . actor ) ;
124
145
}
125
146
126
147
_notification_added ( mtray , notification ) { // Notification event handler.
@@ -250,12 +271,7 @@ class CinnamonNotificationsApplet extends Applet.TextIconApplet {
250
271
on_orientation_changed ( orientation ) {
251
272
this . _orientation = orientation ;
252
273
253
- if ( this . menu ) {
254
- this . menu . destroy ( ) ;
255
- }
256
- this . menu = new Applet . AppletPopupMenu ( this , orientation ) ;
257
- this . menuManager . addMenu ( this . menu ) ;
258
- this . _display ( ) ;
274
+ this . _arrangeDisplay ( ) ;
259
275
}
260
276
261
277
on_applet_clicked ( event ) {
0 commit comments