summaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'gtk')
-rw-r--r--gtk/src/audiohandler.c64
-rw-r--r--gtk/src/callbacks.c63
-rw-r--r--gtk/src/hb-backend.c41
-rw-r--r--gtk/src/main.c14
-rw-r--r--gtk/src/plist.c30
-rw-r--r--gtk/src/presets.c696
-rw-r--r--gtk/src/preview.c2
-rw-r--r--gtk/src/queuehandler.c76
-rw-r--r--gtk/src/resources.c22
-rw-r--r--gtk/src/settings.c74
-rw-r--r--gtk/src/subtitlehandler.c50
-rw-r--r--gtk/src/values.c414
-rw-r--r--gtk/src/values.h111
-rw-r--r--gtk/src/x264handler.c10
14 files changed, 583 insertions, 1084 deletions
diff --git a/gtk/src/audiohandler.c b/gtk/src/audiohandler.c
index 70b512e4b..5a821b3e9 100644
--- a/gtk/src/audiohandler.c
+++ b/gtk/src/audiohandler.c
@@ -341,7 +341,7 @@ void ghb_santiize_audio_tracks(signal_user_data_t *ud)
for (ii = 0; ii < count; ii++)
{
- GhbValue *asettings = ghb_array_get_nth(alist, ii);
+ GhbValue *asettings = ghb_array_get(alist, ii);
ghb_sanitize_audio_settings(ud->settings, asettings);
}
ghb_audio_list_refresh_all(ud);
@@ -456,7 +456,7 @@ ghb_get_user_audio_lang(GhbValue *settings, const hb_title_t *title, gint track)
audio_list = ghb_settings_get_value(settings, "audio_list");
if (ghb_array_len(audio_list) <= track)
return "und";
- asettings = ghb_array_get_nth(audio_list, track);
+ asettings = ghb_array_get(audio_list, track);
track = ghb_settings_get_int(asettings, "AudioTrack");
lang = ghb_get_source_audio_lang(title, track);
return lang;
@@ -498,7 +498,7 @@ audio_add_track(
hb_audio_config_t *aconfig = NULL;
aconfig = ghb_get_audio_info(title, track);
- asettings = ghb_dict_value_new();
+ asettings = ghb_dict_new();
ghb_settings_set_int(asettings, "AudioTrack", track);
@@ -557,7 +557,7 @@ audio_select_and_add_track(
gint copy_mask = ghb_get_copy_mask(settings);
- audio = ghb_array_get_nth(pref_audio, pref_index);
+ audio = ghb_array_get(pref_audio, pref_index);
acodec = ghb_settings_audio_encoder_codec(audio, "AudioEncoder");
fallback = ghb_select_fallback(settings, acodec);
@@ -625,7 +625,7 @@ static void set_pref_audio_with_lang(
gdouble drc, gain, quality;
gboolean enable_quality;
- audio = ghb_array_get_nth(pref_audio, ii);
+ audio = ghb_array_get(pref_audio, ii);
acodec = ghb_settings_audio_encoder_codec(audio, "AudioEncoder");
fallback = ghb_select_fallback(settings, acodec);
copy_mask = ghb_get_copy_mask(settings);
@@ -724,8 +724,8 @@ ghb_set_pref_audio_settings(GhbValue *settings)
{
const gchar *lang;
gboolean mode;
- GhbValue *glang = ghb_array_get_nth(lang_list, ii);
- lang = ghb_value_const_string(glang);
+ GhbValue *glang = ghb_array_get(lang_list, ii);
+ lang = ghb_value_get_string(glang);
mode = ghb_settings_get_boolean(settings, "AudioSecondaryEncoderMode");
set_pref_audio_with_lang(title, settings, lang, behavior, mode, track_used);
}
@@ -768,7 +768,7 @@ audio_get_selected_settings(signal_user_data_t *ud, int *index)
if (row >= ghb_array_len(audio_list))
return NULL;
- asettings = ghb_array_get_nth(audio_list, row);
+ asettings = ghb_array_get(audio_list, row);
if (index != NULL)
*index = row;
}
@@ -951,7 +951,7 @@ ghb_audio_list_refresh_selected(signal_user_data_t *ud)
if (row >= ghb_array_len(audio_list))
return;
- asettings = ghb_array_get_nth(audio_list, row);
+ asettings = ghb_array_get(audio_list, row);
audio_refresh_list_row_ui(tm, &ti, ud, asettings);
}
}
@@ -984,7 +984,7 @@ audio_refresh_list_ui(signal_user_data_t *ud)
for (ii = 0; ii < count; ii++)
{
gtk_tree_model_iter_nth_child(tm, &ti, NULL, ii);
- asettings = ghb_array_get_nth(audio_list, ii);
+ asettings = ghb_array_get(audio_list, ii);
audio_refresh_list_row_ui(tm, &ti, ud, asettings);
}
}
@@ -1309,11 +1309,11 @@ ghb_clear_audio_list_settings(GhbValue *settings)
audio_list = ghb_settings_get_value(settings, "audio_list");
if (audio_list == NULL)
{
- audio_list = ghb_array_value_new();
+ audio_list = ghb_array_new();
ghb_settings_set_value(settings, "audio_list", audio_list);
}
else
- ghb_array_value_reset(audio_list);
+ ghb_array_reset(audio_list);
}
void
@@ -1394,7 +1394,7 @@ audio_list_selection_changed_cb(GtkTreeSelection *ts, signal_user_data_t *ud)
if (row < 0) return;
audio_list = ghb_settings_get_value(ud->settings, "audio_list");
if (row >= 0 && row < ghb_array_len(audio_list))
- asettings = ghb_array_get_nth(audio_list, row);
+ asettings = ghb_array_get(audio_list, row);
}
audio_update_dialog_widgets(ud, asettings);
}
@@ -1413,7 +1413,7 @@ audio_add_to_settings(GhbValue *settings, GhbValue *asettings)
audio_list = ghb_settings_get_value(settings, "audio_list");
if (audio_list == NULL)
{
- audio_list = ghb_array_value_new(8);
+ audio_list = ghb_array_new(8);
ghb_settings_set_value(settings, "audio_list", audio_list);
}
@@ -1428,7 +1428,7 @@ audio_add_to_settings(GhbValue *settings, GhbValue *asettings)
}
GhbValue *aname;
- aname = ghb_dict_lookup(asettings, "AudioTrackName");
+ aname = ghb_dict_get(asettings, "AudioTrackName");
if (aname == NULL)
{
ghb_settings_set_string(asettings, "AudioTrackName", "");
@@ -1474,7 +1474,7 @@ audio_add_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
}
else
{
- ghb_value_free(backup);
+ ghb_value_free(&backup);
}
}
}
@@ -1557,7 +1557,7 @@ audio_edit_clicked_cb(GtkWidget *widget, gchar *path, signal_user_data_t *ud)
}
else
{
- ghb_value_free(backup);
+ ghb_value_free(&backup);
}
}
}
@@ -1663,7 +1663,7 @@ static void audio_def_update_widgets(GtkWidget *row, GhbValue *adict)
GhbValue *gval;
GtkWidget *widget;
- ghb_dict_iter_init(adict, &ti);
+ ti = ghb_dict_iter_init(adict);
block_updates = TRUE;
while (ghb_dict_iter_next(adict, &ti, &key, &gval))
@@ -1814,7 +1814,7 @@ GtkWidget * ghb_create_audio_settings_row(signal_user_data_t *ud)
ghb_audio_encoder_opts_set(combo);
// Init to first audio encoder
const hb_encoder_t *aud_enc = hb_audio_encoder_get_next(NULL);
- ghb_update_widget(GTK_WIDGET(combo), ghb_int64_value(aud_enc->codec));
+ ghb_update_widget(GTK_WIDGET(combo), ghb_int_value(aud_enc->codec));
gtk_widget_set_tooltip_markup(GTK_WIDGET(combo),
_("Set the audio codec to encode this track with."));
gtk_widget_set_valign(GTK_WIDGET(combo), GTK_ALIGN_CENTER);
@@ -1847,7 +1847,7 @@ GtkWidget * ghb_create_audio_settings_row(signal_user_data_t *ud)
combo = GTK_COMBO_BOX(gtk_combo_box_new());
ghb_init_combo_box(combo);
ghb_audio_bitrate_opts_set(combo, FALSE);
- ghb_update_widget(GTK_WIDGET(combo), ghb_int64_value(192));
+ ghb_update_widget(GTK_WIDGET(combo), ghb_int_value(192));
gtk_widget_set_tooltip_markup(GTK_WIDGET(combo),
_("Set the bitrate to encode this track with."));
gtk_widget_set_valign(GTK_WIDGET(combo), GTK_ALIGN_CENTER);
@@ -1900,7 +1900,7 @@ GtkWidget * ghb_create_audio_settings_row(signal_user_data_t *ud)
combo = GTK_COMBO_BOX(gtk_combo_box_new());
ghb_init_combo_box(combo);
ghb_mix_opts_set(combo);
- ghb_update_widget(GTK_WIDGET(combo), ghb_int64_value(HB_AMIXDOWN_5POINT1));
+ ghb_update_widget(GTK_WIDGET(combo), ghb_int_value(HB_AMIXDOWN_5POINT1));
gtk_widget_set_tooltip_markup(GTK_WIDGET(combo),
_("Set the mixdown of the output audio track."));
gtk_widget_set_valign(GTK_WIDGET(combo), GTK_ALIGN_CENTER);
@@ -1913,7 +1913,7 @@ GtkWidget * ghb_create_audio_settings_row(signal_user_data_t *ud)
combo = GTK_COMBO_BOX(gtk_combo_box_new());
ghb_init_combo_box(combo);
ghb_audio_samplerate_opts_set(combo);
- ghb_update_widget(GTK_WIDGET(combo), ghb_int64_value(0));
+ ghb_update_widget(GTK_WIDGET(combo), ghb_int_value(0));
gtk_widget_set_tooltip_markup(GTK_WIDGET(combo),
_("Set the sample rate of the output audio track."));
gtk_widget_set_valign(GTK_WIDGET(combo), GTK_ALIGN_CENTER);
@@ -2053,7 +2053,7 @@ audio_def_setting_update(signal_user_data_t *ud, GtkWidget *widget)
int count = ghb_array_len(alist);
if (!block_updates && index >= 0 && index < count)
{
- GhbValue *adict = ghb_array_get_nth(alist, index);
+ GhbValue *adict = ghb_array_get(alist, index);
ghb_widget_to_setting(adict, widget);
}
}
@@ -2161,7 +2161,7 @@ void audio_def_set_limits(signal_user_data_t *ud, GtkWidget *widget, gboolean se
if (index < 0 || index >= count)
return;
- GhbValue *adict = ghb_array_get_nth(alist, index);
+ GhbValue *adict = ghb_array_get(alist, index);
int codec = ghb_settings_audio_encoder_codec(adict, "AudioEncoder");
int fallback = ghb_settings_audio_encoder_codec(ud->settings,
@@ -2248,7 +2248,7 @@ audio_def_quality_enable_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
gint index = gtk_list_box_row_get_index(row);
GhbValue *alist = ghb_settings_get_value(ud->settings, "AudioList");
- GhbValue *adict = ghb_array_get_nth(alist, index);
+ GhbValue *adict = ghb_array_get(alist, index);
audio_def_settings_bitrate_show(GTK_WIDGET(row),
!ghb_settings_get_boolean(adict, "AudioTrackQualityEnable"));
@@ -2266,7 +2266,7 @@ audio_def_quality_changed_cb(GtkWidget *widget, gdouble quality, signal_user_dat
gint index = gtk_list_box_row_get_index(row);
GhbValue *alist = ghb_settings_get_value(ud->settings, "AudioList");
- GhbValue *adict = ghb_array_get_nth(alist, index);
+ GhbValue *adict = ghb_array_get(alist, index);
char *s_quality = get_quality_string(adict, quality);
ghb_update_widget(quality_label, ghb_string_value(s_quality));
g_free(s_quality);
@@ -2311,13 +2311,13 @@ audio_def_setting_add_cb(GtkWidget *widget, signal_user_data_t *ud)
if (count > 0)
{
// Use first item in list as defaults for new entries.
- adict = ghb_value_dup(ghb_array_get_nth(alist, 0));
+ adict = ghb_value_dup(ghb_array_get(alist, 0));
audio_def_update_widgets(GTK_WIDGET(row), adict);
}
else
{
// Use hard coded defaults
- adict = ghb_dict_value_new();
+ adict = ghb_dict_new();
audio_def_settings_init_row(adict, GTK_WIDGET(row));
}
ghb_array_append(alist, adict);
@@ -2420,7 +2420,7 @@ audio_def_lang_list_init(signal_user_data_t *ud)
lang_list = ghb_settings_get_value(ud->settings, "AudioLanguageList");
if (lang_list == NULL)
{
- lang_list = ghb_array_value_new(8);
+ lang_list = ghb_array_new();
ghb_settings_set_value(ud->settings, "AudioLanguageList", lang_list);
}
@@ -2428,7 +2428,7 @@ audio_def_lang_list_init(signal_user_data_t *ud)
count = ghb_array_len(lang_list);
for (ii = 0; ii < count; )
{
- GhbValue *lang_val = ghb_array_get_nth(lang_list, ii);
+ GhbValue *lang_val = ghb_array_get(lang_list, ii);
int idx = ghb_lookup_audio_lang(lang_val);
GtkListBox *avail, *selected;
@@ -2467,7 +2467,7 @@ void ghb_audio_defaults_to_ui(signal_user_data_t *ud)
alist = ghb_settings_get_value(ud->settings, "AudioList");
if (alist == NULL)
{
- alist = ghb_array_value_new(8);
+ alist = ghb_array_new();
ghb_settings_set_value(ud->settings, "AudioList", alist);
}
@@ -2482,7 +2482,7 @@ void ghb_audio_defaults_to_ui(signal_user_data_t *ud)
{
GhbValue *adict;
- adict = ghb_array_get_nth(alist, ii);
+ adict = ghb_array_get(alist, ii);
widget = ghb_create_audio_settings_row(ud);
gtk_list_box_insert(list_box, widget, -1);
audio_def_update_widgets(widget, adict);
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c
index e81bf21a5..f1709dd81 100644
--- a/gtk/src/callbacks.c
+++ b/gtk/src/callbacks.c
@@ -115,23 +115,22 @@ dep_check(signal_user_data_t *ud, const gchar *name, gboolean *out_hide)
gint count;
gboolean result = TRUE;
GhbValue *array, *data;
- gchar *widget_name;
+ const gchar *widget_name;
g_debug("dep_check () %s", name);
if (rev_map == NULL) return TRUE;
- array = ghb_dict_lookup(rev_map, name);
+ array = ghb_dict_get(rev_map, name);
count = ghb_array_len(array);
*out_hide = FALSE;
for (ii = 0; ii < count; ii++)
{
- data = ghb_array_get_nth(array, ii);
- widget_name = ghb_value_string(ghb_array_get_nth(data, 0));
+ data = ghb_array_get(array, ii);
+ widget_name = ghb_value_get_string(ghb_array_get(data, 0));
widget = GHB_WIDGET(ud->builder, widget_name);
dep_object = gtk_builder_get_object(ud->builder, name);
if (widget != NULL && !gtk_widget_is_sensitive(widget))
{
- g_free(widget_name);
continue;
}
if (dep_object == NULL)
@@ -146,11 +145,10 @@ dep_check(signal_user_data_t *ud, const gchar *name, gboolean *out_hide)
gboolean sensitive = FALSE;
gboolean die, hide;
- die = ghb_value_boolean(ghb_array_get_nth(data, 2));
- hide = ghb_value_boolean(ghb_array_get_nth(data, 3));
- value = ghb_value_string(ghb_array_get_nth(data, 1));
- values = g_strsplit(value, "|", 10);
- g_free(value);
+ die = ghb_value_get_bool(ghb_array_get(data, 2));
+ hide = ghb_value_get_bool(ghb_array_get(data, 3));
+ const char *tmp = ghb_value_get_string(ghb_array_get(data, 1));
+ values = g_strsplit(tmp, "|", 10);
if (widget)
value = ghb_widget_string(widget);
@@ -194,7 +192,6 @@ dep_check(signal_user_data_t *ud, const gchar *name, gboolean *out_hide)
g_strfreev (values);
g_free(value);
}
- g_free(widget_name);
}
return result;
}
@@ -209,7 +206,7 @@ ghb_check_dependency(
const gchar *name;
GhbValue *array, *data;
gint count, ii;
- gchar *dep_name;
+ const gchar *dep_name;
GType type;
if (widget != NULL)
@@ -225,20 +222,19 @@ ghb_check_dependency(
g_debug("ghb_check_dependency() %s", name);
if (dep_map == NULL) return;
- array = ghb_dict_lookup(dep_map, name);
+ array = ghb_dict_get(dep_map, name);
count = ghb_array_len(array);
for (ii = 0; ii < count; ii++)
{
gboolean sensitive;
gboolean hide;
- data = ghb_array_get_nth(array, ii);
- dep_name = ghb_value_string(data);
+ data = ghb_array_get(array, ii);
+ dep_name = ghb_value_get_string(data);
dep_object = gtk_builder_get_object(ud->builder, dep_name);
if (dep_object == NULL)
{
g_message("Failed to find dependent widget %s", dep_name);
- g_free(dep_name);
continue;
}
sensitive = dep_check(ud, dep_name, &hide);
@@ -257,7 +253,6 @@ ghb_check_dependency(
gtk_widget_show_now(GTK_WIDGET(dep_object));
}
}
- g_free(dep_name);
}
}
@@ -271,7 +266,7 @@ ghb_check_all_depencencies(signal_user_data_t *ud)
g_debug("ghb_check_all_depencencies ()");
if (rev_map == NULL) return;
- ghb_dict_iter_init(rev_map, &iter);
+ iter = ghb_dict_iter_init(rev_map);
while (ghb_dict_iter_next(rev_map, &iter, &dep_name, &value))
{
gboolean sensitive;
@@ -1141,10 +1136,10 @@ show_settings(GhbValue *settings)
const gchar *key;
GhbValue *gval;
- ghb_dict_iter_init(settings, &iter);
+ iter = ghb_dict_iter_init(settings);
while (ghb_dict_iter_next(settings, &iter, &key, &gval))
{
- char *str = ghb_value_string(gval);
+ char *str = ghb_value_get_string_xform(gval);
printf("show key %s val %s\n", key, str);
g_free(str);
}
@@ -1918,7 +1913,7 @@ load_all_titles(signal_user_data_t *ud, int titleindex)
if (count == 0)
count = 1;
- settings_array = ghb_array_value_new(count);
+ settings_array = ghb_array_new();
preset = ghb_get_current_preset(ud);
if (preset != NULL)
@@ -1944,14 +1939,14 @@ load_all_titles(signal_user_data_t *ud, int titleindex)
set_title_settings(ud, settings);
ghb_array_append(settings_array, settings);
}
- ghb_value_free(preset_path);
+ ghb_value_free(&preset_path);
if (titleindex < 0 || titleindex >= count)
{
titleindex = 0;
}
- ghb_value_free(ud->settings_array);
+ ghb_value_free(&ud->settings_array);
ud->settings_array = settings_array;
- ud->settings = ghb_array_get_nth(ud->settings_array, titleindex);
+ ud->settings = ghb_array_get(ud->settings_array, titleindex);
}
static gboolean update_preview = FALSE;
@@ -1968,7 +1963,7 @@ title_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
count = ghb_array_len(ud->settings_array);
int idx = (titleindex >= 0 && titleindex < count) ? titleindex : 0;
- ud->settings = ghb_array_get_nth(ud->settings_array, idx);
+ ud->settings = ghb_array_get(ud->settings_array, idx);
ghb_load_settings(ud);
ghb_audio_title_change(ud, title != NULL);
@@ -2691,7 +2686,7 @@ find_queue_job(GhbValue *queue, gint unique_id, GhbValue **job)
count = ghb_array_len(queue);
for (ii = 0; ii < count; ii++)
{
- js = ghb_array_get_nth(queue, ii);
+ js = ghb_array_get(queue, ii);
job_unique_id = ghb_settings_get_int(js, "job_unique_id");
if (job_unique_id == unique_id)
{
@@ -2850,7 +2845,7 @@ queue_pending_count(GhbValue *queue)
for (ii = 0; ii < count; ii++)
{
- js = ghb_array_get_nth(queue, ii);
+ js = ghb_array_get(queue, ii);
status = ghb_settings_get_int(js, "job_status");
if (status == GHB_QUEUE_PENDING)
{
@@ -2890,7 +2885,7 @@ ghb_start_next_job(signal_user_data_t *ud)
for (ii = 0; ii < count; ii++)
{
- js = ghb_array_get_nth(ud->queue, ii);
+ js = ghb_array_get(ud->queue, ii);
status = ghb_settings_get_int(js, "job_status");
if (status == GHB_QUEUE_PENDING)
{
@@ -3142,11 +3137,11 @@ ghb_backend_events(signal_user_data_t *ud)
if (title == NULL)
{
gtk_label_set_text(label, _("No Title Found"));
- ghb_ui_update(ud, "title", ghb_int64_value(-1));
+ ghb_ui_update(ud, "title", ghb_int_value(-1));
}
else
{
- ghb_ui_update(ud, "title", ghb_int64_value(title->index));
+ ghb_ui_update(ud, "title", ghb_int_value(title->index));
}
if (ghb_queue_edit_settings != NULL)
@@ -3677,13 +3672,14 @@ chapter_refresh_list_row_ui(
const hb_title_t *title,
int index)
{
- gchar *chapter, *s_duration, *s_start;
+ const gchar *chapter;
+ gchar *s_duration, *s_start;
gint hh, mm, ss;
gint64 duration, start;
// Update row with settings data
g_debug("Updating chapter row ui");
- chapter = ghb_value_string(ghb_array_get_nth(chapter_list, index));
+ chapter = ghb_value_get_string(ghb_array_get(chapter_list, index));
duration = ghb_get_chapter_duration(title, index) / 90000;
break_duration(duration, &hh, &mm, &ss);
s_duration = g_strdup_printf("%02d:%02d:%02d", hh, mm, ss);
@@ -3697,7 +3693,6 @@ chapter_refresh_list_row_ui(
3, chapter,
4, TRUE,
-1);
- g_free(chapter);
g_free(s_duration);
g_free(s_start);
}
@@ -3815,7 +3810,7 @@ chapter_edited_cb(
GhbValue *chapter;
chapters = ghb_settings_get_value(ud->settings, "chapter_list");
- chapter = ghb_array_get_nth(chapters, index-1);
+ chapter = ghb_array_get(chapters, index-1);
ghb_string_value_set(chapter, text);
if ((chapter_edit_key == GDK_KEY_Return || chapter_edit_key == GDK_KEY_Down) &&
gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter))
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index 084b89ed5..5a65d20e1 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -771,8 +771,8 @@ find_combo_entry(combo_opts_t *opts, const GhbValue *gval)
if (ghb_value_type(gval) == GHB_STRING)
{
- gchar *str;
- str = ghb_value_string(gval);
+ const gchar *str;
+ str = ghb_value_get_string(gval);
for (ii = 0; ii < opts->count; ii++)
{
if (strcmp(opts->map[ii].shortOpt, str) == 0)
@@ -780,13 +780,12 @@ find_combo_entry(combo_opts_t *opts, const GhbValue *gval)
break;
}
}
- g_free(str);
return ii;
}
else if (ghb_value_type(gval) == GHB_DOUBLE)
{
gdouble val;
- val = ghb_value_double(gval);
+ val = ghb_value_get_double(gval);
for (ii = 0; ii < opts->count; ii++)
{
if (opts->map[ii].ivalue == val)
@@ -800,7 +799,7 @@ find_combo_entry(combo_opts_t *opts, const GhbValue *gval)
ghb_value_type(gval) == GHB_BOOL)
{
gint64 val;
- val = ghb_value_int64(gval);
+ val = ghb_value_get_int(gval);
for (ii = 0; ii < opts->count; ii++)
{
if ((gint64)opts->map[ii].ivalue == val)
@@ -900,43 +899,37 @@ int
ghb_lookup_audio_lang(const GhbValue *glang)
{
gint ii;
- gchar *str;
+ const gchar *str;
- str = ghb_value_string(glang);
+ str = ghb_value_get_string(glang);
for (ii = 0; ii < LANG_TABLE_SIZE; ii++)
{
if (ghb_language_table[ii].iso639_2 &&
strcmp(ghb_language_table[ii].iso639_2, str) == 0)
{
- g_free(str);
return ii;
}
if (ghb_language_table[ii].iso639_2b &&
strcmp(ghb_language_table[ii].iso639_2b, str) == 0)
{
- g_free(str);
return ii;
}
if (ghb_language_table[ii].iso639_1 &&
strcmp(ghb_language_table[ii].iso639_1, str) == 0)
{
- g_free(str);
return ii;
}
if (ghb_language_table[ii].native_name &&
strcmp(ghb_language_table[ii].native_name, str) == 0)
{
- g_free(str);
return ii;
}
if (ghb_language_table[ii].eng_name &&
strcmp(ghb_language_table[ii].eng_name, str) == 0)
{
- g_free(str);
return ii;
}
}
- g_free(str);
return -1;
}
@@ -2037,7 +2030,7 @@ video_tune_opts_set(signal_user_data_t *ud, const gchar *name)
// Check if encoder has been set yet.
// If not, bail
- GhbValue *value = ghb_dict_lookup(ud->settings, "VideoEncoder");
+ GhbValue *value = ghb_dict_get(ud->settings, "VideoEncoder");
if (value == NULL) return;
int encoder = ghb_get_video_encoder(ud->settings);
@@ -2086,7 +2079,7 @@ video_profile_opts_set(signal_user_data_t *ud, const gchar *name)
// Check if encoder has been set yet.
// If not, bail
- GhbValue *value = ghb_dict_lookup(ud->settings, "VideoEncoder");
+ GhbValue *value = ghb_dict_get(ud->settings, "VideoEncoder");
if (value == NULL) return;
int encoder = ghb_get_video_encoder(ud->settings);
@@ -2123,7 +2116,7 @@ video_level_opts_set(signal_user_data_t *ud, const gchar *name)
// Check if encoder has been set yet.
// If not, bail
- GhbValue *value = ghb_dict_lookup(ud->settings, "VideoEncoder");
+ GhbValue *value = ghb_dict_get(ud->settings, "VideoEncoder");
if (value == NULL) return;
int encoder = ghb_get_video_encoder(ud->settings);
@@ -2845,7 +2838,7 @@ ghb_get_chapters(const hb_title_t *title)
gint count, ii;
GhbValue *chapters = NULL;
- chapters = ghb_array_value_new(0);
+ chapters = ghb_array_new();
if (title == NULL) return chapters;
count = hb_list_count( title->list_chapter );
@@ -2879,7 +2872,7 @@ ghb_ac3_in_audio_list(const GhbValue *audio_list)
GhbValue *asettings;
gint acodec;
- asettings = ghb_array_get_nth(audio_list, ii);
+ asettings = ghb_array_get(audio_list, ii);
acodec = ghb_settings_audio_encoder_codec(asettings, "AudioEncoder");
if (acodec & HB_ACODEC_AC3)
return TRUE;
@@ -3939,7 +3932,7 @@ ghb_validate_subtitles(GhbValue *settings, GtkWindow *parent)
count = ghb_array_len(slist);
for (ii = 0; ii < count; ii++)
{
- subtitle = ghb_array_get_nth(slist, ii);
+ subtitle = ghb_array_get(slist, ii);
track = ghb_settings_get_int(subtitle, "SubtitleTrack");
source = ghb_settings_get_int(subtitle, "SubtitleSource");
burned = track != -1 &&
@@ -4023,7 +4016,7 @@ ghb_validate_audio(GhbValue *settings, GtkWindow *parent)
hb_audio_config_t *aconfig;
int track, codec;
- asettings = ghb_array_get_nth(audio_list, ii);
+ asettings = ghb_array_get(audio_list, ii);
track = ghb_settings_get_int(asettings, "AudioTrack");
codec = ghb_settings_audio_encoder_codec(asettings, "AudioEncoder");
if (codec == HB_ACODEC_AUTO_PASS)
@@ -4404,8 +4397,8 @@ add_job(hb_handle_t *h, GhbValue *js, gint unique_id)
gchar *name;
name = NULL;
- chapter = ghb_array_get_nth(chapters, chap);
- name = ghb_value_string(chapter);
+ chapter = ghb_array_get(chapters, chap);
+ name = ghb_value_get_string_xform(chapter);
if (name == NULL)
{
name = g_strdup_printf (_("Chapter %2d"), chap+1);
@@ -4646,7 +4639,7 @@ add_job(hb_handle_t *h, GhbValue *js, gint unique_id)
const char *aname;
double gain, drc, quality;
- asettings = ghb_array_get_nth(audio_list, ii);
+ asettings = ghb_array_get(audio_list, ii);
track = ghb_settings_get_int(asettings, "AudioTrack");
aname = ghb_settings_get_const_string(asettings, "AudioTrackName");
acodec = ghb_settings_audio_encoder_codec(asettings, "AudioEncoder");
@@ -4717,7 +4710,7 @@ add_job(hb_handle_t *h, GhbValue *js, gint unique_id)
GhbValue *ssettings;
gint source;
- ssettings = ghb_array_get_nth(subtitle_list, ii);
+ ssettings = ghb_array_get(subtitle_list, ii);
force = ghb_settings_get_boolean(ssettings, "SubtitleForced");
burned = ghb_settings_get_boolean(ssettings, "SubtitleBurned");
diff --git a/gtk/src/main.c b/gtk/src/main.c
index d05b66f84..3a9d581b1 100644
--- a/gtk/src/main.c
+++ b/gtk/src/main.c
@@ -886,7 +886,7 @@ main(int argc, char *argv[])
ud->globals = ghb_settings_new();
ud->prefs = ghb_settings_new();
- ud->settings_array = ghb_array_value_new(1);
+ ud->settings_array = ghb_array_new();
ud->settings = ghb_settings_new();
ghb_array_append(ud->settings_array, ud->settings);
@@ -1049,7 +1049,7 @@ main(int argc, char *argv[])
if (preset)
{
ghb_select_preset(ud->builder, preset);
- ghb_value_free(preset);
+ ghb_value_free(&preset);
}
}
else
@@ -1230,11 +1230,11 @@ main(int argc, char *argv[])
gtk_main();
ghb_backend_close();
- ghb_value_free(ud->queue);
- ghb_value_free(ud->settings_array);
- ghb_value_free(ud->prefs);
- ghb_value_free(ud->globals);
- ghb_value_free(ud->x264_priv);
+ ghb_value_free(&ud->queue);
+ ghb_value_free(&ud->settings_array);
+ ghb_value_free(&ud->prefs);
+ ghb_value_free(&ud->globals);
+ ghb_value_free(&ud->x264_priv);
g_io_channel_unref(ud->activity_log);
ghb_settings_close();
diff --git a/gtk/src/plist.c b/gtk/src/plist.c
index 51430cc5b..2507a67a6 100644
--- a/gtk/src/plist.c
+++ b/gtk/src/plist.c
@@ -118,12 +118,12 @@ start_element(
} break;
case P_DICT:
{
- gval = ghb_dict_value_new();
+ gval = ghb_dict_new();
g_queue_push_head(pd->stack, gval);
} break;
case P_ARRAY:
{
- gval = ghb_array_value_new(128);
+ gval = ghb_array_new();
g_queue_push_head(pd->stack, gval);
} break;
case P_INTEGER:
@@ -166,11 +166,11 @@ start_element(
if (pd->key == NULL)
{
g_warning("No key for dictionary item");
- ghb_value_free(gval);
+ ghb_value_free(&gval);
}
else
{
- ghb_dict_insert(current, pd->key, gval);
+ ghb_dict_set(current, pd->key, gval);
}
}
else
@@ -243,7 +243,7 @@ end_element(
case P_INTEGER:
{
gint64 val = g_strtod(pd->value, NULL);
- gval = ghb_int64_value_new(val);
+ gval = ghb_int_value_new(val);
} break;
case P_REAL:
{
@@ -256,11 +256,11 @@ end_element(
} break;
case P_TRUE:
{
- gval = ghb_boolean_value_new(TRUE);
+ gval = ghb_bool_value_new(TRUE);
} break;
case P_FALSE:
{
- gval = ghb_boolean_value_new(FALSE);
+ gval = ghb_bool_value_new(FALSE);
} break;
default:
{
@@ -287,11 +287,11 @@ end_element(
if (pd->key == NULL)
{
g_warning("No key for dictionary item");
- ghb_value_free(gval);
+ ghb_value_free(&gval);
}
else
{
- ghb_dict_insert(current, pd->key, gval);
+ ghb_dict_set(current, pd->key, gval);
}
}
else
@@ -431,7 +431,7 @@ gval_write(FILE *file, GhbValue *gval)
count = ghb_array_len(gval);
for (ii = 0; ii < count; ii++)
{
- val = ghb_array_get_nth(gval, ii);
+ val = ghb_array_get(gval, ii);
gval_write(file, val);
}
indent--;
@@ -446,7 +446,7 @@ gval_write(FILE *file, GhbValue *gval)
indent_fprintf(file, indent, "<dict>\n");
indent++;
- ghb_dict_iter_init(gval, &iter);
+ iter = ghb_dict_iter_init(gval);
while (ghb_dict_iter_next(gval, &iter, &key, &val))
{
indent_fprintf(file, indent, "<key>%s</key>\n", key);
@@ -459,7 +459,7 @@ gval_write(FILE *file, GhbValue *gval)
else if (gtype == GHB_BOOL)
{
gchar *tag;
- if (ghb_value_boolean(gval))
+ if (ghb_value_get_bool(gval))
{
tag = "true";
}
@@ -471,17 +471,17 @@ gval_write(FILE *file, GhbValue *gval)
}
else if (gtype == GHB_DOUBLE)
{
- gdouble val = ghb_value_double(gval);
+ gdouble val = ghb_value_get_double(gval);
indent_fprintf(file, indent, "<real>%.17g</real>\n", val);
}
else if (gtype == GHB_INT)
{
- gint64 val = ghb_value_int64(gval);
+ gint64 val = ghb_value_get_int(gval);
indent_fprintf(file, indent, "<integer>%"PRId64"</integer>\n", val);
}
else if (gtype == GHB_STRING)
{
- const gchar *str = ghb_value_string(gval);
+ const gchar *str = ghb_value_get_string(gval);
gchar *esc = g_markup_escape_text(str, -1);
indent_fprintf(file, indent, "<string>%s</string>\n", esc);
g_free(esc);
diff --git a/gtk/src/presets.c b/gtk/src/presets.c
index 688c8d5e0..099841b51 100644
--- a/gtk/src/presets.c
+++ b/gtk/src/presets.c
@@ -60,10 +60,10 @@ dict_clean(GhbValue *dict, GhbValue *template)
GhbValue *val;
GhbValue *template_val;
- ghb_dict_iter_init(tmp, &iter);
+ iter = ghb_dict_iter_init(tmp);
while (ghb_dict_iter_next(tmp, &iter, &key, &val))
{
- template_val = ghb_dict_lookup(template, key);
+ template_val = ghb_dict_get(template, key);
if (template_val == NULL)
{
ghb_dict_remove(dict, key);
@@ -71,23 +71,23 @@ dict_clean(GhbValue *dict, GhbValue *template)
if (ghb_value_type(val) == GHB_DICT &&
ghb_value_type(template_val) == GHB_DICT)
{
- val = ghb_dict_lookup(dict, key);
+ val = ghb_dict_get(dict, key);
dict_clean(val, template_val);
}
if (ghb_value_type(val) == GHB_ARRAY &&
ghb_value_type(template_val) == GHB_ARRAY &&
ghb_array_len(template_val) > 0)
{
- template_val = ghb_array_get_nth(template_val, 0);
+ template_val = ghb_array_get(template_val, 0);
if (ghb_value_type(template_val) == GHB_DICT)
{
- val = ghb_dict_lookup(dict, key);
+ val = ghb_dict_get(dict, key);
int count = ghb_array_len(val);
int ii;
for (ii = 0; ii < count; ii++)
{
GhbValue *array_val;
- array_val = ghb_array_get_nth(val, ii);
+ array_val = ghb_array_get(val, ii);
if (ghb_value_type(array_val) == GHB_DICT)
{
dict_clean(array_val, template_val);
@@ -96,7 +96,7 @@ dict_clean(GhbValue *dict, GhbValue *template)
}
}
}
- ghb_value_free(tmp);
+ ghb_value_free(&tmp);
}
gint
@@ -144,7 +144,7 @@ ghb_parse_preset_path(const gchar *path)
GhbValue *preset;
gint ii;
- preset = ghb_array_value_new(MAX_NESTED_PRESET);
+ preset = ghb_array_new();
split = g_strsplit(path, "#", MAX_NESTED_PRESET);
for (ii = 0; split[ii] != NULL; ii++)
{
@@ -161,7 +161,7 @@ preset_path_from_indices(GhbValue *presets, gint *indices, gint len)
GhbValue *path;
g_debug("preset_path_from_indices");
- path = ghb_array_value_new(MAX_NESTED_PRESET);
+ path = ghb_array_new();
for (ii = 0; ii < len; ii++)
{
GhbValue *dict;
@@ -170,14 +170,14 @@ preset_path_from_indices(GhbValue *presets, gint *indices, gint len)
count = ghb_array_len(presets);
if (indices[ii] >= count) break;
- dict = ghb_array_get_nth(presets, indices[ii]);
- name = ghb_dict_lookup(dict, "PresetName");
+ dict = ghb_array_get(presets, indices[ii]);
+ name = ghb_dict_get(dict, "PresetName");
if (name)
ghb_array_append(path, ghb_value_dup(name));
- folder = ghb_value_boolean(preset_dict_get_value(dict, "Folder"));
+ folder = ghb_value_get_bool(preset_dict_get_value(dict, "Folder"));
if (!folder)
break;
- presets = ghb_dict_lookup(dict, "ChildrenArray");
+ presets = ghb_dict_get(dict, "ChildrenArray");
}
return path;
}
@@ -196,12 +196,11 @@ ghb_preset_path_string(const GhbValue *path)
count = ghb_array_len(path);
for (ii = 0; ii < count; ii++)
{
- val = ghb_array_get_nth(path, ii);
- str = ghb_value_string(val);
- g_string_append(gstr, str);
+ val = ghb_array_get(path, ii);
+ const char *tmp = ghb_value_get_string(val);
+ g_string_append(gstr, tmp);
if (ii < count-1)
g_string_append(gstr, "->");
- g_free(str);
}
}
str = g_string_free(gstr, FALSE);
@@ -239,7 +238,7 @@ preset_path_cmp(const GhbValue *path1, const GhbValue *path2)
{
gint count, ii;
GhbValue *val;
- gchar *str1, *str2;
+ const gchar *str1, *str2;
gint result;
count = ghb_array_len(path1);
@@ -248,15 +247,13 @@ preset_path_cmp(const GhbValue *path1, const GhbValue *path2)
return ii - count;
for (ii = 0; ii < count; ii++)
{
- val = ghb_array_get_nth(path1, ii);
- str1 = ghb_value_string(val);
- val = ghb_array_get_nth(path2, ii);
- str2 = ghb_value_string(val);
+ val = ghb_array_get(path1, ii);
+ str1 = ghb_value_get_string(val);
+ val = ghb_array_get(path2, ii);
+ str2 = ghb_value_get_string(val);
result = strcmp(str1, str2);
if (result != 0)
return result;
- g_free(str1);
- g_free(str2);
}
return 0;
}
@@ -273,13 +270,13 @@ presets_get_dict(GhbValue *presets, gint *indices, gint len)
{
count = ghb_array_len(presets);
if (indices[ii] >= count) return NULL;
- dict = ghb_array_get_nth(presets, indices[ii]);
+ dict = ghb_array_get(presets, indices[ii]);
if (ii < len-1)
{
- folder = ghb_value_boolean(preset_dict_get_value(dict, "Folder"));
+ folder = ghb_value_get_bool(preset_dict_get_value(dict, "Folder"));
if (!folder)
return NULL;
- presets = ghb_dict_lookup(dict, "ChildrenArray");
+ presets = ghb_dict_get(dict, "ChildrenArray");
}
}
if (ii < len)
@@ -298,11 +295,11 @@ presets_get_folder(GhbValue *presets, gint *indices, gint len)
{
count = ghb_array_len(presets);
if (indices[ii] >= count) return NULL;
- dict = ghb_array_get_nth(presets, indices[ii]);
- folder = ghb_value_boolean(preset_dict_get_value(dict, "Folder"));
+ dict = ghb_array_get(presets, indices[ii]);
+ folder = ghb_value_get_bool(preset_dict_get_value(dict, "Folder"));
if (!folder)
break;
- presets = ghb_dict_lookup(dict, "ChildrenArray");
+ presets = ghb_dict_get(dict, "ChildrenArray");
}
if (ii < len)
return NULL;
@@ -313,13 +310,13 @@ static GhbValue*
plist_get_dict(GhbValue *presets, const gchar *name)
{
if (presets == NULL || name == NULL) return NULL;
- return ghb_dict_lookup(presets, name);
+ return ghb_dict_get(presets, name);
}
static const gchar*
preset_get_name(GhbValue *dict)
{
- return ghb_value_const_string(preset_dict_get_value(dict, "PresetName"));
+ return ghb_value_get_string(preset_dict_get_value(dict, "PresetName"));
}
static gboolean
@@ -329,20 +326,20 @@ preset_folder_is_open(GhbValue *dict)
gval = preset_dict_get_value(dict, "FolderOpen");
if (gval != NULL)
- return ghb_value_boolean(gval);
+ return ghb_value_get_bool(gval);
return FALSE;
}
gboolean
ghb_preset_folder(GhbValue *dict)
{
- return ghb_value_int(preset_dict_get_value(dict, "Folder"));
+ return ghb_value_get_int(preset_dict_get_value(dict, "Folder"));
}
gint
ghb_preset_type(GhbValue *dict)
{
- return ghb_value_int(preset_dict_get_value(dict, "Type"));
+ return ghb_value_get_int(preset_dict_get_value(dict, "Type"));
}
static void
@@ -423,7 +420,7 @@ presets_find_element(GhbValue *presets, const gchar *name)
for (ii = 0; ii < count; ii++)
{
const gchar *str;
- dict = ghb_array_get_nth(presets, ii);
+ dict = ghb_array_get(presets, ii);
str = preset_get_name(dict);
if (strcmp(name, str) == 0)
{
@@ -444,9 +441,9 @@ single_find_pos(GhbValue *presets, const gchar *name, gint type)
for (ii = 0; ii < count; ii++)
{
const gchar *str;
- dict = ghb_array_get_nth(presets, ii);
+ dict = ghb_array_get(presets, ii);
str = preset_get_name(dict);
- ptype = ghb_value_int(preset_dict_get_value(dict, "Type"));
+ ptype = ghb_value_get_int(preset_dict_get_value(dict, "Type"));
if (strcasecmp(name, str) <= 0 && ptype == type)
{
return ii;
@@ -474,25 +471,25 @@ presets_find_pos(const GhbValue *path, gint type, gint *len)
indices = g_malloc(MAX_NESTED_PRESET * sizeof(gint));
for (ii = 0; ii < count-1; ii++)
{
- val = ghb_array_get_nth(path, ii);
- name = ghb_value_const_string(val);
+ val = ghb_array_get(path, ii);
+ name = ghb_value_get_string(val);
indices[ii] = presets_find_element(nested, name);
if (indices[ii] == -1) {
g_free(indices);
return NULL;
}
- dict = ghb_array_get_nth(nested, indices[ii]);
- folder = ghb_value_boolean(preset_dict_get_value(dict, "Folder"));
+ dict = ghb_array_get(nested, indices[ii]);
+ folder = ghb_value_get_bool(preset_dict_get_value(dict, "Folder"));
nested = NULL;
if (!folder)
break;
- nested = ghb_dict_lookup(dict, "ChildrenArray");
+ nested = ghb_dict_get(dict, "ChildrenArray");
}
if (nested)
{
const gchar *name;
- name = ghb_value_const_string(ghb_array_get_nth(path, count-1));
+ name = ghb_value_get_string(ghb_array_get(path, count-1));
indices[ii] = single_find_pos(nested, name, type);
ii++;
}
@@ -505,20 +502,20 @@ preset_tree_depth(GhbValue *dict)
{
gboolean folder;
- folder = ghb_value_boolean(preset_dict_get_value(dict, "Folder"));
+ folder = ghb_value_get_bool(preset_dict_get_value(dict, "Folder"));
if (folder)
{
gint depth = 0;
gint count, ii;
GhbValue *presets;
- presets = ghb_dict_lookup(dict, "ChildrenArray");
+ presets = ghb_dict_get(dict, "ChildrenArray");
count = ghb_array_len(presets);
for (ii = 0; ii < count; ii++)
{
gint tmp;
- dict = ghb_array_get_nth(presets, ii);
+ dict = ghb_array_get(presets, ii);
tmp = preset_tree_depth(dict);
depth = MAX(depth, tmp);
}
@@ -536,7 +533,7 @@ preset_is_default(GhbValue *dict)
const GhbValue *val;
val = preset_dict_get_value(dict, "Default");
- return ghb_value_boolean(val);
+ return ghb_value_get_bool(val);
}
static void
@@ -550,20 +547,20 @@ presets_clear_default(GhbValue *presets)
GhbValue *dict;
gboolean folder;
- dict = ghb_array_get_nth(presets, ii);
- folder = ghb_value_boolean(preset_dict_get_value(dict, "Folder"));
+ dict = ghb_array_get(presets, ii);
+ folder = ghb_value_get_bool(preset_dict_get_value(dict, "Folder"));
if (folder)
{
GhbValue *nested;
- nested = ghb_dict_lookup(dict, "ChildrenArray");
+ nested = ghb_dict_get(dict, "ChildrenArray");
presets_clear_default(nested);
}
else
{
if (preset_is_default(dict))
{
- ghb_dict_insert(dict, "Default", ghb_boolean_value_new(FALSE));
+ ghb_dict_set(dict, "Default", ghb_bool_value_new(FALSE));
}
}
}
@@ -581,19 +578,19 @@ presets_customize(GhbValue *presets)
gboolean folder;
gint ptype;
- dict = ghb_array_get_nth(presets, ii);
+ dict = ghb_array_get(presets, ii);
- ptype = ghb_value_int(preset_dict_get_value(dict, "Type"));
+ ptype = ghb_value_get_int(preset_dict_get_value(dict, "Type"));
if (ptype != PRESETS_CUSTOM)
{
- ghb_dict_insert(dict, "Type", ghb_int64_value_new(PRESETS_CUSTOM));
+ ghb_dict_set(dict, "Type", ghb_int_value_new(PRESETS_CUSTOM));
}
- folder = ghb_value_boolean(preset_dict_get_value(dict, "Folder"));
+ folder = ghb_value_get_bool(preset_dict_get_value(dict, "Folder"));
if (folder)
{
GhbValue *nested;
- nested = ghb_dict_lookup(dict, "ChildrenArray");
+ nested = ghb_dict_get(dict, "ChildrenArray");
presets_customize(nested);
}
}
@@ -611,14 +608,14 @@ presets_find_default2(GhbValue *presets, gint *len)
GhbValue *dict;
gboolean folder;
- dict = ghb_array_get_nth(presets, ii);
- folder = ghb_value_boolean(preset_dict_get_value(dict, "Folder"));
+ dict = ghb_array_get(presets, ii);
+ folder = ghb_value_get_bool(preset_dict_get_value(dict, "Folder"));
if (folder)
{
GhbValue *nested;
gint pos = *len;
- nested = ghb_dict_lookup(dict, "ChildrenArray");
+ nested = ghb_dict_get(dict, "ChildrenArray");
(*len)++;
indices = presets_find_default2(nested, len);
if (indices)
@@ -672,8 +669,8 @@ ghb_preset_indices_from_path(
*len = 0;
for (ii = 0; ii < count; ii++)
{
- val = ghb_array_get_nth(path, ii);
- name = ghb_value_const_string(val);
+ val = ghb_array_get(path, ii);
+ name = ghb_value_get_string(val);
indices[ii] = presets_find_element(nested, name);
if (indices[ii] == -1)
{
@@ -682,14 +679,14 @@ ghb_preset_indices_from_path(
}
if (ii < count-1)
{
- dict = ghb_array_get_nth(nested, indices[ii]);
- folder = ghb_value_boolean(preset_dict_get_value(dict, "Folder"));
+ dict = ghb_array_get(nested, indices[ii]);
+ folder = ghb_value_get_bool(preset_dict_get_value(dict, "Folder"));
if (!folder)
{
g_free(indices);
return NULL;
}
- nested = ghb_dict_lookup(dict, "ChildrenArray");
+ nested = ghb_dict_get(dict, "ChildrenArray");
}
}
*len = ii;
@@ -748,7 +745,7 @@ presets_set_default(gint *indices, gint len)
dict = presets_get_dict(presetsPlist, indices, len);
if (dict)
{
- ghb_dict_insert(dict, "Default", ghb_boolean_value_new(TRUE));
+ ghb_dict_set(dict, "Default", ghb_bool_value_new(TRUE));
}
store_presets();
}
@@ -762,7 +759,7 @@ presets_set_folder_open(gboolean open, gint *indices, gint len)
dict = presets_get_dict(presetsPlist, indices, len);
if (dict)
{
- ghb_dict_insert(dict, "FolderOpen", ghb_boolean_value_new(open));
+ ghb_dict_set(dict, "FolderOpen", ghb_bool_value_new(open));
}
}
@@ -779,25 +776,25 @@ key_cmp(gconstpointer a, gconstpointer b)
static const GhbValue*
preset_dict_get_value(GhbValue *dict, const gchar *key)
{
- return ghb_dict_lookup(dict, key);
+ return ghb_dict_get(dict, key);
}
static const char * dict_get_string(GhbValue *dict, const char *key)
{
- GhbValue *gval = ghb_dict_lookup(dict, key);
+ GhbValue *gval = ghb_dict_get(dict, key);
if (gval == NULL)
return NULL;
- return ghb_value_const_string(gval);
+ return ghb_value_get_string(gval);
}
static gboolean dict_get_boolean(GhbValue *dict, const char *key)
{
- GhbValue *gval = ghb_dict_lookup(dict, key);
+ GhbValue *gval = ghb_dict_get(dict, key);
if (gval == NULL)
return FALSE;
- return ghb_value_boolean(gval);
+ return ghb_value_get_bool(gval);
}
const gchar*
@@ -827,7 +824,7 @@ init_settings_from_array(
count = ghb_array_len(array);
for (ii = 0; ii < count; ii++)
{
- val = ghb_array_get_nth(array, ii);
+ val = ghb_array_get(array, ii);
ghb_array_append(dest, ghb_value_dup(val));
}
}
@@ -837,16 +834,16 @@ init_settings_from_array(
count = ghb_array_len(array);
// The first element of the template array is always the
// template for the allowed values
- gval = ghb_array_get_nth(template, 0);
+ gval = ghb_array_get(template, 0);
for (ii = 0; ii < count; ii++)
{
- val = ghb_array_get_nth(array, ii);
+ val = ghb_array_get(array, ii);
if (ghb_value_type(gval) == GHB_DICT)
{
GhbValue *new_dict;
if (val != NULL && ghb_value_type(val) == GHB_DICT)
{
- new_dict = ghb_dict_value_new();
+ new_dict = ghb_dict_new();
init_settings_from_dict(new_dict, gval, val, filter);
}
else
@@ -860,7 +857,7 @@ init_settings_from_array(
GhbValue *new_array;
if (val != NULL && ghb_value_type(val) == GHB_ARRAY)
{
- new_array = ghb_array_value_new(8);
+ new_array = ghb_array_new();
init_settings_from_array(new_array, gval, val, filter);
}
else
@@ -891,20 +888,20 @@ init_settings_from_dict(
const gchar *key;
GhbValue *gval, *val, *new_val;
- ghb_dict_iter_init(template, &iter);
+ iter = ghb_dict_iter_init(template);
// middle (void*) cast prevents gcc warning "defreferencing type-punned
// pointer will break strict-aliasing rules"
while (ghb_dict_iter_next(template, &iter, &key, &gval))
{
val = NULL;
if (dict)
- val = ghb_dict_lookup(dict, key);
+ val = ghb_dict_get(dict, key);
if (ghb_value_type(gval) == GHB_DICT)
{
GhbValue *new_dict;
if (val != NULL && ghb_value_type(val) == GHB_DICT)
{
- new_dict = ghb_dict_value_new();
+ new_dict = ghb_dict_new();
init_settings_from_dict(new_dict, gval, val, filter);
}
else
@@ -918,7 +915,7 @@ init_settings_from_dict(
GhbValue *new_array;
if (val != NULL && ghb_value_type(val) == GHB_ARRAY)
{
- new_array = ghb_array_value_new(8);
+ new_array = ghb_array_new();
init_settings_from_array(new_array, gval, val, filter);
}
else
@@ -943,12 +940,12 @@ init_settings_from_dict(
// If not filtering the source, copy source elements that
// were not in the template.
- ghb_dict_iter_init(dict, &iter);
+ iter = ghb_dict_iter_init(dict);
// middle (void*) cast prevents gcc warning "defreferencing type-punned
// pointer will break strict-aliasing rules"
while (ghb_dict_iter_next(dict, &iter, &key, &gval))
{
- val = ghb_dict_lookup(template, key);
+ val = ghb_dict_get(template, key);
if (val == NULL)
{
ghb_settings_set_value(dest, key, gval);
@@ -1009,14 +1006,14 @@ ghb_settings_to_ui(signal_user_data_t *ud, GhbValue *dict)
ghb_ui_settings_update(ud, dict, key, gval);
}
- ghb_dict_iter_init(tmp, &iter);
+ iter = ghb_dict_iter_init(tmp);
// middle (void*) cast prevents gcc warning "defreferencing type-punned
// pointer will break strict-aliasing rules"
while (ghb_dict_iter_next(tmp, &iter, &key, &gval))
{
ghb_ui_settings_update(ud, dict, key, gval);
}
- ghb_value_free(tmp);
+ ghb_value_free(&tmp);
}
static GhbValue *current_preset = NULL;
@@ -1028,7 +1025,7 @@ ghb_preset_is_custom()
if (current_preset == NULL) return FALSE;
val = preset_dict_get_value(current_preset, "Type");
- return (ghb_value_int(val) == 1);
+ return (ghb_value_get_int(val) == 1);
}
void
@@ -1059,14 +1056,14 @@ ghb_set_preset_settings_from_indices(
gboolean folder;
current_preset = dict;
- folder = ghb_value_boolean(preset_dict_get_value(dict, "Folder"));
+ folder = ghb_value_get_bool(preset_dict_get_value(dict, "Folder"));
if (folder)
ghb_preset_to_settings(ud->settings, NULL);
else
ghb_preset_to_settings(ud->settings, dict);
path = preset_path_from_indices(presetsPlist, indices, len);
ghb_settings_set_value(ud->settings, "preset", path);
- ghb_value_free(path);
+ ghb_value_free(&path);
}
}
@@ -1414,13 +1411,13 @@ ghb_prefs_save(GhbValue *settings)
if (dict == NULL) return;
pref_dict = plist_get_dict(prefsPlist, "Preferences");
if (pref_dict == NULL) return;
- ghb_dict_iter_init(dict, &iter);
+ iter = ghb_dict_iter_init(dict);
while (ghb_dict_iter_next(dict, &iter, &key, NULL))
{
value = ghb_settings_get_value(settings, key);
if (value != NULL)
{
- ghb_dict_insert(pref_dict, key, ghb_value_dup(value));
+ ghb_dict_set(pref_dict, key, ghb_value_dup(value));
}
}
store_prefs();
@@ -1438,10 +1435,10 @@ ghb_pref_save(GhbValue *settings, const gchar *key)
GhbValue *dict;
dict = plist_get_dict(prefsPlist, "Preferences");
if (dict == NULL) return;
- value2 = ghb_dict_lookup(dict, key);
+ value2 = ghb_dict_get(dict, key);
if (ghb_value_cmp(value, value2) != 0)
{
- ghb_dict_insert(dict, key, ghb_value_dup(value));
+ ghb_dict_set(dict, key, ghb_value_dup(value));
store_prefs();
prefs_modified = FALSE;
}
@@ -1459,10 +1456,10 @@ ghb_pref_set(GhbValue *settings, const gchar *key)
GhbValue *dict;
dict = plist_get_dict(prefsPlist, "Preferences");
if (dict == NULL) return;
- value2 = ghb_dict_lookup(dict, key);
+ value2 = ghb_dict_get(dict, key);
if (ghb_value_cmp(value, value2) != 0)
{
- ghb_dict_insert(dict, key, ghb_value_dup(value));
+ ghb_dict_set(dict, key, ghb_value_dup(value));
prefs_modified = TRUE;
}
}
@@ -1494,7 +1491,7 @@ ghb_settings_init(GhbValue *settings, const char *name)
// that have not yet been set. So set *all* settings first
// then update the ui.
internal = plist_get_dict(internalPlist, name);
- ghb_dict_iter_init(internal, &iter);
+ iter = ghb_dict_iter_init(internal);
// middle (void*) cast prevents gcc warning "defreferencing type-punned
// pointer will break strict-aliasing rules"
while (ghb_dict_iter_next(internal, &iter, &key, &gval))
@@ -1507,9 +1504,9 @@ void
ghb_settings_close()
{
if (presetsPlist)
- ghb_value_free(presetsPlist);
+ ghb_value_free(&presetsPlist);
if (prefsPlist)
- ghb_value_free(prefsPlist);
+ ghb_value_free(&prefsPlist);
}
#if defined(_WIN32)
@@ -1552,21 +1549,21 @@ ghb_prefs_load(signal_user_data_t *ud)
GhbValue *internalPlist = ghb_resource_get("internal-defaults");
prefsPlist = read_config_file("preferences");
if (prefsPlist == NULL)
- prefsPlist = ghb_dict_value_new();
+ prefsPlist = ghb_dict_new();
dict = plist_get_dict(prefsPlist, "Preferences");
internal = plist_get_dict(internalPlist, "Preferences");
if (dict == NULL && internal)
{
- dict = ghb_dict_value_new();
- ghb_dict_insert(prefsPlist, "Preferences", dict);
+ dict = ghb_dict_new();
+ ghb_dict_set(prefsPlist, "Preferences", dict);
// Get defaults from internal defaults
- ghb_dict_iter_init(internal, &iter);
+ iter = ghb_dict_iter_init(internal);
// middle (void*) cast prevents gcc warning "defreferencing type-punned
// pointer will break strict-aliasing rules"
while (ghb_dict_iter_next(internal, &iter, &key, &gval))
{
- ghb_dict_insert(dict, key, ghb_value_dup(gval));
+ ghb_dict_set(dict, key, ghb_value_dup(gval));
}
const gchar *dir = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
@@ -1574,16 +1571,16 @@ ghb_prefs_load(signal_user_data_t *ud)
{
dir = ".";
}
- ghb_dict_insert(dict, "ExportDirectory", ghb_string_value_new(dir));
+ ghb_dict_set(dict, "ExportDirectory", ghb_string_value_new(dir));
dir = g_get_user_special_dir (G_USER_DIRECTORY_VIDEOS);
if (dir == NULL)
{
dir = ".";
}
- ghb_dict_insert(dict, "destination_dir", ghb_string_value_new(dir));
+ ghb_dict_set(dict, "destination_dir", ghb_string_value_new(dir));
- ghb_dict_insert(dict, "SrtDir", ghb_string_value_new(dir));
+ ghb_dict_set(dict, "SrtDir", ghb_string_value_new(dir));
#if defined(_WIN32)
gchar *source;
@@ -1592,7 +1589,7 @@ ghb_prefs_load(signal_user_data_t *ud)
{
source = g_strdup("C:" G_DIR_SEPARATOR_S);
}
- ghb_dict_insert(dict, "default_source", ghb_string_value_new(source));
+ ghb_dict_set(dict, "default_source", ghb_string_value_new(source));
g_free(source);
#endif
store_prefs();
@@ -1696,7 +1693,7 @@ ghb_presets_list_init(
gboolean folder;
// Additional settings, add row
- dict = ghb_array_get_nth(presets, ii);
+ dict = ghb_array_get(presets, ii);
preset = preset_get_name(dict);
more_indices[len] = ii;
def = preset_is_default(dict);
@@ -1841,7 +1838,7 @@ presets_list_insert(
if (indices[len-1] >= count)
return;
// Additional settings, add row
- dict = ghb_array_get_nth(presets, indices[len-1]);
+ dict = ghb_array_get(presets, indices[len-1]);
preset = preset_get_name(dict);
def = preset_is_default(dict);
@@ -1898,8 +1895,8 @@ remove_std_presets(signal_user_data_t *ud)
GhbValue *dict;
gint ptype;
- dict = ghb_array_get_nth(presetsPlist, ii);
- ptype = ghb_value_int(preset_dict_get_value(dict, "Type"));
+ dict = ghb_array_get(presetsPlist, ii);
+ ptype = ghb_value_get_int(preset_dict_get_value(dict, "Type"));
if (ptype == PRESETS_BUILTIN)
{
if (ghb_presets_remove(presetsPlist, &indices, 1))
@@ -2016,66 +2013,6 @@ value_map_t decomb_xlat[] =
{NULL, NULL}
};
-#if 0
-extern iso639_lang_t ghb_language_table[];
-
-static GhbValue*
-export_lang_xlat2(GhbValue *lin_val)
-{
- GhbValue *gval;
-
- if (lin_val == NULL) return NULL;
- gint ii;
- gchar *str;
-
- str = ghb_value_string(lin_val);
- for (ii = 0; ghb_language_table[ii].eng_name; ii++)
- {
- if (strcmp(str, ghb_language_table[ii].iso639_2) == 0)
- {
- const gchar *lang;
-
- if (ghb_language_table[ii].native_name[0] != 0)
- lang = ghb_language_table[ii].native_name;
- else
- lang = ghb_language_table[ii].eng_name;
-
- gval = ghb_string_value_new(lang);
- g_free(str);
- return gval;
- }
- }
- g_debug("Can't map language value: (%s)", str);
- g_free(str);
- return NULL;
-}
-
-static GhbValue*
-import_lang_xlat2(GhbValue *mac_val)
-{
- GhbValue *gval;
-
- if (mac_val == NULL) return NULL;
- gint ii;
- gchar *str;
-
- str = ghb_value_string(mac_val);
- for (ii = 0; ghb_language_table[ii].eng_name; ii++)
- {
- if ((strcmp(str, ghb_language_table[ii].eng_name) == 0) ||
- (strcmp(str, ghb_language_table[ii].native_name) == 0))
- {
- gval = ghb_string_value_new(ghb_language_table[ii].iso639_2);
- g_free(str);
- return gval;
- }
- }
- g_debug("Can't map language value: (%s)", str);
- g_free(str);
- return NULL;
-}
-#endif
-
static GhbValue*
export_value_xlat2(value_map_t *value_map, GhbValue *lin_val, GhbType mac_type)
{
@@ -2086,7 +2023,7 @@ export_value_xlat2(value_map_t *value_map, GhbValue *lin_val, GhbType mac_type)
gchar *str;
GhbValue *sval;
- str = ghb_value_string(lin_val);
+ str = ghb_value_get_string_xform(lin_val);
for (ii = 0; value_map[ii].mac_val; ii++)
{
if (strcmp(str, value_map[ii].lin_val) == 0)
@@ -2097,10 +2034,10 @@ export_value_xlat2(value_map_t *value_map, GhbValue *lin_val, GhbType mac_type)
if (gval == NULL)
{
g_warning("can't transform");
- ghb_value_free(sval);
+ ghb_value_free(&sval);
return NULL;
}
- ghb_value_free(sval);
+ ghb_value_free(&sval);
return gval;
}
}
@@ -2116,7 +2053,7 @@ export_value_video_framerate(GhbValue *lin_val)
gchar *str;
const gchar *fr;
- str = ghb_value_string(lin_val);
+ str = ghb_value_get_string_xform(lin_val);
fr = hb_video_framerate_get_name(hb_video_framerate_get_from_name(str));
g_free(str);
if (fr != NULL)
@@ -2132,7 +2069,7 @@ export_value_audio_samplerate(GhbValue *lin_val)
gchar *str;
const gchar *sr;
- str = ghb_value_string(lin_val);
+ str = ghb_value_get_string_xform(lin_val);
sr = hb_audio_samplerate_get_name(hb_audio_samplerate_get_from_name(str));
g_free(str);
if (sr != NULL)
@@ -2145,12 +2082,11 @@ static GhbValue*
export_value_mixdown(GhbValue *lin_val)
{
GhbValue *sval = NULL;
- gchar *str;
+ const gchar *str;
const gchar *mix;
- str = ghb_value_string(lin_val);
+ str = ghb_value_get_string(lin_val);
mix = hb_mixdown_get_name(hb_mixdown_get_from_name(str));
- g_free(str);
if (mix != NULL)
sval = ghb_string_value_new(mix);
@@ -2161,12 +2097,11 @@ static GhbValue*
export_value_video_encoder(GhbValue *lin_val)
{
GhbValue *sval = NULL;
- gchar *str;
+ const gchar *str;
const gchar *enc;
- str = ghb_value_string(lin_val);
+ str = ghb_value_get_string(lin_val);
enc = hb_video_encoder_get_name(hb_video_encoder_get_from_name(str));
- g_free(str);
if (enc != NULL)
sval = ghb_string_value_new(enc);
@@ -2177,12 +2112,11 @@ static GhbValue*
export_value_audio_encoder(GhbValue *lin_val)
{
GhbValue *sval = NULL;
- gchar *str;
+ const gchar *str;
const gchar *enc;
- str = ghb_value_string(lin_val);
+ str = ghb_value_get_string(lin_val);
enc = hb_audio_encoder_get_name(hb_audio_encoder_get_from_name(str));
- g_free(str);
if (enc != NULL)
sval = ghb_string_value_new(enc);
@@ -2193,12 +2127,11 @@ static GhbValue*
export_value_container(GhbValue *lin_val)
{
GhbValue *sval = NULL;
- gchar *str;
+ const gchar *str;
const gchar *mux;
- str = ghb_value_string(lin_val);
+ str = ghb_value_get_string(lin_val);
mux = hb_container_get_name(hb_container_get_from_name(str));
- g_free(str);
if (mux != NULL)
sval = ghb_string_value_new(mux);
@@ -2213,41 +2146,41 @@ export_value_xlat(GhbValue *dict)
const gchar *key;
key = "VideoEncoder";
- lin_val = ghb_dict_lookup(dict, key);
+ lin_val = ghb_dict_get(dict, key);
gval = export_value_video_encoder(lin_val);
if (gval)
- ghb_dict_insert(dict, key, gval);
+ ghb_dict_set(dict, key, gval);
key = "FileFormat";
- lin_val = ghb_dict_lookup(dict, key);
+ lin_val = ghb_dict_get(dict, key);
gval = export_value_container(lin_val);
if (gval)
- ghb_dict_insert(dict, key, gval);
+ ghb_dict_set(dict, key, gval);
key = "VideoFramerate";
- lin_val = ghb_dict_lookup(dict, key);
+ lin_val = ghb_dict_get(dict, key);
gval = export_value_video_framerate(lin_val);
if (gval)
- ghb_dict_insert(dict, key, gval);
+ ghb_dict_set(dict, key, gval);
key = "PictureDetelecine";
- lin_val = ghb_dict_lookup(dict, key);
+ lin_val = ghb_dict_get(dict, key);
gval = export_value_xlat2(detel_xlat, lin_val, GHB_INT);
if (gval)
- ghb_dict_insert(dict, key, gval);
+ ghb_dict_set(dict, key, gval);
key = "PictureDecomb";
- lin_val = ghb_dict_lookup(dict, key);
+ lin_val = ghb_dict_get(dict, key);
gval = export_value_xlat2(decomb_xlat, lin_val, GHB_INT);
if (gval)
- ghb_dict_insert(dict, key, gval);
+ ghb_dict_set(dict, key, gval);
key = "PictureDeinterlace";
- lin_val = ghb_dict_lookup(dict, key);
+ lin_val = ghb_dict_get(dict, key);
gval = export_value_xlat2(deint_xlat, lin_val, GHB_INT);
if (gval)
- ghb_dict_insert(dict, key, gval);
+ ghb_dict_set(dict, key, gval);
#if 0
key = "PictureDenoisePreset";
- lin_val = ghb_dict_lookup(dict, key);
+ lin_val = ghb_dict_get(dict, key);
gval = export_value_xlat2(denoise_xlat, lin_val, GHB_INT);
if (gval)
- ghb_dict_insert(dict, key, gval);
+ ghb_dict_set(dict, key, gval);
#endif
gint count, ii;
@@ -2255,31 +2188,31 @@ export_value_xlat(GhbValue *dict)
GhbValue *adict;
key = "AudioEncoderFallback";
- lin_val = ghb_dict_lookup(dict, key);
+ lin_val = ghb_dict_get(dict, key);
gval = export_value_audio_encoder(lin_val);
if (gval)
- ghb_dict_insert(dict, key, gval);
+ ghb_dict_set(dict, key, gval);
- alist = ghb_dict_lookup(dict, "AudioList");
+ alist = ghb_dict_get(dict, "AudioList");
count = ghb_array_len(alist);
for (ii = 0; ii < count; ii++)
{
- adict = ghb_array_get_nth(alist, ii);
+ adict = ghb_array_get(alist, ii);
key = "AudioEncoder";
- lin_val = ghb_dict_lookup(adict, key);
+ lin_val = ghb_dict_get(adict, key);
gval = export_value_audio_encoder(lin_val);
if (gval)
- ghb_dict_insert(adict, key, gval);
+ ghb_dict_set(adict, key, gval);
key = "AudioSamplerate";
- lin_val = ghb_dict_lookup(adict, key);
+ lin_val = ghb_dict_get(adict, key);
gval = export_value_audio_samplerate(lin_val);
if (gval)
- ghb_dict_insert(adict, key, gval);
+ ghb_dict_set(adict, key, gval);
key = "AudioMixdown";
- lin_val = ghb_dict_lookup(adict, key);
+ lin_val = ghb_dict_get(adict, key);
gval = export_value_mixdown(lin_val);
if (gval)
- ghb_dict_insert(adict, key, gval);
+ ghb_dict_set(adict, key, gval);
}
}
@@ -2294,14 +2227,14 @@ import_value_xlat2(
GhbValue *gval, *def_val;
if (mac_val == NULL) return NULL;
- def_val = ghb_dict_lookup(defaults, key);
+ def_val = ghb_dict_get(defaults, key);
if (def_val)
{
gint ii;
gchar *str;
GhbValue *sval;
- str = ghb_value_string(mac_val);
+ str = ghb_value_get_string_xform(mac_val);
for (ii = 0; value_map[ii].mac_val; ii++)
{
if (strcmp(str, value_map[ii].mac_val) == 0 ||
@@ -2313,10 +2246,10 @@ import_value_xlat2(
if (gval == NULL)
{
g_warning("can't transform");
- ghb_value_free(sval);
+ ghb_value_free(&sval);
return NULL;
}
- ghb_value_free(sval);
+ ghb_value_free(&sval);
return gval;
}
}
@@ -2329,7 +2262,7 @@ import_value_xlat2(
gchar *str;
GhbValue *sval;
- str = ghb_value_string(mac_val);
+ str = ghb_value_get_string_xform(mac_val);
for (ii = 0; value_map[ii].mac_val; ii++)
{
if (strcmp(str, value_map[ii].mac_val) == 0 ||
@@ -2341,10 +2274,10 @@ import_value_xlat2(
if (gval == NULL)
{
g_warning("can't transform");
- ghb_value_free(sval);
+ ghb_value_free(&sval);
return NULL;
}
- ghb_value_free(sval);
+ ghb_value_free(&sval);
return gval;
}
}
@@ -2360,7 +2293,7 @@ import_value_video_framerate(GhbValue *mac_val)
gchar *str;
const gchar *fr;
- str = ghb_value_string(mac_val);
+ str = ghb_value_get_string_xform(mac_val);
fr = hb_video_framerate_get_name(hb_video_framerate_get_from_name(str));
g_free(str);
@@ -2377,7 +2310,7 @@ import_value_audio_samplerate(GhbValue *mac_val)
gchar *str;
const gchar *sr;
- str = ghb_value_string(mac_val);
+ str = ghb_value_get_string_xform(mac_val);
sr = hb_audio_samplerate_get_name(hb_audio_samplerate_get_from_name(str));
g_free(str);
@@ -2391,12 +2324,11 @@ static GhbValue*
import_value_mixdown(GhbValue *mac_val)
{
GhbValue *sval = NULL;
- gchar *str;
+ const gchar *str;
const gchar *mix;
- str = ghb_value_string(mac_val);
+ str = ghb_value_get_string(mac_val);
mix = hb_mixdown_get_short_name(hb_mixdown_get_from_name(str));
- g_free(str);
if (mix != NULL)
sval = ghb_string_value_new(mix);
@@ -2408,12 +2340,11 @@ static GhbValue*
import_value_video_encoder(GhbValue *mac_val)
{
GhbValue *sval = NULL;
- gchar *str;
+ const gchar *str;
const gchar *enc;
- str = ghb_value_string(mac_val);
+ str = ghb_value_get_string(mac_val);
enc = hb_video_encoder_get_short_name(hb_video_encoder_get_from_name(str));
- g_free(str);
if (enc != NULL)
sval = ghb_string_value_new(enc);
@@ -2425,12 +2356,11 @@ static GhbValue*
import_value_audio_encoder(GhbValue *mac_val)
{
GhbValue *sval = NULL;
- gchar *str;
+ const gchar *str;
const gchar *enc;
- str = ghb_value_string(mac_val);
+ str = ghb_value_get_string(mac_val);
enc = hb_audio_encoder_get_short_name(hb_audio_encoder_get_from_name(str));
- g_free(str);
if (enc != NULL)
sval = ghb_string_value_new(enc);
@@ -2442,12 +2372,11 @@ static GhbValue*
import_value_container(GhbValue *mac_val)
{
GhbValue *sval = NULL;
- gchar *str;
+ const gchar *str;
const gchar *mux;
- str = ghb_value_string(mac_val);
+ str = ghb_value_get_string(mac_val);
mux = hb_container_get_short_name(hb_container_get_from_name(str));
- g_free(str);
if (mux != NULL)
sval = ghb_string_value_new(mux);
@@ -2464,40 +2393,40 @@ import_value_xlat(GhbValue *dict)
GhbValue *internalPlist = ghb_resource_get("internal-defaults");
defaults = plist_get_dict(internalPlist, "Presets");
key = "VideoEncoder";
- mac_val = ghb_dict_lookup(dict, key);
+ mac_val = ghb_dict_get(dict, key);
gval = import_value_video_encoder(mac_val);
if (gval)
- ghb_dict_insert(dict, key, gval);
+ ghb_dict_set(dict, key, gval);
key = "FileFormat";
- mac_val = ghb_dict_lookup(dict, key);
+ mac_val = ghb_dict_get(dict, key);
gval = import_value_container(mac_val);
if (gval)
- ghb_dict_insert(dict, key, gval);
+ ghb_dict_set(dict, key, gval);
key = "VideoFramerate";
- mac_val = ghb_dict_lookup(dict, key);
+ mac_val = ghb_dict_get(dict, key);
gval = import_value_video_framerate(mac_val);
if (gval)
- ghb_dict_insert(dict, key, gval);
+ ghb_dict_set(dict, key, gval);
key = "PictureDetelecine";
- mac_val = ghb_dict_lookup(dict, key);
+ mac_val = ghb_dict_get(dict, key);
gval = import_value_xlat2(defaults, detel_xlat, key, mac_val);
if (gval)
- ghb_dict_insert(dict, key, gval);
+ ghb_dict_set(dict, key, gval);
key = "PictureDecomb";
- mac_val = ghb_dict_lookup(dict, key);
+ mac_val = ghb_dict_get(dict, key);
gval = import_value_xlat2(defaults, decomb_xlat, key, mac_val);
if (gval)
- ghb_dict_insert(dict, key, gval);
+ ghb_dict_set(dict, key, gval);
key = "PictureDeinterlace";
- mac_val = ghb_dict_lookup(dict, key);
+ mac_val = ghb_dict_get(dict, key);
gval = import_value_xlat2(defaults, deint_xlat, key, mac_val);
if (gval)
- ghb_dict_insert(dict, key, gval);
+ ghb_dict_set(dict, key, gval);
key = "PictureDenoisePreset";
- mac_val = ghb_dict_lookup(dict, key);
+ mac_val = ghb_dict_get(dict, key);
gval = import_value_xlat2(defaults, denoise_xlat, key, mac_val);
if (gval)
- ghb_dict_insert(dict, key, gval);
+ ghb_dict_set(dict, key, gval);
ghb_dict_remove(dict, "Subtitles");
ghb_dict_remove(dict, "SubtitlesForced");
@@ -2509,50 +2438,50 @@ import_value_xlat(GhbValue *dict)
GhbValue *adeflist;
key = "AudioEncoderFallback";
- mac_val = ghb_dict_lookup(dict, key);
+ mac_val = ghb_dict_get(dict, key);
gval = import_value_audio_encoder(mac_val);
if (gval)
- ghb_dict_insert(dict, key, gval);
+ ghb_dict_set(dict, key, gval);
- adeflist = ghb_dict_lookup(defaults, "AudioList");
+ adeflist = ghb_dict_get(defaults, "AudioList");
if (adeflist)
{
- adefaults = ghb_array_get_nth(adeflist, 0);
- alist = ghb_dict_lookup(dict, "AudioList");
+ adefaults = ghb_array_get(adeflist, 0);
+ alist = ghb_dict_get(dict, "AudioList");
count = ghb_array_len(alist);
for (ii = 0; ii < count; ii++)
{
- adict = ghb_array_get_nth(alist, ii);
+ adict = ghb_array_get(alist, ii);
key = "AudioEncoder";
- mac_val = ghb_dict_lookup(adict, key);
+ mac_val = ghb_dict_get(adict, key);
gval = import_value_audio_encoder(mac_val);
if (gval == NULL)
- gval = ghb_value_dup(ghb_dict_lookup(adefaults, key));
+ gval = ghb_value_dup(ghb_dict_get(adefaults, key));
if (gval)
- ghb_dict_insert(adict, key, gval);
+ ghb_dict_set(adict, key, gval);
key = "AudioSamplerate";
- mac_val = ghb_dict_lookup(adict, key);
+ mac_val = ghb_dict_get(adict, key);
gval = import_value_audio_samplerate(mac_val);
if (gval == NULL)
- gval = ghb_value_dup(ghb_dict_lookup(adefaults, key));
+ gval = ghb_value_dup(ghb_dict_get(adefaults, key));
if (gval)
- ghb_dict_insert(adict, key, gval);
+ ghb_dict_set(adict, key, gval);
key = "AudioMixdown";
- mac_val = ghb_dict_lookup(adict, key);
+ mac_val = ghb_dict_get(adict, key);
gval = import_value_mixdown(mac_val);
if (gval == NULL)
- gval = ghb_value_dup(ghb_dict_lookup(adefaults, key));
+ gval = ghb_value_dup(ghb_dict_get(adefaults, key));
if (gval)
- ghb_dict_insert(adict, key, gval);
+ ghb_dict_set(adict, key, gval);
- mac_val = ghb_dict_lookup(adict, "AudioTrackDRCSlider");
+ mac_val = ghb_dict_get(adict, "AudioTrackDRCSlider");
if (mac_val != NULL)
{
gdouble drc;
- drc = ghb_value_double(mac_val);
+ drc = ghb_value_get_double(mac_val);
if (drc < 1.0)
{
- ghb_dict_insert(adict, "AudioTrackDRCSlider",
+ ghb_dict_set(adict, "AudioTrackDRCSlider",
ghb_double_value_new(0.0));
}
}
@@ -2567,7 +2496,7 @@ import_xlat_preset(GhbValue *user_preset)
g_debug("import_xlat_preset ()");
- dict = ghb_dict_value_new();
+ dict = ghb_dict_new();
// First, initialize the preset with defaults.
// Then import user presets over top of defaults
@@ -2577,23 +2506,23 @@ import_xlat_preset(GhbValue *user_preset)
// Initialize the AudioLanguageList from preferences PreferredLanguage
// and translate old AudioDUB preference option if found
- GhbValue *list = ghb_dict_lookup(dict, "AudioLanguageList");
+ GhbValue *list = ghb_dict_get(dict, "AudioLanguageList");
if (list == NULL)
{
- list = ghb_array_value_new(8);
- ghb_dict_insert(dict, "AudioLanguageList", list);
+ list = ghb_array_new();
+ ghb_dict_set(dict, "AudioLanguageList", list);
}
if (ghb_array_len(list) == 0)
{
GhbValue *prefs = plist_get_dict(prefsPlist, "Preferences");
- GhbValue *gdub = ghb_dict_lookup(prefs, "AudioDUB");
- GhbValue *glang = ghb_dict_lookup(prefs, "PreferredLanguage");
+ GhbValue *gdub = ghb_dict_get(prefs, "AudioDUB");
+ GhbValue *glang = ghb_dict_get(prefs, "PreferredLanguage");
const char *lang = NULL;
if (glang != NULL)
{
- lang = ghb_value_const_string(glang);
+ lang = ghb_value_get_string(glang);
}
- if (gdub != NULL && !ghb_value_boolean(gdub))
+ if (gdub != NULL && !ghb_value_get_bool(gdub))
{
if (lang == NULL || strncmp(lang, "und", 4))
{
@@ -2608,38 +2537,38 @@ import_xlat_preset(GhbValue *user_preset)
// Initialize the SubtitleLanguageList from preferences PreferredLanguage
// and translate old AudioDUB preference option if found
- list = ghb_dict_lookup(dict, "SubtitleLanguageList");
+ list = ghb_dict_get(dict, "SubtitleLanguageList");
if (list == NULL)
{
- list = ghb_array_value_new(8);
- ghb_dict_insert(dict, "SubtitleLanguageList", list);
+ list = ghb_array_new(8);
+ ghb_dict_set(dict, "SubtitleLanguageList", list);
}
if (ghb_array_len(list) == 0)
{
GhbValue *prefs = plist_get_dict(prefsPlist, "Preferences");
- GhbValue *val = ghb_dict_lookup(prefs, "PreferredLanguage");
+ GhbValue *val = ghb_dict_get(prefs, "PreferredLanguage");
if (val != NULL)
{
ghb_array_append(list, ghb_value_dup(val));
- val = ghb_dict_lookup(prefs, "AudioDUB");
- if (val != NULL && !ghb_value_boolean(val))
+ val = ghb_dict_get(prefs, "AudioDUB");
+ if (val != NULL && !ghb_value_get_bool(val))
{
- ghb_dict_insert(dict,
+ ghb_dict_set(dict,
"SubtitleAddForeignAudioSubtitle",
- ghb_boolean_value_new(TRUE));
+ ghb_bool_value_new(TRUE));
}
}
}
- GhbValue *addCC = ghb_dict_lookup(dict, "SubtitleAddCC");
+ GhbValue *addCC = ghb_dict_get(dict, "SubtitleAddCC");
if (addCC == NULL)
{
GhbValue *prefs = plist_get_dict(prefsPlist, "Preferences");
- GhbValue *val = ghb_dict_lookup(prefs, "AddCC");
+ GhbValue *val = ghb_dict_get(prefs, "AddCC");
if (val != NULL)
{
- ghb_dict_insert(dict, "SubtitleAddCC",
+ ghb_dict_set(dict, "SubtitleAddCC",
ghb_value_dup(val));
}
}
@@ -2737,7 +2666,7 @@ import_xlat_preset(GhbValue *user_preset)
const char * const *videoPresets;
videoPresets = hb_video_encoder_get_presets(encoder);
const char *videoPreset;
- if (ghb_dict_lookup(user_preset, "x264Preset") != NULL)
+ if (ghb_dict_get(user_preset, "x264Preset") != NULL)
videoPreset = ghb_settings_get_const_string(dict, "x264Preset");
else
videoPreset = ghb_settings_get_const_string(dict, "VideoPreset");
@@ -2754,7 +2683,7 @@ import_xlat_preset(GhbValue *user_preset)
ghb_settings_set_string(dict, "VideoPreset", videoPreset);
char *videoTune;
- if (ghb_dict_lookup(user_preset, "x264Tune") != NULL)
+ if (ghb_dict_get(user_preset, "x264Tune") != NULL)
videoTune = ghb_settings_get_string(dict, "x264Tune");
else
videoTune = ghb_settings_get_string(dict, "VideoTune");
@@ -2791,7 +2720,7 @@ import_xlat_preset(GhbValue *user_preset)
}
const char *videoProfile;
- if (ghb_dict_lookup(user_preset, "x264Profile") != NULL)
+ if (ghb_dict_get(user_preset, "x264Profile") != NULL)
videoProfile = ghb_settings_get_const_string(dict, "x264Profile");
else
videoProfile = ghb_settings_get_const_string(dict, "VideoProfile");
@@ -2799,14 +2728,14 @@ import_xlat_preset(GhbValue *user_preset)
ghb_settings_set_string(dict, "VideoProfile", videoProfile);
const char *videoLevel;
- if (ghb_dict_lookup(user_preset, "x264Level") != NULL)
+ if (ghb_dict_get(user_preset, "x264Level") != NULL)
videoLevel = ghb_settings_get_const_string(dict, "x264Level");
else
videoLevel = ghb_settings_get_const_string(dict, "VideoLevel");
if (videoLevel != NULL)
ghb_settings_set_string(dict, "VideoLevel", videoLevel);
- if (ghb_dict_lookup(user_preset, "x264OptionExtra") != NULL)
+ if (ghb_dict_get(user_preset, "x264OptionExtra") != NULL)
{
const char *optionExtra;
optionExtra = ghb_settings_get_const_string(dict, "x264OptionExtra");
@@ -2828,13 +2757,13 @@ import_xlat_presets(GhbValue *presets)
count = ghb_array_len(presets);
for (ii = 0; ii < count; ii++)
{
- dict = ghb_array_get_nth(presets, ii);
- folder = ghb_value_boolean(preset_dict_get_value(dict, "Folder"));
+ dict = ghb_array_get(presets, ii);
+ folder = ghb_value_get_bool(preset_dict_get_value(dict, "Folder"));
if (folder)
{
GhbValue *nested;
- nested = ghb_dict_lookup(dict, "ChildrenArray");
+ nested = ghb_dict_get(dict, "ChildrenArray");
import_xlat_presets(nested);
}
else
@@ -2852,73 +2781,70 @@ export_xlat_preset(GhbValue *dict)
gboolean autoscale, br, constant;
g_debug("export_xlat_prest ()");
- autoscale = ghb_value_boolean(preset_dict_get_value(dict, "autoscale"));
- br = ghb_value_boolean(
+ autoscale = ghb_value_get_bool(preset_dict_get_value(dict, "autoscale"));
+ br = ghb_value_get_bool(
preset_dict_get_value(dict, "vquality_type_bitrate"));
- constant = ghb_value_boolean(
+ constant = ghb_value_get_bool(
preset_dict_get_value(dict, "vquality_type_constant"));
if (autoscale)
{
- ghb_dict_insert(dict, "UsesPictureSettings", ghb_int_value_new(2));
+ ghb_dict_set(dict, "UsesPictureSettings", ghb_int_value_new(2));
}
else
{
- ghb_dict_insert(dict, "UsesPictureSettings", ghb_int_value_new(1));
+ ghb_dict_set(dict, "UsesPictureSettings", ghb_int_value_new(1));
}
// VideoQualityType/0/1/2 - vquality_type_/target/bitrate/constant
// *note: target is no longer used
if (br)
{
- ghb_dict_insert(dict, "VideoQualityType", ghb_int_value_new(1));
+ ghb_dict_set(dict, "VideoQualityType", ghb_int_value_new(1));
}
else if (constant)
{
- ghb_dict_insert(dict, "VideoQualityType", ghb_int_value_new(2));
+ ghb_dict_set(dict, "VideoQualityType", ghb_int_value_new(2));
}
- if (ghb_value_boolean(preset_dict_get_value(dict, "VideoFramerateCFR")))
+ if (ghb_value_get_bool(preset_dict_get_value(dict, "VideoFramerateCFR")))
{
- ghb_dict_insert(dict, "VideoFramerateMode",
- ghb_string_value_new("cfr"));
+ ghb_dict_set(dict, "VideoFramerateMode", ghb_string_value_new("cfr"));
}
- else if (ghb_value_boolean(preset_dict_get_value(dict, "VideoFrameratePFR")))
+ else if (ghb_value_get_bool(preset_dict_get_value(dict, "VideoFrameratePFR")))
{
- ghb_dict_insert(dict, "VideoFramerateMode",
- ghb_string_value_new("pfr"));
+ ghb_dict_set(dict, "VideoFramerateMode", ghb_string_value_new("pfr"));
}
else
{
- ghb_dict_insert(dict, "VideoFramerateMode",
- ghb_string_value_new("vfr"));
+ ghb_dict_set(dict, "VideoFramerateMode", ghb_string_value_new("vfr"));
}
- if (ghb_value_int(preset_dict_get_value(dict, "PictureDeblock")) < 5)
+ if (ghb_value_get_int(preset_dict_get_value(dict, "PictureDeblock")) < 5)
{
- ghb_dict_insert(dict, "PictureDeblock", ghb_int_value_new(0));
+ ghb_dict_set(dict, "PictureDeblock", ghb_int_value_new(0));
}
GhbValue *alist, *adict;
gint count, ii;
- alist = ghb_dict_lookup(dict, "AudioList");
+ alist = ghb_dict_get(dict, "AudioList");
count = ghb_array_len(alist);
for (ii = 0; ii < count; ii++)
{
gdouble drc;
- adict = ghb_array_get_nth(alist, ii);
- drc = ghb_value_double(
+ adict = ghb_array_get(alist, ii);
+ drc = ghb_value_get_double(
preset_dict_get_value(adict, "AudioTrackDRCSlider"));
if (drc < 1.0)
{
- ghb_dict_insert(adict, "AudioTrackDRCSlider",
+ ghb_dict_set(adict, "AudioTrackDRCSlider",
ghb_double_value_new(0.0));
}
}
- if (ghb_value_boolean(preset_dict_get_value(dict, "x264UseAdvancedOptions")))
+ if (ghb_value_get_bool(preset_dict_get_value(dict, "x264UseAdvancedOptions")))
{
ghb_dict_remove(dict, "VideoPreset");
ghb_dict_remove(dict, "VideoTune");
@@ -2942,7 +2868,7 @@ export_xlat_preset(GhbValue *dict)
g_string_append_printf(str, ",%s", "zerolatency");
}
tunes = g_string_free(str, FALSE);
- ghb_dict_insert(dict, "VideoTune", ghb_string_value_new(tunes));
+ ghb_dict_set(dict, "VideoTune", ghb_string_value_new(tunes));
g_free(tunes);
}
@@ -2967,13 +2893,13 @@ export_xlat_presets(GhbValue *presets)
count = ghb_array_len(presets);
for (ii = 0; ii < count; ii++)
{
- dict = ghb_array_get_nth(presets, ii);
- folder = ghb_value_boolean(preset_dict_get_value(dict, "Folder"));
+ dict = ghb_array_get(presets, ii);
+ folder = ghb_value_get_bool(preset_dict_get_value(dict, "Folder"));
if (folder)
{
GhbValue *nested;
- nested = ghb_dict_lookup(dict, "ChildrenArray");
+ nested = ghb_dict_get(dict, "ChildrenArray");
export_xlat_presets(nested);
}
else
@@ -3001,7 +2927,7 @@ store_presets()
export = ghb_value_dup(presetsPlist);
export_xlat_presets(export);
store_plist("presets", export);
- ghb_value_free(export);
+ ghb_value_free(&export);
}
static void
@@ -3046,16 +2972,16 @@ ghb_presets_reload(signal_user_data_t *ud)
GhbValue *copy_dict;
gint indices = 0;
- std_dict = ghb_array_get_nth(std_presets, ii);
+ std_dict = ghb_array_get(std_presets, ii);
copy_dict = ghb_value_dup(std_dict);
- ghb_dict_insert(copy_dict, "PresetBuildNumber",
- ghb_int64_value_new(hb_get_build(NULL)));
+ ghb_dict_set(copy_dict, "PresetBuildNumber",
+ ghb_int_value_new(hb_get_build(NULL)));
ghb_presets_insert(presetsPlist, copy_dict, &indices, 1);
presets_list_insert(ud, &indices, 1);
}
import_xlat_presets(presetsPlist);
store_presets();
- ghb_value_free(std_presets);
+ ghb_value_free(&std_presets);
}
static gboolean
@@ -3069,8 +2995,8 @@ check_old_presets(GhbValue *presetsArray)
GhbValue *dict;
GhbValue *type;
- dict = ghb_array_get_nth(presetsArray, ii);
- type = ghb_dict_lookup(dict, "Type");
+ dict = ghb_array_get(presetsArray, ii);
+ type = ghb_dict_get(dict, "Type");
if (type == NULL)
return TRUE;
}
@@ -3091,8 +3017,8 @@ replace_standard_presets(GhbValue *presetsArray)
GhbValue *dict;
gint ptype;
- dict = ghb_array_get_nth(presetsArray, ii);
- ptype = ghb_value_int(preset_dict_get_value(dict, "Type"));
+ dict = ghb_array_get(presetsArray, ii);
+ ptype = ghb_value_get_int(preset_dict_get_value(dict, "Type"));
if (ptype == PRESETS_BUILTIN)
{
gint indices = 0;
@@ -3122,13 +3048,13 @@ replace_standard_presets(GhbValue *presetsArray)
GhbValue *copy_dict;
gint indices = 0;
- std_dict = ghb_array_get_nth(std_presets, ii);
+ std_dict = ghb_array_get(std_presets, ii);
copy_dict = ghb_value_dup(std_dict);
- ghb_dict_insert(copy_dict, "PresetBuildNumber",
- ghb_int64_value_new(hb_get_build(NULL)));
+ ghb_dict_set(copy_dict, "PresetBuildNumber",
+ ghb_int_value_new(hb_get_build(NULL)));
ghb_presets_insert(presetsArray, copy_dict, &indices, 1);
}
- ghb_value_free(std_presets);
+ ghb_value_free(&std_presets);
}
static int
@@ -3144,8 +3070,8 @@ update_standard_presets(signal_user_data_t *ud, GhbValue *presetsArray)
gint64 build;
gint type;
- dict = ghb_array_get_nth(presetsArray, ii);
- gval = ghb_dict_lookup(dict, "Type");
+ dict = ghb_array_get(presetsArray, ii);
+ gval = ghb_dict_get(dict, "Type");
if (gval == NULL)
{
// Old preset that doesn't have a Type
@@ -3153,10 +3079,10 @@ update_standard_presets(signal_user_data_t *ud, GhbValue *presetsArray)
return 1;
}
- type = ghb_value_int(gval);
+ type = ghb_value_get_int(gval);
if (type == 0)
{
- gval = ghb_dict_lookup(dict, "PresetBuildNumber");
+ gval = ghb_dict_get(dict, "PresetBuildNumber");
if (gval == NULL)
{
// Old preset that doesn't have a build number
@@ -3164,7 +3090,7 @@ update_standard_presets(signal_user_data_t *ud, GhbValue *presetsArray)
return 1;
}
- build = ghb_value_int64(gval);
+ build = ghb_value_get_int(gval);
if (build != hb_get_build(NULL))
{
// Build number does not match
@@ -3211,7 +3137,7 @@ settings_save(signal_user_data_t *ud, const GhbValue *path)
GhbValue *internalPlist = ghb_resource_get("internal-defaults");
if (internalPlist == NULL) return;
count = ghb_array_len(path);
- name = ghb_value_const_string(ghb_array_get_nth(path, count-1));
+ name = ghb_value_get_string(ghb_array_get(path, count-1));
indices = ghb_preset_indices_from_path(presetsPlist, path, &len);
if (indices)
{
@@ -3251,7 +3177,7 @@ settings_save(signal_user_data_t *ud, const GhbValue *path)
ghb_settings_set_int64(dict, "Type", PRESETS_CUSTOM);
ghb_settings_set_int64(dict, "PresetBuildNumber", hb_get_build(NULL));
- ghb_dict_insert(dict, "PresetName", ghb_string_value_new(name));
+ ghb_dict_set(dict, "PresetName", ghb_string_value_new(name));
if (replace)
{
gint *def_indices, def_len;
@@ -3259,14 +3185,14 @@ settings_save(signal_user_data_t *ud, const GhbValue *path)
if (def_indices != NULL &&
preset_path_cmp(indices, len, def_indices, def_len) != 0)
{
- ghb_dict_insert(dict, "Default", ghb_boolean_value_new(FALSE));
+ ghb_dict_set(dict, "Default", ghb_bool_value_new(FALSE));
}
presets_list_update_item(ud, indices, len, FALSE);
g_free(def_indices);
}
else
{
- ghb_dict_insert(dict, "Default", ghb_boolean_value_new(FALSE));
+ ghb_dict_set(dict, "Default", ghb_bool_value_new(FALSE));
presets_list_insert(ud, indices, len);
}
if (!ghb_settings_get_boolean(ud->settings, "PictureWidthEnable"))
@@ -3277,8 +3203,8 @@ settings_save(signal_user_data_t *ud, const GhbValue *path)
{
ghb_dict_remove(dict, "PictureHeight");
}
- ghb_dict_insert(dict, "autoscale",
- ghb_boolean_value_new(
+ ghb_dict_set(dict, "autoscale",
+ ghb_bool_value_new(
!ghb_settings_get_boolean(ud->settings, "PictureWidthEnable") &&
!ghb_settings_get_boolean(ud->settings, "PictureHeightEnable")
)
@@ -3302,7 +3228,7 @@ folder_save(signal_user_data_t *ud, const GhbValue *path)
const gchar *name;
count = ghb_array_len(path);
- name = ghb_value_const_string(ghb_array_get_nth(path, count-1));
+ name = ghb_value_get_string(ghb_array_get(path, count-1));
indices = ghb_preset_indices_from_path(presetsPlist, path, &len);
if (indices)
{
@@ -3323,7 +3249,7 @@ folder_save(signal_user_data_t *ud, const GhbValue *path)
}
// Already exists, update its description
dict = presets_get_dict(presetsPlist, indices, len);
- ghb_dict_insert(dict, "PresetDescription",
+ ghb_dict_set(dict, "PresetDescription",
ghb_value_dup(preset_dict_get_value(
ud->settings, "PresetDescription")));
presets_list_update_item(ud, indices, len, FALSE);
@@ -3336,7 +3262,7 @@ folder_save(signal_user_data_t *ud, const GhbValue *path)
indices = presets_find_pos(path, PRESETS_CUSTOM, &len);
if (indices)
{
- dict = ghb_dict_value_new();
+ dict = ghb_dict_new();
ghb_presets_insert(presetsPlist, dict, indices, len);
}
else
@@ -3345,14 +3271,14 @@ folder_save(signal_user_data_t *ud, const GhbValue *path)
return;
}
}
- ghb_dict_insert(dict, "PresetDescription",
+ ghb_dict_set(dict, "PresetDescription",
ghb_value_dup(preset_dict_get_value(
ud->settings, "PresetDescription")));
- ghb_dict_insert(dict, "PresetName", ghb_string_value_new(name));
- folder = ghb_array_value_new(8);
- ghb_dict_insert(dict, "ChildrenArray", folder);
- ghb_dict_insert(dict, "Type", ghb_int64_value_new(PRESETS_CUSTOM));
- ghb_dict_insert(dict, "Folder", ghb_boolean_value_new(TRUE));
+ ghb_dict_set(dict, "PresetName", ghb_string_value_new(name));
+ folder = ghb_array_new();
+ ghb_dict_set(dict, "ChildrenArray", folder);
+ ghb_dict_set(dict, "Type", ghb_int_value_new(PRESETS_CUSTOM));
+ ghb_dict_set(dict, "Folder", ghb_bool_value_new(TRUE));
presets_list_insert(ud, indices, len);
g_free(indices);
@@ -3427,11 +3353,11 @@ update_subtitle_presets(signal_user_data_t *ud)
gint count, ii, source;
subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
- slist = ghb_array_value_new(8);
+ slist = ghb_array_new();
count = ghb_array_len(subtitle_list);
for (ii = 0; ii < count; ii++)
{
- subtitle = ghb_array_get_nth(subtitle_list, ii);
+ subtitle = ghb_array_get(subtitle_list, ii);
source = ghb_settings_get_int(subtitle, "SubtitleSource");
if (source != SRTSUB)
{
@@ -3507,21 +3433,21 @@ preset_import_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
gint *indices, len;
gint index = 1;
- dict = ghb_array_get_nth(array, ii);
- path = ghb_array_value_new(1);
- name = ghb_value_dup(ghb_dict_lookup(dict, "PresetName"));
+ dict = ghb_array_get(array, ii);
+ path = ghb_array_new();
+ name = ghb_value_dup(ghb_dict_get(dict, "PresetName"));
ghb_array_append(path, name);
indices = ghb_preset_indices_from_path(presetsPlist, path, &len);
// Modify the preset name till we make it unique
while (indices != NULL)
{
- gchar *str = ghb_value_string(name);
+ const gchar *tmp = ghb_value_get_string(name);
- ghb_value_free(path);
+ ghb_value_free(&path);
g_free(indices);
- str = g_strdup_printf("%s %d", str, index);
- path = ghb_array_value_new(1);
+ char *str = g_strdup_printf("%s %d", tmp, index);
+ path = ghb_array_new();
name = ghb_string_value_new(str);
ghb_array_append(path, name);
g_free(str);
@@ -3529,14 +3455,14 @@ preset_import_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
index++;
indices = ghb_preset_indices_from_path(presetsPlist, path, &len);
}
- ghb_dict_insert(dict, "PresetName", ghb_value_dup(name));
+ ghb_dict_set(dict, "PresetName", ghb_value_dup(name));
indices = presets_find_pos(path, PRESETS_CUSTOM, &len);
ghb_presets_insert(presetsPlist, ghb_value_dup(dict), indices, len);
presets_list_insert(ud, indices, len);
- ghb_value_free(path);
+ ghb_value_free(&path);
g_free(indices);
}
- ghb_value_free(array);
+ ghb_value_free(&array);
exportDir = ghb_settings_get_const_string(ud->prefs, "ExportDirectory");
dir = g_path_get_dirname(filename);
@@ -3597,11 +3523,11 @@ preset_export_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
count = ghb_array_len(preset);
if (count <= 0)
{
- ghb_value_free(preset);
+ ghb_value_free(&preset);
return;
}
- name = ghb_value_const_string(ghb_array_get_nth(preset, count-1));
+ name = ghb_value_get_string(ghb_array_get(preset, count-1));
dialog = gtk_file_chooser_dialog_new(_("Export Preset"), NULL,
GTK_FILE_CHOOSER_ACTION_SAVE,
@@ -3622,7 +3548,7 @@ preset_export_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
indices = ghb_preset_indices_from_path(presetsPlist, preset, &len);
if (indices == NULL)
{
- ghb_value_free(preset);
+ ghb_value_free(&preset);
return;
}
@@ -3639,14 +3565,14 @@ preset_export_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
dict = presets_get_dict(presetsPlist, indices, len);
export = ghb_value_dup(dict);
- array = ghb_array_value_new(1);
+ array = ghb_array_new();
ghb_array_append(array, export);
presets_clear_default(array);
presets_customize(array);
export_xlat_presets(array);
store_plist(filename, array);
- ghb_value_free(array);
+ ghb_value_free(&array);
exportDir = ghb_settings_get_const_string(ud->prefs, "ExportDirectory");
dir = g_path_get_dirname(filename);
@@ -3660,7 +3586,7 @@ preset_export_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
}
gtk_widget_destroy(dialog);
g_free(indices);
- ghb_value_free(preset);
+ ghb_value_free(&preset);
}
G_MODULE_EXPORT void
@@ -3679,7 +3605,7 @@ presets_new_folder_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
preset = get_selected_path(ud);
count = ghb_array_len(preset);
if (count > 0)
- name = ghb_value_const_string(ghb_array_get_nth(preset, count-1));
+ name = ghb_value_get_string(ghb_array_get(preset, count-1));
else
count = 1;
@@ -3687,8 +3613,8 @@ presets_new_folder_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
dict = presets_get_dict(presetsPlist, indices, len);
if (dict != NULL)
{
- description = ghb_value_const_string(
- ghb_dict_lookup(dict, "PresetDescription"));
+ description = ghb_value_get_string(
+ ghb_dict_get(dict, "PresetDescription"));
ghb_ui_update(ud, "FolderDescription", ghb_string_value(description));
}
@@ -3707,7 +3633,7 @@ presets_new_folder_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
if (count > MAX_NESTED_PRESET-1)
count = MAX_NESTED_PRESET-1;
- dest = ghb_array_value_new(MAX_NESTED_PRESET);
+ dest = ghb_array_new();
if (indices != NULL)
{
gint ptype;
@@ -3722,10 +3648,10 @@ presets_new_folder_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
GhbValue *val = ghb_widget_value(GTK_WIDGET(desc));
ghb_settings_set_value(ud->settings, "PresetDescription", val);
folder_save(ud, dest);
- ghb_value_free(dest);
+ ghb_value_free(&dest);
}
g_free(indices);
- ghb_value_free(preset);
+ ghb_value_free(&preset);
}
G_MODULE_EXPORT void
@@ -3746,7 +3672,7 @@ presets_save_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
count = ghb_array_len(preset);
if (count > 0)
- name = ghb_value_const_string(ghb_array_get_nth(preset, count-1));
+ name = ghb_value_get_string(ghb_array_get(preset, count-1));
else
count = 1;
@@ -3777,7 +3703,7 @@ presets_save_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
const gchar *name = gtk_entry_get_text(entry);
GhbValue *dest;
- dest = ghb_array_value_new(MAX_NESTED_PRESET);
+ dest = ghb_array_new();
indices = ghb_preset_indices_from_path(presetsPlist, preset, &len);
if (indices)
{
@@ -3796,9 +3722,9 @@ presets_save_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
update_subtitle_presets(ud);
settings_save(ud, dest);
- ghb_value_free(dest);
+ ghb_value_free(&dest);
}
- ghb_value_free(preset);
+ ghb_value_free(&preset);
}
G_MODULE_EXPORT void
@@ -4185,7 +4111,7 @@ presets_row_expanded_cb(
count = ghb_array_len(presets);
for (ii = 0; ii < count; ii++)
{
- dict = ghb_array_get_nth(presets, ii);
+ dict = ghb_array_get(presets, ii);
folder = ghb_preset_folder(dict);
if (folder)
{
@@ -4340,7 +4266,7 @@ presets_default_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
}
g_free(indices);
}
- ghb_value_free(preset);
+ ghb_value_free(&preset);
}
G_MODULE_EXPORT void
@@ -4363,17 +4289,17 @@ preset_edited_cb(
g_debug("text (%s)", text);
preset = get_selected_path(ud);
- dest = ghb_array_value_new(MAX_NESTED_PRESET);
+ dest = ghb_array_new();
count = ghb_array_len(preset);
ghb_array_copy(dest, preset, count-1);
ghb_array_append(dest, ghb_string_value_new(text));
indices = ghb_preset_indices_from_path(presetsPlist, dest, &len);
- ghb_value_free(dest);
+ ghb_value_free(&dest);
if (indices != NULL)
{
// Already exists
g_free(indices);
- ghb_value_free(preset);
+ ghb_value_free(&preset);
return;
}
@@ -4386,10 +4312,10 @@ preset_edited_cb(
gtk_tree_store_set(store, &iter, 0, text, -1);
dict = presets_get_dict(presetsPlist, indices, len);
- ghb_dict_insert(dict, "PresetName", ghb_string_value_new(text));
+ ghb_dict_set(dict, "PresetName", ghb_string_value_new(text));
store_presets();
gtk_tree_path_free (treepath);
- ghb_value_free(preset);
+ ghb_value_free(&preset);
}
G_MODULE_EXPORT void
diff --git a/gtk/src/preview.c b/gtk/src/preview.c
index b53c697c4..deb7da868 100644
--- a/gtk/src/preview.c
+++ b/gtk/src/preview.c
@@ -768,7 +768,7 @@ live_preview_start_cb(GtkWidget *xwidget, signal_user_data_t *ud)
ghb_settings_set_value(js, "Preferences", ud->prefs);
ghb_add_live_job(js, ud->preview->live_id);
ghb_start_live_encode();
- ghb_value_free(js);
+ ghb_value_free(&js);
}
}
diff --git a/gtk/src/queuehandler.c b/gtk/src/queuehandler.c
index 6c49c5e6f..f721c03f6 100644
--- a/gtk/src/queuehandler.c
+++ b/gtk/src/queuehandler.c
@@ -564,7 +564,7 @@ add_to_queue_list(signal_user_data_t *ud, GhbValue *settings, GtkTreeIter *piter
GhbValue *asettings;
const hb_encoder_t *audio_encoder;
- asettings = ghb_array_get_nth(audio_list, ii);
+ asettings = ghb_array_get(audio_list, ii);
audio_encoder = ghb_settings_audio_encoder(asettings, "AudioEncoder");
double q = ghb_settings_get_double(asettings, "AudioTrackQuality");
@@ -626,7 +626,7 @@ add_to_queue_list(signal_user_data_t *ud, GhbValue *settings, GtkTreeIter *piter
gboolean force, burn, def;
gint source;
- settings = ghb_array_get_nth(sub_list, ii);
+ settings = ghb_array_get(sub_list, ii);
track = ghb_settings_get_string(settings, "SubtitleTrackDescription");
source = ghb_settings_get_int(settings, "SubtitleSource");
force = ghb_settings_get_boolean(settings, "SubtitleForced");
@@ -701,7 +701,7 @@ ghb_update_status(signal_user_data_t *ud, int status, int index)
}
GhbValue *settings;
- settings = ghb_array_get_nth(ud->queue, index);
+ settings = ghb_array_get(ud->queue, index);
if (settings == NULL) // should never happen
return;
@@ -745,7 +745,7 @@ save_queue_file(signal_user_data_t *ud)
count = ghb_array_len(queue);
for (ii = 0; ii < count; ii++)
{
- GhbValue *settings = ghb_array_get_nth(ud->queue, ii);
+ GhbValue *settings = ghb_array_get(ud->queue, ii);
if (settings == NULL)
continue;
ghb_settings_set_int(settings, "job_status", GHB_QUEUE_PENDING);
@@ -764,7 +764,7 @@ save_queue_file(signal_user_data_t *ud)
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), "queue.json");
if (gtk_dialog_run(GTK_DIALOG (dialog)) != GTK_RESPONSE_ACCEPT)
{
- ghb_value_free(queue);
+ ghb_value_free(&queue);
gtk_widget_destroy(dialog);
return;
}
@@ -774,7 +774,7 @@ save_queue_file(signal_user_data_t *ud)
ghb_write_settings_file(filename, queue);
g_free (filename);
- ghb_value_free(queue);
+ ghb_value_free(&queue);
}
static void
@@ -821,20 +821,20 @@ open_queue_file(signal_user_data_t *ud)
count = ghb_array_len(queue);
for (ii = 0; ii < count; ii++)
{
- GhbValue *settings = ghb_array_get_nth(queue, ii);
+ GhbValue *settings = ghb_array_get(queue, ii);
ghb_value_incref(settings);
ghb_array_remove(queue, ii);
ghb_settings_set_int(settings, "job_status", GHB_QUEUE_PENDING);
ghb_settings_set_int(settings, "job_unique_id", 0);
if (ud->queue == NULL)
- ud->queue = ghb_array_value_new(32);
+ ud->queue = ghb_array_new();
ghb_array_append(ud->queue, settings);
add_to_queue_list(ud, settings, NULL);
}
ghb_queue_buttons_grey(ud);
ghb_save_queue(ud->queue);
- ghb_value_free(queue);
+ ghb_value_free(&queue);
}
g_free (filename);
}
@@ -914,7 +914,7 @@ validate_settings(signal_user_data_t *ud, GhbValue *settings, gint batch)
GhbValue *js;
const gchar *filename;
- js = ghb_array_get_nth(ud->queue, ii);
+ js = ghb_array_get(ud->queue, ii);
filename = ghb_settings_get_const_string(js, "destination");
if (strcmp(dest, filename) == 0)
{
@@ -1051,7 +1051,7 @@ queue_add(signal_user_data_t *ud, GhbValue *settings, gint batch)
}
if (ud->queue == NULL)
- ud->queue = ghb_array_value_new(32);
+ ud->queue = ghb_array_new();
// Copy current prefs into settings
// The job should run with the preferences that existed
@@ -1077,7 +1077,7 @@ queue_add_clicked_cb(GtkWidget *widget, signal_user_data_t *ud)
g_debug("queue_add_clicked_cb ()");
GhbValue *settings = ghb_value_dup(ud->settings);
if (!queue_add(ud, settings, 0))
- ghb_value_free(settings);
+ ghb_value_free(&settings);
// Validation of settings may have changed audio list
ghb_audio_list_refresh_all(ud);
}
@@ -1089,9 +1089,9 @@ title_multiple_can_select(GhbValue *settings_array, int index)
GhbValue *settings, *gdest;
const char *dest;
- settings = ghb_array_get_nth(settings_array, index);
+ settings = ghb_array_get(settings_array, index);
gdest = ghb_settings_get_value(settings, "destination");
- dest = ghb_value_const_string(gdest);
+ dest = ghb_value_get_string(gdest);
if (dest == NULL)
return FALSE;
@@ -1101,9 +1101,9 @@ title_multiple_can_select(GhbValue *settings_array, int index)
{
const char *tmp;
- settings = ghb_array_get_nth(settings_array, ii);
+ settings = ghb_array_get(settings_array, ii);
gdest = ghb_settings_get_value(settings, "destination");
- tmp = ghb_value_const_string(gdest);
+ tmp = ghb_value_get_string(gdest);
if (tmp != NULL && !strncmp(dest, tmp, PATH_MAX))
return FALSE;
}
@@ -1249,7 +1249,7 @@ title_add_multiple_check_conflicts(signal_user_data_t *ud)
row = GTK_WIDGET(gtk_list_box_get_row_at_index(list, ii));
selected = GTK_TOGGLE_BUTTON(find_widget(row, "title_selected"));
- settings = ghb_array_get_nth(ud->settings_array, ii);
+ settings = ghb_array_get(ud->settings_array, ii);
can_select = title_multiple_can_select(ud->settings_array, ii);
ghb_settings_set_boolean(settings, "title_selected", FALSE);
gtk_toggle_button_set_active(selected, FALSE);
@@ -1292,7 +1292,7 @@ title_add_multiple_select_all_cb(GtkWidget *widget, signal_user_data_t *ud)
{
row = GTK_WIDGET(gtk_list_box_get_row_at_index(list, ii));
selected = GTK_TOGGLE_BUTTON(find_widget(row, "title_selected"));
- settings = ghb_array_get_nth(ud->settings_array, ii);
+ settings = ghb_array_get(ud->settings_array, ii);
can_select = title_multiple_can_select(ud->settings_array, ii);
ghb_settings_set_boolean(settings, "title_selected", can_select);
gtk_toggle_button_set_active(selected, TRUE);
@@ -1331,7 +1331,7 @@ title_add_multiple_clear_all_cb(GtkWidget *widget, signal_user_data_t *ud)
{
row = GTK_WIDGET(gtk_list_box_get_row_at_index(list, ii));
selected = GTK_TOGGLE_BUTTON(find_widget(row, "title_selected"));
- settings = ghb_array_get_nth(ud->settings_array, ii);
+ settings = ghb_array_get(ud->settings_array, ii);
ghb_settings_set_boolean(settings, "title_selected", FALSE);
gtk_toggle_button_set_active(selected, FALSE);
}
@@ -1348,7 +1348,7 @@ add_multiple_titles(signal_user_data_t *ud)
{
GhbValue *settings;
- settings = ghb_value_dup(ghb_array_get_nth(ud->settings_array, ii));
+ settings = ghb_value_dup(ghb_array_get(ud->settings_array, ii));
if (ghb_settings_get_boolean(settings, "title_selected"))
{
queue_add(ud, settings, ii);
@@ -1393,7 +1393,7 @@ title_selected_cb(GtkWidget *widget, signal_user_data_t *ud)
gint index = gtk_list_box_row_get_index(row);
selected = ghb_widget_boolean(widget);
- settings = ghb_array_get_nth(ud->settings_array, index);
+ settings = ghb_array_get(ud->settings_array, index);
can_select = title_multiple_can_select(ud->settings_array, index);
ghb_settings_set_boolean(settings, "title_selected",
selected && can_select);
@@ -1410,7 +1410,7 @@ title_dest_file_cb(GtkWidget *widget, signal_user_data_t *ud)
gint index = gtk_list_box_row_get_index(row);
dest_file = ghb_widget_string(widget);
- settings = ghb_array_get_nth(ud->settings_array, index);
+ settings = ghb_array_get(ud->settings_array, index);
ghb_settings_set_string(settings, "dest_file", dest_file);
dest_dir = ghb_settings_get_string(settings, "dest_dir");
@@ -1444,7 +1444,7 @@ title_dest_dir_cb(GtkWidget *widget, signal_user_data_t *ud)
gint index = gtk_list_box_row_get_index(row);
dest_dir = ghb_widget_string(widget);
- settings = ghb_array_get_nth(ud->settings_array, index);
+ settings = ghb_array_get(ud->settings_array, index);
ghb_settings_set_string(settings, "dest_dir", dest_dir);
dest_file = ghb_settings_get_string(settings, "dest_file");
@@ -1559,7 +1559,7 @@ queue_add_multiple_clicked_cb(GtkWidget *widget, signal_user_data_t *ud)
entry = GTK_ENTRY(find_widget(row, "title_file"));
chooser = GTK_FILE_CHOOSER(find_widget(row, "title_dir"));
- settings = ghb_array_get_nth(ud->settings_array, ii);
+ settings = ghb_array_get(ud->settings_array, ii);
title_id = ghb_settings_get_int(settings, "title");
title = ghb_lookup_title(title_id, &titleindex);
if (title != NULL)
@@ -1660,7 +1660,7 @@ queue_remove_clicked_cb(GtkWidget *widget, gchar *path, signal_user_data_t *ud)
if (row < 0) return;
if (row >= ghb_array_len(ud->queue))
return;
- settings = ghb_array_get_nth(ud->queue, row);
+ settings = ghb_array_get(ud->queue, row);
status = ghb_settings_get_int(settings, "job_status");
if (status == GHB_QUEUE_RUNNING)
{
@@ -1696,7 +1696,7 @@ find_last_finished(GhbValue *queue)
count = ghb_array_len(queue);
for (ii = 0; ii < count; ii++)
{
- js = ghb_array_get_nth(queue, ii);
+ js = ghb_array_get(queue, ii);
status = ghb_settings_get_int(js, "job_status");
if (status != GHB_QUEUE_DONE && status != GHB_QUEUE_RUNNING)
{
@@ -1742,7 +1742,7 @@ queue_drag_motion_cb(
indices = gtk_tree_path_get_indices(path);
row = indices[0];
gtk_tree_path_free(path);
- js = ghb_array_get_nth(ud->queue, row);
+ js = ghb_array_get(ud->queue, row);
status = ghb_settings_get_int(js, "job_status");
if (status != GHB_QUEUE_PENDING && status != GHB_QUEUE_CANCELED)
{
@@ -1771,7 +1771,7 @@ queue_drag_motion_cb(
}
indices = gtk_tree_path_get_indices(path);
row = indices[0];
- js = ghb_array_get_nth(ud->queue, row);
+ js = ghb_array_get(ud->queue, row);
finished = find_last_finished(ud->queue);
if (row < finished)
@@ -1855,7 +1855,7 @@ queue_drag_cb(
indices = gtk_tree_path_get_indices(srcpath);
row = indices[0];
gtk_tree_path_free(srcpath);
- js = ghb_array_get_nth(ud->queue, row);
+ js = ghb_array_get(ud->queue, row);
switch (pos)
{
@@ -2027,7 +2027,7 @@ queue_start_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
count = ghb_array_len(ud->queue);
for (ii = 0; ii < count; ii++)
{
- js = ghb_array_get_nth(ud->queue, ii);
+ js = ghb_array_get(ud->queue, ii);
status = ghb_settings_get_int(js, "job_status");
if ((status == GHB_QUEUE_RUNNING) ||
(status == GHB_QUEUE_PENDING))
@@ -2043,7 +2043,7 @@ queue_start_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
GhbValue *settings = ghb_value_dup(ud->settings);
if (!queue_add(ud, settings, 0))
{
- ghb_value_free(settings);
+ ghb_value_free(&settings);
return;
}
// Validation of settings may have changed audio list
@@ -2086,7 +2086,7 @@ find_pid:
count = ghb_array_len(queue);
for (ii = 0; ii < count; ii++)
{
- settings = ghb_array_get_nth(queue, ii);
+ settings = ghb_array_get(queue, ii);
status = ghb_settings_get_int(settings, "job_status");
if (status != GHB_QUEUE_DONE && status != GHB_QUEUE_CANCELED)
{
@@ -2095,7 +2095,7 @@ find_pid:
}
if (!unfinished)
{
- ghb_value_free(queue);
+ ghb_value_free(&queue);
goto find_pid;
}
else
@@ -2114,7 +2114,7 @@ find_pid:
// First get rid of any old items we don't want
for (ii = count-1; ii >= 0; ii--)
{
- settings = ghb_array_get_nth(queue, ii);
+ settings = ghb_array_get(queue, ii);
status = ghb_settings_get_int(settings, "job_status");
if (status == GHB_QUEUE_DONE || status == GHB_QUEUE_CANCELED)
{
@@ -2124,7 +2124,7 @@ find_pid:
count = ghb_array_len(queue);
for (ii = 0; ii < count; ii++)
{
- settings = ghb_array_get_nth(queue, ii);
+ settings = ghb_array_get(queue, ii);
ghb_settings_set_int(settings, "job_unique_id", 0);
ghb_settings_set_int(settings, "job_status", GHB_QUEUE_PENDING);
add_to_queue_list(ud, settings, NULL);
@@ -2134,7 +2134,7 @@ find_pid:
}
else
{
- ghb_value_free(queue);
+ ghb_value_free(&queue);
}
g_free(message);
}
@@ -2203,7 +2203,7 @@ queue_key_press_cb(
if (row < 0) return FALSE;
if (row >= ghb_array_len(ud->queue))
return FALSE;
- settings = ghb_array_get_nth(ud->queue, row);
+ settings = ghb_array_get(ud->queue, row);
status = ghb_settings_get_int(settings, "job_status");
if (status == GHB_QUEUE_RUNNING)
{
@@ -2257,7 +2257,7 @@ queue_edit_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
if (row < 0) return;
if (row >= ghb_array_len(ud->queue))
return;
- ghb_queue_edit_settings = ghb_array_get_nth(ud->queue, row);
+ ghb_queue_edit_settings = ghb_array_get(ud->queue, row);
status = ghb_settings_get_int(ghb_queue_edit_settings, "job_status");
if (status == GHB_QUEUE_PENDING)
{
diff --git a/gtk/src/resources.c b/gtk/src/resources.c
index c0caddf72..6683f1cd7 100644
--- a/gtk/src/resources.c
+++ b/gtk/src/resources.c
@@ -31,7 +31,7 @@ ghb_resource_init()
GBytes *gbytes;
gconstpointer data;
- resources = ghb_dict_value_new();
+ resources = ghb_dict_new();
ghb_data_register_resource();
GResource *data_res = ghb_data_get_resource();
@@ -39,42 +39,42 @@ ghb_resource_init()
gbytes = g_resource_lookup_data(data_res,
"/org/handbrake/data/internal_defaults.json", 0, NULL);
data = g_bytes_get_data(gbytes, &data_size);
- val = ghb_json_parse(data, data_size);
+ val = ghb_json_parse(data);
g_bytes_unref(gbytes);
- ghb_dict_insert(resources, "internal-defaults", val);
+ ghb_dict_set(resources, "internal-defaults", val);
gbytes = g_resource_lookup_data(data_res,
"/org/handbrake/data/standard_presets.json", 0, NULL);
data = g_bytes_get_data(gbytes, &data_size);
- val = ghb_json_parse(data, data_size);
+ val = ghb_json_parse(data);
g_bytes_unref(gbytes);
- ghb_dict_insert(resources, "standard-presets", val);
+ ghb_dict_set(resources, "standard-presets", val);
gbytes = g_resource_lookup_data(data_res,
"/org/handbrake/data/widget.deps", 0, NULL);
data = g_bytes_get_data(gbytes, &data_size);
- val = ghb_json_parse(data, data_size);
+ val = ghb_json_parse(data);
g_bytes_unref(gbytes);
- ghb_dict_insert(resources, "widget-deps", val);
+ ghb_dict_set(resources, "widget-deps", val);
gbytes = g_resource_lookup_data(data_res,
"/org/handbrake/data/widget_reverse.deps", 0, NULL);
data = g_bytes_get_data(gbytes, &data_size);
- val = ghb_json_parse(data, data_size);
+ val = ghb_json_parse(data);
g_bytes_unref(gbytes);
- ghb_dict_insert(resources, "widget-reverse-deps", val);
+ ghb_dict_set(resources, "widget-reverse-deps", val);
}
GhbValue*
ghb_resource_get(const gchar *name)
{
GhbValue *result;
- result = ghb_dict_lookup(resources, name);
+ result = ghb_dict_get(resources, name);
return result;
}
void
ghb_resource_free()
{
- ghb_value_free(resources);
+ ghb_value_free(&resources);
}
diff --git a/gtk/src/settings.c b/gtk/src/settings.c
index 26a622a61..31d66f5f8 100644
--- a/gtk/src/settings.c
+++ b/gtk/src/settings.c
@@ -34,7 +34,7 @@ debug_get_object(GtkBuilder* b, const gchar *n)
GhbValue*
ghb_settings_new()
{
- return ghb_dict_value_new();
+ return ghb_dict_new();
}
void
@@ -45,13 +45,13 @@ ghb_settings_set_value(
{
if (key == NULL || value == NULL)
return;
- ghb_dict_insert(settings, key, ghb_value_dup(value));
+ ghb_dict_set(settings, key, ghb_value_dup(value));
}
void
ghb_settings_take_value(GhbValue *settings, const gchar *key, GhbValue *value)
{
- ghb_dict_insert(settings, key, value);
+ ghb_dict_set(settings, key, value);
}
void
@@ -62,7 +62,7 @@ ghb_settings_set_string(
{
GhbValue *value;
value = ghb_string_value_new(sval);
- ghb_dict_insert(settings, key, value);
+ ghb_dict_set(settings, key, value);
}
void
@@ -70,38 +70,38 @@ ghb_settings_set_double(GhbValue *settings, const gchar *key, gdouble dval)
{
GhbValue *value;
value = ghb_double_value_new(dval);
- ghb_dict_insert(settings, key, value);
+ ghb_dict_set(settings, key, value);
}
void
ghb_settings_set_int64(GhbValue *settings, const gchar *key, gint64 ival)
{
GhbValue *value;
- value = ghb_int64_value_new(ival);
- ghb_dict_insert(settings, key, value);
+ value = ghb_int_value_new(ival);
+ ghb_dict_set(settings, key, value);
}
void
ghb_settings_set_int(GhbValue *settings, const gchar *key, gint ival)
{
GhbValue *value;
- value = ghb_int64_value_new((gint64)ival);
- ghb_dict_insert(settings, key, value);
+ value = ghb_int_value_new((gint64)ival);
+ ghb_dict_set(settings, key, value);
}
void
ghb_settings_set_boolean(GhbValue *settings, const gchar *key, gboolean bval)
{
GhbValue *value;
- value = ghb_boolean_value_new(bval);
- ghb_dict_insert(settings, key, value);
+ value = ghb_bool_value_new(bval);
+ ghb_dict_set(settings, key, value);
}
GhbValue*
ghb_settings_get_value(const GhbValue *settings, const gchar *key)
{
GhbValue *value;
- value = ghb_dict_lookup(settings, key);
+ value = ghb_dict_get(settings, key);
if (value == NULL)
g_debug("returning null (%s)", key);
return value;
@@ -113,7 +113,7 @@ ghb_settings_get_boolean(const GhbValue *settings, const gchar *key)
const GhbValue* value;
value = ghb_settings_get_value(settings, key);
if (value == NULL) return FALSE;
- return ghb_value_boolean(value);
+ return ghb_value_get_bool(value);
}
gint64
@@ -122,7 +122,7 @@ ghb_settings_get_int64(const GhbValue *settings, const gchar *key)
const GhbValue* value;
value = ghb_settings_get_value(settings, key);
if (value == NULL) return 0;
- return ghb_value_int64(value);
+ return ghb_value_get_int(value);
}
gint
@@ -131,7 +131,7 @@ ghb_settings_get_int(const GhbValue *settings, const gchar *key)
const GhbValue* value;
value = ghb_settings_get_value(settings, key);
if (value == NULL) return 0;
- return ghb_value_int(value);
+ return ghb_value_get_int(value);
}
gdouble
@@ -140,7 +140,7 @@ ghb_settings_get_double(const GhbValue *settings, const gchar *key)
const GhbValue* value;
value = ghb_settings_get_value(settings, key);
if (value == NULL) return 0;
- return ghb_value_double(value);
+ return ghb_value_get_double(value);
}
const gchar*
@@ -148,7 +148,7 @@ ghb_settings_get_const_string(const GhbValue *settings, const gchar *key)
{
const GhbValue* value;
value = ghb_settings_get_value(settings, key);
- return ghb_value_const_string(value);
+ return ghb_value_get_string(value);
}
gchar*
@@ -157,7 +157,7 @@ ghb_settings_get_string(const GhbValue *settings, const gchar *key)
const GhbValue* value;
value = ghb_settings_get_value(settings, key);
if (value == NULL) return g_strdup("");
- return ghb_value_string(value);
+ return ghb_value_get_string_xform(value);
}
gint
@@ -235,37 +235,37 @@ ghb_widget_value(GtkWidget *widget)
bval = gtk_toggle_button_get_inconsistent(GTK_TOGGLE_BUTTON(widget));
if (bval)
{
- value = ghb_boolean_value_new(FALSE);
+ value = ghb_bool_value_new(FALSE);
}
else
{
bval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
- value = ghb_boolean_value_new(bval);
+ value = ghb_bool_value_new(bval);
}
}
else if (type == GTK_TYPE_CHECK_BUTTON)
{
gboolean bval;
bval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
- value = ghb_boolean_value_new(bval);
+ value = ghb_bool_value_new(bval);
}
else if (type == GTK_TYPE_TOGGLE_TOOL_BUTTON)
{
gboolean bval;
bval = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(widget));
- value = ghb_boolean_value_new(bval);
+ value = ghb_bool_value_new(bval);
}
else if (type == GTK_TYPE_TOGGLE_BUTTON)
{
gboolean bval;
bval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
- value = ghb_boolean_value_new(bval);
+ value = ghb_bool_value_new(bval);
}
else if (type == GTK_TYPE_CHECK_MENU_ITEM)
{
gboolean bval;
bval = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
- value = ghb_boolean_value_new(bval);
+ value = ghb_bool_value_new(bval);
}
else if (type == GTK_TYPE_COMBO_BOX)
{
@@ -367,8 +367,8 @@ ghb_widget_string(GtkWidget *widget)
gchar *sval;
value = ghb_widget_value(widget);
- sval = ghb_value_string(value);
- ghb_value_free(value);
+ sval = ghb_value_get_string_xform(value);
+ ghb_value_free(&value);
return sval;
}
@@ -379,8 +379,8 @@ ghb_widget_double(GtkWidget *widget)
gdouble dval;
value = ghb_widget_value(widget);
- dval = ghb_value_double(value);
- ghb_value_free(value);
+ dval = ghb_value_get_double(value);
+ ghb_value_free(&value);
return dval;
}
@@ -391,8 +391,8 @@ ghb_widget_int64(GtkWidget *widget)
gint64 ival;
value = ghb_widget_value(widget);
- ival = ghb_value_int64(value);
- ghb_value_free(value);
+ ival = ghb_value_get_int(value);
+ ghb_value_free(&value);
return ival;
}
@@ -403,8 +403,8 @@ ghb_widget_int(GtkWidget *widget)
gint ival;
value = ghb_widget_value(widget);
- ival = (gint)ghb_value_int64(value);
- ghb_value_free(value);
+ ival = (gint)ghb_value_get_int(value);
+ ghb_value_free(&value);
return ival;
}
@@ -415,8 +415,8 @@ ghb_widget_boolean(GtkWidget *widget)
gboolean bval;
value = ghb_widget_value(widget);
- bval = ghb_value_boolean(value);
- ghb_value_free(value);
+ bval = ghb_value_get_bool(value);
+ ghb_value_free(&value);
return bval;
}
@@ -455,9 +455,9 @@ ghb_update_widget(GtkWidget *widget, const GhbValue *value)
if (type == GHB_ARRAY || type == GHB_DICT)
return;
if (value == NULL) return;
- str = tmp = ghb_value_string(value);
- ival = ghb_value_int(value);
- dval = ghb_value_double(value);
+ str = tmp = ghb_value_get_string_xform(value);
+ ival = ghb_value_get_int(value);
+ dval = ghb_value_get_double(value);
type = G_OBJECT_TYPE(widget);
if (str == NULL)
diff --git a/gtk/src/subtitlehandler.c b/gtk/src/subtitlehandler.c
index 9efc9c57d..440dbe0a6 100644
--- a/gtk/src/subtitlehandler.c
+++ b/gtk/src/subtitlehandler.c
@@ -145,7 +145,7 @@ subtitle_refresh_list_ui_from_settings(signal_user_data_t *ud, GhbValue *setting
{
g_return_if_fail(tv != NULL);
gtk_tree_model_iter_nth_child(tm, &ti, NULL, ii);
- subsettings = ghb_array_get_nth(subtitle_list, ii);
+ subsettings = ghb_array_get(subtitle_list, ii);
subtitle_refresh_list_row_ui(tm, &ti, subsettings);
}
}
@@ -164,7 +164,7 @@ ghb_subtitle_exclusive_burn_settings(GhbValue *settings, gint index)
gint ii, count;
subtitle_list = ghb_settings_get_value(settings, "subtitle_list");
- subsettings = ghb_array_get_nth(subtitle_list, index);
+ subsettings = ghb_array_get(subtitle_list, index);
if (subsettings != NULL)
{
int track = ghb_settings_get_int(subsettings, "SubtitleTrack");
@@ -182,7 +182,7 @@ ghb_subtitle_exclusive_burn_settings(GhbValue *settings, gint index)
{
if (ii != index)
{
- subsettings = ghb_array_get_nth(subtitle_list, ii);
+ subsettings = ghb_array_get(subtitle_list, ii);
int track = ghb_settings_get_int(subsettings, "SubtitleTrack");
if (track != -1)
{
@@ -216,7 +216,7 @@ ghb_subtitle_exclusive_default_settings(GhbValue *settings, gint index)
{
if (ii != index)
{
- subtitle = ghb_array_get_nth(subtitle_list, ii);
+ subtitle = ghb_array_get(subtitle_list, ii);
ghb_settings_set_boolean(subtitle, "SubtitleDefaultTrack", FALSE);
}
}
@@ -252,7 +252,7 @@ subtitle_add_to_settings(GhbValue *settings, GhbValue *subsettings)
subtitle_list = ghb_settings_get_value(settings, "subtitle_list");
if (subtitle_list == NULL)
{
- subtitle_list = ghb_array_value_new(8);
+ subtitle_list = ghb_array_new();
ghb_settings_set_value(settings, "subtitle_list", subtitle_list);
}
@@ -393,7 +393,7 @@ static GhbValue* subtitle_add_track(
return NULL;
}
- GhbValue *subsettings = ghb_dict_value_new();
+ GhbValue *subsettings = ghb_dict_new();
ghb_settings_set_int(subsettings, "SubtitleTrack", track);
ghb_settings_set_int(subsettings, "SubtitleSource", source);
@@ -526,8 +526,8 @@ ghb_set_pref_subtitle_settings(signal_user_data_t *ud, const hb_title_t *title,
lang_count = ghb_array_len(lang_list);
if (lang_count > 0)
{
- GhbValue *glang = ghb_array_get_nth(lang_list, 0);
- pref_lang = ghb_value_const_string(glang);
+ GhbValue *glang = ghb_array_get(lang_list, 0);
+ pref_lang = ghb_value_get_string(glang);
}
if (pref_lang == NULL || !strncmp(pref_lang, "und", 4))
@@ -582,8 +582,8 @@ ghb_set_pref_subtitle_settings(signal_user_data_t *ud, const hb_title_t *title,
// Find "best" subtitle based on subtitle preferences
for (ii = 0; ii < lang_count; ii++)
{
- GhbValue *glang = ghb_array_get_nth(lang_list, ii);
- const gchar *lang = ghb_value_const_string(glang);
+ GhbValue *glang = ghb_array_get(lang_list, ii);
+ const gchar *lang = ghb_value_get_string(glang);
int next_track = 0;
track = ghb_find_subtitle_track(title, lang, next_track);
@@ -717,7 +717,7 @@ subtitle_get_selected_settings(signal_user_data_t *ud, int *index)
if (row >= ghb_array_len(subtitle_list))
return NULL;
- subsettings = ghb_array_get_nth(subtitle_list, row);
+ subsettings = ghb_array_get(subtitle_list, row);
if (index != NULL)
*index = row;
}
@@ -954,7 +954,7 @@ ghb_subtitle_list_refresh_selected(signal_user_data_t *ud)
if (row >= ghb_array_len(subtitle_list))
return;
- subsettings = ghb_array_get_nth(subtitle_list, row);
+ subsettings = ghb_array_get(subtitle_list, row);
subtitle_refresh_list_row_ui(tm, &ti, subsettings);
}
}
@@ -1044,11 +1044,11 @@ ghb_clear_subtitle_list_settings(GhbValue *settings)
subtitle_list = ghb_settings_get_value(settings, "subtitle_list");
if (subtitle_list == NULL)
{
- subtitle_list = ghb_array_value_new();
+ subtitle_list = ghb_array_new();
ghb_settings_set_value(settings, "subtitle_list", subtitle_list);
}
else
- ghb_array_value_reset(subtitle_list);
+ ghb_array_reset(subtitle_list);
}
static void
@@ -1123,7 +1123,7 @@ subtitle_list_selection_changed_cb(GtkTreeSelection *ts, signal_user_data_t *ud)
subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
if (row >= 0 && row < ghb_array_len(subtitle_list))
- subsettings = ghb_array_get_nth(subtitle_list, row);
+ subsettings = ghb_array_get(subtitle_list, row);
}
subtitle_update_dialog_widgets(ud, subsettings);
if (subsettings)
@@ -1147,7 +1147,7 @@ static gboolean subtitle_is_one_burned(GhbValue *settings)
count = ghb_array_len(subtitle_list);
for (ii = 0; ii < count; ii++)
{
- subsettings = ghb_array_get_nth(subtitle_list, ii);
+ subsettings = ghb_array_get(subtitle_list, ii);
if (ghb_settings_get_boolean(subsettings, "SubtitleBurned"))
{
return TRUE;
@@ -1219,7 +1219,7 @@ subtitle_add_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
}
else
{
- ghb_value_free(backup);
+ ghb_value_free(&backup);
}
}
}
@@ -1293,7 +1293,7 @@ ghb_subtitle_prune(signal_user_data_t *ud)
gboolean burned;
int source;
- subsettings = ghb_array_get_nth(subtitle_list, ii);
+ subsettings = ghb_array_get(subtitle_list, ii);
burned = ghb_settings_get_boolean(subsettings, "SubtitleBurned");
source = ghb_settings_get_boolean(subsettings, "SubtitleSource");
burned = burned || !hb_subtitle_can_pass(source, mux->format);
@@ -1334,7 +1334,7 @@ ghb_reset_subtitles(signal_user_data_t *ud, GhbValue *settings)
count = ghb_array_len(slist);
for (ii = 0; ii < count; ii++)
{
- subtitle = ghb_value_dup(ghb_array_get_nth(slist, ii));
+ subtitle = ghb_value_dup(ghb_array_get(slist, ii));
subtitle_add_to_settings(ud->settings, subtitle);
}
subtitle_refresh_list_ui(ud);
@@ -1397,11 +1397,11 @@ ghb_subtitle_set_pref_lang(GhbValue *settings)
lang_list = ghb_settings_get_value(settings, "SubtitleLanguageList");
if (ghb_array_len(lang_list) > 0)
{
- GhbValue *glang = ghb_array_get_nth(lang_list, 0);
+ GhbValue *glang = ghb_array_get(lang_list, 0);
if (glang != NULL)
{
ghb_settings_set_string(settings, "PreferredLanguage",
- ghb_value_const_string(glang));
+ ghb_value_get_string(glang));
set = TRUE;
}
}
@@ -1484,7 +1484,7 @@ subtitle_remove_lang_clicked_cb(GtkWidget *widget, signal_user_data_t *ud)
if (ghb_array_len(lang_list) > 0)
{
const iso639_lang_t *lang;
- GhbValue *entry = ghb_array_get_nth(lang_list, 0);
+ GhbValue *entry = ghb_array_get(lang_list, 0);
lang = ghb_iso639_lookup_by_int(ghb_lookup_audio_lang(entry));
subtitle_update_pref_lang(ud, lang);
}
@@ -1525,7 +1525,7 @@ static void subtitle_def_lang_list_init(signal_user_data_t *ud)
lang_list = ghb_settings_get_value(ud->settings, "SubtitleLanguageList");
if (lang_list == NULL)
{
- lang_list = ghb_array_value_new(8);
+ lang_list = ghb_array_new();
ghb_settings_set_value(ud->settings, "SubtitleLanguageList", lang_list);
}
@@ -1533,7 +1533,7 @@ static void subtitle_def_lang_list_init(signal_user_data_t *ud)
count = ghb_array_len(lang_list);
for (ii = 0; ii < count; )
{
- GhbValue *lang_val = ghb_array_get_nth(lang_list, ii);
+ GhbValue *lang_val = ghb_array_get(lang_list, ii);
int idx = ghb_lookup_audio_lang(lang_val);
if (ii == 0)
{
@@ -1624,7 +1624,7 @@ subtitle_edit_clicked_cb(GtkWidget *widget, gchar *path, signal_user_data_t *ud)
}
else
{
- ghb_value_free(backup);
+ ghb_value_free(&backup);
}
}
}
diff --git a/gtk/src/values.c b/gtk/src/values.c
index b7ceaf082..3985e6490 100644
--- a/gtk/src/values.c
+++ b/gtk/src/values.c
@@ -20,45 +20,6 @@
#include <inttypes.h>
#include "values.h"
-GhbType
-ghb_value_type(const GhbValue *val)
-{
- if (val == NULL)
- return GHB_NULL;
- GhbType type = json_typeof(val);
- if (type == JSON_TRUE || type == JSON_FALSE)
- return GHB_BOOL;
- return type;
-}
-
-void
-ghb_value_incref(GhbValue *gval)
-{
- if (gval == NULL) return;
- json_incref(gval);
-}
-
-void
-ghb_value_decref(GhbValue *gval)
-{
- if (gval == NULL) return;
- json_decref(gval);
-}
-
-void
-ghb_value_free(GhbValue *gval)
-{
- if (gval == NULL) return;
- json_decref(gval);
-}
-
-GhbValue*
-ghb_value_dup(const GhbValue *gval)
-{
- if (gval == NULL) return NULL;
- return json_deep_copy(gval);
-}
-
void
debug_show_type(GhbType tp)
{
@@ -123,202 +84,6 @@ debug_show_value(GhbValue *gval)
}
}
-static GhbValue* xform_int(json_int_t i, GhbType type)
-{
- switch (type)
- {
- default:
- case GHB_NULL:
- return json_null();
- case GHB_BOOL:
- return json_boolean(i);
- case GHB_INT:
- return json_integer(i);
- case GHB_DOUBLE:
- return json_real(i);
- case GHB_STRING:
- {
- char *s = g_strdup_printf("%"JSON_INTEGER_FORMAT, i);
- GhbValue *v = json_string(s);
- g_free(s);
- return v;
- }
- }
-}
-
-static GhbValue* xform_double(double d, GhbType type)
-{
- switch (type)
- {
- default:
- case GHB_NULL:
- return json_null();
- case GHB_BOOL:
- return json_boolean((int)d != 0);
- case GHB_INT:
- return json_integer(d);
- case GHB_DOUBLE:
- return json_real(d);
- case GHB_STRING:
- {
- char *s = g_strdup_printf("%g", d);
- GhbValue *v = json_string(s);
- g_free(s);
- return v;
- }
- }
-}
-
-static GhbValue* xform_string(const char * s, GhbType type)
-{
- switch (type)
- {
- default:
- case GHB_NULL:
- {
- return json_null();
- }
- case GHB_BOOL:
- {
- if (!strcasecmp(s, "true") ||
- !strcasecmp(s, "yes") ||
- !strcasecmp(s, "1"))
- {
- return json_true();
- }
- return json_false();
- }
- case GHB_INT:
- {
- double d = g_strtod(s, NULL);
- return json_integer(d);
- }
- case GHB_DOUBLE:
- {
- double d = g_strtod(s, NULL);
- return json_real(d);
- }
- case GHB_STRING:
- {
- return json_string(s);
- }
- }
-}
-
-static GhbValue* xform_null(GhbType type)
-{
- switch (type)
- {
- default:
- case GHB_NULL:
- return json_null();
- case GHB_BOOL:
- return json_false();
- case GHB_INT:
- return json_integer(0);
- case GHB_DOUBLE:
- return json_real(0.0);
- case GHB_STRING:
- return json_string("");
- }
-}
-
-GhbValue* ghb_value_xform(const GhbValue *val, GhbType type)
-{
- GhbType src_type = ghb_value_type(val);
- if (src_type == type && val != NULL)
- {
- json_incref((GhbValue*)val);
- return (GhbValue*)val;
- }
- switch (src_type)
- {
- default:
- case GHB_NULL:
- {
- return xform_null(type);
- }
- case GHB_BOOL:
- {
- json_int_t b = json_is_true(val);
- return xform_int(b, type);
- }
- case GHB_INT:
- {
- json_int_t i = json_integer_value(val);
- return xform_int(i, type);
- }
- case GHB_DOUBLE:
- {
- double d = json_real_value(val);
- return xform_double(d, type);
- }
- case GHB_STRING:
- {
- const char *s = json_string_value(val);
- return xform_string(s, type);
- }
- }
-}
-
-gint
-ghb_value_int(const GhbValue *val)
-{
- gint result;
- GhbValue *v = ghb_value_xform(val, GHB_INT);
- result = json_integer_value(v);
- json_decref(v);
- return result;
-}
-
-gint64
-ghb_value_int64(const GhbValue *val)
-{
- gint64 result;
- GhbValue *v = ghb_value_xform(val, GHB_INT);
- result = json_integer_value(v);
- json_decref(v);
- return result;
-}
-
-gdouble
-ghb_value_double(const GhbValue *val)
-{
- gdouble result;
- GhbValue *v = ghb_value_xform(val, GHB_DOUBLE);
- result = json_real_value(v);
- json_decref(v);
- return result;
-}
-
-gchar*
-ghb_value_string(const GhbValue *val)
-{
- gchar *result;
- GhbValue *v = ghb_value_xform(val, GHB_STRING);
- result = g_strdup(json_string_value(v));
- json_decref(v);
- return result;
-}
-
-const gchar*
-ghb_value_const_string(const GhbValue *val)
-{
- if (ghb_value_type(val) != GHB_STRING)
- return NULL;
- return json_string_value(val);
-}
-
-gboolean
-ghb_value_boolean(const GhbValue *val)
-{
- gboolean result;
- GhbValue *v = ghb_value_xform(val, GHB_BOOL);
- result = json_is_true(v);
- json_decref(v);
- return result;
-}
-
gint
ghb_value_cmp(const GhbValue *vala, const GhbValue *valb)
{
@@ -337,7 +102,7 @@ ghb_string_value(const gchar *str)
}
GhbValue*
-ghb_int64_value(gint64 ival)
+ghb_int_value(gint64 ival)
{
static GhbValue *gval = NULL;
if (gval == NULL)
@@ -348,12 +113,6 @@ ghb_int64_value(gint64 ival)
}
GhbValue*
-ghb_int_value(gint ival)
-{
- return ghb_int64_value(ival);
-}
-
-GhbValue*
ghb_double_value(gdouble dval)
{
static GhbValue *gval = NULL;
@@ -373,180 +132,9 @@ ghb_boolean_value(gboolean bval)
return gval;
}
-GhbValue*
-ghb_string_value_new(const gchar *str)
-{
- return json_string(str);
-}
-
void
ghb_string_value_set(GhbValue *gval, const gchar *str)
{
json_string_set(gval, str);
}
-GhbValue*
-ghb_int64_value_new(gint64 ival)
-{
- return json_integer(ival);
-}
-
-GhbValue*
-ghb_int_value_new(gint ival)
-{
- return json_integer(ival);
-}
-
-GhbValue*
-ghb_double_value_new(gdouble dval)
-{
- return json_real(dval);
-}
-
-GhbValue*
-ghb_boolean_value_new(gboolean bval)
-{
- return json_boolean(bval);
-}
-
-GhbValue*
-ghb_dict_value_new()
-{
- return json_object();
-}
-
-GhbValue*
-ghb_array_value_new()
-{
- return json_array();
-}
-
-void
-ghb_array_value_reset(GhbValue *array)
-{
- json_array_clear(array);
-}
-
-void
-ghb_dict_insert(GhbValue *dict, const gchar *key, GhbValue *val)
-{
- json_object_set_new(dict, key, val);
-}
-
-void
-ghb_dict_iter_init(GhbValue *dict, GhbDictIter *iter)
-{
- *iter = json_object_iter(dict);
-}
-
-int
-ghb_dict_iter_next(GhbValue *dict, GhbDictIter *iter,
- const char **key, GhbValue **val)
-{
- if (*iter == NULL)
- return 0;
- if (key != NULL)
- *key = json_object_iter_key(*iter);
- if (val != NULL)
- *val = json_object_iter_value(*iter);
- *iter = json_object_iter_next(dict, *iter);
- return 1;
-}
-
-GhbValue*
-ghb_dict_lookup(const GhbValue *dict, const gchar *key)
-{
- return json_object_get(dict, key);
-}
-
-gboolean
-ghb_dict_remove(GhbValue *dict, const gchar *key)
-{
- return json_object_del(dict, key) == 0;
-}
-
-GhbValue*
-ghb_array_get_nth(const GhbValue *array, gint ii)
-{
- return json_array_get(array, ii);
-}
-
-void
-ghb_array_insert(GhbValue *array, guint ii, GhbValue *val)
-{
- json_array_insert_new(array, ii, val);
-}
-
-void
-ghb_array_append(GhbValue *array, GhbValue *val)
-{
- json_array_append_new(array, val);
-}
-
-void
-ghb_array_remove(GhbValue *array, guint ii)
-{
- json_array_remove(array, ii);
-}
-
-void
-ghb_array_replace(GhbValue *array, guint ii, GhbValue *val)
-{
- if (ii < 0 || ii >= json_array_size(array))
- {
- g_warning("ghb_array_replace: invalid index");
- return;
- }
- json_array_set_new(array, ii, val);
-}
-
-void
-ghb_array_copy(GhbValue *arr1, GhbValue *arr2, gint count)
-{
- gint len, ii;
-
- // empty the first array if it is not already empty
- json_array_clear(arr1);
-
- len = ghb_array_len(arr2);
- count = MIN(count, len);
- for (ii = 0; ii < count; ii++)
- ghb_array_append(arr1, ghb_value_dup(ghb_array_get_nth(arr2, ii)));
-}
-
-gint
-ghb_array_len(const GhbValue *array)
-{
- return json_array_size(array);
-}
-
-void
-ghb_json_write(FILE *file, GhbValue *gval)
-{
- char * json = json_dumps(gval, JSON_INDENT(4)|JSON_PRESERVE_ORDER);
- fprintf(file, "%s", json);
- free(json);
-}
-
-void
-ghb_json_write_file(const char *path, GhbValue *gval)
-{
- FILE *file = g_fopen(path, "w");
- if (file == NULL)
- return;
- ghb_json_write(file, gval);
- fclose(file);
-}
-
-GhbValue*
-ghb_json_parse(const char *json, size_t size)
-{
- return json_loadb(json, size, JSON_REJECT_DUPLICATES, NULL);
-}
-
-GhbValue*
-ghb_json_parse_file(const char *path)
-{
- return json_load_file(path, JSON_REJECT_DUPLICATES, NULL);
-}
-
diff --git a/gtk/src/values.h b/gtk/src/values.h
index 7c8786f5d..9c2072710 100644
--- a/gtk/src/values.h
+++ b/gtk/src/values.h
@@ -18,73 +18,70 @@
#include <glib.h>
#include <glib-object.h>
-#include "jansson.h"
+#include "hb_dict.h"
-#define GHB_DICT JSON_OBJECT
-#define GHB_ARRAY JSON_ARRAY
-#define GHB_STRING JSON_STRING
-#define GHB_INT JSON_INTEGER
-#define GHB_DOUBLE JSON_REAL
-#define GHB_NULL JSON_NULL
-#define GHB_BOOL 0xff
+#define GHB_DICT HB_VALUE_TYPE_DICT
+#define GHB_ARRAY HB_VALUE_TYPE_ARRAY
+#define GHB_STRING HB_VALUE_TYPE_STRING
+#define GHB_INT HB_VALUE_TYPE_INT
+#define GHB_DOUBLE HB_VALUE_TYPE_DOUBLE
+#define GHB_NULL HB_VALUE_TYPE_NULL
+#define GHB_BOOL HB_VALUE_TYPE_BOOL
-typedef json_t GhbValue;
-typedef int GhbType;
-typedef void* GhbDictIter;
+typedef hb_value_t GhbValue;
+typedef hb_value_type_t GhbType;
+typedef hb_dict_iter_t GhbDictIter;
-void ghb_value_incref(GhbValue *gval);
-void ghb_value_decref(GhbValue *gval);
-GhbType ghb_value_type(const GhbValue *val);
-GhbType ghb_array_get_type(void);
-GhbType ghb_dict_get_type(void);
-GhbValue* ghb_array_get_nth(const GhbValue *array, gint ii);
-void ghb_array_insert(GhbValue *gval, guint ii, GhbValue *val);
-void ghb_array_replace(GhbValue *gval, guint ii, GhbValue *val);
-void ghb_array_append(GhbValue *gval, GhbValue *val);
-void ghb_array_remove(GhbValue *gval, guint ii);
-gint ghb_array_len(const GhbValue *gval);
-void ghb_array_copy(GhbValue *arr1, GhbValue *arr2, gint count);
+#define ghb_dict_new hb_dict_init
+#define ghb_dict_get hb_dict_get
+#define ghb_dict_set hb_dict_set
+#define ghb_dict_remove hb_dict_remove
+#define ghb_dict_iter_init hb_dict_iter_init
+#define ghb_dict_iter_next hb_dict_iter_next_ex
-GhbValue* ghb_value_xform(const GhbValue *val, GhbType type);
-void ghb_value_free(GhbValue *gval);
-GhbValue* ghb_value_dup(const GhbValue *val);
-gint ghb_value_int(const GhbValue *val);
-gint64 ghb_value_int64(const GhbValue *val);
-gdouble ghb_value_double(const GhbValue *val);
-gchar* ghb_value_string(const GhbValue *val);
-const gchar* ghb_value_const_string(const GhbValue *val);
-gboolean ghb_value_boolean(const GhbValue *val);
+#define ghb_value_incref hb_value_incref
+#define ghb_value_decref hb_value_decref
+#define ghb_value_free hb_value_free
+#define ghb_value_type hb_value_type
+#define ghb_value_dup hb_value_dup
-GhbValue* ghb_string_value(const gchar *str);
-void ghb_string_value_set(GhbValue *gval, const gchar *str);
-GhbValue* ghb_int64_value(gint64 ival);
-GhbValue* ghb_int_value(gint ival);
-GhbValue* ghb_double_value(gdouble dval);
-GhbValue* ghb_boolean_value(gboolean bval);
+#define ghb_array_new hb_value_array_init
+#define ghb_array_get hb_value_array_get
+#define ghb_array_insert hb_value_array_insert
+#define ghb_array_append hb_value_array_append
+#define ghb_array_remove hb_value_array_remove
+#define ghb_array_replace hb_value_array_set
+#define ghb_array_len hb_value_array_len
+#define ghb_array_copy hb_value_array_copy
+#define ghb_array_reset hb_value_array_clear
+
+#define ghb_value_get_int hb_value_get_int
+#define ghb_value_get_double hb_value_get_double
+#define ghb_value_get_bool hb_value_get_bool
+#define ghb_value_get_string hb_value_get_string
+#define ghb_value_get_string_xform hb_value_get_string_xform
+
+#define ghb_value_xform hb_value_xform
+
+#define ghb_string_value_new hb_value_string
+#define ghb_int_value_new hb_value_int
+#define ghb_double_value_new hb_value_double
+#define ghb_bool_value_new hb_value_bool
+
+#define ghb_json_write(file,val) hb_value_write_file_json(val,file)
+#define ghb_json_write_file(path,val) hb_value_write_json(val,path)
+#define ghb_json_parse hb_value_json
+#define ghb_json_parse_file hb_value_read_json
gint ghb_value_cmp(const GhbValue *vala, const GhbValue *valb);
-GhbValue* ghb_string_value_new(const gchar *str);
-GhbValue* ghb_int64_value_new(gint64 ival);
-GhbValue* ghb_int_value_new(gint ival);
-GhbValue* ghb_double_value_new(gdouble dval);
-GhbValue* ghb_boolean_value_new(gboolean bval);
-GhbValue* ghb_dict_value_new(void);
-GhbValue* ghb_array_value_new();
-void ghb_array_value_reset(GhbValue *array);
+void ghb_string_value_set(GhbValue *gval, const gchar *str);
-void ghb_dict_insert(GhbValue *gval, const gchar *key, GhbValue *val);
-void ghb_dict_iter_init(GhbValue *gval, GhbDictIter *iter);
-int ghb_dict_iter_next(GhbValue *dict, GhbDictIter *iter,
- const char **key, GhbValue **val);
-GhbValue* ghb_dict_lookup(const GhbValue *gval, const gchar *key);
-gboolean ghb_dict_remove(GhbValue *gval, const gchar *key);
+GhbValue* ghb_string_value(const gchar *str);
+GhbValue* ghb_int_value(gint64 ival);
+GhbValue* ghb_double_value(gdouble dval);
+GhbValue* ghb_boolean_value(gboolean bval);
void debug_show_value(GhbValue *gval);
void debug_show_type(GhbType tp);
-void ghb_json_write(FILE *file, GhbValue *gval);
-void ghb_json_write_file(const char *path, GhbValue *gval);
-GhbValue* ghb_json_parse(const char *json, size_t size);
-GhbValue* ghb_json_parse_file(const char *path);
-
#endif // _GHB_VALUES_H_
diff --git a/gtk/src/x264handler.c b/gtk/src/x264handler.c
index 649a3a78f..e8e2f3f2b 100644
--- a/gtk/src/x264handler.c
+++ b/gtk/src/x264handler.c
@@ -366,7 +366,7 @@ x264_update_int_setting(signal_user_data_t *ud, const gchar *name, const gchar *
if (val == NULL) return;
ival = g_strtod (val, NULL);
- ghb_settings_set_value(ud->x264_priv, name, ghb_int64_value(ival));
+ ghb_settings_set_value(ud->x264_priv, name, ghb_int_value(ival));
ghb_check_dependency(ud, NULL, name);
}
@@ -712,7 +712,7 @@ x264_opt_update(signal_user_data_t *ud, GtkWidget *widget)
gval = ghb_widget_value(widget);
if (ghb_value_type(gval) == GHB_BOOL)
{
- if (ghb_value_boolean(gval))
+ if (ghb_value_get_bool(gval))
val = g_strdup("1");
else
val = g_strdup("0");
@@ -721,7 +721,7 @@ x264_opt_update(signal_user_data_t *ud, GtkWidget *widget)
{
val = ghb_widget_string(widget);
}
- ghb_value_free(gval);
+ ghb_value_free(&gval);
}
if (type == X264_OPT_TRANS)
{
@@ -759,7 +759,7 @@ x264_opt_update(signal_user_data_t *ud, GtkWidget *widget)
gval = ghb_widget_value(widget);
if (ghb_value_type(gval) == GHB_BOOL)
{
- if (ghb_value_boolean(gval))
+ if (ghb_value_get_bool(gval))
val = g_strdup("1");
else
val = g_strdup("0");
@@ -768,7 +768,7 @@ x264_opt_update(signal_user_data_t *ud, GtkWidget *widget)
{
val = ghb_widget_string(widget);
}
- ghb_value_free(gval);
+ ghb_value_free(&gval);
}
if (type == X264_OPT_TRANS)
{