Esempio n. 1
0
static void
subtitle_set_track_description(GValue *settings, GValue *subsettings)
{
    char *desc;

    if (ghb_settings_get_int(subsettings, "SubtitleSource") == SRTSUB)
    {
        gchar *filename, *code;
        const gchar *lang;

        lang = ghb_settings_combo_option(subsettings, "SrtLanguage");
        code = ghb_settings_get_string(subsettings, "SrtCodeset");

        filename = ghb_settings_get_string(subsettings, "SrtFile");
        if (g_file_test(filename, G_FILE_TEST_IS_REGULAR))
        {
            gchar *basename;

            basename = g_path_get_basename(filename);
            desc = g_strdup_printf("%s (%s)(SRT)(%s)", lang, code, basename);
            g_free(basename);
        }
        else
        {
            desc = g_strdup_printf("%s (%s)(SRT)", lang, code);
        }
        g_free(code);
    }
    else
    {
        int title_id, titleindex;
        const hb_title_t *title;
        int track;
        hb_subtitle_t *subtitle;

        title_id = ghb_settings_get_int(settings, "title");
        title = ghb_lookup_title(title_id, &titleindex);
        track = ghb_settings_get_int(subsettings, "SubtitleTrack");
        if (track < 0)
        {
            desc = g_strdup(_("Foreign Audio Search"));
        }
        else
        {
            subtitle = ghb_get_subtitle_info(title, track);
            desc = g_strdup_printf("%d - %s (%s)", track + 1, subtitle->lang,
                                   hb_subsource_name(subtitle->source));
        }
    }

    ghb_settings_set_string(
        subsettings, "SubtitleTrackDescription", desc);

    g_free(desc);
}
Esempio n. 2
0
gchar*
get_deblock_val(signal_user_data_t *ud)
{
    gchar *alpha, *beta;
    gchar *result;
    alpha = ghb_settings_get_string(ud->x264_priv, "x264_deblock_alpha");
    beta = ghb_settings_get_string(ud->x264_priv, "x264_deblock_beta");
    result = g_strdup_printf("%s,%s", alpha, beta);
    g_free(alpha);
    g_free(beta);
    return result;
}
Esempio n. 3
0
G_MODULE_EXPORT void
x264_use_advanced_options_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
    ghb_widget_to_setting(ud->settings, widget);

    if (ghb_settings_get_boolean(ud->prefs, "HideAdvancedVideoSettings") &&
        ghb_settings_get_boolean(ud->settings, "x264UseAdvancedOptions"))
    {
        ghb_ui_update(ud, "x264UseAdvancedOptions", ghb_boolean_value(FALSE));
        return;
    }

    if (ghb_settings_get_boolean(ud->settings, "x264UseAdvancedOptions"))
    {
        ghb_ui_update(ud, "x264PresetSlider", ghb_int_value(5));
        ghb_ui_update(ud, "x264Tune", ghb_string_value("none"));
        ghb_ui_update(ud, "h264Profile", ghb_string_value("auto"));
        ghb_ui_update(ud, "h264Level", ghb_string_value("auto"));

        char *options = ghb_settings_get_string(ud->settings, "x264Option");
        ghb_ui_update(ud, "x264OptionExtra", ghb_string_value(options));
        g_free(options);
    }

    ghb_check_dependency(ud, widget, NULL);
    ghb_clear_presets_selection(ud);
}
Esempio n. 4
0
G_MODULE_EXPORT void
srt_file_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
    GValue *subsettings;

    g_debug("srt_file_changed_cb()");
    ghb_check_dependency(ud, widget, NULL);
    ghb_widget_to_setting(ud->settings, widget);
    subsettings = subtitle_get_selected_settings(ud, NULL);
    if (subsettings != NULL)
    {
        gchar *filename, *dirname;

        ghb_widget_to_setting(subsettings, widget);
        subtitle_set_track_description(ud->settings, subsettings);
        ghb_subtitle_list_refresh_selected(ud);
        ghb_live_reset(ud);

        // Update SrtDir preference
        filename = ghb_settings_get_string(subsettings, "SrtFile");
        if (g_file_test(filename, G_FILE_TEST_IS_DIR))
        {
            ghb_settings_set_string(ud->prefs, "SrtDir", filename);
        }
        else
        {
            dirname = g_path_get_dirname(filename);
            ghb_settings_set_string(ud->prefs, "SrtDir", dirname);
            g_free(dirname);
        }
        ghb_pref_save(ud->prefs, "SrtDir");
        g_free(filename);
    }
}
Esempio n. 5
0
G_MODULE_EXPORT gboolean
lavc_focus_out_cb(GtkWidget *widget, GdkEventFocus *event,
    signal_user_data_t *ud)
{
    ghb_widget_to_setting(ud->settings, widget);

#if 0
    gchar *options, *sopts;
    ****************************************************************
    When there are lavc widget in the future, this will be populated
    ****************************************************************
    options = ghb_settings_get_string(ud->settings, "x264Option");
    sopts = sanitize_x264opts(ud, options);
    ignore_options_update = TRUE;
    if (sopts != NULL && strcmp(sopts, options) != 0)
    {
        ghb_ui_update(ud, "x264Option", ghb_string_value(sopts));
        ghb_x264_parse_options(ud, sopts);
    }
    g_free(options);
    g_free(sopts);
    ignore_options_update = FALSE;
#endif
    return FALSE;
}
Esempio n. 6
0
static void
subtitle_set_track_description(GValue *subsettings)
{
    char *track;

    if (ghb_settings_get_int(subsettings, "SubtitleSource") == SRTSUB)
    {
        gchar *filename, *code;
        const gchar *lang;

        lang = ghb_settings_combo_option(subsettings, "SrtLanguage");
        code = ghb_settings_get_string(subsettings, "SrtCodeset");

        filename = ghb_settings_get_string(subsettings, "SrtFile");
        if (g_file_test(filename, G_FILE_TEST_IS_REGULAR))
        {
            gchar *basename;

            basename = g_path_get_basename(filename);
            track = g_strdup_printf("%s (%s)(SRT)(%s)", lang, code, basename);
            g_free(basename);
        }
        else
        {
            track = g_strdup_printf("%s (%s)(SRT)", lang, code);
        }
        g_free(code);
    }
    else
    {
        track = g_strdup(
                    ghb_settings_combo_option(subsettings, "SubtitleTrack"));
    }

    ghb_settings_set_string(
        subsettings, "SubtitleTrackDescription", track);

    g_free(track);
}
Esempio n. 7
0
G_MODULE_EXPORT void
queue_edit_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
{
    GtkTreeView *treeview;
    GtkTreeSelection *selection;
    GtkTreeModel *store;
    GtkTreeIter iter;
    gint row;
    gint *indices;
    gint status;

    g_debug("queue_key_press_cb ()");
    treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "queue_list"));
    store = gtk_tree_view_get_model(treeview);

    selection = gtk_tree_view_get_selection (treeview);
    if (gtk_tree_selection_get_selected(selection, &store, &iter))
    {
        GtkTreePath *treepath;

        treepath = gtk_tree_model_get_path (store, &iter);
        // Find the entry in the queue
        indices = gtk_tree_path_get_indices (treepath);
        row = indices[0];
        // Can only free the treepath After getting what I need from
        // indices since this points into treepath somewhere.
        gtk_tree_path_free (treepath);
        if (row < 0) return;
        if (row >= ghb_array_len(ud->queue))
            return;
        ghb_queue_edit_settings = ghb_array_get_nth(ud->queue, row);
        status = ghb_settings_get_int(ghb_queue_edit_settings, "job_status");
        if (status == GHB_QUEUE_PENDING)
        {
            // Remove the selected item
            gtk_tree_store_remove(GTK_TREE_STORE(store), &iter);
            // Remove the corresponding item from the queue list
            ghb_array_remove(ud->queue, row);
        }
        else
        {
            ghb_queue_edit_settings = ghb_value_dup(ghb_queue_edit_settings);
        }
        gchar *source;
        source = ghb_settings_get_string(ghb_queue_edit_settings, "source");
        ghb_do_scan(ud, source, 0, FALSE);
        g_free(source);
    }
}
Esempio n. 8
0
G_MODULE_EXPORT void
x264_entry_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
    g_debug("x264_entry_changed_cb ()");

    static char *tt = NULL;

    if (tt == NULL)
    {
        GtkWidget *eo = GTK_WIDGET(GHB_WIDGET(ud->builder, "x264OptionExtra"));
        tt = gtk_widget_get_tooltip_text(eo);
    }

    if (!ignore_options_update)
    {
        GtkWidget *textview;
        gchar *options;

        textview = GTK_WIDGET(GHB_WIDGET(ud->builder, "x264Option"));
        ghb_widget_to_setting(ud->settings, textview);
        options = ghb_settings_get_string(ud->settings, "x264Option");

        ignore_options_update = TRUE;
        ghb_x264_parse_options(ud, options);
        if (!gtk_widget_has_focus(textview))
        {
            gchar *sopts;

            sopts = sanitize_x264opts(ud, options);
            ghb_ui_update(ud, "x264Option", ghb_string_value(sopts));
            ghb_x264_parse_options(ud, sopts);

            GtkWidget *eo = GTK_WIDGET(GHB_WIDGET(ud->builder, "x264OptionExtra"));
            char * new_tt;
            if (sopts)
                new_tt = g_strdup_printf("%s\n\nExpanded Options:\n\"%s\"", tt, sopts);
            else
                new_tt = g_strdup_printf("%s\n\nExpanded Options:\n\"\"", tt);
            gtk_widget_set_tooltip_text(eo, new_tt);
            g_free(new_tt);

            g_free(options);
            options = sopts;
        }
        g_free(options);
        ignore_options_update = FALSE;
    }
}
Esempio n. 9
0
G_MODULE_EXPORT gboolean
x264_focus_out_cb(GtkWidget *widget, GdkEventFocus *event,
    signal_user_data_t *ud)
{
    gchar *options, *sopts;

    ghb_widget_to_setting(ud->settings, widget);
    options = ghb_settings_get_string(ud->settings, "x264Option");
    sopts = sanitize_x264opts(ud, options);
    ignore_options_update = TRUE;
    if (sopts != NULL && strcmp(sopts, options) != 0)
    {
        ghb_ui_update(ud, "x264Option", ghb_string_value(sopts));
        ghb_x264_parse_options(ud, sopts);
    }
    g_free(options);
    g_free(sopts);
    ignore_options_update = FALSE;
    return FALSE;
}
Esempio n. 10
0
static void
subtitle_refresh_list_row_ui(
    GtkTreeModel *tm,
    GtkTreeIter *ti,
    GValue *subsettings)
{
    GtkTreeIter cti;
    gboolean forced, burned, def;
    char *info_src, *info_src_2;
    char *info_dst, *info_dst_2;


    info_src_2 = NULL;
    info_dst_2 = NULL;

    forced = ghb_settings_get_boolean(subsettings, "SubtitleForced");
    burned = ghb_settings_get_boolean(subsettings, "SubtitleBurned");
    def = ghb_settings_get_boolean(subsettings, "SubtitleDefaultTrack");
    info_src = ghb_settings_get_string(subsettings, "SubtitleTrackDescription");
    if (ghb_settings_get_int(subsettings, "SubtitleSource") == SRTSUB)
    {
        gint offset;
        offset = ghb_settings_get_int(subsettings, "SrtOffset");
        if (offset != 0)
        {
            info_dst_2 = g_strdup_printf("Offset: %dms", offset);
        }
    }

    GString *str = g_string_new("");
    g_string_append_printf(str, "%s ", burned ? "Burned Into Video" :
                                                "Passthrough");
    if (forced)
    {
        g_string_append_printf(str, "(Forced Subtitles Only)");
    }
    if (def)
    {
        g_string_append_printf(str, "(Default)");
    }

    info_dst = g_string_free(str, FALSE);

    gtk_tree_store_set(GTK_TREE_STORE(tm), ti,
        // These are displayed in list
        0, info_src,
        1, "-->",
        2, info_dst,
        3, "hb-edit",
        4, "hb-queue-delete",
        5, 0.5,
        -1);

    if (info_src_2 != NULL || info_dst_2 != NULL)
    {
        if (info_src_2 == NULL)
            info_src_2 = g_strdup("");
        if (info_dst_2 == NULL)
            info_dst_2 = g_strdup("");

        if(!gtk_tree_model_iter_children(tm, &cti, ti))
        {
            gtk_tree_store_append(GTK_TREE_STORE(tm), &cti, ti);
        }
        gtk_tree_store_set(GTK_TREE_STORE(tm), &cti,
            // These are displayed in list
            0, info_src_2,
            2, info_dst_2,
            5, 0.0,
            -1);
    }
    else
    {
        if(gtk_tree_model_iter_children(tm, &cti, ti))
        {
            gtk_tree_store_remove(GTK_TREE_STORE(tm), &cti);
        }
    }

    g_free(info_src);
    g_free(info_src_2);
    g_free(info_dst);
    g_free(info_dst_2);
}
Esempio n. 11
0
static void
add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter)
{
    GtkTreeView *treeview;
    GtkTreeIter iter;
    GtkTreeStore *store;
    gchar *info;
    gint status;
    GtkTreeIter citer;
    gchar *dest, *preset, *vol_name, *basename;
    const gchar *vcodec, *container;
    gchar *fps, *vcodec_abbr;
    gint title, start_point, end_point, width, height;
    gint source_width, source_height;
    gboolean pass2 = FALSE, keep_aspect, vqtype, turbo;
    gint pic_par;
    gchar *escape, *escape2;
    
    g_debug("update_queue_list ()");
    if (settings == NULL) return;
    treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "queue_list"));
    store = GTK_TREE_STORE(gtk_tree_view_get_model(treeview));
        
    title = ghb_settings_get_int(settings, "titlenum");
    start_point = ghb_settings_get_int(settings, "start_point");
    end_point = ghb_settings_get_int(settings, "end_point");
    vol_name = ghb_settings_get_string(settings, "volume_label");
    dest = ghb_settings_get_string(settings, "destination");
    basename = g_path_get_basename(dest);
    escape = g_markup_escape_text(basename, -1);
    escape2 = g_markup_escape_text(vol_name, -1);

    vqtype = ghb_settings_get_boolean(settings, "vquality_type_constant");
    if (!vqtype)
        pass2 = ghb_settings_get_boolean(settings, "VideoTwoPass");
    const gchar *points = "Chapters";
    if (ghb_settings_combo_int(settings, "PtoPType") == 0)
        points = "Chapters";
    else if (ghb_settings_combo_int(settings, "PtoPType") == 1)
        points = "Seconds";
    else if (ghb_settings_combo_int(settings, "PtoPType") == 2)
        points = "Frames";
    info = g_strdup_printf 
    (
        "<big><b>%s</b></big> "
        "<small>(Title %d, %s %d through %d, %d Video %s)"
        " --> %s</small>",
         escape2, title, points, start_point, end_point, 
         pass2 ? 2:1, pass2 ? "Passes":"Pass", escape
    );
    g_free(basename);
    g_free(escape);
    g_free(escape2);

    if (piter)
        iter = *piter;
    else
        gtk_tree_store_append(store, &iter, NULL);

    gtk_tree_store_set(store, &iter, 1, info, 2, "hb-queue-delete", -1);
    g_free(info);
    status = ghb_settings_get_int(settings, "job_status");
    switch (status)
    {
        case GHB_QUEUE_PENDING:
            gtk_tree_store_set(store, &iter, 0, "hb-queue-job", -1);
            break;
        case GHB_QUEUE_CANCELED:
            gtk_tree_store_set(store, &iter, 0, "hb-canceled", -1);
            break;
        case GHB_QUEUE_RUNNING:
            gtk_tree_store_set(store, &iter, 0, "hb-working0", -1);
            break;
        case GHB_QUEUE_DONE:
            gtk_tree_store_set(store, &iter, 0, "hb-complete", -1);
            break;
        default:
            gtk_tree_store_set(store, &iter, 0, "hb-queue-job", -1);
            break;
    }

    GString *str = g_string_new("");
    gboolean markers;
    gboolean preset_modified;
    gint mux;
    const GValue *path;

    container = ghb_settings_combo_option(settings, "FileFormat");
    mux = ghb_settings_combo_int(settings, "FileFormat");
    preset_modified = ghb_settings_get_boolean(settings, "preset_modified");
    path = ghb_settings_get_value(settings, "preset");
    preset = ghb_preset_path_string(path);
    markers = ghb_settings_get_boolean(settings, "ChapterMarkers");

    if (preset_modified)
        g_string_append_printf(str, 
            "<b>Modified Preset Based On:</b> <small>%s</small>\n", 
            preset);
    else
        g_string_append_printf(str, 
            "<b>Preset:</b> <small>%s</small>\n", 
            preset);

    if (markers)
    {
        g_string_append_printf(str, 
            "<b>Format:</b> <small>%s Container, Chapter Markers</small>\n", 
            container);
    }
    else
    {
        g_string_append_printf(str, 
            "<b>Format:</b> <small>%s Container</small>\n", container);
    }
    if (mux == HB_MUX_MP4)
    {
        gboolean ipod, http, large;

        ipod = ghb_settings_get_boolean(settings, "Mp4iPodCompatible");
        http = ghb_settings_get_boolean(settings, "Mp4HttpOptimize");
        large = ghb_settings_get_boolean(settings, "Mp4LargeFile");
        if (http || ipod || large)
        {
            g_string_append_printf(str, "<b>MP4 Options:</b><small>");
            if (ipod)
                g_string_append_printf(str, " - iPod 5G Support");
            if (http)
                g_string_append_printf(str, " - Web Optimized");
            if (large)
                g_string_append_printf(str, " - Large File Size (>4GB)");
            g_string_append_printf(str, "</small>\n");
        }
    }
    escape = g_markup_escape_text(dest, -1);
    g_string_append_printf(str, 
        "<b>Destination:</b> <small>%s</small>\n", escape);

    width = ghb_settings_get_int(settings, "scale_width");
    height = ghb_settings_get_int(settings, "scale_height");
    pic_par = ghb_settings_combo_int(settings, "PicturePAR");
    keep_aspect = ghb_settings_get_boolean(settings, "PictureKeepRatio");

    gchar *aspect_desc;
    switch (pic_par)
    {
    case 0:
    {
        if (keep_aspect)
        {
            aspect_desc = "(Aspect Preserved)";
        }
        else
        {
            aspect_desc = "(Aspect Lost)";
        }
    } break;

    case 1:
    {
        aspect_desc = "(Strict Anamorphic)";
    } break;

    case 2:
    {
        aspect_desc = "(Loose Anamorphic)";
    } break;

    case 3:
    {
        aspect_desc = "(Custom Anamorphic)";
    } break;

    default:
    {
        aspect_desc = "(Unknown)";
    } break;
    }
    vqtype = ghb_settings_get_boolean(settings, "vquality_type_constant");
    vcodec = ghb_settings_combo_option(settings, "VideoEncoder");
    vcodec_abbr = ghb_settings_get_string(settings, "VideoEncoder");

    gchar *vq_desc = "Error";
    gchar *vq_units = "";
    gchar *vqstr;
    gdouble vqvalue;
    if (!vqtype)
    {
        // Has to be bitrate
        vqvalue = ghb_settings_get_int(settings, "VideoAvgBitrate");
        vq_desc = "Bitrate:";
        vq_units = "kbps";
        vqstr = g_strdup_printf("%d", (gint)vqvalue);
    }
    else
    {
        // Constant quality
        vqvalue = ghb_settings_get_double(settings, "VideoQualitySlider");
        vq_desc = "Constant Quality:";
        vqstr = g_strdup_printf("%d", (gint)vqvalue);
        if (strcmp(vcodec_abbr, "x264") == 0)
        {
            vq_units = "(RF)";
        }
        else
        {
            vq_units = "(QP)";
        }
    }
    fps = ghb_settings_get_string(settings, "VideoFramerate");
    if (strcmp("source", fps) == 0)
    {
        g_free(fps);
        if (ghb_settings_get_boolean(settings, "VideoFramerateCFR"))
            fps = g_strdup("Same As Source (constant)");
        else
            fps = g_strdup("Same As Source (variable)");
    }
    else
    {
        if (ghb_settings_get_boolean(settings, "VideoFrameratePFR"))
        {
            gchar *tmp;
            tmp = g_strdup_printf("Peak %s (may be lower)", fps);
            g_free(fps);
            fps = tmp;
        }
        else
        {
            gchar *tmp;
            tmp = g_strdup_printf("%s (constant frame rate)", fps);
            g_free(fps);
            fps = tmp;
        }
    }
    source_width = ghb_settings_get_int(settings, "source_width");
    source_height = ghb_settings_get_int(settings, "source_height");
    g_string_append_printf(str,
        "<b>Picture:</b> Source: <small>%d x %d, Output %d x %d %s</small>\n",
         source_width, source_height, width, height, aspect_desc);

    gint decomb, detel;
    gboolean decomb_deint;
    gboolean filters = FALSE;

    decomb_deint = ghb_settings_get_boolean(settings, "PictureDecombDeinterlace");
    decomb = ghb_settings_combo_int(settings, "PictureDecomb");
    g_string_append_printf(str, "<b>Filters:</b><small>");
    detel = ghb_settings_combo_int(settings, "PictureDetelecine");
    if (detel)
    {
        g_string_append_printf(str, " - Detelecine");
        if (detel == 1)
        {
            gchar *cust;
            cust = ghb_settings_get_string(settings, "PictureDetelecineCustom");
            g_string_append_printf(str, ": %s", cust);
            g_free(cust);
        }
        filters = TRUE;
    }
    if (decomb_deint && decomb)
    {
        g_string_append_printf(str, " - Decomb");
        if (decomb == 1)
        {
            gchar *cust;
            cust = ghb_settings_get_string(settings, "PictureDecombCustom");
            g_string_append_printf(str, ": %s", cust);
            g_free(cust);
        }
        filters = TRUE;
    }
    else if (!decomb_deint)
    {
        gint deint = ghb_settings_combo_int(settings, "PictureDeinterlace");
        if (deint)
        {
            if (deint == 1)
            {
                gchar *cust = ghb_settings_get_string(settings,
                                                "PictureDeinterlaceCustom");
                g_string_append_printf(str, " - Deinterlace: %s", cust);
                g_free(cust);
            }
            else
            {
                const gchar *opt = ghb_settings_combo_option(settings,
                                                    "PictureDeinterlace");
                g_string_append_printf(str, " - Deinterlace: %s", opt);
            }
            filters = TRUE;
        }
    }
    gint denoise = ghb_settings_combo_int(settings, "PictureDenoise");
    if (denoise)
    {
        if (denoise == 1)
        {
            gchar *cust = ghb_settings_get_string(settings,
                                                    "PictureDenoiseCustom");
            g_string_append_printf(str, " - Denoise: %s", cust);
            g_free(cust);
        }
        else
        {
            const gchar *opt = ghb_settings_combo_option(settings,
                                                    "PictureDenoise");
            g_string_append_printf(str, " - Denoise: %s", opt);
        }
        filters = TRUE;
    }
    gint deblock = ghb_settings_get_int(settings, "PictureDeblock");
    if (deblock >= 5)
    {
        g_string_append_printf(str, " - Deblock (%d)", deblock);
        filters = TRUE;
    }
    if (ghb_settings_get_boolean(settings, "VideoGrayScale"))
    {
        g_string_append_printf(str, " - Grayscale");
        filters = TRUE;
    }
    if (!filters)
        g_string_append_printf(str, " None");
    g_string_append_printf(str, "</small>\n");

    g_string_append_printf(str,
        "<b>Video:</b> <small>%s, Framerate: %s, %s %s%s</small>\n",
         vcodec, fps, vq_desc, vqstr, vq_units);

    turbo = ghb_settings_get_boolean(settings, "VideoTurboTwoPass");
    if (turbo)
    {
        g_string_append_printf(str, "<b>Turbo:</b> <small>On</small>\n");
    }
    if (strcmp(vcodec_abbr, "x264") == 0 ||
        strcmp(vcodec_abbr, "ffmpeg") == 0)
    {
        gchar *opts = ghb_build_advanced_opts_string(settings);
        g_string_append_printf(str, 
            "<b>Advanced Options:</b> <small>%s</small>\n", opts);
        g_free(opts);
    }
    // Add the audios
    gint count, ii;
    const GValue *audio_list;

    audio_list = ghb_settings_get_value(settings, "audio_list");
    count = ghb_array_len(audio_list);
    for (ii = 0; ii < count; ii++)
    {
        gchar *quality = NULL, *samplerate, *track;
        const gchar *acodec, *mix;
        GValue *asettings;
        gdouble sr;

        asettings = ghb_array_get_nth(audio_list, ii);

        acodec = ghb_settings_combo_option(asettings, "AudioEncoderActual");
        double q = ghb_settings_get_double(asettings, "AudioTrackQuality");
        if (ghb_settings_get_boolean(asettings, "AudioTrackQualityEnable") &&
            q != HB_INVALID_AUDIO_QUALITY)
        {
            int codec = ghb_settings_combo_int(asettings, "AudioEncoderActual");
            quality = ghb_format_quality("Quality: ", codec, q);
        }
        else
        {
            const char *br;
            br = ghb_settings_get_string(asettings, "AudioBitrate");
            quality = g_strdup_printf("Bitrate: %s", br);
        }
        sr = ghb_settings_get_double(asettings, "AudioSamplerate");
        samplerate = ghb_settings_get_string(asettings, "AudioSamplerate");
        if ((int)sr == 0)
        {
            samplerate = g_strdup("Same As Source");
        }
        else
        {
            samplerate = g_strdup_printf("%.4g", sr);
        }
        track = ghb_settings_get_string(asettings, "AudioTrackDescription");
        mix = ghb_settings_combo_option(asettings, "AudioMixdown");
        if (count == 1)
            g_string_append_printf(str, "<b>Audio:</b>");
        else if (ii == 0)
            g_string_append_printf(str, "<b>Audio:</b>\n");
        if (count != 1)
            g_string_append_printf(str, "\t");

        g_string_append_printf(str,
            "<small> %s, Encoder: %s, Mixdown: %s, SampleRate: %s, %s</small>\n",
             track, acodec, mix, samplerate, quality);
        g_free(track);
        g_free(quality);
        g_free(samplerate);
    }

    // Add the audios
    const GValue *sub_list;

    sub_list = ghb_settings_get_value(settings, "subtitle_list");
    count = ghb_array_len(sub_list);
    for (ii = 0; ii < count; ii++)
    {
        GValue *settings;
        gchar *track;
        gboolean force, burn, def;
        gint source;

        settings = ghb_array_get_nth(sub_list, ii);
        track = ghb_settings_get_string(settings, "SubtitleTrackDescription");
        source = ghb_settings_get_int(settings, "SubtitleSource");
        force = ghb_settings_get_boolean(settings, "SubtitleForced");
        burn = ghb_settings_get_boolean(settings, "SubtitleBurned");
        def = ghb_settings_get_boolean(settings, "SubtitleDefaultTrack");
        if (count == 1)
            g_string_append_printf(str, "<b>Subtitle:</b>");
        else if (ii == 0)
            g_string_append_printf(str, "<b>Subtitles:</b>\n");
        if (count != 1)
            g_string_append_printf(str, "\t");

        if (source != SRTSUB)
        {
            g_string_append_printf(str,
                "<small> %s%s%s%s</small>",
                track, 
                force ? " (Force)":"",
                burn  ? " (Burn)":"",
                def   ? " (Default)":""
            );
        }
        else
        {
            gint offset;
            gchar *filename, *basename, *code;

            offset = ghb_settings_get_int(settings, "SrtOffset");
            filename = ghb_settings_get_string(settings, "SrtFile");
            basename = g_path_get_basename(filename);
            code = ghb_settings_get_string(settings, "SrtCodeset");
            g_string_append_printf(str,
                "<small> %s (%s), %s, Offset (ms) %d%s</small>",
                track, code, basename, offset,
                def   ? " (Default)":""
            );
            g_free(filename);
            g_free(basename);
            g_free(code);
        }
        if (ii < count-1)
            g_string_append_printf(str, "\n");
        g_free(track);
    }

    info = g_string_free(str, FALSE);
    gtk_tree_store_append(store, &citer, &iter);
    gtk_tree_store_set(store, &citer, 1, info, -1);
    g_free(info);
    g_free(fps);
    g_free(vcodec_abbr);
    g_free(vol_name);
    g_free(dest);
    g_free(preset);
}
Esempio n. 12
0
static gboolean
validate_settings(signal_user_data_t *ud, GValue *settings, gint batch)
{
    // Check to see if the dest file exists or is
    // already in the queue
    gchar *message, *dest;
    gint count, ii;
    gint titleindex;

    titleindex = ghb_settings_combo_int(settings, "title");
    if (titleindex < 0) return FALSE;
    dest = ghb_settings_get_string(settings, "destination");
    count = ghb_array_len(ud->queue);
    for (ii = 0; ii < count; ii++)
    {
        GValue *js;
        gchar *filename;

        js = ghb_array_get_nth(ud->queue, ii);
        filename = ghb_settings_get_string(js, "destination");
        if (strcmp(dest, filename) == 0)
        {
            message = g_strdup_printf(
                        "Destination: %s\n\n"
                        "Another queued job has specified the same destination.\n"
                        "Do you want to overwrite?",
                        dest);
            if (!ghb_message_dialog(GTK_MESSAGE_QUESTION, message, "Cancel", "Overwrite"))
            {
                g_free(filename);
                g_free(dest);
                g_free(message);
                return FALSE;
            }
            g_free(message);
            break;
        }
        g_free(filename);
    }
    gchar *destdir = g_path_get_dirname(dest);
    if (!g_file_test(destdir, G_FILE_TEST_IS_DIR))
    {
        message = g_strdup_printf(
                    "Destination: %s\n\n"
                    "This is not a valid directory.",
                    destdir);
        ghb_message_dialog(GTK_MESSAGE_ERROR, message, "Cancel", NULL);
        g_free(dest);
        g_free(message);
        g_free(destdir);
        return FALSE;
    }
#if !defined(_WIN32)
    // This doesn't work properly on windows
    if (g_access(destdir, R_OK|W_OK) != 0)
    {
        message = g_strdup_printf(
                    "Destination: %s\n\n"
                    "Can not read or write the directory.",
                    destdir);
        ghb_message_dialog(GTK_MESSAGE_ERROR, message, "Cancel", NULL);
        g_free(dest);
        g_free(message);
        g_free(destdir);
        return FALSE;
    }
#endif
    if (!batch)
    {
        GFile *gfile;
        GFileInfo *info;
        guint64 size;
        gchar *resolved = ghb_resolve_symlink(destdir);

        gfile = g_file_new_for_path(resolved);
        info = g_file_query_filesystem_info(gfile, 
                            G_FILE_ATTRIBUTE_FILESYSTEM_FREE, NULL, NULL);
        if (info != NULL)
        {
            if (g_file_info_has_attribute(info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE))
            {
                size = g_file_info_get_attribute_uint64(info, 
                                        G_FILE_ATTRIBUTE_FILESYSTEM_FREE);
                
                gint64 fsize = (guint64)10 * 1024 * 1024 * 1024;
                if (size < fsize)
                {
                    message = g_strdup_printf(
                                "Destination filesystem is almost full: %uM free\n\n"
                                "Encode may be incomplete if you proceed.\n",
                                (guint)(size / (1024L*1024L)));
                    if (!ghb_message_dialog(GTK_MESSAGE_QUESTION, message, "Cancel", "Proceed"))
                    {
                        g_free(dest);
                        g_free(message);
                        return FALSE;
                    }
                    g_free(message);
                }
            }
            g_object_unref(info);
        }
        g_object_unref(gfile);
        g_free(resolved);
    }
    g_free(destdir);
    if (g_file_test(dest, G_FILE_TEST_EXISTS))
    {
        message = g_strdup_printf(
                    "Destination: %s\n\n"
                    "File already exists.\n"
                    "Do you want to overwrite?",
                    dest);
        if (!ghb_message_dialog(GTK_MESSAGE_QUESTION, message, "Cancel", "Overwrite"))
        {
            g_free(dest);
            g_free(message);
            return FALSE;
        }
        g_free(message);
        g_unlink(dest);
    }
    g_free(dest);
    // Validate video quality is in a reasonable range
    if (!ghb_validate_vquality(settings))
    {
        return FALSE;
    }
    // Validate audio settings
    if (!ghb_validate_audio(settings))
    {
        return FALSE;
    }
    // Validate audio settings
    if (!ghb_validate_subtitles(settings))
    {
        return FALSE;
    }
    // Validate video settings
    if (!ghb_validate_video(settings))
    {
        return FALSE;
    }
    // Validate filter settings
    if (!ghb_validate_filters(settings))
    {
        return FALSE;
    }
    return TRUE;
}
Esempio n. 13
0
int
main (int argc, char *argv[])
{
	signal_user_data_t *ud;
	GValue *preset;
	GError *error = NULL;
	GOptionContext *context;

#ifdef ENABLE_NLS
	bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
#endif

	if (!g_thread_supported())
		g_thread_init(NULL);
	context = g_option_context_new ("- Transcode media formats");
	g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
	g_option_context_add_group (context, gtk_get_option_group (TRUE));
#if defined(_ENABLE_GST)
	g_option_context_add_group (context, gst_init_get_option_group ());
#endif
	g_option_context_parse (context, &argc, &argv, &error);
	g_option_context_free(context);

	if (argc > 1 && dvd_device == NULL && argv[1][0] != '-')
	{
		dvd_device = argv[1];
	}
	
	gtk_init (&argc, &argv);
	gtk_rc_parse_string(hud_rcstyle);
	g_type_class_unref(g_type_class_ref(GTK_TYPE_BUTTON));
	g_object_set(gtk_settings_get_default(), "gtk-button-images", TRUE, NULL);
#if !defined(_WIN32)
	notify_init("HandBrake");
#endif
	ghb_register_transforms();
	ghb_resource_init();
	ghb_load_icons();

#if !defined(_WIN32)
	dbus_g_thread_init();
#endif
	ghb_udev_init();

	ghb_write_pid_file();
	ud = g_malloc0(sizeof(signal_user_data_t));
	ud->debug = ghb_debug;
	g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, debug_log_handler, ud);
	g_log_set_handler ("Gtk", G_LOG_LEVEL_WARNING, warn_log_handler, ud);
	//g_log_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL, warn_log_handler, ud);
	ud->settings = ghb_settings_new();
	ud->builder = create_builder_or_die (BUILDER_NAME);
	// Enable events that alert us to media change events
	watch_volumes (ud);

	//GtkWidget *widget = GHB_WIDGET(ud->builder, "PictureDetelecineCustom");
	//gtk_entry_set_inner_border(widget, 2);

	// Since GtkBuilder no longer assigns object ids to widget names
	// Assign a few that are necessary for style overrides to work
	GtkWidget *widget;
