Beispiel #1
0
static void
subtitle_refresh_list_ui_from_settings(signal_user_data_t *ud, GValue *settings)
{
    GValue *subtitle_list;
    GValue *subsettings;
    gint ii, count, tm_count;
    GtkTreeView  *tv;
    GtkTreeModel *tm;
    GtkTreeIter   ti;

    tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
    tm = gtk_tree_view_get_model(tv);

    tm_count = gtk_tree_model_iter_n_children(tm, NULL);

    subtitle_list = ghb_settings_get_value(settings, "subtitle_list");
    count = ghb_array_len(subtitle_list);
    if (count != tm_count)
    {
        ghb_clear_subtitle_list_ui(ud->builder);
        for (ii = 0; ii < count; ii++)
        {
            gtk_tree_store_append(GTK_TREE_STORE(tm), &ti, NULL);
        }
    }
    for (ii = 0; ii < count; ii++)
    {
        g_return_if_fail(tv != NULL);
        gtk_tree_model_iter_nth_child(tm, &ti, NULL, ii);
        subsettings = ghb_array_get_nth(subtitle_list, ii);
        subtitle_refresh_list_row_ui(tm, &ti, subsettings);
    }
}
Beispiel #2
0
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;
    gboolean one_burned;
    gint track, mux;

    hb_title_t *title;
    int titleindex = ghb_settings_combo_int(ud->settings, "title");
    title = ghb_get_title_info(titleindex);
    if (title == NULL)
    {
        return;
    }

    // Back up settings in case we need to revert.
    backup = ghb_value_dup(
                ghb_settings_get_value(ud->settings, "subtitle_list"));

    one_burned = subtitle_is_one_burned(ud->settings);
    mux = ghb_settings_combo_int(ud->settings, "FileFormat");

    int count = hb_list_count(title->list_subtitle);
    for (subsettings = NULL, track = 0;
         subsettings == NULL && track < count; track++)
    {
        subsettings = subtitle_add_track(ud, ud->settings, title, track, mux,
                                FALSE, FALSE, &one_burned);
    }
    if (subsettings == NULL)
    {
        subsettings = subtitle_add_track(ud, ud->settings, title, 0, mux,
                                FALSE, TRUE, &one_burned);
    }
    ghb_add_subtitle_to_ui(ud, subsettings);

    if (subsettings != NULL)
    {
        // Pop up the edit dialog
        GtkResponseType response;
        GtkWidget *dialog = GHB_WIDGET(ud->builder, "subtitle_dialog");
        response = gtk_dialog_run(GTK_DIALOG(dialog));
        gtk_widget_hide(dialog);
        if (response != GTK_RESPONSE_OK)
        {
            ghb_settings_take_value(ud->settings, "subtitle_list", backup);
            subsettings = subtitle_get_selected_settings(ud, NULL);
            if (subsettings != NULL)
            {
                subtitle_update_dialog_widgets(ud, subsettings);
            }
            subtitle_refresh_list_ui(ud);
        }
        else
        {
            ghb_value_free(backup);
        }
    }
}
static GValue*
get_selected_asettings(signal_user_data_t *ud)
{
    GtkTreeView *treeview;
    GtkTreePath *treepath;
    GtkTreeSelection *selection;
    GtkTreeModel *store;
    GtkTreeIter iter;
    gint *indices;
    gint row;
    GValue *asettings = NULL;
    const GValue *audio_list;
    
    g_debug("get_selected_asettings ()");
    treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "audio_list"));
    selection = gtk_tree_view_get_selection (treeview);
    if (gtk_tree_selection_get_selected(selection, &store, &iter))
    {
        // Get the row number
        treepath = gtk_tree_model_get_path (store, &iter);
        indices = gtk_tree_path_get_indices (treepath);
        row = indices[0];
        gtk_tree_path_free(treepath);
        // find audio settings
        if (row < 0) return NULL;
        audio_list = ghb_settings_get_value(ud->settings, "audio_list");
        if (row >= ghb_array_len(audio_list))
            return NULL;
        asettings = ghb_array_get_nth(audio_list, row);
    }
    return asettings;
}
Beispiel #4
0
static GValue*
subtitle_get_selected_settings(signal_user_data_t *ud, int *index)
{
    GtkTreeView *tv;
    GtkTreePath *tp;
    GtkTreeSelection *ts;
    GtkTreeModel *tm;
    GtkTreeIter iter;
    gint *indices;
    gint row;
    GValue *subsettings = NULL;
    const GValue *subtitle_list;

    g_debug("get_selected_settings ()");
    tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
    ts = gtk_tree_view_get_selection(tv);
    if (gtk_tree_selection_get_selected(ts, &tm, &iter))
    {
        // Get the row number
        tp = gtk_tree_model_get_path(tm, &iter);
        indices = gtk_tree_path_get_indices(tp);
        row = indices[0];
        gtk_tree_path_free(tp);
        if (row < 0) return NULL;

        subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
        if (row >= ghb_array_len(subtitle_list))
            return NULL;

        subsettings = ghb_array_get_nth(subtitle_list, row);
        if (index != NULL)
            *index = row;
    }
    return subsettings;
}
Beispiel #5
0
void
ghb_subtitle_list_refresh_selected(signal_user_data_t *ud)
{
    GtkTreeView *tv;
    GtkTreeModel *tm;
    GtkTreePath *tp;
    GtkTreeSelection *ts;
    GtkTreeIter ti;
    gint *indices;
    gint row;
    GValue *subsettings = NULL;
    const GValue *subtitle_list;

    g_debug("subtitle_list_refresh_selected()");
    tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
    ts = gtk_tree_view_get_selection(tv);
    if (gtk_tree_selection_get_selected(ts, &tm, &ti))
    {
        // Get the row number
        tp = gtk_tree_model_get_path(tm, &ti);
        indices = gtk_tree_path_get_indices(tp);
        row = indices[0];
        gtk_tree_path_free(tp);
        if (row < 0) return;

        subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
        if (row >= ghb_array_len(subtitle_list))
            return;

        subsettings = ghb_array_get_nth(subtitle_list, row);
        subtitle_refresh_list_row_ui(tm, &ti, subsettings);
    }
}
Beispiel #6
0
const gchar*
ghb_settings_get_const_string(const GValue *settings, const gchar *key)
{
    const GValue* value;
    value = ghb_settings_get_value(settings, key);
    return g_value_get_string(value);
}
Beispiel #7
0
void
ghb_reset_subtitles(signal_user_data_t *ud, GValue *settings)
{
    GValue *slist;
    GValue *subtitle;
    gint count, ii;
    gint title_id, titleindex;
    const hb_title_t *title;

    g_debug("ghb_reset_subtitles");
    ghb_clear_subtitle_list_settings(ud->settings);
    ghb_clear_subtitle_list_ui(ud->builder);
    title_id = ghb_settings_get_int(ud->settings, "title");
    title = ghb_lookup_title(title_id, &titleindex);
    if (title == NULL)
        return;

    slist = ghb_settings_get_value(settings, "subtitle_list");
    count = ghb_array_len(slist);
    for (ii = 0; ii < count; ii++)
    {
        subtitle = ghb_value_dup(ghb_array_get_nth(slist, ii));
        subtitle_add_to_settings(ud->settings, subtitle);
    }
    subtitle_refresh_list_ui(ud);
}
Beispiel #8
0
G_MODULE_EXPORT void
subtitle_remove_clicked_cb(GtkWidget *widget, gchar *path, signal_user_data_t *ud)
{
    GtkTreeView *tv;
    GtkTreePath *tp;
    GtkTreeModel *tm;
    GtkTreeSelection *ts;
    GtkTreeIter ti, nextIter;
    gint row;
    gint *indices;
    GValue *subtitle_list;

    tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
    ts = gtk_tree_view_get_selection(tv);
    tm = gtk_tree_view_get_model(tv);
    tp = gtk_tree_path_new_from_string (path);
    if (gtk_tree_path_get_depth(tp) > 1) return;
    if (gtk_tree_model_get_iter(tm, &ti, tp))
    {
        nextIter = ti;
        if (!gtk_tree_model_iter_next(tm, &nextIter))
        {
            nextIter = ti;
            if (gtk_tree_model_get_iter_first(tm, &nextIter))
            {
                gtk_tree_selection_select_iter(ts, &nextIter);
            }
        }
        else
        {
            gtk_tree_selection_select_iter(ts, &nextIter);
        }

        subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");

        // Get the row number
        indices = gtk_tree_path_get_indices (tp);
        row = indices[0];
        if (row < 0 || row >= ghb_array_len(subtitle_list))
        {
            gtk_tree_path_free(tp);
            return;
        }

        // Update our settings list before removing the row from the
        // 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);
        ghb_array_remove(subtitle_list, row);
        ghb_value_free(old);

        // Remove the selected item
        gtk_tree_store_remove(GTK_TREE_STORE(tm), &ti);

        ghb_live_reset(ud);
    }
    gtk_tree_path_free(tp);
}
Beispiel #9
0
gint
ghb_settings_get_int(const GValue *settings, const gchar *key)
{
    const GValue* value;
    value = ghb_settings_get_value(settings, key);
    if (value == NULL) return 0;
    return ghb_value_int(value);
}
Beispiel #10
0
gchar*
ghb_settings_get_string(const GValue *settings, const gchar *key)
{
    const GValue* value;
    value = ghb_settings_get_value(settings, key);
    if (value == NULL) return g_strdup("");
    return ghb_value_string(value);
}
Beispiel #11
0
gdouble
ghb_settings_get_double(const GValue *settings, const gchar *key)
{
    const GValue* value;
    value = ghb_settings_get_value(settings, key);
    if (value == NULL) return 0;
    return ghb_value_double(value);
}
Beispiel #12
0
gboolean
ghb_settings_get_boolean(const GValue *settings, const gchar *key)
{
    const GValue* value;
    value = ghb_settings_get_value(settings, key);
    if (value == NULL) return FALSE;
    return ghb_value_boolean(value);
}
Beispiel #13
0
G_MODULE_EXPORT void
audio_remove_clicked_cb(GtkWidget *widget, signal_user_data_t *ud)
{
    GtkTreeView *treeview;
    GtkTreePath *treepath;
    GtkTreeSelection *selection;
    GtkTreeModel *store;
    GtkTreeIter iter, nextIter;
    gint *indices;
    gint row;
    GValue *audio_list;

    g_debug("audio_remove_clicked_cb ()");
    treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "audio_list"));
    selection = gtk_tree_view_get_selection (treeview);
    if (gtk_tree_selection_get_selected(selection, &store, &iter))
    {
        nextIter = iter;
        if (!gtk_tree_model_iter_next(store, &nextIter))
        {
            nextIter = iter;
            if (gtk_tree_model_get_iter_first(store, &nextIter))
            {
                gtk_tree_selection_select_iter (selection, &nextIter);
            }
        }
        else
        {
            gtk_tree_selection_select_iter (selection, &nextIter);
        }
        // Get the row number
        treepath = gtk_tree_model_get_path (store, &iter);
        indices = gtk_tree_path_get_indices (treepath);
        row = indices[0];
        gtk_tree_path_free(treepath);
        if (row < 0) return;

        audio_list = ghb_settings_get_value(ud->settings, "audio_list");
        if (row >= ghb_array_len(audio_list))
            return;

        // Update our settings list before removing the row from the
        // 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);
        ghb_value_free(old);
        ghb_array_remove(audio_list, row);

        // Remove the selected item
        gtk_list_store_remove (GTK_LIST_STORE(store), &iter);
        // remove from audio settings list
        widget = GHB_WIDGET (ud->builder, "audio_add");
        gtk_widget_set_sensitive(widget, TRUE);
    }
}
Beispiel #14
0
static void subtitle_def_lang_list_init(signal_user_data_t *ud)
{
    GValue *lang_list;

    // Clear selected languages.
    subtitle_def_selected_lang_list_clear(ud);

    lang_list = ghb_settings_get_value(ud->settings, "SubtitleLanguageList");
    if (lang_list == NULL)
    {
        lang_list = ghb_array_value_new(8);
        ghb_settings_set_value(ud->settings, "SubtitleLanguageList", lang_list);
    }

    int ii, count;
    count = ghb_array_len(lang_list);
    for (ii = 0; ii < count; )
    {
        GValue *lang_val = ghb_array_get_nth(lang_list, ii);
        int idx = ghb_lookup_audio_lang(lang_val);
        if (ii == 0)
        {
            const iso639_lang_t *lang;
            lang = ghb_iso639_lookup_by_int(idx);
            subtitle_update_pref_lang(ud, lang);
        }

        GtkListBox *avail, *selected;
        GtkListBoxRow *row;
        avail = GTK_LIST_BOX(GHB_WIDGET(ud->builder, "subtitle_avail_lang"));
        selected = GTK_LIST_BOX(GHB_WIDGET(ud->builder, "subtitle_selected_lang"));
        row = ghb_find_lang_row(avail, idx);
        if (row)
        {
            GtkWidget *label = gtk_bin_get_child(GTK_BIN(row));
            g_object_ref(G_OBJECT(label));
            gtk_widget_destroy(GTK_WIDGET(row));
            gtk_widget_show(label);
            gtk_list_box_insert(selected, label, -1);
            ii++;
        }
        else
        {
            // Error in list.  Probably duplicate languages.  Remove
            // this item from the list.
            GValue *glang = ghb_array_get_nth(lang_list, ii);
            ghb_array_remove(lang_list, ii);
            ghb_value_free(glang);
            count--;
        }
    }
    if (count == 0)
    {
        subtitle_update_pref_lang(ud, NULL);
    }
}
Beispiel #15
0
void
check_list_full(signal_user_data_t *ud)
{
    GValue *audio_list;
    gint count;

    audio_list = ghb_settings_get_value(ud->settings, "audio_list");
    count = ghb_array_len(audio_list);
    GtkWidget * widget = GHB_WIDGET(ud->builder, "audio_add");
    gtk_widget_set_sensitive(widget, count != 99);
}
Beispiel #16
0
static void
subtitle_add_to_settings(GValue *settings, GValue *subsettings)
{
    // Add the current subtitle settings to the list.
    GValue *subtitle_list;
    gint count;
    gboolean burned, forced, def;
    gint source;

    subtitle_list = ghb_settings_get_value(settings, "subtitle_list");
    if (subtitle_list == NULL)
    {
        subtitle_list = ghb_array_value_new(8);
        ghb_settings_set_value(settings, "subtitle_list", subtitle_list);
    }

    // Validate some settings
    const char *mux_id;
    const hb_container_t *mux;

    mux_id = ghb_settings_get_const_string(settings, "FileFormat");
    mux = ghb_lookup_container_by_name(mux_id);

    source = ghb_settings_get_int(subsettings, "SubtitleSource");
    burned = ghb_settings_get_boolean(subsettings, "SubtitleBurned");
    if (burned && !hb_subtitle_can_burn(source))
    {
        burned = FALSE;
        ghb_settings_set_boolean(subsettings, "SubtitleBurned", burned);
    }
    if (!burned && !hb_subtitle_can_pass(source, mux->format))
    {
        burned = TRUE;
        ghb_settings_set_boolean(subsettings, "SubtitleBurned", burned);
        ghb_settings_set_boolean(subsettings, "SubtitleDefaultTrack", FALSE);
    }
    def = ghb_settings_get_boolean(subsettings, "SubtitleDefaultTrack");
    forced = ghb_settings_get_boolean(subsettings, "SubtitleForced");
    if (forced && !hb_subtitle_can_force(source))
    {
        forced = FALSE;
        ghb_settings_set_boolean(subsettings, "SubtitleForced", forced);
    }

    ghb_array_append(subtitle_list, subsettings);

    // Check consistancy of exclusive flags
    count = ghb_array_len(subtitle_list);
    if (burned)
        ghb_subtitle_exclusive_burn_settings(settings, count-1);
    if (def)
        ghb_subtitle_exclusive_default_settings(settings, count-1);
}
Beispiel #17
0
const gchar*
ghb_get_user_audio_lang(GValue *settings, gint titleindex, gint track)
{
    GValue *audio_list, *asettings;
    const gchar *lang;

    audio_list = ghb_settings_get_value(settings, "audio_list");
    if (ghb_array_len(audio_list) <= track)
        return "und";
    asettings = ghb_array_get_nth(audio_list, track);
    track = ghb_settings_get_int(asettings, "AudioTrack");
    lang = ghb_get_source_audio_lang(titleindex, track);
    return lang;
}
Beispiel #18
0
static void
ghb_clear_subtitle_list_settings(GValue *settings)
{
    GValue *subtitle_list;

    subtitle_list = ghb_settings_get_value(settings, "subtitle_list");
    if (subtitle_list == NULL)
    {
        subtitle_list = ghb_array_value_new(8);
        ghb_settings_set_value(settings, "subtitle_list", subtitle_list);
    }
    else
        ghb_array_value_reset(subtitle_list, 8);
}
Beispiel #19
0
G_MODULE_EXPORT void
subtitle_list_selection_changed_cb(GtkTreeSelection *ts, signal_user_data_t *ud)
{
    GtkTreeModel *tm;
    GtkTreeIter iter;
    GValue *subsettings = NULL;
    int row;

    g_debug("subtitle_list_selection_changed_cb()");
    if (gtk_tree_selection_get_selected(ts, &tm, &iter))
    {
        GtkTreeIter piter;

        if (gtk_tree_model_iter_parent(tm, &piter, &iter))
        {
            GtkTreePath *path;
            GtkTreeView *tv;

            gtk_tree_selection_select_iter(ts, &piter);
            path = gtk_tree_model_get_path(tm, &piter);
            tv = gtk_tree_selection_get_tree_view(ts);
            // Make the parent visible in scroll window if it is not.
            gtk_tree_view_scroll_to_cell(tv, path, NULL, FALSE, 0, 0);
            gtk_tree_path_free(path);
            return;
        }

        GtkTreePath *tp;
        gint *indices;
        GValue *subtitle_list;

        tp = gtk_tree_model_get_path(tm, &iter);
        indices = gtk_tree_path_get_indices(tp);
        row = indices[0];
        gtk_tree_path_free(tp);

        subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
        if (row >= 0 && row < ghb_array_len(subtitle_list))
            subsettings = ghb_array_get_nth(subtitle_list, row);
    }
    subtitle_update_dialog_widgets(ud, subsettings);
    if (subsettings)
    {
        if (ghb_settings_get_boolean(subsettings, "SubtitleBurned"))
        {
            ghb_subtitle_exclusive_burn(ud, row);
        }
    }
}
Beispiel #20
0
void
ghb_clear_audio_list_settings(GValue *settings)
{
    GValue *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);
        ghb_settings_set_value(settings, "audio_list", audio_list);
    }
    else
        ghb_array_value_reset(audio_list, 8);
}
Beispiel #21
0
G_MODULE_EXPORT void
subtitle_remove_lang_clicked_cb(GtkWidget *widget, signal_user_data_t *ud)
{

    GtkListBox *avail, *selected;
    GtkListBoxRow *row;
    GtkWidget *label;

    avail = GTK_LIST_BOX(GHB_WIDGET(ud->builder, "subtitle_avail_lang"));
    selected = GTK_LIST_BOX(GHB_WIDGET(ud->builder, "subtitle_selected_lang"));
    row = gtk_list_box_get_selected_row(selected);
    if (row != NULL)
    {
        gint index;
        GValue *lang_list;

        index = gtk_list_box_row_get_index(row);

        // Remove from UI selected language list box
        label = gtk_bin_get_child(GTK_BIN(row));
        g_object_ref(G_OBJECT(label));
        int idx = (intptr_t)g_object_get_data(G_OBJECT(label), "lang_idx");
        gtk_widget_destroy(GTK_WIDGET(row));
        gtk_widget_show(label);
        // Add to UI available language list box
        gtk_list_box_insert(avail, label, idx);

        // Remove from preset language list
        lang_list = ghb_settings_get_value(ud->settings, "SubtitleLanguageList");
        GValue *glang = ghb_array_get_nth(lang_list, index);
        ghb_array_remove(lang_list, index);
        ghb_value_free(glang);

        ghb_clear_presets_selection(ud);

        if (ghb_array_len(lang_list) > 0)
        {
            const iso639_lang_t *lang;
            GValue *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);
        }
        else
        {
            subtitle_update_pref_lang(ud, NULL);
        }
    }
}
Beispiel #22
0
G_MODULE_EXPORT void
subtitle_edit_clicked_cb(GtkWidget *widget, gchar *path, signal_user_data_t *ud)
{
    GtkTreeView *tv;
    GtkTreePath *tp;
    GtkTreeModel *tm;
    GtkTreeSelection *ts;
    GtkTreeIter ti;

    tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
    ts = gtk_tree_view_get_selection(tv);
    tm = gtk_tree_view_get_model(tv);
    tp = gtk_tree_path_new_from_string (path);
    if (gtk_tree_path_get_depth(tp) > 1) return;
    if (gtk_tree_model_get_iter(tm, &ti, tp))
    {
        GValue *subsettings, *backup;

        gtk_tree_selection_select_iter(ts, &ti);

        // Back up settings in case we need to revert.
        backup = ghb_value_dup(
                    ghb_settings_get_value(ud->settings, "subtitle_list"));

        // Pop up the edit dialog
        GtkResponseType response;
        GtkWidget *dialog = GHB_WIDGET(ud->builder, "subtitle_dialog");
        response = gtk_dialog_run(GTK_DIALOG(dialog));
        gtk_widget_hide(dialog);
        if (response != GTK_RESPONSE_OK)
        {
            ghb_settings_take_value(ud->settings, "subtitle_list", backup);
            subsettings = subtitle_get_selected_settings(ud, NULL);
            if (subsettings != NULL)
            {
                subtitle_update_dialog_widgets(ud, subsettings);
            }
            subtitle_refresh_list_ui(ud);
        }
        else
        {
            ghb_value_free(backup);
        }
    }
}
Beispiel #23
0
void
ghb_subtitle_exclusive_default_settings(GValue *settings, gint index)
{
    GValue *subtitle_list;
    GValue *subtitle;
    gint ii, count;

    subtitle_list = ghb_settings_get_value(settings, "subtitle_list");
    count = ghb_array_len(subtitle_list);
    for (ii = 0; ii < count; ii++)
    {
        if (ii != index)
        {
            subtitle = ghb_array_get_nth(subtitle_list, ii);
            ghb_settings_set_boolean(subtitle, "SubtitleDefaultTrack", FALSE);
        }
    }
}
Beispiel #24
0
void
ghb_subtitle_exclusive_burn_settings(GValue *settings, gint index)
{
    GValue *subtitle_list;
    GValue *subsettings;
    gint ii, count;

    subtitle_list = ghb_settings_get_value(settings, "subtitle_list");
    count = ghb_array_len(subtitle_list);
    for (ii = 0; ii < count; ii++)
    {
        if (ii != index)
        {
            subsettings = ghb_array_get_nth(subtitle_list, ii);
            ghb_settings_set_boolean(subsettings, "SubtitleBurned", FALSE);
        }
    }
}
Beispiel #25
0
void
ghb_subtitle_prune(signal_user_data_t *ud)
{
    GValue *subtitle_list;
    GValue *subsettings;
    gint ii;
    gboolean one_burned = FALSE;

    subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
    if (subtitle_list == NULL)
        return;

    const char *mux_id;
    const hb_container_t *mux;

    mux_id = ghb_settings_get_const_string(ud->settings, "FileFormat");
    mux = ghb_lookup_container_by_name(mux_id);

    for (ii = 0; ii < ghb_array_len(subtitle_list); )
    {
        gboolean burned;
        int source;

        subsettings = ghb_array_get_nth(subtitle_list, ii);
        burned = ghb_settings_get_boolean(subsettings, "SubtitleBurned");
        source = ghb_settings_get_boolean(subsettings, "SubtitleSource");
        burned = burned || !hb_subtitle_can_pass(source, mux->format);
        if (burned && one_burned)
        {
            GValue *gsub = ghb_array_get_nth(subtitle_list, ii);
            ghb_array_remove(subtitle_list, ii);
            ghb_value_free(gsub);
            continue;
        }
        one_burned = one_burned || burned;
        ghb_settings_set_boolean(subsettings, "SubtitleBurned", burned);
        ii++;
    }
    subsettings = subtitle_get_selected_settings(ud, NULL);
    if (subsettings != NULL)
    {
        subtitle_update_dialog_widgets(ud, subsettings);
    }
}
Beispiel #26
0
void
ghb_set_pref_audio_from_settings(signal_user_data_t *ud, GValue *settings)
{
    const GValue *audio_list, *audio;
    gint count, ii;

    // Clear the audio list
    ghb_clear_audio_list_ui(ud->builder);

    audio_list = ghb_settings_get_value(settings, "audio_list");
    count = ghb_array_len(audio_list);
    for (ii = 0; ii < count; ii++)
    {
        audio = ghb_array_get_nth(audio_list, ii);
        ghb_add_audio_to_ui(ud->builder, audio);
        ghb_adjust_audio_rate_combos(ud);
    }
    check_list_full(ud);
}
Beispiel #27
0
static gboolean subtitle_is_one_burned(GValue *settings)
{
    GValue *subtitle_list, *subsettings;
    int count, ii;

    subtitle_list = ghb_settings_get_value(settings, "subtitle_list");
    if (subtitle_list == NULL)
        return FALSE;

    count = ghb_array_len(subtitle_list);
    for (ii = 0; ii < count; ii++)
    {
        subsettings = ghb_array_get_nth(subtitle_list, ii);
        if (ghb_settings_get_boolean(subsettings, "SubtitleBurned"))
        {
            return TRUE;
        }
    }
    return FALSE;
}
Beispiel #28
0
static gboolean
ghb_add_audio_to_settings(GValue *settings, GValue *asettings)
{
    GValue *audio_list;
    const gchar * track;
    int count;

    audio_list = ghb_settings_get_value(settings, "audio_list");
    if (audio_list == NULL)
    {
        audio_list = ghb_array_value_new(8);
        ghb_settings_set_value(settings, "audio_list", audio_list);
    }
    count = ghb_array_len(audio_list);
    // Don't allow more than 99
    // This is a hard limit imposed by libhb/reader.c:GetFifoForId()
    if (count >= 99)
    {
        ghb_value_free(asettings);
        return FALSE;
    }

    int title_no = ghb_settings_get_int(settings, "title_no");
    int track_no = ghb_settings_get_int(asettings, "AudioTrack");
    track = ghb_audio_track_description(track_no, title_no);
    ghb_settings_set_string(asettings, "AudioTrackDescription", track);

    GValue *aname;
    aname = ghb_dict_lookup(asettings, "AudioTrackName");
    if (aname == NULL)
    {
        ghb_settings_set_string(asettings, "AudioTrackName", "");
    }
    if (ghb_array_len(audio_list) >= 99)
    {
        ghb_value_free(asettings);
        return FALSE;
    }
    ghb_array_append(audio_list, asettings);
    return TRUE;
}
Beispiel #29
0
int
ghb_ui_update_from_settings(signal_user_data_t *ud, const gchar *name, const GValue *settings)
{
    GObject *object;
    GValue * value;

    g_debug("ghb_ui_update_from_settings() %s", name);
    if (name == NULL)
        return 0;
    value = ghb_settings_get_value(settings, name);
    if (value == NULL)
        return 0;
    object = GHB_OBJECT(ud->builder, name);
    if (object == NULL)
    {
        g_debug("Failed to find widget for key: %s\n", name);
        return -1;
    }
    ghb_update_widget((GtkWidget*)object, value);
    // Its possible the value hasn't changed. Since settings are only
    // updated when the value changes, I'm initializing settings here as well.
    ghb_widget_to_setting(ud->settings, (GtkWidget*)object);
    return 0;
}
Beispiel #30
0
G_MODULE_EXPORT void
subtitle_add_lang_clicked_cb(GtkWidget *widget, signal_user_data_t *ud)
{
    GtkListBox *avail = GTK_LIST_BOX(GHB_WIDGET(ud->builder, "subtitle_avail_lang"));
    GtkListBox *selected = GTK_LIST_BOX(GHB_WIDGET(ud->builder, "subtitle_selected_lang"));
    GtkListBoxRow *row;
    GtkWidget *label;

    row = gtk_list_box_get_selected_row(avail);
    if (row != NULL)
    {
        int idx;
        const iso639_lang_t *lang;
        GValue *glang, *lang_list;

        // Remove from UI available language list box
        label = gtk_bin_get_child(GTK_BIN(row));
        g_object_ref(G_OBJECT(label));
        gtk_widget_destroy(GTK_WIDGET(row));
        gtk_widget_show(label);
        // Add to UI selected language list box
        gtk_list_box_insert(selected, label, -1);

        // Add to preset language list
        idx = (intptr_t)g_object_get_data(G_OBJECT(label), "lang_idx");
        lang = ghb_iso639_lookup_by_int(idx);
        glang = ghb_string_value_new(lang->iso639_2);
        lang_list = ghb_settings_get_value(ud->settings, "SubtitleLanguageList");
        if (ghb_array_len(lang_list) == 0)
        {
            subtitle_update_pref_lang(ud, lang);
        }
        ghb_array_append(lang_list, glang);
        ghb_clear_presets_selection(ud);
    }
}