diff options
author | jstebbins <[email protected]> | 2008-08-22 23:20:53 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2008-08-22 23:20:53 +0000 |
commit | 158e774a39c3c914dbe1ae2294df57853812b3e8 (patch) | |
tree | fa65dc6e553a81ef1233f1cce3be8ee4556fed78 | |
parent | 212b4a9f3cdc1e4a0bdf6c99202c2e58537c7af7 (diff) |
LinGui: improve data entry method for deinterlace and denoise settings in
tweaks mode. replaces GtkComboBox with GtkComboBoxEntry.
add easter egg that gives access to hidden preferences
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1649 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | gtk/src/callbacks.c | 132 | ||||
-rw-r--r-- | gtk/src/ghb.ui | 249 | ||||
-rw-r--r-- | gtk/src/hb-backend.c | 101 | ||||
-rw-r--r-- | gtk/src/internal_defaults | 2 | ||||
-rw-r--r-- | gtk/src/internal_defaults.h | 2 | ||||
-rw-r--r-- | gtk/src/main.c | 12 | ||||
-rw-r--r-- | gtk/src/settings.c | 142 |
7 files changed, 496 insertions, 144 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index 803737241..fe64e2763 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -78,6 +78,7 @@ static dependency_t dep_map[] = {"variable_frame_rate", "framerate", "enable", TRUE}, {"variable_frame_rate", "detelecine", "enable", TRUE}, {"decomb", "deinterlace", "enable", TRUE}, + {"decomb", "tweak_deinterlace", "enable", TRUE}, {"autocrop", "crop_top", "disable", FALSE}, {"autocrop", "crop_bottom", "disable", FALSE}, {"autocrop", "crop_left", "disable", FALSE}, @@ -1204,6 +1205,58 @@ setting_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud) clear_presets_selection(ud); } +static void +validate_filter_widget(signal_user_data_t *ud, const gchar *name) +{ + GtkTreeModel *store; + GtkTreeIter iter; + const gchar *str; + gboolean foundit = FALSE; + GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(ud->builder, name)); + if (ghb_widget_index(GTK_WIDGET(combo)) < 0) + { // Validate user input + const gchar *val = ghb_settings_get_string(ud->settings, name); + store = gtk_combo_box_get_model(combo); + // Check to see if user manually entered one of the combo options + if (gtk_tree_model_get_iter_first(store, &iter)) + { + do + { + gtk_tree_model_get(store, &iter, 0, &str, -1); + if (strcasecmp(val, str) == 0) + { + gtk_combo_box_set_active_iter(combo, &iter); + foundit = TRUE; + break; + } + } while (gtk_tree_model_iter_next(store, &iter)); + } + if (!foundit) + { // validate format of filter string + if (!ghb_validate_filter_string(val, -1)) + gtk_combo_box_set_active(combo, 0); + } + } +} + +gboolean +deint_tweak_focus_out_cb(GtkWidget *widget, GdkEventFocus *event, + signal_user_data_t *ud) +{ + g_debug("deint_tweak_focus_out_cb ()\n"); + validate_filter_widget(ud, "tweak_deinterlace"); + return FALSE; +} + +gboolean +denoise_tweak_focus_out_cb(GtkWidget *widget, GdkEventFocus *event, + signal_user_data_t *ud) +{ + g_debug("denoise_tweak_focus_out_cb ()\n"); + validate_filter_widget(ud, "tweak_noise"); + return FALSE; +} + void http_opt_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { @@ -3323,6 +3376,59 @@ pref_changed_cb(GtkWidget *widget, signal_user_data_t *ud) } void +tweaks_changed_cb(GtkWidget *widget, signal_user_data_t *ud) +{ + g_debug("tweaks_changed_cb\n"); + ghb_widget_to_setting (ud->settings, widget); + const gchar *name = gtk_widget_get_name(widget); + ghb_pref_save(ud->settings, name); + + gboolean tweaks = ghb_settings_get_bool(ud->settings, "allow_tweaks"); + widget = GHB_WIDGET(ud->builder, "deinterlace"); + tweaks ? gtk_widget_hide(widget) : gtk_widget_show(widget); + widget = GHB_WIDGET(ud->builder, "tweak_deinterlace"); + !tweaks ? gtk_widget_hide(widget) : gtk_widget_show(widget); + + widget = GHB_WIDGET(ud->builder, "denoise"); + tweaks ? gtk_widget_hide(widget) : gtk_widget_show(widget); + widget = GHB_WIDGET(ud->builder, "tweak_denoise"); + !tweaks ? gtk_widget_hide(widget) : gtk_widget_show(widget); + if (tweaks) + { + const gchar *str; + str = ghb_settings_get_short_opt(ud->settings, "deinterlace"); + ghb_ui_update(ud, "tweak_deinterlace", str); + str = ghb_settings_get_short_opt(ud->settings, "denoise"); + ghb_ui_update(ud, "tweak_denoise", str); + } + else + { + const gchar *str; + str = ghb_settings_get_short_opt(ud->settings, "tweak_deinterlace"); + ghb_ui_update(ud, "deinterlace", str); + str = ghb_settings_get_short_opt(ud->settings, "tweak_denoise"); + ghb_ui_update(ud, "denoise", str); + } +} + +void +hbfd_feature_changed_cb(GtkWidget *widget, signal_user_data_t *ud) +{ + g_debug("hbfd_feature_changed_cb\n"); + ghb_widget_to_setting (ud->settings, widget); + const gchar *name = gtk_widget_get_name(widget); + ghb_pref_save(ud->settings, name); + + gboolean hbfd = ghb_settings_get_bool(ud->settings, "hbfd_feature"); + GtkAction *action; + gint val; + val = ghb_settings_get_int(ud->settings, "hbfd"); + ghb_ui_update_int(ud, "hbfd", hbfd && val); + action = GHB_ACTION (ud->builder, "hbfd"); + gtk_action_set_visible(action, hbfd); +} + +void ghb_file_menu_add_dvd(signal_user_data_t *ud) { GList *link, *drives; @@ -3574,3 +3680,29 @@ tweak_setting_cb( return ret; } +gboolean +easter_egg_cb( + GtkWidget *widget, + GdkEventButton *event, + signal_user_data_t *ud) +{ + g_debug("press %d %d", event->type, event->button); + if (event->type == GDK_3BUTTON_PRESS && event->button == 1) + { // Its a tripple left mouse button click + GtkWidget *widget; + widget = GHB_WIDGET(ud->builder, "allow_tweaks"); + gtk_widget_show(widget); + widget = GHB_WIDGET(ud->builder, "hbfd_feature"); + gtk_widget_show(widget); + } + else if (event->type == GDK_BUTTON_PRESS && event->button == 1) + { + GtkWidget *widget; + widget = GHB_WIDGET(ud->builder, "allow_tweaks"); + gtk_widget_hide(widget); + widget = GHB_WIDGET(ud->builder, "hbfd_feature"); + gtk_widget_hide(widget); + } + return FALSE; +} + diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui index 594388be3..9128e7ef8 100644 --- a/gtk/src/ghb.ui +++ b/gtk/src/ghb.ui @@ -1337,6 +1337,7 @@ <object class="GtkCheckButton" id="deblock"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="tooltip-text" translatable="yes">This is a filter that gets applied before encoding. If the source looks blocky before encoding, you may want to use this.</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">Deblock</property> <property name="draw_indicator">True</property> @@ -1353,22 +1354,14 @@ <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="GtkEventBox" id="tweak_deinterlace"> + <object class="GtkLabel" id="label20"> <property name="visible">True</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> + <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> <packing> <property name="expand">False</property> @@ -1386,6 +1379,23 @@ <property name="position">1</property> </packing> </child> + <child> + <object class="GtkComboBoxEntry" id="tweak_deinterlace"> + <property name="visible">False</property> + <signal handler="setting_widget_changed_cb" name="changed"/> + <child internal-child="entry"> + <object class="GtkEntry" id="comboboxentry-entry1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <signal handler="deint_tweak_focus_out_cb" name="focus_out_event"/> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="position">2</property> + </packing> + </child> </object> <packing> <property name="expand">False</property> @@ -1398,21 +1408,13 @@ <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="GtkEventBox" id="tweak_denoise"> + <object class="GtkLabel" id="label21"> <property name="visible">True</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> + <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> <packing> <property name="expand">False</property> @@ -1430,6 +1432,23 @@ <property name="position">1</property> </packing> </child> + <child> + <object class="GtkComboBoxEntry" id="tweak_denoise"> + <property name="visible">False</property> + <signal handler="setting_widget_changed_cb" name="changed"/> + <child internal-child="entry"> + <object class="GtkEntry" id="comboboxentry-entry2"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <signal handler="denoise_tweak_focus_out_cb" name="focus_out_event"/> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="position">2</property> + </packing> + </child> </object> <packing> <property name="expand">False</property> @@ -3314,97 +3333,155 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property> <property name="skip_taskbar_hint">True</property> <property name="skip_pager_hint">True</property> <property name="has_separator">False</property> - <signal handler="gtk_widget_hide_on_delete" name="delete_event"/> + <signal name="delete_event" handler="gtk_widget_hide_on_delete"/> <child internal-child="vbox"> <object class="GtkVBox" id="dialog-vbox6"> <property name="visible">True</property> <property name="spacing">2</property> <child> - <object class="GtkFrame" id="frame16"> + <object class="GtkHBox" id="hbox24"> <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="shadow_type">GTK_SHADOW_ETCHED_OUT</property> <child> - <object class="GtkAlignment" id="alignment2"> + <object class="GtkVBox" id="vbox19"> <property name="visible">True</property> - <property name="left_padding">12</property> <child> - <object class="GtkVBox" id="vbox29"> + <object class="GtkEventBox" id="eventbox1"> <property name="visible">True</property> + <property name="events">GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_STRUCTURE_MASK</property> + <property name="visible_window">False</property> + <property name="above_child">True</property> + <signal name="button_press_event" handler="easter_egg_cb"/> <child> - <object class="GtkCheckButton" id="use_source_name"> + <object class="GtkImage" id="image3"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="tooltip-text" translatable="yes">The destination filename will be automatically -generated from the source filename or volume -label.</property> - <property name="label" translatable="yes">Derive destination name from source</property> - <property name="draw_indicator">True</property> - <signal handler="pref_changed_cb" name="toggled"/> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="icon_size">6</property> + <property name="icon_name">hb-icon</property> </object> </child> + </object> + <packing> + <property name="expand">False</property> + </packing> + </child> + <child> + <placeholder/> + </child> + </object> + </child> + <child> + <object class="GtkFrame" id="frame16"> + <property name="visible">True</property> + <property name="label_xalign">0</property> + <property name="shadow_type">GTK_SHADOW_ETCHED_OUT</property> + <child> + <object class="GtkAlignment" id="alignment6"> + <property name="visible">True</property> + <property name="left_padding">12</property> <child> - <object class="GtkCheckButton" id="linear_vquality"> + <object class="GtkVBox" id="vbox29"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="tooltip-text" translatable="yes">x264 uses a different scale for video quality than + <child> + <object class="GtkCheckButton" id="use_source_name"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="tooltip_text">The destination filename will be automatically +generated from the source filename or volume +label.</property> + <property name="label" translatable="yes">Derive destination name from source</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="pref_changed_cb"/> + </object> + </child> + <child> + <object class="GtkCheckButton" id="linear_vquality"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="tooltip_text">x264 uses a different scale for video quality than other codecs. This adjusts the scale so that similar values give similar quality across all the video codecs.</property> - <property name="label" translatable="yes">Adjust x264 video quality scale</property> - <property name="draw_indicator">True</property> - <signal handler="pref_changed_cb" name="toggled"/> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="noscale"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="tooltip-text" translatable="yes">When picture settings require that the image + <property name="label" translatable="yes">Adjust x264 video quality scale</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="pref_changed_cb"/> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="noscale"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="tooltip_text">When picture settings require that the image dimensions be rounded to some multiple number of pixels. This setting will crop a few extra pixels instead of doing exact cropping and scaling to the required multiple.</property> - <property name="label" translatable="yes">Loose cropping</property> - <property name="draw_indicator">True</property> - <signal handler="pref_changed_cb" name="toggled"/> - </object> - <packing> - <property name="position">2</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="directqp"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="tooltip-text" translatable="yes">HandBrake allows entry of QP/CRF values for x264 + <property name="label" translatable="yes">Loose cropping</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="pref_changed_cb"/> + </object> + <packing> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="directqp"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="tooltip_text">HandBrake allows entry of QP/CRF values for x264 and FFMPEG instead of the percentage metric. This preference is associated with the current preset only. You *MUST* save the current preset to preserve this setting.</property> - <property name="label" translatable="yes">Allow direct QP/CRF</property> - <property name="draw_indicator">True</property> - <signal handler="vcodec_changed_cb" name="toggled"/> + <property name="label" translatable="yes">Allow direct QP/CRF</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="vcodec_changed_cb"/> + </object> + <packing> + <property name="position">3</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="allow_tweaks"> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Allow Tweaks</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="tweaks_changed_cb"/> + </object> + <packing> + <property name="position">4</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="hbfd_feature"> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Allow HandBrake For Dummies</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="hbfd_feature_changed_cb"/> + </object> + <packing> + <property name="position">5</property> + </packing> + </child> </object> - <packing> - <property name="position">3</property> - </packing> </child> </object> </child> + <child type="label"> + <object class="GtkLabel" id="label18"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Preferences</b></property> + <property name="use_markup">True</property> + </object> + </child> </object> - </child> - <child type="label"> - <object class="GtkLabel" id="label7"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Preferences</b></property> - <property name="use_markup">True</property> - </object> + <packing> + <property name="position">1</property> + </packing> </child> </object> <packing> diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index 376166426..bba5cac61 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -837,6 +837,28 @@ init_combo_box(GtkBuilder *builder, const gchar *name) "text", 0, "sensitive", 1, NULL); } +// Set up the model for the combo box +static void +init_combo_box_entry(GtkBuilder *builder, const gchar *name) +{ + GtkComboBox *combo; + GtkListStore *store; + + g_debug("init_combo_box_entry() %s\n", name); + // First modify the combobox model to allow greying out of options + combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name)); + // Store contains: + // 1 - String to display + // 2 - bool indicating whether the entry is selectable (grey or not) + // 3 - String that is used for presets + // 4 - Int value determined by backend + // 5 - String value determined by backend + store = gtk_list_store_new(5, G_TYPE_STRING, G_TYPE_BOOLEAN, + G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING); + gtk_combo_box_set_model(combo, GTK_TREE_MODEL(store)); + gtk_combo_box_entry_set_text_column(GTK_COMBO_BOX_ENTRY(combo), 0); +} + static void audio_bitrate_opts_set(GtkBuilder *builder, const gchar *name, hb_rate_t *rates, gint count) { @@ -1383,8 +1405,12 @@ ghb_update_ui_combo_box(GtkBuilder *builder, const gchar *name, gint user_data, generic_opts_set(builder, "container", &container_opts); if (all || strcmp(name, "deinterlace") == 0) generic_opts_set(builder, "deinterlace", &deint_opts); + if (all || strcmp(name, "tweak_deinterlace") == 0) + generic_opts_set(builder, "tweak_deinterlace", &deint_opts); if (all || strcmp(name, "denoise") == 0) generic_opts_set(builder, "denoise", &denoise_opts); + if (all || strcmp(name, "tweak_denoise") == 0) + generic_opts_set(builder, "tweak_denoise", &denoise_opts); if (all || strcmp(name, "video_codec") == 0) generic_opts_set(builder, "video_codec", &vcodec_opts); if (all || strcmp(name, "audio_codec") == 0) @@ -1418,7 +1444,9 @@ init_ui_combo_boxes(GtkBuilder *builder) init_combo_box(builder, "audio_track"); init_combo_box(builder, "container"); init_combo_box(builder, "deinterlace"); + init_combo_box_entry(builder, "tweak_deinterlace"); init_combo_box(builder, "denoise"); + init_combo_box_entry(builder, "tweak_denoise"); init_combo_box(builder, "video_codec"); init_combo_box(builder, "audio_codec"); init_combo_box(builder, "x264_direct"); @@ -2054,6 +2082,7 @@ ghb_validate_filters(signal_user_data_t *ud) { gboolean tweaks; const gchar *str; + gint index; gchar *message; gboolean enabled; @@ -2085,16 +2114,19 @@ ghb_validate_filters(signal_user_data_t *ud) 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)) + index = ghb_settings_get_index(ud->settings, "tweak_deinterlace"); + if (index < 0) { - 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; + str = ghb_settings_get_string(ud->settings, "tweak_deinterlace"); + if (!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"); @@ -2109,16 +2141,19 @@ ghb_validate_filters(signal_user_data_t *ud) 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)) + index = ghb_settings_get_index(ud->settings, "tweak_denoise"); + if (index < 0) { - 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; + str = ghb_settings_get_string(ud->settings, "tweak_denoise"); + if (!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; @@ -2534,7 +2569,8 @@ ghb_add_job(job_settings_t *js, gint unique_id) gboolean decomb = ghb_settings_get_bool(settings, "decomb"); - gint deint = ghb_settings_get_int(settings, "deinterlace"); + gint deint = ghb_settings_get_int( + settings, tweaks ? "tweak_deinterlace":"deinterlace"); if (!decomb) job->deinterlace = (deint == 0) ? 0 : 1; else @@ -2596,16 +2632,8 @@ ghb_add_job(job_settings_t *js, gint unique_id) } 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_filter_deinterlace.settings = (gchar*)ghb_settings_get_string( + settings, tweaks ? "tweak_deinterlace" : "deinterlace"); hb_list_add( job->filters, &hb_filter_deinterlace ); } if( ghb_settings_get_bool(settings, "deblock") ) @@ -2622,19 +2650,12 @@ ghb_add_job(job_settings_t *js, gint unique_id) } hb_list_add( job->filters, &hb_filter_deblock ); } - gint denoise = ghb_settings_get_int(settings, "denoise"); + gint denoise = ghb_settings_get_int( + settings, tweaks ? "tweak_denoise" : "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_filter_denoise.settings = (gchar*)ghb_settings_get_string( + settings, tweaks ? "tweak_denoise" : "denoise"); hb_list_add( job->filters, &hb_filter_denoise ); } job->width = ghb_settings_get_int(settings, "scale_width"); diff --git a/gtk/src/internal_defaults b/gtk/src/internal_defaults index 4fb15f229..258653dc4 100644 --- a/gtk/src/internal_defaults +++ b/gtk/src/internal_defaults @@ -27,8 +27,6 @@ deblock=disable tweak_decomb= tweak_detelecine= tweak_deblock= -tweak_deinterlace= -tweak_denoise= grayscale=disable video_codec=x264 two_pass=disable diff --git a/gtk/src/internal_defaults.h b/gtk/src/internal_defaults.h index fbd2d3506..f1b6b7e51 100644 --- a/gtk/src/internal_defaults.h +++ b/gtk/src/internal_defaults.h @@ -27,8 +27,6 @@ "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" diff --git a/gtk/src/main.c b/gtk/src/main.c index 18d64da13..3c4039cff 100644 --- a/gtk/src/main.c +++ b/gtk/src/main.c @@ -548,6 +548,18 @@ main (int argc, char *argv[]) ghb_hbfd(ud, TRUE); } const gchar *source = ghb_settings_get_string(ud->settings, "default_source"); + gboolean tweaks = ghb_settings_get_bool(ud->settings, "allow_tweaks"); + GtkWidget *widget; + widget = GHB_WIDGET(ud->builder, "deinterlace"); + tweaks ? gtk_widget_hide(widget) : gtk_widget_show(widget); + widget = GHB_WIDGET(ud->builder, "tweak_deinterlace"); + !tweaks ? gtk_widget_hide(widget) : gtk_widget_show(widget); + + widget = GHB_WIDGET(ud->builder, "denoise"); + tweaks ? gtk_widget_hide(widget) : gtk_widget_show(widget); + widget = GHB_WIDGET(ud->builder, "tweak_denoise"); + !tweaks ? gtk_widget_hide(widget) : gtk_widget_show(widget); + ghb_dvd_set_current(source, ud); // Start the show. window = GHB_WIDGET (ud->builder, "hb_window"); diff --git a/gtk/src/settings.c b/gtk/src/settings.c index 662561038..da43a9877 100644 --- a/gtk/src/settings.c +++ b/gtk/src/settings.c @@ -92,7 +92,7 @@ static void settings_set(GHashTable *settings, const gchar *key, const gchar *str, gint val, gdouble dbl) { - g_debug("ghb_setting_set () key (%s), svalue (%s), ivalue %d, dvalue %.2g\n", key, str, val, dbl); + g_debug("setting_set () key (%s), svalue (%s), ivalue %d, dvalue %.2g\n", key, str, val, dbl); setting_value_t *value = g_malloc(sizeof(setting_value_t)); if (str != NULL) value->svalue = g_strdup(str); @@ -128,7 +128,9 @@ ghb_settings_set(GHashTable *settings, const gchar *key, setting_value_t *value) g_debug("Bad key or value\n"); return; } - g_debug("\tkey (%s) -- value (%s)\n", key, value->svalue); + g_debug("ghb_settings_set key (%s) -- value (%d,%d,%s,%s,%s)\n", key, + value->index, value->ivalue, value->option, value->shortOpt, + value->svalue); g_hash_table_insert(settings, g_strdup(key), value); } @@ -435,7 +437,6 @@ ghb_widget_value(GtkWidget *widget) gtk_tree_model_get(store, &iter, 0, &option, 2, &shortOpt, 3, &ivalue, 4, &svalue, -1); - g_debug("\tcombo: index %d opt (%s) Short Opt (%s) value %d\n", index, option, shortOpt, ivalue); value->option = option; value->shortOpt = shortOpt; value->svalue = svalue; @@ -453,6 +454,39 @@ ghb_widget_value(GtkWidget *widget) value->dvalue = 0; } } + else if (type == GTK_TYPE_COMBO_BOX_ENTRY) + { + GtkTreeModel *store; + GtkTreeIter iter; + gchar *shortOpt, *option, *svalue; + gint ivalue; + gint index = gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); + + store = gtk_combo_box_get_model(GTK_COMBO_BOX(widget)); + if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget), &iter)) + { + gtk_tree_model_get(store, &iter, 0, &option, 2, &shortOpt, + 3, &ivalue, 4, &svalue, -1); + + value->option = option; + value->shortOpt = shortOpt; + value->svalue = svalue; + value->index = index; + value->ivalue = ivalue; + value->dvalue = ivalue; + } + else + { + const gchar *str = gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget)); + if (str == NULL) str = ""; + value->option = g_strdup(str); + value->shortOpt = g_strdup(str); + value->svalue = g_strdup(str); + value->index = -1; + value->ivalue = -1; + value->dvalue = 0; + } + } else if (type == GTK_TYPE_SPIN_BUTTON) { value->index = 0; @@ -674,7 +708,7 @@ update_widget(GtkWidget *widget, const gchar *parm_svalue, gint parm_ivalue) gint ivalue; gboolean foundit = FALSE; - g_debug("combo"); + g_debug("combo (%s)", value); store = gtk_combo_box_get_model(GTK_COMBO_BOX(widget)); if (gtk_tree_model_get_iter_first (store, &iter)) { @@ -703,6 +737,47 @@ update_widget(GtkWidget *widget, const gchar *parm_svalue, gint parm_ivalue) gtk_combo_box_set_active (GTK_COMBO_BOX(widget), 0); } } + else if (type == GTK_TYPE_COMBO_BOX_ENTRY) + { + GtkTreeModel *store; + GtkTreeIter iter; + gchar *shortOpt; + gint ivalue; + gboolean foundit = FALSE; + + g_debug("GTK_COMBO_BOX_ENTRY"); + store = gtk_combo_box_get_model(GTK_COMBO_BOX(widget)); + if (gtk_tree_model_get_iter_first (store, &iter)) + { + do + { + gtk_tree_model_get(store, &iter, 2, &shortOpt, 3, &ivalue, -1); + if (parm_svalue == NULL && ivalue == parm_ivalue) + { + gtk_combo_box_set_active_iter (GTK_COMBO_BOX(widget), &iter); + g_free(shortOpt); + foundit = TRUE; + break; + } + else if (strcmp(shortOpt, value) == 0) + { + gtk_combo_box_set_active_iter (GTK_COMBO_BOX(widget), &iter); + g_free(shortOpt); + foundit = TRUE; + break; + } + g_free(shortOpt); + } while (gtk_tree_model_iter_next (store, &iter)); + } + if (!foundit) + { + GtkEntry *entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(widget))); + if (entry) + { + gtk_entry_set_text (entry, value); + } + } + } else if (type == GTK_TYPE_SPIN_BUTTON) { gdouble val; @@ -967,6 +1042,28 @@ ghb_presets_get_name(gint index) return result; } +static gchar* +preset_get_string( + GKeyFile *keyFile, + const gchar *name, + const gchar *key) +{ + gchar *str; + + g_debug("preset (%s) key (%s)\n", name, key); + str = NULL; + if (name != NULL && keyFile != NULL) + { + str = g_key_file_get_string(keyFile, name, key, NULL); + g_debug("(%s, %s)\n", key, str); + } + if (str == NULL) + { + str = g_key_file_get_string(internalKeyFile, "Presets", key, NULL); + } + return str; +} + static gboolean init_presets_hash_from_key_file(signal_user_data_t *ud, const gchar *name, GKeyFile *keyFile) { @@ -983,16 +1080,7 @@ init_presets_hash_from_key_file(signal_user_data_t *ud, const gchar *name, GKeyF for (ii = 0; keys[ii] != NULL; ii++) { g_debug("key (%s)\n", keys[ii]); - str = NULL; - if (name != NULL && keyFile != NULL) - { - str = g_key_file_get_string(keyFile, name, keys[ii], NULL); - g_debug("(%s, %s)\n", keys[ii], str); - } - if (str == NULL) - { - str = g_key_file_get_string(internalKeyFile, "Presets", keys[ii], NULL); - } + str = preset_get_string(keyFile, name, keys[ii]); if (str != NULL) { g_debug("name (%s): key (%s) -- str (%s)\n", name, keys[ii], str); @@ -1024,6 +1112,22 @@ preset_to_ui(signal_user_data_t *ud, presets_data_t *data) // Initialize from preset init_presets_hash_from_key_file(ud, data->name, data->keyFile); } + if (ghb_settings_get_bool(ud->settings, "allow_tweaks")) + { + gchar *str; + str = preset_get_string(data->keyFile, data->name, "deinterlace"); + if (str) + { + ghb_ui_update(ud, "tweak_deinterlace", str); + g_free(str); + } + str = preset_get_string(data->keyFile, data->name, "denoise"); + if (str) + { + ghb_ui_update(ud, "tweak_denoise", str); + g_free(str); + } + } } static void @@ -1506,6 +1610,16 @@ ghb_settings_save(signal_user_data_t *ud, const gchar *name) g_debug("ghb_settings_save ()\n"); ski.name = name; ski.keyFile = customKeyFile; + if (ghb_settings_get_bool(ud->settings, "allow_tweaks")) + { + const gchar *str; + str = ghb_settings_get_short_opt(ud->settings, "tweak_deinterlace"); + if (str) + ghb_settings_set_string(ud->settings, "deinterlace", str); + str = ghb_settings_get_short_opt(ud->settings, "tweak_denoise"); + if (str) + ghb_settings_set_string(ud->settings, "denoise", str); + } ski.autoscale = ghb_settings_get_bool (ud->settings, "autoscale"); g_hash_table_foreach(ud->settings, store_to_key_file, &ski); presets_store(); |