summaryrefslogtreecommitdiffstats
path: root/gtk/src
diff options
context:
space:
mode:
authorJohn Stebbins <[email protected]>2016-02-20 18:00:46 -0700
committerJohn Stebbins <[email protected]>2016-03-09 13:10:10 -0700
commita44ccb49f182d4eeb122fbe675b28deb5c36b793 (patch)
tree6cc064cc24dacc2a80d41fb9543640c9004895af /gtk/src
parent96c02dd6f256f4a4e74f8962f56502d28e5e65a3 (diff)
filters: make job filter settings an hb_dict_t
This simplifies accessing and changing filter parameters programatically. It also changes the custom filter string format to a ':' separated list of key/value pairs.
Diffstat (limited to 'gtk/src')
-rw-r--r--gtk/src/hb-backend.c54
-rw-r--r--gtk/src/queuehandler.c16
2 files changed, 27 insertions, 43 deletions
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index ccadcfbd4..2a8d79bb9 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -3741,12 +3741,10 @@ ghb_validate_filters(GhbValue *settings, GtkWindow *parent)
"PictureDeinterlaceFilter");
deint_preset = ghb_dict_get_string(settings,
"PictureDeinterlacePreset");
- if (!strcasecmp(deint_preset, "custom"))
- {
- deint_custom = ghb_dict_get_string(settings,
- "PictureDeinterlaceCustom");
- }
- if (hb_validate_filter_preset(filter_id, deint_preset, deint_custom))
+ deint_custom = ghb_dict_get_string(settings,
+ "PictureDeinterlaceCustom");
+ if (hb_validate_filter_preset(filter_id, deint_preset, NULL,
+ deint_custom))
{
if (deint_custom != NULL)
{
@@ -3780,12 +3778,9 @@ ghb_validate_filters(GhbValue *settings, GtkWindow *parent)
int filter_id;
filter_id = HB_FILTER_DETELECINE;
- if (!strcasecmp(detel_preset, "custom"))
- {
- detel_custom = ghb_dict_get_string(settings,
- "PictureDetelecineCustom");
- }
- if (hb_validate_filter_preset(filter_id, detel_preset, detel_custom))
+ detel_custom = ghb_dict_get_string(settings, "PictureDetelecineCustom");
+ if (hb_validate_filter_preset(filter_id, detel_preset, NULL,
+ detel_custom))
{
if (detel_custom != NULL)
{
@@ -3820,32 +3815,17 @@ ghb_validate_filters(GhbValue *settings, GtkWindow *parent)
{
denoise_tune = ghb_dict_get_string(settings, "PictureDenoiseTune");
}
- if (!strcasecmp(denoise_preset, "custom"))
+ denoise_custom = ghb_dict_get_string(settings, "PictureDenoiseCustom");
+ if (hb_validate_filter_preset(filter_id, denoise_preset, denoise_tune,
+ denoise_custom))
{
- denoise_custom = ghb_dict_get_string(settings,
- "PictureDenoiseCustom");
- }
- if (hb_validate_filter_preset(filter_id, denoise_preset,
- denoise_custom != NULL ? denoise_custom : denoise_tune))
- {
- if (denoise_custom != NULL)
- {
- message = g_strdup_printf(
- _("Invalid Denoise Settings:\n\n"
- "Filter: %s\n"
- "Preset: %s\n"
- "Custom: %s\n"), denoise_filter, denoise_preset,
- denoise_custom);
- }
- else
- {
- message = g_strdup_printf(
- _("Invalid Denoise Settings:\n\n"
- "Filter: %s\n"
- "Preset: %s\n"
- "Tune: %s\n"), denoise_filter, denoise_preset,
- denoise_tune);
- }
+ message = g_strdup_printf(
+ _("Invalid Denoise Settings:\n\n"
+ "Filter: %s\n"
+ "Preset: %s\n"
+ "Tune: %s\n"
+ "Custom: %s\n"), denoise_filter, denoise_preset,
+ denoise_tune, denoise_custom);
ghb_message_dialog(parent, GTK_MESSAGE_ERROR,
message, _("Cancel"), NULL);
g_free(message);
diff --git a/gtk/src/queuehandler.c b/gtk/src/queuehandler.c
index 8d13b499b..2365d0e04 100644
--- a/gtk/src/queuehandler.c
+++ b/gtk/src/queuehandler.c
@@ -1071,7 +1071,6 @@ void ghb_finalize_job(GhbValue *settings)
// Add scale filter since the above does not
GhbValue *filter_list, *filter_dict;
int width, height, crop[4];
- char *filter_str;
filter_list = ghb_get_job_filter_list(settings);
width = ghb_dict_get_int(settings, "scale_width");
@@ -1082,13 +1081,18 @@ void ghb_finalize_job(GhbValue *settings)
crop[2] = ghb_dict_get_int(settings, "PictureLeftCrop");
crop[3] = ghb_dict_get_int(settings, "PictureRightCrop");
- filter_str = g_strdup_printf("%d:%d:%d:%d:%d:%d",
- width, height, crop[0], crop[1], crop[2], crop[3]);
+ hb_dict_t * dict = ghb_dict_new();
+ ghb_dict_set_int(dict, "width", width);
+ ghb_dict_set_int(dict, "height", height);
+ ghb_dict_set_int(dict, "crop-top", crop[0]);
+ ghb_dict_set_int(dict, "crop-bottom", crop[1]);
+ ghb_dict_set_int(dict, "crop-left", crop[2]);
+ ghb_dict_set_int(dict, "crop-right", crop[3]);
+
filter_dict = ghb_dict_new();
ghb_dict_set_int(filter_dict, "ID", HB_FILTER_CROP_SCALE);
- ghb_dict_set_string(filter_dict, "Settings", filter_str);
- hb_value_array_append(filter_list, filter_dict);
- g_free(filter_str);
+ ghb_dict_set(filter_dict, "Settings", dict);
+ hb_add_filter2(filter_list, filter_dict);
ghb_value_free(&preset);
}