Package list cinnamon-menus / d63a35f libmenu / gmenu-desktopappinfo.c
d63a35f

Tree @d63a35f (Download .tar.gz)

gmenu-desktopappinfo.c @d63a35fraw · history · blame

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
/*
 * gmenu-desktopappinfo.c
 * Copyright (C) 2020 Lars Mueller <cobinja@yahoo.de>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110, USA.
 */

#include "gmenu-desktopappinfo.h"
#include <gio/gdesktopappinfo.h>

struct _GMenuDesktopAppInfo
{
  GObject parent_instance;
  
  GDesktopAppInfo *super_appinfo;
  gchar *desktop_id;
  gboolean is_flatpak;
  gchar *startup_wm_class;
  gchar *flatpak_app_id;
};

// This function sets desktop id and startup wm class and adds ":flatpak" for flatpak apps
static void
update_app_data (GMenuDesktopAppInfo *info)
{
  gchar *exec = NULL;
  gchar *id = NULL;
  gchar *startup_wm_class = NULL;

  g_free (info->desktop_id);
  info->desktop_id = NULL;

  g_free (info->startup_wm_class);
  info->startup_wm_class = NULL;

  g_free (info->flatpak_app_id);
  info->flatpak_app_id = NULL;

  if (info->super_appinfo != NULL)
  {
    exec = (gchar *) g_app_info_get_executable (G_APP_INFO (info->super_appinfo));
    id = (gchar *) g_app_info_get_id (G_APP_INFO (info->super_appinfo));
    startup_wm_class = (gchar *) g_desktop_app_info_get_startup_wm_class (info->super_appinfo);

    if (exec && (strstr (exec, "flatpak") || strstr (exec, "bwrap")))
    {
      info->desktop_id = g_strconcat (id, GMENU_DESKTOPAPPINFO_FLATPAK_SUFFIX, NULL);
      if (startup_wm_class)
      {
        info->startup_wm_class = g_strconcat (startup_wm_class, GMENU_DESKTOPAPPINFO_FLATPAK_SUFFIX, NULL);
      }

      // if (g_desktop_app_info_has_key (info->super_appinfo, "X-Flatpak"))
      // {
        info->flatpak_app_id = g_desktop_app_info_get_string (info->super_appinfo, "X-Flatpak");
      // }

      info->is_flatpak = TRUE;
    } else {
      info->desktop_id = g_strdup (id);
      info->is_flatpak = FALSE;
      info->startup_wm_class = g_strdup (startup_wm_class);
    }
  }
}

static GAppInfo *
gmenu_desktopappinfo_dup (GAppInfo *appinfo)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  GMenuDesktopAppInfo *new_info;

  new_info = g_object_new (GMENU_TYPE_DESKTOPAPPINFO, NULL);
  
  new_info->super_appinfo = G_DESKTOP_APP_INFO (g_app_info_dup(G_APP_INFO(info->super_appinfo)));
  
  update_app_data (new_info);
  
  return G_APP_INFO (new_info);
}

static gboolean
gmenu_desktopappinfo_equal (GAppInfo *appinfo1,
                              GAppInfo *appinfo2)
{
  GMenuDesktopAppInfo *info1 = GMENU_DESKTOPAPPINFO (appinfo1);
  GMenuDesktopAppInfo *info2 = GMENU_DESKTOPAPPINFO (appinfo2);

  if (info1->desktop_id == NULL ||
      info2->desktop_id == NULL)
    return info1 == info2;

  return strcmp (info1->desktop_id, info2->desktop_id) == 0;
}

static const char *
gmenu_desktopappinfo_get_id (GAppInfo *appinfo)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);

  return info->desktop_id;
}

static const char *
gmenu_desktopappinfo_get_name (GAppInfo *appinfo)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_app_info_get_name (G_APP_INFO(info->super_appinfo));
}

static const char *
gmenu_desktopappinfo_get_description (GAppInfo *appinfo)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_app_info_get_description (G_APP_INFO(info->super_appinfo));
}

static const char *
gmenu_desktopappinfo_get_executable (GAppInfo *appinfo)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_app_info_get_executable (G_APP_INFO(info->super_appinfo));
}

static GIcon *
gmenu_desktopappinfo_get_icon (GAppInfo *appinfo)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_app_info_get_icon (G_APP_INFO(info->super_appinfo));
}

