mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-29 15:22:11 +02:00
clapper-app: Clamp command line args to allowed values
Instead of running into warnings or other problems when user specifies an out of range value for command line option, just clamp them to nearest allowed one.
This commit is contained in:
@@ -419,11 +419,19 @@ clapper_app_application_command_line (GApplication *app, GApplicationCommandLine
|
||||
app_opts.enqueue = g_variant_dict_contains (options, "enqueue");
|
||||
}
|
||||
|
||||
if (!g_variant_dict_lookup (options, "volume", "d", &app_opts.volume))
|
||||
if (g_variant_dict_lookup (options, "volume", "d", &app_opts.volume))
|
||||
app_opts.volume = CLAMP (app_opts.volume, 0, 2.0); // clamp to allowed range
|
||||
else
|
||||
app_opts.volume = -1;
|
||||
if (!g_variant_dict_lookup (options, "speed", "d", &app_opts.speed))
|
||||
|
||||
if (g_variant_dict_lookup (options, "speed", "d", &app_opts.speed))
|
||||
app_opts.speed = CLAMP (app_opts.speed, 0.05, 2.0); // clamp to allowed range
|
||||
else
|
||||
app_opts.speed = -1;
|
||||
if (!g_variant_dict_lookup (options, "progression-mode", "i", &app_opts.progression_mode))
|
||||
|
||||
if (g_variant_dict_lookup (options, "progression-mode", "i", &app_opts.progression_mode))
|
||||
app_opts.progression_mode = CLAMP (app_opts.progression_mode, 0, 4); // clamp to possible modes
|
||||
else
|
||||
app_opts.progression_mode = -1;
|
||||
|
||||
app_opts.fullscreen = g_variant_dict_contains (options, "fullscreen");
|
||||
|
Reference in New Issue
Block a user