summaryrefslogtreecommitdiffstats
path: root/gtk/src
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2008-08-21 00:43:46 +0000
committerjstebbins <[email protected]>2008-08-21 00:43:46 +0000
commit212b4a9f3cdc1e4a0bdf6c99202c2e58537c7af7 (patch)
tree4d76f0354c106d249f05b8e155bbf109c5af593e /gtk/src
parent85cc8a84080abeca75ea05337df0f0971c39cdb9 (diff)
LinGui: add a hidden feature to allow tweaking some settings. currently
tweaks are available for detelecine, decomb, deinterlace, deblock, and denoise to enable, you must manually edit preferences file and add "allow_tweaks=1" to tweak a setting, right click on the widget, an entry dialog will appear. minimal validity checking is done on the tweak's value. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1648 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk/src')
-rw-r--r--gtk/src/callbacks.c64
-rw-r--r--gtk/src/ghb.ui135
-rw-r--r--gtk/src/hb-backend.c148
-rw-r--r--gtk/src/hb-backend.h2
-rw-r--r--gtk/src/internal_defaults9
-rw-r--r--gtk/src/internal_defaults.h9
-rw-r--r--gtk/src/main.c6
7 files changed, 357 insertions, 16 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c
index df6a17b55..803737241 100644
--- a/gtk/src/callbacks.c
+++ b/gtk/src/callbacks.c
@@ -2471,6 +2471,11 @@ validate_settings(signal_user_data_t *ud)
{
return FALSE;
}
+ // Validate filter settings
+ if (!ghb_validate_filters(ud))
+ {
+ return FALSE;
+ }
audio_list_refresh(ud);
return TRUE;
}
@@ -3510,3 +3515,62 @@ ghb_hal_init()
//gvm_hal_claim_branch ("/org/freedesktop/Hal/devices/local");
}
+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_settings_get_bool (ud->settings, "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 = gtk_widget_get_name(widget);
+ if (g_str_has_prefix(name, "tweak_"))
+ {
+ tweak_name = g_strdup(name);
+ }
+ else
+ {
+ tweak_name = g_strdup_printf("tweak_%s", name);
+ }
+
+ tweak = ghb_settings_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 = gtk_entry_get_text(entry);
+ if (ghb_validate_filter_string(tweak, -1))
+ ghb_settings_set_string(ud->settings, tweak_name, tweak);
+ else
+ {
+ gchar *message;
+ message = g_strdup_printf(
+ "Invalid Settings:\n%s",
+ tweak);
+ ghb_message_dialog(GTK_MESSAGE_ERROR, message, "Cancel", NULL);
+ g_free(message);
+ }
+ }
+ g_free(tweak_name);
+ ret = TRUE;
+ }
+ return ret;
+}
+
diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui
index 6af322955..594388be3 100644
--- a/gtk/src/ghb.ui
+++ b/gtk/src/ghb.ui
@@ -1311,6 +1311,7 @@
<property name="label" translatable="yes">Detelecine</property>
<property name="draw_indicator">True</property>
<signal handler="setting_widget_changed_cb" name="toggled"/>
+ <signal handler="tweak_setting_cb" name="button-press-event"/>
</object>
<packing>
<property name="position">1</property>
@@ -1325,6 +1326,7 @@
<property name="active">True</property>
<property name="draw_indicator">True</property>
<signal handler="setting_widget_changed_cb" name="toggled"/>
+ <signal handler="tweak_setting_cb" name="button-press-event"/>
</object>
<packing>
<property name="expand">False</property>
@@ -1339,6 +1341,7 @@
<property name="label" translatable="yes">Deblock</property>
<property name="draw_indicator">True</property>
<signal handler="setting_widget_changed_cb" name="toggled"/>
+ <signal handler="tweak_setting_cb" name="button-press-event"/>
</object>
<packing>
<property name="expand">False</property>
@@ -1350,12 +1353,22 @@
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
- <object class="GtkLabel" id="label20">
+ <object class="GtkEventBox" id="tweak_deinterlace">
<property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Deinterlace:</property>
- <property name="width_chars">10</property>
+ <property name="visible_window">False</property>
+ <property name="above_child">True</property>
+ <signal name="button_press_event" handler="tweak_setting_cb"/>
+ <child>
+ <object class="GtkLabel" id="label20">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="selectable">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Deinterlace:</property>
+ <property name="width_chars">10</property>
+ </object>
+ </child>
</object>
<packing>
<property name="expand">False</property>
@@ -1366,6 +1379,7 @@
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<signal handler="setting_widget_changed_cb" name="changed"/>
+ <signal handler="tweak_setting_cb" name="button-press-event"/>
</object>
<packing>
<property name="expand">False</property>
@@ -1384,12 +1398,21 @@
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
- <object class="GtkLabel" id="label21">
+ <object class="GtkEventBox" id="tweak_denoise">
<property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Denoise:</property>
- <property name="width_chars">10</property>
+ <property name="visible_window">False</property>
+ <property name="above_child">True</property>
+ <signal name="button_press_event" handler="tweak_setting_cb"/>
+ <child>
+ <object class="GtkLabel" id="label21">
+ <property name="visible">True</property>
+ <property name="selectable">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Denoise:</property>
+ <property name="width_chars">10</property>
+ </object>
+ </child>
</object>
<packing>
<property name="expand">False</property>
@@ -1400,6 +1423,7 @@
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<signal handler="setting_widget_changed_cb" name="changed"/>
+ <signal handler="tweak_setting_cb" name="button-press-event"/>
</object>
<packing>
<property name="expand">False</property>
@@ -3412,6 +3436,97 @@ this setting.</property>
<action-widget response="-5">pref_ok</action-widget>
</action-widgets>
</object>
+ <object class="GtkDialog" id="tweak_dialog">
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="border_width">5</property>
+ <property name="modal">True</property>
+ <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="has_separator">False</property>
+ <signal handler="gtk_widget_hide_on_delete" name="delete_event"/>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="dialog-vbox7">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="spacing">2</property>
+ <child>
+ <object class="GtkHBox" id="hbox9">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <object class="GtkLabel" id="label33">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">Setting:</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="tweak_setting">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="max_length">40</property>
+ <property name="activates_default">True</property>
+ <property name="width_chars">30</property>
+ <property name="truncate_multiline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="dialog-action_area7">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+ <child>
+ <object class="GtkButton" id="tweak_cancel">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">gtk-cancel</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="tweak_ok">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">gtk-ok</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">tweak_cancel</action-widget>
+ <action-widget response="-5">tweak_ok</action-widget>
+ </action-widgets>
+ </object>
<object class="GtkDialog" id="preset_save_dialog">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">5</property>
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index 57e1a857c..376166426 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -2024,6 +2024,107 @@ ghb_guess_bitrate(GHashTable *settings)
}
gboolean
+ghb_validate_filter_string(const gchar *str, gint max_fields)
+{
+ gint fields = 0;
+ gboolean in_field = FALSE;
+ if (str == NULL || *str == 0) return TRUE;
+ while (*str)
+ {
+ if (*str >= '0' && *str <= '9')
+ {
+ if (!in_field)
+ {
+ fields++;
+ // negative max_fields means infinate
+ if (max_fields >= 0 && fields > max_fields) return FALSE;
+ in_field = TRUE;
+ }
+ }
+ else if (!in_field) return FALSE;
+ else if (*str != ':') return FALSE;
+ else in_field = FALSE;
+ str++;
+ }
+ return TRUE;
+}
+
+gboolean
+ghb_validate_filters(signal_user_data_t *ud)
+{
+ gboolean tweaks;
+ const gchar *str;
+ gchar *message;
+ gboolean enabled;
+
+ tweaks = ghb_settings_get_bool(ud->settings, "allow_tweaks");
+ if (tweaks)
+ {
+ // detele 6
+ str = ghb_settings_get_string(ud->settings, "tweak_detelecine");
+ enabled = ghb_settings_get_bool(ud->settings, "detelecine");
+ if (enabled && !ghb_validate_filter_string(str, 6))
+ {
+ message = g_strdup_printf(
+ "Invalid Detelecine Settings:\n\n%s\n",
+ str);
+ ghb_message_dialog(GTK_MESSAGE_ERROR, message, "Cancel", NULL);
+ g_free(message);
+ return FALSE;
+ }
+ // decomb 7
+ str = ghb_settings_get_string(ud->settings, "tweak_decomb");
+ enabled = ghb_settings_get_bool(ud->settings, "decomb");
+ if (enabled && !ghb_validate_filter_string(str, 7))
+ {
+ message = g_strdup_printf(
+ "Invalid Decomb Settings:\n\n%s\n",
+ str);
+ ghb_message_dialog(GTK_MESSAGE_ERROR, message, "Cancel", NULL);
+ g_free(message);
+ return FALSE;
+ }
+ // deinte 4
+ str = ghb_settings_get_string(ud->settings, "tweak_deinterlace");
+ enabled = ghb_settings_get_bool(ud->settings, "deinterlace");
+ if (enabled && !ghb_validate_filter_string(str, 4))
+ {
+ message = g_strdup_printf(
+ "Invalid Deinterlace Settings:\n\n%s\n",
+ str);
+ ghb_message_dialog(GTK_MESSAGE_ERROR, message, "Cancel", NULL);
+ g_free(message);
+ return FALSE;
+ }
+ // debloc 2
+ str = ghb_settings_get_string(ud->settings, "tweak_deblock");
+ enabled = ghb_settings_get_bool(ud->settings, "deblock");
+ if (enabled && !ghb_validate_filter_string(str, 2))
+ {
+ message = g_strdup_printf(
+ "Invalid Deblock Settings:\n\n%s\n",
+ str);
+ ghb_message_dialog(GTK_MESSAGE_ERROR, message, "Cancel", NULL);
+ g_free(message);
+ return FALSE;
+ }
+ // denois 4
+ str = ghb_settings_get_string(ud->settings, "tweak_denoise");
+ enabled = ghb_settings_get_bool(ud->settings, "denoise");
+ if (enabled && !ghb_validate_filter_string(str, 4))
+ {
+ message = g_strdup_printf(
+ "Invalid Denoise Settings:\n\n%s\n",
+ str);
+ ghb_message_dialog(GTK_MESSAGE_ERROR, message, "Cancel", NULL);
+ g_free(message);
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+gboolean
ghb_validate_video(signal_user_data_t *ud)
{
GHashTable *settings = ud->settings;
@@ -2363,6 +2464,7 @@ ghb_add_job(job_settings_t *js, gint unique_id)
GHashTable *settings = js->settings;
static gchar *x264opts;
gint sub_id = 0;
+ gboolean tweaks = FALSE;
g_debug("ghb_add_job()\n");
if (h == NULL) return;
@@ -2382,6 +2484,7 @@ ghb_add_job(job_settings_t *js, gint unique_id)
job = title->job;
if (job == NULL) return;
+ tweaks = ghb_settings_get_int(settings, "allow_tweaks");
job->mux = ghb_settings_get_int(settings, "container");
if (job->mux == HB_MUX_MP4)
{
@@ -2465,28 +2568,73 @@ ghb_add_job(job_settings_t *js, gint unique_id)
if( ghb_settings_get_bool(settings, "detelecine" ) || job->vfr )
{
hb_filter_detelecine.settings = NULL;
+ if (tweaks)
+ {
+ const gchar *str;
+ str = ghb_settings_get_string(settings, "tweak_detelecine");
+ if (str && str[0])
+ {
+ hb_filter_detelecine.settings = (gchar*)str;
+ }
+ }
hb_list_add( job->filters, &hb_filter_detelecine );
}
if( decomb )
{
// Use default settings
hb_filter_decomb.settings = NULL;
+ if (tweaks)
+ {
+ const gchar *str;
+ str = ghb_settings_get_string(settings, "tweak_decomb");
+ if (str && str[0])
+ {
+ hb_filter_decomb.settings = (gchar*)str;
+ }
+ }
hb_list_add( job->filters, &hb_filter_decomb );
}
if( job->deinterlace )
{
hb_filter_deinterlace.settings = (gchar*)ghb_settings_get_string(settings, "deinterlace");
+ if (tweaks)
+ {
+ const gchar *str;
+ str = ghb_settings_get_string(settings, "tweak_deinterlace");
+ if (str && str[0])
+ {
+ hb_filter_deinterlace.settings = (gchar*)str;
+ }
+ }
hb_list_add( job->filters, &hb_filter_deinterlace );
}
if( ghb_settings_get_bool(settings, "deblock") )
{
hb_filter_deblock.settings = NULL;
+ if (tweaks)
+ {
+ const gchar *str;
+ str = ghb_settings_get_string(settings, "tweak_deblock");
+ if (str && str[0])
+ {
+ hb_filter_deblock.settings = (gchar*)str;
+ }
+ }
hb_list_add( job->filters, &hb_filter_deblock );
}
gint denoise = ghb_settings_get_int(settings, "denoise");
if( denoise != 0 )
{
hb_filter_denoise.settings = (gchar*)ghb_settings_get_string(settings, "denoise");
+ if (tweaks)
+ {
+ const gchar *str;
+ str = ghb_settings_get_string(settings, "tweak_denoise");
+ if (str && str[0])
+ {
+ hb_filter_denoise.settings = (gchar*)str;
+ }
+ }
hb_list_add( job->filters, &hb_filter_denoise );
}
job->width = ghb_settings_get_int(settings, "scale_width");
diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h
index 1b7e641c5..eaf4e4c56 100644
--- a/gtk/src/hb-backend.h
+++ b/gtk/src/hb-backend.h
@@ -118,6 +118,8 @@ gboolean ghb_validate_container(signal_user_data_t *ud);
gboolean ghb_validate_vquality(GHashTable *settings);
gboolean ghb_validate_audio(signal_user_data_t *ud);
gboolean ghb_validate_video(signal_user_data_t *ud);
+gboolean ghb_validate_filters(signal_user_data_t *ud);
+gboolean ghb_validate_filter_string(const gchar *str, gint max_fields);
void ghb_hb_cleanup(gboolean partial);
gint ghb_lookup_acodec(const gchar *acodec);
gint ghb_lookup_bitrate(const gchar *bitrate);
diff --git a/gtk/src/internal_defaults b/gtk/src/internal_defaults
index 19ac6fefe..4fb15f229 100644
--- a/gtk/src/internal_defaults
+++ b/gtk/src/internal_defaults
@@ -23,8 +23,13 @@ detelecine=enable
decomb=enable
deinterlace=none
denoise=none
-grayscale=disable
deblock=disable
+tweak_decomb=
+tweak_detelecine=
+tweak_deblock=
+tweak_deinterlace=
+tweak_denoise=
+grayscale=disable
video_codec=x264
two_pass=disable
turbo=enable
@@ -82,5 +87,5 @@ show_presets=enable
linear_vquality=disable
noscale=disable
nocheckvquality=disable
-
+allow_tweaks=disable
diff --git a/gtk/src/internal_defaults.h b/gtk/src/internal_defaults.h
index 13ffbe144..fbd2d3506 100644
--- a/gtk/src/internal_defaults.h
+++ b/gtk/src/internal_defaults.h
@@ -23,8 +23,13 @@
"decomb=enable\n"
"deinterlace=none\n"
"denoise=none\n"
-"grayscale=disable\n"
"deblock=disable\n"
+"tweak_decomb=\n"
+"tweak_detelecine=\n"
+"tweak_deblock=\n"
+"tweak_deinterlace=\n"
+"tweak_denoise=\n"
+"grayscale=disable\n"
"video_codec=x264\n"
"two_pass=disable\n"
"turbo=enable\n"
@@ -82,5 +87,5 @@
"linear_vquality=disable\n"
"noscale=disable\n"
"nocheckvquality=disable\n"
-"\n"
+"allow_tweaks=disable\n"
"\n"
diff --git a/gtk/src/main.c b/gtk/src/main.c
index 53b71d953..18d64da13 100644
--- a/gtk/src/main.c
+++ b/gtk/src/main.c
@@ -166,8 +166,10 @@ MyConnect(
g_return_if_fail(handler_name != NULL);
g_return_if_fail(signal_name != NULL);
- g_debug("handler_name %s\n", handler_name);
- g_debug("signal_name %s\n", signal_name);
+ //const gchar *name = gtk_widget_get_name((GtkWidget*)object);
+ //g_message("\n\nname %s", name);
+ g_debug("handler_name %s", handler_name);
+ g_debug("signal_name %s", signal_name);
callback = self_symbol_lookup(handler_name);
if (!callback)
{