Пример #1
0
gint64
ghb_settings_get_int64(const GValue *settings, const gchar *key)
{
    const GValue* value;
    value = ghb_settings_get_value(settings, key);
    if (value == NULL) return 0;
    return ghb_value_int64(value);
}
Пример #2
0
gint
ghb_widget_int(GtkWidget *widget)
{
    GValue *value;
    gint ival;

    value = ghb_widget_value(widget);
    ival = (gint)ghb_value_int64(value);
    ghb_value_free(value);
    return ival;
}
Пример #3
0
gint
ghb_value_cmp(const GValue *vala, const GValue *valb)
{
	GType typa;
	GType typb;

	if ((vala == NULL && valb != NULL) || (vala != NULL && valb == NULL))
	{
		return 1;
	}
	typa = G_VALUE_TYPE(vala);
	typb = G_VALUE_TYPE(valb);
	if (typa != typb)
	{
		return 1;
	}
	
	if (typa == G_TYPE_STRING)
	{
		char *stra, *strb;
		gint res;
		stra = ghb_value_string(vala);
		strb = ghb_value_string(valb);
		if (stra == NULL && strb == NULL)
			return 0;
		if (stra == NULL)
		{
			g_free(strb);
			return -1;
		}
		if (strb == NULL)
		{
			g_free(stra);
			return 1;
		}
		res =  strcmp(stra, strb);
		g_free(stra);
		g_free(strb);
		return res;
	}
	else if (typa == G_TYPE_INT64 || typa == G_TYPE_INT || 
			typa == G_TYPE_BOOLEAN)
	{
		return ghb_value_int64(vala) - ghb_value_int64(valb);
	}
	else if (typa == G_TYPE_DOUBLE || typa == G_TYPE_FLOAT)
	{
		return ghb_value_double(vala) - ghb_value_double(valb);
	}
	else if (typa == ghb_array_get_type())
	{
		// Cheating here.  Just assume they are different.
		// Maybe later I'll recurse through these
		return 1;
	}
	else if (typa == ghb_dict_get_type())
	{
		// Cheating here.  Just assume they are different.
		// Maybe later I'll recurse through these
		return 1;
	}
	else
	{
		g_warning("ghb_value_cmp: unrecognized type");
		return 1;
	}
	return 0;
}