static gboolean
gmenu_desktopappinfo_launch (GAppInfo *appinfo, GList *files, GAppLaunchContext *launch_context, GError **error)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_app_info_launch (G_APP_INFO(info->super_appinfo), files, launch_context, error);
}

static gboolean
gmenu_desktopappinfo_supports_uris (GAppInfo *appinfo)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_app_info_supports_uris (G_APP_INFO(info->super_appinfo));
}

static gboolean
gmenu_desktopappinfo_supports_files (GAppInfo *appinfo)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_app_info_supports_files (G_APP_INFO(info->super_appinfo));
}

static gboolean
gmenu_desktopappinfo_launch_uris (GAppInfo           *appinfo,
                                GList              *uris,
                                GAppLaunchContext  *launch_context,
                                GError            **error)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_app_info_launch_uris (G_APP_INFO(info->super_appinfo), uris, launch_context, error);
}

static gboolean
gmenu_desktopappinfo_should_show (GAppInfo *appinfo)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_app_info_should_show (G_APP_INFO(info->super_appinfo));
}

static gboolean
gmenu_desktopappinfo_set_as_default_for_type (GAppInfo    *appinfo,
                                                const char  *content_type,
                                                GError     **error)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_app_info_set_as_default_for_type (G_APP_INFO(info->super_appinfo), content_type, error);
}

static gboolean
gmenu_desktopappinfo_set_as_default_for_extension (GAppInfo    *appinfo,
                                                 const char  *extension,
                                                 GError     **error)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_app_info_set_as_default_for_extension (G_APP_INFO(info->super_appinfo), extension, error);
}

static gboolean
gmenu_desktopappinfo_add_supports_type (GAppInfo    *appinfo,
                                      const char  *content_type,
                                      GError     **error)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_app_info_add_supports_type (G_APP_INFO(info->super_appinfo), content_type, error);
}

static gboolean
gmenu_desktopappinfo_can_remove_supports_type (GAppInfo *appinfo)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_app_info_can_remove_supports_type (G_APP_INFO(info->super_appinfo));
}

static gboolean
gmenu_desktopappinfo_remove_supports_type (GAppInfo    *appinfo,
                                         const char  *content_type,
                                         GError     **error)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_app_info_remove_supports_type (G_APP_INFO(info->super_appinfo), content_type, error);
}

static gboolean
gmenu_desktopappinfo_can_delete (GAppInfo *appinfo)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_app_info_can_delete (G_APP_INFO(info->super_appinfo));
}

static gboolean
gmenu_desktopappinfo_delete (GAppInfo *appinfo)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_app_info_delete (G_APP_INFO(info->super_appinfo));
}

static const char *
gmenu_desktopappinfo_get_commandline (GAppInfo *appinfo)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_app_info_get_commandline (G_APP_INFO(info->super_appinfo));
}

static const char *
gmenu_desktopappinfo_get_display_name (GAppInfo *appinfo)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_app_info_get_display_name (G_APP_INFO(info->super_appinfo));
}

static gboolean
gmenu_desktopappinfo_set_as_last_used_for_type (GAppInfo    *appinfo,
                                         const char  *content_type,
                                         GError     **error)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_app_info_set_as_last_used_for_type (G_APP_INFO(info->super_appinfo), content_type, error);
}

static const char **
gmenu_desktopappinfo_get_supported_types (GAppInfo    *appinfo)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_app_info_get_supported_types (G_APP_INFO(info->super_appinfo));
}

