예제 #1
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);
}
예제 #2
0
파일: icons.c 프로젝트: Doluci/HandBrake
void
ghb_load_icons()
{
    GHashTableIter iter;
    gchar *key;
    GValue *gval;

    GValue *icons = ghb_resource_get("icons");
    ghb_dict_iter_init(&iter, icons);
    // middle (void*) cast prevents gcc warning "defreferencing type-punned
    // pointer will break strict-aliasing rules"
    while (g_hash_table_iter_next(
            &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval))
    {
        ghb_rawdata_t *rd;
        gint size;
        GdkPixbuf *pb;
        gboolean svg;
        char *name = g_strdup(key);
        char *pos;

        pos = g_strstr_len(name, -1, ".");
        if (pos != NULL)
            *pos = '\0';

        GInputStream *gis;
        svg = ghb_value_boolean(ghb_dict_lookup(gval, "svg"));
        rd = g_value_get_boxed(ghb_dict_lookup(gval, "data"));
        if (svg)
        {
            int ii;
            int sizes[] = {16, 22, 24, 32, 48, 64, 128, 256, 0};
            for (ii = 0; sizes[ii]; ii++)
            {
                gis = g_memory_input_stream_new_from_data(rd->data, rd->size,
                                                          NULL);
                pb = gdk_pixbuf_new_from_stream_at_scale(gis,
                                                         sizes[ii], sizes[ii],
                                                         TRUE, NULL, NULL);
                g_input_stream_close(gis, NULL, NULL);
                size = gdk_pixbuf_get_height(pb);
                gtk_icon_theme_add_builtin_icon(name, size, pb);
                g_object_unref(pb);
            }
        }
        else
        {
            gis = g_memory_input_stream_new_from_data(rd->data, rd->size, NULL);
            pb = gdk_pixbuf_new_from_stream(gis, NULL, NULL);
            g_input_stream_close(gis, NULL, NULL);
            size = gdk_pixbuf_get_height(pb);
            gtk_icon_theme_add_builtin_icon(name, size, pb);
            g_object_unref(pb);
        }
        g_free(name);
    }
}
예제 #3
0
gint
ghb_widget_boolean(GtkWidget *widget)
{
    GValue *value;
    gboolean bval;

    value = ghb_widget_value(widget);
    bval = ghb_value_boolean(value);
    ghb_value_free(value);
    return bval;
}
예제 #4
0
파일: icons.c 프로젝트: DarthGoon/HandBrake
void
ghb_load_icons()
{
    GHashTableIter iter;
    gchar *key;
    GValue *gval;

    GValue *icons = ghb_resource_get("icons");
    ghb_dict_iter_init(&iter, icons);
    // middle (void*) cast prevents gcc warning "defreferencing type-punned
    // pointer will break strict-aliasing rules"
    while (g_hash_table_iter_next(
            &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval))
    {
        gint colorspace, bps, width, height, rowstride;
        gboolean alpha;
        ghb_rawdata_t *rd;
        gint size;
        GdkPixbuf *pb;
        char *name = g_strdup(key);
        char *pos;

        pos = g_strstr_len(name, -1, ".");
        if (pos != NULL)
            *pos = '\0';

        colorspace = ghb_value_int(ghb_dict_lookup(gval, "colorspace"));
        alpha = ghb_value_boolean(ghb_dict_lookup(gval, "alpha"));
        bps = ghb_value_int(ghb_dict_lookup(gval, "bps"));
        width = ghb_value_int(ghb_dict_lookup(gval, "width"));
        height = ghb_value_int(ghb_dict_lookup(gval, "height"));
        rowstride = ghb_value_int(ghb_dict_lookup(gval, "rowstride"));
        rd = g_value_get_boxed(ghb_dict_lookup(gval, "data"));
        pb = gdk_pixbuf_new_from_data(
                rd->data, colorspace, alpha, bps,
                width, height, rowstride,
                NULL, NULL);
        size = gdk_pixbuf_get_height(pb);
        gtk_icon_theme_add_builtin_icon(name, size, pb);
        g_object_unref(pb);
        g_free(name);
    }
}
예제 #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("");
        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);
    }
}