OSDN Git Service

WinGui:
[handbrake-jp/handbrake-jp-git.git] / gtk / src / presets.c
index 7d7e844..1946f0b 100644 (file)
@@ -918,6 +918,16 @@ preset_to_ui(signal_user_data_t *ud, GValue *dict)
                        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);
+               }
        }
 }
 
@@ -1211,7 +1221,6 @@ ghb_find_pid_file()
                        if (strncmp(file, "ghb.pid.", 8) == 0)
                        {
                                gchar *path;
-                               int fd, lock = 1;
                                pid_t my_pid;
                                int pid;
 
@@ -1222,9 +1231,12 @@ ghb_find_pid_file()
                                        file = g_dir_read_name(gdir);
                                        continue;
                                }
-
                                path = g_strdup_printf("%s/%s", config, file);
-                               fd = g_open(path, O_RDWR);
+
+#if !defined(_WIN32)
+                               int fd, lock = 1;
+
+                               fd = open(path, O_RDWR);
                                if (fd >= 0)
                                {
                                        lock = lockf(fd, F_TLOCK, 0);
@@ -1240,6 +1252,13 @@ ghb_find_pid_file()
                                }
                                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);
                }
@@ -2003,10 +2022,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}
 };
 
@@ -3043,7 +3062,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;
@@ -3086,7 +3104,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));
 
@@ -3098,21 +3115,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;
@@ -3153,6 +3157,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
@@ -3537,7 +3555,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);
@@ -3552,12 +3570,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);
@@ -3582,7 +3600,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);
        }
@@ -3611,6 +3630,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);
@@ -4095,6 +4131,7 @@ ghb_refresh_preset(signal_user_data_t *ud)
                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
@@ -4115,7 +4152,8 @@ ghb_refresh_preset(signal_user_data_t *ud)
                        {
                                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;
@@ -4173,6 +4211,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
@@ -4193,7 +4232,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;