#if defined(_NO_UPDATE_CHECK)
	widget = GHB_WIDGET(ud->builder, "check_updates_box");
	gtk_widget_hide(widget);
#endif

	widget = GHB_WIDGET(ud->builder, "preview_hud");
	gtk_widget_set_name(widget, "preview_hud");
	widget = GHB_WIDGET(ud->builder, "preview_window");
	gtk_widget_set_name(widget, "preview_window");

	// Set up the "hud" control overlay for the preview window
	GtkWidget *draw, *hud, *blender, *align;

	align = GHB_WIDGET(ud->builder, "preview_window_alignment");
	draw = GHB_WIDGET(ud->builder, "preview_image_align");
	hud = GHB_WIDGET(ud->builder, "preview_hud");

	// Set up compositing for hud
	blender = ghb_compositor_new();

	gtk_container_add(GTK_CONTAINER(align), blender);
	ghb_compositor_zlist_insert(GHB_COMPOSITOR(blender), draw, 1, 1);
	ghb_compositor_zlist_insert(GHB_COMPOSITOR(blender), hud, 2, .85);
	gtk_widget_show(blender);

	// Redirect stderr to the activity window
	ghb_preview_init(ud);
	IoRedirect(ud);
	ghb_log( "%s - %s - %s",
		HB_PROJECT_TITLE, HB_PROJECT_BUILD_TITLE, HB_PROJECT_URL_WEBSITE );
	ghb_init_dep_map();

	// Need to connect x264_options textview buffer to the changed signal
	// since it can't be done automatically
	GtkTextView *textview;
	GtkTextBuffer *buffer;
	textview = GTK_TEXT_VIEW(GHB_WIDGET (ud->builder, "x264Option"));
	buffer = gtk_text_view_get_buffer (textview);
	g_signal_connect(buffer, "changed", (GCallback)x264_entry_changed_cb, ud);

	ghb_combo_init(ud);

	g_debug("ud %p\n", ud);
	g_debug("ud->builder %p\n", ud->builder);

	bind_audio_tree_model(ud);
	bind_subtitle_tree_model(ud);
	bind_presets_tree_model(ud);
	bind_queue_tree_model(ud);
	bind_chapter_tree_model(ud);
	// Connect up the signals to their callbacks
	// I wrote my own connector so that I could pass user data
	// to the callbacks.  Builder's standard autoconnect doesn't all this.
	gtk_builder_connect_signals_full (ud->builder, MyConnect, ud);

	// Load all internal settings
	ghb_settings_init(ud);
	// Load the presets files
	ghb_presets_load(ud);
	ghb_prefs_load(ud);

	ghb_prefs_to_ui(ud);

	gint logLevel;
	logLevel = ghb_settings_get_int(ud->settings, "LoggingLevel");
	ghb_backend_init(logLevel);

	if (ghb_settings_get_boolean(ud->settings, "hbfd"))
	{
		ghb_hbfd(ud, TRUE);
	}
	gchar *source = ghb_settings_get_string(ud->settings, "default_source");
	ghb_dvd_set_current(source, ud);
	g_free(source);

	// Parsing x264 options "" initializes x264 widgets to proper defaults
	ghb_x264_parse_options(ud, "");

	// Populate the presets tree view
	ghb_presets_list_init(ud, NULL, 0);
	// Get the first preset name
	if (arg_preset != NULL)
	{
		preset = ghb_parse_preset_path(arg_preset);
		if (preset)
		{
			ghb_select_preset(ud->builder, preset);
			ghb_value_free(preset);
		}
	}
	else
	{
		ghb_select_default_preset(ud->builder);
	}

	// Grey out widgets that are dependent on a disabled feature
	ghb_check_all_depencencies (ud);

	if (dvd_device != NULL)
	{
		// Source overridden from command line option
		ghb_settings_set_string(ud->settings, "scan_source", dvd_device);
		g_idle_add((GSourceFunc)ghb_idle_scan, ud);
	}
	// Reload and check status of the last saved queue
	g_idle_add((GSourceFunc)ghb_reload_queue, ud);

	// Start timer for monitoring libhb status, 500ms
	g_timeout_add (500, ghb_timer_cb, (gpointer)ud);

	// Add dvd devices to File menu
	ghb_volname_cache_init();
	g_thread_create((GThreadFunc)ghb_cache_volnames, ud, FALSE, NULL);