static void
gmenu_desktopappinfo_interface_init (GAppInfoIface *iface)
{
  iface->dup = gmenu_desktopappinfo_dup;
  iface->equal = gmenu_desktopappinfo_equal;
  iface->get_id = gmenu_desktopappinfo_get_id;
  iface->get_name = gmenu_desktopappinfo_get_name;
  iface->get_description = gmenu_desktopappinfo_get_description;
  iface->get_executable = gmenu_desktopappinfo_get_executable;
  iface->get_icon = gmenu_desktopappinfo_get_icon;
  iface->launch = gmenu_desktopappinfo_launch;
  iface->supports_uris = gmenu_desktopappinfo_supports_uris;
  iface->supports_files = gmenu_desktopappinfo_supports_files;
  iface->launch_uris = gmenu_desktopappinfo_launch_uris;
  iface->should_show = gmenu_desktopappinfo_should_show;
  iface->set_as_default_for_type = gmenu_desktopappinfo_set_as_default_for_type;
  iface->set_as_default_for_extension = gmenu_desktopappinfo_set_as_default_for_extension;
  iface->add_supports_type = gmenu_desktopappinfo_add_supports_type;
  iface->can_remove_supports_type = gmenu_desktopappinfo_can_remove_supports_type;
  iface->remove_supports_type = gmenu_desktopappinfo_remove_supports_type;
  iface->can_delete = gmenu_desktopappinfo_can_delete;
  iface->do_delete = gmenu_desktopappinfo_delete;
  iface->get_commandline = gmenu_desktopappinfo_get_commandline;
  iface->get_display_name = gmenu_desktopappinfo_get_display_name;
  iface->set_as_last_used_for_type = gmenu_desktopappinfo_set_as_last_used_for_type;
  iface->get_supported_types = gmenu_desktopappinfo_get_supported_types;
}

G_DEFINE_TYPE_WITH_CODE (GMenuDesktopAppInfo, gmenu_desktopappinfo, G_TYPE_OBJECT,
                         G_IMPLEMENT_INTERFACE (G_TYPE_APP_INFO, gmenu_desktopappinfo_interface_init))

static void
gmenu_desktopappinfo_init (GMenuDesktopAppInfo *info)
{
  info->super_appinfo = NULL;
  info->desktop_id = NULL;
  info->flatpak_app_id = NULL;
  info->startup_wm_class = NULL;
}

static void
gmenu_desktopappinfo_finalize (GObject *object)
{
  /* TODO: Add deinitalization code here */
  
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (object);
  
  g_free (info->desktop_id);
  g_free (info->startup_wm_class);
  g_free (info->flatpak_app_id);

  if (info->super_appinfo)
    g_object_unref (info->super_appinfo);
}

static void
gmenu_desktopappinfo_class_init (GMenuDesktopAppInfoClass *klass)
{
  GObjectClass* object_class = G_OBJECT_CLASS (klass);

  object_class->finalize = gmenu_desktopappinfo_finalize;
}

/**
 * gmenu_desktopappinfo_new:
 * @desktop_id: the desktop file id
 *
 * This is currently unused in Cinnamon and does not make sense here
 * because the desktop id as used here is not necessarily unique
 *
 * Returns: (nullable): %NULL
 */
GMenuDesktopAppInfo*
gmenu_desktopappinfo_new (const char *desktop_id)
{
  return NULL;
}

/**
 * gmenu_desktopappinfo_new_from_filename:
 * @filename: (type filename): the path of a desktop file, in the GLib
 *      filename encoding
 *
 * Creates a new #GMenuDesktopAppInfo.
 *
 * Returns: (nullable): a new #GMenuDesktopAppInfo or %NULL on error.
 **/
GMenuDesktopAppInfo*
gmenu_desktopappinfo_new_from_filename (gchar *filename)
{
  GMenuDesktopAppInfo *info = NULL;

  info = g_object_new (GMENU_TYPE_DESKTOPAPPINFO, NULL);
  info->super_appinfo = g_desktop_app_info_new_from_filename (filename);
  
  if (info->super_appinfo)
  {
    update_app_data (info);
    return info;
  } else {
      g_object_unref (info);
      return NULL;
  }
}

/**
 * gmenu_desktopappinfo_new_from_keyfile:
 * @key_file: an opened #GKeyFile
 *
 * Creates a new #GMenuDesktopAppInfo.
 *
 * Returns: (nullable): a new #GMenuDesktopAppInfo or %NULL on error.
 **/
GMenuDesktopAppInfo*
gmenu_desktopappinfo_new_from_keyfile (GKeyFile *keyfile)
{
  GMenuDesktopAppInfo *info = NULL;

  info = g_object_new (GMENU_TYPE_DESKTOPAPPINFO, NULL);
  info->super_appinfo = g_desktop_app_info_new_from_keyfile (keyfile);
  
  if (info->super_appinfo)
  {
    update_app_data (info);
    return info;
  } else {
      g_object_unref (info);
      return NULL;
  }
}

