aboutsummaryrefslogtreecommitdiff
path: root/fastiv.c
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2021-11-18 12:44:25 +0100
committerPřemysl Eric Janouch <p@janouch.name>2021-11-18 12:46:05 +0100
commit06af1a3cc9920780c7edeba34677fc66b18ff5eb (patch)
tree2be217eba41f38bf5e669920018b756354516e79 /fastiv.c
parent47293cfc10c9d752a77c5d1a22319fdea15f1271 (diff)
downloadfiv-06af1a3cc9920780c7edeba34677fc66b18ff5eb.tar.gz
fiv-06af1a3cc9920780c7edeba34677fc66b18ff5eb.tar.xz
fiv-06af1a3cc9920780c7edeba34677fc66b18ff5eb.zip
Add a command line option to list supported types
Make it work without a display connection.
Diffstat (limited to 'fastiv.c')
-rw-r--r--fastiv.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/fastiv.c b/fastiv.c
index 7162a53..70210b1 100644
--- a/fastiv.c
+++ b/fastiv.c
@@ -396,24 +396,33 @@ on_button_press_browser(G_GNUC_UNUSED GtkWidget *widget, GdkEventButton *event)
int
main(int argc, char *argv[])
{
- gboolean show_version = FALSE;
+ gboolean show_version = FALSE, show_supported_media_types = FALSE;
gchar **path_args = NULL;
const GOptionEntry options[] = {
{G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &path_args,
NULL, "[FILE | DIRECTORY]"},
+ {"list-supported-media-types", 0, G_OPTION_FLAG_IN_MAIN,
+ G_OPTION_ARG_NONE, &show_supported_media_types,
+ "Output supported media types and exit", NULL},
{"version", 'V', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
- &show_version, "output version information and exit", NULL},
+ &show_version, "Output version information and exit", NULL},
{},
};
GError *error = NULL;
- if (!gtk_init_with_args(
- &argc, &argv, " - fast image viewer", options, NULL, &error))
- exit_fatal("%s", error->message);
+ gboolean initialized = gtk_init_with_args(
+ &argc, &argv, " - fast image viewer", options, NULL, &error);
if (show_version) {
printf(PROJECT_NAME " " PROJECT_VERSION "\n");
return 0;
}
+ if (show_supported_media_types) {
+ for (char **types = fastiv_io_all_supported_media_types(); *types; )
+ g_print("%s\n", *types++);
+ return 0;
+ }
+ if (!initialized)
+ exit_fatal("%s", error->message);
// NOTE: Firefox and Eye of GNOME both interpret multiple arguments
// in a special way. This is problematic, because one-element lists
@@ -506,8 +515,10 @@ main(int argc, char *argv[])
G_CALLBACK(on_key_press), NULL);
gtk_container_add(GTK_CONTAINER(g.window), g.stack);
- // TODO(p): Also milk gdk-pixbuf, if linked in, needs to be done in runtime.
- g.supported_globs = extract_mime_globs(fastiv_io_supported_media_types);
+ char **types = fastiv_io_all_supported_media_types();
+ g.supported_globs = extract_mime_globs((const char **) types);
+ g_strfreev(types);
+
g.files = g_ptr_array_new_full(16, g_free);
gchar *cwd = g_get_current_dir();