#if defined(_USE_APP_IND)
	GtkUIManager * uim = GTK_UI_MANAGER(GHB_OBJECT(ud->builder, "uimanager1"));

	GtkMenu *ai_menu = GTK_MENU(gtk_ui_manager_get_widget(uim, "/ui/tray_menu"));
	ud->ai = app_indicator_new("HandBrake", "hb-icon", APP_INDICATOR_CATEGORY_APPLICATION_STATUS);
	app_indicator_set_menu( ud->ai, ai_menu );
	app_indicator_set_label( ud->ai, "", "99.99%");
	if (ghb_settings_get_boolean(ud->settings, "show_status"))
	{
		app_indicator_set_status( ud->ai, APP_INDICATOR_STATUS_ACTIVE );
	}
	else
	{
		app_indicator_set_status( ud->ai, APP_INDICATOR_STATUS_PASSIVE );
	}
	GtkStatusIcon *si;
	si = GTK_STATUS_ICON(GHB_OBJECT(ud->builder, "hb_status"));

	gtk_status_icon_set_visible(si, FALSE );
#else
	GtkStatusIcon *si;
	si = GTK_STATUS_ICON(GHB_OBJECT(ud->builder, "hb_status"));

	gtk_status_icon_set_visible(si,
			ghb_settings_get_boolean(ud->settings, "show_status"));

