@@ -16,6 +16,7 @@ use tokio::io::AsyncWrite;
16
16
struct Item {
17
17
appid : String ,
18
18
description : String ,
19
+ actions : Vec < Action > ,
19
20
exec : String ,
20
21
icon : Option < String > ,
21
22
keywords : Option < Vec < String > > ,
@@ -25,6 +26,13 @@ struct Item {
25
26
src : PathSource ,
26
27
}
27
28
29
+ #[ derive( Debug , PartialEq , Eq ) ]
30
+ pub struct Action {
31
+ pub name : String ,
32
+ pub description : String ,
33
+ pub exec : String ,
34
+ }
35
+
28
36
impl Hash for Item {
29
37
fn hash < H : Hasher > ( & self , state : & mut H ) {
30
38
self . appid . hash ( state) ;
@@ -150,6 +158,25 @@ impl<W: AsyncWrite + Unpin> App<W> {
150
158
continue ;
151
159
}
152
160
161
+ let mut actions = vec ! [ ] ;
162
+
163
+ if let Some ( entries) = entry. actions ( ) {
164
+ for action in entries. split ( ';' ) {
165
+ let action =
166
+ entry. action_name ( action, locale) . and_then ( |name| {
167
+ entry. action_exec ( action) . map ( |exec| Action {
168
+ name : action. to_string ( ) ,
169
+ description : name. to_string ( ) ,
170
+ exec : exec. to_string ( ) ,
171
+ } )
172
+ } ) ;
173
+
174
+ if let Some ( action) = action {
175
+ actions. push ( action) ;
176
+ }
177
+ }
178
+ }
179
+
153
180
let item = Item {
154
181
appid : entry. appid . to_owned ( ) ,
155
182
name : name. to_string ( ) ,
@@ -166,6 +193,7 @@ impl<W: AsyncWrite + Unpin> App<W> {
166
193
path : path. clone ( ) ,
167
194
prefers_non_default_gpu : entry. prefers_non_default_gpu ( ) ,
168
195
src,
196
+ actions,
169
197
} ;
170
198
171
199
deduplicator. insert ( item) ;
@@ -219,14 +247,30 @@ impl<W: AsyncWrite + Unpin> App<W> {
219
247
options. push ( ContextOption {
220
248
id : 0 ,
221
249
name : ( if entry. prefers_non_default_gpu {
250
+ "Integrated Graphics"
251
+ } else {
252
+ "Discrete Graphics"
253
+ } )
254
+ . to_owned ( ) ,
255
+ description : ( if entry. prefers_non_default_gpu {
222
256
"Launch Using Integrated Graphics Card"
223
257
} else {
224
258
"Launch Using Discrete Graphics Card"
225
259
} )
226
260
. to_owned ( ) ,
261
+ exec : None ,
227
262
} ) ;
228
263
}
229
264
265
+ for ( idx, action) in entry. actions . iter ( ) . enumerate ( ) {
266
+ options. push ( ContextOption {
267
+ id : idx as u32 ,
268
+ name : action. name . to_owned ( ) ,
269
+ description : action. description . to_owned ( ) ,
270
+ exec : Some ( action. exec . to_string ( ) ) ,
271
+ } )
272
+ }
273
+
230
274
if !options. is_empty ( ) {
231
275
let response = PluginResponse :: Context { id, options } ;
232
276
0 commit comments