OSDN Git Service

LinGui: remove target file size option
[handbrake-jp/handbrake-jp-git.git] / gtk / src / presets.c
index fe6493d..2e231bf 100644 (file)
@@ -1,7 +1,7 @@
 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
 /*
  * presets.c
- * Copyright (C) John Stebbins 2008 <stebbins@stebbins>
+ * Copyright (C) John Stebbins 2008-2011 <stebbins@stebbins>
  * 
  * presets.c is free software.
  * 
@@ -906,6 +906,29 @@ preset_to_ui(signal_user_data_t *ud, GValue *dict)
        init_settings_from_dict(ud->settings, hidden, dict);
        init_ui_from_dict(ud, internal, dict);
        init_ui_from_dict(ud, hidden, dict);
+
+       if (dict != NULL)
+       {
+               GValue *val;
+               gboolean dd;
+
+               val = ghb_dict_lookup(dict, "PictureDecombDeinterlace");
+               if (val != NULL)
+               {
+                       dd = ghb_value_boolean(val);
+                       ghb_ui_update(ud, "PictureDeinterlaceDecomb", ghb_boolean_value(!dd));
+               }
+               val = ghb_dict_lookup(dict, "PictureHeight");
+               if (val != NULL)
+               {
+                       ghb_ui_update(ud, "scale_height", val);
+               }
+               val = ghb_dict_lookup(dict, "PictureWidth");
+               if (val != NULL)
+               {
+                       ghb_ui_update(ud, "scale_width", val);
+               }
+       }
 }
 
 void
@@ -1138,6 +1161,113 @@ ghb_lock_file(const gchar *name)
 #endif
 }
 
+void
+ghb_write_pid_file()
+{
+#if !defined(_WIN32)
+       gchar *config, *path;
+       pid_t pid;
+       FILE *fp;
+       int fd, lock;
+
+       pid = getpid();
+
+       config = ghb_get_user_config_dir(NULL);
+       path = g_strdup_printf ("%s/ghb.pid.%d", config, pid);
+
+       fp = g_fopen(path, "w");
+       fprintf(fp, "%d\n", pid);
+       fclose(fp);
+
+       fd = open(path, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR);
+       lock = lockf(fd, F_TLOCK, 0);
+
+       g_free(config);
+       g_free(path);
+#endif
+}
+
+void
+ghb_unlink_pid_file(int pid)
+{
+       gchar *config, *path;
+
+       config = ghb_get_user_config_dir(NULL);
+       path = g_strdup_printf ("%s/ghb.pid.%d", config, pid);
+
+       if (g_file_test(path, G_FILE_TEST_IS_REGULAR))
+       {
+               g_unlink(path);
+       }
+
+       g_free(config);
+       g_free(path);
+}
+
+int
+ghb_find_pid_file()
+{
+       const gchar *file;
+       gchar *config;
+
+       config = ghb_get_user_config_dir(NULL);
+
+       if (g_file_test(config, G_FILE_TEST_IS_DIR))
+       {
+               GDir *gdir = g_dir_open(config, 0, NULL);
+               file = g_dir_read_name(gdir);
+               while (file)
+               {
+                       if (strncmp(file, "ghb.pid.", 8) == 0)
+                       {
+                               gchar *path;
+                               pid_t my_pid;
+                               int pid;
+
+                               sscanf(file, "ghb.pid.%d", &pid);
+                               my_pid = getpid();
+                               if (my_pid == pid)
+                               {
+                                       file = g_dir_read_name(gdir);
+                                       continue;
+                               }
+                               path = g_strdup_printf("%s/%s", config, file);
+
+#if !defined(_WIN32)
+                               int fd, lock = 1;
+
+                               fd = open(path, O_RDWR);
+                               if (fd >= 0)
+                               {
+                                       lock = lockf(fd, F_TLOCK, 0);
+                               }
+                               if (lock == 0)
+                               {
+                                       close(fd);
+                                       g_dir_close(gdir);
+                                       g_unlink(path);
+                                       g_free(path);
+                                       g_free(config);
+                                       return pid;
+                               }
+                               g_free(path);
+                               close(fd);
+#else
+                               g_dir_close(gdir);
+                               g_unlink(path);
+                               g_free(path);
+                               g_free(config);
+                               return pid;
+#endif
+                       }
+                       file = g_dir_read_name(gdir);
+               }
+               g_dir_close(gdir);
+       }
+       g_free(config);
+       return -1;
+}
+
 static void
 remove_plist(const gchar *name)
 {
@@ -1228,7 +1358,7 @@ ghb_prefs_to_ui(signal_user_data_t *ud)
                ghb_ui_update(ud, "hbfd", ghb_int64_value(0));
        }
        gval = ghb_settings_get_value(ud->settings, "default_source");
-       ghb_settings_set_value (ud->settings, "source", gval);
+       ghb_settings_set_value (ud->settings, "scan_source", gval);
 
        str = ghb_settings_get_string(ud->settings, "destination_dir");
        ghb_ui_update(ud, "dest_dir", ghb_string_value(str));
@@ -1793,19 +1923,61 @@ remove_std_presets(signal_user_data_t *ud)
 void
 ghb_save_queue(GValue *queue)
 {
-       store_plist(queue, "queue");
+       pid_t pid;
+       char *path;
+
+       pid = getpid();
+       path = g_strdup_printf ("queue.%d", pid);
+       store_plist(queue, path);
+       g_free(path);
 }
 
 GValue*
 ghb_load_queue()
 {
-       return load_plist("queue");
+       GValue *queue;
+       pid_t pid;
+       char *path;
+
+       pid = getpid();
+       path = g_strdup_printf ("queue.%d", pid);
+       queue = load_plist(path);
+       g_free(path);
+       return queue;
+}
+
+GValue*
+ghb_load_old_queue(int pid)
+{
+       GValue *queue;
+       char *path;
+
+       path = g_strdup_printf ("queue.%d", pid);
+       queue = load_plist(path);
+       g_free(path);
+       return queue;
+}
+
+void
+ghb_remove_old_queue_file(int pid)
+{
+       char *path;
+
+       path = g_strdup_printf ("queue.%d", pid);
+       remove_plist(path);
+       g_free(path);
 }
 
 void
 ghb_remove_queue_file()
 {
-       remove_plist("queue");
+       pid_t pid;
+       char *path;
+
+       pid = getpid();
+       path = g_strdup_printf ("queue.%d", pid);
+       remove_plist(path);
+       g_free(path);
 }
 
 typedef struct
@@ -1827,7 +1999,8 @@ static value_map_t acodec_xlat[] =
 {
        {"AAC (faac)", "faac"},
        {"AAC (CoreAudio)", "faac"},
-       {"AC3 Passthru", "ac3"},
+       {"AC3 Passthru", "ac3pass"},
+       {"DTS Passthru", "dtspass"},
        {"MP3 (lame)", "lame"},
        {"Vorbis (vorbis)", "vorbis"},
        {NULL,NULL}
@@ -1850,10 +2023,10 @@ value_map_t framerate_xlat[] =
        {"10", "10"},
        {"12", "12"},
        {"15", "15"},
-       {"23.976", "23.976"},
+       {"23.976 (NTSC Film)", "23.976"},
        {"24", "24"},
-       {"25", "25"},
-       {"29.97", "29.97"},
+       {"25 (PAL Film/Video)", "25"},
+       {"29.97 (NTSC Video)", "29.97"},
        {NULL, NULL}
 };
 
@@ -2470,21 +2643,18 @@ import_xlat_preset(GValue *dict)
        } break;
        }
        // VideoQualityType/0/1/2 - vquality_type_/target/bitrate/constant
+       // *note: target is no longer used
        switch (vqtype)
        {
        case 0:
        {
-               ghb_dict_insert(dict, g_strdup("vquality_type_target"), 
-                                               ghb_boolean_value_new(TRUE));
                ghb_dict_insert(dict, g_strdup("vquality_type_bitrate"), 
-                                               ghb_boolean_value_new(FALSE));
+                                               ghb_boolean_value_new(TRUE));
                ghb_dict_insert(dict, g_strdup("vquality_type_constant"), 
                                                ghb_boolean_value_new(FALSE));
        } break;
        case 1:
        {
-               ghb_dict_insert(dict, g_strdup("vquality_type_target"), 
-                                               ghb_boolean_value_new(FALSE));
                ghb_dict_insert(dict, g_strdup("vquality_type_bitrate"), 
                                                ghb_boolean_value_new(TRUE));
                ghb_dict_insert(dict, g_strdup("vquality_type_constant"), 
@@ -2492,8 +2662,6 @@ import_xlat_preset(GValue *dict)
        } break;
        case 2:
        {
-               ghb_dict_insert(dict, g_strdup("vquality_type_target"), 
-                                               ghb_boolean_value_new(FALSE));
                ghb_dict_insert(dict, g_strdup("vquality_type_bitrate"), 
                                                ghb_boolean_value_new(FALSE));
                ghb_dict_insert(dict, g_strdup("vquality_type_constant"), 
@@ -2501,21 +2669,92 @@ import_xlat_preset(GValue *dict)
        } break;
        default:
        {
-               ghb_dict_insert(dict, g_strdup("vquality_type_target"), 
-                                               ghb_boolean_value_new(FALSE));
                ghb_dict_insert(dict, g_strdup("vquality_type_bitrate"), 
                                                ghb_boolean_value_new(FALSE));
                ghb_dict_insert(dict, g_strdup("vquality_type_constant"), 
                                                ghb_boolean_value_new(TRUE));
        } break;
        }
+
        import_value_xlat(dict);
 
+       GValue *mode = ghb_dict_lookup(dict, "VideoFramerateMode");
+       if (mode == NULL)
+       {
+               GValue *fr = ghb_dict_lookup(dict, "VideoFramerate");
+               if (fr)
+               {
+                       gchar *str;
+                       gboolean pfr = FALSE;
+                       GValue *pfr_val = ghb_dict_lookup(dict, "VideoFrameratePFR");
+                       if (pfr_val)
+                       {
+                               pfr = ghb_value_boolean(pfr_val);
+                       }
+                       str = ghb_value_string(fr);
+                       if (strcmp(str, "source") == 0)
+                       {
+                               ghb_dict_insert(dict, g_strdup("VideoFramerateCFR"), 
+                                                               ghb_boolean_value_new(FALSE));
+                               ghb_dict_insert(dict, g_strdup("VideoFramerateVFR"), 
+                                                               ghb_boolean_value_new(TRUE));
+                       }
+                       else if (!pfr)
+                       {
+                               ghb_dict_insert(dict, g_strdup("VideoFramerateCFR"), 
+                                                               ghb_boolean_value_new(TRUE));
+                               ghb_dict_insert(dict, g_strdup("VideoFramerateVFR"), 
+                                                               ghb_boolean_value_new(FALSE));
+                       }
+                       else
+                       {
+                               ghb_dict_insert(dict, g_strdup("VideoFramerateCFR"), 
+                                                               ghb_boolean_value_new(FALSE));
+                               ghb_dict_insert(dict, g_strdup("VideoFramerateVFR"), 
+                                                               ghb_boolean_value_new(FALSE));
+                       }
+            g_free(str);
+               }
+       }
+       else
+       {
+               gchar *str;
+               str = ghb_value_string(mode);
+               if (strcmp(str, "cfr") == 0)
+               {
+                               ghb_dict_insert(dict, g_strdup("VideoFramerateCFR"), 
+                                                               ghb_boolean_value_new(TRUE));
+                               ghb_dict_insert(dict, g_strdup("VideoFrameratePFR"), 
+                                                               ghb_boolean_value_new(FALSE));
+                               ghb_dict_insert(dict, g_strdup("VideoFramerateVFR"), 
+                                                               ghb_boolean_value_new(FALSE));
+               }
+               else if (strcmp(str, "pfr") == 0)
+               {
+                               ghb_dict_insert(dict, g_strdup("VideoFramerateCFR"), 
+                                                               ghb_boolean_value_new(FALSE));
+                               ghb_dict_insert(dict, g_strdup("VideoFrameratePFR"), 
+                                                               ghb_boolean_value_new(TRUE));
+                               ghb_dict_insert(dict, g_strdup("VideoFramerateVFR"), 
+                                                               ghb_boolean_value_new(FALSE));
+               }
+               else
+               {
+                               ghb_dict_insert(dict, g_strdup("VideoFramerateCFR"), 
+                                                               ghb_boolean_value_new(FALSE));
+                               ghb_dict_insert(dict, g_strdup("VideoFrameratePFR"), 
+                                                               ghb_boolean_value_new(FALSE));
+                               ghb_dict_insert(dict, g_strdup("VideoFramerateVFR"), 
+                                                               ghb_boolean_value_new(TRUE));
+               }
+               g_free(str);
+       }
+
        gdouble vquality;
        const GValue *gval;
 
        vquality = ghb_value_double(preset_dict_get_value(dict, "VideoQualitySlider"));
-       if (vquality < 1.0)
+       if (vquality > 0.0 && vquality < 1.0)
        {
                gint vcodec;
 
@@ -2579,12 +2818,10 @@ import_xlat_presets(GValue *presets)
 static void
 export_xlat_preset(GValue *dict)
 {
-       gboolean autoscale, target, br, constant;
+       gboolean autoscale, br, constant;
 
        g_debug("export_xlat_prest ()");
        autoscale = ghb_value_boolean(preset_dict_get_value(dict, "autoscale"));
-       target = ghb_value_boolean(
-                               preset_dict_get_value(dict, "vquality_type_target"));
        br = ghb_value_boolean(
                                preset_dict_get_value(dict, "vquality_type_bitrate"));
        constant = ghb_value_boolean(
@@ -2598,12 +2835,8 @@ export_xlat_preset(GValue *dict)
                                                ghb_int_value_new(1));
 
        // VideoQualityType/0/1/2 - vquality_type_/target/bitrate/constant
-       if (target)
-       {
-               ghb_dict_insert(dict, g_strdup("VideoQualityType"), 
-                                               ghb_int_value_new(0));
-       }
-       else if (br)
+       // *note: target is no longer used
+       if (br)
        {
                ghb_dict_insert(dict, g_strdup("VideoQualityType"), 
                                                ghb_int_value_new(1));
@@ -2614,6 +2847,22 @@ export_xlat_preset(GValue *dict)
                                                ghb_int_value_new(2));
        }
 
+       if (ghb_value_boolean(preset_dict_get_value(dict, "VideoFramerateCFR")))
+       {
+               ghb_dict_insert(dict, g_strdup("VideoFramerateMode"), 
+                                               ghb_string_value_new("cfr"));
+       }
+       else if (ghb_value_boolean(preset_dict_get_value(dict, "VideoFrameratePFR")))
+       {
+               ghb_dict_insert(dict, g_strdup("VideoFramerateMode"), 
+                                               ghb_string_value_new("pfr"));
+       }
+       else
+       {
+               ghb_dict_insert(dict, g_strdup("VideoFramerateMode"), 
+                                               ghb_string_value_new("vfr"));
+       }
+
        GValue *alist, *adict;
        gint count, ii;
 
@@ -2633,11 +2882,25 @@ export_xlat_preset(GValue *dict)
                }
        }
 
+       GValue *internal;
+       GHashTableIter iter;
+       gchar *key;
+       GValue *value;
+       internal = plist_get_dict(internalPlist, "XlatPresets");
+       ghb_dict_iter_init(&iter, internal);
+       // middle (void*) cast prevents gcc warning "defreferencing type-punned
+       // pointer will break strict-aliasing rules"
+       while (g_hash_table_iter_next(
+                       &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&value))
+       {
+               ghb_dict_remove(dict, key);
+       }
+
+       // remove obsolete keys
        ghb_dict_remove(dict, "UsesMaxPictureSettings");
-       ghb_dict_remove(dict, "autoscale");
-       ghb_dict_remove(dict, "vquality_type_target");
-       ghb_dict_remove(dict, "vquality_type_bitrate");
-       ghb_dict_remove(dict, "vquality_type_constant");
+       ghb_dict_remove(dict, "VFR");
+       ghb_dict_remove(dict, "VideoFrameratePFR");
+
        export_value_xlat(dict);
 }
 
@@ -2890,7 +3153,6 @@ settings_save(signal_user_data_t *ud, const GValue *path)
        GHashTableIter iter;
        gchar *key;
        GValue *value;
-       gboolean autoscale;
        gint *indices, len, count;
        gint *def_indices, def_len;
        const gchar *name;
@@ -2933,7 +3195,6 @@ settings_save(signal_user_data_t *ud, const GValue *path)
                }
        }
        current_preset = dict;
-       autoscale = ghb_settings_get_boolean(ud->settings, "autoscale");
        ghb_settings_set_int64(ud->settings, "Type", PRESETS_CUSTOM);
        ghb_settings_set_int64(ud->settings, "PresetBuildNumber", hb_get_build(NULL));
 
@@ -2945,21 +3206,8 @@ settings_save(signal_user_data_t *ud, const GValue *path)
                        &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&value))
        {
                const GValue *gval;
-               gchar *key2;
 
-               key2 = key;
-               if (!autoscale)
-               {
-                       if (strcmp(key, "PictureWidth") == 0)
-                       {
-                               key2 = "scale_width";
-                       }
-                       else if (strcmp(key, "PictureHeight") == 0)
-                       {
-                               key2 = "scale_height";
-                       }
-               }
-               gval = ghb_settings_get_value(ud->settings, key2);
+               gval = ghb_settings_get_value(ud->settings, key);
                if (gval == NULL)
                {
                        continue;
@@ -3000,6 +3248,20 @@ settings_save(signal_user_data_t *ud, const GValue *path)
                                                ghb_boolean_value_new(FALSE));
                presets_list_insert(ud, indices, len);
        }
+       if (!ghb_settings_get_boolean( ud->settings, "PictureWidthEnable"))
+       {
+               ghb_dict_remove(dict, "PictureWidth");
+       }
+       if (!ghb_settings_get_boolean( ud->settings, "PictureHeightEnable"))
+       {
+               ghb_dict_remove(dict, "PictureHeight");
+       }
+       ghb_dict_insert(dict, g_strdup("autoscale"), 
+               ghb_boolean_value_new(
+                       !ghb_settings_get_boolean( ud->settings, "PictureWidthEnable") &&
+                       !ghb_settings_get_boolean( ud->settings, "PictureHeightEnable")
+               )
+       );
        store_presets();
        ud->dont_clear_presets = TRUE;
        // Make the new preset the selected item
@@ -3229,7 +3491,6 @@ preset_import_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
                        return;
                }
                array = ghb_plist_parse_file(filename);
-               g_free(filename);
 
                import_xlat_presets(array);
                presets_clear_default(array);
@@ -3279,8 +3540,10 @@ preset_import_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
                        ghb_settings_set_string(ud->settings, "ExportDirectory", dir);
                        ghb_pref_save(ud->settings, "ExportDirectory");
                }
+               g_free(filename);
                g_free(exportDir);
                g_free(dir);
+               store_presets();
        }
        gtk_widget_destroy(dialog);
 }
@@ -3383,7 +3646,7 @@ presets_new_folder_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
        const gchar *description = "";
        gint count, *indices, len;
 
-       g_debug("presets_save_clicked_cb ()");
+       g_debug("presets_new_folder_clicked_cb ()");
        preset = ghb_settings_get_value (ud->settings, "preset_selection");
 
        count = ghb_array_len(preset);
@@ -3398,12 +3661,12 @@ presets_new_folder_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
        {
                description = g_value_get_string(
                                                        ghb_dict_lookup(dict, "PresetDescription"));
-               ghb_ui_update(ud, "PresetDescription", ghb_string_value(description));
+               ghb_ui_update(ud, "FolderDescription", ghb_string_value(description));
        }
 
-       desc = GTK_TEXT_VIEW(GHB_WIDGET(ud->builder, "PresetDescription"));
-       dialog = GHB_WIDGET(ud->builder, "preset_save_dialog");
-       entry = GTK_ENTRY(GHB_WIDGET(ud->builder, "PresetName"));
+       desc = GTK_TEXT_VIEW(GHB_WIDGET(ud->builder, "FolderDescription"));
+       dialog = GHB_WIDGET(ud->builder, "preset_new_folder_dialog");
+       entry = GTK_ENTRY(GHB_WIDGET(ud->builder, "FolderName"));
        gtk_entry_set_text(entry, name);
        response = gtk_dialog_run(GTK_DIALOG(dialog));
        gtk_widget_hide(dialog);
@@ -3428,7 +3691,8 @@ presets_new_folder_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
                        }
                }
                ghb_array_append(dest, ghb_string_value_new(name));
-               ghb_widget_to_setting(ud->settings, GTK_WIDGET(desc));
+               GValue *val = ghb_widget_value(GTK_WIDGET(desc));
+               ghb_settings_set_value(ud->settings, "PresetDescription", val);
                folder_save(ud, dest);
                ghb_value_free(dest);
        }
@@ -3457,6 +3721,23 @@ presets_save_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
                count = 1;
 
        desc = GTK_TEXT_VIEW(GHB_WIDGET(ud->builder, "PresetDescription"));
+       int width = ghb_settings_get_int(ud->settings, "PictureWidth");
+       int height = ghb_settings_get_int(ud->settings, "PictureHeight");
+       gboolean autoscale = ghb_settings_get_boolean(ud->settings, "autoscale");
+       ghb_ui_update(ud, "PictureWidthEnable", 
+               ghb_boolean_value(width!=0&&!autoscale));
+       ghb_ui_update(ud, "PictureHeightEnable", 
+               ghb_boolean_value(height!=0&&!autoscale));
+       if (!width)
+       {
+               width = ghb_settings_get_int(ud->settings, "scale_width");
+               ghb_ui_update(ud, "PictureWidth", ghb_int_value(width));
+       }
+       if (!height)
+       {
+               height = ghb_settings_get_int(ud->settings, "scale_height");
+               ghb_ui_update(ud, "PictureHeight", ghb_int_value(height));
+       }
        dialog = GHB_WIDGET(ud->builder, "preset_save_dialog");
        entry = GTK_ENTRY(GHB_WIDGET(ud->builder, "PresetName"));
        gtk_entry_set_text(entry, name);
@@ -3923,6 +4204,76 @@ preset_update_title_deps(signal_user_data_t *ud, ghb_title_info_t *tinfo)
        }
 }
 
+void
+ghb_refresh_preset(signal_user_data_t *ud)
+{
+       ghb_title_info_t tinfo;
+       GValue *preset;
+       gint *indices, len;
+
+       g_debug("ghb_refresh_preset ()");
+       preset = ghb_settings_get_value(ud->settings, "preset_selection");
+       indices = ghb_preset_indices_from_path(presetsPlist, preset, &len);
+       if (indices)
+       {
+               gboolean folder;
+
+               folder = ghb_presets_get_folder(presetsPlist, indices, len);
+               if (!folder)
+               {
+                       ud->dont_clear_presets = TRUE;
+                       ud->scale_busy = TRUE;
+                       // Temporarily set the video_quality range to (0,100)
+                       // This is needed so the video_quality value does not get
+                       // truncated when set.  The range will be readjusted below
+                       GtkWidget *qp = GHB_WIDGET(ud->builder, "VideoQualitySlider");
+                       gtk_range_set_range (GTK_RANGE(qp), 0, 100);
+                       gtk_scale_set_digits(GTK_SCALE(qp), 3);
+                       // Clear the audio list prior to changing the preset.  Existing 
+                       // audio can cause the container extension to be automatically 
+                       // changed when it shouldn't be
+                       ghb_clear_audio_list(ud);
+                       ghb_set_preset_from_indices(ud, indices, len);
+                       gint titleindex;
+                       titleindex = ghb_settings_combo_int(ud->settings, "title");
+                       ghb_set_pref_audio(titleindex, ud);
+                       ghb_set_pref_subtitle(titleindex, ud);
+                       ghb_settings_set_boolean(ud->settings, "preset_modified", FALSE);
+                       if (ghb_get_title_info (&tinfo, titleindex))
+                       {
+                               preset_update_title_deps(ud, &tinfo);
+                       }
+                       ud->scale_busy = FALSE;
+                       ghb_set_scale (ud, GHB_PIC_KEEP_PAR|GHB_PIC_USE_MAX);
+                       ud->dont_clear_presets = FALSE;
+
+                       gdouble vqmin, vqmax, step, page;
+                       gint digits;
+                       gboolean inverted;
+
+                       ghb_vquality_range(ud, &vqmin, &vqmax, &step, 
+                                                               &page, &digits, &inverted);
+                       gtk_range_set_range (GTK_RANGE(qp), vqmin, vqmax);
+                       gtk_range_set_increments (GTK_RANGE(qp), step, page);
+                       gtk_scale_set_digits(GTK_SCALE(qp), digits);
+                       gtk_range_set_inverted (GTK_RANGE(qp), inverted);
+
+                       gchar *text;
+                       gint crop[4];
+                       GtkWidget *crop_widget;
+                       crop[0] = ghb_settings_get_int(ud->settings, "PictureTopCrop");
+                       crop[1] = ghb_settings_get_int(ud->settings, "PictureBottomCrop");
+                       crop[2] = ghb_settings_get_int(ud->settings, "PictureLeftCrop");
+                       crop[3] = ghb_settings_get_int(ud->settings, "PictureRightCrop");
+                       crop_widget = GHB_WIDGET (ud->builder, "crop_values");
+                       text = g_strdup_printf("%d:%d:%d:%d", 
+                                                                       crop[0], crop[1], crop[2], crop[3]);
+                       gtk_label_set_text (GTK_LABEL(crop_widget), text);
+                       g_free(text);
+               }
+       }
+}
+
 G_MODULE_EXPORT void
 presets_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_t *ud)
 {
@@ -3951,6 +4302,7 @@ presets_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_
                if (!folder)
                {
                        ud->dont_clear_presets = TRUE;
+                       ud->scale_busy = TRUE;
                        // Temporarily set the video_quality range to (0,100)
                        // This is needed so the video_quality value does not get
                        // truncated when set.  The range will be readjusted below
@@ -3962,7 +4314,6 @@ presets_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_
                        // changed when it shouldn't be
                        ghb_clear_audio_list(ud);
                        ghb_set_preset_from_indices(ud, indices, len);
-                       gtk_tree_path_free(treepath);
                        gint titleindex;
                        titleindex = ghb_settings_combo_int(ud->settings, "title");
                        ghb_set_pref_audio(titleindex, ud);
@@ -3972,7 +4323,8 @@ presets_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_
                        {
                                preset_update_title_deps(ud, &tinfo);
                        }
-                       ghb_set_scale (ud, GHB_PIC_KEEP_PAR);
+                       ud->scale_busy = FALSE;
+                       ghb_set_scale (ud, GHB_PIC_KEEP_PAR|GHB_PIC_USE_MAX);
                        ud->dont_clear_presets = FALSE;
 
                        gdouble vqmin, vqmax, step, page;
@@ -3999,6 +4351,7 @@ presets_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_
                        gtk_label_set_text (GTK_LABEL(crop_widget), text);
                        g_free(text);
                }
+               gtk_tree_path_free(treepath);
                gtk_widget_set_sensitive(widget, TRUE);
        }
        else
@@ -4006,6 +4359,21 @@ presets_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_
                g_debug("No selection???  Perhaps unselected.");
                gtk_widget_set_sensitive(widget, FALSE);
        }
+       if (ghb_settings_combo_int(ud->settings, "PtoPType") == 0)
+       {
+               gint start, end;
+               start = ghb_settings_get_int(ud->settings, "start_point");
+               end = ghb_settings_get_int(ud->settings, "end_point");
+               widget = GHB_WIDGET (ud->builder, "ChapterMarkers");
+               gtk_widget_set_sensitive(widget, TRUE);
+               if (start == end)
+               {
+                       ud->dont_clear_presets = TRUE;
+                       ghb_ui_update(ud, "ChapterMarkers", ghb_boolean_value(FALSE));
+                       ud->dont_clear_presets = FALSE;
+                       gtk_widget_set_sensitive(widget, FALSE);
+               }
+       }
 }
 
 void