示例#1
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;
}
示例#2
0
G_MODULE_EXPORT void
x264_entry_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
    g_debug("x264_entry_changed_cb ()");

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

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

        textview = GTK_WIDGET(GHB_WIDGET(ud->builder, "x264Option"));
        ghb_widget_to_setting(ud->settings, textview);
        options = ghb_dict_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_update_x264Option(ud, sopts);
            ghb_x264_parse_options(ud, sopts);

            if (ghb_dict_get_bool(ud->settings, "x264UseAdvancedOptions"))
            {
                GtkWidget *eo;
                eo = GTK_WIDGET(GHB_WIDGET(ud->builder, "VideoOptionExtra"));
                char * tt;
                if (sopts)
                    tt = g_strdup_printf(_("%s\n\nExpanded Options:\n\"%s\""),
                                         video_option_tooltip, sopts);
                else
                    tt = g_strdup_printf(_("%s\n\nExpanded Options:\n\"\""),
                                         video_option_tooltip);
                gtk_widget_set_tooltip_text(eo, tt);
                g_free(tt);
            }

            g_free(sopts);
        }
        ignore_options_update = FALSE;
    }
}
示例#3
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;
    }
}
示例#4
0
G_MODULE_EXPORT gboolean
x264_focus_out_cb(GtkWidget *widget, GdkEventFocus *event,
    signal_user_data_t *ud)
{
    const gchar *options;
    gchar *sopts;

    ghb_widget_to_setting(ud->settings, widget);
    options = ghb_dict_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(sopts);
    ignore_options_update = FALSE;
    return FALSE;
}
示例#5
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("");
        const gchar *options;
        gchar **split = NULL;
        gint ii;
        gboolean foundit = FALSE;

        options = ghb_dict_get_string(ud->settings, "x264Option");
        if (options)
        {
            split = g_strsplit(options, ":", -1);
        }
        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
                {
                    GhbValue *gval;
                    gval = ghb_widget_value(widget);
                    if (ghb_value_type(gval) == GHB_BOOL)
                    {
                        if (ghb_value_get_bool(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
            {
                GhbValue *gval;
                gval = ghb_widget_value(widget);
                if (ghb_value_type(gval) == GHB_BOOL)
                {
                    if (ghb_value_get_bool(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_update_x264Option(ud, sopts);
        ghb_x264_parse_options(ud, sopts);
        g_free(sopts);
        g_free(result);
    }
}