diff options
author | Matthias Clasen <mclasen@redhat.com> | 2016-09-11 11:04:40 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2016-09-11 11:25:50 -0400 |
commit | ac95470c0196feec1f2353425460d676a669a896 (patch) | |
tree | 6679040898c829686642e36c81df93bbefec5895 /demos | |
parent | 3f102c27aaeb6c8c1a51e1aa26108ab2be93ac46 (diff) | |
download | gtk+-ac95470c0196feec1f2353425460d676a669a896.tar.gz |
Add a --version option to gtk3-demo
This was missing, for no good reason.
Diffstat (limited to 'demos')
-rw-r--r-- | demos/gtk-demo/main.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/demos/gtk-demo/main.c b/demos/gtk-demo/main.c index 923030f02b..616c33f38c 100644 --- a/demos/gtk-demo/main.c +++ b/demos/gtk-demo/main.c @@ -1144,6 +1144,33 @@ out: return 0; } +static void +print_version (void) +{ + g_print ("gtk3-demo %d.%d.%d\n", + gtk_get_major_version (), + gtk_get_minor_version (), + gtk_get_micro_version ()); +} + +static int +local_options (GApplication *app, + GVariantDict *options, + gpointer data) +{ + gboolean version = FALSE; + + g_variant_dict_lookup (options, "version", "b", &version); + + if (version) + { + print_version (); + return 0; + } + + return -1; +} + int main (int argc, char **argv) { @@ -1169,6 +1196,7 @@ main (int argc, char **argv) app_entries, G_N_ELEMENTS (app_entries), app); + g_application_add_main_option (G_APPLICATION (app), "version", 0, 0, G_OPTION_ARG_NONE, "Show program version", NULL); g_application_add_main_option (G_APPLICATION (app), "run", 0, 0, G_OPTION_ARG_STRING, "Run an example", "EXAMPLE"); g_application_add_main_option (G_APPLICATION (app), "list", 0, 0, G_OPTION_ARG_NONE, "List examples", NULL); g_application_add_main_option (G_APPLICATION (app), "autoquit", 0, 0, G_OPTION_ARG_NONE, "Quit after a delay", NULL); @@ -1176,6 +1204,7 @@ main (int argc, char **argv) g_signal_connect (app, "startup", G_CALLBACK (startup), NULL); g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); g_signal_connect (app, "command-line", G_CALLBACK (command_line), NULL); + g_signal_connect (app, "handle-local-options", G_CALLBACK (local_options), NULL); g_application_run (G_APPLICATION (app), argc, argv); |