Skip to content

Commit 7c77bb3

Browse files
oSoMoNTingPing
authored andcommitted
xdg-open: add an 'ask' option to force going through the application chooser
The 'ask' option was introduced in version 3 of the org.freedesktop.portal.OpenURI.{OpenURI,OpenFile} interface. If false (the default), the portal may use a default application or pick the last choice.
1 parent 1834cd8 commit 7c77bb3

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/xdg-open.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,16 @@
3535
static char **uris = NULL;
3636
static gboolean show_help = FALSE;
3737
static gboolean show_version = FALSE;
38+
static gboolean ask = FALSE;
3839

3940
static GOptionEntry entries[] = {
4041
/* Compat options with "real" xdg-open */
4142
{ "manual", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &show_help, NULL, NULL },
4243
{ "version", 0, 0, G_OPTION_ARG_NONE, &show_version, N_("Show program version"), NULL },
4344

45+
/* Portal-specific options */
46+
{ "ask", 0, 0, G_OPTION_ARG_NONE, &ask, N_("Ask the user to choose an app"), NULL },
47+
4448
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &uris, NULL, NULL },
4549
{ NULL, 0, 0, 0, NULL, NULL, NULL }
4650
};
@@ -97,6 +101,7 @@ main (int argc, char *argv[])
97101
}
98102

99103
g_variant_builder_init (&opt_builder, G_VARIANT_TYPE_VARDICT);
104+
g_variant_builder_add (&opt_builder, "{sv}", "ask", g_variant_new_boolean (ask));
100105

101106
file = g_file_new_for_commandline_arg (uris[0]);
102107
if (g_file_is_native (file))

0 commit comments

Comments
 (0)