This repository was archived by the owner on Mar 4, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +12
-14
lines changed
composite_template/example_application_window Expand file tree Collapse file tree 4 files changed +12
-14
lines changed Original file line number Diff line number Diff line change @@ -29,8 +29,8 @@ impl ApplicationImpl for SimpleApplication {
29
29
/// aksed to present itself.
30
30
fn activate ( & self , app : & Self :: Type ) {
31
31
let app = app. downcast_ref :: < super :: SimpleApplication > ( ) . unwrap ( ) ;
32
- let priv_ = SimpleApplication :: from_instance ( app) ;
33
- let window = priv_
32
+ let imp = app. imp ( ) ;
33
+ let window = imp
34
34
. window
35
35
. get ( )
36
36
. expect ( "Should always be initiliazed in gio_application_startup" ) ;
@@ -49,10 +49,9 @@ impl ApplicationImpl for SimpleApplication {
49
49
self . parent_startup ( app) ;
50
50
51
51
let app = app. downcast_ref :: < super :: SimpleApplication > ( ) . unwrap ( ) ;
52
- let priv_ = SimpleApplication :: from_instance ( app) ;
52
+ let imp = app. imp ( ) ;
53
53
let window = SimpleWindow :: new ( app) ;
54
- priv_
55
- . window
54
+ imp. window
56
55
. set ( window)
57
56
. expect ( "Failed to initialize application window" ) ;
58
57
}
Original file line number Diff line number Diff line change @@ -41,8 +41,8 @@ impl ObjectImpl for SimpleWindow {
41
41
// Connect our method `on_increment_clicked` to be called
42
42
// when the increment button is clicked.
43
43
increment. connect_clicked ( clone ! ( @weak obj => move |_| {
44
- let priv_ = SimpleWindow :: from_instance ( & obj) ;
45
- priv_ . on_increment_clicked( ) ;
44
+ let imp = obj. imp ( ) ;
45
+ imp . on_increment_clicked( ) ;
46
46
} ) ) ;
47
47
48
48
obj. add ( & label) ;
Original file line number Diff line number Diff line change @@ -18,9 +18,8 @@ impl ExampleApplicationWindow {
18
18
fn init_label ( & self ) {
19
19
// To access fields such as template children, you must get
20
20
// the private struct.
21
- let self_ = imp:: ExampleApplicationWindow :: from_instance ( self ) ;
22
- self_
23
- . subtitle
21
+ let imp = self . imp ( ) ;
22
+ imp. subtitle
24
23
. set_text ( "This is an example window made using composite templates" ) ;
25
24
}
26
25
}
Original file line number Diff line number Diff line change @@ -19,12 +19,12 @@ impl Model {
19
19
}
20
20
21
21
pub fn append ( & self , obj : & RowData ) {
22
- let self_ = imp:: Model :: from_instance ( self ) ;
22
+ let imp = self . imp ( ) ;
23
23
let index = {
24
24
// Borrow the data only once and ensure the borrow guard is dropped
25
25
// before we emit the items_changed signal because the view
26
26
// could call get_item / get_n_item from the signal handler to update its state
27
- let mut data = self_ . 0 . borrow_mut ( ) ;
27
+ let mut data = imp . 0 . borrow_mut ( ) ;
28
28
data. push ( obj. clone ( ) ) ;
29
29
data. len ( ) - 1
30
30
} ;
@@ -33,8 +33,8 @@ impl Model {
33
33
}
34
34
35
35
pub fn remove ( & self , index : u32 ) {
36
- let self_ = imp:: Model :: from_instance ( self ) ;
37
- self_ . 0 . borrow_mut ( ) . remove ( index as usize ) ;
36
+ let imp = self . imp ( ) ;
37
+ imp . 0 . borrow_mut ( ) . remove ( index as usize ) ;
38
38
// Emits a signal that 1 item was removed, 0 added at the position index
39
39
self . items_changed ( index, 1 , 0 ) ;
40
40
}
You can’t perform that action at this time.
0 commit comments