@@ -26,6 +26,13 @@ struct Item {
26
26
src : PathSource ,
27
27
}
28
28
29
+ #[ derive( Debug , PartialEq , Eq ) ]
30
+ pub struct Action {
31
+ pub name : String ,
32
+ pub description : String ,
33
+ pub exec : String ,
34
+ }
35
+
29
36
impl Hash for Item {
30
37
fn hash < H : Hasher > ( & self , state : & mut H ) {
31
38
self . appid . hash ( state) ;
@@ -155,12 +162,14 @@ impl<W: AsyncWrite + Unpin> App<W> {
155
162
156
163
if let Some ( entries) = entry. actions ( ) {
157
164
for action in entries. split ( ';' ) {
158
- let action = entry. action_name ( action, locale)
159
- . and_then ( |name| entry. action_exec ( action) . map ( |exe | Action {
160
- name : action. to_string ( ) ,
161
- description : name. to_string ( ) ,
162
- exec : exec. to_string ( )
163
- } ) ) ;
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
+ } ) ;
164
173
165
174
if let Some ( action) = action {
166
175
actions. push ( action) ;
@@ -184,7 +193,7 @@ impl<W: AsyncWrite + Unpin> App<W> {
184
193
path : path. clone ( ) ,
185
194
prefers_non_default_gpu : entry. prefers_non_default_gpu ( ) ,
186
195
src,
187
- actions
196
+ actions,
188
197
} ;
189
198
190
199
deduplicator. insert ( item) ;
@@ -238,14 +247,30 @@ impl<W: AsyncWrite + Unpin> App<W> {
238
247
options. push ( ContextOption {
239
248
id : 0 ,
240
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 {
241
256
"Launch Using Integrated Graphics Card"
242
257
} else {
243
258
"Launch Using Discrete Graphics Card"
244
259
} )
245
260
. to_owned ( ) ,
261
+ exec : None ,
246
262
} ) ;
247
263
}
248
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
+
249
274
if !options. is_empty ( ) {
250
275
let response = PluginResponse :: Context { id, options } ;
251
276
0 commit comments