@@ -79,6 +79,13 @@ glib::wrapper! {
79
79
@implements gio:: ActionGroup , gio:: ActionMap ;
80
80
}
81
81
82
+ fn load_string ( path : & str ) -> String {
83
+ let Ok ( data) = gio:: resources_lookup_data ( path, gio:: ResourceLookupFlags :: empty ( ) ) else {
84
+ return format ! ( "{path} not found" ) ;
85
+ } ;
86
+ String :: from_utf8 ( data. to_vec ( ) ) . unwrap_or_else ( |e| format ! ( "{path} is invalid utf8 {e}" ) )
87
+ }
88
+
82
89
impl ShutterApplication {
83
90
pub fn new ( application_id : & str , flags : & gio:: ApplicationFlags ) -> Self {
84
91
glib:: Object :: builder ( )
@@ -109,42 +116,18 @@ impl ShutterApplication {
109
116
. issue_url ( "https://github.com/shutter-project/shutter/issues" )
110
117
. license_type ( gtk:: License :: Gpl30 )
111
118
. artists (
112
- String :: from_utf8 (
113
- gio:: resources_lookup_data (
114
- "/org/shutter-project/Shutter/credits/art" ,
115
- gio:: ResourceLookupFlags :: empty ( ) ,
116
- )
117
- . expect ( "no artist data" )
118
- . to_vec ( ) ,
119
- )
120
- . expect ( "can't convert artists to utf8" )
121
- . lines ( )
122
- . collect :: < Vec < _ > > ( ) ,
119
+ load_string ( "/org/shutter-project/Shutter/credits/art" )
120
+ . lines ( )
121
+ . collect :: < Vec < _ > > ( ) ,
123
122
)
124
123
. developers (
125
- String :: from_utf8 (
126
- gio:: resources_lookup_data (
127
- "/org/shutter-project/Shutter/credits/dev" ,
128
- gio:: ResourceLookupFlags :: empty ( ) ,
129
- )
130
- . expect ( "no dev data" )
131
- . to_vec ( ) ,
132
- )
133
- . expect ( "can't convert devs to utf8" )
134
- . lines ( )
135
- . collect :: < Vec < _ > > ( ) ,
136
- )
137
- . copyright (
138
- String :: from_utf8 (
139
- gio:: resources_lookup_data (
140
- "/org/shutter-project/Shutter/credits/copyright" ,
141
- gio:: ResourceLookupFlags :: empty ( ) ,
142
- )
143
- . expect ( "no copyright data" )
144
- . to_vec ( ) ,
145
- )
146
- . expect ( "can't convert copyright to utf8" ) ,
124
+ load_string ( "/org/shutter-project/Shutter/credits/dev" )
125
+ . lines ( )
126
+ . collect :: < Vec < _ > > ( ) ,
147
127
)
128
+ . copyright ( load_string (
129
+ "/org/shutter-project/Shutter/credits/copyright" ,
130
+ ) )
148
131
. build ( ) ;
149
132
150
133
about. present ( Some ( & window) ) ;
0 commit comments