/**
 * gmenu_desktopappinfo_get_filename:
 * @appinfo: a #MenuGDesktopAppInfo
 *
 * When @info was created from a known filename, return it.  In some
 * situations such as the #GMenuDesktopAppInfo returned from
 * gmenu_desktopappinfo_new_from_keyfile(), this function will return %NULL.
 *
 * Returns: (type filename): The full path to the file for @info,
 *     or %NULL if not known.
 * Since: 2.24
 */
const char * gmenu_desktopappinfo_get_filename (GMenuDesktopAppInfo *appinfo)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_desktop_app_info_get_filename (info->super_appinfo);
}

/**
 * gmenu_desktopappinfo_get_generic_name:
 * @appinfo: a #MenuGDesktopAppInfo
 *
 * Gets the generic name from the destkop file.
 *
 * Returns: The value of the GenericName key
 */
const char * gmenu_desktopappinfo_get_generic_name (GMenuDesktopAppInfo *appinfo)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_desktop_app_info_get_generic_name (info->super_appinfo);
}

/**
 * gmenu_desktopappinfo_get_categories:
 * @appinfo: a #GMenuDesktopAppInfo
 *
 * Gets the categories from the desktop file.
 *
 * Returns: The unparsed Categories key from the desktop file;
 *     i.e. no attempt is made to split it by ';' or validate it.
 */
const char * gmenu_desktopappinfo_get_categories (GMenuDesktopAppInfo *appinfo)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_desktop_app_info_get_categories (info->super_appinfo);
}

/**
 * gmenu_desktopappinfo_get_keywords:
 * @appinfo: a #GMenuDesktopAppInfo
 *
 * Gets the keywords from the desktop file.
 *
 * Returns: (transfer none): The value of the Keywords key
 */
const char * const *gmenu_desktopappinfo_get_keywords (GMenuDesktopAppInfo *appinfo)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_desktop_app_info_get_keywords (info->super_appinfo);
}

/**
 * gmenu_desktopappinfo_get_nodisplay:
 * @appinfo: a #GMenuDesktopAppInfo
 *
 * Gets the value of the NoDisplay key, which helps determine if the
 * application info should be shown in menus. See
 * #G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY and g_app_info_should_show().
 *
 * Returns: The value of the NoDisplay key
 */
gboolean gmenu_desktopappinfo_get_nodisplay (GMenuDesktopAppInfo *appinfo)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_desktop_app_info_get_nodisplay (info->super_appinfo);
}

/**
 * gmenu_desktopappinfo_get_show_in:
 * @appinfo: a #GMenuDesktopAppInfo
 * @desktop_env: (nullable): a string specifying a desktop name
 *
 * Checks if the application info should be shown in menus that list available
 * applications for a specific name of the desktop, based on the
 * `OnlyShowIn` and `NotShowIn` keys.
 *
 * @desktop_env should typically be given as %NULL, in which case the
 * `XDG_CURRENT_DESKTOP` environment variable is consulted.  If you want
 * to override the default mechanism then you may specify @desktop_env,
 * but this is not recommended.
 *
 * Note that g_app_info_should_show() for @info will include this check (with
 * %NULL for @desktop_env) as well as additional checks.
 *
 * Returns: %TRUE if the @info should be shown in @desktop_env according to the
 * `OnlyShowIn` and `NotShowIn` keys, %FALSE
 * otherwise.
 */
gboolean gmenu_desktopappinfo_get_show_in (GMenuDesktopAppInfo *appinfo, const gchar *desktop_env)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_desktop_app_info_get_show_in (info->super_appinfo, desktop_env);
}

/**
 * gmenu_desktopappinfo_get_startup_wm_class:
 * @appinfo: a #GMenuDesktopAppInfo that supports startup notify
 *
 * Retrieves the StartupWMClass field from @info. This represents the
 * WM_CLASS property of the main window of the application, if launched
 * through @info.
 * 
 * Note: The returned value contain the suffix ":flatpak" if @info specifies a flatpak app
 * and if the desktop file has a StartupWMClass
 *
 * Returns: (transfer none): the startup WM class, or %NULL if none is set
 * in the desktop file.
 */
const char * gmenu_desktopappinfo_get_startup_wm_class (GMenuDesktopAppInfo *appinfo)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);

  return info->startup_wm_class;
}