#if GTK_CHECK_VERSION(2, 16, 0)
	gtk_status_icon_set_has_tooltip(si, TRUE);
	g_signal_connect(si, "query-tooltip", 
					status_icon_query_tooltip_cb, ud);
#else
	gtk_status_icon_set_tooltip(si, "HandBrake");
#endif
#endif

	// Ugly hack to keep subtitle table from bouncing around as I change
	// which set of controls are visible
	GtkRequisition req;
	gint width, height;
	
	widget = GHB_WIDGET(ud->builder, "SrtCodeset");
	gtk_widget_size_request( widget, &req );
	height = req.height;
	widget = GHB_WIDGET(ud->builder, "srt_code_label");
	gtk_widget_size_request( widget, &req );
	height += req.height;
	widget = GHB_WIDGET(ud->builder, "subtitle_table");
	gtk_widget_set_size_request(widget, -1, height);
	
	widget = GHB_WIDGET (ud->builder, "hb_window");

	GdkGeometry geo = { 
		-1, -1, 1024, 768, -1, -1, 10, 10, 0, 0, GDK_GRAVITY_NORTH_WEST
	};
	GdkWindowHints geo_mask;
	geo_mask = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | GDK_HINT_BASE_SIZE;
	gtk_window_set_geometry_hints( GTK_WINDOW(widget), widget, &geo, geo_mask);
	width = ghb_settings_get_int(ud->settings, "window_width");
	height = ghb_settings_get_int(ud->settings, "window_height");
	gtk_window_resize(GTK_WINDOW(widget), width, height);
	gtk_widget_show(widget);

	/*
 	 * Filter objects in GtkBuilder xml
 	 * Unfortunately, GtkFilter is poorly supported by GtkBuilder,
 	 * so a lot of the setup must happen in code.
		SourceFilterAll
		SourceFilterVideo
		SourceFilterTS
		SourceFilterMPG
		SourceFilterEVO
		SourceFilterVOB
		SourceFilterMKV
		SourceFilterMP4
		SourceFilterAVI
		SourceFilterMOV
		SourceFilterOGG
		SourceFilterFLV
		SourceFilterWMV
	*/
	// Add filters to source chooser
	GtkFileFilter *filter;
	GtkFileChooser *chooser;
	chooser = GTK_FILE_CHOOSER(GHB_WIDGET(ud->builder, "source_dialog"));
	filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterAll"));
	gtk_file_filter_set_name(filter, "All");
	gtk_file_filter_add_pattern(filter, "*");
	gtk_file_chooser_add_filter(chooser, filter);
	filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterVideo"));
	gtk_file_filter_set_name(filter, "Video");
	gtk_file_filter_add_mime_type(filter, "video/*");
	gtk_file_chooser_add_filter(chooser, filter);
	filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterTS"));
	gtk_file_filter_set_name(filter, "TS");
	gtk_file_filter_add_pattern(filter, "*.ts");
	gtk_file_filter_add_pattern(filter, "*.TS");
	gtk_file_filter_add_pattern(filter, "*.m2ts");
	gtk_file_filter_add_pattern(filter, "*.M2TS");
	gtk_file_chooser_add_filter(chooser, filter);
	filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterMPG"));
	gtk_file_filter_set_name(filter, "MPG");
	gtk_file_filter_add_pattern(filter, "*.mpg");
	gtk_file_filter_add_pattern(filter, "*.MPG");
	gtk_file_filter_add_pattern(filter, "*.mepg");
	gtk_file_filter_add_pattern(filter, "*.MEPG");
	gtk_file_chooser_add_filter(chooser, filter);
	filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterEVO"));
	gtk_file_filter_set_name(filter, "EVO");
	gtk_file_filter_add_pattern(filter, "*.evo");
	gtk_file_filter_add_pattern(filter, "*.EVO");
	gtk_file_chooser_add_filter(chooser, filter);
	filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterVOB"));
	gtk_file_filter_set_name(filter, "VOB");
	gtk_file_filter_add_pattern(filter, "*.vob");
	gtk_file_filter_add_pattern(filter, "*.VOB");
	gtk_file_chooser_add_filter(chooser, filter);
	filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterMKV"));
	gtk_file_filter_set_name(filter, "MKV");
	gtk_file_filter_add_pattern(filter, "*.mkv");
	gtk_file_filter_add_pattern(filter, "*.MKV");
	gtk_file_chooser_add_filter(chooser, filter);
	filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterMP4"));
	gtk_file_filter_set_name(filter, "MP4");
	gtk_file_filter_add_pattern(filter, "*.mp4");
	gtk_file_filter_add_pattern(filter, "*.MP4");
	gtk_file_filter_add_pattern(filter, "*.m4v");
	gtk_file_filter_add_pattern(filter, "*.M4V");
	gtk_file_chooser_add_filter(chooser, filter);
	filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterMOV"));
	gtk_file_filter_set_name(filter, "MOV");
	gtk_file_filter_add_pattern(filter, "*.mov");
	gtk_file_filter_add_pattern(filter, "*.MOV");
	gtk_file_chooser_add_filter(chooser, filter);
	filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterAVI"));
	gtk_file_filter_set_name(filter, "AVI");
	gtk_file_filter_add_pattern(filter, "*.avi");
	gtk_file_filter_add_pattern(filter, "*.AVI");
	gtk_file_chooser_add_filter(chooser, filter);
	filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterOGG"));
	gtk_file_filter_set_name(filter, "OGG");
	gtk_file_filter_add_pattern(filter, "*.ogg");
	gtk_file_filter_add_pattern(filter, "*.OGG");
	gtk_file_filter_add_pattern(filter, "*.ogv");
	gtk_file_filter_add_pattern(filter, "*.OGV");
	gtk_file_filter_add_pattern(filter, "*.ogm");
	gtk_file_filter_add_pattern(filter, "*.OGM");
	gtk_file_chooser_add_filter(chooser, filter);
	filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterFLV"));
	gtk_file_filter_set_name(filter, "FLV");
	gtk_file_filter_add_pattern(filter, "*.flv");
	gtk_file_filter_add_pattern(filter, "*.FLV");
	gtk_file_chooser_add_filter(chooser, filter);
	filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterWMV"));
	gtk_file_filter_set_name(filter, "WMV");
	gtk_file_filter_add_pattern(filter, "*.wmv");
	gtk_file_filter_add_pattern(filter, "*.WMV");
	gtk_file_chooser_add_filter(chooser, filter);

	// Gtk has a really stupid bug.  If the file chooser is showing
	// hidden files AND there is no filter set, it will not select
	// the filename when gtk_file_chooser_set_filename is called.
	// So add a completely unnessary filter to prevent this behavior.
	filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterAll"));
	gtk_file_chooser_set_filter(chooser, filter);

	PangoFontDescription *font_desc;
	font_desc = pango_font_description_from_string ("monospace 10");
	textview = GTK_TEXT_VIEW(GHB_WIDGET (ud->builder, "activity_view"));
	gtk_widget_modify_font(GTK_WIDGET(textview), font_desc);      
	pango_font_description_free (font_desc);      

	// Everything should be go-to-go.  Lets rock!

	gtk_main ();
	gtk_status_icon_set_visible(si, FALSE);
	ghb_backend_close();
	if (ud->queue)
		ghb_value_free(ud->queue);
	ghb_value_free(ud->settings);
	g_io_channel_unref(ud->activity_log);
	ghb_settings_close();
