diff options
author | jstebbins <[email protected]> | 2015-03-06 18:12:27 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2015-03-06 18:12:27 +0000 |
commit | b2afa282e450e3c1e7c1ab75925734086e6b706a (patch) | |
tree | 65376e1623e890e518c3dc5f1b847a255b82d2c6 | |
parent | f6bf7d75908d718ea620ac2e6f691627d0a9e7c2 (diff) |
LinGui: change settings dict from glib to jansson
This will allow for preferences, presets, and queue files to be
written as json instead of plists (currently still plists).
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6968 b64f7644-9d1e-0410-96f1-a4d463321fa5
34 files changed, 1410 insertions, 1827 deletions
diff --git a/doc/BUILD-Linux b/doc/BUILD-Linux index 1702276f1..3490ccb19 100644 --- a/doc/BUILD-Linux +++ b/doc/BUILD-Linux @@ -1,4 +1,4 @@ -Guide to Building HandBrake svn6419 (2014093001) on Linux +Guide to Building HandBrake svn6963 (2015030501) on Linux ********************************************************* 1 Introduction @@ -82,6 +82,7 @@ Ubuntu 14.04 packages: * libass-dev (cli/gui) * libmp3lame-dev (cli/gui) * libx264-dev (cli/gui) + * libjansson-dev (cli/gui) * intltool (gui) * libglib2.0-dev (gui) * libdbus-glib-1-dev (gui) @@ -132,6 +133,7 @@ Additional Fedora packages: * libass-devel (cli/gui) * lame-devel (cli/gui) * x264-devel (cli/gui) + * jansson-devel (cli/gui) * dbus-glib-devel (gui) * libgudev1-devel (gui) * webkitgtk3-devel (gui) @@ -511,6 +513,6 @@ Appendix A Project Repository Details root: svn://svn.handbrake.fr/HandBrake branch: trunk uuid: b64f7644-9d1e-0410-96f1-a4d463321fa5 - rev: 6419 - date: 2014-09-21 09:44:45 -0700 + rev: 6963 + date: 2015-03-03 12:59:35 -0700 type: developer diff --git a/doc/texi/Building.linux.texi b/doc/texi/Building.linux.texi index 79da9b796..89fb33fee 100644 --- a/doc/texi/Building.linux.texi +++ b/doc/texi/Building.linux.texi @@ -52,6 +52,7 @@ Ubuntu 14.04 packages: @item libass-dev (cli/gui) @item libmp3lame-dev (cli/gui) @item libx264-dev (cli/gui) +@item libjansson-dev (cli/gui) @item intltool (gui) @item libglib2.0-dev (gui) @item libdbus-glib-1-dev (gui) @@ -110,6 +111,7 @@ Additional Fedora packages: @item libass-devel (cli/gui) @item lame-devel (cli/gui) @item x264-devel (cli/gui) +@item jansson-devel (cli/gui) @item dbus-glib-devel (gui) @item libgudev1-devel (gui) @item webkitgtk3-devel (gui) diff --git a/gtk/configure.ac b/gtk/configure.ac index 45b30b2cf..88fdf65df 100644 --- a/gtk/configure.ac +++ b/gtk/configure.ac @@ -153,8 +153,8 @@ if test x"$BUILD_PKG_CONFIG" = x"no"; then AC_MSG_ERROR([You need to install pkg-config]) fi -GHB_TOOLS_CFLAGS=`$BUILD_PKG_CONFIG --cflags glib-2.0 gdk-pixbuf-2.0 gtk+-3.0` -GHB_TOOLS_LIBS=`$BUILD_PKG_CONFIG --libs glib-2.0 gdk-pixbuf-2.0` +GHB_TOOLS_CFLAGS=`$BUILD_PKG_CONFIG --cflags glib-2.0 gdk-pixbuf-2.0 gtk+-3.0 jansson` +GHB_TOOLS_LIBS=`$BUILD_PKG_CONFIG --libs glib-2.0 gdk-pixbuf-2.0 jansson` HB_LIBS="-lhandbrake -lavresample -lavformat -lavcodec -lavutil -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lsamplerate -lx264 -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson" diff --git a/gtk/src/audiohandler.c b/gtk/src/audiohandler.c index 4fea404aa..8f59f6d7c 100644 --- a/gtk/src/audiohandler.c +++ b/gtk/src/audiohandler.c @@ -22,10 +22,10 @@ #include "audiohandler.h" #include "presets.h" -static void audio_add_to_settings(GValue *settings, GValue *asettings); -static void ghb_add_audio_to_ui(signal_user_data_t *ud, const GValue *settings); -static GValue* audio_get_selected_settings(signal_user_data_t *ud, int *index); -static void ghb_clear_audio_list_settings(GValue *settings); +static void audio_add_to_settings(GhbValue *settings, GhbValue *asettings); +static void ghb_add_audio_to_ui(signal_user_data_t *ud, const GhbValue *settings); +static GhbValue* audio_get_selected_settings(signal_user_data_t *ud, int *index); +static void ghb_clear_audio_list_settings(GhbValue *settings); static void ghb_clear_audio_list_ui(GtkBuilder *builder); static void ghb_adjust_audio_rate_combos(signal_user_data_t *ud); @@ -48,7 +48,7 @@ static void enable_quality_widget(signal_user_data_t *ud, int acodec) } } -static void audio_deps(signal_user_data_t *ud, GValue *asettings, GtkWidget *widget) +static void audio_deps(signal_user_data_t *ud, GhbValue *asettings, GtkWidget *widget) { ghb_adjust_audio_rate_combos(ud); ghb_grey_combo_options (ud); @@ -147,7 +147,7 @@ ghb_select_audio_codec(gint mux, hb_audio_config_t *aconfig, gint acodec, gint f return acodec; } -int ghb_get_copy_mask(GValue *settings) +int ghb_get_copy_mask(GhbValue *settings) { gint mask = 0; @@ -174,7 +174,7 @@ int ghb_get_copy_mask(GValue *settings) return mask; } -int ghb_select_fallback(GValue *settings, int acodec) +int ghb_select_fallback(GhbValue *settings, int acodec) { gint fallback = 0; @@ -198,7 +198,7 @@ int ghb_select_fallback(GValue *settings, int acodec) } static void -ghb_sanitize_audio_settings(GValue *settings, GValue *asettings) +ghb_sanitize_audio_settings(GhbValue *settings, GhbValue *asettings) { int title_id, titleindex; const hb_title_t *title; @@ -268,7 +268,7 @@ ghb_sanitize_audio_settings(GValue *settings, GValue *asettings) static void ghb_adjust_audio_rate_combos(signal_user_data_t *ud) { - GValue *asettings = audio_get_selected_settings(ud, NULL); + GhbValue *asettings = audio_get_selected_settings(ud, NULL); if (asettings != NULL) { ghb_sanitize_audio_settings(ud->settings, asettings); @@ -324,17 +324,17 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud) void ghb_santiize_audio_tracks(signal_user_data_t *ud) { int ii; - GValue *alist = ghb_settings_get_value(ud->settings, "audio_list"); + GhbValue *alist = ghb_settings_get_value(ud->settings, "audio_list"); int count = ghb_array_len(alist); for (ii = 0; ii < count; ii++) { - GValue *asettings = ghb_array_get_nth(alist, ii); + GhbValue *asettings = ghb_array_get_nth(alist, ii); ghb_sanitize_audio_settings(ud->settings, asettings); } ghb_audio_list_refresh_all(ud); - GValue *asettings = audio_get_selected_settings(ud, NULL); + GhbValue *asettings = audio_get_selected_settings(ud, NULL); if (asettings != NULL) { ghb_ui_update(ud, "AudioEncoder", @@ -370,7 +370,7 @@ static char * get_gain_string(gdouble gain) return s_gain; } -static char * get_quality_string(GValue *settings, gdouble quality) +static char * get_quality_string(GhbValue *settings, gdouble quality) { float low, high, gran; int dir; @@ -386,7 +386,7 @@ static char * get_quality_string(GValue *settings, gdouble quality) } static void -audio_update_dialog_widgets(signal_user_data_t *ud, GValue *asettings) +audio_update_dialog_widgets(signal_user_data_t *ud, GhbValue *asettings) { if (asettings != NULL) { @@ -436,9 +436,9 @@ free_audio_hash_key_value(gpointer data) } const gchar* -ghb_get_user_audio_lang(GValue *settings, const hb_title_t *title, gint track) +ghb_get_user_audio_lang(GhbValue *settings, const hb_title_t *title, gint track) { - GValue *audio_list, *asettings; + GhbValue *audio_list, *asettings; const gchar *lang; audio_list = ghb_settings_get_value(settings, "audio_list"); @@ -468,9 +468,9 @@ get_track_used(gint settings, GHashTable *track_indices, gint count) return used; } -static GValue* +static GhbValue* audio_add_track( - GValue *settings, + GhbValue *settings, const hb_title_t *title, int track, int encoder, @@ -482,7 +482,7 @@ audio_add_track( gdouble drc, gdouble gain) { - GValue *asettings; + GhbValue *asettings; hb_audio_config_t *aconfig = NULL; aconfig = ghb_get_audio_info(title, track); @@ -520,16 +520,16 @@ audio_add_track( return asettings; } -static GValue* +static GhbValue* audio_select_and_add_track( const hb_title_t *title, - GValue *settings, - GValue *pref_audio, + GhbValue *settings, + GhbValue *pref_audio, const char *lang, int pref_index, int start_track) { - GValue *audio, *asettings = NULL; + GhbValue *audio, *asettings = NULL; gdouble drc, gain, quality; gboolean enable_quality; gint track, acodec, bitrate, samplerate, mix; @@ -579,13 +579,13 @@ audio_select_and_add_track( static void set_pref_audio_with_lang( const hb_title_t *title, - GValue *settings, + GhbValue *settings, const char *lang, int behavior, gboolean secondary_audio_track_mode, GHashTable *track_used) { - const GValue *pref_audio, *audio_list; + const GhbValue *pref_audio, *audio_list; int count, ii, track, track_count, audio_count; audio_list = ghb_settings_get_value(settings, "audio_list"); @@ -607,7 +607,7 @@ static void set_pref_audio_with_lang( count = (track_count && secondary_audio_track_mode) ? 1 : count; for (ii = 0; ii < count; ii++) { - const GValue *audio; + const GhbValue *audio; gint acodec, fallback, copy_mask, bitrate, samplerate, mix; gint select_acodec; gdouble drc, gain, quality; @@ -671,13 +671,13 @@ void ghb_audio_title_change(signal_user_data_t *ud, gboolean title_valid) } void -ghb_set_pref_audio_settings(GValue *settings) +ghb_set_pref_audio_settings(GhbValue *settings) { GHashTable *track_used; int title_id, titleindex; const hb_title_t *title; - const GValue *lang_list; + const GhbValue *lang_list; gint behavior; gint ii, audio_count, lang_count; @@ -712,12 +712,12 @@ ghb_set_pref_audio_settings(GValue *settings) { const gchar *lang; gboolean mode; - GValue *glang = ghb_array_get_nth(lang_list, ii); - lang = g_value_get_string(glang); + GhbValue *glang = ghb_array_get_nth(lang_list, ii); + lang = ghb_value_const_string(glang); mode = ghb_settings_get_boolean(settings, "AudioSecondaryEncoderMode"); set_pref_audio_with_lang(title, settings, lang, behavior, mode, track_used); } - GValue *audio_list = ghb_settings_get_value(settings, "audio_list"); + GhbValue *audio_list = ghb_settings_get_value(settings, "audio_list"); if (audio_list == NULL || ghb_array_len(audio_list) == 0) { // No matching audio tracks found. Add first track matching @@ -727,7 +727,7 @@ ghb_set_pref_audio_settings(GValue *settings) g_hash_table_destroy(track_used); } -static GValue* +static GhbValue* audio_get_selected_settings(signal_user_data_t *ud, int *index) { GtkTreeView *tv; @@ -737,8 +737,8 @@ audio_get_selected_settings(signal_user_data_t *ud, int *index) GtkTreeIter ti; gint *indices; gint row; - GValue *asettings = NULL; - const GValue *audio_list; + GhbValue *asettings = NULL; + const GhbValue *audio_list; tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "audio_list_view")); ts = gtk_tree_view_get_selection (tv); @@ -768,7 +768,7 @@ audio_refresh_list_row_ui( GtkTreeModel *tm, GtkTreeIter *ti, signal_user_data_t *ud, - const GValue *settings) + const GhbValue *settings) { GtkTreeIter cti; char *info_src, *info_src_2; @@ -920,8 +920,8 @@ ghb_audio_list_refresh_selected(signal_user_data_t *ud) GtkTreeIter ti; gint *indices; gint row; - GValue *asettings = NULL; - const GValue *audio_list; + GhbValue *asettings = NULL; + const GhbValue *audio_list; g_debug("ghb_audio_list_refresh_selected ()"); tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "audio_list_view")); @@ -947,8 +947,8 @@ ghb_audio_list_refresh_selected(signal_user_data_t *ud) static void audio_refresh_list_ui(signal_user_data_t *ud) { - GValue *audio_list; - GValue *asettings; + GhbValue *audio_list; + GhbValue *asettings; gint ii, count, tm_count; GtkTreeView *tv; GtkTreeModel *tm; @@ -988,7 +988,7 @@ audio_codec_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { static gint prev_acodec = 0; gint acodec; - GValue *asettings; + GhbValue *asettings; ghb_widget_to_setting(ud->settings, widget); acodec = ghb_settings_audio_encoder_codec(ud->settings, "AudioEncoder"); @@ -1078,7 +1078,7 @@ audio_codec_changed_cb(GtkWidget *widget, signal_user_data_t *ud) G_MODULE_EXPORT void audio_track_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { - GValue *asettings; + GhbValue *asettings; g_debug("audio_track_changed_cb ()"); ghb_widget_to_setting(ud->settings, widget); @@ -1119,7 +1119,7 @@ audio_track_changed_cb(GtkWidget *widget, signal_user_data_t *ud) G_MODULE_EXPORT void audio_mix_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { - GValue *asettings; + GhbValue *asettings; ghb_widget_to_setting(ud->settings, widget); if (block_updates) @@ -1140,7 +1140,7 @@ audio_mix_changed_cb(GtkWidget *widget, signal_user_data_t *ud) G_MODULE_EXPORT void audio_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { - GValue *asettings; + GhbValue *asettings; ghb_widget_to_setting(ud->settings, widget); if (block_updates) @@ -1209,7 +1209,7 @@ char * ghb_format_quality( const char *prefix, int codec, double quality ) G_MODULE_EXPORT void quality_widget_changed_cb(GtkWidget *widget, gdouble quality, signal_user_data_t *ud) { - GValue *asettings; + GhbValue *asettings; ghb_check_dependency(ud, widget, NULL); char *s_quality = get_quality_string(ud->settings, quality); @@ -1230,7 +1230,7 @@ quality_widget_changed_cb(GtkWidget *widget, gdouble quality, signal_user_data_t G_MODULE_EXPORT void drc_widget_changed_cb(GtkWidget *widget, gdouble drc, signal_user_data_t *ud) { - GValue *asettings; + GhbValue *asettings; g_debug("drc_widget_changed_cb ()"); @@ -1265,7 +1265,7 @@ format_gain_cb(GtkScale *scale, gdouble val, signal_user_data_t *ud) G_MODULE_EXPORT void gain_widget_changed_cb(GtkWidget *widget, gdouble gain, signal_user_data_t *ud) { - GValue *asettings; + GhbValue *asettings; g_debug("gain_widget_changed_cb ()"); @@ -1289,19 +1289,19 @@ gain_widget_changed_cb(GtkWidget *widget, gdouble gain, signal_user_data_t *ud) } void -ghb_clear_audio_list_settings(GValue *settings) +ghb_clear_audio_list_settings(GhbValue *settings) { - GValue *audio_list; + GhbValue *audio_list; g_debug("clear_audio_list_settings ()"); audio_list = ghb_settings_get_value(settings, "audio_list"); if (audio_list == NULL) { - audio_list = ghb_array_value_new(8); + audio_list = ghb_array_value_new(); ghb_settings_set_value(settings, "audio_list", audio_list); } else - ghb_array_value_reset(audio_list, 8); + ghb_array_value_reset(audio_list); } void @@ -1322,7 +1322,7 @@ ghb_clear_audio_list_ui(GtkBuilder *builder) } static void -ghb_add_audio_to_ui(signal_user_data_t *ud, const GValue *asettings) +ghb_add_audio_to_ui(signal_user_data_t *ud, const GhbValue *asettings) { GtkTreeView *tv; GtkTreeIter ti; @@ -1347,7 +1347,7 @@ audio_list_selection_changed_cb(GtkTreeSelection *ts, signal_user_data_t *ud) { GtkTreeModel *tm; GtkTreeIter ti; - GValue *asettings = NULL; + GhbValue *asettings = NULL; gint row; g_debug("audio_list_selection_changed_cb ()"); @@ -1371,7 +1371,7 @@ audio_list_selection_changed_cb(GtkTreeSelection *ts, signal_user_data_t *ud) GtkTreePath *tp; gint *indices; - GValue *audio_list; + GhbValue *audio_list; // Get the row number tp = gtk_tree_model_get_path (tm, &ti); @@ -1388,9 +1388,9 @@ audio_list_selection_changed_cb(GtkTreeSelection *ts, signal_user_data_t *ud) } static void -audio_add_to_settings(GValue *settings, GValue *asettings) +audio_add_to_settings(GhbValue *settings, GhbValue *asettings) { - GValue *audio_list; + GhbValue *audio_list; int title_id; const hb_title_t *title; gint titleindex; @@ -1415,7 +1415,7 @@ audio_add_to_settings(GValue *settings, GValue *asettings) g_free(desc); } - GValue *aname; + GhbValue *aname; aname = ghb_dict_lookup(asettings, "AudioTrackName"); if (aname == NULL) { @@ -1428,7 +1428,7 @@ G_MODULE_EXPORT void audio_add_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) { // Add the current audio settings to the list. - GValue *asettings, *backup; + GhbValue *asettings, *backup; int title_id, titleindex; const hb_title_t *title; @@ -1438,7 +1438,7 @@ audio_add_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) // Back up settings in case we need to revert. backup = ghb_value_dup( ghb_settings_get_value(ud->settings, "audio_list")); - GValue *pref_audio = ghb_settings_get_value(ud->settings, "AudioList"); + GhbValue *pref_audio = ghb_settings_get_value(ud->settings, "AudioList"); asettings = audio_select_and_add_track(title, ud->settings, pref_audio, "und", 0, 0); ghb_add_audio_to_ui(ud, asettings); @@ -1479,14 +1479,14 @@ audio_add_all_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) title_id = ghb_settings_get_int(ud->settings, "title"); title = ghb_lookup_title(title_id, &titleindex); - GValue *pref_audio = ghb_settings_get_value(ud->settings, "AudioList"); + GhbValue *pref_audio = ghb_settings_get_value(ud->settings, "AudioList"); int pref_count = ghb_array_len(pref_audio); int ii; for (ii = 0; ii < pref_count; ii++) { - GValue *asettings; + GhbValue *asettings; int track = 0; do @@ -1520,7 +1520,7 @@ audio_edit_clicked_cb(GtkWidget *widget, gchar *path, signal_user_data_t *ud) if (gtk_tree_path_get_depth(tp) > 1) return; if (gtk_tree_model_get_iter(tm, &ti, tp)) { - GValue *asettings, *backup; + GhbValue *asettings, *backup; gtk_tree_selection_select_iter(ts, &ti); @@ -1560,7 +1560,7 @@ audio_remove_clicked_cb(GtkWidget *widget, gchar *path, signal_user_data_t *ud) GtkTreeIter ti, nextIter; gint row; gint *indices; - GValue *audio_list; + GhbValue *audio_list; tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "audio_list_view")); ts = gtk_tree_view_get_selection(tv); @@ -1598,7 +1598,7 @@ audio_remove_clicked_cb(GtkWidget *widget, gchar *path, signal_user_data_t *ud) // treeview. Removing from the treeview sometimes provokes an // immediate selection change, so the list needs to be up to date // when this happens. - GValue *old = ghb_array_get_nth(audio_list, row); + GhbValue *old = ghb_array_get_nth(audio_list, row); ghb_value_free(old); ghb_array_remove(audio_list, row); @@ -1617,7 +1617,7 @@ audio_reset_clicked_cb(GtkWidget *widget, signal_user_data_t *ud) audio_refresh_list_ui(ud); } -static GtkWidget *find_widget(GtkWidget *widget, gchar *name) +static GtkWidget *find_widget(GtkWidget *widget, const gchar *name) { const char *wname; GtkWidget *result = NULL; @@ -1646,17 +1646,17 @@ static GtkWidget *find_widget(GtkWidget *widget, gchar *name) return result; } -static void audio_def_update_widgets(GtkWidget *row, GValue *adict) +static void audio_def_update_widgets(GtkWidget *row, GhbValue *adict) { - GHashTableIter ti; - gchar *key; - GValue *gval; + GhbDictIter ti; + const gchar *key; + GhbValue *gval; GtkWidget *widget; - ghb_dict_iter_init(&ti, adict); + ghb_dict_iter_init(adict, &ti); block_updates = TRUE; - while (g_hash_table_iter_next(&ti, (gpointer*)&key, (gpointer*)&gval)) + while (ghb_dict_iter_next(adict, &ti, &key, &gval)) { widget = find_widget(row, key); if (widget != NULL) @@ -1732,7 +1732,7 @@ static void audio_def_settings_show(GtkWidget *widget, gboolean show) } static void -audio_def_settings_init_row(GValue *adict, GtkWidget *row) +audio_def_settings_init_row(GhbValue *adict, GtkWidget *row) { GtkWidget *widget; @@ -2039,11 +2039,11 @@ audio_def_setting_update(signal_user_data_t *ud, GtkWidget *widget) GtkListBoxRow *row = audio_settings_get_row(widget); gint index = gtk_list_box_row_get_index(row); - GValue *alist = ghb_settings_get_value(ud->settings, "AudioList"); + GhbValue *alist = ghb_settings_get_value(ud->settings, "AudioList"); int count = ghb_array_len(alist); if (!block_updates && index >= 0 && index < count) { - GValue *adict = ghb_array_get_nth(alist, index); + GhbValue *adict = ghb_array_get_nth(alist, index); ghb_widget_to_setting(adict, widget); } } @@ -2061,7 +2061,7 @@ audio_add_lang_clicked_cb(GtkWidget *widget, signal_user_data_t *ud) { int idx; const iso639_lang_t *lang; - GValue *glang, *alang_list; + GhbValue *glang, *alang_list; // Remove from UI available language list box label = gtk_bin_get_child(GTK_BIN(row)); @@ -2095,7 +2095,7 @@ audio_remove_lang_clicked_cb(GtkWidget *widget, signal_user_data_t *ud) if (row != NULL) { gint index; - GValue *alang_list; + GhbValue *alang_list; index = gtk_list_box_row_get_index(row); @@ -2110,7 +2110,7 @@ audio_remove_lang_clicked_cb(GtkWidget *widget, signal_user_data_t *ud) // Remove from preset language list alang_list = ghb_settings_get_value(ud->settings, "AudioLanguageList"); - GValue *glang = ghb_array_get_nth(alang_list, index); + GhbValue *glang = ghb_array_get_nth(alang_list, index); ghb_array_remove(alang_list, index); ghb_value_free(glang); ghb_clear_presets_selection(ud); @@ -2148,12 +2148,12 @@ void audio_def_set_limits(signal_user_data_t *ud, GtkWidget *widget, gboolean se GtkListBoxRow *row = audio_settings_get_row(widget); gint index = gtk_list_box_row_get_index(row); - GValue *alist = ghb_settings_get_value(ud->settings, "AudioList"); + GhbValue *alist = ghb_settings_get_value(ud->settings, "AudioList"); int count = ghb_array_len(alist); if (index < 0 || index >= count) return; - GValue *adict = ghb_array_get_nth(alist, index); + GhbValue *adict = ghb_array_get_nth(alist, index); int codec = ghb_settings_audio_encoder_codec(adict, "AudioEncoder"); int fallback = ghb_settings_audio_encoder_codec(ud->settings, @@ -2239,8 +2239,8 @@ audio_def_quality_enable_changed_cb(GtkWidget *widget, signal_user_data_t *ud) GtkListBoxRow *row = audio_settings_get_row(widget); gint index = gtk_list_box_row_get_index(row); - GValue *alist = ghb_settings_get_value(ud->settings, "AudioList"); - GValue *adict = ghb_array_get_nth(alist, index); + GhbValue *alist = ghb_settings_get_value(ud->settings, "AudioList"); + GhbValue *adict = ghb_array_get_nth(alist, index); audio_def_settings_bitrate_show(GTK_WIDGET(row), !ghb_settings_get_boolean(adict, "AudioTrackQualityEnable")); @@ -2257,8 +2257,8 @@ audio_def_quality_changed_cb(GtkWidget *widget, gdouble quality, signal_user_dat "AudioTrackQualityValue"); gint index = gtk_list_box_row_get_index(row); - GValue *alist = ghb_settings_get_value(ud->settings, "AudioList"); - GValue *adict = ghb_array_get_nth(alist, index); + GhbValue *alist = ghb_settings_get_value(ud->settings, "AudioList"); + GhbValue *adict = ghb_array_get_nth(alist, index); char *s_quality = get_quality_string(adict, quality); ghb_update_widget(quality_label, ghb_string_value(s_quality)); g_free(s_quality); @@ -2297,8 +2297,8 @@ audio_def_setting_add_cb(GtkWidget *widget, signal_user_data_t *ud) { GtkListBoxRow *row = audio_settings_get_row(widget); - GValue *adict; - GValue *alist = ghb_settings_get_value(ud->settings, "AudioList"); + GhbValue *adict; + GhbValue *alist = ghb_settings_get_value(ud->settings, "AudioList"); int count = ghb_array_len(alist); if (count > 0) { @@ -2330,14 +2330,14 @@ audio_def_setting_remove_cb(GtkWidget *widget, signal_user_data_t *ud) GtkListBoxRow *row = audio_settings_get_row(widget); gint index = gtk_list_box_row_get_index(row); - GValue *alist = ghb_settings_get_value(ud->settings, "AudioList"); + GhbValue *alist = ghb_settings_get_value(ud->settings, "AudioList"); int count = ghb_array_len(alist); if (index < 0 || index >= count) { return; } gtk_widget_destroy(GTK_WIDGET(row)); - GValue *asettings = ghb_array_get_nth(alist, index); + GhbValue *asettings = ghb_array_get_nth(alist, index); ghb_array_remove(alist, index); ghb_value_free(asettings); ghb_clear_presets_selection(ud); @@ -2406,7 +2406,7 @@ audio_def_selected_lang_list_clear(signal_user_data_t *ud) static void audio_def_lang_list_init(signal_user_data_t *ud) { - GValue *lang_list; + GhbValue *lang_list; // Clear selected languages. audio_def_selected_lang_list_clear(ud); @@ -2422,7 +2422,7 @@ audio_def_lang_list_init(signal_user_data_t *ud) count = ghb_array_len(lang_list); for (ii = 0; ii < count; ) { - GValue *lang_val = ghb_array_get_nth(lang_list, ii); + GhbValue *lang_val = ghb_array_get_nth(lang_list, ii); int idx = ghb_lookup_audio_lang(lang_val); GtkListBox *avail, *selected; @@ -2443,7 +2443,7 @@ audio_def_lang_list_init(signal_user_data_t *ud) { // Error in list. Probably duplicate languages. Remove // this item from the list. - GValue *glang = ghb_array_get_nth(lang_list, ii); + GhbValue *glang = ghb_array_get_nth(lang_list, ii); ghb_array_remove(lang_list, ii); ghb_value_free(glang); count--; @@ -2454,7 +2454,7 @@ audio_def_lang_list_init(signal_user_data_t *ud) void ghb_audio_defaults_to_ui(signal_user_data_t *ud) { GtkListBox *list_box; - GValue *alist; + GhbValue *alist; int count, ii; audio_def_lang_list_init(ud); @@ -2476,7 +2476,7 @@ void ghb_audio_defaults_to_ui(signal_user_data_t *ud) count = ghb_array_len(alist); for (ii = 0; ii < count; ii++) { - GValue *adict; + GhbValue *adict; adict = ghb_array_get_nth(alist, ii); widget = ghb_create_audio_settings_row(ud); diff --git a/gtk/src/audiohandler.h b/gtk/src/audiohandler.h index 93f91708f..46bcce3c3 100644 --- a/gtk/src/audiohandler.h +++ b/gtk/src/audiohandler.h @@ -25,15 +25,16 @@ #if !defined(_AUDIOHANDLER_H_) #define _AUDIOHANDLER_H_ +#include "values.h" #include "settings.h" void ghb_santiize_audio_tracks(signal_user_data_t *ud); -void ghb_set_pref_audio_settings(GValue *settings); -const gchar* ghb_get_user_audio_lang(GValue *settings, const hb_title_t *title, gint track); +void ghb_set_pref_audio_settings(GhbValue *settings); +const gchar* ghb_get_user_audio_lang(GhbValue *settings, const hb_title_t *title, gint track); void ghb_audio_list_refresh_selected(signal_user_data_t *ud); gint ghb_select_audio_codec(gint mux, hb_audio_config_t *aconfig, gint acodec, gint fallback_acodec, gint copy_mask); -int ghb_select_fallback( GValue *settings, int acodec ); -int ghb_get_copy_mask(GValue *settings); +int ghb_select_fallback( GhbValue *settings, int acodec ); +int ghb_get_copy_mask(GhbValue *settings); void ghb_audio_list_refresh_all(signal_user_data_t *ud); char * ghb_format_quality( const char *prefix, int codec, double quality ); void ghb_init_audio_defaults_ui(signal_user_data_t *ud); diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index 65da635b5..2fc2e5a2d 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -78,7 +78,7 @@ #include "x264handler.h" static void load_all_titles(signal_user_data_t *ud, int titleindex); -static void update_chapter_list_settings(GValue *settings); +static void update_chapter_list_settings(GhbValue *settings); static GList* dvd_device_list(); static void prune_logs(signal_user_data_t *ud); void ghb_notify_done(signal_user_data_t *ud); @@ -96,8 +96,8 @@ static gboolean appcast_busy = FALSE; // you will have to look further to combo box options // maps in hb-backend.c -GValue *dep_map; -GValue *rev_map; +GhbValue *dep_map; +GhbValue *rev_map; void ghb_init_dep_map() @@ -114,7 +114,7 @@ dep_check(signal_user_data_t *ud, const gchar *name, gboolean *out_hide) gint ii; gint count; gboolean result = TRUE; - GValue *array, *data; + GhbValue *array, *data; gchar *widget_name; g_debug("dep_check () %s", name); @@ -207,7 +207,7 @@ ghb_check_dependency( { GObject *dep_object; const gchar *name; - GValue *array, *data; + GhbValue *array, *data; gint count, ii; gchar *dep_name; GType type; @@ -222,7 +222,7 @@ ghb_check_dependency( else name = alt_name; - g_debug("ghb_check_dependency () %s", name); + g_debug("ghb_check_dependency() %s", name); if (dep_map == NULL) return; array = ghb_dict_lookup(dep_map, name); @@ -264,18 +264,15 @@ ghb_check_dependency( void ghb_check_all_depencencies(signal_user_data_t *ud) { - GHashTableIter iter; - gchar *dep_name; - GValue *value; + GhbDictIter iter; + const gchar *dep_name; + GhbValue *value; GObject *dep_object; g_debug("ghb_check_all_depencencies ()"); if (rev_map == NULL) return; - ghb_dict_iter_init(&iter, rev_map); - // middle (void*) cast prevents gcc warning "defreferencing type-punned - // pointer will break strict-aliasing rules" - while (g_hash_table_iter_next( - &iter, (gpointer*)(void*)&dep_name, (gpointer*)(void*)&value)) + ghb_dict_iter_init(rev_map, &iter); + while (ghb_dict_iter_next(rev_map, &iter, &dep_name, &value)) { gboolean sensitive; gboolean hide; @@ -542,7 +539,7 @@ ghb_cache_volnames(signal_user_data_t *ud) } static const gchar* -get_extension(signal_user_data_t *ud, GValue *settings) +get_extension(signal_user_data_t *ud, GhbValue *settings) { const char *mux_id; const hb_container_t *mux; @@ -573,7 +570,7 @@ check_name_template(signal_user_data_t *ud, const char *str) } static void -set_destination_settings(signal_user_data_t *ud, GValue *settings) +set_destination_settings(signal_user_data_t *ud, GhbValue *settings) { const gchar *extension; gchar *filename; @@ -1047,7 +1044,7 @@ ghb_scale_configure( } void -ghb_set_widget_ranges(signal_user_data_t *ud, GValue *settings) +ghb_set_widget_ranges(signal_user_data_t *ud, GhbValue *settings) { int title_id, titleindex; const hb_title_t * title; @@ -1138,17 +1135,14 @@ check_chapter_markers(signal_user_data_t *ud) #if 0 void -show_settings(GValue *settings) +show_settings(GhbValue *settings) { - GHashTableIter iter; - gchar *key; - GValue *gval; + GhbDictIter iter; + const gchar *key; + GhbValue *gval; - ghb_dict_iter_init(&iter, settings); - // middle (void*) cast prevents gcc warning "defreferencing type-punned - // pointer will break strict-aliasing rules" - while (g_hash_table_iter_next( - &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval)) + ghb_dict_iter_init(settings, &iter); + while (ghb_dict_iter_next(settings, &iter, &key, &gval)) { char *str = ghb_value_string(gval); printf("show key %s val %s\n", key, str); @@ -1160,7 +1154,7 @@ show_settings(GValue *settings) void ghb_load_settings(signal_user_data_t * ud) { - GValue *preset; + GhbValue *preset; gboolean preset_modified; static gboolean busy = FALSE; @@ -1256,7 +1250,7 @@ ghb_idle_scan(signal_user_data_t *ud) return FALSE; } -extern GValue *ghb_queue_edit_settings; +extern GhbValue *ghb_queue_edit_settings; static gchar *last_scan_file = NULL; void @@ -1800,7 +1794,7 @@ ghb_update_title_info(signal_user_data_t *ud) } void -set_title_settings(signal_user_data_t *ud, GValue *settings) +set_title_settings(signal_user_data_t *ud, GhbValue *settings) { int title_id, titleindex; const hb_title_t * title; @@ -1914,8 +1908,8 @@ static void load_all_titles(signal_user_data_t *ud, int titleindex) { gint ii, count; - GValue *preset, *preset_path = NULL; - GValue *settings_array; + GhbValue *preset, *preset_path = NULL; + GhbValue *settings_array; const hb_title_t *title; hb_list_t *list = ghb_get_title_list(); @@ -1938,7 +1932,7 @@ load_all_titles(signal_user_data_t *ud, int titleindex) for (ii = 0; ii < count; ii++) { int index; - GValue *settings = ghb_settings_new(); + GhbValue *settings = ghb_settings_new(); title = hb_list_item(list, ii); index = (title != NULL) ? title->index : -1; @@ -2683,9 +2677,9 @@ ghb_cancel_encode2(signal_user_data_t *ud, const gchar *extra_msg) } static gint -find_queue_job(GValue *queue, gint unique_id, GValue **job) +find_queue_job(GhbValue *queue, gint unique_id, GhbValue **job) { - GValue *js; + GhbValue *js; gint ii, count; gint job_unique_id; @@ -2709,12 +2703,12 @@ find_queue_job(GValue *queue, gint unique_id, GValue **job) } static void -submit_job(signal_user_data_t *ud, GValue *settings) +submit_job(signal_user_data_t *ud, GhbValue *settings) { static gint unique_id = 1; gchar *type, *modified, *preset; - const GValue *path; - GValue *js; + const GhbValue *path; + GhbValue *js; gboolean preset_modified; g_debug("submit_job"); @@ -2796,7 +2790,7 @@ prune_logs(signal_user_data_t *ud) } static void -queue_scan(signal_user_data_t *ud, GValue *js) +queue_scan(signal_user_data_t *ud, GhbValue *js) { gchar *path; gint title_id; @@ -2851,10 +2845,10 @@ queue_scan(signal_user_data_t *ud, GValue *js) } static gint -queue_pending_count(GValue *queue) +queue_pending_count(GhbValue *queue) { gint nn, ii, count; - GValue *js; + GhbValue *js; gint status; nn = 0; @@ -2886,11 +2880,11 @@ ghb_update_pending(signal_user_data_t *ud) g_free(str); } -GValue* +GhbValue* ghb_start_next_job(signal_user_data_t *ud) { gint count, ii; - GValue *js; + GhbValue *js; gint status; GtkWidget *progress; @@ -2941,7 +2935,7 @@ working_status_string(signal_user_data_t *ud, ghb_instance_status_t *status) gchar *task_str, *job_str, *status_str; gint qcount; gint index; - GValue *js; + GhbValue *js; gboolean subtitle_scan = FALSE; qcount = ghb_array_len(ud->queue); @@ -3015,7 +3009,7 @@ searching_status_string(signal_user_data_t *ud, ghb_instance_status_t *status) gchar *task_str, *job_str, *status_str; gint qcount; gint index; - GValue *js; + GhbValue *js; qcount = ghb_array_len(ud->queue); index = find_queue_job(ud->queue, status->unique_id, &js); @@ -3056,7 +3050,7 @@ ghb_backend_events(signal_user_data_t *ud) gchar *status_str; GtkProgressBar *progress; GtkLabel *work_status; - GValue *js; + GhbValue *js; gint index; GtkTreeView *treeview; GtkTreeModel *store; @@ -3681,7 +3675,7 @@ static void chapter_refresh_list_row_ui( GtkTreeModel *tm, GtkTreeIter *ti, - GValue *chapter_list, + GhbValue *chapter_list, const hb_title_t *title, int index) { @@ -3724,7 +3718,7 @@ ghb_clear_chapter_list_ui(GtkBuilder *builder) static void chapter_refresh_list_ui(signal_user_data_t *ud) { - GValue *chapter_list; + GhbValue *chapter_list; gint ii, count, tm_count; GtkTreeView *tv; GtkTreeModel *tm; @@ -3763,9 +3757,9 @@ ghb_chapter_list_refresh_all(signal_user_data_t *ud) } static void -update_chapter_list_settings(GValue *settings) +update_chapter_list_settings(GhbValue *settings) { - GValue *chapters; + GhbValue *chapters; gint title_id, titleindex; const hb_title_t *title; @@ -3819,12 +3813,12 @@ chapter_edited_cb( -1); gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, 0, &index, -1); - const GValue *chapters; - GValue *chapter; + const GhbValue *chapters; + GhbValue *chapter; chapters = ghb_settings_get_value(ud->settings, "chapter_list"); chapter = ghb_array_get_nth(chapters, index-1); - g_value_set_string(chapter, text); + 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)) { @@ -4001,7 +3995,7 @@ hbfd_feature_changed_cb(GtkWidget *widget, signal_user_data_t *ud) gboolean hbfd = ghb_settings_get_boolean(ud->prefs, "hbfd_feature"); if (hbfd) { - const GValue *val; + const GhbValue *val; val = ghb_settings_get_value(ud->prefs, "hbfd"); ghb_ui_settings_update(ud, ud->prefs, "hbfd", val); } diff --git a/gtk/src/callbacks.h b/gtk/src/callbacks.h index 97e2e1ce1..73003211e 100644 --- a/gtk/src/callbacks.h +++ b/gtk/src/callbacks.h @@ -31,6 +31,7 @@ #include <gtk/gtk.h> #include "hb.h" +#include "values.h" #include "settings.h" #if GLIB_CHECK_VERSION(2, 32, 0) @@ -60,7 +61,7 @@ void ghb_error_dialog( void ghb_init_dep_map(void); void ghb_cancel_encode(signal_user_data_t *ud, const gchar *extra_msg); gboolean ghb_cancel_encode2(signal_user_data_t *ud, const gchar *extra_msg); -GValue* ghb_start_next_job(signal_user_data_t *ud); +GhbValue* ghb_start_next_job(signal_user_data_t *ud); void ghb_check_dependency( signal_user_data_t *ud, GtkWidget *widget, const gchar *alt_name); void ghb_do_scan( signal_user_data_t *ud, const gchar *filename, diff --git a/gtk/src/create_resources.c b/gtk/src/create_resources.c index 233c468a9..d9a5e7668 100644 --- a/gtk/src/create_resources.c +++ b/gtk/src/create_resources.c @@ -40,7 +40,7 @@ typedef struct { gchar *key; gchar *value; - GValue *plist; + GhbValue *plist; GQueue *stack; GQueue *tag_stack; gboolean closed_top; @@ -91,12 +91,12 @@ lookup_attr_value( return NULL; } -static GValue* +static GhbValue* read_string_from_file(const gchar *fname) { gchar *buffer; size_t size; - GValue *gval; + GhbValue *gval; FILE *fd; fd = g_fopen(fname, "r"); @@ -108,13 +108,13 @@ read_string_from_file(const gchar *fname) buffer = g_malloc(size+1); size = fread(buffer, 1, size, fd); buffer[size] = 0; - gval = ghb_value_new(G_TYPE_STRING); - g_value_take_string(gval, buffer); + gval = ghb_string_value_new(buffer); + g_free(buffer); fclose(fd); return gval; } -static void add_icon(GValue *dict, const char *fname) +static void add_icon(GhbValue *dict, const char *fname) { FILE *f; @@ -132,30 +132,36 @@ static void add_icon(GValue *dict, const char *fname) return; } - ghb_rawdata_t *rd; - rd = g_malloc(sizeof(ghb_rawdata_t)); + char* base64; + guint8 *data; + gsize data_size; + fseek(f, 0, SEEK_END); - rd->size = ftell(f); + data_size = ftell(f); fseek(f, 0, SEEK_SET); - rd->data = g_malloc(rd->size); - fread(rd->data, 1, rd->size, f); + data = g_malloc(data_size); + fread(data, 1, data_size, f); + base64 = g_base64_encode(data, data_size); - GValue *data = ghb_rawdata_value_new(rd); - ghb_dict_insert(dict, g_strdup("svg"), ghb_boolean_value_new(svg)); - ghb_dict_insert(dict, g_strdup("data"), data); + GhbValue *icon = ghb_string_value_new(base64); + ghb_dict_insert(dict, "svg", ghb_boolean_value_new(svg)); + ghb_dict_insert(dict, "data", icon); + + g_free(base64); + g_free(data); } -static void insert_value(GValue *container, const char *key, GValue *element) +static void insert_value(GhbValue *container, const char *key, GhbValue *element) { - GType gtype; + GhbType gtype; - gtype = G_VALUE_TYPE(container); - if (gtype == ghb_array_get_type()) + gtype = ghb_value_type(container); + if (gtype == GHB_ARRAY) { ghb_array_append(container, element); } - else if (gtype == ghb_dict_get_type()) + else if (gtype == GHB_DICT) { if (key == NULL) { @@ -164,7 +170,7 @@ static void insert_value(GValue *container, const char *key, GValue *element) } else { - ghb_dict_insert(container, g_strdup(key), element); + ghb_dict_insert(container, key, element); } } else @@ -209,9 +215,8 @@ start_element( return; } g_queue_push_head(pd->tag_stack, id.pid); - GType gtype = 0; - GValue *gval = NULL; - GValue *current = g_queue_peek_head(pd->stack); + GhbValue *gval = NULL; + GhbValue *current = g_queue_peek_head(pd->stack); switch (id.id) { case R_SECTION: @@ -397,9 +402,8 @@ end_element( if (start_id.id != id) g_warning("start tag != end tag: (%s %d) %d", name, id, id); - GValue *gval = NULL; - GValue *current = g_queue_peek_head(pd->stack); - GType gtype = 0; + GhbValue *gval = NULL; + GhbValue *current = g_queue_peek_head(pd->stack); switch (id) { case R_SECTION: @@ -462,7 +466,7 @@ destroy_notify(gpointer data) //g_debug("destroy parser"); } -GValue* +GhbValue* ghb_resource_parse(const gchar *buf, gssize len) { GMarkupParseContext *ctx; @@ -493,12 +497,12 @@ ghb_resource_parse(const gchar *buf, gssize len) return pd.plist; } -GValue* +GhbValue* ghb_resource_parse_file(FILE *fd) { gchar *buffer; size_t size; - GValue *gval; + GhbValue *gval; if (fd == NULL) return NULL; @@ -535,7 +539,7 @@ gint main(gint argc, gchar *argv[]) { FILE *file; - GValue *gval; + GhbValue *gval; int opt; const gchar *src, *dst; diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index bfe48a0a8..cc206b0c8 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -761,14 +761,14 @@ ghb_vquality_range( } gint -find_combo_entry(combo_opts_t *opts, const GValue *gval) +find_combo_entry(combo_opts_t *opts, const GhbValue *gval) { gint ii; if (opts == NULL) return 0; - if (G_VALUE_TYPE(gval) == G_TYPE_STRING) + if (ghb_value_type(gval) == GHB_STRING) { gchar *str; str = ghb_value_string(gval); @@ -782,7 +782,7 @@ find_combo_entry(combo_opts_t *opts, const GValue *gval) g_free(str); return ii; } - else if (G_VALUE_TYPE(gval) == G_TYPE_DOUBLE) + else if (ghb_value_type(gval) == GHB_DOUBLE) { gdouble val; val = ghb_value_double(gval); @@ -795,9 +795,8 @@ find_combo_entry(combo_opts_t *opts, const GValue *gval) } return ii; } - else if (G_VALUE_TYPE(gval) == G_TYPE_INT || - G_VALUE_TYPE(gval) == G_TYPE_BOOLEAN || - G_VALUE_TYPE(gval) == G_TYPE_INT64) + else if (ghb_value_type(gval) == GHB_INT || + ghb_value_type(gval) == GHB_BOOL) { gint64 val; val = ghb_value_int64(gval); @@ -814,7 +813,7 @@ find_combo_entry(combo_opts_t *opts, const GValue *gval) } static const gchar* -lookup_generic_string(combo_opts_t *opts, const GValue *gval) +lookup_generic_string(combo_opts_t *opts, const GhbValue *gval) { gint ii; const gchar *result = ""; @@ -828,7 +827,7 @@ lookup_generic_string(combo_opts_t *opts, const GValue *gval) } static gint -lookup_generic_int(combo_opts_t *opts, const GValue *gval) +lookup_generic_int(combo_opts_t *opts, const GhbValue *gval) { gint ii; gint result = -1; @@ -845,7 +844,7 @@ lookup_generic_int(combo_opts_t *opts, const GValue *gval) } static gdouble -lookup_generic_double(combo_opts_t *opts, const GValue *gval) +lookup_generic_double(combo_opts_t *opts, const GhbValue *gval) { gint ii; gdouble result = -1; @@ -859,7 +858,7 @@ lookup_generic_double(combo_opts_t *opts, const GValue *gval) } static const gchar* -lookup_generic_option(combo_opts_t *opts, const GValue *gval) +lookup_generic_option(combo_opts_t *opts, const GhbValue *gval) { gint ii; const gchar *result = ""; @@ -897,7 +896,7 @@ const iso639_lang_t* ghb_iso639_lookup_by_int(int idx) } int -ghb_lookup_audio_lang(const GValue *glang) +ghb_lookup_audio_lang(const GhbValue *glang) { gint ii; gchar *str; @@ -941,7 +940,7 @@ ghb_lookup_audio_lang(const GValue *glang) } static int -lookup_audio_lang_int(const GValue *glang) +lookup_audio_lang_int(const GhbValue *glang) { gint ii = ghb_lookup_audio_lang(glang); if (ii >= 0) @@ -950,7 +949,7 @@ lookup_audio_lang_int(const GValue *glang) } static const gchar* -lookup_audio_lang_option(const GValue *glang) +lookup_audio_lang_option(const GhbValue *glang) { gint ii = ghb_lookup_audio_lang(glang); if (ii >= 0) @@ -988,7 +987,7 @@ ghb_hb_cleanup(gboolean partial) } gint -ghb_subtitle_track_source(GValue *settings, gint track) +ghb_subtitle_track_source(GhbValue *settings, gint track) { gint title_id, titleindex; const hb_title_t *title; @@ -1011,7 +1010,7 @@ ghb_subtitle_track_source(GValue *settings, gint track) } const gchar* -ghb_subtitle_track_lang(GValue *settings, gint track) +ghb_subtitle_track_lang(GhbValue *settings, gint track) { gint title_id, titleindex; const hb_title_t * title; @@ -1340,14 +1339,14 @@ ghb_lookup_audio_samplerate_rate(const char *name) } int -ghb_settings_audio_samplerate_rate(const GValue *settings, const char *name) +ghb_settings_audio_samplerate_rate(const GhbValue *settings, const char *name) { const char *rate_id = ghb_settings_get_const_string(settings, name); return ghb_lookup_audio_samplerate_rate(rate_id); } const hb_rate_t* -ghb_settings_audio_samplerate(const GValue *settings, const char *name) +ghb_settings_audio_samplerate(const GhbValue *settings, const char *name) { const char *rate_id = ghb_settings_get_const_string(settings, name); return ghb_lookup_audio_samplerate(rate_id); @@ -1435,14 +1434,14 @@ ghb_lookup_video_framerate_rate(const char *name) } int -ghb_settings_video_framerate_rate(const GValue *settings, const char *name) +ghb_settings_video_framerate_rate(const GhbValue *settings, const char *name) { const char *rate_id = ghb_settings_get_const_string(settings, name); return ghb_lookup_video_framerate_rate(rate_id); } const hb_rate_t* -ghb_settings_video_framerate(const GValue *settings, const char *name) +ghb_settings_video_framerate(const GhbValue *settings, const char *name) { const char *rate_id = ghb_settings_get_const_string(settings, name); return ghb_lookup_video_framerate(rate_id); @@ -1506,14 +1505,14 @@ ghb_lookup_video_encoder_codec(const char *name) } int -ghb_settings_video_encoder_codec(const GValue *settings, const char *name) +ghb_settings_video_encoder_codec(const GhbValue *settings, const char *name) { const char *encoder_id = ghb_settings_get_const_string(settings, name); return ghb_lookup_video_encoder_codec(encoder_id); } const hb_encoder_t* -ghb_settings_video_encoder(const GValue *settings, const char *name) +ghb_settings_video_encoder(const GhbValue *settings, const char *name) { const char *encoder_id = ghb_settings_get_const_string(settings, name); return ghb_lookup_video_encoder(encoder_id); @@ -1580,14 +1579,14 @@ ghb_lookup_audio_encoder_codec(const char *name) } int -ghb_settings_audio_encoder_codec(const GValue *settings, const char *name) +ghb_settings_audio_encoder_codec(const GhbValue *settings, const char *name) { const char *encoder_id = ghb_settings_get_const_string(settings, name); return ghb_lookup_audio_encoder_codec(encoder_id); } const hb_encoder_t* -ghb_settings_audio_encoder(const GValue *settings, const char *name) +ghb_settings_audio_encoder(const GhbValue *settings, const char *name) { const char *encoder_id = ghb_settings_get_const_string(settings, name); return ghb_lookup_audio_encoder(encoder_id); @@ -1705,14 +1704,14 @@ ghb_lookup_mixdown_mix(const char *name) } int -ghb_settings_mixdown_mix(const GValue *settings, const char *name) +ghb_settings_mixdown_mix(const GhbValue *settings, const char *name) { const char *mixdown_id = ghb_settings_get_const_string(settings, name); return ghb_lookup_mixdown_mix(mixdown_id); } const hb_mixdown_t* -ghb_settings_mixdown(const GValue *settings, const char *name) +ghb_settings_mixdown(const GhbValue *settings, const char *name) { const char *mixdown_id = ghb_settings_get_const_string(settings, name); return ghb_lookup_mixdown(mixdown_id); @@ -2036,7 +2035,7 @@ video_tune_opts_set(signal_user_data_t *ud, const gchar *name) // Check if encoder has been set yet. // If not, bail - GValue *value = ghb_dict_lookup(ud->settings, "VideoEncoder"); + GhbValue *value = ghb_dict_lookup(ud->settings, "VideoEncoder"); if (value == NULL) return; int encoder = ghb_get_video_encoder(ud->settings); @@ -2085,7 +2084,7 @@ video_profile_opts_set(signal_user_data_t *ud, const gchar *name) // Check if encoder has been set yet. // If not, bail - GValue *value = ghb_dict_lookup(ud->settings, "VideoEncoder"); + GhbValue *value = ghb_dict_lookup(ud->settings, "VideoEncoder"); if (value == NULL) return; int encoder = ghb_get_video_encoder(ud->settings); @@ -2122,7 +2121,7 @@ video_level_opts_set(signal_user_data_t *ud, const gchar *name) // Check if encoder has been set yet. // If not, bail - GValue *value = ghb_dict_lookup(ud->settings, "VideoEncoder"); + GhbValue *value = ghb_dict_lookup(ud->settings, "VideoEncoder"); if (value == NULL) return; int encoder = ghb_get_video_encoder(ud->settings); @@ -2454,7 +2453,7 @@ find_combo_table(const gchar *name) } gint -ghb_lookup_combo_int(const gchar *name, const GValue *gval) +ghb_lookup_combo_int(const gchar *name, const GhbValue *gval) { if (gval == NULL) return 0; @@ -2469,7 +2468,7 @@ ghb_lookup_combo_int(const gchar *name, const GValue *gval) } gdouble -ghb_lookup_combo_double(const gchar *name, const GValue *gval) +ghb_lookup_combo_double(const gchar *name, const GhbValue *gval) { if (gval == NULL) return 0; @@ -2484,7 +2483,7 @@ ghb_lookup_combo_double(const gchar *name, const GValue *gval) } const gchar* -ghb_lookup_combo_option(const gchar *name, const GValue *gval) +ghb_lookup_combo_option(const gchar *name, const GhbValue *gval) { if (gval == NULL) return NULL; @@ -2499,7 +2498,7 @@ ghb_lookup_combo_option(const gchar *name, const GValue *gval) } const gchar* -ghb_lookup_combo_string(const gchar *name, const GValue *gval) +ghb_lookup_combo_string(const gchar *name, const GhbValue *gval) { if (gval == NULL) return NULL; @@ -2684,7 +2683,7 @@ init_ui_combo_boxes(GtkBuilder *builder) // Construct the advanced options string // The result is allocated, so someone must free it at some point. gchar* -ghb_build_advanced_opts_string(GValue *settings) +ghb_build_advanced_opts_string(GhbValue *settings) { gint vcodec; vcodec = ghb_settings_video_encoder_codec(settings, "VideoEncoder"); @@ -2698,7 +2697,7 @@ ghb_build_advanced_opts_string(GValue *settings) } } -void ghb_set_video_encoder_opts(hb_job_t *job, GValue *js) +void ghb_set_video_encoder_opts(hb_job_t *job, GhbValue *js) { gint vcodec = ghb_settings_video_encoder_codec(js, "VideoEncoder"); @@ -2844,12 +2843,12 @@ ghb_get_chapter_start(const hb_title_t *title, gint chap) return start; } -GValue* +GhbValue* ghb_get_chapters(const hb_title_t *title) { hb_chapter_t * chapter; gint count, ii; - GValue *chapters = NULL; + GhbValue *chapters = NULL; chapters = ghb_array_value_new(0); @@ -2875,14 +2874,14 @@ ghb_get_chapters(const hb_title_t *title) } gboolean -ghb_ac3_in_audio_list(const GValue *audio_list) +ghb_ac3_in_audio_list(const GhbValue *audio_list) { gint count, ii; count = ghb_array_len(audio_list); for (ii = 0; ii < count; ii++) { - GValue *asettings; + GhbValue *asettings; gint acodec; asettings = ghb_array_get_nth(audio_list, ii); @@ -3115,14 +3114,14 @@ ghb_lookup_audio_bitrate_rate(const char *name) } int -ghb_settings_audio_bitrate_rate(const GValue *settings, const char *name) +ghb_settings_audio_bitrate_rate(const GhbValue *settings, const char *name) { const char *rate_id = ghb_settings_get_const_string(settings, name); return ghb_lookup_audio_bitrate_rate(rate_id); } const hb_rate_t* -ghb_settings_audio_bitrate(const GValue *settings, const char *name) +ghb_settings_audio_bitrate(const GhbValue *settings, const char *name) { const char *rate_id = ghb_settings_get_const_string(settings, name); return ghb_lookup_audio_bitrate(rate_id); @@ -3517,7 +3516,7 @@ ghb_limit_rational( gint *num, gint *den, gint limit ) } void -ghb_set_scale_settings(GValue *settings, gint mode) +ghb_set_scale_settings(GhbValue *settings, gint mode) { gboolean keep_aspect; gint pic_par; @@ -3884,7 +3883,7 @@ ghb_validate_filter_string(const gchar *str, gint max_fields) } gboolean -ghb_validate_filters(GValue *settings, GtkWindow *parent) +ghb_validate_filters(GhbValue *settings, GtkWindow *parent) { gchar *str; gint index; @@ -3951,7 +3950,7 @@ ghb_validate_filters(GValue *settings, GtkWindow *parent) } gboolean -ghb_validate_video(GValue *settings, GtkWindow *parent) +ghb_validate_video(GhbValue *settings, GtkWindow *parent) { gint vcodec; gchar *message; @@ -3984,7 +3983,7 @@ ghb_validate_video(GValue *settings, GtkWindow *parent) } gboolean -ghb_validate_subtitles(GValue *settings, GtkWindow *parent) +ghb_validate_subtitles(GhbValue *settings, GtkWindow *parent) { gint title_id, titleindex; const hb_title_t * title; @@ -3999,7 +3998,7 @@ ghb_validate_subtitles(GValue *settings, GtkWindow *parent) return FALSE; } - const GValue *slist, *subtitle; + const GhbValue *slist, *subtitle; gint count, ii, source, track; gboolean burned, one_burned = FALSE; @@ -4059,7 +4058,7 @@ ghb_validate_subtitles(GValue *settings, GtkWindow *parent) } gboolean -ghb_validate_audio(GValue *settings, GtkWindow *parent) +ghb_validate_audio(GhbValue *settings, GtkWindow *parent) { gint title_id, titleindex; const hb_title_t * title; @@ -4080,14 +4079,14 @@ ghb_validate_audio(GValue *settings, GtkWindow *parent) mux_id = ghb_settings_get_const_string(settings, "FileFormat"); mux = ghb_lookup_container_by_name(mux_id); - const GValue *audio_list; + const GhbValue *audio_list; gint count, ii; audio_list = ghb_settings_get_value(settings, "audio_list"); count = ghb_array_len(audio_list); for (ii = 0; ii < count; ii++) { - GValue *asettings; + GhbValue *asettings; hb_audio_config_t *aconfig; int track, codec; @@ -4190,7 +4189,7 @@ ghb_validate_audio(GValue *settings, GtkWindow *parent) } static void -add_job(hb_handle_t *h, GValue *js, gint unique_id, int titleindex) +add_job(hb_handle_t *h, GhbValue *js, gint unique_id, int titleindex) { hb_list_t * list; const hb_title_t * title; @@ -4198,7 +4197,7 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, int titleindex) hb_filter_object_t * filter; gchar *filter_str; gchar *dest_str = NULL; - GValue *prefs; + GhbValue *prefs; g_debug("add_job()\n"); if (h == NULL) return; @@ -4285,8 +4284,8 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, int titleindex) job->chapter_markers = 0; if ( job->chapter_markers ) { - GValue *chapters; - GValue *chapter; + GhbValue *chapters; + GhbValue *chapter; gint chap; gint count; @@ -4466,7 +4465,7 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, int titleindex) hb_add_filter( job, filter, filter_str ); g_free(filter_str); - const GValue *audio_list; + const GhbValue *audio_list; gint count, ii; gint tcount = 0; @@ -4474,7 +4473,7 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, int titleindex) count = ghb_array_len(audio_list); for (ii = 0; ii < count; ii++) { - GValue *asettings; + GhbValue *asettings; hb_audio_config_t audio; hb_audio_config_t *aconfig; gint acodec, fallback; @@ -4559,7 +4558,7 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, int titleindex) hb_job_set_file( job, dest_str); g_free(dest_str); - const GValue *subtitle_list; + const GhbValue *subtitle_list; gint subtitle; gboolean force, burned, def, one_burned = FALSE; @@ -4568,7 +4567,7 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, int titleindex) count = ghb_array_len(subtitle_list); for (ii = 0; ii < count; ii++) { - GValue *ssettings; + GhbValue *ssettings; gint source; ssettings = ghb_array_get_nth(subtitle_list, ii); @@ -4731,7 +4730,7 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, int titleindex) } void -ghb_add_job(GValue *js, gint unique_id) +ghb_add_job(GhbValue *js, gint unique_id) { // Since I'm doing a scan of the single title I want just prior // to adding the job, there is only the one title to choose from. @@ -4739,7 +4738,7 @@ ghb_add_job(GValue *js, gint unique_id) } void -ghb_add_live_job(GValue *js, gint unique_id) +ghb_add_live_job(GhbValue *js, gint unique_id) { int title_id, titleindex; const hb_title_t *title; diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h index fd6e5a641..d2040a3cb 100644 --- a/gtk/src/hb-backend.h +++ b/gtk/src/hb-backend.h @@ -17,6 +17,7 @@ #if !defined(_HBBACKEND_H_) #define _HBBACKEND_H_ +#include "values.h" #include "settings.h" #include "hb.h" #include "lang.h" @@ -87,13 +88,13 @@ float ghb_vquality_default(signal_user_data_t *ud); void ghb_combo_init(signal_user_data_t *ud); void ghb_backend_init(gint debug); void ghb_backend_close(void); -void ghb_add_job(GValue *js, gint unique_id); +void ghb_add_job(GhbValue *js, gint unique_id); void ghb_remove_job(gint unique_id); void ghb_start_queue(void); void ghb_stop_queue(void); void ghb_pause_queue(void); -void ghb_add_live_job(GValue *js, gint unique_id); +void ghb_add_live_job(GhbValue *js, gint unique_id); void ghb_start_live_encode(); void ghb_stop_live_encode(); @@ -111,15 +112,15 @@ void ghb_backend_queue_scan(const gchar *path, gint titleindex); hb_list_t * ghb_get_title_list(); void ghb_par_init(signal_user_data_t *ud); void ghb_set_scale(signal_user_data_t *ud, gint mode); -void ghb_set_scale_settings(GValue *settings, gint mode); +void ghb_set_scale_settings(GhbValue *settings, gint mode); void ghb_picture_settings_deps(signal_user_data_t *ud); -GValue* ghb_get_chapters(const hb_title_t *title); +GhbValue* ghb_get_chapters(const hb_title_t *title); gint64 ghb_get_chapter_duration(const hb_title_t *title, gint chap); gint64 ghb_get_chapter_start(const hb_title_t *title, gint chap); void ghb_part_duration( const hb_title_t *title, gint sc, gint ec, gint *hh, gint *mm, gint *ss); gint ghb_get_best_mix(hb_audio_config_t *aconfig, gint acodec, gint mix); -gboolean ghb_ac3_in_audio_list(const GValue *audio_list); +gboolean ghb_ac3_in_audio_list(const GhbValue *audio_list); gboolean ghb_audio_is_passthru(gint acodec); gboolean ghb_audio_can_passthru(gint acodec); gint ghb_get_default_acodec(void); @@ -135,25 +136,25 @@ void ghb_add_all_subtitles(signal_user_data_t *ud, gint titleindex); gint ghb_find_subtitle_track(const hb_title_t * title, const gchar * lang, int start); gint ghb_pick_subtitle_track(signal_user_data_t *ud); gint ghb_longest_title(void); -gchar* ghb_build_advanced_opts_string(GValue *settings); +gchar* ghb_build_advanced_opts_string(GhbValue *settings); GdkPixbuf* ghb_get_preview_image( const hb_title_t *title, gint index, signal_user_data_t *ud, gint *out_width, gint *out_height); gchar* ghb_dvd_volname(const gchar *device); -gint ghb_subtitle_track_source(GValue *settings, gint track); -const gchar* ghb_subtitle_track_lang(GValue *settings, gint track); - -gboolean ghb_validate_vquality(GValue *settings); -gboolean ghb_validate_audio(GValue *settings, GtkWindow *parent); -gboolean ghb_validate_subtitles(GValue *settings, GtkWindow *parent); -gboolean ghb_validate_video(GValue *settings, GtkWindow *parent); -gboolean ghb_validate_filters(GValue *settings, GtkWindow *parent); +gint ghb_subtitle_track_source(GhbValue *settings, gint track); +const gchar* ghb_subtitle_track_lang(GhbValue *settings, gint track); + +gboolean ghb_validate_vquality(GhbValue *settings); +gboolean ghb_validate_audio(GhbValue *settings, GtkWindow *parent); +gboolean ghb_validate_subtitles(GhbValue *settings, GtkWindow *parent); +gboolean ghb_validate_video(GhbValue *settings, GtkWindow *parent); +gboolean ghb_validate_filters(GhbValue *settings, GtkWindow *parent); gboolean ghb_validate_filter_string(const gchar *str, gint max_fields); void ghb_hb_cleanup(gboolean partial); -gint ghb_lookup_combo_int(const gchar *name, const GValue *gval); -gdouble ghb_lookup_combo_double(const gchar *name, const GValue *gval); -const gchar* ghb_lookup_combo_option(const gchar *name, const GValue *gval); -const gchar* ghb_lookup_combo_string(const gchar *name, const GValue *gval); +gint ghb_lookup_combo_int(const gchar *name, const GhbValue *gval); +gdouble ghb_lookup_combo_double(const gchar *name, const GhbValue *gval); +const gchar* ghb_lookup_combo_option(const gchar *name, const GhbValue *gval); +const gchar* ghb_lookup_combo_string(const gchar *name, const GhbValue *gval); gchar* ghb_get_tmp_dir(); gint ghb_find_closest_audio_samplerate(gint rate); @@ -167,7 +168,7 @@ void ghb_mix_opts_set(GtkComboBox *combo); void ghb_mix_opts_filter(GtkComboBox *combo, gint acodec); void ghb_audio_samplerate_opts_set(GtkComboBox *combo); -int ghb_lookup_audio_lang(const GValue *glang); +int ghb_lookup_audio_lang(const GhbValue *glang); const iso639_lang_t* ghb_iso639_lookup_by_int(int idx); void ghb_update_display_aspect_label(signal_user_data_t *ud); gchar* ghb_create_title_label(const hb_title_t *title); @@ -177,36 +178,36 @@ const hb_title_t* ghb_lookup_title(int title_id, int *index); const hb_container_t* ghb_lookup_container_by_name(const gchar *name); const hb_encoder_t* ghb_lookup_audio_encoder(const char *name); int ghb_lookup_audio_encoder_codec(const char *name); -int ghb_settings_audio_encoder_codec(const GValue *settings, const char *name); +int ghb_settings_audio_encoder_codec(const GhbValue *settings, const char *name); const hb_encoder_t* ghb_settings_audio_encoder( - const GValue *settings, const char *name); + const GhbValue *settings, const char *name); const hb_encoder_t* ghb_lookup_video_encoder(const char *name); int ghb_lookup_video_encoder_codec(const char *name); -int ghb_settings_video_encoder_codec(const GValue *settings, const char *name); +int ghb_settings_video_encoder_codec(const GhbValue *settings, const char *name); const hb_encoder_t* ghb_settings_video_encoder( - const GValue *settings, const char *name); + const GhbValue *settings, const char *name); const hb_mixdown_t* ghb_lookup_mixdown(const char *name); int ghb_lookup_mixdown_mix(const char *name); -int ghb_settings_mixdown_mix(const GValue *settings, const char *name); +int ghb_settings_mixdown_mix(const GhbValue *settings, const char *name); const hb_mixdown_t* ghb_settings_mixdown( - const GValue *settings, const char *name); + const GhbValue *settings, const char *name); const hb_rate_t* ghb_lookup_video_framerate(const char *name); int ghb_lookup_video_framerate_rate(const char *name); -int ghb_settings_video_framerate_rate(const GValue *settings, const char *name); +int ghb_settings_video_framerate_rate(const GhbValue *settings, const char *name); const hb_rate_t* ghb_settings_video_framerate( - const GValue *settings, const char *name); + const GhbValue *settings, const char *name); const hb_rate_t* ghb_lookup_audio_samplerate(const char *name); int ghb_lookup_audio_samplerate_rate(const char *name); int ghb_settings_audio_samplerate_rate( - const GValue *settings, const char *name); + const GhbValue *settings, const char *name); const hb_rate_t* ghb_settings_audio_samplerate( - const GValue *settings, const char *name); + const GhbValue *settings, const char *name); const char* ghb_audio_samplerate_get_short_name(int rate); const hb_rate_t* ghb_lookup_audio_bitrate(const char *name); int ghb_lookup_audio_bitrate_rate(const char *name); -int ghb_settings_audio_bitrate_rate(const GValue *settings, const char *name); +int ghb_settings_audio_bitrate_rate(const GhbValue *settings, const char *name); const hb_rate_t* ghb_settings_audio_bitrate( - const GValue *settings, const char *name); + const GhbValue *settings, const char *name); const char* ghb_audio_bitrate_get_short_name(int rate); hb_audio_config_t* ghb_get_audio_info(const hb_title_t *title, gint track); hb_subtitle_t* ghb_get_subtitle_info(const hb_title_t *title, gint track); diff --git a/gtk/src/icons.c b/gtk/src/icons.c index aef0b056d..5c22527ad 100644 --- a/gtk/src/icons.c +++ b/gtk/src/icons.c @@ -5,23 +5,22 @@ void ghb_load_icons() { - GHashTableIter iter; - gchar *key; - GValue *gval; + GhbDictIter iter; + const gchar *key; + GhbValue *gval; - GValue *icons = ghb_resource_get("icons"); - ghb_dict_iter_init(&iter, icons); - // middle (void*) cast prevents gcc warning "defreferencing type-punned - // pointer will break strict-aliasing rules" - while (g_hash_table_iter_next( - &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval)) + GhbValue *icons = ghb_resource_get("icons"); + ghb_dict_iter_init(icons, &iter); + while (ghb_dict_iter_next(icons, &iter, &key, &gval)) { - ghb_rawdata_t *rd; gint size; GdkPixbuf *pb; gboolean svg; char *name = g_strdup(key); char *pos; + const char *base64; + guint8 *data; + gsize data_size; pos = g_strstr_len(name, -1, "."); if (pos != NULL) @@ -29,14 +28,15 @@ ghb_load_icons() GInputStream *gis; svg = ghb_value_boolean(ghb_dict_lookup(gval, "svg")); - rd = g_value_get_boxed(ghb_dict_lookup(gval, "data")); + base64 = ghb_value_const_string(ghb_dict_lookup(gval, "data")); + data = g_base64_decode(base64, &data_size); if (svg) { int ii; int sizes[] = {16, 22, 24, 32, 48, 64, 128, 256, 0}; for (ii = 0; sizes[ii]; ii++) { - gis = g_memory_input_stream_new_from_data(rd->data, rd->size, + gis = g_memory_input_stream_new_from_data(data, data_size, NULL); pb = gdk_pixbuf_new_from_stream_at_scale(gis, sizes[ii], sizes[ii], @@ -49,7 +49,7 @@ ghb_load_icons() } else { - gis = g_memory_input_stream_new_from_data(rd->data, rd->size, NULL); + gis = g_memory_input_stream_new_from_data(data, data_size, NULL); pb = gdk_pixbuf_new_from_stream(gis, NULL, NULL); g_input_stream_close(gis, NULL, NULL); size = gdk_pixbuf_get_height(pb); diff --git a/gtk/src/ini_to_plist.c b/gtk/src/ini_to_plist.c deleted file mode 100644 index fd20323b3..000000000 --- a/gtk/src/ini_to_plist.c +++ /dev/null @@ -1,104 +0,0 @@ -#include <glib.h> -#include <glib-object.h> -#include <glib/gstdio.h> -#include <string.h> -#include "values.h" -#include "plist.h" - -gboolean -string_is_true(const gchar *str) -{ - return (strcmp(str, "enable") == 0); -} - -gboolean -string_is_bool(const gchar *str) -{ - return (strcmp(str, "enable") == 0) || (strcmp(str, "disable") == 0); -} - -GType -guess_type(const gchar *str) -{ - gchar *end; - gdouble dval; - - if (*str == 0) - return G_TYPE_STRING; - if (string_is_bool(str)) - return G_TYPE_BOOLEAN; - dval = g_strtod(str, &end); - if (*end == 0) - { - if (strchr(str, '.') == NULL) - return G_TYPE_INT64; - else - return G_TYPE_DOUBLE; - } - - return G_TYPE_STRING; -} - -void -set_value(GValue *gval, const gchar *str, GType gtype) -{ - if (gtype == G_TYPE_STRING) - { - g_value_set_string(gval, str); - } - else if (gtype == G_TYPE_INT64) - { - gint64 val = g_strtod(str, NULL); - g_value_set_int64(gval, val); - } - else if (gtype == G_TYPE_DOUBLE) - { - gdouble val = g_strtod(str, NULL); - g_value_set_double(gval, val); - } - else if (gtype == G_TYPE_BOOLEAN) - { - if (string_is_true(str)) - g_value_set_boolean(gval, TRUE); - else - g_value_set_boolean(gval, FALSE); - } -} - -int -main(gint argc, gchar *argv[]) -{ - GKeyFile *kf; - gchar **groups; - gchar **keys; - gint ii, jj; - GValue *top; - GValue *dict; - - g_type_init(); - top = ghb_dict_value_new(); - kf = g_key_file_new(); - g_key_file_load_from_file(kf, argv[1], 0, NULL); - groups = g_key_file_get_groups(kf, NULL); - for (ii = 0; groups[ii]; ii++) - { - dict = ghb_dict_value_new(); - ghb_dict_insert(top, , g_strdup(groups[ii]), dict); - keys = g_key_file_get_keys(kf, groups[ii], NULL, NULL); - for (jj = 0; keys[jj]; jj++) - { - gchar *str; - GValue *gval; - GType gtype; - - str = g_key_file_get_string(kf, groups[ii], keys[jj], NULL); - gtype = guess_type(str); - gval = g_malloc0(sizeof(GValue)); - g_value_init(gval, gtype); - set_value(gval, str, gtype); - ghb_dict_insert(dict, g_strdup(keys[jj]), gval); - } - } - ghb_plist_write_file("a_p_list", top); -} - diff --git a/gtk/src/main.c b/gtk/src/main.c index 92f770015..ad4be4561 100644 --- a/gtk/src/main.c +++ b/gtk/src/main.c @@ -89,7 +89,7 @@ GtkBuilder* create_builder_or_die(const gchar * name) { guint res = 0; - GValue *gval; + GhbValue *gval; GError *error = NULL; const gchar *ghb_ui; @@ -101,7 +101,7 @@ create_builder_or_die(const gchar * name) g_debug("create_builder_or_die()\n"); GtkBuilder *xml = gtk_builder_new(); gval = ghb_resource_get("ghb-ui"); - ghb_ui = g_value_get_string(gval); + ghb_ui = ghb_value_const_string(gval); if (xml != NULL) res = gtk_builder_add_from_string(xml, ghb_ui, -1, &error); if (!xml || !res) @@ -782,7 +782,7 @@ int main(int argc, char *argv[]) { signal_user_data_t *ud; - GValue *preset; + GhbValue *preset; GError *error = NULL; GOptionContext *context; @@ -833,7 +833,6 @@ main(int argc, char *argv[]) #if !defined(_WIN32) notify_init("HandBrake"); #endif - ghb_register_transforms(); ghb_resource_init(); ghb_load_icons(); @@ -1033,7 +1032,7 @@ main(int argc, char *argv[]) } else { - GValue *gval = ghb_settings_get_value(ud->prefs, "default_source"); + GhbValue *gval = ghb_settings_get_value(ud->prefs, "default_source"); ghb_settings_set_value(ud->globals, "scan_source", gval); } // Reload and check status of the last saved queue diff --git a/gtk/src/makedeps.py b/gtk/src/makedeps.py index a98b50ba4..910f787d3 100644 --- a/gtk/src/makedeps.py +++ b/gtk/src/makedeps.py @@ -17,23 +17,23 @@ dep_map = ( DepEntry("title", "end_point", "none", True, False), DepEntry("title", "angle", "none", True, False), DepEntry("title", "angle_label", "1", True, False), - DepEntry("use_dvdnav", "angle", "FALSE", True, True), - DepEntry("use_dvdnav", "angle_label", "FALSE", True, True), + DepEntry("use_dvdnav", "angle", "0", True, True), + DepEntry("use_dvdnav", "angle_label", "0", True, True), DepEntry("angle_count", "angle", "1", True, True), DepEntry("angle_count", "angle_label", "1", True, True), - DepEntry("vquality_type_bitrate", "VideoAvgBitrate", "TRUE", False, False), - DepEntry("vquality_type_constant", "VideoQualitySlider", "TRUE", False, False), - DepEntry("vquality_type_constant", "VideoTwoPass", "TRUE", True, False), - DepEntry("vquality_type_constant", "VideoTurboTwoPass", "TRUE", True, False), + DepEntry("vquality_type_bitrate", "VideoAvgBitrate", "1", False, False), + DepEntry("vquality_type_constant", "VideoQualitySlider", "1", False, False), + DepEntry("vquality_type_constant", "VideoTwoPass", "1", True, False), + DepEntry("vquality_type_constant", "VideoTurboTwoPass", "1", True, False), DepEntry("VideoFramerate", "VideoFrameratePFR", "source", True, True), DepEntry("VideoFramerate", "VideoFramerateVFR", "source", False, True), - DepEntry("VideoTwoPass", "VideoTurboTwoPass", "TRUE", False, False), - DepEntry("PictureDecombDeinterlace", "PictureDeinterlace", "TRUE", True, True), - DepEntry("PictureDecombDeinterlace", "PictureDeinterlaceCustom", "TRUE", True, True), - DepEntry("PictureDecombDeinterlace", "PictureDeinterlaceLabel", "TRUE", True, True), - DepEntry("PictureDecombDeinterlace", "PictureDecomb", "FALSE", True, True), - DepEntry("PictureDecombDeinterlace", "PictureDecombCustom", "FALSE", True, True), - DepEntry("PictureDecombDeinterlace", "PictureDecombLabel", "FALSE", True, True), + DepEntry("VideoTwoPass", "VideoTurboTwoPass", "1", False, False), + DepEntry("PictureDecombDeinterlace", "PictureDeinterlace", "1", True, True), + DepEntry("PictureDecombDeinterlace", "PictureDeinterlaceCustom", "1", True, True), + DepEntry("PictureDecombDeinterlace", "PictureDeinterlaceLabel", "1", True, True), + DepEntry("PictureDecombDeinterlace", "PictureDecomb", "0", True, True), + DepEntry("PictureDecombDeinterlace", "PictureDecombCustom", "0", True, True), + DepEntry("PictureDecombDeinterlace", "PictureDecombLabel", "0", True, True), DepEntry("PictureDeinterlace", "PictureDeinterlaceCustom", "custom", False, True), DepEntry("PictureDenoiseFilter", "PictureDenoisePreset", "off", True, True), DepEntry("PictureDenoiseFilter", "PictureDenoisePresetLabel", "off", True, True), @@ -45,14 +45,14 @@ dep_map = ( DepEntry("PictureDenoisePreset", "PictureDenoiseTuneLabel", "custom", True, True), DepEntry("PictureDecomb", "PictureDecombCustom", "custom", False, True), DepEntry("PictureDetelecine", "PictureDetelecineCustom", "custom", False, True), - DepEntry("PictureWidthEnable", "PictureWidth", "TRUE", False, False), - DepEntry("PictureHeightEnable", "PictureHeight", "TRUE", False, False), - DepEntry("PictureAutoCrop", "PictureTopCrop", "FALSE", False, False), - DepEntry("PictureAutoCrop", "PictureBottomCrop", "FALSE", False, False), - DepEntry("PictureAutoCrop", "PictureLeftCrop", "FALSE", False, False), - DepEntry("PictureAutoCrop", "PictureRightCrop", "FALSE", False, False), - DepEntry("AudioTrackQualityEnable", "AudioBitrate", "TRUE", True, True), - DepEntry("AudioTrackQualityEnable", "AudioTrackQualityBox", "FALSE", True, True), + DepEntry("PictureWidthEnable", "PictureWidth", "1", False, False), + DepEntry("PictureHeightEnable", "PictureHeight", "1", False, False), + DepEntry("PictureAutoCrop", "PictureTopCrop", "0", False, False), + DepEntry("PictureAutoCrop", "PictureBottomCrop", "0", False, False), + DepEntry("PictureAutoCrop", "PictureLeftCrop", "0", False, False), + DepEntry("PictureAutoCrop", "PictureRightCrop", "0", False, False), + DepEntry("AudioTrackQualityEnable", "AudioBitrate", "1", True, True), + DepEntry("AudioTrackQualityEnable", "AudioTrackQualityBox", "0", True, True), DepEntry("AudioEncoder", "AudioBitrateLabel", "copy:mp3|copy:aac|copy:ac3|copy:dts|copy:dtshd", True, False), DepEntry("AudioEncoder", "AudioBitrate", "copy:mp3|copy:aac|copy:ac3|copy:dts|copy:dtshd", True, False), DepEntry("AudioEncoder", "AudioSamplerateLabel", "copy:mp3|copy:aac|copy:ac3|copy:dts|copy:dtshd", True, False), @@ -78,13 +78,13 @@ dep_map = ( DepEntry("VideoEncoder", "VideoLevelLabel", "x264|x265", False, True), DepEntry("VideoEncoder", "x264FastDecode", "x264", False, True), DepEntry("VideoEncoder", "x264UseAdvancedOptions", "x264", False, True), - DepEntry("HideAdvancedVideoSettings", "x264UseAdvancedOptions", "TRUE", True, True), + DepEntry("HideAdvancedVideoSettings", "x264UseAdvancedOptions", "1", True, True), DepEntry("VideoEncoder", "VideoOptionExtraWindow", "x264|x265|mpeg4|mpeg2|VP8", False, True), DepEntry("VideoEncoder", "VideoOptionExtraLabel", "x264|x265|mpeg4|mpeg2|VP8", False, True), - DepEntry("x264UseAdvancedOptions", "VideoSettingsTable", "TRUE", True, False), + DepEntry("x264UseAdvancedOptions", "VideoSettingsTable", "1", True, False), DepEntry("VideoEncoder", "x264_box", "x264", False, True), - DepEntry("x264UseAdvancedOptions", "x264_box", "FALSE", True, False), - DepEntry("auto_name", "autoname_box", "TRUE", False, False), + DepEntry("x264UseAdvancedOptions", "x264_box", "0", True, False), + DepEntry("auto_name", "autoname_box", "1", False, False), ) def main(): diff --git a/gtk/src/plist.c b/gtk/src/plist.c index 9581b771f..a2429864f 100644 --- a/gtk/src/plist.c +++ b/gtk/src/plist.c @@ -2,12 +2,13 @@ #include <stdlib.h> #include <fcntl.h> #include <string.h> +#include <inttypes.h> #include <glib.h> #include <glib/gstdio.h> #include <glib-object.h> -#include "plist.h" #include "values.h" +#include "plist.h" #define BUF_SZ (128*1024) @@ -60,7 +61,7 @@ typedef struct { gchar *key; gchar *value; - GValue *plist; + GhbValue *plist; GQueue *stack; GQueue *tag_stack; gboolean closed_top; @@ -102,9 +103,9 @@ start_element( return; } g_queue_push_head(pd->tag_stack, id.pid); - GType gtype = 0; - GValue *gval = NULL; - GValue *current = g_queue_peek_head(pd->stack); + GhbType gtype = 0; + GhbValue *gval = NULL; + GhbValue *current = g_queue_peek_head(pd->stack); switch (id.id) { case P_PLIST: @@ -155,12 +156,12 @@ start_element( pd->plist = gval; return; } - gtype = G_VALUE_TYPE(current); - if (gtype == ghb_array_get_type()) + gtype = ghb_value_type(current); + if (gtype == GHB_ARRAY) { ghb_array_append(current, gval); } - else if (gtype == ghb_dict_get_type()) + else if (gtype == GHB_DICT) { if (pd->key == NULL) { @@ -169,7 +170,7 @@ start_element( } else { - ghb_dict_insert(current, g_strdup(pd->key), gval); + ghb_dict_insert(current, pd->key, gval); } } else @@ -217,9 +218,9 @@ end_element( if (start_id.id != id) g_warning("start tag != end tag: (%s %d) %d", name, id, id); - GValue *gval = NULL; - GValue *current = g_queue_peek_head(pd->stack); - GType gtype = 0; + GhbValue *gval = NULL; + GhbValue *current = g_queue_peek_head(pd->stack); + GhbType gtype = 0; switch (id) { case P_PLIST: @@ -253,14 +254,6 @@ end_element( { gval = ghb_string_value_new(pd->value); } break; - case P_DATE: - { - GDate date; - GTimeVal time; - g_time_val_from_iso8601(pd->value, &time); - g_date_set_time_val(&date, &time); - gval = ghb_date_value_new(&date); - } break; case P_TRUE: { gval = ghb_boolean_value_new(TRUE); @@ -269,12 +262,9 @@ end_element( { gval = ghb_boolean_value_new(FALSE); } break; - case P_DATA: + default: { - ghb_rawdata_t *data; - data = g_malloc(sizeof(ghb_rawdata_t)); - data->data = g_base64_decode(pd->value, &(data->size)); - gval = ghb_rawdata_value_new(data); + g_message("Unhandled plist type %d", id); } break; } if (gval) @@ -287,12 +277,12 @@ end_element( pd->closed_top = TRUE; return; } - gtype = G_VALUE_TYPE(current); - if (gtype == ghb_array_get_type()) + gtype = ghb_value_type(current); + if (gtype == GHB_ARRAY) { ghb_array_append(current, gval); } - else if (gtype == ghb_dict_get_type()) + else if (gtype == GHB_DICT) { if (pd->key == NULL) { @@ -301,7 +291,7 @@ end_element( } else { - ghb_dict_insert(current, g_strdup(pd->key), gval); + ghb_dict_insert(current, pd->key, gval); } } else @@ -352,7 +342,7 @@ destroy_notify(gpointer data) //g_debug("destroy parser"); } -GValue* +GhbValue* ghb_plist_parse(const gchar *buf, gssize len) { GMarkupParseContext *ctx; @@ -384,12 +374,12 @@ ghb_plist_parse(const gchar *buf, gssize len) return pd.plist; } -GValue* +GhbValue* ghb_plist_parse_file(const gchar *filename) { gchar *buffer; size_t size; - GValue *gval; + GhbValue *gval; FILE *fd; fd = g_fopen(filename, "r"); @@ -422,28 +412,18 @@ indent_fprintf(FILE *file, gint indent, const gchar *fmt, ...) va_end(ap); } -// Used for sorting dictionaries. -static gint -key_cmp(gconstpointer a, gconstpointer b) -{ - gchar *stra = (gchar*)a; - gchar *strb = (gchar*)b; - - return strcmp(stra, strb); -} - static void -gval_write(FILE *file, GValue *gval) +gval_write(FILE *file, GhbValue *gval) { static gint indent = 0; gint ii; - GType gtype; + GhbType gtype; if (gval == NULL) return; - gtype = G_VALUE_TYPE(gval); - if (gtype == ghb_array_get_type()) + gtype = ghb_value_type(gval); + if (gtype == GHB_ARRAY) { - GValue *val; + GhbValue *val; gint count; indent_fprintf(file, indent, "<array>\n"); @@ -457,34 +437,29 @@ gval_write(FILE *file, GValue *gval) indent--; indent_fprintf(file, indent, "</array>\n"); } - else if (gtype == ghb_dict_get_type()) + else if (gtype == GHB_DICT) { - GValue *val; - GHashTable *dict = g_value_get_boxed(gval); - GList *link, *keys; - keys = g_hash_table_get_keys(dict); - // Sort the dictionary. Not really necessray, but it makes - // finding things easier - keys = g_list_sort(keys, key_cmp); - link = keys; + const char *key; + GhbValue *val; + GhbDictIter iter; + indent_fprintf(file, indent, "<dict>\n"); indent++; - while (link) + + ghb_dict_iter_init(gval, &iter); + while (ghb_dict_iter_next(gval, &iter, &key, &val)) { - gchar *key = (gchar*)link->data; - val = g_hash_table_lookup(dict, key); indent_fprintf(file, indent, "<key>%s</key>\n", key); gval_write(file, val); - link = link->next; } + indent--; indent_fprintf(file, indent, "</dict>\n"); - g_list_free(keys); } - else if (gtype == G_TYPE_BOOLEAN) + else if (gtype == GHB_BOOL) { gchar *tag; - if (g_value_get_boolean(gval)) + if (ghb_value_boolean(gval)) { tag = "true"; } @@ -494,45 +469,19 @@ gval_write(FILE *file, GValue *gval) } indent_fprintf(file, indent, "<%s />\n", tag); } - else if (gtype == g_date_get_type()) - { - GDate *date; - date = g_value_get_boxed(gval); - indent_fprintf(file, indent, "<date>%d-%d-%d</date>\n", - g_date_get_year(date), - g_date_get_month(date), - g_date_get_day(date) - ); - } - else if (gtype == ghb_rawdata_get_type()) + else if (gtype == GHB_DOUBLE) { - ghb_rawdata_t *data; - gchar *base64; - data = g_value_get_boxed(gval); - base64 = g_base64_encode(data->data, data->size); - indent_fprintf(file, indent, "<data>\n"); - indent_fprintf(file, 0, "%s\n", base64); - indent_fprintf(file, indent, "</data>\n"); - g_free(base64); - } - else if (gtype == G_TYPE_DOUBLE) - { - gdouble val = g_value_get_double(gval); + gdouble val = ghb_value_double(gval); indent_fprintf(file, indent, "<real>%.17g</real>\n", val); } - else if (gtype == G_TYPE_INT64) + else if (gtype == GHB_INT) { - gint val = g_value_get_int64(gval); - indent_fprintf(file, indent, "<integer>%d</integer>\n", val); + gint64 val = ghb_value_int64(gval); + indent_fprintf(file, indent, "<integer>%"PRId64"</integer>\n", val); } - else if (gtype == G_TYPE_INT) + else if (gtype == GHB_STRING) { - gint val = g_value_get_int(gval); - indent_fprintf(file, indent, "<integer>%d</integer>\n", val); - } - else if (gtype == G_TYPE_STRING) - { - const gchar *str = g_value_get_string(gval); + const gchar *str = ghb_value_string(gval); gchar *esc = g_markup_escape_text(str, -1); indent_fprintf(file, indent, "<string>%s</string>\n", esc); g_free(esc); @@ -540,26 +489,12 @@ gval_write(FILE *file, GValue *gval) else { // Try to make anything thats unrecognized into a string - const gchar *str; - GValue val = {0,}; - g_value_init(&val, G_TYPE_STRING); - if (g_value_transform(gval, &val)) - { - str = g_value_get_string(&val); - gchar *esc = g_markup_escape_text(str, -1); - indent_fprintf(file, indent, "<string>%s</string>\n", esc); - g_free(esc); - } - else - { - g_message("failed to transform"); - } - g_value_unset(&val); + g_warning("Unhandled data type %d", gtype); } } void -ghb_plist_write(FILE *file, GValue *gval) +ghb_plist_write(FILE *file, GhbValue *gval) { fprintf(file, "%s", preamble); gval_write(file, gval); @@ -567,7 +502,7 @@ ghb_plist_write(FILE *file, GValue *gval) } void -ghb_plist_write_file(const gchar *filename, GValue *gval) +ghb_plist_write_file(const gchar *filename, GhbValue *gval) { FILE *file; @@ -585,7 +520,7 @@ ghb_plist_write_file(const gchar *filename, GValue *gval) gint main(gint argc, gchar *argv[]) { - GValue *gval; + GhbValue *gval; g_type_init(); diff --git a/gtk/src/plist.h b/gtk/src/plist.h index 8b2498826..1587c89ac 100644 --- a/gtk/src/plist.h +++ b/gtk/src/plist.h @@ -4,11 +4,12 @@ #include <stdio.h> #include <glib.h> #include <glib-object.h> +#include "values.h" -GValue* ghb_plist_parse(const gchar *buf, gssize len); -GValue* ghb_plist_parse_file(const gchar *filename); -void ghb_plist_write(FILE *file, GValue *gval); -void ghb_plist_write_file(const gchar *filename, GValue *gval); +GhbValue* ghb_plist_parse(const gchar *buf, gssize len); +GhbValue* ghb_plist_parse_file(const gchar *filename); +void ghb_plist_write(FILE *file, GhbValue *gval); +void ghb_plist_write_file(const gchar *filename, GhbValue *gval); #endif // _PLIST_H_ diff --git a/gtk/src/presets.c b/gtk/src/presets.c index 3d0c12c99..82199c0ec 100644 --- a/gtk/src/presets.c +++ b/gtk/src/presets.c @@ -42,30 +42,27 @@ enum PRESETS_CUSTOM }; -static GValue *presetsPlistFile = NULL; -static GValue *presetsPlist = NULL; -static GValue *prefsPlist = NULL; +static GhbValue *presetsPlistFile = NULL; +static GhbValue *presetsPlist = NULL; +static GhbValue *prefsPlist = NULL; static gboolean prefs_modified = FALSE; -static const GValue* preset_dict_get_value(GValue *dict, const gchar *key); -static void store_plist(GValue *plist, const gchar *name); +static const GhbValue* preset_dict_get_value(GhbValue *dict, const gchar *key); +static void store_plist(GhbValue *plist, const gchar *name); static void store_presets(void); static void store_prefs(void); static void -dict_clean(GValue *dict, GValue *template) +dict_clean(GhbValue *dict, GhbValue *template) { - GValue *tmp = ghb_value_dup(dict); - GHashTableIter iter; - gchar *key; - GValue *value; - GValue *template_val; + GhbValue *tmp = ghb_value_dup(dict); + GhbDictIter iter; + const gchar *key; + GhbValue *value; + GhbValue *template_val; - ghb_dict_iter_init(&iter, tmp); - // middle (void*) cast prevents gcc warning "defreferencing type-punned - // pointer will break strict-aliasing rules" - while (g_hash_table_iter_next( - &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&value)) + ghb_dict_iter_init(tmp, &iter); + while (ghb_dict_iter_next(tmp, &iter, &key, &value)) { template_val = ghb_dict_lookup(template, key); if (template_val == NULL) @@ -114,11 +111,11 @@ ghb_tree_path_new_from_indices(gint *indices, gint len) } } -GValue* +GhbValue* ghb_parse_preset_path(const gchar *path) { gchar **split; - GValue *preset; + GhbValue *preset; gint ii; preset = ghb_array_value_new(MAX_NESTED_PRESET); @@ -131,19 +128,19 @@ ghb_parse_preset_path(const gchar *path) return preset; } -static GValue* -preset_path_from_indices(GValue *presets, gint *indices, gint len) +static GhbValue* +preset_path_from_indices(GhbValue *presets, gint *indices, gint len) { gint ii; - GValue *path; + GhbValue *path; g_debug("preset_path_from_indices"); path = ghb_array_value_new(MAX_NESTED_PRESET); for (ii = 0; ii < len; ii++) { - GValue *dict; + GhbValue *dict; gint count, folder; - const GValue *name; + const GhbValue *name; count = ghb_array_len(presets); if (indices[ii] >= count) break; @@ -160,11 +157,11 @@ preset_path_from_indices(GValue *presets, gint *indices, gint len) } gchar* -ghb_preset_path_string(const GValue *path) +ghb_preset_path_string(const GhbValue *path) { gint count, ii; GString *gstr; - GValue *val; + GhbValue *val; gchar *str; gstr = g_string_new(""); @@ -186,12 +183,12 @@ ghb_preset_path_string(const GValue *path) } void -dump_preset_path(const gchar *msg, const GValue *path) +dump_preset_path(const gchar *msg, const GhbValue *path) { gchar *str; if (path) - debug_show_type (G_VALUE_TYPE(path)); + debug_show_type (ghb_value_type(path)); str = ghb_preset_path_string(path); g_message("%s path: (%s)", msg, str); g_free(str); @@ -212,10 +209,10 @@ dump_preset_indices(const gchar *msg, gint *indices, gint len) #if 0 static gint -preset_path_cmp(const GValue *path1, const GValue *path2) +preset_path_cmp(const GhbValue *path1, const GhbValue *path2) { gint count, ii; - GValue *val; + GhbValue *val; gchar *str1, *str2; gint result; @@ -239,11 +236,11 @@ preset_path_cmp(const GValue *path1, const GValue *path2) } #endif -static GValue* -presets_get_dict(GValue *presets, gint *indices, gint len) +static GhbValue* +presets_get_dict(GhbValue *presets, gint *indices, gint len) { gint ii, count, folder; - GValue *dict = NULL; + GhbValue *dict = NULL; g_debug("presets_get_dict ()"); for (ii = 0; ii < len; ii++) @@ -264,11 +261,11 @@ presets_get_dict(GValue *presets, gint *indices, gint len) return dict; } -static GValue* -presets_get_folder(GValue *presets, gint *indices, gint len) +static GhbValue* +presets_get_folder(GhbValue *presets, gint *indices, gint len) { gint ii, count, folder; - GValue *dict; + GhbValue *dict; g_debug("presets_get_folder ()"); for (ii = 0; ii < len; ii++) @@ -286,46 +283,46 @@ presets_get_folder(GValue *presets, gint *indices, gint len) return presets; } -static GValue* -plist_get_dict(GValue *presets, const gchar *name) +static GhbValue* +plist_get_dict(GhbValue *presets, const gchar *name) { if (presets == NULL || name == NULL) return NULL; return ghb_dict_lookup(presets, name); } static const gchar* -preset_get_name(GValue *dict) +preset_get_name(GhbValue *dict) { - return g_value_get_string(preset_dict_get_value(dict, "PresetName")); + return ghb_value_const_string(preset_dict_get_value(dict, "PresetName")); } static gboolean -preset_folder_is_open(GValue *dict) +preset_folder_is_open(GhbValue *dict) { - const GValue *gval; + const GhbValue *gval; gval = preset_dict_get_value(dict, "FolderOpen"); if (gval != NULL) - return g_value_get_boolean(gval); + return ghb_value_boolean(gval); return FALSE; } gboolean -ghb_preset_folder(GValue *dict) +ghb_preset_folder(GhbValue *dict) { return ghb_value_int(preset_dict_get_value(dict, "Folder")); } gint -ghb_preset_type(GValue *dict) +ghb_preset_type(GhbValue *dict) { return ghb_value_int(preset_dict_get_value(dict, "Type")); } static void -presets_remove_nth(GValue *presets, gint pos) +presets_remove_nth(GhbValue *presets, gint pos) { - GValue *dict; + GhbValue *dict; gint count; if (presets == NULL || pos < 0) return; @@ -338,11 +335,11 @@ presets_remove_nth(GValue *presets, gint pos) gboolean ghb_presets_remove( - GValue *presets, + GhbValue *presets, gint *indices, gint len) { - GValue *folder = NULL; + GhbValue *folder = NULL; folder = presets_get_folder(presets, indices, len-1); if (folder) @@ -357,12 +354,12 @@ ghb_presets_remove( static void ghb_presets_replace( - GValue *presets, - GValue *dict, + GhbValue *presets, + GhbValue *dict, gint *indices, gint len) { - GValue *folder = NULL; + GhbValue *folder = NULL; folder = presets_get_folder(presets, indices, len-1); if (folder) @@ -375,12 +372,12 @@ ghb_presets_replace( static void ghb_presets_insert( - GValue *presets, - GValue *dict, + GhbValue *presets, + GhbValue *dict, gint *indices, gint len) { - GValue *folder = NULL; + GhbValue *folder = NULL; folder = presets_get_folder(presets, indices, len-1); if (folder) @@ -392,9 +389,9 @@ ghb_presets_insert( } static gint -presets_find_element(GValue *presets, const gchar *name) +presets_find_element(GhbValue *presets, const gchar *name) { - GValue *dict; + GhbValue *dict; gint count, ii; g_debug("presets_find_element () (%s)", name); @@ -414,9 +411,9 @@ presets_find_element(GValue *presets, const gchar *name) } static gint -single_find_pos(GValue *presets, const gchar *name, gint type) +single_find_pos(GhbValue *presets, const gchar *name, gint type) { - GValue *dict; + GhbValue *dict; gint count, ii, ptype, last; if (presets == NULL || name == NULL) return -1; @@ -438,15 +435,15 @@ single_find_pos(GValue *presets, const gchar *name, gint type) } static gint* -presets_find_pos(const GValue *path, gint type, gint *len) +presets_find_pos(const GhbValue *path, gint type, gint *len) { - GValue *nested; - GValue *val; + GhbValue *nested; + GhbValue *val; gint count, ii; gboolean folder; gint *indices = NULL; const gchar *name; - GValue *dict; + GhbValue *dict; g_debug("presets_find_pos () "); nested = presetsPlist; @@ -455,7 +452,7 @@ presets_find_pos(const GValue *path, gint type, gint *len) for (ii = 0; ii < count-1; ii++) { val = ghb_array_get_nth(path, ii); - name = g_value_get_string(val); + name = ghb_value_const_string(val); indices[ii] = presets_find_element(nested, name); if (indices[ii] == -1) { g_free(indices); @@ -472,7 +469,7 @@ presets_find_pos(const GValue *path, gint type, gint *len) { const gchar *name; - name = g_value_get_string(ghb_array_get_nth(path, count-1)); + name = ghb_value_const_string(ghb_array_get_nth(path, count-1)); indices[ii] = single_find_pos(nested, name, type); ii++; } @@ -481,7 +478,7 @@ presets_find_pos(const GValue *path, gint type, gint *len) } static gint -preset_tree_depth(GValue *dict) +preset_tree_depth(GhbValue *dict) { gboolean folder; @@ -490,7 +487,7 @@ preset_tree_depth(GValue *dict) { gint depth = 0; gint count, ii; - GValue *presets; + GhbValue *presets; presets = ghb_dict_lookup(dict, "ChildrenArray"); count = ghb_array_len(presets); @@ -511,30 +508,30 @@ preset_tree_depth(GValue *dict) } static gboolean -preset_is_default(GValue *dict) +preset_is_default(GhbValue *dict) { - const GValue *val; + const GhbValue *val; val = preset_dict_get_value(dict, "Default"); return ghb_value_boolean(val); } static void -presets_clear_default(GValue *presets) +presets_clear_default(GhbValue *presets) { gint count, ii; count = ghb_array_len(presets); for (ii = 0; ii < count; ii++) { - GValue *dict; + GhbValue *dict; gboolean folder; dict = ghb_array_get_nth(presets, ii); folder = ghb_value_boolean(preset_dict_get_value(dict, "Folder")); if (folder) { - GValue *nested; + GhbValue *nested; nested = ghb_dict_lookup(dict, "ChildrenArray"); presets_clear_default(nested); @@ -543,22 +540,21 @@ presets_clear_default(GValue *presets) { if (preset_is_default(dict)) { - ghb_dict_insert(dict, g_strdup("Default"), - ghb_boolean_value_new(FALSE)); + ghb_dict_insert(dict, "Default", ghb_boolean_value_new(FALSE)); } } } } static void -presets_customize(GValue *presets) +presets_customize(GhbValue *presets) { gint count, ii; count = ghb_array_len(presets); for (ii = 0; ii < count; ii++) { - GValue *dict; + GhbValue *dict; gboolean folder; gint ptype; @@ -567,13 +563,12 @@ presets_customize(GValue *presets) ptype = ghb_value_int(preset_dict_get_value(dict, "Type")); if (ptype != PRESETS_CUSTOM) { - ghb_dict_insert(dict, g_strdup("Type"), - ghb_int64_value_new(PRESETS_CUSTOM)); + ghb_dict_insert(dict, "Type", ghb_int64_value_new(PRESETS_CUSTOM)); } folder = ghb_value_boolean(preset_dict_get_value(dict, "Folder")); if (folder) { - GValue *nested; + GhbValue *nested; nested = ghb_dict_lookup(dict, "ChildrenArray"); presets_customize(nested); @@ -582,7 +577,7 @@ presets_customize(GValue *presets) } static gint* -presets_find_default2(GValue *presets, gint *len) +presets_find_default2(GhbValue *presets, gint *len) { gint count, ii; gint *indices; @@ -590,14 +585,14 @@ presets_find_default2(GValue *presets, gint *len) count = ghb_array_len(presets); for (ii = 0; ii < count; ii++) { - GValue *dict; + GhbValue *dict; gboolean folder; dict = ghb_array_get_nth(presets, ii); folder = ghb_value_boolean(preset_dict_get_value(dict, "Folder")); if (folder) { - GValue *nested; + GhbValue *nested; gint pos = *len; nested = ghb_dict_lookup(dict, "ChildrenArray"); @@ -626,7 +621,7 @@ presets_find_default2(GValue *presets, gint *len) } static gint* -presets_find_default(GValue *presets, gint *len) +presets_find_default(GhbValue *presets, gint *len) { *len = 0; return presets_find_default2(presets, len); @@ -634,16 +629,16 @@ presets_find_default(GValue *presets, gint *len) gint* ghb_preset_indices_from_path( - GValue *presets, - const GValue *path, + GhbValue *presets, + const GhbValue *path, gint *len) { - GValue *nested; - GValue *val; + GhbValue *nested; + GhbValue *val; gint count, ii; gint *indices = NULL; const gchar *name; - GValue *dict; + GhbValue *dict; gboolean folder; g_debug("ghb_preset_indices_from_path () "); @@ -655,7 +650,7 @@ ghb_preset_indices_from_path( for (ii = 0; ii < count; ii++) { val = ghb_array_get_nth(path, ii); - name = g_value_get_string(val); + name = ghb_value_const_string(val); indices[ii] = presets_find_element(nested, name); if (indices[ii] == -1) { @@ -680,11 +675,11 @@ ghb_preset_indices_from_path( static gint ghb_presets_get_type( - GValue *presets, + GhbValue *presets, gint *indices, gint len) { - GValue *dict; + GhbValue *dict; gint type = 0; dict = presets_get_dict(presets, indices, len); @@ -701,11 +696,11 @@ ghb_presets_get_type( static gboolean ghb_presets_get_folder( - GValue *presets, + GhbValue *presets, gint *indices, gint len) { - GValue *dict; + GhbValue *dict; gboolean folder = FALSE; dict = presets_get_dict(presets, indices, len); @@ -723,14 +718,14 @@ ghb_presets_get_folder( void presets_set_default(gint *indices, gint len) { - GValue *dict; + GhbValue *dict; g_debug("presets_set_default ()"); presets_clear_default(presetsPlist); dict = presets_get_dict(presetsPlist, indices, len); if (dict) { - ghb_dict_insert(dict, g_strdup("Default"), ghb_boolean_value_new(TRUE)); + ghb_dict_insert(dict, "Default", ghb_boolean_value_new(TRUE)); } store_presets(); } @@ -738,14 +733,13 @@ presets_set_default(gint *indices, gint len) static void presets_set_folder_open(gboolean open, gint *indices, gint len) { - GValue *dict; + GhbValue *dict; g_debug("presets_set_folder_open ()"); dict = presets_get_dict(presetsPlist, indices, len); if (dict) { - ghb_dict_insert(dict, g_strdup("FolderOpen"), - ghb_boolean_value_new(open)); + ghb_dict_insert(dict, "FolderOpen", ghb_boolean_value_new(open)); } } @@ -759,48 +753,48 @@ key_cmp(gconstpointer a, gconstpointer b) return strcmp(stra, strb); } -static const GValue* -preset_dict_get_value(GValue *dict, const gchar *key) +static const GhbValue* +preset_dict_get_value(GhbValue *dict, const gchar *key) { return ghb_dict_lookup(dict, key); } -static const char * dict_get_string(GValue *dict, const char *key) +static const char * dict_get_string(GhbValue *dict, const char *key) { - GValue *gval = ghb_dict_lookup(dict, key); + GhbValue *gval = ghb_dict_lookup(dict, key); if (gval == NULL) return NULL; - return g_value_get_string(gval); + return ghb_value_const_string(gval); } -static gboolean dict_get_boolean(GValue *dict, const char *key) +static gboolean dict_get_boolean(GhbValue *dict, const char *key) { - GValue *gval = ghb_dict_lookup(dict, key); + GhbValue *gval = ghb_dict_lookup(dict, key); if (gval == NULL) return FALSE; - return g_value_get_boolean(gval); + return ghb_value_boolean(gval); } const gchar* -ghb_presets_get_description(GValue *pdict) +ghb_presets_get_description(GhbValue *pdict) { return dict_get_string(pdict, "PresetDescription"); } static void init_settings_from_dict( - GValue *dest, GValue *template, GValue *dict, gboolean filter); + GhbValue *dest, GhbValue *template, GhbValue *dict, gboolean filter); static void init_settings_from_array( - GValue *dest, - GValue *template, - GValue *array, + GhbValue *dest, + GhbValue *template, + GhbValue *array, gboolean filter) { - GValue *gval, *val, *new_val; + GhbValue *gval, *val, *new_val; gint count, ii; if (ghb_array_len(template) == 0) @@ -824,10 +818,10 @@ init_settings_from_array( for (ii = 0; ii < count; ii++) { val = ghb_array_get_nth(array, ii); - if (G_VALUE_TYPE(gval) == ghb_dict_get_type()) + if (ghb_value_type(gval) == GHB_DICT) { - GValue *new_dict; - if (val != NULL && G_VALUE_TYPE(val) == ghb_dict_get_type()) + GhbValue *new_dict; + if (val != NULL && ghb_value_type(val) == GHB_DICT) { new_dict = ghb_dict_value_new(); init_settings_from_dict(new_dict, gval, val, filter); @@ -838,10 +832,10 @@ init_settings_from_array( } new_val = new_dict; } - else if (G_VALUE_TYPE(gval) == ghb_array_get_type()) + else if (ghb_value_type(gval) == GHB_ARRAY) { - GValue *new_array; - if (val != NULL && G_VALUE_TYPE(val) == ghb_array_get_type()) + GhbValue *new_array; + if (val != NULL && ghb_value_type(val) == GHB_ARRAY) { new_array = ghb_array_value_new(8); init_settings_from_array(new_array, gval, val, filter); @@ -865,28 +859,27 @@ init_settings_from_array( static void init_settings_from_dict( - GValue *dest, - GValue *template, - GValue *dict, + GhbValue *dest, + GhbValue *template, + GhbValue *dict, gboolean filter) { - GHashTableIter iter; - gchar *key; - GValue *gval, *val, *new_val; + GhbDictIter iter; + const gchar *key; + GhbValue *gval, *val, *new_val; - ghb_dict_iter_init(&iter, template); + ghb_dict_iter_init(template, &iter); // middle (void*) cast prevents gcc warning "defreferencing type-punned // pointer will break strict-aliasing rules" - while (g_hash_table_iter_next( - &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval)) + while (ghb_dict_iter_next(template, &iter, &key, &gval)) { val = NULL; if (dict) val = ghb_dict_lookup(dict, key); - if (G_VALUE_TYPE(gval) == ghb_dict_get_type()) + if (ghb_value_type(gval) == GHB_DICT) { - GValue *new_dict; - if (val != NULL && G_VALUE_TYPE(val) == ghb_dict_get_type()) + GhbValue *new_dict; + if (val != NULL && ghb_value_type(val) == GHB_DICT) { new_dict = ghb_dict_value_new(); init_settings_from_dict(new_dict, gval, val, filter); @@ -897,10 +890,10 @@ init_settings_from_dict( } new_val = new_dict; } - else if (G_VALUE_TYPE(gval) == ghb_array_get_type()) + else if (ghb_value_type(gval) == GHB_ARRAY) { - GValue *new_array; - if (val != NULL && G_VALUE_TYPE(val) == ghb_array_get_type()) + GhbValue *new_array; + if (val != NULL && ghb_value_type(val) == GHB_ARRAY) { new_array = ghb_array_value_new(8); init_settings_from_array(new_array, gval, val, filter); @@ -927,11 +920,10 @@ init_settings_from_dict( // If not filtering the source, copy source elements that // were not in the template. - ghb_dict_iter_init(&iter, dict); + ghb_dict_iter_init(dict, &iter); // middle (void*) cast prevents gcc warning "defreferencing type-punned // pointer will break strict-aliasing rules" - while (g_hash_table_iter_next( - &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval)) + while (ghb_dict_iter_next(dict, &iter, &key, &gval)) { val = ghb_dict_lookup(template, key); if (val == NULL) @@ -942,14 +934,14 @@ init_settings_from_dict( } void -ghb_preset_to_settings(GValue *settings, GValue *preset) +ghb_preset_to_settings(GhbValue *settings, GhbValue *preset) { // Initialize the ui from presets file. - GValue *internal; + GhbValue *internal; // Get key list from internal default presets. This way we do not // load any unknown keys. - GValue *internalPlist = ghb_resource_get("internal-defaults"); + GhbValue *internalPlist = ghb_resource_get("internal-defaults"); if (internalPlist == NULL) return; internal = plist_get_dict(internalPlist, "Presets"); if (preset == NULL) @@ -958,34 +950,57 @@ ghb_preset_to_settings(GValue *settings, GValue *preset) init_settings_from_dict(settings, preset, NULL, TRUE); } +// Initialization order of some widgets matter because the value of +// these widgets are used to establich limits on the values that +// other widgets are allowed to take. +// +// So make sure these get initialized first. +static const char *widget_priority_list[] = +{ + "preview_count", + "PtoPType", + "VideoEncoder", + "VideoQualityGranularity", + "AudioEncoder", + NULL +}; + void -ghb_settings_to_ui(signal_user_data_t *ud, GValue *dict) +ghb_settings_to_ui(signal_user_data_t *ud, GhbValue *dict) { - GHashTableIter iter; - gchar *key; - GValue *gval; - GValue *tmp = ghb_value_dup(dict); + GhbDictIter iter; + const gchar *key; + GhbValue *gval; + int ii; + GhbValue *tmp = ghb_value_dup(dict); if (dict == NULL) return; - ghb_dict_iter_init(&iter, tmp); + for (ii = 0; widget_priority_list[ii] != NULL; ii++) + { + key = widget_priority_list[ii]; + gval = ghb_settings_get_value(tmp, key); + if (gval != NULL) + ghb_ui_settings_update(ud, dict, key, gval); + } + + ghb_dict_iter_init(tmp, &iter); // middle (void*) cast prevents gcc warning "defreferencing type-punned // pointer will break strict-aliasing rules" - while (g_hash_table_iter_next( - &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval)) + while (ghb_dict_iter_next(tmp, &iter, &key, &gval)) { ghb_ui_settings_update(ud, dict, key, gval); } ghb_value_free(tmp); } -static GValue *current_preset = NULL; +static GhbValue *current_preset = NULL; gboolean ghb_preset_is_custom() { - const GValue *val; + const GhbValue *val; if (current_preset == NULL) return FALSE; val = preset_dict_get_value(current_preset, "Type"); @@ -998,7 +1013,7 @@ ghb_set_preset_settings_from_indices( gint *indices, gint len) { - GValue *dict = NULL; + GhbValue *dict = NULL; gint fallback[2] = {0, -1}; if (indices) @@ -1016,7 +1031,7 @@ ghb_set_preset_settings_from_indices( } else { - GValue *path; + GhbValue *path; gboolean folder; current_preset = dict; @@ -1031,7 +1046,7 @@ ghb_set_preset_settings_from_indices( } } -static const GValue* +static const GhbValue* curr_preset_get_value(const gchar *key) { if (current_preset == NULL) return NULL; @@ -1043,7 +1058,7 @@ ghb_update_from_preset( signal_user_data_t *ud, const gchar *key) { - const GValue *gval; + const GhbValue *gval; g_debug("ghb_update_from_preset() %s", key); gval = curr_preset_get_value(key); @@ -1086,7 +1101,7 @@ ghb_select_preset2( } void -ghb_select_preset(GtkBuilder *builder, const GValue *path) +ghb_select_preset(GtkBuilder *builder, const GhbValue *path) { gint *indices, len; @@ -1155,7 +1170,7 @@ ghb_get_user_config_dir(gchar *subdir) } static void -store_plist(GValue *plist, const gchar *name) +store_plist(GhbValue *plist, const gchar *name) { gchar *config, *path; FILE *file; @@ -1169,11 +1184,11 @@ store_plist(GValue *plist, const gchar *name) fclose(file); } -static GValue* +static GhbValue* load_plist(const gchar *name) { gchar *config, *path; - GValue *plist = NULL; + GhbValue *plist = NULL; config = ghb_get_user_config_dir(NULL); path = g_strdup_printf ("%s/%s", config, name); @@ -1331,29 +1346,26 @@ remove_plist(const gchar *name) } void -ghb_prefs_save(GValue *settings) +ghb_prefs_save(GhbValue *settings) { - GValue *dict; - GValue *pref_dict; - GHashTableIter iter; - gchar *key; - const GValue *value; + GhbValue *dict; + GhbValue *pref_dict; + GhbDictIter iter; + const gchar *key; + const GhbValue *value; - GValue *internalPlist = ghb_resource_get("internal-defaults"); + GhbValue *internalPlist = ghb_resource_get("internal-defaults"); dict = plist_get_dict(internalPlist, "Preferences"); if (dict == NULL) return; pref_dict = plist_get_dict(prefsPlist, "Preferences"); if (pref_dict == NULL) return; - ghb_dict_iter_init(&iter, dict); - // middle (void*) cast prevents gcc warning "defreferencing type-punned - // pointer will break strict-aliasing rules" - while (g_hash_table_iter_next( - &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&value)) + ghb_dict_iter_init(dict, &iter); + while (ghb_dict_iter_next(dict, &iter, &key, NULL)) { value = ghb_settings_get_value(settings, key); if (value != NULL) { - ghb_dict_insert(pref_dict, g_strdup(key), ghb_value_dup(value)); + ghb_dict_insert(pref_dict, key, ghb_value_dup(value)); } } store_prefs(); @@ -1361,20 +1373,20 @@ ghb_prefs_save(GValue *settings) } void -ghb_pref_save(GValue *settings, const gchar *key) +ghb_pref_save(GhbValue *settings, const gchar *key) { - const GValue *value, *value2; + const GhbValue *value, *value2; value = ghb_settings_get_value(settings, key); if (value != NULL) { - GValue *dict; + GhbValue *dict; dict = plist_get_dict(prefsPlist, "Preferences"); if (dict == NULL) return; value2 = ghb_dict_lookup(dict, key); if (ghb_value_cmp(value, value2) != 0) { - ghb_dict_insert(dict, g_strdup(key), ghb_value_dup(value)); + ghb_dict_insert(dict, key, ghb_value_dup(value)); store_prefs(); prefs_modified = FALSE; } @@ -1382,20 +1394,20 @@ ghb_pref_save(GValue *settings, const gchar *key) } void -ghb_pref_set(GValue *settings, const gchar *key) +ghb_pref_set(GhbValue *settings, const gchar *key) { - const GValue *value, *value2; + const GhbValue *value, *value2; value = ghb_settings_get_value(settings, key); if (value != NULL) { - GValue *dict; + GhbValue *dict; dict = plist_get_dict(prefsPlist, "Preferences"); if (dict == NULL) return; value2 = ghb_dict_lookup(dict, key); if (ghb_value_cmp(value, value2) != 0) { - ghb_dict_insert(dict, g_strdup(key), ghb_value_dup(value)); + ghb_dict_insert(dict, key, ghb_value_dup(value)); prefs_modified = TRUE; } } @@ -1412,26 +1424,25 @@ ghb_prefs_store(void) } void -ghb_settings_init(GValue *settings, const char *name) +ghb_settings_init(GhbValue *settings, const char *name) { - GValue *internal; - GHashTableIter iter; - gchar *key; - GValue *gval; + GhbValue *internal; + GhbDictIter iter; + const gchar *key; + GhbValue *gval; g_debug("ghb_settings_init"); - GValue *internalPlist = ghb_resource_get("internal-defaults"); + GhbValue *internalPlist = ghb_resource_get("internal-defaults"); // Setting a ui widget will cause the corresponding setting // to be set, but it also triggers a callback that can // have the side effect of using other settings values // 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(&iter, internal); + ghb_dict_iter_init(internal, &iter); // middle (void*) cast prevents gcc warning "defreferencing type-punned // pointer will break strict-aliasing rules" - while (g_hash_table_iter_next( - &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval)) + while (ghb_dict_iter_next(internal, &iter, &key, &gval)) { ghb_settings_set_value(settings, key, gval); } @@ -1477,13 +1488,13 @@ FindFirstCDROM(void) void ghb_prefs_load(signal_user_data_t *ud) { - GValue *dict, *internal; - GHashTableIter iter; - gchar *key; - GValue *gval; + GhbValue *dict, *internal; + GhbDictIter iter; + const gchar *key; + GhbValue *gval; g_debug("ghb_prefs_load"); - GValue *internalPlist = ghb_resource_get("internal-defaults"); + GhbValue *internalPlist = ghb_resource_get("internal-defaults"); prefsPlist = load_plist("preferences"); if (prefsPlist == NULL) prefsPlist = ghb_dict_value_new(); @@ -1492,16 +1503,15 @@ ghb_prefs_load(signal_user_data_t *ud) if (dict == NULL && internal) { dict = ghb_dict_value_new(); - ghb_dict_insert(prefsPlist, g_strdup("Preferences"), dict); + ghb_dict_insert(prefsPlist, "Preferences", dict); // Get defaults from internal defaults - ghb_dict_iter_init(&iter, internal); + ghb_dict_iter_init(internal, &iter); // middle (void*) cast prevents gcc warning "defreferencing type-punned // pointer will break strict-aliasing rules" - while (g_hash_table_iter_next( - &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval)) + while (ghb_dict_iter_next(internal, &iter, &key, &gval)) { - ghb_dict_insert(dict, g_strdup(key), ghb_value_dup(gval)); + ghb_dict_insert(dict, key, ghb_value_dup(gval)); } const gchar *dir = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP); @@ -1509,19 +1519,16 @@ ghb_prefs_load(signal_user_data_t *ud) { dir = "."; } - ghb_dict_insert(dict, - g_strdup("ExportDirectory"), ghb_value_dup(ghb_string_value(dir))); + ghb_dict_insert(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, - g_strdup("destination_dir"), ghb_value_dup(ghb_string_value(dir))); + ghb_dict_insert(dict, "destination_dir", ghb_string_value_new(dir)); - ghb_dict_insert(dict, - g_strdup("SrtDir"), ghb_value_dup(ghb_string_value(dir))); + ghb_dict_insert(dict, "SrtDir", ghb_string_value_new(dir)); #if defined(_WIN32) gchar *source; @@ -1530,8 +1537,7 @@ ghb_prefs_load(signal_user_data_t *ud) { source = g_strdup("C:" G_DIR_SEPARATOR_S); } - ghb_dict_insert(dict, g_strdup("default_source"), - ghb_value_dup(ghb_string_value(source))); + ghb_dict_insert(dict, "default_source", ghb_string_value_new(source)); g_free(source); #endif store_prefs(); @@ -1539,17 +1545,17 @@ ghb_prefs_load(signal_user_data_t *ud) } void -ghb_prefs_to_settings(GValue *settings) +ghb_prefs_to_settings(GhbValue *settings) { // Initialize the ui from presets file. - GValue *internal, *dict; + GhbValue *internal, *dict; if (prefsPlist == NULL) return; // Get key list from internal default presets. This way we do not // load any unknown keys. - GValue *internalPlist = ghb_resource_get("internal-defaults"); + GhbValue *internalPlist = ghb_resource_get("internal-defaults"); if (internalPlist == NULL) return; internal = plist_get_dict(internalPlist, "Preferences"); dict = plist_get_dict(prefsPlist, "Preferences"); @@ -1600,9 +1606,9 @@ ghb_presets_list_init( const gchar *description; gboolean def; gint count, ii; - GValue *dict; + GhbValue *dict; gint *more_indices; - GValue *presets = NULL; + GhbValue *presets = NULL; g_debug("ghb_presets_list_init ()"); more_indices = g_malloc((len+1)*sizeof(gint)); @@ -1705,7 +1711,7 @@ presets_list_update_item( const gchar *description; gint type; gboolean def, folder; - GValue *dict; + GhbValue *dict; const gchar *color; g_debug("presets_list_update_item ()"); @@ -1751,9 +1757,9 @@ presets_list_insert( gint type; gboolean def, folder; gint count; - GValue *presets; + GhbValue *presets; GtkTreePath *parent_path; - GValue *dict; + GhbValue *dict; const gchar *color; g_debug("presets_list_insert ()"); @@ -1834,7 +1840,7 @@ remove_std_presets(signal_user_data_t *ud) count = ghb_array_len(presetsPlist); for (ii = count-1; ii >= 0; ii--) { - GValue *dict; + GhbValue *dict; gint ptype; dict = ghb_array_get_nth(presetsPlist, ii); @@ -1850,7 +1856,7 @@ remove_std_presets(signal_user_data_t *ud) } void -ghb_save_queue(GValue *queue) +ghb_save_queue(GhbValue *queue) { pid_t pid; char *path; @@ -1861,10 +1867,10 @@ ghb_save_queue(GValue *queue) g_free(path); } -GValue* +GhbValue* ghb_load_queue() { - GValue *queue; + GhbValue *queue; pid_t pid; char *path; @@ -1875,10 +1881,10 @@ ghb_load_queue() return queue; } -GValue* +GhbValue* ghb_load_old_queue(int pid) { - GValue *queue; + GhbValue *queue; char *path; path = g_strdup_printf ("queue.%d", pid); @@ -1958,10 +1964,10 @@ value_map_t decomb_xlat[] = #if 0 extern iso639_lang_t ghb_language_table[]; -static GValue* -export_lang_xlat2(GValue *lin_val) +static GhbValue* +export_lang_xlat2(GhbValue *lin_val) { - GValue *gval; + GhbValue *gval; if (lin_val == NULL) return NULL; gint ii; @@ -1989,10 +1995,10 @@ export_lang_xlat2(GValue *lin_val) return NULL; } -static GValue* -import_lang_xlat2(GValue *mac_val) +static GhbValue* +import_lang_xlat2(GhbValue *mac_val) { - GValue *gval; + GhbValue *gval; if (mac_val == NULL) return NULL; gint ii; @@ -2015,15 +2021,15 @@ import_lang_xlat2(GValue *mac_val) } #endif -static GValue* -export_value_xlat2(value_map_t *value_map, GValue *lin_val, GType mac_type) +static GhbValue* +export_value_xlat2(value_map_t *value_map, GhbValue *lin_val, GhbType mac_type) { - GValue *gval; + GhbValue *gval; if (lin_val == NULL) return NULL; gint ii; gchar *str; - GValue *sval; + GhbValue *sval; str = ghb_value_string(lin_val); for (ii = 0; value_map[ii].mac_val; ii++) @@ -2032,11 +2038,10 @@ export_value_xlat2(value_map_t *value_map, GValue *lin_val, GType mac_type) { sval = ghb_string_value_new(value_map[ii].mac_val); g_free(str); - gval = ghb_value_new(mac_type); - if (!g_value_transform(sval, gval)) + gval = ghb_value_xform(sval, mac_type); + if (gval == NULL) { g_warning("can't transform"); - ghb_value_free(gval); ghb_value_free(sval); return NULL; } @@ -2049,10 +2054,10 @@ export_value_xlat2(value_map_t *value_map, GValue *lin_val, GType mac_type) return NULL; } -static GValue* -export_value_video_framerate(GValue *lin_val) +static GhbValue* +export_value_video_framerate(GhbValue *lin_val) { - GValue *sval = NULL; + GhbValue *sval = NULL; gchar *str; const gchar *fr; @@ -2065,10 +2070,10 @@ export_value_video_framerate(GValue *lin_val) return sval; } -static GValue* -export_value_audio_samplerate(GValue *lin_val) +static GhbValue* +export_value_audio_samplerate(GhbValue *lin_val) { - GValue *sval = NULL; + GhbValue *sval = NULL; gchar *str; const gchar *sr; @@ -2081,10 +2086,10 @@ export_value_audio_samplerate(GValue *lin_val) return sval; } -static GValue* -export_value_mixdown(GValue *lin_val) +static GhbValue* +export_value_mixdown(GhbValue *lin_val) { - GValue *sval = NULL; + GhbValue *sval = NULL; gchar *str; const gchar *mix; @@ -2097,10 +2102,10 @@ export_value_mixdown(GValue *lin_val) return sval; } -static GValue* -export_value_video_encoder(GValue *lin_val) +static GhbValue* +export_value_video_encoder(GhbValue *lin_val) { - GValue *sval = NULL; + GhbValue *sval = NULL; gchar *str; const gchar *enc; @@ -2113,10 +2118,10 @@ export_value_video_encoder(GValue *lin_val) return sval; } -static GValue* -export_value_audio_encoder(GValue *lin_val) +static GhbValue* +export_value_audio_encoder(GhbValue *lin_val) { - GValue *sval = NULL; + GhbValue *sval = NULL; gchar *str; const gchar *enc; @@ -2129,10 +2134,10 @@ export_value_audio_encoder(GValue *lin_val) return sval; } -static GValue* -export_value_container(GValue *lin_val) +static GhbValue* +export_value_container(GhbValue *lin_val) { - GValue *sval = NULL; + GhbValue *sval = NULL; gchar *str; const gchar *mux; @@ -2147,58 +2152,58 @@ export_value_container(GValue *lin_val) // Translate values for compatibility with other platforms static void -export_value_xlat(GValue *dict) +export_value_xlat(GhbValue *dict) { - GValue *lin_val, *gval; + GhbValue *lin_val, *gval; const gchar *key; key = "VideoEncoder"; lin_val = ghb_dict_lookup(dict, key); gval = export_value_video_encoder(lin_val); if (gval) - ghb_dict_insert(dict, g_strdup(key), gval); + ghb_dict_insert(dict, key, gval); key = "FileFormat"; lin_val = ghb_dict_lookup(dict, key); gval = export_value_container(lin_val); if (gval) - ghb_dict_insert(dict, g_strdup(key), gval); + ghb_dict_insert(dict, key, gval); key = "VideoFramerate"; lin_val = ghb_dict_lookup(dict, key); gval = export_value_video_framerate(lin_val); if (gval) - ghb_dict_insert(dict, g_strdup(key), gval); + ghb_dict_insert(dict, key, gval); key = "PictureDetelecine"; lin_val = ghb_dict_lookup(dict, key); - gval = export_value_xlat2(detel_xlat, lin_val, G_TYPE_INT); + gval = export_value_xlat2(detel_xlat, lin_val, GHB_INT); if (gval) - ghb_dict_insert(dict, g_strdup(key), gval); + ghb_dict_insert(dict, key, gval); key = "PictureDecomb"; lin_val = ghb_dict_lookup(dict, key); - gval = export_value_xlat2(decomb_xlat, lin_val, G_TYPE_INT); + gval = export_value_xlat2(decomb_xlat, lin_val, GHB_INT); if (gval) - ghb_dict_insert(dict, g_strdup(key), gval); + ghb_dict_insert(dict, key, gval); key = "PictureDeinterlace"; lin_val = ghb_dict_lookup(dict, key); - gval = export_value_xlat2(deint_xlat, lin_val, G_TYPE_INT); + gval = export_value_xlat2(deint_xlat, lin_val, GHB_INT); if (gval) - ghb_dict_insert(dict, g_strdup(key), gval); + ghb_dict_insert(dict, key, gval); #if 0 key = "PictureDenoisePreset"; lin_val = ghb_dict_lookup(dict, key); - gval = export_value_xlat2(denoise_xlat, lin_val, G_TYPE_INT); + gval = export_value_xlat2(denoise_xlat, lin_val, GHB_INT); if (gval) - ghb_dict_insert(dict, g_strdup(key), gval); + ghb_dict_insert(dict, key, gval); #endif gint count, ii; - GValue *alist; - GValue *adict; + GhbValue *alist; + GhbValue *adict; key = "AudioEncoderFallback"; lin_val = ghb_dict_lookup(dict, key); gval = export_value_audio_encoder(lin_val); if (gval) - ghb_dict_insert(dict, g_strdup(key), gval); + ghb_dict_insert(dict, key, gval); alist = ghb_dict_lookup(dict, "AudioList"); count = ghb_array_len(alist); @@ -2209,29 +2214,29 @@ export_value_xlat(GValue *dict) lin_val = ghb_dict_lookup(adict, key); gval = export_value_audio_encoder(lin_val); if (gval) - ghb_dict_insert(adict, g_strdup(key), gval); + ghb_dict_insert(adict, key, gval); key = "AudioSamplerate"; lin_val = ghb_dict_lookup(adict, key); gval = export_value_audio_samplerate(lin_val); if (gval) - ghb_dict_insert(adict, g_strdup(key), gval); + ghb_dict_insert(adict, key, gval); key = "AudioMixdown"; lin_val = ghb_dict_lookup(adict, key); gval = export_value_mixdown(lin_val); if (gval) - ghb_dict_insert(adict, g_strdup(key), gval); + ghb_dict_insert(adict, key, gval); } } -static GValue* +static GhbValue* import_value_xlat2( - GValue *defaults, + GhbValue *defaults, value_map_t *value_map, const gchar *key, - GValue *mac_val) + GhbValue *mac_val) { - GValue *gval, *def_val; + GhbValue *gval, *def_val; if (mac_val == NULL) return NULL; def_val = ghb_dict_lookup(defaults, key); @@ -2239,7 +2244,7 @@ import_value_xlat2( { gint ii; gchar *str; - GValue *sval; + GhbValue *sval; str = ghb_value_string(mac_val); for (ii = 0; value_map[ii].mac_val; ii++) @@ -2249,11 +2254,10 @@ import_value_xlat2( { sval = ghb_string_value_new(value_map[ii].lin_val); g_free(str); - gval = ghb_value_new(G_VALUE_TYPE(def_val)); - if (!g_value_transform(sval, gval)) + gval = ghb_value_xform(sval, ghb_value_type(def_val)); + if (gval == NULL) { g_warning("can't transform"); - ghb_value_free(gval); ghb_value_free(sval); return NULL; } @@ -2268,7 +2272,7 @@ import_value_xlat2( { gint ii; gchar *str; - GValue *sval; + GhbValue *sval; str = ghb_value_string(mac_val); for (ii = 0; value_map[ii].mac_val; ii++) @@ -2278,11 +2282,10 @@ import_value_xlat2( { sval = ghb_string_value_new(value_map[ii].lin_val); g_free(str); - gval = ghb_value_new(G_VALUE_TYPE(mac_val)); - if (!g_value_transform(sval, gval)) + gval = ghb_value_xform(sval, ghb_value_type(mac_val)); + if (gval == NULL) { g_warning("can't transform"); - ghb_value_free(gval); ghb_value_free(sval); return NULL; } @@ -2295,10 +2298,10 @@ import_value_xlat2( return NULL; } -static GValue* -import_value_video_framerate(GValue *mac_val) +static GhbValue* +import_value_video_framerate(GhbValue *mac_val) { - GValue *sval = NULL; + GhbValue *sval = NULL; gchar *str; const gchar *fr; @@ -2312,10 +2315,10 @@ import_value_video_framerate(GValue *mac_val) return sval; } -static GValue* -import_value_audio_samplerate(GValue *mac_val) +static GhbValue* +import_value_audio_samplerate(GhbValue *mac_val) { - GValue *sval = NULL; + GhbValue *sval = NULL; gchar *str; const gchar *sr; @@ -2329,10 +2332,10 @@ import_value_audio_samplerate(GValue *mac_val) return sval; } -static GValue* -import_value_mixdown(GValue *mac_val) +static GhbValue* +import_value_mixdown(GhbValue *mac_val) { - GValue *sval = NULL; + GhbValue *sval = NULL; gchar *str; const gchar *mix; @@ -2346,10 +2349,10 @@ import_value_mixdown(GValue *mac_val) return sval; } -static GValue* -import_value_video_encoder(GValue *mac_val) +static GhbValue* +import_value_video_encoder(GhbValue *mac_val) { - GValue *sval = NULL; + GhbValue *sval = NULL; gchar *str; const gchar *enc; @@ -2363,10 +2366,10 @@ import_value_video_encoder(GValue *mac_val) return sval; } -static GValue* -import_value_audio_encoder(GValue *mac_val) +static GhbValue* +import_value_audio_encoder(GhbValue *mac_val) { - GValue *sval = NULL; + GhbValue *sval = NULL; gchar *str; const gchar *enc; @@ -2380,10 +2383,10 @@ import_value_audio_encoder(GValue *mac_val) return sval; } -static GValue* -import_value_container(GValue *mac_val) +static GhbValue* +import_value_container(GhbValue *mac_val) { - GValue *sval = NULL; + GhbValue *sval = NULL; gchar *str; const gchar *mux; @@ -2398,63 +2401,63 @@ import_value_container(GValue *mac_val) } static void -import_value_xlat(GValue *dict) +import_value_xlat(GhbValue *dict) { - GValue *defaults, *mac_val, *gval; + GhbValue *defaults, *mac_val, *gval; const gchar *key; - GValue *internalPlist = ghb_resource_get("internal-defaults"); + GhbValue *internalPlist = ghb_resource_get("internal-defaults"); defaults = plist_get_dict(internalPlist, "Presets"); key = "VideoEncoder"; mac_val = ghb_dict_lookup(dict, key); gval = import_value_video_encoder(mac_val); if (gval) - ghb_dict_insert(dict, g_strdup(key), gval); + ghb_dict_insert(dict, key, gval); key = "FileFormat"; mac_val = ghb_dict_lookup(dict, key); gval = import_value_container(mac_val); if (gval) - ghb_dict_insert(dict, g_strdup(key), gval); + ghb_dict_insert(dict, key, gval); key = "VideoFramerate"; mac_val = ghb_dict_lookup(dict, key); gval = import_value_video_framerate(mac_val); if (gval) - ghb_dict_insert(dict, g_strdup(key), gval); + ghb_dict_insert(dict, key, gval); key = "PictureDetelecine"; mac_val = ghb_dict_lookup(dict, key); gval = import_value_xlat2(defaults, detel_xlat, key, mac_val); if (gval) - ghb_dict_insert(dict, g_strdup(key), gval); + ghb_dict_insert(dict, key, gval); key = "PictureDecomb"; mac_val = ghb_dict_lookup(dict, key); gval = import_value_xlat2(defaults, decomb_xlat, key, mac_val); if (gval) - ghb_dict_insert(dict, g_strdup(key), gval); + ghb_dict_insert(dict, key, gval); key = "PictureDeinterlace"; mac_val = ghb_dict_lookup(dict, key); gval = import_value_xlat2(defaults, deint_xlat, key, mac_val); if (gval) - ghb_dict_insert(dict, g_strdup(key), gval); + ghb_dict_insert(dict, key, gval); key = "PictureDenoisePreset"; mac_val = ghb_dict_lookup(dict, key); gval = import_value_xlat2(defaults, denoise_xlat, key, mac_val); if (gval) - ghb_dict_insert(dict, g_strdup(key), gval); + ghb_dict_insert(dict, key, gval); ghb_dict_remove(dict, "Subtitles"); ghb_dict_remove(dict, "SubtitlesForced"); gint count, ii; - GValue *alist; - GValue *adict; - GValue *adefaults; - GValue *adeflist; + GhbValue *alist; + GhbValue *adict; + GhbValue *adefaults; + GhbValue *adeflist; key = "AudioEncoderFallback"; mac_val = ghb_dict_lookup(dict, key); gval = import_value_audio_encoder(mac_val); if (gval) - ghb_dict_insert(dict, g_strdup(key), gval); + ghb_dict_insert(dict, key, gval); adeflist = ghb_dict_lookup(defaults, "AudioList"); if (adeflist) @@ -2471,21 +2474,21 @@ import_value_xlat(GValue *dict) if (gval == NULL) gval = ghb_value_dup(ghb_dict_lookup(adefaults, key)); if (gval) - ghb_dict_insert(adict, g_strdup(key), gval); + ghb_dict_insert(adict, key, gval); key = "AudioSamplerate"; mac_val = ghb_dict_lookup(adict, key); gval = import_value_audio_samplerate(mac_val); if (gval == NULL) gval = ghb_value_dup(ghb_dict_lookup(adefaults, key)); if (gval) - ghb_dict_insert(adict, g_strdup(key), gval); + ghb_dict_insert(adict, key, gval); key = "AudioMixdown"; mac_val = ghb_dict_lookup(adict, key); gval = import_value_mixdown(mac_val); if (gval == NULL) gval = ghb_value_dup(ghb_dict_lookup(adefaults, key)); if (gval) - ghb_dict_insert(adict, g_strdup(key), gval); + ghb_dict_insert(adict, key, gval); mac_val = ghb_dict_lookup(adict, "AudioTrackDRCSlider"); if (mac_val != NULL) @@ -2494,7 +2497,7 @@ import_value_xlat(GValue *dict) drc = ghb_value_double(mac_val); if (drc < 1.0) { - ghb_dict_insert(adict, g_strdup("AudioTrackDRCSlider"), + ghb_dict_insert(adict, "AudioTrackDRCSlider", ghb_double_value_new(0.0)); } } @@ -2502,10 +2505,10 @@ import_value_xlat(GValue *dict) } } -static GValue* -import_xlat_preset(GValue *user_preset) +static GhbValue* +import_xlat_preset(GhbValue *user_preset) { - GValue *dict, *internal; + GhbValue *dict, *internal; g_debug("import_xlat_preset ()"); @@ -2513,27 +2516,27 @@ import_xlat_preset(GValue *user_preset) // First, initialize the preset with defaults. // Then import user presets over top of defaults - GValue *internalPlist = ghb_resource_get("internal-defaults"); + GhbValue *internalPlist = ghb_resource_get("internal-defaults"); internal = plist_get_dict(internalPlist, "Presets"); init_settings_from_dict(dict, internal, user_preset, FALSE); // Initialize the AudioLanguageList from preferences PreferredLanguage // and translate old AudioDUB preference option if found - GValue *list = ghb_dict_lookup(dict, "AudioLanguageList"); + GhbValue *list = ghb_dict_lookup(dict, "AudioLanguageList"); if (list == NULL) { list = ghb_array_value_new(8); - ghb_dict_insert(dict, g_strdup("AudioLanguageList"), list); + ghb_dict_insert(dict, "AudioLanguageList", list); } if (ghb_array_len(list) == 0) { - GValue *prefs = plist_get_dict(prefsPlist, "Preferences"); - GValue *gdub = ghb_dict_lookup(prefs, "AudioDUB"); - GValue *glang = ghb_dict_lookup(prefs, "PreferredLanguage"); + GhbValue *prefs = plist_get_dict(prefsPlist, "Preferences"); + GhbValue *gdub = ghb_dict_lookup(prefs, "AudioDUB"); + GhbValue *glang = ghb_dict_lookup(prefs, "PreferredLanguage"); const char *lang = NULL; if (glang != NULL) { - lang = g_value_get_string(glang); + lang = ghb_value_const_string(glang); } if (gdub != NULL && !ghb_value_boolean(gdub)) { @@ -2554,12 +2557,12 @@ import_xlat_preset(GValue *user_preset) if (list == NULL) { list = ghb_array_value_new(8); - ghb_dict_insert(dict, g_strdup("SubtitleLanguageList"), list); + ghb_dict_insert(dict, "SubtitleLanguageList", list); } if (ghb_array_len(list) == 0) { - GValue *prefs = plist_get_dict(prefsPlist, "Preferences"); - GValue *val = ghb_dict_lookup(prefs, "PreferredLanguage"); + GhbValue *prefs = plist_get_dict(prefsPlist, "Preferences"); + GhbValue *val = ghb_dict_lookup(prefs, "PreferredLanguage"); if (val != NULL) { ghb_array_append(list, ghb_value_dup(val)); @@ -2568,20 +2571,20 @@ import_xlat_preset(GValue *user_preset) if (val != NULL && !ghb_value_boolean(val)) { ghb_dict_insert(dict, - g_strdup("SubtitleAddForeignAudioSubtitle"), + "SubtitleAddForeignAudioSubtitle", ghb_boolean_value_new(TRUE)); } } } - GValue *addCC = ghb_dict_lookup(dict, "SubtitleAddCC"); + GhbValue *addCC = ghb_dict_lookup(dict, "SubtitleAddCC"); if (addCC == NULL) { - GValue *prefs = plist_get_dict(prefsPlist, "Preferences"); - GValue *val = ghb_dict_lookup(prefs, "AddCC"); + GhbValue *prefs = plist_get_dict(prefsPlist, "Preferences"); + GhbValue *val = ghb_dict_lookup(prefs, "AddCC"); if (val != NULL) { - ghb_dict_insert(dict, g_strdup("SubtitleAddCC"), + ghb_dict_insert(dict, "SubtitleAddCC", ghb_value_dup(val)); } } @@ -2689,6 +2692,7 @@ import_xlat_preset(GValue *user_preset) if (!strcasecmp(videoPreset, videoPresets[ii])) { ghb_settings_set_int(dict, "VideoPresetSlider", ii); + break; } } if (videoPreset != NULL) @@ -2758,10 +2762,10 @@ import_xlat_preset(GValue *user_preset) } static void -import_xlat_presets(GValue *presets) +import_xlat_presets(GhbValue *presets) { gint count, ii; - GValue *dict; + GhbValue *dict; gboolean folder; g_debug("import_xlat_presets ()"); @@ -2773,14 +2777,14 @@ import_xlat_presets(GValue *presets) folder = ghb_value_boolean(preset_dict_get_value(dict, "Folder")); if (folder) { - GValue *nested; + GhbValue *nested; nested = ghb_dict_lookup(dict, "ChildrenArray"); import_xlat_presets(nested); } else { - GValue *import_dict = import_xlat_preset(dict); + GhbValue *import_dict = import_xlat_preset(dict); ghb_array_replace(presets, ii, import_dict); } } @@ -2788,7 +2792,7 @@ import_xlat_presets(GValue *presets) // Translate internal values to preset key, value pairs static void -export_xlat_preset(GValue *dict) +export_xlat_preset(GhbValue *dict) { gboolean autoscale, br, constant; @@ -2801,50 +2805,46 @@ export_xlat_preset(GValue *dict) if (autoscale) { - ghb_dict_insert(dict, g_strdup("UsesPictureSettings"), - ghb_int_value_new(2)); + ghb_dict_insert(dict, "UsesPictureSettings", ghb_int_value_new(2)); } else { - ghb_dict_insert(dict, g_strdup("UsesPictureSettings"), - ghb_int_value_new(1)); + ghb_dict_insert(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, g_strdup("VideoQualityType"), - ghb_int_value_new(1)); + ghb_dict_insert(dict, "VideoQualityType", ghb_int_value_new(1)); } else if (constant) { - ghb_dict_insert(dict, g_strdup("VideoQualityType"), - ghb_int_value_new(2)); + ghb_dict_insert(dict, "VideoQualityType", ghb_int_value_new(2)); } if (ghb_value_boolean(preset_dict_get_value(dict, "VideoFramerateCFR"))) { - ghb_dict_insert(dict, g_strdup("VideoFramerateMode"), + ghb_dict_insert(dict, "VideoFramerateMode", ghb_string_value_new("cfr")); } else if (ghb_value_boolean(preset_dict_get_value(dict, "VideoFrameratePFR"))) { - ghb_dict_insert(dict, g_strdup("VideoFramerateMode"), + ghb_dict_insert(dict, "VideoFramerateMode", ghb_string_value_new("pfr")); } else { - ghb_dict_insert(dict, g_strdup("VideoFramerateMode"), + ghb_dict_insert(dict, "VideoFramerateMode", ghb_string_value_new("vfr")); } if (ghb_value_int(preset_dict_get_value(dict, "PictureDeblock")) < 5) { - ghb_dict_insert(dict, g_strdup("PictureDeblock"), ghb_int_value_new(0)); + ghb_dict_insert(dict, "PictureDeblock", ghb_int_value_new(0)); } - GValue *alist, *adict; + GhbValue *alist, *adict; gint count, ii; alist = ghb_dict_lookup(dict, "AudioList"); @@ -2858,7 +2858,7 @@ export_xlat_preset(GValue *dict) preset_dict_get_value(adict, "AudioTrackDRCSlider")); if (drc < 1.0) { - ghb_dict_insert(adict, g_strdup("AudioTrackDRCSlider"), + ghb_dict_insert(adict, "AudioTrackDRCSlider", ghb_double_value_new(0.0)); } } @@ -2887,15 +2887,14 @@ export_xlat_preset(GValue *dict) g_string_append_printf(str, ",%s", "zerolatency"); } tunes = g_string_free(str, FALSE); - ghb_dict_insert(dict, g_strdup("VideoTune"), - ghb_string_value_new(tunes)); + ghb_dict_insert(dict, "VideoTune", ghb_string_value_new(tunes)); g_free(tunes); } // Remove everything from dist that isn't in "Presets" - GValue *internal; - GValue *internalPlist = ghb_resource_get("internal-defaults"); + GhbValue *internal; + GhbValue *internalPlist = ghb_resource_get("internal-defaults"); internal = plist_get_dict(internalPlist, "Presets"); dict_clean(dict, internal); @@ -2903,10 +2902,10 @@ export_xlat_preset(GValue *dict) } static void -export_xlat_presets(GValue *presets) +export_xlat_presets(GhbValue *presets) { gint count, ii; - GValue *dict; + GhbValue *dict; gboolean folder; if (presets == NULL) return; @@ -2917,7 +2916,7 @@ export_xlat_presets(GValue *presets) folder = ghb_value_boolean(preset_dict_get_value(dict, "Folder")); if (folder) { - GValue *nested; + GhbValue *nested; nested = ghb_dict_lookup(dict, "ChildrenArray"); export_xlat_presets(nested); @@ -2942,7 +2941,7 @@ delayed_store_prefs(gpointer data) static void store_presets() { - GValue *export; + GhbValue *export; export = ghb_value_dup(presetsPlist); export_xlat_presets(export); @@ -2969,7 +2968,7 @@ store_prefs(void) void ghb_presets_reload(signal_user_data_t *ud) { - GValue *std_presets; + GhbValue *std_presets; gint count, ii; int *indices, len; @@ -2988,13 +2987,13 @@ ghb_presets_reload(signal_user_data_t *ud) count = ghb_array_len(std_presets); for (ii = count-1; ii >= 0; ii--) { - GValue *std_dict; - GValue *copy_dict; + GhbValue *std_dict; + GhbValue *copy_dict; gint indices = 0; std_dict = ghb_array_get_nth(std_presets, ii); copy_dict = ghb_value_dup(std_dict); - ghb_dict_insert(copy_dict, g_strdup("PresetBuildNumber"), + ghb_dict_insert(copy_dict, "PresetBuildNumber", ghb_int64_value_new(hb_get_build(NULL))); ghb_presets_insert(presetsPlist, copy_dict, &indices, 1); presets_list_insert(ud, &indices, 1); @@ -3005,15 +3004,15 @@ ghb_presets_reload(signal_user_data_t *ud) } static gboolean -check_old_presets(GValue *presetsArray) +check_old_presets(GhbValue *presetsArray) { gint count, ii; count = ghb_array_len(presetsArray); for (ii = count-1; ii >= 0; ii--) { - GValue *dict; - GValue *type; + GhbValue *dict; + GhbValue *type; dict = ghb_array_get_nth(presetsArray, ii); type = ghb_dict_lookup(dict, "Type"); @@ -3024,9 +3023,9 @@ check_old_presets(GValue *presetsArray) } static void -replace_standard_presets(GValue *presetsArray) +replace_standard_presets(GhbValue *presetsArray) { - GValue *std_presets, *tmp; + GhbValue *std_presets, *tmp; int *indices, len; gint count, ii; @@ -3034,7 +3033,7 @@ replace_standard_presets(GValue *presetsArray) count = ghb_array_len(presetsArray); for (ii = count-1; ii >= 0; ii--) { - GValue *dict; + GhbValue *dict; gint ptype; dict = ghb_array_get_nth(presetsArray, ii); @@ -3064,13 +3063,13 @@ replace_standard_presets(GValue *presetsArray) count = ghb_array_len(std_presets); for (ii = count-1; ii >= 0; ii--) { - GValue *std_dict; - GValue *copy_dict; + GhbValue *std_dict; + GhbValue *copy_dict; gint indices = 0; std_dict = ghb_array_get_nth(std_presets, ii); copy_dict = ghb_value_dup(std_dict); - ghb_dict_insert(copy_dict, g_strdup("PresetBuildNumber"), + ghb_dict_insert(copy_dict, "PresetBuildNumber", ghb_int64_value_new(hb_get_build(NULL))); ghb_presets_insert(presetsArray, copy_dict, &indices, 1); } @@ -3078,15 +3077,15 @@ replace_standard_presets(GValue *presetsArray) } static int -update_standard_presets(signal_user_data_t *ud, GValue *presetsArray) +update_standard_presets(signal_user_data_t *ud, GhbValue *presetsArray) { gint count, ii; count = ghb_array_len(presetsArray); for (ii = count-1; ii >= 0; ii--) { - GValue *dict; - const GValue *gval; + GhbValue *dict; + const GhbValue *gval; gint64 build; gint type; @@ -3128,7 +3127,7 @@ ghb_presets_load(signal_user_data_t *ud) gboolean store = FALSE; presetsPlistFile = load_plist("presets"); if ((presetsPlistFile == NULL) || - (G_VALUE_TYPE(presetsPlistFile) == ghb_dict_get_type()) || + (ghb_value_type(presetsPlistFile) == GHB_DICT) || (check_old_presets(presetsPlistFile))) { presetsPlistFile = ghb_resource_get("standard-presets"); @@ -3146,18 +3145,18 @@ ghb_presets_load(signal_user_data_t *ud) } static void -settings_save(signal_user_data_t *ud, const GValue *path) +settings_save(signal_user_data_t *ud, const GhbValue *path) { - GValue *dict; + GhbValue *dict; gint *indices, len, count; const gchar *name; gboolean replace = FALSE; g_debug("settings_save"); - GValue *internalPlist = ghb_resource_get("internal-defaults"); + GhbValue *internalPlist = ghb_resource_get("internal-defaults"); if (internalPlist == NULL) return; count = ghb_array_len(path); - name = g_value_get_string(ghb_array_get_nth(path, count-1)); + name = ghb_value_const_string(ghb_array_get_nth(path, count-1)); indices = ghb_preset_indices_from_path(presetsPlist, path, &len); if (indices) { @@ -3197,7 +3196,7 @@ settings_save(signal_user_data_t *ud, const GValue *path) ghb_settings_set_int64(dict, "Type", PRESETS_CUSTOM); ghb_settings_set_int64(dict, "PresetBuildNumber", hb_get_build(NULL)); - ghb_dict_insert(dict, g_strdup("PresetName"), ghb_string_value_new(name)); + ghb_dict_insert(dict, "PresetName", ghb_string_value_new(name)); if (replace) { gint *def_indices, def_len; @@ -3205,16 +3204,14 @@ settings_save(signal_user_data_t *ud, const GValue *path) if (def_indices != NULL && preset_path_cmp(indices, len, def_indices, def_len) != 0) { - ghb_dict_insert(dict, g_strdup("Default"), - ghb_boolean_value_new(FALSE)); + ghb_dict_insert(dict, "Default", ghb_boolean_value_new(FALSE)); } presets_list_update_item(ud, indices, len, FALSE); g_free(def_indices); } else { - ghb_dict_insert(dict, g_strdup("Default"), - ghb_boolean_value_new(FALSE)); + ghb_dict_insert(dict, "Default", ghb_boolean_value_new(FALSE)); presets_list_insert(ud, indices, len); } if (!ghb_settings_get_boolean(ud->settings, "PictureWidthEnable")) @@ -3225,7 +3222,7 @@ settings_save(signal_user_data_t *ud, const GValue *path) { ghb_dict_remove(dict, "PictureHeight"); } - ghb_dict_insert(dict, g_strdup("autoscale"), + ghb_dict_insert(dict, "autoscale", ghb_boolean_value_new( !ghb_settings_get_boolean(ud->settings, "PictureWidthEnable") && !ghb_settings_get_boolean(ud->settings, "PictureHeightEnable") @@ -3243,14 +3240,14 @@ settings_save(signal_user_data_t *ud, const GValue *path) } static void -folder_save(signal_user_data_t *ud, const GValue *path) +folder_save(signal_user_data_t *ud, const GhbValue *path) { - GValue *dict, *folder; + GhbValue *dict, *folder; gint *indices, len, count; const gchar *name; count = ghb_array_len(path); - name = g_value_get_string(ghb_array_get_nth(path, count-1)); + name = ghb_value_const_string(ghb_array_get_nth(path, count-1)); indices = ghb_preset_indices_from_path(presetsPlist, path, &len); if (indices) { @@ -3271,7 +3268,7 @@ folder_save(signal_user_data_t *ud, const GValue *path) } // Already exists, update its description dict = presets_get_dict(presetsPlist, indices, len); - ghb_dict_insert(dict, g_strdup("PresetDescription"), + ghb_dict_insert(dict, "PresetDescription", ghb_value_dup(preset_dict_get_value( ud->settings, "PresetDescription"))); presets_list_update_item(ud, indices, len, FALSE); @@ -3293,15 +3290,14 @@ folder_save(signal_user_data_t *ud, const GValue *path) return; } } - ghb_dict_insert(dict, g_strdup("PresetDescription"), + ghb_dict_insert(dict, "PresetDescription", ghb_value_dup(preset_dict_get_value( ud->settings, "PresetDescription"))); - ghb_dict_insert(dict, g_strdup("PresetName"), ghb_string_value_new(name)); + ghb_dict_insert(dict, "PresetName", ghb_string_value_new(name)); folder = ghb_array_value_new(8); - ghb_dict_insert(dict, g_strdup("ChildrenArray"), folder); - ghb_dict_insert(dict, g_strdup("Type"), - ghb_int64_value_new(PRESETS_CUSTOM)); - ghb_dict_insert(dict, g_strdup("Folder"), ghb_boolean_value_new(TRUE)); + 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)); presets_list_insert(ud, indices, len); g_free(indices); @@ -3371,8 +3367,8 @@ static void update_subtitle_presets(signal_user_data_t *ud) { g_debug("update_subtitle_presets"); - const GValue *subtitle_list, *subtitle; - GValue *slist, *dict; + const GhbValue *subtitle_list, *subtitle; + GhbValue *slist, *dict; gint count, ii, source; subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list"); @@ -3430,7 +3426,7 @@ preset_import_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) gtk_widget_hide(dialog); if (response == GTK_RESPONSE_ACCEPT) { - GValue *dict, *array; + GhbValue *dict, *array; gchar *dir; gint count, ii; @@ -3452,7 +3448,7 @@ preset_import_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) count = ghb_array_len(array); for (ii = 0; ii < count; ii++) { - GValue *path, *name; + GhbValue *path, *name; gint *indices, len; gint index = 1; @@ -3478,7 +3474,7 @@ 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, g_strdup("PresetName"), ghb_value_dup(name)); + ghb_dict_insert(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); @@ -3501,7 +3497,7 @@ preset_import_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) gtk_widget_destroy(dialog); } -GValue* +GhbValue* get_selected_path(signal_user_data_t *ud) { GtkTreeView *treeview; @@ -3515,7 +3511,7 @@ get_selected_path(signal_user_data_t *ud) { GtkTreePath *treepath; gint *indices, len; - GValue *path; + GhbValue *path; treepath = gtk_tree_model_get_path(store, &iter); indices = gtk_tree_path_get_indices(treepath); @@ -3532,7 +3528,7 @@ preset_export_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) { GtkWidget *dialog; GtkResponseType response; - GValue *preset; + GhbValue *preset; const gchar *name = ""; gint count, *indices, len; const gchar *exportDir; @@ -3550,7 +3546,7 @@ preset_export_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) return; } - name = g_value_get_string(ghb_array_get_nth(preset, count-1)); + name = ghb_value_const_string(ghb_array_get_nth(preset, count-1)); dialog = gtk_file_chooser_dialog_new(_("Export Preset"), NULL, GTK_FILE_CHOOSER_ACTION_SAVE, @@ -3579,7 +3575,7 @@ preset_export_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) gtk_widget_hide(dialog); if (response == GTK_RESPONSE_ACCEPT) { - GValue *export, *dict, *array; + GhbValue *export, *dict, *array; FILE *file; gchar *dir; @@ -3625,7 +3621,7 @@ presets_new_folder_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) GtkEntry *entry; GtkTextView *desc; GtkResponseType response; - GValue *preset, *dict; + GhbValue *preset, *dict; const gchar *name = ""; const gchar *description = ""; gint count, *indices, len; @@ -3634,7 +3630,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 = g_value_get_string(ghb_array_get_nth(preset, count-1)); + name = ghb_value_const_string(ghb_array_get_nth(preset, count-1)); else count = 1; @@ -3642,7 +3638,7 @@ presets_new_folder_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) dict = presets_get_dict(presetsPlist, indices, len); if (dict != NULL) { - description = g_value_get_string( + description = ghb_value_const_string( ghb_dict_lookup(dict, "PresetDescription")); ghb_ui_update(ud, "FolderDescription", ghb_string_value(description)); } @@ -3657,7 +3653,7 @@ presets_new_folder_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) { // save the preset const gchar *name = gtk_entry_get_text(entry); - GValue *dest; + GhbValue *dest; if (count > MAX_NESTED_PRESET-1) count = MAX_NESTED_PRESET-1; @@ -3674,7 +3670,7 @@ presets_new_folder_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) } } ghb_array_append(dest, ghb_string_value_new(name)); - GValue *val = ghb_widget_value(GTK_WIDGET(desc)); + GhbValue *val = ghb_widget_value(GTK_WIDGET(desc)); ghb_settings_set_value(ud->settings, "PresetDescription", val); folder_save(ud, dest); ghb_value_free(dest); @@ -3690,7 +3686,7 @@ presets_save_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) GtkEntry *entry; GtkTextView *desc; GtkResponseType response; - GValue *preset; + GhbValue *preset; const gchar *name = ""; gint count, *indices, len; @@ -3701,7 +3697,7 @@ presets_save_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) count = ghb_array_len(preset); if (count > 0) - name = g_value_get_string(ghb_array_get_nth(preset, count-1)); + name = ghb_value_const_string(ghb_array_get_nth(preset, count-1)); else count = 1; @@ -3730,7 +3726,7 @@ presets_save_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) { // save the preset const gchar *name = gtk_entry_get_text(entry); - GValue *dest; + GhbValue *dest; dest = ghb_array_value_new(MAX_NESTED_PRESET); indices = ghb_preset_indices_from_path(presetsPlist, preset, &len); @@ -3765,7 +3761,7 @@ preset_type_changed_cb(GtkWidget *widget, signal_user_data_t *ud) G_MODULE_EXPORT void presets_restore_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) { - GValue *preset; + GhbValue *preset; g_debug("presets_restore_clicked_cb ()"); // Reload only the standard presets @@ -3866,7 +3862,7 @@ presets_drag_motion_cb( GtkTreeSelection *select; gint src_ptype, dst_ptype; gboolean src_folder, dst_folder; - GValue *preset; + GhbValue *preset; gint tree_depth, ii; GtkWidget *widget; @@ -3991,7 +3987,7 @@ presets_drag_cb( GtkTreeModel *srcmodel; GtkTreeSelection *select; GtkTreePath *srcpath = NULL; - GValue *preset; + GhbValue *preset; gint tree_depth, ii; srcwidget = GTK_TREE_VIEW(gtk_drag_get_source_widget(dc)); @@ -4104,7 +4100,7 @@ presets_row_expanded_cb( { gint *indices, len; gboolean expanded, folder; - GValue *dict; + GhbValue *dict; expanded = gtk_tree_view_row_expanded(treeview, path); indices = gtk_tree_path_get_indices(path); @@ -4130,7 +4126,7 @@ presets_row_expanded_cb( // Collapsing parent folder collapses all children if (!expanded) { - GValue *presets = NULL; + GhbValue *presets = NULL; gint *more_indices, count, ii; more_indices = g_malloc((len+1)*sizeof(gint)); @@ -4153,14 +4149,14 @@ presets_row_expanded_cb( store_presets(); } -GValue* +GhbValue* ghb_get_current_preset(signal_user_data_t *ud) { GtkTreeView *tv; GtkTreeModel *tm; GtkTreeSelection *ts; GtkTreeIter ti; - GValue *preset = NULL; + GhbValue *preset = NULL; tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "presets_list")); ts = gtk_tree_view_get_selection(tv); @@ -4178,14 +4174,14 @@ ghb_get_current_preset(signal_user_data_t *ud) return preset; } -GValue* +GhbValue* ghb_get_current_preset_path(signal_user_data_t *ud) { GtkTreeView *tv; GtkTreeModel *tm; GtkTreeSelection *ts; GtkTreeIter ti; - GValue *path = NULL; + GhbValue *path = NULL; tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "presets_list")); ts = gtk_tree_view_get_selection(tv); @@ -4279,7 +4275,7 @@ presets_frame_size_allocate_cb(GtkWidget *widget, GtkAllocation *allocation, sig G_MODULE_EXPORT void presets_default_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) { - GValue *preset; + GhbValue *preset; gint *indices, len; g_debug("presets_default_clicked_cb ()"); @@ -4310,8 +4306,8 @@ preset_edited_cb( GtkTreeView *treeview; GtkTreeIter iter; gint *indices, len, count; - GValue *dict; - GValue *preset, *dest; + GhbValue *dict; + GhbValue *preset, *dest; g_debug("preset_edited_cb ()"); g_debug("path (%s)", path); @@ -4341,7 +4337,7 @@ preset_edited_cb( gtk_tree_store_set(store, &iter, 0, text, -1); dict = presets_get_dict(presetsPlist, indices, len); - ghb_dict_insert(dict, g_strdup("PresetName"), ghb_string_value_new(text)); + ghb_dict_insert(dict, "PresetName", ghb_string_value_new(text)); store_presets(); gtk_tree_path_free (treepath); ghb_value_free(preset); diff --git a/gtk/src/presets.h b/gtk/src/presets.h index add5eac2b..f3bbaf0cb 100644 --- a/gtk/src/presets.h +++ b/gtk/src/presets.h @@ -16,40 +16,42 @@ #if !defined(_GHB_PRESETS_H_) #define _GHB_PRESETS_H_ +#include "values.h" + void ghb_settings_save(signal_user_data_t *ud, const gchar *name); void ghb_presets_load(signal_user_data_t *ud); void ghb_update_from_preset(signal_user_data_t *ud, const gchar *key); -void ghb_settings_init(GValue *settings, const char *name); +void ghb_settings_init(GhbValue *settings, const char *name); void ghb_settings_close(); void ghb_globals_to_ui(signal_user_data_t *ud); void ghb_prefs_load(signal_user_data_t *ud); void ghb_prefs_to_ui(signal_user_data_t *ud); -void ghb_prefs_save(GValue *settings); -void ghb_pref_save(GValue *settings, const gchar *key); -void ghb_pref_set(GValue *settings, const gchar *key); +void ghb_prefs_save(GhbValue *settings); +void ghb_pref_save(GhbValue *settings, const gchar *key); +void ghb_pref_set(GhbValue *settings, const gchar *key); void ghb_prefs_store(void); -void ghb_save_queue(GValue *queue); -GValue* ghb_load_queue(); -GValue* ghb_load_old_queue(int pid); +void ghb_save_queue(GhbValue *queue); +GhbValue* ghb_load_queue(); +GhbValue* ghb_load_old_queue(int pid); void ghb_remove_queue_file(void); void ghb_remove_old_queue_file(int pid); gchar* ghb_get_user_config_dir(gchar *subdir); -void ghb_settings_to_ui(signal_user_data_t *ud, GValue *dict); +void ghb_settings_to_ui(signal_user_data_t *ud, GhbValue *dict); void ghb_clear_presets_selection(signal_user_data_t *ud); -void ghb_select_preset(GtkBuilder *builder, const GValue *preset); +void ghb_select_preset(GtkBuilder *builder, const GhbValue *preset); void ghb_select_default_preset(GtkBuilder *builder); void ghb_presets_list_init(signal_user_data_t *ud, gint *indices, gint len); -GValue* ghb_parse_preset_path(const gchar *path); -gchar* ghb_preset_path_string(const GValue *path); +GhbValue* ghb_parse_preset_path(const gchar *path); +gchar* ghb_preset_path_string(const GhbValue *path); gboolean ghb_preset_is_custom(void); gboolean ghb_lock_file(const gchar *name); int ghb_find_pid_file(); void ghb_unlink_pid_file(int pid); void ghb_write_pid_file(); -GValue* ghb_get_current_preset(signal_user_data_t *ud); -GValue* ghb_get_current_preset_path(signal_user_data_t *ud); -void ghb_preset_to_settings(GValue *settings, GValue *preset); -void ghb_prefs_to_settings(GValue *settings); -void dump_preset_path(const gchar *msg, const GValue *path); +GhbValue* ghb_get_current_preset(signal_user_data_t *ud); +GhbValue* ghb_get_current_preset_path(signal_user_data_t *ud); +void ghb_preset_to_settings(GhbValue *settings, GhbValue *preset); +void ghb_prefs_to_settings(GhbValue *settings); +void dump_preset_path(const gchar *msg, const GhbValue *path); #endif // _GHB_PRESETS_H_ diff --git a/gtk/src/preview.c b/gtk/src/preview.c index b57d7c1a8..b53c697c4 100644 --- a/gtk/src/preview.c +++ b/gtk/src/preview.c @@ -758,7 +758,7 @@ live_preview_start_cb(GtkWidget *xwidget, signal_user_data_t *ud) } else { - GValue *js; + GhbValue *js; ud->preview->encode_frame = frame; js = ghb_value_dup(ud->settings); diff --git a/gtk/src/queuehandler.c b/gtk/src/queuehandler.c index 4fcabefa3..c3457989e 100644 --- a/gtk/src/queuehandler.c +++ b/gtk/src/queuehandler.c @@ -67,7 +67,7 @@ queue_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_t } static void -add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter) +add_to_queue_list(signal_user_data_t *ud, GhbValue *settings, GtkTreeIter *piter) { GtkTreeView *treeview; GtkTreeIter iter; @@ -171,7 +171,7 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter) gchar *preset; gboolean markers; gboolean preset_modified; - const GValue *path; + const GhbValue *path; const char *mux_id; const hb_container_t *mux; @@ -546,7 +546,7 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter) // Source description, Encoder, Mix, Samplerate, Bitrate // ... gint count, ii; - const GValue *audio_list; + const GhbValue *audio_list; audio_list = ghb_settings_get_value(settings, "audio_list"); count = ghb_array_len(audio_list); @@ -561,7 +561,7 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter) for (ii = 0; ii < count; ii++) { gchar *quality = NULL, *track; - GValue *asettings; + GhbValue *asettings; const hb_encoder_t *audio_encoder; asettings = ghb_array_get_nth(audio_list, ii); @@ -607,7 +607,7 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter) // Subtitle Tracks: count // Subtitle description(Subtitle options) // ... - const GValue *sub_list; + const GhbValue *sub_list; sub_list = ghb_settings_get_value(settings, "subtitle_list"); count = ghb_array_len(sub_list); @@ -621,7 +621,7 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter) } for (ii = 0; ii < count; ii++) { - GValue *settings; + GhbValue *settings; gchar *track; gboolean force, burn, def; gint source; @@ -700,7 +700,7 @@ ghb_update_status(signal_user_data_t *ud, int status, int index) return; } - GValue *settings; + GhbValue *settings; settings = ghb_array_get_nth(ud->queue, index); if (settings == NULL) // should never happen return; @@ -740,12 +740,12 @@ static void save_queue_file(signal_user_data_t *ud) { int ii, count; - GValue *queue = ghb_value_dup(ud->queue); + GhbValue *queue = ghb_value_dup(ud->queue); count = ghb_array_len(queue); for (ii = 0; ii < count; ii++) { - GValue *settings = ghb_array_get_nth(ud->queue, ii); + GhbValue *settings = ghb_array_get_nth(ud->queue, ii); if (settings == NULL) continue; ghb_settings_set_int(settings, "job_status", GHB_QUEUE_PENDING); @@ -817,7 +817,7 @@ open_queue_file(signal_user_data_t *ud) return; } - GValue *queue; + GhbValue *queue; char *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog)); gtk_widget_destroy(dialog); @@ -830,7 +830,7 @@ open_queue_file(signal_user_data_t *ud) count = ghb_array_len(queue); for (ii = 0; ii < count; ii++) { - GValue *settings = ghb_array_get_nth(queue, ii); + GhbValue *settings = ghb_array_get_nth(queue, ii); ghb_array_remove(queue, ii); ghb_settings_set_int(settings, "job_status", GHB_QUEUE_PENDING); ghb_settings_set_int(settings, "job_unique_id", 0); @@ -900,7 +900,7 @@ queue_reload_clicked_cb(GtkWidget *widget, signal_user_data_t *ud) } static gboolean -validate_settings(signal_user_data_t *ud, GValue *settings, gint batch) +validate_settings(signal_user_data_t *ud, GhbValue *settings, gint batch) { // Check to see if the dest file exists or is // already in the queue @@ -920,7 +920,7 @@ validate_settings(signal_user_data_t *ud, GValue *settings, gint batch) count = ghb_array_len(ud->queue); for (ii = 0; ii < count; ii++) { - GValue *js; + GhbValue *js; const gchar *filename; js = ghb_array_get_nth(ud->queue, ii); @@ -1050,7 +1050,7 @@ validate_settings(signal_user_data_t *ud, GValue *settings, gint batch) } static gboolean -queue_add(signal_user_data_t *ud, GValue *settings, gint batch) +queue_add(signal_user_data_t *ud, GhbValue *settings, gint batch) { // Add settings to the queue g_debug("queue_add ()"); @@ -1084,7 +1084,7 @@ G_MODULE_EXPORT void queue_add_clicked_cb(GtkWidget *widget, signal_user_data_t *ud) { g_debug("queue_add_clicked_cb ()"); - GValue *settings = ghb_value_dup(ud->settings); + GhbValue *settings = ghb_value_dup(ud->settings); if (!queue_add(ud, settings, 0)) ghb_value_free(settings); // Validation of settings may have changed audio list @@ -1092,15 +1092,15 @@ queue_add_clicked_cb(GtkWidget *widget, signal_user_data_t *ud) } static gboolean -title_multiple_can_select(GValue *settings_array, int index) +title_multiple_can_select(GhbValue *settings_array, int index) { gint count, ii; - GValue *settings, *gdest; + GhbValue *settings, *gdest; const char *dest; settings = ghb_array_get_nth(settings_array, index); gdest = ghb_settings_get_value(settings, "destination"); - dest = g_value_get_string(gdest); + dest = ghb_value_const_string(gdest); if (dest == NULL) return FALSE; @@ -1112,7 +1112,7 @@ title_multiple_can_select(GValue *settings_array, int index) settings = ghb_array_get_nth(settings_array, ii); gdest = ghb_settings_get_value(settings, "destination"); - tmp = g_value_get_string(gdest); + tmp = ghb_value_const_string(gdest); if (tmp != NULL && !strncmp(dest, tmp, PATH_MAX)) return FALSE; } @@ -1244,7 +1244,7 @@ static void title_add_multiple_check_conflicts(signal_user_data_t *ud) { gint count, ii; - GValue *settings; + GhbValue *settings; GtkWidget *row; GtkListBox *list; GtkToggleButton *selected; @@ -1274,7 +1274,7 @@ G_MODULE_EXPORT void title_add_multiple_select_all_cb(GtkWidget *widget, signal_user_data_t *ud) { gint count, ii; - GValue *settings; + GhbValue *settings; GtkWidget *row; GtkListBox *list; GtkToggleButton *selected; @@ -1314,7 +1314,7 @@ G_MODULE_EXPORT void title_add_multiple_clear_all_cb(GtkWidget *widget, signal_user_data_t *ud) { gint count, ii; - GValue *settings; + GhbValue *settings; GtkWidget *row; GtkListBox *list; GtkToggleButton *selected; @@ -1355,7 +1355,7 @@ add_multiple_titles(signal_user_data_t *ud) count = ghb_array_len(ud->settings_array); for (ii = 0; ii < count; ii++) { - GValue *settings; + GhbValue *settings; settings = ghb_value_dup(ghb_array_get_nth(ud->settings_array, ii)); if (ghb_settings_get_boolean(settings, "title_selected")) @@ -1378,7 +1378,7 @@ title_get_row(GtkWidget *widget) G_MODULE_EXPORT void title_selected_cb(GtkWidget *widget, signal_user_data_t *ud) { - GValue *settings; + GhbValue *settings; gboolean selected; GtkToggleButton *select_all; GtkToggleButton *clear_all; @@ -1411,7 +1411,7 @@ title_selected_cb(GtkWidget *widget, signal_user_data_t *ud) G_MODULE_EXPORT void title_dest_file_cb(GtkWidget *widget, signal_user_data_t *ud) { - GValue *settings; + GhbValue *settings; gchar *dest_file, *dest_dir, *dest; GtkListBoxRow * row = title_get_row(widget); if (row == NULL) @@ -1445,7 +1445,7 @@ title_dest_file_cb(GtkWidget *widget, signal_user_data_t *ud) G_MODULE_EXPORT void title_dest_dir_cb(GtkWidget *widget, signal_user_data_t *ud) { - GValue *settings; + GhbValue *settings; gchar *dest_file, *dest_dir, *dest; GtkListBoxRow * row = title_get_row(widget); if (row == NULL) @@ -1555,7 +1555,7 @@ queue_add_multiple_clicked_cb(GtkWidget *widget, signal_user_data_t *ud) count = ghb_array_len(ud->settings_array); for (ii = 0; ii < count; ii++) { - GValue *settings; + GhbValue *settings; GtkLabel *label; GtkEntry *entry; GtkFileChooser *chooser; @@ -1650,7 +1650,7 @@ queue_remove_clicked_cb(GtkWidget *widget, gchar *path, signal_user_data_t *ud) gint row; gint *indices; gint unique_id; - GValue *settings; + GhbValue *settings; gint status; g_debug("queue_remove_clicked_cb ()"); @@ -1684,7 +1684,7 @@ queue_remove_clicked_cb(GtkWidget *widget, gchar *path, signal_user_data_t *ud) // Remove the selected item gtk_tree_store_remove(GTK_TREE_STORE(store), &iter); // Remove the corresponding item from the queue list - GValue *old = ghb_array_get_nth(ud->queue, row); + GhbValue *old = ghb_array_get_nth(ud->queue, row); ghb_array_remove(ud->queue, row); ghb_value_free(old); ghb_save_queue(ud->queue); @@ -1697,9 +1697,9 @@ queue_remove_clicked_cb(GtkWidget *widget, gchar *path, signal_user_data_t *ud) } static gint -find_last_finished(GValue *queue) +find_last_finished(GhbValue *queue) { - GValue *js; + GhbValue *js; gint ii, count; gint status; @@ -1733,7 +1733,7 @@ queue_drag_motion_cb( GtkTreePath *path = NULL; GtkTreeViewDropPosition pos; gint *indices, row, status, finished; - GValue *js; + GhbValue *js; GtkTreeIter iter; GtkTreeView *srctv; GtkTreeModel *model; @@ -1818,7 +1818,7 @@ queue_drag_cb( GtkTreeViewDropPosition pos; GtkTreeIter dstiter, srciter; gint *indices, row; - GValue *js; + GhbValue *js; GtkTreeModel *dstmodel = gtk_tree_view_get_model(dstwidget); @@ -2019,7 +2019,7 @@ queue_list_size_allocate_cb(GtkWidget *widget, GtkAllocation *allocation, GtkCel G_MODULE_EXPORT void queue_start_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) { - GValue *js; + GhbValue *js; gboolean running = FALSE; gint count, ii; gint status; @@ -2050,7 +2050,7 @@ queue_start_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) { // The queue has no running or pending jobs. // Add current settings to the queue, then run. - GValue *settings = ghb_value_dup(ud->settings); + GhbValue *settings = ghb_value_dup(ud->settings); if (!queue_add(ud, settings, 0)) { ghb_value_free(settings); @@ -2075,12 +2075,12 @@ queue_pause_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) gboolean ghb_reload_queue(signal_user_data_t *ud) { - GValue *queue; + GhbValue *queue; gint unfinished = 0; gint count, ii; gint pid; gint status; - GValue *settings; + GhbValue *settings; gchar *message; g_debug("ghb_reload_queue"); @@ -2128,7 +2128,7 @@ find_pid: status = ghb_settings_get_int(settings, "job_status"); if (status == GHB_QUEUE_DONE || status == GHB_QUEUE_CANCELED) { - GValue *old = ghb_array_get_nth(queue, ii); + GhbValue *old = ghb_array_get_nth(queue, ii); ghb_value_free(old); ghb_array_remove(queue, ii); } @@ -2174,7 +2174,7 @@ ghb_queue_remove_row(signal_user_data_t *ud, int row) } g_free(path); - GValue *old = ghb_array_get_nth(ud->queue, row); + GhbValue *old = ghb_array_get_nth(ud->queue, row); ghb_value_free(old); ghb_array_remove(ud->queue, row); ghb_save_queue(ud->queue); @@ -2193,7 +2193,7 @@ queue_key_press_cb( gint row; gint *indices; gint unique_id; - GValue *settings; + GhbValue *settings; gint status; g_debug("queue_key_press_cb ()"); @@ -2232,7 +2232,7 @@ queue_key_press_cb( // Remove the selected item gtk_tree_store_remove(GTK_TREE_STORE(store), &iter); // Remove the corresponding item from the queue list - GValue *old = ghb_array_get_nth(ud->queue, row); + GhbValue *old = ghb_array_get_nth(ud->queue, row); ghb_value_free(old); ghb_array_remove(ud->queue, row); ghb_save_queue(ud->queue); @@ -2241,7 +2241,7 @@ queue_key_press_cb( return FALSE; } -GValue *ghb_queue_edit_settings = NULL; +GhbValue *ghb_queue_edit_settings = NULL; G_MODULE_EXPORT void queue_edit_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) diff --git a/gtk/src/resources.c b/gtk/src/resources.c index d0b5dee4b..7010202f1 100644 --- a/gtk/src/resources.c +++ b/gtk/src/resources.c @@ -25,7 +25,7 @@ static const gchar resource_str[] = #include "resource_data.h" ; -static GValue *resources; +static GhbValue *resources; void ghb_resource_init() @@ -33,10 +33,10 @@ ghb_resource_init() resources = ghb_plist_parse(resource_str, sizeof(resource_str)-1); } -GValue* +GhbValue* ghb_resource_get(const gchar *name) { - GValue *result; + GhbValue *result; result = ghb_dict_lookup(resources, name); return result; } diff --git a/gtk/src/resources.h b/gtk/src/resources.h index c9378acc4..85b8ab10b 100644 --- a/gtk/src/resources.h +++ b/gtk/src/resources.h @@ -16,8 +16,10 @@ #if !defined(_RESOURCES_H_) #define _RESOURCES_H_ +#include "values.h" + void ghb_resource_init(void); void ghb_resource_free(); -GValue* ghb_resource_get(const gchar *name); +GhbValue* ghb_resource_get(const gchar *name); #endif // _RESOURCES_H_ diff --git a/gtk/src/settings.c b/gtk/src/settings.c index 053f263da..91d95e761 100644 --- a/gtk/src/settings.c +++ b/gtk/src/settings.c @@ -21,7 +21,7 @@ #include "hb-backend.h" #include "values.h" -void dump_settings(GValue *settings); +void dump_settings(GhbValue *settings); void ghb_pref_audio_init(signal_user_data_t *ud); GObject* @@ -31,7 +31,7 @@ debug_get_object(GtkBuilder* b, const gchar *n) return gtk_builder_get_object(b, n); } -GValue* +GhbValue* ghb_settings_new() { return ghb_dict_value_new(); @@ -39,147 +39,147 @@ ghb_settings_new() void ghb_settings_set_value( - GValue *settings, + GhbValue *settings, const gchar *key, - const GValue *value) + const GhbValue *value) { if (key == NULL || value == NULL) return; - ghb_dict_insert(settings, g_strdup(key), ghb_value_dup(value)); + ghb_dict_insert(settings, key, ghb_value_dup(value)); } void -ghb_settings_take_value(GValue *settings, const gchar *key, GValue *value) +ghb_settings_take_value(GhbValue *settings, const gchar *key, GhbValue *value) { - ghb_dict_insert(settings, g_strdup(key), value); + ghb_dict_insert(settings, key, value); } void ghb_settings_set_string( - GValue *settings, + GhbValue *settings, const gchar *key, const gchar *sval) { - GValue *value; + GhbValue *value; value = ghb_string_value_new(sval); - ghb_dict_insert(settings, g_strdup(key), value); + ghb_dict_insert(settings, key, value); } void -ghb_settings_set_double(GValue *settings, const gchar *key, gdouble dval) +ghb_settings_set_double(GhbValue *settings, const gchar *key, gdouble dval) { - GValue *value; + GhbValue *value; value = ghb_double_value_new(dval); - ghb_dict_insert(settings, g_strdup(key), value); + ghb_dict_insert(settings, key, value); } void -ghb_settings_set_int64(GValue *settings, const gchar *key, gint64 ival) +ghb_settings_set_int64(GhbValue *settings, const gchar *key, gint64 ival) { - GValue *value; + GhbValue *value; value = ghb_int64_value_new(ival); - ghb_dict_insert(settings, g_strdup(key), value); + ghb_dict_insert(settings, key, value); } void -ghb_settings_set_int(GValue *settings, const gchar *key, gint ival) +ghb_settings_set_int(GhbValue *settings, const gchar *key, gint ival) { - GValue *value; + GhbValue *value; value = ghb_int64_value_new((gint64)ival); - ghb_dict_insert(settings, g_strdup(key), value); + ghb_dict_insert(settings, key, value); } void -ghb_settings_set_boolean(GValue *settings, const gchar *key, gboolean bval) +ghb_settings_set_boolean(GhbValue *settings, const gchar *key, gboolean bval) { - GValue *value; + GhbValue *value; value = ghb_boolean_value_new(bval); - ghb_dict_insert(settings, g_strdup(key), value); + ghb_dict_insert(settings, key, value); } -GValue* -ghb_settings_get_value(const GValue *settings, const gchar *key) +GhbValue* +ghb_settings_get_value(const GhbValue *settings, const gchar *key) { - GValue *value; + GhbValue *value; value = ghb_dict_lookup(settings, key); if (value == NULL) - g_warning("returning null (%s)", key); + g_debug("returning null (%s)", key); return value; } gboolean -ghb_settings_get_boolean(const GValue *settings, const gchar *key) +ghb_settings_get_boolean(const GhbValue *settings, const gchar *key) { - const GValue* value; + const GhbValue* value; value = ghb_settings_get_value(settings, key); if (value == NULL) return FALSE; return ghb_value_boolean(value); } gint64 -ghb_settings_get_int64(const GValue *settings, const gchar *key) +ghb_settings_get_int64(const GhbValue *settings, const gchar *key) { - const GValue* value; + const GhbValue* value; value = ghb_settings_get_value(settings, key); if (value == NULL) return 0; return ghb_value_int64(value); } gint -ghb_settings_get_int(const GValue *settings, const gchar *key) +ghb_settings_get_int(const GhbValue *settings, const gchar *key) { - const GValue* value; + const GhbValue* value; value = ghb_settings_get_value(settings, key); if (value == NULL) return 0; return ghb_value_int(value); } gdouble -ghb_settings_get_double(const GValue *settings, const gchar *key) +ghb_settings_get_double(const GhbValue *settings, const gchar *key) { - const GValue* value; + const GhbValue* value; value = ghb_settings_get_value(settings, key); if (value == NULL) return 0; return ghb_value_double(value); } const gchar* -ghb_settings_get_const_string(const GValue *settings, const gchar *key) +ghb_settings_get_const_string(const GhbValue *settings, const gchar *key) { - const GValue* value; + const GhbValue* value; value = ghb_settings_get_value(settings, key); - return g_value_get_string(value); + return ghb_value_const_string(value); } gchar* -ghb_settings_get_string(const GValue *settings, const gchar *key) +ghb_settings_get_string(const GhbValue *settings, const gchar *key) { - const GValue* value; + const GhbValue* value; value = ghb_settings_get_value(settings, key); if (value == NULL) return g_strdup(""); return ghb_value_string(value); } gint -ghb_settings_combo_int(const GValue *settings, const gchar *key) +ghb_settings_combo_int(const GhbValue *settings, const gchar *key) { return ghb_lookup_combo_int(key, ghb_settings_get_value(settings, key)); } gdouble -ghb_settings_combo_double(const GValue *settings, const gchar *key) +ghb_settings_combo_double(const GhbValue *settings, const gchar *key) { return ghb_lookup_combo_double(key, ghb_settings_get_value(settings, key)); } const gchar* -ghb_settings_combo_option(const GValue *settings, const gchar *key) +ghb_settings_combo_option(const GhbValue *settings, const gchar *key) { return ghb_lookup_combo_option(key, ghb_settings_get_value(settings, key)); } const gchar* -ghb_settings_combo_string(const GValue *settings, const gchar *key) +ghb_settings_combo_string(const GhbValue *settings, const gchar *key) { return ghb_lookup_combo_string(key, ghb_settings_get_value(settings, key)); } @@ -209,10 +209,10 @@ ghb_get_setting_key(GtkWidget *widget) return name; } -GValue* +GhbValue* ghb_widget_value(GtkWidget *widget) { - GValue *value = NULL; + GhbValue *value = NULL; const gchar *name; GType type; @@ -363,7 +363,7 @@ ghb_widget_value(GtkWidget *widget) gchar* ghb_widget_string(GtkWidget *widget) { - GValue *value; + GhbValue *value; gchar *sval; value = ghb_widget_value(widget); @@ -375,7 +375,7 @@ ghb_widget_string(GtkWidget *widget) gdouble ghb_widget_double(GtkWidget *widget) { - GValue *value; + GhbValue *value; gdouble dval; value = ghb_widget_value(widget); @@ -387,7 +387,7 @@ ghb_widget_double(GtkWidget *widget) gint64 ghb_widget_int64(GtkWidget *widget) { - GValue *value; + GhbValue *value; gint64 ival; value = ghb_widget_value(widget); @@ -399,7 +399,7 @@ ghb_widget_int64(GtkWidget *widget) gint ghb_widget_int(GtkWidget *widget) { - GValue *value; + GhbValue *value; gint ival; value = ghb_widget_value(widget); @@ -411,7 +411,7 @@ ghb_widget_int(GtkWidget *widget) gint ghb_widget_boolean(GtkWidget *widget) { - GValue *value; + GhbValue *value; gboolean bval; value = ghb_widget_value(widget); @@ -421,10 +421,10 @@ ghb_widget_boolean(GtkWidget *widget) } void -ghb_widget_to_setting(GValue *settings, GtkWidget *widget) +ghb_widget_to_setting(GhbValue *settings, GtkWidget *widget) { const gchar *key = NULL; - GValue *value; + GhbValue *value; if (widget == NULL) return; g_debug("ghb_widget_to_setting"); @@ -443,16 +443,16 @@ ghb_widget_to_setting(GValue *settings, GtkWidget *widget) } void -ghb_update_widget(GtkWidget *widget, const GValue *value) +ghb_update_widget(GtkWidget *widget, const GhbValue *value) { - GType type; + GhbType type; gchar *str, *tmp; gint ival; gdouble dval; const char *name = ghb_get_setting_key(widget); - type = G_VALUE_TYPE(value); - if (type == ghb_array_get_type() || type == ghb_dict_get_type()) + type = ghb_value_type(value); + if (type == GHB_ARRAY || type == GHB_DICT) return; if (value == NULL) return; str = tmp = ghb_value_string(value); @@ -618,10 +618,10 @@ ghb_update_widget(GtkWidget *widget, const GValue *value) } int -ghb_ui_update_from_settings(signal_user_data_t *ud, const gchar *name, const GValue *settings) +ghb_ui_update_from_settings(signal_user_data_t *ud, const gchar *name, const GhbValue *settings) { GObject *object; - GValue * value; + GhbValue * value; g_debug("ghb_ui_update_from_settings() %s", name); if (name == NULL) @@ -643,7 +643,7 @@ ghb_ui_update_from_settings(signal_user_data_t *ud, const gchar *name, const GVa } int -ghb_ui_update(signal_user_data_t *ud, const gchar *name, const GValue *value) +ghb_ui_update(signal_user_data_t *ud, const gchar *name, const GhbValue *value) { GObject *object; @@ -666,9 +666,9 @@ ghb_ui_update(signal_user_data_t *ud, const gchar *name, const GValue *value) int ghb_ui_settings_update( signal_user_data_t *ud, - GValue *settings, + GhbValue *settings, const gchar *name, - const GValue *value) + const GhbValue *value) { GObject *object; diff --git a/gtk/src/settings.h b/gtk/src/settings.h index 2367bcb6a..895e4fbe6 100644 --- a/gtk/src/settings.h +++ b/gtk/src/settings.h @@ -17,6 +17,7 @@ #define _SETTINGS_H_ #include <gtk/gtk.h> +#include "values.h" #define GHB_WIDGET(b,n) GTK_WIDGET(gtk_builder_get_object ((b), (n))) //#define GHB_WIDGET(b,n) GTK_WIDGET(debug_get_object((b), (n))) @@ -55,13 +56,13 @@ typedef struct gboolean scale_busy; gint cancel_encode; GtkBuilder *builder; - GValue *x264_priv; - GValue *globals; - GValue *prefs; - GValue *settings; - GValue *settings_array; - GValue *queue; - GValue *current_job; + GhbValue *x264_priv; + GhbValue *globals; + GhbValue *prefs; + GhbValue *settings; + GhbValue *settings_array; + GhbValue *queue; + GhbValue *current_job; GIOChannel *activity_log; GIOChannel *job_activity_log; preview_t *preview; @@ -79,49 +80,49 @@ enum GHB_QUEUE_DONE, }; -GValue* ghb_settings_new(void); +GhbValue* ghb_settings_new(void); void ghb_settings_take_value( - GValue *settings, const gchar *key, GValue *value); + GhbValue *settings, const gchar *key, GhbValue *value); void ghb_settings_set_value( - GValue *settings, const gchar *key, const GValue *value); + GhbValue *settings, const gchar *key, const GhbValue *value); void ghb_settings_set_string( - GValue *settings, const gchar *key, const gchar *sval); -void ghb_settings_set_double(GValue *settings, const gchar *key, gdouble dval); -void ghb_settings_set_int64(GValue *settings, const gchar *key, gint64 ival); -void ghb_settings_set_int(GValue *settings, const gchar *key, gint ival); + GhbValue *settings, const gchar *key, const gchar *sval); +void ghb_settings_set_double(GhbValue *settings, const gchar *key, gdouble dval); +void ghb_settings_set_int64(GhbValue *settings, const gchar *key, gint64 ival); +void ghb_settings_set_int(GhbValue *settings, const gchar *key, gint ival); void ghb_settings_set_boolean( - GValue *settings, const gchar *key, gboolean bval); + GhbValue *settings, const gchar *key, gboolean bval); void ghb_settings_copy( - GValue *settings, const gchar *key, const GValue *value); -GValue* ghb_settings_get_value(const GValue *settings, const gchar *key); -gboolean ghb_settings_get_boolean(const GValue *settings, const gchar *key); -gint64 ghb_settings_get_int64(const GValue *settings, const gchar *key); -gint ghb_settings_get_int(const GValue *settings, const gchar *key); -gdouble ghb_settings_get_double(const GValue *settings, const gchar *key); -gchar* ghb_settings_get_string(const GValue *settings, const gchar *key); + GhbValue *settings, const gchar *key, const GhbValue *value); +GhbValue* ghb_settings_get_value(const GhbValue *settings, const gchar *key); +gboolean ghb_settings_get_boolean(const GhbValue *settings, const gchar *key); +gint64 ghb_settings_get_int64(const GhbValue *settings, const gchar *key); +gint ghb_settings_get_int(const GhbValue *settings, const gchar *key); +gdouble ghb_settings_get_double(const GhbValue *settings, const gchar *key); +gchar* ghb_settings_get_string(const GhbValue *settings, const gchar *key); const gchar* ghb_settings_get_const_string( - const GValue *settings, const gchar *key); -gint ghb_settings_combo_int(const GValue *settings, const gchar *key); -gdouble ghb_settings_combo_double(const GValue *settings, const gchar *key); -const gchar* ghb_settings_combo_option(const GValue *settings, const gchar *key); -const gchar* ghb_settings_combo_string(const GValue *settings, const gchar *key); + const GhbValue *settings, const gchar *key); +gint ghb_settings_combo_int(const GhbValue *settings, const gchar *key); +gdouble ghb_settings_combo_double(const GhbValue *settings, const gchar *key); +const gchar* ghb_settings_combo_option(const GhbValue *settings, const gchar *key); +const gchar* ghb_settings_combo_string(const GhbValue *settings, const gchar *key); -GValue* ghb_widget_value(GtkWidget *widget); +GhbValue* ghb_widget_value(GtkWidget *widget); gchar* ghb_widget_string(GtkWidget *widget); gdouble ghb_widget_double(GtkWidget *widget); gint64 ghb_widget_int64(GtkWidget *widget); gint ghb_widget_int(GtkWidget *widget); gint ghb_widget_boolean(GtkWidget *widget); -void ghb_widget_to_setting(GValue *settings, GtkWidget *widget); +void ghb_widget_to_setting(GhbValue *settings, GtkWidget *widget); int ghb_ui_update( - signal_user_data_t *ud, const gchar *name, const GValue *value); + signal_user_data_t *ud, const gchar *name, const GhbValue *value); int ghb_ui_update_from_settings( - signal_user_data_t *ud, const gchar *name, const GValue *settings); + signal_user_data_t *ud, const gchar *name, const GhbValue *settings); int ghb_ui_settings_update( - signal_user_data_t *ud, GValue *settings, const gchar *name, - const GValue *value); + signal_user_data_t *ud, GhbValue *settings, const gchar *name, + const GhbValue *value); const gchar* ghb_get_setting_key(GtkWidget *widget); -void ghb_update_widget(GtkWidget *widget, const GValue *value); +void ghb_update_widget(GtkWidget *widget, const GhbValue *value); #endif // _SETTINGS_H_ diff --git a/gtk/src/subtitlehandler.c b/gtk/src/subtitlehandler.c index ff7a8ec79..0b80cfe89 100644 --- a/gtk/src/subtitlehandler.c +++ b/gtk/src/subtitlehandler.c @@ -23,17 +23,17 @@ #include "audiohandler.h" #include "subtitlehandler.h" -static void subtitle_add_to_settings(GValue *settings, GValue *subsettings); -static void ghb_add_subtitle_to_ui(signal_user_data_t *ud, GValue *subsettings); -static void add_to_subtitle_list_ui(signal_user_data_t *ud, GValue *settings); -static void ghb_clear_subtitle_list_settings(GValue *settings); +static void subtitle_add_to_settings(GhbValue *settings, GhbValue *subsettings); +static void ghb_add_subtitle_to_ui(signal_user_data_t *ud, GhbValue *subsettings); +static void add_to_subtitle_list_ui(signal_user_data_t *ud, GhbValue *settings); +static void ghb_clear_subtitle_list_settings(GhbValue *settings); static void ghb_clear_subtitle_list_ui(GtkBuilder *builder); static void subtitle_refresh_list_row_ui( GtkTreeModel *tm, GtkTreeIter *ti, - GValue *subsettings) + GhbValue *subsettings) { GtkTreeIter cti; gboolean forced, burned, def; @@ -117,10 +117,10 @@ subtitle_refresh_list_row_ui( } static void -subtitle_refresh_list_ui_from_settings(signal_user_data_t *ud, GValue *settings) +subtitle_refresh_list_ui_from_settings(signal_user_data_t *ud, GhbValue *settings) { - GValue *subtitle_list; - GValue *subsettings; + GhbValue *subtitle_list; + GhbValue *subsettings; gint ii, count, tm_count; GtkTreeView *tv; GtkTreeModel *tm; @@ -157,10 +157,10 @@ subtitle_refresh_list_ui(signal_user_data_t *ud) } void -ghb_subtitle_exclusive_burn_settings(GValue *settings, gint index) +ghb_subtitle_exclusive_burn_settings(GhbValue *settings, gint index) { - GValue *subtitle_list; - GValue *subsettings; + GhbValue *subtitle_list; + GhbValue *subsettings; gint ii, count; subtitle_list = ghb_settings_get_value(settings, "subtitle_list"); @@ -204,10 +204,10 @@ ghb_subtitle_exclusive_burn(signal_user_data_t *ud, gint index) } void -ghb_subtitle_exclusive_default_settings(GValue *settings, gint index) +ghb_subtitle_exclusive_default_settings(GhbValue *settings, gint index) { - GValue *subtitle_list; - GValue *subtitle; + GhbValue *subtitle_list; + GhbValue *subtitle; gint ii, count; subtitle_list = ghb_settings_get_value(settings, "subtitle_list"); @@ -230,7 +230,7 @@ ghb_subtitle_exclusive_default(signal_user_data_t *ud, gint index) } static void -ghb_add_subtitle_to_ui(signal_user_data_t *ud, GValue *subsettings) +ghb_add_subtitle_to_ui(signal_user_data_t *ud, GhbValue *subsettings) { if (subsettings == NULL) return; @@ -241,10 +241,10 @@ ghb_add_subtitle_to_ui(signal_user_data_t *ud, GValue *subsettings) } static void -subtitle_add_to_settings(GValue *settings, GValue *subsettings) +subtitle_add_to_settings(GhbValue *settings, GhbValue *subsettings) { // Add the current subtitle settings to the list. - GValue *subtitle_list; + GhbValue *subtitle_list; gint count; gboolean burned, forced, def; gint source; @@ -295,7 +295,7 @@ subtitle_add_to_settings(GValue *settings, GValue *subsettings) } static void -subtitle_set_track_description(GValue *settings, GValue *subsettings) +subtitle_set_track_description(GhbValue *settings, GhbValue *subsettings) { char *desc = NULL; @@ -362,9 +362,9 @@ subtitle_set_track_description(GValue *settings, GValue *subsettings) g_free(desc); } -static GValue* subtitle_add_track( +static GhbValue* subtitle_add_track( signal_user_data_t *ud, - GValue *settings, + GhbValue *settings, const hb_title_t *title, int track, int mux, @@ -393,7 +393,7 @@ static GValue* subtitle_add_track( return NULL; } - GValue *subsettings = ghb_dict_value_new(); + GhbValue *subsettings = ghb_dict_value_new(); ghb_settings_set_int(subsettings, "SubtitleTrack", track); ghb_settings_set_int(subsettings, "SubtitleSource", source); @@ -475,7 +475,7 @@ ghb_subtitle_title_change(signal_user_data_t *ud, gboolean show) } void -ghb_set_pref_subtitle_settings(signal_user_data_t *ud, const hb_title_t *title, GValue *settings) +ghb_set_pref_subtitle_settings(signal_user_data_t *ud, const hb_title_t *title, GhbValue *settings) { gint track; gboolean *used; @@ -484,7 +484,7 @@ ghb_set_pref_subtitle_settings(signal_user_data_t *ud, const hb_title_t *title, gboolean burn_foreign, burn_first, burn_dvd, burn_bd; gboolean one_burned = FALSE; - const GValue *lang_list; + const GhbValue *lang_list; gint lang_count, sub_count, ii; int behavior; @@ -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) { - GValue *glang = ghb_array_get_nth(lang_list, 0); - pref_lang = g_value_get_string(glang); + GhbValue *glang = ghb_array_get_nth(lang_list, 0); + pref_lang = ghb_value_const_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++) { - GValue *glang = ghb_array_get_nth(lang_list, ii); - const gchar *lang = g_value_get_string(glang); + GhbValue *glang = ghb_array_get_nth(lang_list, ii); + const gchar *lang = ghb_value_const_string(glang); int next_track = 0; track = ghb_find_subtitle_track(title, lang, next_track); @@ -688,7 +688,7 @@ ghb_selected_subtitle_row(signal_user_data_t *ud) return row; } -static GValue* +static GhbValue* subtitle_get_selected_settings(signal_user_data_t *ud, int *index) { GtkTreeView *tv; @@ -698,8 +698,8 @@ subtitle_get_selected_settings(signal_user_data_t *ud, int *index) GtkTreeIter iter; gint *indices; gint row; - GValue *subsettings = NULL; - const GValue *subtitle_list; + GhbValue *subsettings = NULL; + const GhbValue *subtitle_list; g_debug("get_selected_settings ()"); tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list_view")); @@ -725,7 +725,7 @@ subtitle_get_selected_settings(signal_user_data_t *ud, int *index) } static void -subtitle_update_dialog_widgets(signal_user_data_t *ud, GValue *subsettings) +subtitle_update_dialog_widgets(signal_user_data_t *ud, GhbValue *subsettings) { GtkWidget *widget; @@ -810,10 +810,10 @@ subtitle_update_dialog_widgets(signal_user_data_t *ud, GValue *subsettings) } } -static GValue* +static GhbValue* subtitle_update_setting(GtkWidget *widget, signal_user_data_t *ud) { - GValue *subsettings; + GhbValue *subsettings; ghb_widget_to_setting(ud->settings, widget); subsettings = subtitle_get_selected_settings(ud, NULL); @@ -829,7 +829,7 @@ subtitle_update_setting(GtkWidget *widget, signal_user_data_t *ud) G_MODULE_EXPORT void subtitle_track_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { - GValue *subsettings; + GhbValue *subsettings; g_debug("subtitle_track_changed_cb()"); ghb_widget_to_setting(ud->settings, widget); @@ -858,7 +858,7 @@ subtitle_forced_toggled_cb(GtkWidget *widget, signal_user_data_t *ud) G_MODULE_EXPORT void subtitle_burned_toggled_cb(GtkWidget *widget, signal_user_data_t *ud) { - GValue *subsettings; + GhbValue *subsettings; int index; ghb_widget_to_setting(ud->settings, widget); @@ -879,7 +879,7 @@ subtitle_burned_toggled_cb(GtkWidget *widget, signal_user_data_t *ud) G_MODULE_EXPORT void subtitle_default_toggled_cb(GtkWidget *widget, signal_user_data_t *ud) { - GValue *subsettings; + GhbValue *subsettings; int index; ghb_widget_to_setting(ud->settings, widget); @@ -900,7 +900,7 @@ subtitle_default_toggled_cb(GtkWidget *widget, signal_user_data_t *ud) G_MODULE_EXPORT void subtitle_srt_radio_toggled_cb(GtkWidget *widget, signal_user_data_t *ud) { - GValue *subsettings; + GhbValue *subsettings; ghb_widget_to_setting(ud->settings, widget); subsettings = subtitle_get_selected_settings(ud, NULL); @@ -935,8 +935,8 @@ ghb_subtitle_list_refresh_selected(signal_user_data_t *ud) GtkTreeIter ti; gint *indices; gint row; - GValue *subsettings = NULL; - const GValue *subtitle_list; + GhbValue *subsettings = NULL; + const GhbValue *subtitle_list; g_debug("subtitle_list_refresh_selected()"); tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list_view")); @@ -968,7 +968,7 @@ ghb_subtitle_list_refresh_all(signal_user_data_t *ud) G_MODULE_EXPORT void srt_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { - GValue *subsettings; + GhbValue *subsettings; g_debug("srt_changed_cb()"); ghb_check_dependency(ud, widget, NULL); @@ -986,7 +986,7 @@ srt_changed_cb(GtkWidget *widget, signal_user_data_t *ud) G_MODULE_EXPORT void srt_file_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { - GValue *subsettings; + GhbValue *subsettings; g_debug("srt_file_changed_cb()"); ghb_check_dependency(ud, widget, NULL); @@ -1021,7 +1021,7 @@ srt_file_changed_cb(GtkWidget *widget, signal_user_data_t *ud) G_MODULE_EXPORT void srt_lang_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { - GValue *subsettings; + GhbValue *subsettings; g_debug("srt_lang_changed_cb()"); ghb_check_dependency(ud, widget, NULL); @@ -1037,18 +1037,18 @@ srt_lang_changed_cb(GtkWidget *widget, signal_user_data_t *ud) } static void -ghb_clear_subtitle_list_settings(GValue *settings) +ghb_clear_subtitle_list_settings(GhbValue *settings) { - GValue *subtitle_list; + GhbValue *subtitle_list; subtitle_list = ghb_settings_get_value(settings, "subtitle_list"); if (subtitle_list == NULL) { - subtitle_list = ghb_array_value_new(8); + subtitle_list = ghb_array_value_new(); ghb_settings_set_value(settings, "subtitle_list", subtitle_list); } else - ghb_array_value_reset(subtitle_list, 8); + ghb_array_value_reset(subtitle_list); } static void @@ -1068,7 +1068,7 @@ ghb_clear_subtitle_list_ui(GtkBuilder *builder) } static void -add_to_subtitle_list_ui(signal_user_data_t *ud, GValue *subsettings) +add_to_subtitle_list_ui(signal_user_data_t *ud, GhbValue *subsettings) { GtkTreeView *tv; GtkTreeIter ti; @@ -1090,7 +1090,7 @@ subtitle_list_selection_changed_cb(GtkTreeSelection *ts, signal_user_data_t *ud) { GtkTreeModel *tm; GtkTreeIter iter; - GValue *subsettings = NULL; + GhbValue *subsettings = NULL; int row; g_debug("subtitle_list_selection_changed_cb()"); @@ -1114,7 +1114,7 @@ subtitle_list_selection_changed_cb(GtkTreeSelection *ts, signal_user_data_t *ud) GtkTreePath *tp; gint *indices; - GValue *subtitle_list; + GhbValue *subtitle_list; tp = gtk_tree_model_get_path(tm, &iter); indices = gtk_tree_path_get_indices(tp); @@ -1135,9 +1135,9 @@ subtitle_list_selection_changed_cb(GtkTreeSelection *ts, signal_user_data_t *ud) } } -static gboolean subtitle_is_one_burned(GValue *settings) +static gboolean subtitle_is_one_burned(GhbValue *settings) { - GValue *subtitle_list, *subsettings; + GhbValue *subtitle_list, *subsettings; int count, ii; subtitle_list = ghb_settings_get_value(settings, "subtitle_list"); @@ -1160,7 +1160,7 @@ G_MODULE_EXPORT void subtitle_add_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) { // Add the current subtitle settings to the list. - GValue *subsettings, *backup; + GhbValue *subsettings, *backup; gboolean one_burned; gint track; @@ -1273,8 +1273,8 @@ subtitle_reset_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) void ghb_subtitle_prune(signal_user_data_t *ud) { - GValue *subtitle_list; - GValue *subsettings; + GhbValue *subtitle_list; + GhbValue *subsettings; gint ii; gboolean one_burned = FALSE; @@ -1299,7 +1299,7 @@ ghb_subtitle_prune(signal_user_data_t *ud) burned = burned || !hb_subtitle_can_pass(source, mux->format); if (burned && one_burned) { - GValue *gsub = ghb_array_get_nth(subtitle_list, ii); + GhbValue *gsub = ghb_array_get_nth(subtitle_list, ii); ghb_array_remove(subtitle_list, ii); ghb_value_free(gsub); continue; @@ -1316,10 +1316,10 @@ ghb_subtitle_prune(signal_user_data_t *ud) } void -ghb_reset_subtitles(signal_user_data_t *ud, GValue *settings) +ghb_reset_subtitles(signal_user_data_t *ud, GhbValue *settings) { - GValue *slist; - GValue *subtitle; + GhbValue *slist; + GhbValue *subtitle; gint count, ii; gint title_id, titleindex; const hb_title_t *title; @@ -1392,18 +1392,18 @@ subtitle_update_pref_lang(signal_user_data_t *ud, const iso639_lang_t *lang) } void -ghb_subtitle_set_pref_lang(GValue *settings) +ghb_subtitle_set_pref_lang(GhbValue *settings) { - GValue *lang_list; + GhbValue *lang_list; gboolean set = FALSE; lang_list = ghb_settings_get_value(settings, "SubtitleLanguageList"); if (ghb_array_len(lang_list) > 0) { - GValue *glang = ghb_array_get_nth(lang_list, 0); + GhbValue *glang = ghb_array_get_nth(lang_list, 0); if (glang != NULL) { ghb_settings_set_string(settings, "PreferredLanguage", - g_value_get_string(glang)); + ghb_value_const_string(glang)); set = TRUE; } } @@ -1426,7 +1426,7 @@ subtitle_add_lang_clicked_cb(GtkWidget *widget, signal_user_data_t *ud) { int idx; const iso639_lang_t *lang; - GValue *glang, *lang_list; + GhbValue *glang, *lang_list; // Remove from UI available language list box label = gtk_bin_get_child(GTK_BIN(row)); @@ -1464,7 +1464,7 @@ subtitle_remove_lang_clicked_cb(GtkWidget *widget, signal_user_data_t *ud) if (row != NULL) { gint index; - GValue *lang_list; + GhbValue *lang_list; index = gtk_list_box_row_get_index(row); @@ -1479,7 +1479,7 @@ subtitle_remove_lang_clicked_cb(GtkWidget *widget, signal_user_data_t *ud) // Remove from preset language list lang_list = ghb_settings_get_value(ud->settings, "SubtitleLanguageList"); - GValue *glang = ghb_array_get_nth(lang_list, index); + GhbValue *glang = ghb_array_get_nth(lang_list, index); ghb_array_remove(lang_list, index); ghb_value_free(glang); @@ -1488,7 +1488,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; - GValue *entry = ghb_array_get_nth(lang_list, 0); + GhbValue *entry = ghb_array_get_nth(lang_list, 0); lang = ghb_iso639_lookup_by_int(ghb_lookup_audio_lang(entry)); subtitle_update_pref_lang(ud, lang); } @@ -1521,7 +1521,7 @@ static void subtitle_def_selected_lang_list_clear(signal_user_data_t *ud) static void subtitle_def_lang_list_init(signal_user_data_t *ud) { - GValue *lang_list; + GhbValue *lang_list; // Clear selected languages. subtitle_def_selected_lang_list_clear(ud); @@ -1537,7 +1537,7 @@ static void subtitle_def_lang_list_init(signal_user_data_t *ud) count = ghb_array_len(lang_list); for (ii = 0; ii < count; ) { - GValue *lang_val = ghb_array_get_nth(lang_list, ii); + GhbValue *lang_val = ghb_array_get_nth(lang_list, ii); int idx = ghb_lookup_audio_lang(lang_val); if (ii == 0) { @@ -1564,7 +1564,7 @@ static void subtitle_def_lang_list_init(signal_user_data_t *ud) { // Error in list. Probably duplicate languages. Remove // this item from the list. - GValue *glang = ghb_array_get_nth(lang_list, ii); + GhbValue *glang = ghb_array_get_nth(lang_list, ii); ghb_array_remove(lang_list, ii); ghb_value_free(glang); count--; @@ -1605,7 +1605,7 @@ subtitle_edit_clicked_cb(GtkWidget *widget, gchar *path, signal_user_data_t *ud) if (gtk_tree_path_get_depth(tp) > 1) return; if (gtk_tree_model_get_iter(tm, &ti, tp)) { - GValue *subsettings, *backup; + GhbValue *subsettings, *backup; gtk_tree_selection_select_iter(ts, &ti); @@ -1645,7 +1645,7 @@ subtitle_remove_clicked_cb(GtkWidget *widget, gchar *path, signal_user_data_t *u GtkTreeIter ti, nextIter; gint row; gint *indices; - GValue *subtitle_list; + GhbValue *subtitle_list; tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list_view")); ts = gtk_tree_view_get_selection(tv); @@ -1683,7 +1683,7 @@ subtitle_remove_clicked_cb(GtkWidget *widget, gchar *path, signal_user_data_t *u // treeview. Removing from the treeview sometimes provokes an // immediate selection change, so the list needs to be up to date // when this happens. - GValue *old = ghb_array_get_nth(subtitle_list, row); + GhbValue *old = ghb_array_get_nth(subtitle_list, row); ghb_array_remove(subtitle_list, row); ghb_value_free(old); diff --git a/gtk/src/subtitlehandler.h b/gtk/src/subtitlehandler.h index 597d82f11..d266376e1 100644 --- a/gtk/src/subtitlehandler.h +++ b/gtk/src/subtitlehandler.h @@ -25,17 +25,18 @@ #if !defined(_SUBTITLEHANDLER_H_) #define _SUBTITLEHANDLER_H_ +#include "values.h" #include "settings.h" -void ghb_set_pref_subtitle_settings(signal_user_data_t *ud, const hb_title_t *title, GValue *settings); -void ghb_set_subtitle(signal_user_data_t *ud, gint track, GValue *settings); -void ghb_reset_subtitles(signal_user_data_t *ud, GValue *settings); +void ghb_set_pref_subtitle_settings(signal_user_data_t *ud, const hb_title_t *title, GhbValue *settings); +void ghb_set_subtitle(signal_user_data_t *ud, gint track, GhbValue *settings); +void ghb_reset_subtitles(signal_user_data_t *ud, GhbValue *settings); void ghb_subtitle_prune(signal_user_data_t *ud); void ghb_subtitle_list_refresh_selected(signal_user_data_t *ud); void ghb_subtitle_list_refresh_all(signal_user_data_t *ud); void ghb_init_subtitle_defaults_ui(signal_user_data_t *ud); void ghb_subtitle_defaults_to_ui(signal_user_data_t *ud); void ghb_subtitle_title_change(signal_user_data_t *ud, gboolean show); -void ghb_subtitle_set_pref_lang(GValue *settings); +void ghb_subtitle_set_pref_lang(GhbValue *settings); #endif // _SUBTITLEHANDLER_H_ diff --git a/gtk/src/values.c b/gtk/src/values.c index 966fda8fe..c0bb1305b 100644 --- a/gtk/src/values.c +++ b/gtk/src/values.c @@ -19,63 +19,87 @@ #include <inttypes.h> #include "values.h" -static void dict_delete_key(gpointer data); -static void dict_delete_value(gpointer data); - -GValue* -ghb_value_new(GType gtype) -{ - GValue *gval = g_malloc0(sizeof(GValue)); - g_value_init(gval, gtype); - return gval; +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; +} + +GhbValue* +ghb_value_new(GhbType type) +{ + GhbValue *val = NULL; + switch (type) + { + case GHB_DICT: + val = json_object(); + break; + case GHB_ARRAY: + val = json_array(); + break; + case GHB_STRING: + val = json_string(""); + break; + case GHB_INT: + val = json_integer(0); + break; + case GHB_DOUBLE: + val = json_real(0.0); + break; + case GHB_BOOL: + val = json_false(); + break; + default: + g_warning("Unrecognized GHB value type %d", type); + break; + } + return val; } void -ghb_value_free(GValue *gval) +ghb_value_free(GhbValue *gval) { if (gval == NULL) return; - g_value_unset(gval); - g_free(gval); + json_decref(gval); } -GValue* -ghb_value_dup(const GValue *val) +GhbValue* +ghb_value_dup(const GhbValue *gval) { - if (val == NULL) return NULL; - GValue *copy = ghb_value_new(G_VALUE_TYPE(val)); - g_value_copy(val, copy); - return copy; + if (gval == NULL) return NULL; + return json_deep_copy(gval); } void -debug_show_type(GType tp) +debug_show_type(GhbType tp) { const gchar *str = "unknown"; - if (tp == G_TYPE_STRING) + if (tp == GHB_STRING) { str ="string"; } - else if (tp == G_TYPE_INT) + else if (tp == GHB_INT) { str ="int"; } - else if (tp == G_TYPE_INT64) - { - str ="int64"; - } - else if (tp == G_TYPE_DOUBLE) + else if (tp == GHB_DOUBLE) { str ="double"; } - else if (tp == G_TYPE_BOOLEAN) + else if (tp == GHB_BOOL) { str ="bool"; } - else if (tp == ghb_array_get_type()) + else if (tp == GHB_ARRAY) { str ="array"; } - else if (tp == ghb_dict_get_type()) + else if (tp == GHB_DICT) { str ="dict"; } @@ -83,633 +107,422 @@ debug_show_type(GType tp) } void -debug_show_value(GValue *gval) +debug_show_value(GhbValue *gval) { - GType tp; + GhbType tp; - tp = G_VALUE_TYPE(gval); - if (tp == G_TYPE_STRING) - { - g_message("Type %s value %s", "string", g_value_get_string(gval)); - } - else if (tp == G_TYPE_INT) + tp = ghb_value_type(gval); + if (tp == GHB_STRING) { - g_message("Type %s value %d", "int", g_value_get_int(gval)); + g_message("Type %s value %s", "string", json_string_value(gval)); } - else if (tp == G_TYPE_INT64) + else if (tp == GHB_INT) { - g_message("Type %s value %" PRId64, "int64", g_value_get_int64(gval)); + g_message("Type %s value %"JSON_INTEGER_FORMAT, "int", + json_integer_value(gval)); } - else if (tp == G_TYPE_DOUBLE) + else if (tp == GHB_DOUBLE) { - g_message("Type %s value %f", "double", g_value_get_double(gval)); + g_message("Type %s value %f", "double", json_real_value(gval)); } - else if (tp == G_TYPE_BOOLEAN) + else if (tp == GHB_BOOL) { - g_message("Type %s value %d", "boolean", g_value_get_boolean(gval)); + g_message("Type %s value %d", "boolean", json_is_true(gval)); } - else if (tp == ghb_array_get_type()) + else if (tp == GHB_ARRAY) { - g_message("Type %s", "boolean"); + g_message("Type %s", "array"); } - else if (tp == ghb_dict_get_type()) + else if (tp == GHB_DICT) { g_message("Type %s", "dict"); } } -gint -ghb_value_int(const GValue *val) +static GhbValue* xform_int(json_int_t i, GhbType type) { - gint result; - - if (val == NULL) return 0; - GValue xform = {0,}; - if (G_VALUE_TYPE(val) != G_TYPE_INT) + switch (type) { - g_value_init(&xform, G_TYPE_INT); - if (!g_value_transform(val, &xform)) + 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: { - debug_show_type(G_VALUE_TYPE(val)); - g_warning("int can't transform"); - return 0; + char *s = g_strdup_printf("%"JSON_INTEGER_FORMAT, i); + GhbValue *v = json_string(s); + g_free(s); + return v; } - result = g_value_get_int(&xform); - g_value_unset(&xform); - } - else - { - result = g_value_get_int(val); } - return result; } -gint64 -ghb_value_int64(const GValue *val) +static GhbValue* xform_double(double d, GhbType type) { - gint64 result; - - if (val == NULL) return 0; - GValue xform = {0,}; - if (G_VALUE_TYPE(val) != G_TYPE_INT64) + switch (type) { - g_value_init(&xform, G_TYPE_INT64); - if (!g_value_transform(val, &xform)) + 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: { - debug_show_type(G_VALUE_TYPE(val)); - g_warning("int64 can't transform"); - return 0; + char *s = g_strdup_printf("%g", d); + GhbValue *v = json_string(s); + g_free(s); + return v; } - result = g_value_get_int64(&xform); - g_value_unset(&xform); - } - else - { - result = g_value_get_int64(val); } - return result; } -gdouble -ghb_value_double(const GValue *val) +static GhbValue* xform_string(const char * s, GhbType type) { - gdouble result; - - if (val == NULL) return 0; - GValue xform = {0,}; - if (G_VALUE_TYPE(val) != G_TYPE_DOUBLE) + switch (type) { - g_value_init(&xform, G_TYPE_DOUBLE); - if (!g_value_transform(val, &xform)) + default: + case GHB_NULL: { - debug_show_type(G_VALUE_TYPE(val)); - g_warning("double can't transform"); - return 0; + return json_null(); } - result = g_value_get_double(&xform); - g_value_unset(&xform); - } - else - { - result = g_value_get_double(val); - } - return result; -} - -gchar* -ghb_value_string(const GValue *val) -{ - gchar *result; - - if (val == NULL) return 0; - GValue xform = {0,}; - if (G_VALUE_TYPE(val) != G_TYPE_STRING) - { - g_value_init(&xform, G_TYPE_STRING); - if (!g_value_transform(val, &xform)) + case GHB_BOOL: { - debug_show_type(G_VALUE_TYPE(val)); - g_warning("string can't transform"); - return NULL; + 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); } - result = g_strdup(g_value_get_string(&xform)); - g_value_unset(&xform); - } - else - { - result = g_strdup(g_value_get_string(val)); } - return result; } -gboolean -ghb_value_boolean(const GValue *val) +static GhbValue* xform_null(GhbType type) { - gboolean result; - - if (val == NULL) return FALSE; - GValue xform = {0,}; - if (G_VALUE_TYPE(val) != G_TYPE_BOOLEAN) + switch (type) { - g_value_init(&xform, G_TYPE_BOOLEAN); - if (!g_value_transform(val, &xform)) - { - debug_show_type(G_VALUE_TYPE(val)); - g_warning("boolean can't transform"); - return FALSE; - } - result = g_value_get_boolean(&xform); - g_value_unset(&xform); + 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(""); } - else - { - result = g_value_get_boolean(val); - } - return result; } -gint -ghb_value_cmp(const GValue *vala, const GValue *valb) +GhbValue* ghb_value_xform(const GhbValue *val, GhbType type) { - GType typa; - GType typb; - - if ((vala == NULL && valb != NULL) || (vala != NULL && valb == NULL)) + GhbType src_type = ghb_value_type(val); + if (src_type == type && val != NULL) { - return 1; + json_incref((GhbValue*)val); + return (GhbValue*)val; } - typa = G_VALUE_TYPE(vala); - typb = G_VALUE_TYPE(valb); - if (typa != typb) + switch (src_type) { - return 1; - } - - if (typa == G_TYPE_STRING) - { - char *stra, *strb; - gint res; - stra = ghb_value_string(vala); - strb = ghb_value_string(valb); - if (stra == NULL && strb == NULL) - return 0; - if (stra == NULL) + default: + case GHB_NULL: { - g_free(strb); - return -1; + return xform_null(type); } - if (strb == NULL) + case GHB_BOOL: { - g_free(stra); - return 1; + 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); } - res = strcmp(stra, strb); - g_free(stra); - g_free(strb); - return res; - } - else if (typa == G_TYPE_INT64 || typa == G_TYPE_INT || - typa == G_TYPE_BOOLEAN) - { - return ghb_value_int64(vala) - ghb_value_int64(valb); - } - else if (typa == G_TYPE_DOUBLE || typa == G_TYPE_FLOAT) - { - return ghb_value_double(vala) - ghb_value_double(valb); - } - else if (typa == ghb_array_get_type()) - { - // Cheating here. Just assume they are different. - // Maybe later I'll recurse through these - return 1; - } - else if (typa == ghb_dict_get_type()) - { - // Cheating here. Just assume they are different. - // Maybe later I'll recurse through these - return 1; - } - else - { - g_warning("ghb_value_cmp: unrecognized type"); - return 1; } - return 0; -} - -GValue* -ghb_string_value(const gchar *str) -{ - static GValue gval = {0,}; - if (!G_IS_VALUE(&gval)) - g_value_init(&gval, G_TYPE_STRING); - g_value_set_string(&gval, str); - return &gval; -} - -GValue* -ghb_int64_value(gint64 ival) -{ - static GValue gval = {0,}; - if (!G_IS_VALUE(&gval)) - g_value_init(&gval, G_TYPE_INT64); - g_value_set_int64(&gval, ival); - return &gval; -} - -GValue* -ghb_int_value(gint ival) -{ - static GValue gval = {0,}; - if (!G_IS_VALUE(&gval)) - g_value_init(&gval, G_TYPE_INT64); - g_value_set_int64(&gval, (gint64)ival); - return &gval; } -GValue* -ghb_double_value(gdouble dval) +gint +ghb_value_int(const GhbValue *val) { - static GValue gval = {0,}; - if (!G_IS_VALUE(&gval)) - g_value_init(&gval, G_TYPE_DOUBLE); - g_value_set_double(&gval, dval); - return &gval; + gint result; + GhbValue *v = ghb_value_xform(val, GHB_INT); + result = json_integer_value(v); + json_decref(v); + return result; } -GValue* -ghb_boolean_value(gboolean bval) +gint64 +ghb_value_int64(const GhbValue *val) { - static GValue gval = {0,}; - if (!G_IS_VALUE(&gval)) - g_value_init(&gval, G_TYPE_BOOLEAN); - g_value_set_boolean(&gval, bval); - return &gval; + gint64 result; + GhbValue *v = ghb_value_xform(val, GHB_INT); + result = json_integer_value(v); + json_decref(v); + return result; } -GValue* -ghb_string_value_new(const gchar *str) +gdouble +ghb_value_double(const GhbValue *val) { - GValue *gval = ghb_value_new(G_TYPE_STRING); - g_value_set_string(gval, str); - return gval; + gdouble result; + GhbValue *v = ghb_value_xform(val, GHB_DOUBLE); + result = json_real_value(v); + json_decref(v); + return result; } -GValue* -ghb_int64_value_new(gint64 ival) +gchar* +ghb_value_string(const GhbValue *val) { - GValue *gval = ghb_value_new(G_TYPE_INT64); - g_value_set_int64(gval, ival); - return gval; + gchar *result; + GhbValue *v = ghb_value_xform(val, GHB_STRING); + result = g_strdup(json_string_value(v)); + json_decref(v); + return result; } -GValue* -ghb_int_value_new(gint ival) +const gchar* +ghb_value_const_string(const GhbValue *val) { - GValue *gval = ghb_value_new(G_TYPE_INT64); - g_value_set_int64(gval, ival); - return gval; + if (ghb_value_type(val) != GHB_STRING) + return NULL; + return json_string_value(val); } -GValue* -ghb_double_value_new(gdouble dval) +gboolean +ghb_value_boolean(const GhbValue *val) { - GValue *gval = ghb_value_new(G_TYPE_DOUBLE); - g_value_set_double(gval, dval); - return gval; + gboolean result; + GhbValue *v = ghb_value_xform(val, GHB_BOOL); + result = json_is_true(v); + json_decref(v); + return result; } -GValue* -ghb_boolean_value_new(gboolean bval) +gint +ghb_value_cmp(const GhbValue *vala, const GhbValue *valb) { - GValue *gval = ghb_value_new(G_TYPE_BOOLEAN); - g_value_set_boolean(gval, bval); - return gval; + return !json_equal((GhbValue*)vala, (GhbValue*)valb); } -GValue* -ghb_dict_value_new() +GhbValue* +ghb_string_value(const gchar *str) { - GHashTable *dict; - GValue *gval = ghb_value_new(ghb_dict_get_type()); - dict = g_hash_table_new_full(g_str_hash, g_str_equal, - dict_delete_key, dict_delete_value); - g_value_take_boxed(gval, dict); + static GhbValue *gval = NULL; + if (gval == NULL) + gval = json_string(str); + else + json_string_set(gval, str); return gval; } -GValue* -ghb_array_value_new(guint size) +GhbValue* +ghb_int64_value(gint64 ival) { - GValue *gval = ghb_value_new(ghb_array_get_type()); - GArray *array; - - array = g_array_sized_new(FALSE, FALSE, sizeof(GValue*), size); - g_value_take_boxed(gval, array); + static GhbValue *gval = NULL; + if (gval == NULL) + gval = json_integer(ival); + else + json_integer_set(gval, ival); return gval; } -void -ghb_array_value_reset(GValue *gval, guint size) +GhbValue* +ghb_int_value(gint ival) { - GArray *array; - g_value_reset(gval); - array = g_array_sized_new(FALSE, FALSE, sizeof(GValue*), size); - g_value_take_boxed(gval, array); + return ghb_int64_value(ival); } -GValue* -ghb_date_value_new(GDate *date) +GhbValue* +ghb_double_value(gdouble dval) { - GValue *gval = ghb_value_new(g_date_get_type()); - g_value_set_boxed(gval, date); + static GhbValue *gval = NULL; + if (gval == NULL) + gval = json_real(dval); + else + json_real_set(gval, dval); return gval; } -GValue* -ghb_rawdata_value_new(ghb_rawdata_t *data) +GhbValue* +ghb_boolean_value(gboolean bval) { - GValue *gval = ghb_value_new(ghb_rawdata_get_type()); - g_value_take_boxed(gval, data); + // Jansson boolean is singleton, no need for local static + GhbValue *gval = json_boolean(bval); + json_decref(gval); return gval; } -static gpointer -rawdata_copy(gpointer boxed) +GhbValue* +ghb_string_value_new(const gchar *str) { - const ghb_rawdata_t *data = (const ghb_rawdata_t*)boxed; - ghb_rawdata_t *copy = g_malloc(sizeof(ghb_rawdata_t)); - copy->size = data->size; - if (data->data) - { - copy->data = g_malloc(data->size); - memcpy(copy->data, data->data, data->size); - } - else - { - copy->data = NULL; - copy->size = 0; - } - return copy; + return json_string(str); } -static void -rawdata_free(gpointer boxed) +void +ghb_string_value_set(GhbValue *gval, const gchar *str) { - ghb_rawdata_t *data = (ghb_rawdata_t*)boxed; - if (data->data) g_free(data->data); - g_free(data); + json_string_set(gval, str); } - -GType -ghb_rawdata_get_type(void) +GhbValue* +ghb_int64_value_new(gint64 ival) { - static GType type_id = 0; - if (!type_id) - type_id = g_boxed_type_register_static(g_intern_static_string("GHBData"), - (GBoxedCopyFunc) rawdata_copy, - (GBoxedFreeFunc) rawdata_free); - return type_id; + return json_integer(ival); } -static void -dict_delete_key(gpointer data) +GhbValue* +ghb_int_value_new(gint ival) { - if (data == NULL) - { - g_warning("dict frees null key"); - return; - } - g_free(data); + return json_integer(ival); } -static void -dict_delete_value(gpointer data) +GhbValue* +ghb_double_value_new(gdouble dval) { - GValue *gval = (GValue*)data; - if (gval == NULL) - { - g_warning("dict frees null value"); - return; - } - ghb_value_free(gval); + return json_real(dval); } -static gpointer -dict_copy(gpointer boxed) +GhbValue* +ghb_boolean_value_new(gboolean bval) { - GHashTable *dict = (GHashTable*)boxed; - GHashTable *copy; - GHashTableIter iter; - gchar *key; - GValue *gval; - - copy = g_hash_table_new_full(g_str_hash, g_str_equal, - dict_delete_key, dict_delete_value); - - g_hash_table_iter_init(&iter, dict); - // middle (void*) cast prevents gcc warning "defreferencing type-punned - // pointer will break strict-aliasing rules" - while (g_hash_table_iter_next( - &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval)) - { - g_hash_table_insert(copy, g_strdup(key), ghb_value_dup(gval)); - } - return copy; + return json_boolean(bval); } -static void -dict_free(gpointer boxed) +GhbValue* +ghb_dict_value_new() { - GHashTable *dict = (GHashTable*)boxed; - g_hash_table_destroy(dict); + return json_object(); } - -GType -ghb_dict_get_type(void) +GhbValue* +ghb_array_value_new() { - static GType type_id = 0; - if (!type_id) - type_id = g_boxed_type_register_static( - g_intern_static_string("GHBDict"), - (GBoxedCopyFunc) dict_copy, - (GBoxedFreeFunc) dict_free); - return type_id; + return json_array(); } void -ghb_dict_insert(GValue *gval, gchar *key, GValue *val) +ghb_array_value_reset(GhbValue *array) { - GHashTable *dict = g_value_get_boxed(gval); - g_hash_table_insert(dict, key, val); + json_array_clear(array); } void -ghb_dict_iter_init(GHashTableIter *iter, GValue *gval) +ghb_dict_insert(GhbValue *dict, const gchar *key, GhbValue *val) { - GHashTable *dict = g_value_get_boxed(gval); - g_hash_table_iter_init(iter, dict); + json_object_set_new(dict, key, val); } -GValue* -ghb_dict_lookup(const GValue *gval, const gchar *key) +void +ghb_dict_iter_init(GhbValue *dict, GhbDictIter *iter) { - GHashTable *dict = g_value_get_boxed(gval); - return g_hash_table_lookup(dict, key); + *iter = json_object_iter(dict); } -gboolean -ghb_dict_remove(GValue *gval, const gchar *key) +int +ghb_dict_iter_next(GhbValue *dict, GhbDictIter *iter, + const char **key, GhbValue **val) { - GHashTable *dict = g_value_get_boxed(gval); - return g_hash_table_remove(dict, key); + 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; } -static gpointer -array_copy(gpointer boxed) +GhbValue* +ghb_dict_lookup(const GhbValue *dict, const gchar *key) { - const GArray *array = (const GArray*)boxed; - GArray *copy = g_array_new(FALSE, FALSE, sizeof(GValue*)); - - GValue *gval, *gval_copy; - gint ii; - - for (ii = 0; ii < array->len; ii++) - { - gval = g_array_index(array, GValue*, ii); - if (gval) - { - gval_copy = ghb_value_dup(gval); - g_array_append_val(copy, gval_copy); - } - } - return copy; + return json_object_get(dict, key); } -static void -array_free(gpointer boxed) -{ - GArray *array = (GArray*)boxed; - GValue *gval; - gint ii; - - for (ii = 0; ii < array->len; ii++) - { - gval = g_array_index(array, GValue*, ii); - if (gval) - { - ghb_value_free(gval); - } - } - g_array_free(array, TRUE); -} - - -GType -ghb_array_get_type(void) +gboolean +ghb_dict_remove(GhbValue *dict, const gchar *key) { - static GType type_id = 0; - if (!type_id) - type_id = g_boxed_type_register_static( - g_intern_static_string("GHBArray"), - (GBoxedCopyFunc) array_copy, - (GBoxedFreeFunc) array_free); - return type_id; + return json_object_del(dict, key) == 0; } -GValue* -ghb_array_get_nth(const GValue *gval, gint ii) +GhbValue* +ghb_array_get_nth(const GhbValue *array, gint ii) { - GArray *arr = g_value_get_boxed(gval); - return g_array_index(arr, GValue*, ii); + return json_array_get(array, ii); } void -ghb_array_insert(GValue *gval, guint ii, GValue *val) +ghb_array_insert(GhbValue *array, guint ii, GhbValue *val) { - GArray *arr = g_value_get_boxed(gval); - // A little nastyness here. The array pointer - // can change when the array changes size. So - // I must re-box it in the GValue each time. - arr = g_array_insert_val(arr, ii, val); - memset(gval, 0, sizeof(GValue)); - g_value_init(gval, ghb_array_get_type()); - g_value_take_boxed(gval, arr); + json_array_insert_new(array, ii, val); } void -ghb_array_append(GValue *gval, GValue *val) +ghb_array_append(GhbValue *array, GhbValue *val) { - GArray *arr = g_value_get_boxed(gval); - // A little nastyness here. The array pointer - // can change when the array changes size. So - // I must re-box it in the GValue each time. - arr = g_array_append_val(arr, val); - memset(gval, 0, sizeof(GValue)); - g_value_init(gval, ghb_array_get_type()); - g_value_take_boxed(gval, arr); + json_array_append_new(array, val); } void -ghb_array_remove(GValue *gval, guint ii) +ghb_array_remove(GhbValue *array, guint ii) { - GArray *arr = g_value_get_boxed(gval); - // A little nastyness here. The array pointer - // can change when the array changes size. So - // I must re-box it in the GValue each time. - arr = g_array_remove_index(arr, ii); - memset(gval, 0, sizeof(GValue)); - g_value_init(gval, ghb_array_get_type()); - g_value_take_boxed(gval, arr); + json_array_remove(array, ii); } void -ghb_array_replace(GValue *gval, guint ii, GValue *val) +ghb_array_replace(GhbValue *array, guint ii, GhbValue *val) { - GArray *arr = g_value_get_boxed(gval); - // A little nastyness here. The array pointer - // can change when the array changes size. So - // I must re-box it in the GValue each time. - if (ii >= arr->len) return; - ghb_value_free(((GValue**)arr->data)[ii]); - ((GValue**)arr->data)[ii] = 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(GValue *arr1, GValue *arr2, gint count) +ghb_array_copy(GhbValue *arr1, GhbValue *arr2, gint count) { gint len, ii; // empty the first array if it is not already empty - len = ghb_array_len(arr1); - for (ii = 0; ii < len; ii++) - { - GValue *old = ghb_array_get_nth(arr1, 0); - ghb_array_remove(arr1, 0); - ghb_value_free(old); - } + json_array_clear(arr1); len = ghb_array_len(arr2); count = MIN(count, len); @@ -718,82 +531,7 @@ ghb_array_copy(GValue *arr1, GValue *arr2, gint count) } gint -ghb_array_len(const GValue *gval) +ghb_array_len(const GhbValue *array) { - if (gval == NULL) return 0; - GArray *arr = g_value_get_boxed(gval); - return arr->len; -} - -static void -xform_string_int(const GValue *sval, GValue *ival) -{ - gchar *end; - - const gchar *str = g_value_get_string(sval); - gint val = 0; - if (str != NULL) - { - val = g_strtod(str, &end); - if (*end) - val = (guint)(~0)>>1; - } - g_value_set_int(ival, val); -} - -static void -xform_string_int64(const GValue *sval, GValue *ival) -{ - gchar *end; - const gchar *str = g_value_get_string(sval); - gint64 val = 0; - if (str != NULL) - { - val = g_strtod(str, &end); - if (*end) - val = (guint64)(~0L)>>1; - } - g_value_set_int64(ival, val); -} - -static void -xform_string_double(const GValue *sval, GValue *dval) -{ - const gchar *str = g_value_get_string(sval); - double val = 0.0; - if (str != NULL) - val = g_strtod(str, NULL); - g_value_set_double(dval, val); -} - -static void -xform_double_string(const GValue *dval, GValue *sval) -{ - gchar *str; - double val = g_value_get_double(dval); - str = g_strdup_printf("%g", val); - g_value_take_string(sval, str); -} - -static void -xform_boolean_double(const GValue *bval, GValue *dval) -{ - gboolean b = g_value_get_boolean(bval); - double val = b; - g_value_set_double(dval, val); -} - -void -ghb_register_transforms() -{ - g_value_register_transform_func(G_TYPE_STRING, G_TYPE_INT64, - xform_string_int64); - g_value_register_transform_func(G_TYPE_STRING, G_TYPE_INT, - xform_string_int); - g_value_register_transform_func(G_TYPE_STRING, G_TYPE_DOUBLE, - xform_string_double); - g_value_register_transform_func(G_TYPE_BOOLEAN, G_TYPE_DOUBLE, - xform_boolean_double); - g_value_register_transform_func(G_TYPE_DOUBLE, G_TYPE_STRING, - xform_double_string); + return json_array_size(array); } diff --git a/gtk/src/values.h b/gtk/src/values.h index f58b2dbfb..ceb70687c 100644 --- a/gtk/src/values.h +++ b/gtk/src/values.h @@ -18,60 +18,67 @@ #include <glib.h> #include <glib-object.h> +#include "jansson.h" -typedef struct -{ - guchar *data; - gsize size; -} ghb_rawdata_t; +#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 -GType ghb_rawdata_get_type(void); +typedef json_t GhbValue; +typedef int GhbType; +typedef void* GhbDictIter; -GType ghb_array_get_type(void); -GType ghb_dict_get_type(void); -GValue* ghb_array_get_nth(const GValue *array, gint ii); -void ghb_array_insert(GValue *gval, guint ii, GValue *val); -void ghb_array_replace(GValue *gval, guint ii, GValue *val); -void ghb_array_append(GValue *gval, GValue *val); -void ghb_array_remove(GValue *gval, guint ii); -gint ghb_array_len(const GValue *gval); -void ghb_array_copy(GValue *arr1, GValue *arr2, gint count); +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); -void ghb_value_free(GValue *gval); -GValue* ghb_value_new(GType gtype); -GValue* ghb_value_dup(const GValue *val); -gint ghb_value_int(const GValue *val); -gint64 ghb_value_int64(const GValue *val); -gdouble ghb_value_double(const GValue *val); -gchar* ghb_value_string(const GValue *val); -gboolean ghb_value_boolean(const GValue *val); +GhbValue* ghb_value_xform(const GhbValue *val, GhbType type); +void ghb_value_free(GhbValue *gval); +GhbValue* ghb_value_new(GhbType type); +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); -GValue* ghb_string_value(const gchar *str); -GValue* ghb_int64_value(gint64 ival); -GValue* ghb_int_value(gint ival); -GValue* ghb_double_value(gdouble dval); -GValue* ghb_boolean_value(gboolean bval); +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); -gint ghb_value_cmp(const GValue *vala, const GValue *valb); -GValue* ghb_string_value_new(const gchar *str); -GValue* ghb_int64_value_new(gint64 ival); -GValue* ghb_int_value_new(gint ival); -GValue* ghb_double_value_new(gdouble dval); -GValue* ghb_boolean_value_new(gboolean bval); -GValue* ghb_dict_value_new(void); -GValue* ghb_array_value_new(guint size); -void ghb_array_value_reset(GValue *gval, guint size); +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); -GValue* ghb_date_value_new(GDate *date); -GValue* ghb_rawdata_value_new(ghb_rawdata_t *data); +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); -void ghb_dict_insert(GValue *gval, gchar *key, GValue *val); -void ghb_dict_iter_init(GHashTableIter *iter, GValue *gval); -GValue* ghb_dict_lookup(const GValue *gval, const gchar *key); -gboolean ghb_dict_remove(GValue *gval, const gchar *key); -void ghb_register_transforms(void); - -void debug_show_value(GValue *gval); -void debug_show_type(GType tp); +void debug_show_value(GhbValue *gval); +void debug_show_type(GhbType tp); #endif // _GHB_VALUES_H_ diff --git a/gtk/src/videohandler.c b/gtk/src/videohandler.c index 70245d0e0..8a5e16591 100644 --- a/gtk/src/videohandler.c +++ b/gtk/src/videohandler.c @@ -21,7 +21,7 @@ #include "preview.h" #include "hb-backend.h" -int ghb_get_video_encoder(GValue *settings) +int ghb_get_video_encoder(GhbValue *settings) { const char *encoder; encoder = ghb_settings_get_const_string(settings, "VideoEncoder"); diff --git a/gtk/src/videohandler.h b/gtk/src/videohandler.h index b649f9307..3f5ea0dcf 100644 --- a/gtk/src/videohandler.h +++ b/gtk/src/videohandler.h @@ -25,9 +25,10 @@ #if !defined(_VIDEOHANDLER_H_) #define _VIDEOHANDLER_H_ +#include "values.h" #include "settings.h" -int ghb_get_video_encoder(GValue *settings); +int ghb_get_video_encoder(GhbValue *settings); void ghb_video_setting_changed(GtkWidget *widget, signal_user_data_t *ud); #endif // _VIDEOHANDLER_H_ diff --git a/gtk/src/x264handler.c b/gtk/src/x264handler.c index 14a04ebcc..46eb8c1cf 100644 --- a/gtk/src/x264handler.c +++ b/gtk/src/x264handler.c @@ -708,9 +708,9 @@ x264_opt_update(signal_user_data_t *ud, GtkWidget *widget) val = get_psy_val(ud); else { - GValue *gval; + GhbValue *gval; gval = ghb_widget_value(widget); - if (G_VALUE_TYPE(gval) == G_TYPE_BOOLEAN) + if (ghb_value_type(gval) == GHB_BOOL) { if (ghb_value_boolean(gval)) val = g_strdup("1"); @@ -755,9 +755,9 @@ x264_opt_update(signal_user_data_t *ud, GtkWidget *widget) val = get_psy_val(ud); else { - GValue *gval; + GhbValue *gval; gval = ghb_widget_value(widget); - if (G_VALUE_TYPE(gval) == G_TYPE_BOOLEAN) + if (ghb_value_type(gval) == GHB_BOOL) { if (ghb_value_boolean(gval)) val = g_strdup("1"); diff --git a/make/include/main.defs b/make/include/main.defs index 56db40c4d..88de5933f 100644 --- a/make/include/main.defs +++ b/make/include/main.defs @@ -51,6 +51,7 @@ ifneq (,$(filter $(BUILD.system),darwin cygwin mingw)) MODULES += contrib/libsamplerate MODULES += contrib/lame MODULES += contrib/x264 + MODULES += contrib/jansson endif ifeq (1,$(FEATURE.fdk_aac)) @@ -95,7 +96,6 @@ ifneq (,$(filter $(BUILD.system),solaris)) MODULES += contrib/libiconv endif -MODULES += contrib/jansson ## these must come after contrib since some contrib modules are optional MODULES += libhb diff --git a/pkg/linux/debian/control.trusty b/pkg/linux/debian/control.trusty index 0e959fe03..ce34c9828 100644 --- a/pkg/linux/debian/control.trusty +++ b/pkg/linux/debian/control.trusty @@ -2,7 +2,7 @@ Source: handbrake Section: graphics Priority: optional Maintainer: John Stebbins <[email protected]> -Build-Depends: debhelper (>= 6), autotools-dev, libtool, libgudev-1.0-dev, intltool, autoconf, yasm (>= 1.2.0), cmake, libbz2-dev, zlib1g-dev, libgtk-3-dev, libwebkitgtk-3.0-dev, libnotify-dev, libgstreamer1.0-dev, libgstreamer-plugins-base1.0-dev, wget, python (>= 2.6), libappindicator3-dev, libfribidi-dev (>= 0.19.0), libxml2-dev, libogg-dev, libtheora-dev, libvorbis-dev, libsamplerate0-dev, libfreetype6-dev, libfontconfig1-dev, libass-dev, libmp3lame-dev, libx264-dev +Build-Depends: debhelper (>= 6), autotools-dev, libtool, libgudev-1.0-dev, intltool, autoconf, yasm (>= 1.2.0), cmake, libbz2-dev, zlib1g-dev, libgtk-3-dev, libwebkitgtk-3.0-dev, libnotify-dev, libgstreamer1.0-dev, libgstreamer-plugins-base1.0-dev, wget, python (>= 2.6), libappindicator3-dev, libfribidi-dev (>= 0.19.0), libxml2-dev, libogg-dev, libtheora-dev, libvorbis-dev, libsamplerate0-dev, libfreetype6-dev, libfontconfig1-dev, libass-dev, libmp3lame-dev, libx264-dev, libjansson-dev Standards-Version: 3.8.4 Homepage: http://www.handbrake.fr/ diff --git a/pkg/linux/debian/control.utopic b/pkg/linux/debian/control.utopic index 0e959fe03..ce34c9828 100644 --- a/pkg/linux/debian/control.utopic +++ b/pkg/linux/debian/control.utopic @@ -2,7 +2,7 @@ Source: handbrake Section: graphics Priority: optional Maintainer: John Stebbins <[email protected]> -Build-Depends: debhelper (>= 6), autotools-dev, libtool, libgudev-1.0-dev, intltool, autoconf, yasm (>= 1.2.0), cmake, libbz2-dev, zlib1g-dev, libgtk-3-dev, libwebkitgtk-3.0-dev, libnotify-dev, libgstreamer1.0-dev, libgstreamer-plugins-base1.0-dev, wget, python (>= 2.6), libappindicator3-dev, libfribidi-dev (>= 0.19.0), libxml2-dev, libogg-dev, libtheora-dev, libvorbis-dev, libsamplerate0-dev, libfreetype6-dev, libfontconfig1-dev, libass-dev, libmp3lame-dev, libx264-dev +Build-Depends: debhelper (>= 6), autotools-dev, libtool, libgudev-1.0-dev, intltool, autoconf, yasm (>= 1.2.0), cmake, libbz2-dev, zlib1g-dev, libgtk-3-dev, libwebkitgtk-3.0-dev, libnotify-dev, libgstreamer1.0-dev, libgstreamer-plugins-base1.0-dev, wget, python (>= 2.6), libappindicator3-dev, libfribidi-dev (>= 0.19.0), libxml2-dev, libogg-dev, libtheora-dev, libvorbis-dev, libsamplerate0-dev, libfreetype6-dev, libfontconfig1-dev, libass-dev, libmp3lame-dev, libx264-dev, libjansson-dev Standards-Version: 3.8.4 Homepage: http://www.handbrake.fr/ |