/**
 * gmenu_desktopappinfo_get_is_hidden:
 * @appinfo: a #GMenuDesktopAppInfo.
 *
 * A desktop file is hidden if the Hidden key in it is
 * set to True.
 *
 * Returns: %TRUE if hidden, %FALSE otherwise.
 **/
gboolean gmenu_desktopappinfo_get_is_hidden (GMenuDesktopAppInfo *appinfo)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_desktop_app_info_get_is_hidden (info->super_appinfo);
}

/**
 * gmenu_desktopappinfo_has_key:
 * @appinfo: a #GMenuDesktopAppInfo
 * @key: the key to look up
 *
 * Returns whether @key exists in the "Desktop Entry" group
 * of the keyfile backing @info.
 *
 * Returns: %TRUE if the @key exists
 */
gboolean gmenu_desktopappinfo_has_key (GMenuDesktopAppInfo *appinfo, const char *key)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_desktop_app_info_has_key (info->super_appinfo, key);
}

/**
 * gmenu_desktopappinfo_get_string:
 * @appinfo: a #GMenuDesktopAppInfo
 * @key: the key to look up
 *
 * Looks up a string value in the keyfile backing @info.
 *
 * The @key is looked up in the "Desktop Entry" group.
 *
 * Returns: a newly allocated string, or %NULL if the key
 *     is not found
 */
char * gmenu_desktopappinfo_get_string (GMenuDesktopAppInfo *appinfo, const char *key)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_desktop_app_info_get_string (info->super_appinfo, key);
}

/**
 * gmenu_desktopappinfo_get_locale_string:
 * @appinfo: a #GMenuDesktopAppInfo
 * @key: the key to look up
 *
 * Looks up a localized string value in the keyfile backing @info
 * translated to the current locale.
 *
 * The @key is looked up in the "Desktop Entry" group.
 *
 * Returns: (nullable): a newly allocated string, or %NULL if the key
 *     is not found
 */
char * gmenu_desktopappinfo_get_locale_string (GMenuDesktopAppInfo *appinfo, const char *key)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_desktop_app_info_get_locale_string (info->super_appinfo, key);
}

/**
 * gmenu_desktopappinfo_get_boolean:
 * @appinfo: a #GMenuDesktopAppInfo
 * @key: the key to look up
 *
 * Looks up a boolean value in the keyfile backing @info.
 *
 * The @key is looked up in the "Desktop Entry" group.
 *
 * Returns: the boolean value, or %FALSE if the key
 *     is not found
 */
gboolean gmenu_desktopappinfo_get_boolean (GMenuDesktopAppInfo *appinfo, const char *key)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_desktop_app_info_get_boolean (info->super_appinfo, key);
}

/**
 * gmenu_desktopappinfo_list_actions:
 * @appinfo: a #GMenuDesktopAppInfo
 *
 * Returns the list of "additional application actions" supported on the
 * desktop file, as per the desktop file specification.
 *
 * As per the specification, this is the list of actions that are
 * explicitly listed in the "Actions" key of the [Desktop Entry] group.
 *
 * Returns: (array zero-terminated=1) (element-type utf8) (transfer none): a list of strings, always non-%NULL
 **/
const gchar * const * gmenu_desktopappinfo_list_actions (GMenuDesktopAppInfo *appinfo)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_desktop_app_info_list_actions (info->super_appinfo);
}

/**
 * gmenu_desktopappinfo_launch_action:
 * @appinfo: a #GMenuDesktopAppInfo
 * @action_name: the name of the action as from
 *   g_desktop_app_info_list_actions()
 * @launch_context: (nullable): a #GAppLaunchContext
 *
 * Activates the named application action.
 *
 * You may only call this function on action names that were
 * returned from g_desktop_app_info_list_actions().
 *
 * Note that if the main entry of the desktop file indicates that the
 * application supports startup notification, and @launch_context is
 * non-%NULL, then startup notification will be used when activating the
 * action (and as such, invocation of the action on the receiving side
 * must signal the end of startup notification when it is completed).
 * This is the expected behaviour of applications declaring additional
 * actions, as per the desktop file specification.
 *
 * As with g_app_info_launch() there is no way to detect failures that
 * occur while using this function.
 */