#if !defined(_WIN32)
	notify_uninit();
#endif
	g_free(ud);

	return 0;
}
Esempio n. 14
0
void
ghb_set_pref_audio_settings(gint titleindex, GValue *settings)
{
    gint track;
    gchar *source_lang;
    hb_audio_config_t *aconfig;
    GHashTable *track_indices;
    gint mux;

    const GValue *pref_audio;
    const GValue *audio, *drc, *gain, *enable_qual;
    gint acodec, bitrate, mix;
    gdouble rate, quality;
    gint count, ii, list_count;
    
    g_debug("set_pref_audio");
    mux = ghb_settings_combo_int(settings, "FileFormat");
    track_indices = g_hash_table_new_full(g_int_hash, g_int_equal, 
                        free_audio_hash_key_value, free_audio_hash_key_value);
    // Clear the audio list
    ghb_clear_audio_list_settings(settings);

    // Find "best" audio based on audio preferences
    if (!ghb_settings_get_boolean(settings, "AudioDUB"))
    {
        source_lang = g_strdup(ghb_get_source_audio_lang(titleindex, 0));
    }
    else
    {
        source_lang = ghb_settings_get_string(settings, "PreferredLanguage");
    }

    pref_audio = ghb_settings_get_value(settings, "AudioList");

    list_count = 0;
    count = ghb_array_len(pref_audio);
    for (ii = 0; ii < count; ii++)
    {
        gint select_acodec;
        gint fallback;

        audio = ghb_array_get_nth(pref_audio, ii);
        acodec = ghb_settings_combo_int(audio, "AudioEncoder");
        fallback = ghb_select_fallback(settings, mux, acodec);
        gint copy_mask = ghb_get_copy_mask(settings);
        select_acodec = ghb_select_audio_codec(mux, NULL, acodec, fallback, copy_mask);
        bitrate = ghb_settings_combo_int(audio, "AudioBitrate");
        rate = ghb_settings_combo_double(audio, "AudioSamplerate");
        mix = ghb_settings_combo_int(audio, "AudioMixdown");
        drc = ghb_settings_get_value(audio, "AudioTrackDRCSlider");
        gain = ghb_settings_get_value(audio, "AudioTrackGain");
        enable_qual = ghb_settings_get_value(audio, "AudioTrackQualityEnable");
        quality = ghb_settings_get_double(audio, "AudioTrackQuality");
        // If there are multiple audios using the same codec, then
        // select sequential tracks for each.  The hash keeps track 
        // of the tracks used for each codec.
        track = ghb_find_audio_track(titleindex, source_lang, 
                                select_acodec, fallback, track_indices);
        // Check to see if:
        // 1. pref codec is passthru
        // 2. source codec is not passthru
        // 3. next pref is enabled
        aconfig = ghb_get_scan_audio_info(titleindex, track);
        if (aconfig && ghb_audio_is_passthru (acodec))
        {
            // HB_ACODEC_* are bit fields.  Treat acodec as mask
            if (!(aconfig->in.codec & select_acodec & HB_ACODEC_PASS_MASK))
            {
                if (acodec != HB_ACODEC_AUTO_PASS)
                    acodec = fallback;
                // If we can't substitute the passthru with a suitable
                // encoder and
                // If there's more audio to process, or we've already
                // placed one in the list, then we can skip this one
                if (!(select_acodec & fallback) && 
                    ((ii + 1 < count) || (list_count != 0)))
                {
                    // Skip this audio
                    acodec = 0;
                }
            }
            else
            {
                select_acodec &= aconfig->in.codec | HB_ACODEC_PASS_FLAG;
            }
        }
        if (titleindex >= 0 && track < 0)
            acodec = 0;
        if (acodec != 0)
        {
            GValue *asettings = ghb_dict_value_new();
            ghb_settings_set_int(asettings, "AudioTrack", track);
            ghb_settings_set_string(asettings, "AudioEncoder", 
                ghb_lookup_combo_string("AudioEncoder", ghb_int_value(acodec)));
            ghb_settings_set_value(asettings, "AudioEncoderActual", 
                                    ghb_lookup_audio_encoder_value(select_acodec));
            ghb_settings_set_value(asettings, "AudioTrackQualityEnable", enable_qual);
            ghb_settings_set_double(asettings, "AudioTrackQuality", quality);

            // This gets set autimatically if the codec is passthru
            ghb_settings_set_string(asettings, "AudioBitrate",
                ghb_lookup_combo_string("AudioBitrate", ghb_int_value(bitrate)));
            ghb_settings_set_string(asettings, "AudioSamplerate",
                ghb_lookup_combo_string("AudioSamplerate", ghb_int_value(rate)));
            mix = ghb_get_best_mix( aconfig, select_acodec, mix);
            ghb_settings_set_string(asettings, "AudioMixdown",
                ghb_lookup_combo_string("AudioMixdown", ghb_int_value(mix)));
            ghb_settings_set_value(asettings, "AudioTrackDRCSlider", drc);
            ghb_settings_set_value(asettings, "AudioTrackGain", gain);
            ghb_sanitize_audio(settings, asettings);
            ghb_add_audio_to_settings(settings, asettings);
        }
    }
    g_free(source_lang);
    g_hash_table_destroy(track_indices);
}
Esempio n. 15
0
static GValue*  subtitle_add_track(
    signal_user_data_t *ud,
    GValue *settings,
    const hb_title_t *title,
    int track,
    int mux,
    gboolean default_track,
    gboolean srt,
    gboolean *burned)
{
    int source = 0;

    if (track >= 0 && !srt)
    {
        hb_subtitle_t *subtitle = hb_list_item(title->list_subtitle, track);
        source = subtitle->source;
    }
    else if (srt)
    {
        source = SRTSUB;
    }

    if (*burned && !hb_subtitle_can_pass(source, mux))
    {
        // Can only burn one.  Skip others that must be burned.
        return NULL;
    }

    GValue *subsettings = ghb_dict_value_new();
    ghb_settings_set_int(subsettings, "SubtitleTrack", track);
    ghb_settings_set_int(subsettings, "SubtitleSource", source);

    // Set default SRT settings
    gchar *pref_lang, *dir, *filename;

    pref_lang = ghb_settings_get_string(settings, "PreferredLanguage");
    ghb_settings_set_string(subsettings, "SrtLanguage", pref_lang);
    g_free(pref_lang);

    ghb_settings_set_string(subsettings, "SrtCodeset", "UTF-8");

    dir = ghb_settings_get_string(ud->prefs, "SrtDir");
    filename = g_strdup_printf("%s/none", dir);
    ghb_settings_set_string(subsettings, "SrtFile", filename);
    g_free(dir);
    g_free(filename);

    ghb_settings_set_int(subsettings, "SrtOffset", 0);

    subtitle_set_track_description(settings, subsettings);

    if (!hb_subtitle_can_pass(source, mux))
    {
        ghb_settings_set_boolean(subsettings, "SubtitleBurned", TRUE);
        *burned = TRUE;
    }
    else
    {
        ghb_settings_set_boolean(subsettings, "SubtitleBurned", FALSE);
    }
    if (track == -1)
    {
        // Foreign audio search "track"
        ghb_settings_set_boolean(subsettings, "SubtitleForced", TRUE);
    }
    else
    {
        ghb_settings_set_boolean(subsettings, "SubtitleForced", FALSE);
    }
    if (default_track)
    {
        ghb_settings_set_boolean(subsettings, "SubtitleDefaultTrack", TRUE);
    }
    else
    {
        ghb_settings_set_boolean(subsettings, "SubtitleDefaultTrack", FALSE);
    }
    subtitle_add_to_settings(settings, subsettings);

    return subsettings;
}
Esempio n. 16
0
G_MODULE_EXPORT void
x264_setting_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
    static char *tt = NULL;


    if (tt == NULL)
    {
        GtkWidget *eo = GTK_WIDGET(GHB_WIDGET(ud->builder, "x264OptionExtra"));
        tt = gtk_widget_get_tooltip_text(eo);
    }

    ghb_widget_to_setting(ud->settings, widget);

    int x264Preset = ghb_settings_get_int(ud->settings, "x264PresetSlider");
    const char *preset;
    preset = hb_video_encoder_get_presets(HB_VCODEC_X264)[x264Preset];
    ghb_settings_set_string(ud->settings, "x264Preset", preset);

    if (!ghb_settings_get_boolean(ud->settings, "x264UseAdvancedOptions"))
    {
        GString *str = g_string_new("");
        char *preset;
        char *tune;
        char *profile;
        char *level;
        char *opts;
        char *tunes;

        preset = ghb_settings_get_string(ud->settings, "x264Preset");
        tune = ghb_settings_get_string(ud->settings, "x264Tune");
        profile = ghb_settings_get_string(ud->settings, "h264Profile");
        level = ghb_settings_get_string(ud->settings, "h264Level");
        opts = ghb_settings_get_string(ud->settings, "x264OptionExtra");

        if (tune[0] && strcmp(tune, "none"))
        {
            g_string_append_printf(str, "%s", tune);
        }
        if (ghb_settings_get_boolean(ud->settings, "x264FastDecode"))
        {
            g_string_append_printf(str, "%s%s", str->str[0] ? "," : "", "fastdecode");
        }
        if (ghb_settings_get_boolean(ud->settings, "x264ZeroLatency"))
        {
            g_string_append_printf(str, "%s%s", str->str[0] ? "," : "", "zerolatency");
        }
        tunes = g_string_free(str, FALSE);

        char * new_opts;

        int w = ghb_settings_get_int(ud->settings, "scale_width");
        int h = ghb_settings_get_int(ud->settings, "scale_height");

        if (w == 0 || h == 0)
        {
            if (!ghb_settings_get_boolean(ud->settings, "autoscale"))
            {
                w = ghb_settings_get_int(ud->settings, "PictureWidth");
                h = ghb_settings_get_int(ud->settings, "PictureHeight");

                if (h == 0 && w != 0)
                {
                    h = w * 9 / 16;
                }
                if (w == 0 && h != 0)
                {
                    w = h * 16 / 9;
                }
            }
            if (w == 0 || h == 0)
            {
                w = 1280;
                h = 720;
            }
        }

        if (!strcasecmp(profile, "auto"))
        {
            profile[0] = 0;
        }
        if (!strcasecmp(level, "auto"))
        {
            level[0] = 0;
        }
        new_opts = hb_x264_param_unparse(
                        preset, tunes, opts, profile, level, w, h);
        if (new_opts)
            ghb_ui_update(ud, "x264Option", ghb_string_value(new_opts));
        else
            ghb_ui_update(ud, "x264Option", ghb_string_value(""));

        GtkWidget *eo = GTK_WIDGET(GHB_WIDGET(ud->builder, "x264OptionExtra"));

        char * new_tt;
        if (new_opts)
            new_tt = g_strdup_printf("%s\n\nExpanded Options:\n\"%s\"", tt, new_opts);
        else
            new_tt = g_strdup_printf("%s\n\nExpanded Options:\n\"\"", tt);
        gtk_widget_set_tooltip_text(eo, new_tt);

        g_free(new_tt);
        g_free(new_opts);

        g_free(preset);
        g_free(tune);
        g_free(profile);
        g_free(level);
        g_free(opts);
        g_free(tunes);
    }
    else
    {
        char *opts = ghb_settings_get_string(ud->settings, "x264Option");

        GtkWidget *eo = GTK_WIDGET(GHB_WIDGET(ud->builder, "x264OptionExtra"));
        char * new_tt;
        if (opts)
            new_tt = g_strdup_printf("%s\n\nExpanded Options:\n\"%s\"", tt, opts);
        else
            new_tt = g_strdup_printf("%s\n\nExpanded Options:\n\"\"", tt);
        gtk_widget_set_tooltip_text(eo, new_tt);
        g_free(new_tt);

        g_free(opts);
    }

    ghb_check_dependency(ud, widget, NULL);
    ghb_clear_presets_selection(ud);
}
Esempio n. 17
0
void
ghb_audio_list_refresh(signal_user_data_t *ud)
{
    GtkTreeView *treeview;
    GtkTreeIter iter;
    GtkListStore *store;
    gboolean done;
    gint row = 0;
    const GValue *audio_list;

    g_debug("ghb_audio_list_refresh ()");
    treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "audio_list"));
    store = GTK_LIST_STORE(gtk_tree_view_get_model(treeview));
    if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter))
    {
        do
        {
            const gchar *track, *codec, *br = NULL, *sr, *mix;
            gchar *s_drc, *s_gain, *s_quality = NULL;
            gdouble drc, gain;
            GValue *asettings;

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

            track = ghb_settings_combo_option(asettings, "AudioTrack");
            codec = ghb_settings_combo_option(asettings, "AudioEncoderActual");
            double quality = ghb_settings_get_double(asettings, "AudioTrackQuality");
            if (ghb_settings_get_boolean(asettings, "AudioTrackQualityEnable") &&
                quality != HB_INVALID_AUDIO_QUALITY)
            {
                int codec = ghb_settings_combo_int(asettings, "AudioEncoderActual");
                s_quality = ghb_format_quality("Q/", codec, quality);
            }
            else
            {
                br = ghb_settings_get_string(asettings, "AudioBitrate");
            }
            sr = ghb_settings_combo_option(asettings, "AudioSamplerate");
            mix = ghb_settings_combo_option(asettings, "AudioMixdown");
            gain = ghb_settings_get_double(asettings, "AudioTrackGain");
            s_gain = g_strdup_printf("%.fdB", gain);

            drc = ghb_settings_get_double(asettings, "AudioTrackDRCSlider");
            if (drc < 1.0)
                s_drc = g_strdup("Off");
            else
                s_drc = g_strdup_printf("%.1f", drc);

            gtk_list_store_set(GTK_LIST_STORE(store), &iter, 
                // These are displayed in list
                0, track,
                1, codec,
                2, s_quality ? s_quality : br,
                3, sr,
                4, mix,
                5, s_gain,
                6, s_drc,
                -1);
            g_free(s_drc);
            g_free(s_gain);
            done = !gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter);
            row++;
        } while (!done);
    }
}
Esempio n. 18
0
static void
x264_opt_update(signal_user_data_t *ud, GtkWidget *widget)
{
    gint jj;
    const gchar *name = ghb_get_setting_key(widget);
    gchar **opt_syns = NULL;
    const gchar *def_val = NULL;
    gint type;
    trans_table_t *trans;

    for (jj = 0; jj < X264_OPT_MAP_SIZE; jj++)
    {
        if (strcmp(name, x264_opt_map[jj].name) == 0)
        {
            // found the options that needs updating
            opt_syns = x264_opt_map[jj].opt_syns;
            def_val = x264_opt_map[jj].def_val;
            type = x264_opt_map[jj].type;
            trans = x264_opt_map[jj].translation;
            break;
        }
    }
    if (opt_syns != NULL)
    {
        GString *x264opts = g_string_new("");
        gchar *options;
        gchar **split = NULL;
        gint ii;
        gboolean foundit = FALSE;

        options = ghb_settings_get_string(ud->settings, "x264Option");
        if (options)
        {
            split = g_strsplit(options, ":", -1);
            g_free(options);
        }
        for (ii = 0; split && split[ii] != NULL; ii++)
        {
            gint syn;
            gchar *val = NULL;
            gchar *pos = strchr(split[ii], '=');
            if (pos != NULL)
            {
                val = pos + 1;
                *pos = 0;
            }
            syn = find_syn_match(split[ii], opt_syns);
            if (syn >= 0)
            { // Updating this option
                gchar *val;
                foundit = TRUE;
                if (type == X264_OPT_DEBLOCK)
                    val = get_deblock_val(ud);
                else if (type == X264_OPT_PSY)
                    val = get_psy_val(ud);
                else
                {
                    GValue *gval;
                    gval = ghb_widget_value(widget);
                    if (G_VALUE_TYPE(gval) == G_TYPE_BOOLEAN)
                    {
                        if (ghb_value_boolean(gval))
                            val = g_strdup("1");
                        else
                            val = g_strdup("0");
                    }
                    else
                    {
                        val = ghb_widget_string(widget);
                    }
                    ghb_value_free(gval);
                }
                if (type == X264_OPT_TRANS)
                {
                    gchar *tmp;
                    tmp = g_strdup(trans_ui_val(trans, val));
                    if (tmp)
                    {
                        g_free(val);
                        val = tmp;
                    }
                }
                if (strcmp(def_val, val) != 0)
                {
                    g_string_append_printf(x264opts, "%s=%s:", opt_syns[syn], val);
                }
                g_free(val);
            }
            else if (val != NULL)
                g_string_append_printf(x264opts, "%s=%s:", split[ii], val);
            else
                g_string_append_printf(x264opts, "%s:", split[ii]);

        }
        if (split) g_strfreev(split);
        if (!foundit)
        {
            gchar *val;
            if (type == X264_OPT_DEBLOCK)
                val = get_deblock_val(ud);
            else if (type == X264_OPT_PSY)
                val = get_psy_val(ud);
            else
            {
                GValue *gval;
                gval = ghb_widget_value(widget);
                if (G_VALUE_TYPE(gval) == G_TYPE_BOOLEAN)
                {
                    if (ghb_value_boolean(gval))
                        val = g_strdup("1");
                    else
                        val = g_strdup("0");
                }
                else
                {
                    val = ghb_widget_string(widget);
                }
                ghb_value_free(gval);
            }
            if (type == X264_OPT_TRANS)
            {
                gchar *tmp;
                tmp = g_strdup(trans_ui_val(trans, val));
                if (tmp)
                {
                    g_free(val);
                    val = tmp;
                }
            }
            if (strcmp(def_val, val) != 0)
            {
                g_string_append_printf(x264opts, "%s=%s:", opt_syns[0], val);
            }
            g_free(val);
        }
        // Update the options value
        // strip the trailing ":"
        gchar *result;
        gint len;
        result = g_string_free(x264opts, FALSE);
        len = strlen(result);
        if (len > 0) result[len - 1] = 0;
        gchar *sopts;
        sopts = sanitize_x264opts(ud, result);
        ghb_ui_update(ud, "x264Option", ghb_string_value(sopts));
        ghb_x264_parse_options(ud, sopts);
        g_free(sopts);
        g_free(result);
    }
}
Esempio n. 19
0
int
main (int argc, char *argv[])
{
	signal_user_data_t *ud;
	GValue *preset;
	GError *error = NULL;
	GOptionContext *context;

#ifdef ENABLE_NLS
	bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
#endif

	if (!g_thread_supported())
		g_thread_init(NULL);
	context = g_option_context_new ("- Rip and encode DVD or MPEG file");
	g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
	g_option_context_add_group (context, gtk_get_option_group (TRUE));
#if !defined(_WIN32)
	g_option_context_add_group (context, gst_init_get_option_group ());
#endif
	g_option_context_parse (context, &argc, &argv, &error);
	g_option_context_free(context);

	if (argc > 1 && dvd_device == NULL && argv[1][0] != '-')
	{
		dvd_device = argv[1];
	}
	
	gtk_set_locale ();
	gtk_init (&argc, &argv);
	gtk_rc_parse_string(hud_rcstyle);
	g_type_class_unref(g_type_class_ref(GTK_TYPE_BUTTON));
	g_object_set(gtk_settings_get_default(), "gtk-button-images", TRUE, NULL);
#if !defined(_WIN32)
	notify_init("HandBrake");
#endif
	ghb_register_transforms();
	ghb_resource_init();
	ghb_load_icons();

#if !defined(_WIN32)
	dbus_g_thread_init();
#endif
	ghb_udev_init();

	ghb_write_pid_file();
	ud = g_malloc0(sizeof(signal_user_data_t));
	ud->debug = ghb_debug;
	g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, debug_log_handler, ud);
	g_log_set_handler ("Gtk", G_LOG_LEVEL_WARNING, warn_log_handler, ud);
	//g_log_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL, warn_log_handler, ud);
	ud->settings = ghb_settings_new();
	ud->builder = create_builder_or_die (BUILDER_NAME);
	// Enable events that alert us to media change events
	watch_volumes (ud);

	//GtkWidget *widget = GHB_WIDGET(ud->builder, "PictureDetelecineCustom");
	//gtk_entry_set_inner_border(widget, 2);

	// Since GtkBuilder no longer assigns object ids to widget names
	// Assign a few that are necessary for style overrides to work
	GtkWidget *widget;
