@@ -122,7 +122,7 @@ pub mod imp {
122
122
fn set_zoom ( & self , v : f64 ) {
123
123
let Zoom { value, provider } = & mut * self . zoom . borrow_mut ( ) ;
124
124
* value = v. clamp ( 1.0 / ZOOM_MAX_FACTOR , ZOOM_MAX_FACTOR ) ;
125
- provider. load_from_data ( & format ! (
125
+ provider. load_from_string ( & format ! (
126
126
"textview {{
127
127
font-size: {}rem;
128
128
}}" ,
@@ -232,26 +232,26 @@ impl Window {
232
232
233
233
let act_open_page = gio:: SimpleAction :: new ( "open-omni" , Some ( glib:: VariantTy :: STRING ) ) ;
234
234
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( ) ) ) ,
236
236
) ;
237
237
self . add_action ( & act_open_page) ;
238
238
239
239
let act_open_url = gio:: SimpleAction :: new ( "open-url" , Some ( glib:: VariantTy :: STRING ) ) ;
240
240
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( ) ) ) ,
242
242
) ;
243
243
self . add_action ( & act_open_url) ;
244
244
245
245
let act_open_in_new_tab =
246
246
gio:: SimpleAction :: new ( "open-in-new-tab" , Some ( glib:: VariantTy :: STRING ) ) ;
247
247
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( ) ) ) ,
249
249
) ;
250
250
self . add_action ( & act_open_in_new_tab) ;
251
251
252
252
let act_set_clipboard =
253
253
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| {
255
255
this. set_clipboard( v. unwrap( ) . get:: <String >( ) . unwrap( ) . as_str( ) ) ;
256
256
this. imp( ) . toast_overlay. add_toast( adw:: Toast :: new( "Copied to clipboard" ) ) ;
257
257
} ) ) ;
@@ -267,7 +267,8 @@ impl Window {
267
267
imp. scroll_ctrl
268
268
. set_flags ( gtk:: EventControllerScrollFlags :: VERTICAL ) ;
269
269
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| {
271
272
let up = y < 0.0 ;
272
273
if let Some ( gdk:: ModifierType :: CONTROL_MASK ) = ctrl. current_event( ) . map( |e| e. modifier_state( ) ) {
273
274
if up {
@@ -283,7 +284,7 @@ impl Window {
283
284
) ;
284
285
imp. mouse_prev_next_ctrl . set_button ( 0 ) ;
285
286
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, _, _, _| {
287
288
match ctrl. current_button( ) {
288
289
8 => {
289
290
this. previous( ) ;
@@ -299,7 +300,8 @@ impl Window {
299
300
self . connect_local (
300
301
"notify::url" ,
301
302
false ,
302
- clone ! ( @weak self as this => @default -panic, move |_| {
303
+ clone ! ( #[ weak( rename_to = this) ] self , #[ upgrade_or_default]
304
+ move |_| {
303
305
this. update_domain_color( ) ;
304
306
305
307
let bar = & this. imp( ) . url_bar;
@@ -313,12 +315,14 @@ impl Window {
313
315
) ;
314
316
315
317
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| {
317
319
this. page_switched( tab_view) ;
318
320
} ) ,
319
321
) ;
320
322
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| {
322
326
tab_view. close_page_finish( page, !page. is_pinned( ) ) ;
323
327
324
328
if tab_view. n_pages( ) == 0 {
@@ -329,19 +333,21 @@ impl Window {
329
333
} ) ,
330
334
) ;
331
335
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 |_| {
333
339
this. new_tab( ) ;
334
340
this. imp( ) . tab_view. selected_page( ) . unwrap( )
335
341
} ) ,
336
342
) ;
337
343
338
344
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| {
340
346
this. open_omni( this. imp( ) . url_bar. text( ) . as_str( ) ) ;
341
347
} ) ) ;
342
348
343
349
adw:: StyleManager :: default ( ) . connect_dark_notify (
344
- clone ! ( @ weak self as this => @ default -panic , move |_| {
350
+ clone ! ( # [ weak( rename_to = this) ] self , move |_| {
345
351
this. update_domain_color( )
346
352
} ) ,
347
353
) ;
@@ -358,7 +364,8 @@ impl Window {
358
364
ctrl. set_propagation_phase ( gtk:: PropagationPhase :: Capture ) ;
359
365
360
366
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| {
362
369
let action = match ( modif. contains( gdk:: ModifierType :: CONTROL_MASK ) , key) {
363
370
( true , gdk:: Key :: ISO_Left_Tab ) => Some ( "win.focus-previous-tab" ) ,
364
371
( true , gdk:: Key :: Tab ) => Some ( "win.focus-next-tab" ) ,
@@ -380,7 +387,8 @@ impl Window {
380
387
. build ( ) ;
381
388
382
389
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, _, _| {
384
392
if let Ok ( files) = value. get:: <gdk:: FileList >( ) {
385
393
for f in files. files( ) {
386
394
this. open_in_new_tab( & format!( "file://{}" , f. path( ) . unwrap( ) . to_str( ) . unwrap( ) ) ) ;
@@ -626,7 +634,7 @@ impl Window {
626
634
let imp = self . imp ( ) ;
627
635
let url = imp. url_bar . text ( ) . to_string ( ) ;
628
636
629
- glibctx ( ) . spawn_local ( clone ! ( @ weak imp => async move {
637
+ glibctx ( ) . spawn_local ( clone ! ( # [ weak] imp, async move {
630
638
match Self :: append_bookmark( & url) . await {
631
639
Ok ( _) => {
632
640
info!( "{} saved to bookmarks" , url) ;
0 commit comments