@@ -15,6 +15,7 @@ use crate::gui::types::message::Message;
1515use crate :: gui:: types:: settings:: Settings ;
1616use crate :: translations:: translations:: { quit_analysis_translation, settings_translation} ;
1717use crate :: translations:: translations_3:: thumbnail_mode_translation;
18+ use crate :: translations:: translations_4:: { pause_translation, resume_translation} ;
1819use crate :: utils:: types:: icon:: Icon ;
1920use crate :: { Language , SNIFFNET_TITLECASE , StyleType } ;
2021
@@ -37,6 +38,7 @@ pub fn header(sniffer: &Sniffer) -> Container<'_, Message, StyleType> {
3738 language,
3839 color_gradient,
3940 unread_notifications,
41+ sniffer. frozen ,
4042 ) ;
4143 }
4244
@@ -60,10 +62,15 @@ pub fn header(sniffer: &Sniffer) -> Container<'_, Message, StyleType> {
6062 Container :: new ( Space :: with_width ( 60 ) )
6163 } )
6264 . push ( horizontal_space ( ) )
63- . push ( Container :: new ( Space :: with_width ( 40 ) ) )
65+ . push ( Container :: new ( Space :: with_width ( 80 ) ) )
6466 . push ( Space :: with_width ( 20 ) )
6567 . push ( logo)
6668 . push ( Space :: with_width ( 20 ) )
69+ . push ( if is_running {
70+ Container :: new ( get_button_freeze ( font, language, sniffer. frozen , false ) )
71+ } else {
72+ Container :: new ( Space :: with_width ( 40 ) )
73+ } )
6774 . push ( if is_running {
6875 Container :: new ( get_button_minimize ( font, language, false ) )
6976 } else {
@@ -161,9 +168,56 @@ pub fn get_button_minimize<'a>(
161168 . class ( ButtonType :: Thumbnail )
162169 . on_press ( Message :: ToggleThumbnail ( false ) ) ;
163170
164- Tooltip :: new ( content, Text :: new ( tooltip) . font ( font) , Position :: Right )
165- . gap ( 0 )
166- . class ( tooltip_style)
171+ Tooltip :: new (
172+ content,
173+ Text :: new ( tooltip) . font ( font) ,
174+ Position :: FollowCursor ,
175+ )
176+ . gap ( 0 )
177+ . class ( tooltip_style)
178+ }
179+
180+ pub fn get_button_freeze < ' a > (
181+ font : Font ,
182+ language : Language ,
183+ frozen : bool ,
184+ thumbnail : bool ,
185+ ) -> Tooltip < ' a , Message , StyleType > {
186+ let size = if thumbnail { 19 } else { 23 } ;
187+ let button_size = if thumbnail { 30 } else { 40 } ;
188+ let icon = if frozen { Icon :: Resume } else { Icon :: Pause } ;
189+ let tooltip = if thumbnail {
190+ ""
191+ } else if frozen {
192+ resume_translation ( language)
193+ } else {
194+ pause_translation ( language)
195+ } ;
196+ let tooltip_style = if thumbnail {
197+ ContainerType :: Standard
198+ } else {
199+ ContainerType :: Tooltip
200+ } ;
201+
202+ let content = button (
203+ icon. to_text ( )
204+ . size ( size)
205+ . align_x ( Alignment :: Center )
206+ . align_y ( Alignment :: Center ) ,
207+ )
208+ . padding ( 0 )
209+ . height ( button_size)
210+ . width ( button_size)
211+ . class ( ButtonType :: Thumbnail )
212+ . on_press ( Message :: Freeze ) ;
213+
214+ Tooltip :: new (
215+ content,
216+ Text :: new ( tooltip) . font ( font) ,
217+ Position :: FollowCursor ,
218+ )
219+ . gap ( 0 )
220+ . class ( tooltip_style)
167221}
168222
169223fn thumbnail_header < ' a > (
@@ -172,14 +226,16 @@ fn thumbnail_header<'a>(
172226 language : Language ,
173227 color_gradient : GradientType ,
174228 unread_notifications : usize ,
229+ frozen : bool ,
175230) -> Container < ' a , Message , StyleType > {
176231 Container :: new (
177232 Row :: new ( )
178233 . align_y ( Alignment :: Center )
179234 . push ( horizontal_space ( ) )
180- . push ( Space :: with_width ( 80 ) )
235+ . push ( Space :: with_width ( 110 ) )
181236 . push ( Text :: new ( SNIFFNET_TITLECASE ) . font ( font_headers) )
182237 . push ( Space :: with_width ( 10 ) )
238+ . push ( get_button_freeze ( font, language, frozen, true ) )
183239 . push ( get_button_minimize ( font, language, true ) )
184240 . push ( horizontal_space ( ) )
185241 . push ( if unread_notifications > 0 {
0 commit comments