@@ -122,7 +122,7 @@ pub mod imp {
122122 fn set_zoom ( & self , v : f64 ) {
123123 let Zoom { value, provider } = & mut * self . zoom . borrow_mut ( ) ;
124124 * value = v. clamp ( 1.0 / ZOOM_MAX_FACTOR , ZOOM_MAX_FACTOR ) ;
125- provider. load_from_data ( & format ! (
125+ provider. load_from_string ( & format ! (
126126 "textview {{
127127 font-size: {}rem;
128128 }}" ,
@@ -232,26 +232,26 @@ impl Window {
232232
233233 let act_open_page = gio:: SimpleAction :: new ( "open-omni" , Some ( glib:: VariantTy :: STRING ) ) ;
234234 act_open_page. connect_activate (
235- clone ! ( @ weak self as this => move |_, v| this. open_omni( v. unwrap( ) . get:: <String >( ) . unwrap( ) . as_str( ) ) ) ,
235+ clone ! ( # [ weak( rename_to = this) ] self , move |_, v| this. open_omni( v. unwrap( ) . get:: <String >( ) . unwrap( ) . as_str( ) ) ) ,
236236 ) ;
237237 self . add_action ( & act_open_page) ;
238238
239239 let act_open_url = gio:: SimpleAction :: new ( "open-url" , Some ( glib:: VariantTy :: STRING ) ) ;
240240 act_open_url. connect_activate (
241- clone ! ( @ weak self as this => move |_, v| this. open_url_str( v. unwrap( ) . get:: <String >( ) . unwrap( ) . as_str( ) ) ) ,
241+ clone ! ( # [ weak( rename_to = this) ] self , move |_, v| this. open_url_str( v. unwrap( ) . get:: <String >( ) . unwrap( ) . as_str( ) ) ) ,
242242 ) ;
243243 self . add_action ( & act_open_url) ;
244244
245245 let act_open_in_new_tab =
246246 gio:: SimpleAction :: new ( "open-in-new-tab" , Some ( glib:: VariantTy :: STRING ) ) ;
247247 act_open_in_new_tab. connect_activate (
248- clone ! ( @ weak self as this => move |_, v| this. open_in_new_tab( v. unwrap( ) . get:: <String >( ) . unwrap( ) . as_str( ) ) ) ,
248+ clone ! ( # [ weak( rename_to = this) ] self , move |_, v| this. open_in_new_tab( v. unwrap( ) . get:: <String >( ) . unwrap( ) . as_str( ) ) ) ,
249249 ) ;
250250 self . add_action ( & act_open_in_new_tab) ;
251251
252252 let act_set_clipboard =
253253 gio:: SimpleAction :: new ( "set-clipboard" , Some ( glib:: VariantTy :: STRING ) ) ;
254- act_set_clipboard. connect_activate ( clone ! ( @ weak self as this => move |_, v| {
254+ act_set_clipboard. connect_activate ( clone ! ( # [ weak( rename_to = this) ] self , move |_, v| {
255255 this. set_clipboard( v. unwrap( ) . get:: <String >( ) . unwrap( ) . as_str( ) ) ;
256256 this. imp( ) . toast_overlay. add_toast( adw:: Toast :: new( "Copied to clipboard" ) ) ;
257257 } ) ) ;
@@ -267,7 +267,8 @@ impl Window {
267267 imp. scroll_ctrl
268268 . set_flags ( gtk:: EventControllerScrollFlags :: VERTICAL ) ;
269269 imp. scroll_ctrl . connect_scroll (
270- clone ! ( @weak self as this => @default -panic, move |ctrl, _, y| {
270+ clone ! ( #[ weak( rename_to = this) ] self , #[ upgrade_or_panic]
271+ move |ctrl, _, y| {
271272 let up = y < 0.0 ;
272273 if let Some ( gdk:: ModifierType :: CONTROL_MASK ) = ctrl. current_event( ) . map( |e| e. modifier_state( ) ) {
273274 if up {
@@ -283,7 +284,7 @@ impl Window {
283284 ) ;
284285 imp. mouse_prev_next_ctrl . set_button ( 0 ) ;
285286 imp. mouse_prev_next_ctrl . connect_pressed (
286- clone ! ( @ weak self as this => @ default -panic , move |ctrl, _, _, _| {
287+ clone ! ( # [ weak( rename_to = this) ] self , move |ctrl, _, _, _| {
287288 match ctrl. current_button( ) {
288289 8 => {
289290 this. previous( ) ;
@@ -299,7 +300,8 @@ impl Window {
299300 self . connect_local (
300301 "notify::url" ,
301302 false ,
302- clone ! ( @weak self as this => @default -panic, move |_| {
303+ clone ! ( #[ weak( rename_to = this) ] self , #[ upgrade_or_default]
304+ move |_| {
303305 this. update_domain_color( ) ;
304306
305307 let bar = & this. imp( ) . url_bar;
@@ -313,12 +315,14 @@ impl Window {
313315 ) ;
314316
315317 imp. tab_view . connect_selected_page_notify (
316- clone ! ( @ weak self as this => @ default -panic , move |tab_view| {
318+ clone ! ( # [ weak( rename_to = this) ] self , move |tab_view| {
317319 this. page_switched( tab_view) ;
318320 } ) ,
319321 ) ;
320322 imp. tab_view . connect_close_page (
321- clone ! ( @weak self as this => @default -panic, move |tab_view, page| {
323+ clone ! ( #[ weak( rename_to = this) ] self ,
324+ #[ upgrade_or_panic]
325+ move |tab_view, page| {
322326 tab_view. close_page_finish( page, !page. is_pinned( ) ) ;
323327
324328 if tab_view. n_pages( ) == 0 {
@@ -329,19 +333,21 @@ impl Window {
329333 } ) ,
330334 ) ;
331335 imp. tab_overview . connect_create_tab (
332- clone ! ( @weak self as this => @default -panic, move |_| {
336+ clone ! ( #[ weak( rename_to = this) ] self ,
337+ #[ upgrade_or_panic]
338+ move |_| {
333339 this. new_tab( ) ;
334340 this. imp( ) . tab_view. selected_page( ) . unwrap( )
335341 } ) ,
336342 ) ;
337343
338344 imp. url_bar
339- . connect_activate ( clone ! ( @ weak self as this => @ default -panic , move |_sq| {
345+ . connect_activate ( clone ! ( # [ weak( rename_to = this) ] self , move |_sq| {
340346 this. open_omni( this. imp( ) . url_bar. text( ) . as_str( ) ) ;
341347 } ) ) ;
342348
343349 adw:: StyleManager :: default ( ) . connect_dark_notify (
344- clone ! ( @ weak self as this => @ default -panic , move |_| {
350+ clone ! ( # [ weak( rename_to = this) ] self , move |_| {
345351 this. update_domain_color( )
346352 } ) ,
347353 ) ;
@@ -358,7 +364,8 @@ impl Window {
358364 ctrl. set_propagation_phase ( gtk:: PropagationPhase :: Capture ) ;
359365
360366 ctrl. connect_key_pressed (
361- clone ! ( @weak self as this => @default -panic, move |_, key, _, modif| {
367+ clone ! ( #[ weak( rename_to = this) ] self , #[ upgrade_or_panic]
368+ move |_, key, _, modif| {
362369 let action = match ( modif. contains( gdk:: ModifierType :: CONTROL_MASK ) , key) {
363370 ( true , gdk:: Key :: ISO_Left_Tab ) => Some ( "win.focus-previous-tab" ) ,
364371 ( true , gdk:: Key :: Tab ) => Some ( "win.focus-next-tab" ) ,
@@ -380,7 +387,8 @@ impl Window {
380387 . build ( ) ;
381388
382389 drop_target. connect_drop (
383- clone ! ( @weak self as this => @default -return false , move |_, value, _, _| {
390+ clone ! ( #[ weak( rename_to = this) ] self , #[ upgrade_or_panic]
391+ move |_, value, _, _| {
384392 if let Ok ( files) = value. get:: <gdk:: FileList >( ) {
385393 for f in files. files( ) {
386394 this. open_in_new_tab( & format!( "file://{}" , f. path( ) . unwrap( ) . to_str( ) . unwrap( ) ) ) ;
@@ -626,7 +634,7 @@ impl Window {
626634 let imp = self . imp ( ) ;
627635 let url = imp. url_bar . text ( ) . to_string ( ) ;
628636
629- glibctx ( ) . spawn_local ( clone ! ( @ weak imp => async move {
637+ glibctx ( ) . spawn_local ( clone ! ( # [ weak] imp, async move {
630638 match Self :: append_bookmark( & url) . await {
631639 Ok ( _) => {
632640 info!( "{} saved to bookmarks" , url) ;
0 commit comments