This repository was archived by the owner on Jun 8, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +32
-2
lines changed Expand file tree Collapse file tree 3 files changed +32
-2
lines changed Original file line number Diff line number Diff line change 5
5
use ffi;
6
6
use gobject_ffi;
7
7
8
+ use std:: borrow:: Borrow ;
8
9
use std:: marker;
9
10
use std:: mem;
10
11
use std:: ptr;
@@ -119,12 +120,13 @@ pub trait ObjectInterfaceExt: ObjectInterface {
119
120
/// Install properties on the interface.
120
121
///
121
122
/// All implementors of the interface must provide these properties.
122
- fn install_properties ( & mut self , properties : & [ Property ] ) {
123
+ fn install_properties < ' a , T : Borrow < Property < ' a > > > ( & mut self , properties : & [ T ] ) {
123
124
if properties. is_empty ( ) {
124
125
return ;
125
126
}
126
127
127
128
for property in properties {
129
+ let property = property. borrow ( ) ;
128
130
let pspec = ( property. 1 ) ( property. 0 ) ;
129
131
unsafe {
130
132
gobject_ffi:: g_object_interface_install_property (
Original file line number Diff line number Diff line change 8
8
use ffi;
9
9
use gobject_ffi;
10
10
11
+ use std:: borrow:: Borrow ;
12
+ use std:: fmt;
11
13
use std:: mem;
12
14
use std:: ptr;
13
15
@@ -133,8 +135,15 @@ unsafe extern "C" fn constructed<T: ObjectSubclass>(obj: *mut gobject_ffi::GObje
133
135
}
134
136
135
137
/// Definition of a property.
138
+ #[ derive( Clone ) ]
136
139
pub struct Property < ' a > ( pub & ' a str , pub fn ( & str ) -> :: ParamSpec ) ;
137
140
141
+ impl < ' a > fmt:: Debug for Property < ' a > {
142
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> Result < ( ) , fmt:: Error > {
143
+ f. debug_tuple ( "Property" ) . field ( & self . 0 ) . finish ( )
144
+ }
145
+ }
146
+
138
147
/// Extension trait for `glib::Object`'s class struct.
139
148
///
140
149
/// This contains various class methods and allows subclasses to override the virtual methods.
@@ -143,14 +152,15 @@ pub unsafe trait ObjectClassSubclassExt: Sized + 'static {
143
152
///
144
153
/// The index in the properties array is going to be the index passed to the
145
154
/// property setters and getters.
146
- fn install_properties ( & mut self , properties : & [ Property ] ) {
155
+ fn install_properties < ' a , T : Borrow < Property < ' a > > > ( & mut self , properties : & [ T ] ) {
147
156
if properties. is_empty ( ) {
148
157
return ;
149
158
}
150
159
151
160
let mut pspecs = Vec :: with_capacity ( properties. len ( ) ) ;
152
161
153
162
for property in properties {
163
+ let property = property. borrow ( ) ;
154
164
let pspec = ( property. 1 ) ( property. 0 ) ;
155
165
pspecs. push ( pspec) ;
156
166
}
Original file line number Diff line number Diff line change 7
7
use ffi;
8
8
use gobject_ffi;
9
9
10
+ use std:: fmt;
10
11
use std:: marker;
11
12
use std:: mem;
12
13
use std:: ptr;
@@ -535,6 +536,15 @@ impl SignalInvocationHint {
535
536
}
536
537
}
537
538
539
+ impl fmt:: Debug for SignalInvocationHint {
540
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> Result < ( ) , fmt:: Error > {
541
+ f. debug_struct ( "SignalInvocationHint" )
542
+ . field ( "detail" , & self . detail ( ) )
543
+ . field ( "run_type" , & self . run_type ( ) )
544
+ . finish ( )
545
+ }
546
+ }
547
+
538
548
pub ( crate ) unsafe fn add_signal_with_accumulator < F > (
539
549
type_ : ffi:: GType ,
540
550
name : & str ,
@@ -582,6 +592,14 @@ pub(crate) unsafe fn add_signal_with_accumulator<F>(
582
592
583
593
pub struct SignalClassHandlerToken ( * mut gobject_ffi:: GTypeInstance ) ;
584
594
595
+ impl fmt:: Debug for SignalClassHandlerToken {
596
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> Result < ( ) , fmt:: Error > {
597
+ f. debug_tuple ( "SignalClassHandlerToken" )
598
+ . field ( & unsafe { :: Object :: from_glib_borrow ( self . 0 as * mut gobject_ffi:: GObject ) } )
599
+ . finish ( )
600
+ }
601
+ }
602
+
585
603
pub ( crate ) unsafe fn add_signal_with_class_handler < F > (
586
604
type_ : ffi:: GType ,
587
605
name : & str ,
You can’t perform that action at this time.
0 commit comments