#if defined(_NO_UPDATE_CHECK)
	widget = GHB_WIDGET(ud->builder, "check_updates_box");
	gtk_widget_hide(widget);
#endif

	widget = GHB_WIDGET(ud->builder, "preview_hud");
	gtk_widget_set_name(widget, "preview_hud");
	widget = GHB_WIDGET(ud->builder, "preview_window");
	gtk_widget_set_name(widget, "preview_window");

	// Set up the "hud" control overlay for the preview window
	GtkWidget *draw, *hud, *blender, *align;

	align = GHB_WIDGET(ud->builder, "preview_window_alignment");
	draw = GHB_WIDGET(ud->builder, "preview_image_align");
	hud = GHB_WIDGET(ud->builder, "preview_hud");

	// Set up compositing for hud
	blender = ghb_compositor_new();

	gtk_container_add(GTK_CONTAINER(align), blender);
	ghb_compositor_zlist_insert(GHB_COMPOSITOR(blender), draw, 1, 1);
	ghb_compositor_zlist_insert(GHB_COMPOSITOR(blender), hud, 2, .85);
	gtk_widget_show(blender);

	// Redirect stderr to the activity window
	ghb_preview_init(ud);
	IoRedirect(ud);
	ghb_log( "%s - %s - %s",
		HB_PROJECT_TITLE, HB_PROJECT_BUILD_TITLE, HB_PROJECT_URL_WEBSITE );
	ghb_init_dep_map();

	// Need to connect x264_options textview buffer to the changed signal
	// since it can't be done automatically
	GtkTextView *textview;
	GtkTextBuffer *buffer;
	textview = GTK_TEXT_VIEW(GHB_WIDGET (ud->builder, "x264Option"));
	buffer = gtk_text_view_get_buffer (textview);
	g_signal_connect(buffer, "changed", (GCallback)x264_entry_changed_cb, ud);

	ghb_combo_init(ud);

	g_debug("ud %p\n", ud);
	g_debug("ud->builder %p\n", ud->builder);

	bind_audio_tree_model(ud);
	bind_subtitle_tree_model(ud);
	bind_presets_tree_model(ud);
	bind_queue_tree_model(ud);
	bind_chapter_tree_model(ud);
	// Connect up the signals to their callbacks
	// I wrote my own connector so that I could pass user data
	// to the callbacks.  Builder's standard autoconnect doesn't all this.
	gtk_builder_connect_signals_full (ud->builder, MyConnect, ud);

	// Load all internal settings
	ghb_settings_init(ud);
	// Load the presets files
	ghb_presets_load(ud);
	ghb_prefs_load(ud);

	ghb_prefs_to_ui(ud);

	gint logLevel;
	logLevel = ghb_settings_get_int(ud->settings, "LoggingLevel");
	ghb_backend_init(logLevel);

	if (ghb_settings_get_boolean(ud->settings, "hbfd"))
	{
		ghb_hbfd(ud, TRUE);
	}
	gchar *source = ghb_settings_get_string(ud->settings, "default_source");
	ghb_dvd_set_current(source, ud);
	g_free(source);

	// Parsing x264 options "" initializes x264 widgets to proper defaults
	ghb_x264_parse_options(ud, "");

	// Populate the presets tree view
	ghb_presets_list_init(ud, NULL, 0);
	// Get the first preset name
	if (arg_preset != NULL)
	{
		preset = ghb_parse_preset_path(arg_preset);
		if (preset)
		{
			ghb_select_preset(ud->builder, preset);
			ghb_value_free(preset);
		}
	}
	else
	{
		ghb_select_default_preset(ud->builder);
	}

	// Grey out widgets that are dependent on a disabled feature
	ghb_check_all_depencencies (ud);

	if (dvd_device != NULL)
	{
		// Source overridden from command line option
		ghb_settings_set_string(ud->settings, "scan_source", dvd_device);
		g_idle_add((GSourceFunc)ghb_idle_scan, ud);
	}
	// Reload and check status of the last saved queue
	g_idle_add((GSourceFunc)ghb_reload_queue, ud);

	// Start timer for monitoring libhb status, 500ms
	g_timeout_add (500, ghb_timer_cb, (gpointer)ud);

	// Add dvd devices to File menu
	ghb_volname_cache_init();
	g_thread_create((GThreadFunc)ghb_cache_volnames, ud, FALSE, NULL);

	GtkStatusIcon *si;
	si = GTK_STATUS_ICON(GHB_OBJECT(ud->builder, "hb_status"));

	gtk_status_icon_set_visible(si,
			ghb_settings_get_boolean(ud->settings, "show_status"));

