summaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2012-11-12 08:22:07 +0000
committerjstebbins <[email protected]>2012-11-12 08:22:07 +0000
commitab5445d6f279a3477c08f069ff3329b696cb9ac8 (patch)
tree28b1f1aa52db4f2f0d35a35950f6486955703426 /gtk
parentcf1f034f914348d0f0bfcd5f8902f0a3fb519273 (diff)
Improve management of titles and jobs
Cleans up several several unavoidable memory leaks caused by old api. Clearly separates titles from jobs. Titles are set during scan and never modified now. Since titles are immutable, this lead to API some changes. For example, We were setting chapter names in the title from the front ends. Now these get set in the job. These new APIs allow us to start moving away from our use of title->job. Eventually, I would like to eliminate title->job completely, but the mac ui is too tightly tied to using this field to allow removing it at this time. So there is temporarily a convenience function used only by the mac ui that allows it to continue using title->job and also use the new APIs. New APIs: typedef struct hb_title_set_s hb_title_set_t; struct hb_title_set_s { hb_list_t * list_title; int feature; // Detected DVD feature title }; hb_title_set_t * hb_get_title_set( hb_handle_t * ); This is just something I added to clean up how "feature title" info is passed. hb_job_t * hb_job_init( hb_title_t * title ); Initializes a new job with default settings from the title. hb_job_t * hb_job_init_by_index( hb_handle_t *h, int title_index ); Same as hb_job_init(). For use by win Interop lib. void hb_job_reset( hb_job_t * job ); Convenience function for the MacUi. Clears audio, subtitle, and filter lists. The macui still uses title->job because it is so intricately tied to it. So I created this convenience function that it can call after adding a job. void hb_job_close( hb_job_t ** job ); Releases the job an all resources it contains. void hb_job_set_advanced_opts( hb_job_t *job, const char *advanced_opts ); Makes a copy of "advanced_opts" and stores in job. Freed by hb_job_close(). void hb_job_set_file( hb_job_t *job, const char *file ); Makes a copy of "file" and stores in job. Freed by hb_job_close(). void hb_chapter_set_title(hb_chapter_t *chapter, const char *title); Makes a copy of "title" and stores in chapter. Freed by hb_chapter_close(). Recommended usage (cli and lingui are updated to do this): job = hb_job_init( title ); // set job settings ... hb_add(h, job); hb_job_close( &job ); I have also added new APIs for managing metadata. These are used to add metadata to a job. void hb_metadata_set_name( hb_metadata_t *metadata, const char *name ); void hb_metadata_set_artist( hb_metadata_t *metadata, const char *artist ); void hb_metadata_set_composer( hb_metadata_t *metadata, const char *composer ); void hb_metadata_set_release_date( hb_metadata_t *metadata, const char *release_date ); void hb_metadata_set_comment( hb_metadata_t *metadata, const char *comment ); void hb_metadata_set_genre( hb_metadata_t *metadata, const char *genre ); void hb_metadata_set_album( hb_metadata_t *metadata, const char *album ); void hb_metadata_set_coverart( hb_metadata_t *metadata, const uint8_t *coverart, int size ); Example: job = hb_job_init( &job ); // set job settings ... hb_metadata_set_artist( job->metadata, "Danny Elfman" ); hb_add(h, job); hb_job_close( &job ); Some APIs have changed in order to avoid using title incorrectly and use the new hb_title_set_t. -void hb_autopassthru_apply_settings( hb_job_t * job, hb_title_t * title ); +void hb_autopassthru_apply_settings( hb_job_t * job ); -void hb_get_preview( hb_handle_t *, hb_title_t *, int, uint8_t * ); +void hb_get_preview( hb_handle_t *, hb_job_t *, int, uint8_t * ); hb_thread_t * hb_scan_init( hb_handle_t *, volatile int * die, const char * path, int title_index, - hb_list_t * list_title, int preview_count, + hb_title_set_t * title_set, int preview_count, int store_previews, uint64_t min_duration ); These APIs have been removed. Win Interop will need some changes. I think what I've provided will be suffecient, but let me know if it's not. -void hb_get_preview_by_index( hb_handle_t *, int, int, uint8_t * ); -void hb_set_anamorphic_size_by_index( hb_handle_t *, int, - int *output_width, int *output_height, - int *output_par_width, int *output_par_height ); git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5058 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk')
-rw-r--r--gtk/src/callbacks.c184
-rw-r--r--gtk/src/ghb.ui311
-rw-r--r--gtk/src/hb-backend.c411
-rw-r--r--gtk/src/hb-backend.h25
-rw-r--r--gtk/src/internal_defaults.xml16
-rw-r--r--gtk/src/presets.c30
-rw-r--r--gtk/src/values.c9
7 files changed, 633 insertions, 353 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c
index 0ff45d1c1..29c767c17 100644
--- a/gtk/src/callbacks.c
+++ b/gtk/src/callbacks.c
@@ -1328,9 +1328,8 @@ update_title_duration(signal_user_data_t *ud)
}
else if (ghb_settings_combo_int(ud->settings, "PtoPType") == 2)
{
- ghb_title_info_t tinfo;
-
- if (ghb_get_title_info (&tinfo, ti))
+ hb_title_t * title = ghb_get_title_info (ti);
+ if (title != NULL)
{
gint64 frames;
gint duration;
@@ -1338,7 +1337,7 @@ update_title_duration(signal_user_data_t *ud)
start = ghb_settings_get_int(ud->settings, "start_point");
end = ghb_settings_get_int(ud->settings, "end_point");
frames = end - start + 1;
- duration = frames * tinfo.rate_base / tinfo.rate;
+ duration = frames * title->rate_base / title->rate;
hh = duration / (60*60);
mm = (duration / 60) % 60;
ss = duration % 60;
@@ -1354,19 +1353,19 @@ update_title_duration(signal_user_data_t *ud)
}
static void
-show_title_info(signal_user_data_t *ud, ghb_title_info_t *tinfo)
+show_title_info(signal_user_data_t *ud, hb_title_t *title)
{
GtkWidget *widget;
gchar *text;
- ghb_settings_set_string(ud->settings, "source", tinfo->path);
- if (tinfo->type == HB_STREAM_TYPE || tinfo->type == HB_FF_STREAM_TYPE)
+ ghb_settings_set_string(ud->settings, "source", title->path);
+ if (title->type == HB_STREAM_TYPE || title->type == HB_FF_STREAM_TYPE)
{
GtkWidget *widget = GHB_WIDGET (ud->builder, "source_title");
- if (tinfo->name != NULL && tinfo->name[0] != 0)
+ if (title->name != NULL && title->name[0] != 0)
{
- gtk_label_set_text (GTK_LABEL(widget), tinfo->name);
- ghb_settings_set_string(ud->settings, "volume_label", tinfo->name);
+ gtk_label_set_text (GTK_LABEL(widget), title->name);
+ ghb_settings_set_string(ud->settings, "volume_label", title->name);
set_destination(ud);
}
else
@@ -1380,31 +1379,35 @@ show_title_info(signal_user_data_t *ud, ghb_title_info_t *tinfo)
ud->scale_busy = TRUE;
update_title_duration(ud);
widget = GHB_WIDGET (ud->builder, "source_codec");
- if ( tinfo->video_codec_name )
- gtk_label_set_text (GTK_LABEL(widget), tinfo->video_codec_name);
+ if ( title->video_codec_name )
+ gtk_label_set_text (GTK_LABEL(widget), title->video_codec_name);
else
gtk_label_set_text (GTK_LABEL(widget), "Unknown");
widget = GHB_WIDGET (ud->builder, "source_dimensions");
- text = g_strdup_printf ("%d x %d", tinfo->width, tinfo->height);
+ text = g_strdup_printf ("%d x %d", title->width, title->height);
gtk_label_set_text (GTK_LABEL(widget), text);
- ghb_settings_set_int(ud->settings, "source_width", tinfo->width);
- ghb_settings_set_int(ud->settings, "source_height", tinfo->height);
+ ghb_settings_set_int(ud->settings, "source_width", title->width);
+ ghb_settings_set_int(ud->settings, "source_height", title->height);
g_free(text);
widget = GHB_WIDGET (ud->builder, "source_aspect");
- text = get_aspect_string(tinfo->aspect_n, tinfo->aspect_d);
+ gint aspect_n, aspect_d;
+ hb_reduce(&aspect_n, &aspect_d,
+ title->width * title->pixel_aspect_width,
+ title->height * title->pixel_aspect_height);
+ text = get_aspect_string(aspect_n, aspect_d);
gtk_label_set_text (GTK_LABEL(widget), text);
g_free(text);
widget = GHB_WIDGET (ud->builder, "source_frame_rate");
- text = (gchar*)get_rate_string(tinfo->rate_base, tinfo->rate);
+ text = (gchar*)get_rate_string(title->rate_base, title->rate);
gtk_label_set_text (GTK_LABEL(widget), text);
g_free(text);
//widget = GHB_WIDGET (ud->builder, "source_interlaced");
- //gtk_label_set_text (GTK_LABEL(widget), tinfo->interlaced ? "Yes" : "No");
+ //gtk_label_set_text (GTK_LABEL(widget), title->interlaced ? "Yes" : "No");
ghb_ui_update(ud, "scale_width",
- ghb_int64_value(tinfo->width - tinfo->crop[2] - tinfo->crop[3]));
+ ghb_int64_value(title->width - title->crop[2] - title->crop[3]));
// If anamorphic or keep_aspect, the hight will be automatically calculated
gboolean keep_aspect;
gint pic_par;
@@ -1413,28 +1416,28 @@ show_title_info(signal_user_data_t *ud, ghb_title_info_t *tinfo)
if (!(keep_aspect || pic_par) || pic_par == 3)
{
ghb_ui_update(ud, "scale_height",
- ghb_int64_value(tinfo->height - tinfo->crop[0] - tinfo->crop[1]));
+ ghb_int64_value(title->height - title->crop[0] - title->crop[1]));
}
// Set the limits of cropping. hb_set_anamorphic_size crashes if
// you pass it a cropped width or height == 0.
gint bound;
- bound = tinfo->height / 2 - 8;
+ bound = title->height / 2 - 8;
widget = GHB_WIDGET (ud->builder, "PictureTopCrop");
gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 0, bound);
widget = GHB_WIDGET (ud->builder, "PictureBottomCrop");
gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 0, bound);
- bound = tinfo->width / 2 - 8;
+ bound = title->width / 2 - 8;
widget = GHB_WIDGET (ud->builder, "PictureLeftCrop");
gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 0, bound);
widget = GHB_WIDGET (ud->builder, "PictureRightCrop");
gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 0, bound);
if (ghb_settings_get_boolean(ud->settings, "PictureAutoCrop"))
{
- ghb_ui_update(ud, "PictureTopCrop", ghb_int64_value(tinfo->crop[0]));
- ghb_ui_update(ud, "PictureBottomCrop", ghb_int64_value(tinfo->crop[1]));
- ghb_ui_update(ud, "PictureLeftCrop", ghb_int64_value(tinfo->crop[2]));
- ghb_ui_update(ud, "PictureRightCrop", ghb_int64_value(tinfo->crop[3]));
+ ghb_ui_update(ud, "PictureTopCrop", ghb_int64_value(title->crop[0]));
+ ghb_ui_update(ud, "PictureBottomCrop", ghb_int64_value(title->crop[1]));
+ ghb_ui_update(ud, "PictureLeftCrop", ghb_int64_value(title->crop[2]));
+ ghb_ui_update(ud, "PictureRightCrop", ghb_int64_value(title->crop[3]));
}
ud->scale_busy = FALSE;
ghb_set_scale (ud, GHB_PIC_KEEP_PAR|GHB_PIC_USE_MAX);
@@ -1443,25 +1446,26 @@ show_title_info(signal_user_data_t *ud, ghb_title_info_t *tinfo)
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");
- width = tinfo->width - crop[2] - crop[3];
- height = tinfo->height - crop[0] - crop[1];
+ width = title->width - crop[2] - crop[3];
+ height = title->height - crop[0] - crop[1];
widget = GHB_WIDGET (ud->builder, "crop_dimensions");
text = g_strdup_printf ("%d x %d", width, height);
gtk_label_set_text (GTK_LABEL(widget), text);
g_free(text);
- gint duration = tinfo->duration / 90000;
+ gint duration = title->duration / 90000;
+ gint num_chapters = hb_list_count(title->list_chapter);
if (ghb_settings_combo_int(ud->settings, "PtoPType") == 0)
{
widget = GHB_WIDGET (ud->builder, "start_point");
- gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, tinfo->num_chapters);
+ gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, num_chapters);
gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), 1);
widget = GHB_WIDGET (ud->builder, "end_point");
- gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, tinfo->num_chapters);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), tinfo->num_chapters);
+ gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, num_chapters);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), num_chapters);
}
else if (ghb_settings_combo_int(ud->settings, "PtoPType") == 1)
{
@@ -1476,7 +1480,7 @@ show_title_info(signal_user_data_t *ud, ghb_title_info_t *tinfo)
}
else if (ghb_settings_combo_int(ud->settings, "PtoPType") == 2)
{
- gdouble max_frames = (gdouble)duration * tinfo->rate / tinfo->rate_base;
+ gdouble max_frames = (gdouble)duration * title->rate / title->rate_base;
widget = GHB_WIDGET (ud->builder, "start_point");
gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, max_frames);
gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), 1);
@@ -1488,29 +1492,57 @@ show_title_info(signal_user_data_t *ud, ghb_title_info_t *tinfo)
widget = GHB_WIDGET (ud->builder, "angle");
gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), 1);
- gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, tinfo->angle_count);
- ghb_settings_set_int(ud->settings, "angle_count", tinfo->angle_count);
+ gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, title->angle_count);
+ ghb_settings_set_int(ud->settings, "angle_count", title->angle_count);
ud->dont_clear_presets = FALSE;
+ // Set default metadata name
+ ghb_ui_update(ud, "MetaName", ghb_string_value(title->name));
+ if (title->metadata)
+ {
+ if (title->metadata->name)
+ {
+ ghb_ui_update(ud, "MetaName",
+ ghb_string_value(title->metadata->name));
+ }
+ ghb_ui_update(ud, "MetaArtist",
+ ghb_string_value(title->metadata->artist));
+ ghb_ui_update(ud, "MetaReleaseDate",
+ ghb_string_value(title->metadata->release_date));
+ ghb_ui_update(ud, "MetaComment",
+ ghb_string_value(title->metadata->comment));
+ if (!title->metadata->name && title->metadata->album)
+ {
+ ghb_ui_update(ud, "MetaName",
+ ghb_string_value(title->metadata->album));
+ }
+ ghb_ui_update(ud, "MetaAlbumArtist",
+ ghb_string_value(title->metadata->album_artist));
+ ghb_ui_update(ud, "MetaGenre",
+ ghb_string_value(title->metadata->genre));
+ ghb_ui_update(ud, "MetaDescription",
+ ghb_string_value(title->metadata->description));
+ ghb_ui_update(ud, "MetaLongDescription",
+ ghb_string_value(title->metadata->long_description));
+ }
}
void
set_title_settings(GValue *settings, gint titleindex)
{
- ghb_title_info_t tinfo;
-
ghb_settings_set_int(settings, "title", titleindex);
ghb_settings_set_int(settings, "title_no", titleindex);
- if (ghb_get_title_info (&tinfo, titleindex))
+ hb_title_t * title = ghb_get_title_info(titleindex);
+ if (title != NULL)
{
- ghb_settings_set_int(settings, "source_width", tinfo.width);
- ghb_settings_set_int(settings, "source_height", tinfo.height);
- ghb_settings_set_string(settings, "source", tinfo.path);
- if (tinfo.type == HB_STREAM_TYPE || tinfo.type == HB_FF_STREAM_TYPE)
+ ghb_settings_set_int(settings, "source_width", title->width);
+ ghb_settings_set_int(settings, "source_height", title->height);
+ ghb_settings_set_string(settings, "source", title->path);
+ if (title->type == HB_STREAM_TYPE || title->type == HB_FF_STREAM_TYPE)
{
- if (tinfo.name != NULL && tinfo.name[0] != 0)
+ if (title->name != NULL && title->name[0] != 0)
{
- ghb_settings_set_string(settings, "volume_label", tinfo.name);
+ ghb_settings_set_string(settings, "volume_label", title->name);
}
else
{
@@ -1519,7 +1551,7 @@ set_title_settings(GValue *settings, gint titleindex)
}
}
ghb_settings_set_int(settings, "scale_width",
- tinfo.width - tinfo.crop[2] - tinfo.crop[3]);
+ title->width - title->crop[2] - title->crop[3]);
// If anamorphic or keep_aspect, the hight will
// be automatically calculated
@@ -1530,11 +1562,11 @@ set_title_settings(GValue *settings, gint titleindex)
if (!(keep_aspect || pic_par) || pic_par == 3)
{
ghb_settings_set_int(settings, "scale_height",
- tinfo.width - tinfo.crop[0] - tinfo.crop[1]);
+ title->width - title->crop[0] - title->crop[1]);
}
ghb_set_scale_settings(settings, GHB_PIC_KEEP_PAR|GHB_PIC_USE_MAX);
- ghb_settings_set_int(settings, "angle_count", tinfo.angle_count);
+ ghb_settings_set_int(settings, "angle_count", title->angle_count);
}
update_chapter_list_settings(settings);
ghb_set_pref_audio_settings(titleindex, settings);
@@ -1559,14 +1591,13 @@ ghb_add_all_titles(signal_user_data_t *ud)
for (ii = 0; ii < count; ii++)
{
- ghb_title_info_t tinfo;
-
GValue *settings = ghb_value_dup(ud->settings);
ghb_settings_set_boolean(settings, "use_source_name", TRUE);
- if (ghb_get_title_info (&tinfo, ii))
+ hb_title_t * title = ghb_get_title_info(ii);
+ if (title != NULL)
{
- if (tinfo.type == HB_DVD_TYPE ||
- tinfo.type == HB_BD_TYPE)
+ if (title->type == HB_DVD_TYPE ||
+ title->type == HB_BD_TYPE)
{
ghb_settings_set_boolean(settings,
"title_no_in_destination", TRUE);
@@ -1582,7 +1613,6 @@ static gboolean update_preview = FALSE;
G_MODULE_EXPORT void
title_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
- ghb_title_info_t tinfo;
gint titleindex;
g_debug("title_changed_cb ()");
@@ -1593,9 +1623,10 @@ title_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
ghb_update_ui_combo_box (ud, "AudioTrack", titleindex, FALSE);
ghb_update_ui_combo_box (ud, "SubtitleTrack", titleindex, FALSE);
- if (ghb_get_title_info (&tinfo, titleindex))
+ hb_title_t * title = ghb_get_title_info(titleindex);
+ if (title != NULL)
{
- show_title_info(ud, &tinfo);
+ show_title_info(ud, title);
}
ghb_check_dependency(ud, widget, NULL);
update_chapter_list_settings(ud->settings);
@@ -1640,26 +1671,28 @@ G_MODULE_EXPORT void
ptop_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
gint ti;
- ghb_title_info_t tinfo;
+ hb_title_t * title;
ghb_widget_to_setting(ud->settings, widget);
ghb_check_dependency(ud, widget, NULL);
ghb_live_reset(ud);
ti = ghb_settings_combo_int(ud->settings, "title");
- if (!ghb_get_title_info (&tinfo, ti))
+ title = ghb_get_title_info(ti);
+ if (title == NULL)
return;
- gint duration = tinfo.duration / 90000;
+ gint num_chapters = hb_list_count(title->list_chapter);
+ gint duration = title->duration / 90000;
if (ghb_settings_combo_int(ud->settings, "PtoPType") == 0)
{
widget = GHB_WIDGET (ud->builder, "start_point");
- gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, tinfo.num_chapters);
+ gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, num_chapters);
gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), 1);
widget = GHB_WIDGET (ud->builder, "end_point");
- gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, tinfo.num_chapters);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), tinfo.num_chapters);
+ gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, num_chapters);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), num_chapters);
}
else if (ghb_settings_combo_int(ud->settings, "PtoPType") == 1)
{
@@ -1673,7 +1706,7 @@ ptop_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
}
else if (ghb_settings_combo_int(ud->settings, "PtoPType") == 2)
{
- gdouble max_frames = (gdouble)duration * tinfo.rate / tinfo.rate_base;
+ gdouble max_frames = (gdouble)duration * title->rate / title->rate_base;
widget = GHB_WIDGET (ud->builder, "start_point");
gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 1, max_frames);
gtk_spin_button_set_value (GTK_SPIN_BUTTON(widget), 1);
@@ -1715,6 +1748,20 @@ setting_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
ghb_live_reset(ud);
}
+G_MODULE_EXPORT gboolean
+meta_focus_out_cb(GtkWidget *widget, GdkEventFocus *event,
+ signal_user_data_t *ud)
+{
+ ghb_widget_to_setting(ud->settings, widget);
+ return FALSE;
+}
+
+G_MODULE_EXPORT void
+meta_setting_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
+{
+ ghb_widget_to_setting(ud->settings, widget);
+}
+
G_MODULE_EXPORT void
chapter_markers_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
@@ -1926,7 +1973,6 @@ G_MODULE_EXPORT void
crop_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
gint titleindex, crop[4];
- ghb_title_info_t tinfo;
g_debug("crop_changed_cb ()");
ghb_widget_to_setting(ud->settings, widget);
@@ -1940,13 +1986,14 @@ crop_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
crop[2] = ghb_settings_get_int(ud->settings, "PictureLeftCrop");
crop[3] = ghb_settings_get_int(ud->settings, "PictureRightCrop");
titleindex = ghb_settings_combo_int(ud->settings, "title");
- if (ghb_get_title_info (&tinfo, titleindex))
+ hb_title_t * title = ghb_get_title_info(titleindex);
+ if (title != NULL)
{
gint width, height;
gchar *text;
- width = tinfo.width - crop[2] - crop[3];
- height = tinfo.height - crop[0] - crop[1];
+ width = title->width - crop[2] - crop[3];
+ height = title->height - crop[0] - crop[1];
widget = GHB_WIDGET (ud->builder, "crop_dimensions");
text = g_strdup_printf ("%d x %d", width, height);
gtk_label_set_text (GTK_LABEL(widget), text);
@@ -2787,15 +2834,14 @@ ghb_backend_events(signal_user_data_t *ud)
ghb_refresh_preset(ud);
}
- ghb_title_info_t tinfo;
-
ghb_update_ui_combo_box(ud, "title", 0, FALSE);
titleindex = ghb_longest_title();
ghb_ui_update(ud, "title", ghb_int64_value(titleindex));
label = GTK_LABEL(GHB_WIDGET (ud->builder, "source_title"));
// Are there really any titles.
- if (!ghb_get_title_info(&tinfo, titleindex))
+ hb_title_t * title = ghb_get_title_info(titleindex);
+ if (title == NULL)
{
gtk_label_set_text(label, "None");
}
diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui
index bf24d17d1..b5ca17ca2 100644
--- a/gtk/src/ghb.ui
+++ b/gtk/src/ghb.ui
@@ -4231,6 +4231,317 @@ no-fast-pskip=0:no-dct-decimate=0:cabac=1</property>
<property name="tab_fill">False</property>
</packing>
</child>
+ <child>
+ <object class="GtkAlignment" id="alignment76">
+ <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="top_padding">48</property>
+ <property name="right_padding">24</property>
+ <property name="left_padding">24</property>
+ <property name="yscale">0</property>
+ <child>
+ <object class="GtkTable" id="tags_table">
+ <property name="n_rows">8</property>
+ <property name="n_columns">2</property>
+ <property name="visible">True</property>
+ <property name="column_spacing">5</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="tag_title_label">
+ <property name="visible">True</property>
+ <property name="xalign">1</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">Title:</property>
+ <property name="use_markup">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="MetaName">
+ <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">80</property>
+ <property name="activates_default">True</property>
+ <property name="width_chars">50</property>
+ <property name="truncate_multiline">True</property>
+ <signal name="changed" handler="meta_setting_widget_changed_cb"/>
+ </object>
+ <packing>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="tag_actors_label">
+ <property name="visible">True</property>
+ <property name="xalign">1</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">Actors:</property>
+ <property name="use_markup">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="MetaArtist">
+ <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">80</property>
+ <property name="activates_default">True</property>
+ <property name="width_chars">50</property>
+ <property name="truncate_multiline">True</property>
+ <signal name="changed" handler="meta_setting_widget_changed_cb"/>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="tag_director_label">
+ <property name="visible">True</property>
+ <property name="xalign">1</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">Director:</property>
+ <property name="use_markup">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="MetaAlbumArtist">
+ <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">80</property>
+ <property name="activates_default">True</property>
+ <property name="width_chars">50</property>
+ <property name="truncate_multiline">True</property>
+ <signal name="changed" handler="meta_setting_widget_changed_cb"/>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="tag_release_date_label">
+ <property name="visible">True</property>
+ <property name="xalign">1</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">Release Date:</property>
+ <property name="use_markup">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="MetaReleaseDate">
+ <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">80</property>
+ <property name="activates_default">True</property>
+ <property name="width_chars">50</property>
+ <property name="truncate_multiline">True</property>
+ <signal name="changed" handler="meta_setting_widget_changed_cb"/>
+ </object>
+ <packing>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="tag_comment_label">
+ <property name="visible">True</property>
+ <property name="xalign">1</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">Comment:</property>
+ <property name="use_markup">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="MetaComment">
+ <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">80</property>
+ <property name="activates_default">True</property>
+ <property name="width_chars">50</property>
+ <property name="truncate_multiline">True</property>
+ <signal name="changed" handler="meta_setting_widget_changed_cb"/>
+ </object>
+ <packing>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="tag_genre_label">
+ <property name="visible">True</property>
+ <property name="xalign">1</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">Genre:</property>
+ <property name="use_markup">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="MetaGenre">
+ <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">80</property>
+ <property name="activates_default">True</property>
+ <property name="width_chars">50</property>
+ <property name="truncate_multiline">True</property>
+ <signal name="changed" handler="meta_setting_widget_changed_cb"/>
+ </object>
+ <packing>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="tag_description_label">
+ <property name="visible">True</property>
+ <property name="xalign">1</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">Description:</property>
+ <property name="use_markup">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">6</property>
+ <property name="bottom_attach">7</property>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="MetaDescription">
+ <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">80</property>
+ <property name="activates_default">True</property>
+ <property name="width_chars">50</property>
+ <property name="truncate_multiline">True</property>
+ <signal name="changed" handler="meta_setting_widget_changed_cb"/>
+ </object>
+ <packing>
+ <property name="top_attach">6</property>
+ <property name="bottom_attach">7</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="tag_long_description_label">
+ <property name="visible">True</property>
+ <property name="xalign">1</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">Plot:</property>
+ <property name="use_markup">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">7</property>
+ <property name="bottom_attach">8</property>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="MetaLongDescriptionScroll">
+ <property name="height_request">80</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="shadow_type">etched-in</property>
+ <child>
+ <object class="GtkTextView" id="MetaLongDescription">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="wrap_mode">GTK_WRAP_CHAR</property>
+ <property name="accepts_tab">False</property>
+ <signal handler="meta_focus_out_cb" name="focus_out_event"/>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="top_attach">7</property>
+ <property name="bottom_attach">8</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="metadata_label">
+ <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">Tags</property>
+ </object>
+ <packing>
+ <property name="position">6</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
</object>
</child>
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index f2638bf73..cda5882e8 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -1404,18 +1404,11 @@ ghb_subtitle_track_source(GValue *settings, gint track)
if (titleindex < 0)
return VOBSUB;
- hb_list_t * list;
hb_title_t * title;
hb_subtitle_t * sub;
if (h_scan == NULL) return VOBSUB;
- list = hb_get_titles( h_scan );
- if( !hb_list_count( list ) )
- {
- /* No valid title, stop right there */
- return VOBSUB;
- }
- title = hb_list_item( list, titleindex );
+ title = ghb_get_title_info( titleindex );
if (title == NULL) return VOBSUB; // Bad titleindex
sub = hb_list_item( title->list_subtitle, track);
if (sub != NULL)
@@ -1445,17 +1438,10 @@ ghb_subtitle_track_source_name(GValue *settings, gint track)
if (titleindex < 0)
goto done;
- hb_list_t * list;
hb_title_t * title;
hb_subtitle_t * sub;
- if (h_scan == NULL)
- goto done;
- list = hb_get_titles( h_scan );
- if( !hb_list_count( list ) )
- goto done;
-
- title = hb_list_item( list, titleindex );
+ title = ghb_get_title_info( titleindex );
if (title == NULL)
goto done;
@@ -1482,20 +1468,10 @@ ghb_subtitle_track_lang(GValue *settings, gint track)
if (track < 0)
goto fail;
- hb_list_t * list;
hb_title_t * title;
hb_subtitle_t * sub;
- if (h_scan == NULL)
- goto fail;
-
- list = hb_get_titles( h_scan );
- if( !hb_list_count( list ) )
- {
- /* No valid title, stop right there */
- goto fail;
- }
- title = hb_list_item( list, titleindex );
+ title = ghb_get_title_info( titleindex );
if (title == NULL) // Bad titleindex
goto fail;
sub = hb_list_item( title->list_subtitle, track);
@@ -1509,17 +1485,9 @@ fail:
gint
ghb_get_title_number(gint titleindex)
{
- hb_list_t * list;
hb_title_t * title;
- if (h_scan == NULL) return 1;
- list = hb_get_titles( h_scan );
- if( !hb_list_count( list ) )
- {
- /* No valid title, stop right there */
- return 1;
- }
- title = hb_list_item( list, titleindex );
+ title = ghb_get_title_info( titleindex );
if (title == NULL) return 1; // Bad titleindex
return title->index;
}
@@ -2104,7 +2072,6 @@ audio_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex)
{
GtkTreeIter iter;
GtkListStore *store;
- hb_list_t * list = NULL;
hb_title_t * title = NULL;
hb_audio_config_t * audio;
gint ii;
@@ -2114,14 +2081,10 @@ audio_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex)
g_debug("audio_track_opts_set ()\n");
store = get_combo_box_store(builder, name);
gtk_list_store_clear(store);
- if (h_scan != NULL)
+ title = ghb_get_title_info(titleindex);
+ if (title != NULL)
{
- list = hb_get_titles( h_scan );
- title = (hb_title_t*)hb_list_item( list, titleindex );
- if (title != NULL)
- {
- count = hb_list_count( title->list_audio );
- }
+ count = hb_list_count( title->list_audio );
}
if (count > 100) count = 100;
if (audio_track_opts.map)
@@ -2188,16 +2151,13 @@ audio_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex)
const gchar*
ghb_audio_track_description(gint track, int titleindex)
{
- hb_list_t * list = NULL;
hb_title_t * title = NULL;
hb_audio_config_t * audio;
gchar * desc = "Unknown";
g_debug("ghb_audio_track_description ()\n");
- if (h_scan == NULL) return desc;
- list = hb_get_titles( h_scan );
- title = (hb_title_t*)hb_list_item( list, titleindex );
+ title = ghb_get_title_info( titleindex );
if (title == NULL) return desc;
if (track >= hb_list_count( title->list_audio )) return desc;
@@ -2211,7 +2171,6 @@ subtitle_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex)
{
GtkTreeIter iter;
GtkListStore *store;
- hb_list_t * list = NULL;
hb_title_t * title = NULL;
hb_subtitle_t * subtitle;
gint ii, count = 0;
@@ -2220,14 +2179,10 @@ subtitle_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex)
g_debug("subtitle_track_opts_set ()\n");
store = get_combo_box_store(builder, name);
gtk_list_store_clear(store);
- if (h_scan != NULL)
+ title = ghb_get_title_info(titleindex);
+ if (title != NULL)
{
- list = hb_get_titles( h_scan );
- title = (hb_title_t*)hb_list_item( list, titleindex );
- if (title != NULL)
- {
- count = hb_list_count( title->list_subtitle );
- }
+ count = hb_list_count( title->list_subtitle );
}
if (count > 100) count = 100;
if (subtitle_opts.map) g_free(subtitle_opts.map);
@@ -2313,44 +2268,39 @@ subtitle_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex)
gint
ghb_longest_title()
{
- hb_list_t * list;
+ hb_title_set_t * title_set;
hb_title_t * title;
gint ii;
gint count = 0;
- gint titleindex = 0;
gint feature;
g_debug("ghb_longest_title ()\n");
if (h_scan == NULL) return 0;
- list = hb_get_titles( h_scan );
- count = hb_list_count( list );
+ title_set = hb_get_title_set( h_scan );
+ count = hb_list_count( title_set->list_title );
if (count < 1) return 0;
- title = (hb_title_t*)hb_list_item(list, 0);
- feature = title->job->feature;
+ title = (hb_title_t*)hb_list_item(title_set->list_title, 0);
+ feature = title_set->feature;
for (ii = 0; ii < count; ii++)
{
- title = (hb_title_t*)hb_list_item(list, ii);
+ title = (hb_title_t*)hb_list_item(title_set->list_title, ii);
if (title->index == feature)
{
return ii;
}
}
- return titleindex;
+ return 0;
}
const gchar*
ghb_get_source_audio_lang(gint titleindex, gint track)
{
- hb_list_t * list;
hb_title_t * title;
hb_audio_config_t * audio;
const gchar *lang = "und";
g_debug("ghb_lookup_1st_audio_lang ()\n");
- if (h_scan == NULL)
- return lang;
- list = hb_get_titles( h_scan );
- title = (hb_title_t*)hb_list_item( list, titleindex );
+ title = ghb_get_title_info( titleindex );
if (title == NULL)
return lang;
if (hb_list_count( title->list_audio ) <= track)
@@ -2390,7 +2340,6 @@ ghb_find_audio_track(
gint fallback_acodec,
GHashTable *track_indices)
{
- hb_list_t * list;
hb_title_t * title;
hb_audio_config_t * audio;
gint ii;
@@ -2405,9 +2354,7 @@ ghb_find_audio_track(
gint channels;
g_debug("find_audio_track ()\n");
- if (h_scan == NULL) return -1;
- list = hb_get_titles( h_scan );
- title = (hb_title_t*)hb_list_item( list, titleindex );
+ title = ghb_get_title_info( titleindex );
if (title != NULL)
{
count = hb_list_count( title->list_audio );
@@ -2617,15 +2564,12 @@ ghb_find_pref_subtitle_track(const gchar *lang)
gint
ghb_find_cc_track(gint titleindex)
{
- hb_list_t * list;
hb_title_t * title;
hb_subtitle_t * subtitle;
gint count, ii;
g_debug("ghb_find_cc_track ()\n");
- if (h_scan == NULL) return -2;
- list = hb_get_titles( h_scan );
- title = (hb_title_t*)hb_list_item( list, titleindex );
+ title = ghb_get_title_info( titleindex );
if (title != NULL)
{
count = hb_list_count( title->list_subtitle );
@@ -2649,57 +2593,55 @@ ghb_find_subtitle_track(
gint source,
GHashTable * track_indices)
{
- hb_list_t * list;
hb_title_t * title;
hb_subtitle_t * subtitle;
gint count, ii;
gboolean *used;
-
+
g_debug("find_subtitle_track ()\n");
if (strcmp(lang, "auto") == 0)
return -1;
- if (h_scan == NULL) return -1;
- list = hb_get_titles( h_scan );
- title = (hb_title_t*)hb_list_item( list, titleindex );
- if (title != NULL)
+
+ title = ghb_get_title_info( titleindex );
+ if (title == NULL)
+ return -2;
+
+ count = hb_list_count( title->list_subtitle );
+ used = g_hash_table_lookup(track_indices, lang);
+ if (used == NULL)
{
- count = hb_list_count( title->list_subtitle );
- used = g_hash_table_lookup(track_indices, lang);
- if (used == NULL)
+ used = g_malloc0(count * sizeof(gboolean));
+ g_hash_table_insert(track_indices, g_strdup(lang), used);
+ }
+ // Try to find an item that matches the preferred language and source
+ for (ii = 0; ii < count; ii++)
+ {
+ if (used[ii])
+ continue;
+
+ subtitle = (hb_subtitle_t*)hb_list_item( title->list_subtitle, ii );
+ if (source == subtitle->source &&
+ ((strcmp(lang, subtitle->iso639_2) == 0) ||
+ (strcmp(lang, "und") == 0)))
{
- used = g_malloc0(count * sizeof(gboolean));
- g_hash_table_insert(track_indices, g_strdup(lang), used);
+ used[ii] = TRUE;
+ return ii;
}
- // Try to find an item that matches the preferred language and source
- for (ii = 0; ii < count; ii++)
- {
- if (used[ii])
- continue;
+ }
+ // Try to find an item that matches the preferred language
+ for (ii = 0; ii < count; ii++)
+ {
+ if (used[ii])
+ continue;
- subtitle = (hb_subtitle_t*)hb_list_item( title->list_subtitle, ii );
- if (source == subtitle->source &&
- ((strcmp(lang, subtitle->iso639_2) == 0) ||
- (strcmp(lang, "und") == 0)))
- {
- used[ii] = TRUE;
- return ii;
- }
- }
- // Try to find an item that matches the preferred language
- for (ii = 0; ii < count; ii++)
+ subtitle = (hb_subtitle_t*)hb_list_item( title->list_subtitle, ii );
+ if (((!force || (force && ghb_canForceSub(subtitle->source))) &&
+ (!burn || (burn && ghb_canBurnSub(subtitle->source)))) &&
+ ((strcmp(lang, subtitle->iso639_2) == 0) ||
+ (strcmp(lang, "und") == 0)))
{
- if (used[ii])
- continue;
-
- subtitle = (hb_subtitle_t*)hb_list_item( title->list_subtitle, ii );
- if (((!force || (force && ghb_canForceSub(subtitle->source))) &&
- (!burn || (burn && ghb_canBurnSub(subtitle->source)))) &&
- ((strcmp(lang, subtitle->iso639_2) == 0) ||
- (strcmp(lang, "und") == 0)))
- {
- used[ii] = TRUE;
- return ii;
- }
+ used[ii] = TRUE;
+ return ii;
}
}
return -2;
@@ -3081,16 +3023,13 @@ ghb_build_advanced_opts_string(GValue *settings)
void
ghb_part_duration(gint tt, gint sc, gint ec, gint *hh, gint *mm, gint *ss)
{
- hb_list_t * list;
hb_title_t * title;
- hb_chapter_t * chapter;
+ hb_chapter_t * chapter;
gint count, c;
gint64 duration;
*hh = *mm = *ss = 0;
- if (h_scan == NULL) return;
- list = hb_get_titles( h_scan );
- title = (hb_title_t*)hb_list_item( list, tt );
+ title = ghb_get_title_info( tt );
if (title == NULL) return;
*hh = title->hours;
@@ -3119,16 +3058,13 @@ ghb_part_duration(gint tt, gint sc, gint ec, gint *hh, gint *mm, gint *ss)
void
ghb_get_chapter_duration(gint ti, gint ii, gint *hh, gint *mm, gint *ss)
{
- hb_list_t * list;
hb_title_t * title;
- hb_chapter_t * chapter;
+ hb_chapter_t * chapter;
gint count;
g_debug("ghb_get_chapter_duration (title = %d)\n", ti);
*hh = *mm = *ss = 0;
- if (h_scan == NULL) return;
- list = hb_get_titles( h_scan );
- title = (hb_title_t*)hb_list_item( list, ti );
+ title = ghb_get_title_info( ti );
if (title == NULL) return;
count = hb_list_count( title->list_chapter );
if (ii >= count) return;
@@ -3142,18 +3078,15 @@ ghb_get_chapter_duration(gint ti, gint ii, gint *hh, gint *mm, gint *ss)
GValue*
ghb_get_chapters(gint titleindex)
{
- hb_list_t * list;
hb_title_t * title;
- hb_chapter_t * chapter;
+ hb_chapter_t * chapter;
gint count, ii;
GValue *chapters = NULL;
g_debug("ghb_get_chapters (title = %d)\n", titleindex);
chapters = ghb_array_value_new(0);
- if (h_scan == NULL) return chapters;
- list = hb_get_titles( h_scan );
- title = (hb_title_t*)hb_list_item( list, titleindex );
+ title = ghb_get_title_info( titleindex );
if (title == NULL) return chapters;
count = hb_list_count( title->list_chapter );
for (ii = 0; ii < count; ii++)
@@ -3601,49 +3534,15 @@ ghb_track_status()
}
}
-gboolean
-ghb_get_title_info(ghb_title_info_t *tinfo, gint titleindex)
+hb_title_t *
+ghb_get_title_info(gint titleindex)
{
hb_list_t * list;
- hb_title_t * title;
-
- if (h_scan == NULL) return FALSE;
- list = hb_get_titles( h_scan );
- if( !hb_list_count( list ) )
- {
- /* No valid title, stop right there */
- return FALSE;
- }
- title = hb_list_item( list, titleindex );
- if (title == NULL) return FALSE; // Bad titleindex
- tinfo->index = titleindex;
- tinfo->video_codec_name = title->video_codec_name;
- tinfo->width = title->width;
- tinfo->height = title->height;
- memcpy(tinfo->crop, title->crop, 4 * sizeof(int));
- // Don't allow crop to 0
- if (title->crop[0] + title->crop[1] >= title->height)
- title->crop[0] = title->crop[1] = 0;
- if (title->crop[2] + title->crop[3] >= title->width)
- title->crop[2] = title->crop[3] = 0;
- tinfo->num_chapters = hb_list_count(title->list_chapter);
- tinfo->rate_base = title->rate_base;
- tinfo->rate = title->rate;
- tinfo->interlaced = title->detected_interlacing;
- hb_reduce(&(tinfo->aspect_n), &(tinfo->aspect_d),
- title->width * title->pixel_aspect_width,
- title->height * title->pixel_aspect_height);
- tinfo->hours = title->hours;
- tinfo->minutes = title->minutes;
- tinfo->seconds = title->seconds;
- tinfo->duration = title->duration;
-
- tinfo->angle_count = title->angle_count;
- tinfo->path = title->path;
- tinfo->name = title->name;
- tinfo->type = title->type;
- return TRUE;
+ if (h_scan == NULL) return NULL;
+ list = hb_get_titles( h_scan );
+ if (list == NULL) return NULL;
+ return hb_list_item( list, titleindex );
}
hb_audio_config_t*
@@ -3740,13 +3639,13 @@ ghb_limit_rational( gint *num, gint *den, gint limit )
void
ghb_set_scale_settings(GValue *settings, gint mode)
{
- hb_list_t * list;
hb_title_t * title;
hb_job_t * job;
gboolean keep_aspect;
gint pic_par;
gboolean autocrop, autoscale, noscale;
- gint crop[4], width, height, par_width, par_height;
+ gint crop[4] = {0,};
+ gint width, height, par_width, par_height;
gint crop_width, crop_height;
gint aspect_n, aspect_d;
gboolean keep_width = (mode & GHB_PIC_KEEP_WIDTH);
@@ -3769,19 +3668,13 @@ ghb_set_scale_settings(GValue *settings, gint mode)
ghb_settings_set_boolean(settings, "PictureKeepRatio", TRUE);
}
- if (h_scan == NULL) return;
- list = hb_get_titles( h_scan );
- if( !hb_list_count( list ) )
- {
- /* No valid title, stop right there */
- return;
- }
gint titleindex;
titleindex = ghb_settings_combo_int(settings, "title");
- title = hb_list_item( list, titleindex );
+ title = ghb_get_title_info (titleindex);
if (title == NULL) return;
- job = title->job;
+
+ job = hb_job_init( title );
if (job == NULL) return;
// First configure widgets
@@ -3801,14 +3694,12 @@ ghb_set_scale_settings(GValue *settings, gint mode)
keep_height = FALSE;
}
- ghb_title_info_t tinfo;
- ghb_get_title_info (&tinfo, titleindex);
if (autocrop)
{
- crop[0] = tinfo.crop[0];
- crop[1] = tinfo.crop[1];
- crop[2] = tinfo.crop[2];
- crop[3] = tinfo.crop[3];
+ crop[0] = title->crop[0];
+ crop[1] = title->crop[1];
+ crop[2] = title->crop[2];
+ crop[3] = title->crop[3];
ghb_settings_set_int(settings, "PictureTopCrop", crop[0]);
ghb_settings_set_int(settings, "PictureBottomCrop", crop[1]);
ghb_settings_set_int(settings, "PictureLeftCrop", crop[2]);
@@ -3826,8 +3717,8 @@ ghb_set_scale_settings(GValue *settings, gint mode)
gint need1, need2;
// Adjust the cropping to accomplish the desired width and height
- crop_width = tinfo.width - crop[2] - crop[3];
- crop_height = tinfo.height - crop[0] - crop[1];
+ crop_width = width - crop[2] - crop[3];
+ crop_height = height - crop[0] - crop[1];
width = MOD_DOWN(crop_width, mod);
height = MOD_DOWN(crop_height, mod);
@@ -3999,6 +3890,7 @@ ghb_set_scale_settings(GValue *settings, gint mode)
ghb_settings_set_int(settings, "PicturePARHeight", par_height);
ghb_settings_set_int(settings, "PictureDisplayWidth", disp_width);
ghb_settings_set_int(settings, "PictureDisplayHeight", height);
+ hb_job_close( &job );
}
void
@@ -4290,25 +4182,20 @@ ghb_validate_video(GValue *settings)
gboolean
ghb_validate_subtitles(GValue *settings)
{
- hb_list_t * list;
hb_title_t * title;
gchar *message;
- if (h_scan == NULL) return FALSE;
- list = hb_get_titles( h_scan );
- if( !hb_list_count( list ) )
+ gint titleindex;
+
+ titleindex = ghb_settings_combo_int(settings, "title");
+ title = ghb_get_title_info(titleindex);
+ if (title == NULL)
{
/* No valid title, stop right there */
g_message("No title found.\n");
return FALSE;
}
- gint titleindex;
-
- titleindex = ghb_settings_combo_int(settings, "title");
- title = hb_list_item( list, titleindex );
- if (title == NULL) return FALSE;
-
const GValue *slist, *subtitle;
gint count, ii, source;
gboolean burned, one_burned = FALSE;
@@ -4368,25 +4255,20 @@ ghb_validate_subtitles(GValue *settings)
gboolean
ghb_validate_audio(GValue *settings)
{
- hb_list_t * list;
hb_title_t * title;
gchar *message;
GValue *value;
- if (h_scan == NULL) return FALSE;
- list = hb_get_titles( h_scan );
- if( !hb_list_count( list ) )
+ gint titleindex;
+
+ titleindex = ghb_settings_combo_int(settings, "title");
+ title = ghb_get_title_info( titleindex );
+ if (title == NULL)
{
/* No valid title, stop right there */
g_message("No title found.\n");
return FALSE;
}
-
- gint titleindex;
-
- titleindex = ghb_settings_combo_int(settings, "title");
- title = hb_list_item( list, titleindex );
- if (title == NULL) return FALSE;
gint mux = ghb_settings_combo_int(settings, "FileFormat");
const GValue *audio_list;
@@ -4602,7 +4484,7 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
if (title == NULL) return;
/* Set job settings */
- job = title->job;
+ job = hb_job_init( title );
if (job == NULL) return;
job->angle = ghb_settings_get_int(js, "angle");
@@ -4686,9 +4568,8 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
{
name = g_strdup_printf ("Chapter %2d", chap+1);
}
- chapter_s = hb_list_item( job->title->list_chapter, chap);
- strncpy(chapter_s->title, name, 1023);
- chapter_s->title[1023] = '\0';
+ chapter_s = hb_list_item( job->list_chapter, chap);
+ hb_chapter_set_title(chapter_s, name);
g_free(name);
}
}
@@ -4945,7 +4826,8 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
}
dest_str = ghb_settings_get_string(js, "destination");
- job->file = dest_str;
+ hb_job_set_file( job, dest_str);
+ g_free(dest_str);
const GValue *subtitle_list;
gint subtitle;
@@ -5066,6 +4948,57 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
advanced_opts = NULL;
}
+ char * meta;
+
+ meta = ghb_settings_get_string(js, "MetaName");
+ if (meta && *meta)
+ {
+ hb_metadata_set_name(job->metadata, meta);
+ }
+ free(meta);
+ meta = ghb_settings_get_string(js, "MetaArtist");
+ if (meta && *meta)
+ {
+ hb_metadata_set_artist(job->metadata, meta);
+ }
+ free(meta);
+ meta = ghb_settings_get_string(js, "MetaAlbumArtist");
+ if (meta && *meta)
+ {
+ hb_metadata_set_album_artist(job->metadata, meta);
+ }
+ free(meta);
+ meta = ghb_settings_get_string(js, "MetaReleaseDate");
+ if (meta && *meta)
+ {
+ hb_metadata_set_release_date(job->metadata, meta);
+ }
+ free(meta);
+ meta = ghb_settings_get_string(js, "MetaComment");
+ if (meta && *meta)
+ {
+ hb_metadata_set_comment(job->metadata, meta);
+ }
+ free(meta);
+ meta = ghb_settings_get_string(js, "MetaGenre");
+ if (meta && *meta)
+ {
+ hb_metadata_set_genre(job->metadata, meta);
+ }
+ free(meta);
+ meta = ghb_settings_get_string(js, "MetaDescription");
+ if (meta && *meta)
+ {
+ hb_metadata_set_description(job->metadata, meta);
+ }
+ free(meta);
+ meta = ghb_settings_get_string(js, "MetaLongDescription");
+ if (meta && *meta)
+ {
+ hb_metadata_set_long_description(job->metadata, meta);
+ }
+ free(meta);
+
if (job->indepth_scan == 1)
{
// Subtitle scan. Look for subtitle matching audio language
@@ -5076,7 +5009,7 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
*/
job->pass = -1;
job->indepth_scan = 1;
- job->advanced_opts = NULL;
+ hb_job_set_advanced_opts(job, NULL);
/*
* Add the pre-scan job
@@ -5095,7 +5028,7 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
*/
job->pass = 1;
job->indepth_scan = 0;
- job->advanced_opts = advanced_opts;
+ hb_job_set_advanced_opts(job, advanced_opts);
/*
* If turbo options have been selected then set job->fastfirstpass
@@ -5109,10 +5042,9 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
{
job->fastfirstpass = 0;
}
+
job->sequence_id = (unique_id & 0xFFFFFF) | (sub_id++ << 24);
hb_add( h, job );
- //if (job->advanced_opts != NULL)
- // g_free(job->advanced_opts);
job->pass = 2;
/*
@@ -5124,25 +5056,18 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
job->indepth_scan = 0;
job->sequence_id = (unique_id & 0xFFFFFF) | (sub_id++ << 24);
hb_add( h, job );
- //if (job->advanced_opts != NULL)
- // g_free(job->advanced_opts);
}
else
{
- job->advanced_opts = advanced_opts;
+ hb_job_set_advanced_opts(job, advanced_opts);
job->indepth_scan = 0;
job->pass = 0;
job->sequence_id = (unique_id & 0xFFFFFF) | (sub_id++ << 24);
hb_add( h, job );
- //if (job->advanced_opts != NULL)
- // g_free(job->advanced_opts);
}
+ g_free(advanced_opts);
- // Reset the job so it can be use again to add other jobs
- // for the same title.
- hb_reset_job(job);
-
- if (dest_str) g_free(dest_str);
+ hb_job_close(&job);
}
void
@@ -5327,19 +5252,16 @@ ghb_get_preview_image(
{
GValue *settings;
hb_title_t *title;
- hb_list_t *list;
+ hb_job_t *job;
settings = ud->settings;
- list = hb_get_titles( h_scan );
- if( !hb_list_count( list ) )
- {
- /* No valid title, stop right there */
- return NULL;
- }
- title = hb_list_item( list, titleindex );
- if (title == NULL) return NULL;
- if (title->job == NULL) return NULL;
- set_preview_job_settings(title->job, settings);
+ title = ghb_get_title_info( titleindex );
+ if( title == NULL ) return NULL;
+
+ job = hb_job_init( title );
+ if (job == NULL) return NULL;
+
+ set_preview_job_settings(job, settings);
// hb_get_preview doesn't compensate for anamorphic, so lets
// calculate scale factors
@@ -5347,13 +5269,13 @@ ghb_get_preview_image(
gint pic_par = ghb_settings_combo_int(settings, "PicturePAR");
if (pic_par)
{
- hb_set_anamorphic_size( title->job, &width, &height,
+ hb_set_anamorphic_size( job, &width, &height,
&par_width, &par_height );
}
// Make sure we have a big enough buffer to receive the image from libhb
- gint dstWidth = title->job->width;
- gint dstHeight= title->job->height;
+ gint dstWidth = job->width;
+ gint dstHeight= job->height;
static guint8 *buffer = NULL;
static gint bufferSize = 0;
@@ -5365,7 +5287,8 @@ ghb_get_preview_image(
bufferSize = newSize;
buffer = (guint8*) g_realloc( buffer, bufferSize );
}
- hb_get_preview( h_scan, title, index, buffer );
+ hb_get_preview( h_scan, job, index, buffer );
+ hb_job_close( &job );
// Create an GdkPixbuf and copy the libhb image into it, converting it from
// libhb's format something suitable.
diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h
index e1ff28a75..ded2fd8c0 100644
--- a/gtk/src/hb-backend.h
+++ b/gtk/src/hb-backend.h
@@ -62,29 +62,6 @@ typedef struct
#define GHB_PIC_KEEP_PAR 0x20
#define GHB_PIC_USE_MAX 0x40
-typedef struct
-{
- gchar *path;
- gchar *name;
- gint index;
- gint type;
- char *video_codec_name;
- gint width;
- gint height;
- gint crop[4];
- gint num_chapters;
- gint rate;
- gint rate_base;
- gint interlaced;
- gint aspect_n;
- gint aspect_d;
- gint hours;
- gint minutes;
- gint seconds;
- gint64 duration;
- gint angle_count;
-} ghb_title_info_t;
-
#define GHB_AUDIO_SAMPLERATE 1
#define GHB_AUDIO_BITRATE 2
#define GHB_FRAMERATE 3
@@ -123,7 +100,7 @@ void ghb_track_status(void);
void ghb_backend_scan(const gchar *path, gint titleindex, gint preview_count, guint64 min_duration);
void ghb_backend_scan_stop();
void ghb_backend_queue_scan(const gchar *path, gint titleindex);
-gboolean ghb_get_title_info(ghb_title_info_t *tinfo, gint titleindex);
+hb_title_t* ghb_get_title_info(gint titleindex);
void ghb_par_init(signal_user_data_t *ud);
void ghb_set_scale(signal_user_data_t *ud, gint mode);
void ghb_set_scale_settings(GValue *settings, gint mode);
diff --git a/gtk/src/internal_defaults.xml b/gtk/src/internal_defaults.xml
index 68667222a..e5d98cebe 100644
--- a/gtk/src/internal_defaults.xml
+++ b/gtk/src/internal_defaults.xml
@@ -24,6 +24,22 @@
<integer>100</integer>
<key>folder</key>
<string></string>
+ <key>MetaName</key>
+ <string></string>
+ <key>MetaArtist</key>
+ <string></string>
+ <key>MetaAlbumArtist</key>
+ <string></string>
+ <key>MetaReleaseDate</key>
+ <string></string>
+ <key>MetaComment</key>
+ <string></string>
+ <key>MetaGenre</key>
+ <string></string>
+ <key>MetaDescription</key>
+ <string></string>
+ <key>MetaLongDescription</key>
+ <string></string>
<key>preset</key>
<array>
<string>Normal</string>
diff --git a/gtk/src/presets.c b/gtk/src/presets.c
index eeacbde04..1905e5597 100644
--- a/gtk/src/presets.c
+++ b/gtk/src/presets.c
@@ -4195,12 +4195,12 @@ presets_row_expanded_cb(
}
static void
-preset_update_title_deps(signal_user_data_t *ud, ghb_title_info_t *tinfo)
+preset_update_title_deps(signal_user_data_t *ud, hb_title_t *title)
{
GtkWidget *widget;
ghb_ui_update(ud, "scale_width",
- ghb_int64_value(tinfo->width - tinfo->crop[2] - tinfo->crop[3]));
+ ghb_int64_value(title->width - title->crop[2] - title->crop[3]));
// If anamorphic or keep_aspect, the hight will be automatically calculated
gboolean keep_aspect;
gint pic_par;
@@ -4209,35 +4209,34 @@ preset_update_title_deps(signal_user_data_t *ud, ghb_title_info_t *tinfo)
if (!(keep_aspect || pic_par) || pic_par == 3)
{
ghb_ui_update(ud, "scale_height",
- ghb_int64_value(tinfo->height - tinfo->crop[0] - tinfo->crop[1]));
+ ghb_int64_value(title->height - title->crop[0] - title->crop[1]));
}
// Set the limits of cropping. hb_set_anamorphic_size crashes if
// you pass it a cropped width or height == 0.
gint bound;
- bound = tinfo->height / 2 - 2;
+ bound = title->height / 2 - 2;
widget = GHB_WIDGET (ud->builder, "PictureTopCrop");
gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 0, bound);
widget = GHB_WIDGET (ud->builder, "PictureBottomCrop");
gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 0, bound);
- bound = tinfo->width / 2 - 2;
+ bound = title->width / 2 - 2;
widget = GHB_WIDGET (ud->builder, "PictureLeftCrop");
gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 0, bound);
widget = GHB_WIDGET (ud->builder, "PictureRightCrop");
gtk_spin_button_set_range (GTK_SPIN_BUTTON(widget), 0, bound);
if (ghb_settings_get_boolean(ud->settings, "PictureAutoCrop"))
{
- ghb_ui_update(ud, "PictureTopCrop", ghb_int64_value(tinfo->crop[0]));
- ghb_ui_update(ud, "PictureBottomCrop", ghb_int64_value(tinfo->crop[1]));
- ghb_ui_update(ud, "PictureLeftCrop", ghb_int64_value(tinfo->crop[2]));
- ghb_ui_update(ud, "PictureRightCrop", ghb_int64_value(tinfo->crop[3]));
+ ghb_ui_update(ud, "PictureTopCrop", ghb_int64_value(title->crop[0]));
+ ghb_ui_update(ud, "PictureBottomCrop", ghb_int64_value(title->crop[1]));
+ ghb_ui_update(ud, "PictureLeftCrop", ghb_int64_value(title->crop[2]));
+ ghb_ui_update(ud, "PictureRightCrop", ghb_int64_value(title->crop[3]));
}
}
void
ghb_refresh_preset(signal_user_data_t *ud)
{
- ghb_title_info_t tinfo;
GValue *preset;
gint *indices, len;
@@ -4266,9 +4265,10 @@ ghb_refresh_preset(signal_user_data_t *ud)
ghb_set_pref_audio_from_settings(ud, ud->settings);
ghb_set_pref_subtitle(titleindex, ud);
ghb_settings_set_boolean(ud->settings, "preset_modified", FALSE);
- if (ghb_get_title_info (&tinfo, titleindex))
+ hb_title_t * title = ghb_get_title_info(titleindex);
+ if (title != NULL)
{
- preset_update_title_deps(ud, &tinfo);
+ preset_update_title_deps(ud, title);
}
ud->scale_busy = FALSE;
ghb_set_scale (ud, GHB_PIC_KEEP_PAR|GHB_PIC_USE_MAX);
@@ -4306,7 +4306,6 @@ presets_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_
{
GtkTreeModel *store;
GtkTreeIter iter;
- ghb_title_info_t tinfo;
GtkWidget *widget;
g_debug("presets_list_selection_changed_cb ()");
@@ -4343,9 +4342,10 @@ presets_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_
ghb_set_pref_audio_from_settings(ud, ud->settings);
ghb_set_pref_subtitle(titleindex, ud);
ghb_settings_set_boolean(ud->settings, "preset_modified", FALSE);
- if (ghb_get_title_info (&tinfo, titleindex))
+ hb_title_t * title = ghb_get_title_info(titleindex);
+ if (title != NULL)
{
- preset_update_title_deps(ud, &tinfo);
+ preset_update_title_deps(ud, title);
}
ud->scale_busy = FALSE;
ghb_set_scale (ud, GHB_PIC_KEEP_PAR|GHB_PIC_USE_MAX);
diff --git a/gtk/src/values.c b/gtk/src/values.c
index dd23d0e48..f755363e5 100644
--- a/gtk/src/values.c
+++ b/gtk/src/values.c
@@ -322,7 +322,14 @@ ghb_string_value(const gchar *str)
static GValue gval = {0,};
if (!G_IS_VALUE(&gval))
g_value_init(&gval, G_TYPE_STRING);
- g_value_set_string(&gval, str);
+ if (str == NULL)
+ {
+ g_value_set_string(&gval, "");
+ }
+ else
+ {
+ g_value_set_string(&gval, str);
+ }
return &gval;
}