summaryrefslogtreecommitdiffstats
path: root/gtk/src
diff options
context:
space:
mode:
Diffstat (limited to 'gtk/src')
-rw-r--r--gtk/src/callbacks.c63
-rw-r--r--gtk/src/hb-backend.c193
-rw-r--r--gtk/src/hb-backend.h1
3 files changed, 141 insertions, 116 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c
index 390abc36e..6c8dc88e4 100644
--- a/gtk/src/callbacks.c
+++ b/gtk/src/callbacks.c
@@ -5003,69 +5003,6 @@ ghb_uninhibit_gsm()
}
G_MODULE_EXPORT gboolean
-tweak_setting_cb(
- GtkWidget *widget,
- GdkEventButton *event,
- signal_user_data_t *ud)
-{
- const gchar *name;
- gchar *tweak_name;
- gboolean ret = FALSE;
- gboolean allow_tweaks;
-
- g_debug("press %d %d", event->type, event->button);
- allow_tweaks = ghb_dict_get_bool(ud->prefs, "allow_tweaks");
- if (allow_tweaks && event->type == GDK_BUTTON_PRESS && event->button == 3)
- { // Its a right mouse click
- GtkWidget *dialog;
- GtkEntry *entry;
- GtkResponseType response;
- const gchar *tweak = NULL;
-
- name = ghb_get_setting_key(widget);
- if (g_str_has_prefix(name, "tweak_"))
- {
- tweak_name = g_strdup(name);
- }
- else
- {
- tweak_name = g_strdup_printf("tweak_%s", name);
- }
-
- tweak = ghb_dict_get_string(ud->settings, tweak_name);
- dialog = GHB_WIDGET(ud->builder, "tweak_dialog");
- gtk_window_set_title(GTK_WINDOW(dialog), tweak_name);
- entry = GTK_ENTRY(GHB_WIDGET(ud->builder, "tweak_setting"));
- if (tweak)
- {
- gtk_entry_set_text(entry, tweak);
- }
- response = gtk_dialog_run(GTK_DIALOG(dialog));
- gtk_widget_hide(dialog);
- if (response == GTK_RESPONSE_OK)
- {
- tweak = (gchar*)gtk_entry_get_text(entry);
- if (ghb_validate_filter_string(tweak, -1))
- ghb_dict_set_string(ud->settings, tweak_name, tweak);
- else
- {
- GtkWindow *hb_window;
- gchar *message;
- hb_window = GTK_WINDOW(GHB_WIDGET(ud->builder, "hb_window"));
- message = g_strdup_printf(
- _("Invalid Settings:\n%s"),
- tweak);
- ghb_message_dialog(hb_window, GTK_MESSAGE_ERROR, message, _("Cancel"), NULL);
- g_free(message);
- }
- }
- g_free(tweak_name);
- ret = TRUE;
- }
- return ret;
-}
-
-G_MODULE_EXPORT gboolean
easter_egg_cb(
GtkWidget *widget,
GdkEventButton *event,
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index 7d5680658..f76574134 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -3894,87 +3894,176 @@ get_preview_geometry(signal_user_data_t *ud, const hb_title_t *title,
}
gboolean
-ghb_validate_filter_string(const gchar *str, gint max_fields)
-{
- gint fields = 0;
- gchar *end;
-
- if (str == NULL || *str == 0) return TRUE;
- while (*str)
- {
- g_strtod(str, &end);
- if (str != end)
- { // Found a numeric value
- fields++;
- // negative max_fields means infinate
- if (max_fields >= 0 && fields > max_fields) return FALSE;
- if (*end == 0)
- return TRUE;
- if (*end != ':')
- return FALSE;
- str = end + 1;
- }
- else
- return FALSE;
- }
- return FALSE;
-}
-
-gboolean
ghb_validate_filters(GhbValue *settings, GtkWindow *parent)
{
- const gchar *str;
- gint index;
gchar *message;
- gboolean decomb_deint = ghb_dict_get_bool(settings, "PictureDecombDeinterlace");
- // deinte
- index = ghb_settings_combo_int(settings, "PictureDeinterlace");
- if (!decomb_deint && index == 1)
+ // Deinterlace
+ gboolean decomb_deint;
+ const char *deint_preset;
+ decomb_deint = ghb_dict_get_bool(settings, "PictureDecombDeinterlace");
+ deint_preset = ghb_dict_get_string(settings, "PictureDeinterlace");
+ if (!decomb_deint && strcasecmp(deint_preset, "off"))
{
- str = ghb_dict_get_string(settings, "PictureDeinterlaceCustom");
- if (!ghb_validate_filter_string(str, -1))
+ const char *deint_custom = NULL;
+ int filter_id;
+
+ filter_id = HB_FILTER_DEINTERLACE;
+ if (!strcasecmp(deint_preset, "custom"))
{
- message = g_strdup_printf(
- _("Invalid Deinterlace Settings:\n\n%s\n"), str);
+ deint_custom = ghb_dict_get_string(settings,
+ "PictureDeinterlaceCustom");
+ }
+ if (hb_validate_filter_preset(filter_id, deint_preset, deint_custom))
+ {
+ if (deint_custom != NULL)
+ {
+ message = g_strdup_printf(
+ _("Invalid Deinterlace Settings:\n\n"
+ "Preset: %s\n"
+ "Custom: %s\n"), deint_preset, deint_custom);
+ }
+ else
+ {
+ message = g_strdup_printf(
+ _("Invalid Deinterlace Settings:\n\n"
+ "Preset: %s\n"), deint_preset);
+ }
ghb_message_dialog(parent, GTK_MESSAGE_ERROR,
message, _("Cancel"), NULL);
g_free(message);
return FALSE;
}
}
- // detel
- index = ghb_settings_combo_int(settings, "PictureDetelecine");
- if (index == 1)
+
+ // Decomb
+ deint_preset = ghb_dict_get_string(settings, "PictureDecomb");
+ if (decomb_deint && strcasecmp(deint_preset, "off"))
{
- str = ghb_dict_get_string(settings, "PictureDetelecineCustom");
- if (!ghb_validate_filter_string(str, -1))
+ const char *deint_custom = NULL;
+ int filter_id;
+
+ filter_id = HB_FILTER_DECOMB;
+ if (!strcasecmp(deint_preset, "custom"))
{
- message = g_strdup_printf(
- _("Invalid Detelecine Settings:\n\n%s\n"), str);
+ deint_custom = ghb_dict_get_string(settings, "PictureDecombCustom");
+ }
+ if (hb_validate_filter_preset(filter_id, deint_preset, deint_custom))
+ {
+ if (deint_custom != NULL)
+ {
+ message = g_strdup_printf(
+ _("Invalid Decomb Settings:\n\n"
+ "Preset: %s\n"
+ "Custom: %s\n"), deint_preset, deint_custom);
+ }
+ else
+ {
+ message = g_strdup_printf(
+ _("Invalid Decomb Settings:\n\n"
+ "Preset: %s\n"), deint_preset);
+ }
ghb_message_dialog(parent, GTK_MESSAGE_ERROR,
message, _("Cancel"), NULL);
g_free(message);
return FALSE;
}
}
- // decomb
- index = ghb_settings_combo_int(settings, "PictureDecomb");
- if (decomb_deint && index == 1)
+
+ // Detelecine
+ const char *detel_preset;
+ detel_preset = ghb_dict_get_string(settings, "PictureDetelecine");
+ if (strcasecmp(detel_preset, "off"))
{
- str = ghb_dict_get_string(settings, "PictureDecombCustom");
- if (!ghb_validate_filter_string(str, -1))
+ const char *detel_custom = NULL;
+ int filter_id;
+
+ filter_id = HB_FILTER_DETELECINE;
+ if (!strcasecmp(detel_preset, "custom"))
+ {
+ detel_custom = ghb_dict_get_string(settings, "PictureDecombCustom");
+ }
+ if (hb_validate_filter_preset(filter_id, detel_preset, detel_custom))
+ {
+ if (detel_custom != NULL)
+ {
+ message = g_strdup_printf(
+ _("Invalid Detelecine Settings:\n\n"
+ "Preset: %s\n"
+ "Custom: %s\n"), detel_preset, detel_custom);
+ }
+ else
+ {
+ message = g_strdup_printf(
+ _("Invalid Detelecine Settings:\n\n"
+ "Preset: %s\n"), detel_preset);
+ }
+ ghb_message_dialog(parent, GTK_MESSAGE_ERROR,
+ message, _("Cancel"), NULL);
+ g_free(message);
+ return FALSE;
+ }
+ }
+
+ // Denoise
+ const char *denoise_filter;
+ denoise_filter = ghb_dict_get_string(settings, "PictureDenoiseFilter");
+ if (strcasecmp(denoise_filter, "off"))
+ {
+ const char *denoise_preset, *denoise_tune, *denoise_custom = NULL;
+ int filter_id;
+
+ if (!strcasecmp(denoise_filter, "nlmeans"))
+ {
+ filter_id = HB_FILTER_NLMEANS;
+ }
+ else if (!strcasecmp(denoise_filter, "hqdn3d"))
+ {
+ filter_id = HB_FILTER_HQDN3D;
+ }
+ else
{
message = g_strdup_printf(
- _("Invalid Decomb Settings:\n\n%s\n"), str);
+ _("Invalid Denoise Filter: %s\n"), denoise_filter);
+ ghb_message_dialog(parent, GTK_MESSAGE_ERROR,
+ message, _("Cancel"), NULL);
+ g_free(message);
+ return FALSE;
+ }
+ denoise_preset = ghb_dict_get_string(settings, "PictureDenoisePreset");
+ 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_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);
+ }
ghb_message_dialog(parent, GTK_MESSAGE_ERROR,
message, _("Cancel"), NULL);
g_free(message);
return FALSE;
}
}
- // denoise
- // TODO
return TRUE;
}
diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h
index ae2352e85..acb57ae7d 100644
--- a/gtk/src/hb-backend.h
+++ b/gtk/src/hb-backend.h
@@ -148,7 +148,6 @@ gboolean ghb_validate_audio(GhbValue *settings, GtkWindow *parent);
gboolean ghb_validate_subtitles(GhbValue *settings, GtkWindow *parent);
gboolean ghb_validate_video(GhbValue *settings, GtkWindow *parent);
gboolean ghb_validate_filters(GhbValue *settings, GtkWindow *parent);
-gboolean ghb_validate_filter_string(const gchar *str, gint max_fields);
void ghb_hb_cleanup(gboolean partial);
gint ghb_lookup_combo_int(const gchar *name, const GhbValue *gval);
gdouble ghb_lookup_combo_double(const gchar *name, const GhbValue *gval);