#if GTK_CHECK_VERSION(2, 16, 0)
	gtk_status_icon_set_has_tooltip(si, TRUE);
	g_signal_connect(si, "query-tooltip", 
					status_icon_query_tooltip_cb, ud);
#else
	gtk_status_icon_set_tooltip(si, "HandBrake");
#endif

	// Ugly hack to keep subtitle table from bouncing around as I change
	// which set of controls are visible
	GtkRequisition req;
	gint height;
	
	widget = GHB_WIDGET(ud->builder, "SrtCodeset");
	gtk_widget_size_request( widget, &req );
	height = req.height;
	widget = GHB_WIDGET(ud->builder, "srt_code_label");
	gtk_widget_size_request( widget, &req );
	height += req.height;
	widget = GHB_WIDGET(ud->builder, "subtitle_table");
	gtk_widget_set_size_request(widget, -1, height);
	
	// Everything should be go-to-go.  Lets rock!

	gtk_main ();
	gtk_status_icon_set_visible(si, FALSE);
	ghb_backend_close();
	if (ud->queue)
		ghb_value_free(ud->queue);
	ghb_value_free(ud->settings);
	g_io_channel_unref(ud->activity_log);
	ghb_settings_close();
#if !defined(_WIN32)
	notify_uninit();
#endif
	g_free(ud);

	return 0;
}