void gmenu_desktopappinfo_launch_action (GMenuDesktopAppInfo *appinfo, const gchar *action_name, GAppLaunchContext *launch_context)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  g_desktop_app_info_launch_action (info->super_appinfo, action_name, launch_context);
}

/**
 * gmenu_desktopappinfo_get_action_name:
 * @appinfo: a #GMenuDesktopAppInfo
 * @action_name: the name of the action as from
 *   gmenu_desktopappinfo_list_actions()
 *
 * Gets the user-visible display name of the "additional application
 * action" specified by @action_name.
 *
 * This corresponds to the "Name" key within the keyfile group for the
 * action.
 *
 * Returns: (transfer full): the locale-specific action name
 *
 * Since: 2.38
 */
gchar * gmenu_desktopappinfo_get_action_name (GMenuDesktopAppInfo *appinfo, const gchar *action_name)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_desktop_app_info_get_action_name (info->super_appinfo, action_name);
}

/**
 * gmenu_desktopappinfo_launch_uris_as_manager:
 * @appinfo: a #GMenuDesktopAppInfo
 * @uris: (element-type utf8): List of URIs
 * @launch_context: (nullable): a #GAppLaunchContext
 * @spawn_flags: #GSpawnFlags, used for each process
 * @user_setup: (scope async) (nullable): a #GSpawnChildSetupFunc, used once
 *     for each process.
 * @user_setup_data: (closure user_setup) (nullable): User data for @user_setup
 * @pid_callback: (scope call) (nullable): Callback for child processes
 * @pid_callback_data: (closure pid_callback) (nullable): User data for @callback
 * @error: return location for a #GError, or %NULL
 *
 * This function performs the equivalent of g_app_info_launch_uris(),
 * but is intended primarily for operating system components that
 * launch applications.  Ordinary applications should use
 * g_app_info_launch_uris().
 *
 * If the application is launched via GSpawn, then @spawn_flags, @user_setup
 * and @user_setup_data are used for the call to g_spawn_async().
 * Additionally, @pid_callback (with @pid_callback_data) will be called to
 * inform about the PID of the created process. See g_spawn_async_with_pipes()
 * for information on certain parameter conditions that can enable an
 * optimized posix_spawn() codepath to be used.
 *
 * If application launching occurs via some other mechanism (eg: D-Bus
 * activation) then @spawn_flags, @user_setup, @user_setup_data,
 * @pid_callback and @pid_callback_data are ignored.
 *
 * Returns: %TRUE on successful launch, %FALSE otherwise.
 */
gboolean gmenu_desktopappinfo_launch_uris_as_manager (GMenuDesktopAppInfo            *appinfo,
                                           GList                      *uris,
                                           GAppLaunchContext          *launch_context,
                                           GSpawnFlags                 spawn_flags,
                                           GSpawnChildSetupFunc        user_setup,
                                           gpointer                    user_setup_data,
                                           GDesktopAppLaunchCallback   pid_callback,
                                           gpointer                    pid_callback_data,
                                           GError                    **error)
{
  GMenuDesktopAppInfo *info = GMENU_DESKTOPAPPINFO (appinfo);
  return g_desktop_app_info_launch_uris_as_manager (info->super_appinfo,
                                                    uris,
                                                    launch_context,
                                                    spawn_flags,
                                                    user_setup,
                                                    user_setup_data,
                                                    pid_callback,
                                                    pid_callback_data,
                                                    error);
}

/**
 * gmenu_desktopappinfo_get_is_flatpak:
 * @appinfo: a #GMenuMenuDesktopAppInfo
 * 
 * Returns: %TRUE if @info specifies a flatpak app, %FALSE otherwise
 */
gboolean gmenu_desktopappinfo_get_is_flatpak (GMenuDesktopAppInfo *appinfo)
{
  return appinfo->is_flatpak;
}

/**
 * gmenu_desktopappinfo_get_flatpak_app_id:
 * @appinfo: a #GMenuMenuDesktopAppInfo
 * 
 * This function looks up the "X-Flatpak" key of the [Desktop Entry] group,
 * which contains the Flatpak App ID
 * 
 * Returns: (nullable): the flatpak app id or %NULL
 */
const char *
gmenu_desktopappinfo_get_flatpak_app_id (GMenuDesktopAppInfo *appinfo)
{
  return appinfo->flatpak_app_id;
}